{"app_name":"Debian Janitor","binary_packages":["libnspr4-dbgsym","libnspr4-dev","libnspr4"],"branch_url":"git+ssh://git@salsa.debian.org/mozilla-team/nspr.git","build_distribution":"sid","build_log_highlight_lines":[1621,1627,1637,1643,1837,1843,1853,1859],"build_log_include_lines":[1844,1874],"build_log_line_count":8362,"build_log_name":"build.log","campaign":"control","change_set":"a54043ef-fdfa-4c26-a02a-915e77d04fd1","codebase":"nspr","codemod_log_name":"codemod.log","command":"brz up '--revision=git-v1:0ea5e81e77a9f849b4652916d89170cd6dffd82f'","current_year":"2026","description":"","is_admin":false,"lintian_result":{"groups":[{"group_id":"nspr_2:4.38.2-1~jan+control1","input_files":[{"hints":[],"path":"libnspr4-dbgsym_4.38.2-1~jan+control1_amd64.deb"},{"hints":[{"experimental":false,"note":"control != sid","pointer":{"item":{"index":"libnspr4-dev_4.38.2-1~jan+control1_amd64.deb (installed)","name":"usr/share/doc/libnspr4-dev/changelog.Debian.gz"},"line_position":1},"tag":"changelog-distribution-does-not-match-changes-file","visibility":"warning"},{"experimental":false,"note":"","pointer":{"item":{"index":"libnspr4-dev_4.38.2-1~jan+control1_amd64.deb (installed)","name":"usr/bin/nspr-config"},"line_position":0},"tag":"no-manual-page","visibility":"warning"}],"path":"libnspr4-dev_4.38.2-1~jan+control1_amd64.deb"},{"hints":[{"experimental":false,"note":"control != sid","pointer":{"item":{"index":"libnspr4_4.38.2-1~jan+control1_amd64.deb (installed)","name":"usr/share/doc/libnspr4/changelog.Debian.gz"},"line_position":1},"tag":"changelog-distribution-does-not-match-changes-file","visibility":"warning"},{"experimental":false,"note":"example: usr/lib/x86_64-linux-gnu/libnspr4.so","pointer":{"item":{"index":"libnspr4_4.38.2-1~jan+control1_amd64.deb (installed)","name":"usr/lib/x86_64-linux-gnu/libnspr4.so"},"line_position":0},"tag":"lacks-unversioned-link-to-shared-library","visibility":"warning"},{"experimental":false,"note":"example: usr/lib/x86_64-linux-gnu/libplc4.so","pointer":{"item":{"index":"libnspr4_4.38.2-1~jan+control1_amd64.deb (installed)","name":"usr/lib/x86_64-linux-gnu/libplc4.so"},"line_position":0},"tag":"lacks-unversioned-link-to-shared-library","visibility":"warning"},{"experimental":false,"note":"example: usr/lib/x86_64-linux-gnu/libplds4.so","pointer":{"item":{"index":"libnspr4_4.38.2-1~jan+control1_amd64.deb (installed)","name":"usr/lib/x86_64-linux-gnu/libplds4.so"},"line_position":0},"tag":"lacks-unversioned-link-to-shared-library","visibility":"warning"},{"experimental":false,"note":"lacks-unversioned-link-to-shared-library usr/lib/*/libnspr4.so usr/lib/*/libnspr4.so","pointer":{"item":{"index":"libnspr4_4.38.2-1~jan+control1_amd64.deb (installed)","name":"usr/share/lintian/overrides/libnspr4"},"line_position":9},"tag":"mismatched-override","visibility":"warning"},{"experimental":false,"note":"lacks-unversioned-link-to-shared-library usr/lib/*/libplc4.so usr/lib/*/libplc4.so","pointer":{"item":{"index":"libnspr4_4.38.2-1~jan+control1_amd64.deb (installed)","name":"usr/share/lintian/overrides/libnspr4"},"line_position":10},"tag":"mismatched-override","visibility":"warning"},{"experimental":false,"note":"lacks-unversioned-link-to-shared-library usr/lib/*/libplds4.so usr/lib/*/libplds4.so","pointer":{"item":{"index":"libnspr4_4.38.2-1~jan+control1_amd64.deb (installed)","name":"usr/share/lintian/overrides/libnspr4"},"line_position":11},"tag":"mismatched-override","visibility":"warning"}],"path":"libnspr4_4.38.2-1~jan+control1_amd64.deb"},{"hints":[{"experimental":false,"note":"","pointer":{"item":{"index":"nspr_4.38.2-1~jan+control1.dsc (patched)","name":"debian/changelog"},"line_position":1},"tag":"no-nmu-in-changelog","visibility":"warning"},{"experimental":false,"note":"2:4.38.2-1~jan+control1","pointer":{"item":{"index":"nspr_4.38.2-1~jan+control1.dsc (patched)","name":"debian/changelog"},"line_position":1},"tag":"source-nmu-has-incorrect-version-number","visibility":"warning"}],"path":"nspr_4.38.2-1~jan+control1.dsc"},{"hints":[],"path":"nspr_4.38.2-1~jan+control1_amd64.buildinfo"},{"hints":[{"experimental":false,"note":"sid control","tag":"distribution-and-changes-mismatch","visibility":"warning"}],"path":"nspr_4.38.2-1~jan+control1_amd64.changes"}],"source_name":"nspr","source_version":"2:4.38.2-1~jan+control1"}],"lintian_version":"2.143.0"},"logs":{"build":{"description":"build","name":"build.log","url":"/control/c/nspr/a54043ef-fdfa-4c26-a02a-915e77d04fd1/logs/build.log"},"codemod":{"description":"codemod","name":"codemod.log","url":"/control/c/nspr/a54043ef-fdfa-4c26-a02a-915e77d04fd1/logs/codemod.log"},"worker":{"content":"[2026-11-08T14:09:14Z INFO  janitor_worker] Opening branch at https://salsa.debian.org/mozilla-team/nspr.git\n[2026-11-08T14:09:16Z INFO  janitor_worker] Cached branch URL http://janitor.debian.net/git/nspr missing: http://janitor.debian.net/git/nspr/\n[2026-11-08T14:09:16Z DEBUG janitor_worker] Workspace path: /srv/worker/output/1/janitor-worker-YpG52Y/nspr\n[2026-11-08T14:09:16Z DEBUG silver_platter::workspace] Creating sprout from git+ssh://git@salsa.debian.org/mozilla-team/nspr.git\n  69% (280/405)\nTotal 7202 (delta 1479), reused 1897 (delta 1476), pack-reused 5290 (from 1)\n[2026-11-08T14:09:22Z DEBUG silver_platter::utils] Colocated branch experimental not found, skipping\n[2026-11-08T14:09:22Z DEBUG silver_platter::utils] Colocated branch vendor not found, skipping\n[2026-11-08T14:09:22Z DEBUG silver_platter::utils] Colocated branch pristine-tar not found, skipping\n[2026-11-08T14:09:22Z DEBUG silver_platter::utils] Colocated branch upstream not found, skipping\nNothing to delete.\n[2026-11-08T14:09:22Z DEBUG silver_platter::workspace] Fetching colocated branches: {\"vendor\": \"vendor\", \"upstream\": \"upstream\", \"pristine-tar\": \"pristine-tar\", \"experimental\": \"experimental\"}\n[2026-11-08T14:09:22Z INFO  janitor_worker] Workspace ready - starting.\n[2026-11-08T14:09:22Z INFO  janitor_worker::debian] Running [\"brz\", \"up\", \"--revision=git-v1:0ea5e81e77a9f849b4652916d89170cd6dffd82f\"]\n[2026-11-08T14:09:23Z DEBUG debian_analyzer::detect_gbp_dch] Branch history analysis: changelog_only: 12, other_only: 23, mixed: 3, dch_references: 0, unreleased_references: 0\n[2026-11-08T14:09:23Z INFO  silver_platter::debian::codemod] Assuming changelog does not need to be updated, since it never uses UNRELEASED entries\nfound 4458 deltas to reuse\n[2026-11-08T14:11:04Z INFO  ognibuild::debian::fix_build] Using fixers: [PgBuildExtOutOfDateControlFixer, MissingConfigureFixer, MissingAutomakeInputFixer, MissingConfigStatusInputFixer, MissingPerlFileFixer, DebcargoUnacceptablePredicateFixer, DebcargoUnacceptableComparatorFixer, RetryAptFetchFailure, PackageDependencyFixer]\n[2026-11-08T14:11:04Z DEBUG ognibuild::debian::build] Adding dummy changelog entry 2:4.38.2-1~jan+control1 for build\n[2026-11-08T14:11:04Z DEBUG ognibuild::debian::build] Writing build log to /srv/worker/output/1/janitor-worker-YpG52Y/build.log\n[2026-11-08T14:11:04Z INFO  ognibuild::debian::build] Building debian packages, running sbuild --chroot-mode=unshare --no-clean-source -A -s -v -d sid.\n[2026-11-08T14:17:26Z INFO  ognibuild::debian::build] Build succeeded.\n[2026-11-08T14:17:26Z INFO  janitor_worker::debian::build] Built [\"/srv/worker/output/1/janitor-worker-YpG52Y/nspr_4.38.2-1~jan+control1_amd64.buildinfo\", \"/srv/worker/output/1/janitor-worker-YpG52Y/nspr_4.38.2-1~jan+control1_amd64.changes\"].\n[2026-11-08T14:17:26Z DEBUG janitor_worker::debian::lintian] Running lintian: cd \"/srv/worker/output/1/janitor-worker-YpG52Y\" && \"lintian\" \"--exp-output=format=json\" \"--allow-root\" \"/srv/worker/output/1/janitor-worker-YpG52Y/nspr_4.38.2-1~jan+control1_amd64.buildinfo\" \"/srv/worker/output/1/janitor-worker-YpG52Y/nspr_4.38.2-1~jan+control1_amd64.changes\"\n[2026-11-08T14:17:31Z INFO  janitor_worker] Pushing result branch to http://janitor.debian.net/git/nspr\nfound 0 deltas to reuse\n[2026-11-08T14:17:32Z INFO  janitor_worker::vcs] Pushing packaging branch cache to http://janitor.debian.net/git/nspr,branch=debian%2Flatest\nfound 803 deltas to reuse\n03)\n79/803)\n[2026-11-08T14:17:33Z INFO  janitor_worker::vcs] Pushed packaging branch cache to http://janitor.debian.net/git/nspr,branch=debian%2Flatest\n","description":"worker","name":"worker.log","url":"/control/c/nspr/a54043ef-fdfa-4c26-a02a-915e77d04fd1/logs/worker.log"}},"my_review":null,"other_reviews":[],"primary_log":"worker","publish_history":[],"queue_position":1,"result_code":"success","resume_from":null,"reviews":[],"revision":"git-v1:0ea5e81e77a9f849b4652916d89170cd6dffd82f","run":{"branch_url":"git+ssh://git@salsa.debian.org/mozilla-team/nspr.git","build_version":null,"change_set":"a54043ef-fdfa-4c26-a02a-915e77d04fd1","codebase":"nspr","command":"brz up '--revision=git-v1:0ea5e81e77a9f849b4652916d89170cd6dffd82f'","context":null,"debian_build_distribution":"sid","debian_build_version":null,"description":"","duration_seconds":508,"failure_stage":null,"failure_transient":null,"finish_time":"2026-11-08T14:17:34.619561Z","id":"a54043ef-fdfa-4c26-a02a-915e77d04fd1","logfilenames":["worker.log","codemod.log","build.log"],"main_branch_revision":"git-v1:2353227fa67cfba62b545ac85764ba5ab9a2c199","publish_status":"needs-manual-review","result_branches":[{"absorbed":false,"base_revision":"git-v1:2353227fa67cfba62b545ac85764ba5ab9a2c199","diff":"diff --git a/debian/changelog b/debian/changelog\nindex 3f0fcd2..a050597 100644\n--- a/debian/changelog\n+++ b/debian/changelog\n@@ -1,15 +1,3 @@\n-nspr (2:4.40-1) unstable; urgency=medium\n-\n-  * New upstream release.\n-\n- -- Mike Hommey <glandium@debian.org>  Wed, 02 Sep 2026 11:17:14 +0900\n-\n-nspr (2:4.39-1) unstable; urgency=medium\n-\n-  * New upstream release.\n-\n- -- Mike Hommey <glandium@debian.org>  Wed, 22 Jul 2026 07:23:53 +0900\n-\n nspr (2:4.38.2-1) unstable; urgency=medium\n \n   * New upstream release.\ndiff --git a/nspr/.clang-format b/nspr/.clang-format\nindex 8ecf81e..37d82b9 100644\n--- a/nspr/.clang-format\n+++ b/nspr/.clang-format\n@@ -1,65 +1,14 @@\n----\n-# Keep in sync with NSS's\n-Language:        Cpp\n-AccessModifierOffset: -2\n-AlignAfterOpenBracket: true\n-AlignEscapedNewlinesLeft: false\n-AlignOperands:   true\n-AlignTrailingComments: true\n-AllowAllParametersOfDeclarationOnNextLine: false\n-AllowShortBlocksOnASingleLine: false\n-AllowShortCaseLabelsOnASingleLine: false\n-AllowShortIfStatementsOnASingleLine: false\n-AllowShortLoopsOnASingleLine: false\n-AllowShortFunctionsOnASingleLine: All\n-AlwaysBreakAfterDefinitionReturnType: true\n-AlwaysBreakTemplateDeclarations: false\n-AlwaysBreakBeforeMultilineStrings: false\n-BreakBeforeBinaryOperators: false\n-BreakBeforeTernaryOperators: true\n-BreakConstructorInitializersBeforeComma: false\n-BinPackParameters: true\n-BinPackArguments: true\n-ColumnLimit:     0\n-ConstructorInitializerAllOnOneLineOrOnePerLine: true\n-ConstructorInitializerIndentWidth: 4\n-DerivePointerAlignment: true\n-ExperimentalAutoDetectBinPacking: false\n-IndentCaseLabels: true\n-IndentWrappedFunctionNames: false\n-IndentFunctionDeclarationAfterType: false\n-MaxEmptyLinesToKeep: 1\n-KeepEmptyLinesAtTheStartOfBlocks: true\n-NamespaceIndentation: None\n-ObjCBlockIndentWidth: 2\n-ObjCSpaceAfterProperty: true\n-ObjCSpaceBeforeProtocolList: false\n-PenaltyBreakBeforeFirstCallParameter: 19\n-PenaltyBreakComment: 300\n-PenaltyBreakString: 1000\n-PenaltyBreakFirstLessLess: 120\n-PenaltyExcessCharacter: 1000000\n-PenaltyReturnTypeOnItsOwnLine: 200\n-PointerAlignment: Right\n-SpacesBeforeTrailingComments: 1\n-Cpp11BracedListStyle: false\n-Standard:        Cpp03\n-IndentWidth:     4\n-TabWidth:        8\n-UseTab:          Never\n-BreakBeforeBraces: Linux\n-SpacesInParentheses: false\n-SpacesInSquareBrackets: false\n-SpacesInAngles:  false\n-SpaceInEmptyParentheses: false\n-SpacesInCStyleCastParentheses: false\n-SpaceAfterCStyleCast: false\n-SpacesInContainerLiterals: true\n-SpaceBeforeAssignmentOperators: true\n-ContinuationIndentWidth: 4\n-CommentPragmas:  '^ IWYU pragma:'\n-ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]\n-SpaceBeforeParens: ControlStatements\n-DisableFormat:   false\n+BasedOnStyle: Google\n+ColumnLimit: 80\n+\n SortIncludes: false\n-...\n+IndentPPDirectives: AfterHash\n+\n+# The Google coding style states:\n+# You should do this consistently within a single file, so, when modifying an\n+# existing file, use the style in that file.\n+# Let's be more prescriptive and default to the one used in the Mozilla\n+# coding style\n+DerivePointerAlignment: false\n+PointerAlignment: Left\n+\ndiff --git a/nspr/.cvsignore b/nspr/.cvsignore\nnew file mode 100644\nindex 0000000..5a12c76\n--- /dev/null\n+++ b/nspr/.cvsignore\n@@ -0,0 +1,5 @@\n+Makefile\n+config-defs.h\n+config.cache\n+config.log\n+config.status\ndiff --git a/nspr/.editorconfig b/nspr/.editorconfig\ndeleted file mode 100644\nindex 9cb6ca9..0000000\n--- a/nspr/.editorconfig\n+++ /dev/null\n@@ -1,14 +0,0 @@\n-# https://editorconfig.org\n-root = true\n-\n-[*]\n-end_of_line = lf\n-charset = utf-8\n-trim_trailing_whitespace = true\n-insert_final_newline = true\n-\n-[*.{c,cpp,cc,cxx,h,hh,hpp,hxx,mm,m}]\n-indent_style = space\n-indent_size = 2\n-# Matches ColumnLimit in .clang-format\n-max_line_length = 80\ndiff --git a/nspr/.git-blame-ignore-revs b/nspr/.git-blame-ignore-revs\ndeleted file mode 100644\nindex 7bba23a..0000000\n--- a/nspr/.git-blame-ignore-revs\n+++ /dev/null\n@@ -1,3 +0,0 @@\n-39dd19cea29164528f3409c6a9756f6c80e7493c # Kai Engert - Bug 1581890 - remove whitespace from end of line in h/c/cpp. r=glandium\n-90e5436680a4539468751f2996e5b907a181d5cf # Kai Engert - Bug 1581890 - formatted code with artistic style utility. r=glandium\n-cc3e66d37a962a7acbd479729cfccee1b154eaef # Sylvestre Ledru - reformat the tree with clang-format\ndiff --git a/nspr/.github/workflows/ci.yml b/nspr/.github/workflows/ci.yml\ndeleted file mode 100644\nindex a5397f3..0000000\n--- a/nspr/.github/workflows/ci.yml\n+++ /dev/null\n@@ -1,224 +0,0 @@\n-name: CI\n-\n-on:\n-  push:\n-    branches: [main]\n-  pull_request:\n-  workflow_dispatch:\n-\n-jobs:\n-  unix:\n-    name: ${{ matrix.os }}${{ matrix.cc && format(' ({0})', matrix.cc) || '' }}\n-    runs-on: ${{ matrix.os }}\n-    strategy:\n-      fail-fast: false\n-      matrix:\n-        include:\n-          - os: ubuntu-latest\n-            cc: gcc\n-          - os: ubuntu-latest\n-            cc: clang\n-          - os: macos-latest\n-    steps:\n-      - uses: actions/checkout@v4\n-\n-      - name: Configure and build\n-        env:\n-          CC: ${{ matrix.cc }}\n-        run: |\n-          mkdir target\n-          cd target\n-          ../configure --enable-64bit --prefix=$PWD/dist\n-          make -j$(getconf _NPROCESSORS_ONLN)\n-\n-      - name: Build tests\n-        run: make -C target/pr/tests -j$(getconf _NPROCESSORS_ONLN)\n-\n-      - name: Run tests\n-        working-directory: target/pr/tests\n-        run: ../../../pr/tests/runtests.sh ../../dist\n-\n-  warnings-as-errors:\n-    name: ubuntu-latest (clang, -Wall -Werror)\n-    runs-on: ubuntu-latest\n-    continue-on-error: true\n-    steps:\n-      - uses: actions/checkout@v4\n-\n-      - name: Configure and build\n-        env:\n-          CC: clang\n-          CFLAGS: \"-Wall -Werror -Qunused-arguments\"\n-        run: |\n-          mkdir target\n-          cd target\n-          ../configure --enable-64bit --prefix=$PWD/dist\n-          make -j$(getconf _NPROCESSORS_ONLN)\n-\n-  clang-format:\n-    name: clang-format\n-    runs-on: ubuntu-latest\n-    steps:\n-      - uses: actions/checkout@v4\n-\n-      - name: Install clang-format\n-        run: sudo apt-get update && sudo apt-get install -y clang-format\n-\n-      - name: Check formatting (fails if not formatted)\n-        run: |\n-          files=$(find pr lib -type f \\( -name '*.c' -o -name '*.h' \\))\n-          clang-format --dry-run $files\n-\n-  ruff:\n-    name: ruff\n-    runs-on: ubuntu-latest\n-    steps:\n-      - uses: actions/checkout@v4\n-\n-      - name: Install ruff\n-        run: pipx install ruff\n-\n-      - name: Lint (ruff check)\n-        run: ruff check .\n-\n-      - name: Check formatting (ruff format)\n-        run: ruff format --check .\n-\n-  sanitizers:\n-    name: ubuntu-latest (clang, ASan+UBSan)\n-    runs-on: ubuntu-latest\n-    steps:\n-      - uses: actions/checkout@v4\n-\n-      - name: Configure and build\n-        env:\n-          CC: clang\n-          CFLAGS: \"-O1 -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=undefined\"\n-          LDFLAGS: \"-fsanitize=address,undefined\"\n-        run: |\n-          mkdir target\n-          cd target\n-          ../configure --enable-64bit --enable-debug --prefix=$PWD/dist\n-          make -j$(getconf _NPROCESSORS_ONLN)\n-\n-      - name: Build tests\n-        env:\n-          CC: clang\n-          CFLAGS: \"-O1 -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=undefined\"\n-          LDFLAGS: \"-fsanitize=address,undefined\"\n-        run: make -C target/pr/tests -j$(getconf _NPROCESSORS_ONLN)\n-\n-      - name: Run tests\n-        working-directory: target/pr/tests\n-        env:\n-          ASAN_OPTIONS: \"detect_leaks=1:abort_on_error=1:halt_on_error=1\"\n-          UBSAN_OPTIONS: \"print_stacktrace=1:halt_on_error=1\"\n-          LSAN_OPTIONS: \"suppressions=${{ github.workspace }}/build/sanitizers/lsan_suppressions.txt:print_suppressions=0\"\n-        run: ../../../pr/tests/runtests.sh ../../dist\n-\n-      - name: Build lib/tests\n-        env:\n-          CC: clang\n-          CFLAGS: \"-O1 -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=undefined\"\n-          LDFLAGS: \"-fsanitize=address,undefined\"\n-        run: make -C target/lib/tests -j$(getconf _NPROCESSORS_ONLN)\n-\n-      - name: Run lib/tests\n-        working-directory: target/lib/tests\n-        env:\n-          ASAN_OPTIONS: \"detect_leaks=1:abort_on_error=1:halt_on_error=1\"\n-          UBSAN_OPTIONS: \"print_stacktrace=1:halt_on_error=1\"\n-          LSAN_OPTIONS: \"suppressions=${{ github.workspace }}/build/sanitizers/lsan_suppressions.txt:print_suppressions=0\"\n-        run: |\n-          export LD_LIBRARY_PATH=\"$GITHUB_WORKSPACE/target/dist/lib:$LD_LIBRARY_PATH\"\n-          rval=0\n-          for prog in arena base64t getopt string; do\n-            printf 'Running %s\\n' \"$prog\"\n-            if ! ./\"$prog\"; then\n-              printf 'FAILED: %s\\n' \"$prog\"\n-              rval=1\n-            fi\n-          done\n-          exit $rval\n-\n-  coverage:\n-    name: ubuntu-latest (coverage)\n-    runs-on: ubuntu-latest\n-    steps:\n-      - uses: actions/checkout@v4\n-\n-      - name: Install lcov\n-        run: sudo apt-get update && sudo apt-get install -y lcov\n-\n-      - name: Configure and build with coverage\n-        env:\n-          CFLAGS: \"-O0 -g --coverage -fprofile-update=atomic\"\n-          CXXFLAGS: \"-O0 -g --coverage -fprofile-update=atomic\"\n-          LDFLAGS: \"--coverage\"\n-        run: |\n-          mkdir target\n-          cd target\n-          ../configure --enable-64bit --enable-debug --prefix=$PWD/dist\n-          make -j$(getconf _NPROCESSORS_ONLN)\n-\n-      - name: Build tests\n-        env:\n-          CFLAGS: \"-O0 -g --coverage -fprofile-update=atomic\"\n-          CXXFLAGS: \"-O0 -g --coverage -fprofile-update=atomic\"\n-          LDFLAGS: \"--coverage\"\n-        run: make -C target/pr/tests -j$(getconf _NPROCESSORS_ONLN) XCFLAGS=--coverage\n-\n-      - name: Run tests\n-        working-directory: target/pr/tests\n-        run: ../../../pr/tests/runtests.sh ../../dist\n-\n-      - name: Capture coverage\n-        run: |\n-          lcov --directory target --capture --output-file coverage.info \\\n-               --ignore-errors mismatch,negative,unused,gcov,source\n-          lcov --remove coverage.info '/usr/*' '*/pr/tests/*' --output-file coverage.info \\\n-               --ignore-errors unused\n-          lcov --list coverage.info\n-\n-      - name: Upload coverage to Codecov\n-        uses: codecov/codecov-action@v4\n-        with:\n-          files: coverage.info\n-          fail_ci_if_error: true\n-          token: ${{ secrets.CODECOV_TOKEN }}\n-\n-  windows:\n-    name: windows-latest\n-    runs-on: windows-latest\n-    steps:\n-      - uses: actions/checkout@v4\n-\n-      - name: Install MozillaBuild\n-        shell: pwsh\n-        run: |\n-          $url = 'https://ftp.mozilla.org/pub/mozilla/libraries/win32/MozillaBuildSetup-Latest.exe'\n-          Invoke-WebRequest -Uri $url -OutFile mb.exe\n-          Start-Process -FilePath .\\mb.exe -ArgumentList '/S' -Wait\n-\n-      - name: Write build script\n-        shell: bash\n-        run: |\n-          cat > build.sh <<'EOF'\n-          set -e\n-          export PATH=\"$(cygpath -u \"$VCToolsInstallDir\")bin/Hostx64/x64:$PATH\"\n-          mkdir target\n-          cd target\n-          ../configure --enable-64bit --enable-win32-target=WIN95 --prefix=$PWD/dist\n-          make -j$NUMBER_OF_PROCESSORS\n-          make -C pr/tests -j$NUMBER_OF_PROCESSORS\n-          cd pr/tests\n-          ../../../pr/tests/runtests.sh ../../dist\n-          EOF\n-\n-      - name: Build and test\n-        shell: cmd\n-        run: |\n-          for /f \"usebackq tokens=*\" %%i in (`\"%ProgramFiles(x86)%\\Microsoft Visual Studio\\Installer\\vswhere.exe\" -latest -property installationPath`) do set VSPATH=%%i\n-          call \"%VSPATH%\\VC\\Auxiliary\\Build\\vcvars64.bat\"\n-          set MOZILLABUILD=C:\\mozilla-build\\\n-          C:\\mozilla-build\\msys2\\msys2_shell.cmd -no-start -defterm -full-path -here -c \"bash build.sh\"\ndiff --git a/nspr/.github/workflows/nss.yml b/nspr/.github/workflows/nss.yml\ndeleted file mode 100644\nindex 98f0012..0000000\n--- a/nspr/.github/workflows/nss.yml\n+++ /dev/null\n@@ -1,32 +0,0 @@\n-name: NSS build\n-\n-on:\n-  push:\n-    branches: [main]\n-  pull_request:\n-  workflow_dispatch:\n-\n-jobs:\n-  build-nss:\n-    name: Build NSS against NSPR main\n-    runs-on: ubuntu-latest\n-    steps:\n-      - name: Checkout NSPR\n-        uses: actions/checkout@v4\n-        with:\n-          path: nspr\n-\n-      - name: Checkout NSS\n-        uses: actions/checkout@v4\n-        with:\n-          repository: nss-dev/nss\n-          path: nss\n-\n-      - name: Install build dependencies\n-        run: |\n-          sudo apt-get update\n-          sudo apt-get install -y mercurial gyp ninja-build zlib1g-dev\n-\n-      - name: Build NSS with sibling NSPR\n-        working-directory: nss\n-        run: ./build.sh -v --disable-tests\ndiff --git a/nspr/.hg-annotate-ignore-revs b/nspr/.hg-annotate-ignore-revs\nnew file mode 100644\nindex 0000000..317f838\n--- /dev/null\n+++ b/nspr/.hg-annotate-ignore-revs\n@@ -0,0 +1,2 @@\n+6856b110d025599a243f0b0128c7f39572a9ead0 - Kai Engert - Bug 1581890 - remove whitespace from end of line in h/c/cpp. r=glandium \n+b2e285dc48be27713b3c648de3cf33f8637a3e94 - Kai Engert - Bug 1581890 - formatted code with artistic style utility. r=glandium\ndiff --git a/nspr/.hg_archival.txt b/nspr/.hg_archival.txt\nnew file mode 100644\nindex 0000000..e85e2f2\n--- /dev/null\n+++ b/nspr/.hg_archival.txt\n@@ -0,0 +1,4 @@\n+repo: a4b34919bf34db2ee22acbbc305693c8980b6dc6\n+node: 7acb8859be67e8c1811d0ee8dc8a51710c1f3f58\n+branch: NSPR_4_38_BRANCH\n+tag: NSPR_4_38_2_RTM\ndiff --git a/nspr/.gitignore b/nspr/.hgignore\nsimilarity index 80%\nrename from nspr/.gitignore\nrename to nspr/.hgignore\nindex d35c565..c23f286 100644\n--- a/nspr/.gitignore\n+++ b/nspr/.hgignore\n@@ -1,3 +1,4 @@\n+syntax: glob\n *~\n *OPT.OBJ/*\n *DBG.OBJ/*\ndiff --git a/nspr/README.md b/nspr/README.md\ndeleted file mode 100644\nindex 7fba237..0000000\n--- a/nspr/README.md\n+++ /dev/null\n@@ -1,74 +0,0 @@\n-# NSPR — Netscape Portable Runtime\n-\n-[![CI](https://github.com/mozilla/nspr/actions/workflows/ci.yml/badge.svg)](https://github.com/mozilla/nspr/actions/workflows/ci.yml)\n-[![codecov](https://codecov.io/gh/mozilla/nspr/branch/main/graph/badge.svg)](https://codecov.io/gh/mozilla/nspr)\n-[![License: MPL 2.0](https://img.shields.io/badge/License-MPL_2.0-brightgreen.svg)](https://www.mozilla.org/en-US/MPL/2.0/)\n-\n-> [!WARNING]\n-> **NSPR is a legacy library (started in 1994!) and should not be used\n-> for new projects.**\n-> It predates modern C/C++ standards and the portable threading, I/O,\n-> time, and networking primitives now available in the standard library\n-> and the operating system. New code should rely on those instead\n-> (e.g. `<threads.h>` / `std::thread`, `<chrono>`, POSIX/Winsock APIs).\n-> NSPR is maintained primarily for the benefit of existing consumers\n-> such as [NSS](https://github.com/nss-dev/nss) and Firefox.\n-\n-NSPR (Netscape Portable Runtime) is a platform-neutral API that provides\n-system-level and libc-like functions. It gives applications a uniform\n-interface to non-GUI operating system facilities and is used by Mozilla\n-clients, Red Hat and Oracle server applications, and other software.\n-\n-NSPR is **functionally complete** and is in maintenance mode: updates\n-track changes in supported operating systems rather than adding new\n-features.\n-\n-## Features\n-\n-- **Threads** — a unified threading API across platforms ranging from\n-  those without native threads to those with sophisticated implementations.\n-- **Thread synchronization** — monitor-style mutual exclusion and\n-  condition variables, with Java-compatible reentrancy.\n-- **I/O** — an enhanced BSD-sockets model supporting layered, synchronous\n-  I/O with optional non-blocking behavior.\n-- **Network addresses** — manipulation of network addresses with a\n-  migration path between IPv4 and IPv6.\n-- **Time** — interval timers for timeouts and scheduling, plus calendar\n-  functions covering roughly year −30000 to year 30000.\n-- **Memory management** — `malloc`, `calloc`, `realloc`, `free`.\n-- **Shared library linking** — load and unload dynamic libraries.\n-\n-## Getting NSPR\n-\n-- **Windows** — build from source.\n-- **macOS** — install via [MacPorts](https://www.macports.org/) or\n-  [Homebrew](https://brew.sh/).\n-- **Debian / Ubuntu** — `sudo apt-get install libnspr4-dev`\n-- **openSUSE** — install `mozilla-nspr` (and `mozilla-nspr-devel` for\n-  headers) via `zypper` or YaST.\n-\n-## Building from source\n-\n-```sh\n-mkdir target && cd target\n-../configure\n-make\n-```\n-\n-## Running the test suite\n-\n-```sh\n-make -C target/pr/tests\n-cd target/pr/tests && ./runtests.sh\n-```\n-\n-## Related projects\n-\n-- [NSS](https://github.com/nss-dev/nss) — Network Security Services,\n-  built on top of NSPR.\n-\n-## License\n-\n-NSPR is licensed under the\n-[Mozilla Public License, version 2.0](https://www.mozilla.org/en-US/MPL/2.0/).\n-See [LICENSE](LICENSE) for details.\ndiff --git a/nspr/automation/release/nspr-release-helper.py b/nspr/automation/release/nspr-release-helper.py\nold mode 100755\nnew mode 100644\nindex 6529239..582854e\n--- a/nspr/automation/release/nspr-release-helper.py\n+++ b/nspr/automation/release/nspr-release-helper.py\n@@ -6,6 +6,9 @@\n \n import os\n import sys\n+import datetime\n+import shutil\n+import glob\n from optparse import OptionParser\n from subprocess import check_call\n \n@@ -13,15 +16,11 @@ prinit_h = \"pr/include/prinit.h\"\n f_conf = \"configure\"\n f_conf_in = \"configure.in\"\n \n-\n def check_call_noisy(cmd, *args, **kwargs):\n     print(\"Executing command:\", cmd)\n     check_call(cmd, *args, **kwargs)\n \n-\n-o = OptionParser(\n-    usage=\"client.py [options] remove_beta | set_beta | print_library_versions | set_version_to_minor_release | set_version_to_patch_release | create_nspr_release_archive\"\n-)\n+o = OptionParser(usage=\"client.py [options] remove_beta | set_beta | print_library_versions | set_version_to_minor_release | set_version_to_patch_release | create_nspr_release_archive\")\n \n try:\n     options, args = o.parse_args()\n@@ -30,47 +29,35 @@ except IndexError:\n     o.print_help()\n     sys.exit(2)\n \n-\n def exit_with_failure(what):\n     print(\"failure: \", what)\n     sys.exit(2)\n \n-\n def check_files_exist():\n-    if not os.path.exists(prinit_h):\n-        exit_with_failure(\n-            \"cannot find expected header files, must run from inside NSPR git directory\"\n-        )\n-\n+    if (not os.path.exists(prinit_h)):\n+        exit_with_failure(\"cannot find expected header files, must run from inside NSPR hg directory\")\n \n def sed_inplace(sed_expression, filename):\n-    backup_file = filename + \".tmp\"\n+    backup_file = filename + '.tmp'\n     check_call_noisy([\"sed\", \"-i.tmp\", sed_expression, filename])\n     os.remove(backup_file)\n \n-\n def toggle_beta_status(is_beta):\n     check_files_exist()\n-    if is_beta:\n+    if (is_beta):\n         print(\"adding Beta status to version numbers\")\n-        sed_inplace('s/^\\\\(#define *PR_VERSION *\"[0-9.]\\\\+\\\\)\" *$/\\\\1 Beta\"/', prinit_h)\n-        sed_inplace(\"s/^\\\\(#define *PR_BETA *\\\\)PR_FALSE *$/\\\\1PR_TRUE/\", prinit_h)\n+        sed_inplace('s/^\\\\(#define *PR_VERSION *\\\"[0-9.]\\\\+\\\\)\\\" *$/\\\\1 Beta\\\"/', prinit_h)\n+        sed_inplace('s/^\\\\(#define *PR_BETA *\\\\)PR_FALSE *$/\\\\1PR_TRUE/', prinit_h)\n \n     else:\n         print(\"removing Beta status from version numbers\")\n-        sed_inplace(\n-            's/^\\\\(#define *PR_VERSION *\"[0-9.]\\\\+\\\\) *Beta\" *$/\\\\1\"/', prinit_h\n-        )\n-        sed_inplace(\"s/^\\\\(#define *PR_BETA *\\\\)PR_TRUE *$/\\\\1PR_FALSE/\", prinit_h)\n-    print(\n-        \"please run 'git status' and 'git diff' to verify the files have been verified correctly\"\n-    )\n-\n+        sed_inplace('s/^\\\\(#define *PR_VERSION *\\\"[0-9.]\\\\+\\\\) *Beta\\\" *$/\\\\1\\\"/', prinit_h)\n+        sed_inplace('s/^\\\\(#define *PR_BETA *\\\\)PR_TRUE *$/\\\\1PR_FALSE/', prinit_h)\n+    print(\"please run 'hg stat' and 'hg diff' to verify the files have been verified correctly\")\n \n def print_beta_versions():\n     check_call_noisy([\"egrep\", \"#define *PR_VERSION|#define *PR_BETA\", prinit_h])\n \n-\n def remove_beta_status():\n     print(\"--- removing beta flags. Existing versions were:\")\n     print_beta_versions()\n@@ -78,7 +65,6 @@ def remove_beta_status():\n     print(\"--- finished modifications, new versions are:\")\n     print_beta_versions()\n \n-\n def set_beta_status():\n     print(\"--- adding beta flags. Existing versions were:\")\n     print_beta_versions()\n@@ -86,51 +72,31 @@ def set_beta_status():\n     print(\"--- finished modifications, new versions are:\")\n     print_beta_versions()\n \n-\n def print_library_versions():\n     check_files_exist()\n-    check_call_noisy(\n-        [\n-            \"egrep\",\n-            \"#define *PR_VERSION|#define PR_VMAJOR|#define *PR_VMINOR|#define *PR_VPATCH|#define *PR_BETA\",\n-            prinit_h,\n-        ]\n-    )\n-\n+    check_call_noisy([\"egrep\", \"#define *PR_VERSION|#define PR_VMAJOR|#define *PR_VMINOR|#define *PR_VPATCH|#define *PR_BETA\", prinit_h])\n \n def ensure_arguments_after_action(how_many, usage):\n-    if len(sys.argv) != (2 + how_many):\n-        exit_with_failure(\n-            \"incorrect number of arguments, expected parameters are:\\n\" + usage\n-        )\n-\n+    if (len(sys.argv) != (2+how_many)):\n+        exit_with_failure(\"incorrect number of arguments, expected parameters are:\\n\" + usage)\n \n def set_major_versions(major):\n-    sed_inplace(\"s/^\\\\(#define *PR_VMAJOR *\\\\).*$/\\\\1\" + major + \"/\", prinit_h)\n-    sed_inplace(\"s/^MOD_MAJOR_VERSION=.*$/MOD_MAJOR_VERSION=\" + major + \"/\", f_conf)\n-    sed_inplace(\"s/^MOD_MAJOR_VERSION=.*$/MOD_MAJOR_VERSION=\" + major + \"/\", f_conf_in)\n-\n+    sed_inplace('s/^\\\\(#define *PR_VMAJOR *\\\\).*$/\\\\1' + major + '/', prinit_h)\n+    sed_inplace('s/^MOD_MAJOR_VERSION=.*$/MOD_MAJOR_VERSION=' + major + '/', f_conf)\n+    sed_inplace('s/^MOD_MAJOR_VERSION=.*$/MOD_MAJOR_VERSION=' + major + '/', f_conf_in)\n \n def set_minor_versions(minor):\n-    sed_inplace(\"s/^\\\\(#define *PR_VMINOR *\\\\).*$/\\\\1\" + minor + \"/\", prinit_h)\n-    sed_inplace(\"s/^MOD_MINOR_VERSION=.*$/MOD_MINOR_VERSION=\" + minor + \"/\", f_conf)\n-    sed_inplace(\"s/^MOD_MINOR_VERSION=.*$/MOD_MINOR_VERSION=\" + minor + \"/\", f_conf_in)\n-\n+    sed_inplace('s/^\\\\(#define *PR_VMINOR *\\\\).*$/\\\\1' + minor + '/', prinit_h)\n+    sed_inplace('s/^MOD_MINOR_VERSION=.*$/MOD_MINOR_VERSION=' + minor + '/', f_conf)\n+    sed_inplace('s/^MOD_MINOR_VERSION=.*$/MOD_MINOR_VERSION=' + minor + '/', f_conf_in)\n \n def set_patch_versions(patch):\n-    sed_inplace(\"s/^\\\\(#define *PR_VPATCH *\\\\).*$/\\\\1\" + patch + \"/\", prinit_h)\n-    sed_inplace(\"s/^MOD_PATCH_VERSION=.*$/MOD_PATCH_VERSION=\" + patch + \"/\", f_conf)\n-    sed_inplace(\"s/^MOD_PATCH_VERSION=.*$/MOD_PATCH_VERSION=\" + patch + \"/\", f_conf_in)\n-\n+    sed_inplace('s/^\\\\(#define *PR_VPATCH *\\\\).*$/\\\\1' + patch + '/', prinit_h)\n+    sed_inplace('s/^MOD_PATCH_VERSION=.*$/MOD_PATCH_VERSION=' + patch + '/', f_conf)\n+    sed_inplace('s/^MOD_PATCH_VERSION=.*$/MOD_PATCH_VERSION=' + patch + '/', f_conf_in)\n \n def set_full_lib_versions(version):\n-    sed_inplace(\n-        's/^\\\\(#define *PR_VERSION *\"\\\\)\\\\([0-9.]\\\\+\\\\)\\\\(.*\\\\)$/\\\\1'\n-        + version\n-        + \"\\\\3/\",\n-        prinit_h,\n-    )\n-\n+    sed_inplace('s/^\\\\(#define *PR_VERSION *\\\"\\\\)\\\\([0-9.]\\\\+\\\\)\\\\(.*\\\\)$/\\\\1' + version + '\\\\3/', prinit_h)\n \n def set_all_lib_versions(version, major, minor, patch):\n     set_full_lib_versions(version)\n@@ -149,47 +115,35 @@ def set_all_lib_versions(version, major, minor, patch):\n     print(\"======== ATTENTION ========\")\n     print(\"===========================\")\n \n-\n def set_version_to_minor_release():\n     ensure_arguments_after_action(2, \"major_version  minor_version\")\n     major = args[1].strip()\n     minor = args[2].strip()\n-    version = major + \".\" + minor\n+    version = major + '.' + minor\n     patch = \"0\"\n     set_all_lib_versions(version, major, minor, patch)\n \n-\n def set_version_to_patch_release():\n     ensure_arguments_after_action(3, \"major_version  minor_version  patch_release\")\n     major = args[1].strip()\n     minor = args[2].strip()\n     patch = args[3].strip()\n-    version = major + \".\" + minor + \".\" + patch\n+    version = major + '.' + minor + '.' + patch\n     set_all_lib_versions(version, major, minor, patch)\n \n-\n def create_nspr_release_archive():\n-    ensure_arguments_after_action(2, \"nspr_release_version  nspr_git_release_tag\")\n-    nsprrel = args[1].strip()  # e.g. 4.10.9\n-    nsprreltag = args[2].strip()  # e.g. NSPR_4_10_9_RTM\n+    ensure_arguments_after_action(2, \"nspr_release_version  nspr_hg_release_tag\")\n+    nsprrel = args[1].strip() #e.g. 4.10.9\n+    nsprreltag = args[2].strip() #e.g. NSPR_4_10_9_RTM\n \n     nspr_tar = \"nspr-\" + nsprrel + \".tar.gz\"\n-    nspr_stagedir = \"../stage/v\" + nsprrel + \"/src\"\n-    if os.path.exists(nspr_stagedir):\n+    nspr_stagedir=\"../stage/v\" + nsprrel + \"/src\"\n+    if (os.path.exists(nspr_stagedir)):\n         exit_with_failure(\"nspr stage directory already exists: \" + nspr_stagedir)\n \n     check_call_noisy([\"mkdir\", \"-p\", nspr_stagedir])\n-    check_call_noisy(\n-        [\n-            \"git\",\n-            \"archive\",\n-            \"--format=tar.gz\",\n-            \"--prefix=nspr-\" + nsprrel + \"/nspr/\",\n-            \"-o\",\n-            \"../stage/v\" + nsprrel + \"/src/\" + nspr_tar,\n-            nsprreltag,\n-        ]\n-    )\n+    check_call_noisy([\"hg\", \"archive\", \"-r\", nsprreltag, \"--prefix=nspr-\" + nsprrel + \"/nspr\",\n+                      \"../stage/v\" + nsprrel + \"/src/\" + nspr_tar, \"-X\", \".hgtags\"])\n     print(\"changing to directory \" + nspr_stagedir)\n     os.chdir(nspr_stagedir)\n \n@@ -198,25 +152,24 @@ def create_nspr_release_archive():\n     print(\"created directory \" + nspr_stagedir + \" with files:\")\n     check_call_noisy([\"ls\", \"-l\"])\n \n-\n-if action in (\"remove_beta\"):\n+if action in ('remove_beta'):\n     remove_beta_status()\n \n-elif action in (\"set_beta\"):\n+elif action in ('set_beta'):\n     set_beta_status()\n \n-elif action in (\"print_library_versions\"):\n+elif action in ('print_library_versions'):\n     print_library_versions()\n \n # x.y version number - 2 parameters\n-elif action in (\"set_version_to_minor_release\"):\n+elif action in ('set_version_to_minor_release'):\n     set_version_to_minor_release()\n \n # x.y.z version number - 3 parameters\n-elif action in (\"set_version_to_patch_release\"):\n+elif action in ('set_version_to_patch_release'):\n     set_version_to_patch_release()\n \n-elif action in (\"create_nspr_release_archive\"):\n+elif action in ('create_nspr_release_archive'):\n     create_nspr_release_archive()\n \n else:\ndiff --git a/nspr/build/autoconf/README b/nspr/build/autoconf/README\nindex 66272f8..a7e52cc 100644\n--- a/nspr/build/autoconf/README\n+++ b/nspr/build/autoconf/README\n@@ -1,3 +1,3 @@\n The config.guess and config.sub scripts were downloaded from\n-http://git.savannah.gnu.org/cgit/config.git/tree/config.guess?id=428664896cf9e92d264976a960c76660938dffce\n-http://git.savannah.gnu.org/cgit/config.git/tree/config.sub?id=428664896cf9e92d264976a960c76660938dffce\n+http://git.savannah.gnu.org/cgit/config.git/tree/config.guess?id=2593751ef276497e312d7c4ce7fd049614c7bf80\n+http://git.savannah.gnu.org/cgit/config.git/tree/config.sub?id=2593751ef276497e312d7c4ce7fd049614c7bf80\ndiff --git a/nspr/build/autoconf/config.guess b/nspr/build/autoconf/config.guess\nindex c7f4c32..e94095c 100755\n--- a/nspr/build/autoconf/config.guess\n+++ b/nspr/build/autoconf/config.guess\n@@ -1,14 +1,12 @@\n #! /bin/sh\n # Attempt to guess a canonical system name.\n-#   Copyright 1992-2026 Free Software Foundation, Inc.\n+#   Copyright 1992-2020 Free Software Foundation, Inc.\n \n-# shellcheck disable=SC2006,SC2268 # see below for rationale\n-\n-timestamp='2026-05-17'\n+timestamp='2020-07-12'\n \n # This file is free software; you can redistribute it and/or modify it\n # under the terms of the GNU General Public License as published by\n-# the Free Software Foundation, either version 3 of the License, or\n+# the Free Software Foundation; either version 3 of the License, or\n # (at your option) any later version.\n #\n # This program is distributed in the hope that it will be useful, but\n@@ -29,25 +27,17 @@ timestamp='2026-05-17'\n # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.\n #\n # You can get the latest version of this script from:\n-# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess\n+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess\n #\n # Please send patches to <config-patches@gnu.org>.\n \n \n-# The \"shellcheck disable\" line above the timestamp inhibits complaints\n-# about features and limitations of the classic Bourne shell that were\n-# superseded or lifted in POSIX.  However, this script identifies a wide\n-# variety of pre-POSIX systems that do not have POSIX shells at all, and\n-# even some reasonably current systems (Solaris 10 as case-in-point) still\n-# have a pre-POSIX /bin/sh.\n-\n-\n me=`echo \"$0\" | sed -e 's,.*/,,'`\n \n usage=\"\\\n Usage: $0 [OPTION]\n \n-Output the configuration name of the system '$me' is run on.\n+Output the configuration name of the system \\`$me' is run on.\n \n Options:\n   -h, --help         print this help, then exit\n@@ -60,13 +50,13 @@ version=\"\\\n GNU config.guess ($timestamp)\n \n Originally written by Per Bothner.\n-Copyright 1992-2026 Free Software Foundation, Inc.\n+Copyright 1992-2020 Free Software Foundation, Inc.\n \n This is free software; see the source for copying conditions.  There is NO\n warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\"\n \n help=\"\n-Try '$me --help' for more information.\"\n+Try \\`$me --help' for more information.\"\n \n # Parse command line\n while test $# -gt 0 ; do\n@@ -94,16 +84,13 @@ if test $# != 0; then\n   exit 1\n fi\n \n-# Just in case it came from the environment.\n-GUESS=\n-\n # CC_FOR_BUILD -- compiler used by this script. Note that the use of a\n # compiler to aid in system detection is discouraged as it requires\n # temporary files to be created and, as you can see below, it is a\n # headache to deal with in a portable fashion.\n \n-# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still\n-# use 'HOST_CC' if defined, but it is deprecated.\n+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still\n+# use `HOST_CC' if defined, but it is deprecated.\n \n # Portable tmp directory creation inspired by the Autoconf team.\n \n@@ -115,7 +102,7 @@ set_cc_for_build() {\n     # prevent multiple calls if $tmp is already set\n     test \"$tmp\" && return 0\n     : \"${TMPDIR=/tmp}\"\n-    # shellcheck disable=SC2039,SC3028\n+    # shellcheck disable=SC2039\n     { tmp=`(umask 077 && mktemp -d \"$TMPDIR/cgXXXXXX\") 2>/dev/null` && test -n \"$tmp\" && test -d \"$tmp\" ; } ||\n \t{ test -n \"$RANDOM\" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir \"$tmp\" 2>/dev/null) ; } ||\n \t{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir \"$tmp\" 2>/dev/null) && echo \"Warning: creating insecure temp directory\" >&2 ; } ||\n@@ -123,9 +110,9 @@ set_cc_for_build() {\n     dummy=$tmp/dummy\n     case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in\n \t,,)    echo \"int x;\" > \"$dummy.c\"\n-\t       for driver in cc gcc c17 c99 c89 ; do\n+\t       for driver in cc gcc c89 c99 ; do\n \t\t   if ($driver -c -o \"$dummy.o\" \"$dummy.c\") >/dev/null 2>&1 ; then\n-\t\t       CC_FOR_BUILD=$driver\n+\t\t       CC_FOR_BUILD=\"$driver\"\n \t\t       break\n \t\t   fi\n \t       done\n@@ -146,59 +133,40 @@ fi\n \n UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown\n UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown\n-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown\n+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown\n UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown\n \n-case $UNAME_SYSTEM in\n-Ironclad|Linux|GNU|GNU/*)\n-\tLIBC=unknown\n+case \"$UNAME_SYSTEM\" in\n+Linux|GNU|GNU/*)\n+\t# If the system lacks a compiler, then just pick glibc.\n+\t# We could probably try harder.\n+\tLIBC=gnu\n \n \tset_cc_for_build\n \tcat <<-EOF > \"$dummy.c\"\n-\t#if defined(__ANDROID__)\n-\tLIBC=android\n-\t#else\n \t#include <features.h>\n \t#if defined(__UCLIBC__)\n \tLIBC=uclibc\n \t#elif defined(__dietlibc__)\n \tLIBC=dietlibc\n-\t#elif defined(__GLIBC__)\n-\tLIBC=gnu\n-\t#elif defined(__LLVM_LIBC__)\n-\tLIBC=llvm\n-\t#elif defined(__mlibc__)\n-\tLIBC=mlibc\n \t#else\n-\t#include <stdarg.h>\n-\t/* First heuristic to detect musl libc.  */\n-\t#ifdef __DEFINED_va_list\n-\tLIBC=musl\n-\t#endif\n-\t#endif\n+\tLIBC=gnu\n \t#endif\n \tEOF\n-\tcc_set_libc=`$CC_FOR_BUILD -E \"$dummy.c\" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`\n-\teval \"$cc_set_libc\"\n+\teval \"`$CC_FOR_BUILD -E \"$dummy.c\" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`\"\n \n-\t# Second heuristic to detect musl libc.\n-\tif [ \"$LIBC\" = unknown ] &&\n-\t   command -v ldd >/dev/null &&\n-\t   ldd --version 2>&1 | grep -q ^musl; then\n-\t\tLIBC=musl\n-\tfi\n-\n-\t# If the system lacks a compiler, then just pick glibc.\n-\t# We could probably try harder.\n-\tif [ \"$LIBC\" = unknown ]; then\n-\t\tLIBC=gnu\n+\t# If ldd exists, use it to detect musl libc.\n+\tif command -v ldd >/dev/null && \\\n+\t\tldd --version 2>&1 | grep -q ^musl\n+\tthen\n+\t    LIBC=musl\n \tfi\n \t;;\n esac\n \n # Note: order is significant - the case branches are not exclusive.\n \n-case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in\n+case \"$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION\" in\n     *:NetBSD:*:*)\n \t# NetBSD (nbsd) targets should (where applicable) match one or\n \t# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,\n@@ -210,12 +178,12 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in\n \t#\n \t# Note: NetBSD doesn't particularly care about the vendor\n \t# portion of the name.  We always set it to \"unknown\".\n+\tsysctl=\"sysctl -n hw.machine_arch\"\n \tUNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \\\n-\t    /sbin/sysctl -n hw.machine_arch 2>/dev/null || \\\n-\t    /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \\\n+\t    \"/sbin/$sysctl\" 2>/dev/null || \\\n+\t    \"/usr/sbin/$sysctl\" 2>/dev/null || \\\n \t    echo unknown)`\n-\tcase $UNAME_MACHINE_ARCH in\n-\t    aarch64eb) machine=aarch64_be-unknown ;;\n+\tcase \"$UNAME_MACHINE_ARCH\" in\n \t    armeb) machine=armeb-unknown ;;\n \t    arm*) machine=arm-unknown ;;\n \t    sh3el) machine=shl-unknown ;;\n@@ -224,13 +192,13 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in\n \t    earmv*)\n \t\tarch=`echo \"$UNAME_MACHINE_ARCH\" | sed -e 's,^e\\(armv[0-9]\\).*$,\\1,'`\n \t\tendian=`echo \"$UNAME_MACHINE_ARCH\" | sed -ne 's,^.*\\(eb\\)$,\\1,p'`\n-\t\tmachine=${arch}${endian}-unknown\n+\t\tmachine=\"${arch}${endian}\"-unknown\n \t\t;;\n-\t    *) machine=$UNAME_MACHINE_ARCH-unknown ;;\n+\t    *) machine=\"$UNAME_MACHINE_ARCH\"-unknown ;;\n \tesac\n \t# The Operating System including object format, if it has switched\n \t# to ELF recently (or will in the future) and ABI.\n-\tcase $UNAME_MACHINE_ARCH in\n+\tcase \"$UNAME_MACHINE_ARCH\" in\n \t    earm*)\n \t\tos=netbsdelf\n \t\t;;\n@@ -251,7 +219,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in\n \t\t;;\n \tesac\n \t# Determine ABI tags.\n-\tcase $UNAME_MACHINE_ARCH in\n+\tcase \"$UNAME_MACHINE_ARCH\" in\n \t    earm*)\n \t\texpr='s/^earmv[0-9]/-eabi/;s/eb$//'\n \t\tabi=`echo \"$UNAME_MACHINE_ARCH\" | sed -e \"$expr\"`\n@@ -262,7 +230,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in\n \t# thus, need a distinct triplet. However, they do not need\n \t# kernel version information, so it can be replaced with a\n \t# suitable tag, in the style of linux-gnu.\n-\tcase $UNAME_VERSION in\n+\tcase \"$UNAME_VERSION\" in\n \t    Debian*)\n \t\trelease='-gnu'\n \t\t;;\n@@ -273,57 +241,51 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in\n \t# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:\n \t# contains redundant information, the shorter form:\n \t# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.\n-\tGUESS=$machine-${os}${release}${abi-}\n-\t;;\n+\techo \"$machine-${os}${release}${abi-}\"\n+\texit ;;\n     *:Bitrig:*:*)\n \tUNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`\n-\tGUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_MACHINE_ARCH\"-unknown-bitrig\"$UNAME_RELEASE\"\n+\texit ;;\n     *:OpenBSD:*:*)\n \tUNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`\n-\tGUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE\n-\t;;\n-    *:SecBSD:*:*)\n-\tUNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`\n-\tGUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_MACHINE_ARCH\"-unknown-openbsd\"$UNAME_RELEASE\"\n+\texit ;;\n     *:LibertyBSD:*:*)\n \tUNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\\.//'`\n-\tGUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_MACHINE_ARCH\"-unknown-libertybsd\"$UNAME_RELEASE\"\n+\texit ;;\n     *:MidnightBSD:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-midnightbsd\"$UNAME_RELEASE\"\n+\texit ;;\n     *:ekkoBSD:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-ekkobsd\"$UNAME_RELEASE\"\n+\texit ;;\n     *:SolidBSD:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-solidbsd\"$UNAME_RELEASE\"\n+\texit ;;\n     *:OS108:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-os108_\"$UNAME_RELEASE\"\n+\texit ;;\n     macppc:MirBSD:*:*)\n-\tGUESS=powerpc-unknown-mirbsd$UNAME_RELEASE\n-\t;;\n+\techo powerpc-unknown-mirbsd\"$UNAME_RELEASE\"\n+\texit ;;\n     *:MirBSD:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-mirbsd\"$UNAME_RELEASE\"\n+\texit ;;\n     *:Sortix:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-sortix\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-sortix\n+\texit ;;\n     *:Twizzler:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-twizzler\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-twizzler\n+\texit ;;\n     *:Redox:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-redox\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-redox\n+\texit ;;\n     mips:OSF1:*.*)\n-\tGUESS=mips-dec-osf1\n-\t;;\n+\techo mips-dec-osf1\n+\texit ;;\n     alpha:OSF1:*:*)\n-\t# Reset EXIT trap before exiting to avoid spurious non-zero exit code.\n-\ttrap '' 0\n \tcase $UNAME_RELEASE in\n \t*4.0)\n \t\tUNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`\n@@ -337,7 +299,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in\n \t# covers most systems running today.  This code pipes the CPU\n \t# types through head -n 1, so we only detect the type of CPU 0.\n \tALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \\(.*\\) processor.*$/\\1/p' | head -n 1`\n-\tcase $ALPHA_CPU_TYPE in\n+\tcase \"$ALPHA_CPU_TYPE\" in\n \t    \"EV4 (21064)\")\n \t\tUNAME_MACHINE=alpha ;;\n \t    \"EV4.5 (21064)\")\n@@ -374,121 +336,117 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in\n \t# A Tn.n version is a released field test version.\n \t# A Xn.n version is an unreleased experimental baselevel.\n \t# 1.2 uses \"1.2\" for uname -r.\n-\tOSF_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`\n-\tGUESS=$UNAME_MACHINE-dec-osf$OSF_REL\n-\t;;\n+\techo \"$UNAME_MACHINE\"-dec-osf\"`echo \"$UNAME_RELEASE\" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`\"\n+\t# Reset EXIT trap before exiting to avoid spurious non-zero exit code.\n+\texitcode=$?\n+\ttrap '' 0\n+\texit $exitcode ;;\n     Amiga*:UNIX_System_V:4.0:*)\n-\tGUESS=m68k-unknown-sysv4\n-\t;;\n+\techo m68k-unknown-sysv4\n+\texit ;;\n     *:[Aa]miga[Oo][Ss]:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-amigaos\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-amigaos\n+\texit ;;\n     *:[Mm]orph[Oo][Ss]:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-morphos\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-morphos\n+\texit ;;\n     *:OS/390:*:*)\n-\tGUESS=i370-ibm-openedition\n-\t;;\n+\techo i370-ibm-openedition\n+\texit ;;\n     *:z/VM:*:*)\n-\tGUESS=s390-ibm-zvmoe\n-\t;;\n+\techo s390-ibm-zvmoe\n+\texit ;;\n     *:OS400:*:*)\n-\tGUESS=powerpc-ibm-os400\n-\t;;\n+\techo powerpc-ibm-os400\n+\texit ;;\n     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)\n-\tGUESS=arm-acorn-riscix$UNAME_RELEASE\n-\t;;\n+\techo arm-acorn-riscix\"$UNAME_RELEASE\"\n+\texit ;;\n     arm*:riscos:*:*|arm*:RISCOS:*:*)\n-\tGUESS=arm-unknown-riscos\n-\t;;\n+\techo arm-unknown-riscos\n+\texit ;;\n     SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)\n-\tGUESS=hppa1.1-hitachi-hiuxmpp\n-\t;;\n+\techo hppa1.1-hitachi-hiuxmpp\n+\texit ;;\n     Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)\n \t# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.\n-\tcase `(/bin/universe) 2>/dev/null` in\n-\t    att) GUESS=pyramid-pyramid-sysv3 ;;\n-\t    *)   GUESS=pyramid-pyramid-bsd   ;;\n-\tesac\n-\t;;\n+\tif test \"`(/bin/universe) 2>/dev/null`\" = att ; then\n+\t\techo pyramid-pyramid-sysv3\n+\telse\n+\t\techo pyramid-pyramid-bsd\n+\tfi\n+\texit ;;\n     NILE*:*:*:dcosx)\n-\tGUESS=pyramid-pyramid-svr4\n-\t;;\n+\techo pyramid-pyramid-svr4\n+\texit ;;\n     DRS?6000:unix:4.0:6*)\n-\tGUESS=sparc-icl-nx6\n-\t;;\n+\techo sparc-icl-nx6\n+\texit ;;\n     DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)\n \tcase `/usr/bin/uname -p` in\n-\t    sparc) GUESS=sparc-icl-nx7 ;;\n-\tesac\n-\t;;\n+\t    sparc) echo sparc-icl-nx7; exit ;;\n+\tesac ;;\n     s390x:SunOS:*:*)\n-\tSUN_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/[^.]*//'`\n-\tGUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL\n-\t;;\n+\techo \"$UNAME_MACHINE\"-ibm-solaris2\"`echo \"$UNAME_RELEASE\" | sed -e 's/[^.]*//'`\"\n+\texit ;;\n     sun4H:SunOS:5.*:*)\n-\tSUN_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/[^.]*//'`\n-\tGUESS=sparc-hal-solaris2$SUN_REL\n-\t;;\n+\techo sparc-hal-solaris2\"`echo \"$UNAME_RELEASE\"|sed -e 's/[^.]*//'`\"\n+\texit ;;\n     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)\n-\tSUN_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/[^.]*//'`\n-\tGUESS=sparc-sun-solaris2$SUN_REL\n-\t;;\n+\techo sparc-sun-solaris2\"`echo \"$UNAME_RELEASE\" | sed -e 's/[^.]*//'`\"\n+\texit ;;\n     i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)\n-\tGUESS=i386-pc-auroraux$UNAME_RELEASE\n-\t;;\n+\techo i386-pc-auroraux\"$UNAME_RELEASE\"\n+\texit ;;\n     i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)\n \tset_cc_for_build\n \tSUN_ARCH=i386\n \t# If there is a compiler, see if it is configured for 64-bit objects.\n \t# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.\n \t# This test works for both compilers.\n-\tif test \"$CC_FOR_BUILD\" != no_compiler_found; then\n+\tif [ \"$CC_FOR_BUILD\" != no_compiler_found ]; then\n \t    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \\\n-\t\t(CCOPTS=\"\" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \\\n+\t\t(CCOPTS=\"\" $CC_FOR_BUILD -E - 2>/dev/null) | \\\n \t\tgrep IS_64BIT_ARCH >/dev/null\n \t    then\n \t\tSUN_ARCH=x86_64\n \t    fi\n \tfi\n-\tSUN_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/[^.]*//'`\n-\tGUESS=$SUN_ARCH-pc-solaris2$SUN_REL\n-\t;;\n+\techo \"$SUN_ARCH\"-pc-solaris2\"`echo \"$UNAME_RELEASE\"|sed -e 's/[^.]*//'`\"\n+\texit ;;\n     sun4*:SunOS:6*:*)\n \t# According to config.sub, this is the proper way to canonicalize\n \t# SunOS6.  Hard to guess exactly what SunOS6 will be like, but\n \t# it's likely to be more like Solaris than SunOS4.\n-\tSUN_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/[^.]*//'`\n-\tGUESS=sparc-sun-solaris3$SUN_REL\n-\t;;\n+\techo sparc-sun-solaris3\"`echo \"$UNAME_RELEASE\"|sed -e 's/[^.]*//'`\"\n+\texit ;;\n     sun4*:SunOS:*:*)\n-\tcase `/usr/bin/arch -k` in\n+\tcase \"`/usr/bin/arch -k`\" in\n \t    Series*|S4*)\n \t\tUNAME_RELEASE=`uname -v`\n \t\t;;\n \tesac\n-\t# Japanese Language versions have a version number like '4.1.3-JL'.\n-\tSUN_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/-/_/'`\n-\tGUESS=sparc-sun-sunos$SUN_REL\n-\t;;\n+\t# Japanese Language versions have a version number like `4.1.3-JL'.\n+\techo sparc-sun-sunos\"`echo \"$UNAME_RELEASE\"|sed -e 's/-/_/'`\"\n+\texit ;;\n     sun3*:SunOS:*:*)\n-\tGUESS=m68k-sun-sunos$UNAME_RELEASE\n-\t;;\n+\techo m68k-sun-sunos\"$UNAME_RELEASE\"\n+\texit ;;\n     sun*:*:4.2BSD:*)\n \tUNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`\n \ttest \"x$UNAME_RELEASE\" = x && UNAME_RELEASE=3\n-\tcase `/bin/arch` in\n+\tcase \"`/bin/arch`\" in\n \t    sun3)\n-\t\tGUESS=m68k-sun-sunos$UNAME_RELEASE\n+\t\techo m68k-sun-sunos\"$UNAME_RELEASE\"\n \t\t;;\n \t    sun4)\n-\t\tGUESS=sparc-sun-sunos$UNAME_RELEASE\n+\t\techo sparc-sun-sunos\"$UNAME_RELEASE\"\n \t\t;;\n \tesac\n-\t;;\n+\texit ;;\n     aushp:SunOS:*:*)\n-\tGUESS=sparc-auspex-sunos$UNAME_RELEASE\n-\t;;\n+\techo sparc-auspex-sunos\"$UNAME_RELEASE\"\n+\texit ;;\n     # The situation for MiNT is a little confusing.  The machine name\n     # can be virtually everything (everything which is not\n     # \"atarist\" or \"atariste\" at least should have a processor\n@@ -498,41 +456,41 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in\n     # MiNT.  But MiNT is downward compatible to TOS, so this should\n     # be no problem.\n     atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)\n-\tGUESS=m68k-atari-mint$UNAME_RELEASE\n-\t;;\n+\techo m68k-atari-mint\"$UNAME_RELEASE\"\n+\texit ;;\n     atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)\n-\tGUESS=m68k-atari-mint$UNAME_RELEASE\n-\t;;\n+\techo m68k-atari-mint\"$UNAME_RELEASE\"\n+\texit ;;\n     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)\n-\tGUESS=m68k-atari-mint$UNAME_RELEASE\n-\t;;\n+\techo m68k-atari-mint\"$UNAME_RELEASE\"\n+\texit ;;\n     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)\n-\tGUESS=m68k-milan-mint$UNAME_RELEASE\n-\t;;\n+\techo m68k-milan-mint\"$UNAME_RELEASE\"\n+\texit ;;\n     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)\n-\tGUESS=m68k-hades-mint$UNAME_RELEASE\n-\t;;\n+\techo m68k-hades-mint\"$UNAME_RELEASE\"\n+\texit ;;\n     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)\n-\tGUESS=m68k-unknown-mint$UNAME_RELEASE\n-\t;;\n+\techo m68k-unknown-mint\"$UNAME_RELEASE\"\n+\texit ;;\n     m68k:machten:*:*)\n-\tGUESS=m68k-apple-machten$UNAME_RELEASE\n-\t;;\n+\techo m68k-apple-machten\"$UNAME_RELEASE\"\n+\texit ;;\n     powerpc:machten:*:*)\n-\tGUESS=powerpc-apple-machten$UNAME_RELEASE\n-\t;;\n+\techo powerpc-apple-machten\"$UNAME_RELEASE\"\n+\texit ;;\n     RISC*:Mach:*:*)\n-\tGUESS=mips-dec-mach_bsd4.3\n-\t;;\n+\techo mips-dec-mach_bsd4.3\n+\texit ;;\n     RISC*:ULTRIX:*:*)\n-\tGUESS=mips-dec-ultrix$UNAME_RELEASE\n-\t;;\n+\techo mips-dec-ultrix\"$UNAME_RELEASE\"\n+\texit ;;\n     VAX*:ULTRIX*:*:*)\n-\tGUESS=vax-dec-ultrix$UNAME_RELEASE\n-\t;;\n+\techo vax-dec-ultrix\"$UNAME_RELEASE\"\n+\texit ;;\n     2020:CLIX:*:* | 2430:CLIX:*:*)\n-\tGUESS=clipper-intergraph-clix$UNAME_RELEASE\n-\t;;\n+\techo clipper-intergraph-clix\"$UNAME_RELEASE\"\n+\texit ;;\n     mips:*:*:UMIPS | mips:*:*:RISCos)\n \tset_cc_for_build\n \tsed 's/^\t//' << EOF > \"$dummy.c\"\n@@ -560,84 +518,82 @@ EOF\n \t  dummyarg=`echo \"$UNAME_RELEASE\" | sed -n 's/\\([0-9]*\\).*/\\1/p'` &&\n \t  SYSTEM_NAME=`\"$dummy\" \"$dummyarg\"` &&\n \t    { echo \"$SYSTEM_NAME\"; exit; }\n-\tGUESS=mips-mips-riscos$UNAME_RELEASE\n-\t;;\n+\techo mips-mips-riscos\"$UNAME_RELEASE\"\n+\texit ;;\n     Motorola:PowerMAX_OS:*:*)\n-\tGUESS=powerpc-motorola-powermax\n-\t;;\n+\techo powerpc-motorola-powermax\n+\texit ;;\n     Motorola:*:4.3:PL8-*)\n-\tGUESS=powerpc-harris-powermax\n-\t;;\n+\techo powerpc-harris-powermax\n+\texit ;;\n     Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)\n-\tGUESS=powerpc-harris-powermax\n-\t;;\n+\techo powerpc-harris-powermax\n+\texit ;;\n     Night_Hawk:Power_UNIX:*:*)\n-\tGUESS=powerpc-harris-powerunix\n-\t;;\n+\techo powerpc-harris-powerunix\n+\texit ;;\n     m88k:CX/UX:7*:*)\n-\tGUESS=m88k-harris-cxux7\n-\t;;\n+\techo m88k-harris-cxux7\n+\texit ;;\n     m88k:*:4*:R4*)\n-\tGUESS=m88k-motorola-sysv4\n-\t;;\n+\techo m88k-motorola-sysv4\n+\texit ;;\n     m88k:*:3*:R3*)\n-\tGUESS=m88k-motorola-sysv3\n-\t;;\n+\techo m88k-motorola-sysv3\n+\texit ;;\n     AViiON:dgux:*:*)\n \t# DG/UX returns AViiON for all architectures\n \tUNAME_PROCESSOR=`/usr/bin/uname -p`\n-\tif test \"$UNAME_PROCESSOR\" = mc88100 || test \"$UNAME_PROCESSOR\" = mc88110\n+\tif [ \"$UNAME_PROCESSOR\" = mc88100 ] || [ \"$UNAME_PROCESSOR\" = mc88110 ]\n \tthen\n-\t    if test \"$TARGET_BINARY_INTERFACE\"x = m88kdguxelfx || \\\n-\t       test \"$TARGET_BINARY_INTERFACE\"x = x\n+\t    if [ \"$TARGET_BINARY_INTERFACE\"x = m88kdguxelfx ] || \\\n+\t       [ \"$TARGET_BINARY_INTERFACE\"x = x ]\n \t    then\n-\t\tGUESS=m88k-dg-dgux$UNAME_RELEASE\n+\t\techo m88k-dg-dgux\"$UNAME_RELEASE\"\n \t    else\n-\t\tGUESS=m88k-dg-dguxbcs$UNAME_RELEASE\n+\t\techo m88k-dg-dguxbcs\"$UNAME_RELEASE\"\n \t    fi\n \telse\n-\t    GUESS=i586-dg-dgux$UNAME_RELEASE\n+\t    echo i586-dg-dgux\"$UNAME_RELEASE\"\n \tfi\n-\t;;\n+\texit ;;\n     M88*:DolphinOS:*:*)\t# DolphinOS (SVR3)\n-\tGUESS=m88k-dolphin-sysv3\n-\t;;\n+\techo m88k-dolphin-sysv3\n+\texit ;;\n     M88*:*:R3*:*)\n \t# Delta 88k system running SVR3\n-\tGUESS=m88k-motorola-sysv3\n-\t;;\n+\techo m88k-motorola-sysv3\n+\texit ;;\n     XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)\n-\tGUESS=m88k-tektronix-sysv3\n-\t;;\n+\techo m88k-tektronix-sysv3\n+\texit ;;\n     Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)\n-\tGUESS=m68k-tektronix-bsd\n-\t;;\n+\techo m68k-tektronix-bsd\n+\texit ;;\n     *:IRIX*:*:*)\n-\tIRIX_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/-/_/g'`\n-\tGUESS=mips-sgi-irix$IRIX_REL\n-\t;;\n+\techo mips-sgi-irix\"`echo \"$UNAME_RELEASE\"|sed -e 's/-/_/g'`\"\n+\texit ;;\n     ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.\n-\tGUESS=romp-ibm-aix    # uname -m gives an 8 hex-code CPU id\n-\t;;                    # Note that: echo \"'`uname -s`'\" gives 'AIX '\n+\techo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id\n+\texit ;;               # Note that: echo \"'`uname -s`'\" gives 'AIX '\n     i*86:AIX:*:*)\n-\tGUESS=i386-ibm-aix\n-\t;;\n+\techo i386-ibm-aix\n+\texit ;;\n     ia64:AIX:*:*)\n-\tif test -x /usr/bin/oslevel ; then\n+\tif [ -x /usr/bin/oslevel ] ; then\n \t\tIBM_REV=`/usr/bin/oslevel`\n \telse\n-\t\tIBM_REV=$UNAME_VERSION.$UNAME_RELEASE\n+\t\tIBM_REV=\"$UNAME_VERSION.$UNAME_RELEASE\"\n \tfi\n-\tGUESS=$UNAME_MACHINE-ibm-aix$IBM_REV\n-\t;;\n+\techo \"$UNAME_MACHINE\"-ibm-aix\"$IBM_REV\"\n+\texit ;;\n     *:AIX:2:3)\n \tif grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then\n \t\tset_cc_for_build\n \t\tsed 's/^\t\t//' << EOF > \"$dummy.c\"\n \t\t#include <sys/systemcfg.h>\n \n-\t\tint\n-\t\tmain ()\n+\t\tmain()\n \t\t\t{\n \t\t\tif (!__power_pc())\n \t\t\t\texit(1);\n@@ -647,16 +603,16 @@ EOF\n EOF\n \t\tif $CC_FOR_BUILD -o \"$dummy\" \"$dummy.c\" && SYSTEM_NAME=`\"$dummy\"`\n \t\tthen\n-\t\t\tGUESS=$SYSTEM_NAME\n+\t\t\techo \"$SYSTEM_NAME\"\n \t\telse\n-\t\t\tGUESS=rs6000-ibm-aix3.2.5\n+\t\t\techo rs6000-ibm-aix3.2.5\n \t\tfi\n \telif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then\n-\t\tGUESS=rs6000-ibm-aix3.2.4\n+\t\techo rs6000-ibm-aix3.2.4\n \telse\n-\t\tGUESS=rs6000-ibm-aix3.2\n+\t\techo rs6000-ibm-aix3.2\n \tfi\n-\t;;\n+\texit ;;\n     *:AIX:*:[4567])\n \tIBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`\n \tif /usr/sbin/lsattr -El \"$IBM_CPU_ID\" | grep ' POWER' >/dev/null 2>&1; then\n@@ -664,56 +620,56 @@ EOF\n \telse\n \t\tIBM_ARCH=powerpc\n \tfi\n-\tif test -x /usr/bin/lslpp ; then\n-\t\tIBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \\\n+\tif [ -x /usr/bin/lslpp ] ; then\n+\t\tIBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |\n \t\t\t   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`\n \telse\n-\t\tIBM_REV=$UNAME_VERSION.$UNAME_RELEASE\n+\t\tIBM_REV=\"$UNAME_VERSION.$UNAME_RELEASE\"\n \tfi\n-\tGUESS=$IBM_ARCH-ibm-aix$IBM_REV\n-\t;;\n+\techo \"$IBM_ARCH\"-ibm-aix\"$IBM_REV\"\n+\texit ;;\n     *:AIX:*:*)\n-\tGUESS=rs6000-ibm-aix\n-\t;;\n+\techo rs6000-ibm-aix\n+\texit ;;\n     ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)\n-\tGUESS=romp-ibm-bsd4.4\n-\t;;\n+\techo romp-ibm-bsd4.4\n+\texit ;;\n     ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and\n-\tGUESS=romp-ibm-bsd$UNAME_RELEASE    # 4.3 with uname added to\n-\t;;                                  # report: romp-ibm BSD 4.3\n+\techo romp-ibm-bsd\"$UNAME_RELEASE\"   # 4.3 with uname added to\n+\texit ;;                             # report: romp-ibm BSD 4.3\n     *:BOSX:*:*)\n-\tGUESS=rs6000-bull-bosx\n-\t;;\n+\techo rs6000-bull-bosx\n+\texit ;;\n     DPX/2?00:B.O.S.:*:*)\n-\tGUESS=m68k-bull-sysv3\n-\t;;\n+\techo m68k-bull-sysv3\n+\texit ;;\n     9000/[34]??:4.3bsd:1.*:*)\n-\tGUESS=m68k-hp-bsd\n-\t;;\n+\techo m68k-hp-bsd\n+\texit ;;\n     hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)\n-\tGUESS=m68k-hp-bsd4.4\n-\t;;\n+\techo m68k-hp-bsd4.4\n+\texit ;;\n     9000/[34678]??:HP-UX:*:*)\n-\tHPUX_REV=`echo \"$UNAME_RELEASE\" | sed -e 's/[^.]*.[0B]*//'`\n-\tcase $UNAME_MACHINE in\n+\tHPUX_REV=`echo \"$UNAME_RELEASE\"|sed -e 's/[^.]*.[0B]*//'`\n+\tcase \"$UNAME_MACHINE\" in\n \t    9000/31?)            HP_ARCH=m68000 ;;\n \t    9000/[34]??)         HP_ARCH=m68k ;;\n \t    9000/[678][0-9][0-9])\n-\t\tif test -x /usr/bin/getconf; then\n+\t\tif [ -x /usr/bin/getconf ]; then\n \t\t    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`\n \t\t    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`\n-\t\t    case $sc_cpu_version in\n+\t\t    case \"$sc_cpu_version\" in\n \t\t      523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0\n \t\t      528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1\n \t\t      532)                      # CPU_PA_RISC2_0\n-\t\t\tcase $sc_kernel_bits in\n+\t\t\tcase \"$sc_kernel_bits\" in\n \t\t\t  32) HP_ARCH=hppa2.0n ;;\n \t\t\t  64) HP_ARCH=hppa2.0w ;;\n \t\t\t  '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20\n \t\t\tesac ;;\n \t\t    esac\n \t\tfi\n-\t\tif test \"$HP_ARCH\" = \"\"; then\n+\t\tif [ \"$HP_ARCH\" = \"\" ]; then\n \t\t    set_cc_for_build\n \t\t    sed 's/^\t\t//' << EOF > \"$dummy.c\"\n \n@@ -721,8 +677,7 @@ EOF\n \t\t#include <stdlib.h>\n \t\t#include <unistd.h>\n \n-\t\tint\n-\t\tmain ()\n+\t\tint main ()\n \t\t{\n \t\t#if defined(_SC_KERNEL_BITS)\n \t\t    long bits = sysconf(_SC_KERNEL_BITS);\n@@ -753,7 +708,7 @@ EOF\n \t\t    test -z \"$HP_ARCH\" && HP_ARCH=hppa\n \t\tfi ;;\n \tesac\n-\tif test \"$HP_ARCH\" = hppa2.0w\n+\tif [ \"$HP_ARCH\" = hppa2.0w ]\n \tthen\n \t    set_cc_for_build\n \n@@ -774,12 +729,12 @@ EOF\n \t\tHP_ARCH=hppa64\n \t    fi\n \tfi\n-\tGUESS=$HP_ARCH-hp-hpux$HPUX_REV\n-\t;;\n+\techo \"$HP_ARCH\"-hp-hpux\"$HPUX_REV\"\n+\texit ;;\n     ia64:HP-UX:*:*)\n-\tHPUX_REV=`echo \"$UNAME_RELEASE\" | sed -e 's/[^.]*.[0B]*//'`\n-\tGUESS=ia64-hp-hpux$HPUX_REV\n-\t;;\n+\tHPUX_REV=`echo \"$UNAME_RELEASE\"|sed -e 's/[^.]*.[0B]*//'`\n+\techo ia64-hp-hpux\"$HPUX_REV\"\n+\texit ;;\n     3050*:HI-UX:*:*)\n \tset_cc_for_build\n \tsed 's/^\t//' << EOF > \"$dummy.c\"\n@@ -809,36 +764,36 @@ EOF\n EOF\n \t$CC_FOR_BUILD -o \"$dummy\" \"$dummy.c\" && SYSTEM_NAME=`\"$dummy\"` &&\n \t\t{ echo \"$SYSTEM_NAME\"; exit; }\n-\tGUESS=unknown-hitachi-hiuxwe2\n-\t;;\n+\techo unknown-hitachi-hiuxwe2\n+\texit ;;\n     9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)\n-\tGUESS=hppa1.1-hp-bsd\n-\t;;\n+\techo hppa1.1-hp-bsd\n+\texit ;;\n     9000/8??:4.3bsd:*:*)\n-\tGUESS=hppa1.0-hp-bsd\n-\t;;\n+\techo hppa1.0-hp-bsd\n+\texit ;;\n     *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)\n-\tGUESS=hppa1.0-hp-mpeix\n-\t;;\n+\techo hppa1.0-hp-mpeix\n+\texit ;;\n     hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)\n-\tGUESS=hppa1.1-hp-osf\n-\t;;\n+\techo hppa1.1-hp-osf\n+\texit ;;\n     hp8??:OSF1:*:*)\n-\tGUESS=hppa1.0-hp-osf\n-\t;;\n+\techo hppa1.0-hp-osf\n+\texit ;;\n     i*86:OSF1:*:*)\n-\tif test -x /usr/sbin/sysversion ; then\n-\t    GUESS=$UNAME_MACHINE-unknown-osf1mk\n+\tif [ -x /usr/sbin/sysversion ] ; then\n+\t    echo \"$UNAME_MACHINE\"-unknown-osf1mk\n \telse\n-\t    GUESS=$UNAME_MACHINE-unknown-osf1\n+\t    echo \"$UNAME_MACHINE\"-unknown-osf1\n \tfi\n-\t;;\n+\texit ;;\n     parisc*:Lites*:*:*)\n-\tGUESS=hppa1.1-hp-lites\n-\t;;\n+\techo hppa1.1-hp-lites\n+\texit ;;\n     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)\n-\tGUESS=c1-convex-bsd\n-\t;;\n+\techo c1-convex-bsd\n+\texit ;;\n     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)\n \tif getsysinfo -f scalar_acc\n \tthen echo c32-convex-bsd\n@@ -846,18 +801,17 @@ EOF\n \tfi\n \texit ;;\n     C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)\n-\tGUESS=c34-convex-bsd\n-\t;;\n+\techo c34-convex-bsd\n+\texit ;;\n     C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)\n-\tGUESS=c38-convex-bsd\n-\t;;\n+\techo c38-convex-bsd\n+\texit ;;\n     C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)\n-\tGUESS=c4-convex-bsd\n-\t;;\n+\techo c4-convex-bsd\n+\texit ;;\n     CRAY*Y-MP:*:*:*)\n-\tCRAY_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/\\.[^.]*$/.X/'`\n-\tGUESS=ymp-cray-unicos$CRAY_REL\n-\t;;\n+\techo ymp-cray-unicos\"$UNAME_RELEASE\" | sed -e 's/\\.[^.]*$/.X/'\n+\texit ;;\n     CRAY*[A-Z]90:*:*:*)\n \techo \"$UNAME_MACHINE\"-cray-unicos\"$UNAME_RELEASE\" \\\n \t| sed -e 's/CRAY.*\\([A-Z]90\\)/\\1/' \\\n@@ -865,153 +819,112 @@ EOF\n \t      -e 's/\\.[^.]*$/.X/'\n \texit ;;\n     CRAY*TS:*:*:*)\n-\tCRAY_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/\\.[^.]*$/.X/'`\n-\tGUESS=t90-cray-unicos$CRAY_REL\n-\t;;\n+\techo t90-cray-unicos\"$UNAME_RELEASE\" | sed -e 's/\\.[^.]*$/.X/'\n+\texit ;;\n     CRAY*T3E:*:*:*)\n-\tCRAY_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/\\.[^.]*$/.X/'`\n-\tGUESS=alphaev5-cray-unicosmk$CRAY_REL\n-\t;;\n+\techo alphaev5-cray-unicosmk\"$UNAME_RELEASE\" | sed -e 's/\\.[^.]*$/.X/'\n+\texit ;;\n     CRAY*SV1:*:*:*)\n-\tCRAY_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/\\.[^.]*$/.X/'`\n-\tGUESS=sv1-cray-unicos$CRAY_REL\n-\t;;\n+\techo sv1-cray-unicos\"$UNAME_RELEASE\" | sed -e 's/\\.[^.]*$/.X/'\n+\texit ;;\n     *:UNICOS/mp:*:*)\n-\tCRAY_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/\\.[^.]*$/.X/'`\n-\tGUESS=craynv-cray-unicosmp$CRAY_REL\n-\t;;\n+\techo craynv-cray-unicosmp\"$UNAME_RELEASE\" | sed -e 's/\\.[^.]*$/.X/'\n+\texit ;;\n     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)\n \tFUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`\n \tFUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\\///'`\n \tFUJITSU_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/ /_/'`\n-\tGUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}\n-\t;;\n+\techo \"${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}\"\n+\texit ;;\n     5000:UNIX_System_V:4.*:*)\n \tFUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\\///'`\n \tFUJITSU_REL=`echo \"$UNAME_RELEASE\" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`\n-\tGUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}\n-\t;;\n+\techo \"sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}\"\n+\texit ;;\n     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\\ Embedded/OS:*:*)\n-\tGUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-bsdi\"$UNAME_RELEASE\"\n+\texit ;;\n     sparc*:BSD/OS:*:*)\n-\tGUESS=sparc-unknown-bsdi$UNAME_RELEASE\n-\t;;\n+\techo sparc-unknown-bsdi\"$UNAME_RELEASE\"\n+\texit ;;\n     *:BSD/OS:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-bsdi\"$UNAME_RELEASE\"\n+\texit ;;\n     arm:FreeBSD:*:*)\n \tUNAME_PROCESSOR=`uname -p`\n \tset_cc_for_build\n \tif echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \\\n \t    | grep -q __ARM_PCS_VFP\n \tthen\n-\t    FREEBSD_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/[-(].*//'`\n-\t    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi\n+\t    echo \"${UNAME_PROCESSOR}\"-unknown-freebsd\"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`\"-gnueabi\n \telse\n-\t    FREEBSD_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/[-(].*//'`\n-\t    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf\n+\t    echo \"${UNAME_PROCESSOR}\"-unknown-freebsd\"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`\"-gnueabihf\n \tfi\n-\t;;\n+\texit ;;\n     *:FreeBSD:*:*)\n-\tUNAME_PROCESSOR=`uname -p`\n-\tcase $UNAME_PROCESSOR in\n+\tUNAME_PROCESSOR=`/usr/bin/uname -p`\n+\tcase \"$UNAME_PROCESSOR\" in\n \t    amd64)\n \t\tUNAME_PROCESSOR=x86_64 ;;\n \t    i386)\n \t\tUNAME_PROCESSOR=i586 ;;\n \tesac\n-\tFREEBSD_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/[-(].*//'`\n-\tGUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL\n-\t;;\n+\techo \"$UNAME_PROCESSOR\"-unknown-freebsd\"`echo \"$UNAME_RELEASE\"|sed -e 's/[-(].*//'`\"\n+\texit ;;\n     i*:CYGWIN*:*)\n-\tGUESS=$UNAME_MACHINE-pc-cygwin\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-cygwin\n+\texit ;;\n     *:MINGW64*:*)\n-\tGUESS=$UNAME_MACHINE-pc-mingw64\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-mingw64\n+\texit ;;\n     *:MINGW*:*)\n-\tGUESS=$UNAME_MACHINE-pc-mingw32\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-mingw32\n+\texit ;;\n     *:MSYS*:*)\n-\tGUESS=$UNAME_MACHINE-pc-msys\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-msys\n+\texit ;;\n     i*:PW*:*)\n-\tGUESS=$UNAME_MACHINE-pc-pw32\n-\t;;\n-    *:SerenityOS:*:*)\n-        GUESS=$UNAME_MACHINE-pc-serenity\n-        ;;\n+\techo \"$UNAME_MACHINE\"-pc-pw32\n+\texit ;;\n     *:Interix*:*)\n-\tcase $UNAME_MACHINE in\n+\tcase \"$UNAME_MACHINE\" in\n \t    x86)\n-\t\tGUESS=i586-pc-interix$UNAME_RELEASE\n-\t\t;;\n+\t\techo i586-pc-interix\"$UNAME_RELEASE\"\n+\t\texit ;;\n \t    authenticamd | genuineintel | EM64T)\n-\t\tGUESS=x86_64-unknown-interix$UNAME_RELEASE\n-\t\t;;\n+\t\techo x86_64-unknown-interix\"$UNAME_RELEASE\"\n+\t\texit ;;\n \t    IA64)\n-\t\tGUESS=ia64-unknown-interix$UNAME_RELEASE\n-\t\t;;\n+\t\techo ia64-unknown-interix\"$UNAME_RELEASE\"\n+\t\texit ;;\n \tesac ;;\n     i*:UWIN*:*)\n-\tGUESS=$UNAME_MACHINE-pc-uwin\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-uwin\n+\texit ;;\n     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)\n-\tGUESS=x86_64-pc-cygwin\n-\t;;\n+\techo x86_64-pc-cygwin\n+\texit ;;\n     prep*:SunOS:5.*:*)\n-\tSUN_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/[^.]*//'`\n-\tGUESS=powerpcle-unknown-solaris2$SUN_REL\n-\t;;\n+\techo powerpcle-unknown-solaris2\"`echo \"$UNAME_RELEASE\"|sed -e 's/[^.]*//'`\"\n+\texit ;;\n     *:GNU:*:*)\n \t# the GNU system\n-\tGNU_ARCH=`echo \"$UNAME_MACHINE\" | sed -e 's,[-/].*$,,'`\n-\tGNU_REL=`echo \"$UNAME_RELEASE\" | sed -e 's,/.*$,,'`\n-\tGUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL\n-\t;;\n+\techo \"`echo \"$UNAME_MACHINE\"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo \"$UNAME_RELEASE\"|sed -e 's,/.*$,,'`\"\n+\texit ;;\n     *:GNU/*:*:*)\n \t# other systems with GNU libc and userland\n-\tGNU_SYS=`echo \"$UNAME_SYSTEM\" | sed 's,^[^/]*/,,' | tr \"[:upper:]\" \"[:lower:]\"`\n-\tGNU_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/[-(].*//'`\n-\tGUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC\n-\t;;\n-    x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)\n-\tGUESS=\"$UNAME_MACHINE-pc-managarm-mlibc\"\n-\t;;\n-    *:[Mm]anagarm:*:*)\n-\tGUESS=\"$UNAME_MACHINE-unknown-managarm-mlibc\"\n-\t;;\n+\techo \"$UNAME_MACHINE-unknown-`echo \"$UNAME_SYSTEM\" | sed 's,^[^/]*/,,' | tr \"[:upper:]\" \"[:lower:]\"``echo \"$UNAME_RELEASE\"|sed -e 's/[-(].*//'`-$LIBC\"\n+\texit ;;\n     *:Minix:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-minix\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-minix\n+\texit ;;\n     aarch64:Linux:*:*)\n-\tset_cc_for_build\n-\tCPU=$UNAME_MACHINE\n-\tLIBCABI=$LIBC\n-\tif test \"$CC_FOR_BUILD\" != no_compiler_found; then\n-\t    ABI=64\n-\t    sed 's/^\t    //' << EOF > \"$dummy.c\"\n-\t    #ifdef __ARM_EABI__\n-\t    #ifdef __ARM_PCS_VFP\n-\t    ABI=eabihf\n-\t    #else\n-\t    ABI=eabi\n-\t    #endif\n-\t    #endif\n-EOF\n-\t    cc_set_abi=`$CC_FOR_BUILD -E \"$dummy.c\" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`\n-\t    eval \"$cc_set_abi\"\n-\t    case $ABI in\n-\t\teabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;\n-\t    esac\n-\tfi\n-\tGUESS=$CPU-unknown-linux-$LIBCABI\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     aarch64_be:Linux:*:*)\n \tUNAME_MACHINE=aarch64_be\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     alpha:Linux:*:*)\n \tcase `sed -n '/^cpu model/s/^.*: \\(.*\\)/\\1/p' /proc/cpuinfo 2>/dev/null` in\n \t  EV5)   UNAME_MACHINE=alphaev5 ;;\n@@ -1024,72 +937,60 @@ EOF\n \tesac\n \tobjdump --private-headers /bin/sh | grep -q ld.so.1\n \tif test \"$?\" = 0 ; then LIBC=gnulibc1 ; fi\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n-    arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n+    arc:Linux:*:* | arceb:Linux:*:*)\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     arm*:Linux:*:*)\n \tset_cc_for_build\n \tif echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \\\n \t    | grep -q __ARM_EABI__\n \tthen\n-\t    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n+\t    echo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n \telse\n \t    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \\\n \t\t| grep -q __ARM_PCS_VFP\n \t    then\n-\t\tGUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi\n+\t\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"eabi\n \t    else\n-\t\tGUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf\n+\t\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"eabihf\n \t    fi\n \tfi\n-\t;;\n+\texit ;;\n     avr32*:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     cris:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-axis-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-axis-linux-\"$LIBC\"\n+\texit ;;\n     crisv32:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-axis-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-axis-linux-\"$LIBC\"\n+\texit ;;\n     e2k:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     frv:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     hexagon:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     i*86:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-pc-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-linux-\"$LIBC\"\n+\texit ;;\n     ia64:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     k1om:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n-    kvx:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n-    kvx:cos:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-cos\n-\t;;\n-    kvx:mbr:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-mbr\n-\t;;\n-    loongarch32:Linux:*:* | loongarch64:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     m32r*:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     m68*:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     mips:Linux:*:* | mips64:Linux:*:*)\n \tset_cc_for_build\n \tIS_GLIBC=0\n@@ -1134,138 +1035,123 @@ EOF\n \t#endif\n \t#endif\n EOF\n-\tcc_set_vars=`$CC_FOR_BUILD -E \"$dummy.c\" 2>/dev/null | grep '^CPU\\|^MIPS_ENDIAN\\|^LIBCABI'`\n-\teval \"$cc_set_vars\"\n+\teval \"`$CC_FOR_BUILD -E \"$dummy.c\" 2>/dev/null | grep '^CPU\\|^MIPS_ENDIAN\\|^LIBCABI'`\"\n \ttest \"x$CPU\" != x && { echo \"$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI\"; exit; }\n \t;;\n     mips64el:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     openrisc*:Linux:*:*)\n-\tGUESS=or1k-unknown-linux-$LIBC\n-\t;;\n+\techo or1k-unknown-linux-\"$LIBC\"\n+\texit ;;\n     or32:Linux:*:* | or1k*:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     padre:Linux:*:*)\n-\tGUESS=sparc-unknown-linux-$LIBC\n-\t;;\n+\techo sparc-unknown-linux-\"$LIBC\"\n+\texit ;;\n     parisc64:Linux:*:* | hppa64:Linux:*:*)\n-\tGUESS=hppa64-unknown-linux-$LIBC\n-\t;;\n+\techo hppa64-unknown-linux-\"$LIBC\"\n+\texit ;;\n     parisc:Linux:*:* | hppa:Linux:*:*)\n \t# Look for CPU level\n \tcase `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in\n-\t  PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;\n-\t  PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;\n-\t  *)    GUESS=hppa-unknown-linux-$LIBC ;;\n+\t  PA7*) echo hppa1.1-unknown-linux-\"$LIBC\" ;;\n+\t  PA8*) echo hppa2.0-unknown-linux-\"$LIBC\" ;;\n+\t  *)    echo hppa-unknown-linux-\"$LIBC\" ;;\n \tesac\n-\t;;\n+\texit ;;\n     ppc64:Linux:*:*)\n-\tGUESS=powerpc64-unknown-linux-$LIBC\n-\t;;\n+\techo powerpc64-unknown-linux-\"$LIBC\"\n+\texit ;;\n     ppc:Linux:*:*)\n-\tGUESS=powerpc-unknown-linux-$LIBC\n-\t;;\n+\techo powerpc-unknown-linux-\"$LIBC\"\n+\texit ;;\n     ppc64le:Linux:*:*)\n-\tGUESS=powerpc64le-unknown-linux-$LIBC\n-\t;;\n+\techo powerpc64le-unknown-linux-\"$LIBC\"\n+\texit ;;\n     ppcle:Linux:*:*)\n-\tGUESS=powerpcle-unknown-linux-$LIBC\n-\t;;\n-    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo powerpcle-unknown-linux-\"$LIBC\"\n+\texit ;;\n+    riscv32:Linux:*:* | riscv64:Linux:*:*)\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     s390:Linux:*:* | s390x:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-ibm-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-ibm-linux-\"$LIBC\"\n+\texit ;;\n     sh64*:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     sh*:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     sparc:Linux:*:* | sparc64:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n-    sw_64:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     tile*:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     vax:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-dec-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-dec-linux-\"$LIBC\"\n+\texit ;;\n     x86_64:Linux:*:*)\n \tset_cc_for_build\n-\tCPU=$UNAME_MACHINE\n \tLIBCABI=$LIBC\n-\tif test \"$CC_FOR_BUILD\" != no_compiler_found; then\n-\t    ABI=64\n-\t    sed 's/^\t    //' << EOF > \"$dummy.c\"\n-\t    #ifdef __i386__\n-\t    ABI=x86\n-\t    #else\n-\t    #ifdef __ILP32__\n-\t    ABI=x32\n-\t    #endif\n-\t    #endif\n-EOF\n-\t    cc_set_abi=`$CC_FOR_BUILD -E \"$dummy.c\" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`\n-\t    eval \"$cc_set_abi\"\n-\t    case $ABI in\n-\t\tx86) CPU=i686 ;;\n-\t\tx32) LIBCABI=${LIBC}x32 ;;\n-\t    esac\n+\tif [ \"$CC_FOR_BUILD\" != no_compiler_found ]; then\n+\t    if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \\\n+\t\t(CCOPTS=\"\" $CC_FOR_BUILD -E - 2>/dev/null) | \\\n+\t\tgrep IS_X32 >/dev/null\n+\t    then\n+\t\tLIBCABI=\"$LIBC\"x32\n+\t    fi\n \tfi\n-\tGUESS=$CPU-pc-linux-$LIBCABI\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-linux-\"$LIBCABI\"\n+\texit ;;\n     xtensa*:Linux:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-linux-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-linux-\"$LIBC\"\n+\texit ;;\n     i*86:DYNIX/ptx:4*:*)\n \t# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.\n \t# earlier versions are messed up and put the nodename in both\n \t# sysname and nodename.\n-\tGUESS=i386-sequent-sysv4\n-\t;;\n+\techo i386-sequent-sysv4\n+\texit ;;\n     i*86:UNIX_SV:4.2MP:2.*)\n \t# Unixware is an offshoot of SVR4, but it has its own version\n \t# number series starting with 2...\n \t# I am not positive that other SVR4 systems won't match this,\n \t# I just have to hope.  -- rms.\n \t# Use sysv4.2uw... so that sysv4* matches it.\n-\tGUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-sysv4.2uw\"$UNAME_VERSION\"\n+\texit ;;\n     i*86:OS/2:*:*)\n-\t# If we were able to find 'uname', then EMX Unix compatibility\n+\t# If we were able to find `uname', then EMX Unix compatibility\n \t# is probably installed.\n-\tGUESS=$UNAME_MACHINE-pc-os2-emx\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-os2-emx\n+\texit ;;\n     i*86:XTS-300:*:STOP)\n-\tGUESS=$UNAME_MACHINE-unknown-stop\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-stop\n+\texit ;;\n     i*86:atheos:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-atheos\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-atheos\n+\texit ;;\n     i*86:syllable:*:*)\n-\tGUESS=$UNAME_MACHINE-pc-syllable\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-syllable\n+\texit ;;\n     i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)\n-\tGUESS=i386-unknown-lynxos$UNAME_RELEASE\n-\t;;\n+\techo i386-unknown-lynxos\"$UNAME_RELEASE\"\n+\texit ;;\n     i*86:*DOS:*:*)\n-\tGUESS=$UNAME_MACHINE-pc-msdosdjgpp\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-msdosdjgpp\n+\texit ;;\n     i*86:*:4.*:*)\n \tUNAME_REL=`echo \"$UNAME_RELEASE\" | sed 's/\\/MP$//'`\n \tif grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then\n-\t\tGUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL\n+\t\techo \"$UNAME_MACHINE\"-univel-sysv\"$UNAME_REL\"\n \telse\n-\t\tGUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL\n+\t\techo \"$UNAME_MACHINE\"-pc-sysv\"$UNAME_REL\"\n \tfi\n-\t;;\n+\texit ;;\n     i*86:*:5:[678]*)\n \t# UnixWare 7.x, OpenUNIX and OpenServer 6.\n \tcase `/bin/uname -X | grep \"^Machine\"` in\n@@ -1273,12 +1159,12 @@ EOF\n \t    *Pentium)\t     UNAME_MACHINE=i586 ;;\n \t    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;\n \tesac\n-\tGUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}\n-\t;;\n+\techo \"$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}\"\n+\texit ;;\n     i*86:*:3.2:*)\n \tif test -f /usr/options/cb.name; then\n \t\tUNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`\n-\t\tGUESS=$UNAME_MACHINE-pc-isc$UNAME_REL\n+\t\techo \"$UNAME_MACHINE\"-pc-isc\"$UNAME_REL\"\n \telif /bin/uname -X 2>/dev/null >/dev/null ; then\n \t\tUNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`\n \t\t(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486\n@@ -1288,11 +1174,11 @@ EOF\n \t\t\t&& UNAME_MACHINE=i686\n \t\t(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \\\n \t\t\t&& UNAME_MACHINE=i686\n-\t\tGUESS=$UNAME_MACHINE-pc-sco$UNAME_REL\n+\t\techo \"$UNAME_MACHINE\"-pc-sco\"$UNAME_REL\"\n \telse\n-\t\tGUESS=$UNAME_MACHINE-pc-sysv32\n+\t\techo \"$UNAME_MACHINE\"-pc-sysv32\n \tfi\n-\t;;\n+\texit ;;\n     pc:*:*:*)\n \t# Left here for compatibility:\n \t# uname -m prints for DJGPP always 'pc', but it prints nothing about\n@@ -1300,31 +1186,31 @@ EOF\n \t# Note: whatever this is, it MUST be the same as what config.sub\n \t# prints for the \"djgpp\" host, or else GDB configure will decide that\n \t# this is a cross-build.\n-\tGUESS=i586-pc-msdosdjgpp\n-\t;;\n+\techo i586-pc-msdosdjgpp\n+\texit ;;\n     Intel:Mach:3*:*)\n-\tGUESS=i386-pc-mach3\n-\t;;\n+\techo i386-pc-mach3\n+\texit ;;\n     paragon:*:*:*)\n-\tGUESS=i860-intel-osf1\n-\t;;\n+\techo i860-intel-osf1\n+\texit ;;\n     i860:*:4.*:*) # i860-SVR4\n \tif grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then\n-\t  GUESS=i860-stardent-sysv$UNAME_RELEASE    # Stardent Vistra i860-SVR4\n+\t  echo i860-stardent-sysv\"$UNAME_RELEASE\" # Stardent Vistra i860-SVR4\n \telse # Add other i860-SVR4 vendors below as they are discovered.\n-\t  GUESS=i860-unknown-sysv$UNAME_RELEASE     # Unknown i860-SVR4\n+\t  echo i860-unknown-sysv\"$UNAME_RELEASE\"  # Unknown i860-SVR4\n \tfi\n-\t;;\n+\texit ;;\n     mini*:CTIX:SYS*5:*)\n \t# \"miniframe\"\n-\tGUESS=m68010-convergent-sysv\n-\t;;\n+\techo m68010-convergent-sysv\n+\texit ;;\n     mc68k:UNIX:SYSTEM5:3.51m)\n-\tGUESS=m68k-convergent-sysv\n-\t;;\n+\techo m68k-convergent-sysv\n+\texit ;;\n     M680?0:D-NIX:5.3:*)\n-\tGUESS=m68k-diab-dnix\n-\t;;\n+\techo m68k-diab-dnix\n+\texit ;;\n     M68*:*:R3V[5678]*:*)\n \ttest -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;\n     3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)\n@@ -1349,119 +1235,116 @@ EOF\n \t/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \\\n \t    && { echo i586-ncr-sysv4.3\"$OS_REL\"; exit; } ;;\n     m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)\n-\tGUESS=m68k-unknown-lynxos$UNAME_RELEASE\n-\t;;\n+\techo m68k-unknown-lynxos\"$UNAME_RELEASE\"\n+\texit ;;\n     mc68030:UNIX_System_V:4.*:*)\n-\tGUESS=m68k-atari-sysv4\n-\t;;\n+\techo m68k-atari-sysv4\n+\texit ;;\n     TSUNAMI:LynxOS:2.*:*)\n-\tGUESS=sparc-unknown-lynxos$UNAME_RELEASE\n-\t;;\n+\techo sparc-unknown-lynxos\"$UNAME_RELEASE\"\n+\texit ;;\n     rs6000:LynxOS:2.*:*)\n-\tGUESS=rs6000-unknown-lynxos$UNAME_RELEASE\n-\t;;\n+\techo rs6000-unknown-lynxos\"$UNAME_RELEASE\"\n+\texit ;;\n     PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)\n-\tGUESS=powerpc-unknown-lynxos$UNAME_RELEASE\n-\t;;\n+\techo powerpc-unknown-lynxos\"$UNAME_RELEASE\"\n+\texit ;;\n     SM[BE]S:UNIX_SV:*:*)\n-\tGUESS=mips-dde-sysv$UNAME_RELEASE\n-\t;;\n+\techo mips-dde-sysv\"$UNAME_RELEASE\"\n+\texit ;;\n     RM*:ReliantUNIX-*:*:*)\n-\tGUESS=mips-sni-sysv4\n-\t;;\n+\techo mips-sni-sysv4\n+\texit ;;\n     RM*:SINIX-*:*:*)\n-\tGUESS=mips-sni-sysv4\n-\t;;\n+\techo mips-sni-sysv4\n+\texit ;;\n     *:SINIX-*:*:*)\n \tif uname -p 2>/dev/null >/dev/null ; then\n \t\tUNAME_MACHINE=`(uname -p) 2>/dev/null`\n-\t\tGUESS=$UNAME_MACHINE-sni-sysv4\n+\t\techo \"$UNAME_MACHINE\"-sni-sysv4\n \telse\n-\t\tGUESS=ns32k-sni-sysv\n+\t\techo ns32k-sni-sysv\n \tfi\n-\t;;\n-    PENTIUM:*:4.0*:*)\t# Unisys 'ClearPath HMP IX 4000' SVR4/MP effort\n+\texit ;;\n+    PENTIUM:*:4.0*:*)\t# Unisys `ClearPath HMP IX 4000' SVR4/MP effort\n \t\t\t# says <Richard.M.Bartel@ccMail.Census.GOV>\n-\tGUESS=i586-unisys-sysv4\n-\t;;\n+\techo i586-unisys-sysv4\n+\texit ;;\n     *:UNIX_System_V:4*:FTX*)\n \t# From Gerald Hewes <hewes@openmarket.com>.\n \t# How about differentiating between stratus architectures? -djm\n-\tGUESS=hppa1.1-stratus-sysv4\n-\t;;\n+\techo hppa1.1-stratus-sysv4\n+\texit ;;\n     *:*:*:FTX*)\n \t# From seanf@swdc.stratus.com.\n-\tGUESS=i860-stratus-sysv4\n-\t;;\n+\techo i860-stratus-sysv4\n+\texit ;;\n     i*86:VOS:*:*)\n \t# From Paul.Green@stratus.com.\n-\tGUESS=$UNAME_MACHINE-stratus-vos\n-\t;;\n+\techo \"$UNAME_MACHINE\"-stratus-vos\n+\texit ;;\n     *:VOS:*:*)\n \t# From Paul.Green@stratus.com.\n-\tGUESS=hppa1.1-stratus-vos\n-\t;;\n+\techo hppa1.1-stratus-vos\n+\texit ;;\n     mc68*:A/UX:*:*)\n-\tGUESS=m68k-apple-aux$UNAME_RELEASE\n-\t;;\n+\techo m68k-apple-aux\"$UNAME_RELEASE\"\n+\texit ;;\n     news*:NEWS-OS:6*:*)\n-\tGUESS=mips-sony-newsos6\n-\t;;\n+\techo mips-sony-newsos6\n+\texit ;;\n     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)\n-\tif test -d /usr/nec; then\n-\t\tGUESS=mips-nec-sysv$UNAME_RELEASE\n+\tif [ -d /usr/nec ]; then\n+\t\techo mips-nec-sysv\"$UNAME_RELEASE\"\n \telse\n-\t\tGUESS=mips-unknown-sysv$UNAME_RELEASE\n+\t\techo mips-unknown-sysv\"$UNAME_RELEASE\"\n \tfi\n-\t;;\n+\texit ;;\n     BeBox:BeOS:*:*)\t# BeOS running on hardware made by Be, PPC only.\n-\tGUESS=powerpc-be-beos\n-\t;;\n+\techo powerpc-be-beos\n+\texit ;;\n     BeMac:BeOS:*:*)\t# BeOS running on Mac or Mac clone, PPC only.\n-\tGUESS=powerpc-apple-beos\n-\t;;\n+\techo powerpc-apple-beos\n+\texit ;;\n     BePC:BeOS:*:*)\t# BeOS running on Intel PC compatible.\n-\tGUESS=i586-pc-beos\n-\t;;\n+\techo i586-pc-beos\n+\texit ;;\n     BePC:Haiku:*:*)\t# Haiku running on Intel PC compatible.\n-\tGUESS=i586-pc-haiku\n-\t;;\n-    ppc:Haiku:*:*)\t# Haiku running on Apple PowerPC\n-\tGUESS=powerpc-apple-haiku\n-\t;;\n-    *:Haiku:*:*)\t# Haiku modern gcc (not bound by BeOS compat)\n-\tGUESS=$UNAME_MACHINE-unknown-haiku\n-\t;;\n+\techo i586-pc-haiku\n+\texit ;;\n+    x86_64:Haiku:*:*)\n+\techo x86_64-unknown-haiku\n+\texit ;;\n     SX-4:SUPER-UX:*:*)\n-\tGUESS=sx4-nec-superux$UNAME_RELEASE\n-\t;;\n+\techo sx4-nec-superux\"$UNAME_RELEASE\"\n+\texit ;;\n     SX-5:SUPER-UX:*:*)\n-\tGUESS=sx5-nec-superux$UNAME_RELEASE\n-\t;;\n+\techo sx5-nec-superux\"$UNAME_RELEASE\"\n+\texit ;;\n     SX-6:SUPER-UX:*:*)\n-\tGUESS=sx6-nec-superux$UNAME_RELEASE\n-\t;;\n+\techo sx6-nec-superux\"$UNAME_RELEASE\"\n+\texit ;;\n     SX-7:SUPER-UX:*:*)\n-\tGUESS=sx7-nec-superux$UNAME_RELEASE\n-\t;;\n+\techo sx7-nec-superux\"$UNAME_RELEASE\"\n+\texit ;;\n     SX-8:SUPER-UX:*:*)\n-\tGUESS=sx8-nec-superux$UNAME_RELEASE\n-\t;;\n+\techo sx8-nec-superux\"$UNAME_RELEASE\"\n+\texit ;;\n     SX-8R:SUPER-UX:*:*)\n-\tGUESS=sx8r-nec-superux$UNAME_RELEASE\n-\t;;\n+\techo sx8r-nec-superux\"$UNAME_RELEASE\"\n+\texit ;;\n     SX-ACE:SUPER-UX:*:*)\n-\tGUESS=sxace-nec-superux$UNAME_RELEASE\n-\t;;\n+\techo sxace-nec-superux\"$UNAME_RELEASE\"\n+\texit ;;\n     Power*:Rhapsody:*:*)\n-\tGUESS=powerpc-apple-rhapsody$UNAME_RELEASE\n-\t;;\n+\techo powerpc-apple-rhapsody\"$UNAME_RELEASE\"\n+\texit ;;\n     *:Rhapsody:*:*)\n-\tGUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_MACHINE\"-apple-rhapsody\"$UNAME_RELEASE\"\n+\texit ;;\n     arm64:Darwin:*:*)\n-\tGUESS=aarch64-apple-darwin$UNAME_RELEASE\n-\t;;\n+\techo aarch64-apple-darwin\"$UNAME_RELEASE\"\n+\texit ;;\n     *:Darwin:*:*)\n \tUNAME_PROCESSOR=`uname -p`\n \tcase $UNAME_PROCESSOR in\n@@ -1476,7 +1359,7 @@ EOF\n \telse\n \t    set_cc_for_build\n \tfi\n-\tif test \"$CC_FOR_BUILD\" != no_compiler_found; then\n+\tif [ \"$CC_FOR_BUILD\" != no_compiler_found ]; then\n \t    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \\\n \t\t   (CCOPTS=\"\" $CC_FOR_BUILD -E - 2>/dev/null) | \\\n \t\t   grep IS_64BIT_ARCH >/dev/null\n@@ -1497,125 +1380,109 @@ EOF\n \t    # uname -m returns i386 or x86_64\n \t    UNAME_PROCESSOR=$UNAME_MACHINE\n \tfi\n-\tGUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_PROCESSOR\"-apple-darwin\"$UNAME_RELEASE\"\n+\texit ;;\n     *:procnto*:*:* | *:QNX:[0123456789]*:*)\n \tUNAME_PROCESSOR=`uname -p`\n \tif test \"$UNAME_PROCESSOR\" = x86; then\n \t\tUNAME_PROCESSOR=i386\n \t\tUNAME_MACHINE=pc\n \tfi\n-\tGUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_PROCESSOR\"-\"$UNAME_MACHINE\"-nto-qnx\"$UNAME_RELEASE\"\n+\texit ;;\n     *:QNX:*:4*)\n-\tGUESS=i386-pc-qnx\n-\t;;\n+\techo i386-pc-qnx\n+\texit ;;\n     NEO-*:NONSTOP_KERNEL:*:*)\n-\tGUESS=neo-tandem-nsk$UNAME_RELEASE\n-\t;;\n+\techo neo-tandem-nsk\"$UNAME_RELEASE\"\n+\texit ;;\n     NSE-*:NONSTOP_KERNEL:*:*)\n-\tGUESS=nse-tandem-nsk$UNAME_RELEASE\n-\t;;\n+\techo nse-tandem-nsk\"$UNAME_RELEASE\"\n+\texit ;;\n     NSR-*:NONSTOP_KERNEL:*:*)\n-\tGUESS=nsr-tandem-nsk$UNAME_RELEASE\n-\t;;\n+\techo nsr-tandem-nsk\"$UNAME_RELEASE\"\n+\texit ;;\n     NSV-*:NONSTOP_KERNEL:*:*)\n-\tGUESS=nsv-tandem-nsk$UNAME_RELEASE\n-\t;;\n+\techo nsv-tandem-nsk\"$UNAME_RELEASE\"\n+\texit ;;\n     NSX-*:NONSTOP_KERNEL:*:*)\n-\tGUESS=nsx-tandem-nsk$UNAME_RELEASE\n-\t;;\n+\techo nsx-tandem-nsk\"$UNAME_RELEASE\"\n+\texit ;;\n     *:NonStop-UX:*:*)\n-\tGUESS=mips-compaq-nonstopux\n-\t;;\n+\techo mips-compaq-nonstopux\n+\texit ;;\n     BS2000:POSIX*:*:*)\n-\tGUESS=bs2000-siemens-sysv\n-\t;;\n+\techo bs2000-siemens-sysv\n+\texit ;;\n     DS/*:UNIX_System_V:*:*)\n-\tGUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE\n-\t;;\n+\techo \"$UNAME_MACHINE\"-\"$UNAME_SYSTEM\"-\"$UNAME_RELEASE\"\n+\texit ;;\n     *:Plan9:*:*)\n \t# \"uname -m\" is not consistent, so use $cputype instead. 386\n \t# is converted to i386 for consistency with other x86\n \t# operating systems.\n-\tif test \"${cputype-}\" = 386; then\n+\t# shellcheck disable=SC2154\n+\tif test \"$cputype\" = 386; then\n \t    UNAME_MACHINE=i386\n-\telif test \"x${cputype-}\" != x; then\n-\t    UNAME_MACHINE=$cputype\n+\telse\n+\t    UNAME_MACHINE=\"$cputype\"\n \tfi\n-\tGUESS=$UNAME_MACHINE-unknown-plan9\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-plan9\n+\texit ;;\n     *:TOPS-10:*:*)\n-\tGUESS=pdp10-unknown-tops10\n-\t;;\n+\techo pdp10-unknown-tops10\n+\texit ;;\n     *:TENEX:*:*)\n-\tGUESS=pdp10-unknown-tenex\n-\t;;\n+\techo pdp10-unknown-tenex\n+\texit ;;\n     KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)\n-\tGUESS=pdp10-dec-tops20\n-\t;;\n+\techo pdp10-dec-tops20\n+\texit ;;\n     XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)\n-\tGUESS=pdp10-xkl-tops20\n-\t;;\n+\techo pdp10-xkl-tops20\n+\texit ;;\n     *:TOPS-20:*:*)\n-\tGUESS=pdp10-unknown-tops20\n-\t;;\n+\techo pdp10-unknown-tops20\n+\texit ;;\n     *:ITS:*:*)\n-\tGUESS=pdp10-unknown-its\n-\t;;\n+\techo pdp10-unknown-its\n+\texit ;;\n     SEI:*:*:SEIUX)\n-\tGUESS=mips-sei-seiux$UNAME_RELEASE\n-\t;;\n+\techo mips-sei-seiux\"$UNAME_RELEASE\"\n+\texit ;;\n     *:DragonFly:*:*)\n-\tDRAGONFLY_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/[-(].*//'`\n-\tGUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-dragonfly\"`echo \"$UNAME_RELEASE\"|sed -e 's/[-(].*//'`\"\n+\texit ;;\n     *:*VMS:*:*)\n \tUNAME_MACHINE=`(uname -p) 2>/dev/null`\n-\tcase $UNAME_MACHINE in\n-\t    A*) GUESS=alpha-dec-vms ;;\n-\t    I*) GUESS=ia64-dec-vms ;;\n-\t    V*) GUESS=vax-dec-vms ;;\n+\tcase \"$UNAME_MACHINE\" in\n+\t    A*) echo alpha-dec-vms ; exit ;;\n+\t    I*) echo ia64-dec-vms ; exit ;;\n+\t    V*) echo vax-dec-vms ; exit ;;\n \tesac ;;\n     *:XENIX:*:SysV)\n-\tGUESS=i386-pc-xenix\n-\t;;\n+\techo i386-pc-xenix\n+\texit ;;\n     i*86:skyos:*:*)\n-\tSKYOS_REL=`echo \"$UNAME_RELEASE\" | sed -e 's/ .*$//'`\n-\tGUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-skyos\"`echo \"$UNAME_RELEASE\" | sed -e 's/ .*$//'`\"\n+\texit ;;\n     i*86:rdos:*:*)\n-\tGUESS=$UNAME_MACHINE-pc-rdos\n-\t;;\n-    i*86:Fiwix:*:*)\n-\tGUESS=$UNAME_MACHINE-pc-fiwix\n-\t;;\n-    *:AROS:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-aros\n-\t;;\n+\techo \"$UNAME_MACHINE\"-pc-rdos\n+\texit ;;\n+    i*86:AROS:*:*)\n+\techo \"$UNAME_MACHINE\"-pc-aros\n+\texit ;;\n     x86_64:VMkernel:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-esx\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-esx\n+\texit ;;\n     amd64:Isilon\\ OneFS:*:*)\n-\tGUESS=x86_64-unknown-onefs\n-\t;;\n+\techo x86_64-unknown-onefs\n+\texit ;;\n     *:Unleashed:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE\n-\t;;\n-    x86_64:[Ii]ronclad:*:*|i?86:[Ii]ronclad:*:*)\n-\tGUESS=$UNAME_MACHINE-pc-ironclad-$LIBC\n-\t;;\n-    *:[Ii]ronclad:*:*)\n-\tGUESS=$UNAME_MACHINE-unknown-ironclad-$LIBC\n-\t;;\n+\techo \"$UNAME_MACHINE\"-unknown-unleashed\"$UNAME_RELEASE\"\n+\texit ;;\n esac\n \n-# Do we have a guess based on uname results?\n-if test \"x$GUESS\" != x; then\n-    echo \"$GUESS\"\n-    exit\n-fi\n-\n # No uname command or uname output not recognized.\n set_cc_for_build\n cat > \"$dummy.c\" <<EOF\n@@ -1631,7 +1498,6 @@ cat > \"$dummy.c\" <<EOF\n #endif\n #endif\n #endif\n-int\n main ()\n {\n #if defined (sony)\n@@ -1748,7 +1614,7 @@ main ()\n }\n EOF\n \n-$CC_FOR_BUILD -o \"$dummy\" \"$dummy.c\" 2>/dev/null && SYSTEM_NAME=`\"$dummy\"` &&\n+$CC_FOR_BUILD -o \"$dummy\" \"$dummy.c\" 2>/dev/null && SYSTEM_NAME=`$dummy` &&\n \t{ echo \"$SYSTEM_NAME\"; exit; }\n \n # Apollos put the system type in the environment.\n@@ -1756,7 +1622,7 @@ test -d /usr/apollo && { echo \"$ISP-apollo-$SYSTYPE\"; exit; }\n \n echo \"$0: unable to guess system type\" >&2\n \n-case $UNAME_MACHINE:$UNAME_SYSTEM in\n+case \"$UNAME_MACHINE:$UNAME_SYSTEM\" in\n     mips:Linux | mips64:Linux)\n \t# If we got here on MIPS GNU/Linux, output extra information.\n \tcat >&2 <<EOF\n@@ -1773,16 +1639,14 @@ This script (version $timestamp), has failed to recognize the\n operating system you are using. If your script is old, overwrite *all*\n copies of config.guess and config.sub with the latest versions from:\n \n-  https://git.savannah.gnu.org/cgit/config.git/plain/config.guess\n+  https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess\n and\n-  https://git.savannah.gnu.org/cgit/config.git/plain/config.sub\n+  https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub\n EOF\n \n-our_year=`echo $timestamp | sed 's,-.*,,'`\n-thisyear=`date +%Y`\n+year=`echo $timestamp | sed 's,-.*,,'`\n # shellcheck disable=SC2003\n-script_age=`expr \"$thisyear\" - \"$our_year\"`\n-if test \"$script_age\" -lt 3 ; then\n+if test \"`expr \"\\`date +%Y\\`\" - \"$year\"`\" -lt 3 ; then\n    cat >&2 <<EOF\n \n If $0 has already been updated, send the following data and any\n@@ -1816,8 +1680,8 @@ fi\n exit 1\n \n # Local variables:\n-# eval: (add-hook 'before-save-hook 'time-stamp nil t)\n+# eval: (add-hook 'before-save-hook 'time-stamp)\n # time-stamp-start: \"timestamp='\"\n-# time-stamp-format: \"%Y-%02m-%02d\"\n+# time-stamp-format: \"%:y-%02m-%02d\"\n # time-stamp-end: \"'\"\n # End:\ndiff --git a/nspr/build/autoconf/config.sub b/nspr/build/autoconf/config.sub\nindex 404aa08..3d9a8dc 100755\n--- a/nspr/build/autoconf/config.sub\n+++ b/nspr/build/autoconf/config.sub\n@@ -1,14 +1,12 @@\n #! /bin/sh\n # Configuration validation subroutine script.\n-#   Copyright 1992-2026 Free Software Foundation, Inc.\n+#   Copyright 1992-2020 Free Software Foundation, Inc.\n \n-# shellcheck disable=SC2006,SC2268,SC2162 # see below for rationale\n-\n-timestamp='2026-05-17'\n+timestamp='2020-07-10'\n \n # This file is free software; you can redistribute it and/or modify it\n # under the terms of the GNU General Public License as published by\n-# the Free Software Foundation, either version 3 of the License, or\n+# the Free Software Foundation; either version 3 of the License, or\n # (at your option) any later version.\n #\n # This program is distributed in the hope that it will be useful, but\n@@ -35,7 +33,7 @@ timestamp='2026-05-17'\n # Otherwise, we print the canonical config type on stdout and succeed.\n \n # You can get the latest version of this script from:\n-# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub\n+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub\n \n # This file is supposed to be the same for all GNU packages\n # and recognize all the CPU types, system types and aliases\n@@ -52,13 +50,6 @@ timestamp='2026-05-17'\n #\tCPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM\n # It is wrong to echo any other type of specification.\n \n-# The \"shellcheck disable\" line above the timestamp inhibits complaints\n-# about features and limitations of the classic Bourne shell that were\n-# superseded or lifted in POSIX.  However, this script identifies a wide\n-# variety of pre-POSIX systems that do not have POSIX shells at all, and\n-# even some reasonably current systems (Solaris 10 as case-in-point) still\n-# have a pre-POSIX /bin/sh.\n-\n me=`echo \"$0\" | sed -e 's,.*/,,'`\n \n usage=\"\\\n@@ -76,13 +67,13 @@ Report bugs and patches to <config-patches@gnu.org>.\"\n version=\"\\\n GNU config.sub ($timestamp)\n \n-Copyright 1992-2026 Free Software Foundation, Inc.\n+Copyright 1992-2020 Free Software Foundation, Inc.\n \n This is free software; see the source for copying conditions.  There is NO\n warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\"\n \n help=\"\n-Try '$me --help' for more information.\"\n+Try \\`$me --help' for more information.\"\n \n # Parse command line\n while test $# -gt 0 ; do\n@@ -120,16 +111,15 @@ case $# in\n esac\n \n # Split fields of configuration type\n-saved_IFS=$IFS\n+# shellcheck disable=SC2162\n IFS=\"-\" read field1 field2 field3 field4 <<EOF\n $1\n EOF\n-IFS=$saved_IFS\n \n # Separate into logical components for further validation\n case $1 in\n \t*-*-*-*-*)\n-\t\techo \"Invalid configuration '$1': more than four components\" >&2\n+\t\techo Invalid configuration \\`\"$1\"\\': more than four components >&2\n \t\texit 1\n \t\t;;\n \t*-*-*-*)\n@@ -141,22 +131,10 @@ case $1 in\n \t\t# parts\n \t\tmaybe_os=$field2-$field3\n \t\tcase $maybe_os in\n-\t\t\t  cloudabi*-eabi* \\\n-\t\t\t| kfreebsd*-gnu* \\\n-\t\t\t| knetbsd*-gnu* \\\n-\t\t\t| kopensolaris*-gnu* \\\n-\t\t\t| ironclad-* \\\n-\t\t\t| linux-* \\\n-\t\t\t| managarm-* \\\n-\t\t\t| netbsd*-eabi* \\\n-\t\t\t| netbsd*-gnu* \\\n-\t\t\t| nto-qnx* \\\n-\t\t\t| os2-emx* \\\n-\t\t\t| rtmk-nova* \\\n-\t\t\t| storm-chaos* \\\n-\t\t\t| uclinux-gnu* \\\n-\t\t\t| uclinux-uclibc* \\\n-\t\t\t| windows-* )\n+\t\t\tnto-qnx* | linux-* | uclinux-uclibc* \\\n+\t\t\t| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \\\n+\t\t\t| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \\\n+\t\t\t| storm-chaos* | os2-emx* | rtmk-nova*)\n \t\t\t\tbasic_machine=$field1\n \t\t\t\tbasic_os=$maybe_os\n \t\t\t\t;;\n@@ -171,12 +149,8 @@ case $1 in\n \t\tesac\n \t\t;;\n \t*-*)\n+\t\t# A lone config we happen to match not fitting any pattern\n \t\tcase $field1-$field2 in\n-\t\t\t# Shorthands that happen to contain a single dash\n-\t\t\tconvex-c[12] | convex-c3[248])\n-\t\t\t\tbasic_machine=$field2-convex\n-\t\t\t\tbasic_os=\n-\t\t\t\t;;\n \t\t\tdecstation-3100)\n \t\t\t\tbasic_machine=mips-dec\n \t\t\t\tbasic_os=\n@@ -184,87 +158,24 @@ case $1 in\n \t\t\t*-*)\n \t\t\t\t# Second component is usually, but not always the OS\n \t\t\t\tcase $field2 in\n-\t\t\t\t\t# Do not treat sunos as a manufacturer\n+\t\t\t\t\t# Prevent following clause from handling this valid os\n \t\t\t\t\tsun*os*)\n \t\t\t\t\t\tbasic_machine=$field1\n \t\t\t\t\t\tbasic_os=$field2\n \t\t\t\t\t\t;;\n \t\t\t\t\t# Manufacturers\n-\t\t\t\t\t  3100* \\\n-\t\t\t\t\t| 32* \\\n-\t\t\t\t\t| 3300* \\\n-\t\t\t\t\t| 3600* \\\n-\t\t\t\t\t| 7300* \\\n-\t\t\t\t\t| acorn \\\n-\t\t\t\t\t| altos* \\\n-\t\t\t\t\t| apollo \\\n-\t\t\t\t\t| apple \\\n-\t\t\t\t\t| atari \\\n-\t\t\t\t\t| att* \\\n-\t\t\t\t\t| axis \\\n-\t\t\t\t\t| be \\\n-\t\t\t\t\t| bull \\\n-\t\t\t\t\t| cbm \\\n-\t\t\t\t\t| ccur \\\n-\t\t\t\t\t| cisco \\\n-\t\t\t\t\t| commodore \\\n-\t\t\t\t\t| convergent* \\\n-\t\t\t\t\t| convex* \\\n-\t\t\t\t\t| cray \\\n-\t\t\t\t\t| crds \\\n-\t\t\t\t\t| dec* \\\n-\t\t\t\t\t| delta* \\\n-\t\t\t\t\t| dg \\\n-\t\t\t\t\t| digital \\\n-\t\t\t\t\t| dolphin \\\n-\t\t\t\t\t| encore* \\\n-\t\t\t\t\t| gould \\\n-\t\t\t\t\t| harris \\\n-\t\t\t\t\t| highlevel \\\n-\t\t\t\t\t| hitachi* \\\n-\t\t\t\t\t| hp \\\n-\t\t\t\t\t| ibm* \\\n-\t\t\t\t\t| intergraph \\\n-\t\t\t\t\t| isi* \\\n-\t\t\t\t\t| knuth \\\n-\t\t\t\t\t| masscomp \\\n-\t\t\t\t\t| microblaze* \\\n-\t\t\t\t\t| mips* \\\n-\t\t\t\t\t| motorola* \\\n-\t\t\t\t\t| ncr* \\\n-\t\t\t\t\t| news \\\n-\t\t\t\t\t| next \\\n-\t\t\t\t\t| ns \\\n-\t\t\t\t\t| oki \\\n-\t\t\t\t\t| omron* \\\n-\t\t\t\t\t| pc533* \\\n-\t\t\t\t\t| rebel \\\n-\t\t\t\t\t| rom68k \\\n-\t\t\t\t\t| rombug \\\n-\t\t\t\t\t| semi \\\n-\t\t\t\t\t| sequent* \\\n-\t\t\t\t\t| sgi* \\\n-\t\t\t\t\t| siemens \\\n-\t\t\t\t\t| sim \\\n-\t\t\t\t\t| sni \\\n-\t\t\t\t\t| sony* \\\n-\t\t\t\t\t| stratus \\\n-\t\t\t\t\t| sun \\\n-\t\t\t\t\t| sun[234]* \\\n-\t\t\t\t\t| tektronix \\\n-\t\t\t\t\t| tti* \\\n-\t\t\t\t\t| ultra \\\n-\t\t\t\t\t| unicom* \\\n-\t\t\t\t\t| wec \\\n-\t\t\t\t\t| winbond \\\n-\t\t\t\t\t| wrs)\n+\t\t\t\t\tdec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \\\n+\t\t\t\t\t| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \\\n+\t\t\t\t\t| unicom* | ibm* | next | hp | isi* | apollo | altos* \\\n+\t\t\t\t\t| convergent* | ncr* | news | 32* | 3600* | 3100* \\\n+\t\t\t\t\t| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \\\n+\t\t\t\t\t| ultra | tti* | harris | dolphin | highlevel | gould \\\n+\t\t\t\t\t| cbm | ns | masscomp | apple | axis | knuth | cray \\\n+\t\t\t\t\t| microblaze* | sim | cisco \\\n+\t\t\t\t\t| oki | wec | wrs | winbond)\n \t\t\t\t\t\tbasic_machine=$field1-$field2\n \t\t\t\t\t\tbasic_os=\n \t\t\t\t\t\t;;\n-\t\t\t\t\ttock* | zephyr*)\n-\t\t\t\t\t\tbasic_machine=$field1-unknown\n-\t\t\t\t\t\tbasic_os=$field2\n-\t\t\t\t\t\t;;\n \t\t\t\t\t*)\n \t\t\t\t\t\tbasic_machine=$field1\n \t\t\t\t\t\tbasic_os=$field2\n@@ -345,6 +256,26 @@ case $1 in\n \t\t\t\tbasic_machine=arm-unknown\n \t\t\t\tbasic_os=cegcc\n \t\t\t\t;;\n+\t\t\tconvex-c1)\n+\t\t\t\tbasic_machine=c1-convex\n+\t\t\t\tbasic_os=bsd\n+\t\t\t\t;;\n+\t\t\tconvex-c2)\n+\t\t\t\tbasic_machine=c2-convex\n+\t\t\t\tbasic_os=bsd\n+\t\t\t\t;;\n+\t\t\tconvex-c32)\n+\t\t\t\tbasic_machine=c32-convex\n+\t\t\t\tbasic_os=bsd\n+\t\t\t\t;;\n+\t\t\tconvex-c34)\n+\t\t\t\tbasic_machine=c34-convex\n+\t\t\t\tbasic_os=bsd\n+\t\t\t\t;;\n+\t\t\tconvex-c38)\n+\t\t\t\tbasic_machine=c38-convex\n+\t\t\t\tbasic_os=bsd\n+\t\t\t\t;;\n \t\t\tcray)\n \t\t\t\tbasic_machine=j90-cray\n \t\t\t\tbasic_os=unicos\n@@ -767,26 +698,15 @@ case $basic_machine in\n \t\tvendor=dec\n \t\tbasic_os=tops20\n \t\t;;\n-\tdelta | 3300 | delta-motorola | 3300-motorola | motorola-delta | motorola-3300)\n+\tdelta | 3300 | motorola-3300 | motorola-delta \\\n+\t      | 3300-motorola | delta-motorola)\n \t\tcpu=m68k\n \t\tvendor=motorola\n \t\t;;\n-\t# This used to be dpx2*, but that gets the RS6000-based\n-\t# DPX/20 and the x86-based DPX/2-100 wrong.  See\n-\t# https://oldskool.silicium.org/stations/bull_dpx20.htm\n-\t# https://www.feb-patrimoine.com/english/bull_dpx2.htm\n-\t# https://www.feb-patrimoine.com/english/unix_and_bull.htm\n-\tdpx2 | dpx2[23]00 | dpx2[23]xx)\n+\tdpx2*)\n \t\tcpu=m68k\n \t\tvendor=bull\n-\t\t;;\n-\tdpx2100 | dpx21xx)\n-\t\tcpu=i386\n-\t\tvendor=bull\n-\t\t;;\n-\tdpx20)\n-\t\tcpu=rs6000\n-\t\tvendor=bull\n+\t\tbasic_os=sysv3\n \t\t;;\n \tencore | umax | mmax)\n \t\tcpu=ns32k\n@@ -901,6 +821,18 @@ case $basic_machine in\n \tnext | m*-next)\n \t\tcpu=m68k\n \t\tvendor=next\n+\t\tcase $basic_os in\n+\t\t    openstep*)\n+\t\t        ;;\n+\t\t    nextstep*)\n+\t\t\t;;\n+\t\t    ns2*)\n+\t\t      basic_os=nextstep2\n+\t\t\t;;\n+\t\t    *)\n+\t\t      basic_os=nextstep3\n+\t\t\t;;\n+\t\tesac\n \t\t;;\n \tnp1)\n \t\tcpu=np1\n@@ -989,13 +921,12 @@ case $basic_machine in\n \t\t;;\n \n \t*-*)\n-\t\tsaved_IFS=$IFS\n+\t\t# shellcheck disable=SC2162\n \t\tIFS=\"-\" read cpu vendor <<EOF\n $basic_machine\n EOF\n-\t\tIFS=$saved_IFS\n \t\t;;\n-\t# We use 'pc' rather than 'unknown'\n+\t# We use `pc' rather than `unknown'\n \t# because (1) that's what they normally are, and\n \t# (2) the word \"unknown\" tends to confuse beginning users.\n \ti*86 | x86_64)\n@@ -1023,19 +954,15 @@ unset -v basic_machine\n \n # Decode basic machines in the full and proper CPU-Company form.\n case $cpu-$vendor in\n-\t# Here we handle the default manufacturer of certain CPU types in canonical form.\n-\t# It is in some cases the only manufacturer, in others, it is the most popular.\n-\tc[12]-convex | c[12]-unknown | c3[248]-convex | c3[248]-unknown)\n-\t\tvendor=convex\n-\t\tbasic_os=${basic_os:-bsd}\n-\t\t;;\n+\t# Here we handle the default manufacturer of certain CPU types in canonical form. It is in\n+\t# some cases the only manufacturer, in others, it is the most popular.\n \tcraynv-unknown)\n \t\tvendor=cray\n \t\tbasic_os=${basic_os:-unicosmp}\n \t\t;;\n \tc90-unknown | c90-cray)\n \t\tvendor=cray\n-\t\tbasic_os=${basic_os:-unicos}\n+\t\tbasic_os=${Basic_os:-unicos}\n \t\t;;\n \tfx80-unknown)\n \t\tvendor=alliant\n@@ -1076,34 +1003,11 @@ case $cpu-$vendor in\n \t\t;;\n \n \t# Here we normalize CPU types with a missing or matching vendor\n-\tarmh-unknown | armh-alt)\n-\t\tcpu=armv7l\n-\t\tvendor=alt\n-\t\tbasic_os=${basic_os:-linux-gnueabihf}\n-\t\t;;\n-\n-\t# Normalized CPU+vendor pairs that imply an OS, if not otherwise specified\n-\tm68k-isi)\n-\t\tbasic_os=${basic_os:-sysv}\n-\t\t;;\n-\tm68k-sony)\n-\t\tbasic_os=${basic_os:-newsos}\n-\t\t;;\n-\tm68k-tektronix)\n-\t\tbasic_os=${basic_os:-bsd}\n-\t\t;;\n-\tm88k-harris)\n-\t\tbasic_os=${basic_os:-sysv3}\n-\t\t;;\n-\ti386-bull | m68k-bull)\n-\t\tbasic_os=${basic_os:-sysv3}\n-\t\t;;\n-\trs6000-bull)\n+\tdpx20-unknown | dpx20-bull)\n+\t\tcpu=rs6000\n+\t\tvendor=bull\n \t\tbasic_os=${basic_os:-bosx}\n \t\t;;\n-\tmips-sni)\n-\t\tbasic_os=${basic_os:-sysv4}\n-\t\t;;\n \n \t# Here we normalize CPU types irrespective of the vendor\n \tamd64-*)\n@@ -1111,7 +1015,7 @@ case $cpu-$vendor in\n \t\t;;\n \tblackfin-*)\n \t\tcpu=bfin\n-\t\tbasic_os=${basic_os:-linux}\n+\t\tbasic_os=linux\n \t\t;;\n \tc54x-*)\n \t\tcpu=tic54x\n@@ -1134,7 +1038,7 @@ case $cpu-$vendor in\n \t\t;;\n \tm68knommu-*)\n \t\tcpu=m68k\n-\t\tbasic_os=${basic_os:-linux}\n+\t\tbasic_os=linux\n \t\t;;\n \tm9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)\n \t\tcpu=s12z\n@@ -1144,12 +1048,12 @@ case $cpu-$vendor in\n \t\t;;\n \tparisc-*)\n \t\tcpu=hppa\n-\t\tbasic_os=${basic_os:-linux}\n+\t\tbasic_os=linux\n \t\t;;\n \tpentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)\n \t\tcpu=i586\n \t\t;;\n-\tpentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)\n+\tpentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)\n \t\tcpu=i686\n \t\t;;\n \tpentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)\n@@ -1158,6 +1062,9 @@ case $cpu-$vendor in\n \tpentium4-*)\n \t\tcpu=i786\n \t\t;;\n+\tpc98-*)\n+\t\tcpu=i386\n+\t\t;;\n \tppc-* | ppcbe-*)\n \t\tcpu=powerpc\n \t\t;;\n@@ -1191,10 +1098,13 @@ case $cpu-$vendor in\n \ttx39el-*)\n \t\tcpu=mipstx39el\n \t\t;;\n+\tx64-*)\n+\t\tcpu=x86_64\n+\t\t;;\n \txscale-* | xscalee[bl]-*)\n \t\tcpu=`echo \"$cpu\" | sed 's/^xscale/arm/'`\n \t\t;;\n-\tarm64-* | aarch64le-* | arm64_32-*)\n+\tarm64-*)\n \t\tcpu=aarch64\n \t\t;;\n \n@@ -1246,233 +1156,108 @@ case $cpu-$vendor in\n \t\t# Recognize the canonical CPU types that are allowed with any\n \t\t# company name.\n \t\tcase $cpu in\n-\t\t\t  1750a \\\n-\t\t\t| 580 \\\n-\t\t\t| [cjt]90 \\\n+\t\t\t1750a | 580 \\\n \t\t\t| a29k \\\n-\t\t\t| aarch64 \\\n-\t\t\t| aarch64_be \\\n-\t\t\t| aarch64c \\\n+\t\t\t| aarch64 | aarch64_be \\\n \t\t\t| abacus \\\n-\t\t\t| alpha \\\n-\t\t\t| alpha64 \\\n-\t\t\t| alpha64ev56 \\\n-\t\t\t| alpha64ev6[78] \\\n-\t\t\t| alpha64ev[4-8] \\\n-\t\t\t| alpha64pca5[67] \\\n-\t\t\t| alphaev56 \\\n-\t\t\t| alphaev6[78] \\\n-\t\t\t| alphaev[4-8] \\\n-\t\t\t| alphapca5[67] \\\n+\t\t\t| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \\\n+\t\t\t| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \\\n+\t\t\t| alphapca5[67] | alpha64pca5[67] \\\n \t\t\t| am33_2.0 \\\n \t\t\t| amdgcn \\\n-\t\t\t| arc \\\n-\t\t\t| arc32 \\\n-\t\t\t| arc64 \\\n-\t\t\t| arceb \\\n-\t\t\t| arm \\\n-\t\t\t| arm64e \\\n-\t\t\t| arm64ec \\\n-\t\t\t| arm[lb]e \\\n-\t\t\t| arme[lb] \\\n-\t\t\t| armv* \\\n+\t\t\t| arc | arceb \\\n+\t\t\t| arm | arm[lb]e | arme[lb] | armv* \\\n+\t\t\t| avr | avr32 \\\n \t\t\t| asmjs \\\n-\t\t\t| avr \\\n-\t\t\t| avr32 \\\n \t\t\t| ba \\\n-\t\t\t| be32 \\\n-\t\t\t| be64 \\\n-\t\t\t| bfin \\\n-\t\t\t| bpf \\\n-\t\t\t| bs2000 \\\n-\t\t\t| c30 \\\n-\t\t\t| c4x \\\n-\t\t\t| c8051 \\\n-\t\t\t| c[123]* \\\n-\t\t\t| clipper \\\n-\t\t\t| craynv \\\n-\t\t\t| csky \\\n-\t\t\t| cydra \\\n-\t\t\t| d10v \\\n-\t\t\t| d30v \\\n-\t\t\t| dlx \\\n-\t\t\t| dsp16xx \\\n-\t\t\t| e2k \\\n-\t\t\t| elxsi \\\n-\t\t\t| epiphany \\\n-\t\t\t| f30[01] \\\n-\t\t\t| f700 \\\n-\t\t\t| fido \\\n-\t\t\t| fr30 \\\n-\t\t\t| frv \\\n-\t\t\t| ft32 \\\n-\t\t\t| fx80 \\\n-\t\t\t| h8300 \\\n-\t\t\t| h8500 \\\n+\t\t\t| be32 | be64 \\\n+\t\t\t| bfin | bpf | bs2000 \\\n+\t\t\t| c[123]* | c30 | [cjt]90 | c4x \\\n+\t\t\t| c8051 | clipper | craynv | csky | cydra \\\n+\t\t\t| d10v | d30v | dlx | dsp16xx \\\n+\t\t\t| e2k | elxsi | epiphany \\\n+\t\t\t| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \\\n+\t\t\t| h8300 | h8500 \\\n+\t\t\t| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \\\n \t\t\t| hexagon \\\n-\t\t\t| hppa \\\n-\t\t\t| hppa1.[01] \\\n-\t\t\t| hppa2.0 \\\n-\t\t\t| hppa2.0[nw] \\\n-\t\t\t| hppa64 \\\n-\t\t\t| i*86 \\\n-\t\t\t| i370 \\\n-\t\t\t| i860 \\\n-\t\t\t| i960 \\\n-\t\t\t| ia16 \\\n-\t\t\t| ia64 \\\n-\t\t\t| intelgt \\\n-\t\t\t| ip2k \\\n-\t\t\t| iq2000 \\\n-\t\t\t| javascript \\\n+\t\t\t| i370 | i*86 | i860 | i960 | ia16 | ia64 \\\n+\t\t\t| ip2k | iq2000 \\\n \t\t\t| k1om \\\n-\t\t\t| kvx \\\n-\t\t\t| le32 \\\n-\t\t\t| le64 \\\n+\t\t\t| le32 | le64 \\\n \t\t\t| lm32 \\\n-\t\t\t| loongarch32 \\\n-\t\t\t| loongarch64 \\\n-\t\t\t| m32c \\\n-\t\t\t| m32r \\\n-\t\t\t| m32rle \\\n-\t\t\t| m5200 \\\n-\t\t\t| m68000 \\\n-\t\t\t| m680[012346]0 \\\n-\t\t\t| m6811 \\\n-\t\t\t| m6812 \\\n-\t\t\t| m68360 \\\n-\t\t\t| m683?2 \\\n-\t\t\t| m68hc11 \\\n-\t\t\t| m68hc12 \\\n-\t\t\t| m68hcs12x \\\n-\t\t\t| m68k \\\n-\t\t\t| m88110 \\\n-\t\t\t| m88k \\\n-\t\t\t| maxq \\\n-\t\t\t| mb \\\n-\t\t\t| mcore \\\n-\t\t\t| mep \\\n-\t\t\t| metag \\\n-\t\t\t| microblaze \\\n-\t\t\t| microblazeel \\\n-\t\t\t| mips* \\\n+\t\t\t| m32c | m32r | m32rle \\\n+\t\t\t| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \\\n+\t\t\t| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \\\n+\t\t\t| m88110 | m88k | maxq | mb | mcore | mep | metag \\\n+\t\t\t| microblaze | microblazeel \\\n+\t\t\t| mips | mipsbe | mipseb | mipsel | mipsle \\\n+\t\t\t| mips16 \\\n+\t\t\t| mips64 | mips64eb | mips64el \\\n+\t\t\t| mips64octeon | mips64octeonel \\\n+\t\t\t| mips64orion | mips64orionel \\\n+\t\t\t| mips64r5900 | mips64r5900el \\\n+\t\t\t| mips64vr | mips64vrel \\\n+\t\t\t| mips64vr4100 | mips64vr4100el \\\n+\t\t\t| mips64vr4300 | mips64vr4300el \\\n+\t\t\t| mips64vr5000 | mips64vr5000el \\\n+\t\t\t| mips64vr5900 | mips64vr5900el \\\n+\t\t\t| mipsisa32 | mipsisa32el \\\n+\t\t\t| mipsisa32r2 | mipsisa32r2el \\\n+\t\t\t| mipsisa32r6 | mipsisa32r6el \\\n+\t\t\t| mipsisa64 | mipsisa64el \\\n+\t\t\t| mipsisa64r2 | mipsisa64r2el \\\n+\t\t\t| mipsisa64r6 | mipsisa64r6el \\\n+\t\t\t| mipsisa64sb1 | mipsisa64sb1el \\\n+\t\t\t| mipsisa64sr71k | mipsisa64sr71kel \\\n+\t\t\t| mipsr5900 | mipsr5900el \\\n+\t\t\t| mipstx39 | mipstx39el \\\n \t\t\t| mmix \\\n-\t\t\t| mn10200 \\\n-\t\t\t| mn10300 \\\n+\t\t\t| mn10200 | mn10300 \\\n \t\t\t| moxie \\\n-\t\t\t| msp430 \\\n \t\t\t| mt \\\n-\t\t\t| nanomips* \\\n-\t\t\t| nds32 \\\n-\t\t\t| nds32be \\\n-\t\t\t| nds32le \\\n+\t\t\t| msp430 \\\n+\t\t\t| nds32 | nds32le | nds32be \\\n \t\t\t| nfp \\\n-\t\t\t| nios \\\n-\t\t\t| nios2 \\\n-\t\t\t| nios2eb \\\n-\t\t\t| nios2el \\\n-\t\t\t| none \\\n-\t\t\t| np1 \\\n-\t\t\t| ns16k \\\n-\t\t\t| ns32k \\\n-\t\t\t| nvptx \\\n+\t\t\t| nios | nios2 | nios2eb | nios2el \\\n+\t\t\t| none | np1 | ns16k | ns32k | nvptx \\\n \t\t\t| open8 \\\n \t\t\t| or1k* \\\n \t\t\t| or32 \\\n \t\t\t| orion \\\n-\t\t\t| pdp10 \\\n-\t\t\t| pdp11 \\\n \t\t\t| picochip \\\n-\t\t\t| pj \\\n-\t\t\t| pjl \\\n-\t\t\t| pn \\\n-\t\t\t| power \\\n-\t\t\t| powerpc \\\n-\t\t\t| powerpc64 \\\n-\t\t\t| powerpc64le \\\n-\t\t\t| powerpcle \\\n-\t\t\t| powerpcspe \\\n+\t\t\t| pdp10 | pdp11 | pj | pjl | pn | power \\\n+\t\t\t| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \\\n \t\t\t| pru \\\n \t\t\t| pyramid \\\n-\t\t\t| riscv \\\n-\t\t\t| riscv32 \\\n-\t\t\t| riscv32be \\\n-\t\t\t| riscv64 \\\n-\t\t\t| riscv64be \\\n-\t\t\t| rl78 \\\n-\t\t\t| romp \\\n-\t\t\t| rs6000 \\\n-\t\t\t| rx \\\n-\t\t\t| s390 \\\n-\t\t\t| s390x \\\n+\t\t\t| riscv | riscv32 | riscv64 \\\n+\t\t\t| rl78 | romp | rs6000 | rx \\\n+\t\t\t| s390 | s390x \\\n \t\t\t| score \\\n-\t\t\t| sh \\\n-\t\t\t| sh64 \\\n-\t\t\t| sh64le \\\n-\t\t\t| sh[12345][lb]e \\\n-\t\t\t| sh[1234] \\\n-\t\t\t| sh[1234]e[lb] \\\n-\t\t\t| sh[23]e \\\n-\t\t\t| sh[23]ele \\\n-\t\t\t| sh[24]a \\\n-\t\t\t| sh[24]ae[lb] \\\n-\t\t\t| sh[lb]e \\\n-\t\t\t| she[lb] \\\n-\t\t\t| shl \\\n-\t\t\t| sparc \\\n-\t\t\t| sparc64 \\\n-\t\t\t| sparc64b \\\n-\t\t\t| sparc64v \\\n-\t\t\t| sparc86x \\\n-\t\t\t| sparclet \\\n+\t\t\t| sh | shl \\\n+\t\t\t| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \\\n+\t\t\t| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \\\n+\t\t\t| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \\\n \t\t\t| sparclite \\\n-\t\t\t| sparcv8 \\\n-\t\t\t| sparcv9 \\\n-\t\t\t| sparcv9b \\\n-\t\t\t| sparcv9v \\\n+\t\t\t| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \\\n \t\t\t| spu \\\n-\t\t\t| sv1 \\\n-\t\t\t| sw_64 \\\n-\t\t\t| sx* \\\n \t\t\t| tahoe \\\n-\t\t\t| thumbv7* \\\n-\t\t\t| tic30 \\\n-\t\t\t| tic4x \\\n-\t\t\t| tic54x \\\n-\t\t\t| tic55x \\\n-\t\t\t| tic6x \\\n-\t\t\t| tic80 \\\n+\t\t\t| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \\\n \t\t\t| tron \\\n \t\t\t| ubicom32 \\\n-\t\t\t| v70 \\\n-\t\t\t| v810 \\\n-\t\t\t| v850 \\\n-\t\t\t| v850e \\\n-\t\t\t| v850e1 \\\n-\t\t\t| v850e2 \\\n-\t\t\t| v850e2v3 \\\n-\t\t\t| v850es \\\n+\t\t\t| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \\\n \t\t\t| vax \\\n-\t\t\t| vc4 \\\n \t\t\t| visium \\\n \t\t\t| w65 \\\n-\t\t\t| wasm32 \\\n-\t\t\t| wasm64 \\\n+\t\t\t| wasm32 | wasm64 \\\n \t\t\t| we32k \\\n-\t\t\t| x86 \\\n-\t\t\t| x86_64 \\\n-\t\t\t| xc16x \\\n-\t\t\t| xgate \\\n-\t\t\t| xps100 \\\n-\t\t\t| xstormy16 \\\n-\t\t\t| xtensa* \\\n+\t\t\t| x86 | x86_64 | xc16x | xgate | xps100 \\\n+\t\t\t| xstormy16 | xtensa* \\\n \t\t\t| ymp \\\n-\t\t\t| z80 \\\n-\t\t\t| z8k)\n+\t\t\t| z8k | z80)\n \t\t\t\t;;\n \n \t\t\t*)\n-\t\t\t\techo \"Invalid configuration '$1': machine '$cpu-$vendor' not recognized\" 1>&2\n+\t\t\t\techo Invalid configuration \\`\"$1\"\\': machine \\`\"$cpu-$vendor\"\\' not recognized 1>&2\n \t\t\t\texit 1\n \t\t\t\t;;\n \t\tesac\n@@ -1493,48 +1278,34 @@ esac\n \n # Decode manufacturer-specific aliases for certain operating systems.\n \n-if test x\"$basic_os\" != x\n+if [ x$basic_os != x ]\n then\n \n-# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just\n+# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just\n # set os.\n-obj=\n case $basic_os in\n \tgnu/linux*)\n \t\tkernel=linux\n-\t\tos=`echo \"$basic_os\" | sed -e 's|gnu/linux|gnu|'`\n-\t\t;;\n-\tos2-emx)\n-\t\tkernel=os2\n-\t\tos=`echo \"$basic_os\" | sed -e 's|os2-emx|emx|'`\n+\t\tos=`echo $basic_os | sed -e 's|gnu/linux|gnu|'`\n \t\t;;\n \tnto-qnx*)\n \t\tkernel=nto\n-\t\tos=`echo \"$basic_os\" | sed -e 's|nto-qnx|qnx|'`\n+\t\tos=`echo $basic_os | sed -e 's|nto-qnx|qnx|'`\n \t\t;;\n \t*-*)\n-\t\tsaved_IFS=$IFS\n+\t\t# shellcheck disable=SC2162\n \t\tIFS=\"-\" read kernel os <<EOF\n $basic_os\n EOF\n-\t\tIFS=$saved_IFS\n \t\t;;\n \t# Default OS when just kernel was specified\n \tnto*)\n \t\tkernel=nto\n-\t\tos=`echo \"$basic_os\" | sed -e 's|nto|qnx|'`\n-\t\t;;\n-\tironclad*)\n-\t\tkernel=ironclad\n-\t\tos=`echo \"$basic_os\" | sed -e 's|ironclad|gnu|'`\n+\t\tos=`echo $basic_os | sed -e 's|nto|qnx|'`\n \t\t;;\n \tlinux*)\n \t\tkernel=linux\n-\t\tos=`echo \"$basic_os\" | sed -e 's|linux|gnu|'`\n-\t\t;;\n-\tmanagarm*)\n-\t\tkernel=managarm\n-\t\tos=`echo \"$basic_os\" | sed -e 's|managarm|mlibc|'`\n+\t\tos=`echo $basic_os | sed -e 's|linux|gnu|'`\n \t\t;;\n \t*)\n \t\tkernel=\n@@ -1555,7 +1326,7 @@ case $os in\n \t\tos=cnk\n \t\t;;\n \tsolaris1 | solaris1.*)\n-\t\tos=`echo \"$os\" | sed -e 's|solaris1|sunos4|'`\n+\t\tos=`echo $os | sed -e 's|solaris1|sunos4|'`\n \t\t;;\n \tsolaris)\n \t\tos=solaris2\n@@ -1563,23 +1334,6 @@ case $os in\n \tunixware*)\n \t\tos=sysv4.2uw\n \t\t;;\n-\t# The marketing names for NeXT's operating systems were\n-\t# NeXTSTEP, NeXTSTEP 2, OpenSTEP 3, OpenSTEP 4.  'openstep' is\n-\t# mapped to 'openstep3', but 'openstep1' and 'openstep2' are\n-\t# mapped to 'nextstep' and 'nextstep2', consistent with the\n-\t# treatment of SunOS/Solaris.\n-\tns | ns1 | nextstep | nextstep1 | openstep1)\n-\t\tos=nextstep\n-\t\t;;\n-\tns2 | nextstep2 | openstep2)\n-\t\tos=nextstep2\n-\t\t;;\n-\tns3 | nextstep3 | openstep | openstep3)\n-\t\tos=openstep3\n-\t\t;;\n-\tns4 | nextstep4 | openstep4)\n-\t\tos=openstep4\n-\t\t;;\n \t# es1800 is here to avoid being matched by es* (a different OS)\n \tes1800*)\n \t\tos=ose\n@@ -1601,7 +1355,7 @@ case $os in\n \t\tos=sco3.2v4\n \t\t;;\n \tsco3.2.[4-9]*)\n-\t\tos=`echo \"$os\" | sed -e 's/sco3.2./sco3.2v/'`\n+\t\tos=`echo $os | sed -e 's/sco3.2./sco3.2v/'`\n \t\t;;\n \tsco*v* | scout)\n \t\t# Don't match below\n@@ -1613,7 +1367,13 @@ case $os in\n \t\tos=psos\n \t\t;;\n \tqnx*)\n-\t\tos=qnx\n+\t\tcase $cpu in\n+\t\t    x86 | i*86)\n+\t\t\t;;\n+\t\t    *)\n+\t\t\tos=nto-$os\n+\t\t\t;;\n+\t\tesac\n \t\t;;\n \thiux*)\n \t\tos=hiuxwe2\n@@ -1650,7 +1410,6 @@ case $os in\n \t\t;;\n \tutek*)\n \t\tos=bsd\n-\t\tvendor=`echo \"$vendor\" | sed -e 's|^unknown$|tektronix|'`\n \t\t;;\n \tdynix*)\n \t\tos=bsd\n@@ -1667,25 +1426,21 @@ case $os in\n \t386bsd)\n \t\tos=bsd\n \t\t;;\n-\tctix*)\n-\t\tos=sysv\n-\t\tvendor=`echo \"$vendor\" | sed -e 's|^unknown$|convergent|'`\n-\t\t;;\n-\tuts*)\n+\tctix* | uts*)\n \t\tos=sysv\n \t\t;;\n \tnova*)\n-\t\tkernel=rtmk\n-\t\tos=nova\n+\t\tos=rtmk-nova\n+\t\t;;\n+\tns2)\n+\t\tos=nextstep2\n \t\t;;\n \t# Preserve the version number of sinix5.\n \tsinix5.*)\n-\t\tos=`echo \"$os\" | sed -e 's|sinix|sysv|'`\n-\t\tvendor=`echo \"$vendor\" | sed -e 's|^unknown$|sni|'`\n+\t\tos=`echo $os | sed -e 's|sinix|sysv|'`\n \t\t;;\n \tsinix*)\n \t\tos=sysv4\n-\t\tvendor=`echo \"$vendor\" | sed -e 's|^unknown$|sni|'`\n \t\t;;\n \ttpf*)\n \t\tos=tpf\n@@ -1723,16 +1478,10 @@ case $os in\n \t\t\tos=eabi\n \t\t\t;;\n \t\t    *)\n-\t\t\tos=\n-\t\t\tobj=elf\n+\t\t\tos=elf\n \t\t\t;;\n \t\tesac\n \t\t;;\n-\taout* | coff* | elf* | pe*)\n-\t\t# These are machine code file formats, not OSes\n-\t\tobj=$os\n-\t\tos=\n-\t\t;;\n \t*)\n \t\t# No normalization, but not necessarily accepted, that comes below.\n \t\t;;\n@@ -1751,15 +1500,12 @@ else\n # system, and we'll never get to this point.\n \n kernel=\n-obj=\n case $cpu-$vendor in\n \tscore-*)\n-\t\tos=\n-\t\tobj=elf\n+\t\tos=elf\n \t\t;;\n \tspu-*)\n-\t\tos=\n-\t\tobj=elf\n+\t\tos=elf\n \t\t;;\n \t*-acorn)\n \t\tos=riscix1.2\n@@ -1769,35 +1515,28 @@ case $cpu-$vendor in\n \t\tos=gnu\n \t\t;;\n \tarm*-semi)\n-\t\tos=\n-\t\tobj=aout\n+\t\tos=aout\n \t\t;;\n \tc4x-* | tic4x-*)\n-\t\tos=\n-\t\tobj=coff\n+\t\tos=coff\n \t\t;;\n \tc8051-*)\n-\t\tos=\n-\t\tobj=elf\n+\t\tos=elf\n \t\t;;\n \tclipper-intergraph)\n \t\tos=clix\n \t\t;;\n \thexagon-*)\n-\t\tos=\n-\t\tobj=elf\n+\t\tos=elf\n \t\t;;\n \ttic54x-*)\n-\t\tos=\n-\t\tobj=coff\n+\t\tos=coff\n \t\t;;\n \ttic55x-*)\n-\t\tos=\n-\t\tobj=coff\n+\t\tos=coff\n \t\t;;\n \ttic6x-*)\n-\t\tos=\n-\t\tobj=coff\n+\t\tos=coff\n \t\t;;\n \t# This must come before the *-dec entry.\n \tpdp10-*)\n@@ -1819,43 +1558,28 @@ case $cpu-$vendor in\n \t\tos=sunos3\n \t\t;;\n \tm68*-cisco)\n-\t\tos=\n-\t\tobj=aout\n+\t\tos=aout\n \t\t;;\n \tmep-*)\n-\t\tos=\n-\t\tobj=elf\n-\t\t;;\n-\t# The -sgi and -siemens entries must be before the mips- entry\n-\t# or we get the wrong os.\n-\t*-sgi)\n-\t\tos=irix\n-\t\t;;\n-\t*-siemens)\n-\t\tos=sysv4\n+\t\tos=elf\n \t\t;;\n \tmips*-cisco)\n-\t\tos=\n-\t\tobj=elf\n+\t\tos=elf\n \t\t;;\n-\tmips*-*|nanomips*-*)\n-\t\tos=\n-\t\tobj=elf\n+\tmips*-*)\n+\t\tos=elf\n \t\t;;\n \tor32-*)\n-\t\tos=\n-\t\tobj=coff\n+\t\tos=coff\n \t\t;;\n-\t# This must be before the sparc-* entry or we get the wrong os.\n-\t*-tti)\n+\t*-tti)\t# must be before sparc entry or we get the wrong os.\n \t\tos=sysv3\n \t\t;;\n \tsparc-* | *-sun)\n \t\tos=sunos4.1.1\n \t\t;;\n \tpru-*)\n-\t\tos=\n-\t\tobj=elf\n+\t\tos=elf\n \t\t;;\n \t*-be)\n \t\tos=beos\n@@ -1879,7 +1603,7 @@ case $cpu-$vendor in\n \t\tos=hpux\n \t\t;;\n \t*-hitachi)\n-\t\tos=hiuxwe2\n+\t\tos=hiux\n \t\t;;\n \ti860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)\n \t\tos=sysv\n@@ -1923,6 +1647,12 @@ case $cpu-$vendor in\n \t*-encore)\n \t\tos=bsd\n \t\t;;\n+\t*-sgi)\n+\t\tos=irix\n+\t\t;;\n+\t*-siemens)\n+\t\tos=sysv4\n+\t\t;;\n \t*-masscomp)\n \t\tos=rtu\n \t\t;;\n@@ -1930,12 +1660,10 @@ case $cpu-$vendor in\n \t\tos=uxpv\n \t\t;;\n \t*-rom68k)\n-\t\tos=\n-\t\tobj=coff\n+\t\tos=coff\n \t\t;;\n \t*-*bug)\n-\t\tos=\n-\t\tobj=coff\n+\t\tos=coff\n \t\t;;\n \t*-apple)\n \t\tos=macos\n@@ -1953,325 +1681,83 @@ esac\n \n fi\n \n-# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).\n-\n+# Now, validate our (potentially fixed-up) OS.\n case $os in\n-\t# Sometimes we do \"kernel-libc\", so those need to count as OSes.\n-\tllvm* | musl* | newlib* | relibc* | uclibc*)\n-\t\t;;\n-\t# Likewise for \"kernel-abi\"\n-\teabi* | gnueabi*)\n+\t# Sometimes we do \"kernel-abi\", so those need to count as OSes.\n+\tmusl* | newlib* | uclibc*)\n \t\t;;\n-\t# VxWorks passes extra cpu info in the 4th filed.\n-\tsimlinux | simwindows | spe)\n-\t\t;;\n-\t# See `case $cpu-$os` validation below\n-\tghcjs)\n+\t# Likewise for \"kernel-libc\"\n+\teabi | eabihf | gnueabi | gnueabihf)\n \t\t;;\n \t# Now accept the basic system types.\n+\t# The portable systems comes first.\n \t# Each alternative MUST end in a * to match a version number.\n-\t  abug \\\n-\t| aix* \\\n-\t| amdhsa* \\\n-\t| amigados* \\\n-\t| amigaos* \\\n-\t| android* \\\n-\t| aof* \\\n-\t| aos* \\\n-\t| aros* \\\n-\t| atheos* \\\n-\t| auroraux* \\\n-\t| aux* \\\n-\t| banan_os* \\\n-\t| beos* \\\n-\t| bitrig* \\\n-\t| bme* \\\n-\t| bosx* \\\n-\t| bsd* \\\n-\t| cegcc* \\\n-\t| chorusos* \\\n-\t| chorusrdb* \\\n-\t| clix* \\\n-\t| cloudabi* \\\n-\t| cnk* \\\n-\t| conix* \\\n-\t| cos* \\\n-\t| cxux* \\\n-\t| cygwin* \\\n-\t| darwin* \\\n-\t| dgux* \\\n-\t| dicos* \\\n-\t| dnix* \\\n-\t| domain* \\\n-\t| dragonfly* \\\n-\t| drops* \\\n-\t| ebmon* \\\n-\t| ecoff* \\\n-\t| ekkobsd* \\\n-\t| emscripten* \\\n-\t| emx* \\\n-\t| es* \\\n-\t| fiwix* \\\n-\t| freebsd* \\\n-\t| fuchsia* \\\n-\t| genix* \\\n-\t| genode* \\\n-\t| glidix* \\\n-\t| gnu* \\\n-\t| go32* \\\n-\t| haiku* \\\n-\t| hcos* \\\n-\t| hiux* \\\n-\t| hms* \\\n-\t| hpux* \\\n-\t| ieee* \\\n-\t| interix* \\\n-\t| ios* \\\n-\t| iris* \\\n-\t| irix* \\\n-\t| isc* \\\n-\t| its* \\\n-\t| l4re* \\\n-\t| libertybsd* \\\n-\t| lites* \\\n-\t| lnews* \\\n-\t| luna* \\\n-\t| lynxos* \\\n-\t| mach* \\\n-\t| macos* \\\n-\t| magic* \\\n-\t| mbr* \\\n-\t| midipix* \\\n-\t| midnightbsd* \\\n-\t| mingw32* \\\n-\t| mingw64* \\\n-\t| minix* \\\n-\t| mint* \\\n-\t| mirbsd* \\\n-\t| mks* \\\n-\t| mlibc* \\\n-\t| mmixware* \\\n-\t| mon960* \\\n-\t| morphos* \\\n-\t| moss* \\\n-\t| moxiebox* \\\n-\t| mpeix* \\\n-\t| mpw* \\\n-\t| msdos* \\\n-\t| msys* \\\n-\t| mvs* \\\n-\t| nacl* \\\n-\t| netbsd* \\\n-\t| netware* \\\n-\t| newsos* \\\n-\t| nextstep* \\\n-\t| nindy* \\\n-\t| nonstopux* \\\n-\t| nova* \\\n-\t| nsk* \\\n-\t| nucleus* \\\n-\t| nx6 \\\n-\t| nx7 \\\n-\t| oabi* \\\n-\t| ohos* \\\n-\t| onefs* \\\n-\t| openbsd* \\\n-\t| openedition* \\\n-\t| openstep* \\\n-\t| os108* \\\n-\t| os2* \\\n-\t| os400* \\\n-\t| os68k* \\\n-\t| os9* \\\n-\t| ose* \\\n-\t| osf* \\\n-\t| oskit* \\\n-\t| osx* \\\n-\t| palmos* \\\n-\t| phoenix* \\\n-\t| plan9* \\\n-\t| powermax* \\\n-\t| powerunix* \\\n-\t| proelf* \\\n-\t| psos* \\\n-\t| psp* \\\n-\t| ptx* \\\n-\t| pw32* \\\n-\t| qnx* \\\n-\t| rdos* \\\n-\t| redox* \\\n-\t| rhapsody* \\\n-\t| riscix* \\\n-\t| riscos* \\\n-\t| rtems* \\\n-\t| rtmk* \\\n-\t| rtu* \\\n-\t| scout* \\\n-\t| secbsd* \\\n-\t| sei* \\\n-\t| serenity* \\\n-\t| sim* \\\n-\t| skyos* \\\n-\t| solaris* \\\n-\t| solidbsd* \\\n-\t| sortix* \\\n-\t| storm-chaos* \\\n-\t| sunos \\\n-\t| sunos[34]* \\\n-\t| superux* \\\n-\t| syllable* \\\n-\t| sym* \\\n-\t| sysv* \\\n-\t| tenex* \\\n-\t| tirtos* \\\n-\t| tock* \\\n-\t| toppers* \\\n-\t| tops10* \\\n-\t| tops20* \\\n-\t| tpf* \\\n-\t| tvos* \\\n-\t| twizzler* \\\n-\t| uclinux* \\\n-\t| udi* \\\n-\t| udk* \\\n-\t| ultrix* \\\n-\t| unicos* \\\n-\t| uniplus* \\\n-\t| unleashed* \\\n-\t| unos* \\\n-\t| uwin* \\\n-\t| uxpv* \\\n-\t| v88r* \\\n-\t|*vms* \\\n-\t| vos* \\\n-\t| vsta* \\\n-\t| vxsim* \\\n-\t| vxworks* \\\n-\t| wasi* \\\n-\t| watchos* \\\n-\t| wince* \\\n-\t| windiss* \\\n-\t| windows* \\\n-\t| winnt* \\\n-\t| xenix* \\\n-\t| xray* \\\n-\t| zephyr* \\\n-\t| zvmoe* )\n+\tgnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \\\n+\t     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \\\n+\t     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \\\n+\t     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \\\n+\t     | hiux* | abug | nacl* | netware* | windows* \\\n+\t     | os9* | macos* | osx* | ios* \\\n+\t     | mpw* | magic* | mmixware* | mon960* | lnews* \\\n+\t     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \\\n+\t     | aos* | aros* | cloudabi* | sortix* | twizzler* \\\n+\t     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \\\n+\t     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \\\n+\t     | mirbsd* | netbsd* | dicos* | openedition* | ose* \\\n+\t     | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \\\n+\t     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \\\n+\t     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \\\n+\t     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \\\n+\t     | udi* | lites* | ieee* | go32* | aux* | hcos* \\\n+\t     | chorusrdb* | cegcc* | glidix* \\\n+\t     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \\\n+\t     | midipix* | mingw32* | mingw64* | mint* \\\n+\t     | uxpv* | beos* | mpeix* | udk* | moxiebox* \\\n+\t     | interix* | uwin* | mks* | rhapsody* | darwin* \\\n+\t     | openstep* | oskit* | conix* | pw32* | nonstopux* \\\n+\t     | storm-chaos* | tops10* | tenex* | tops20* | its* \\\n+\t     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \\\n+\t     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \\\n+\t     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \\\n+\t     | skyos* | haiku* | rdos* | toppers* | drops* | es* \\\n+\t     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \\\n+\t     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \\\n+\t     | nsk* | powerunix* | genode* | zvmoe* )\n \t\t;;\n \t# This one is extra strict with allowed versions\n \tsco3.2v2 | sco3.2v[4-9]* | sco5v6*)\n \t\t# Don't forget version if it is 3.2v4 or newer.\n \t\t;;\n-\t# This refers to builds using the UEFI calling convention\n-\t# (which depends on the architecture) and PE file format.\n-\t# Note that this is both a different calling convention and\n-\t# different file format than that of GNU-EFI\n-\t# (x86_64-w64-mingw32).\n-\tuefi)\n-\t\t;;\n \tnone)\n \t\t;;\n-\tkernel* | msvc* )\n-\t\t# Restricted further below\n-\t\t;;\n-\t'')\n-\t\tif test x\"$obj\" = x\n-\t\tthen\n-\t\t\techo \"Invalid configuration '$1': Blank OS only allowed with explicit machine code file format\" 1>&2\n-\t\tfi\n-\t\t;;\n-\t*)\n-\t\techo \"Invalid configuration '$1': OS '$os' not recognized\" 1>&2\n-\t\texit 1\n-\t\t;;\n-esac\n-\n-case $obj in\n-\taout* | coff* | elf* | pe*)\n-\t\t;;\n-\t'')\n-\t\t# empty is fine\n-\t\t;;\n \t*)\n-\t\techo \"Invalid configuration '$1': Machine code format '$obj' not recognized\" 1>&2\n-\t\texit 1\n-\t\t;;\n-esac\n-\n-# Here we handle the constraint that a (synthetic) cpu and os are\n-# valid only in combination with each other and nowhere else.\n-case $cpu-$os in\n-\t# The \"javascript-unknown-ghcjs\" triple is used by GHC; we\n-\t# accept it here in order to tolerate that, but reject any\n-\t# variations.\n-\tjavascript-ghcjs)\n-\t\t;;\n-\tjavascript-* | *-ghcjs)\n-\t\techo \"Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'\" 1>&2\n+\t\techo Invalid configuration \\`\"$1\"\\': OS \\`\"$os\"\\' not recognized 1>&2\n \t\texit 1\n \t\t;;\n esac\n \n # As a final step for OS-related things, validate the OS-kernel combination\n # (given a valid OS), if there is a kernel.\n-case $kernel-$os-$obj in\n-\tlinux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \\\n-\t\t    | linux-mlibc*- | linux-musl*- | linux-newlib*- \\\n-\t\t    | linux-relibc*- | linux-uclibc*- | linux-ohos*- )\n-\t\t;;\n-\tuclinux-uclibc*- | uclinux-gnu*- )\n-\t\t;;\n-\tironclad-gnu*- | ironclad-mlibc*- )\n+case $kernel-$os in\n+\tlinux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* )\n \t\t;;\n-\tmanagarm-mlibc*- | managarm-kernel*- )\n-\t\t;;\n-\twindows*-msvc*-)\n-\t\t;;\n-\t-dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \\\n-\t\t    | -uclibc*- )\n+\t-dietlibc* | -newlib* | -musl* | -uclibc* )\n \t\t# These are just libc implementations, not actual OSes, and thus\n \t\t# require a kernel.\n-\t\techo \"Invalid configuration '$1': libc '$os' needs explicit kernel.\" 1>&2\n+\t\techo \"Invalid configuration \\`$1': libc \\`$os' needs explicit kernel.\" 1>&2\n \t\texit 1\n \t\t;;\n-\t-kernel*- )\n-\t\techo \"Invalid configuration '$1': '$os' needs explicit kernel.\" 1>&2\n-\t\texit 1\n+\tkfreebsd*-gnu* | kopensolaris*-gnu*)\n \t\t;;\n-\t*-kernel*- )\n-\t\techo \"Invalid configuration '$1': '$kernel' does not support '$os'.\" 1>&2\n-\t\texit 1\n-\t\t;;\n-\t*-msvc*- )\n-\t\techo \"Invalid configuration '$1': '$os' needs 'windows'.\" 1>&2\n-\t\texit 1\n-\t\t;;\n-\tkfreebsd*-gnu*- | knetbsd*-gnu*- | netbsd*-gnu*- | kopensolaris*-gnu*-)\n-\t\t;;\n-\tvxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)\n-\t\t;;\n-\tnto-qnx*-)\n-\t\t;;\n-\tos2-emx-)\n-\t\t;;\n-\trtmk-nova-)\n-\t\t;;\n-\t*-eabi*- | *-gnueabi*-)\n-\t\t;;\n-\tios*-simulator- | tvos*-simulator- | watchos*-simulator- )\n+\tnto-qnx*)\n \t\t;;\n-\tnone--*)\n-\t\t# None (no kernel, i.e. freestanding / bare metal),\n-\t\t# can be paired with an machine code file format\n+\t*-eabi* | *-gnueabi*)\n \t\t;;\n-\t-*-)\n+\t-*)\n \t\t# Blank kernel with real OS is always fine.\n \t\t;;\n-\t--*)\n-\t\t# Blank kernel and OS with real machine code file format is always fine.\n-\t\t;;\n-\t*-*-*)\n-\t\techo \"Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'.\" 1>&2\n+\t*-*)\n+\t\techo \"Invalid configuration \\`$1': Kernel \\`$kernel' not known to work with OS \\`$os'.\" 1>&2\n \t\texit 1\n \t\t;;\n esac\n@@ -2284,7 +1770,7 @@ case $vendor in\n \t\t\t*-riscix*)\n \t\t\t\tvendor=acorn\n \t\t\t\t;;\n-\t\t\t*-sunos* | *-solaris*)\n+\t\t\t*-sunos*)\n \t\t\t\tvendor=sun\n \t\t\t\t;;\n \t\t\t*-cnk* | *-aix*)\n@@ -2354,12 +1840,12 @@ case $vendor in\n \t\t;;\n esac\n \n-echo \"$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}\"\n+echo \"$cpu-$vendor-${kernel:+$kernel-}$os\"\n exit\n \n # Local variables:\n-# eval: (add-hook 'before-save-hook 'time-stamp nil t)\n+# eval: (add-hook 'before-save-hook 'time-stamp)\n # time-stamp-start: \"timestamp='\"\n-# time-stamp-format: \"%Y-%02m-%02d\"\n+# time-stamp-format: \"%:y-%02m-%02d\"\n # time-stamp-end: \"'\"\n # End:\ndiff --git a/nspr/build/sanitizers/lsan_suppressions.txt b/nspr/build/sanitizers/lsan_suppressions.txt\ndeleted file mode 100644\nindex e4cb762..0000000\n--- a/nspr/build/sanitizers/lsan_suppressions.txt\n+++ /dev/null\n@@ -1,19 +0,0 @@\n-# LeakSanitizer suppressions for the NSPR test suite.\n-#\n-# These entries cover NSPR's process-global singletons that are allocated\n-# once during PR_Init / lazy initialization and deliberately never freed\n-# for the life of the process. They are not growing leaks (e.g. the reinit\n-# test performs several PR_Init/PR_Cleanup cycles yet only one instance of\n-# each is ever allocated), so they are safe to suppress rather than adding\n-# teardown to the stable, widely-deployed library ABI.\n-#\n-# Format: https://clang.llvm.org/docs/AddressSanitizer.html#suppressing-memory-leaks\n-\n-# Thread-private-data key table (pr/src/threads/prtpd.c).\n-leak:_PR_InitTPD\n-\n-# Dynamic linker global state and the initial library path (pr/src/linking/prlink.c).\n-leak:_PR_InitLinker\n-\n-# File-descriptor cache entries (pr/src/io/prfdcach.c).\n-leak:_PR_Getfd\ndiff --git a/nspr/build/win32/pgomerge.py b/nspr/build/win32/pgomerge.py\nold mode 100755\nnew mode 100644\nindex 6206387..313d668\n--- a/nspr/build/win32/pgomerge.py\n+++ b/nspr/build/win32/pgomerge.py\n@@ -8,41 +8,37 @@\n # $PWD/$basename.pgd using pgomgr, then deletes them.\n # No errors if any of these files don't exist.\n \n-import os\n-import os.path\n-import subprocess\n-import sys\n-\n+import sys, os, os.path, subprocess\n if not sys.platform == \"win32\":\n-    raise RuntimeError(\"This script was only meant for Windows.\")\n-\n+    raise Exception(\"This script was only meant for Windows.\")\n \n def MergePGOFiles(basename, pgddir, pgcdir):\n-    \"\"\"Merge pgc files produced from an instrumented binary\n-    into the pgd file for the second pass of profile-guided optimization\n-    with MSVC.  |basename| is the name of the DLL or EXE without the\n-    extension.  |pgddir| is the path that contains <basename>.pgd\n-    (should be the objdir it was built in).  |pgcdir| is the path\n-    containing basename!N.pgc files, which is probably dist/bin.\n-    Calls pgomgr to merge each pgc file into the pgd, then deletes\n-    the pgc files.\"\"\"\n-    if not os.path.isdir(pgddir) or not os.path.isdir(pgcdir):\n-        return\n-    pgdfile = os.path.abspath(os.path.join(pgddir, basename + \".pgd\"))\n-    if not os.path.isfile(pgdfile):\n-        return\n-    for file in os.listdir(pgcdir):\n-        if file.startswith(basename + \"!\") and file.endswith(\".pgc\"):\n-            try:\n-                pgcfile = os.path.normpath(os.path.join(pgcdir, file))\n-                subprocess.call([\"pgomgr\", \"-merge\", pgcfile, pgdfile])\n-                os.remove(pgcfile)\n-            except OSError:\n-                pass\n-\n+  \"\"\"Merge pgc files produced from an instrumented binary\n+     into the pgd file for the second pass of profile-guided optimization\n+     with MSVC.  |basename| is the name of the DLL or EXE without the\n+     extension.  |pgddir| is the path that contains <basename>.pgd\n+     (should be the objdir it was built in).  |pgcdir| is the path\n+     containing basename!N.pgc files, which is probably dist/bin.\n+     Calls pgomgr to merge each pgc file into the pgd, then deletes\n+     the pgc files.\"\"\"\n+  if not os.path.isdir(pgddir) or not os.path.isdir(pgcdir):\n+    return\n+  pgdfile = os.path.abspath(os.path.join(pgddir, basename + \".pgd\"))\n+  if not os.path.isfile(pgdfile):\n+    return\n+  for file in os.listdir(pgcdir):\n+    if file.startswith(basename+\"!\") and file.endswith(\".pgc\"):\n+      try:\n+        pgcfile = os.path.normpath(os.path.join(pgcdir, file))\n+        subprocess.call(['pgomgr', '-merge',\n+                         pgcfile,\n+                         pgdfile])\n+        os.remove(pgcfile)\n+      except OSError:\n+        pass\n \n-if __name__ == \"__main__\":\n-    if len(sys.argv) != 3:\n-        print(\"Usage: pgomerge.py <binary basename> <dist/bin>\", file=sys.stderr)\n-        sys.exit(1)\n-    MergePGOFiles(sys.argv[1], os.getcwd(), sys.argv[2])\n+if __name__ == '__main__':\n+  if len(sys.argv) != 3:\n+      print >>sys.stderr, \"Usage: pgomerge.py <binary basename> <dist/bin>\"\n+      sys.exit(1)\n+  MergePGOFiles(sys.argv[1], os.getcwd(), sys.argv[2])\ndiff --git a/nspr/config/.cvsignore b/nspr/config/.cvsignore\nnew file mode 100644\nindex 0000000..bb3ee4b\n--- /dev/null\n+++ b/nspr/config/.cvsignore\n@@ -0,0 +1,11 @@\n+nfspwd\n+revdepth\n+my_config.mk\n+my_overrides.mk\n+autoconf.mk\n+nsprincl.mk\n+nsprincl.sh\n+now\n+Makefile\n+nsinstall\n+nspr-config\ndiff --git a/nspr/config/autoconf.mk.in b/nspr/config/autoconf.mk.in\nindex 4257db9..08a1024 100644\n--- a/nspr/config/autoconf.mk.in\n+++ b/nspr/config/autoconf.mk.in\n@@ -1,3 +1,4 @@\n+# -*- Mode: Makefile -*-\n # This Source Code Form is subject to the terms of the Mozilla Public\n # License, v. 2.0. If a copy of the MPL was not distributed with this\n # file, You can obtain one at http://mozilla.org/MPL/2.0/.\n@@ -47,6 +48,7 @@ MOZ_OPTIMIZE\t= @MOZ_OPTIMIZE@\n MOZ_DEBUG\t= @MOZ_DEBUG@\n MOZ_DEBUG_SYMBOLS = @MOZ_DEBUG_SYMBOLS@\n \n+USE_CPLUS\t= @USE_CPLUS@\n USE_IPV6\t= @USE_IPV6@\n USE_N32\t\t= @USE_N32@\n USE_X32\t\t= @USE_X32@\ndiff --git a/nspr/config/libc_r.h b/nspr/config/libc_r.h\nindex d4ad1c1..2af8f2e 100644\n--- a/nspr/config/libc_r.h\n+++ b/nspr/config/libc_r.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/config/now.c b/nspr/config/now.c\nindex cd221e1..f949ba5 100644\n--- a/nspr/config/now.c\n+++ b/nspr/config/now.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/config/nsinstall.c b/nspr/config/nsinstall.c\nindex 2d3cb96..bba9297 100644\n--- a/nspr/config/nsinstall.c\n+++ b/nspr/config/nsinstall.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/config/nspr.m4 b/nspr/config/nspr.m4\nindex a24e4a4..d21df69 100644\n--- a/nspr/config/nspr.m4\n+++ b/nspr/config/nspr.m4\n@@ -1,3 +1,4 @@\n+# -*- tab-width: 4; -*-\n # Configure paths for NSPR\n # Public domain - Chris Seawood <cls@seawood.org> 2001-04-05\n # Based upon gtk.m4 (also PD) by Owen Taylor\ndiff --git a/nspr/config/pathsub.h b/nspr/config/pathsub.h\nindex 4588a67..98b6c11 100644\n--- a/nspr/config/pathsub.h\n+++ b/nspr/config/pathsub.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/config/prdepend.h b/nspr/config/prdepend.h\nindex 160356e..6c66b37 100644\n--- a/nspr/config/prdepend.h\n+++ b/nspr/config/prdepend.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/configure b/nspr/configure\nindex 86f59e6..da498b1 100755\n--- a/nspr/configure\n+++ b/nspr/configure\n@@ -3003,8 +3003,8 @@ test -n \"$target_alias\" &&\n   program_prefix=${target_alias}-\n \n MOD_MAJOR_VERSION=4\n-MOD_MINOR_VERSION=40\n-MOD_PATCH_VERSION=0\n+MOD_MINOR_VERSION=38\n+MOD_PATCH_VERSION=2\n NSPR_MODNAME=nspr20\n _HAVE_PTHREADS=\n USE_PTHREADS=\ndiff --git a/nspr/configure.in b/nspr/configure.in\nindex 3072ba5..70e43dd 100644\n--- a/nspr/configure.in\n+++ b/nspr/configure.in\n@@ -15,8 +15,8 @@ dnl ========================================================\n dnl = Defaults\n dnl ========================================================\n MOD_MAJOR_VERSION=4\n-MOD_MINOR_VERSION=40\n-MOD_PATCH_VERSION=0\n+MOD_MINOR_VERSION=38\n+MOD_PATCH_VERSION=2\n NSPR_MODNAME=nspr20\n _HAVE_PTHREADS=\n USE_PTHREADS=\n@@ -25,6 +25,7 @@ USE_NSPR_THREADS=\n USE_N32=\n USE_X32=\n USE_64=\n+USE_CPLUS=\n USE_IPV6=\n USE_MDUPDATE=\n _MACOSX_DEPLOYMENT_TARGET=\n@@ -373,6 +374,12 @@ AC_ARG_ENABLE(mdupdate,\n \t    USE_MDUPDATE=1\n       fi ])\n \n+AC_ARG_ENABLE(cplus,\n+    [  --enable-cplus          Enable some c++ api routines],\n+    [ if test \"$enableval\" = \"yes\"; then\n+\t    USE_CPLUS=1\n+      fi])\n+\n AC_ARG_WITH(arm-kuser,\n     [  --with-arm-kuser        Use kuser helpers (Linux/ARM only)\n                           (Requires kernel 2.6.13 or later)],\n@@ -525,6 +532,11 @@ AC_PROG_CC\n \n dnl Reenter the conditional blocks after invoking AC_PROG_CC.\n if test \"$target\" != \"$host\"; then\n+    if test -n \"$USE_CPLUS\"; then\n+        AC_CHECK_PROGS(CXX, $CXX \"${target_alias}-g++\" \"${target}-g++\", echo)\n+        unset ac_cv_prog_CXX\n+        AC_PROG_CXX\n+    fi\n \n     case \"$build:$target\" in\n       powerpc-apple-darwin8*:i?86-apple-darwin*|*:arm*-apple-darwin*)\n@@ -567,6 +579,13 @@ if test \"$target\" != \"$host\"; then\n     CFLAGS=$_SAVE_CFLAGS\n     LDFLAGS=$_SAVE_LDFLAGS\n else\n+    if test -n \"$USE_CPLUS\"; then\n+        if test \"$CC\" = \"cl\" -a -z \"$CXX\"; then\n+            CXX=$CC\n+        else\n+            AC_PROG_CXX\n+        fi\n+    fi\n     AC_PROG_RANLIB\n     AC_PATH_PROGS(AS, as, $CC)\n     AC_PATH_PROGS(AR, ar, echo not_ar)\n@@ -2377,6 +2396,7 @@ AC_SUBST(MOZ_OPTIMIZE)\n AC_SUBST(MOZ_DEBUG)\n AC_SUBST(MOZ_DEBUG_SYMBOLS)\n \n+AC_SUBST(USE_CPLUS)\n AC_SUBST(USE_IPV6)\n AC_SUBST(USE_N32)\n AC_SUBST(USE_X32)\n@@ -2521,6 +2541,13 @@ elif test -n \"$USE_BTHREADS\"; then\n     \"\n fi\n \n+if test -n \"$USE_CPLUS\"; then\n+    MAKEFILES=\"$MAKEFILES\n+        pr/src/cplus/Makefile\n+        pr/src/cplus/tests/Makefile\n+    \"\n+fi\n+\n echo $MAKEFILES > unallmakefiles\n \n AC_CONFIG_FILES([$MAKEFILES])\ndiff --git a/nspr/lib/.cvsignore b/nspr/lib/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/lib/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/lib/ds/.cvsignore b/nspr/lib/ds/.cvsignore\nnew file mode 100644\nindex 0000000..bcab60f\n--- /dev/null\n+++ b/nspr/lib/ds/.cvsignore\n@@ -0,0 +1,2 @@\n+Makefile\n+_pl_bld.h\ndiff --git a/nspr/lib/ds/plarena.c b/nspr/lib/ds/plarena.c\nindex 3a96d60..1c7e116 100644\n--- a/nspr/lib/ds/plarena.c\n+++ b/nspr/lib/ds/plarena.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -19,61 +20,60 @@\n #ifdef PL_ARENAMETER\n static PLArenaStats* arena_stats_list;\n \n-#define COUNT(pool, what) (pool)->stats.what++\n+#  define COUNT(pool, what) (pool)->stats.what++\n #else\n-#define COUNT(pool, what) /* nothing */\n+#  define COUNT(pool, what) /* nothing */\n #endif\n \n #define PL_ARENA_DEFAULT_ALIGN sizeof(double)\n \n PR_IMPLEMENT(void)\n PL_InitArenaPool(PLArenaPool* pool, const char* name, PRUint32 size,\n-                 PRUint32 align)\n-{\n-    /*\n-     * Look-up table of PR_BITMASK(PR_CeilingLog2(align)) values for\n-     * align = 1 to 32.\n-     */\n-    static const PRUint8 pmasks[33] = {\n-        0, /*  not used */\n-        0, 1, 3, 3, 7, 7, 7, 7,\n-        15, 15, 15, 15, 15, 15, 15, 15, /*  1 ... 16 */\n-        31, 31, 31, 31, 31, 31, 31, 31,\n-        31, 31, 31, 31, 31, 31, 31, 31 /* 17 ... 32 */\n-    };\n-\n-    if (align == 0) {\n-        align = PL_ARENA_DEFAULT_ALIGN;\n-    }\n-\n-    if (align < sizeof(pmasks) / sizeof(pmasks[0])) {\n-        pool->mask = pmasks[align];\n-    } else {\n-        pool->mask = PR_BITMASK(PR_CeilingLog2(align));\n-    }\n-\n-    pool->first.next = NULL;\n-    /* Set all three addresses in pool->first to the same dummy value.\n-     * These addresses are only compared with each other, but never\n-     * dereferenced. */\n-    pool->first.base = pool->first.avail = pool->first.limit =\n-        (PRUword)PL_ARENA_ALIGN(pool, &pool->first + 1);\n-    pool->current = &pool->first;\n-    /*\n-     * Compute the net size so that each arena's gross size is |size|.\n-     * sizeof(PLArena) + pool->mask is the header and alignment slop\n-     * that PL_ArenaAllocate adds to the net size.\n-     */\n-    if (size > sizeof(PLArena) + pool->mask) {\n-        pool->arenasize = size - (sizeof(PLArena) + pool->mask);\n-    } else {\n-        pool->arenasize = size;\n-    }\n+                 PRUint32 align) {\n+  /*\n+   * Look-up table of PR_BITMASK(PR_CeilingLog2(align)) values for\n+   * align = 1 to 32.\n+   */\n+  static const PRUint8 pmasks[33] = {\n+      0, /*  not used */\n+      0,  1,  3,  3,  7,  7,  7,  7,\n+      15, 15, 15, 15, 15, 15, 15, 15, /*  1 ... 16 */\n+      31, 31, 31, 31, 31, 31, 31, 31,\n+      31, 31, 31, 31, 31, 31, 31, 31 /* 17 ... 32 */\n+  };\n+\n+  if (align == 0) {\n+    align = PL_ARENA_DEFAULT_ALIGN;\n+  }\n+\n+  if (align < sizeof(pmasks) / sizeof(pmasks[0])) {\n+    pool->mask = pmasks[align];\n+  } else {\n+    pool->mask = PR_BITMASK(PR_CeilingLog2(align));\n+  }\n+\n+  pool->first.next = NULL;\n+  /* Set all three addresses in pool->first to the same dummy value.\n+   * These addresses are only compared with each other, but never\n+   * dereferenced. */\n+  pool->first.base = pool->first.avail = pool->first.limit =\n+      (PRUword)PL_ARENA_ALIGN(pool, &pool->first + 1);\n+  pool->current = &pool->first;\n+  /*\n+   * Compute the net size so that each arena's gross size is |size|.\n+   * sizeof(PLArena) + pool->mask is the header and alignment slop\n+   * that PL_ArenaAllocate adds to the net size.\n+   */\n+  if (size > sizeof(PLArena) + pool->mask) {\n+    pool->arenasize = size - (sizeof(PLArena) + pool->mask);\n+  } else {\n+    pool->arenasize = size;\n+  }\n #ifdef PL_ARENAMETER\n-    memset(&pool->stats, 0, sizeof pool->stats);\n-    pool->stats.name = strdup(name);\n-    pool->stats.next = arena_stats_list;\n-    arena_stats_list = &pool->stats;\n+  memset(&pool->stats, 0, sizeof pool->stats);\n+  pool->stats.name = strdup(name);\n+  pool->stats.next = arena_stats_list;\n+  arena_stats_list = &pool->stats;\n #endif\n }\n \n@@ -96,263 +96,235 @@ PL_InitArenaPool(PLArenaPool* pool, const char* name, PRUint32 size,\n **\n */\n \n-PR_IMPLEMENT(void*)\n-PL_ArenaAllocate(PLArenaPool* pool, PRUint32 nb)\n-{\n-    PLArena* a;\n-    char* rp; /* returned pointer */\n-    PRUint32 nbOld;\n-\n-    PR_ASSERT((nb & pool->mask) == 0);\n-\n-    nbOld = nb;\n-    nb = (PRUword)PL_ARENA_ALIGN(pool, nb); /* force alignment */\n-    if (nb < nbOld) {\n-        return NULL;\n-    }\n+PR_IMPLEMENT(void*) PL_ArenaAllocate(PLArenaPool* pool, PRUint32 nb) {\n+  PLArena* a;\n+  char* rp; /* returned pointer */\n+  PRUint32 nbOld;\n \n-    /* attempt to allocate from arenas at pool->current */\n-    {\n-        a = pool->current;\n-        do {\n-            if (nb <= a->limit - a->avail) {\n-                pool->current = a;\n-                rp = (char*)a->avail;\n-                a->avail += nb;\n-                return rp;\n-            }\n-        } while (NULL != (a = a->next));\n-    }\n+  PR_ASSERT((nb & pool->mask) == 0);\n+\n+  nbOld = nb;\n+  nb = (PRUword)PL_ARENA_ALIGN(pool, nb); /* force alignment */\n+  if (nb < nbOld) {\n+    return NULL;\n+  }\n \n-    /* attempt to allocate from the heap */\n-    {\n-        PRUint32 sz = PR_MAX(pool->arenasize, nb);\n-        if (PR_UINT32_MAX - sz < sizeof *a + pool->mask) {\n-            a = NULL;\n-        } else {\n-            sz += sizeof *a + pool->mask; /* header and alignment slop */\n-            a = (PLArena*)PR_MALLOC(sz);\n-        }\n-        if (NULL != a) {\n-            a->limit = (PRUword)a + sz;\n-            a->base = a->avail = (PRUword)PL_ARENA_ALIGN(pool, a + 1);\n-            PL_MAKE_MEM_NOACCESS((void*)a->avail, a->limit - a->avail);\n-            rp = (char*)a->avail;\n-            a->avail += nb;\n-            PR_ASSERT(a->avail <= a->limit);\n-            /* the newly allocated arena is linked after pool->current\n-             *  and becomes pool->current */\n-            a->next = pool->current->next;\n-            pool->current->next = a;\n-            pool->current = a;\n-            if (NULL == pool->first.next) {\n-                pool->first.next = a;\n-            }\n-            PL_COUNT_ARENA(pool, ++);\n-            COUNT(pool, nmallocs);\n-            return (rp);\n-        }\n+  /* attempt to allocate from arenas at pool->current */\n+  {\n+    a = pool->current;\n+    do {\n+      if (nb <= a->limit - a->avail) {\n+        pool->current = a;\n+        rp = (char*)a->avail;\n+        a->avail += nb;\n+        return rp;\n+      }\n+    } while (NULL != (a = a->next));\n+  }\n+\n+  /* attempt to allocate from the heap */\n+  {\n+    PRUint32 sz = PR_MAX(pool->arenasize, nb);\n+    if (PR_UINT32_MAX - sz < sizeof *a + pool->mask) {\n+      a = NULL;\n+    } else {\n+      sz += sizeof *a + pool->mask; /* header and alignment slop */\n+      a = (PLArena*)PR_MALLOC(sz);\n+    }\n+    if (NULL != a) {\n+      a->limit = (PRUword)a + sz;\n+      a->base = a->avail = (PRUword)PL_ARENA_ALIGN(pool, a + 1);\n+      PL_MAKE_MEM_NOACCESS((void*)a->avail, a->limit - a->avail);\n+      rp = (char*)a->avail;\n+      a->avail += nb;\n+      PR_ASSERT(a->avail <= a->limit);\n+      /* the newly allocated arena is linked after pool->current\n+       *  and becomes pool->current */\n+      a->next = pool->current->next;\n+      pool->current->next = a;\n+      pool->current = a;\n+      if (NULL == pool->first.next) {\n+        pool->first.next = a;\n+      }\n+      PL_COUNT_ARENA(pool, ++);\n+      COUNT(pool, nmallocs);\n+      return (rp);\n     }\n+  }\n \n-    /* we got to here, and there's no memory to allocate */\n-    return (NULL);\n+  /* we got to here, and there's no memory to allocate */\n+  return (NULL);\n } /* --- end PL_ArenaAllocate() --- */\n \n PR_IMPLEMENT(void*)\n-PL_ArenaGrow(PLArenaPool* pool, void* p, PRUint32 size, PRUint32 incr)\n-{\n-    void* newp;\n-\n-    if (PR_UINT32_MAX - size < incr) {\n-        return NULL;\n-    }\n-    PL_ARENA_ALLOCATE(newp, pool, size + incr);\n-    if (newp) {\n-        memcpy(newp, p, size);\n-        PL_MAKE_MEM_NOACCESS(p, size);\n-    }\n-    return newp;\n+PL_ArenaGrow(PLArenaPool* pool, void* p, PRUint32 size, PRUint32 incr) {\n+  void* newp;\n+\n+  if (PR_UINT32_MAX - size < incr) {\n+    return NULL;\n+  }\n+  PL_ARENA_ALLOCATE(newp, pool, size + incr);\n+  if (newp) {\n+    memcpy(newp, p, size);\n+  }\n+  return newp;\n }\n \n-PR_IMPLEMENT(void)\n-PL_ClearArenaPool(PLArenaPool* pool, PRInt32 pattern)\n-{\n-    PLArena* a;\n-\n-    for (a = pool->first.next; a; a = a->next) {\n-        PR_ASSERT(a->base <= a->avail && a->avail <= a->limit);\n-        a->avail = a->base;\n-        PL_CLEAR_UNUSED_PATTERN(a, pattern);\n-        PL_MAKE_MEM_NOACCESS((void*)a->avail, a->limit - a->avail);\n-    }\n+PR_IMPLEMENT(void) PL_ClearArenaPool(PLArenaPool* pool, PRInt32 pattern) {\n+  PLArena* a;\n+\n+  for (a = pool->first.next; a; a = a->next) {\n+    PR_ASSERT(a->base <= a->avail && a->avail <= a->limit);\n+    a->avail = a->base;\n+    PL_CLEAR_UNUSED_PATTERN(a, pattern);\n+    PL_MAKE_MEM_NOACCESS((void*)a->avail, a->limit - a->avail);\n+  }\n }\n \n /*\n  * Free tail arenas linked after head, which may not be the true list head.\n  * Reset pool->current to point to head in case it pointed at a tail arena.\n  */\n-static void\n-FreeArenaList(PLArenaPool* pool, PLArena* head)\n-{\n-    PLArena* a = head->next;\n-    if (!a) {\n-        return;\n-    }\n-\n-    head->next = NULL;\n-\n-    do {\n-        PLArena* tmp = a;\n-        a = a->next;\n-        PL_CLEAR_ARENA(tmp);\n-        PL_COUNT_ARENA(pool, --);\n-        PR_DELETE(tmp);\n-    } while (a);\n-\n-    pool->current = head;\n+static void FreeArenaList(PLArenaPool* pool, PLArena* head) {\n+  PLArena* a = head->next;\n+  if (!a) {\n+    return;\n+  }\n+\n+  head->next = NULL;\n+\n+  do {\n+    PLArena* tmp = a;\n+    a = a->next;\n+    PL_CLEAR_ARENA(tmp);\n+    PL_COUNT_ARENA(pool, --);\n+    PR_DELETE(tmp);\n+  } while (a);\n+\n+  pool->current = head;\n }\n \n-PR_IMPLEMENT(void)\n-PL_ArenaRelease(PLArenaPool* pool, char* mark)\n-{\n-    PLArena* a;\n-\n-    for (a = &pool->first; a; a = a->next) {\n-        if (PR_UPTRDIFF(mark, a->base) <= PR_UPTRDIFF(a->avail, a->base)) {\n-            a->avail = (PRUword)PL_ARENA_ALIGN(pool, mark);\n-            PL_MAKE_MEM_NOACCESS((void*)a->avail, a->limit - a->avail);\n-            FreeArenaList(pool, a);\n-            return;\n-        }\n+PR_IMPLEMENT(void) PL_ArenaRelease(PLArenaPool* pool, char* mark) {\n+  PLArena* a;\n+\n+  for (a = &pool->first; a; a = a->next) {\n+    if (PR_UPTRDIFF(mark, a->base) <= PR_UPTRDIFF(a->avail, a->base)) {\n+      a->avail = (PRUword)PL_ARENA_ALIGN(pool, mark);\n+      FreeArenaList(pool, a);\n+      return;\n     }\n+  }\n }\n \n-PR_IMPLEMENT(void)\n-PL_FreeArenaPool(PLArenaPool* pool)\n-{\n-    FreeArenaList(pool, &pool->first);\n-    COUNT(pool, ndeallocs);\n+PR_IMPLEMENT(void) PL_FreeArenaPool(PLArenaPool* pool) {\n+  FreeArenaList(pool, &pool->first);\n+  COUNT(pool, ndeallocs);\n }\n \n-PR_IMPLEMENT(void)\n-PL_FinishArenaPool(PLArenaPool* pool)\n-{\n-    FreeArenaList(pool, &pool->first);\n+PR_IMPLEMENT(void) PL_FinishArenaPool(PLArenaPool* pool) {\n+  FreeArenaList(pool, &pool->first);\n #ifdef PL_ARENAMETER\n-    {\n-        PLArenaStats *stats, **statsp;\n-\n-        if (pool->stats.name) {\n-            PR_DELETE(pool->stats.name);\n-        }\n-        for (statsp = &arena_stats_list; (stats = *statsp) != 0;\n-             statsp = &stats->next) {\n-            if (stats == &pool->stats) {\n-                *statsp = stats->next;\n-                return;\n-            }\n-        }\n+  {\n+    PLArenaStats *stats, **statsp;\n+\n+    if (pool->stats.name) {\n+      PR_DELETE(pool->stats.name);\n     }\n+    for (statsp = &arena_stats_list; (stats = *statsp) != 0;\n+         statsp = &stats->next) {\n+      if (stats == &pool->stats) {\n+        *statsp = stats->next;\n+        return;\n+      }\n+    }\n+  }\n #endif\n }\n \n-PR_IMPLEMENT(void)\n-PL_CompactArenaPool(PLArenaPool* ap) {}\n+PR_IMPLEMENT(void) PL_CompactArenaPool(PLArenaPool* ap) {}\n \n-PR_IMPLEMENT(void)\n-PL_ArenaFinish(void) {}\n+PR_IMPLEMENT(void) PL_ArenaFinish(void) {}\n \n PR_IMPLEMENT(size_t)\n PL_SizeOfArenaPoolExcludingPool(const PLArenaPool* pool,\n-                                PLMallocSizeFn mallocSizeOf)\n-{\n-    /*\n-     * The first PLArena is within |pool|, so don't measure it.  Subsequent\n-     * PLArenas are separate and must be measured.\n-     */\n-    size_t size = 0;\n-    const PLArena* arena = pool->first.next;\n-    while (arena) {\n-        size += mallocSizeOf(arena);\n-        arena = arena->next;\n-    }\n-    return size;\n+                                PLMallocSizeFn mallocSizeOf) {\n+  /*\n+   * The first PLArena is within |pool|, so don't measure it.  Subsequent\n+   * PLArenas are separate and must be measured.\n+   */\n+  size_t size = 0;\n+  const PLArena* arena = pool->first.next;\n+  while (arena) {\n+    size += mallocSizeOf(arena);\n+    arena = arena->next;\n+  }\n+  return size;\n }\n \n #ifdef PL_ARENAMETER\n-PR_IMPLEMENT(void)\n-PL_ArenaCountAllocation(PLArenaPool* pool, PRUint32 nb)\n-{\n-    pool->stats.nallocs++;\n-    pool->stats.nbytes += nb;\n-    if (nb > pool->stats.maxalloc) {\n-        pool->stats.maxalloc = nb;\n-    }\n-    pool->stats.variance += nb * nb;\n+PR_IMPLEMENT(void) PL_ArenaCountAllocation(PLArenaPool* pool, PRUint32 nb) {\n+  pool->stats.nallocs++;\n+  pool->stats.nbytes += nb;\n+  if (nb > pool->stats.maxalloc) {\n+    pool->stats.maxalloc = nb;\n+  }\n+  pool->stats.variance += nb * nb;\n }\n \n PR_IMPLEMENT(void)\n-PL_ArenaCountInplaceGrowth(PLArenaPool* pool, PRUint32 size, PRUint32 incr)\n-{\n-    pool->stats.ninplace++;\n+PL_ArenaCountInplaceGrowth(PLArenaPool* pool, PRUint32 size, PRUint32 incr) {\n+  pool->stats.ninplace++;\n }\n \n PR_IMPLEMENT(void)\n-PL_ArenaCountGrowth(PLArenaPool* pool, PRUint32 size, PRUint32 incr)\n-{\n-    pool->stats.ngrows++;\n-    pool->stats.nbytes += incr;\n-    pool->stats.variance -= size * size;\n-    size += incr;\n-    if (size > pool->stats.maxalloc) {\n-        pool->stats.maxalloc = size;\n-    }\n-    pool->stats.variance += size * size;\n+PL_ArenaCountGrowth(PLArenaPool* pool, PRUint32 size, PRUint32 incr) {\n+  pool->stats.ngrows++;\n+  pool->stats.nbytes += incr;\n+  pool->stats.variance -= size * size;\n+  size += incr;\n+  if (size > pool->stats.maxalloc) {\n+    pool->stats.maxalloc = size;\n+  }\n+  pool->stats.variance += size * size;\n }\n \n-PR_IMPLEMENT(void)\n-PL_ArenaCountRelease(PLArenaPool* pool, char* mark)\n-{\n-    pool->stats.nreleases++;\n+PR_IMPLEMENT(void) PL_ArenaCountRelease(PLArenaPool* pool, char* mark) {\n+  pool->stats.nreleases++;\n }\n \n-PR_IMPLEMENT(void)\n-PL_ArenaCountRetract(PLArenaPool* pool, char* mark)\n-{\n-    pool->stats.nfastrels++;\n+PR_IMPLEMENT(void) PL_ArenaCountRetract(PLArenaPool* pool, char* mark) {\n+  pool->stats.nfastrels++;\n }\n \n-#include <math.h>\n-#include <stdio.h>\n+#  include <math.h>\n+#  include <stdio.h>\n \n-PR_IMPLEMENT(void)\n-PL_DumpArenaStats(FILE* fp)\n-{\n-    PLArenaStats* stats;\n-    double mean, variance;\n-\n-    for (stats = arena_stats_list; stats; stats = stats->next) {\n-        if (stats->nallocs != 0) {\n-            mean = (double)stats->nbytes / stats->nallocs;\n-            variance = fabs(stats->variance / stats->nallocs - mean * mean);\n-        } else {\n-            mean = variance = 0;\n-        }\n-\n-        fprintf(fp, \"\\n%s allocation statistics:\\n\", stats->name);\n-        fprintf(fp, \"              number of arenas: %u\\n\", stats->narenas);\n-        fprintf(fp, \"         number of allocations: %u\\n\", stats->nallocs);\n-        fprintf(fp, \" number of free arena reclaims: %u\\n\", stats->nreclaims);\n-        fprintf(fp, \"        number of malloc calls: %u\\n\", stats->nmallocs);\n-        fprintf(fp, \"       number of deallocations: %u\\n\", stats->ndeallocs);\n-        fprintf(fp, \"  number of allocation growths: %u\\n\", stats->ngrows);\n-        fprintf(fp, \"    number of in-place growths: %u\\n\", stats->ninplace);\n-        fprintf(fp, \"number of released allocations: %u\\n\", stats->nreleases);\n-        fprintf(fp, \"       number of fast releases: %u\\n\", stats->nfastrels);\n-        fprintf(fp, \"         total bytes allocated: %u\\n\", stats->nbytes);\n-        fprintf(fp, \"          mean allocation size: %g\\n\", mean);\n-        fprintf(fp, \"            standard deviation: %g\\n\", sqrt(variance));\n-        fprintf(fp, \"       maximum allocation size: %u\\n\", stats->maxalloc);\n+PR_IMPLEMENT(void) PL_DumpArenaStats(FILE* fp) {\n+  PLArenaStats* stats;\n+  double mean, variance;\n+\n+  for (stats = arena_stats_list; stats; stats = stats->next) {\n+    if (stats->nallocs != 0) {\n+      mean = (double)stats->nbytes / stats->nallocs;\n+      variance = fabs(stats->variance / stats->nallocs - mean * mean);\n+    } else {\n+      mean = variance = 0;\n     }\n+\n+    fprintf(fp, \"\\n%s allocation statistics:\\n\", stats->name);\n+    fprintf(fp, \"              number of arenas: %u\\n\", stats->narenas);\n+    fprintf(fp, \"         number of allocations: %u\\n\", stats->nallocs);\n+    fprintf(fp, \" number of free arena reclaims: %u\\n\", stats->nreclaims);\n+    fprintf(fp, \"        number of malloc calls: %u\\n\", stats->nmallocs);\n+    fprintf(fp, \"       number of deallocations: %u\\n\", stats->ndeallocs);\n+    fprintf(fp, \"  number of allocation growths: %u\\n\", stats->ngrows);\n+    fprintf(fp, \"    number of in-place growths: %u\\n\", stats->ninplace);\n+    fprintf(fp, \"number of released allocations: %u\\n\", stats->nreleases);\n+    fprintf(fp, \"       number of fast releases: %u\\n\", stats->nfastrels);\n+    fprintf(fp, \"         total bytes allocated: %u\\n\", stats->nbytes);\n+    fprintf(fp, \"          mean allocation size: %g\\n\", mean);\n+    fprintf(fp, \"            standard deviation: %g\\n\", sqrt(variance));\n+    fprintf(fp, \"       maximum allocation size: %u\\n\", stats->maxalloc);\n+  }\n }\n #endif /* PL_ARENAMETER */\ndiff --git a/nspr/lib/ds/plarena.h b/nspr/lib/ds/plarena.h\nindex 3ebc659..0ca00c0 100644\n--- a/nspr/lib/ds/plarena.h\n+++ b/nspr/lib/ds/plarena.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -15,43 +16,43 @@\n \n PR_BEGIN_EXTERN_C\n \n-typedef struct PLArena PLArena;\n+typedef struct PLArena          PLArena;\n \n struct PLArena {\n-    PLArena* next; /* next arena for this lifetime */\n-    PRUword base;  /* aligned base address, follows this header */\n-    PRUword limit; /* one beyond last byte in arena */\n-    PRUword avail; /* points to next available byte */\n+    PLArena     *next;          /* next arena for this lifetime */\n+    PRUword     base;           /* aligned base address, follows this header */\n+    PRUword     limit;          /* one beyond last byte in arena */\n+    PRUword     avail;          /* points to next available byte */\n };\n \n #ifdef PL_ARENAMETER\n typedef struct PLArenaStats PLArenaStats;\n \n struct PLArenaStats {\n-    PLArenaStats* next; /* next in arenaStats list */\n-    char* name;         /* name for debugging */\n-    PRUint32 narenas;   /* number of arenas in pool */\n-    PRUint32 nallocs;   /* number of PL_ARENA_ALLOCATE() calls */\n-    PRUint32 nreclaims; /* number of reclaims from freeArenas */\n-    PRUint32 nmallocs;  /* number of malloc() calls */\n-    PRUint32 ndeallocs; /* number of lifetime deallocations */\n-    PRUint32 ngrows;    /* number of PL_ARENA_GROW() calls */\n-    PRUint32 ninplace;  /* number of in-place growths */\n-    PRUint32 nreleases; /* number of PL_ARENA_RELEASE() calls */\n-    PRUint32 nfastrels; /* number of \"fast path\" releases */\n-    PRUint32 nbytes;    /* total bytes allocated */\n-    PRUint32 maxalloc;  /* maximum allocation size in bytes */\n-    PRFloat64 variance; /* size variance accumulator */\n+    PLArenaStats  *next;        /* next in arenaStats list */\n+    char          *name;        /* name for debugging */\n+    PRUint32      narenas;      /* number of arenas in pool */\n+    PRUint32      nallocs;      /* number of PL_ARENA_ALLOCATE() calls */\n+    PRUint32      nreclaims;    /* number of reclaims from freeArenas */\n+    PRUint32      nmallocs;     /* number of malloc() calls */\n+    PRUint32      ndeallocs;    /* number of lifetime deallocations */\n+    PRUint32      ngrows;       /* number of PL_ARENA_GROW() calls */\n+    PRUint32      ninplace;     /* number of in-place growths */\n+    PRUint32      nreleases;    /* number of PL_ARENA_RELEASE() calls */\n+    PRUint32      nfastrels;    /* number of \"fast path\" releases */\n+    PRUint32      nbytes;       /* total bytes allocated */\n+    PRUint32      maxalloc;     /* maximum allocation size in bytes */\n+    PRFloat64     variance;     /* size variance accumulator */\n };\n #endif\n \n-typedef struct PLArenaPool PLArenaPool;\n+typedef struct PLArenaPool      PLArenaPool;\n \n struct PLArenaPool {\n-    PLArena first;      /* first arena in pool list */\n-    PLArena* current;   /* arena from which to allocate space */\n-    PRUint32 arenasize; /* net exact size of a new arena */\n-    PRUword mask;       /* alignment mask (power-of-2 - 1) */\n+    PLArena     first;          /* first arena in pool list */\n+    PLArena     *current;       /* arena from which to allocate space */\n+    PRUint32    arenasize;      /* net exact size of a new arena */\n+    PRUword     mask;           /* alignment mask (power-of-2 - 1) */\n #ifdef PL_ARENAMETER\n     PLArenaStats stats;\n #endif\n@@ -103,21 +104,15 @@ struct PLArenaPool {\n #define PL_ASAN_VISIBILITY(type_) PR_IMPORT(type_)\n #endif\n \n-/*\n- * Size of the poisoned redzone placed after each arena allocation.\n- * Matches ASan's default redzone to catch intra-arena buffer overflows.\n- */\n-#define PL_ARENA_REDZONE_SIZE 16\n-\n /* These definitions are usually provided through the\n  * sanitizer/asan_interface.h header installed by ASan.\n  * See https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning\n  */\n \n-PL_ASAN_VISIBILITY(void)\n-__asan_poison_memory_region(void const volatile* addr, size_t size);\n-PL_ASAN_VISIBILITY(void)\n-__asan_unpoison_memory_region(void const volatile* addr, size_t size);\n+PL_ASAN_VISIBILITY(void) __asan_poison_memory_region(\n+    void const volatile *addr, size_t size);\n+PL_ASAN_VISIBILITY(void) __asan_unpoison_memory_region(\n+    void const volatile *addr, size_t size);\n \n #define PL_MAKE_MEM_NOACCESS(addr, size) \\\n     __asan_poison_memory_region((addr), (size))\n@@ -130,8 +125,6 @@ __asan_unpoison_memory_region(void const volatile* addr, size_t size);\n \n #else\n \n-#define PL_ARENA_REDZONE_SIZE 0\n-\n #define PL_MAKE_MEM_NOACCESS(addr, size)\n #define PL_MAKE_MEM_UNDEFINED(addr, size)\n #define PL_MAKE_MEM_DEFINED(addr, size)\n@@ -144,110 +137,104 @@ __asan_unpoison_memory_region(void const volatile* addr, size_t size);\n  * per ALLOCATE and GROW.\n  */\n #ifdef PL_ARENA_CONST_ALIGN_MASK\n-#define PL_ARENA_ALIGN(pool, n) \\\n-    (((PRUword)(n) + PL_ARENA_CONST_ALIGN_MASK) & ~PL_ARENA_CONST_ALIGN_MASK)\n+#define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + PL_ARENA_CONST_ALIGN_MASK) \\\n+                                & ~PL_ARENA_CONST_ALIGN_MASK)\n \n #define PL_INIT_ARENA_POOL(pool, name, size) \\\n-    PL_InitArenaPool(pool, name, size, PL_ARENA_CONST_ALIGN_MASK + 1)\n+        PL_InitArenaPool(pool, name, size, PL_ARENA_CONST_ALIGN_MASK + 1)\n #else\n-#define PL_ARENA_ALIGN(pool, n) \\\n-    (((PRUword)(n) + (pool)->mask) & ~(pool)->mask)\n+#define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + (pool)->mask) & ~(pool)->mask)\n #endif\n \n-#define PL_ARENA_ALLOCATE(p, pool, nb)                                           \\\n-    PR_BEGIN_MACRO                                                               \\\n-    PLArena* _a = (pool)->current;                                               \\\n-    PRUint32 _nb = PL_ARENA_ALIGN(pool, (PRUint32)(nb) + PL_ARENA_REDZONE_SIZE); \\\n-    PRUword _p = _a->avail;                                                      \\\n-    if (_nb < (PRUint32)nb) {                                                    \\\n-        _p = 0;                                                                  \\\n-    } else if (_nb > (_a->limit - _a->avail)) {                                  \\\n-        _p = (PRUword)PL_ArenaAllocate(pool, _nb);                               \\\n-    } else {                                                                     \\\n-        _a->avail += _nb;                                                        \\\n-    }                                                                            \\\n-    p = (void*)_p;                                                               \\\n-    if (p) {                                                                     \\\n-        PL_MAKE_MEM_UNDEFINED(p, (PRUint32)nb);                                  \\\n-        PL_ArenaCountAllocation(pool, (PRUint32)nb);                             \\\n-    }                                                                            \\\n+#define PL_ARENA_ALLOCATE(p, pool, nb) \\\n+    PR_BEGIN_MACRO \\\n+        PLArena *_a = (pool)->current; \\\n+        PRUint32 _nb = PL_ARENA_ALIGN(pool, (PRUint32)nb); \\\n+        PRUword _p = _a->avail; \\\n+        if (_nb < (PRUint32)nb) { \\\n+            _p = 0; \\\n+        } else if (_nb > (_a->limit - _a->avail)) { \\\n+            _p = (PRUword)PL_ArenaAllocate(pool, _nb); \\\n+        } else { \\\n+            _a->avail += _nb; \\\n+        } \\\n+        p = (void *)_p; \\\n+        if (p) { \\\n+            PL_MAKE_MEM_UNDEFINED(p, (PRUint32)nb); \\\n+            PL_ArenaCountAllocation(pool, (PRUint32)nb); \\\n+        } \\\n     PR_END_MACRO\n \n-#define PL_ARENA_GROW(p, pool, size, incr)                                   \\\n-    PR_BEGIN_MACRO                                                           \\\n-    PLArena* _a = (pool)->current;                                           \\\n-    PRUint32 _incr = PL_ARENA_ALIGN(pool, (PRUint32)incr);                   \\\n-    if (_incr < (PRUint32)incr) {                                            \\\n-        p = NULL;                                                            \\\n-    } else if (_a->avail ==                                                  \\\n-                   (PRUword)(p) +                                            \\\n-                       PL_ARENA_ALIGN(pool, size + PL_ARENA_REDZONE_SIZE) && \\\n-               _incr <= (_a->limit - _a->avail)) {                           \\\n-        PL_MAKE_MEM_UNDEFINED((unsigned char*)(p) + size, (PRUint32)incr);   \\\n-        _a->avail += _incr;                                                  \\\n-        PL_MAKE_MEM_NOACCESS((unsigned char*)(p) + size + incr,              \\\n-                             PL_ARENA_REDZONE_SIZE);                         \\\n-        PL_ArenaCountInplaceGrowth(pool, size, (PRUint32)incr);              \\\n-    } else {                                                                 \\\n-        p = PL_ArenaGrow(pool, p, size, (PRUint32)incr);                     \\\n-    }                                                                        \\\n-    if (p) {                                                                 \\\n-        PL_ArenaCountGrowth(pool, size, (PRUint32)incr);                     \\\n-    }                                                                        \\\n+#define PL_ARENA_GROW(p, pool, size, incr) \\\n+    PR_BEGIN_MACRO \\\n+        PLArena *_a = (pool)->current; \\\n+        PRUint32 _incr = PL_ARENA_ALIGN(pool, (PRUint32)incr); \\\n+        if (_incr < (PRUint32)incr) { \\\n+            p = NULL; \\\n+        } else if (_a->avail == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \\\n+            _incr <= (_a->limit - _a->avail)) { \\\n+            PL_MAKE_MEM_UNDEFINED((unsigned char *)(p) + size, (PRUint32)incr); \\\n+            _a->avail += _incr; \\\n+            PL_ArenaCountInplaceGrowth(pool, size, (PRUint32)incr); \\\n+        } else { \\\n+            p = PL_ArenaGrow(pool, p, size, (PRUint32)incr); \\\n+        } \\\n+        if (p) {\\\n+            PL_ArenaCountGrowth(pool, size, (PRUint32)incr); \\\n+        } \\\n     PR_END_MACRO\n \n-#define PL_ARENA_MARK(pool) ((void*)(pool)->current->avail)\n-#define PR_UPTRDIFF(p, q) ((PRUword)(p) - (PRUword)(q))\n+#define PL_ARENA_MARK(pool) ((void *) (pool)->current->avail)\n+#define PR_UPTRDIFF(p,q) ((PRUword)(p) - (PRUword)(q))\n \n-#define PL_CLEAR_UNUSED_PATTERN(a, pattern)                            \\\n-    PR_BEGIN_MACRO                                                     \\\n-    PR_ASSERT((a)->avail <= (a)->limit);                               \\\n-    PL_MAKE_MEM_UNDEFINED((void*)(a)->avail, (a)->limit - (a)->avail); \\\n-    memset((void*)(a)->avail, (pattern), (a)->limit - (a)->avail);     \\\n+#define PL_CLEAR_UNUSED_PATTERN(a, pattern) \\\n+    PR_BEGIN_MACRO \\\n+        PR_ASSERT((a)->avail <= (a)->limit); \\\n+        PL_MAKE_MEM_UNDEFINED((void*)(a)->avail, (a)->limit - (a)->avail); \\\n+        memset((void*)(a)->avail, (pattern), (a)->limit - (a)->avail); \\\n     PR_END_MACRO\n #ifdef DEBUG\n #define PL_FREE_PATTERN 0xDA\n #define PL_CLEAR_UNUSED(a) PL_CLEAR_UNUSED_PATTERN((a), PL_FREE_PATTERN)\n-#define PL_CLEAR_ARENA(a)                                           \\\n-    PR_BEGIN_MACRO                                                  \\\n-    PL_MAKE_MEM_UNDEFINED((void*)(a), (a)->limit - (PRUword)(a));   \\\n-    memset((void*)(a), PL_FREE_PATTERN, (a)->limit - (PRUword)(a)); \\\n+#define PL_CLEAR_ARENA(a) \\\n+    PR_BEGIN_MACRO \\\n+        PL_MAKE_MEM_UNDEFINED((void*)(a), (a)->limit - (PRUword)(a)); \\\n+        memset((void*)(a), PL_FREE_PATTERN, (a)->limit - (PRUword)(a)); \\\n     PR_END_MACRO\n #else\n #define PL_CLEAR_UNUSED(a)\n #define PL_CLEAR_ARENA(a)\n #endif\n \n-#define PL_ARENA_RELEASE(pool, mark)                                     \\\n-    PR_BEGIN_MACRO                                                       \\\n-    char* _m = (char*)(mark);                                            \\\n-    PLArena* _a = (pool)->current;                                       \\\n-    if (PR_UPTRDIFF(_m, _a->base) <= PR_UPTRDIFF(_a->avail, _a->base)) { \\\n-        _a->avail = (PRUword)PL_ARENA_ALIGN(pool, _m);                   \\\n-        PL_CLEAR_UNUSED(_a);                                             \\\n-        PL_MAKE_MEM_NOACCESS((void*)_a->avail, _a->limit - _a->avail);   \\\n-        PL_ArenaCountRetract(pool, _m);                                  \\\n-    } else {                                                             \\\n-        PL_ArenaRelease(pool, _m);                                       \\\n-    }                                                                    \\\n-    PL_ArenaCountRelease(pool, _m);                                      \\\n+#define PL_ARENA_RELEASE(pool, mark) \\\n+    PR_BEGIN_MACRO \\\n+        char *_m = (char *)(mark); \\\n+        PLArena *_a = (pool)->current; \\\n+        if (PR_UPTRDIFF(_m, _a->base) <= PR_UPTRDIFF(_a->avail, _a->base)) { \\\n+            _a->avail = (PRUword)PL_ARENA_ALIGN(pool, _m); \\\n+            PL_CLEAR_UNUSED(_a); \\\n+            PL_MAKE_MEM_NOACCESS((void*)_a->avail, _a->limit - _a->avail); \\\n+            PL_ArenaCountRetract(pool, _m); \\\n+        } else { \\\n+            PL_ArenaRelease(pool, _m); \\\n+        } \\\n+        PL_ArenaCountRelease(pool, _m); \\\n     PR_END_MACRO\n \n #ifdef PL_ARENAMETER\n-#define PL_COUNT_ARENA(pool, op) ((pool)->stats.narenas op)\n+#define PL_COUNT_ARENA(pool,op) ((pool)->stats.narenas op)\n #else\n-#define PL_COUNT_ARENA(pool, op)\n+#define PL_COUNT_ARENA(pool,op)\n #endif\n \n-#define PL_ARENA_DESTROY(pool, a, pnext)  \\\n-    PR_BEGIN_MACRO                        \\\n-    PL_COUNT_ARENA(pool, --);             \\\n-    if ((pool)->current == (a))           \\\n-        (pool)->current = &(pool)->first; \\\n-    *(pnext) = (a)->next;                 \\\n-    PL_CLEAR_ARENA(a);                    \\\n-    free(a);                              \\\n-    (a) = 0;                              \\\n+#define PL_ARENA_DESTROY(pool, a, pnext) \\\n+    PR_BEGIN_MACRO \\\n+        PL_COUNT_ARENA(pool,--); \\\n+        if ((pool)->current == (a)) (pool)->current = &(pool)->first; \\\n+        *(pnext) = (a)->next; \\\n+        PL_CLEAR_ARENA(a); \\\n+        free(a); \\\n+        (a) = 0; \\\n     PR_END_MACRO\n \n /*\n@@ -259,38 +246,33 @@ __asan_unpoison_memory_region(void const volatile* addr, size_t size);\n ** Note: choose a gross size that's a power of two to avoid the heap allocator\n ** rounding the size up.\n **/\n-PR_EXTERN(void)\n-PL_InitArenaPool(PLArenaPool* pool, const char* name, PRUint32 size,\n-                 PRUint32 align);\n+PR_EXTERN(void) PL_InitArenaPool(\n+    PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align);\n \n /*\n ** Finish using arenas, freeing all memory associated with them.\n ** NOTE: this function is now a no-op. If you want to free a single\n ** PLArenaPoolUse use PL_FreeArenaPool() or PL_FinishArenaPool().\n **/\n-PR_EXTERN(void)\n-PL_ArenaFinish(void);\n+PR_EXTERN(void) PL_ArenaFinish(void);\n \n /*\n ** Free the arenas in pool.  The user may continue to allocate from pool\n ** after calling this function.  There is no need to call PL_InitArenaPool()\n ** again unless PL_FinishArenaPool(pool) has been called.\n **/\n-PR_EXTERN(void)\n-PL_FreeArenaPool(PLArenaPool* pool);\n+PR_EXTERN(void) PL_FreeArenaPool(PLArenaPool *pool);\n \n /*\n ** Free the arenas in pool and finish using it altogether.\n **/\n-PR_EXTERN(void)\n-PL_FinishArenaPool(PLArenaPool* pool);\n+PR_EXTERN(void) PL_FinishArenaPool(PLArenaPool *pool);\n \n /*\n ** Compact all of the arenas in a pool so that no space is wasted.\n ** NOT IMPLEMENTED.  Do not use.\n **/\n-PR_EXTERN(void)\n-PL_CompactArenaPool(PLArenaPool* pool);\n+PR_EXTERN(void) PL_CompactArenaPool(PLArenaPool *pool);\n \n /*\n ** Friend functions used by the PL_ARENA_*() macros.\n@@ -298,64 +280,56 @@ PL_CompactArenaPool(PLArenaPool* pool);\n ** WARNING: do not call these functions directly. Always use the\n ** PL_ARENA_*() macros.\n **/\n-PR_EXTERN(void*)\n-PL_ArenaAllocate(PLArenaPool* pool, PRUint32 nb);\n+PR_EXTERN(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb);\n \n-PR_EXTERN(void*)\n-PL_ArenaGrow(PLArenaPool* pool, void* p, PRUint32 size, PRUint32 incr);\n+PR_EXTERN(void *) PL_ArenaGrow(\n+    PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr);\n \n-PR_EXTERN(void)\n-PL_ArenaRelease(PLArenaPool* pool, char* mark);\n+PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark);\n \n /*\n ** memset contents of all arenas in pool to pattern\n */\n-PR_EXTERN(void)\n-PL_ClearArenaPool(PLArenaPool* pool, PRInt32 pattern);\n+PR_EXTERN(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern);\n \n /*\n ** A function like malloc_size() or malloc_usable_size() that measures the\n ** size of a heap block.\n */\n-typedef size_t (*PLMallocSizeFn)(const void* ptr);\n+typedef size_t (*PLMallocSizeFn)(const void *ptr);\n \n /*\n ** Measure all memory used by a PLArenaPool, excluding the PLArenaPool\n ** structure.\n */\n-PR_EXTERN(size_t)\n-PL_SizeOfArenaPoolExcludingPool(const PLArenaPool* pool,\n-                                PLMallocSizeFn mallocSizeOf);\n+PR_EXTERN(size_t) PL_SizeOfArenaPoolExcludingPool(\n+    const PLArenaPool *pool, PLMallocSizeFn mallocSizeOf);\n \n #ifdef PL_ARENAMETER\n \n #include <stdio.h>\n \n-PR_EXTERN(void)\n-PL_ArenaCountAllocation(PLArenaPool* pool, PRUint32 nb);\n+PR_EXTERN(void) PL_ArenaCountAllocation(PLArenaPool *pool, PRUint32 nb);\n \n-PR_EXTERN(void)\n-PL_ArenaCountInplaceGrowth(PLArenaPool* pool, PRUint32 size, PRUint32 incr);\n+PR_EXTERN(void) PL_ArenaCountInplaceGrowth(\n+    PLArenaPool *pool, PRUint32 size, PRUint32 incr);\n \n-PR_EXTERN(void)\n-PL_ArenaCountGrowth(PLArenaPool* pool, PRUint32 size, PRUint32 incr);\n+PR_EXTERN(void) PL_ArenaCountGrowth(\n+    PLArenaPool *pool, PRUint32 size, PRUint32 incr);\n \n-PR_EXTERN(void)\n-PL_ArenaCountRelease(PLArenaPool* pool, char* mark);\n+PR_EXTERN(void) PL_ArenaCountRelease(PLArenaPool *pool, char *mark);\n \n-PR_EXTERN(void)\n-PL_ArenaCountRetract(PLArenaPool* pool, char* mark);\n+PR_EXTERN(void) PL_ArenaCountRetract(PLArenaPool *pool, char *mark);\n \n-PR_EXTERN(void)\n-PL_DumpArenaStats(FILE* fp);\n+PR_EXTERN(void) PL_DumpArenaStats(FILE *fp);\n \n-#else /* !PL_ARENAMETER */\n+#else  /* !PL_ARENAMETER */\n \n-#define PL_ArenaCountAllocation(ap, nb)            /* nothing */\n-#define PL_ArenaCountInplaceGrowth(ap, size, incr) /* nothing */\n-#define PL_ArenaCountGrowth(ap, size, incr)        /* nothing */\n-#define PL_ArenaCountRelease(ap, mark)             /* nothing */\n-#define PL_ArenaCountRetract(ap, mark)             /* nothing */\n+#define PL_ArenaCountAllocation(ap, nb)                 /* nothing */\n+#define PL_ArenaCountInplaceGrowth(ap, size, incr)      /* nothing */\n+#define PL_ArenaCountGrowth(ap, size, incr)             /* nothing */\n+#define PL_ArenaCountRelease(ap, mark)                  /* nothing */\n+#define PL_ArenaCountRetract(ap, mark)                  /* nothing */\n \n #endif /* !PL_ARENAMETER */\n \ndiff --git a/nspr/lib/ds/plarenas.h b/nspr/lib/ds/plarenas.h\nindex c05e7dd..4a0f5a8 100644\n--- a/nspr/lib/ds/plarenas.h\n+++ b/nspr/lib/ds/plarenas.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/lib/ds/plds.rc b/nspr/lib/ds/plds.rc\nindex 05c6bc0..a7f3f93 100644\n--- a/nspr/lib/ds/plds.rc\n+++ b/nspr/lib/ds/plds.rc\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/lib/ds/plhash.c b/nspr/lib/ds/plhash.c\nindex dfb52ba..f6c224e 100644\n--- a/nspr/lib/ds/plhash.c\n+++ b/nspr/lib/ds/plhash.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -29,104 +30,93 @@\n /*\n ** Stubs for default hash allocator ops.\n */\n-static void* PR_CALLBACK\n-DefaultAllocTable(void* pool, PRSize size)\n-{\n-    return PR_MALLOC(size);\n+static void* PR_CALLBACK DefaultAllocTable(void* pool, PRSize size) {\n+  return PR_MALLOC(size);\n }\n \n-static void PR_CALLBACK\n-DefaultFreeTable(void* pool, void* item)\n-{\n-    PR_Free(item);\n+static void PR_CALLBACK DefaultFreeTable(void* pool, void* item) {\n+  PR_Free(item);\n }\n \n-static PLHashEntry* PR_CALLBACK\n-DefaultAllocEntry(void* pool, const void* key)\n-{\n-    return PR_NEW(PLHashEntry);\n+static PLHashEntry* PR_CALLBACK DefaultAllocEntry(void* pool, const void* key) {\n+  return PR_NEW(PLHashEntry);\n }\n \n-static void PR_CALLBACK\n-DefaultFreeEntry(void* pool, PLHashEntry* he,\n-                 PRUintn flag)\n-{\n-    if (flag == HT_FREE_ENTRY) {\n-        PR_Free(he);\n-    }\n+static void PR_CALLBACK DefaultFreeEntry(void* pool, PLHashEntry* he,\n+                                         PRUintn flag) {\n+  if (flag == HT_FREE_ENTRY) {\n+    PR_Free(he);\n+  }\n }\n \n static PLHashAllocOps defaultHashAllocOps = {\n-    DefaultAllocTable, DefaultFreeTable, DefaultAllocEntry, DefaultFreeEntry\n-};\n+    DefaultAllocTable, DefaultFreeTable, DefaultAllocEntry, DefaultFreeEntry};\n \n PR_IMPLEMENT(PLHashTable*)\n PL_NewHashTable(PRUint32 n, PLHashFunction keyHash, PLHashComparator keyCompare,\n                 PLHashComparator valueCompare, const PLHashAllocOps* allocOps,\n-                void* allocPriv)\n-{\n-    PLHashTable* ht;\n-    PRSize nb;\n-\n-    if (n <= MINBUCKETS) {\n-        n = MINBUCKETSLOG2;\n-    } else {\n-        n = PR_CeilingLog2(n);\n-        if ((PRInt32)n < 0) {\n-            return 0;\n-        }\n+                void* allocPriv) {\n+  PLHashTable* ht;\n+  PRSize nb;\n+\n+  if (n <= MINBUCKETS) {\n+    n = MINBUCKETSLOG2;\n+  } else {\n+    n = PR_CeilingLog2(n);\n+    if ((PRInt32)n < 0) {\n+      return 0;\n     }\n+  }\n \n-    if (!allocOps) {\n-        allocOps = &defaultHashAllocOps;\n-    }\n-\n-    ht = (PLHashTable*)((*allocOps->allocTable)(allocPriv, sizeof *ht));\n-    if (!ht) {\n-        return 0;\n-    }\n-    memset(ht, 0, sizeof *ht);\n-    ht->shift = PL_HASH_BITS - n;\n-    n = 1 << n;\n-    nb = n * sizeof(PLHashEntry*);\n-    ht->buckets = (PLHashEntry**)((*allocOps->allocTable)(allocPriv, nb));\n-    if (!ht->buckets) {\n-        (*allocOps->freeTable)(allocPriv, ht);\n-        return 0;\n-    }\n-    memset(ht->buckets, 0, nb);\n+  if (!allocOps) {\n+    allocOps = &defaultHashAllocOps;\n+  }\n \n-    ht->keyHash = keyHash;\n-    ht->keyCompare = keyCompare;\n-    ht->valueCompare = valueCompare;\n-    ht->allocOps = allocOps;\n-    ht->allocPriv = allocPriv;\n-    return ht;\n+  ht = (PLHashTable*)((*allocOps->allocTable)(allocPriv, sizeof *ht));\n+  if (!ht) {\n+    return 0;\n+  }\n+  memset(ht, 0, sizeof *ht);\n+  ht->shift = PL_HASH_BITS - n;\n+  n = 1 << n;\n+  nb = n * sizeof(PLHashEntry*);\n+  ht->buckets = (PLHashEntry**)((*allocOps->allocTable)(allocPriv, nb));\n+  if (!ht->buckets) {\n+    (*allocOps->freeTable)(allocPriv, ht);\n+    return 0;\n+  }\n+  memset(ht->buckets, 0, nb);\n+\n+  ht->keyHash = keyHash;\n+  ht->keyCompare = keyCompare;\n+  ht->valueCompare = valueCompare;\n+  ht->allocOps = allocOps;\n+  ht->allocPriv = allocPriv;\n+  return ht;\n }\n \n PR_IMPLEMENT(void)\n-PL_HashTableDestroy(PLHashTable* ht)\n-{\n-    PRUint32 i, n;\n-    PLHashEntry *he, *next;\n-    const PLHashAllocOps* allocOps = ht->allocOps;\n-    void* allocPriv = ht->allocPriv;\n-\n-    n = NBUCKETS(ht);\n-    for (i = 0; i < n; i++) {\n-        for (he = ht->buckets[i]; he; he = next) {\n-            next = he->next;\n-            (*allocOps->freeEntry)(allocPriv, he, HT_FREE_ENTRY);\n-        }\n+PL_HashTableDestroy(PLHashTable* ht) {\n+  PRUint32 i, n;\n+  PLHashEntry *he, *next;\n+  const PLHashAllocOps* allocOps = ht->allocOps;\n+  void* allocPriv = ht->allocPriv;\n+\n+  n = NBUCKETS(ht);\n+  for (i = 0; i < n; i++) {\n+    for (he = ht->buckets[i]; he; he = next) {\n+      next = he->next;\n+      (*allocOps->freeEntry)(allocPriv, he, HT_FREE_ENTRY);\n     }\n+  }\n #ifdef DEBUG\n-    memset(ht->buckets, 0xDB, n * sizeof ht->buckets[0]);\n+  memset(ht->buckets, 0xDB, n * sizeof ht->buckets[0]);\n #endif\n-    (*allocOps->freeTable)(allocPriv, ht->buckets);\n+  (*allocOps->freeTable)(allocPriv, ht->buckets);\n #ifdef DEBUG\n-    memset(ht, 0xDB, sizeof *ht);\n+  memset(ht, 0xDB, sizeof *ht);\n #endif\n-    (*allocOps->freeTable)(allocPriv, ht);\n+  (*allocOps->freeTable)(allocPriv, ht);\n }\n \n /*\n@@ -135,33 +125,32 @@ PL_HashTableDestroy(PLHashTable* ht)\n #define GOLDEN_RATIO 0x9E3779B9U /* 2/(1+sqrt(5))*(2^32) */\n \n PR_IMPLEMENT(PLHashEntry**)\n-PL_HashTableRawLookup(PLHashTable* ht, PLHashNumber keyHash, const void* key)\n-{\n-    PLHashEntry *he, **hep, **hep0;\n-    PLHashNumber h;\n+PL_HashTableRawLookup(PLHashTable* ht, PLHashNumber keyHash, const void* key) {\n+  PLHashEntry *he, **hep, **hep0;\n+  PLHashNumber h;\n \n #ifdef HASHMETER\n-    ht->nlookups++;\n+  ht->nlookups++;\n #endif\n-    h = keyHash * GOLDEN_RATIO;\n-    h >>= ht->shift;\n-    hep = hep0 = &ht->buckets[h];\n-    while ((he = *hep) != 0) {\n-        if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) {\n-            /* Move to front of chain if not already there */\n-            if (hep != hep0) {\n-                *hep = he->next;\n-                he->next = *hep0;\n-                *hep0 = he;\n-            }\n-            return hep0;\n-        }\n-        hep = &he->next;\n+  h = keyHash * GOLDEN_RATIO;\n+  h >>= ht->shift;\n+  hep = hep0 = &ht->buckets[h];\n+  while ((he = *hep) != 0) {\n+    if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) {\n+      /* Move to front of chain if not already there */\n+      if (hep != hep0) {\n+        *hep = he->next;\n+        he->next = *hep0;\n+        *hep0 = he;\n+      }\n+      return hep0;\n+    }\n+    hep = &he->next;\n #ifdef HASHMETER\n-        ht->nsteps++;\n+    ht->nsteps++;\n #endif\n-    }\n-    return hep;\n+  }\n+  return hep;\n }\n \n /*\n@@ -169,196 +158,189 @@ PL_HashTableRawLookup(PLHashTable* ht, PLHashNumber keyHash, const void* key)\n */\n PR_IMPLEMENT(PLHashEntry**)\n PL_HashTableRawLookupConst(PLHashTable* ht, PLHashNumber keyHash,\n-                           const void* key)\n-{\n-    PLHashEntry *he, **hep;\n-    PLHashNumber h;\n+                           const void* key) {\n+  PLHashEntry *he, **hep;\n+  PLHashNumber h;\n \n #ifdef HASHMETER\n-    ht->nlookups++;\n+  ht->nlookups++;\n #endif\n-    h = keyHash * GOLDEN_RATIO;\n-    h >>= ht->shift;\n-    hep = &ht->buckets[h];\n-    while ((he = *hep) != 0) {\n-        if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) {\n-            break;\n-        }\n-        hep = &he->next;\n+  h = keyHash * GOLDEN_RATIO;\n+  h >>= ht->shift;\n+  hep = &ht->buckets[h];\n+  while ((he = *hep) != 0) {\n+    if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) {\n+      break;\n+    }\n+    hep = &he->next;\n #ifdef HASHMETER\n-        ht->nsteps++;\n+    ht->nsteps++;\n #endif\n-    }\n-    return hep;\n+  }\n+  return hep;\n }\n \n PR_IMPLEMENT(PLHashEntry*)\n PL_HashTableRawAdd(PLHashTable* ht, PLHashEntry** hep, PLHashNumber keyHash,\n-                   const void* key, void* value)\n-{\n-    PRUint32 i, n;\n-    PLHashEntry *he, *next, **oldbuckets;\n-    PRSize nb;\n-\n-    /* Grow the table if it is overloaded */\n-    n = NBUCKETS(ht);\n-    if (ht->nentries >= OVERLOADED(n)) {\n-        oldbuckets = ht->buckets;\n-        nb = 2 * n * sizeof(PLHashEntry*);\n-        ht->buckets =\n-            (PLHashEntry**)((*ht->allocOps->allocTable)(ht->allocPriv, nb));\n-        if (!ht->buckets) {\n-            ht->buckets = oldbuckets;\n-            return 0;\n-        }\n-        memset(ht->buckets, 0, nb);\n+                   const void* key, void* value) {\n+  PRUint32 i, n;\n+  PLHashEntry *he, *next, **oldbuckets;\n+  PRSize nb;\n+\n+  /* Grow the table if it is overloaded */\n+  n = NBUCKETS(ht);\n+  if (ht->nentries >= OVERLOADED(n)) {\n+    oldbuckets = ht->buckets;\n+    nb = 2 * n * sizeof(PLHashEntry*);\n+    ht->buckets =\n+        (PLHashEntry**)((*ht->allocOps->allocTable)(ht->allocPriv, nb));\n+    if (!ht->buckets) {\n+      ht->buckets = oldbuckets;\n+      return 0;\n+    }\n+    memset(ht->buckets, 0, nb);\n #ifdef HASHMETER\n-        ht->ngrows++;\n+    ht->ngrows++;\n #endif\n-        ht->shift--;\n-\n-        for (i = 0; i < n; i++) {\n-            for (he = oldbuckets[i]; he; he = next) {\n-                next = he->next;\n-                hep = PL_HashTableRawLookup(ht, he->keyHash, he->key);\n-                PR_ASSERT(*hep == 0);\n-                he->next = 0;\n-                *hep = he;\n-            }\n-        }\n+    ht->shift--;\n+\n+    for (i = 0; i < n; i++) {\n+      for (he = oldbuckets[i]; he; he = next) {\n+        next = he->next;\n+        hep = PL_HashTableRawLookup(ht, he->keyHash, he->key);\n+        PR_ASSERT(*hep == 0);\n+        he->next = 0;\n+        *hep = he;\n+      }\n+    }\n #ifdef DEBUG\n-        memset(oldbuckets, 0xDB, n * sizeof oldbuckets[0]);\n+    memset(oldbuckets, 0xDB, n * sizeof oldbuckets[0]);\n #endif\n-        (*ht->allocOps->freeTable)(ht->allocPriv, oldbuckets);\n-        hep = PL_HashTableRawLookup(ht, keyHash, key);\n-    }\n+    (*ht->allocOps->freeTable)(ht->allocPriv, oldbuckets);\n+    hep = PL_HashTableRawLookup(ht, keyHash, key);\n+  }\n \n-    /* Make a new key value entry */\n-    he = (*ht->allocOps->allocEntry)(ht->allocPriv, key);\n-    if (!he) {\n-        return 0;\n-    }\n-    he->keyHash = keyHash;\n-    he->key = key;\n-    he->value = value;\n-    he->next = *hep;\n-    *hep = he;\n-    ht->nentries++;\n-    return he;\n+  /* Make a new key value entry */\n+  he = (*ht->allocOps->allocEntry)(ht->allocPriv, key);\n+  if (!he) {\n+    return 0;\n+  }\n+  he->keyHash = keyHash;\n+  he->key = key;\n+  he->value = value;\n+  he->next = *hep;\n+  *hep = he;\n+  ht->nentries++;\n+  return he;\n }\n \n PR_IMPLEMENT(PLHashEntry*)\n-PL_HashTableAdd(PLHashTable* ht, const void* key, void* value)\n-{\n-    PLHashNumber keyHash;\n-    PLHashEntry *he, **hep;\n-\n-    keyHash = (*ht->keyHash)(key);\n-    hep = PL_HashTableRawLookup(ht, keyHash, key);\n-    if ((he = *hep) != 0) {\n-        /* Hit; see if values match */\n-        if ((*ht->valueCompare)(he->value, value)) {\n-            /* key,value pair is already present in table */\n-            return he;\n-        }\n-        if (he->value) {\n-            (*ht->allocOps->freeEntry)(ht->allocPriv, he, HT_FREE_VALUE);\n-        }\n-        he->value = value;\n-        return he;\n+PL_HashTableAdd(PLHashTable* ht, const void* key, void* value) {\n+  PLHashNumber keyHash;\n+  PLHashEntry *he, **hep;\n+\n+  keyHash = (*ht->keyHash)(key);\n+  hep = PL_HashTableRawLookup(ht, keyHash, key);\n+  if ((he = *hep) != 0) {\n+    /* Hit; see if values match */\n+    if ((*ht->valueCompare)(he->value, value)) {\n+      /* key,value pair is already present in table */\n+      return he;\n     }\n-    return PL_HashTableRawAdd(ht, hep, keyHash, key, value);\n+    if (he->value) {\n+      (*ht->allocOps->freeEntry)(ht->allocPriv, he, HT_FREE_VALUE);\n+    }\n+    he->value = value;\n+    return he;\n+  }\n+  return PL_HashTableRawAdd(ht, hep, keyHash, key, value);\n }\n \n PR_IMPLEMENT(void)\n-PL_HashTableRawRemove(PLHashTable* ht, PLHashEntry** hep, PLHashEntry* he)\n-{\n-    PRUint32 i, n;\n-    PLHashEntry *next, **oldbuckets;\n-    PRSize nb;\n-\n-    *hep = he->next;\n-    (*ht->allocOps->freeEntry)(ht->allocPriv, he, HT_FREE_ENTRY);\n-\n-    /* Shrink table if it's underloaded */\n-    n = NBUCKETS(ht);\n-    if (--ht->nentries < UNDERLOADED(n)) {\n-        oldbuckets = ht->buckets;\n-        nb = n * sizeof(PLHashEntry*) / 2;\n-        ht->buckets =\n-            (PLHashEntry**)((*ht->allocOps->allocTable)(ht->allocPriv, nb));\n-        if (!ht->buckets) {\n-            ht->buckets = oldbuckets;\n-            return;\n-        }\n-        memset(ht->buckets, 0, nb);\n+PL_HashTableRawRemove(PLHashTable* ht, PLHashEntry** hep, PLHashEntry* he) {\n+  PRUint32 i, n;\n+  PLHashEntry *next, **oldbuckets;\n+  PRSize nb;\n+\n+  *hep = he->next;\n+  (*ht->allocOps->freeEntry)(ht->allocPriv, he, HT_FREE_ENTRY);\n+\n+  /* Shrink table if it's underloaded */\n+  n = NBUCKETS(ht);\n+  if (--ht->nentries < UNDERLOADED(n)) {\n+    oldbuckets = ht->buckets;\n+    nb = n * sizeof(PLHashEntry*) / 2;\n+    ht->buckets =\n+        (PLHashEntry**)((*ht->allocOps->allocTable)(ht->allocPriv, nb));\n+    if (!ht->buckets) {\n+      ht->buckets = oldbuckets;\n+      return;\n+    }\n+    memset(ht->buckets, 0, nb);\n #ifdef HASHMETER\n-        ht->nshrinks++;\n+    ht->nshrinks++;\n #endif\n-        ht->shift++;\n-\n-        for (i = 0; i < n; i++) {\n-            for (he = oldbuckets[i]; he; he = next) {\n-                next = he->next;\n-                hep = PL_HashTableRawLookup(ht, he->keyHash, he->key);\n-                PR_ASSERT(*hep == 0);\n-                he->next = 0;\n-                *hep = he;\n-            }\n-        }\n+    ht->shift++;\n+\n+    for (i = 0; i < n; i++) {\n+      for (he = oldbuckets[i]; he; he = next) {\n+        next = he->next;\n+        hep = PL_HashTableRawLookup(ht, he->keyHash, he->key);\n+        PR_ASSERT(*hep == 0);\n+        he->next = 0;\n+        *hep = he;\n+      }\n+    }\n #ifdef DEBUG\n-        memset(oldbuckets, 0xDB, n * sizeof oldbuckets[0]);\n+    memset(oldbuckets, 0xDB, n * sizeof oldbuckets[0]);\n #endif\n-        (*ht->allocOps->freeTable)(ht->allocPriv, oldbuckets);\n-    }\n+    (*ht->allocOps->freeTable)(ht->allocPriv, oldbuckets);\n+  }\n }\n \n PR_IMPLEMENT(PRBool)\n-PL_HashTableRemove(PLHashTable* ht, const void* key)\n-{\n-    PLHashNumber keyHash;\n-    PLHashEntry *he, **hep;\n-\n-    keyHash = (*ht->keyHash)(key);\n-    hep = PL_HashTableRawLookup(ht, keyHash, key);\n-    if ((he = *hep) == 0) {\n-        return PR_FALSE;\n-    }\n-\n-    /* Hit; remove element */\n-    PL_HashTableRawRemove(ht, hep, he);\n-    return PR_TRUE;\n+PL_HashTableRemove(PLHashTable* ht, const void* key) {\n+  PLHashNumber keyHash;\n+  PLHashEntry *he, **hep;\n+\n+  keyHash = (*ht->keyHash)(key);\n+  hep = PL_HashTableRawLookup(ht, keyHash, key);\n+  if ((he = *hep) == 0) {\n+    return PR_FALSE;\n+  }\n+\n+  /* Hit; remove element */\n+  PL_HashTableRawRemove(ht, hep, he);\n+  return PR_TRUE;\n }\n \n PR_IMPLEMENT(void*)\n-PL_HashTableLookup(PLHashTable* ht, const void* key)\n-{\n-    PLHashNumber keyHash;\n-    PLHashEntry *he, **hep;\n-\n-    keyHash = (*ht->keyHash)(key);\n-    hep = PL_HashTableRawLookup(ht, keyHash, key);\n-    if ((he = *hep) != 0) {\n-        return he->value;\n-    }\n-    return 0;\n+PL_HashTableLookup(PLHashTable* ht, const void* key) {\n+  PLHashNumber keyHash;\n+  PLHashEntry *he, **hep;\n+\n+  keyHash = (*ht->keyHash)(key);\n+  hep = PL_HashTableRawLookup(ht, keyHash, key);\n+  if ((he = *hep) != 0) {\n+    return he->value;\n+  }\n+  return 0;\n }\n \n /*\n ** Same as PL_HashTableLookup but doesn't reorder the hash entries.\n */\n PR_IMPLEMENT(void*)\n-PL_HashTableLookupConst(PLHashTable* ht, const void* key)\n-{\n-    PLHashNumber keyHash;\n-    PLHashEntry *he, **hep;\n-\n-    keyHash = (*ht->keyHash)(key);\n-    hep = PL_HashTableRawLookupConst(ht, keyHash, key);\n-    if ((he = *hep) != 0) {\n-        return he->value;\n-    }\n-    return 0;\n+PL_HashTableLookupConst(PLHashTable* ht, const void* key) {\n+  PLHashNumber keyHash;\n+  PLHashEntry *he, **hep;\n+\n+  keyHash = (*ht->keyHash)(key);\n+  hep = PL_HashTableRawLookupConst(ht, keyHash, key);\n+  if ((he = *hep) != 0) {\n+    return he->value;\n+  }\n+  return 0;\n }\n \n /*\n@@ -367,124 +349,119 @@ PL_HashTableLookupConst(PLHashTable* ht, const void* key)\n ** Return a count of the number of elements scanned.\n */\n PR_IMPLEMENT(int)\n-PL_HashTableEnumerateEntries(PLHashTable* ht, PLHashEnumerator f, void* arg)\n-{\n-    PLHashEntry *he, **hep;\n-    PRUint32 i, nbuckets;\n-    int rv, n = 0;\n-    PLHashEntry* todo = 0;\n-\n-    nbuckets = NBUCKETS(ht);\n-    for (i = 0; i < nbuckets; i++) {\n-        hep = &ht->buckets[i];\n-        while ((he = *hep) != 0) {\n-            rv = (*f)(he, n, arg);\n-            n++;\n-            if (rv & (HT_ENUMERATE_REMOVE | HT_ENUMERATE_UNHASH)) {\n-                *hep = he->next;\n-                if (rv & HT_ENUMERATE_REMOVE) {\n-                    he->next = todo;\n-                    todo = he;\n-                }\n-            } else {\n-                hep = &he->next;\n-            }\n-            if (rv & HT_ENUMERATE_STOP) {\n-                goto out;\n-            }\n+PL_HashTableEnumerateEntries(PLHashTable* ht, PLHashEnumerator f, void* arg) {\n+  PLHashEntry *he, **hep;\n+  PRUint32 i, nbuckets;\n+  int rv, n = 0;\n+  PLHashEntry* todo = 0;\n+\n+  nbuckets = NBUCKETS(ht);\n+  for (i = 0; i < nbuckets; i++) {\n+    hep = &ht->buckets[i];\n+    while ((he = *hep) != 0) {\n+      rv = (*f)(he, n, arg);\n+      n++;\n+      if (rv & (HT_ENUMERATE_REMOVE | HT_ENUMERATE_UNHASH)) {\n+        *hep = he->next;\n+        if (rv & HT_ENUMERATE_REMOVE) {\n+          he->next = todo;\n+          todo = he;\n         }\n+      } else {\n+        hep = &he->next;\n+      }\n+      if (rv & HT_ENUMERATE_STOP) {\n+        goto out;\n+      }\n     }\n+  }\n \n out:\n-    hep = &todo;\n-    while ((he = *hep) != 0) {\n-        PL_HashTableRawRemove(ht, hep, he);\n-    }\n-    return n;\n+  hep = &todo;\n+  while ((he = *hep) != 0) {\n+    PL_HashTableRawRemove(ht, hep, he);\n+  }\n+  return n;\n }\n \n #ifdef HASHMETER\n-#include <math.h>\n-#include <stdio.h>\n+#  include <math.h>\n+#  include <stdio.h>\n \n PR_IMPLEMENT(void)\n-PL_HashTableDumpMeter(PLHashTable* ht, PLHashEnumerator dump, FILE* fp)\n-{\n-    double mean, variance;\n-    PRUint32 nchains, nbuckets;\n-    PRUint32 i, n, maxChain, maxChainLen;\n-    PLHashEntry* he;\n-\n-    variance = 0;\n-    nchains = 0;\n-    maxChainLen = 0;\n-    nbuckets = NBUCKETS(ht);\n-    for (i = 0; i < nbuckets; i++) {\n-        he = ht->buckets[i];\n-        if (!he) {\n-            continue;\n-        }\n-        nchains++;\n-        for (n = 0; he; he = he->next) {\n-            n++;\n-        }\n-        variance += n * n;\n-        if (n > maxChainLen) {\n-            maxChainLen = n;\n-            maxChain = i;\n-        }\n+PL_HashTableDumpMeter(PLHashTable* ht, PLHashEnumerator dump, FILE* fp) {\n+  double mean, variance;\n+  PRUint32 nchains, nbuckets;\n+  PRUint32 i, n, maxChain, maxChainLen;\n+  PLHashEntry* he;\n+\n+  variance = 0;\n+  nchains = 0;\n+  maxChainLen = 0;\n+  nbuckets = NBUCKETS(ht);\n+  for (i = 0; i < nbuckets; i++) {\n+    he = ht->buckets[i];\n+    if (!he) {\n+      continue;\n+    }\n+    nchains++;\n+    for (n = 0; he; he = he->next) {\n+      n++;\n+    }\n+    variance += n * n;\n+    if (n > maxChainLen) {\n+      maxChainLen = n;\n+      maxChain = i;\n+    }\n+  }\n+  mean = (double)ht->nentries / nchains;\n+  variance = fabs(variance / nchains - mean * mean);\n+\n+  fprintf(fp, \"\\nHash table statistics:\\n\");\n+  fprintf(fp, \"     number of lookups: %u\\n\", ht->nlookups);\n+  fprintf(fp, \"     number of entries: %u\\n\", ht->nentries);\n+  fprintf(fp, \"       number of grows: %u\\n\", ht->ngrows);\n+  fprintf(fp, \"     number of shrinks: %u\\n\", ht->nshrinks);\n+  fprintf(fp, \"   mean steps per hash: %g\\n\",\n+          (double)ht->nsteps / ht->nlookups);\n+  fprintf(fp, \"mean hash chain length: %g\\n\", mean);\n+  fprintf(fp, \"    standard deviation: %g\\n\", sqrt(variance));\n+  fprintf(fp, \" max hash chain length: %u\\n\", maxChainLen);\n+  fprintf(fp, \"        max hash chain: [%u]\\n\", maxChain);\n+\n+  for (he = ht->buckets[maxChain], i = 0; he; he = he->next, i++)\n+    if ((*dump)(he, i, fp) != HT_ENUMERATE_NEXT) {\n+      break;\n     }\n-    mean = (double)ht->nentries / nchains;\n-    variance = fabs(variance / nchains - mean * mean);\n-\n-    fprintf(fp, \"\\nHash table statistics:\\n\");\n-    fprintf(fp, \"     number of lookups: %u\\n\", ht->nlookups);\n-    fprintf(fp, \"     number of entries: %u\\n\", ht->nentries);\n-    fprintf(fp, \"       number of grows: %u\\n\", ht->ngrows);\n-    fprintf(fp, \"     number of shrinks: %u\\n\", ht->nshrinks);\n-    fprintf(fp, \"   mean steps per hash: %g\\n\",\n-            (double)ht->nsteps / ht->nlookups);\n-    fprintf(fp, \"mean hash chain length: %g\\n\", mean);\n-    fprintf(fp, \"    standard deviation: %g\\n\", sqrt(variance));\n-    fprintf(fp, \" max hash chain length: %u\\n\", maxChainLen);\n-    fprintf(fp, \"        max hash chain: [%u]\\n\", maxChain);\n-\n-    for (he = ht->buckets[maxChain], i = 0; he; he = he->next, i++)\n-        if ((*dump)(he, i, fp) != HT_ENUMERATE_NEXT) {\n-            break;\n-        }\n }\n #endif /* HASHMETER */\n \n PR_IMPLEMENT(int)\n-PL_HashTableDump(PLHashTable* ht, PLHashEnumerator dump, FILE* fp)\n-{\n-    int count;\n+PL_HashTableDump(PLHashTable* ht, PLHashEnumerator dump, FILE* fp) {\n+  int count;\n \n-    count = PL_HashTableEnumerateEntries(ht, dump, fp);\n+  count = PL_HashTableEnumerateEntries(ht, dump, fp);\n #ifdef HASHMETER\n-    PL_HashTableDumpMeter(ht, dump, fp);\n+  PL_HashTableDumpMeter(ht, dump, fp);\n #endif\n-    return count;\n+  return count;\n }\n \n PR_IMPLEMENT(PLHashNumber)\n-PL_HashString(const void* key)\n-{\n-    PLHashNumber h;\n-    const PRUint8* s;\n-\n-    h = 0;\n-    for (s = (const PRUint8*)key; *s; s++) {\n-        h = PR_ROTATE_LEFT32(h, 4) ^ *s;\n-    }\n-    return h;\n+PL_HashString(const void* key) {\n+  PLHashNumber h;\n+  const PRUint8* s;\n+\n+  h = 0;\n+  for (s = (const PRUint8*)key; *s; s++) {\n+    h = PR_ROTATE_LEFT32(h, 4) ^ *s;\n+  }\n+  return h;\n }\n \n PR_IMPLEMENT(int)\n-PL_CompareStrings(const void* v1, const void* v2)\n-{\n-    return strcmp((const char*)v1, (const char*)v2) == 0;\n+PL_CompareStrings(const void* v1, const void* v2) {\n+  return strcmp((const char*)v1, (const char*)v2) == 0;\n }\n \n PR_IMPLEMENT(int)\ndiff --git a/nspr/lib/ds/plhash.h b/nspr/lib/ds/plhash.h\nindex f725500..2c221ae 100644\n--- a/nspr/lib/ds/plhash.h\n+++ b/nspr/lib/ds/plhash.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -12,53 +13,52 @@\n \n PR_BEGIN_EXTERN_C\n \n-typedef struct PLHashEntry PLHashEntry;\n-typedef struct PLHashTable PLHashTable;\n+typedef struct PLHashEntry  PLHashEntry;\n+typedef struct PLHashTable  PLHashTable;\n typedef PRUint32 PLHashNumber;\n-#define PL_HASH_BITS 32 /* Number of bits in PLHashNumber */\n-typedef PLHashNumber(PR_CALLBACK* PLHashFunction)(const void* key);\n-typedef PRIntn(PR_CALLBACK* PLHashComparator)(const void* v1, const void* v2);\n+#define PL_HASH_BITS 32  /* Number of bits in PLHashNumber */\n+typedef PLHashNumber (PR_CALLBACK *PLHashFunction)(const void *key);\n+typedef PRIntn (PR_CALLBACK *PLHashComparator)(const void *v1, const void *v2);\n \n-typedef PRIntn(PR_CALLBACK* PLHashEnumerator)(PLHashEntry* he, PRIntn i,\n-                                              void* arg);\n+typedef PRIntn (PR_CALLBACK *PLHashEnumerator)(PLHashEntry *he, PRIntn i, void *arg);\n \n /* Flag bits in PLHashEnumerator's return value */\n-#define HT_ENUMERATE_NEXT 0   /* continue enumerating entries */\n-#define HT_ENUMERATE_STOP 1   /* stop enumerating entries */\n-#define HT_ENUMERATE_REMOVE 2 /* remove and free the current entry */\n-#define HT_ENUMERATE_UNHASH 4 /* just unhash the current entry */\n+#define HT_ENUMERATE_NEXT       0       /* continue enumerating entries */\n+#define HT_ENUMERATE_STOP       1       /* stop enumerating entries */\n+#define HT_ENUMERATE_REMOVE     2       /* remove and free the current entry */\n+#define HT_ENUMERATE_UNHASH     4       /* just unhash the current entry */\n \n typedef struct PLHashAllocOps {\n-    void*(PR_CALLBACK* allocTable)(void* pool, PRSize size);\n-    void(PR_CALLBACK* freeTable)(void* pool, void* item);\n-    PLHashEntry*(PR_CALLBACK* allocEntry)(void* pool, const void* key);\n-    void(PR_CALLBACK* freeEntry)(void* pool, PLHashEntry* he, PRUintn flag);\n+    void *              (PR_CALLBACK *allocTable)(void *pool, PRSize size);\n+    void                (PR_CALLBACK *freeTable)(void *pool, void *item);\n+    PLHashEntry *       (PR_CALLBACK *allocEntry)(void *pool, const void *key);\n+    void                (PR_CALLBACK *freeEntry)(void *pool, PLHashEntry *he, PRUintn flag);\n } PLHashAllocOps;\n \n-#define HT_FREE_VALUE 0 /* just free the entry's value */\n-#define HT_FREE_ENTRY 1 /* free value and entire entry */\n+#define HT_FREE_VALUE   0               /* just free the entry's value */\n+#define HT_FREE_ENTRY   1               /* free value and entire entry */\n \n struct PLHashEntry {\n-    PLHashEntry* next;    /* hash chain linkage */\n-    PLHashNumber keyHash; /* key hash function result */\n-    const void* key;      /* ptr to opaque key */\n-    void* value;          /* ptr to opaque value */\n+    PLHashEntry         *next;          /* hash chain linkage */\n+    PLHashNumber        keyHash;        /* key hash function result */\n+    const void          *key;           /* ptr to opaque key */\n+    void                *value;         /* ptr to opaque value */\n };\n \n struct PLHashTable {\n-    PLHashEntry** buckets;          /* vector of hash buckets */\n-    PRUint32 nentries;              /* number of entries in table */\n-    PRUint32 shift;                 /* multiplicative hash shift */\n-    PLHashFunction keyHash;         /* key hash function */\n-    PLHashComparator keyCompare;    /* key comparison function */\n-    PLHashComparator valueCompare;  /* value comparison function */\n-    const PLHashAllocOps* allocOps; /* allocation operations */\n-    void* allocPriv;                /* allocation private data */\n+    PLHashEntry         **buckets;      /* vector of hash buckets */\n+    PRUint32              nentries;       /* number of entries in table */\n+    PRUint32              shift;          /* multiplicative hash shift */\n+    PLHashFunction      keyHash;        /* key hash function */\n+    PLHashComparator    keyCompare;     /* key comparison function */\n+    PLHashComparator    valueCompare;   /* value comparison function */\n+    const PLHashAllocOps *allocOps;     /* allocation operations */\n+    void                *allocPriv;     /* allocation private data */\n #ifdef HASHMETER\n-    PRUint32 nlookups; /* total number of lookups */\n-    PRUint32 nsteps;   /* number of hash chains traversed */\n-    PRUint32 ngrows;   /* number of table expansions */\n-    PRUint32 nshrinks; /* number of table contractions */\n+    PRUint32              nlookups;       /* total number of lookups */\n+    PRUint32              nsteps;         /* number of hash chains traversed */\n+    PRUint32              ngrows;         /* number of table expansions */\n+    PRUint32              nshrinks;       /* number of table contractions */\n #endif\n };\n \n@@ -66,60 +66,60 @@ struct PLHashTable {\n  * Create a new hash table.\n  * If allocOps is null, use default allocator ops built on top of malloc().\n  */\n-PR_EXTERN(PLHashTable*)\n+PR_EXTERN(PLHashTable *)\n PL_NewHashTable(PRUint32 numBuckets, PLHashFunction keyHash,\n                 PLHashComparator keyCompare, PLHashComparator valueCompare,\n-                const PLHashAllocOps* allocOps, void* allocPriv);\n+                const PLHashAllocOps *allocOps, void *allocPriv);\n \n PR_EXTERN(void)\n-PL_HashTableDestroy(PLHashTable* ht);\n+PL_HashTableDestroy(PLHashTable *ht);\n \n /* Higher level access methods */\n-PR_EXTERN(PLHashEntry*)\n-PL_HashTableAdd(PLHashTable* ht, const void* key, void* value);\n+PR_EXTERN(PLHashEntry *)\n+PL_HashTableAdd(PLHashTable *ht, const void *key, void *value);\n \n PR_EXTERN(PRBool)\n-PL_HashTableRemove(PLHashTable* ht, const void* key);\n+PL_HashTableRemove(PLHashTable *ht, const void *key);\n \n-PR_EXTERN(void*)\n-PL_HashTableLookup(PLHashTable* ht, const void* key);\n+PR_EXTERN(void *)\n+PL_HashTableLookup(PLHashTable *ht, const void *key);\n \n-PR_EXTERN(void*)\n-PL_HashTableLookupConst(PLHashTable* ht, const void* key);\n+PR_EXTERN(void *)\n+PL_HashTableLookupConst(PLHashTable *ht, const void *key);\n \n PR_EXTERN(PRIntn)\n-PL_HashTableEnumerateEntries(PLHashTable* ht, PLHashEnumerator f, void* arg);\n+PL_HashTableEnumerateEntries(PLHashTable *ht, PLHashEnumerator f, void *arg);\n \n /* General-purpose C string hash function. */\n PR_EXTERN(PLHashNumber)\n-PL_HashString(const void* key);\n+PL_HashString(const void *key);\n \n /* Compare strings using strcmp(), return true if equal. */\n PR_EXTERN(PRIntn)\n-PL_CompareStrings(const void* v1, const void* v2);\n+PL_CompareStrings(const void *v1, const void *v2);\n \n /* Stub function just returns v1 == v2 */\n PR_EXTERN(PRIntn)\n-PL_CompareValues(const void* v1, const void* v2);\n+PL_CompareValues(const void *v1, const void *v2);\n \n /* Low level access methods */\n-PR_EXTERN(PLHashEntry**)\n-PL_HashTableRawLookup(PLHashTable* ht, PLHashNumber keyHash, const void* key);\n+PR_EXTERN(PLHashEntry **)\n+PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key);\n \n-PR_EXTERN(PLHashEntry**)\n-PL_HashTableRawLookupConst(PLHashTable* ht, PLHashNumber keyHash,\n-                           const void* key);\n+PR_EXTERN(PLHashEntry **)\n+PL_HashTableRawLookupConst(PLHashTable *ht, PLHashNumber keyHash,\n+                           const void *key);\n \n-PR_EXTERN(PLHashEntry*)\n-PL_HashTableRawAdd(PLHashTable* ht, PLHashEntry** hep, PLHashNumber keyHash,\n-                   const void* key, void* value);\n+PR_EXTERN(PLHashEntry *)\n+PL_HashTableRawAdd(PLHashTable *ht, PLHashEntry **hep, PLHashNumber keyHash,\n+                   const void *key, void *value);\n \n PR_EXTERN(void)\n-PL_HashTableRawRemove(PLHashTable* ht, PLHashEntry** hep, PLHashEntry* he);\n+PL_HashTableRawRemove(PLHashTable *ht, PLHashEntry **hep, PLHashEntry *he);\n \n /* This can be trivially implemented using PL_HashTableEnumerateEntries. */\n PR_EXTERN(PRIntn)\n-PL_HashTableDump(PLHashTable* ht, PLHashEnumerator dump, FILE* fp);\n+PL_HashTableDump(PLHashTable *ht, PLHashEnumerator dump, FILE *fp);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/lib/ds/plvrsion.c b/nspr/lib/ds/plvrsion.c\nindex 89626a9..d50f8f8 100644\n--- a/nspr/lib/ds/plvrsion.c\n+++ b/nspr/lib/ds/plvrsion.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,22 +11,22 @@\n /************************************************************************/\n #include \"_pl_bld.h\"\n #if !defined(_BUILD_TIME)\n-#ifdef HAVE_LONG_LONG\n-#define _BUILD_TIME 0\n-#else\n-#define _BUILD_TIME { 0, 0 }\n-#endif\n+#  ifdef HAVE_LONG_LONG\n+#    define _BUILD_TIME 0\n+#  else\n+#    define _BUILD_TIME {0, 0}\n+#  endif\n #endif\n #if !defined(_BUILD_STRING)\n-#define _BUILD_STRING \"\"\n+#  define _BUILD_STRING \"\"\n #endif\n #if !defined(_PRODUCTION)\n-#define _PRODUCTION \"\"\n+#  define _PRODUCTION \"\"\n #endif\n #if defined(DEBUG)\n-#define _DEBUG_STRING \" (debug)\"\n+#  define _DEBUG_STRING \" (debug)\"\n #else\n-#define _DEBUG_STRING \"\"\n+#  define _DEBUG_STRING \"\"\n #endif\n \n /*\n@@ -36,8 +37,8 @@\n #define VERSION_DESC_NAME CONCAT2(prVersionDescription_libplds, PR_VMAJOR)\n \n PRVersionDescription VERSION_DESC_NAME = {\n-    /* version          */ 2,             /* this is the only one supported */\n-    /* buildTime        */ _BUILD_TIME,   /* usecs since midnight 1/1/1970 GMT */\n+    /* version          */ 2,           /* this is the only one supported */\n+    /* buildTime        */ _BUILD_TIME, /* usecs since midnight 1/1/1970 GMT */\n     /* buildTimeString  */ _BUILD_STRING, /*    ditto, but human readable */\n     /* vMajor           */ PR_VMAJOR,     /* NSPR's version number */\n     /* vMinor           */ PR_VMINOR,     /*  and minor version */\n@@ -48,8 +49,8 @@ PRVersionDescription VERSION_DESC_NAME = {\n #else\n     /* debug            */ PR_FALSE, /* an optomized build */\n #endif\n-    /* special          */ PR_FALSE,           /* they're all special, but ... */\n-    /* filename         */ _PRODUCTION,        /* the produced library name */\n+    /* special          */ PR_FALSE,    /* they're all special, but ... */\n+    /* filename         */ _PRODUCTION, /* the produced library name */\n     /* description      */ \"Portable runtime\", /* what we are */\n     /* security         */ \"N/A\",              /* not applicable here */\n                                                /* copywrite        */\n@@ -57,8 +58,7 @@ PRVersionDescription VERSION_DESC_NAME = {\n     \"License, v. 2.0. If a copy of the MPL was not distributed with this file, \"\n     \"You can obtain one at http://mozilla.org/MPL/2.0/.\",\n     /* comment          */ \"http://www.mozilla.org/MPL/\",\n-    /* specialString    */ \"\"\n-};\n+    /* specialString    */ \"\"};\n \n #ifdef XP_UNIX\n \n@@ -75,26 +75,24 @@ static char sccsid[] = \"@(#)NSPR \" PR_VERSION _DEBUG_STRING \"  \" _BUILD_STRING;\n #endif /* XP_UNIX */\n \n #ifdef _PR_HAS_PRAGMA_DIAGNOSTIC\n-#pragma GCC diagnostic push\n-#pragma GCC diagnostic ignored \"-Wunused-but-set-variable\"\n+#  pragma GCC diagnostic push\n+#  pragma GCC diagnostic ignored \"-Wunused-but-set-variable\"\n #endif\n-PR_IMPLEMENT(const PRVersionDescription*)\n-libVersionPoint()\n-{\n+PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint() {\n #ifdef XP_UNIX\n-    /*\n-     * Add dummy references to rcsid and sccsid to prevent them\n-     * from being optimized away as unused variables.\n-     */\n-    const char* dummy;\n+  /*\n+   * Add dummy references to rcsid and sccsid to prevent them\n+   * from being optimized away as unused variables.\n+   */\n+  const char* dummy;\n \n-    dummy = rcsid;\n-    dummy = sccsid;\n+  dummy = rcsid;\n+  dummy = sccsid;\n #endif\n-    return &VERSION_DESC_NAME;\n+  return &VERSION_DESC_NAME;\n } /* versionEntryPointType */\n #ifdef _PR_HAS_PRAGMA_DIAGNOSTIC\n-#pragma GCC diagnostic pop\n+#  pragma GCC diagnostic pop\n #endif\n \n /* plvrsion.c */\ndiff --git a/nspr/lib/libc/.cvsignore b/nspr/lib/libc/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/lib/libc/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/lib/libc/include/.cvsignore b/nspr/lib/libc/include/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/lib/libc/include/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/lib/libc/include/plbase64.h b/nspr/lib/libc/include/plbase64.h\nindex 40a8ab9..8f2117c 100644\n--- a/nspr/lib/libc/include/plbase64.h\n+++ b/nspr/lib/libc/include/plbase64.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -30,8 +31,13 @@ PR_BEGIN_EXTERN_C\n  * to avoid PRUint32 overflow.\n  */\n \n-PR_EXTERN(char*)\n-PL_Base64Encode(const char* src, PRUint32 srclen, char* dest);\n+PR_EXTERN(char *)\n+PL_Base64Encode\n+(\n+    const char *src,\n+    PRUint32    srclen,\n+    char       *dest\n+);\n \n /*\n  * PL_Base64Decode\n@@ -57,8 +63,13 @@ PL_Base64Encode(const char* src, PRUint32 srclen, char* dest);\n  * which is equivalent but doesn't overflow for any value of srclen.\n  */\n \n-PR_EXTERN(char*)\n-PL_Base64Decode(const char* src, PRUint32 srclen, char* dest);\n+PR_EXTERN(char *)\n+PL_Base64Decode\n+(\n+    const char *src,\n+    PRUint32    srclen,\n+    char       *dest\n+);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/lib/libc/include/plerror.h b/nspr/lib/libc/include/plerror.h\nindex a00d720..cd85dd3 100644\n--- a/nspr/lib/libc/include/plerror.h\n+++ b/nspr/lib/libc/include/plerror.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -19,14 +20,12 @@ PR_BEGIN_EXTERN_C\n /*\n ** Print the messages to \"syserr\" prepending 'msg' if not NULL.\n */\n-PR_EXTERN(void)\n-PL_PrintError(const char* msg);\n+PR_EXTERN(void) PL_PrintError(const char *msg);\n \n /*\n ** Print the messages to specified output file prepending 'msg' if not NULL.\n */\n-PR_EXTERN(void)\n-PL_FPrintError(PRFileDesc* output, const char* msg);\n+PR_EXTERN(void) PL_FPrintError(PRFileDesc *output, const char *msg);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/lib/libc/include/plgetopt.h b/nspr/lib/libc/include/plgetopt.h\nindex 579b882..bd5181b 100644\n--- a/nspr/lib/libc/include/plgetopt.h\n+++ b/nspr/lib/libc/include/plgetopt.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -17,27 +18,30 @@ PR_BEGIN_EXTERN_C\n \n typedef struct PLOptionInternal PLOptionInternal;\n \n-typedef enum {\n-    PL_OPT_OK,  /* all's well with the option */\n-    PL_OPT_EOL, /* end of options list */\n-    PL_OPT_BAD  /* invalid option (and value) */\n+typedef enum\n+{\n+    PL_OPT_OK,              /* all's well with the option */\n+    PL_OPT_EOL,             /* end of options list */\n+    PL_OPT_BAD              /* invalid option (and value) */\n } PLOptStatus;\n \n-typedef struct PLLongOpt {\n-    const char* longOptName; /* long option name string                  */\n-    PRIntn longOption;       /* value put in PLOptState for this option. */\n-    PRBool valueRequired;    /* If option name not followed by '=',      */\n-                             /* value is the next argument from argv.    */\n+typedef struct PLLongOpt\n+{\n+    const char * longOptName;   /* long option name string                  */\n+    PRIntn       longOption;    /* value put in PLOptState for this option. */\n+    PRBool       valueRequired; /* If option name not followed by '=',      */\n+    /* value is the next argument from argv.    */\n } PLLongOpt;\n \n-typedef struct PLOptState {\n-    char option;       /* the name of the option */\n-    const char* value; /* the value of that option | NULL */\n+typedef struct PLOptState\n+{\n+    char option;                /* the name of the option */\n+    const char *value;          /* the value of that option | NULL */\n \n-    PLOptionInternal* internal; /* private processing state */\n+    PLOptionInternal *internal; /* private processing state */\n \n-    PRIntn longOption;   /* value from PLLongOpt put here */\n-    PRIntn longOptIndex; /* index into caller's array of PLLongOpts */\n+    PRIntn   longOption;        /* value from PLLongOpt put here */\n+    PRIntn   longOptIndex;      /* index into caller's array of PLLongOpts */\n } PLOptState;\n \n /*\n@@ -47,8 +51,8 @@ typedef struct PLOptState {\n  * names.  Option names that may have an option argument value must be\n  * followed immediately by a ':' character.\n  */\n-PR_EXTERN(PLOptState*)\n-PL_CreateOptState(PRIntn argc, char** argv, const char* options);\n+PR_EXTERN(PLOptState*) PL_CreateOptState(\n+    PRIntn argc, char **argv, const char *options);\n \n /*\n  * PL_CreateLongOptState\n@@ -61,17 +65,16 @@ PL_CreateOptState(PRIntn argc, char** argv, const char* options);\n  * If PLLongOpt.valueRequired is not PR_FALSE, and the option name was not\n  * followed by '=' then the next argument from argv is taken as the value.\n  */\n-PR_EXTERN(PLOptState*)\n-PL_CreateLongOptState(PRIntn argc, char** argv, const char* options,\n-                      const PLLongOpt* longOpts);\n+PR_EXTERN(PLOptState*) PL_CreateLongOptState(\n+    PRIntn argc, char **argv, const char *options,\n+    const PLLongOpt *longOpts);\n /*\n  * PL_DestroyOptState\n  *\n  * Call this to destroy the PLOptState returned from PL_CreateOptState or\n  * PL_CreateLongOptState.\n  */\n-PR_EXTERN(void)\n-PL_DestroyOptState(PLOptState* opt);\n+PR_EXTERN(void) PL_DestroyOptState(PLOptState *opt);\n \n /*\n  * PL_GetNextOpt\n@@ -112,11 +115,11 @@ PL_DestroyOptState(PLOptState* opt);\n  *   any possible single character name.  It might be advisable to choose\n  *   longOption values greater than 0xff for such long options.\n  */\n-PR_EXTERN(PLOptStatus)\n-PL_GetNextOpt(PLOptState* opt);\n+PR_EXTERN(PLOptStatus) PL_GetNextOpt(PLOptState *opt);\n \n PR_END_EXTERN_C\n \n #endif /* defined(PLGETOPT_H_) */\n \n /* plgetopt.h */\n+\ndiff --git a/nspr/lib/libc/include/plstr.h b/nspr/lib/libc/include/plstr.h\nindex 31290f8..ea59832 100644\n--- a/nspr/lib/libc/include/plstr.h\n+++ b/nspr/lib/libc/include/plstr.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -35,7 +36,7 @@ PR_BEGIN_EXTERN_C\n  */\n \n PR_EXTERN(PRUint32)\n-PL_strlen(const char* str);\n+PL_strlen(const char *str);\n \n /*\n  * PL_strnlen\n@@ -46,7 +47,7 @@ PL_strlen(const char* str);\n  */\n \n PR_EXTERN(PRUint32)\n-PL_strnlen(const char* str, PRUint32 max);\n+PL_strnlen(const char *str, PRUint32 max);\n \n /*\n  * PL_strcpy\n@@ -56,8 +57,8 @@ PL_strnlen(const char* str, PRUint32 max);\n  * buffer is large enough.  It returns the \"dest\" argument.\n  */\n \n-PR_EXTERN(char*)\n-PL_strcpy(char* dest, const char* src);\n+PR_EXTERN(char *)\n+PL_strcpy(char *dest, const char *src);\n \n /*\n  * PL_strncpy\n@@ -69,8 +70,8 @@ PL_strcpy(char* dest, const char* src);\n  * the result will *not* be null-terminated (JLRU).\n  */\n \n-PR_EXTERN(char*)\n-PL_strncpy(char* dest, const char* src, PRUint32 max);\n+PR_EXTERN(char *)\n+PL_strncpy(char *dest, const char *src, PRUint32 max);\n \n /*\n  * PL_strncpyz\n@@ -92,8 +93,8 @@ PL_strncpy(char* dest, const char* src, PRUint32 max);\n  * and the result will be properly terminated.\n  */\n \n-PR_EXTERN(char*)\n-PL_strncpyz(char* dest, const char* src, PRUint32 max);\n+PR_EXTERN(char *)\n+PL_strncpyz(char *dest, const char *src, PRUint32 max);\n \n /*\n  * PL_strdup\n@@ -106,8 +107,8 @@ PL_strncpyz(char* dest, const char* src, PRUint32 max);\n  * upon malloc failure.\n  */\n \n-PR_EXTERN(char*)\n-PL_strdup(const char* s);\n+PR_EXTERN(char *)\n+PL_strdup(const char *s);\n \n /*\n  * PL_strfree\n@@ -116,7 +117,7 @@ PL_strdup(const char* s);\n  */\n \n PR_EXTERN(void)\n-PL_strfree(char* s);\n+PL_strfree(char *s);\n \n /*\n  * PL_strndup\n@@ -130,8 +131,8 @@ PL_strfree(char* s);\n  * containing the null value.  This routine returns null upon malloc failure.\n  */\n \n-PR_EXTERN(char*)\n-PL_strndup(const char* s, PRUint32 max);\n+PR_EXTERN(char *)\n+PL_strndup(const char *s, PRUint32 max);\n \n /*\n  * PL_strcat\n@@ -142,8 +143,8 @@ PL_strndup(const char* s, PRUint32 max);\n  * argument returns null; otherwise, the first argument is returned.\n  */\n \n-PR_EXTERN(char*)\n-PL_strcat(char* dst, const char* src);\n+PR_EXTERN(char *)\n+PL_strcat(char *dst, const char *src);\n \n /*\n  * PL_strncat\n@@ -157,8 +158,8 @@ PL_strcat(char* dst, const char* src);\n  * returns null; otherwise, the destination argument is returned.\n  */\n \n-PR_EXTERN(char*)\n-PL_strncat(char* dst, const char* src, PRUint32 max);\n+PR_EXTERN(char *)\n+PL_strncat(char *dst, const char *src, PRUint32 max);\n \n /*\n  * PL_strcatn\n@@ -171,8 +172,8 @@ PL_strncat(char* dst, const char* src, PRUint32 max);\n  * null; otherwise, the destination argument is returned.\n  */\n \n-PR_EXTERN(char*)\n-PL_strcatn(char* dst, PRUint32 max, const char* src);\n+PR_EXTERN(char *)\n+PL_strcatn(char *dst, PRUint32 max, const char *src);\n \n /*\n  * PL_strcmp\n@@ -184,7 +185,7 @@ PL_strcatn(char* dst, PRUint32 max, const char* src);\n  */\n \n PR_EXTERN(PRIntn)\n-PL_strcmp(const char* a, const char* b);\n+PL_strcmp(const char *a, const char *b);\n \n /*\n  * PL_strncmp\n@@ -198,7 +199,7 @@ PL_strcmp(const char* a, const char* b);\n  */\n \n PR_EXTERN(PRIntn)\n-PL_strncmp(const char* a, const char* b, PRUint32 max);\n+PL_strncmp(const char *a, const char *b, PRUint32 max);\n \n /*\n  * PL_strcasecmp\n@@ -210,19 +211,19 @@ PL_strncmp(const char* a, const char* b, PRUint32 max);\n  */\n \n PR_EXTERN(PRIntn)\n-PL_strcasecmp(const char* a, const char* b);\n+PL_strcasecmp(const char *a, const char *b);\n \n /*\n  * PL_strncasecmp\n  *\n  * Returns an integer, the sign of which -- positive, zero or negative --\n  * reflects the case-insensitive lexical sorting order of the first n characters\n- * of the two strings indicated.  The result is positive if the first string\n- * comes after the second.  The NSPR implementation is not i18n.\n+ * of the two strings indicated.  The result is positive if the first string comes\n+ * after the second.  The NSPR implementation is not i18n.\n  */\n \n PR_EXTERN(PRIntn)\n-PL_strncasecmp(const char* a, const char* b, PRUint32 max);\n+PL_strncasecmp(const char *a, const char *b, PRUint32 max);\n \n /*\n  * PL_strchr\n@@ -232,8 +233,8 @@ PL_strncasecmp(const char* a, const char* b, PRUint32 max);\n  * provided string is null.  The character may be the null character.\n  */\n \n-PR_EXTERN(char*)\n-PL_strchr(const char* s, char c);\n+PR_EXTERN(char *)\n+PL_strchr(const char *s, char c);\n \n /*\n  * PL_strrchr\n@@ -243,8 +244,8 @@ PL_strchr(const char* s, char c);\n  * provided string is null.  The character may be the null character.\n  */\n \n-PR_EXTERN(char*)\n-PL_strrchr(const char* s, char c);\n+PR_EXTERN(char *)\n+PL_strrchr(const char *s, char c);\n \n /*\n  * PL_strnchr\n@@ -255,20 +256,20 @@ PL_strrchr(const char* s, char c);\n  * null character.\n  */\n \n-PR_EXTERN(char*)\n-PL_strnchr(const char* s, char c, PRUint32 n);\n+PR_EXTERN(char *)\n+PL_strnchr(const char *s, char c, PRUint32 n);\n \n /*\n  * PL_strnrchr\n  *\n  * Returns a pointer to the last instance of the specified character within the\n- * first n characters of the provided string.  It returns null if the character\n- * is not found, or if the provided string is null.  The character may be the\n- * null character.\n+ * first n characters of the provided string.  It returns null if the character is\n+ * not found, or if the provided string is null.  The character may be the null\n+ * character.\n  */\n \n-PR_EXTERN(char*)\n-PL_strnrchr(const char* s, char c, PRUint32 n);\n+PR_EXTERN(char *)\n+PL_strnrchr(const char *s, char c, PRUint32 n);\n \n /*\n  * NOTE: Looking for strcasechr, strcaserchr, strncasechr, or strncaserchr?\n@@ -279,45 +280,45 @@ PL_strnrchr(const char* s, char c, PRUint32 n);\n  * PL_strpbrk\n  *\n  * Returns a pointer to the first instance in the first string of any character\n- * (not including the terminating null character) of the second string.  It\n- * returns null if either string is null.\n+ * (not including the terminating null character) of the second string.  It returns\n+ * null if either string is null.\n  */\n \n-PR_EXTERN(char*)\n-PL_strpbrk(const char* s, const char* list);\n+PR_EXTERN(char *)\n+PL_strpbrk(const char *s, const char *list);\n \n /*\n  * PL_strprbrk\n  *\n  * Returns a pointer to the last instance in the first string of any character\n- * (not including the terminating null character) of the second string.  It\n- * returns null if either string is null.\n+ * (not including the terminating null character) of the second string.  It returns\n+ * null if either string is null.\n  */\n \n-PR_EXTERN(char*)\n-PL_strprbrk(const char* s, const char* list);\n+PR_EXTERN(char *)\n+PL_strprbrk(const char *s, const char *list);\n \n /*\n  * PL_strnpbrk\n  *\n- * Returns a pointer to the first instance (within the first n characters) of\n- * any character (not including the terminating null character) of the second\n- * string. It returns null if either string is null.\n+ * Returns a pointer to the first instance (within the first n characters) of any\n+ * character (not including the terminating null character) of the second string.\n+ * It returns null if either string is null.\n  */\n \n-PR_EXTERN(char*)\n-PL_strnpbrk(const char* s, const char* list, PRUint32 n);\n+PR_EXTERN(char *)\n+PL_strnpbrk(const char *s, const char *list, PRUint32 n);\n \n /*\n  * PL_strnprbrk\n  *\n  * Returns a pointer to the last instance (within the first n characters) of any\n- * character (not including the terminating null character) of the second\n- * string. It returns null if either string is null.\n+ * character (not including the terminating null character) of the second string.\n+ * It returns null if either string is null.\n  */\n \n-PR_EXTERN(char*)\n-PL_strnprbrk(const char* s, const char* list, PRUint32 n);\n+PR_EXTERN(char *)\n+PL_strnprbrk(const char *s, const char *list, PRUint32 n);\n \n /*\n  * PL_strstr\n@@ -326,18 +327,18 @@ PL_strnprbrk(const char* s, const char* list, PRUint32 n);\n  * big one.  It returns null if either string is null.\n  */\n \n-PR_EXTERN(char*)\n-PL_strstr(const char* big, const char* little);\n+PR_EXTERN(char *)\n+PL_strstr(const char *big, const char *little);\n \n /*\n  * PL_strrstr\n  *\n- * Returns a pointer to the last instance of the little string within the big\n- * one. It returns null if either string is null.\n+ * Returns a pointer to the last instance of the little string within the big one.\n+ * It returns null if either string is null.\n  */\n \n-PR_EXTERN(char*)\n-PL_strrstr(const char* big, const char* little);\n+PR_EXTERN(char *)\n+PL_strrstr(const char *big, const char *little);\n \n /*\n  * PL_strnstr\n@@ -347,8 +348,8 @@ PL_strrstr(const char* big, const char* little);\n  * returns null if the length of the little string is greater than n.\n  */\n \n-PR_EXTERN(char*)\n-PL_strnstr(const char* big, const char* little, PRUint32 n);\n+PR_EXTERN(char *)\n+PL_strnstr(const char *big, const char *little, PRUint32 n);\n \n /*\n  * PL_strnrstr\n@@ -358,52 +359,50 @@ PL_strnstr(const char* big, const char* little, PRUint32 n);\n  * returns null if the length of the little string is greater than n.\n  */\n \n-PR_EXTERN(char*)\n-PL_strnrstr(const char* big, const char* little, PRUint32 max);\n+PR_EXTERN(char *)\n+PL_strnrstr(const char *big, const char *little, PRUint32 max);\n \n /*\n  * PL_strcasestr\n  *\n- * Returns a pointer to the first instance of the little string within the big\n- * one, ignoring case.  It returns null if either string is null.\n+ * Returns a pointer to the first instance of the little string within the big one,\n+ * ignoring case.  It returns null if either string is null.\n  */\n \n-PR_EXTERN(char*)\n-PL_strcasestr(const char* big, const char* little);\n+PR_EXTERN(char *)\n+PL_strcasestr(const char *big, const char *little);\n \n /*\n  * PL_strcaserstr\n  *\n- * Returns a pointer to the last instance of the little string within the big\n- * one, ignoring case.  It returns null if either string is null.\n+ * Returns a pointer to the last instance of the little string within the big one,\n+ * ignoring case.  It returns null if either string is null.\n  */\n \n-PR_EXTERN(char*)\n-PL_strcaserstr(const char* big, const char* little);\n+PR_EXTERN(char *)\n+PL_strcaserstr(const char *big, const char *little);\n \n /*\n  * PL_strncasestr\n  *\n  * Returns a pointer to the first instance of the little string within the first\n- * n characters of the big one, ignoring case.  It returns null if either string\n- * is null.  It returns null if the length of the little string is greater than\n- * n.\n+ * n characters of the big one, ignoring case.  It returns null if either string is\n+ * null.  It returns null if the length of the little string is greater than n.\n  */\n \n-PR_EXTERN(char*)\n-PL_strncasestr(const char* big, const char* little, PRUint32 max);\n+PR_EXTERN(char *)\n+PL_strncasestr(const char *big, const char *little, PRUint32 max);\n \n /*\n  * PL_strncaserstr\n  *\n  * Returns a pointer to the last instance of the little string within the first\n- * n characters of the big one, ignoring case.  It returns null if either string\n- * is null.  It returns null if the length of the little string is greater than\n- * n.\n+ * n characters of the big one, ignoring case.  It returns null if either string is\n+ * null.  It returns null if the length of the little string is greater than n.\n  */\n \n-PR_EXTERN(char*)\n-PL_strncaserstr(const char* big, const char* little, PRUint32 max);\n+PR_EXTERN(char *)\n+PL_strncaserstr(const char *big, const char *little, PRUint32 max);\n \n /*\n  * PL_strtok_r\n@@ -424,8 +423,8 @@ PL_strncaserstr(const char* big, const char* little, PRUint32 max);\n  * token remains in s1, PL_strtok_r returns null.\n  */\n \n-PR_EXTERN(char*)\n-PL_strtok_r(char* s1, const char* s2, char** lasts);\n+PR_EXTERN(char *)\n+PL_strtok_r(char *s1, const char *s2, char **lasts);\n \n /*\n  * Things not (yet?) included: strspn/strcspn, strsep.\ndiff --git a/nspr/lib/libc/src/.cvsignore b/nspr/lib/libc/src/.cvsignore\nnew file mode 100644\nindex 0000000..bcab60f\n--- /dev/null\n+++ b/nspr/lib/libc/src/.cvsignore\n@@ -0,0 +1,2 @@\n+Makefile\n+_pl_bld.h\ndiff --git a/nspr/lib/libc/src/base64.c b/nspr/lib/libc/src/base64.c\nindex 4f47b12..4517a74 100644\n--- a/nspr/lib/libc/src/base64.c\n+++ b/nspr/lib/libc/src/base64.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,72 +9,64 @@\n \n #include <string.h> /* for strlen */\n \n-static unsigned char* base = (unsigned char*)\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n+static unsigned char *base = (unsigned char *)\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n \n-static void\n-encode3to4(const unsigned char* src, unsigned char* dest)\n-{\n-    PRUint32 b32 = (PRUint32)0;\n-    PRIntn i, j = 18;\n+static void encode3to4(const unsigned char* src, unsigned char* dest) {\n+  PRUint32 b32 = (PRUint32)0;\n+  PRIntn i, j = 18;\n \n-    for (i = 0; i < 3; i++) {\n-        b32 <<= 8;\n-        b32 |= (PRUint32)src[i];\n-    }\n+  for (i = 0; i < 3; i++) {\n+    b32 <<= 8;\n+    b32 |= (PRUint32)src[i];\n+  }\n \n-    for (i = 0; i < 4; i++) {\n-        dest[i] = base[(PRUint32)((b32 >> j) & 0x3F)];\n-        j -= 6;\n-    }\n+  for (i = 0; i < 4; i++) {\n+    dest[i] = base[(PRUint32)((b32 >> j) & 0x3F)];\n+    j -= 6;\n+  }\n \n-    return;\n+  return;\n }\n \n-static void\n-encode2to4(const unsigned char* src, unsigned char* dest)\n-{\n-    dest[0] = base[(PRUint32)((src[0] >> 2) & 0x3F)];\n-    dest[1] = base[(PRUint32)(((src[0] & 0x03) << 4) | ((src[1] >> 4) & 0x0F))];\n-    dest[2] = base[(PRUint32)((src[1] & 0x0F) << 2)];\n-    dest[3] = (unsigned char)'=';\n-    return;\n+static void encode2to4(const unsigned char* src, unsigned char* dest) {\n+  dest[0] = base[(PRUint32)((src[0] >> 2) & 0x3F)];\n+  dest[1] = base[(PRUint32)(((src[0] & 0x03) << 4) | ((src[1] >> 4) & 0x0F))];\n+  dest[2] = base[(PRUint32)((src[1] & 0x0F) << 2)];\n+  dest[3] = (unsigned char)'=';\n+  return;\n }\n \n-static void\n-encode1to4(const unsigned char* src, unsigned char* dest)\n-{\n-    dest[0] = base[(PRUint32)((src[0] >> 2) & 0x3F)];\n-    dest[1] = base[(PRUint32)((src[0] & 0x03) << 4)];\n-    dest[2] = (unsigned char)'=';\n-    dest[3] = (unsigned char)'=';\n-    return;\n+static void encode1to4(const unsigned char* src, unsigned char* dest) {\n+  dest[0] = base[(PRUint32)((src[0] >> 2) & 0x3F)];\n+  dest[1] = base[(PRUint32)((src[0] & 0x03) << 4)];\n+  dest[2] = (unsigned char)'=';\n+  dest[3] = (unsigned char)'=';\n+  return;\n }\n \n-static void\n-encode(const unsigned char* src, PRUint32 srclen,\n-       unsigned char* dest)\n-{\n-    while (srclen >= 3) {\n-        encode3to4(src, dest);\n-        src += 3;\n-        dest += 4;\n-        srclen -= 3;\n-    }\n-\n-    switch (srclen) {\n-        case 2:\n-            encode2to4(src, dest);\n-            break;\n-        case 1:\n-            encode1to4(src, dest);\n-            break;\n-        case 0:\n-            break;\n-        default:\n-            PR_NOT_REACHED(\"coding error\");\n-    }\n-\n-    return;\n+static void encode(const unsigned char* src, PRUint32 srclen,\n+                   unsigned char* dest) {\n+  while (srclen >= 3) {\n+    encode3to4(src, dest);\n+    src += 3;\n+    dest += 4;\n+    srclen -= 3;\n+  }\n+\n+  switch (srclen) {\n+    case 2:\n+      encode2to4(src, dest);\n+      break;\n+    case 1:\n+      encode1to4(src, dest);\n+      break;\n+    case 0:\n+      break;\n+    default:\n+      PR_NOT_REACHED(\"coding error\");\n+  }\n+\n+  return;\n }\n \n /*\n@@ -89,177 +82,166 @@ encode(const unsigned char* src, PRUint32 srclen,\n  */\n \n PR_IMPLEMENT(char*)\n-PL_Base64Encode(const char* src, PRUint32 srclen, char* dest)\n-{\n-    if (0 == srclen) {\n-        size_t len = strlen(src);\n-        srclen = len;\n-        /* Detect truncation. */\n-        if (srclen != len) {\n-            return (char*)0;\n-        }\n+PL_Base64Encode(const char* src, PRUint32 srclen, char* dest) {\n+  if (0 == srclen) {\n+    size_t len = strlen(src);\n+    srclen = len;\n+    /* Detect truncation. */\n+    if (srclen != len) {\n+      return (char*)0;\n     }\n+  }\n \n+  if ((char*)0 == dest) {\n+    PRUint32 destlen;\n+    /* Ensure all PRUint32 values stay within range. */\n+    if (srclen > (PR_UINT32_MAX / 4) * 3) {\n+      return (char*)0;\n+    }\n+    destlen = ((srclen + 2) / 3) * 4;\n+    dest = (char*)PR_MALLOC(destlen + 1);\n     if ((char*)0 == dest) {\n-        PRUint32 destlen;\n-        /* Ensure all PRUint32 values stay within range. */\n-        if (srclen > (PR_UINT32_MAX / 4) * 3) {\n-            return (char*)0;\n-        }\n-        destlen = ((srclen + 2) / 3) * 4;\n-        dest = (char*)PR_MALLOC(destlen + 1);\n-        if ((char*)0 == dest) {\n-            return (char*)0;\n-        }\n-        dest[destlen] = (char)0; /* null terminate */\n+      return (char*)0;\n     }\n+    dest[destlen] = (char)0; /* null terminate */\n+  }\n \n-    encode((const unsigned char*)src, srclen, (unsigned char*)dest);\n-    return dest;\n+  encode((const unsigned char*)src, srclen, (unsigned char*)dest);\n+  return dest;\n }\n \n-static PRInt32\n-codetovalue(unsigned char c)\n-{\n-    if ((c >= (unsigned char)'A') && (c <= (unsigned char)'Z')) {\n-        return (PRInt32)(c - (unsigned char)'A');\n-    } else if ((c >= (unsigned char)'a') && (c <= (unsigned char)'z')) {\n-        return ((PRInt32)(c - (unsigned char)'a') + 26);\n-    } else if ((c >= (unsigned char)'0') && (c <= (unsigned char)'9')) {\n-        return ((PRInt32)(c - (unsigned char)'0') + 52);\n-    } else if ((unsigned char)'+' == c) {\n-        return (PRInt32)62;\n-    } else if ((unsigned char)'/' == c) {\n-        return (PRInt32)63;\n-    } else {\n-        return -1;\n-    }\n+static PRInt32 codetovalue(unsigned char c) {\n+  if ((c >= (unsigned char)'A') && (c <= (unsigned char)'Z')) {\n+    return (PRInt32)(c - (unsigned char)'A');\n+  } else if ((c >= (unsigned char)'a') && (c <= (unsigned char)'z')) {\n+    return ((PRInt32)(c - (unsigned char)'a') + 26);\n+  } else if ((c >= (unsigned char)'0') && (c <= (unsigned char)'9')) {\n+    return ((PRInt32)(c - (unsigned char)'0') + 52);\n+  } else if ((unsigned char)'+' == c) {\n+    return (PRInt32)62;\n+  } else if ((unsigned char)'/' == c) {\n+    return (PRInt32)63;\n+  } else {\n+    return -1;\n+  }\n }\n \n-static PRStatus\n-decode4to3(const unsigned char* src, unsigned char* dest)\n-{\n-    PRUint32 b32 = (PRUint32)0;\n-    PRInt32 bits;\n-    PRIntn i;\n-\n-    for (i = 0; i < 4; i++) {\n-        bits = codetovalue(src[i]);\n-        if (bits < 0) {\n-            return PR_FAILURE;\n-        }\n-\n-        b32 <<= 6;\n-        b32 |= bits;\n+static PRStatus decode4to3(const unsigned char* src, unsigned char* dest) {\n+  PRUint32 b32 = (PRUint32)0;\n+  PRInt32 bits;\n+  PRIntn i;\n+\n+  for (i = 0; i < 4; i++) {\n+    bits = codetovalue(src[i]);\n+    if (bits < 0) {\n+      return PR_FAILURE;\n     }\n \n-    dest[0] = (unsigned char)((b32 >> 16) & 0xFF);\n-    dest[1] = (unsigned char)((b32 >> 8) & 0xFF);\n-    dest[2] = (unsigned char)((b32) & 0xFF);\n+    b32 <<= 6;\n+    b32 |= bits;\n+  }\n+\n+  dest[0] = (unsigned char)((b32 >> 16) & 0xFF);\n+  dest[1] = (unsigned char)((b32 >> 8) & 0xFF);\n+  dest[2] = (unsigned char)((b32) & 0xFF);\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n }\n \n-static PRStatus\n-decode3to2(const unsigned char* src, unsigned char* dest)\n-{\n-    PRUint32 b32 = (PRUint32)0;\n-    PRInt32 bits;\n-    PRUint32 ubits;\n+static PRStatus decode3to2(const unsigned char* src, unsigned char* dest) {\n+  PRUint32 b32 = (PRUint32)0;\n+  PRInt32 bits;\n+  PRUint32 ubits;\n \n-    bits = codetovalue(src[0]);\n-    if (bits < 0) {\n-        return PR_FAILURE;\n-    }\n+  bits = codetovalue(src[0]);\n+  if (bits < 0) {\n+    return PR_FAILURE;\n+  }\n \n-    b32 = (PRUint32)bits;\n-    b32 <<= 6;\n+  b32 = (PRUint32)bits;\n+  b32 <<= 6;\n \n-    bits = codetovalue(src[1]);\n-    if (bits < 0) {\n-        return PR_FAILURE;\n-    }\n+  bits = codetovalue(src[1]);\n+  if (bits < 0) {\n+    return PR_FAILURE;\n+  }\n \n-    b32 |= (PRUint32)bits;\n-    b32 <<= 4;\n+  b32 |= (PRUint32)bits;\n+  b32 <<= 4;\n \n-    bits = codetovalue(src[2]);\n-    if (bits < 0) {\n-        return PR_FAILURE;\n-    }\n+  bits = codetovalue(src[2]);\n+  if (bits < 0) {\n+    return PR_FAILURE;\n+  }\n \n-    ubits = (PRUint32)bits;\n-    b32 |= (ubits >> 2);\n+  ubits = (PRUint32)bits;\n+  b32 |= (ubits >> 2);\n \n-    dest[0] = (unsigned char)((b32 >> 8) & 0xFF);\n-    dest[1] = (unsigned char)((b32) & 0xFF);\n+  dest[0] = (unsigned char)((b32 >> 8) & 0xFF);\n+  dest[1] = (unsigned char)((b32) & 0xFF);\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n }\n \n-static PRStatus\n-decode2to1(const unsigned char* src, unsigned char* dest)\n-{\n-    PRUint32 b32;\n-    PRUint32 ubits;\n-    PRInt32 bits;\n+static PRStatus decode2to1(const unsigned char* src, unsigned char* dest) {\n+  PRUint32 b32;\n+  PRUint32 ubits;\n+  PRInt32 bits;\n \n-    bits = codetovalue(src[0]);\n-    if (bits < 0) {\n-        return PR_FAILURE;\n-    }\n+  bits = codetovalue(src[0]);\n+  if (bits < 0) {\n+    return PR_FAILURE;\n+  }\n \n-    ubits = (PRUint32)bits;\n-    b32 = (ubits << 2);\n+  ubits = (PRUint32)bits;\n+  b32 = (ubits << 2);\n \n-    bits = codetovalue(src[1]);\n-    if (bits < 0) {\n-        return PR_FAILURE;\n-    }\n+  bits = codetovalue(src[1]);\n+  if (bits < 0) {\n+    return PR_FAILURE;\n+  }\n \n-    ubits = (PRUint32)bits;\n-    b32 |= (ubits >> 4);\n+  ubits = (PRUint32)bits;\n+  b32 |= (ubits >> 4);\n \n-    dest[0] = (unsigned char)b32;\n+  dest[0] = (unsigned char)b32;\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n }\n \n-static PRStatus\n-decode(const unsigned char* src, PRUint32 srclen,\n-       unsigned char* dest)\n-{\n-    PRStatus rv;\n-\n-    while (srclen >= 4) {\n-        rv = decode4to3(src, dest);\n-        if (PR_SUCCESS != rv) {\n-            return PR_FAILURE;\n-        }\n-\n-        src += 4;\n-        dest += 3;\n-        srclen -= 4;\n-    }\n+static PRStatus decode(const unsigned char* src, PRUint32 srclen,\n+                       unsigned char* dest) {\n+  PRStatus rv;\n \n-    switch (srclen) {\n-        case 3:\n-            rv = decode3to2(src, dest);\n-            break;\n-        case 2:\n-            rv = decode2to1(src, dest);\n-            break;\n-        case 1:\n-            rv = PR_FAILURE;\n-            break;\n-        case 0:\n-            rv = PR_SUCCESS;\n-            break;\n-        default:\n-            PR_NOT_REACHED(\"coding error\");\n+  while (srclen >= 4) {\n+    rv = decode4to3(src, dest);\n+    if (PR_SUCCESS != rv) {\n+      return PR_FAILURE;\n     }\n \n-    return rv;\n+    src += 4;\n+    dest += 3;\n+    srclen -= 4;\n+  }\n+\n+  switch (srclen) {\n+    case 3:\n+      rv = decode3to2(src, dest);\n+      break;\n+    case 2:\n+      rv = decode2to1(src, dest);\n+      break;\n+    case 1:\n+      rv = PR_FAILURE;\n+      break;\n+    case 0:\n+      rv = PR_SUCCESS;\n+      break;\n+    default:\n+      PR_NOT_REACHED(\"coding error\");\n+  }\n+\n+  return rv;\n }\n \n /*\n@@ -276,53 +258,52 @@ decode(const unsigned char* src, PRUint32 srclen,\n  */\n \n PR_IMPLEMENT(char*)\n-PL_Base64Decode(const char* src, PRUint32 srclen, char* dest)\n-{\n-    PRStatus status;\n-    PRBool allocated = PR_FALSE;\n-\n-    if ((char*)0 == src) {\n-        return (char*)0;\n-    }\n-\n-    if (0 == srclen) {\n-        size_t len = strlen(src);\n-        srclen = len;\n-        /* Detect truncation. */\n-        if (srclen != len) {\n-            return (char*)0;\n-        }\n+PL_Base64Decode(const char* src, PRUint32 srclen, char* dest) {\n+  PRStatus status;\n+  PRBool allocated = PR_FALSE;\n+\n+  if ((char*)0 == src) {\n+    return (char*)0;\n+  }\n+\n+  if (0 == srclen) {\n+    size_t len = strlen(src);\n+    srclen = len;\n+    /* Detect truncation. */\n+    if (srclen != len) {\n+      return (char*)0;\n     }\n-\n-    if (srclen && (0 == (srclen & 3))) {\n-        if ((char)'=' == src[srclen - 1]) {\n-            if ((char)'=' == src[srclen - 2]) {\n-                srclen -= 2;\n-            } else {\n-                srclen -= 1;\n-            }\n-        }\n+  }\n+\n+  if (srclen && (0 == (srclen & 3))) {\n+    if ((char)'=' == src[srclen - 1]) {\n+      if ((char)'=' == src[srclen - 2]) {\n+        srclen -= 2;\n+      } else {\n+        srclen -= 1;\n+      }\n     }\n+  }\n \n+  if ((char*)0 == dest) {\n+    /* The following computes ((srclen * 3) / 4) without overflow. */\n+    PRUint32 destlen = (srclen / 4) * 3 + ((srclen % 4) * 3) / 4;\n+    dest = (char*)PR_MALLOC(destlen + 1);\n     if ((char*)0 == dest) {\n-        /* The following computes ((srclen * 3) / 4) without overflow. */\n-        PRUint32 destlen = (srclen / 4) * 3 + ((srclen % 4) * 3) / 4;\n-        dest = (char*)PR_MALLOC(destlen + 1);\n-        if ((char*)0 == dest) {\n-            return (char*)0;\n-        }\n-        dest[destlen] = (char)0; /* null terminate */\n-        allocated = PR_TRUE;\n+      return (char*)0;\n     }\n-\n-    status = decode((const unsigned char*)src, srclen, (unsigned char*)dest);\n-    if (PR_SUCCESS != status) {\n-        if (PR_TRUE == allocated) {\n-            PR_DELETE(dest);\n-        }\n-\n-        return (char*)0;\n+    dest[destlen] = (char)0; /* null terminate */\n+    allocated = PR_TRUE;\n+  }\n+\n+  status = decode((const unsigned char*)src, srclen, (unsigned char*)dest);\n+  if (PR_SUCCESS != status) {\n+    if (PR_TRUE == allocated) {\n+      PR_DELETE(dest);\n     }\n \n-    return dest;\n+    return (char*)0;\n+  }\n+\n+  return dest;\n }\ndiff --git a/nspr/lib/libc/src/plc.rc b/nspr/lib/libc/src/plc.rc\nindex fa11440..6e2279f 100644\n--- a/nspr/lib/libc/src/plc.rc\n+++ b/nspr/lib/libc/src/plc.rc\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/lib/libc/src/plerror.c b/nspr/lib/libc/src/plerror.c\nindex 388334c..1ffee17 100644\n--- a/nspr/lib/libc/src/plerror.c\n+++ b/nspr/lib/libc/src/plerror.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -13,30 +14,26 @@\n #include \"prprf.h\"\n #include \"prerror.h\"\n \n-PR_IMPLEMENT(void)\n-PL_FPrintError(PRFileDesc* fd, const char* msg)\n-{\n-    PRErrorCode error = PR_GetError();\n-    PRInt32 oserror = PR_GetOSError();\n-    const char* name = PR_ErrorToName(error);\n+PR_IMPLEMENT(void) PL_FPrintError(PRFileDesc* fd, const char* msg) {\n+  PRErrorCode error = PR_GetError();\n+  PRInt32 oserror = PR_GetOSError();\n+  const char* name = PR_ErrorToName(error);\n \n-    if (NULL != msg) {\n-        PR_fprintf(fd, \"%s: \", msg);\n-    }\n-    if (NULL == name)\n-        PR_fprintf(fd, \" (%d)OUT OF RANGE, oserror = %d\\n\", error, oserror);\n-    else\n-        PR_fprintf(fd, \"%s(%d), oserror = %d\\n\", name, error, oserror);\n+  if (NULL != msg) {\n+    PR_fprintf(fd, \"%s: \", msg);\n+  }\n+  if (NULL == name)\n+    PR_fprintf(fd, \" (%d)OUT OF RANGE, oserror = %d\\n\", error, oserror);\n+  else\n+    PR_fprintf(fd, \"%s(%d), oserror = %d\\n\", name, error, oserror);\n } /* PL_FPrintError */\n \n-PR_IMPLEMENT(void)\n-PL_PrintError(const char* msg)\n-{\n-    static PRFileDesc* fd = NULL;\n-    if (NULL == fd) {\n-        fd = PR_GetSpecialFD(PR_StandardError);\n-    }\n-    PL_FPrintError(fd, msg);\n+PR_IMPLEMENT(void) PL_PrintError(const char* msg) {\n+  static PRFileDesc* fd = NULL;\n+  if (NULL == fd) {\n+    fd = PR_GetSpecialFD(PR_StandardError);\n+  }\n+  PL_FPrintError(fd, msg);\n } /* PL_PrintError */\n \n /* plerror.c */\ndiff --git a/nspr/lib/libc/src/plgetopt.c b/nspr/lib/libc/src/plgetopt.c\nindex 7c61ceb..94b57c2 100644\n--- a/nspr/lib/libc/src/plgetopt.c\n+++ b/nspr/lib/libc/src/plgetopt.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -18,15 +19,15 @@\n static char static_Nul = 0;\n \n struct PLOptionInternal {\n-    const char* options;       /* client options list specification */\n-    PRIntn argc;               /* original number of arguments */\n-    char** argv;               /* vector of pointers to arguments */\n-    PRIntn xargc;              /* which one we're processing now */\n-    const char* xargv;         /* where within *argv[xargc] */\n-    PRIntn minus;              /* do we already have the '-'? */\n-    const PLLongOpt* longOpts; /* Caller's array */\n-    PRBool endOfOpts;          /* have reached a \"--\" argument */\n-    PRIntn optionsLen;         /* is strlen(options) */\n+  const char* options;       /* client options list specification */\n+  PRIntn argc;               /* original number of arguments */\n+  char** argv;               /* vector of pointers to arguments */\n+  PRIntn xargc;              /* which one we're processing now */\n+  const char* xargv;         /* where within *argv[xargc] */\n+  PRIntn minus;              /* do we already have the '-'? */\n+  const PLLongOpt* longOpts; /* Caller's array */\n+  PRBool endOfOpts;          /* have reached a \"--\" argument */\n+  PRIntn optionsLen;         /* is strlen(options) */\n };\n \n /*\n@@ -37,192 +38,186 @@ struct PLOptionInternal {\n ** options    vector of single character options w/ | w/o ':\n */\n PR_IMPLEMENT(PLOptState*)\n-PL_CreateOptState(PRIntn argc, char** argv, const char* options)\n-{\n-    return PL_CreateLongOptState(argc, argv, options, NULL);\n+PL_CreateOptState(PRIntn argc, char** argv, const char* options) {\n+  return PL_CreateLongOptState(argc, argv, options, NULL);\n } /* PL_CreateOptState */\n \n PR_IMPLEMENT(PLOptState*)\n PL_CreateLongOptState(PRIntn argc, char** argv, const char* options,\n-                      const PLLongOpt* longOpts)\n-{\n-    PLOptState* opt = NULL;\n-    PLOptionInternal* internal;\n-\n-    if (NULL == options) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return opt;\n-    }\n-\n-    opt = PR_NEWZAP(PLOptState);\n-    if (NULL == opt) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return opt;\n-    }\n+                      const PLLongOpt* longOpts) {\n+  PLOptState* opt = NULL;\n+  PLOptionInternal* internal;\n \n-    internal = PR_NEW(PLOptionInternal);\n-    if (NULL == internal) {\n-        PR_DELETE(opt);\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n-    }\n-\n-    opt->option = 0;\n-    opt->value = NULL;\n-    opt->internal = internal;\n-    opt->longOption = 0;\n-    opt->longOptIndex = -1;\n-\n-    internal->argc = argc;\n-    internal->argv = argv;\n-    internal->xargc = 0;\n-    internal->xargv = &static_Nul;\n-    internal->minus = 0;\n-    internal->options = options;\n-    internal->longOpts = longOpts;\n-    internal->endOfOpts = PR_FALSE;\n-    internal->optionsLen = PL_strlen(options);\n+  if (NULL == options) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return opt;\n+  }\n \n+  opt = PR_NEWZAP(PLOptState);\n+  if (NULL == opt) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n     return opt;\n+  }\n+\n+  internal = PR_NEW(PLOptionInternal);\n+  if (NULL == internal) {\n+    PR_DELETE(opt);\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n+\n+  opt->option = 0;\n+  opt->value = NULL;\n+  opt->internal = internal;\n+  opt->longOption = 0;\n+  opt->longOptIndex = -1;\n+\n+  internal->argc = argc;\n+  internal->argv = argv;\n+  internal->xargc = 0;\n+  internal->xargv = &static_Nul;\n+  internal->minus = 0;\n+  internal->options = options;\n+  internal->longOpts = longOpts;\n+  internal->endOfOpts = PR_FALSE;\n+  internal->optionsLen = PL_strlen(options);\n+\n+  return opt;\n } /* PL_CreateLongOptState */\n \n /*\n ** Destroy object created by CreateOptState()\n */\n-PR_IMPLEMENT(void)\n-PL_DestroyOptState(PLOptState* opt)\n-{\n-    PR_DELETE(opt->internal);\n-    PR_DELETE(opt);\n+PR_IMPLEMENT(void) PL_DestroyOptState(PLOptState* opt) {\n+  PR_DELETE(opt->internal);\n+  PR_DELETE(opt);\n } /* PL_DestroyOptState */\n \n-PR_IMPLEMENT(PLOptStatus)\n-PL_GetNextOpt(PLOptState* opt)\n-{\n-    PLOptionInternal* internal = opt->internal;\n-\n-    opt->longOption = 0;\n-    opt->longOptIndex = -1;\n-    /*\n-    ** If the current xarg points to nul, advance to the next\n-    ** element of the argv vector. If the vector index is equal\n-    ** to argc, we're out of arguments, so return an EOL.\n-    ** Note whether the first character of the new argument is\n-    ** a '-' and skip by it if it is.\n-    */\n-    while (0 == *internal->xargv) {\n-        internal->xargc += 1;\n-        if (internal->xargc >= internal->argc) {\n-            opt->option = 0;\n-            opt->value = NULL;\n-            return PL_OPT_EOL;\n-        }\n-        internal->xargv = internal->argv[internal->xargc];\n-        internal->minus = 0;\n-        if (!internal->endOfOpts && ('-' == *internal->xargv)) {\n-            internal->minus++;\n-            internal->xargv++; /* and consume */\n-            if ('-' == *internal->xargv && internal->longOpts) {\n-                internal->minus++;\n-                internal->xargv++;\n-                if (0 == *internal->xargv) {\n-                    internal->endOfOpts = PR_TRUE;\n-                }\n-            }\n+PR_IMPLEMENT(PLOptStatus) PL_GetNextOpt(PLOptState* opt) {\n+  PLOptionInternal* internal = opt->internal;\n+\n+  opt->longOption = 0;\n+  opt->longOptIndex = -1;\n+  /*\n+  ** If the current xarg points to nul, advance to the next\n+  ** element of the argv vector. If the vector index is equal\n+  ** to argc, we're out of arguments, so return an EOL.\n+  ** Note whether the first character of the new argument is\n+  ** a '-' and skip by it if it is.\n+  */\n+  while (0 == *internal->xargv) {\n+    internal->xargc += 1;\n+    if (internal->xargc >= internal->argc) {\n+      opt->option = 0;\n+      opt->value = NULL;\n+      return PL_OPT_EOL;\n+    }\n+    internal->xargv = internal->argv[internal->xargc];\n+    internal->minus = 0;\n+    if (!internal->endOfOpts && ('-' == *internal->xargv)) {\n+      internal->minus++;\n+      internal->xargv++; /* and consume */\n+      if ('-' == *internal->xargv && internal->longOpts) {\n+        internal->minus++;\n+        internal->xargv++;\n+        if (0 == *internal->xargv) {\n+          internal->endOfOpts = PR_TRUE;\n         }\n+      }\n     }\n+  }\n+\n+  /*\n+  ** If we already have a '-' or '--' in hand, xargv points to the next\n+  ** option. See if we can find a match in the list of possible\n+  ** options supplied.\n+  */\n+  if (internal->minus == 2) {\n+    char* foundEqual = strchr(internal->xargv, '=');\n+    PRIntn optNameLen =\n+        foundEqual ? (foundEqual - internal->xargv) : strlen(internal->xargv);\n+    const PLLongOpt* longOpt = internal->longOpts;\n+    PLOptStatus result = PL_OPT_BAD;\n+\n+    opt->option = 0;\n+    opt->value = NULL;\n \n-    /*\n-    ** If we already have a '-' or '--' in hand, xargv points to the next\n-    ** option. See if we can find a match in the list of possible\n-    ** options supplied.\n-    */\n-    if (internal->minus == 2) {\n-        char* foundEqual = strchr(internal->xargv, '=');\n-        PRIntn optNameLen =\n-            foundEqual ? (foundEqual - internal->xargv) : strlen(internal->xargv);\n-        const PLLongOpt* longOpt = internal->longOpts;\n-        PLOptStatus result = PL_OPT_BAD;\n-\n-        opt->option = 0;\n-        opt->value = NULL;\n-\n-        for (; longOpt->longOptName; ++longOpt) {\n-            if (strncmp(longOpt->longOptName, internal->xargv, optNameLen)) {\n-                continue; /* not a possible match */\n-            }\n-            if (strlen(longOpt->longOptName) != optNameLen) {\n-                continue; /* not a match */\n-            }\n-            /* option name match */\n-            opt->longOptIndex = longOpt - internal->longOpts;\n-            opt->longOption = longOpt->longOption;\n-            /* value is part of the current argv[] element if = was found */\n-            /* note: this sets value even for long options that do not\n-             * require option if specified as --long=value */\n-            if (foundEqual) {\n-                opt->value = foundEqual + 1;\n-            } else if (longOpt->valueRequired) {\n-                /* value is the next argv[] element, if any */\n-                if (internal->xargc + 1 < internal->argc) {\n-                    opt->value = internal->argv[++(internal->xargc)];\n-                }\n-                /* missing value */\n-                else {\n-                    break; /* return PL_OPT_BAD */\n-                }\n-            }\n-            result = PL_OPT_OK;\n-            break;\n+    for (; longOpt->longOptName; ++longOpt) {\n+      if (strncmp(longOpt->longOptName, internal->xargv, optNameLen)) {\n+        continue; /* not a possible match */\n+      }\n+      if (strlen(longOpt->longOptName) != optNameLen) {\n+        continue; /* not a match */\n+      }\n+      /* option name match */\n+      opt->longOptIndex = longOpt - internal->longOpts;\n+      opt->longOption = longOpt->longOption;\n+      /* value is part of the current argv[] element if = was found */\n+      /* note: this sets value even for long options that do not\n+       * require option if specified as --long=value */\n+      if (foundEqual) {\n+        opt->value = foundEqual + 1;\n+      } else if (longOpt->valueRequired) {\n+        /* value is the next argv[] element, if any */\n+        if (internal->xargc + 1 < internal->argc) {\n+          opt->value = internal->argv[++(internal->xargc)];\n+        }\n+        /* missing value */\n+        else {\n+          break; /* return PL_OPT_BAD */\n         }\n-        internal->xargv = &static_Nul; /* consume this */\n-        return result;\n+      }\n+      result = PL_OPT_OK;\n+      break;\n     }\n-    if (internal->minus) {\n-        PRIntn cop;\n-        PRIntn eoo = internal->optionsLen;\n-        for (cop = 0; cop < eoo; ++cop) {\n-            if (internal->options[cop] == *internal->xargv) {\n-                opt->option = *internal->xargv++;\n-                opt->longOption = opt->option & 0xff;\n-                /*\n-                ** if options indicates that there's an associated\n-                ** value, it must be provided, either as part of this\n-                ** argv[] element or as the next one\n-                */\n-                if (':' == internal->options[cop + 1]) {\n-                    /* value is part of the current argv[] element */\n-                    if (0 != *internal->xargv) {\n-                        opt->value = internal->xargv;\n-                    }\n-                    /* value is the next argv[] element, if any */\n-                    else if (internal->xargc + 1 < internal->argc) {\n-                        opt->value = internal->argv[++(internal->xargc)];\n-                    }\n-                    /* missing value */\n-                    else {\n-                        return PL_OPT_BAD;\n-                    }\n-\n-                    internal->xargv = &static_Nul;\n-                    internal->minus = 0;\n-                } else {\n-                    opt->value = NULL;\n-                }\n-                return PL_OPT_OK;\n-            }\n+    internal->xargv = &static_Nul; /* consume this */\n+    return result;\n+  }\n+  if (internal->minus) {\n+    PRIntn cop;\n+    PRIntn eoo = internal->optionsLen;\n+    for (cop = 0; cop < eoo; ++cop) {\n+      if (internal->options[cop] == *internal->xargv) {\n+        opt->option = *internal->xargv++;\n+        opt->longOption = opt->option & 0xff;\n+        /*\n+        ** if options indicates that there's an associated\n+        ** value, it must be provided, either as part of this\n+        ** argv[] element or as the next one\n+        */\n+        if (':' == internal->options[cop + 1]) {\n+          /* value is part of the current argv[] element */\n+          if (0 != *internal->xargv) {\n+            opt->value = internal->xargv;\n+          }\n+          /* value is the next argv[] element, if any */\n+          else if (internal->xargc + 1 < internal->argc) {\n+            opt->value = internal->argv[++(internal->xargc)];\n+          }\n+          /* missing value */\n+          else {\n+            return PL_OPT_BAD;\n+          }\n+\n+          internal->xargv = &static_Nul;\n+          internal->minus = 0;\n+        } else {\n+          opt->value = NULL;\n         }\n-        internal->xargv += 1; /* consume that option */\n-        return PL_OPT_BAD;\n+        return PL_OPT_OK;\n+      }\n     }\n-\n-    /*\n-    ** No '-', so it must be a standalone value. The option is nul.\n-    */\n-    opt->value = internal->argv[internal->xargc];\n-    internal->xargv = &static_Nul;\n-    opt->option = 0;\n-    return PL_OPT_OK;\n+    internal->xargv += 1; /* consume that option */\n+    return PL_OPT_BAD;\n+  }\n+\n+  /*\n+  ** No '-', so it must be a standalone value. The option is nul.\n+  */\n+  opt->value = internal->argv[internal->xargc];\n+  internal->xargv = &static_Nul;\n+  opt->option = 0;\n+  return PL_OPT_OK;\n } /* PL_GetNextOpt */\n \n /* plgetopt.c */\ndiff --git a/nspr/lib/libc/src/plvrsion.c b/nspr/lib/libc/src/plvrsion.c\nindex 8ccfacf..240c6eb 100644\n--- a/nspr/lib/libc/src/plvrsion.c\n+++ b/nspr/lib/libc/src/plvrsion.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,22 +11,22 @@\n /************************************************************************/\n #include \"_pl_bld.h\"\n #if !defined(_BUILD_TIME)\n-#ifdef HAVE_LONG_LONG\n-#define _BUILD_TIME 0\n-#else\n-#define _BUILD_TIME { 0, 0 }\n-#endif\n+#  ifdef HAVE_LONG_LONG\n+#    define _BUILD_TIME 0\n+#  else\n+#    define _BUILD_TIME {0, 0}\n+#  endif\n #endif\n #if !defined(_BUILD_STRING)\n-#define _BUILD_STRING \"\"\n+#  define _BUILD_STRING \"\"\n #endif\n #if !defined(_PRODUCTION)\n-#define _PRODUCTION \"\"\n+#  define _PRODUCTION \"\"\n #endif\n #if defined(DEBUG)\n-#define _DEBUG_STRING \" (debug)\"\n+#  define _DEBUG_STRING \" (debug)\"\n #else\n-#define _DEBUG_STRING \"\"\n+#  define _DEBUG_STRING \"\"\n #endif\n \n /*\n@@ -36,8 +37,8 @@\n #define VERSION_DESC_NAME CONCAT2(prVersionDescription_libplc, PR_VMAJOR)\n \n PRVersionDescription VERSION_DESC_NAME = {\n-    /* version          */ 2,             /* this is the only one supported */\n-    /* buildTime        */ _BUILD_TIME,   /* usecs since midnight 1/1/1970 GMT */\n+    /* version          */ 2,           /* this is the only one supported */\n+    /* buildTime        */ _BUILD_TIME, /* usecs since midnight 1/1/1970 GMT */\n     /* buildTimeString  */ _BUILD_STRING, /*    ditto, but human readable */\n     /* vMajor           */ PR_VMAJOR,     /* NSPR's version number */\n     /* vMinor           */ PR_VMINOR,     /*  and minor version */\n@@ -48,8 +49,8 @@ PRVersionDescription VERSION_DESC_NAME = {\n #else\n     /* debug            */ PR_FALSE, /* an optomized build */\n #endif\n-    /* special          */ PR_FALSE,           /* they're all special, but ... */\n-    /* filename         */ _PRODUCTION,        /* the produced library name */\n+    /* special          */ PR_FALSE,    /* they're all special, but ... */\n+    /* filename         */ _PRODUCTION, /* the produced library name */\n     /* description      */ \"Portable runtime\", /* what we are */\n     /* security         */ \"N/A\",              /* not applicable here */\n                                                /* copywrite        */\n@@ -57,8 +58,7 @@ PRVersionDescription VERSION_DESC_NAME = {\n     \"License, v. 2.0. If a copy of the MPL was not distributed with this file, \"\n     \"You can obtain one at http://mozilla.org/MPL/2.0/.\",\n     /* comment          */ \"http://www.mozilla.org/MPL/\",\n-    /* specialString    */ \"\"\n-};\n+    /* specialString    */ \"\"};\n \n #ifdef XP_UNIX\n \n@@ -75,26 +75,24 @@ static char sccsid[] = \"@(#)NSPR \" PR_VERSION _DEBUG_STRING \"  \" _BUILD_STRING;\n #endif /* XP_UNIX */\n \n #ifdef _PR_HAS_PRAGMA_DIAGNOSTIC\n-#pragma GCC diagnostic push\n-#pragma GCC diagnostic ignored \"-Wunused-but-set-variable\"\n+#  pragma GCC diagnostic push\n+#  pragma GCC diagnostic ignored \"-Wunused-but-set-variable\"\n #endif\n-PR_IMPLEMENT(const PRVersionDescription*)\n-libVersionPoint()\n-{\n+PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint() {\n #ifdef XP_UNIX\n-    /*\n-     * Add dummy references to rcsid and sccsid to prevent them\n-     * from being optimized away as unused variables.\n-     */\n-    const char* dummy;\n+  /*\n+   * Add dummy references to rcsid and sccsid to prevent them\n+   * from being optimized away as unused variables.\n+   */\n+  const char* dummy;\n \n-    dummy = rcsid;\n-    dummy = sccsid;\n+  dummy = rcsid;\n+  dummy = sccsid;\n #endif\n-    return &VERSION_DESC_NAME;\n+  return &VERSION_DESC_NAME;\n } /* versionEntryPointType */\n #ifdef _PR_HAS_PRAGMA_DIAGNOSTIC\n-#pragma GCC diagnostic pop\n+#  pragma GCC diagnostic pop\n #endif\n \n /* plvrsion.c */\ndiff --git a/nspr/lib/libc/src/strcase.c b/nspr/lib/libc/src/strcase.c\nindex 16366f5..520d230 100644\n--- a/nspr/lib/libc/src/strcase.c\n+++ b/nspr/lib/libc/src/strcase.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,187 +10,179 @@ static const unsigned char uc[] = {\n     '\\000', '\\001', '\\002', '\\003', '\\004', '\\005', '\\006', '\\007', '\\010',\n     '\\011', '\\012', '\\013', '\\014', '\\015', '\\016', '\\017', '\\020', '\\021',\n     '\\022', '\\023', '\\024', '\\025', '\\026', '\\027', '\\030', '\\031', '\\032',\n-    '\\033', '\\034', '\\035', '\\036', '\\037', ' ', '!', '\"', '#',\n-    '$', '%', '&', '\\'', '(', ')', '*', '+', ',',\n-    '-', '.', '/', '0', '1', '2', '3', '4', '5',\n-    '6', '7', '8', '9', ':', ';', '<', '=', '>',\n-    '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',\n-    'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',\n-    'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',\n-    'Z', '[', '\\\\', ']', '^', '_', '`', 'A', 'B',\n-    'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',\n-    'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',\n-    'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}',\n-    '~', '\\177', 0200, 0201, 0202, 0203, 0204, 0205, 0206,\n-    0207, 0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217,\n-    0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, 0230,\n-    0231, 0232, 0233, 0234, 0235, 0236, 0237, 0240, 0241,\n-    0242, 0243, 0244, 0245, 0246, 0247, 0250, 0251, 0252,\n-    0253, 0254, 0255, 0256, 0257, 0260, 0261, 0262, 0263,\n-    0264, 0265, 0266, 0267, 0270, 0271, 0272, 0273, 0274,\n-    0275, 0276, 0277, 0300, 0301, 0302, 0303, 0304, 0305,\n-    0306, 0307, 0310, 0311, 0312, 0313, 0314, 0315, 0316,\n-    0317, 0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327,\n-    0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, 0340,\n-    0341, 0342, 0343, 0344, 0345, 0346, 0347, 0350, 0351,\n-    0352, 0353, 0354, 0355, 0356, 0357, 0360, 0361, 0362,\n-    0363, 0364, 0365, 0366, 0367, 0370, 0371, 0372, 0373,\n-    0374, 0375, 0376, 0377\n-};\n+    '\\033', '\\034', '\\035', '\\036', '\\037', ' ',    '!',    '\"',    '#',\n+    '$',    '%',    '&',    '\\'',   '(',    ')',    '*',    '+',    ',',\n+    '-',    '.',    '/',    '0',    '1',    '2',    '3',    '4',    '5',\n+    '6',    '7',    '8',    '9',    ':',    ';',    '<',    '=',    '>',\n+    '?',    '@',    'A',    'B',    'C',    'D',    'E',    'F',    'G',\n+    'H',    'I',    'J',    'K',    'L',    'M',    'N',    'O',    'P',\n+    'Q',    'R',    'S',    'T',    'U',    'V',    'W',    'X',    'Y',\n+    'Z',    '[',    '\\\\',   ']',    '^',    '_',    '`',    'A',    'B',\n+    'C',    'D',    'E',    'F',    'G',    'H',    'I',    'J',    'K',\n+    'L',    'M',    'N',    'O',    'P',    'Q',    'R',    'S',    'T',\n+    'U',    'V',    'W',    'X',    'Y',    'Z',    '{',    '|',    '}',\n+    '~',    '\\177', 0200,   0201,   0202,   0203,   0204,   0205,   0206,\n+    0207,   0210,   0211,   0212,   0213,   0214,   0215,   0216,   0217,\n+    0220,   0221,   0222,   0223,   0224,   0225,   0226,   0227,   0230,\n+    0231,   0232,   0233,   0234,   0235,   0236,   0237,   0240,   0241,\n+    0242,   0243,   0244,   0245,   0246,   0247,   0250,   0251,   0252,\n+    0253,   0254,   0255,   0256,   0257,   0260,   0261,   0262,   0263,\n+    0264,   0265,   0266,   0267,   0270,   0271,   0272,   0273,   0274,\n+    0275,   0276,   0277,   0300,   0301,   0302,   0303,   0304,   0305,\n+    0306,   0307,   0310,   0311,   0312,   0313,   0314,   0315,   0316,\n+    0317,   0320,   0321,   0322,   0323,   0324,   0325,   0326,   0327,\n+    0330,   0331,   0332,   0333,   0334,   0335,   0336,   0337,   0340,\n+    0341,   0342,   0343,   0344,   0345,   0346,   0347,   0350,   0351,\n+    0352,   0353,   0354,   0355,   0356,   0357,   0360,   0361,   0362,\n+    0363,   0364,   0365,   0366,   0367,   0370,   0371,   0372,   0373,\n+    0374,   0375,   0376,   0377};\n \n PR_IMPLEMENT(PRIntn)\n-PL_strcasecmp(const char* a, const char* b)\n-{\n-    const unsigned char* ua = (const unsigned char*)a;\n-    const unsigned char* ub = (const unsigned char*)b;\n-\n-    if ((const char*)0 == a) {\n-        return ((const char*)0 == b) ? 0 : -1;\n-    }\n-    if ((const char*)0 == b) {\n-        return 1;\n-    }\n-\n-    while ((uc[*ua] == uc[*ub]) && ('\\0' != *a)) {\n-        a++;\n-        ua++;\n-        ub++;\n-    }\n-\n-    return (PRIntn)(uc[*ua] - uc[*ub]);\n+PL_strcasecmp(const char* a, const char* b) {\n+  const unsigned char* ua = (const unsigned char*)a;\n+  const unsigned char* ub = (const unsigned char*)b;\n+\n+  if ((const char*)0 == a) {\n+    return ((const char*)0 == b) ? 0 : -1;\n+  }\n+  if ((const char*)0 == b) {\n+    return 1;\n+  }\n+\n+  while ((uc[*ua] == uc[*ub]) && ('\\0' != *a)) {\n+    a++;\n+    ua++;\n+    ub++;\n+  }\n+\n+  return (PRIntn)(uc[*ua] - uc[*ub]);\n }\n \n PR_IMPLEMENT(PRIntn)\n-PL_strncasecmp(const char* a, const char* b, PRUint32 max)\n-{\n-    const unsigned char* ua = (const unsigned char*)a;\n-    const unsigned char* ub = (const unsigned char*)b;\n-\n-    if ((const char*)0 == a) {\n-        return ((const char*)0 == b) ? 0 : -1;\n-    }\n-    if ((const char*)0 == b) {\n-        return 1;\n-    }\n-\n-    while (max && (uc[*ua] == uc[*ub]) && ('\\0' != *a)) {\n-        a++;\n-        ua++;\n-        ub++;\n-        max--;\n-    }\n-\n-    if (0 == max) {\n-        return (PRIntn)0;\n-    }\n-\n-    return (PRIntn)(uc[*ua] - uc[*ub]);\n+PL_strncasecmp(const char* a, const char* b, PRUint32 max) {\n+  const unsigned char* ua = (const unsigned char*)a;\n+  const unsigned char* ub = (const unsigned char*)b;\n+\n+  if ((const char*)0 == a) {\n+    return ((const char*)0 == b) ? 0 : -1;\n+  }\n+  if ((const char*)0 == b) {\n+    return 1;\n+  }\n+\n+  while (max && (uc[*ua] == uc[*ub]) && ('\\0' != *a)) {\n+    a++;\n+    ua++;\n+    ub++;\n+    max--;\n+  }\n+\n+  if (0 == max) {\n+    return (PRIntn)0;\n+  }\n+\n+  return (PRIntn)(uc[*ua] - uc[*ub]);\n }\n \n PR_IMPLEMENT(char*)\n-PL_strcasestr(const char* big, const char* little)\n-{\n-    PRUint32 ll;\n+PL_strcasestr(const char* big, const char* little) {\n+  PRUint32 ll;\n \n-    if (((const char*)0 == big) || ((const char*)0 == little)) {\n-        return (char*)0;\n-    }\n-    if (((char)0 == *big) || ((char)0 == *little)) {\n-        return (char*)0;\n-    }\n+  if (((const char*)0 == big) || ((const char*)0 == little)) {\n+    return (char*)0;\n+  }\n+  if (((char)0 == *big) || ((char)0 == *little)) {\n+    return (char*)0;\n+  }\n \n-    ll = strlen(little);\n+  ll = strlen(little);\n \n-    for (; *big; big++) /* obvious improvement available here */\n-        if (0 == PL_strncasecmp(big, little, ll)) {\n-            return (char*)big;\n-        }\n+  for (; *big; big++) /* obvious improvement available here */\n+    if (0 == PL_strncasecmp(big, little, ll)) {\n+      return (char*)big;\n+    }\n \n-    return (char*)0;\n+  return (char*)0;\n }\n \n PR_IMPLEMENT(char*)\n-PL_strcaserstr(const char* big, const char* little)\n-{\n-    const char* p;\n-    PRUint32 bl, ll;\n+PL_strcaserstr(const char* big, const char* little) {\n+  const char* p;\n+  PRUint32 bl, ll;\n \n-    if (((const char*)0 == big) || ((const char*)0 == little)) {\n-        return (char*)0;\n-    }\n-    if (((char)0 == *big) || ((char)0 == *little)) {\n-        return (char*)0;\n-    }\n+  if (((const char*)0 == big) || ((const char*)0 == little)) {\n+    return (char*)0;\n+  }\n+  if (((char)0 == *big) || ((char)0 == *little)) {\n+    return (char*)0;\n+  }\n \n-    bl = strlen(big);\n-    ll = strlen(little);\n-    if (bl < ll) {\n-        return (char*)0;\n-    }\n-    p = &big[bl - ll];\n+  bl = strlen(big);\n+  ll = strlen(little);\n+  if (bl < ll) {\n+    return (char*)0;\n+  }\n+  p = &big[bl - ll];\n \n-    for (; p >= big; p--) /* obvious improvement available here */\n-        if (0 == PL_strncasecmp(p, little, ll)) {\n-            return (char*)p;\n-        }\n+  for (; p >= big; p--) /* obvious improvement available here */\n+    if (0 == PL_strncasecmp(p, little, ll)) {\n+      return (char*)p;\n+    }\n \n-    return (char*)0;\n+  return (char*)0;\n }\n \n PR_IMPLEMENT(char*)\n-PL_strncasestr(const char* big, const char* little, PRUint32 max)\n-{\n-    PRUint32 ll;\n+PL_strncasestr(const char* big, const char* little, PRUint32 max) {\n+  PRUint32 ll;\n \n-    if (((const char*)0 == big) || ((const char*)0 == little)) {\n-        return (char*)0;\n-    }\n-    if (((char)0 == *big) || ((char)0 == *little)) {\n-        return (char*)0;\n-    }\n+  if (((const char*)0 == big) || ((const char*)0 == little)) {\n+    return (char*)0;\n+  }\n+  if (((char)0 == *big) || ((char)0 == *little)) {\n+    return (char*)0;\n+  }\n \n-    ll = strlen(little);\n-    if (ll > max) {\n-        return (char*)0;\n-    }\n-    max -= ll;\n-    max++;\n+  ll = strlen(little);\n+  if (ll > max) {\n+    return (char*)0;\n+  }\n+  max -= ll;\n+  max++;\n \n-    for (; max && *big; big++, max--) /* obvious improvement available here */\n-        if (0 == PL_strncasecmp(big, little, ll)) {\n-            return (char*)big;\n-        }\n+  for (; max && *big; big++, max--) /* obvious improvement available here */\n+    if (0 == PL_strncasecmp(big, little, ll)) {\n+      return (char*)big;\n+    }\n \n-    return (char*)0;\n+  return (char*)0;\n }\n \n PR_IMPLEMENT(char*)\n-PL_strncaserstr(const char* big, const char* little, PRUint32 max)\n-{\n-    const char* p;\n-    PRUint32 ll;\n+PL_strncaserstr(const char* big, const char* little, PRUint32 max) {\n+  const char* p;\n+  PRUint32 ll;\n \n-    if (((const char*)0 == big) || ((const char*)0 == little)) {\n-        return (char*)0;\n-    }\n-    if (((char)0 == *big) || ((char)0 == *little)) {\n-        return (char*)0;\n-    }\n+  if (((const char*)0 == big) || ((const char*)0 == little)) {\n+    return (char*)0;\n+  }\n+  if (((char)0 == *big) || ((char)0 == *little)) {\n+    return (char*)0;\n+  }\n \n-    ll = strlen(little);\n+  ll = strlen(little);\n \n-    for (p = big; max && *p; p++, max--)\n-        ;\n+  for (p = big; max && *p; p++, max--);\n \n-    p -= ll;\n-    if (p < big) {\n-        return (char*)0;\n-    }\n+  p -= ll;\n+  if (p < big) {\n+    return (char*)0;\n+  }\n \n-    for (; p >= big; p--) /* obvious improvement available here */\n-        if (0 == PL_strncasecmp(p, little, ll)) {\n-            return (char*)p;\n-        }\n+  for (; p >= big; p--) /* obvious improvement available here */\n+    if (0 == PL_strncasecmp(p, little, ll)) {\n+      return (char*)p;\n+    }\n \n-    return (char*)0;\n+  return (char*)0;\n }\ndiff --git a/nspr/lib/libc/src/strcat.c b/nspr/lib/libc/src/strcat.c\nindex ecf30be..40a1b95 100644\n--- a/nspr/lib/libc/src/strcat.c\n+++ b/nspr/lib/libc/src/strcat.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,48 +7,43 @@\n #include <string.h>\n \n PR_IMPLEMENT(char*)\n-PL_strcat(char* dest, const char* src)\n-{\n-    if (((char*)0 == dest) || ((const char*)0 == src)) {\n-        return dest;\n-    }\n+PL_strcat(char* dest, const char* src) {\n+  if (((char*)0 == dest) || ((const char*)0 == src)) {\n+    return dest;\n+  }\n \n-    return strcat(dest, src);\n+  return strcat(dest, src);\n }\n \n PR_IMPLEMENT(char*)\n-PL_strncat(char* dest, const char* src, PRUint32 max)\n-{\n-    char* rv;\n+PL_strncat(char* dest, const char* src, PRUint32 max) {\n+  char* rv;\n \n-    if (((char*)0 == dest) || ((const char*)0 == src) || (0 == max)) {\n-        return dest;\n-    }\n+  if (((char*)0 == dest) || ((const char*)0 == src) || (0 == max)) {\n+    return dest;\n+  }\n \n-    for (rv = dest; *dest; dest++)\n-        ;\n+  for (rv = dest; *dest; dest++);\n \n-    (void)PL_strncpy(dest, src, max);\n-    return rv;\n+  (void)PL_strncpy(dest, src, max);\n+  return rv;\n }\n \n PR_IMPLEMENT(char*)\n-PL_strcatn(char* dest, PRUint32 max, const char* src)\n-{\n-    char* rv;\n-    PRUint32 dl;\n-\n-    if (((char*)0 == dest) || ((const char*)0 == src)) {\n-        return dest;\n-    }\n+PL_strcatn(char* dest, PRUint32 max, const char* src) {\n+  char* rv;\n+  PRUint32 dl;\n \n-    for (rv = dest, dl = 0; *dest; dest++, dl++)\n-        ;\n+  if (((char*)0 == dest) || ((const char*)0 == src)) {\n+    return dest;\n+  }\n \n-    if (max <= dl) {\n-        return rv;\n-    }\n-    (void)PL_strncpyz(dest, src, max - dl);\n+  for (rv = dest, dl = 0; *dest; dest++, dl++);\n \n+  if (max <= dl) {\n     return rv;\n+  }\n+  (void)PL_strncpyz(dest, src, max - dl);\n+\n+  return rv;\n }\ndiff --git a/nspr/lib/libc/src/strchr.c b/nspr/lib/libc/src/strchr.c\nindex 9c49d23..d2f1080 100644\n--- a/nspr/lib/libc/src/strchr.c\n+++ b/nspr/lib/libc/src/strchr.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,64 +7,59 @@\n #include <string.h>\n \n PR_IMPLEMENT(char*)\n-PL_strchr(const char* s, char c)\n-{\n-    if ((const char*)0 == s) {\n-        return (char*)0;\n-    }\n+PL_strchr(const char* s, char c) {\n+  if ((const char*)0 == s) {\n+    return (char*)0;\n+  }\n \n-    return strchr(s, c);\n+  return strchr(s, c);\n }\n \n PR_IMPLEMENT(char*)\n-PL_strrchr(const char* s, char c)\n-{\n-    if ((const char*)0 == s) {\n-        return (char*)0;\n-    }\n+PL_strrchr(const char* s, char c) {\n+  if ((const char*)0 == s) {\n+    return (char*)0;\n+  }\n \n-    return strrchr(s, c);\n+  return strrchr(s, c);\n }\n \n PR_IMPLEMENT(char*)\n-PL_strnchr(const char* s, char c, PRUint32 n)\n-{\n-    if ((const char*)0 == s) {\n-        return (char*)0;\n-    }\n-\n-    for (; n && *s; s++, n--)\n-        if (*s == c) {\n-            return (char*)s;\n-        }\n+PL_strnchr(const char* s, char c, PRUint32 n) {\n+  if ((const char*)0 == s) {\n+    return (char*)0;\n+  }\n \n-    if (((char)0 == c) && (n > 0) && ((char)0 == *s)) {\n-        return (char*)s;\n+  for (; n && *s; s++, n--)\n+    if (*s == c) {\n+      return (char*)s;\n     }\n \n-    return (char*)0;\n+  if (((char)0 == c) && (n > 0) && ((char)0 == *s)) {\n+    return (char*)s;\n+  }\n+\n+  return (char*)0;\n }\n \n PR_IMPLEMENT(char*)\n-PL_strnrchr(const char* s, char c, PRUint32 n)\n-{\n-    const char* p;\n+PL_strnrchr(const char* s, char c, PRUint32 n) {\n+  const char* p;\n \n-    if ((const char*)0 == s) {\n-        return (char*)0;\n-    }\n+  if ((const char*)0 == s) {\n+    return (char*)0;\n+  }\n \n-    for (p = s; n && *p; p++, n--)\n-        ;\n+  for (p = s; n && *p; p++, n--);\n \n-    if (((char)0 == c) && (n > 0) && ((char)0 == *p)) {\n-        return (char*)p;\n-    }\n+  if (((char)0 == c) && (n > 0) && ((char)0 == *p)) {\n+    return (char*)p;\n+  }\n \n-    for (p--; p >= s; p--)\n-        if (*p == c) {\n-            return (char*)p;\n-        }\n+  for (p--; p >= s; p--)\n+    if (*p == c) {\n+      return (char*)p;\n+    }\n \n-    return (char*)0;\n+  return (char*)0;\n }\ndiff --git a/nspr/lib/libc/src/strcmp.c b/nspr/lib/libc/src/strcmp.c\nindex 5f917e8..0196d8d 100644\n--- a/nspr/lib/libc/src/strcmp.c\n+++ b/nspr/lib/libc/src/strcmp.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,27 +7,25 @@\n #include <string.h>\n \n PR_IMPLEMENT(PRIntn)\n-PL_strcmp(const char* a, const char* b)\n-{\n-    if ((const char*)0 == a) {\n-        return ((const char*)0 == b) ? 0 : -1;\n-    }\n-    if ((const char*)0 == b) {\n-        return 1;\n-    }\n+PL_strcmp(const char* a, const char* b) {\n+  if ((const char*)0 == a) {\n+    return ((const char*)0 == b) ? 0 : -1;\n+  }\n+  if ((const char*)0 == b) {\n+    return 1;\n+  }\n \n-    return (PRIntn)strcmp(a, b);\n+  return (PRIntn)strcmp(a, b);\n }\n \n PR_IMPLEMENT(PRIntn)\n-PL_strncmp(const char* a, const char* b, PRUint32 max)\n-{\n-    if ((const char*)0 == a) {\n-        return ((const char*)0 == b) ? 0 : -1;\n-    }\n-    if ((const char*)0 == b) {\n-        return 1;\n-    }\n+PL_strncmp(const char* a, const char* b, PRUint32 max) {\n+  if ((const char*)0 == a) {\n+    return ((const char*)0 == b) ? 0 : -1;\n+  }\n+  if ((const char*)0 == b) {\n+    return 1;\n+  }\n \n-    return (PRIntn)strncmp(a, b, (size_t)max);\n+  return (PRIntn)strncmp(a, b, (size_t)max);\n }\ndiff --git a/nspr/lib/libc/src/strcpy.c b/nspr/lib/libc/src/strcpy.c\nindex 9a81cda..9e9ad44 100644\n--- a/nspr/lib/libc/src/strcpy.c\n+++ b/nspr/lib/libc/src/strcpy.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,59 +7,54 @@\n #include <string.h>\n \n PR_IMPLEMENT(char*)\n-PL_strcpy(char* dest, const char* src)\n-{\n-    if (((char*)0 == dest) || ((const char*)0 == src)) {\n-        return (char*)0;\n-    }\n+PL_strcpy(char* dest, const char* src) {\n+  if (((char*)0 == dest) || ((const char*)0 == src)) {\n+    return (char*)0;\n+  }\n \n-    return strcpy(dest, src);\n+  return strcpy(dest, src);\n }\n \n PR_IMPLEMENT(char*)\n-PL_strncpy(char* dest, const char* src, PRUint32 max)\n-{\n-    char* rv;\n+PL_strncpy(char* dest, const char* src, PRUint32 max) {\n+  char* rv;\n \n-    if ((char*)0 == dest) {\n-        return (char*)0;\n-    }\n-    if ((const char*)0 == src) {\n-        return (char*)0;\n-    }\n+  if ((char*)0 == dest) {\n+    return (char*)0;\n+  }\n+  if ((const char*)0 == src) {\n+    return (char*)0;\n+  }\n \n-    for (rv = dest; max && ((*dest = *src) != 0); dest++, src++, max--)\n-        ;\n+  for (rv = dest; max && ((*dest = *src) != 0); dest++, src++, max--);\n \n #ifdef JLRU\n-    /* XXX I (wtc) think the -- and ++ operators should be postfix. */\n-    while (--max) {\n-        *++dest = '\\0';\n-    }\n+  /* XXX I (wtc) think the -- and ++ operators should be postfix. */\n+  while (--max) {\n+    *++dest = '\\0';\n+  }\n #endif /* JLRU */\n \n-    return rv;\n+  return rv;\n }\n \n PR_IMPLEMENT(char*)\n-PL_strncpyz(char* dest, const char* src, PRUint32 max)\n-{\n-    char* rv;\n+PL_strncpyz(char* dest, const char* src, PRUint32 max) {\n+  char* rv;\n \n-    if ((char*)0 == dest) {\n-        return (char*)0;\n-    }\n-    if ((const char*)0 == src) {\n-        return (char*)0;\n-    }\n-    if (0 == max) {\n-        return (char*)0;\n-    }\n+  if ((char*)0 == dest) {\n+    return (char*)0;\n+  }\n+  if ((const char*)0 == src) {\n+    return (char*)0;\n+  }\n+  if (0 == max) {\n+    return (char*)0;\n+  }\n \n-    for (rv = dest, max--; max && ((*dest = *src) != 0); dest++, src++, max--)\n-        ;\n+  for (rv = dest, max--; max && ((*dest = *src) != 0); dest++, src++, max--);\n \n-    *dest = '\\0';\n+  *dest = '\\0';\n \n-    return rv;\n+  return rv;\n }\ndiff --git a/nspr/lib/libc/src/strdup.c b/nspr/lib/libc/src/strdup.c\nindex a4a17ab..3a39f01 100644\n--- a/nspr/lib/libc/src/strdup.c\n+++ b/nspr/lib/libc/src/strdup.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,49 +8,47 @@\n #include <string.h>\n \n PR_IMPLEMENT(char*)\n-PL_strdup(const char* s)\n-{\n-    char* rv;\n-    size_t n;\n+PL_strdup(const char* s) {\n+  char* rv;\n+  size_t n;\n \n-    if ((const char*)0 == s) {\n-        s = \"\";\n-    }\n+  if ((const char*)0 == s) {\n+    s = \"\";\n+  }\n \n-    n = strlen(s) + 1;\n+  n = strlen(s) + 1;\n \n-    rv = (char*)malloc(n);\n-    if ((char*)0 == rv) {\n-        return rv;\n-    }\n+  rv = (char*)malloc(n);\n+  if ((char*)0 == rv) {\n+    return rv;\n+  }\n \n-    (void)memcpy(rv, s, n);\n+  (void)memcpy(rv, s, n);\n \n-    return rv;\n+  return rv;\n }\n \n PR_IMPLEMENT(void)\n PL_strfree(char* s) { free(s); }\n \n PR_IMPLEMENT(char*)\n-PL_strndup(const char* s, PRUint32 max)\n-{\n-    char* rv;\n-    size_t l;\n+PL_strndup(const char* s, PRUint32 max) {\n+  char* rv;\n+  size_t l;\n \n-    if ((const char*)0 == s) {\n-        s = \"\";\n-    }\n+  if ((const char*)0 == s) {\n+    s = \"\";\n+  }\n \n-    l = PL_strnlen(s, max);\n+  l = PL_strnlen(s, max);\n \n-    rv = (char*)malloc(l + 1);\n-    if ((char*)0 == rv) {\n-        return rv;\n-    }\n+  rv = (char*)malloc(l + 1);\n+  if ((char*)0 == rv) {\n+    return rv;\n+  }\n \n-    (void)memcpy(rv, s, l);\n-    rv[l] = '\\0';\n+  (void)memcpy(rv, s, l);\n+  rv[l] = '\\0';\n \n-    return rv;\n+  return rv;\n }\ndiff --git a/nspr/lib/libc/src/strlen.c b/nspr/lib/libc/src/strlen.c\nindex c4a28ed..b162a8c 100644\n--- a/nspr/lib/libc/src/strlen.c\n+++ b/nspr/lib/libc/src/strlen.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,38 +9,35 @@\n #include <string.h>\n \n PR_IMPLEMENT(PRUint32)\n-PL_strlen(const char* str)\n-{\n-    size_t l;\n+PL_strlen(const char* str) {\n+  size_t l;\n \n-    if ((const char*)0 == str) {\n-        return 0;\n-    }\n+  if ((const char*)0 == str) {\n+    return 0;\n+  }\n \n-    l = strlen(str);\n+  l = strlen(str);\n \n-    /* error checking in case we have a 64-bit platform -- make sure\n-     * we don't have ultra long strings that overflow an int32\n-     */\n-    if (sizeof(PRUint32) < sizeof(size_t)) {\n-        if (l > PR_INT32_MAX) {\n-            PR_Assert(\"l <= PR_INT32_MAX\", __FILE__, __LINE__);\n-        }\n+  /* error checking in case we have a 64-bit platform -- make sure\n+   * we don't have ultra long strings that overflow an int32\n+   */\n+  if (sizeof(PRUint32) < sizeof(size_t)) {\n+    if (l > PR_INT32_MAX) {\n+      PR_Assert(\"l <= PR_INT32_MAX\", __FILE__, __LINE__);\n     }\n+  }\n \n-    return (PRUint32)l;\n+  return (PRUint32)l;\n }\n \n PR_IMPLEMENT(PRUint32)\n-PL_strnlen(const char* str, PRUint32 max)\n-{\n-    register const char* s;\n+PL_strnlen(const char* str, PRUint32 max) {\n+  register const char* s;\n \n-    if ((const char*)0 == str) {\n-        return 0;\n-    }\n-    for (s = str; max && *s; s++, max--)\n-        ;\n+  if ((const char*)0 == str) {\n+    return 0;\n+  }\n+  for (s = str; max && *s; s++, max--);\n \n-    return (PRUint32)(s - str);\n+  return (PRUint32)(s - str);\n }\ndiff --git a/nspr/lib/libc/src/strpbrk.c b/nspr/lib/libc/src/strpbrk.c\nindex 9c41acf..d2ab403 100644\n--- a/nspr/lib/libc/src/strpbrk.c\n+++ b/nspr/lib/libc/src/strpbrk.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,73 +7,67 @@\n #include <string.h>\n \n PR_IMPLEMENT(char*)\n-PL_strpbrk(const char* s, const char* list)\n-{\n-    if (((const char*)0 == s) || ((const char*)0 == list)) {\n-        return (char*)0;\n-    }\n+PL_strpbrk(const char* s, const char* list) {\n+  if (((const char*)0 == s) || ((const char*)0 == list)) {\n+    return (char*)0;\n+  }\n \n-    return strpbrk(s, list);\n+  return strpbrk(s, list);\n }\n \n PR_IMPLEMENT(char*)\n-PL_strprbrk(const char* s, const char* list)\n-{\n-    const char* p;\n-    const char* r;\n+PL_strprbrk(const char* s, const char* list) {\n+  const char* p;\n+  const char* r;\n \n-    if (((const char*)0 == s) || ((const char*)0 == list)) {\n-        return (char*)0;\n-    }\n+  if (((const char*)0 == s) || ((const char*)0 == list)) {\n+    return (char*)0;\n+  }\n \n-    for (r = s; *r; r++)\n-        ;\n+  for (r = s; *r; r++);\n \n-    for (r--; r >= s; r--)\n-        for (p = list; *p; p++)\n-            if (*r == *p) {\n-                return (char*)r;\n-            }\n+  for (r--; r >= s; r--)\n+    for (p = list; *p; p++)\n+      if (*r == *p) {\n+        return (char*)r;\n+      }\n \n-    return (char*)0;\n+  return (char*)0;\n }\n \n PR_IMPLEMENT(char*)\n-PL_strnpbrk(const char* s, const char* list, PRUint32 max)\n-{\n-    const char* p;\n+PL_strnpbrk(const char* s, const char* list, PRUint32 max) {\n+  const char* p;\n \n-    if (((const char*)0 == s) || ((const char*)0 == list)) {\n-        return (char*)0;\n-    }\n+  if (((const char*)0 == s) || ((const char*)0 == list)) {\n+    return (char*)0;\n+  }\n \n-    for (; max && *s; s++, max--)\n-        for (p = list; *p; p++)\n-            if (*s == *p) {\n-                return (char*)s;\n-            }\n+  for (; max && *s; s++, max--)\n+    for (p = list; *p; p++)\n+      if (*s == *p) {\n+        return (char*)s;\n+      }\n \n-    return (char*)0;\n+  return (char*)0;\n }\n \n PR_IMPLEMENT(char*)\n-PL_strnprbrk(const char* s, const char* list, PRUint32 max)\n-{\n-    const char* p;\n-    const char* r;\n+PL_strnprbrk(const char* s, const char* list, PRUint32 max) {\n+  const char* p;\n+  const char* r;\n \n-    if (((const char*)0 == s) || ((const char*)0 == list)) {\n-        return (char*)0;\n-    }\n+  if (((const char*)0 == s) || ((const char*)0 == list)) {\n+    return (char*)0;\n+  }\n \n-    for (r = s; max && *r; r++, max--)\n-        ;\n+  for (r = s; max && *r; r++, max--);\n \n-    for (r--; r >= s; r--)\n-        for (p = list; *p; p++)\n-            if (*r == *p) {\n-                return (char*)r;\n-            }\n+  for (r--; r >= s; r--)\n+    for (p = list; *p; p++)\n+      if (*r == *p) {\n+        return (char*)r;\n+      }\n \n-    return (char*)0;\n+  return (char*)0;\n }\ndiff --git a/nspr/lib/libc/src/strstr.c b/nspr/lib/libc/src/strstr.c\nindex f85f287..d038bc2 100644\n--- a/nspr/lib/libc/src/strstr.c\n+++ b/nspr/lib/libc/src/strstr.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,104 +7,99 @@\n #include <string.h>\n \n PR_IMPLEMENT(char*)\n-PL_strstr(const char* big, const char* little)\n-{\n-    if (((const char*)0 == big) || ((const char*)0 == little)) {\n-        return (char*)0;\n-    }\n-    if (((char)0 == *big) || ((char)0 == *little)) {\n-        return (char*)0;\n-    }\n-\n-    return strstr(big, little);\n+PL_strstr(const char* big, const char* little) {\n+  if (((const char*)0 == big) || ((const char*)0 == little)) {\n+    return (char*)0;\n+  }\n+  if (((char)0 == *big) || ((char)0 == *little)) {\n+    return (char*)0;\n+  }\n+\n+  return strstr(big, little);\n }\n \n PR_IMPLEMENT(char*)\n-PL_strrstr(const char* big, const char* little)\n-{\n-    const char* p;\n-    size_t ll;\n-    size_t bl;\n-\n-    if (((const char*)0 == big) || ((const char*)0 == little)) {\n-        return (char*)0;\n-    }\n-    if (((char)0 == *big) || ((char)0 == *little)) {\n-        return (char*)0;\n-    }\n-\n-    ll = strlen(little);\n-    bl = strlen(big);\n-    if (bl < ll) {\n-        return (char*)0;\n-    }\n-    p = &big[bl - ll];\n-\n-    for (; p >= big; p--)\n-        if (*little == *p)\n-            if (0 == strncmp(p, little, ll)) {\n-                return (char*)p;\n-            }\n+PL_strrstr(const char* big, const char* little) {\n+  const char* p;\n+  size_t ll;\n+  size_t bl;\n+\n+  if (((const char*)0 == big) || ((const char*)0 == little)) {\n+    return (char*)0;\n+  }\n+  if (((char)0 == *big) || ((char)0 == *little)) {\n+    return (char*)0;\n+  }\n \n+  ll = strlen(little);\n+  bl = strlen(big);\n+  if (bl < ll) {\n     return (char*)0;\n+  }\n+  p = &big[bl - ll];\n+\n+  for (; p >= big; p--)\n+    if (*little == *p)\n+      if (0 == strncmp(p, little, ll)) {\n+        return (char*)p;\n+      }\n+\n+  return (char*)0;\n }\n \n PR_IMPLEMENT(char*)\n-PL_strnstr(const char* big, const char* little, PRUint32 max)\n-{\n-    size_t ll;\n-\n-    if (((const char*)0 == big) || ((const char*)0 == little)) {\n-        return (char*)0;\n-    }\n-    if (((char)0 == *big) || ((char)0 == *little)) {\n-        return (char*)0;\n-    }\n-\n-    ll = strlen(little);\n-    if (ll > (size_t)max) {\n-        return (char*)0;\n-    }\n-    max -= (PRUint32)ll;\n-    max++;\n-\n-    for (; max && *big; big++, max--)\n-        if (*little == *big)\n-            if (0 == strncmp(big, little, ll)) {\n-                return (char*)big;\n-            }\n+PL_strnstr(const char* big, const char* little, PRUint32 max) {\n+  size_t ll;\n+\n+  if (((const char*)0 == big) || ((const char*)0 == little)) {\n+    return (char*)0;\n+  }\n+  if (((char)0 == *big) || ((char)0 == *little)) {\n+    return (char*)0;\n+  }\n \n+  ll = strlen(little);\n+  if (ll > (size_t)max) {\n     return (char*)0;\n+  }\n+  max -= (PRUint32)ll;\n+  max++;\n+\n+  for (; max && *big; big++, max--)\n+    if (*little == *big)\n+      if (0 == strncmp(big, little, ll)) {\n+        return (char*)big;\n+      }\n+\n+  return (char*)0;\n }\n \n PR_IMPLEMENT(char*)\n-PL_strnrstr(const char* big, const char* little, PRUint32 max)\n-{\n-    const char* p;\n-    size_t ll;\n-\n-    if (((const char*)0 == big) || ((const char*)0 == little)) {\n-        return (char*)0;\n-    }\n-    if (((char)0 == *big) || ((char)0 == *little)) {\n-        return (char*)0;\n-    }\n-\n-    ll = strlen(little);\n-\n-    for (p = big; max && *p; p++, max--)\n-        ;\n-\n-    p -= ll;\n-    if (p < big) {\n-        return (char*)0;\n-    }\n-\n-    for (; p >= big; p--)\n-        if (*little == *p)\n-            if (0 == strncmp(p, little, ll)) {\n-                return (char*)p;\n-            }\n+PL_strnrstr(const char* big, const char* little, PRUint32 max) {\n+  const char* p;\n+  size_t ll;\n+\n+  if (((const char*)0 == big) || ((const char*)0 == little)) {\n+    return (char*)0;\n+  }\n+  if (((char)0 == *big) || ((char)0 == *little)) {\n+    return (char*)0;\n+  }\n+\n+  ll = strlen(little);\n+\n+  for (p = big; max && *p; p++, max--);\n \n+  p -= ll;\n+  if (p < big) {\n     return (char*)0;\n+  }\n+\n+  for (; p >= big; p--)\n+    if (*little == *p)\n+      if (0 == strncmp(p, little, ll)) {\n+        return (char*)p;\n+      }\n+\n+  return (char*)0;\n }\ndiff --git a/nspr/lib/libc/src/strtok.c b/nspr/lib/libc/src/strtok.c\nindex 3b616c5..1251f85 100644\n--- a/nspr/lib/libc/src/strtok.c\n+++ b/nspr/lib/libc/src/strtok.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -5,47 +6,46 @@\n #include \"plstr.h\"\n \n PR_IMPLEMENT(char*)\n-PL_strtok_r(char* s1, const char* s2, char** lasts)\n-{\n-    const char* sepp;\n-    int c, sc;\n-    char* tok;\n-\n-    if (s1 == NULL) {\n-        if (*lasts == NULL) {\n-            return NULL;\n-        }\n-\n-        s1 = *lasts;\n+PL_strtok_r(char* s1, const char* s2, char** lasts) {\n+  const char* sepp;\n+  int c, sc;\n+  char* tok;\n+\n+  if (s1 == NULL) {\n+    if (*lasts == NULL) {\n+      return NULL;\n     }\n \n-    for (; (c = *s1) != 0; s1++) {\n-        for (sepp = s2; (sc = *sepp) != 0; sepp++) {\n-            if (c == sc) {\n-                break;\n-            }\n-        }\n-        if (sc == 0) {\n-            break;\n-        }\n-    }\n+    s1 = *lasts;\n+  }\n \n-    if (c == 0) {\n-        *lasts = NULL;\n-        return NULL;\n+  for (; (c = *s1) != 0; s1++) {\n+    for (sepp = s2; (sc = *sepp) != 0; sepp++) {\n+      if (c == sc) {\n+        break;\n+      }\n     }\n-\n-    tok = s1++;\n-\n-    for (; (c = *s1) != 0; s1++) {\n-        for (sepp = s2; (sc = *sepp) != 0; sepp++) {\n-            if (c == sc) {\n-                *s1++ = '\\0';\n-                *lasts = s1;\n-                return tok;\n-            }\n-        }\n+    if (sc == 0) {\n+      break;\n     }\n+  }\n+\n+  if (c == 0) {\n     *lasts = NULL;\n-    return tok;\n+    return NULL;\n+  }\n+\n+  tok = s1++;\n+\n+  for (; (c = *s1) != 0; s1++) {\n+    for (sepp = s2; (sc = *sepp) != 0; sepp++) {\n+      if (c == sc) {\n+        *s1++ = '\\0';\n+        *lasts = s1;\n+        return tok;\n+      }\n+    }\n+  }\n+  *lasts = NULL;\n+  return tok;\n }\ndiff --git a/nspr/lib/prstreams/.cvsignore b/nspr/lib/prstreams/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/lib/prstreams/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/lib/prstreams/Makefile.in b/nspr/lib/prstreams/Makefile.in\nnew file mode 100644\nindex 0000000..5865ab8\n--- /dev/null\n+++ b/nspr/lib/prstreams/Makefile.in\n@@ -0,0 +1,131 @@\n+# \n+# This Source Code Form is subject to the terms of the Mozilla Public\n+# License, v. 2.0. If a copy of the MPL was not distributed with this\n+# file, You can obtain one at http://mozilla.org/MPL/2.0/.\n+\n+#! gmake\n+\n+MOD_DEPTH\t= ../..\n+topsrcdir\t= @top_srcdir@\n+srcdir\t\t= @srcdir@\n+VPATH\t\t= @srcdir@\n+\n+include $(MOD_DEPTH)/config/autoconf.mk\n+\n+include $(topsrcdir)/config/config.mk\n+\n+ifeq ($(OS_ARCH), BeOS)\n+    CFLAGS += -frtti -fexceptions\n+endif\n+\n+INCLUDES = -I$(dist_includedir)\n+\n+HEADERS = $(wildcard $(srcdir)/*.h)\n+\n+CSRCS = \\\n+\tplvrsion.c \\\n+\t$(NULL)\n+\n+CXXSRCS = \\\n+\tprstrms.cpp \\\n+\t$(NULL)\n+\n+OBJS = $(addprefix $(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX)) $(CXXSRCS:.cpp=.$(OBJ_SUFFIX)))\n+\n+ifeq ($(OS_ARCH), WINNT)\n+        RES=$(OBJDIR)/prstrms.res\n+        RESNAME=prstrms.rc\n+        OS_LIBS = user32.lib\n+else\n+    ifeq ($(OS_ARCH), AIX)\n+      ifeq ($(OS_RELEASE), 4.1)\n+        ifeq ($(CLASSIC_NSPR),1)\n+            OS_LIBS += -lC -lc\n+        else\n+            OS_LIBS += -lC_r -lc_r\n+        endif\n+      else\n+        # makeC++SharedLib(_r) is in either /usr/lpp/xlC/bin\n+        # or /usr/ibmcxx/bin.\n+        ifeq ($(CLASSIC_NSPR),1)\n+            MKSHLIB = makeC++SharedLib -p 0\n+        else\n+            MKSHLIB = makeC++SharedLib_r -p 0\n+        endif\n+        OS_LIBS += -ldl\n+      endif\n+    endif\n+endif\n+\n+ifeq ($(OS_ARCH),BeOS)\n+    OS_LIBS = -lstdc++.r4\n+endif\n+\n+EXTRA_LIBS = $(LIBNSPR)\n+\n+# On SCOOS, we can't link with extra libraries when\n+# we build a shared library.  If we do so, the linker doesn't\n+# complain, but we would run into weird problems at run-time.\n+# Therefore on these platforms, we link just the object files.\n+ifeq ($(OS_ARCH),SCOOS)\n+    EXTRA_LIBS =\n+endif\n+\n+ifdef RESOLVE_LINK_SYMBOLS\n+EXTRA_LIBS += $(OS_LIBS)\n+endif\n+\n+LIBRARY_NAME    = prstrms\n+LIBRARY_VERSION = $(MOD_MAJOR_VERSION)\n+\n+RELEASE_HEADERS = $(HEADERS)\n+RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)\n+RELEASE_LIBS    = $(TARGETS)\n+\n+include $(topsrcdir)/config/rules.mk\n+\n+#\n+# Version information generation (begin)\n+#\n+ECHO = echo\n+TINC = $(OBJDIR)/_pl_bld.h\n+PROD = $(notdir $(SHARED_LIBRARY))\n+NOW = $(MOD_DEPTH)/config/$(OBJDIR)/now\n+SH_DATE = $(shell date \"+%Y-%m-%d %T\")\n+SH_NOW = $(shell $(NOW))\n+\n+ifeq ($(OS_ARCH), WINNT)\n+\tSUF = i64\n+else\n+\tSUF = LL\n+endif\n+\n+$(TINC):\n+\t@$(MAKE_OBJDIR)\n+\t@$(ECHO) '#define _BUILD_STRING \"$(SH_DATE)\"' > $(TINC)\n+\t@if test ! -z \"$(SH_NOW)\"; then \\\n+\t    $(ECHO) '#define _BUILD_TIME $(SH_NOW)$(SUF)' >> $(TINC); \\\n+\telse \\\n+\t    true; \\\n+\tfi\n+\t@$(ECHO) '#define _PRODUCTION \"$(PROD)\"' >> $(TINC)\n+\n+\n+$(OBJDIR)/plvrsion.$(OBJ_SUFFIX): plvrsion.c $(TINC)\n+ifeq ($(OS_ARCH), WINNT)\n+\t$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) $<\n+else\n+\t$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) $<\n+endif\n+#\n+# Version information generation (end)\n+#\n+\n+export:: $(TARGETS) $(HEADERS)\n+\t$(INSTALL) -m 444 $(HEADERS) $(dist_includedir)\n+\t$(INSTALL) -m 444 $(TARGETS) $(dist_libdir)\n+ifeq ($(OS_ARCH),HP-UX)\n+ifdef SHARED_LIBRARY\n+\t$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_libdir)\n+endif\n+endif\ndiff --git a/nspr/lib/prstreams/plvrsion.c b/nspr/lib/prstreams/plvrsion.c\nnew file mode 100644\nindex 0000000..746ddf7\n--- /dev/null\n+++ b/nspr/lib/prstreams/plvrsion.c\n@@ -0,0 +1,98 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+#include \"prinit.h\"\n+#include \"prvrsion.h\"\n+\n+/************************************************************************/\n+/**************************IDENTITY AND VERSIONING***********************/\n+/************************************************************************/\n+#include \"_pl_bld.h\"\n+#if !defined(_BUILD_TIME)\n+#  ifdef HAVE_LONG_LONG\n+#    define _BUILD_TIME 0\n+#  else\n+#    define _BUILD_TIME {0, 0}\n+#  endif\n+#endif\n+#if !defined(_BUILD_STRING)\n+#  define _BUILD_STRING \"\"\n+#endif\n+#if !defined(_PRODUCTION)\n+#  define _PRODUCTION \"\"\n+#endif\n+#if defined(DEBUG)\n+#  define _DEBUG_STRING \" (debug)\"\n+#else\n+#  define _DEBUG_STRING \"\"\n+#endif\n+\n+/*\n+ * A trick to expand the PR_VMAJOR macro before concatenation.\n+ */\n+#define CONCAT(x, y) x##y\n+#define CONCAT2(x, y) CONCAT(x, y)\n+#define VERSION_DESC_NAME CONCAT2(prVersionDescription_libprstrms, PR_VMAJOR)\n+\n+PRVersionDescription VERSION_DESC_NAME = {\n+    /* version          */ 2,           /* this is the only one supported */\n+    /* buildTime        */ _BUILD_TIME, /* usecs since midnight 1/1/1970 GMT */\n+    /* buildTimeString  */ _BUILD_STRING, /*    ditto, but human readable */\n+    /* vMajor           */ PR_VMAJOR,     /* NSPR's version number */\n+    /* vMinor           */ PR_VMINOR,     /*  and minor version */\n+    /* vPatch           */ PR_VPATCH,     /*  and patch */\n+    /* beta             */ PR_BETA,       /* beta build boolean */\n+#if defined(DEBUG)\n+    /* debug            */ PR_TRUE, /* a debug build */\n+#else\n+    /* debug            */ PR_FALSE, /* an optomized build */\n+#endif\n+    /* special          */ PR_FALSE,    /* they're all special, but ... */\n+    /* filename         */ _PRODUCTION, /* the produced library name */\n+    /* description      */ \"Portable runtime\", /* what we are */\n+    /* security         */ \"N/A\",              /* not applicable here */\n+                                               /* copywrite        */\n+    \"This Source Code Form is subject to the terms of the Mozilla Public \"\n+    \"License, v. 2.0. If a copy of the MPL was not distributed with this file, \"\n+    \"You can obtain one at http://mozilla.org/MPL/2.0/.\",\n+    /* comment          */ \"http://www.mozilla.org/MPL/\",\n+    /* specialString    */ \"\"};\n+\n+#ifdef XP_UNIX\n+\n+/*\n+ * Version information for the 'ident' and 'what commands\n+ *\n+ * NOTE: the first component of the concatenated rcsid string\n+ * must not end in a '$' to prevent rcs keyword substitution.\n+ */\n+static char rcsid[] =\n+    \"$Header: NSPR \" PR_VERSION _DEBUG_STRING \"  \" _BUILD_STRING \" $\";\n+static char sccsid[] = \"@(#)NSPR \" PR_VERSION _DEBUG_STRING \"  \" _BUILD_STRING;\n+\n+#endif /* XP_UNIX */\n+\n+#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC\n+#  pragma GCC diagnostic push\n+#  pragma GCC diagnostic ignored \"-Wunused-but-set-variable\"\n+#endif\n+PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint() {\n+#ifdef XP_UNIX\n+  /*\n+   * Add dummy references to rcsid and sccsid to prevent them\n+   * from being optimized away as unused variables.\n+   */\n+  const char* dummy;\n+\n+  dummy = rcsid;\n+  dummy = sccsid;\n+#endif\n+  return &VERSION_DESC_NAME;\n+} /* versionEntryPointType */\n+#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC\n+#  pragma GCC diagnostic pop\n+#endif\n+\n+/* plvrsion.c */\ndiff --git a/nspr/lib/prstreams/prstrms.cpp b/nspr/lib/prstreams/prstrms.cpp\nnew file mode 100644\nindex 0000000..878175d\n--- /dev/null\n+++ b/nspr/lib/prstreams/prstrms.cpp\n@@ -0,0 +1,517 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+ * Robin J. Maxwell 11-22-96\n+ * Fredrik Roubert <roubert@google.com> 2010-07-23\n+ * Matt Austern <austern@google.com> 2010-07-23\n+ */\n+\n+#include \"prstrms.h\"\n+\n+#include <cstdio>\n+#include <cstring>\n+#include <ios>\n+#include <new>\n+\n+using std::ios_base;\n+using std::iostream;\n+using std::istream;\n+using std::nothrow;\n+using std::ostream;\n+using std::streambuf;\n+using std::streamsize;\n+\n+\n+PRfilebuf::PRfilebuf():\n+    _fd(NULL),\n+    _opened(false),\n+    _allocated(false),\n+    _unbuffered(false),\n+    _user_buf(false),\n+    _buf_base(NULL),\n+    _buf_end(NULL) { }\n+\n+\n+PRfilebuf::PRfilebuf(PRFileDesc *fd):\n+    _fd(fd),\n+    _opened(false),\n+    _allocated(false),\n+    _unbuffered(false),\n+    _user_buf(false),\n+    _buf_base(NULL),\n+    _buf_end(NULL) { }\n+\n+\n+PRfilebuf::PRfilebuf(PRFileDesc *fd, char_type *ptr, streamsize len):\n+    _fd(fd),\n+    _opened(false),\n+    _allocated(false),\n+    _unbuffered(false),\n+    _user_buf(false),\n+    _buf_base(NULL),\n+    _buf_end(NULL)\n+{\n+    setbuf(ptr, len);\n+}\n+\n+\n+PRfilebuf::~PRfilebuf()\n+{\n+    if (_opened) {\n+        close();\n+    } else {\n+        sync();\n+    }\n+    if (_allocated) {\n+        delete _buf_base;\n+    }\n+}\n+\n+\n+PRfilebuf *PRfilebuf::open(\n+    const char *name, ios_base::openmode flags, PRIntn mode)\n+{\n+    if (_fd != NULL) {\n+        return NULL;  // Error if already open.\n+    }\n+\n+    // Translate flags argument.\n+    PRIntn prflags = 0;\n+    bool ate = (flags & ios_base::ate) != 0;\n+    flags &= ~(ios_base::ate | ios_base::binary);\n+\n+    // TODO: The flag PR_CREATE_FILE should probably be used for the cases\n+    // (out), (out|app), (out|trunc) and (in|out|trunc) as the C++ standard\n+    // specifies that these cases should open files 'as if by using fopen with\n+    // \"w\"'. But adding that flag here will cause the unit test to leave files\n+    // behind after running (which might or might not be an error in the unit\n+    // test) so the matter needs further investigation before any changes are\n+    // made. The old prstreams implementation used the non-standard flag\n+    // ios::nocreate to control the use of PR_CREATE_FILE.\n+\n+    if (flags == (ios_base::out)) {\n+        prflags = PR_WRONLY | PR_TRUNCATE;\n+    } else if (flags == (ios_base::out | ios_base::app)) {\n+        prflags = PR_RDWR | PR_APPEND;\n+    } else if (flags == (ios_base::out | ios_base::trunc)) {\n+        prflags = PR_WRONLY | PR_TRUNCATE;\n+    } else if (flags == (ios_base::in)) {\n+        prflags = PR_RDONLY;\n+    } else if (flags == (ios_base::in | ios_base::out)) {\n+        prflags = PR_RDWR;\n+    } else if (flags == (ios_base::in | ios_base::out | ios_base::trunc)) {\n+        prflags = PR_RDWR | PR_TRUNCATE;\n+    } else {\n+        return NULL;  // Unrecognized flag combination.\n+    }\n+\n+    if ((_fd = PR_Open(name, prflags, mode)) == NULL) {\n+        return NULL;\n+    }\n+\n+    _opened = true;\n+\n+    if (ate &&\n+        seekoff(0, ios_base::end, flags) == pos_type(traits_type::eof())) {\n+        close();\n+        return NULL;\n+    }\n+\n+    return this;\n+}\n+\n+\n+PRfilebuf *PRfilebuf::attach(PRFileDesc *fd)\n+{\n+    if (_fd != NULL) {\n+        return NULL;  // Error if already open.\n+    }\n+\n+    _opened = false;\n+    _fd = fd;\n+    return this;\n+}\n+\n+\n+PRfilebuf *PRfilebuf::close()\n+{\n+    if (_fd == NULL) {\n+        return NULL;\n+    }\n+\n+    int status = sync();\n+\n+    if (PR_Close(_fd) == PR_FAILURE ||\n+        traits_type::eq_int_type(status, traits_type::eof())) {\n+        return NULL;\n+    }\n+\n+    _fd = NULL;\n+    return this;\n+}\n+\n+\n+streambuf *PRfilebuf::setbuf(char_type *ptr, streamsize len)\n+{\n+    if (is_open() && _buf_end) {\n+        return NULL;\n+    }\n+\n+    if (!ptr || len <= 0) {\n+        _unbuffered = true;\n+    } else {\n+        setb(ptr, ptr + len, false);\n+    }\n+\n+    return this;\n+}\n+\n+\n+streambuf::pos_type PRfilebuf::seekoff(\n+    off_type offset, ios_base::seekdir dir, ios_base::openmode /*flags*/)\n+{\n+    if (PR_GetDescType(_fd) != PR_DESC_FILE) {\n+        return traits_type::eof();\n+    }\n+\n+    PRSeekWhence whence;\n+    PRInt64 pos;\n+\n+    switch (dir) {\n+        case ios_base::beg: whence = PR_SEEK_SET; break;\n+        case ios_base::cur: whence = PR_SEEK_CUR; break;\n+        case ios_base::end: whence = PR_SEEK_END; break;\n+        default:\n+            return traits_type::eof();  // This should never happen.\n+    }\n+\n+    if (traits_type::eq_int_type(sync(), traits_type::eof())) {\n+        return traits_type::eof();\n+    }\n+\n+    if ((pos = PR_Seek64(_fd, offset, whence)) == -1) {\n+        return traits_type::eof();\n+    }\n+\n+    return pos;\n+}\n+\n+\n+int PRfilebuf::sync()\n+{\n+    if (_fd == NULL) {\n+        return traits_type::eof();\n+    }\n+\n+    if (!_unbuffered) {\n+        // Sync write area.\n+        PRInt32 waiting;\n+        if ((waiting = pptr() - pbase()) != 0) {\n+            PRInt32 nout;\n+            if ((nout = PR_Write(_fd, pbase(), waiting)) != waiting) {\n+                if (nout > 0) {\n+                    // Should set _pptr -= nout.\n+                    pbump(-nout);\n+                    memmove(pbase(), pbase() + nout, waiting - nout);\n+                }\n+                return traits_type::eof();\n+            }\n+        }\n+        setp(NULL, NULL);  // Empty put area.\n+\n+        if (PR_GetDescType(_fd) == PR_DESC_FILE) {\n+            // Sockets can't seek; don't need this.\n+            PROffset64 avail;\n+            if ((avail = in_avail()) > 0) {\n+                if (PR_Seek64(_fd, -avail, PR_SEEK_CUR) != -1) {\n+                    return traits_type::eof();\n+                }\n+            }\n+        }\n+        setg(NULL, NULL, NULL);  // Empty get area.\n+    }\n+\n+    return 0;\n+}\n+\n+\n+streambuf::int_type PRfilebuf::underflow()\n+{\n+    PRInt32 count;\n+    char_type byte;\n+\n+    if (gptr() != NULL && gptr() < egptr()) {\n+        return traits_type::to_int_type(*gptr());\n+    }\n+\n+    // Make sure there is a reserve area.\n+    if (!_unbuffered && _buf_base == NULL && !allocate()) {\n+        return traits_type::eof();\n+    }\n+\n+    // Sync before new buffer created below.\n+    if (traits_type::eq_int_type(sync(), traits_type::eof())) {\n+        return traits_type::eof();\n+    }\n+\n+    if (_unbuffered) {\n+        if (PR_Read(_fd, &byte, 1) <= 0) {\n+            return traits_type::eof();\n+        }\n+\n+        return traits_type::to_int_type(byte);\n+    }\n+\n+    if ((count = PR_Read(_fd, _buf_base, _buf_end - _buf_base)) <= 0) {\n+        return traits_type::eof();  // Reached EOF.\n+    }\n+\n+    setg(_buf_base, _buf_base, _buf_base + count);\n+    return traits_type::to_int_type(*gptr());\n+}\n+\n+\n+streambuf::int_type PRfilebuf::overflow(int_type c)\n+{\n+    // Make sure there is a reserve area.\n+    if (!_unbuffered && _buf_base == NULL && !allocate()) {\n+        return traits_type::eof();\n+    }\n+\n+    // Sync before new buffer created below.\n+    if (traits_type::eq_int_type(sync(), traits_type::eof())) {\n+        return traits_type::eof();\n+    }\n+\n+    if (!_unbuffered) {\n+        setp(_buf_base, _buf_end);\n+    }\n+\n+    if (!traits_type::eq_int_type(c, traits_type::eof())) {\n+        // Extract the byte to be written.\n+        // (Required on big-endian architectures.)\n+        char_type byte = traits_type::to_char_type(c);\n+        if (!_unbuffered && pptr() < epptr()) {  // Guard against recursion.\n+            return sputc(byte);\n+        } else {\n+            if (PR_Write(_fd, &byte, 1) != 1) {\n+                return traits_type::eof();\n+            }\n+        }\n+    }\n+\n+    return traits_type::not_eof(c);\n+}\n+\n+\n+bool PRfilebuf::allocate()\n+{\n+    char_type *buf = new(nothrow) char_type[BUFSIZ];\n+    if (buf == NULL) {\n+        return false;\n+    }\n+\n+    setb(buf, buf + BUFSIZ, true);\n+    return true;\n+}\n+\n+\n+void PRfilebuf::setb(char_type *buf_base, char_type *buf_end, bool user_buf)\n+{\n+    if (_buf_base && !_user_buf) {\n+        delete[] _buf_base;\n+    }\n+\n+    _buf_base = buf_base;\n+    _buf_end = buf_end;\n+    _user_buf = user_buf;\n+}\n+\n+\n+PRifstream::PRifstream():\n+    istream(NULL),\n+    _filebuf()\n+{\n+    init(&_filebuf);\n+}\n+\n+\n+PRifstream::PRifstream(PRFileDesc *fd):\n+    istream(NULL),\n+    _filebuf(fd)\n+{\n+    init(&_filebuf);\n+}\n+\n+\n+PRifstream::PRifstream(PRFileDesc *fd, char_type *ptr, streamsize len):\n+    istream(NULL),\n+    _filebuf(fd, ptr, len)\n+{\n+    init(&_filebuf);\n+}\n+\n+\n+PRifstream::PRifstream(const char *name, openmode flags, PRIntn mode):\n+    istream(NULL),\n+    _filebuf()\n+{\n+    init(&_filebuf);\n+    if (!_filebuf.open(name, flags | in, mode)) {\n+        setstate(failbit);\n+    }\n+}\n+\n+\n+PRifstream::~PRifstream() { }\n+\n+\n+void PRifstream::open(const char *name, openmode flags, PRIntn mode)\n+{\n+    if (is_open() || !_filebuf.open(name, flags | in, mode)) {\n+        setstate(failbit);\n+    }\n+}\n+\n+\n+void PRifstream::attach(PRFileDesc *fd)\n+{\n+    if (!_filebuf.attach(fd)) {\n+        setstate(failbit);\n+    }\n+}\n+\n+\n+void PRifstream::close()\n+{\n+    if (_filebuf.close() == NULL) {\n+        setstate(failbit);\n+    }\n+}\n+\n+\n+PRofstream::PRofstream():\n+    ostream(NULL),\n+    _filebuf()\n+{\n+    init(&_filebuf);\n+}\n+\n+\n+PRofstream::PRofstream(PRFileDesc *fd):\n+    ostream(NULL),\n+    _filebuf(fd)\n+{\n+    init(&_filebuf);\n+}\n+\n+\n+PRofstream::PRofstream(PRFileDesc *fd, char_type *ptr, streamsize len):\n+    ostream(NULL),\n+    _filebuf(fd, ptr, len)\n+{\n+    init(&_filebuf);\n+}\n+\n+\n+PRofstream::PRofstream(const char *name, openmode flags, PRIntn mode):\n+    ostream(NULL),\n+    _filebuf()\n+{\n+    init(&_filebuf);\n+    if (!_filebuf.open(name, flags | out, mode)) {\n+        setstate(failbit);\n+    }\n+}\n+\n+\n+PRofstream::~PRofstream() { }\n+\n+\n+void PRofstream::open(const char *name, openmode flags, PRIntn mode)\n+{\n+    if (is_open() || !_filebuf.open(name, flags | out, mode)) {\n+        setstate(failbit);\n+    }\n+}\n+\n+\n+void PRofstream::attach(PRFileDesc *fd)\n+{\n+    if (!_filebuf.attach(fd)) {\n+        setstate(failbit);\n+    }\n+}\n+\n+\n+void PRofstream::close()\n+{\n+    if (_filebuf.close() == NULL) {\n+        setstate(failbit);\n+    }\n+}\n+\n+\n+PRfstream::PRfstream():\n+    iostream(NULL),\n+    _filebuf()\n+{\n+    init(&_filebuf);\n+}\n+\n+\n+PRfstream::PRfstream(PRFileDesc *fd):\n+    iostream(NULL),\n+    _filebuf(fd)\n+{\n+    init(&_filebuf);\n+}\n+\n+\n+PRfstream::PRfstream(PRFileDesc *fd, char_type *ptr, streamsize len):\n+    iostream(NULL),\n+    _filebuf(fd, ptr, len)\n+{\n+    init(&_filebuf);\n+}\n+\n+\n+PRfstream::PRfstream(const char *name, openmode flags, PRIntn mode):\n+    iostream(NULL),\n+    _filebuf()\n+{\n+    init(&_filebuf);\n+    if (!_filebuf.open(name, flags | in | out, mode)) {\n+        setstate(failbit);\n+    }\n+}\n+\n+\n+PRfstream::~PRfstream() { }\n+\n+\n+void PRfstream::open(const char *name, openmode flags, PRIntn mode)\n+{\n+    if (is_open() || !_filebuf.open(name, flags | in | out, mode)) {\n+        setstate(failbit);\n+    }\n+}\n+\n+\n+void PRfstream::attach(PRFileDesc *fd)\n+{\n+    if (!_filebuf.attach(fd)) {\n+        setstate(failbit);\n+    }\n+}\n+\n+\n+void PRfstream::close()\n+{\n+    if (_filebuf.close() == NULL) {\n+        setstate(failbit);\n+    }\n+}\ndiff --git a/nspr/lib/prstreams/prstrms.h b/nspr/lib/prstreams/prstrms.h\nnew file mode 100644\nindex 0000000..113a416\n--- /dev/null\n+++ b/nspr/lib/prstreams/prstrms.h\n@@ -0,0 +1,154 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+ * Robin J. Maxwell 11-22-96\n+ * Fredrik Roubert <roubert@google.com> 2010-07-23\n+ * Matt Austern <austern@google.com> 2010-07-23\n+ */\n+\n+#ifndef _PRSTRMS_H\n+#define _PRSTRMS_H\n+\n+#include <cstddef>\n+#include <istream>\n+#include <ostream>\n+#include <streambuf>\n+\n+#include \"prio.h\"\n+\n+#ifdef _MSC_VER\n+// http://support.microsoft.com/kb/q168958/\n+class PR_IMPLEMENT(std::_Mutex);\n+class PR_IMPLEMENT(std::ios_base);\n+#endif\n+\n+\n+class PR_IMPLEMENT(PRfilebuf): public std::streambuf\n+{\n+public:\n+    PRfilebuf();\n+    PRfilebuf(PRFileDesc *fd);\n+    PRfilebuf(PRFileDesc *fd, char_type *ptr, std::streamsize len);\n+    virtual ~PRfilebuf();\n+\n+    bool is_open() const {\n+        return _fd != NULL;\n+    }\n+\n+    PRfilebuf *open(\n+        const char *name,\n+        std::ios_base::openmode flags,\n+        PRIntn mode);\n+    PRfilebuf *attach(PRFileDesc *fd);\n+    PRfilebuf *close();\n+\n+protected:\n+    virtual std::streambuf *setbuf(char_type *ptr, std::streamsize len);\n+    virtual pos_type seekoff(\n+        off_type offset,\n+        std::ios_base::seekdir dir,\n+        std::ios_base::openmode flags);\n+    virtual pos_type seekpos(\n+        pos_type pos,\n+        std::ios_base::openmode flags) {\n+        return seekoff(pos, std::ios_base::beg, flags);\n+    }\n+    virtual int sync();\n+    virtual int_type underflow();\n+    virtual int_type overflow(int_type c = traits_type::eof());\n+\n+    // TODO: Override pbackfail(), showmanyc(), uflow(), xsgetn(), and xsputn().\n+\n+private:\n+    bool allocate();\n+    void setb(char_type *buf_base, char_type *buf_end, bool user_buf);\n+\n+    PRFileDesc *_fd;\n+    bool _opened;\n+    bool _allocated;\n+    bool _unbuffered;\n+    bool _user_buf;\n+    char_type *_buf_base;\n+    char_type *_buf_end;\n+};\n+\n+\n+class PR_IMPLEMENT(PRifstream): public std::istream\n+{\n+public:\n+    PRifstream();\n+    PRifstream(PRFileDesc *fd);\n+    PRifstream(PRFileDesc *fd, char_type *ptr, std::streamsize len);\n+    PRifstream(const char *name, openmode flags = in, PRIntn mode = 0);\n+    virtual ~PRifstream();\n+\n+    PRfilebuf *rdbuf() const {\n+        return &_filebuf;\n+    }\n+    bool is_open() const {\n+        return _filebuf.is_open();\n+    }\n+\n+    void open(const char *name, openmode flags = in, PRIntn mode = 0);\n+    void attach(PRFileDesc *fd);\n+    void close();\n+\n+private:\n+    mutable PRfilebuf _filebuf;\n+};\n+\n+\n+class PR_IMPLEMENT(PRofstream): public std::ostream\n+{\n+public:\n+    PRofstream();\n+    PRofstream(PRFileDesc *fd);\n+    PRofstream(PRFileDesc *fd, char_type *ptr, std::streamsize len);\n+    PRofstream(const char *name, openmode flags = out, PRIntn mode = 0);\n+    virtual ~PRofstream();\n+\n+    PRfilebuf *rdbuf() const {\n+        return &_filebuf;\n+    }\n+    bool is_open() const {\n+        return _filebuf.is_open();\n+    }\n+\n+    void open(const char *name, openmode flags = out, PRIntn mode = 0);\n+    void attach(PRFileDesc *fd);\n+    void close();\n+\n+private:\n+    mutable PRfilebuf _filebuf;\n+};\n+\n+\n+class PR_IMPLEMENT(PRfstream): public std::iostream\n+{\n+public:\n+    PRfstream();\n+    PRfstream(PRFileDesc *fd);\n+    PRfstream(PRFileDesc *fd, char_type *ptr, std::streamsize len);\n+    PRfstream(const char *name, openmode flags = in | out, PRIntn mode = 0);\n+    virtual ~PRfstream();\n+\n+    PRfilebuf *rdbuf() const {\n+        return &_filebuf;\n+    }\n+    bool is_open() const {\n+        return _filebuf.is_open();\n+    }\n+\n+    void open(const char *name, openmode flags = in | out, PRIntn mode = 0);\n+    void attach(PRFileDesc *fd);\n+    void close();\n+\n+private:\n+    mutable PRfilebuf _filebuf;\n+};\n+\n+\n+#endif /* _PRSTRMS_H */\ndiff --git a/nspr/lib/prstreams/prstrms.rc b/nspr/lib/prstreams/prstrms.rc\nnew file mode 100644\nindex 0000000..1b7d703\n--- /dev/null\n+++ b/nspr/lib/prstreams/prstrms.rc\n@@ -0,0 +1,57 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+#include \"prinit.h\"\n+#include <winver.h>\n+\n+#define MY_LIBNAME \"prstrms\"\n+#define MY_FILEDESCRIPTION \"PRSTRMS Library\"\n+\n+#define STRINGIZE(x) #x\n+#define STRINGIZE2(x) STRINGIZE(x)\n+#define PR_VMAJOR_STR STRINGIZE2(PR_VMAJOR)\n+\n+#ifdef _DEBUG\n+#  define MY_DEBUG_STR \" (debug)\"\n+#  define MY_FILEFLAGS_1 VS_FF_DEBUG\n+#else\n+#  define MY_DEBUG_STR \"\"\n+#  define MY_FILEFLAGS_1 0x0L\n+#endif\n+#if PR_BETA\n+#  define MY_FILEFLAGS_2 MY_FILEFLAGS_1 | VS_FF_PRERELEASE\n+#else\n+#  define MY_FILEFLAGS_2 MY_FILEFLAGS_1\n+#endif\n+\n+#ifdef WINNT\n+#  define MY_FILEOS VOS_NT_WINDOWS32\n+#  define MY_INTERNAL_NAME \"lib\" MY_LIBNAME PR_VMAJOR_STR\n+#else\n+#  define MY_FILEOS VOS__WINDOWS32\n+#  define MY_INTERNAL_NAME MY_LIBNAME PR_VMAJOR_STR\n+#endif\n+\n+/////////////////////////////////////////////////////////////////////////////\n+//\n+// Version-information resource\n+//\n+\n+VS_VERSION_INFO VERSIONINFO FILEVERSION PR_VMAJOR, PR_VMINOR, PR_VPATCH,\n+    0 PRODUCTVERSION PR_VMAJOR, PR_VMINOR, PR_VPATCH,\n+    0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS MY_FILEFLAGS_2 FILEOS\n+        MY_FILEOS FILETYPE VFT_DLL FILESUBTYPE 0x0L  // not used\n+\n+    BEGIN BLOCK \"StringFileInfo\" BEGIN BLOCK\n+                \"040904B0\"  // Lang=US English, CharSet=Unicode\n+    BEGIN VALUE \"CompanyName\",\n+    \"Mozilla Foundation\\0\" VALUE \"FileDescription\",\n+    MY_FILEDESCRIPTION MY_DEBUG_STR \"\\0\" VALUE \"FileVersion\",\n+    PR_VERSION \"\\0\" VALUE \"InternalName\",\n+    MY_INTERNAL_NAME \"\\0\" VALUE \"OriginalFilename\",\n+    MY_INTERNAL_NAME \".dll\\0\" VALUE \"ProductName\",\n+    \"Netscape Portable Runtime\\0\" VALUE \"ProductVersion\",\n+    PR_VERSION \"\\0\" END END BLOCK \"VarFileInfo\" BEGIN VALUE \"Translation\",\n+    0x409, 1200 END END\ndiff --git a/nspr/lib/prstreams/tests/testprstrm/.cvsignore b/nspr/lib/prstreams/tests/testprstrm/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/lib/prstreams/tests/testprstrm/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/lib/prstreams/tests/testprstrm/Makefile.in b/nspr/lib/prstreams/tests/testprstrm/Makefile.in\nnew file mode 100644\nindex 0000000..d90eed2\n--- /dev/null\n+++ b/nspr/lib/prstreams/tests/testprstrm/Makefile.in\n@@ -0,0 +1,148 @@\n+# \n+# This Source Code Form is subject to the terms of the Mozilla Public\n+# License, v. 2.0. If a copy of the MPL was not distributed with this\n+# file, You can obtain one at http://mozilla.org/MPL/2.0/.\n+\n+#! gmake\n+\n+MOD_DEPTH\t= ../../../..\n+topsrcdir\t= @top_srcdir@\n+srcdir\t\t= @srcdir@\n+VPATH\t\t= @srcdir@\n+\n+include $(MOD_DEPTH)/config/autoconf.mk\n+\n+include $(topsrcdir)/config/config.mk\n+\n+CXXSRCS =           \\\n+\ttestprstrm.cpp    \\\n+\t$(NULL)\n+\n+OBJS = $(addprefix $(OBJDIR)/,$(CXXSRCS:.cpp=.$(OBJ_SUFFIX)))\n+\n+ifeq (,$(filter-out WINNT,$(OS_ARCH)))\n+PROG_SUFFIX = .exe\n+else\n+PROG_SUFFIX =\n+endif\n+\n+PROGS = $(addprefix $(OBJDIR)/, $(CXXSRCS:.cpp=$(PROG_SUFFIX)))\n+\n+TARGETS = $(PROGS) $(OBJS)\n+\n+INCLUDES = -I$(dist_includedir)\n+\n+# Setting the variables LDOPTS and LIBPR.  We first initialize\n+# them to the default values, then adjust them for some platforms.\n+LDOPTS = -L$(dist_libdir)\n+LIBPR = -lnspr$(MOD_MAJOR_VERSION)\n+LIBPRSTRMS = -lprstrms$(MOD_MAJOR_VERSION)\n+\n+ifeq ($(OS_ARCH), WINNT)\n+  LDOPTS = -NOLOGO -DEBUG -INCREMENTAL:NO\n+  ifeq ($(OS_TARGET), WIN95)\n+    LIBPR = $(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)\n+    LIBPRSTRMS = $(dist_libdir)/prstrms$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)\n+  else\n+    LIBPR = $(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)\n+    LIBPRSTRMS = $(dist_libdir)/libprstrms$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)\n+  endif\n+endif\n+\n+ifneq ($(OS_ARCH), WINNT)\n+PWD = $(shell pwd)\n+endif\n+\n+ifeq ($(OS_ARCH), HP-UX)\n+LDOPTS += -Wl,+s,+b,$(PWD)/$(dist_libdir)\n+endif\n+\n+# AIX\n+ifeq ($(OS_ARCH),AIX)\n+LDOPTS += -blibpath:$(PWD)/$(dist_libdir):/usr/lib:/lib\n+ifeq ($(OS_ARCH)$(OS_RELEASE),AIX4.1)\n+LIBPR = -lnspr$(MOD_MAJOR_VERSION)_shr\n+LIBPRSTRMS = -lprstrms$(MOD_MAJOR_VERSION)_shr\n+else\n+LDOPTS += -brtl\n+EXTRA_LIBS = -ldl\n+endif\n+endif\n+\n+# Solaris\n+ifeq ($(OS_ARCH), SunOS)\n+ifdef NS_USE_GCC\n+LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(dist_libdir)\n+else\n+LDOPTS += -R $(PWD)/$(dist_libdir)\n+# CC on SunOS 5.5.x needs to link with -lpthread even though we already\n+# linked with this system library when we built libnspr.so.\n+ifdef USE_PTHREADS\n+EXTRA_LIBS = -lpthread\n+endif # USE_PTHREADS\n+endif # NS_USE_GCC\n+endif # SunOS\n+\n+ifeq ($(OS_ARCH), SCOOS)\n+# SCO Unix needs to link against -lsocket again even though we\n+# already linked with these system libraries when we built libnspr.so.\n+EXTRA_LIBS = -lsocket\n+# This hardcodes in the executable programs the directory to find\n+# libnspr.so etc. at program startup.  Equivalent to the -R or -rpath\n+# option for ld on other platforms.\n+export LD_RUN_PATH = $(PWD)/$(dist_libdir)\n+endif\n+\n+#####################################################\n+#\n+# The rules\n+#\n+#####################################################\n+\n+include $(topsrcdir)/config/rules.mk\n+\n+AIX_PRE_4_2 = 0\n+ifeq ($(OS_ARCH),AIX)\n+ifneq ($(OS_RELEASE),4.2)\n+ifneq ($(USE_PTHREADS), 1)\n+#AIX_PRE_4_2 = 1\n+endif\n+endif\n+endif\n+\n+ifeq ($(AIX_PRE_4_2),1)\n+\n+# AIX releases prior to 4.2 need a special two-step linking hack\n+# in order to both override the system select() and be able to \n+# get at the original system select().\n+#\n+# We use a pattern rule in ns/nspr20/config/rules.mk to generate\n+# the .$(OBJ_SUFFIX) file from the .c source file, then do the\n+# two-step linking hack below.\n+\n+$(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)\n+\t@$(MAKE_OBJDIR)\n+\trm -f $@ $(AIX_TMP)\n+\t$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).a\n+\t$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)\n+\trm -f $(AIX_TMP)\n+\n+else\n+\n+# All platforms that are not AIX pre-4.2.\n+\n+$(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)\n+\t@$(MAKE_OBJDIR)\n+ifeq ($(OS_ARCH), WINNT)\n+\tlink $(LDOPTS) $< $(LIBPR) $(LIBPRSTRMS) ws2_32.lib -out:$@\n+else\n+\t$(CCC) $(XCFLAGS) $< $(LDOPTS) $(LIBPR) $(LIBPRSTRMS) $(EXTRA_LIBS) -o $@\n+endif\n+endif\n+\n+export:: $(TARGETS)\n+clean::\n+\trm -f $(TARGETS)\n+\n+testlinker:\n+\techo $(LINK)\ndiff --git a/nspr/lib/prstreams/tests/testprstrm/testprstrm.cpp b/nspr/lib/prstreams/tests/testprstrm/testprstrm.cpp\nnew file mode 100644\nindex 0000000..236e6ac\n--- /dev/null\n+++ b/nspr/lib/prstreams/tests/testprstrm/testprstrm.cpp\n@@ -0,0 +1,172 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+#include \"prstrms.h\"\n+\n+#include \"prinit.h\"\n+#include \"prio.h\"\n+#include \"prthread.h\"\n+\n+#include <cstring>\n+#include <iostream>\n+\n+#ifdef XP_UNIX\n+#include <sys/stat.h>\n+#endif\n+\n+using std::cout;\n+using std::endl;\n+using std::ios;\n+\n+const unsigned int MaxCnt = 1;\n+\n+typedef struct threadarg {\n+    const char *mytag;\n+} threadarg;\n+\n+void threadwork(threadarg *arg);\n+\n+void\n+threadmain(void *mytag)\n+{\n+    threadarg arg;\n+\n+    arg.mytag = static_cast<const char *>(mytag);\n+\n+    threadwork(&arg);\n+}\n+\n+void\n+threadwork(threadarg *arg)\n+{\n+    unsigned int i;\n+\n+    char fname1[256];\n+    char fname2[256];\n+\n+    strcpy(fname1, arg->mytag);\n+    strcpy(fname2, arg->mytag);\n+    strcat(fname2, \"2\");\n+    PR_Delete(fname1);\n+    PR_Delete(fname2);\n+\n+    PRfilebuf *fb[MaxCnt];\n+    PRifstream *ifs[MaxCnt];\n+    PRofstream *ofs[MaxCnt];\n+    int mode = 0;\n+#ifdef XP_UNIX\n+    mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;\n+#endif\n+\n+    //\n+    // Allocate a bunch\n+    cout << \"Testing unused filebufs ----------------\" << endl;\n+    for (i=0; i < MaxCnt; i++) {\n+        fb[i] = new PRfilebuf;\n+    }\n+    // Delete them\n+    for (i=0; i < MaxCnt; i++) {\n+        delete fb[i];\n+    }\n+    cout << \"Unused filebufs complete ---------------\" << endl;\n+\n+    //\n+    // Allocate a bunch\n+    cout << \"Testing unused ifstream -----------------\" << endl;\n+    for (i=0; i < MaxCnt; i++) {\n+        ifs[i] = new PRifstream;\n+    }\n+    //\n+    // Delete them\n+    for (i=0; i < MaxCnt; i++) {\n+        delete ifs[i];\n+    }\n+    cout << \"Unused ifstream complete ----------------\" << endl;\n+    //\n+    // Allocate a bunch\n+    cout << \"Testing unused ofstream -----------------\" << endl;\n+    for (i=0; i < MaxCnt; i++) {\n+        ofs[i] = new PRofstream;\n+    }\n+    for (i=0; i < MaxCnt; i++) {\n+        *(ofs[i]) << \"A\"; // Write a bit\n+        delete ofs[i]; // Delete it.\n+    }\n+    cout << \"Unused ofstream complete ----------------\" << endl;\n+\n+    cout << \"Testing use of ofstream 1 (extra filebuf allocated) ---------\" << endl;\n+    PRofstream *aos = new PRofstream(fname1, ios::out|ios::ate, mode);\n+    for (i=0; i < MaxCnt; i++) {\n+        for (int j=0; j < 8192; j++) {\n+            *aos << \"AaBbCcDdEeFfGg\" << endl;\n+        }\n+        fb[i] = new PRfilebuf; // Allocate as we go to hack at the heap\n+    }\n+    //\n+    // Delete the extra foo we allocated\n+    for (i=0; i < MaxCnt; i++) {\n+        delete fb[i];\n+    }\n+    aos->flush(); // Explicit flush\n+    delete aos;\n+    cout << \"Testing use of ofstream 1 complete (extra filebuf deleted) --\" << endl;\n+    cout << \"Testing use of ofstream 2 (extra filebuf allocated) ---------\" << endl;\n+    PRofstream *aos2 = new PRofstream(fname2, ios::out, mode);\n+\n+    for (i=0; i < MaxCnt; i++) {\n+        *aos2 << \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\";\n+    }\n+    // Force flushing in the dtor\n+    delete aos2;\n+    cout << \"Testing use of ofstream 2 complete (extra filebuf deleted) --\" << endl;\n+    char line[1024];\n+    cout << \"Testing use of ifstream 1 (stack allocation) -------------\" << endl;\n+    PRifstream ais(fname1);\n+    for (i=0; i < MaxCnt; i++) {\n+        ais >> line;\n+    }\n+    cout << \"Testing use of ifstream 1 complete -----------------------\" << endl;\n+    cout << \"Testing use of ifstream 2 ----------------------\" << endl;\n+    PRifstream *ais2 = new PRifstream(fname2);\n+    char achar;\n+    for (i=0; i < MaxCnt*10; i++) {\n+        *ais2 >> achar;\n+    }\n+    delete ais2;\n+    cout << \"Testing use of ifstream 2 complete -------------\" << endl;\n+}\n+\n+#define STACKSIZE 1024*1024\n+int\n+main()\n+{\n+    PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 256);\n+    threadmain(const_cast<char *>(\"TestFile\"));\n+    PRThread *thr1 = PR_CreateThread(PR_SYSTEM_THREAD,\n+                                     threadmain,\n+                                     const_cast<char *>(\"TestFile1\"),\n+                                     PR_PRIORITY_NORMAL,\n+                                     PR_GLOBAL_THREAD,\n+                                     PR_JOINABLE_THREAD,\n+                                     STACKSIZE);\n+    PRThread *thr2 = PR_CreateThread(PR_SYSTEM_THREAD,\n+                                     threadmain,\n+                                     const_cast<char *>(\"TestFile2\"),\n+                                     PR_PRIORITY_NORMAL,\n+                                     PR_GLOBAL_THREAD,\n+                                     PR_JOINABLE_THREAD,\n+                                     STACKSIZE);\n+    PRThread *thr3 = PR_CreateThread(PR_SYSTEM_THREAD,\n+                                     threadmain,\n+                                     const_cast<char *>(\"TestFile3\"),\n+                                     PR_PRIORITY_NORMAL,\n+                                     PR_GLOBAL_THREAD,\n+                                     PR_JOINABLE_THREAD,\n+                                     STACKSIZE);\n+    PR_JoinThread(thr1);\n+    PR_JoinThread(thr2);\n+    PR_JoinThread(thr3);\n+    return 0;\n+}\ndiff --git a/nspr/lib/tests/.cvsignore b/nspr/lib/tests/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/lib/tests/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/lib/tests/Makefile.in b/nspr/lib/tests/Makefile.in\nindex 9d87bdd..721e313 100644\n--- a/nspr/lib/tests/Makefile.in\n+++ b/nspr/lib/tests/Makefile.in\n@@ -152,7 +152,7 @@ else\n ifeq ($(OS_ARCH), WINCE)\n \t$(LD) $(LDOPTS) $< $(LIBPLC) $(LIBPLDS) $(LIBPR) ws2.lib -out:$@\n else\n-\t$(CC) $(XCFLAGS) $(LDFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBPLDS) $(LIBPR) $(EXTRA_LIBS) -o $@\n+\t$(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBPLDS) $(LIBPR) $(EXTRA_LIBS) -o $@\n endif\n endif\n endif\ndiff --git a/nspr/lib/tests/arena.c b/nspr/lib/tests/arena.c\nindex d1c5446..8a3bf37 100644\n--- a/nspr/lib/tests/arena.c\n+++ b/nspr/lib/tests/arena.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -30,143 +31,133 @@ PRIntn stressIterations = 15;\n PRIntn maxAlloc = (1024 * 1024);\n PRIntn stressThreads = 4;\n \n-void\n-DumpAll(void)\n-{\n-    return;\n-}\n+void DumpAll(void) { return; }\n \n /*\n ** Test Arena allocation.\n */\n-static void\n-ArenaAllocate(void)\n-{\n-    PLArenaPool ap;\n-    void* ptr;\n-    PRInt32 i;\n-\n-    PL_InitArenaPool(&ap, \"AllocArena\", 2048, sizeof(double));\n+static void ArenaAllocate(void) {\n+  PLArenaPool ap;\n+  void* ptr;\n+  PRInt32 i;\n+\n+  PL_InitArenaPool(&ap, \"AllocArena\", 2048, sizeof(double));\n+  PR_LOG(tLM, PR_LOG_DEBUG,\n+         (\"AA, InitPool -- Pool: %p. first: %p, current: %p, size: %d\", &ap,\n+          ap.first, ap.current, ap.arenasize));\n+\n+  for (i = 0; i < 150; i++) {\n+    PL_ARENA_ALLOCATE(ptr, &ap, 512);\n     PR_LOG(tLM, PR_LOG_DEBUG,\n-           (\"AA, InitPool -- Pool: %p. first: %p, current: %p, size: %d\", &ap,\n-            ap.first, ap.current, ap.arenasize));\n-\n-    for (i = 0; i < 150; i++) {\n-        PL_ARENA_ALLOCATE(ptr, &ap, 512);\n-        PR_LOG(tLM, PR_LOG_DEBUG,\n-               (\"AA, after alloc -- Pool: %p. first: %p, current: %p, size: %d\",\n-                &ap, ap.first, ap.current, ap.arenasize));\n-        PR_LOG(tLM, PR_LOG_DEBUG, (\"AA -- Pool: %p. alloc: %p \", &ap, ptr));\n-    }\n+           (\"AA, after alloc -- Pool: %p. first: %p, current: %p, size: %d\",\n+            &ap, ap.first, ap.current, ap.arenasize));\n+    PR_LOG(tLM, PR_LOG_DEBUG, (\"AA -- Pool: %p. alloc: %p \", &ap, ptr));\n+  }\n \n-    PL_FreeArenaPool(&ap);\n+  PL_FreeArenaPool(&ap);\n \n-    for (i = 0; i < 221; i++) {\n-        PL_ARENA_ALLOCATE(ptr, &ap, 512);\n-        PR_LOG(tLM, PR_LOG_DEBUG,\n-               (\"AA, after alloc -- Pool: %p. first: %p, current: %p, size: %d\",\n-                &ap, ap.first, ap.current, ap.arenasize));\n-        PR_LOG(tLM, PR_LOG_DEBUG, (\"AA -- Pool: %p. alloc: %p \", &ap, ptr));\n-    }\n+  for (i = 0; i < 221; i++) {\n+    PL_ARENA_ALLOCATE(ptr, &ap, 512);\n+    PR_LOG(tLM, PR_LOG_DEBUG,\n+           (\"AA, after alloc -- Pool: %p. first: %p, current: %p, size: %d\",\n+            &ap, ap.first, ap.current, ap.arenasize));\n+    PR_LOG(tLM, PR_LOG_DEBUG, (\"AA -- Pool: %p. alloc: %p \", &ap, ptr));\n+  }\n \n-    PL_FreeArenaPool(&ap);\n+  PL_FreeArenaPool(&ap);\n \n-    return;\n+  return;\n } /* end ArenaGrow() */\n /*\n ** Test Arena grow.\n */\n-static void\n-ArenaGrow(void)\n-{\n-    PLArenaPool ap;\n-    void* ptr;\n-    PRInt32 i;\n-\n-    PL_InitArenaPool(&ap, \"TheArena\", 4096, sizeof(double));\n-    PL_ARENA_ALLOCATE(ptr, &ap, 512);\n+static void ArenaGrow(void) {\n+  PLArenaPool ap;\n+  void* ptr;\n+  PRInt32 i;\n \n-    PR_LOG(tLM, PR_LOG_DEBUG,\n-           (\"Before growth -- Pool: %p. alloc: %p \", &ap, ptr));\n+  PL_InitArenaPool(&ap, \"TheArena\", 4096, sizeof(double));\n+  PL_ARENA_ALLOCATE(ptr, &ap, 512);\n \n-    for (i = 0; i < 10; i++) {\n-        PL_ARENA_GROW(ptr, &ap, 512, 7000);\n-        PR_LOG(tLM, PR_LOG_DEBUG,\n-               (\"After growth -- Pool: %p. alloc: %p \", &ap, ptr));\n-    }\n+  PR_LOG(tLM, PR_LOG_DEBUG,\n+         (\"Before growth -- Pool: %p. alloc: %p \", &ap, ptr));\n \n-    return;\n+  for (i = 0; i < 10; i++) {\n+    PL_ARENA_GROW(ptr, &ap, 512, 7000);\n+    PR_LOG(tLM, PR_LOG_DEBUG,\n+           (\"After growth -- Pool: %p. alloc: %p \", &ap, ptr));\n+  }\n+\n+  return;\n } /* end ArenaGrow() */\n \n /*\n ** Test arena Mark and Release.\n */\n-static void\n-MarkAndRelease(void)\n-{\n-    PLArenaPool ap;\n-    void* ptr = NULL;\n-    void *mark0, *mark1;\n-    PRIntn i;\n-\n-    PL_InitArenaPool(&ap, \"TheArena\", 4096, sizeof(double));\n-    mark0 = PL_ARENA_MARK(&ap);\n+static void MarkAndRelease(void) {\n+  PLArenaPool ap;\n+  void* ptr = NULL;\n+  void *mark0, *mark1;\n+  PRIntn i;\n+\n+  PL_InitArenaPool(&ap, \"TheArena\", 4096, sizeof(double));\n+  mark0 = PL_ARENA_MARK(&ap);\n+  PR_LOG(tLM, PR_LOG_DEBUG,\n+         (\"mark0. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p, m0: %p\",\n+          &ap, ap.first.next, ap.current, ap.arenasize, ptr, mark0));\n+\n+  for (i = 0; i < 201; i++) {\n+    PL_ARENA_ALLOCATE(ptr, &ap, 512);\n     PR_LOG(tLM, PR_LOG_DEBUG,\n-           (\"mark0. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p, m0: %p\",\n-            &ap, ap.first.next, ap.current, ap.arenasize, ptr, mark0));\n-\n-    for (i = 0; i < 201; i++) {\n-        PL_ARENA_ALLOCATE(ptr, &ap, 512);\n-        PR_LOG(tLM, PR_LOG_DEBUG,\n-               (\"mr. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n-                ap.first.next, ap.current, ap.arenasize, ptr));\n-    }\n+           (\"mr. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n+            ap.first.next, ap.current, ap.arenasize, ptr));\n+  }\n \n-    mark1 = PL_ARENA_MARK(&ap);\n-    PR_LOG(tLM, PR_LOG_DEBUG,\n-           (\"mark1. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p, m1: %p\",\n-            &ap, ap.first.next, ap.current, ap.arenasize, ptr, mark1));\n-\n-    for (i = 0; i < 225; i++) {\n-        PL_ARENA_ALLOCATE(ptr, &ap, 512);\n-        PR_LOG(tLM, PR_LOG_DEBUG,\n-               (\"mr. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n-                ap.first.next, ap.current, ap.arenasize, ptr));\n-    }\n+  mark1 = PL_ARENA_MARK(&ap);\n+  PR_LOG(tLM, PR_LOG_DEBUG,\n+         (\"mark1. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p, m1: %p\",\n+          &ap, ap.first.next, ap.current, ap.arenasize, ptr, mark1));\n \n-    PL_ARENA_RELEASE(&ap, mark1);\n+  for (i = 0; i < 225; i++) {\n+    PL_ARENA_ALLOCATE(ptr, &ap, 512);\n     PR_LOG(tLM, PR_LOG_DEBUG,\n-           (\"Release-1: %p -- Pool: %p. first: %p, current: %p, size: %d\", mark1,\n-            &ap, ap.first, ap.current, ap.arenasize));\n+           (\"mr. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n+            ap.first.next, ap.current, ap.arenasize, ptr));\n+  }\n \n-    for (i = 0; i < 20; i++) {\n-        PL_ARENA_ALLOCATE(ptr, &ap, 512);\n-        PR_LOG(tLM, PR_LOG_DEBUG,\n-               (\"mr. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n-                ap.first.next, ap.current, ap.arenasize, ptr));\n-    }\n+  PL_ARENA_RELEASE(&ap, mark1);\n+  PR_LOG(tLM, PR_LOG_DEBUG,\n+         (\"Release-1: %p -- Pool: %p. first: %p, current: %p, size: %d\", mark1,\n+          &ap, ap.first, ap.current, ap.arenasize));\n \n-    PL_ARENA_RELEASE(&ap, mark1);\n+  for (i = 0; i < 20; i++) {\n+    PL_ARENA_ALLOCATE(ptr, &ap, 512);\n     PR_LOG(tLM, PR_LOG_DEBUG,\n-           (\"Release-1. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n+           (\"mr. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n             ap.first.next, ap.current, ap.arenasize, ptr));\n+  }\n \n-    PL_ARENA_RELEASE(&ap, mark0);\n-    PR_LOG(tLM, PR_LOG_DEBUG,\n-           (\"Release-0. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n-            ap.first.next, ap.current, ap.arenasize, ptr));\n+  PL_ARENA_RELEASE(&ap, mark1);\n+  PR_LOG(tLM, PR_LOG_DEBUG,\n+         (\"Release-1. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n+          ap.first.next, ap.current, ap.arenasize, ptr));\n \n-    PL_FreeArenaPool(&ap);\n-    PR_LOG(tLM, PR_LOG_DEBUG,\n-           (\"Free. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n-            ap.first.next, ap.current, ap.arenasize, ptr));\n+  PL_ARENA_RELEASE(&ap, mark0);\n+  PR_LOG(tLM, PR_LOG_DEBUG,\n+         (\"Release-0. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n+          ap.first.next, ap.current, ap.arenasize, ptr));\n \n-    PL_FinishArenaPool(&ap);\n-    PR_LOG(tLM, PR_LOG_DEBUG,\n-           (\"Finish. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n-            ap.first.next, ap.current, ap.arenasize, ptr));\n+  PL_FreeArenaPool(&ap);\n+  PR_LOG(tLM, PR_LOG_DEBUG,\n+         (\"Free. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n+          ap.first.next, ap.current, ap.arenasize, ptr));\n+\n+  PL_FinishArenaPool(&ap);\n+  PR_LOG(tLM, PR_LOG_DEBUG,\n+         (\"Finish. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p\", &ap,\n+          ap.first.next, ap.current, ap.arenasize, ptr));\n \n-    return;\n+  return;\n } /* end MarkAndRelease() */\n \n /*\n@@ -174,14 +165,12 @@ MarkAndRelease(void)\n ** min..max, rounded to the next doubleword\n **\n */\n-static PRIntn\n-RandSize(PRIntn min, PRIntn max)\n-{\n-    PRIntn sz = (rand() % (max - min)) + min + sizeof(double);\n+static PRIntn RandSize(PRIntn min, PRIntn max) {\n+  PRIntn sz = (rand() % (max - min)) + min + sizeof(double);\n \n-    sz &= ~sizeof(double) - 1;\n+  sz &= ~sizeof(double) - 1;\n \n-    return (sz);\n+  return (sz);\n }\n \n /*\n@@ -190,47 +179,45 @@ RandSize(PRIntn min, PRIntn max)\n ** This tests the free_list protection.\n **\n */\n-static void PR_CALLBACK\n-StressThread(void* arg)\n-{\n-    PLArenaPool ap;\n-    PRIntn i;\n-    PRIntn sz;\n-    void* ptr;\n-    PRThread* tp = PR_GetCurrentThread();\n-\n-    PR_LOG(tLM, PR_LOG_DEBUG,\n-           (\"Stress Thread %p started\\n\", PR_GetCurrentThread()));\n-    PL_InitArenaPool(&ap, \"TheArena\", RandSize(poolMin, poolMax), sizeof(double));\n-\n-    for (i = 0; i < stressIterations; i++) {\n-        PRIntn allocated = 0;\n-\n-        while (allocated < maxAlloc) {\n-            sz = RandSize(arenaMin, arenaMax);\n-            PL_ARENA_ALLOCATE(ptr, &ap, sz);\n-            if (ptr == NULL) {\n-                PR_LOG(\n-                    tLM, PR_LOG_ERROR,\n-                    (\"ARENA_ALLOCATE() returned NULL\\n\\tAllocated: %d\\n\", allocated));\n-                break;\n-            }\n-            allocated += sz;\n-        }\n-        PR_LOG(tLM, PR_LOG_DEBUG,\n-               (\"Stress thread %p finished one iteration\\n\", tp));\n-        PL_FreeArenaPool(&ap);\n+static void PR_CALLBACK StressThread(void* arg) {\n+  PLArenaPool ap;\n+  PRIntn i;\n+  PRIntn sz;\n+  void* ptr;\n+  PRThread* tp = PR_GetCurrentThread();\n+\n+  PR_LOG(tLM, PR_LOG_DEBUG,\n+         (\"Stress Thread %p started\\n\", PR_GetCurrentThread()));\n+  PL_InitArenaPool(&ap, \"TheArena\", RandSize(poolMin, poolMax), sizeof(double));\n+\n+  for (i = 0; i < stressIterations; i++) {\n+    PRIntn allocated = 0;\n+\n+    while (allocated < maxAlloc) {\n+      sz = RandSize(arenaMin, arenaMax);\n+      PL_ARENA_ALLOCATE(ptr, &ap, sz);\n+      if (ptr == NULL) {\n+        PR_LOG(\n+            tLM, PR_LOG_ERROR,\n+            (\"ARENA_ALLOCATE() returned NULL\\n\\tAllocated: %d\\n\", allocated));\n+        break;\n+      }\n+      allocated += sz;\n     }\n-    PR_LOG(tLM, PR_LOG_DEBUG, (\"Stress thread %p finished all iteration\\n\", tp));\n-    PL_FinishArenaPool(&ap);\n-    PR_LOG(tLM, PR_LOG_DEBUG, (\"Stress thread %p after FinishArenaPool()\\n\", tp));\n-\n-    /* That's all folks! let's quit */\n-    PR_EnterMonitor(tMon);\n-    threadCount--;\n-    PR_Notify(tMon);\n-    PR_ExitMonitor(tMon);\n-    return;\n+    PR_LOG(tLM, PR_LOG_DEBUG,\n+           (\"Stress thread %p finished one iteration\\n\", tp));\n+    PL_FreeArenaPool(&ap);\n+  }\n+  PR_LOG(tLM, PR_LOG_DEBUG, (\"Stress thread %p finished all iteration\\n\", tp));\n+  PL_FinishArenaPool(&ap);\n+  PR_LOG(tLM, PR_LOG_DEBUG, (\"Stress thread %p after FinishArenaPool()\\n\", tp));\n+\n+  /* That's all folks! let's quit */\n+  PR_EnterMonitor(tMon);\n+  threadCount--;\n+  PR_Notify(tMon);\n+  PR_ExitMonitor(tMon);\n+  return;\n }\n \n /*\n@@ -239,31 +226,29 @@ StressThread(void* arg)\n ** Do NOT pass an individual arena to another thread.\n **\n */\n-static void\n-Stress(void)\n-{\n-    PRThread* tt;\n-    PRIntn i;\n-\n-    tMon = PR_NewMonitor();\n-\n-    for (i = 0; i < stressThreads; i++) {\n-        PR_EnterMonitor(tMon);\n-        tt = PR_CreateThread(PR_USER_THREAD, StressThread, NULL, PR_PRIORITY_NORMAL,\n-                             PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-        threadCount++;\n-        PR_ExitMonitor(tMon);\n-    }\n+static void Stress(void) {\n+  PRThread* tt;\n+  PRIntn i;\n+\n+  tMon = PR_NewMonitor();\n \n-    /* Wait for all threads to exit */\n+  for (i = 0; i < stressThreads; i++) {\n     PR_EnterMonitor(tMon);\n-    while (threadCount != 0) {\n-        PR_Wait(tMon, PR_INTERVAL_NO_TIMEOUT);\n-    }\n+    tt = PR_CreateThread(PR_USER_THREAD, StressThread, NULL, PR_PRIORITY_NORMAL,\n+                         PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+    threadCount++;\n     PR_ExitMonitor(tMon);\n-    PR_DestroyMonitor(tMon);\n+  }\n \n-    return;\n+  /* Wait for all threads to exit */\n+  PR_EnterMonitor(tMon);\n+  while (threadCount != 0) {\n+    PR_Wait(tMon, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_ExitMonitor(tMon);\n+  PR_DestroyMonitor(tMon);\n+\n+  return;\n } /* end Stress() */\n \n /*\n@@ -271,96 +256,90 @@ Stress(void)\n ** uses failed_already to display results and set program\n ** exit code.\n */\n-static PRIntn\n-EvaluateResults(void)\n-{\n-    PRIntn rc = 0;\n-\n-    if (failed_already == PR_TRUE) {\n-        PR_LOG(tLM, PR_LOG_DEBUG, (\"FAIL\\n\"));\n-        rc = 1;\n-    } else {\n-        PR_LOG(tLM, PR_LOG_DEBUG, (\"PASS\\n\"));\n-    }\n-    return (rc);\n+static PRIntn EvaluateResults(void) {\n+  PRIntn rc = 0;\n+\n+  if (failed_already == PR_TRUE) {\n+    PR_LOG(tLM, PR_LOG_DEBUG, (\"FAIL\\n\"));\n+    rc = 1;\n+  } else {\n+    PR_LOG(tLM, PR_LOG_DEBUG, (\"PASS\\n\"));\n+  }\n+  return (rc);\n } /* EvaluateResults() */\n \n-void\n-Help(void)\n-{\n-    printf(\"arena [options]\\n\");\n-    printf(\"where options are:\\n\");\n-    printf(\"-p <n>   minimum size of an arena pool. Default(%d)\\n\", poolMin);\n-    printf(\"-P <n>   maximum size of an arena pool. Default(%d)\\n\", poolMax);\n-    printf(\"-a <n>   minimum size of an arena allocation. Default(%d)\\n\",\n-           arenaMin);\n-    printf(\"-A <n>   maximum size of an arena allocation. Default(%d)\\n\",\n-           arenaMax);\n-    printf(\"-i <n>   number of iterations in a stress thread. Default(%d)\\n\",\n-           stressIterations);\n-    printf(\n-        \"-s <n>   maximum allocation for a single stress thread. Default(%d)\\n\",\n-        maxAlloc);\n-    printf(\"-t <n>   number of stress threads. Default(%d)\\n\", stressThreads);\n-    printf(\"-d       enable debug mode\\n\");\n-    printf(\"\\n\");\n-    exit(1);\n+void Help(void) {\n+  printf(\"arena [options]\\n\");\n+  printf(\"where options are:\\n\");\n+  printf(\"-p <n>   minimum size of an arena pool. Default(%d)\\n\", poolMin);\n+  printf(\"-P <n>   maximum size of an arena pool. Default(%d)\\n\", poolMax);\n+  printf(\"-a <n>   minimum size of an arena allocation. Default(%d)\\n\",\n+         arenaMin);\n+  printf(\"-A <n>   maximum size of an arena allocation. Default(%d)\\n\",\n+         arenaMax);\n+  printf(\"-i <n>   number of iterations in a stress thread. Default(%d)\\n\",\n+         stressIterations);\n+  printf(\n+      \"-s <n>   maximum allocation for a single stress thread. Default(%d)\\n\",\n+      maxAlloc);\n+  printf(\"-t <n>   number of stress threads. Default(%d)\\n\", stressThreads);\n+  printf(\"-d       enable debug mode\\n\");\n+  printf(\"\\n\");\n+  exit(1);\n }\n \n-PRIntn\n-main(PRIntn argc, char* argv[])\n-{\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dhp:P:a:A:i:s:t:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'a': /* arena Min size */\n-                arenaMin = atol(opt->value);\n-                break;\n-            case 'A': /* arena Max size  */\n-                arenaMax = atol(opt->value);\n-                break;\n-            case 'p': /* pool Min size */\n-                poolMin = atol(opt->value);\n-                break;\n-            case 'P': /* pool Max size */\n-                poolMax = atol(opt->value);\n-                break;\n-            case 'i': /* Iterations in stress tests */\n-                stressIterations = atol(opt->value);\n-                break;\n-            case 's': /* storage to get per iteration */\n-                maxAlloc = atol(opt->value);\n-                break;\n-            case 't': /* Number of stress threads to create */\n-                stressThreads = atol(opt->value);\n-                break;\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            case 'h': /* help */\n-            default:\n-                Help();\n-        } /* end switch() */\n-    } /* end while() */\n-    PL_DestroyOptState(opt);\n-\n-    srand((unsigned)time(NULL)); /* seed random number generator */\n-    tLM = PR_NewLogModule(\"testcase\");\n+PRIntn main(PRIntn argc, char* argv[]) {\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dhp:P:a:A:i:s:t:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'a': /* arena Min size */\n+        arenaMin = atol(opt->value);\n+        break;\n+      case 'A': /* arena Max size  */\n+        arenaMax = atol(opt->value);\n+        break;\n+      case 'p': /* pool Min size */\n+        poolMin = atol(opt->value);\n+        break;\n+      case 'P': /* pool Max size */\n+        poolMax = atol(opt->value);\n+        break;\n+      case 'i': /* Iterations in stress tests */\n+        stressIterations = atol(opt->value);\n+        break;\n+      case 's': /* storage to get per iteration */\n+        maxAlloc = atol(opt->value);\n+        break;\n+      case 't': /* Number of stress threads to create */\n+        stressThreads = atol(opt->value);\n+        break;\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      case 'h': /* help */\n+      default:\n+        Help();\n+    } /* end switch() */\n+  } /* end while() */\n+  PL_DestroyOptState(opt);\n+\n+  srand((unsigned)time(NULL)); /* seed random number generator */\n+  tLM = PR_NewLogModule(\"testcase\");\n \n #if 0\n     ArenaAllocate();\n     ArenaGrow();\n #endif\n \n-    MarkAndRelease();\n+  MarkAndRelease();\n \n-    Stress();\n+  Stress();\n \n-    return (EvaluateResults());\n+  return (EvaluateResults());\n } /* end main() */\n \n /* arena.c */\ndiff --git a/nspr/lib/tests/base64t.c b/nspr/lib/tests/base64t.c\nindex 6c105ff..5b6b8fc 100644\n--- a/nspr/lib/tests/base64t.c\n+++ b/nspr/lib/tests/base64t.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,3242 +9,3171 @@\n \n #include <stdio.h>\n \n-static unsigned char* base = (unsigned char*)\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n+static unsigned char *base = (unsigned char *)\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n \n /* PL_Base64Encode, single characters */\n-PRBool\n-test_001(void)\n-{\n-    PRUint32 a, b;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char result[8];\n-    char* rv;\n-\n-    printf(\n-        \"Test 001 (PL_Base64Encode, single characters)                         \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    plain[1] = plain[2] = plain[3] = (unsigned char)0;\n-    cypher[2] = cypher[3] = (unsigned char)'=';\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (unsigned char)(a * 4 + b);\n-            cypher[1] = base[(b * 16)];\n-\n-            rv = PL_Base64Encode((char*)plain, 1, result);\n-            if (rv != result) {\n-                printf(\"FAIL\\n\\t(%d, %d): return value\\n\", a, b);\n-                return PR_FALSE;\n-            }\n-\n-            if (0 != PL_strncmp((char*)cypher, result, 4)) {\n-                printf(\"FAIL\\n\\t(%d, %d): expected \\\"%s,\\\" got \\\"%.4s.\\\"\\n\", a, b,\n-                       cypher, result);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_001(void) {\n+  PRUint32 a, b;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char result[8];\n+  char* rv;\n+\n+  printf(\n+      \"Test 001 (PL_Base64Encode, single characters)                         \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  plain[1] = plain[2] = plain[3] = (unsigned char)0;\n+  cypher[2] = cypher[3] = (unsigned char)'=';\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (unsigned char)(a * 4 + b);\n+      cypher[1] = base[(b * 16)];\n+\n+      rv = PL_Base64Encode((char*)plain, 1, result);\n+      if (rv != result) {\n+        printf(\"FAIL\\n\\t(%d, %d): return value\\n\", a, b);\n+        return PR_FALSE;\n+      }\n+\n+      if (0 != PL_strncmp((char*)cypher, result, 4)) {\n+        printf(\"FAIL\\n\\t(%d, %d): expected \\\"%s,\\\" got \\\"%.4s.\\\"\\n\", a, b,\n+               cypher, result);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Encode, double characters */\n-PRBool\n-test_002(void)\n-{\n-    PRUint32 a, b, c, d;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char result[8];\n-    char* rv;\n-\n-    printf(\n-        \"Test 002 (PL_Base64Encode, double characters)                         \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    plain[2] = plain[3] = (unsigned char)0;\n-    cypher[3] = (unsigned char)'=';\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (a * 4) + b;\n-            for (c = 0; c < 16; c++) {\n-                cypher[1] = base[b * 16 + c];\n-                for (d = 0; d < 16; d++) {\n-                    plain[1] = c * 16 + d;\n-                    cypher[2] = base[d * 4];\n-\n-                    rv = PL_Base64Encode((char*)plain, 2, result);\n-                    if (rv != result) {\n-                        printf(\"FAIL\\n\\t(%d, %d, %d, %d): return value\\n\", a, b, c, d);\n-                        return PR_FALSE;\n-                    }\n-\n-                    if (0 != PL_strncmp((char*)cypher, result, 4)) {\n-                        printf(\"FAIL\\n\\t(%d, %d, %d, %d): expected \\\"%s,\\\" got \\\"%.4s.\\\"\\n\",\n-                               a, b, c, d, cypher, result);\n-                        return PR_FALSE;\n-                    }\n-                }\n-            }\n+PRBool test_002(void) {\n+  PRUint32 a, b, c, d;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char result[8];\n+  char* rv;\n+\n+  printf(\n+      \"Test 002 (PL_Base64Encode, double characters)                         \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  plain[2] = plain[3] = (unsigned char)0;\n+  cypher[3] = (unsigned char)'=';\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (a * 4) + b;\n+      for (c = 0; c < 16; c++) {\n+        cypher[1] = base[b * 16 + c];\n+        for (d = 0; d < 16; d++) {\n+          plain[1] = c * 16 + d;\n+          cypher[2] = base[d * 4];\n+\n+          rv = PL_Base64Encode((char*)plain, 2, result);\n+          if (rv != result) {\n+            printf(\"FAIL\\n\\t(%d, %d, %d, %d): return value\\n\", a, b, c, d);\n+            return PR_FALSE;\n+          }\n+\n+          if (0 != PL_strncmp((char*)cypher, result, 4)) {\n+            printf(\"FAIL\\n\\t(%d, %d, %d, %d): expected \\\"%s,\\\" got \\\"%.4s.\\\"\\n\",\n+                   a, b, c, d, cypher, result);\n+            return PR_FALSE;\n+          }\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Encode, triple characters */\n-PRBool\n-test_003(void)\n-{\n-    PRUint32 a, b, c, d, e, f;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char result[8];\n-    char* rv;\n-\n-    printf(\n-        \"Test 003 (PL_Base64Encode, triple characters)                         \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (a * 4) + b;\n-            for (c = 0; c < 16; c++) {\n-                cypher[1] = base[b * 16 + c];\n-                for (d = 0; d < 16; d++) {\n-                    plain[1] = c * 16 + d;\n-                    for (e = 0; e < 4; e++) {\n-                        cypher[2] = base[d * 4 + e];\n-                        for (f = 0; f < 64; f++) {\n-                            plain[2] = e * 64 + f;\n-                            cypher[3] = base[f];\n-\n-                            rv = PL_Base64Encode((char*)plain, 3, result);\n-                            if (rv != result) {\n-                                printf(\"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): return value\\n\", a, b,\n-                                       c, d, e, f);\n-                                return PR_FALSE;\n-                            }\n-\n-                            if (0 != PL_strncmp((char*)cypher, result, 4)) {\n-                                printf(\n-                                    \"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): expected \\\"%s,\\\" got \"\n-                                    \"\\\"%.4s.\\\"\\n\",\n-                                    a, b, c, d, e, f, cypher, result);\n-                                return PR_FALSE;\n-                            }\n-                        }\n-                    }\n-                }\n+PRBool test_003(void) {\n+  PRUint32 a, b, c, d, e, f;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char result[8];\n+  char* rv;\n+\n+  printf(\n+      \"Test 003 (PL_Base64Encode, triple characters)                         \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (a * 4) + b;\n+      for (c = 0; c < 16; c++) {\n+        cypher[1] = base[b * 16 + c];\n+        for (d = 0; d < 16; d++) {\n+          plain[1] = c * 16 + d;\n+          for (e = 0; e < 4; e++) {\n+            cypher[2] = base[d * 4 + e];\n+            for (f = 0; f < 64; f++) {\n+              plain[2] = e * 64 + f;\n+              cypher[3] = base[f];\n+\n+              rv = PL_Base64Encode((char*)plain, 3, result);\n+              if (rv != result) {\n+                printf(\"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): return value\\n\", a, b,\n+                       c, d, e, f);\n+                return PR_FALSE;\n+              }\n+\n+              if (0 != PL_strncmp((char*)cypher, result, 4)) {\n+                printf(\n+                    \"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): expected \\\"%s,\\\" got \"\n+                    \"\\\"%.4s.\\\"\\n\",\n+                    a, b, c, d, e, f, cypher, result);\n+                return PR_FALSE;\n+              }\n             }\n+          }\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n static struct {\n-    const char* plaintext;\n-    const char* cyphertext;\n+  const char* plaintext;\n+  const char* cyphertext;\n } array[] = {\n     /* Cyphertexts generated with uuenview 0.5.13 */\n-    { \" \", \"IA==\" },\n-    { \".\", \"Lg==\" },\n-    { \"/\", \"Lw==\" },\n-    { \"C\", \"Qw==\" },\n-    { \"H\", \"SA==\" },\n-    { \"S\", \"Uw==\" },\n-    { \"^\", \"Xg==\" },\n-    { \"a\", \"YQ==\" },\n-    { \"o\", \"bw==\" },\n-    { \"t\", \"dA==\" },\n-\n-    { \"AB\", \"QUI=\" },\n-    { \"AH\", \"QUg=\" },\n-    { \"AQ\", \"QVE=\" },\n-    { \"BD\", \"QkQ=\" },\n-    { \"CR\", \"Q1I=\" },\n-    { \"CS\", \"Q1M=\" },\n-    { \"DB\", \"REI=\" },\n-    { \"DC\", \"REM=\" },\n-    { \"EK\", \"RUs=\" },\n-    { \"ET\", \"RVQ=\" },\n-    { \"IM\", \"SU0=\" },\n-    { \"JR\", \"SlI=\" },\n-    { \"LO\", \"TE8=\" },\n-    { \"LW\", \"TFc=\" },\n-    { \"ML\", \"TUw=\" },\n-    { \"SB\", \"U0I=\" },\n-    { \"TO\", \"VE8=\" },\n-    { \"VS\", \"VlM=\" },\n-    { \"WP\", \"V1A=\" },\n+    {\" \", \"IA==\"},\n+    {\".\", \"Lg==\"},\n+    {\"/\", \"Lw==\"},\n+    {\"C\", \"Qw==\"},\n+    {\"H\", \"SA==\"},\n+    {\"S\", \"Uw==\"},\n+    {\"^\", \"Xg==\"},\n+    {\"a\", \"YQ==\"},\n+    {\"o\", \"bw==\"},\n+    {\"t\", \"dA==\"},\n+\n+    {\"AB\", \"QUI=\"},\n+    {\"AH\", \"QUg=\"},\n+    {\"AQ\", \"QVE=\"},\n+    {\"BD\", \"QkQ=\"},\n+    {\"CR\", \"Q1I=\"},\n+    {\"CS\", \"Q1M=\"},\n+    {\"DB\", \"REI=\"},\n+    {\"DC\", \"REM=\"},\n+    {\"EK\", \"RUs=\"},\n+    {\"ET\", \"RVQ=\"},\n+    {\"IM\", \"SU0=\"},\n+    {\"JR\", \"SlI=\"},\n+    {\"LO\", \"TE8=\"},\n+    {\"LW\", \"TFc=\"},\n+    {\"ML\", \"TUw=\"},\n+    {\"SB\", \"U0I=\"},\n+    {\"TO\", \"VE8=\"},\n+    {\"VS\", \"VlM=\"},\n+    {\"WP\", \"V1A=\"},\n     /* legitimate two-letter words */\n-    { \"ad\", \"YWQ=\" },\n-    { \"ah\", \"YWg=\" },\n-    { \"am\", \"YW0=\" },\n-    { \"an\", \"YW4=\" },\n-    { \"as\", \"YXM=\" },\n-    { \"at\", \"YXQ=\" },\n-    { \"ax\", \"YXg=\" },\n-    { \"be\", \"YmU=\" },\n-    { \"by\", \"Ynk=\" },\n-    { \"do\", \"ZG8=\" },\n-    { \"go\", \"Z28=\" },\n-    { \"he\", \"aGU=\" },\n-    { \"hi\", \"aGk=\" },\n-    { \"if\", \"aWY=\" },\n-    { \"in\", \"aW4=\" },\n-    { \"is\", \"aXM=\" },\n-    { \"it\", \"aXQ=\" },\n-    { \"me\", \"bWU=\" },\n-    { \"my\", \"bXk=\" },\n-    { \"no\", \"bm8=\" },\n-    { \"of\", \"b2Y=\" },\n-    { \"on\", \"b24=\" },\n-    { \"or\", \"b3I=\" },\n-    { \"ox\", \"b3g=\" },\n-    { \"so\", \"c28=\" },\n-    { \"to\", \"dG8=\" },\n-    { \"up\", \"dXA=\" },\n-    { \"us\", \"dXM=\" },\n-    { \"we\", \"d2U=\" },\n+    {\"ad\", \"YWQ=\"},\n+    {\"ah\", \"YWg=\"},\n+    {\"am\", \"YW0=\"},\n+    {\"an\", \"YW4=\"},\n+    {\"as\", \"YXM=\"},\n+    {\"at\", \"YXQ=\"},\n+    {\"ax\", \"YXg=\"},\n+    {\"be\", \"YmU=\"},\n+    {\"by\", \"Ynk=\"},\n+    {\"do\", \"ZG8=\"},\n+    {\"go\", \"Z28=\"},\n+    {\"he\", \"aGU=\"},\n+    {\"hi\", \"aGk=\"},\n+    {\"if\", \"aWY=\"},\n+    {\"in\", \"aW4=\"},\n+    {\"is\", \"aXM=\"},\n+    {\"it\", \"aXQ=\"},\n+    {\"me\", \"bWU=\"},\n+    {\"my\", \"bXk=\"},\n+    {\"no\", \"bm8=\"},\n+    {\"of\", \"b2Y=\"},\n+    {\"on\", \"b24=\"},\n+    {\"or\", \"b3I=\"},\n+    {\"ox\", \"b3g=\"},\n+    {\"so\", \"c28=\"},\n+    {\"to\", \"dG8=\"},\n+    {\"up\", \"dXA=\"},\n+    {\"us\", \"dXM=\"},\n+    {\"we\", \"d2U=\"},\n     /* all three-letter entries in /usr/dict/words */\n-    { \"1st\", \"MXN0\" },\n-    { \"2nd\", \"Mm5k\" },\n-    { \"3rd\", \"M3Jk\" },\n-    { \"4th\", \"NHRo\" },\n-    { \"5th\", \"NXRo\" },\n-    { \"6th\", \"NnRo\" },\n-    { \"7th\", \"N3Ro\" },\n-    { \"8th\", \"OHRo\" },\n-    { \"9th\", \"OXRo\" },\n-    { \"AAA\", \"QUFB\" },\n-    { \"AAU\", \"QUFV\" },\n-    { \"ABA\", \"QUJB\" },\n-    { \"abc\", \"YWJj\" },\n-    { \"Abe\", \"QWJl\" },\n-    { \"Abo\", \"QWJv\" },\n-    { \"ace\", \"YWNl\" },\n-    { \"ACM\", \"QUNN\" },\n-    { \"ACS\", \"QUNT\" },\n-    { \"act\", \"YWN0\" },\n-    { \"Ada\", \"QWRh\" },\n-    { \"add\", \"YWRk\" },\n-    { \"ado\", \"YWRv\" },\n-    { \"aft\", \"YWZ0\" },\n-    { \"age\", \"YWdl\" },\n-    { \"ago\", \"YWdv\" },\n-    { \"aid\", \"YWlk\" },\n-    { \"ail\", \"YWls\" },\n-    { \"aim\", \"YWlt\" },\n-    { \"air\", \"YWly\" },\n-    { \"ala\", \"YWxh\" },\n-    { \"alb\", \"YWxi\" },\n-    { \"ale\", \"YWxl\" },\n-    { \"Ali\", \"QWxp\" },\n-    { \"all\", \"YWxs\" },\n-    { \"alp\", \"YWxw\" },\n-    { \"A&M\", \"QSZN\" },\n-    { \"AMA\", \"QU1B\" },\n-    { \"ami\", \"YW1p\" },\n-    { \"amp\", \"YW1w\" },\n-    { \"Amy\", \"QW15\" },\n-    { \"amy\", \"YW15\" },\n-    { \"ana\", \"YW5h\" },\n-    { \"and\", \"YW5k\" },\n-    { \"ani\", \"YW5p\" },\n-    { \"Ann\", \"QW5u\" },\n-    { \"ant\", \"YW50\" },\n-    { \"any\", \"YW55\" },\n-    { \"A&P\", \"QSZQ\" },\n-    { \"ape\", \"YXBl\" },\n-    { \"Apr\", \"QXBy\" },\n-    { \"APS\", \"QVBT\" },\n-    { \"apt\", \"YXB0\" },\n-    { \"arc\", \"YXJj\" },\n-    { \"are\", \"YXJl\" },\n-    { \"ark\", \"YXJr\" },\n-    { \"arm\", \"YXJt\" },\n-    { \"art\", \"YXJ0\" },\n-    { \"a's\", \"YSdz\" },\n-    { \"ash\", \"YXNo\" },\n-    { \"ask\", \"YXNr\" },\n-    { \"ass\", \"YXNz\" },\n-    { \"ate\", \"YXRl\" },\n-    { \"Aug\", \"QXVn\" },\n-    { \"auk\", \"YXVr\" },\n-    { \"Ave\", \"QXZl\" },\n-    { \"awe\", \"YXdl\" },\n-    { \"awl\", \"YXds\" },\n-    { \"awn\", \"YXdu\" },\n-    { \"axe\", \"YXhl\" },\n-    { \"aye\", \"YXll\" },\n-    { \"bad\", \"YmFk\" },\n-    { \"bag\", \"YmFn\" },\n-    { \"bah\", \"YmFo\" },\n-    { \"bam\", \"YmFt\" },\n-    { \"ban\", \"YmFu\" },\n-    { \"bar\", \"YmFy\" },\n-    { \"bat\", \"YmF0\" },\n-    { \"bay\", \"YmF5\" },\n-    { \"bed\", \"YmVk\" },\n-    { \"bee\", \"YmVl\" },\n-    { \"beg\", \"YmVn\" },\n-    { \"bel\", \"YmVs\" },\n-    { \"Ben\", \"QmVu\" },\n-    { \"bet\", \"YmV0\" },\n-    { \"bey\", \"YmV5\" },\n-    { \"bib\", \"Ymli\" },\n-    { \"bid\", \"Ymlk\" },\n-    { \"big\", \"Ymln\" },\n-    { \"bin\", \"Ymlu\" },\n-    { \"bit\", \"Yml0\" },\n-    { \"biz\", \"Yml6\" },\n-    { \"BMW\", \"Qk1X\" },\n-    { \"boa\", \"Ym9h\" },\n-    { \"bob\", \"Ym9i\" },\n-    { \"bog\", \"Ym9n\" },\n-    { \"bon\", \"Ym9u\" },\n-    { \"boo\", \"Ym9v\" },\n-    { \"bop\", \"Ym9w\" },\n-    { \"bow\", \"Ym93\" },\n-    { \"box\", \"Ym94\" },\n-    { \"boy\", \"Ym95\" },\n-    { \"b's\", \"Yidz\" },\n-    { \"BTL\", \"QlRM\" },\n-    { \"BTU\", \"QlRV\" },\n-    { \"bub\", \"YnVi\" },\n-    { \"bud\", \"YnVk\" },\n-    { \"bug\", \"YnVn\" },\n-    { \"bum\", \"YnVt\" },\n-    { \"bun\", \"YnVu\" },\n-    { \"bus\", \"YnVz\" },\n-    { \"but\", \"YnV0\" },\n-    { \"buy\", \"YnV5\" },\n-    { \"bye\", \"Ynll\" },\n-    { \"cab\", \"Y2Fi\" },\n-    { \"Cal\", \"Q2Fs\" },\n-    { \"cam\", \"Y2Ft\" },\n-    { \"can\", \"Y2Fu\" },\n-    { \"cap\", \"Y2Fw\" },\n-    { \"car\", \"Y2Fy\" },\n-    { \"cat\", \"Y2F0\" },\n-    { \"caw\", \"Y2F3\" },\n-    { \"CBS\", \"Q0JT\" },\n-    { \"CDC\", \"Q0RD\" },\n-    { \"CEQ\", \"Q0VR\" },\n-    { \"chi\", \"Y2hp\" },\n-    { \"CIA\", \"Q0lB\" },\n-    { \"cit\", \"Y2l0\" },\n-    { \"cod\", \"Y29k\" },\n-    { \"cog\", \"Y29n\" },\n-    { \"col\", \"Y29s\" },\n-    { \"con\", \"Y29u\" },\n-    { \"coo\", \"Y29v\" },\n-    { \"cop\", \"Y29w\" },\n-    { \"cos\", \"Y29z\" },\n-    { \"cot\", \"Y290\" },\n-    { \"cow\", \"Y293\" },\n-    { \"cox\", \"Y294\" },\n-    { \"coy\", \"Y295\" },\n-    { \"CPA\", \"Q1BB\" },\n-    { \"cpu\", \"Y3B1\" },\n-    { \"CRT\", \"Q1JU\" },\n-    { \"cry\", \"Y3J5\" },\n-    { \"c's\", \"Yydz\" },\n-    { \"cub\", \"Y3Vi\" },\n-    { \"cud\", \"Y3Vk\" },\n-    { \"cue\", \"Y3Vl\" },\n-    { \"cup\", \"Y3Vw\" },\n-    { \"cur\", \"Y3Vy\" },\n-    { \"cut\", \"Y3V0\" },\n-    { \"dab\", \"ZGFi\" },\n-    { \"dad\", \"ZGFk\" },\n-    { \"dam\", \"ZGFt\" },\n-    { \"Dan\", \"RGFu\" },\n-    { \"Dar\", \"RGFy\" },\n-    { \"day\", \"ZGF5\" },\n-    { \"Dec\", \"RGVj\" },\n-    { \"Dee\", \"RGVl\" },\n-    { \"Del\", \"RGVs\" },\n-    { \"den\", \"ZGVu\" },\n-    { \"Des\", \"RGVz\" },\n-    { \"dew\", \"ZGV3\" },\n-    { \"dey\", \"ZGV5\" },\n-    { \"did\", \"ZGlk\" },\n-    { \"die\", \"ZGll\" },\n-    { \"dig\", \"ZGln\" },\n-    { \"dim\", \"ZGlt\" },\n-    { \"din\", \"ZGlu\" },\n-    { \"dip\", \"ZGlw\" },\n-    { \"Dis\", \"RGlz\" },\n-    { \"DNA\", \"RE5B\" },\n-    { \"DOD\", \"RE9E\" },\n-    { \"doe\", \"ZG9l\" },\n-    { \"dog\", \"ZG9n\" },\n-    { \"don\", \"ZG9u\" },\n-    { \"dot\", \"ZG90\" },\n-    { \"Dow\", \"RG93\" },\n-    { \"dry\", \"ZHJ5\" },\n-    { \"d's\", \"ZCdz\" },\n-    { \"dub\", \"ZHVi\" },\n-    { \"dud\", \"ZHVk\" },\n-    { \"due\", \"ZHVl\" },\n-    { \"dug\", \"ZHVn\" },\n-    { \"dun\", \"ZHVu\" },\n-    { \"dye\", \"ZHll\" },\n-    { \"ear\", \"ZWFy\" },\n-    { \"eat\", \"ZWF0\" },\n-    { \"ebb\", \"ZWJi\" },\n-    { \"EDT\", \"RURU\" },\n-    { \"eel\", \"ZWVs\" },\n-    { \"eft\", \"ZWZ0\" },\n-    { \"e.g\", \"ZS5n\" },\n-    { \"egg\", \"ZWdn\" },\n-    { \"ego\", \"ZWdv\" },\n-    { \"eke\", \"ZWtl\" },\n-    { \"Eli\", \"RWxp\" },\n-    { \"elk\", \"ZWxr\" },\n-    { \"ell\", \"ZWxs\" },\n-    { \"elm\", \"ZWxt\" },\n-    { \"Ely\", \"RWx5\" },\n-    { \"end\", \"ZW5k\" },\n-    { \"Eng\", \"RW5n\" },\n-    { \"EPA\", \"RVBB\" },\n-    { \"era\", \"ZXJh\" },\n-    { \"ere\", \"ZXJl\" },\n-    { \"erg\", \"ZXJn\" },\n-    { \"err\", \"ZXJy\" },\n-    { \"e's\", \"ZSdz\" },\n-    { \"EST\", \"RVNU\" },\n-    { \"eta\", \"ZXRh\" },\n-    { \"etc\", \"ZXRj\" },\n-    { \"Eva\", \"RXZh\" },\n-    { \"eve\", \"ZXZl\" },\n-    { \"ewe\", \"ZXdl\" },\n-    { \"eye\", \"ZXll\" },\n-    { \"FAA\", \"RkFB\" },\n-    { \"fad\", \"ZmFk\" },\n-    { \"fag\", \"ZmFn\" },\n-    { \"fan\", \"ZmFu\" },\n-    { \"far\", \"ZmFy\" },\n-    { \"fat\", \"ZmF0\" },\n-    { \"fay\", \"ZmF5\" },\n-    { \"FBI\", \"RkJJ\" },\n-    { \"FCC\", \"RkND\" },\n-    { \"FDA\", \"RkRB\" },\n-    { \"Feb\", \"RmVi\" },\n-    { \"fed\", \"ZmVk\" },\n-    { \"fee\", \"ZmVl\" },\n-    { \"few\", \"ZmV3\" },\n-    { \"fib\", \"Zmli\" },\n-    { \"fig\", \"Zmln\" },\n-    { \"fin\", \"Zmlu\" },\n-    { \"fir\", \"Zmly\" },\n-    { \"fit\", \"Zml0\" },\n-    { \"fix\", \"Zml4\" },\n-    { \"Flo\", \"Rmxv\" },\n-    { \"flu\", \"Zmx1\" },\n-    { \"fly\", \"Zmx5\" },\n-    { \"FMC\", \"Rk1D\" },\n-    { \"fob\", \"Zm9i\" },\n-    { \"foe\", \"Zm9l\" },\n-    { \"fog\", \"Zm9n\" },\n-    { \"fop\", \"Zm9w\" },\n-    { \"for\", \"Zm9y\" },\n-    { \"fox\", \"Zm94\" },\n-    { \"FPC\", \"RlBD\" },\n-    { \"fro\", \"ZnJv\" },\n-    { \"fry\", \"ZnJ5\" },\n-    { \"f's\", \"Zidz\" },\n-    { \"FTC\", \"RlRD\" },\n-    { \"fum\", \"ZnVt\" },\n-    { \"fun\", \"ZnVu\" },\n-    { \"fur\", \"ZnVy\" },\n-    { \"gab\", \"Z2Fi\" },\n-    { \"gad\", \"Z2Fk\" },\n-    { \"gag\", \"Z2Fn\" },\n-    { \"gal\", \"Z2Fs\" },\n-    { \"gam\", \"Z2Ft\" },\n-    { \"GAO\", \"R0FP\" },\n-    { \"gap\", \"Z2Fw\" },\n-    { \"gar\", \"Z2Fy\" },\n-    { \"gas\", \"Z2Fz\" },\n-    { \"gay\", \"Z2F5\" },\n-    { \"gee\", \"Z2Vl\" },\n-    { \"gel\", \"Z2Vs\" },\n-    { \"gem\", \"Z2Vt\" },\n-    { \"get\", \"Z2V0\" },\n-    { \"gig\", \"Z2ln\" },\n-    { \"Gil\", \"R2ls\" },\n-    { \"gin\", \"Z2lu\" },\n-    { \"GMT\", \"R01U\" },\n-    { \"GNP\", \"R05Q\" },\n-    { \"gnu\", \"Z251\" },\n-    { \"Goa\", \"R29h\" },\n-    { \"gob\", \"Z29i\" },\n-    { \"god\", \"Z29k\" },\n-    { \"gog\", \"Z29n\" },\n-    { \"GOP\", \"R09Q\" },\n-    { \"got\", \"Z290\" },\n-    { \"GPO\", \"R1BP\" },\n-    { \"g's\", \"Zydz\" },\n-    { \"GSA\", \"R1NB\" },\n-    { \"gum\", \"Z3Vt\" },\n-    { \"gun\", \"Z3Vu\" },\n-    { \"Gus\", \"R3Vz\" },\n-    { \"gut\", \"Z3V0\" },\n-    { \"guy\", \"Z3V5\" },\n-    { \"gym\", \"Z3lt\" },\n-    { \"gyp\", \"Z3lw\" },\n-    { \"had\", \"aGFk\" },\n-    { \"Hal\", \"SGFs\" },\n-    { \"ham\", \"aGFt\" },\n-    { \"Han\", \"SGFu\" },\n-    { \"hap\", \"aGFw\" },\n-    { \"hat\", \"aGF0\" },\n-    { \"haw\", \"aGF3\" },\n-    { \"hay\", \"aGF5\" },\n-    { \"hem\", \"aGVt\" },\n-    { \"hen\", \"aGVu\" },\n-    { \"her\", \"aGVy\" },\n-    { \"hew\", \"aGV3\" },\n-    { \"hex\", \"aGV4\" },\n-    { \"hey\", \"aGV5\" },\n-    { \"hid\", \"aGlk\" },\n-    { \"him\", \"aGlt\" },\n-    { \"hip\", \"aGlw\" },\n-    { \"his\", \"aGlz\" },\n-    { \"hit\", \"aGl0\" },\n-    { \"hob\", \"aG9i\" },\n-    { \"hoc\", \"aG9j\" },\n-    { \"hoe\", \"aG9l\" },\n-    { \"hog\", \"aG9n\" },\n-    { \"hoi\", \"aG9p\" },\n-    { \"Hom\", \"SG9t\" },\n-    { \"hop\", \"aG9w\" },\n-    { \"hot\", \"aG90\" },\n-    { \"how\", \"aG93\" },\n-    { \"hoy\", \"aG95\" },\n-    { \"h's\", \"aCdz\" },\n-    { \"hub\", \"aHVi\" },\n-    { \"hue\", \"aHVl\" },\n-    { \"hug\", \"aHVn\" },\n-    { \"huh\", \"aHVo\" },\n-    { \"hum\", \"aHVt\" },\n-    { \"Hun\", \"SHVu\" },\n-    { \"hut\", \"aHV0\" },\n-    { \"Ian\", \"SWFu\" },\n-    { \"IBM\", \"SUJN\" },\n-    { \"Ibn\", \"SWJu\" },\n-    { \"ICC\", \"SUND\" },\n-    { \"ice\", \"aWNl\" },\n-    { \"icy\", \"aWN5\" },\n-    { \"I'd\", \"SSdk\" },\n-    { \"Ida\", \"SWRh\" },\n-    { \"i.e\", \"aS5l\" },\n-    { \"iii\", \"aWlp\" },\n-    { \"Ike\", \"SWtl\" },\n-    { \"ill\", \"aWxs\" },\n-    { \"I'm\", \"SSdt\" },\n-    { \"imp\", \"aW1w\" },\n-    { \"Inc\", \"SW5j\" },\n-    { \"ink\", \"aW5r\" },\n-    { \"inn\", \"aW5u\" },\n-    { \"ion\", \"aW9u\" },\n-    { \"Ira\", \"SXJh\" },\n-    { \"ire\", \"aXJl\" },\n-    { \"irk\", \"aXJr\" },\n-    { \"IRS\", \"SVJT\" },\n-    { \"i's\", \"aSdz\" },\n-    { \"Ito\", \"SXRv\" },\n-    { \"ITT\", \"SVRU\" },\n-    { \"ivy\", \"aXZ5\" },\n-    { \"jab\", \"amFi\" },\n-    { \"jag\", \"amFn\" },\n-    { \"jam\", \"amFt\" },\n-    { \"Jan\", \"SmFu\" },\n-    { \"jar\", \"amFy\" },\n-    { \"jaw\", \"amF3\" },\n-    { \"jay\", \"amF5\" },\n-    { \"Jed\", \"SmVk\" },\n-    { \"jet\", \"amV0\" },\n-    { \"Jew\", \"SmV3\" },\n-    { \"jig\", \"amln\" },\n-    { \"Jim\", \"Smlt\" },\n-    { \"job\", \"am9i\" },\n-    { \"Joe\", \"Sm9l\" },\n-    { \"jog\", \"am9n\" },\n-    { \"Jon\", \"Sm9u\" },\n-    { \"jot\", \"am90\" },\n-    { \"joy\", \"am95\" },\n-    { \"j's\", \"aidz\" },\n-    { \"jug\", \"anVn\" },\n-    { \"jut\", \"anV0\" },\n-    { \"Kay\", \"S2F5\" },\n-    { \"keg\", \"a2Vn\" },\n-    { \"ken\", \"a2Vu\" },\n-    { \"key\", \"a2V5\" },\n-    { \"kid\", \"a2lk\" },\n-    { \"Kim\", \"S2lt\" },\n-    { \"kin\", \"a2lu\" },\n-    { \"kit\", \"a2l0\" },\n-    { \"k's\", \"aydz\" },\n-    { \"lab\", \"bGFi\" },\n-    { \"lac\", \"bGFj\" },\n-    { \"lad\", \"bGFk\" },\n-    { \"lag\", \"bGFn\" },\n-    { \"lam\", \"bGFt\" },\n-    { \"Lao\", \"TGFv\" },\n-    { \"lap\", \"bGFw\" },\n-    { \"law\", \"bGF3\" },\n-    { \"lax\", \"bGF4\" },\n-    { \"lay\", \"bGF5\" },\n-    { \"lea\", \"bGVh\" },\n-    { \"led\", \"bGVk\" },\n-    { \"lee\", \"bGVl\" },\n-    { \"leg\", \"bGVn\" },\n-    { \"Len\", \"TGVu\" },\n-    { \"Leo\", \"TGVv\" },\n-    { \"let\", \"bGV0\" },\n-    { \"Lev\", \"TGV2\" },\n-    { \"Lew\", \"TGV3\" },\n-    { \"lew\", \"bGV3\" },\n-    { \"lid\", \"bGlk\" },\n-    { \"lie\", \"bGll\" },\n-    { \"lim\", \"bGlt\" },\n-    { \"Lin\", \"TGlu\" },\n-    { \"lip\", \"bGlw\" },\n-    { \"lit\", \"bGl0\" },\n-    { \"Liz\", \"TGl6\" },\n-    { \"lob\", \"bG9i\" },\n-    { \"log\", \"bG9n\" },\n-    { \"lop\", \"bG9w\" },\n-    { \"Los\", \"TG9z\" },\n-    { \"lot\", \"bG90\" },\n-    { \"Lou\", \"TG91\" },\n-    { \"low\", \"bG93\" },\n-    { \"loy\", \"bG95\" },\n-    { \"l's\", \"bCdz\" },\n-    { \"LSI\", \"TFNJ\" },\n-    { \"Ltd\", \"THRk\" },\n-    { \"LTV\", \"TFRW\" },\n-    { \"lug\", \"bHVn\" },\n-    { \"lux\", \"bHV4\" },\n-    { \"lye\", \"bHll\" },\n-    { \"Mac\", \"TWFj\" },\n-    { \"mad\", \"bWFk\" },\n-    { \"Mae\", \"TWFl\" },\n-    { \"man\", \"bWFu\" },\n-    { \"Mao\", \"TWFv\" },\n-    { \"map\", \"bWFw\" },\n-    { \"mar\", \"bWFy\" },\n-    { \"mat\", \"bWF0\" },\n-    { \"maw\", \"bWF3\" },\n-    { \"Max\", \"TWF4\" },\n-    { \"max\", \"bWF4\" },\n-    { \"may\", \"bWF5\" },\n-    { \"MBA\", \"TUJB\" },\n-    { \"Meg\", \"TWVn\" },\n-    { \"Mel\", \"TWVs\" },\n-    { \"men\", \"bWVu\" },\n-    { \"met\", \"bWV0\" },\n-    { \"mew\", \"bWV3\" },\n-    { \"mid\", \"bWlk\" },\n-    { \"mig\", \"bWln\" },\n-    { \"min\", \"bWlu\" },\n-    { \"MIT\", \"TUlU\" },\n-    { \"mix\", \"bWl4\" },\n-    { \"mob\", \"bW9i\" },\n-    { \"Moe\", \"TW9l\" },\n-    { \"moo\", \"bW9v\" },\n-    { \"mop\", \"bW9w\" },\n-    { \"mot\", \"bW90\" },\n-    { \"mow\", \"bW93\" },\n-    { \"MPH\", \"TVBI\" },\n-    { \"Mrs\", \"TXJz\" },\n-    { \"m's\", \"bSdz\" },\n-    { \"mud\", \"bXVk\" },\n-    { \"mug\", \"bXVn\" },\n-    { \"mum\", \"bXVt\" },\n-    { \"nab\", \"bmFi\" },\n-    { \"nag\", \"bmFn\" },\n-    { \"Nan\", \"TmFu\" },\n-    { \"nap\", \"bmFw\" },\n-    { \"Nat\", \"TmF0\" },\n-    { \"nay\", \"bmF5\" },\n-    { \"NBC\", \"TkJD\" },\n-    { \"NBS\", \"TkJT\" },\n-    { \"NCO\", \"TkNP\" },\n-    { \"NCR\", \"TkNS\" },\n-    { \"Ned\", \"TmVk\" },\n-    { \"nee\", \"bmVl\" },\n-    { \"net\", \"bmV0\" },\n-    { \"new\", \"bmV3\" },\n-    { \"nib\", \"bmli\" },\n-    { \"NIH\", \"TklI\" },\n-    { \"nil\", \"bmls\" },\n-    { \"nip\", \"bmlw\" },\n-    { \"nit\", \"bml0\" },\n-    { \"NNE\", \"Tk5F\" },\n-    { \"NNW\", \"Tk5X\" },\n-    { \"nob\", \"bm9i\" },\n-    { \"nod\", \"bm9k\" },\n-    { \"non\", \"bm9u\" },\n-    { \"nor\", \"bm9y\" },\n-    { \"not\", \"bm90\" },\n-    { \"Nov\", \"Tm92\" },\n-    { \"now\", \"bm93\" },\n-    { \"NRC\", \"TlJD\" },\n-    { \"n's\", \"bidz\" },\n-    { \"NSF\", \"TlNG\" },\n-    { \"nun\", \"bnVu\" },\n-    { \"nut\", \"bnV0\" },\n-    { \"NYC\", \"TllD\" },\n-    { \"NYU\", \"TllV\" },\n-    { \"oaf\", \"b2Fm\" },\n-    { \"oak\", \"b2Fr\" },\n-    { \"oar\", \"b2Fy\" },\n-    { \"oat\", \"b2F0\" },\n-    { \"Oct\", \"T2N0\" },\n-    { \"odd\", \"b2Rk\" },\n-    { \"ode\", \"b2Rl\" },\n-    { \"off\", \"b2Zm\" },\n-    { \"oft\", \"b2Z0\" },\n-    { \"ohm\", \"b2ht\" },\n-    { \"oil\", \"b2ls\" },\n-    { \"old\", \"b2xk\" },\n-    { \"one\", \"b25l\" },\n-    { \"opt\", \"b3B0\" },\n-    { \"orb\", \"b3Ji\" },\n-    { \"ore\", \"b3Jl\" },\n-    { \"Orr\", \"T3Jy\" },\n-    { \"o's\", \"bydz\" },\n-    { \"Ott\", \"T3R0\" },\n-    { \"our\", \"b3Vy\" },\n-    { \"out\", \"b3V0\" },\n-    { \"ova\", \"b3Zh\" },\n-    { \"owe\", \"b3dl\" },\n-    { \"owl\", \"b3ds\" },\n-    { \"own\", \"b3du\" },\n-    { \"pad\", \"cGFk\" },\n-    { \"pal\", \"cGFs\" },\n-    { \"Pam\", \"UGFt\" },\n-    { \"pan\", \"cGFu\" },\n-    { \"pap\", \"cGFw\" },\n-    { \"par\", \"cGFy\" },\n-    { \"pat\", \"cGF0\" },\n-    { \"paw\", \"cGF3\" },\n-    { \"pax\", \"cGF4\" },\n-    { \"pay\", \"cGF5\" },\n-    { \"Paz\", \"UGF6\" },\n-    { \"PBS\", \"UEJT\" },\n-    { \"PDP\", \"UERQ\" },\n-    { \"pea\", \"cGVh\" },\n-    { \"pee\", \"cGVl\" },\n-    { \"peg\", \"cGVn\" },\n-    { \"pen\", \"cGVu\" },\n-    { \"pep\", \"cGVw\" },\n-    { \"per\", \"cGVy\" },\n-    { \"pet\", \"cGV0\" },\n-    { \"pew\", \"cGV3\" },\n-    { \"PhD\", \"UGhE\" },\n-    { \"phi\", \"cGhp\" },\n-    { \"pie\", \"cGll\" },\n-    { \"pig\", \"cGln\" },\n-    { \"pin\", \"cGlu\" },\n-    { \"pip\", \"cGlw\" },\n-    { \"pit\", \"cGl0\" },\n-    { \"ply\", \"cGx5\" },\n-    { \"pod\", \"cG9k\" },\n-    { \"Poe\", \"UG9l\" },\n-    { \"poi\", \"cG9p\" },\n-    { \"pol\", \"cG9s\" },\n-    { \"pop\", \"cG9w\" },\n-    { \"pot\", \"cG90\" },\n-    { \"pow\", \"cG93\" },\n-    { \"ppm\", \"cHBt\" },\n-    { \"pro\", \"cHJv\" },\n-    { \"pry\", \"cHJ5\" },\n-    { \"p's\", \"cCdz\" },\n-    { \"psi\", \"cHNp\" },\n-    { \"PTA\", \"UFRB\" },\n-    { \"pub\", \"cHVi\" },\n-    { \"PUC\", \"UFVD\" },\n-    { \"pug\", \"cHVn\" },\n-    { \"pun\", \"cHVu\" },\n-    { \"pup\", \"cHVw\" },\n-    { \"pus\", \"cHVz\" },\n-    { \"put\", \"cHV0\" },\n-    { \"PVC\", \"UFZD\" },\n-    { \"QED\", \"UUVE\" },\n-    { \"q's\", \"cSdz\" },\n-    { \"qua\", \"cXVh\" },\n-    { \"quo\", \"cXVv\" },\n-    { \"Rae\", \"UmFl\" },\n-    { \"rag\", \"cmFn\" },\n-    { \"raj\", \"cmFq\" },\n-    { \"ram\", \"cmFt\" },\n-    { \"ran\", \"cmFu\" },\n-    { \"rap\", \"cmFw\" },\n-    { \"rat\", \"cmF0\" },\n-    { \"raw\", \"cmF3\" },\n-    { \"ray\", \"cmF5\" },\n-    { \"RCA\", \"UkNB\" },\n-    { \"R&D\", \"UiZE\" },\n-    { \"reb\", \"cmVi\" },\n-    { \"red\", \"cmVk\" },\n-    { \"rep\", \"cmVw\" },\n-    { \"ret\", \"cmV0\" },\n-    { \"rev\", \"cmV2\" },\n-    { \"Rex\", \"UmV4\" },\n-    { \"rho\", \"cmhv\" },\n-    { \"rib\", \"cmli\" },\n-    { \"rid\", \"cmlk\" },\n-    { \"rig\", \"cmln\" },\n-    { \"rim\", \"cmlt\" },\n-    { \"Rio\", \"Umlv\" },\n-    { \"rip\", \"cmlw\" },\n-    { \"RNA\", \"Uk5B\" },\n-    { \"rob\", \"cm9i\" },\n-    { \"rod\", \"cm9k\" },\n-    { \"roe\", \"cm9l\" },\n-    { \"Ron\", \"Um9u\" },\n-    { \"rot\", \"cm90\" },\n-    { \"row\", \"cm93\" },\n-    { \"Roy\", \"Um95\" },\n-    { \"RPM\", \"UlBN\" },\n-    { \"r's\", \"cidz\" },\n-    { \"rub\", \"cnVi\" },\n-    { \"rue\", \"cnVl\" },\n-    { \"rug\", \"cnVn\" },\n-    { \"rum\", \"cnVt\" },\n-    { \"run\", \"cnVu\" },\n-    { \"rut\", \"cnV0\" },\n-    { \"rye\", \"cnll\" },\n-    { \"sac\", \"c2Fj\" },\n-    { \"sad\", \"c2Fk\" },\n-    { \"sag\", \"c2Fn\" },\n-    { \"Sal\", \"U2Fs\" },\n-    { \"Sam\", \"U2Ft\" },\n-    { \"San\", \"U2Fu\" },\n-    { \"Sao\", \"U2Fv\" },\n-    { \"sap\", \"c2Fw\" },\n-    { \"sat\", \"c2F0\" },\n-    { \"saw\", \"c2F3\" },\n-    { \"sax\", \"c2F4\" },\n-    { \"say\", \"c2F5\" },\n-    { \"Sci\", \"U2Np\" },\n-    { \"SCM\", \"U0NN\" },\n-    { \"sea\", \"c2Vh\" },\n-    { \"sec\", \"c2Vj\" },\n-    { \"see\", \"c2Vl\" },\n-    { \"sen\", \"c2Vu\" },\n-    { \"seq\", \"c2Vx\" },\n-    { \"set\", \"c2V0\" },\n-    { \"sew\", \"c2V3\" },\n-    { \"sex\", \"c2V4\" },\n-    { \"she\", \"c2hl\" },\n-    { \"Shu\", \"U2h1\" },\n-    { \"shy\", \"c2h5\" },\n-    { \"sib\", \"c2li\" },\n-    { \"sic\", \"c2lj\" },\n-    { \"sin\", \"c2lu\" },\n-    { \"sip\", \"c2lw\" },\n-    { \"sir\", \"c2ly\" },\n-    { \"sis\", \"c2lz\" },\n-    { \"sit\", \"c2l0\" },\n-    { \"six\", \"c2l4\" },\n-    { \"ski\", \"c2tp\" },\n-    { \"sky\", \"c2t5\" },\n-    { \"sly\", \"c2x5\" },\n-    { \"sob\", \"c29i\" },\n-    { \"Soc\", \"U29j\" },\n-    { \"sod\", \"c29k\" },\n-    { \"Sol\", \"U29s\" },\n-    { \"son\", \"c29u\" },\n-    { \"sop\", \"c29w\" },\n-    { \"sou\", \"c291\" },\n-    { \"sow\", \"c293\" },\n-    { \"soy\", \"c295\" },\n-    { \"spa\", \"c3Bh\" },\n-    { \"spy\", \"c3B5\" },\n-    { \"Sri\", \"U3Jp\" },\n-    { \"s's\", \"cydz\" },\n-    { \"SSE\", \"U1NF\" },\n-    { \"SST\", \"U1NU\" },\n-    { \"SSW\", \"U1NX\" },\n-    { \"Stu\", \"U3R1\" },\n-    { \"sub\", \"c3Vi\" },\n-    { \"sud\", \"c3Vk\" },\n-    { \"sue\", \"c3Vl\" },\n-    { \"sum\", \"c3Vt\" },\n-    { \"sun\", \"c3Vu\" },\n-    { \"sup\", \"c3Vw\" },\n-    { \"Sus\", \"U3Vz\" },\n-    { \"tab\", \"dGFi\" },\n-    { \"tad\", \"dGFk\" },\n-    { \"tag\", \"dGFn\" },\n-    { \"tam\", \"dGFt\" },\n-    { \"tan\", \"dGFu\" },\n-    { \"tao\", \"dGFv\" },\n-    { \"tap\", \"dGFw\" },\n-    { \"tar\", \"dGFy\" },\n-    { \"tat\", \"dGF0\" },\n-    { \"tau\", \"dGF1\" },\n-    { \"tax\", \"dGF4\" },\n-    { \"tea\", \"dGVh\" },\n-    { \"Ted\", \"VGVk\" },\n-    { \"ted\", \"dGVk\" },\n-    { \"tee\", \"dGVl\" },\n-    { \"Tel\", \"VGVs\" },\n-    { \"ten\", \"dGVu\" },\n-    { \"the\", \"dGhl\" },\n-    { \"thy\", \"dGh5\" },\n-    { \"tic\", \"dGlj\" },\n-    { \"tid\", \"dGlk\" },\n-    { \"tie\", \"dGll\" },\n-    { \"til\", \"dGls\" },\n-    { \"Tim\", \"VGlt\" },\n-    { \"tin\", \"dGlu\" },\n-    { \"tip\", \"dGlw\" },\n-    { \"tit\", \"dGl0\" },\n-    { \"TNT\", \"VE5U\" },\n-    { \"toe\", \"dG9l\" },\n-    { \"tog\", \"dG9n\" },\n-    { \"Tom\", \"VG9t\" },\n-    { \"ton\", \"dG9u\" },\n-    { \"too\", \"dG9v\" },\n-    { \"top\", \"dG9w\" },\n-    { \"tor\", \"dG9y\" },\n-    { \"tot\", \"dG90\" },\n-    { \"tow\", \"dG93\" },\n-    { \"toy\", \"dG95\" },\n-    { \"TRW\", \"VFJX\" },\n-    { \"try\", \"dHJ5\" },\n-    { \"t's\", \"dCdz\" },\n-    { \"TTL\", \"VFRM\" },\n-    { \"TTY\", \"VFRZ\" },\n-    { \"tub\", \"dHVi\" },\n-    { \"tug\", \"dHVn\" },\n-    { \"tum\", \"dHVt\" },\n-    { \"tun\", \"dHVu\" },\n-    { \"TVA\", \"VFZB\" },\n-    { \"TWA\", \"VFdB\" },\n-    { \"two\", \"dHdv\" },\n-    { \"TWX\", \"VFdY\" },\n-    { \"ugh\", \"dWdo\" },\n-    { \"UHF\", \"VUhG\" },\n-    { \"Uri\", \"VXJp\" },\n-    { \"urn\", \"dXJu\" },\n-    { \"U.S\", \"VS5T\" },\n-    { \"u's\", \"dSdz\" },\n-    { \"USA\", \"VVNB\" },\n-    { \"USC\", \"VVND\" },\n-    { \"use\", \"dXNl\" },\n-    { \"USN\", \"VVNO\" },\n-    { \"van\", \"dmFu\" },\n-    { \"vat\", \"dmF0\" },\n-    { \"vee\", \"dmVl\" },\n-    { \"vet\", \"dmV0\" },\n-    { \"vex\", \"dmV4\" },\n-    { \"VHF\", \"VkhG\" },\n-    { \"via\", \"dmlh\" },\n-    { \"vie\", \"dmll\" },\n-    { \"vii\", \"dmlp\" },\n-    { \"vis\", \"dmlz\" },\n-    { \"viz\", \"dml6\" },\n-    { \"von\", \"dm9u\" },\n-    { \"vow\", \"dm93\" },\n-    { \"v's\", \"didz\" },\n-    { \"WAC\", \"V0FD\" },\n-    { \"wad\", \"d2Fk\" },\n-    { \"wag\", \"d2Fn\" },\n-    { \"wah\", \"d2Fo\" },\n-    { \"wan\", \"d2Fu\" },\n-    { \"war\", \"d2Fy\" },\n-    { \"was\", \"d2Fz\" },\n-    { \"wax\", \"d2F4\" },\n-    { \"way\", \"d2F5\" },\n-    { \"web\", \"d2Vi\" },\n-    { \"wed\", \"d2Vk\" },\n-    { \"wee\", \"d2Vl\" },\n-    { \"Wei\", \"V2Vp\" },\n-    { \"wet\", \"d2V0\" },\n-    { \"who\", \"d2hv\" },\n-    { \"why\", \"d2h5\" },\n-    { \"wig\", \"d2ln\" },\n-    { \"win\", \"d2lu\" },\n-    { \"wit\", \"d2l0\" },\n-    { \"woe\", \"d29l\" },\n-    { \"wok\", \"d29r\" },\n-    { \"won\", \"d29u\" },\n-    { \"woo\", \"d29v\" },\n-    { \"wop\", \"d29w\" },\n-    { \"wow\", \"d293\" },\n-    { \"wry\", \"d3J5\" },\n-    { \"w's\", \"dydz\" },\n-    { \"x's\", \"eCdz\" },\n-    { \"yah\", \"eWFo\" },\n-    { \"yak\", \"eWFr\" },\n-    { \"yam\", \"eWFt\" },\n-    { \"yap\", \"eWFw\" },\n-    { \"yaw\", \"eWF3\" },\n-    { \"yea\", \"eWVh\" },\n-    { \"yen\", \"eWVu\" },\n-    { \"yet\", \"eWV0\" },\n-    { \"yin\", \"eWlu\" },\n-    { \"yip\", \"eWlw\" },\n-    { \"yon\", \"eW9u\" },\n-    { \"you\", \"eW91\" },\n-    { \"yow\", \"eW93\" },\n-    { \"y's\", \"eSdz\" },\n-    { \"yuh\", \"eXVo\" },\n-    { \"zag\", \"emFn\" },\n-    { \"Zan\", \"WmFu\" },\n-    { \"zap\", \"emFw\" },\n-    { \"Zen\", \"WmVu\" },\n-    { \"zig\", \"emln\" },\n-    { \"zip\", \"emlw\" },\n-    { \"Zoe\", \"Wm9l\" },\n-    { \"zoo\", \"em9v\" },\n-    { \"z's\", \"eidz\" },\n+    {\"1st\", \"MXN0\"},\n+    {\"2nd\", \"Mm5k\"},\n+    {\"3rd\", \"M3Jk\"},\n+    {\"4th\", \"NHRo\"},\n+    {\"5th\", \"NXRo\"},\n+    {\"6th\", \"NnRo\"},\n+    {\"7th\", \"N3Ro\"},\n+    {\"8th\", \"OHRo\"},\n+    {\"9th\", \"OXRo\"},\n+    {\"AAA\", \"QUFB\"},\n+    {\"AAU\", \"QUFV\"},\n+    {\"ABA\", \"QUJB\"},\n+    {\"abc\", \"YWJj\"},\n+    {\"Abe\", \"QWJl\"},\n+    {\"Abo\", \"QWJv\"},\n+    {\"ace\", \"YWNl\"},\n+    {\"ACM\", \"QUNN\"},\n+    {\"ACS\", \"QUNT\"},\n+    {\"act\", \"YWN0\"},\n+    {\"Ada\", \"QWRh\"},\n+    {\"add\", \"YWRk\"},\n+    {\"ado\", \"YWRv\"},\n+    {\"aft\", \"YWZ0\"},\n+    {\"age\", \"YWdl\"},\n+    {\"ago\", \"YWdv\"},\n+    {\"aid\", \"YWlk\"},\n+    {\"ail\", \"YWls\"},\n+    {\"aim\", \"YWlt\"},\n+    {\"air\", \"YWly\"},\n+    {\"ala\", \"YWxh\"},\n+    {\"alb\", \"YWxi\"},\n+    {\"ale\", \"YWxl\"},\n+    {\"Ali\", \"QWxp\"},\n+    {\"all\", \"YWxs\"},\n+    {\"alp\", \"YWxw\"},\n+    {\"A&M\", \"QSZN\"},\n+    {\"AMA\", \"QU1B\"},\n+    {\"ami\", \"YW1p\"},\n+    {\"amp\", \"YW1w\"},\n+    {\"Amy\", \"QW15\"},\n+    {\"amy\", \"YW15\"},\n+    {\"ana\", \"YW5h\"},\n+    {\"and\", \"YW5k\"},\n+    {\"ani\", \"YW5p\"},\n+    {\"Ann\", \"QW5u\"},\n+    {\"ant\", \"YW50\"},\n+    {\"any\", \"YW55\"},\n+    {\"A&P\", \"QSZQ\"},\n+    {\"ape\", \"YXBl\"},\n+    {\"Apr\", \"QXBy\"},\n+    {\"APS\", \"QVBT\"},\n+    {\"apt\", \"YXB0\"},\n+    {\"arc\", \"YXJj\"},\n+    {\"are\", \"YXJl\"},\n+    {\"ark\", \"YXJr\"},\n+    {\"arm\", \"YXJt\"},\n+    {\"art\", \"YXJ0\"},\n+    {\"a's\", \"YSdz\"},\n+    {\"ash\", \"YXNo\"},\n+    {\"ask\", \"YXNr\"},\n+    {\"ass\", \"YXNz\"},\n+    {\"ate\", \"YXRl\"},\n+    {\"Aug\", \"QXVn\"},\n+    {\"auk\", \"YXVr\"},\n+    {\"Ave\", \"QXZl\"},\n+    {\"awe\", \"YXdl\"},\n+    {\"awl\", \"YXds\"},\n+    {\"awn\", \"YXdu\"},\n+    {\"axe\", \"YXhl\"},\n+    {\"aye\", \"YXll\"},\n+    {\"bad\", \"YmFk\"},\n+    {\"bag\", \"YmFn\"},\n+    {\"bah\", \"YmFo\"},\n+    {\"bam\", \"YmFt\"},\n+    {\"ban\", \"YmFu\"},\n+    {\"bar\", \"YmFy\"},\n+    {\"bat\", \"YmF0\"},\n+    {\"bay\", \"YmF5\"},\n+    {\"bed\", \"YmVk\"},\n+    {\"bee\", \"YmVl\"},\n+    {\"beg\", \"YmVn\"},\n+    {\"bel\", \"YmVs\"},\n+    {\"Ben\", \"QmVu\"},\n+    {\"bet\", \"YmV0\"},\n+    {\"bey\", \"YmV5\"},\n+    {\"bib\", \"Ymli\"},\n+    {\"bid\", \"Ymlk\"},\n+    {\"big\", \"Ymln\"},\n+    {\"bin\", \"Ymlu\"},\n+    {\"bit\", \"Yml0\"},\n+    {\"biz\", \"Yml6\"},\n+    {\"BMW\", \"Qk1X\"},\n+    {\"boa\", \"Ym9h\"},\n+    {\"bob\", \"Ym9i\"},\n+    {\"bog\", \"Ym9n\"},\n+    {\"bon\", \"Ym9u\"},\n+    {\"boo\", \"Ym9v\"},\n+    {\"bop\", \"Ym9w\"},\n+    {\"bow\", \"Ym93\"},\n+    {\"box\", \"Ym94\"},\n+    {\"boy\", \"Ym95\"},\n+    {\"b's\", \"Yidz\"},\n+    {\"BTL\", \"QlRM\"},\n+    {\"BTU\", \"QlRV\"},\n+    {\"bub\", \"YnVi\"},\n+    {\"bud\", \"YnVk\"},\n+    {\"bug\", \"YnVn\"},\n+    {\"bum\", \"YnVt\"},\n+    {\"bun\", \"YnVu\"},\n+    {\"bus\", \"YnVz\"},\n+    {\"but\", \"YnV0\"},\n+    {\"buy\", \"YnV5\"},\n+    {\"bye\", \"Ynll\"},\n+    {\"cab\", \"Y2Fi\"},\n+    {\"Cal\", \"Q2Fs\"},\n+    {\"cam\", \"Y2Ft\"},\n+    {\"can\", \"Y2Fu\"},\n+    {\"cap\", \"Y2Fw\"},\n+    {\"car\", \"Y2Fy\"},\n+    {\"cat\", \"Y2F0\"},\n+    {\"caw\", \"Y2F3\"},\n+    {\"CBS\", \"Q0JT\"},\n+    {\"CDC\", \"Q0RD\"},\n+    {\"CEQ\", \"Q0VR\"},\n+    {\"chi\", \"Y2hp\"},\n+    {\"CIA\", \"Q0lB\"},\n+    {\"cit\", \"Y2l0\"},\n+    {\"cod\", \"Y29k\"},\n+    {\"cog\", \"Y29n\"},\n+    {\"col\", \"Y29s\"},\n+    {\"con\", \"Y29u\"},\n+    {\"coo\", \"Y29v\"},\n+    {\"cop\", \"Y29w\"},\n+    {\"cos\", \"Y29z\"},\n+    {\"cot\", \"Y290\"},\n+    {\"cow\", \"Y293\"},\n+    {\"cox\", \"Y294\"},\n+    {\"coy\", \"Y295\"},\n+    {\"CPA\", \"Q1BB\"},\n+    {\"cpu\", \"Y3B1\"},\n+    {\"CRT\", \"Q1JU\"},\n+    {\"cry\", \"Y3J5\"},\n+    {\"c's\", \"Yydz\"},\n+    {\"cub\", \"Y3Vi\"},\n+    {\"cud\", \"Y3Vk\"},\n+    {\"cue\", \"Y3Vl\"},\n+    {\"cup\", \"Y3Vw\"},\n+    {\"cur\", \"Y3Vy\"},\n+    {\"cut\", \"Y3V0\"},\n+    {\"dab\", \"ZGFi\"},\n+    {\"dad\", \"ZGFk\"},\n+    {\"dam\", \"ZGFt\"},\n+    {\"Dan\", \"RGFu\"},\n+    {\"Dar\", \"RGFy\"},\n+    {\"day\", \"ZGF5\"},\n+    {\"Dec\", \"RGVj\"},\n+    {\"Dee\", \"RGVl\"},\n+    {\"Del\", \"RGVs\"},\n+    {\"den\", \"ZGVu\"},\n+    {\"Des\", \"RGVz\"},\n+    {\"dew\", \"ZGV3\"},\n+    {\"dey\", \"ZGV5\"},\n+    {\"did\", \"ZGlk\"},\n+    {\"die\", \"ZGll\"},\n+    {\"dig\", \"ZGln\"},\n+    {\"dim\", \"ZGlt\"},\n+    {\"din\", \"ZGlu\"},\n+    {\"dip\", \"ZGlw\"},\n+    {\"Dis\", \"RGlz\"},\n+    {\"DNA\", \"RE5B\"},\n+    {\"DOD\", \"RE9E\"},\n+    {\"doe\", \"ZG9l\"},\n+    {\"dog\", \"ZG9n\"},\n+    {\"don\", \"ZG9u\"},\n+    {\"dot\", \"ZG90\"},\n+    {\"Dow\", \"RG93\"},\n+    {\"dry\", \"ZHJ5\"},\n+    {\"d's\", \"ZCdz\"},\n+    {\"dub\", \"ZHVi\"},\n+    {\"dud\", \"ZHVk\"},\n+    {\"due\", \"ZHVl\"},\n+    {\"dug\", \"ZHVn\"},\n+    {\"dun\", \"ZHVu\"},\n+    {\"dye\", \"ZHll\"},\n+    {\"ear\", \"ZWFy\"},\n+    {\"eat\", \"ZWF0\"},\n+    {\"ebb\", \"ZWJi\"},\n+    {\"EDT\", \"RURU\"},\n+    {\"eel\", \"ZWVs\"},\n+    {\"eft\", \"ZWZ0\"},\n+    {\"e.g\", \"ZS5n\"},\n+    {\"egg\", \"ZWdn\"},\n+    {\"ego\", \"ZWdv\"},\n+    {\"eke\", \"ZWtl\"},\n+    {\"Eli\", \"RWxp\"},\n+    {\"elk\", \"ZWxr\"},\n+    {\"ell\", \"ZWxs\"},\n+    {\"elm\", \"ZWxt\"},\n+    {\"Ely\", \"RWx5\"},\n+    {\"end\", \"ZW5k\"},\n+    {\"Eng\", \"RW5n\"},\n+    {\"EPA\", \"RVBB\"},\n+    {\"era\", \"ZXJh\"},\n+    {\"ere\", \"ZXJl\"},\n+    {\"erg\", \"ZXJn\"},\n+    {\"err\", \"ZXJy\"},\n+    {\"e's\", \"ZSdz\"},\n+    {\"EST\", \"RVNU\"},\n+    {\"eta\", \"ZXRh\"},\n+    {\"etc\", \"ZXRj\"},\n+    {\"Eva\", \"RXZh\"},\n+    {\"eve\", \"ZXZl\"},\n+    {\"ewe\", \"ZXdl\"},\n+    {\"eye\", \"ZXll\"},\n+    {\"FAA\", \"RkFB\"},\n+    {\"fad\", \"ZmFk\"},\n+    {\"fag\", \"ZmFn\"},\n+    {\"fan\", \"ZmFu\"},\n+    {\"far\", \"ZmFy\"},\n+    {\"fat\", \"ZmF0\"},\n+    {\"fay\", \"ZmF5\"},\n+    {\"FBI\", \"RkJJ\"},\n+    {\"FCC\", \"RkND\"},\n+    {\"FDA\", \"RkRB\"},\n+    {\"Feb\", \"RmVi\"},\n+    {\"fed\", \"ZmVk\"},\n+    {\"fee\", \"ZmVl\"},\n+    {\"few\", \"ZmV3\"},\n+    {\"fib\", \"Zmli\"},\n+    {\"fig\", \"Zmln\"},\n+    {\"fin\", \"Zmlu\"},\n+    {\"fir\", \"Zmly\"},\n+    {\"fit\", \"Zml0\"},\n+    {\"fix\", \"Zml4\"},\n+    {\"Flo\", \"Rmxv\"},\n+    {\"flu\", \"Zmx1\"},\n+    {\"fly\", \"Zmx5\"},\n+    {\"FMC\", \"Rk1D\"},\n+    {\"fob\", \"Zm9i\"},\n+    {\"foe\", \"Zm9l\"},\n+    {\"fog\", \"Zm9n\"},\n+    {\"fop\", \"Zm9w\"},\n+    {\"for\", \"Zm9y\"},\n+    {\"fox\", \"Zm94\"},\n+    {\"FPC\", \"RlBD\"},\n+    {\"fro\", \"ZnJv\"},\n+    {\"fry\", \"ZnJ5\"},\n+    {\"f's\", \"Zidz\"},\n+    {\"FTC\", \"RlRD\"},\n+    {\"fum\", \"ZnVt\"},\n+    {\"fun\", \"ZnVu\"},\n+    {\"fur\", \"ZnVy\"},\n+    {\"gab\", \"Z2Fi\"},\n+    {\"gad\", \"Z2Fk\"},\n+    {\"gag\", \"Z2Fn\"},\n+    {\"gal\", \"Z2Fs\"},\n+    {\"gam\", \"Z2Ft\"},\n+    {\"GAO\", \"R0FP\"},\n+    {\"gap\", \"Z2Fw\"},\n+    {\"gar\", \"Z2Fy\"},\n+    {\"gas\", \"Z2Fz\"},\n+    {\"gay\", \"Z2F5\"},\n+    {\"gee\", \"Z2Vl\"},\n+    {\"gel\", \"Z2Vs\"},\n+    {\"gem\", \"Z2Vt\"},\n+    {\"get\", \"Z2V0\"},\n+    {\"gig\", \"Z2ln\"},\n+    {\"Gil\", \"R2ls\"},\n+    {\"gin\", \"Z2lu\"},\n+    {\"GMT\", \"R01U\"},\n+    {\"GNP\", \"R05Q\"},\n+    {\"gnu\", \"Z251\"},\n+    {\"Goa\", \"R29h\"},\n+    {\"gob\", \"Z29i\"},\n+    {\"god\", \"Z29k\"},\n+    {\"gog\", \"Z29n\"},\n+    {\"GOP\", \"R09Q\"},\n+    {\"got\", \"Z290\"},\n+    {\"GPO\", \"R1BP\"},\n+    {\"g's\", \"Zydz\"},\n+    {\"GSA\", \"R1NB\"},\n+    {\"gum\", \"Z3Vt\"},\n+    {\"gun\", \"Z3Vu\"},\n+    {\"Gus\", \"R3Vz\"},\n+    {\"gut\", \"Z3V0\"},\n+    {\"guy\", \"Z3V5\"},\n+    {\"gym\", \"Z3lt\"},\n+    {\"gyp\", \"Z3lw\"},\n+    {\"had\", \"aGFk\"},\n+    {\"Hal\", \"SGFs\"},\n+    {\"ham\", \"aGFt\"},\n+    {\"Han\", \"SGFu\"},\n+    {\"hap\", \"aGFw\"},\n+    {\"hat\", \"aGF0\"},\n+    {\"haw\", \"aGF3\"},\n+    {\"hay\", \"aGF5\"},\n+    {\"hem\", \"aGVt\"},\n+    {\"hen\", \"aGVu\"},\n+    {\"her\", \"aGVy\"},\n+    {\"hew\", \"aGV3\"},\n+    {\"hex\", \"aGV4\"},\n+    {\"hey\", \"aGV5\"},\n+    {\"hid\", \"aGlk\"},\n+    {\"him\", \"aGlt\"},\n+    {\"hip\", \"aGlw\"},\n+    {\"his\", \"aGlz\"},\n+    {\"hit\", \"aGl0\"},\n+    {\"hob\", \"aG9i\"},\n+    {\"hoc\", \"aG9j\"},\n+    {\"hoe\", \"aG9l\"},\n+    {\"hog\", \"aG9n\"},\n+    {\"hoi\", \"aG9p\"},\n+    {\"Hom\", \"SG9t\"},\n+    {\"hop\", \"aG9w\"},\n+    {\"hot\", \"aG90\"},\n+    {\"how\", \"aG93\"},\n+    {\"hoy\", \"aG95\"},\n+    {\"h's\", \"aCdz\"},\n+    {\"hub\", \"aHVi\"},\n+    {\"hue\", \"aHVl\"},\n+    {\"hug\", \"aHVn\"},\n+    {\"huh\", \"aHVo\"},\n+    {\"hum\", \"aHVt\"},\n+    {\"Hun\", \"SHVu\"},\n+    {\"hut\", \"aHV0\"},\n+    {\"Ian\", \"SWFu\"},\n+    {\"IBM\", \"SUJN\"},\n+    {\"Ibn\", \"SWJu\"},\n+    {\"ICC\", \"SUND\"},\n+    {\"ice\", \"aWNl\"},\n+    {\"icy\", \"aWN5\"},\n+    {\"I'd\", \"SSdk\"},\n+    {\"Ida\", \"SWRh\"},\n+    {\"i.e\", \"aS5l\"},\n+    {\"iii\", \"aWlp\"},\n+    {\"Ike\", \"SWtl\"},\n+    {\"ill\", \"aWxs\"},\n+    {\"I'm\", \"SSdt\"},\n+    {\"imp\", \"aW1w\"},\n+    {\"Inc\", \"SW5j\"},\n+    {\"ink\", \"aW5r\"},\n+    {\"inn\", \"aW5u\"},\n+    {\"ion\", \"aW9u\"},\n+    {\"Ira\", \"SXJh\"},\n+    {\"ire\", \"aXJl\"},\n+    {\"irk\", \"aXJr\"},\n+    {\"IRS\", \"SVJT\"},\n+    {\"i's\", \"aSdz\"},\n+    {\"Ito\", \"SXRv\"},\n+    {\"ITT\", \"SVRU\"},\n+    {\"ivy\", \"aXZ5\"},\n+    {\"jab\", \"amFi\"},\n+    {\"jag\", \"amFn\"},\n+    {\"jam\", \"amFt\"},\n+    {\"Jan\", \"SmFu\"},\n+    {\"jar\", \"amFy\"},\n+    {\"jaw\", \"amF3\"},\n+    {\"jay\", \"amF5\"},\n+    {\"Jed\", \"SmVk\"},\n+    {\"jet\", \"amV0\"},\n+    {\"Jew\", \"SmV3\"},\n+    {\"jig\", \"amln\"},\n+    {\"Jim\", \"Smlt\"},\n+    {\"job\", \"am9i\"},\n+    {\"Joe\", \"Sm9l\"},\n+    {\"jog\", \"am9n\"},\n+    {\"Jon\", \"Sm9u\"},\n+    {\"jot\", \"am90\"},\n+    {\"joy\", \"am95\"},\n+    {\"j's\", \"aidz\"},\n+    {\"jug\", \"anVn\"},\n+    {\"jut\", \"anV0\"},\n+    {\"Kay\", \"S2F5\"},\n+    {\"keg\", \"a2Vn\"},\n+    {\"ken\", \"a2Vu\"},\n+    {\"key\", \"a2V5\"},\n+    {\"kid\", \"a2lk\"},\n+    {\"Kim\", \"S2lt\"},\n+    {\"kin\", \"a2lu\"},\n+    {\"kit\", \"a2l0\"},\n+    {\"k's\", \"aydz\"},\n+    {\"lab\", \"bGFi\"},\n+    {\"lac\", \"bGFj\"},\n+    {\"lad\", \"bGFk\"},\n+    {\"lag\", \"bGFn\"},\n+    {\"lam\", \"bGFt\"},\n+    {\"Lao\", \"TGFv\"},\n+    {\"lap\", \"bGFw\"},\n+    {\"law\", \"bGF3\"},\n+    {\"lax\", \"bGF4\"},\n+    {\"lay\", \"bGF5\"},\n+    {\"lea\", \"bGVh\"},\n+    {\"led\", \"bGVk\"},\n+    {\"lee\", \"bGVl\"},\n+    {\"leg\", \"bGVn\"},\n+    {\"Len\", \"TGVu\"},\n+    {\"Leo\", \"TGVv\"},\n+    {\"let\", \"bGV0\"},\n+    {\"Lev\", \"TGV2\"},\n+    {\"Lew\", \"TGV3\"},\n+    {\"lew\", \"bGV3\"},\n+    {\"lid\", \"bGlk\"},\n+    {\"lie\", \"bGll\"},\n+    {\"lim\", \"bGlt\"},\n+    {\"Lin\", \"TGlu\"},\n+    {\"lip\", \"bGlw\"},\n+    {\"lit\", \"bGl0\"},\n+    {\"Liz\", \"TGl6\"},\n+    {\"lob\", \"bG9i\"},\n+    {\"log\", \"bG9n\"},\n+    {\"lop\", \"bG9w\"},\n+    {\"Los\", \"TG9z\"},\n+    {\"lot\", \"bG90\"},\n+    {\"Lou\", \"TG91\"},\n+    {\"low\", \"bG93\"},\n+    {\"loy\", \"bG95\"},\n+    {\"l's\", \"bCdz\"},\n+    {\"LSI\", \"TFNJ\"},\n+    {\"Ltd\", \"THRk\"},\n+    {\"LTV\", \"TFRW\"},\n+    {\"lug\", \"bHVn\"},\n+    {\"lux\", \"bHV4\"},\n+    {\"lye\", \"bHll\"},\n+    {\"Mac\", \"TWFj\"},\n+    {\"mad\", \"bWFk\"},\n+    {\"Mae\", \"TWFl\"},\n+    {\"man\", \"bWFu\"},\n+    {\"Mao\", \"TWFv\"},\n+    {\"map\", \"bWFw\"},\n+    {\"mar\", \"bWFy\"},\n+    {\"mat\", \"bWF0\"},\n+    {\"maw\", \"bWF3\"},\n+    {\"Max\", \"TWF4\"},\n+    {\"max\", \"bWF4\"},\n+    {\"may\", \"bWF5\"},\n+    {\"MBA\", \"TUJB\"},\n+    {\"Meg\", \"TWVn\"},\n+    {\"Mel\", \"TWVs\"},\n+    {\"men\", \"bWVu\"},\n+    {\"met\", \"bWV0\"},\n+    {\"mew\", \"bWV3\"},\n+    {\"mid\", \"bWlk\"},\n+    {\"mig\", \"bWln\"},\n+    {\"min\", \"bWlu\"},\n+    {\"MIT\", \"TUlU\"},\n+    {\"mix\", \"bWl4\"},\n+    {\"mob\", \"bW9i\"},\n+    {\"Moe\", \"TW9l\"},\n+    {\"moo\", \"bW9v\"},\n+    {\"mop\", \"bW9w\"},\n+    {\"mot\", \"bW90\"},\n+    {\"mow\", \"bW93\"},\n+    {\"MPH\", \"TVBI\"},\n+    {\"Mrs\", \"TXJz\"},\n+    {\"m's\", \"bSdz\"},\n+    {\"mud\", \"bXVk\"},\n+    {\"mug\", \"bXVn\"},\n+    {\"mum\", \"bXVt\"},\n+    {\"nab\", \"bmFi\"},\n+    {\"nag\", \"bmFn\"},\n+    {\"Nan\", \"TmFu\"},\n+    {\"nap\", \"bmFw\"},\n+    {\"Nat\", \"TmF0\"},\n+    {\"nay\", \"bmF5\"},\n+    {\"NBC\", \"TkJD\"},\n+    {\"NBS\", \"TkJT\"},\n+    {\"NCO\", \"TkNP\"},\n+    {\"NCR\", \"TkNS\"},\n+    {\"Ned\", \"TmVk\"},\n+    {\"nee\", \"bmVl\"},\n+    {\"net\", \"bmV0\"},\n+    {\"new\", \"bmV3\"},\n+    {\"nib\", \"bmli\"},\n+    {\"NIH\", \"TklI\"},\n+    {\"nil\", \"bmls\"},\n+    {\"nip\", \"bmlw\"},\n+    {\"nit\", \"bml0\"},\n+    {\"NNE\", \"Tk5F\"},\n+    {\"NNW\", \"Tk5X\"},\n+    {\"nob\", \"bm9i\"},\n+    {\"nod\", \"bm9k\"},\n+    {\"non\", \"bm9u\"},\n+    {\"nor\", \"bm9y\"},\n+    {\"not\", \"bm90\"},\n+    {\"Nov\", \"Tm92\"},\n+    {\"now\", \"bm93\"},\n+    {\"NRC\", \"TlJD\"},\n+    {\"n's\", \"bidz\"},\n+    {\"NSF\", \"TlNG\"},\n+    {\"nun\", \"bnVu\"},\n+    {\"nut\", \"bnV0\"},\n+    {\"NYC\", \"TllD\"},\n+    {\"NYU\", \"TllV\"},\n+    {\"oaf\", \"b2Fm\"},\n+    {\"oak\", \"b2Fr\"},\n+    {\"oar\", \"b2Fy\"},\n+    {\"oat\", \"b2F0\"},\n+    {\"Oct\", \"T2N0\"},\n+    {\"odd\", \"b2Rk\"},\n+    {\"ode\", \"b2Rl\"},\n+    {\"off\", \"b2Zm\"},\n+    {\"oft\", \"b2Z0\"},\n+    {\"ohm\", \"b2ht\"},\n+    {\"oil\", \"b2ls\"},\n+    {\"old\", \"b2xk\"},\n+    {\"one\", \"b25l\"},\n+    {\"opt\", \"b3B0\"},\n+    {\"orb\", \"b3Ji\"},\n+    {\"ore\", \"b3Jl\"},\n+    {\"Orr\", \"T3Jy\"},\n+    {\"o's\", \"bydz\"},\n+    {\"Ott\", \"T3R0\"},\n+    {\"our\", \"b3Vy\"},\n+    {\"out\", \"b3V0\"},\n+    {\"ova\", \"b3Zh\"},\n+    {\"owe\", \"b3dl\"},\n+    {\"owl\", \"b3ds\"},\n+    {\"own\", \"b3du\"},\n+    {\"pad\", \"cGFk\"},\n+    {\"pal\", \"cGFs\"},\n+    {\"Pam\", \"UGFt\"},\n+    {\"pan\", \"cGFu\"},\n+    {\"pap\", \"cGFw\"},\n+    {\"par\", \"cGFy\"},\n+    {\"pat\", \"cGF0\"},\n+    {\"paw\", \"cGF3\"},\n+    {\"pax\", \"cGF4\"},\n+    {\"pay\", \"cGF5\"},\n+    {\"Paz\", \"UGF6\"},\n+    {\"PBS\", \"UEJT\"},\n+    {\"PDP\", \"UERQ\"},\n+    {\"pea\", \"cGVh\"},\n+    {\"pee\", \"cGVl\"},\n+    {\"peg\", \"cGVn\"},\n+    {\"pen\", \"cGVu\"},\n+    {\"pep\", \"cGVw\"},\n+    {\"per\", \"cGVy\"},\n+    {\"pet\", \"cGV0\"},\n+    {\"pew\", \"cGV3\"},\n+    {\"PhD\", \"UGhE\"},\n+    {\"phi\", \"cGhp\"},\n+    {\"pie\", \"cGll\"},\n+    {\"pig\", \"cGln\"},\n+    {\"pin\", \"cGlu\"},\n+    {\"pip\", \"cGlw\"},\n+    {\"pit\", \"cGl0\"},\n+    {\"ply\", \"cGx5\"},\n+    {\"pod\", \"cG9k\"},\n+    {\"Poe\", \"UG9l\"},\n+    {\"poi\", \"cG9p\"},\n+    {\"pol\", \"cG9s\"},\n+    {\"pop\", \"cG9w\"},\n+    {\"pot\", \"cG90\"},\n+    {\"pow\", \"cG93\"},\n+    {\"ppm\", \"cHBt\"},\n+    {\"pro\", \"cHJv\"},\n+    {\"pry\", \"cHJ5\"},\n+    {\"p's\", \"cCdz\"},\n+    {\"psi\", \"cHNp\"},\n+    {\"PTA\", \"UFRB\"},\n+    {\"pub\", \"cHVi\"},\n+    {\"PUC\", \"UFVD\"},\n+    {\"pug\", \"cHVn\"},\n+    {\"pun\", \"cHVu\"},\n+    {\"pup\", \"cHVw\"},\n+    {\"pus\", \"cHVz\"},\n+    {\"put\", \"cHV0\"},\n+    {\"PVC\", \"UFZD\"},\n+    {\"QED\", \"UUVE\"},\n+    {\"q's\", \"cSdz\"},\n+    {\"qua\", \"cXVh\"},\n+    {\"quo\", \"cXVv\"},\n+    {\"Rae\", \"UmFl\"},\n+    {\"rag\", \"cmFn\"},\n+    {\"raj\", \"cmFq\"},\n+    {\"ram\", \"cmFt\"},\n+    {\"ran\", \"cmFu\"},\n+    {\"rap\", \"cmFw\"},\n+    {\"rat\", \"cmF0\"},\n+    {\"raw\", \"cmF3\"},\n+    {\"ray\", \"cmF5\"},\n+    {\"RCA\", \"UkNB\"},\n+    {\"R&D\", \"UiZE\"},\n+    {\"reb\", \"cmVi\"},\n+    {\"red\", \"cmVk\"},\n+    {\"rep\", \"cmVw\"},\n+    {\"ret\", \"cmV0\"},\n+    {\"rev\", \"cmV2\"},\n+    {\"Rex\", \"UmV4\"},\n+    {\"rho\", \"cmhv\"},\n+    {\"rib\", \"cmli\"},\n+    {\"rid\", \"cmlk\"},\n+    {\"rig\", \"cmln\"},\n+    {\"rim\", \"cmlt\"},\n+    {\"Rio\", \"Umlv\"},\n+    {\"rip\", \"cmlw\"},\n+    {\"RNA\", \"Uk5B\"},\n+    {\"rob\", \"cm9i\"},\n+    {\"rod\", \"cm9k\"},\n+    {\"roe\", \"cm9l\"},\n+    {\"Ron\", \"Um9u\"},\n+    {\"rot\", \"cm90\"},\n+    {\"row\", \"cm93\"},\n+    {\"Roy\", \"Um95\"},\n+    {\"RPM\", \"UlBN\"},\n+    {\"r's\", \"cidz\"},\n+    {\"rub\", \"cnVi\"},\n+    {\"rue\", \"cnVl\"},\n+    {\"rug\", \"cnVn\"},\n+    {\"rum\", \"cnVt\"},\n+    {\"run\", \"cnVu\"},\n+    {\"rut\", \"cnV0\"},\n+    {\"rye\", \"cnll\"},\n+    {\"sac\", \"c2Fj\"},\n+    {\"sad\", \"c2Fk\"},\n+    {\"sag\", \"c2Fn\"},\n+    {\"Sal\", \"U2Fs\"},\n+    {\"Sam\", \"U2Ft\"},\n+    {\"San\", \"U2Fu\"},\n+    {\"Sao\", \"U2Fv\"},\n+    {\"sap\", \"c2Fw\"},\n+    {\"sat\", \"c2F0\"},\n+    {\"saw\", \"c2F3\"},\n+    {\"sax\", \"c2F4\"},\n+    {\"say\", \"c2F5\"},\n+    {\"Sci\", \"U2Np\"},\n+    {\"SCM\", \"U0NN\"},\n+    {\"sea\", \"c2Vh\"},\n+    {\"sec\", \"c2Vj\"},\n+    {\"see\", \"c2Vl\"},\n+    {\"sen\", \"c2Vu\"},\n+    {\"seq\", \"c2Vx\"},\n+    {\"set\", \"c2V0\"},\n+    {\"sew\", \"c2V3\"},\n+    {\"sex\", \"c2V4\"},\n+    {\"she\", \"c2hl\"},\n+    {\"Shu\", \"U2h1\"},\n+    {\"shy\", \"c2h5\"},\n+    {\"sib\", \"c2li\"},\n+    {\"sic\", \"c2lj\"},\n+    {\"sin\", \"c2lu\"},\n+    {\"sip\", \"c2lw\"},\n+    {\"sir\", \"c2ly\"},\n+    {\"sis\", \"c2lz\"},\n+    {\"sit\", \"c2l0\"},\n+    {\"six\", \"c2l4\"},\n+    {\"ski\", \"c2tp\"},\n+    {\"sky\", \"c2t5\"},\n+    {\"sly\", \"c2x5\"},\n+    {\"sob\", \"c29i\"},\n+    {\"Soc\", \"U29j\"},\n+    {\"sod\", \"c29k\"},\n+    {\"Sol\", \"U29s\"},\n+    {\"son\", \"c29u\"},\n+    {\"sop\", \"c29w\"},\n+    {\"sou\", \"c291\"},\n+    {\"sow\", \"c293\"},\n+    {\"soy\", \"c295\"},\n+    {\"spa\", \"c3Bh\"},\n+    {\"spy\", \"c3B5\"},\n+    {\"Sri\", \"U3Jp\"},\n+    {\"s's\", \"cydz\"},\n+    {\"SSE\", \"U1NF\"},\n+    {\"SST\", \"U1NU\"},\n+    {\"SSW\", \"U1NX\"},\n+    {\"Stu\", \"U3R1\"},\n+    {\"sub\", \"c3Vi\"},\n+    {\"sud\", \"c3Vk\"},\n+    {\"sue\", \"c3Vl\"},\n+    {\"sum\", \"c3Vt\"},\n+    {\"sun\", \"c3Vu\"},\n+    {\"sup\", \"c3Vw\"},\n+    {\"Sus\", \"U3Vz\"},\n+    {\"tab\", \"dGFi\"},\n+    {\"tad\", \"dGFk\"},\n+    {\"tag\", \"dGFn\"},\n+    {\"tam\", \"dGFt\"},\n+    {\"tan\", \"dGFu\"},\n+    {\"tao\", \"dGFv\"},\n+    {\"tap\", \"dGFw\"},\n+    {\"tar\", \"dGFy\"},\n+    {\"tat\", \"dGF0\"},\n+    {\"tau\", \"dGF1\"},\n+    {\"tax\", \"dGF4\"},\n+    {\"tea\", \"dGVh\"},\n+    {\"Ted\", \"VGVk\"},\n+    {\"ted\", \"dGVk\"},\n+    {\"tee\", \"dGVl\"},\n+    {\"Tel\", \"VGVs\"},\n+    {\"ten\", \"dGVu\"},\n+    {\"the\", \"dGhl\"},\n+    {\"thy\", \"dGh5\"},\n+    {\"tic\", \"dGlj\"},\n+    {\"tid\", \"dGlk\"},\n+    {\"tie\", \"dGll\"},\n+    {\"til\", \"dGls\"},\n+    {\"Tim\", \"VGlt\"},\n+    {\"tin\", \"dGlu\"},\n+    {\"tip\", \"dGlw\"},\n+    {\"tit\", \"dGl0\"},\n+    {\"TNT\", \"VE5U\"},\n+    {\"toe\", \"dG9l\"},\n+    {\"tog\", \"dG9n\"},\n+    {\"Tom\", \"VG9t\"},\n+    {\"ton\", \"dG9u\"},\n+    {\"too\", \"dG9v\"},\n+    {\"top\", \"dG9w\"},\n+    {\"tor\", \"dG9y\"},\n+    {\"tot\", \"dG90\"},\n+    {\"tow\", \"dG93\"},\n+    {\"toy\", \"dG95\"},\n+    {\"TRW\", \"VFJX\"},\n+    {\"try\", \"dHJ5\"},\n+    {\"t's\", \"dCdz\"},\n+    {\"TTL\", \"VFRM\"},\n+    {\"TTY\", \"VFRZ\"},\n+    {\"tub\", \"dHVi\"},\n+    {\"tug\", \"dHVn\"},\n+    {\"tum\", \"dHVt\"},\n+    {\"tun\", \"dHVu\"},\n+    {\"TVA\", \"VFZB\"},\n+    {\"TWA\", \"VFdB\"},\n+    {\"two\", \"dHdv\"},\n+    {\"TWX\", \"VFdY\"},\n+    {\"ugh\", \"dWdo\"},\n+    {\"UHF\", \"VUhG\"},\n+    {\"Uri\", \"VXJp\"},\n+    {\"urn\", \"dXJu\"},\n+    {\"U.S\", \"VS5T\"},\n+    {\"u's\", \"dSdz\"},\n+    {\"USA\", \"VVNB\"},\n+    {\"USC\", \"VVND\"},\n+    {\"use\", \"dXNl\"},\n+    {\"USN\", \"VVNO\"},\n+    {\"van\", \"dmFu\"},\n+    {\"vat\", \"dmF0\"},\n+    {\"vee\", \"dmVl\"},\n+    {\"vet\", \"dmV0\"},\n+    {\"vex\", \"dmV4\"},\n+    {\"VHF\", \"VkhG\"},\n+    {\"via\", \"dmlh\"},\n+    {\"vie\", \"dmll\"},\n+    {\"vii\", \"dmlp\"},\n+    {\"vis\", \"dmlz\"},\n+    {\"viz\", \"dml6\"},\n+    {\"von\", \"dm9u\"},\n+    {\"vow\", \"dm93\"},\n+    {\"v's\", \"didz\"},\n+    {\"WAC\", \"V0FD\"},\n+    {\"wad\", \"d2Fk\"},\n+    {\"wag\", \"d2Fn\"},\n+    {\"wah\", \"d2Fo\"},\n+    {\"wan\", \"d2Fu\"},\n+    {\"war\", \"d2Fy\"},\n+    {\"was\", \"d2Fz\"},\n+    {\"wax\", \"d2F4\"},\n+    {\"way\", \"d2F5\"},\n+    {\"web\", \"d2Vi\"},\n+    {\"wed\", \"d2Vk\"},\n+    {\"wee\", \"d2Vl\"},\n+    {\"Wei\", \"V2Vp\"},\n+    {\"wet\", \"d2V0\"},\n+    {\"who\", \"d2hv\"},\n+    {\"why\", \"d2h5\"},\n+    {\"wig\", \"d2ln\"},\n+    {\"win\", \"d2lu\"},\n+    {\"wit\", \"d2l0\"},\n+    {\"woe\", \"d29l\"},\n+    {\"wok\", \"d29r\"},\n+    {\"won\", \"d29u\"},\n+    {\"woo\", \"d29v\"},\n+    {\"wop\", \"d29w\"},\n+    {\"wow\", \"d293\"},\n+    {\"wry\", \"d3J5\"},\n+    {\"w's\", \"dydz\"},\n+    {\"x's\", \"eCdz\"},\n+    {\"yah\", \"eWFo\"},\n+    {\"yak\", \"eWFr\"},\n+    {\"yam\", \"eWFt\"},\n+    {\"yap\", \"eWFw\"},\n+    {\"yaw\", \"eWF3\"},\n+    {\"yea\", \"eWVh\"},\n+    {\"yen\", \"eWVu\"},\n+    {\"yet\", \"eWV0\"},\n+    {\"yin\", \"eWlu\"},\n+    {\"yip\", \"eWlw\"},\n+    {\"yon\", \"eW9u\"},\n+    {\"you\", \"eW91\"},\n+    {\"yow\", \"eW93\"},\n+    {\"y's\", \"eSdz\"},\n+    {\"yuh\", \"eXVo\"},\n+    {\"zag\", \"emFn\"},\n+    {\"Zan\", \"WmFu\"},\n+    {\"zap\", \"emFw\"},\n+    {\"Zen\", \"WmVu\"},\n+    {\"zig\", \"emln\"},\n+    {\"zip\", \"emlw\"},\n+    {\"Zoe\", \"Wm9l\"},\n+    {\"zoo\", \"em9v\"},\n+    {\"z's\", \"eidz\"},\n     /* the false rumors file */\n-    { \"\\\"So when I die, the first thing I will see in heaven is a score list?\\\"\",\n-      \"IlNvIHdoZW4gSSBkaWUsIHRoZSBmaXJzdCB0aGluZyBJIHdpbGwgc2VlIGluIGhlYXZlbiBpc\"\n-      \"yBhIHNjb3JlIGxpc3Q/Ig==\" },\n-    { \"1st Law of Hacking: leaving is much more difficult than entering.\",\n-      \"MXN0IExhdyBvZiBIYWNraW5nOiBsZWF2aW5nIGlzIG11Y2ggbW9yZSBkaWZmaWN1bHQgdGhhb\"\n-      \"iBlbnRlcmluZy4=\" },\n-    { \"2nd Law of Hacking: first in, first out.\",\n-      \"Mm5kIExhdyBvZiBIYWNraW5nOiBmaXJzdCBpbiwgZmlyc3Qgb3V0Lg==\" },\n-    { \"3rd Law of Hacking: the last blow counts most.\",\n-      \"M3JkIExhdyBvZiBIYWNraW5nOiB0aGUgbGFzdCBibG93IGNvdW50cyBtb3N0Lg==\" },\n-    { \"4th Law of Hacking: you will find the exit at the entrance.\",\n-      \"NHRoIExhdyBvZiBIYWNraW5nOiB5b3Ugd2lsbCBmaW5kIHRoZSBleGl0IGF0IHRoZSBlbnRyY\"\n-      \"W5jZS4=\" },\n-    { \"A chameleon imitating a mail daemon often delivers scrolls of fire.\",\n-      \"QSBjaGFtZWxlb24gaW1pdGF0aW5nIGEgbWFpbCBkYWVtb24gb2Z0ZW4gZGVsaXZlcnMgc2Nyb\"\n-      \"2xscyBvZiBmaXJlLg==\" },\n-    { \"A cockatrice corpse is guaranteed to be untainted!\",\n-      \"QSBjb2NrYXRyaWNlIGNvcnBzZSBpcyBndWFyYW50ZWVkIHRvIGJlIHVudGFpbnRlZCE=\" },\n-    { \"A dead cockatrice is just a dead lizard.\",\n-      \"QSBkZWFkIGNvY2thdHJpY2UgaXMganVzdCBhIGRlYWQgbGl6YXJkLg==\" },\n-    { \"A dragon is just a snake that ate a scroll of fire.\",\n-      \"QSBkcmFnb24gaXMganVzdCBhIHNuYWtlIHRoYXQgYXRlIGEgc2Nyb2xsIG9mIGZpcmUu\" },\n-    { \"A fading corridor enlightens your insight.\",\n-      \"QSBmYWRpbmcgY29ycmlkb3IgZW5saWdodGVucyB5b3VyIGluc2lnaHQu\" },\n-    { \"A glowing potion is too hot to drink.\",\n-      \"QSBnbG93aW5nIHBvdGlvbiBpcyB0b28gaG90IHRvIGRyaW5rLg==\" },\n-    { \"A good amulet may protect you against guards.\",\n-      \"QSBnb29kIGFtdWxldCBtYXkgcHJvdGVjdCB5b3UgYWdhaW5zdCBndWFyZHMu\" },\n-    { \"A lizard corpse is a good thing to turn undead.\",\n-      \"QSBsaXphcmQgY29ycHNlIGlzIGEgZ29vZCB0aGluZyB0byB0dXJuIHVuZGVhZC4=\" },\n-    { \"A long worm can be defined recursively. So how should you attack it?\",\n-      \"QSBsb25nIHdvcm0gY2FuIGJlIGRlZmluZWQgcmVjdXJzaXZlbHkuIFNvIGhvdyBzaG91bGQge\"\n-      \"W91IGF0dGFjayBpdD8=\" },\n-    { \"A monstrous mind is a toy forever.\",\n-      \"QSBtb25zdHJvdXMgbWluZCBpcyBhIHRveSBmb3JldmVyLg==\" },\n-    { \"A nymph will be very pleased if you call her by her real name: Lorelei.\",\n-      \"QSBueW1waCB3aWxsIGJlIHZlcnkgcGxlYXNlZCBpZiB5b3UgY2FsbCBoZXIgYnkgaGVyIHJlY\"\n-      \"WwgbmFtZTogTG9yZWxlaS4=\" },\n-    { \"A ring of dungeon master control is a great find.\",\n-      \"QSByaW5nIG9mIGR1bmdlb24gbWFzdGVyIGNvbnRyb2wgaXMgYSBncmVhdCBmaW5kLg==\" },\n-    { \"A ring of extra ring finger is useless if not enchanted.\",\n-      \"QSByaW5nIG9mIGV4dHJhIHJpbmcgZmluZ2VyIGlzIHVzZWxlc3MgaWYgbm90IGVuY2hhbnRlZ\"\n-      \"C4=\" },\n-    { \"A rope may form a trail in a maze.\",\n-      \"QSByb3BlIG1heSBmb3JtIGEgdHJhaWwgaW4gYSBtYXplLg==\" },\n-    { \"A staff may recharge if you drop it for awhile.\",\n-      \"QSBzdGFmZiBtYXkgcmVjaGFyZ2UgaWYgeW91IGRyb3AgaXQgZm9yIGF3aGlsZS4=\" },\n-    { \"A visit to the Zoo is very educational; you meet interesting animals.\",\n-      \"QSB2aXNpdCB0byB0aGUgWm9vIGlzIHZlcnkgZWR1Y2F0aW9uYWw7IHlvdSBtZWV0IGludGVyZ\"\n-      \"XN0aW5nIGFuaW1hbHMu\" },\n-    { \"A wand of deaf is a more dangerous weapon than a wand of sheep.\",\n-      \"QSB3YW5kIG9mIGRlYWYgaXMgYSBtb3JlIGRhbmdlcm91cyB3ZWFwb24gdGhhbiBhIHdhbmQgb\"\n-      \"2Ygc2hlZXAu\" },\n-    { \"A wand of vibration might bring the whole cave crashing about your ears.\",\n-      \"QSB3YW5kIG9mIHZpYnJhdGlvbiBtaWdodCBicmluZyB0aGUgd2hvbGUgY2F2ZSBjcmFzaGluZ\"\n-      \"yBhYm91dCB5b3VyIGVhcnMu\" },\n-    { \"A winner never quits. A quitter never wins.\",\n-      \"QSB3aW5uZXIgbmV2ZXIgcXVpdHMuIEEgcXVpdHRlciBuZXZlciB3aW5zLg==\" },\n-    { \"A wish? Okay, make me a fortune cookie!\",\n-      \"QSB3aXNoPyBPa2F5LCBtYWtlIG1lIGEgZm9ydHVuZSBjb29raWUh\" },\n-    { \"Afraid of mimics? Try to wear a ring of true seeing.\",\n-      \"QWZyYWlkIG9mIG1pbWljcz8gVHJ5IHRvIHdlYXIgYSByaW5nIG9mIHRydWUgc2VlaW5nLg=\"\n-      \"=\" },\n-    { \"All monsters are created evil, but some are more evil than others.\",\n-      \"QWxsIG1vbnN0ZXJzIGFyZSBjcmVhdGVkIGV2aWwsIGJ1dCBzb21lIGFyZSBtb3JlIGV2aWwgd\"\n-      \"GhhbiBvdGhlcnMu\" },\n-    { \"Always attack a floating eye from behind!\",\n-      \"QWx3YXlzIGF0dGFjayBhIGZsb2F0aW5nIGV5ZSBmcm9tIGJlaGluZCE=\" },\n-    { \"An elven cloak is always the height of fashion.\",\n-      \"QW4gZWx2ZW4gY2xvYWsgaXMgYWx3YXlzIHRoZSBoZWlnaHQgb2YgZmFzaGlvbi4=\" },\n-    { \"Any small object that is accidentally dropped will hide under a larger \"\n-      \"object.\",\n-      \"QW55IHNtYWxsIG9iamVjdCB0aGF0IGlzIGFjY2lkZW50YWxseSBkcm9wcGVkIHdpbGwgaGlkZ\"\n-      \"SB1bmRlciBhIGxhcmdlciBvYmplY3Qu\" },\n-    { \"Balrogs do not appear above level 20.\",\n-      \"QmFscm9ncyBkbyBub3QgYXBwZWFyIGFib3ZlIGxldmVsIDIwLg==\" },\n-    { \"Banana peels work especially well against Keystone Kops.\",\n-      \"QmFuYW5hIHBlZWxzIHdvcmsgZXNwZWNpYWxseSB3ZWxsIGFnYWluc3QgS2V5c3RvbmUgS29wc\"\n-      \"y4=\" },\n-    { \"Be careful when eating bananas. Monsters might slip on the peels.\",\n-      \"QmUgY2FyZWZ1bCB3aGVuIGVhdGluZyBiYW5hbmFzLiBNb25zdGVycyBtaWdodCBzbGlwIG9uI\"\n-      \"HRoZSBwZWVscy4=\" },\n-    { \"Better leave the dungeon; otherwise you might get hurt badly.\",\n-      \"QmV0dGVyIGxlYXZlIHRoZSBkdW5nZW9uOyBvdGhlcndpc2UgeW91IG1pZ2h0IGdldCBodXJ0I\"\n-      \"GJhZGx5Lg==\" },\n-    { \"Beware of the potion of nitroglycerin -- it's not for the weak of heart.\",\n-      \"QmV3YXJlIG9mIHRoZSBwb3Rpb24gb2Ygbml0cm9nbHljZXJpbiAtLSBpdCdzIG5vdCBmb3Igd\"\n-      \"GhlIHdlYWsgb2YgaGVhcnQu\" },\n-    { \"Beware: there's always a chance that your wand explodes as you try to \"\n-      \"zap it!\",\n-      \"QmV3YXJlOiB0aGVyZSdzIGFsd2F5cyBhIGNoYW5jZSB0aGF0IHlvdXIgd2FuZCBleHBsb2Rlc\"\n-      \"yBhcyB5b3UgdHJ5IHRvIHphcCBpdCE=\" },\n-    { \"Beyond the 23rd level lies a happy retirement in a room of your own.\",\n-      \"QmV5b25kIHRoZSAyM3JkIGxldmVsIGxpZXMgYSBoYXBweSByZXRpcmVtZW50IGluIGEgcm9vb\"\n-      \"SBvZiB5b3VyIG93bi4=\" },\n-    { \"Changing your suit without dropping your sword? You must be kidding!\",\n-      \"Q2hhbmdpbmcgeW91ciBzdWl0IHdpdGhvdXQgZHJvcHBpbmcgeW91ciBzd29yZD8gWW91IG11c\"\n-      \"3QgYmUga2lkZGluZyE=\" },\n-    { \"Cockatrices might turn themselves to stone faced with a mirror.\",\n-      \"Q29ja2F0cmljZXMgbWlnaHQgdHVybiB0aGVtc2VsdmVzIHRvIHN0b25lIGZhY2VkIHdpdGggY\"\n-      \"SBtaXJyb3Iu\" },\n-    { \"Consumption of home-made food is strictly forbidden in this dungeon.\",\n-      \"Q29uc3VtcHRpb24gb2YgaG9tZS1tYWRlIGZvb2QgaXMgc3RyaWN0bHkgZm9yYmlkZGVuIGluI\"\n-      \"HRoaXMgZHVuZ2Vvbi4=\" },\n-    { \"Dark room? Your chance to develop your photographs!\",\n-      \"RGFyayByb29tPyBZb3VyIGNoYW5jZSB0byBkZXZlbG9wIHlvdXIgcGhvdG9ncmFwaHMh\" },\n-    { \"Dark rooms are not *completely* dark: just wait and let your eyes \"\n-      \"adjust...\",\n-      \"RGFyayByb29tcyBhcmUgbm90ICpjb21wbGV0ZWx5KiBkYXJrOiBqdXN0IHdhaXQgYW5kIGxld\"\n-      \"CB5b3VyIGV5ZXMgYWRqdXN0Li4u\" },\n-    { \"David London sez, \\\"Hey guys, *WIELD* a lizard corpse against a \"\n-      \"cockatrice!\\\"\",\n-      \"RGF2aWQgTG9uZG9uIHNleiwgIkhleSBndXlzLCAqV0lFTEQqIGEgbGl6YXJkIGNvcnBzZSBhZ\"\n-      \"2FpbnN0IGEgY29ja2F0cmljZSEi\" },\n-    { \"Death is just life's way of telling you you've been fired.\",\n-      \"RGVhdGggaXMganVzdCBsaWZlJ3Mgd2F5IG9mIHRlbGxpbmcgeW91IHlvdSd2ZSBiZWVuIGZpc\"\n-      \"mVkLg==\" },\n-    { \"Demi-gods don't need any help from the gods.\",\n-      \"RGVtaS1nb2RzIGRvbid0IG5lZWQgYW55IGhlbHAgZnJvbSB0aGUgZ29kcy4=\" },\n-    { \"Demons *HATE* Priests and Priestesses.\",\n-      \"RGVtb25zICpIQVRFKiBQcmllc3RzIGFuZCBQcmllc3Rlc3Nlcy4=\" },\n-    { \"Didn't you forget to pay?\", \"RGlkbid0IHlvdSBmb3JnZXQgdG8gcGF5Pw==\" },\n-    { \"Didn't your mother tell you not to eat food off the floor?\",\n-      \"RGlkbid0IHlvdXIgbW90aGVyIHRlbGwgeW91IG5vdCB0byBlYXQgZm9vZCBvZmYgdGhlIGZsb\"\n-      \"29yPw==\" },\n-    { \"Direct a direct hit on your direct opponent, directing in the right \"\n-      \"direction.\",\n-      \"RGlyZWN0IGEgZGlyZWN0IGhpdCBvbiB5b3VyIGRpcmVjdCBvcHBvbmVudCwgZGlyZWN0aW5nI\"\n-      \"GluIHRoZSByaWdodCBkaXJlY3Rpb24u\" },\n-    { \"Do you want to make more money? Sure, we all do! Join the Fort Ludios \"\n-      \"guard!\",\n-      \"RG8geW91IHdhbnQgdG8gbWFrZSBtb3JlIG1vbmV5PyBTdXJlLCB3ZSBhbGwgZG8hIEpvaW4gd\"\n-      \"GhlIEZvcnQgTHVkaW9zIGd1YXJkIQ==\" },\n-    { \"Don't eat too much: you might start hiccoughing!\",\n-      \"RG9uJ3QgZWF0IHRvbyBtdWNoOiB5b3UgbWlnaHQgc3RhcnQgaGljY291Z2hpbmch\" },\n-    { \"Don't play hack at your work; your boss might hit you!\",\n-      \"RG9uJ3QgcGxheSBoYWNrIGF0IHlvdXIgd29yazsgeW91ciBib3NzIG1pZ2h0IGhpdCB5b3U\"\n-      \"h\" },\n-    { \"Don't tell a soul you found a secret door, otherwise it isn't a secret \"\n-      \"anymore.\",\n-      \"RG9uJ3QgdGVsbCBhIHNvdWwgeW91IGZvdW5kIGEgc2VjcmV0IGRvb3IsIG90aGVyd2lzZSBpd\"\n-      \"CBpc24ndCBhIHNlY3JldCBhbnltb3JlLg==\" },\n-    { \"Drinking potions of booze may land you in jail if you are under 21.\",\n-      \"RHJpbmtpbmcgcG90aW9ucyBvZiBib296ZSBtYXkgbGFuZCB5b3UgaW4gamFpbCBpZiB5b3UgY\"\n-      \"XJlIHVuZGVyIDIxLg==\" },\n-    { \"Drop your vanity and get rid of your jewels! Pickpockets about!\",\n-      \"RHJvcCB5b3VyIHZhbml0eSBhbmQgZ2V0IHJpZCBvZiB5b3VyIGpld2VscyEgUGlja3BvY2tld\"\n-      \"HMgYWJvdXQh\" },\n-    { \"Eat 10 cloves of garlic and keep all humans at a two-square distance.\",\n-      \"RWF0IDEwIGNsb3ZlcyBvZiBnYXJsaWMgYW5kIGtlZXAgYWxsIGh1bWFucyBhdCBhIHR3by1zc\"\n-      \"XVhcmUgZGlzdGFuY2Uu\" },\n-    { \"Eels hide under mud. Use a unicorn to clear the water and make them \"\n-      \"visible.\",\n-      \"RWVscyBoaWRlIHVuZGVyIG11ZC4gVXNlIGEgdW5pY29ybiB0byBjbGVhciB0aGUgd2F0ZXIgY\"\n-      \"W5kIG1ha2UgdGhlbSB2aXNpYmxlLg==\" },\n-    { \"Engrave your wishes with a wand of wishing.\",\n-      \"RW5ncmF2ZSB5b3VyIHdpc2hlcyB3aXRoIGEgd2FuZCBvZiB3aXNoaW5nLg==\" },\n-    { \"Eventually you will come to admire the swift elegance of a retreating \"\n-      \"nymph.\",\n-      \"RXZlbnR1YWxseSB5b3Ugd2lsbCBjb21lIHRvIGFkbWlyZSB0aGUgc3dpZnQgZWxlZ2FuY2Ugb\"\n-      \"2YgYSByZXRyZWF0aW5nIG55bXBoLg==\" },\n-    { \"Ever heard hissing outside? I *knew* you hadn't!\",\n-      \"RXZlciBoZWFyZCBoaXNzaW5nIG91dHNpZGU/IEkgKmtuZXcqIHlvdSBoYWRuJ3Qh\" },\n-    { \"Ever lifted a dragon corpse?\",\n-      \"RXZlciBsaWZ0ZWQgYSBkcmFnb24gY29ycHNlPw==\" },\n-    { \"Ever seen a leocrotta dancing the tengu?\",\n-      \"RXZlciBzZWVuIGEgbGVvY3JvdHRhIGRhbmNpbmcgdGhlIHRlbmd1Pw==\" },\n-    { \"Ever seen your weapon glow plaid?\",\n-      \"RXZlciBzZWVuIHlvdXIgd2VhcG9uIGdsb3cgcGxhaWQ/\" },\n-    { \"Ever tamed a shopkeeper?\", \"RXZlciB0YW1lZCBhIHNob3BrZWVwZXI/\" },\n-    { \"Ever tried digging through a Vault Guard?\",\n-      \"RXZlciB0cmllZCBkaWdnaW5nIHRocm91Z2ggYSBWYXVsdCBHdWFyZD8=\" },\n-    { \"Ever tried enchanting a rope?\",\n-      \"RXZlciB0cmllZCBlbmNoYW50aW5nIGEgcm9wZT8=\" },\n-    { \"Floating eyes can't stand Hawaiian shirts.\",\n-      \"RmxvYXRpbmcgZXllcyBjYW4ndCBzdGFuZCBIYXdhaWlhbiBzaGlydHMu\" },\n-    { \"For any remedy there is a misery.\",\n-      \"Rm9yIGFueSByZW1lZHkgdGhlcmUgaXMgYSBtaXNlcnku\" },\n-    { \"Giant bats turn into giant vampires.\",\n-      \"R2lhbnQgYmF0cyB0dXJuIGludG8gZ2lhbnQgdmFtcGlyZXMu\" },\n-    { \"Good day for overcoming obstacles. Try a steeplechase.\",\n-      \"R29vZCBkYXkgZm9yIG92ZXJjb21pbmcgb2JzdGFjbGVzLiBUcnkgYSBzdGVlcGxlY2hhc2U\"\n-      \"u\" },\n-    { \"Half Moon tonight. (At least it's better than no Moon at all.)\",\n-      \"SGFsZiBNb29uIHRvbmlnaHQuIChBdCBsZWFzdCBpdCdzIGJldHRlciB0aGFuIG5vIE1vb24gY\"\n-      \"XQgYWxsLik=\" },\n-    { \"Help! I'm being held prisoner in a fortune cookie factory!\",\n-      \"SGVscCEgSSdtIGJlaW5nIGhlbGQgcHJpc29uZXIgaW4gYSBmb3J0dW5lIGNvb2tpZSBmYWN0b\"\n-      \"3J5IQ==\" },\n-    { \"Housecats have nine lives, kittens only one.\",\n-      \"SG91c2VjYXRzIGhhdmUgbmluZSBsaXZlcywga2l0dGVucyBvbmx5IG9uZS4=\" },\n-    { \"How long can you tread water?\",\n-      \"SG93IGxvbmcgY2FuIHlvdSB0cmVhZCB3YXRlcj8=\" },\n-    { \"Hungry? There is an abundance of food on the next level.\",\n-      \"SHVuZ3J5PyBUaGVyZSBpcyBhbiBhYnVuZGFuY2Ugb2YgZm9vZCBvbiB0aGUgbmV4dCBsZXZlb\"\n-      \"C4=\" },\n-    { \"I guess you've never hit a mail daemon with the Amulet of Yendor...\",\n-      \"SSBndWVzcyB5b3UndmUgbmV2ZXIgaGl0IGEgbWFpbCBkYWVtb24gd2l0aCB0aGUgQW11bGV0I\"\n-      \"G9mIFllbmRvci4uLg==\" },\n-    { \"If you are the shopkeeper, you can take things for free.\",\n-      \"SWYgeW91IGFyZSB0aGUgc2hvcGtlZXBlciwgeW91IGNhbiB0YWtlIHRoaW5ncyBmb3IgZnJlZ\"\n-      \"S4=\" },\n-    { \"If you can't learn to do it well, learn to enjoy doing it badly.\",\n-      \"SWYgeW91IGNhbid0IGxlYXJuIHRvIGRvIGl0IHdlbGwsIGxlYXJuIHRvIGVuam95IGRvaW5nI\"\n-      \"Gl0IGJhZGx5Lg==\" },\n-    { \"If you thought the Wizard was bad, just wait till you meet the Warlord!\",\n-      \"SWYgeW91IHRob3VnaHQgdGhlIFdpemFyZCB3YXMgYmFkLCBqdXN0IHdhaXQgdGlsbCB5b3Ugb\"\n-      \"WVldCB0aGUgV2FybG9yZCE=\" },\n-    { \"If you turn blind, don't expect your dog to be turned into a seeing-eye \"\n-      \"dog.\",\n-      \"SWYgeW91IHR1cm4gYmxpbmQsIGRvbid0IGV4cGVjdCB5b3VyIGRvZyB0byBiZSB0dXJuZWQga\"\n-      \"W50byBhIHNlZWluZy1leWUgZG9nLg==\" },\n-    { \"If you want to feel great, you must eat something real big.\",\n-      \"SWYgeW91IHdhbnQgdG8gZmVlbCBncmVhdCwgeW91IG11c3QgZWF0IHNvbWV0aGluZyByZWFsI\"\n-      \"GJpZy4=\" },\n-    { \"If you want to float, you'd better eat a floating eye.\",\n-      \"SWYgeW91IHdhbnQgdG8gZmxvYXQsIHlvdSdkIGJldHRlciBlYXQgYSBmbG9hdGluZyBleWU\"\n-      \"u\" },\n-    { \"If your ghost kills a player, it increases your score.\",\n-      \"SWYgeW91ciBnaG9zdCBraWxscyBhIHBsYXllciwgaXQgaW5jcmVhc2VzIHlvdXIgc2NvcmU\"\n-      \"u\" },\n-    { \"Increase mindpower: Tame your own ghost!\",\n-      \"SW5jcmVhc2UgbWluZHBvd2VyOiBUYW1lIHlvdXIgb3duIGdob3N0IQ==\" },\n-    { \"It furthers one to see the great man.\",\n-      \"SXQgZnVydGhlcnMgb25lIHRvIHNlZSB0aGUgZ3JlYXQgbWFuLg==\" },\n-    { \"It's easy to overlook a monster in a wood.\",\n-      \"SXQncyBlYXN5IHRvIG92ZXJsb29rIGEgbW9uc3RlciBpbiBhIHdvb2Qu\" },\n-    { \"Just below any trapdoor there may be another one. Just keep falling!\",\n-      \"SnVzdCBiZWxvdyBhbnkgdHJhcGRvb3IgdGhlcmUgbWF5IGJlIGFub3RoZXIgb25lLiBKdXN0I\"\n-      \"GtlZXAgZmFsbGluZyE=\" },\n-    { \"Katanas are very sharp; watch you don't cut yourself.\",\n-      \"S2F0YW5hcyBhcmUgdmVyeSBzaGFycDsgd2F0Y2ggeW91IGRvbid0IGN1dCB5b3Vyc2VsZi4\"\n-      \"=\" },\n-    { \"Keep a clear mind: quaff clear potions.\",\n-      \"S2VlcCBhIGNsZWFyIG1pbmQ6IHF1YWZmIGNsZWFyIHBvdGlvbnMu\" },\n-    { \"Kicking the terminal doesn't hurt the monsters.\",\n-      \"S2lja2luZyB0aGUgdGVybWluYWwgZG9lc24ndCBodXJ0IHRoZSBtb25zdGVycy4=\" },\n-    { \"Killer bees keep appearing till you kill their queen.\",\n-      \"S2lsbGVyIGJlZXMga2VlcCBhcHBlYXJpbmcgdGlsbCB5b3Uga2lsbCB0aGVpciBxdWVlbi4\"\n-      \"=\" },\n-    { \"Killer bunnies can be tamed with carrots only.\",\n-      \"S2lsbGVyIGJ1bm5pZXMgY2FuIGJlIHRhbWVkIHdpdGggY2Fycm90cyBvbmx5Lg==\" },\n-    { \"Latest news? Put `rec.games.roguelike.nethack' in your .newsrc!\",\n-      \"TGF0ZXN0IG5ld3M/\"\n-      \"IFB1dCBgcmVjLmdhbWVzLnJvZ3VlbGlrZS5uZXRoYWNrJyBpbiB5b3VyIC5uZXdzcmMh\" },\n-    { \"Learn how to spell. Play NetHack!\",\n-      \"TGVhcm4gaG93IHRvIHNwZWxsLiBQbGF5IE5ldEhhY2sh\" },\n-    { \"Leprechauns hide their gold in a secret room.\",\n-      \"TGVwcmVjaGF1bnMgaGlkZSB0aGVpciBnb2xkIGluIGEgc2VjcmV0IHJvb20u\" },\n-    { \"Let your fingers do the walking on the yulkjhnb keys.\",\n-      \"TGV0IHlvdXIgZmluZ2VycyBkbyB0aGUgd2Fsa2luZyBvbiB0aGUgeXVsa2pobmIga2V5cy4\"\n-      \"=\" },\n-    { \"Let's face it: this time you're not going to win.\",\n-      \"TGV0J3MgZmFjZSBpdDogdGhpcyB0aW1lIHlvdSdyZSBub3QgZ29pbmcgdG8gd2luLg==\" },\n-    { \"Let's have a party, drink a lot of booze.\",\n-      \"TGV0J3MgaGF2ZSBhIHBhcnR5LCBkcmluayBhIGxvdCBvZiBib296ZS4=\" },\n-    { \"Liquor sellers do not drink; they hate to see you twice.\",\n-      \"TGlxdW9yIHNlbGxlcnMgZG8gbm90IGRyaW5rOyB0aGV5IGhhdGUgdG8gc2VlIHlvdSB0d2ljZ\"\n-      \"S4=\" },\n-    { \"Lunar eclipse tonight. May as well quit now!\",\n-      \"THVuYXIgZWNsaXBzZSB0b25pZ2h0LiBNYXkgYXMgd2VsbCBxdWl0IG5vdyE=\" },\n-    { \"Meeting your own ghost decreases your luck considerably!\",\n-      \"TWVldGluZyB5b3VyIG93biBnaG9zdCBkZWNyZWFzZXMgeW91ciBsdWNrIGNvbnNpZGVyYWJse\"\n-      \"SE=\" },\n-    { \"Money to invest? Take it to the local branch of the Magic Memory Vault!\",\n-      \"TW9uZXkgdG8gaW52ZXN0PyBUYWtlIGl0IHRvIHRoZSBsb2NhbCBicmFuY2ggb2YgdGhlIE1hZ\"\n-      \"2ljIE1lbW9yeSBWYXVsdCE=\" },\n-    { \"Monsters come from nowhere to hit you everywhere.\",\n-      \"TW9uc3RlcnMgY29tZSBmcm9tIG5vd2hlcmUgdG8gaGl0IHlvdSBldmVyeXdoZXJlLg==\" },\n-    { \"Monsters sleep because you are boring, not because they ever get tired.\",\n-      \"TW9uc3RlcnMgc2xlZXAgYmVjYXVzZSB5b3UgYXJlIGJvcmluZywgbm90IGJlY2F1c2UgdGhle\"\n-      \"SBldmVyIGdldCB0aXJlZC4=\" },\n-    { \"Most monsters prefer minced meat. That's why they are hitting you!\",\n-      \"TW9zdCBtb25zdGVycyBwcmVmZXIgbWluY2VkIG1lYXQuIFRoYXQncyB3aHkgdGhleSBhcmUga\"\n-      \"Gl0dGluZyB5b3Uh\" },\n-    { \"Most of the bugs in NetHack are on the floor.\",\n-      \"TW9zdCBvZiB0aGUgYnVncyBpbiBOZXRIYWNrIGFyZSBvbiB0aGUgZmxvb3Iu\" },\n-    { \"Much ado Nothing Happens.\", \"TXVjaCBhZG8gTm90aGluZyBIYXBwZW5zLg==\" },\n-    { \"Multi-player NetHack is a myth.\",\n-      \"TXVsdGktcGxheWVyIE5ldEhhY2sgaXMgYSBteXRoLg==\" },\n-    { \"NetHack is addictive. Too late, you're already hooked.\",\n-      \"TmV0SGFjayBpcyBhZGRpY3RpdmUuIFRvbyBsYXRlLCB5b3UncmUgYWxyZWFkeSBob29rZWQ\"\n-      \"u\" },\n-    { \"Never ask a shopkeeper for a price list.\",\n-      \"TmV2ZXIgYXNrIGEgc2hvcGtlZXBlciBmb3IgYSBwcmljZSBsaXN0Lg==\" },\n-    { \"Never burn a tree, unless you like getting whacked with a +5 shovel.\",\n-      \"TmV2ZXIgYnVybiBhIHRyZWUsIHVubGVzcyB5b3UgbGlrZSBnZXR0aW5nIHdoYWNrZWQgd2l0a\"\n-      \"CBhICs1IHNob3ZlbC4=\" },\n-    { \"Never eat with glowing hands!\",\n-      \"TmV2ZXIgZWF0IHdpdGggZ2xvd2luZyBoYW5kcyE=\" },\n-    { \"Never mind the monsters hitting you: they just replace the charwomen.\",\n-      \"TmV2ZXIgbWluZCB0aGUgbW9uc3RlcnMgaGl0dGluZyB5b3U6IHRoZXkganVzdCByZXBsYWNlI\"\n-      \"HRoZSBjaGFyd29tZW4u\" },\n-    { \"Never play leapfrog with a unicorn.\",\n-      \"TmV2ZXIgcGxheSBsZWFwZnJvZyB3aXRoIGEgdW5pY29ybi4=\" },\n-    { \"Never step on a cursed engraving.\",\n-      \"TmV2ZXIgc3RlcCBvbiBhIGN1cnNlZCBlbmdyYXZpbmcu\" },\n-    { \"Never swim with a camera: there's nothing to take pictures of.\",\n-      \"TmV2ZXIgc3dpbSB3aXRoIGEgY2FtZXJhOiB0aGVyZSdzIG5vdGhpbmcgdG8gdGFrZSBwaWN0d\"\n-      \"XJlcyBvZi4=\" },\n-    { \"Never teach your pet rust monster to fetch.\",\n-      \"TmV2ZXIgdGVhY2ggeW91ciBwZXQgcnVzdCBtb25zdGVyIHRvIGZldGNoLg==\" },\n-    { \"Never trust a random generator in magic fields.\",\n-      \"TmV2ZXIgdHJ1c3QgYSByYW5kb20gZ2VuZXJhdG9yIGluIG1hZ2ljIGZpZWxkcy4=\" },\n-    { \"Never use a wand of death.\", \"TmV2ZXIgdXNlIGEgd2FuZCBvZiBkZWF0aC4=\" },\n-    { \"No level contains two shops. The maze is no level. So...\",\n-      \"Tm8gbGV2ZWwgY29udGFpbnMgdHdvIHNob3BzLiBUaGUgbWF6ZSBpcyBubyBsZXZlbC4gU28uL\"\n-      \"i4=\" },\n-    { \"No part of this fortune may be reproduced, stored in a retrieval system, \"\n-      \"...\",\n-      \"Tm8gcGFydCBvZiB0aGlzIGZvcnR1bmUgbWF5IGJlIHJlcHJvZHVjZWQsIHN0b3JlZCBpbiBhI\"\n-      \"HJldHJpZXZhbCBzeXN0ZW0sIC4uLg==\" },\n-    { \"Not all rumors are as misleading as this one.\",\n-      \"Tm90IGFsbCBydW1vcnMgYXJlIGFzIG1pc2xlYWRpbmcgYXMgdGhpcyBvbmUu\" },\n-    { \"Nymphs and nurses like beautiful rings.\",\n-      \"TnltcGhzIGFuZCBudXJzZXMgbGlrZSBiZWF1dGlmdWwgcmluZ3Mu\" },\n-    { \"Nymphs are blondes. Are you a gentleman?\",\n-      \"TnltcGhzIGFyZSBibG9uZGVzLiBBcmUgeW91IGEgZ2VudGxlbWFuPw==\" },\n-    { \"Offering a unicorn a worthless piece of glass might prove to be fatal!\",\n-      \"T2ZmZXJpbmcgYSB1bmljb3JuIGEgd29ydGhsZXNzIHBpZWNlIG9mIGdsYXNzIG1pZ2h0IHByb\"\n-      \"3ZlIHRvIGJlIGZhdGFsIQ==\" },\n-    { \"Old hackers never die: young ones do.\",\n-      \"T2xkIGhhY2tlcnMgbmV2ZXIgZGllOiB5b3VuZyBvbmVzIGRvLg==\" },\n-    { \"One has to leave shops before closing time.\",\n-      \"T25lIGhhcyB0byBsZWF2ZSBzaG9wcyBiZWZvcmUgY2xvc2luZyB0aW1lLg==\" },\n-    { \"One homunculus a day keeps the doctor away.\",\n-      \"T25lIGhvbXVuY3VsdXMgYSBkYXkga2VlcHMgdGhlIGRvY3RvciBhd2F5Lg==\" },\n-    { \"One level further down somebody is getting killed, right now.\",\n-      \"T25lIGxldmVsIGZ1cnRoZXIgZG93biBzb21lYm9keSBpcyBnZXR0aW5nIGtpbGxlZCwgcmlna\"\n-      \"HQgbm93Lg==\" },\n-    { \"Only a wizard can use a magic whistle.\",\n-      \"T25seSBhIHdpemFyZCBjYW4gdXNlIGEgbWFnaWMgd2hpc3RsZS4=\" },\n-    { \"Only adventurers of evil alignment think of killing their dog.\",\n-      \"T25seSBhZHZlbnR1cmVycyBvZiBldmlsIGFsaWdubWVudCB0aGluayBvZiBraWxsaW5nIHRoZ\"\n-      \"WlyIGRvZy4=\" },\n-    { \"Only chaotic evils kill sleeping monsters.\",\n-      \"T25seSBjaGFvdGljIGV2aWxzIGtpbGwgc2xlZXBpbmcgbW9uc3RlcnMu\" },\n-    { \"Only real trappers escape traps.\",\n-      \"T25seSByZWFsIHRyYXBwZXJzIGVzY2FwZSB0cmFwcy4=\" },\n-    { \"Only real wizards can write scrolls.\",\n-      \"T25seSByZWFsIHdpemFyZHMgY2FuIHdyaXRlIHNjcm9sbHMu\" },\n-    { \"Operation OVERKILL has started now.\",\n-      \"T3BlcmF0aW9uIE9WRVJLSUxMIGhhcyBzdGFydGVkIG5vdy4=\" },\n-    { \"PLEASE ignore previous rumor.\",\n-      \"UExFQVNFIGlnbm9yZSBwcmV2aW91cyBydW1vci4=\" },\n-    { \"Polymorph into an ettin; meet your opponents face to face to face.\",\n-      \"UG9seW1vcnBoIGludG8gYW4gZXR0aW47IG1lZXQgeW91ciBvcHBvbmVudHMgZmFjZSB0byBmY\"\n-      \"WNlIHRvIGZhY2Uu\" },\n-    { \"Praying will frighten demons.\",\n-      \"UHJheWluZyB3aWxsIGZyaWdodGVuIGRlbW9ucy4=\" },\n-    { \"Row (3x) that boat gently down the stream, Charon (4x), death is but a \"\n-      \"dream.\",\n-      \"Um93ICgzeCkgdGhhdCBib2F0IGdlbnRseSBkb3duIHRoZSBzdHJlYW0sIENoYXJvbiAoNHgpL\"\n-      \"CBkZWF0aCBpcyBidXQgYSBkcmVhbS4=\" },\n-    { \"Running is good for your legs.\",\n-      \"UnVubmluZyBpcyBnb29kIGZvciB5b3VyIGxlZ3Mu\" },\n-    { \"Screw up your courage! You've screwed up everything else.\",\n-      \"U2NyZXcgdXAgeW91ciBjb3VyYWdlISBZb3UndmUgc2NyZXdlZCB1cCBldmVyeXRoaW5nIGVsc\"\n-      \"2Uu\" },\n-    { \"Seepage? Leaky pipes? Rising damp? Summon the plumber!\",\n-      \"U2VlcGFnZT8gTGVha3kgcGlwZXM/\"\n-      \"IFJpc2luZyBkYW1wPyBTdW1tb24gdGhlIHBsdW1iZXIh\" },\n-    { \"Segmentation fault (core dumped).\",\n-      \"U2VnbWVudGF0aW9uIGZhdWx0IChjb3JlIGR1bXBlZCku\" },\n-    { \"Shopkeepers sometimes die from old age.\",\n-      \"U2hvcGtlZXBlcnMgc29tZXRpbWVzIGRpZSBmcm9tIG9sZCBhZ2Uu\" },\n-    { \"Some mazes (especially small ones) have no solutions, says man 6 maze.\",\n-      \"U29tZSBtYXplcyAoZXNwZWNpYWxseSBzbWFsbCBvbmVzKSBoYXZlIG5vIHNvbHV0aW9ucywgc\"\n-      \"2F5cyBtYW4gNiBtYXplLg==\" },\n-    { \"Some questions the Sphynx asks just *don't* have any answers.\",\n-      \"U29tZSBxdWVzdGlvbnMgdGhlIFNwaHlueCBhc2tzIGp1c3QgKmRvbid0KiBoYXZlIGFueSBhb\"\n-      \"nN3ZXJzLg==\" },\n-    { \"Sometimes \\\"mu\\\" is the answer.\",\n-      \"U29tZXRpbWVzICJtdSIgaXMgdGhlIGFuc3dlci4=\" },\n-    { \"Sorry, no fortune this time. Better luck next cookie!\",\n-      \"U29ycnksIG5vIGZvcnR1bmUgdGhpcyB0aW1lLiBCZXR0ZXIgbHVjayBuZXh0IGNvb2tpZSE\"\n-      \"=\" },\n-    { \"Spare your scrolls of make-edible until it's really necessary!\",\n-      \"U3BhcmUgeW91ciBzY3JvbGxzIG9mIG1ha2UtZWRpYmxlIHVudGlsIGl0J3MgcmVhbGx5IG5lY\"\n-      \"2Vzc2FyeSE=\" },\n-    { \"Suddenly, the dungeon will collapse...\",\n-      \"U3VkZGVubHksIHRoZSBkdW5nZW9uIHdpbGwgY29sbGFwc2UuLi4=\" },\n-    { \"Taming a mail daemon may cause a system security violation.\",\n-      \"VGFtaW5nIGEgbWFpbCBkYWVtb24gbWF5IGNhdXNlIGEgc3lzdGVtIHNlY3VyaXR5IHZpb2xhd\"\n-      \"Glvbi4=\" },\n-    { \"The crowd was so tough, the Stooges won't play the Dungeon anymore, nyuk \"\n-      \"nyuk.\",\n-      \"VGhlIGNyb3dkIHdhcyBzbyB0b3VnaCwgdGhlIFN0b29nZXMgd29uJ3QgcGxheSB0aGUgRHVuZ\"\n-      \"2VvbiBhbnltb3JlLCBueXVrIG55dWsu\" },\n-    { \"The leprechauns hide their treasure in a small hidden room.\",\n-      \"VGhlIGxlcHJlY2hhdW5zIGhpZGUgdGhlaXIgdHJlYXN1cmUgaW4gYSBzbWFsbCBoaWRkZW4gc\"\n-      \"m9vbS4=\" },\n-    { \"The longer the wand the better.\",\n-      \"VGhlIGxvbmdlciB0aGUgd2FuZCB0aGUgYmV0dGVyLg==\" },\n-    { \"The magic word is \\\"XYZZY\\\".\", \"VGhlIG1hZ2ljIHdvcmQgaXMgIlhZWlpZIi4=\" },\n-    { \"The meek shall inherit your bones files.\",\n-      \"VGhlIG1lZWsgc2hhbGwgaW5oZXJpdCB5b3VyIGJvbmVzIGZpbGVzLg==\" },\n-    { \"The mines are dark and deep, and I have levels to go before I sleep.\",\n-      \"VGhlIG1pbmVzIGFyZSBkYXJrIGFuZCBkZWVwLCBhbmQgSSBoYXZlIGxldmVscyB0byBnbyBiZ\"\n-      \"WZvcmUgSSBzbGVlcC4=\" },\n-    { \"The use of dynamite is dangerous.\",\n-      \"VGhlIHVzZSBvZiBkeW5hbWl0ZSBpcyBkYW5nZXJvdXMu\" },\n-    { \"There are no worms in the UNIX version.\",\n-      \"VGhlcmUgYXJlIG5vIHdvcm1zIGluIHRoZSBVTklYIHZlcnNpb24u\" },\n-    { \"There is a trap on this level!\",\n-      \"VGhlcmUgaXMgYSB0cmFwIG9uIHRoaXMgbGV2ZWwh\" },\n-    { \"They say that Demogorgon, Asmodeus, Orcus, Yeenoghu & Juiblex is no law \"\n-      \"firm.\",\n-      \"VGhleSBzYXkgdGhhdCBEZW1vZ29yZ29uLCBBc21vZGV1cywgT3JjdXMsIFllZW5vZ2h1ICYgS\"\n-      \"nVpYmxleCBpcyBubyBsYXcgZmlybS4=\" },\n-    { \"They say that Geryon has an evil twin, beware!\",\n-      \"VGhleSBzYXkgdGhhdCBHZXJ5b24gaGFzIGFuIGV2aWwgdHdpbiwgYmV3YXJlIQ==\" },\n-    { \"They say that Medusa would make a terrible pet.\",\n-      \"VGhleSBzYXkgdGhhdCBNZWR1c2Egd291bGQgbWFrZSBhIHRlcnJpYmxlIHBldC4=\" },\n-    { \"They say that NetHack bugs are Seldon planned.\",\n-      \"VGhleSBzYXkgdGhhdCBOZXRIYWNrIGJ1Z3MgYXJlIFNlbGRvbiBwbGFubmVkLg==\" },\n-    { \"They say that NetHack comes in 256 flavors.\",\n-      \"VGhleSBzYXkgdGhhdCBOZXRIYWNrIGNvbWVzIGluIDI1NiBmbGF2b3JzLg==\" },\n-    { \"They say that NetHack is just a computer game.\",\n-      \"VGhleSBzYXkgdGhhdCBOZXRIYWNrIGlzIGp1c3QgYSBjb21wdXRlciBnYW1lLg==\" },\n-    { \"They say that NetHack is more than just a computer game.\",\n-      \"VGhleSBzYXkgdGhhdCBOZXRIYWNrIGlzIG1vcmUgdGhhbiBqdXN0IGEgY29tcHV0ZXIgZ2FtZ\"\n-      \"S4=\" },\n-    { \"They say that NetHack is never what it used to be.\",\n-      \"VGhleSBzYXkgdGhhdCBOZXRIYWNrIGlzIG5ldmVyIHdoYXQgaXQgdXNlZCB0byBiZS4=\" },\n-    { \"They say that a baby dragon is too small to hurt or help you.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGJhYnkgZHJhZ29uIGlzIHRvbyBzbWFsbCB0byBodXJ0IG9yIGhlb\"\n-      \"HAgeW91Lg==\" },\n-    { \"They say that a black pudding is simply a brown pudding gone bad.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGJsYWNrIHB1ZGRpbmcgaXMgc2ltcGx5IGEgYnJvd24gcHVkZGluZ\"\n-      \"yBnb25lIGJhZC4=\" },\n-    { \"They say that a black sheep has 3 bags full of wool.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGJsYWNrIHNoZWVwIGhhcyAzIGJhZ3MgZnVsbCBvZiB3b29sLg=\"\n-      \"=\" },\n-    { \"They say that a blank scroll is like a blank check.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGJsYW5rIHNjcm9sbCBpcyBsaWtlIGEgYmxhbmsgY2hlY2su\" },\n-    { \"They say that a cat named Morris has nine lives.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGNhdCBuYW1lZCBNb3JyaXMgaGFzIG5pbmUgbGl2ZXMu\" },\n-    { \"They say that a desperate shopper might pay any price in a shop.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGRlc3BlcmF0ZSBzaG9wcGVyIG1pZ2h0IHBheSBhbnkgcHJpY2Uga\"\n-      \"W4gYSBzaG9wLg==\" },\n-    { \"They say that a diamond dog is everybody's best friend.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGRpYW1vbmQgZG9nIGlzIGV2ZXJ5Ym9keSdzIGJlc3QgZnJpZW5kL\"\n-      \"g==\" },\n-    { \"They say that a dwarf lord can carry a pick-axe because his armor is \"\n-      \"light.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGR3YXJmIGxvcmQgY2FuIGNhcnJ5IGEgcGljay1heGUgYmVjYXVzZ\"\n-      \"SBoaXMgYXJtb3IgaXMgbGlnaHQu\" },\n-    { \"They say that a floating eye can defeat Medusa.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGZsb2F0aW5nIGV5ZSBjYW4gZGVmZWF0IE1lZHVzYS4=\" },\n-    { \"They say that a fortune only has 1 line and you can't read between it.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGZvcnR1bmUgb25seSBoYXMgMSBsaW5lIGFuZCB5b3UgY2FuJ3Qgc\"\n-      \"mVhZCBiZXR3ZWVuIGl0Lg==\" },\n-    { \"They say that a fortune only has 1 line, but you can read between it.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGZvcnR1bmUgb25seSBoYXMgMSBsaW5lLCBidXQgeW91IGNhbiByZ\"\n-      \"WFkIGJldHdlZW4gaXQu\" },\n-    { \"They say that a fountain looks nothing like a regularly erupting geyser.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGZvdW50YWluIGxvb2tzIG5vdGhpbmcgbGlrZSBhIHJlZ3VsYXJse\"\n-      \"SBlcnVwdGluZyBnZXlzZXIu\" },\n-    { \"They say that a gold doubloon is worth more than its weight in gold.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGdvbGQgZG91Ymxvb24gaXMgd29ydGggbW9yZSB0aGFuIGl0cyB3Z\"\n-      \"WlnaHQgaW4gZ29sZC4=\" },\n-    { \"They say that a grid bug won't pay a shopkeeper for zapping you in a \"\n-      \"shop.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGdyaWQgYnVnIHdvbid0IHBheSBhIHNob3BrZWVwZXIgZm9yIHphc\"\n-      \"HBpbmcgeW91IGluIGEgc2hvcC4=\" },\n-    { \"They say that a gypsy could tell your fortune for a price.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGd5cHN5IGNvdWxkIHRlbGwgeW91ciBmb3J0dW5lIGZvciBhIHBya\"\n-      \"WNlLg==\" },\n-    { \"They say that a hacker named Alice once level teleported by using a \"\n-      \"mirror.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGhhY2tlciBuYW1lZCBBbGljZSBvbmNlIGxldmVsIHRlbGVwb3J0Z\"\n-      \"WQgYnkgdXNpbmcgYSBtaXJyb3Iu\" },\n-    { \"They say that a hacker named David once slew a giant with a sling and a \"\n-      \"rock.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGhhY2tlciBuYW1lZCBEYXZpZCBvbmNlIHNsZXcgYSBnaWFudCB3a\"\n-      \"XRoIGEgc2xpbmcgYW5kIGEgcm9jay4=\" },\n-    { \"They say that a hacker named Dorothy once rode a fog cloud to Oz.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGhhY2tlciBuYW1lZCBEb3JvdGh5IG9uY2Ugcm9kZSBhIGZvZyBjb\"\n-      \"G91ZCB0byBPei4=\" },\n-    { \"They say that a hacker named Mary once lost a white sheep in the mazes.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGhhY2tlciBuYW1lZCBNYXJ5IG9uY2UgbG9zdCBhIHdoaXRlIHNoZ\"\n-      \"WVwIGluIHRoZSBtYXplcy4=\" },\n-    { \"They say that a helm of brilliance is not to be taken lightly.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGhlbG0gb2YgYnJpbGxpYW5jZSBpcyBub3QgdG8gYmUgdGFrZW4gb\"\n-      \"GlnaHRseS4=\" },\n-    { \"They say that a hot dog and a hell hound are the same thing.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGhvdCBkb2cgYW5kIGEgaGVsbCBob3VuZCBhcmUgdGhlIHNhbWUgd\"\n-      \"Ghpbmcu\" },\n-    { \"They say that a lamp named Aladdin's Lamp contains a djinni with 3 \"\n-      \"wishes.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGxhbXAgbmFtZWQgQWxhZGRpbidzIExhbXAgY29udGFpbnMgYSBka\"\n-      \"mlubmkgd2l0aCAzIHdpc2hlcy4=\" },\n-    { \"They say that a large dog named Lassie will lead you to the amulet.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGxhcmdlIGRvZyBuYW1lZCBMYXNzaWUgd2lsbCBsZWFkIHlvdSB0b\"\n-      \"yB0aGUgYW11bGV0Lg==\" },\n-    { \"They say that a long sword is not a light sword.\",\n-      \"VGhleSBzYXkgdGhhdCBhIGxvbmcgc3dvcmQgaXMgbm90IGEgbGlnaHQgc3dvcmQu\" },\n-    { \"They say that a manes won't mince words with you.\",\n-      \"VGhleSBzYXkgdGhhdCBhIG1hbmVzIHdvbid0IG1pbmNlIHdvcmRzIHdpdGggeW91Lg==\" },\n-    { \"They say that a mind is a terrible thing to waste.\",\n-      \"VGhleSBzYXkgdGhhdCBhIG1pbmQgaXMgYSB0ZXJyaWJsZSB0aGluZyB0byB3YXN0ZS4=\" },\n-    { \"They say that a plain nymph will only wear a wire ring in one ear.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHBsYWluIG55bXBoIHdpbGwgb25seSB3ZWFyIGEgd2lyZSByaW5nI\"\n-      \"GluIG9uZSBlYXIu\" },\n-    { \"They say that a plumed hat could be a previously used crested helmet.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHBsdW1lZCBoYXQgY291bGQgYmUgYSBwcmV2aW91c2x5IHVzZWQgY\"\n-      \"3Jlc3RlZCBoZWxtZXQu\" },\n-    { \"They say that a potion of oil is difficult to grasp.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHBvdGlvbiBvZiBvaWwgaXMgZGlmZmljdWx0IHRvIGdyYXNwLg=\"\n-      \"=\" },\n-    { \"They say that a potion of yogurt is a cancelled potion of sickness.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHBvdGlvbiBvZiB5b2d1cnQgaXMgYSBjYW5jZWxsZWQgcG90aW9uI\"\n-      \"G9mIHNpY2tuZXNzLg==\" },\n-    { \"They say that a purple worm is not a baby purple dragon.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHB1cnBsZSB3b3JtIGlzIG5vdCBhIGJhYnkgcHVycGxlIGRyYWdvb\"\n-      \"i4=\" },\n-    { \"They say that a quivering blob tastes different than a gelatinous cube.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHF1aXZlcmluZyBibG9iIHRhc3RlcyBkaWZmZXJlbnQgdGhhbiBhI\"\n-      \"GdlbGF0aW5vdXMgY3ViZS4=\" },\n-    { \"They say that a runed broadsword named Stormbringer attracts vortices.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHJ1bmVkIGJyb2Fkc3dvcmQgbmFtZWQgU3Rvcm1icmluZ2VyIGF0d\"\n-      \"HJhY3RzIHZvcnRpY2VzLg==\" },\n-    { \"They say that a scroll of summoning has other names.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHNjcm9sbCBvZiBzdW1tb25pbmcgaGFzIG90aGVyIG5hbWVzLg=\"\n-      \"=\" },\n-    { \"They say that a shaman can bestow blessings but usually doesn't.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHNoYW1hbiBjYW4gYmVzdG93IGJsZXNzaW5ncyBidXQgdXN1YWxse\"\n-      \"SBkb2Vzbid0Lg==\" },\n-    { \"They say that a shaman will bless you for an eye of newt and wing of \"\n-      \"bat.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHNoYW1hbiB3aWxsIGJsZXNzIHlvdSBmb3IgYW4gZXllIG9mIG5ld\"\n-      \"3QgYW5kIHdpbmcgb2YgYmF0Lg==\" },\n-    { \"They say that a shimmering gold shield is not a polished silver shield.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHNoaW1tZXJpbmcgZ29sZCBzaGllbGQgaXMgbm90IGEgcG9saXNoZ\"\n-      \"WQgc2lsdmVyIHNoaWVsZC4=\" },\n-    { \"They say that a spear will hit a neo-otyugh. (Do YOU know what that is?)\",\n-      \"VGhleSBzYXkgdGhhdCBhIHNwZWFyIHdpbGwgaGl0IGEgbmVvLW90eXVnaC4gKERvIFlPVSBrb\"\n-      \"m93IHdoYXQgdGhhdCBpcz8p\" },\n-    { \"They say that a spotted dragon is the ultimate shape changer.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHNwb3R0ZWQgZHJhZ29uIGlzIHRoZSB1bHRpbWF0ZSBzaGFwZSBja\"\n-      \"GFuZ2VyLg==\" },\n-    { \"They say that a stethoscope is no good if you can only hear your \"\n-      \"heartbeat.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHN0ZXRob3Njb3BlIGlzIG5vIGdvb2QgaWYgeW91IGNhbiBvbmx5I\"\n-      \"GhlYXIgeW91ciBoZWFydGJlYXQu\" },\n-    { \"They say that a succubus named Suzy will sometimes warn you of danger.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHN1Y2N1YnVzIG5hbWVkIFN1enkgd2lsbCBzb21ldGltZXMgd2Fyb\"\n-      \"iB5b3Ugb2YgZGFuZ2VyLg==\" },\n-    { \"They say that a wand of cancellation is not like a wand of polymorph.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHdhbmQgb2YgY2FuY2VsbGF0aW9uIGlzIG5vdCBsaWtlIGEgd2FuZ\"\n-      \"CBvZiBwb2x5bW9ycGgu\" },\n-    { \"They say that a wood golem named Pinocchio would be easy to control.\",\n-      \"VGhleSBzYXkgdGhhdCBhIHdvb2QgZ29sZW0gbmFtZWQgUGlub2NjaGlvIHdvdWxkIGJlIGVhc\"\n-      \"3kgdG8gY29udHJvbC4=\" },\n-    { \"They say that after killing a dragon it's time for a change of scenery.\",\n-      \"VGhleSBzYXkgdGhhdCBhZnRlciBraWxsaW5nIGEgZHJhZ29uIGl0J3MgdGltZSBmb3IgYSBja\"\n-      \"GFuZ2Ugb2Ygc2NlbmVyeS4=\" },\n-    { \"They say that an amulet of strangulation is worse than ring around the \"\n-      \"collar.\",\n-      \"VGhleSBzYXkgdGhhdCBhbiBhbXVsZXQgb2Ygc3RyYW5ndWxhdGlvbiBpcyB3b3JzZSB0aGFuI\"\n-      \"HJpbmcgYXJvdW5kIHRoZSBjb2xsYXIu\" },\n-    { \"They say that an attic is the best place to hide your toys.\",\n-      \"VGhleSBzYXkgdGhhdCBhbiBhdHRpYyBpcyB0aGUgYmVzdCBwbGFjZSB0byBoaWRlIHlvdXIgd\"\n-      \"G95cy4=\" },\n-    { \"They say that an axe named Cleaver once belonged to a hacker named \"\n-      \"Beaver.\",\n-      \"VGhleSBzYXkgdGhhdCBhbiBheGUgbmFtZWQgQ2xlYXZlciBvbmNlIGJlbG9uZ2VkIHRvIGEga\"\n-      \"GFja2VyIG5hbWVkIEJlYXZlci4=\" },\n-    { \"They say that an eye of newt and a wing of bat are double the trouble.\",\n-      \"VGhleSBzYXkgdGhhdCBhbiBleWUgb2YgbmV3dCBhbmQgYSB3aW5nIG9mIGJhdCBhcmUgZG91Y\"\n-      \"mxlIHRoZSB0cm91YmxlLg==\" },\n-    { \"They say that an incubus named Izzy sometimes makes women feel \"\n-      \"sensitive.\",\n-      \"VGhleSBzYXkgdGhhdCBhbiBpbmN1YnVzIG5hbWVkIEl6enkgc29tZXRpbWVzIG1ha2VzIHdvb\"\n-      \"WVuIGZlZWwgc2Vuc2l0aXZlLg==\" },\n-    { \"They say that an opulent throne room is rarely a place to wish you'd be \"\n-      \"in.\",\n-      \"VGhleSBzYXkgdGhhdCBhbiBvcHVsZW50IHRocm9uZSByb29tIGlzIHJhcmVseSBhIHBsYWNlI\"\n-      \"HRvIHdpc2ggeW91J2QgYmUgaW4u\" },\n-    { \"They say that an unlucky hacker once had a nose bleed at an altar and \"\n-      \"died.\",\n-      \"VGhleSBzYXkgdGhhdCBhbiB1bmx1Y2t5IGhhY2tlciBvbmNlIGhhZCBhIG5vc2UgYmxlZWQgY\"\n-      \"XQgYW4gYWx0YXIgYW5kIGRpZWQu\" },\n-    { \"They say that and they say this but they never say never, never!\",\n-      \"VGhleSBzYXkgdGhhdCBhbmQgdGhleSBzYXkgdGhpcyBidXQgdGhleSBuZXZlciBzYXkgbmV2Z\"\n-      \"XIsIG5ldmVyIQ==\" },\n-    { \"They say that any quantum mechanic knows that speed kills.\",\n-      \"VGhleSBzYXkgdGhhdCBhbnkgcXVhbnR1bSBtZWNoYW5pYyBrbm93cyB0aGF0IHNwZWVkIGtpb\"\n-      \"GxzLg==\" },\n-    { \"They say that applying a unicorn horn means you've missed the point.\",\n-      \"VGhleSBzYXkgdGhhdCBhcHBseWluZyBhIHVuaWNvcm4gaG9ybiBtZWFucyB5b3UndmUgbWlzc\"\n-      \"2VkIHRoZSBwb2ludC4=\" },\n-    { \"They say that blue stones are radioactive, beware.\",\n-      \"VGhleSBzYXkgdGhhdCBibHVlIHN0b25lcyBhcmUgcmFkaW9hY3RpdmUsIGJld2FyZS4=\" },\n-    { \"They say that building a dungeon is a team effort.\",\n-      \"VGhleSBzYXkgdGhhdCBidWlsZGluZyBhIGR1bmdlb24gaXMgYSB0ZWFtIGVmZm9ydC4=\" },\n-    { \"They say that chaotic characters never get a kick out of altars.\",\n-      \"VGhleSBzYXkgdGhhdCBjaGFvdGljIGNoYXJhY3RlcnMgbmV2ZXIgZ2V0IGEga2ljayBvdXQgb\"\n-      \"2YgYWx0YXJzLg==\" },\n-    { \"They say that collapsing a dungeon often creates a panic.\",\n-      \"VGhleSBzYXkgdGhhdCBjb2xsYXBzaW5nIGEgZHVuZ2VvbiBvZnRlbiBjcmVhdGVzIGEgcGFua\"\n-      \"WMu\" },\n-    { \"They say that counting your eggs before they hatch shows that you care.\",\n-      \"VGhleSBzYXkgdGhhdCBjb3VudGluZyB5b3VyIGVnZ3MgYmVmb3JlIHRoZXkgaGF0Y2ggc2hvd\"\n-      \"3MgdGhhdCB5b3UgY2FyZS4=\" },\n-    { \"They say that dipping a bag of tricks in a fountain won't make it an \"\n-      \"icebox.\",\n-      \"VGhleSBzYXkgdGhhdCBkaXBwaW5nIGEgYmFnIG9mIHRyaWNrcyBpbiBhIGZvdW50YWluIHdvb\"\n-      \"id0IG1ha2UgaXQgYW4gaWNlYm94Lg==\" },\n-    { \"They say that dipping an eel and brown mold in hot water makes \"\n-      \"bouillabaisse.\",\n-      \"VGhleSBzYXkgdGhhdCBkaXBwaW5nIGFuIGVlbCBhbmQgYnJvd24gbW9sZCBpbiBob3Qgd2F0Z\"\n-      \"XIgbWFrZXMgYm91aWxsYWJhaXNzZS4=\" },\n-    { \"They say that donating a doubloon is extremely pious charity.\",\n-      \"VGhleSBzYXkgdGhhdCBkb25hdGluZyBhIGRvdWJsb29uIGlzIGV4dHJlbWVseSBwaW91cyBja\"\n-      \"GFyaXR5Lg==\" },\n-    { \"They say that eating royal jelly attracts grizzly owlbears.\",\n-      \"VGhleSBzYXkgdGhhdCBlYXRpbmcgcm95YWwgamVsbHkgYXR0cmFjdHMgZ3JpenpseSBvd2xiZ\"\n-      \"WFycy4=\" },\n-    { \"They say that eggs, pancakes and juice are just a mundane breakfast.\",\n-      \"VGhleSBzYXkgdGhhdCBlZ2dzLCBwYW5jYWtlcyBhbmQganVpY2UgYXJlIGp1c3QgYSBtdW5kY\"\n-      \"W5lIGJyZWFrZmFzdC4=\" },\n-    { \"They say that everyone knows why Medusa stands alone in the dark.\",\n-      \"VGhleSBzYXkgdGhhdCBldmVyeW9uZSBrbm93cyB3aHkgTWVkdXNhIHN0YW5kcyBhbG9uZSBpb\"\n-      \"iB0aGUgZGFyay4=\" },\n-    { \"They say that everyone wanted rec.games.hack to undergo a name change.\",\n-      \"VGhleSBzYXkgdGhhdCBldmVyeW9uZSB3YW50ZWQgcmVjLmdhbWVzLmhhY2sgdG8gdW5kZXJnb\"\n-      \"yBhIG5hbWUgY2hhbmdlLg==\" },\n-    { \"They say that finding a winning strategy is a deliberate move on your \"\n-      \"part.\",\n-      \"VGhleSBzYXkgdGhhdCBmaW5kaW5nIGEgd2lubmluZyBzdHJhdGVneSBpcyBhIGRlbGliZXJhd\"\n-      \"GUgbW92ZSBvbiB5b3VyIHBhcnQu\" },\n-    { \"They say that finding worthless glass is worth something.\",\n-      \"VGhleSBzYXkgdGhhdCBmaW5kaW5nIHdvcnRobGVzcyBnbGFzcyBpcyB3b3J0aCBzb21ldGhpb\"\n-      \"mcu\" },\n-    { \"They say that fortune cookies are food for thought.\",\n-      \"VGhleSBzYXkgdGhhdCBmb3J0dW5lIGNvb2tpZXMgYXJlIGZvb2QgZm9yIHRob3VnaHQu\" },\n-    { \"They say that gold is only wasted on a pet dragon.\",\n-      \"VGhleSBzYXkgdGhhdCBnb2xkIGlzIG9ubHkgd2FzdGVkIG9uIGEgcGV0IGRyYWdvbi4=\" },\n-    { \"They say that good things come to those that wait.\",\n-      \"VGhleSBzYXkgdGhhdCBnb29kIHRoaW5ncyBjb21lIHRvIHRob3NlIHRoYXQgd2FpdC4=\" },\n-    { \"They say that greased objects will slip out of monsters' hands.\",\n-      \"VGhleSBzYXkgdGhhdCBncmVhc2VkIG9iamVjdHMgd2lsbCBzbGlwIG91dCBvZiBtb25zdGVyc\"\n-      \"ycgaGFuZHMu\" },\n-    { \"They say that if you can't spell then you'll wish you had a spell book.\",\n-      \"VGhleSBzYXkgdGhhdCBpZiB5b3UgY2FuJ3Qgc3BlbGwgdGhlbiB5b3UnbGwgd2lzaCB5b3Uga\"\n-      \"GFkIGEgc3BlbGwgYm9vay4=\" },\n-    { \"They say that if you live by the sword, you'll die by the sword.\",\n-      \"VGhleSBzYXkgdGhhdCBpZiB5b3UgbGl2ZSBieSB0aGUgc3dvcmQsIHlvdSdsbCBkaWUgYnkgd\"\n-      \"GhlIHN3b3JkLg==\" },\n-    { \"They say that if you play like a monster you'll have a better game.\",\n-      \"VGhleSBzYXkgdGhhdCBpZiB5b3UgcGxheSBsaWtlIGEgbW9uc3RlciB5b3UnbGwgaGF2ZSBhI\"\n-      \"GJldHRlciBnYW1lLg==\" },\n-    { \"They say that if you sleep with a demon you might awake with a headache.\",\n-      \"VGhleSBzYXkgdGhhdCBpZiB5b3Ugc2xlZXAgd2l0aCBhIGRlbW9uIHlvdSBtaWdodCBhd2FrZ\"\n-      \"SB3aXRoIGEgaGVhZGFjaGUu\" },\n-    { \"They say that if you step on a crack you could break your mother's back.\",\n-      \"VGhleSBzYXkgdGhhdCBpZiB5b3Ugc3RlcCBvbiBhIGNyYWNrIHlvdSBjb3VsZCBicmVhayB5b\"\n-      \"3VyIG1vdGhlcidzIGJhY2su\" },\n-    { \"They say that if you're invisible you can still be heard!\",\n-      \"VGhleSBzYXkgdGhhdCBpZiB5b3UncmUgaW52aXNpYmxlIHlvdSBjYW4gc3RpbGwgYmUgaGVhc\"\n-      \"mQh\" },\n-    { \"They say that if you're lucky you can feel the runes on a scroll.\",\n-      \"VGhleSBzYXkgdGhhdCBpZiB5b3UncmUgbHVja3kgeW91IGNhbiBmZWVsIHRoZSBydW5lcyBvb\"\n-      \"iBhIHNjcm9sbC4=\" },\n-    { \"They say that in the big picture gold is only small change.\",\n-      \"VGhleSBzYXkgdGhhdCBpbiB0aGUgYmlnIHBpY3R1cmUgZ29sZCBpcyBvbmx5IHNtYWxsIGNoY\"\n-      \"W5nZS4=\" },\n-    { \"They say that in the dungeon it's not what you know that really matters.\",\n-      \"VGhleSBzYXkgdGhhdCBpbiB0aGUgZHVuZ2VvbiBpdCdzIG5vdCB3aGF0IHlvdSBrbm93IHRoY\"\n-      \"XQgcmVhbGx5IG1hdHRlcnMu\" },\n-    { \"They say that in the dungeon moon rocks are really dilithium crystals.\",\n-      \"VGhleSBzYXkgdGhhdCBpbiB0aGUgZHVuZ2VvbiBtb29uIHJvY2tzIGFyZSByZWFsbHkgZGlsa\"\n-      \"XRoaXVtIGNyeXN0YWxzLg==\" },\n-    { \"They say that in the dungeon the boorish customer is never right.\",\n-      \"VGhleSBzYXkgdGhhdCBpbiB0aGUgZHVuZ2VvbiB0aGUgYm9vcmlzaCBjdXN0b21lciBpcyBuZ\"\n-      \"XZlciByaWdodC4=\" },\n-    { \"They say that in the dungeon you don't need a watch to tell time.\",\n-      \"VGhleSBzYXkgdGhhdCBpbiB0aGUgZHVuZ2VvbiB5b3UgZG9uJ3QgbmVlZCBhIHdhdGNoIHRvI\"\n-      \"HRlbGwgdGltZS4=\" },\n-    { \"They say that in the dungeon you need something old, new, burrowed and \"\n-      \"blue.\",\n-      \"VGhleSBzYXkgdGhhdCBpbiB0aGUgZHVuZ2VvbiB5b3UgbmVlZCBzb21ldGhpbmcgb2xkLCBuZ\"\n-      \"XcsIGJ1cnJvd2VkIGFuZCBibHVlLg==\" },\n-    { \"They say that in the dungeon you should always count your blessings.\",\n-      \"VGhleSBzYXkgdGhhdCBpbiB0aGUgZHVuZ2VvbiB5b3Ugc2hvdWxkIGFsd2F5cyBjb3VudCB5b\"\n-      \"3VyIGJsZXNzaW5ncy4=\" },\n-    { \"They say that iron golem plate mail isn't worth wishing for.\",\n-      \"VGhleSBzYXkgdGhhdCBpcm9uIGdvbGVtIHBsYXRlIG1haWwgaXNuJ3Qgd29ydGggd2lzaGluZ\"\n-      \"yBmb3Iu\" },\n-    { \"They say that it takes four quarterstaffs to make one staff.\",\n-      \"VGhleSBzYXkgdGhhdCBpdCB0YWtlcyBmb3VyIHF1YXJ0ZXJzdGFmZnMgdG8gbWFrZSBvbmUgc\"\n-      \"3RhZmYu\" },\n-    { \"They say that it's not over till the fat ladies sing.\",\n-      \"VGhleSBzYXkgdGhhdCBpdCdzIG5vdCBvdmVyIHRpbGwgdGhlIGZhdCBsYWRpZXMgc2luZy4\"\n-      \"=\" },\n-    { \"They say that it's not over till the fat lady shouts `Off with its \"\n-      \"head'.\",\n-      \"VGhleSBzYXkgdGhhdCBpdCdzIG5vdCBvdmVyIHRpbGwgdGhlIGZhdCBsYWR5IHNob3V0cyBgT\"\n-      \"2ZmIHdpdGggaXRzIGhlYWQnLg==\" },\n-    { \"They say that kicking a heavy statue is really a dumb move.\",\n-      \"VGhleSBzYXkgdGhhdCBraWNraW5nIGEgaGVhdnkgc3RhdHVlIGlzIHJlYWxseSBhIGR1bWIgb\"\n-      \"W92ZS4=\" },\n-    { \"They say that kicking a valuable gem doesn't seem to make sense.\",\n-      \"VGhleSBzYXkgdGhhdCBraWNraW5nIGEgdmFsdWFibGUgZ2VtIGRvZXNuJ3Qgc2VlbSB0byBtY\"\n-      \"WtlIHNlbnNlLg==\" },\n-    { \"They say that leprechauns know Latin and you should too.\",\n-      \"VGhleSBzYXkgdGhhdCBsZXByZWNoYXVucyBrbm93IExhdGluIGFuZCB5b3Ugc2hvdWxkIHRvb\"\n-      \"y4=\" },\n-    { \"They say that minotaurs get lost outside of the mazes.\",\n-      \"VGhleSBzYXkgdGhhdCBtaW5vdGF1cnMgZ2V0IGxvc3Qgb3V0c2lkZSBvZiB0aGUgbWF6ZXM\"\n-      \"u\" },\n-    { \"They say that most trolls are born again.\",\n-      \"VGhleSBzYXkgdGhhdCBtb3N0IHRyb2xscyBhcmUgYm9ybiBhZ2Fpbi4=\" },\n-    { \"They say that naming your cat Garfield will make you more attractive.\",\n-      \"VGhleSBzYXkgdGhhdCBuYW1pbmcgeW91ciBjYXQgR2FyZmllbGQgd2lsbCBtYWtlIHlvdSBtb\"\n-      \"3JlIGF0dHJhY3RpdmUu\" },\n-    { \"They say that no one knows everything about everything in the dungeon.\",\n-      \"VGhleSBzYXkgdGhhdCBubyBvbmUga25vd3MgZXZlcnl0aGluZyBhYm91dCBldmVyeXRoaW5nI\"\n-      \"GluIHRoZSBkdW5nZW9uLg==\" },\n-    { \"They say that no one plays NetHack just for the fun of it.\",\n-      \"VGhleSBzYXkgdGhhdCBubyBvbmUgcGxheXMgTmV0SGFjayBqdXN0IGZvciB0aGUgZnVuIG9mI\"\n-      \"Gl0Lg==\" },\n-    { \"They say that no one really subscribes to rec.games.roguelike.nethack.\",\n-      \"VGhleSBzYXkgdGhhdCBubyBvbmUgcmVhbGx5IHN1YnNjcmliZXMgdG8gcmVjLmdhbWVzLnJvZ\"\n-      \"3VlbGlrZS5uZXRoYWNrLg==\" },\n-    { \"They say that no one will admit to starting a rumor.\",\n-      \"VGhleSBzYXkgdGhhdCBubyBvbmUgd2lsbCBhZG1pdCB0byBzdGFydGluZyBhIHJ1bW9yLg=\"\n-      \"=\" },\n-    { \"They say that nurses sometimes carry scalpels and never use them.\",\n-      \"VGhleSBzYXkgdGhhdCBudXJzZXMgc29tZXRpbWVzIGNhcnJ5IHNjYWxwZWxzIGFuZCBuZXZlc\"\n-      \"iB1c2UgdGhlbS4=\" },\n-    { \"They say that once you've met one wizard you've met them all.\",\n-      \"VGhleSBzYXkgdGhhdCBvbmNlIHlvdSd2ZSBtZXQgb25lIHdpemFyZCB5b3UndmUgbWV0IHRoZ\"\n-      \"W0gYWxsLg==\" },\n-    { \"They say that one troll is worth 10,000 newts.\",\n-      \"VGhleSBzYXkgdGhhdCBvbmUgdHJvbGwgaXMgd29ydGggMTAsMDAwIG5ld3RzLg==\" },\n-    { \"They say that only David can find the zoo!\",\n-      \"VGhleSBzYXkgdGhhdCBvbmx5IERhdmlkIGNhbiBmaW5kIHRoZSB6b28h\" },\n-    { \"They say that only angels play their harps for their pets.\",\n-      \"VGhleSBzYXkgdGhhdCBvbmx5IGFuZ2VscyBwbGF5IHRoZWlyIGhhcnBzIGZvciB0aGVpciBwZ\"\n-      \"XRzLg==\" },\n-    { \"They say that only big spenders carry gold.\",\n-      \"VGhleSBzYXkgdGhhdCBvbmx5IGJpZyBzcGVuZGVycyBjYXJyeSBnb2xkLg==\" },\n-    { \"They say that orc shamans are healthy, wealthy and wise.\",\n-      \"VGhleSBzYXkgdGhhdCBvcmMgc2hhbWFucyBhcmUgaGVhbHRoeSwgd2VhbHRoeSBhbmQgd2lzZ\"\n-      \"S4=\" },\n-    { \"They say that playing NetHack is like walking into a death trap.\",\n-      \"VGhleSBzYXkgdGhhdCBwbGF5aW5nIE5ldEhhY2sgaXMgbGlrZSB3YWxraW5nIGludG8gYSBkZ\"\n-      \"WF0aCB0cmFwLg==\" },\n-    { \"They say that problem breathing is best treated by a proper diet.\",\n-      \"VGhleSBzYXkgdGhhdCBwcm9ibGVtIGJyZWF0aGluZyBpcyBiZXN0IHRyZWF0ZWQgYnkgYSBwc\"\n-      \"m9wZXIgZGlldC4=\" },\n-    { \"They say that quaffing many potions of levitation can give you a \"\n-      \"headache.\",\n-      \"VGhleSBzYXkgdGhhdCBxdWFmZmluZyBtYW55IHBvdGlvbnMgb2YgbGV2aXRhdGlvbiBjYW4gZ\"\n-      \"2l2ZSB5b3UgYSBoZWFkYWNoZS4=\" },\n-    { \"They say that queen bees get that way by eating royal jelly.\",\n-      \"VGhleSBzYXkgdGhhdCBxdWVlbiBiZWVzIGdldCB0aGF0IHdheSBieSBlYXRpbmcgcm95YWwga\"\n-      \"mVsbHku\" },\n-    { \"They say that reading a scare monster scroll is the same as saying \"\n-      \"Elbereth.\",\n-      \"VGhleSBzYXkgdGhhdCByZWFkaW5nIGEgc2NhcmUgbW9uc3RlciBzY3JvbGwgaXMgdGhlIHNhb\"\n-      \"WUgYXMgc2F5aW5nIEVsYmVyZXRoLg==\" },\n-    { \"They say that real hackers always are controlled.\",\n-      \"VGhleSBzYXkgdGhhdCByZWFsIGhhY2tlcnMgYWx3YXlzIGFyZSBjb250cm9sbGVkLg==\" },\n-    { \"They say that real hackers never sleep.\",\n-      \"VGhleSBzYXkgdGhhdCByZWFsIGhhY2tlcnMgbmV2ZXIgc2xlZXAu\" },\n-    { \"They say that shopkeepers are insured by Croesus himself!\",\n-      \"VGhleSBzYXkgdGhhdCBzaG9wa2VlcGVycyBhcmUgaW5zdXJlZCBieSBDcm9lc3VzIGhpbXNlb\"\n-      \"GYh\" },\n-    { \"They say that shopkeepers never carry more than 20 gold pieces, at \"\n-      \"night.\",\n-      \"VGhleSBzYXkgdGhhdCBzaG9wa2VlcGVycyBuZXZlciBjYXJyeSBtb3JlIHRoYW4gMjAgZ29sZ\"\n-      \"CBwaWVjZXMsIGF0IG5pZ2h0Lg==\" },\n-    { \"They say that shopkeepers never sell blessed potions of invisibility.\",\n-      \"VGhleSBzYXkgdGhhdCBzaG9wa2VlcGVycyBuZXZlciBzZWxsIGJsZXNzZWQgcG90aW9ucyBvZ\"\n-      \"iBpbnZpc2liaWxpdHku\" },\n-    { \"They say that soldiers wear kid gloves and silly helmets.\",\n-      \"VGhleSBzYXkgdGhhdCBzb2xkaWVycyB3ZWFyIGtpZCBnbG92ZXMgYW5kIHNpbGx5IGhlbG1ld\"\n-      \"HMu\" },\n-    { \"They say that some Kops are on the take.\",\n-      \"VGhleSBzYXkgdGhhdCBzb21lIEtvcHMgYXJlIG9uIHRoZSB0YWtlLg==\" },\n-    { \"They say that some guards' palms can be greased.\",\n-      \"VGhleSBzYXkgdGhhdCBzb21lIGd1YXJkcycgcGFsbXMgY2FuIGJlIGdyZWFzZWQu\" },\n-    { \"They say that some monsters may kiss your boots to stop your drum \"\n-      \"playing.\",\n-      \"VGhleSBzYXkgdGhhdCBzb21lIG1vbnN0ZXJzIG1heSBraXNzIHlvdXIgYm9vdHMgdG8gc3Rvc\"\n-      \"CB5b3VyIGRydW0gcGxheWluZy4=\" },\n-    { \"They say that sometimes you can be the hit of the party when playing a \"\n-      \"horn.\",\n-      \"VGhleSBzYXkgdGhhdCBzb21ldGltZXMgeW91IGNhbiBiZSB0aGUgaGl0IG9mIHRoZSBwYXJ0e\"\n-      \"SB3aGVuIHBsYXlpbmcgYSBob3JuLg==\" },\n-    { \"They say that the NetHack gods generally welcome your sacrifices.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGUgTmV0SGFjayBnb2RzIGdlbmVyYWxseSB3ZWxjb21lIHlvdXIgc\"\n-      \"2FjcmlmaWNlcy4=\" },\n-    { \"They say that the Three Rings are named Vilya, Nenya and Narya.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGUgVGhyZWUgUmluZ3MgYXJlIG5hbWVkIFZpbHlhLCBOZW55YSBhb\"\n-      \"mQgTmFyeWEu\" },\n-    { \"They say that the Wizard of Yendor has a death wish.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGUgV2l6YXJkIG9mIFllbmRvciBoYXMgYSBkZWF0aCB3aXNoLg=\"\n-      \"=\" },\n-    { \"They say that the `hair of the dog' is sometimes an effective remedy.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGUgYGhhaXIgb2YgdGhlIGRvZycgaXMgc29tZXRpbWVzIGFuIGVmZ\"\n-      \"mVjdGl2ZSByZW1lZHku\" },\n-    { \"They say that the best time to save your game is now before its too \"\n-      \"late.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGUgYmVzdCB0aW1lIHRvIHNhdmUgeW91ciBnYW1lIGlzIG5vdyBiZ\"\n-      \"WZvcmUgaXRzIHRvbyBsYXRlLg==\" },\n-    { \"They say that the biggest obstacle in NetHack is your mind.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGUgYmlnZ2VzdCBvYnN0YWNsZSBpbiBOZXRIYWNrIGlzIHlvdXIgb\"\n-      \"WluZC4=\" },\n-    { \"They say that the gods are angry when they hit you with objects.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGUgZ29kcyBhcmUgYW5ncnkgd2hlbiB0aGV5IGhpdCB5b3Ugd2l0a\"\n-      \"CBvYmplY3RzLg==\" },\n-    { \"They say that the priesthood are specially favored by the gods.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGUgcHJpZXN0aG9vZCBhcmUgc3BlY2lhbGx5IGZhdm9yZWQgYnkgd\"\n-      \"GhlIGdvZHMu\" },\n-    { \"They say that the way to make a unicorn happy is to give it what it \"\n-      \"wants.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGUgd2F5IHRvIG1ha2UgYSB1bmljb3JuIGhhcHB5IGlzIHRvIGdpd\"\n-      \"mUgaXQgd2hhdCBpdCB3YW50cy4=\" },\n-    { \"They say that there are no black or white stones, only gray.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGVyZSBhcmUgbm8gYmxhY2sgb3Igd2hpdGUgc3RvbmVzLCBvbmx5I\"\n-      \"GdyYXku\" },\n-    { \"They say that there are no skeletons hence there are no skeleton keys.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGVyZSBhcmUgbm8gc2tlbGV0b25zIGhlbmNlIHRoZXJlIGFyZSBub\"\n-      \"yBza2VsZXRvbiBrZXlzLg==\" },\n-    { \"They say that there is a clever rogue in every hacker just dying to \"\n-      \"escape.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGVyZSBpcyBhIGNsZXZlciByb2d1ZSBpbiBldmVyeSBoYWNrZXIga\"\n-      \"nVzdCBkeWluZyB0byBlc2NhcGUu\" },\n-    { \"They say that there is no such thing as free advice.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGVyZSBpcyBubyBzdWNoIHRoaW5nIGFzIGZyZWUgYWR2aWNlLg=\"\n-      \"=\" },\n-    { \"They say that there is only one way to win at NetHack.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGVyZSBpcyBvbmx5IG9uZSB3YXkgdG8gd2luIGF0IE5ldEhhY2s\"\n-      \"u\" },\n-    { \"They say that there once was a fearsome chaotic samurai named Luk No.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGVyZSBvbmNlIHdhcyBhIGZlYXJzb21lIGNoYW90aWMgc2FtdXJha\"\n-      \"SBuYW1lZCBMdWsgTm8u\" },\n-    { \"They say that there was a time when cursed holy water wasn't water.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGVyZSB3YXMgYSB0aW1lIHdoZW4gY3Vyc2VkIGhvbHkgd2F0ZXIgd\"\n-      \"2Fzbid0IHdhdGVyLg==\" },\n-    { \"They say that there's no point in crying over a gray ooze.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGVyZSdzIG5vIHBvaW50IGluIGNyeWluZyBvdmVyIGEgZ3JheSBvb\"\n-      \"3plLg==\" },\n-    { \"They say that there's only hope left after you've opened Pandora's box.\",\n-      \"VGhleSBzYXkgdGhhdCB0aGVyZSdzIG9ubHkgaG9wZSBsZWZ0IGFmdGVyIHlvdSd2ZSBvcGVuZ\"\n-      \"WQgUGFuZG9yYSdzIGJveC4=\" },\n-    { \"They say that trapdoors should always be marked `Caution: Trap Door'.\",\n-      \"VGhleSBzYXkgdGhhdCB0cmFwZG9vcnMgc2hvdWxkIGFsd2F5cyBiZSBtYXJrZWQgYENhdXRpb\"\n-      \"246IFRyYXAgRG9vcicu\" },\n-    { \"They say that using an amulet of change isn't a difficult operation.\",\n-      \"VGhleSBzYXkgdGhhdCB1c2luZyBhbiBhbXVsZXQgb2YgY2hhbmdlIGlzbid0IGEgZGlmZmljd\"\n-      \"Wx0IG9wZXJhdGlvbi4=\" },\n-    { \"They say that water walking boots are better if you are fast like \"\n-      \"Hermes.\",\n-      \"VGhleSBzYXkgdGhhdCB3YXRlciB3YWxraW5nIGJvb3RzIGFyZSBiZXR0ZXIgaWYgeW91IGFyZ\"\n-      \"SBmYXN0IGxpa2UgSGVybWVzLg==\" },\n-    { \"They say that when you wear a circular amulet you might resemble a \"\n-      \"troll.\",\n-      \"VGhleSBzYXkgdGhhdCB3aGVuIHlvdSB3ZWFyIGEgY2lyY3VsYXIgYW11bGV0IHlvdSBtaWdod\"\n-      \"CByZXNlbWJsZSBhIHRyb2xsLg==\" },\n-    { \"They say that when you're hungry you can get a pizza in 30 moves or it's \"\n-      \"free.\",\n-      \"VGhleSBzYXkgdGhhdCB3aGVuIHlvdSdyZSBodW5ncnkgeW91IGNhbiBnZXQgYSBwaXp6YSBpb\"\n-      \"iAzMCBtb3ZlcyBvciBpdCdzIGZyZWUu\" },\n-    { \"They say that when your god is angry you should try another one.\",\n-      \"VGhleSBzYXkgdGhhdCB3aGVuIHlvdXIgZ29kIGlzIGFuZ3J5IHlvdSBzaG91bGQgdHJ5IGFub\"\n-      \"3RoZXIgb25lLg==\" },\n-    { \"They say that wielding a unicorn horn takes strength.\",\n-      \"VGhleSBzYXkgdGhhdCB3aWVsZGluZyBhIHVuaWNvcm4gaG9ybiB0YWtlcyBzdHJlbmd0aC4\"\n-      \"=\" },\n-    { \"They say that with speed boots you never worry about hit and run \"\n-      \"accidents.\",\n-      \"VGhleSBzYXkgdGhhdCB3aXRoIHNwZWVkIGJvb3RzIHlvdSBuZXZlciB3b3JyeSBhYm91dCBoa\"\n-      \"XQgYW5kIHJ1biBhY2NpZGVudHMu\" },\n-    { \"They say that you can defeat a killer bee with a unicorn horn.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIGRlZmVhdCBhIGtpbGxlciBiZWUgd2l0aCBhIHVuaWNvc\"\n-      \"m4gaG9ybi4=\" },\n-    { \"They say that you can only cross the River Styx in Charon's boat.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIG9ubHkgY3Jvc3MgdGhlIFJpdmVyIFN0eXggaW4gQ2hhc\"\n-      \"m9uJ3MgYm9hdC4=\" },\n-    { \"They say that you can only kill a lich once and then you'd better be \"\n-      \"careful.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIG9ubHkga2lsbCBhIGxpY2ggb25jZSBhbmQgdGhlbiB5b\"\n-      \"3UnZCBiZXR0ZXIgYmUgY2FyZWZ1bC4=\" },\n-    { \"They say that you can only wish for things you've already had.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIG9ubHkgd2lzaCBmb3IgdGhpbmdzIHlvdSd2ZSBhbHJlY\"\n-      \"WR5IGhhZC4=\" },\n-    { \"They say that you can train a cat by talking gently to it.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIHRyYWluIGEgY2F0IGJ5IHRhbGtpbmcgZ2VudGx5IHRvI\"\n-      \"Gl0Lg==\" },\n-    { \"They say that you can train a dog by talking firmly to it.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIHRyYWluIGEgZG9nIGJ5IHRhbGtpbmcgZmlybWx5IHRvI\"\n-      \"Gl0Lg==\" },\n-    { \"They say that you can trust your gold with the king.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIHRydXN0IHlvdXIgZ29sZCB3aXRoIHRoZSBraW5nLg=\"\n-      \"=\" },\n-    { \"They say that you can't wipe your greasy bare hands on a blank scroll.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3UgY2FuJ3Qgd2lwZSB5b3VyIGdyZWFzeSBiYXJlIGhhbmRzIG9uI\"\n-      \"GEgYmxhbmsgc2Nyb2xsLg==\" },\n-    { \"They say that you cannot trust scrolls of rumor.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3UgY2Fubm90IHRydXN0IHNjcm9sbHMgb2YgcnVtb3Iu\" },\n-    { \"They say that you could fall head over heels for an energy vortex.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3UgY291bGQgZmFsbCBoZWFkIG92ZXIgaGVlbHMgZm9yIGFuIGVuZ\"\n-      \"XJneSB2b3J0ZXgu\" },\n-    { \"They say that you need a key in order to open locked doors.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3UgbmVlZCBhIGtleSBpbiBvcmRlciB0byBvcGVuIGxvY2tlZCBkb\"\n-      \"29ycy4=\" },\n-    { \"They say that you need a mirror to notice a mimic in an antique shop.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3UgbmVlZCBhIG1pcnJvciB0byBub3RpY2UgYSBtaW1pYyBpbiBhb\"\n-      \"iBhbnRpcXVlIHNob3Au\" },\n-    { \"They say that you really can use a pick-axe unless you really can't.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3UgcmVhbGx5IGNhbiB1c2UgYSBwaWNrLWF4ZSB1bmxlc3MgeW91I\"\n-      \"HJlYWxseSBjYW4ndC4=\" },\n-    { \"They say that you should always store your tools in the cellar.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIGFsd2F5cyBzdG9yZSB5b3VyIHRvb2xzIGluIHRoZ\"\n-      \"SBjZWxsYXIu\" },\n-    { \"They say that you should be careful while climbing the ladder to \"\n-      \"success.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIGJlIGNhcmVmdWwgd2hpbGUgY2xpbWJpbmcgdGhlI\"\n-      \"GxhZGRlciB0byBzdWNjZXNzLg==\" },\n-    { \"They say that you should call your armor `rustproof'.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIGNhbGwgeW91ciBhcm1vciBgcnVzdHByb29mJy4\"\n-      \"=\" },\n-    { \"They say that you should name your dog Spuds to have a cool pet.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIG5hbWUgeW91ciBkb2cgU3B1ZHMgdG8gaGF2ZSBhI\"\n-      \"GNvb2wgcGV0Lg==\" },\n-    { \"They say that you should name your weapon after your first monster kill.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIG5hbWUgeW91ciB3ZWFwb24gYWZ0ZXIgeW91ciBma\"\n-      \"XJzdCBtb25zdGVyIGtpbGwu\" },\n-    { \"They say that you should never introduce a rope golem to a succubus.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIG5ldmVyIGludHJvZHVjZSBhIHJvcGUgZ29sZW0gd\"\n-      \"G8gYSBzdWNjdWJ1cy4=\" },\n-    { \"They say that you should never sleep near invisible ring wraiths.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIG5ldmVyIHNsZWVwIG5lYXIgaW52aXNpYmxlIHJpb\"\n-      \"mcgd3JhaXRocy4=\" },\n-    { \"They say that you should never try to leave the dungeon with a bag of \"\n-      \"gems.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIG5ldmVyIHRyeSB0byBsZWF2ZSB0aGUgZHVuZ2Vvb\"\n-      \"iB3aXRoIGEgYmFnIG9mIGdlbXMu\" },\n-    { \"They say that you should remove your armor before sitting on a throne.\",\n-      \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIHJlbW92ZSB5b3VyIGFybW9yIGJlZm9yZSBzaXR0a\"\n-      \"W5nIG9uIGEgdGhyb25lLg==\" },\n-    { \"This fortune cookie is copy protected.\",\n-      \"VGhpcyBmb3J0dW5lIGNvb2tpZSBpcyBjb3B5IHByb3RlY3RlZC4=\" },\n-    { \"This fortune cookie is the property of Fortune Cookies, Inc.\",\n-      \"VGhpcyBmb3J0dW5lIGNvb2tpZSBpcyB0aGUgcHJvcGVydHkgb2YgRm9ydHVuZSBDb29raWVzL\"\n-      \"CBJbmMu\" },\n-    { \"Tired? Try a scroll of charging on yourself.\",\n-      \"VGlyZWQ/IFRyeSBhIHNjcm9sbCBvZiBjaGFyZ2luZyBvbiB5b3Vyc2VsZi4=\" },\n-    { \"To achieve the next higher rating, you need 3 more points.\",\n-      \"VG8gYWNoaWV2ZSB0aGUgbmV4dCBoaWdoZXIgcmF0aW5nLCB5b3UgbmVlZCAzIG1vcmUgcG9pb\"\n-      \"nRzLg==\" },\n-    { \"To reach heaven, escape the dungeon while wearing a ring of levitation.\",\n-      \"VG8gcmVhY2ggaGVhdmVuLCBlc2NhcGUgdGhlIGR1bmdlb24gd2hpbGUgd2VhcmluZyBhIHJpb\"\n-      \"mcgb2YgbGV2aXRhdGlvbi4=\" },\n-    { \"Tourists wear shirts loud enough to wake the dead.\",\n-      \"VG91cmlzdHMgd2VhciBzaGlydHMgbG91ZCBlbm91Z2ggdG8gd2FrZSB0aGUgZGVhZC4=\" },\n-    { \"Try calling your katana Moulinette.\",\n-      \"VHJ5IGNhbGxpbmcgeW91ciBrYXRhbmEgTW91bGluZXR0ZS4=\" },\n-    { \"Ulch! That meat was painted!\",\n-      \"VWxjaCEgVGhhdCBtZWF0IHdhcyBwYWludGVkIQ==\" },\n-    { \"Unfortunately, this message was left intentionally blank.\",\n-      \"VW5mb3J0dW5hdGVseSwgdGhpcyBtZXNzYWdlIHdhcyBsZWZ0IGludGVudGlvbmFsbHkgYmxhb\"\n-      \"msu\" },\n-    { \"Using a morning star in the evening has no effect.\",\n-      \"VXNpbmcgYSBtb3JuaW5nIHN0YXIgaW4gdGhlIGV2ZW5pbmcgaGFzIG5vIGVmZmVjdC4=\" },\n-    { \"Want a hint? Zap a wand of make invisible on your weapon!\",\n-      \"V2FudCBhIGhpbnQ/\"\n-      \"IFphcCBhIHdhbmQgb2YgbWFrZSBpbnZpc2libGUgb24geW91ciB3ZWFwb24h\" },\n-    { \"Want to ascend in a hurry? Apply at Gizmonic Institute.\",\n-      \"V2FudCB0byBhc2NlbmQgaW4gYSBodXJyeT8gQXBwbHkgYXQgR2l6bW9uaWMgSW5zdGl0dXRlL\"\n-      \"g==\" },\n-    { \"Wanted: shopkeepers. Send a scroll of mail to Mage of Yendor/Level \"\n-      \"35/Dungeon.\",\n-      \"V2FudGVkOiBzaG9wa2VlcGVycy4gU2VuZCBhIHNjcm9sbCBvZiBtYWlsIHRvIE1hZ2Ugb2YgW\"\n-      \"WVuZG9yL0xldmVsIDM1L0R1bmdlb24u\" },\n-    { \"Warning: fortune reading can be hazardous to your health.\",\n-      \"V2FybmluZzogZm9ydHVuZSByZWFkaW5nIGNhbiBiZSBoYXphcmRvdXMgdG8geW91ciBoZWFsd\"\n-      \"Ggu\" },\n-    { \"We have new ways of detecting treachery...\",\n-      \"V2UgaGF2ZSBuZXcgd2F5cyBvZiBkZXRlY3RpbmcgdHJlYWNoZXJ5Li4u\" },\n-    { \"Wet towels make great weapons!\",\n-      \"V2V0IHRvd2VscyBtYWtlIGdyZWF0IHdlYXBvbnMh\" },\n-    { \"What a pity, you cannot read it!\",\n-      \"V2hhdCBhIHBpdHksIHlvdSBjYW5ub3QgcmVhZCBpdCE=\" },\n-    { \"When a piercer drops in on you, you will be tempted to hit the ceiling!\",\n-      \"V2hlbiBhIHBpZXJjZXIgZHJvcHMgaW4gb24geW91LCB5b3Ugd2lsbCBiZSB0ZW1wdGVkIHRvI\"\n-      \"GhpdCB0aGUgY2VpbGluZyE=\" },\n-    { \"When in a maze follow the right wall and you will never get lost.\",\n-      \"V2hlbiBpbiBhIG1hemUgZm9sbG93IHRoZSByaWdodCB3YWxsIGFuZCB5b3Ugd2lsbCBuZXZlc\"\n-      \"iBnZXQgbG9zdC4=\" },\n-    { \"When you have a key, you don't have to wait for the guard.\",\n-      \"V2hlbiB5b3UgaGF2ZSBhIGtleSwgeW91IGRvbid0IGhhdmUgdG8gd2FpdCBmb3IgdGhlIGd1Y\"\n-      \"XJkLg==\" },\n-    { \"Why are you wasting time reading fortunes?\",\n-      \"V2h5IGFyZSB5b3Ugd2FzdGluZyB0aW1lIHJlYWRpbmcgZm9ydHVuZXM/\" },\n-    { \"Wish for a master key and open the Magic Memory Vault!\",\n-      \"V2lzaCBmb3IgYSBtYXN0ZXIga2V5IGFuZCBvcGVuIHRoZSBNYWdpYyBNZW1vcnkgVmF1bHQ\"\n-      \"h\" },\n-    { \"Wizard expects every monster to do its duty.\",\n-      \"V2l6YXJkIGV4cGVjdHMgZXZlcnkgbW9uc3RlciB0byBkbyBpdHMgZHV0eS4=\" },\n-    { \"Wow! You could've had a potion of fruit juice!\",\n-      \"V293ISBZb3UgY291bGQndmUgaGFkIGEgcG90aW9uIG9mIGZydWl0IGp1aWNlIQ==\" },\n-    { \"Yet Another Silly Message (YASM).\",\n-      \"WWV0IEFub3RoZXIgU2lsbHkgTWVzc2FnZSAoWUFTTSku\" },\n-    { \"You are destined to be misled by a fortune.\",\n-      \"WW91IGFyZSBkZXN0aW5lZCB0byBiZSBtaXNsZWQgYnkgYSBmb3J0dW5lLg==\" },\n-    { \"You can get a genuine Amulet of Yendor by doing the following: --More--\",\n-      \"WW91IGNhbiBnZXQgYSBnZW51aW5lIEFtdWxldCBvZiBZZW5kb3IgYnkgZG9pbmcgdGhlIGZvb\"\n-      \"Gxvd2luZzogLS1Nb3JlLS0=\" },\n-    { \"You can protect yourself from black dragons by doing the following: \"\n-      \"--More--\",\n-      \"WW91IGNhbiBwcm90ZWN0IHlvdXJzZWxmIGZyb20gYmxhY2sgZHJhZ29ucyBieSBkb2luZyB0a\"\n-      \"GUgZm9sbG93aW5nOiAtLU1vcmUtLQ==\" },\n-    { \"You can't get by the snake.\", \"WW91IGNhbid0IGdldCBieSB0aGUgc25ha2Uu\" },\n-    { \"You feel like someone is pulling your leg.\",\n-      \"WW91IGZlZWwgbGlrZSBzb21lb25lIGlzIHB1bGxpbmcgeW91ciBsZWcu\" },\n-    { \"You have to outwit the Sphynx or pay her.\",\n-      \"WW91IGhhdmUgdG8gb3V0d2l0IHRoZSBTcGh5bnggb3IgcGF5IGhlci4=\" },\n-    { \"You hear the fortune cookie's hissing!\",\n-      \"WW91IGhlYXIgdGhlIGZvcnR1bmUgY29va2llJ3MgaGlzc2luZyE=\" },\n-    { \"You may get rich selling letters, but beware of being blackmailed!\",\n-      \"WW91IG1heSBnZXQgcmljaCBzZWxsaW5nIGxldHRlcnMsIGJ1dCBiZXdhcmUgb2YgYmVpbmcgY\"\n-      \"mxhY2ttYWlsZWQh\" },\n-    { \"You offend Shai-Hulud by sheathing your crysknife without having drawn \"\n-      \"blood.\",\n-      \"WW91IG9mZmVuZCBTaGFpLUh1bHVkIGJ5IHNoZWF0aGluZyB5b3VyIGNyeXNrbmlmZSB3aXRob\"\n-      \"3V0IGhhdmluZyBkcmF3biBibG9vZC4=\" },\n-    { \"You swallowed the fortune!\", \"WW91IHN3YWxsb3dlZCB0aGUgZm9ydHVuZSE=\" },\n-    { \"You want to regain strength? Two levels ahead is a guesthouse!\",\n-      \"WW91IHdhbnQgdG8gcmVnYWluIHN0cmVuZ3RoPyBUd28gbGV2ZWxzIGFoZWFkIGlzIGEgZ3Vlc\"\n-      \"3Rob3VzZSE=\" },\n-    { \"You will encounter a tall, dark, and gruesome creature...\",\n-      \"WW91IHdpbGwgZW5jb3VudGVyIGEgdGFsbCwgZGFyaywgYW5kIGdydWVzb21lIGNyZWF0dXJlL\"\n-      \"i4u\" },\n-\n-    { \"The End\", \"VGhlIEVuZA==\" }\n-};\n+    {\"\\\"So when I die, the first thing I will see in heaven is a score list?\\\"\",\n+     \"IlNvIHdoZW4gSSBkaWUsIHRoZSBmaXJzdCB0aGluZyBJIHdpbGwgc2VlIGluIGhlYXZlbiBpc\"\n+     \"yBhIHNjb3JlIGxpc3Q/Ig==\"},\n+    {\"1st Law of Hacking: leaving is much more difficult than entering.\",\n+     \"MXN0IExhdyBvZiBIYWNraW5nOiBsZWF2aW5nIGlzIG11Y2ggbW9yZSBkaWZmaWN1bHQgdGhhb\"\n+     \"iBlbnRlcmluZy4=\"},\n+    {\"2nd Law of Hacking: first in, first out.\",\n+     \"Mm5kIExhdyBvZiBIYWNraW5nOiBmaXJzdCBpbiwgZmlyc3Qgb3V0Lg==\"},\n+    {\"3rd Law of Hacking: the last blow counts most.\",\n+     \"M3JkIExhdyBvZiBIYWNraW5nOiB0aGUgbGFzdCBibG93IGNvdW50cyBtb3N0Lg==\"},\n+    {\"4th Law of Hacking: you will find the exit at the entrance.\",\n+     \"NHRoIExhdyBvZiBIYWNraW5nOiB5b3Ugd2lsbCBmaW5kIHRoZSBleGl0IGF0IHRoZSBlbnRyY\"\n+     \"W5jZS4=\"},\n+    {\"A chameleon imitating a mail daemon often delivers scrolls of fire.\",\n+     \"QSBjaGFtZWxlb24gaW1pdGF0aW5nIGEgbWFpbCBkYWVtb24gb2Z0ZW4gZGVsaXZlcnMgc2Nyb\"\n+     \"2xscyBvZiBmaXJlLg==\"},\n+    {\"A cockatrice corpse is guaranteed to be untainted!\",\n+     \"QSBjb2NrYXRyaWNlIGNvcnBzZSBpcyBndWFyYW50ZWVkIHRvIGJlIHVudGFpbnRlZCE=\"},\n+    {\"A dead cockatrice is just a dead lizard.\",\n+     \"QSBkZWFkIGNvY2thdHJpY2UgaXMganVzdCBhIGRlYWQgbGl6YXJkLg==\"},\n+    {\"A dragon is just a snake that ate a scroll of fire.\",\n+     \"QSBkcmFnb24gaXMganVzdCBhIHNuYWtlIHRoYXQgYXRlIGEgc2Nyb2xsIG9mIGZpcmUu\"},\n+    {\"A fading corridor enlightens your insight.\",\n+     \"QSBmYWRpbmcgY29ycmlkb3IgZW5saWdodGVucyB5b3VyIGluc2lnaHQu\"},\n+    {\"A glowing potion is too hot to drink.\",\n+     \"QSBnbG93aW5nIHBvdGlvbiBpcyB0b28gaG90IHRvIGRyaW5rLg==\"},\n+    {\"A good amulet may protect you against guards.\",\n+     \"QSBnb29kIGFtdWxldCBtYXkgcHJvdGVjdCB5b3UgYWdhaW5zdCBndWFyZHMu\"},\n+    {\"A lizard corpse is a good thing to turn undead.\",\n+     \"QSBsaXphcmQgY29ycHNlIGlzIGEgZ29vZCB0aGluZyB0byB0dXJuIHVuZGVhZC4=\"},\n+    {\"A long worm can be defined recursively. So how should you attack it?\",\n+     \"QSBsb25nIHdvcm0gY2FuIGJlIGRlZmluZWQgcmVjdXJzaXZlbHkuIFNvIGhvdyBzaG91bGQge\"\n+     \"W91IGF0dGFjayBpdD8=\"},\n+    {\"A monstrous mind is a toy forever.\",\n+     \"QSBtb25zdHJvdXMgbWluZCBpcyBhIHRveSBmb3JldmVyLg==\"},\n+    {\"A nymph will be very pleased if you call her by her real name: Lorelei.\",\n+     \"QSBueW1waCB3aWxsIGJlIHZlcnkgcGxlYXNlZCBpZiB5b3UgY2FsbCBoZXIgYnkgaGVyIHJlY\"\n+     \"WwgbmFtZTogTG9yZWxlaS4=\"},\n+    {\"A ring of dungeon master control is a great find.\",\n+     \"QSByaW5nIG9mIGR1bmdlb24gbWFzdGVyIGNvbnRyb2wgaXMgYSBncmVhdCBmaW5kLg==\"},\n+    {\"A ring of extra ring finger is useless if not enchanted.\",\n+     \"QSByaW5nIG9mIGV4dHJhIHJpbmcgZmluZ2VyIGlzIHVzZWxlc3MgaWYgbm90IGVuY2hhbnRlZ\"\n+     \"C4=\"},\n+    {\"A rope may form a trail in a maze.\",\n+     \"QSByb3BlIG1heSBmb3JtIGEgdHJhaWwgaW4gYSBtYXplLg==\"},\n+    {\"A staff may recharge if you drop it for awhile.\",\n+     \"QSBzdGFmZiBtYXkgcmVjaGFyZ2UgaWYgeW91IGRyb3AgaXQgZm9yIGF3aGlsZS4=\"},\n+    {\"A visit to the Zoo is very educational; you meet interesting animals.\",\n+     \"QSB2aXNpdCB0byB0aGUgWm9vIGlzIHZlcnkgZWR1Y2F0aW9uYWw7IHlvdSBtZWV0IGludGVyZ\"\n+     \"XN0aW5nIGFuaW1hbHMu\"},\n+    {\"A wand of deaf is a more dangerous weapon than a wand of sheep.\",\n+     \"QSB3YW5kIG9mIGRlYWYgaXMgYSBtb3JlIGRhbmdlcm91cyB3ZWFwb24gdGhhbiBhIHdhbmQgb\"\n+     \"2Ygc2hlZXAu\"},\n+    {\"A wand of vibration might bring the whole cave crashing about your ears.\",\n+     \"QSB3YW5kIG9mIHZpYnJhdGlvbiBtaWdodCBicmluZyB0aGUgd2hvbGUgY2F2ZSBjcmFzaGluZ\"\n+     \"yBhYm91dCB5b3VyIGVhcnMu\"},\n+    {\"A winner never quits. A quitter never wins.\",\n+     \"QSB3aW5uZXIgbmV2ZXIgcXVpdHMuIEEgcXVpdHRlciBuZXZlciB3aW5zLg==\"},\n+    {\"A wish? Okay, make me a fortune cookie!\",\n+     \"QSB3aXNoPyBPa2F5LCBtYWtlIG1lIGEgZm9ydHVuZSBjb29raWUh\"},\n+    {\"Afraid of mimics? Try to wear a ring of true seeing.\",\n+     \"QWZyYWlkIG9mIG1pbWljcz8gVHJ5IHRvIHdlYXIgYSByaW5nIG9mIHRydWUgc2VlaW5nLg=\"\n+     \"=\"},\n+    {\"All monsters are created evil, but some are more evil than others.\",\n+     \"QWxsIG1vbnN0ZXJzIGFyZSBjcmVhdGVkIGV2aWwsIGJ1dCBzb21lIGFyZSBtb3JlIGV2aWwgd\"\n+     \"GhhbiBvdGhlcnMu\"},\n+    {\"Always attack a floating eye from behind!\",\n+     \"QWx3YXlzIGF0dGFjayBhIGZsb2F0aW5nIGV5ZSBmcm9tIGJlaGluZCE=\"},\n+    {\"An elven cloak is always the height of fashion.\",\n+     \"QW4gZWx2ZW4gY2xvYWsgaXMgYWx3YXlzIHRoZSBoZWlnaHQgb2YgZmFzaGlvbi4=\"},\n+    {\"Any small object that is accidentally dropped will hide under a larger \"\n+     \"object.\",\n+     \"QW55IHNtYWxsIG9iamVjdCB0aGF0IGlzIGFjY2lkZW50YWxseSBkcm9wcGVkIHdpbGwgaGlkZ\"\n+     \"SB1bmRlciBhIGxhcmdlciBvYmplY3Qu\"},\n+    {\"Balrogs do not appear above level 20.\",\n+     \"QmFscm9ncyBkbyBub3QgYXBwZWFyIGFib3ZlIGxldmVsIDIwLg==\"},\n+    {\"Banana peels work especially well against Keystone Kops.\",\n+     \"QmFuYW5hIHBlZWxzIHdvcmsgZXNwZWNpYWxseSB3ZWxsIGFnYWluc3QgS2V5c3RvbmUgS29wc\"\n+     \"y4=\"},\n+    {\"Be careful when eating bananas. Monsters might slip on the peels.\",\n+     \"QmUgY2FyZWZ1bCB3aGVuIGVhdGluZyBiYW5hbmFzLiBNb25zdGVycyBtaWdodCBzbGlwIG9uI\"\n+     \"HRoZSBwZWVscy4=\"},\n+    {\"Better leave the dungeon; otherwise you might get hurt badly.\",\n+     \"QmV0dGVyIGxlYXZlIHRoZSBkdW5nZW9uOyBvdGhlcndpc2UgeW91IG1pZ2h0IGdldCBodXJ0I\"\n+     \"GJhZGx5Lg==\"},\n+    {\"Beware of the potion of nitroglycerin -- it's not for the weak of heart.\",\n+     \"QmV3YXJlIG9mIHRoZSBwb3Rpb24gb2Ygbml0cm9nbHljZXJpbiAtLSBpdCdzIG5vdCBmb3Igd\"\n+     \"GhlIHdlYWsgb2YgaGVhcnQu\"},\n+    {\"Beware: there's always a chance that your wand explodes as you try to \"\n+     \"zap it!\",\n+     \"QmV3YXJlOiB0aGVyZSdzIGFsd2F5cyBhIGNoYW5jZSB0aGF0IHlvdXIgd2FuZCBleHBsb2Rlc\"\n+     \"yBhcyB5b3UgdHJ5IHRvIHphcCBpdCE=\"},\n+    {\"Beyond the 23rd level lies a happy retirement in a room of your own.\",\n+     \"QmV5b25kIHRoZSAyM3JkIGxldmVsIGxpZXMgYSBoYXBweSByZXRpcmVtZW50IGluIGEgcm9vb\"\n+     \"SBvZiB5b3VyIG93bi4=\"},\n+    {\"Changing your suit without dropping your sword? You must be kidding!\",\n+     \"Q2hhbmdpbmcgeW91ciBzdWl0IHdpdGhvdXQgZHJvcHBpbmcgeW91ciBzd29yZD8gWW91IG11c\"\n+     \"3QgYmUga2lkZGluZyE=\"},\n+    {\"Cockatrices might turn themselves to stone faced with a mirror.\",\n+     \"Q29ja2F0cmljZXMgbWlnaHQgdHVybiB0aGVtc2VsdmVzIHRvIHN0b25lIGZhY2VkIHdpdGggY\"\n+     \"SBtaXJyb3Iu\"},\n+    {\"Consumption of home-made food is strictly forbidden in this dungeon.\",\n+     \"Q29uc3VtcHRpb24gb2YgaG9tZS1tYWRlIGZvb2QgaXMgc3RyaWN0bHkgZm9yYmlkZGVuIGluI\"\n+     \"HRoaXMgZHVuZ2Vvbi4=\"},\n+    {\"Dark room? Your chance to develop your photographs!\",\n+     \"RGFyayByb29tPyBZb3VyIGNoYW5jZSB0byBkZXZlbG9wIHlvdXIgcGhvdG9ncmFwaHMh\"},\n+    {\"Dark rooms are not *completely* dark: just wait and let your eyes \"\n+     \"adjust...\",\n+     \"RGFyayByb29tcyBhcmUgbm90ICpjb21wbGV0ZWx5KiBkYXJrOiBqdXN0IHdhaXQgYW5kIGxld\"\n+     \"CB5b3VyIGV5ZXMgYWRqdXN0Li4u\"},\n+    {\"David London sez, \\\"Hey guys, *WIELD* a lizard corpse against a \"\n+     \"cockatrice!\\\"\",\n+     \"RGF2aWQgTG9uZG9uIHNleiwgIkhleSBndXlzLCAqV0lFTEQqIGEgbGl6YXJkIGNvcnBzZSBhZ\"\n+     \"2FpbnN0IGEgY29ja2F0cmljZSEi\"},\n+    {\"Death is just life's way of telling you you've been fired.\",\n+     \"RGVhdGggaXMganVzdCBsaWZlJ3Mgd2F5IG9mIHRlbGxpbmcgeW91IHlvdSd2ZSBiZWVuIGZpc\"\n+     \"mVkLg==\"},\n+    {\"Demi-gods don't need any help from the gods.\",\n+     \"RGVtaS1nb2RzIGRvbid0IG5lZWQgYW55IGhlbHAgZnJvbSB0aGUgZ29kcy4=\"},\n+    {\"Demons *HATE* Priests and Priestesses.\",\n+     \"RGVtb25zICpIQVRFKiBQcmllc3RzIGFuZCBQcmllc3Rlc3Nlcy4=\"},\n+    {\"Didn't you forget to pay?\", \"RGlkbid0IHlvdSBmb3JnZXQgdG8gcGF5Pw==\"},\n+    {\"Didn't your mother tell you not to eat food off the floor?\",\n+     \"RGlkbid0IHlvdXIgbW90aGVyIHRlbGwgeW91IG5vdCB0byBlYXQgZm9vZCBvZmYgdGhlIGZsb\"\n+     \"29yPw==\"},\n+    {\"Direct a direct hit on your direct opponent, directing in the right \"\n+     \"direction.\",\n+     \"RGlyZWN0IGEgZGlyZWN0IGhpdCBvbiB5b3VyIGRpcmVjdCBvcHBvbmVudCwgZGlyZWN0aW5nI\"\n+     \"GluIHRoZSByaWdodCBkaXJlY3Rpb24u\"},\n+    {\"Do you want to make more money? Sure, we all do! Join the Fort Ludios \"\n+     \"guard!\",\n+     \"RG8geW91IHdhbnQgdG8gbWFrZSBtb3JlIG1vbmV5PyBTdXJlLCB3ZSBhbGwgZG8hIEpvaW4gd\"\n+     \"GhlIEZvcnQgTHVkaW9zIGd1YXJkIQ==\"},\n+    {\"Don't eat too much: you might start hiccoughing!\",\n+     \"RG9uJ3QgZWF0IHRvbyBtdWNoOiB5b3UgbWlnaHQgc3RhcnQgaGljY291Z2hpbmch\"},\n+    {\"Don't play hack at your work; your boss might hit you!\",\n+     \"RG9uJ3QgcGxheSBoYWNrIGF0IHlvdXIgd29yazsgeW91ciBib3NzIG1pZ2h0IGhpdCB5b3U\"\n+     \"h\"},\n+    {\"Don't tell a soul you found a secret door, otherwise it isn't a secret \"\n+     \"anymore.\",\n+     \"RG9uJ3QgdGVsbCBhIHNvdWwgeW91IGZvdW5kIGEgc2VjcmV0IGRvb3IsIG90aGVyd2lzZSBpd\"\n+     \"CBpc24ndCBhIHNlY3JldCBhbnltb3JlLg==\"},\n+    {\"Drinking potions of booze may land you in jail if you are under 21.\",\n+     \"RHJpbmtpbmcgcG90aW9ucyBvZiBib296ZSBtYXkgbGFuZCB5b3UgaW4gamFpbCBpZiB5b3UgY\"\n+     \"XJlIHVuZGVyIDIxLg==\"},\n+    {\"Drop your vanity and get rid of your jewels! Pickpockets about!\",\n+     \"RHJvcCB5b3VyIHZhbml0eSBhbmQgZ2V0IHJpZCBvZiB5b3VyIGpld2VscyEgUGlja3BvY2tld\"\n+     \"HMgYWJvdXQh\"},\n+    {\"Eat 10 cloves of garlic and keep all humans at a two-square distance.\",\n+     \"RWF0IDEwIGNsb3ZlcyBvZiBnYXJsaWMgYW5kIGtlZXAgYWxsIGh1bWFucyBhdCBhIHR3by1zc\"\n+     \"XVhcmUgZGlzdGFuY2Uu\"},\n+    {\"Eels hide under mud. Use a unicorn to clear the water and make them \"\n+     \"visible.\",\n+     \"RWVscyBoaWRlIHVuZGVyIG11ZC4gVXNlIGEgdW5pY29ybiB0byBjbGVhciB0aGUgd2F0ZXIgY\"\n+     \"W5kIG1ha2UgdGhlbSB2aXNpYmxlLg==\"},\n+    {\"Engrave your wishes with a wand of wishing.\",\n+     \"RW5ncmF2ZSB5b3VyIHdpc2hlcyB3aXRoIGEgd2FuZCBvZiB3aXNoaW5nLg==\"},\n+    {\"Eventually you will come to admire the swift elegance of a retreating \"\n+     \"nymph.\",\n+     \"RXZlbnR1YWxseSB5b3Ugd2lsbCBjb21lIHRvIGFkbWlyZSB0aGUgc3dpZnQgZWxlZ2FuY2Ugb\"\n+     \"2YgYSByZXRyZWF0aW5nIG55bXBoLg==\"},\n+    {\"Ever heard hissing outside? I *knew* you hadn't!\",\n+     \"RXZlciBoZWFyZCBoaXNzaW5nIG91dHNpZGU/IEkgKmtuZXcqIHlvdSBoYWRuJ3Qh\"},\n+    {\"Ever lifted a dragon corpse?\",\n+     \"RXZlciBsaWZ0ZWQgYSBkcmFnb24gY29ycHNlPw==\"},\n+    {\"Ever seen a leocrotta dancing the tengu?\",\n+     \"RXZlciBzZWVuIGEgbGVvY3JvdHRhIGRhbmNpbmcgdGhlIHRlbmd1Pw==\"},\n+    {\"Ever seen your weapon glow plaid?\",\n+     \"RXZlciBzZWVuIHlvdXIgd2VhcG9uIGdsb3cgcGxhaWQ/\"},\n+    {\"Ever tamed a shopkeeper?\", \"RXZlciB0YW1lZCBhIHNob3BrZWVwZXI/\"},\n+    {\"Ever tried digging through a Vault Guard?\",\n+     \"RXZlciB0cmllZCBkaWdnaW5nIHRocm91Z2ggYSBWYXVsdCBHdWFyZD8=\"},\n+    {\"Ever tried enchanting a rope?\",\n+     \"RXZlciB0cmllZCBlbmNoYW50aW5nIGEgcm9wZT8=\"},\n+    {\"Floating eyes can't stand Hawaiian shirts.\",\n+     \"RmxvYXRpbmcgZXllcyBjYW4ndCBzdGFuZCBIYXdhaWlhbiBzaGlydHMu\"},\n+    {\"For any remedy there is a misery.\",\n+     \"Rm9yIGFueSByZW1lZHkgdGhlcmUgaXMgYSBtaXNlcnku\"},\n+    {\"Giant bats turn into giant vampires.\",\n+     \"R2lhbnQgYmF0cyB0dXJuIGludG8gZ2lhbnQgdmFtcGlyZXMu\"},\n+    {\"Good day for overcoming obstacles. Try a steeplechase.\",\n+     \"R29vZCBkYXkgZm9yIG92ZXJjb21pbmcgb2JzdGFjbGVzLiBUcnkgYSBzdGVlcGxlY2hhc2U\"\n+     \"u\"},\n+    {\"Half Moon tonight. (At least it's better than no Moon at all.)\",\n+     \"SGFsZiBNb29uIHRvbmlnaHQuIChBdCBsZWFzdCBpdCdzIGJldHRlciB0aGFuIG5vIE1vb24gY\"\n+     \"XQgYWxsLik=\"},\n+    {\"Help! I'm being held prisoner in a fortune cookie factory!\",\n+     \"SGVscCEgSSdtIGJlaW5nIGhlbGQgcHJpc29uZXIgaW4gYSBmb3J0dW5lIGNvb2tpZSBmYWN0b\"\n+     \"3J5IQ==\"},\n+    {\"Housecats have nine lives, kittens only one.\",\n+     \"SG91c2VjYXRzIGhhdmUgbmluZSBsaXZlcywga2l0dGVucyBvbmx5IG9uZS4=\"},\n+    {\"How long can you tread water?\",\n+     \"SG93IGxvbmcgY2FuIHlvdSB0cmVhZCB3YXRlcj8=\"},\n+    {\"Hungry? There is an abundance of food on the next level.\",\n+     \"SHVuZ3J5PyBUaGVyZSBpcyBhbiBhYnVuZGFuY2Ugb2YgZm9vZCBvbiB0aGUgbmV4dCBsZXZlb\"\n+     \"C4=\"},\n+    {\"I guess you've never hit a mail daemon with the Amulet of Yendor...\",\n+     \"SSBndWVzcyB5b3UndmUgbmV2ZXIgaGl0IGEgbWFpbCBkYWVtb24gd2l0aCB0aGUgQW11bGV0I\"\n+     \"G9mIFllbmRvci4uLg==\"},\n+    {\"If you are the shopkeeper, you can take things for free.\",\n+     \"SWYgeW91IGFyZSB0aGUgc2hvcGtlZXBlciwgeW91IGNhbiB0YWtlIHRoaW5ncyBmb3IgZnJlZ\"\n+     \"S4=\"},\n+    {\"If you can't learn to do it well, learn to enjoy doing it badly.\",\n+     \"SWYgeW91IGNhbid0IGxlYXJuIHRvIGRvIGl0IHdlbGwsIGxlYXJuIHRvIGVuam95IGRvaW5nI\"\n+     \"Gl0IGJhZGx5Lg==\"},\n+    {\"If you thought the Wizard was bad, just wait till you meet the Warlord!\",\n+     \"SWYgeW91IHRob3VnaHQgdGhlIFdpemFyZCB3YXMgYmFkLCBqdXN0IHdhaXQgdGlsbCB5b3Ugb\"\n+     \"WVldCB0aGUgV2FybG9yZCE=\"},\n+    {\"If you turn blind, don't expect your dog to be turned into a seeing-eye \"\n+     \"dog.\",\n+     \"SWYgeW91IHR1cm4gYmxpbmQsIGRvbid0IGV4cGVjdCB5b3VyIGRvZyB0byBiZSB0dXJuZWQga\"\n+     \"W50byBhIHNlZWluZy1leWUgZG9nLg==\"},\n+    {\"If you want to feel great, you must eat something real big.\",\n+     \"SWYgeW91IHdhbnQgdG8gZmVlbCBncmVhdCwgeW91IG11c3QgZWF0IHNvbWV0aGluZyByZWFsI\"\n+     \"GJpZy4=\"},\n+    {\"If you want to float, you'd better eat a floating eye.\",\n+     \"SWYgeW91IHdhbnQgdG8gZmxvYXQsIHlvdSdkIGJldHRlciBlYXQgYSBmbG9hdGluZyBleWU\"\n+     \"u\"},\n+    {\"If your ghost kills a player, it increases your score.\",\n+     \"SWYgeW91ciBnaG9zdCBraWxscyBhIHBsYXllciwgaXQgaW5jcmVhc2VzIHlvdXIgc2NvcmU\"\n+     \"u\"},\n+    {\"Increase mindpower: Tame your own ghost!\",\n+     \"SW5jcmVhc2UgbWluZHBvd2VyOiBUYW1lIHlvdXIgb3duIGdob3N0IQ==\"},\n+    {\"It furthers one to see the great man.\",\n+     \"SXQgZnVydGhlcnMgb25lIHRvIHNlZSB0aGUgZ3JlYXQgbWFuLg==\"},\n+    {\"It's easy to overlook a monster in a wood.\",\n+     \"SXQncyBlYXN5IHRvIG92ZXJsb29rIGEgbW9uc3RlciBpbiBhIHdvb2Qu\"},\n+    {\"Just below any trapdoor there may be another one. Just keep falling!\",\n+     \"SnVzdCBiZWxvdyBhbnkgdHJhcGRvb3IgdGhlcmUgbWF5IGJlIGFub3RoZXIgb25lLiBKdXN0I\"\n+     \"GtlZXAgZmFsbGluZyE=\"},\n+    {\"Katanas are very sharp; watch you don't cut yourself.\",\n+     \"S2F0YW5hcyBhcmUgdmVyeSBzaGFycDsgd2F0Y2ggeW91IGRvbid0IGN1dCB5b3Vyc2VsZi4\"\n+     \"=\"},\n+    {\"Keep a clear mind: quaff clear potions.\",\n+     \"S2VlcCBhIGNsZWFyIG1pbmQ6IHF1YWZmIGNsZWFyIHBvdGlvbnMu\"},\n+    {\"Kicking the terminal doesn't hurt the monsters.\",\n+     \"S2lja2luZyB0aGUgdGVybWluYWwgZG9lc24ndCBodXJ0IHRoZSBtb25zdGVycy4=\"},\n+    {\"Killer bees keep appearing till you kill their queen.\",\n+     \"S2lsbGVyIGJlZXMga2VlcCBhcHBlYXJpbmcgdGlsbCB5b3Uga2lsbCB0aGVpciBxdWVlbi4\"\n+     \"=\"},\n+    {\"Killer bunnies can be tamed with carrots only.\",\n+     \"S2lsbGVyIGJ1bm5pZXMgY2FuIGJlIHRhbWVkIHdpdGggY2Fycm90cyBvbmx5Lg==\"},\n+    {\"Latest news? Put `rec.games.roguelike.nethack' in your .newsrc!\",\n+     \"TGF0ZXN0IG5ld3M/\"\n+     \"IFB1dCBgcmVjLmdhbWVzLnJvZ3VlbGlrZS5uZXRoYWNrJyBpbiB5b3VyIC5uZXdzcmMh\"},\n+    {\"Learn how to spell. Play NetHack!\",\n+     \"TGVhcm4gaG93IHRvIHNwZWxsLiBQbGF5IE5ldEhhY2sh\"},\n+    {\"Leprechauns hide their gold in a secret room.\",\n+     \"TGVwcmVjaGF1bnMgaGlkZSB0aGVpciBnb2xkIGluIGEgc2VjcmV0IHJvb20u\"},\n+    {\"Let your fingers do the walking on the yulkjhnb keys.\",\n+     \"TGV0IHlvdXIgZmluZ2VycyBkbyB0aGUgd2Fsa2luZyBvbiB0aGUgeXVsa2pobmIga2V5cy4\"\n+     \"=\"},\n+    {\"Let's face it: this time you're not going to win.\",\n+     \"TGV0J3MgZmFjZSBpdDogdGhpcyB0aW1lIHlvdSdyZSBub3QgZ29pbmcgdG8gd2luLg==\"},\n+    {\"Let's have a party, drink a lot of booze.\",\n+     \"TGV0J3MgaGF2ZSBhIHBhcnR5LCBkcmluayBhIGxvdCBvZiBib296ZS4=\"},\n+    {\"Liquor sellers do not drink; they hate to see you twice.\",\n+     \"TGlxdW9yIHNlbGxlcnMgZG8gbm90IGRyaW5rOyB0aGV5IGhhdGUgdG8gc2VlIHlvdSB0d2ljZ\"\n+     \"S4=\"},\n+    {\"Lunar eclipse tonight. May as well quit now!\",\n+     \"THVuYXIgZWNsaXBzZSB0b25pZ2h0LiBNYXkgYXMgd2VsbCBxdWl0IG5vdyE=\"},\n+    {\"Meeting your own ghost decreases your luck considerably!\",\n+     \"TWVldGluZyB5b3VyIG93biBnaG9zdCBkZWNyZWFzZXMgeW91ciBsdWNrIGNvbnNpZGVyYWJse\"\n+     \"SE=\"},\n+    {\"Money to invest? Take it to the local branch of the Magic Memory Vault!\",\n+     \"TW9uZXkgdG8gaW52ZXN0PyBUYWtlIGl0IHRvIHRoZSBsb2NhbCBicmFuY2ggb2YgdGhlIE1hZ\"\n+     \"2ljIE1lbW9yeSBWYXVsdCE=\"},\n+    {\"Monsters come from nowhere to hit you everywhere.\",\n+     \"TW9uc3RlcnMgY29tZSBmcm9tIG5vd2hlcmUgdG8gaGl0IHlvdSBldmVyeXdoZXJlLg==\"},\n+    {\"Monsters sleep because you are boring, not because they ever get tired.\",\n+     \"TW9uc3RlcnMgc2xlZXAgYmVjYXVzZSB5b3UgYXJlIGJvcmluZywgbm90IGJlY2F1c2UgdGhle\"\n+     \"SBldmVyIGdldCB0aXJlZC4=\"},\n+    {\"Most monsters prefer minced meat. That's why they are hitting you!\",\n+     \"TW9zdCBtb25zdGVycyBwcmVmZXIgbWluY2VkIG1lYXQuIFRoYXQncyB3aHkgdGhleSBhcmUga\"\n+     \"Gl0dGluZyB5b3Uh\"},\n+    {\"Most of the bugs in NetHack are on the floor.\",\n+     \"TW9zdCBvZiB0aGUgYnVncyBpbiBOZXRIYWNrIGFyZSBvbiB0aGUgZmxvb3Iu\"},\n+    {\"Much ado Nothing Happens.\", \"TXVjaCBhZG8gTm90aGluZyBIYXBwZW5zLg==\"},\n+    {\"Multi-player NetHack is a myth.\",\n+     \"TXVsdGktcGxheWVyIE5ldEhhY2sgaXMgYSBteXRoLg==\"},\n+    {\"NetHack is addictive. Too late, you're already hooked.\",\n+     \"TmV0SGFjayBpcyBhZGRpY3RpdmUuIFRvbyBsYXRlLCB5b3UncmUgYWxyZWFkeSBob29rZWQ\"\n+     \"u\"},\n+    {\"Never ask a shopkeeper for a price list.\",\n+     \"TmV2ZXIgYXNrIGEgc2hvcGtlZXBlciBmb3IgYSBwcmljZSBsaXN0Lg==\"},\n+    {\"Never burn a tree, unless you like getting whacked with a +5 shovel.\",\n+     \"TmV2ZXIgYnVybiBhIHRyZWUsIHVubGVzcyB5b3UgbGlrZSBnZXR0aW5nIHdoYWNrZWQgd2l0a\"\n+     \"CBhICs1IHNob3ZlbC4=\"},\n+    {\"Never eat with glowing hands!\",\n+     \"TmV2ZXIgZWF0IHdpdGggZ2xvd2luZyBoYW5kcyE=\"},\n+    {\"Never mind the monsters hitting you: they just replace the charwomen.\",\n+     \"TmV2ZXIgbWluZCB0aGUgbW9uc3RlcnMgaGl0dGluZyB5b3U6IHRoZXkganVzdCByZXBsYWNlI\"\n+     \"HRoZSBjaGFyd29tZW4u\"},\n+    {\"Never play leapfrog with a unicorn.\",\n+     \"TmV2ZXIgcGxheSBsZWFwZnJvZyB3aXRoIGEgdW5pY29ybi4=\"},\n+    {\"Never step on a cursed engraving.\",\n+     \"TmV2ZXIgc3RlcCBvbiBhIGN1cnNlZCBlbmdyYXZpbmcu\"},\n+    {\"Never swim with a camera: there's nothing to take pictures of.\",\n+     \"TmV2ZXIgc3dpbSB3aXRoIGEgY2FtZXJhOiB0aGVyZSdzIG5vdGhpbmcgdG8gdGFrZSBwaWN0d\"\n+     \"XJlcyBvZi4=\"},\n+    {\"Never teach your pet rust monster to fetch.\",\n+     \"TmV2ZXIgdGVhY2ggeW91ciBwZXQgcnVzdCBtb25zdGVyIHRvIGZldGNoLg==\"},\n+    {\"Never trust a random generator in magic fields.\",\n+     \"TmV2ZXIgdHJ1c3QgYSByYW5kb20gZ2VuZXJhdG9yIGluIG1hZ2ljIGZpZWxkcy4=\"},\n+    {\"Never use a wand of death.\", \"TmV2ZXIgdXNlIGEgd2FuZCBvZiBkZWF0aC4=\"},\n+    {\"No level contains two shops. The maze is no level. So...\",\n+     \"Tm8gbGV2ZWwgY29udGFpbnMgdHdvIHNob3BzLiBUaGUgbWF6ZSBpcyBubyBsZXZlbC4gU28uL\"\n+     \"i4=\"},\n+    {\"No part of this fortune may be reproduced, stored in a retrieval system, \"\n+     \"...\",\n+     \"Tm8gcGFydCBvZiB0aGlzIGZvcnR1bmUgbWF5IGJlIHJlcHJvZHVjZWQsIHN0b3JlZCBpbiBhI\"\n+     \"HJldHJpZXZhbCBzeXN0ZW0sIC4uLg==\"},\n+    {\"Not all rumors are as misleading as this one.\",\n+     \"Tm90IGFsbCBydW1vcnMgYXJlIGFzIG1pc2xlYWRpbmcgYXMgdGhpcyBvbmUu\"},\n+    {\"Nymphs and nurses like beautiful rings.\",\n+     \"TnltcGhzIGFuZCBudXJzZXMgbGlrZSBiZWF1dGlmdWwgcmluZ3Mu\"},\n+    {\"Nymphs are blondes. Are you a gentleman?\",\n+     \"TnltcGhzIGFyZSBibG9uZGVzLiBBcmUgeW91IGEgZ2VudGxlbWFuPw==\"},\n+    {\"Offering a unicorn a worthless piece of glass might prove to be fatal!\",\n+     \"T2ZmZXJpbmcgYSB1bmljb3JuIGEgd29ydGhsZXNzIHBpZWNlIG9mIGdsYXNzIG1pZ2h0IHByb\"\n+     \"3ZlIHRvIGJlIGZhdGFsIQ==\"},\n+    {\"Old hackers never die: young ones do.\",\n+     \"T2xkIGhhY2tlcnMgbmV2ZXIgZGllOiB5b3VuZyBvbmVzIGRvLg==\"},\n+    {\"One has to leave shops before closing time.\",\n+     \"T25lIGhhcyB0byBsZWF2ZSBzaG9wcyBiZWZvcmUgY2xvc2luZyB0aW1lLg==\"},\n+    {\"One homunculus a day keeps the doctor away.\",\n+     \"T25lIGhvbXVuY3VsdXMgYSBkYXkga2VlcHMgdGhlIGRvY3RvciBhd2F5Lg==\"},\n+    {\"One level further down somebody is getting killed, right now.\",\n+     \"T25lIGxldmVsIGZ1cnRoZXIgZG93biBzb21lYm9keSBpcyBnZXR0aW5nIGtpbGxlZCwgcmlna\"\n+     \"HQgbm93Lg==\"},\n+    {\"Only a wizard can use a magic whistle.\",\n+     \"T25seSBhIHdpemFyZCBjYW4gdXNlIGEgbWFnaWMgd2hpc3RsZS4=\"},\n+    {\"Only adventurers of evil alignment think of killing their dog.\",\n+     \"T25seSBhZHZlbnR1cmVycyBvZiBldmlsIGFsaWdubWVudCB0aGluayBvZiBraWxsaW5nIHRoZ\"\n+     \"WlyIGRvZy4=\"},\n+    {\"Only chaotic evils kill sleeping monsters.\",\n+     \"T25seSBjaGFvdGljIGV2aWxzIGtpbGwgc2xlZXBpbmcgbW9uc3RlcnMu\"},\n+    {\"Only real trappers escape traps.\",\n+     \"T25seSByZWFsIHRyYXBwZXJzIGVzY2FwZSB0cmFwcy4=\"},\n+    {\"Only real wizards can write scrolls.\",\n+     \"T25seSByZWFsIHdpemFyZHMgY2FuIHdyaXRlIHNjcm9sbHMu\"},\n+    {\"Operation OVERKILL has started now.\",\n+     \"T3BlcmF0aW9uIE9WRVJLSUxMIGhhcyBzdGFydGVkIG5vdy4=\"},\n+    {\"PLEASE ignore previous rumor.\",\n+     \"UExFQVNFIGlnbm9yZSBwcmV2aW91cyBydW1vci4=\"},\n+    {\"Polymorph into an ettin; meet your opponents face to face to face.\",\n+     \"UG9seW1vcnBoIGludG8gYW4gZXR0aW47IG1lZXQgeW91ciBvcHBvbmVudHMgZmFjZSB0byBmY\"\n+     \"WNlIHRvIGZhY2Uu\"},\n+    {\"Praying will frighten demons.\",\n+     \"UHJheWluZyB3aWxsIGZyaWdodGVuIGRlbW9ucy4=\"},\n+    {\"Row (3x) that boat gently down the stream, Charon (4x), death is but a \"\n+     \"dream.\",\n+     \"Um93ICgzeCkgdGhhdCBib2F0IGdlbnRseSBkb3duIHRoZSBzdHJlYW0sIENoYXJvbiAoNHgpL\"\n+     \"CBkZWF0aCBpcyBidXQgYSBkcmVhbS4=\"},\n+    {\"Running is good for your legs.\",\n+     \"UnVubmluZyBpcyBnb29kIGZvciB5b3VyIGxlZ3Mu\"},\n+    {\"Screw up your courage! You've screwed up everything else.\",\n+     \"U2NyZXcgdXAgeW91ciBjb3VyYWdlISBZb3UndmUgc2NyZXdlZCB1cCBldmVyeXRoaW5nIGVsc\"\n+     \"2Uu\"},\n+    {\"Seepage? Leaky pipes? Rising damp? Summon the plumber!\",\n+     \"U2VlcGFnZT8gTGVha3kgcGlwZXM/\"\n+     \"IFJpc2luZyBkYW1wPyBTdW1tb24gdGhlIHBsdW1iZXIh\"},\n+    {\"Segmentation fault (core dumped).\",\n+     \"U2VnbWVudGF0aW9uIGZhdWx0IChjb3JlIGR1bXBlZCku\"},\n+    {\"Shopkeepers sometimes die from old age.\",\n+     \"U2hvcGtlZXBlcnMgc29tZXRpbWVzIGRpZSBmcm9tIG9sZCBhZ2Uu\"},\n+    {\"Some mazes (especially small ones) have no solutions, says man 6 maze.\",\n+     \"U29tZSBtYXplcyAoZXNwZWNpYWxseSBzbWFsbCBvbmVzKSBoYXZlIG5vIHNvbHV0aW9ucywgc\"\n+     \"2F5cyBtYW4gNiBtYXplLg==\"},\n+    {\"Some questions the Sphynx asks just *don't* have any answers.\",\n+     \"U29tZSBxdWVzdGlvbnMgdGhlIFNwaHlueCBhc2tzIGp1c3QgKmRvbid0KiBoYXZlIGFueSBhb\"\n+     \"nN3ZXJzLg==\"},\n+    {\"Sometimes \\\"mu\\\" is the answer.\",\n+     \"U29tZXRpbWVzICJtdSIgaXMgdGhlIGFuc3dlci4=\"},\n+    {\"Sorry, no fortune this time. Better luck next cookie!\",\n+     \"U29ycnksIG5vIGZvcnR1bmUgdGhpcyB0aW1lLiBCZXR0ZXIgbHVjayBuZXh0IGNvb2tpZSE\"\n+     \"=\"},\n+    {\"Spare your scrolls of make-edible until it's really necessary!\",\n+     \"U3BhcmUgeW91ciBzY3JvbGxzIG9mIG1ha2UtZWRpYmxlIHVudGlsIGl0J3MgcmVhbGx5IG5lY\"\n+     \"2Vzc2FyeSE=\"},\n+    {\"Suddenly, the dungeon will collapse...\",\n+     \"U3VkZGVubHksIHRoZSBkdW5nZW9uIHdpbGwgY29sbGFwc2UuLi4=\"},\n+    {\"Taming a mail daemon may cause a system security violation.\",\n+     \"VGFtaW5nIGEgbWFpbCBkYWVtb24gbWF5IGNhdXNlIGEgc3lzdGVtIHNlY3VyaXR5IHZpb2xhd\"\n+     \"Glvbi4=\"},\n+    {\"The crowd was so tough, the Stooges won't play the Dungeon anymore, nyuk \"\n+     \"nyuk.\",\n+     \"VGhlIGNyb3dkIHdhcyBzbyB0b3VnaCwgdGhlIFN0b29nZXMgd29uJ3QgcGxheSB0aGUgRHVuZ\"\n+     \"2VvbiBhbnltb3JlLCBueXVrIG55dWsu\"},\n+    {\"The leprechauns hide their treasure in a small hidden room.\",\n+     \"VGhlIGxlcHJlY2hhdW5zIGhpZGUgdGhlaXIgdHJlYXN1cmUgaW4gYSBzbWFsbCBoaWRkZW4gc\"\n+     \"m9vbS4=\"},\n+    {\"The longer the wand the better.\",\n+     \"VGhlIGxvbmdlciB0aGUgd2FuZCB0aGUgYmV0dGVyLg==\"},\n+    {\"The magic word is \\\"XYZZY\\\".\", \"VGhlIG1hZ2ljIHdvcmQgaXMgIlhZWlpZIi4=\"},\n+    {\"The meek shall inherit your bones files.\",\n+     \"VGhlIG1lZWsgc2hhbGwgaW5oZXJpdCB5b3VyIGJvbmVzIGZpbGVzLg==\"},\n+    {\"The mines are dark and deep, and I have levels to go before I sleep.\",\n+     \"VGhlIG1pbmVzIGFyZSBkYXJrIGFuZCBkZWVwLCBhbmQgSSBoYXZlIGxldmVscyB0byBnbyBiZ\"\n+     \"WZvcmUgSSBzbGVlcC4=\"},\n+    {\"The use of dynamite is dangerous.\",\n+     \"VGhlIHVzZSBvZiBkeW5hbWl0ZSBpcyBkYW5nZXJvdXMu\"},\n+    {\"There are no worms in the UNIX version.\",\n+     \"VGhlcmUgYXJlIG5vIHdvcm1zIGluIHRoZSBVTklYIHZlcnNpb24u\"},\n+    {\"There is a trap on this level!\",\n+     \"VGhlcmUgaXMgYSB0cmFwIG9uIHRoaXMgbGV2ZWwh\"},\n+    {\"They say that Demogorgon, Asmodeus, Orcus, Yeenoghu & Juiblex is no law \"\n+     \"firm.\",\n+     \"VGhleSBzYXkgdGhhdCBEZW1vZ29yZ29uLCBBc21vZGV1cywgT3JjdXMsIFllZW5vZ2h1ICYgS\"\n+     \"nVpYmxleCBpcyBubyBsYXcgZmlybS4=\"},\n+    {\"They say that Geryon has an evil twin, beware!\",\n+     \"VGhleSBzYXkgdGhhdCBHZXJ5b24gaGFzIGFuIGV2aWwgdHdpbiwgYmV3YXJlIQ==\"},\n+    {\"They say that Medusa would make a terrible pet.\",\n+     \"VGhleSBzYXkgdGhhdCBNZWR1c2Egd291bGQgbWFrZSBhIHRlcnJpYmxlIHBldC4=\"},\n+    {\"They say that NetHack bugs are Seldon planned.\",\n+     \"VGhleSBzYXkgdGhhdCBOZXRIYWNrIGJ1Z3MgYXJlIFNlbGRvbiBwbGFubmVkLg==\"},\n+    {\"They say that NetHack comes in 256 flavors.\",\n+     \"VGhleSBzYXkgdGhhdCBOZXRIYWNrIGNvbWVzIGluIDI1NiBmbGF2b3JzLg==\"},\n+    {\"They say that NetHack is just a computer game.\",\n+     \"VGhleSBzYXkgdGhhdCBOZXRIYWNrIGlzIGp1c3QgYSBjb21wdXRlciBnYW1lLg==\"},\n+    {\"They say that NetHack is more than just a computer game.\",\n+     \"VGhleSBzYXkgdGhhdCBOZXRIYWNrIGlzIG1vcmUgdGhhbiBqdXN0IGEgY29tcHV0ZXIgZ2FtZ\"\n+     \"S4=\"},\n+    {\"They say that NetHack is never what it used to be.\",\n+     \"VGhleSBzYXkgdGhhdCBOZXRIYWNrIGlzIG5ldmVyIHdoYXQgaXQgdXNlZCB0byBiZS4=\"},\n+    {\"They say that a baby dragon is too small to hurt or help you.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGJhYnkgZHJhZ29uIGlzIHRvbyBzbWFsbCB0byBodXJ0IG9yIGhlb\"\n+     \"HAgeW91Lg==\"},\n+    {\"They say that a black pudding is simply a brown pudding gone bad.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGJsYWNrIHB1ZGRpbmcgaXMgc2ltcGx5IGEgYnJvd24gcHVkZGluZ\"\n+     \"yBnb25lIGJhZC4=\"},\n+    {\"They say that a black sheep has 3 bags full of wool.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGJsYWNrIHNoZWVwIGhhcyAzIGJhZ3MgZnVsbCBvZiB3b29sLg=\"\n+     \"=\"},\n+    {\"They say that a blank scroll is like a blank check.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGJsYW5rIHNjcm9sbCBpcyBsaWtlIGEgYmxhbmsgY2hlY2su\"},\n+    {\"They say that a cat named Morris has nine lives.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGNhdCBuYW1lZCBNb3JyaXMgaGFzIG5pbmUgbGl2ZXMu\"},\n+    {\"They say that a desperate shopper might pay any price in a shop.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGRlc3BlcmF0ZSBzaG9wcGVyIG1pZ2h0IHBheSBhbnkgcHJpY2Uga\"\n+     \"W4gYSBzaG9wLg==\"},\n+    {\"They say that a diamond dog is everybody's best friend.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGRpYW1vbmQgZG9nIGlzIGV2ZXJ5Ym9keSdzIGJlc3QgZnJpZW5kL\"\n+     \"g==\"},\n+    {\"They say that a dwarf lord can carry a pick-axe because his armor is \"\n+     \"light.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGR3YXJmIGxvcmQgY2FuIGNhcnJ5IGEgcGljay1heGUgYmVjYXVzZ\"\n+     \"SBoaXMgYXJtb3IgaXMgbGlnaHQu\"},\n+    {\"They say that a floating eye can defeat Medusa.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGZsb2F0aW5nIGV5ZSBjYW4gZGVmZWF0IE1lZHVzYS4=\"},\n+    {\"They say that a fortune only has 1 line and you can't read between it.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGZvcnR1bmUgb25seSBoYXMgMSBsaW5lIGFuZCB5b3UgY2FuJ3Qgc\"\n+     \"mVhZCBiZXR3ZWVuIGl0Lg==\"},\n+    {\"They say that a fortune only has 1 line, but you can read between it.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGZvcnR1bmUgb25seSBoYXMgMSBsaW5lLCBidXQgeW91IGNhbiByZ\"\n+     \"WFkIGJldHdlZW4gaXQu\"},\n+    {\"They say that a fountain looks nothing like a regularly erupting geyser.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGZvdW50YWluIGxvb2tzIG5vdGhpbmcgbGlrZSBhIHJlZ3VsYXJse\"\n+     \"SBlcnVwdGluZyBnZXlzZXIu\"},\n+    {\"They say that a gold doubloon is worth more than its weight in gold.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGdvbGQgZG91Ymxvb24gaXMgd29ydGggbW9yZSB0aGFuIGl0cyB3Z\"\n+     \"WlnaHQgaW4gZ29sZC4=\"},\n+    {\"They say that a grid bug won't pay a shopkeeper for zapping you in a \"\n+     \"shop.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGdyaWQgYnVnIHdvbid0IHBheSBhIHNob3BrZWVwZXIgZm9yIHphc\"\n+     \"HBpbmcgeW91IGluIGEgc2hvcC4=\"},\n+    {\"They say that a gypsy could tell your fortune for a price.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGd5cHN5IGNvdWxkIHRlbGwgeW91ciBmb3J0dW5lIGZvciBhIHBya\"\n+     \"WNlLg==\"},\n+    {\"They say that a hacker named Alice once level teleported by using a \"\n+     \"mirror.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGhhY2tlciBuYW1lZCBBbGljZSBvbmNlIGxldmVsIHRlbGVwb3J0Z\"\n+     \"WQgYnkgdXNpbmcgYSBtaXJyb3Iu\"},\n+    {\"They say that a hacker named David once slew a giant with a sling and a \"\n+     \"rock.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGhhY2tlciBuYW1lZCBEYXZpZCBvbmNlIHNsZXcgYSBnaWFudCB3a\"\n+     \"XRoIGEgc2xpbmcgYW5kIGEgcm9jay4=\"},\n+    {\"They say that a hacker named Dorothy once rode a fog cloud to Oz.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGhhY2tlciBuYW1lZCBEb3JvdGh5IG9uY2Ugcm9kZSBhIGZvZyBjb\"\n+     \"G91ZCB0byBPei4=\"},\n+    {\"They say that a hacker named Mary once lost a white sheep in the mazes.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGhhY2tlciBuYW1lZCBNYXJ5IG9uY2UgbG9zdCBhIHdoaXRlIHNoZ\"\n+     \"WVwIGluIHRoZSBtYXplcy4=\"},\n+    {\"They say that a helm of brilliance is not to be taken lightly.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGhlbG0gb2YgYnJpbGxpYW5jZSBpcyBub3QgdG8gYmUgdGFrZW4gb\"\n+     \"GlnaHRseS4=\"},\n+    {\"They say that a hot dog and a hell hound are the same thing.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGhvdCBkb2cgYW5kIGEgaGVsbCBob3VuZCBhcmUgdGhlIHNhbWUgd\"\n+     \"Ghpbmcu\"},\n+    {\"They say that a lamp named Aladdin's Lamp contains a djinni with 3 \"\n+     \"wishes.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGxhbXAgbmFtZWQgQWxhZGRpbidzIExhbXAgY29udGFpbnMgYSBka\"\n+     \"mlubmkgd2l0aCAzIHdpc2hlcy4=\"},\n+    {\"They say that a large dog named Lassie will lead you to the amulet.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGxhcmdlIGRvZyBuYW1lZCBMYXNzaWUgd2lsbCBsZWFkIHlvdSB0b\"\n+     \"yB0aGUgYW11bGV0Lg==\"},\n+    {\"They say that a long sword is not a light sword.\",\n+     \"VGhleSBzYXkgdGhhdCBhIGxvbmcgc3dvcmQgaXMgbm90IGEgbGlnaHQgc3dvcmQu\"},\n+    {\"They say that a manes won't mince words with you.\",\n+     \"VGhleSBzYXkgdGhhdCBhIG1hbmVzIHdvbid0IG1pbmNlIHdvcmRzIHdpdGggeW91Lg==\"},\n+    {\"They say that a mind is a terrible thing to waste.\",\n+     \"VGhleSBzYXkgdGhhdCBhIG1pbmQgaXMgYSB0ZXJyaWJsZSB0aGluZyB0byB3YXN0ZS4=\"},\n+    {\"They say that a plain nymph will only wear a wire ring in one ear.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHBsYWluIG55bXBoIHdpbGwgb25seSB3ZWFyIGEgd2lyZSByaW5nI\"\n+     \"GluIG9uZSBlYXIu\"},\n+    {\"They say that a plumed hat could be a previously used crested helmet.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHBsdW1lZCBoYXQgY291bGQgYmUgYSBwcmV2aW91c2x5IHVzZWQgY\"\n+     \"3Jlc3RlZCBoZWxtZXQu\"},\n+    {\"They say that a potion of oil is difficult to grasp.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHBvdGlvbiBvZiBvaWwgaXMgZGlmZmljdWx0IHRvIGdyYXNwLg=\"\n+     \"=\"},\n+    {\"They say that a potion of yogurt is a cancelled potion of sickness.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHBvdGlvbiBvZiB5b2d1cnQgaXMgYSBjYW5jZWxsZWQgcG90aW9uI\"\n+     \"G9mIHNpY2tuZXNzLg==\"},\n+    {\"They say that a purple worm is not a baby purple dragon.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHB1cnBsZSB3b3JtIGlzIG5vdCBhIGJhYnkgcHVycGxlIGRyYWdvb\"\n+     \"i4=\"},\n+    {\"They say that a quivering blob tastes different than a gelatinous cube.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHF1aXZlcmluZyBibG9iIHRhc3RlcyBkaWZmZXJlbnQgdGhhbiBhI\"\n+     \"GdlbGF0aW5vdXMgY3ViZS4=\"},\n+    {\"They say that a runed broadsword named Stormbringer attracts vortices.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHJ1bmVkIGJyb2Fkc3dvcmQgbmFtZWQgU3Rvcm1icmluZ2VyIGF0d\"\n+     \"HJhY3RzIHZvcnRpY2VzLg==\"},\n+    {\"They say that a scroll of summoning has other names.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHNjcm9sbCBvZiBzdW1tb25pbmcgaGFzIG90aGVyIG5hbWVzLg=\"\n+     \"=\"},\n+    {\"They say that a shaman can bestow blessings but usually doesn't.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHNoYW1hbiBjYW4gYmVzdG93IGJsZXNzaW5ncyBidXQgdXN1YWxse\"\n+     \"SBkb2Vzbid0Lg==\"},\n+    {\"They say that a shaman will bless you for an eye of newt and wing of \"\n+     \"bat.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHNoYW1hbiB3aWxsIGJsZXNzIHlvdSBmb3IgYW4gZXllIG9mIG5ld\"\n+     \"3QgYW5kIHdpbmcgb2YgYmF0Lg==\"},\n+    {\"They say that a shimmering gold shield is not a polished silver shield.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHNoaW1tZXJpbmcgZ29sZCBzaGllbGQgaXMgbm90IGEgcG9saXNoZ\"\n+     \"WQgc2lsdmVyIHNoaWVsZC4=\"},\n+    {\"They say that a spear will hit a neo-otyugh. (Do YOU know what that is?)\",\n+     \"VGhleSBzYXkgdGhhdCBhIHNwZWFyIHdpbGwgaGl0IGEgbmVvLW90eXVnaC4gKERvIFlPVSBrb\"\n+     \"m93IHdoYXQgdGhhdCBpcz8p\"},\n+    {\"They say that a spotted dragon is the ultimate shape changer.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHNwb3R0ZWQgZHJhZ29uIGlzIHRoZSB1bHRpbWF0ZSBzaGFwZSBja\"\n+     \"GFuZ2VyLg==\"},\n+    {\"They say that a stethoscope is no good if you can only hear your \"\n+     \"heartbeat.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHN0ZXRob3Njb3BlIGlzIG5vIGdvb2QgaWYgeW91IGNhbiBvbmx5I\"\n+     \"GhlYXIgeW91ciBoZWFydGJlYXQu\"},\n+    {\"They say that a succubus named Suzy will sometimes warn you of danger.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHN1Y2N1YnVzIG5hbWVkIFN1enkgd2lsbCBzb21ldGltZXMgd2Fyb\"\n+     \"iB5b3Ugb2YgZGFuZ2VyLg==\"},\n+    {\"They say that a wand of cancellation is not like a wand of polymorph.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHdhbmQgb2YgY2FuY2VsbGF0aW9uIGlzIG5vdCBsaWtlIGEgd2FuZ\"\n+     \"CBvZiBwb2x5bW9ycGgu\"},\n+    {\"They say that a wood golem named Pinocchio would be easy to control.\",\n+     \"VGhleSBzYXkgdGhhdCBhIHdvb2QgZ29sZW0gbmFtZWQgUGlub2NjaGlvIHdvdWxkIGJlIGVhc\"\n+     \"3kgdG8gY29udHJvbC4=\"},\n+    {\"They say that after killing a dragon it's time for a change of scenery.\",\n+     \"VGhleSBzYXkgdGhhdCBhZnRlciBraWxsaW5nIGEgZHJhZ29uIGl0J3MgdGltZSBmb3IgYSBja\"\n+     \"GFuZ2Ugb2Ygc2NlbmVyeS4=\"},\n+    {\"They say that an amulet of strangulation is worse than ring around the \"\n+     \"collar.\",\n+     \"VGhleSBzYXkgdGhhdCBhbiBhbXVsZXQgb2Ygc3RyYW5ndWxhdGlvbiBpcyB3b3JzZSB0aGFuI\"\n+     \"HJpbmcgYXJvdW5kIHRoZSBjb2xsYXIu\"},\n+    {\"They say that an attic is the best place to hide your toys.\",\n+     \"VGhleSBzYXkgdGhhdCBhbiBhdHRpYyBpcyB0aGUgYmVzdCBwbGFjZSB0byBoaWRlIHlvdXIgd\"\n+     \"G95cy4=\"},\n+    {\"They say that an axe named Cleaver once belonged to a hacker named \"\n+     \"Beaver.\",\n+     \"VGhleSBzYXkgdGhhdCBhbiBheGUgbmFtZWQgQ2xlYXZlciBvbmNlIGJlbG9uZ2VkIHRvIGEga\"\n+     \"GFja2VyIG5hbWVkIEJlYXZlci4=\"},\n+    {\"They say that an eye of newt and a wing of bat are double the trouble.\",\n+     \"VGhleSBzYXkgdGhhdCBhbiBleWUgb2YgbmV3dCBhbmQgYSB3aW5nIG9mIGJhdCBhcmUgZG91Y\"\n+     \"mxlIHRoZSB0cm91YmxlLg==\"},\n+    {\"They say that an incubus named Izzy sometimes makes women feel \"\n+     \"sensitive.\",\n+     \"VGhleSBzYXkgdGhhdCBhbiBpbmN1YnVzIG5hbWVkIEl6enkgc29tZXRpbWVzIG1ha2VzIHdvb\"\n+     \"WVuIGZlZWwgc2Vuc2l0aXZlLg==\"},\n+    {\"They say that an opulent throne room is rarely a place to wish you'd be \"\n+     \"in.\",\n+     \"VGhleSBzYXkgdGhhdCBhbiBvcHVsZW50IHRocm9uZSByb29tIGlzIHJhcmVseSBhIHBsYWNlI\"\n+     \"HRvIHdpc2ggeW91J2QgYmUgaW4u\"},\n+    {\"They say that an unlucky hacker once had a nose bleed at an altar and \"\n+     \"died.\",\n+     \"VGhleSBzYXkgdGhhdCBhbiB1bmx1Y2t5IGhhY2tlciBvbmNlIGhhZCBhIG5vc2UgYmxlZWQgY\"\n+     \"XQgYW4gYWx0YXIgYW5kIGRpZWQu\"},\n+    {\"They say that and they say this but they never say never, never!\",\n+     \"VGhleSBzYXkgdGhhdCBhbmQgdGhleSBzYXkgdGhpcyBidXQgdGhleSBuZXZlciBzYXkgbmV2Z\"\n+     \"XIsIG5ldmVyIQ==\"},\n+    {\"They say that any quantum mechanic knows that speed kills.\",\n+     \"VGhleSBzYXkgdGhhdCBhbnkgcXVhbnR1bSBtZWNoYW5pYyBrbm93cyB0aGF0IHNwZWVkIGtpb\"\n+     \"GxzLg==\"},\n+    {\"They say that applying a unicorn horn means you've missed the point.\",\n+     \"VGhleSBzYXkgdGhhdCBhcHBseWluZyBhIHVuaWNvcm4gaG9ybiBtZWFucyB5b3UndmUgbWlzc\"\n+     \"2VkIHRoZSBwb2ludC4=\"},\n+    {\"They say that blue stones are radioactive, beware.\",\n+     \"VGhleSBzYXkgdGhhdCBibHVlIHN0b25lcyBhcmUgcmFkaW9hY3RpdmUsIGJld2FyZS4=\"},\n+    {\"They say that building a dungeon is a team effort.\",\n+     \"VGhleSBzYXkgdGhhdCBidWlsZGluZyBhIGR1bmdlb24gaXMgYSB0ZWFtIGVmZm9ydC4=\"},\n+    {\"They say that chaotic characters never get a kick out of altars.\",\n+     \"VGhleSBzYXkgdGhhdCBjaGFvdGljIGNoYXJhY3RlcnMgbmV2ZXIgZ2V0IGEga2ljayBvdXQgb\"\n+     \"2YgYWx0YXJzLg==\"},\n+    {\"They say that collapsing a dungeon often creates a panic.\",\n+     \"VGhleSBzYXkgdGhhdCBjb2xsYXBzaW5nIGEgZHVuZ2VvbiBvZnRlbiBjcmVhdGVzIGEgcGFua\"\n+     \"WMu\"},\n+    {\"They say that counting your eggs before they hatch shows that you care.\",\n+     \"VGhleSBzYXkgdGhhdCBjb3VudGluZyB5b3VyIGVnZ3MgYmVmb3JlIHRoZXkgaGF0Y2ggc2hvd\"\n+     \"3MgdGhhdCB5b3UgY2FyZS4=\"},\n+    {\"They say that dipping a bag of tricks in a fountain won't make it an \"\n+     \"icebox.\",\n+     \"VGhleSBzYXkgdGhhdCBkaXBwaW5nIGEgYmFnIG9mIHRyaWNrcyBpbiBhIGZvdW50YWluIHdvb\"\n+     \"id0IG1ha2UgaXQgYW4gaWNlYm94Lg==\"},\n+    {\"They say that dipping an eel and brown mold in hot water makes \"\n+     \"bouillabaisse.\",\n+     \"VGhleSBzYXkgdGhhdCBkaXBwaW5nIGFuIGVlbCBhbmQgYnJvd24gbW9sZCBpbiBob3Qgd2F0Z\"\n+     \"XIgbWFrZXMgYm91aWxsYWJhaXNzZS4=\"},\n+    {\"They say that donating a doubloon is extremely pious charity.\",\n+     \"VGhleSBzYXkgdGhhdCBkb25hdGluZyBhIGRvdWJsb29uIGlzIGV4dHJlbWVseSBwaW91cyBja\"\n+     \"GFyaXR5Lg==\"},\n+    {\"They say that eating royal jelly attracts grizzly owlbears.\",\n+     \"VGhleSBzYXkgdGhhdCBlYXRpbmcgcm95YWwgamVsbHkgYXR0cmFjdHMgZ3JpenpseSBvd2xiZ\"\n+     \"WFycy4=\"},\n+    {\"They say that eggs, pancakes and juice are just a mundane breakfast.\",\n+     \"VGhleSBzYXkgdGhhdCBlZ2dzLCBwYW5jYWtlcyBhbmQganVpY2UgYXJlIGp1c3QgYSBtdW5kY\"\n+     \"W5lIGJyZWFrZmFzdC4=\"},\n+    {\"They say that everyone knows why Medusa stands alone in the dark.\",\n+     \"VGhleSBzYXkgdGhhdCBldmVyeW9uZSBrbm93cyB3aHkgTWVkdXNhIHN0YW5kcyBhbG9uZSBpb\"\n+     \"iB0aGUgZGFyay4=\"},\n+    {\"They say that everyone wanted rec.games.hack to undergo a name change.\",\n+     \"VGhleSBzYXkgdGhhdCBldmVyeW9uZSB3YW50ZWQgcmVjLmdhbWVzLmhhY2sgdG8gdW5kZXJnb\"\n+     \"yBhIG5hbWUgY2hhbmdlLg==\"},\n+    {\"They say that finding a winning strategy is a deliberate move on your \"\n+     \"part.\",\n+     \"VGhleSBzYXkgdGhhdCBmaW5kaW5nIGEgd2lubmluZyBzdHJhdGVneSBpcyBhIGRlbGliZXJhd\"\n+     \"GUgbW92ZSBvbiB5b3VyIHBhcnQu\"},\n+    {\"They say that finding worthless glass is worth something.\",\n+     \"VGhleSBzYXkgdGhhdCBmaW5kaW5nIHdvcnRobGVzcyBnbGFzcyBpcyB3b3J0aCBzb21ldGhpb\"\n+     \"mcu\"},\n+    {\"They say that fortune cookies are food for thought.\",\n+     \"VGhleSBzYXkgdGhhdCBmb3J0dW5lIGNvb2tpZXMgYXJlIGZvb2QgZm9yIHRob3VnaHQu\"},\n+    {\"They say that gold is only wasted on a pet dragon.\",\n+     \"VGhleSBzYXkgdGhhdCBnb2xkIGlzIG9ubHkgd2FzdGVkIG9uIGEgcGV0IGRyYWdvbi4=\"},\n+    {\"They say that good things come to those that wait.\",\n+     \"VGhleSBzYXkgdGhhdCBnb29kIHRoaW5ncyBjb21lIHRvIHRob3NlIHRoYXQgd2FpdC4=\"},\n+    {\"They say that greased objects will slip out of monsters' hands.\",\n+     \"VGhleSBzYXkgdGhhdCBncmVhc2VkIG9iamVjdHMgd2lsbCBzbGlwIG91dCBvZiBtb25zdGVyc\"\n+     \"ycgaGFuZHMu\"},\n+    {\"They say that if you can't spell then you'll wish you had a spell book.\",\n+     \"VGhleSBzYXkgdGhhdCBpZiB5b3UgY2FuJ3Qgc3BlbGwgdGhlbiB5b3UnbGwgd2lzaCB5b3Uga\"\n+     \"GFkIGEgc3BlbGwgYm9vay4=\"},\n+    {\"They say that if you live by the sword, you'll die by the sword.\",\n+     \"VGhleSBzYXkgdGhhdCBpZiB5b3UgbGl2ZSBieSB0aGUgc3dvcmQsIHlvdSdsbCBkaWUgYnkgd\"\n+     \"GhlIHN3b3JkLg==\"},\n+    {\"They say that if you play like a monster you'll have a better game.\",\n+     \"VGhleSBzYXkgdGhhdCBpZiB5b3UgcGxheSBsaWtlIGEgbW9uc3RlciB5b3UnbGwgaGF2ZSBhI\"\n+     \"GJldHRlciBnYW1lLg==\"},\n+    {\"They say that if you sleep with a demon you might awake with a headache.\",\n+     \"VGhleSBzYXkgdGhhdCBpZiB5b3Ugc2xlZXAgd2l0aCBhIGRlbW9uIHlvdSBtaWdodCBhd2FrZ\"\n+     \"SB3aXRoIGEgaGVhZGFjaGUu\"},\n+    {\"They say that if you step on a crack you could break your mother's back.\",\n+     \"VGhleSBzYXkgdGhhdCBpZiB5b3Ugc3RlcCBvbiBhIGNyYWNrIHlvdSBjb3VsZCBicmVhayB5b\"\n+     \"3VyIG1vdGhlcidzIGJhY2su\"},\n+    {\"They say that if you're invisible you can still be heard!\",\n+     \"VGhleSBzYXkgdGhhdCBpZiB5b3UncmUgaW52aXNpYmxlIHlvdSBjYW4gc3RpbGwgYmUgaGVhc\"\n+     \"mQh\"},\n+    {\"They say that if you're lucky you can feel the runes on a scroll.\",\n+     \"VGhleSBzYXkgdGhhdCBpZiB5b3UncmUgbHVja3kgeW91IGNhbiBmZWVsIHRoZSBydW5lcyBvb\"\n+     \"iBhIHNjcm9sbC4=\"},\n+    {\"They say that in the big picture gold is only small change.\",\n+     \"VGhleSBzYXkgdGhhdCBpbiB0aGUgYmlnIHBpY3R1cmUgZ29sZCBpcyBvbmx5IHNtYWxsIGNoY\"\n+     \"W5nZS4=\"},\n+    {\"They say that in the dungeon it's not what you know that really matters.\",\n+     \"VGhleSBzYXkgdGhhdCBpbiB0aGUgZHVuZ2VvbiBpdCdzIG5vdCB3aGF0IHlvdSBrbm93IHRoY\"\n+     \"XQgcmVhbGx5IG1hdHRlcnMu\"},\n+    {\"They say that in the dungeon moon rocks are really dilithium crystals.\",\n+     \"VGhleSBzYXkgdGhhdCBpbiB0aGUgZHVuZ2VvbiBtb29uIHJvY2tzIGFyZSByZWFsbHkgZGlsa\"\n+     \"XRoaXVtIGNyeXN0YWxzLg==\"},\n+    {\"They say that in the dungeon the boorish customer is never right.\",\n+     \"VGhleSBzYXkgdGhhdCBpbiB0aGUgZHVuZ2VvbiB0aGUgYm9vcmlzaCBjdXN0b21lciBpcyBuZ\"\n+     \"XZlciByaWdodC4=\"},\n+    {\"They say that in the dungeon you don't need a watch to tell time.\",\n+     \"VGhleSBzYXkgdGhhdCBpbiB0aGUgZHVuZ2VvbiB5b3UgZG9uJ3QgbmVlZCBhIHdhdGNoIHRvI\"\n+     \"HRlbGwgdGltZS4=\"},\n+    {\"They say that in the dungeon you need something old, new, burrowed and \"\n+     \"blue.\",\n+     \"VGhleSBzYXkgdGhhdCBpbiB0aGUgZHVuZ2VvbiB5b3UgbmVlZCBzb21ldGhpbmcgb2xkLCBuZ\"\n+     \"XcsIGJ1cnJvd2VkIGFuZCBibHVlLg==\"},\n+    {\"They say that in the dungeon you should always count your blessings.\",\n+     \"VGhleSBzYXkgdGhhdCBpbiB0aGUgZHVuZ2VvbiB5b3Ugc2hvdWxkIGFsd2F5cyBjb3VudCB5b\"\n+     \"3VyIGJsZXNzaW5ncy4=\"},\n+    {\"They say that iron golem plate mail isn't worth wishing for.\",\n+     \"VGhleSBzYXkgdGhhdCBpcm9uIGdvbGVtIHBsYXRlIG1haWwgaXNuJ3Qgd29ydGggd2lzaGluZ\"\n+     \"yBmb3Iu\"},\n+    {\"They say that it takes four quarterstaffs to make one staff.\",\n+     \"VGhleSBzYXkgdGhhdCBpdCB0YWtlcyBmb3VyIHF1YXJ0ZXJzdGFmZnMgdG8gbWFrZSBvbmUgc\"\n+     \"3RhZmYu\"},\n+    {\"They say that it's not over till the fat ladies sing.\",\n+     \"VGhleSBzYXkgdGhhdCBpdCdzIG5vdCBvdmVyIHRpbGwgdGhlIGZhdCBsYWRpZXMgc2luZy4\"\n+     \"=\"},\n+    {\"They say that it's not over till the fat lady shouts `Off with its \"\n+     \"head'.\",\n+     \"VGhleSBzYXkgdGhhdCBpdCdzIG5vdCBvdmVyIHRpbGwgdGhlIGZhdCBsYWR5IHNob3V0cyBgT\"\n+     \"2ZmIHdpdGggaXRzIGhlYWQnLg==\"},\n+    {\"They say that kicking a heavy statue is really a dumb move.\",\n+     \"VGhleSBzYXkgdGhhdCBraWNraW5nIGEgaGVhdnkgc3RhdHVlIGlzIHJlYWxseSBhIGR1bWIgb\"\n+     \"W92ZS4=\"},\n+    {\"They say that kicking a valuable gem doesn't seem to make sense.\",\n+     \"VGhleSBzYXkgdGhhdCBraWNraW5nIGEgdmFsdWFibGUgZ2VtIGRvZXNuJ3Qgc2VlbSB0byBtY\"\n+     \"WtlIHNlbnNlLg==\"},\n+    {\"They say that leprechauns know Latin and you should too.\",\n+     \"VGhleSBzYXkgdGhhdCBsZXByZWNoYXVucyBrbm93IExhdGluIGFuZCB5b3Ugc2hvdWxkIHRvb\"\n+     \"y4=\"},\n+    {\"They say that minotaurs get lost outside of the mazes.\",\n+     \"VGhleSBzYXkgdGhhdCBtaW5vdGF1cnMgZ2V0IGxvc3Qgb3V0c2lkZSBvZiB0aGUgbWF6ZXM\"\n+     \"u\"},\n+    {\"They say that most trolls are born again.\",\n+     \"VGhleSBzYXkgdGhhdCBtb3N0IHRyb2xscyBhcmUgYm9ybiBhZ2Fpbi4=\"},\n+    {\"They say that naming your cat Garfield will make you more attractive.\",\n+     \"VGhleSBzYXkgdGhhdCBuYW1pbmcgeW91ciBjYXQgR2FyZmllbGQgd2lsbCBtYWtlIHlvdSBtb\"\n+     \"3JlIGF0dHJhY3RpdmUu\"},\n+    {\"They say that no one knows everything about everything in the dungeon.\",\n+     \"VGhleSBzYXkgdGhhdCBubyBvbmUga25vd3MgZXZlcnl0aGluZyBhYm91dCBldmVyeXRoaW5nI\"\n+     \"GluIHRoZSBkdW5nZW9uLg==\"},\n+    {\"They say that no one plays NetHack just for the fun of it.\",\n+     \"VGhleSBzYXkgdGhhdCBubyBvbmUgcGxheXMgTmV0SGFjayBqdXN0IGZvciB0aGUgZnVuIG9mI\"\n+     \"Gl0Lg==\"},\n+    {\"They say that no one really subscribes to rec.games.roguelike.nethack.\",\n+     \"VGhleSBzYXkgdGhhdCBubyBvbmUgcmVhbGx5IHN1YnNjcmliZXMgdG8gcmVjLmdhbWVzLnJvZ\"\n+     \"3VlbGlrZS5uZXRoYWNrLg==\"},\n+    {\"They say that no one will admit to starting a rumor.\",\n+     \"VGhleSBzYXkgdGhhdCBubyBvbmUgd2lsbCBhZG1pdCB0byBzdGFydGluZyBhIHJ1bW9yLg=\"\n+     \"=\"},\n+    {\"They say that nurses sometimes carry scalpels and never use them.\",\n+     \"VGhleSBzYXkgdGhhdCBudXJzZXMgc29tZXRpbWVzIGNhcnJ5IHNjYWxwZWxzIGFuZCBuZXZlc\"\n+     \"iB1c2UgdGhlbS4=\"},\n+    {\"They say that once you've met one wizard you've met them all.\",\n+     \"VGhleSBzYXkgdGhhdCBvbmNlIHlvdSd2ZSBtZXQgb25lIHdpemFyZCB5b3UndmUgbWV0IHRoZ\"\n+     \"W0gYWxsLg==\"},\n+    {\"They say that one troll is worth 10,000 newts.\",\n+     \"VGhleSBzYXkgdGhhdCBvbmUgdHJvbGwgaXMgd29ydGggMTAsMDAwIG5ld3RzLg==\"},\n+    {\"They say that only David can find the zoo!\",\n+     \"VGhleSBzYXkgdGhhdCBvbmx5IERhdmlkIGNhbiBmaW5kIHRoZSB6b28h\"},\n+    {\"They say that only angels play their harps for their pets.\",\n+     \"VGhleSBzYXkgdGhhdCBvbmx5IGFuZ2VscyBwbGF5IHRoZWlyIGhhcnBzIGZvciB0aGVpciBwZ\"\n+     \"XRzLg==\"},\n+    {\"They say that only big spenders carry gold.\",\n+     \"VGhleSBzYXkgdGhhdCBvbmx5IGJpZyBzcGVuZGVycyBjYXJyeSBnb2xkLg==\"},\n+    {\"They say that orc shamans are healthy, wealthy and wise.\",\n+     \"VGhleSBzYXkgdGhhdCBvcmMgc2hhbWFucyBhcmUgaGVhbHRoeSwgd2VhbHRoeSBhbmQgd2lzZ\"\n+     \"S4=\"},\n+    {\"They say that playing NetHack is like walking into a death trap.\",\n+     \"VGhleSBzYXkgdGhhdCBwbGF5aW5nIE5ldEhhY2sgaXMgbGlrZSB3YWxraW5nIGludG8gYSBkZ\"\n+     \"WF0aCB0cmFwLg==\"},\n+    {\"They say that problem breathing is best treated by a proper diet.\",\n+     \"VGhleSBzYXkgdGhhdCBwcm9ibGVtIGJyZWF0aGluZyBpcyBiZXN0IHRyZWF0ZWQgYnkgYSBwc\"\n+     \"m9wZXIgZGlldC4=\"},\n+    {\"They say that quaffing many potions of levitation can give you a \"\n+     \"headache.\",\n+     \"VGhleSBzYXkgdGhhdCBxdWFmZmluZyBtYW55IHBvdGlvbnMgb2YgbGV2aXRhdGlvbiBjYW4gZ\"\n+     \"2l2ZSB5b3UgYSBoZWFkYWNoZS4=\"},\n+    {\"They say that queen bees get that way by eating royal jelly.\",\n+     \"VGhleSBzYXkgdGhhdCBxdWVlbiBiZWVzIGdldCB0aGF0IHdheSBieSBlYXRpbmcgcm95YWwga\"\n+     \"mVsbHku\"},\n+    {\"They say that reading a scare monster scroll is the same as saying \"\n+     \"Elbereth.\",\n+     \"VGhleSBzYXkgdGhhdCByZWFkaW5nIGEgc2NhcmUgbW9uc3RlciBzY3JvbGwgaXMgdGhlIHNhb\"\n+     \"WUgYXMgc2F5aW5nIEVsYmVyZXRoLg==\"},\n+    {\"They say that real hackers always are controlled.\",\n+     \"VGhleSBzYXkgdGhhdCByZWFsIGhhY2tlcnMgYWx3YXlzIGFyZSBjb250cm9sbGVkLg==\"},\n+    {\"They say that real hackers never sleep.\",\n+     \"VGhleSBzYXkgdGhhdCByZWFsIGhhY2tlcnMgbmV2ZXIgc2xlZXAu\"},\n+    {\"They say that shopkeepers are insured by Croesus himself!\",\n+     \"VGhleSBzYXkgdGhhdCBzaG9wa2VlcGVycyBhcmUgaW5zdXJlZCBieSBDcm9lc3VzIGhpbXNlb\"\n+     \"GYh\"},\n+    {\"They say that shopkeepers never carry more than 20 gold pieces, at \"\n+     \"night.\",\n+     \"VGhleSBzYXkgdGhhdCBzaG9wa2VlcGVycyBuZXZlciBjYXJyeSBtb3JlIHRoYW4gMjAgZ29sZ\"\n+     \"CBwaWVjZXMsIGF0IG5pZ2h0Lg==\"},\n+    {\"They say that shopkeepers never sell blessed potions of invisibility.\",\n+     \"VGhleSBzYXkgdGhhdCBzaG9wa2VlcGVycyBuZXZlciBzZWxsIGJsZXNzZWQgcG90aW9ucyBvZ\"\n+     \"iBpbnZpc2liaWxpdHku\"},\n+    {\"They say that soldiers wear kid gloves and silly helmets.\",\n+     \"VGhleSBzYXkgdGhhdCBzb2xkaWVycyB3ZWFyIGtpZCBnbG92ZXMgYW5kIHNpbGx5IGhlbG1ld\"\n+     \"HMu\"},\n+    {\"They say that some Kops are on the take.\",\n+     \"VGhleSBzYXkgdGhhdCBzb21lIEtvcHMgYXJlIG9uIHRoZSB0YWtlLg==\"},\n+    {\"They say that some guards' palms can be greased.\",\n+     \"VGhleSBzYXkgdGhhdCBzb21lIGd1YXJkcycgcGFsbXMgY2FuIGJlIGdyZWFzZWQu\"},\n+    {\"They say that some monsters may kiss your boots to stop your drum \"\n+     \"playing.\",\n+     \"VGhleSBzYXkgdGhhdCBzb21lIG1vbnN0ZXJzIG1heSBraXNzIHlvdXIgYm9vdHMgdG8gc3Rvc\"\n+     \"CB5b3VyIGRydW0gcGxheWluZy4=\"},\n+    {\"They say that sometimes you can be the hit of the party when playing a \"\n+     \"horn.\",\n+     \"VGhleSBzYXkgdGhhdCBzb21ldGltZXMgeW91IGNhbiBiZSB0aGUgaGl0IG9mIHRoZSBwYXJ0e\"\n+     \"SB3aGVuIHBsYXlpbmcgYSBob3JuLg==\"},\n+    {\"They say that the NetHack gods generally welcome your sacrifices.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGUgTmV0SGFjayBnb2RzIGdlbmVyYWxseSB3ZWxjb21lIHlvdXIgc\"\n+     \"2FjcmlmaWNlcy4=\"},\n+    {\"They say that the Three Rings are named Vilya, Nenya and Narya.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGUgVGhyZWUgUmluZ3MgYXJlIG5hbWVkIFZpbHlhLCBOZW55YSBhb\"\n+     \"mQgTmFyeWEu\"},\n+    {\"They say that the Wizard of Yendor has a death wish.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGUgV2l6YXJkIG9mIFllbmRvciBoYXMgYSBkZWF0aCB3aXNoLg=\"\n+     \"=\"},\n+    {\"They say that the `hair of the dog' is sometimes an effective remedy.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGUgYGhhaXIgb2YgdGhlIGRvZycgaXMgc29tZXRpbWVzIGFuIGVmZ\"\n+     \"mVjdGl2ZSByZW1lZHku\"},\n+    {\"They say that the best time to save your game is now before its too \"\n+     \"late.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGUgYmVzdCB0aW1lIHRvIHNhdmUgeW91ciBnYW1lIGlzIG5vdyBiZ\"\n+     \"WZvcmUgaXRzIHRvbyBsYXRlLg==\"},\n+    {\"They say that the biggest obstacle in NetHack is your mind.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGUgYmlnZ2VzdCBvYnN0YWNsZSBpbiBOZXRIYWNrIGlzIHlvdXIgb\"\n+     \"WluZC4=\"},\n+    {\"They say that the gods are angry when they hit you with objects.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGUgZ29kcyBhcmUgYW5ncnkgd2hlbiB0aGV5IGhpdCB5b3Ugd2l0a\"\n+     \"CBvYmplY3RzLg==\"},\n+    {\"They say that the priesthood are specially favored by the gods.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGUgcHJpZXN0aG9vZCBhcmUgc3BlY2lhbGx5IGZhdm9yZWQgYnkgd\"\n+     \"GhlIGdvZHMu\"},\n+    {\"They say that the way to make a unicorn happy is to give it what it \"\n+     \"wants.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGUgd2F5IHRvIG1ha2UgYSB1bmljb3JuIGhhcHB5IGlzIHRvIGdpd\"\n+     \"mUgaXQgd2hhdCBpdCB3YW50cy4=\"},\n+    {\"They say that there are no black or white stones, only gray.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGVyZSBhcmUgbm8gYmxhY2sgb3Igd2hpdGUgc3RvbmVzLCBvbmx5I\"\n+     \"GdyYXku\"},\n+    {\"They say that there are no skeletons hence there are no skeleton keys.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGVyZSBhcmUgbm8gc2tlbGV0b25zIGhlbmNlIHRoZXJlIGFyZSBub\"\n+     \"yBza2VsZXRvbiBrZXlzLg==\"},\n+    {\"They say that there is a clever rogue in every hacker just dying to \"\n+     \"escape.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGVyZSBpcyBhIGNsZXZlciByb2d1ZSBpbiBldmVyeSBoYWNrZXIga\"\n+     \"nVzdCBkeWluZyB0byBlc2NhcGUu\"},\n+    {\"They say that there is no such thing as free advice.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGVyZSBpcyBubyBzdWNoIHRoaW5nIGFzIGZyZWUgYWR2aWNlLg=\"\n+     \"=\"},\n+    {\"They say that there is only one way to win at NetHack.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGVyZSBpcyBvbmx5IG9uZSB3YXkgdG8gd2luIGF0IE5ldEhhY2s\"\n+     \"u\"},\n+    {\"They say that there once was a fearsome chaotic samurai named Luk No.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGVyZSBvbmNlIHdhcyBhIGZlYXJzb21lIGNoYW90aWMgc2FtdXJha\"\n+     \"SBuYW1lZCBMdWsgTm8u\"},\n+    {\"They say that there was a time when cursed holy water wasn't water.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGVyZSB3YXMgYSB0aW1lIHdoZW4gY3Vyc2VkIGhvbHkgd2F0ZXIgd\"\n+     \"2Fzbid0IHdhdGVyLg==\"},\n+    {\"They say that there's no point in crying over a gray ooze.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGVyZSdzIG5vIHBvaW50IGluIGNyeWluZyBvdmVyIGEgZ3JheSBvb\"\n+     \"3plLg==\"},\n+    {\"They say that there's only hope left after you've opened Pandora's box.\",\n+     \"VGhleSBzYXkgdGhhdCB0aGVyZSdzIG9ubHkgaG9wZSBsZWZ0IGFmdGVyIHlvdSd2ZSBvcGVuZ\"\n+     \"WQgUGFuZG9yYSdzIGJveC4=\"},\n+    {\"They say that trapdoors should always be marked `Caution: Trap Door'.\",\n+     \"VGhleSBzYXkgdGhhdCB0cmFwZG9vcnMgc2hvdWxkIGFsd2F5cyBiZSBtYXJrZWQgYENhdXRpb\"\n+     \"246IFRyYXAgRG9vcicu\"},\n+    {\"They say that using an amulet of change isn't a difficult operation.\",\n+     \"VGhleSBzYXkgdGhhdCB1c2luZyBhbiBhbXVsZXQgb2YgY2hhbmdlIGlzbid0IGEgZGlmZmljd\"\n+     \"Wx0IG9wZXJhdGlvbi4=\"},\n+    {\"They say that water walking boots are better if you are fast like \"\n+     \"Hermes.\",\n+     \"VGhleSBzYXkgdGhhdCB3YXRlciB3YWxraW5nIGJvb3RzIGFyZSBiZXR0ZXIgaWYgeW91IGFyZ\"\n+     \"SBmYXN0IGxpa2UgSGVybWVzLg==\"},\n+    {\"They say that when you wear a circular amulet you might resemble a \"\n+     \"troll.\",\n+     \"VGhleSBzYXkgdGhhdCB3aGVuIHlvdSB3ZWFyIGEgY2lyY3VsYXIgYW11bGV0IHlvdSBtaWdod\"\n+     \"CByZXNlbWJsZSBhIHRyb2xsLg==\"},\n+    {\"They say that when you're hungry you can get a pizza in 30 moves or it's \"\n+     \"free.\",\n+     \"VGhleSBzYXkgdGhhdCB3aGVuIHlvdSdyZSBodW5ncnkgeW91IGNhbiBnZXQgYSBwaXp6YSBpb\"\n+     \"iAzMCBtb3ZlcyBvciBpdCdzIGZyZWUu\"},\n+    {\"They say that when your god is angry you should try another one.\",\n+     \"VGhleSBzYXkgdGhhdCB3aGVuIHlvdXIgZ29kIGlzIGFuZ3J5IHlvdSBzaG91bGQgdHJ5IGFub\"\n+     \"3RoZXIgb25lLg==\"},\n+    {\"They say that wielding a unicorn horn takes strength.\",\n+     \"VGhleSBzYXkgdGhhdCB3aWVsZGluZyBhIHVuaWNvcm4gaG9ybiB0YWtlcyBzdHJlbmd0aC4\"\n+     \"=\"},\n+    {\"They say that with speed boots you never worry about hit and run \"\n+     \"accidents.\",\n+     \"VGhleSBzYXkgdGhhdCB3aXRoIHNwZWVkIGJvb3RzIHlvdSBuZXZlciB3b3JyeSBhYm91dCBoa\"\n+     \"XQgYW5kIHJ1biBhY2NpZGVudHMu\"},\n+    {\"They say that you can defeat a killer bee with a unicorn horn.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIGRlZmVhdCBhIGtpbGxlciBiZWUgd2l0aCBhIHVuaWNvc\"\n+     \"m4gaG9ybi4=\"},\n+    {\"They say that you can only cross the River Styx in Charon's boat.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIG9ubHkgY3Jvc3MgdGhlIFJpdmVyIFN0eXggaW4gQ2hhc\"\n+     \"m9uJ3MgYm9hdC4=\"},\n+    {\"They say that you can only kill a lich once and then you'd better be \"\n+     \"careful.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIG9ubHkga2lsbCBhIGxpY2ggb25jZSBhbmQgdGhlbiB5b\"\n+     \"3UnZCBiZXR0ZXIgYmUgY2FyZWZ1bC4=\"},\n+    {\"They say that you can only wish for things you've already had.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIG9ubHkgd2lzaCBmb3IgdGhpbmdzIHlvdSd2ZSBhbHJlY\"\n+     \"WR5IGhhZC4=\"},\n+    {\"They say that you can train a cat by talking gently to it.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIHRyYWluIGEgY2F0IGJ5IHRhbGtpbmcgZ2VudGx5IHRvI\"\n+     \"Gl0Lg==\"},\n+    {\"They say that you can train a dog by talking firmly to it.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIHRyYWluIGEgZG9nIGJ5IHRhbGtpbmcgZmlybWx5IHRvI\"\n+     \"Gl0Lg==\"},\n+    {\"They say that you can trust your gold with the king.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3UgY2FuIHRydXN0IHlvdXIgZ29sZCB3aXRoIHRoZSBraW5nLg=\"\n+     \"=\"},\n+    {\"They say that you can't wipe your greasy bare hands on a blank scroll.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3UgY2FuJ3Qgd2lwZSB5b3VyIGdyZWFzeSBiYXJlIGhhbmRzIG9uI\"\n+     \"GEgYmxhbmsgc2Nyb2xsLg==\"},\n+    {\"They say that you cannot trust scrolls of rumor.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3UgY2Fubm90IHRydXN0IHNjcm9sbHMgb2YgcnVtb3Iu\"},\n+    {\"They say that you could fall head over heels for an energy vortex.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3UgY291bGQgZmFsbCBoZWFkIG92ZXIgaGVlbHMgZm9yIGFuIGVuZ\"\n+     \"XJneSB2b3J0ZXgu\"},\n+    {\"They say that you need a key in order to open locked doors.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3UgbmVlZCBhIGtleSBpbiBvcmRlciB0byBvcGVuIGxvY2tlZCBkb\"\n+     \"29ycy4=\"},\n+    {\"They say that you need a mirror to notice a mimic in an antique shop.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3UgbmVlZCBhIG1pcnJvciB0byBub3RpY2UgYSBtaW1pYyBpbiBhb\"\n+     \"iBhbnRpcXVlIHNob3Au\"},\n+    {\"They say that you really can use a pick-axe unless you really can't.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3UgcmVhbGx5IGNhbiB1c2UgYSBwaWNrLWF4ZSB1bmxlc3MgeW91I\"\n+     \"HJlYWxseSBjYW4ndC4=\"},\n+    {\"They say that you should always store your tools in the cellar.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIGFsd2F5cyBzdG9yZSB5b3VyIHRvb2xzIGluIHRoZ\"\n+     \"SBjZWxsYXIu\"},\n+    {\"They say that you should be careful while climbing the ladder to \"\n+     \"success.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIGJlIGNhcmVmdWwgd2hpbGUgY2xpbWJpbmcgdGhlI\"\n+     \"GxhZGRlciB0byBzdWNjZXNzLg==\"},\n+    {\"They say that you should call your armor `rustproof'.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIGNhbGwgeW91ciBhcm1vciBgcnVzdHByb29mJy4\"\n+     \"=\"},\n+    {\"They say that you should name your dog Spuds to have a cool pet.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIG5hbWUgeW91ciBkb2cgU3B1ZHMgdG8gaGF2ZSBhI\"\n+     \"GNvb2wgcGV0Lg==\"},\n+    {\"They say that you should name your weapon after your first monster kill.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIG5hbWUgeW91ciB3ZWFwb24gYWZ0ZXIgeW91ciBma\"\n+     \"XJzdCBtb25zdGVyIGtpbGwu\"},\n+    {\"They say that you should never introduce a rope golem to a succubus.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIG5ldmVyIGludHJvZHVjZSBhIHJvcGUgZ29sZW0gd\"\n+     \"G8gYSBzdWNjdWJ1cy4=\"},\n+    {\"They say that you should never sleep near invisible ring wraiths.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIG5ldmVyIHNsZWVwIG5lYXIgaW52aXNpYmxlIHJpb\"\n+     \"mcgd3JhaXRocy4=\"},\n+    {\"They say that you should never try to leave the dungeon with a bag of \"\n+     \"gems.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIG5ldmVyIHRyeSB0byBsZWF2ZSB0aGUgZHVuZ2Vvb\"\n+     \"iB3aXRoIGEgYmFnIG9mIGdlbXMu\"},\n+    {\"They say that you should remove your armor before sitting on a throne.\",\n+     \"VGhleSBzYXkgdGhhdCB5b3Ugc2hvdWxkIHJlbW92ZSB5b3VyIGFybW9yIGJlZm9yZSBzaXR0a\"\n+     \"W5nIG9uIGEgdGhyb25lLg==\"},\n+    {\"This fortune cookie is copy protected.\",\n+     \"VGhpcyBmb3J0dW5lIGNvb2tpZSBpcyBjb3B5IHByb3RlY3RlZC4=\"},\n+    {\"This fortune cookie is the property of Fortune Cookies, Inc.\",\n+     \"VGhpcyBmb3J0dW5lIGNvb2tpZSBpcyB0aGUgcHJvcGVydHkgb2YgRm9ydHVuZSBDb29raWVzL\"\n+     \"CBJbmMu\"},\n+    {\"Tired? Try a scroll of charging on yourself.\",\n+     \"VGlyZWQ/IFRyeSBhIHNjcm9sbCBvZiBjaGFyZ2luZyBvbiB5b3Vyc2VsZi4=\"},\n+    {\"To achieve the next higher rating, you need 3 more points.\",\n+     \"VG8gYWNoaWV2ZSB0aGUgbmV4dCBoaWdoZXIgcmF0aW5nLCB5b3UgbmVlZCAzIG1vcmUgcG9pb\"\n+     \"nRzLg==\"},\n+    {\"To reach heaven, escape the dungeon while wearing a ring of levitation.\",\n+     \"VG8gcmVhY2ggaGVhdmVuLCBlc2NhcGUgdGhlIGR1bmdlb24gd2hpbGUgd2VhcmluZyBhIHJpb\"\n+     \"mcgb2YgbGV2aXRhdGlvbi4=\"},\n+    {\"Tourists wear shirts loud enough to wake the dead.\",\n+     \"VG91cmlzdHMgd2VhciBzaGlydHMgbG91ZCBlbm91Z2ggdG8gd2FrZSB0aGUgZGVhZC4=\"},\n+    {\"Try calling your katana Moulinette.\",\n+     \"VHJ5IGNhbGxpbmcgeW91ciBrYXRhbmEgTW91bGluZXR0ZS4=\"},\n+    {\"Ulch! That meat was painted!\",\n+     \"VWxjaCEgVGhhdCBtZWF0IHdhcyBwYWludGVkIQ==\"},\n+    {\"Unfortunately, this message was left intentionally blank.\",\n+     \"VW5mb3J0dW5hdGVseSwgdGhpcyBtZXNzYWdlIHdhcyBsZWZ0IGludGVudGlvbmFsbHkgYmxhb\"\n+     \"msu\"},\n+    {\"Using a morning star in the evening has no effect.\",\n+     \"VXNpbmcgYSBtb3JuaW5nIHN0YXIgaW4gdGhlIGV2ZW5pbmcgaGFzIG5vIGVmZmVjdC4=\"},\n+    {\"Want a hint? Zap a wand of make invisible on your weapon!\",\n+     \"V2FudCBhIGhpbnQ/\"\n+     \"IFphcCBhIHdhbmQgb2YgbWFrZSBpbnZpc2libGUgb24geW91ciB3ZWFwb24h\"},\n+    {\"Want to ascend in a hurry? Apply at Gizmonic Institute.\",\n+     \"V2FudCB0byBhc2NlbmQgaW4gYSBodXJyeT8gQXBwbHkgYXQgR2l6bW9uaWMgSW5zdGl0dXRlL\"\n+     \"g==\"},\n+    {\"Wanted: shopkeepers. Send a scroll of mail to Mage of Yendor/Level \"\n+     \"35/Dungeon.\",\n+     \"V2FudGVkOiBzaG9wa2VlcGVycy4gU2VuZCBhIHNjcm9sbCBvZiBtYWlsIHRvIE1hZ2Ugb2YgW\"\n+     \"WVuZG9yL0xldmVsIDM1L0R1bmdlb24u\"},\n+    {\"Warning: fortune reading can be hazardous to your health.\",\n+     \"V2FybmluZzogZm9ydHVuZSByZWFkaW5nIGNhbiBiZSBoYXphcmRvdXMgdG8geW91ciBoZWFsd\"\n+     \"Ggu\"},\n+    {\"We have new ways of detecting treachery...\",\n+     \"V2UgaGF2ZSBuZXcgd2F5cyBvZiBkZXRlY3RpbmcgdHJlYWNoZXJ5Li4u\"},\n+    {\"Wet towels make great weapons!\",\n+     \"V2V0IHRvd2VscyBtYWtlIGdyZWF0IHdlYXBvbnMh\"},\n+    {\"What a pity, you cannot read it!\",\n+     \"V2hhdCBhIHBpdHksIHlvdSBjYW5ub3QgcmVhZCBpdCE=\"},\n+    {\"When a piercer drops in on you, you will be tempted to hit the ceiling!\",\n+     \"V2hlbiBhIHBpZXJjZXIgZHJvcHMgaW4gb24geW91LCB5b3Ugd2lsbCBiZSB0ZW1wdGVkIHRvI\"\n+     \"GhpdCB0aGUgY2VpbGluZyE=\"},\n+    {\"When in a maze follow the right wall and you will never get lost.\",\n+     \"V2hlbiBpbiBhIG1hemUgZm9sbG93IHRoZSByaWdodCB3YWxsIGFuZCB5b3Ugd2lsbCBuZXZlc\"\n+     \"iBnZXQgbG9zdC4=\"},\n+    {\"When you have a key, you don't have to wait for the guard.\",\n+     \"V2hlbiB5b3UgaGF2ZSBhIGtleSwgeW91IGRvbid0IGhhdmUgdG8gd2FpdCBmb3IgdGhlIGd1Y\"\n+     \"XJkLg==\"},\n+    {\"Why are you wasting time reading fortunes?\",\n+     \"V2h5IGFyZSB5b3Ugd2FzdGluZyB0aW1lIHJlYWRpbmcgZm9ydHVuZXM/\"},\n+    {\"Wish for a master key and open the Magic Memory Vault!\",\n+     \"V2lzaCBmb3IgYSBtYXN0ZXIga2V5IGFuZCBvcGVuIHRoZSBNYWdpYyBNZW1vcnkgVmF1bHQ\"\n+     \"h\"},\n+    {\"Wizard expects every monster to do its duty.\",\n+     \"V2l6YXJkIGV4cGVjdHMgZXZlcnkgbW9uc3RlciB0byBkbyBpdHMgZHV0eS4=\"},\n+    {\"Wow! You could've had a potion of fruit juice!\",\n+     \"V293ISBZb3UgY291bGQndmUgaGFkIGEgcG90aW9uIG9mIGZydWl0IGp1aWNlIQ==\"},\n+    {\"Yet Another Silly Message (YASM).\",\n+     \"WWV0IEFub3RoZXIgU2lsbHkgTWVzc2FnZSAoWUFTTSku\"},\n+    {\"You are destined to be misled by a fortune.\",\n+     \"WW91IGFyZSBkZXN0aW5lZCB0byBiZSBtaXNsZWQgYnkgYSBmb3J0dW5lLg==\"},\n+    {\"You can get a genuine Amulet of Yendor by doing the following: --More--\",\n+     \"WW91IGNhbiBnZXQgYSBnZW51aW5lIEFtdWxldCBvZiBZZW5kb3IgYnkgZG9pbmcgdGhlIGZvb\"\n+     \"Gxvd2luZzogLS1Nb3JlLS0=\"},\n+    {\"You can protect yourself from black dragons by doing the following: \"\n+     \"--More--\",\n+     \"WW91IGNhbiBwcm90ZWN0IHlvdXJzZWxmIGZyb20gYmxhY2sgZHJhZ29ucyBieSBkb2luZyB0a\"\n+     \"GUgZm9sbG93aW5nOiAtLU1vcmUtLQ==\"},\n+    {\"You can't get by the snake.\", \"WW91IGNhbid0IGdldCBieSB0aGUgc25ha2Uu\"},\n+    {\"You feel like someone is pulling your leg.\",\n+     \"WW91IGZlZWwgbGlrZSBzb21lb25lIGlzIHB1bGxpbmcgeW91ciBsZWcu\"},\n+    {\"You have to outwit the Sphynx or pay her.\",\n+     \"WW91IGhhdmUgdG8gb3V0d2l0IHRoZSBTcGh5bnggb3IgcGF5IGhlci4=\"},\n+    {\"You hear the fortune cookie's hissing!\",\n+     \"WW91IGhlYXIgdGhlIGZvcnR1bmUgY29va2llJ3MgaGlzc2luZyE=\"},\n+    {\"You may get rich selling letters, but beware of being blackmailed!\",\n+     \"WW91IG1heSBnZXQgcmljaCBzZWxsaW5nIGxldHRlcnMsIGJ1dCBiZXdhcmUgb2YgYmVpbmcgY\"\n+     \"mxhY2ttYWlsZWQh\"},\n+    {\"You offend Shai-Hulud by sheathing your crysknife without having drawn \"\n+     \"blood.\",\n+     \"WW91IG9mZmVuZCBTaGFpLUh1bHVkIGJ5IHNoZWF0aGluZyB5b3VyIGNyeXNrbmlmZSB3aXRob\"\n+     \"3V0IGhhdmluZyBkcmF3biBibG9vZC4=\"},\n+    {\"You swallowed the fortune!\", \"WW91IHN3YWxsb3dlZCB0aGUgZm9ydHVuZSE=\"},\n+    {\"You want to regain strength? Two levels ahead is a guesthouse!\",\n+     \"WW91IHdhbnQgdG8gcmVnYWluIHN0cmVuZ3RoPyBUd28gbGV2ZWxzIGFoZWFkIGlzIGEgZ3Vlc\"\n+     \"3Rob3VzZSE=\"},\n+    {\"You will encounter a tall, dark, and gruesome creature...\",\n+     \"WW91IHdpbGwgZW5jb3VudGVyIGEgdGFsbCwgZGFyaywgYW5kIGdydWVzb21lIGNyZWF0dXJlL\"\n+     \"i4u\"},\n+\n+    {\"The End\", \"VGhlIEVuZA==\"}};\n \n /* PL_Base64Encode, random strings */\n-PRBool\n-test_004(void)\n-{\n-    int i;\n-    char result[4096];\n+PRBool test_004(void) {\n+  int i;\n+  char result[4096];\n \n-    printf(\n-        \"Test 004 (PL_Base64Encode, random strings)                            \"\n-        \"...\");\n-    fflush(stdout);\n+  printf(\n+      \"Test 004 (PL_Base64Encode, random strings)                            \"\n+      \"...\");\n+  fflush(stdout);\n \n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRUint32 plen = PL_strlen(array[i].plaintext);\n-        PRUint32 clen = ((plen + 2) / 3) * 4;\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRUint32 plen = PL_strlen(array[i].plaintext);\n+    PRUint32 clen = ((plen + 2) / 3) * 4;\n \n-        char* rv = PL_Base64Encode(array[i].plaintext, plen, result);\n+    char* rv = PL_Base64Encode(array[i].plaintext, plen, result);\n \n-        if (rv != result) {\n-            printf(\"FAIL\\n\\t(%d): return value\\n\", i);\n-            return PR_FALSE;\n-        }\n+    if (rv != result) {\n+      printf(\"FAIL\\n\\t(%d): return value\\n\", i);\n+      return PR_FALSE;\n+    }\n \n-        if (0 != PL_strncmp(result, array[i].cyphertext, clen)) {\n-            printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%.*s.\\\"\\n\", i,\n-                   array[i].plaintext, array[i].cyphertext, clen, result);\n-            return PR_FALSE;\n-        }\n+    if (0 != PL_strncmp(result, array[i].cyphertext, clen)) {\n+      printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%.*s.\\\"\\n\", i,\n+             array[i].plaintext, array[i].cyphertext, clen, result);\n+      return PR_FALSE;\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Encode, single characters, malloc */\n-PRBool\n-test_005(void)\n-{\n-    PRUint32 a, b;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char* rv;\n-\n-    printf(\n-        \"Test 005 (PL_Base64Encode, single characters, malloc)                 \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    plain[1] = plain[2] = plain[3] = (unsigned char)0;\n-    cypher[2] = cypher[3] = (unsigned char)'=';\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (unsigned char)(a * 4 + b);\n-            cypher[1] = base[(b * 16)];\n-\n-            rv = PL_Base64Encode((char*)plain, 1, (char*)0);\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL\\n\\t(%d, %d): no return value\\n\", a, b);\n-                return PR_FALSE;\n-            }\n-\n-            if (0 != PL_strcmp((char*)cypher, rv)) {\n-                printf(\"FAIL\\n\\t(%d, %d): expected \\\"%s,\\\" got \\\"%s.\\\"\\n\", a, b, cypher,\n-                       rv);\n-                PR_DELETE(rv);\n-                return PR_FALSE;\n-            }\n+PRBool test_005(void) {\n+  PRUint32 a, b;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char* rv;\n+\n+  printf(\n+      \"Test 005 (PL_Base64Encode, single characters, malloc)                 \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  plain[1] = plain[2] = plain[3] = (unsigned char)0;\n+  cypher[2] = cypher[3] = (unsigned char)'=';\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (unsigned char)(a * 4 + b);\n+      cypher[1] = base[(b * 16)];\n+\n+      rv = PL_Base64Encode((char*)plain, 1, (char*)0);\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL\\n\\t(%d, %d): no return value\\n\", a, b);\n+        return PR_FALSE;\n+      }\n+\n+      if (0 != PL_strcmp((char*)cypher, rv)) {\n+        printf(\"FAIL\\n\\t(%d, %d): expected \\\"%s,\\\" got \\\"%s.\\\"\\n\", a, b, cypher,\n+               rv);\n+        PR_DELETE(rv);\n+        return PR_FALSE;\n+      }\n \n-            PR_DELETE(rv);\n-        }\n+      PR_DELETE(rv);\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Encode, double characters, malloc */\n-PRBool\n-test_006(void)\n-{\n-    PRUint32 a, b, c, d;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char* rv;\n-\n-    printf(\n-        \"Test 006 (PL_Base64Encode, double characters, malloc)                 \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    plain[2] = plain[3] = (unsigned char)0;\n-    cypher[3] = (unsigned char)'=';\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (a * 4) + b;\n-            for (c = 0; c < 16; c++) {\n-                cypher[1] = base[b * 16 + c];\n-                for (d = 0; d < 16; d++) {\n-                    plain[1] = c * 16 + d;\n-                    cypher[2] = base[d * 4];\n-\n-                    rv = PL_Base64Encode((char*)plain, 2, (char*)0);\n-                    if ((char*)0 == rv) {\n-                        printf(\"FAIL\\n\\t(%d, %d, %d, %d): no return value\\n\", a, b, c, d);\n-                        return PR_FALSE;\n-                    }\n-\n-                    if (0 != PL_strcmp((char*)cypher, rv)) {\n-                        printf(\"FAIL\\n\\t(%d, %d, %d, %d): expected \\\"%s,\\\" got \\\"%s.\\\"\\n\",\n-                               a, b, c, d, cypher, rv);\n-                        PR_DELETE(rv);\n-                        return PR_FALSE;\n-                    }\n-\n-                    PR_DELETE(rv);\n-                }\n-            }\n+PRBool test_006(void) {\n+  PRUint32 a, b, c, d;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char* rv;\n+\n+  printf(\n+      \"Test 006 (PL_Base64Encode, double characters, malloc)                 \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  plain[2] = plain[3] = (unsigned char)0;\n+  cypher[3] = (unsigned char)'=';\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (a * 4) + b;\n+      for (c = 0; c < 16; c++) {\n+        cypher[1] = base[b * 16 + c];\n+        for (d = 0; d < 16; d++) {\n+          plain[1] = c * 16 + d;\n+          cypher[2] = base[d * 4];\n+\n+          rv = PL_Base64Encode((char*)plain, 2, (char*)0);\n+          if ((char*)0 == rv) {\n+            printf(\"FAIL\\n\\t(%d, %d, %d, %d): no return value\\n\", a, b, c, d);\n+            return PR_FALSE;\n+          }\n+\n+          if (0 != PL_strcmp((char*)cypher, rv)) {\n+            printf(\"FAIL\\n\\t(%d, %d, %d, %d): expected \\\"%s,\\\" got \\\"%s.\\\"\\n\",\n+                   a, b, c, d, cypher, rv);\n+            PR_DELETE(rv);\n+            return PR_FALSE;\n+          }\n+\n+          PR_DELETE(rv);\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Encode, triple characters, malloc */\n-PRBool\n-test_007(void)\n-{\n-    PRUint32 a, b, c, d, e, f;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char* rv;\n-\n-    printf(\n-        \"Test 007 (PL_Base64Encode, triple characters, malloc)                 \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (a * 4) + b;\n-            for (c = 0; c < 16; c++) {\n-                cypher[1] = base[b * 16 + c];\n-                for (d = 0; d < 16; d++) {\n-                    plain[1] = c * 16 + d;\n-                    for (e = 0; e < 4; e++) {\n-                        cypher[2] = base[d * 4 + e];\n-                        for (f = 0; f < 64; f++) {\n-                            plain[2] = e * 64 + f;\n-                            cypher[3] = base[f];\n-\n-                            rv = PL_Base64Encode((char*)plain, 3, (char*)0);\n-                            if ((char*)0 == rv) {\n-                                printf(\"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): no return value\\n\", a,\n-                                       b, c, d, e, f);\n-                                return PR_FALSE;\n-                            }\n-\n-                            if (0 != PL_strcmp((char*)cypher, rv)) {\n-                                printf(\n-                                    \"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): expected \\\"%s,\\\" got \"\n-                                    \"\\\"%.4s.\\\"\\n\",\n-                                    a, b, c, d, e, f, cypher, rv);\n-                                PR_DELETE(rv);\n-                                return PR_FALSE;\n-                            }\n-\n-                            PR_DELETE(rv);\n-                        }\n-                    }\n-                }\n+PRBool test_007(void) {\n+  PRUint32 a, b, c, d, e, f;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char* rv;\n+\n+  printf(\n+      \"Test 007 (PL_Base64Encode, triple characters, malloc)                 \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (a * 4) + b;\n+      for (c = 0; c < 16; c++) {\n+        cypher[1] = base[b * 16 + c];\n+        for (d = 0; d < 16; d++) {\n+          plain[1] = c * 16 + d;\n+          for (e = 0; e < 4; e++) {\n+            cypher[2] = base[d * 4 + e];\n+            for (f = 0; f < 64; f++) {\n+              plain[2] = e * 64 + f;\n+              cypher[3] = base[f];\n+\n+              rv = PL_Base64Encode((char*)plain, 3, (char*)0);\n+              if ((char*)0 == rv) {\n+                printf(\"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): no return value\\n\", a,\n+                       b, c, d, e, f);\n+                return PR_FALSE;\n+              }\n+\n+              if (0 != PL_strcmp((char*)cypher, rv)) {\n+                printf(\n+                    \"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): expected \\\"%s,\\\" got \"\n+                    \"\\\"%.4s.\\\"\\n\",\n+                    a, b, c, d, e, f, cypher, rv);\n+                PR_DELETE(rv);\n+                return PR_FALSE;\n+              }\n+\n+              PR_DELETE(rv);\n             }\n+          }\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Encode, random strings, malloc */\n-PRBool\n-test_008(void)\n-{\n-    int i;\n-\n-    printf(\n-        \"Test 008 (PL_Base64Encode, random strings, malloc)                    \"\n-        \"...\");\n-    fflush(stdout);\n+PRBool test_008(void) {\n+  int i;\n \n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRUint32 plen = PL_strlen(array[i].plaintext);\n-        PRUint32 clen = ((plen + 2) / 3) * 4;\n+  printf(\n+      \"Test 008 (PL_Base64Encode, random strings, malloc)                    \"\n+      \"...\");\n+  fflush(stdout);\n \n-        char* rv = PL_Base64Encode(array[i].plaintext, plen, (char*)0);\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRUint32 plen = PL_strlen(array[i].plaintext);\n+    PRUint32 clen = ((plen + 2) / 3) * 4;\n \n-        if ((char*)0 == rv) {\n-            printf(\"FAIL\\n\\t(%d): no return value\\n\", i);\n-            return PR_FALSE;\n-        }\n+    char* rv = PL_Base64Encode(array[i].plaintext, plen, (char*)0);\n \n-        if (0 != PL_strcmp(rv, array[i].cyphertext)) {\n-            printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%s.\\\"\\n\", i,\n-                   array[i].plaintext, array[i].cyphertext, rv);\n-            PR_DELETE(rv);\n-            return PR_FALSE;\n-        }\n+    if ((char*)0 == rv) {\n+      printf(\"FAIL\\n\\t(%d): no return value\\n\", i);\n+      return PR_FALSE;\n+    }\n \n-        PR_DELETE(rv);\n+    if (0 != PL_strcmp(rv, array[i].cyphertext)) {\n+      printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%s.\\\"\\n\", i,\n+             array[i].plaintext, array[i].cyphertext, rv);\n+      return PR_FALSE;\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, single characters */\n-PRBool\n-test_009(void)\n-{\n-    PRUint32 a, b;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char result[8];\n-    char* rv;\n-\n-    printf(\n-        \"Test 009 (PL_Base64Decode, single characters, equals)                 \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    plain[1] = plain[2] = plain[3] = (unsigned char)0;\n-    cypher[2] = cypher[3] = (unsigned char)'=';\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (unsigned char)(a * 4 + b);\n-            cypher[1] = base[(b * 16)];\n-\n-            rv = PL_Base64Decode((char*)cypher, 4, result);\n-            if (rv != result) {\n-                printf(\"FAIL\\n\\t(%d, %d): return value\\n\", a, b);\n-                return PR_FALSE;\n-            }\n-\n-            if (0 != PL_strncmp((char*)plain, result, 1)) {\n-                printf(\"FAIL\\n\\t(%d, %d): expected \\\"%s,\\\" got \\\"%.1s.\\\"\\n\", a, b,\n-                       plain, result);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_009(void) {\n+  PRUint32 a, b;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char result[8];\n+  char* rv;\n+\n+  printf(\n+      \"Test 009 (PL_Base64Decode, single characters, equals)                 \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  plain[1] = plain[2] = plain[3] = (unsigned char)0;\n+  cypher[2] = cypher[3] = (unsigned char)'=';\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (unsigned char)(a * 4 + b);\n+      cypher[1] = base[(b * 16)];\n+\n+      rv = PL_Base64Decode((char*)cypher, 4, result);\n+      if (rv != result) {\n+        printf(\"FAIL\\n\\t(%d, %d): return value\\n\", a, b);\n+        return PR_FALSE;\n+      }\n+\n+      if (0 != PL_strncmp((char*)plain, result, 1)) {\n+        printf(\"FAIL\\n\\t(%d, %d): expected \\\"%s,\\\" got \\\"%.1s.\\\"\\n\", a, b,\n+               plain, result);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, single characters */\n-PRBool\n-test_010(void)\n-{\n-    PRUint32 a, b;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char result[8];\n-    char* rv;\n-\n-    printf(\n-        \"Test 010 (PL_Base64Decode, single characters, no equals)              \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    plain[1] = plain[2] = plain[3] = (unsigned char)0;\n-    cypher[2] = cypher[3] = (unsigned char)0;\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (unsigned char)(a * 4 + b);\n-            cypher[1] = base[(b * 16)];\n-\n-            rv = PL_Base64Decode((char*)cypher, 2, result);\n-            if (rv != result) {\n-                printf(\"FAIL\\n\\t(%d, %d): return value\\n\", a, b);\n-                return PR_FALSE;\n-            }\n-\n-            if (0 != PL_strncmp((char*)plain, result, 1)) {\n-                printf(\"FAIL\\n\\t(%d, %d): expected \\\"%s,\\\" got \\\"%.1s.\\\"\\n\", a, b,\n-                       plain, result);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_010(void) {\n+  PRUint32 a, b;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char result[8];\n+  char* rv;\n+\n+  printf(\n+      \"Test 010 (PL_Base64Decode, single characters, no equals)              \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  plain[1] = plain[2] = plain[3] = (unsigned char)0;\n+  cypher[2] = cypher[3] = (unsigned char)0;\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (unsigned char)(a * 4 + b);\n+      cypher[1] = base[(b * 16)];\n+\n+      rv = PL_Base64Decode((char*)cypher, 2, result);\n+      if (rv != result) {\n+        printf(\"FAIL\\n\\t(%d, %d): return value\\n\", a, b);\n+        return PR_FALSE;\n+      }\n+\n+      if (0 != PL_strncmp((char*)plain, result, 1)) {\n+        printf(\"FAIL\\n\\t(%d, %d): expected \\\"%s,\\\" got \\\"%.1s.\\\"\\n\", a, b,\n+               plain, result);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, double characters */\n-PRBool\n-test_011(void)\n-{\n-    PRUint32 a, b, c, d;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char result[8];\n-    char* rv;\n-\n-    printf(\n-        \"Test 011 (PL_Base64Decode, double characters, equals)                 \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    plain[2] = plain[3] = (unsigned char)0;\n-    cypher[3] = (unsigned char)'=';\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (a * 4) + b;\n-            for (c = 0; c < 16; c++) {\n-                cypher[1] = base[b * 16 + c];\n-                for (d = 0; d < 16; d++) {\n-                    plain[1] = c * 16 + d;\n-                    cypher[2] = base[d * 4];\n-\n-                    rv = PL_Base64Decode((char*)cypher, 4, result);\n-                    if (rv != result) {\n-                        printf(\"FAIL\\n\\t(%d, %d, %d, %d): return value\\n\", a, b, c, d);\n-                        return PR_FALSE;\n-                    }\n-\n-                    if (0 != PL_strncmp((char*)plain, result, 2)) {\n-                        printf(\"FAIL\\n\\t(%d, %d, %d, %d): expected \\\"%s,\\\" got \\\"%.2s.\\\"\\n\",\n-                               a, b, c, d, plain, result);\n-                        return PR_FALSE;\n-                    }\n-                }\n-            }\n+PRBool test_011(void) {\n+  PRUint32 a, b, c, d;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char result[8];\n+  char* rv;\n+\n+  printf(\n+      \"Test 011 (PL_Base64Decode, double characters, equals)                 \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  plain[2] = plain[3] = (unsigned char)0;\n+  cypher[3] = (unsigned char)'=';\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (a * 4) + b;\n+      for (c = 0; c < 16; c++) {\n+        cypher[1] = base[b * 16 + c];\n+        for (d = 0; d < 16; d++) {\n+          plain[1] = c * 16 + d;\n+          cypher[2] = base[d * 4];\n+\n+          rv = PL_Base64Decode((char*)cypher, 4, result);\n+          if (rv != result) {\n+            printf(\"FAIL\\n\\t(%d, %d, %d, %d): return value\\n\", a, b, c, d);\n+            return PR_FALSE;\n+          }\n+\n+          if (0 != PL_strncmp((char*)plain, result, 2)) {\n+            printf(\"FAIL\\n\\t(%d, %d, %d, %d): expected \\\"%s,\\\" got \\\"%.2s.\\\"\\n\",\n+                   a, b, c, d, plain, result);\n+            return PR_FALSE;\n+          }\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, double characters */\n-PRBool\n-test_012(void)\n-{\n-    PRUint32 a, b, c, d;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char result[8];\n-    char* rv;\n-\n-    printf(\n-        \"Test 012 (PL_Base64Decode, double characters, no equals)              \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    plain[2] = plain[3] = (unsigned char)0;\n-    cypher[3] = (unsigned char)0;\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (a * 4) + b;\n-            for (c = 0; c < 16; c++) {\n-                cypher[1] = base[b * 16 + c];\n-                for (d = 0; d < 16; d++) {\n-                    plain[1] = c * 16 + d;\n-                    cypher[2] = base[d * 4];\n-\n-                    rv = PL_Base64Decode((char*)cypher, 3, result);\n-                    if (rv != result) {\n-                        printf(\"FAIL\\n\\t(%d, %d, %d, %d): return value\\n\", a, b, c, d);\n-                        return PR_FALSE;\n-                    }\n-\n-                    if (0 != PL_strncmp((char*)plain, result, 2)) {\n-                        printf(\"FAIL\\n\\t(%d, %d, %d, %d): expected \\\"%s,\\\" got \\\"%.2s.\\\"\\n\",\n-                               a, b, c, d, cypher, result);\n-                        return PR_FALSE;\n-                    }\n-                }\n-            }\n+PRBool test_012(void) {\n+  PRUint32 a, b, c, d;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char result[8];\n+  char* rv;\n+\n+  printf(\n+      \"Test 012 (PL_Base64Decode, double characters, no equals)              \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  plain[2] = plain[3] = (unsigned char)0;\n+  cypher[3] = (unsigned char)0;\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (a * 4) + b;\n+      for (c = 0; c < 16; c++) {\n+        cypher[1] = base[b * 16 + c];\n+        for (d = 0; d < 16; d++) {\n+          plain[1] = c * 16 + d;\n+          cypher[2] = base[d * 4];\n+\n+          rv = PL_Base64Decode((char*)cypher, 3, result);\n+          if (rv != result) {\n+            printf(\"FAIL\\n\\t(%d, %d, %d, %d): return value\\n\", a, b, c, d);\n+            return PR_FALSE;\n+          }\n+\n+          if (0 != PL_strncmp((char*)plain, result, 2)) {\n+            printf(\"FAIL\\n\\t(%d, %d, %d, %d): expected \\\"%s,\\\" got \\\"%.2s.\\\"\\n\",\n+                   a, b, c, d, cypher, result);\n+            return PR_FALSE;\n+          }\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, triple characters */\n-PRBool\n-test_013(void)\n-{\n-    PRUint32 a, b, c, d, e, f;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char result[8];\n-    char* rv;\n-\n-    printf(\n-        \"Test 013 (PL_Base64Decode, triple characters)                         \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (a * 4) + b;\n-            for (c = 0; c < 16; c++) {\n-                cypher[1] = base[b * 16 + c];\n-                for (d = 0; d < 16; d++) {\n-                    plain[1] = c * 16 + d;\n-                    for (e = 0; e < 4; e++) {\n-                        cypher[2] = base[d * 4 + e];\n-                        for (f = 0; f < 64; f++) {\n-                            plain[2] = e * 64 + f;\n-                            cypher[3] = base[f];\n-\n-                            rv = PL_Base64Decode((char*)cypher, 4, result);\n-                            if (rv != result) {\n-                                printf(\"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): return value\\n\", a, b,\n-                                       c, d, e, f);\n-                                return PR_FALSE;\n-                            }\n-\n-                            if (0 != PL_strncmp((char*)plain, result, 3)) {\n-                                printf(\n-                                    \"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): expected \\\"%s,\\\" got \"\n-                                    \"\\\"%.3s.\\\"\\n\",\n-                                    a, b, c, d, e, f, plain, result);\n-                                return PR_FALSE;\n-                            }\n-                        }\n-                    }\n-                }\n+PRBool test_013(void) {\n+  PRUint32 a, b, c, d, e, f;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char result[8];\n+  char* rv;\n+\n+  printf(\n+      \"Test 013 (PL_Base64Decode, triple characters)                         \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (a * 4) + b;\n+      for (c = 0; c < 16; c++) {\n+        cypher[1] = base[b * 16 + c];\n+        for (d = 0; d < 16; d++) {\n+          plain[1] = c * 16 + d;\n+          for (e = 0; e < 4; e++) {\n+            cypher[2] = base[d * 4 + e];\n+            for (f = 0; f < 64; f++) {\n+              plain[2] = e * 64 + f;\n+              cypher[3] = base[f];\n+\n+              rv = PL_Base64Decode((char*)cypher, 4, result);\n+              if (rv != result) {\n+                printf(\"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): return value\\n\", a, b,\n+                       c, d, e, f);\n+                return PR_FALSE;\n+              }\n+\n+              if (0 != PL_strncmp((char*)plain, result, 3)) {\n+                printf(\n+                    \"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): expected \\\"%s,\\\" got \"\n+                    \"\\\"%.3s.\\\"\\n\",\n+                    a, b, c, d, e, f, plain, result);\n+                return PR_FALSE;\n+              }\n             }\n+          }\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, random strings */\n-PRBool\n-test_014(void)\n-{\n-    int i;\n-    char result[4096];\n+PRBool test_014(void) {\n+  int i;\n+  char result[4096];\n \n-    printf(\n-        \"Test 014 (PL_Base64Decode, random strings, equals)                    \"\n-        \"...\");\n-    fflush(stdout);\n+  printf(\n+      \"Test 014 (PL_Base64Decode, random strings, equals)                    \"\n+      \"...\");\n+  fflush(stdout);\n \n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRUint32 clen = PL_strlen(array[i].cyphertext);\n-        PRUint32 plen = (clen * 3) / 4;\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRUint32 clen = PL_strlen(array[i].cyphertext);\n+    PRUint32 plen = (clen * 3) / 4;\n \n-        char* rv = PL_Base64Decode(array[i].cyphertext, clen, result);\n+    char* rv = PL_Base64Decode(array[i].cyphertext, clen, result);\n \n-        if (rv != result) {\n-            printf(\"FAIL\\n\\t(%d): return value\\n\", i);\n-            return PR_FALSE;\n-        }\n+    if (rv != result) {\n+      printf(\"FAIL\\n\\t(%d): return value\\n\", i);\n+      return PR_FALSE;\n+    }\n \n-        if (0 == (clen & 3)) {\n-            if ('=' == array[i].cyphertext[clen - 1]) {\n-                if ('=' == array[i].cyphertext[clen - 2]) {\n-                    plen -= 2;\n-                } else {\n-                    plen -= 1;\n-                }\n-            }\n+    if (0 == (clen & 3)) {\n+      if ('=' == array[i].cyphertext[clen - 1]) {\n+        if ('=' == array[i].cyphertext[clen - 2]) {\n+          plen -= 2;\n+        } else {\n+          plen -= 1;\n         }\n+      }\n+    }\n \n-        if (0 != PL_strncmp(result, array[i].plaintext, plen)) {\n-            printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%.*s.\\\"\\n\", i,\n-                   array[i].cyphertext, array[i].plaintext, plen, result);\n-            return PR_FALSE;\n-        }\n+    if (0 != PL_strncmp(result, array[i].plaintext, plen)) {\n+      printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%.*s.\\\"\\n\", i,\n+             array[i].cyphertext, array[i].plaintext, plen, result);\n+      return PR_FALSE;\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, random strings */\n-PRBool\n-test_015(void)\n-{\n-    int i;\n-    char buffer[4096];\n-    char result[4096];\n-    char* rv;\n-\n-    printf(\n-        \"Test 015 (PL_Base64Decode, random strings, no equals)                 \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRUint32 clen, plen;\n-\n-        PL_strcpy(buffer, array[i].cyphertext);\n-        clen = PL_strlen(buffer);\n-\n-        if (0 == (clen & 3)) {\n-            if ('=' == buffer[clen - 1]) {\n-                if ('=' == buffer[clen - 2]) {\n-                    buffer[clen - 2] = buffer[clen - 1] = (char)0;\n-                    clen -= 2;\n-                } else {\n-                    buffer[clen - 1] = (char)0;\n-                    clen -= 1;\n-                }\n-            }\n+PRBool test_015(void) {\n+  int i;\n+  char buffer[4096];\n+  char result[4096];\n+  char* rv;\n+\n+  printf(\n+      \"Test 015 (PL_Base64Decode, random strings, no equals)                 \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRUint32 clen, plen;\n+\n+    PL_strcpy(buffer, array[i].cyphertext);\n+    clen = PL_strlen(buffer);\n+\n+    if (0 == (clen & 3)) {\n+      if ('=' == buffer[clen - 1]) {\n+        if ('=' == buffer[clen - 2]) {\n+          buffer[clen - 2] = buffer[clen - 1] = (char)0;\n+          clen -= 2;\n+        } else {\n+          buffer[clen - 1] = (char)0;\n+          clen -= 1;\n         }\n+      }\n+    }\n \n-        plen = (clen * 3) / 4;\n+    plen = (clen * 3) / 4;\n \n-        rv = PL_Base64Decode(buffer, clen, result);\n+    rv = PL_Base64Decode(buffer, clen, result);\n \n-        if (rv != result) {\n-            printf(\"FAIL\\n\\t(%d): return value\\n\", i);\n-            return PR_FALSE;\n-        }\n+    if (rv != result) {\n+      printf(\"FAIL\\n\\t(%d): return value\\n\", i);\n+      return PR_FALSE;\n+    }\n \n-        if (0 != PL_strncmp(result, array[i].plaintext, plen)) {\n-            printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%.*s.\\\"\\n\", i,\n-                   array[i].cyphertext, array[i].plaintext, plen, result);\n-            return PR_FALSE;\n-        }\n+    if (0 != PL_strncmp(result, array[i].plaintext, plen)) {\n+      printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%.*s.\\\"\\n\", i,\n+             array[i].cyphertext, array[i].plaintext, plen, result);\n+      return PR_FALSE;\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, single characters, malloc */\n-PRBool\n-test_016(void)\n-{\n-    PRUint32 a, b;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char* rv;\n-\n-    printf(\n-        \"Test 016 (PL_Base64Decode, single characters, equals, malloc)         \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    plain[1] = plain[2] = plain[3] = (unsigned char)0;\n-    cypher[2] = cypher[3] = (unsigned char)'=';\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (unsigned char)(a * 4 + b);\n-            cypher[1] = base[(b * 16)];\n-\n-            rv = PL_Base64Decode((char*)cypher, 4, (char*)0);\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL\\n\\t(%d, %d): no return value\\n\", a, b);\n-                return PR_FALSE;\n-            }\n-\n-            if (0 != PL_strcmp((char*)plain, rv)) {\n-                printf(\"FAIL\\n\\t(%d, %d): expected \\\"%s,\\\" got \\\"%s.\\\"\\n\", a, b, plain,\n-                       rv);\n-                PR_DELETE(rv);\n-                return PR_FALSE;\n-            }\n+PRBool test_016(void) {\n+  PRUint32 a, b;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char* rv;\n+\n+  printf(\n+      \"Test 016 (PL_Base64Decode, single characters, equals, malloc)         \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  plain[1] = plain[2] = plain[3] = (unsigned char)0;\n+  cypher[2] = cypher[3] = (unsigned char)'=';\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (unsigned char)(a * 4 + b);\n+      cypher[1] = base[(b * 16)];\n+\n+      rv = PL_Base64Decode((char*)cypher, 4, (char*)0);\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL\\n\\t(%d, %d): no return value\\n\", a, b);\n+        return PR_FALSE;\n+      }\n+\n+      if (0 != PL_strcmp((char*)plain, rv)) {\n+        printf(\"FAIL\\n\\t(%d, %d): expected \\\"%s,\\\" got \\\"%s.\\\"\\n\", a, b, plain,\n+               rv);\n+        PR_DELETE(rv);\n+        return PR_FALSE;\n+      }\n \n-            PR_DELETE(rv);\n-        }\n+      PR_DELETE(rv);\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, single characters, malloc */\n-PRBool\n-test_017(void)\n-{\n-    PRUint32 a, b;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char* rv;\n-\n-    printf(\n-        \"Test 017 (PL_Base64Decode, single characters, no equals, malloc)      \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    plain[1] = plain[2] = plain[3] = (unsigned char)0;\n-    cypher[2] = cypher[3] = (unsigned char)0;\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (unsigned char)(a * 4 + b);\n-            cypher[1] = base[(b * 16)];\n-\n-            rv = PL_Base64Decode((char*)cypher, 2, (char*)0);\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL\\n\\t(%d, %d): no return value\\n\", a, b);\n-                return PR_FALSE;\n-            }\n-\n-            if (0 != PL_strcmp((char*)plain, rv)) {\n-                printf(\"FAIL\\n\\t(%d, %d): expected \\\"%s,\\\" got \\\"%s.\\\"\\n\", a, b, plain,\n-                       rv);\n-                PR_DELETE(rv);\n-                return PR_FALSE;\n-            }\n+PRBool test_017(void) {\n+  PRUint32 a, b;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char* rv;\n+\n+  printf(\n+      \"Test 017 (PL_Base64Decode, single characters, no equals, malloc)      \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  plain[1] = plain[2] = plain[3] = (unsigned char)0;\n+  cypher[2] = cypher[3] = (unsigned char)0;\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (unsigned char)(a * 4 + b);\n+      cypher[1] = base[(b * 16)];\n+\n+      rv = PL_Base64Decode((char*)cypher, 2, (char*)0);\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL\\n\\t(%d, %d): no return value\\n\", a, b);\n+        return PR_FALSE;\n+      }\n+\n+      if (0 != PL_strcmp((char*)plain, rv)) {\n+        printf(\"FAIL\\n\\t(%d, %d): expected \\\"%s,\\\" got \\\"%s.\\\"\\n\", a, b, plain,\n+               rv);\n+        PR_DELETE(rv);\n+        return PR_FALSE;\n+      }\n \n-            PR_DELETE(rv);\n-        }\n+      PR_DELETE(rv);\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, double characters, malloc */\n-PRBool\n-test_018(void)\n-{\n-    PRUint32 a, b, c, d;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char* rv;\n-\n-    printf(\n-        \"Test 018 (PL_Base64Decode, double characters, equals, malloc)         \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    plain[2] = plain[3] = (unsigned char)0;\n-    cypher[3] = (unsigned char)'=';\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (a * 4) + b;\n-            for (c = 0; c < 16; c++) {\n-                cypher[1] = base[b * 16 + c];\n-                for (d = 0; d < 16; d++) {\n-                    plain[1] = c * 16 + d;\n-                    cypher[2] = base[d * 4];\n-\n-                    rv = PL_Base64Decode((char*)cypher, 4, (char*)0);\n-                    if ((char*)0 == rv) {\n-                        printf(\"FAIL\\n\\t(%d, %d, %d, %d): no return value\\n\", a, b, c, d);\n-                        return PR_FALSE;\n-                    }\n-\n-                    if (0 != PL_strcmp((char*)plain, rv)) {\n-                        printf(\"FAIL\\n\\t(%d, %d, %d, %d): expected \\\"%s,\\\" got \\\"%s.\\\"\\n\",\n-                               a, b, c, d, plain, rv);\n-                        PR_DELETE(rv);\n-                        return PR_FALSE;\n-                    }\n-\n-                    PR_DELETE(rv);\n-                }\n-            }\n+PRBool test_018(void) {\n+  PRUint32 a, b, c, d;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char* rv;\n+\n+  printf(\n+      \"Test 018 (PL_Base64Decode, double characters, equals, malloc)         \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  plain[2] = plain[3] = (unsigned char)0;\n+  cypher[3] = (unsigned char)'=';\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (a * 4) + b;\n+      for (c = 0; c < 16; c++) {\n+        cypher[1] = base[b * 16 + c];\n+        for (d = 0; d < 16; d++) {\n+          plain[1] = c * 16 + d;\n+          cypher[2] = base[d * 4];\n+\n+          rv = PL_Base64Decode((char*)cypher, 4, (char*)0);\n+          if ((char*)0 == rv) {\n+            printf(\"FAIL\\n\\t(%d, %d, %d, %d): no return value\\n\", a, b, c, d);\n+            return PR_FALSE;\n+          }\n+\n+          if (0 != PL_strcmp((char*)plain, rv)) {\n+            printf(\"FAIL\\n\\t(%d, %d, %d, %d): expected \\\"%s,\\\" got \\\"%s.\\\"\\n\",\n+                   a, b, c, d, plain, rv);\n+            PR_DELETE(rv);\n+            return PR_FALSE;\n+          }\n+\n+          PR_DELETE(rv);\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, double characters, malloc */\n-PRBool\n-test_019(void)\n-{\n-    PRUint32 a, b, c, d;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char* rv;\n-\n-    printf(\n-        \"Test 019 (PL_Base64Decode, double characters, no equals, malloc)      \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    plain[2] = plain[3] = (unsigned char)0;\n-    cypher[3] = (unsigned char)0;\n-    cypher[4] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (a * 4) + b;\n-            for (c = 0; c < 16; c++) {\n-                cypher[1] = base[b * 16 + c];\n-                for (d = 0; d < 16; d++) {\n-                    plain[1] = c * 16 + d;\n-                    cypher[2] = base[d * 4];\n-\n-                    rv = PL_Base64Decode((char*)cypher, 3, (char*)0);\n-                    if ((char*)0 == rv) {\n-                        printf(\"FAIL\\n\\t(%d, %d, %d, %d): no return value\\n\", a, b, c, d);\n-                        return PR_FALSE;\n-                    }\n-\n-                    if (0 != PL_strcmp((char*)plain, rv)) {\n-                        printf(\"FAIL\\n\\t(%d, %d, %d, %d): expected \\\"%s,\\\" got \\\"%s.\\\"\\n\",\n-                               a, b, c, d, cypher, rv);\n-                        PR_DELETE(rv);\n-                        return PR_FALSE;\n-                    }\n-\n-                    PR_DELETE(rv);\n-                }\n-            }\n+PRBool test_019(void) {\n+  PRUint32 a, b, c, d;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char* rv;\n+\n+  printf(\n+      \"Test 019 (PL_Base64Decode, double characters, no equals, malloc)      \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  plain[2] = plain[3] = (unsigned char)0;\n+  cypher[3] = (unsigned char)0;\n+  cypher[4] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (a * 4) + b;\n+      for (c = 0; c < 16; c++) {\n+        cypher[1] = base[b * 16 + c];\n+        for (d = 0; d < 16; d++) {\n+          plain[1] = c * 16 + d;\n+          cypher[2] = base[d * 4];\n+\n+          rv = PL_Base64Decode((char*)cypher, 3, (char*)0);\n+          if ((char*)0 == rv) {\n+            printf(\"FAIL\\n\\t(%d, %d, %d, %d): no return value\\n\", a, b, c, d);\n+            return PR_FALSE;\n+          }\n+\n+          if (0 != PL_strcmp((char*)plain, rv)) {\n+            printf(\"FAIL\\n\\t(%d, %d, %d, %d): expected \\\"%s,\\\" got \\\"%s.\\\"\\n\",\n+                   a, b, c, d, cypher, rv);\n+            PR_DELETE(rv);\n+            return PR_FALSE;\n+          }\n+\n+          PR_DELETE(rv);\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, triple characters, malloc */\n-PRBool\n-test_020(void)\n-{\n-    PRUint32 a, b, c, d, e, f;\n-    unsigned char plain[4];\n-    unsigned char cypher[5];\n-    char* rv;\n-\n-    printf(\n-        \"Test 020 (PL_Base64Decode, triple characters, malloc)                 \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    cypher[4] = (unsigned char)0;\n-    plain[3] = (unsigned char)0;\n-\n-    for (a = 0; a < 64; a++) {\n-        cypher[0] = base[a];\n-        for (b = 0; b < 4; b++) {\n-            plain[0] = (a * 4) + b;\n-            for (c = 0; c < 16; c++) {\n-                cypher[1] = base[b * 16 + c];\n-                for (d = 0; d < 16; d++) {\n-                    plain[1] = c * 16 + d;\n-                    for (e = 0; e < 4; e++) {\n-                        cypher[2] = base[d * 4 + e];\n-                        for (f = 0; f < 64; f++) {\n-                            plain[2] = e * 64 + f;\n-                            cypher[3] = base[f];\n-\n-                            rv = PL_Base64Decode((char*)cypher, 4, (char*)0);\n-                            if ((char*)0 == rv) {\n-                                printf(\"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): no return value\\n\", a,\n-                                       b, c, d, e, f);\n-                                return PR_FALSE;\n-                            }\n-\n-                            if (0 != PL_strcmp((char*)plain, rv)) {\n-                                printf(\n-                                    \"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): expected \\\"%s,\\\" got \"\n-                                    \"\\\"%.3s.\\\"\\n\",\n-                                    a, b, c, d, e, f, plain, rv);\n-                                PR_DELETE(rv);\n-                                return PR_FALSE;\n-                            }\n-\n-                            PR_DELETE(rv);\n-                        }\n-                    }\n-                }\n+PRBool test_020(void) {\n+  PRUint32 a, b, c, d, e, f;\n+  unsigned char plain[4];\n+  unsigned char cypher[5];\n+  char* rv;\n+\n+  printf(\n+      \"Test 020 (PL_Base64Decode, triple characters, malloc)                 \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  cypher[4] = (unsigned char)0;\n+  plain[3] = (unsigned char)0;\n+\n+  for (a = 0; a < 64; a++) {\n+    cypher[0] = base[a];\n+    for (b = 0; b < 4; b++) {\n+      plain[0] = (a * 4) + b;\n+      for (c = 0; c < 16; c++) {\n+        cypher[1] = base[b * 16 + c];\n+        for (d = 0; d < 16; d++) {\n+          plain[1] = c * 16 + d;\n+          for (e = 0; e < 4; e++) {\n+            cypher[2] = base[d * 4 + e];\n+            for (f = 0; f < 64; f++) {\n+              plain[2] = e * 64 + f;\n+              cypher[3] = base[f];\n+\n+              rv = PL_Base64Decode((char*)cypher, 4, (char*)0);\n+              if ((char*)0 == rv) {\n+                printf(\"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): no return value\\n\", a,\n+                       b, c, d, e, f);\n+                return PR_FALSE;\n+              }\n+\n+              if (0 != PL_strcmp((char*)plain, rv)) {\n+                printf(\n+                    \"FAIL\\n\\t(%d, %d, %d, %d, %d, %d): expected \\\"%s,\\\" got \"\n+                    \"\\\"%.3s.\\\"\\n\",\n+                    a, b, c, d, e, f, plain, rv);\n+                PR_DELETE(rv);\n+                return PR_FALSE;\n+              }\n+\n+              PR_DELETE(rv);\n             }\n+          }\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, random strings, malloc */\n-PRBool\n-test_021(void)\n-{\n-    int i;\n-\n-    printf(\n-        \"Test 021 (PL_Base64Decode, random strings, equals, malloc)            \"\n-        \"...\");\n-    fflush(stdout);\n+PRBool test_021(void) {\n+  int i;\n \n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRUint32 clen = PL_strlen(array[i].cyphertext);\n+  printf(\n+      \"Test 021 (PL_Base64Decode, random strings, equals, malloc)            \"\n+      \"...\");\n+  fflush(stdout);\n \n-        char* rv = PL_Base64Decode(array[i].cyphertext, clen, (char*)0);\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRUint32 clen = PL_strlen(array[i].cyphertext);\n \n-        if ((char*)0 == rv) {\n-            printf(\"FAIL\\n\\t(%d): no return value\\n\", i);\n-            return PR_FALSE;\n-        }\n+    char* rv = PL_Base64Decode(array[i].cyphertext, clen, (char*)0);\n \n-        if (0 != PL_strcmp(rv, array[i].plaintext)) {\n-            printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%s.\\\"\\n\", i,\n-                   array[i].cyphertext, array[i].plaintext, rv);\n-            PR_DELETE(rv);\n-            return PR_FALSE;\n-        }\n+    if ((char*)0 == rv) {\n+      printf(\"FAIL\\n\\t(%d): no return value\\n\", i);\n+      return PR_FALSE;\n+    }\n \n-        PR_DELETE(rv);\n+    if (0 != PL_strcmp(rv, array[i].plaintext)) {\n+      printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%s.\\\"\\n\", i,\n+             array[i].cyphertext, array[i].plaintext, rv);\n+      PR_DELETE(rv);\n+      return PR_FALSE;\n     }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+    PR_DELETE(rv);\n+  }\n+\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Encode, random strings, malloc */\n-PRBool\n-test_022(void)\n-{\n-    int i;\n-    char buffer[4096];\n-    char* rv;\n-\n-    printf(\n-        \"Test 022 (PL_Base64Decode, random strings, no equals, malloc)         \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRUint32 clen;\n-\n-        PL_strcpy(buffer, array[i].cyphertext);\n-        clen = PL_strlen(buffer);\n-\n-        if (0 == (clen & 3)) {\n-            if ('=' == buffer[clen - 1]) {\n-                if ('=' == buffer[clen - 2]) {\n-                    buffer[clen - 2] = buffer[clen - 1] = (char)0;\n-                    clen -= 2;\n-                } else {\n-                    buffer[clen - 1] = (char)0;\n-                    clen -= 1;\n-                }\n-            }\n+PRBool test_022(void) {\n+  int i;\n+  char buffer[4096];\n+  char* rv;\n+\n+  printf(\n+      \"Test 022 (PL_Base64Decode, random strings, no equals, malloc)         \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRUint32 clen;\n+\n+    PL_strcpy(buffer, array[i].cyphertext);\n+    clen = PL_strlen(buffer);\n+\n+    if (0 == (clen & 3)) {\n+      if ('=' == buffer[clen - 1]) {\n+        if ('=' == buffer[clen - 2]) {\n+          buffer[clen - 2] = buffer[clen - 1] = (char)0;\n+          clen -= 2;\n+        } else {\n+          buffer[clen - 1] = (char)0;\n+          clen -= 1;\n         }\n+      }\n+    }\n \n-        rv = PL_Base64Decode(buffer, clen, (char*)0);\n-\n-        if ((char*)0 == rv) {\n-            printf(\"FAIL\\n\\t(%d): no return value\\n\", i);\n-            return PR_FALSE;\n-        }\n+    rv = PL_Base64Decode(buffer, clen, (char*)0);\n \n-        if (0 != PL_strcmp(rv, array[i].plaintext)) {\n-            printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%s.\\\"\\n\", i,\n-                   array[i].cyphertext, array[i].plaintext, rv);\n-            PR_DELETE(rv);\n-            return PR_FALSE;\n-        }\n+    if ((char*)0 == rv) {\n+      printf(\"FAIL\\n\\t(%d): no return value\\n\", i);\n+      return PR_FALSE;\n+    }\n \n-        PR_DELETE(rv);\n+    if (0 != PL_strcmp(rv, array[i].plaintext)) {\n+      printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%s.\\\"\\n\", i,\n+             array[i].cyphertext, array[i].plaintext, rv);\n+      return PR_FALSE;\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Encode, random strings */\n-PRBool\n-test_023(void)\n-{\n-    int i;\n-    char result[4096];\n+PRBool test_023(void) {\n+  int i;\n+  char result[4096];\n \n-    printf(\n-        \"Test 023 (PL_Base64Encode, random strings, strlen)                    \"\n-        \"...\");\n-    fflush(stdout);\n+  printf(\n+      \"Test 023 (PL_Base64Encode, random strings, strlen)                    \"\n+      \"...\");\n+  fflush(stdout);\n \n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRUint32 plen = PL_strlen(array[i].plaintext);\n-        PRUint32 clen = ((plen + 2) / 3) * 4;\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRUint32 plen = PL_strlen(array[i].plaintext);\n+    PRUint32 clen = ((plen + 2) / 3) * 4;\n \n-        char* rv = PL_Base64Encode(array[i].plaintext, 0, result);\n+    char* rv = PL_Base64Encode(array[i].plaintext, 0, result);\n \n-        if (rv != result) {\n-            printf(\"FAIL\\n\\t(%d): return value\\n\", i);\n-            return PR_FALSE;\n-        }\n+    if (rv != result) {\n+      printf(\"FAIL\\n\\t(%d): return value\\n\", i);\n+      return PR_FALSE;\n+    }\n \n-        if (0 != PL_strncmp(result, array[i].cyphertext, clen)) {\n-            printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%.*s.\\\"\\n\", i,\n-                   array[i].plaintext, array[i].cyphertext, clen, result);\n-            return PR_FALSE;\n-        }\n+    if (0 != PL_strncmp(result, array[i].cyphertext, clen)) {\n+      printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%.*s.\\\"\\n\", i,\n+             array[i].plaintext, array[i].cyphertext, clen, result);\n+      return PR_FALSE;\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Encode, random strings, malloc */\n-PRBool\n-test_024(void)\n-{\n-    int i;\n+PRBool test_024(void) {\n+  int i;\n \n-    printf(\n-        \"Test 024 (PL_Base64Encode, random strings, malloc, strlen)            \"\n-        \"...\");\n-    fflush(stdout);\n+  printf(\n+      \"Test 024 (PL_Base64Encode, random strings, malloc, strlen)            \"\n+      \"...\");\n+  fflush(stdout);\n \n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRUint32 plen = PL_strlen(array[i].plaintext);\n-        PRUint32 clen = ((plen + 2) / 3) * 4;\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRUint32 plen = PL_strlen(array[i].plaintext);\n+    PRUint32 clen = ((plen + 2) / 3) * 4;\n \n-        char* rv = PL_Base64Encode(array[i].plaintext, 0, (char*)0);\n-\n-        if ((char*)0 == rv) {\n-            printf(\"FAIL\\n\\t(%d): no return value\\n\", i);\n-            return PR_FALSE;\n-        }\n+    char* rv = PL_Base64Encode(array[i].plaintext, 0, (char*)0);\n \n-        if (0 != PL_strcmp(rv, array[i].cyphertext)) {\n-            printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%s.\\\"\\n\", i,\n-                   array[i].plaintext, array[i].cyphertext, rv);\n-            PR_DELETE(rv);\n-            return PR_FALSE;\n-        }\n+    if ((char*)0 == rv) {\n+      printf(\"FAIL\\n\\t(%d): no return value\\n\", i);\n+      return PR_FALSE;\n+    }\n \n-        PR_DELETE(rv);\n+    if (0 != PL_strcmp(rv, array[i].cyphertext)) {\n+      printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%s.\\\"\\n\", i,\n+             array[i].plaintext, array[i].cyphertext, rv);\n+      return PR_FALSE;\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, random strings */\n-PRBool\n-test_025(void)\n-{\n-    int i;\n-    char result[4096];\n+PRBool test_025(void) {\n+  int i;\n+  char result[4096];\n \n-    printf(\n-        \"Test 025 (PL_Base64Decode, random strings, equals, strlen)            \"\n-        \"...\");\n-    fflush(stdout);\n+  printf(\n+      \"Test 025 (PL_Base64Decode, random strings, equals, strlen)            \"\n+      \"...\");\n+  fflush(stdout);\n \n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRUint32 clen = PL_strlen(array[i].cyphertext);\n-        PRUint32 plen = (clen * 3) / 4;\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRUint32 clen = PL_strlen(array[i].cyphertext);\n+    PRUint32 plen = (clen * 3) / 4;\n \n-        char* rv = PL_Base64Decode(array[i].cyphertext, 0, result);\n+    char* rv = PL_Base64Decode(array[i].cyphertext, 0, result);\n \n-        if (rv != result) {\n-            printf(\"FAIL\\n\\t(%d): return value\\n\", i);\n-            return PR_FALSE;\n-        }\n+    if (rv != result) {\n+      printf(\"FAIL\\n\\t(%d): return value\\n\", i);\n+      return PR_FALSE;\n+    }\n \n-        if (0 == (clen & 3)) {\n-            if ('=' == array[i].cyphertext[clen - 1]) {\n-                if ('=' == array[i].cyphertext[clen - 2]) {\n-                    plen -= 2;\n-                } else {\n-                    plen -= 1;\n-                }\n-            }\n+    if (0 == (clen & 3)) {\n+      if ('=' == array[i].cyphertext[clen - 1]) {\n+        if ('=' == array[i].cyphertext[clen - 2]) {\n+          plen -= 2;\n+        } else {\n+          plen -= 1;\n         }\n+      }\n+    }\n \n-        if (0 != PL_strncmp(result, array[i].plaintext, plen)) {\n-            printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%.*s.\\\"\\n\", i,\n-                   array[i].cyphertext, array[i].plaintext, plen, result);\n-            return PR_FALSE;\n-        }\n+    if (0 != PL_strncmp(result, array[i].plaintext, plen)) {\n+      printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%.*s.\\\"\\n\", i,\n+             array[i].cyphertext, array[i].plaintext, plen, result);\n+      return PR_FALSE;\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, random strings */\n-PRBool\n-test_026(void)\n-{\n-    int i;\n-    char buffer[4096];\n-    char result[4096];\n-    char* rv;\n-\n-    printf(\n-        \"Test 026 (PL_Base64Decode, random strings, no equals, strlen)         \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRUint32 clen, plen;\n-\n-        PL_strcpy(buffer, array[i].cyphertext);\n-        clen = PL_strlen(buffer);\n-\n-        if (0 == (clen & 3)) {\n-            if ('=' == buffer[clen - 1]) {\n-                if ('=' == buffer[clen - 2]) {\n-                    buffer[clen - 2] = buffer[clen - 1] = (char)0;\n-                    clen -= 2;\n-                } else {\n-                    buffer[clen - 1] = (char)0;\n-                    clen -= 1;\n-                }\n-            }\n+PRBool test_026(void) {\n+  int i;\n+  char buffer[4096];\n+  char result[4096];\n+  char* rv;\n+\n+  printf(\n+      \"Test 026 (PL_Base64Decode, random strings, no equals, strlen)         \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRUint32 clen, plen;\n+\n+    PL_strcpy(buffer, array[i].cyphertext);\n+    clen = PL_strlen(buffer);\n+\n+    if (0 == (clen & 3)) {\n+      if ('=' == buffer[clen - 1]) {\n+        if ('=' == buffer[clen - 2]) {\n+          buffer[clen - 2] = buffer[clen - 1] = (char)0;\n+          clen -= 2;\n+        } else {\n+          buffer[clen - 1] = (char)0;\n+          clen -= 1;\n         }\n+      }\n+    }\n \n-        plen = (clen * 3) / 4;\n+    plen = (clen * 3) / 4;\n \n-        rv = PL_Base64Decode(buffer, 0, result);\n+    rv = PL_Base64Decode(buffer, 0, result);\n \n-        if (rv != result) {\n-            printf(\"FAIL\\n\\t(%d): return value\\n\", i);\n-            return PR_FALSE;\n-        }\n+    if (rv != result) {\n+      printf(\"FAIL\\n\\t(%d): return value\\n\", i);\n+      return PR_FALSE;\n+    }\n \n-        if (0 != PL_strncmp(result, array[i].plaintext, plen)) {\n-            printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%.*s.\\\"\\n\", i,\n-                   array[i].cyphertext, array[i].plaintext, plen, result);\n-            return PR_FALSE;\n-        }\n+    if (0 != PL_strncmp(result, array[i].plaintext, plen)) {\n+      printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%.*s.\\\"\\n\", i,\n+             array[i].cyphertext, array[i].plaintext, plen, result);\n+      return PR_FALSE;\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Decode, random strings, malloc */\n-PRBool\n-test_027(void)\n-{\n-    int i;\n-\n-    printf(\n-        \"Test 027 (PL_Base64Decode, random strings, equals, malloc, strlen)    \"\n-        \"...\");\n-    fflush(stdout);\n+PRBool test_027(void) {\n+  int i;\n \n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRUint32 clen = PL_strlen(array[i].cyphertext);\n+  printf(\n+      \"Test 027 (PL_Base64Decode, random strings, equals, malloc, strlen)    \"\n+      \"...\");\n+  fflush(stdout);\n \n-        char* rv = PL_Base64Decode(array[i].cyphertext, 0, (char*)0);\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRUint32 clen = PL_strlen(array[i].cyphertext);\n \n-        if ((char*)0 == rv) {\n-            printf(\"FAIL\\n\\t(%d): no return value\\n\", i);\n-            return PR_FALSE;\n-        }\n+    char* rv = PL_Base64Decode(array[i].cyphertext, 0, (char*)0);\n \n-        if (0 != PL_strcmp(rv, array[i].plaintext)) {\n-            printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%s.\\\"\\n\", i,\n-                   array[i].cyphertext, array[i].plaintext, rv);\n-            PR_DELETE(rv);\n-            return PR_FALSE;\n-        }\n+    if ((char*)0 == rv) {\n+      printf(\"FAIL\\n\\t(%d): no return value\\n\", i);\n+      return PR_FALSE;\n+    }\n \n-        PR_DELETE(rv);\n+    if (0 != PL_strcmp(rv, array[i].plaintext)) {\n+      printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%s.\\\"\\n\", i,\n+             array[i].cyphertext, array[i].plaintext, rv);\n+      PR_DELETE(rv);\n+      return PR_FALSE;\n     }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+    PR_DELETE(rv);\n+  }\n+\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_Base64Encode, random strings, malloc */\n-PRBool\n-test_028(void)\n-{\n-    int i;\n-    char buffer[4096];\n-    char* rv;\n-\n-    printf(\n-        \"Test 028 (PL_Base64Decode, random strings, no equals, malloc, strlen) \"\n-        \"...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRUint32 clen;\n-\n-        PL_strcpy(buffer, array[i].cyphertext);\n-        clen = PL_strlen(buffer);\n-\n-        if (0 == (clen & 3)) {\n-            if ('=' == buffer[clen - 1]) {\n-                if ('=' == buffer[clen - 2]) {\n-                    buffer[clen - 2] = buffer[clen - 1] = (char)0;\n-                    clen -= 2;\n-                } else {\n-                    buffer[clen - 1] = (char)0;\n-                    clen -= 1;\n-                }\n-            }\n+PRBool test_028(void) {\n+  int i;\n+  char buffer[4096];\n+  char* rv;\n+\n+  printf(\n+      \"Test 028 (PL_Base64Decode, random strings, no equals, malloc, strlen) \"\n+      \"...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRUint32 clen;\n+\n+    PL_strcpy(buffer, array[i].cyphertext);\n+    clen = PL_strlen(buffer);\n+\n+    if (0 == (clen & 3)) {\n+      if ('=' == buffer[clen - 1]) {\n+        if ('=' == buffer[clen - 2]) {\n+          buffer[clen - 2] = buffer[clen - 1] = (char)0;\n+          clen -= 2;\n+        } else {\n+          buffer[clen - 1] = (char)0;\n+          clen -= 1;\n         }\n+      }\n+    }\n \n-        rv = PL_Base64Decode(buffer, 0, (char*)0);\n-\n-        if ((char*)0 == rv) {\n-            printf(\"FAIL\\n\\t(%d): no return value\\n\", i);\n-            return PR_FALSE;\n-        }\n+    rv = PL_Base64Decode(buffer, 0, (char*)0);\n \n-        if (0 != PL_strcmp(rv, array[i].plaintext)) {\n-            printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%s.\\\"\\n\", i,\n-                   array[i].cyphertext, array[i].plaintext, rv);\n-            PR_DELETE(rv);\n-            return PR_FALSE;\n-        }\n+    if ((char*)0 == rv) {\n+      printf(\"FAIL\\n\\t(%d): no return value\\n\", i);\n+      return PR_FALSE;\n+    }\n \n-        PR_DELETE(rv);\n+    if (0 != PL_strcmp(rv, array[i].plaintext)) {\n+      printf(\"FAIL\\n\\t(%d, \\\"%s\\\"): expected \\n\\\"%s,\\\" got \\n\\\"%s.\\\"\\n\", i,\n+             array[i].cyphertext, array[i].plaintext, rv);\n+      return PR_FALSE;\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n-int\n-main(int argc, char* argv[])\n-{\n-    printf(\"Testing the Portable Library base64 functions:\\n\");\n-    printf(\"(warning: the \\\"triple characters\\\" tests are slow)\\n\");\n-\n-    if (1 && test_001() && test_002() && test_003() && test_004() && test_005() &&\n-        test_006() && test_007() && test_008() && test_009() && test_010() &&\n-        test_011() && test_012() && test_013() && test_014() && test_015() &&\n-        test_016() && test_017() && test_018() && test_019() && test_020() &&\n-        test_021() && test_022() && test_023() && test_024() && test_025() &&\n-        test_026() && test_027() && test_028()) {\n-        printf(\"Suite passed.\\n\");\n-        return 0;\n-    } else {\n-        printf(\"Suite failed.\\n\");\n-        return 1;\n-    }\n-\n-    /*NOTREACHED*/\n+int main(int argc, char* argv[]) {\n+  printf(\"Testing the Portable Library base64 functions:\\n\");\n+  printf(\"(warning: the \\\"triple characters\\\" tests are slow)\\n\");\n+\n+  if (1 && test_001() && test_002() && test_003() && test_004() && test_005() &&\n+      test_006() && test_007() && test_008() && test_009() && test_010() &&\n+      test_011() && test_012() && test_013() && test_014() && test_015() &&\n+      test_016() && test_017() && test_018() && test_019() && test_020() &&\n+      test_021() && test_022() && test_023() && test_024() && test_025() &&\n+      test_026() && test_027() && test_028()) {\n+    printf(\"Suite passed.\\n\");\n+    return 0;\n+  } else {\n+    printf(\"Suite failed.\\n\");\n+    return 1;\n+  }\n+\n+  /*NOTREACHED*/\n }\ndiff --git a/nspr/lib/tests/getopt.c b/nspr/lib/tests/getopt.c\nindex c75752a..1c0f0b4 100644\n--- a/nspr/lib/tests/getopt.c\n+++ b/nspr/lib/tests/getopt.c\n@@ -9,32 +9,30 @@\n #include \"nspr.h\"\n #include \"plgetopt.h\"\n \n-static const PLLongOpt optArray[] = { { \"longa\", 'a', PR_TRUE },\n-                                      { \"longb\", 'b', PR_TRUE },\n-                                      { \"longc\", 'c', PR_FALSE },\n-                                      { \"longd\", 'd' | 0x100, PR_TRUE },\n-                                      { \"longe\", 'e' | 0x100, PR_FALSE },\n-                                      {\n-                                          NULL,\n-                                      } };\n+static const PLLongOpt optArray[] = {{\"longa\", 'a', PR_TRUE},\n+                                     {\"longb\", 'b', PR_TRUE},\n+                                     {\"longc\", 'c', PR_FALSE},\n+                                     {\"longd\", 'd' | 0x100, PR_TRUE},\n+                                     {\"longe\", 'e' | 0x100, PR_FALSE},\n+                                     {\n+                                         NULL,\n+                                     }};\n \n-int\n-main(int argc, char** argv)\n-{\n-    PLOptState* opt;\n-    PLOptStatus ostat;\n+int main(int argc, char** argv) {\n+  PLOptState* opt;\n+  PLOptStatus ostat;\n \n-    opt = PL_CreateLongOptState(argc, argv, \"a:b:c\", optArray);\n+  opt = PL_CreateLongOptState(argc, argv, \"a:b:c\", optArray);\n \n-    while (PL_OPT_OK == (ostat = PL_GetNextOpt(opt))) {\n-        if (opt->option == 0 && opt->longOptIndex < 0) {\n-            printf(\"Positional parameter: \\\"%s\\\"\\n\", opt->value);\n-        } else\n-            printf(\"%s option: %x (\\'%c\\', index %d), argument: \\\"%s\\\"\\n\",\n-                   (ostat == PL_OPT_BAD) ? \"BAD\" : \"GOOD\", opt->longOption,\n-                   opt->option ? opt->option : ' ', opt->longOptIndex, opt->value);\n-    }\n-    printf(\"last result was %s\\n\", (ostat == PL_OPT_BAD) ? \"BAD\" : \"EOL\");\n-    PL_DestroyOptState(opt);\n-    return 0;\n+  while (PL_OPT_OK == (ostat = PL_GetNextOpt(opt))) {\n+    if (opt->option == 0 && opt->longOptIndex < 0) {\n+      printf(\"Positional parameter: \\\"%s\\\"\\n\", opt->value);\n+    } else\n+      printf(\"%s option: %x (\\'%c\\', index %d), argument: \\\"%s\\\"\\n\",\n+             (ostat == PL_OPT_BAD) ? \"BAD\" : \"GOOD\", opt->longOption,\n+             opt->option ? opt->option : ' ', opt->longOptIndex, opt->value);\n+  }\n+  printf(\"last result was %s\\n\", (ostat == PL_OPT_BAD) ? \"BAD\" : \"EOL\");\n+  PL_DestroyOptState(opt);\n+  return 0;\n }\ndiff --git a/nspr/lib/tests/string.c b/nspr/lib/tests/string.c\nindex b3f48b4..710e302 100644\n--- a/nspr/lib/tests/string.c\n+++ b/nspr/lib/tests/string.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,2827 +9,2762 @@\n #include <stdio.h>\n \n /* PL_strlen */\n-PRBool\n-test_001(void)\n-{\n-    static struct {\n-        const char* str;\n-        PRUint32 len;\n-    } array[] = { { (const char*)0, 0 },\n-                  { \"\", 0 },\n-                  { \"a\", 1 },\n-                  { \"abcdefg\", 7 },\n-                  { \"abcdefg\\0hijk\", 7 } };\n-\n-    int i;\n-\n-    printf(\"Test 001 (PL_strlen)      ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        if (PL_strlen(array[i].str) != array[i].len) {\n-            printf(\"FAIL (%d: %s->%d, %d)\\n\", i,\n-                   array[i].str ? array[i].str : \"(null)\", PL_strlen(array[i].str),\n-                   array[i].len);\n-            return PR_FALSE;\n-        }\n+PRBool test_001(void) {\n+  static struct {\n+    const char* str;\n+    PRUint32 len;\n+  } array[] = {{(const char*)0, 0},\n+               {\"\", 0},\n+               {\"a\", 1},\n+               {\"abcdefg\", 7},\n+               {\"abcdefg\\0hijk\", 7}};\n+\n+  int i;\n+\n+  printf(\"Test 001 (PL_strlen)      ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    if (PL_strlen(array[i].str) != array[i].len) {\n+      printf(\"FAIL (%d: %s->%d, %d)\\n\", i,\n+             array[i].str ? array[i].str : \"(null)\", PL_strlen(array[i].str),\n+             array[i].len);\n+      return PR_FALSE;\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strnlen */\n-PRBool\n-test_002(void)\n-{\n-    static struct {\n-        const char* str;\n-        PRUint32 max;\n-        PRUint32 len;\n-    } array[] = {\n-        { (const char*)0, 0, 0 },\n-        { (const char*)0, 12, 0 },\n-        { \"\", 0, 0 },\n-        { \"\", 12, 0 },\n-        { \"a\", 0, 0 },\n-        { \"a\", 1, 1 },\n-        { \"a\", 12, 1 },\n-        { \"abcdefg\", 0, 0 },\n-        { \"abcdefg\", 1, 1 },\n-        { \"abcdefg\", 7, 7 },\n-        { \"abcdefg\", 12, 7 },\n-        { \"abcdefg\\0hijk\", 0, 0 },\n-        { \"abcdefg\\0hijk\", 1, 1 },\n-        { \"abcdefg\\0hijk\", 7, 7 },\n-        { \"abcdefg\\0hijk\", 12, 7 },\n-    };\n-\n-    int i;\n-\n-    printf(\"Test 002 (PL_strnlen)     ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        if (PL_strnlen(array[i].str, array[i].max) != array[i].len) {\n-            printf(\"FAIL (%d: %s,%d->%d, %d)\\n\", i,\n-                   array[i].str ? array[i].str : \"(null)\", array[i].max,\n-                   PL_strnlen(array[i].str, array[i].max), array[i].len);\n-            return PR_FALSE;\n-        }\n+PRBool test_002(void) {\n+  static struct {\n+    const char* str;\n+    PRUint32 max;\n+    PRUint32 len;\n+  } array[] = {\n+      {(const char*)0, 0, 0},\n+      {(const char*)0, 12, 0},\n+      {\"\", 0, 0},\n+      {\"\", 12, 0},\n+      {\"a\", 0, 0},\n+      {\"a\", 1, 1},\n+      {\"a\", 12, 1},\n+      {\"abcdefg\", 0, 0},\n+      {\"abcdefg\", 1, 1},\n+      {\"abcdefg\", 7, 7},\n+      {\"abcdefg\", 12, 7},\n+      {\"abcdefg\\0hijk\", 0, 0},\n+      {\"abcdefg\\0hijk\", 1, 1},\n+      {\"abcdefg\\0hijk\", 7, 7},\n+      {\"abcdefg\\0hijk\", 12, 7},\n+  };\n+\n+  int i;\n+\n+  printf(\"Test 002 (PL_strnlen)     ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    if (PL_strnlen(array[i].str, array[i].max) != array[i].len) {\n+      printf(\"FAIL (%d: %s,%d->%d, %d)\\n\", i,\n+             array[i].str ? array[i].str : \"(null)\", array[i].max,\n+             PL_strnlen(array[i].str, array[i].max), array[i].len);\n+      return PR_FALSE;\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strcpy */\n-PRBool\n-test_003(void)\n-{\n-    static char buffer[1024];\n-\n-    static struct {\n-        const char* str;\n-        char* dest;\n-        char* rv;\n-        PRBool comp;\n-    } array[] = { { (const char*)0, (char*)0, (char*)0, PR_FALSE },\n-                  { (const char*)0, buffer, (char*)0, PR_FALSE },\n-                  { \"\", (char*)0, (char*)0, PR_FALSE },\n-                  { \"\", buffer, buffer, PR_TRUE },\n-                  { \"a\", (char*)0, (char*)0, PR_FALSE },\n-                  { \"a\", buffer, buffer, PR_TRUE },\n-                  { \"abcdefg\", (char*)0, (char*)0, PR_FALSE },\n-                  { \"abcdefg\", buffer, buffer, PR_TRUE },\n-                  { \"wxyz\\0abcdefg\", (char*)0, (char*)0, PR_FALSE },\n-                  { \"wxyz\\0abcdefg\", buffer, buffer, PR_TRUE } };\n-\n-    int i;\n-\n-    printf(\"Test 003 (PL_strcpy)      ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv;\n-        const char* a = array[i].str;\n-        const char* b = (const char*)array[i].dest;\n-\n-        rv = PL_strcpy(array[i].dest, array[i].str);\n-        if (array[i].rv != rv) {\n-            printf(\"FAIL %d: (0x%x, %s)->0x%x\\n\", i, array[i].dest,\n-                   array[i].str ? array[i].str : \"(null)\", rv);\n-            return PR_FALSE;\n+PRBool test_003(void) {\n+  static char buffer[1024];\n+\n+  static struct {\n+    const char* str;\n+    char* dest;\n+    char* rv;\n+    PRBool comp;\n+  } array[] = {{(const char*)0, (char*)0, (char*)0, PR_FALSE},\n+               {(const char*)0, buffer, (char*)0, PR_FALSE},\n+               {\"\", (char*)0, (char*)0, PR_FALSE},\n+               {\"\", buffer, buffer, PR_TRUE},\n+               {\"a\", (char*)0, (char*)0, PR_FALSE},\n+               {\"a\", buffer, buffer, PR_TRUE},\n+               {\"abcdefg\", (char*)0, (char*)0, PR_FALSE},\n+               {\"abcdefg\", buffer, buffer, PR_TRUE},\n+               {\"wxyz\\0abcdefg\", (char*)0, (char*)0, PR_FALSE},\n+               {\"wxyz\\0abcdefg\", buffer, buffer, PR_TRUE}};\n+\n+  int i;\n+\n+  printf(\"Test 003 (PL_strcpy)      ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv;\n+    const char* a = array[i].str;\n+    const char* b = (const char*)array[i].dest;\n+\n+    rv = PL_strcpy(array[i].dest, array[i].str);\n+    if (array[i].rv != rv) {\n+      printf(\"FAIL %d: (0x%x, %s)->0x%x\\n\", i, array[i].dest,\n+             array[i].str ? array[i].str : \"(null)\", rv);\n+      return PR_FALSE;\n+    }\n+\n+    if (array[i].comp) {\n+      while (1) {\n+        if (*a != *b) {\n+          printf(\"FAIL %d: %s->%.32s\\n\", i,\n+                 array[i].str ? array[i].str : \"(null)\",\n+                 array[i].dest ? array[i].dest : \"(null)\");\n+          return PR_FALSE;\n         }\n \n-        if (array[i].comp) {\n-            while (1) {\n-                if (*a != *b) {\n-                    printf(\"FAIL %d: %s->%.32s\\n\", i,\n-                           array[i].str ? array[i].str : \"(null)\",\n-                           array[i].dest ? array[i].dest : \"(null)\");\n-                    return PR_FALSE;\n-                }\n-\n-                if ((char)0 == *a) {\n-                    break;\n-                }\n-\n-                a++;\n-                b++;\n-            }\n+        if ((char)0 == *a) {\n+          break;\n         }\n+\n+        a++;\n+        b++;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strncpy */\n-PRBool\n-test_004(void)\n-{\n-    static char buffer[1024];\n-\n-    static struct {\n-        const char* str;\n-        PRUint32 len;\n-        char* dest;\n-        char* rv;\n-        PRBool comp;\n-        const char* result;\n-        PRBool nulled;\n-    } array[] = {\n-        { (const char*)0, 0, (char*)0, (char*)0, PR_FALSE, (const char*)0,\n-          PR_FALSE },\n-        { (const char*)0, 0, buffer, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { (const char*)0, 1, (char*)0, (char*)0, PR_FALSE, (const char*)0,\n-          PR_FALSE },\n-        { (const char*)0, 7, (char*)0, (char*)0, PR_FALSE, (const char*)0,\n-          PR_FALSE },\n-        { (const char*)0, 1, buffer, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { (const char*)0, 7, buffer, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"\", 1, buffer, buffer, PR_TRUE, \"\", PR_TRUE },\n-        { \"\", 7, buffer, buffer, PR_TRUE, \"\", PR_TRUE },\n-        { \"a\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"a\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"a\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"a\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"b\", 1, buffer, buffer, PR_TRUE, \"b\", PR_FALSE },\n-        { \"c\", 7, buffer, buffer, PR_TRUE, \"c\", PR_TRUE },\n-        { \"de\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"de\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"de\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"de\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"fg\", 1, buffer, buffer, PR_TRUE, \"f\", PR_FALSE },\n-        { \"hi\", 7, buffer, buffer, PR_TRUE, \"hi\", PR_TRUE },\n-        { \"jklmnopq\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"jklmnopq\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"jklmnopq\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"jklmnopq\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"rstuvwxy\", 1, buffer, buffer, PR_TRUE, \"r\", PR_FALSE },\n-        { \"zABCDEFG\", 7, buffer, buffer, PR_TRUE, \"zABCDEF\", PR_FALSE },\n-        { \"a\\0XXX\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"a\\0XXX\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"a\\0XXX\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"a\\0XXX\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"b\\0XXX\", 1, buffer, buffer, PR_TRUE, \"b\", PR_FALSE },\n-        { \"c\\0XXX\", 7, buffer, buffer, PR_TRUE, \"c\", PR_TRUE },\n-        { \"de\\0XXX\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"de\\0XXX\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"de\\0XXX\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"de\\0XXX\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"fg\\0XXX\", 1, buffer, buffer, PR_TRUE, \"f\", PR_FALSE },\n-        { \"hi\\0XXX\", 7, buffer, buffer, PR_TRUE, \"hi\", PR_TRUE },\n-        { \"jklmnopq\\0XXX\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0,\n-          PR_FALSE },\n-        { \"jklmnopq\\0XXX\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE },\n-        { \"jklmnopq\\0XXX\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0,\n-          PR_FALSE },\n-        { \"jklmnopq\\0XXX\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0,\n-          PR_FALSE },\n-        { \"rstuvwxy\\0XXX\", 1, buffer, buffer, PR_TRUE, \"r\", PR_FALSE },\n-        { \"zABCDEFG\\0XXX\", 7, buffer, buffer, PR_TRUE, \"zABCDEF\", PR_FALSE },\n-    };\n-\n-    int i;\n-\n-    printf(\"Test 004 (PL_strncpy)     ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv;\n-        int j;\n-\n-        for (j = 0; j < sizeof(buffer); j++) {\n-            buffer[j] = '-';\n-        }\n+PRBool test_004(void) {\n+  static char buffer[1024];\n+\n+  static struct {\n+    const char* str;\n+    PRUint32 len;\n+    char* dest;\n+    char* rv;\n+    PRBool comp;\n+    const char* result;\n+    PRBool nulled;\n+  } array[] = {\n+      {(const char*)0, 0, (char*)0, (char*)0, PR_FALSE, (const char*)0,\n+       PR_FALSE},\n+      {(const char*)0, 0, buffer, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {(const char*)0, 1, (char*)0, (char*)0, PR_FALSE, (const char*)0,\n+       PR_FALSE},\n+      {(const char*)0, 7, (char*)0, (char*)0, PR_FALSE, (const char*)0,\n+       PR_FALSE},\n+      {(const char*)0, 1, buffer, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {(const char*)0, 7, buffer, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"\", 1, buffer, buffer, PR_TRUE, \"\", PR_TRUE},\n+      {\"\", 7, buffer, buffer, PR_TRUE, \"\", PR_TRUE},\n+      {\"a\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"a\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"a\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"a\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"b\", 1, buffer, buffer, PR_TRUE, \"b\", PR_FALSE},\n+      {\"c\", 7, buffer, buffer, PR_TRUE, \"c\", PR_TRUE},\n+      {\"de\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"de\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"de\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"de\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"fg\", 1, buffer, buffer, PR_TRUE, \"f\", PR_FALSE},\n+      {\"hi\", 7, buffer, buffer, PR_TRUE, \"hi\", PR_TRUE},\n+      {\"jklmnopq\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"jklmnopq\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"jklmnopq\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"jklmnopq\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"rstuvwxy\", 1, buffer, buffer, PR_TRUE, \"r\", PR_FALSE},\n+      {\"zABCDEFG\", 7, buffer, buffer, PR_TRUE, \"zABCDEF\", PR_FALSE},\n+      {\"a\\0XXX\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"a\\0XXX\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"a\\0XXX\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"a\\0XXX\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"b\\0XXX\", 1, buffer, buffer, PR_TRUE, \"b\", PR_FALSE},\n+      {\"c\\0XXX\", 7, buffer, buffer, PR_TRUE, \"c\", PR_TRUE},\n+      {\"de\\0XXX\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"de\\0XXX\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"de\\0XXX\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"de\\0XXX\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"fg\\0XXX\", 1, buffer, buffer, PR_TRUE, \"f\", PR_FALSE},\n+      {\"hi\\0XXX\", 7, buffer, buffer, PR_TRUE, \"hi\", PR_TRUE},\n+      {\"jklmnopq\\0XXX\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0,\n+       PR_FALSE},\n+      {\"jklmnopq\\0XXX\", 0, buffer, buffer, PR_FALSE, (const char*)0, PR_FALSE},\n+      {\"jklmnopq\\0XXX\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0,\n+       PR_FALSE},\n+      {\"jklmnopq\\0XXX\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0,\n+       PR_FALSE},\n+      {\"rstuvwxy\\0XXX\", 1, buffer, buffer, PR_TRUE, \"r\", PR_FALSE},\n+      {\"zABCDEFG\\0XXX\", 7, buffer, buffer, PR_TRUE, \"zABCDEF\", PR_FALSE},\n+  };\n+\n+  int i;\n+\n+  printf(\"Test 004 (PL_strncpy)     ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv;\n+    int j;\n+\n+    for (j = 0; j < sizeof(buffer); j++) {\n+      buffer[j] = '-';\n+    }\n \n-        rv = PL_strncpy(array[i].dest, array[i].str, array[i].len);\n-        if (array[i].rv != rv) {\n-            printf(\"FAIL %d: (0x%x, %s, %lu)->0x%x\\n\", i, array[i].dest,\n-                   array[i].str ? array[i].str : \"(null)\", array[i].len, rv);\n-            return PR_FALSE;\n+    rv = PL_strncpy(array[i].dest, array[i].str, array[i].len);\n+    if (array[i].rv != rv) {\n+      printf(\"FAIL %d: (0x%x, %s, %lu)->0x%x\\n\", i, array[i].dest,\n+             array[i].str ? array[i].str : \"(null)\", array[i].len, rv);\n+      return PR_FALSE;\n+    }\n+\n+    if (array[i].comp) {\n+      const char* a = array[i].result;\n+      const char* b = array[i].dest;\n+\n+      while (*a) {\n+        if (*a != *b) {\n+          printf(\"FAIL %d: %s != %.32s\\n\", i, array[i].result, array[i].dest);\n+          return PR_FALSE;\n         }\n \n-        if (array[i].comp) {\n-            const char* a = array[i].result;\n-            const char* b = array[i].dest;\n-\n-            while (*a) {\n-                if (*a != *b) {\n-                    printf(\"FAIL %d: %s != %.32s\\n\", i, array[i].result, array[i].dest);\n-                    return PR_FALSE;\n-                }\n-\n-                a++;\n-                b++;\n-            }\n-\n-            if (array[i].nulled) {\n-                if (*b != '\\0') {\n-                    printf(\"FAIL %d: not terminated\\n\", i);\n-                    return PR_FALSE;\n-                }\n-            } else {\n-                if (*b != '-') {\n-                    printf(\"FAIL %d: overstepped\\n\", i);\n-                    return PR_FALSE;\n-                }\n-            }\n+        a++;\n+        b++;\n+      }\n+\n+      if (array[i].nulled) {\n+        if (*b != '\\0') {\n+          printf(\"FAIL %d: not terminated\\n\", i);\n+          return PR_FALSE;\n+        }\n+      } else {\n+        if (*b != '-') {\n+          printf(\"FAIL %d: overstepped\\n\", i);\n+          return PR_FALSE;\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strncpyz */\n-PRBool\n-test_005(void)\n-{\n-    static char buffer[1024];\n-\n-    static struct {\n-        const char* str;\n-        PRUint32 len;\n-        char* dest;\n-        char* rv;\n-        PRBool comp;\n-        const char* result;\n-    } array[] = {\n-        { (const char*)0, 0, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { (const char*)0, 0, buffer, (char*)0, PR_FALSE, (const char*)0 },\n-        { (const char*)0, 1, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { (const char*)0, 7, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { (const char*)0, 1, buffer, (char*)0, PR_FALSE, (const char*)0 },\n-        { (const char*)0, 7, buffer, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"\", 0, buffer, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"\", 1, buffer, buffer, PR_TRUE, \"\" },\n-        { \"\", 7, buffer, buffer, PR_TRUE, \"\" },\n-        { \"a\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"a\", 0, buffer, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"a\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"a\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"b\", 1, buffer, buffer, PR_TRUE, \"\" },\n-        { \"c\", 7, buffer, buffer, PR_TRUE, \"c\" },\n-        { \"de\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"de\", 0, buffer, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"de\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"de\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"fg\", 1, buffer, buffer, PR_TRUE, \"\" },\n-        { \"hi\", 7, buffer, buffer, PR_TRUE, \"hi\" },\n-        { \"jklmnopq\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"jklmnopq\", 0, buffer, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"jklmnopq\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"jklmnopq\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"rstuvwxy\", 1, buffer, buffer, PR_TRUE, \"\" },\n-        { \"zABCDEFG\", 7, buffer, buffer, PR_TRUE, \"zABCDE\" },\n-        { \"a\\0XXX\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"a\\0XXX\", 0, buffer, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"a\\0XXX\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"a\\0XXX\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"b\\0XXX\", 1, buffer, buffer, PR_TRUE, \"\" },\n-        { \"c\\0XXX\", 7, buffer, buffer, PR_TRUE, \"c\" },\n-        { \"de\\0XXX\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"de\\0XXX\", 0, buffer, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"de\\0XXX\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"de\\0XXX\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"fg\\0XXX\", 1, buffer, buffer, PR_TRUE, \"\" },\n-        { \"hi\\0XXX\", 7, buffer, buffer, PR_TRUE, \"hi\" },\n-        { \"jklmnopq\\0XXX\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"jklmnopq\\0XXX\", 0, buffer, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"jklmnopq\\0XXX\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"jklmnopq\\0XXX\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0 },\n-        { \"rstuvwxy\\0XXX\", 1, buffer, buffer, PR_TRUE, \"\" },\n-        { \"zABCDEFG\\0XXX\", 7, buffer, buffer, PR_TRUE, \"zABCDE\" },\n-    };\n-\n-    int i;\n-\n-    printf(\"Test 005 (PL_strncpyz)    ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv;\n-        int j;\n-\n-        for (j = 0; j < sizeof(buffer); j++) {\n-            buffer[j] = '-';\n-        }\n-\n-        rv = PL_strncpyz(array[i].dest, array[i].str, array[i].len);\n-        if (array[i].rv != rv) {\n-            printf(\"FAIL %d: (0x%x, %s, %lu)->0x%x\\n\", i, array[i].dest,\n-                   array[i].str ? array[i].str : \"(null)\", array[i].len, rv);\n-            return PR_FALSE;\n-        }\n+PRBool test_005(void) {\n+  static char buffer[1024];\n+\n+  static struct {\n+    const char* str;\n+    PRUint32 len;\n+    char* dest;\n+    char* rv;\n+    PRBool comp;\n+    const char* result;\n+  } array[] = {\n+      {(const char*)0, 0, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {(const char*)0, 0, buffer, (char*)0, PR_FALSE, (const char*)0},\n+      {(const char*)0, 1, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {(const char*)0, 7, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {(const char*)0, 1, buffer, (char*)0, PR_FALSE, (const char*)0},\n+      {(const char*)0, 7, buffer, (char*)0, PR_FALSE, (const char*)0},\n+      {\"\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"\", 0, buffer, (char*)0, PR_FALSE, (const char*)0},\n+      {\"\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"\", 1, buffer, buffer, PR_TRUE, \"\"},\n+      {\"\", 7, buffer, buffer, PR_TRUE, \"\"},\n+      {\"a\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"a\", 0, buffer, (char*)0, PR_FALSE, (const char*)0},\n+      {\"a\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"a\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"b\", 1, buffer, buffer, PR_TRUE, \"\"},\n+      {\"c\", 7, buffer, buffer, PR_TRUE, \"c\"},\n+      {\"de\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"de\", 0, buffer, (char*)0, PR_FALSE, (const char*)0},\n+      {\"de\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"de\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"fg\", 1, buffer, buffer, PR_TRUE, \"\"},\n+      {\"hi\", 7, buffer, buffer, PR_TRUE, \"hi\"},\n+      {\"jklmnopq\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"jklmnopq\", 0, buffer, (char*)0, PR_FALSE, (const char*)0},\n+      {\"jklmnopq\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"jklmnopq\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"rstuvwxy\", 1, buffer, buffer, PR_TRUE, \"\"},\n+      {\"zABCDEFG\", 7, buffer, buffer, PR_TRUE, \"zABCDE\"},\n+      {\"a\\0XXX\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"a\\0XXX\", 0, buffer, (char*)0, PR_FALSE, (const char*)0},\n+      {\"a\\0XXX\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"a\\0XXX\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"b\\0XXX\", 1, buffer, buffer, PR_TRUE, \"\"},\n+      {\"c\\0XXX\", 7, buffer, buffer, PR_TRUE, \"c\"},\n+      {\"de\\0XXX\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"de\\0XXX\", 0, buffer, (char*)0, PR_FALSE, (const char*)0},\n+      {\"de\\0XXX\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"de\\0XXX\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"fg\\0XXX\", 1, buffer, buffer, PR_TRUE, \"\"},\n+      {\"hi\\0XXX\", 7, buffer, buffer, PR_TRUE, \"hi\"},\n+      {\"jklmnopq\\0XXX\", 0, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"jklmnopq\\0XXX\", 0, buffer, (char*)0, PR_FALSE, (const char*)0},\n+      {\"jklmnopq\\0XXX\", 1, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"jklmnopq\\0XXX\", 7, (char*)0, (char*)0, PR_FALSE, (const char*)0},\n+      {\"rstuvwxy\\0XXX\", 1, buffer, buffer, PR_TRUE, \"\"},\n+      {\"zABCDEFG\\0XXX\", 7, buffer, buffer, PR_TRUE, \"zABCDE\"},\n+  };\n+\n+  int i;\n+\n+  printf(\"Test 005 (PL_strncpyz)    ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv;\n+    int j;\n+\n+    for (j = 0; j < sizeof(buffer); j++) {\n+      buffer[j] = '-';\n+    }\n \n-        if (array[i].comp) {\n-            const char* a = array[i].result;\n-            const char* b = array[i].dest;\n+    rv = PL_strncpyz(array[i].dest, array[i].str, array[i].len);\n+    if (array[i].rv != rv) {\n+      printf(\"FAIL %d: (0x%x, %s, %lu)->0x%x\\n\", i, array[i].dest,\n+             array[i].str ? array[i].str : \"(null)\", array[i].len, rv);\n+      return PR_FALSE;\n+    }\n \n-            while (1) {\n-                if (*a != *b) {\n-                    printf(\"FAIL %d: %s != %.32s\\n\", i, array[i].result, array[i].dest);\n-                    return PR_FALSE;\n-                }\n+    if (array[i].comp) {\n+      const char* a = array[i].result;\n+      const char* b = array[i].dest;\n \n-                if ((char)0 == *a) {\n-                    break;\n-                }\n+      while (1) {\n+        if (*a != *b) {\n+          printf(\"FAIL %d: %s != %.32s\\n\", i, array[i].result, array[i].dest);\n+          return PR_FALSE;\n+        }\n \n-                a++;\n-                b++;\n-            }\n+        if ((char)0 == *a) {\n+          break;\n         }\n+\n+        a++;\n+        b++;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strdup */\n-PRBool\n-test_006(void)\n-{\n-    static const char* array[] = { (const char*)0, \"\", \"a\", \"abcdefg\" };\n+PRBool test_006(void) {\n+  static const char* array[] = {(const char*)0, \"\", \"a\", \"abcdefg\"};\n \n-    int i;\n+  int i;\n \n-    printf(\"Test 006 (PL_strdup)      ...\");\n-    fflush(stdout);\n+  printf(\"Test 006 (PL_strdup)      ...\");\n+  fflush(stdout);\n \n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strdup(array[i]);\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strdup(array[i]);\n \n-        if ((char*)0 == rv) {\n-            printf(\"FAIL %d: 0x%x -> 0\\n\", i, array[i]);\n-            return PR_FALSE;\n+    if ((char*)0 == rv) {\n+      printf(\"FAIL %d: 0x%x -> 0\\n\", i, array[i]);\n+      return PR_FALSE;\n+    }\n+\n+    if ((const char*)0 == array[i]) {\n+      if ((char)0 != *rv) {\n+        printf(\"FAIL %d: (const char *)0 -> %.32s\\n\", i, rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      const char* a = array[i];\n+      const char* b = (const char*)rv;\n+\n+      while (1) {\n+        if (*a != *b) {\n+          printf(\"FAIL %d: %s != %.32s\\n\", i, array[i], rv);\n+          return PR_FALSE;\n         }\n \n-        if ((const char*)0 == array[i]) {\n-            if ((char)0 != *rv) {\n-                printf(\"FAIL %d: (const char *)0 -> %.32s\\n\", i, rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            const char* a = array[i];\n-            const char* b = (const char*)rv;\n-\n-            while (1) {\n-                if (*a != *b) {\n-                    printf(\"FAIL %d: %s != %.32s\\n\", i, array[i], rv);\n-                    return PR_FALSE;\n-                }\n-\n-                if ((char)0 == *a) {\n-                    break;\n-                }\n-\n-                a++;\n-                b++;\n-            }\n+        if ((char)0 == *a) {\n+          break;\n         }\n-        PL_strfree(rv);\n+\n+        a++;\n+        b++;\n+      }\n     }\n+    PL_strfree(rv);\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strndup */\n-PRBool\n-test_007(void)\n-{\n-    static struct {\n-        const char* str;\n-        PRUint32 len;\n-        const char* result;\n-    } array[] = { { (const char*)0, 0, \"\" },\n-                  { (const char*)0, 1, \"\" },\n-                  { (const char*)0, 7, \"\" },\n-                  { \"\", 0, \"\" },\n-                  { \"\", 1, \"\" },\n-                  { \"\", 7, \"\" },\n-                  { \"a\", 0, \"\" },\n-                  { \"a\", 1, \"a\" },\n-                  { \"a\", 7, \"a\" },\n-                  { \"ab\", 0, \"\" },\n-                  { \"ab\", 1, \"a\" },\n-                  { \"ab\", 7, \"ab\" },\n-                  { \"abcdefg\", 0, \"\" },\n-                  { \"abcdefg\", 1, \"a\" },\n-                  { \"abcdefg\", 7, \"abcdefg\" },\n-                  { \"abcdefghijk\", 0, \"\" },\n-                  { \"abcdefghijk\", 1, \"a\" },\n-                  { \"abcdefghijk\", 7, \"abcdefg\" },\n-                  { \"abcdef\\0ghijk\", 0, \"\" },\n-                  { \"abcdef\\0ghijk\", 1, \"a\" },\n-                  { \"abcdef\\0ghijk\", 7, \"abcdef\" } };\n-\n-    int i;\n-\n-    printf(\"Test 007 (PL_strndup)     ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strndup(array[i].str, array[i].len);\n-        const char* a;\n-        const char* b;\n-\n-        if ((char*)0 == rv) {\n-            printf(\"FAIL %d: %s,%lu -> 0\\n\", i,\n-                   array[i].str ? array[i].str : \"(null)\", array[i].len);\n-            return PR_FALSE;\n-        }\n-\n-        a = array[i].result;\n-        b = (const char*)rv;\n+PRBool test_007(void) {\n+  static struct {\n+    const char* str;\n+    PRUint32 len;\n+    const char* result;\n+  } array[] = {{(const char*)0, 0, \"\"},\n+               {(const char*)0, 1, \"\"},\n+               {(const char*)0, 7, \"\"},\n+               {\"\", 0, \"\"},\n+               {\"\", 1, \"\"},\n+               {\"\", 7, \"\"},\n+               {\"a\", 0, \"\"},\n+               {\"a\", 1, \"a\"},\n+               {\"a\", 7, \"a\"},\n+               {\"ab\", 0, \"\"},\n+               {\"ab\", 1, \"a\"},\n+               {\"ab\", 7, \"ab\"},\n+               {\"abcdefg\", 0, \"\"},\n+               {\"abcdefg\", 1, \"a\"},\n+               {\"abcdefg\", 7, \"abcdefg\"},\n+               {\"abcdefghijk\", 0, \"\"},\n+               {\"abcdefghijk\", 1, \"a\"},\n+               {\"abcdefghijk\", 7, \"abcdefg\"},\n+               {\"abcdef\\0ghijk\", 0, \"\"},\n+               {\"abcdef\\0ghijk\", 1, \"a\"},\n+               {\"abcdef\\0ghijk\", 7, \"abcdef\"}};\n+\n+  int i;\n+\n+  printf(\"Test 007 (PL_strndup)     ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strndup(array[i].str, array[i].len);\n+    const char* a;\n+    const char* b;\n+\n+    if ((char*)0 == rv) {\n+      printf(\"FAIL %d: %s,%lu -> 0\\n\", i,\n+             array[i].str ? array[i].str : \"(null)\", array[i].len);\n+      return PR_FALSE;\n+    }\n \n-        while (1) {\n-            if (*a != *b) {\n-                printf(\"FAIL %d: %s != %.32s\\n\", i, array[i].result, rv);\n-                return PR_FALSE;\n-            }\n+    a = array[i].result;\n+    b = (const char*)rv;\n \n-            if ((char)0 == *a) {\n-                break;\n-            }\n+    while (1) {\n+      if (*a != *b) {\n+        printf(\"FAIL %d: %s != %.32s\\n\", i, array[i].result, rv);\n+        return PR_FALSE;\n+      }\n \n-            a++;\n-            b++;\n-        }\n+      if ((char)0 == *a) {\n+        break;\n+      }\n \n-        free(rv);\n+      a++;\n+      b++;\n     }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+    free(rv);\n+  }\n+\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strcat */\n-PRBool\n-test_008(void)\n-{\n-    static struct {\n-        const char* first;\n-        const char* second;\n-        const char* result;\n-    } array[] = { { (const char*)0, (const char*)0, (const char*)0 },\n-                  { (const char*)0, \"xyz\", (const char*)0 },\n-                  { \"\", (const char*)0, \"\" },\n-                  { \"\", \"\", \"\" },\n-                  { \"ab\", \"\", \"ab\" },\n-                  { \"cd\", \"ef\", \"cdef\" },\n-                  { \"gh\\0X\", \"\", \"gh\" },\n-                  { \"ij\\0X\", \"kl\", \"ijkl\" },\n-                  { \"mn\\0X\", \"op\\0X\", \"mnop\" },\n-                  { \"qr\", \"st\\0X\", \"qrst\" },\n-                  { \"uv\\0X\", \"wx\\0X\", \"uvwx\" } };\n-\n-    int i;\n-\n-    printf(\"Test 008 (PL_strcat)      ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char buffer[1024];\n-        int j;\n-        char* rv;\n-\n-        for (j = 0; j < sizeof(buffer); j++) {\n-            buffer[j] = '-';\n-        }\n+PRBool test_008(void) {\n+  static struct {\n+    const char* first;\n+    const char* second;\n+    const char* result;\n+  } array[] = {{(const char*)0, (const char*)0, (const char*)0},\n+               {(const char*)0, \"xyz\", (const char*)0},\n+               {\"\", (const char*)0, \"\"},\n+               {\"\", \"\", \"\"},\n+               {\"ab\", \"\", \"ab\"},\n+               {\"cd\", \"ef\", \"cdef\"},\n+               {\"gh\\0X\", \"\", \"gh\"},\n+               {\"ij\\0X\", \"kl\", \"ijkl\"},\n+               {\"mn\\0X\", \"op\\0X\", \"mnop\"},\n+               {\"qr\", \"st\\0X\", \"qrst\"},\n+               {\"uv\\0X\", \"wx\\0X\", \"uvwx\"}};\n+\n+  int i;\n+\n+  printf(\"Test 008 (PL_strcat)      ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char buffer[1024];\n+    int j;\n+    char* rv;\n+\n+    for (j = 0; j < sizeof(buffer); j++) {\n+      buffer[j] = '-';\n+    }\n \n-        if ((const char*)0 != array[i].first) {\n-            (void)PL_strcpy(buffer, array[i].first);\n-        }\n+    if ((const char*)0 != array[i].first) {\n+      (void)PL_strcpy(buffer, array[i].first);\n+    }\n \n-        rv = PL_strcat(((const char*)0 == array[i].first) ? (char*)0 : buffer,\n-                       array[i].second);\n+    rv = PL_strcat(((const char*)0 == array[i].first) ? (char*)0 : buffer,\n+                   array[i].second);\n \n-        if ((const char*)0 == array[i].result) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s+%s -> %.32s, not zero\\n\", i,\n-                       array[i].first ? array[i].first : \"(null)\",\n-                       array[i].second ? array[i].second : \"(null)\", rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s+%s -> null, not %s\\n\", i,\n-                       array[i].first ? array[i].first : \"(null)\",\n-                       array[i].second ? array[i].second : \"(null)\", array[i].result);\n-                return PR_FALSE;\n-            } else {\n-                const char* a = array[i].result;\n-                const char* b = (const char*)rv;\n-\n-                while (1) {\n-                    if (*a != *b) {\n-                        printf(\"FAIL %d: %s+%s -> %.32s, not %s\\n\", i,\n-                               array[i].first ? array[i].first : \"(null)\",\n-                               array[i].second ? array[i].second : \"(null)\", rv,\n-                               array[i].result);\n-                        return PR_FALSE;\n-                    }\n-\n-                    if ((char)0 == *a) {\n-                        break;\n-                    }\n-\n-                    a++;\n-                    b++;\n-                }\n-            }\n+    if ((const char*)0 == array[i].result) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s+%s -> %.32s, not zero\\n\", i,\n+               array[i].first ? array[i].first : \"(null)\",\n+               array[i].second ? array[i].second : \"(null)\", rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s+%s -> null, not %s\\n\", i,\n+               array[i].first ? array[i].first : \"(null)\",\n+               array[i].second ? array[i].second : \"(null)\", array[i].result);\n+        return PR_FALSE;\n+      } else {\n+        const char* a = array[i].result;\n+        const char* b = (const char*)rv;\n+\n+        while (1) {\n+          if (*a != *b) {\n+            printf(\"FAIL %d: %s+%s -> %.32s, not %s\\n\", i,\n+                   array[i].first ? array[i].first : \"(null)\",\n+                   array[i].second ? array[i].second : \"(null)\", rv,\n+                   array[i].result);\n+            return PR_FALSE;\n+          }\n+\n+          if ((char)0 == *a) {\n+            break;\n+          }\n+\n+          a++;\n+          b++;\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strncat */\n-PRBool\n-test_009(void)\n-{\n-    static struct {\n-        const char* first;\n-        const char* second;\n-        PRUint32 length;\n-        PRBool nulled;\n-        const char* result;\n-    } array[] = { { (const char*)0, (const char*)0, 0, PR_FALSE, (const char*)0 },\n-                  { (const char*)0, (const char*)0, 1, PR_FALSE, (const char*)0 },\n-                  { (const char*)0, (const char*)0, 7, PR_FALSE, (const char*)0 },\n-                  { (const char*)0, \"\", 0, PR_FALSE, (const char*)0 },\n-                  { (const char*)0, \"\", 1, PR_FALSE, (const char*)0 },\n-                  { (const char*)0, \"\", 7, PR_FALSE, (const char*)0 },\n-                  { (const char*)0, \"stuff\", 0, PR_FALSE, (const char*)0 },\n-                  { (const char*)0, \"stuff\", 1, PR_FALSE, (const char*)0 },\n-                  { (const char*)0, \"stuff\", 7, PR_FALSE, (const char*)0 },\n-                  { \"\", (const char*)0, 0, PR_TRUE, \"\" },\n-                  { \"\", (const char*)0, 1, PR_TRUE, \"\" },\n-                  { \"\", (const char*)0, 7, PR_TRUE, \"\" },\n-                  { \"\", \"\", 0, PR_TRUE, \"\" },\n-                  { \"\", \"\", 1, PR_TRUE, \"\" },\n-                  { \"\", \"\", 7, PR_TRUE, \"\" },\n-                  { \"\", \"abcdefgh\", 0, PR_TRUE, \"\" },\n-                  { \"\", \"abcdefgh\", 1, PR_FALSE, \"a\" },\n-                  { \"\", \"abcdefgh\", 7, PR_FALSE, \"abcdefg\" },\n-                  { \"xyz\", (const char*)0, 0, PR_TRUE, \"xyz\" },\n-                  { \"xyz\", (const char*)0, 1, PR_TRUE, \"xyz\" },\n-                  { \"xyz\", (const char*)0, 7, PR_TRUE, \"xyz\" },\n-                  { \"xyz\", \"\", 0, PR_TRUE, \"xyz\" },\n-                  { \"xyz\", \"\", 1, PR_TRUE, \"xyz\" },\n-                  { \"xyz\", \"\", 7, PR_TRUE, \"xyz\" },\n-                  { \"xyz\", \"abcdefgh\", 0, PR_TRUE, \"xyz\" },\n-                  { \"xyz\", \"abcdefgh\", 1, PR_FALSE, \"xyza\" },\n-                  { \"xyz\", \"abcdefgh\", 7, PR_FALSE, \"xyzabcdefg\" } };\n-\n-    int i;\n-\n-    printf(\"Test 009 (PL_strncat)     ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char buffer[1024];\n-        int j;\n-        char* rv;\n-\n-        for (j = 0; j < sizeof(buffer); j++) {\n-            buffer[j] = '-';\n-        }\n+PRBool test_009(void) {\n+  static struct {\n+    const char* first;\n+    const char* second;\n+    PRUint32 length;\n+    PRBool nulled;\n+    const char* result;\n+  } array[] = {{(const char*)0, (const char*)0, 0, PR_FALSE, (const char*)0},\n+               {(const char*)0, (const char*)0, 1, PR_FALSE, (const char*)0},\n+               {(const char*)0, (const char*)0, 7, PR_FALSE, (const char*)0},\n+               {(const char*)0, \"\", 0, PR_FALSE, (const char*)0},\n+               {(const char*)0, \"\", 1, PR_FALSE, (const char*)0},\n+               {(const char*)0, \"\", 7, PR_FALSE, (const char*)0},\n+               {(const char*)0, \"stuff\", 0, PR_FALSE, (const char*)0},\n+               {(const char*)0, \"stuff\", 1, PR_FALSE, (const char*)0},\n+               {(const char*)0, \"stuff\", 7, PR_FALSE, (const char*)0},\n+               {\"\", (const char*)0, 0, PR_TRUE, \"\"},\n+               {\"\", (const char*)0, 1, PR_TRUE, \"\"},\n+               {\"\", (const char*)0, 7, PR_TRUE, \"\"},\n+               {\"\", \"\", 0, PR_TRUE, \"\"},\n+               {\"\", \"\", 1, PR_TRUE, \"\"},\n+               {\"\", \"\", 7, PR_TRUE, \"\"},\n+               {\"\", \"abcdefgh\", 0, PR_TRUE, \"\"},\n+               {\"\", \"abcdefgh\", 1, PR_FALSE, \"a\"},\n+               {\"\", \"abcdefgh\", 7, PR_FALSE, \"abcdefg\"},\n+               {\"xyz\", (const char*)0, 0, PR_TRUE, \"xyz\"},\n+               {\"xyz\", (const char*)0, 1, PR_TRUE, \"xyz\"},\n+               {\"xyz\", (const char*)0, 7, PR_TRUE, \"xyz\"},\n+               {\"xyz\", \"\", 0, PR_TRUE, \"xyz\"},\n+               {\"xyz\", \"\", 1, PR_TRUE, \"xyz\"},\n+               {\"xyz\", \"\", 7, PR_TRUE, \"xyz\"},\n+               {\"xyz\", \"abcdefgh\", 0, PR_TRUE, \"xyz\"},\n+               {\"xyz\", \"abcdefgh\", 1, PR_FALSE, \"xyza\"},\n+               {\"xyz\", \"abcdefgh\", 7, PR_FALSE, \"xyzabcdefg\"}};\n+\n+  int i;\n+\n+  printf(\"Test 009 (PL_strncat)     ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char buffer[1024];\n+    int j;\n+    char* rv;\n+\n+    for (j = 0; j < sizeof(buffer); j++) {\n+      buffer[j] = '-';\n+    }\n \n-        if ((const char*)0 != array[i].first) {\n-            (void)PL_strcpy(buffer, array[i].first);\n+    if ((const char*)0 != array[i].first) {\n+      (void)PL_strcpy(buffer, array[i].first);\n+    }\n+\n+    rv = PL_strncat(((const char*)0 == array[i].first) ? (char*)0 : buffer,\n+                    array[i].second, array[i].length);\n+\n+    if ((const char*)0 == array[i].result) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s+%s/%lu -> %.32s, not zero\\n\", i,\n+               array[i].first ? array[i].first : \"(null)\",\n+               array[i].second ? array[i].second : \"(null)\", array[i].length,\n+               rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s+%s/%lu -> null, not %s\\n\", i,\n+               array[i].first ? array[i].first : \"(null)\",\n+               array[i].second ? array[i].second : \"(null)\", array[i].length,\n+               array[i].result);\n+        return PR_FALSE;\n+      } else {\n+        const char* a = array[i].result;\n+        const char* b = (const char*)rv;\n+\n+        while (*a) {\n+          if (*a != *b) {\n+            printf(\"FAIL %d: %s+%s/%lu -> %.32s, not %s\\n\", i,\n+                   array[i].first ? array[i].first : \"(null)\",\n+                   array[i].second ? array[i].second : \"(null)\",\n+                   array[i].length, rv, array[i].result);\n+            return PR_FALSE;\n+          }\n+\n+          a++;\n+          b++;\n         }\n \n-        rv = PL_strncat(((const char*)0 == array[i].first) ? (char*)0 : buffer,\n-                        array[i].second, array[i].length);\n-\n-        if ((const char*)0 == array[i].result) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s+%s/%lu -> %.32s, not zero\\n\", i,\n-                       array[i].first ? array[i].first : \"(null)\",\n-                       array[i].second ? array[i].second : \"(null)\", array[i].length,\n-                       rv);\n-                return PR_FALSE;\n-            }\n+        if (array[i].nulled) {\n+          if ((char)0 != *b) {\n+            printf(\"FAIL %d: %s+%s/%lu -> not nulled\\n\", i,\n+                   array[i].first ? array[i].first : \"(null)\",\n+                   array[i].second ? array[i].second : \"(null)\",\n+                   array[i].length);\n+            return PR_FALSE;\n+          }\n         } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s+%s/%lu -> null, not %s\\n\", i,\n-                       array[i].first ? array[i].first : \"(null)\",\n-                       array[i].second ? array[i].second : \"(null)\", array[i].length,\n-                       array[i].result);\n-                return PR_FALSE;\n-            } else {\n-                const char* a = array[i].result;\n-                const char* b = (const char*)rv;\n-\n-                while (*a) {\n-                    if (*a != *b) {\n-                        printf(\"FAIL %d: %s+%s/%lu -> %.32s, not %s\\n\", i,\n-                               array[i].first ? array[i].first : \"(null)\",\n-                               array[i].second ? array[i].second : \"(null)\",\n-                               array[i].length, rv, array[i].result);\n-                        return PR_FALSE;\n-                    }\n-\n-                    a++;\n-                    b++;\n-                }\n-\n-                if (array[i].nulled) {\n-                    if ((char)0 != *b) {\n-                        printf(\"FAIL %d: %s+%s/%lu -> not nulled\\n\", i,\n-                               array[i].first ? array[i].first : \"(null)\",\n-                               array[i].second ? array[i].second : \"(null)\",\n-                               array[i].length);\n-                        return PR_FALSE;\n-                    }\n-                } else {\n-                    if ((char)0 == *b) {\n-                        printf(\"FAIL %d: %s+%s/%lu -> overrun\\n\", i,\n-                               array[i].first ? array[i].first : \"(null)\",\n-                               array[i].second ? array[i].second : \"(null)\",\n-                               array[i].length);\n-                        return PR_FALSE;\n-                    }\n-                }\n-            }\n+          if ((char)0 == *b) {\n+            printf(\"FAIL %d: %s+%s/%lu -> overrun\\n\", i,\n+                   array[i].first ? array[i].first : \"(null)\",\n+                   array[i].second ? array[i].second : \"(null)\",\n+                   array[i].length);\n+            return PR_FALSE;\n+          }\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strcatn */\n-PRBool\n-test_010(void)\n-{\n-    static struct {\n-        const char* first;\n-        const char* second;\n-        PRUint32 length;\n-        const char* result;\n-    } array[] = { { (const char*)0, (const char*)0, 0, (const char*)0 },\n-                  { (const char*)0, (const char*)0, 1, (const char*)0 },\n-                  { (const char*)0, (const char*)0, 7, (const char*)0 },\n-                  { (const char*)0, \"\", 0, (const char*)0 },\n-                  { (const char*)0, \"\", 1, (const char*)0 },\n-                  { (const char*)0, \"\", 7, (const char*)0 },\n-                  { (const char*)0, \"stuff\", 0, (const char*)0 },\n-                  { (const char*)0, \"stuff\", 1, (const char*)0 },\n-                  { (const char*)0, \"stuff\", 7, (const char*)0 },\n-                  { \"\", (const char*)0, 0, \"\" },\n-                  { \"\", (const char*)0, 1, \"\" },\n-                  { \"\", (const char*)0, 7, \"\" },\n-                  { \"\", \"\", 0, \"\" },\n-                  { \"\", \"\", 1, \"\" },\n-                  { \"\", \"\", 7, \"\" },\n-                  { \"\", \"abcdefgh\", 0, \"\" },\n-                  { \"\", \"abcdefgh\", 1, \"\" },\n-                  { \"\", \"abcdefgh\", 7, \"abcdef\" },\n-                  { \"xyz\", (const char*)0, 0, \"xyz\" },\n-                  { \"xyz\", (const char*)0, 1, \"xyz\" },\n-                  { \"xyz\", (const char*)0, 7, \"xyz\" },\n-                  { \"xyz\", \"\", 0, \"xyz\" },\n-                  { \"xyz\", \"\", 1, \"xyz\" },\n-                  { \"xyz\", \"\", 7, \"xyz\" },\n-                  { \"xyz\", \"abcdefgh\", 0, \"xyz\" },\n-                  { \"xyz\", \"abcdefgh\", 1, \"xyz\" },\n-                  { \"xyz\", \"abcdefgh\", 7, \"xyzabc\" } };\n-\n-    int i;\n-\n-    printf(\"Test 010 (PL_strcatn)     ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char buffer[1024];\n-        int j;\n-        char* rv;\n-\n-        for (j = 0; j < sizeof(buffer); j++) {\n-            buffer[j] = '-';\n-        }\n+PRBool test_010(void) {\n+  static struct {\n+    const char* first;\n+    const char* second;\n+    PRUint32 length;\n+    const char* result;\n+  } array[] = {{(const char*)0, (const char*)0, 0, (const char*)0},\n+               {(const char*)0, (const char*)0, 1, (const char*)0},\n+               {(const char*)0, (const char*)0, 7, (const char*)0},\n+               {(const char*)0, \"\", 0, (const char*)0},\n+               {(const char*)0, \"\", 1, (const char*)0},\n+               {(const char*)0, \"\", 7, (const char*)0},\n+               {(const char*)0, \"stuff\", 0, (const char*)0},\n+               {(const char*)0, \"stuff\", 1, (const char*)0},\n+               {(const char*)0, \"stuff\", 7, (const char*)0},\n+               {\"\", (const char*)0, 0, \"\"},\n+               {\"\", (const char*)0, 1, \"\"},\n+               {\"\", (const char*)0, 7, \"\"},\n+               {\"\", \"\", 0, \"\"},\n+               {\"\", \"\", 1, \"\"},\n+               {\"\", \"\", 7, \"\"},\n+               {\"\", \"abcdefgh\", 0, \"\"},\n+               {\"\", \"abcdefgh\", 1, \"\"},\n+               {\"\", \"abcdefgh\", 7, \"abcdef\"},\n+               {\"xyz\", (const char*)0, 0, \"xyz\"},\n+               {\"xyz\", (const char*)0, 1, \"xyz\"},\n+               {\"xyz\", (const char*)0, 7, \"xyz\"},\n+               {\"xyz\", \"\", 0, \"xyz\"},\n+               {\"xyz\", \"\", 1, \"xyz\"},\n+               {\"xyz\", \"\", 7, \"xyz\"},\n+               {\"xyz\", \"abcdefgh\", 0, \"xyz\"},\n+               {\"xyz\", \"abcdefgh\", 1, \"xyz\"},\n+               {\"xyz\", \"abcdefgh\", 7, \"xyzabc\"}};\n+\n+  int i;\n+\n+  printf(\"Test 010 (PL_strcatn)     ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char buffer[1024];\n+    int j;\n+    char* rv;\n+\n+    for (j = 0; j < sizeof(buffer); j++) {\n+      buffer[j] = '-';\n+    }\n \n-        if ((const char*)0 != array[i].first) {\n-            (void)PL_strcpy(buffer, array[i].first);\n-        }\n+    if ((const char*)0 != array[i].first) {\n+      (void)PL_strcpy(buffer, array[i].first);\n+    }\n \n-        rv = PL_strcatn(((const char*)0 == array[i].first) ? (char*)0 : buffer,\n-                        array[i].length, array[i].second);\n-\n-        if ((const char*)0 == array[i].result) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s+%s/%lu -> %.32s, not zero\\n\", i,\n-                       array[i].first ? array[i].first : \"(null)\",\n-                       array[i].second ? array[i].second : \"(null)\", array[i].length,\n-                       rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s+%s/%lu -> null, not %s\\n\", i,\n-                       array[i].first ? array[i].first : \"(null)\",\n-                       array[i].second ? array[i].second : \"(null)\", array[i].length,\n-                       array[i].result);\n-                return PR_FALSE;\n-            } else {\n-                const char* a = array[i].result;\n-                const char* b = (const char*)rv;\n-\n-                while (1) {\n-                    if (*a != *b) {\n-                        printf(\"FAIL %d: %s+%s/%lu -> %.32s, not %s\\n\", i,\n-                               array[i].first ? array[i].first : \"(null)\",\n-                               array[i].second ? array[i].second : \"(null)\",\n-                               array[i].length, rv, array[i].result);\n-                        return PR_FALSE;\n-                    }\n-\n-                    if ((char)0 == *a) {\n-                        break;\n-                    }\n-\n-                    a++;\n-                    b++;\n-                }\n-            }\n+    rv = PL_strcatn(((const char*)0 == array[i].first) ? (char*)0 : buffer,\n+                    array[i].length, array[i].second);\n+\n+    if ((const char*)0 == array[i].result) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s+%s/%lu -> %.32s, not zero\\n\", i,\n+               array[i].first ? array[i].first : \"(null)\",\n+               array[i].second ? array[i].second : \"(null)\", array[i].length,\n+               rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s+%s/%lu -> null, not %s\\n\", i,\n+               array[i].first ? array[i].first : \"(null)\",\n+               array[i].second ? array[i].second : \"(null)\", array[i].length,\n+               array[i].result);\n+        return PR_FALSE;\n+      } else {\n+        const char* a = array[i].result;\n+        const char* b = (const char*)rv;\n+\n+        while (1) {\n+          if (*a != *b) {\n+            printf(\"FAIL %d: %s+%s/%lu -> %.32s, not %s\\n\", i,\n+                   array[i].first ? array[i].first : \"(null)\",\n+                   array[i].second ? array[i].second : \"(null)\",\n+                   array[i].length, rv, array[i].result);\n+            return PR_FALSE;\n+          }\n+\n+          if ((char)0 == *a) {\n+            break;\n+          }\n+\n+          a++;\n+          b++;\n         }\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strcmp */\n-PRBool\n-test_011(void)\n-{\n-    static struct {\n-        const char* one;\n-        const char* two;\n-        PRIntn sign;\n-    } array[] = { { (const char*)0, (const char*)0, 0 },\n-                  { (const char*)0, \"word\", -1 },\n-                  { \"word\", (const char*)0, 1 },\n-                  { \"word\", \"word\", 0 },\n-                  { \"aZYXVUT\", \"bZYXVUT\", -1 },\n-                  { \"aZYXVUT\", \"bAAAAAA\", -1 },\n-                  { \"a\", \"aa\", -1 },\n-                  { \"a\", \"a\", 0 },\n-                  { \"a\", \"A\", 1 },\n-                  { \"aaaaa\", \"baaaa\", -1 },\n-                  { \"aaaaa\", \"abaaa\", -1 },\n-                  { \"aaaaa\", \"aabaa\", -1 },\n-                  { \"aaaaa\", \"aaaba\", -1 },\n-                  { \"aaaaa\", \"aaaab\", -1 },\n-                  { \"bZYXVUT\", \"aZYXVUT\", 1 },\n-                  { \"bAAAAAA\", \"aZYXVUT\", 1 },\n-                  { \"aa\", \"a\", 1 },\n-                  { \"A\", \"a\", -1 },\n-                  { \"baaaa\", \"aaaaa\", 1 },\n-                  { \"abaaa\", \"aaaaa\", 1 },\n-                  { \"aabaa\", \"aaaaa\", 1 },\n-                  { \"aaaba\", \"aaaaa\", 1 },\n-                  { \"aaaab\", \"aaaaa\", 1 },\n-                  { \"word\", \"Word\", 1 },\n-                  { \"word\", \"wOrd\", 1 },\n-                  { \"word\", \"woRd\", 1 },\n-                  { \"word\", \"worD\", 1 },\n-                  { \"WORD\", \"wORD\", -1 },\n-                  { \"WORD\", \"WoRD\", -1 },\n-                  { \"WORD\", \"WOrD\", -1 },\n-                  { \"WORD\", \"WORd\", -1 } };\n-\n-    int i;\n-\n-    printf(\"Test 011 (PL_strcmp)      ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRIntn rv = PL_strcmp(array[i].one, array[i].two);\n-\n-        switch (array[i].sign) {\n-            case -1:\n-                if (rv < 0) {\n-                    continue;\n-                }\n-                break;\n-            case 1:\n-                if (rv > 0) {\n-                    continue;\n-                }\n-                break;\n-            case 0:\n-                if (0 == rv) {\n-                    continue;\n-                }\n-                break;\n-            default:\n-                PR_NOT_REACHED(\"static data inconsistancy\");\n-                break;\n+PRBool test_011(void) {\n+  static struct {\n+    const char* one;\n+    const char* two;\n+    PRIntn sign;\n+  } array[] = {{(const char*)0, (const char*)0, 0},\n+               {(const char*)0, \"word\", -1},\n+               {\"word\", (const char*)0, 1},\n+               {\"word\", \"word\", 0},\n+               {\"aZYXVUT\", \"bZYXVUT\", -1},\n+               {\"aZYXVUT\", \"bAAAAAA\", -1},\n+               {\"a\", \"aa\", -1},\n+               {\"a\", \"a\", 0},\n+               {\"a\", \"A\", 1},\n+               {\"aaaaa\", \"baaaa\", -1},\n+               {\"aaaaa\", \"abaaa\", -1},\n+               {\"aaaaa\", \"aabaa\", -1},\n+               {\"aaaaa\", \"aaaba\", -1},\n+               {\"aaaaa\", \"aaaab\", -1},\n+               {\"bZYXVUT\", \"aZYXVUT\", 1},\n+               {\"bAAAAAA\", \"aZYXVUT\", 1},\n+               {\"aa\", \"a\", 1},\n+               {\"A\", \"a\", -1},\n+               {\"baaaa\", \"aaaaa\", 1},\n+               {\"abaaa\", \"aaaaa\", 1},\n+               {\"aabaa\", \"aaaaa\", 1},\n+               {\"aaaba\", \"aaaaa\", 1},\n+               {\"aaaab\", \"aaaaa\", 1},\n+               {\"word\", \"Word\", 1},\n+               {\"word\", \"wOrd\", 1},\n+               {\"word\", \"woRd\", 1},\n+               {\"word\", \"worD\", 1},\n+               {\"WORD\", \"wORD\", -1},\n+               {\"WORD\", \"WoRD\", -1},\n+               {\"WORD\", \"WOrD\", -1},\n+               {\"WORD\", \"WORd\", -1}};\n+\n+  int i;\n+\n+  printf(\"Test 011 (PL_strcmp)      ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRIntn rv = PL_strcmp(array[i].one, array[i].two);\n+\n+    switch (array[i].sign) {\n+      case -1:\n+        if (rv < 0) {\n+          continue;\n         }\n-\n-        printf(\"FAIL %d: %s-%s -> %d, not %d\\n\", i,\n-               array[i].one ? array[i].one : \"(null)\",\n-               array[i].two ? array[i].two : \"(null)\", rv, array[i].sign);\n-        return PR_FALSE;\n+        break;\n+      case 1:\n+        if (rv > 0) {\n+          continue;\n+        }\n+        break;\n+      case 0:\n+        if (0 == rv) {\n+          continue;\n+        }\n+        break;\n+      default:\n+        PR_NOT_REACHED(\"static data inconsistancy\");\n+        break;\n     }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+    printf(\"FAIL %d: %s-%s -> %d, not %d\\n\", i,\n+           array[i].one ? array[i].one : \"(null)\",\n+           array[i].two ? array[i].two : \"(null)\", rv, array[i].sign);\n+    return PR_FALSE;\n+  }\n+\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strncmp */\n-PRBool\n-test_012(void)\n-{\n-    static struct {\n-        const char* one;\n-        const char* two;\n-        PRUint32 max;\n-        PRIntn sign;\n-    } array[] = { { (const char*)0, (const char*)0, 0, 0 },\n-                  { (const char*)0, (const char*)0, 1, 0 },\n-                  { (const char*)0, (const char*)0, 4, 0 },\n-                  { (const char*)0, \"word\", 0, -1 },\n-                  { (const char*)0, \"word\", 1, -1 },\n-                  { (const char*)0, \"word\", 4, -1 },\n-                  { \"word\", (const char*)0, 0, 1 },\n-                  { \"word\", (const char*)0, 1, 1 },\n-                  { \"word\", (const char*)0, 4, 1 },\n-                  { \"word\", \"word\", 0, 0 },\n-                  { \"word\", \"word\", 1, 0 },\n-                  { \"word\", \"word\", 3, 0 },\n-                  { \"word\", \"word\", 5, 0 },\n-                  { \"aZYXVUT\", \"bZYXVUT\", 0, 0 },\n-                  { \"aZYXVUT\", \"bZYXVUT\", 1, -1 },\n-                  { \"aZYXVUT\", \"bZYXVUT\", 4, -1 },\n-                  { \"aZYXVUT\", \"bZYXVUT\", 9, -1 },\n-                  { \"aZYXVUT\", \"bAAAAAA\", 0, 0 },\n-                  { \"aZYXVUT\", \"bAAAAAA\", 1, -1 },\n-                  { \"aZYXVUT\", \"bAAAAAA\", 4, -1 },\n-                  { \"aZYXVUT\", \"bAAAAAA\", 5, -1 },\n-                  { \"a\", \"aa\", 0, 0 },\n-                  { \"a\", \"aa\", 1, 0 },\n-                  { \"a\", \"aa\", 4, -1 },\n-                  { \"a\", \"a\", 0, 0 },\n-                  { \"a\", \"a\", 1, 0 },\n-                  { \"a\", \"a\", 4, 0 },\n-                  { \"a\", \"A\", 0, 0 },\n-                  { \"a\", \"A\", 1, 1 },\n-                  { \"a\", \"A\", 4, 1 },\n-                  { \"aaaaa\", \"baaaa\", 0, 0 },\n-                  { \"aaaaa\", \"baaaa\", 1, -1 },\n-                  { \"aaaaa\", \"baaaa\", 4, -1 },\n-                  { \"aaaaa\", \"abaaa\", 0, 0 },\n-                  { \"aaaaa\", \"abaaa\", 1, 0 },\n-                  { \"aaaaa\", \"abaaa\", 4, -1 },\n-                  { \"aaaaa\", \"aabaa\", 0, 0 },\n-                  { \"aaaaa\", \"aabaa\", 1, 0 },\n-                  { \"aaaaa\", \"aabaa\", 4, -1 },\n-                  { \"aaaaa\", \"aaaba\", 0, 0 },\n-                  { \"aaaaa\", \"aaaba\", 1, 0 },\n-                  { \"aaaaa\", \"aaaba\", 4, -1 },\n-                  { \"aaaaa\", \"aaaab\", 0, 0 },\n-                  { \"aaaaa\", \"aaaab\", 1, 0 },\n-                  { \"aaaaa\", \"aaaab\", 4, 0 },\n-                  { \"bZYXVUT\", \"aZYXVUT\", 0, 0 },\n-                  { \"bZYXVUT\", \"aZYXVUT\", 1, 1 },\n-                  { \"bZYXVUT\", \"aZYXVUT\", 4, 1 },\n-                  { \"bAAAAAA\", \"aZYXVUT\", 0, 0 },\n-                  { \"bAAAAAA\", \"aZYXVUT\", 1, 1 },\n-                  { \"bAAAAAA\", \"aZYXVUT\", 4, 1 },\n-                  { \"aa\", \"a\", 0, 0 },\n-                  { \"aa\", \"a\", 1, 0 },\n-                  { \"aa\", \"a\", 4, 1 },\n-                  { \"A\", \"a\", 0, 0 },\n-                  { \"A\", \"a\", 1, -1 },\n-                  { \"A\", \"a\", 4, -1 },\n-                  { \"baaaa\", \"aaaaa\", 0, 0 },\n-                  { \"baaaa\", \"aaaaa\", 1, 1 },\n-                  { \"baaaa\", \"aaaaa\", 4, 1 },\n-                  { \"abaaa\", \"aaaaa\", 0, 0 },\n-                  { \"abaaa\", \"aaaaa\", 1, 0 },\n-                  { \"abaaa\", \"aaaaa\", 4, 1 },\n-                  { \"aabaa\", \"aaaaa\", 0, 0 },\n-                  { \"aabaa\", \"aaaaa\", 1, 0 },\n-                  { \"aabaa\", \"aaaaa\", 4, 1 },\n-                  { \"aaaba\", \"aaaaa\", 0, 0 },\n-                  { \"aaaba\", \"aaaaa\", 1, 0 },\n-                  { \"aaaba\", \"aaaaa\", 4, 1 },\n-                  { \"aaaab\", \"aaaaa\", 0, 0 },\n-                  { \"aaaab\", \"aaaaa\", 1, 0 },\n-                  { \"aaaab\", \"aaaaa\", 4, 0 },\n-                  { \"word\", \"Word\", 0, 0 },\n-                  { \"word\", \"Word\", 1, 1 },\n-                  { \"word\", \"Word\", 3, 1 },\n-                  { \"word\", \"wOrd\", 0, 0 },\n-                  { \"word\", \"wOrd\", 1, 0 },\n-                  { \"word\", \"wOrd\", 3, 1 },\n-                  { \"word\", \"woRd\", 0, 0 },\n-                  { \"word\", \"woRd\", 1, 0 },\n-                  { \"word\", \"woRd\", 3, 1 },\n-                  { \"word\", \"worD\", 0, 0 },\n-                  { \"word\", \"worD\", 1, 0 },\n-                  { \"word\", \"worD\", 3, 0 },\n-                  { \"WORD\", \"wORD\", 0, 0 },\n-                  { \"WORD\", \"wORD\", 1, -1 },\n-                  { \"WORD\", \"wORD\", 3, -1 },\n-                  { \"WORD\", \"WoRD\", 0, 0 },\n-                  { \"WORD\", \"WoRD\", 1, 0 },\n-                  { \"WORD\", \"WoRD\", 3, -1 },\n-                  { \"WORD\", \"WOrD\", 0, 0 },\n-                  { \"WORD\", \"WOrD\", 1, 0 },\n-                  { \"WORD\", \"WOrD\", 3, -1 },\n-                  { \"WORD\", \"WORd\", 0, 0 },\n-                  { \"WORD\", \"WORd\", 1, 0 },\n-                  { \"WORD\", \"WORd\", 3, 0 }\n-\n-    };\n-\n-    int i;\n-\n-    printf(\"Test 012 (PL_strncmp)     ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRIntn rv = PL_strncmp(array[i].one, array[i].two, array[i].max);\n-\n-        switch (array[i].sign) {\n-            case -1:\n-                if (rv < 0) {\n-                    continue;\n-                }\n-                break;\n-            case 1:\n-                if (rv > 0) {\n-                    continue;\n-                }\n-                break;\n-            case 0:\n-                if (0 == rv) {\n-                    continue;\n-                }\n-                break;\n-            default:\n-                PR_NOT_REACHED(\"static data inconsistancy\");\n-                break;\n+PRBool test_012(void) {\n+  static struct {\n+    const char* one;\n+    const char* two;\n+    PRUint32 max;\n+    PRIntn sign;\n+  } array[] = {{(const char*)0, (const char*)0, 0, 0},\n+               {(const char*)0, (const char*)0, 1, 0},\n+               {(const char*)0, (const char*)0, 4, 0},\n+               {(const char*)0, \"word\", 0, -1},\n+               {(const char*)0, \"word\", 1, -1},\n+               {(const char*)0, \"word\", 4, -1},\n+               {\"word\", (const char*)0, 0, 1},\n+               {\"word\", (const char*)0, 1, 1},\n+               {\"word\", (const char*)0, 4, 1},\n+               {\"word\", \"word\", 0, 0},\n+               {\"word\", \"word\", 1, 0},\n+               {\"word\", \"word\", 3, 0},\n+               {\"word\", \"word\", 5, 0},\n+               {\"aZYXVUT\", \"bZYXVUT\", 0, 0},\n+               {\"aZYXVUT\", \"bZYXVUT\", 1, -1},\n+               {\"aZYXVUT\", \"bZYXVUT\", 4, -1},\n+               {\"aZYXVUT\", \"bZYXVUT\", 9, -1},\n+               {\"aZYXVUT\", \"bAAAAAA\", 0, 0},\n+               {\"aZYXVUT\", \"bAAAAAA\", 1, -1},\n+               {\"aZYXVUT\", \"bAAAAAA\", 4, -1},\n+               {\"aZYXVUT\", \"bAAAAAA\", 5, -1},\n+               {\"a\", \"aa\", 0, 0},\n+               {\"a\", \"aa\", 1, 0},\n+               {\"a\", \"aa\", 4, -1},\n+               {\"a\", \"a\", 0, 0},\n+               {\"a\", \"a\", 1, 0},\n+               {\"a\", \"a\", 4, 0},\n+               {\"a\", \"A\", 0, 0},\n+               {\"a\", \"A\", 1, 1},\n+               {\"a\", \"A\", 4, 1},\n+               {\"aaaaa\", \"baaaa\", 0, 0},\n+               {\"aaaaa\", \"baaaa\", 1, -1},\n+               {\"aaaaa\", \"baaaa\", 4, -1},\n+               {\"aaaaa\", \"abaaa\", 0, 0},\n+               {\"aaaaa\", \"abaaa\", 1, 0},\n+               {\"aaaaa\", \"abaaa\", 4, -1},\n+               {\"aaaaa\", \"aabaa\", 0, 0},\n+               {\"aaaaa\", \"aabaa\", 1, 0},\n+               {\"aaaaa\", \"aabaa\", 4, -1},\n+               {\"aaaaa\", \"aaaba\", 0, 0},\n+               {\"aaaaa\", \"aaaba\", 1, 0},\n+               {\"aaaaa\", \"aaaba\", 4, -1},\n+               {\"aaaaa\", \"aaaab\", 0, 0},\n+               {\"aaaaa\", \"aaaab\", 1, 0},\n+               {\"aaaaa\", \"aaaab\", 4, 0},\n+               {\"bZYXVUT\", \"aZYXVUT\", 0, 0},\n+               {\"bZYXVUT\", \"aZYXVUT\", 1, 1},\n+               {\"bZYXVUT\", \"aZYXVUT\", 4, 1},\n+               {\"bAAAAAA\", \"aZYXVUT\", 0, 0},\n+               {\"bAAAAAA\", \"aZYXVUT\", 1, 1},\n+               {\"bAAAAAA\", \"aZYXVUT\", 4, 1},\n+               {\"aa\", \"a\", 0, 0},\n+               {\"aa\", \"a\", 1, 0},\n+               {\"aa\", \"a\", 4, 1},\n+               {\"A\", \"a\", 0, 0},\n+               {\"A\", \"a\", 1, -1},\n+               {\"A\", \"a\", 4, -1},\n+               {\"baaaa\", \"aaaaa\", 0, 0},\n+               {\"baaaa\", \"aaaaa\", 1, 1},\n+               {\"baaaa\", \"aaaaa\", 4, 1},\n+               {\"abaaa\", \"aaaaa\", 0, 0},\n+               {\"abaaa\", \"aaaaa\", 1, 0},\n+               {\"abaaa\", \"aaaaa\", 4, 1},\n+               {\"aabaa\", \"aaaaa\", 0, 0},\n+               {\"aabaa\", \"aaaaa\", 1, 0},\n+               {\"aabaa\", \"aaaaa\", 4, 1},\n+               {\"aaaba\", \"aaaaa\", 0, 0},\n+               {\"aaaba\", \"aaaaa\", 1, 0},\n+               {\"aaaba\", \"aaaaa\", 4, 1},\n+               {\"aaaab\", \"aaaaa\", 0, 0},\n+               {\"aaaab\", \"aaaaa\", 1, 0},\n+               {\"aaaab\", \"aaaaa\", 4, 0},\n+               {\"word\", \"Word\", 0, 0},\n+               {\"word\", \"Word\", 1, 1},\n+               {\"word\", \"Word\", 3, 1},\n+               {\"word\", \"wOrd\", 0, 0},\n+               {\"word\", \"wOrd\", 1, 0},\n+               {\"word\", \"wOrd\", 3, 1},\n+               {\"word\", \"woRd\", 0, 0},\n+               {\"word\", \"woRd\", 1, 0},\n+               {\"word\", \"woRd\", 3, 1},\n+               {\"word\", \"worD\", 0, 0},\n+               {\"word\", \"worD\", 1, 0},\n+               {\"word\", \"worD\", 3, 0},\n+               {\"WORD\", \"wORD\", 0, 0},\n+               {\"WORD\", \"wORD\", 1, -1},\n+               {\"WORD\", \"wORD\", 3, -1},\n+               {\"WORD\", \"WoRD\", 0, 0},\n+               {\"WORD\", \"WoRD\", 1, 0},\n+               {\"WORD\", \"WoRD\", 3, -1},\n+               {\"WORD\", \"WOrD\", 0, 0},\n+               {\"WORD\", \"WOrD\", 1, 0},\n+               {\"WORD\", \"WOrD\", 3, -1},\n+               {\"WORD\", \"WORd\", 0, 0},\n+               {\"WORD\", \"WORd\", 1, 0},\n+               {\"WORD\", \"WORd\", 3, 0}\n+\n+  };\n+\n+  int i;\n+\n+  printf(\"Test 012 (PL_strncmp)     ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRIntn rv = PL_strncmp(array[i].one, array[i].two, array[i].max);\n+\n+    switch (array[i].sign) {\n+      case -1:\n+        if (rv < 0) {\n+          continue;\n         }\n-\n-        printf(\"FAIL %d: %s-%s/%ld -> %d, not %d\\n\", i,\n-               array[i].one ? array[i].one : \"(null)\",\n-               array[i].two ? array[i].two : \"(null)\", array[i].max, rv,\n-               array[i].sign);\n-        return PR_FALSE;\n+        break;\n+      case 1:\n+        if (rv > 0) {\n+          continue;\n+        }\n+        break;\n+      case 0:\n+        if (0 == rv) {\n+          continue;\n+        }\n+        break;\n+      default:\n+        PR_NOT_REACHED(\"static data inconsistancy\");\n+        break;\n     }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+    printf(\"FAIL %d: %s-%s/%ld -> %d, not %d\\n\", i,\n+           array[i].one ? array[i].one : \"(null)\",\n+           array[i].two ? array[i].two : \"(null)\", array[i].max, rv,\n+           array[i].sign);\n+    return PR_FALSE;\n+  }\n+\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strcasecmp */\n-PRBool\n-test_013(void)\n-{\n-    static struct {\n-        const char* one;\n-        const char* two;\n-        PRIntn sign;\n-    } array[] = { { (const char*)0, (const char*)0, 0 },\n-                  { (const char*)0, \"word\", -1 },\n-                  { \"word\", (const char*)0, 1 },\n-                  { \"word\", \"word\", 0 },\n-                  { \"aZYXVUT\", \"bZYXVUT\", -1 },\n-                  { \"aZYXVUT\", \"bAAAAAA\", -1 },\n-                  { \"a\", \"aa\", -1 },\n-                  { \"a\", \"a\", 0 },\n-                  { \"a\", \"A\", 0 },\n-                  { \"aaaaa\", \"baaaa\", -1 },\n-                  { \"aaaaa\", \"abaaa\", -1 },\n-                  { \"aaaaa\", \"aabaa\", -1 },\n-                  { \"aaaaa\", \"aaaba\", -1 },\n-                  { \"aaaaa\", \"aaaab\", -1 },\n-                  { \"bZYXVUT\", \"aZYXVUT\", 1 },\n-                  { \"bAAAAAA\", \"aZYXVUT\", 1 },\n-                  { \"aa\", \"a\", 1 },\n-                  { \"A\", \"a\", 0 },\n-                  { \"baaaa\", \"aaaaa\", 1 },\n-                  { \"abaaa\", \"aaaaa\", 1 },\n-                  { \"aabaa\", \"aaaaa\", 1 },\n-                  { \"aaaba\", \"aaaaa\", 1 },\n-                  { \"aaaab\", \"aaaaa\", 1 },\n-                  { \"word\", \"Word\", 0 },\n-                  { \"word\", \"wOrd\", 0 },\n-                  { \"word\", \"woRd\", 0 },\n-                  { \"word\", \"worD\", 0 },\n-                  { \"WORD\", \"wORD\", 0 },\n-                  { \"WORD\", \"WoRD\", 0 },\n-                  { \"WORD\", \"WOrD\", 0 },\n-                  { \"WORD\", \"WORd\", 0 } };\n-\n-    int i;\n-\n-    printf(\"Test 013 (PL_strcasecmp)  ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRIntn rv = PL_strcasecmp(array[i].one, array[i].two);\n-\n-        switch (array[i].sign) {\n-            case -1:\n-                if (rv < 0) {\n-                    continue;\n-                }\n-                break;\n-            case 1:\n-                if (rv > 0) {\n-                    continue;\n-                }\n-                break;\n-            case 0:\n-                if (0 == rv) {\n-                    continue;\n-                }\n-                break;\n-            default:\n-                PR_NOT_REACHED(\"static data inconsistancy\");\n-                break;\n+PRBool test_013(void) {\n+  static struct {\n+    const char* one;\n+    const char* two;\n+    PRIntn sign;\n+  } array[] = {{(const char*)0, (const char*)0, 0},\n+               {(const char*)0, \"word\", -1},\n+               {\"word\", (const char*)0, 1},\n+               {\"word\", \"word\", 0},\n+               {\"aZYXVUT\", \"bZYXVUT\", -1},\n+               {\"aZYXVUT\", \"bAAAAAA\", -1},\n+               {\"a\", \"aa\", -1},\n+               {\"a\", \"a\", 0},\n+               {\"a\", \"A\", 0},\n+               {\"aaaaa\", \"baaaa\", -1},\n+               {\"aaaaa\", \"abaaa\", -1},\n+               {\"aaaaa\", \"aabaa\", -1},\n+               {\"aaaaa\", \"aaaba\", -1},\n+               {\"aaaaa\", \"aaaab\", -1},\n+               {\"bZYXVUT\", \"aZYXVUT\", 1},\n+               {\"bAAAAAA\", \"aZYXVUT\", 1},\n+               {\"aa\", \"a\", 1},\n+               {\"A\", \"a\", 0},\n+               {\"baaaa\", \"aaaaa\", 1},\n+               {\"abaaa\", \"aaaaa\", 1},\n+               {\"aabaa\", \"aaaaa\", 1},\n+               {\"aaaba\", \"aaaaa\", 1},\n+               {\"aaaab\", \"aaaaa\", 1},\n+               {\"word\", \"Word\", 0},\n+               {\"word\", \"wOrd\", 0},\n+               {\"word\", \"woRd\", 0},\n+               {\"word\", \"worD\", 0},\n+               {\"WORD\", \"wORD\", 0},\n+               {\"WORD\", \"WoRD\", 0},\n+               {\"WORD\", \"WOrD\", 0},\n+               {\"WORD\", \"WORd\", 0}};\n+\n+  int i;\n+\n+  printf(\"Test 013 (PL_strcasecmp)  ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRIntn rv = PL_strcasecmp(array[i].one, array[i].two);\n+\n+    switch (array[i].sign) {\n+      case -1:\n+        if (rv < 0) {\n+          continue;\n         }\n-\n-        printf(\"FAIL %d: %s-%s -> %d, not %d\\n\", i,\n-               array[i].one ? array[i].one : \"(null)\",\n-               array[i].two ? array[i].two : \"(null)\", rv, array[i].sign);\n-        return PR_FALSE;\n+        break;\n+      case 1:\n+        if (rv > 0) {\n+          continue;\n+        }\n+        break;\n+      case 0:\n+        if (0 == rv) {\n+          continue;\n+        }\n+        break;\n+      default:\n+        PR_NOT_REACHED(\"static data inconsistancy\");\n+        break;\n     }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+    printf(\"FAIL %d: %s-%s -> %d, not %d\\n\", i,\n+           array[i].one ? array[i].one : \"(null)\",\n+           array[i].two ? array[i].two : \"(null)\", rv, array[i].sign);\n+    return PR_FALSE;\n+  }\n+\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strncasecmp */\n-PRBool\n-test_014(void)\n-{\n-    static struct {\n-        const char* one;\n-        const char* two;\n-        PRUint32 max;\n-        PRIntn sign;\n-    } array[] = { { (const char*)0, (const char*)0, 0, 0 },\n-                  { (const char*)0, (const char*)0, 1, 0 },\n-                  { (const char*)0, (const char*)0, 4, 0 },\n-                  { (const char*)0, \"word\", 0, -1 },\n-                  { (const char*)0, \"word\", 1, -1 },\n-                  { (const char*)0, \"word\", 4, -1 },\n-                  { \"word\", (const char*)0, 0, 1 },\n-                  { \"word\", (const char*)0, 1, 1 },\n-                  { \"word\", (const char*)0, 4, 1 },\n-                  { \"word\", \"word\", 0, 0 },\n-                  { \"word\", \"word\", 1, 0 },\n-                  { \"word\", \"word\", 3, 0 },\n-                  { \"word\", \"word\", 5, 0 },\n-                  { \"aZYXVUT\", \"bZYXVUT\", 0, 0 },\n-                  { \"aZYXVUT\", \"bZYXVUT\", 1, -1 },\n-                  { \"aZYXVUT\", \"bZYXVUT\", 4, -1 },\n-                  { \"aZYXVUT\", \"bZYXVUT\", 9, -1 },\n-                  { \"aZYXVUT\", \"bAAAAAA\", 0, 0 },\n-                  { \"aZYXVUT\", \"bAAAAAA\", 1, -1 },\n-                  { \"aZYXVUT\", \"bAAAAAA\", 4, -1 },\n-                  { \"aZYXVUT\", \"bAAAAAA\", 5, -1 },\n-                  { \"a\", \"aa\", 0, 0 },\n-                  { \"a\", \"aa\", 1, 0 },\n-                  { \"a\", \"aa\", 4, -1 },\n-                  { \"a\", \"a\", 0, 0 },\n-                  { \"a\", \"a\", 1, 0 },\n-                  { \"a\", \"a\", 4, 0 },\n-                  { \"a\", \"A\", 0, 0 },\n-                  { \"a\", \"A\", 1, 0 },\n-                  { \"a\", \"A\", 4, 0 },\n-                  { \"aaaaa\", \"baaaa\", 0, 0 },\n-                  { \"aaaaa\", \"baaaa\", 1, -1 },\n-                  { \"aaaaa\", \"baaaa\", 4, -1 },\n-                  { \"aaaaa\", \"abaaa\", 0, 0 },\n-                  { \"aaaaa\", \"abaaa\", 1, 0 },\n-                  { \"aaaaa\", \"abaaa\", 4, -1 },\n-                  { \"aaaaa\", \"aabaa\", 0, 0 },\n-                  { \"aaaaa\", \"aabaa\", 1, 0 },\n-                  { \"aaaaa\", \"aabaa\", 4, -1 },\n-                  { \"aaaaa\", \"aaaba\", 0, 0 },\n-                  { \"aaaaa\", \"aaaba\", 1, 0 },\n-                  { \"aaaaa\", \"aaaba\", 4, -1 },\n-                  { \"aaaaa\", \"aaaab\", 0, 0 },\n-                  { \"aaaaa\", \"aaaab\", 1, 0 },\n-                  { \"aaaaa\", \"aaaab\", 4, 0 },\n-                  { \"bZYXVUT\", \"aZYXVUT\", 0, 0 },\n-                  { \"bZYXVUT\", \"aZYXVUT\", 1, 1 },\n-                  { \"bZYXVUT\", \"aZYXVUT\", 4, 1 },\n-                  { \"bAAAAAA\", \"aZYXVUT\", 0, 0 },\n-                  { \"bAAAAAA\", \"aZYXVUT\", 1, 1 },\n-                  { \"bAAAAAA\", \"aZYXVUT\", 4, 1 },\n-                  { \"aa\", \"a\", 0, 0 },\n-                  { \"aa\", \"a\", 1, 0 },\n-                  { \"aa\", \"a\", 4, 1 },\n-                  { \"A\", \"a\", 0, 0 },\n-                  { \"A\", \"a\", 1, 0 },\n-                  { \"A\", \"a\", 4, 0 },\n-                  { \"baaaa\", \"aaaaa\", 0, 0 },\n-                  { \"baaaa\", \"aaaaa\", 1, 1 },\n-                  { \"baaaa\", \"aaaaa\", 4, 1 },\n-                  { \"abaaa\", \"aaaaa\", 0, 0 },\n-                  { \"abaaa\", \"aaaaa\", 1, 0 },\n-                  { \"abaaa\", \"aaaaa\", 4, 1 },\n-                  { \"aabaa\", \"aaaaa\", 0, 0 },\n-                  { \"aabaa\", \"aaaaa\", 1, 0 },\n-                  { \"aabaa\", \"aaaaa\", 4, 1 },\n-                  { \"aaaba\", \"aaaaa\", 0, 0 },\n-                  { \"aaaba\", \"aaaaa\", 1, 0 },\n-                  { \"aaaba\", \"aaaaa\", 4, 1 },\n-                  { \"aaaab\", \"aaaaa\", 0, 0 },\n-                  { \"aaaab\", \"aaaaa\", 1, 0 },\n-                  { \"aaaab\", \"aaaaa\", 4, 0 },\n-                  { \"word\", \"Word\", 0, 0 },\n-                  { \"word\", \"Word\", 1, 0 },\n-                  { \"word\", \"Word\", 3, 0 },\n-                  { \"word\", \"wOrd\", 0, 0 },\n-                  { \"word\", \"wOrd\", 1, 0 },\n-                  { \"word\", \"wOrd\", 3, 0 },\n-                  { \"word\", \"woRd\", 0, 0 },\n-                  { \"word\", \"woRd\", 1, 0 },\n-                  { \"word\", \"woRd\", 3, 0 },\n-                  { \"word\", \"worD\", 0, 0 },\n-                  { \"word\", \"worD\", 1, 0 },\n-                  { \"word\", \"worD\", 3, 0 },\n-                  { \"WORD\", \"wORD\", 0, 0 },\n-                  { \"WORD\", \"wORD\", 1, 0 },\n-                  { \"WORD\", \"wORD\", 3, 0 },\n-                  { \"WORD\", \"WoRD\", 0, 0 },\n-                  { \"WORD\", \"WoRD\", 1, 0 },\n-                  { \"WORD\", \"WoRD\", 3, 0 },\n-                  { \"WORD\", \"WOrD\", 0, 0 },\n-                  { \"WORD\", \"WOrD\", 1, 0 },\n-                  { \"WORD\", \"WOrD\", 3, 0 },\n-                  { \"WORD\", \"WORd\", 0, 0 },\n-                  { \"WORD\", \"WORd\", 1, 0 },\n-                  { \"WORD\", \"WORd\", 3, 0 } };\n-\n-    int i;\n-\n-    printf(\"Test 014 (PL_strncasecmp) ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        PRIntn rv = PL_strncasecmp(array[i].one, array[i].two, array[i].max);\n-\n-        switch (array[i].sign) {\n-            case -1:\n-                if (rv < 0) {\n-                    continue;\n-                }\n-                break;\n-            case 1:\n-                if (rv > 0) {\n-                    continue;\n-                }\n-                break;\n-            case 0:\n-                if (0 == rv) {\n-                    continue;\n-                }\n-                break;\n-            default:\n-                PR_NOT_REACHED(\"static data inconsistancy\");\n-                break;\n+PRBool test_014(void) {\n+  static struct {\n+    const char* one;\n+    const char* two;\n+    PRUint32 max;\n+    PRIntn sign;\n+  } array[] = {{(const char*)0, (const char*)0, 0, 0},\n+               {(const char*)0, (const char*)0, 1, 0},\n+               {(const char*)0, (const char*)0, 4, 0},\n+               {(const char*)0, \"word\", 0, -1},\n+               {(const char*)0, \"word\", 1, -1},\n+               {(const char*)0, \"word\", 4, -1},\n+               {\"word\", (const char*)0, 0, 1},\n+               {\"word\", (const char*)0, 1, 1},\n+               {\"word\", (const char*)0, 4, 1},\n+               {\"word\", \"word\", 0, 0},\n+               {\"word\", \"word\", 1, 0},\n+               {\"word\", \"word\", 3, 0},\n+               {\"word\", \"word\", 5, 0},\n+               {\"aZYXVUT\", \"bZYXVUT\", 0, 0},\n+               {\"aZYXVUT\", \"bZYXVUT\", 1, -1},\n+               {\"aZYXVUT\", \"bZYXVUT\", 4, -1},\n+               {\"aZYXVUT\", \"bZYXVUT\", 9, -1},\n+               {\"aZYXVUT\", \"bAAAAAA\", 0, 0},\n+               {\"aZYXVUT\", \"bAAAAAA\", 1, -1},\n+               {\"aZYXVUT\", \"bAAAAAA\", 4, -1},\n+               {\"aZYXVUT\", \"bAAAAAA\", 5, -1},\n+               {\"a\", \"aa\", 0, 0},\n+               {\"a\", \"aa\", 1, 0},\n+               {\"a\", \"aa\", 4, -1},\n+               {\"a\", \"a\", 0, 0},\n+               {\"a\", \"a\", 1, 0},\n+               {\"a\", \"a\", 4, 0},\n+               {\"a\", \"A\", 0, 0},\n+               {\"a\", \"A\", 1, 0},\n+               {\"a\", \"A\", 4, 0},\n+               {\"aaaaa\", \"baaaa\", 0, 0},\n+               {\"aaaaa\", \"baaaa\", 1, -1},\n+               {\"aaaaa\", \"baaaa\", 4, -1},\n+               {\"aaaaa\", \"abaaa\", 0, 0},\n+               {\"aaaaa\", \"abaaa\", 1, 0},\n+               {\"aaaaa\", \"abaaa\", 4, -1},\n+               {\"aaaaa\", \"aabaa\", 0, 0},\n+               {\"aaaaa\", \"aabaa\", 1, 0},\n+               {\"aaaaa\", \"aabaa\", 4, -1},\n+               {\"aaaaa\", \"aaaba\", 0, 0},\n+               {\"aaaaa\", \"aaaba\", 1, 0},\n+               {\"aaaaa\", \"aaaba\", 4, -1},\n+               {\"aaaaa\", \"aaaab\", 0, 0},\n+               {\"aaaaa\", \"aaaab\", 1, 0},\n+               {\"aaaaa\", \"aaaab\", 4, 0},\n+               {\"bZYXVUT\", \"aZYXVUT\", 0, 0},\n+               {\"bZYXVUT\", \"aZYXVUT\", 1, 1},\n+               {\"bZYXVUT\", \"aZYXVUT\", 4, 1},\n+               {\"bAAAAAA\", \"aZYXVUT\", 0, 0},\n+               {\"bAAAAAA\", \"aZYXVUT\", 1, 1},\n+               {\"bAAAAAA\", \"aZYXVUT\", 4, 1},\n+               {\"aa\", \"a\", 0, 0},\n+               {\"aa\", \"a\", 1, 0},\n+               {\"aa\", \"a\", 4, 1},\n+               {\"A\", \"a\", 0, 0},\n+               {\"A\", \"a\", 1, 0},\n+               {\"A\", \"a\", 4, 0},\n+               {\"baaaa\", \"aaaaa\", 0, 0},\n+               {\"baaaa\", \"aaaaa\", 1, 1},\n+               {\"baaaa\", \"aaaaa\", 4, 1},\n+               {\"abaaa\", \"aaaaa\", 0, 0},\n+               {\"abaaa\", \"aaaaa\", 1, 0},\n+               {\"abaaa\", \"aaaaa\", 4, 1},\n+               {\"aabaa\", \"aaaaa\", 0, 0},\n+               {\"aabaa\", \"aaaaa\", 1, 0},\n+               {\"aabaa\", \"aaaaa\", 4, 1},\n+               {\"aaaba\", \"aaaaa\", 0, 0},\n+               {\"aaaba\", \"aaaaa\", 1, 0},\n+               {\"aaaba\", \"aaaaa\", 4, 1},\n+               {\"aaaab\", \"aaaaa\", 0, 0},\n+               {\"aaaab\", \"aaaaa\", 1, 0},\n+               {\"aaaab\", \"aaaaa\", 4, 0},\n+               {\"word\", \"Word\", 0, 0},\n+               {\"word\", \"Word\", 1, 0},\n+               {\"word\", \"Word\", 3, 0},\n+               {\"word\", \"wOrd\", 0, 0},\n+               {\"word\", \"wOrd\", 1, 0},\n+               {\"word\", \"wOrd\", 3, 0},\n+               {\"word\", \"woRd\", 0, 0},\n+               {\"word\", \"woRd\", 1, 0},\n+               {\"word\", \"woRd\", 3, 0},\n+               {\"word\", \"worD\", 0, 0},\n+               {\"word\", \"worD\", 1, 0},\n+               {\"word\", \"worD\", 3, 0},\n+               {\"WORD\", \"wORD\", 0, 0},\n+               {\"WORD\", \"wORD\", 1, 0},\n+               {\"WORD\", \"wORD\", 3, 0},\n+               {\"WORD\", \"WoRD\", 0, 0},\n+               {\"WORD\", \"WoRD\", 1, 0},\n+               {\"WORD\", \"WoRD\", 3, 0},\n+               {\"WORD\", \"WOrD\", 0, 0},\n+               {\"WORD\", \"WOrD\", 1, 0},\n+               {\"WORD\", \"WOrD\", 3, 0},\n+               {\"WORD\", \"WORd\", 0, 0},\n+               {\"WORD\", \"WORd\", 1, 0},\n+               {\"WORD\", \"WORd\", 3, 0}};\n+\n+  int i;\n+\n+  printf(\"Test 014 (PL_strncasecmp) ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    PRIntn rv = PL_strncasecmp(array[i].one, array[i].two, array[i].max);\n+\n+    switch (array[i].sign) {\n+      case -1:\n+        if (rv < 0) {\n+          continue;\n         }\n-\n-        printf(\"FAIL %d: %s-%s/%ld -> %d, not %d\\n\", i,\n-               array[i].one ? array[i].one : \"(null)\",\n-               array[i].two ? array[i].two : \"(null)\", array[i].max, rv,\n-               array[i].sign);\n-        return PR_FALSE;\n+        break;\n+      case 1:\n+        if (rv > 0) {\n+          continue;\n+        }\n+        break;\n+      case 0:\n+        if (0 == rv) {\n+          continue;\n+        }\n+        break;\n+      default:\n+        PR_NOT_REACHED(\"static data inconsistancy\");\n+        break;\n     }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+    printf(\"FAIL %d: %s-%s/%ld -> %d, not %d\\n\", i,\n+           array[i].one ? array[i].one : \"(null)\",\n+           array[i].two ? array[i].two : \"(null)\", array[i].max, rv,\n+           array[i].sign);\n+    return PR_FALSE;\n+  }\n+\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strchr */\n-PRBool\n-test_015(void)\n-{\n-    static struct {\n-        const char* str;\n-        char chr;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, 'a', PR_FALSE, 0 },\n-                  { (const char*)0, '\\0', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'a', PR_TRUE, 0 },\n-                  { \"abcdefg\", 'b', PR_TRUE, 1 },\n-                  { \"abcdefg\", 'c', PR_TRUE, 2 },\n-                  { \"abcdefg\", 'd', PR_TRUE, 3 },\n-                  { \"abcdefg\", 'e', PR_TRUE, 4 },\n-                  { \"abcdefg\", 'f', PR_TRUE, 5 },\n-                  { \"abcdefg\", 'g', PR_TRUE, 6 },\n-                  { \"abcdefg\", 'h', PR_FALSE, 0 },\n-                  { \"abcdefg\", '\\0', PR_TRUE, 7 },\n-                  { \"abcdefg\", 'A', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'B', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'C', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'D', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'E', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'F', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'G', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'H', PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", 'a', PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", 'b', PR_TRUE, 1 },\n-                  { \"abcdefgabcdefg\", 'c', PR_TRUE, 2 },\n-                  { \"abcdefgabcdefg\", 'd', PR_TRUE, 3 },\n-                  { \"abcdefgabcdefg\", 'e', PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", 'f', PR_TRUE, 5 },\n-                  { \"abcdefgabcdefg\", 'g', PR_TRUE, 6 },\n-                  { \"abcdefgabcdefg\", 'h', PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", '\\0', PR_TRUE, 14 } };\n-\n-    int i;\n-\n-    printf(\"Test 015 (PL_strchr)      ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strchr(array[i].str, array[i].chr);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%c -> %.32s, not zero\\n\", i, array[i].str,\n-                       array[i].chr, rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%c -> null, not +%lu\\n\", i, array[i].str,\n-                       array[i].chr, array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%c -> 0x%x, not 0x%x+%lu\\n\", i, array[i].str,\n-                       array[i].chr, rv, array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_015(void) {\n+  static struct {\n+    const char* str;\n+    char chr;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, 'a', PR_FALSE, 0},\n+               {(const char*)0, '\\0', PR_FALSE, 0},\n+               {\"abcdefg\", 'a', PR_TRUE, 0},\n+               {\"abcdefg\", 'b', PR_TRUE, 1},\n+               {\"abcdefg\", 'c', PR_TRUE, 2},\n+               {\"abcdefg\", 'd', PR_TRUE, 3},\n+               {\"abcdefg\", 'e', PR_TRUE, 4},\n+               {\"abcdefg\", 'f', PR_TRUE, 5},\n+               {\"abcdefg\", 'g', PR_TRUE, 6},\n+               {\"abcdefg\", 'h', PR_FALSE, 0},\n+               {\"abcdefg\", '\\0', PR_TRUE, 7},\n+               {\"abcdefg\", 'A', PR_FALSE, 0},\n+               {\"abcdefg\", 'B', PR_FALSE, 0},\n+               {\"abcdefg\", 'C', PR_FALSE, 0},\n+               {\"abcdefg\", 'D', PR_FALSE, 0},\n+               {\"abcdefg\", 'E', PR_FALSE, 0},\n+               {\"abcdefg\", 'F', PR_FALSE, 0},\n+               {\"abcdefg\", 'G', PR_FALSE, 0},\n+               {\"abcdefg\", 'H', PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", 'a', PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", 'b', PR_TRUE, 1},\n+               {\"abcdefgabcdefg\", 'c', PR_TRUE, 2},\n+               {\"abcdefgabcdefg\", 'd', PR_TRUE, 3},\n+               {\"abcdefgabcdefg\", 'e', PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", 'f', PR_TRUE, 5},\n+               {\"abcdefgabcdefg\", 'g', PR_TRUE, 6},\n+               {\"abcdefgabcdefg\", 'h', PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", '\\0', PR_TRUE, 14}};\n+\n+  int i;\n+\n+  printf(\"Test 015 (PL_strchr)      ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strchr(array[i].str, array[i].chr);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%c -> %.32s, not zero\\n\", i, array[i].str,\n+               array[i].chr, rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%c -> null, not +%lu\\n\", i, array[i].str,\n+               array[i].chr, array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%c -> 0x%x, not 0x%x+%lu\\n\", i, array[i].str,\n+               array[i].chr, rv, array[i].str, array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strrchr */\n-PRBool\n-test_016(void)\n-{\n-    static struct {\n-        const char* str;\n-        char chr;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, 'a', PR_FALSE, 0 },\n-                  { (const char*)0, '\\0', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'a', PR_TRUE, 0 },\n-                  { \"abcdefg\", 'b', PR_TRUE, 1 },\n-                  { \"abcdefg\", 'c', PR_TRUE, 2 },\n-                  { \"abcdefg\", 'd', PR_TRUE, 3 },\n-                  { \"abcdefg\", 'e', PR_TRUE, 4 },\n-                  { \"abcdefg\", 'f', PR_TRUE, 5 },\n-                  { \"abcdefg\", 'g', PR_TRUE, 6 },\n-                  { \"abcdefg\", 'h', PR_FALSE, 0 },\n-                  { \"abcdefg\", '\\0', PR_TRUE, 7 },\n-                  { \"abcdefg\", 'A', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'B', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'C', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'D', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'E', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'F', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'G', PR_FALSE, 0 },\n-                  { \"abcdefg\", 'H', PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", 'a', PR_TRUE, 7 },\n-                  { \"abcdefgabcdefg\", 'b', PR_TRUE, 8 },\n-                  { \"abcdefgabcdefg\", 'c', PR_TRUE, 9 },\n-                  { \"abcdefgabcdefg\", 'd', PR_TRUE, 10 },\n-                  { \"abcdefgabcdefg\", 'e', PR_TRUE, 11 },\n-                  { \"abcdefgabcdefg\", 'f', PR_TRUE, 12 },\n-                  { \"abcdefgabcdefg\", 'g', PR_TRUE, 13 },\n-                  { \"abcdefgabcdefg\", 'h', PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", '\\0', PR_TRUE, 14 } };\n-\n-    int i;\n-\n-    printf(\"Test 016 (PL_strrchr)     ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strrchr(array[i].str, array[i].chr);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%c -> %.32s, not zero\\n\", i, array[i].str,\n-                       array[i].chr, rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%c -> null, not +%lu\\n\", i, array[i].str,\n-                       array[i].chr, array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%c -> 0x%x, not 0x%x+%lu\\n\", i, array[i].str,\n-                       array[i].chr, rv, array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_016(void) {\n+  static struct {\n+    const char* str;\n+    char chr;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, 'a', PR_FALSE, 0},\n+               {(const char*)0, '\\0', PR_FALSE, 0},\n+               {\"abcdefg\", 'a', PR_TRUE, 0},\n+               {\"abcdefg\", 'b', PR_TRUE, 1},\n+               {\"abcdefg\", 'c', PR_TRUE, 2},\n+               {\"abcdefg\", 'd', PR_TRUE, 3},\n+               {\"abcdefg\", 'e', PR_TRUE, 4},\n+               {\"abcdefg\", 'f', PR_TRUE, 5},\n+               {\"abcdefg\", 'g', PR_TRUE, 6},\n+               {\"abcdefg\", 'h', PR_FALSE, 0},\n+               {\"abcdefg\", '\\0', PR_TRUE, 7},\n+               {\"abcdefg\", 'A', PR_FALSE, 0},\n+               {\"abcdefg\", 'B', PR_FALSE, 0},\n+               {\"abcdefg\", 'C', PR_FALSE, 0},\n+               {\"abcdefg\", 'D', PR_FALSE, 0},\n+               {\"abcdefg\", 'E', PR_FALSE, 0},\n+               {\"abcdefg\", 'F', PR_FALSE, 0},\n+               {\"abcdefg\", 'G', PR_FALSE, 0},\n+               {\"abcdefg\", 'H', PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", 'a', PR_TRUE, 7},\n+               {\"abcdefgabcdefg\", 'b', PR_TRUE, 8},\n+               {\"abcdefgabcdefg\", 'c', PR_TRUE, 9},\n+               {\"abcdefgabcdefg\", 'd', PR_TRUE, 10},\n+               {\"abcdefgabcdefg\", 'e', PR_TRUE, 11},\n+               {\"abcdefgabcdefg\", 'f', PR_TRUE, 12},\n+               {\"abcdefgabcdefg\", 'g', PR_TRUE, 13},\n+               {\"abcdefgabcdefg\", 'h', PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", '\\0', PR_TRUE, 14}};\n+\n+  int i;\n+\n+  printf(\"Test 016 (PL_strrchr)     ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strrchr(array[i].str, array[i].chr);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%c -> %.32s, not zero\\n\", i, array[i].str,\n+               array[i].chr, rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%c -> null, not +%lu\\n\", i, array[i].str,\n+               array[i].chr, array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%c -> 0x%x, not 0x%x+%lu\\n\", i, array[i].str,\n+               array[i].chr, rv, array[i].str, array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strnchr */\n-PRBool\n-test_017(void)\n-{\n-    static struct {\n-        const char* str;\n-        char chr;\n-        PRUint32 max;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, 'a', 2, PR_FALSE, 0 },\n-                  { (const char*)0, '\\0', 2, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'a', 5, PR_TRUE, 0 },\n-                  { \"abcdefg\", 'b', 5, PR_TRUE, 1 },\n-                  { \"abcdefg\", 'c', 5, PR_TRUE, 2 },\n-                  { \"abcdefg\", 'd', 5, PR_TRUE, 3 },\n-                  { \"abcdefg\", 'e', 5, PR_TRUE, 4 },\n-                  { \"abcdefg\", 'f', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'g', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'h', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", '\\0', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", '\\0', 15, PR_TRUE, 7 },\n-                  { \"abcdefg\", 'A', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'B', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'C', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'D', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'E', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'F', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'G', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'H', 5, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", 'a', 10, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", 'b', 10, PR_TRUE, 1 },\n-                  { \"abcdefgabcdefg\", 'c', 10, PR_TRUE, 2 },\n-                  { \"abcdefgabcdefg\", 'd', 10, PR_TRUE, 3 },\n-                  { \"abcdefgabcdefg\", 'e', 10, PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", 'f', 10, PR_TRUE, 5 },\n-                  { \"abcdefgabcdefg\", 'g', 10, PR_TRUE, 6 },\n-                  { \"abcdefgabcdefg\", 'h', 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", '\\0', 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", '\\0', 14, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", '\\0', 15, PR_TRUE, 14 } };\n-\n-    int i;\n-\n-    printf(\"Test 017 (PL_strnchr)     ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strnchr(array[i].str, array[i].chr, array[i].max);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%c/%lu -> %.32s, not zero\\n\", i, array[i].str,\n-                       array[i].chr, array[i].max, rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%c/%lu -> null, not +%lu\\n\", i, array[i].str,\n-                       array[i].chr, array[i].max, array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%c/%lu -> 0x%x, not 0x%x+%lu\\n\", i, array[i].str,\n-                       array[i].chr, array[i].max, rv, array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_017(void) {\n+  static struct {\n+    const char* str;\n+    char chr;\n+    PRUint32 max;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, 'a', 2, PR_FALSE, 0},\n+               {(const char*)0, '\\0', 2, PR_FALSE, 0},\n+               {\"abcdefg\", 'a', 5, PR_TRUE, 0},\n+               {\"abcdefg\", 'b', 5, PR_TRUE, 1},\n+               {\"abcdefg\", 'c', 5, PR_TRUE, 2},\n+               {\"abcdefg\", 'd', 5, PR_TRUE, 3},\n+               {\"abcdefg\", 'e', 5, PR_TRUE, 4},\n+               {\"abcdefg\", 'f', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'g', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'h', 5, PR_FALSE, 0},\n+               {\"abcdefg\", '\\0', 5, PR_FALSE, 0},\n+               {\"abcdefg\", '\\0', 15, PR_TRUE, 7},\n+               {\"abcdefg\", 'A', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'B', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'C', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'D', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'E', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'F', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'G', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'H', 5, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", 'a', 10, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", 'b', 10, PR_TRUE, 1},\n+               {\"abcdefgabcdefg\", 'c', 10, PR_TRUE, 2},\n+               {\"abcdefgabcdefg\", 'd', 10, PR_TRUE, 3},\n+               {\"abcdefgabcdefg\", 'e', 10, PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", 'f', 10, PR_TRUE, 5},\n+               {\"abcdefgabcdefg\", 'g', 10, PR_TRUE, 6},\n+               {\"abcdefgabcdefg\", 'h', 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", '\\0', 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", '\\0', 14, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", '\\0', 15, PR_TRUE, 14}};\n+\n+  int i;\n+\n+  printf(\"Test 017 (PL_strnchr)     ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strnchr(array[i].str, array[i].chr, array[i].max);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%c/%lu -> %.32s, not zero\\n\", i, array[i].str,\n+               array[i].chr, array[i].max, rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%c/%lu -> null, not +%lu\\n\", i, array[i].str,\n+               array[i].chr, array[i].max, array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%c/%lu -> 0x%x, not 0x%x+%lu\\n\", i, array[i].str,\n+               array[i].chr, array[i].max, rv, array[i].str, array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strnrchr */\n-PRBool\n-test_018(void)\n-{\n-    static struct {\n-        const char* str;\n-        char chr;\n-        PRUint32 max;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, 'a', 2, PR_FALSE, 0 },\n-                  { (const char*)0, '\\0', 2, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'a', 5, PR_TRUE, 0 },\n-                  { \"abcdefg\", 'b', 5, PR_TRUE, 1 },\n-                  { \"abcdefg\", 'c', 5, PR_TRUE, 2 },\n-                  { \"abcdefg\", 'd', 5, PR_TRUE, 3 },\n-                  { \"abcdefg\", 'e', 5, PR_TRUE, 4 },\n-                  { \"abcdefg\", 'f', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'g', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'h', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", '\\0', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", '\\0', 15, PR_TRUE, 7 },\n-                  { \"abcdefg\", 'A', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'B', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'C', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'D', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'E', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'F', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'G', 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", 'H', 5, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", 'a', 10, PR_TRUE, 7 },\n-                  { \"abcdefgabcdefg\", 'b', 10, PR_TRUE, 8 },\n-                  { \"abcdefgabcdefg\", 'c', 10, PR_TRUE, 9 },\n-                  { \"abcdefgabcdefg\", 'd', 10, PR_TRUE, 3 },\n-                  { \"abcdefgabcdefg\", 'e', 10, PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", 'f', 10, PR_TRUE, 5 },\n-                  { \"abcdefgabcdefg\", 'g', 10, PR_TRUE, 6 },\n-                  { \"abcdefgabcdefg\", 'h', 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", '\\0', 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", '\\0', 14, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", '\\0', 15, PR_TRUE, 14 } };\n-\n-    int i;\n-\n-    printf(\"Test 018 (PL_strnrchr)    ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strnrchr(array[i].str, array[i].chr, array[i].max);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%c/%lu -> %.32s, not zero\\n\", i, array[i].str,\n-                       array[i].chr, array[i].max, rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%c/%lu -> null, not +%lu\\n\", i, array[i].str,\n-                       array[i].chr, array[i].max, array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%c/%lu -> 0x%x, not 0x%x+%lu\\n\", i, array[i].str,\n-                       array[i].chr, array[i].max, rv, array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_018(void) {\n+  static struct {\n+    const char* str;\n+    char chr;\n+    PRUint32 max;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, 'a', 2, PR_FALSE, 0},\n+               {(const char*)0, '\\0', 2, PR_FALSE, 0},\n+               {\"abcdefg\", 'a', 5, PR_TRUE, 0},\n+               {\"abcdefg\", 'b', 5, PR_TRUE, 1},\n+               {\"abcdefg\", 'c', 5, PR_TRUE, 2},\n+               {\"abcdefg\", 'd', 5, PR_TRUE, 3},\n+               {\"abcdefg\", 'e', 5, PR_TRUE, 4},\n+               {\"abcdefg\", 'f', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'g', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'h', 5, PR_FALSE, 0},\n+               {\"abcdefg\", '\\0', 5, PR_FALSE, 0},\n+               {\"abcdefg\", '\\0', 15, PR_TRUE, 7},\n+               {\"abcdefg\", 'A', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'B', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'C', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'D', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'E', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'F', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'G', 5, PR_FALSE, 0},\n+               {\"abcdefg\", 'H', 5, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", 'a', 10, PR_TRUE, 7},\n+               {\"abcdefgabcdefg\", 'b', 10, PR_TRUE, 8},\n+               {\"abcdefgabcdefg\", 'c', 10, PR_TRUE, 9},\n+               {\"abcdefgabcdefg\", 'd', 10, PR_TRUE, 3},\n+               {\"abcdefgabcdefg\", 'e', 10, PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", 'f', 10, PR_TRUE, 5},\n+               {\"abcdefgabcdefg\", 'g', 10, PR_TRUE, 6},\n+               {\"abcdefgabcdefg\", 'h', 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", '\\0', 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", '\\0', 14, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", '\\0', 15, PR_TRUE, 14}};\n+\n+  int i;\n+\n+  printf(\"Test 018 (PL_strnrchr)    ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strnrchr(array[i].str, array[i].chr, array[i].max);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%c/%lu -> %.32s, not zero\\n\", i, array[i].str,\n+               array[i].chr, array[i].max, rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%c/%lu -> null, not +%lu\\n\", i, array[i].str,\n+               array[i].chr, array[i].max, array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%c/%lu -> 0x%x, not 0x%x+%lu\\n\", i, array[i].str,\n+               array[i].chr, array[i].max, rv, array[i].str, array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strpbrk */\n-PRBool\n-test_019(void)\n-{\n-    static struct {\n-        const char* str;\n-        const char* chrs;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, (const char*)0, PR_FALSE, 0 },\n-                  { (const char*)0, \"abc\", PR_FALSE, 0 },\n-                  { \"abc\", (const char*)0, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"\", PR_FALSE, 0 },\n-                  { \"\", \"aeiou\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ae\", PR_TRUE, 0 },\n-                  { \"abcdefg\", \"ei\", PR_TRUE, 4 },\n-                  { \"abcdefg\", \"io\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"bcd\", PR_TRUE, 1 },\n-                  { \"abcdefg\", \"cbd\", PR_TRUE, 1 },\n-                  { \"abcdefg\", \"dbc\", PR_TRUE, 1 },\n-                  { \"abcdefg\", \"ghi\", PR_TRUE, 6 },\n-                  { \"abcdefg\", \"AE\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"EI\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"IO\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"BCD\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"CBD\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"DBC\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"GHI\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"ae\", PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"ei\", PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", \"io\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"bcd\", PR_TRUE, 1 },\n-                  { \"abcdefgabcdefg\", \"cbd\", PR_TRUE, 1 },\n-                  { \"abcdefgabcdefg\", \"dbc\", PR_TRUE, 1 },\n-                  { \"abcdefgabcdefg\", \"ghi\", PR_TRUE, 6 },\n-                  { \"abcdefgabcdefg\", \"AE\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"EI\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"IO\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"BCD\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"CBD\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"DBC\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"GHI\", PR_FALSE, 0 } };\n-\n-    int i;\n-\n-    printf(\"Test 019 (PL_strpbrk)     ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strpbrk(array[i].str, array[i].chrs);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%s -> %.32s, not null\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].chrs ? array[i].chrs : \"(null)\", rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%s -> null, not +%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].chrs ? array[i].chrs : \"(null)\", array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%s -> 0x%x, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].chrs ? array[i].chrs : \"(null)\", rv, array[i].str,\n-                       array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_019(void) {\n+  static struct {\n+    const char* str;\n+    const char* chrs;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, (const char*)0, PR_FALSE, 0},\n+               {(const char*)0, \"abc\", PR_FALSE, 0},\n+               {\"abc\", (const char*)0, PR_FALSE, 0},\n+               {\"abcdefg\", \"\", PR_FALSE, 0},\n+               {\"\", \"aeiou\", PR_FALSE, 0},\n+               {\"abcdefg\", \"ae\", PR_TRUE, 0},\n+               {\"abcdefg\", \"ei\", PR_TRUE, 4},\n+               {\"abcdefg\", \"io\", PR_FALSE, 0},\n+               {\"abcdefg\", \"bcd\", PR_TRUE, 1},\n+               {\"abcdefg\", \"cbd\", PR_TRUE, 1},\n+               {\"abcdefg\", \"dbc\", PR_TRUE, 1},\n+               {\"abcdefg\", \"ghi\", PR_TRUE, 6},\n+               {\"abcdefg\", \"AE\", PR_FALSE, 0},\n+               {\"abcdefg\", \"EI\", PR_FALSE, 0},\n+               {\"abcdefg\", \"IO\", PR_FALSE, 0},\n+               {\"abcdefg\", \"BCD\", PR_FALSE, 0},\n+               {\"abcdefg\", \"CBD\", PR_FALSE, 0},\n+               {\"abcdefg\", \"DBC\", PR_FALSE, 0},\n+               {\"abcdefg\", \"GHI\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"ae\", PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"ei\", PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", \"io\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"bcd\", PR_TRUE, 1},\n+               {\"abcdefgabcdefg\", \"cbd\", PR_TRUE, 1},\n+               {\"abcdefgabcdefg\", \"dbc\", PR_TRUE, 1},\n+               {\"abcdefgabcdefg\", \"ghi\", PR_TRUE, 6},\n+               {\"abcdefgabcdefg\", \"AE\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"EI\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"IO\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"BCD\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"CBD\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"DBC\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"GHI\", PR_FALSE, 0}};\n+\n+  int i;\n+\n+  printf(\"Test 019 (PL_strpbrk)     ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strpbrk(array[i].str, array[i].chrs);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%s -> %.32s, not null\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].chrs ? array[i].chrs : \"(null)\", rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%s -> null, not +%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].chrs ? array[i].chrs : \"(null)\", array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%s -> 0x%x, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].chrs ? array[i].chrs : \"(null)\", rv, array[i].str,\n+               array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strprbrk */\n-PRBool\n-test_020(void)\n-{\n-    static struct {\n-        const char* str;\n-        const char* chrs;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, (const char*)0, PR_FALSE, 0 },\n-                  { (const char*)0, \"abc\", PR_FALSE, 0 },\n-                  { \"abc\", (const char*)0, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"\", PR_FALSE, 0 },\n-                  { \"\", \"aeiou\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ae\", PR_TRUE, 4 },\n-                  { \"abcdefg\", \"ei\", PR_TRUE, 4 },\n-                  { \"abcdefg\", \"io\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"bcd\", PR_TRUE, 3 },\n-                  { \"abcdefg\", \"cbd\", PR_TRUE, 3 },\n-                  { \"abcdefg\", \"dbc\", PR_TRUE, 3 },\n-                  { \"abcdefg\", \"ghi\", PR_TRUE, 6 },\n-                  { \"abcdefg\", \"AE\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"EI\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"IO\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"BCD\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"CBD\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"DBC\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"GHI\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"ae\", PR_TRUE, 11 },\n-                  { \"abcdefgabcdefg\", \"ei\", PR_TRUE, 11 },\n-                  { \"abcdefgabcdefg\", \"io\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"bcd\", PR_TRUE, 10 },\n-                  { \"abcdefgabcdefg\", \"cbd\", PR_TRUE, 10 },\n-                  { \"abcdefgabcdefg\", \"dbc\", PR_TRUE, 10 },\n-                  { \"abcdefgabcdefg\", \"ghi\", PR_TRUE, 13 },\n-                  { \"abcdefgabcdefg\", \"AE\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"EI\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"IO\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"BCD\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"CBD\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"DBC\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"GHI\", PR_FALSE, 0 } };\n-\n-    int i;\n-\n-    printf(\"Test 020 (PL_strprbrk)    ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strprbrk(array[i].str, array[i].chrs);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%s -> %.32s, not null\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].chrs ? array[i].chrs : \"(null)\", rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%s -> null, not +%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].chrs ? array[i].chrs : \"(null)\", array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%s -> 0x%x, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].chrs ? array[i].chrs : \"(null)\", rv, array[i].str,\n-                       array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_020(void) {\n+  static struct {\n+    const char* str;\n+    const char* chrs;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, (const char*)0, PR_FALSE, 0},\n+               {(const char*)0, \"abc\", PR_FALSE, 0},\n+               {\"abc\", (const char*)0, PR_FALSE, 0},\n+               {\"abcdefg\", \"\", PR_FALSE, 0},\n+               {\"\", \"aeiou\", PR_FALSE, 0},\n+               {\"abcdefg\", \"ae\", PR_TRUE, 4},\n+               {\"abcdefg\", \"ei\", PR_TRUE, 4},\n+               {\"abcdefg\", \"io\", PR_FALSE, 0},\n+               {\"abcdefg\", \"bcd\", PR_TRUE, 3},\n+               {\"abcdefg\", \"cbd\", PR_TRUE, 3},\n+               {\"abcdefg\", \"dbc\", PR_TRUE, 3},\n+               {\"abcdefg\", \"ghi\", PR_TRUE, 6},\n+               {\"abcdefg\", \"AE\", PR_FALSE, 0},\n+               {\"abcdefg\", \"EI\", PR_FALSE, 0},\n+               {\"abcdefg\", \"IO\", PR_FALSE, 0},\n+               {\"abcdefg\", \"BCD\", PR_FALSE, 0},\n+               {\"abcdefg\", \"CBD\", PR_FALSE, 0},\n+               {\"abcdefg\", \"DBC\", PR_FALSE, 0},\n+               {\"abcdefg\", \"GHI\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"ae\", PR_TRUE, 11},\n+               {\"abcdefgabcdefg\", \"ei\", PR_TRUE, 11},\n+               {\"abcdefgabcdefg\", \"io\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"bcd\", PR_TRUE, 10},\n+               {\"abcdefgabcdefg\", \"cbd\", PR_TRUE, 10},\n+               {\"abcdefgabcdefg\", \"dbc\", PR_TRUE, 10},\n+               {\"abcdefgabcdefg\", \"ghi\", PR_TRUE, 13},\n+               {\"abcdefgabcdefg\", \"AE\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"EI\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"IO\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"BCD\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"CBD\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"DBC\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"GHI\", PR_FALSE, 0}};\n+\n+  int i;\n+\n+  printf(\"Test 020 (PL_strprbrk)    ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strprbrk(array[i].str, array[i].chrs);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%s -> %.32s, not null\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].chrs ? array[i].chrs : \"(null)\", rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%s -> null, not +%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].chrs ? array[i].chrs : \"(null)\", array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%s -> 0x%x, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].chrs ? array[i].chrs : \"(null)\", rv, array[i].str,\n+               array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strnpbrk */\n-PRBool\n-test_021(void)\n-{\n-    static struct {\n-        const char* str;\n-        const char* chrs;\n-        PRUint32 max;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, (const char*)0, 3, PR_FALSE, 0 },\n-                  { (const char*)0, \"abc\", 3, PR_FALSE, 0 },\n-                  { \"abc\", (const char*)0, 3, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"\", 3, PR_FALSE, 0 },\n-                  { \"\", \"aeiou\", 3, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ae\", 0, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ae\", 1, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"ae\", 4, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"ae\", 5, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"ae\", 6, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"ei\", 4, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"io\", 10, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"bcd\", 2, PR_TRUE, 1 },\n-                  { \"abcdefg\", \"cbd\", 2, PR_TRUE, 1 },\n-                  { \"abcdefg\", \"dbc\", 2, PR_TRUE, 1 },\n-                  { \"abcdefg\", \"ghi\", 6, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ghi\", 7, PR_TRUE, 6 },\n-                  { \"abcdefg\", \"AE\", 9, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"EI\", 9, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"IO\", 9, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"BCD\", 9, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"CBD\", 9, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"DBC\", 9, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"GHI\", 9, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"ae\", 10, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"ei\", 10, PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", \"io\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"bcd\", 10, PR_TRUE, 1 },\n-                  { \"abcdefgabcdefg\", \"cbd\", 10, PR_TRUE, 1 },\n-                  { \"abcdefgabcdefg\", \"dbc\", 10, PR_TRUE, 1 },\n-                  { \"abcdefgabcdefg\", \"ghi\", 10, PR_TRUE, 6 },\n-                  { \"abcdefgabcdefg\", \"AE\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"EI\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"IO\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"BCD\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"CBD\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"DBC\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"GHI\", 10, PR_FALSE, 0 } };\n-\n-    int i;\n-\n-    printf(\"Test 021 (PL_strnpbrk)    ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strnpbrk(array[i].str, array[i].chrs, array[i].max);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> %.32s, not null\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].chrs ? array[i].chrs : \"(null)\", array[i].max, rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> null, not +%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].chrs ? array[i].chrs : \"(null)\", array[i].max,\n-                       array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> 0x%x, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].chrs ? array[i].chrs : \"(null)\", array[i].max, rv,\n-                       array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_021(void) {\n+  static struct {\n+    const char* str;\n+    const char* chrs;\n+    PRUint32 max;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, (const char*)0, 3, PR_FALSE, 0},\n+               {(const char*)0, \"abc\", 3, PR_FALSE, 0},\n+               {\"abc\", (const char*)0, 3, PR_FALSE, 0},\n+               {\"abcdefg\", \"\", 3, PR_FALSE, 0},\n+               {\"\", \"aeiou\", 3, PR_FALSE, 0},\n+               {\"abcdefg\", \"ae\", 0, PR_FALSE, 0},\n+               {\"abcdefg\", \"ae\", 1, PR_TRUE, 0},\n+               {\"abcdefg\", \"ae\", 4, PR_TRUE, 0},\n+               {\"abcdefg\", \"ae\", 5, PR_TRUE, 0},\n+               {\"abcdefg\", \"ae\", 6, PR_TRUE, 0},\n+               {\"abcdefg\", \"ei\", 4, PR_FALSE, 0},\n+               {\"abcdefg\", \"io\", 10, PR_FALSE, 0},\n+               {\"abcdefg\", \"bcd\", 2, PR_TRUE, 1},\n+               {\"abcdefg\", \"cbd\", 2, PR_TRUE, 1},\n+               {\"abcdefg\", \"dbc\", 2, PR_TRUE, 1},\n+               {\"abcdefg\", \"ghi\", 6, PR_FALSE, 0},\n+               {\"abcdefg\", \"ghi\", 7, PR_TRUE, 6},\n+               {\"abcdefg\", \"AE\", 9, PR_FALSE, 0},\n+               {\"abcdefg\", \"EI\", 9, PR_FALSE, 0},\n+               {\"abcdefg\", \"IO\", 9, PR_FALSE, 0},\n+               {\"abcdefg\", \"BCD\", 9, PR_FALSE, 0},\n+               {\"abcdefg\", \"CBD\", 9, PR_FALSE, 0},\n+               {\"abcdefg\", \"DBC\", 9, PR_FALSE, 0},\n+               {\"abcdefg\", \"GHI\", 9, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"ae\", 10, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"ei\", 10, PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", \"io\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"bcd\", 10, PR_TRUE, 1},\n+               {\"abcdefgabcdefg\", \"cbd\", 10, PR_TRUE, 1},\n+               {\"abcdefgabcdefg\", \"dbc\", 10, PR_TRUE, 1},\n+               {\"abcdefgabcdefg\", \"ghi\", 10, PR_TRUE, 6},\n+               {\"abcdefgabcdefg\", \"AE\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"EI\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"IO\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"BCD\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"CBD\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"DBC\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"GHI\", 10, PR_FALSE, 0}};\n+\n+  int i;\n+\n+  printf(\"Test 021 (PL_strnpbrk)    ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strnpbrk(array[i].str, array[i].chrs, array[i].max);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> %.32s, not null\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].chrs ? array[i].chrs : \"(null)\", array[i].max, rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> null, not +%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].chrs ? array[i].chrs : \"(null)\", array[i].max,\n+               array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> 0x%x, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].chrs ? array[i].chrs : \"(null)\", array[i].max, rv,\n+               array[i].str, array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strnprbrk */\n-PRBool\n-test_022(void)\n-{\n-    static struct {\n-        const char* str;\n-        const char* chrs;\n-        PRUint32 max;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, (const char*)0, 3, PR_FALSE, 0 },\n-                  { (const char*)0, \"abc\", 3, PR_FALSE, 0 },\n-                  { \"abc\", (const char*)0, 3, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"\", 3, PR_FALSE, 0 },\n-                  { \"\", \"aeiou\", 3, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ae\", 0, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ae\", 1, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"ae\", 4, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"ae\", 5, PR_TRUE, 4 },\n-                  { \"abcdefg\", \"ae\", 6, PR_TRUE, 4 },\n-                  { \"abcdefg\", \"ei\", 4, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"io\", 10, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"bcd\", 2, PR_TRUE, 1 },\n-                  { \"abcdefg\", \"cbd\", 2, PR_TRUE, 1 },\n-                  { \"abcdefg\", \"dbc\", 2, PR_TRUE, 1 },\n-                  { \"abcdefg\", \"bcd\", 3, PR_TRUE, 2 },\n-                  { \"abcdefg\", \"cbd\", 3, PR_TRUE, 2 },\n-                  { \"abcdefg\", \"dbc\", 3, PR_TRUE, 2 },\n-                  { \"abcdefg\", \"bcd\", 5, PR_TRUE, 3 },\n-                  { \"abcdefg\", \"cbd\", 5, PR_TRUE, 3 },\n-                  { \"abcdefg\", \"dbc\", 5, PR_TRUE, 3 },\n-                  { \"abcdefg\", \"bcd\", 15, PR_TRUE, 3 },\n-                  { \"abcdefg\", \"cbd\", 15, PR_TRUE, 3 },\n-                  { \"abcdefg\", \"dbc\", 15, PR_TRUE, 3 },\n-                  { \"abcdefg\", \"ghi\", 6, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ghi\", 7, PR_TRUE, 6 },\n-                  { \"abcdefg\", \"AE\", 9, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"EI\", 9, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"IO\", 9, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"BCD\", 9, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"CBD\", 9, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"DBC\", 9, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"GHI\", 9, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"ae\", 10, PR_TRUE, 7 },\n-                  { \"abcdefgabcdefg\", \"ei\", 10, PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", \"io\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"bcd\", 10, PR_TRUE, 9 },\n-                  { \"abcdefgabcdefg\", \"cbd\", 10, PR_TRUE, 9 },\n-                  { \"abcdefgabcdefg\", \"dbc\", 10, PR_TRUE, 9 },\n-                  { \"abcdefgabcdefg\", \"ghi\", 10, PR_TRUE, 6 },\n-                  { \"abcdefgabcdefg\", \"AE\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"EI\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"IO\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"BCD\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"CBD\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"DBC\", 10, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"GHI\", 10, PR_FALSE, 0 } };\n-\n-    int i;\n-\n-    printf(\"Test 022 (PL_strnprbrk)   ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strnprbrk(array[i].str, array[i].chrs, array[i].max);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> %.32s, not null\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].chrs ? array[i].chrs : \"(null)\", array[i].max, rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> null, not +%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].chrs ? array[i].chrs : \"(null)\", array[i].max,\n-                       array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> 0x%x, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].chrs ? array[i].chrs : \"(null)\", array[i].max, rv,\n-                       array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_022(void) {\n+  static struct {\n+    const char* str;\n+    const char* chrs;\n+    PRUint32 max;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, (const char*)0, 3, PR_FALSE, 0},\n+               {(const char*)0, \"abc\", 3, PR_FALSE, 0},\n+               {\"abc\", (const char*)0, 3, PR_FALSE, 0},\n+               {\"abcdefg\", \"\", 3, PR_FALSE, 0},\n+               {\"\", \"aeiou\", 3, PR_FALSE, 0},\n+               {\"abcdefg\", \"ae\", 0, PR_FALSE, 0},\n+               {\"abcdefg\", \"ae\", 1, PR_TRUE, 0},\n+               {\"abcdefg\", \"ae\", 4, PR_TRUE, 0},\n+               {\"abcdefg\", \"ae\", 5, PR_TRUE, 4},\n+               {\"abcdefg\", \"ae\", 6, PR_TRUE, 4},\n+               {\"abcdefg\", \"ei\", 4, PR_FALSE, 0},\n+               {\"abcdefg\", \"io\", 10, PR_FALSE, 0},\n+               {\"abcdefg\", \"bcd\", 2, PR_TRUE, 1},\n+               {\"abcdefg\", \"cbd\", 2, PR_TRUE, 1},\n+               {\"abcdefg\", \"dbc\", 2, PR_TRUE, 1},\n+               {\"abcdefg\", \"bcd\", 3, PR_TRUE, 2},\n+               {\"abcdefg\", \"cbd\", 3, PR_TRUE, 2},\n+               {\"abcdefg\", \"dbc\", 3, PR_TRUE, 2},\n+               {\"abcdefg\", \"bcd\", 5, PR_TRUE, 3},\n+               {\"abcdefg\", \"cbd\", 5, PR_TRUE, 3},\n+               {\"abcdefg\", \"dbc\", 5, PR_TRUE, 3},\n+               {\"abcdefg\", \"bcd\", 15, PR_TRUE, 3},\n+               {\"abcdefg\", \"cbd\", 15, PR_TRUE, 3},\n+               {\"abcdefg\", \"dbc\", 15, PR_TRUE, 3},\n+               {\"abcdefg\", \"ghi\", 6, PR_FALSE, 0},\n+               {\"abcdefg\", \"ghi\", 7, PR_TRUE, 6},\n+               {\"abcdefg\", \"AE\", 9, PR_FALSE, 0},\n+               {\"abcdefg\", \"EI\", 9, PR_FALSE, 0},\n+               {\"abcdefg\", \"IO\", 9, PR_FALSE, 0},\n+               {\"abcdefg\", \"BCD\", 9, PR_FALSE, 0},\n+               {\"abcdefg\", \"CBD\", 9, PR_FALSE, 0},\n+               {\"abcdefg\", \"DBC\", 9, PR_FALSE, 0},\n+               {\"abcdefg\", \"GHI\", 9, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"ae\", 10, PR_TRUE, 7},\n+               {\"abcdefgabcdefg\", \"ei\", 10, PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", \"io\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"bcd\", 10, PR_TRUE, 9},\n+               {\"abcdefgabcdefg\", \"cbd\", 10, PR_TRUE, 9},\n+               {\"abcdefgabcdefg\", \"dbc\", 10, PR_TRUE, 9},\n+               {\"abcdefgabcdefg\", \"ghi\", 10, PR_TRUE, 6},\n+               {\"abcdefgabcdefg\", \"AE\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"EI\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"IO\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"BCD\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"CBD\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"DBC\", 10, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"GHI\", 10, PR_FALSE, 0}};\n+\n+  int i;\n+\n+  printf(\"Test 022 (PL_strnprbrk)   ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strnprbrk(array[i].str, array[i].chrs, array[i].max);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> %.32s, not null\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].chrs ? array[i].chrs : \"(null)\", array[i].max, rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> null, not +%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].chrs ? array[i].chrs : \"(null)\", array[i].max,\n+               array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> 0x%x, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].chrs ? array[i].chrs : \"(null)\", array[i].max, rv,\n+               array[i].str, array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strstr */\n-PRBool\n-test_023(void)\n-{\n-    static struct {\n-        const char* str;\n-        const char* sub;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, (const char*)0, PR_FALSE, 0 },\n-                  { (const char*)0, \"blah\", PR_FALSE, 0 },\n-                  { \"blah-de-blah\", (const char*)0, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", PR_TRUE, 0 },\n-                  { \"\", \"blah\", PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"a\", PR_TRUE, 0 },\n-                  { \"abcdefg\", \"c\", PR_TRUE, 2 },\n-                  { \"abcdefg\", \"e\", PR_TRUE, 4 },\n-                  { \"abcdefg\", \"g\", PR_TRUE, 6 },\n-                  { \"abcdefg\", \"i\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ab\", PR_TRUE, 0 },\n-                  { \"abcdefg\", \"cd\", PR_TRUE, 2 },\n-                  { \"abcdefg\", \"ef\", PR_TRUE, 4 },\n-                  { \"abcdefg\", \"gh\", PR_FALSE, 0 },\n-                  { \"abcdabc\", \"bc\", PR_TRUE, 1 },\n-                  { \"abcdefg\", \"abcdefg\", PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"a\", PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"c\", PR_TRUE, 2 },\n-                  { \"abcdefgabcdefg\", \"e\", PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", \"g\", PR_TRUE, 6 },\n-                  { \"abcdefgabcdefg\", \"i\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"ab\", PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"cd\", PR_TRUE, 2 },\n-                  { \"abcdefgabcdefg\", \"ef\", PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", \"gh\", PR_FALSE, 0 },\n-                  { \"abcdabcabcdabc\", \"bc\", PR_TRUE, 1 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"a\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"c\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"e\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"g\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"i\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"ab\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"cd\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"ef\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"gh\", PR_FALSE, 0 },\n-                  { \"ABCDABC\", \"bc\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"abcdefg\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"a\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"c\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"e\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"g\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"i\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"ab\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"cd\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"ef\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"gh\", PR_FALSE, 0 },\n-                  { \"ABCDABCABCDABC\", \"bc\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", PR_FALSE, 0 } };\n-\n-    int i;\n-\n-    printf(\"Test 023 (PL_strstr)      ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strstr(array[i].str, array[i].sub);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%s -> %.32s, not null\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%s -> null, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].str,\n-                       array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%s -> 0x%x, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", rv, array[i].str,\n-                       array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_023(void) {\n+  static struct {\n+    const char* str;\n+    const char* sub;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, (const char*)0, PR_FALSE, 0},\n+               {(const char*)0, \"blah\", PR_FALSE, 0},\n+               {\"blah-de-blah\", (const char*)0, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", PR_TRUE, 0},\n+               {\"\", \"blah\", PR_FALSE, 0},\n+               {\"blah-de-blah\", \"\", PR_FALSE, 0},\n+               {\"abcdefg\", \"a\", PR_TRUE, 0},\n+               {\"abcdefg\", \"c\", PR_TRUE, 2},\n+               {\"abcdefg\", \"e\", PR_TRUE, 4},\n+               {\"abcdefg\", \"g\", PR_TRUE, 6},\n+               {\"abcdefg\", \"i\", PR_FALSE, 0},\n+               {\"abcdefg\", \"ab\", PR_TRUE, 0},\n+               {\"abcdefg\", \"cd\", PR_TRUE, 2},\n+               {\"abcdefg\", \"ef\", PR_TRUE, 4},\n+               {\"abcdefg\", \"gh\", PR_FALSE, 0},\n+               {\"abcdabc\", \"bc\", PR_TRUE, 1},\n+               {\"abcdefg\", \"abcdefg\", PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"a\", PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"c\", PR_TRUE, 2},\n+               {\"abcdefgabcdefg\", \"e\", PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", \"g\", PR_TRUE, 6},\n+               {\"abcdefgabcdefg\", \"i\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"ab\", PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"cd\", PR_TRUE, 2},\n+               {\"abcdefgabcdefg\", \"ef\", PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", \"gh\", PR_FALSE, 0},\n+               {\"abcdabcabcdabc\", \"bc\", PR_TRUE, 1},\n+               {\"abcdefgabcdefg\", \"abcdefg\", PR_TRUE, 0},\n+               {\"ABCDEFG\", \"a\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"c\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"e\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"g\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"i\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"ab\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"cd\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"ef\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"gh\", PR_FALSE, 0},\n+               {\"ABCDABC\", \"bc\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"abcdefg\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"a\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"c\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"e\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"g\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"i\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"ab\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"cd\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"ef\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"gh\", PR_FALSE, 0},\n+               {\"ABCDABCABCDABC\", \"bc\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", PR_FALSE, 0}};\n+\n+  int i;\n+\n+  printf(\"Test 023 (PL_strstr)      ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strstr(array[i].str, array[i].sub);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%s -> %.32s, not null\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%s -> null, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].str,\n+               array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%s -> 0x%x, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", rv, array[i].str,\n+               array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strrstr */\n-PRBool\n-test_024(void)\n-{\n-    static struct {\n-        const char* str;\n-        const char* sub;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, (const char*)0, PR_FALSE, 0 },\n-                  { (const char*)0, \"blah\", PR_FALSE, 0 },\n-                  { \"blah-de-blah\", (const char*)0, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", PR_TRUE, 8 },\n-                  { \"\", \"blah\", PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"a\", PR_TRUE, 0 },\n-                  { \"abcdefg\", \"c\", PR_TRUE, 2 },\n-                  { \"abcdefg\", \"e\", PR_TRUE, 4 },\n-                  { \"abcdefg\", \"g\", PR_TRUE, 6 },\n-                  { \"abcdefg\", \"i\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ab\", PR_TRUE, 0 },\n-                  { \"abcdefg\", \"cd\", PR_TRUE, 2 },\n-                  { \"abcdefg\", \"ef\", PR_TRUE, 4 },\n-                  { \"abcdefg\", \"gh\", PR_FALSE, 0 },\n-                  { \"abcdabc\", \"bc\", PR_TRUE, 5 },\n-                  { \"abcdefg\", \"abcdefg\", PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"a\", PR_TRUE, 7 },\n-                  { \"abcdefgabcdefg\", \"c\", PR_TRUE, 9 },\n-                  { \"abcdefgabcdefg\", \"e\", PR_TRUE, 11 },\n-                  { \"abcdefgabcdefg\", \"g\", PR_TRUE, 13 },\n-                  { \"abcdefgabcdefg\", \"i\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"ab\", PR_TRUE, 7 },\n-                  { \"abcdefgabcdefg\", \"cd\", PR_TRUE, 9 },\n-                  { \"abcdefgabcdefg\", \"ef\", PR_TRUE, 11 },\n-                  { \"abcdefgabcdefg\", \"gh\", PR_FALSE, 0 },\n-                  { \"abcdabcabcdabc\", \"bc\", PR_TRUE, 12 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", PR_TRUE, 7 },\n-                  { \"ABCDEFG\", \"a\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"c\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"e\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"g\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"i\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"ab\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"cd\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"ef\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"gh\", PR_FALSE, 0 },\n-                  { \"ABCDABC\", \"bc\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"abcdefg\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"a\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"c\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"e\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"g\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"i\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"ab\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"cd\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"ef\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"gh\", PR_FALSE, 0 },\n-                  { \"ABCDABCABCDABC\", \"bc\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", PR_FALSE, 0 } };\n-\n-    int i;\n-\n-    printf(\"Test 024 (PL_strrstr)     ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strrstr(array[i].str, array[i].sub);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%s -> %.32s, not null\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%s -> null, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].str,\n-                       array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%s -> 0x%x, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", rv, array[i].str,\n-                       array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_024(void) {\n+  static struct {\n+    const char* str;\n+    const char* sub;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, (const char*)0, PR_FALSE, 0},\n+               {(const char*)0, \"blah\", PR_FALSE, 0},\n+               {\"blah-de-blah\", (const char*)0, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", PR_TRUE, 8},\n+               {\"\", \"blah\", PR_FALSE, 0},\n+               {\"blah-de-blah\", \"\", PR_FALSE, 0},\n+               {\"abcdefg\", \"a\", PR_TRUE, 0},\n+               {\"abcdefg\", \"c\", PR_TRUE, 2},\n+               {\"abcdefg\", \"e\", PR_TRUE, 4},\n+               {\"abcdefg\", \"g\", PR_TRUE, 6},\n+               {\"abcdefg\", \"i\", PR_FALSE, 0},\n+               {\"abcdefg\", \"ab\", PR_TRUE, 0},\n+               {\"abcdefg\", \"cd\", PR_TRUE, 2},\n+               {\"abcdefg\", \"ef\", PR_TRUE, 4},\n+               {\"abcdefg\", \"gh\", PR_FALSE, 0},\n+               {\"abcdabc\", \"bc\", PR_TRUE, 5},\n+               {\"abcdefg\", \"abcdefg\", PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"a\", PR_TRUE, 7},\n+               {\"abcdefgabcdefg\", \"c\", PR_TRUE, 9},\n+               {\"abcdefgabcdefg\", \"e\", PR_TRUE, 11},\n+               {\"abcdefgabcdefg\", \"g\", PR_TRUE, 13},\n+               {\"abcdefgabcdefg\", \"i\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"ab\", PR_TRUE, 7},\n+               {\"abcdefgabcdefg\", \"cd\", PR_TRUE, 9},\n+               {\"abcdefgabcdefg\", \"ef\", PR_TRUE, 11},\n+               {\"abcdefgabcdefg\", \"gh\", PR_FALSE, 0},\n+               {\"abcdabcabcdabc\", \"bc\", PR_TRUE, 12},\n+               {\"abcdefgabcdefg\", \"abcdefg\", PR_TRUE, 7},\n+               {\"ABCDEFG\", \"a\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"c\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"e\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"g\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"i\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"ab\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"cd\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"ef\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"gh\", PR_FALSE, 0},\n+               {\"ABCDABC\", \"bc\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"abcdefg\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"a\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"c\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"e\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"g\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"i\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"ab\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"cd\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"ef\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"gh\", PR_FALSE, 0},\n+               {\"ABCDABCABCDABC\", \"bc\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", PR_FALSE, 0}};\n+\n+  int i;\n+\n+  printf(\"Test 024 (PL_strrstr)     ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strrstr(array[i].str, array[i].sub);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%s -> %.32s, not null\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%s -> null, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].str,\n+               array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%s -> 0x%x, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", rv, array[i].str,\n+               array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strnstr */\n-PRBool\n-test_025(void)\n-{\n-    static struct {\n-        const char* str;\n-        const char* sub;\n-        PRUint32 max;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, (const char*)0, 12, PR_FALSE, 0 },\n-                  { (const char*)0, \"blah\", 12, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", (const char*)0, 12, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 0, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 2, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 3, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 4, PR_TRUE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 5, PR_TRUE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 12, PR_TRUE, 0 },\n-                  { \"\", \"blah\", 12, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"\", 12, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"a\", 5, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"c\", 5, PR_TRUE, 2 },\n-                  { \"abcdefg\", \"e\", 5, PR_TRUE, 4 },\n-                  { \"abcdefg\", \"g\", 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"i\", 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ab\", 5, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"cd\", 5, PR_TRUE, 2 },\n-                  { \"abcdefg\", \"ef\", 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"gh\", 5, PR_FALSE, 0 },\n-                  { \"abcdabc\", \"bc\", 5, PR_TRUE, 1 },\n-                  { \"abcdabc\", \"bc\", 6, PR_TRUE, 1 },\n-                  { \"abcdabc\", \"bc\", 7, PR_TRUE, 1 },\n-                  { \"abcdefg\", \"abcdefg\", 6, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"abcdefg\", 7, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"abcdefg\", 8, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"a\", 12, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"c\", 12, PR_TRUE, 2 },\n-                  { \"abcdefgabcdefg\", \"e\", 12, PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", \"g\", 12, PR_TRUE, 6 },\n-                  { \"abcdefgabcdefg\", \"i\", 12, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"ab\", 12, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"cd\", 12, PR_TRUE, 2 },\n-                  { \"abcdefgabcdefg\", \"ef\", 12, PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", \"gh\", 12, PR_FALSE, 0 },\n-                  { \"abcdabcabcdabc\", \"bc\", 5, PR_TRUE, 1 },\n-                  { \"abcdabcabcdabc\", \"bc\", 6, PR_TRUE, 1 },\n-                  { \"abcdabcabcdabc\", \"bc\", 7, PR_TRUE, 1 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", 6, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", 7, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", 8, PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"a\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"c\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"e\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"g\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"i\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"ab\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"cd\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"ef\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"gh\", 5, PR_FALSE, 0 },\n-                  { \"ABCDABC\", \"bc\", 5, PR_FALSE, 0 },\n-                  { \"ABCDABC\", \"bc\", 6, PR_FALSE, 0 },\n-                  { \"ABCDABC\", \"bc\", 7, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"abcdefg\", 6, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"abcdefg\", 7, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"abcdefg\", 8, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"a\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"c\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"e\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"g\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"i\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"ab\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"cd\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"ef\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"gh\", 12, PR_FALSE, 0 },\n-                  { \"ABCDABCABCDABC\", \"bc\", 5, PR_FALSE, 0 },\n-                  { \"ABCDABCABCDABC\", \"bc\", 6, PR_FALSE, 0 },\n-                  {\n-                      \"ABCDABCABCDABC\",\n-                      \"bc\",\n-                      7,\n-                      PR_FALSE,\n-                  },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", 6, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", 7, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", 8, PR_FALSE, 0 } };\n-\n-    int i;\n-\n-    printf(\"Test 025 (PL_strnstr)     ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strnstr(array[i].str, array[i].sub, array[i].max);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> %.32s, not null\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> null, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].max,\n-                       array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> 0x%x, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv,\n-                       array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_025(void) {\n+  static struct {\n+    const char* str;\n+    const char* sub;\n+    PRUint32 max;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, (const char*)0, 12, PR_FALSE, 0},\n+               {(const char*)0, \"blah\", 12, PR_FALSE, 0},\n+               {\"blah-de-blah\", (const char*)0, 12, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 0, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 2, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 3, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 4, PR_TRUE, 0},\n+               {\"blah-de-blah\", \"blah\", 5, PR_TRUE, 0},\n+               {\"blah-de-blah\", \"blah\", 12, PR_TRUE, 0},\n+               {\"\", \"blah\", 12, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"\", 12, PR_FALSE, 0},\n+               {\"abcdefg\", \"a\", 5, PR_TRUE, 0},\n+               {\"abcdefg\", \"c\", 5, PR_TRUE, 2},\n+               {\"abcdefg\", \"e\", 5, PR_TRUE, 4},\n+               {\"abcdefg\", \"g\", 5, PR_FALSE, 0},\n+               {\"abcdefg\", \"i\", 5, PR_FALSE, 0},\n+               {\"abcdefg\", \"ab\", 5, PR_TRUE, 0},\n+               {\"abcdefg\", \"cd\", 5, PR_TRUE, 2},\n+               {\"abcdefg\", \"ef\", 5, PR_FALSE, 0},\n+               {\"abcdefg\", \"gh\", 5, PR_FALSE, 0},\n+               {\"abcdabc\", \"bc\", 5, PR_TRUE, 1},\n+               {\"abcdabc\", \"bc\", 6, PR_TRUE, 1},\n+               {\"abcdabc\", \"bc\", 7, PR_TRUE, 1},\n+               {\"abcdefg\", \"abcdefg\", 6, PR_FALSE, 0},\n+               {\"abcdefg\", \"abcdefg\", 7, PR_TRUE, 0},\n+               {\"abcdefg\", \"abcdefg\", 8, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"a\", 12, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"c\", 12, PR_TRUE, 2},\n+               {\"abcdefgabcdefg\", \"e\", 12, PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", \"g\", 12, PR_TRUE, 6},\n+               {\"abcdefgabcdefg\", \"i\", 12, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"ab\", 12, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"cd\", 12, PR_TRUE, 2},\n+               {\"abcdefgabcdefg\", \"ef\", 12, PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", \"gh\", 12, PR_FALSE, 0},\n+               {\"abcdabcabcdabc\", \"bc\", 5, PR_TRUE, 1},\n+               {\"abcdabcabcdabc\", \"bc\", 6, PR_TRUE, 1},\n+               {\"abcdabcabcdabc\", \"bc\", 7, PR_TRUE, 1},\n+               {\"abcdefgabcdefg\", \"abcdefg\", 6, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"abcdefg\", 7, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"abcdefg\", 8, PR_TRUE, 0},\n+               {\"ABCDEFG\", \"a\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"c\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"e\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"g\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"i\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"ab\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"cd\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"ef\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"gh\", 5, PR_FALSE, 0},\n+               {\"ABCDABC\", \"bc\", 5, PR_FALSE, 0},\n+               {\"ABCDABC\", \"bc\", 6, PR_FALSE, 0},\n+               {\"ABCDABC\", \"bc\", 7, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"abcdefg\", 6, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"abcdefg\", 7, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"abcdefg\", 8, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"a\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"c\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"e\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"g\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"i\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"ab\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"cd\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"ef\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"gh\", 12, PR_FALSE, 0},\n+               {\"ABCDABCABCDABC\", \"bc\", 5, PR_FALSE, 0},\n+               {\"ABCDABCABCDABC\", \"bc\", 6, PR_FALSE, 0},\n+               {\n+                   \"ABCDABCABCDABC\",\n+                   \"bc\",\n+                   7,\n+                   PR_FALSE,\n+               },\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", 6, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", 7, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", 8, PR_FALSE, 0}};\n+\n+  int i;\n+\n+  printf(\"Test 025 (PL_strnstr)     ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strnstr(array[i].str, array[i].sub, array[i].max);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> %.32s, not null\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> null, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].max,\n+               array[i].str, array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> 0x%x, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv,\n+               array[i].str, array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strnrstr */\n-PRBool\n-test_026(void)\n-{\n-    static struct {\n-        const char* str;\n-        const char* sub;\n-        PRUint32 max;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, (const char*)0, 12, PR_FALSE, 0 },\n-                  { (const char*)0, \"blah\", 12, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", (const char*)0, 12, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 0, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 2, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 3, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 4, PR_TRUE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 5, PR_TRUE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 11, PR_TRUE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 12, PR_TRUE, 8 },\n-                  { \"blah-de-blah\", \"blah\", 13, PR_TRUE, 8 },\n-                  { \"\", \"blah\", 12, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"\", 12, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"a\", 5, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"c\", 5, PR_TRUE, 2 },\n-                  { \"abcdefg\", \"e\", 5, PR_TRUE, 4 },\n-                  { \"abcdefg\", \"g\", 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"i\", 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ab\", 5, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"cd\", 5, PR_TRUE, 2 },\n-                  { \"abcdefg\", \"ef\", 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"gh\", 5, PR_FALSE, 0 },\n-                  { \"abcdabc\", \"bc\", 5, PR_TRUE, 1 },\n-                  { \"abcdabc\", \"bc\", 6, PR_TRUE, 1 },\n-                  { \"abcdabc\", \"bc\", 7, PR_TRUE, 5 },\n-                  { \"abcdefg\", \"abcdefg\", 6, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"abcdefg\", 7, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"abcdefg\", 8, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"a\", 12, PR_TRUE, 7 },\n-                  { \"abcdefgabcdefg\", \"c\", 12, PR_TRUE, 9 },\n-                  { \"abcdefgabcdefg\", \"e\", 12, PR_TRUE, 11 },\n-                  { \"abcdefgabcdefg\", \"g\", 12, PR_TRUE, 6 },\n-                  { \"abcdefgabcdefg\", \"i\", 12, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"ab\", 12, PR_TRUE, 7 },\n-                  { \"abcdefgabcdefg\", \"cd\", 12, PR_TRUE, 9 },\n-                  { \"abcdefgabcdefg\", \"ef\", 12, PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", \"gh\", 12, PR_FALSE, 0 },\n-                  { \"abcdabcabcdabc\", \"bc\", 12, PR_TRUE, 8 },\n-                  { \"abcdabcabcdabc\", \"bc\", 13, PR_TRUE, 8 },\n-                  { \"abcdabcabcdabc\", \"bc\", 14, PR_TRUE, 12 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", 13, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", 14, PR_TRUE, 7 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", 15, PR_TRUE, 7 },\n-                  { \"ABCDEFG\", \"a\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"c\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"e\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"g\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"i\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"ab\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"cd\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"ef\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"gh\", 5, PR_FALSE, 0 },\n-                  { \"ABCDABC\", \"bc\", 5, PR_FALSE, 0 },\n-                  { \"ABCDABC\", \"bc\", 6, PR_FALSE, 0 },\n-                  { \"ABCDABC\", \"bc\", 7, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"abcdefg\", 6, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"abcdefg\", 7, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"abcdefg\", 8, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"a\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"c\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"e\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"g\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"i\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"ab\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"cd\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"ef\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"gh\", 12, PR_FALSE, 0 },\n-                  { \"ABCDABCABCDABC\", \"bc\", 12, PR_FALSE, 0 },\n-                  { \"ABCDABCABCDABC\", \"bc\", 13, PR_FALSE, 0 },\n-                  { \"ABCDABCABCDABC\", \"bc\", 14, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", 13, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", 14, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", 15, PR_FALSE, 0 } };\n-\n-    int i;\n-\n-    printf(\"Test 026 (PL_strnrstr)    ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strnrstr(array[i].str, array[i].sub, array[i].max);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> %.32s, not null\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> null, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].max,\n-                       array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> 0x%x, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv,\n-                       array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_026(void) {\n+  static struct {\n+    const char* str;\n+    const char* sub;\n+    PRUint32 max;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, (const char*)0, 12, PR_FALSE, 0},\n+               {(const char*)0, \"blah\", 12, PR_FALSE, 0},\n+               {\"blah-de-blah\", (const char*)0, 12, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 0, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 2, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 3, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 4, PR_TRUE, 0},\n+               {\"blah-de-blah\", \"blah\", 5, PR_TRUE, 0},\n+               {\"blah-de-blah\", \"blah\", 11, PR_TRUE, 0},\n+               {\"blah-de-blah\", \"blah\", 12, PR_TRUE, 8},\n+               {\"blah-de-blah\", \"blah\", 13, PR_TRUE, 8},\n+               {\"\", \"blah\", 12, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"\", 12, PR_FALSE, 0},\n+               {\"abcdefg\", \"a\", 5, PR_TRUE, 0},\n+               {\"abcdefg\", \"c\", 5, PR_TRUE, 2},\n+               {\"abcdefg\", \"e\", 5, PR_TRUE, 4},\n+               {\"abcdefg\", \"g\", 5, PR_FALSE, 0},\n+               {\"abcdefg\", \"i\", 5, PR_FALSE, 0},\n+               {\"abcdefg\", \"ab\", 5, PR_TRUE, 0},\n+               {\"abcdefg\", \"cd\", 5, PR_TRUE, 2},\n+               {\"abcdefg\", \"ef\", 5, PR_FALSE, 0},\n+               {\"abcdefg\", \"gh\", 5, PR_FALSE, 0},\n+               {\"abcdabc\", \"bc\", 5, PR_TRUE, 1},\n+               {\"abcdabc\", \"bc\", 6, PR_TRUE, 1},\n+               {\"abcdabc\", \"bc\", 7, PR_TRUE, 5},\n+               {\"abcdefg\", \"abcdefg\", 6, PR_FALSE, 0},\n+               {\"abcdefg\", \"abcdefg\", 7, PR_TRUE, 0},\n+               {\"abcdefg\", \"abcdefg\", 8, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"a\", 12, PR_TRUE, 7},\n+               {\"abcdefgabcdefg\", \"c\", 12, PR_TRUE, 9},\n+               {\"abcdefgabcdefg\", \"e\", 12, PR_TRUE, 11},\n+               {\"abcdefgabcdefg\", \"g\", 12, PR_TRUE, 6},\n+               {\"abcdefgabcdefg\", \"i\", 12, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"ab\", 12, PR_TRUE, 7},\n+               {\"abcdefgabcdefg\", \"cd\", 12, PR_TRUE, 9},\n+               {\"abcdefgabcdefg\", \"ef\", 12, PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", \"gh\", 12, PR_FALSE, 0},\n+               {\"abcdabcabcdabc\", \"bc\", 12, PR_TRUE, 8},\n+               {\"abcdabcabcdabc\", \"bc\", 13, PR_TRUE, 8},\n+               {\"abcdabcabcdabc\", \"bc\", 14, PR_TRUE, 12},\n+               {\"abcdefgabcdefg\", \"abcdefg\", 13, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"abcdefg\", 14, PR_TRUE, 7},\n+               {\"abcdefgabcdefg\", \"abcdefg\", 15, PR_TRUE, 7},\n+               {\"ABCDEFG\", \"a\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"c\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"e\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"g\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"i\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"ab\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"cd\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"ef\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"gh\", 5, PR_FALSE, 0},\n+               {\"ABCDABC\", \"bc\", 5, PR_FALSE, 0},\n+               {\"ABCDABC\", \"bc\", 6, PR_FALSE, 0},\n+               {\"ABCDABC\", \"bc\", 7, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"abcdefg\", 6, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"abcdefg\", 7, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"abcdefg\", 8, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"a\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"c\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"e\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"g\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"i\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"ab\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"cd\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"ef\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"gh\", 12, PR_FALSE, 0},\n+               {\"ABCDABCABCDABC\", \"bc\", 12, PR_FALSE, 0},\n+               {\"ABCDABCABCDABC\", \"bc\", 13, PR_FALSE, 0},\n+               {\"ABCDABCABCDABC\", \"bc\", 14, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", 13, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", 14, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", 15, PR_FALSE, 0}};\n+\n+  int i;\n+\n+  printf(\"Test 026 (PL_strnrstr)    ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strnrstr(array[i].str, array[i].sub, array[i].max);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> %.32s, not null\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> null, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].max,\n+               array[i].str, array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> 0x%x, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv,\n+               array[i].str, array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strcasestr */\n-PRBool\n-test_027(void)\n-{\n-    static struct {\n-        const char* str;\n-        const char* sub;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, (const char*)0, PR_FALSE, 0 },\n-                  { (const char*)0, \"blah\", PR_FALSE, 0 },\n-                  { \"blah-de-blah\", (const char*)0, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", PR_TRUE, 0 },\n-                  { \"\", \"blah\", PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"a\", PR_TRUE, 0 },\n-                  { \"abcdefg\", \"c\", PR_TRUE, 2 },\n-                  { \"abcdefg\", \"e\", PR_TRUE, 4 },\n-                  { \"abcdefg\", \"g\", PR_TRUE, 6 },\n-                  { \"abcdefg\", \"i\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ab\", PR_TRUE, 0 },\n-                  { \"abcdefg\", \"cd\", PR_TRUE, 2 },\n-                  { \"abcdefg\", \"ef\", PR_TRUE, 4 },\n-                  { \"abcdefg\", \"gh\", PR_FALSE, 0 },\n-                  { \"abcdabc\", \"bc\", PR_TRUE, 1 },\n-                  { \"abcdefg\", \"abcdefg\", PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"a\", PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"c\", PR_TRUE, 2 },\n-                  { \"abcdefgabcdefg\", \"e\", PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", \"g\", PR_TRUE, 6 },\n-                  { \"abcdefgabcdefg\", \"i\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"ab\", PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"cd\", PR_TRUE, 2 },\n-                  { \"abcdefgabcdefg\", \"ef\", PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", \"gh\", PR_FALSE, 0 },\n-                  { \"abcdabcabcdabc\", \"bc\", PR_TRUE, 1 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"a\", PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"c\", PR_TRUE, 2 },\n-                  { \"ABCDEFG\", \"e\", PR_TRUE, 4 },\n-                  { \"ABCDEFG\", \"g\", PR_TRUE, 6 },\n-                  { \"ABCDEFG\", \"i\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"ab\", PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"cd\", PR_TRUE, 2 },\n-                  { \"ABCDEFG\", \"ef\", PR_TRUE, 4 },\n-                  { \"ABCDEFG\", \"gh\", PR_FALSE, 0 },\n-                  { \"ABCDABC\", \"bc\", PR_TRUE, 1 },\n-                  { \"ABCDEFG\", \"abcdefg\", PR_TRUE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"a\", PR_TRUE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"c\", PR_TRUE, 2 },\n-                  { \"ABCDEFGABCDEFG\", \"e\", PR_TRUE, 4 },\n-                  { \"ABCDEFGABCDEFG\", \"g\", PR_TRUE, 6 },\n-                  { \"ABCDEFGABCDEFG\", \"i\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"ab\", PR_TRUE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"cd\", PR_TRUE, 2 },\n-                  { \"ABCDEFGABCDEFG\", \"ef\", PR_TRUE, 4 },\n-                  { \"ABCDEFGABCDEFG\", \"gh\", PR_FALSE, 0 },\n-                  { \"ABCDABCABCDABC\", \"bc\", PR_TRUE, 1 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", PR_TRUE, 0 } };\n-\n-    int i;\n-\n-    printf(\"Test 027 (PL_strcasestr)  ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strcasestr(array[i].str, array[i].sub);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%s -> %.32s, not null\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%s -> null, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].str,\n-                       array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%s -> 0x%x, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", rv, array[i].str,\n-                       array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_027(void) {\n+  static struct {\n+    const char* str;\n+    const char* sub;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, (const char*)0, PR_FALSE, 0},\n+               {(const char*)0, \"blah\", PR_FALSE, 0},\n+               {\"blah-de-blah\", (const char*)0, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", PR_TRUE, 0},\n+               {\"\", \"blah\", PR_FALSE, 0},\n+               {\"blah-de-blah\", \"\", PR_FALSE, 0},\n+               {\"abcdefg\", \"a\", PR_TRUE, 0},\n+               {\"abcdefg\", \"c\", PR_TRUE, 2},\n+               {\"abcdefg\", \"e\", PR_TRUE, 4},\n+               {\"abcdefg\", \"g\", PR_TRUE, 6},\n+               {\"abcdefg\", \"i\", PR_FALSE, 0},\n+               {\"abcdefg\", \"ab\", PR_TRUE, 0},\n+               {\"abcdefg\", \"cd\", PR_TRUE, 2},\n+               {\"abcdefg\", \"ef\", PR_TRUE, 4},\n+               {\"abcdefg\", \"gh\", PR_FALSE, 0},\n+               {\"abcdabc\", \"bc\", PR_TRUE, 1},\n+               {\"abcdefg\", \"abcdefg\", PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"a\", PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"c\", PR_TRUE, 2},\n+               {\"abcdefgabcdefg\", \"e\", PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", \"g\", PR_TRUE, 6},\n+               {\"abcdefgabcdefg\", \"i\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"ab\", PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"cd\", PR_TRUE, 2},\n+               {\"abcdefgabcdefg\", \"ef\", PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", \"gh\", PR_FALSE, 0},\n+               {\"abcdabcabcdabc\", \"bc\", PR_TRUE, 1},\n+               {\"abcdefgabcdefg\", \"abcdefg\", PR_TRUE, 0},\n+               {\"ABCDEFG\", \"a\", PR_TRUE, 0},\n+               {\"ABCDEFG\", \"c\", PR_TRUE, 2},\n+               {\"ABCDEFG\", \"e\", PR_TRUE, 4},\n+               {\"ABCDEFG\", \"g\", PR_TRUE, 6},\n+               {\"ABCDEFG\", \"i\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"ab\", PR_TRUE, 0},\n+               {\"ABCDEFG\", \"cd\", PR_TRUE, 2},\n+               {\"ABCDEFG\", \"ef\", PR_TRUE, 4},\n+               {\"ABCDEFG\", \"gh\", PR_FALSE, 0},\n+               {\"ABCDABC\", \"bc\", PR_TRUE, 1},\n+               {\"ABCDEFG\", \"abcdefg\", PR_TRUE, 0},\n+               {\"ABCDEFGABCDEFG\", \"a\", PR_TRUE, 0},\n+               {\"ABCDEFGABCDEFG\", \"c\", PR_TRUE, 2},\n+               {\"ABCDEFGABCDEFG\", \"e\", PR_TRUE, 4},\n+               {\"ABCDEFGABCDEFG\", \"g\", PR_TRUE, 6},\n+               {\"ABCDEFGABCDEFG\", \"i\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"ab\", PR_TRUE, 0},\n+               {\"ABCDEFGABCDEFG\", \"cd\", PR_TRUE, 2},\n+               {\"ABCDEFGABCDEFG\", \"ef\", PR_TRUE, 4},\n+               {\"ABCDEFGABCDEFG\", \"gh\", PR_FALSE, 0},\n+               {\"ABCDABCABCDABC\", \"bc\", PR_TRUE, 1},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", PR_TRUE, 0}};\n+\n+  int i;\n+\n+  printf(\"Test 027 (PL_strcasestr)  ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strcasestr(array[i].str, array[i].sub);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%s -> %.32s, not null\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%s -> null, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].str,\n+               array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%s -> 0x%x, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", rv, array[i].str,\n+               array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strcaserstr */\n-PRBool\n-test_028(void)\n-{\n-    static struct {\n-        const char* str;\n-        const char* sub;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, (const char*)0, PR_FALSE, 0 },\n-                  { (const char*)0, \"blah\", PR_FALSE, 0 },\n-                  { \"blah-de-blah\", (const char*)0, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", PR_TRUE, 8 },\n-                  { \"\", \"blah\", PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"a\", PR_TRUE, 0 },\n-                  { \"abcdefg\", \"c\", PR_TRUE, 2 },\n-                  { \"abcdefg\", \"e\", PR_TRUE, 4 },\n-                  { \"abcdefg\", \"g\", PR_TRUE, 6 },\n-                  { \"abcdefg\", \"i\", PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ab\", PR_TRUE, 0 },\n-                  { \"abcdefg\", \"cd\", PR_TRUE, 2 },\n-                  { \"abcdefg\", \"ef\", PR_TRUE, 4 },\n-                  { \"abcdefg\", \"gh\", PR_FALSE, 0 },\n-                  { \"abcdabc\", \"bc\", PR_TRUE, 5 },\n-                  { \"abcdefg\", \"abcdefg\", PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"a\", PR_TRUE, 7 },\n-                  { \"abcdefgabcdefg\", \"c\", PR_TRUE, 9 },\n-                  { \"abcdefgabcdefg\", \"e\", PR_TRUE, 11 },\n-                  { \"abcdefgabcdefg\", \"g\", PR_TRUE, 13 },\n-                  { \"abcdefgabcdefg\", \"i\", PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"ab\", PR_TRUE, 7 },\n-                  { \"abcdefgabcdefg\", \"cd\", PR_TRUE, 9 },\n-                  { \"abcdefgabcdefg\", \"ef\", PR_TRUE, 11 },\n-                  { \"abcdefgabcdefg\", \"gh\", PR_FALSE, 0 },\n-                  { \"abcdabcabcdabc\", \"bc\", PR_TRUE, 12 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", PR_TRUE, 7 },\n-                  { \"ABCDEFG\", \"a\", PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"c\", PR_TRUE, 2 },\n-                  { \"ABCDEFG\", \"e\", PR_TRUE, 4 },\n-                  { \"ABCDEFG\", \"g\", PR_TRUE, 6 },\n-                  { \"ABCDEFG\", \"i\", PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"ab\", PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"cd\", PR_TRUE, 2 },\n-                  { \"ABCDEFG\", \"ef\", PR_TRUE, 4 },\n-                  { \"ABCDEFG\", \"gh\", PR_FALSE, 0 },\n-                  { \"ABCDABC\", \"bc\", PR_TRUE, 5 },\n-                  { \"ABCDEFG\", \"abcdefg\", PR_TRUE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"a\", PR_TRUE, 7 },\n-                  { \"ABCDEFGABCDEFG\", \"c\", PR_TRUE, 9 },\n-                  { \"ABCDEFGABCDEFG\", \"e\", PR_TRUE, 11 },\n-                  { \"ABCDEFGABCDEFG\", \"g\", PR_TRUE, 13 },\n-                  { \"ABCDEFGABCDEFG\", \"i\", PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"ab\", PR_TRUE, 7 },\n-                  { \"ABCDEFGABCDEFG\", \"cd\", PR_TRUE, 9 },\n-                  { \"ABCDEFGABCDEFG\", \"ef\", PR_TRUE, 11 },\n-                  { \"ABCDEFGABCDEFG\", \"gh\", PR_FALSE, 0 },\n-                  { \"ABCDABCABCDABC\", \"bc\", PR_TRUE, 12 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", PR_TRUE, 7 } };\n-\n-    int i;\n-\n-    printf(\"Test 028 (PL_strcaserstr) ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strcaserstr(array[i].str, array[i].sub);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%s -> %.32s, not null\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%s -> null, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].str,\n-                       array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%s -> 0x%x, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", rv, array[i].str,\n-                       array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+PRBool test_028(void) {\n+  static struct {\n+    const char* str;\n+    const char* sub;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, (const char*)0, PR_FALSE, 0},\n+               {(const char*)0, \"blah\", PR_FALSE, 0},\n+               {\"blah-de-blah\", (const char*)0, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", PR_TRUE, 8},\n+               {\"\", \"blah\", PR_FALSE, 0},\n+               {\"blah-de-blah\", \"\", PR_FALSE, 0},\n+               {\"abcdefg\", \"a\", PR_TRUE, 0},\n+               {\"abcdefg\", \"c\", PR_TRUE, 2},\n+               {\"abcdefg\", \"e\", PR_TRUE, 4},\n+               {\"abcdefg\", \"g\", PR_TRUE, 6},\n+               {\"abcdefg\", \"i\", PR_FALSE, 0},\n+               {\"abcdefg\", \"ab\", PR_TRUE, 0},\n+               {\"abcdefg\", \"cd\", PR_TRUE, 2},\n+               {\"abcdefg\", \"ef\", PR_TRUE, 4},\n+               {\"abcdefg\", \"gh\", PR_FALSE, 0},\n+               {\"abcdabc\", \"bc\", PR_TRUE, 5},\n+               {\"abcdefg\", \"abcdefg\", PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"a\", PR_TRUE, 7},\n+               {\"abcdefgabcdefg\", \"c\", PR_TRUE, 9},\n+               {\"abcdefgabcdefg\", \"e\", PR_TRUE, 11},\n+               {\"abcdefgabcdefg\", \"g\", PR_TRUE, 13},\n+               {\"abcdefgabcdefg\", \"i\", PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"ab\", PR_TRUE, 7},\n+               {\"abcdefgabcdefg\", \"cd\", PR_TRUE, 9},\n+               {\"abcdefgabcdefg\", \"ef\", PR_TRUE, 11},\n+               {\"abcdefgabcdefg\", \"gh\", PR_FALSE, 0},\n+               {\"abcdabcabcdabc\", \"bc\", PR_TRUE, 12},\n+               {\"abcdefgabcdefg\", \"abcdefg\", PR_TRUE, 7},\n+               {\"ABCDEFG\", \"a\", PR_TRUE, 0},\n+               {\"ABCDEFG\", \"c\", PR_TRUE, 2},\n+               {\"ABCDEFG\", \"e\", PR_TRUE, 4},\n+               {\"ABCDEFG\", \"g\", PR_TRUE, 6},\n+               {\"ABCDEFG\", \"i\", PR_FALSE, 0},\n+               {\"ABCDEFG\", \"ab\", PR_TRUE, 0},\n+               {\"ABCDEFG\", \"cd\", PR_TRUE, 2},\n+               {\"ABCDEFG\", \"ef\", PR_TRUE, 4},\n+               {\"ABCDEFG\", \"gh\", PR_FALSE, 0},\n+               {\"ABCDABC\", \"bc\", PR_TRUE, 5},\n+               {\"ABCDEFG\", \"abcdefg\", PR_TRUE, 0},\n+               {\"ABCDEFGABCDEFG\", \"a\", PR_TRUE, 7},\n+               {\"ABCDEFGABCDEFG\", \"c\", PR_TRUE, 9},\n+               {\"ABCDEFGABCDEFG\", \"e\", PR_TRUE, 11},\n+               {\"ABCDEFGABCDEFG\", \"g\", PR_TRUE, 13},\n+               {\"ABCDEFGABCDEFG\", \"i\", PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"ab\", PR_TRUE, 7},\n+               {\"ABCDEFGABCDEFG\", \"cd\", PR_TRUE, 9},\n+               {\"ABCDEFGABCDEFG\", \"ef\", PR_TRUE, 11},\n+               {\"ABCDEFGABCDEFG\", \"gh\", PR_FALSE, 0},\n+               {\"ABCDABCABCDABC\", \"bc\", PR_TRUE, 12},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", PR_TRUE, 7}};\n+\n+  int i;\n+\n+  printf(\"Test 028 (PL_strcaserstr) ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strcaserstr(array[i].str, array[i].sub);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%s -> %.32s, not null\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%s -> null, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].str,\n+               array[i].off);\n+        return PR_FALSE;\n+      }\n+\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%s -> 0x%x, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", rv, array[i].str,\n+               array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n /* PL_strncasestr */\n-PRBool\n-test_029(void)\n-{\n-    static struct {\n-        const char* str;\n-        const char* sub;\n-        PRUint32 max;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, (const char*)0, 12, PR_FALSE, 0 },\n-                  { (const char*)0, \"blah\", 12, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", (const char*)0, 12, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 0, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 2, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 3, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 4, PR_TRUE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 5, PR_TRUE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 12, PR_TRUE, 0 },\n-                  { \"\", \"blah\", 12, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"\", 12, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"a\", 5, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"c\", 5, PR_TRUE, 2 },\n-                  { \"abcdefg\", \"e\", 5, PR_TRUE, 4 },\n-                  { \"abcdefg\", \"g\", 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"i\", 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ab\", 5, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"cd\", 5, PR_TRUE, 2 },\n-                  { \"abcdefg\", \"ef\", 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"gh\", 5, PR_FALSE, 0 },\n-                  { \"abcdabc\", \"bc\", 5, PR_TRUE, 1 },\n-                  { \"abcdabc\", \"bc\", 6, PR_TRUE, 1 },\n-                  { \"abcdabc\", \"bc\", 7, PR_TRUE, 1 },\n-                  { \"abcdefg\", \"abcdefg\", 6, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"abcdefg\", 7, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"abcdefg\", 8, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"a\", 12, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"c\", 12, PR_TRUE, 2 },\n-                  { \"abcdefgabcdefg\", \"e\", 12, PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", \"g\", 12, PR_TRUE, 6 },\n-                  { \"abcdefgabcdefg\", \"i\", 12, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"ab\", 12, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"cd\", 12, PR_TRUE, 2 },\n-                  { \"abcdefgabcdefg\", \"ef\", 12, PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", \"gh\", 12, PR_FALSE, 0 },\n-                  { \"abcdabcabcdabc\", \"bc\", 5, PR_TRUE, 1 },\n-                  { \"abcdabcabcdabc\", \"bc\", 6, PR_TRUE, 1 },\n-                  { \"abcdabcabcdabc\", \"bc\", 7, PR_TRUE, 1 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", 6, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", 7, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", 8, PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"a\", 5, PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"c\", 5, PR_TRUE, 2 },\n-                  { \"ABCDEFG\", \"e\", 5, PR_TRUE, 4 },\n-                  { \"ABCDEFG\", \"g\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"i\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"ab\", 5, PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"cd\", 5, PR_TRUE, 2 },\n-                  { \"ABCDEFG\", \"ef\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"gh\", 5, PR_FALSE, 0 },\n-                  { \"ABCDABC\", \"bc\", 5, PR_TRUE, 1 },\n-                  { \"ABCDABC\", \"bc\", 6, PR_TRUE, 1 },\n-                  { \"ABCDABC\", \"bc\", 7, PR_TRUE, 1 },\n-                  { \"ABCDEFG\", \"abcdefg\", 6, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"abcdefg\", 7, PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"abcdefg\", 8, PR_TRUE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"a\", 12, PR_TRUE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"c\", 12, PR_TRUE, 2 },\n-                  { \"ABCDEFGABCDEFG\", \"e\", 12, PR_TRUE, 4 },\n-                  { \"ABCDEFGABCDEFG\", \"g\", 12, PR_TRUE, 6 },\n-                  { \"ABCDEFGABCDEFG\", \"i\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"ab\", 12, PR_TRUE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"cd\", 12, PR_TRUE, 2 },\n-                  { \"ABCDEFGABCDEFG\", \"ef\", 12, PR_TRUE, 4 },\n-                  { \"ABCDEFGABCDEFG\", \"gh\", 12, PR_FALSE, 0 },\n-                  { \"ABCDABCABCDABC\", \"bc\", 5, PR_TRUE, 1 },\n-                  { \"ABCDABCABCDABC\", \"bc\", 6, PR_TRUE, 1 },\n-                  { \"ABCDABCABCDABC\", \"bc\", 7, PR_TRUE, 1 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", 6, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", 7, PR_TRUE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", 8, PR_TRUE, 0 } };\n-\n-    int i;\n-\n-    printf(\"Test 029 (PL_strncasestr) ...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strncasestr(array[i].str, array[i].sub, array[i].max);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> %.32s, not null\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> null, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].max,\n-                       array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> 0x%x, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv,\n-                       array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n-    }\n-\n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n-}\n+PRBool test_029(void) {\n+  static struct {\n+    const char* str;\n+    const char* sub;\n+    PRUint32 max;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, (const char*)0, 12, PR_FALSE, 0},\n+               {(const char*)0, \"blah\", 12, PR_FALSE, 0},\n+               {\"blah-de-blah\", (const char*)0, 12, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 0, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 2, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 3, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 4, PR_TRUE, 0},\n+               {\"blah-de-blah\", \"blah\", 5, PR_TRUE, 0},\n+               {\"blah-de-blah\", \"blah\", 12, PR_TRUE, 0},\n+               {\"\", \"blah\", 12, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"\", 12, PR_FALSE, 0},\n+               {\"abcdefg\", \"a\", 5, PR_TRUE, 0},\n+               {\"abcdefg\", \"c\", 5, PR_TRUE, 2},\n+               {\"abcdefg\", \"e\", 5, PR_TRUE, 4},\n+               {\"abcdefg\", \"g\", 5, PR_FALSE, 0},\n+               {\"abcdefg\", \"i\", 5, PR_FALSE, 0},\n+               {\"abcdefg\", \"ab\", 5, PR_TRUE, 0},\n+               {\"abcdefg\", \"cd\", 5, PR_TRUE, 2},\n+               {\"abcdefg\", \"ef\", 5, PR_FALSE, 0},\n+               {\"abcdefg\", \"gh\", 5, PR_FALSE, 0},\n+               {\"abcdabc\", \"bc\", 5, PR_TRUE, 1},\n+               {\"abcdabc\", \"bc\", 6, PR_TRUE, 1},\n+               {\"abcdabc\", \"bc\", 7, PR_TRUE, 1},\n+               {\"abcdefg\", \"abcdefg\", 6, PR_FALSE, 0},\n+               {\"abcdefg\", \"abcdefg\", 7, PR_TRUE, 0},\n+               {\"abcdefg\", \"abcdefg\", 8, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"a\", 12, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"c\", 12, PR_TRUE, 2},\n+               {\"abcdefgabcdefg\", \"e\", 12, PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", \"g\", 12, PR_TRUE, 6},\n+               {\"abcdefgabcdefg\", \"i\", 12, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"ab\", 12, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"cd\", 12, PR_TRUE, 2},\n+               {\"abcdefgabcdefg\", \"ef\", 12, PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", \"gh\", 12, PR_FALSE, 0},\n+               {\"abcdabcabcdabc\", \"bc\", 5, PR_TRUE, 1},\n+               {\"abcdabcabcdabc\", \"bc\", 6, PR_TRUE, 1},\n+               {\"abcdabcabcdabc\", \"bc\", 7, PR_TRUE, 1},\n+               {\"abcdefgabcdefg\", \"abcdefg\", 6, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"abcdefg\", 7, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"abcdefg\", 8, PR_TRUE, 0},\n+               {\"ABCDEFG\", \"a\", 5, PR_TRUE, 0},\n+               {\"ABCDEFG\", \"c\", 5, PR_TRUE, 2},\n+               {\"ABCDEFG\", \"e\", 5, PR_TRUE, 4},\n+               {\"ABCDEFG\", \"g\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"i\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"ab\", 5, PR_TRUE, 0},\n+               {\"ABCDEFG\", \"cd\", 5, PR_TRUE, 2},\n+               {\"ABCDEFG\", \"ef\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"gh\", 5, PR_FALSE, 0},\n+               {\"ABCDABC\", \"bc\", 5, PR_TRUE, 1},\n+               {\"ABCDABC\", \"bc\", 6, PR_TRUE, 1},\n+               {\"ABCDABC\", \"bc\", 7, PR_TRUE, 1},\n+               {\"ABCDEFG\", \"abcdefg\", 6, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"abcdefg\", 7, PR_TRUE, 0},\n+               {\"ABCDEFG\", \"abcdefg\", 8, PR_TRUE, 0},\n+               {\"ABCDEFGABCDEFG\", \"a\", 12, PR_TRUE, 0},\n+               {\"ABCDEFGABCDEFG\", \"c\", 12, PR_TRUE, 2},\n+               {\"ABCDEFGABCDEFG\", \"e\", 12, PR_TRUE, 4},\n+               {\"ABCDEFGABCDEFG\", \"g\", 12, PR_TRUE, 6},\n+               {\"ABCDEFGABCDEFG\", \"i\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"ab\", 12, PR_TRUE, 0},\n+               {\"ABCDEFGABCDEFG\", \"cd\", 12, PR_TRUE, 2},\n+               {\"ABCDEFGABCDEFG\", \"ef\", 12, PR_TRUE, 4},\n+               {\"ABCDEFGABCDEFG\", \"gh\", 12, PR_FALSE, 0},\n+               {\"ABCDABCABCDABC\", \"bc\", 5, PR_TRUE, 1},\n+               {\"ABCDABCABCDABC\", \"bc\", 6, PR_TRUE, 1},\n+               {\"ABCDABCABCDABC\", \"bc\", 7, PR_TRUE, 1},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", 6, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", 7, PR_TRUE, 0},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", 8, PR_TRUE, 0}};\n+\n+  int i;\n+\n+  printf(\"Test 029 (PL_strncasestr) ...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strncasestr(array[i].str, array[i].sub, array[i].max);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> %.32s, not null\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> null, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].max,\n+               array[i].str, array[i].off);\n+        return PR_FALSE;\n+      }\n \n-/* PL_strncaserstr */\n-PRBool\n-test_030(void)\n-{\n-    static struct {\n-        const char* str;\n-        const char* sub;\n-        PRUint32 max;\n-        PRBool ret;\n-        PRUint32 off;\n-    } array[] = { { (const char*)0, (const char*)0, 12, PR_FALSE, 0 },\n-                  { (const char*)0, \"blah\", 12, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", (const char*)0, 12, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 0, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 2, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 3, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 4, PR_TRUE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 5, PR_TRUE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 11, PR_TRUE, 0 },\n-                  { \"blah-de-blah\", \"blah\", 12, PR_TRUE, 8 },\n-                  { \"blah-de-blah\", \"blah\", 13, PR_TRUE, 8 },\n-                  { \"\", \"blah\", 12, PR_FALSE, 0 },\n-                  { \"blah-de-blah\", \"\", 12, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"a\", 5, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"c\", 5, PR_TRUE, 2 },\n-                  { \"abcdefg\", \"e\", 5, PR_TRUE, 4 },\n-                  { \"abcdefg\", \"g\", 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"i\", 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"ab\", 5, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"cd\", 5, PR_TRUE, 2 },\n-                  { \"abcdefg\", \"ef\", 5, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"gh\", 5, PR_FALSE, 0 },\n-                  { \"abcdabc\", \"bc\", 5, PR_TRUE, 1 },\n-                  { \"abcdabc\", \"bc\", 6, PR_TRUE, 1 },\n-                  { \"abcdabc\", \"bc\", 7, PR_TRUE, 5 },\n-                  { \"abcdefg\", \"abcdefg\", 6, PR_FALSE, 0 },\n-                  { \"abcdefg\", \"abcdefg\", 7, PR_TRUE, 0 },\n-                  { \"abcdefg\", \"abcdefg\", 8, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"a\", 12, PR_TRUE, 7 },\n-                  { \"abcdefgabcdefg\", \"c\", 12, PR_TRUE, 9 },\n-                  { \"abcdefgabcdefg\", \"e\", 12, PR_TRUE, 11 },\n-                  { \"abcdefgabcdefg\", \"g\", 12, PR_TRUE, 6 },\n-                  { \"abcdefgabcdefg\", \"i\", 12, PR_FALSE, 0 },\n-                  { \"abcdefgabcdefg\", \"ab\", 12, PR_TRUE, 7 },\n-                  { \"abcdefgabcdefg\", \"cd\", 12, PR_TRUE, 9 },\n-                  { \"abcdefgabcdefg\", \"ef\", 12, PR_TRUE, 4 },\n-                  { \"abcdefgabcdefg\", \"gh\", 12, PR_FALSE, 0 },\n-                  { \"abcdabcabcdabc\", \"bc\", 12, PR_TRUE, 8 },\n-                  { \"abcdabcabcdabc\", \"bc\", 13, PR_TRUE, 8 },\n-                  { \"abcdabcabcdabc\", \"bc\", 14, PR_TRUE, 12 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", 13, PR_TRUE, 0 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", 14, PR_TRUE, 7 },\n-                  { \"abcdefgabcdefg\", \"abcdefg\", 15, PR_TRUE, 7 },\n-                  { \"ABCDEFG\", \"a\", 5, PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"c\", 5, PR_TRUE, 2 },\n-                  { \"ABCDEFG\", \"e\", 5, PR_TRUE, 4 },\n-                  { \"ABCDEFG\", \"g\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"i\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"ab\", 5, PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"cd\", 5, PR_TRUE, 2 },\n-                  { \"ABCDEFG\", \"ef\", 5, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"gh\", 5, PR_FALSE, 0 },\n-                  { \"ABCDABC\", \"bc\", 5, PR_TRUE, 1 },\n-                  { \"ABCDABC\", \"bc\", 6, PR_TRUE, 1 },\n-                  { \"ABCDABC\", \"bc\", 7, PR_TRUE, 5 },\n-                  { \"ABCDEFG\", \"abcdefg\", 6, PR_FALSE, 0 },\n-                  { \"ABCDEFG\", \"abcdefg\", 7, PR_TRUE, 0 },\n-                  { \"ABCDEFG\", \"abcdefg\", 8, PR_TRUE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"a\", 12, PR_TRUE, 7 },\n-                  { \"ABCDEFGABCDEFG\", \"c\", 12, PR_TRUE, 9 },\n-                  { \"ABCDEFGABCDEFG\", \"e\", 12, PR_TRUE, 11 },\n-                  { \"ABCDEFGABCDEFG\", \"g\", 12, PR_TRUE, 6 },\n-                  { \"ABCDEFGABCDEFG\", \"i\", 12, PR_FALSE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"ab\", 12, PR_TRUE, 7 },\n-                  { \"ABCDEFGABCDEFG\", \"cd\", 12, PR_TRUE, 9 },\n-                  { \"ABCDEFGABCDEFG\", \"ef\", 12, PR_TRUE, 4 },\n-                  { \"ABCDEFGABCDEFG\", \"gh\", 12, PR_FALSE, 0 },\n-                  { \"ABCDABCABCDABC\", \"bc\", 12, PR_TRUE, 8 },\n-                  { \"ABCDABCABCDABC\", \"bc\", 13, PR_TRUE, 8 },\n-                  { \"ABCDABCABCDABC\", \"bc\", 14, PR_TRUE, 12 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", 13, PR_TRUE, 0 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", 14, PR_TRUE, 7 },\n-                  { \"ABCDEFGABCDEFG\", \"abcdefg\", 15, PR_TRUE, 7 } };\n-\n-    int i;\n-\n-    printf(\"Test 030 (PL_strncaserstr)...\");\n-    fflush(stdout);\n-\n-    for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n-        char* rv = PL_strncaserstr(array[i].str, array[i].sub, array[i].max);\n-\n-        if (PR_FALSE == array[i].ret) {\n-            if ((char*)0 != rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> %.32s, not null\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv);\n-                return PR_FALSE;\n-            }\n-        } else {\n-            if ((char*)0 == rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> null, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].max,\n-                       array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-\n-            if (&array[i].str[array[i].off] != rv) {\n-                printf(\"FAIL %d: %s,%s/%lu -> 0x%x, not 0x%x+%lu\\n\", i,\n-                       array[i].str ? array[i].str : \"(null)\",\n-                       array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv,\n-                       array[i].str, array[i].off);\n-                return PR_FALSE;\n-            }\n-        }\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> 0x%x, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv,\n+               array[i].str, array[i].off);\n+        return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n-/* PL_strtok_r */\n-PRBool\n-test_031(void)\n-{\n-    static const char* tokens[] = {\n-        \"wtc\", \"relyea\", \"nelsonb\", \"jpierre\", \"nicolson\",\n-        \"ian.mcgreer\", \"kirk.erickson\", \"sonja.mirtitsch\", \"mhein\"\n-    };\n-\n-    static const char* seps[] = { \", \", \",\", \" \", \"\\t\", \",,,\",\n-                                  \" ,\", \"    \", \" \\t\\t\", \",\" };\n-\n-    static const char s2[] = \", \\t\";\n-\n-    char string[1024];\n-    char* s1;\n-    char* token;\n-    char* lasts;\n-    unsigned int i;\n-\n-    printf(\"Test 031 (PL_strtok_r)    ...\");\n-    fflush(stdout);\n-\n-    /* Build the string. */\n-    string[0] = '\\0';\n-    for (i = 0; i < sizeof(tokens) / sizeof(tokens[0]); i++) {\n-        PL_strcat(string, tokens[i]);\n-        PL_strcat(string, seps[i]);\n-    }\n+/* PL_strncaserstr */\n+PRBool test_030(void) {\n+  static struct {\n+    const char* str;\n+    const char* sub;\n+    PRUint32 max;\n+    PRBool ret;\n+    PRUint32 off;\n+  } array[] = {{(const char*)0, (const char*)0, 12, PR_FALSE, 0},\n+               {(const char*)0, \"blah\", 12, PR_FALSE, 0},\n+               {\"blah-de-blah\", (const char*)0, 12, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 0, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 2, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 3, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"blah\", 4, PR_TRUE, 0},\n+               {\"blah-de-blah\", \"blah\", 5, PR_TRUE, 0},\n+               {\"blah-de-blah\", \"blah\", 11, PR_TRUE, 0},\n+               {\"blah-de-blah\", \"blah\", 12, PR_TRUE, 8},\n+               {\"blah-de-blah\", \"blah\", 13, PR_TRUE, 8},\n+               {\"\", \"blah\", 12, PR_FALSE, 0},\n+               {\"blah-de-blah\", \"\", 12, PR_FALSE, 0},\n+               {\"abcdefg\", \"a\", 5, PR_TRUE, 0},\n+               {\"abcdefg\", \"c\", 5, PR_TRUE, 2},\n+               {\"abcdefg\", \"e\", 5, PR_TRUE, 4},\n+               {\"abcdefg\", \"g\", 5, PR_FALSE, 0},\n+               {\"abcdefg\", \"i\", 5, PR_FALSE, 0},\n+               {\"abcdefg\", \"ab\", 5, PR_TRUE, 0},\n+               {\"abcdefg\", \"cd\", 5, PR_TRUE, 2},\n+               {\"abcdefg\", \"ef\", 5, PR_FALSE, 0},\n+               {\"abcdefg\", \"gh\", 5, PR_FALSE, 0},\n+               {\"abcdabc\", \"bc\", 5, PR_TRUE, 1},\n+               {\"abcdabc\", \"bc\", 6, PR_TRUE, 1},\n+               {\"abcdabc\", \"bc\", 7, PR_TRUE, 5},\n+               {\"abcdefg\", \"abcdefg\", 6, PR_FALSE, 0},\n+               {\"abcdefg\", \"abcdefg\", 7, PR_TRUE, 0},\n+               {\"abcdefg\", \"abcdefg\", 8, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"a\", 12, PR_TRUE, 7},\n+               {\"abcdefgabcdefg\", \"c\", 12, PR_TRUE, 9},\n+               {\"abcdefgabcdefg\", \"e\", 12, PR_TRUE, 11},\n+               {\"abcdefgabcdefg\", \"g\", 12, PR_TRUE, 6},\n+               {\"abcdefgabcdefg\", \"i\", 12, PR_FALSE, 0},\n+               {\"abcdefgabcdefg\", \"ab\", 12, PR_TRUE, 7},\n+               {\"abcdefgabcdefg\", \"cd\", 12, PR_TRUE, 9},\n+               {\"abcdefgabcdefg\", \"ef\", 12, PR_TRUE, 4},\n+               {\"abcdefgabcdefg\", \"gh\", 12, PR_FALSE, 0},\n+               {\"abcdabcabcdabc\", \"bc\", 12, PR_TRUE, 8},\n+               {\"abcdabcabcdabc\", \"bc\", 13, PR_TRUE, 8},\n+               {\"abcdabcabcdabc\", \"bc\", 14, PR_TRUE, 12},\n+               {\"abcdefgabcdefg\", \"abcdefg\", 13, PR_TRUE, 0},\n+               {\"abcdefgabcdefg\", \"abcdefg\", 14, PR_TRUE, 7},\n+               {\"abcdefgabcdefg\", \"abcdefg\", 15, PR_TRUE, 7},\n+               {\"ABCDEFG\", \"a\", 5, PR_TRUE, 0},\n+               {\"ABCDEFG\", \"c\", 5, PR_TRUE, 2},\n+               {\"ABCDEFG\", \"e\", 5, PR_TRUE, 4},\n+               {\"ABCDEFG\", \"g\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"i\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"ab\", 5, PR_TRUE, 0},\n+               {\"ABCDEFG\", \"cd\", 5, PR_TRUE, 2},\n+               {\"ABCDEFG\", \"ef\", 5, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"gh\", 5, PR_FALSE, 0},\n+               {\"ABCDABC\", \"bc\", 5, PR_TRUE, 1},\n+               {\"ABCDABC\", \"bc\", 6, PR_TRUE, 1},\n+               {\"ABCDABC\", \"bc\", 7, PR_TRUE, 5},\n+               {\"ABCDEFG\", \"abcdefg\", 6, PR_FALSE, 0},\n+               {\"ABCDEFG\", \"abcdefg\", 7, PR_TRUE, 0},\n+               {\"ABCDEFG\", \"abcdefg\", 8, PR_TRUE, 0},\n+               {\"ABCDEFGABCDEFG\", \"a\", 12, PR_TRUE, 7},\n+               {\"ABCDEFGABCDEFG\", \"c\", 12, PR_TRUE, 9},\n+               {\"ABCDEFGABCDEFG\", \"e\", 12, PR_TRUE, 11},\n+               {\"ABCDEFGABCDEFG\", \"g\", 12, PR_TRUE, 6},\n+               {\"ABCDEFGABCDEFG\", \"i\", 12, PR_FALSE, 0},\n+               {\"ABCDEFGABCDEFG\", \"ab\", 12, PR_TRUE, 7},\n+               {\"ABCDEFGABCDEFG\", \"cd\", 12, PR_TRUE, 9},\n+               {\"ABCDEFGABCDEFG\", \"ef\", 12, PR_TRUE, 4},\n+               {\"ABCDEFGABCDEFG\", \"gh\", 12, PR_FALSE, 0},\n+               {\"ABCDABCABCDABC\", \"bc\", 12, PR_TRUE, 8},\n+               {\"ABCDABCABCDABC\", \"bc\", 13, PR_TRUE, 8},\n+               {\"ABCDABCABCDABC\", \"bc\", 14, PR_TRUE, 12},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", 13, PR_TRUE, 0},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", 14, PR_TRUE, 7},\n+               {\"ABCDEFGABCDEFG\", \"abcdefg\", 15, PR_TRUE, 7}};\n+\n+  int i;\n+\n+  printf(\"Test 030 (PL_strncaserstr)...\");\n+  fflush(stdout);\n+\n+  for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {\n+    char* rv = PL_strncaserstr(array[i].str, array[i].sub, array[i].max);\n+\n+    if (PR_FALSE == array[i].ret) {\n+      if ((char*)0 != rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> %.32s, not null\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv);\n+        return PR_FALSE;\n+      }\n+    } else {\n+      if ((char*)0 == rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> null, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].max,\n+               array[i].str, array[i].off);\n+        return PR_FALSE;\n+      }\n \n-    /* Scan the string for tokens. */\n-    i = 0;\n-    s1 = string;\n-    while ((token = PL_strtok_r(s1, s2, &lasts)) != NULL) {\n-        if (PL_strcmp(token, tokens[i]) != 0) {\n-            printf(\"FAIL wrong token scanned\\n\");\n-            return PR_FALSE;\n-        }\n-        i++;\n-        s1 = NULL;\n-    }\n-    if (i != sizeof(tokens) / sizeof(tokens[0])) {\n-        printf(\"FAIL wrong number of tokens scanned\\n\");\n+      if (&array[i].str[array[i].off] != rv) {\n+        printf(\"FAIL %d: %s,%s/%lu -> 0x%x, not 0x%x+%lu\\n\", i,\n+               array[i].str ? array[i].str : \"(null)\",\n+               array[i].sub ? array[i].sub : \"(null)\", array[i].max, rv,\n+               array[i].str, array[i].off);\n         return PR_FALSE;\n+      }\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return PR_TRUE;\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n }\n \n-int\n-main(int argc, char* argv[])\n-{\n-    printf(\"Testing the Portable Library string functions:\\n\");\n-\n-    if (1 && test_001() && test_001() && test_002() && test_003() && test_004() &&\n-        test_005() && test_006() && test_007() && test_008() && test_009() &&\n-        test_010() && test_011() && test_012() && test_013() && test_014() &&\n-        test_015() && test_016() && test_017() && test_018() && test_019() &&\n-        test_020() && test_021() && test_022() && test_023() && test_024() &&\n-        test_025() && test_026() && test_027() && test_028() && test_029() &&\n-        test_030() && test_031()) {\n-        printf(\"Suite passed.\\n\");\n-        return 0;\n-    } else {\n-        printf(\"Suite failed.\\n\");\n-        return 1;\n+/* PL_strtok_r */\n+PRBool test_031(void) {\n+  static const char* tokens[] = {\n+      \"wtc\",         \"relyea\",        \"nelsonb\",         \"jpierre\", \"nicolson\",\n+      \"ian.mcgreer\", \"kirk.erickson\", \"sonja.mirtitsch\", \"mhein\"};\n+\n+  static const char* seps[] = {\", \", \",\",    \" \",     \"\\t\", \",,,\",\n+                               \" ,\", \"    \", \" \\t\\t\", \",\"};\n+\n+  static const char s2[] = \", \\t\";\n+\n+  char string[1024];\n+  char* s1;\n+  char* token;\n+  char* lasts;\n+  unsigned int i;\n+\n+  printf(\"Test 031 (PL_strtok_r)    ...\");\n+  fflush(stdout);\n+\n+  /* Build the string. */\n+  string[0] = '\\0';\n+  for (i = 0; i < sizeof(tokens) / sizeof(tokens[0]); i++) {\n+    PL_strcat(string, tokens[i]);\n+    PL_strcat(string, seps[i]);\n+  }\n+\n+  /* Scan the string for tokens. */\n+  i = 0;\n+  s1 = string;\n+  while ((token = PL_strtok_r(s1, s2, &lasts)) != NULL) {\n+    if (PL_strcmp(token, tokens[i]) != 0) {\n+      printf(\"FAIL wrong token scanned\\n\");\n+      return PR_FALSE;\n     }\n+    i++;\n+    s1 = NULL;\n+  }\n+  if (i != sizeof(tokens) / sizeof(tokens[0])) {\n+    printf(\"FAIL wrong number of tokens scanned\\n\");\n+    return PR_FALSE;\n+  }\n+\n+  printf(\"PASS\\n\");\n+  return PR_TRUE;\n+}\n \n-    /*NOTREACHED*/\n+int main(int argc, char* argv[]) {\n+  printf(\"Testing the Portable Library string functions:\\n\");\n+\n+  if (1 && test_001() && test_001() && test_002() && test_003() && test_004() &&\n+      test_005() && test_006() && test_007() && test_008() && test_009() &&\n+      test_010() && test_011() && test_012() && test_013() && test_014() &&\n+      test_015() && test_016() && test_017() && test_018() && test_019() &&\n+      test_020() && test_021() && test_022() && test_023() && test_024() &&\n+      test_025() && test_026() && test_027() && test_028() && test_029() &&\n+      test_030() && test_031()) {\n+    printf(\"Suite passed.\\n\");\n+    return 0;\n+  } else {\n+    printf(\"Suite failed.\\n\");\n+    return 1;\n+  }\n+\n+  /*NOTREACHED*/\n }\ndiff --git a/nspr/pr/.cvsignore b/nspr/pr/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/include/.cvsignore b/nspr/pr/include/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/include/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/include/gencfg.c b/nspr/pr/include/gencfg.c\nindex 7a40545..f47ecf1 100644\n--- a/nspr/pr/include/gencfg.c\n+++ b/nspr/pr/include/gencfg.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -5,10 +6,10 @@\n #include <stdio.h>\n \n #if defined(__sun)\n-#ifndef SOLARIS\n+#  ifndef SOLARIS\n error -\n     SOLARIS is not defined\n-#endif\n+#  endif\n #endif\n \n #if defined(__hpux)\n@@ -17,33 +18,32 @@ error -\n #endif\n \n #if defined(__alpha)\n-#if !(defined(_WIN32)) && !(defined(__linux)) && !(defined(__FreeBSD__))\n+#  if !(defined(_WIN32)) && !(defined(__linux)) && !(defined(__FreeBSD__))\n         error -\n     None of _WIN32,\n-    __linux,\n-    or __FreeBSD__ is defined\n-#endif\n+    __linux, or __FreeBSD__ is defined\n+#  endif\n #endif\n \n #if defined(_IBMR2)\n-#ifndef AIX\n-                error -\n-            AIX is not defined\n-#endif\n+#  ifndef AIX\n+                         error -\n+                     AIX is not defined\n+#  endif\n #endif\n \n #if defined(linux)\n-#ifndef LINUX\n-                error -\n-            LINUX is not defined\n-#endif\n+#  ifndef LINUX\n+                         error -\n+                     LINUX is not defined\n+#  endif\n #endif\n \n #if defined(__APPLE__)\n-#ifndef DARWIN\n-                error -\n-            DARWIN is not defined\n-#endif\n+#  ifndef DARWIN\n+                         error -\n+                     DARWIN is not defined\n+#  endif\n #endif\n \n /************************************************************************/\n@@ -51,48 +51,48 @@ error -\n /* Generate cpucfg.h */\n \n #ifdef XP_PC\n-#ifdef WIN32\n-#define INT64 _PRInt64\n-#else\n-#define INT64 long\n-#endif\n+#  ifdef WIN32\n+#    define INT64 _PRInt64\n+#  else\n+#    define INT64 long\n+#  endif\n #else\n-#define INT64 long long\n+#    define INT64 long long\n #endif\n \n-            struct align_short {\n-    char c;\n-    short a;\n+                     struct align_short {\n+  char c;\n+  short a;\n };\n struct align_int {\n-    char c;\n-    int a;\n+  char c;\n+  int a;\n };\n struct align_long {\n-    char c;\n-    long a;\n+  char c;\n+  long a;\n };\n struct align_PRInt64 {\n-    char c;\n-    INT64 a;\n+  char c;\n+  INT64 a;\n };\n struct align_fakelonglong {\n-    char c;\n-    struct {\n-        long hi, lo;\n-    } a;\n+  char c;\n+  struct {\n+    long hi, lo;\n+  } a;\n };\n struct align_float {\n-    char c;\n-    float a;\n+  char c;\n+  float a;\n };\n struct align_double {\n-    char c;\n-    double a;\n+  char c;\n+  double a;\n };\n struct align_pointer {\n-    char c;\n-    void* a;\n+  char c;\n+  void* a;\n };\n \n #define ALIGN_OF(type) (((char*)&(((struct align_##type*)0)->a)) - ((char*)0))\n@@ -102,67 +102,61 @@ int bpb;\n /* Used if shell doesn't support redirection. By default, assume it does. */\n FILE* stream;\n \n-static int\n-Log2(int n)\n-{\n-    int log2 = 0;\n-\n-    if (n & (n - 1)) {\n-        log2++;\n-    }\n-    if (n >> 16) {\n-        log2 += 16, n >>= 16;\n-    }\n-    if (n >> 8) {\n-        log2 += 8, n >>= 8;\n-    }\n-    if (n >> 4) {\n-        log2 += 4, n >>= 4;\n-    }\n-    if (n >> 2) {\n-        log2 += 2, n >>= 2;\n-    }\n-    if (n >> 1) {\n-        log2++;\n-    }\n-    return log2;\n+static int Log2(int n) {\n+  int log2 = 0;\n+\n+  if (n & (n - 1)) {\n+    log2++;\n+  }\n+  if (n >> 16) {\n+    log2 += 16, n >>= 16;\n+  }\n+  if (n >> 8) {\n+    log2 += 8, n >>= 8;\n+  }\n+  if (n >> 4) {\n+    log2 += 4, n >>= 4;\n+  }\n+  if (n >> 2) {\n+    log2 += 2, n >>= 2;\n+  }\n+  if (n >> 1) {\n+    log2++;\n+  }\n+  return log2;\n }\n \n /* We assume that int's are 32 bits */\n-static void\n-do64(void)\n-{\n-    union {\n-        int i;\n-        char c[4];\n-    } u;\n-\n-    u.i = 0x01020304;\n-    if (u.c[0] == 0x01) {\n-        fprintf(stream, \"#undef  IS_LITTLE_ENDIAN\\n\");\n-        fprintf(stream, \"#define IS_BIG_ENDIAN 1\\n\\n\");\n-    } else {\n-        fprintf(stream, \"#define IS_LITTLE_ENDIAN 1\\n\");\n-        fprintf(stream, \"#undef  IS_BIG_ENDIAN\\n\\n\");\n-    }\n+static void do64(void) {\n+  union {\n+    int i;\n+    char c[4];\n+  } u;\n+\n+  u.i = 0x01020304;\n+  if (u.c[0] == 0x01) {\n+    fprintf(stream, \"#undef  IS_LITTLE_ENDIAN\\n\");\n+    fprintf(stream, \"#define IS_BIG_ENDIAN 1\\n\\n\");\n+  } else {\n+    fprintf(stream, \"#define IS_LITTLE_ENDIAN 1\\n\");\n+    fprintf(stream, \"#undef  IS_BIG_ENDIAN\\n\\n\");\n+  }\n }\n \n-static void\n-do32(void)\n-{\n-    union {\n-        long i;\n-        char c[4];\n-    } u;\n-\n-    u.i = 0x01020304;\n-    if (u.c[0] == 0x01) {\n-        fprintf(stream, \"#undef  IS_LITTLE_ENDIAN\\n\");\n-        fprintf(stream, \"#define IS_BIG_ENDIAN 1\\n\\n\");\n-    } else {\n-        fprintf(stream, \"#define IS_LITTLE_ENDIAN 1\\n\");\n-        fprintf(stream, \"#undef  IS_BIG_ENDIAN\\n\\n\");\n-    }\n+static void do32(void) {\n+  union {\n+    long i;\n+    char c[4];\n+  } u;\n+\n+  u.i = 0x01020304;\n+  if (u.c[0] == 0x01) {\n+    fprintf(stream, \"#undef  IS_LITTLE_ENDIAN\\n\");\n+    fprintf(stream, \"#define IS_BIG_ENDIAN 1\\n\\n\");\n+  } else {\n+    fprintf(stream, \"#define IS_LITTLE_ENDIAN 1\\n\");\n+    fprintf(stream, \"#undef  IS_BIG_ENDIAN\\n\\n\");\n+  }\n }\n \n /*\n@@ -170,82 +164,76 @@ do32(void)\n ** there with and's and shift's in it that assumes a byte is 8 bits, so\n ** forget about porting THIS code to those non 8 bit byte machines.\n */\n-static void\n-BitsPerByte(void)\n-{\n-    bpb = 8;\n-}\n+static void BitsPerByte(void) { bpb = 8; }\n \n-int\n-main(int argc, char** argv)\n-{\n-    BitsPerByte();\n-\n-    /* If we got a command line argument, try to use it as the stream. */\n-    ++argv;\n-    if (*argv) {\n-        if (!(stream = fopen(*argv, \"wt\"))) {\n-            fprintf(stderr, \"Could not write to output file %s.\\n\", *argv);\n-            return 1;\n-        }\n-    } else {\n-        stream = stdout;\n-    }\n+int main(int argc, char** argv) {\n+  BitsPerByte();\n \n-    fprintf(stream, \"#ifndef nspr_cpucfg___\\n\");\n-    fprintf(stream, \"#define nspr_cpucfg___\\n\\n\");\n-\n-    fprintf(stream, \"/* AUTOMATICALLY GENERATED - DO NOT EDIT */\\n\\n\");\n-\n-    if (sizeof(long) == 8) {\n-        do64();\n-    } else {\n-        do32();\n-    }\n-    fprintf(stream, \"#define PR_BYTES_PER_BYTE   %d\\n\", sizeof(char));\n-    fprintf(stream, \"#define PR_BYTES_PER_SHORT  %d\\n\", sizeof(short));\n-    fprintf(stream, \"#define PR_BYTES_PER_INT    %d\\n\", sizeof(int));\n-    fprintf(stream, \"#define PR_BYTES_PER_INT64  %d\\n\", 8);\n-    fprintf(stream, \"#define PR_BYTES_PER_LONG   %d\\n\", sizeof(long));\n-    fprintf(stream, \"#define PR_BYTES_PER_FLOAT  %d\\n\", sizeof(float));\n-    fprintf(stream, \"#define PR_BYTES_PER_DOUBLE %d\\n\\n\", sizeof(double));\n-\n-    fprintf(stream, \"#define PR_BITS_PER_BYTE    %d\\n\", bpb);\n-    fprintf(stream, \"#define PR_BITS_PER_SHORT   %d\\n\", bpb * sizeof(short));\n-    fprintf(stream, \"#define PR_BITS_PER_INT     %d\\n\", bpb * sizeof(int));\n-    fprintf(stream, \"#define PR_BITS_PER_INT64   %d\\n\", bpb * 8);\n-    fprintf(stream, \"#define PR_BITS_PER_LONG    %d\\n\", bpb * sizeof(long));\n-    fprintf(stream, \"#define PR_BITS_PER_FLOAT   %d\\n\", bpb * sizeof(float));\n-    fprintf(stream, \"#define PR_BITS_PER_DOUBLE  %d\\n\\n\", bpb * sizeof(double));\n-\n-    fprintf(stream, \"#define PR_BITS_PER_BYTE_LOG2   %d\\n\", Log2(bpb));\n-    fprintf(stream, \"#define PR_BITS_PER_SHORT_LOG2  %d\\n\",\n-            Log2(bpb * sizeof(short)));\n-    fprintf(stream, \"#define PR_BITS_PER_INT_LOG2    %d\\n\",\n-            Log2(bpb * sizeof(int)));\n-    fprintf(stream, \"#define PR_BITS_PER_INT64_LOG2  %d\\n\", 6);\n-    fprintf(stream, \"#define PR_BITS_PER_LONG_LOG2   %d\\n\",\n-            Log2(bpb * sizeof(long)));\n-    fprintf(stream, \"#define PR_BITS_PER_FLOAT_LOG2  %d\\n\",\n-            Log2(bpb * sizeof(float)));\n-    fprintf(stream, \"#define PR_BITS_PER_DOUBLE_LOG2 %d\\n\\n\",\n-            Log2(bpb * sizeof(double)));\n-\n-    fprintf(stream, \"#define PR_ALIGN_OF_SHORT   %d\\n\", ALIGN_OF(short));\n-    fprintf(stream, \"#define PR_ALIGN_OF_INT     %d\\n\", ALIGN_OF(int));\n-    fprintf(stream, \"#define PR_ALIGN_OF_LONG    %d\\n\", ALIGN_OF(long));\n-    if (sizeof(INT64) < 8) {\n-        /* this machine doesn't actually support PRInt64's */\n-        fprintf(stream, \"#define PR_ALIGN_OF_INT64   %d\\n\", ALIGN_OF(fakelonglong));\n-    } else {\n-        fprintf(stream, \"#define PR_ALIGN_OF_INT64   %d\\n\", ALIGN_OF(PRInt64));\n+  /* If we got a command line argument, try to use it as the stream. */\n+  ++argv;\n+  if (*argv) {\n+    if (!(stream = fopen(*argv, \"wt\"))) {\n+      fprintf(stderr, \"Could not write to output file %s.\\n\", *argv);\n+      return 1;\n     }\n-    fprintf(stream, \"#define PR_ALIGN_OF_FLOAT   %d\\n\", ALIGN_OF(float));\n-    fprintf(stream, \"#define PR_ALIGN_OF_DOUBLE  %d\\n\", ALIGN_OF(double));\n-    fprintf(stream, \"#define PR_ALIGN_OF_POINTER %d\\n\\n\", ALIGN_OF(pointer));\n-\n-    fprintf(stream, \"#endif /* nspr_cpucfg___ */\\n\");\n-    fclose(stream);\n-\n-    return 0;\n+  } else {\n+    stream = stdout;\n+  }\n+\n+  fprintf(stream, \"#ifndef nspr_cpucfg___\\n\");\n+  fprintf(stream, \"#define nspr_cpucfg___\\n\\n\");\n+\n+  fprintf(stream, \"/* AUTOMATICALLY GENERATED - DO NOT EDIT */\\n\\n\");\n+\n+  if (sizeof(long) == 8) {\n+    do64();\n+  } else {\n+    do32();\n+  }\n+  fprintf(stream, \"#define PR_BYTES_PER_BYTE   %d\\n\", sizeof(char));\n+  fprintf(stream, \"#define PR_BYTES_PER_SHORT  %d\\n\", sizeof(short));\n+  fprintf(stream, \"#define PR_BYTES_PER_INT    %d\\n\", sizeof(int));\n+  fprintf(stream, \"#define PR_BYTES_PER_INT64  %d\\n\", 8);\n+  fprintf(stream, \"#define PR_BYTES_PER_LONG   %d\\n\", sizeof(long));\n+  fprintf(stream, \"#define PR_BYTES_PER_FLOAT  %d\\n\", sizeof(float));\n+  fprintf(stream, \"#define PR_BYTES_PER_DOUBLE %d\\n\\n\", sizeof(double));\n+\n+  fprintf(stream, \"#define PR_BITS_PER_BYTE    %d\\n\", bpb);\n+  fprintf(stream, \"#define PR_BITS_PER_SHORT   %d\\n\", bpb * sizeof(short));\n+  fprintf(stream, \"#define PR_BITS_PER_INT     %d\\n\", bpb * sizeof(int));\n+  fprintf(stream, \"#define PR_BITS_PER_INT64   %d\\n\", bpb * 8);\n+  fprintf(stream, \"#define PR_BITS_PER_LONG    %d\\n\", bpb * sizeof(long));\n+  fprintf(stream, \"#define PR_BITS_PER_FLOAT   %d\\n\", bpb * sizeof(float));\n+  fprintf(stream, \"#define PR_BITS_PER_DOUBLE  %d\\n\\n\", bpb * sizeof(double));\n+\n+  fprintf(stream, \"#define PR_BITS_PER_BYTE_LOG2   %d\\n\", Log2(bpb));\n+  fprintf(stream, \"#define PR_BITS_PER_SHORT_LOG2  %d\\n\",\n+          Log2(bpb * sizeof(short)));\n+  fprintf(stream, \"#define PR_BITS_PER_INT_LOG2    %d\\n\",\n+          Log2(bpb * sizeof(int)));\n+  fprintf(stream, \"#define PR_BITS_PER_INT64_LOG2  %d\\n\", 6);\n+  fprintf(stream, \"#define PR_BITS_PER_LONG_LOG2   %d\\n\",\n+          Log2(bpb * sizeof(long)));\n+  fprintf(stream, \"#define PR_BITS_PER_FLOAT_LOG2  %d\\n\",\n+          Log2(bpb * sizeof(float)));\n+  fprintf(stream, \"#define PR_BITS_PER_DOUBLE_LOG2 %d\\n\\n\",\n+          Log2(bpb * sizeof(double)));\n+\n+  fprintf(stream, \"#define PR_ALIGN_OF_SHORT   %d\\n\", ALIGN_OF(short));\n+  fprintf(stream, \"#define PR_ALIGN_OF_INT     %d\\n\", ALIGN_OF(int));\n+  fprintf(stream, \"#define PR_ALIGN_OF_LONG    %d\\n\", ALIGN_OF(long));\n+  if (sizeof(INT64) < 8) {\n+    /* this machine doesn't actually support PRInt64's */\n+    fprintf(stream, \"#define PR_ALIGN_OF_INT64   %d\\n\", ALIGN_OF(fakelonglong));\n+  } else {\n+    fprintf(stream, \"#define PR_ALIGN_OF_INT64   %d\\n\", ALIGN_OF(PRInt64));\n+  }\n+  fprintf(stream, \"#define PR_ALIGN_OF_FLOAT   %d\\n\", ALIGN_OF(float));\n+  fprintf(stream, \"#define PR_ALIGN_OF_DOUBLE  %d\\n\", ALIGN_OF(double));\n+  fprintf(stream, \"#define PR_ALIGN_OF_POINTER %d\\n\\n\", ALIGN_OF(pointer));\n+\n+  fprintf(stream, \"#endif /* nspr_cpucfg___ */\\n\");\n+  fclose(stream);\n+\n+  return 0;\n }\ndiff --git a/nspr/pr/include/md/.cvsignore b/nspr/pr/include/md/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/include/md/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/include/md/_aix.h b/nspr/pr/include/md/_aix.h\nindex 2f9c1f7..c2794d3 100644\n--- a/nspr/pr/include/md/_aix.h\n+++ b/nspr/pr/include/md/_aix.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -20,21 +21,21 @@\n  * Internal configuration macros\n  */\n \n-#define PR_LINKER_ARCH \"aix\"\n-#define _PR_SI_SYSNAME \"AIX\"\n-#define _PR_SI_ARCHITECTURE \"rs6000\"\n-#define PR_DLL_SUFFIX \".so\"\n+#define PR_LINKER_ARCH          \"aix\"\n+#define _PR_SI_SYSNAME          \"AIX\"\n+#define _PR_SI_ARCHITECTURE     \"rs6000\"\n+#define PR_DLL_SUFFIX           \".so\"\n \n-#define _PR_VMBASE 0x30000000\n-#define _PR_STACK_VMBASE 0x50000000\n-#define _MD_DEFAULT_STACK_SIZE (2 * 65536L)\n-#define _MD_MINIMUM_STACK_SIZE (2 * 65536L)\n-#define _MD_MMAP_FLAGS MAP_PRIVATE\n+#define _PR_VMBASE              0x30000000\n+#define _PR_STACK_VMBASE        0x50000000\n+#define _MD_DEFAULT_STACK_SIZE  (2*65536L)\n+#define _MD_MINIMUM_STACK_SIZE  (2*65536L)\n+#define _MD_MMAP_FLAGS          MAP_PRIVATE\n \n #define NEED_TIME_R\n-#undef HAVE_STACK_GROWING_UP\n-#undef HAVE_WEAK_IO_SYMBOLS\n-#undef HAVE_WEAK_MALLOC_SYMBOLS\n+#undef  HAVE_STACK_GROWING_UP\n+#undef  HAVE_WEAK_IO_SYMBOLS\n+#undef  HAVE_WEAK_MALLOC_SYMBOLS\n #define HAVE_DLL\n #define USE_DLFCN\n #define _PR_HAVE_SOCKADDR_LEN\n@@ -62,9 +63,9 @@ extern PRIntervalTime _MD_AixGetInterval(void);\n extern PRIntervalTime _MD_AixIntervalPerSec(void);\n #define _MD_INTERVAL_PER_SEC _MD_AixIntervalPerSec\n \n-#else /* defined(AIX_TIMERS) */\n+#else  /* defined(AIX_TIMERS) */\n #define _MD_INTERVAL_USE_GTOD\n-#endif /* defined(AIX_TIMERS) */\n+#endif  /* defined(AIX_TIMERS) */\n \n #ifdef AIX_HAVE_ATOMIC_OP_H\n /* The atomic operations */\n@@ -74,12 +75,9 @@ extern PRIntervalTime _MD_AixIntervalPerSec(void);\n #define _PR_HAVE_ATOMIC_CAS\n #endif\n #define _MD_INIT_ATOMIC()\n-#define _MD_ATOMIC_INCREMENT(val) \\\n-    ((PRInt32)fetch_and_add((atomic_p)val, 1) + 1)\n-#define _MD_ATOMIC_ADD(ptr, val) \\\n-    ((PRInt32)fetch_and_add((atomic_p)ptr, val) + val)\n-#define _MD_ATOMIC_DECREMENT(val) \\\n-    ((PRInt32)fetch_and_add((atomic_p)val, -1) - 1)\n+#define _MD_ATOMIC_INCREMENT(val)   ((PRInt32)fetch_and_add((atomic_p)val, 1) + 1)\n+#define _MD_ATOMIC_ADD(ptr, val)   ((PRInt32)fetch_and_add((atomic_p)ptr, val) + val)\n+#define _MD_ATOMIC_DECREMENT(val)   ((PRInt32)fetch_and_add((atomic_p)val, -1) - 1)\n #define _MD_ATOMIC_SET(val, newval) _AIX_AtomicSet(val, newval)\n #endif /* AIX_HAVE_ATOMIC_OP_H */\n \n@@ -87,13 +85,13 @@ extern PRIntervalTime _MD_AixIntervalPerSec(void);\n \n #include <setjmp.h>\n \n-#define _MD_GET_SP(_t) (_t)->md.jb[3]\n-#define _MD_SET_THR_SP(_t, _sp) ((_t)->md.jb[3] = (int)(_sp - 2 * 64))\n-#define PR_NUM_GCREGS _JBLEN\n+#define _MD_GET_SP(_t)              (_t)->md.jb[3]\n+#define _MD_SET_THR_SP(_t, _sp)     ((_t)->md.jb[3] = (int) (_sp - 2 * 64))\n+#define PR_NUM_GCREGS               _JBLEN\n \n-#define CONTEXT(_th) ((_th)->md.jb)\n-#define SAVE_CONTEXT(_th) _setjmp(CONTEXT(_th))\n-#define GOTO_CONTEXT(_th) _longjmp(CONTEXT(_th), 1)\n+#define CONTEXT(_th)                ((_th)->md.jb)\n+#define SAVE_CONTEXT(_th)           _setjmp(CONTEXT(_th))\n+#define GOTO_CONTEXT(_th)           _longjmp(CONTEXT(_th), 1)\n \n #ifdef PTHREADS_USER\n #include \"_nspr_pthread.h\"\n@@ -102,30 +100,30 @@ extern PRIntervalTime _MD_AixIntervalPerSec(void);\n /*\n ** Initialize the thread context preparing it to execute _main.\n */\n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \\\n-    PR_BEGIN_MACRO                                    \\\n-    *status = PR_TRUE;                                \\\n-    if (setjmp(CONTEXT(_thread))) {                   \\\n-        (*_main)();                                   \\\n-    }                                                 \\\n-    _MD_GET_SP(_thread) = (int)(_sp - 2 * 64);        \\\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)         \\\n+    PR_BEGIN_MACRO                    \\\n+        *status = PR_TRUE;              \\\n+    if (setjmp(CONTEXT(_thread))) { \\\n+        (*_main)();         \\\n+    }               \\\n+    _MD_GET_SP(_thread) = (int) (_sp - 2 * 64);     \\\n     PR_END_MACRO\n \n-#define _MD_SWITCH_CONTEXT(_thread)    \\\n-    if (!setjmp(CONTEXT(_thread))) {   \\\n-        (_thread)->md.errcode = errno; \\\n-        _PR_Schedule();                \\\n+#define _MD_SWITCH_CONTEXT(_thread)  \\\n+    if (!setjmp(CONTEXT(_thread))) { \\\n+    (_thread)->md.errcode = errno;  \\\n+    _PR_Schedule();          \\\n     }\n \n /*\n ** Restore a thread context, saved by _MD_SWITCH_CONTEXT\n */\n-#define _MD_RESTORE_CONTEXT(_thread)     \\\n-    {                                    \\\n-        errno = (_thread)->md.errcode;   \\\n-        _MD_SET_CURRENT_THREAD(_thread); \\\n-        longjmp(CONTEXT(_thread), 1);    \\\n-    }\n+#define _MD_RESTORE_CONTEXT(_thread) \\\n+{                    \\\n+    errno = (_thread)->md.errcode; \\\n+    _MD_SET_CURRENT_THREAD(_thread); \\\n+    longjmp(CONTEXT(_thread), 1); \\\n+}\n \n /* Machine-dependent (MD) data structures */\n \n@@ -167,29 +165,29 @@ struct _MDCPU_Unix {\n     PRInt32 ioq_osfd_cnt;\n #ifndef _PR_USE_POLL\n     fd_set fd_read_set, fd_write_set, fd_exception_set;\n-    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD],\n-        fd_exception_cnt[_PR_MD_MAX_OSFD];\n+    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],\n+            fd_exception_cnt[_PR_MD_MAX_OSFD];\n #else\n-    struct pollfd* ioq_pollfds;\n+    struct pollfd *ioq_pollfds;\n     int ioq_pollfds_size;\n-#endif /* _PR_USE_POLL */\n+#endif  /* _PR_USE_POLL */\n };\n \n-#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)\n+#define _PR_IOQ(_cpu)           ((_cpu)->md.md_unix.ioQ)\n #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n-#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)\n-#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)\n-#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)\n-#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)\n-#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)\n-#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)\n-#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)\n-#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)\n-#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)\n-#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)\n-#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)\n-\n-#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32\n+#define _PR_FD_READ_SET(_cpu)       ((_cpu)->md.md_unix.fd_read_set)\n+#define _PR_FD_READ_CNT(_cpu)       ((_cpu)->md.md_unix.fd_read_cnt)\n+#define _PR_FD_WRITE_SET(_cpu)      ((_cpu)->md.md_unix.fd_write_set)\n+#define _PR_FD_WRITE_CNT(_cpu)      ((_cpu)->md.md_unix.fd_write_cnt)\n+#define _PR_FD_EXCEPTION_SET(_cpu)  ((_cpu)->md.md_unix.fd_exception_set)\n+#define _PR_FD_EXCEPTION_CNT(_cpu)  ((_cpu)->md.md_unix.fd_exception_cnt)\n+#define _PR_IOQ_TIMEOUT(_cpu)       ((_cpu)->md.md_unix.ioq_timeout)\n+#define _PR_IOQ_MAX_OSFD(_cpu)      ((_cpu)->md.md_unix.ioq_max_osfd)\n+#define _PR_IOQ_OSFD_CNT(_cpu)      ((_cpu)->md.md_unix.ioq_osfd_cnt)\n+#define _PR_IOQ_POLLFDS(_cpu)       ((_cpu)->md.md_unix.ioq_pollfds)\n+#define _PR_IOQ_POLLFDS_SIZE(_cpu)  ((_cpu)->md.md_unix.ioq_pollfds_size)\n+\n+#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)  32\n \n struct _MDCPU {\n     struct _MDCPU_Unix md_unix;\n@@ -207,10 +205,10 @@ struct _MDCPU {\n #define _MD_IOQ_LOCK()\n #define _MD_IOQ_UNLOCK()\n \n-#define _MD_EARLY_INIT _MD_EarlyInit\n-#define _MD_FINAL_INIT _PR_UnixInit\n-#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)\n-#define _MD_INIT_THREAD _MD_InitializeThread\n+#define _MD_EARLY_INIT              _MD_EarlyInit\n+#define _MD_FINAL_INIT          _PR_UnixInit\n+#define _MD_INIT_RUNNING_CPU(cpu)   _MD_unix_init_running_cpu(cpu)\n+#define _MD_INIT_THREAD         _MD_InitializeThread\n #define _MD_EXIT_THREAD(thread)\n #define _MD_SUSPEND_THREAD(thread)\n #define _MD_RESUME_THREAD(thread)\n@@ -218,8 +216,8 @@ struct _MDCPU {\n #endif /* PTHREADS_USER */\n \n #ifdef AIX_RENAME_SELECT\n-#define _MD_SELECT select\n-#define _MD_POLL poll\n+#define _MD_SELECT  select\n+#define _MD_POLL    poll\n #endif\n \n extern void _MD_aix_map_sendfile_error(int err);\ndiff --git a/nspr/pr/include/md/_aix32.cfg b/nspr/pr/include/md/_aix32.cfg\nindex b788960..23a3f51 100644\n--- a/nspr/pr/include/md/_aix32.cfg\n+++ b/nspr/pr/include/md/_aix32.cfg\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/md/_aix64.cfg b/nspr/pr/include/md/_aix64.cfg\nindex 35050e9..7efe896 100644\n--- a/nspr/pr/include/md/_aix64.cfg\n+++ b/nspr/pr/include/md/_aix64.cfg\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/md/_darwin.cfg b/nspr/pr/include/md/_darwin.cfg\nindex 0a8b152..5e11893 100644\n--- a/nspr/pr/include/md/_darwin.cfg\n+++ b/nspr/pr/include/md/_darwin.cfg\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/md/_darwin.h b/nspr/pr/include/md/_darwin.h\nindex 51d09d9..b3f89fb 100644\n--- a/nspr/pr/include/md/_darwin.h\n+++ b/nspr/pr/include/md/_darwin.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -15,8 +16,8 @@\n #include <TargetConditionals.h>\n #endif\n \n-#define PR_LINKER_ARCH \"darwin\"\n-#define _PR_SI_SYSNAME \"DARWIN\"\n+#define PR_LINKER_ARCH  \"darwin\"\n+#define _PR_SI_SYSNAME  \"DARWIN\"\n #ifdef __i386__\n #define _PR_SI_ARCHITECTURE \"x86\"\n #elif defined(__x86_64__)\n@@ -30,14 +31,14 @@\n #else\n #error \"Unknown CPU architecture\"\n #endif\n-#define PR_DLL_SUFFIX \".dylib\"\n+#define PR_DLL_SUFFIX       \".dylib\"\n \n-#define _PR_VMBASE 0x30000000\n-#define _PR_STACK_VMBASE 0x50000000\n-#define _MD_DEFAULT_STACK_SIZE 65536L\n-#define _MD_MMAP_FLAGS MAP_PRIVATE\n+#define _PR_VMBASE              0x30000000\n+#define _PR_STACK_VMBASE    0x50000000\n+#define _MD_DEFAULT_STACK_SIZE  65536L\n+#define _MD_MMAP_FLAGS          MAP_PRIVATE\n \n-#undef HAVE_STACK_GROWING_UP\n+#undef  HAVE_STACK_GROWING_UP\n #define HAVE_DLL\n #define USE_DLFCN\n #define _PR_HAVE_SOCKADDR_LEN\n@@ -83,58 +84,57 @@\n #ifdef __ppc__\n #define _PR_HAVE_ATOMIC_OPS\n #define _MD_INIT_ATOMIC()\n-extern PRInt32 _PR_DarwinPPC_AtomicIncrement(PRInt32* val);\n-#define _MD_ATOMIC_INCREMENT(val) _PR_DarwinPPC_AtomicIncrement(val)\n-extern PRInt32 _PR_DarwinPPC_AtomicDecrement(PRInt32* val);\n-#define _MD_ATOMIC_DECREMENT(val) _PR_DarwinPPC_AtomicDecrement(val)\n-extern PRInt32 _PR_DarwinPPC_AtomicSet(PRInt32* val, PRInt32 newval);\n+extern PRInt32 _PR_DarwinPPC_AtomicIncrement(PRInt32 *val);\n+#define _MD_ATOMIC_INCREMENT(val)   _PR_DarwinPPC_AtomicIncrement(val)\n+extern PRInt32 _PR_DarwinPPC_AtomicDecrement(PRInt32 *val);\n+#define _MD_ATOMIC_DECREMENT(val)   _PR_DarwinPPC_AtomicDecrement(val)\n+extern PRInt32 _PR_DarwinPPC_AtomicSet(PRInt32 *val, PRInt32 newval);\n #define _MD_ATOMIC_SET(val, newval) _PR_DarwinPPC_AtomicSet(val, newval)\n-extern PRInt32 _PR_DarwinPPC_AtomicAdd(PRInt32* ptr, PRInt32 val);\n-#define _MD_ATOMIC_ADD(ptr, val) _PR_DarwinPPC_AtomicAdd(ptr, val)\n+extern PRInt32 _PR_DarwinPPC_AtomicAdd(PRInt32 *ptr, PRInt32 val);\n+#define _MD_ATOMIC_ADD(ptr, val)    _PR_DarwinPPC_AtomicAdd(ptr, val)\n #endif /* __ppc__ */\n \n #ifdef __i386__\n #define _PR_HAVE_ATOMIC_OPS\n #define _MD_INIT_ATOMIC()\n-extern PRInt32 _PR_Darwin_x86_AtomicIncrement(PRInt32* val);\n-#define _MD_ATOMIC_INCREMENT(val) _PR_Darwin_x86_AtomicIncrement(val)\n-extern PRInt32 _PR_Darwin_x86_AtomicDecrement(PRInt32* val);\n-#define _MD_ATOMIC_DECREMENT(val) _PR_Darwin_x86_AtomicDecrement(val)\n-extern PRInt32 _PR_Darwin_x86_AtomicSet(PRInt32* val, PRInt32 newval);\n+extern PRInt32 _PR_Darwin_x86_AtomicIncrement(PRInt32 *val);\n+#define _MD_ATOMIC_INCREMENT(val)   _PR_Darwin_x86_AtomicIncrement(val)\n+extern PRInt32 _PR_Darwin_x86_AtomicDecrement(PRInt32 *val);\n+#define _MD_ATOMIC_DECREMENT(val)   _PR_Darwin_x86_AtomicDecrement(val)\n+extern PRInt32 _PR_Darwin_x86_AtomicSet(PRInt32 *val, PRInt32 newval);\n #define _MD_ATOMIC_SET(val, newval) _PR_Darwin_x86_AtomicSet(val, newval)\n-extern PRInt32 _PR_Darwin_x86_AtomicAdd(PRInt32* ptr, PRInt32 val);\n-#define _MD_ATOMIC_ADD(ptr, val) _PR_Darwin_x86_AtomicAdd(ptr, val)\n+extern PRInt32 _PR_Darwin_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val);\n+#define _MD_ATOMIC_ADD(ptr, val)    _PR_Darwin_x86_AtomicAdd(ptr, val)\n #endif /* __i386__ */\n \n #ifdef __x86_64__\n #define _PR_HAVE_ATOMIC_OPS\n #define _MD_INIT_ATOMIC()\n-extern PRInt32 _PR_Darwin_x86_64_AtomicIncrement(PRInt32* val);\n-#define _MD_ATOMIC_INCREMENT(val) _PR_Darwin_x86_64_AtomicIncrement(val)\n-extern PRInt32 _PR_Darwin_x86_64_AtomicDecrement(PRInt32* val);\n-#define _MD_ATOMIC_DECREMENT(val) _PR_Darwin_x86_64_AtomicDecrement(val)\n-extern PRInt32 _PR_Darwin_x86_64_AtomicSet(PRInt32* val, PRInt32 newval);\n+extern PRInt32 _PR_Darwin_x86_64_AtomicIncrement(PRInt32 *val);\n+#define _MD_ATOMIC_INCREMENT(val)   _PR_Darwin_x86_64_AtomicIncrement(val)\n+extern PRInt32 _PR_Darwin_x86_64_AtomicDecrement(PRInt32 *val);\n+#define _MD_ATOMIC_DECREMENT(val)   _PR_Darwin_x86_64_AtomicDecrement(val)\n+extern PRInt32 _PR_Darwin_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval);\n #define _MD_ATOMIC_SET(val, newval) _PR_Darwin_x86_64_AtomicSet(val, newval)\n-extern PRInt32 _PR_Darwin_x86_64_AtomicAdd(PRInt32* ptr, PRInt32 val);\n-#define _MD_ATOMIC_ADD(ptr, val) _PR_Darwin_x86_64_AtomicAdd(ptr, val)\n+extern PRInt32 _PR_Darwin_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val);\n+#define _MD_ATOMIC_ADD(ptr, val)    _PR_Darwin_x86_64_AtomicAdd(ptr, val)\n #endif /* __x86_64__ */\n \n #ifdef __aarch64__\n #define _PR_HAVE_ATOMIC_OPS\n #define _MD_INIT_ATOMIC()\n-#define _MD_ATOMIC_INCREMENT(val) __sync_add_and_fetch(val, 1)\n-#define _MD_ATOMIC_DECREMENT(val) __sync_sub_and_fetch(val, 1)\n+#define _MD_ATOMIC_INCREMENT(val)   __sync_add_and_fetch(val, 1)\n+#define _MD_ATOMIC_DECREMENT(val)   __sync_sub_and_fetch(val, 1)\n #define _MD_ATOMIC_SET(val, newval) __sync_lock_test_and_set(val, newval)\n-#define _MD_ATOMIC_ADD(ptr, val) __sync_add_and_fetch(ptr, val)\n+#define _MD_ATOMIC_ADD(ptr, val)    __sync_add_and_fetch(ptr, val)\n #endif /* __aarch64__ */\n \n #if defined(__arm__)\n #define _PR_HAVE_ATOMIC_OPS\n #define _MD_INIT_ATOMIC()\n-#define _MD_ATOMIC_INCREMENT(val) OSAtomicIncrement32(val)\n-#define _MD_ATOMIC_DECREMENT(val) OSAtomicDecrement32(val)\n-static inline PRInt32\n-_MD_ATOMIC_SET(PRInt32* val, PRInt32 newval)\n+#define _MD_ATOMIC_INCREMENT(val)   OSAtomicIncrement32(val)\n+#define _MD_ATOMIC_DECREMENT(val)   OSAtomicDecrement32(val)\n+static inline PRInt32 _MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval)\n {\n     PRInt32 oldval;\n     do {\n@@ -142,7 +142,7 @@ _MD_ATOMIC_SET(PRInt32* val, PRInt32 newval)\n     } while (!OSAtomicCompareAndSwap32(oldval, newval, val));\n     return oldval;\n }\n-#define _MD_ATOMIC_ADD(ptr, val) OSAtomicAdd32(val, ptr)\n+#define _MD_ATOMIC_ADD(ptr, val)    OSAtomicAdd32(val, ptr)\n #endif /* __arm__ */\n \n #define USE_SETJMP\n@@ -153,37 +153,37 @@ _MD_ATOMIC_SET(PRInt32* val, PRInt32 newval)\n \n #define PR_CONTEXT_TYPE jmp_buf\n \n-#define CONTEXT(_th) ((_th)->md.context)\n-#define _MD_GET_SP(_th) (((struct sigcontext*)(_th)->md.context)->sc_onstack)\n-#define PR_NUM_GCREGS _JBLEN\n+#define CONTEXT(_th)       ((_th)->md.context)\n+#define _MD_GET_SP(_th)    (((struct sigcontext *) (_th)->md.context)->sc_onstack)\n+#define PR_NUM_GCREGS       _JBLEN\n \n /*\n ** Initialize a thread context to run \"_main()\" when started\n */\n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)       \\\n-    {                                                       \\\n-        *status = PR_TRUE;                                  \\\n-        if (setjmp(CONTEXT(_thread))) {                     \\\n-            _main();                                        \\\n-        }                                                   \\\n-        _MD_GET_SP(_thread) = (unsigned char*)((_sp) - 64); \\\n-    }\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)  \\\n+{  \\\n+    *status = PR_TRUE;  \\\n+    if (setjmp(CONTEXT(_thread))) {  \\\n+        _main();  \\\n+    }  \\\n+    _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 64); \\\n+}\n \n-#define _MD_SWITCH_CONTEXT(_thread)    \\\n-    if (!setjmp(CONTEXT(_thread))) {   \\\n-        (_thread)->md.errcode = errno; \\\n-        _PR_Schedule();                \\\n+#define _MD_SWITCH_CONTEXT(_thread)  \\\n+    if (!setjmp(CONTEXT(_thread))) {  \\\n+    (_thread)->md.errcode = errno;  \\\n+    _PR_Schedule();  \\\n     }\n \n /*\n ** Restore a thread context, saved by _MD_SWITCH_CONTEXT\n */\n-#define _MD_RESTORE_CONTEXT(_thread)     \\\n-    {                                    \\\n-        errno = (_thread)->md.errcode;   \\\n-        _MD_SET_CURRENT_THREAD(_thread); \\\n-        longjmp(CONTEXT(_thread), 1);    \\\n-    }\n+#define _MD_RESTORE_CONTEXT(_thread) \\\n+{   \\\n+    errno = (_thread)->md.errcode;  \\\n+    _MD_SET_CURRENT_THREAD(_thread);  \\\n+    longjmp(CONTEXT(_thread), 1);  \\\n+}\n \n /* Machine-dependent (MD) data structures */\n \n@@ -225,29 +225,29 @@ struct _MDCPU_Unix {\n     PRInt32 ioq_osfd_cnt;\n #ifndef _PR_USE_POLL\n     fd_set fd_read_set, fd_write_set, fd_exception_set;\n-    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD],\n-        fd_exception_cnt[_PR_MD_MAX_OSFD];\n+    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],\n+            fd_exception_cnt[_PR_MD_MAX_OSFD];\n #else\n-    struct pollfd* ioq_pollfds;\n+    struct pollfd *ioq_pollfds;\n     int ioq_pollfds_size;\n-#endif /* _PR_USE_POLL */\n+#endif  /* _PR_USE_POLL */\n };\n \n-#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)\n+#define _PR_IOQ(_cpu)           ((_cpu)->md.md_unix.ioQ)\n #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n-#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)\n-#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)\n-#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)\n-#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)\n-#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)\n-#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)\n-#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)\n-#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)\n-#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)\n-#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)\n-#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)\n-\n-#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32\n+#define _PR_FD_READ_SET(_cpu)       ((_cpu)->md.md_unix.fd_read_set)\n+#define _PR_FD_READ_CNT(_cpu)       ((_cpu)->md.md_unix.fd_read_cnt)\n+#define _PR_FD_WRITE_SET(_cpu)      ((_cpu)->md.md_unix.fd_write_set)\n+#define _PR_FD_WRITE_CNT(_cpu)      ((_cpu)->md.md_unix.fd_write_cnt)\n+#define _PR_FD_EXCEPTION_SET(_cpu)  ((_cpu)->md.md_unix.fd_exception_set)\n+#define _PR_FD_EXCEPTION_CNT(_cpu)  ((_cpu)->md.md_unix.fd_exception_cnt)\n+#define _PR_IOQ_TIMEOUT(_cpu)       ((_cpu)->md.md_unix.ioq_timeout)\n+#define _PR_IOQ_MAX_OSFD(_cpu)      ((_cpu)->md.md_unix.ioq_max_osfd)\n+#define _PR_IOQ_OSFD_CNT(_cpu)      ((_cpu)->md.md_unix.ioq_osfd_cnt)\n+#define _PR_IOQ_POLLFDS(_cpu)       ((_cpu)->md.md_unix.ioq_pollfds)\n+#define _PR_IOQ_POLLFDS_SIZE(_cpu)  ((_cpu)->md.md_unix.ioq_pollfds_size)\n+\n+#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)  32\n \n struct _MDCPU {\n     struct _MDCPU_Unix md_unix;\n@@ -262,42 +262,45 @@ struct _MDCPU {\n #define _MD_IOQ_LOCK()\n #define _MD_IOQ_UNLOCK()\n \n-extern PRStatus _MD_InitializeThread(PRThread* thread);\n+extern PRStatus _MD_InitializeThread(PRThread *thread);\n \n-#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)\n-#define _MD_INIT_THREAD _MD_InitializeThread\n+#define _MD_INIT_RUNNING_CPU(cpu)       _MD_unix_init_running_cpu(cpu)\n+#define _MD_INIT_THREAD                 _MD_InitializeThread\n #define _MD_EXIT_THREAD(thread)\n-#define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread\n-#define _MD_RESUME_THREAD(thread) _MD_resume_thread\n+#define _MD_SUSPEND_THREAD(thread)      _MD_suspend_thread\n+#define _MD_RESUME_THREAD(thread)       _MD_resume_thread\n #define _MD_CLEAN_THREAD(_thread)\n \n-extern PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                                  PRThreadPriority priority,\n-                                  PRThreadScope scope, PRThreadState state,\n-                                  PRUint32 stackSize);\n-extern void _MD_SET_PRIORITY(struct _MDThread* thread, PRUintn newPri);\n-extern PRStatus _MD_WAIT(PRThread*, PRIntervalTime timeout);\n-extern PRStatus _MD_WAKEUP_WAITER(PRThread*);\n+extern PRStatus _MD_CREATE_THREAD(\n+    PRThread *thread,\n+    void (*start) (void *),\n+    PRThreadPriority priority,\n+    PRThreadScope scope,\n+    PRThreadState state,\n+    PRUint32 stackSize);\n+extern void _MD_SET_PRIORITY(struct _MDThread *thread, PRUintn newPri);\n+extern PRStatus _MD_WAIT(PRThread *, PRIntervalTime timeout);\n+extern PRStatus _MD_WAKEUP_WAITER(PRThread *);\n extern void _MD_YIELD(void);\n \n #endif /* ! _PR_PTHREADS */\n \n-#define _MD_EARLY_INIT _MD_EarlyInit\n-#define _MD_FINAL_INIT _PR_UnixInit\n-#define _MD_INTERVAL_INIT _PR_Mach_IntervalInit\n-#define _MD_GET_INTERVAL _PR_Mach_GetInterval\n-#define _MD_INTERVAL_PER_SEC _PR_Mach_TicksPerSecond\n+#define _MD_EARLY_INIT          _MD_EarlyInit\n+#define _MD_FINAL_INIT          _PR_UnixInit\n+#define _MD_INTERVAL_INIT       _PR_Mach_IntervalInit\n+#define _MD_GET_INTERVAL        _PR_Mach_GetInterval\n+#define _MD_INTERVAL_PER_SEC    _PR_Mach_TicksPerSecond\n \n-extern void _MD_EarlyInit(void);\n-extern void _PR_Mach_IntervalInit(void);\n-extern PRIntervalTime _PR_Mach_GetInterval(void);\n-extern PRIntervalTime _PR_Mach_TicksPerSecond(void);\n+extern void             _MD_EarlyInit(void);\n+extern void             _PR_Mach_IntervalInit(void);\n+extern PRIntervalTime   _PR_Mach_GetInterval(void);\n+extern PRIntervalTime   _PR_Mach_TicksPerSecond(void);\n \n /*\n  * We wrapped the select() call.  _MD_SELECT refers to the built-in,\n  * unwrapped version.\n  */\n-#define _MD_SELECT(nfds, r, w, e, tv) syscall(SYS_select, nfds, r, w, e, tv)\n+#define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)\n \n /* For writev() */\n #include <sys/uio.h>\ndiff --git a/nspr/pr/include/md/_freebsd.cfg b/nspr/pr/include/md/_freebsd.cfg\nindex 6bea76d..1d1039a 100644\n--- a/nspr/pr/include/md/_freebsd.cfg\n+++ b/nspr/pr/include/md/_freebsd.cfg\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/md/_freebsd.h b/nspr/pr/include/md/_freebsd.h\nindex 20795d7..118cb9f 100644\n--- a/nspr/pr/include/md/_freebsd.h\n+++ b/nspr/pr/include/md/_freebsd.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,12 +9,12 @@\n #include \"prthread.h\"\n \n #if __FreeBSD__ >= 2\n-#include <osreldate.h> /* for __FreeBSD_version */\n+#include <osreldate.h>  /* for __FreeBSD_version */\n #endif\n #include <sys/syscall.h>\n \n-#define PR_LINKER_ARCH \"freebsd\"\n-#define _PR_SI_SYSNAME \"FREEBSD\"\n+#define PR_LINKER_ARCH  \"freebsd\"\n+#define _PR_SI_SYSNAME  \"FREEBSD\"\n #if defined(__i386__)\n #define _PR_SI_ARCHITECTURE \"x86\"\n #elif defined(__alpha__)\n@@ -40,17 +41,17 @@\n #error \"Unknown CPU architecture\"\n #endif\n #if defined(__ELF__)\n-#define PR_DLL_SUFFIX \".so\"\n+#define PR_DLL_SUFFIX          \".so\"\n #else\n-#define PR_DLL_SUFFIX \".so.1.0\"\n+#define PR_DLL_SUFFIX          \".so.1.0\"\n #endif\n \n-#define _PR_VMBASE 0x30000000\n-#define _PR_STACK_VMBASE 0x50000000\n-#define _MD_DEFAULT_STACK_SIZE 65536L\n-#define _MD_MMAP_FLAGS MAP_PRIVATE\n+#define _PR_VMBASE              0x30000000\n+#define _PR_STACK_VMBASE    0x50000000\n+#define _MD_DEFAULT_STACK_SIZE  65536L\n+#define _MD_MMAP_FLAGS          MAP_PRIVATE\n \n-#undef HAVE_STACK_GROWING_UP\n+#undef  HAVE_STACK_GROWING_UP\n #define HAVE_DLL\n #define USE_DLFCN\n #define _PR_HAVE_SOCKADDR_LEN\n@@ -94,36 +95,36 @@\n \n #define CONTEXT(_th) ((_th)->md.context)\n \n-#define _MD_GET_SP(_th) (_th)->md.context[0]._sjb[2]\n-#define PR_NUM_GCREGS _JBLEN\n+#define _MD_GET_SP(_th)    (_th)->md.context[0]._sjb[2]\n+#define PR_NUM_GCREGS   _JBLEN\n \n /*\n ** Initialize a thread context to run \"_main()\" when started\n */\n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)       \\\n-    {                                                       \\\n-        *status = PR_TRUE;                                  \\\n-        if (sigsetjmp(CONTEXT(_thread), 1)) {               \\\n-            _main();                                        \\\n-        }                                                   \\\n-        _MD_GET_SP(_thread) = (unsigned char*)((_sp) - 64); \\\n-    }\n-\n-#define _MD_SWITCH_CONTEXT(_thread)        \\\n-    if (!sigsetjmp(CONTEXT(_thread), 1)) { \\\n-        (_thread)->md.errcode = errno;     \\\n-        _PR_Schedule();                    \\\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)  \\\n+{  \\\n+    *status = PR_TRUE;  \\\n+    if (sigsetjmp(CONTEXT(_thread), 1)) {  \\\n+        _main();  \\\n+    }  \\\n+    _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 64); \\\n+}\n+\n+#define _MD_SWITCH_CONTEXT(_thread)  \\\n+    if (!sigsetjmp(CONTEXT(_thread), 1)) {  \\\n+    (_thread)->md.errcode = errno;  \\\n+    _PR_Schedule();  \\\n     }\n \n /*\n ** Restore a thread context, saved by _MD_SWITCH_CONTEXT\n */\n-#define _MD_RESTORE_CONTEXT(_thread)     \\\n-    {                                    \\\n-        errno = (_thread)->md.errcode;   \\\n-        _MD_SET_CURRENT_THREAD(_thread); \\\n-        siglongjmp(CONTEXT(_thread), 1); \\\n-    }\n+#define _MD_RESTORE_CONTEXT(_thread) \\\n+{   \\\n+    errno = (_thread)->md.errcode;  \\\n+    _MD_SET_CURRENT_THREAD(_thread);  \\\n+    siglongjmp(CONTEXT(_thread), 1);  \\\n+}\n \n /* Machine-dependent (MD) data structures */\n \n@@ -165,29 +166,29 @@ struct _MDCPU_Unix {\n     PRInt32 ioq_osfd_cnt;\n #ifndef _PR_USE_POLL\n     fd_set fd_read_set, fd_write_set, fd_exception_set;\n-    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD],\n-        fd_exception_cnt[_PR_MD_MAX_OSFD];\n+    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],\n+            fd_exception_cnt[_PR_MD_MAX_OSFD];\n #else\n-    struct pollfd* ioq_pollfds;\n+    struct pollfd *ioq_pollfds;\n     int ioq_pollfds_size;\n-#endif /* _PR_USE_POLL */\n+#endif  /* _PR_USE_POLL */\n };\n \n-#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)\n+#define _PR_IOQ(_cpu)           ((_cpu)->md.md_unix.ioQ)\n #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n-#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)\n-#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)\n-#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)\n-#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)\n-#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)\n-#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)\n-#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)\n-#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)\n-#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)\n-#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)\n-#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)\n-\n-#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32\n+#define _PR_FD_READ_SET(_cpu)       ((_cpu)->md.md_unix.fd_read_set)\n+#define _PR_FD_READ_CNT(_cpu)       ((_cpu)->md.md_unix.fd_read_cnt)\n+#define _PR_FD_WRITE_SET(_cpu)      ((_cpu)->md.md_unix.fd_write_set)\n+#define _PR_FD_WRITE_CNT(_cpu)      ((_cpu)->md.md_unix.fd_write_cnt)\n+#define _PR_FD_EXCEPTION_SET(_cpu)  ((_cpu)->md.md_unix.fd_exception_set)\n+#define _PR_FD_EXCEPTION_CNT(_cpu)  ((_cpu)->md.md_unix.fd_exception_cnt)\n+#define _PR_IOQ_TIMEOUT(_cpu)       ((_cpu)->md.md_unix.ioq_timeout)\n+#define _PR_IOQ_MAX_OSFD(_cpu)      ((_cpu)->md.md_unix.ioq_max_osfd)\n+#define _PR_IOQ_OSFD_CNT(_cpu)      ((_cpu)->md.md_unix.ioq_osfd_cnt)\n+#define _PR_IOQ_POLLFDS(_cpu)       ((_cpu)->md.md_unix.ioq_pollfds)\n+#define _PR_IOQ_POLLFDS_SIZE(_cpu)  ((_cpu)->md.md_unix.ioq_pollfds_size)\n+\n+#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)  32\n \n struct _MDCPU {\n     struct _MDCPU_Unix md_unix;\n@@ -202,47 +203,50 @@ struct _MDCPU {\n #define _MD_IOQ_LOCK()\n #define _MD_IOQ_UNLOCK()\n \n-extern PRStatus _MD_InitializeThread(PRThread* thread);\n+extern PRStatus _MD_InitializeThread(PRThread *thread);\n \n-#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)\n-#define _MD_INIT_THREAD _MD_InitializeThread\n+#define _MD_INIT_RUNNING_CPU(cpu)       _MD_unix_init_running_cpu(cpu)\n+#define _MD_INIT_THREAD                 _MD_InitializeThread\n #define _MD_EXIT_THREAD(thread)\n-#define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread\n-#define _MD_RESUME_THREAD(thread) _MD_resume_thread\n+#define _MD_SUSPEND_THREAD(thread)      _MD_suspend_thread\n+#define _MD_RESUME_THREAD(thread)       _MD_resume_thread\n #define _MD_CLEAN_THREAD(_thread)\n \n-extern PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                                  PRThreadPriority priority,\n-                                  PRThreadScope scope, PRThreadState state,\n-                                  PRUint32 stackSize);\n-extern void _MD_SET_PRIORITY(struct _MDThread* thread, PRUintn newPri);\n-extern PRStatus _MD_WAIT(PRThread*, PRIntervalTime timeout);\n-extern PRStatus _MD_WAKEUP_WAITER(PRThread*);\n+extern PRStatus _MD_CREATE_THREAD(\n+    PRThread *thread,\n+    void (*start) (void *),\n+    PRThreadPriority priority,\n+    PRThreadScope scope,\n+    PRThreadState state,\n+    PRUint32 stackSize);\n+extern void _MD_SET_PRIORITY(struct _MDThread *thread, PRUintn newPri);\n+extern PRStatus _MD_WAIT(PRThread *, PRIntervalTime timeout);\n+extern PRStatus _MD_WAKEUP_WAITER(PRThread *);\n extern void _MD_YIELD(void);\n \n #endif /* ! _PR_PTHREADS */\n \n extern void _MD_EarlyInit(void);\n \n-#define _MD_EARLY_INIT _MD_EarlyInit\n-#define _MD_FINAL_INIT _PR_UnixInit\n+#define _MD_EARLY_INIT                  _MD_EarlyInit\n+#define _MD_FINAL_INIT          _PR_UnixInit\n #define _PR_HAVE_CLOCK_MONOTONIC\n \n /*\n  * We wrapped the select() call.  _MD_SELECT refers to the built-in,\n  * unwrapped version.\n  */\n-#define _MD_SELECT(nfds, r, w, e, tv) syscall(SYS_select, nfds, r, w, e, tv)\n+#define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)\n \n #if defined(_PR_POLL_AVAILABLE)\n #include <poll.h>\n-#define _MD_POLL(fds, nfds, timeout) syscall(SYS_poll, fds, nfds, timeout)\n+#define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)\n #endif\n \n-/* freebsd has INADDR_LOOPBACK defined, but in /usr/include/rpc/types.h, and I\n-   didn't want to be including that.. */\n+/* freebsd has INADDR_LOOPBACK defined, but in /usr/include/rpc/types.h, and I didn't\n+   want to be including that.. */\n #ifndef INADDR_LOOPBACK\n-#define INADDR_LOOPBACK (u_long)0x7F000001\n+#define INADDR_LOOPBACK         (u_long)0x7F000001\n #endif\n \n /* For writev() */\ndiff --git a/nspr/pr/include/md/_linux.cfg b/nspr/pr/include/md/_linux.cfg\nindex f92f1b4..009d5e5 100644\n--- a/nspr/pr/include/md/_linux.cfg\n+++ b/nspr/pr/include/md/_linux.cfg\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/md/_linux.h b/nspr/pr/include/md/_linux.h\nindex 9d3f002..bfa3677 100644\n--- a/nspr/pr/include/md/_linux.h\n+++ b/nspr/pr/include/md/_linux.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -16,8 +17,8 @@\n  * Internal configuration macros\n  */\n \n-#define PR_LINKER_ARCH \"linux\"\n-#define _PR_SI_SYSNAME \"LINUX\"\n+#define PR_LINKER_ARCH  \"linux\"\n+#define _PR_SI_SYSNAME  \"LINUX\"\n #ifdef __powerpc64__\n #define _PR_SI_ARCHITECTURE \"ppc64\"\n #elif defined(__powerpc__)\n@@ -77,18 +78,18 @@\n #else\n #error \"Unknown CPU architecture\"\n #endif\n-#define PR_DLL_SUFFIX \".so\"\n+#define PR_DLL_SUFFIX       \".so\"\n \n-#define _PR_VMBASE 0x30000000\n-#define _PR_STACK_VMBASE 0x50000000\n-#define _MD_DEFAULT_STACK_SIZE 65536L\n-#define _MD_MMAP_FLAGS MAP_PRIVATE\n+#define _PR_VMBASE              0x30000000\n+#define _PR_STACK_VMBASE    0x50000000\n+#define _MD_DEFAULT_STACK_SIZE  65536L\n+#define _MD_MMAP_FLAGS          MAP_PRIVATE\n \n #if defined(__aarch64__) || defined(__mips__)\n-#define _MD_MINIMUM_STACK_SIZE 0x20000\n+#define _MD_MINIMUM_STACK_SIZE  0x20000\n #endif\n \n-#undef HAVE_STACK_GROWING_UP\n+#undef  HAVE_STACK_GROWING_UP\n \n /*\n  * Elf linux supports dl* functions\n@@ -106,40 +107,40 @@\n #if defined(__i386__)\n #define _PR_HAVE_ATOMIC_OPS\n #define _MD_INIT_ATOMIC()\n-extern PRInt32 _PR_x86_AtomicIncrement(PRInt32* val);\n-#define _MD_ATOMIC_INCREMENT _PR_x86_AtomicIncrement\n-extern PRInt32 _PR_x86_AtomicDecrement(PRInt32* val);\n-#define _MD_ATOMIC_DECREMENT _PR_x86_AtomicDecrement\n-extern PRInt32 _PR_x86_AtomicAdd(PRInt32* ptr, PRInt32 val);\n-#define _MD_ATOMIC_ADD _PR_x86_AtomicAdd\n-extern PRInt32 _PR_x86_AtomicSet(PRInt32* val, PRInt32 newval);\n-#define _MD_ATOMIC_SET _PR_x86_AtomicSet\n+extern PRInt32 _PR_x86_AtomicIncrement(PRInt32 *val);\n+#define _MD_ATOMIC_INCREMENT          _PR_x86_AtomicIncrement\n+extern PRInt32 _PR_x86_AtomicDecrement(PRInt32 *val);\n+#define _MD_ATOMIC_DECREMENT          _PR_x86_AtomicDecrement\n+extern PRInt32 _PR_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val);\n+#define _MD_ATOMIC_ADD                _PR_x86_AtomicAdd\n+extern PRInt32 _PR_x86_AtomicSet(PRInt32 *val, PRInt32 newval);\n+#define _MD_ATOMIC_SET                _PR_x86_AtomicSet\n #endif\n \n #if defined(__ia64__)\n #define _PR_HAVE_ATOMIC_OPS\n #define _MD_INIT_ATOMIC()\n-extern PRInt32 _PR_ia64_AtomicIncrement(PRInt32* val);\n-#define _MD_ATOMIC_INCREMENT _PR_ia64_AtomicIncrement\n-extern PRInt32 _PR_ia64_AtomicDecrement(PRInt32* val);\n-#define _MD_ATOMIC_DECREMENT _PR_ia64_AtomicDecrement\n-extern PRInt32 _PR_ia64_AtomicAdd(PRInt32* ptr, PRInt32 val);\n-#define _MD_ATOMIC_ADD _PR_ia64_AtomicAdd\n-extern PRInt32 _PR_ia64_AtomicSet(PRInt32* val, PRInt32 newval);\n-#define _MD_ATOMIC_SET _PR_ia64_AtomicSet\n+extern PRInt32 _PR_ia64_AtomicIncrement(PRInt32 *val);\n+#define _MD_ATOMIC_INCREMENT          _PR_ia64_AtomicIncrement\n+extern PRInt32 _PR_ia64_AtomicDecrement(PRInt32 *val);\n+#define _MD_ATOMIC_DECREMENT          _PR_ia64_AtomicDecrement\n+extern PRInt32 _PR_ia64_AtomicAdd(PRInt32 *ptr, PRInt32 val);\n+#define _MD_ATOMIC_ADD                _PR_ia64_AtomicAdd\n+extern PRInt32 _PR_ia64_AtomicSet(PRInt32 *val, PRInt32 newval);\n+#define _MD_ATOMIC_SET                _PR_ia64_AtomicSet\n #endif\n \n #if defined(__x86_64__)\n #define _PR_HAVE_ATOMIC_OPS\n #define _MD_INIT_ATOMIC()\n-extern PRInt32 _PR_x86_64_AtomicIncrement(PRInt32* val);\n-#define _MD_ATOMIC_INCREMENT _PR_x86_64_AtomicIncrement\n-extern PRInt32 _PR_x86_64_AtomicDecrement(PRInt32* val);\n-#define _MD_ATOMIC_DECREMENT _PR_x86_64_AtomicDecrement\n-extern PRInt32 _PR_x86_64_AtomicAdd(PRInt32* ptr, PRInt32 val);\n-#define _MD_ATOMIC_ADD _PR_x86_64_AtomicAdd\n-extern PRInt32 _PR_x86_64_AtomicSet(PRInt32* val, PRInt32 newval);\n-#define _MD_ATOMIC_SET _PR_x86_64_AtomicSet\n+extern PRInt32 _PR_x86_64_AtomicIncrement(PRInt32 *val);\n+#define _MD_ATOMIC_INCREMENT          _PR_x86_64_AtomicIncrement\n+extern PRInt32 _PR_x86_64_AtomicDecrement(PRInt32 *val);\n+#define _MD_ATOMIC_DECREMENT          _PR_x86_64_AtomicDecrement\n+extern PRInt32 _PR_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val);\n+#define _MD_ATOMIC_ADD                _PR_x86_64_AtomicAdd\n+extern PRInt32 _PR_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval);\n+#define _MD_ATOMIC_SET                _PR_x86_64_AtomicSet\n #endif\n \n #if defined(__loongarch__)\n@@ -169,14 +170,14 @@ extern PRInt32 _PR_x86_64_AtomicSet(PRInt32* val, PRInt32 newval);\n #if defined(__powerpc__) && !defined(__powerpc64__)\n #define _PR_HAVE_ATOMIC_OPS\n #define _MD_INIT_ATOMIC()\n-extern PRInt32 _PR_ppc_AtomicIncrement(PRInt32* val);\n-#define _MD_ATOMIC_INCREMENT _PR_ppc_AtomicIncrement\n-extern PRInt32 _PR_ppc_AtomicDecrement(PRInt32* val);\n-#define _MD_ATOMIC_DECREMENT _PR_ppc_AtomicDecrement\n-extern PRInt32 _PR_ppc_AtomicAdd(PRInt32* ptr, PRInt32 val);\n-#define _MD_ATOMIC_ADD _PR_ppc_AtomicAdd\n-extern PRInt32 _PR_ppc_AtomicSet(PRInt32* val, PRInt32 newval);\n-#define _MD_ATOMIC_SET _PR_ppc_AtomicSet\n+extern PRInt32 _PR_ppc_AtomicIncrement(PRInt32 *val);\n+#define _MD_ATOMIC_INCREMENT          _PR_ppc_AtomicIncrement\n+extern PRInt32 _PR_ppc_AtomicDecrement(PRInt32 *val);\n+#define _MD_ATOMIC_DECREMENT          _PR_ppc_AtomicDecrement\n+extern PRInt32 _PR_ppc_AtomicAdd(PRInt32 *ptr, PRInt32 val);\n+#define _MD_ATOMIC_ADD                _PR_ppc_AtomicAdd\n+extern PRInt32 _PR_ppc_AtomicSet(PRInt32 *val, PRInt32 newval);\n+#define _MD_ATOMIC_SET                _PR_ppc_AtomicSet\n #endif\n \n #if defined(__powerpc64__)\n@@ -214,57 +215,57 @@ extern PRInt32 _PR_ppc_AtomicSet(PRInt32* val, PRInt32 newval);\n #if defined(__alpha)\n #define _PR_HAVE_ATOMIC_OPS\n #define _MD_INIT_ATOMIC()\n-#define _MD_ATOMIC_ADD(ptr, i)                                      \\\n-    ({                                                              \\\n-        PRInt32 __atomic_tmp, __atomic_ret;                         \\\n-        __asm__ __volatile__(                                       \\\n-            \"1: ldl_l   %[ret], %[val]          \\n\"                 \\\n-            \"   addl    %[ret], %[inc], %[tmp]  \\n\"                 \\\n-            \"   addl    %[ret], %[inc], %[ret]  \\n\"                 \\\n-            \"   stl_c   %[tmp], %[val]          \\n\"                 \\\n-            \"   beq     %[tmp], 2f              \\n\"                 \\\n-            \".subsection 2                      \\n\"                 \\\n-            \"2: br      1b                      \\n\"                 \\\n-            \".previous\"                                             \\\n-            : [ret] \"=&r\"(__atomic_ret), [tmp] \"=&r\"(__atomic_tmp), \\\n-              [val] \"=m\"(*ptr)                                      \\\n-            : [inc] \"Ir\"(i), \"m\"(*ptr));                            \\\n-        __atomic_ret;                                               \\\n-    })\n+#define _MD_ATOMIC_ADD(ptr, i) ({               \\\n+    PRInt32 __atomic_tmp, __atomic_ret;   \\\n+    __asm__ __volatile__(                       \\\n+    \"1: ldl_l   %[ret], %[val]          \\n\"     \\\n+    \"   addl    %[ret], %[inc], %[tmp]  \\n\"     \\\n+    \"   addl    %[ret], %[inc], %[ret]  \\n\"     \\\n+    \"   stl_c   %[tmp], %[val]          \\n\"     \\\n+    \"   beq     %[tmp], 2f              \\n\"     \\\n+    \".subsection 2                      \\n\"     \\\n+    \"2: br      1b                      \\n\"     \\\n+    \".previous\"                                 \\\n+    : [ret] \"=&r\" (__atomic_ret),               \\\n+      [tmp] \"=&r\" (__atomic_tmp),               \\\n+      [val] \"=m\" (*ptr)                         \\\n+    : [inc] \"Ir\" (i), \"m\" (*ptr));              \\\n+    __atomic_ret;                               \\\n+})\n #define _MD_ATOMIC_INCREMENT(ptr) _MD_ATOMIC_ADD(ptr, 1)\n-#define _MD_ATOMIC_DECREMENT(ptr)                                   \\\n-    ({                                                              \\\n-        PRInt32 __atomic_tmp, __atomic_ret;                         \\\n-        __asm__ __volatile__(                                       \\\n-            \"1: ldl_l   %[ret], %[val]          \\n\"                 \\\n-            \"   subl    %[ret], 1, %[tmp]       \\n\"                 \\\n-            \"   subl    %[ret], 1, %[ret]       \\n\"                 \\\n-            \"   stl_c   %[tmp], %[val]          \\n\"                 \\\n-            \"   beq     %[tmp], 2f              \\n\"                 \\\n-            \".subsection 2                      \\n\"                 \\\n-            \"2: br      1b                      \\n\"                 \\\n-            \".previous\"                                             \\\n-            : [ret] \"=&r\"(__atomic_ret), [tmp] \"=&r\"(__atomic_tmp), \\\n-              [val] \"=m\"(*ptr)                                      \\\n-            : \"m\"(*ptr));                                           \\\n-        __atomic_ret;                                               \\\n-    })\n-#define _MD_ATOMIC_SET(ptr, n)                                      \\\n-    ({                                                              \\\n-        PRInt32 __atomic_tmp, __atomic_ret;                         \\\n-        __asm__ __volatile__(                                       \\\n-            \"1: ldl_l   %[ret], %[val]          \\n\"                 \\\n-            \"   mov     %[newval], %[tmp]       \\n\"                 \\\n-            \"   stl_c   %[tmp], %[val]          \\n\"                 \\\n-            \"   beq     %[tmp], 2f              \\n\"                 \\\n-            \".subsection 2                      \\n\"                 \\\n-            \"2: br      1b                      \\n\"                 \\\n-            \".previous\"                                             \\\n-            : [ret] \"=&r\"(__atomic_ret), [tmp] \"=&r\"(__atomic_tmp), \\\n-              [val] \"=m\"(*ptr)                                      \\\n-            : [newval] \"Ir\"(n), \"m\"(*ptr));                         \\\n-        __atomic_ret;                                               \\\n-    })\n+#define _MD_ATOMIC_DECREMENT(ptr) ({            \\\n+    PRInt32 __atomic_tmp, __atomic_ret;   \\\n+    __asm__ __volatile__(                       \\\n+    \"1: ldl_l   %[ret], %[val]          \\n\"     \\\n+    \"   subl    %[ret], 1, %[tmp]       \\n\"     \\\n+    \"   subl    %[ret], 1, %[ret]       \\n\"     \\\n+    \"   stl_c   %[tmp], %[val]          \\n\"     \\\n+    \"   beq     %[tmp], 2f              \\n\"     \\\n+    \".subsection 2                      \\n\"     \\\n+    \"2: br      1b                      \\n\"     \\\n+    \".previous\"                                 \\\n+    : [ret] \"=&r\" (__atomic_ret),               \\\n+      [tmp] \"=&r\" (__atomic_tmp),               \\\n+      [val] \"=m\" (*ptr)                         \\\n+    : \"m\" (*ptr));                              \\\n+    __atomic_ret;                               \\\n+})\n+#define _MD_ATOMIC_SET(ptr, n) ({               \\\n+    PRInt32 __atomic_tmp, __atomic_ret;   \\\n+    __asm__ __volatile__(                       \\\n+    \"1: ldl_l   %[ret], %[val]          \\n\"     \\\n+    \"   mov     %[newval], %[tmp]       \\n\"     \\\n+    \"   stl_c   %[tmp], %[val]          \\n\"     \\\n+    \"   beq     %[tmp], 2f              \\n\"     \\\n+    \".subsection 2                      \\n\"     \\\n+    \"2: br      1b                      \\n\"     \\\n+    \".previous\"                                 \\\n+    : [ret] \"=&r\" (__atomic_ret),               \\\n+      [tmp] \"=&r\"(__atomic_tmp),                \\\n+      [val] \"=m\" (*ptr)                         \\\n+    : [newval] \"Ir\" (n), \"m\" (*ptr));           \\\n+    __atomic_ret;                               \\\n+})\n #endif\n \n #if defined(__arm__) || defined(__aarch64__)\n@@ -290,17 +291,16 @@ extern PRInt32 _PR_ppc_AtomicSet(PRInt32* val, PRInt32 newval);\n  * Atomically store newval in *ptr if *ptr is equal to oldval.\n  * Return zero if *ptr was changed or non-zero if no exchange happened.\n  */\n-typedef int(__kernel_cmpxchg_t)(int oldval, int newval, volatile int* ptr);\n-#define __kernel_cmpxchg (*(__kernel_cmpxchg_t*)0xffff0fc0)\n+typedef int (__kernel_cmpxchg_t)(int oldval, int newval, volatile int *ptr);\n+#define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0)\n \n #define _MD_ATOMIC_INCREMENT(ptr) _MD_ATOMIC_ADD(ptr, 1)\n #define _MD_ATOMIC_DECREMENT(ptr) _MD_ATOMIC_ADD(ptr, -1)\n \n-static inline PRInt32\n-_MD_ATOMIC_ADD(PRInt32* ptr, PRInt32 n)\n+static inline PRInt32 _MD_ATOMIC_ADD(PRInt32 *ptr, PRInt32 n)\n {\n     PRInt32 ov, nv;\n-    volatile PRInt32* vp = ptr;\n+    volatile PRInt32 *vp = ptr;\n \n     do {\n         ov = *vp;\n@@ -310,11 +310,10 @@ _MD_ATOMIC_ADD(PRInt32* ptr, PRInt32 n)\n     return nv;\n }\n \n-static inline PRInt32\n-_MD_ATOMIC_SET(PRInt32* ptr, PRInt32 nv)\n+static inline PRInt32 _MD_ATOMIC_SET(PRInt32 *ptr, PRInt32 nv)\n {\n     PRInt32 ov;\n-    volatile PRInt32* vp = ptr;\n+    volatile PRInt32 *vp = ptr;\n \n     do {\n         ov = *vp;\n@@ -333,14 +332,14 @@ _MD_ATOMIC_SET(PRInt32* ptr, PRInt32 nv)\n #define _PR_STAT_HAS_ONLY_ST_ATIME\n #if defined(__alpha) || defined(__ia64__)\n #define _PR_HAVE_LARGE_OFF_T\n-#elif (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || \\\n-    defined(ANDROID)\n+#elif (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) \\\n+    || defined(ANDROID)\n #define _PR_HAVE_OFF64_T\n #else\n #define _PR_NO_LARGE_FILES\n #endif\n-#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || \\\n-    defined(ANDROID)\n+#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) \\\n+    || defined(ANDROID)\n #define _PR_INET6\n #define _PR_HAVE_INET_NTOP\n #define _PR_HAVE_GETHOSTBYNAME2\n@@ -362,7 +361,7 @@ _MD_ATOMIC_SET(PRInt32* ptr, PRInt32 nv)\n extern void _MD_CleanupBeforeExit(void);\n #define _MD_CLEANUP_BEFORE_EXIT _MD_CleanupBeforeExit\n \n-#else /* ! _PR_PTHREADS */\n+#else  /* ! _PR_PTHREADS */\n \n #include <setjmp.h>\n \n@@ -384,9 +383,9 @@ extern void _MD_CleanupBeforeExit(void);\n #endif /* glibc 2.1 or later */\n #define _MD_SET_FP(_t, val)\n #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))\n-#define _MD_GET_FP_PTR(_t) ((void*)0)\n+#define _MD_GET_FP_PTR(_t) ((void *) 0)\n /* aix = 64, macos = 70 */\n-#define PR_NUM_GCREGS 64\n+#define PR_NUM_GCREGS  64\n \n #elif defined(__alpha)\n /* Alpha based Linux */\n@@ -395,13 +394,13 @@ extern void _MD_CleanupBeforeExit(void);\n #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_SP]\n #define _MD_SET_FP(_t, val)\n #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))\n-#define _MD_GET_FP_PTR(_t) ((void*)0)\n+#define _MD_GET_FP_PTR(_t) ((void *) 0)\n #define _MD_SP_TYPE long int\n #else\n #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp\n #define _MD_SET_FP(_t, val)\n #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))\n-#define _MD_GET_FP_PTR(_t) ((void*)0)\n+#define _MD_GET_FP_PTR(_t) ((void *) 0)\n #define _MD_SP_TYPE __ptr_t\n #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */\n \n@@ -410,13 +409,13 @@ extern void _MD_CleanupBeforeExit(void);\n \n #elif defined(__ia64__)\n \n-#define _MD_GET_SP(_t) ((long*)((_t)->md.context[0].__jmpbuf)[0])\n+#define _MD_GET_SP(_t)      ((long *)((_t)->md.context[0].__jmpbuf)[0])\n #define _MD_SET_FP(_t, val)\n-#define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))\n-#define _MD_GET_FP_PTR(_t) ((void*)0)\n-#define _MD_SP_TYPE long int\n+#define _MD_GET_SP_PTR(_t)  &(_MD_GET_SP(_t))\n+#define _MD_GET_FP_PTR(_t)  ((void *) 0)\n+#define _MD_SP_TYPE         long int\n \n-#define PR_NUM_GCREGS _JBLEN\n+#define PR_NUM_GCREGS       _JBLEN\n \n #elif defined(__mc68000__)\n /* m68k based Linux */\n@@ -429,13 +428,13 @@ extern void _MD_CleanupBeforeExit(void);\n #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp\n #define _MD_SET_FP(_t, val)\n #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))\n-#define _MD_GET_FP_PTR(_t) ((void*)0)\n+#define _MD_GET_FP_PTR(_t) ((void *) 0)\n #define _MD_SP_TYPE int\n #else\n #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp\n #define _MD_SET_FP(_t, val)\n #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))\n-#define _MD_GET_FP_PTR(_t) ((void*)0)\n+#define _MD_GET_FP_PTR(_t) ((void *) 0)\n #define _MD_SP_TYPE __ptr_t\n #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */\n \n@@ -458,7 +457,7 @@ extern void _MD_CleanupBeforeExit(void);\n #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__fp\n #define _MD_SET_FP(_t, val)\n #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))\n-#define _MD_GET_FP_PTR(_t) ((void*)0)\n+#define _MD_GET_FP_PTR(_t) ((void *) 0)\n #define _MD_SP_TYPE __ptr_t\n #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */\n \n@@ -477,7 +476,7 @@ extern void _MD_CleanupBeforeExit(void);\n #define _MD_GET_FP_PTR(_t) &((_t)->md.context[0].__jmpbuf[0].__bp)\n #define _MD_SP_TYPE __ptr_t\n #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */\n-#define PR_NUM_GCREGS 6\n+#define PR_NUM_GCREGS   6\n \n #elif defined(__mips__)\n /* Linux/MIPS */\n@@ -529,11 +528,9 @@ extern void _MD_CleanupBeforeExit(void);\n /* Linux/M32R */\n #if defined(__GLIBC__) && __GLIBC__ >= 2\n #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__regs[JB_SP]\n-#define _MD_SET_FP(_t, val) \\\n-    ((_t)->md.context[0].__jmpbuf[0].__regs[JB_FP] = (val))\n+#define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[0].__regs[JB_FP] = (val))\n #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))\n-#define _MD_GET_FP_PTR(_t) \\\n-    (&(_t)->md.context[0].__jmpbuf[0].__regs[JB_FP])\n+#define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[0].__regs[JB_FP])\n #define _MD_SP_TYPE __ptr_t\n #else\n #error \"Linux/M32R pre-glibc2 not supported yet\"\n@@ -550,69 +547,69 @@ extern void _MD_CleanupBeforeExit(void);\n */\n #ifdef __powerpc__\n \n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)        \\\n-    {                                                        \\\n-        *status = PR_TRUE;                                   \\\n-        if (sigsetjmp(CONTEXT(_thread), 1)) {                \\\n-            _main();                                         \\\n-        }                                                    \\\n-        _MD_GET_SP(_thread) = (unsigned char*)((_sp) - 128); \\\n-        _thread->md.sp = _MD_GET_SP_PTR(_thread);            \\\n-        _thread->md.fp = _MD_GET_FP_PTR(_thread);            \\\n-        _MD_SET_FP(_thread, 0);                              \\\n-    }\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)  \\\n+{  \\\n+    *status = PR_TRUE;  \\\n+    if (sigsetjmp(CONTEXT(_thread), 1)) {  \\\n+        _main();  \\\n+    }  \\\n+    _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 128); \\\n+    _thread->md.sp = _MD_GET_SP_PTR(_thread); \\\n+    _thread->md.fp = _MD_GET_FP_PTR(_thread); \\\n+    _MD_SET_FP(_thread, 0); \\\n+}\n \n #elif defined(__mips__)\n \n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)             \\\n-    {                                                             \\\n-        *status = PR_TRUE;                                        \\\n-        (void)sigsetjmp(CONTEXT(_thread), 1);                     \\\n-        _thread->md.context[0].__jmpbuf[0].__pc = (__ptr_t)_main; \\\n-        _MD_GET_SP(_thread) = (_MD_SP_TYPE)((_sp) - 64);          \\\n-        _thread->md.sp = _MD_GET_SP_PTR(_thread);                 \\\n-        _thread->md.fp = _MD_GET_FP_PTR(_thread);                 \\\n-        _MD_SET_FP(_thread, 0);                                   \\\n-    }\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)  \\\n+{  \\\n+    *status = PR_TRUE;  \\\n+    (void) sigsetjmp(CONTEXT(_thread), 1);  \\\n+    _thread->md.context[0].__jmpbuf[0].__pc = (__ptr_t) _main;  \\\n+    _MD_GET_SP(_thread) = (_MD_SP_TYPE) ((_sp) - 64); \\\n+    _thread->md.sp = _MD_GET_SP_PTR(_thread); \\\n+    _thread->md.fp = _MD_GET_FP_PTR(_thread); \\\n+    _MD_SET_FP(_thread, 0); \\\n+}\n \n #else\n \n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)    \\\n-    {                                                    \\\n-        *status = PR_TRUE;                               \\\n-        if (sigsetjmp(CONTEXT(_thread), 1)) {            \\\n-            _main();                                     \\\n-        }                                                \\\n-        _MD_GET_SP(_thread) = (_MD_SP_TYPE)((_sp) - 64); \\\n-        _thread->md.sp = _MD_GET_SP_PTR(_thread);        \\\n-        _thread->md.fp = _MD_GET_FP_PTR(_thread);        \\\n-        _MD_SET_FP(_thread, 0);                          \\\n-    }\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)  \\\n+{  \\\n+    *status = PR_TRUE;  \\\n+    if (sigsetjmp(CONTEXT(_thread), 1)) {  \\\n+        _main();  \\\n+    }  \\\n+    _MD_GET_SP(_thread) = (_MD_SP_TYPE) ((_sp) - 64); \\\n+    _thread->md.sp = _MD_GET_SP_PTR(_thread); \\\n+    _thread->md.fp = _MD_GET_FP_PTR(_thread); \\\n+    _MD_SET_FP(_thread, 0); \\\n+}\n \n #endif /*__powerpc__*/\n \n-#define _MD_SWITCH_CONTEXT(_thread)        \\\n-    if (!sigsetjmp(CONTEXT(_thread), 1)) { \\\n-        (_thread)->md.errcode = errno;     \\\n-        _PR_Schedule();                    \\\n+#define _MD_SWITCH_CONTEXT(_thread)  \\\n+    if (!sigsetjmp(CONTEXT(_thread), 1)) {  \\\n+    (_thread)->md.errcode = errno;  \\\n+    _PR_Schedule();  \\\n     }\n \n /*\n ** Restore a thread context, saved by _MD_SWITCH_CONTEXT\n */\n-#define _MD_RESTORE_CONTEXT(_thread)     \\\n-    {                                    \\\n-        errno = (_thread)->md.errcode;   \\\n-        _MD_SET_CURRENT_THREAD(_thread); \\\n-        siglongjmp(CONTEXT(_thread), 1); \\\n-    }\n+#define _MD_RESTORE_CONTEXT(_thread) \\\n+{   \\\n+    errno = (_thread)->md.errcode;  \\\n+    _MD_SET_CURRENT_THREAD(_thread);  \\\n+    siglongjmp(CONTEXT(_thread), 1);  \\\n+}\n \n /* Machine-dependent (MD) data structures */\n \n struct _MDThread {\n     PR_CONTEXT_TYPE context;\n-    void* sp;\n-    void* fp;\n+    void *sp;\n+    void *fp;\n     int id;\n     int errcode;\n };\n@@ -640,7 +637,7 @@ struct _MDSegment {\n /*\n  * md-specific cpu structure field\n  */\n-#include <sys/time.h> /* for FD_SETSIZE */\n+#include <sys/time.h>  /* for FD_SETSIZE */\n #define _PR_MD_MAX_OSFD FD_SETSIZE\n \n struct _MDCPU_Unix {\n@@ -650,29 +647,29 @@ struct _MDCPU_Unix {\n     PRInt32 ioq_osfd_cnt;\n #ifndef _PR_USE_POLL\n     fd_set fd_read_set, fd_write_set, fd_exception_set;\n-    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD],\n-        fd_exception_cnt[_PR_MD_MAX_OSFD];\n+    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],\n+            fd_exception_cnt[_PR_MD_MAX_OSFD];\n #else\n-    struct pollfd* ioq_pollfds;\n+    struct pollfd *ioq_pollfds;\n     int ioq_pollfds_size;\n-#endif /* _PR_USE_POLL */\n+#endif  /* _PR_USE_POLL */\n };\n \n-#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)\n+#define _PR_IOQ(_cpu)           ((_cpu)->md.md_unix.ioQ)\n #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n-#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)\n-#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)\n-#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)\n-#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)\n-#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)\n-#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)\n-#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)\n-#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)\n-#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)\n-#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)\n-#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)\n-\n-#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32\n+#define _PR_FD_READ_SET(_cpu)       ((_cpu)->md.md_unix.fd_read_set)\n+#define _PR_FD_READ_CNT(_cpu)       ((_cpu)->md.md_unix.fd_read_cnt)\n+#define _PR_FD_WRITE_SET(_cpu)      ((_cpu)->md.md_unix.fd_write_set)\n+#define _PR_FD_WRITE_CNT(_cpu)      ((_cpu)->md.md_unix.fd_write_cnt)\n+#define _PR_FD_EXCEPTION_SET(_cpu)  ((_cpu)->md.md_unix.fd_exception_set)\n+#define _PR_FD_EXCEPTION_CNT(_cpu)  ((_cpu)->md.md_unix.fd_exception_cnt)\n+#define _PR_IOQ_TIMEOUT(_cpu)       ((_cpu)->md.md_unix.ioq_timeout)\n+#define _PR_IOQ_MAX_OSFD(_cpu)      ((_cpu)->md.md_unix.ioq_max_osfd)\n+#define _PR_IOQ_OSFD_CNT(_cpu)      ((_cpu)->md.md_unix.ioq_osfd_cnt)\n+#define _PR_IOQ_POLLFDS(_cpu)       ((_cpu)->md.md_unix.ioq_pollfds)\n+#define _PR_IOQ_POLLFDS_SIZE(_cpu)  ((_cpu)->md.md_unix.ioq_pollfds_size)\n+\n+#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)  32\n \n struct _MDCPU {\n     struct _MDCPU_Unix md_unix;\n@@ -687,30 +684,33 @@ struct _MDCPU {\n #define _MD_IOQ_LOCK()\n #define _MD_IOQ_UNLOCK()\n \n-extern PRStatus _MD_InitializeThread(PRThread* thread);\n+extern PRStatus _MD_InitializeThread(PRThread *thread);\n \n-#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)\n-#define _MD_INIT_THREAD _MD_InitializeThread\n+#define _MD_INIT_RUNNING_CPU(cpu)       _MD_unix_init_running_cpu(cpu)\n+#define _MD_INIT_THREAD                 _MD_InitializeThread\n #define _MD_EXIT_THREAD(thread)\n-#define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread\n-#define _MD_RESUME_THREAD(thread) _MD_resume_thread\n+#define _MD_SUSPEND_THREAD(thread)      _MD_suspend_thread\n+#define _MD_RESUME_THREAD(thread)       _MD_resume_thread\n #define _MD_CLEAN_THREAD(_thread)\n \n-extern PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                                  PRThreadPriority priority,\n-                                  PRThreadScope scope, PRThreadState state,\n-                                  PRUint32 stackSize);\n-extern void _MD_SET_PRIORITY(struct _MDThread* thread, PRUintn newPri);\n-extern PRStatus _MD_WAIT(PRThread*, PRIntervalTime timeout);\n-extern PRStatus _MD_WAKEUP_WAITER(PRThread*);\n+extern PRStatus _MD_CREATE_THREAD(\n+    PRThread *thread,\n+    void (*start) (void *),\n+    PRThreadPriority priority,\n+    PRThreadScope scope,\n+    PRThreadState state,\n+    PRUint32 stackSize);\n+extern void _MD_SET_PRIORITY(struct _MDThread *thread, PRUintn newPri);\n+extern PRStatus _MD_WAIT(PRThread *, PRIntervalTime timeout);\n+extern PRStatus _MD_WAKEUP_WAITER(PRThread *);\n extern void _MD_YIELD(void);\n \n #endif /* ! _PR_PTHREADS */\n \n extern void _MD_EarlyInit(void);\n \n-#define _MD_EARLY_INIT _MD_EarlyInit\n-#define _MD_FINAL_INIT _PR_UnixInit\n+#define _MD_EARLY_INIT                  _MD_EarlyInit\n+#define _MD_FINAL_INIT                  _PR_UnixInit\n #define _PR_HAVE_CLOCK_MONOTONIC\n \n /*\n@@ -721,7 +721,7 @@ extern void _MD_EarlyInit(void);\n \n #ifdef _PR_POLL_AVAILABLE\n #include <sys/poll.h>\n-extern int __syscall_poll(struct pollfd* ufds, unsigned long int nfds,\n+extern int __syscall_poll(struct pollfd *ufds, unsigned long int nfds,\n                           int timeout);\n #define _MD_POLL __syscall_poll\n #endif\ndiff --git a/nspr/pr/include/md/_netbsd.cfg b/nspr/pr/include/md/_netbsd.cfg\nindex bcf280c..1326556 100644\n--- a/nspr/pr/include/md/_netbsd.cfg\n+++ b/nspr/pr/include/md/_netbsd.cfg\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/md/_netbsd.h b/nspr/pr/include/md/_netbsd.h\nindex b1ed0c3..1ec0fe6 100644\n--- a/nspr/pr/include/md/_netbsd.h\n+++ b/nspr/pr/include/md/_netbsd.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,10 +7,10 @@\n #define nspr_netbsd_defs_h___\n \n #include <sys/syscall.h>\n-#include <sys/param.h> /* for __NetBSD_Version__ */\n+#include <sys/param.h>  /* for __NetBSD_Version__ */\n \n-#define PR_LINKER_ARCH \"netbsd\"\n-#define _PR_SI_SYSNAME \"NetBSD\"\n+#define PR_LINKER_ARCH  \"netbsd\"\n+#define _PR_SI_SYSNAME  \"NetBSD\"\n #if defined(__i386__)\n #define _PR_SI_ARCHITECTURE \"x86\"\n #elif defined(__alpha__)\n@@ -26,23 +27,23 @@\n #define _PR_SI_ARCHITECTURE \"sparc\"\n #elif defined(__mips__)\n #define _PR_SI_ARCHITECTURE \"mips\"\n-#elif defined(__arm32__) || defined(__arm__) || defined(__armel__) || \\\n-    defined(__armeb__)\n+#elif defined(__arm32__) || defined(__arm__) || defined(__armel__) \\\n+    || defined(__armeb__)\n #define _PR_SI_ARCHITECTURE \"arm\"\n #endif\n \n #if defined(__ELF__)\n-#define PR_DLL_SUFFIX \".so\"\n+#define PR_DLL_SUFFIX       \".so\"\n #else\n-#define PR_DLL_SUFFIX \".so.1.0\"\n+#define PR_DLL_SUFFIX       \".so.1.0\"\n #endif\n \n-#define _PR_VMBASE 0x30000000\n-#define _PR_STACK_VMBASE 0x50000000\n-#define _MD_DEFAULT_STACK_SIZE 65536L\n-#define _MD_MMAP_FLAGS MAP_PRIVATE\n+#define _PR_VMBASE              0x30000000\n+#define _PR_STACK_VMBASE    0x50000000\n+#define _MD_DEFAULT_STACK_SIZE  65536L\n+#define _MD_MMAP_FLAGS          MAP_PRIVATE\n \n-#undef HAVE_STACK_GROWING_UP\n+#undef  HAVE_STACK_GROWING_UP\n #define HAVE_DLL\n #define USE_DLFCN\n #define _PR_HAVE_SOCKADDR_LEN\n@@ -70,8 +71,7 @@\n \n #define CONTEXT(_th) ((_th)->md.context)\n \n-#if defined(__i386__) || defined(__sparc__) || defined(__m68k__) || \\\n-    defined(__powerpc__)\n+#if defined(__i386__) || defined(__sparc__) || defined(__m68k__) || defined(__powerpc__)\n #define JB_SP_INDEX 2\n #elif defined(__mips__)\n #define JB_SP_INDEX 4\n@@ -89,37 +89,37 @@\n #else\n #error \"Need to define SP index in jmp_buf here\"\n #endif\n-#define _MD_GET_SP(_th) (_th)->md.context[JB_SP_INDEX]\n+#define _MD_GET_SP(_th)    (_th)->md.context[JB_SP_INDEX]\n \n-#define PR_NUM_GCREGS _JBLEN\n+#define PR_NUM_GCREGS   _JBLEN\n \n /*\n ** Initialize a thread context to run \"_main()\" when started\n */\n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)        \\\n-    {                                                        \\\n-        *status = PR_TRUE;                                   \\\n-        if (sigsetjmp(CONTEXT(_thread), 1)) {                \\\n-            _main();                                         \\\n-        }                                                    \\\n-        _MD_GET_SP(_thread) = (unsigned char *)((_sp) - 64); \\\n-    }\n-\n-#define _MD_SWITCH_CONTEXT(_thread)        \\\n-    if (!sigsetjmp(CONTEXT(_thread), 1)) { \\\n-        (_thread)->md.errcode = errno;     \\\n-        _PR_Schedule();                    \\\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)  \\\n+{  \\\n+    *status = PR_TRUE;  \\\n+    if (sigsetjmp(CONTEXT(_thread), 1)) {  \\\n+        _main();  \\\n+    }  \\\n+    _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 64); \\\n+}\n+\n+#define _MD_SWITCH_CONTEXT(_thread)  \\\n+    if (!sigsetjmp(CONTEXT(_thread), 1)) {  \\\n+        (_thread)->md.errcode = errno;  \\\n+        _PR_Schedule();  \\\n     }\n \n /*\n ** Restore a thread context, saved by _MD_SWITCH_CONTEXT\n */\n-#define _MD_RESTORE_CONTEXT(_thread)     \\\n-    {                                    \\\n-        errno = (_thread)->md.errcode;   \\\n-        _MD_SET_CURRENT_THREAD(_thread); \\\n-        siglongjmp(CONTEXT(_thread), 1); \\\n-    }\n+#define _MD_RESTORE_CONTEXT(_thread) \\\n+{   \\\n+    errno = (_thread)->md.errcode;  \\\n+    _MD_SET_CURRENT_THREAD(_thread);  \\\n+    siglongjmp(CONTEXT(_thread), 1);  \\\n+}\n \n /* Machine-dependent (MD) data structures */\n \n@@ -161,29 +161,29 @@ struct _MDCPU_Unix {\n     PRInt32 ioq_osfd_cnt;\n #ifndef _PR_USE_POLL\n     fd_set fd_read_set, fd_write_set, fd_exception_set;\n-    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD],\n-        fd_exception_cnt[_PR_MD_MAX_OSFD];\n+    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],\n+            fd_exception_cnt[_PR_MD_MAX_OSFD];\n #else\n-    struct pollfd* ioq_pollfds;\n+    struct pollfd *ioq_pollfds;\n     int ioq_pollfds_size;\n-#endif /* _PR_USE_POLL */\n+#endif  /* _PR_USE_POLL */\n };\n \n-#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)\n+#define _PR_IOQ(_cpu)           ((_cpu)->md.md_unix.ioQ)\n #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n-#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)\n-#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)\n-#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)\n-#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)\n-#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)\n-#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)\n-#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)\n-#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)\n-#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)\n-#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)\n-#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)\n-\n-#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32\n+#define _PR_FD_READ_SET(_cpu)       ((_cpu)->md.md_unix.fd_read_set)\n+#define _PR_FD_READ_CNT(_cpu)       ((_cpu)->md.md_unix.fd_read_cnt)\n+#define _PR_FD_WRITE_SET(_cpu)      ((_cpu)->md.md_unix.fd_write_set)\n+#define _PR_FD_WRITE_CNT(_cpu)      ((_cpu)->md.md_unix.fd_write_cnt)\n+#define _PR_FD_EXCEPTION_SET(_cpu)  ((_cpu)->md.md_unix.fd_exception_set)\n+#define _PR_FD_EXCEPTION_CNT(_cpu)  ((_cpu)->md.md_unix.fd_exception_cnt)\n+#define _PR_IOQ_TIMEOUT(_cpu)       ((_cpu)->md.md_unix.ioq_timeout)\n+#define _PR_IOQ_MAX_OSFD(_cpu)      ((_cpu)->md.md_unix.ioq_max_osfd)\n+#define _PR_IOQ_OSFD_CNT(_cpu)      ((_cpu)->md.md_unix.ioq_osfd_cnt)\n+#define _PR_IOQ_POLLFDS(_cpu)       ((_cpu)->md.md_unix.ioq_pollfds)\n+#define _PR_IOQ_POLLFDS_SIZE(_cpu)  ((_cpu)->md.md_unix.ioq_pollfds_size)\n+\n+#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)  32\n \n struct _MDCPU {\n     struct _MDCPU_Unix md_unix;\n@@ -198,29 +198,29 @@ struct _MDCPU {\n #define _MD_IOQ_LOCK()\n #define _MD_IOQ_UNLOCK()\n \n-#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)\n-#define _MD_INIT_THREAD _MD_InitializeThread\n+#define _MD_INIT_RUNNING_CPU(cpu)       _MD_unix_init_running_cpu(cpu)\n+#define _MD_INIT_THREAD                 _MD_InitializeThread\n #define _MD_EXIT_THREAD(thread)\n-#define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread\n-#define _MD_RESUME_THREAD(thread) _MD_resume_thread\n+#define _MD_SUSPEND_THREAD(thread)      _MD_suspend_thread\n+#define _MD_RESUME_THREAD(thread)       _MD_resume_thread\n #define _MD_CLEAN_THREAD(_thread)\n \n #endif /* ! _PR_PTHREADS */\n \n extern void _MD_EarlyInit(void);\n \n-#define _MD_EARLY_INIT _MD_EarlyInit\n-#define _MD_FINAL_INIT _PR_UnixInit\n+#define _MD_EARLY_INIT                  _MD_EarlyInit\n+#define _MD_FINAL_INIT          _PR_UnixInit\n #define _PR_HAVE_CLOCK_MONOTONIC\n \n /*\n  * We wrapped the select() call.  _MD_SELECT refers to the built-in,\n  * unwrapped version.\n  */\n-#define _MD_SELECT(nfds, r, w, e, tv) syscall(SYS_select, nfds, r, w, e, tv)\n+#define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)\n #if defined(_PR_POLL_AVAILABLE)\n #include <poll.h>\n-#define _MD_POLL(fds, nfds, timeout) syscall(SYS_poll, fds, nfds, timeout)\n+#define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)\n #endif\n \n #if NetBSD1_3 == 1L\ndiff --git a/nspr/pr/include/md/_nspr_pthread.h b/nspr/pr/include/md/_nspr_pthread.h\nindex c8f4492..01796e7 100644\n--- a/nspr/pr/include/md/_nspr_pthread.h\n+++ b/nspr/pr/include/md/_nspr_pthread.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -17,71 +18,72 @@ extern pthread_key_t current_cpu_key;\n extern pthread_key_t last_thread_key;\n extern pthread_key_t intsoff_key;\n \n-#define _MD_CURRENT_THREAD() \\\n-    ((struct PRThread*)pthread_getspecific(current_thread_key))\n-#define _MD_CURRENT_CPU() \\\n-    ((struct _PRCPU*)pthread_getspecific(current_cpu_key))\n-#define _MD_LAST_THREAD() \\\n-    ((struct PRThread*)pthread_getspecific(last_thread_key))\n+#define _MD_CURRENT_THREAD()            \\\n+            ((struct PRThread *) pthread_getspecific(current_thread_key))\n+#define _MD_CURRENT_CPU()               \\\n+            ((struct _PRCPU *) pthread_getspecific(current_cpu_key))\n+#define _MD_LAST_THREAD()               \\\n+            ((struct PRThread *) pthread_getspecific(last_thread_key))\n \n-#define _MD_SET_CURRENT_THREAD(newval) \\\n-    pthread_setspecific(current_thread_key, (void*)newval)\n+#define _MD_SET_CURRENT_THREAD(newval)          \\\n+    pthread_setspecific(current_thread_key, (void *)newval)\n \n-#define _MD_SET_CURRENT_CPU(newval) \\\n-    pthread_setspecific(current_cpu_key, (void*)newval)\n+#define _MD_SET_CURRENT_CPU(newval)             \\\n+    pthread_setspecific(current_cpu_key, (void *)newval)\n \n-#define _MD_SET_LAST_THREAD(newval) \\\n-    pthread_setspecific(last_thread_key, (void*)newval)\n+#define _MD_SET_LAST_THREAD(newval)             \\\n+    pthread_setspecific(last_thread_key, (void *)newval)\n \n #define _MD_SET_INTSOFF(_val)\n-#define _MD_GET_INTSOFF() 1\n+#define _MD_GET_INTSOFF()   1\n \n /*\n ** Initialize the thread context preparing it to execute _main.\n */\n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \\\n-    PR_BEGIN_MACRO                                    \\\n-    *status = PR_TRUE;                                \\\n-    if (SAVE_CONTEXT(_thread)) {                      \\\n-        (*_main)();                                   \\\n-    }                                                 \\\n-    _MD_SET_THR_SP(_thread, _sp);                     \\\n-    _thread->no_sched = 0;                            \\\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)           \\\n+    PR_BEGIN_MACRO                                              \\\n+        *status = PR_TRUE;                                      \\\n+        if (SAVE_CONTEXT(_thread)) {                            \\\n+            (*_main)();                                         \\\n+        }                                                       \\\n+        _MD_SET_THR_SP(_thread, _sp);                           \\\n+        _thread->no_sched = 0;                                  \\\n     PR_END_MACRO\n \n-#define _MD_SWITCH_CONTEXT(_thread)        \\\n-    PR_BEGIN_MACRO                         \\\n-    PR_ASSERT(_thread->no_sched);          \\\n-    if (!SAVE_CONTEXT(_thread)) {          \\\n-        (_thread)->md.errcode = errno;     \\\n-        _MD_SET_LAST_THREAD(_thread);      \\\n-        _PR_Schedule();                    \\\n-    } else {                               \\\n-        (_MD_LAST_THREAD())->no_sched = 0; \\\n-    }                                      \\\n+#define _MD_SWITCH_CONTEXT(_thread)                                 \\\n+    PR_BEGIN_MACRO                                                  \\\n+    PR_ASSERT(_thread->no_sched);                                   \\\n+    if (!SAVE_CONTEXT(_thread)) {                                   \\\n+        (_thread)->md.errcode = errno;                              \\\n+        _MD_SET_LAST_THREAD(_thread);                               \\\n+        _PR_Schedule();                                             \\\n+    } else {                                                        \\\n+         (_MD_LAST_THREAD())->no_sched = 0;                         \\\n+    }                                                               \\\n     PR_END_MACRO\n \n /*\n ** Restore a thread context, saved by _MD_SWITCH_CONTEXT\n */\n-#define _MD_RESTORE_CONTEXT(_thread) \\\n-    PR_BEGIN_MACRO                   \\\n-    errno = (_thread)->md.errcode;   \\\n-    _MD_SET_CURRENT_THREAD(_thread); \\\n-    _thread->no_sched = 1;           \\\n-    GOTO_CONTEXT(_thread);           \\\n+#define _MD_RESTORE_CONTEXT(_thread)                                \\\n+    PR_BEGIN_MACRO                                                  \\\n+    errno = (_thread)->md.errcode;                                  \\\n+    _MD_SET_CURRENT_THREAD(_thread);                                \\\n+    _thread->no_sched = 1;                                          \\\n+    GOTO_CONTEXT(_thread);                                          \\\n     PR_END_MACRO\n \n+\n /* Machine-dependent (MD) data structures */\n \n struct _MDThread {\n-    jmp_buf jb;\n-    int id;\n-    int errcode;\n-    pthread_t pthread;\n+    jmp_buf         jb;\n+    int             id;\n+    int             errcode;\n+    pthread_t       pthread;\n     pthread_mutex_t pthread_mutex;\n-    pthread_cond_t pthread_cond;\n-    int wait;\n+    pthread_cond_t  pthread_cond;\n+    int             wait;\n };\n \n struct _MDThreadStack {\n@@ -116,34 +118,34 @@ struct _MDCPU_Unix {\n     PRInt32 ioq_osfd_cnt;\n #ifndef _PR_USE_POLL\n     fd_set fd_read_set, fd_write_set, fd_exception_set;\n-    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD],\n-        fd_exception_cnt[_PR_MD_MAX_OSFD];\n+    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],\n+            fd_exception_cnt[_PR_MD_MAX_OSFD];\n #else\n-    struct pollfd* ioq_pollfds;\n+    struct pollfd *ioq_pollfds;\n     int ioq_pollfds_size;\n-#endif /* _PR_USE_POLL */\n+#endif  /* _PR_USE_POLL */\n };\n \n-#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)\n+#define _PR_IOQ(_cpu)           ((_cpu)->md.md_unix.ioQ)\n #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n-#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)\n-#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)\n-#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)\n-#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)\n-#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)\n-#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)\n-#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)\n-#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)\n-#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)\n-#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)\n-#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)\n-\n-#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32\n+#define _PR_FD_READ_SET(_cpu)       ((_cpu)->md.md_unix.fd_read_set)\n+#define _PR_FD_READ_CNT(_cpu)       ((_cpu)->md.md_unix.fd_read_cnt)\n+#define _PR_FD_WRITE_SET(_cpu)      ((_cpu)->md.md_unix.fd_write_set)\n+#define _PR_FD_WRITE_CNT(_cpu)      ((_cpu)->md.md_unix.fd_write_cnt)\n+#define _PR_FD_EXCEPTION_SET(_cpu)  ((_cpu)->md.md_unix.fd_exception_set)\n+#define _PR_FD_EXCEPTION_CNT(_cpu)  ((_cpu)->md.md_unix.fd_exception_cnt)\n+#define _PR_IOQ_TIMEOUT(_cpu)       ((_cpu)->md.md_unix.ioq_timeout)\n+#define _PR_IOQ_MAX_OSFD(_cpu)      ((_cpu)->md.md_unix.ioq_max_osfd)\n+#define _PR_IOQ_OSFD_CNT(_cpu)      ((_cpu)->md.md_unix.ioq_osfd_cnt)\n+#define _PR_IOQ_POLLFDS(_cpu)       ((_cpu)->md.md_unix.ioq_pollfds)\n+#define _PR_IOQ_POLLFDS_SIZE(_cpu)  ((_cpu)->md.md_unix.ioq_pollfds_size)\n+\n+#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)  32\n \n struct _MDCPU {\n-    jmp_buf jb;\n-    pthread_t pthread;\n-    struct _MDCPU_Unix md_unix;\n+    jmp_buf             jb;\n+    pthread_t           pthread;\n+    struct _MDCPU_Unix  md_unix;\n };\n \n /*\n@@ -159,22 +161,19 @@ extern pthread_mutex_t _pr_heapLock;\n \n #define _PR_UNLOCK(lock) pthread_mutex_unlock(lock)\n \n-#define _PR_LOCK_HEAP()             \\\n-    {                               \\\n-        if (_pr_primordialCPU) {    \\\n-            _PR_LOCK(_pr_heapLock); \\\n-        }\n \n-#define _PR_UNLOCK_HEAP()         \\\n-    if (_pr_primordialCPU) {      \\\n-        _PR_UNLOCK(_pr_heapLock); \\\n-    }                             \\\n-    }\n+#define _PR_LOCK_HEAP() {                                   \\\n+                if (_pr_primordialCPU) {                    \\\n+                    _PR_LOCK(_pr_heapLock);                 \\\n+                }\n+\n+#define _PR_UNLOCK_HEAP()   if (_pr_primordialCPU)  {       \\\n+                    _PR_UNLOCK(_pr_heapLock);               \\\n+                }                                           \\\n+              }\n \n-NSPR_API(PRStatus)\n-_MD_NEW_LOCK(struct _MDLock* md);\n-NSPR_API(void)\n-_MD_FREE_LOCK(struct _MDLock* lockp);\n+NSPR_API(PRStatus) _MD_NEW_LOCK(struct _MDLock *md);\n+NSPR_API(void) _MD_FREE_LOCK(struct _MDLock *lockp);\n \n #define _MD_LOCK(_lockp) _PR_LOCK(&(_lockp)->mutex)\n #define _MD_UNLOCK(_lockp) _PR_UNLOCK(&(_lockp)->mutex)\n@@ -184,29 +183,23 @@ _MD_FREE_LOCK(struct _MDLock* lockp);\n #define _MD_IOQ_UNLOCK()\n #define _MD_CHECK_FOR_EXIT()\n \n-NSPR_API(PRStatus)\n-_MD_InitThread(struct PRThread* thread);\n+NSPR_API(PRStatus) _MD_InitThread(struct PRThread *thread);\n #define _MD_INIT_THREAD _MD_InitThread\n #define _MD_INIT_ATTACHED_THREAD _MD_InitThread\n \n-NSPR_API(void)\n-_MD_ExitThread(struct PRThread* thread);\n+NSPR_API(void) _MD_ExitThread(struct PRThread *thread);\n #define _MD_EXIT_THREAD _MD_ExitThread\n \n-NSPR_API(void)\n-_MD_SuspendThread(struct PRThread* thread);\n+NSPR_API(void) _MD_SuspendThread(struct PRThread *thread);\n #define _MD_SUSPEND_THREAD _MD_SuspendThread\n \n-NSPR_API(void)\n-_MD_ResumeThread(struct PRThread* thread);\n+NSPR_API(void) _MD_ResumeThread(struct PRThread *thread);\n #define _MD_RESUME_THREAD _MD_ResumeThread\n \n-NSPR_API(void)\n-_MD_SuspendCPU(struct _PRCPU* thread);\n+NSPR_API(void) _MD_SuspendCPU(struct _PRCPU *thread);\n #define _MD_SUSPEND_CPU _MD_SuspendCPU\n \n-NSPR_API(void)\n-_MD_ResumeCPU(struct _PRCPU* thread);\n+NSPR_API(void) _MD_ResumeCPU(struct _PRCPU *thread);\n #define _MD_RESUME_CPU _MD_ResumeCPU\n \n #define _MD_BEGIN_SUSPEND_ALL()\n@@ -214,46 +207,43 @@ _MD_ResumeCPU(struct _PRCPU* thread);\n #define _MD_BEGIN_RESUME_ALL()\n #define _MD_END_RESUME_ALL()\n \n-NSPR_API(void)\n-_MD_EarlyInit(void);\n+NSPR_API(void) _MD_EarlyInit(void);\n #define _MD_EARLY_INIT _MD_EarlyInit\n \n #define _MD_FINAL_INIT _PR_UnixInit\n \n-NSPR_API(void)\n-_MD_InitLocks(void);\n+NSPR_API(void) _MD_InitLocks(void);\n #define _MD_INIT_LOCKS _MD_InitLocks\n \n-NSPR_API(void)\n-_MD_CleanThread(struct PRThread* thread);\n+NSPR_API(void) _MD_CleanThread(struct PRThread *thread);\n #define _MD_CLEAN_THREAD _MD_CleanThread\n \n-NSPR_API(PRStatus)\n-_MD_CreateThread(struct PRThread* thread, void (*start)(void*),\n-                 PRThreadPriority priority, PRThreadScope scope,\n-                 PRThreadState state, PRUint32 stackSize);\n+NSPR_API(PRStatus) _MD_CreateThread(\n+    struct PRThread *thread,\n+    void (*start) (void *),\n+    PRThreadPriority priority,\n+    PRThreadScope scope,\n+    PRThreadState state,\n+    PRUint32 stackSize);\n #define _MD_CREATE_THREAD _MD_CreateThread\n \n extern void _MD_CleanupBeforeExit(void);\n #define _MD_CLEANUP_BEFORE_EXIT _MD_CleanupBeforeExit\n \n-NSPR_API(void)\n-_MD_InitRunningCPU(struct _PRCPU* cpu);\n-#define _MD_INIT_RUNNING_CPU _MD_InitRunningCPU\n+NSPR_API(void) _MD_InitRunningCPU(struct _PRCPU *cpu);\n+#define    _MD_INIT_RUNNING_CPU _MD_InitRunningCPU\n \n /* The _PR_MD_WAIT_LOCK and _PR_MD_WAKEUP_WAITER functions put to sleep and\n  * awaken a thread which is waiting on a lock or cvar.\n  */\n-NSPR_API(PRStatus)\n-_MD_wait(struct PRThread*, PRIntervalTime timeout);\n+NSPR_API(PRStatus) _MD_wait(struct PRThread *, PRIntervalTime timeout);\n #define _MD_WAIT _MD_wait\n \n-NSPR_API(PRStatus)\n-_MD_WakeupWaiter(struct PRThread*);\n+NSPR_API(PRStatus) _MD_WakeupWaiter(struct PRThread *);\n #define _MD_WAKEUP_WAITER _MD_WakeupWaiter\n \n-NSPR_API(void)\n-_MD_SetPriority(struct _MDThread* thread, PRThreadPriority newPri);\n+NSPR_API(void) _MD_SetPriority(struct _MDThread *thread,\n+                               PRThreadPriority newPri);\n #define _MD_SET_PRIORITY _MD_SetPriority\n \n #endif /* PTHREADS_USER */\ndiff --git a/nspr/pr/include/md/_nto.cfg b/nspr/pr/include/md/_nto.cfg\nindex 47bee72..b76a560 100644\n--- a/nspr/pr/include/md/_nto.cfg\n+++ b/nspr/pr/include/md/_nto.cfg\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/md/_nto.h b/nspr/pr/include/md/_nto.h\nindex 42a14ef..1094dd1 100644\n--- a/nspr/pr/include/md/_nto.h\n+++ b/nspr/pr/include/md/_nto.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,25 +9,25 @@\n /*\n ** Internal configuration macros\n */\n-#define PR_LINKER_ARCH \"nto\"\n-#define _PR_SI_SYSNAME \"NTO\"\n+#define PR_LINKER_ARCH      \"nto\"\n+#define _PR_SI_SYSNAME      \"NTO\"\n #define _PR_SI_ARCHITECTURE \"x86\"\n-#define PR_DLL_SUFFIX \".so\"\n+#define PR_DLL_SUFFIX       \".so\"\n \n-#define _PR_VMBASE 0x30000000\n-#define _PR_STACK_VMBASE 0x50000000\n-#define _MD_DEFAULT_STACK_SIZE 65536L\n-#define _MD_MINIMUM_STACK_SIZE 131072L\n-#define _MD_MMAP_FLAGS MAP_PRIVATE\n+#define _PR_VMBASE      0x30000000\n+#define _PR_STACK_VMBASE    0x50000000\n+#define _MD_DEFAULT_STACK_SIZE  65536L\n+#define _MD_MINIMUM_STACK_SIZE  131072L\n+#define _MD_MMAP_FLAGS      MAP_PRIVATE\n \n #ifndef HAVE_WEAK_IO_SYMBOLS\n #define HAVE_WEAK_IO_SYMBOLS\n #endif\n \n-#undef _PR_POLL_AVAILABLE\n-#undef _PR_USE_POLL\n+#undef  _PR_POLL_AVAILABLE\n+#undef  _PR_USE_POLL\n #define _PR_HAVE_SOCKADDR_LEN\n-#undef HAVE_BSD_FLOCK\n+#undef  HAVE_BSD_FLOCK\n #define HAVE_FCNTL_FILE_LOCKING\n #define _PR_NO_LARGE_FILES\n #define _PR_STAT_HAS_ONLY_ST_ATIME\n@@ -34,12 +35,12 @@\n #define _PR_HAVE_POSIX_SEMAPHORES\n \n #undef FD_SETSIZE\n-#define FD_SETSIZE 4096\n+#define FD_SETSIZE  4096\n #include <sys/time.h>\n #include <sys/types.h>\n #include <sys/select.h>\n \n-#undef HAVE_STACK_GROWING_UP\n+#undef  HAVE_STACK_GROWING_UP\n #define HAVE_DLL\n #define USE_DLFCN\n #define NEED_STRFTIME_LOCK\n@@ -54,40 +55,40 @@\n \n #include <setjmp.h>\n \n-#define _SETJMP setjmp\n-#define _LONGJMP longjmp\n-#define _PR_CONTEXT_TYPE jmp_buf\n-#define _PR_NUM_GCREGS _JBLEN\n-#define _MD_GET_SP(_t) (_t)->md.context[7]\n+#define _SETJMP         setjmp\n+#define _LONGJMP        longjmp\n+#define _PR_CONTEXT_TYPE    jmp_buf\n+#define _PR_NUM_GCREGS      _JBLEN\n+#define _MD_GET_SP(_t)      (_t)->md.context[7]\n+\n+#define CONTEXT(_th)        ((_th)->md.context)\n \n-#define CONTEXT(_th) ((_th)->md.context)\n \n /*\n ** Initialize the thread context preparing it to execute _main.\n */\n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \\\n-    {                                                 \\\n-        *status = PR_TRUE;                            \\\n-        if (_SETJMP(CONTEXT(_thread)))                \\\n-            (*_main)();                               \\\n-        _MD_GET_SP(_thread) = (int)((_sp) - 128);     \\\n-    }\n-\n-#define _MD_SWITCH_CONTEXT(_thread)    \\\n-    if (!_SETJMP(CONTEXT(_thread))) {  \\\n-        (_thread)->md.errcode = errno; \\\n-        _PR_Schedule();                \\\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)   \\\n+{                           \\\n+    *status = PR_TRUE;                  \\\n+    if(_SETJMP(CONTEXT(_thread))) (*_main)();       \\\n+    _MD_GET_SP(_thread) = (int) ((_sp) - 128);      \\\n+}\n+\n+#define _MD_SWITCH_CONTEXT(_thread) \\\n+    if (!_SETJMP(CONTEXT(_thread))) {   \\\n+    (_thread)->md.errcode = errno;  \\\n+    _PR_Schedule();         \\\n     }\n \n /*\n ** Restore a thread context, saved by _MD_SWITCH_CONTEXT\n */\n-#define _MD_RESTORE_CONTEXT(_thread)     \\\n-    {                                    \\\n-        errno = (_thread)->md.errcode;   \\\n-        _MD_SET_CURRENT_THREAD(_thread); \\\n-        _LONGJMP(CONTEXT(_thread), 1);   \\\n-    }\n+#define _MD_RESTORE_CONTEXT(_thread)    \\\n+{                   \\\n+    errno = (_thread)->md.errcode;  \\\n+    _MD_SET_CURRENT_THREAD(_thread);    \\\n+    _LONGJMP(CONTEXT(_thread), 1);  \\\n+}\n \n /*\n ** Machine-dependent (MD) data structures.\n@@ -121,7 +122,7 @@ struct _MDSegment {\n /*\n ** md-specific cpu structure field\n */\n-#define _PR_MD_MAX_OSFD FD_SETSIZE\n+#define _PR_MD_MAX_OSFD     FD_SETSIZE\n \n struct _MDCPU_Unix {\n     PRCList ioQ;\n@@ -130,36 +131,35 @@ struct _MDCPU_Unix {\n     PRInt32 ioq_osfd_cnt;\n #ifndef _PR_USE_POLL\n     fd_set fd_read_set, fd_write_set, fd_exception_set;\n-    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD],\n-        fd_exception_cnt[_PR_MD_MAX_OSFD];\n+    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD], fd_exception_cnt[_PR_MD_MAX_OSFD];\n #else\n-    struct pollfd* ioq_pollfds;\n+    struct pollfd *ioq_pollfds;\n     int ioq_pollfds_size;\n #endif\n };\n \n-#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)\n-#define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n-#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)\n-#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)\n-#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)\n-#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)\n-#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)\n-#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)\n-#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)\n-#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)\n-#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)\n-#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)\n-#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)\n-\n-#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32\n+#define _PR_IOQ(_cpu)           ((_cpu)->md.md_unix.ioQ)\n+#define _PR_ADD_TO_IOQ(_pq, _cpu)   PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n+#define _PR_FD_READ_SET(_cpu)       ((_cpu)->md.md_unix.fd_read_set)\n+#define _PR_FD_READ_CNT(_cpu)       ((_cpu)->md.md_unix.fd_read_cnt)\n+#define _PR_FD_WRITE_SET(_cpu)      ((_cpu)->md.md_unix.fd_write_set)\n+#define _PR_FD_WRITE_CNT(_cpu)      ((_cpu)->md.md_unix.fd_write_cnt)\n+#define _PR_FD_EXCEPTION_SET(_cpu)  ((_cpu)->md.md_unix.fd_exception_set)\n+#define _PR_FD_EXCEPTION_CNT(_cpu)  ((_cpu)->md.md_unix.fd_exception_cnt)\n+#define _PR_IOQ_TIMEOUT(_cpu)       ((_cpu)->md.md_unix.ioq_timeout)\n+#define _PR_IOQ_MAX_OSFD(_cpu)      ((_cpu)->md.md_unix.ioq_max_osfd)\n+#define _PR_IOQ_OSFD_CNT(_cpu)      ((_cpu)->md.md_unix.ioq_osfd_cnt)\n+#define _PR_IOQ_POLLFDS(_cpu)       ((_cpu)->md.md_unix.ioq_pollfds)\n+#define _PR_IOQ_POLLFDS_SIZE(_cpu)  ((_cpu)->md.md_unix.ioq_pollfds_size)\n+\n+#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)  32\n \n struct _MDCPU {\n     struct _MDCPU_Unix md_unix;\n };\n \n #define _MD_INIT_LOCKS()\n-#define _MD_NEW_LOCK(lock) PR_SUCCESS\n+#define _MD_NEW_LOCK(lock)      PR_SUCCESS\n #define _MD_FREE_LOCK(lock)\n #define _MD_LOCK(lock)\n #define _MD_UNLOCK(lock)\n@@ -168,10 +168,10 @@ struct _MDCPU {\n #define _MD_IOQ_UNLOCK()\n \n #define _MD_INTERVAL_USE_GTOD\n-#define _MD_EARLY_INIT _MD_EarlyInit\n-#define _MD_FINAL_INIT _PR_UnixInit\n-#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)\n-#define _MD_INIT_THREAD _MD_InitializeThread\n+#define _MD_EARLY_INIT          _MD_EarlyInit\n+#define _MD_FINAL_INIT          _PR_UnixInit\n+#define _MD_INIT_RUNNING_CPU(cpu)   _MD_unix_init_running_cpu(cpu)\n+#define _MD_INIT_THREAD         _MD_InitializeThread\n #define _MD_EXIT_THREAD(thread)\n #define _MD_SUSPEND_THREAD(thread)\n #define _MD_RESUME_THREAD(thread)\n@@ -181,7 +181,7 @@ struct _MDCPU {\n ** We wrapped the select() call.  _MD_SELECT refers to the built-in,\n ** unwrapped version.\n */\n-#define _MD_SELECT select\n+#define _MD_SELECT      select\n \n #define SA_RESTART 0\n \ndiff --git a/nspr/pr/include/md/_openbsd.cfg b/nspr/pr/include/md/_openbsd.cfg\nindex ee9c95f..b68d6e9 100644\n--- a/nspr/pr/include/md/_openbsd.cfg\n+++ b/nspr/pr/include/md/_openbsd.cfg\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/md/_openbsd.h b/nspr/pr/include/md/_openbsd.h\nindex 7188dfa..1949631 100644\n--- a/nspr/pr/include/md/_openbsd.h\n+++ b/nspr/pr/include/md/_openbsd.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,8 +8,8 @@\n \n #include <sys/syscall.h>\n \n-#define PR_LINKER_ARCH \"openbsd\"\n-#define _PR_SI_SYSNAME \"OPENBSD\"\n+#define PR_LINKER_ARCH  \"openbsd\"\n+#define _PR_SI_SYSNAME  \"OPENBSD\"\n #if defined(__i386__)\n #define _PR_SI_ARCHITECTURE \"x86\"\n #elif defined(__alpha__)\n@@ -27,14 +28,14 @@\n #define _PR_SI_ARCHITECTURE \"arm\"\n #endif\n \n-#define PR_DLL_SUFFIX \".so\"\n+#define PR_DLL_SUFFIX       \".so\"\n \n-#define _PR_VMBASE 0x30000000\n-#define _PR_STACK_VMBASE 0x50000000\n-#define _MD_DEFAULT_STACK_SIZE 65536L\n-#define _MD_MMAP_FLAGS MAP_PRIVATE\n+#define _PR_VMBASE              0x30000000\n+#define _PR_STACK_VMBASE    0x50000000\n+#define _MD_DEFAULT_STACK_SIZE  65536L\n+#define _MD_MMAP_FLAGS          MAP_PRIVATE\n \n-#undef HAVE_STACK_GROWING_UP\n+#undef  HAVE_STACK_GROWING_UP\n #define HAVE_DLL\n #define USE_DLFCN\n #define _PR_HAVE_SOCKADDR_LEN\n@@ -73,37 +74,37 @@\n #else\n #error \"Need to define SP index in jmp_buf here\"\n #endif\n-#define _MD_GET_SP(_th) (_th)->md.context[JB_SP_INDEX]\n+#define _MD_GET_SP(_th)    (_th)->md.context[JB_SP_INDEX]\n \n-#define PR_NUM_GCREGS _JBLEN\n+#define PR_NUM_GCREGS   _JBLEN\n \n /*\n ** Initialize a thread context to run \"_main()\" when started\n */\n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)        \\\n-    {                                                        \\\n-        *status = PR_TRUE;                                   \\\n-        if (sigsetjmp(CONTEXT(_thread), 1)) {                \\\n-            _main();                                         \\\n-        }                                                    \\\n-        _MD_GET_SP(_thread) = (unsigned char *)((_sp) - 64); \\\n-    }\n-\n-#define _MD_SWITCH_CONTEXT(_thread)        \\\n-    if (!sigsetjmp(CONTEXT(_thread), 1)) { \\\n-        (_thread)->md.errcode = errno;     \\\n-        _PR_Schedule();                    \\\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)  \\\n+{  \\\n+    *status = PR_TRUE;  \\\n+    if (sigsetjmp(CONTEXT(_thread), 1)) {  \\\n+        _main();  \\\n+    }  \\\n+    _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 64); \\\n+}\n+\n+#define _MD_SWITCH_CONTEXT(_thread)  \\\n+    if (!sigsetjmp(CONTEXT(_thread), 1)) {  \\\n+        (_thread)->md.errcode = errno;  \\\n+        _PR_Schedule();  \\\n     }\n \n /*\n ** Restore a thread context, saved by _MD_SWITCH_CONTEXT\n */\n-#define _MD_RESTORE_CONTEXT(_thread)     \\\n-    {                                    \\\n-        errno = (_thread)->md.errcode;   \\\n-        _MD_SET_CURRENT_THREAD(_thread); \\\n-        siglongjmp(CONTEXT(_thread), 1); \\\n-    }\n+#define _MD_RESTORE_CONTEXT(_thread) \\\n+{   \\\n+    errno = (_thread)->md.errcode;  \\\n+    _MD_SET_CURRENT_THREAD(_thread);  \\\n+    siglongjmp(CONTEXT(_thread), 1);  \\\n+}\n \n /* Machine-dependent (MD) data structures */\n \n@@ -145,29 +146,29 @@ struct _MDCPU_Unix {\n     PRInt32 ioq_osfd_cnt;\n #ifndef _PR_USE_POLL\n     fd_set fd_read_set, fd_write_set, fd_exception_set;\n-    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD],\n-        fd_exception_cnt[_PR_MD_MAX_OSFD];\n+    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],\n+            fd_exception_cnt[_PR_MD_MAX_OSFD];\n #else\n-    struct pollfd* ioq_pollfds;\n+    struct pollfd *ioq_pollfds;\n     int ioq_pollfds_size;\n-#endif /* _PR_USE_POLL */\n+#endif  /* _PR_USE_POLL */\n };\n \n-#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)\n+#define _PR_IOQ(_cpu)           ((_cpu)->md.md_unix.ioQ)\n #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n-#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)\n-#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)\n-#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)\n-#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)\n-#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)\n-#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)\n-#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)\n-#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)\n-#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)\n-#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)\n-#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)\n-\n-#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32\n+#define _PR_FD_READ_SET(_cpu)       ((_cpu)->md.md_unix.fd_read_set)\n+#define _PR_FD_READ_CNT(_cpu)       ((_cpu)->md.md_unix.fd_read_cnt)\n+#define _PR_FD_WRITE_SET(_cpu)      ((_cpu)->md.md_unix.fd_write_set)\n+#define _PR_FD_WRITE_CNT(_cpu)      ((_cpu)->md.md_unix.fd_write_cnt)\n+#define _PR_FD_EXCEPTION_SET(_cpu)  ((_cpu)->md.md_unix.fd_exception_set)\n+#define _PR_FD_EXCEPTION_CNT(_cpu)  ((_cpu)->md.md_unix.fd_exception_cnt)\n+#define _PR_IOQ_TIMEOUT(_cpu)       ((_cpu)->md.md_unix.ioq_timeout)\n+#define _PR_IOQ_MAX_OSFD(_cpu)      ((_cpu)->md.md_unix.ioq_max_osfd)\n+#define _PR_IOQ_OSFD_CNT(_cpu)      ((_cpu)->md.md_unix.ioq_osfd_cnt)\n+#define _PR_IOQ_POLLFDS(_cpu)       ((_cpu)->md.md_unix.ioq_pollfds)\n+#define _PR_IOQ_POLLFDS_SIZE(_cpu)  ((_cpu)->md.md_unix.ioq_pollfds_size)\n+\n+#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)  32\n \n struct _MDCPU {\n     struct _MDCPU_Unix md_unix;\n@@ -182,28 +183,28 @@ struct _MDCPU {\n #define _MD_IOQ_LOCK()\n #define _MD_IOQ_UNLOCK()\n \n-#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)\n-#define _MD_INIT_THREAD _MD_InitializeThread\n+#define _MD_INIT_RUNNING_CPU(cpu)       _MD_unix_init_running_cpu(cpu)\n+#define _MD_INIT_THREAD                 _MD_InitializeThread\n #define _MD_EXIT_THREAD(thread)\n-#define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread\n-#define _MD_RESUME_THREAD(thread) _MD_resume_thread\n+#define _MD_SUSPEND_THREAD(thread)      _MD_suspend_thread\n+#define _MD_RESUME_THREAD(thread)       _MD_resume_thread\n #define _MD_CLEAN_THREAD(_thread)\n \n #endif /* ! _PR_PTHREADS */\n \n extern void _MD_EarlyInit(void);\n \n-#define _MD_EARLY_INIT _MD_EarlyInit\n-#define _MD_FINAL_INIT _PR_UnixInit\n+#define _MD_EARLY_INIT                  _MD_EarlyInit\n+#define _MD_FINAL_INIT          _PR_UnixInit\n #define _PR_HAVE_CLOCK_MONOTONIC\n \n /*\n  * We wrapped the select() call.  _MD_SELECT refers to the built-in,\n  * unwrapped version.\n  */\n-#define _MD_SELECT(nfds, r, w, e, tv) syscall(SYS_select, nfds, r, w, e, tv)\n+#define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)\n #include <poll.h>\n-#define _MD_POLL(fds, nfds, timeout) syscall(SYS_poll, fds, nfds, timeout)\n+#define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)\n \n #if OpenBSD1_3 == 1L\n typedef unsigned int nfds_t;\ndiff --git a/nspr/pr/include/md/_pcos.h b/nspr/pr/include/md/_pcos.h\nindex d87c5fd..9d34574 100644\n--- a/nspr/pr/include/md/_pcos.h\n+++ b/nspr/pr/include/md/_pcos.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -5,23 +6,24 @@\n #ifndef prpcos_h___\n #define prpcos_h___\n \n-#define PR_DLL_SUFFIX \".dll\"\n+#define PR_DLL_SUFFIX       \".dll\"\n \n #include <stdlib.h>\n \n-#define DIRECTORY_SEPARATOR '\\\\'\n-#define DIRECTORY_SEPARATOR_STR \"\\\\\"\n-#define PATH_SEPARATOR ';'\n+#define DIRECTORY_SEPARATOR         '\\\\'\n+#define DIRECTORY_SEPARATOR_STR     \"\\\\\"\n+#define PATH_SEPARATOR              ';'\n \n /*\n ** Routines for processing command line arguments\n */\n PR_BEGIN_EXTERN_C\n-extern char* optarg;\n+extern char *optarg;\n extern int optind;\n-extern int getopt(int argc, char** argv, char* spec);\n+extern int getopt(int argc, char **argv, char *spec);\n PR_END_EXTERN_C\n \n+\n /*\n ** Definitions of directory structures amd functions\n ** These definitions are from:\n@@ -29,12 +31,11 @@ PR_END_EXTERN_C\n */\n #include <sys/stat.h>\n #include <io.h>\n-#include <fcntl.h> /* O_BINARY */\n+#include <fcntl.h>          /* O_BINARY */\n \n-extern PRStatus _MD_WindowsGetHostName(char* name, PRUint32 namelen);\n+extern PRStatus _MD_WindowsGetHostName(char *name, PRUint32 namelen);\n #define _MD_GETHOSTNAME _MD_WindowsGetHostName\n-extern PRStatus _MD_WindowsGetSysInfo(PRSysInfo cmd, char* name,\n-                                      PRUint32 namelen);\n+extern PRStatus _MD_WindowsGetSysInfo(PRSysInfo cmd, char *name, PRUint32 namelen);\n #define _MD_GETSYSINFO _MD_WindowsGetSysInfo\n \n #endif /* prpcos_h___ */\ndiff --git a/nspr/pr/include/md/_pth.h b/nspr/pr/include/md/_pth.h\nindex e0e2cf3..7bcea96 100644\n--- a/nspr/pr/include/md/_pth.h\n+++ b/nspr/pr/include/md/_pth.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -13,23 +14,23 @@\n #define _PR_MD_DISABLE_CLOCK_INTERRUPTS()\n #define _PR_MD_ENABLE_CLOCK_INTERRUPTS()\n \n-#define _PT_PTHREAD_MUTEXATTR_INIT pthread_mutexattr_init\n-#define _PT_PTHREAD_MUTEXATTR_DESTROY pthread_mutexattr_destroy\n-#define _PT_PTHREAD_MUTEX_INIT(m, a) pthread_mutex_init(&(m), &(a))\n+#define _PT_PTHREAD_MUTEXATTR_INIT        pthread_mutexattr_init\n+#define _PT_PTHREAD_MUTEXATTR_DESTROY     pthread_mutexattr_destroy\n+#define _PT_PTHREAD_MUTEX_INIT(m, a)      pthread_mutex_init(&(m), &(a))\n #if defined(FREEBSD)\n-#define _PT_PTHREAD_MUTEX_IS_LOCKED(m) pt_pthread_mutex_is_locked(&(m))\n+#define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    pt_pthread_mutex_is_locked(&(m))\n #else\n-#define _PT_PTHREAD_MUTEX_IS_LOCKED(m) (EBUSY == pthread_mutex_trylock(&(m)))\n+#define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    (EBUSY == pthread_mutex_trylock(&(m)))\n #endif\n #if defined(ANDROID)\n /* Conditional attribute init and destroy aren't implemented in bionic. */\n-#define _PT_PTHREAD_CONDATTR_INIT(x) 0\n-#define _PT_PTHREAD_CONDATTR_DESTROY(x) /* */\n+#define _PT_PTHREAD_CONDATTR_INIT(x)      0\n+#define _PT_PTHREAD_CONDATTR_DESTROY(x)   /* */\n #else\n-#define _PT_PTHREAD_CONDATTR_INIT pthread_condattr_init\n-#define _PT_PTHREAD_CONDATTR_DESTROY pthread_condattr_destroy\n+#define _PT_PTHREAD_CONDATTR_INIT         pthread_condattr_init\n+#define _PT_PTHREAD_CONDATTR_DESTROY      pthread_condattr_destroy\n #endif\n-#define _PT_PTHREAD_COND_INIT(m, a) pthread_cond_init(&(m), &(a))\n+#define _PT_PTHREAD_COND_INIT(m, a)       pthread_cond_init(&(m), &(a))\n \n /* The pthreads standard does not specify an invalid value for the\n  * pthread_t handle.  (0 is usually an invalid pthread identifier\n@@ -60,24 +61,26 @@\n  *   PR_EnterMonitor calls any of these functions, infinite\n  *   recursion ensues.\n  */\n-#if defined(AIX) || defined(SOLARIS) || defined(LINUX) || defined(__GNU__) || \\\n-    defined(__GLIBC__) || defined(FREEBSD) || defined(NETBSD) ||              \\\n-    defined(OPENBSD) || defined(NTO) || defined(DARWIN) || defined(RISCOS)\n-#define _PT_PTHREAD_INVALIDATE_THR_HANDLE(t) (t) = 0\n-#define _PT_PTHREAD_THR_HANDLE_IS_INVALID(t) (t) == 0\n-#define _PT_PTHREAD_COPY_THR_HANDLE(st, dt) (dt) = (st)\n+#if defined(AIX) || defined(SOLARIS) \\\n+    || defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \\\n+    || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \\\n+    || defined(NTO) || defined(DARWIN) \\\n+    || defined(RISCOS)\n+#define _PT_PTHREAD_INVALIDATE_THR_HANDLE(t)  (t) = 0\n+#define _PT_PTHREAD_THR_HANDLE_IS_INVALID(t)  (t) == 0\n+#define _PT_PTHREAD_COPY_THR_HANDLE(st, dt)   (dt) = (st)\n #else\n #error \"pthreads is not supported for this architecture\"\n #endif\n \n #if defined(_PR_PTHREADS)\n-#define _PT_PTHREAD_ATTR_INIT pthread_attr_init\n-#define _PT_PTHREAD_ATTR_DESTROY pthread_attr_destroy\n-#define _PT_PTHREAD_CREATE(t, a, f, r) pthread_create(t, &a, f, r)\n-#define _PT_PTHREAD_KEY_CREATE pthread_key_create\n-#define _PT_PTHREAD_ATTR_SETSCHEDPOLICY pthread_attr_setschedpolicy\n+#define _PT_PTHREAD_ATTR_INIT            pthread_attr_init\n+#define _PT_PTHREAD_ATTR_DESTROY         pthread_attr_destroy\n+#define _PT_PTHREAD_CREATE(t, a, f, r)   pthread_create(t, &a, f, r)\n+#define _PT_PTHREAD_KEY_CREATE           pthread_key_create\n+#define _PT_PTHREAD_ATTR_SETSCHEDPOLICY  pthread_attr_setschedpolicy\n #define _PT_PTHREAD_ATTR_GETSTACKSIZE(a, s) pthread_attr_getstacksize(a, s)\n-#define _PT_PTHREAD_GETSPECIFIC(k, r) (r) = pthread_getspecific(k)\n+#define _PT_PTHREAD_GETSPECIFIC(k, r)    (r) = pthread_getspecific(k)\n #else\n #error \"Cannot determine pthread strategy\"\n #endif\n@@ -85,9 +88,10 @@\n /*\n  * These platforms don't have sigtimedwait()\n  */\n-#if (defined(AIX) && !defined(AIX4_3_PLUS)) || defined(LINUX) ||  \\\n-    defined(__GNU__) || defined(__GLIBC__) || defined(FREEBSD) || \\\n-    defined(NETBSD) || defined(OPENBSD) || defined(DARWIN)\n+#if (defined(AIX) && !defined(AIX4_3_PLUS)) \\\n+    || defined(LINUX) || defined(__GNU__)|| defined(__GLIBC__) \\\n+    || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \\\n+    || defined(DARWIN)\n #define PT_NO_SIGTIMEDWAIT\n #endif\n \n@@ -95,22 +99,22 @@\n #include <sys/priv.h>\n #include <sys/sched.h>\n #ifndef PTHREAD_CREATE_JOINABLE\n-#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED\n+#define PTHREAD_CREATE_JOINABLE     PTHREAD_CREATE_UNDETACHED\n #endif\n-#define PT_PRIO_MIN DEFAULT_PRIO\n-#define PT_PRIO_MAX DEFAULT_PRIO\n-#elif defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) || \\\n-    defined(FREEBSD)\n-#define PT_PRIO_MIN sched_get_priority_min(SCHED_OTHER)\n-#define PT_PRIO_MAX sched_get_priority_max(SCHED_OTHER)\n+#define PT_PRIO_MIN            DEFAULT_PRIO\n+#define PT_PRIO_MAX            DEFAULT_PRIO\n+#elif defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \\\n+    || defined(FREEBSD)\n+#define PT_PRIO_MIN            sched_get_priority_min(SCHED_OTHER)\n+#define PT_PRIO_MAX            sched_get_priority_max(SCHED_OTHER)\n #elif defined(NTO)\n /*\n  * Neutrino has functions that return the priority range but\n  * they return invalid numbers, so I just hard coded these here\n  * for now.  Jerry.Kirk@Nexarecorp.com\n  */\n-#define PT_PRIO_MIN 0\n-#define PT_PRIO_MAX 30\n+#define PT_PRIO_MIN            0\n+#define PT_PRIO_MAX            30\n #elif defined(SOLARIS)\n /*\n  * Solaris doesn't seem to have macros for the min/max priorities.\n@@ -118,14 +122,16 @@\n  * man pages, and pthread_setschedparam indeed allows 0-127.  However,\n  * pthread_attr_setschedparam does not allow 0; it allows 1-127.\n  */\n-#define PT_PRIO_MIN 1\n-#define PT_PRIO_MAX 127\n+#define PT_PRIO_MIN            1\n+#define PT_PRIO_MAX            127\n #elif defined(OPENBSD)\n-#define PT_PRIO_MIN 0\n-#define PT_PRIO_MAX 31\n-#elif defined(NETBSD) || defined(DARWIN) || defined(RISCOS) /* XXX */\n-#define PT_PRIO_MIN 0\n-#define PT_PRIO_MAX 126\n+#define PT_PRIO_MIN            0\n+#define PT_PRIO_MAX            31\n+#elif defined(NETBSD) \\\n+    || defined(DARWIN) \\\n+    || defined(RISCOS) /* XXX */\n+#define PT_PRIO_MIN            0\n+#define PT_PRIO_MAX            126\n #else\n #error \"pthreads is not supported for this architecture\"\n #endif\n@@ -137,11 +143,13 @@\n  */\n #if defined(AIX)\n extern int (*_PT_aix_yield_fcn)();\n-#define _PT_PTHREAD_YIELD() (*_PT_aix_yield_fcn)()\n-#elif defined(SOLARIS) || defined(LINUX) || defined(__GNU__) ||  \\\n-    defined(__GLIBC__) || defined(FREEBSD) || defined(NETBSD) || \\\n-    defined(OPENBSD) || defined(NTO) || defined(DARWIN) || defined(RISCOS)\n-#define _PT_PTHREAD_YIELD() sched_yield()\n+#define _PT_PTHREAD_YIELD()         (*_PT_aix_yield_fcn)()\n+#elif defined(SOLARIS) \\\n+    || defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \\\n+    || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \\\n+    || defined(NTO) || defined(DARWIN) \\\n+    || defined(RISCOS)\n+#define _PT_PTHREAD_YIELD()             sched_yield()\n #else\n #error \"Need to define _PT_PTHREAD_YIELD for this platform\"\n #endif\ndiff --git a/nspr/pr/include/md/_qnx.cfg b/nspr/pr/include/md/_qnx.cfg\nindex 8532120..a459b8c 100644\n--- a/nspr/pr/include/md/_qnx.cfg\n+++ b/nspr/pr/include/md/_qnx.cfg\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/md/_qnx.h b/nspr/pr/include/md/_qnx.h\nindex 34d5ff3..923e174 100644\n--- a/nspr/pr/include/md/_qnx.h\n+++ b/nspr/pr/include/md/_qnx.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,15 +9,15 @@\n /*\n ** Internal configuration macros\n */\n-#define PR_LINKER_ARCH \"qnx\"\n-#define _PR_SI_SYSNAME \"QNX\"\n+#define PR_LINKER_ARCH      \"qnx\"\n+#define _PR_SI_SYSNAME      \"QNX\"\n #define _PR_SI_ARCHITECTURE \"x86\"\n-#define PR_DLL_SUFFIX \".so\"\n+#define PR_DLL_SUFFIX       \".so\"\n \n-#define _PR_VMBASE 0x30000000\n-#define _PR_STACK_VMBASE 0x50000000\n-#define _MD_DEFAULT_STACK_SIZE 65536L\n-#define _MD_MMAP_FLAGS MAP_PRIVATE\n+#define _PR_VMBASE      0x30000000\n+#define _PR_STACK_VMBASE    0x50000000\n+#define _MD_DEFAULT_STACK_SIZE  65536L\n+#define _MD_MMAP_FLAGS      MAP_PRIVATE\n \n #ifndef HAVE_WEAK_IO_SYMBOLS\n #define HAVE_WEAK_IO_SYMBOLS\n@@ -31,9 +32,9 @@\n \n #include <sys/select.h>\n \n-#undef HAVE_STACK_GROWING_UP\n-#undef HAVE_DLL\n-#undef USE_DLFCN\n+#undef  HAVE_STACK_GROWING_UP\n+#undef  HAVE_DLL\n+#undef  USE_DLFCN\n #define NEED_STRFTIME_LOCK\n #define NEED_TIME_R\n #define _PR_NEED_STRCASECMP\n@@ -46,40 +47,39 @@\n \n #include <setjmp.h>\n \n-#define _SETJMP setjmp\n-#define _LONGJMP longjmp\n-#define _PR_CONTEXT_TYPE jmp_buf\n-#define _PR_NUM_GCREGS _JBLEN\n-#define _MD_GET_SP(_t) (_t)->md.context[7]\n+#define _SETJMP         setjmp\n+#define _LONGJMP        longjmp\n+#define _PR_CONTEXT_TYPE    jmp_buf\n+#define _PR_NUM_GCREGS      _JBLEN\n+#define _MD_GET_SP(_t)      (_t)->md.context[7]\n \n-#define CONTEXT(_th) ((_th)->md.context)\n+#define CONTEXT(_th)        ((_th)->md.context)\n \n /*\n ** Initialize the thread context preparing it to execute _main.\n */\n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \\\n-    {                                                 \\\n-        *status = PR_TRUE;                            \\\n-        if (_SETJMP(CONTEXT(_thread)))                \\\n-            (*_main)();                               \\\n-        _MD_GET_SP(_thread) = (int)((_sp) - 128);     \\\n-    }\n-\n-#define _MD_SWITCH_CONTEXT(_thread)    \\\n-    if (!_SETJMP(CONTEXT(_thread))) {  \\\n-        (_thread)->md.errcode = errno; \\\n-        _PR_Schedule();                \\\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)   \\\n+{                           \\\n+    *status = PR_TRUE;                  \\\n+    if(_SETJMP(CONTEXT(_thread))) (*_main)();       \\\n+    _MD_GET_SP(_thread) = (int) ((_sp) - 128);      \\\n+}\n+\n+#define _MD_SWITCH_CONTEXT(_thread) \\\n+    if (!_SETJMP(CONTEXT(_thread))) {   \\\n+    (_thread)->md.errcode = errno;  \\\n+    _PR_Schedule();         \\\n     }\n \n /*\n ** Restore a thread context, saved by _MD_SWITCH_CONTEXT\n */\n-#define _MD_RESTORE_CONTEXT(_thread)     \\\n-    {                                    \\\n-        errno = (_thread)->md.errcode;   \\\n-        _MD_SET_CURRENT_THREAD(_thread); \\\n-        _LONGJMP(CONTEXT(_thread), 1);   \\\n-    }\n+#define _MD_RESTORE_CONTEXT(_thread)    \\\n+{                   \\\n+    errno = (_thread)->md.errcode;  \\\n+    _MD_SET_CURRENT_THREAD(_thread);    \\\n+    _LONGJMP(CONTEXT(_thread), 1);  \\\n+}\n \n /*\n ** Machine-dependent (MD) data structures.\n@@ -113,7 +113,7 @@ struct _MDSegment {\n /*\n ** md-specific cpu structure field\n */\n-#define _PR_MD_MAX_OSFD FD_SETSIZE\n+#define _PR_MD_MAX_OSFD     FD_SETSIZE\n \n struct _MDCPU_Unix {\n     PRCList ioQ;\n@@ -122,36 +122,35 @@ struct _MDCPU_Unix {\n     PRInt32 ioq_osfd_cnt;\n #ifndef _PR_USE_POLL\n     fd_set fd_read_set, fd_write_set, fd_exception_set;\n-    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD],\n-        fd_exception_cnt[_PR_MD_MAX_OSFD];\n+    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD], fd_exception_cnt[_PR_MD_MAX_OSFD];\n #else\n-    struct pollfd* ioq_pollfds;\n+    struct pollfd *ioq_pollfds;\n     int ioq_pollfds_size;\n #endif\n };\n \n-#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)\n-#define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n-#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)\n-#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)\n-#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)\n-#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)\n-#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)\n-#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)\n-#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)\n-#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)\n-#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)\n-#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)\n-#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)\n-\n-#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32\n+#define _PR_IOQ(_cpu)           ((_cpu)->md.md_unix.ioQ)\n+#define _PR_ADD_TO_IOQ(_pq, _cpu)   PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n+#define _PR_FD_READ_SET(_cpu)       ((_cpu)->md.md_unix.fd_read_set)\n+#define _PR_FD_READ_CNT(_cpu)       ((_cpu)->md.md_unix.fd_read_cnt)\n+#define _PR_FD_WRITE_SET(_cpu)      ((_cpu)->md.md_unix.fd_write_set)\n+#define _PR_FD_WRITE_CNT(_cpu)      ((_cpu)->md.md_unix.fd_write_cnt)\n+#define _PR_FD_EXCEPTION_SET(_cpu)  ((_cpu)->md.md_unix.fd_exception_set)\n+#define _PR_FD_EXCEPTION_CNT(_cpu)  ((_cpu)->md.md_unix.fd_exception_cnt)\n+#define _PR_IOQ_TIMEOUT(_cpu)       ((_cpu)->md.md_unix.ioq_timeout)\n+#define _PR_IOQ_MAX_OSFD(_cpu)      ((_cpu)->md.md_unix.ioq_max_osfd)\n+#define _PR_IOQ_OSFD_CNT(_cpu)      ((_cpu)->md.md_unix.ioq_osfd_cnt)\n+#define _PR_IOQ_POLLFDS(_cpu)       ((_cpu)->md.md_unix.ioq_pollfds)\n+#define _PR_IOQ_POLLFDS_SIZE(_cpu)  ((_cpu)->md.md_unix.ioq_pollfds_size)\n+\n+#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)  32\n \n struct _MDCPU {\n     struct _MDCPU_Unix md_unix;\n };\n \n #define _MD_INIT_LOCKS()\n-#define _MD_NEW_LOCK(lock) PR_SUCCESS\n+#define _MD_NEW_LOCK(lock)      PR_SUCCESS\n #define _MD_FREE_LOCK(lock)\n #define _MD_LOCK(lock)\n #define _MD_UNLOCK(lock)\n@@ -160,10 +159,10 @@ struct _MDCPU {\n #define _MD_IOQ_UNLOCK()\n \n #define _MD_INTERVAL_USE_GTOD\n-#define _MD_EARLY_INIT _MD_EarlyInit\n-#define _MD_FINAL_INIT _PR_UnixInit\n-#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)\n-#define _MD_INIT_THREAD _MD_InitializeThread\n+#define _MD_EARLY_INIT          _MD_EarlyInit\n+#define _MD_FINAL_INIT          _PR_UnixInit\n+#define _MD_INIT_RUNNING_CPU(cpu)   _MD_unix_init_running_cpu(cpu)\n+#define _MD_INIT_THREAD         _MD_InitializeThread\n #define _MD_EXIT_THREAD(thread)\n #define _MD_SUSPEND_THREAD(thread)\n #define _MD_RESUME_THREAD(thread)\n@@ -176,7 +175,7 @@ struct _MDCPU {\n #include <sys/time.h>\n #include <sys/types.h>\n #include <sys/select.h>\n-#define _MD_SELECT select\n+#define _MD_SELECT      select\n \n #define SA_RESTART 0\n \ndiff --git a/nspr/pr/include/md/_riscos.cfg b/nspr/pr/include/md/_riscos.cfg\nindex 9f56055..c7adf2e 100644\n--- a/nspr/pr/include/md/_riscos.cfg\n+++ b/nspr/pr/include/md/_riscos.cfg\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/md/_riscos.h b/nspr/pr/include/md/_riscos.h\nindex 52e58bc..ec03dcb 100644\n--- a/nspr/pr/include/md/_riscos.h\n+++ b/nspr/pr/include/md/_riscos.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,10 +9,10 @@\n /*\n ** Internal configuration macros\n */\n-#define PR_LINKER_ARCH \"riscos\"\n-#define _PR_SI_SYSNAME \"RISCOS\"\n+#define PR_LINKER_ARCH      \"riscos\"\n+#define _PR_SI_SYSNAME      \"RISCOS\"\n #define _PR_SI_ARCHITECTURE \"arm\"\n-#define PR_DLL_SUFFIX \".so\"\n+#define PR_DLL_SUFFIX       \".so\"\n \n #define _PR_POLL_AVAILABLE\n #define _PR_USE_POLL\n@@ -25,7 +26,8 @@\n #include <sys/poll.h>\n #include <kernel.h>\n \n-#undef HAVE_STACK_GROWING_UP\n+\n+#undef  HAVE_STACK_GROWING_UP\n #define HAVE_DLL\n #define USE_DLFCN\n #define NEED_STRFTIME_LOCK\n@@ -40,40 +42,40 @@\n \n #include <setjmp.h>\n \n-#define _SETJMP setjmp\n-#define _LONGJMP longjmp\n-#define _PR_CONTEXT_TYPE jmp_buf\n-#define _PR_NUM_GCREGS _JBLEN\n-#define _MD_GET_SP(_t) (_t)->md.context[7]\n+#define _SETJMP         setjmp\n+#define _LONGJMP        longjmp\n+#define _PR_CONTEXT_TYPE    jmp_buf\n+#define _PR_NUM_GCREGS      _JBLEN\n+#define _MD_GET_SP(_t)      (_t)->md.context[7]\n+\n+#define CONTEXT(_th)        ((_th)->md.context)\n \n-#define CONTEXT(_th) ((_th)->md.context)\n \n /*\n ** Initialize the thread context preparing it to execute _main.\n */\n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \\\n-    {                                                 \\\n-        *status = PR_TRUE;                            \\\n-        if (_SETJMP(CONTEXT(_thread)))                \\\n-            (*_main)();                               \\\n-        _MD_GET_SP(_thread) = (int)((_sp) - 128);     \\\n-    }\n-\n-#define _MD_SWITCH_CONTEXT(_thread)    \\\n-    if (!_SETJMP(CONTEXT(_thread))) {  \\\n-        (_thread)->md.errcode = errno; \\\n-        _PR_Schedule();                \\\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)   \\\n+{                           \\\n+    *status = PR_TRUE;                  \\\n+    if(_SETJMP(CONTEXT(_thread))) (*_main)();       \\\n+    _MD_GET_SP(_thread) = (int) ((_sp) - 128);      \\\n+}\n+\n+#define _MD_SWITCH_CONTEXT(_thread) \\\n+    if (!_SETJMP(CONTEXT(_thread))) {   \\\n+    (_thread)->md.errcode = errno;  \\\n+    _PR_Schedule();         \\\n     }\n \n /*\n ** Restore a thread context, saved by _MD_SWITCH_CONTEXT\n */\n-#define _MD_RESTORE_CONTEXT(_thread)     \\\n-    {                                    \\\n-        errno = (_thread)->md.errcode;   \\\n-        _MD_SET_CURRENT_THREAD(_thread); \\\n-        _LONGJMP(CONTEXT(_thread), 1);   \\\n-    }\n+#define _MD_RESTORE_CONTEXT(_thread)    \\\n+{                   \\\n+    errno = (_thread)->md.errcode;  \\\n+    _MD_SET_CURRENT_THREAD(_thread);    \\\n+    _LONGJMP(CONTEXT(_thread), 1);  \\\n+}\n \n /*\n ** Machine-dependent (MD) data structures.\n@@ -107,7 +109,7 @@ struct _MDSegment {\n /*\n ** md-specific cpu structure field\n */\n-#define _PR_MD_MAX_OSFD FD_SETSIZE\n+#define _PR_MD_MAX_OSFD     FD_SETSIZE\n \n struct _MDCPU_Unix {\n     PRCList ioQ;\n@@ -116,36 +118,35 @@ struct _MDCPU_Unix {\n     PRInt32 ioq_osfd_cnt;\n #ifndef _PR_USE_POLL\n     fd_set fd_read_set, fd_write_set, fd_exception_set;\n-    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD],\n-        fd_exception_cnt[_PR_MD_MAX_OSFD];\n+    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD], fd_exception_cnt[_PR_MD_MAX_OSFD];\n #else\n-    struct pollfd* ioq_pollfds;\n+    struct pollfd *ioq_pollfds;\n     int ioq_pollfds_size;\n #endif\n };\n \n-#define _PR_IOQ(_cpu) /*  */ ((_cpu)->md.md_unix.ioQ)\n-#define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n-#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)\n-#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)\n-#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)\n-#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)\n-#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)\n-#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)\n-#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)\n-#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)\n-#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)\n-#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)\n-#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)\n-\n-#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32\n+#define _PR_IOQ(_cpu)   /*  */  ((_cpu)->md.md_unix.ioQ)\n+#define _PR_ADD_TO_IOQ(_pq, _cpu)   PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n+#define _PR_FD_READ_SET(_cpu)       ((_cpu)->md.md_unix.fd_read_set)\n+#define _PR_FD_READ_CNT(_cpu)       ((_cpu)->md.md_unix.fd_read_cnt)\n+#define _PR_FD_WRITE_SET(_cpu)      ((_cpu)->md.md_unix.fd_write_set)\n+#define _PR_FD_WRITE_CNT(_cpu)      ((_cpu)->md.md_unix.fd_write_cnt)\n+#define _PR_FD_EXCEPTION_SET(_cpu)  ((_cpu)->md.md_unix.fd_exception_set)\n+#define _PR_FD_EXCEPTION_CNT(_cpu)  ((_cpu)->md.md_unix.fd_exception_cnt)\n+#define _PR_IOQ_TIMEOUT(_cpu)       ((_cpu)->md.md_unix.ioq_timeout)\n+#define _PR_IOQ_MAX_OSFD(_cpu)      ((_cpu)->md.md_unix.ioq_max_osfd)\n+#define _PR_IOQ_OSFD_CNT(_cpu)      ((_cpu)->md.md_unix.ioq_osfd_cnt)\n+#define _PR_IOQ_POLLFDS(_cpu)       ((_cpu)->md.md_unix.ioq_pollfds)\n+#define _PR_IOQ_POLLFDS_SIZE(_cpu)  ((_cpu)->md.md_unix.ioq_pollfds_size)\n+\n+#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)  32\n \n struct _MDCPU {\n     struct _MDCPU_Unix md_unix;\n };\n \n #define _MD_INIT_LOCKS()\n-#define _MD_NEW_LOCK(lock) PR_SUCCESS\n+#define _MD_NEW_LOCK(lock)      PR_SUCCESS\n #define _MD_FREE_LOCK(lock)\n #define _MD_LOCK(lock)\n #define _MD_UNLOCK(lock)\n@@ -154,10 +155,10 @@ struct _MDCPU {\n #define _MD_IOQ_UNLOCK()\n \n #define _MD_INTERVAL_USE_GTOD\n-#define _MD_EARLY_INIT _MD_EarlyInit\n-#define _MD_FINAL_INIT _PR_UnixInit\n-#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)\n-#define _MD_INIT_THREAD _MD_InitializeThread\n+#define _MD_EARLY_INIT          _MD_EarlyInit\n+#define _MD_FINAL_INIT          _PR_UnixInit\n+#define _MD_INIT_RUNNING_CPU(cpu)   _MD_unix_init_running_cpu(cpu)\n+#define _MD_INIT_THREAD         _MD_InitializeThread\n #define _MD_EXIT_THREAD(thread)\n #define _MD_SUSPEND_THREAD(thread)\n #define _MD_RESUME_THREAD(thread)\n@@ -170,6 +171,6 @@ struct _MDCPU {\n #include <sys/time.h>\n #include <sys/types.h>\n #include <sys/select.h>\n-#define _MD_SELECT select\n+#define _MD_SELECT      select\n \n #endif /* nspr_riscos_defs_h___ */\ndiff --git a/nspr/pr/include/md/_solaris.cfg b/nspr/pr/include/md/_solaris.cfg\nindex 5efc4aa..6745637 100644\n--- a/nspr/pr/include/md/_solaris.cfg\n+++ b/nspr/pr/include/md/_solaris.cfg\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/md/_solaris.h b/nspr/pr/include/md/_solaris.h\nindex 90967af..4ebf77f 100644\n--- a/nspr/pr/include/md/_solaris.h\n+++ b/nspr/pr/include/md/_solaris.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,8 +10,8 @@\n  * Internal configuration macros\n  */\n \n-#define PR_LINKER_ARCH \"solaris\"\n-#define _PR_SI_SYSNAME \"SOLARIS\"\n+#define PR_LINKER_ARCH  \"solaris\"\n+#define _PR_SI_SYSNAME  \"SOLARIS\"\n #ifdef sparc\n #define _PR_SI_ARCHITECTURE \"sparc\"\n #elif defined(__x86_64)\n@@ -20,20 +21,20 @@\n #else\n #error unknown processor\n #endif\n-#define PR_DLL_SUFFIX \".so\"\n+#define PR_DLL_SUFFIX       \".so\"\n \n-#define _PR_VMBASE 0x30000000\n-#define _PR_STACK_VMBASE 0x50000000\n-#define _MD_DEFAULT_STACK_SIZE (2 * 65536L)\n-#define _MD_MMAP_FLAGS MAP_SHARED\n+#define _PR_VMBASE      0x30000000\n+#define _PR_STACK_VMBASE    0x50000000\n+#define _MD_DEFAULT_STACK_SIZE  (2*65536L)\n+#define _MD_MMAP_FLAGS          MAP_SHARED\n \n-#undef HAVE_STACK_GROWING_UP\n+#undef  HAVE_STACK_GROWING_UP\n \n #ifndef HAVE_WEAK_IO_SYMBOLS\n #define HAVE_WEAK_IO_SYMBOLS\n #endif\n \n-#undef HAVE_WEAK_MALLOC_SYMBOLS\n+#undef  HAVE_WEAK_MALLOC_SYMBOLS\n #define HAVE_DLL\n #define USE_DLFCN\n #define NEED_STRFTIME_LOCK\n@@ -76,19 +77,19 @@ struct addrinfo {\n     int ai_socktype;\n     int ai_protocol;\n     size_t ai_addrlen;\n-    char* ai_canonname;\n-    struct sockaddr* ai_addr;\n-    struct addrinfo* ai_next;\n+    char *ai_canonname;\n+    struct sockaddr *ai_addr;\n+    struct addrinfo *ai_next;\n };\n #define AI_CANONNAME 0x0010\n #define AI_V4MAPPED 0x0001\n-#define AI_ALL 0x0002\n-#define AI_ADDRCONFIG 0x0004\n+#define AI_ALL      0x0002\n+#define AI_ADDRCONFIG   0x0004\n #define _PR_HAVE_MD_SOCKADDR_IN6\n /* isomorphic to struct in6_addr on Solaris 8 */\n struct _md_in6_addr {\n     union {\n-        PRUint8 _S6_u8[16];\n+        PRUint8  _S6_u8[16];\n         PRUint32 _S6_u32[4];\n         PRUint32 __S6_align;\n     } _S6_un;\n@@ -110,12 +111,10 @@ struct _md_sockaddr_in6 {\n \n #include \"prinrval.h\"\n #define _MD_INTERVAL_INIT()\n-NSPR_API(PRIntervalTime)\n-_MD_Solaris_GetInterval(void);\n-#define _MD_GET_INTERVAL _MD_Solaris_GetInterval\n-NSPR_API(PRIntervalTime)\n-_MD_Solaris_TicksPerSecond(void);\n-#define _MD_INTERVAL_PER_SEC _MD_Solaris_TicksPerSecond\n+NSPR_API(PRIntervalTime) _MD_Solaris_GetInterval(void);\n+#define _MD_GET_INTERVAL                  _MD_Solaris_GetInterval\n+NSPR_API(PRIntervalTime) _MD_Solaris_TicksPerSecond(void);\n+#define _MD_INTERVAL_PER_SEC              _MD_Solaris_TicksPerSecond\n \n #if defined(_PR_HAVE_ATOMIC_OPS)\n /*\n@@ -123,30 +122,25 @@ _MD_Solaris_TicksPerSecond(void);\n */\n #define _MD_INIT_ATOMIC()\n \n-NSPR_API(PRInt32)\n-_MD_AtomicIncrement(PRInt32* val);\n+NSPR_API(PRInt32) _MD_AtomicIncrement(PRInt32 *val);\n #define _MD_ATOMIC_INCREMENT _MD_AtomicIncrement\n \n-NSPR_API(PRInt32)\n-_MD_AtomicAdd(PRInt32* ptr, PRInt32 val);\n+NSPR_API(PRInt32) _MD_AtomicAdd(PRInt32 *ptr, PRInt32 val);\n #define _MD_ATOMIC_ADD _MD_AtomicAdd\n \n-NSPR_API(PRInt32)\n-_MD_AtomicDecrement(PRInt32* val);\n+NSPR_API(PRInt32) _MD_AtomicDecrement(PRInt32 *val);\n #define _MD_ATOMIC_DECREMENT _MD_AtomicDecrement\n \n-NSPR_API(PRInt32)\n-_MD_AtomicSet(PRInt32* val, PRInt32 newval);\n+NSPR_API(PRInt32) _MD_AtomicSet(PRInt32 *val, PRInt32 newval);\n #define _MD_ATOMIC_SET _MD_AtomicSet\n #endif /* _PR_HAVE_ATOMIC_OPS */\n \n #if defined(_PR_PTHREADS)\n \n-NSPR_API(void)\n-_MD_EarlyInit(void);\n+NSPR_API(void)      _MD_EarlyInit(void);\n \n-#define _MD_EARLY_INIT _MD_EarlyInit\n-#define _MD_FINAL_INIT _PR_UnixInit\n+#define _MD_EARLY_INIT      _MD_EarlyInit\n+#define _MD_FINAL_INIT      _PR_UnixInit\n \n #else /* _PR_PTHREADS */\n \n@@ -165,51 +159,46 @@ _MD_EarlyInit(void);\n ** Initialization Related definitions\n */\n \n-NSPR_API(void)\n-_MD_EarlyInit(void);\n-NSPR_API(void)\n-_MD_SolarisInit();\n-#define _MD_EARLY_INIT _MD_EarlyInit\n-#define _MD_FINAL_INIT _MD_SolarisInit\n-#define _MD_INIT_THREAD _MD_InitializeThread\n+NSPR_API(void)              _MD_EarlyInit(void);\n+NSPR_API(void)              _MD_SolarisInit();\n+#define _MD_EARLY_INIT      _MD_EarlyInit\n+#define _MD_FINAL_INIT      _MD_SolarisInit\n+#define _MD_INIT_THREAD     _MD_InitializeThread\n \n #ifdef USE_SETJMP\n \n #include <setjmp.h>\n \n-#define _PR_CONTEXT_TYPE jmp_buf\n+#define _PR_CONTEXT_TYPE    jmp_buf\n \n #ifdef sparc\n-#define _MD_GET_SP(_t) (_t)->md.context[2]\n+#define _MD_GET_SP(_t)      (_t)->md.context[2]\n #else\n-#define _MD_GET_SP(_t) (_t)->md.context[4]\n+#define _MD_GET_SP(_t)      (_t)->md.context[4]\n #endif\n \n-#define PR_NUM_GCREGS _JBLEN\n-#define CONTEXT(_thread) (_thread)->md.context\n+#define PR_NUM_GCREGS       _JBLEN\n+#define CONTEXT(_thread)    (_thread)->md.context\n \n-#else /* ! USE_SETJMP */\n+#else  /* ! USE_SETJMP */\n \n #ifdef sparc\n-#define _PR_CONTEXT_TYPE ucontext_t\n-#define _MD_GET_SP(_t) (_t)->md.context.uc_mcontext.gregs[REG_SP]\n+#define _PR_CONTEXT_TYPE    ucontext_t\n+#define _MD_GET_SP(_t)      (_t)->md.context.uc_mcontext.gregs[REG_SP]\n /*\n ** Sparc's use register windows. the _MD_GetRegisters for the sparc's\n ** doesn't actually store anything into the argument buffer; instead the\n ** register windows are homed to the stack. I assume that the stack\n ** always has room for the registers to spill to...\n */\n-#define PR_NUM_GCREGS 0\n+#define PR_NUM_GCREGS       0\n #else\n-#define _PR_CONTEXT_TYPE         \\\n-    unsigned int edi;            \\\n-    sigset_t oldMask, blockMask; \\\n-    ucontext_t\n-#define _MD_GET_SP(_t) (_t)->md.context.uc_mcontext.gregs[USP]\n-#define PR_NUM_GCREGS _JBLEN\n+#define _PR_CONTEXT_TYPE    unsigned int edi; sigset_t oldMask, blockMask; ucontext_t\n+#define _MD_GET_SP(_t)      (_t)->md.context.uc_mcontext.gregs[USP]\n+#define PR_NUM_GCREGS       _JBLEN\n #endif\n \n-#define CONTEXT(_thread) (&(_thread)->md.context)\n+#define CONTEXT(_thread)    (&(_thread)->md.context)\n \n #endif /* ! USE_SETJMP */\n \n@@ -223,59 +212,57 @@ _MD_SolarisInit();\n #define GETTIME(tt) _pr_solx86_clock_gettime(CLOCK_REALTIME, (tt))\n #else\n #define GETTIME(tt) clock_gettime(CLOCK_REALTIME, (tt))\n-#endif /* i386 */\n+#endif  /* i386 */\n \n-#define _MD_SAVE_ERRNO(_thread) (_thread)->md.errcode = errno;\n-#define _MD_RESTORE_ERRNO(_thread) errno = (_thread)->md.errcode;\n+#define _MD_SAVE_ERRNO(_thread)         (_thread)->md.errcode = errno;\n+#define _MD_RESTORE_ERRNO(_thread)      errno = (_thread)->md.errcode;\n \n #ifdef sparc\n \n #ifdef USE_SETJMP\n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \\\n-    PR_BEGIN_MACRO                                    \\\n-    int* context = (_thread)->md.context;             \\\n-    *status = PR_TRUE;                                \\\n-    (void)setjmp(context);                            \\\n-    (_thread)->md.context[1] = (int)((_sp) - 64);     \\\n-    (_thread)->md.context[2] = (int)_main;            \\\n-    (_thread)->md.context[3] = (int)_main + 4;        \\\n-    _thread->no_sched = 0;                            \\\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)         \\\n+    PR_BEGIN_MACRO                    \\\n+    int *context = (_thread)->md.context;         \\\n+    *status = PR_TRUE;              \\\n+    (void) setjmp(context);               \\\n+    (_thread)->md.context[1] = (int) ((_sp) - 64); \\\n+    (_thread)->md.context[2] = (int) _main;       \\\n+    (_thread)->md.context[3] = (int) _main + 4; \\\n+    _thread->no_sched = 0; \\\n     PR_END_MACRO\n \n-#define _MD_SWITCH_CONTEXT(_thread)      \\\n-    if (!setjmp(CONTEXT(_thread))) {     \\\n-        _MD_SAVE_ERRNO(_thread)          \\\n-        _MD_SET_LAST_THREAD(_thread);    \\\n-        _MD_SET_CURRENT_THREAD(_thread); \\\n-        _PR_Schedule();                  \\\n+#define _MD_SWITCH_CONTEXT(_thread)    \\\n+    if (!setjmp(CONTEXT(_thread))) { \\\n+    _MD_SAVE_ERRNO(_thread)    \\\n+    _MD_SET_LAST_THREAD(_thread);    \\\n+    _MD_SET_CURRENT_THREAD(_thread);     \\\n+    _PR_Schedule();          \\\n     }\n \n #define _MD_RESTORE_CONTEXT(_newThread)     \\\n-    {                                       \\\n-        _MD_RESTORE_ERRNO(_newThread)       \\\n-        _MD_SET_CURRENT_THREAD(_newThread); \\\n-        longjmp(CONTEXT(_newThread), 1);    \\\n-    }\n+{                    \\\n+    _MD_RESTORE_ERRNO(_newThread)       \\\n+    _MD_SET_CURRENT_THREAD(_newThread); \\\n+    longjmp(CONTEXT(_newThread), 1);    \\\n+}\n \n #else\n /*\n ** Initialize the thread context preparing it to execute _main.\n */\n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)                  \\\n-    PR_BEGIN_MACRO                                                     \\\n-    ucontext_t* uc = CONTEXT(_thread);                                 \\\n-    *status = PR_TRUE;                                                 \\\n-    getcontext(uc);                                                    \\\n-    uc->uc_stack.ss_sp =                                               \\\n-        (char*)((unsigned long)(_sp - WINDOWSIZE - SA(MINFRAME)) &     \\\n-                0xfffffff8);                                           \\\n-    uc->uc_stack.ss_size = _thread->stack->stackSize;                  \\\n-    uc->uc_stack.ss_flags = 0; /* ? */                                 \\\n-    uc->uc_mcontext.gregs[REG_SP] = (unsigned int)uc->uc_stack.ss_sp;  \\\n-    uc->uc_mcontext.gregs[REG_PC] = (unsigned int)_main;               \\\n-    uc->uc_mcontext.gregs[REG_nPC] = (unsigned int)((char*)_main) + 4; \\\n-    uc->uc_flags = UC_ALL;                                             \\\n-    _thread->no_sched = 0;                                             \\\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)                   \\\n+    PR_BEGIN_MACRO                                                      \\\n+    ucontext_t *uc = CONTEXT(_thread);                                  \\\n+    *status = PR_TRUE;                                                  \\\n+    getcontext(uc);                                                     \\\n+    uc->uc_stack.ss_sp = (char *) ((unsigned long)(_sp - WINDOWSIZE - SA(MINFRAME)) & 0xfffffff8);  \\\n+    uc->uc_stack.ss_size = _thread->stack->stackSize;                   \\\n+    uc->uc_stack.ss_flags = 0;              /* ? */                     \\\n+    uc->uc_mcontext.gregs[REG_SP] = (unsigned int) uc->uc_stack.ss_sp;  \\\n+    uc->uc_mcontext.gregs[REG_PC] = (unsigned int) _main;               \\\n+    uc->uc_mcontext.gregs[REG_nPC] = (unsigned int) ((char*)_main)+4;   \\\n+    uc->uc_flags = UC_ALL;                                              \\\n+    _thread->no_sched = 0;                                              \\\n     PR_END_MACRO\n \n /*\n@@ -283,108 +270,105 @@ _MD_SolarisInit();\n ** calling the thread scheduler. Reload cpu when we come back from the\n ** context switch because it might have changed.\n */\n-#define _MD_SWITCH_CONTEXT(_thread)      \\\n-    PR_BEGIN_MACRO                       \\\n-    if (!getcontext(CONTEXT(_thread))) { \\\n-        _MD_SAVE_ERRNO(_thread);         \\\n-        _MD_SET_LAST_THREAD(_thread);    \\\n-        _PR_Schedule();                  \\\n-    }                                    \\\n+#define _MD_SWITCH_CONTEXT(_thread)                 \\\n+    PR_BEGIN_MACRO                                  \\\n+        if (!getcontext(CONTEXT(_thread))) {        \\\n+            _MD_SAVE_ERRNO(_thread);                \\\n+            _MD_SET_LAST_THREAD(_thread);           \\\n+            _PR_Schedule();                         \\\n+        }                                           \\\n     PR_END_MACRO\n \n /*\n ** Restore a thread context that was saved by _MD_SWITCH_CONTEXT or\n ** initialized by _MD_INIT_CONTEXT.\n */\n-#define _MD_RESTORE_CONTEXT(_newThread)   \\\n-    PR_BEGIN_MACRO                        \\\n-    ucontext_t* uc = CONTEXT(_newThread); \\\n-    uc->uc_mcontext.gregs[11] = 1;        \\\n-    _MD_RESTORE_ERRNO(_newThread);        \\\n-    _MD_SET_CURRENT_THREAD(_newThread);   \\\n-    setcontext(uc);                       \\\n+#define _MD_RESTORE_CONTEXT(_newThread)                     \\\n+    PR_BEGIN_MACRO                                          \\\n+        ucontext_t *uc = CONTEXT(_newThread);               \\\n+        uc->uc_mcontext.gregs[11] = 1;                      \\\n+        _MD_RESTORE_ERRNO(_newThread);                      \\\n+        _MD_SET_CURRENT_THREAD(_newThread);                 \\\n+        setcontext(uc);                                     \\\n     PR_END_MACRO\n #endif\n \n-#else /* x86 solaris */\n+#else  /* x86 solaris */\n \n #ifdef USE_SETJMP\n \n #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \\\n-    PR_BEGIN_MACRO                                    \\\n-    *status = PR_TRUE;                                \\\n-    if (setjmp(CONTEXT(_thread)))                     \\\n-        _main();                                      \\\n-    _MD_GET_SP(_thread) = (int)((_sp) - 64);          \\\n+    PR_BEGIN_MACRO \\\n+    *status = PR_TRUE; \\\n+    if (setjmp(CONTEXT(_thread))) _main(); \\\n+    _MD_GET_SP(_thread) = (int) ((_sp) - 64); \\\n     PR_END_MACRO\n \n-#define _MD_SWITCH_CONTEXT(_thread)  \\\n+#define _MD_SWITCH_CONTEXT(_thread) \\\n     if (!setjmp(CONTEXT(_thread))) { \\\n-        _MD_SAVE_ERRNO(_thread)      \\\n-        _PR_Schedule();              \\\n+        _MD_SAVE_ERRNO(_thread) \\\n+        _PR_Schedule(); \\\n     }\n \n-#define _MD_RESTORE_CONTEXT(_newThread)     \\\n-    {                                       \\\n-        _MD_RESTORE_ERRNO(_newThread)       \\\n-        _MD_SET_CURRENT_THREAD(_newThread); \\\n-        longjmp(CONTEXT(_newThread), 1);    \\\n-    }\n+#define _MD_RESTORE_CONTEXT(_newThread) \\\n+{ \\\n+    _MD_RESTORE_ERRNO(_newThread) \\\n+    _MD_SET_CURRENT_THREAD(_newThread); \\\n+    longjmp(CONTEXT(_newThread), 1); \\\n+}\n \n #else /* USE_SETJMP */\n \n-#define WINDOWSIZE 0\n+#define WINDOWSIZE      0\n \n int getedi(void);\n void setedi(int);\n \n-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)            \\\n-    PR_BEGIN_MACRO                                               \\\n-    ucontext_t* uc = CONTEXT(_thread);                           \\\n-    *status = PR_TRUE;                                           \\\n-    getcontext(uc);                                              \\\n-    /* Force sp to be double aligned! */                         \\\n-    uc->uc_mcontext.gregs[USP] =                                 \\\n-        (int)((unsigned long)(_sp - WINDOWSIZE - SA(MINFRAME)) & \\\n-              0xfffffff8);                                       \\\n-    uc->uc_mcontext.gregs[PC] = (int)_main;                      \\\n-    (_thread)->no_sched = 0;                                     \\\n+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)         \\\n+    PR_BEGIN_MACRO                  \\\n+    ucontext_t *uc = CONTEXT(_thread);      \\\n+        *status = PR_TRUE;              \\\n+    getcontext(uc);                 \\\n+    /* Force sp to be double aligned! */        \\\n+        uc->uc_mcontext.gregs[USP] = (int) ((unsigned long)(_sp - WINDOWSIZE - SA(MINFRAME)) & 0xfffffff8); \\\n+    uc->uc_mcontext.gregs[PC] = (int) _main;    \\\n+    (_thread)->no_sched = 0; \\\n     PR_END_MACRO\n \n /* getcontext() may return 1, contrary to what the man page says */\n-#define _MD_SWITCH_CONTEXT(_thread)                               \\\n-    PR_BEGIN_MACRO                                                \\\n-    ucontext_t* uc = CONTEXT(_thread);                            \\\n-    PR_ASSERT(_thread->no_sched);                                 \\\n-    sigfillset(&((_thread)->md.blockMask));                       \\\n-    sigprocmask(SIG_BLOCK, &((_thread)->md.blockMask),            \\\n-                &((_thread)->md.oldMask));                        \\\n-    (_thread)->md.edi = getedi();                                 \\\n-    if (!getcontext(uc)) {                                        \\\n+#define _MD_SWITCH_CONTEXT(_thread)         \\\n+    PR_BEGIN_MACRO                  \\\n+    ucontext_t *uc = CONTEXT(_thread);      \\\n+    PR_ASSERT(_thread->no_sched);           \\\n+    sigfillset(&((_thread)->md.blockMask));     \\\n+    sigprocmask(SIG_BLOCK, &((_thread)->md.blockMask),  \\\n+        &((_thread)->md.oldMask));      \\\n+    (_thread)->md.edi = getedi();           \\\n+    if (! getcontext(uc)) {             \\\n         sigprocmask(SIG_SETMASK, &((_thread)->md.oldMask), NULL); \\\n-        uc->uc_mcontext.gregs[EDI] = (_thread)->md.edi;           \\\n-        _MD_SAVE_ERRNO(_thread)                                   \\\n-        _MD_SET_LAST_THREAD(_thread);                             \\\n-        _PR_Schedule();                                           \\\n-    } else {                                                      \\\n+        uc->uc_mcontext.gregs[EDI] = (_thread)->md.edi; \\\n+        _MD_SAVE_ERRNO(_thread)         \\\n+            _MD_SET_LAST_THREAD(_thread);           \\\n+        _PR_Schedule();             \\\n+    } else {                    \\\n         sigprocmask(SIG_SETMASK, &((_thread)->md.oldMask), NULL); \\\n-        setedi((_thread)->md.edi);                                \\\n-        PR_ASSERT(_MD_LAST_THREAD() != _MD_CURRENT_THREAD());     \\\n-        _MD_LAST_THREAD()->no_sched = 0;                          \\\n-    }                                                             \\\n+        setedi((_thread)->md.edi);      \\\n+        PR_ASSERT(_MD_LAST_THREAD() !=_MD_CURRENT_THREAD()); \\\n+        _MD_LAST_THREAD()->no_sched = 0;    \\\n+    }                       \\\n     PR_END_MACRO\n \n /*\n ** Restore a thread context, saved by _PR_SWITCH_CONTEXT\n */\n-#define _MD_RESTORE_CONTEXT(_newthread)   \\\n-    PR_BEGIN_MACRO                        \\\n-    ucontext_t* uc = CONTEXT(_newthread); \\\n-    uc->uc_mcontext.gregs[EAX] = 1;       \\\n-    _MD_RESTORE_ERRNO(_newthread)         \\\n-    _MD_SET_CURRENT_THREAD(_newthread);   \\\n-    (_newthread)->no_sched = 1;           \\\n-    setcontext(uc);                       \\\n+#define _MD_RESTORE_CONTEXT(_newthread)         \\\n+    PR_BEGIN_MACRO                  \\\n+    ucontext_t *uc = CONTEXT(_newthread);       \\\n+    uc->uc_mcontext.gregs[EAX] = 1;         \\\n+    _MD_RESTORE_ERRNO(_newthread)           \\\n+    _MD_SET_CURRENT_THREAD(_newthread);     \\\n+    (_newthread)->no_sched = 1;         \\\n+    setcontext(uc);                 \\\n     PR_END_MACRO\n #endif /* USE_SETJMP */\n \n@@ -428,36 +412,36 @@ struct _MDCPU_Unix {\n     PRInt32 ioq_osfd_cnt;\n #ifndef _PR_USE_POLL\n     fd_set fd_read_set, fd_write_set, fd_exception_set;\n-    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD],\n-        fd_exception_cnt[_PR_MD_MAX_OSFD];\n+    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],\n+            fd_exception_cnt[_PR_MD_MAX_OSFD];\n #else\n-    struct pollfd* ioq_pollfds;\n+    struct pollfd *ioq_pollfds;\n     int ioq_pollfds_size;\n-#endif /* _PR_USE_POLL */\n+#endif  /* _PR_USE_POLL */\n };\n \n-#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)\n+#define _PR_IOQ(_cpu)           ((_cpu)->md.md_unix.ioQ)\n #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))\n-#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)\n-#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)\n-#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)\n-#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)\n-#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)\n-#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)\n-#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)\n-#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)\n-#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)\n-#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)\n-#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)\n-\n-#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32\n+#define _PR_FD_READ_SET(_cpu)       ((_cpu)->md.md_unix.fd_read_set)\n+#define _PR_FD_READ_CNT(_cpu)       ((_cpu)->md.md_unix.fd_read_cnt)\n+#define _PR_FD_WRITE_SET(_cpu)      ((_cpu)->md.md_unix.fd_write_set)\n+#define _PR_FD_WRITE_CNT(_cpu)      ((_cpu)->md.md_unix.fd_write_cnt)\n+#define _PR_FD_EXCEPTION_SET(_cpu)  ((_cpu)->md.md_unix.fd_exception_set)\n+#define _PR_FD_EXCEPTION_CNT(_cpu)  ((_cpu)->md.md_unix.fd_exception_cnt)\n+#define _PR_IOQ_TIMEOUT(_cpu)       ((_cpu)->md.md_unix.ioq_timeout)\n+#define _PR_IOQ_MAX_OSFD(_cpu)      ((_cpu)->md.md_unix.ioq_max_osfd)\n+#define _PR_IOQ_OSFD_CNT(_cpu)      ((_cpu)->md.md_unix.ioq_osfd_cnt)\n+#define _PR_IOQ_POLLFDS(_cpu)       ((_cpu)->md.md_unix.ioq_pollfds)\n+#define _PR_IOQ_POLLFDS_SIZE(_cpu)  ((_cpu)->md.md_unix.ioq_pollfds_size)\n+\n+#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)  32\n \n struct _MDCPU {\n     struct _MDCPU_Unix md_unix;\n };\n \n #define _MD_INIT_LOCKS()\n-#define _MD_NEW_LOCK(lock) PR_SUCCESS\n+#define _MD_NEW_LOCK(lock)              PR_SUCCESS\n #define _MD_FREE_LOCK(lock)\n #define _MD_LOCK(lock)\n #define _MD_UNLOCK(lock)\n@@ -465,39 +449,39 @@ struct _MDCPU {\n #define _MD_IOQ_LOCK()\n #define _MD_IOQ_UNLOCK()\n \n-#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)\n-#define _MD_INIT_THREAD _MD_InitializeThread\n+#define _MD_INIT_RUNNING_CPU(cpu)       _MD_unix_init_running_cpu(cpu)\n+#define _MD_INIT_THREAD                 _MD_InitializeThread\n #define _MD_EXIT_THREAD(thread)\n #define _MD_SUSPEND_THREAD(thread)\n #define _MD_RESUME_THREAD(thread)\n #define _MD_CLEAN_THREAD(_thread)\n \n-extern PRStatus _MD_WAIT(struct PRThread*, PRIntervalTime timeout);\n-extern PRStatus _MD_WAKEUP_WAITER(struct PRThread*);\n-extern void _MD_YIELD(void);\n-extern PRStatus _MD_InitializeThread(PRThread* thread);\n-extern void _MD_SET_PRIORITY(struct _MDThread* thread, PRThreadPriority newPri);\n-extern PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                                  PRThreadPriority priority,\n-                                  PRThreadScope scope, PRThreadState state,\n+extern PRStatus _MD_WAIT(struct PRThread *, PRIntervalTime timeout);\n+extern PRStatus _MD_WAKEUP_WAITER(struct PRThread *);\n+extern void     _MD_YIELD(void);\n+extern PRStatus _MD_InitializeThread(PRThread *thread);\n+extern void     _MD_SET_PRIORITY(struct _MDThread *thread,\n+                                 PRThreadPriority newPri);\n+extern PRStatus _MD_CREATE_THREAD(PRThread *thread, void (*start) (void *),\n+                                  PRThreadPriority priority, PRThreadScope scope, PRThreadState state,\n                                   PRUint32 stackSize);\n \n /* The following defines the unwrapped versions of select() and poll(). */\n-extern int _select(int nfds, fd_set* readfds, fd_set* writefds,\n-                   fd_set* exceptfds, struct timeval* timeout);\n-#define _MD_SELECT _select\n+extern int _select(int nfds, fd_set *readfds, fd_set *writefds,\n+                   fd_set *exceptfds, struct timeval *timeout);\n+#define _MD_SELECT  _select\n \n #include <stropts.h>\n #include <poll.h>\n #define _MD_POLL _poll\n-extern int _poll(struct pollfd* fds, unsigned long nfds, int timeout);\n+extern int _poll(struct pollfd *fds, unsigned long nfds, int timeout);\n \n PR_BEGIN_EXTERN_C\n \n /*\n ** Missing function prototypes\n */\n-extern int gethostname(char* name, int namelen);\n+extern int gethostname (char *name, int namelen);\n \n PR_END_EXTERN_C\n \n@@ -506,3 +490,4 @@ PR_END_EXTERN_C\n extern void _MD_solaris_map_sendfile_error(int err);\n \n #endif /* nspr_solaris_defs_h___ */\n+\ndiff --git a/nspr/pr/include/md/_unix_errors.h b/nspr/pr/include/md/_unix_errors.h\nindex fcd2a58..0578fd0 100644\n--- a/nspr/pr/include/md/_unix_errors.h\n+++ b/nspr/pr/include/md/_unix_errors.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,25 +12,25 @@\n PR_BEGIN_EXTERN_C\n \n extern void _MD_unix_map_default_error(int err);\n-#define _PR_MD_MAP_DEFAULT_ERROR _MD_unix_map_default_error\n+#define _PR_MD_MAP_DEFAULT_ERROR    _MD_unix_map_default_error\n \n extern void _MD_unix_map_opendir_error(int err);\n-#define _PR_MD_MAP_OPENDIR_ERROR _MD_unix_map_opendir_error\n+#define _PR_MD_MAP_OPENDIR_ERROR    _MD_unix_map_opendir_error\n \n extern void _MD_unix_map_closedir_error(int err);\n-#define _PR_MD_MAP_CLOSEDIR_ERROR _MD_unix_map_closedir_error\n+#define _PR_MD_MAP_CLOSEDIR_ERROR   _MD_unix_map_closedir_error\n \n extern void _MD_unix_readdir_error(int err);\n-#define _PR_MD_MAP_READDIR_ERROR _MD_unix_readdir_error\n+#define _PR_MD_MAP_READDIR_ERROR    _MD_unix_readdir_error\n \n extern void _MD_unix_map_unlink_error(int err);\n #define _PR_MD_MAP_UNLINK_ERROR _MD_unix_map_unlink_error\n \n extern void _MD_unix_map_stat_error(int err);\n-#define _PR_MD_MAP_STAT_ERROR _MD_unix_map_stat_error\n+#define _PR_MD_MAP_STAT_ERROR   _MD_unix_map_stat_error\n \n extern void _MD_unix_map_fstat_error(int err);\n-#define _PR_MD_MAP_FSTAT_ERROR _MD_unix_map_fstat_error\n+#define _PR_MD_MAP_FSTAT_ERROR  _MD_unix_map_fstat_error\n \n extern void _MD_unix_map_rename_error(int err);\n #define _PR_MD_MAP_RENAME_ERROR _MD_unix_map_rename_error\n@@ -38,40 +39,40 @@ extern void _MD_unix_map_access_error(int err);\n #define _PR_MD_MAP_ACCESS_ERROR _MD_unix_map_access_error\n \n extern void _MD_unix_map_mkdir_error(int err);\n-#define _PR_MD_MAP_MKDIR_ERROR _MD_unix_map_mkdir_error\n+#define _PR_MD_MAP_MKDIR_ERROR  _MD_unix_map_mkdir_error\n \n extern void _MD_unix_map_rmdir_error(int err);\n-#define _PR_MD_MAP_RMDIR_ERROR _MD_unix_map_rmdir_error\n+#define _PR_MD_MAP_RMDIR_ERROR  _MD_unix_map_rmdir_error\n \n extern void _MD_unix_map_read_error(int err);\n-#define _PR_MD_MAP_READ_ERROR _MD_unix_map_read_error\n+#define _PR_MD_MAP_READ_ERROR   _MD_unix_map_read_error\n \n extern void _MD_unix_map_write_error(int err);\n-#define _PR_MD_MAP_WRITE_ERROR _MD_unix_map_write_error\n+#define _PR_MD_MAP_WRITE_ERROR  _MD_unix_map_write_error\n \n extern void _MD_unix_map_lseek_error(int err);\n-#define _PR_MD_MAP_LSEEK_ERROR _MD_unix_map_lseek_error\n+#define _PR_MD_MAP_LSEEK_ERROR  _MD_unix_map_lseek_error\n \n extern void _MD_unix_map_fsync_error(int err);\n-#define _PR_MD_MAP_FSYNC_ERROR _MD_unix_map_fsync_error\n+#define _PR_MD_MAP_FSYNC_ERROR  _MD_unix_map_fsync_error\n \n extern void _MD_unix_map_close_error(int err);\n-#define _PR_MD_MAP_CLOSE_ERROR _MD_unix_map_close_error\n+#define _PR_MD_MAP_CLOSE_ERROR  _MD_unix_map_close_error\n \n extern void _MD_unix_map_socket_error(int err);\n #define _PR_MD_MAP_SOCKET_ERROR _MD_unix_map_socket_error\n \n extern void _MD_unix_map_socketavailable_error(int err);\n-#define _PR_MD_MAP_SOCKETAVAILABLE_ERROR _MD_unix_map_socketavailable_error\n+#define _PR_MD_MAP_SOCKETAVAILABLE_ERROR    _MD_unix_map_socketavailable_error\n \n extern void _MD_unix_map_recv_error(int err);\n-#define _PR_MD_MAP_RECV_ERROR _MD_unix_map_recv_error\n+#define _PR_MD_MAP_RECV_ERROR   _MD_unix_map_recv_error\n \n extern void _MD_unix_map_recvfrom_error(int err);\n-#define _PR_MD_MAP_RECVFROM_ERROR _MD_unix_map_recvfrom_error\n+#define _PR_MD_MAP_RECVFROM_ERROR   _MD_unix_map_recvfrom_error\n \n extern void _MD_unix_map_send_error(int err);\n-#define _PR_MD_MAP_SEND_ERROR _MD_unix_map_send_error\n+#define _PR_MD_MAP_SEND_ERROR   _MD_unix_map_send_error\n \n extern void _MD_unix_map_sendto_error(int err);\n #define _PR_MD_MAP_SENDTO_ERROR _MD_unix_map_sendto_error\n@@ -83,25 +84,25 @@ extern void _MD_unix_map_accept_error(int err);\n #define _PR_MD_MAP_ACCEPT_ERROR _MD_unix_map_accept_error\n \n extern void _MD_unix_map_connect_error(int err);\n-#define _PR_MD_MAP_CONNECT_ERROR _MD_unix_map_connect_error\n+#define _PR_MD_MAP_CONNECT_ERROR    _MD_unix_map_connect_error\n \n extern void _MD_unix_map_bind_error(int err);\n-#define _PR_MD_MAP_BIND_ERROR _MD_unix_map_bind_error\n+#define _PR_MD_MAP_BIND_ERROR   _MD_unix_map_bind_error\n \n extern void _MD_unix_map_listen_error(int err);\n #define _PR_MD_MAP_LISTEN_ERROR _MD_unix_map_listen_error\n \n extern void _MD_unix_map_shutdown_error(int err);\n-#define _PR_MD_MAP_SHUTDOWN_ERROR _MD_unix_map_shutdown_error\n+#define _PR_MD_MAP_SHUTDOWN_ERROR   _MD_unix_map_shutdown_error\n \n extern void _MD_unix_map_socketpair_error(int err);\n #define _PR_MD_MAP_SOCKETPAIR_ERROR _MD_unix_map_socketpair_error\n \n extern void _MD_unix_map_getsockname_error(int err);\n-#define _PR_MD_MAP_GETSOCKNAME_ERROR _MD_unix_map_getsockname_error\n+#define _PR_MD_MAP_GETSOCKNAME_ERROR    _MD_unix_map_getsockname_error\n \n extern void _MD_unix_map_getpeername_error(int err);\n-#define _PR_MD_MAP_GETPEERNAME_ERROR _MD_unix_map_getpeername_error\n+#define _PR_MD_MAP_GETPEERNAME_ERROR    _MD_unix_map_getpeername_error\n \n extern void _MD_unix_map_getsockopt_error(int err);\n #define _PR_MD_MAP_GETSOCKOPT_ERROR _MD_unix_map_getsockopt_error\n@@ -110,13 +111,13 @@ extern void _MD_unix_map_setsockopt_error(int err);\n #define _PR_MD_MAP_SETSOCKOPT_ERROR _MD_unix_map_setsockopt_error\n \n extern void _MD_unix_map_open_error(int err);\n-#define _PR_MD_MAP_OPEN_ERROR _MD_unix_map_open_error\n+#define _PR_MD_MAP_OPEN_ERROR   _MD_unix_map_open_error\n \n extern void _MD_unix_map_mmap_error(int err);\n-#define _PR_MD_MAP_MMAP_ERROR _MD_unix_map_mmap_error\n+#define _PR_MD_MAP_MMAP_ERROR   _MD_unix_map_mmap_error\n \n extern void _MD_unix_map_gethostname_error(int err);\n-#define _PR_MD_MAP_GETHOSTNAME_ERROR _MD_unix_map_gethostname_error\n+#define _PR_MD_MAP_GETHOSTNAME_ERROR    _MD_unix_map_gethostname_error\n \n extern void _MD_unix_map_select_error(int err);\n #define _PR_MD_MAP_SELECT_ERROR _MD_unix_map_select_error\n@@ -128,10 +129,10 @@ extern void _MD_unix_map_poll_revents_error(int err);\n #define _PR_MD_MAP_POLL_REVENTS_ERROR _MD_unix_map_poll_revents_error\n \n extern void _MD_unix_map_flock_error(int err);\n-#define _PR_MD_MAP_FLOCK_ERROR _MD_unix_map_flock_error\n+#define _PR_MD_MAP_FLOCK_ERROR  _MD_unix_map_flock_error\n \n extern void _MD_unix_map_lockf_error(int err);\n-#define _PR_MD_MAP_LOCKF_ERROR _MD_unix_map_lockf_error\n+#define _PR_MD_MAP_LOCKF_ERROR  _MD_unix_map_lockf_error\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/md/_unixos.h b/nspr/pr/include/md/_unixos.h\nindex 889fddf..7d444cd 100644\n--- a/nspr/pr/include/md/_unixos.h\n+++ b/nspr/pr/include/md/_unixos.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -13,10 +14,10 @@\n  * Linux: FD_SETSIZE is defined in /usr/include/sys/select.h and should\n  * not be redefined.\n  */\n-#if !defined(LINUX) && !defined(__GNU__) && !defined(__GLIBC__) && \\\n-    !defined(DARWIN)\n+#if !defined(LINUX) && !defined(__GNU__) && !defined(__GLIBC__) \\\n+    && !defined(DARWIN)\n #ifndef FD_SETSIZE\n-#define FD_SETSIZE 4096\n+#define FD_SETSIZE  4096\n #endif\n #endif\n \n@@ -53,10 +54,10 @@\n \n #define _PR_HAVE_O_APPEND\n \n-#define PR_DIRECTORY_SEPARATOR '/'\n-#define PR_DIRECTORY_SEPARATOR_STR \"/\"\n-#define PR_PATH_SEPARATOR ':'\n-#define PR_PATH_SEPARATOR_STR \":\"\n+#define PR_DIRECTORY_SEPARATOR      '/'\n+#define PR_DIRECTORY_SEPARATOR_STR  \"/\"\n+#define PR_PATH_SEPARATOR       ':'\n+#define PR_PATH_SEPARATOR_STR       \":\"\n typedef int (*FARPROC)();\n \n /*\n@@ -70,19 +71,19 @@ extern PRIntervalTime intr_timeout_ticks;\n  * of _PR_UnixPollDesc\n  */\n #ifdef _PR_USE_POLL\n-#define _PR_UNIX_POLL_READ POLLIN\n-#define _PR_UNIX_POLL_WRITE POLLOUT\n-#define _PR_UNIX_POLL_EXCEPT POLLPRI\n-#define _PR_UNIX_POLL_ERR POLLERR\n-#define _PR_UNIX_POLL_NVAL POLLNVAL\n-#define _PR_UNIX_POLL_HUP POLLHUP\n+#define _PR_UNIX_POLL_READ    POLLIN\n+#define _PR_UNIX_POLL_WRITE   POLLOUT\n+#define _PR_UNIX_POLL_EXCEPT  POLLPRI\n+#define _PR_UNIX_POLL_ERR     POLLERR\n+#define _PR_UNIX_POLL_NVAL    POLLNVAL\n+#define _PR_UNIX_POLL_HUP     POLLHUP\n #else /* _PR_USE_POLL */\n-#define _PR_UNIX_POLL_READ 0x1\n-#define _PR_UNIX_POLL_WRITE 0x2\n-#define _PR_UNIX_POLL_EXCEPT 0x4\n-#define _PR_UNIX_POLL_ERR 0x8\n-#define _PR_UNIX_POLL_NVAL 0x10\n-#define _PR_UNIX_POLL_HUP 0x20\n+#define _PR_UNIX_POLL_READ    0x1\n+#define _PR_UNIX_POLL_WRITE   0x2\n+#define _PR_UNIX_POLL_EXCEPT  0x4\n+#define _PR_UNIX_POLL_ERR     0x8\n+#define _PR_UNIX_POLL_NVAL    0x10\n+#define _PR_UNIX_POLL_HUP     0x20\n #endif /* _PR_USE_POLL */\n \n typedef struct _PRUnixPollDesc {\n@@ -92,20 +93,23 @@ typedef struct _PRUnixPollDesc {\n } _PRUnixPollDesc;\n \n typedef struct PRPollQueue {\n-    PRCList links;          /* for linking PRPollQueue's together */\n-    _PRUnixPollDesc* pds;   /* array of poll descriptors */\n-    PRUintn npds;           /* length of the array */\n+    PRCList links;        /* for linking PRPollQueue's together */\n+    _PRUnixPollDesc *pds;        /* array of poll descriptors */\n+    PRUintn npds;            /* length of the array */\n     PRPackedBool on_ioq;    /* is this on the async i/o work q? */\n-    PRIntervalTime timeout; /* timeout, in ticks */\n-    struct PRThread* thr;\n+    PRIntervalTime timeout;        /* timeout, in ticks */\n+    struct PRThread *thr;\n } PRPollQueue;\n \n #define _PR_POLLQUEUE_PTR(_qp) \\\n-    ((PRPollQueue*)((char*)(_qp) - offsetof(PRPollQueue, links)))\n+    ((PRPollQueue*) ((char*) (_qp) - offsetof(PRPollQueue,links)))\n \n-extern PRInt32 _PR_WaitForMultipleFDs(_PRUnixPollDesc* unixpds, PRInt32 pdcnt,\n-                                      PRIntervalTime timeout);\n-extern void _PR_Unblock_IO_Wait(struct PRThread* thr);\n+\n+extern PRInt32 _PR_WaitForMultipleFDs(\n+    _PRUnixPollDesc *unixpds,\n+    PRInt32 pdcnt,\n+    PRIntervalTime timeout);\n+extern void _PR_Unblock_IO_Wait(struct PRThread *thr);\n \n #if defined(_PR_LOCAL_THREADS_ONLY) || defined(_PR_GLOBAL_THREADS_ONLY)\n #define _MD_CHECK_FOR_EXIT()\n@@ -119,16 +123,16 @@ extern PRUint32 _pr_md_ioq_timeout;\n struct _MDFileDesc {\n     int osfd;\n #if defined(LINUX) && defined(_PR_PTHREADS)\n-    int tcp_nodelay; /* used by pt_LinuxSendFile */\n+    int tcp_nodelay;  /* used by pt_LinuxSendFile */\n #endif\n };\n \n struct _MDDir {\n-    DIR* d;\n+    DIR *d;\n };\n \n struct _PRCPU;\n-extern void _MD_unix_init_running_cpu(struct _PRCPU* cpu);\n+extern void _MD_unix_init_running_cpu(struct _PRCPU *cpu);\n \n /*\n ** Make a redzone at both ends of the stack segment. Disallow access\n@@ -143,49 +147,49 @@ extern void _MD_unix_init_running_cpu(struct _PRCPU* cpu);\n \n #if defined(DEBUG) && !defined(DARWIN)\n #if !defined(SOLARIS)\n-#include <string.h> /* for memset() */\n-#define _MD_INIT_STACK(ts, REDZONE)                                          \\\n-    PR_BEGIN_MACRO(void)                                                     \\\n-    mprotect((void*)ts->seg->vaddr, REDZONE, PROT_NONE);                     \\\n-    (void)mprotect((void*)((char*)ts->seg->vaddr + REDZONE + ts->stackSize), \\\n-                   REDZONE, PROT_NONE);                                      \\\n-    /*                                                                       \\\n-    ** Fill stack memory with something that turns into an illegal           \\\n-    ** pointer value. This will sometimes find runtime references to         \\\n-    ** uninitialized pointers. We don't do this for solaris because we       \\\n-    ** can use purify instead.                                               \\\n-    */                                                                       \\\n-    if (_pr_debugStacks) {                                                   \\\n-        memset(ts->allocBase + REDZONE, 0xf7, ts->stackSize);                \\\n-    }                                                                        \\\n+#include <string.h>  /* for memset() */\n+#define _MD_INIT_STACK(ts,REDZONE)                  \\\n+    PR_BEGIN_MACRO                                  \\\n+    (void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_NONE); \\\n+    (void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\\\n+            REDZONE, PROT_NONE);                \\\n+    /*                                  \\\n+    ** Fill stack memory with something that turns into an illegal  \\\n+    ** pointer value. This will sometimes find runtime references to    \\\n+    ** uninitialized pointers. We don't do this for solaris because we  \\\n+    ** can use purify instead.                      \\\n+    */                                  \\\n+    if (_pr_debugStacks) {                      \\\n+    memset(ts->allocBase + REDZONE, 0xf7, ts->stackSize);       \\\n+    }                                   \\\n     PR_END_MACRO\n-#else /* !SOLARIS */\n-#define _MD_INIT_STACK(ts, REDZONE)                                          \\\n-    PR_BEGIN_MACRO(void)                                                     \\\n-    mprotect((void*)ts->seg->vaddr, REDZONE, PROT_NONE);                     \\\n-    (void)mprotect((void*)((char*)ts->seg->vaddr + REDZONE + ts->stackSize), \\\n-                   REDZONE, PROT_NONE);                                      \\\n+#else   /* !SOLARIS */\n+#define _MD_INIT_STACK(ts,REDZONE)                  \\\n+    PR_BEGIN_MACRO                                  \\\n+    (void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_NONE); \\\n+    (void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\\\n+            REDZONE, PROT_NONE);                \\\n     PR_END_MACRO\n-#endif /* !SOLARIS */\n+#endif  /* !SOLARIS */\n \n /*\n  * _MD_CLEAR_STACK\n  *  Allow access to the redzone pages; the access was turned off in\n  *  _MD_INIT_STACK.\n  */\n-#define _MD_CLEAR_STACK(ts)                                                  \\\n-    PR_BEGIN_MACRO(void)                                                     \\\n-    mprotect((void*)ts->seg->vaddr, REDZONE, PROT_READ | PROT_WRITE);        \\\n-    (void)mprotect((void*)((char*)ts->seg->vaddr + REDZONE + ts->stackSize), \\\n-                   REDZONE, PROT_READ | PROT_WRITE);                         \\\n+#define _MD_CLEAR_STACK(ts)                     \\\n+    PR_BEGIN_MACRO                                  \\\n+    (void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_READ|PROT_WRITE);\\\n+    (void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\\\n+            REDZONE, PROT_READ|PROT_WRITE);         \\\n     PR_END_MACRO\n \n-#else /* DEBUG */\n+#else   /* DEBUG */\n \n-#define _MD_INIT_STACK(ts, REDZONE)\n+#define _MD_INIT_STACK(ts,REDZONE)\n #define _MD_CLEAR_STACK(ts)\n \n-#endif /* DEBUG */\n+#endif  /* DEBUG */\n \n #if !defined(SOLARIS)\n \n@@ -211,91 +215,95 @@ struct PRProcessAttr;\n \n /* Create a new process (fork() + exec()) */\n #define _MD_CREATE_PROCESS _MD_CreateUnixProcess\n-extern struct PRProcess* _MD_CreateUnixProcess(\n-    const char* path, char* const* argv, char* const* envp,\n-    const struct PRProcessAttr* attr);\n+extern struct PRProcess * _MD_CreateUnixProcess(\n+    const char *path,\n+    char *const *argv,\n+    char *const *envp,\n+    const struct PRProcessAttr *attr\n+);\n \n #define _MD_DETACH_PROCESS _MD_DetachUnixProcess\n-extern PRStatus _MD_DetachUnixProcess(struct PRProcess* process);\n+extern PRStatus _MD_DetachUnixProcess(struct PRProcess *process);\n \n /* Wait for a child process to terminate */\n #define _MD_WAIT_PROCESS _MD_WaitUnixProcess\n-extern PRStatus _MD_WaitUnixProcess(struct PRProcess* process,\n-                                    PRInt32* exitCode);\n+extern PRStatus _MD_WaitUnixProcess(struct PRProcess *process,\n+                                    PRInt32 *exitCode);\n \n #define _MD_KILL_PROCESS _MD_KillUnixProcess\n-extern PRStatus _MD_KillUnixProcess(struct PRProcess* process);\n+extern PRStatus _MD_KillUnixProcess(struct PRProcess *process);\n \n /************************************************************************/\n \n extern void _MD_EnableClockInterrupts(void);\n extern void _MD_DisableClockInterrupts(void);\n \n-#define _MD_START_INTERRUPTS _MD_StartInterrupts\n-#define _MD_STOP_INTERRUPTS _MD_StopInterrupts\n-#define _MD_DISABLE_CLOCK_INTERRUPTS _MD_DisableClockInterrupts\n-#define _MD_ENABLE_CLOCK_INTERRUPTS _MD_EnableClockInterrupts\n-#define _MD_BLOCK_CLOCK_INTERRUPTS _MD_BlockClockInterrupts\n-#define _MD_UNBLOCK_CLOCK_INTERRUPTS _MD_UnblockClockInterrupts\n+#define _MD_START_INTERRUPTS            _MD_StartInterrupts\n+#define _MD_STOP_INTERRUPTS             _MD_StopInterrupts\n+#define _MD_DISABLE_CLOCK_INTERRUPTS    _MD_DisableClockInterrupts\n+#define _MD_ENABLE_CLOCK_INTERRUPTS     _MD_EnableClockInterrupts\n+#define _MD_BLOCK_CLOCK_INTERRUPTS      _MD_BlockClockInterrupts\n+#define _MD_UNBLOCK_CLOCK_INTERRUPTS    _MD_UnblockClockInterrupts\n \n /************************************************************************/\n \n-extern void _MD_InitCPUS(void);\n-#define _MD_INIT_CPUS _MD_InitCPUS\n+extern void     _MD_InitCPUS(void);\n+#define _MD_INIT_CPUS           _MD_InitCPUS\n \n-extern void _MD_Wakeup_CPUs(void);\n+extern void     _MD_Wakeup_CPUs(void);\n #define _MD_WAKEUP_CPUS _MD_Wakeup_CPUs\n \n-#define _MD_PAUSE_CPU _MD_PauseCPU\n+#define _MD_PAUSE_CPU           _MD_PauseCPU\n \n #if defined(_PR_LOCAL_THREADS_ONLY) || defined(_PR_GLOBAL_THREADS_ONLY)\n #define _MD_CLEANUP_BEFORE_EXIT()\n #endif\n \n-#define _MD_EXIT(status) _exit(status)\n+#define _MD_EXIT(status)        _exit(status)\n \n /************************************************************************/\n \n-#define _MD_GET_ENV getenv\n-#define _MD_PUT_ENV putenv\n+#define _MD_GET_ENV             getenv\n+#define _MD_PUT_ENV             putenv\n \n /************************************************************************/\n \n #define _MD_INIT_FILEDESC(fd)\n \n-extern void _MD_MakeNonblock(PRFileDesc* fd);\n-#define _MD_MAKE_NONBLOCK _MD_MakeNonblock\n+extern void     _MD_MakeNonblock(PRFileDesc *fd);\n+#define _MD_MAKE_NONBLOCK           _MD_MakeNonblock\n \n /************************************************************************/\n \n #if !defined(_PR_PTHREADS)\n \n-extern void _MD_InitSegs(void);\n-extern PRStatus _MD_AllocSegment(PRSegment* seg, PRUint32 size, void* vaddr);\n-extern void _MD_FreeSegment(PRSegment* seg);\n+extern void     _MD_InitSegs(void);\n+extern PRStatus _MD_AllocSegment(PRSegment *seg, PRUint32 size,\n+                                 void *vaddr);\n+extern void     _MD_FreeSegment(PRSegment *seg);\n \n-#define _MD_INIT_SEGS _MD_InitSegs\n-#define _MD_ALLOC_SEGMENT _MD_AllocSegment\n-#define _MD_FREE_SEGMENT _MD_FreeSegment\n+#define _MD_INIT_SEGS           _MD_InitSegs\n+#define _MD_ALLOC_SEGMENT       _MD_AllocSegment\n+#define _MD_FREE_SEGMENT        _MD_FreeSegment\n \n #endif /* !defined(_PR_PTHREADS) */\n \n /************************************************************************/\n \n #ifdef _MD_INTERVAL_USE_GTOD\n-extern PRIntervalTime _PR_UNIX_GetInterval(void);\n-extern PRIntervalTime _PR_UNIX_TicksPerSecond(void);\n+extern PRIntervalTime   _PR_UNIX_GetInterval(void);\n+extern PRIntervalTime   _PR_UNIX_TicksPerSecond(void);\n #define _MD_INTERVAL_INIT()\n-#define _MD_GET_INTERVAL _PR_UNIX_GetInterval\n-#define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond\n+#define _MD_GET_INTERVAL        _PR_UNIX_GetInterval\n+#define _MD_INTERVAL_PER_SEC        _PR_UNIX_TicksPerSecond\n #endif\n \n #ifdef _PR_HAVE_CLOCK_MONOTONIC\n-extern PRIntervalTime _PR_UNIX_GetInterval2(void);\n-extern PRIntervalTime _PR_UNIX_TicksPerSecond2(void);\n+extern PRIntervalTime   _PR_UNIX_GetInterval2(void);\n+extern PRIntervalTime   _PR_UNIX_TicksPerSecond2(void);\n #define _MD_INTERVAL_INIT()\n-#define _MD_GET_INTERVAL _PR_UNIX_GetInterval2\n-#define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond2\n+#define _MD_GET_INTERVAL        _PR_UNIX_GetInterval2\n+#define _MD_INTERVAL_PER_SEC        _PR_UNIX_TicksPerSecond2\n #endif\n \n #define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000)\n@@ -303,8 +311,8 @@ extern PRIntervalTime _PR_UNIX_TicksPerSecond2(void);\n \n /************************************************************************/\n \n-#define _MD_ERRNO() (errno)\n-#define _MD_GET_SOCKET_ERROR() (errno)\n+#define _MD_ERRNO()                 (errno)\n+#define _MD_GET_SOCKET_ERROR()      (errno)\n \n /************************************************************************/\n \n@@ -317,146 +325,144 @@ extern void _MD_BlockClockInterrupts(void);\n extern void _MD_UnblockClockInterrupts(void);\n extern void _MD_PauseCPU(PRIntervalTime timeout);\n \n-extern PRStatus _MD_open_dir(struct _MDDir*, const char*);\n-extern PRInt32 _MD_close_dir(struct _MDDir*);\n-extern char* _MD_read_dir(struct _MDDir*, PRIntn);\n-extern PRInt32 _MD_open(const char* name, PRIntn osflags, PRIntn mode);\n-extern PRInt32 _MD_delete(const char* name);\n-extern PRInt32 _MD_getfileinfo(const char* fn, PRFileInfo* info);\n-extern PRInt32 _MD_getfileinfo64(const char* fn, PRFileInfo64* info);\n-extern PRInt32 _MD_getopenfileinfo(const PRFileDesc* fd, PRFileInfo* info);\n-extern PRInt32 _MD_getopenfileinfo64(const PRFileDesc* fd, PRFileInfo64* info);\n-extern PRInt32 _MD_rename(const char* from, const char* to);\n-extern PRInt32 _MD_access(const char* name, PRAccessHow how);\n-extern PRInt32 _MD_mkdir(const char* name, PRIntn mode);\n-extern PRInt32 _MD_rmdir(const char* name);\n-extern PRInt32 _MD_accept_read(PRInt32 sock, PRInt32* newSock,\n-                               PRNetAddr** raddr, void* buf, PRInt32 amount);\n-extern PRInt32 _PR_UnixSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n-                                PRTransmitFileFlags flags,\n-                                PRIntervalTime timeout);\n+extern PRStatus _MD_open_dir(struct _MDDir *, const char *);\n+extern PRInt32  _MD_close_dir(struct _MDDir *);\n+extern char *   _MD_read_dir(struct _MDDir *, PRIntn);\n+extern PRInt32  _MD_open(const char *name, PRIntn osflags, PRIntn mode);\n+extern PRInt32  _MD_delete(const char *name);\n+extern PRInt32  _MD_getfileinfo(const char *fn, PRFileInfo *info);\n+extern PRInt32  _MD_getfileinfo64(const char *fn, PRFileInfo64 *info);\n+extern PRInt32  _MD_getopenfileinfo(const PRFileDesc *fd, PRFileInfo *info);\n+extern PRInt32  _MD_getopenfileinfo64(const PRFileDesc *fd, PRFileInfo64 *info);\n+extern PRInt32  _MD_rename(const char *from, const char *to);\n+extern PRInt32  _MD_access(const char *name, PRAccessHow how);\n+extern PRInt32  _MD_mkdir(const char *name, PRIntn mode);\n+extern PRInt32  _MD_rmdir(const char *name);\n+extern PRInt32  _MD_accept_read(PRInt32 sock, PRInt32 *newSock,\n+                                PRNetAddr **raddr, void *buf, PRInt32 amount);\n+extern PRInt32  _PR_UnixSendFile(PRFileDesc *sd, PRSendFileData *sfd,\n+                                 PRTransmitFileFlags flags, PRIntervalTime timeout);\n \n extern PRStatus _MD_LockFile(PRInt32 osfd);\n extern PRStatus _MD_TLockFile(PRInt32 osfd);\n extern PRStatus _MD_UnlockFile(PRInt32 osfd);\n \n-#define _MD_OPEN_DIR(dir, name) _MD_open_dir(dir, name)\n-#define _MD_CLOSE_DIR(dir) _MD_close_dir(dir)\n-#define _MD_READ_DIR(dir, flags) _MD_read_dir(dir, flags)\n-#define _MD_OPEN(name, osflags, mode) _MD_open(name, osflags, mode)\n-#define _MD_OPEN_FILE(name, osflags, mode) _MD_open(name, osflags, mode)\n-extern PRInt32 _MD_read(PRFileDesc* fd, void* buf, PRInt32 amount);\n-#define _MD_READ(fd, buf, amount) _MD_read(fd, buf, amount)\n-extern PRInt32 _MD_write(PRFileDesc* fd, const void* buf, PRInt32 amount);\n-#define _MD_WRITE(fd, buf, amount) _MD_write(fd, buf, amount)\n-#define _MD_DELETE(name) _MD_delete(name)\n-#define _MD_GETFILEINFO(fn, info) _MD_getfileinfo(fn, info)\n-#define _MD_GETFILEINFO64(fn, info) _MD_getfileinfo64(fn, info)\n-#define _MD_GETOPENFILEINFO(fd, info) _MD_getopenfileinfo(fd, info)\n+#define _MD_OPEN_DIR(dir, name)         _MD_open_dir(dir, name)\n+#define _MD_CLOSE_DIR(dir)              _MD_close_dir(dir)\n+#define _MD_READ_DIR(dir, flags)        _MD_read_dir(dir, flags)\n+#define _MD_OPEN(name, osflags, mode)   _MD_open(name, osflags, mode)\n+#define _MD_OPEN_FILE(name, osflags, mode)  _MD_open(name, osflags, mode)\n+extern PRInt32 _MD_read(PRFileDesc *fd, void *buf, PRInt32 amount);\n+#define _MD_READ(fd,buf,amount)         _MD_read(fd,buf,amount)\n+extern PRInt32 _MD_write(PRFileDesc *fd, const void *buf, PRInt32 amount);\n+#define _MD_WRITE(fd,buf,amount)        _MD_write(fd,buf,amount)\n+#define _MD_DELETE(name)                _MD_delete(name)\n+#define _MD_GETFILEINFO(fn, info)       _MD_getfileinfo(fn, info)\n+#define _MD_GETFILEINFO64(fn, info)     _MD_getfileinfo64(fn, info)\n+#define _MD_GETOPENFILEINFO(fd, info)   _MD_getopenfileinfo(fd, info)\n #define _MD_GETOPENFILEINFO64(fd, info) _MD_getopenfileinfo64(fd, info)\n-#define _MD_RENAME(from, to) _MD_rename(from, to)\n-#define _MD_ACCESS(name, how) _MD_access(name, how)\n-#define _MD_MKDIR(name, mode) _MD_mkdir(name, mode)\n-#define _MD_MAKE_DIR(name, mode) _MD_mkdir(name, mode)\n-#define _MD_RMDIR(name) _MD_rmdir(name)\n-#define _MD_ACCEPT_READ(sock, newSock, raddr, buf, amount) \\\n-    _MD_accept_read(sock, newSock, raddr, buf, amount)\n+#define _MD_RENAME(from, to)            _MD_rename(from, to)\n+#define _MD_ACCESS(name, how)           _MD_access(name, how)\n+#define _MD_MKDIR(name, mode)           _MD_mkdir(name, mode)\n+#define _MD_MAKE_DIR(name, mode)        _MD_mkdir(name, mode)\n+#define _MD_RMDIR(name)                 _MD_rmdir(name)\n+#define _MD_ACCEPT_READ(sock, newSock, raddr, buf, amount)  _MD_accept_read(sock, newSock, raddr, buf, amount)\n \n #define _MD_LOCKFILE _MD_LockFile\n #define _MD_TLOCKFILE _MD_TLockFile\n #define _MD_UNLOCKFILE _MD_UnlockFile\n \n-extern PRInt32 _MD_socket(int af, int type, int flags);\n-#define _MD_SOCKET _MD_socket\n-extern PRInt32 _MD_connect(PRFileDesc* fd, const PRNetAddr* addr,\n-                           PRUint32 addrlen, PRIntervalTime timeout);\n+\n+extern PRInt32      _MD_socket(int af, int type, int flags);\n+#define _MD_SOCKET  _MD_socket\n+extern PRInt32      _MD_connect(PRFileDesc *fd, const PRNetAddr *addr,\n+                                PRUint32 addrlen, PRIntervalTime timeout);\n #define _MD_CONNECT _MD_connect\n-extern PRInt32 _MD_accept(PRFileDesc* fd, PRNetAddr* addr, PRUint32* addrlen,\n-                          PRIntervalTime timeout);\n-#define _MD_ACCEPT _MD_accept\n-extern PRInt32 _MD_bind(PRFileDesc* fd, const PRNetAddr* addr,\n-                        PRUint32 addrlen);\n-#define _MD_BIND _MD_bind\n-extern PRInt32 _MD_listen(PRFileDesc* fd, PRIntn backlog);\n-#define _MD_LISTEN _MD_listen\n-extern PRInt32 _MD_shutdown(PRFileDesc* fd, PRIntn how);\n-#define _MD_SHUTDOWN _MD_shutdown\n-\n-extern PRInt32 _MD_recv(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n-                        PRIntervalTime timeout);\n-#define _MD_RECV _MD_recv\n-extern PRInt32 _MD_send(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-                        PRIntn flags, PRIntervalTime timeout);\n-#define _MD_SEND _MD_send\n-extern PRInt32 _MD_recvfrom(PRFileDesc* fd, void* buf, PRInt32 amount,\n-                            PRIntn flags, PRNetAddr* addr, PRUint32* addrlen,\n-                            PRIntervalTime timeout);\n-#define _MD_RECVFROM _MD_recvfrom\n-extern PRInt32 _MD_sendto(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-                          PRIntn flags, const PRNetAddr* addr, PRUint32 addrlen,\n+extern PRInt32      _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen,\n+                               PRIntervalTime timeout);\n+#define _MD_ACCEPT  _MD_accept\n+extern PRInt32      _MD_bind(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen);\n+#define _MD_BIND    _MD_bind\n+extern PRInt32      _MD_listen(PRFileDesc *fd, PRIntn backlog);\n+#define _MD_LISTEN  _MD_listen\n+extern PRInt32      _MD_shutdown(PRFileDesc *fd, PRIntn how);\n+#define _MD_SHUTDOWN    _MD_shutdown\n+\n+extern PRInt32      _MD_recv(PRFileDesc *fd, void *buf, PRInt32 amount,\n+                             PRIntn flags, PRIntervalTime timeout);\n+#define _MD_RECV    _MD_recv\n+extern PRInt32      _MD_send(PRFileDesc *fd, const void *buf, PRInt32 amount,\n+                             PRIntn flags, PRIntervalTime timeout);\n+#define _MD_SEND    _MD_send\n+extern PRInt32      _MD_recvfrom(PRFileDesc *fd, void *buf, PRInt32 amount,\n+                                 PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen,\n+                                 PRIntervalTime timeout);\n+#define _MD_RECVFROM    _MD_recvfrom\n+extern PRInt32 _MD_sendto(PRFileDesc *fd, const void *buf, PRInt32 amount,\n+                          PRIntn flags, const PRNetAddr *addr, PRUint32 addrlen,\n                           PRIntervalTime timeout);\n-#define _MD_SENDTO _MD_sendto\n-extern PRInt32 _MD_writev(PRFileDesc* fd, const struct PRIOVec* iov,\n-                          PRInt32 iov_size, PRIntervalTime timeout);\n-#define _MD_WRITEV _MD_writev\n+#define _MD_SENDTO  _MD_sendto\n+extern PRInt32      _MD_writev(PRFileDesc *fd, const struct PRIOVec *iov,\n+                               PRInt32 iov_size, PRIntervalTime timeout);\n+#define _MD_WRITEV  _MD_writev\n \n-extern PRInt32 _MD_socketavailable(PRFileDesc* fd);\n-#define _MD_SOCKETAVAILABLE _MD_socketavailable\n-extern PRInt64 _MD_socketavailable64(PRFileDesc* fd);\n-#define _MD_SOCKETAVAILABLE64 _MD_socketavailable64\n+extern PRInt32      _MD_socketavailable(PRFileDesc *fd);\n+#define _MD_SOCKETAVAILABLE     _MD_socketavailable\n+extern PRInt64      _MD_socketavailable64(PRFileDesc *fd);\n+#define _MD_SOCKETAVAILABLE64       _MD_socketavailable64\n \n-#define _MD_PIPEAVAILABLE _MD_socketavailable\n+#define _MD_PIPEAVAILABLE       _MD_socketavailable\n \n-extern PRInt32 _MD_pr_poll(PRPollDesc* pds, PRIntn npds,\n+extern PRInt32 _MD_pr_poll(PRPollDesc *pds, PRIntn npds,\n                            PRIntervalTime timeout);\n-#define _MD_PR_POLL _MD_pr_poll\n+#define _MD_PR_POLL     _MD_pr_poll\n \n-extern PRInt32 _MD_close(PRInt32 osfd);\n-#define _MD_CLOSE_FILE _MD_close\n-extern PRInt32 _MD_lseek(PRFileDesc*, PRInt32, PRSeekWhence);\n-#define _MD_LSEEK _MD_lseek\n-extern PRInt64 _MD_lseek64(PRFileDesc*, PRInt64, PRSeekWhence);\n+extern PRInt32      _MD_close(PRInt32 osfd);\n+#define _MD_CLOSE_FILE  _MD_close\n+extern PRInt32      _MD_lseek(PRFileDesc*, PRInt32, PRSeekWhence);\n+#define _MD_LSEEK   _MD_lseek\n+extern PRInt64      _MD_lseek64(PRFileDesc*, PRInt64, PRSeekWhence);\n #define _MD_LSEEK64 _MD_lseek64\n-extern PRInt32 _MD_fsync(PRFileDesc* fd);\n-#define _MD_FSYNC _MD_fsync\n+extern PRInt32      _MD_fsync(PRFileDesc *fd);\n+#define _MD_FSYNC   _MD_fsync\n \n-extern PRInt32 _MD_socketpair(int af, int type, int flags, PRInt32* osfd);\n-#define _MD_SOCKETPAIR _MD_socketpair\n+extern PRInt32 _MD_socketpair(int af, int type, int flags, PRInt32 *osfd);\n+#define _MD_SOCKETPAIR      _MD_socketpair\n \n-#define _MD_CLOSE_SOCKET _MD_close\n+#define _MD_CLOSE_SOCKET    _MD_close\n \n #ifndef NO_NSPR_10_SUPPORT\n-#define _MD_STAT stat\n+#define _MD_STAT    stat\n #endif\n \n-extern PRStatus _MD_getpeername(PRFileDesc* fd, PRNetAddr* addr,\n-                                PRUint32* addrlen);\n+extern PRStatus _MD_getpeername(PRFileDesc *fd, PRNetAddr *addr,\n+                                PRUint32 *addrlen);\n #define _MD_GETPEERNAME _MD_getpeername\n-extern PRStatus _MD_getsockname(PRFileDesc* fd, PRNetAddr* addr,\n-                                PRUint32* addrlen);\n+extern PRStatus _MD_getsockname(PRFileDesc *fd, PRNetAddr *addr,\n+                                PRUint32 *addrlen);\n #define _MD_GETSOCKNAME _MD_getsockname\n \n-extern PRStatus _MD_getsockopt(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n-                               char* optval, PRInt32* optlen);\n-#define _MD_GETSOCKOPT _MD_getsockopt\n-extern PRStatus _MD_setsockopt(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n-                               const char* optval, PRInt32 optlen);\n-#define _MD_SETSOCKOPT _MD_setsockopt\n+extern PRStatus _MD_getsockopt(PRFileDesc *fd, PRInt32 level,\n+                               PRInt32 optname, char* optval, PRInt32* optlen);\n+#define _MD_GETSOCKOPT      _MD_getsockopt\n+extern PRStatus _MD_setsockopt(PRFileDesc *fd, PRInt32 level,\n+                               PRInt32 optname, const char* optval, PRInt32 optlen);\n+#define _MD_SETSOCKOPT      _MD_setsockopt\n \n-extern PRStatus _MD_set_fd_inheritable(PRFileDesc* fd, PRBool inheritable);\n+extern PRStatus _MD_set_fd_inheritable(PRFileDesc *fd, PRBool inheritable);\n #define _MD_SET_FD_INHERITABLE _MD_set_fd_inheritable\n \n-extern void _MD_init_fd_inheritable(PRFileDesc* fd, PRBool imported);\n+extern void _MD_init_fd_inheritable(PRFileDesc *fd, PRBool imported);\n #define _MD_INIT_FD_INHERITABLE _MD_init_fd_inheritable\n \n-extern void _MD_query_fd_inheritable(PRFileDesc* fd);\n+extern void _MD_query_fd_inheritable(PRFileDesc *fd);\n #define _MD_QUERY_FD_INHERITABLE _MD_query_fd_inheritable\n \n-extern PRStatus _MD_gethostname(char* name, PRUint32 namelen);\n-#define _MD_GETHOSTNAME _MD_gethostname\n+extern PRStatus _MD_gethostname(char *name, PRUint32 namelen);\n+#define _MD_GETHOSTNAME     _MD_gethostname\n \n-extern PRStatus _MD_getsysinfo(PRSysInfo cmd, char* name, PRUint32 namelen);\n-#define _MD_GETSYSINFO _MD_getsysinfo\n+extern PRStatus _MD_getsysinfo(PRSysInfo cmd, char *name, PRUint32 namelen);\n+#define _MD_GETSYSINFO      _MD_getsysinfo\n \n extern int _MD_unix_get_nonblocking_connect_error(int osfd);\n \n@@ -468,21 +474,25 @@ struct _MDFileMap {\n     PRBool isAnonFM; /* when true, PR_CloseFileMap() must close the related fd */\n };\n \n-extern PRStatus _MD_CreateFileMap(struct PRFileMap* fmap, PRInt64 size);\n+extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);\n #define _MD_CREATE_FILE_MAP _MD_CreateFileMap\n \n #define _MD_GET_MEM_MAP_ALIGNMENT() PR_GetPageSize()\n \n-extern void* _MD_MemMap(struct PRFileMap* fmap, PRInt64 offset, PRUint32 len);\n+extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,\n+                         PRUint32 len);\n #define _MD_MEM_MAP _MD_MemMap\n \n-extern PRStatus _MD_MemUnmap(void* addr, PRUint32 size);\n+extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);\n #define _MD_MEM_UNMAP _MD_MemUnmap\n \n-extern PRStatus _MD_CloseFileMap(struct PRFileMap* fmap);\n+extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);\n #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap\n \n-extern PRStatus _MD_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len);\n+extern PRStatus _MD_SyncMemMap(\n+    PRFileDesc *fd,\n+    void *addr,\n+    PRUint32 len);\n #define _MD_SYNC_MEM_MAP _MD_SyncMemMap\n \n /*\n@@ -517,21 +527,21 @@ struct pollfd {\n \n /* poll events */\n \n-#define POLLIN 0x0001     /* fd is readable */\n-#define POLLPRI 0x0002    /* high priority info at fd */\n-#define POLLOUT 0x0004    /* fd is writeable (won't block) */\n-#define POLLRDNORM 0x0040 /* normal data is readable */\n-#define POLLWRNORM POLLOUT\n-#define POLLRDBAND 0x0080 /* out-of-band data is readable */\n-#define POLLWRBAND 0x0100 /* out-of-band data is writeable */\n+#define POLLIN      0x0001      /* fd is readable */\n+#define POLLPRI     0x0002      /* high priority info at fd */\n+#define POLLOUT     0x0004      /* fd is writeable (won't block) */\n+#define POLLRDNORM  0x0040      /* normal data is readable */\n+#define POLLWRNORM  POLLOUT\n+#define POLLRDBAND  0x0080      /* out-of-band data is readable */\n+#define POLLWRBAND  0x0100      /* out-of-band data is writeable */\n \n-#define POLLNORM POLLRDNORM\n+#define POLLNORM    POLLRDNORM\n \n-#define POLLERR 0x0008  /* fd has error condition */\n-#define POLLHUP 0x0010  /* fd has been hung up on */\n-#define POLLNVAL 0x0020 /* invalid pollfd entry */\n+#define POLLERR     0x0008      /* fd has error condition */\n+#define POLLHUP     0x0010      /* fd has been hung up on */\n+#define POLLNVAL    0x0020      /* invalid pollfd entry */\n \n-extern int poll(struct pollfd*, unsigned long, int);\n+extern int poll(struct pollfd *, unsigned long, int);\n \n #endif /* _PR_NEED_FAKE_POLL */\n \n@@ -590,13 +600,15 @@ typedef PRInt64 _MDOff64_t;\n #error \"I don't know yet\"\n #endif\n \n-typedef PRIntn (*_MD_Fstat64)(PRIntn osfd, _MDStat64* buf);\n-typedef PRIntn (*_MD_Open64)(const char* path, int oflag, ...);\n-typedef PRIntn (*_MD_Stat64)(const char* path, _MDStat64* buf);\n+typedef PRIntn (*_MD_Fstat64)(PRIntn osfd, _MDStat64 *buf);\n+typedef PRIntn (*_MD_Open64)(const char *path, int oflag, ...);\n+typedef PRIntn (*_MD_Stat64)(const char *path, _MDStat64 *buf);\n typedef _MDOff64_t (*_MD_Lseek64)(PRIntn osfd, _MDOff64_t, PRIntn whence);\n-typedef void* (*_MD_Mmap64)(void* addr, PRSize len, PRIntn prot, PRIntn flags,\n-                            PRIntn fildes, _MDOff64_t offset);\n-struct _MD_IOVector {\n+typedef void* (*_MD_Mmap64)(\n+    void *addr, PRSize len, PRIntn prot, PRIntn flags,\n+    PRIntn fildes, _MDOff64_t offset);\n+struct _MD_IOVector\n+{\n     _MD_Open64 _open64;\n     _MD_Mmap64 _mmap64;\n     _MD_Stat64 _stat64;\ndiff --git a/nspr/pr/include/md/_win32_errors.h b/nspr/pr/include/md/_win32_errors.h\nindex bc1c230..d267d8a 100644\n--- a/nspr/pr/include/md/_win32_errors.h\n+++ b/nspr/pr/include/md/_win32_errors.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,26 +10,27 @@\n #include <winsock.h>\n #include <errno.h>\n \n+\n extern void _MD_win32_map_default_error(PRInt32 err);\n-#define _PR_MD_MAP_DEFAULT_ERROR _MD_win32_map_default_error\n+#define _PR_MD_MAP_DEFAULT_ERROR    _MD_win32_map_default_error\n \n extern void _MD_win32_map_opendir_error(PRInt32 err);\n-#define _PR_MD_MAP_OPENDIR_ERROR _MD_win32_map_opendir_error\n+#define _PR_MD_MAP_OPENDIR_ERROR    _MD_win32_map_opendir_error\n \n extern void _MD_win32_map_closedir_error(PRInt32 err);\n-#define _PR_MD_MAP_CLOSEDIR_ERROR _MD_win32_map_closedir_error\n+#define _PR_MD_MAP_CLOSEDIR_ERROR   _MD_win32_map_closedir_error\n \n extern void _MD_unix_readdir_error(PRInt32 err);\n-#define _PR_MD_MAP_READDIR_ERROR _MD_unix_readdir_error\n+#define _PR_MD_MAP_READDIR_ERROR    _MD_unix_readdir_error\n \n extern void _MD_win32_map_delete_error(PRInt32 err);\n #define _PR_MD_MAP_DELETE_ERROR _MD_win32_map_delete_error\n \n extern void _MD_win32_map_stat_error(PRInt32 err);\n-#define _PR_MD_MAP_STAT_ERROR _MD_win32_map_stat_error\n+#define _PR_MD_MAP_STAT_ERROR   _MD_win32_map_stat_error\n \n extern void _MD_win32_map_fstat_error(PRInt32 err);\n-#define _PR_MD_MAP_FSTAT_ERROR _MD_win32_map_fstat_error\n+#define _PR_MD_MAP_FSTAT_ERROR  _MD_win32_map_fstat_error\n \n extern void _MD_win32_map_rename_error(PRInt32 err);\n #define _PR_MD_MAP_RENAME_ERROR _MD_win32_map_rename_error\n@@ -37,40 +39,40 @@ extern void _MD_win32_map_access_error(PRInt32 err);\n #define _PR_MD_MAP_ACCESS_ERROR _MD_win32_map_access_error\n \n extern void _MD_win32_map_mkdir_error(PRInt32 err);\n-#define _PR_MD_MAP_MKDIR_ERROR _MD_win32_map_mkdir_error\n+#define _PR_MD_MAP_MKDIR_ERROR  _MD_win32_map_mkdir_error\n \n extern void _MD_win32_map_rmdir_error(PRInt32 err);\n-#define _PR_MD_MAP_RMDIR_ERROR _MD_win32_map_rmdir_error\n+#define _PR_MD_MAP_RMDIR_ERROR  _MD_win32_map_rmdir_error\n \n extern void _MD_win32_map_read_error(PRInt32 err);\n-#define _PR_MD_MAP_READ_ERROR _MD_win32_map_read_error\n+#define _PR_MD_MAP_READ_ERROR   _MD_win32_map_read_error\n \n extern void _MD_win32_map_transmitfile_error(PRInt32 err);\n-#define _PR_MD_MAP_TRANSMITFILE_ERROR _MD_win32_map_transmitfile_error\n+#define _PR_MD_MAP_TRANSMITFILE_ERROR   _MD_win32_map_transmitfile_error\n \n extern void _MD_win32_map_write_error(PRInt32 err);\n-#define _PR_MD_MAP_WRITE_ERROR _MD_win32_map_write_error\n+#define _PR_MD_MAP_WRITE_ERROR  _MD_win32_map_write_error\n \n extern void _MD_win32_map_lseek_error(PRInt32 err);\n-#define _PR_MD_MAP_LSEEK_ERROR _MD_win32_map_lseek_error\n+#define _PR_MD_MAP_LSEEK_ERROR  _MD_win32_map_lseek_error\n \n extern void _MD_win32_map_fsync_error(PRInt32 err);\n-#define _PR_MD_MAP_FSYNC_ERROR _MD_win32_map_fsync_error\n+#define _PR_MD_MAP_FSYNC_ERROR  _MD_win32_map_fsync_error\n \n extern void _MD_win32_map_close_error(PRInt32 err);\n-#define _PR_MD_MAP_CLOSE_ERROR _MD_win32_map_close_error\n+#define _PR_MD_MAP_CLOSE_ERROR  _MD_win32_map_close_error\n \n extern void _MD_win32_map_socket_error(PRInt32 err);\n #define _PR_MD_MAP_SOCKET_ERROR _MD_win32_map_socket_error\n \n extern void _MD_win32_map_recv_error(PRInt32 err);\n-#define _PR_MD_MAP_RECV_ERROR _MD_win32_map_recv_error\n+#define _PR_MD_MAP_RECV_ERROR   _MD_win32_map_recv_error\n \n extern void _MD_win32_map_recvfrom_error(PRInt32 err);\n-#define _PR_MD_MAP_RECVFROM_ERROR _MD_win32_map_recvfrom_error\n+#define _PR_MD_MAP_RECVFROM_ERROR   _MD_win32_map_recvfrom_error\n \n extern void _MD_win32_map_send_error(PRInt32 err);\n-#define _PR_MD_MAP_SEND_ERROR _MD_win32_map_send_error\n+#define _PR_MD_MAP_SEND_ERROR   _MD_win32_map_send_error\n \n extern void _MD_win32_map_sendto_error(PRInt32 err);\n #define _PR_MD_MAP_SENDTO_ERROR _MD_win32_map_sendto_error\n@@ -79,25 +81,25 @@ extern void _MD_win32_map_accept_error(PRInt32 err);\n #define _PR_MD_MAP_ACCEPT_ERROR _MD_win32_map_accept_error\n \n extern void _MD_win32_map_acceptex_error(PRInt32 err);\n-#define _PR_MD_MAP_ACCEPTEX_ERROR _MD_win32_map_acceptex_error\n+#define _PR_MD_MAP_ACCEPTEX_ERROR   _MD_win32_map_acceptex_error\n \n extern void _MD_win32_map_connect_error(PRInt32 err);\n-#define _PR_MD_MAP_CONNECT_ERROR _MD_win32_map_connect_error\n+#define _PR_MD_MAP_CONNECT_ERROR    _MD_win32_map_connect_error\n \n extern void _MD_win32_map_bind_error(PRInt32 err);\n-#define _PR_MD_MAP_BIND_ERROR _MD_win32_map_bind_error\n+#define _PR_MD_MAP_BIND_ERROR   _MD_win32_map_bind_error\n \n extern void _MD_win32_map_listen_error(PRInt32 err);\n #define _PR_MD_MAP_LISTEN_ERROR _MD_win32_map_listen_error\n \n extern void _MD_win32_map_shutdown_error(PRInt32 err);\n-#define _PR_MD_MAP_SHUTDOWN_ERROR _MD_win32_map_shutdown_error\n+#define _PR_MD_MAP_SHUTDOWN_ERROR   _MD_win32_map_shutdown_error\n \n extern void _MD_win32_map_getsockname_error(PRInt32 err);\n-#define _PR_MD_MAP_GETSOCKNAME_ERROR _MD_win32_map_getsockname_error\n+#define _PR_MD_MAP_GETSOCKNAME_ERROR    _MD_win32_map_getsockname_error\n \n extern void _MD_win32_map_getpeername_error(PRInt32 err);\n-#define _PR_MD_MAP_GETPEERNAME_ERROR _MD_win32_map_getpeername_error\n+#define _PR_MD_MAP_GETPEERNAME_ERROR    _MD_win32_map_getpeername_error\n \n extern void _MD_win32_map_getsockopt_error(PRInt32 err);\n #define _PR_MD_MAP_GETSOCKOPT_ERROR _MD_win32_map_getsockopt_error\n@@ -106,15 +108,15 @@ extern void _MD_win32_map_setsockopt_error(PRInt32 err);\n #define _PR_MD_MAP_SETSOCKOPT_ERROR _MD_win32_map_setsockopt_error\n \n extern void _MD_win32_map_open_error(PRInt32 err);\n-#define _PR_MD_MAP_OPEN_ERROR _MD_win32_map_open_error\n+#define _PR_MD_MAP_OPEN_ERROR   _MD_win32_map_open_error\n \n extern void _MD_win32_map_gethostname_error(PRInt32 err);\n-#define _PR_MD_MAP_GETHOSTNAME_ERROR _MD_win32_map_gethostname_error\n+#define _PR_MD_MAP_GETHOSTNAME_ERROR    _MD_win32_map_gethostname_error\n \n extern void _MD_win32_map_select_error(PRInt32 err);\n #define _PR_MD_MAP_SELECT_ERROR _MD_win32_map_select_error\n \n extern void _MD_win32_map_lockf_error(int err);\n-#define _PR_MD_MAP_LOCKF_ERROR _MD_win32_map_lockf_error\n+#define _PR_MD_MAP_LOCKF_ERROR  _MD_win32_map_lockf_error\n \n #endif /* nspr_win32_errors_h___ */\ndiff --git a/nspr/pr/include/md/_win95.cfg b/nspr/pr/include/md/_win95.cfg\nindex 54bbd47..7c379fc 100644\n--- a/nspr/pr/include/md/_win95.cfg\n+++ b/nspr/pr/include/md/_win95.cfg\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/md/_win95.h b/nspr/pr/include/md/_win95.h\nindex 21b1f66..281cd6f 100644\n--- a/nspr/pr/include/md/_win95.h\n+++ b/nspr/pr/include/md/_win95.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -15,24 +16,24 @@\n  * Internal configuration macros\n  */\n \n-#define PR_LINKER_ARCH \"win32\"\n-#define _PR_SI_SYSNAME \"WIN95\"\n+#define PR_LINKER_ARCH      \"win32\"\n+#define _PR_SI_SYSNAME        \"WIN95\"\n #if defined(_M_IX86) || defined(_X86_)\n-#define _PR_SI_ARCHITECTURE \"x86\"\n+#define _PR_SI_ARCHITECTURE   \"x86\"\n #elif defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)\n-#define _PR_SI_ARCHITECTURE \"x86-64\"\n+#define _PR_SI_ARCHITECTURE   \"x86-64\"\n #elif defined(_M_IA64) || defined(_IA64_)\n-#define _PR_SI_ARCHITECTURE \"ia64\"\n+#define _PR_SI_ARCHITECTURE   \"ia64\"\n #elif defined(_M_ARM) || defined(_ARM_)\n-#define _PR_SI_ARCHITECTURE \"arm\"\n+#define _PR_SI_ARCHITECTURE   \"arm\"\n #elif defined(_M_ARM64)\n-#define _PR_SI_ARCHITECTURE \"aarch64\"\n+#define _PR_SI_ARCHITECTURE   \"aarch64\"\n #else\n #error unknown processor architecture\n #endif\n \n #define HAVE_DLL\n-#undef HAVE_THREAD_AFFINITY\n+#undef  HAVE_THREAD_AFFINITY\n #define _PR_HAVE_GETADDRINFO\n #define _PR_INET6_PROBE\n #ifndef _PR_INET6\n@@ -48,16 +49,16 @@ struct addrinfo {\n     int ai_socktype;\n     int ai_protocol;\n     size_t ai_addrlen;\n-    char* ai_canonname;\n-    struct sockaddr* ai_addr;\n-    struct addrinfo* ai_next;\n+    char *ai_canonname;\n+    struct sockaddr *ai_addr;\n+    struct addrinfo *ai_next;\n };\n #endif\n #define _PR_HAVE_MD_SOCKADDR_IN6\n /* isomorphic to struct in6_addr on Windows */\n struct _md_in6_addr {\n     union {\n-        PRUint8 _S6_u8[16];\n+        PRUint8  _S6_u8[16];\n         PRUint16 _S6_u16[8];\n     } _S6_un;\n };\n@@ -77,99 +78,99 @@ struct _md_sockaddr_in6 {\n /* --- Common User-Thread/Native-Thread Definitions --------------------- */\n \n /* --- Globals --- */\n-extern struct PRLock* _pr_schedLock;\n+extern struct PRLock                      *_pr_schedLock;\n \n /* --- Typedefs --- */\n-typedef void (*FiberFunc)(void*);\n+typedef void (*FiberFunc)(void *);\n \n-#define PR_NUM_GCREGS 8\n-typedef PRInt32 PR_CONTEXT_TYPE[PR_NUM_GCREGS];\n-#define GC_VMBASE 0x40000000\n-#define GC_VMLIMIT 0x00FFFFFF\n+#define PR_NUM_GCREGS           8\n+typedef PRInt32                 PR_CONTEXT_TYPE[PR_NUM_GCREGS];\n+#define GC_VMBASE               0x40000000\n+#define GC_VMLIMIT              0x00FFFFFF\n \n-#define _MD_MAGIC_THREAD 0x22222222\n-#define _MD_MAGIC_THREADSTACK 0x33333333\n-#define _MD_MAGIC_SEGMENT 0x44444444\n-#define _MD_MAGIC_DIR 0x55555555\n-#define _MD_MAGIC_CV 0x66666666\n+#define _MD_MAGIC_THREAD    0x22222222\n+#define _MD_MAGIC_THREADSTACK   0x33333333\n+#define _MD_MAGIC_SEGMENT   0x44444444\n+#define _MD_MAGIC_DIR       0x55555555\n+#define _MD_MAGIC_CV        0x66666666\n \n struct _MDCPU {\n-    int unused;\n+    int              unused;\n };\n \n struct _MDThread {\n-    HANDLE blocked_sema;  /* Threads block on this when waiting\n-                           * for IO or CondVar.\n-                           */\n-    PRBool inCVWaitQueue; /* PR_TRUE if the thread is in the\n-                           * wait queue of some cond var.\n-                           * PR_FALSE otherwise.  */\n-    HANDLE handle;        /* Win32 thread handle */\n-    PRUint32 id;\n-    void* sp;                     /* only valid when suspended */\n-    PRUint32 magic;               /* for debugging */\n-    PR_CONTEXT_TYPE gcContext;    /* Thread context for GC */\n-    struct PRThread *prev, *next; /* used by the cvar wait queue to\n-                                   * chain the PRThread structures\n-                                   * together */\n-    void (*start)(void*);         /* used by _PR_MD_CREATE_THREAD to\n-                                   * pass its 'start' argument to\n-                                   * pr_root. */\n+    HANDLE           blocked_sema;      /* Threads block on this when waiting\n+                                         * for IO or CondVar.\n+                                         */\n+    PRBool           inCVWaitQueue;     /* PR_TRUE if the thread is in the\n+                                         * wait queue of some cond var.\n+                                         * PR_FALSE otherwise.  */\n+    HANDLE           handle;            /* Win32 thread handle */\n+    PRUint32         id;\n+    void            *sp;                /* only valid when suspended */\n+    PRUint32         magic;             /* for debugging */\n+    PR_CONTEXT_TYPE  gcContext;         /* Thread context for GC */\n+    struct PRThread *prev, *next;       /* used by the cvar wait queue to\n+                                         * chain the PRThread structures\n+                                         * together */\n+    void (*start)(void *);              /* used by _PR_MD_CREATE_THREAD to\n+                                         * pass its 'start' argument to\n+                                         * pr_root. */\n };\n \n struct _MDThreadStack {\n-    PRUint32 magic; /* for debugging */\n+    PRUint32           magic;          /* for debugging */\n };\n \n struct _MDSegment {\n-    PRUint32 magic; /* for debugging */\n+    PRUint32           magic;          /* for debugging */\n };\n \n #undef PROFILE_LOCKS\n \n struct _MDDir {\n-    HANDLE d_hdl;\n+    HANDLE           d_hdl;\n     WIN32_FIND_DATAA d_entry;\n-    PRBool firstEntry; /* Is this the entry returned\n-                        * by FindFirstFile()? */\n-    PRUint32 magic;    /* for debugging */\n+    PRBool           firstEntry;     /* Is this the entry returned\n+                                      * by FindFirstFile()? */\n+    PRUint32         magic;          /* for debugging */\n };\n \n #ifdef MOZ_UNICODE\n struct _MDDirUTF16 {\n-    HANDLE d_hdl;\n+    HANDLE           d_hdl;\n     WIN32_FIND_DATAW d_entry;\n-    PRBool firstEntry; /* Is this the entry returned\n-                        * by FindFirstFileW()? */\n-    PRUint32 magic;    /* for debugging */\n+    PRBool           firstEntry;     /* Is this the entry returned\n+                                      * by FindFirstFileW()? */\n+    PRUint32         magic;          /* for debugging */\n };\n #endif /* MOZ_UNICODE */\n \n struct _MDCVar {\n     PRUint32 magic;\n-    struct PRThread *waitHead, *waitTail; /* the wait queue: a doubly-\n-                                           * linked list of threads\n-                                           * waiting on this condition\n-                                           * variable */\n-    PRIntn nwait;                         /* number of threads in the\n-                                           * wait queue */\n+    struct PRThread *waitHead, *waitTail;  /* the wait queue: a doubly-\n+                                            * linked list of threads\n+                                            * waiting on this condition\n+                                            * variable */\n+    PRIntn nwait;                          /* number of threads in the\n+                                            * wait queue */\n };\n \n #define _MD_CV_NOTIFIED_LENGTH 6\n typedef struct _MDNotified _MDNotified;\n struct _MDNotified {\n-    PRIntn length; /* # of used entries in this\n-                    * structure */\n+    PRIntn length;                     /* # of used entries in this\n+                                        * structure */\n     struct {\n-        struct _MDCVar* cv;          /* the condition variable notified */\n-        PRIntn times;                /* and the number of times notified */\n-        struct PRThread* notifyHead; /* list of threads to wake up */\n+        struct _MDCVar *cv;            /* the condition variable notified */\n+        PRIntn times;                  /* and the number of times notified */\n+        struct PRThread *notifyHead;   /* list of threads to wake up */\n     } cv[_MD_CV_NOTIFIED_LENGTH];\n-    _MDNotified* link; /* link to another of these, or NULL */\n+    _MDNotified *link;                 /* link to another of these, or NULL */\n };\n \n struct _MDLock {\n-    CRITICAL_SECTION mutex; /* this is recursive on NT */\n+    CRITICAL_SECTION mutex;          /* this is recursive on NT */\n \n     /*\n      * When notifying cvars, there is no point in actually\n@@ -177,7 +178,7 @@ struct _MDLock {\n      * released the lock.  So, we temporarily record the cvars.\n      * When doing an unlock, we'll then wake up the waiting threads.\n      */\n-    struct _MDNotified notified; /* array of conditions notified */\n+    struct _MDNotified notified;     /* array of conditions notified */\n #ifdef PROFILE_LOCKS\n     PRInt32 hitcount;\n     PRInt32 misscount;\n@@ -185,18 +186,18 @@ struct _MDLock {\n };\n \n struct _MDSemaphore {\n-    HANDLE sem;\n+    HANDLE           sem;\n };\n \n struct _MDFileDesc {\n-    PROsfd osfd; /* The osfd can come from one of three spaces:\n-                  * - For stdin, stdout, and stderr, we are using\n-                  *   the libc file handle (0, 1, 2), which is an int.\n-                  * - For files and pipes, we are using Win32 HANDLE,\n-                  *   which is a void*.\n-                  * - For sockets, we are using Winsock SOCKET, which\n-                  *   is a u_int.\n-                  */\n+    PROsfd osfd;     /* The osfd can come from one of three spaces:\n+                      * - For stdin, stdout, and stderr, we are using\n+                      *   the libc file handle (0, 1, 2), which is an int.\n+                      * - For files and pipes, we are using Win32 HANDLE,\n+                      *   which is a void*.\n+                      * - For sockets, we are using Winsock SOCKET, which\n+                      *   is a u_int.\n+                      */\n };\n \n struct _MDProcess {\n@@ -205,205 +206,208 @@ struct _MDProcess {\n };\n \n /* --- Misc stuff --- */\n-#define _MD_GET_SP(thread) (thread)->md.gcContext[6]\n+#define _MD_GET_SP(thread)            (thread)->md.gcContext[6]\n \n /* --- NT security stuff --- */\n \n extern void _PR_NT_InitSids(void);\n extern void _PR_NT_FreeSids(void);\n-extern PRStatus _PR_NT_MakeSecurityDescriptorACL(PRIntn mode,\n-                                                 DWORD accessTable[],\n-                                                 PSECURITY_DESCRIPTOR* resultSD,\n-                                                 PACL* resultACL);\n-extern void _PR_NT_FreeSecurityDescriptorACL(PSECURITY_DESCRIPTOR pSD,\n-                                             PACL pACL);\n+extern PRStatus _PR_NT_MakeSecurityDescriptorACL(\n+    PRIntn mode,\n+    DWORD accessTable[],\n+    PSECURITY_DESCRIPTOR *resultSD,\n+    PACL *resultACL\n+);\n+extern void _PR_NT_FreeSecurityDescriptorACL(\n+    PSECURITY_DESCRIPTOR pSD, PACL pACL);\n \n /* --- IO stuff --- */\n \n-#define _MD_OPEN _PR_MD_OPEN\n-#define _MD_OPEN_FILE _PR_MD_OPEN_FILE\n-#define _MD_READ _PR_MD_READ\n-#define _MD_WRITE _PR_MD_WRITE\n-#define _MD_WRITEV _PR_MD_WRITEV\n-#define _MD_LSEEK _PR_MD_LSEEK\n-#define _MD_LSEEK64 _PR_MD_LSEEK64\n+#define _MD_OPEN                      _PR_MD_OPEN\n+#define _MD_OPEN_FILE                 _PR_MD_OPEN_FILE\n+#define _MD_READ                      _PR_MD_READ\n+#define _MD_WRITE                     _PR_MD_WRITE\n+#define _MD_WRITEV                    _PR_MD_WRITEV\n+#define _MD_LSEEK                     _PR_MD_LSEEK\n+#define _MD_LSEEK64                   _PR_MD_LSEEK64\n extern PRInt32 _MD_CloseFile(PROsfd osfd);\n-#define _MD_CLOSE_FILE _MD_CloseFile\n-#define _MD_GETFILEINFO _PR_MD_GETFILEINFO\n-#define _MD_GETFILEINFO64 _PR_MD_GETFILEINFO64\n-#define _MD_GETOPENFILEINFO _PR_MD_GETOPENFILEINFO\n-#define _MD_GETOPENFILEINFO64 _PR_MD_GETOPENFILEINFO64\n-#define _MD_STAT _PR_MD_STAT\n-#define _MD_RENAME _PR_MD_RENAME\n-#define _MD_ACCESS _PR_MD_ACCESS\n-#define _MD_DELETE _PR_MD_DELETE\n-#define _MD_MKDIR _PR_MD_MKDIR\n-#define _MD_MAKE_DIR _PR_MD_MAKE_DIR\n-#define _MD_RMDIR _PR_MD_RMDIR\n-#define _MD_LOCKFILE _PR_MD_LOCKFILE\n-#define _MD_TLOCKFILE _PR_MD_TLOCKFILE\n-#define _MD_UNLOCKFILE _PR_MD_UNLOCKFILE\n+#define _MD_CLOSE_FILE                _MD_CloseFile\n+#define _MD_GETFILEINFO               _PR_MD_GETFILEINFO\n+#define _MD_GETFILEINFO64             _PR_MD_GETFILEINFO64\n+#define _MD_GETOPENFILEINFO           _PR_MD_GETOPENFILEINFO\n+#define _MD_GETOPENFILEINFO64         _PR_MD_GETOPENFILEINFO64\n+#define _MD_STAT                      _PR_MD_STAT\n+#define _MD_RENAME                    _PR_MD_RENAME\n+#define _MD_ACCESS                    _PR_MD_ACCESS\n+#define _MD_DELETE                    _PR_MD_DELETE\n+#define _MD_MKDIR                     _PR_MD_MKDIR\n+#define _MD_MAKE_DIR                  _PR_MD_MAKE_DIR\n+#define _MD_RMDIR                     _PR_MD_RMDIR\n+#define _MD_LOCKFILE                  _PR_MD_LOCKFILE\n+#define _MD_TLOCKFILE                 _PR_MD_TLOCKFILE\n+#define _MD_UNLOCKFILE                _PR_MD_UNLOCKFILE\n \n /* --- UTF16 IO stuff --- */\n #ifdef MOZ_UNICODE\n-#define _MD_OPEN_FILE_UTF16 _PR_MD_OPEN_FILE_UTF16\n-#define _MD_OPEN_DIR_UTF16 _PR_MD_OPEN_DIR_UTF16\n-#define _MD_READ_DIR_UTF16 _PR_MD_READ_DIR_UTF16\n-#define _MD_CLOSE_DIR_UTF16 _PR_MD_CLOSE_DIR_UTF16\n-#define _MD_GETFILEINFO64_UTF16 _PR_MD_GETFILEINFO64_UTF16\n+#define _MD_OPEN_FILE_UTF16           _PR_MD_OPEN_FILE_UTF16\n+#define _MD_OPEN_DIR_UTF16            _PR_MD_OPEN_DIR_UTF16\n+#define _MD_READ_DIR_UTF16            _PR_MD_READ_DIR_UTF16\n+#define _MD_CLOSE_DIR_UTF16           _PR_MD_CLOSE_DIR_UTF16\n+#define _MD_GETFILEINFO64_UTF16       _PR_MD_GETFILEINFO64_UTF16\n #endif /* MOZ_UNICODE */\n \n /* --- Socket IO stuff --- */\n extern void _PR_MD_InitSockets(void);\n extern void _PR_MD_CleanupSockets(void);\n-#define _MD_EACCES WSAEACCES\n-#define _MD_EADDRINUSE WSAEADDRINUSE\n-#define _MD_EADDRNOTAVAIL WSAEADDRNOTAVAIL\n-#define _MD_EAFNOSUPPORT WSAEAFNOSUPPORT\n-#define _MD_EAGAIN WSAEWOULDBLOCK\n-#define _MD_EALREADY WSAEALREADY\n-#define _MD_EBADF WSAEBADF\n-#define _MD_ECONNREFUSED WSAECONNREFUSED\n-#define _MD_ECONNRESET WSAECONNRESET\n-#define _MD_EFAULT WSAEFAULT\n-#define _MD_EINPROGRESS WSAEINPROGRESS\n-#define _MD_EINTR WSAEINTR\n-#define _MD_EINVAL EINVAL\n-#define _MD_EISCONN WSAEISCONN\n-#define _MD_ENETUNREACH WSAENETUNREACH\n-#define _MD_ENOENT ENOENT\n-#define _MD_ENOTCONN WSAENOTCONN\n-#define _MD_ENOTSOCK WSAENOTSOCK\n-#define _MD_EOPNOTSUPP WSAEOPNOTSUPP\n-#define _MD_EWOULDBLOCK WSAEWOULDBLOCK\n-#define _MD_GET_SOCKET_ERROR() WSAGetLastError()\n+#define _MD_EACCES                WSAEACCES\n+#define _MD_EADDRINUSE            WSAEADDRINUSE\n+#define _MD_EADDRNOTAVAIL         WSAEADDRNOTAVAIL\n+#define _MD_EAFNOSUPPORT          WSAEAFNOSUPPORT\n+#define _MD_EAGAIN                WSAEWOULDBLOCK\n+#define _MD_EALREADY              WSAEALREADY\n+#define _MD_EBADF                 WSAEBADF\n+#define _MD_ECONNREFUSED          WSAECONNREFUSED\n+#define _MD_ECONNRESET            WSAECONNRESET\n+#define _MD_EFAULT                WSAEFAULT\n+#define _MD_EINPROGRESS           WSAEINPROGRESS\n+#define _MD_EINTR                 WSAEINTR\n+#define _MD_EINVAL                EINVAL\n+#define _MD_EISCONN               WSAEISCONN\n+#define _MD_ENETUNREACH           WSAENETUNREACH\n+#define _MD_ENOENT                ENOENT\n+#define _MD_ENOTCONN              WSAENOTCONN\n+#define _MD_ENOTSOCK              WSAENOTSOCK\n+#define _MD_EOPNOTSUPP            WSAEOPNOTSUPP\n+#define _MD_EWOULDBLOCK           WSAEWOULDBLOCK\n+#define _MD_GET_SOCKET_ERROR()    WSAGetLastError()\n #define _MD_SET_SOCKET_ERROR(_err) WSASetLastError(_err)\n \n #define _MD_INIT_FILEDESC(fd)\n-extern void _MD_MakeNonblock(PRFileDesc* f);\n-#define _MD_MAKE_NONBLOCK _MD_MakeNonblock\n-#define _MD_INIT_FD_INHERITABLE _PR_MD_INIT_FD_INHERITABLE\n-#define _MD_QUERY_FD_INHERITABLE _PR_MD_QUERY_FD_INHERITABLE\n-#define _MD_SHUTDOWN _PR_MD_SHUTDOWN\n-#define _MD_LISTEN _PR_MD_LISTEN\n+extern void _MD_MakeNonblock(PRFileDesc *f);\n+#define _MD_MAKE_NONBLOCK             _MD_MakeNonblock\n+#define _MD_INIT_FD_INHERITABLE       _PR_MD_INIT_FD_INHERITABLE\n+#define _MD_QUERY_FD_INHERITABLE      _PR_MD_QUERY_FD_INHERITABLE\n+#define _MD_SHUTDOWN                  _PR_MD_SHUTDOWN\n+#define _MD_LISTEN                    _PR_MD_LISTEN\n extern PRInt32 _MD_CloseSocket(PROsfd osfd);\n-#define _MD_CLOSE_SOCKET _MD_CloseSocket\n-#define _MD_SENDTO _PR_MD_SENDTO\n+#define _MD_CLOSE_SOCKET              _MD_CloseSocket\n+#define _MD_SENDTO                    _PR_MD_SENDTO\n #ifdef _WIN64\n-#define _MD_TCPSENDTO _PR_MD_TCPSENDTO\n+#define _MD_TCPSENDTO                 _PR_MD_TCPSENDTO\n #endif\n-#define _MD_RECVFROM _PR_MD_RECVFROM\n+#define _MD_RECVFROM                  _PR_MD_RECVFROM\n #define _MD_SOCKETPAIR(s, type, proto, sv) -1\n-#define _MD_GETSOCKNAME _PR_MD_GETSOCKNAME\n-#define _MD_GETPEERNAME _PR_MD_GETPEERNAME\n-#define _MD_GETSOCKOPT _PR_MD_GETSOCKOPT\n-#define _MD_SETSOCKOPT _PR_MD_SETSOCKOPT\n-#define _MD_SET_FD_INHERITABLE _PR_MD_SET_FD_INHERITABLE\n-#define _MD_SELECT select\n-#define _MD_FSYNC _PR_MD_FSYNC\n-#define READ_FD 1\n-#define WRITE_FD 2\n+#define _MD_GETSOCKNAME               _PR_MD_GETSOCKNAME\n+#define _MD_GETPEERNAME               _PR_MD_GETPEERNAME\n+#define _MD_GETSOCKOPT                _PR_MD_GETSOCKOPT\n+#define _MD_SETSOCKOPT                _PR_MD_SETSOCKOPT\n+#define _MD_SET_FD_INHERITABLE        _PR_MD_SET_FD_INHERITABLE\n+#define _MD_SELECT                    select\n+#define _MD_FSYNC                     _PR_MD_FSYNC\n+#define READ_FD                       1\n+#define WRITE_FD                      2\n \n #define _MD_INIT_ATOMIC()\n #if defined(_M_IX86) || defined(_X86_)\n-#define _MD_ATOMIC_INCREMENT _PR_MD_ATOMIC_INCREMENT\n-#define _MD_ATOMIC_ADD _PR_MD_ATOMIC_ADD\n-#define _MD_ATOMIC_DECREMENT _PR_MD_ATOMIC_DECREMENT\n+#define _MD_ATOMIC_INCREMENT          _PR_MD_ATOMIC_INCREMENT\n+#define _MD_ATOMIC_ADD                _PR_MD_ATOMIC_ADD\n+#define _MD_ATOMIC_DECREMENT          _PR_MD_ATOMIC_DECREMENT\n #else /* non-x86 processors */\n-#define _MD_ATOMIC_INCREMENT(x) InterlockedIncrement((PLONG)x)\n-#define _MD_ATOMIC_ADD(ptr, val) \\\n-    (InterlockedExchangeAdd((PLONG)ptr, (LONG)val) + val)\n-#define _MD_ATOMIC_DECREMENT(x) InterlockedDecrement((PLONG)x)\n+#define _MD_ATOMIC_INCREMENT(x)       InterlockedIncrement((PLONG)x)\n+#define _MD_ATOMIC_ADD(ptr,val)    (InterlockedExchangeAdd((PLONG)ptr, (LONG)val) + val)\n+#define _MD_ATOMIC_DECREMENT(x)       InterlockedDecrement((PLONG)x)\n #endif /* x86 */\n-#define _MD_ATOMIC_SET(x, y) InterlockedExchange((PLONG)x, (LONG)y)\n+#define _MD_ATOMIC_SET(x,y)           InterlockedExchange((PLONG)x, (LONG)y)\n+\n+#define _MD_INIT_IO                   _PR_MD_INIT_IO\n \n-#define _MD_INIT_IO _PR_MD_INIT_IO\n \n /* win95 doesn't have async IO */\n-#define _MD_SOCKET _PR_MD_SOCKET\n-extern PRInt32 _MD_SocketAvailable(PRFileDesc* fd);\n-#define _MD_SOCKETAVAILABLE _MD_SocketAvailable\n-#define _MD_PIPEAVAILABLE _PR_MD_PIPEAVAILABLE\n-#define _MD_CONNECT _PR_MD_CONNECT\n-extern PROsfd _MD_Accept(PRFileDesc* fd, PRNetAddr* raddr, PRUint32* rlen,\n+#define _MD_SOCKET                    _PR_MD_SOCKET\n+extern PRInt32 _MD_SocketAvailable(PRFileDesc *fd);\n+#define _MD_SOCKETAVAILABLE           _MD_SocketAvailable\n+#define _MD_PIPEAVAILABLE             _PR_MD_PIPEAVAILABLE\n+#define _MD_CONNECT                   _PR_MD_CONNECT\n+extern PROsfd _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen,\n                          PRIntervalTime timeout);\n-#define _MD_ACCEPT _MD_Accept\n-#define _MD_BIND _PR_MD_BIND\n-#define _MD_RECV _PR_MD_RECV\n-#define _MD_SEND _PR_MD_SEND\n-#define _MD_PR_POLL _PR_MD_PR_POLL\n+#define _MD_ACCEPT                    _MD_Accept\n+#define _MD_BIND                      _PR_MD_BIND\n+#define _MD_RECV                      _PR_MD_RECV\n+#define _MD_SEND                      _PR_MD_SEND\n+#define _MD_PR_POLL                   _PR_MD_PR_POLL\n \n /* --- Scheduler stuff --- */\n // #define _MD_PAUSE_CPU                 _PR_MD_PAUSE_CPU\n #define _MD_PAUSE_CPU\n \n /* --- DIR stuff --- */\n-#define PR_DIRECTORY_SEPARATOR '\\\\'\n-#define PR_DIRECTORY_SEPARATOR_STR \"\\\\\"\n-#define PR_PATH_SEPARATOR ';'\n-#define PR_PATH_SEPARATOR_STR \";\"\n-#define _MD_ERRNO() GetLastError()\n-#define _MD_OPEN_DIR _PR_MD_OPEN_DIR\n-#define _MD_CLOSE_DIR _PR_MD_CLOSE_DIR\n-#define _MD_READ_DIR _PR_MD_READ_DIR\n+#define PR_DIRECTORY_SEPARATOR        '\\\\'\n+#define PR_DIRECTORY_SEPARATOR_STR    \"\\\\\"\n+#define PR_PATH_SEPARATOR       ';'\n+#define PR_PATH_SEPARATOR_STR       \";\"\n+#define _MD_ERRNO()                   GetLastError()\n+#define _MD_OPEN_DIR                  _PR_MD_OPEN_DIR\n+#define _MD_CLOSE_DIR                 _PR_MD_CLOSE_DIR\n+#define _MD_READ_DIR                  _PR_MD_READ_DIR\n \n /* --- Segment stuff --- */\n #define _MD_INIT_SEGS()\n-#define _MD_ALLOC_SEGMENT(seg, size, vaddr) 0\n+#define _MD_ALLOC_SEGMENT(seg, size, vaddr)   0\n #define _MD_FREE_SEGMENT(seg)\n \n /* --- Environment Stuff --- */\n-#define _MD_GET_ENV _PR_MD_GET_ENV\n-#define _MD_PUT_ENV _PR_MD_PUT_ENV\n+#define _MD_GET_ENV                 _PR_MD_GET_ENV\n+#define _MD_PUT_ENV                 _PR_MD_PUT_ENV\n \n /* --- Threading Stuff --- */\n-#define _MD_DEFAULT_STACK_SIZE 0\n-#define _MD_INIT_THREAD _PR_MD_INIT_THREAD\n-#define _MD_INIT_ATTACHED_THREAD _PR_MD_INIT_THREAD\n-#define _MD_CREATE_THREAD _PR_MD_CREATE_THREAD\n-#define _MD_YIELD _PR_MD_YIELD\n-#define _MD_SET_PRIORITY _PR_MD_SET_PRIORITY\n+#define _MD_DEFAULT_STACK_SIZE            0\n+#define _MD_INIT_THREAD             _PR_MD_INIT_THREAD\n+#define _MD_INIT_ATTACHED_THREAD    _PR_MD_INIT_THREAD\n+#define _MD_CREATE_THREAD           _PR_MD_CREATE_THREAD\n+#define _MD_YIELD                   _PR_MD_YIELD\n+#define _MD_SET_PRIORITY            _PR_MD_SET_PRIORITY\n #define _MD_SET_CURRENT_THREAD_NAME _PR_MD_SET_CURRENT_THREAD_NAME\n-#define _MD_CLEAN_THREAD _PR_MD_CLEAN_THREAD\n-#define _MD_SETTHREADAFFINITYMASK _PR_MD_SETTHREADAFFINITYMASK\n-#define _MD_GETTHREADAFFINITYMASK _PR_MD_GETTHREADAFFINITYMASK\n-#define _MD_EXIT_THREAD _PR_MD_EXIT_THREAD\n-#define _MD_EXIT _PR_MD_EXIT\n-#define _MD_SUSPEND_THREAD _PR_MD_SUSPEND_THREAD\n-#define _MD_RESUME_THREAD _PR_MD_RESUME_THREAD\n-#define _MD_SUSPEND_CPU _PR_MD_SUSPEND_CPU\n-#define _MD_RESUME_CPU _PR_MD_RESUME_CPU\n+#define _MD_CLEAN_THREAD            _PR_MD_CLEAN_THREAD\n+#define _MD_SETTHREADAFFINITYMASK   _PR_MD_SETTHREADAFFINITYMASK\n+#define _MD_GETTHREADAFFINITYMASK   _PR_MD_GETTHREADAFFINITYMASK\n+#define _MD_EXIT_THREAD             _PR_MD_EXIT_THREAD\n+#define _MD_EXIT                    _PR_MD_EXIT\n+#define _MD_SUSPEND_THREAD          _PR_MD_SUSPEND_THREAD\n+#define _MD_RESUME_THREAD           _PR_MD_RESUME_THREAD\n+#define _MD_SUSPEND_CPU             _PR_MD_SUSPEND_CPU\n+#define _MD_RESUME_CPU              _PR_MD_RESUME_CPU\n #define _MD_BEGIN_SUSPEND_ALL()\n #define _MD_BEGIN_RESUME_ALL()\n #define _MD_END_SUSPEND_ALL()\n #define _MD_END_RESUME_ALL()\n \n /* --- Lock stuff --- */\n-#define _PR_LOCK _MD_LOCK\n-#define _PR_UNLOCK _MD_UNLOCK\n+#define _PR_LOCK                      _MD_LOCK\n+#define _PR_UNLOCK                    _MD_UNLOCK\n \n-#define _MD_NEW_LOCK _PR_MD_NEW_LOCK\n-#define _MD_FREE_LOCK(lock) DeleteCriticalSection(&((lock)->mutex))\n-#define _MD_LOCK(lock) EnterCriticalSection(&((lock)->mutex))\n-#define _MD_TEST_AND_LOCK(lock) (EnterCriticalSection(&((lock)->mutex)), 0)\n-#define _MD_UNLOCK _PR_MD_UNLOCK\n+#define _MD_NEW_LOCK                  _PR_MD_NEW_LOCK\n+#define _MD_FREE_LOCK(lock)           DeleteCriticalSection(&((lock)->mutex))\n+#define _MD_LOCK(lock)                EnterCriticalSection(&((lock)->mutex))\n+#define _MD_TEST_AND_LOCK(lock)       (EnterCriticalSection(&((lock)->mutex)),0)\n+#define _MD_UNLOCK                    _PR_MD_UNLOCK\n \n /* --- lock and cv waiting --- */\n-#define _MD_WAIT _PR_MD_WAIT\n-#define _MD_WAKEUP_WAITER _PR_MD_WAKEUP_WAITER\n+#define _MD_WAIT                      _PR_MD_WAIT\n+#define _MD_WAKEUP_WAITER             _PR_MD_WAKEUP_WAITER\n \n /* --- CVar ------------------- */\n-#define _MD_WAIT_CV _PR_MD_WAIT_CV\n-#define _MD_NEW_CV _PR_MD_NEW_CV\n-#define _MD_FREE_CV _PR_MD_FREE_CV\n-#define _MD_NOTIFY_CV _PR_MD_NOTIFY_CV\n-#define _MD_NOTIFYALL_CV _PR_MD_NOTIFYALL_CV\n+#define _MD_WAIT_CV                   _PR_MD_WAIT_CV\n+#define _MD_NEW_CV                    _PR_MD_NEW_CV\n+#define _MD_FREE_CV                   _PR_MD_FREE_CV\n+#define _MD_NOTIFY_CV                 _PR_MD_NOTIFY_CV\n+#define _MD_NOTIFYALL_CV              _PR_MD_NOTIFYALL_CV\n \n /* XXXMB- the IOQ stuff is certainly not working correctly yet. */\n // extern  struct _MDLock              _pr_ioq_lock;\n #define _MD_IOQ_LOCK()\n #define _MD_IOQ_UNLOCK()\n \n+\n /* --- Initialization stuff --- */\n #define _MD_START_INTERRUPTS()\n #define _MD_STOP_INTERRUPTS()\n@@ -411,7 +415,7 @@ extern PROsfd _MD_Accept(PRFileDesc* fd, PRNetAddr* raddr, PRUint32* rlen,\n #define _MD_ENABLE_CLOCK_INTERRUPTS()\n #define _MD_BLOCK_CLOCK_INTERRUPTS()\n #define _MD_UNBLOCK_CLOCK_INTERRUPTS()\n-#define _MD_EARLY_INIT _PR_MD_EARLY_INIT\n+#define _MD_EARLY_INIT                _PR_MD_EARLY_INIT\n #define _MD_FINAL_INIT()\n #define _MD_EARLY_CLEANUP()\n #define _MD_INIT_CPUS()\n@@ -421,38 +425,41 @@ struct PRProcess;\n struct PRProcessAttr;\n \n #define _MD_CREATE_PROCESS _PR_CreateWindowsProcess\n-extern struct PRProcess* _PR_CreateWindowsProcess(\n-    const char* path, char* const* argv, char* const* envp,\n-    const struct PRProcessAttr* attr);\n+extern struct PRProcess * _PR_CreateWindowsProcess(\n+    const char *path,\n+    char *const *argv,\n+    char *const *envp,\n+    const struct PRProcessAttr *attr\n+);\n \n #define _MD_DETACH_PROCESS _PR_DetachWindowsProcess\n-extern PRStatus _PR_DetachWindowsProcess(struct PRProcess* process);\n+extern PRStatus _PR_DetachWindowsProcess(struct PRProcess *process);\n \n /* --- Wait for a child process to terminate --- */\n #define _MD_WAIT_PROCESS _PR_WaitWindowsProcess\n-extern PRStatus _PR_WaitWindowsProcess(struct PRProcess* process,\n-                                       PRInt32* exitCode);\n+extern PRStatus _PR_WaitWindowsProcess(struct PRProcess *process,\n+                                       PRInt32 *exitCode);\n \n #define _MD_KILL_PROCESS _PR_KillWindowsProcess\n-extern PRStatus _PR_KillWindowsProcess(struct PRProcess* process);\n+extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process);\n \n-#define _MD_CLEANUP_BEFORE_EXIT _PR_MD_CLEANUP_BEFORE_EXIT\n+#define _MD_CLEANUP_BEFORE_EXIT           _PR_MD_CLEANUP_BEFORE_EXIT\n #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \\\n-    PR_BEGIN_MACRO                                    \\\n-    *status = PR_TRUE;                                \\\n+    PR_BEGIN_MACRO \\\n+    *status = PR_TRUE; \\\n     PR_END_MACRO\n #define _MD_SWITCH_CONTEXT\n #define _MD_RESTORE_CONTEXT\n \n /* --- Intervals --- */\n-#define _MD_INTERVAL_INIT _PR_MD_INTERVAL_INIT\n-#define _MD_GET_INTERVAL _PR_MD_GET_INTERVAL\n-#define _MD_INTERVAL_PER_SEC _PR_MD_INTERVAL_PER_SEC\n-#define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000)\n-#define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000)\n+#define _MD_INTERVAL_INIT                 _PR_MD_INTERVAL_INIT\n+#define _MD_GET_INTERVAL                  _PR_MD_GET_INTERVAL\n+#define _MD_INTERVAL_PER_SEC              _PR_MD_INTERVAL_PER_SEC\n+#define _MD_INTERVAL_PER_MILLISEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000)\n+#define _MD_INTERVAL_PER_MICROSEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000000)\n \n /* --- Time --- */\n-extern void _PR_FileTimeToPRTime(const FILETIME* filetime, PRTime* prtm);\n+extern void _PR_FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm);\n \n #ifdef WINCE\n extern void _MD_InitTime(void);\n@@ -461,44 +468,42 @@ extern void _MD_CleanupTime(void);\n \n /* --- Native-Thread Specific Definitions ------------------------------- */\n \n-extern struct PRThread* _MD_CURRENT_THREAD(void);\n+extern struct PRThread * _MD_CURRENT_THREAD(void);\n \n #ifdef _PR_USE_STATIC_TLS\n-extern __declspec(thread) struct PRThread* _pr_currentThread;\n+extern __declspec(thread) struct PRThread *_pr_currentThread;\n #define _MD_GET_ATTACHED_THREAD() _pr_currentThread\n #define _MD_SET_CURRENT_THREAD(_thread) (_pr_currentThread = (_thread))\n \n-extern __declspec(thread) struct PRThread* _pr_thread_last_run;\n+extern __declspec(thread) struct PRThread *_pr_thread_last_run;\n #define _MD_LAST_THREAD() _pr_thread_last_run\n #define _MD_SET_LAST_THREAD(_thread) (_pr_thread_last_run = 0)\n \n-extern __declspec(thread) struct _PRCPU* _pr_currentCPU;\n+extern __declspec(thread) struct _PRCPU *_pr_currentCPU;\n #define _MD_CURRENT_CPU() _pr_currentCPU\n #define _MD_SET_CURRENT_CPU(_cpu) (_pr_currentCPU = 0)\n #else /* _PR_USE_STATIC_TLS */\n extern DWORD _pr_currentThreadIndex;\n-#define _MD_GET_ATTACHED_THREAD() \\\n-    ((PRThread*)TlsGetValue(_pr_currentThreadIndex))\n-#define _MD_SET_CURRENT_THREAD(_thread) \\\n-    TlsSetValue(_pr_currentThreadIndex, (_thread))\n+#define _MD_GET_ATTACHED_THREAD() ((PRThread *) TlsGetValue(_pr_currentThreadIndex))\n+#define _MD_SET_CURRENT_THREAD(_thread) TlsSetValue(_pr_currentThreadIndex, (_thread))\n \n extern DWORD _pr_lastThreadIndex;\n-#define _MD_LAST_THREAD() ((PRThread*)TlsGetValue(_pr_lastThreadIndex))\n+#define _MD_LAST_THREAD() ((PRThread *) TlsGetValue(_pr_lastThreadIndex))\n #define _MD_SET_LAST_THREAD(_thread) TlsSetValue(_pr_lastThreadIndex, 0)\n \n extern DWORD _pr_currentCPUIndex;\n-#define _MD_CURRENT_CPU() ((struct _PRCPU*)TlsGetValue(_pr_currentCPUIndex))\n+#define _MD_CURRENT_CPU() ((struct _PRCPU *) TlsGetValue(_pr_currentCPUIndex))\n #define _MD_SET_CURRENT_CPU(_cpu) TlsSetValue(_pr_currentCPUIndex, 0)\n #endif /* _PR_USE_STATIC_TLS */\n \n /* --- Scheduler stuff --- */\n-#define LOCK_SCHEDULER() 0\n-#define UNLOCK_SCHEDULER() 0\n-#define _PR_LockSched() 0\n-#define _PR_UnlockSched() 0\n+#define LOCK_SCHEDULER()                 0\n+#define UNLOCK_SCHEDULER()               0\n+#define _PR_LockSched()                  0\n+#define _PR_UnlockSched()                0\n \n /* --- Initialization stuff --- */\n-#define _MD_INIT_LOCKS _PR_MD_INIT_LOCKS\n+#define _MD_INIT_LOCKS                   _PR_MD_INIT_LOCKS\n \n /* --- Stack stuff --- */\n #define _MD_INIT_STACK(stack, redzone)\n@@ -511,30 +516,34 @@ struct _MDFileMap {\n     DWORD dwAccess;\n };\n \n-extern PRStatus _MD_CreateFileMap(struct PRFileMap* fmap, PRInt64 size);\n+extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);\n #define _MD_CREATE_FILE_MAP _MD_CreateFileMap\n \n extern PRInt32 _MD_GetMemMapAlignment(void);\n #define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment\n \n-extern void* _MD_MemMap(struct PRFileMap* fmap, PRInt64 offset, PRUint32 len);\n+extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,\n+                         PRUint32 len);\n #define _MD_MEM_MAP _MD_MemMap\n \n-extern PRStatus _MD_MemUnmap(void* addr, PRUint32 size);\n+extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);\n #define _MD_MEM_UNMAP _MD_MemUnmap\n \n-extern PRStatus _MD_CloseFileMap(struct PRFileMap* fmap);\n+extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);\n #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap\n \n-extern PRStatus _MD_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len);\n+extern PRStatus _MD_SyncMemMap(\n+    PRFileDesc *fd,\n+    void *addr,\n+    PRUint32 len);\n #define _MD_SYNC_MEM_MAP _MD_SyncMemMap\n \n /* --- Named semaphores stuff --- */\n #define _PR_HAVE_NAMED_SEMAPHORES\n-#define _MD_OPEN_SEMAPHORE _PR_MD_OPEN_SEMAPHORE\n-#define _MD_WAIT_SEMAPHORE _PR_MD_WAIT_SEMAPHORE\n-#define _MD_POST_SEMAPHORE _PR_MD_POST_SEMAPHORE\n-#define _MD_CLOSE_SEMAPHORE _PR_MD_CLOSE_SEMAPHORE\n-#define _MD_DELETE_SEMAPHORE(name) PR_SUCCESS /* no op */\n+#define _MD_OPEN_SEMAPHORE            _PR_MD_OPEN_SEMAPHORE\n+#define _MD_WAIT_SEMAPHORE            _PR_MD_WAIT_SEMAPHORE\n+#define _MD_POST_SEMAPHORE            _PR_MD_POST_SEMAPHORE\n+#define _MD_CLOSE_SEMAPHORE           _PR_MD_CLOSE_SEMAPHORE\n+#define _MD_DELETE_SEMAPHORE(name)    PR_SUCCESS  /* no op */\n \n #endif /* nspr_win32_defs_h___ */\ndiff --git a/nspr/pr/include/md/_winnt.cfg b/nspr/pr/include/md/_winnt.cfg\nindex 604e12f..e2a277f 100644\n--- a/nspr/pr/include/md/_winnt.cfg\n+++ b/nspr/pr/include/md/_winnt.cfg\n@@ -1,3 +1,5 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/md/_winnt.h b/nspr/pr/include/md/_winnt.h\nindex 0bd0dec..faed03e 100644\n--- a/nspr/pr/include/md/_winnt.h\n+++ b/nspr/pr/include/md/_winnt.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,10 +9,10 @@\n /* Need to force service-pack 3 extensions to be defined by\n ** setting _WIN32_WINNT to NT 4.0 for winsock.h, winbase.h, winnt.h.\n */\n-#ifndef _WIN32_WINNT\n+#ifndef  _WIN32_WINNT\n #define _WIN32_WINNT 0x0400\n-#elif (_WIN32_WINNT < 0x0400)\n-#undef _WIN32_WINNT\n+#elif   (_WIN32_WINNT < 0x0400)\n+#undef  _WIN32_WINNT\n #define _WIN32_WINNT 0x0400\n #endif /* _WIN32_WINNT */\n \n@@ -29,14 +30,14 @@\n  * Internal configuration macros\n  */\n \n-#define PR_LINKER_ARCH \"win32\"\n-#define _PR_SI_SYSNAME \"WINNT\"\n+#define PR_LINKER_ARCH      \"win32\"\n+#define _PR_SI_SYSNAME        \"WINNT\"\n #if defined(_M_IX86) || defined(_X86_)\n-#define _PR_SI_ARCHITECTURE \"x86\"\n+#define _PR_SI_ARCHITECTURE   \"x86\"\n #elif defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)\n-#define _PR_SI_ARCHITECTURE \"x86-64\"\n+#define _PR_SI_ARCHITECTURE   \"x86-64\"\n #elif defined(_M_IA64) || defined(_IA64_)\n-#define _PR_SI_ARCHITECTURE \"ia64\"\n+#define _PR_SI_ARCHITECTURE   \"ia64\"\n #else\n #error unknown processor architecture\n #endif\n@@ -59,16 +60,16 @@ struct addrinfo {\n     int ai_socktype;\n     int ai_protocol;\n     size_t ai_addrlen;\n-    char* ai_canonname;\n-    struct sockaddr* ai_addr;\n-    struct addrinfo* ai_next;\n+    char *ai_canonname;\n+    struct sockaddr *ai_addr;\n+    struct addrinfo *ai_next;\n };\n #endif\n #define _PR_HAVE_MD_SOCKADDR_IN6\n /* isomorphic to struct in6_addr on Windows */\n struct _md_in6_addr {\n     union {\n-        PRUint8 _S6_u8[16];\n+        PRUint8  _S6_u8[16];\n         PRUint16 _S6_u16[8];\n     } _S6_un;\n };\n@@ -96,47 +97,49 @@ struct _md_sockaddr_in6 {\n /* --- Common User-Thread/Native-Thread Definitions --------------------- */\n \n /* --- Globals --- */\n-extern struct PRLock* _pr_schedLock;\n+extern struct PRLock                      *_pr_schedLock;\n \n /* --- Typedefs --- */\n-typedef void (*FiberFunc)(void*);\n+typedef void (*FiberFunc)(void *);\n \n-#define PR_NUM_GCREGS 8\n-typedef PRInt32 PR_CONTEXT_TYPE[PR_NUM_GCREGS];\n-#define GC_VMBASE 0x40000000\n-#define GC_VMLIMIT 0x00FFFFFF\n+#define PR_NUM_GCREGS           8\n+typedef PRInt32                 PR_CONTEXT_TYPE[PR_NUM_GCREGS];\n+#define GC_VMBASE               0x40000000\n+#define GC_VMLIMIT              0x00FFFFFF\n \n-#define _MD_MAGIC_THREAD 0x22222222\n-#define _MD_MAGIC_THREADSTACK 0x33333333\n-#define _MD_MAGIC_SEGMENT 0x44444444\n-#define _MD_MAGIC_DIR 0x55555555\n+#define _MD_MAGIC_THREAD    0x22222222\n+#define _MD_MAGIC_THREADSTACK   0x33333333\n+#define _MD_MAGIC_SEGMENT   0x44444444\n+#define _MD_MAGIC_DIR       0x55555555\n \n struct _MDCPU {\n-    int unused;\n+    int              unused;\n };\n \n-enum _MDIOModel { _MD_BlockingIO = 0x38,\n-                  _MD_MultiWaitIO = 0x49 };\n+enum _MDIOModel {\n+    _MD_BlockingIO = 0x38,\n+    _MD_MultiWaitIO = 0x49\n+};\n \n typedef struct _MDOverlapped {\n-    OVERLAPPED overlapped; /* Used for async I/O */\n+    OVERLAPPED overlapped;              /* Used for async I/O */\n \n-    enum _MDIOModel ioModel; /* The I/O model to implement\n-                              * using overlapped I/O.\n-                              */\n+    enum _MDIOModel ioModel;            /* The I/O model to implement\n+                                         * using overlapped I/O.\n+                                         */\n     union {\n-        struct _MDThread* mdThread; /* For blocking I/O, this structure\n-                                     * is embedded in the _MDThread\n-                                     * structure.\n-                                     */\n+        struct _MDThread *mdThread;     /* For blocking I/O, this structure\n+                                         * is embedded in the _MDThread\n+                                         * structure.\n+                                         */\n         struct {\n-            PRCList links;           /* for group->io_ready list */\n-            struct PRRecvWait* desc; /* For multiwait I/O, this structure\n-                                      * is associated with a PRRecvWait\n-                                      * structure.\n-                                      */\n-            struct PRWaitGroup* group;\n-            struct TimerEvent* timer;\n+            PRCList links;              /* for group->io_ready list */\n+            struct PRRecvWait *desc;    /* For multiwait I/O, this structure\n+                                         * is associated with a PRRecvWait\n+                                         * structure.\n+                                         */\n+            struct PRWaitGroup *group;\n+            struct TimerEvent *timer;\n             DWORD error;\n         } mw;\n     } data;\n@@ -144,48 +147,48 @@ typedef struct _MDOverlapped {\n \n struct _MDThread {\n     /* The overlapped structure must be first! */\n-    struct _MDOverlapped overlapped;  /* Used for async IO for this thread */\n-    void* acceptex_buf;               /* Used for AcceptEx() */\n-    TRANSMIT_FILE_BUFFERS* xmit_bufs; /* Used for TransmitFile() */\n-    HANDLE blocked_sema;              /* Threads block on this when waiting\n-                                       * for IO or CondVar.\n-                                       */\n-    PRInt32 blocked_io_status;        /* Status of the completed IO */\n-    PRInt32 blocked_io_bytes;         /* Bytes transferred for completed IO */\n-    PRInt32 blocked_io_error;         /* Save error if status is FALSE */\n-    HANDLE handle;\n-    PRUint32 id;\n-    void* sp;                     /* only valid when suspended */\n-    PRUint32 magic;               /* for debugging */\n-    PR_CONTEXT_TYPE gcContext;    /* Thread context for GC */\n-    struct _PRCPU* thr_bound_cpu; /* thread bound to cpu */\n-    PRBool interrupt_disabled;    /* thread cannot be interrupted */\n-    HANDLE thr_event;             /* For native-threads-only support,\n-                                      thread blocks on this event     */\n+    struct _MDOverlapped overlapped;    /* Used for async IO for this thread */\n+    void            *acceptex_buf;      /* Used for AcceptEx() */\n+    TRANSMIT_FILE_BUFFERS *xmit_bufs;   /* Used for TransmitFile() */\n+    HANDLE           blocked_sema;      /* Threads block on this when waiting\n+                                         * for IO or CondVar.\n+                                         */\n+    PRInt32          blocked_io_status; /* Status of the completed IO */\n+    PRInt32          blocked_io_bytes;  /* Bytes transferred for completed IO */\n+    PRInt32          blocked_io_error;  /* Save error if status is FALSE */\n+    HANDLE           handle;\n+    PRUint32         id;\n+    void            *sp;                /* only valid when suspended */\n+    PRUint32         magic;             /* for debugging */\n+    PR_CONTEXT_TYPE  gcContext;         /* Thread context for GC */\n+    struct _PRCPU    *thr_bound_cpu;        /* thread bound to cpu */\n+    PRBool           interrupt_disabled;/* thread cannot be interrupted */\n+    HANDLE           thr_event;         /* For native-threads-only support,\n+                                            thread blocks on this event     */\n \n     /* The following are used only if this is a fiber */\n-    void* fiber_id;           /* flag whether or not this is a fiber*/\n-    FiberFunc fiber_fn;       /* main fiber routine */\n-    void* fiber_arg;          /* arg to main fiber routine */\n-    PRUint32 fiber_stacksize; /* stacksize for fiber */\n-    PRInt32 fiber_last_error; /* last error for the fiber */\n-    void (*start)(void*);     /* used by _PR_MD_CREATE_THREAD to\n-                               * pass its 'start' argument to\n-                               * pr_root. */\n+    void            *fiber_id;          /* flag whether or not this is a fiber*/\n+    FiberFunc        fiber_fn;          /* main fiber routine */\n+    void            *fiber_arg;         /* arg to main fiber routine */\n+    PRUint32         fiber_stacksize;   /* stacksize for fiber */\n+    PRInt32          fiber_last_error;  /* last error for the fiber */\n+    void (*start)(void *);              /* used by _PR_MD_CREATE_THREAD to\n+                                         * pass its 'start' argument to\n+                                         * pr_root. */\n };\n \n struct _MDThreadStack {\n-    PRUint32 magic; /* for debugging */\n+    PRUint32           magic;          /* for debugging */\n };\n \n struct _MDSegment {\n-    PRUint32 magic; /* for debugging */\n+    PRUint32           magic;          /* for debugging */\n };\n \n #undef PROFILE_LOCKS\n \n struct _MDLock {\n-    CRITICAL_SECTION mutex; /* this is recursive on NT */\n+    CRITICAL_SECTION mutex;          /* this is recursive on NT */\n #ifdef PROFILE_LOCKS\n     PRInt32 hitcount;\n     PRInt32 misscount;\n@@ -193,45 +196,45 @@ struct _MDLock {\n };\n \n struct _MDDir {\n-    HANDLE d_hdl;\n-    WIN32_FIND_DATA d_entry;\n-    PRBool firstEntry; /* Is this the entry returned\n-                        * by FindFirstFile()? */\n-    PRUint32 magic;    /* for debugging */\n+    HANDLE           d_hdl;\n+    WIN32_FIND_DATA  d_entry;\n+    PRBool           firstEntry;     /* Is this the entry returned\n+                                      * by FindFirstFile()? */\n+    PRUint32         magic;          /* for debugging */\n };\n \n struct _MDCVar {\n-    PRUint32 unused;\n+    PRUint32         unused;\n };\n \n struct _MDSemaphore {\n-    HANDLE sem;\n+    HANDLE           sem;\n };\n \n struct _MDFileDesc {\n-    PROsfd osfd;               /* The osfd can come from one of three spaces:\n-                                * - For stdin, stdout, and stderr, we are using\n-                                *   the libc file handle (0, 1, 2), which is an int.\n-                                * - For files and pipes, we are using Win32 HANDLE,\n-                                *   which is a void*.\n-                                * - For sockets, we are using Winsock SOCKET, which\n-                                *   is a u_int.\n-                                */\n-    PRBool io_model_committed; /* The io model (blocking or nonblocking)\n-                                * for this osfd has been committed and\n-                                * cannot be changed.  The osfd has been\n-                                * either associated with the io\n-                                * completion port or made nonblocking. */\n-    PRBool sync_file_io;       /* Use synchronous file I/O on the osfd\n-                                * (a file handle) */\n-    PRBool accepted_socket;    /* Is this an accepted socket (on the\n-                                * server side)? */\n-    PRNetAddr peer_addr;       /* If this is an accepted socket, cache\n-                                * the peer's address returned by\n-                                * AcceptEx().  This is to work around\n-                                * the bug that getpeername() on an\n-                                * socket accepted by AcceptEx() returns\n-                                * an all-zero net address. */\n+    PROsfd osfd;     /* The osfd can come from one of three spaces:\n+                      * - For stdin, stdout, and stderr, we are using\n+                      *   the libc file handle (0, 1, 2), which is an int.\n+                      * - For files and pipes, we are using Win32 HANDLE,\n+                      *   which is a void*.\n+                      * - For sockets, we are using Winsock SOCKET, which\n+                      *   is a u_int.\n+                      */\n+    PRBool io_model_committed;  /* The io model (blocking or nonblocking)\n+                                 * for this osfd has been committed and\n+                                 * cannot be changed.  The osfd has been\n+                                 * either associated with the io\n+                                 * completion port or made nonblocking. */\n+    PRBool sync_file_io;        /* Use synchronous file I/O on the osfd\n+                                 * (a file handle) */\n+    PRBool accepted_socket;     /* Is this an accepted socket (on the\n+                                 * server side)? */\n+    PRNetAddr peer_addr;        /* If this is an accepted socket, cache\n+                                 * the peer's address returned by\n+                                 * AcceptEx().  This is to work around\n+                                 * the bug that getpeername() on an\n+                                 * socket accepted by AcceptEx() returns\n+                                 * an all-zero net address. */\n };\n \n struct _MDProcess {\n@@ -239,188 +242,189 @@ struct _MDProcess {\n     DWORD id;\n };\n \n+\n /* --- Misc stuff --- */\n-#define _MD_GET_SP(thread) (thread)->md.gcContext[6]\n+#define _MD_GET_SP(thread)            (thread)->md.gcContext[6]\n \n /* --- NT security stuff --- */\n \n extern void _PR_NT_InitSids(void);\n extern void _PR_NT_FreeSids(void);\n-extern PRStatus _PR_NT_MakeSecurityDescriptorACL(PRIntn mode,\n-                                                 DWORD accessTable[],\n-                                                 PSECURITY_DESCRIPTOR* resultSD,\n-                                                 PACL* resultACL);\n-extern void _PR_NT_FreeSecurityDescriptorACL(PSECURITY_DESCRIPTOR pSD,\n-                                             PACL pACL);\n+extern PRStatus _PR_NT_MakeSecurityDescriptorACL(\n+    PRIntn mode,\n+    DWORD accessTable[],\n+    PSECURITY_DESCRIPTOR *resultSD,\n+    PACL *resultACL\n+);\n+extern void _PR_NT_FreeSecurityDescriptorACL(\n+    PSECURITY_DESCRIPTOR pSD, PACL pACL);\n \n /* --- IO stuff --- */\n \n extern PRInt32 _md_Associate(HANDLE);\n extern PRInt32 _PR_MD_CLOSE(PROsfd osfd, PRBool socket);\n \n-#define _MD_OPEN _PR_MD_OPEN\n-#define _MD_OPEN_FILE _PR_MD_OPEN_FILE\n-#define _MD_READ _PR_MD_READ\n-#define _MD_WRITE _PR_MD_WRITE\n-#define _MD_WRITEV _PR_MD_WRITEV\n-#define _MD_LSEEK _PR_MD_LSEEK\n-#define _MD_LSEEK64 _PR_MD_LSEEK64\n-#define _MD_CLOSE_FILE(f) _PR_MD_CLOSE(f, PR_FALSE)\n-#define _MD_GETFILEINFO _PR_MD_GETFILEINFO\n-#define _MD_GETFILEINFO64 _PR_MD_GETFILEINFO64\n-#define _MD_GETOPENFILEINFO _PR_MD_GETOPENFILEINFO\n-#define _MD_GETOPENFILEINFO64 _PR_MD_GETOPENFILEINFO64\n-#define _MD_STAT _PR_MD_STAT\n-#define _MD_RENAME _PR_MD_RENAME\n-#define _MD_ACCESS _PR_MD_ACCESS\n-#define _MD_DELETE _PR_MD_DELETE\n-#define _MD_MKDIR _PR_MD_MKDIR\n-#define _MD_MAKE_DIR _PR_MD_MAKE_DIR\n-#define _MD_RMDIR _PR_MD_RMDIR\n-#define _MD_LOCKFILE _PR_MD_LOCKFILE\n-#define _MD_TLOCKFILE _PR_MD_TLOCKFILE\n-#define _MD_UNLOCKFILE _PR_MD_UNLOCKFILE\n+#define _MD_OPEN                      _PR_MD_OPEN\n+#define _MD_OPEN_FILE                 _PR_MD_OPEN_FILE\n+#define _MD_READ                      _PR_MD_READ\n+#define _MD_WRITE                     _PR_MD_WRITE\n+#define _MD_WRITEV                    _PR_MD_WRITEV\n+#define _MD_LSEEK                     _PR_MD_LSEEK\n+#define _MD_LSEEK64                   _PR_MD_LSEEK64\n+#define _MD_CLOSE_FILE(f)             _PR_MD_CLOSE(f, PR_FALSE)\n+#define _MD_GETFILEINFO               _PR_MD_GETFILEINFO\n+#define _MD_GETFILEINFO64             _PR_MD_GETFILEINFO64\n+#define _MD_GETOPENFILEINFO           _PR_MD_GETOPENFILEINFO\n+#define _MD_GETOPENFILEINFO64         _PR_MD_GETOPENFILEINFO64\n+#define _MD_STAT                      _PR_MD_STAT\n+#define _MD_RENAME                    _PR_MD_RENAME\n+#define _MD_ACCESS                    _PR_MD_ACCESS\n+#define _MD_DELETE                    _PR_MD_DELETE\n+#define _MD_MKDIR                     _PR_MD_MKDIR\n+#define _MD_MAKE_DIR                  _PR_MD_MAKE_DIR\n+#define _MD_RMDIR                     _PR_MD_RMDIR\n+#define _MD_LOCKFILE                  _PR_MD_LOCKFILE\n+#define _MD_TLOCKFILE                 _PR_MD_TLOCKFILE\n+#define _MD_UNLOCKFILE                _PR_MD_UNLOCKFILE\n \n /* --- Socket IO stuff --- */\n-#define _MD_GET_SOCKET_ERROR() WSAGetLastError()\n+#define _MD_GET_SOCKET_ERROR()    WSAGetLastError()\n #define _MD_SET_SOCKET_ERROR(_err) WSASetLastError(_err)\n \n #define _MD_INIT_FILEDESC(fd)\n-#define _MD_MAKE_NONBLOCK _PR_MD_MAKE_NONBLOCK\n-#define _MD_INIT_FD_INHERITABLE _PR_MD_INIT_FD_INHERITABLE\n-#define _MD_QUERY_FD_INHERITABLE _PR_MD_QUERY_FD_INHERITABLE\n-#define _MD_SHUTDOWN _PR_MD_SHUTDOWN\n-#define _MD_LISTEN _PR_MD_LISTEN\n-#define _MD_CLOSE_SOCKET(s) _PR_MD_CLOSE(s, PR_TRUE)\n-#define _MD_SENDTO _PR_MD_SENDTO\n-#define _MD_RECVFROM _PR_MD_RECVFROM\n+#define _MD_MAKE_NONBLOCK             _PR_MD_MAKE_NONBLOCK\n+#define _MD_INIT_FD_INHERITABLE       _PR_MD_INIT_FD_INHERITABLE\n+#define _MD_QUERY_FD_INHERITABLE      _PR_MD_QUERY_FD_INHERITABLE\n+#define _MD_SHUTDOWN                  _PR_MD_SHUTDOWN\n+#define _MD_LISTEN                    _PR_MD_LISTEN\n+#define _MD_CLOSE_SOCKET(s)           _PR_MD_CLOSE(s, PR_TRUE)\n+#define _MD_SENDTO                    _PR_MD_SENDTO\n+#define _MD_RECVFROM                  _PR_MD_RECVFROM\n #define _MD_SOCKETPAIR(s, type, proto, sv) -1\n-#define _MD_GETSOCKNAME _PR_MD_GETSOCKNAME\n-#define _MD_GETPEERNAME _PR_MD_GETPEERNAME\n-#define _MD_GETSOCKOPT _PR_MD_GETSOCKOPT\n-#define _MD_SETSOCKOPT _PR_MD_SETSOCKOPT\n-#define _MD_SELECT select\n-extern int _PR_NTFiberSafeSelect(int, fd_set*, fd_set*, fd_set*,\n-                                 const struct timeval*);\n-#define _MD_FSYNC _PR_MD_FSYNC\n-#define _MD_SOCKETAVAILABLE _PR_MD_SOCKETAVAILABLE\n-#define _MD_PIPEAVAILABLE _PR_MD_PIPEAVAILABLE\n-#define _MD_SET_FD_INHERITABLE _PR_MD_SET_FD_INHERITABLE\n+#define _MD_GETSOCKNAME               _PR_MD_GETSOCKNAME\n+#define _MD_GETPEERNAME               _PR_MD_GETPEERNAME\n+#define _MD_GETSOCKOPT                _PR_MD_GETSOCKOPT\n+#define _MD_SETSOCKOPT                _PR_MD_SETSOCKOPT\n+#define _MD_SELECT                    select\n+extern int _PR_NTFiberSafeSelect(int, fd_set *, fd_set *, fd_set *,\n+                                 const struct timeval *);\n+#define _MD_FSYNC                     _PR_MD_FSYNC\n+#define _MD_SOCKETAVAILABLE           _PR_MD_SOCKETAVAILABLE\n+#define _MD_PIPEAVAILABLE             _PR_MD_PIPEAVAILABLE\n+#define _MD_SET_FD_INHERITABLE        _PR_MD_SET_FD_INHERITABLE\n \n #define _MD_INIT_ATOMIC()\n #if defined(_M_IX86) || defined(_X86_)\n-#define _MD_ATOMIC_INCREMENT _PR_MD_ATOMIC_INCREMENT\n-#define _MD_ATOMIC_ADD _PR_MD_ATOMIC_ADD\n-#define _MD_ATOMIC_DECREMENT _PR_MD_ATOMIC_DECREMENT\n+#define _MD_ATOMIC_INCREMENT          _PR_MD_ATOMIC_INCREMENT\n+#define _MD_ATOMIC_ADD                _PR_MD_ATOMIC_ADD\n+#define _MD_ATOMIC_DECREMENT          _PR_MD_ATOMIC_DECREMENT\n #else /* non-x86 processors */\n-#define _MD_ATOMIC_INCREMENT(x) InterlockedIncrement((PLONG)x)\n-#define _MD_ATOMIC_ADD(ptr, val) \\\n-    (InterlockedExchangeAdd((PLONG)ptr, (LONG)val) + val)\n-#define _MD_ATOMIC_DECREMENT(x) InterlockedDecrement((PLONG)x)\n+#define _MD_ATOMIC_INCREMENT(x)       InterlockedIncrement((PLONG)x)\n+#define _MD_ATOMIC_ADD(ptr,val)    (InterlockedExchangeAdd((PLONG)ptr, (LONG)val) + val)\n+#define _MD_ATOMIC_DECREMENT(x)       InterlockedDecrement((PLONG)x)\n #endif /* x86 */\n-#define _MD_ATOMIC_SET(x, y) InterlockedExchange((PLONG)x, (LONG)y)\n+#define _MD_ATOMIC_SET(x,y)           InterlockedExchange((PLONG)x, (LONG)y)\n \n-#define _MD_INIT_IO _PR_MD_INIT_IO\n-#define _MD_SOCKET _PR_MD_SOCKET\n-#define _MD_CONNECT _PR_MD_CONNECT\n+#define _MD_INIT_IO                   _PR_MD_INIT_IO\n+#define _MD_SOCKET                    _PR_MD_SOCKET\n+#define _MD_CONNECT                   _PR_MD_CONNECT\n \n-#define _MD_ACCEPT(s, a, l, to) \\\n-    _MD_FAST_ACCEPT(s, a, l, to, PR_FALSE, NULL, NULL)\n+#define _MD_ACCEPT(s, a, l, to)       \\\n+        _MD_FAST_ACCEPT(s, a, l, to, PR_FALSE, NULL, NULL)\n #define _MD_FAST_ACCEPT(s, a, l, to, fast, cb, cba) \\\n-    _PR_MD_FAST_ACCEPT(s, a, l, to, fast, cb, cba)\n+        _PR_MD_FAST_ACCEPT(s, a, l, to, fast, cb, cba)\n #define _MD_ACCEPT_READ(s, ns, ra, buf, l, t) \\\n-    _MD_FAST_ACCEPT_READ(s, ns, ra, buf, l, t, PR_FALSE, NULL, NULL)\n+        _MD_FAST_ACCEPT_READ(s, ns, ra, buf, l, t, PR_FALSE, NULL, NULL)\n #define _MD_FAST_ACCEPT_READ(s, ns, ra, buf, l, t, fast, cb, cba) \\\n-    _PR_MD_FAST_ACCEPT_READ(s, ns, ra, buf, l, t, fast, cb, cba)\n-#define _MD_UPDATE_ACCEPT_CONTEXT _PR_MD_UPDATE_ACCEPT_CONTEXT\n+        _PR_MD_FAST_ACCEPT_READ(s, ns, ra, buf, l, t, fast, cb, cba)\n+#define _MD_UPDATE_ACCEPT_CONTEXT     _PR_MD_UPDATE_ACCEPT_CONTEXT\n \n-#define _MD_BIND _PR_MD_BIND\n-#define _MD_RECV _PR_MD_RECV\n-#define _MD_SEND _PR_MD_SEND\n-#define _MD_SENDFILE _PR_MD_SENDFILE\n-#define _MD_PR_POLL _PR_MD_PR_POLL\n+#define _MD_BIND                      _PR_MD_BIND\n+#define _MD_RECV                      _PR_MD_RECV\n+#define _MD_SEND                      _PR_MD_SEND\n+#define _MD_SENDFILE                  _PR_MD_SENDFILE\n+#define _MD_PR_POLL                   _PR_MD_PR_POLL\n \n /* --- Scheduler stuff --- */\n-#define _MD_PAUSE_CPU _PR_MD_PAUSE_CPU\n+#define _MD_PAUSE_CPU                   _PR_MD_PAUSE_CPU\n \n /* --- DIR stuff --- */\n-#define PR_DIRECTORY_SEPARATOR '\\\\'\n-#define PR_DIRECTORY_SEPARATOR_STR \"\\\\\"\n-#define PR_PATH_SEPARATOR ';'\n-#define PR_PATH_SEPARATOR_STR \";\"\n-#define _MD_ERRNO() GetLastError()\n-#define _MD_OPEN_DIR _PR_MD_OPEN_DIR\n-#define _MD_CLOSE_DIR _PR_MD_CLOSE_DIR\n-#define _MD_READ_DIR _PR_MD_READ_DIR\n+#define PR_DIRECTORY_SEPARATOR        '\\\\'\n+#define PR_DIRECTORY_SEPARATOR_STR    \"\\\\\"\n+#define PR_PATH_SEPARATOR       ';'\n+#define PR_PATH_SEPARATOR_STR       \";\"\n+#define _MD_ERRNO()                   GetLastError()\n+#define _MD_OPEN_DIR                  _PR_MD_OPEN_DIR\n+#define _MD_CLOSE_DIR                 _PR_MD_CLOSE_DIR\n+#define _MD_READ_DIR                  _PR_MD_READ_DIR\n \n /* --- Segment stuff --- */\n #define _MD_INIT_SEGS()\n-#define _MD_ALLOC_SEGMENT(seg, size, vaddr) 0\n+#define _MD_ALLOC_SEGMENT(seg, size, vaddr)   0\n #define _MD_FREE_SEGMENT(seg)\n \n /* --- Environment Stuff --- */\n-#define _MD_GET_ENV _PR_MD_GET_ENV\n-#define _MD_PUT_ENV _PR_MD_PUT_ENV\n+#define _MD_GET_ENV                 _PR_MD_GET_ENV\n+#define _MD_PUT_ENV                 _PR_MD_PUT_ENV\n \n /* --- Threading Stuff --- */\n-#define _MD_DEFAULT_STACK_SIZE 0\n-#define _MD_INIT_THREAD _PR_MD_INIT_THREAD\n-#define _MD_INIT_ATTACHED_THREAD _PR_MD_INIT_THREAD\n-#define _MD_CREATE_THREAD _PR_MD_CREATE_THREAD\n-#define _MD_JOIN_THREAD _PR_MD_JOIN_THREAD\n-#define _MD_END_THREAD _PR_MD_END_THREAD\n-#define _MD_YIELD _PR_MD_YIELD\n-#define _MD_SET_PRIORITY _PR_MD_SET_PRIORITY\n+#define _MD_DEFAULT_STACK_SIZE            0\n+#define _MD_INIT_THREAD             _PR_MD_INIT_THREAD\n+#define _MD_INIT_ATTACHED_THREAD    _PR_MD_INIT_THREAD\n+#define _MD_CREATE_THREAD           _PR_MD_CREATE_THREAD\n+#define _MD_JOIN_THREAD             _PR_MD_JOIN_THREAD\n+#define _MD_END_THREAD              _PR_MD_END_THREAD\n+#define _MD_YIELD                   _PR_MD_YIELD\n+#define _MD_SET_PRIORITY            _PR_MD_SET_PRIORITY\n #define _MD_SET_CURRENT_THREAD_NAME _PR_MD_SET_CURRENT_THREAD_NAME\n-#define _MD_CLEAN_THREAD _PR_MD_CLEAN_THREAD\n-#define _MD_SETTHREADAFFINITYMASK _PR_MD_SETTHREADAFFINITYMASK\n-#define _MD_GETTHREADAFFINITYMASK _PR_MD_GETTHREADAFFINITYMASK\n-#define _MD_EXIT_THREAD _PR_MD_EXIT_THREAD\n-#define _MD_SUSPEND_THREAD _PR_MD_SUSPEND_THREAD\n-#define _MD_RESUME_THREAD _PR_MD_RESUME_THREAD\n-#define _MD_SUSPEND_CPU _PR_MD_SUSPEND_CPU\n-#define _MD_RESUME_CPU _PR_MD_RESUME_CPU\n+#define _MD_CLEAN_THREAD            _PR_MD_CLEAN_THREAD\n+#define _MD_SETTHREADAFFINITYMASK   _PR_MD_SETTHREADAFFINITYMASK\n+#define _MD_GETTHREADAFFINITYMASK   _PR_MD_GETTHREADAFFINITYMASK\n+#define _MD_EXIT_THREAD             _PR_MD_EXIT_THREAD\n+#define _MD_SUSPEND_THREAD          _PR_MD_SUSPEND_THREAD\n+#define _MD_RESUME_THREAD           _PR_MD_RESUME_THREAD\n+#define _MD_SUSPEND_CPU             _PR_MD_SUSPEND_CPU\n+#define _MD_RESUME_CPU              _PR_MD_RESUME_CPU\n #define _MD_BEGIN_SUSPEND_ALL()\n #define _MD_BEGIN_RESUME_ALL()\n #define _MD_END_SUSPEND_ALL()\n #define _MD_END_RESUME_ALL()\n \n-extern void _PR_Unblock_IO_Wait(PRThread* thr);\n+extern void _PR_Unblock_IO_Wait(PRThread *thr);\n \n /* --- Lock stuff --- */\n-#define _MD_NEW_LOCK(lock) \\\n-    (InitializeCriticalSection(&((lock)->mutex)), PR_SUCCESS)\n-#define _MD_FREE_LOCK(lock) DeleteCriticalSection(&((lock)->mutex))\n+#define _MD_NEW_LOCK(lock)            (InitializeCriticalSection(&((lock)->mutex)),PR_SUCCESS)\n+#define _MD_FREE_LOCK(lock)           DeleteCriticalSection(&((lock)->mutex))\n #ifndef PROFILE_LOCKS\n-#define _MD_LOCK(lock) EnterCriticalSection(&((lock)->mutex))\n-#define _MD_TEST_AND_LOCK(lock) \\\n-    (TryEnterCriticalSection(&((lock)->mutex)) == FALSE)\n-#define _MD_UNLOCK(lock) LeaveCriticalSection(&((lock)->mutex))\n+#define _MD_LOCK(lock)                EnterCriticalSection(&((lock)->mutex))\n+#define _MD_TEST_AND_LOCK(lock)       (TryEnterCriticalSection(&((lock)->mutex))== FALSE)\n+#define _MD_UNLOCK(lock)              LeaveCriticalSection(&((lock)->mutex))\n #else\n-#define _MD_LOCK(lock)                                   \\\n-    PR_BEGIN_MACRO                                       \\\n+#define _MD_LOCK(lock)                 \\\n+    PR_BEGIN_MACRO \\\n     BOOL rv = TryEnterCriticalSection(&((lock)->mutex)); \\\n-    if (rv == TRUE) {                                    \\\n-        InterlockedIncrement(&((lock)->hitcount));       \\\n-    } else {                                             \\\n-        InterlockedIncrement(&((lock)->misscount));      \\\n-        EnterCriticalSection(&((lock)->mutex));          \\\n-    }                                                    \\\n+    if (rv == TRUE) { \\\n+        InterlockedIncrement(&((lock)->hitcount)); \\\n+    } else { \\\n+        InterlockedIncrement(&((lock)->misscount)); \\\n+        EnterCriticalSection(&((lock)->mutex)); \\\n+    } \\\n     PR_END_MACRO\n-#define _MD_TEST_AND_LOCK(lock) 0 /* XXXMB */\n-#define _MD_UNLOCK(lock) LeaveCriticalSection(&((lock)->mutex))\n+#define _MD_TEST_AND_LOCK(lock)       0  /* XXXMB */\n+#define _MD_UNLOCK(lock)              LeaveCriticalSection(&((lock)->mutex))\n #endif\n-#define _PR_LOCK _MD_LOCK\n-#define _PR_UNLOCK _MD_UNLOCK\n+#define _PR_LOCK                      _MD_LOCK\n+#define _PR_UNLOCK                    _MD_UNLOCK\n \n /* --- lock and cv waiting --- */\n-#define _MD_WAIT _PR_MD_WAIT\n-#define _MD_WAKEUP_WAITER _PR_MD_WAKEUP_WAITER\n+#define _MD_WAIT                      _PR_MD_WAIT\n+#define _MD_WAKEUP_WAITER             _PR_MD_WAKEUP_WAITER\n \n /* XXXMB- the IOQ stuff is certainly not working correctly yet. */\n-extern struct _MDLock _pr_ioq_lock;\n-#define _MD_IOQ_LOCK() _MD_LOCK(&_pr_ioq_lock)\n-#define _MD_IOQ_UNLOCK() _MD_UNLOCK(&_pr_ioq_lock)\n+extern  struct _MDLock              _pr_ioq_lock;\n+#define _MD_IOQ_LOCK()                _MD_LOCK(&_pr_ioq_lock)\n+#define _MD_IOQ_UNLOCK()              _MD_UNLOCK(&_pr_ioq_lock)\n+\n \n /* --- Initialization stuff --- */\n #define _MD_START_INTERRUPTS()\n@@ -429,7 +433,7 @@ extern struct _MDLock _pr_ioq_lock;\n #define _MD_ENABLE_CLOCK_INTERRUPTS()\n #define _MD_BLOCK_CLOCK_INTERRUPTS()\n #define _MD_UNBLOCK_CLOCK_INTERRUPTS()\n-#define _MD_EARLY_INIT _PR_MD_EARLY_INIT\n+#define _MD_EARLY_INIT                _PR_MD_EARLY_INIT\n #define _MD_FINAL_INIT()\n #define _MD_EARLY_CLEANUP()\n #define _MD_INIT_CPUS()\n@@ -440,108 +444,112 @@ struct PRProcessAttr;\n \n /* --- Create a new process --- */\n #define _MD_CREATE_PROCESS _PR_CreateWindowsProcess\n-extern struct PRProcess* _PR_CreateWindowsProcess(\n-    const char* path, char* const* argv, char* const* envp,\n-    const struct PRProcessAttr* attr);\n+extern struct PRProcess * _PR_CreateWindowsProcess(\n+    const char *path,\n+    char *const *argv,\n+    char *const *envp,\n+    const struct PRProcessAttr *attr\n+);\n \n #define _MD_DETACH_PROCESS _PR_DetachWindowsProcess\n-extern PRStatus _PR_DetachWindowsProcess(struct PRProcess* process);\n+extern PRStatus _PR_DetachWindowsProcess(struct PRProcess *process);\n \n /* --- Wait for a child process to terminate --- */\n #define _MD_WAIT_PROCESS _PR_WaitWindowsProcess\n-extern PRStatus _PR_WaitWindowsProcess(struct PRProcess* process,\n-                                       PRInt32* exitCode);\n+extern PRStatus _PR_WaitWindowsProcess(struct PRProcess *process,\n+                                       PRInt32 *exitCode);\n \n #define _MD_KILL_PROCESS _PR_KillWindowsProcess\n-extern PRStatus _PR_KillWindowsProcess(struct PRProcess* process);\n+extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process);\n \n /* --- User Threading stuff --- */\n #define HAVE_FIBERS\n-#define _MD_CREATE_USER_THREAD _PR_MD_CREATE_USER_THREAD\n+#define _MD_CREATE_USER_THREAD            _PR_MD_CREATE_USER_THREAD\n #define _MD_CREATE_PRIMORDIAL_USER_THREAD _PR_MD_CREATE_PRIMORDIAL_USER_THREAD\n-#define _MD_CLEANUP_BEFORE_EXIT _PR_MD_CLEANUP_BEFORE_EXIT\n-#define _MD_EXIT _PR_MD_EXIT\n-#define _MD_INIT_CONTEXT _PR_MD_INIT_CONTEXT\n-#define _MD_SWITCH_CONTEXT _PR_MD_SWITCH_CONTEXT\n-#define _MD_RESTORE_CONTEXT _PR_MD_RESTORE_CONTEXT\n+#define _MD_CLEANUP_BEFORE_EXIT           _PR_MD_CLEANUP_BEFORE_EXIT\n+#define _MD_EXIT                          _PR_MD_EXIT\n+#define _MD_INIT_CONTEXT                  _PR_MD_INIT_CONTEXT\n+#define _MD_SWITCH_CONTEXT                _PR_MD_SWITCH_CONTEXT\n+#define _MD_RESTORE_CONTEXT               _PR_MD_RESTORE_CONTEXT\n \n /* --- Intervals --- */\n-#define _MD_INTERVAL_INIT _PR_MD_INTERVAL_INIT\n-#define _MD_GET_INTERVAL _PR_MD_GET_INTERVAL\n-#define _MD_INTERVAL_PER_SEC _PR_MD_INTERVAL_PER_SEC\n-#define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000)\n-#define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000)\n+#define _MD_INTERVAL_INIT                 _PR_MD_INTERVAL_INIT\n+#define _MD_GET_INTERVAL                  _PR_MD_GET_INTERVAL\n+#define _MD_INTERVAL_PER_SEC              _PR_MD_INTERVAL_PER_SEC\n+#define _MD_INTERVAL_PER_MILLISEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000)\n+#define _MD_INTERVAL_PER_MICROSEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000000)\n \n /* --- Time --- */\n-extern void _PR_FileTimeToPRTime(const FILETIME* filetime, PRTime* prtm);\n+extern void _PR_FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm);\n \n /* --- Native-Thread Specific Definitions ------------------------------- */\n \n extern BOOL _pr_use_static_tls;\n \n-extern __declspec(thread) struct PRThread* _pr_current_fiber;\n+extern __declspec(thread) struct PRThread *_pr_current_fiber;\n extern DWORD _pr_currentFiberIndex;\n \n-#define _MD_GET_ATTACHED_THREAD()           \\\n+#define _MD_GET_ATTACHED_THREAD() \\\n     (_pr_use_static_tls ? _pr_current_fiber \\\n-                        : (PRThread*)TlsGetValue(_pr_currentFiberIndex))\n+    : (PRThread *) TlsGetValue(_pr_currentFiberIndex))\n \n-extern struct PRThread* _MD_CURRENT_THREAD(void);\n+extern struct PRThread * _MD_CURRENT_THREAD(void);\n \n-#define _MD_SET_CURRENT_THREAD(_thread)                \\\n-    PR_BEGIN_MACRO                                     \\\n-    if (_pr_use_static_tls) {                          \\\n-        _pr_current_fiber = (_thread);                 \\\n-    } else {                                           \\\n-        TlsSetValue(_pr_currentFiberIndex, (_thread)); \\\n-    }                                                  \\\n+#define _MD_SET_CURRENT_THREAD(_thread) \\\n+    PR_BEGIN_MACRO \\\n+        if (_pr_use_static_tls) { \\\n+            _pr_current_fiber = (_thread); \\\n+        } else { \\\n+            TlsSetValue(_pr_currentFiberIndex, (_thread)); \\\n+        } \\\n     PR_END_MACRO\n \n-extern __declspec(thread) struct PRThread* _pr_fiber_last_run;\n+extern __declspec(thread) struct PRThread *_pr_fiber_last_run;\n extern DWORD _pr_lastFiberIndex;\n \n-#define _MD_LAST_THREAD()                    \\\n+#define _MD_LAST_THREAD() \\\n     (_pr_use_static_tls ? _pr_fiber_last_run \\\n-                        : (PRThread*)TlsGetValue(_pr_lastFiberIndex))\n-\n-#define _MD_SET_LAST_THREAD(_thread)                \\\n-    PR_BEGIN_MACRO                                  \\\n-    if (_pr_use_static_tls) {                       \\\n-        _pr_fiber_last_run = (_thread);             \\\n-    } else {                                        \\\n-        TlsSetValue(_pr_lastFiberIndex, (_thread)); \\\n-    }                                               \\\n+    : (PRThread *) TlsGetValue(_pr_lastFiberIndex))\n+\n+#define _MD_SET_LAST_THREAD(_thread) \\\n+    PR_BEGIN_MACRO \\\n+        if (_pr_use_static_tls) { \\\n+            _pr_fiber_last_run = (_thread); \\\n+        } else { \\\n+            TlsSetValue(_pr_lastFiberIndex, (_thread)); \\\n+        } \\\n     PR_END_MACRO\n \n-extern __declspec(thread) struct _PRCPU* _pr_current_cpu;\n+extern __declspec(thread) struct _PRCPU *_pr_current_cpu;\n extern DWORD _pr_currentCPUIndex;\n \n-#define _MD_CURRENT_CPU()                 \\\n+#define _MD_CURRENT_CPU() \\\n     (_pr_use_static_tls ? _pr_current_cpu \\\n-                        : (struct _PRCPU*)TlsGetValue(_pr_currentCPUIndex))\n-\n-#define _MD_SET_CURRENT_CPU(_cpu)                 \\\n-    PR_BEGIN_MACRO                                \\\n-    if (_pr_use_static_tls) {                     \\\n-        _pr_current_cpu = (_cpu);                 \\\n-    } else {                                      \\\n-        TlsSetValue(_pr_currentCPUIndex, (_cpu)); \\\n-    }                                             \\\n+    : (struct _PRCPU *) TlsGetValue(_pr_currentCPUIndex))\n+\n+#define _MD_SET_CURRENT_CPU(_cpu) \\\n+    PR_BEGIN_MACRO \\\n+        if (_pr_use_static_tls) { \\\n+            _pr_current_cpu = (_cpu); \\\n+        } else { \\\n+            TlsSetValue(_pr_currentCPUIndex, (_cpu)); \\\n+        } \\\n     PR_END_MACRO\n \n extern __declspec(thread) PRUintn _pr_ints_off;\n extern DWORD _pr_intsOffIndex;\n \n #define _MD_GET_INTSOFF() \\\n-    (_pr_use_static_tls ? _pr_ints_off : (PRUintn)TlsGetValue(_pr_intsOffIndex))\n-\n-#define _MD_SET_INTSOFF(_val)                          \\\n-    PR_BEGIN_MACRO                                     \\\n-    if (_pr_use_static_tls) {                          \\\n-        _pr_ints_off = (_val);                         \\\n-    } else {                                           \\\n-        TlsSetValue(_pr_intsOffIndex, (LPVOID)(_val)); \\\n-    }                                                  \\\n+    (_pr_use_static_tls ? _pr_ints_off \\\n+    : (PRUintn) TlsGetValue(_pr_intsOffIndex))\n+\n+#define _MD_SET_INTSOFF(_val) \\\n+    PR_BEGIN_MACRO \\\n+        if (_pr_use_static_tls) { \\\n+            _pr_ints_off = (_val); \\\n+        } else { \\\n+            TlsSetValue(_pr_intsOffIndex, (LPVOID) (_val)); \\\n+        } \\\n     PR_END_MACRO\n \n /* --- Initialization stuff --- */\n@@ -558,30 +566,34 @@ struct _MDFileMap {\n     DWORD dwAccess;\n };\n \n-extern PRStatus _MD_CreateFileMap(struct PRFileMap* fmap, PRInt64 size);\n+extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);\n #define _MD_CREATE_FILE_MAP _MD_CreateFileMap\n \n extern PRInt32 _MD_GetMemMapAlignment(void);\n #define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment\n \n-extern void* _MD_MemMap(struct PRFileMap* fmap, PRInt64 offset, PRUint32 len);\n+extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,\n+                         PRUint32 len);\n #define _MD_MEM_MAP _MD_MemMap\n \n-extern PRStatus _MD_MemUnmap(void* addr, PRUint32 size);\n+extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);\n #define _MD_MEM_UNMAP _MD_MemUnmap\n \n-extern PRStatus _MD_CloseFileMap(struct PRFileMap* fmap);\n+extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);\n #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap\n \n-extern PRStatus _MD_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len);\n+extern PRStatus _MD_SyncMemMap(\n+    PRFileDesc *fd,\n+    void *addr,\n+    PRUint32 len);\n #define _MD_SYNC_MEM_MAP _MD_SyncMemMap\n \n /* --- Named semaphores stuff --- */\n #define _PR_HAVE_NAMED_SEMAPHORES\n-#define _MD_OPEN_SEMAPHORE _PR_MD_OPEN_SEMAPHORE\n-#define _MD_WAIT_SEMAPHORE _PR_MD_WAIT_SEMAPHORE\n-#define _MD_POST_SEMAPHORE _PR_MD_POST_SEMAPHORE\n-#define _MD_CLOSE_SEMAPHORE _PR_MD_CLOSE_SEMAPHORE\n-#define _MD_DELETE_SEMAPHORE(name) PR_SUCCESS /* no op */\n+#define _MD_OPEN_SEMAPHORE            _PR_MD_OPEN_SEMAPHORE\n+#define _MD_WAIT_SEMAPHORE            _PR_MD_WAIT_SEMAPHORE\n+#define _MD_POST_SEMAPHORE            _PR_MD_POST_SEMAPHORE\n+#define _MD_CLOSE_SEMAPHORE           _PR_MD_CLOSE_SEMAPHORE\n+#define _MD_DELETE_SEMAPHORE(name)    PR_SUCCESS  /* no op */\n \n #endif /* nspr_win32_defs_h___ */\ndiff --git a/nspr/pr/include/md/prosdep.h b/nspr/pr/include/md/prosdep.h\nindex 9b8167a..0eeb48d 100644\n--- a/nspr/pr/include/md/prosdep.h\n+++ b/nspr/pr/include/md/prosdep.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/nspr.h b/nspr/pr/include/nspr.h\nindex 6a612f9..0cbc71c 100644\n--- a/nspr/pr/include/nspr.h\n+++ b/nspr/pr/include/nspr.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/obsolete/.cvsignore b/nspr/pr/include/obsolete/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/include/obsolete/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/include/obsolete/pralarm.h b/nspr/pr/include/obsolete/pralarm.h\nindex 96fa68f..9ae3a4b 100644\n--- a/nspr/pr/include/obsolete/pralarm.h\n+++ b/nspr/pr/include/obsolete/pralarm.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -32,6 +33,7 @@\n #include \"prtypes.h\"\n #include \"prinrval.h\"\n \n+\n PR_BEGIN_EXTERN_C\n \n /**********************************************************************/\n@@ -41,8 +43,8 @@ PR_BEGIN_EXTERN_C\n typedef struct PRAlarm PRAlarm;\n typedef struct PRAlarmID PRAlarmID;\n \n-typedef PRBool(PR_CALLBACK* PRPeriodicAlarmFn)(PRAlarmID* id, void* clientData,\n-                                               PRUint32 late);\n+typedef PRBool (PR_CALLBACK *PRPeriodicAlarmFn)(\n+    PRAlarmID *id, void *clientData, PRUint32 late);\n \n /**********************************************************************/\n /****************************** FUNCTIONS *****************************/\n@@ -66,8 +68,7 @@ typedef PRBool(PR_CALLBACK* PRPeriodicAlarmFn)(PRAlarmID* id, void* clientData,\n ** MEMORY:      The object (PRAlarm) and a thread to support notifications.\n ** ALGORITHM:   N/A\n ***********************************************************************/\n-NSPR_API(PRAlarm*)\n-PR_CreateAlarm(void);\n+NSPR_API(PRAlarm*) PR_CreateAlarm(void);\n \n /***********************************************************************\n ** FUNCTION:    PR_DestroyAlarm\n@@ -87,8 +88,7 @@ PR_CreateAlarm(void);\n ** MEMORY:      N/A\n ** ALGORITHM:   N/A\n ***********************************************************************/\n-NSPR_API(PRStatus)\n-PR_DestroyAlarm(PRAlarm* alarm);\n+NSPR_API(PRStatus) PR_DestroyAlarm(PRAlarm *alarm);\n \n /***********************************************************************\n ** FUNCTION:    PR_SetAlarm\n@@ -126,9 +126,9 @@ PR_DestroyAlarm(PRAlarm* alarm);\n **              The amount of lateness of one notification is taken into\n **              account on the next in an attempt to avoid long term slew.\n ***********************************************************************/\n-NSPR_API(PRAlarmID*)\n-PR_SetAlarm(PRAlarm* alarm, PRIntervalTime period, PRUint32 rate,\n-            PRPeriodicAlarmFn function, void* clientData);\n+NSPR_API(PRAlarmID*) PR_SetAlarm(\n+    PRAlarm *alarm, PRIntervalTime period, PRUint32 rate,\n+    PRPeriodicAlarmFn function, void *clientData);\n \n /***********************************************************************\n ** FUNCTION:    PR_ResetAlarm\n@@ -152,8 +152,8 @@ PR_SetAlarm(PRAlarm* alarm, PRIntervalTime period, PRUint32 rate,\n ** MEMORY:      N/A.\n ** ALGORITHM:   See PR_SetAlarm().\n ***********************************************************************/\n-NSPR_API(PRStatus)\n-PR_ResetAlarm(PRAlarmID* id, PRIntervalTime period, PRUint32 rate);\n+NSPR_API(PRStatus) PR_ResetAlarm(\n+    PRAlarmID *id, PRIntervalTime period, PRUint32 rate);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/obsolete/probslet.h b/nspr/pr/include/obsolete/probslet.h\nindex 6af4e63..db743c5 100644\n--- a/nspr/pr/include/obsolete/probslet.h\n+++ b/nspr/pr/include/obsolete/probslet.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,7 +12,7 @@\n #define PROBSLET_H\n \n #include \"prio.h\"\n-#include \"private/pprio.h\" /* for PROsfd */\n+#include \"private/pprio.h\"  /* for PROsfd */\n \n PR_BEGIN_EXTERN_C\n \n@@ -19,8 +20,7 @@ PR_BEGIN_EXTERN_C\n ** Yield the current thread.  The proper function to use in place of\n ** PR_Yield() is PR_Sleep() with an argument of PR_INTERVAL_NO_WAIT.\n */\n-NSPR_API(PRStatus)\n-PR_Yield(void);\n+NSPR_API(PRStatus) PR_Yield(void);\n \n /************************************************************************/\n /************* The following definitions are for select *****************/\n@@ -36,10 +36,10 @@ PR_Yield(void);\n #define PR_MAX_SELECT_DESC 1024\n #endif\n typedef struct PR_fd_set {\n-    PRUint32 hsize;\n-    PRFileDesc* harray[PR_MAX_SELECT_DESC];\n-    PRUint32 nsize;\n-    PROsfd narray[PR_MAX_SELECT_DESC];\n+    PRUint32      hsize;\n+    PRFileDesc   *harray[PR_MAX_SELECT_DESC];\n+    PRUint32      nsize;\n+    PROsfd        narray[PR_MAX_SELECT_DESC];\n } PR_fd_set;\n \n /*\n@@ -48,13 +48,10 @@ typedef struct PR_fd_set {\n ** DESCRIPTION:\n **\n ** The call returns as soon as I/O is ready on one or more of the underlying\n-** file/socket descriptors or an exceptional condition is pending. A count of\n-* the\n+** file/socket descriptors or an exceptional condition is pending. A count of the\n ** number of ready descriptors is returned unless a timeout occurs in which case\n-** zero is returned.  On return, PR_Select replaces the given descriptor sets\n-* with\n-** subsets consisting of those descriptors that are ready for the requested\n-* condition.\n+** zero is returned.  On return, PR_Select replaces the given descriptor sets with\n+** subsets consisting of those descriptors that are ready for the requested condition.\n ** The total number of ready descriptors in all the sets is the return value.\n **\n ** INPUTS:\n@@ -100,9 +97,9 @@ typedef struct PR_fd_set {\n ** XXX can we implement this on windoze and mac?\n **************************************************************************\n */\n-NSPR_API(PRInt32)\n-PR_Select(PRInt32 num, PR_fd_set* readfds, PR_fd_set* writefds,\n-          PR_fd_set* exceptfds, PRIntervalTime timeout);\n+NSPR_API(PRInt32) PR_Select(\n+    PRInt32 num, PR_fd_set *readfds, PR_fd_set *writefds,\n+    PR_fd_set *exceptfds, PRIntervalTime timeout);\n \n /*\n ** The following are not thread safe for two threads operating on them at the\n@@ -118,42 +115,31 @@ PR_Select(PRInt32 num, PR_fd_set* readfds, PR_fd_set* writefds,\n ** PR_FD_NSET(osfd, &fdset) includes a particular native file descriptor osfd\n ** in fdset.\n ** PR_FD_NCLR(osfd, &fdset) removes a native file descriptor osfd from fdset.\n-** PR_FD_NISSET(osfd, &fdset) is nonzero if native file descriptor osfd is a\n-* member of\n+** PR_FD_NISSET(osfd, &fdset) is nonzero if native file descriptor osfd is a member of\n ** fdset, zero otherwise.\n */\n \n-NSPR_API(void)\n-PR_FD_ZERO(PR_fd_set* set);\n-NSPR_API(void)\n-PR_FD_SET(PRFileDesc* fd, PR_fd_set* set);\n-NSPR_API(void)\n-PR_FD_CLR(PRFileDesc* fd, PR_fd_set* set);\n-NSPR_API(PRInt32)\n-PR_FD_ISSET(PRFileDesc* fd, PR_fd_set* set);\n-NSPR_API(void)\n-PR_FD_NSET(PROsfd osfd, PR_fd_set* set);\n-NSPR_API(void)\n-PR_FD_NCLR(PROsfd osfd, PR_fd_set* set);\n-NSPR_API(PRInt32)\n-PR_FD_NISSET(PROsfd osfd, PR_fd_set* set);\n+NSPR_API(void)        PR_FD_ZERO(PR_fd_set *set);\n+NSPR_API(void)        PR_FD_SET(PRFileDesc *fd, PR_fd_set *set);\n+NSPR_API(void)        PR_FD_CLR(PRFileDesc *fd, PR_fd_set *set);\n+NSPR_API(PRInt32)     PR_FD_ISSET(PRFileDesc *fd, PR_fd_set *set);\n+NSPR_API(void)        PR_FD_NSET(PROsfd osfd, PR_fd_set *set);\n+NSPR_API(void)        PR_FD_NCLR(PROsfd osfd, PR_fd_set *set);\n+NSPR_API(PRInt32)     PR_FD_NISSET(PROsfd osfd, PR_fd_set *set);\n \n /*\n ** The next two entry points should not be in the API, but they are\n ** declared here for historical reasons.\n */\n \n-NSPR_API(PRInt32)\n-PR_GetSysfdTableMax(void);\n+NSPR_API(PRInt32) PR_GetSysfdTableMax(void);\n \n-NSPR_API(PRInt32)\n-PR_SetSysfdTableSize(PRIntn table_size);\n+NSPR_API(PRInt32) PR_SetSysfdTableSize(PRIntn table_size);\n \n #ifndef NO_NSPR_10_SUPPORT\n #include <sys/stat.h>\n \n-NSPR_API(PRInt32)\n-PR_Stat(const char* path, struct stat* buf);\n+NSPR_API(PRInt32) PR_Stat(const char *path, struct stat *buf);\n #endif /* NO_NSPR_10_SUPPORT */\n \n PR_END_EXTERN_C\ndiff --git a/nspr/pr/include/obsolete/protypes.h b/nspr/pr/include/obsolete/protypes.h\nindex d801304..4ebf9b4 100644\n--- a/nspr/pr/include/obsolete/protypes.h\n+++ b/nspr/pr/include/obsolete/protypes.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -91,7 +92,8 @@ typedef PRInt64 int64;\n  * int32\n  */\n \n-#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES) && !defined(HPUX)\n+#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \\\n+    && !defined(HPUX)\n #if !defined(_WIN32) && !defined(NTO)\n typedef PRInt32 int32;\n #else\n@@ -103,7 +105,8 @@ typedef long int32;\n  * int16\n  */\n \n-#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES) && !defined(HPUX)\n+#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \\\n+    && !defined(HPUX)\n typedef PRInt16 int16;\n #endif\n \n@@ -111,7 +114,8 @@ typedef PRInt16 int16;\n  * int8\n  */\n \n-#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES) && !defined(HPUX)\n+#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \\\n+    && !defined(HPUX)\n typedef PRInt8 int8;\n #endif\n \n@@ -120,10 +124,11 @@ typedef PRUptrdiff uptrdiff_t;\n typedef PRUword uprword_t;\n typedef PRWord prword_t;\n \n+\n /* Re: prbit.h */\n-#define TEST_BIT PR_TEST_BIT\n-#define SET_BIT PR_SET_BIT\n-#define CLEAR_BIT PR_CLEAR_BIT\n+#define TEST_BIT    PR_TEST_BIT\n+#define SET_BIT     PR_SET_BIT\n+#define CLEAR_BIT   PR_CLEAR_BIT\n \n /* Re: prarena.h->plarena.h */\n #define PRArena PLArena\ndiff --git a/nspr/pr/include/obsolete/prsem.h b/nspr/pr/include/obsolete/prsem.h\nindex 049933f..d1981d2 100644\n--- a/nspr/pr/include/obsolete/prsem.h\n+++ b/nspr/pr/include/obsolete/prsem.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -19,15 +20,13 @@ typedef struct PRSemaphore PRSemaphore;\n /*\n ** Create a new semaphore object.\n */\n-NSPR_API(PRSemaphore*)\n-PR_NewSem(PRUintn value);\n+NSPR_API(PRSemaphore*) PR_NewSem(PRUintn value);\n \n /*\n ** Destroy the given semaphore object.\n **\n */\n-NSPR_API(void)\n-PR_DestroySem(PRSemaphore* sem);\n+NSPR_API(void) PR_DestroySem(PRSemaphore *sem);\n \n /*\n ** Wait on a Semaphore.\n@@ -43,16 +42,14 @@ PR_DestroySem(PRSemaphore* sem);\n ** This routine can return PR_PENDING_INTERRUPT if the waiting thread\n ** has been interrupted.\n */\n-NSPR_API(PRStatus)\n-PR_WaitSem(PRSemaphore* sem);\n+NSPR_API(PRStatus) PR_WaitSem(PRSemaphore *sem);\n \n /*\n ** This routine increments the counter value of the semaphore. If other threads\n ** are blocked for the semaphore, then the scheduler will determine which ONE\n ** thread will be unblocked.\n */\n-NSPR_API(void)\n-PR_PostSem(PRSemaphore* sem);\n+NSPR_API(void) PR_PostSem(PRSemaphore *sem);\n \n /*\n ** Returns the value of the semaphore referenced by sem without affecting\n@@ -60,8 +57,7 @@ PR_PostSem(PRSemaphore* sem);\n F** at the time of the call, but may not be the actual value when the\n ** caller inspects it.\n */\n-NSPR_API(PRUintn)\n-PR_GetValueSem(PRSemaphore* sem);\n+NSPR_API(PRUintn) PR_GetValueSem(PRSemaphore *sem);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/pratom.h b/nspr/pr/include/pratom.h\nindex 86f3d4a..5ced3c2 100644\n--- a/nspr/pr/include/pratom.h\n+++ b/nspr/pr/include/pratom.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -24,8 +25,7 @@ PR_BEGIN_EXTERN_C\n ** RETURN:\n **    the returned value is the result of the increment\n */\n-NSPR_API(PRInt32)\n-PR_AtomicIncrement(PRInt32* val);\n+NSPR_API(PRInt32)   PR_AtomicIncrement(PRInt32 *val);\n \n /*\n ** FUNCTION: PR_AtomicDecrement\n@@ -36,8 +36,7 @@ PR_AtomicIncrement(PRInt32* val);\n ** RETURN:\n **    the returned value is the result of the decrement\n */\n-NSPR_API(PRInt32)\n-PR_AtomicDecrement(PRInt32* val);\n+NSPR_API(PRInt32)   PR_AtomicDecrement(PRInt32 *val);\n \n /*\n ** FUNCTION: PR_AtomicSet\n@@ -49,8 +48,7 @@ PR_AtomicDecrement(PRInt32* val);\n ** RETURN:\n **    Returns the prior value\n */\n-NSPR_API(PRInt32)\n-PR_AtomicSet(PRInt32* val, PRInt32 newval);\n+NSPR_API(PRInt32) PR_AtomicSet(PRInt32 *val, PRInt32 newval);\n \n /*\n ** FUNCTION: PR_AtomicAdd\n@@ -62,8 +60,7 @@ PR_AtomicSet(PRInt32* val, PRInt32 newval);\n ** RETURN:\n **    the returned value is the result of the addition\n */\n-NSPR_API(PRInt32)\n-PR_AtomicAdd(PRInt32* ptr, PRInt32 val);\n+NSPR_API(PRInt32)   PR_AtomicAdd(PRInt32 *ptr, PRInt32 val);\n \n /*\n ** MACRO: PR_ATOMIC_INCREMENT\n@@ -93,23 +90,28 @@ PR_AtomicAdd(PRInt32* ptr, PRInt32 val);\n #pragma intrinsic(_InterlockedExchangeAdd)\n #endif\n \n-#define PR_ATOMIC_INCREMENT(val) _InterlockedIncrement((long volatile*)(val))\n-#define PR_ATOMIC_DECREMENT(val) _InterlockedDecrement((long volatile*)(val))\n+#define PR_ATOMIC_INCREMENT(val) _InterlockedIncrement((long volatile *)(val))\n+#define PR_ATOMIC_DECREMENT(val) _InterlockedDecrement((long volatile *)(val))\n #define PR_ATOMIC_SET(val, newval) \\\n-    _InterlockedExchange((long volatile*)(val), (long)(newval))\n+        _InterlockedExchange((long volatile *)(val), (long)(newval))\n #define PR_ATOMIC_ADD(ptr, val) \\\n-    (_InterlockedExchangeAdd((long volatile*)(ptr), (long)(val)) + (val))\n-\n-#elif ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) &&          \\\n-    ((defined(__APPLE__) &&                                                  \\\n-      (defined(__ppc__) || defined(__i386__) || defined(__x86_64__))) ||     \\\n-     (defined(__linux__) &&                                                  \\\n-      ((defined(__i386__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \\\n-       defined(__ia64__) || defined(__x86_64__) || defined(__powerpc__) ||   \\\n-       (defined(__arm__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) ||  \\\n-       defined(__aarch64__) || defined(__alpha) ||                           \\\n-       (defined(__riscv) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) ||  \\\n-       (defined(__mips__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)))))\n+        (_InterlockedExchangeAdd((long volatile *)(ptr), (long)(val)) + (val))\n+\n+#elif ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && \\\n+      ((defined(__APPLE__) && \\\n+           (defined(__ppc__) || defined(__i386__) || defined(__x86_64__))) || \\\n+       (defined(__linux__) && \\\n+           ((defined(__i386__) && \\\n+           defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \\\n+           defined(__ia64__) || defined(__x86_64__) || \\\n+           defined(__powerpc__) || \\\n+           (defined(__arm__) && \\\n+           defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \\\n+           defined(__aarch64__) || defined(__alpha) || \\\n+           (defined(__riscv) && \\\n+           defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \\\n+           (defined(__mips__) && \\\n+           defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)))))\n \n /*\n  * Because the GCC manual warns that some processors may support\n@@ -137,8 +139,8 @@ PR_AtomicAdd(PRInt32* ptr, PRInt32 val);\n typedef struct PRStackElemStr PRStackElem;\n \n struct PRStackElemStr {\n-    PRStackElem* prstk_elem_next; /* next pointer MUST be at offset 0;\n-                                    assembly language code relies on this */\n+    PRStackElem *prstk_elem_next;   /* next pointer MUST be at offset 0;\n+                                      assembly language code relies on this */\n };\n \n typedef struct PRStackStr PRStack;\n@@ -152,8 +154,7 @@ typedef struct PRStackStr PRStack;\n ** RETURN:\n **    A pointer to the created stack, if successful, else NULL.\n */\n-NSPR_API(PRStack*)\n-PR_CreateStack(const char* stack_name);\n+NSPR_API(PRStack *) PR_CreateStack(const char *stack_name);\n \n /*\n ** FUNCTION: PR_StackPush\n@@ -165,8 +166,7 @@ PR_CreateStack(const char* stack_name);\n ** RETURN:\n **    None\n */\n-NSPR_API(void)\n-PR_StackPush(PRStack* stack, PRStackElem* stack_elem);\n+NSPR_API(void)          PR_StackPush(PRStack *stack, PRStackElem *stack_elem);\n \n /*\n ** FUNCTION: PR_StackPop\n@@ -179,8 +179,7 @@ PR_StackPush(PRStack* stack, PRStackElem* stack_elem);\n **    if non-empty,\n **    else NULL\n */\n-NSPR_API(PRStackElem*)\n-PR_StackPop(PRStack* stack);\n+NSPR_API(PRStackElem *) PR_StackPop(PRStack *stack);\n \n /*\n ** FUNCTION: PR_DestroyStack\n@@ -194,8 +193,7 @@ PR_StackPop(PRStack* stack);\n **                  PR_GetError will return\n **                      PR_INVALID_STATE_ERROR - stack is not empty\n */\n-NSPR_API(PRStatus)\n-PR_DestroyStack(PRStack* stack);\n+NSPR_API(PRStatus)      PR_DestroyStack(PRStack *stack);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prbit.h b/nspr/pr/include/prbit.h\nindex aadf204..50c6592 100644\n--- a/nspr/pr/include/prbit.h\n+++ b/nspr/pr/include/prbit.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -12,34 +13,32 @@ PR_BEGIN_EXTERN_C\n ** Replace compare/jump/add/shift sequence with compiler built-in/intrinsic\n ** functions.\n */\n-#if defined(_WIN32) && (_MSC_VER >= 1300) &&                   \\\n+#if defined(_WIN32) && (_MSC_VER >= 1300) && \\\n     (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) || \\\n      defined(_M_ARM64))\n-#include <intrin.h>\n-#pragma intrinsic(_BitScanForward, _BitScanReverse)\n-__forceinline static int\n-__prBitScanForward32(unsigned int val)\n+# include <intrin.h>\n+# pragma  intrinsic(_BitScanForward,_BitScanReverse)\n+__forceinline static int __prBitScanForward32(unsigned int val)\n {\n     unsigned long idx;\n     _BitScanForward(&idx, (unsigned long)val);\n-    return ((int)idx);\n+    return( (int)idx );\n }\n-__forceinline static int\n-__prBitScanReverse32(unsigned int val)\n+__forceinline static int __prBitScanReverse32(unsigned int val)\n {\n     unsigned long idx;\n     _BitScanReverse(&idx, (unsigned long)val);\n-    return ((int)(31 - idx));\n+    return( (int)(31-idx) );\n }\n-#define pr_bitscan_ctz32(val) __prBitScanForward32(val)\n-#define pr_bitscan_clz32(val) __prBitScanReverse32(val)\n-#define PR_HAVE_BUILTIN_BITSCAN32\n+# define pr_bitscan_ctz32(val)  __prBitScanForward32(val)\n+# define pr_bitscan_clz32(val)  __prBitScanReverse32(val)\n+# define  PR_HAVE_BUILTIN_BITSCAN32\n #elif ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && \\\n-    (defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \\\n-     defined(__aarch64__))\n-#define pr_bitscan_ctz32(val) __builtin_ctz(val)\n-#define pr_bitscan_clz32(val) __builtin_clz(val)\n-#define PR_HAVE_BUILTIN_BITSCAN32\n+       (defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \\\n+        defined(__aarch64__))\n+# define pr_bitscan_ctz32(val)  __builtin_ctz(val)\n+# define pr_bitscan_clz32(val)  __builtin_clz(val)\n+# define  PR_HAVE_BUILTIN_BITSCAN32\n #endif /* MSVC || GCC */\n \n /*\n@@ -47,56 +46,51 @@ __prBitScanReverse32(unsigned int val)\n */\n typedef unsigned long prbitmap_t;\n \n-#define PR_TEST_BIT(_map, _bit)                \\\n-    ((_map)[(_bit) >> PR_BITS_PER_LONG_LOG2] & \\\n-     (1L << ((_bit) & (PR_BITS_PER_LONG - 1))))\n-#define PR_SET_BIT(_map, _bit)                  \\\n-    ((_map)[(_bit) >> PR_BITS_PER_LONG_LOG2] |= \\\n-     (1L << ((_bit) & (PR_BITS_PER_LONG - 1))))\n-#define PR_CLEAR_BIT(_map, _bit)                \\\n-    ((_map)[(_bit) >> PR_BITS_PER_LONG_LOG2] &= \\\n-     ~(1L << ((_bit) & (PR_BITS_PER_LONG - 1))))\n+#define PR_TEST_BIT(_map,_bit) \\\n+    ((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] & (1L << ((_bit) & (PR_BITS_PER_LONG-1))))\n+#define PR_SET_BIT(_map,_bit) \\\n+    ((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] |= (1L << ((_bit) & (PR_BITS_PER_LONG-1))))\n+#define PR_CLEAR_BIT(_map,_bit) \\\n+    ((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] &= ~(1L << ((_bit) & (PR_BITS_PER_LONG-1))))\n \n /*\n ** Compute the log of the least power of 2 greater than or equal to n\n */\n-NSPR_API(PRIntn)\n-PR_CeilingLog2(PRUint32 i);\n+NSPR_API(PRIntn) PR_CeilingLog2(PRUint32 i);\n \n /*\n ** Compute the log of the greatest power of 2 less than or equal to n\n */\n-NSPR_API(PRIntn)\n-PR_FloorLog2(PRUint32 i);\n+NSPR_API(PRIntn) PR_FloorLog2(PRUint32 i);\n \n /*\n ** Macro version of PR_CeilingLog2: Compute the log of the least power of\n ** 2 greater than or equal to _n. The result is returned in _log2.\n */\n #ifdef PR_HAVE_BUILTIN_BITSCAN32\n-#define PR_CEILING_LOG2(_log2, _n)                           \\\n-    PR_BEGIN_MACRO                                           \\\n-    PRUint32 j_ = (PRUint32)(_n);                            \\\n+#define PR_CEILING_LOG2(_log2,_n)      \\\n+  PR_BEGIN_MACRO                       \\\n+    PRUint32 j_ = (PRUint32)(_n);      \\\n     (_log2) = (j_ <= 1 ? 0 : 32 - pr_bitscan_clz32(j_ - 1)); \\\n-    PR_END_MACRO\n+  PR_END_MACRO\n #else\n-#define PR_CEILING_LOG2(_log2, _n)  \\\n-    PR_BEGIN_MACRO                  \\\n+#define PR_CEILING_LOG2(_log2,_n)   \\\n+  PR_BEGIN_MACRO                    \\\n     PRUint32 j_ = (PRUint32)(_n);   \\\n     (_log2) = 0;                    \\\n-    if ((j_) & ((j_) - 1))          \\\n-        (_log2) += 1;               \\\n+    if ((j_) & ((j_)-1))            \\\n+    (_log2) += 1;               \\\n     if ((j_) >> 16)                 \\\n-        (_log2) += 16, (j_) >>= 16; \\\n+    (_log2) += 16, (j_) >>= 16; \\\n     if ((j_) >> 8)                  \\\n-        (_log2) += 8, (j_) >>= 8;   \\\n+    (_log2) += 8, (j_) >>= 8;   \\\n     if ((j_) >> 4)                  \\\n-        (_log2) += 4, (j_) >>= 4;   \\\n+    (_log2) += 4, (j_) >>= 4;   \\\n     if ((j_) >> 2)                  \\\n-        (_log2) += 2, (j_) >>= 2;   \\\n+    (_log2) += 2, (j_) >>= 2;   \\\n     if ((j_) >> 1)                  \\\n-        (_log2) += 1;               \\\n-    PR_END_MACRO\n+    (_log2) += 1;               \\\n+  PR_END_MACRO\n #endif /* PR_HAVE_BUILTIN_BITSCAN32 */\n \n /*\n@@ -106,27 +100,27 @@ PR_FloorLog2(PRUint32 i);\n ** This is equivalent to finding the highest set bit in the word.\n */\n #ifdef PR_HAVE_BUILTIN_BITSCAN32\n-#define PR_FLOOR_LOG2(_log2, _n)               \\\n-    PR_BEGIN_MACRO                             \\\n-    PRUint32 j_ = (PRUint32)(_n);              \\\n+#define PR_FLOOR_LOG2(_log2,_n)     \\\n+  PR_BEGIN_MACRO                    \\\n+    PRUint32 j_ = (PRUint32)(_n);   \\\n     (_log2) = 31 - pr_bitscan_clz32((j_) | 1); \\\n-    PR_END_MACRO\n+  PR_END_MACRO\n #else\n-#define PR_FLOOR_LOG2(_log2, _n)    \\\n-    PR_BEGIN_MACRO                  \\\n+#define PR_FLOOR_LOG2(_log2,_n)   \\\n+  PR_BEGIN_MACRO                    \\\n     PRUint32 j_ = (PRUint32)(_n);   \\\n     (_log2) = 0;                    \\\n     if ((j_) >> 16)                 \\\n-        (_log2) += 16, (j_) >>= 16; \\\n+    (_log2) += 16, (j_) >>= 16; \\\n     if ((j_) >> 8)                  \\\n-        (_log2) += 8, (j_) >>= 8;   \\\n+    (_log2) += 8, (j_) >>= 8;   \\\n     if ((j_) >> 4)                  \\\n-        (_log2) += 4, (j_) >>= 4;   \\\n+    (_log2) += 4, (j_) >>= 4;   \\\n     if ((j_) >> 2)                  \\\n-        (_log2) += 2, (j_) >>= 2;   \\\n+    (_log2) += 2, (j_) >>= 2;   \\\n     if ((j_) >> 1)                  \\\n-        (_log2) += 1;               \\\n-    PR_END_MACRO\n+    (_log2) += 1;               \\\n+  PR_END_MACRO\n #endif /* PR_HAVE_BUILTIN_BITSCAN32 */\n \n /*\n@@ -143,9 +137,8 @@ PR_FloorLog2(PRUint32 i);\n ** construct.\n */\n \n-#if defined(_MSC_VER) &&                                         \\\n-    (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \\\n-     defined(_M_ARM) || defined(_M_ARM64))\n+#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || \\\n+    defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64))\n #include <stdlib.h>\n #pragma intrinsic(_rotl, _rotr)\n #define PR_ROTATE_LEFT32(a, bits) _rotl(a, bits)\ndiff --git a/nspr/pr/include/prclist.h b/nspr/pr/include/prclist.h\nindex cdba319..a069176 100644\n--- a/nspr/pr/include/prclist.h\n+++ b/nspr/pr/include/prclist.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -13,48 +14,52 @@ typedef struct PRCListStr PRCList;\n ** Circular linked list\n */\n struct PRCListStr {\n-    PRCList* next;\n-    PRCList* prev;\n+    PRCList *next;\n+    PRCList *prev;\n };\n \n /*\n ** Insert element \"_e\" into the list, before \"_l\".\n */\n-#define PR_INSERT_BEFORE(_e, _l)     \\\n-    PR_BEGIN_MACRO(_e)->next = (_l); \\\n-    (_e)->prev = (_l)->prev;         \\\n-    (_l)->prev->next = (_e);         \\\n-    (_l)->prev = (_e);               \\\n+#define PR_INSERT_BEFORE(_e,_l)  \\\n+    PR_BEGIN_MACRO       \\\n+    (_e)->next = (_l);   \\\n+    (_e)->prev = (_l)->prev; \\\n+    (_l)->prev->next = (_e); \\\n+    (_l)->prev = (_e);   \\\n     PR_END_MACRO\n \n /*\n ** Insert element \"_e\" into the list, after \"_l\".\n */\n-#define PR_INSERT_AFTER(_e, _l)            \\\n-    PR_BEGIN_MACRO(_e)->next = (_l)->next; \\\n-    (_e)->prev = (_l);                     \\\n-    (_l)->next->prev = (_e);               \\\n-    (_l)->next = (_e);                     \\\n+#define PR_INSERT_AFTER(_e,_l)   \\\n+    PR_BEGIN_MACRO       \\\n+    (_e)->next = (_l)->next; \\\n+    (_e)->prev = (_l);   \\\n+    (_l)->next->prev = (_e); \\\n+    (_l)->next = (_e);   \\\n     PR_END_MACRO\n \n /*\n ** Return the element following element \"_e\"\n */\n-#define PR_NEXT_LINK(_e) ((_e)->next)\n+#define PR_NEXT_LINK(_e)     \\\n+        ((_e)->next)\n /*\n ** Return the element preceding element \"_e\"\n */\n-#define PR_PREV_LINK(_e) ((_e)->prev)\n+#define PR_PREV_LINK(_e)     \\\n+        ((_e)->prev)\n \n /*\n ** Append an element \"_e\" to the end of the list \"_l\"\n */\n-#define PR_APPEND_LINK(_e, _l) PR_INSERT_BEFORE(_e, _l)\n+#define PR_APPEND_LINK(_e,_l) PR_INSERT_BEFORE(_e,_l)\n \n /*\n ** Insert an element \"_e\" at the head of the list \"_l\"\n */\n-#define PR_INSERT_LINK(_e, _l) PR_INSERT_AFTER(_e, _l)\n+#define PR_INSERT_LINK(_e,_l) PR_INSERT_AFTER(_e,_l)\n \n /* Return the head/tail of the list */\n #define PR_LIST_HEAD(_l) (_l)->next\n@@ -63,36 +68,41 @@ struct PRCListStr {\n /*\n ** Remove the element \"_e\" from it's circular list.\n */\n-#define PR_REMOVE_LINK(_e)                       \\\n-    PR_BEGIN_MACRO(_e)->prev->next = (_e)->next; \\\n-    (_e)->next->prev = (_e)->prev;               \\\n+#define PR_REMOVE_LINK(_e)         \\\n+    PR_BEGIN_MACRO             \\\n+    (_e)->prev->next = (_e)->next; \\\n+    (_e)->next->prev = (_e)->prev; \\\n     PR_END_MACRO\n \n /*\n ** Remove the element \"_e\" from it's circular list. Also initializes the\n ** linkage.\n */\n-#define PR_REMOVE_AND_INIT_LINK(_e)              \\\n-    PR_BEGIN_MACRO(_e)->prev->next = (_e)->next; \\\n-    (_e)->next->prev = (_e)->prev;               \\\n-    (_e)->next = (_e);                           \\\n-    (_e)->prev = (_e);                           \\\n+#define PR_REMOVE_AND_INIT_LINK(_e)    \\\n+    PR_BEGIN_MACRO             \\\n+    (_e)->prev->next = (_e)->next; \\\n+    (_e)->next->prev = (_e)->prev; \\\n+    (_e)->next = (_e);         \\\n+    (_e)->prev = (_e);         \\\n     PR_END_MACRO\n \n /*\n ** Return non-zero if the given circular list \"_l\" is empty, zero if the\n ** circular list is not empty\n */\n-#define PR_CLIST_IS_EMPTY(_l) ((_l)->next == (_l))\n+#define PR_CLIST_IS_EMPTY(_l) \\\n+    ((_l)->next == (_l))\n \n /*\n ** Initialize a circular list\n */\n-#define PR_INIT_CLIST(_l)            \\\n-    PR_BEGIN_MACRO(_l)->next = (_l); \\\n-    (_l)->prev = (_l);               \\\n+#define PR_INIT_CLIST(_l)  \\\n+    PR_BEGIN_MACRO     \\\n+    (_l)->next = (_l); \\\n+    (_l)->prev = (_l); \\\n     PR_END_MACRO\n \n-#define PR_INIT_STATIC_CLIST(_l) { (_l), (_l) }\n+#define PR_INIT_STATIC_CLIST(_l) \\\n+    {(_l), (_l)}\n \n #endif /* prclist_h___ */\ndiff --git a/nspr/pr/include/prcmon.h b/nspr/pr/include/prcmon.h\nindex 6f4df1c..6917113 100644\n--- a/nspr/pr/include/prcmon.h\n+++ b/nspr/pr/include/prcmon.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -28,43 +29,37 @@ PR_BEGIN_EXTERN_C\n ** up). This call will return NULL if the monitor cache needs to be\n ** expanded and the system is out of memory.\n */\n-NSPR_API(PRMonitor*)\n-PR_CEnterMonitor(void* address);\n+NSPR_API(PRMonitor*) PR_CEnterMonitor(void *address);\n \n /*\n ** Like PR_ExitMonitor except use the \"address\" to find a monitor in the\n ** monitor cache.\n */\n-NSPR_API(PRStatus)\n-PR_CExitMonitor(void* address);\n+NSPR_API(PRStatus) PR_CExitMonitor(void *address);\n \n /*\n ** Like PR_Wait except use the \"address\" to find a monitor in the\n ** monitor cache.\n */\n-NSPR_API(PRStatus)\n-PR_CWait(void* address, PRIntervalTime timeout);\n+NSPR_API(PRStatus) PR_CWait(void *address, PRIntervalTime timeout);\n \n /*\n ** Like PR_Notify except use the \"address\" to find a monitor in the\n ** monitor cache.\n */\n-NSPR_API(PRStatus)\n-PR_CNotify(void* address);\n+NSPR_API(PRStatus) PR_CNotify(void *address);\n \n /*\n ** Like PR_NotifyAll except use the \"address\" to find a monitor in the\n ** monitor cache.\n */\n-NSPR_API(PRStatus)\n-PR_CNotifyAll(void* address);\n+NSPR_API(PRStatus) PR_CNotifyAll(void *address);\n \n /*\n ** Set a callback to be invoked each time a monitor is recycled from the cache\n ** freelist, with the monitor's cache-key passed in address.\n */\n-NSPR_API(void)\n-PR_CSetOnMonitorRecycle(void(PR_CALLBACK* callback)(void* address));\n+NSPR_API(void) PR_CSetOnMonitorRecycle(void (PR_CALLBACK *callback)(void *address));\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prcountr.h b/nspr/pr/include/prcountr.h\nindex 722f904..1503d06 100644\n--- a/nspr/pr/include/prcountr.h\n+++ b/nspr/pr/include/prcountr.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -80,11 +81,13 @@ PR_BEGIN_EXTERN_C\n ** ... don't even think of looking in here.\n **\n */\n-typedef void* PRCounterHandle;\n+typedef void *  PRCounterHandle;\n \n #define PRCOUNTER_NAME_MAX 31\n #define PRCOUNTER_DESC_MAX 255\n \n+\n+\n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_DEFINE_COUNTER() -- Define a PRCounterHandle\n **\n@@ -103,10 +106,10 @@ typedef void* PRCounterHandle;\n **\n */\n #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)\n-#define PR_INIT_COUNTER_HANDLE(handle, value) \\\n+#define PR_INIT_COUNTER_HANDLE(handle,value)\\\n     (handle) = (PRCounterHandle)(value)\n #else\n-#define PR_INIT_COUNTER_HANDLE(handle, value)\n+#define PR_INIT_COUNTER_HANDLE(handle,value)\n #endif\n \n /* -----------------------------------------------------------------------\n@@ -139,14 +142,18 @@ typedef void* PRCounterHandle;\n **\n */\n #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)\n-#define PR_CREATE_COUNTER(handle, qName, rName, description) \\\n-    (handle) = PR_CreateCounter((qName), (rName), (description))\n+#define PR_CREATE_COUNTER(handle,qName,rName,description)\\\n+   (handle) = PR_CreateCounter((qName),(rName),(description))\n #else\n-#define PR_CREATE_COUNTER(handle, qName, rName, description)\n+#define PR_CREATE_COUNTER(handle,qName,rName,description)\n #endif\n \n NSPR_API(PRCounterHandle)\n-PR_CreateCounter(const char* qName, const char* rName, const char* description);\n+PR_CreateCounter(\n+    const char *qName,\n+    const char *rName,\n+    const char *description\n+);\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_DestroyCounter() -- Destroy a counter object.\n@@ -172,7 +179,10 @@ PR_CreateCounter(const char* qName, const char* rName, const char* description);\n #endif\n \n NSPR_API(void)\n-PR_DestroyCounter(PRCounterHandle handle);\n+PR_DestroyCounter(\n+    PRCounterHandle handle\n+);\n+\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_GetCounterHandleFromName() -- Retreive a\n@@ -195,14 +205,17 @@ PR_DestroyCounter(PRCounterHandle handle);\n **\n */\n #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)\n-#define PR_GET_COUNTER_HANDLE_FROM_NAME(handle, qName, rName) \\\n-    (handle) = PR_GetCounterHandleFromName((qName), (rName))\n+#define PR_GET_COUNTER_HANDLE_FROM_NAME(handle,qName,rName)\\\n+    (handle) = PR_GetCounterHandleFromName((qName),(rName))\n #else\n-#define PR_GET_COUNTER_HANDLE_FROM_NAME(handle, qName, rName)\n+#define PR_GET_COUNTER_HANDLE_FROM_NAME(handle,qName,rName)\n #endif\n \n NSPR_API(PRCounterHandle)\n-PR_GetCounterHandleFromName(const char* qName, const char* rName);\n+PR_GetCounterHandleFromName(\n+    const char *qName,\n+    const char *rName\n+);\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_GetCounterNameFromHandle() -- Retreive a\n@@ -225,15 +238,20 @@ PR_GetCounterHandleFromName(const char* qName, const char* rName);\n **\n */\n #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)\n-#define PR_GET_COUNTER_NAME_FROM_HANDLE(handle, qName, rName, description) \\\n-    PR_GetCounterNameFromHandle((handle), (qName), (rName), (description))\n+#define PR_GET_COUNTER_NAME_FROM_HANDLE(handle,qName,rName,description)\\\n+    PR_GetCounterNameFromHandle((handle),(qName),(rName),(description))\n #else\n-#define PR_GET_COUNTER_NAME_FROM_HANDLE(handle, qName, rName, description)\n+#define PR_GET_COUNTER_NAME_FROM_HANDLE(handle,qName,rName,description )\n #endif\n \n NSPR_API(void)\n-PR_GetCounterNameFromHandle(PRCounterHandle handle, const char** qName,\n-                            const char** rName, const char** description);\n+PR_GetCounterNameFromHandle(\n+    PRCounterHandle handle,\n+    const char **qName,\n+    const char **rName,\n+    const char **description\n+);\n+\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_IncrementCounter() -- Add one to the referenced\n@@ -258,7 +276,10 @@ PR_GetCounterNameFromHandle(PRCounterHandle handle, const char** qName,\n #endif\n \n NSPR_API(void)\n-PR_IncrementCounter(PRCounterHandle handle);\n+PR_IncrementCounter(\n+    PRCounterHandle handle\n+);\n+\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_DecrementCounter() -- Subtract one from the\n@@ -284,7 +305,9 @@ PR_IncrementCounter(PRCounterHandle handle);\n #endif\n \n NSPR_API(void)\n-PR_DecrementCounter(PRCounterHandle handle);\n+PR_DecrementCounter(\n+    PRCounterHandle handle\n+);\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_AddToCounter() -- Add a value to a counter.\n@@ -304,13 +327,18 @@ PR_DecrementCounter(PRCounterHandle handle);\n **\n */\n #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)\n-#define PR_ADD_TO_COUNTER(handle, value) PR_AddToCounter((handle), (value))\n+#define PR_ADD_TO_COUNTER(handle,value)\\\n+    PR_AddToCounter((handle),(value))\n #else\n-#define PR_ADD_TO_COUNTER(handle, value)\n+#define PR_ADD_TO_COUNTER(handle,value)\n #endif\n \n NSPR_API(void)\n-PR_AddToCounter(PRCounterHandle handle, PRUint32 value);\n+PR_AddToCounter(\n+    PRCounterHandle handle,\n+    PRUint32 value\n+);\n+\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_SubtractFromCounter() -- A value is subtracted\n@@ -333,14 +361,18 @@ PR_AddToCounter(PRCounterHandle handle, PRUint32 value);\n **\n */\n #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)\n-#define PR_SUBTRACT_FROM_COUNTER(handle, value) \\\n-    PR_SubtractFromCounter((handle), (value))\n+#define PR_SUBTRACT_FROM_COUNTER(handle,value)\\\n+    PR_SubtractFromCounter((handle),(value))\n #else\n-#define PR_SUBTRACT_FROM_COUNTER(handle, value)\n+#define PR_SUBTRACT_FROM_COUNTER(handle,value)\n #endif\n \n NSPR_API(void)\n-PR_SubtractFromCounter(PRCounterHandle handle, PRUint32 value);\n+PR_SubtractFromCounter(\n+    PRCounterHandle handle,\n+    PRUint32 value\n+);\n+\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_GetCounter() -- Retreive the value of a counter\n@@ -359,13 +391,16 @@ PR_SubtractFromCounter(PRCounterHandle handle, PRUint32 value);\n **\n */\n #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)\n-#define PR_GET_COUNTER(counter, handle) (counter) = PR_GetCounter((handle))\n+#define PR_GET_COUNTER(counter,handle)\\\n+    (counter) = PR_GetCounter((handle))\n #else\n-#define PR_GET_COUNTER(counter, handle) 0\n+#define PR_GET_COUNTER(counter,handle) 0\n #endif\n \n NSPR_API(PRUint32)\n-PR_GetCounter(PRCounterHandle handle);\n+PR_GetCounter(\n+    PRCounterHandle handle\n+);\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_SetCounter() -- Replace the content of counter\n@@ -388,13 +423,17 @@ PR_GetCounter(PRCounterHandle handle);\n **\n */\n #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)\n-#define PR_SET_COUNTER(handle, value) PR_SetCounter((handle), (value))\n+#define PR_SET_COUNTER(handle,value) PR_SetCounter((handle),(value))\n #else\n-#define PR_SET_COUNTER(handle, value)\n+#define PR_SET_COUNTER(handle,value)\n #endif\n \n NSPR_API(void)\n-PR_SetCounter(PRCounterHandle handle, PRUint32 value);\n+PR_SetCounter(\n+    PRCounterHandle handle,\n+    PRUint32 value\n+);\n+\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_FindNextCounterQname() -- Retreive the next QName counter\n@@ -426,14 +465,16 @@ PR_SetCounter(PRCounterHandle handle, PRUint32 value);\n **\n */\n #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)\n-#define PR_FIND_NEXT_COUNTER_QNAME(next, handle) \\\n+#define PR_FIND_NEXT_COUNTER_QNAME(next,handle)\\\n     (next) = PR_FindNextCounterQname((handle))\n #else\n-#define PR_FIND_NEXT_COUNTER_QNAME(next, handle) NULL\n+#define PR_FIND_NEXT_COUNTER_QNAME(next,handle) NULL\n #endif\n \n NSPR_API(PRCounterHandle)\n-PR_FindNextCounterQname(PRCounterHandle handle);\n+PR_FindNextCounterQname(\n+    PRCounterHandle handle\n+);\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_FindNextCounterRname() -- Retreive the next RName counter\n@@ -467,14 +508,17 @@ PR_FindNextCounterQname(PRCounterHandle handle);\n **\n */\n #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)\n-#define PR_FIND_NEXT_COUNTER_RNAME(next, rhandle, qhandle) \\\n-    (next) = PR_FindNextCounterRname((rhandle), (qhandle))\n+#define PR_FIND_NEXT_COUNTER_RNAME(next,rhandle,qhandle)\\\n+    (next) = PR_FindNextCounterRname((rhandle),(qhandle))\n #else\n-#define PR_FIND_NEXT_COUNTER_RNAME(next, rhandle, qhandle)\n+#define PR_FIND_NEXT_COUNTER_RNAME(next,rhandle,qhandle)\n #endif\n \n NSPR_API(PRCounterHandle)\n-PR_FindNextCounterRname(PRCounterHandle rhandle, PRCounterHandle qhandle);\n+PR_FindNextCounterRname(\n+    PRCounterHandle rhandle,\n+    PRCounterHandle qhandle\n+);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prcvar.h b/nspr/pr/include/prcvar.h\nindex 3a6d6c7..413a364 100644\n--- a/nspr/pr/include/prcvar.h\n+++ b/nspr/pr/include/prcvar.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -23,8 +24,7 @@ typedef struct PRCondVar PRCondVar;\n ** This may fail if memory is tight or if some operating system resource\n ** is low. In such cases, a NULL will be returned.\n */\n-NSPR_API(PRCondVar*)\n-PR_NewCondVar(PRLock* lock);\n+NSPR_API(PRCondVar*) PR_NewCondVar(PRLock *lock);\n \n /*\n ** Destroy a condition variable. There must be no thread\n@@ -32,8 +32,7 @@ PR_NewCondVar(PRLock* lock);\n ** that the condvar is no longer in use.\n **\n */\n-NSPR_API(void)\n-PR_DestroyCondVar(PRCondVar* cvar);\n+NSPR_API(void) PR_DestroyCondVar(PRCondVar *cvar);\n \n /*\n ** The thread that waits on a condition is blocked in a \"waiting on\n@@ -63,8 +62,7 @@ PR_DestroyCondVar(PRCondVar* cvar);\n ** with the condition variable or the thread was interrupted (PR_Interrupt()).\n ** The particular reason can be extracted with PR_GetError().\n */\n-NSPR_API(PRStatus)\n-PR_WaitCondVar(PRCondVar* cvar, PRIntervalTime timeout);\n+NSPR_API(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout);\n \n /*\n ** Notify ONE thread that is currently waiting on 'cvar'. Which thread is\n@@ -79,8 +77,7 @@ PR_WaitCondVar(PRCondVar* cvar, PRIntervalTime timeout);\n ** Returns PR_FAILURE if the caller has not locked the lock associated\n ** with the condition variable.\n */\n-NSPR_API(PRStatus)\n-PR_NotifyCondVar(PRCondVar* cvar);\n+NSPR_API(PRStatus) PR_NotifyCondVar(PRCondVar *cvar);\n \n /*\n ** Notify all of the threads waiting on the condition variable. The order\n@@ -90,8 +87,7 @@ PR_NotifyCondVar(PRCondVar* cvar);\n ** Returns PR_FAILURE if the caller has not locked the lock associated\n ** with the condition variable.\n */\n-NSPR_API(PRStatus)\n-PR_NotifyAllCondVar(PRCondVar* cvar);\n+NSPR_API(PRStatus) PR_NotifyAllCondVar(PRCondVar *cvar);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prdtoa.h b/nspr/pr/include/prdtoa.h\nindex e629339..312a9d6 100644\n--- a/nspr/pr/include/prdtoa.h\n+++ b/nspr/pr/include/prdtoa.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -21,7 +22,7 @@ PR_BEGIN_EXTERN_C\n ** zero is returned.\n */\n NSPR_API(PRFloat64)\n-PR_strtod(const char* s00, char** se);\n+PR_strtod(const char *s00, char **se);\n \n /*\n ** PR_cnvtf()\n@@ -29,8 +30,7 @@ PR_strtod(const char* s00, char** se);\n ** prcsn - number of digits of precision to generate floating\n ** point value.\n */\n-NSPR_API(void)\n-PR_cnvtf(char* buf, PRIntn bufsz, PRIntn prcsn, PRFloat64 fval);\n+NSPR_API(void) PR_cnvtf(char *buf, PRIntn bufsz, PRIntn prcsn, PRFloat64 fval);\n \n /*\n ** PR_dtoa() converts double to a string.\n@@ -43,9 +43,8 @@ PR_cnvtf(char* buf, PRIntn bufsz, PRIntn prcsn, PRFloat64 fval);\n **     0 ==> shortest string that yields d when read in\n **           and rounded to nearest.\n */\n-NSPR_API(PRStatus)\n-PR_dtoa(PRFloat64 d, PRIntn mode, PRIntn ndigits, PRIntn* decpt, PRIntn* sign,\n-        char** rve, char* buf, PRSize bufsize);\n+NSPR_API(PRStatus) PR_dtoa(PRFloat64 d, PRIntn mode, PRIntn ndigits,\n+                           PRIntn *decpt, PRIntn *sign, char **rve, char *buf, PRSize bufsize);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prenv.h b/nspr/pr/include/prenv.h\nindex 200d38a..550f05c 100644\n--- a/nspr/pr/include/prenv.h\n+++ b/nspr/pr/include/prenv.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,8 +10,7 @@\n \n /*******************************************************************************/\n /*******************************************************************************/\n-/****************** THESE FUNCTIONS MAY NOT BE THREAD SAFE\n- * *********************/\n+/****************** THESE FUNCTIONS MAY NOT BE THREAD SAFE *********************/\n /*******************************************************************************/\n /*******************************************************************************/\n \n@@ -88,8 +88,7 @@ PR_BEGIN_EXTERN_C\n **   functions on the same platform. (!)\n **\n */\n-NSPR_API(char*)\n-PR_GetEnv(const char* var);\n+NSPR_API(char*) PR_GetEnv(const char *var);\n \n /*\n ** PR_GetEnvSecure() -- get a security-sensitive environment variable\n@@ -103,8 +102,7 @@ PR_GetEnv(const char* var);\n ** platforms may have platform-specific privilege elevation mechanisms\n ** not recognized by this function; see the implementation for details.\n */\n-NSPR_API(char*)\n-PR_GetEnvSecure(const char* var);\n+NSPR_API(char*) PR_GetEnvSecure(const char *var);\n \n /*\n ** PR_SetEnv() -- set, unset or change an environment variable\n@@ -127,8 +125,7 @@ PR_GetEnvSecure(const char* var);\n **\n **\n */\n-NSPR_API(PRStatus)\n-PR_SetEnv(const char* string);\n+NSPR_API(PRStatus) PR_SetEnv(const char *string);\n \n /*\n ** PR_DuplicateEnvironment() -- Obtain a copy of the environment.\n@@ -158,8 +155,7 @@ PR_SetEnv(const char* string);\n **   Similarly to PR_GetEnv(), this function may not interoperate as\n **   expected with the operating system's native environment accessors.\n */\n-NSPR_API(char**)\n-PR_DuplicateEnvironment(void);\n+NSPR_API(char **) PR_DuplicateEnvironment(void);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prerr.h b/nspr/pr/include/prerr.h\nindex 28bf6d7..8512329 100644\n--- a/nspr/pr/include/prerr.h\n+++ b/nspr/pr/include/prerr.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -12,236 +13,235 @@\n  */\n \n /* Memory allocation attempt failed */\n-#define PR_OUT_OF_MEMORY_ERROR (-6000L)\n+#define PR_OUT_OF_MEMORY_ERROR                   (-6000L)\n \n /* Invalid file descriptor */\n-#define PR_BAD_DESCRIPTOR_ERROR (-5999L)\n+#define PR_BAD_DESCRIPTOR_ERROR                  (-5999L)\n \n /* The operation would have blocked */\n-#define PR_WOULD_BLOCK_ERROR (-5998L)\n+#define PR_WOULD_BLOCK_ERROR                     (-5998L)\n \n /* Invalid memory address argument */\n-#define PR_ACCESS_FAULT_ERROR (-5997L)\n+#define PR_ACCESS_FAULT_ERROR                    (-5997L)\n \n /* Invalid function for file type */\n-#define PR_INVALID_METHOD_ERROR (-5996L)\n+#define PR_INVALID_METHOD_ERROR                  (-5996L)\n \n /* Invalid memory address argument */\n-#define PR_ILLEGAL_ACCESS_ERROR (-5995L)\n+#define PR_ILLEGAL_ACCESS_ERROR                  (-5995L)\n \n /* Some unknown error has occurred */\n-#define PR_UNKNOWN_ERROR (-5994L)\n+#define PR_UNKNOWN_ERROR                         (-5994L)\n \n /* Operation interrupted by another thread */\n-#define PR_PENDING_INTERRUPT_ERROR (-5993L)\n+#define PR_PENDING_INTERRUPT_ERROR               (-5993L)\n \n /* function not implemented */\n-#define PR_NOT_IMPLEMENTED_ERROR (-5992L)\n+#define PR_NOT_IMPLEMENTED_ERROR                 (-5992L)\n \n /* I/O function error */\n-#define PR_IO_ERROR (-5991L)\n+#define PR_IO_ERROR                              (-5991L)\n \n /* I/O operation timed out */\n-#define PR_IO_TIMEOUT_ERROR (-5990L)\n+#define PR_IO_TIMEOUT_ERROR                      (-5990L)\n \n /* I/O operation on busy file descriptor */\n-#define PR_IO_PENDING_ERROR (-5989L)\n+#define PR_IO_PENDING_ERROR                      (-5989L)\n \n /* The directory could not be opened */\n-#define PR_DIRECTORY_OPEN_ERROR (-5988L)\n+#define PR_DIRECTORY_OPEN_ERROR                  (-5988L)\n \n /* Invalid function argument */\n-#define PR_INVALID_ARGUMENT_ERROR (-5987L)\n+#define PR_INVALID_ARGUMENT_ERROR                (-5987L)\n \n /* Network address not available (in use?) */\n-#define PR_ADDRESS_NOT_AVAILABLE_ERROR (-5986L)\n+#define PR_ADDRESS_NOT_AVAILABLE_ERROR           (-5986L)\n \n /* Network address type not supported */\n-#define PR_ADDRESS_NOT_SUPPORTED_ERROR (-5985L)\n+#define PR_ADDRESS_NOT_SUPPORTED_ERROR           (-5985L)\n \n /* Already connected */\n-#define PR_IS_CONNECTED_ERROR (-5984L)\n+#define PR_IS_CONNECTED_ERROR                    (-5984L)\n \n /* Network address is invalid */\n-#define PR_BAD_ADDRESS_ERROR (-5983L)\n+#define PR_BAD_ADDRESS_ERROR                     (-5983L)\n \n /* Local Network address is in use */\n-#define PR_ADDRESS_IN_USE_ERROR (-5982L)\n+#define PR_ADDRESS_IN_USE_ERROR                  (-5982L)\n \n /* Connection refused by peer */\n-#define PR_CONNECT_REFUSED_ERROR (-5981L)\n+#define PR_CONNECT_REFUSED_ERROR                 (-5981L)\n \n /* Network address is presently unreachable */\n-#define PR_NETWORK_UNREACHABLE_ERROR (-5980L)\n+#define PR_NETWORK_UNREACHABLE_ERROR             (-5980L)\n \n /* Connection attempt timed out */\n-#define PR_CONNECT_TIMEOUT_ERROR (-5979L)\n+#define PR_CONNECT_TIMEOUT_ERROR                 (-5979L)\n \n /* Network file descriptor is not connected */\n-#define PR_NOT_CONNECTED_ERROR (-5978L)\n+#define PR_NOT_CONNECTED_ERROR                   (-5978L)\n \n /* Failure to load dynamic library */\n-#define PR_LOAD_LIBRARY_ERROR (-5977L)\n+#define PR_LOAD_LIBRARY_ERROR                    (-5977L)\n \n /* Failure to unload dynamic library */\n-#define PR_UNLOAD_LIBRARY_ERROR (-5976L)\n+#define PR_UNLOAD_LIBRARY_ERROR                  (-5976L)\n \n /* Symbol not found in any of the loaded dynamic libraries */\n-#define PR_FIND_SYMBOL_ERROR (-5975L)\n+#define PR_FIND_SYMBOL_ERROR                     (-5975L)\n \n /* Insufficient system resources */\n-#define PR_INSUFFICIENT_RESOURCES_ERROR (-5974L)\n+#define PR_INSUFFICIENT_RESOURCES_ERROR          (-5974L)\n \n /* A directory lookup on a network address has failed */\n-#define PR_DIRECTORY_LOOKUP_ERROR (-5973L)\n+#define PR_DIRECTORY_LOOKUP_ERROR                (-5973L)\n \n /* Attempt to access a TPD key that is out of range */\n-#define PR_TPD_RANGE_ERROR (-5972L)\n+#define PR_TPD_RANGE_ERROR                       (-5972L)\n \n /* Process open FD table is full */\n-#define PR_PROC_DESC_TABLE_FULL_ERROR (-5971L)\n+#define PR_PROC_DESC_TABLE_FULL_ERROR            (-5971L)\n \n /* System open FD table is full */\n-#define PR_SYS_DESC_TABLE_FULL_ERROR (-5970L)\n+#define PR_SYS_DESC_TABLE_FULL_ERROR             (-5970L)\n \n /* Network operation attempted on non-network file descriptor */\n-#define PR_NOT_SOCKET_ERROR (-5969L)\n+#define PR_NOT_SOCKET_ERROR                      (-5969L)\n \n /* TCP-specific function attempted on a non-TCP file descriptor */\n-#define PR_NOT_TCP_SOCKET_ERROR (-5968L)\n+#define PR_NOT_TCP_SOCKET_ERROR                  (-5968L)\n \n /* TCP file descriptor is already bound */\n-#define PR_SOCKET_ADDRESS_IS_BOUND_ERROR (-5967L)\n+#define PR_SOCKET_ADDRESS_IS_BOUND_ERROR         (-5967L)\n \n /* Access Denied */\n-#define PR_NO_ACCESS_RIGHTS_ERROR (-5966L)\n+#define PR_NO_ACCESS_RIGHTS_ERROR                (-5966L)\n \n /* The requested operation is not supported by the platform */\n-#define PR_OPERATION_NOT_SUPPORTED_ERROR (-5965L)\n+#define PR_OPERATION_NOT_SUPPORTED_ERROR         (-5965L)\n \n /* The host operating system does not support the protocol requested */\n-#define PR_PROTOCOL_NOT_SUPPORTED_ERROR (-5964L)\n+#define PR_PROTOCOL_NOT_SUPPORTED_ERROR          (-5964L)\n \n /* Access to the remote file has been severed */\n-#define PR_REMOTE_FILE_ERROR (-5963L)\n+#define PR_REMOTE_FILE_ERROR                     (-5963L)\n \n /* The value requested is too large to be stored in the data buffer provided */\n-#define PR_BUFFER_OVERFLOW_ERROR (-5962L)\n+#define PR_BUFFER_OVERFLOW_ERROR                 (-5962L)\n \n /* TCP connection reset by peer */\n-#define PR_CONNECT_RESET_ERROR (-5961L)\n+#define PR_CONNECT_RESET_ERROR                   (-5961L)\n \n /* Unused */\n-#define PR_RANGE_ERROR (-5960L)\n+#define PR_RANGE_ERROR                           (-5960L)\n \n /* The operation would have deadlocked */\n-#define PR_DEADLOCK_ERROR (-5959L)\n+#define PR_DEADLOCK_ERROR                        (-5959L)\n \n /* The file is already locked */\n-#define PR_FILE_IS_LOCKED_ERROR (-5958L)\n+#define PR_FILE_IS_LOCKED_ERROR                  (-5958L)\n \n /* Write would result in file larger than the system allows */\n-#define PR_FILE_TOO_BIG_ERROR (-5957L)\n+#define PR_FILE_TOO_BIG_ERROR                    (-5957L)\n \n /* The device for storing the file is full */\n-#define PR_NO_DEVICE_SPACE_ERROR (-5956L)\n+#define PR_NO_DEVICE_SPACE_ERROR                 (-5956L)\n \n /* Unused */\n-#define PR_PIPE_ERROR (-5955L)\n+#define PR_PIPE_ERROR                            (-5955L)\n \n /* Unused */\n-#define PR_NO_SEEK_DEVICE_ERROR (-5954L)\n+#define PR_NO_SEEK_DEVICE_ERROR                  (-5954L)\n \n /* Cannot perform a normal file operation on a directory */\n-#define PR_IS_DIRECTORY_ERROR (-5953L)\n+#define PR_IS_DIRECTORY_ERROR                    (-5953L)\n \n /* Symbolic link loop */\n-#define PR_LOOP_ERROR (-5952L)\n+#define PR_LOOP_ERROR                            (-5952L)\n \n /* File name is too long */\n-#define PR_NAME_TOO_LONG_ERROR (-5951L)\n+#define PR_NAME_TOO_LONG_ERROR                   (-5951L)\n \n /* File not found */\n-#define PR_FILE_NOT_FOUND_ERROR (-5950L)\n+#define PR_FILE_NOT_FOUND_ERROR                  (-5950L)\n \n /* Cannot perform directory operation on a normal file */\n-#define PR_NOT_DIRECTORY_ERROR (-5949L)\n+#define PR_NOT_DIRECTORY_ERROR                   (-5949L)\n \n /* Cannot write to a read-only file system */\n-#define PR_READ_ONLY_FILESYSTEM_ERROR (-5948L)\n+#define PR_READ_ONLY_FILESYSTEM_ERROR            (-5948L)\n \n /* Cannot delete a directory that is not empty */\n-#define PR_DIRECTORY_NOT_EMPTY_ERROR (-5947L)\n+#define PR_DIRECTORY_NOT_EMPTY_ERROR             (-5947L)\n \n /* Cannot delete or rename a file object while the file system is busy */\n-#define PR_FILESYSTEM_MOUNTED_ERROR (-5946L)\n+#define PR_FILESYSTEM_MOUNTED_ERROR              (-5946L)\n \n /* Cannot rename a file to a file system on another device */\n-#define PR_NOT_SAME_DEVICE_ERROR (-5945L)\n+#define PR_NOT_SAME_DEVICE_ERROR                 (-5945L)\n \n /* The directory object in the file system is corrupted */\n-#define PR_DIRECTORY_CORRUPTED_ERROR (-5944L)\n+#define PR_DIRECTORY_CORRUPTED_ERROR             (-5944L)\n \n /* Cannot create or rename a filename that already exists */\n-#define PR_FILE_EXISTS_ERROR (-5943L)\n+#define PR_FILE_EXISTS_ERROR                     (-5943L)\n \n /* Directory is full.  No additional filenames may be added */\n-#define PR_MAX_DIRECTORY_ENTRIES_ERROR (-5942L)\n+#define PR_MAX_DIRECTORY_ENTRIES_ERROR           (-5942L)\n \n /* The required device was in an invalid state */\n-#define PR_INVALID_DEVICE_STATE_ERROR (-5941L)\n+#define PR_INVALID_DEVICE_STATE_ERROR            (-5941L)\n \n /* The device is locked */\n-#define PR_DEVICE_IS_LOCKED_ERROR (-5940L)\n+#define PR_DEVICE_IS_LOCKED_ERROR                (-5940L)\n \n /* No more entries in the directory */\n-#define PR_NO_MORE_FILES_ERROR (-5939L)\n+#define PR_NO_MORE_FILES_ERROR                   (-5939L)\n \n /* Encountered end of file */\n-#define PR_END_OF_FILE_ERROR (-5938L)\n+#define PR_END_OF_FILE_ERROR                     (-5938L)\n \n /* Seek error */\n-#define PR_FILE_SEEK_ERROR (-5937L)\n+#define PR_FILE_SEEK_ERROR                       (-5937L)\n \n /* The file is busy */\n-#define PR_FILE_IS_BUSY_ERROR (-5936L)\n+#define PR_FILE_IS_BUSY_ERROR                    (-5936L)\n \n /* The I/O operation was aborted */\n-#define PR_OPERATION_ABORTED_ERROR (-5935L)\n+#define PR_OPERATION_ABORTED_ERROR               (-5935L)\n \n /* Operation is still in progress (probably a non-blocking connect) */\n-#define PR_IN_PROGRESS_ERROR (-5934L)\n+#define PR_IN_PROGRESS_ERROR                     (-5934L)\n \n /* Operation has already been initiated (probably a non-blocking connect) */\n-#define PR_ALREADY_INITIATED_ERROR (-5933L)\n+#define PR_ALREADY_INITIATED_ERROR               (-5933L)\n \n /* The wait group is empty */\n-#define PR_GROUP_EMPTY_ERROR (-5932L)\n+#define PR_GROUP_EMPTY_ERROR                     (-5932L)\n \n /* Object state improper for request */\n-#define PR_INVALID_STATE_ERROR (-5931L)\n+#define PR_INVALID_STATE_ERROR                   (-5931L)\n \n /* Network is down */\n-#define PR_NETWORK_DOWN_ERROR (-5930L)\n+#define PR_NETWORK_DOWN_ERROR                    (-5930L)\n \n /* Socket shutdown */\n-#define PR_SOCKET_SHUTDOWN_ERROR (-5929L)\n+#define PR_SOCKET_SHUTDOWN_ERROR                 (-5929L)\n \n /* Connection aborted */\n-#define PR_CONNECT_ABORTED_ERROR (-5928L)\n+#define PR_CONNECT_ABORTED_ERROR                 (-5928L)\n \n /* Host is unreachable */\n-#define PR_HOST_UNREACHABLE_ERROR (-5927L)\n+#define PR_HOST_UNREACHABLE_ERROR                (-5927L)\n \n /* The library is not loaded */\n-#define PR_LIBRARY_NOT_LOADED_ERROR (-5926L)\n+#define PR_LIBRARY_NOT_LOADED_ERROR              (-5926L)\n \n-/* The one-time function was previously called and failed. Its error code is no\n- * longer available */\n-#define PR_CALL_ONCE_ERROR (-5925L)\n+/* The one-time function was previously called and failed. Its error code is no longer available */\n+#define PR_CALL_ONCE_ERROR                       (-5925L)\n \n /* Placeholder for the end of the list */\n-#define PR_MAX_ERROR (-5924L)\n+#define PR_MAX_ERROR                             (-5924L)\n \n extern void nspr_InitializePRErrorTable(void);\n #define ERROR_TABLE_BASE_nspr (-6000L)\ndiff --git a/nspr/pr/include/prerror.h b/nspr/pr/include/prerror.h\nindex 94705af..f445aa9 100644\n--- a/nspr/pr/include/prerror.h\n+++ b/nspr/pr/include/prerror.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -21,8 +22,7 @@ typedef PRInt32 PRErrorCode;\n ** the error. Also, if available, the platform specific oserror is stored.\n ** If there is no appropriate OS error number, a zero my be supplied.\n */\n-NSPR_API(void)\n-PR_SetError(PRErrorCode errorCode, PRInt32 oserr);\n+NSPR_API(void) PR_SetError(PRErrorCode errorCode, PRInt32 oserr);\n \n /*\n ** The text value specified may be NULL. If it is not NULL and the text length\n@@ -33,37 +33,34 @@ PR_SetError(PRErrorCode errorCode, PRInt32 oserr);\n ** The text will be copied into to thread structure and remain there\n ** until the next call to PR_SetError.\n */\n-NSPR_API(void)\n-PR_SetErrorText(PRIntn textLength, const char* text);\n+NSPR_API(void) PR_SetErrorText(\n+    PRIntn textLength, const char *text);\n \n /*\n ** Return the current threads last set error code.\n */\n-NSPR_API(PRErrorCode)\n-PR_GetError(void);\n+NSPR_API(PRErrorCode) PR_GetError(void);\n \n /*\n ** Return the current threads last set os error code. This is used for\n ** machine specific code that desires the underlying os error.\n */\n-NSPR_API(PRInt32)\n-PR_GetOSError(void);\n+NSPR_API(PRInt32) PR_GetOSError(void);\n \n /*\n ** Get the length of the error text. If a zero is returned, then there\n ** is no text. Otherwise, the value returned is sufficient to contain\n ** the error text currently available.\n */\n-NSPR_API(PRInt32)\n-PR_GetErrorTextLength(void);\n+NSPR_API(PRInt32) PR_GetErrorTextLength(void);\n \n /*\n ** Copy the current threads current error text. Then actual number of bytes\n ** copied is returned as the result. If the result is zero, the 'text' area\n ** is unaffected.\n */\n-NSPR_API(PRInt32)\n-PR_GetErrorText(char* text);\n+NSPR_API(PRInt32) PR_GetErrorText(char *text);\n+\n \n /*\n Copyright (C) 1987, 1988 Student Information Processing Board of the\n@@ -80,6 +77,7 @@ make no representations about the suitability of this software for any\n purpose.  It is provided \"as is\" without express or implied warranty.\n */\n \n+\n /*\n  * NOTE:\n  *      The interfaces for error-code-translation described in the rest of\n@@ -146,7 +144,7 @@ purpose.  It is provided \"as is\" without express or implied warranty.\n  */\n typedef PRUint32 PRLanguageCode;\n #define PR_LANGUAGE_I_DEFAULT 0 /* i-default, the default language */\n-#define PR_LANGUAGE_EN 1        /* English, explicitly negotiated */\n+#define PR_LANGUAGE_EN 1 /* English, explicitly negotiated */\n \n /*\n  * struct PRErrorMessage --\n@@ -154,8 +152,8 @@ typedef PRUint32 PRLanguageCode;\n  *    An error message in an error table.\n  */\n struct PRErrorMessage {\n-    const char* name;    /* Macro name for error */\n-    const char* en_text; /* Default English text */\n+    const char * name;    /* Macro name for error */\n+    const char * en_text; /* Default English text */\n };\n \n /*\n@@ -164,10 +162,10 @@ struct PRErrorMessage {\n  *    An error table, provided by a library.\n  */\n struct PRErrorTable {\n-    const struct PRErrorMessage* msgs; /* Array of error information */\n-    const char* name;                  /* Name of error table source */\n-    PRErrorCode base;                  /* Error code for first error in table */\n-    int n_msgs;                        /* Number of codes in table */\n+    const struct PRErrorMessage * msgs; /* Array of error information */\n+    const char *name; /* Name of error table source */\n+    PRErrorCode base; /* Error code for first error in table */\n+    int n_msgs; /* Number of codes in table */\n };\n \n /*\n@@ -180,8 +178,8 @@ struct PRErrorCallbackPrivate;\n /*\n  * struct PRErrorCallbackTablePrivate --\n  *\n- *    A data structure under which the localization plugin may store\n- * information, associated with an error table, that is private to itself.\n+ *    A data structure under which the localization plugin may store information,\n+ *    associated with an error table, that is private to itself.\n  */\n struct PRErrorCallbackTablePrivate;\n \n@@ -195,10 +193,11 @@ struct PRErrorCallbackTablePrivate;\n  *    The callback returns the appropriate UTF-8 encoded description, or NULL\n  *    if no description can be found.\n  */\n-typedef const char* PRErrorCallbackLookupFn(\n-    PRErrorCode code, PRLanguageCode language, const struct PRErrorTable* table,\n-    struct PRErrorCallbackPrivate* cb_private,\n-    struct PRErrorCallbackTablePrivate* table_private);\n+typedef const char *\n+PRErrorCallbackLookupFn(PRErrorCode code, PRLanguageCode language,\n+                        const struct PRErrorTable *table,\n+                        struct PRErrorCallbackPrivate *cb_private,\n+                        struct PRErrorCallbackTablePrivate *table_private);\n \n /*\n  * PRErrorCallbackNewTableFn --\n@@ -207,12 +206,12 @@ typedef const char* PRErrorCallbackLookupFn(\n  *    callback which is called once with each error table registered\n  *    with NSPR.  The callback is provided with the error table and\n  *    the plugin's private structure.  The callback returns any table private\n- *    data it wishes to associate with the error table.  Does not need to be\n- * thread safe.\n+ *    data it wishes to associate with the error table.  Does not need to be thread\n+ *    safe.\n  */\n-typedef struct PRErrorCallbackTablePrivate* PRErrorCallbackNewTableFn(\n-    const struct PRErrorTable* table,\n-    struct PRErrorCallbackPrivate* cb_private);\n+typedef struct PRErrorCallbackTablePrivate *\n+PRErrorCallbackNewTableFn(const struct PRErrorTable *table,\n+                          struct PRErrorCallbackPrivate *cb_private);\n \n /**********************************************************************/\n /****************************** FUNCTIONS *****************************/\n@@ -228,8 +227,9 @@ typedef struct PRErrorCallbackTablePrivate* PRErrorCallbackNewTableFn(\n **  valid for the duration of the process.  Never returns NULL.\n **\n ***********************************************************************/\n-NSPR_API(const char*)\n-PR_ErrorToString(PRErrorCode code, PRLanguageCode language);\n+NSPR_API(const char *) PR_ErrorToString(PRErrorCode code,\n+                                        PRLanguageCode language);\n+\n \n /***********************************************************************\n ** FUNCTION:    PR_ErrorToName\n@@ -241,8 +241,8 @@ PR_ErrorToString(PRErrorCode code, PRLanguageCode language);\n **  Does not work for error table 0, the system error codes.\n **\n ***********************************************************************/\n-NSPR_API(const char*)\n-PR_ErrorToName(PRErrorCode code);\n+NSPR_API(const char *) PR_ErrorToName(PRErrorCode code);\n+\n \n /***********************************************************************\n ** FUNCTION:    PR_ErrorLanguages\n@@ -255,8 +255,8 @@ PR_ErrorToName(PRErrorCode code);\n **  with a null pointer.\n **\n ***********************************************************************/\n-NSPR_API(const char* const*)\n-PR_ErrorLanguages(void);\n+NSPR_API(const char * const *) PR_ErrorLanguages(void);\n+\n \n /***********************************************************************\n ** FUNCTION:    PR_ErrorInstallTable\n@@ -268,8 +268,8 @@ PR_ErrorLanguages(void);\n **  NOT THREAD SAFE!\n **\n ***********************************************************************/\n-NSPR_API(PRErrorCode)\n-PR_ErrorInstallTable(const struct PRErrorTable* table);\n+NSPR_API(PRErrorCode) PR_ErrorInstallTable(const struct PRErrorTable *table);\n+\n \n /***********************************************************************\n ** FUNCTION:    PR_ErrorInstallCallback\n@@ -284,11 +284,10 @@ PR_ErrorInstallTable(const struct PRErrorTable* table);\n **  NOT THREAD SAFE!\n **\n ***********************************************************************/\n-NSPR_API(void)\n-PR_ErrorInstallCallback(const char* const* languages,\n-                        PRErrorCallbackLookupFn* lookup,\n-                        PRErrorCallbackNewTableFn* newtable,\n-                        struct PRErrorCallbackPrivate* cb_private);\n+NSPR_API(void) PR_ErrorInstallCallback(const char * const * languages,\n+                                       PRErrorCallbackLookupFn *lookup,\n+                                       PRErrorCallbackNewTableFn *newtable,\n+                                       struct PRErrorCallbackPrivate *cb_private);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prinet.h b/nspr/pr/include/prinet.h\nindex 2bd28a8..ffa4f91 100644\n--- a/nspr/pr/include/prinet.h\n+++ b/nspr/pr/include/prinet.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -33,8 +34,8 @@\n \n #if defined(XP_UNIX)\n #include <sys/types.h>\n-#include <sys/socket.h> /* AF_INET */\n-#include <netinet/in.h> /* INADDR_ANY, ..., ntohl(), ... */\n+#include <sys/socket.h>     /* AF_INET */\n+#include <netinet/in.h>         /* INADDR_ANY, ..., ntohl(), ... */\n #ifdef XP_UNIX\n #ifdef AIX\n /*\ndiff --git a/nspr/pr/include/prinit.h b/nspr/pr/include/prinit.h\nindex 0203649..398dd16 100644\n--- a/nspr/pr/include/prinit.h\n+++ b/nspr/pr/include/prinit.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -19,7 +20,7 @@ PR_BEGIN_EXTERN_C\n ** NSPR's name, this should persist until at least the turn of the\n ** century.\n */\n-#define PR_NAME \"NSPR\"\n+#define PR_NAME     \"NSPR\"\n \n /*\n ** NSPR's version is used to determine the likelihood that the version you\n@@ -29,11 +30,11 @@ PR_BEGIN_EXTERN_C\n ** The format of the version string is\n **     \"<major version>.<minor version>[.<patch level>] [<Beta>]\"\n */\n-#define PR_VERSION \"4.40\"\n-#define PR_VMAJOR 4\n-#define PR_VMINOR 40\n-#define PR_VPATCH 0\n-#define PR_BETA PR_FALSE\n+#define PR_VERSION  \"4.38.2\"\n+#define PR_VMAJOR   4\n+#define PR_VMINOR   38\n+#define PR_VPATCH   2\n+#define PR_BETA     PR_FALSE\n \n /*\n ** PRVersionCheck\n@@ -61,14 +62,13 @@ typedef PRBool (*PRVersionCheck)(const char*);\n ** Note that NSPR has no cooperating dependencies.\n */\n \n-NSPR_API(PRBool)\n-PR_VersionCheck(const char* importedVersion);\n+NSPR_API(PRBool) PR_VersionCheck(const char *importedVersion);\n \n /*\n  * Returns a const string of the NSPR library version.\n  */\n-NSPR_API(const char*)\n-PR_GetVersion(void);\n+NSPR_API(const char*) PR_GetVersion(void);\n+\n \n /************************************************************************/\n /*******************************INITIALIZATION***************************/\n@@ -80,8 +80,8 @@ PR_GetVersion(void);\n **\n ** The specificaiton of 'maxPTDs' is ignored.\n */\n-NSPR_API(void)\n-PR_Init(PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs);\n+NSPR_API(void) PR_Init(\n+    PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs);\n \n /*\n ** And alternate form of initialization, one that may become the default if\n@@ -101,16 +101,15 @@ PR_Init(PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs);\n ** function, 'prmain'.\n */\n \n-typedef PRIntn(PR_CALLBACK* PRPrimordialFn)(PRIntn argc, char** argv);\n+typedef PRIntn (PR_CALLBACK *PRPrimordialFn)(PRIntn argc, char **argv);\n \n-NSPR_API(PRIntn)\n-PR_Initialize(PRPrimordialFn prmain, PRIntn argc, char** argv, PRUintn maxPTDs);\n+NSPR_API(PRIntn) PR_Initialize(\n+    PRPrimordialFn prmain, PRIntn argc, char **argv, PRUintn maxPTDs);\n \n /*\n ** Return PR_TRUE if PR_Init has already been called.\n */\n-NSPR_API(PRBool)\n-PR_Initialized(void);\n+NSPR_API(PRBool) PR_Initialized(void);\n \n /*\n  * Perform a graceful shutdown of NSPR.  PR_Cleanup() may be called by\n@@ -128,66 +127,57 @@ PR_Initialized(void);\n  * or PR_FAILURE if the calling thread of this function is not the\n  * primordial thread.\n  */\n-NSPR_API(PRStatus)\n-PR_Cleanup(void);\n+NSPR_API(PRStatus) PR_Cleanup(void);\n \n /*\n ** Disable Interrupts\n **      Disables timer signals used for pre-emptive scheduling.\n */\n-NSPR_API(void)\n-PR_DisableClockInterrupts(void);\n+NSPR_API(void) PR_DisableClockInterrupts(void);\n \n /*\n ** Enables Interrupts\n **      Enables timer signals used for pre-emptive scheduling.\n */\n-NSPR_API(void)\n-PR_EnableClockInterrupts(void);\n+NSPR_API(void) PR_EnableClockInterrupts(void);\n \n /*\n ** Block Interrupts\n **      Blocks the timer signal used for pre-emptive scheduling\n */\n-NSPR_API(void)\n-PR_BlockClockInterrupts(void);\n+NSPR_API(void) PR_BlockClockInterrupts(void);\n \n /*\n ** Unblock Interrupts\n **      Unblocks the timer signal used for pre-emptive scheduling\n */\n-NSPR_API(void)\n-PR_UnblockClockInterrupts(void);\n+NSPR_API(void) PR_UnblockClockInterrupts(void);\n \n /*\n ** Create extra virtual processor threads. Generally used with MP systems.\n */\n-NSPR_API(void)\n-PR_SetConcurrency(PRUintn numCPUs);\n+NSPR_API(void) PR_SetConcurrency(PRUintn numCPUs);\n \n /*\n ** Control the method and size of the file descriptor (PRFileDesc*)\n ** cache used by the runtime. Setting 'high' to zero is for performance,\n ** any other value probably for debugging (see memo on FD caching).\n */\n-NSPR_API(PRStatus)\n-PR_SetFDCacheSize(PRIntn low, PRIntn high);\n+NSPR_API(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high);\n \n /*\n  * Cause an immediate, nongraceful, forced termination of the process.\n  * It takes a PRIntn argument, which is the exit status code of the\n  * process.\n  */\n-NSPR_API(void)\n-PR_ProcessExit(PRIntn status);\n+NSPR_API(void) PR_ProcessExit(PRIntn status);\n \n /*\n ** Abort the process in a non-graceful manner. This will cause a core file,\n ** call to the debugger or other moral equivalent as well as causing the\n ** entire process to stop.\n */\n-NSPR_API(void)\n-PR_Abort(void);\n+NSPR_API(void) PR_Abort(void);\n \n /*\n  ****************************************************************\n@@ -203,15 +193,21 @@ typedef struct PRCallOnceType {\n     PRStatus status;\n } PRCallOnceType;\n \n-typedef PRStatus(PR_CALLBACK* PRCallOnceFN)(void);\n+typedef PRStatus (PR_CALLBACK *PRCallOnceFN)(void);\n+\n+typedef PRStatus (PR_CALLBACK *PRCallOnceWithArgFN)(void *arg);\n \n-typedef PRStatus(PR_CALLBACK* PRCallOnceWithArgFN)(void* arg);\n+NSPR_API(PRStatus) PR_CallOnce(\n+    PRCallOnceType *once,\n+    PRCallOnceFN    func\n+);\n \n-NSPR_API(PRStatus)\n-PR_CallOnce(PRCallOnceType* once, PRCallOnceFN func);\n+NSPR_API(PRStatus) PR_CallOnceWithArg(\n+    PRCallOnceType      *once,\n+    PRCallOnceWithArgFN  func,\n+    void                *arg\n+);\n \n-NSPR_API(PRStatus)\n-PR_CallOnceWithArg(PRCallOnceType* once, PRCallOnceWithArgFN func, void* arg);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prinrval.h b/nspr/pr/include/prinrval.h\nindex 6984793..7797291 100644\n--- a/nspr/pr/include/prinrval.h\n+++ b/nspr/pr/include/prinrval.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -75,8 +76,7 @@ typedef PRUint32 PRIntervalTime;\n ** MEMORY:      N/A\n ** ALGORITHM:   Platform dependent\n ***********************************************************************/\n-NSPR_API(PRIntervalTime)\n-PR_IntervalNow(void);\n+NSPR_API(PRIntervalTime) PR_IntervalNow(void);\n \n /***********************************************************************\n ** FUNCTION:    PR_TicksPerSecond\n@@ -94,8 +94,7 @@ PR_IntervalNow(void);\n ** MEMORY:      N/A\n ** ALGORITHM:   N/A\n ***********************************************************************/\n-NSPR_API(PRUint32)\n-PR_TicksPerSecond(void);\n+NSPR_API(PRUint32) PR_TicksPerSecond(void);\n \n /***********************************************************************\n ** FUNCTION:    PR_SecondsToInterval\n@@ -114,12 +113,9 @@ PR_TicksPerSecond(void);\n ** MEMORY:      N/A\n ** ALGORITHM:   N/A\n ***********************************************************************/\n-NSPR_API(PRIntervalTime)\n-PR_SecondsToInterval(PRUint32 seconds);\n-NSPR_API(PRIntervalTime)\n-PR_MillisecondsToInterval(PRUint32 milli);\n-NSPR_API(PRIntervalTime)\n-PR_MicrosecondsToInterval(PRUint32 micro);\n+NSPR_API(PRIntervalTime) PR_SecondsToInterval(PRUint32 seconds);\n+NSPR_API(PRIntervalTime) PR_MillisecondsToInterval(PRUint32 milli);\n+NSPR_API(PRIntervalTime) PR_MicrosecondsToInterval(PRUint32 micro);\n \n /***********************************************************************\n ** FUNCTION:    PR_IntervalToSeconds\n@@ -138,15 +134,13 @@ PR_MicrosecondsToInterval(PRUint32 micro);\n ** MEMORY:      N/A\n ** ALGORITHM:   N/A\n ***********************************************************************/\n-NSPR_API(PRUint32)\n-PR_IntervalToSeconds(PRIntervalTime ticks);\n-NSPR_API(PRUint32)\n-PR_IntervalToMilliseconds(PRIntervalTime ticks);\n-NSPR_API(PRUint32)\n-PR_IntervalToMicroseconds(PRIntervalTime ticks);\n+NSPR_API(PRUint32) PR_IntervalToSeconds(PRIntervalTime ticks);\n+NSPR_API(PRUint32) PR_IntervalToMilliseconds(PRIntervalTime ticks);\n+NSPR_API(PRUint32) PR_IntervalToMicroseconds(PRIntervalTime ticks);\n \n PR_END_EXTERN_C\n \n+\n #endif /* !defined(prinrval_h) */\n \n /* prinrval.h */\ndiff --git a/nspr/pr/include/prio.h b/nspr/pr/include/prio.h\nindex a9c2d76..f726d47 100644\n--- a/nspr/pr/include/prio.h\n+++ b/nspr/pr/include/prio.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -20,20 +21,20 @@\n PR_BEGIN_EXTERN_C\n \n /* Typedefs */\n-typedef struct PRDir PRDir;\n-typedef struct PRDirEntry PRDirEntry;\n+typedef struct PRDir            PRDir;\n+typedef struct PRDirEntry       PRDirEntry;\n #ifdef MOZ_UNICODE\n-typedef struct PRDirUTF16 PRDirUTF16;\n-typedef struct PRDirEntryUTF16 PRDirEntryUTF16;\n+typedef struct PRDirUTF16       PRDirUTF16;\n+typedef struct PRDirEntryUTF16  PRDirEntryUTF16;\n #endif /* MOZ_UNICODE */\n-typedef struct PRFileDesc PRFileDesc;\n-typedef struct PRFileInfo PRFileInfo;\n-typedef struct PRFileInfo64 PRFileInfo64;\n-typedef union PRNetAddr PRNetAddr;\n-typedef struct PRIOMethods PRIOMethods;\n-typedef struct PRPollDesc PRPollDesc;\n-typedef struct PRFilePrivate PRFilePrivate;\n-typedef struct PRSendFileData PRSendFileData;\n+typedef struct PRFileDesc       PRFileDesc;\n+typedef struct PRFileInfo       PRFileInfo;\n+typedef struct PRFileInfo64     PRFileInfo64;\n+typedef union  PRNetAddr        PRNetAddr;\n+typedef struct PRIOMethods      PRIOMethods;\n+typedef struct PRPollDesc       PRPollDesc;\n+typedef struct PRFilePrivate    PRFilePrivate;\n+typedef struct PRSendFileData   PRSendFileData;\n \n /*\n ***************************************************************************\n@@ -46,15 +47,15 @@ typedef struct PRSendFileData PRSendFileData;\n ***************************************************************************\n */\n \n-typedef PRIntn PRDescIdentity; /* see: Layering file descriptors */\n+typedef PRIntn PRDescIdentity;          /* see: Layering file descriptors */\n \n struct PRFileDesc {\n-    const PRIOMethods* methods; /* the I/O methods table */\n-    PRFilePrivate* secret;      /* layer dependent data */\n-    PRFileDesc *lower, *higher; /* pointers to adjacent layers */\n-    void(PR_CALLBACK* dtor)(PRFileDesc* fd);\n+    const PRIOMethods *methods;         /* the I/O methods table */\n+    PRFilePrivate *secret;              /* layer dependent data */\n+    PRFileDesc *lower, *higher;         /* pointers to adjacent layers */\n+    void (PR_CALLBACK *dtor)(PRFileDesc *fd);\n     /* A destructor function for layer */\n-    PRDescIdentity identity; /* Identity of this particular layer  */\n+    PRDescIdentity identity;            /* Identity of this particular layer  */\n };\n \n /*\n@@ -67,10 +68,10 @@ struct PRFileDesc {\n ***************************************************************************\n */\n typedef enum PRTransmitFileFlags {\n-    PR_TRANSMITFILE_KEEP_OPEN = 0,   /* socket is left open after file\n-                                      * is transmitted. */\n-    PR_TRANSMITFILE_CLOSE_SOCKET = 1 /* socket is closed after file\n-                                      * is transmitted. */\n+    PR_TRANSMITFILE_KEEP_OPEN = 0,    /* socket is left open after file\n+                                       * is transmitted. */\n+    PR_TRANSMITFILE_CLOSE_SOCKET = 1  /* socket is closed after file\n+                                       * is transmitted. */\n } PRTransmitFileFlags;\n \n /*\n@@ -128,41 +129,41 @@ typedef enum PRTransmitFileFlags {\n \n struct PRIPv6Addr {\n     union {\n-        PRUint8 _S6_u8[16];\n+        PRUint8  _S6_u8[16];\n         PRUint16 _S6_u16[8];\n         PRUint32 _S6_u32[4];\n         PRUint64 _S6_u64[2];\n     } _S6_un;\n };\n-#define pr_s6_addr _S6_un._S6_u8\n-#define pr_s6_addr16 _S6_un._S6_u16\n-#define pr_s6_addr32 _S6_un._S6_u32\n-#define pr_s6_addr64 _S6_un._S6_u64\n+#define pr_s6_addr      _S6_un._S6_u8\n+#define pr_s6_addr16    _S6_un._S6_u16\n+#define pr_s6_addr32    _S6_un._S6_u32\n+#define pr_s6_addr64    _S6_un._S6_u64\n \n typedef struct PRIPv6Addr PRIPv6Addr;\n \n union PRNetAddr {\n     struct {\n-        PRUint16 family; /* address family (0x00ff maskable) */\n-        char data[14];   /* raw address data */\n+        PRUint16 family;                /* address family (0x00ff maskable) */\n+        char data[14];                  /* raw address data */\n     } raw;\n     struct {\n-        PRUint16 family; /* address family (AF_INET) */\n-        PRUint16 port;   /* port number */\n-        PRUint32 ip;     /* The actual 32 bits of address */\n+        PRUint16 family;                /* address family (AF_INET) */\n+        PRUint16 port;                  /* port number */\n+        PRUint32 ip;                    /* The actual 32 bits of address */\n         char pad[8];\n     } inet;\n     struct {\n-        PRUint16 family;   /* address family (AF_INET6) */\n-        PRUint16 port;     /* port number */\n-        PRUint32 flowinfo; /* routing information */\n-        PRIPv6Addr ip;     /* the actual 128 bits of address */\n-        PRUint32 scope_id; /* set of interfaces for a scope */\n+        PRUint16 family;                /* address family (AF_INET6) */\n+        PRUint16 port;                  /* port number */\n+        PRUint32 flowinfo;              /* routing information */\n+        PRIPv6Addr ip;                  /* the actual 128 bits of address */\n+        PRUint32 scope_id;              /* set of interfaces for a scope */\n     } ipv6;\n #if defined(XP_UNIX) || defined(XP_WIN)\n-    struct {             /* Unix domain socket address */\n-        PRUint16 family; /* address family (AF_UNIX) */\n-        char path[104];  /* null-terminated pathname */\n+    struct {                            /* Unix domain socket address */\n+        PRUint16 family;                /* address family (AF_UNIX) */\n+        char path[104];                 /* null-terminated pathname */\n     } local;\n #endif\n };\n@@ -176,13 +177,14 @@ union PRNetAddr {\n ** the following enumeration are supported.\n ***************************************************************************\n */\n-typedef enum PRSockOption {\n-    PR_SockOpt_Nonblocking,    /* nonblocking io */\n-    PR_SockOpt_Linger,         /* linger on close if data present */\n-    PR_SockOpt_Reuseaddr,      /* allow local address reuse */\n-    PR_SockOpt_Keepalive,      /* keep connections alive */\n-    PR_SockOpt_RecvBufferSize, /* receive buffer size */\n-    PR_SockOpt_SendBufferSize, /* send buffer size */\n+typedef enum PRSockOption\n+{\n+    PR_SockOpt_Nonblocking,     /* nonblocking io */\n+    PR_SockOpt_Linger,          /* linger on close if data present */\n+    PR_SockOpt_Reuseaddr,       /* allow local address reuse */\n+    PR_SockOpt_Keepalive,       /* keep connections alive */\n+    PR_SockOpt_RecvBufferSize,  /* receive buffer size */\n+    PR_SockOpt_SendBufferSize,  /* send buffer size */\n \n     PR_SockOpt_IpTimeToLive,    /* time to live */\n     PR_SockOpt_IpTypeOfService, /* type of service and precedence */\n@@ -193,28 +195,30 @@ typedef enum PRSockOption {\n     PR_SockOpt_McastTimeToLive, /* multicast timetolive */\n     PR_SockOpt_McastLoopback,   /* multicast loopback */\n \n-    PR_SockOpt_NoDelay,    /* don't delay send to coalesce packets */\n-    PR_SockOpt_MaxSegment, /* maximum segment size */\n-    PR_SockOpt_Broadcast,  /* enable broadcast */\n-    PR_SockOpt_Reuseport,  /* allow local address & port reuse on\n-                            * platforms that support it */\n-    PR_SockOpt_DontFrag,   /* Do not fragment flag */\n+    PR_SockOpt_NoDelay,         /* don't delay send to coalesce packets */\n+    PR_SockOpt_MaxSegment,      /* maximum segment size */\n+    PR_SockOpt_Broadcast,       /* enable broadcast */\n+    PR_SockOpt_Reuseport,       /* allow local address & port reuse on\n+                                 * platforms that support it */\n+    PR_SockOpt_DontFrag,        /* Do not fragment flag */\n     PR_SockOpt_Last\n } PRSockOption;\n \n typedef struct PRLinger {\n-    PRBool polarity;       /* Polarity of the option's setting */\n-    PRIntervalTime linger; /* Time to linger before closing */\n+    PRBool polarity;            /* Polarity of the option's setting */\n+    PRIntervalTime linger;      /* Time to linger before closing */\n } PRLinger;\n \n typedef struct PRMcastRequest {\n-    PRNetAddr mcaddr; /* IP multicast address of group */\n-    PRNetAddr ifaddr; /* local IP address of interface */\n+    PRNetAddr mcaddr;           /* IP multicast address of group */\n+    PRNetAddr ifaddr;           /* local IP address of interface */\n } PRMcastRequest;\n \n-typedef struct PRSocketOptionData {\n+typedef struct PRSocketOptionData\n+{\n     PRSockOption option;\n-    union {\n+    union\n+    {\n         PRUintn ip_ttl;             /* IP time to live */\n         PRUintn mcast_ttl;          /* IP multicast time to live */\n         PRUintn tos;                /* IP type of service and precedence */\n@@ -246,7 +250,7 @@ typedef struct PRSocketOptionData {\n ***************************************************************************\n */\n typedef struct PRIOVec {\n-    char* iov_base;\n+    char *iov_base;\n     int iov_len;\n } PRIOVec;\n \n@@ -255,7 +259,8 @@ typedef struct PRIOVec {\n ** Discover what type of socket is being described by the file descriptor.\n ***************************************************************************\n */\n-typedef enum PRDescType {\n+typedef enum PRDescType\n+{\n     PR_DESC_FILE = 1,\n     PR_DESC_SOCKET_TCP = 2,\n     PR_DESC_SOCKET_UDP = 3,\n@@ -269,8 +274,7 @@ typedef enum PRSeekWhence {\n     PR_SEEK_END = 2\n } PRSeekWhence;\n \n-NSPR_API(PRDescType)\n-PR_GetDescType(PRFileDesc* file);\n+NSPR_API(PRDescType) PR_GetDescType(PRFileDesc *file);\n \n /*\n ***************************************************************************\n@@ -288,110 +292,99 @@ PR_GetDescType(PRFileDesc* file);\n ***************************************************************************\n */\n \n-typedef PRStatus(PR_CALLBACK* PRCloseFN)(PRFileDesc* fd);\n-typedef PRInt32(PR_CALLBACK* PRReadFN)(PRFileDesc* fd, void* buf,\n-                                       PRInt32 amount);\n-typedef PRInt32(PR_CALLBACK* PRWriteFN)(PRFileDesc* fd, const void* buf,\n-                                        PRInt32 amount);\n-typedef PRInt32(PR_CALLBACK* PRAvailableFN)(PRFileDesc* fd);\n-typedef PRInt64(PR_CALLBACK* PRAvailable64FN)(PRFileDesc* fd);\n-typedef PRStatus(PR_CALLBACK* PRFsyncFN)(PRFileDesc* fd);\n-typedef PROffset32(PR_CALLBACK* PRSeekFN)(PRFileDesc* fd, PROffset32 offset,\n-                                          PRSeekWhence how);\n-typedef PROffset64(PR_CALLBACK* PRSeek64FN)(PRFileDesc* fd, PROffset64 offset,\n-                                            PRSeekWhence how);\n-typedef PRStatus(PR_CALLBACK* PRFileInfoFN)(PRFileDesc* fd, PRFileInfo* info);\n-typedef PRStatus(PR_CALLBACK* PRFileInfo64FN)(PRFileDesc* fd,\n-                                              PRFileInfo64* info);\n-typedef PRInt32(PR_CALLBACK* PRWritevFN)(PRFileDesc* fd, const PRIOVec* iov,\n-                                         PRInt32 iov_size,\n-                                         PRIntervalTime timeout);\n-typedef PRStatus(PR_CALLBACK* PRConnectFN)(PRFileDesc* fd,\n-                                           const PRNetAddr* addr,\n-                                           PRIntervalTime timeout);\n-typedef PRFileDesc*(PR_CALLBACK* PRAcceptFN)(PRFileDesc* fd, PRNetAddr* addr,\n-                                             PRIntervalTime timeout);\n-typedef PRStatus(PR_CALLBACK* PRBindFN)(PRFileDesc* fd, const PRNetAddr* addr);\n-typedef PRStatus(PR_CALLBACK* PRListenFN)(PRFileDesc* fd, PRIntn backlog);\n-typedef PRStatus(PR_CALLBACK* PRShutdownFN)(PRFileDesc* fd, PRIntn how);\n-typedef PRInt32(PR_CALLBACK* PRRecvFN)(PRFileDesc* fd, void* buf,\n-                                       PRInt32 amount, PRIntn flags,\n-                                       PRIntervalTime timeout);\n-typedef PRInt32(PR_CALLBACK* PRSendFN)(PRFileDesc* fd, const void* buf,\n-                                       PRInt32 amount, PRIntn flags,\n-                                       PRIntervalTime timeout);\n-typedef PRInt32(PR_CALLBACK* PRRecvfromFN)(PRFileDesc* fd, void* buf,\n-                                           PRInt32 amount, PRIntn flags,\n-                                           PRNetAddr* addr,\n-                                           PRIntervalTime timeout);\n-typedef PRInt32(PR_CALLBACK* PRSendtoFN)(PRFileDesc* fd, const void* buf,\n-                                         PRInt32 amount, PRIntn flags,\n-                                         const PRNetAddr* addr,\n-                                         PRIntervalTime timeout);\n-typedef PRInt16(PR_CALLBACK* PRPollFN)(PRFileDesc* fd, PRInt16 in_flags,\n-                                       PRInt16* out_flags);\n-typedef PRInt32(PR_CALLBACK* PRAcceptreadFN)(PRFileDesc* sd, PRFileDesc** nd,\n-                                             PRNetAddr** raddr, void* buf,\n-                                             PRInt32 amount, PRIntervalTime t);\n-typedef PRInt32(PR_CALLBACK* PRTransmitfileFN)(PRFileDesc* sd, PRFileDesc* fd,\n-                                               const void* headers,\n-                                               PRInt32 hlen,\n-                                               PRTransmitFileFlags flags,\n-                                               PRIntervalTime t);\n-typedef PRStatus(PR_CALLBACK* PRGetsocknameFN)(PRFileDesc* fd, PRNetAddr* addr);\n-typedef PRStatus(PR_CALLBACK* PRGetpeernameFN)(PRFileDesc* fd, PRNetAddr* addr);\n-typedef PRStatus(PR_CALLBACK* PRGetsocketoptionFN)(PRFileDesc* fd,\n-                                                   PRSocketOptionData* data);\n-typedef PRStatus(PR_CALLBACK* PRSetsocketoptionFN)(\n-    PRFileDesc* fd, const PRSocketOptionData* data);\n-typedef PRInt32(PR_CALLBACK* PRSendfileFN)(PRFileDesc* networkSocket,\n-                                           PRSendFileData* sendData,\n-                                           PRTransmitFileFlags flags,\n-                                           PRIntervalTime timeout);\n-typedef PRStatus(PR_CALLBACK* PRConnectcontinueFN)(PRFileDesc* fd,\n-                                                   PRInt16 out_flags);\n-typedef PRIntn(PR_CALLBACK* PRReservedFN)(PRFileDesc* fd);\n+typedef PRStatus (PR_CALLBACK *PRCloseFN)(PRFileDesc *fd);\n+typedef PRInt32 (PR_CALLBACK *PRReadFN)(PRFileDesc *fd, void *buf, PRInt32 amount);\n+typedef PRInt32 (PR_CALLBACK *PRWriteFN)(PRFileDesc *fd, const void *buf, PRInt32 amount);\n+typedef PRInt32 (PR_CALLBACK *PRAvailableFN)(PRFileDesc *fd);\n+typedef PRInt64 (PR_CALLBACK *PRAvailable64FN)(PRFileDesc *fd);\n+typedef PRStatus (PR_CALLBACK *PRFsyncFN)(PRFileDesc *fd);\n+typedef PROffset32 (PR_CALLBACK *PRSeekFN)(PRFileDesc *fd, PROffset32 offset, PRSeekWhence how);\n+typedef PROffset64 (PR_CALLBACK *PRSeek64FN)(PRFileDesc *fd, PROffset64 offset, PRSeekWhence how);\n+typedef PRStatus (PR_CALLBACK *PRFileInfoFN)(PRFileDesc *fd, PRFileInfo *info);\n+typedef PRStatus (PR_CALLBACK *PRFileInfo64FN)(PRFileDesc *fd, PRFileInfo64 *info);\n+typedef PRInt32 (PR_CALLBACK *PRWritevFN)(\n+    PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size,\n+    PRIntervalTime timeout);\n+typedef PRStatus (PR_CALLBACK *PRConnectFN)(\n+    PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout);\n+typedef PRFileDesc* (PR_CALLBACK *PRAcceptFN) (\n+    PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout);\n+typedef PRStatus (PR_CALLBACK *PRBindFN)(PRFileDesc *fd, const PRNetAddr *addr);\n+typedef PRStatus (PR_CALLBACK *PRListenFN)(PRFileDesc *fd, PRIntn backlog);\n+typedef PRStatus (PR_CALLBACK *PRShutdownFN)(PRFileDesc *fd, PRIntn how);\n+typedef PRInt32 (PR_CALLBACK *PRRecvFN)(\n+    PRFileDesc *fd, void *buf, PRInt32 amount,\n+    PRIntn flags, PRIntervalTime timeout);\n+typedef PRInt32 (PR_CALLBACK *PRSendFN) (\n+    PRFileDesc *fd, const void *buf, PRInt32 amount,\n+    PRIntn flags, PRIntervalTime timeout);\n+typedef PRInt32 (PR_CALLBACK *PRRecvfromFN)(\n+    PRFileDesc *fd, void *buf, PRInt32 amount,\n+    PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout);\n+typedef PRInt32 (PR_CALLBACK *PRSendtoFN)(\n+    PRFileDesc *fd, const void *buf, PRInt32 amount,\n+    PRIntn flags, const PRNetAddr *addr, PRIntervalTime timeout);\n+typedef PRInt16 (PR_CALLBACK *PRPollFN)(\n+    PRFileDesc *fd, PRInt16 in_flags, PRInt16 *out_flags);\n+typedef PRInt32 (PR_CALLBACK *PRAcceptreadFN)(\n+    PRFileDesc *sd, PRFileDesc **nd, PRNetAddr **raddr,\n+    void *buf, PRInt32 amount, PRIntervalTime t);\n+typedef PRInt32 (PR_CALLBACK *PRTransmitfileFN)(\n+    PRFileDesc *sd, PRFileDesc *fd, const void *headers,\n+    PRInt32 hlen, PRTransmitFileFlags flags, PRIntervalTime t);\n+typedef PRStatus (PR_CALLBACK *PRGetsocknameFN)(PRFileDesc *fd, PRNetAddr *addr);\n+typedef PRStatus (PR_CALLBACK *PRGetpeernameFN)(PRFileDesc *fd, PRNetAddr *addr);\n+typedef PRStatus (PR_CALLBACK *PRGetsocketoptionFN)(\n+    PRFileDesc *fd, PRSocketOptionData *data);\n+typedef PRStatus (PR_CALLBACK *PRSetsocketoptionFN)(\n+    PRFileDesc *fd, const PRSocketOptionData *data);\n+typedef PRInt32 (PR_CALLBACK *PRSendfileFN)(\n+    PRFileDesc *networkSocket, PRSendFileData *sendData,\n+    PRTransmitFileFlags flags, PRIntervalTime timeout);\n+typedef PRStatus (PR_CALLBACK *PRConnectcontinueFN)(\n+    PRFileDesc *fd, PRInt16 out_flags);\n+typedef PRIntn (PR_CALLBACK *PRReservedFN)(PRFileDesc *fd);\n \n struct PRIOMethods {\n-    PRDescType file_type;          /* Type of file represented (tos)           */\n-    PRCloseFN close;               /* close file and destroy descriptor        */\n-    PRReadFN read;                 /* read up to specified bytes into buffer   */\n-    PRWriteFN write;               /* write specified bytes from buffer        */\n-    PRAvailableFN available;       /* determine number of bytes available      */\n-    PRAvailable64FN available64;   /*          ditto, 64 bit                   */\n-    PRFsyncFN fsync;               /* flush all buffers to permanent store     */\n-    PRSeekFN seek;                 /* position the file to the desired place   */\n-    PRSeek64FN seek64;             /*           ditto, 64 bit                  */\n-    PRFileInfoFN fileInfo;         /* Get information about an open file       */\n-    PRFileInfo64FN fileInfo64;     /*           ditto, 64 bit                  */\n-    PRWritevFN writev;             /* Write segments as described by iovector  */\n-    PRConnectFN connect;           /* Connect to the specified (net) address   */\n-    PRAcceptFN accept;             /* Accept a connection for a (net) peer     */\n-    PRBindFN bind;                 /* Associate a (net) address with the fd    */\n-    PRListenFN listen;             /* Prepare to listen for (net) connections  */\n-    PRShutdownFN shutdown;         /* Shutdown a (net) connection              */\n-    PRRecvFN recv;                 /* Solicit up the the specified bytes       */\n-    PRSendFN send;                 /* Send all the bytes specified             */\n-    PRRecvfromFN recvfrom;         /* Solicit (net) bytes and report source    */\n-    PRSendtoFN sendto;             /* Send bytes to (net) address specified    */\n-    PRPollFN poll;                 /* Test the fd to see if it is ready        */\n-    PRAcceptreadFN acceptread;     /* Accept and read on a new (net) fd        */\n-    PRTransmitfileFN transmitfile; /* Transmit at entire file                  */\n-    PRGetsocknameFN getsockname;   /* Get (net) address associated with fd     */\n-    PRGetpeernameFN getpeername;   /* Get peer's (net) address                 */\n-    PRReservedFN reserved_fn_6;    /* reserved for future use */\n-    PRReservedFN reserved_fn_5;    /* reserved for future use */\n+    PRDescType file_type;           /* Type of file represented (tos)           */\n+    PRCloseFN close;                /* close file and destroy descriptor        */\n+    PRReadFN read;                  /* read up to specified bytes into buffer   */\n+    PRWriteFN write;                /* write specified bytes from buffer        */\n+    PRAvailableFN available;        /* determine number of bytes available      */\n+    PRAvailable64FN available64;    /*          ditto, 64 bit                   */\n+    PRFsyncFN fsync;                /* flush all buffers to permanent store     */\n+    PRSeekFN seek;                  /* position the file to the desired place   */\n+    PRSeek64FN seek64;              /*           ditto, 64 bit                  */\n+    PRFileInfoFN fileInfo;          /* Get information about an open file       */\n+    PRFileInfo64FN fileInfo64;      /*           ditto, 64 bit                  */\n+    PRWritevFN writev;              /* Write segments as described by iovector  */\n+    PRConnectFN connect;            /* Connect to the specified (net) address   */\n+    PRAcceptFN accept;              /* Accept a connection for a (net) peer     */\n+    PRBindFN bind;                  /* Associate a (net) address with the fd    */\n+    PRListenFN listen;              /* Prepare to listen for (net) connections  */\n+    PRShutdownFN shutdown;          /* Shutdown a (net) connection              */\n+    PRRecvFN recv;                  /* Solicit up the the specified bytes       */\n+    PRSendFN send;                  /* Send all the bytes specified             */\n+    PRRecvfromFN recvfrom;          /* Solicit (net) bytes and report source    */\n+    PRSendtoFN sendto;              /* Send bytes to (net) address specified    */\n+    PRPollFN poll;                  /* Test the fd to see if it is ready        */\n+    PRAcceptreadFN acceptread;      /* Accept and read on a new (net) fd        */\n+    PRTransmitfileFN transmitfile;  /* Transmit at entire file                  */\n+    PRGetsocknameFN getsockname;    /* Get (net) address associated with fd     */\n+    PRGetpeernameFN getpeername;    /* Get peer's (net) address                 */\n+    PRReservedFN reserved_fn_6;     /* reserved for future use */\n+    PRReservedFN reserved_fn_5;     /* reserved for future use */\n     PRGetsocketoptionFN getsocketoption;\n     /* Get current setting of specified option  */\n     PRSetsocketoptionFN setsocketoption;\n     /* Set value of specified option            */\n-    PRSendfileFN sendfile; /* Send a (partial) file with header/trailer*/\n+    PRSendfileFN sendfile;          /* Send a (partial) file with header/trailer*/\n     PRConnectcontinueFN connectcontinue;\n     /* Continue a nonblocking connect */\n-    PRReservedFN reserved_fn_3; /* reserved for future use */\n-    PRReservedFN reserved_fn_2; /* reserved for future use */\n-    PRReservedFN reserved_fn_1; /* reserved for future use */\n-    PRReservedFN reserved_fn_0; /* reserved for future use */\n+    PRReservedFN reserved_fn_3;     /* reserved for future use */\n+    PRReservedFN reserved_fn_2;     /* reserved for future use */\n+    PRReservedFN reserved_fn_1;     /* reserved for future use */\n+    PRReservedFN reserved_fn_0;     /* reserved for future use */\n };\n \n /*\n@@ -413,18 +406,18 @@ struct PRIOMethods {\n  **************************************************************************\n  */\n \n-typedef enum PRSpecialFD {\n-    PR_StandardInput,  /* standard input */\n-    PR_StandardOutput, /* standard output */\n-    PR_StandardError   /* standard error */\n+typedef enum PRSpecialFD\n+{\n+    PR_StandardInput,          /* standard input */\n+    PR_StandardOutput,         /* standard output */\n+    PR_StandardError           /* standard error */\n } PRSpecialFD;\n \n-NSPR_API(PRFileDesc*)\n-PR_GetSpecialFD(PRSpecialFD id);\n+NSPR_API(PRFileDesc*) PR_GetSpecialFD(PRSpecialFD id);\n \n-#define PR_STDIN PR_GetSpecialFD(PR_StandardInput)\n-#define PR_STDOUT PR_GetSpecialFD(PR_StandardOutput)\n-#define PR_STDERR PR_GetSpecialFD(PR_StandardError)\n+#define PR_STDIN    PR_GetSpecialFD(PR_StandardInput)\n+#define PR_STDOUT   PR_GetSpecialFD(PR_StandardOutput)\n+#define PR_STDERR   PR_GetSpecialFD(PR_StandardError)\n \n /*\n  **************************************************************************\n@@ -455,19 +448,15 @@ PR_GetSpecialFD(PRSpecialFD id);\n  **************************************************************************\n  */\n \n-#define PR_IO_LAYER_HEAD (PRDescIdentity) - 3\n-#define PR_INVALID_IO_LAYER (PRDescIdentity) - 1\n-#define PR_TOP_IO_LAYER (PRDescIdentity) - 2\n+#define PR_IO_LAYER_HEAD (PRDescIdentity)-3\n+#define PR_INVALID_IO_LAYER (PRDescIdentity)-1\n+#define PR_TOP_IO_LAYER (PRDescIdentity)-2\n #define PR_NSPR_IO_LAYER (PRDescIdentity)0\n \n-NSPR_API(PRDescIdentity)\n-PR_GetUniqueIdentity(const char* layer_name);\n-NSPR_API(const char*)\n-PR_GetNameForIdentity(PRDescIdentity ident);\n-NSPR_API(PRDescIdentity)\n-PR_GetLayersIdentity(PRFileDesc* fd);\n-NSPR_API(PRFileDesc*)\n-PR_GetIdentitiesLayer(PRFileDesc* fd_stack, PRDescIdentity id);\n+NSPR_API(PRDescIdentity) PR_GetUniqueIdentity(const char *layer_name);\n+NSPR_API(const char*) PR_GetNameForIdentity(PRDescIdentity ident);\n+NSPR_API(PRDescIdentity) PR_GetLayersIdentity(PRFileDesc* fd);\n+NSPR_API(PRFileDesc*) PR_GetIdentitiesLayer(PRFileDesc* fd_stack, PRDescIdentity id);\n \n /*\n  **************************************************************************\n@@ -477,8 +466,7 @@ PR_GetIdentitiesLayer(PRFileDesc* fd_stack, PRDescIdentity id);\n  * layer's methods table. You may NOT modify the table directly.\n  **************************************************************************\n  */\n-NSPR_API(const PRIOMethods*)\n-PR_GetDefaultIOMethods(void);\n+NSPR_API(const PRIOMethods *) PR_GetDefaultIOMethods(void);\n \n /*\n  **************************************************************************\n@@ -489,8 +477,8 @@ PR_GetDefaultIOMethods(void);\n  * provided. The runtime will not modify the table nor test its correctness.\n  **************************************************************************\n  */\n-NSPR_API(PRFileDesc*)\n-PR_CreateIOLayerStub(PRDescIdentity ident, const PRIOMethods* methods);\n+NSPR_API(PRFileDesc*) PR_CreateIOLayerStub(\n+    PRDescIdentity ident, const PRIOMethods *methods);\n \n /*\n  **************************************************************************\n@@ -506,8 +494,7 @@ PR_CreateIOLayerStub(PRDescIdentity ident, const PRIOMethods* methods);\n  * pushing and popping layers of the stack.\n  **************************************************************************\n  */\n-NSPR_API(PRFileDesc*)\n-PR_CreateIOLayer(PRFileDesc* fd);\n+NSPR_API(PRFileDesc*) PR_CreateIOLayer(PRFileDesc* fd);\n \n /*\n  **************************************************************************\n@@ -523,8 +510,8 @@ PR_CreateIOLayer(PRFileDesc* fd);\n  * stack will not change.\n  **************************************************************************\n  */\n-NSPR_API(PRStatus)\n-PR_PushIOLayer(PRFileDesc* fd_stack, PRDescIdentity id, PRFileDesc* layer);\n+NSPR_API(PRStatus) PR_PushIOLayer(\n+    PRFileDesc *fd_stack, PRDescIdentity id, PRFileDesc *layer);\n \n /*\n  **************************************************************************\n@@ -540,8 +527,7 @@ PR_PushIOLayer(PRFileDesc* fd_stack, PRDescIdentity id, PRFileDesc* layer);\n  * that file descriptor will remain valid.\n  **************************************************************************\n  */\n-NSPR_API(PRFileDesc*)\n-PR_PopIOLayer(PRFileDesc* fd_stack, PRDescIdentity id);\n+NSPR_API(PRFileDesc*) PR_PopIOLayer(PRFileDesc *fd_stack, PRDescIdentity id);\n \n /*\n  **************************************************************************\n@@ -588,14 +574,14 @@ PR_PopIOLayer(PRFileDesc* fd_stack, PRDescIdentity id);\n  */\n \n /* Open flags */\n-#define PR_RDONLY 0x01\n-#define PR_WRONLY 0x02\n-#define PR_RDWR 0x04\n-#define PR_CREATE_FILE 0x08\n-#define PR_APPEND 0x10\n-#define PR_TRUNCATE 0x20\n-#define PR_SYNC 0x40\n-#define PR_EXCL 0x80\n+#define PR_RDONLY       0x01\n+#define PR_WRONLY       0x02\n+#define PR_RDWR         0x04\n+#define PR_CREATE_FILE  0x08\n+#define PR_APPEND       0x10\n+#define PR_TRUNCATE     0x20\n+#define PR_SYNC         0x40\n+#define PR_EXCL         0x80\n \n /*\n ** File modes ....\n@@ -615,8 +601,7 @@ PR_PopIOLayer(PRFileDesc* fd_stack, PRDescIdentity id);\n **\n */\n \n-NSPR_API(PRFileDesc*)\n-PR_Open(const char* name, PRIntn flags, PRIntn mode);\n+NSPR_API(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode);\n \n /*\n  **************************************************************************\n@@ -629,28 +614,28 @@ PR_Open(const char* name, PRIntn flags, PRIntn mode);\n  */\n \n /* File mode bits */\n-#define PR_IRWXU 00700 /* read, write, execute/search by owner */\n-#define PR_IRUSR 00400 /* read permission, owner */\n-#define PR_IWUSR 00200 /* write permission, owner */\n-#define PR_IXUSR 00100 /* execute/search permission, owner */\n-#define PR_IRWXG 00070 /* read, write, execute/search by group */\n-#define PR_IRGRP 00040 /* read permission, group */\n-#define PR_IWGRP 00020 /* write permission, group */\n-#define PR_IXGRP 00010 /* execute/search permission, group */\n-#define PR_IRWXO 00007 /* read, write, execute/search by others */\n-#define PR_IROTH 00004 /* read permission, others */\n-#define PR_IWOTH 00002 /* write permission, others */\n-#define PR_IXOTH 00001 /* execute/search permission, others */\n-\n-NSPR_API(PRFileDesc*)\n-PR_OpenFile(const char* name, PRIntn flags, PRIntn mode);\n+#define PR_IRWXU 00700  /* read, write, execute/search by owner */\n+#define PR_IRUSR 00400  /* read permission, owner */\n+#define PR_IWUSR 00200  /* write permission, owner */\n+#define PR_IXUSR 00100  /* execute/search permission, owner */\n+#define PR_IRWXG 00070  /* read, write, execute/search by group */\n+#define PR_IRGRP 00040  /* read permission, group */\n+#define PR_IWGRP 00020  /* write permission, group */\n+#define PR_IXGRP 00010  /* execute/search permission, group */\n+#define PR_IRWXO 00007  /* read, write, execute/search by others */\n+#define PR_IROTH 00004  /* read permission, others */\n+#define PR_IWOTH 00002  /* write permission, others */\n+#define PR_IXOTH 00001  /* execute/search permission, others */\n+\n+NSPR_API(PRFileDesc*) PR_OpenFile(\n+    const char *name, PRIntn flags, PRIntn mode);\n \n #ifdef MOZ_UNICODE\n /*\n  * EXPERIMENTAL: This function may be removed in a future release.\n  */\n-NSPR_API(PRFileDesc*)\n-PR_OpenFileUTF16(const PRUnichar* name, PRIntn flags, PRIntn mode);\n+NSPR_API(PRFileDesc*) PR_OpenFileUTF16(\n+    const PRUnichar *name, PRIntn flags, PRIntn mode);\n #endif /* MOZ_UNICODE */\n \n /*\n@@ -673,8 +658,7 @@ PR_OpenFileUTF16(const PRUnichar* name, PRIntn flags, PRIntn mode);\n  **************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_Close(PRFileDesc* fd);\n+NSPR_API(PRStatus)    PR_Close(PRFileDesc *fd);\n \n /*\n  **************************************************************************\n@@ -709,8 +693,7 @@ PR_Close(PRFileDesc* fd);\n  **************************************************************************\n  */\n \n-NSPR_API(PRInt32)\n-PR_Read(PRFileDesc* fd, void* buf, PRInt32 amount);\n+NSPR_API(PRInt32) PR_Read(PRFileDesc *fd, void *buf, PRInt32 amount);\n \n /*\n  ***************************************************************************\n@@ -734,8 +717,7 @@ PR_Read(PRFileDesc* fd, void* buf, PRInt32 amount);\n  ***************************************************************************\n  */\n \n-NSPR_API(PRInt32)\n-PR_Write(PRFileDesc* fd, const void* buf, PRInt32 amount);\n+NSPR_API(PRInt32) PR_Write(PRFileDesc *fd,const void *buf,PRInt32 amount);\n \n /*\n  ***************************************************************************\n@@ -767,11 +749,11 @@ PR_Write(PRFileDesc* fd, const void* buf, PRInt32 amount);\n  ***************************************************************************\n  */\n \n-#define PR_MAX_IOVECTOR_SIZE 16 /* 'iov_size' must be <= */\n+#define PR_MAX_IOVECTOR_SIZE 16   /* 'iov_size' must be <= */\n \n-NSPR_API(PRInt32)\n-PR_Writev(PRFileDesc* fd, const PRIOVec* iov, PRInt32 iov_size,\n-          PRIntervalTime timeout);\n+NSPR_API(PRInt32) PR_Writev(\n+    PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size,\n+    PRIntervalTime timeout);\n \n /*\n  ***************************************************************************\n@@ -790,29 +772,29 @@ PR_Writev(PRFileDesc* fd, const PRIOVec* iov, PRInt32 iov_size,\n  ***************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_Delete(const char* name);\n+NSPR_API(PRStatus) PR_Delete(const char *name);\n \n /**************************************************************************/\n \n-typedef enum PRFileType {\n+typedef enum PRFileType\n+{\n     PR_FILE_FILE = 1,\n     PR_FILE_DIRECTORY = 2,\n     PR_FILE_OTHER = 3\n } PRFileType;\n \n struct PRFileInfo {\n-    PRFileType type;     /* Type of file */\n-    PROffset32 size;     /* Size, in bytes, of file's contents */\n-    PRTime creationTime; /* Creation time per definition of PRTime */\n-    PRTime modifyTime;   /* Last modification time per definition of PRTime */\n+    PRFileType type;        /* Type of file */\n+    PROffset32 size;        /* Size, in bytes, of file's contents */\n+    PRTime creationTime;    /* Creation time per definition of PRTime */\n+    PRTime modifyTime;      /* Last modification time per definition of PRTime */\n };\n \n struct PRFileInfo64 {\n-    PRFileType type;     /* Type of file */\n-    PROffset64 size;     /* Size, in bytes, of file's contents */\n-    PRTime creationTime; /* Creation time per definition of PRTime */\n-    PRTime modifyTime;   /* Last modification time per definition of PRTime */\n+    PRFileType type;        /* Type of file */\n+    PROffset64 size;        /* Size, in bytes, of file's contents */\n+    PRTime creationTime;    /* Creation time per definition of PRTime */\n+    PRTime modifyTime;      /* Last modification time per definition of PRTime */\n };\n \n /****************************************************************************\n@@ -833,17 +815,14 @@ struct PRFileInfo64 {\n  ***************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_GetFileInfo(const char* fn, PRFileInfo* info);\n-NSPR_API(PRStatus)\n-PR_GetFileInfo64(const char* fn, PRFileInfo64* info);\n+NSPR_API(PRStatus) PR_GetFileInfo(const char *fn, PRFileInfo *info);\n+NSPR_API(PRStatus) PR_GetFileInfo64(const char *fn, PRFileInfo64 *info);\n \n #ifdef MOZ_UNICODE\n /*\n  * EXPERIMENTAL: This function may be removed in a future release.\n  */\n-NSPR_API(PRStatus)\n-PR_GetFileInfo64UTF16(const PRUnichar* fn, PRFileInfo64* info);\n+NSPR_API(PRStatus) PR_GetFileInfo64UTF16(const PRUnichar *fn, PRFileInfo64 *info);\n #endif /* MOZ_UNICODE */\n \n /*\n@@ -863,10 +842,8 @@ PR_GetFileInfo64UTF16(const PRUnichar* fn, PRFileInfo64* info);\n  ***************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_GetOpenFileInfo(PRFileDesc* fd, PRFileInfo* info);\n-NSPR_API(PRStatus)\n-PR_GetOpenFileInfo64(PRFileDesc* fd, PRFileInfo64* info);\n+NSPR_API(PRStatus) PR_GetOpenFileInfo(PRFileDesc *fd, PRFileInfo *info);\n+NSPR_API(PRStatus) PR_GetOpenFileInfo64(PRFileDesc *fd, PRFileInfo64 *info);\n \n /*\n  **************************************************************************\n@@ -884,8 +861,7 @@ PR_GetOpenFileInfo64(PRFileDesc* fd, PRFileInfo64* info);\n  **************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_Rename(const char* from, const char* to);\n+NSPR_API(PRStatus)    PR_Rename(const char *from, const char *to);\n \n /*\n  *************************************************************************\n@@ -917,8 +893,7 @@ typedef enum PRAccessHow {\n     PR_ACCESS_READ_OK = 3\n } PRAccessHow;\n \n-NSPR_API(PRStatus)\n-PR_Access(const char* name, PRAccessHow how);\n+NSPR_API(PRStatus) PR_Access(const char *name, PRAccessHow how);\n \n /*\n  *************************************************************************\n@@ -953,10 +928,8 @@ PR_Access(const char* name, PRAccessHow how);\n  *************************************************************************\n  */\n \n-NSPR_API(PROffset32)\n-PR_Seek(PRFileDesc* fd, PROffset32 offset, PRSeekWhence whence);\n-NSPR_API(PROffset64)\n-PR_Seek64(PRFileDesc* fd, PROffset64 offset, PRSeekWhence whence);\n+NSPR_API(PROffset32) PR_Seek(PRFileDesc *fd, PROffset32 offset, PRSeekWhence whence);\n+NSPR_API(PROffset64) PR_Seek64(PRFileDesc *fd, PROffset64 offset, PRSeekWhence whence);\n \n /*\n  ************************************************************************\n@@ -978,10 +951,8 @@ PR_Seek64(PRFileDesc* fd, PROffset64 offset, PRSeekWhence whence);\n  ************************************************************************\n  */\n \n-NSPR_API(PRInt32)\n-PR_Available(PRFileDesc* fd);\n-NSPR_API(PRInt64)\n-PR_Available64(PRFileDesc* fd);\n+NSPR_API(PRInt32) PR_Available(PRFileDesc *fd);\n+NSPR_API(PRInt64) PR_Available64(PRFileDesc *fd);\n \n /*\n  ************************************************************************\n@@ -1000,24 +971,23 @@ PR_Available64(PRFileDesc* fd);\n  ************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_Sync(PRFileDesc* fd);\n+NSPR_API(PRStatus)  PR_Sync(PRFileDesc *fd);\n \n /************************************************************************/\n \n struct PRDirEntry {\n-    const char* name; /* name of entry, relative to directory name */\n+    const char *name;        /* name of entry, relative to directory name */\n };\n \n #ifdef MOZ_UNICODE\n struct PRDirEntryUTF16 {\n-    const PRUnichar* name; /* name of entry in UTF16, relative to\n-                            * directory name */\n+    const PRUnichar *name;   /* name of entry in UTF16, relative to\n+                              * directory name */\n };\n #endif /* MOZ_UNICODE */\n \n #if !defined(NO_NSPR_10_SUPPORT)\n-#define PR_DirName(dirEntry) (dirEntry->name)\n+#define PR_DirName(dirEntry)    (dirEntry->name)\n #endif\n \n /*\n@@ -1040,15 +1010,13 @@ struct PRDirEntryUTF16 {\n  *************************************************************************\n  */\n \n-NSPR_API(PRDir*)\n-PR_OpenDir(const char* name);\n+NSPR_API(PRDir*) PR_OpenDir(const char *name);\n \n #ifdef MOZ_UNICODE\n /*\n  * EXPERIMENTAL: This function may be removed in a future release.\n  */\n-NSPR_API(PRDirUTF16*)\n-PR_OpenDirUTF16(const PRUnichar* name);\n+NSPR_API(PRDirUTF16*) PR_OpenDirUTF16(const PRUnichar *name);\n #endif /* MOZ_UNICODE */\n \n /*\n@@ -1082,15 +1050,13 @@ typedef enum PRDirFlags {\n     PR_SKIP_HIDDEN = 0x4\n } PRDirFlags;\n \n-NSPR_API(PRDirEntry*)\n-PR_ReadDir(PRDir* dir, PRDirFlags flags);\n+NSPR_API(PRDirEntry*) PR_ReadDir(PRDir *dir, PRDirFlags flags);\n \n #ifdef MOZ_UNICODE\n /*\n  * EXPERIMENTAL: This function may be removed in a future release.\n  */\n-NSPR_API(PRDirEntryUTF16*)\n-PR_ReadDirUTF16(PRDirUTF16* dir, PRDirFlags flags);\n+NSPR_API(PRDirEntryUTF16*) PR_ReadDirUTF16(PRDirUTF16 *dir, PRDirFlags flags);\n #endif /* MOZ_UNICODE */\n \n /*\n@@ -1110,15 +1076,13 @@ PR_ReadDirUTF16(PRDirUTF16* dir, PRDirFlags flags);\n  *************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_CloseDir(PRDir* dir);\n+NSPR_API(PRStatus) PR_CloseDir(PRDir *dir);\n \n #ifdef MOZ_UNICODE\n /*\n  * EXPERIMENTAL: This function may be removed in a future release.\n  */\n-NSPR_API(PRStatus)\n-PR_CloseDirUTF16(PRDirUTF16* dir);\n+NSPR_API(PRStatus) PR_CloseDirUTF16(PRDirUTF16 *dir);\n #endif /* MOZ_UNICODE */\n \n /*\n@@ -1141,8 +1105,7 @@ PR_CloseDirUTF16(PRDirUTF16* dir);\n  *************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_MkDir(const char* name, PRIntn mode);\n+NSPR_API(PRStatus) PR_MkDir(const char *name, PRIntn mode);\n \n /*\n  *************************************************************************\n@@ -1154,8 +1117,7 @@ PR_MkDir(const char* name, PRIntn mode);\n  *************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_MakeDir(const char* name, PRIntn mode);\n+NSPR_API(PRStatus) PR_MakeDir(const char *name, PRIntn mode);\n \n /*\n  *************************************************************************\n@@ -1175,8 +1137,7 @@ PR_MakeDir(const char* name, PRIntn mode);\n  **************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_RmDir(const char* name);\n+NSPR_API(PRStatus) PR_RmDir(const char *name);\n \n /*\n  *************************************************************************\n@@ -1195,8 +1156,7 @@ PR_RmDir(const char* name);\n  **************************************************************************\n  */\n \n-NSPR_API(PRFileDesc*)\n-PR_NewUDPSocket(void);\n+NSPR_API(PRFileDesc*)    PR_NewUDPSocket(void);\n \n /*\n  *************************************************************************\n@@ -1215,8 +1175,7 @@ PR_NewUDPSocket(void);\n  **************************************************************************\n  */\n \n-NSPR_API(PRFileDesc*)\n-PR_NewTCPSocket(void);\n+NSPR_API(PRFileDesc*)    PR_NewTCPSocket(void);\n \n /*\n  *************************************************************************\n@@ -1236,8 +1195,7 @@ PR_NewTCPSocket(void);\n  **************************************************************************\n  */\n \n-NSPR_API(PRFileDesc*)\n-PR_OpenUDPSocket(PRIntn af);\n+NSPR_API(PRFileDesc*)    PR_OpenUDPSocket(PRIntn af);\n \n /*\n  *************************************************************************\n@@ -1257,8 +1215,7 @@ PR_OpenUDPSocket(PRIntn af);\n  **************************************************************************\n  */\n \n-NSPR_API(PRFileDesc*)\n-PR_OpenTCPSocket(PRIntn af);\n+NSPR_API(PRFileDesc*)    PR_OpenTCPSocket(PRIntn af);\n \n /*\n  *************************************************************************\n@@ -1286,8 +1243,8 @@ PR_OpenTCPSocket(PRIntn af);\n  **************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_Connect(PRFileDesc* fd, const PRNetAddr* addr, PRIntervalTime timeout);\n+NSPR_API(PRStatus) PR_Connect(\n+    PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout);\n \n /*\n  *************************************************************************\n@@ -1321,8 +1278,7 @@ PR_Connect(PRFileDesc* fd, const PRNetAddr* addr, PRIntervalTime timeout);\n  *       error code.\n  */\n \n-NSPR_API(PRStatus)\n-PR_ConnectContinue(PRFileDesc* fd, PRInt16 out_flags);\n+NSPR_API(PRStatus)    PR_ConnectContinue(PRFileDesc *fd, PRInt16 out_flags);\n \n /*\n  *************************************************************************\n@@ -1352,8 +1308,7 @@ PR_ConnectContinue(PRFileDesc* fd, PRInt16 out_flags);\n  *       error code.\n  */\n \n-NSPR_API(PRStatus)\n-PR_GetConnectStatus(const PRPollDesc* pd);\n+NSPR_API(PRStatus)    PR_GetConnectStatus(const PRPollDesc *pd);\n \n /*\n  *************************************************************************\n@@ -1377,8 +1332,8 @@ PR_GetConnectStatus(const PRPollDesc* pd);\n  **************************************************************************\n  */\n \n-NSPR_API(PRFileDesc*)\n-PR_Accept(PRFileDesc* fd, PRNetAddr* addr, PRIntervalTime timeout);\n+NSPR_API(PRFileDesc*) PR_Accept(\n+    PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout);\n \n /*\n  *************************************************************************\n@@ -1399,8 +1354,7 @@ PR_Accept(PRFileDesc* fd, PRNetAddr* addr, PRIntervalTime timeout);\n  **************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_Bind(PRFileDesc* fd, const PRNetAddr* addr);\n+NSPR_API(PRStatus) PR_Bind(PRFileDesc *fd, const PRNetAddr *addr);\n \n /*\n  *************************************************************************\n@@ -1422,8 +1376,7 @@ PR_Bind(PRFileDesc* fd, const PRNetAddr* addr);\n  **************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_Listen(PRFileDesc* fd, PRIntn backlog);\n+NSPR_API(PRStatus) PR_Listen(PRFileDesc *fd, PRIntn backlog);\n \n /*\n  *************************************************************************\n@@ -1447,14 +1400,14 @@ PR_Listen(PRFileDesc* fd, PRIntn backlog);\n  **************************************************************************\n  */\n \n-typedef enum PRShutdownHow {\n-    PR_SHUTDOWN_RCV = 0,  /* disallow further receives */\n-    PR_SHUTDOWN_SEND = 1, /* disallow further sends */\n-    PR_SHUTDOWN_BOTH = 2  /* disallow further receives and sends */\n+typedef enum PRShutdownHow\n+{\n+    PR_SHUTDOWN_RCV = 0,      /* disallow further receives */\n+    PR_SHUTDOWN_SEND = 1,     /* disallow further sends */\n+    PR_SHUTDOWN_BOTH = 2      /* disallow further receives and sends */\n } PRShutdownHow;\n \n-NSPR_API(PRStatus)\n-PR_Shutdown(PRFileDesc* fd, PRShutdownHow how);\n+NSPR_API(PRStatus)    PR_Shutdown(PRFileDesc *fd, PRShutdownHow how);\n \n /*\n  *************************************************************************\n@@ -1487,9 +1440,8 @@ PR_Shutdown(PRFileDesc* fd, PRShutdownHow how);\n \n #define PR_MSG_PEEK 0x2\n \n-NSPR_API(PRInt32)\n-PR_Recv(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n-        PRIntervalTime timeout);\n+NSPR_API(PRInt32)    PR_Recv(PRFileDesc *fd, void *buf, PRInt32 amount,\n+                             PRIntn flags, PRIntervalTime timeout);\n \n /*\n  *************************************************************************\n@@ -1519,9 +1471,8 @@ PR_Recv(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n  **************************************************************************\n  */\n \n-NSPR_API(PRInt32)\n-PR_Send(PRFileDesc* fd, const void* buf, PRInt32 amount, PRIntn flags,\n-        PRIntervalTime timeout);\n+NSPR_API(PRInt32)    PR_Send(PRFileDesc *fd, const void *buf, PRInt32 amount,\n+                             PRIntn flags, PRIntervalTime timeout);\n \n /*\n  *************************************************************************\n@@ -1555,9 +1506,9 @@ PR_Send(PRFileDesc* fd, const void* buf, PRInt32 amount, PRIntn flags,\n  **************************************************************************\n  */\n \n-NSPR_API(PRInt32)\n-PR_RecvFrom(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n-            PRNetAddr* addr, PRIntervalTime timeout);\n+NSPR_API(PRInt32) PR_RecvFrom(\n+    PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,\n+    PRNetAddr *addr, PRIntervalTime timeout);\n \n /*\n  *************************************************************************\n@@ -1588,9 +1539,9 @@ PR_RecvFrom(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n  **************************************************************************\n  */\n \n-NSPR_API(PRInt32)\n-PR_SendTo(PRFileDesc* fd, const void* buf, PRInt32 amount, PRIntn flags,\n-          const PRNetAddr* addr, PRIntervalTime timeout);\n+NSPR_API(PRInt32) PR_SendTo(\n+    PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,\n+    const PRNetAddr *addr, PRIntervalTime timeout);\n \n /*\n *************************************************************************\n@@ -1628,10 +1579,10 @@ PR_SendTo(PRFileDesc* fd, const void* buf, PRInt32 amount, PRIntn flags,\n **************************************************************************\n */\n \n-NSPR_API(PRInt32)\n-PR_TransmitFile(PRFileDesc* networkSocket, PRFileDesc* sourceFile,\n-                const void* headers, PRInt32 hlen, PRTransmitFileFlags flags,\n-                PRIntervalTime timeout);\n+NSPR_API(PRInt32) PR_TransmitFile(\n+    PRFileDesc *networkSocket, PRFileDesc *sourceFile,\n+    const void *headers, PRInt32 hlen, PRTransmitFileFlags flags,\n+    PRIntervalTime timeout);\n \n /*\n *************************************************************************\n@@ -1668,20 +1619,21 @@ PR_TransmitFile(PRFileDesc* networkSocket, PRFileDesc* sourceFile,\n */\n \n struct PRSendFileData {\n-    PRFileDesc* fd;       /* file to send                         */\n-    PRUint32 file_offset; /* file offset                          */\n-    PRSize file_nbytes;   /* number of bytes of file data to send */\n+    PRFileDesc  *fd;            /* file to send                         */\n+    PRUint32    file_offset;    /* file offset                          */\n+    PRSize      file_nbytes;    /* number of bytes of file data to send */\n     /* if 0, send data from file_offset to  */\n     /* end-of-file.                         */\n-    const void* header;  /* header buffer                        */\n-    PRInt32 hlen;        /* header len                           */\n-    const void* trailer; /* trailer buffer                       */\n-    PRInt32 tlen;        /* trailer len                          */\n+    const void  *header;        /* header buffer                        */\n+    PRInt32     hlen;           /* header len                           */\n+    const void  *trailer;       /* trailer buffer                       */\n+    PRInt32     tlen;           /* trailer len                          */\n };\n \n-NSPR_API(PRInt32)\n-PR_SendFile(PRFileDesc* networkSocket, PRSendFileData* sendData,\n-            PRTransmitFileFlags flags, PRIntervalTime timeout);\n+\n+NSPR_API(PRInt32) PR_SendFile(\n+    PRFileDesc *networkSocket, PRSendFileData *sendData,\n+    PRTransmitFileFlags flags, PRIntervalTime timeout);\n \n /*\n *************************************************************************\n@@ -1731,12 +1683,11 @@ PR_SendFile(PRFileDesc* networkSocket, PRSendFileData* sendData,\n **    char buf[USER_DATA_SIZE + PR_ACCEPT_READ_BUF_OVERHEAD];\n **    bytesRead = PR_AcceptRead( s, fd, &a, &p, USER_DATA_SIZE, ...);\n */\n-#define PR_ACCEPT_READ_BUF_OVERHEAD (32 + (2 * sizeof(PRNetAddr)))\n+#define PR_ACCEPT_READ_BUF_OVERHEAD (32+(2*sizeof(PRNetAddr)))\n \n-NSPR_API(PRInt32)\n-PR_AcceptRead(PRFileDesc* listenSock, PRFileDesc** acceptedSock,\n-              PRNetAddr** peerAddr, void* buf, PRInt32 amount,\n-              PRIntervalTime timeout);\n+NSPR_API(PRInt32) PR_AcceptRead(\n+    PRFileDesc *listenSock, PRFileDesc **acceptedSock,\n+    PRNetAddr **peerAddr, void *buf, PRInt32 amount, PRIntervalTime timeout);\n \n /*\n *************************************************************************\n@@ -1758,8 +1709,7 @@ PR_AcceptRead(PRFileDesc* listenSock, PRFileDesc** acceptedSock,\n ** XXX can we implement this on windoze and mac?\n **************************************************************************\n **/\n-NSPR_API(PRStatus)\n-PR_NewTCPSocketPair(PRFileDesc* fds[2]);\n+NSPR_API(PRStatus) PR_NewTCPSocketPair(PRFileDesc *fds[2]);\n \n /*\n *************************************************************************\n@@ -1779,8 +1729,7 @@ PR_NewTCPSocketPair(PRFileDesc* fds[2]);\n **     be obtained by calling PR_GetError().\n **************************************************************************\n **/\n-NSPR_API(PRStatus)\n-PR_GetSockName(PRFileDesc* fd, PRNetAddr* addr);\n+NSPR_API(PRStatus)  PR_GetSockName(PRFileDesc *fd, PRNetAddr *addr);\n \n /*\n *************************************************************************\n@@ -1802,14 +1751,13 @@ PR_GetSockName(PRFileDesc* fd, PRNetAddr* addr);\n **     be obtained by calling PR_GetError().\n **************************************************************************\n **/\n-NSPR_API(PRStatus)\n-PR_GetPeerName(PRFileDesc* fd, PRNetAddr* addr);\n+NSPR_API(PRStatus)  PR_GetPeerName(PRFileDesc *fd, PRNetAddr *addr);\n \n-NSPR_API(PRStatus)\n-PR_GetSocketOption(PRFileDesc* fd, PRSocketOptionData* data);\n+NSPR_API(PRStatus)  PR_GetSocketOption(\n+    PRFileDesc *fd, PRSocketOptionData *data);\n \n-NSPR_API(PRStatus)\n-PR_SetSocketOption(PRFileDesc* fd, const PRSocketOptionData* data);\n+NSPR_API(PRStatus)  PR_SetSocketOption(\n+    PRFileDesc *fd, const PRSocketOptionData *data);\n \n /*\n  *********************************************************************\n@@ -1838,8 +1786,9 @@ PR_SetSocketOption(PRFileDesc* fd, const PRSocketOptionData* data);\n  *     be obtained by calling PR_GetError().\n  *************************************************************************\n  */\n-NSPR_API(PRStatus)\n-PR_SetFDInheritable(PRFileDesc* fd, PRBool inheritable);\n+NSPR_API(PRStatus) PR_SetFDInheritable(\n+    PRFileDesc *fd,\n+    PRBool inheritable);\n \n /*\n  ************************************************************************\n@@ -1857,8 +1806,7 @@ PR_SetFDInheritable(PRFileDesc* fd, PRBool inheritable);\n  *     by calling PR_GetError().\n  *************************************************************************\n  */\n-NSPR_API(PRFileDesc*)\n-PR_GetInheritedFD(const char* name);\n+NSPR_API(PRFileDesc *) PR_GetInheritedFD(const char *name);\n \n /*\n  *********************************************************************\n@@ -1874,31 +1822,30 @@ typedef struct PRFileMap PRFileMap;\n  * protection options for read and write accesses of a file mapping\n  */\n typedef enum PRFileMapProtect {\n-    PR_PROT_READONLY,  /* read only */\n-    PR_PROT_READWRITE, /* readable, and write is shared */\n-    PR_PROT_WRITECOPY  /* readable, and write is private (copy-on-write) */\n+    PR_PROT_READONLY,     /* read only */\n+    PR_PROT_READWRITE,    /* readable, and write is shared */\n+    PR_PROT_WRITECOPY     /* readable, and write is private (copy-on-write) */\n } PRFileMapProtect;\n \n-NSPR_API(PRFileMap*)\n-PR_CreateFileMap(PRFileDesc* fd, PRInt64 size, PRFileMapProtect prot);\n+NSPR_API(PRFileMap *) PR_CreateFileMap(\n+    PRFileDesc *fd,\n+    PRInt64 size,\n+    PRFileMapProtect prot);\n \n /*\n  * return the alignment (in bytes) of the offset argument to PR_MemMap\n  */\n-NSPR_API(PRInt32)\n-PR_GetMemMapAlignment(void);\n+NSPR_API(PRInt32) PR_GetMemMapAlignment(void);\n \n-NSPR_API(void*)\n-PR_MemMap(PRFileMap* fmap,\n-          PROffset64 offset, /* must be aligned and sized according to the\n-                              * return value of PR_GetMemMapAlignment() */\n-          PRUint32 len);\n+NSPR_API(void *) PR_MemMap(\n+    PRFileMap *fmap,\n+    PROffset64 offset,  /* must be aligned and sized according to the\n+                         * return value of PR_GetMemMapAlignment() */\n+    PRUint32 len);\n \n-NSPR_API(PRStatus)\n-PR_MemUnmap(void* addr, PRUint32 len);\n+NSPR_API(PRStatus) PR_MemUnmap(void *addr, PRUint32 len);\n \n-NSPR_API(PRStatus)\n-PR_CloseFileMap(PRFileMap* fmap);\n+NSPR_API(PRStatus) PR_CloseFileMap(PRFileMap *fmap);\n \n /*\n  * Synchronously flush the given memory-mapped address range of the given open\n@@ -1908,8 +1855,10 @@ PR_CloseFileMap(PRFileMap* fmap);\n  * On some platforms, the function will call PR_Sync(fd) internally if it is\n  * necessary for flushing modified data to disk synchronously.\n  */\n-NSPR_API(PRStatus)\n-PR_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len);\n+NSPR_API(PRStatus) PR_SyncMemMap(\n+    PRFileDesc *fd,\n+    void *addr,\n+    PRUint32 len);\n \n /*\n  ******************************************************************\n@@ -1924,8 +1873,10 @@ PR_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len);\n  * read and write ends of the pipe.\n  */\n \n-NSPR_API(PRStatus)\n-PR_CreatePipe(PRFileDesc** readPipe, PRFileDesc** writePipe);\n+NSPR_API(PRStatus) PR_CreatePipe(\n+    PRFileDesc **readPipe,\n+    PRFileDesc **writePipe\n+);\n \n /************************************************************************/\n /************** The following definitions are for poll ******************/\n@@ -1945,23 +1896,23 @@ struct PRPollDesc {\n #if defined(_PR_POLL_BACKCOMPAT)\n \n #include <poll.h>\n-#define PR_POLL_READ POLLIN\n-#define PR_POLL_WRITE POLLOUT\n-#define PR_POLL_EXCEPT POLLPRI\n-#define PR_POLL_ERR POLLERR   /* only in out_flags */\n-#define PR_POLL_NVAL POLLNVAL /* only in out_flags when fd is bad */\n-#define PR_POLL_HUP POLLHUP   /* only in out_flags */\n+#define PR_POLL_READ    POLLIN\n+#define PR_POLL_WRITE   POLLOUT\n+#define PR_POLL_EXCEPT  POLLPRI\n+#define PR_POLL_ERR     POLLERR     /* only in out_flags */\n+#define PR_POLL_NVAL    POLLNVAL    /* only in out_flags when fd is bad */\n+#define PR_POLL_HUP     POLLHUP     /* only in out_flags */\n \n-#else /* _PR_POLL_BACKCOMPAT */\n+#else  /* _PR_POLL_BACKCOMPAT */\n \n-#define PR_POLL_READ 0x1\n-#define PR_POLL_WRITE 0x2\n-#define PR_POLL_EXCEPT 0x4\n-#define PR_POLL_ERR 0x8   /* only in out_flags */\n-#define PR_POLL_NVAL 0x10 /* only in out_flags when fd is bad */\n-#define PR_POLL_HUP 0x20  /* only in out_flags */\n+#define PR_POLL_READ    0x1\n+#define PR_POLL_WRITE   0x2\n+#define PR_POLL_EXCEPT  0x4\n+#define PR_POLL_ERR     0x8         /* only in out_flags */\n+#define PR_POLL_NVAL    0x10        /* only in out_flags when fd is bad */\n+#define PR_POLL_HUP     0x20        /* only in out_flags */\n \n-#endif /* _PR_POLL_BACKCOMPAT */\n+#endif  /* _PR_POLL_BACKCOMPAT */\n \n /*\n *************************************************************************\n@@ -2003,8 +1954,8 @@ struct PRPollDesc {\n **                              calling PR_GetError().\n **************************************************************************\n */\n-NSPR_API(PRInt32)\n-PR_Poll(PRPollDesc* pds, PRIntn npds, PRIntervalTime timeout);\n+NSPR_API(PRInt32) PR_Poll(\n+    PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout);\n \n /*\n **************************************************************************\n@@ -2047,17 +1998,13 @@ PR_Poll(PRPollDesc* pds, PRIntn npds, PRIntervalTime timeout);\n **************************************************************************\n */\n \n-NSPR_API(PRFileDesc*)\n-PR_NewPollableEvent(void);\n+NSPR_API(PRFileDesc *) PR_NewPollableEvent(void);\n \n-NSPR_API(PRStatus)\n-PR_DestroyPollableEvent(PRFileDesc* event);\n+NSPR_API(PRStatus) PR_DestroyPollableEvent(PRFileDesc *event);\n \n-NSPR_API(PRStatus)\n-PR_SetPollableEvent(PRFileDesc* event);\n+NSPR_API(PRStatus) PR_SetPollableEvent(PRFileDesc *event);\n \n-NSPR_API(PRStatus)\n-PR_WaitForPollableEvent(PRFileDesc* event);\n+NSPR_API(PRStatus) PR_WaitForPollableEvent(PRFileDesc *event);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/pripcsem.h b/nspr/pr/include/pripcsem.h\nindex 6d0af4b..f5a524d 100644\n--- a/nspr/pr/include/pripcsem.h\n+++ b/nspr/pr/include/pripcsem.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -53,11 +54,11 @@ typedef struct PRSem PRSem;\n  * arguments are ignored.\n  */\n \n-#define PR_SEM_CREATE 0x1 /* create if not exist */\n-#define PR_SEM_EXCL 0x2   /* fail if already exists */\n+#define PR_SEM_CREATE 0x1  /* create if not exist */\n+#define PR_SEM_EXCL   0x2  /* fail if already exists */\n \n-NSPR_API(PRSem*)\n-PR_OpenSemaphore(const char* name, PRIntn flags, PRIntn mode, PRUintn value);\n+NSPR_API(PRSem *) PR_OpenSemaphore(\n+    const char *name, PRIntn flags, PRIntn mode, PRUintn value);\n \n /*\n  * PR_WaitSemaphore --\n@@ -69,8 +70,7 @@ PR_OpenSemaphore(const char* name, PRIntn flags, PRIntn mode, PRUintn value);\n  * The \"test and decrement\" operation is performed atomically.\n  */\n \n-NSPR_API(PRStatus)\n-PR_WaitSemaphore(PRSem* sem);\n+NSPR_API(PRStatus) PR_WaitSemaphore(PRSem *sem);\n \n /*\n  * PR_PostSemaphore --\n@@ -78,8 +78,7 @@ PR_WaitSemaphore(PRSem* sem);\n  * Increment the value of the named semaphore by 1.\n  */\n \n-NSPR_API(PRStatus)\n-PR_PostSemaphore(PRSem* sem);\n+NSPR_API(PRStatus) PR_PostSemaphore(PRSem *sem);\n \n /*\n  * PR_CloseSemaphore --\n@@ -87,8 +86,7 @@ PR_PostSemaphore(PRSem* sem);\n  * Close a named semaphore handle.\n  */\n \n-NSPR_API(PRStatus)\n-PR_CloseSemaphore(PRSem* sem);\n+NSPR_API(PRStatus) PR_CloseSemaphore(PRSem *sem);\n \n /*\n  * PR_DeleteSemaphore --\n@@ -96,8 +94,7 @@ PR_CloseSemaphore(PRSem* sem);\n  * Remove a named semaphore from the system.\n  */\n \n-NSPR_API(PRStatus)\n-PR_DeleteSemaphore(const char* name);\n+NSPR_API(PRStatus) PR_DeleteSemaphore(const char *name);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/private/.cvsignore b/nspr/pr/include/private/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/include/private/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/include/private/pprio.h b/nspr/pr/include/private/pprio.h\nindex c1f6b1e..be8252b 100644\n--- a/nspr/pr/include/private/pprio.h\n+++ b/nspr/pr/include/private/pprio.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -26,14 +27,10 @@ typedef PRInt32 PROsfd;\n #endif\n \n /* Return the method tables for files, tcp sockets and udp sockets */\n-NSPR_API(const PRIOMethods*)\n-PR_GetFileMethods(void);\n-NSPR_API(const PRIOMethods*)\n-PR_GetTCPMethods(void);\n-NSPR_API(const PRIOMethods*)\n-PR_GetUDPMethods(void);\n-NSPR_API(const PRIOMethods*)\n-PR_GetPipeMethods(void);\n+NSPR_API(const PRIOMethods*)    PR_GetFileMethods(void);\n+NSPR_API(const PRIOMethods*)    PR_GetTCPMethods(void);\n+NSPR_API(const PRIOMethods*)    PR_GetUDPMethods(void);\n+NSPR_API(const PRIOMethods*)    PR_GetPipeMethods(void);\n \n /*\n ** Convert a NSPR socket handle to a native socket handle.\n@@ -51,25 +48,19 @@ PR_GetPipeMethods(void);\n ** changes the configuration of the native handle, (e.g., changes it to\n ** blocking or closes it), NSPR will not work correctly.\n */\n-NSPR_API(PROsfd)\n-PR_FileDesc2NativeHandle(PRFileDesc*);\n-NSPR_API(void)\n-PR_ChangeFileDescNativeHandle(PRFileDesc*, PROsfd);\n-NSPR_API(PRFileDesc*)\n-PR_AllocFileDesc(PROsfd osfd, const PRIOMethods* methods);\n-NSPR_API(void)\n-PR_FreeFileDesc(PRFileDesc* fd);\n+NSPR_API(PROsfd)       PR_FileDesc2NativeHandle(PRFileDesc *);\n+NSPR_API(void)         PR_ChangeFileDescNativeHandle(PRFileDesc *, PROsfd);\n+NSPR_API(PRFileDesc*)  PR_AllocFileDesc(PROsfd osfd,\n+                                        const PRIOMethods *methods);\n+NSPR_API(void)         PR_FreeFileDesc(PRFileDesc *fd);\n /*\n ** Import an existing OS file to NSPR.\n */\n-NSPR_API(PRFileDesc*)\n-PR_ImportFile(PROsfd osfd);\n-NSPR_API(PRFileDesc*)\n-PR_ImportPipe(PROsfd osfd);\n-NSPR_API(PRFileDesc*)\n-PR_ImportTCPSocket(PROsfd osfd);\n-NSPR_API(PRFileDesc*)\n-PR_ImportUDPSocket(PROsfd osfd);\n+NSPR_API(PRFileDesc*)  PR_ImportFile(PROsfd osfd);\n+NSPR_API(PRFileDesc*)  PR_ImportPipe(PROsfd osfd);\n+NSPR_API(PRFileDesc*)  PR_ImportTCPSocket(PROsfd osfd);\n+NSPR_API(PRFileDesc*)  PR_ImportUDPSocket(PROsfd osfd);\n+\n \n /*\n  *************************************************************************\n@@ -89,8 +80,7 @@ PR_ImportUDPSocket(PROsfd osfd);\n  **************************************************************************\n  */\n \n-NSPR_API(PRFileDesc*)\n-PR_CreateSocketPollFd(PROsfd osfd);\n+NSPR_API(PRFileDesc*)   PR_CreateSocketPollFd(PROsfd osfd);\n \n /*\n  *************************************************************************\n@@ -108,8 +98,8 @@ PR_CreateSocketPollFd(PROsfd osfd);\n  **************************************************************************\n  */\n \n-NSPR_API(PRStatus)\n-PR_DestroySocketPollFd(PRFileDesc* fd);\n+NSPR_API(PRStatus) PR_DestroySocketPollFd(PRFileDesc *fd);\n+\n \n /*\n ** Macros for PR_Socket\n@@ -132,8 +122,7 @@ PR_DestroySocketPollFd(PRFileDesc* fd);\n /*\n ** Create a new Socket; this function is obsolete.\n */\n-NSPR_API(PRFileDesc*)\n-PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto);\n+NSPR_API(PRFileDesc*)   PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto);\n \n /* FUNCTION: PR_LockFile\n ** DESCRIPTION:\n@@ -142,8 +131,7 @@ PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto);\n **    PR_SUCCESS when the lock is held\n **    PR_FAILURE otherwise\n */\n-NSPR_API(PRStatus)\n-PR_LockFile(PRFileDesc* fd);\n+NSPR_API(PRStatus) PR_LockFile(PRFileDesc *fd);\n \n /* FUNCTION: PR_TLockFile\n ** DESCRIPTION:\n@@ -153,8 +141,7 @@ PR_LockFile(PRFileDesc* fd);\n **    PR_SUCCESS when the lock is held\n **    PR_FAILURE otherwise\n */\n-NSPR_API(PRStatus)\n-PR_TLockFile(PRFileDesc* fd);\n+NSPR_API(PRStatus) PR_TLockFile(PRFileDesc *fd);\n \n /* FUNCTION: PR_UnlockFile\n ** DESCRIPTION:\n@@ -164,23 +151,21 @@ PR_TLockFile(PRFileDesc* fd);\n **    PR_SUCCESS when the lock is released\n **    PR_FAILURE otherwise\n */\n-NSPR_API(PRStatus)\n-PR_UnlockFile(PRFileDesc* fd);\n+NSPR_API(PRStatus) PR_UnlockFile(PRFileDesc *fd);\n \n /*\n ** Emulate acceptread by accept and recv.\n */\n-NSPR_API(PRInt32)\n-PR_EmulateAcceptRead(PRFileDesc* sd, PRFileDesc** nd, PRNetAddr** raddr,\n-                     void* buf, PRInt32 amount, PRIntervalTime timeout);\n+NSPR_API(PRInt32) PR_EmulateAcceptRead(PRFileDesc *sd, PRFileDesc **nd,\n+                                       PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout);\n \n /*\n ** Emulate sendfile by reading from the file and writing to the socket.\n ** The file is memory-mapped if memory-mapped files are supported.\n */\n-NSPR_API(PRInt32)\n-PR_EmulateSendFile(PRFileDesc* networkSocket, PRSendFileData* sendData,\n-                   PRTransmitFileFlags flags, PRIntervalTime timeout);\n+NSPR_API(PRInt32) PR_EmulateSendFile(\n+    PRFileDesc *networkSocket, PRSendFileData *sendData,\n+    PRTransmitFileFlags flags, PRIntervalTime timeout);\n \n #ifdef WIN32\n /* FUNCTION: PR_NTFast_AcceptRead\n@@ -191,11 +176,10 @@ PR_EmulateSendFile(PRFileDesc* networkSocket, PRSendFileData* sendData,\n **    the acceptcontext.  The generic version of PR_AcceptRead always\n **    updates the accept context.  This version does not.\n **/\n-NSPR_API(PRInt32)\n-PR_NTFast_AcceptRead(PRFileDesc* sd, PRFileDesc** nd, PRNetAddr** raddr,\n-                     void* buf, PRInt32 amount, PRIntervalTime t);\n+NSPR_API(PRInt32) PR_NTFast_AcceptRead(PRFileDesc *sd, PRFileDesc **nd,\n+                                       PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime t);\n \n-typedef void (*_PR_AcceptTimeoutCallback)(void*);\n+typedef void (*_PR_AcceptTimeoutCallback)(void *);\n \n /* FUNCTION: PR_NTFast_AcceptRead_WithTimeoutCallback\n ** DESCRIPTION:\n@@ -211,12 +195,15 @@ typedef void (*_PR_AcceptTimeoutCallback)(void*);\n **    continue the accept.   If the timeout occurs on the read, it will\n **    close the connection and return error.\n */\n-NSPR_API(PRInt32)\n-PR_NTFast_AcceptRead_WithTimeoutCallback(PRFileDesc* sd, PRFileDesc** nd,\n-                                         PRNetAddr** raddr, void* buf,\n-                                         PRInt32 amount, PRIntervalTime t,\n-                                         _PR_AcceptTimeoutCallback callback,\n-                                         void* callback_arg);\n+NSPR_API(PRInt32) PR_NTFast_AcceptRead_WithTimeoutCallback(\n+    PRFileDesc *sd,\n+    PRFileDesc **nd,\n+    PRNetAddr **raddr,\n+    void *buf,\n+    PRInt32 amount,\n+    PRIntervalTime t,\n+    _PR_AcceptTimeoutCallback callback,\n+    void *callback_arg);\n \n /* FUNCTION: PR_NTFast_Accept\n ** DESCRIPTION:\n@@ -226,8 +213,8 @@ PR_NTFast_AcceptRead_WithTimeoutCallback(PRFileDesc* sd, PRFileDesc** nd,\n **    the acceptcontext.  The generic version of PR_Accept always\n **    updates the accept context.  This version does not.\n **/\n-NSPR_API(PRFileDesc*)\n-PR_NTFast_Accept(PRFileDesc* fd, PRNetAddr* addr, PRIntervalTime timeout);\n+NSPR_API(PRFileDesc*)   PR_NTFast_Accept(PRFileDesc *fd, PRNetAddr *addr,\n+        PRIntervalTime timeout);\n \n /* FUNCTION: PR_NTFast_Update\n ** DESCRIPTION:\n@@ -237,15 +224,16 @@ PR_NTFast_Accept(PRFileDesc* fd, PRNetAddr* addr, PRIntervalTime timeout);\n **    Without calling this, the only operations supported on the socket\n **    Are PR_Read, PR_Write, PR_Transmitfile, and PR_Close.\n */\n-NSPR_API(void)\n-PR_NTFast_UpdateAcceptContext(PRFileDesc* acceptSock, PRFileDesc* listenSock);\n+NSPR_API(void) PR_NTFast_UpdateAcceptContext(PRFileDesc *acceptSock,\n+        PRFileDesc *listenSock);\n+\n \n /* FUNCTION: PR_NT_CancelIo\n ** DESCRIPTION:\n **    Cancel IO operations on fd.\n */\n-NSPR_API(PRStatus)\n-PR_NT_CancelIo(PRFileDesc* fd);\n+NSPR_API(PRStatus) PR_NT_CancelIo(PRFileDesc *fd);\n+\n \n #endif /* WIN32 */\n \ndiff --git a/nspr/pr/include/private/pprmwait.h b/nspr/pr/include/private/pprmwait.h\nindex fbe63ed..3e4057c 100644\n--- a/nspr/pr/include/private/pprmwait.h\n+++ b/nspr/pr/include/private/pprmwait.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -21,44 +22,40 @@\n  * Introduction to Algorithms, p. 232, The MIT Press, 1990.\n  */\n \n-#define _MW_HASH(a, m) \\\n-    ((((PRUptrdiff)(a) >> 4) ^ ((PRUptrdiff)(a) >> 10)) % (m))\n-#define _MW_HASH2(a, m) \\\n-    (1 + ((((PRUptrdiff)(a) >> 4) ^ ((PRUptrdiff)(a) >> 10)) % (m - 2)))\n+#define _MW_HASH(a, m) ((((PRUptrdiff)(a) >> 4) ^ ((PRUptrdiff)(a) >> 10)) % (m))\n+#define _MW_HASH2(a, m) (1 + ((((PRUptrdiff)(a) >> 4) ^ ((PRUptrdiff)(a) >> 10)) % (m - 2)))\n #define _MW_ABORTED(_rv) \\\n     ((PR_FAILURE == (_rv)) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError()))\n \n-typedef enum { _prmw_success,\n-               _prmw_rehash,\n-               _prmw_error } _PR_HashStory;\n+typedef enum {_prmw_success, _prmw_rehash, _prmw_error} _PR_HashStory;\n \n-typedef struct _PRWaiterHash {\n-    PRUint16 count;        /* current number in hash table */\n-    PRUint16 length;       /* current size of the hash table */\n-    PRRecvWait* recv_wait; /* hash table of receive wait objects */\n+typedef struct _PRWaiterHash\n+{\n+    PRUint16 count;             /* current number in hash table */\n+    PRUint16 length;            /* current size of the hash table */\n+    PRRecvWait *recv_wait;      /* hash table of receive wait objects */\n } _PRWaiterHash;\n \n-typedef enum { _prmw_running,\n-               _prmw_stopping,\n-               _prmw_stopped } PRMWGroupState;\n-\n-struct PRWaitGroup {\n-    PRCList group_link;   /* all groups are linked to each other */\n-    PRCList io_ready;     /* list of I/O requests that are ready */\n-    PRMWGroupState state; /* state of this group (so we can shut down) */\n-\n-    PRLock* ml;               /* lock for synchronizing this wait group */\n-    PRCondVar* io_taken;      /* calling threads notify when they take I/O */\n-    PRCondVar* io_complete;   /* calling threads wait here for completions */\n-    PRCondVar* new_business;  /* polling thread waits here more work */\n-    PRCondVar* mw_manage;     /* used to manage group lists */\n-    PRThread* poller;         /* thread that's actually doing the poll() */\n-    PRUint16 waiting_threads; /* number of threads waiting for recv */\n-    PRUint16 polling_count;   /* number of elements in the polling list */\n-    PRUint32 p_timestamp;     /* pseudo-time group had element removed */\n-    PRPollDesc* polling_list; /* list poller builds for polling */\n-    PRIntervalTime last_poll; /* last time we polled */\n-    _PRWaiterHash* waiter;    /* pointer to hash table of wait receive objects */\n+typedef enum {_prmw_running, _prmw_stopping, _prmw_stopped} PRMWGroupState;\n+\n+struct PRWaitGroup\n+{\n+    PRCList group_link;         /* all groups are linked to each other */\n+    PRCList io_ready;           /* list of I/O requests that are ready */\n+    PRMWGroupState state;       /* state of this group (so we can shut down) */\n+\n+    PRLock *ml;                 /* lock for synchronizing this wait group */\n+    PRCondVar *io_taken;        /* calling threads notify when they take I/O */\n+    PRCondVar *io_complete;     /* calling threads wait here for completions */\n+    PRCondVar *new_business;    /* polling thread waits here more work */\n+    PRCondVar *mw_manage;       /* used to manage group lists */\n+    PRThread* poller;           /* thread that's actually doing the poll() */\n+    PRUint16 waiting_threads;   /* number of threads waiting for recv */\n+    PRUint16 polling_count;     /* number of elements in the polling list */\n+    PRUint32 p_timestamp;       /* pseudo-time group had element removed */\n+    PRPollDesc *polling_list;   /* list poller builds for polling */\n+    PRIntervalTime last_poll;   /* last time we polled */\n+    _PRWaiterHash *waiter;      /* pointer to hash table of wait receive objects */\n \n #ifdef WINNT\n     /*\n@@ -67,9 +64,9 @@ struct PRWaitGroup {\n      * idle threads cannot use nspr locks, we have to use an md lock\n      * to protect the io_ready list.\n      */\n-    _MDLock mdlock;    /* protect io_ready, waiter, and wait_list */\n-    PRCList wait_list; /* used in place of io_complete.  reuse\n-                        * waitQLinks in the PRThread structure. */\n+    _MDLock mdlock;             /* protect io_ready, waiter, and wait_list */\n+    PRCList wait_list;          /* used in place of io_complete.  reuse\n+                                 * waitQLinks in the PRThread structure. */\n #endif /* WINNT */\n };\n \n@@ -78,28 +75,27 @@ struct PRWaitGroup {\n ******************** Wait group enumerations **************************\n ***********************************************************************\n **********************************************************************/\n-typedef struct _PRGlobalState {\n-    PRCList group_list; /* master of the group list */\n-    PRWaitGroup* group; /* the default (NULL) group */\n+typedef struct _PRGlobalState\n+{\n+    PRCList group_list;         /* master of the group list */\n+    PRWaitGroup *group;         /* the default (NULL) group */\n } _PRGlobalState;\n \n #ifdef WINNT\n-extern PRStatus NT_HashRemoveInternal(PRWaitGroup* group, PRFileDesc* fd);\n+extern PRStatus NT_HashRemoveInternal(PRWaitGroup *group, PRFileDesc *fd);\n #endif\n \n-typedef enum {\n-    _PR_ENUM_UNSEALED = 0,\n-    _PR_ENUM_SEALED = 0x0eadface\n-} _PREnumSeal;\n-\n-struct PRMWaitEnumerator {\n-    PRWaitGroup* group;   /* group this enumerator is bound to */\n-    PRThread* thread;     /* thread in midst of an enumeration */\n-    _PREnumSeal seal;     /* trying to detect deleted objects */\n-    PRUint32 p_timestamp; /* when enumeration was (re)started */\n-    PRRecvWait** waiter;  /* pointer into hash table */\n-    PRUintn index;        /* position in hash table */\n-    void* pad[4];         /* some room to grow */\n+typedef enum {_PR_ENUM_UNSEALED=0, _PR_ENUM_SEALED=0x0eadface} _PREnumSeal;\n+\n+struct PRMWaitEnumerator\n+{\n+    PRWaitGroup *group;       /* group this enumerator is bound to */\n+    PRThread *thread;               /* thread in midst of an enumeration */\n+    _PREnumSeal seal;               /* trying to detect deleted objects */\n+    PRUint32 p_timestamp;           /* when enumeration was (re)started */\n+    PRRecvWait **waiter;            /* pointer into hash table */\n+    PRUintn index;                  /* position in hash table */\n+    void *pad[4];                   /* some room to grow */\n };\n \n #endif /* defined(_PPRMWAIT_H) */\ndiff --git a/nspr/pr/include/private/pprthred.h b/nspr/pr/include/private/pprthred.h\nindex 7be3f25..e0cc751 100644\n--- a/nspr/pr/include/private/pprthred.h\n+++ b/nspr/pr/include/private/pprthred.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -30,9 +31,9 @@ PR_BEGIN_EXTERN_C\n ** This call is not normally needed unless you create your own native\n ** thread. PR_Init does this automatically for the primordial thread.\n */\n-NSPR_API(PRThread*)\n-PR_AttachThread(PRThreadType type, PRThreadPriority priority,\n-                PRThreadStack* stack);\n+NSPR_API(PRThread*) PR_AttachThread(PRThreadType type,\n+                                    PRThreadPriority priority,\n+                                    PRThreadStack *stack);\n \n /*\n ** Detach the nspr thread from the currently executing native thread.\n@@ -45,24 +46,22 @@ PR_AttachThread(PRThreadType type, PRThreadPriority priority,\n **\n ** This call returns after the nspr thread object is destroyed.\n */\n-NSPR_API(void)\n-PR_DetachThread(void);\n+NSPR_API(void) PR_DetachThread(void);\n \n /*\n ** Get the id of the named thread. Each thread is assigned a unique id\n ** when it is created or attached.\n */\n-NSPR_API(PRUint32)\n-PR_GetThreadID(PRThread* thread);\n+NSPR_API(PRUint32) PR_GetThreadID(PRThread *thread);\n \n /*\n ** Set the procedure that is called when a thread is dumped. The procedure\n ** will be applied to the argument, arg, when called. Setting the procedure\n ** to NULL effectively removes it.\n */\n-typedef void (*PRThreadDumpProc)(PRFileDesc* fd, PRThread* t, void* arg);\n-NSPR_API(void)\n-PR_SetThreadDumpProc(PRThread* thread, PRThreadDumpProc dump, void* arg);\n+typedef void (*PRThreadDumpProc)(PRFileDesc *fd, PRThread *t, void *arg);\n+NSPR_API(void) PR_SetThreadDumpProc(\n+    PRThread* thread, PRThreadDumpProc dump, void *arg);\n \n /*\n ** Get this thread's affinity mask.  The affinity mask is a 32 bit quantity\n@@ -72,35 +71,31 @@ PR_SetThreadDumpProc(PRThread* thread, PRThreadDumpProc dump, void* arg);\n **\n ** Returns 0 on success, -1 on failure.\n */\n-NSPR_API(PRInt32)\n-PR_GetThreadAffinityMask(PRThread* thread, PRUint32* mask);\n+NSPR_API(PRInt32) PR_GetThreadAffinityMask(PRThread *thread, PRUint32 *mask);\n \n /*\n ** Set this thread's affinity mask.\n **\n ** Returns 0 on success, -1 on failure.\n */\n-NSPR_API(PRInt32)\n-PR_SetThreadAffinityMask(PRThread* thread, PRUint32 mask);\n+NSPR_API(PRInt32) PR_SetThreadAffinityMask(PRThread *thread, PRUint32 mask );\n \n /*\n ** Set the default CPU Affinity mask.\n **\n */\n-NSPR_API(PRInt32)\n-PR_SetCPUAffinityMask(PRUint32 mask);\n+NSPR_API(PRInt32) PR_SetCPUAffinityMask(PRUint32 mask);\n \n /*\n ** Show status of all threads to standard error output.\n */\n-NSPR_API(void)\n-PR_ShowStatus(void);\n+NSPR_API(void) PR_ShowStatus(void);\n \n /*\n ** Set thread recycle mode to on (1) or off (0)\n */\n-NSPR_API(void)\n-PR_SetThreadRecycleMode(PRUint32 flag);\n+NSPR_API(void) PR_SetThreadRecycleMode(PRUint32 flag);\n+\n \n /*---------------------------------------------------------------------------\n ** THREAD PRIVATE FUNCTIONS FOR GARBAGE COLLECTIBLE THREADS\n@@ -117,53 +112,49 @@ PR_SetThreadRecycleMode(PRUint32 flag);\n ** Same as PR_CreateThread except that the thread is marked as garbage\n ** collectible.\n */\n-NSPR_API(PRThread*)\n-PR_CreateThreadGCAble(PRThreadType type, void (*start)(void* arg), void* arg,\n-                      PRThreadPriority priority, PRThreadScope scope,\n-                      PRThreadState state, PRUint32 stackSize);\n+NSPR_API(PRThread*) PR_CreateThreadGCAble(PRThreadType type,\n+        void (*start)(void *arg),\n+        void *arg,\n+        PRThreadPriority priority,\n+        PRThreadScope scope,\n+        PRThreadState state,\n+        PRUint32 stackSize);\n \n /*\n ** Same as PR_AttachThread except that the thread being attached is marked as\n ** garbage collectible.\n */\n-NSPR_API(PRThread*)\n-PR_AttachThreadGCAble(PRThreadType type, PRThreadPriority priority,\n-                      PRThreadStack* stack);\n+NSPR_API(PRThread*) PR_AttachThreadGCAble(PRThreadType type,\n+        PRThreadPriority priority,\n+        PRThreadStack *stack);\n \n /*\n ** Mark the thread as garbage collectible.\n */\n-NSPR_API(void)\n-PR_SetThreadGCAble(void);\n+NSPR_API(void) PR_SetThreadGCAble(void);\n \n /*\n ** Unmark the thread as garbage collectible.\n */\n-NSPR_API(void)\n-PR_ClearThreadGCAble(void);\n+NSPR_API(void) PR_ClearThreadGCAble(void);\n \n /*\n-** This routine prevents all other GC able threads from running. This call is\n-* needed by\n+** This routine prevents all other GC able threads from running. This call is needed by\n ** the garbage collector.\n */\n-NSPR_API(void)\n-PR_SuspendAll(void);\n+NSPR_API(void) PR_SuspendAll(void);\n \n /*\n-** This routine unblocks all other GC able threads that were suspended from\n-* running by\n+** This routine unblocks all other GC able threads that were suspended from running by\n ** PR_SuspendAll(). This call is needed by the garbage collector.\n */\n-NSPR_API(void)\n-PR_ResumeAll(void);\n+NSPR_API(void) PR_ResumeAll(void);\n \n /*\n ** Return the thread stack pointer of the given thread.\n ** Needed by the garbage collector.\n */\n-NSPR_API(void*)\n-PR_GetSP(PRThread* thread);\n+NSPR_API(void *) PR_GetSP(PRThread *thread);\n \n /*\n ** Save the registers that the GC would find interesting into the thread\n@@ -178,8 +169,7 @@ PR_GetSP(PRThread* thread);\n **\n ** This function simply calls the internal function _MD_HomeGCRegisters().\n */\n-NSPR_API(PRWord*)\n-PR_GetGCRegisters(PRThread* t, int isCurrent, int* np);\n+NSPR_API(PRWord *) PR_GetGCRegisters(PRThread *t, int isCurrent, int *np);\n \n /*\n ** (Get|Set)ExecutionEnvironent\n@@ -189,10 +179,8 @@ PR_GetGCRegisters(PRThread* t, int isCurrent, int* np);\n **\n ** There's no locking required around these calls.\n */\n-NSPR_API(void*)\n-GetExecutionEnvironment(PRThread* thread);\n-NSPR_API(void)\n-SetExecutionEnvironment(PRThread* thread, void* environment);\n+NSPR_API(void*) GetExecutionEnvironment(PRThread *thread);\n+NSPR_API(void) SetExecutionEnvironment(PRThread* thread, void *environment);\n \n /*\n ** Enumeration function that applies \"func(thread,i,arg)\" to each active\n@@ -201,17 +189,17 @@ SetExecutionEnvironment(PRThread* thread, void* environment);\n ** stops, returning the failure value from PR_EnumerateThreads.\n ** Needed by the garbage collector.\n */\n-typedef PRStatus(PR_CALLBACK* PREnumerator)(PRThread* t, int i, void* arg);\n-NSPR_API(PRStatus)\n-PR_EnumerateThreads(PREnumerator func, void* arg);\n+typedef PRStatus (PR_CALLBACK *PREnumerator)(PRThread *t, int i, void *arg);\n+NSPR_API(PRStatus) PR_EnumerateThreads(PREnumerator func, void *arg);\n \n /*\n ** Signature of a thread stack scanning function. It is applied to every\n ** contiguous group of potential pointers within a thread. Count denotes the\n ** number of pointers.\n */\n-typedef PRStatus(PR_CALLBACK* PRScanStackFun)(PRThread* t, void** baseAddr,\n-                                              PRUword count, void* closure);\n+typedef PRStatus\n+(PR_CALLBACK *PRScanStackFun)(PRThread* t,\n+                              void** baseAddr, PRUword count, void* closure);\n \n /*\n ** Applies scanFun to all contiguous groups of potential pointers\n@@ -220,8 +208,8 @@ typedef PRStatus(PR_CALLBACK* PRScanStackFun)(PRThread* t, void** baseAddr,\n ** is aborted, and the status value is returned.\n */\n NSPR_API(PRStatus)\n-PR_ThreadScanStackPointers(PRThread* t, PRScanStackFun scanFun,\n-                           void* scanClosure);\n+PR_ThreadScanStackPointers(PRThread* t,\n+                           PRScanStackFun scanFun, void* scanClosure);\n \n /*\n ** Calls PR_ThreadScanStackPointers for every thread.\n@@ -244,8 +232,7 @@ PR_GetStackSpaceLeft(PRThread* t);\n /*\n ** Get a pointer to the primordial CPU.\n */\n-NSPR_API(struct _PRCPU*)\n-_PR_GetPrimordialCPU(void);\n+NSPR_API(struct _PRCPU *) _PR_GetPrimordialCPU(void);\n \n /*---------------------------------------------------------------------------\n ** THREAD SYNCHRONIZATION PRIVATE FUNCTIONS\n@@ -258,45 +245,40 @@ _PR_GetPrimordialCPU(void);\n ** This may fail if memory is tight or if some operating system resource\n ** is low.\n */\n-NSPR_API(PRMonitor*)\n-PR_NewNamedMonitor(const char* name);\n+NSPR_API(PRMonitor*) PR_NewNamedMonitor(const char* name);\n \n /*\n ** Test and then lock the lock if it's not already locked by some other\n ** thread. Return PR_FALSE if some other thread owned the lock at the\n ** time of the call.\n */\n-NSPR_API(PRBool)\n-PR_TestAndLock(PRLock* lock);\n+NSPR_API(PRBool) PR_TestAndLock(PRLock *lock);\n \n /*\n ** Test and then enter the mutex associated with the monitor if it's not\n ** already entered by some other thread. Return PR_FALSE if some other\n ** thread owned the mutex at the time of the call.\n */\n-NSPR_API(PRBool)\n-PR_TestAndEnterMonitor(PRMonitor* mon);\n+NSPR_API(PRBool) PR_TestAndEnterMonitor(PRMonitor *mon);\n \n /*\n ** Return the number of times that the current thread has entered the\n ** mutex. Returns zero if the current thread has not entered the mutex.\n */\n-NSPR_API(PRIntn)\n-PR_GetMonitorEntryCount(PRMonitor* mon);\n+NSPR_API(PRIntn) PR_GetMonitorEntryCount(PRMonitor *mon);\n \n /*\n ** Just like PR_CEnterMonitor except that if the monitor is owned by\n ** another thread NULL is returned.\n */\n-NSPR_API(PRMonitor*)\n-PR_CTestAndEnterMonitor(void* address);\n+NSPR_API(PRMonitor*) PR_CTestAndEnterMonitor(void *address);\n \n /*---------------------------------------------------------------------------\n ** PLATFORM-SPECIFIC INITIALIZATION FUNCTIONS\n ---------------------------------------------------------------------------*/\n \n /* I think PR_GetMonitorEntryCount is useless. All you really want is this... */\n-#define PR_InMonitor(m) (PR_GetMonitorEntryCount(m) > 0)\n+#define PR_InMonitor(m)     (PR_GetMonitorEntryCount(m) > 0)\n \n /*---------------------------------------------------------------------------\n ** Special X-Lock hack for client\ndiff --git a/nspr/pr/include/private/primpl.h b/nspr/pr/include/private/primpl.h\nindex 1f0d07d..4a1d1fd 100644\n--- a/nspr/pr/include/private/primpl.h\n+++ b/nspr/pr/include/private/primpl.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -120,48 +121,52 @@ typedef struct _MDFileMap _MDFileMap;\n \n #define PT_CV_NOTIFIED_LENGTH 6\n typedef struct _PT_Notified _PT_Notified;\n-struct _PT_Notified {\n-    PRIntn length; /* # of used entries in this structure */\n-    struct {\n-        PRCondVar* cv; /* the condition variable notified */\n-        PRIntn times;  /* and the number of times notified */\n+struct _PT_Notified\n+{\n+    PRIntn length;              /* # of used entries in this structure */\n+    struct\n+    {\n+        PRCondVar *cv;          /* the condition variable notified */\n+        PRIntn times;           /* and the number of times notified */\n     } cv[PT_CV_NOTIFIED_LENGTH];\n-    _PT_Notified* link; /* link to another of these | NULL */\n+    _PT_Notified *link;         /* link to another of these | NULL */\n };\n \n /*\n  * bits defined for pthreads 'state' field\n  */\n-#define PT_THREAD_DETACHED 0x01  /* thread can't be joined */\n-#define PT_THREAD_GLOBAL 0x02    /* a global thread (unlikely) */\n-#define PT_THREAD_SYSTEM 0x04    /* system (not user) thread */\n-#define PT_THREAD_PRIMORD 0x08   /* this is the primordial thread */\n-#define PT_THREAD_ABORTED 0x10   /* thread has been interrupted */\n-#define PT_THREAD_GCABLE 0x20    /* thread is garbage collectible */\n-#define PT_THREAD_SUSPENDED 0x40 /* thread has been suspended */\n-#define PT_THREAD_FOREIGN 0x80   /* thread is not one of ours */\n-#define PT_THREAD_BOUND 0x100    /* a bound-global thread */\n-\n-#define _PT_THREAD_INTERRUPTED(thr) \\\n-    (!(thr->interrupt_blocked) && (thr->state & PT_THREAD_ABORTED))\n-#define _PT_THREAD_BLOCK_INTERRUPT(thr) (thr->interrupt_blocked = 1)\n-#define _PT_THREAD_UNBLOCK_INTERRUPT(thr) (thr->interrupt_blocked = 0)\n+#define PT_THREAD_DETACHED  0x01    /* thread can't be joined */\n+#define PT_THREAD_GLOBAL    0x02    /* a global thread (unlikely) */\n+#define PT_THREAD_SYSTEM    0x04    /* system (not user) thread */\n+#define PT_THREAD_PRIMORD   0x08    /* this is the primordial thread */\n+#define PT_THREAD_ABORTED   0x10    /* thread has been interrupted */\n+#define PT_THREAD_GCABLE    0x20    /* thread is garbage collectible */\n+#define PT_THREAD_SUSPENDED 0x40    /* thread has been suspended */\n+#define PT_THREAD_FOREIGN   0x80    /* thread is not one of ours */\n+#define PT_THREAD_BOUND     0x100    /* a bound-global thread */\n+\n+#define _PT_THREAD_INTERRUPTED(thr)                 \\\n+        (!(thr->interrupt_blocked) && (thr->state & PT_THREAD_ABORTED))\n+#define _PT_THREAD_BLOCK_INTERRUPT(thr)             \\\n+        (thr->interrupt_blocked = 1)\n+#define _PT_THREAD_UNBLOCK_INTERRUPT(thr)           \\\n+        (thr->interrupt_blocked = 0)\n \n #define _PT_IS_GCABLE_THREAD(thr) ((thr)->state & PT_THREAD_GCABLE)\n \n /*\n ** Possible values for thread's suspend field\n-** Note that the first two can be the same as they are really mutually\n-* exclusive,\n+** Note that the first two can be the same as they are really mutually exclusive,\n ** i.e. both cannot be happening at the same time. We have two symbolic names\n ** just as a mnemonic.\n **/\n-#define PT_THREAD_RESUMED 0x80    /* thread has been resumed */\n-#define PT_THREAD_SETGCABLE 0x100 /* set the GCAble flag */\n+#define PT_THREAD_RESUMED   0x80    /* thread has been resumed */\n+#define PT_THREAD_SETGCABLE 0x100   /* set the GCAble flag */\n \n #if defined(DEBUG)\n \n-typedef struct PTDebug {\n+typedef struct PTDebug\n+{\n     PRTime timeStarted;\n     PRUintn locks_created, locks_destroyed;\n     PRUintn locks_acquired, locks_released;\n@@ -171,8 +176,7 @@ typedef struct PTDebug {\n \n #endif /* defined(DEBUG) */\n \n-NSPR_API(void)\n-PT_FPrintStats(PRFileDesc* fd, const char* msg);\n+NSPR_API(void) PT_FPrintStats(PRFileDesc *fd, const char *msg);\n \n /*\n  * On Linux and its derivatives POSIX priority scheduling works only for\n@@ -187,8 +191,7 @@ PT_FPrintStats(PRFileDesc* fd, const char* msg);\n \n #else /* defined(_PR_PTHREADS) */\n \n-NSPR_API(void)\n-PT_FPrintStats(PRFileDesc* fd, const char* msg);\n+NSPR_API(void) PT_FPrintStats(PRFileDesc *fd, const char *msg);\n \n /*\n ** This section is contains those parts needed to implement NSPR on\n@@ -202,14 +205,14 @@ PT_FPrintStats(PRFileDesc* fd, const char* msg);\n  */\n #ifdef _PR_LOCAL_THREADS_ONLY\n \n-#define _PR_MD_SUSPEND_THREAD(thread)\n-#define _PR_MD_RESUME_THREAD(thread)\n-#define _PR_MD_SUSPEND_CPU(cpu)\n-#define _PR_MD_RESUME_CPU(cpu)\n-#define _PR_MD_BEGIN_SUSPEND_ALL()\n-#define _PR_MD_END_SUSPEND_ALL()\n-#define _PR_MD_BEGIN_RESUME_ALL()\n-#define _PR_MD_END_RESUME_ALL()\n+#define        _PR_MD_SUSPEND_THREAD(thread)\n+#define        _PR_MD_RESUME_THREAD(thread)\n+#define        _PR_MD_SUSPEND_CPU(cpu)\n+#define        _PR_MD_RESUME_CPU(cpu)\n+#define        _PR_MD_BEGIN_SUSPEND_ALL()\n+#define        _PR_MD_END_SUSPEND_ALL()\n+#define        _PR_MD_BEGIN_RESUME_ALL()\n+#define        _PR_MD_END_RESUME_ALL()\n #define _PR_MD_INIT_ATTACHED_THREAD(thread) PR_FAILURE\n \n #endif\n@@ -219,92 +222,84 @@ typedef struct _PRCPU _PRCPU;\n typedef struct _MDCPU _MDCPU;\n \n struct _PRCPUQueue {\n-    _MDLock runQLock;   /* lock for the run + wait queues */\n-    _MDLock sleepQLock; /* lock for the run + wait queues */\n-    _MDLock miscQLock;  /* lock for the run + wait queues */\n+    _MDLock  runQLock;          /* lock for the run + wait queues */\n+    _MDLock  sleepQLock;        /* lock for the run + wait queues */\n+    _MDLock  miscQLock;         /* lock for the run + wait queues */\n \n     PRCList runQ[PR_PRIORITY_LAST + 1]; /* run queue for this CPU */\n-    PRUint32 runQReadyMask;\n+    PRUint32  runQReadyMask;\n     PRCList sleepQ;\n     PRIntervalTime sleepQmax;\n     PRCList pauseQ;\n     PRCList suspendQ;\n     PRCList waitingToJoinQ;\n \n-    PRUintn numCPUs; /* number of CPUs using this Q */\n+    PRUintn   numCPUs;          /* number of CPUs using this Q */\n };\n \n struct _PRCPU {\n-    PRCList links; /* link list of CPUs */\n-    PRUint32 id;   /* id for this CPU */\n+    PRCList links;              /* link list of CPUs */\n+    PRUint32 id;                /* id for this CPU */\n \n     union {\n         PRInt32 bits;\n         PRUint8 missed[4];\n     } u;\n-    PRIntn where;        /* index into u.missed */\n-    PRPackedBool paused; /* cpu is paused */\n-    PRPackedBool exit;   /* cpu should exit */\n+    PRIntn where;               /* index into u.missed */\n+    PRPackedBool paused;        /* cpu is paused */\n+    PRPackedBool exit;          /* cpu should exit */\n \n-    PRThread* thread;      /* native thread for this CPUThread */\n-    PRThread* idle_thread; /* user-level idle thread for this CPUThread */\n+    PRThread *thread;           /* native thread for this CPUThread */\n+    PRThread *idle_thread;      /* user-level idle thread for this CPUThread */\n \n-    PRIntervalTime last_clock; /* the last time we went into\n-                                * _PR_ClockInterrupt() on this CPU\n-                                */\n+    PRIntervalTime last_clock;  /* the last time we went into\n+                                 * _PR_ClockInterrupt() on this CPU\n+                                 */\n \n-    _PRCPUQueue* queue;\n+    _PRCPUQueue *queue;\n \n     _MDCPU md;\n };\n \n typedef struct _PRInterruptTable {\n-    const char* name;\n+    const char *name;\n     PRUintn missed_bit;\n     void (*handler)(void);\n } _PRInterruptTable;\n \n-#define _PR_CPU_PTR(_qp) ((_PRCPU*)((char*)(_qp) - offsetof(_PRCPU, links)))\n+#define _PR_CPU_PTR(_qp) \\\n+    ((_PRCPU*) ((char*) (_qp) - offsetof(_PRCPU,links)))\n \n-#if !defined(WIN32) && !(defined(SOLARIS) && defined(_PR_GLOBAL_THREADS_ONLY))\n-#define _MD_GET_ATTACHED_THREAD() (_PR_MD_CURRENT_THREAD())\n+#if !defined(WIN32) \\\n+        && !(defined(SOLARIS) && defined(_PR_GLOBAL_THREADS_ONLY))\n+#define _MD_GET_ATTACHED_THREAD()        (_PR_MD_CURRENT_THREAD())\n #endif\n \n #ifdef _PR_LOCAL_THREADS_ONLY\n \n-NSPR_API(struct _PRCPU*)\n-_pr_currentCPU;\n-NSPR_API(PRThread*)\n-_pr_currentThread;\n-NSPR_API(PRThread*)\n-_pr_lastThread;\n-NSPR_API(PRInt32)\n-_pr_intsOff;\n-\n-#define _MD_CURRENT_CPU() (_pr_currentCPU)\n-#define _MD_SET_CURRENT_CPU(_cpu) (_pr_currentCPU = (_cpu))\n-#define _MD_CURRENT_THREAD() (_pr_currentThread)\n+NSPR_API(struct _PRCPU *)              _pr_currentCPU;\n+NSPR_API(PRThread *)                   _pr_currentThread;\n+NSPR_API(PRThread *)                   _pr_lastThread;\n+NSPR_API(PRInt32)                      _pr_intsOff;\n+\n+#define _MD_CURRENT_CPU()               (_pr_currentCPU)\n+#define _MD_SET_CURRENT_CPU(_cpu)       (_pr_currentCPU = (_cpu))\n+#define _MD_CURRENT_THREAD()            (_pr_currentThread)\n #define _MD_SET_CURRENT_THREAD(_thread) (_pr_currentThread = (_thread))\n-#define _MD_LAST_THREAD() (_pr_lastThread)\n-#define _MD_SET_LAST_THREAD(t) (_pr_lastThread = t)\n+#define _MD_LAST_THREAD()               (_pr_lastThread)\n+#define _MD_SET_LAST_THREAD(t)          (_pr_lastThread = t)\n+\n+#define _MD_GET_INTSOFF()               (_pr_intsOff)\n+#define _MD_SET_INTSOFF(_val)           (_pr_intsOff = _val)\n \n-#define _MD_GET_INTSOFF() (_pr_intsOff)\n-#define _MD_SET_INTSOFF(_val) (_pr_intsOff = _val)\n \n /* The unbalanced curly braces in these two macros are intentional */\n-#define _PR_LOCK_HEAP()     \\\n-    {                       \\\n-        PRIntn _is;         \\\n-        if (_pr_currentCPU) \\\n-            _PR_INTSOFF(_is);\n-#define _PR_UNLOCK_HEAP() \\\n-    if (_pr_currentCPU)   \\\n-        _PR_INTSON(_is);  \\\n-    }\n+#define _PR_LOCK_HEAP() { PRIntn _is; if (_pr_currentCPU) _PR_INTSOFF(_is);\n+#define _PR_UNLOCK_HEAP() if (_pr_currentCPU) _PR_INTSON(_is); }\n \n #endif /* _PR_LOCAL_THREADS_ONLY */\n \n-extern PRInt32 _native_threads_only;\n+extern PRInt32                  _native_threads_only;\n \n #if defined(_PR_GLOBAL_THREADS_ONLY)\n \n@@ -340,21 +335,22 @@ extern PRInt32 _native_threads_only;\n \n #else\n \n-#define _PR_INTSOFF(_is)                        \\\n-    PR_BEGIN_MACRO(_is) = _PR_MD_GET_INTSOFF(); \\\n-    _PR_MD_SET_INTSOFF(1);                      \\\n+#define _PR_INTSOFF(_is) \\\n+    PR_BEGIN_MACRO \\\n+        (_is) = _PR_MD_GET_INTSOFF(); \\\n+        _PR_MD_SET_INTSOFF(1); \\\n     PR_END_MACRO\n \n #define _PR_FAST_INTSON(_is) \\\n-    PR_BEGIN_MACRO           \\\n-    _PR_MD_SET_INTSOFF(_is); \\\n+    PR_BEGIN_MACRO \\\n+        _PR_MD_SET_INTSOFF(_is); \\\n     PR_END_MACRO\n \n-#define _PR_INTSON(_is)                               \\\n-    PR_BEGIN_MACRO                                    \\\n-    if ((_is == 0) && (_PR_MD_CURRENT_CPU())->u.bits) \\\n-        _PR_IntsOn((_PR_MD_CURRENT_CPU()));           \\\n-    _PR_MD_SET_INTSOFF(_is);                          \\\n+#define _PR_INTSON(_is) \\\n+    PR_BEGIN_MACRO \\\n+        if ((_is == 0) && (_PR_MD_CURRENT_CPU())->u.bits) \\\n+                _PR_IntsOn((_PR_MD_CURRENT_CPU())); \\\n+        _PR_MD_SET_INTSOFF(_is); \\\n     PR_END_MACRO\n \n #ifdef _PR_LOCAL_THREADS_ONLY\n@@ -371,17 +367,17 @@ extern PRInt32 _native_threads_only;\n #define _PR_CPU_LIST_LOCK()\n #define _PR_CPU_LIST_UNLOCK()\n \n-#define _PR_ADD_RUNQ(_thread, _cpu, _pri)                     \\\n-    PR_BEGIN_MACRO                                            \\\n+#define _PR_ADD_RUNQ(_thread, _cpu, _pri) \\\n+    PR_BEGIN_MACRO \\\n     PR_APPEND_LINK(&(_thread)->links, &_PR_RUNQ(_cpu)[_pri]); \\\n-    _PR_RUNQREADYMASK(_cpu) |= (1L << _pri);                  \\\n+    _PR_RUNQREADYMASK(_cpu) |= (1L << _pri); \\\n     PR_END_MACRO\n \n-#define _PR_DEL_RUNQ(_thread)                     \\\n-    PR_BEGIN_MACRO                                \\\n-    _PRCPU* _cpu = _thread->cpu;                  \\\n-    PRInt32 _pri = _thread->priority;             \\\n-    PR_REMOVE_LINK(&(_thread)->links);            \\\n+#define _PR_DEL_RUNQ(_thread) \\\n+    PR_BEGIN_MACRO \\\n+    _PRCPU *_cpu = _thread->cpu; \\\n+    PRInt32 _pri = _thread->priority; \\\n+    PR_REMOVE_LINK(&(_thread)->links); \\\n     if (PR_CLIST_IS_EMPTY(&_PR_RUNQ(_cpu)[_pri])) \\\n         _PR_RUNQREADYMASK(_cpu) &= ~(1L << _pri); \\\n     PR_END_MACRO\n@@ -395,99 +391,107 @@ extern PRInt32 _native_threads_only;\n #define _PR_ADD_JOINQ(_thread, _cpu) \\\n     PR_APPEND_LINK(&(_thread)->links, &_PR_WAITINGTOJOINQ(_cpu));\n \n-#define _PR_DEL_JOINQ(_thread) PR_REMOVE_LINK(&(_thread)->links);\n+#define _PR_DEL_JOINQ(_thread) \\\n+    PR_REMOVE_LINK(&(_thread)->links);\n \n #define _PR_ADD_SUSPENDQ(_thread, _cpu) \\\n     PR_APPEND_LINK(&(_thread)->links, &_PR_SUSPENDQ(_cpu));\n \n-#define _PR_DEL_SUSPENDQ(_thread) PR_REMOVE_LINK(&(_thread)->links);\n+#define _PR_DEL_SUSPENDQ(_thread) \\\n+    PR_REMOVE_LINK(&(_thread)->links);\n \n #define _PR_THREAD_SWITCH_CPU(_thread, _newCPU)\n \n #define _PR_IS_NATIVE_THREAD_SUPPORTED() 0\n \n-#else /* _PR_LOCAL_THREADS_ONLY */\n+#else        /* _PR_LOCAL_THREADS_ONLY */\n \n /* These are for the \"combined\" thread model */\n \n-#define _PR_THREAD_LOCK(_thread) _PR_MD_LOCK(&(_thread)->threadLock);\n+#define _PR_THREAD_LOCK(_thread) \\\n+    _PR_MD_LOCK(&(_thread)->threadLock);\n \n-#define _PR_THREAD_UNLOCK(_thread) _PR_MD_UNLOCK(&(_thread)->threadLock);\n+#define _PR_THREAD_UNLOCK(_thread) \\\n+    _PR_MD_UNLOCK(&(_thread)->threadLock);\n \n-#define _PR_RUNQ_LOCK(_cpu)                \\\n-    PR_BEGIN_MACRO                         \\\n-    _PR_MD_LOCK(&(_cpu)->queue->runQLock); \\\n+#define _PR_RUNQ_LOCK(_cpu) \\\n+    PR_BEGIN_MACRO \\\n+    _PR_MD_LOCK(&(_cpu)->queue->runQLock );\\\n     PR_END_MACRO\n \n-#define _PR_RUNQ_UNLOCK(_cpu)                \\\n-    PR_BEGIN_MACRO                           \\\n-    _PR_MD_UNLOCK(&(_cpu)->queue->runQLock); \\\n+#define _PR_RUNQ_UNLOCK(_cpu) \\\n+    PR_BEGIN_MACRO \\\n+    _PR_MD_UNLOCK(&(_cpu)->queue->runQLock );\\\n     PR_END_MACRO\n \n-#define _PR_SLEEPQ_LOCK(_cpu) _PR_MD_LOCK(&(_cpu)->queue->sleepQLock);\n+#define _PR_SLEEPQ_LOCK(_cpu) \\\n+    _PR_MD_LOCK(&(_cpu)->queue->sleepQLock );\n \n-#define _PR_SLEEPQ_UNLOCK(_cpu) _PR_MD_UNLOCK(&(_cpu)->queue->sleepQLock);\n+#define _PR_SLEEPQ_UNLOCK(_cpu) \\\n+    _PR_MD_UNLOCK(&(_cpu)->queue->sleepQLock );\n \n-#define _PR_MISCQ_LOCK(_cpu) _PR_MD_LOCK(&(_cpu)->queue->miscQLock);\n+#define _PR_MISCQ_LOCK(_cpu) \\\n+    _PR_MD_LOCK(&(_cpu)->queue->miscQLock );\n \n-#define _PR_MISCQ_UNLOCK(_cpu) _PR_MD_UNLOCK(&(_cpu)->queue->miscQLock);\n+#define _PR_MISCQ_UNLOCK(_cpu) \\\n+    _PR_MD_UNLOCK(&(_cpu)->queue->miscQLock );\n \n-#define _PR_CPU_LIST_LOCK() _PR_MD_LOCK(&_pr_cpuLock)\n-#define _PR_CPU_LIST_UNLOCK() _PR_MD_UNLOCK(&_pr_cpuLock)\n+#define _PR_CPU_LIST_LOCK()                 _PR_MD_LOCK(&_pr_cpuLock)\n+#define _PR_CPU_LIST_UNLOCK()               _PR_MD_UNLOCK(&_pr_cpuLock)\n \n-#define QUEUE_RUN 0x1\n-#define QUEUE_SLEEP 0x2\n-#define QUEUE_JOIN 0x4\n-#define QUEUE_SUSPEND 0x8\n-#define QUEUE_LOCK 0x10\n+#define QUEUE_RUN           0x1\n+#define QUEUE_SLEEP         0x2\n+#define QUEUE_JOIN          0x4\n+#define QUEUE_SUSPEND       0x8\n+#define QUEUE_LOCK          0x10\n \n-#define _PR_ADD_RUNQ(_thread, _cpu, _pri)                     \\\n-    PR_BEGIN_MACRO                                            \\\n+#define _PR_ADD_RUNQ(_thread, _cpu, _pri) \\\n+    PR_BEGIN_MACRO \\\n     PR_APPEND_LINK(&(_thread)->links, &_PR_RUNQ(_cpu)[_pri]); \\\n-    _PR_RUNQREADYMASK(_cpu) |= (1L << _pri);                  \\\n-    PR_ASSERT((_thread)->queueCount == 0);                    \\\n-    (_thread)->queueCount = QUEUE_RUN;                        \\\n+    _PR_RUNQREADYMASK(_cpu) |= (1L << _pri); \\\n+    PR_ASSERT((_thread)->queueCount == 0); \\\n+    (_thread)->queueCount = QUEUE_RUN; \\\n     PR_END_MACRO\n \n-#define _PR_DEL_RUNQ(_thread)                      \\\n-    PR_BEGIN_MACRO                                 \\\n-    _PRCPU* _cpu = _thread->cpu;                   \\\n-    PRInt32 _pri = _thread->priority;              \\\n-    PR_REMOVE_LINK(&(_thread)->links);             \\\n-    if (PR_CLIST_IS_EMPTY(&_PR_RUNQ(_cpu)[_pri]))  \\\n-        _PR_RUNQREADYMASK(_cpu) &= ~(1L << _pri);  \\\n-    PR_ASSERT((_thread)->queueCount == QUEUE_RUN); \\\n-    (_thread)->queueCount = 0;                     \\\n+#define _PR_DEL_RUNQ(_thread) \\\n+    PR_BEGIN_MACRO \\\n+    _PRCPU *_cpu = _thread->cpu; \\\n+    PRInt32 _pri = _thread->priority; \\\n+    PR_REMOVE_LINK(&(_thread)->links); \\\n+    if (PR_CLIST_IS_EMPTY(&_PR_RUNQ(_cpu)[_pri])) \\\n+        _PR_RUNQREADYMASK(_cpu) &= ~(1L << _pri); \\\n+    PR_ASSERT((_thread)->queueCount == QUEUE_RUN);\\\n+    (_thread)->queueCount = 0; \\\n     PR_END_MACRO\n \n-#define _PR_ADD_SLEEPQ(_thread, _timeout)  \\\n+#define _PR_ADD_SLEEPQ(_thread, _timeout) \\\n     PR_ASSERT((_thread)->queueCount == 0); \\\n-    (_thread)->queueCount = QUEUE_SLEEP;   \\\n+    (_thread)->queueCount = QUEUE_SLEEP; \\\n     _PR_AddSleepQ(_thread, _timeout);\n \n-#define _PR_DEL_SLEEPQ(_thread, _propogate)          \\\n-    PR_ASSERT((_thread)->queueCount == QUEUE_SLEEP); \\\n-    (_thread)->queueCount = 0;                       \\\n+#define _PR_DEL_SLEEPQ(_thread, _propogate) \\\n+    PR_ASSERT((_thread)->queueCount == QUEUE_SLEEP);\\\n+    (_thread)->queueCount = 0; \\\n     _PR_DelSleepQ(_thread, _propogate);\n \n-#define _PR_ADD_JOINQ(_thread, _cpu)       \\\n+#define _PR_ADD_JOINQ(_thread, _cpu) \\\n     PR_ASSERT((_thread)->queueCount == 0); \\\n-    (_thread)->queueCount = QUEUE_JOIN;    \\\n+    (_thread)->queueCount = QUEUE_JOIN; \\\n     PR_APPEND_LINK(&(_thread)->links, &_PR_WAITINGTOJOINQ(_cpu));\n \n-#define _PR_DEL_JOINQ(_thread)                      \\\n-    PR_ASSERT((_thread)->queueCount == QUEUE_JOIN); \\\n-    (_thread)->queueCount = 0;                      \\\n+#define _PR_DEL_JOINQ(_thread) \\\n+    PR_ASSERT((_thread)->queueCount == QUEUE_JOIN);\\\n+    (_thread)->queueCount = 0; \\\n     PR_REMOVE_LINK(&(_thread)->links);\n \n-#define _PR_ADD_SUSPENDQ(_thread, _cpu)    \\\n+#define _PR_ADD_SUSPENDQ(_thread, _cpu) \\\n     PR_ASSERT((_thread)->queueCount == 0); \\\n     (_thread)->queueCount = QUEUE_SUSPEND; \\\n     PR_APPEND_LINK(&(_thread)->links, &_PR_SUSPENDQ(_cpu));\n \n-#define _PR_DEL_SUSPENDQ(_thread)                      \\\n-    PR_ASSERT((_thread)->queueCount == QUEUE_SUSPEND); \\\n-    (_thread)->queueCount = 0;                         \\\n+#define _PR_DEL_SUSPENDQ(_thread) \\\n+    PR_ASSERT((_thread)->queueCount == QUEUE_SUSPEND);\\\n+    (_thread)->queueCount = 0; \\\n     PR_REMOVE_LINK(&(_thread)->links);\n \n #define _PR_THREAD_SWITCH_CPU(_thread, _newCPU) \\\n@@ -506,184 +510,187 @@ extern PRInt32 _native_threads_only;\n extern _PRInterruptTable _pr_interruptTable[];\n \n /* Bits for _pr_interruptState.u.missed[0,1] */\n-#define _PR_MISSED_CLOCK 0x1\n-#define _PR_MISSED_IO 0x2\n-#define _PR_MISSED_CHILD 0x4\n+#define _PR_MISSED_CLOCK    0x1\n+#define _PR_MISSED_IO        0x2\n+#define _PR_MISSED_CHILD    0x4\n \n-extern void _PR_IntsOn(_PRCPU* cpu);\n+extern void _PR_IntsOn(_PRCPU *cpu);\n \n-NSPR_API(void)\n-_PR_WakeupCPU(void);\n-NSPR_API(void)\n-_PR_PauseCPU(void);\n+NSPR_API(void) _PR_WakeupCPU(void);\n+NSPR_API(void) _PR_PauseCPU(void);\n \n /************************************************************************/\n \n-#define _PR_LOCK_LOCK(_lock) _PR_MD_LOCK(&(_lock)->ilock);\n-#define _PR_LOCK_UNLOCK(_lock) _PR_MD_UNLOCK(&(_lock)->ilock);\n+#define _PR_LOCK_LOCK(_lock) \\\n+    _PR_MD_LOCK(&(_lock)->ilock);\n+#define _PR_LOCK_UNLOCK(_lock) \\\n+    _PR_MD_UNLOCK(&(_lock)->ilock);\n \n-extern void _PR_UnblockLockWaiter(PRLock* lock);\n-extern PRStatus _PR_InitLock(PRLock* lock);\n-extern void _PR_FreeLock(PRLock* lock);\n+extern void _PR_UnblockLockWaiter(PRLock *lock);\n+extern PRStatus _PR_InitLock(PRLock *lock);\n+extern void _PR_FreeLock(PRLock *lock);\n \n-#define _PR_LOCK_PTR(_qp) ((PRLock*)((char*)(_qp) - offsetof(PRLock, links)))\n+#define _PR_LOCK_PTR(_qp) \\\n+    ((PRLock*) ((char*) (_qp) - offsetof(PRLock,links)))\n \n /************************************************************************/\n \n-#define _PR_CVAR_LOCK(_cvar) _PR_MD_LOCK(&(_cvar)->ilock);\n-#define _PR_CVAR_UNLOCK(_cvar) _PR_MD_UNLOCK(&(_cvar)->ilock);\n+#define _PR_CVAR_LOCK(_cvar) \\\n+    _PR_MD_LOCK(&(_cvar)->ilock);\n+#define _PR_CVAR_UNLOCK(_cvar) \\\n+    _PR_MD_UNLOCK(&(_cvar)->ilock);\n \n-extern PRStatus _PR_InitCondVar(PRCondVar* cvar, PRLock* lock);\n-extern void _PR_FreeCondVar(PRCondVar* cvar);\n-extern PRStatus _PR_WaitCondVar(PRThread* thread, PRCondVar* cvar, PRLock* lock,\n-                                PRIntervalTime timeout);\n-extern void _PR_NotifyCondVar(PRCondVar* cvar, PRThread* me);\n-extern PRUint32 _PR_CondVarToString(PRCondVar* cvar, char* buf,\n-                                    PRUint32 buflen);\n+extern PRStatus _PR_InitCondVar(PRCondVar *cvar, PRLock *lock);\n+extern void _PR_FreeCondVar(PRCondVar *cvar);\n+extern PRStatus _PR_WaitCondVar(\n+    PRThread *thread, PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout);\n+extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me);\n+extern PRUint32 _PR_CondVarToString(PRCondVar *cvar, char *buf, PRUint32 buflen);\n \n-NSPR_API(void)\n-_PR_Notify(PRMonitor* mon, PRBool all, PRBool sticky);\n+NSPR_API(void) _PR_Notify(PRMonitor *mon, PRBool all, PRBool sticky);\n \n /* PRThread.flags */\n-#define _PR_SYSTEM 0x01\n-#define _PR_INTERRUPT 0x02\n-#define _PR_ATTACHED 0x04            /* created via PR_AttachThread */\n-#define _PR_PRIMORDIAL 0x08          /* the thread that called PR_Init */\n-#define _PR_ON_SLEEPQ 0x10           /* thread is on the sleepQ */\n-#define _PR_ON_PAUSEQ 0x20           /* thread is on the pauseQ */\n-#define _PR_SUSPENDING 0x40          /* thread wants to suspend */\n-#define _PR_GLOBAL_SCOPE 0x80        /* thread is global scope */\n-#define _PR_IDLE_THREAD 0x200        /* this is an idle thread        */\n-#define _PR_GCABLE_THREAD 0x400      /* this is a collectable thread */\n-#define _PR_BOUND_THREAD 0x800       /* a bound thread */\n-#define _PR_INTERRUPT_BLOCKED 0x1000 /* interrupts blocked */\n+#define _PR_SYSTEM          0x01\n+#define _PR_INTERRUPT       0x02\n+#define _PR_ATTACHED        0x04        /* created via PR_AttachThread */\n+#define _PR_PRIMORDIAL      0x08        /* the thread that called PR_Init */\n+#define _PR_ON_SLEEPQ       0x10        /* thread is on the sleepQ */\n+#define _PR_ON_PAUSEQ       0x20        /* thread is on the pauseQ */\n+#define _PR_SUSPENDING      0x40        /* thread wants to suspend */\n+#define _PR_GLOBAL_SCOPE    0x80        /* thread is global scope */\n+#define _PR_IDLE_THREAD     0x200       /* this is an idle thread        */\n+#define _PR_GCABLE_THREAD   0x400       /* this is a collectable thread */\n+#define _PR_BOUND_THREAD    0x800       /* a bound thread */\n+#define _PR_INTERRUPT_BLOCKED   0x1000  /* interrupts blocked */\n \n /* PRThread.state */\n-#define _PR_UNBORN 0\n-#define _PR_RUNNABLE 1\n-#define _PR_RUNNING 2\n-#define _PR_LOCK_WAIT 3\n-#define _PR_COND_WAIT 4\n-#define _PR_JOIN_WAIT 5\n-#define _PR_IO_WAIT 6\n-#define _PR_SUSPENDED 7\n-#define _PR_DEAD_STATE 8         /* for debugging */\n+#define _PR_UNBORN       0\n+#define _PR_RUNNABLE     1\n+#define _PR_RUNNING      2\n+#define _PR_LOCK_WAIT    3\n+#define _PR_COND_WAIT    4\n+#define _PR_JOIN_WAIT    5\n+#define _PR_IO_WAIT      6\n+#define _PR_SUSPENDED    7\n+#define _PR_DEAD_STATE   8  /* for debugging */\n \n /* PRThreadStack.flags */\n-#define _PR_STACK_VM 0x1         /* using vm instead of malloc */\n-#define _PR_STACK_MAPPED 0x2     /* vm is mapped */\n-#define _PR_STACK_PRIMORDIAL 0x4 /* stack for primordial thread */\n+#define _PR_STACK_VM            0x1    /* using vm instead of malloc */\n+#define _PR_STACK_MAPPED        0x2    /* vm is mapped */\n+#define _PR_STACK_PRIMORDIAL    0x4    /* stack for primordial thread */\n \n /*\n ** If the default stcksize from the client is zero, we need to pick a machine\n-** dependent value.  This is only for standard user threads.  For custom\n-* threads,\n+** dependent value.  This is only for standard user threads.  For custom threads,\n ** 0 has a special meaning.\n ** Adjust stackSize. Round up to a page boundary.\n */\n \n #ifndef _MD_MINIMUM_STACK_SIZE\n-#define _MD_MINIMUM_STACK_SIZE 0\n+#define _MD_MINIMUM_STACK_SIZE  0\n #endif\n \n #if (!defined(HAVE_CUSTOM_USER_THREADS))\n-#define _PR_ADJUST_STACKSIZE(stackSize)                                  \\\n-    PR_BEGIN_MACRO                                                       \\\n-    if (stackSize == 0)                                                  \\\n-        stackSize = _MD_DEFAULT_STACK_SIZE;                              \\\n-    if (stackSize < _MD_MINIMUM_STACK_SIZE)                              \\\n-        stackSize = _MD_MINIMUM_STACK_SIZE;                              \\\n+#define        _PR_ADJUST_STACKSIZE(stackSize) \\\n+        PR_BEGIN_MACRO \\\n+    if (stackSize == 0) \\\n+                stackSize = _MD_DEFAULT_STACK_SIZE; \\\n+    if (stackSize < _MD_MINIMUM_STACK_SIZE) \\\n+                stackSize = _MD_MINIMUM_STACK_SIZE; \\\n     stackSize = (stackSize + (1 << _pr_pageShift) - 1) >> _pr_pageShift; \\\n-    stackSize <<= _pr_pageShift;                                         \\\n-    PR_END_MACRO\n+    stackSize <<= _pr_pageShift; \\\n+        PR_END_MACRO\n #else\n-#define _PR_ADJUST_STACKSIZE(stackSize)\n+#define        _PR_ADJUST_STACKSIZE(stackSize)\n #endif\n \n #define _PR_IS_GCABLE_THREAD(thr) ((thr)->flags & _PR_GCABLE_THREAD)\n \n-#define _PR_PENDING_INTERRUPT(thr) \\\n-    (!((thr)->flags & _PR_INTERRUPT_BLOCKED) && ((thr)->flags & _PR_INTERRUPT))\n-#define _PR_THREAD_BLOCK_INTERRUPT(thr) (thr->flags |= _PR_INTERRUPT_BLOCKED)\n-#define _PR_THREAD_UNBLOCK_INTERRUPT(thr) \\\n-    (thr->flags &= ~_PR_INTERRUPT_BLOCKED)\n+#define _PR_PENDING_INTERRUPT(thr)                  \\\n+        (!((thr)->flags & _PR_INTERRUPT_BLOCKED) && ((thr)->flags & _PR_INTERRUPT))\n+#define _PR_THREAD_BLOCK_INTERRUPT(thr)         \\\n+        (thr->flags |= _PR_INTERRUPT_BLOCKED)\n+#define _PR_THREAD_UNBLOCK_INTERRUPT(thr)           \\\n+        (thr->flags &= ~_PR_INTERRUPT_BLOCKED)\n \n #define _PR_THREAD_PTR(_qp) \\\n-    ((PRThread*)((char*)(_qp) - offsetof(PRThread, links)))\n+    ((PRThread*) ((char*) (_qp) - offsetof(PRThread,links)))\n \n #define _PR_ACTIVE_THREAD_PTR(_qp) \\\n-    ((PRThread*)((char*)(_qp) - offsetof(PRThread, active)))\n+    ((PRThread*) ((char*) (_qp) - offsetof(PRThread,active)))\n \n #define _PR_THREAD_CONDQ_PTR(_qp) \\\n-    ((PRThread*)((char*)(_qp) - offsetof(PRThread, waitQLinks)))\n+    ((PRThread*) ((char*) (_qp) - offsetof(PRThread,waitQLinks)))\n \n #define _PR_THREAD_MD_TO_PTR(_md) \\\n-    ((PRThread*)((char*)(_md) - offsetof(PRThread, md)))\n+    ((PRThread*) ((char*) (_md) - offsetof(PRThread,md)))\n \n-#define _PR_THREAD_STACK_TO_PTR(_stack) ((PRThread*)(_stack->thr))\n+#define _PR_THREAD_STACK_TO_PTR(_stack) \\\n+    ((PRThread*) (_stack->thr))\n \n extern PRCList _pr_active_local_threadQ;\n extern PRCList _pr_active_global_threadQ;\n extern PRCList _pr_cpuQ;\n-extern _MDLock _pr_cpuLock;\n+extern _MDLock  _pr_cpuLock;\n extern PRInt32 _pr_md_idle_cpus;\n \n-#define _PR_ACTIVE_LOCAL_THREADQ() _pr_active_local_threadQ\n-#define _PR_ACTIVE_GLOBAL_THREADQ() _pr_active_global_threadQ\n-#define _PR_CPUQ() _pr_cpuQ\n-#define _PR_RUNQ(_cpu) ((_cpu)->queue->runQ)\n-#define _PR_RUNQREADYMASK(_cpu) ((_cpu)->queue->runQReadyMask)\n-#define _PR_SLEEPQ(_cpu) ((_cpu)->queue->sleepQ)\n-#define _PR_SLEEPQMAX(_cpu) ((_cpu)->queue->sleepQmax)\n-#define _PR_PAUSEQ(_cpu) ((_cpu)->queue->pauseQ)\n-#define _PR_SUSPENDQ(_cpu) ((_cpu)->queue->suspendQ)\n-#define _PR_WAITINGTOJOINQ(_cpu) ((_cpu)->queue->waitingToJoinQ)\n-\n-extern PRUint32 _pr_recycleThreads; /* Flag for behavior on thread cleanup */\n-extern PRLock* _pr_deadQLock;\n+#define _PR_ACTIVE_LOCAL_THREADQ()          _pr_active_local_threadQ\n+#define _PR_ACTIVE_GLOBAL_THREADQ()         _pr_active_global_threadQ\n+#define _PR_CPUQ()                          _pr_cpuQ\n+#define _PR_RUNQ(_cpu)                      ((_cpu)->queue->runQ)\n+#define _PR_RUNQREADYMASK(_cpu)             ((_cpu)->queue->runQReadyMask)\n+#define _PR_SLEEPQ(_cpu)                    ((_cpu)->queue->sleepQ)\n+#define _PR_SLEEPQMAX(_cpu)                 ((_cpu)->queue->sleepQmax)\n+#define _PR_PAUSEQ(_cpu)                    ((_cpu)->queue->pauseQ)\n+#define _PR_SUSPENDQ(_cpu)                  ((_cpu)->queue->suspendQ)\n+#define _PR_WAITINGTOJOINQ(_cpu)            ((_cpu)->queue->waitingToJoinQ)\n+\n+extern PRUint32 _pr_recycleThreads;   /* Flag for behavior on thread cleanup */\n+extern PRLock *_pr_deadQLock;\n extern PRUint32 _pr_numNativeDead;\n extern PRUint32 _pr_numUserDead;\n extern PRCList _pr_deadNativeQ;\n extern PRCList _pr_deadUserQ;\n-#define _PR_DEADNATIVEQ _pr_deadNativeQ\n-#define _PR_DEADUSERQ _pr_deadUserQ\n-#define _PR_DEADQ_LOCK PR_Lock(_pr_deadQLock);\n-#define _PR_DEADQ_UNLOCK PR_Unlock(_pr_deadQLock);\n-#define _PR_INC_DEADNATIVE (_pr_numNativeDead++)\n-#define _PR_DEC_DEADNATIVE (_pr_numNativeDead--)\n-#define _PR_NUM_DEADNATIVE (_pr_numNativeDead)\n-#define _PR_INC_DEADUSER (_pr_numUserDead++)\n-#define _PR_DEC_DEADUSER (_pr_numUserDead--)\n-#define _PR_NUM_DEADUSER (_pr_numUserDead)\n+#define _PR_DEADNATIVEQ     _pr_deadNativeQ\n+#define _PR_DEADUSERQ       _pr_deadUserQ\n+#define _PR_DEADQ_LOCK      PR_Lock(_pr_deadQLock);\n+#define _PR_DEADQ_UNLOCK    PR_Unlock(_pr_deadQLock);\n+#define _PR_INC_DEADNATIVE  (_pr_numNativeDead++)\n+#define _PR_DEC_DEADNATIVE  (_pr_numNativeDead--)\n+#define _PR_NUM_DEADNATIVE  (_pr_numNativeDead)\n+#define _PR_INC_DEADUSER    (_pr_numUserDead++)\n+#define _PR_DEC_DEADUSER    (_pr_numUserDead--)\n+#define _PR_NUM_DEADUSER    (_pr_numUserDead)\n \n extern PRUint32 _pr_utid;\n \n-extern struct _PRCPU* _pr_primordialCPU;\n+extern struct _PRCPU  *_pr_primordialCPU;\n \n-extern PRLock* _pr_activeLock;            /* lock for userActive and systemActive */\n-extern PRInt32 _pr_userActive;            /* number of active user threads */\n-extern PRInt32 _pr_systemActive;          /* number of active system threads */\n-extern PRInt32 _pr_primordialExitCount;   /* number of user threads left\n-                                           * before the primordial thread\n-                                           * can exit.  */\n-extern PRCondVar* _pr_primordialExitCVar; /* the condition variable for\n+extern PRLock *_pr_activeLock;          /* lock for userActive and systemActive */\n+extern PRInt32 _pr_userActive;          /* number of active user threads */\n+extern PRInt32 _pr_systemActive;        /* number of active system threads */\n+extern PRInt32 _pr_primordialExitCount; /* number of user threads left\n+                                         * before the primordial thread\n+                                         * can exit.  */\n+extern PRCondVar *_pr_primordialExitCVar; /* the condition variable for\n                                            * notifying the primordial thread\n                                            * when all other user threads\n                                            * have terminated.  */\n \n extern PRUintn _pr_maxPTDs;\n \n-extern PRLock* _pr_terminationCVLock;\n+extern PRLock *_pr_terminationCVLock;\n \n /*************************************************************************\n- * Internal routines either called by PR itself or from machine-dependent *\n- * code.                                                                  *\n- *************************************************************************/\n+* Internal routines either called by PR itself or from machine-dependent *\n+* code.                                                                  *\n+*************************************************************************/\n \n extern void _PR_ClockInterrupt(void);\n \n extern void _PR_Schedule(void);\n-extern void _PR_SetThreadPriority(PRThread* thread, PRThreadPriority priority);\n+extern void _PR_SetThreadPriority(\n+    PRThread* thread, PRThreadPriority priority);\n \n /***********************************************************************\n ** FUNCTION:    _PR_NewSegment()\n@@ -699,7 +706,7 @@ extern void _PR_SetThreadPriority(PRThread* thread, PRThreadPriority priority);\n ** OUTPUTS: a memory segment is allocated, a PRSegment is allocated\n ** RETURN:  pointer to PRSegment\n ***********************************************************************/\n-extern PRSegment* _PR_NewSegment(PRUint32 size, void* vaddr);\n+extern PRSegment* _PR_NewSegment(PRUint32 size, void *vaddr);\n \n /***********************************************************************\n ** FUNCTION:    _PR_DestroySegment()\n@@ -709,182 +716,158 @@ extern PRSegment* _PR_NewSegment(PRUint32 size, void* vaddr);\n ** OUTPUTS: the the PRSegment and its associated memory segment are freed\n ** RETURN:  void\n ***********************************************************************/\n-extern void _PR_DestroySegment(PRSegment* seg);\n+extern void _PR_DestroySegment(PRSegment *seg);\n \n-extern PRThreadStack* _PR_NewStack(PRUint32 stackSize);\n-extern void _PR_FreeStack(PRThreadStack* stack);\n-extern PRBool _PR_NotifyThread(PRThread* thread, PRThread* me);\n-extern void _PR_NotifyLockedThread(PRThread* thread);\n+extern PRThreadStack * _PR_NewStack(PRUint32 stackSize);\n+extern void _PR_FreeStack(PRThreadStack *stack);\n+extern PRBool _PR_NotifyThread (PRThread *thread, PRThread *me);\n+extern void _PR_NotifyLockedThread (PRThread *thread);\n \n-NSPR_API(void)\n-_PR_AddSleepQ(PRThread* thread, PRIntervalTime timeout);\n-NSPR_API(void)\n-_PR_DelSleepQ(PRThread* thread, PRBool propogate_time);\n+NSPR_API(void) _PR_AddSleepQ(PRThread *thread, PRIntervalTime timeout);\n+NSPR_API(void) _PR_DelSleepQ(PRThread *thread, PRBool propogate_time);\n \n-extern void _PR_AddThreadToRunQ(PRThread* me, PRThread* thread);\n+extern void _PR_AddThreadToRunQ(PRThread *me, PRThread *thread);\n \n-NSPR_API(PRThread*)\n-_PR_CreateThread(PRThreadType type, void (*start)(void* arg), void* arg,\n-                 PRThreadPriority priority, PRThreadScope scope,\n-                 PRThreadState state, PRUint32 stackSize, PRUint32 flags);\n+NSPR_API(PRThread*) _PR_CreateThread(PRThreadType type,\n+                                     void (*start)(void *arg),\n+                                     void *arg,\n+                                     PRThreadPriority priority,\n+                                     PRThreadScope scope,\n+                                     PRThreadState state,\n+                                     PRUint32 stackSize,\n+                                     PRUint32 flags);\n \n-extern void _PR_NativeDestroyThread(PRThread* thread);\n-extern void _PR_UserDestroyThread(PRThread* thread);\n+extern void _PR_NativeDestroyThread(PRThread *thread);\n+extern void _PR_UserDestroyThread(PRThread *thread);\n \n-extern PRThread* _PRI_AttachThread(PRThreadType type, PRThreadPriority priority,\n-                                   PRThreadStack* stack, PRUint32 flags);\n+extern PRThread* _PRI_AttachThread(\n+    PRThreadType type, PRThreadPriority priority,\n+    PRThreadStack *stack, PRUint32 flags);\n \n extern void _PRI_DetachThread(void);\n \n+\n #define _PR_IO_PENDING(_thread) ((_thread)->io_pending)\n \n-NSPR_API(void)\n-_PR_MD_INIT_CPUS();\n-#define _PR_MD_INIT_CPUS _MD_INIT_CPUS\n+NSPR_API(void) _PR_MD_INIT_CPUS();\n+#define    _PR_MD_INIT_CPUS _MD_INIT_CPUS\n \n-NSPR_API(void)\n-_PR_MD_WAKEUP_CPUS();\n-#define _PR_MD_WAKEUP_CPUS _MD_WAKEUP_CPUS\n+NSPR_API(void) _PR_MD_WAKEUP_CPUS();\n+#define    _PR_MD_WAKEUP_CPUS _MD_WAKEUP_CPUS\n \n /* Interrupts related */\n \n-NSPR_API(void)\n-_PR_MD_START_INTERRUPTS(void);\n-#define _PR_MD_START_INTERRUPTS _MD_START_INTERRUPTS\n+NSPR_API(void) _PR_MD_START_INTERRUPTS(void);\n+#define    _PR_MD_START_INTERRUPTS _MD_START_INTERRUPTS\n \n-NSPR_API(void)\n-_PR_MD_STOP_INTERRUPTS(void);\n-#define _PR_MD_STOP_INTERRUPTS _MD_STOP_INTERRUPTS\n+NSPR_API(void) _PR_MD_STOP_INTERRUPTS(void);\n+#define    _PR_MD_STOP_INTERRUPTS _MD_STOP_INTERRUPTS\n \n-NSPR_API(void)\n-_PR_MD_ENABLE_CLOCK_INTERRUPTS(void);\n-#define _PR_MD_ENABLE_CLOCK_INTERRUPTS _MD_ENABLE_CLOCK_INTERRUPTS\n+NSPR_API(void) _PR_MD_ENABLE_CLOCK_INTERRUPTS(void);\n+#define    _PR_MD_ENABLE_CLOCK_INTERRUPTS _MD_ENABLE_CLOCK_INTERRUPTS\n \n-NSPR_API(void)\n-_PR_MD_DISABLE_CLOCK_INTERRUPTS(void);\n-#define _PR_MD_DISABLE_CLOCK_INTERRUPTS _MD_DISABLE_CLOCK_INTERRUPTS\n+NSPR_API(void) _PR_MD_DISABLE_CLOCK_INTERRUPTS(void);\n+#define    _PR_MD_DISABLE_CLOCK_INTERRUPTS _MD_DISABLE_CLOCK_INTERRUPTS\n \n-NSPR_API(void)\n-_PR_MD_BLOCK_CLOCK_INTERRUPTS(void);\n-#define _PR_MD_BLOCK_CLOCK_INTERRUPTS _MD_BLOCK_CLOCK_INTERRUPTS\n+NSPR_API(void) _PR_MD_BLOCK_CLOCK_INTERRUPTS(void);\n+#define    _PR_MD_BLOCK_CLOCK_INTERRUPTS _MD_BLOCK_CLOCK_INTERRUPTS\n \n-NSPR_API(void)\n-_PR_MD_UNBLOCK_CLOCK_INTERRUPTS(void);\n-#define _PR_MD_UNBLOCK_CLOCK_INTERRUPTS _MD_UNBLOCK_CLOCK_INTERRUPTS\n+NSPR_API(void) _PR_MD_UNBLOCK_CLOCK_INTERRUPTS(void);\n+#define    _PR_MD_UNBLOCK_CLOCK_INTERRUPTS _MD_UNBLOCK_CLOCK_INTERRUPTS\n \n /* The _PR_MD_WAIT_LOCK and _PR_MD_WAKEUP_WAITER functions put to sleep and\n  * awaken a thread which is waiting on a lock or cvar.\n  */\n-extern PRStatus _PR_MD_WAIT(PRThread*, PRIntervalTime timeout);\n-#define _PR_MD_WAIT _MD_WAIT\n+extern PRStatus _PR_MD_WAIT(PRThread *, PRIntervalTime timeout);\n+#define    _PR_MD_WAIT _MD_WAIT\n \n-extern PRStatus _PR_MD_WAKEUP_WAITER(PRThread*);\n-#define _PR_MD_WAKEUP_WAITER _MD_WAKEUP_WAITER\n+extern PRStatus _PR_MD_WAKEUP_WAITER(PRThread *);\n+#define    _PR_MD_WAKEUP_WAITER _MD_WAKEUP_WAITER\n \n #ifndef _PR_LOCAL_THREADS_ONLY /* not if only local threads supported */\n-NSPR_API(void)\n-_PR_MD_CLOCK_INTERRUPT(void);\n-#define _PR_MD_CLOCK_INTERRUPT _MD_CLOCK_INTERRUPT\n+NSPR_API(void) _PR_MD_CLOCK_INTERRUPT(void);\n+#define    _PR_MD_CLOCK_INTERRUPT _MD_CLOCK_INTERRUPT\n #endif\n \n /* Stack debugging */\n-NSPR_API(void)\n-_PR_MD_INIT_STACK(PRThreadStack* ts, PRIntn redzone);\n-#define _PR_MD_INIT_STACK _MD_INIT_STACK\n+NSPR_API(void) _PR_MD_INIT_STACK(PRThreadStack *ts, PRIntn redzone);\n+#define    _PR_MD_INIT_STACK _MD_INIT_STACK\n \n-NSPR_API(void)\n-_PR_MD_CLEAR_STACK(PRThreadStack* ts);\n-#define _PR_MD_CLEAR_STACK _MD_CLEAR_STACK\n+NSPR_API(void) _PR_MD_CLEAR_STACK(PRThreadStack* ts);\n+#define    _PR_MD_CLEAR_STACK _MD_CLEAR_STACK\n \n /* CPU related */\n-NSPR_API(PRInt32)\n-_PR_MD_GET_INTSOFF(void);\n-#define _PR_MD_GET_INTSOFF _MD_GET_INTSOFF\n+NSPR_API(PRInt32) _PR_MD_GET_INTSOFF(void);\n+#define    _PR_MD_GET_INTSOFF _MD_GET_INTSOFF\n \n-NSPR_API(void)\n-_PR_MD_SET_INTSOFF(PRInt32 _val);\n-#define _PR_MD_SET_INTSOFF _MD_SET_INTSOFF\n+NSPR_API(void) _PR_MD_SET_INTSOFF(PRInt32 _val);\n+#define    _PR_MD_SET_INTSOFF _MD_SET_INTSOFF\n \n-NSPR_API(_PRCPU*)\n-_PR_MD_CURRENT_CPU(void);\n-#define _PR_MD_CURRENT_CPU _MD_CURRENT_CPU\n+NSPR_API(_PRCPU*) _PR_MD_CURRENT_CPU(void);\n+#define    _PR_MD_CURRENT_CPU _MD_CURRENT_CPU\n \n-NSPR_API(void)\n-_PR_MD_SET_CURRENT_CPU(_PRCPU* cpu);\n-#define _PR_MD_SET_CURRENT_CPU _MD_SET_CURRENT_CPU\n+NSPR_API(void) _PR_MD_SET_CURRENT_CPU(_PRCPU *cpu);\n+#define    _PR_MD_SET_CURRENT_CPU _MD_SET_CURRENT_CPU\n \n-NSPR_API(void)\n-_PR_MD_INIT_RUNNING_CPU(_PRCPU* cpu);\n-#define _PR_MD_INIT_RUNNING_CPU _MD_INIT_RUNNING_CPU\n+NSPR_API(void) _PR_MD_INIT_RUNNING_CPU(_PRCPU *cpu);\n+#define    _PR_MD_INIT_RUNNING_CPU _MD_INIT_RUNNING_CPU\n \n /*\n  * Returns the number of threads awoken or 0 if a timeout occurred;\n  */\n extern PRInt32 _PR_MD_PAUSE_CPU(PRIntervalTime timeout);\n-#define _PR_MD_PAUSE_CPU _MD_PAUSE_CPU\n+#define    _PR_MD_PAUSE_CPU _MD_PAUSE_CPU\n \n extern void _PR_MD_CLEANUP_BEFORE_EXIT(void);\n #define _PR_MD_CLEANUP_BEFORE_EXIT _MD_CLEANUP_BEFORE_EXIT\n \n extern void _PR_MD_EXIT(PRIntn status);\n-#define _PR_MD_EXIT _MD_EXIT\n+#define    _PR_MD_EXIT _MD_EXIT\n \n /* Locks related */\n \n-NSPR_API(void)\n-_PR_MD_INIT_LOCKS(void);\n-#define _PR_MD_INIT_LOCKS _MD_INIT_LOCKS\n+NSPR_API(void) _PR_MD_INIT_LOCKS(void);\n+#define    _PR_MD_INIT_LOCKS _MD_INIT_LOCKS\n \n-NSPR_API(PRStatus)\n-_PR_MD_NEW_LOCK(_MDLock* md);\n-#define _PR_MD_NEW_LOCK _MD_NEW_LOCK\n+NSPR_API(PRStatus) _PR_MD_NEW_LOCK(_MDLock *md);\n+#define    _PR_MD_NEW_LOCK _MD_NEW_LOCK\n \n-NSPR_API(void)\n-_PR_MD_FREE_LOCK(_MDLock* md);\n-#define _PR_MD_FREE_LOCK _MD_FREE_LOCK\n+NSPR_API(void) _PR_MD_FREE_LOCK(_MDLock *md);\n+#define    _PR_MD_FREE_LOCK _MD_FREE_LOCK\n \n-NSPR_API(void)\n-_PR_MD_LOCK(_MDLock* md);\n-#define _PR_MD_LOCK _MD_LOCK\n+NSPR_API(void) _PR_MD_LOCK(_MDLock *md);\n+#define    _PR_MD_LOCK _MD_LOCK\n \n /* Return 0 on success, a nonzero value on failure. */\n-NSPR_API(PRIntn)\n-_PR_MD_TEST_AND_LOCK(_MDLock* md);\n-#define _PR_MD_TEST_AND_LOCK _MD_TEST_AND_LOCK\n+NSPR_API(PRIntn) _PR_MD_TEST_AND_LOCK(_MDLock *md);\n+#define    _PR_MD_TEST_AND_LOCK _MD_TEST_AND_LOCK\n \n-NSPR_API(void)\n-_PR_MD_UNLOCK(_MDLock* md);\n-#define _PR_MD_UNLOCK _MD_UNLOCK\n+NSPR_API(void) _PR_MD_UNLOCK(_MDLock *md);\n+#define    _PR_MD_UNLOCK _MD_UNLOCK\n \n-NSPR_API(void)\n-_PR_MD_IOQ_LOCK(void);\n-#define _PR_MD_IOQ_LOCK _MD_IOQ_LOCK\n+NSPR_API(void) _PR_MD_IOQ_LOCK(void);\n+#define    _PR_MD_IOQ_LOCK _MD_IOQ_LOCK\n \n-NSPR_API(void)\n-_PR_MD_IOQ_UNLOCK(void);\n-#define _PR_MD_IOQ_UNLOCK _MD_IOQ_UNLOCK\n+NSPR_API(void) _PR_MD_IOQ_UNLOCK(void);\n+#define    _PR_MD_IOQ_UNLOCK _MD_IOQ_UNLOCK\n \n #ifndef _PR_LOCAL_THREADS_ONLY /* not if only local threads supported */\n /* Semaphore related -- only for native threads */\n #ifdef HAVE_CVAR_BUILT_ON_SEM\n-NSPR_API(void)\n-_PR_MD_NEW_SEM(_MDSemaphore* md, PRUintn value);\n+NSPR_API(void) _PR_MD_NEW_SEM(_MDSemaphore *md, PRUintn value);\n #define _PR_MD_NEW_SEM _MD_NEW_SEM\n \n-NSPR_API(void)\n-_PR_MD_DESTROY_SEM(_MDSemaphore* md);\n+NSPR_API(void) _PR_MD_DESTROY_SEM(_MDSemaphore *md);\n #define _PR_MD_DESTROY_SEM _MD_DESTROY_SEM\n \n-NSPR_API(PRStatus)\n-_PR_MD_TIMED_WAIT_SEM(_MDSemaphore* md, PRIntervalTime timeout);\n+NSPR_API(PRStatus) _PR_MD_TIMED_WAIT_SEM(\n+    _MDSemaphore *md, PRIntervalTime timeout);\n #define _PR_MD_TIMED_WAIT_SEM _MD_TIMED_WAIT_SEM\n \n-NSPR_API(PRStatus)\n-_PR_MD_WAIT_SEM(_MDSemaphore* md);\n+NSPR_API(PRStatus) _PR_MD_WAIT_SEM(_MDSemaphore *md);\n #define _PR_MD_WAIT_SEM _MD_WAIT_SEM\n \n-NSPR_API(void)\n-_PR_MD_POST_SEM(_MDSemaphore* md);\n+NSPR_API(void) _PR_MD_POST_SEM(_MDSemaphore *md);\n #define _PR_MD_POST_SEM _MD_POST_SEM\n #endif /* HAVE_CVAR_BUILT_ON_SEM */\n \n@@ -893,298 +876,289 @@ _PR_MD_POST_SEM(_MDSemaphore* md);\n /* Condition Variables related -- only for native threads */\n \n #ifndef _PR_LOCAL_THREADS_ONLY /* not if only local threads supported */\n-NSPR_API(PRInt32)\n-_PR_MD_NEW_CV(_MDCVar* md);\n-#define _PR_MD_NEW_CV _MD_NEW_CV\n+NSPR_API(PRInt32) _PR_MD_NEW_CV(_MDCVar *md);\n+#define    _PR_MD_NEW_CV _MD_NEW_CV\n \n-NSPR_API(void)\n-_PR_MD_FREE_CV(_MDCVar* md);\n-#define _PR_MD_FREE_CV _MD_FREE_CV\n+NSPR_API(void) _PR_MD_FREE_CV(_MDCVar *md);\n+#define    _PR_MD_FREE_CV _MD_FREE_CV\n \n-NSPR_API(void)\n-_PR_MD_WAIT_CV(_MDCVar* mdCVar, _MDLock* mdLock, PRIntervalTime timeout);\n-#define _PR_MD_WAIT_CV _MD_WAIT_CV\n+NSPR_API(void) _PR_MD_WAIT_CV(\n+    _MDCVar *mdCVar,_MDLock *mdLock,PRIntervalTime timeout);\n+#define    _PR_MD_WAIT_CV _MD_WAIT_CV\n \n-NSPR_API(void)\n-_PR_MD_NOTIFY_CV(_MDCVar* md, _MDLock* lock);\n-#define _PR_MD_NOTIFY_CV _MD_NOTIFY_CV\n+NSPR_API(void) _PR_MD_NOTIFY_CV(_MDCVar *md, _MDLock *lock);\n+#define    _PR_MD_NOTIFY_CV _MD_NOTIFY_CV\n \n-NSPR_API(void)\n-_PR_MD_NOTIFYALL_CV(_MDCVar* md, _MDLock* lock);\n-#define _PR_MD_NOTIFYALL_CV _MD_NOTIFYALL_CV\n+NSPR_API(void) _PR_MD_NOTIFYALL_CV(_MDCVar *md, _MDLock *lock);\n+#define    _PR_MD_NOTIFYALL_CV _MD_NOTIFYALL_CV\n #endif /* _PR_LOCAL_THREADS_ONLY */\n \n /* Threads related */\n-NSPR_API(PRThread*)\n-_PR_MD_CURRENT_THREAD(void);\n-#define _PR_MD_CURRENT_THREAD _MD_CURRENT_THREAD\n+NSPR_API(PRThread*) _PR_MD_CURRENT_THREAD(void);\n+#define    _PR_MD_CURRENT_THREAD _MD_CURRENT_THREAD\n \n-NSPR_API(PRThread*)\n-_PR_MD_GET_ATTACHED_THREAD(void);\n-#define _PR_MD_GET_ATTACHED_THREAD _MD_GET_ATTACHED_THREAD\n+NSPR_API(PRThread*) _PR_MD_GET_ATTACHED_THREAD(void);\n+#define    _PR_MD_GET_ATTACHED_THREAD _MD_GET_ATTACHED_THREAD\n \n-NSPR_API(PRThread*)\n-_PR_MD_LAST_THREAD(void);\n-#define _PR_MD_LAST_THREAD _MD_LAST_THREAD\n+NSPR_API(PRThread*) _PR_MD_LAST_THREAD(void);\n+#define    _PR_MD_LAST_THREAD _MD_LAST_THREAD\n \n-NSPR_API(void)\n-_PR_MD_SET_CURRENT_THREAD(PRThread* thread);\n-#define _PR_MD_SET_CURRENT_THREAD _MD_SET_CURRENT_THREAD\n+NSPR_API(void) _PR_MD_SET_CURRENT_THREAD(PRThread *thread);\n+#define    _PR_MD_SET_CURRENT_THREAD _MD_SET_CURRENT_THREAD\n \n-NSPR_API(void)\n-_PR_MD_SET_LAST_THREAD(PRThread* thread);\n-#define _PR_MD_SET_LAST_THREAD _MD_SET_LAST_THREAD\n+NSPR_API(void) _PR_MD_SET_LAST_THREAD(PRThread *thread);\n+#define    _PR_MD_SET_LAST_THREAD _MD_SET_LAST_THREAD\n \n-extern PRStatus _PR_MD_INIT_THREAD(PRThread* thread);\n-#define _PR_MD_INIT_THREAD _MD_INIT_THREAD\n+extern PRStatus _PR_MD_INIT_THREAD(PRThread *thread);\n+#define    _PR_MD_INIT_THREAD _MD_INIT_THREAD\n \n-extern void _PR_MD_EXIT_THREAD(PRThread* thread);\n-#define _PR_MD_EXIT_THREAD _MD_EXIT_THREAD\n+extern void _PR_MD_EXIT_THREAD(PRThread *thread);\n+#define    _PR_MD_EXIT_THREAD _MD_EXIT_THREAD\n \n #ifndef _PR_LOCAL_THREADS_ONLY /* not if only local threads supported */\n \n-NSPR_API(PRStatus)\n-_PR_MD_INIT_ATTACHED_THREAD(PRThread* thread);\n-#define _PR_MD_INIT_ATTACHED_THREAD _MD_INIT_ATTACHED_THREAD\n+NSPR_API(PRStatus) _PR_MD_INIT_ATTACHED_THREAD(PRThread *thread);\n+#define    _PR_MD_INIT_ATTACHED_THREAD _MD_INIT_ATTACHED_THREAD\n \n-extern void _PR_MD_SUSPEND_THREAD(PRThread* thread);\n-#define _PR_MD_SUSPEND_THREAD _MD_SUSPEND_THREAD\n+extern void _PR_MD_SUSPEND_THREAD(PRThread *thread);\n+#define    _PR_MD_SUSPEND_THREAD _MD_SUSPEND_THREAD\n \n-extern void _PR_MD_RESUME_THREAD(PRThread* thread);\n-#define _PR_MD_RESUME_THREAD _MD_RESUME_THREAD\n+extern void _PR_MD_RESUME_THREAD(PRThread *thread);\n+#define    _PR_MD_RESUME_THREAD _MD_RESUME_THREAD\n \n-extern void _PR_MD_SUSPEND_CPU(_PRCPU* cpu);\n-#define _PR_MD_SUSPEND_CPU _MD_SUSPEND_CPU\n+extern void _PR_MD_SUSPEND_CPU(_PRCPU  *cpu);\n+#define    _PR_MD_SUSPEND_CPU _MD_SUSPEND_CPU\n \n-extern void _PR_MD_RESUME_CPU(_PRCPU* cpu);\n-#define _PR_MD_RESUME_CPU _MD_RESUME_CPU\n+extern void _PR_MD_RESUME_CPU(_PRCPU  *cpu);\n+#define    _PR_MD_RESUME_CPU _MD_RESUME_CPU\n \n extern void _PR_MD_BEGIN_SUSPEND_ALL(void);\n-#define _PR_MD_BEGIN_SUSPEND_ALL _MD_BEGIN_SUSPEND_ALL\n+#define    _PR_MD_BEGIN_SUSPEND_ALL _MD_BEGIN_SUSPEND_ALL\n \n extern void _PR_MD_END_SUSPEND_ALL(void);\n-#define _PR_MD_END_SUSPEND_ALL _MD_END_SUSPEND_ALL\n+#define    _PR_MD_END_SUSPEND_ALL _MD_END_SUSPEND_ALL\n \n extern void _PR_MD_BEGIN_RESUME_ALL(void);\n-#define _PR_MD_BEGIN_RESUME_ALL _MD_BEGIN_RESUME_ALL\n+#define    _PR_MD_BEGIN_RESUME_ALL _MD_BEGIN_RESUME_ALL\n \n extern void _PR_MD_END_RESUME_ALL(void);\n-#define _PR_MD_END_RESUME_ALL _MD_END_RESUME_ALL\n+#define    _PR_MD_END_RESUME_ALL _MD_END_RESUME_ALL\n \n-#endif /* !_PR_LOCAL_THREADS_ONLY */\n+#endif        /* !_PR_LOCAL_THREADS_ONLY */\n \n-extern void _PR_MD_CLEAN_THREAD(PRThread* thread);\n-#define _PR_MD_CLEAN_THREAD _MD_CLEAN_THREAD\n+extern void _PR_MD_CLEAN_THREAD(PRThread *thread);\n+#define    _PR_MD_CLEAN_THREAD _MD_CLEAN_THREAD\n \n #ifdef HAVE_CUSTOM_USER_THREADS\n-extern void _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(PRThread*);\n-#define _PR_MD_CREATE_PRIMORDIAL_USER_THREAD \\\n-    _MD_CREATE_PRIMORDIAL_USER_THREAD\n-\n-extern PRThread* _PR_MD_CREATE_USER_THREAD(PRUint32 stacksize,\n-                                           void (*start)(void*), void* arg);\n-#define _PR_MD_CREATE_USER_THREAD _MD_CREATE_USER_THREAD\n+extern void _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(PRThread *);\n+#define    _PR_MD_CREATE_PRIMORDIAL_USER_THREAD _MD_CREATE_PRIMORDIAL_USER_THREAD\n+\n+extern PRThread* _PR_MD_CREATE_USER_THREAD(\n+    PRUint32 stacksize,\n+    void (*start)(void *),\n+    void *arg);\n+#define    _PR_MD_CREATE_USER_THREAD _MD_CREATE_USER_THREAD\n #endif\n \n-extern PRStatus _PR_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                                     PRThreadPriority priority,\n-                                     PRThreadScope scope, PRThreadState state,\n-                                     PRUint32 stackSize);\n-#define _PR_MD_CREATE_THREAD _MD_CREATE_THREAD\n+extern PRStatus _PR_MD_CREATE_THREAD(\n+    PRThread *thread,\n+    void (*start) (void *),\n+    PRThreadPriority priority,\n+    PRThreadScope scope,\n+    PRThreadState state,\n+    PRUint32 stackSize);\n+#define    _PR_MD_CREATE_THREAD _MD_CREATE_THREAD\n \n-extern void _PR_MD_JOIN_THREAD(_MDThread* md);\n-#define _PR_MD_JOIN_THREAD _MD_JOIN_THREAD\n+extern void _PR_MD_JOIN_THREAD(_MDThread *md);\n+#define    _PR_MD_JOIN_THREAD _MD_JOIN_THREAD\n \n extern void _PR_MD_END_THREAD(void);\n-#define _PR_MD_END_THREAD _MD_END_THREAD\n+#define    _PR_MD_END_THREAD _MD_END_THREAD\n \n extern void _PR_MD_YIELD(void);\n-#define _PR_MD_YIELD _MD_YIELD\n+#define    _PR_MD_YIELD _MD_YIELD\n \n-extern void _PR_MD_SET_PRIORITY(_MDThread* md, PRThreadPriority newPri);\n-#define _PR_MD_SET_PRIORITY _MD_SET_PRIORITY\n+extern void _PR_MD_SET_PRIORITY(_MDThread *md, PRThreadPriority newPri);\n+#define    _PR_MD_SET_PRIORITY _MD_SET_PRIORITY\n \n-extern void _PR_MD_SET_CURRENT_THREAD_NAME(const char* name);\n-#define _PR_MD_SET_CURRENT_THREAD_NAME _MD_SET_CURRENT_THREAD_NAME\n+extern void _PR_MD_SET_CURRENT_THREAD_NAME(const char *name);\n+#define    _PR_MD_SET_CURRENT_THREAD_NAME _MD_SET_CURRENT_THREAD_NAME\n \n-NSPR_API(void)\n-_PR_MD_SUSPENDALL(void);\n-#define _PR_MD_SUSPENDALL _MD_SUSPENDALL\n+NSPR_API(void) _PR_MD_SUSPENDALL(void);\n+#define    _PR_MD_SUSPENDALL _MD_SUSPENDALL\n \n-NSPR_API(void)\n-_PR_MD_RESUMEALL(void);\n-#define _PR_MD_RESUMEALL _MD_RESUMEALL\n+NSPR_API(void) _PR_MD_RESUMEALL(void);\n+#define    _PR_MD_RESUMEALL _MD_RESUMEALL\n \n-extern void _PR_MD_INIT_CONTEXT(PRThread* thread, char* top,\n-                                void (*start)(void), PRBool* status);\n-#define _PR_MD_INIT_CONTEXT _MD_INIT_CONTEXT\n+extern void _PR_MD_INIT_CONTEXT(\n+    PRThread *thread, char *top, void (*start) (void), PRBool *status);\n+#define    _PR_MD_INIT_CONTEXT _MD_INIT_CONTEXT\n \n-extern void _PR_MD_SWITCH_CONTEXT(PRThread* thread);\n-#define _PR_MD_SWITCH_CONTEXT _MD_SWITCH_CONTEXT\n+extern void _PR_MD_SWITCH_CONTEXT(PRThread *thread);\n+#define    _PR_MD_SWITCH_CONTEXT _MD_SWITCH_CONTEXT\n \n-extern void _PR_MD_RESTORE_CONTEXT(PRThread* thread);\n-#define _PR_MD_RESTORE_CONTEXT _MD_RESTORE_CONTEXT\n+extern void _PR_MD_RESTORE_CONTEXT(PRThread *thread);\n+#define    _PR_MD_RESTORE_CONTEXT _MD_RESTORE_CONTEXT\n \n /* Segment related */\n extern void _PR_MD_INIT_SEGS(void);\n-#define _PR_MD_INIT_SEGS _MD_INIT_SEGS\n+#define    _PR_MD_INIT_SEGS _MD_INIT_SEGS\n \n-extern PRStatus _PR_MD_ALLOC_SEGMENT(PRSegment* seg, PRUint32 size,\n-                                     void* vaddr);\n-#define _PR_MD_ALLOC_SEGMENT _MD_ALLOC_SEGMENT\n+extern PRStatus _PR_MD_ALLOC_SEGMENT(PRSegment *seg, PRUint32 size, void *vaddr);\n+#define    _PR_MD_ALLOC_SEGMENT _MD_ALLOC_SEGMENT\n \n-extern void _PR_MD_FREE_SEGMENT(PRSegment* seg);\n-#define _PR_MD_FREE_SEGMENT _MD_FREE_SEGMENT\n+extern void _PR_MD_FREE_SEGMENT(PRSegment *seg);\n+#define    _PR_MD_FREE_SEGMENT _MD_FREE_SEGMENT\n \n /* Directory enumeration related */\n-extern PRStatus _PR_MD_OPEN_DIR(_MDDir* md, const char* name);\n-#define _PR_MD_OPEN_DIR _MD_OPEN_DIR\n+extern PRStatus _PR_MD_OPEN_DIR(_MDDir *md,const char *name);\n+#define    _PR_MD_OPEN_DIR _MD_OPEN_DIR\n \n-extern char* _PR_MD_READ_DIR(_MDDir* md, PRIntn flags);\n-#define _PR_MD_READ_DIR _MD_READ_DIR\n+extern char * _PR_MD_READ_DIR(_MDDir *md, PRIntn flags);\n+#define    _PR_MD_READ_DIR _MD_READ_DIR\n \n-extern PRInt32 _PR_MD_CLOSE_DIR(_MDDir* md);\n-#define _PR_MD_CLOSE_DIR _MD_CLOSE_DIR\n+extern PRInt32 _PR_MD_CLOSE_DIR(_MDDir *md);\n+#define    _PR_MD_CLOSE_DIR _MD_CLOSE_DIR\n \n /* Named semaphores related */\n-extern PRSem* _PR_MD_OPEN_SEMAPHORE(const char* osname, PRIntn flags,\n-                                    PRIntn mode, PRUintn value);\n-#define _PR_MD_OPEN_SEMAPHORE _MD_OPEN_SEMAPHORE\n+extern PRSem * _PR_MD_OPEN_SEMAPHORE(\n+    const char *osname, PRIntn flags, PRIntn mode, PRUintn value);\n+#define    _PR_MD_OPEN_SEMAPHORE _MD_OPEN_SEMAPHORE\n \n-extern PRStatus _PR_MD_WAIT_SEMAPHORE(PRSem* sem);\n-#define _PR_MD_WAIT_SEMAPHORE _MD_WAIT_SEMAPHORE\n+extern PRStatus _PR_MD_WAIT_SEMAPHORE(PRSem *sem);\n+#define    _PR_MD_WAIT_SEMAPHORE _MD_WAIT_SEMAPHORE\n \n-extern PRStatus _PR_MD_POST_SEMAPHORE(PRSem* sem);\n-#define _PR_MD_POST_SEMAPHORE _MD_POST_SEMAPHORE\n+extern PRStatus _PR_MD_POST_SEMAPHORE(PRSem *sem);\n+#define    _PR_MD_POST_SEMAPHORE _MD_POST_SEMAPHORE\n \n-extern PRStatus _PR_MD_CLOSE_SEMAPHORE(PRSem* sem);\n-#define _PR_MD_CLOSE_SEMAPHORE _MD_CLOSE_SEMAPHORE\n+extern PRStatus _PR_MD_CLOSE_SEMAPHORE(PRSem *sem);\n+#define    _PR_MD_CLOSE_SEMAPHORE _MD_CLOSE_SEMAPHORE\n \n-extern PRStatus _PR_MD_DELETE_SEMAPHORE(const char* osname);\n-#define _PR_MD_DELETE_SEMAPHORE _MD_DELETE_SEMAPHORE\n+extern PRStatus _PR_MD_DELETE_SEMAPHORE(const char *osname);\n+#define    _PR_MD_DELETE_SEMAPHORE _MD_DELETE_SEMAPHORE\n \n /* I/O related */\n-extern void _PR_MD_INIT_FILEDESC(PRFileDesc* fd);\n-#define _PR_MD_INIT_FILEDESC _MD_INIT_FILEDESC\n+extern void _PR_MD_INIT_FILEDESC(PRFileDesc *fd);\n+#define    _PR_MD_INIT_FILEDESC _MD_INIT_FILEDESC\n \n-extern void _PR_MD_MAKE_NONBLOCK(PRFileDesc* fd);\n-#define _PR_MD_MAKE_NONBLOCK _MD_MAKE_NONBLOCK\n+extern void _PR_MD_MAKE_NONBLOCK(PRFileDesc *fd);\n+#define    _PR_MD_MAKE_NONBLOCK _MD_MAKE_NONBLOCK\n \n /* File I/O related */\n-extern PROsfd _PR_MD_OPEN(const char* name, PRIntn osflags, PRIntn mode);\n-#define _PR_MD_OPEN _MD_OPEN\n+extern PROsfd _PR_MD_OPEN(const char *name, PRIntn osflags, PRIntn mode);\n+#define    _PR_MD_OPEN _MD_OPEN\n \n-extern PROsfd _PR_MD_OPEN_FILE(const char* name, PRIntn osflags, PRIntn mode);\n-#define _PR_MD_OPEN_FILE _MD_OPEN_FILE\n+extern PROsfd _PR_MD_OPEN_FILE(const char *name, PRIntn osflags, PRIntn mode);\n+#define    _PR_MD_OPEN_FILE _MD_OPEN_FILE\n \n extern PRInt32 _PR_MD_CLOSE_FILE(PROsfd osfd);\n-#define _PR_MD_CLOSE_FILE _MD_CLOSE_FILE\n+#define    _PR_MD_CLOSE_FILE _MD_CLOSE_FILE\n \n-extern PRInt32 _PR_MD_READ(PRFileDesc* fd, void* buf, PRInt32 amount);\n-#define _PR_MD_READ _MD_READ\n+extern PRInt32 _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 amount);\n+#define    _PR_MD_READ _MD_READ\n \n-extern PRInt32 _PR_MD_WRITE(PRFileDesc* fd, const void* buf, PRInt32 amount);\n-#define _PR_MD_WRITE _MD_WRITE\n+extern PRInt32 _PR_MD_WRITE(PRFileDesc *fd, const void *buf, PRInt32 amount);\n+#define    _PR_MD_WRITE _MD_WRITE\n \n-extern PRInt32 _PR_MD_WRITEV(PRFileDesc* fd, const struct PRIOVec* iov,\n-                             PRInt32 iov_size, PRIntervalTime timeout);\n-#define _PR_MD_WRITEV _MD_WRITEV\n+extern PRInt32 _PR_MD_WRITEV(\n+    PRFileDesc *fd, const struct PRIOVec *iov,\n+    PRInt32 iov_size, PRIntervalTime timeout);\n+#define    _PR_MD_WRITEV _MD_WRITEV\n \n-extern PRInt32 _PR_MD_FSYNC(PRFileDesc* fd);\n-#define _PR_MD_FSYNC _MD_FSYNC\n+extern PRInt32 _PR_MD_FSYNC(PRFileDesc *fd);\n+#define    _PR_MD_FSYNC _MD_FSYNC\n \n-extern PRInt32 _PR_MD_DELETE(const char* name);\n-#define _PR_MD_DELETE _MD_DELETE\n+extern PRInt32 _PR_MD_DELETE(const char *name);\n+#define        _PR_MD_DELETE _MD_DELETE\n \n-extern PRInt32 _PR_MD_RENAME(const char* from, const char* to);\n+extern PRInt32 _PR_MD_RENAME(const char *from, const char *to);\n #define _PR_MD_RENAME _MD_RENAME\n \n-extern PRInt32 _PR_MD_ACCESS(const char* name, PRAccessHow how);\n+extern PRInt32 _PR_MD_ACCESS(const char *name, PRAccessHow how);\n #define _PR_MD_ACCESS _MD_ACCESS\n \n-extern PRInt32 _PR_MD_STAT(const char* name, struct stat* buf);\n+extern PRInt32 _PR_MD_STAT(const char *name, struct stat *buf);\n #define _PR_MD_STAT _MD_STAT\n \n-extern PRInt32 _PR_MD_MKDIR(const char* name, PRIntn mode);\n+extern PRInt32 _PR_MD_MKDIR(const char *name, PRIntn mode);\n #define _PR_MD_MKDIR _MD_MKDIR\n \n-extern PRInt32 _PR_MD_MAKE_DIR(const char* name, PRIntn mode);\n+extern PRInt32 _PR_MD_MAKE_DIR(const char *name, PRIntn mode);\n #define _PR_MD_MAKE_DIR _MD_MAKE_DIR\n \n-extern PRInt32 _PR_MD_RMDIR(const char* name);\n+extern PRInt32 _PR_MD_RMDIR(const char *name);\n #define _PR_MD_RMDIR _MD_RMDIR\n \n #ifdef MOZ_UNICODE\n /* UTF16 File I/O related */\n-extern PRStatus _PR_MD_OPEN_DIR_UTF16(_MDDirUTF16* md, const PRUnichar* name);\n-#define _PR_MD_OPEN_DIR_UTF16 _MD_OPEN_DIR_UTF16\n+extern PRStatus _PR_MD_OPEN_DIR_UTF16(_MDDirUTF16 *md, const PRUnichar *name);\n+#define    _PR_MD_OPEN_DIR_UTF16 _MD_OPEN_DIR_UTF16\n \n-extern PROsfd _PR_MD_OPEN_FILE_UTF16(const PRUnichar* name, PRIntn osflags,\n-                                     PRIntn mode);\n-#define _PR_MD_OPEN_FILE_UTF16 _MD_OPEN_FILE_UTF16\n+extern PROsfd _PR_MD_OPEN_FILE_UTF16(const PRUnichar *name, PRIntn osflags, PRIntn mode);\n+#define    _PR_MD_OPEN_FILE_UTF16 _MD_OPEN_FILE_UTF16\n \n-extern PRUnichar* _PR_MD_READ_DIR_UTF16(_MDDirUTF16* md, PRIntn flags);\n-#define _PR_MD_READ_DIR_UTF16 _MD_READ_DIR_UTF16\n+extern PRUnichar * _PR_MD_READ_DIR_UTF16(_MDDirUTF16 *md, PRIntn flags);\n+#define    _PR_MD_READ_DIR_UTF16 _MD_READ_DIR_UTF16\n \n-extern PRInt32 _PR_MD_CLOSE_DIR_UTF16(_MDDirUTF16* md);\n-#define _PR_MD_CLOSE_DIR_UTF16 _MD_CLOSE_DIR_UTF16\n+extern PRInt32 _PR_MD_CLOSE_DIR_UTF16(_MDDirUTF16 *md);\n+#define    _PR_MD_CLOSE_DIR_UTF16 _MD_CLOSE_DIR_UTF16\n \n-extern PRInt32 _PR_MD_GETFILEINFO64_UTF16(const PRUnichar* fn,\n-                                          PRFileInfo64* info);\n+extern PRInt32 _PR_MD_GETFILEINFO64_UTF16(const PRUnichar *fn, PRFileInfo64 *info);\n #define _PR_MD_GETFILEINFO64_UTF16 _MD_GETFILEINFO64_UTF16\n #endif /* MOZ_UNICODE */\n \n /* Socket I/O related */\n extern void _PR_MD_INIT_IO(void);\n-#define _PR_MD_INIT_IO _MD_INIT_IO\n+#define    _PR_MD_INIT_IO _MD_INIT_IO\n \n extern PRInt32 _PR_MD_CLOSE_SOCKET(PROsfd osfd);\n-#define _PR_MD_CLOSE_SOCKET _MD_CLOSE_SOCKET\n+#define    _PR_MD_CLOSE_SOCKET _MD_CLOSE_SOCKET\n \n-extern PRInt32 _PR_MD_CONNECT(PRFileDesc* fd, const PRNetAddr* addr,\n-                              PRUint32 addrlen, PRIntervalTime timeout);\n-#define _PR_MD_CONNECT _MD_CONNECT\n+extern PRInt32 _PR_MD_CONNECT(\n+    PRFileDesc *fd, const PRNetAddr *addr,\n+    PRUint32 addrlen, PRIntervalTime timeout);\n+#define    _PR_MD_CONNECT _MD_CONNECT\n \n-extern PROsfd _PR_MD_ACCEPT(PRFileDesc* fd, PRNetAddr* addr, PRUint32* addrlen,\n-                            PRIntervalTime timeout);\n-#define _PR_MD_ACCEPT _MD_ACCEPT\n+extern PROsfd _PR_MD_ACCEPT(\n+    PRFileDesc *fd, PRNetAddr *addr,\n+    PRUint32 *addrlen, PRIntervalTime timeout);\n+#define    _PR_MD_ACCEPT _MD_ACCEPT\n \n-extern PRInt32 _PR_MD_BIND(PRFileDesc* fd, const PRNetAddr* addr,\n-                           PRUint32 addrlen);\n-#define _PR_MD_BIND _MD_BIND\n+extern PRInt32 _PR_MD_BIND(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen);\n+#define    _PR_MD_BIND _MD_BIND\n \n-extern PRInt32 _PR_MD_LISTEN(PRFileDesc* fd, PRIntn backlog);\n-#define _PR_MD_LISTEN _MD_LISTEN\n+extern PRInt32 _PR_MD_LISTEN(PRFileDesc *fd, PRIntn backlog);\n+#define    _PR_MD_LISTEN _MD_LISTEN\n \n-extern PRInt32 _PR_MD_SHUTDOWN(PRFileDesc* fd, PRIntn how);\n-#define _PR_MD_SHUTDOWN _MD_SHUTDOWN\n+extern PRInt32 _PR_MD_SHUTDOWN(PRFileDesc *fd, PRIntn how);\n+#define    _PR_MD_SHUTDOWN _MD_SHUTDOWN\n \n-extern PRInt32 _PR_MD_RECV(PRFileDesc* fd, void* buf, PRInt32 amount,\n+extern PRInt32 _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount,\n                            PRIntn flags, PRIntervalTime timeout);\n-#define _PR_MD_RECV _MD_RECV\n+#define    _PR_MD_RECV _MD_RECV\n \n-extern PRInt32 _PR_MD_SEND(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-                           PRIntn flags, PRIntervalTime timeout);\n-#define _PR_MD_SEND _MD_SEND\n+extern PRInt32 _PR_MD_SEND(\n+    PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,\n+    PRIntervalTime timeout);\n+#define    _PR_MD_SEND _MD_SEND\n \n-extern PRInt32 _PR_MD_ACCEPT_READ(PRFileDesc* sd, PROsfd* newSock,\n-                                  PRNetAddr** raddr, void* buf, PRInt32 amount,\n+extern PRInt32 _PR_MD_ACCEPT_READ(PRFileDesc *sd, PROsfd *newSock,\n+                                  PRNetAddr **raddr, void *buf, PRInt32 amount,\n                                   PRIntervalTime timeout);\n #define _PR_MD_ACCEPT_READ _MD_ACCEPT_READ\n \n #ifdef WIN32\n-extern PROsfd _PR_MD_FAST_ACCEPT(PRFileDesc* fd, PRNetAddr* addr,\n-                                 PRUint32* addrlen, PRIntervalTime timeout,\n+extern PROsfd _PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *addr,\n+                                 PRUint32 *addrlen, PRIntervalTime timeout,\n                                  PRBool fast,\n                                  _PR_AcceptTimeoutCallback callback,\n-                                 void* callbackArg);\n+                                 void *callbackArg);\n \n-extern PRInt32 _PR_MD_FAST_ACCEPT_READ(PRFileDesc* sd, PROsfd* newSock,\n-                                       PRNetAddr** raddr, void* buf,\n-                                       PRInt32 amount, PRIntervalTime timeout,\n-                                       PRBool fast,\n+extern PRInt32 _PR_MD_FAST_ACCEPT_READ(PRFileDesc *sd, PROsfd *newSock,\n+                                       PRNetAddr **raddr, void *buf, PRInt32 amount,\n+                                       PRIntervalTime timeout, PRBool fast,\n                                        _PR_AcceptTimeoutCallback callback,\n-                                       void* callbackArg);\n+                                       void *callbackArg);\n \n extern void _PR_MD_UPDATE_ACCEPT_CONTEXT(PROsfd s, PROsfd ls);\n #define _PR_MD_UPDATE_ACCEPT_CONTEXT _MD_UPDATE_ACCEPT_CONTEXT\n@@ -1197,66 +1171,66 @@ extern void _PR_MD_UPDATE_ACCEPT_CONTEXT(PROsfd s, PROsfd ls);\n extern const PRTime _pr_filetime_offset;\n #endif /* WIN32 */\n \n-extern PRInt32 _PR_MD_SENDFILE(PRFileDesc* sock, PRSendFileData* sfd,\n-                               PRInt32 flags, PRIntervalTime timeout);\n+extern PRInt32 _PR_MD_SENDFILE(\n+    PRFileDesc *sock, PRSendFileData *sfd,\n+    PRInt32 flags, PRIntervalTime timeout);\n #define _PR_MD_SENDFILE _MD_SENDFILE\n \n-extern PRStatus _PR_MD_GETSOCKNAME(PRFileDesc* fd, PRNetAddr* addr,\n-                                   PRUint32* addrlen);\n-#define _PR_MD_GETSOCKNAME _MD_GETSOCKNAME\n+extern PRStatus _PR_MD_GETSOCKNAME(\n+    PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen);\n+#define    _PR_MD_GETSOCKNAME _MD_GETSOCKNAME\n \n-extern PRStatus _PR_MD_GETPEERNAME(PRFileDesc* fd, PRNetAddr* addr,\n-                                   PRUint32* addrlen);\n-#define _PR_MD_GETPEERNAME _MD_GETPEERNAME\n+extern PRStatus _PR_MD_GETPEERNAME(\n+    PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen);\n+#define    _PR_MD_GETPEERNAME _MD_GETPEERNAME\n \n-extern PRStatus _PR_MD_GETSOCKOPT(PRFileDesc* fd, PRInt32 level,\n-                                  PRInt32 optname, char* optval,\n-                                  PRInt32* optlen);\n-#define _PR_MD_GETSOCKOPT _MD_GETSOCKOPT\n+extern PRStatus _PR_MD_GETSOCKOPT(\n+    PRFileDesc *fd, PRInt32 level, PRInt32 optname, char* optval, PRInt32* optlen);\n+#define    _PR_MD_GETSOCKOPT _MD_GETSOCKOPT\n \n-extern PRStatus _PR_MD_SETSOCKOPT(PRFileDesc* fd, PRInt32 level,\n-                                  PRInt32 optname, const char* optval,\n-                                  PRInt32 optlen);\n-#define _PR_MD_SETSOCKOPT _MD_SETSOCKOPT\n+extern PRStatus _PR_MD_SETSOCKOPT(\n+    PRFileDesc *fd, PRInt32 level, PRInt32 optname,\n+    const char* optval, PRInt32 optlen);\n+#define    _PR_MD_SETSOCKOPT _MD_SETSOCKOPT\n \n-extern PRStatus PR_CALLBACK _PR_SocketGetSocketOption(PRFileDesc* fd,\n-                                                      PRSocketOptionData* data);\n+extern PRStatus PR_CALLBACK _PR_SocketGetSocketOption(\n+    PRFileDesc *fd, PRSocketOptionData *data);\n \n-extern PRStatus PR_CALLBACK\n-_PR_SocketSetSocketOption(PRFileDesc* fd, const PRSocketOptionData* data);\n+extern PRStatus PR_CALLBACK _PR_SocketSetSocketOption(\n+    PRFileDesc *fd, const PRSocketOptionData *data);\n \n-extern PRInt32 _PR_MD_RECVFROM(PRFileDesc* fd, void* buf, PRInt32 amount,\n-                               PRIntn flags, PRNetAddr* addr, PRUint32* addrlen,\n-                               PRIntervalTime timeout);\n-#define _PR_MD_RECVFROM _MD_RECVFROM\n+extern PRInt32 _PR_MD_RECVFROM(\n+    PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,\n+    PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout);\n+#define    _PR_MD_RECVFROM _MD_RECVFROM\n \n-extern PRInt32 _PR_MD_SENDTO(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-                             PRIntn flags, const PRNetAddr* addr,\n-                             PRUint32 addrlen, PRIntervalTime timeout);\n-#define _PR_MD_SENDTO _MD_SENDTO\n+extern PRInt32 _PR_MD_SENDTO(\n+    PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,\n+    const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout);\n+#define    _PR_MD_SENDTO _MD_SENDTO\n \n #if defined(_WIN64) && defined(WIN95)\n-extern PRInt32 _PR_MD_TCPSENDTO(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-                                PRIntn flags, const PRNetAddr* addr,\n-                                PRUint32 addrlen, PRIntervalTime timeout);\n-#define _PR_MD_TCPSENDTO _MD_TCPSENDTO\n+extern PRInt32 _PR_MD_TCPSENDTO(\n+    PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,\n+    const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout);\n+#define    _PR_MD_TCPSENDTO _MD_TCPSENDTO\n #endif\n \n-extern PRInt32 _PR_MD_SOCKETPAIR(int af, int type, int flags, PROsfd* osfd);\n-#define _PR_MD_SOCKETPAIR _MD_SOCKETPAIR\n+extern PRInt32 _PR_MD_SOCKETPAIR(int af, int type, int flags, PROsfd *osfd);\n+#define    _PR_MD_SOCKETPAIR _MD_SOCKETPAIR\n \n extern PROsfd _PR_MD_SOCKET(int af, int type, int flags);\n-#define _PR_MD_SOCKET _MD_SOCKET\n+#define    _PR_MD_SOCKET _MD_SOCKET\n \n-extern PRInt32 _PR_MD_SOCKETAVAILABLE(PRFileDesc* fd);\n-#define _PR_MD_SOCKETAVAILABLE _MD_SOCKETAVAILABLE\n+extern PRInt32 _PR_MD_SOCKETAVAILABLE(PRFileDesc *fd);\n+#define    _PR_MD_SOCKETAVAILABLE _MD_SOCKETAVAILABLE\n \n-extern PRInt32 _PR_MD_PIPEAVAILABLE(PRFileDesc* fd);\n-#define _PR_MD_PIPEAVAILABLE _MD_PIPEAVAILABLE\n+extern PRInt32 _PR_MD_PIPEAVAILABLE(PRFileDesc *fd);\n+#define    _PR_MD_PIPEAVAILABLE _MD_PIPEAVAILABLE\n \n-extern PRInt32 _PR_MD_PR_POLL(PRPollDesc* pds, PRIntn npds,\n+extern PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds,\n                               PRIntervalTime timeout);\n-#define _PR_MD_PR_POLL _MD_PR_POLL\n+#define    _PR_MD_PR_POLL _MD_PR_POLL\n \n /*\n  * Initialize fd->secret->inheritable for a newly created fd.\n@@ -1270,22 +1244,23 @@ extern PRInt32 _PR_MD_PR_POLL(PRPollDesc* pds, PRIntn npds,\n  * _PR_TRI_UNKNOWN and only pay the cost of the system call\n  * (in _PR_MD_QUERY_FD_INHERITABLE) when necessary.\n  */\n-extern void _PR_MD_INIT_FD_INHERITABLE(PRFileDesc* fd, PRBool imported);\n-#define _PR_MD_INIT_FD_INHERITABLE _MD_INIT_FD_INHERITABLE\n+extern void _PR_MD_INIT_FD_INHERITABLE(PRFileDesc *fd, PRBool imported);\n+#define    _PR_MD_INIT_FD_INHERITABLE _MD_INIT_FD_INHERITABLE\n+\n+extern PRStatus _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable);\n+#define    _PR_MD_SET_FD_INHERITABLE _MD_SET_FD_INHERITABLE\n \n-extern PRStatus _PR_MD_SET_FD_INHERITABLE(PRFileDesc* fd, PRBool inheritable);\n-#define _PR_MD_SET_FD_INHERITABLE _MD_SET_FD_INHERITABLE\n \n-#define _PR_PROCESS_TIMEOUT_INTERRUPT_ERRORS(me)    \\\n-    if (_PR_PENDING_INTERRUPT(me)) {                \\\n-        me->flags &= ~_PR_INTERRUPT;                \\\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0); \\\n-    } else {                                        \\\n-        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);        \\\n-    }\n+#define _PR_PROCESS_TIMEOUT_INTERRUPT_ERRORS(me) \\\n+        if (_PR_PENDING_INTERRUPT(me)) { \\\n+                me->flags &= ~_PR_INTERRUPT; \\\n+                PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0); \\\n+        } else { \\\n+                PR_SetError(PR_IO_TIMEOUT_ERROR, 0); \\\n+        }\n \n-extern void* _PR_MD_GET_SP(PRThread* thread);\n-#define _PR_MD_GET_SP _MD_GET_SP\n+extern void *_PR_MD_GET_SP(PRThread *thread);\n+#define    _PR_MD_GET_SP _MD_GET_SP\n \n #endif /* defined(_PR_PTHREADS) */\n \n@@ -1296,34 +1271,32 @@ extern void* _PR_MD_GET_SP(PRThread* thread);\n *************************************************************************/\n /************************************************************************/\n \n-extern PROffset32 _PR_MD_LSEEK(PRFileDesc* fd, PROffset32 offset,\n-                               PRSeekWhence whence);\n-#define _PR_MD_LSEEK _MD_LSEEK\n+extern PROffset32 _PR_MD_LSEEK(PRFileDesc *fd, PROffset32 offset, PRSeekWhence whence);\n+#define    _PR_MD_LSEEK _MD_LSEEK\n \n-extern PROffset64 _PR_MD_LSEEK64(PRFileDesc* fd, PROffset64 offset,\n-                                 PRSeekWhence whence);\n-#define _PR_MD_LSEEK64 _MD_LSEEK64\n+extern PROffset64 _PR_MD_LSEEK64(PRFileDesc *fd, PROffset64 offset, PRSeekWhence whence);\n+#define    _PR_MD_LSEEK64 _MD_LSEEK64\n \n-extern PRInt32 _PR_MD_GETFILEINFO(const char* fn, PRFileInfo* info);\n+extern PRInt32 _PR_MD_GETFILEINFO(const char *fn, PRFileInfo *info);\n #define _PR_MD_GETFILEINFO _MD_GETFILEINFO\n \n-extern PRInt32 _PR_MD_GETFILEINFO64(const char* fn, PRFileInfo64* info);\n+extern PRInt32 _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info);\n #define _PR_MD_GETFILEINFO64 _MD_GETFILEINFO64\n \n-extern PRInt32 _PR_MD_GETOPENFILEINFO(const PRFileDesc* fd, PRFileInfo* info);\n+extern PRInt32 _PR_MD_GETOPENFILEINFO(const PRFileDesc *fd, PRFileInfo *info);\n #define _PR_MD_GETOPENFILEINFO _MD_GETOPENFILEINFO\n \n-extern PRInt32 _PR_MD_GETOPENFILEINFO64(const PRFileDesc* fd,\n-                                        PRFileInfo64* info);\n+extern PRInt32 _PR_MD_GETOPENFILEINFO64(const PRFileDesc *fd, PRFileInfo64 *info);\n #define _PR_MD_GETOPENFILEINFO64 _MD_GETOPENFILEINFO64\n \n+\n /*****************************************************************************/\n /************************** File descriptor caching **************************/\n /*****************************************************************************/\n extern void _PR_InitFdCache(void);\n extern void _PR_CleanupFdCache(void);\n-extern PRFileDesc* _PR_Getfd(void);\n-extern void _PR_Putfd(PRFileDesc* fd);\n+extern PRFileDesc *_PR_Getfd(void);\n+extern void _PR_Putfd(PRFileDesc *fd);\n \n /*\n  * These flags are used by NSPR temporarily in the poll\n@@ -1337,10 +1310,10 @@ extern void _PR_Putfd(PRFileDesc* fd);\n  * assumed that the PR_POLL_EXCEPT flag doesn't get mapped\n  * to other flags.\n  */\n-#define _PR_POLL_READ_SYS_READ 0x1\n-#define _PR_POLL_READ_SYS_WRITE 0x2\n-#define _PR_POLL_WRITE_SYS_READ 0x4\n-#define _PR_POLL_WRITE_SYS_WRITE 0x8\n+#define _PR_POLL_READ_SYS_READ     0x1\n+#define _PR_POLL_READ_SYS_WRITE    0x2\n+#define _PR_POLL_WRITE_SYS_READ    0x4\n+#define _PR_POLL_WRITE_SYS_WRITE   0x8\n \n /*\n ** These methods are coerced into file descriptor methods table\n@@ -1351,7 +1324,7 @@ extern PRIntn _PR_InvalidInt(void);\n extern PRInt16 _PR_InvalidInt16(void);\n extern PRInt64 _PR_InvalidInt64(void);\n extern PRStatus _PR_InvalidStatus(void);\n-extern PRFileDesc* _PR_InvalidDesc(void);\n+extern PRFileDesc *_PR_InvalidDesc(void);\n \n extern PRIOMethods _pr_faulty_methods;\n \n@@ -1387,52 +1360,55 @@ extern PRUintn _PR_NetAddrSize(const PRNetAddr* addr);\n */\n \n #if defined(XP_UNIX)\n-#define PR_NETADDR_SIZE(_addr)                    \\\n-    ((_addr)->raw.family == PR_AF_INET            \\\n-         ? sizeof((_addr)->inet)                  \\\n-         : ((_addr)->raw.family == PR_AF_INET6    \\\n-                ? sizeof(struct _md_sockaddr_in6) \\\n-                : sizeof((_addr)->local)))\n+#define PR_NETADDR_SIZE(_addr)                  \\\n+        ((_addr)->raw.family == PR_AF_INET      \\\n+        ? sizeof((_addr)->inet)                 \\\n+        : ((_addr)->raw.family == PR_AF_INET6   \\\n+        ? sizeof(struct _md_sockaddr_in6)       \\\n+        : sizeof((_addr)->local)))\n #else\n-#define PR_NETADDR_SIZE(_addr)                                 \\\n-    ((_addr)->raw.family == PR_AF_INET ? sizeof((_addr)->inet) \\\n-                                       : sizeof(struct _md_sockaddr_in6))\n+#define PR_NETADDR_SIZE(_addr)                  \\\n+        ((_addr)->raw.family == PR_AF_INET      \\\n+        ? sizeof((_addr)->inet)                 \\\n+        : sizeof(struct _md_sockaddr_in6))\n #endif /* defined(XP_UNIX) */\n \n #else\n \n #if defined(XP_UNIX)\n-#define PR_NETADDR_SIZE(_addr)                                         \\\n-    ((_addr)->raw.family == PR_AF_INET                                 \\\n-         ? sizeof((_addr)->inet)                                       \\\n-         : ((_addr)->raw.family == PR_AF_INET6 ? sizeof((_addr)->ipv6) \\\n-                                               : sizeof((_addr)->local)))\n+#define PR_NETADDR_SIZE(_addr)                  \\\n+        ((_addr)->raw.family == PR_AF_INET      \\\n+        ? sizeof((_addr)->inet)                 \\\n+        : ((_addr)->raw.family == PR_AF_INET6   \\\n+        ? sizeof((_addr)->ipv6)                 \\\n+        : sizeof((_addr)->local)))\n #else\n-#define PR_NETADDR_SIZE(_addr)                                 \\\n-    ((_addr)->raw.family == PR_AF_INET ? sizeof((_addr)->inet) \\\n-                                       : sizeof((_addr)->ipv6))\n+#define PR_NETADDR_SIZE(_addr)                  \\\n+        ((_addr)->raw.family == PR_AF_INET      \\\n+        ? sizeof((_addr)->inet)                 \\\n+        : sizeof((_addr)->ipv6))\n #endif /* defined(XP_UNIX) */\n \n #endif /* defined(_PR_INET6) */\n \n-extern PRStatus _PR_MapOptionName(PRSockOption optname, PRInt32* level,\n-                                  PRInt32* name);\n-extern void _PR_InitThreads(PRThreadType type, PRThreadPriority priority,\n-                            PRUintn maxPTDs);\n+extern PRStatus _PR_MapOptionName(\n+    PRSockOption optname, PRInt32 *level, PRInt32 *name);\n+extern void _PR_InitThreads(\n+    PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs);\n \n struct PRLock {\n #if defined(_PR_PTHREADS)\n-    pthread_mutex_t mutex; /* the underlying lock */\n-    _PT_Notified notified; /* array of conditions notified */\n-    PRBool locked;         /* whether the mutex is locked */\n-    pthread_t owner;       /* if locked, current lock owner */\n+    pthread_mutex_t mutex;          /* the underlying lock */\n+    _PT_Notified notified;          /* array of conditions notified */\n+    PRBool locked;                  /* whether the mutex is locked */\n+    pthread_t owner;                /* if locked, current lock owner */\n #elif defined(_PR_BTHREADS)\n-    sem_id semaphoreID;   /* the underlying lock */\n-    int32 benaphoreCount; /* number of people in lock */\n-    thread_id owner;      /* current lock owner */\n+    sem_id  semaphoreID;        /* the underlying lock */\n+    int32   benaphoreCount;     /* number of people in lock */\n+    thread_id   owner;          /* current lock owner */\n #else /* not pthreads or Be threads */\n     PRCList links;                  /* linkage for PRThread.lockList */\n-    struct PRThread* owner;         /* current lock owner */\n+    struct PRThread *owner;         /* current lock owner */\n     PRCList waitQ;                  /* list of threads waiting for lock */\n     PRThreadPriority priority;      /* priority of lock */\n     PRThreadPriority boostPriority; /* boosted priority of lock owner */\n@@ -1441,21 +1417,20 @@ struct PRLock {\n };\n \n struct PRCondVar {\n-    PRLock* lock; /* associated lock that protects the condition */\n+    PRLock *lock;               /* associated lock that protects the condition */\n #if defined(_PR_PTHREADS)\n-    pthread_cond_t cv;      /* underlying pthreads condition */\n-    PRInt32 notify_pending; /* CV has destroy pending notification */\n+    pthread_cond_t cv;          /* underlying pthreads condition */\n+    PRInt32 notify_pending;     /* CV has destroy pending notification */\n #elif defined(_PR_BTHREADS)\n-    sem_id sem; /* the underlying lock */\n-    sem_id\n-        handshakeSem;    /* the lock for 'notify'-threads waiting for confirmation */\n-    sem_id signalSem;    /* the lock for threads waiting for someone to notify */\n-    volatile int32 nw;   /* the number waiting */\n-    volatile int32 ns;   /* the number signalling */\n-    long signalBenCount; /* the number waiting on the underlying sem */\n+    sem_id    sem;              /* the underlying lock */\n+    sem_id    handshakeSem;     /* the lock for 'notify'-threads waiting for confirmation */\n+    sem_id    signalSem;        /* the lock for threads waiting for someone to notify */\n+    volatile int32    nw;       /* the number waiting */\n+    volatile int32    ns;       /* the number signalling */\n+    long signalBenCount;        /* the number waiting on the underlying sem */\n #else /* not pthreads or Be threads */\n-    PRCList condQ; /* Condition variable wait Q */\n-    _MDLock ilock; /* Internal Lock to protect condQ */\n+    PRCList condQ;              /* Condition variable wait Q */\n+    _MDLock ilock;              /* Internal Lock to protect condQ */\n     _MDCVar md;\n #endif\n };\n@@ -1463,52 +1438,52 @@ struct PRCondVar {\n /************************************************************************/\n \n struct PRMonitor {\n-    const char* name; /* monitor name for debugging */\n+    const char* name;           /* monitor name for debugging */\n #if defined(_PR_PTHREADS)\n-    pthread_mutex_t lock;   /* lock is only held when accessing fields\n-                             * of the PRMonitor, instead of being held\n-                             * while the monitor is entered. The only\n-                             * exception is notifyTimes, which is\n-                             * protected by the monitor. */\n-    pthread_t owner;        /* the owner of the monitor or invalid */\n-    pthread_cond_t entryCV; /* for threads waiting to enter the monitor */\n-\n-    pthread_cond_t waitCV; /* for threads waiting on the monitor */\n-    PRInt32 refCount;      /* reference count, an atomic variable.\n-                            * PR_NewMonitor adds a reference to the\n-                            * newly created PRMonitor, and\n-                            * PR_DestroyMonitor releases that reference.\n-                            * PR_ExitMonitor adds a reference before\n-                            * unlocking the internal lock if it needs to\n-                            * signal entryCV, and releases the reference\n-                            * after signaling entryCV. */\n-#else                      /* defined(_PR_PTHREADS) */\n-    PRLock lock;       /* lock is only held when accessing fields\n-                        * of the PRMonitor, instead of being held\n-                        * while the monitor is entered. The only\n-                        * exception is notifyTimes, which is\n-                        * protected by the monitor. */\n-    PRThread* owner;   /* the owner of the monitor or invalid */\n-    PRCondVar entryCV; /* for threads waiting to enter the monitor */\n-\n-    PRCondVar waitCV; /* for threads waiting on the monitor */\n-#endif                     /* defined(_PR_PTHREADS) */\n-    PRUint32 entryCount;   /* # of times re-entered */\n-    PRIntn notifyTimes;    /* number of pending notifies for waitCV.\n-                            * The special value -1 means a broadcast\n-                            * (PR_NotifyAll). */\n+    pthread_mutex_t lock;       /* lock is only held when accessing fields\n+                                 * of the PRMonitor, instead of being held\n+                                 * while the monitor is entered. The only\n+                                 * exception is notifyTimes, which is\n+                                 * protected by the monitor. */\n+    pthread_t owner;            /* the owner of the monitor or invalid */\n+    pthread_cond_t entryCV;     /* for threads waiting to enter the monitor */\n+\n+    pthread_cond_t waitCV;      /* for threads waiting on the monitor */\n+    PRInt32 refCount;           /* reference count, an atomic variable.\n+                                 * PR_NewMonitor adds a reference to the\n+                                 * newly created PRMonitor, and\n+                                 * PR_DestroyMonitor releases that reference.\n+                                 * PR_ExitMonitor adds a reference before\n+                                 * unlocking the internal lock if it needs to\n+                                 * signal entryCV, and releases the reference\n+                                 * after signaling entryCV. */\n+#else  /* defined(_PR_PTHREADS) */\n+    PRLock lock;                /* lock is only held when accessing fields\n+                                 * of the PRMonitor, instead of being held\n+                                 * while the monitor is entered. The only\n+                                 * exception is notifyTimes, which is\n+                                 * protected by the monitor. */\n+    PRThread *owner;            /* the owner of the monitor or invalid */\n+    PRCondVar entryCV;          /* for threads waiting to enter the monitor */\n+\n+    PRCondVar waitCV;           /* for threads waiting on the monitor */\n+#endif /* defined(_PR_PTHREADS) */\n+    PRUint32 entryCount;        /* # of times re-entered */\n+    PRIntn notifyTimes;         /* number of pending notifies for waitCV.\n+                                 * The special value -1 means a broadcast\n+                                 * (PR_NotifyAll). */\n };\n \n /************************************************************************/\n \n struct PRSemaphore {\n #if defined(_PR_BTHREADS)\n-    sem_id sem;\n-    int32 benaphoreCount;\n+    sem_id  sem;\n+    int32   benaphoreCount;\n #else\n-    PRCondVar* cvar;  /* associated lock and condition variable queue */\n-    PRUintn count;    /* the value of the counting semaphore */\n-    PRUint32 waiters; /* threads waiting on the semaphore */\n+    PRCondVar *cvar;        /* associated lock and condition variable queue */\n+    PRUintn count;            /* the value of the counting semaphore */\n+    PRUint32 waiters;            /* threads waiting on the semaphore */\n #if defined(_PR_PTHREADS)\n #else  /* defined(_PR_PTHREADS) */\n     _MDSemaphore md;\n@@ -1520,7 +1495,7 @@ struct PRSemaphore {\n \n struct PRSem {\n #ifdef _PR_HAVE_POSIX_SEMAPHORES\n-    sem_t* sem;\n+    sem_t *sem;\n #elif defined(_PR_HAVE_SYSV_SEMAPHORES)\n     int semid;\n #elif defined(WIN32)\n@@ -1540,8 +1515,8 @@ struct PRStackStr {\n     PRStackElem prstk_head;\n #endif\n \n-    PRLock* prstk_lock;\n-    char* prstk_name;\n+    PRLock *prstk_lock;\n+    char *prstk_name;\n };\n \n /************************************************************************/\n@@ -1551,69 +1526,69 @@ struct PRThreadStack {\n     PRCList links;\n     PRUintn flags;\n \n-    char* allocBase;    /* base of stack's allocated memory */\n-    PRUint32 allocSize; /* size of stack's allocated memory */\n-    char* stackBottom;  /* bottom of stack from C's point of view */\n-    char* stackTop;     /* top of stack from C's point of view */\n-    PRUint32 stackSize; /* size of usable portion of the stack */\n+    char *allocBase;            /* base of stack's allocated memory */\n+    PRUint32 allocSize;         /* size of stack's allocated memory */\n+    char *stackBottom;          /* bottom of stack from C's point of view */\n+    char *stackTop;             /* top of stack from C's point of view */\n+    PRUint32 stackSize;         /* size of usable portion of the stack */\n \n-    PRSegment* seg;\n-    PRThread* thr; /* back pointer to thread owning this stack */\n+    PRSegment *seg;\n+    PRThread* thr;          /* back pointer to thread owning this stack */\n \n #if defined(_PR_PTHREADS)\n-#else  /* defined(_PR_PTHREADS) */\n+#else /* defined(_PR_PTHREADS) */\n     _MDThreadStack md;\n #endif /* defined(_PR_PTHREADS) */\n };\n \n extern void _PR_DestroyThreadPrivate(PRThread*);\n \n-typedef void(PR_CALLBACK* _PRStartFn)(void*);\n+typedef void (PR_CALLBACK *_PRStartFn)(void *);\n \n struct PRThread {\n-    PRUint32 state;            /* thread's creation state */\n-    PRThreadPriority priority; /* apparent priority, loosly defined */\n+    PRUint32 state;                 /* thread's creation state */\n+    PRThreadPriority priority;      /* apparent priority, loosly defined */\n \n-    void* arg;            /* argument to the client's entry point */\n-    _PRStartFn startFunc; /* the root of the client's thread */\n+    void *arg;                      /* argument to the client's entry point */\n+    _PRStartFn startFunc;           /* the root of the client's thread */\n \n-    PRThreadStack* stack; /* info about thread's stack (for GC) */\n-    void* environment;    /* pointer to execution environment */\n+    PRThreadStack *stack;           /* info about thread's stack (for GC) */\n+    void *environment;              /* pointer to execution environment */\n \n-    PRThreadDumpProc dump; /* dump thread info out */\n-    void* dumpArg;         /* argument for the dump function */\n+    PRThreadDumpProc dump;          /* dump thread info out */\n+    void *dumpArg;                  /* argument for the dump function */\n \n     /*\n     ** Per thread private data\n     */\n-    PRUint32 tpdLength;       /* thread's current vector length */\n-    void** privateData;       /* private data vector or NULL */\n-    PRErrorCode errorCode;    /* current NSPR error code | zero */\n-    PRInt32 osErrorCode;      /* mapping of errorCode | zero */\n-    PRIntn errorStringLength; /* textLength from last call to PR_SetErrorText() */\n-    PRInt32 errorStringSize;  /* malloc()'d size of buffer | zero */\n-    char* errorString;        /* current error string | NULL */\n-    char* name;               /* thread's name */\n+    PRUint32 tpdLength;             /* thread's current vector length */\n+    void **privateData;             /* private data vector or NULL */\n+    PRErrorCode errorCode;          /* current NSPR error code | zero */\n+    PRInt32 osErrorCode;            /* mapping of errorCode | zero */\n+    PRIntn  errorStringLength;      /* textLength from last call to PR_SetErrorText() */\n+    PRInt32 errorStringSize;        /* malloc()'d size of buffer | zero */\n+    char *errorString;              /* current error string | NULL */\n+    char *name;                     /* thread's name */\n \n #if defined(_PR_PTHREADS)\n-    pthread_t id; /* pthread identifier for the thread */\n-    PRBool idSet; /* whether 'id' has been set. Protected by\n-                   * pt_book.ml. */\n+    pthread_t id;                   /* pthread identifier for the thread */\n+    PRBool idSet;                   /* whether 'id' has been set. Protected by\n+                                     * pt_book.ml. */\n #ifdef _PR_NICE_PRIORITY_SCHEDULING\n-    pid_t tid; /* Linux-specific kernel thread ID */\n+    pid_t tid;                      /* Linux-specific kernel thread ID */\n #endif\n-    PRBool okToDelete;     /* ok to delete the PRThread struct? */\n-    PRCondVar* waiting;    /* where the thread is waiting | NULL */\n-    void* sp;              /* recorded sp for garbage collection */\n-    PRThread *next, *prev; /* simple linked list of all threads */\n-    PRUint32 suspend;      /* used to store suspend and resume flags */\n+    PRBool okToDelete;              /* ok to delete the PRThread struct? */\n+    PRCondVar *waiting;             /* where the thread is waiting | NULL */\n+    void *sp;                       /* recorded sp for garbage collection */\n+    PRThread *next, *prev;          /* simple linked list of all threads */\n+    PRUint32 suspend;               /* used to store suspend and resume flags */\n #ifdef PT_NO_SIGTIMEDWAIT\n     pthread_mutex_t suspendResumeMutex;\n     pthread_cond_t suspendResumeCV;\n #endif\n-    PRUint32 interrupt_blocked;  /* interrupt blocked */\n-    struct pollfd* syspoll_list; /* Unix polling list used by PR_Poll */\n-    PRUint32 syspoll_count;      /* number of elements in syspoll_list */\n+    PRUint32 interrupt_blocked;     /* interrupt blocked */\n+    struct pollfd *syspoll_list;    /* Unix polling list used by PR_Poll */\n+    PRUint32 syspoll_count;         /* number of elements in syspoll_list */\n #elif defined(_PR_BTHREADS)\n     PRUint32 flags;\n     _MDThread md;\n@@ -1621,50 +1596,50 @@ struct PRThread {\n     PRInt32 io_fd;\n     PRBool io_suspended;\n #else /* not pthreads or Be threads */\n-    _MDLock threadLock; /* Lock to protect thread state variables.\n-                         * Protects the following fields:\n-                         *     state\n-                         *     priority\n-                         *     links\n-                         *     wait\n-                         *     cpu\n-                         */\n+    _MDLock threadLock;             /* Lock to protect thread state variables.\n+                                     * Protects the following fields:\n+                                     *     state\n+                                     *     priority\n+                                     *     links\n+                                     *     wait\n+                                     *     cpu\n+                                     */\n     PRUint32 queueCount;\n     PRUint32 waitCount;\n \n-    PRCList active; /* on list of all active threads        */\n+    PRCList active;                 /* on list of all active threads        */\n     PRCList links;\n-    PRCList waitQLinks;   /* when thread is PR_Wait'ing */\n-    PRCList lockList;     /* list of locks currently holding */\n-    PRIntervalTime sleep; /* sleep time when thread is sleeping */\n+    PRCList waitQLinks;             /* when thread is PR_Wait'ing */\n+    PRCList lockList;               /* list of locks currently holding */\n+    PRIntervalTime sleep;           /* sleep time when thread is sleeping */\n     struct _wait {\n-        struct PRLock* lock;\n-        struct PRCondVar* cvar;\n+        struct PRLock *lock;\n+        struct PRCondVar *cvar;\n     } wait;\n \n     PRUint32 id;\n     PRUint32 flags;\n-    PRUint32 no_sched; /* Don't schedule the thread to run.\n-                        * This flag has relevance only when\n-                        * multiple NSPR CPUs are created.\n-                        * When a thread is de-scheduled, there\n-                        * is a narrow window of time in which\n-                        * the thread is put on the run queue\n-                        * but the scheduler is actually using\n-                        * the stack of this thread.  It is safe\n-                        * to run this thread on a different CPU\n-                        * only when its stack is not in use on\n-                        * any other CPU.  The no_sched flag is\n-                        * set during this interval to prevent\n-                        * the thread from being scheduled on a\n-                        * different CPU.\n-                        */\n+    PRUint32 no_sched;              /* Don't schedule the thread to run.\n+                                     * This flag has relevance only when\n+                                     * multiple NSPR CPUs are created.\n+                                     * When a thread is de-scheduled, there\n+                                     * is a narrow window of time in which\n+                                     * the thread is put on the run queue\n+                                     * but the scheduler is actually using\n+                                     * the stack of this thread.  It is safe\n+                                     * to run this thread on a different CPU\n+                                     * only when its stack is not in use on\n+                                     * any other CPU.  The no_sched flag is\n+                                     * set during this interval to prevent\n+                                     * the thread from being scheduled on a\n+                                     * different CPU.\n+                                     */\n \n     /* thread termination condition variable for join */\n-    PRCondVar* term;\n+    PRCondVar *term;\n \n-    _PRCPU* cpu;                     /* cpu to which this thread is bound    */\n-    PRUint32 threadAllocatedOnStack; /* boolean */\n+    _PRCPU *cpu;                    /* cpu to which this thread is bound    */\n+    PRUint32 threadAllocatedOnStack;/* boolean */\n \n     /* When an async IO is in progress and a second async IO cannot be\n      * initiated, the io_pending flag is set to true.  Some platforms will\n@@ -1687,11 +1662,11 @@ struct PRThread {\n };\n \n struct PRProcessAttr {\n-    PRFileDesc* stdinFd;\n-    PRFileDesc* stdoutFd;\n-    PRFileDesc* stderrFd;\n-    char* currentDirectory;\n-    char* fdInheritBuffer;\n+    PRFileDesc *stdinFd;\n+    PRFileDesc *stdoutFd;\n+    PRFileDesc *stderrFd;\n+    char *currentDirectory;\n+    char *fdInheritBuffer;\n     PRSize fdInheritBufferSize;\n     PRSize fdInheritBufferUsed;\n };\n@@ -1701,7 +1676,7 @@ struct PRProcess {\n };\n \n struct PRFileMap {\n-    PRFileDesc* fd;\n+    PRFileDesc *fd;\n     PRFileMapProtect prot;\n     _MDFileMap md;\n };\n@@ -1720,9 +1695,9 @@ struct PRFileMap {\n **   structure is freed.\n */\n \n-#define _PR_FILEDESC_OPEN 0xaaaaaaaa   /* 1010101... */\n-#define _PR_FILEDESC_CLOSED 0x55555555 /* 0101010... */\n-#define _PR_FILEDESC_FREED 0x11111111\n+#define _PR_FILEDESC_OPEN       0xaaaaaaaa    /* 1010101... */\n+#define _PR_FILEDESC_CLOSED     0x55555555    /* 0101010... */\n+#define _PR_FILEDESC_FREED      0x11111111\n \n /*\n ** A boolean type with an additional \"unknown\" state\n@@ -1738,26 +1713,26 @@ struct PRFilePrivate {\n     PRInt32 state;\n     PRBool nonblocking;\n     _PRTriStateBool inheritable;\n-    PRFileDesc* next;\n-    PRIntn lockCount; /*   0: not locked\n-                       *  -1: a native lockfile call is in progress\n-                       * > 0: # times the file is locked */\n+    PRFileDesc *next;\n+    PRIntn lockCount;   /*   0: not locked\n+                         *  -1: a native lockfile call is in progress\n+                         * > 0: # times the file is locked */\n #ifdef _PR_HAVE_PEEK_BUFFER\n-    char* peekBuffer;\n+    char *peekBuffer;\n     PRInt32 peekBufSize;\n     PRInt32 peekBytes;\n #endif\n #if !defined(_PR_HAVE_O_APPEND)\n-    PRBool appendMode; /* Some platforms don't have O_APPEND or its\n-                        * equivalent, so they have to seek to end of\n-                        * file on write if the file was opened in\n-                        * append mode.  See Bugzilla 4090, 276330. */\n+    PRBool  appendMode; /* Some platforms don't have O_APPEND or its\n+                         * equivalent, so they have to seek to end of\n+                         * file on write if the file was opened in\n+                         * append mode.  See Bugzilla 4090, 276330. */\n #endif\n     _MDFileDesc md;\n #ifdef _PR_NEED_SECRET_AF\n-    PRUint16 af; /* If the platform's implementation of accept()\n-                  * requires knowing the address family of the\n-                  * socket, we save the address family here. */\n+    PRUint16 af;        /* If the platform's implementation of accept()\n+                         * requires knowing the address family of the\n+             * socket, we save the address family here. */\n #endif\n \n #if defined(_WIN64)\n@@ -1774,14 +1749,14 @@ struct PRFilePrivate {\n };\n \n #ifdef _WIN64\n-#define PR_PRIdOSFD \"lld\" /* for printing PROsfd */\n+#define PR_PRIdOSFD \"lld\"       /* for printing PROsfd */\n #define PR_PRIxOSFD \"llx\"\n-#define PR_SCNdOSFD \"lld\" /* for scanning PROsfd */\n+#define PR_SCNdOSFD \"lld\"       /* for scanning PROsfd */\n #define PR_SCNxOSFD \"llx\"\n #else\n-#define PR_PRIdOSFD \"ld\" /* for printing PROsfd */\n+#define PR_PRIdOSFD \"ld\"        /* for printing PROsfd */\n #define PR_PRIxOSFD \"lx\"\n-#define PR_SCNdOSFD \"ld\" /* for scanning PROsfd */\n+#define PR_SCNdOSFD \"ld\"        /* for scanning PROsfd */\n #define PR_SCNxOSFD \"lx\"\n #endif\n \n@@ -1815,7 +1790,7 @@ extern void _PR_InitDtoa(void);\n extern void _PR_InitTime(void);\n extern void _PR_InitMW(void);\n extern void _PR_InitRWLocks(void);\n-extern void _PR_CleanupThread(PRThread* thread);\n+extern void _PR_CleanupThread(PRThread *thread);\n extern void _PR_CleanupCallOnce(void);\n extern void _PR_CleanupMW(void);\n extern void _PR_CleanupTime(void);\n@@ -1838,12 +1813,12 @@ extern void _PR_InitLayerCache(void);\n \n extern PRBool _pr_initialized;\n extern void _PR_ImplicitInitialization(void);\n-extern PRBool _PR_Obsolete(const char* obsolete, const char* preferred);\n+extern PRBool _PR_Obsolete(const char *obsolete, const char *preferred);\n \n /************************************************************************/\n \n struct PRSegment {\n-    void* vaddr;\n+    void *vaddr;\n     PRUint32 size;\n     PRUintn flags;\n #if defined(_PR_PTHREADS)\n@@ -1853,26 +1828,26 @@ struct PRSegment {\n };\n \n /* PRSegment.flags */\n-#define _PR_SEG_VM 0x1\n+#define _PR_SEG_VM    0x1\n \n /************************************************************************/\n \n extern PRInt32 _pr_pageSize;\n extern PRInt32 _pr_pageShift;\n \n-extern PRLogModuleInfo* _pr_clock_lm;\n-extern PRLogModuleInfo* _pr_cmon_lm;\n-extern PRLogModuleInfo* _pr_io_lm;\n-extern PRLogModuleInfo* _pr_cvar_lm;\n-extern PRLogModuleInfo* _pr_mon_lm;\n-extern PRLogModuleInfo* _pr_linker_lm;\n-extern PRLogModuleInfo* _pr_sched_lm;\n-extern PRLogModuleInfo* _pr_thread_lm;\n-extern PRLogModuleInfo* _pr_gc_lm;\n+extern PRLogModuleInfo *_pr_clock_lm;\n+extern PRLogModuleInfo *_pr_cmon_lm;\n+extern PRLogModuleInfo *_pr_io_lm;\n+extern PRLogModuleInfo *_pr_cvar_lm;\n+extern PRLogModuleInfo *_pr_mon_lm;\n+extern PRLogModuleInfo *_pr_linker_lm;\n+extern PRLogModuleInfo *_pr_sched_lm;\n+extern PRLogModuleInfo *_pr_thread_lm;\n+extern PRLogModuleInfo *_pr_gc_lm;\n \n-extern PRFileDesc* _pr_stdin;\n-extern PRFileDesc* _pr_stdout;\n-extern PRFileDesc* _pr_stderr;\n+extern PRFileDesc *_pr_stdin;\n+extern PRFileDesc *_pr_stdout;\n+extern PRFileDesc *_pr_stderr;\n \n /* Zone allocator */\n /*\n@@ -1892,75 +1867,76 @@ extern void _PR_DestroyZones(void);\n #endif\n \n /* Overriding malloc, free, etc. */\n-#if !defined(_PR_NO_PREEMPT) && defined(XP_UNIX) && !defined(_PR_PTHREADS) && \\\n-    !defined(_PR_GLOBAL_THREADS_ONLY) && !defined(PURIFY) &&                  \\\n-    !defined(DARWIN) && !defined(QNX)\n+#if !defined(_PR_NO_PREEMPT) && defined(XP_UNIX) \\\n+        && !defined(_PR_PTHREADS) && !defined(_PR_GLOBAL_THREADS_ONLY) \\\n+        && !defined(PURIFY) \\\n+        && !defined(DARWIN) \\\n+        && !defined(QNX)\n #define _PR_OVERRIDE_MALLOC\n #endif\n \n /*************************************************************************\n- * External machine-dependent code provided by each OS.                     *\n- *                                                                  *\n- *************************************************************************/\n+* External machine-dependent code provided by each OS.                     *                                                                     *\n+*************************************************************************/\n \n /* Initialization related */\n extern void _PR_MD_EARLY_INIT(void);\n-#define _PR_MD_EARLY_INIT _MD_EARLY_INIT\n+#define    _PR_MD_EARLY_INIT _MD_EARLY_INIT\n \n extern void _PR_MD_INTERVAL_INIT(void);\n-#define _PR_MD_INTERVAL_INIT _MD_INTERVAL_INIT\n+#define    _PR_MD_INTERVAL_INIT _MD_INTERVAL_INIT\n \n-NSPR_API(void)\n-_PR_MD_FINAL_INIT(void);\n-#define _PR_MD_FINAL_INIT _MD_FINAL_INIT\n+NSPR_API(void) _PR_MD_FINAL_INIT(void);\n+#define    _PR_MD_FINAL_INIT _MD_FINAL_INIT\n \n extern void _PR_MD_EARLY_CLEANUP(void);\n-#define _PR_MD_EARLY_CLEANUP _MD_EARLY_CLEANUP\n+#define    _PR_MD_EARLY_CLEANUP _MD_EARLY_CLEANUP\n \n /* Process control */\n \n-extern PRProcess* _PR_MD_CREATE_PROCESS(const char* path, char* const* argv,\n-                                        char* const* envp,\n-                                        const PRProcessAttr* attr);\n-#define _PR_MD_CREATE_PROCESS _MD_CREATE_PROCESS\n+extern PRProcess * _PR_MD_CREATE_PROCESS(\n+    const char *path,\n+    char *const *argv,\n+    char *const *envp,\n+    const PRProcessAttr *attr);\n+#define    _PR_MD_CREATE_PROCESS _MD_CREATE_PROCESS\n \n-extern PRStatus _PR_MD_DETACH_PROCESS(PRProcess* process);\n-#define _PR_MD_DETACH_PROCESS _MD_DETACH_PROCESS\n+extern PRStatus _PR_MD_DETACH_PROCESS(PRProcess *process);\n+#define    _PR_MD_DETACH_PROCESS _MD_DETACH_PROCESS\n \n-extern PRStatus _PR_MD_WAIT_PROCESS(PRProcess* process, PRInt32* exitCode);\n-#define _PR_MD_WAIT_PROCESS _MD_WAIT_PROCESS\n+extern PRStatus _PR_MD_WAIT_PROCESS(PRProcess *process, PRInt32 *exitCode);\n+#define    _PR_MD_WAIT_PROCESS _MD_WAIT_PROCESS\n \n-extern PRStatus _PR_MD_KILL_PROCESS(PRProcess* process);\n-#define _PR_MD_KILL_PROCESS _MD_KILL_PROCESS\n+extern PRStatus _PR_MD_KILL_PROCESS(PRProcess *process);\n+#define    _PR_MD_KILL_PROCESS _MD_KILL_PROCESS\n \n /* Current Time */\n-NSPR_API(PRTime)\n-_PR_MD_NOW(void);\n-#define _PR_MD_NOW _MD_NOW\n+NSPR_API(PRTime) _PR_MD_NOW(void);\n+#define    _PR_MD_NOW _MD_NOW\n \n /* Environment related */\n-extern char* _PR_MD_GET_ENV(const char* name);\n-#define _PR_MD_GET_ENV _MD_GET_ENV\n+extern char* _PR_MD_GET_ENV(const char *name);\n+#define    _PR_MD_GET_ENV _MD_GET_ENV\n \n-extern PRIntn _PR_MD_PUT_ENV(const char* name);\n-#define _PR_MD_PUT_ENV _MD_PUT_ENV\n+extern PRIntn _PR_MD_PUT_ENV(const char *name);\n+#define    _PR_MD_PUT_ENV _MD_PUT_ENV\n \n /* Atomic operations */\n \n extern void _PR_MD_INIT_ATOMIC(void);\n-#define _PR_MD_INIT_ATOMIC _MD_INIT_ATOMIC\n+#define    _PR_MD_INIT_ATOMIC _MD_INIT_ATOMIC\n \n-extern PRInt32 _PR_MD_ATOMIC_INCREMENT(PRInt32*);\n-#define _PR_MD_ATOMIC_INCREMENT _MD_ATOMIC_INCREMENT\n+extern PRInt32 _PR_MD_ATOMIC_INCREMENT(PRInt32 *);\n+#define    _PR_MD_ATOMIC_INCREMENT _MD_ATOMIC_INCREMENT\n \n-extern PRInt32 _PR_MD_ATOMIC_ADD(PRInt32*, PRInt32);\n-#define _PR_MD_ATOMIC_ADD _MD_ATOMIC_ADD\n+extern PRInt32 _PR_MD_ATOMIC_ADD(PRInt32 *, PRInt32);\n+#define    _PR_MD_ATOMIC_ADD _MD_ATOMIC_ADD\n \n-extern PRInt32 _PR_MD_ATOMIC_DECREMENT(PRInt32*);\n-#define _PR_MD_ATOMIC_DECREMENT _MD_ATOMIC_DECREMENT\n+extern PRInt32 _PR_MD_ATOMIC_DECREMENT(PRInt32 *);\n+#define    _PR_MD_ATOMIC_DECREMENT _MD_ATOMIC_DECREMENT\n \n-extern PRInt32 _PR_MD_ATOMIC_SET(PRInt32*, PRInt32);\n-#define _PR_MD_ATOMIC_SET _MD_ATOMIC_SET\n+extern PRInt32 _PR_MD_ATOMIC_SET(PRInt32 *, PRInt32);\n+#define    _PR_MD_ATOMIC_SET _MD_ATOMIC_SET\n \n /* Garbage collection */\n \n@@ -1975,7 +1951,7 @@ extern PRInt32 _PR_MD_ATOMIC_SET(PRInt32*, PRInt32);\n ** area to be used as scratch storage to hold just the registers\n ** necessary for scanning.\n */\n-extern PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np);\n+extern PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np);\n \n /* Time intervals */\n \n@@ -1987,41 +1963,47 @@ extern PRIntervalTime _PR_MD_INTERVAL_PER_SEC(void);\n \n /* Affinity masks */\n \n-extern PRInt32 _PR_MD_SETTHREADAFFINITYMASK(PRThread* thread, PRUint32 mask);\n+extern PRInt32 _PR_MD_SETTHREADAFFINITYMASK(PRThread *thread, PRUint32 mask );\n #define _PR_MD_SETTHREADAFFINITYMASK _MD_SETTHREADAFFINITYMASK\n \n-extern PRInt32 _PR_MD_GETTHREADAFFINITYMASK(PRThread* thread, PRUint32* mask);\n+extern PRInt32 _PR_MD_GETTHREADAFFINITYMASK(PRThread *thread, PRUint32 *mask);\n #define _PR_MD_GETTHREADAFFINITYMASK _MD_GETTHREADAFFINITYMASK\n \n /* File locking */\n \n extern PRStatus _PR_MD_LOCKFILE(PROsfd osfd);\n-#define _PR_MD_LOCKFILE _MD_LOCKFILE\n+#define    _PR_MD_LOCKFILE _MD_LOCKFILE\n \n extern PRStatus _PR_MD_TLOCKFILE(PROsfd osfd);\n-#define _PR_MD_TLOCKFILE _MD_TLOCKFILE\n+#define    _PR_MD_TLOCKFILE _MD_TLOCKFILE\n \n extern PRStatus _PR_MD_UNLOCKFILE(PROsfd osfd);\n-#define _PR_MD_UNLOCKFILE _MD_UNLOCKFILE\n+#define    _PR_MD_UNLOCKFILE _MD_UNLOCKFILE\n \n /* Memory-mapped files */\n \n-extern PRStatus _PR_MD_CREATE_FILE_MAP(PRFileMap* fmap, PRInt64 size);\n+extern PRStatus _PR_MD_CREATE_FILE_MAP(PRFileMap *fmap, PRInt64 size);\n #define _PR_MD_CREATE_FILE_MAP _MD_CREATE_FILE_MAP\n \n extern PRInt32 _PR_MD_GET_MEM_MAP_ALIGNMENT(void);\n #define _PR_MD_GET_MEM_MAP_ALIGNMENT _MD_GET_MEM_MAP_ALIGNMENT\n \n-extern void* _PR_MD_MEM_MAP(PRFileMap* fmap, PROffset64 offset, PRUint32 len);\n+extern void * _PR_MD_MEM_MAP(\n+    PRFileMap *fmap,\n+    PROffset64 offset,\n+    PRUint32 len);\n #define _PR_MD_MEM_MAP _MD_MEM_MAP\n \n-extern PRStatus _PR_MD_MEM_UNMAP(void* addr, PRUint32 size);\n+extern PRStatus _PR_MD_MEM_UNMAP(void *addr, PRUint32 size);\n #define _PR_MD_MEM_UNMAP _MD_MEM_UNMAP\n \n-extern PRStatus _PR_MD_CLOSE_FILE_MAP(PRFileMap* fmap);\n+extern PRStatus _PR_MD_CLOSE_FILE_MAP(PRFileMap *fmap);\n #define _PR_MD_CLOSE_FILE_MAP _MD_CLOSE_FILE_MAP\n \n-extern PRStatus _PR_MD_SYNC_MEM_MAP(PRFileDesc* fd, void* addr, PRUint32 len);\n+extern PRStatus _PR_MD_SYNC_MEM_MAP(\n+    PRFileDesc *fd,\n+    void *addr,\n+    PRUint32 len);\n #define _PR_MD_SYNC_MEM_MAP _MD_SYNC_MEM_MAP\n \n /* Named Shared Memory */\n@@ -2029,51 +2011,66 @@ extern PRStatus _PR_MD_SYNC_MEM_MAP(PRFileDesc* fd, void* addr, PRUint32 len);\n /*\n ** Declare PRSharedMemory.\n */\n-struct PRSharedMemory {\n-    char* ipcname; /* after conversion to native */\n-    PRSize size;   /* from open */\n-    PRIntn mode;   /* from open */\n-    PRIntn flags;  /* from open */\n+struct PRSharedMemory\n+{\n+    char        *ipcname; /* after conversion to native */\n+    PRSize      size;  /* from open */\n+    PRIntn      mode;  /* from open */\n+    PRIntn      flags; /* from open */\n #if defined(PR_HAVE_POSIX_NAMED_SHARED_MEMORY)\n-    int id;\n+    int         id;\n #elif defined(PR_HAVE_SYSV_NAMED_SHARED_MEMORY)\n-    int id;\n+    int         id;\n #elif defined(PR_HAVE_WIN32_NAMED_SHARED_MEMORY)\n-    HANDLE handle;\n+    HANDLE      handle;\n #else\n-    PRUint32 nothing; /* placeholder, nothing behind here */\n+    PRUint32    nothing; /* placeholder, nothing behind here */\n #endif\n-    PRUint32 ident; /* guard word at end of struct */\n+    PRUint32    ident; /* guard word at end of struct */\n #define _PR_SHM_IDENT 0xdeadbad\n };\n \n-extern PRSharedMemory* _MD_OpenSharedMemory(const char* name, PRSize size,\n-                                            PRIntn flags, PRIntn mode);\n+extern PRSharedMemory * _MD_OpenSharedMemory(\n+    const char *name,\n+    PRSize      size,\n+    PRIntn      flags,\n+    PRIntn      mode\n+);\n #define _PR_MD_OPEN_SHARED_MEMORY _MD_OpenSharedMemory\n \n-extern void* _MD_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags);\n+extern void * _MD_AttachSharedMemory( PRSharedMemory *shm, PRIntn flags );\n #define _PR_MD_ATTACH_SHARED_MEMORY _MD_AttachSharedMemory\n \n-extern PRStatus _MD_DetachSharedMemory(PRSharedMemory* shm, void* addr);\n+extern PRStatus _MD_DetachSharedMemory( PRSharedMemory *shm, void *addr );\n #define _PR_MD_DETACH_SHARED_MEMORY _MD_DetachSharedMemory\n \n-extern PRStatus _MD_CloseSharedMemory(PRSharedMemory* shm);\n+extern PRStatus _MD_CloseSharedMemory( PRSharedMemory *shm );\n #define _PR_MD_CLOSE_SHARED_MEMORY _MD_CloseSharedMemory\n \n-extern PRStatus _MD_DeleteSharedMemory(const char* name);\n-#define _PR_MD_DELETE_SHARED_MEMORY _MD_DeleteSharedMemory\n+extern PRStatus _MD_DeleteSharedMemory( const char *name );\n+#define _PR_MD_DELETE_SHARED_MEMORY  _MD_DeleteSharedMemory\n \n-extern PRFileMap* _md_OpenAnonFileMap(const char* dirName, PRSize size,\n-                                      PRFileMapProtect prot);\n+extern PRFileMap* _md_OpenAnonFileMap(\n+    const char *dirName,\n+    PRSize      size,\n+    PRFileMapProtect prot\n+);\n #define _PR_MD_OPEN_ANON_FILE_MAP _md_OpenAnonFileMap\n \n-extern PRStatus _md_ExportFileMapAsString(PRFileMap* fm, PRSize bufSize,\n-                                          char* buf);\n+extern PRStatus _md_ExportFileMapAsString(\n+    PRFileMap *fm,\n+    PRSize    bufSize,\n+    char      *buf\n+);\n #define _PR_MD_EXPORT_FILE_MAP_AS_STRING _md_ExportFileMapAsString\n \n-extern PRFileMap* _md_ImportFileMapFromString(const char* fmstring);\n+extern PRFileMap * _md_ImportFileMapFromString(\n+    const char *fmstring\n+);\n #define _PR_MD_IMPORT_FILE_MAP_FROM_STRING _md_ImportFileMapFromString\n \n+\n+\n /* Interprocess communications (IPC) */\n \n /*\n@@ -2086,31 +2083,31 @@ extern PRFileMap* _md_ImportFileMapFromString(const char* fmstring);\n  * Types of NSPR IPC objects\n  */\n typedef enum {\n-    _PRIPCSem, /* semaphores */\n-    _PRIPCShm  /* shared memory segments */\n+    _PRIPCSem,  /* semaphores */\n+    _PRIPCShm   /* shared memory segments */\n } _PRIPCType;\n \n /*\n  * Make a native IPC name from an NSPR IPC name.\n  */\n-extern PRStatus _PR_MakeNativeIPCName(const char* name, /* NSPR IPC name */\n-                                      char* result,     /* result buffer */\n-                                      PRIntn size,      /* size of result buffer */\n-                                      _PRIPCType type   /* type of IPC object */\n+extern PRStatus _PR_MakeNativeIPCName(\n+    const char *name,  /* NSPR IPC name */\n+    char *result,      /* result buffer */\n+    PRIntn size,       /* size of result buffer */\n+    _PRIPCType type    /* type of IPC object */\n );\n \n /* Socket call error code */\n \n-NSPR_API(PRInt32)\n-_PR_MD_GET_SOCKET_ERROR(void);\n-#define _PR_MD_GET_SOCKET_ERROR _MD_GET_SOCKET_ERROR\n+NSPR_API(PRInt32) _PR_MD_GET_SOCKET_ERROR(void);\n+#define    _PR_MD_GET_SOCKET_ERROR _MD_GET_SOCKET_ERROR\n \n /* Get name of current host */\n-extern PRStatus _PR_MD_GETHOSTNAME(char* name, PRUint32 namelen);\n-#define _PR_MD_GETHOSTNAME _MD_GETHOSTNAME\n+extern PRStatus _PR_MD_GETHOSTNAME(char *name, PRUint32 namelen);\n+#define    _PR_MD_GETHOSTNAME _MD_GETHOSTNAME\n \n-extern PRStatus _PR_MD_GETSYSINFO(PRSysInfo cmd, char* name, PRUint32 namelen);\n-#define _PR_MD_GETSYSINFO _MD_GETSYSINFO\n+extern PRStatus _PR_MD_GETSYSINFO(PRSysInfo cmd, char *name, PRUint32 namelen);\n+#define    _PR_MD_GETSYSINFO _MD_GETSYSINFO\n \n /* File descriptor inheritance */\n \n@@ -2119,29 +2116,29 @@ extern PRStatus _PR_MD_GETSYSINFO(PRSysInfo cmd, char* name, PRUint32 namelen);\n  * know the inheritable attribute of the fd, call this function\n  * to find that out.  This typically requires a system call.\n  */\n-extern void _PR_MD_QUERY_FD_INHERITABLE(PRFileDesc* fd);\n-#define _PR_MD_QUERY_FD_INHERITABLE _MD_QUERY_FD_INHERITABLE\n+extern void _PR_MD_QUERY_FD_INHERITABLE(PRFileDesc *fd);\n+#define    _PR_MD_QUERY_FD_INHERITABLE _MD_QUERY_FD_INHERITABLE\n \n /* --- PR_GetRandomNoise() related things --- */\n \n-extern PRSize _PR_MD_GetRandomNoise(void* buf, PRSize size);\n-#define _PR_MD_GET_RANDOM_NOISE(buf, size) _PR_MD_GetRandomNoise((buf), (size))\n-extern PRSize _pr_CopyLowBits(void* dest, PRSize dstlen, void* src,\n-                              PRSize srclen);\n+extern PRSize _PR_MD_GetRandomNoise( void *buf, PRSize size );\n+#define _PR_MD_GET_RANDOM_NOISE(buf,size) _PR_MD_GetRandomNoise((buf),(size))\n+extern PRSize _pr_CopyLowBits( void *dest, PRSize dstlen, void *src, PRSize srclen );\n \n /* end PR_GetRandomNoise() related */\n \n #if defined(_WIN64) && defined(WIN95)\n typedef struct _PRFileDescList {\n-    PRFileDesc* fd;\n-    struct _PRFileDescList* next;\n+    PRFileDesc *fd;\n+    struct _PRFileDescList *next;\n } PRFileDescList;\n \n-extern PRLock* _fd_waiting_for_overlapped_done_lock;\n-extern PRFileDescList* _fd_waiting_for_overlapped_done;\n+extern PRLock *_fd_waiting_for_overlapped_done_lock;\n+extern PRFileDescList *_fd_waiting_for_overlapped_done;\n extern void CheckOverlappedPendingSocketsAreDone();\n #endif\n \n+\n PR_END_EXTERN_C\n \n #endif /* primpl_h___ */\ndiff --git a/nspr/pr/include/private/prpriv.h b/nspr/pr/include/private/prpriv.h\nindex 9b14da0..f45eee4 100644\n--- a/nspr/pr/include/private/prpriv.h\n+++ b/nspr/pr/include/private/prpriv.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/include/prlink.h b/nspr/pr/include/prlink.h\nindex 09e03de..0e38eff 100644\n--- a/nspr/pr/include/prlink.h\n+++ b/nspr/pr/include/prlink.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -15,7 +16,7 @@ PR_BEGIN_EXTERN_C\n typedef struct PRLibrary PRLibrary;\n \n typedef struct PRStaticLinkTable {\n-    const char* name;\n+    const char *name;\n     void (*fp)(void);\n } PRStaticLinkTable;\n \n@@ -26,8 +27,7 @@ typedef struct PRStaticLinkTable {\n ** The string provided as 'path' is copied. The caller can do whatever is\n ** convenient with the argument when the function is complete.\n */\n-NSPR_API(PRStatus)\n-PR_SetLibraryPath(const char* path);\n+NSPR_API(PRStatus) PR_SetLibraryPath(const char *path);\n \n /*\n ** Return a character string which contains the path used to search for\n@@ -37,8 +37,7 @@ PR_SetLibraryPath(const char* path);\n ** The storage is allocated by the runtime and becomes the responsibilty\n ** of the caller.\n */\n-NSPR_API(char*)\n-PR_GetLibraryPath(void);\n+NSPR_API(char*) PR_GetLibraryPath(void);\n \n /*\n ** Given a directory name \"dir\" and a library name \"lib\" construct a full\n@@ -51,15 +50,13 @@ PR_GetLibraryPath(void);\n ** The storage for the result is allocated by the runtime and becomes the\n ** responsibility of the caller.\n */\n-NSPR_API(char*)\n-PR_GetLibraryName(const char* dir, const char* lib);\n+NSPR_API(char*) PR_GetLibraryName(const char *dir, const char *lib);\n \n /*\n **\n ** Free the memory allocated, for the caller, by PR_GetLibraryName\n */\n-NSPR_API(void)\n-PR_FreeLibraryName(char* mem);\n+NSPR_API(void) PR_FreeLibraryName(char *mem);\n \n /*\n ** Given a library \"name\" try to load the library. The argument \"name\"\n@@ -73,8 +70,7 @@ PR_FreeLibraryName(char* mem);\n **\n ** This increments the reference count of the library.\n */\n-NSPR_API(PRLibrary*)\n-PR_LoadLibrary(const char* name);\n+NSPR_API(PRLibrary*) PR_LoadLibrary(const char *name);\n \n /*\n ** Each operating system has its preferred way of specifying\n@@ -108,22 +104,22 @@ typedef struct PRLibSpec {\n     PRLibSpecType type;\n     union {\n         /* if type is PR_LibSpec_Pathname */\n-        const char* pathname;\n+        const char *pathname;\n \n         /* if type is PR_LibSpec_MacNamedFragment */\n         struct {\n-            const struct FSSpec* fsspec;\n-            const char* name;\n-        } mac_named_fragment; /* obsolete (for Mac OS Classic) */\n+            const struct FSSpec *fsspec;\n+            const char *name;\n+        } mac_named_fragment;      /* obsolete (for Mac OS Classic) */\n \n         /* if type is PR_LibSpec_MacIndexedFragment */\n         struct {\n-            const struct FSSpec* fsspec;\n+            const struct FSSpec *fsspec;\n             PRUint32 index;\n-        } mac_indexed_fragment; /* obsolete (for Mac OS Classic) */\n+        } mac_indexed_fragment;    /* obsolete (for Mac OS Classic) */\n \n         /* if type is PR_LibSpec_PathnameU */\n-        const PRUnichar* pathname_u; /* supported only on Win32 */\n+        const PRUnichar *pathname_u; /* supported only on Win32 */\n     } value;\n } PRLibSpec;\n \n@@ -133,21 +129,22 @@ typedef struct PRLibSpec {\n ** Flags not supported by the underlying OS are ignored.\n */\n \n-#define PR_LD_LAZY 0x1   /* equivalent to RTLD_LAZY on Unix */\n-#define PR_LD_NOW 0x2    /* equivalent to RTLD_NOW on Unix */\n-#define PR_LD_GLOBAL 0x4 /* equivalent to RTLD_GLOBAL on Unix */\n-#define PR_LD_LOCAL 0x8  /* equivalent to RTLD_LOCAL on Unix */\n+#define PR_LD_LAZY   0x1  /* equivalent to RTLD_LAZY on Unix */\n+#define PR_LD_NOW    0x2  /* equivalent to RTLD_NOW on Unix */\n+#define PR_LD_GLOBAL 0x4  /* equivalent to RTLD_GLOBAL on Unix */\n+#define PR_LD_LOCAL  0x8  /* equivalent to RTLD_LOCAL on Unix */\n /* The following is equivalent to LOAD_WITH_ALTERED_SEARCH_PATH on Windows */\n-#define PR_LD_ALT_SEARCH_PATH 0x10\n+#define PR_LD_ALT_SEARCH_PATH  0x10\n /*                0x8000     reserved for NSPR internal use */\n \n /*\n ** Load the specified library, in the manner specified by 'flags'.\n */\n \n-NSPR_API(PRLibrary*)\n-PR_LoadLibraryWithFlags(PRLibSpec libSpec, /* the shared library */\n-                        PRIntn flags       /* flags that affect the loading */\n+NSPR_API(PRLibrary *)\n+PR_LoadLibraryWithFlags(\n+    PRLibSpec libSpec,    /* the shared library */\n+    PRIntn flags          /* flags that affect the loading */\n );\n \n /*\n@@ -159,8 +156,7 @@ PR_LoadLibraryWithFlags(PRLibSpec libSpec, /* the shared library */\n **\n ** This function decrements the reference count of the library.\n */\n-NSPR_API(PRStatus)\n-PR_UnloadLibrary(PRLibrary* lib);\n+NSPR_API(PRStatus) PR_UnloadLibrary(PRLibrary *lib);\n \n /*\n ** Given the name of a procedure, return the address of the function that\n@@ -170,8 +166,7 @@ PR_UnloadLibrary(PRLibrary* lib);\n **\n ** This function does not modify the reference count of the library.\n */\n-NSPR_API(void*)\n-PR_FindSymbol(PRLibrary* lib, const char* name);\n+NSPR_API(void*) PR_FindSymbol(PRLibrary *lib, const char *name);\n \n /*\n ** Similar to PR_FindSymbol, except that the return value is a pointer to\n@@ -182,8 +177,7 @@ PR_FindSymbol(PRLibrary* lib, const char* name);\n ** This function does not modify the reference count of the library.\n */\n typedef void (*PRFuncPtr)(void);\n-NSPR_API(PRFuncPtr)\n-PR_FindFunctionSymbol(PRLibrary* lib, const char* name);\n+NSPR_API(PRFuncPtr) PR_FindFunctionSymbol(PRLibrary *lib, const char *name);\n \n /*\n ** Finds a symbol in one of the currently loaded libraries. Given the\n@@ -195,8 +189,8 @@ PR_FindFunctionSymbol(PRLibrary* lib, const char* name);\n **\n ** This increments the reference count of the library.\n */\n-NSPR_API(void*)\n-PR_FindSymbolAndLibrary(const char* name, PRLibrary** lib);\n+NSPR_API(void*) PR_FindSymbolAndLibrary(const char *name,\n+                                        PRLibrary* *lib);\n \n /*\n ** Similar to PR_FindSymbolAndLibrary, except that the return value is\n@@ -206,8 +200,8 @@ PR_FindSymbolAndLibrary(const char* name, PRLibrary** lib);\n **\n ** This increments the reference count of the library.\n */\n-NSPR_API(PRFuncPtr)\n-PR_FindFunctionSymbolAndLibrary(const char* name, PRLibrary** lib);\n+NSPR_API(PRFuncPtr) PR_FindFunctionSymbolAndLibrary(const char *name,\n+        PRLibrary* *lib);\n \n /*\n ** Register a static link table with the runtime under the name\n@@ -220,8 +214,8 @@ PR_FindFunctionSymbolAndLibrary(const char* name, PRLibrary** lib);\n **\n ** This increments the reference count of the library.\n */\n-NSPR_API(PRLibrary*)\n-PR_LoadStaticLibrary(const char* name, const PRStaticLinkTable* table);\n+NSPR_API(PRLibrary*) PR_LoadStaticLibrary(\n+    const char *name, const PRStaticLinkTable *table);\n \n /*\n ** Return the pathname of the file that the library \"name\" was loaded\n@@ -229,8 +223,7 @@ PR_LoadStaticLibrary(const char* name, const PRStaticLinkTable* table);\n **\n ** The caller is responsible for freeing the result with PR_Free.\n */\n-NSPR_API(char*)\n-PR_GetLibraryFilePathname(const char* name, PRFuncPtr addr);\n+NSPR_API(char *) PR_GetLibraryFilePathname(const char *name, PRFuncPtr addr);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prlock.h b/nspr/pr/include/prlock.h\nindex a284234..9b7fdaa 100644\n--- a/nspr/pr/include/prlock.h\n+++ b/nspr/pr/include/prlock.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -47,8 +48,7 @@ typedef struct PRLock PRLock;\n **   is returned.\n **\n ***********************************************************************/\n-NSPR_API(PRLock*)\n-PR_NewLock(void);\n+NSPR_API(PRLock*) PR_NewLock(void);\n \n /***********************************************************************\n ** FUNCTION:    PR_DestroyLock\n@@ -59,8 +59,7 @@ PR_NewLock(void);\n ** OUTPUTS:     void\n ** RETURN:      None\n ***********************************************************************/\n-NSPR_API(void)\n-PR_DestroyLock(PRLock* lock);\n+NSPR_API(void) PR_DestroyLock(PRLock *lock);\n \n /***********************************************************************\n ** FUNCTION:    PR_Lock\n@@ -71,8 +70,7 @@ PR_DestroyLock(PRLock* lock);\n ** OUTPUTS:     void\n ** RETURN:      None\n ***********************************************************************/\n-NSPR_API(void)\n-PR_Lock(PRLock* lock);\n+NSPR_API(void) PR_Lock(PRLock *lock);\n \n /***********************************************************************\n ** FUNCTION:    PR_Unlock\n@@ -84,8 +82,7 @@ PR_Lock(PRLock* lock);\n ** RETURN:      PR_STATUS\n **              Returns PR_FAILURE if the caller does not own the lock.\n ***********************************************************************/\n-NSPR_API(PRStatus)\n-PR_Unlock(PRLock* lock);\n+NSPR_API(PRStatus) PR_Unlock(PRLock *lock);\n \n /***********************************************************************\n ** MACRO:    PR_ASSERT_CURRENT_THREAD_OWNS_LOCK\n@@ -105,8 +102,7 @@ PR_Unlock(PRLock* lock);\n #endif\n \n /* Don't call this function directly. */\n-NSPR_API(void)\n-PR_AssertCurrentThreadOwnsLock(PRLock* lock);\n+NSPR_API(void) PR_AssertCurrentThreadOwnsLock(PRLock *lock);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prlog.h b/nspr/pr/include/prlog.h\nindex 5ecd3d4..1922c25 100644\n--- a/nspr/pr/include/prlog.h\n+++ b/nspr/pr/include/prlog.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -103,16 +104,16 @@ PR_BEGIN_EXTERN_C\n */\n \n typedef enum PRLogModuleLevel {\n-    PR_LOG_NONE = 0,    /* nothing */\n-    PR_LOG_ALWAYS = 1,  /* always printed */\n-    PR_LOG_ERROR = 2,   /* error messages */\n-    PR_LOG_WARNING = 3, /* warning messages */\n-    PR_LOG_DEBUG = 4,   /* debug messages */\n-\n-    PR_LOG_NOTICE = PR_LOG_DEBUG, /* notice messages */\n-    PR_LOG_WARN = PR_LOG_WARNING, /* warning messages */\n-    PR_LOG_MIN = PR_LOG_DEBUG,    /* minimal debugging messages */\n-    PR_LOG_MAX = PR_LOG_DEBUG     /* maximal debugging messages */\n+    PR_LOG_NONE = 0,                /* nothing */\n+    PR_LOG_ALWAYS = 1,              /* always printed */\n+    PR_LOG_ERROR = 2,               /* error messages */\n+    PR_LOG_WARNING = 3,             /* warning messages */\n+    PR_LOG_DEBUG = 4,               /* debug messages */\n+\n+    PR_LOG_NOTICE = PR_LOG_DEBUG,   /* notice messages */\n+    PR_LOG_WARN = PR_LOG_WARNING,   /* warning messages */\n+    PR_LOG_MIN = PR_LOG_DEBUG,      /* minimal debugging messages */\n+    PR_LOG_MAX = PR_LOG_DEBUG       /* maximal debugging messages */\n } PRLogModuleLevel;\n \n /*\n@@ -121,30 +122,27 @@ typedef enum PRLogModuleLevel {\n **    \"level\" is the debugging level selected for that module\n */\n typedef struct PRLogModuleInfo {\n-    const char* name;\n+    const char *name;\n     PRLogModuleLevel level;\n-    struct PRLogModuleInfo* next;\n+    struct PRLogModuleInfo *next;\n } PRLogModuleInfo;\n \n /*\n ** Create a new log module.\n */\n-NSPR_API(PRLogModuleInfo*)\n-PR_NewLogModule(const char* name);\n+NSPR_API(PRLogModuleInfo*) PR_NewLogModule(const char *name);\n \n /*\n ** Set the file to use for logging. Returns PR_FALSE if the file cannot\n ** be created\n */\n-NSPR_API(PRBool)\n-PR_SetLogFile(const char* name);\n+NSPR_API(PRBool) PR_SetLogFile(const char *name);\n \n /*\n ** Set the size of the logging buffer. If \"buffer_size\" is zero then the\n ** logging becomes \"synchronous\" (or unbuffered).\n */\n-NSPR_API(void)\n-PR_SetLogBuffering(PRIntn buffer_size);\n+NSPR_API(void) PR_SetLogBuffering(PRIntn buffer_size);\n \n /*\n ** Print a string to the log. \"fmt\" is a PR_snprintf format type. All\n@@ -152,22 +150,21 @@ PR_SetLogBuffering(PRIntn buffer_size);\n ** and a time stamp. Also, the routine provides a missing newline if one\n ** is not provided.\n */\n-NSPR_API(void)\n-PR_LogPrint(const char* fmt, ...);\n+NSPR_API(void) PR_LogPrint(const char *fmt, ...);\n \n /*\n ** Flush the log to its file.\n */\n-NSPR_API(void)\n-PR_LogFlush(void);\n+NSPR_API(void) PR_LogFlush(void);\n \n-NSPR_API(void)\n-PR_Assert(const char* s, const char* file, PRIntn ln) PR_PRETEND_NORETURN;\n+NSPR_API(void) PR_Assert(const char *s, const char *file, PRIntn ln)\n+PR_PRETEND_NORETURN;\n \n #if defined(DEBUG) || defined(FORCE_PR_LOG)\n #define PR_LOGGING 1\n \n-#define PR_LOG_TEST(_module, _level) ((_module)->level >= (_level))\n+#define PR_LOG_TEST(_module,_level) \\\n+    ((_module)->level >= (_level))\n \n /*\n ** Log something.\n@@ -176,31 +173,31 @@ PR_Assert(const char* s, const char* file, PRIntn ln) PR_PRETEND_NORETURN;\n **    \"args\" is a variable length list of arguments to print, in the following\n **       format:  (\"printf style format string\", ...)\n */\n-#define PR_LOG(_module, _level, _args)  \\\n-    PR_BEGIN_MACRO                      \\\n-    if (PR_LOG_TEST(_module, _level)) { \\\n-        PR_LogPrint _args;              \\\n-    }                                   \\\n+#define PR_LOG(_module,_level,_args)     \\\n+    PR_BEGIN_MACRO             \\\n+      if (PR_LOG_TEST(_module,_level)) { \\\n+      PR_LogPrint _args;         \\\n+      }                     \\\n     PR_END_MACRO\n \n #else /* defined(DEBUG) || defined(FORCE_PR_LOG) */\n \n #undef PR_LOGGING\n-#define PR_LOG_TEST(module, level) 0\n-#define PR_LOG(module, level, args)\n+#define PR_LOG_TEST(module,level) 0\n+#define PR_LOG(module,level,args)\n \n #endif /* defined(DEBUG) || defined(FORCE_PR_LOG) */\n \n #ifndef NO_NSPR_10_SUPPORT\n \n #ifdef PR_LOGGING\n-#define PR_LOG_BEGIN PR_LOG\n-#define PR_LOG_END PR_LOG\n-#define PR_LOG_DEFINE PR_NewLogModule\n+#define PR_LOG_BEGIN    PR_LOG\n+#define PR_LOG_END      PR_LOG\n+#define PR_LOG_DEFINE   PR_NewLogModule\n #else\n-#define PR_LOG_BEGIN(module, level, args)\n-#define PR_LOG_END(module, level, args)\n-#define PR_LOG_DEFINE(_name) NULL\n+#define PR_LOG_BEGIN(module,level,args)\n+#define PR_LOG_END(module,level,args)\n+#define PR_LOG_DEFINE(_name)    NULL\n #endif /* PR_LOGGING */\n \n #endif /* NO_NSPR_10_SUPPORT */\n@@ -208,15 +205,16 @@ PR_Assert(const char* s, const char* file, PRIntn ln) PR_PRETEND_NORETURN;\n #if defined(DEBUG) || defined(FORCE_PR_ASSERT)\n \n #define PR_ASSERT(_expr) \\\n-    ((_expr) ? ((void)0) : PR_Assert(#_expr, __FILE__, __LINE__))\n+    ((_expr)?((void)0):PR_Assert(# _expr,__FILE__,__LINE__))\n \n #define PR_ASSERT_ARG(_expr) PR_ASSERT(_expr)\n \n-#define PR_NOT_REACHED(_reasonStr) PR_Assert(_reasonStr, __FILE__, __LINE__)\n+#define PR_NOT_REACHED(_reasonStr) \\\n+    PR_Assert(_reasonStr,__FILE__,__LINE__)\n \n #else\n \n-#define PR_ASSERT(expr) ((void)0)\n+#define PR_ASSERT(expr) ((void) 0)\n /* PR_ASSERT_ARG avoids compiler warning: unused variable */\n #define PR_ASSERT_ARG(expr) ((void)(0 && (expr)))\n #define PR_NOT_REACHED(reasonStr)\ndiff --git a/nspr/pr/include/prlong.h b/nspr/pr/include/prlong.h\nindex 21ac3b5..7cc1d56 100644\n--- a/nspr/pr/include/prlong.h\n+++ b/nspr/pr/include/prlong.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -26,36 +27,32 @@ PR_BEGIN_EXTERN_C\n **      Various interesting constants and static variable\n **      initializer\n ***********************************************************************/\n-NSPR_API(PRInt64)\n-LL_MaxInt(void);\n-NSPR_API(PRInt64)\n-LL_MinInt(void);\n-NSPR_API(PRInt64)\n-LL_Zero(void);\n-NSPR_API(PRUint64)\n-LL_MaxUint(void);\n+NSPR_API(PRInt64) LL_MaxInt(void);\n+NSPR_API(PRInt64) LL_MinInt(void);\n+NSPR_API(PRInt64) LL_Zero(void);\n+NSPR_API(PRUint64) LL_MaxUint(void);\n \n #if defined(HAVE_LONG_LONG)\n \n /* Keep this in sync with prtypes.h. */\n #if PR_BYTES_PER_LONG == 8 && !defined(PR_ALTERNATE_INT64_TYPEDEF)\n-#define LL_MAXINT 9223372036854775807L\n-#define LL_MININT (-LL_MAXINT - 1L)\n-#define LL_ZERO 0L\n-#define LL_MAXUINT 18446744073709551615UL\n-#define LL_INIT(hi, lo) ((PRInt64)(((PRUint64)(hi##UL) << 32) + (lo##UL)))\n+#define LL_MAXINT   9223372036854775807L\n+#define LL_MININT   (-LL_MAXINT - 1L)\n+#define LL_ZERO     0L\n+#define LL_MAXUINT  18446744073709551615UL\n+#define LL_INIT(hi, lo)  ((hi ## L << 32) + lo ## L)\n #elif defined(WIN32) && !defined(__GNUC__)\n-#define LL_MAXINT 9223372036854775807i64\n-#define LL_MININT (-LL_MAXINT - 1i64)\n-#define LL_ZERO 0i64\n-#define LL_MAXUINT 18446744073709551615ui64\n-#define LL_INIT(hi, lo) ((PRInt64)(((PRUint64)(hi##ui64) << 32) + (lo##ui64)))\n+#define LL_MAXINT   9223372036854775807i64\n+#define LL_MININT   (-LL_MAXINT - 1i64)\n+#define LL_ZERO     0i64\n+#define LL_MAXUINT  18446744073709551615ui64\n+#define LL_INIT(hi, lo)  ((hi ## i64 << 32) + lo ## i64)\n #else\n-#define LL_MAXINT 9223372036854775807LL\n-#define LL_MININT (-LL_MAXINT - 1LL)\n-#define LL_ZERO 0LL\n-#define LL_MAXUINT 18446744073709551615ULL\n-#define LL_INIT(hi, lo) ((PRInt64)(((PRUint64)(hi##ULL) << 32) + (lo##ULL)))\n+#define LL_MAXINT   9223372036854775807LL\n+#define LL_MININT   (-LL_MAXINT - 1LL)\n+#define LL_ZERO     0LL\n+#define LL_MAXUINT  18446744073709551615ULL\n+#define LL_INIT(hi, lo)  ((hi ## LL << 32) + lo ## LL)\n #endif\n \n /***********************************************************************\n@@ -75,12 +72,12 @@ LL_MaxUint(void);\n **  LL_GE_ZERO        Test for zero or positive\n **  LL_CMP            Compare two values\n ***********************************************************************/\n-#define LL_IS_ZERO(a) ((a) == 0)\n-#define LL_EQ(a, b) ((a) == (b))\n-#define LL_NE(a, b) ((a) != (b))\n-#define LL_GE_ZERO(a) ((a) >= 0)\n-#define LL_CMP(a, op, b) ((PRInt64)(a)op(PRInt64)(b))\n-#define LL_UCMP(a, op, b) ((PRUint64)(a)op(PRUint64)(b))\n+#define LL_IS_ZERO(a)       ((a) == 0)\n+#define LL_EQ(a, b)         ((a) == (b))\n+#define LL_NE(a, b)         ((a) != (b))\n+#define LL_GE_ZERO(a)       ((a) >= 0)\n+#define LL_CMP(a, op, b)    ((PRInt64)(a) op (PRInt64)(b))\n+#define LL_UCMP(a, op, b)   ((PRUint64)(a) op (PRUint64)(b))\n \n /***********************************************************************\n ** MACROS:      LL_<logical operators>\n@@ -91,11 +88,11 @@ LL_MaxUint(void);\n **  LL_OR2            A disgusting deviation\n **  LL_NOT            Negation (one's complement)\n ***********************************************************************/\n-#define LL_AND(r, a, b) ((r) = (a) & (b))\n-#define LL_OR(r, a, b) ((r) = (a) | (b))\n-#define LL_XOR(r, a, b) ((r) = (a) ^ (b))\n-#define LL_OR2(r, a) ((r) = (r) | (a))\n-#define LL_NOT(r, a) ((r) = ~(a))\n+#define LL_AND(r, a, b)        ((r) = (a) & (b))\n+#define LL_OR(r, a, b)        ((r) = (a) | (b))\n+#define LL_XOR(r, a, b)        ((r) = (a) ^ (b))\n+#define LL_OR2(r, a)        ((r) = (r) | (a))\n+#define LL_NOT(r, a)        ((r) = ~(a))\n \n /***********************************************************************\n ** MACROS:      LL_<mathematical operators>\n@@ -104,14 +101,9 @@ LL_MaxUint(void);\n **  LL_ADD            Summation (two's complement)\n **  LL_SUB            Difference (two's complement)\n ***********************************************************************/\n-/*\n- * Negate as unsigned so that negating the most-negative value is\n- * well-defined (negating it as signed is undefined behavior and trips\n- * -fsanitize=undefined). The two's-complement result is unchanged.\n- */\n-#define LL_NEG(r, a) ((r) = (PRInt64)(-(PRUint64)(a)))\n-#define LL_ADD(r, a, b) ((r) = (a) + (b))\n-#define LL_SUB(r, a, b) ((r) = (a) - (b))\n+#define LL_NEG(r, a)        ((r) = -(a))\n+#define LL_ADD(r, a, b)     ((r) = (a) + (b))\n+#define LL_SUB(r, a, b)     ((r) = (a) - (b))\n \n /***********************************************************************\n ** MACROS:      LL_<mathematical operators>\n@@ -120,9 +112,9 @@ LL_MaxUint(void);\n **  LL_DIV            Quotient (two's complement)\n **  LL_MOD            Modulus (two's complement)\n ***********************************************************************/\n-#define LL_MUL(r, a, b) ((r) = (a) * (b))\n-#define LL_DIV(r, a, b) ((r) = (a) / (b))\n-#define LL_MOD(r, a, b) ((r) = (a) % (b))\n+#define LL_MUL(r, a, b)        ((r) = (a) * (b))\n+#define LL_DIV(r, a, b)        ((r) = (a) / (b))\n+#define LL_MOD(r, a, b)        ((r) = (a) % (b))\n \n /***********************************************************************\n ** MACROS:      LL_<shifting operators>\n@@ -132,15 +124,10 @@ LL_MaxUint(void);\n **  LL_USHR           Unsigned shift right [0..64] bits\n **  LL_ISHL           Signed shift left [0..64] bits\n ***********************************************************************/\n-/*\n- * Shift the value as unsigned to keep the left shift well-defined: shifting\n- * a negative value (or into the sign bit) is undefined behavior in C, and\n- * trips -fsanitize=undefined. The two's-complement result is unchanged.\n- */\n-#define LL_SHL(r, a, b) ((r) = (PRInt64)((PRUint64)(a) << (b)))\n-#define LL_SHR(r, a, b) ((r) = (PRInt64)(a) >> (b))\n-#define LL_USHR(r, a, b) ((r) = (PRUint64)(a) >> (b))\n-#define LL_ISHL(r, a, b) ((r) = (PRInt64)((PRUint64)(a) << (b)))\n+#define LL_SHL(r, a, b)     ((r) = (PRInt64)(a) << (b))\n+#define LL_SHR(r, a, b)     ((r) = (PRInt64)(a) >> (b))\n+#define LL_USHR(r, a, b)    ((r) = (PRUint64)(a) >> (b))\n+#define LL_ISHL(r, a, b)    ((r) = (PRInt64)(a) << (b))\n \n /***********************************************************************\n ** MACROS:      LL_<conversion operators>\n@@ -154,15 +141,15 @@ LL_MaxUint(void);\n **  LL_F2L            Convert float to 64 bit\n **  LL_D2L            Convert float to 64 bit\n ***********************************************************************/\n-#define LL_L2I(i, l) ((i) = (PRInt32)(l))\n-#define LL_L2UI(ui, l) ((ui) = (PRUint32)(l))\n-#define LL_L2F(f, l) ((f) = (PRFloat64)(l))\n-#define LL_L2D(d, l) ((d) = (PRFloat64)(l))\n+#define LL_L2I(i, l)        ((i) = (PRInt32)(l))\n+#define LL_L2UI(ui, l)        ((ui) = (PRUint32)(l))\n+#define LL_L2F(f, l)        ((f) = (PRFloat64)(l))\n+#define LL_L2D(d, l)        ((d) = (PRFloat64)(l))\n \n-#define LL_I2L(l, i) ((l) = (PRInt64)(i))\n-#define LL_UI2L(l, ui) ((l) = (PRInt64)(ui))\n-#define LL_F2L(l, f) ((l) = (PRInt64)(f))\n-#define LL_D2L(l, d) ((l) = (PRInt64)(d))\n+#define LL_I2L(l, i)        ((l) = (PRInt64)(i))\n+#define LL_UI2L(l, ui)        ((l) = (PRInt64)(ui))\n+#define LL_F2L(l, f)        ((l) = (PRInt64)(f))\n+#define LL_D2L(l, d)        ((l) = (PRInt64)(d))\n \n /***********************************************************************\n ** MACROS:      LL_UDIVMOD\n@@ -174,265 +161,240 @@ LL_MaxUint(void);\n **              PRUint64 *rp: pointer to remainder\n ***********************************************************************/\n #define LL_UDIVMOD(qp, rp, a, b) \\\n-    (*(qp) = ((PRUint64)(a) / (b)), *(rp) = ((PRUint64)(a) % (b)))\n+    (*(qp) = ((PRUint64)(a) / (b)), \\\n+     *(rp) = ((PRUint64)(a) % (b)))\n \n-#else /* !HAVE_LONG_LONG */\n+#else  /* !HAVE_LONG_LONG */\n \n-#define LL_MAXINT LL_MaxInt()\n-#define LL_MININT LL_MinInt()\n-#define LL_ZERO LL_Zero()\n-#define LL_MAXUINT LL_MaxUint()\n+#define LL_MAXINT   LL_MaxInt()\n+#define LL_MININT   LL_MinInt()\n+#define LL_ZERO     LL_Zero()\n+#define LL_MAXUINT  LL_MaxUint()\n \n #ifdef IS_LITTLE_ENDIAN\n-#define LL_INIT(hi, lo) { PR_UINT32(lo), PR_UINT32(hi) }\n+#define LL_INIT(hi, lo) {PR_UINT32(lo), PR_UINT32(hi)}\n #else\n-#define LL_INIT(hi, lo) { PR_UINT32(hi), PR_UINT32(lo) }\n+#define LL_INIT(hi, lo) {PR_UINT32(hi), PR_UINT32(lo)}\n #endif\n \n-#define LL_IS_ZERO(a) (((a).hi == 0) && ((a).lo == 0))\n-#define LL_EQ(a, b) (((a).hi == (b).hi) && ((a).lo == (b).lo))\n-#define LL_NE(a, b) (((a).hi != (b).hi) || ((a).lo != (b).lo))\n-#define LL_GE_ZERO(a) (((a).hi >> 31) == 0)\n-\n-#define LL_CMP(a, op, b)                    \\\n-    (((a).hi == (b).hi) ? ((a).lo op(b).lo) \\\n-                        : ((PRInt32)(a).hi op(PRInt32)(b).hi))\n-#define LL_UCMP(a, op, b) \\\n-    (((a).hi == (b).hi) ? ((a).lo op(b).lo) : ((a).hi op(b).hi))\n-\n-#define LL_AND(r, a, b) ((r).lo = (a).lo & (b).lo, (r).hi = (a).hi & (b).hi)\n-#define LL_OR(r, a, b) ((r).lo = (a).lo | (b).lo, (r).hi = (a).hi | (b).hi)\n-#define LL_XOR(r, a, b) ((r).lo = (a).lo ^ (b).lo, (r).hi = (a).hi ^ (b).hi)\n-#define LL_OR2(r, a) ((r).lo = (r).lo | (a).lo, (r).hi = (r).hi | (a).hi)\n-#define LL_NOT(r, a) ((r).lo = ~(a).lo, (r).hi = ~(a).hi)\n-\n-#define LL_NEG(r, a) \\\n-    ((r).lo = -(PRInt32)(a).lo, (r).hi = -(PRInt32)(a).hi - ((r).lo != 0))\n-#define LL_ADD(r, a, b)                            \\\n-    {                                              \\\n-        PRInt64 _a, _b;                            \\\n-        _a = a;                                    \\\n-        _b = b;                                    \\\n-        (r).lo = _a.lo + _b.lo;                    \\\n-        (r).hi = _a.hi + _b.hi + ((r).lo < _b.lo); \\\n-    }\n-\n-#define LL_SUB(r, a, b)                           \\\n-    {                                             \\\n-        PRInt64 _a, _b;                           \\\n-        _a = a;                                   \\\n-        _b = b;                                   \\\n-        (r).lo = _a.lo - _b.lo;                   \\\n-        (r).hi = _a.hi - _b.hi - (_a.lo < _b.lo); \\\n-    }\n-\n-#define LL_MUL(r, a, b)                          \\\n-    {                                            \\\n-        PRInt64 _a, _b;                          \\\n-        _a = a;                                  \\\n-        _b = b;                                  \\\n-        LL_MUL32(r, _a.lo, _b.lo);               \\\n-        (r).hi += _a.hi * _b.lo + _a.lo * _b.hi; \\\n-    }\n-\n-#define _lo16(a) ((a) & PR_BITMASK(16))\n-#define _hi16(a) ((a) >> 16)\n-\n-#define LL_MUL32(r, a, b)                                  \\\n-    {                                                      \\\n-        PRUint32 _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3;   \\\n-        _a1 = _hi16(a), _a0 = _lo16(a);                    \\\n-        _b1 = _hi16(b), _b0 = _lo16(b);                    \\\n-        _y0 = _a0 * _b0;                                   \\\n-        _y1 = _a0 * _b1;                                   \\\n-        _y2 = _a1 * _b0;                                   \\\n-        _y3 = _a1 * _b1;                                   \\\n-        _y1 += _hi16(_y0); /* can't carry */               \\\n-        _y1 += _y2;        /* might carry */               \\\n-        if (_y1 < _y2)                                     \\\n-            _y3 += (PRUint32)(PR_BIT(16)); /* propagate */ \\\n-        (r).lo = (_lo16(_y1) << 16) + _lo16(_y0);          \\\n-        (r).hi = _y3 + _hi16(_y1);                         \\\n-    }\n-\n-#define LL_UDIVMOD(qp, rp, a, b) ll_udivmod(qp, rp, a, b)\n-\n-NSPR_API(void)\n-ll_udivmod(PRUint64* qp, PRUint64* rp, PRUint64 a, PRUint64 b);\n-\n-#define LL_DIV(r, a, b)                           \\\n-    {                                             \\\n-        PRInt64 _a, _b;                           \\\n-        PRUint32 _negative = (PRInt32)(a).hi < 0; \\\n-        if (_negative) {                          \\\n-            LL_NEG(_a, a);                        \\\n-        } else {                                  \\\n-            _a = a;                               \\\n-        }                                         \\\n-        if ((PRInt32)(b).hi < 0) {                \\\n-            _negative ^= 1;                       \\\n-            LL_NEG(_b, b);                        \\\n-        } else {                                  \\\n-            _b = b;                               \\\n-        }                                         \\\n-        LL_UDIVMOD(&(r), 0, _a, _b);              \\\n-        if (_negative)                            \\\n-            LL_NEG(r, r);                         \\\n-    }\n-\n-#define LL_MOD(r, a, b)                           \\\n-    {                                             \\\n-        PRInt64 _a, _b;                           \\\n-        PRUint32 _negative = (PRInt32)(a).hi < 0; \\\n-        if (_negative) {                          \\\n-            LL_NEG(_a, a);                        \\\n-        } else {                                  \\\n-            _a = a;                               \\\n-        }                                         \\\n-        if ((PRInt32)(b).hi < 0) {                \\\n-            LL_NEG(_b, b);                        \\\n-        } else {                                  \\\n-            _b = b;                               \\\n-        }                                         \\\n-        LL_UDIVMOD(0, &(r), _a, _b);              \\\n-        if (_negative)                            \\\n-            LL_NEG(r, r);                         \\\n-    }\n-\n-#define LL_SHL(r, a, b)                                                 \\\n-    {                                                                   \\\n-        if (b) {                                                        \\\n-            PRInt64 _a;                                                 \\\n-            _a = a;                                                     \\\n-            if ((b) < 32) {                                             \\\n-                (r).lo = _a.lo << ((b) & 31);                           \\\n-                (r).hi = (_a.hi << ((b) & 31)) | (_a.lo >> (32 - (b))); \\\n-            } else {                                                    \\\n-                (r).lo = 0;                                             \\\n-                (r).hi = _a.lo << ((b) & 31);                           \\\n-            }                                                           \\\n-        } else {                                                        \\\n-            (r) = (a);                                                  \\\n-        }                                                               \\\n-    }\n+#define LL_IS_ZERO(a)        (((a).hi == 0) && ((a).lo == 0))\n+#define LL_EQ(a, b)        (((a).hi == (b).hi) && ((a).lo == (b).lo))\n+#define LL_NE(a, b)        (((a).hi != (b).hi) || ((a).lo != (b).lo))\n+#define LL_GE_ZERO(a)        (((a).hi >> 31) == 0)\n+\n+#define LL_CMP(a, op, b)    (((a).hi == (b).hi) ? ((a).lo op (b).lo) : \\\n+                 ((PRInt32)(a).hi op (PRInt32)(b).hi))\n+#define LL_UCMP(a, op, b)    (((a).hi == (b).hi) ? ((a).lo op (b).lo) : \\\n+                 ((a).hi op (b).hi))\n+\n+#define LL_AND(r, a, b)        ((r).lo = (a).lo & (b).lo, \\\n+                 (r).hi = (a).hi & (b).hi)\n+#define LL_OR(r, a, b)        ((r).lo = (a).lo | (b).lo, \\\n+                 (r).hi = (a).hi | (b).hi)\n+#define LL_XOR(r, a, b)        ((r).lo = (a).lo ^ (b).lo, \\\n+                 (r).hi = (a).hi ^ (b).hi)\n+#define LL_OR2(r, a)        ((r).lo = (r).lo | (a).lo, \\\n+                 (r).hi = (r).hi | (a).hi)\n+#define LL_NOT(r, a)        ((r).lo = ~(a).lo, \\\n+                 (r).hi = ~(a).hi)\n+\n+#define LL_NEG(r, a)        ((r).lo = -(PRInt32)(a).lo, \\\n+                 (r).hi = -(PRInt32)(a).hi - ((r).lo != 0))\n+#define LL_ADD(r, a, b) { \\\n+    PRInt64 _a, _b; \\\n+    _a = a; _b = b; \\\n+    (r).lo = _a.lo + _b.lo; \\\n+    (r).hi = _a.hi + _b.hi + ((r).lo < _b.lo); \\\n+}\n+\n+#define LL_SUB(r, a, b) { \\\n+    PRInt64 _a, _b; \\\n+    _a = a; _b = b; \\\n+    (r).lo = _a.lo - _b.lo; \\\n+    (r).hi = _a.hi - _b.hi - (_a.lo < _b.lo); \\\n+}\n+\n+#define LL_MUL(r, a, b) { \\\n+    PRInt64 _a, _b; \\\n+    _a = a; _b = b; \\\n+    LL_MUL32(r, _a.lo, _b.lo); \\\n+    (r).hi += _a.hi * _b.lo + _a.lo * _b.hi; \\\n+}\n+\n+#define _lo16(a)        ((a) & PR_BITMASK(16))\n+#define _hi16(a)        ((a) >> 16)\n+\n+#define LL_MUL32(r, a, b) { \\\n+     PRUint32 _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3; \\\n+     _a1 = _hi16(a), _a0 = _lo16(a); \\\n+     _b1 = _hi16(b), _b0 = _lo16(b); \\\n+     _y0 = _a0 * _b0; \\\n+     _y1 = _a0 * _b1; \\\n+     _y2 = _a1 * _b0; \\\n+     _y3 = _a1 * _b1; \\\n+     _y1 += _hi16(_y0);                         /* can't carry */ \\\n+     _y1 += _y2;                                /* might carry */ \\\n+     if (_y1 < _y2)    \\\n+        _y3 += (PRUint32)(PR_BIT(16));  /* propagate */ \\\n+     (r).lo = (_lo16(_y1) << 16) + _lo16(_y0); \\\n+     (r).hi = _y3 + _hi16(_y1); \\\n+}\n+\n+#define LL_UDIVMOD(qp, rp, a, b)    ll_udivmod(qp, rp, a, b)\n+\n+NSPR_API(void) ll_udivmod(PRUint64 *qp, PRUint64 *rp, PRUint64 a, PRUint64 b);\n+\n+#define LL_DIV(r, a, b) { \\\n+    PRInt64 _a, _b; \\\n+    PRUint32 _negative = (PRInt32)(a).hi < 0; \\\n+    if (_negative) { \\\n+    LL_NEG(_a, a); \\\n+    } else { \\\n+    _a = a; \\\n+    } \\\n+    if ((PRInt32)(b).hi < 0) { \\\n+    _negative ^= 1; \\\n+    LL_NEG(_b, b); \\\n+    } else { \\\n+    _b = b; \\\n+    } \\\n+    LL_UDIVMOD(&(r), 0, _a, _b); \\\n+    if (_negative) \\\n+    LL_NEG(r, r); \\\n+}\n+\n+#define LL_MOD(r, a, b) { \\\n+    PRInt64 _a, _b; \\\n+    PRUint32 _negative = (PRInt32)(a).hi < 0; \\\n+    if (_negative) { \\\n+    LL_NEG(_a, a); \\\n+    } else { \\\n+    _a = a; \\\n+    } \\\n+    if ((PRInt32)(b).hi < 0) { \\\n+    LL_NEG(_b, b); \\\n+    } else { \\\n+    _b = b; \\\n+    } \\\n+    LL_UDIVMOD(0, &(r), _a, _b); \\\n+    if (_negative) \\\n+    LL_NEG(r, r); \\\n+}\n+\n+#define LL_SHL(r, a, b) { \\\n+    if (b) { \\\n+    PRInt64 _a; \\\n+        _a = a; \\\n+        if ((b) < 32) { \\\n+        (r).lo = _a.lo << ((b) & 31); \\\n+        (r).hi = (_a.hi << ((b) & 31)) | (_a.lo >> (32 - (b))); \\\n+    } else { \\\n+        (r).lo = 0; \\\n+        (r).hi = _a.lo << ((b) & 31); \\\n+    } \\\n+    } else { \\\n+    (r) = (a); \\\n+    } \\\n+}\n \n /* a is an PRInt32, b is PRInt32, r is PRInt64 */\n-#define LL_ISHL(r, a, b)                      \\\n-    {                                         \\\n-        if (b) {                              \\\n-            PRInt64 _a;                       \\\n-            _a.lo = (a);                      \\\n-            _a.hi = 0;                        \\\n-            if ((b) < 32) {                   \\\n-                (r).lo = (a) << ((b) & 31);   \\\n-                (r).hi = ((a) >> (32 - (b))); \\\n-            } else {                          \\\n-                (r).lo = 0;                   \\\n-                (r).hi = (a) << ((b) & 31);   \\\n-            }                                 \\\n-        } else {                              \\\n-            (r).lo = (a);                     \\\n-            (r).hi = 0;                       \\\n-        }                                     \\\n-    }\n-\n-#define LL_SHR(r, a, b)                                                 \\\n-    {                                                                   \\\n-        if (b) {                                                        \\\n-            PRInt64 _a;                                                 \\\n-            _a = a;                                                     \\\n-            if ((b) < 32) {                                             \\\n-                (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \\\n-                (r).hi = (PRInt32)_a.hi >> ((b) & 31);                  \\\n-            } else {                                                    \\\n-                (r).lo = (PRInt32)_a.hi >> ((b) & 31);                  \\\n-                (r).hi = (PRInt32)_a.hi >> 31;                          \\\n-            }                                                           \\\n-        } else {                                                        \\\n-            (r) = (a);                                                  \\\n-        }                                                               \\\n-    }\n-\n-#define LL_USHR(r, a, b)                                                \\\n-    {                                                                   \\\n-        if (b) {                                                        \\\n-            PRInt64 _a;                                                 \\\n-            _a = a;                                                     \\\n-            if ((b) < 32) {                                             \\\n-                (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \\\n-                (r).hi = _a.hi >> ((b) & 31);                           \\\n-            } else {                                                    \\\n-                (r).lo = _a.hi >> ((b) & 31);                           \\\n-                (r).hi = 0;                                             \\\n-            }                                                           \\\n-        } else {                                                        \\\n-            (r) = (a);                                                  \\\n-        }                                                               \\\n-    }\n-\n-#define LL_L2I(i, l) ((i) = (l).lo)\n-#define LL_L2UI(ui, l) ((ui) = (l).lo)\n-#define LL_L2F(f, l)         \\\n-    {                        \\\n-        double _d;           \\\n-        LL_L2D(_d, l);       \\\n-        (f) = (PRFloat64)_d; \\\n-    }\n-\n-#define LL_L2D(d, l)                                           \\\n-    {                                                          \\\n-        int _negative;                                         \\\n-        PRInt64 _absval;                                       \\\n-                                                               \\\n-        _negative = (l).hi >> 31;                              \\\n-        if (_negative) {                                       \\\n-            LL_NEG(_absval, l);                                \\\n-        } else {                                               \\\n-            _absval = l;                                       \\\n-        }                                                      \\\n-        (d) = (double)_absval.hi * 4.294967296e9 + _absval.lo; \\\n-        if (_negative)                                         \\\n-            (d) = -(d);                                        \\\n-    }\n-\n-#define LL_I2L(l, i)                       \\\n-    {                                      \\\n-        PRInt32 _i = ((PRInt32)(i)) >> 31; \\\n-        (l).lo = (i);                      \\\n-        (l).hi = _i;                       \\\n-    }\n-#define LL_UI2L(l, ui) ((l).lo = (ui), (l).hi = 0)\n-#define LL_F2L(l, f)           \\\n-    {                          \\\n-        double _d = (double)f; \\\n-        LL_D2L(l, _d);         \\\n-    }\n-\n-#define LL_D2L(l, d)                      \\\n-    {                                     \\\n-        int _negative;                    \\\n-        double _absval, _d_hi;            \\\n-        PRInt64 _lo_d;                    \\\n-                                          \\\n-        _negative = ((d) < 0);            \\\n-        _absval = _negative ? -(d) : (d); \\\n-                                          \\\n-        (l).hi = _absval / 4.294967296e9; \\\n-        (l).lo = 0;                       \\\n-        LL_L2D(_d_hi, l);                 \\\n-        _absval -= _d_hi;                 \\\n-        _lo_d.hi = 0;                     \\\n-        if (_absval < 0) {                \\\n-            _lo_d.lo = -_absval;          \\\n-            LL_SUB(l, l, _lo_d);          \\\n-        } else {                          \\\n-            _lo_d.lo = _absval;           \\\n-            LL_ADD(l, l, _lo_d);          \\\n-        }                                 \\\n-                                          \\\n-        if (_negative)                    \\\n-            LL_NEG(l, l);                 \\\n-    }\n+#define LL_ISHL(r, a, b) { \\\n+    if (b) { \\\n+    PRInt64 _a; \\\n+    _a.lo = (a); \\\n+    _a.hi = 0; \\\n+        if ((b) < 32) { \\\n+        (r).lo = (a) << ((b) & 31); \\\n+        (r).hi = ((a) >> (32 - (b))); \\\n+    } else { \\\n+        (r).lo = 0; \\\n+        (r).hi = (a) << ((b) & 31); \\\n+    } \\\n+    } else { \\\n+    (r).lo = (a); \\\n+    (r).hi = 0; \\\n+    } \\\n+}\n+\n+#define LL_SHR(r, a, b) { \\\n+    if (b) { \\\n+    PRInt64 _a; \\\n+        _a = a; \\\n+    if ((b) < 32) { \\\n+        (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \\\n+        (r).hi = (PRInt32)_a.hi >> ((b) & 31); \\\n+    } else { \\\n+        (r).lo = (PRInt32)_a.hi >> ((b) & 31); \\\n+        (r).hi = (PRInt32)_a.hi >> 31; \\\n+    } \\\n+    } else { \\\n+    (r) = (a); \\\n+    } \\\n+}\n+\n+#define LL_USHR(r, a, b) { \\\n+    if (b) { \\\n+    PRInt64 _a; \\\n+        _a = a; \\\n+    if ((b) < 32) { \\\n+        (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \\\n+        (r).hi = _a.hi >> ((b) & 31); \\\n+    } else { \\\n+        (r).lo = _a.hi >> ((b) & 31); \\\n+        (r).hi = 0; \\\n+    } \\\n+    } else { \\\n+    (r) = (a); \\\n+    } \\\n+}\n+\n+#define LL_L2I(i, l)        ((i) = (l).lo)\n+#define LL_L2UI(ui, l)        ((ui) = (l).lo)\n+#define LL_L2F(f, l)        { double _d; LL_L2D(_d, l); (f) = (PRFloat64)_d; }\n+\n+#define LL_L2D(d, l) { \\\n+    int _negative; \\\n+    PRInt64 _absval; \\\n+ \\\n+    _negative = (l).hi >> 31; \\\n+    if (_negative) { \\\n+    LL_NEG(_absval, l); \\\n+    } else { \\\n+    _absval = l; \\\n+    } \\\n+    (d) = (double)_absval.hi * 4.294967296e9 + _absval.lo; \\\n+    if (_negative) \\\n+    (d) = -(d); \\\n+}\n+\n+#define LL_I2L(l, i)        { PRInt32 _i = ((PRInt32)(i)) >> 31; (l).lo = (i); (l).hi = _i; }\n+#define LL_UI2L(l, ui)      ((l).lo = (ui), (l).hi = 0)\n+#define LL_F2L(l, f)        { double _d = (double)f; LL_D2L(l, _d); }\n+\n+#define LL_D2L(l, d) { \\\n+    int _negative; \\\n+    double _absval, _d_hi; \\\n+    PRInt64 _lo_d; \\\n+ \\\n+    _negative = ((d) < 0); \\\n+    _absval = _negative ? -(d) : (d); \\\n+ \\\n+    (l).hi = _absval / 4.294967296e9; \\\n+    (l).lo = 0; \\\n+    LL_L2D(_d_hi, l); \\\n+    _absval -= _d_hi; \\\n+    _lo_d.hi = 0; \\\n+    if (_absval < 0) { \\\n+    _lo_d.lo = -_absval; \\\n+    LL_SUB(l, l, _lo_d); \\\n+    } else { \\\n+    _lo_d.lo = _absval; \\\n+    LL_ADD(l, l, _lo_d); \\\n+    } \\\n+ \\\n+    if (_negative) \\\n+    LL_NEG(l, l); \\\n+}\n \n #endif /* !HAVE_LONG_LONG */\n \ndiff --git a/nspr/pr/include/prmem.h b/nspr/pr/include/prmem.h\nindex a05b09d..ed9a428 100644\n--- a/nspr/pr/include/prmem.h\n+++ b/nspr/pr/include/prmem.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -30,17 +31,13 @@ PR_BEGIN_EXTERN_C\n ** must be freed by PR_Free.\n */\n \n-NSPR_API(void*)\n-PR_Malloc(PRUint32 size);\n+NSPR_API(void *) PR_Malloc(PRUint32 size);\n \n-NSPR_API(void*)\n-PR_Calloc(PRUint32 nelem, PRUint32 elsize);\n+NSPR_API(void *) PR_Calloc(PRUint32 nelem, PRUint32 elsize);\n \n-NSPR_API(void*)\n-PR_Realloc(void* ptr, PRUint32 size);\n+NSPR_API(void *) PR_Realloc(void *ptr, PRUint32 size);\n \n-NSPR_API(void)\n-PR_Free(void* ptr);\n+NSPR_API(void) PR_Free(void *ptr);\n \n /*\n ** The following are some convenience macros defined in terms of\n@@ -65,7 +62,7 @@ PR_Free(void* ptr);\n ** OUTPUTS: pointer to _struct\n ** RETURN:  pointer to _struct or error returns from malloc().\n ***********************************************************************/\n-#define PR_NEW(_struct) ((_struct*)PR_MALLOC(sizeof(_struct)))\n+#define PR_NEW(_struct) ((_struct *) PR_MALLOC(sizeof(_struct)))\n \n /***********************************************************************\n ** FUNCTION:    PR_REALLOC()\n@@ -110,11 +107,7 @@ PR_Free(void* ptr);\n ** OUTPUTS: the referenced object is returned to the heap\n ** RETURN:  void\n ***********************************************************************/\n-#define PR_DELETE(_ptr) \\\n-    {                   \\\n-        PR_Free(_ptr);  \\\n-        (_ptr) = NULL;  \\\n-    }\n+#define PR_DELETE(_ptr) { PR_Free(_ptr); (_ptr) = NULL; }\n \n /***********************************************************************\n ** FUNCTION:    PR_FREEIF()\n@@ -126,9 +119,7 @@ PR_Free(void* ptr);\n ** OUTPUTS: the referenced object is conditionally returned to the heap\n ** RETURN:  void\n ***********************************************************************/\n-#define PR_FREEIF(_ptr) \\\n-    if (_ptr)           \\\n-    PR_DELETE(_ptr)\n+#define PR_FREEIF(_ptr) if (_ptr) PR_DELETE(_ptr)\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prmon.h b/nspr/pr/include/prmon.h\nindex c234f2d..374e298 100644\n--- a/nspr/pr/include/prmon.h\n+++ b/nspr/pr/include/prmon.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -19,8 +20,7 @@ typedef struct PRMonitor PRMonitor;\n ** This may fail if memory is tight or if some operating system resource\n ** is low.\n */\n-NSPR_API(PRMonitor*)\n-PR_NewMonitor(void);\n+NSPR_API(PRMonitor*) PR_NewMonitor(void);\n \n /*\n ** Destroy a monitor. The caller is responsible for guaranteeing that the\n@@ -28,24 +28,21 @@ PR_NewMonitor(void);\n ** condition variable and that the lock is not held.\n **\n */\n-NSPR_API(void)\n-PR_DestroyMonitor(PRMonitor* mon);\n+NSPR_API(void) PR_DestroyMonitor(PRMonitor *mon);\n \n /*\n ** Enter the lock associated with the monitor. If the calling thread currently\n ** is in the monitor, the call to enter will silently succeed. In either case,\n ** it will increment the entry count by one.\n */\n-NSPR_API(void)\n-PR_EnterMonitor(PRMonitor* mon);\n+NSPR_API(void) PR_EnterMonitor(PRMonitor *mon);\n \n /*\n ** Decrement the entry count associated with the monitor. If the decremented\n ** entry count is zero, the monitor is exited. Returns PR_FAILURE if the\n ** calling thread has not entered the monitor.\n */\n-NSPR_API(PRStatus)\n-PR_ExitMonitor(PRMonitor* mon);\n+NSPR_API(PRStatus) PR_ExitMonitor(PRMonitor *mon);\n \n /*\n ** Wait for a notify on the monitor's condition variable. Sleep for \"ticks\"\n@@ -63,24 +60,21 @@ PR_ExitMonitor(PRMonitor* mon);\n **\n ** Returns PR_FAILURE if the caller has not entered the monitor.\n */\n-NSPR_API(PRStatus)\n-PR_Wait(PRMonitor* mon, PRIntervalTime ticks);\n+NSPR_API(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime ticks);\n \n /*\n ** Notify a thread waiting on the monitor's condition variable. If a thread\n ** is waiting on the condition variable (using PR_Wait) then it is awakened\n ** and attempts to reenter the monitor.\n */\n-NSPR_API(PRStatus)\n-PR_Notify(PRMonitor* mon);\n+NSPR_API(PRStatus) PR_Notify(PRMonitor *mon);\n \n /*\n ** Notify all of the threads waiting on the monitor's condition variable.\n ** All of threads waiting on the condition are scheduled to reenter the\n ** monitor.\n */\n-NSPR_API(PRStatus)\n-PR_NotifyAll(PRMonitor* mon);\n+NSPR_API(PRStatus) PR_NotifyAll(PRMonitor *mon);\n \n /*\n ** PR_ASSERT_CURRENT_THREAD_IN_MONITOR\n@@ -95,8 +89,7 @@ PR_NotifyAll(PRMonitor* mon);\n #endif\n \n /* Don't call this function directly. */\n-NSPR_API(void)\n-PR_AssertCurrentThreadInMonitor(PRMonitor* mon);\n+NSPR_API(void) PR_AssertCurrentThreadInMonitor(PRMonitor *mon);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prmwait.h b/nspr/pr/include/prmwait.h\nindex 118d4fc..16c0762 100644\n--- a/nspr/pr/include/prmwait.h\n+++ b/nspr/pr/include/prmwait.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -15,17 +16,13 @@ PR_BEGIN_EXTERN_C\n /********************************************************************************/\n /********************************************************************************/\n /********************************************************************************/\n-/******************************       WARNING ****************************/\n+/******************************       WARNING        ****************************/\n /********************************************************************************/\n-/**************************** This is work in progress.\n- * *************************/\n-/************************** Do not make any assumptions\n- * *************************/\n-/************************** about the stability of this\n- * *************************/\n-/************************** API or the underlying imple-\n- * ************************/\n-/************************** mentation. ************************/\n+/**************************** This is work in progress. *************************/\n+/************************** Do not make any assumptions *************************/\n+/************************** about the stability of this *************************/\n+/************************** API or the underlying imple- ************************/\n+/************************** mentation.                   ************************/\n /********************************************************************************/\n /********************************************************************************/\n \n@@ -61,7 +58,8 @@ typedef struct PRWaitGroup PRWaitGroup;\n **                      calling PR_CancelWaitFileDesc() or destroying the\n **                      entire wait group (PR_DestroyWaitGroup()).\n */\n-typedef enum PRMWStatus {\n+typedef enum PRMWStatus\n+{\n     PR_MW_PENDING = 1,\n     PR_MW_SUCCESS = 0,\n     PR_MW_FAILURE = -1,\n@@ -76,9 +74,10 @@ typedef enum PRMWStatus {\n **      pointer to the first byte of that memory and the length (in\n **      bytes) of the interval.\n */\n-typedef struct PRMemoryDescriptor {\n-    void* start;   /* pointer to first byte of memory */\n-    PRSize length; /* length (in bytes) of memory interval */\n+typedef struct PRMemoryDescriptor\n+{\n+    void *start;                /* pointer to first byte of memory */\n+    PRSize length;              /* length (in bytes) of memory interval */\n } PRMemoryDescriptor;\n \n /*\n@@ -106,16 +105,17 @@ typedef struct PRMWaitClientData PRMWaitClientData;\n **      in the caller's address space where data from an initial read\n **      can be placed. The description may indicate a null interval.\n */\n-typedef struct PRRecvWait {\n-    PRCList internal; /* internal runtime linkages */\n+typedef struct PRRecvWait\n+{\n+    PRCList internal;           /* internal runtime linkages */\n \n-    PRFileDesc* fd;         /* file descriptor associated w/ object */\n-    PRMWStatus outcome;     /* outcome of the current/last operation */\n-    PRIntervalTime timeout; /* time allowed for entire operation */\n+    PRFileDesc *fd;             /* file descriptor associated w/ object */\n+    PRMWStatus outcome;         /* outcome of the current/last operation */\n+    PRIntervalTime timeout;     /* time allowed for entire operation */\n \n-    PRInt32 bytesRecv;         /* number of bytes transferred into buffer */\n-    PRMemoryDescriptor buffer; /* where to store first segment of input data */\n-    PRMWaitClientData* client; /* pointer to arbitrary client defined data */\n+    PRInt32 bytesRecv;          /* number of bytes transferred into buffer */\n+    PRMemoryDescriptor buffer;  /* where to store first segment of input data */\n+    PRMWaitClientData *client;  /* pointer to arbitrary client defined data */\n } PRRecvWait;\n \n /*\n@@ -129,6 +129,7 @@ typedef struct PRRecvWait {\n */\n typedef struct PRMWaitEnumerator PRMWaitEnumerator;\n \n+\n /*\n ** FUNCTION:    PR_AddWaitFileDesc\n ** DESCRIPTION:\n@@ -160,8 +161,7 @@ typedef struct PRMWaitEnumerator PRMWaitEnumerator;\n **      PR_INVALID_STATE_ERROR\n **                  The group is being destroyed.\n */\n-NSPR_API(PRStatus)\n-PR_AddWaitFileDesc(PRWaitGroup* group, PRRecvWait* desc);\n+NSPR_API(PRStatus) PR_AddWaitFileDesc(PRWaitGroup *group, PRRecvWait *desc);\n \n /*\n ** FUNCTION:    PR_WaitRecvReady\n@@ -195,8 +195,7 @@ PR_AddWaitFileDesc(PRWaitGroup* group, PRRecvWait* desc);\n **      PR_INVALID_STATE_ERROR\n **                  The group is being destroyed.\n */\n-NSPR_API(PRRecvWait*)\n-PR_WaitRecvReady(PRWaitGroup* group);\n+NSPR_API(PRRecvWait*) PR_WaitRecvReady(PRWaitGroup *group);\n \n /*\n ** FUNCTION:    PR_CancelWaitFileDesc\n@@ -231,8 +230,7 @@ PR_WaitRecvReady(PRWaitGroup* group);\n **      PR_INVALID_STATE_ERROR\n **                  The group is being destroyed.\n */\n-NSPR_API(PRStatus)\n-PR_CancelWaitFileDesc(PRWaitGroup* group, PRRecvWait* desc);\n+NSPR_API(PRStatus) PR_CancelWaitFileDesc(PRWaitGroup *group, PRRecvWait *desc);\n \n /*\n ** FUNCTION:    PR_CancelWaitGroup\n@@ -259,8 +257,7 @@ PR_CancelWaitFileDesc(PRWaitGroup* group, PRRecvWait* desc);\n **      PR_INVALID_ARGUMENT_ERROR\n **      PR_GROUP_EMPTY_ERROR\n */\n-NSPR_API(PRRecvWait*)\n-PR_CancelWaitGroup(PRWaitGroup* group);\n+NSPR_API(PRRecvWait*) PR_CancelWaitGroup(PRWaitGroup *group);\n \n /*\n ** FUNCTION:    PR_CreateWaitGroup\n@@ -287,8 +284,7 @@ PR_CancelWaitGroup(PRWaitGroup* group);\n **  ERRORS\n **      PR_OUT_OF_MEMORY_ERROR\n */\n-NSPR_API(PRWaitGroup*)\n-PR_CreateWaitGroup(PRInt32 size);\n+NSPR_API(PRWaitGroup*) PR_CreateWaitGroup(PRInt32 size);\n \n /*\n ** FUNCTION:    PR_DestroyWaitGroup\n@@ -311,8 +307,7 @@ PR_CreateWaitGroup(PRInt32 size);\n **      PR_INVALID_STATE_ERROR\n **                  The group still contains receive wait objects.\n */\n-NSPR_API(PRStatus)\n-PR_DestroyWaitGroup(PRWaitGroup* group);\n+NSPR_API(PRStatus) PR_DestroyWaitGroup(PRWaitGroup *group);\n \n /*\n ** FUNCTION:    PR_CreateMWaitEnumerator\n@@ -334,8 +329,7 @@ PR_DestroyWaitGroup(PRWaitGroup* group);\n **                  The 'group' argument does not reference a known object.\n **      PR_OUT_OF_MEMORY_ERROR\n */\n-NSPR_API(PRMWaitEnumerator*)\n-PR_CreateMWaitEnumerator(PRWaitGroup* group);\n+NSPR_API(PRMWaitEnumerator*) PR_CreateMWaitEnumerator(PRWaitGroup *group);\n \n /*\n ** FUNCTION:    PR_DestroyMWaitEnumerator\n@@ -353,8 +347,7 @@ PR_CreateMWaitEnumerator(PRWaitGroup* group);\n **      PR_INVALID_ARGUMENT_ERROR\n **                  The enumerator is invalid.\n */\n-NSPR_API(PRStatus)\n-PR_DestroyMWaitEnumerator(PRMWaitEnumerator* enumerator);\n+NSPR_API(PRStatus) PR_DestroyMWaitEnumerator(PRMWaitEnumerator* enumerator);\n \n /*\n ** FUNCTION:    PR_EnumerateWaitGroup\n@@ -377,9 +370,8 @@ PR_DestroyMWaitEnumerator(PRMWaitEnumerator* enumerator);\n **      An enumeration may be abandoned at any time. The runtime is not\n **      keeping any state, so there are no issues in that regard.\n */\n-NSPR_API(PRRecvWait*)\n-PR_EnumerateWaitGroup(PRMWaitEnumerator* enumerator,\n-                      const PRRecvWait* previous);\n+NSPR_API(PRRecvWait*) PR_EnumerateWaitGroup(\n+    PRMWaitEnumerator *enumerator, const PRRecvWait *previous);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prnetdb.h b/nspr/pr/include/prnetdb.h\nindex ed5dda0..023a46e 100644\n--- a/nspr/pr/include/prnetdb.h\n+++ b/nspr/pr/include/prnetdb.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,16 +11,17 @@\n \n PR_BEGIN_EXTERN_C\n \n+\n /*\n  *********************************************************************\n  *  Translate an Internet address to/from a character string\n  *********************************************************************\n  */\n-NSPR_API(PRStatus)\n-PR_StringToNetAddr(const char* string, PRNetAddr* addr);\n+NSPR_API(PRStatus) PR_StringToNetAddr(\n+    const char *string, PRNetAddr *addr);\n \n-NSPR_API(PRStatus)\n-PR_NetAddrToString(const PRNetAddr* addr, char* string, PRUint32 size);\n+NSPR_API(PRStatus) PR_NetAddrToString(\n+    const PRNetAddr *addr, char *string, PRUint32 size);\n \n /*\n ** Structures returned by network data base library.  All addresses are\n@@ -32,8 +34,8 @@ PR_NetAddrToString(const PRNetAddr* addr, char* string, PRUint32 size);\n ** hence the ifdef.\n */\n typedef struct PRHostEnt {\n-    char* h_name;     /* official name of host */\n-    char** h_aliases; /* alias list */\n+    char *h_name;       /* official name of host */\n+    char **h_aliases;   /* alias list */\n #ifdef WIN32\n     PRInt16 h_addrtype; /* host address type */\n     PRInt16 h_length;   /* length of address */\n@@ -41,7 +43,7 @@ typedef struct PRHostEnt {\n     PRInt32 h_addrtype; /* host address type */\n     PRInt32 h_length;   /* length of address */\n #endif\n-    char** h_addr_list; /* list of addresses from name server */\n+    char **h_addr_list; /* list of addresses from name server */\n } PRHostEnt;\n \n /* A safe size to use that will mostly work... */\n@@ -77,9 +79,8 @@ typedef struct PRHostEnt {\n **                      the result will be PR_FAILURE and the reason\n **                      for the failure can be retrieved by PR_GetError().\n ***********************************************************************/\n-NSPR_API(PRStatus)\n-PR_GetHostByName(const char* hostname, char* buf, PRIntn bufsize,\n-                 PRHostEnt* hostentry);\n+NSPR_API(PRStatus) PR_GetHostByName(\n+    const char *hostname, char *buf, PRIntn bufsize, PRHostEnt *hostentry);\n \n /***********************************************************************\n ** FUNCTION:\n@@ -108,15 +109,20 @@ PR_GetHostByName(const char* hostname, char* buf, PRIntn bufsize,\n **                      for the failure can be retrieved by PR_GetError().\n ***********************************************************************/\n \n-#define PR_AI_ALL 0x08\n-#define PR_AI_V4MAPPED 0x10\n-#define PR_AI_ADDRCONFIG 0x20\n+\n+#define PR_AI_ALL         0x08\n+#define PR_AI_V4MAPPED    0x10\n+#define PR_AI_ADDRCONFIG  0x20\n #define PR_AI_NOCANONNAME 0x8000\n-#define PR_AI_DEFAULT (PR_AI_V4MAPPED | PR_AI_ADDRCONFIG)\n+#define PR_AI_DEFAULT     (PR_AI_V4MAPPED | PR_AI_ADDRCONFIG)\n \n-NSPR_API(PRStatus)\n-PR_GetIPNodeByName(const char* hostname, PRUint16 af, PRIntn flags, char* buf,\n-                   PRIntn bufsize, PRHostEnt* hostentry);\n+NSPR_API(PRStatus) PR_GetIPNodeByName(\n+    const char *hostname,\n+    PRUint16 af,\n+    PRIntn flags,\n+    char *buf,\n+    PRIntn bufsize,\n+    PRHostEnt *hostentry);\n \n /***********************************************************************\n ** FUNCTION:\n@@ -139,9 +145,8 @@ PR_GetIPNodeByName(const char* hostname, PRUint16 af, PRIntn flags, char* buf,\n **                      the result will be PR_FAILURE and the reason\n **                      for the failure can be retrieved by PR_GetError().\n ***********************************************************************/\n-NSPR_API(PRStatus)\n-PR_GetHostByAddr(const PRNetAddr* hostaddr, char* buf, PRIntn bufsize,\n-                 PRHostEnt* hostentry);\n+NSPR_API(PRStatus) PR_GetHostByAddr(\n+    const PRNetAddr *hostaddr, char *buf, PRIntn bufsize, PRHostEnt *hostentry);\n \n /***********************************************************************\n ** FUNCTION:    PR_EnumerateHostEnt()\n@@ -174,9 +179,8 @@ PR_GetHostByAddr(const PRNetAddr* hostaddr, char* buf, PRIntn bufsize,\n **                      has failed. The reason for the failure can be\n **                      retrieved by calling PR_GetError().\n ***********************************************************************/\n-NSPR_API(PRIntn)\n-PR_EnumerateHostEnt(PRIntn enumIndex, const PRHostEnt* hostEnt, PRUint16 port,\n-                    PRNetAddr* address);\n+NSPR_API(PRIntn) PR_EnumerateHostEnt(\n+    PRIntn enumIndex, const PRHostEnt *hostEnt, PRUint16 port, PRNetAddr *address);\n \n /***********************************************************************\n ** FUNCTION: PR_InitializeNetAddr(),\n@@ -200,15 +204,16 @@ PR_EnumerateHostEnt(PRIntn enumIndex, const PRHostEnt* hostEnt, PRUint16 port,\n **                      reason for the failure can be retrieved by calling\n **                      PR_GetError();\n ***********************************************************************/\n-typedef enum PRNetAddrValue {\n-    PR_IpAddrNull,     /* do NOT overwrite the IP address */\n-    PR_IpAddrAny,      /* assign logical INADDR_ANY to IP address */\n-    PR_IpAddrLoopback, /* assign logical INADDR_LOOPBACK  */\n-    PR_IpAddrV4Mapped  /* IPv4 mapped address */\n+typedef enum PRNetAddrValue\n+{\n+    PR_IpAddrNull,      /* do NOT overwrite the IP address */\n+    PR_IpAddrAny,       /* assign logical INADDR_ANY to IP address */\n+    PR_IpAddrLoopback,  /* assign logical INADDR_LOOPBACK  */\n+    PR_IpAddrV4Mapped   /* IPv4 mapped address */\n } PRNetAddrValue;\n \n-NSPR_API(PRStatus)\n-PR_InitializeNetAddr(PRNetAddrValue val, PRUint16 port, PRNetAddr* addr);\n+NSPR_API(PRStatus) PR_InitializeNetAddr(\n+    PRNetAddrValue val, PRUint16 port, PRNetAddr *addr);\n \n /***********************************************************************\n ** FUNCTION: PR_SetNetAddr(),\n@@ -235,8 +240,8 @@ PR_InitializeNetAddr(PRNetAddrValue val, PRUint16 port, PRNetAddr* addr);\n **                      reason for the failure can be retrieved by calling\n **                      PR_GetError();\n ***********************************************************************/\n-NSPR_API(PRStatus)\n-PR_SetNetAddr(PRNetAddrValue val, PRUint16 af, PRUint16 port, PRNetAddr* addr);\n+NSPR_API(PRStatus) PR_SetNetAddr(\n+    PRNetAddrValue val, PRUint16 af, PRUint16 port, PRNetAddr *addr);\n \n /***********************************************************************\n ** FUNCTION:\n@@ -251,8 +256,7 @@ PR_SetNetAddr(PRNetAddrValue val, PRUint16 af, PRUint16 port, PRNetAddr* addr);\n **  PRBool                  PR_TRUE if the network address is of the\n **                          specified type, else PR_FALSE.\n ***********************************************************************/\n-NSPR_API(PRBool)\n-PR_IsNetAddrType(const PRNetAddr* addr, PRNetAddrValue val);\n+NSPR_API(PRBool) PR_IsNetAddrType(const PRNetAddr *addr, PRNetAddrValue val);\n \n /***********************************************************************\n ** FUNCTION:\n@@ -269,8 +273,7 @@ PR_IsNetAddrType(const PRNetAddr* addr, PRNetAddrValue val);\n **  void\n **\n ***********************************************************************/\n-NSPR_API(void)\n-PR_ConvertIPv4AddrToIPv6(PRUint32 v4addr, PRIPv6Addr* v6addr);\n+NSPR_API(void) PR_ConvertIPv4AddrToIPv6(PRUint32 v4addr, PRIPv6Addr *v6addr);\n \n /***********************************************************************\n ** MACRO:\n@@ -322,18 +325,17 @@ PR_ConvertIPv4AddrToIPv6(PRUint32 v4addr, PRIPv6Addr* v6addr);\n ***********************************************************************/\n \n typedef struct PRProtoEnt {\n-    char* p_name;     /* official protocol name */\n-    char** p_aliases; /* alias list */\n+    char *p_name;       /* official protocol name */\n+    char **p_aliases;   /* alias list */\n #ifdef WIN32\n-    PRInt16 p_num; /* protocol # */\n+    PRInt16 p_num;      /* protocol # */\n #else\n-    PRInt32 p_num; /* protocol # */\n+    PRInt32 p_num;      /* protocol # */\n #endif\n } PRProtoEnt;\n \n-NSPR_API(PRStatus)\n-PR_GetProtoByName(const char* protocolname, char* buffer, PRInt32 bufsize,\n-                  PRProtoEnt* result);\n+NSPR_API(PRStatus) PR_GetProtoByName(\n+    const char* protocolname, char* buffer, PRInt32 bufsize, PRProtoEnt* result);\n \n /***********************************************************************\n ** FUNCTION:\n@@ -357,9 +359,8 @@ PR_GetProtoByName(const char* protocolname, char* buffer, PRInt32 bufsize,\n **                      the result will be PR_FAILURE and the reason\n **                      for the failure can be retrieved by PR_GetError().\n ***********************************************************************/\n-NSPR_API(PRStatus)\n-PR_GetProtoByNumber(PRInt32 protocolnumber, char* buffer, PRInt32 bufsize,\n-                    PRProtoEnt* result);\n+NSPR_API(PRStatus) PR_GetProtoByNumber(\n+    PRInt32 protocolnumber, char* buffer, PRInt32 bufsize, PRProtoEnt* result);\n \n /***********************************************************************\n ** FUNCTION:\n@@ -384,8 +385,8 @@ PR_GetProtoByNumber(PRInt32 protocolnumber, char* buffer, PRInt32 bufsize,\n ***********************************************************************/\n typedef struct PRAddrInfo PRAddrInfo;\n \n-NSPR_API(PRAddrInfo*)\n-PR_GetAddrInfoByName(const char* hostname, PRUint16 af, PRIntn flags);\n+NSPR_API(PRAddrInfo*) PR_GetAddrInfoByName(\n+    const char *hostname, PRUint16 af, PRIntn flags);\n \n /***********************************************************************\n ** FUNCTION:\n@@ -399,8 +400,7 @@ PR_GetAddrInfoByName(const char* hostname, PRUint16 af, PRIntn flags);\n ** RETURN:\n **  void\n ***********************************************************************/\n-NSPR_API(void)\n-PR_FreeAddrInfo(PRAddrInfo* addrInfo);\n+NSPR_API(void) PR_FreeAddrInfo(PRAddrInfo *addrInfo);\n \n /***********************************************************************\n ** FUNCTION:\n@@ -425,12 +425,11 @@ PR_FreeAddrInfo(PRAddrInfo* addrInfo);\n **                      of the enumerator ('enumPtr'). The enumeration\n **                      is ended if this value is NULL.\n ***********************************************************************/\n-NSPR_API(void*)\n-PR_EnumerateAddrInfo(void* enumPtr, const PRAddrInfo* addrInfo, PRUint16 port,\n-                     PRNetAddr* result);\n+NSPR_API(void *) PR_EnumerateAddrInfo(\n+    void *enumPtr, const PRAddrInfo *addrInfo, PRUint16 port, PRNetAddr *result);\n \n-NSPR_API(PRStatus)\n-PR_GetPrefLoopbackAddrInfo(PRNetAddr* result, PRUint16 port);\n+NSPR_API(PRStatus) PR_GetPrefLoopbackAddrInfo(PRNetAddr *result,\n+                                              PRUint16 port);\n \n /***********************************************************************\n ** FUNCTION:\n@@ -448,8 +447,8 @@ PR_GetPrefLoopbackAddrInfo(PRNetAddr* result, PRUint16 port);\n **                      invalidated once the PRAddrInfo handle is destroyed\n **                      by a call to PR_FreeAddrInfo().\n ***********************************************************************/\n-NSPR_API(const char*)\n-PR_GetCanonNameFromAddrInfo(const PRAddrInfo* addrInfo);\n+NSPR_API(const char *) PR_GetCanonNameFromAddrInfo(\n+    const PRAddrInfo *addrInfo);\n \n /***********************************************************************\n ** FUNCTIONS: PR_ntohs, PR_ntohl, PR_ntohll, PR_htons, PR_htonl, PR_htonll\n@@ -464,18 +463,12 @@ PR_GetCanonNameFromAddrInfo(const PRAddrInfo* addrInfo);\n **      PR_ntonll       64 bit conversion from host to network\n **\n ***********************************************************************/\n-NSPR_API(PRUint16)\n-PR_ntohs(PRUint16);\n-NSPR_API(PRUint32)\n-PR_ntohl(PRUint32);\n-NSPR_API(PRUint64)\n-PR_ntohll(PRUint64);\n-NSPR_API(PRUint16)\n-PR_htons(PRUint16);\n-NSPR_API(PRUint32)\n-PR_htonl(PRUint32);\n-NSPR_API(PRUint64)\n-PR_htonll(PRUint64);\n+NSPR_API(PRUint16) PR_ntohs(PRUint16);\n+NSPR_API(PRUint32) PR_ntohl(PRUint32);\n+NSPR_API(PRUint64) PR_ntohll(PRUint64);\n+NSPR_API(PRUint16) PR_htons(PRUint16);\n+NSPR_API(PRUint32) PR_htonl(PRUint32);\n+NSPR_API(PRUint64) PR_htonll(PRUint64);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prolock.h b/nspr/pr/include/prolock.h\nindex eaa9bdd..7b57b3c 100644\n--- a/nspr/pr/include/prolock.h\n+++ b/nspr/pr/include/prolock.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -49,7 +50,7 @@ PR_BEGIN_EXTERN_C\n */\n \n #if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS)\n-typedef void* PROrderedLock;\n+typedef void * PROrderedLock;\n #else\n /*\n ** Map PROrderedLock and methods onto PRLock when ordered locking\n@@ -78,14 +79,17 @@ typedef PRLock PROrderedLock;\n **\n */\n #if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS)\n-#define PR_CREATE_ORDERED_LOCK(order, name) \\\n-    PR_CreateOrderedLock((order), (name))\n+#define PR_CREATE_ORDERED_LOCK(order,name)\\\n+    PR_CreateOrderedLock((order),(name))\n #else\n #define PR_CREATE_ORDERED_LOCK(order) PR_NewLock()\n #endif\n \n-NSPR_API(PROrderedLock*)\n-PR_CreateOrderedLock(PRInt32 order, const char* name);\n+NSPR_API(PROrderedLock *)\n+PR_CreateOrderedLock(\n+    PRInt32 order,\n+    const char *name\n+);\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_DestroyOrderedLock() -- Destroy an Ordered Lock\n@@ -109,7 +113,9 @@ PR_CreateOrderedLock(PRInt32 order, const char* name);\n #endif\n \n NSPR_API(void)\n-PR_DestroyOrderedLock(PROrderedLock* lock);\n+PR_DestroyOrderedLock(\n+    PROrderedLock *lock\n+);\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_LockOrderedLock() -- Lock an ordered lock\n@@ -135,7 +141,9 @@ PR_DestroyOrderedLock(PROrderedLock* lock);\n #endif\n \n NSPR_API(void)\n-PR_LockOrderedLock(PROrderedLock* lock);\n+PR_LockOrderedLock(\n+    PROrderedLock *lock\n+);\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_UnlockOrderedLock() -- unlock and Ordered Lock\n@@ -161,7 +169,9 @@ PR_LockOrderedLock(PROrderedLock* lock);\n #endif\n \n NSPR_API(PRStatus)\n-PR_UnlockOrderedLock(PROrderedLock* lock);\n+PR_UnlockOrderedLock(\n+    PROrderedLock *lock\n+);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prpdce.h b/nspr/pr/include/prpdce.h\nindex e333be1..bf9ea9e 100644\n--- a/nspr/pr/include/prpdce.h\n+++ b/nspr/pr/include/prpdce.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -29,8 +30,7 @@ PR_BEGIN_EXTERN_C\n ** already held, by another thread or this thread, the\n ** result will be PR_FAILURE.\n */\n-NSPR_API(PRStatus)\n-PRP_TryLock(PRLock* lock);\n+NSPR_API(PRStatus) PRP_TryLock(PRLock *lock);\n \n /*\n ** Create a naked condition variable\n@@ -40,16 +40,14 @@ PRP_TryLock(PRLock* lock);\n ** that may be used in the subsequent \"naked\" condition variable\n ** operations (see PRP_NakedWait, PRP_NakedNotify, PRP_NakedBroadcast);\n */\n-NSPR_API(PRCondVar*)\n-PRP_NewNakedCondVar(void);\n+NSPR_API(PRCondVar*) PRP_NewNakedCondVar(void);\n \n /*\n ** Destroy a naked condition variable\n **\n ** Destroy the condition variable created by PR_NewNakedCondVar.\n */\n-NSPR_API(void)\n-PRP_DestroyNakedCondVar(PRCondVar* cvar);\n+NSPR_API(void) PRP_DestroyNakedCondVar(PRCondVar *cvar);\n \n /*\n ** Wait on a condition\n@@ -62,8 +60,8 @@ PRP_DestroyNakedCondVar(PRCondVar* cvar);\n **\n ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.\n */\n-NSPR_API(PRStatus)\n-PRP_NakedWait(PRCondVar* cvar, PRLock* lock, PRIntervalTime timeout);\n+NSPR_API(PRStatus) PRP_NakedWait(\n+    PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout);\n \n /*\n ** Notify a thread waiting on a condition\n@@ -72,8 +70,7 @@ PRP_NakedWait(PRCondVar* cvar, PRLock* lock, PRIntervalTime timeout);\n **\n ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.\n */\n-NSPR_API(PRStatus)\n-PRP_NakedNotify(PRCondVar* cvar);\n+NSPR_API(PRStatus) PRP_NakedNotify(PRCondVar *cvar);\n \n /*\n ** Notify all threads waiting on a condition\n@@ -82,8 +79,7 @@ PRP_NakedNotify(PRCondVar* cvar);\n **\n ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.\n */\n-NSPR_API(PRStatus)\n-PRP_NakedBroadcast(PRCondVar* cvar);\n+NSPR_API(PRStatus) PRP_NakedBroadcast(PRCondVar *cvar);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prprf.h b/nspr/pr/include/prprf.h\nindex 122631d..759ef40 100644\n--- a/nspr/pr/include/prprf.h\n+++ b/nspr/pr/include/prprf.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -33,22 +34,19 @@ PR_BEGIN_EXTERN_C\n ** of the buffer. Returns the length of the written output, NOT including\n ** the NUL, or (PRUint32)-1 if an error occurs.\n */\n-NSPR_API(PRUint32)\n-PR_snprintf(char* out, PRUint32 outlen, const char* fmt, ...);\n+NSPR_API(PRUint32) PR_snprintf(char *out, PRUint32 outlen, const char *fmt, ...);\n \n /*\n ** sprintf into a PR_MALLOC'd buffer. Return a pointer to the malloc'd\n ** buffer on success, NULL on failure. Call \"PR_smprintf_free\" to release\n ** the memory returned.\n */\n-NSPR_API(char*)\n-PR_smprintf(const char* fmt, ...);\n+NSPR_API(char*) PR_smprintf(const char *fmt, ...);\n \n /*\n ** Free the memory allocated, for the caller, by PR_smprintf\n */\n-NSPR_API(void)\n-PR_smprintf_free(char* mem);\n+NSPR_API(void) PR_smprintf_free(char *mem);\n \n /*\n ** \"append\" sprintf into a PR_MALLOC'd buffer. \"last\" is the last value of\n@@ -57,8 +55,7 @@ PR_smprintf_free(char* mem);\n ** will allocate the initial string. The return value is the new value of\n ** last for subsequent calls, or NULL if there is a malloc failure.\n */\n-NSPR_API(char*)\n-PR_sprintf_append(char* last, const char* fmt, ...);\n+NSPR_API(char*) PR_sprintf_append(char *last, const char *fmt, ...);\n \n /*\n ** sprintf into a function. The function \"f\" is called with a string to\n@@ -67,30 +64,23 @@ PR_sprintf_append(char* last, const char* fmt, ...);\n ** data. The return value is a count of the number of characters fed to\n ** the stuff function, or (PRUint32)-1 if an error occurs.\n */\n-typedef PRIntn (*PRStuffFunc)(void* arg, const char* s, PRUint32 slen);\n+typedef PRIntn (*PRStuffFunc)(void *arg, const char *s, PRUint32 slen);\n \n-NSPR_API(PRUint32)\n-PR_sxprintf(PRStuffFunc f, void* arg, const char* fmt, ...);\n+NSPR_API(PRUint32) PR_sxprintf(PRStuffFunc f, void *arg, const char *fmt, ...);\n \n /*\n ** fprintf to a PRFileDesc\n */\n-NSPR_API(PRUint32)\n-PR_fprintf(struct PRFileDesc* fd, const char* fmt, ...);\n+NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...);\n \n /*\n ** va_list forms of the above.\n */\n-NSPR_API(PRUint32)\n-PR_vsnprintf(char* out, PRUint32 outlen, const char* fmt, va_list ap);\n-NSPR_API(char*)\n-PR_vsmprintf(const char* fmt, va_list ap);\n-NSPR_API(char*)\n-PR_vsprintf_append(char* last, const char* fmt, va_list ap);\n-NSPR_API(PRUint32)\n-PR_vsxprintf(PRStuffFunc f, void* arg, const char* fmt, va_list ap);\n-NSPR_API(PRUint32)\n-PR_vfprintf(struct PRFileDesc* fd, const char* fmt, va_list ap);\n+NSPR_API(PRUint32) PR_vsnprintf(char *out, PRUint32 outlen, const char *fmt, va_list ap);\n+NSPR_API(char*) PR_vsmprintf(const char *fmt, va_list ap);\n+NSPR_API(char*) PR_vsprintf_append(char *last, const char *fmt, va_list ap);\n+NSPR_API(PRUint32) PR_vsxprintf(PRStuffFunc f, void *arg, const char *fmt, va_list ap);\n+NSPR_API(PRUint32) PR_vfprintf(struct PRFileDesc* fd, const char *fmt, va_list ap);\n \n /*\n ***************************************************************************\n@@ -125,8 +115,7 @@ PR_vfprintf(struct PRFileDesc* fd, const char* fmt, va_list ap);\n ***************************************************************************\n */\n \n-NSPR_API(PRInt32)\n-PR_sscanf(const char* buf, const char* fmt, ...);\n+NSPR_API(PRInt32) PR_sscanf(const char *buf, const char *fmt, ...);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prproces.h b/nspr/pr/include/prproces.h\nindex ecc9d01..e23504a 100644\n--- a/nspr/pr/include/prproces.h\n+++ b/nspr/pr/include/prproces.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -17,32 +18,37 @@ PR_BEGIN_EXTERN_C\n typedef struct PRProcess PRProcess;\n typedef struct PRProcessAttr PRProcessAttr;\n \n-NSPR_API(PRProcessAttr*)\n-PR_NewProcessAttr(void);\n+NSPR_API(PRProcessAttr *) PR_NewProcessAttr(void);\n \n-NSPR_API(void)\n-PR_ResetProcessAttr(PRProcessAttr* attr);\n+NSPR_API(void) PR_ResetProcessAttr(PRProcessAttr *attr);\n \n-NSPR_API(void)\n-PR_DestroyProcessAttr(PRProcessAttr* attr);\n+NSPR_API(void) PR_DestroyProcessAttr(PRProcessAttr *attr);\n \n-NSPR_API(void)\n-PR_ProcessAttrSetStdioRedirect(PRProcessAttr* attr, PRSpecialFD stdioFd,\n-                               PRFileDesc* redirectFd);\n+NSPR_API(void) PR_ProcessAttrSetStdioRedirect(\n+    PRProcessAttr *attr,\n+    PRSpecialFD stdioFd,\n+    PRFileDesc *redirectFd\n+);\n \n /*\n  * OBSOLETE -- use PR_ProcessAttrSetStdioRedirect instead.\n  */\n-NSPR_API(void)\n-PR_SetStdioRedirect(PRProcessAttr* attr, PRSpecialFD stdioFd,\n-                    PRFileDesc* redirectFd);\n-\n-NSPR_API(PRStatus)\n-PR_ProcessAttrSetCurrentDirectory(PRProcessAttr* attr, const char* dir);\n-\n-NSPR_API(PRStatus)\n-PR_ProcessAttrSetInheritableFD(PRProcessAttr* attr, PRFileDesc* fd,\n-                               const char* name);\n+NSPR_API(void) PR_SetStdioRedirect(\n+    PRProcessAttr *attr,\n+    PRSpecialFD stdioFd,\n+    PRFileDesc *redirectFd\n+);\n+\n+NSPR_API(PRStatus) PR_ProcessAttrSetCurrentDirectory(\n+    PRProcessAttr *attr,\n+    const char *dir\n+);\n+\n+NSPR_API(PRStatus) PR_ProcessAttrSetInheritableFD(\n+    PRProcessAttr *attr,\n+    PRFileDesc *fd,\n+    const char *name\n+);\n \n /*\n ** Create a new process\n@@ -57,22 +63,23 @@ PR_ProcessAttrSetInheritableFD(PRProcessAttr* attr, PRFileDesc* fd,\n ** termination using PR_WaitProcess().\n */\n \n-NSPR_API(PRProcess*)\n-PR_CreateProcess(const char* path, char* const* argv, char* const* envp,\n-                 const PRProcessAttr* attr);\n+NSPR_API(PRProcess*) PR_CreateProcess(\n+    const char *path,\n+    char *const *argv,\n+    char *const *envp,\n+    const PRProcessAttr *attr);\n \n-NSPR_API(PRStatus)\n-PR_CreateProcessDetached(const char* path, char* const* argv, char* const* envp,\n-                         const PRProcessAttr* attr);\n+NSPR_API(PRStatus) PR_CreateProcessDetached(\n+    const char *path,\n+    char *const *argv,\n+    char *const *envp,\n+    const PRProcessAttr *attr);\n \n-NSPR_API(PRStatus)\n-PR_DetachProcess(PRProcess* process);\n+NSPR_API(PRStatus) PR_DetachProcess(PRProcess *process);\n \n-NSPR_API(PRStatus)\n-PR_WaitProcess(PRProcess* process, PRInt32* exitCode);\n+NSPR_API(PRStatus) PR_WaitProcess(PRProcess *process, PRInt32 *exitCode);\n \n-NSPR_API(PRStatus)\n-PR_KillProcess(PRProcess* process);\n+NSPR_API(PRStatus) PR_KillProcess(PRProcess *process);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prrng.h b/nspr/pr/include/prrng.h\nindex f5bc25a..db7dc68 100644\n--- a/nspr/pr/include/prrng.h\n+++ b/nspr/pr/include/prrng.h\n@@ -1,7 +1,9 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n \n+\n /*\n ** prrng.h -- NSPR Random Number Generator\n **\n@@ -62,8 +64,10 @@ PR_BEGIN_EXTERN_C\n **   component.\n **\n */\n-NSPR_API(PRSize)\n-PR_GetRandomNoise(void* buf, PRSize size);\n+NSPR_API(PRSize) PR_GetRandomNoise(\n+    void    *buf,\n+    PRSize  size\n+);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prrwlock.h b/nspr/pr/include/prrwlock.h\nindex cad7cc1..ab47b53 100644\n--- a/nspr/pr/include/prrwlock.h\n+++ b/nspr/pr/include/prrwlock.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -22,10 +23,12 @@ PR_BEGIN_EXTERN_C\n  *  of NSPR.  All routines operate on a pointer to this opaque entity.\n  */\n \n+\n typedef struct PRRWLock PRRWLock;\n \n #define PR_RWLOCK_RANK_NONE 0\n \n+\n /***********************************************************************\n ** FUNCTION:    PR_NewRWLock\n ** DESCRIPTION:\n@@ -38,8 +41,7 @@ typedef struct PRRWLock PRRWLock;\n **   is returned.\n **\n ***********************************************************************/\n-NSPR_API(PRRWLock*)\n-PR_NewRWLock(PRUint32 lock_rank, const char* lock_name);\n+NSPR_API(PRRWLock*) PR_NewRWLock(PRUint32 lock_rank, const char *lock_name);\n \n /***********************************************************************\n ** FUNCTION:    PR_DestroyRWLock\n@@ -49,8 +51,7 @@ PR_NewRWLock(PRUint32 lock_rank, const char* lock_name);\n ** OUTPUTS:     void\n ** RETURN:      None\n ***********************************************************************/\n-NSPR_API(void)\n-PR_DestroyRWLock(PRRWLock* lock);\n+NSPR_API(void) PR_DestroyRWLock(PRRWLock *lock);\n \n /***********************************************************************\n ** FUNCTION:    PR_RWLock_Rlock\n@@ -60,8 +61,7 @@ PR_DestroyRWLock(PRRWLock* lock);\n ** OUTPUTS:     void\n ** RETURN:      None\n ***********************************************************************/\n-NSPR_API(void)\n-PR_RWLock_Rlock(PRRWLock* lock);\n+NSPR_API(void) PR_RWLock_Rlock(PRRWLock *lock);\n \n /***********************************************************************\n ** FUNCTION:    PR_RWLock_Wlock\n@@ -71,8 +71,7 @@ PR_RWLock_Rlock(PRRWLock* lock);\n ** OUTPUTS:     void\n ** RETURN:      None\n ***********************************************************************/\n-NSPR_API(void)\n-PR_RWLock_Wlock(PRRWLock* lock);\n+NSPR_API(void) PR_RWLock_Wlock(PRRWLock *lock);\n \n /***********************************************************************\n ** FUNCTION:    PR_RWLock_Unlock\n@@ -82,8 +81,7 @@ PR_RWLock_Wlock(PRRWLock* lock);\n ** OUTPUTS:     void\n ** RETURN:      void\n ***********************************************************************/\n-NSPR_API(void)\n-PR_RWLock_Unlock(PRRWLock* lock);\n+NSPR_API(void) PR_RWLock_Unlock(PRRWLock *lock);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prshm.h b/nspr/pr/include/prshm.h\nindex 29efb72..3588aed 100644\n--- a/nspr/pr/include/prshm.h\n+++ b/nspr/pr/include/prshm.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -143,11 +144,16 @@ typedef struct PRSharedMemory PRSharedMemory;\n **   retrieved via PR_GetError() and PR_GetOSError();\n **\n */\n-NSPR_API(PRSharedMemory*)\n-PR_OpenSharedMemory(const char* name, PRSize size, PRIntn flags, PRIntn mode);\n+NSPR_API( PRSharedMemory * )\n+PR_OpenSharedMemory(\n+    const char *name,\n+    PRSize      size,\n+    PRIntn      flags,\n+    PRIntn      mode\n+);\n /* Define values for PR_OpenShareMemory(...,create) */\n-#define PR_SHM_CREATE 0x1 /* create if not exist */\n-#define PR_SHM_EXCL 0x2   /* fail if already exists */\n+#define PR_SHM_CREATE 0x1  /* create if not exist */\n+#define PR_SHM_EXCL   0x2  /* fail if already exists */\n \n /*\n ** FUNCTION: PR_AttachSharedMemory()\n@@ -172,8 +178,11 @@ PR_OpenSharedMemory(const char* name, PRSize size, PRIntn flags, PRIntn mode);\n **\n **\n */\n-NSPR_API(void*)\n-PR_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags);\n+NSPR_API( void * )\n+PR_AttachSharedMemory(\n+    PRSharedMemory *shm,\n+    PRIntn  flags\n+);\n /* Define values for PR_AttachSharedMemory(...,flags) */\n #define PR_SHM_READONLY 0x01\n \n@@ -195,8 +204,11 @@ PR_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags);\n ** RETURNS: PRStatus\n **\n */\n-NSPR_API(PRStatus)\n-PR_DetachSharedMemory(PRSharedMemory* shm, void* addr);\n+NSPR_API( PRStatus )\n+PR_DetachSharedMemory(\n+    PRSharedMemory *shm,\n+    void  *addr\n+);\n \n /*\n ** FUNCTION: PR_CloseSharedMemory()\n@@ -214,8 +226,10 @@ PR_DetachSharedMemory(PRSharedMemory* shm, void* addr);\n ** RETURNS: PRStatus\n **\n */\n-NSPR_API(PRStatus)\n-PR_CloseSharedMemory(PRSharedMemory* shm);\n+NSPR_API( PRStatus )\n+PR_CloseSharedMemory(\n+    PRSharedMemory *shm\n+);\n \n /*\n ** FUNCTION: PR_DeleteSharedMemory()\n@@ -233,8 +247,10 @@ PR_CloseSharedMemory(PRSharedMemory* shm);\n ** RETURNS: PRStatus\n **\n */\n-NSPR_API(PRStatus)\n-PR_DeleteSharedMemory(const char* name);\n+NSPR_API( PRStatus )\n+PR_DeleteSharedMemory(\n+    const char *name\n+);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prshma.h b/nspr/pr/include/prshma.h\nindex b8b3b8c..2a1990a 100644\n--- a/nspr/pr/include/prshma.h\n+++ b/nspr/pr/include/prshma.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -130,8 +131,12 @@ PR_BEGIN_EXTERN_C\n **   Pointer to PRFileMap or NULL on error.\n **\n */\n-NSPR_API(PRFileMap*)\n-PR_OpenAnonFileMap(const char* dirName, PRSize size, PRFileMapProtect prot);\n+NSPR_API( PRFileMap *)\n+PR_OpenAnonFileMap(\n+    const char *dirName,\n+    PRSize      size,\n+    PRFileMapProtect prot\n+);\n \n /*\n ** PR_ProcessAttrSetInheritableFileMap() -- Prepare FileMap for export\n@@ -155,8 +160,11 @@ PR_OpenAnonFileMap(const char* dirName, PRSize size, PRFileMapProtect prot);\n **\n */\n NSPR_API(PRStatus)\n-PR_ProcessAttrSetInheritableFileMap(PRProcessAttr* attr, PRFileMap* fm,\n-                                    const char* shmname);\n+PR_ProcessAttrSetInheritableFileMap(\n+    PRProcessAttr   *attr,\n+    PRFileMap       *fm,\n+    const char      *shmname\n+);\n \n /*\n ** PR_GetInheritedFileMap() -- Import a PRFileMap previously exported\n@@ -176,8 +184,10 @@ PR_ProcessAttrSetInheritableFileMap(PRProcessAttr* attr, PRFileMap* fm,\n **   PRFileMap pointer or NULL.\n **\n */\n-NSPR_API(PRFileMap*)\n-PR_GetInheritedFileMap(const char* shmname);\n+NSPR_API( PRFileMap *)\n+PR_GetInheritedFileMap(\n+    const char *shmname\n+);\n \n /*\n ** PR_ExportFileMapAsString() -- Creates a string identifying a PRFileMap\n@@ -198,13 +208,16 @@ PR_GetInheritedFileMap(const char* shmname);\n **   PRStatus\n **\n */\n-NSPR_API(PRStatus)\n-PR_ExportFileMapAsString(PRFileMap* fm, PRSize bufsize, char* buf);\n+NSPR_API( PRStatus )\n+PR_ExportFileMapAsString(\n+    PRFileMap *fm,\n+    PRSize    bufsize,\n+    char      *buf\n+);\n #define PR_FILEMAP_STRING_BUFSIZE 128\n \n /*\n-** PR_ImportFileMapFromString() -- Creates a PRFileMap from the identifying\n-* string\n+** PR_ImportFileMapFromString() -- Creates a PRFileMap from the identifying string\n **\n ** Description:\n ** PR_ImportFileMapFromString() creates a PRFileMap object from a\n@@ -217,8 +230,10 @@ PR_ExportFileMapAsString(PRFileMap* fm, PRSize bufsize, char* buf);\n **   PRFileMap pointer or NULL.\n **\n */\n-NSPR_API(PRFileMap*)\n-PR_ImportFileMapFromString(const char* fmstring);\n+NSPR_API( PRFileMap * )\n+PR_ImportFileMapFromString(\n+    const char *fmstring\n+);\n \n PR_END_EXTERN_C\n #endif /* prshma_h___ */\ndiff --git a/nspr/pr/include/prsystem.h b/nspr/pr/include/prsystem.h\nindex fd3d33e..577e60e 100644\n--- a/nspr/pr/include/prsystem.h\n+++ b/nspr/pr/include/prsystem.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -18,16 +19,14 @@ PR_BEGIN_EXTERN_C\n **      [<sep><root_component><sep>]*(<component><sep>)<leaf_name>\n */\n \n-NSPR_API(char)\n-PR_GetDirectorySeparator(void);\n+NSPR_API(char) PR_GetDirectorySeparator(void);\n \n /*\n ** OBSOLETE -- the function name is misspelled.\n ** Use PR_GetDirectorySeparator instead.\n */\n \n-NSPR_API(char)\n-PR_GetDirectorySepartor(void);\n+NSPR_API(char) PR_GetDirectorySepartor(void);\n \n /*\n ** Get the host' path separator.\n@@ -35,13 +34,12 @@ PR_GetDirectorySepartor(void);\n **      <directory>[<sep><directory>]*\n */\n \n-NSPR_API(char)\n-PR_GetPathSeparator(void);\n+NSPR_API(char) PR_GetPathSeparator(void);\n \n /* Types of information available via PR_GetSystemInfo(...) */\n typedef enum {\n-    PR_SI_HOSTNAME, /* the hostname with the domain name (if any)\n-                     * removed */\n+    PR_SI_HOSTNAME,  /* the hostname with the domain name (if any)\n+                      * removed */\n     PR_SI_SYSNAME,\n     PR_SI_RELEASE,\n     PR_SI_ARCHITECTURE,\n@@ -50,6 +48,7 @@ typedef enum {\n     PR_SI_RELEASE_BUILD\n } PRSysInfo;\n \n+\n /*\n ** If successful returns a null termintated string in 'buf' for\n ** the information indicated in 'cmd'. If unseccussful the reason for\n@@ -61,20 +60,17 @@ typedef enum {\n \n #define SYS_INFO_BUFFER_LENGTH 256\n \n-NSPR_API(PRStatus)\n-PR_GetSystemInfo(PRSysInfo cmd, char* buf, PRUint32 buflen);\n+NSPR_API(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 buflen);\n \n /*\n ** Return the number of bytes in a page\n */\n-NSPR_API(PRInt32)\n-PR_GetPageSize(void);\n+NSPR_API(PRInt32) PR_GetPageSize(void);\n \n /*\n ** Return log2 of the size of a page\n */\n-NSPR_API(PRInt32)\n-PR_GetPageShift(void);\n+NSPR_API(PRInt32) PR_GetPageShift(void);\n \n /*\n ** PR_GetNumberOfProcessors() -- returns the number of CPUs\n@@ -90,8 +86,7 @@ PR_GetPageShift(void);\n **   The number of available processors or -1 on error\n **\n */\n-NSPR_API(PRInt32)\n-PR_GetNumberOfProcessors(void);\n+NSPR_API(PRInt32) PR_GetNumberOfProcessors( void );\n \n /*\n ** PR_GetPhysicalMemorySize() -- returns the amount of system RAM\n@@ -107,8 +102,7 @@ PR_GetNumberOfProcessors(void);\n **   The amount of system RAM, or 0 on failure.\n **\n */\n-NSPR_API(PRUint64)\n-PR_GetPhysicalMemorySize(void);\n+NSPR_API(PRUint64) PR_GetPhysicalMemorySize(void);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prthread.h b/nspr/pr/include/prthread.h\nindex 808fb20..cacd389 100644\n--- a/nspr/pr/include/prthread.h\n+++ b/nspr/pr/include/prthread.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -50,8 +51,10 @@ PR_BEGIN_EXTERN_C\n typedef struct PRThread PRThread;\n typedef struct PRThreadStack PRThreadStack;\n \n-typedef enum PRThreadType { PR_USER_THREAD,\n-                            PR_SYSTEM_THREAD } PRThreadType;\n+typedef enum PRThreadType {\n+    PR_USER_THREAD,\n+    PR_SYSTEM_THREAD\n+} PRThreadType;\n \n typedef enum PRThreadScope {\n     PR_LOCAL_THREAD,\n@@ -64,13 +67,14 @@ typedef enum PRThreadState {\n     PR_UNJOINABLE_THREAD\n } PRThreadState;\n \n-typedef enum PRThreadPriority {\n-    PR_PRIORITY_FIRST = 0,  /* just a placeholder */\n-    PR_PRIORITY_LOW = 0,    /* the lowest possible priority */\n-    PR_PRIORITY_NORMAL = 1, /* most common expected priority */\n-    PR_PRIORITY_HIGH = 2,   /* slightly more aggressive scheduling */\n-    PR_PRIORITY_URGENT = 3, /* it does little good to have more than one */\n-    PR_PRIORITY_LAST = 3    /* this is just a placeholder */\n+typedef enum PRThreadPriority\n+{\n+    PR_PRIORITY_FIRST = 0,      /* just a placeholder */\n+    PR_PRIORITY_LOW = 0,        /* the lowest possible priority */\n+    PR_PRIORITY_NORMAL = 1,     /* most common expected priority */\n+    PR_PRIORITY_HIGH = 2,       /* slightly more aggressive scheduling */\n+    PR_PRIORITY_URGENT = 3,     /* it does little good to have more than one */\n+    PR_PRIORITY_LAST = 3        /* this is just a placeholder */\n } PRThreadPriority;\n \n /*\n@@ -98,10 +102,13 @@ typedef enum PRThreadPriority {\n ** When the start function returns the thread exits. If it is the last\n ** PR_USER_THREAD to exit then the process exits.\n */\n-NSPR_API(PRThread*)\n-PR_CreateThread(PRThreadType type, void(PR_CALLBACK* start)(void* arg),\n-                void* arg, PRThreadPriority priority, PRThreadScope scope,\n-                PRThreadState state, PRUint32 stackSize);\n+NSPR_API(PRThread*) PR_CreateThread(PRThreadType type,\n+                                    void (PR_CALLBACK *start)(void *arg),\n+                                    void *arg,\n+                                    PRThreadPriority priority,\n+                                    PRThreadScope scope,\n+                                    PRThreadState state,\n+                                    PRUint32 stackSize);\n \n /*\n ** Wait for thread termination:\n@@ -116,24 +123,21 @@ PR_CreateThread(PRThreadType type, void(PR_CALLBACK* start)(void* arg),\n ** The calling thread will not be blocked if the target thread has already\n ** terminated.\n */\n-NSPR_API(PRStatus)\n-PR_JoinThread(PRThread* thread);\n+NSPR_API(PRStatus) PR_JoinThread(PRThread *thread);\n \n /*\n ** Return the current thread object for the currently running code.\n ** Never returns NULL.\n */\n-NSPR_API(PRThread*)\n-PR_GetCurrentThread(void);\n+NSPR_API(PRThread*) PR_GetCurrentThread(void);\n #ifndef NO_NSPR_10_SUPPORT\n #define PR_CurrentThread() PR_GetCurrentThread() /* for nspr1.0 compat. */\n-#endif                                           /* NO_NSPR_10_SUPPORT */\n+#endif /* NO_NSPR_10_SUPPORT */\n \n /*\n ** Get the priority of \"thread\".\n */\n-NSPR_API(PRThreadPriority)\n-PR_GetThreadPriority(const PRThread* thread);\n+NSPR_API(PRThreadPriority) PR_GetThreadPriority(const PRThread *thread);\n \n /*\n ** Change the priority of the \"thread\" to \"priority\".\n@@ -145,21 +149,18 @@ PR_GetThreadPriority(const PRThread* thread);\n ** effect except causing a future PR_GetThreadPriority call to return\n ** |priority|.\n */\n-NSPR_API(void)\n-PR_SetThreadPriority(PRThread* thread, PRThreadPriority priority);\n+NSPR_API(void) PR_SetThreadPriority(PRThread *thread, PRThreadPriority priority);\n \n /*\n ** Set the name of the current thread, which will be visible in a debugger\n ** and accessible via a call to PR_GetThreadName().\n */\n-NSPR_API(PRStatus)\n-PR_SetCurrentThreadName(const char* name);\n+NSPR_API(PRStatus) PR_SetCurrentThreadName(const char *name);\n \n /*\n ** Return the name of \"thread\", if set.  Otherwise return NULL.\n */\n-NSPR_API(const char*)\n-PR_GetThreadName(const PRThread* thread);\n+NSPR_API(const char *) PR_GetThreadName(const PRThread *thread);\n \n /*\n ** This routine returns a new index for per-thread-private data table.\n@@ -185,10 +186,10 @@ PR_GetThreadName(const PRThread* thread);\n ** Returns PR_FAILURE if the total number of indices will exceed the maximun\n ** allowed.\n */\n-typedef void(PR_CALLBACK* PRThreadPrivateDTOR)(void* priv);\n+typedef void (PR_CALLBACK *PRThreadPrivateDTOR)(void *priv);\n \n-NSPR_API(PRStatus)\n-PR_NewThreadPrivateIndex(PRUintn* newIndex, PRThreadPrivateDTOR destructor);\n+NSPR_API(PRStatus) PR_NewThreadPrivateIndex(\n+    PRUintn *newIndex, PRThreadPrivateDTOR destructor);\n \n /*\n ** Define some per-thread-private data.\n@@ -201,8 +202,7 @@ PR_NewThreadPrivateIndex(PRUintn* newIndex, PRThreadPrivateDTOR destructor);\n **\n ** This can return PR_FAILURE if the index is invalid.\n */\n-NSPR_API(PRStatus)\n-PR_SetThreadPrivate(PRUintn tpdIndex, void* priv);\n+NSPR_API(PRStatus) PR_SetThreadPrivate(PRUintn tpdIndex, void *priv);\n \n /*\n ** Recover the per-thread-private data for the current thread. \"tpdIndex\" is\n@@ -213,8 +213,7 @@ PR_SetThreadPrivate(PRUintn tpdIndex, void* priv);\n **\n ** A thread can only get access to its own thread-specific-data.\n */\n-NSPR_API(void*)\n-PR_GetThreadPrivate(PRUintn tpdIndex);\n+NSPR_API(void*) PR_GetThreadPrivate(PRUintn tpdIndex);\n \n /*\n ** This routine sets the interrupt request for a target thread. The interrupt\n@@ -226,27 +225,23 @@ PR_GetThreadPrivate(PRUintn tpdIndex);\n **\n ** PR_Interrupt may itself fail if the target thread is invalid.\n */\n-NSPR_API(PRStatus)\n-PR_Interrupt(PRThread* thread);\n+NSPR_API(PRStatus) PR_Interrupt(PRThread *thread);\n \n /*\n ** Clear the interrupt request for the calling thread. If no such request\n ** is pending, this operation is a noop.\n */\n-NSPR_API(void)\n-PR_ClearInterrupt(void);\n+NSPR_API(void) PR_ClearInterrupt(void);\n \n /*\n ** Block the interrupt for the calling thread.\n */\n-NSPR_API(void)\n-PR_BlockInterrupt(void);\n+NSPR_API(void) PR_BlockInterrupt(void);\n \n /*\n ** Unblock the interrupt for the calling thread.\n */\n-NSPR_API(void)\n-PR_UnblockInterrupt(void);\n+NSPR_API(void) PR_UnblockInterrupt(void);\n \n /*\n ** Make the current thread sleep until \"ticks\" time amount of time\n@@ -255,26 +250,22 @@ PR_UnblockInterrupt(void);\n ** equivalent to PR_INTERVAL_NO_TIMEOUT is an error and will result\n ** in a PR_FAILURE error return.\n */\n-NSPR_API(PRStatus)\n-PR_Sleep(PRIntervalTime ticks);\n+NSPR_API(PRStatus) PR_Sleep(PRIntervalTime ticks);\n \n /*\n ** Get the scoping of this thread.\n */\n-NSPR_API(PRThreadScope)\n-PR_GetThreadScope(const PRThread* thread);\n+NSPR_API(PRThreadScope) PR_GetThreadScope(const PRThread *thread);\n \n /*\n ** Get the type of this thread.\n */\n-NSPR_API(PRThreadType)\n-PR_GetThreadType(const PRThread* thread);\n+NSPR_API(PRThreadType) PR_GetThreadType(const PRThread *thread);\n \n /*\n ** Get the join state of this thread.\n */\n-NSPR_API(PRThreadState)\n-PR_GetThreadState(const PRThread* thread);\n+NSPR_API(PRThreadState) PR_GetThreadState(const PRThread *thread);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prtime.h b/nspr/pr/include/prtime.h\nindex c31be67..917a161 100644\n--- a/nspr/pr/include/prtime.h\n+++ b/nspr/pr/include/prtime.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -23,11 +24,11 @@ PR_BEGIN_EXTERN_C\n /************************* TYPES AND CONSTANTS ************************/\n /**********************************************************************/\n \n-#define PR_MSEC_PER_SEC 1000L\n-#define PR_USEC_PER_SEC 1000000L\n-#define PR_NSEC_PER_SEC 1000000000L\n-#define PR_USEC_PER_MSEC 1000L\n-#define PR_NSEC_PER_MSEC 1000000L\n+#define PR_MSEC_PER_SEC     1000L\n+#define PR_USEC_PER_SEC     1000000L\n+#define PR_NSEC_PER_SEC     1000000000L\n+#define PR_USEC_PER_MSEC    1000L\n+#define PR_NSEC_PER_MSEC    1000000L\n \n /*\n  * PRTime --\n@@ -40,7 +41,8 @@ PR_BEGIN_EXTERN_C\n  *     intended to be exported to other systems or converted to human\n  *     readable form.\n  *\n- *     Notes on porting: PRTime corresponds to time_t in ANSI C.\n+ *     Notes on porting: PRTime corresponds to time_t in ANSI C.  NSPR 1.0\n+ *     simply uses PRInt64.\n  */\n \n typedef PRInt64 PRTime;\n@@ -51,8 +53,8 @@ typedef PRInt64 PRTime;\n  */\n \n typedef struct PRTimeParameters {\n-    PRInt32 tp_gmt_offset; /* the offset from GMT in seconds */\n-    PRInt32 tp_dst_offset; /* contribution of DST in seconds */\n+    PRInt32 tp_gmt_offset;     /* the offset from GMT in seconds */\n+    PRInt32 tp_dst_offset;     /* contribution of DST in seconds */\n } PRTimeParameters;\n \n /*\n@@ -70,30 +72,32 @@ typedef struct PRTimeParameters {\n  *       - replacing tm_isdst by tm_params;\n  *       - the month field is spelled tm_month, not tm_mon;\n  *       - we use absolute year, AD, not the year since 1900.\n- *     Below is a table of date/time type correspondence in the two APIs:\n+ *     The corresponding type in NSPR 1.0 is called PRTime.  Below is\n+ *     a table of date/time type correspondence in the three APIs:\n  *         API          time since epoch          time in components\n  *       ANSI C             time_t                  struct tm\n- *       NSPR               PRTime                  PRExplodedTime\n+ *       NSPR 1.0           PRInt64                   PRTime\n+ *       NSPR 2.0           PRTime                  PRExplodedTime\n  */\n \n typedef struct PRExplodedTime {\n-    PRInt32 tm_usec;  /* microseconds past tm_sec (0-99999)  */\n-    PRInt32 tm_sec;   /* seconds past tm_min (0-61, accomodating\n-                         up to two leap seconds) */\n-    PRInt32 tm_min;   /* minutes past tm_hour (0-59) */\n-    PRInt32 tm_hour;  /* hours past tm_day (0-23) */\n-    PRInt32 tm_mday;  /* days past tm_mon (1-31, note that it\n-                         starts from 1) */\n-    PRInt32 tm_month; /* months past tm_year (0-11, Jan = 0) */\n-    PRInt16 tm_year;  /* absolute year, AD (note that we do not\n-                         count from 1900) */\n-\n-    PRInt8 tm_wday;  /* calculated day of the week\n-                        (0-6, Sun = 0) */\n-    PRInt16 tm_yday; /* calculated day of the year\n-                        (0-365, Jan 1 = 0) */\n-\n-    PRTimeParameters tm_params; /* time parameters used by conversion */\n+    PRInt32 tm_usec;            /* microseconds past tm_sec (0-99999)  */\n+    PRInt32 tm_sec;             /* seconds past tm_min (0-61, accomodating\n+                                   up to two leap seconds) */\n+    PRInt32 tm_min;             /* minutes past tm_hour (0-59) */\n+    PRInt32 tm_hour;            /* hours past tm_day (0-23) */\n+    PRInt32 tm_mday;            /* days past tm_mon (1-31, note that it\n+                                starts from 1) */\n+    PRInt32 tm_month;           /* months past tm_year (0-11, Jan = 0) */\n+    PRInt16 tm_year;            /* absolute year, AD (note that we do not\n+                                count from 1900) */\n+\n+    PRInt8 tm_wday;             /* calculated day of the week\n+                                (0-6, Sun = 0) */\n+    PRInt16 tm_yday;            /* calculated day of the year\n+                                (0-365, Jan 1 = 0) */\n+\n+    PRTimeParameters tm_params;  /* time parameters used by conversion */\n } PRExplodedTime;\n \n /*\n@@ -119,7 +123,7 @@ typedef struct PRExplodedTime {\n  *         to GMT before applying the DST rules.\n  */\n \n-typedef PRTimeParameters(PR_CALLBACK* PRTimeParamFn)(const PRExplodedTime* gmt);\n+typedef PRTimeParameters (PR_CALLBACK *PRTimeParamFn)(const PRExplodedTime *gmt);\n \n /**********************************************************************/\n /****************************** FUNCTIONS *****************************/\n@@ -151,12 +155,12 @@ PR_Now(void);\n  *     as PRExplodedTime.\n  */\n \n-NSPR_API(void)\n-PR_ExplodeTime(PRTime usecs, PRTimeParamFn params, PRExplodedTime* exploded);\n+NSPR_API(void) PR_ExplodeTime(\n+    PRTime usecs, PRTimeParamFn params, PRExplodedTime *exploded);\n \n /* Reverse operation of PR_ExplodeTime */\n NSPR_API(PRTime)\n-PR_ImplodeTime(const PRExplodedTime* exploded);\n+PR_ImplodeTime(const PRExplodedTime *exploded);\n \n /*\n  * Adjust exploded time to normalize field overflows after manipulation.\n@@ -170,27 +174,24 @@ PR_ImplodeTime(const PRExplodedTime* exploded);\n  *     should treat them as \"read-only\".\n  */\n \n-NSPR_API(void)\n-PR_NormalizeTime(PRExplodedTime* exploded, PRTimeParamFn params);\n+NSPR_API(void) PR_NormalizeTime(\n+    PRExplodedTime *exploded, PRTimeParamFn params);\n \n /**********************************************************************/\n /*********************** TIME PARAMETER FUNCTIONS *********************/\n /**********************************************************************/\n \n /* Time parameters that suit current host machine */\n-NSPR_API(PRTimeParameters)\n-PR_LocalTimeParameters(const PRExplodedTime* gmt);\n+NSPR_API(PRTimeParameters) PR_LocalTimeParameters(const PRExplodedTime *gmt);\n \n /* Time parameters that represent Greenwich Mean Time */\n-NSPR_API(PRTimeParameters)\n-PR_GMTParameters(const PRExplodedTime* gmt);\n+NSPR_API(PRTimeParameters) PR_GMTParameters(const PRExplodedTime *gmt);\n \n /*\n  * Time parameters that represent the US Pacific Time Zone, with the\n  * current daylight saving time rules (for testing only)\n  */\n-NSPR_API(PRTimeParameters)\n-PR_USPacificTimeParameters(const PRExplodedTime* gmt);\n+NSPR_API(PRTimeParameters) PR_USPacificTimeParameters(const PRExplodedTime *gmt);\n \n /*\n  * This parses a time/date string into a PRExplodedTime\n@@ -227,9 +228,10 @@ PR_USPacificTimeParameters(const PRExplodedTime* gmt);\n  * the time string which you are parsing.\n  */\n \n-NSPR_API(PRStatus)\n-PR_ParseTimeStringToExplodedTime(const char* string, PRBool default_to_gmt,\n-                                 PRExplodedTime* result);\n+NSPR_API(PRStatus) PR_ParseTimeStringToExplodedTime (\n+    const char *string,\n+    PRBool default_to_gmt,\n+    PRExplodedTime *result);\n \n /*\n  * This uses PR_ParseTimeStringToExplodedTime to parse\n@@ -239,20 +241,21 @@ PR_ParseTimeStringToExplodedTime(const char* string, PRBool default_to_gmt,\n  * if the time/date string can't be parsed.\n  */\n \n-NSPR_API(PRStatus)\n-PR_ParseTimeString(const char* string, PRBool default_to_gmt, PRTime* result);\n+NSPR_API(PRStatus) PR_ParseTimeString (\n+    const char *string,\n+    PRBool default_to_gmt,\n+    PRTime *result);\n \n /* Format a time value into a buffer. Same semantics as strftime() */\n-NSPR_API(PRUint32)\n-PR_FormatTime(char* buf, int buflen, const char* fmt,\n-              const PRExplodedTime* time);\n+NSPR_API(PRUint32) PR_FormatTime(char *buf, int buflen, const char *fmt,\n+                                 const PRExplodedTime *time);\n \n /* Format a time value into a buffer. Time is always in US English format,\n  * regardless of locale setting.\n  */\n NSPR_API(PRUint32)\n-PR_FormatTimeUSEnglish(char* buf, PRUint32 bufSize, const char* format,\n-                       const PRExplodedTime* time);\n+PR_FormatTimeUSEnglish(char *buf, PRUint32 bufSize,\n+                       const char *format, const PRExplodedTime *time);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prtpool.h b/nspr/pr/include/prtpool.h\nindex ef50cec..b4d18d4 100644\n--- a/nspr/pr/include/prtpool.h\n+++ b/nspr/pr/include/prtpool.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -19,64 +20,63 @@\n PR_BEGIN_EXTERN_C\n \n typedef struct PRJobIoDesc {\n-    PRFileDesc* socket;\n+    PRFileDesc *socket;\n     PRErrorCode error;\n     PRIntervalTime timeout;\n } PRJobIoDesc;\n \n typedef struct PRThreadPool PRThreadPool;\n typedef struct PRJob PRJob;\n-typedef void(PR_CALLBACK* PRJobFn)(void* arg);\n+typedef void (PR_CALLBACK *PRJobFn) (void *arg);\n \n /* Create thread pool */\n-NSPR_API(PRThreadPool*)\n+NSPR_API(PRThreadPool *)\n PR_CreateThreadPool(PRInt32 initial_threads, PRInt32 max_threads,\n                     PRUint32 stacksize);\n \n /* queue a job */\n-NSPR_API(PRJob*)\n-PR_QueueJob(PRThreadPool* tpool, PRJobFn fn, void* arg, PRBool joinable);\n+NSPR_API(PRJob *)\n+PR_QueueJob(PRThreadPool *tpool, PRJobFn fn, void *arg, PRBool joinable);\n \n /* queue a job, when a socket is readable */\n-NSPR_API(PRJob*)\n-PR_QueueJob_Read(PRThreadPool* tpool, PRJobIoDesc* iod, PRJobFn fn, void* arg,\n-                 PRBool joinable);\n+NSPR_API(PRJob *)\n+PR_QueueJob_Read(PRThreadPool *tpool, PRJobIoDesc *iod,\n+                 PRJobFn fn, void * arg, PRBool joinable);\n \n /* queue a job, when a socket is writeable */\n-NSPR_API(PRJob*)\n-PR_QueueJob_Write(PRThreadPool* tpool, PRJobIoDesc* iod, PRJobFn fn, void* arg,\n-                  PRBool joinable);\n+NSPR_API(PRJob *)\n+PR_QueueJob_Write(PRThreadPool *tpool, PRJobIoDesc *iod,\n+                  PRJobFn fn, void * arg, PRBool joinable);\n \n /* queue a job, when a socket has a pending connection */\n-NSPR_API(PRJob*)\n-PR_QueueJob_Accept(PRThreadPool* tpool, PRJobIoDesc* iod, PRJobFn fn, void* arg,\n-                   PRBool joinable);\n+NSPR_API(PRJob *)\n+PR_QueueJob_Accept(PRThreadPool *tpool, PRJobIoDesc *iod,\n+                   PRJobFn fn, void * arg, PRBool joinable);\n \n /* queue a job, when the socket connection to addr succeeds or fails */\n-NSPR_API(PRJob*)\n-PR_QueueJob_Connect(PRThreadPool* tpool, PRJobIoDesc* iod,\n-                    const PRNetAddr* addr, PRJobFn fn, void* arg,\n-                    PRBool joinable);\n+NSPR_API(PRJob *)\n+PR_QueueJob_Connect(PRThreadPool *tpool, PRJobIoDesc *iod,\n+                    const PRNetAddr *addr, PRJobFn fn, void * arg, PRBool joinable);\n \n /* queue a job, when a timer exipres */\n-NSPR_API(PRJob*)\n-PR_QueueJob_Timer(PRThreadPool* tpool, PRIntervalTime timeout, PRJobFn fn,\n-                  void* arg, PRBool joinable);\n+NSPR_API(PRJob *)\n+PR_QueueJob_Timer(PRThreadPool *tpool, PRIntervalTime timeout,\n+                  PRJobFn fn, void * arg, PRBool joinable);\n /* cancel a job */\n NSPR_API(PRStatus)\n-PR_CancelJob(PRJob* job);\n+PR_CancelJob(PRJob *job);\n \n /* join a job */\n NSPR_API(PRStatus)\n-PR_JoinJob(PRJob* job);\n+PR_JoinJob(PRJob *job);\n \n /* shutdown pool */\n NSPR_API(PRStatus)\n-PR_ShutdownThreadPool(PRThreadPool* tpool);\n+PR_ShutdownThreadPool(PRThreadPool *tpool);\n \n /* join pool, wait for exit of all threads */\n NSPR_API(PRStatus)\n-PR_JoinThreadPool(PRThreadPool* tpool);\n+PR_JoinThreadPool(PRThreadPool *tpool);\n \n PR_END_EXTERN_C\n \ndiff --git a/nspr/pr/include/prtrace.h b/nspr/pr/include/prtrace.h\nindex 0955125..49bd3ed 100644\n--- a/nspr/pr/include/prtrace.h\n+++ b/nspr/pr/include/prtrace.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -71,18 +72,19 @@ PR_BEGIN_EXTERN_C\n ** ... Don't even think about looking in here.\n **\n */\n-typedef void* PRTraceHandle;\n+typedef void *  PRTraceHandle;\n \n /*\n ** PRTraceEntry -- A trace entry in the in-memory trace buffer\n ** looks like this.\n **\n */\n-typedef struct PRTraceEntry {\n-    PRThread* thread;     /* The thread creating the trace entry */\n-    PRTraceHandle handle; /* PRTraceHandle creating the trace entry */\n-    PRTime time;          /* Value of PR_Now() at time of trace entry */\n-    PRUint32 userData[8]; /* user supplied trace data */\n+typedef struct PRTraceEntry\n+{\n+    PRThread        *thread;        /* The thread creating the trace entry */\n+    PRTraceHandle   handle;         /* PRTraceHandle creating the trace entry */\n+    PRTime          time;           /* Value of PR_Now() at time of trace entry */\n+    PRUint32        userData[8];    /* user supplied trace data */\n } PRTraceEntry;\n \n /*\n@@ -90,7 +92,8 @@ typedef struct PRTraceEntry {\n ** PR_[Set|Get]TraceOption(). See descriptive meanings there.\n **\n */\n-typedef enum PRTraceOption {\n+typedef enum PRTraceOption\n+{\n     PRTraceBufSize,\n     PRTraceEnable,\n     PRTraceDisable,\n@@ -120,13 +123,14 @@ typedef enum PRTraceOption {\n ** to value. e.g. PR_INIT_TRACE_HANDLE( myHandle, NULL );\n **\n */\n-#if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-#define PR_INIT_TRACE_HANDLE(handle, value) \\\n+#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)\n+#define PR_INIT_TRACE_HANDLE(handle,value)\\\n     (handle) = (PRCounterHandle)(value)\n #else\n-#define PR_INIT_TRACE_HANDLE(handle, value)\n+#define PR_INIT_TRACE_HANDLE(handle,value)\n #endif\n \n+\n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_CreateTrace() -- Create a trace handle\n **\n@@ -162,19 +166,21 @@ typedef enum PRTraceOption {\n #define PRTRACE_NAME_MAX 31\n #define PRTRACE_DESC_MAX 255\n \n-#if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-#define PR_CREATE_TRACE(handle, qName, rName, description) \\\n-    (handle) = PR_CreateTrace((qName), (rName), (description))\n+#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)\n+#define PR_CREATE_TRACE(handle,qName,rName,description)\\\n+    (handle) = PR_CreateTrace((qName),(rName),(description))\n #else\n-#define PR_CREATE_TRACE(handle, qName, rName, description)\n+#define PR_CREATE_TRACE(handle,qName,rName,description)\n #endif\n \n NSPR_API(PRTraceHandle)\n-PR_CreateTrace(const char* qName,      /* QName for this trace handle */\n-               const char* rName,      /* RName for this trace handle */\n-               const char* description /* description for this trace handle */\n+PR_CreateTrace(\n+    const char *qName,          /* QName for this trace handle */\n+    const char *rName,          /* RName for this trace handle */\n+    const char *description     /* description for this trace handle */\n );\n \n+\n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_DestroyTrace() -- Destroy a trace handle\n **\n@@ -194,16 +200,19 @@ PR_CreateTrace(const char* qName,      /* QName for this trace handle */\n ** RESTRICTIONS:\n **\n */\n-#if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-#define PR_DESTROY_TRACE(handle) PR_DestroyTrace((handle))\n+#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)\n+#define PR_DESTROY_TRACE(handle)\\\n+    PR_DestroyTrace((handle))\n #else\n #define PR_DESTROY_TRACE(handle)\n #endif\n \n NSPR_API(void)\n-PR_DestroyTrace(PRTraceHandle handle /* Handle to be destroyed */\n+PR_DestroyTrace(\n+    PRTraceHandle handle    /* Handle to be destroyed */\n );\n \n+\n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_Trace() -- Make a trace entry in the in-memory trace\n **\n@@ -232,23 +241,24 @@ PR_DestroyTrace(PRTraceHandle handle /* Handle to be destroyed */\n ** RESTRICTIONS:\n **\n */\n-#if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-#define PR_TRACE(handle, ud0, ud1, ud2, ud3, ud4, ud5, ud6, ud7) \\\n-    PR_Trace((handle), (ud0), (ud1), (ud2), (ud3), (ud4), (ud5), (ud6), (ud7))\n+#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)\n+#define PR_TRACE(handle,ud0,ud1,ud2,ud3,ud4,ud5,ud6,ud7)\\\n+    PR_Trace((handle),(ud0),(ud1),(ud2),(ud3),(ud4),(ud5),(ud6),(ud7))\n #else\n-#define PR_TRACE(handle, ud0, ud1, ud2, ud3, ud4, ud5, ud6, ud7)\n+#define PR_TRACE(handle,ud0,ud1,ud2,ud3,ud4,ud5,ud6,ud7)\n #endif\n \n NSPR_API(void)\n-PR_Trace(PRTraceHandle handle, /* use this trace handle */\n-         PRUint32 userData0,   /* User supplied data word 0 */\n-         PRUint32 userData1,   /* User supplied data word 1 */\n-         PRUint32 userData2,   /* User supplied data word 2 */\n-         PRUint32 userData3,   /* User supplied data word 3 */\n-         PRUint32 userData4,   /* User supplied data word 4 */\n-         PRUint32 userData5,   /* User supplied data word 5 */\n-         PRUint32 userData6,   /* User supplied data word 6 */\n-         PRUint32 userData7    /* User supplied data word 7 */\n+PR_Trace(\n+    PRTraceHandle handle,       /* use this trace handle */\n+    PRUint32    userData0,      /* User supplied data word 0 */\n+    PRUint32    userData1,      /* User supplied data word 1 */\n+    PRUint32    userData2,      /* User supplied data word 2 */\n+    PRUint32    userData3,      /* User supplied data word 3 */\n+    PRUint32    userData4,      /* User supplied data word 4 */\n+    PRUint32    userData5,      /* User supplied data word 5 */\n+    PRUint32    userData6,      /* User supplied data word 6 */\n+    PRUint32    userData7       /* User supplied data word 7 */\n );\n \n /* -----------------------------------------------------------------------\n@@ -318,18 +328,20 @@ PR_Trace(PRTraceHandle handle, /* use this trace handle */\n ** RESTRICTIONS:\n **\n */\n-#if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-#define PR_SET_TRACE_OPTION(command, value) \\\n-    PR_SetTraceOption((command), (value))\n+#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)\n+#define PR_SET_TRACE_OPTION(command,value)\\\n+    PR_SetTraceOption((command),(value))\n #else\n-#define PR_SET_TRACE_OPTION(command, value)\n+#define PR_SET_TRACE_OPTION(command,value)\n #endif\n \n NSPR_API(void)\n-PR_SetTraceOption(PRTraceOption command, /* One of the enumerated values */\n-                  void* value            /* command value or NULL */\n+PR_SetTraceOption(\n+    PRTraceOption command,  /* One of the enumerated values */\n+    void *value             /* command value or NULL */\n );\n \n+\n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_GetTraceOption() -- Retrieve settings from the Trace Facility\n **\n@@ -354,16 +366,17 @@ PR_SetTraceOption(PRTraceOption command, /* One of the enumerated values */\n ** RESTRICTIONS:\n **\n */\n-#if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-#define PR_GET_TRACE_OPTION(command, value) \\\n-    PR_GetTraceOption((command), (value))\n+#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)\n+#define PR_GET_TRACE_OPTION(command,value)\\\n+    PR_GetTraceOption((command),(value))\n #else\n-#define PR_GET_TRACE_OPTION(command, value)\n+#define PR_GET_TRACE_OPTION(command,value)\n #endif\n \n NSPR_API(void)\n-PR_GetTraceOption(PRTraceOption command, /* One of the enumerated values */\n-                  void* value            /* command value or NULL */\n+PR_GetTraceOption(\n+    PRTraceOption command,  /* One of the enumerated values */\n+    void *value             /* command value or NULL */\n );\n \n /* -----------------------------------------------------------------------\n@@ -389,16 +402,17 @@ PR_GetTraceOption(PRTraceOption command, /* One of the enumerated values */\n ** RESTRICTIONS:\n **\n */\n-#if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-#define PR_GET_TRACE_HANDLE_FROM_NAME(handle, qName, rName) \\\n-    (handle) = PR_GetTraceHandleFromName((qName), (rName))\n+#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)\n+#define PR_GET_TRACE_HANDLE_FROM_NAME(handle,qName,rName)\\\n+    (handle) = PR_GetTraceHandleFromName((qName),(rName))\n #else\n-#define PR_GET_TRACE_HANDLE_FROM_NAME(handle, qName, rName)\n+#define PR_GET_TRACE_HANDLE_FROM_NAME(handle,qName,rName)\n #endif\n \n NSPR_API(PRTraceHandle)\n-PR_GetTraceHandleFromName(const char* qName, /* QName search argument */\n-                          const char* rName  /* RName search argument */\n+PR_GetTraceHandleFromName(\n+    const char *qName,      /* QName search argument */\n+    const char *rName       /* RName search argument */\n );\n \n /* -----------------------------------------------------------------------\n@@ -420,19 +434,19 @@ PR_GetTraceHandleFromName(const char* qName, /* QName search argument */\n ** RESTRICTIONS:\n **\n */\n-#if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-#define PR_GET_TRACE_NAME_FROM_HANDLE(handle, qName, rName, description) \\\n-    PR_GetTraceNameFromHandle((handle), (qName), (rName), (description))\n+#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)\n+#define PR_GET_TRACE_NAME_FROM_HANDLE(handle,qName,rName,description)\\\n+    PR_GetTraceNameFromHandle((handle),(qName),(rName),(description))\n #else\n-#define PR_GET_TRACE_NAME_FROM_HANDLE(handle, qName, rName, description)\n+#define PR_GET_TRACE_NAME_FROM_HANDLE(handle,qName,rName,description)\n #endif\n \n NSPR_API(void)\n PR_GetTraceNameFromHandle(\n-    PRTraceHandle handle,    /* handle as search argument */\n-    const char** qName,      /* pointer to associated QName */\n-    const char** rName,      /* pointer to associated RName */\n-    const char** description /* pointer to associated description */\n+    PRTraceHandle handle,       /* handle as search argument */\n+    const char **qName,         /* pointer to associated QName */\n+    const char **rName,         /* pointer to associated RName */\n+    const char **description    /* pointer to associated description */\n );\n \n /* -----------------------------------------------------------------------\n@@ -462,15 +476,18 @@ PR_GetTraceNameFromHandle(\n ** See: PR_SetTraceOption( PRLockTraceHandles ).\n **\n */\n-#if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-#define PR_FIND_NEXT_TRACE_QNAME(next, handle) \\\n+#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)\n+#define PR_FIND_NEXT_TRACE_QNAME(next,handle)\\\n     (next) = PR_FindNextTraceQname((handle))\n #else\n-#define PR_FIND_NEXT_TRACE_QNAME(next, handle)\n+#define PR_FIND_NEXT_TRACE_QNAME(next,handle)\n #endif\n \n NSPR_API(PRTraceHandle)\n-PR_FindNextTraceQname(PRTraceHandle handle);\n+PR_FindNextTraceQname(\n+    PRTraceHandle handle\n+);\n+\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_FindNextTraceRname() -- Retrieive an RName handle\n@@ -501,15 +518,18 @@ PR_FindNextTraceQname(PRTraceHandle handle);\n ** PR_SetTraceOption( PRLockTraceHandles ).\n **\n */\n-#if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-#define PR_FIND_NEXT_TRACE_RNAME(next, rhandle, qhandle) \\\n-    (next) = PR_FindNextTraceRname((rhandle), (qhandle))\n+#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)\n+#define PR_FIND_NEXT_TRACE_RNAME(next,rhandle,qhandle)\\\n+    (next) = PR_FindNextTraceRname((rhandle),(qhandle))\n #else\n-#define PR_FIND_NEXT_TRACE_RNAME(next, rhandle, qhandle)\n+#define PR_FIND_NEXT_TRACE_RNAME(next,rhandle,qhandle)\n #endif\n \n NSPR_API(PRTraceHandle)\n-PR_FindNextTraceRname(PRTraceHandle rhandle, PRTraceHandle qhandle);\n+PR_FindNextTraceRname(\n+    PRTraceHandle rhandle,\n+    PRTraceHandle qhandle\n+);\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_RecordTraceEntries() -- Write trace entries to external media\n@@ -554,14 +574,17 @@ PR_FindNextTraceRname(PRTraceHandle rhandle, PRTraceHandle qhandle);\n ** On error, PR_RecordTraceEntries() may return prematurely.\n **\n */\n-#if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-#define PR_RECORD_TRACE_ENTRIES() PR_RecordTraceEntries()\n+#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)\n+#define PR_RECORD_TRACE_ENTRIES()\\\n+    PR_RecordTraceEntries()\n #else\n #define PR_RECORD_TRACE_ENTRIES()\n #endif\n \n NSPR_API(void)\n-PR_RecordTraceEntries(void);\n+PR_RecordTraceEntries(\n+    void\n+);\n \n /* -----------------------------------------------------------------------\n ** FUNCTION: PR_GetTraceEntries() -- Retreive trace entries from\n@@ -603,19 +626,21 @@ PR_RecordTraceEntries(void);\n ** application may be realized. ... YMMV.\n **\n */\n-#if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-#define PR_GET_TRACE_ENTRIES(buffer, count, found) \\\n-    PR_GetTraceEntries((buffer), (count), (found))\n+#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)\n+#define PR_GET_TRACE_ENTRIES(buffer,count,found)\\\n+        PR_GetTraceEntries((buffer),(count),(found))\n #else\n-#define PR_GET_TRACE_ENTRIES(buffer, count, found)\n+#define PR_GET_TRACE_ENTRIES(buffer,count,found)\n #endif\n \n NSPR_API(PRIntn)\n-PR_GetTraceEntries(PRTraceEntry* buffer, /* where to write output */\n-                   PRInt32 count,        /* number to get */\n-                   PRInt32* found        /* number you got */\n+PR_GetTraceEntries(\n+    PRTraceEntry    *buffer,    /* where to write output */\n+    PRInt32         count,      /* number to get */\n+    PRInt32         *found      /* number you got */\n );\n \n PR_END_EXTERN_C\n \n #endif /* prtrace_h___ */\n+\ndiff --git a/nspr/pr/include/prtypes.h b/nspr/pr/include/prtypes.h\nindex 6601f7b..b24bf40 100644\n--- a/nspr/pr/include/prtypes.h\n+++ b/nspr/pr/include/prtypes.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -67,7 +68,7 @@\n \n #define PR_EXPORT(__type) extern __declspec(dllexport) __type\n #define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type\n-#define PR_IMPORT(__type) extern __declspec(dllimport) __type\n+#define PR_IMPORT(__type) extern  __declspec(dllimport) __type\n #define PR_IMPORT_DATA(__type) extern __declspec(dllimport) __type\n \n #define PR_EXTERN(__type) extern __declspec(dllexport) __type\n@@ -82,7 +83,8 @@\n #else /* Unix */\n \n /* GCC 3.3 and later support the visibility attribute. */\n-#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)\n+#if (__GNUC__ >= 4) || \\\n+    (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)\n #define PR_VISIBILITY_DEFAULT __attribute__((visibility(\"default\")))\n #else\n #define PR_VISIBILITY_DEFAULT\n@@ -118,10 +120,8 @@\n **      Macro body brackets so that macros with compound statement definitions\n **      behave syntactically more like functions when called.\n ***********************************************************************/\n-#define PR_BEGIN_MACRO do {\n-#define PR_END_MACRO \\\n-    }                \\\n-    while (0)\n+#define PR_BEGIN_MACRO  do {\n+#define PR_END_MACRO    } while (0)\n \n /***********************************************************************\n ** MACROS:      PR_BEGIN_EXTERN_C\n@@ -130,8 +130,8 @@\n **      Macro shorthands for conditional C++ extern block delimiters.\n ***********************************************************************/\n #ifdef __cplusplus\n-#define PR_BEGIN_EXTERN_C extern \"C\" {\n-#define PR_END_EXTERN_C }\n+#define PR_BEGIN_EXTERN_C       extern \"C\" {\n+#define PR_END_EXTERN_C         }\n #else\n #define PR_BEGIN_EXTERN_C\n #define PR_END_EXTERN_C\n@@ -143,8 +143,8 @@\n ** DESCRIPTION:\n ** Bit masking macros.  XXX n must be <= 31 to be portable\n ***********************************************************************/\n-#define PR_BIT(n) ((PRUint32)1 << (n))\n-#define PR_BITMASK(n) (PR_BIT(n) - 1)\n+#define PR_BIT(n)       ((PRUint32)1 << (n))\n+#define PR_BITMASK(n)   (PR_BIT(n) - 1)\n \n /***********************************************************************\n ** MACROS:      PR_ROUNDUP\n@@ -154,17 +154,17 @@\n ** DESCRIPTION:\n **      Commonly used macros for operations on compatible types.\n ***********************************************************************/\n-#define PR_ROUNDUP(x, y) ((((x) + ((y) - 1)) / (y)) * (y))\n-#define PR_MIN(x, y) ((x) < (y) ? (x) : (y))\n-#define PR_MAX(x, y) ((x) > (y) ? (x) : (y))\n-#define PR_ABS(x) ((x) < 0 ? -(x) : (x))\n+#define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y))\n+#define PR_MIN(x,y)     ((x)<(y)?(x):(y))\n+#define PR_MAX(x,y)     ((x)>(y)?(x):(y))\n+#define PR_ABS(x)       ((x)<0?-(x):(x))\n \n /***********************************************************************\n ** MACROS:      PR_ARRAY_SIZE\n ** DESCRIPTION:\n **  The number of elements in an array.\n ***********************************************************************/\n-#define PR_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))\n+#define PR_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))\n \n PR_BEGIN_EXTERN_C\n \n@@ -228,7 +228,7 @@ typedef signed char PRInt8;\n  *              PR_UINT8_MAX\n  * DESCRIPTION:\n  *  The maximum and minimum values of a PRInt8 or PRUint8.\n- ************************************************************************/\n+************************************************************************/\n \n #define PR_INT8_MAX 127\n #define PR_INT8_MIN (-128)\n@@ -253,7 +253,7 @@ typedef short PRInt16;\n  *              PR_UINT16_MAX\n  * DESCRIPTION:\n  *  The maximum and minimum values of a PRInt16 or PRUint16.\n- ************************************************************************/\n+************************************************************************/\n \n #define PR_INT16_MAX 32767\n #define PR_INT16_MIN (-32768)\n@@ -268,13 +268,13 @@ typedef short PRInt16;\n #if PR_BYTES_PER_INT == 4\n typedef unsigned int PRUint32;\n typedef int PRInt32;\n-#define PR_INT32(x) x\n-#define PR_UINT32(x) x##U\n+#define PR_INT32(x)  x\n+#define PR_UINT32(x) x ## U\n #elif PR_BYTES_PER_LONG == 4\n typedef unsigned long PRUint32;\n typedef long PRInt32;\n-#define PR_INT32(x) x##L\n-#define PR_UINT32(x) x##UL\n+#define PR_INT32(x)  x ## L\n+#define PR_UINT32(x) x ## UL\n #else\n #error No suitable type for PRInt32/PRUint32\n #endif\n@@ -285,7 +285,7 @@ typedef long PRInt32;\n  *              PR_UINT32_MAX\n  * DESCRIPTION:\n  *  The maximum and minimum values of a PRInt32 or PRUint32.\n- ************************************************************************/\n+************************************************************************/\n \n #define PR_INT32_MAX PR_INT32(2147483647)\n #define PR_INT32_MIN (-PR_INT32_MAX - 1)\n@@ -323,24 +323,24 @@ typedef long PRInt32;\n #if PR_BYTES_PER_LONG == 8 && !defined(PR_ALTERNATE_INT64_TYPEDEF)\n typedef long PRInt64;\n typedef unsigned long PRUint64;\n-#define PR_INT64(x) x##L\n-#define PR_UINT64(x) x##UL\n+#define PR_INT64(x)  x ## L\n+#define PR_UINT64(x) x ## UL\n #elif defined(WIN32) && !defined(__GNUC__)\n-typedef __int64 PRInt64;\n+typedef __int64  PRInt64;\n typedef unsigned __int64 PRUint64;\n-#define PR_INT64(x) x##i64\n-#define PR_UINT64(x) x##ui64\n+#define PR_INT64(x)  x ## i64\n+#define PR_UINT64(x) x ## ui64\n #else\n typedef long long PRInt64;\n typedef unsigned long long PRUint64;\n-#define PR_INT64(x) x##LL\n-#define PR_UINT64(x) x##ULL\n+#define PR_INT64(x)  x ## LL\n+#define PR_UINT64(x) x ## ULL\n #endif /* PR_BYTES_PER_LONG == 8 */\n \n #define PR_INT64_MAX PR_INT64(0x7fffffffffffffff)\n #define PR_INT64_MIN (-PR_INT64_MAX - 1)\n #define PR_UINT64_MAX PR_UINT64(-1)\n-#else /* !HAVE_LONG_LONG */\n+#else  /* !HAVE_LONG_LONG */\n typedef struct {\n #ifdef IS_LITTLE_ENDIAN\n     PRUint32 lo, hi;\n@@ -350,9 +350,9 @@ typedef struct {\n } PRInt64;\n typedef PRInt64 PRUint64;\n \n-#define PR_INT64_MAX (PRInt64){ 0x7fffffff, 0xffffffff }\n-#define PR_INT64_MIN (PRInt64){ 0xffffffff, 0xffffffff }\n-#define PR_UINT64_MAX (PRUint64){ 0xffffffff, 0xffffffff }\n+#define PR_INT64_MAX (PRInt64){0x7fffffff, 0xffffffff}\n+#define PR_INT64_MIN (PRInt64){0xffffffff, 0xffffffff}\n+#define PR_UINT64_MAX (PRUint64){0xffffffff, 0xffffffff}\n \n #endif /* !HAVE_LONG_LONG */\n \n@@ -377,7 +377,7 @@ typedef unsigned int PRUintn;\n ** DESCRIPTION:\n **  NSPR's floating point type is always 64 bits.\n ************************************************************************/\n-typedef double PRFloat64;\n+typedef double          PRFloat64;\n \n /************************************************************************\n ** TYPES:       PRSize\n@@ -386,6 +386,7 @@ typedef double PRFloat64;\n ************************************************************************/\n typedef size_t PRSize;\n \n+\n /************************************************************************\n ** TYPES:       PROffset32, PROffset64\n ** DESCRIPTION:\n@@ -438,8 +439,7 @@ typedef PRUint8 PRPackedBool;\n ** Status code used by some routines that have a single point of failure or\n ** special status return.\n */\n-typedef enum { PR_FAILURE = -1,\n-               PR_SUCCESS = 0 } PRStatus;\n+typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;\n \n #ifndef __PRUNICHAR__\n #define __PRUNICHAR__\n@@ -497,24 +497,20 @@ typedef unsigned long PRUword;\n #if defined(NO_NSPR_10_SUPPORT)\n #else\n /********* ???????????????? FIX ME       ??????????????????????????? *****/\n-/********************** Some old definitions until pr=>ds transition is done\n- * ***/\n-/********************** Also, we are still using NSPR 1.0. GC\n- * ******************/\n+/********************** Some old definitions until pr=>ds transition is done ***/\n+/********************** Also, we are still using NSPR 1.0. GC ******************/\n /*\n ** Fundamental NSPR macros, used nearly everywhere.\n */\n \n-#define PR_PUBLIC_API PR_IMPLEMENT\n+#define PR_PUBLIC_API       PR_IMPLEMENT\n \n /*\n ** Macro body brackets so that macros with compound statement definitions\n ** behave syntactically more like functions when called.\n */\n-#define NSPR_BEGIN_MACRO do {\n-#define NSPR_END_MACRO \\\n-    }                  \\\n-    while (0)\n+#define NSPR_BEGIN_MACRO        do {\n+#define NSPR_END_MACRO          } while (0)\n \n /*\n ** Macro shorthands for conditional C++ extern block delimiters.\n@@ -527,8 +523,8 @@ typedef unsigned long PRUword;\n #endif\n \n #ifdef __cplusplus\n-#define NSPR_BEGIN_EXTERN_C extern \"C\" {\n-#define NSPR_END_EXTERN_C }\n+#define NSPR_BEGIN_EXTERN_C     extern \"C\" {\n+#define NSPR_END_EXTERN_C       }\n #else\n #define NSPR_BEGIN_EXTERN_C\n #define NSPR_END_EXTERN_C\n@@ -550,3 +546,4 @@ typedef unsigned long PRUword;\n PR_END_EXTERN_C\n \n #endif /* prtypes_h___ */\n+\ndiff --git a/nspr/pr/include/prvrsion.h b/nspr/pr/include/prvrsion.h\nold mode 100644\nnew mode 100755\nindex d7c4551..99ed1db\n--- a/nspr/pr/include/prvrsion.h\n+++ b/nspr/pr/include/prvrsion.h\n@@ -1,7 +1,9 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n \n+\n /* author: jstewart */\n \n #if defined(_PRVERSION_H)\n@@ -10,12 +12,6 @@\n \n #include \"prtypes.h\"\n \n-#if defined(__clang__) || \\\n-    (defined(__GNUC__) && \\\n-     (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))\n-#define _PR_HAS_PRAGMA_DIAGNOSTIC\n-#endif\n-\n PR_BEGIN_EXTERN_C\n \n /* All components participating in the PR version protocol must expose\n@@ -35,26 +31,26 @@ typedef struct {\n      * At this time, only version 2 is specified. If this value is not\n      * 2, you must read no further into the structure.\n      */\n-    PRInt32 version;\n+    PRInt32    version;\n \n     /* for Version 2, this is the body format. */\n-    PRInt64 buildTime;     /* 64 bits - usecs since midnight, 1/1/1970 */\n-    char* buildTimeString; /* a human readable version of the time */\n-\n-    PRUint8 vMajor; /* Major version of this component */\n-    PRUint8 vMinor; /* Minor version of this component */\n-    PRUint8 vPatch; /* Patch level of this component */\n-\n-    PRBool beta;    /* true if this is a beta component */\n-    PRBool debug;   /* true if this is a debug component */\n-    PRBool special; /* true if this component is a special build */\n-\n-    char* filename;      /* The original filename */\n-    char* description;   /* description of this component */\n-    char* security;      /* level of security in this component */\n-    char* copyright;     /* The copyright for this file */\n-    char* comment;       /* free form field for misc usage */\n-    char* specialString; /* the special variant for this build */\n+    PRInt64         buildTime;      /* 64 bits - usecs since midnight, 1/1/1970 */\n+    char *          buildTimeString;/* a human readable version of the time */\n+\n+    PRUint8   vMajor;               /* Major version of this component */\n+    PRUint8   vMinor;               /* Minor version of this component */\n+    PRUint8   vPatch;               /* Patch level of this component */\n+\n+    PRBool          beta;           /* true if this is a beta component */\n+    PRBool          debug;          /* true if this is a debug component */\n+    PRBool          special;        /* true if this component is a special build */\n+\n+    char *          filename;       /* The original filename */\n+    char *          description;    /* description of this component */\n+    char *          security;       /* level of security in this component */\n+    char *          copyright;      /* The copyright for this file */\n+    char *          comment;        /* free form field for misc usage */\n+    char *          specialString;  /* the special variant for this build */\n } PRVersionDescription;\n \n /* on NT, restore the previous packing */\n@@ -78,7 +74,7 @@ typedef struct {\n  *       return &prVersionDescription_libfoo;\n  *   }\n  */\n-typedef const PRVersionDescription* (*versionEntryPointType)(void);\n+typedef const PRVersionDescription *(*versionEntryPointType)(void);\n \n /*\n  * Where you declare your libVersionPoint, do it like this:\n@@ -103,6 +99,7 @@ typedef const PRVersionDescription* (*versionEntryPointType)(void);\n \n PR_END_EXTERN_C\n \n-#endif /* defined(_PRVERSION_H) */\n+#endif  /* defined(_PRVERSION_H) */\n \n /* prvrsion.h */\n+\ndiff --git a/nspr/pr/src/.cvsignore b/nspr/pr/src/.cvsignore\nnew file mode 100644\nindex 0000000..41a1bd2\n--- /dev/null\n+++ b/nspr/pr/src/.cvsignore\n@@ -0,0 +1,2 @@\n+Makefile\n+_pr_bld.h\ndiff --git a/nspr/pr/src/Makefile.in b/nspr/pr/src/Makefile.in\nindex 8b5ff48..a9e86f5 100644\n--- a/nspr/pr/src/Makefile.in\n+++ b/nspr/pr/src/Makefile.in\n@@ -24,6 +24,10 @@ ifeq ($(USE_BTHREADS), 1)\n \tDIRS += bthreads\n endif\n \n+ifeq ($(USE_CPLUS), 1)\n+\tDIRS += cplus\n+endif\n+\n #\n # Define platform-dependent OS_LIBS\n #\n@@ -226,6 +230,20 @@ endif\n \n endif\n \n+ifeq ($(USE_CPLUS), 1)\n+OBJS += \\\n+\tcplus/$(OBJDIR)/rcbase.$(OBJ_SUFFIX) \\\n+\tcplus/$(OBJDIR)/rccv.$(OBJ_SUFFIX) \\\n+\tcplus/$(OBJDIR)/rcfileio.$(OBJ_SUFFIX) \\\n+\tcplus/$(OBJDIR)/rcinrval.$(OBJ_SUFFIX) \\\n+\tcplus/$(OBJDIR)/rcio.$(OBJ_SUFFIX) \\\n+\tcplus/$(OBJDIR)/rclock.$(OBJ_SUFFIX) \\\n+\tcplus/$(OBJDIR)/rcnetdb.$(OBJ_SUFFIX) \\\n+\tcplus/$(OBJDIR)/rcnetio.$(OBJ_SUFFIX) \\\n+\tcplus/$(OBJDIR)/rcthread.$(OBJ_SUFFIX) \\\n+\tcplus/$(OBJDIR)/rctime.$(OBJ_SUFFIX)\n+endif\n+\n ifeq ($(OS_ARCH), WINNT)\n RES=$(OBJDIR)/nspr.res\n RESNAME=nspr.rc\ndiff --git a/nspr/pr/src/cplus/.cvsignore b/nspr/pr/src/cplus/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/src/cplus/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/src/cplus/Makefile.in b/nspr/pr/src/cplus/Makefile.in\nnew file mode 100644\nindex 0000000..ec08eab\n--- /dev/null\n+++ b/nspr/pr/src/cplus/Makefile.in\n@@ -0,0 +1,43 @@\n+# \n+# This Source Code Form is subject to the terms of the Mozilla Public\n+# License, v. 2.0. If a copy of the MPL was not distributed with this\n+# file, You can obtain one at http://mozilla.org/MPL/2.0/.\n+\n+#! gmake\n+\n+MOD_DEPTH\t= ../../..\n+topsrcdir\t= @top_srcdir@\n+srcdir\t\t= @srcdir@\n+VPATH\t\t= @srcdir@\n+\n+include $(MOD_DEPTH)/config/autoconf.mk\n+\n+include $(topsrcdir)/config/config.mk\n+\n+CXXSRCS =           \\\n+\trcbase.cpp      \\\n+\trccv.cpp\t\t\\\n+\trcfileio.cpp    \\\n+\trcinrval.cpp\t\\\n+\trcio.cpp\t    \\\n+\trclock.cpp\t    \\\n+\trcnetdb.cpp\t    \\\n+\trcnetio.cpp\t    \\\n+\trcthread.cpp\t\\\n+\trctime.cpp      \\\n+\t$(NULL)\n+\n+OBJS = $(addprefix $(OBJDIR)/,$(CXXSRCS:.cpp=.$(OBJ_SUFFIX)))\n+\n+TARGETS\t= $(OBJS)\n+\n+INCLUDES = -I$(dist_includedir)\n+\n+DEFINES\t+= -D_NSPR_BUILD_\n+\n+include $(topsrcdir)/config/rules.mk\n+\n+HEADERS = $(wildcard $(srcdir)/*.h)\n+\n+export:: $(TARGETS)\n+\ndiff --git a/nspr/pr/src/cplus/rcascii.h b/nspr/pr/src/cplus/rcascii.h\nnew file mode 100644\nindex 0000000..f8b59ce\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcascii.h\n@@ -0,0 +1,143 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** Class definitions to format ASCII data.\n+*/\n+\n+#if defined(_RCASCII_H)\n+#else\n+#define _RCASCII_H\n+\n+/*\n+** RCFormatStuff\n+**  This class maintains no state - that is the responsibility of\n+**  the class' client. For each call to Sx_printf(), the StuffFunction\n+**  will be called for each embedded \"%\" in the 'fmt' string and once\n+**  for each interveaning literal.\n+*/\n+class PR_IMPLEMENT(RCFormatStuff)\n+{\n+public:\n+    RCFormatStuff();\n+    virtual ~RCFormatStuff();\n+\n+    /*\n+    ** Process the arbitrary argument list using as indicated by\n+    ** the 'fmt' string. Each segment of the processing the stuff\n+    ** function is called with the relavent translation.\n+    */\n+    virtual PRInt32 Sx_printf(void *state, const char *fmt, ...);\n+\n+    /*\n+    ** The 'state' argument is not processed by the runtime. It\n+    ** is merely passed from the Sx_printf() call. It is intended\n+    ** to be used by the client to figure out what to do with the\n+    ** new string.\n+    **\n+    ** The new string ('stuff') is ASCII translation driven by the\n+    ** Sx_printf()'s 'fmt' string. It is not guaranteed to be a null\n+    ** terminated string.\n+    **\n+    ** The return value is the number of bytes copied from the 'stuff'\n+    ** string. It is accumulated for each of the calls to the stuff\n+    ** function and returned from the original caller of Sx_printf().\n+    */\n+    virtual PRSize StuffFunction(\n+        void *state, const char *stuff, PRSize stufflen) = 0;\n+};  /* RCFormatStuff */\n+\n+\n+/*\n+** RCFormatBuffer\n+**  The caller is supplying the buffer, the runtime is doing all\n+**  the conversion. The object contains no state, so is reusable\n+**  and reentrant.\n+*/\n+class PR_IMPLEMENT(RCFormatBuffer): public RCFormatStuff\n+{\n+public:\n+    RCFormatBuffer();\n+    virtual ~RCFormatBuffer();\n+\n+    /*\n+    ** Format the trailing arguments as indicated by the 'fmt'\n+    ** string. Put the result in 'buffer'. Return the number\n+    ** of bytes moved into 'buffer'. 'buffer' will always be\n+    ** a properly terminated string even if the convresion fails.\n+    */\n+    virtual PRSize Sn_printf(\n+        char *buffer, PRSize length, const char *fmt, ...);\n+\n+    virtual char *Sm_append(char *buffer, const char *fmt, ...);\n+\n+private:\n+    /*\n+    ** This class overrides the stuff function, does not preserve\n+    ** its virtual-ness and no longer allows the clients to call\n+    ** it in the clear. In other words, it is now the implementation\n+    ** for this class.\n+    */\n+    PRSize StuffFunction(void*, const char*, PRSize);\n+\n+};  /* RCFormatBuffer */\n+\n+/*\n+** RCFormat\n+**  The runtime is supplying the buffer. The object has state - the\n+**  buffer. Each operation must run to completion before the object\n+**  can be reused. When it is, the buffer is reset (whatever that\n+**  means). The result of a conversion is available via the extractor.\n+**  After extracted, the memory still belongs to the class - if the\n+**  caller wants to retain or modify, it must first be copied.\n+*/\n+class PR_IMPLEMENT(RCFormat): pubic RCFormatBuffer\n+{\n+public:\n+    RCFormat();\n+    virtual ~RCFormat();\n+\n+    /*\n+    ** Translate the trailing arguments according to the 'fmt'\n+    ** string and store the results in the object.\n+    */\n+    virtual PRSize Sm_printf(const char *fmt, ...);\n+\n+    /*\n+    ** Extract the latest translation.\n+    ** The object does not surrender the memory occupied by\n+    ** the string. If the caller wishes to modify the data,\n+    ** it must first be copied.\n+    */\n+    const char*();\n+\n+private:\n+    char *buffer;\n+\n+    RCFormat(const RCFormat&);\n+    RCFormat& operator=(const RCFormat&);\n+}; /* RCFormat */\n+\n+/*\n+** RCPrint\n+**  The output is formatted and then written to an associated file\n+**  descriptor. The client can provide a suitable file descriptor\n+**  or can indicate that the output should be directed to one of\n+**  the well-known \"console\" devices.\n+*/\n+class PR_IMPLEMENT(RCPrint): public RCFormat\n+{\n+    virtual ~RCPrint();\n+    RCPrint(RCIO* output);\n+    RCPrint(RCFileIO::SpecialFile output);\n+\n+    virtual PRSize Printf(const char *fmt, ...);\n+private:\n+    RCPrint();\n+};  /* RCPrint */\n+\n+#endif /* defined(_RCASCII_H) */\n+\n+/* RCAscii.h */\ndiff --git a/nspr/pr/src/cplus/rcbase.cpp b/nspr/pr/src/cplus/rcbase.cpp\nnew file mode 100644\nindex 0000000..7c12e6d\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcbase.cpp\n@@ -0,0 +1,31 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** RCBase.cpp - Mixin class for NSPR C++ wrappers\n+*/\n+\n+#include \"rcbase.h\"\n+\n+RCBase::~RCBase() { }\n+\n+PRSize RCBase::GetErrorTextLength() {\n+    return PR_GetErrorTextLength();\n+}\n+PRSize RCBase::CopyErrorText(char *text) {\n+    return PR_GetErrorText(text);\n+}\n+\n+void RCBase::SetError(PRErrorCode error, PRInt32 oserror)\n+{\n+    PR_SetError(error, oserror);\n+}\n+\n+void RCBase::SetErrorText(PRSize text_length, const char *text)\n+{\n+    PR_SetErrorText(text_length, text);\n+}\n+\n+/* rcbase.cpp */\ndiff --git a/nspr/pr/src/cplus/rcbase.h b/nspr/pr/src/cplus/rcbase.h\nnew file mode 100644\nindex 0000000..3cc91f8\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcbase.h\n@@ -0,0 +1,55 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** RCBase.h - Mixin class for NSPR C++ wrappers\n+*/\n+\n+#if defined(_RCRUNTIME_H)\n+#else\n+#define _RCRUNTIME_H\n+\n+#include <prerror.h>\n+\n+/*\n+** Class: RCBase (mixin)\n+**\n+** Generally mixed into every base class. The functions in this class are all\n+** static. Therefore this entire class is just syntatic sugar. It gives the\n+** illusion that errors (in particular) are retrieved via the same object\n+** that just reported a failure. It also (unfortunately) might lead one to\n+** believe that the errors are persistent in that object. They're not.\n+*/\n+\n+class PR_IMPLEMENT(RCBase)\n+{\n+public:\n+    virtual ~RCBase();\n+\n+    static void AbortSelf();\n+\n+    static PRErrorCode GetError();\n+    static PRInt32 GetOSError();\n+\n+    static PRSize GetErrorTextLength();\n+    static PRSize CopyErrorText(char *text);\n+\n+    static void SetError(PRErrorCode error, PRInt32 oserror);\n+    static void SetErrorText(PRSize textLength, const char *text);\n+\n+protected:\n+    RCBase() { }\n+};  /* RCObject */\n+\n+inline PRErrorCode RCBase::GetError() {\n+    return PR_GetError();\n+}\n+inline PRInt32 RCBase::GetOSError() {\n+    return PR_GetOSError();\n+}\n+\n+#endif  /* defined(_RCRUNTIME_H) */\n+\n+/* rcbase.h */\ndiff --git a/nspr/pr/src/cplus/rccv.cpp b/nspr/pr/src/cplus/rccv.cpp\nnew file mode 100644\nindex 0000000..f124385\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rccv.cpp\n@@ -0,0 +1,70 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** RCCondition - C++ wrapper around NSPR's PRCondVar\n+*/\n+\n+#include \"rccv.h\"\n+\n+#include <prlog.h>\n+#include <prerror.h>\n+#include <prcvar.h>\n+\n+RCCondition::RCCondition(class RCLock *lock): RCBase()\n+{\n+    cv = PR_NewCondVar(lock->lock);\n+    PR_ASSERT(NULL != cv);\n+    timeout = PR_INTERVAL_NO_TIMEOUT;\n+}  /* RCCondition::RCCondition */\n+\n+RCCondition::~RCCondition()\n+{\n+    if (NULL != cv) {\n+        PR_DestroyCondVar(cv);\n+    }\n+}  /* RCCondition::~RCCondition */\n+\n+PRStatus RCCondition::Wait()\n+{\n+    PRStatus rv;\n+    PR_ASSERT(NULL != cv);\n+    if (NULL == cv)\n+    {\n+        SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+        rv = PR_FAILURE;\n+    }\n+    else {\n+        rv = PR_WaitCondVar(cv, timeout.interval);\n+    }\n+    return rv;\n+}  /* RCCondition::Wait */\n+\n+PRStatus RCCondition::Notify()\n+{\n+    return PR_NotifyCondVar(cv);\n+}  /* RCCondition::Notify */\n+\n+PRStatus RCCondition::Broadcast()\n+{\n+    return PR_NotifyAllCondVar(cv);\n+}  /* RCCondition::Broadcast */\n+\n+PRStatus RCCondition::SetTimeout(const RCInterval& tmo)\n+{\n+    if (NULL == cv)\n+    {\n+        SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+        return PR_FAILURE;\n+    }\n+    timeout = tmo;\n+    return PR_SUCCESS;\n+}  /* RCCondition::SetTimeout */\n+\n+RCInterval RCCondition::GetTimeout() const {\n+    return timeout;\n+}\n+\n+/* rccv.cpp */\ndiff --git a/nspr/pr/src/cplus/rccv.h b/nspr/pr/src/cplus/rccv.h\nnew file mode 100644\nindex 0000000..afeec61\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rccv.h\n@@ -0,0 +1,64 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** RCCondition - C++ wrapper around NSPR's PRCondVar\n+**\n+** Conditions have a notion of timeouts. A thread that waits on a condition\n+** will resume execution when the condition is notified OR when a specified\n+** interval of time has expired.\n+**\n+** Most applications don't adjust the timeouts on conditions. The literature\n+** would argue that all threads waiting on a single condition must have the\n+** same semantics. But if an application wishes to modify the timeout with\n+** (perhaps) each wait call, that modification should be done consistantly\n+** and under protection of the condition's associated lock.\n+**\n+** The default timeout is infinity.\n+*/\n+\n+#if defined(_RCCOND_H)\n+#else\n+#define _RCCOND_H\n+\n+#include \"rclock.h\"\n+#include \"rcbase.h\"\n+#include \"rcinrval.h\"\n+\n+struct PRCondVar;\n+\n+class PR_IMPLEMENT(RCCondition): public RCBase\n+{\n+public:\n+    RCCondition(RCLock*);           /* associates CV with a lock and infinite tmo */\n+    virtual ~RCCondition();\n+\n+    virtual PRStatus Wait();        /* applies object's current timeout */\n+\n+    virtual PRStatus Notify();      /* perhaps ready one thread */\n+    virtual PRStatus Broadcast();   /* perhaps ready many threads */\n+\n+    virtual PRStatus SetTimeout(const RCInterval&);\n+    /* set object's current timeout value */\n+\n+private:\n+    PRCondVar *cv;\n+    RCInterval timeout;\n+\n+    RCCondition();\n+    RCCondition(const RCCondition&);\n+    void operator=(const RCCondition&);\n+\n+public:\n+    RCInterval GetTimeout() const;\n+};  /* RCCondition */\n+\n+inline RCCondition::RCCondition(): RCBase() { }\n+inline RCCondition::RCCondition(const RCCondition&): RCBase() { }\n+inline void RCCondition::operator=(const RCCondition&) { }\n+\n+#endif /* defined(_RCCOND_H) */\n+\n+/* RCCond.h */\ndiff --git a/nspr/pr/src/cplus/rcfileio.cpp b/nspr/pr/src/cplus/rcfileio.cpp\nnew file mode 100644\nindex 0000000..91c5fde\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcfileio.cpp\n@@ -0,0 +1,247 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** Class implementation for normal and special file I/O (ref: prio.h)\n+*/\n+\n+#include \"rcfileio.h\"\n+\n+#include <string.h>\n+\n+RCFileIO::RCFileIO(): RCIO(RCIO::file) { }\n+\n+RCFileIO::~RCFileIO() {\n+    if (NULL != fd) {\n+        (void)Close();\n+    }\n+}\n+\n+PRInt64 RCFileIO::Available()\n+{\n+    return fd->methods->available(fd);\n+}\n+\n+PRStatus RCFileIO::Close()\n+{\n+    PRStatus rv = fd->methods->close(fd);\n+    fd = NULL;\n+    return rv;\n+}\n+\n+PRStatus RCFileIO::Delete(const char* filename) {\n+    return PR_Delete(filename);\n+}\n+\n+PRStatus RCFileIO::FileInfo(RCFileInfo* info) const\n+{\n+    return fd->methods->fileInfo64(fd, &info->info);\n+}\n+\n+PRStatus RCFileIO::FileInfo(const char *name, RCFileInfo* info)\n+{\n+    return PR_GetFileInfo64(name, &info->info);\n+}\n+\n+PRStatus RCFileIO::Fsync()\n+{\n+    return fd->methods->fsync(fd);\n+}\n+\n+PRStatus RCFileIO::Open(const char *filename, PRIntn flags, PRIntn mode)\n+{\n+    fd = PR_Open(filename, flags, mode);\n+    return (NULL == fd) ? PR_FAILURE : PR_SUCCESS;\n+}  /* RCFileIO::Open */\n+\n+PRInt32 RCFileIO::Read(void *buf, PRSize amount)\n+{\n+    return fd->methods->read(fd, buf, amount);\n+}\n+\n+PRInt64 RCFileIO::Seek(PRInt64 offset, RCIO::Whence how)\n+{\n+    PRSeekWhence whence;\n+    switch (how)\n+    {\n+        case RCFileIO::set: whence = PR_SEEK_SET; break;\n+        case RCFileIO::current: whence = PR_SEEK_CUR; break;\n+        case RCFileIO::end: whence = PR_SEEK_END; break;\n+        default: whence = (PRSeekWhence)-1;\n+    }\n+    return fd->methods->seek64(fd, offset, whence);\n+}  /* RCFileIO::Seek */\n+\n+PRInt32 RCFileIO::Write(const void *buf, PRSize amount)\n+{\n+    return fd->methods->write(fd, buf, amount);\n+}\n+\n+PRInt32 RCFileIO::Writev(\n+    const PRIOVec *iov, PRSize size, const RCInterval& timeout)\n+{\n+    return fd->methods->writev(fd, iov, size, timeout);\n+}\n+\n+RCIO *RCFileIO::GetSpecialFile(RCFileIO::SpecialFile special)\n+{\n+    PRFileDesc* fd;\n+    PRSpecialFD which;\n+    RCFileIO* spec = NULL;\n+\n+    switch (special)\n+    {\n+        case RCFileIO::input: which = PR_StandardInput; break;\n+        case RCFileIO::output: which = PR_StandardOutput; break;\n+        case RCFileIO::error: which = PR_StandardError; break;\n+        default: which = (PRSpecialFD)-1;\n+    }\n+    fd = PR_GetSpecialFD(which);\n+    if (NULL != fd)\n+    {\n+        spec = new RCFileIO();\n+        if (NULL != spec) {\n+            spec->fd = fd;\n+        }\n+    }\n+    return spec;\n+}  /* RCFileIO::GetSpecialFile */\n+\n+\n+/*\n+** The following methods have been made non-virtual and private. These\n+** default implementations are intended to NEVER be called. They\n+** are not valid for this type of I/O class (normal and special file).\n+*/\n+PRStatus RCFileIO::Connect(const RCNetAddr&, const RCInterval&)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return PR_FAILURE;\n+}\n+\n+PRStatus RCFileIO::GetLocalName(RCNetAddr*) const\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return PR_FAILURE;\n+}\n+\n+PRStatus RCFileIO::GetPeerName(RCNetAddr*) const\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return PR_FAILURE;\n+}\n+\n+PRStatus RCFileIO::GetSocketOption(PRSocketOptionData*) const\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return PR_FAILURE;\n+}\n+\n+PRStatus RCFileIO::Listen(PRIntn)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return PR_FAILURE;\n+}\n+\n+PRInt16 RCFileIO::Poll(PRInt16, PRInt16*)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return 0;\n+}\n+\n+PRInt32 RCFileIO::Recv(void*, PRSize, PRIntn, const RCInterval&)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return -1;\n+}\n+\n+PRInt32 RCFileIO::Recvfrom(void*, PRSize, PRIntn, RCNetAddr*, const RCInterval&)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return -1;\n+}\n+\n+PRInt32 RCFileIO::Send(\n+    const void*, PRSize, PRIntn, const RCInterval&)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return -1;\n+}\n+\n+PRInt32 RCFileIO::Sendto(\n+    const void*, PRSize, PRIntn, const RCNetAddr&, const RCInterval&)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return -1;\n+}\n+\n+RCIO* RCFileIO::Accept(RCNetAddr*, const RCInterval&)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return NULL;\n+}\n+\n+PRStatus RCFileIO::Bind(const RCNetAddr&)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return PR_FAILURE;\n+}\n+\n+PRInt32 RCFileIO::AcceptRead(\n+    RCIO**, RCNetAddr**, void*, PRSize, const RCInterval&)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return -1;\n+}\n+\n+PRStatus RCFileIO::SetSocketOption(const PRSocketOptionData*)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return PR_FAILURE;\n+}\n+\n+PRStatus RCFileIO::Shutdown(RCIO::ShutdownHow)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return PR_FAILURE;\n+}\n+\n+PRInt32 RCFileIO::TransmitFile(\n+    RCIO*, const void*, PRSize, RCIO::FileDisposition, const RCInterval&)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return -1;\n+}\n+\n+/*\n+** Class implementation for file information object (ref: prio.h)\n+*/\n+\n+RCFileInfo::~RCFileInfo() { }\n+\n+RCFileInfo::RCFileInfo(const RCFileInfo& her): RCBase()\n+{\n+    info = her.info;    /* RCFileInfo::RCFileInfo */\n+}\n+\n+RCTime RCFileInfo::CreationTime() const {\n+    return RCTime(info.creationTime);\n+}\n+\n+RCTime RCFileInfo::ModifyTime() const {\n+    return RCTime(info.modifyTime);\n+}\n+\n+RCFileInfo::FileType RCFileInfo::Type() const\n+{\n+    RCFileInfo::FileType type;\n+    switch (info.type)\n+    {\n+        case PR_FILE_FILE: type = RCFileInfo::file; break;\n+        case PR_FILE_DIRECTORY: type = RCFileInfo::directory; break;\n+        default: type = RCFileInfo::other;\n+    }\n+    return type;\n+}  /* RCFileInfo::Type */\ndiff --git a/nspr/pr/src/cplus/rcfileio.h b/nspr/pr/src/cplus/rcfileio.h\nnew file mode 100644\nindex 0000000..9e28b36\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcfileio.h\n@@ -0,0 +1,131 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** Class definitions for normal and special file I/O (ref: prio.h)\n+*/\n+\n+#if defined(_RCFILEIO_H)\n+#else\n+#define _RCFILEIO_H\n+\n+#include \"rcio.h\"\n+#include \"rctime.h\"\n+\n+/*\n+** One would normally create a concrete class, such as RCFileIO, but then\n+** pass around more generic references, ie., RCIO.\n+**\n+** This subclass of RCIO hides (makes private) the methods that are not\n+** applicable to normal files.\n+*/\n+\n+class RCFileInfo;\n+\n+class PR_IMPLEMENT(RCFileIO): public RCIO\n+{\n+public:\n+    RCFileIO();\n+    virtual ~RCFileIO();\n+\n+    virtual PRInt64     Available();\n+    virtual PRStatus    Close();\n+    static  PRStatus    Delete(const char *name);\n+    virtual PRStatus    FileInfo(RCFileInfo* info) const;\n+    static  PRStatus    FileInfo(const char *name, RCFileInfo* info);\n+    virtual PRStatus    Fsync();\n+    virtual PRStatus    Open(const char *name, PRIntn flags, PRIntn mode);\n+    virtual PRInt32     Read(void *buf, PRSize amount);\n+    virtual PRInt64     Seek(PRInt64 offset, RCIO::Whence how);\n+    virtual PRInt32     Write(const void *buf, PRSize amount);\n+    virtual PRInt32     Writev(\n+        const PRIOVec *iov, PRSize size,\n+        const RCInterval& timeout);\n+\n+private:\n+\n+    /* These methods made private are unavailable for this object */\n+    RCFileIO(const RCFileIO&);\n+    void operator=(const RCFileIO&);\n+\n+    RCIO*       Accept(RCNetAddr* addr, const RCInterval& timeout);\n+    PRInt32     AcceptRead(\n+        RCIO **newfd, RCNetAddr **address, void *buffer,\n+        PRSize amount, const RCInterval& timeout);\n+    PRStatus    Bind(const RCNetAddr& addr);\n+    PRStatus    Connect(const RCNetAddr& addr, const RCInterval& timeout);\n+    PRStatus    GetLocalName(RCNetAddr *addr) const;\n+    PRStatus    GetPeerName(RCNetAddr *addr) const;\n+    PRStatus    GetSocketOption(PRSocketOptionData *data) const;\n+    PRStatus    Listen(PRIntn backlog);\n+    PRInt16     Poll(PRInt16 in_flags, PRInt16 *out_flags);\n+    PRInt32     Recv(\n+        void *buf, PRSize amount, PRIntn flags,\n+        const RCInterval& timeout);\n+    PRInt32     Recvfrom(\n+        void *buf, PRSize amount, PRIntn flags,\n+        RCNetAddr* addr, const RCInterval& timeout);\n+    PRInt32     Send(\n+        const void *buf, PRSize amount, PRIntn flags,\n+        const RCInterval& timeout);\n+    PRInt32     Sendto(\n+        const void *buf, PRSize amount, PRIntn flags,\n+        const RCNetAddr& addr,\n+        const RCInterval& timeout);\n+    PRStatus    SetSocketOption(const PRSocketOptionData *data);\n+    PRStatus    Shutdown(RCIO::ShutdownHow how);\n+    PRInt32     TransmitFile(\n+        RCIO *source, const void *headers,\n+        PRSize hlen, RCIO::FileDisposition flags,\n+        const RCInterval& timeout);\n+public:\n+\n+    /*\n+    ** The following function return a valid normal file object,\n+    ** Such objects can be used for scanned input and console output.\n+    */\n+    typedef enum {\n+        input = PR_StandardInput,\n+        output = PR_StandardOutput,\n+        error = PR_StandardError\n+    } SpecialFile;\n+\n+    static RCIO *GetSpecialFile(RCFileIO::SpecialFile special);\n+\n+};  /* RCFileIO */\n+\n+class PR_IMPLEMENT(RCFileInfo): public RCBase\n+{\n+public:\n+    typedef enum {\n+        file = PR_FILE_FILE,\n+        directory = PR_FILE_DIRECTORY,\n+        other = PR_FILE_OTHER\n+    } FileType;\n+\n+public:\n+    RCFileInfo();\n+    RCFileInfo(const RCFileInfo&);\n+\n+    virtual ~RCFileInfo();\n+\n+    PRInt64 Size() const;\n+    RCTime CreationTime() const;\n+    RCTime ModifyTime() const;\n+    RCFileInfo::FileType Type() const;\n+\n+    friend PRStatus RCFileIO::FileInfo(RCFileInfo*) const;\n+    friend PRStatus RCFileIO::FileInfo(const char *name, RCFileInfo*);\n+\n+private:\n+    PRFileInfo64 info;\n+};  /* RCFileInfo */\n+\n+inline RCFileInfo::RCFileInfo(): RCBase() { }\n+inline PRInt64 RCFileInfo::Size() const {\n+    return info.size;\n+}\n+\n+#endif /* defined(_RCFILEIO_H) */\ndiff --git a/nspr/pr/src/cplus/rcinrval.cpp b/nspr/pr/src/cplus/rcinrval.cpp\nnew file mode 100644\nindex 0000000..3805a57\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcinrval.cpp\n@@ -0,0 +1,37 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** C++ interval times (ref: prinrval.h)\n+**\n+**  An interval is a period of time. The start of the interval (epoch)\n+**  must be defined by the application. The unit of time of an interval\n+**  is platform dependent, therefore so is the maximum interval that is\n+**  representable. However, that interval is never less that ~12 hours.\n+*/\n+\n+#include \"rcinrval.h\"\n+\n+RCInterval::~RCInterval() { }\n+\n+RCInterval::RCInterval(RCInterval::RCReservedInterval special): RCBase()\n+{\n+    switch (special)\n+    {\n+        case RCInterval::now:\n+            interval = PR_IntervalNow();\n+            break;\n+        case RCInterval::no_timeout:\n+            interval = PR_INTERVAL_NO_TIMEOUT;\n+            break;\n+        case RCInterval::no_wait:\n+            interval = PR_INTERVAL_NO_WAIT;\n+            break;\n+        default:\n+            break;\n+    }\n+}  /* RCInterval::RCInterval */\n+\n+/* rcinrval.cpp */\ndiff --git a/nspr/pr/src/cplus/rcinrval.h b/nspr/pr/src/cplus/rcinrval.h\nnew file mode 100644\nindex 0000000..333209e\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcinrval.h\n@@ -0,0 +1,191 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** C++ interval times (ref: prinrval.h)\n+**\n+**  An interval is a period of time. The start of the interval (epoch)\n+**  must be defined by the application. The unit of time of an interval\n+**  is platform dependent, therefore so is the maximum interval that is\n+**  representable. However, that interval is never less than ~6 hours.\n+*/\n+#if defined(_RCINTERVAL_H)\n+#else\n+#define _RCINTERVAL_H\n+\n+#include \"rcbase.h\"\n+#include <prinrval.h>\n+\n+class PR_IMPLEMENT(RCInterval): public RCBase\n+{\n+public:\n+    typedef enum {now, no_timeout, no_wait} RCReservedInterval;\n+\n+    virtual ~RCInterval();\n+\n+    RCInterval();\n+\n+    RCInterval(PRIntervalTime interval);\n+    RCInterval(const RCInterval& copy);\n+    RCInterval(RCReservedInterval special);\n+\n+    void SetToNow();\n+\n+    void operator=(const RCInterval&);\n+    void operator=(PRIntervalTime interval);\n+\n+    PRBool operator<(const RCInterval&);\n+    PRBool operator>(const RCInterval&);\n+    PRBool operator==(const RCInterval&);\n+    PRBool operator>=(const RCInterval&);\n+    PRBool operator<=(const RCInterval&);\n+\n+    RCInterval operator+(const RCInterval&);\n+    RCInterval operator-(const RCInterval&);\n+    RCInterval& operator+=(const RCInterval&);\n+    RCInterval& operator-=(const RCInterval&);\n+\n+    RCInterval operator/(PRUint32);\n+    RCInterval operator*(PRUint32);\n+    RCInterval& operator/=(PRUint32);\n+    RCInterval& operator*=(PRUint32);\n+\n+\n+    PRUint32 ToSeconds() const;\n+    PRUint32 ToMilliseconds() const;\n+    PRUint32 ToMicroseconds() const;\n+    operator PRIntervalTime() const;\n+\n+    static PRIntervalTime FromSeconds(PRUint32 seconds);\n+    static PRIntervalTime FromMilliseconds(PRUint32 milli);\n+    static PRIntervalTime FromMicroseconds(PRUint32 micro);\n+\n+    friend class RCCondition;\n+\n+private:\n+    PRIntervalTime interval;\n+\n+};  /* RCInterval */\n+\n+\n+inline RCInterval::RCInterval(): RCBase() { }\n+\n+inline RCInterval::RCInterval(const RCInterval& his): RCBase()\n+{\n+    interval = his.interval;\n+}\n+\n+inline RCInterval::RCInterval(PRIntervalTime ticks): RCBase()\n+{\n+    interval = ticks;\n+}\n+\n+inline void RCInterval::SetToNow() {\n+    interval = PR_IntervalNow();\n+}\n+\n+inline void RCInterval::operator=(const RCInterval& his)\n+{\n+    interval = his.interval;\n+}\n+\n+inline void RCInterval::operator=(PRIntervalTime his)\n+{\n+    interval = his;\n+}\n+\n+inline PRBool RCInterval::operator==(const RCInterval& his)\n+{\n+    return (interval == his.interval) ? PR_TRUE : PR_FALSE;\n+}\n+inline PRBool RCInterval::operator<(const RCInterval& his)\n+{\n+    return (interval < his.interval)? PR_TRUE : PR_FALSE;\n+}\n+inline PRBool RCInterval::operator>(const RCInterval& his)\n+{\n+    return (interval > his.interval) ? PR_TRUE : PR_FALSE;\n+}\n+inline PRBool RCInterval::operator<=(const RCInterval& his)\n+{\n+    return (interval <= his.interval) ? PR_TRUE : PR_FALSE;\n+}\n+inline PRBool RCInterval::operator>=(const RCInterval& his)\n+{\n+    return (interval <= his.interval) ? PR_TRUE : PR_FALSE;\n+}\n+\n+inline RCInterval RCInterval::operator+(const RCInterval& his)\n+{\n+    return RCInterval((PRIntervalTime)(interval + his.interval));\n+}\n+inline RCInterval RCInterval::operator-(const RCInterval& his)\n+{\n+    return RCInterval((PRIntervalTime)(interval - his.interval));\n+}\n+inline RCInterval& RCInterval::operator+=(const RCInterval& his)\n+{\n+    interval += his.interval;\n+    return *this;\n+}\n+inline RCInterval& RCInterval::operator-=(const RCInterval& his)\n+{\n+    interval -= his.interval;\n+    return *this;\n+}\n+\n+inline RCInterval RCInterval::operator/(PRUint32 him)\n+{\n+    return RCInterval((PRIntervalTime)(interval / him));\n+}\n+inline RCInterval RCInterval::operator*(PRUint32 him)\n+{\n+    return RCInterval((PRIntervalTime)(interval * him));\n+}\n+\n+inline RCInterval& RCInterval::operator/=(PRUint32 him)\n+{\n+    interval /= him;\n+    return *this;\n+}\n+\n+inline RCInterval& RCInterval::operator*=(PRUint32 him)\n+{\n+    interval *= him;\n+    return *this;\n+}\n+\n+inline PRUint32 RCInterval::ToSeconds() const\n+{\n+    return PR_IntervalToSeconds(interval);\n+}\n+inline PRUint32 RCInterval::ToMilliseconds() const\n+{\n+    return PR_IntervalToMilliseconds(interval);\n+}\n+inline PRUint32 RCInterval::ToMicroseconds() const\n+{\n+    return PR_IntervalToMicroseconds(interval);\n+}\n+inline RCInterval::operator PRIntervalTime() const {\n+    return interval;\n+}\n+\n+inline PRIntervalTime RCInterval::FromSeconds(PRUint32 seconds)\n+{\n+    return PR_SecondsToInterval(seconds);\n+}\n+inline PRIntervalTime RCInterval::FromMilliseconds(PRUint32 milli)\n+{\n+    return PR_MillisecondsToInterval(milli);\n+}\n+inline PRIntervalTime RCInterval::FromMicroseconds(PRUint32 micro)\n+{\n+    return PR_MicrosecondsToInterval(micro);\n+}\n+\n+#endif  /* defined(_RCINTERVAL_H) */\n+\n+/* RCInterval.h */\ndiff --git a/nspr/pr/src/cplus/rcio.cpp b/nspr/pr/src/cplus/rcio.cpp\nnew file mode 100644\nindex 0000000..081a9f6\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcio.cpp\n@@ -0,0 +1,14 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** Base class implmenation for I/O (ref: prio.h)\n+*/\n+\n+#include \"rcio.h\"\n+\n+RCIO::~RCIO() { }\n+\n+RCIO::RCIO(RCIO::RCIOType): RCBase() { }\ndiff --git a/nspr/pr/src/cplus/rcio.h b/nspr/pr/src/cplus/rcio.h\nnew file mode 100644\nindex 0000000..1bd3ac4\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcio.h\n@@ -0,0 +1,117 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** Base class definitions for I/O (ref: prio.h)\n+**\n+** This class is a virtual base class. Construction must be done by a\n+** subclass, but the I/O operations can be done on a RCIO object reference.\n+*/\n+\n+#if defined(_RCIO_H)\n+#else\n+#define _RCIO_H\n+\n+#include \"rcbase.h\"\n+#include \"rcnetdb.h\"\n+#include \"rcinrval.h\"\n+\n+#include \"prio.h\"\n+\n+class RCFileInfo;\n+\n+class PR_IMPLEMENT(RCIO): public RCBase\n+{\n+public:\n+    typedef enum {\n+        open = PR_TRANSMITFILE_KEEP_OPEN,   /* socket is left open after file\n+                                             * is transmitted. */\n+        close = PR_TRANSMITFILE_CLOSE_SOCKET/* socket is closed after file\n+                                             * is transmitted. */\n+    } FileDisposition;\n+\n+    typedef enum {\n+        set = PR_SEEK_SET,                  /* Set to value specified */\n+        current = PR_SEEK_CUR,              /* Seek relative to current position */\n+        end = PR_SEEK_END                   /* seek past end of current eof */\n+    } Whence;\n+\n+    typedef enum {\n+        recv = PR_SHUTDOWN_RCV,             /* receives will be disallowed */\n+        send = PR_SHUTDOWN_SEND,            /* sends will be disallowed */\n+        both = PR_SHUTDOWN_BOTH             /* sends & receives will be disallowed */\n+    } ShutdownHow;\n+\n+public:\n+    virtual ~RCIO();\n+\n+    virtual RCIO*       Accept(RCNetAddr* addr, const RCInterval& timeout) = 0;\n+    virtual PRInt32     AcceptRead(\n+        RCIO **nd, RCNetAddr **raddr, void *buf,\n+        PRSize amount, const RCInterval& timeout) = 0;\n+    virtual PRInt64     Available() = 0;\n+    virtual PRStatus    Bind(const RCNetAddr& addr) = 0;\n+    virtual PRStatus    Close() = 0;\n+    virtual PRStatus    Connect(\n+        const RCNetAddr& addr,\n+        const RCInterval& timeout) = 0;\n+    virtual PRStatus    FileInfo(RCFileInfo *info) const = 0;\n+    virtual PRStatus    Fsync() = 0;\n+    virtual PRStatus    GetLocalName(RCNetAddr *addr) const = 0;\n+    virtual PRStatus    GetPeerName(RCNetAddr *addr) const = 0;\n+    virtual PRStatus    GetSocketOption(PRSocketOptionData *data) const = 0;\n+    virtual PRStatus    Listen(PRIntn backlog) = 0;\n+    virtual PRStatus    Open(const char *name, PRIntn flags, PRIntn mode) = 0;\n+    virtual PRInt16     Poll(PRInt16 in_flags, PRInt16 *out_flags) = 0;\n+    virtual PRInt32     Read(void *buf, PRSize amount) = 0;\n+    virtual PRInt32     Recv(\n+        void *buf, PRSize amount, PRIntn flags,\n+        const RCInterval& timeout) = 0;\n+    virtual PRInt32     Recvfrom(\n+        void *buf, PRSize amount, PRIntn flags,\n+        RCNetAddr* addr, const RCInterval& timeout) = 0;\n+    virtual PRInt64     Seek(PRInt64 offset, Whence how) = 0;\n+    virtual PRInt32     Send(\n+        const void *buf, PRSize amount, PRIntn flags,\n+        const RCInterval& timeout) = 0;\n+    virtual PRInt32     Sendto(\n+        const void *buf, PRSize amount, PRIntn flags,\n+        const RCNetAddr& addr,\n+        const RCInterval& timeout) = 0;\n+    virtual PRStatus    SetSocketOption(const PRSocketOptionData *data) = 0;\n+    virtual PRStatus    Shutdown(ShutdownHow how) = 0;\n+    virtual PRInt32     TransmitFile(\n+        RCIO *source, const void *headers,\n+        PRSize hlen, RCIO::FileDisposition flags,\n+        const RCInterval& timeout) = 0;\n+    virtual PRInt32     Write(const void *buf, PRSize amount) = 0;\n+    virtual PRInt32     Writev(\n+        const PRIOVec *iov, PRSize size,\n+        const RCInterval& timeout) = 0;\n+\n+protected:\n+    typedef enum {\n+        file = PR_DESC_FILE,\n+        tcp = PR_DESC_SOCKET_TCP,\n+        udp = PR_DESC_SOCKET_UDP,\n+        layered = PR_DESC_LAYERED\n+    } RCIOType;\n+\n+    RCIO(RCIOType);\n+\n+    PRFileDesc *fd;  /* where the real code hides */\n+\n+private:\n+    /* no default construction and no copies allowed */\n+    RCIO();\n+    RCIO(const RCIO&);\n+\n+};  /* RCIO */\n+\n+#endif /* defined(_RCIO_H) */\n+\n+/* RCIO.h */\n+\n+\ndiff --git a/nspr/pr/src/cplus/rclock.cpp b/nspr/pr/src/cplus/rclock.cpp\nnew file mode 100644\nindex 0000000..8c106de\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rclock.cpp\n@@ -0,0 +1,42 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+/*\n+** C++ access to NSPR locks (PRLock)\n+*/\n+\n+#include \"rclock.h\"\n+#include <prlog.h>\n+\n+RCLock::RCLock()\n+{\n+    lock = PR_NewLock();  /* it might be NULL */\n+    PR_ASSERT(NULL != lock);\n+}  /* RCLock::RCLock */\n+\n+RCLock::~RCLock()\n+{\n+    if (NULL != lock) {\n+        PR_DestroyLock(lock);\n+    }\n+    lock = NULL;\n+}  /* RCLock::~RCLock */\n+\n+void RCLock::Acquire()\n+{\n+    PR_ASSERT(NULL != lock);\n+    PR_Lock(lock);\n+}  /* RCLock::Acquire */\n+\n+void RCLock::Release()\n+{\n+    PRStatus rv;\n+    PR_ASSERT(NULL != lock);\n+    rv = PR_Unlock(lock);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+}  /* RCLock::Release */\n+\n+/* RCLock.cpp */\n+\ndiff --git a/nspr/pr/src/cplus/rclock.h b/nspr/pr/src/cplus/rclock.h\nnew file mode 100644\nindex 0000000..c86c2f1\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rclock.h\n@@ -0,0 +1,74 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** C++ access to NSPR locks (PRLock)\n+*/\n+\n+#if defined(_RCLOCK_H)\n+#else\n+#define _RCLOCK_H\n+\n+#include \"rcbase.h\"\n+\n+#include <prlock.h>\n+\n+class PR_IMPLEMENT(RCLock): public RCBase\n+{\n+public:\n+    RCLock();\n+    virtual ~RCLock();\n+\n+    void Acquire();                 /* non-reentrant */\n+    void Release();                 /* should be by owning thread */\n+\n+    friend class RCCondition;\n+\n+private:\n+    RCLock(const RCLock&);          /* can't do that */\n+    void operator=(const RCLock&);  /* nor that */\n+\n+    PRLock *lock;\n+};  /* RCLock */\n+\n+/*\n+** Class: RCEnter\n+**\n+** In scope locks. You can only allocate them on the stack. The language\n+** will insure that they get released (by calling the destructor) when\n+** the thread leaves scope, even if via an exception.\n+*/\n+class PR_IMPLEMENT(RCEnter)\n+{\n+public:\n+    ~RCEnter();                     /* releases the lock */\n+    RCEnter(RCLock*);               /* acquires the lock */\n+\n+private:\n+    RCLock *lock;\n+\n+    RCEnter();\n+    RCEnter(const RCEnter&);\n+    void operator=(const RCEnter&);\n+\n+    void *operator new(PRSize) {\n+        return NULL;\n+    }\n+    void operator delete(void*) { }\n+};  /* RCEnter */\n+\n+\n+inline RCEnter::RCEnter(RCLock* ml) {\n+    lock = ml;\n+    lock->Acquire();\n+}\n+inline RCEnter::~RCEnter() {\n+    lock->Release();\n+    lock = NULL;\n+}\n+\n+#endif /* defined(_RCLOCK_H) */\n+\n+/* RCLock.h */\ndiff --git a/nspr/pr/src/cplus/rcmon.h b/nspr/pr/src/cplus/rcmon.h\nnew file mode 100644\nindex 0000000..5d084ef\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcmon.h\n@@ -0,0 +1,47 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** Class: RCMonitor (ref prmonitor.h)\n+**\n+** RCMonitor.h - C++ wrapper around NSPR's monitors\n+*/\n+#if defined(_RCMONITOR_H)\n+#else\n+#define _RCMONITOR_H\n+\n+#include \"rcbase.h\"\n+#include \"rcinrval.h\"\n+\n+struct PRMonitor;\n+\n+class PR_IMPLEMENT(RCMonitor): public RCBase\n+{\n+public:\n+    RCMonitor();                    /* timeout is infinity */\n+    virtual ~RCMonitor();\n+\n+    virtual void Enter();           /* reentrant entry */\n+    virtual void Exit();\n+\n+    virtual void Notify();          /* possibly enable one thread */\n+    virtual void NotifyAll();       /* enable all waiters */\n+\n+    virtual void Wait();            /* applies object's timeout */\n+\n+    virtual void SetTimeout(const RCInterval& timeout);\n+\n+private:\n+    PRMonitor *monitor;\n+    RCInterval timeout;\n+\n+public:\n+    RCInterval GetTimeout() const;  /* get the current value */\n+\n+};  /* RCMonitor */\n+\n+#endif /* defined(_RCMONITOR_H) */\n+\n+/* RCMonitor.h */\ndiff --git a/nspr/pr/src/cplus/rcnetdb.cpp b/nspr/pr/src/cplus/rcnetdb.cpp\nnew file mode 100644\nindex 0000000..19eb665\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcnetdb.cpp\n@@ -0,0 +1,233 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** Base class implementation for network access functions (ref: prnetdb.h)\n+*/\n+\n+#include \"rclock.h\"\n+#include \"rcnetdb.h\"\n+\n+#include <prmem.h>\n+#include <prlog.h>\n+#include <string.h>\n+\n+RCNetAddr::RCNetAddr(const RCNetAddr& his): RCBase()\n+{\n+    address = his.address;\n+}\n+\n+RCNetAddr::RCNetAddr(const RCNetAddr& his, PRUint16 port): RCBase()\n+{\n+    address = his.address;\n+    switch (address.raw.family)\n+    {\n+        case PR_AF_INET: address.inet.port = port; break;\n+        case PR_AF_INET6: address.ipv6.port = port; break;\n+        default: break;\n+    }\n+}  /* RCNetAddr::RCNetAddr */\n+\n+RCNetAddr::RCNetAddr(RCNetAddr::HostValue host, PRUint16 port): RCBase()\n+{\n+    PRNetAddrValue how;\n+    switch (host)\n+    {\n+        case RCNetAddr::any: how = PR_IpAddrAny; break;\n+        case RCNetAddr::loopback: how = PR_IpAddrLoopback; break;\n+        default: PR_NOT_REACHED(\"This can't happen -- and did!\");\n+    }\n+    (void)PR_InitializeNetAddr(how, port, &address);\n+}  /* RCNetAddr::RCNetAddr */\n+\n+RCNetAddr::~RCNetAddr() { }\n+\n+void RCNetAddr::operator=(const RCNetAddr& his) {\n+    address = his.address;\n+}\n+\n+PRStatus RCNetAddr::FromString(const char* string)\n+{\n+    return PR_StringToNetAddr(string, &address);\n+}\n+\n+void RCNetAddr::operator=(const PRNetAddr* addr) {\n+    address = *addr;\n+}\n+\n+PRBool RCNetAddr::operator==(const RCNetAddr& his) const\n+{\n+    PRBool rv = EqualHost(his);\n+    if (rv)\n+    {\n+        switch (address.raw.family)\n+        {\n+            case PR_AF_INET:\n+                rv = (address.inet.port == his.address.inet.port); break;\n+            case PR_AF_INET6:\n+                rv = (address.ipv6.port == his.address.ipv6.port); break;\n+            case PR_AF_LOCAL:\n+            default: break;\n+        }\n+    }\n+    return rv;\n+}  /* RCNetAddr::operator== */\n+\n+PRBool RCNetAddr::EqualHost(const RCNetAddr& his) const\n+{\n+    PRBool rv;\n+    switch (address.raw.family)\n+    {\n+        case PR_AF_INET:\n+            rv = (address.inet.ip == his.address.inet.ip); break;\n+        case PR_AF_INET6:\n+            rv = (0 == memcmp(\n+                      &address.ipv6.ip, &his.address.ipv6.ip,\n+                      sizeof(address.ipv6.ip)));\n+            break;\n+#if defined(XP_UNIX)\n+        case PR_AF_LOCAL:\n+            rv = (0 == strncmp(\n+                      address.local.path, his.address.local.path,\n+                      sizeof(address.local.path)));\n+            break;\n+#endif\n+        default: break;\n+    }\n+    return rv;\n+}  /* RCNetAddr::operator== */\n+\n+PRStatus RCNetAddr::ToString(char *string, PRSize size) const\n+{\n+    return PR_NetAddrToString(&address, string, size);\n+}\n+\n+/*\n+** RCHostLookup\n+*/\n+\n+RCHostLookup::~RCHostLookup()\n+{\n+    if (NULL != address) {\n+        delete [] address;\n+    }\n+}  /* RCHostLookup::~RCHostLookup */\n+\n+RCHostLookup::RCHostLookup(): RCBase()\n+{\n+    address = NULL;\n+    max_index = 0;\n+}  /* RCHostLookup::RCHostLookup */\n+\n+PRStatus RCHostLookup::ByName(const char* name)\n+{\n+    PRStatus rv;\n+    PRNetAddr addr;\n+    PRHostEnt hostentry;\n+    PRIntn index = 0, max;\n+    RCNetAddr* vector = NULL;\n+    RCNetAddr* old_vector = NULL;\n+    void* buffer = PR_Malloc(PR_NETDB_BUF_SIZE);\n+    if (NULL == buffer) {\n+        return PR_FAILURE;\n+    }\n+    rv = PR_GetHostByName(name, (char*)buffer, PR_NETDB_BUF_SIZE, &hostentry);\n+    if (PR_SUCCESS == rv)\n+    {\n+        for (max = 0, index = 0;; ++max)\n+        {\n+            index = PR_EnumerateHostEnt(index, &hostentry, 0, &addr);\n+            if (0 == index) {\n+                break;\n+            }\n+        }\n+        if (max > 0)\n+        {\n+            vector = new RCNetAddr[max];\n+            while (--max > 0)\n+            {\n+                index = PR_EnumerateHostEnt(index, &hostentry, 0, &addr);\n+                if (0 == index) {\n+                    break;\n+                }\n+                vector[index] = &addr;\n+            }\n+            {\n+                RCEnter entry(&ml);\n+                old_vector = address;\n+                address = vector;\n+                max_index = max;\n+            }\n+            if (NULL != old_vector) {\n+                delete [] old_vector;\n+            }\n+        }\n+    }\n+    if (NULL != buffer) {\n+        PR_DELETE(buffer);\n+    }\n+    return PR_SUCCESS;\n+}  /* RCHostLookup::ByName */\n+\n+PRStatus RCHostLookup::ByAddress(const RCNetAddr& host_addr)\n+{\n+    PRStatus rv;\n+    PRNetAddr addr;\n+    PRHostEnt hostentry;\n+    PRIntn index = 0, max;\n+    RCNetAddr* vector = NULL;\n+    RCNetAddr* old_vector = NULL;\n+    char *buffer = (char*)PR_Malloc(PR_NETDB_BUF_SIZE);\n+    if (NULL == buffer) {\n+        return PR_FAILURE;\n+    }\n+    rv = PR_GetHostByAddr(host_addr, buffer, PR_NETDB_BUF_SIZE, &hostentry);\n+    if (PR_SUCCESS == rv)\n+    {\n+        for (max = 0, index = 0;; ++max)\n+        {\n+            index = PR_EnumerateHostEnt(index, &hostentry, 0, &addr);\n+            if (0 == index) {\n+                break;\n+            }\n+        }\n+        if (max > 0)\n+        {\n+            vector = new RCNetAddr[max];\n+            while (--max > 0)\n+            {\n+                index = PR_EnumerateHostEnt(index, &hostentry, 0, &addr);\n+                if (0 == index) {\n+                    break;\n+                }\n+                vector[index] = &addr;\n+            }\n+            {\n+                RCEnter entry(&ml);\n+                old_vector = address;\n+                address = vector;\n+                max_index = max;\n+            }\n+            if (NULL != old_vector) {\n+                delete [] old_vector;\n+            }\n+        }\n+    }\n+    if (NULL != buffer) {\n+        PR_DELETE(buffer);\n+    }\n+    return PR_SUCCESS;\n+}  /* RCHostLookup::ByAddress */\n+\n+const RCNetAddr* RCHostLookup::operator[](PRUintn which)\n+{\n+    RCNetAddr* addr = NULL;\n+    if (which < max_index) {\n+        addr = &address[which];\n+    }\n+    return addr;\n+}  /* RCHostLookup::operator[] */\n+\n+/* RCNetdb.cpp */\ndiff --git a/nspr/pr/src/cplus/rcnetdb.h b/nspr/pr/src/cplus/rcnetdb.h\nnew file mode 100644\nindex 0000000..14e96ec\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcnetdb.h\n@@ -0,0 +1,99 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** Base class definitions for network access functions (ref: prnetdb.h)\n+*/\n+\n+#if defined(_RCNETDB_H)\n+#else\n+#define _RCNETDB_H\n+\n+#include \"rclock.h\"\n+#include \"rcbase.h\"\n+\n+#include <prnetdb.h>\n+\n+class PR_IMPLEMENT(RCNetAddr): public RCBase\n+{\n+public:\n+    typedef enum {\n+        any = PR_IpAddrAny,             /* assign logical INADDR_ANY */\n+        loopback = PR_IpAddrLoopback    /* assign logical INADDR_LOOPBACK */\n+    } HostValue;\n+\n+    RCNetAddr();                        /* default constructor is unit'd object */\n+    RCNetAddr(const RCNetAddr&);        /* copy constructor */\n+    RCNetAddr(HostValue, PRUint16 port);/* init'd w/ 'special' assignments */\n+    RCNetAddr(const RCNetAddr&, PRUint16 port);\n+    /* copy w/ port reassigment */\n+\n+    virtual ~RCNetAddr();\n+\n+    void operator=(const RCNetAddr&);\n+\n+    virtual PRBool operator==(const RCNetAddr&) const;\n+    /* compare of all relavent fields */\n+    virtual PRBool EqualHost(const RCNetAddr&) const;\n+    /* compare of just host field */\n+\n+\n+public:\n+\n+    void operator=(const PRNetAddr*);   /* construction from more primitive data */\n+    operator const PRNetAddr*() const;  /* extraction of underlying representation */\n+    virtual PRStatus FromString(const char* string);\n+    /* initialization from an ASCII string */\n+    virtual PRStatus ToString(char *string, PRSize size) const;\n+    /* convert internal fromat to a string */\n+\n+private:\n+\n+    PRNetAddr address;\n+\n+};  /* RCNetAddr */\n+\n+/*\n+** Class: RCHostLookup\n+**\n+** Abstractions to look up host names and addresses.\n+**\n+** This is a stateful class. One looks up the host by name or by\n+** address, then enumerates over a possibly empty array of network\n+** addresses. The storage for the addresses is owned by the class.\n+*/\n+\n+class RCHostLookup: public RCBase\n+{\n+public:\n+    virtual ~RCHostLookup();\n+\n+    RCHostLookup();\n+\n+    virtual PRStatus ByName(const char* name);\n+    virtual PRStatus ByAddress(const RCNetAddr&);\n+\n+    virtual const RCNetAddr* operator[](PRUintn);\n+\n+private:\n+    RCLock ml;\n+    PRIntn max_index;\n+    RCNetAddr* address;\n+\n+    RCHostLookup(const RCHostLookup&);\n+    RCHostLookup& operator=(const RCHostLookup&);\n+};\n+\n+inline RCNetAddr::RCNetAddr(): RCBase() { }\n+inline RCNetAddr::operator const PRNetAddr*() const {\n+    return &address;\n+}\n+\n+\n+#endif /* defined(_RCNETDB_H) */\n+\n+/* RCNetdb.h */\n+\n+\ndiff --git a/nspr/pr/src/cplus/rcnetio.cpp b/nspr/pr/src/cplus/rcnetio.cpp\nnew file mode 100644\nindex 0000000..e351345\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcnetio.cpp\n@@ -0,0 +1,225 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** Subclass implementation for streamed network I/O (ref: prio.h)\n+*/\n+\n+#include \"rcnetio.h\"\n+\n+#include <private/pprio.h>\n+\n+RCNetStreamIO::~RCNetStreamIO()\n+{\n+    PRStatus rv = (fd->methods->close)(fd);\n+    fd = NULL;\n+}\n+\n+RCNetStreamIO::RCNetStreamIO(): RCIO(RCIO::tcp)\n+{\n+    fd = PR_NewTCPSocket();\n+}\n+\n+RCNetStreamIO::RCNetStreamIO(PRIntn protocol): RCIO(RCIO::tcp)\n+{\n+    fd = PR_Socket(PR_AF_INET, PR_SOCK_STREAM, protocol);\n+}\n+\n+RCIO* RCNetStreamIO::Accept(RCNetAddr* addr, const RCInterval& timeout)\n+{\n+    PRNetAddr peer;\n+    RCNetStreamIO* rcio = NULL;\n+    PRFileDesc* newfd = fd->methods->accept(fd, &peer, timeout);\n+    if (NULL != newfd)\n+    {\n+        rcio = new RCNetStreamIO();\n+        if (NULL != rcio)\n+        {\n+            *addr = &peer;\n+            rcio->fd = newfd;\n+        }\n+        else {\n+            (void)(newfd->methods->close)(newfd);\n+        }\n+    }\n+    return rcio;\n+}  /* RCNetStreamIO::Accept */\n+\n+PRInt32 RCNetStreamIO::AcceptRead(\n+    RCIO **nd, RCNetAddr **raddr, void *buf,\n+    PRSize amount, const RCInterval& timeout)\n+{\n+    PRNetAddr *from;\n+    PRFileDesc *accepted;\n+    PRInt32 rv = (fd->methods->acceptread)(\n+                     fd, &accepted, &from, buf, amount, timeout);\n+    if (rv >= 0)\n+    {\n+        RCNetStreamIO *ns = new RCNetStreamIO();\n+        if (NULL != *nd) {\n+            ns->fd = accepted;\n+        }\n+        else {\n+            PR_Close(accepted);\n+            rv = -1;\n+        }\n+        *nd = ns;\n+    }\n+    return rv;\n+}  /* RCNetStreamIO::AcceptRead */\n+\n+PRInt64 RCNetStreamIO::Available()\n+{\n+    return (fd->methods->available64)(fd);\n+}\n+\n+PRStatus RCNetStreamIO::Bind(const RCNetAddr& addr)\n+{\n+    return (fd->methods->bind)(fd, addr);\n+}\n+\n+PRStatus RCNetStreamIO::Connect(const RCNetAddr& addr, const RCInterval& timeout)\n+{\n+    return (fd->methods->connect)(fd, addr, timeout);\n+}\n+\n+PRStatus RCNetStreamIO::GetLocalName(RCNetAddr *addr) const\n+{\n+    PRNetAddr local;\n+    PRStatus rv = (fd->methods->getsockname)(fd, &local);\n+    if (PR_SUCCESS == rv) {\n+        *addr = &local;\n+    }\n+    return rv;\n+}  /* RCNetStreamIO::GetLocalName */\n+\n+PRStatus RCNetStreamIO::GetPeerName(RCNetAddr *addr) const\n+{\n+    PRNetAddr peer;\n+    PRStatus rv = (fd->methods->getpeername)(fd, &peer);\n+    if (PR_SUCCESS == rv) {\n+        *addr = &peer;\n+    }\n+    return rv;\n+}  /* RCNetStreamIO::GetPeerName */\n+\n+PRStatus RCNetStreamIO::GetSocketOption(PRSocketOptionData *data) const\n+{\n+    return (fd->methods->getsocketoption)(fd, data);\n+}\n+\n+PRStatus RCNetStreamIO::Listen(PRIntn backlog)\n+{\n+    return (fd->methods->listen)(fd, backlog);\n+}\n+\n+PRInt16 RCNetStreamIO::Poll(PRInt16 in_flags, PRInt16 *out_flags)\n+{\n+    return (fd->methods->poll)(fd, in_flags, out_flags);\n+}\n+\n+PRInt32 RCNetStreamIO::Read(void *buf, PRSize amount)\n+{\n+    return (fd->methods->read)(fd, buf, amount);\n+}\n+\n+PRInt32 RCNetStreamIO::Recv(\n+    void *buf, PRSize amount, PRIntn flags, const RCInterval& timeout)\n+{\n+    return (fd->methods->recv)(fd, buf, amount, flags, timeout);\n+}\n+\n+PRInt32 RCNetStreamIO::Recvfrom(\n+    void *buf, PRSize amount, PRIntn flags,\n+    RCNetAddr* addr, const RCInterval& timeout)\n+{\n+    PRNetAddr peer;\n+    PRInt32 rv = (fd->methods->recvfrom)(\n+                     fd, buf, amount, flags, &peer, timeout);\n+    if (-1 != rv) {\n+        *addr = &peer;\n+    }\n+    return rv;\n+}  /* RCNetStreamIO::Recvfrom */\n+\n+PRInt32 RCNetStreamIO::Send(\n+    const void *buf, PRSize amount, PRIntn flags, const RCInterval& timeout)\n+{\n+    return (fd->methods->send)(fd, buf, amount, flags, timeout);\n+}\n+\n+PRInt32 RCNetStreamIO::Sendto(\n+    const void *buf, PRSize amount, PRIntn flags,\n+    const RCNetAddr& addr, const RCInterval& timeout)\n+{\n+    return (fd->methods->sendto)(fd, buf, amount, flags, addr, timeout);\n+}\n+\n+PRStatus RCNetStreamIO::SetSocketOption(const PRSocketOptionData *data)\n+{\n+    return (fd->methods->setsocketoption)(fd, data);\n+}\n+\n+PRStatus RCNetStreamIO::Shutdown(RCIO::ShutdownHow how)\n+{\n+    return (fd->methods->shutdown)(fd, (PRIntn)how);\n+}\n+\n+PRInt32 RCNetStreamIO::TransmitFile(\n+    RCIO *source, const void *headers, PRSize hlen,\n+    RCIO::FileDisposition flags, const RCInterval& timeout)\n+{\n+    RCNetStreamIO *src = (RCNetStreamIO*)source;\n+    return (fd->methods->transmitfile)(\n+               fd, src->fd, headers, hlen, (PRTransmitFileFlags)flags, timeout);\n+}\n+\n+PRInt32 RCNetStreamIO::Write(const void *buf, PRSize amount)\n+{\n+    return (fd->methods->write)(fd, buf, amount);\n+}\n+\n+PRInt32 RCNetStreamIO::Writev(\n+    const PRIOVec *iov, PRSize size, const RCInterval& timeout)\n+{\n+    return (fd->methods->writev)(fd, iov, size, timeout);\n+}\n+\n+/*\n+** Invalid functions\n+*/\n+\n+PRStatus RCNetStreamIO::Close()\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return PR_FAILURE;\n+}\n+\n+PRStatus RCNetStreamIO::FileInfo(RCFileInfo*) const\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return PR_FAILURE;\n+}\n+\n+PRStatus RCNetStreamIO::Fsync()\n+{\n+    return (fd->methods->fsync)(fd);\n+}\n+\n+PRStatus RCNetStreamIO::Open(const char*, PRIntn, PRIntn)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return PR_FAILURE;\n+}\n+\n+PRInt64 RCNetStreamIO::Seek(PRInt64, RCIO::Whence)\n+{\n+    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+    return PR_FAILURE;\n+}\n+\n+/* RCNetStreamIO.cpp */\n+\n+\ndiff --git a/nspr/pr/src/cplus/rcnetio.h b/nspr/pr/src/cplus/rcnetio.h\nnew file mode 100644\nindex 0000000..7f6b669\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcnetio.h\n@@ -0,0 +1,94 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** Subclass definitions for network I/O (ref: prio.h)\n+*/\n+\n+#if defined(_RCNETIO_H)\n+#else\n+#define _RCNETIO_H\n+\n+#include \"rcbase.h\"\n+#include \"rcinrval.h\"\n+#include \"rcio.h\"\n+#include \"rcnetdb.h\"\n+\n+#include \"prio.h\"\n+\n+class RCFileInfo;\n+\n+/*\n+** Class: RCNetStreamIO (ref prio.h)\n+**\n+** Streamed (reliable) network I/O (e.g., TCP).\n+** This class hides (makes private) the functions that are not applicable\n+** to network I/O (i.e., those for file I/O).\n+*/\n+\n+class PR_IMPLEMENT(RCNetStreamIO): public RCIO\n+{\n+\n+public:\n+    RCNetStreamIO();\n+    virtual ~RCNetStreamIO();\n+\n+    virtual RCIO*       Accept(RCNetAddr* addr, const RCInterval& timeout);\n+    virtual PRInt32     AcceptRead(\n+        RCIO **nd, RCNetAddr **raddr, void *buf,\n+        PRSize amount, const RCInterval& timeout);\n+    virtual PRInt64     Available();\n+    virtual PRStatus    Bind(const RCNetAddr& addr);\n+    virtual PRStatus    Connect(\n+        const RCNetAddr& addr, const RCInterval& timeout);\n+    virtual PRStatus    GetLocalName(RCNetAddr *addr) const;\n+    virtual PRStatus    GetPeerName(RCNetAddr *addr) const;\n+    virtual PRStatus    GetSocketOption(PRSocketOptionData *data) const;\n+    virtual PRStatus    Listen(PRIntn backlog);\n+    virtual PRInt16     Poll(PRInt16 in_flags, PRInt16 *out_flags);\n+    virtual PRInt32     Read(void *buf, PRSize amount);\n+    virtual PRInt32     Recv(\n+        void *buf, PRSize amount, PRIntn flags,\n+        const RCInterval& timeout);\n+    virtual PRInt32     Recvfrom(\n+        void *buf, PRSize amount, PRIntn flags,\n+        RCNetAddr* addr, const RCInterval& timeout);\n+    virtual PRInt32     Send(\n+        const void *buf, PRSize amount, PRIntn flags,\n+        const RCInterval& timeout);\n+    virtual PRInt32     Sendto(\n+        const void *buf, PRSize amount, PRIntn flags,\n+        const RCNetAddr& addr,\n+        const RCInterval& timeout);\n+    virtual PRStatus    SetSocketOption(const PRSocketOptionData *data);\n+    virtual PRStatus    Shutdown(ShutdownHow how);\n+    virtual PRInt32     TransmitFile(\n+        RCIO *source, const void *headers,\n+        PRSize hlen, RCIO::FileDisposition flags,\n+        const RCInterval& timeout);\n+    virtual PRInt32     Write(const void *buf, PRSize amount);\n+    virtual PRInt32     Writev(\n+        const PRIOVec *iov, PRSize size,\n+        const RCInterval& timeout);\n+\n+private:\n+    /* functions unavailable to this clients of this class */\n+    RCNetStreamIO(const RCNetStreamIO&);\n+\n+    PRStatus    Close();\n+    PRStatus    Open(const char *name, PRIntn flags, PRIntn mode);\n+    PRStatus    FileInfo(RCFileInfo *info) const;\n+    PRStatus    Fsync();\n+    PRInt64     Seek(PRInt64 offset, RCIO::Whence how);\n+\n+public:\n+    RCNetStreamIO(PRIntn protocol);\n+};  /* RCNetIO */\n+\n+#endif /* defined(_RCNETIO_H) */\n+\n+/* RCNetStreamIO.h */\n+\n+\ndiff --git a/nspr/pr/src/cplus/rcthread.cpp b/nspr/pr/src/cplus/rcthread.cpp\nnew file mode 100644\nindex 0000000..471e580\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcthread.cpp\n@@ -0,0 +1,221 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/* RCThread.cpp - C++ wrapper on NSPR */\n+\n+#include \"rcthread.h\"\n+#include \"rcinrval.h\"\n+\n+#include <prmem.h>\n+#include <prlog.h>\n+#include <stdio.h>\n+#include <prinit.h>\n+\n+static RCPrimordialThread *primordial = NULL;\n+\n+void nas_Root(void *arg)\n+{\n+    RCThread *him = (RCThread*)arg;\n+    while (RCThread::ex_unstarted == him->execution) {\n+        (void)PR_Sleep(PR_INTERVAL_NO_TIMEOUT);    /* wait for Start() */\n+    }\n+    him->RootFunction();  /* he gets a self reference */\n+    if (PR_UNJOINABLE_THREAD == PR_GetThreadState(him->identity)) {\n+        delete him;\n+    }\n+}  /* nas_Root */\n+\n+RCThread::~RCThread() { }\n+\n+RCThread::RCThread(): RCBase() { }\n+\n+RCThread::RCThread(const RCThread&): RCBase()\n+{\n+    PR_NOT_REACHED(\"Cannot call thread copy constructor\");\n+}  /* RCThread::RCThread */\n+\n+RCThread::RCThread(\n+    RCThread::Scope scope, RCThread::State join, PRUint32 stackSize):\n+    RCBase()\n+{\n+    execution = ex_unstarted;\n+    identity = PR_CreateThread(\n+                   PR_USER_THREAD, nas_Root, this,\n+                   PR_GetThreadPriority(PR_GetCurrentThread()),\n+                   (PRThreadScope)scope, (PRThreadState)join, stackSize);\n+}  /* RCThread::RCThread */\n+\n+void RCThread::operator=(const RCThread&)\n+{\n+    PR_NOT_REACHED(\"Cannot call thread assignment operator\");\n+}  /* RCThread::operator= */\n+\n+\n+PRStatus RCThread::Start()\n+{\n+    PRStatus rv;\n+    /* This is an unsafe check, but not too critical */\n+    if (RCThread::ex_unstarted == execution)\n+    {\n+        execution = RCThread::ex_started;\n+        rv = PR_Interrupt(identity);\n+        PR_ASSERT(PR_SUCCESS == rv);\n+    }\n+    else\n+    {\n+        rv = PR_FAILURE;\n+        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    }\n+    return rv;\n+}  /* RCThread::Start */\n+\n+PRStatus RCThread::Join()\n+{\n+    PRStatus rv;\n+    if (RCThread::ex_unstarted == execution)\n+    {\n+        rv = PR_FAILURE;\n+        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    }\n+    else {\n+        rv = PR_JoinThread(identity);\n+    }\n+    if (PR_SUCCESS == rv) {\n+        delete this;\n+    }\n+    return rv;\n+}  /* RCThread::Join */\n+\n+PRStatus RCThread::Interrupt()\n+{\n+    PRStatus rv;\n+    if (RCThread::ex_unstarted == execution)\n+    {\n+        rv = PR_FAILURE;\n+        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    }\n+    else {\n+        rv = PR_Interrupt(identity);\n+    }\n+    return rv;\n+}  /* RCThread::Interrupt */\n+\n+void RCThread::ClearInterrupt() {\n+    PR_ClearInterrupt();\n+}\n+\n+void RCThread::SetPriority(RCThread::Priority new_priority)\n+{\n+    PR_SetThreadPriority(identity, (PRThreadPriority)new_priority);\n+}\n+\n+PRThread *RCThread::Self()\n+{\n+    return PR_GetCurrentThread();\n+}\n+\n+RCThread::Scope RCThread::GetScope() const\n+{\n+    return (RCThread::Scope)PR_GetThreadScope(identity);\n+}\n+\n+RCThread::State RCThread::GetState() const\n+{\n+    return (RCThread::State)PR_GetThreadState(identity);\n+}\n+\n+RCThread::Priority RCThread::GetPriority() const\n+{\n+    return (RCThread::Priority)PR_GetThreadPriority(identity);\n+}\n+\n+static void _rc_PDDestructor(RCThreadPrivateData* privateData)\n+{\n+    PR_ASSERT(NULL != privateData);\n+    privateData->Release();\n+}\n+\n+static PRThreadPrivateDTOR _tpd_dtor = (PRThreadPrivateDTOR)_rc_PDDestructor;\n+\n+PRStatus RCThread::NewPrivateIndex(PRUintn* index)\n+{\n+    return PR_NewThreadPrivateIndex(index, _tpd_dtor);\n+}\n+\n+PRStatus RCThread::SetPrivateData(PRUintn index)\n+{\n+    return PR_SetThreadPrivate(index, NULL);\n+}\n+\n+PRStatus RCThread::SetPrivateData(PRUintn index, RCThreadPrivateData* data)\n+{\n+    return PR_SetThreadPrivate(index, data);\n+}\n+\n+RCThreadPrivateData* RCThread::GetPrivateData(PRUintn index)\n+{\n+    return (RCThreadPrivateData*)PR_GetThreadPrivate(index);\n+}\n+\n+PRStatus RCThread::Sleep(const RCInterval& ticks)\n+{\n+    PRIntervalTime tmo = ticks;\n+    return PR_Sleep(tmo);\n+}\n+\n+RCPrimordialThread *RCThread::WrapPrimordialThread()\n+{\n+    /*\n+    ** This needs to take more care in insuring that the thread\n+    ** being wrapped is really the primordial thread. This code\n+    ** is assuming that the caller is the primordial thread, and\n+    ** there's nothing to insure that.\n+    */\n+    if (NULL == primordial)\n+    {\n+        /* it doesn't have to be perfect */\n+        RCPrimordialThread *me = new RCPrimordialThread();\n+        PR_ASSERT(NULL != me);\n+        if (NULL == primordial)\n+        {\n+            primordial = me;\n+            me->execution = RCThread::ex_started;\n+            me->identity = PR_GetCurrentThread();\n+        }\n+        else {\n+            delete me;    /* somebody beat us to it */\n+        }\n+    }\n+    return primordial;\n+}  /* RCThread::WrapPrimordialThread */\n+\n+RCPrimordialThread::RCPrimordialThread(): RCThread() { }\n+\n+RCPrimordialThread::~RCPrimordialThread() { }\n+\n+void RCPrimordialThread::RootFunction()\n+{\n+    PR_NOT_REACHED(\"Primordial thread calling root function\");\n+}  /* RCPrimordialThread::RootFunction */\n+\n+PRStatus RCPrimordialThread::Cleanup() {\n+    return PR_Cleanup();\n+}\n+\n+PRStatus RCPrimordialThread::SetVirtualProcessors(PRIntn count)\n+{\n+    PR_SetConcurrency(count);\n+    return PR_SUCCESS;\n+}  /* SetVirutalProcessors */\n+\n+RCThreadPrivateData::RCThreadPrivateData() { }\n+\n+RCThreadPrivateData::RCThreadPrivateData(\n+    const RCThreadPrivateData& him) { }\n+\n+RCThreadPrivateData::~RCThreadPrivateData() { }\n+\n+/* RCThread.c */\n+\ndiff --git a/nspr/pr/src/cplus/rcthread.h b/nspr/pr/src/cplus/rcthread.h\nnew file mode 100644\nindex 0000000..b7716d4\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rcthread.h\n@@ -0,0 +1,195 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/* RCThread.h */\n+\n+#if defined(_RCTHREAD_H)\n+#else\n+#define _RCTHREAD_H\n+\n+#include \"rcbase.h\"\n+\n+#include <prthread.h>\n+\n+class RCInterval;\n+\n+class PR_IMPLEMENT(RCThreadPrivateData)\n+{\n+public:\n+    RCThreadPrivateData();\n+    RCThreadPrivateData(const RCThreadPrivateData&);\n+\n+    virtual ~RCThreadPrivateData();\n+\n+    virtual void Release() = 0;\n+\n+};  /* RCThreadPrivateData */\n+\n+class PR_IMPLEMENT(RCThread): public RCBase\n+{\n+public:\n+\n+    typedef enum\n+    {\n+        local = PR_LOCAL_THREAD, global = PR_GLOBAL_THREAD\n+    } Scope;\n+\n+    typedef enum\n+    {\n+        joinable = PR_JOINABLE_THREAD, unjoinable = PR_UNJOINABLE_THREAD\n+    } State;\n+\n+    typedef enum\n+    {\n+        first = PR_PRIORITY_FIRST,\n+        low = PR_PRIORITY_LOW,\n+        normal = PR_PRIORITY_NORMAL,\n+        high = PR_PRIORITY_HIGH,\n+        urgent = PR_PRIORITY_URGENT,\n+        last = PR_PRIORITY_LAST\n+    } Priority;\n+\n+    /*\n+     * Create a new thread, providing scope and joinability state.\n+     */\n+    RCThread(Scope scope, State state, PRUint32 stackSize=0);\n+\n+    /*\n+     * New threads are created in a suspended state. It must be 'started\"\n+     * before it begins execution in the class' defined 'RootFunction()'.\n+     */\n+    virtual PRStatus Start();\n+\n+    /*\n+     * If a thread is created joinable, then the thread's object exists\n+     * until join is called. The thread that calls join will block until\n+     * the target thread returns from it's root function.\n+     */\n+    virtual PRStatus Join();\n+\n+    /*\n+     * The priority of a newly created thread is the same as the creator.\n+     * The priority may be changed either by the new thread itself, by\n+     * the creator or any other arbitrary thread.\n+     */\n+    virtual void SetPriority(Priority newPriority);\n+\n+\n+    /*\n+     * Interrupt another thread, causing it to stop what it\n+     * is doing and return with a well known error code.\n+     */\n+    virtual PRStatus Interrupt();\n+\n+    /*\n+     * And in case a thread was interrupted and didn't get a chance\n+     * to have the notification delivered, a way to cancel the pending\n+     * status.\n+     */\n+    static void ClearInterrupt();\n+\n+    /*\n+     * Methods to discover the attributes of an existing thread.\n+     */\n+    static PRThread *Self();\n+    Scope GetScope() const;\n+    State GetState() const;\n+    Priority GetPriority() const;\n+\n+    /*\n+     * Thread private data\n+     */\n+    static PRStatus NewPrivateIndex(PRUintn* index);\n+\n+    /*\n+     * Getting it - if you want to modify, make a copy\n+     */\n+    static RCThreadPrivateData* GetPrivateData(PRUintn index);\n+\n+    /*\n+     * Setting it to <empty> - deletes existing data\n+     */\n+    static PRStatus SetPrivateData(PRUintn index);\n+\n+    /*\n+     * Setting it - runtime will make a copy, freeing old iff necessary\n+     */\n+    static PRStatus SetPrivateData(PRUintn index, RCThreadPrivateData* data);\n+\n+    /*\n+     * Scheduling control\n+     */\n+    static PRStatus Sleep(const RCInterval& ticks);\n+\n+    friend void nas_Root(void*);\n+    friend class RCPrimordialThread;\n+protected:\n+\n+    /*\n+     * The instantiator of a class must not call the destructor. The base\n+     * implementation of Join will, and if the thread is created unjoinable,\n+     * then the code that called the RootFunction will call the desctructor.\n+     */\n+    virtual ~RCThread();\n+\n+private:\n+\n+    /*\n+     * This is where a newly created thread begins execution. Returning\n+     * from this function is equivalent to terminating the thread.\n+     */\n+    virtual void RootFunction() = 0;\n+\n+    PRThread *identity;\n+\n+    /* Threads are unstarted until started - pretty startling */\n+    enum {ex_unstarted, ex_started} execution;\n+\n+    /* There is no public default constructor or copy constructor */\n+    RCThread();\n+    RCThread(const RCThread&);\n+\n+    /* And there is no assignment operator */\n+    void operator=(const RCThread&);\n+\n+public:\n+    static RCPrimordialThread *WrapPrimordialThread();\n+\n+};\n+\n+/*\n+** class RCPrimordialThread\n+*/\n+class PR_IMPLEMENT(RCPrimordialThread): public RCThread\n+{\n+public:\n+    /*\n+    ** The primordial thread can (optionally) wait for all created\n+    ** threads to terminate before allowing the process to exit.\n+    ** Not calling Cleanup() before returning from main() will cause\n+    ** the immediate termination of the entire process, including\n+    ** any running threads.\n+    */\n+    static PRStatus Cleanup();\n+\n+    /*\n+    ** Only the primordial thread is allowed to adjust the number of\n+    ** virtual processors of the runtime. It's a lame security thing.\n+    */\n+    static PRStatus SetVirtualProcessors(PRIntn count=10);\n+\n+    friend class RCThread;\n+private:\n+    /*\n+    ** None other than the runtime can create of destruct\n+    ** a primordial thread. It is fabricated by the runtime\n+    ** to wrap the thread that initiated the application.\n+    */\n+    RCPrimordialThread();\n+    ~RCPrimordialThread();\n+    void RootFunction();\n+};  /* RCPrimordialThread */\n+\n+#endif /* defined(_RCTHREAD_H) */\ndiff --git a/nspr/pr/src/cplus/rctime.cpp b/nspr/pr/src/cplus/rctime.cpp\nnew file mode 100644\nindex 0000000..2c9823e\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rctime.cpp\n@@ -0,0 +1,56 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** Class implementation for calendar time routines (ref: prtime.h)\n+*/\n+\n+#include \"rctime.h\"\n+\n+RCTime::~RCTime() { }\n+\n+RCTime::RCTime(PRTime time): RCBase() {\n+    gmt = time;\n+}\n+RCTime::RCTime(const RCTime& his): RCBase() {\n+    gmt = his.gmt;\n+}\n+RCTime::RCTime(RCTime::Current): RCBase() {\n+    gmt = PR_Now();\n+}\n+RCTime::RCTime(const PRExplodedTime& time): RCBase()\n+{\n+    gmt = PR_ImplodeTime(&time);\n+}\n+\n+void RCTime::operator=(const PRExplodedTime& time)\n+{\n+    gmt = PR_ImplodeTime(&time);\n+}\n+\n+RCTime RCTime::operator+(const RCTime& his)\n+{\n+    RCTime sum(gmt + his.gmt);\n+    return sum;\n+}\n+\n+RCTime RCTime::operator-(const RCTime& his)\n+{\n+    RCTime difference(gmt - his.gmt);\n+    return difference;\n+}\n+\n+RCTime RCTime::operator/(PRUint64 his)\n+{\n+    RCTime quotient(gmt / gmt);\n+    return quotient;\n+}\n+\n+RCTime RCTime::operator*(PRUint64 his)\n+{\n+    RCTime product(gmt * his);\n+    return product;\n+}\n+\ndiff --git a/nspr/pr/src/cplus/rctime.h b/nspr/pr/src/cplus/rctime.h\nnew file mode 100644\nindex 0000000..3752a3d\n--- /dev/null\n+++ b/nspr/pr/src/cplus/rctime.h\n@@ -0,0 +1,136 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** Class definitions for calendar time routines (ref: prtime.h)\n+*/\n+\n+#if defined(_RCTIME_H)\n+#else\n+#define _RCTIME_H\n+\n+#include \"rcbase.h\"\n+\n+#include <prtime.h>\n+\n+/*\n+** Class: RCTime (ref: prtime.h)\n+**\n+** RCTimes are objects that are intended to be used to represent calendar\n+** times. They maintain units internally as microseconds since the defined\n+** epoch (midnight, January 1, 1970, GMT). Conversions to and from external\n+** formats (PRExplodedTime) are available.\n+**\n+** In general, NCTimes possess normal algebretic capabilities.\n+*/\n+\n+class PR_IMPLEMENT(RCTime): public RCBase\n+{\n+public:\n+    typedef enum {now} Current;\n+\n+    RCTime();                       /* leaves the object unitialized */\n+    RCTime(Current);                /* initializes to current system time */\n+    RCTime(const RCTime&);          /* copy constructor */\n+    RCTime(const PRExplodedTime&);  /* construction from exploded representation */\n+\n+    virtual ~RCTime();\n+\n+    /* assignment operators */\n+    void operator=(const RCTime&);\n+    void operator=(const PRExplodedTime&);\n+\n+    /* comparitive operators */\n+    PRBool operator<(const RCTime&);\n+    PRBool operator>(const RCTime&);\n+    PRBool operator<=(const RCTime&);\n+    PRBool operator>=(const RCTime&);\n+    PRBool operator==(const RCTime&);\n+\n+    /* associative operators */\n+    RCTime operator+(const RCTime&);\n+    RCTime operator-(const RCTime&);\n+    RCTime& operator+=(const RCTime&);\n+    RCTime& operator-=(const RCTime&);\n+\n+    /* multiply and divide operators */\n+    RCTime operator/(PRUint64);\n+    RCTime operator*(PRUint64);\n+    RCTime& operator/=(PRUint64);\n+    RCTime& operator*=(PRUint64);\n+\n+    void Now();                     /* assign current time to object */\n+\n+private:\n+    PRTime gmt;\n+\n+public:\n+\n+    RCTime(PRTime);                 /* construct from raw PRTime */\n+    void operator=(PRTime);         /* assign from raw PRTime */\n+    operator PRTime() const;        /* extract internal representation */\n+};  /* RCTime */\n+\n+inline RCTime::RCTime(): RCBase() { }\n+\n+inline void RCTime::Now() {\n+    gmt = PR_Now();\n+}\n+inline RCTime::operator PRTime() const {\n+    return gmt;\n+}\n+\n+inline void RCTime::operator=(PRTime his) {\n+    gmt = his;\n+}\n+inline void RCTime::operator=(const RCTime& his) {\n+    gmt = his.gmt;\n+}\n+\n+inline PRBool RCTime::operator<(const RCTime& his)\n+{\n+    return (gmt < his.gmt) ? PR_TRUE : PR_FALSE;\n+}\n+inline PRBool RCTime::operator>(const RCTime& his)\n+{\n+    return (gmt > his.gmt) ? PR_TRUE : PR_FALSE;\n+}\n+inline PRBool RCTime::operator<=(const RCTime& his)\n+{\n+    return (gmt <= his.gmt) ? PR_TRUE : PR_FALSE;\n+}\n+inline PRBool RCTime::operator>=(const RCTime& his)\n+{\n+    return (gmt >= his.gmt) ? PR_TRUE : PR_FALSE;\n+}\n+inline PRBool RCTime::operator==(const RCTime& his)\n+{\n+    return (gmt == his.gmt) ? PR_TRUE : PR_FALSE;\n+}\n+\n+inline RCTime& RCTime::operator+=(const RCTime& his)\n+{\n+    gmt += his.gmt;\n+    return *this;\n+}\n+inline RCTime& RCTime::operator-=(const RCTime& his)\n+{\n+    gmt -= his.gmt;\n+    return *this;\n+}\n+inline RCTime& RCTime::operator/=(PRUint64 his)\n+{\n+    gmt /= his;\n+    return *this;\n+}\n+inline RCTime& RCTime::operator*=(PRUint64 his)\n+{\n+    gmt *= his;\n+    return *this;\n+}\n+\n+#endif /* defined(_RCTIME_H) */\n+\n+/* RCTime.h */\ndiff --git a/nspr/pr/src/cplus/tests/.cvsignore b/nspr/pr/src/cplus/tests/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/src/cplus/tests/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/src/cplus/tests/Makefile.in b/nspr/pr/src/cplus/tests/Makefile.in\nnew file mode 100644\nindex 0000000..fd99c16\n--- /dev/null\n+++ b/nspr/pr/src/cplus/tests/Makefile.in\n@@ -0,0 +1,162 @@\n+# \n+# This Source Code Form is subject to the terms of the Mozilla Public\n+# License, v. 2.0. If a copy of the MPL was not distributed with this\n+# file, You can obtain one at http://mozilla.org/MPL/2.0/.\n+\n+\n+#! gmake\n+\n+MOD_DEPTH\t= ../../../..\n+topsrcdir\t= @top_srcdir@\n+srcdir\t\t= @srcdir@\n+VPATH\t\t= @srcdir@\n+\n+include $(MOD_DEPTH)/config/autoconf.mk\n+\n+include $(topsrcdir)/config/config.mk\n+\n+CXXSRCS =           \\\n+\tranfile.cpp     \\\n+\tthread.cpp      \\\n+\tinterval.cpp    \\\n+\ttime.cpp        \\\n+\tfileio.cpp      \\\n+\tswitch.cpp      \\\n+\ttpd.cpp         \\\n+\t$(NULL)\n+\n+OBJS = $(addprefix $(OBJDIR)/,$(CXXSRCS:.cpp=.$(OBJ_SUFFIX)))\n+\n+ifeq (,$(filter-out WINNT,$(OS_ARCH)))\n+PROG_SUFFIX = .exe\n+else\n+PROG_SUFFIX =\n+endif\n+\n+PROGS = $(addprefix $(OBJDIR)/, $(CXXSRCS:.cpp=$(PROG_SUFFIX)))\n+\n+TARGETS = $(PROGS) $(OBJS)\n+\n+INCLUDES = -I.. -I$(dist_includedir)\n+\n+# Setting the variables LDOPTS and LIBPR.  We first initialize\n+# them to the default values, then adjust them for some platforms.\n+LDOPTS = -L$(dist_libdir)\n+LIBPR = -lnspr$(MOD_MAJOR_VERSION)\n+LIBPL = -lplc$(MOD_MAJOR_VERSION)\n+\n+# Solaris\n+ifeq ($(OS_ARCH), SunOS)\n+    ifdef NS_USE_GCC\n+        LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(dist_libdir)\n+    else\n+        LDOPTS += -R $(PWD)/$(dist_libdir)\n+    endif\n+\n+# SunOS 5.5 needs to link with -lpthread, even though we already\n+# linked with this system library when we built libnspr.so.\n+    ifeq ($(OS_RELEASE), 5.5)\n+        ifdef USE_PTHREADS\n+            EXTRA_LIBS = -lpthread\n+        endif\n+    endif\n+endif # SunOS\n+\n+ifeq ($(OS_ARCH), WINNT)\n+  LDOPTS = -NOLOGO -DEBUG -INCREMENTAL:NO\n+  LIBPR = $(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)\n+  LIBPL = $(dist_libdir)/libplc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)\n+endif\n+\n+ifneq ($(OS_ARCH), WINNT)\n+PWD = $(shell pwd)\n+endif\n+\n+ifeq ($(OS_ARCH), HP-UX)\n+    LDOPTS += -Wl,+s,+b,$(PWD)/$(dist_libdir)\n+endif\n+\n+# AIX\n+ifeq ($(OS_ARCH),AIX)\n+    LDOPTS += -blibpath:$(PWD)/$(dist_libdir):/usr/lib:/lib\n+    ifeq ($(OS_ARCH)$(OS_RELEASE),AIX4.1)\n+        LIBPR = -lnspr$(MOD_MAJOR_VERSION)_shr\n+        LIBPLC = -lplc$(MOD_MAJOR_VERSION)_shr\n+    else\n+        LDOPTS += -brtl\n+        EXTRA_LIBS = -ldl\n+    endif\n+endif\n+\n+ifeq ($(OS_ARCH), Linux)\n+    ifeq ($(OS_RELEASE), 1.2)\n+        EXTRA_LIBS = -ldl\n+    else\n+        LDOPTS += -Xlinker -rpath $(PWD)/$(dist_libdir)\n+        ifeq ($(USE_PTHREADS),1)\n+            EXTRA_LIBS = -lpthread\n+        endif\n+    endif\n+endif\n+\n+ifeq ($(OS_ARCH), SCO_SV)\n+# SCO Unix needs to link against -lsocket again even though we\n+# already linked with these system libraries when we built libnspr.so.\n+EXTRA_LIBS = -lsocket\n+# This hardcodes in the executable programs the directory to find\n+# libnspr.so etc. at program startup.  Equivalent to the -R or -rpath\n+# option for ld on other platforms.\n+export LD_RUN_PATH = $(PWD)/$(dist_libdir)\n+endif\n+\n+#####################################################\n+#\n+# The rules\n+#\n+#####################################################\n+\n+include $(topsrcdir)/config/rules.mk\n+\n+AIX_PRE_4_2 = 0\n+ifeq ($(OS_ARCH),AIX)\n+ifneq ($(OS_RELEASE),4.2)\n+ifneq ($(USE_PTHREADS), 1)\n+#AIX_PRE_4_2 = 1\n+endif\n+endif\n+endif\n+\n+ifeq ($(AIX_PRE_4_2),1)\n+\n+# AIX releases prior to 4.2 need a special two-step linking hack\n+# in order to both override the system select() and be able to \n+# get at the original system select().\n+#\n+# We use a pattern rule in ns/nspr20/config/rules.mk to generate\n+# the .$(OBJ_SUFFIX) file from the .c source file, then do the\n+# two-step linking hack below.\n+\n+$(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)\n+\t@$(MAKE_OBJDIR)\n+\trm -f $@ $(AIX_TMP)\n+\t$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).a\n+\t$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)\n+\trm -f $(AIX_TMP)\n+\n+else\n+\n+# All platforms that are not AIX pre-4.2.\n+\n+$(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)\n+\t@$(MAKE_OBJDIR)\n+ifeq ($(OS_ARCH), WINNT)\n+\tlink $(LDOPTS) $< $(LIBPR) $(LIBPL) ws2_32.lib -out:$@\n+else\n+\t$(CCC) $(XCFLAGS) $< $(LDOPTS) $(LIBPR) $(LIBPL) $(EXTRA_LIBS) -o $@\n+endif\n+endif\n+\n+export:: $(TARGETS)\n+clean::\n+\trm -f $(TARGETS)\n+\ndiff --git a/nspr/pr/src/cplus/tests/fileio.cpp b/nspr/pr/src/cplus/tests/fileio.cpp\nnew file mode 100644\nindex 0000000..fdffe99\n--- /dev/null\n+++ b/nspr/pr/src/cplus/tests/fileio.cpp\n@@ -0,0 +1,33 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/* fileio.cpp - a test program */\n+\n+#include \"rcfileio.h\"\n+\n+#include <prlog.h>\n+#include <prprf.h>\n+\n+#define DEFAULT_ITERATIONS 100\n+\n+PRIntn main(PRIntn argc, char **argv)\n+{\n+    PRStatus rv;\n+    RCFileIO fd;\n+    RCFileInfo info;\n+    rv = fd.Open(\"filio.dat\", PR_CREATE_FILE, 0666);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = fd.FileInfo(&info);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = fd.Delete(\"filio.dat\");\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    fd.Close();\n+    PR_ASSERT(PR_SUCCESS == rv);\n+\n+    return 0;\n+}  /* main */\n+\n+/* interval.cpp */\n+\ndiff --git a/nspr/pr/src/cplus/tests/interval.cpp b/nspr/pr/src/cplus/tests/interval.cpp\nnew file mode 100644\nindex 0000000..8acf506\n--- /dev/null\n+++ b/nspr/pr/src/cplus/tests/interval.cpp\n@@ -0,0 +1,101 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/* interval.cpp - a test program */\n+\n+#include \"rclock.h\"\n+#include \"rcthread.h\"\n+#include \"rcinrval.h\"\n+#include \"rccv.h\"\n+\n+#include <prio.h>\n+#include <prlog.h>\n+#include <prprf.h>\n+\n+#define DEFAULT_ITERATIONS 100\n+\n+PRIntn main(PRIntn argc, char **argv)\n+{\n+    RCLock ml;\n+    PRStatus rv;\n+    RCCondition cv(&ml);\n+\n+    RCInterval now, timeout, epoch, elapsed;\n+    PRFileDesc *output = PR_GetSpecialFD(PR_StandardOutput);\n+    PRIntn msecs, seconds, loops, iterations = DEFAULT_ITERATIONS;\n+\n+    /* slow, agonizing waits */\n+    for (seconds = 0; seconds < 10; ++seconds)\n+    {\n+        timeout = RCInterval::FromSeconds(seconds);\n+        cv.SetTimeout(timeout);\n+        {\n+            RCEnter lock(&ml);\n+\n+            epoch.SetToNow();\n+\n+            rv = cv.Wait();\n+            PR_ASSERT(PR_SUCCESS == rv);\n+\n+            now = RCInterval(RCInterval::now);\n+            elapsed = now - epoch;\n+        }\n+\n+        PR_fprintf(\n+            output, \"Waiting %u seconds took %s%u milliseconds\\n\",\n+            seconds, ((elapsed < timeout)? \"**\" : \"\"),\n+            elapsed.ToMilliseconds());\n+    }\n+\n+    /* more slow, agonizing sleeps */\n+    for (seconds = 0; seconds < 10; ++seconds)\n+    {\n+        timeout = RCInterval::FromSeconds(seconds);\n+        {\n+            epoch.SetToNow();\n+\n+            rv = RCThread::Sleep(timeout);\n+            PR_ASSERT(PR_SUCCESS == rv);\n+\n+            now = RCInterval(RCInterval::now);\n+            elapsed = now - epoch;\n+        }\n+\n+        PR_fprintf(\n+            output, \"Sleeping %u seconds took %s%u milliseconds\\n\",\n+            seconds, ((elapsed < timeout)? \"**\" : \"\"),\n+            elapsed.ToMilliseconds());\n+    }\n+\n+    /* fast, spritely little devils */\n+    for (msecs = 10; msecs < 100; msecs += 10)\n+    {\n+        timeout = RCInterval::FromMilliseconds(msecs);\n+        cv.SetTimeout(timeout);\n+        {\n+            RCEnter lock(&ml);\n+\n+            epoch.SetToNow();\n+\n+            for (loops = 0; loops < iterations; ++loops)\n+            {\n+                rv = cv.Wait();\n+                PR_ASSERT(PR_SUCCESS == rv);\n+            }\n+\n+            now = RCInterval(RCInterval::now);\n+            elapsed = now - epoch;\n+        }\n+        elapsed /= iterations;\n+\n+        PR_fprintf(\n+            output, \"Waiting %u msecs took %s%u milliseconds average\\n\",\n+            msecs, ((elapsed < timeout)? \"**\" : \"\"), elapsed.ToMilliseconds());\n+    }\n+    return 0;\n+}  /* main */\n+\n+/* interval.cpp */\n+\ndiff --git a/nspr/pr/src/cplus/tests/ranfile.cpp b/nspr/pr/src/cplus/tests/ranfile.cpp\nnew file mode 100644\nindex 0000000..0fb4c5d\n--- /dev/null\n+++ b/nspr/pr/src/cplus/tests/ranfile.cpp\n@@ -0,0 +1,449 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/***********************************************************************\n+**\n+** Contact:     AOF<mailto:freier@netscape.com>\n+**\n+** Name: ranfile.c\n+**\n+** Description: Test to hammer on various components of NSPR\n+** Modification History:\n+** 20-May-97 AGarcia- Converted the test to accomodate the debug_mode flag.\n+**           The debug mode will print all of the printfs associated with this test.\n+**           The regress mode will be the default mode. Since the regress tool limits\n+**           the output to a one line status:PASS or FAIL,all of the printf statements\n+**           have been handled with an if (debug_mode) statement.\n+** 04-June-97 AGarcia removed the Test_Result function. Regress tool has been updated to\n+**          recognize the return code from tha main program.\n+***********************************************************************/\n+\n+\n+/***********************************************************************\n+** Includes\n+***********************************************************************/\n+/* Used to get the command line option */\n+#include <plgetopt.h>\n+#include <prprf.h>\n+#include <prio.h>\n+\n+#include \"rccv.h\"\n+#include \"rcthread.h\"\n+#include \"rcfileio.h\"\n+#include \"rclock.h\"\n+\n+#include <string.h>\n+#include <stdio.h>\n+#include <stdlib.h>\n+\n+static PRFileDesc *output;\n+static PRIntn debug_mode = 0;\n+static PRIntn failed_already = 0;\n+\n+class HammerData\n+{\n+public:\n+    typedef enum {\n+        sg_go, sg_stop, sg_done\n+    } Action;\n+    typedef enum {\n+        sg_okay, sg_open, sg_close, sg_delete, sg_write, sg_seek\n+    } Problem;\n+\n+    virtual ~HammerData();\n+    HammerData(RCLock* lock, RCCondition *cond, PRUint32 clip);\n+    virtual PRUint32 Random();\n+\n+    Action action;\n+    Problem problem;\n+    PRUint32 writes;\n+    RCInterval timein;\n+    friend class Hammer;\n+private:\n+    RCLock *ml;\n+    RCCondition *cv;\n+    PRUint32 limit;\n+\n+    PRFloat64 seed;\n+};  /* HammerData */\n+\n+class Hammer: public HammerData, public RCThread\n+{\n+public:\n+    virtual ~Hammer();\n+    Hammer(RCThread::Scope scope, RCLock* lock, RCCondition *cond, PRUint32 clip);\n+\n+private:\n+    void RootFunction();\n+\n+};\n+\n+static PRInt32 pageSize = 1024;\n+static const char* baseName = \"./\";\n+static const char *programName = \"Random File\";\n+\n+/***********************************************************************\n+** PRIVATE FUNCTION:    Random\n+** DESCRIPTION:\n+**   Generate a pseudo-random number\n+** INPUTS:      None\n+** OUTPUTS:     None\n+** RETURN:      A pseudo-random unsigned number, 32-bits wide\n+** SIDE EFFECTS:\n+**      Updates random seed (a static)\n+** RESTRICTIONS:\n+**      None\n+** MEMORY:      NA\n+** ALGORITHM:\n+**      Uses the current interval timer value, promoted to a 64 bit\n+**      float as a multiplier for a static residue (which begins\n+**      as an uninitialized variable). The result is bits [16..48)\n+**      of the product. Seed is then updated with the return value\n+**      promoted to a float-64.\n+***********************************************************************/\n+PRUint32 HammerData::Random()\n+{\n+    PRUint32 rv;\n+    PRUint64 shift;\n+    RCInterval now = RCInterval(RCInterval::now);\n+    PRFloat64 random = seed * (PRFloat64)((PRIntervalTime)now);\n+    LL_USHR(shift, *((PRUint64*)&random), 16);\n+    LL_L2UI(rv, shift);\n+    seed = (PRFloat64)rv;\n+    return rv;\n+}  /* HammerData::Random */\n+\n+Hammer::~Hammer() { }\n+\n+Hammer::Hammer(\n+    RCThread::Scope scope, RCLock* lock, RCCondition *cond, PRUint32 clip):\n+    HammerData(lock, cond, clip), RCThread(scope, RCThread::joinable, 0) { }\n+\n+HammerData::~HammerData() { }\n+\n+HammerData::HammerData(RCLock* lock, RCCondition *cond, PRUint32 clip)\n+{\n+    ml = lock;\n+    cv = cond;\n+    writes = 0;\n+    limit = clip;\n+    seed = 0x58a9382;\n+    action = HammerData::sg_go;\n+    problem = HammerData::sg_okay;\n+    timein = RCInterval(RCInterval::now);\n+}  /* HammerData::HammerData */\n+\n+\n+/***********************************************************************\n+** PRIVATE FUNCTION:    Hammer::RootFunction\n+** DESCRIPTION:\n+**   Hammer on the file I/O system\n+** INPUTS:      A pointer to the thread's private data\n+** OUTPUTS:     None\n+** RETURN:      None\n+** SIDE EFFECTS:\n+**      Creates, accesses and deletes a file\n+** RESTRICTIONS:\n+**      (Currently) must have file create permission in \"/usr/tmp\".\n+** MEMORY:      NA\n+** ALGORITHM:\n+**      This function is a root of a thread\n+**      1) Creates a (hopefully) unique file in /usr/tmp/\n+**      2) Writes a zero to a random number of sequential pages\n+**      3) Closes the file\n+**      4) Reopens the file\n+**      5) Seeks to a random page within the file\n+**      6) Writes a one byte on that page\n+**      7) Repeat steps [5..6] for each page in the file\n+**      8) Close and delete the file\n+**      9) Repeat steps [1..8] until told to stop\n+**     10) Notify complete and return\n+***********************************************************************/\n+void Hammer::RootFunction()\n+{\n+    PRUint32 index;\n+    RCFileIO file;\n+    char filename[30];\n+    const char zero = 0;\n+    PRStatus rv = PR_SUCCESS;\n+\n+    limit = (Random() % limit) + 1;\n+\n+    (void)sprintf(filename, \"%ssg%04p.dat\", baseName, this);\n+\n+    if (debug_mode) {\n+        PR_fprintf(output, \"Starting work on %s\\n\", filename);\n+    }\n+\n+    while (PR_TRUE)\n+    {\n+        PRUint64 bytes;\n+        PRUint32 minor = (Random() % limit) + 1;\n+        PRUint32 random = (Random() % limit) + 1;\n+        PRUint32 pages = (Random() % limit) + 10;\n+        while (minor-- > 0)\n+        {\n+            problem = sg_okay;\n+            if (action != sg_go) {\n+                goto finished;\n+            }\n+            problem = sg_open;\n+            rv = file.Open(filename, PR_RDWR|PR_CREATE_FILE, 0666);\n+            if (PR_FAILURE == rv) {\n+                goto finished;\n+            }\n+            for (index = 0; index < pages; index++)\n+            {\n+                problem = sg_okay;\n+                if (action != sg_go) {\n+                    goto close;\n+                }\n+                problem = sg_seek;\n+                bytes = file.Seek(pageSize * index, RCFileIO::set);\n+                if (bytes != pageSize * index) {\n+                    goto close;\n+                }\n+                problem = sg_write;\n+                bytes = file.Write(&zero, sizeof(zero));\n+                if (bytes <= 0) {\n+                    goto close;\n+                }\n+                writes += 1;\n+            }\n+            problem = sg_close;\n+            rv = file.Close();\n+            if (rv != PR_SUCCESS) {\n+                goto purge;\n+            }\n+\n+            problem = sg_okay;\n+            if (action != sg_go) {\n+                goto purge;\n+            }\n+\n+            problem = sg_open;\n+            rv = file.Open(filename, PR_RDWR, 0666);\n+            if (PR_FAILURE == rv) {\n+                goto finished;\n+            }\n+            for (index = 0; index < pages; index++)\n+            {\n+                problem = sg_okay;\n+                if (action != sg_go) {\n+                    goto close;\n+                }\n+                problem = sg_seek;\n+                bytes = file.Seek(pageSize * index, RCFileIO::set);\n+                if (bytes != pageSize * index) {\n+                    goto close;\n+                }\n+                problem = sg_write;\n+                bytes = file.Write(&zero, sizeof(zero));\n+                if (bytes <= 0) {\n+                    goto close;\n+                }\n+                writes += 1;\n+                random = (random + 511) % pages;\n+            }\n+            problem = sg_close;\n+            rv = file.Close();\n+            if (rv != PR_SUCCESS) {\n+                goto purge;\n+            }\n+            problem = sg_delete;\n+            rv = file.Delete(filename);\n+            if (rv != PR_SUCCESS) {\n+                goto finished;\n+            }\n+        }\n+    }\n+\n+close:\n+    (void)file.Close();\n+purge:\n+    (void)file.Delete(filename);\n+finished:\n+    RCEnter scope(ml);\n+    action = HammerData::sg_done;\n+    cv->Notify();\n+\n+    if (debug_mode) {\n+        PR_fprintf(output, \"Ending work on %s\\n\", filename);\n+    }\n+\n+    return;\n+}  /* Hammer::RootFunction */\n+\n+static Hammer* hammer[100];\n+/***********************************************************************\n+** PRIVATE FUNCTION:    main\n+** DESCRIPTION:\n+**   Hammer on the file I/O system\n+** INPUTS:      The usual argc and argv\n+**              argv[0] - program name (not used)\n+**              argv[1] - the number of virtual_procs to execute the major loop\n+**              argv[2] - the number of threads to toss into the batch\n+**              argv[3] - the clipping number applied to randoms\n+**              default values: max_virtual_procs = 2, threads = 10, limit = 57\n+** OUTPUTS:     None\n+** RETURN:      None\n+** SIDE EFFECTS:\n+**      Creates, accesses and deletes lots of files\n+** RESTRICTIONS:\n+**      (Currently) must have file create permission in \"/usr/tmp\".\n+** MEMORY:      NA\n+** ALGORITHM:\n+**      1) Fork a \"Thread()\"\n+**      2) Wait for 'interleave' seconds\n+**      3) For [0..'threads') repeat [1..2]\n+**      4) Mark all objects to stop\n+**      5) Collect the threads, accumulating the results\n+**      6) For [0..'max_virtual_procs') repeat [1..5]\n+**      7) Print accumulated results and exit\n+**\n+**      Characteristic output (from IRIX)\n+**          Random File: Using max_virtual_procs = 2, threads = 10, limit = 57\n+**          Random File: [min [avg] max] writes/sec average\n+***********************************************************************/\n+PRIntn main (PRIntn argc, char *argv[])\n+{\n+    RCLock ml;\n+    PLOptStatus os;\n+    RCCondition cv(&ml);\n+    PRUint32 writesMax = 0, durationTot = 0;\n+    RCThread::Scope thread_scope = RCThread::local;\n+    PRUint32 writes, writesMin = 0x7fffffff, writesTot = 0;\n+    PRIntn active, poll, limit = 0, max_virtual_procs = 0, threads = 0, virtual_procs;\n+    RCInterval interleave(RCInterval::FromMilliseconds(10000)), duration(0);\n+\n+    const char *where[] = {\"okay\", \"open\", \"close\", \"delete\", \"write\", \"seek\"};\n+\n+    PLOptState *opt = PL_CreateOptState(argc, argv, \"Gdl:t:i:\");\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))\n+    {\n+        if (PL_OPT_BAD == os) {\n+            continue;\n+        }\n+        switch (opt->option)\n+        {\n+            case 0:\n+                baseName = opt->value;\n+                break;\n+            case 'G':  /* global threads */\n+                thread_scope = RCThread::global;\n+                break;\n+            case 'd':  /* debug mode */\n+                debug_mode = 1;\n+                break;\n+            case 'l':  /* limiting number */\n+                limit = atoi(opt->value);\n+                break;\n+            case 't':  /* number of threads */\n+                threads = atoi(opt->value);\n+                break;\n+            case 'i':  /* iteration counter */\n+                max_virtual_procs = atoi(opt->value);\n+                break;\n+            default:\n+                break;\n+        }\n+    }\n+    PL_DestroyOptState(opt);\n+    output = PR_GetSpecialFD(PR_StandardOutput);\n+\n+    /* main test */\n+\n+    cv.SetTimeout(interleave);\n+\n+    if (max_virtual_procs == 0) {\n+        max_virtual_procs = 2;\n+    }\n+    if (limit == 0) {\n+        limit = 57;\n+    }\n+    if (threads == 0) {\n+        threads = 10;\n+    }\n+\n+    if (debug_mode) PR_fprintf(output,\n+                                   \"%s: Using %d virtual processors, %d threads, limit = %d and %s threads\\n\",\n+                                   programName, max_virtual_procs, threads, limit,\n+                                   (thread_scope == RCThread::local) ? \"LOCAL\" : \"GLOBAL\");\n+\n+    for (virtual_procs = 0; virtual_procs < max_virtual_procs; ++virtual_procs)\n+    {\n+        if (debug_mode)\n+            PR_fprintf(output,\n+                       \"%s: Setting number of virtual processors to %d\\n\",\n+                       programName, virtual_procs + 1);\n+        RCPrimordialThread::SetVirtualProcessors(virtual_procs + 1);\n+        for (active = 0; active < threads; active++)\n+        {\n+            hammer[active] = new Hammer(thread_scope, &ml, &cv, limit);\n+            hammer[active]->Start();  /* then make it roll */\n+            RCThread::Sleep(interleave);  /* start them slowly */\n+        }\n+\n+        /*\n+         * The last thread started has had the opportunity to run for\n+         * 'interleave' seconds. Now gather them all back in.\n+         */\n+        {\n+            RCEnter scope(&ml);\n+            for (poll = 0; poll < threads; poll++)\n+            {\n+                if (hammer[poll]->action == HammerData::sg_go) { /* don't overwrite done */\n+                    hammer[poll]->action = HammerData::sg_stop;    /* ask him to stop */\n+                }\n+            }\n+        }\n+\n+        while (active > 0)\n+        {\n+            for (poll = 0; poll < threads; poll++)\n+            {\n+                ml.Acquire();\n+                while (hammer[poll]->action < HammerData::sg_done) {\n+                    cv.Wait();\n+                }\n+                ml.Release();\n+\n+                if (hammer[poll]->problem == HammerData::sg_okay)\n+                {\n+                    duration = RCInterval(RCInterval::now) - hammer[poll]->timein;\n+                    writes = hammer[poll]->writes * 1000 / duration;\n+                    if (writes < writesMin) {\n+                        writesMin = writes;\n+                    }\n+                    if (writes > writesMax) {\n+                        writesMax = writes;\n+                    }\n+                    writesTot += hammer[poll]->writes;\n+                    durationTot += duration;\n+                }\n+                else\n+                {\n+                    if (debug_mode) PR_fprintf(output,\n+                                                   \"%s: test failed %s after %ld seconds\\n\",\n+                                                   programName, where[hammer[poll]->problem], duration);\n+                    else {\n+                        failed_already=1;\n+                    }\n+                }\n+                active -= 1;  /* this is another one down */\n+                (void)hammer[poll]->Join();\n+                hammer[poll] = NULL;\n+            }\n+        }\n+        if (debug_mode) PR_fprintf(output,\n+                                       \"%s: [%ld [%ld] %ld] writes/sec average\\n\",\n+                                       programName, writesMin,\n+                                       writesTot * 1000 / durationTot, writesMax);\n+    }\n+\n+    failed_already |= (PR_FAILURE == RCPrimordialThread::Cleanup());\n+    PR_fprintf(output, \"%s\\n\", (failed_already) ? \"FAIL\\n\" : \"PASS\\n\");\n+    return failed_already;\n+}  /* main */\ndiff --git a/nspr/pr/src/cplus/tests/switch.cpp b/nspr/pr/src/cplus/tests/switch.cpp\nnew file mode 100644\nindex 0000000..00de8e3\n--- /dev/null\n+++ b/nspr/pr/src/cplus/tests/switch.cpp\n@@ -0,0 +1,248 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** File:            switch.cpp\n+** Description:     trying to time context switches\n+*/\n+\n+#include \"rccv.h\"\n+#include \"rcinrval.h\"\n+#include \"rclock.h\"\n+#include \"rcthread.h\"\n+\n+#include <prio.h>\n+#include <prlog.h>\n+#include <prprf.h>\n+#include <plerror.h>\n+#include <plgetopt.h>\n+\n+#include <stdlib.h>\n+\n+#define INNER_LOOPS 100\n+#define DEFAULT_LOOPS 100\n+#define DEFAULT_THREADS 10\n+\n+static PRFileDesc *debug_out = NULL;\n+static PRBool debug_mode = PR_FALSE, verbosity = PR_FALSE, failed = PR_FALSE;\n+\n+class Home: public RCCondition\n+{\n+public:\n+    virtual ~Home();\n+    Home(Home *link, RCLock* ml);\n+\n+public:\n+    Home *next;\n+    RCLock* ml;\n+    PRBool twiddle;\n+};  /* Home */\n+\n+Home::~Home() { }\n+\n+Home::Home(Home *link, RCLock* lock): RCCondition(lock)\n+{\n+    ml = lock;\n+    next = link;\n+    twiddle = PR_FALSE;\n+}  /* Home::Home */\n+\n+class Shared: public Home, public RCThread\n+{\n+public:\n+    Shared(RCThread::Scope scope, Home* link, RCLock* ml);\n+\n+private:\n+    ~Shared();\n+    void RootFunction();\n+};  /* Shared */\n+\n+Shared::Shared(RCThread::Scope scope, Home* link, RCLock* lock):\n+    Home(link, lock), RCThread(scope, RCThread::joinable) { }\n+\n+Shared::~Shared() { }\n+\n+void Shared::RootFunction()\n+{\n+    PRStatus status = PR_SUCCESS;\n+    while (PR_SUCCESS == status)\n+    {\n+        RCEnter entry(ml);\n+        while (twiddle && (PR_SUCCESS == status)) {\n+            status = Wait();\n+        }\n+        if (verbosity) {\n+            PR_fprintf(debug_out, \"+\");\n+        }\n+        twiddle = PR_TRUE;\n+        next->twiddle = PR_FALSE;\n+        next->Notify();\n+    }\n+}  /* Shared::RootFunction */\n+\n+static void Help(void)\n+{\n+    debug_out = PR_STDOUT;\n+\n+    PR_fprintf(\n+        debug_out, \"Usage: >./switch [-d] [-c n] [-t n] [-T n] [-G]\\n\");\n+    PR_fprintf(\n+        debug_out, \"-c n\\tloops at thread level (default: %d)\\n\", DEFAULT_LOOPS);\n+    PR_fprintf(\n+        debug_out, \"-t n\\tnumber of threads (default: %d)\\n\", DEFAULT_THREADS);\n+    PR_fprintf(debug_out, \"-d\\tturn on debugging output (default: FALSE)\\n\");\n+    PR_fprintf(debug_out, \"-v\\tturn on verbose output (default: FALSE)\\n\");\n+    PR_fprintf(debug_out, \"-G n\\tglobal threads only (default: FALSE)\\n\");\n+    PR_fprintf(debug_out, \"-C n\\tconcurrency setting (default: 1)\\n\");\n+}  /* Help */\n+\n+PRIntn main(PRIntn argc, char **argv)\n+{\n+    PLOptStatus os;\n+    PRStatus status;\n+    PRBool help = PR_FALSE;\n+    PRUintn concurrency = 1;\n+    RCThread::Scope thread_scope = RCThread::local;\n+    PRUintn thread_count, inner_count, loop_count, average;\n+    PRUintn thread_limit = DEFAULT_THREADS, loop_limit = DEFAULT_LOOPS;\n+    PLOptState *opt = PL_CreateOptState(argc, argv, \"hdvc:t:C:G\");\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))\n+    {\n+        if (PL_OPT_BAD == os) {\n+            continue;\n+        }\n+        switch (opt->option)\n+        {\n+            case 'v':  /* verbose mode */\n+                verbosity = PR_TRUE;\n+            case 'd':  /* debug mode */\n+                debug_mode = PR_TRUE;\n+                break;\n+            case 'c':  /* loop counter */\n+                loop_limit = atoi(opt->value);\n+                break;\n+            case 't':  /* thread limit */\n+                thread_limit = atoi(opt->value);\n+                break;\n+            case 'C':  /* Concurrency limit */\n+                concurrency = atoi(opt->value);\n+                break;\n+            case 'G':  /* global threads only */\n+                thread_scope = RCThread::global;\n+                break;\n+            case 'h':  /* help message */\n+                Help();\n+                help = PR_TRUE;\n+                break;\n+            default:\n+                break;\n+        }\n+    }\n+    PL_DestroyOptState(opt);\n+\n+    if (help) {\n+        return -1;\n+    }\n+\n+    if (PR_TRUE == debug_mode)\n+    {\n+        debug_out = PR_STDOUT;\n+        PR_fprintf(debug_out, \"Test parameters\\n\");\n+        PR_fprintf(debug_out, \"\\tThreads involved: %d\\n\", thread_limit);\n+        PR_fprintf(debug_out, \"\\tIteration limit: %d\\n\", loop_limit);\n+        PR_fprintf(debug_out, \"\\tConcurrency: %d\\n\", concurrency);\n+        PR_fprintf(\n+            debug_out, \"\\tThread type: %s\\n\",\n+            (PR_GLOBAL_THREAD == thread_scope) ? \"GLOBAL\" : \"LOCAL\");\n+    }\n+\n+    /*\n+    ** The interesting part starts here\n+    */\n+    RCLock lock;\n+    Shared* shared;\n+    Home home(NULL, &lock);\n+    Home* link = &home;\n+    RCInterval timein, timeout = 0;\n+\n+    /* Build up the string of objects */\n+    for (thread_count = 1; thread_count <= thread_limit; ++thread_count)\n+    {\n+        shared = new Shared(thread_scope, link, &lock);\n+        shared->Start();  /* make it run */\n+        link = (Home*)shared;\n+    }\n+\n+    /* Pass the message around the horn a few times */\n+    for (loop_count = 1; loop_count <= loop_limit; ++loop_count)\n+    {\n+        timein.SetToNow();\n+        for (inner_count = 0; inner_count < INNER_LOOPS; ++inner_count)\n+        {\n+            RCEnter entry(&lock);\n+            home.twiddle = PR_TRUE;\n+            shared->twiddle = PR_FALSE;\n+            shared->Notify();\n+            while (home.twiddle)\n+            {\n+                failed = (PR_FAILURE == home.Wait()) ? PR_TRUE : PR_FALSE;\n+            }\n+        }\n+        timeout += (RCInterval(RCInterval::now) - timein);\n+    }\n+\n+    /* Figure out how well we did */\n+    if (debug_mode)\n+    {\n+        average = timeout.ToMicroseconds()\n+                  / (INNER_LOOPS * loop_limit * thread_count);\n+        PR_fprintf(\n+            debug_out, \"Average switch times %d usecs for %d threads\\n\",\n+            average, thread_limit);\n+    }\n+\n+    /* Start reclamation process */\n+    link = shared;\n+    for (thread_count = 1; thread_count <= thread_limit; ++thread_count)\n+    {\n+        if (&home == link) {\n+            break;\n+        }\n+        status = ((Shared*)link)->Interrupt();\n+        if (PR_SUCCESS != status)\n+        {\n+            failed = PR_TRUE;\n+            if (debug_mode) {\n+                PL_FPrintError(debug_out, \"Failed to interrupt\");\n+            }\n+        }\n+        link = link->next;\n+    }\n+\n+    for (thread_count = 1; thread_count <= thread_limit; ++thread_count)\n+    {\n+        link = shared->next;\n+        status = shared->Join();\n+        if (PR_SUCCESS != status)\n+        {\n+            failed = PR_TRUE;\n+            if (debug_mode) {\n+                PL_FPrintError(debug_out, \"Failed to join\");\n+            }\n+        }\n+        if (&home == link) {\n+            break;\n+        }\n+        shared = (Shared*)link;\n+    }\n+\n+    PR_fprintf(PR_STDOUT, ((failed) ? \"FAILED\\n\" : \"PASSED\\n\"));\n+\n+    failed |= (PR_SUCCESS == RCPrimordialThread::Cleanup());\n+\n+    return ((failed) ? 1 : 0);\n+}  /* main */\n+\n+/* switch.c */\ndiff --git a/nspr/pr/src/cplus/tests/thread.cpp b/nspr/pr/src/cplus/tests/thread.cpp\nnew file mode 100644\nindex 0000000..ff01402\n--- /dev/null\n+++ b/nspr/pr/src/cplus/tests/thread.cpp\n@@ -0,0 +1,110 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/* thread.cpp - a test program */\n+\n+#include \"rcthread.h\"\n+\n+#include <prlog.h>\n+\n+#include <stdio.h>\n+\n+class TestThread: public RCThread\n+{\n+public:\n+    TestThread(RCThread::State state, PRIntn count);\n+\n+    virtual void RootFunction();\n+\n+protected:\n+    virtual ~TestThread();\n+\n+private:\n+    PRUint32 mydata;\n+};\n+\n+TestThread::~TestThread() { }\n+\n+TestThread::TestThread(RCThread::State state, PRIntn count):\n+    RCThread(RCThread::global, state, 0) {\n+    mydata = count;\n+}\n+\n+void TestThread::RootFunction()\n+{\n+    SetPriority(RCThread::high);\n+    printf(\"TestThread::RootFunction %d did it\\n\", mydata);\n+}  /* TestThread::RootFunction */\n+\n+class Foo1\n+{\n+public:\n+    Foo1();\n+    virtual ~Foo1();\n+\n+    TestThread *thread;\n+    PRIntn data;\n+};\n+\n+Foo1::Foo1()\n+{\n+    data = 0xafaf;\n+    thread = new TestThread(RCThread::joinable, 0xafaf);\n+    thread->Start();\n+}\n+\n+Foo1::~Foo1()\n+{\n+    PRStatus rv = thread->Join();\n+    PR_ASSERT(PR_SUCCESS == rv);\n+}  /* Foo1::~Foo1 */\n+\n+PRIntn main(PRIntn argc, char **agrv)\n+{\n+    PRStatus status;\n+    PRIntn count = 100;\n+    RCThread *thread[10];\n+    while (--count > 0)\n+    {\n+        TestThread *thread = new TestThread(RCThread::joinable, count);\n+        status = thread->Start();  /* have to remember to start it */\n+        PR_ASSERT(PR_SUCCESS == status);\n+        status = thread->Join();  /* this should work */\n+        PR_ASSERT(PR_SUCCESS == status);\n+    }\n+    while (++count < 100)\n+    {\n+        TestThread *thread = new TestThread(RCThread::unjoinable, count);\n+        status = thread->Start();  /* have to remember to start it */\n+        PR_ASSERT(PR_SUCCESS == status);\n+    }\n+\n+    {\n+        Foo1 *foo1 = new Foo1();\n+        PR_ASSERT(NULL != foo1);\n+        delete foo1;\n+    }\n+\n+    {\n+        for (count = 0; count < 10; ++count)\n+        {\n+            thread[count] = new TestThread( RCThread::joinable, count);\n+            status = thread[count]->Start();  /* have to remember to start it */\n+            PR_ASSERT(PR_SUCCESS == status);\n+        }\n+        for (count = 0; count < 10; ++count)\n+        {\n+            PRStatus rv = thread[count]->Join();\n+            PR_ASSERT(PR_SUCCESS == rv);\n+        }\n+    }\n+\n+    (void)RCPrimordialThread::Cleanup();\n+\n+    return 0;\n+}  /* main */\n+\n+/* thread.cpp */\n+\ndiff --git a/nspr/pr/src/cplus/tests/time.cpp b/nspr/pr/src/cplus/tests/time.cpp\nnew file mode 100644\nindex 0000000..ad27caa\n--- /dev/null\n+++ b/nspr/pr/src/cplus/tests/time.cpp\n@@ -0,0 +1,29 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/* time.cpp - a test program */\n+\n+#include \"rctime.h\"\n+\n+#include <prlog.h>\n+#include <prprf.h>\n+\n+#define DEFAULT_ITERATIONS 100\n+\n+PRIntn main(PRIntn argc, char **argv)\n+{\n+    RCTime unitialized;\n+    RCTime now(PR_Now());\n+    RCTime current(RCTime::now);\n+    PRTime time = current;\n+\n+    unitialized = now;\n+    now.Now();\n+\n+    return 0;\n+}  /* main */\n+\n+/* time.cpp */\n+\ndiff --git a/nspr/pr/src/cplus/tests/tpd.cpp b/nspr/pr/src/cplus/tests/tpd.cpp\nnew file mode 100644\nindex 0000000..2a18c9c\n--- /dev/null\n+++ b/nspr/pr/src/cplus/tests/tpd.cpp\n@@ -0,0 +1,353 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/*\n+** File:        tpd.cpp\n+** Description: Exercising the thread private data bailywick.\n+*/\n+\n+#include \"prlog.h\"\n+#include \"prprf.h\"\n+#include \"rcthread.h\"\n+\n+#include <string.h>\n+\n+#include \"plgetopt.h\"\n+\n+/*\n+** class MyThread\n+*/\n+class MyThread: public RCThread\n+{\n+public:\n+    MyThread();\n+\n+private:\n+    ~MyThread();\n+    void RootFunction();\n+};  /* MyThread */\n+\n+/*\n+** class MyPrivateData\n+*/\n+class MyPrivateData: public RCThreadPrivateData\n+{\n+public:\n+    virtual ~MyPrivateData();\n+\n+    MyPrivateData();\n+    MyPrivateData(char*);\n+    MyPrivateData(const MyPrivateData&);\n+\n+    void Release();\n+\n+private:\n+    char *string;\n+};  /* MyPrivateData */\n+\n+static PRUintn key[128];\n+static PRIntn debug = 0;\n+static PRBool failed = PR_FALSE;\n+static PRBool should = PR_TRUE;\n+static PRBool did = PR_TRUE;\n+static PRFileDesc *fout = NULL;\n+\n+static void PrintProgress(PRIntn line)\n+{\n+    failed = failed || (should && !did);\n+    failed = failed || (!should && did);\n+    if (debug > 0)\n+    {\n+        PR_fprintf(\n+            fout, \"@ line %d destructor should %shave been called and was%s\\n\",\n+            line, ((should) ? \"\" : \"NOT \"), ((did) ? \"\" : \" NOT\"));\n+    }\n+}  /* PrintProgress */\n+\n+static void MyAssert(const char *expr, const char *file, PRIntn line)\n+{\n+    if (debug > 0) {\n+        (void)PR_fprintf(fout, \"'%s' in file: %s: %d\\n\", expr, file, line);\n+    }\n+}  /* MyAssert */\n+\n+#define MY_ASSERT(_expr) \\\n+    ((_expr)?((void)0):MyAssert(# _expr,__FILE__,__LINE__))\n+\n+int main(PRIntn argc, char *argv[])\n+{\n+    PRStatus rv;\n+    PRUintn keys;\n+    MyThread *thread;\n+    const RCThreadPrivateData *pd;\n+    PLOptStatus os;\n+    PLOptState *opt = PL_CreateOptState(argc, argv, \"d\");\n+    RCThread *primordial = RCThread::WrapPrimordialThread();\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))\n+    {\n+        if (PL_OPT_BAD == os) {\n+            continue;\n+        }\n+        switch (opt->option)\n+        {\n+            case 'd':  /* debug mode */\n+                debug = PR_TRUE;\n+                break;\n+            default:\n+                break;\n+        }\n+    }\n+    PL_DestroyOptState(opt);\n+\n+    fout = PR_STDOUT;\n+\n+    MyPrivateData extension = MyPrivateData(\"EXTENSION\");\n+    MyPrivateData key_string[] = {\n+        \"Key #0\", \"Key #1\", \"Key #2\", \"Key #3\",\n+        \"Bogus #5\", \"Bogus #6\", \"Bogus #7\", \"Bogus #8\"\n+    };\n+\n+\n+    did = should = PR_FALSE;\n+    for (keys = 0; keys < 4; ++keys)\n+    {\n+        rv = RCThread::NewPrivateIndex(&key[keys]);\n+        key[keys + 4] = key[keys] + 4;\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    /* the first four should be bu null, the last four undefined and null */\n+    did = should = PR_FALSE;\n+    for (keys = 0; keys < 8; ++keys)\n+    {\n+        pd = RCThread::GetPrivateData(key[keys]);\n+        MY_ASSERT(NULL == pd);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    /* initially set private data for new keys */\n+    did = should = PR_FALSE;\n+    for (keys = 0; keys < 4; ++keys)\n+    {\n+        rv = RCThread::SetPrivateData(key[keys], &key_string[keys]);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    /* re-assign the private data, albeit the same content */\n+    did = PR_FALSE; should = PR_TRUE;\n+    for (keys = 0; keys < 4; ++keys)\n+    {\n+        pd = RCThread::GetPrivateData(key[keys]);\n+        PR_ASSERT(NULL != pd);\n+        rv = RCThread::SetPrivateData(key[keys], &key_string[keys]);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    /* set private to <empty> */\n+    did = PR_FALSE; should = PR_TRUE;\n+    for (keys = 0; keys < 4; ++keys)\n+    {\n+        rv = RCThread::SetPrivateData(key[keys]);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    /* should all be null now */\n+    did = should = PR_FALSE;\n+    for (keys = 0; keys < 4; ++keys)\n+    {\n+        pd = RCThread::GetPrivateData(key[keys]);\n+        PR_ASSERT(NULL == pd);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    /* allocate another batch of keys and assign data to them */\n+    did = should = PR_FALSE;\n+    for (keys = 8; keys < 127; ++keys)\n+    {\n+        rv = RCThread::NewPrivateIndex(&key[keys]);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+        rv = RCThread::SetPrivateData(key[keys], &extension);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    /* set all the extended slots to <empty> */\n+    did = PR_FALSE; should = PR_TRUE;\n+    for (keys = 8; keys < 127; ++keys)\n+    {\n+        rv = RCThread::SetPrivateData(key[keys]);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    /* set all the extended slots to <empty> again (noop) */\n+    did = should = PR_FALSE;\n+    for (keys = 8; keys < 127; ++keys)\n+    {\n+        rv = RCThread::SetPrivateData(key[keys]);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+\n+    if (debug) {\n+        PR_fprintf(fout, \"Creating thread\\n\");\n+    }\n+    thread = new MyThread();\n+    if (debug) {\n+        PR_fprintf(fout, \"Starting thread\\n\");\n+    }\n+    thread->Start();\n+    if (debug) {\n+        PR_fprintf(fout, \"Joining thread\\n\");\n+    }\n+    (void)thread->Join();\n+    if (debug) {\n+        PR_fprintf(fout, \"Joined thread\\n\");\n+    }\n+\n+    failed |= (PR_FAILURE == RCPrimordialThread::Cleanup());\n+\n+    (void)PR_fprintf(\n+        fout, \"%s\\n\",((PR_TRUE == failed) ? \"FAILED\" : \"PASSED\"));\n+\n+    return (failed) ? 1 : 0;\n+\n+}  /* main */\n+\n+/*\n+** class MyPrivateData\n+*/\n+MyPrivateData::~MyPrivateData()\n+{\n+    PR_fprintf(\n+        fout, \"MyPrivateData::~MyPrivateData[%s]\\n\",\n+        (NULL != string) ? string : \"NULL\");\n+}  /* MyPrivateData::~MyPrivateData */\n+\n+MyPrivateData::MyPrivateData(): RCThreadPrivateData()\n+{\n+    PR_fprintf(fout, \"MyPrivateData::MyPrivateData()\\n\");\n+    string = NULL;\n+}  /* MyPrivateData::MyPrivateData */\n+\n+MyPrivateData::MyPrivateData(char* data): RCThreadPrivateData()\n+{\n+    PR_fprintf(fout, \"MyPrivateData::MyPrivateData(char* data)\\n\");\n+    string = data;\n+}  /* MyPrivateData:: MyPrivateData */\n+\n+MyPrivateData::MyPrivateData(const MyPrivateData& him): RCThreadPrivateData(him)\n+{\n+    PR_fprintf(fout, \"MyPrivateData::MyPrivateData(const MyPrivateData& him)\\n\");\n+    string = him.string;\n+}  /* MyPrivateData:: MyPrivateData */\n+\n+void MyPrivateData::Release()\n+{\n+    if (should) {\n+        did = PR_TRUE;\n+    }\n+    else {\n+        failed = PR_TRUE;\n+    }\n+}  /* MyPrivateData::operator= */\n+\n+/*\n+** class MyThread\n+*/\n+MyThread::~MyThread() { }\n+MyThread::MyThread(): RCThread(RCThread::global, RCThread::joinable) { }\n+\n+\n+void MyThread::RootFunction()\n+{\n+    PRStatus rv;\n+    PRUintn keys;\n+    const RCThreadPrivateData *pd;\n+\n+    MyPrivateData extension = MyPrivateData(\"EXTENSION\");\n+    MyPrivateData key_string[] = {\n+        \"Key #0\", \"Key #1\", \"Key #2\", \"Key #3\",\n+        \"Bogus #5\", \"Bogus #6\", \"Bogus #7\", \"Bogus #8\"\n+    };\n+\n+    did = should = PR_FALSE;\n+    for (keys = 0; keys < 8; ++keys)\n+    {\n+        pd = GetPrivateData(key[keys]);\n+        MY_ASSERT(NULL == pd);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    did = should = PR_FALSE;\n+    for (keys = 0; keys < 4; ++keys)\n+    {\n+        rv = SetPrivateData(keys, &key_string[keys]);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+    PrintProgress(__LINE__);\n+\n+#if !defined(DEBUG)\n+    did = should = PR_FALSE;\n+    for (keys = 4; keys < 8; ++keys)\n+    {\n+        rv = SetPrivateData(keys, &key_string[keys]);\n+        MY_ASSERT(PR_FAILURE == rv);\n+    }\n+    PrintProgress(__LINE__);\n+#endif\n+\n+    did = PR_FALSE; should = PR_TRUE;\n+    for (keys = 0; keys < 4; ++keys)\n+    {\n+        rv = SetPrivateData(key[keys], &key_string[keys]);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    did = PR_FALSE; should = PR_TRUE;\n+    for (keys = 0; keys < 4; ++keys)\n+    {\n+        rv = SetPrivateData(key[keys]);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    did = should = PR_FALSE;\n+    for (keys = 0; keys < 4; ++keys)\n+    {\n+        rv = SetPrivateData(key[keys]);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    did = should = PR_FALSE;\n+    for (keys = 8; keys < 127; ++keys)\n+    {\n+        rv = SetPrivateData(key[keys], &extension);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    did = PR_FALSE; should = PR_TRUE;\n+    for (keys = 8; keys < 127; ++keys)\n+    {\n+        rv = SetPrivateData(key[keys]);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+    PrintProgress(__LINE__);\n+\n+    did = should = PR_FALSE;\n+    for (keys = 8; keys < 127; ++keys)\n+    {\n+        rv = SetPrivateData(key[keys]);\n+        MY_ASSERT(PR_SUCCESS == rv);\n+    }\n+}  /* MyThread::RootFunction */\n+\n+/* tpd.c */\ndiff --git a/nspr/pr/src/io/.cvsignore b/nspr/pr/src/io/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/src/io/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/src/io/prdir.c b/nspr/pr/src/io/prdir.c\nindex a501347..f08a2eb 100644\n--- a/nspr/pr/src/io/prdir.c\n+++ b/nspr/pr/src/io/prdir.c\n@@ -1,147 +1,131 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n \n #include \"primpl.h\"\n \n-PR_IMPLEMENT(PRDir*)\n-PR_OpenDir(const char* name)\n-{\n-    PRDir* dir;\n-    PRStatus sts;\n-\n-    dir = PR_NEW(PRDir);\n-    if (dir) {\n-        sts = _PR_MD_OPEN_DIR(&dir->md, name);\n-        if (sts != PR_SUCCESS) {\n-            PR_DELETE(dir);\n-            return NULL;\n-        }\n-    } else {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-    }\n-    return dir;\n-}\n+PR_IMPLEMENT(PRDir*) PR_OpenDir(const char* name) {\n+  PRDir* dir;\n+  PRStatus sts;\n \n-PR_IMPLEMENT(PRDirEntry*)\n-PR_ReadDir(PRDir* dir, PRDirFlags flags)\n-{\n-    /* _MD_READ_DIR return a char* to the name; allocation in machine-dependent\n-     * code */\n-    char* name = _PR_MD_READ_DIR(&dir->md, flags);\n-    dir->d.name = name;\n-    return name ? &dir->d : NULL;\n+  dir = PR_NEW(PRDir);\n+  if (dir) {\n+    sts = _PR_MD_OPEN_DIR(&dir->md, name);\n+    if (sts != PR_SUCCESS) {\n+      PR_DELETE(dir);\n+      return NULL;\n+    }\n+  } else {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  }\n+  return dir;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CloseDir(PRDir* dir)\n-{\n-    PRInt32 rv;\n-\n-    if (dir) {\n-        rv = _PR_MD_CLOSE_DIR(&dir->md);\n-        PR_DELETE(dir);\n-        if (rv < 0) {\n-            return PR_FAILURE;\n-        } else {\n-            return PR_SUCCESS;\n-        }\n-    }\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRDirEntry*) PR_ReadDir(PRDir* dir, PRDirFlags flags) {\n+  /* _MD_READ_DIR return a char* to the name; allocation in machine-dependent\n+   * code */\n+  char* name = _PR_MD_READ_DIR(&dir->md, flags);\n+  dir->d.name = name;\n+  return name ? &dir->d : NULL;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_MkDir(const char* name, PRIntn mode)\n-{\n-    PRInt32 rv;\n+PR_IMPLEMENT(PRStatus) PR_CloseDir(PRDir* dir) {\n+  PRInt32 rv;\n \n-    rv = _PR_MD_MKDIR(name, mode);\n+  if (dir) {\n+    rv = _PR_MD_CLOSE_DIR(&dir->md);\n+    PR_DELETE(dir);\n     if (rv < 0) {\n-        return PR_FAILURE;\n+      return PR_FAILURE;\n     } else {\n-        return PR_SUCCESS;\n+      return PR_SUCCESS;\n     }\n+  }\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_MakeDir(const char* name, PRIntn mode)\n-{\n-    PRInt32 rv;\n+PR_IMPLEMENT(PRStatus) PR_MkDir(const char* name, PRIntn mode) {\n+  PRInt32 rv;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    rv = _PR_MD_MAKE_DIR(name, mode);\n-    if (rv < 0) {\n-        return PR_FAILURE;\n-    } else {\n-        return PR_SUCCESS;\n-    }\n+  rv = _PR_MD_MKDIR(name, mode);\n+  if (rv < 0) {\n+    return PR_FAILURE;\n+  } else {\n+    return PR_SUCCESS;\n+  }\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_RmDir(const char* name)\n-{\n-    PRInt32 rv;\n+PR_IMPLEMENT(PRStatus) PR_MakeDir(const char* name, PRIntn mode) {\n+  PRInt32 rv;\n \n-    rv = _PR_MD_RMDIR(name);\n-    if (rv < 0) {\n-        return PR_FAILURE;\n-    } else {\n-        return PR_SUCCESS;\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  rv = _PR_MD_MAKE_DIR(name, mode);\n+  if (rv < 0) {\n+    return PR_FAILURE;\n+  } else {\n+    return PR_SUCCESS;\n+  }\n+}\n+\n+PR_IMPLEMENT(PRStatus) PR_RmDir(const char* name) {\n+  PRInt32 rv;\n+\n+  rv = _PR_MD_RMDIR(name);\n+  if (rv < 0) {\n+    return PR_FAILURE;\n+  } else {\n+    return PR_SUCCESS;\n+  }\n }\n \n #ifdef MOZ_UNICODE\n /*\n  *  UTF16 Interface\n  */\n-PR_IMPLEMENT(PRDirUTF16*)\n-PR_OpenDirUTF16(const PRUnichar* name)\n-{\n-    PRDirUTF16* dir;\n-    PRStatus sts;\n-\n-    dir = PR_NEW(PRDirUTF16);\n-    if (dir) {\n-        sts = _PR_MD_OPEN_DIR_UTF16(&dir->md, name);\n-        if (sts != PR_SUCCESS) {\n-            PR_DELETE(dir);\n-            return NULL;\n-        }\n-    } else {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+PR_IMPLEMENT(PRDirUTF16*) PR_OpenDirUTF16(const PRUnichar* name) {\n+  PRDirUTF16* dir;\n+  PRStatus sts;\n+\n+  dir = PR_NEW(PRDirUTF16);\n+  if (dir) {\n+    sts = _PR_MD_OPEN_DIR_UTF16(&dir->md, name);\n+    if (sts != PR_SUCCESS) {\n+      PR_DELETE(dir);\n+      return NULL;\n     }\n-    return dir;\n+  } else {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  }\n+  return dir;\n }\n \n PR_IMPLEMENT(PRDirEntryUTF16*)\n-PR_ReadDirUTF16(PRDirUTF16* dir, PRDirFlags flags)\n-{\n-    /*\n-     * _MD_READ_DIR_UTF16 return a PRUnichar* to the name; allocation in\n-     * machine-dependent code\n-     */\n-    PRUnichar* name = _PR_MD_READ_DIR_UTF16(&dir->md, flags);\n-    dir->d.name = name;\n-    return name ? &dir->d : NULL;\n+PR_ReadDirUTF16(PRDirUTF16* dir, PRDirFlags flags) {\n+  /*\n+   * _MD_READ_DIR_UTF16 return a PRUnichar* to the name; allocation in\n+   * machine-dependent code\n+   */\n+  PRUnichar* name = _PR_MD_READ_DIR_UTF16(&dir->md, flags);\n+  dir->d.name = name;\n+  return name ? &dir->d : NULL;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CloseDirUTF16(PRDirUTF16* dir)\n-{\n-    PRInt32 rv;\n-\n-    if (dir) {\n-        rv = _PR_MD_CLOSE_DIR_UTF16(&dir->md);\n-        PR_DELETE(dir);\n-        if (rv < 0) {\n-            return PR_FAILURE;\n-        } else {\n-            return PR_SUCCESS;\n-        }\n+PR_IMPLEMENT(PRStatus) PR_CloseDirUTF16(PRDirUTF16* dir) {\n+  PRInt32 rv;\n+\n+  if (dir) {\n+    rv = _PR_MD_CLOSE_DIR_UTF16(&dir->md);\n+    PR_DELETE(dir);\n+    if (rv < 0) {\n+      return PR_FAILURE;\n+    } else {\n+      return PR_SUCCESS;\n     }\n-    return PR_SUCCESS;\n+  }\n+  return PR_SUCCESS;\n }\n \n #endif /* MOZ_UNICODE */\ndiff --git a/nspr/pr/src/io/prfdcach.c b/nspr/pr/src/io/prfdcach.c\nindex d2af1d9..14ae7ac 100644\n--- a/nspr/pr/src/io/prfdcach.c\n+++ b/nspr/pr/src/io/prfdcach.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -27,10 +28,10 @@\n ** (exclusive of those in use) at a time.\n */\n typedef struct _PR_Fd_Cache {\n-    PRLock* ml;\n-    PRIntn count;\n-    PRFileDesc *head, *tail;\n-    PRIntn limit_low, limit_high;\n+  PRLock* ml;\n+  PRIntn count;\n+  PRFileDesc *head, *tail;\n+  PRIntn limit_low, limit_high;\n } _PR_Fd_Cache;\n \n static _PR_Fd_Cache _pr_fd_cache;\n@@ -39,74 +40,72 @@ static _PR_Fd_Cache _pr_fd_cache;\n ** Get a FileDescriptor from the cache if one exists. If not allocate\n ** a new one from the heap.\n */\n-PRFileDesc*\n-_PR_Getfd(void)\n-{\n-    PRFileDesc* fd;\n-    /*\n-    ** $$$\n-    ** This may look a little wasteful. We'll see. Right now I want to\n-    ** be able to toggle between caching and not at runtime to measure\n-    ** the differences. If it isn't too annoying, I'll leave it in.\n-    ** $$$$\n-    **\n-    ** The test is against _pr_fd_cache.limit_high. If that's zero,\n-    ** we're not doing the extended cache but going for performance.\n-    */\n-    if (0 == _pr_fd_cache.limit_high) {\n+PRFileDesc* _PR_Getfd(void) {\n+  PRFileDesc* fd;\n+  /*\n+  ** $$$\n+  ** This may look a little wasteful. We'll see. Right now I want to\n+  ** be able to toggle between caching and not at runtime to measure\n+  ** the differences. If it isn't too annoying, I'll leave it in.\n+  ** $$$$\n+  **\n+  ** The test is against _pr_fd_cache.limit_high. If that's zero,\n+  ** we're not doing the extended cache but going for performance.\n+  */\n+  if (0 == _pr_fd_cache.limit_high) {\n+    goto allocate;\n+  } else {\n+    do {\n+      if (NULL == _pr_fd_cache.head) {\n+        goto allocate; /* nothing there */\n+      }\n+      if (_pr_fd_cache.count < _pr_fd_cache.limit_low) {\n         goto allocate;\n-    } else {\n-        do {\n-            if (NULL == _pr_fd_cache.head) {\n-                goto allocate; /* nothing there */\n-            }\n-            if (_pr_fd_cache.count < _pr_fd_cache.limit_low) {\n-                goto allocate;\n-            }\n-\n-            /* we \"should\" be able to extract an fd from the cache */\n-            PR_Lock(_pr_fd_cache.ml); /* need the lock to do this safely */\n-            fd = _pr_fd_cache.head;   /* protected extraction */\n-            if (NULL == fd)           /* unexpected, but not fatal */\n-            {\n-                PR_ASSERT(0 == _pr_fd_cache.count);\n-                PR_ASSERT(NULL == _pr_fd_cache.tail);\n-            } else {\n-                _pr_fd_cache.count -= 1;\n-                _pr_fd_cache.head = fd->higher;\n-                if (NULL == _pr_fd_cache.head) {\n-                    PR_ASSERT(0 == _pr_fd_cache.count);\n-                    _pr_fd_cache.tail = NULL;\n-                }\n-                PR_ASSERT(&_pr_faulty_methods == fd->methods);\n-                PR_ASSERT(PR_INVALID_IO_LAYER == fd->identity);\n-                PR_ASSERT(_PR_FILEDESC_FREED == fd->secret->state);\n-            }\n-            PR_Unlock(_pr_fd_cache.ml);\n-\n-        } while (NULL == fd); /* then go around and allocate a new one */\n-    }\n+      }\n+\n+      /* we \"should\" be able to extract an fd from the cache */\n+      PR_Lock(_pr_fd_cache.ml); /* need the lock to do this safely */\n+      fd = _pr_fd_cache.head;   /* protected extraction */\n+      if (NULL == fd)           /* unexpected, but not fatal */\n+      {\n+        PR_ASSERT(0 == _pr_fd_cache.count);\n+        PR_ASSERT(NULL == _pr_fd_cache.tail);\n+      } else {\n+        _pr_fd_cache.count -= 1;\n+        _pr_fd_cache.head = fd->higher;\n+        if (NULL == _pr_fd_cache.head) {\n+          PR_ASSERT(0 == _pr_fd_cache.count);\n+          _pr_fd_cache.tail = NULL;\n+        }\n+        PR_ASSERT(&_pr_faulty_methods == fd->methods);\n+        PR_ASSERT(PR_INVALID_IO_LAYER == fd->identity);\n+        PR_ASSERT(_PR_FILEDESC_FREED == fd->secret->state);\n+      }\n+      PR_Unlock(_pr_fd_cache.ml);\n+\n+    } while (NULL == fd); /* then go around and allocate a new one */\n+  }\n \n finished:\n-    fd->dtor = NULL;\n-    fd->lower = fd->higher = NULL;\n-    fd->identity = PR_NSPR_IO_LAYER;\n-    memset(fd->secret, 0, sizeof(PRFilePrivate));\n-    return fd;\n+  fd->dtor = NULL;\n+  fd->lower = fd->higher = NULL;\n+  fd->identity = PR_NSPR_IO_LAYER;\n+  memset(fd->secret, 0, sizeof(PRFilePrivate));\n+  return fd;\n \n allocate:\n-    fd = PR_NEW(PRFileDesc);\n-    if (NULL != fd) {\n-        fd->secret = PR_NEW(PRFilePrivate);\n-        if (NULL == fd->secret) {\n-            PR_DELETE(fd);\n-        }\n-    }\n-    if (NULL != fd) {\n-        goto finished;\n-    } else {\n-        return NULL;\n+  fd = PR_NEW(PRFileDesc);\n+  if (NULL != fd) {\n+    fd->secret = PR_NEW(PRFilePrivate);\n+    if (NULL == fd->secret) {\n+      PR_DELETE(fd);\n     }\n+  }\n+  if (NULL != fd) {\n+    goto finished;\n+  } else {\n+    return NULL;\n+  }\n \n } /* _PR_Getfd */\n \n@@ -114,126 +113,118 @@ allocate:\n ** Return a file descriptor to the cache unless there are too many in\n ** there already. If put in cache, clear the fields first.\n */\n-void\n-_PR_Putfd(PRFileDesc* fd)\n-{\n-    PR_ASSERT(PR_NSPR_IO_LAYER == fd->identity);\n-    fd->methods = &_pr_faulty_methods;\n-    fd->identity = PR_INVALID_IO_LAYER;\n-    fd->secret->state = _PR_FILEDESC_FREED;\n-\n-    if (0 != _pr_fd_cache.limit_high) {\n-        if (_pr_fd_cache.count < _pr_fd_cache.limit_high) {\n-            PR_Lock(_pr_fd_cache.ml);\n-            if (NULL == _pr_fd_cache.tail) {\n-                PR_ASSERT(0 == _pr_fd_cache.count);\n-                PR_ASSERT(NULL == _pr_fd_cache.head);\n-                _pr_fd_cache.head = _pr_fd_cache.tail = fd;\n-            } else {\n-                PR_ASSERT(NULL == _pr_fd_cache.tail->higher);\n-                _pr_fd_cache.tail->higher = fd;\n-                _pr_fd_cache.tail = fd; /* new value */\n-            }\n-            fd->higher = NULL;       /* always so */\n-            _pr_fd_cache.count += 1; /* count the new entry */\n-            PR_Unlock(_pr_fd_cache.ml);\n-            return;\n-        }\n+void _PR_Putfd(PRFileDesc* fd) {\n+  PR_ASSERT(PR_NSPR_IO_LAYER == fd->identity);\n+  fd->methods = &_pr_faulty_methods;\n+  fd->identity = PR_INVALID_IO_LAYER;\n+  fd->secret->state = _PR_FILEDESC_FREED;\n+\n+  if (0 != _pr_fd_cache.limit_high) {\n+    if (_pr_fd_cache.count < _pr_fd_cache.limit_high) {\n+      PR_Lock(_pr_fd_cache.ml);\n+      if (NULL == _pr_fd_cache.tail) {\n+        PR_ASSERT(0 == _pr_fd_cache.count);\n+        PR_ASSERT(NULL == _pr_fd_cache.head);\n+        _pr_fd_cache.head = _pr_fd_cache.tail = fd;\n+      } else {\n+        PR_ASSERT(NULL == _pr_fd_cache.tail->higher);\n+        _pr_fd_cache.tail->higher = fd;\n+        _pr_fd_cache.tail = fd; /* new value */\n+      }\n+      fd->higher = NULL;       /* always so */\n+      _pr_fd_cache.count += 1; /* count the new entry */\n+      PR_Unlock(_pr_fd_cache.ml);\n+      return;\n     }\n+  }\n \n-    PR_Free(fd->secret);\n-    PR_Free(fd);\n+  PR_Free(fd->secret);\n+  PR_Free(fd);\n } /* _PR_Putfd */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_SetFDCacheSize(PRIntn low, PRIntn high)\n-{\n-    /*\n-    ** This can be called at any time, may adjust the cache sizes,\n-    ** turn the caches off, or turn them on. It is not dependent\n-    ** on the compilation setting of DEBUG.\n-    */\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    if (low > high) {\n-        low = high; /* sanity check the params */\n-    }\n-\n-    PR_Lock(_pr_fd_cache.ml);\n-    _pr_fd_cache.limit_high = high;\n-    _pr_fd_cache.limit_low = low;\n-    PR_Unlock(_pr_fd_cache.ml);\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high) {\n+  /*\n+  ** This can be called at any time, may adjust the cache sizes,\n+  ** turn the caches off, or turn them on. It is not dependent\n+  ** on the compilation setting of DEBUG.\n+  */\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  if (low > high) {\n+    low = high; /* sanity check the params */\n+  }\n+\n+  PR_Lock(_pr_fd_cache.ml);\n+  _pr_fd_cache.limit_high = high;\n+  _pr_fd_cache.limit_low = low;\n+  PR_Unlock(_pr_fd_cache.ml);\n+  return PR_SUCCESS;\n } /* PR_SetFDCacheSize */\n \n-void\n-_PR_InitFdCache(void)\n-{\n-    /*\n-    ** The fd caching is enabled by default for DEBUG builds,\n-    ** disabled by default for OPT builds. That default can\n-    ** be overridden at runtime using environment variables\n-    ** or a super-wiz-bang API.\n-    */\n-    const char* low = PR_GetEnv(\"NSPR_FD_CACHE_SIZE_LOW\");\n-    const char* high = PR_GetEnv(\"NSPR_FD_CACHE_SIZE_HIGH\");\n-\n-    /*\n-    ** _low is allowed to be zero, _high is not.\n-    ** If _high is zero, we're not doing the caching.\n-    */\n-\n-    _pr_fd_cache.limit_low = 0;\n+void _PR_InitFdCache(void) {\n+  /*\n+  ** The fd caching is enabled by default for DEBUG builds,\n+  ** disabled by default for OPT builds. That default can\n+  ** be overridden at runtime using environment variables\n+  ** or a super-wiz-bang API.\n+  */\n+  const char* low = PR_GetEnv(\"NSPR_FD_CACHE_SIZE_LOW\");\n+  const char* high = PR_GetEnv(\"NSPR_FD_CACHE_SIZE_HIGH\");\n+\n+  /*\n+  ** _low is allowed to be zero, _high is not.\n+  ** If _high is zero, we're not doing the caching.\n+  */\n+\n+  _pr_fd_cache.limit_low = 0;\n #if defined(DEBUG)\n-    _pr_fd_cache.limit_high = FD_SETSIZE;\n+  _pr_fd_cache.limit_high = FD_SETSIZE;\n #else\n-    _pr_fd_cache.limit_high = 0;\n+  _pr_fd_cache.limit_high = 0;\n #endif /* defined(DEBUG) */\n \n-    if (NULL != low) {\n-        _pr_fd_cache.limit_low = atoi(low);\n-    }\n-    if (NULL != high) {\n-        _pr_fd_cache.limit_high = atoi(high);\n-    }\n+  if (NULL != low) {\n+    _pr_fd_cache.limit_low = atoi(low);\n+  }\n+  if (NULL != high) {\n+    _pr_fd_cache.limit_high = atoi(high);\n+  }\n \n-    if (_pr_fd_cache.limit_low < 0) {\n-        _pr_fd_cache.limit_low = 0;\n-    }\n-    if (_pr_fd_cache.limit_low > FD_SETSIZE) {\n-        _pr_fd_cache.limit_low = FD_SETSIZE;\n-    }\n+  if (_pr_fd_cache.limit_low < 0) {\n+    _pr_fd_cache.limit_low = 0;\n+  }\n+  if (_pr_fd_cache.limit_low > FD_SETSIZE) {\n+    _pr_fd_cache.limit_low = FD_SETSIZE;\n+  }\n \n-    if (_pr_fd_cache.limit_high > FD_SETSIZE) {\n-        _pr_fd_cache.limit_high = FD_SETSIZE;\n-    }\n+  if (_pr_fd_cache.limit_high > FD_SETSIZE) {\n+    _pr_fd_cache.limit_high = FD_SETSIZE;\n+  }\n \n-    if (_pr_fd_cache.limit_high < _pr_fd_cache.limit_low) {\n-        _pr_fd_cache.limit_high = _pr_fd_cache.limit_low;\n-    }\n+  if (_pr_fd_cache.limit_high < _pr_fd_cache.limit_low) {\n+    _pr_fd_cache.limit_high = _pr_fd_cache.limit_low;\n+  }\n \n-    _pr_fd_cache.ml = PR_NewLock();\n-    PR_ASSERT(NULL != _pr_fd_cache.ml);\n+  _pr_fd_cache.ml = PR_NewLock();\n+  PR_ASSERT(NULL != _pr_fd_cache.ml);\n \n } /* _PR_InitFdCache */\n \n-void\n-_PR_CleanupFdCache(void)\n-{\n-    PRFileDesc *fd, *next;\n-\n-    for (fd = _pr_fd_cache.head; fd != NULL; fd = next) {\n-        next = fd->higher;\n-        PR_DELETE(fd->secret);\n-        PR_DELETE(fd);\n-    }\n-    _pr_fd_cache.head = NULL;\n-    _pr_fd_cache.tail = NULL;\n-    _pr_fd_cache.count = 0;\n-    PR_DestroyLock(_pr_fd_cache.ml);\n-    _pr_fd_cache.ml = NULL;\n+void _PR_CleanupFdCache(void) {\n+  PRFileDesc *fd, *next;\n+\n+  for (fd = _pr_fd_cache.head; fd != NULL; fd = next) {\n+    next = fd->higher;\n+    PR_DELETE(fd->secret);\n+    PR_DELETE(fd);\n+  }\n+  _pr_fd_cache.head = NULL;\n+  _pr_fd_cache.tail = NULL;\n+  _pr_fd_cache.count = 0;\n+  PR_DestroyLock(_pr_fd_cache.ml);\n+  _pr_fd_cache.ml = NULL;\n } /* _PR_CleanupFdCache */\n \n /* prfdcach.c */\ndiff --git a/nspr/pr/src/io/prfile.c b/nspr/pr/src/io/prfile.c\nindex 2a99650..1e1b0f0 100644\n--- a/nspr/pr/src/io/prfile.c\n+++ b/nspr/pr/src/io/prfile.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,565 +9,510 @@\n #include <fcntl.h>\n \n #ifdef XP_UNIX\n-#if defined(AIX) || defined(QNX)\n+#  if defined(AIX) || defined(QNX)\n /* To pick up sysconf */\n-#include <unistd.h>\n-#else\n+#    include <unistd.h>\n+#  else\n /* To pick up getrlimit, setrlimit */\n-#include <sys/time.h>\n-#include <sys/resource.h>\n-#endif\n+#    include <sys/time.h>\n+#    include <sys/resource.h>\n+#  endif\n #endif /* XP_UNIX */\n \n extern PRLock* _pr_flock_lock;\n extern PRCondVar* _pr_flock_cv;\n \n-static PRInt32 PR_CALLBACK\n-FileRead(PRFileDesc* fd, void* buf, PRInt32 amount)\n-{\n-    PRInt32 rv = 0;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        rv = -1;\n-    }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        rv = -1;\n-    }\n-    if (rv == -1) {\n-        return rv;\n-    }\n-\n-    rv = _PR_MD_READ(fd, buf, amount);\n-    if (rv < 0) {\n-        PR_ASSERT(rv == -1);\n-    }\n-    PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"read -> %d\", rv));\n+static PRInt32 PR_CALLBACK FileRead(PRFileDesc* fd, void* buf, PRInt32 amount) {\n+  PRInt32 rv = 0;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    rv = -1;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    rv = -1;\n+  }\n+  if (rv == -1) {\n     return rv;\n-}\n-\n-static PRInt32 PR_CALLBACK\n-FileWrite(PRFileDesc* fd, const void* buf,\n-          PRInt32 amount)\n-{\n-    PRInt32 rv = 0;\n-    PRInt32 temp, count;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        rv = -1;\n-    }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        rv = -1;\n-    }\n-    if (rv != 0) {\n-        return rv;\n-    }\n+  }\n+\n+  rv = _PR_MD_READ(fd, buf, amount);\n+  if (rv < 0) {\n+    PR_ASSERT(rv == -1);\n+  }\n+  PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"read -> %d\", rv));\n+  return rv;\n+}\n+\n+static PRInt32 PR_CALLBACK FileWrite(PRFileDesc* fd, const void* buf,\n+                                     PRInt32 amount) {\n+  PRInt32 rv = 0;\n+  PRInt32 temp, count;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    rv = -1;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    rv = -1;\n+  }\n+  if (rv != 0) {\n+    return rv;\n+  }\n \n-    count = 0;\n+  count = 0;\n #if !defined(_PR_HAVE_O_APPEND) /* Bugzilla: 4090, 276330 */\n-    if (fd->secret->appendMode) {\n-        if (PR_Seek64(fd, 0, PR_SEEK_END) == -1) {\n-            return -1;\n-        }\n-    } /* if (fd->secret->appendMode...) */\n+  if (fd->secret->appendMode) {\n+    if (PR_Seek64(fd, 0, PR_SEEK_END) == -1) {\n+      return -1;\n+    }\n+  } /* if (fd->secret->appendMode...) */\n #endif /* _PR_HAVE_O_APPEND */\n-    while (amount > 0) {\n-        temp = _PR_MD_WRITE(fd, buf, amount);\n-        if (temp < 0) {\n-            count = -1;\n-            break;\n-        }\n-        count += temp;\n-        if (fd->secret->nonblocking) {\n-            break;\n-        }\n-        buf = (const void*)((const char*)buf + temp);\n-        amount -= temp;\n+  while (amount > 0) {\n+    temp = _PR_MD_WRITE(fd, buf, amount);\n+    if (temp < 0) {\n+      count = -1;\n+      break;\n     }\n-    PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"write -> %d\", count));\n-    return count;\n+    count += temp;\n+    if (fd->secret->nonblocking) {\n+      break;\n+    }\n+    buf = (const void*)((const char*)buf + temp);\n+    amount -= temp;\n+  }\n+  PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"write -> %d\", count));\n+  return count;\n }\n \n-static PROffset32 PR_CALLBACK\n-FileSeek(PRFileDesc* fd, PROffset32 offset,\n-         PRSeekWhence whence)\n-{\n-    PROffset32 result;\n+static PROffset32 PR_CALLBACK FileSeek(PRFileDesc* fd, PROffset32 offset,\n+                                       PRSeekWhence whence) {\n+  PROffset32 result;\n \n-    result = _PR_MD_LSEEK(fd, offset, whence);\n-    return result;\n+  result = _PR_MD_LSEEK(fd, offset, whence);\n+  return result;\n }\n \n-static PROffset64 PR_CALLBACK\n-FileSeek64(PRFileDesc* fd, PROffset64 offset,\n-           PRSeekWhence whence)\n-{\n-    PROffset64 result;\n+static PROffset64 PR_CALLBACK FileSeek64(PRFileDesc* fd, PROffset64 offset,\n+                                         PRSeekWhence whence) {\n+  PROffset64 result;\n \n-    result = _PR_MD_LSEEK64(fd, offset, whence);\n-    return result;\n+  result = _PR_MD_LSEEK64(fd, offset, whence);\n+  return result;\n }\n \n-static PRInt32 PR_CALLBACK\n-FileAvailable(PRFileDesc* fd)\n-{\n-    PRInt32 result, cur, end;\n+static PRInt32 PR_CALLBACK FileAvailable(PRFileDesc* fd) {\n+  PRInt32 result, cur, end;\n \n-    cur = _PR_MD_LSEEK(fd, 0, PR_SEEK_CUR);\n+  cur = _PR_MD_LSEEK(fd, 0, PR_SEEK_CUR);\n \n-    if (cur >= 0) {\n-        end = _PR_MD_LSEEK(fd, 0, PR_SEEK_END);\n-    }\n+  if (cur >= 0) {\n+    end = _PR_MD_LSEEK(fd, 0, PR_SEEK_END);\n+  }\n \n-    if ((cur < 0) || (end < 0)) {\n-        return -1;\n-    }\n+  if ((cur < 0) || (end < 0)) {\n+    return -1;\n+  }\n \n-    result = end - cur;\n-    _PR_MD_LSEEK(fd, cur, PR_SEEK_SET);\n+  result = end - cur;\n+  _PR_MD_LSEEK(fd, cur, PR_SEEK_SET);\n \n-    return result;\n+  return result;\n }\n \n-static PRInt64 PR_CALLBACK\n-FileAvailable64(PRFileDesc* fd)\n-{\n-    PRInt64 result, cur, end;\n-    PRInt64 minus_one;\n+static PRInt64 PR_CALLBACK FileAvailable64(PRFileDesc* fd) {\n+  PRInt64 result, cur, end;\n+  PRInt64 minus_one;\n \n-    LL_I2L(minus_one, -1);\n-    cur = _PR_MD_LSEEK64(fd, LL_ZERO, PR_SEEK_CUR);\n+  LL_I2L(minus_one, -1);\n+  cur = _PR_MD_LSEEK64(fd, LL_ZERO, PR_SEEK_CUR);\n \n-    if (LL_GE_ZERO(cur)) {\n-        end = _PR_MD_LSEEK64(fd, LL_ZERO, PR_SEEK_END);\n-    }\n+  if (LL_GE_ZERO(cur)) {\n+    end = _PR_MD_LSEEK64(fd, LL_ZERO, PR_SEEK_END);\n+  }\n \n-    if (!LL_GE_ZERO(cur) || !LL_GE_ZERO(end)) {\n-        return minus_one;\n-    }\n+  if (!LL_GE_ZERO(cur) || !LL_GE_ZERO(end)) {\n+    return minus_one;\n+  }\n \n-    LL_SUB(result, end, cur);\n-    (void)_PR_MD_LSEEK64(fd, cur, PR_SEEK_SET);\n+  LL_SUB(result, end, cur);\n+  (void)_PR_MD_LSEEK64(fd, cur, PR_SEEK_SET);\n \n-    return result;\n+  return result;\n }\n \n-static PRInt32 PR_CALLBACK\n-PipeAvailable(PRFileDesc* fd)\n-{\n-    PRInt32 rv;\n-    rv = _PR_MD_PIPEAVAILABLE(fd);\n-    return rv;\n+static PRInt32 PR_CALLBACK PipeAvailable(PRFileDesc* fd) {\n+  PRInt32 rv;\n+  rv = _PR_MD_PIPEAVAILABLE(fd);\n+  return rv;\n }\n \n-static PRInt64 PR_CALLBACK\n-PipeAvailable64(PRFileDesc* fd)\n-{\n-    PRInt64 rv;\n-    LL_I2L(rv, _PR_MD_PIPEAVAILABLE(fd));\n-    return rv;\n+static PRInt64 PR_CALLBACK PipeAvailable64(PRFileDesc* fd) {\n+  PRInt64 rv;\n+  LL_I2L(rv, _PR_MD_PIPEAVAILABLE(fd));\n+  return rv;\n }\n \n-static PRStatus PR_CALLBACK\n-PipeSync(PRFileDesc* fd)\n-{\n-    return PR_SUCCESS;\n-}\n+static PRStatus PR_CALLBACK PipeSync(PRFileDesc* fd) { return PR_SUCCESS; }\n \n-static PRStatus PR_CALLBACK\n-FileGetInfo(PRFileDesc* fd, PRFileInfo* info)\n-{\n-    PRInt32 rv;\n+static PRStatus PR_CALLBACK FileGetInfo(PRFileDesc* fd, PRFileInfo* info) {\n+  PRInt32 rv;\n \n-    rv = _PR_MD_GETOPENFILEINFO(fd, info);\n-    if (rv < 0) {\n-        return PR_FAILURE;\n-    } else {\n-        return PR_SUCCESS;\n-    }\n+  rv = _PR_MD_GETOPENFILEINFO(fd, info);\n+  if (rv < 0) {\n+    return PR_FAILURE;\n+  } else {\n+    return PR_SUCCESS;\n+  }\n }\n \n-static PRStatus PR_CALLBACK\n-FileGetInfo64(PRFileDesc* fd, PRFileInfo64* info)\n-{\n-    /* $$$$ NOT YET IMPLEMENTED */\n-    PRInt32 rv;\n+static PRStatus PR_CALLBACK FileGetInfo64(PRFileDesc* fd, PRFileInfo64* info) {\n+  /* $$$$ NOT YET IMPLEMENTED */\n+  PRInt32 rv;\n \n-    rv = _PR_MD_GETOPENFILEINFO64(fd, info);\n-    if (rv < 0) {\n-        return PR_FAILURE;\n-    } else {\n-        return PR_SUCCESS;\n-    }\n+  rv = _PR_MD_GETOPENFILEINFO64(fd, info);\n+  if (rv < 0) {\n+    return PR_FAILURE;\n+  } else {\n+    return PR_SUCCESS;\n+  }\n }\n \n-static PRStatus PR_CALLBACK\n-FileSync(PRFileDesc* fd)\n-{\n-    PRInt32 result;\n-    result = _PR_MD_FSYNC(fd);\n-    if (result < 0) {\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+static PRStatus PR_CALLBACK FileSync(PRFileDesc* fd) {\n+  PRInt32 result;\n+  result = _PR_MD_FSYNC(fd);\n+  if (result < 0) {\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-static PRStatus PR_CALLBACK\n-FileClose(PRFileDesc* fd)\n-{\n-    if (!fd || !fd->secret ||\n-        (fd->secret->state != _PR_FILEDESC_OPEN &&\n-         fd->secret->state != _PR_FILEDESC_CLOSED)) {\n-        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+static PRStatus PR_CALLBACK FileClose(PRFileDesc* fd) {\n+  if (!fd || !fd->secret ||\n+      (fd->secret->state != _PR_FILEDESC_OPEN &&\n+       fd->secret->state != _PR_FILEDESC_CLOSED)) {\n+    PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-    if (fd->secret->state == _PR_FILEDESC_OPEN) {\n-        if (_PR_MD_CLOSE_FILE(fd->secret->md.osfd) < 0) {\n-            return PR_FAILURE;\n-        }\n-        fd->secret->state = _PR_FILEDESC_CLOSED;\n+  if (fd->secret->state == _PR_FILEDESC_OPEN) {\n+    if (_PR_MD_CLOSE_FILE(fd->secret->md.osfd) < 0) {\n+      return PR_FAILURE;\n     }\n-    PR_FreeFileDesc(fd);\n-    return PR_SUCCESS;\n+    fd->secret->state = _PR_FILEDESC_CLOSED;\n+  }\n+  PR_FreeFileDesc(fd);\n+  return PR_SUCCESS;\n }\n \n-static PRInt16 PR_CALLBACK\n-FilePoll(PRFileDesc* fd, PRInt16 in_flags,\n-         PRInt16* out_flags)\n-{\n-    *out_flags = 0;\n-    return in_flags;\n+static PRInt16 PR_CALLBACK FilePoll(PRFileDesc* fd, PRInt16 in_flags,\n+                                    PRInt16* out_flags) {\n+  *out_flags = 0;\n+  return in_flags;\n } /* FilePoll */\n \n-static PRIOMethods _pr_fileMethods = { PR_DESC_FILE,\n-                                       FileClose,\n-                                       FileRead,\n-                                       FileWrite,\n-                                       FileAvailable,\n-                                       FileAvailable64,\n-                                       FileSync,\n-                                       FileSeek,\n-                                       FileSeek64,\n-                                       FileGetInfo,\n-                                       FileGetInfo64,\n-                                       (PRWritevFN)_PR_InvalidInt,\n-                                       (PRConnectFN)_PR_InvalidStatus,\n-                                       (PRAcceptFN)_PR_InvalidDesc,\n-                                       (PRBindFN)_PR_InvalidStatus,\n-                                       (PRListenFN)_PR_InvalidStatus,\n-                                       (PRShutdownFN)_PR_InvalidStatus,\n-                                       (PRRecvFN)_PR_InvalidInt,\n-                                       (PRSendFN)_PR_InvalidInt,\n-                                       (PRRecvfromFN)_PR_InvalidInt,\n-                                       (PRSendtoFN)_PR_InvalidInt,\n-                                       FilePoll,\n-                                       (PRAcceptreadFN)_PR_InvalidInt,\n-                                       (PRTransmitfileFN)_PR_InvalidInt,\n-                                       (PRGetsocknameFN)_PR_InvalidStatus,\n-                                       (PRGetpeernameFN)_PR_InvalidStatus,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRGetsocketoptionFN)_PR_InvalidStatus,\n-                                       (PRSetsocketoptionFN)_PR_InvalidStatus,\n-                                       (PRSendfileFN)_PR_InvalidInt,\n-                                       (PRConnectcontinueFN)_PR_InvalidStatus,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRReservedFN)_PR_InvalidInt };\n-\n-PR_IMPLEMENT(const PRIOMethods*)\n-PR_GetFileMethods(void)\n-{\n-    return &_pr_fileMethods;\n-}\n-\n-static PRIOMethods _pr_pipeMethods = { PR_DESC_PIPE,\n-                                       FileClose,\n-                                       FileRead,\n-                                       FileWrite,\n-                                       PipeAvailable,\n-                                       PipeAvailable64,\n-                                       PipeSync,\n-                                       (PRSeekFN)_PR_InvalidInt,\n-                                       (PRSeek64FN)_PR_InvalidInt64,\n-                                       (PRFileInfoFN)_PR_InvalidStatus,\n-                                       (PRFileInfo64FN)_PR_InvalidStatus,\n-                                       (PRWritevFN)_PR_InvalidInt,\n-                                       (PRConnectFN)_PR_InvalidStatus,\n-                                       (PRAcceptFN)_PR_InvalidDesc,\n-                                       (PRBindFN)_PR_InvalidStatus,\n-                                       (PRListenFN)_PR_InvalidStatus,\n-                                       (PRShutdownFN)_PR_InvalidStatus,\n-                                       (PRRecvFN)_PR_InvalidInt,\n-                                       (PRSendFN)_PR_InvalidInt,\n-                                       (PRRecvfromFN)_PR_InvalidInt,\n-                                       (PRSendtoFN)_PR_InvalidInt,\n-                                       FilePoll,\n-                                       (PRAcceptreadFN)_PR_InvalidInt,\n-                                       (PRTransmitfileFN)_PR_InvalidInt,\n-                                       (PRGetsocknameFN)_PR_InvalidStatus,\n-                                       (PRGetpeernameFN)_PR_InvalidStatus,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRGetsocketoptionFN)_PR_InvalidStatus,\n-                                       (PRSetsocketoptionFN)_PR_InvalidStatus,\n-                                       (PRSendfileFN)_PR_InvalidInt,\n-                                       (PRConnectcontinueFN)_PR_InvalidStatus,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRReservedFN)_PR_InvalidInt };\n-\n-PR_IMPLEMENT(const PRIOMethods*)\n-PR_GetPipeMethods(void)\n-{\n-    return &_pr_pipeMethods;\n-}\n-\n-PR_IMPLEMENT(PRFileDesc*)\n-PR_Open(const char* name, PRIntn flags, PRIntn mode)\n-{\n-    PROsfd osfd;\n-    PRFileDesc* fd = 0;\n+static PRIOMethods _pr_fileMethods = {PR_DESC_FILE,\n+                                      FileClose,\n+                                      FileRead,\n+                                      FileWrite,\n+                                      FileAvailable,\n+                                      FileAvailable64,\n+                                      FileSync,\n+                                      FileSeek,\n+                                      FileSeek64,\n+                                      FileGetInfo,\n+                                      FileGetInfo64,\n+                                      (PRWritevFN)_PR_InvalidInt,\n+                                      (PRConnectFN)_PR_InvalidStatus,\n+                                      (PRAcceptFN)_PR_InvalidDesc,\n+                                      (PRBindFN)_PR_InvalidStatus,\n+                                      (PRListenFN)_PR_InvalidStatus,\n+                                      (PRShutdownFN)_PR_InvalidStatus,\n+                                      (PRRecvFN)_PR_InvalidInt,\n+                                      (PRSendFN)_PR_InvalidInt,\n+                                      (PRRecvfromFN)_PR_InvalidInt,\n+                                      (PRSendtoFN)_PR_InvalidInt,\n+                                      FilePoll,\n+                                      (PRAcceptreadFN)_PR_InvalidInt,\n+                                      (PRTransmitfileFN)_PR_InvalidInt,\n+                                      (PRGetsocknameFN)_PR_InvalidStatus,\n+                                      (PRGetpeernameFN)_PR_InvalidStatus,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRGetsocketoptionFN)_PR_InvalidStatus,\n+                                      (PRSetsocketoptionFN)_PR_InvalidStatus,\n+                                      (PRSendfileFN)_PR_InvalidInt,\n+                                      (PRConnectcontinueFN)_PR_InvalidStatus,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRReservedFN)_PR_InvalidInt};\n+\n+PR_IMPLEMENT(const PRIOMethods*) PR_GetFileMethods(void) {\n+  return &_pr_fileMethods;\n+}\n+\n+static PRIOMethods _pr_pipeMethods = {PR_DESC_PIPE,\n+                                      FileClose,\n+                                      FileRead,\n+                                      FileWrite,\n+                                      PipeAvailable,\n+                                      PipeAvailable64,\n+                                      PipeSync,\n+                                      (PRSeekFN)_PR_InvalidInt,\n+                                      (PRSeek64FN)_PR_InvalidInt64,\n+                                      (PRFileInfoFN)_PR_InvalidStatus,\n+                                      (PRFileInfo64FN)_PR_InvalidStatus,\n+                                      (PRWritevFN)_PR_InvalidInt,\n+                                      (PRConnectFN)_PR_InvalidStatus,\n+                                      (PRAcceptFN)_PR_InvalidDesc,\n+                                      (PRBindFN)_PR_InvalidStatus,\n+                                      (PRListenFN)_PR_InvalidStatus,\n+                                      (PRShutdownFN)_PR_InvalidStatus,\n+                                      (PRRecvFN)_PR_InvalidInt,\n+                                      (PRSendFN)_PR_InvalidInt,\n+                                      (PRRecvfromFN)_PR_InvalidInt,\n+                                      (PRSendtoFN)_PR_InvalidInt,\n+                                      FilePoll,\n+                                      (PRAcceptreadFN)_PR_InvalidInt,\n+                                      (PRTransmitfileFN)_PR_InvalidInt,\n+                                      (PRGetsocknameFN)_PR_InvalidStatus,\n+                                      (PRGetpeernameFN)_PR_InvalidStatus,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRGetsocketoptionFN)_PR_InvalidStatus,\n+                                      (PRSetsocketoptionFN)_PR_InvalidStatus,\n+                                      (PRSendfileFN)_PR_InvalidInt,\n+                                      (PRConnectcontinueFN)_PR_InvalidStatus,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRReservedFN)_PR_InvalidInt};\n+\n+PR_IMPLEMENT(const PRIOMethods*) PR_GetPipeMethods(void) {\n+  return &_pr_pipeMethods;\n+}\n+\n+PR_IMPLEMENT(PRFileDesc*) PR_Open(const char* name, PRIntn flags, PRIntn mode) {\n+  PROsfd osfd;\n+  PRFileDesc* fd = 0;\n #if !defined(_PR_HAVE_O_APPEND)\n-    PRBool appendMode = (PR_APPEND & flags) ? PR_TRUE : PR_FALSE;\n+  PRBool appendMode = (PR_APPEND & flags) ? PR_TRUE : PR_FALSE;\n #endif\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    /* Map pr open flags and mode to os specific flags */\n+  /* Map pr open flags and mode to os specific flags */\n \n-    osfd = _PR_MD_OPEN(name, flags, mode);\n-    if (osfd != -1) {\n-        fd = PR_AllocFileDesc(osfd, &_pr_fileMethods);\n-        if (!fd) {\n-            (void)_PR_MD_CLOSE_FILE(osfd);\n-        } else {\n+  osfd = _PR_MD_OPEN(name, flags, mode);\n+  if (osfd != -1) {\n+    fd = PR_AllocFileDesc(osfd, &_pr_fileMethods);\n+    if (!fd) {\n+      (void)_PR_MD_CLOSE_FILE(osfd);\n+    } else {\n #if !defined(_PR_HAVE_O_APPEND)\n-            fd->secret->appendMode = appendMode;\n+      fd->secret->appendMode = appendMode;\n #endif\n-            _PR_MD_INIT_FD_INHERITABLE(fd, PR_FALSE);\n-        }\n+      _PR_MD_INIT_FD_INHERITABLE(fd, PR_FALSE);\n     }\n-    return fd;\n+  }\n+  return fd;\n }\n \n PR_IMPLEMENT(PRFileDesc*)\n-PR_OpenFile(const char* name, PRIntn flags, PRIntn mode)\n-{\n-    PROsfd osfd;\n-    PRFileDesc* fd = 0;\n+PR_OpenFile(const char* name, PRIntn flags, PRIntn mode) {\n+  PROsfd osfd;\n+  PRFileDesc* fd = 0;\n #if !defined(_PR_HAVE_O_APPEND)\n-    PRBool appendMode = (PR_APPEND & flags) ? PR_TRUE : PR_FALSE;\n+  PRBool appendMode = (PR_APPEND & flags) ? PR_TRUE : PR_FALSE;\n #endif\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    /* Map pr open flags and mode to os specific flags */\n+  /* Map pr open flags and mode to os specific flags */\n \n-    osfd = _PR_MD_OPEN_FILE(name, flags, mode);\n-    if (osfd != -1) {\n-        fd = PR_AllocFileDesc(osfd, &_pr_fileMethods);\n-        if (!fd) {\n-            (void)_PR_MD_CLOSE_FILE(osfd);\n-        } else {\n+  osfd = _PR_MD_OPEN_FILE(name, flags, mode);\n+  if (osfd != -1) {\n+    fd = PR_AllocFileDesc(osfd, &_pr_fileMethods);\n+    if (!fd) {\n+      (void)_PR_MD_CLOSE_FILE(osfd);\n+    } else {\n #if !defined(_PR_HAVE_O_APPEND)\n-            fd->secret->appendMode = appendMode;\n+      fd->secret->appendMode = appendMode;\n #endif\n-            _PR_MD_INIT_FD_INHERITABLE(fd, PR_FALSE);\n-        }\n+      _PR_MD_INIT_FD_INHERITABLE(fd, PR_FALSE);\n     }\n-    return fd;\n+  }\n+  return fd;\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_GetSysfdTableMax(void)\n-{\n+PR_IMPLEMENT(PRInt32) PR_GetSysfdTableMax(void) {\n #if defined(XP_UNIX) && !defined(AIX) && !defined(QNX)\n-    struct rlimit rlim;\n+  struct rlimit rlim;\n \n-    if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {\n-        /* XXX need to call PR_SetError() */\n-        return -1;\n-    }\n+  if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {\n+    /* XXX need to call PR_SetError() */\n+    return -1;\n+  }\n \n-    return rlim.rlim_max;\n+  return rlim.rlim_max;\n #elif defined(AIX) || defined(QNX)\n-    return sysconf(_SC_OPEN_MAX);\n+  return sysconf(_SC_OPEN_MAX);\n #elif defined(WIN32)\n-    /*\n-     * There is a systemwide limit of 65536 user handles.\n-     */\n-    return 16384;\n+  /*\n+   * There is a systemwide limit of 65536 user handles.\n+   */\n+  return 16384;\n #else\n-    write me;\n+  write me;\n #endif\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_SetSysfdTableSize(int table_size)\n-{\n+PR_IMPLEMENT(PRInt32) PR_SetSysfdTableSize(int table_size) {\n #if defined(XP_UNIX) && !defined(AIX) && !defined(QNX)\n-    struct rlimit rlim;\n-    PRInt32 tableMax = PR_GetSysfdTableMax();\n+  struct rlimit rlim;\n+  PRInt32 tableMax = PR_GetSysfdTableMax();\n \n-    if (tableMax < 0) {\n-        return -1;\n-    }\n+  if (tableMax < 0) {\n+    return -1;\n+  }\n \n-    if (tableMax > FD_SETSIZE) {\n-        tableMax = FD_SETSIZE;\n-    }\n+  if (tableMax > FD_SETSIZE) {\n+    tableMax = FD_SETSIZE;\n+  }\n \n-    rlim.rlim_max = tableMax;\n+  rlim.rlim_max = tableMax;\n \n-    /* Grow as much as we can; even if too big */\n-    if (rlim.rlim_max < table_size) {\n-        rlim.rlim_cur = rlim.rlim_max;\n-    } else {\n-        rlim.rlim_cur = table_size;\n-    }\n+  /* Grow as much as we can; even if too big */\n+  if (rlim.rlim_max < table_size) {\n+    rlim.rlim_cur = rlim.rlim_max;\n+  } else {\n+    rlim.rlim_cur = table_size;\n+  }\n \n-    if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) {\n-        /* XXX need to call PR_SetError() */\n-        return -1;\n-    }\n+  if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) {\n+    /* XXX need to call PR_SetError() */\n+    return -1;\n+  }\n \n-    return rlim.rlim_cur;\n+  return rlim.rlim_cur;\n #elif defined(AIX) || defined(QNX) || defined(WIN32)\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return -1;\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return -1;\n #else\n-    write me;\n+  write me;\n #endif\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Delete(const char* name)\n-{\n-    PRInt32 rv;\n+PR_IMPLEMENT(PRStatus) PR_Delete(const char* name) {\n+  PRInt32 rv;\n \n-    rv = _PR_MD_DELETE(name);\n-    if (rv < 0) {\n-        return PR_FAILURE;\n-    } else {\n-        return PR_SUCCESS;\n-    }\n+  rv = _PR_MD_DELETE(name);\n+  if (rv < 0) {\n+    return PR_FAILURE;\n+  } else {\n+    return PR_SUCCESS;\n+  }\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_GetFileInfo(const char* fn, PRFileInfo* info)\n-{\n-    PRInt32 rv;\n+PR_IMPLEMENT(PRStatus) PR_GetFileInfo(const char* fn, PRFileInfo* info) {\n+  PRInt32 rv;\n \n-    rv = _PR_MD_GETFILEINFO(fn, info);\n-    if (rv < 0) {\n-        return PR_FAILURE;\n-    } else {\n-        return PR_SUCCESS;\n-    }\n+  rv = _PR_MD_GETFILEINFO(fn, info);\n+  if (rv < 0) {\n+    return PR_FAILURE;\n+  } else {\n+    return PR_SUCCESS;\n+  }\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_GetFileInfo64(const char* fn, PRFileInfo64* info)\n-{\n-    PRInt32 rv;\n+PR_IMPLEMENT(PRStatus) PR_GetFileInfo64(const char* fn, PRFileInfo64* info) {\n+  PRInt32 rv;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    rv = _PR_MD_GETFILEINFO64(fn, info);\n-    if (rv < 0) {\n-        return PR_FAILURE;\n-    } else {\n-        return PR_SUCCESS;\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  rv = _PR_MD_GETFILEINFO64(fn, info);\n+  if (rv < 0) {\n+    return PR_FAILURE;\n+  } else {\n+    return PR_SUCCESS;\n+  }\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Rename(const char* from, const char* to)\n-{\n-    PRInt32 rv;\n+PR_IMPLEMENT(PRStatus) PR_Rename(const char* from, const char* to) {\n+  PRInt32 rv;\n \n-    rv = _PR_MD_RENAME(from, to);\n-    if (rv < 0) {\n-        return PR_FAILURE;\n-    } else {\n-        return PR_SUCCESS;\n-    }\n+  rv = _PR_MD_RENAME(from, to);\n+  if (rv < 0) {\n+    return PR_FAILURE;\n+  } else {\n+    return PR_SUCCESS;\n+  }\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Access(const char* name, PRAccessHow how)\n-{\n-    PRInt32 rv;\n+PR_IMPLEMENT(PRStatus) PR_Access(const char* name, PRAccessHow how) {\n+  PRInt32 rv;\n \n-    rv = _PR_MD_ACCESS(name, how);\n-    if (rv < 0) {\n-        return PR_FAILURE;\n-    } else {\n-        return PR_SUCCESS;\n-    }\n+  rv = _PR_MD_ACCESS(name, how);\n+  if (rv < 0) {\n+    return PR_FAILURE;\n+  } else {\n+    return PR_SUCCESS;\n+  }\n }\n \n /*\n ** Import an existing OS file to NSPR\n */\n-PR_IMPLEMENT(PRFileDesc*)\n-PR_ImportFile(PROsfd osfd)\n-{\n-    PRFileDesc* fd = NULL;\n+PR_IMPLEMENT(PRFileDesc*) PR_ImportFile(PROsfd osfd) {\n+  PRFileDesc* fd = NULL;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    fd = PR_AllocFileDesc(osfd, &_pr_fileMethods);\n-    if (!fd) {\n-        (void)_PR_MD_CLOSE_FILE(osfd);\n-    } else {\n-        _PR_MD_INIT_FD_INHERITABLE(fd, PR_TRUE);\n-    }\n+  fd = PR_AllocFileDesc(osfd, &_pr_fileMethods);\n+  if (!fd) {\n+    (void)_PR_MD_CLOSE_FILE(osfd);\n+  } else {\n+    _PR_MD_INIT_FD_INHERITABLE(fd, PR_TRUE);\n+  }\n \n-    return fd;\n+  return fd;\n }\n \n /*\n ** Import an existing OS pipe to NSPR\n */\n-PR_IMPLEMENT(PRFileDesc*)\n-PR_ImportPipe(PROsfd osfd)\n-{\n-    PRFileDesc* fd = NULL;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    fd = PR_AllocFileDesc(osfd, &_pr_pipeMethods);\n-    if (!fd) {\n-        (void)_PR_MD_CLOSE_FILE(osfd);\n-    } else {\n-        _PR_MD_INIT_FD_INHERITABLE(fd, PR_TRUE);\n+PR_IMPLEMENT(PRFileDesc*) PR_ImportPipe(PROsfd osfd) {\n+  PRFileDesc* fd = NULL;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  fd = PR_AllocFileDesc(osfd, &_pr_pipeMethods);\n+  if (!fd) {\n+    (void)_PR_MD_CLOSE_FILE(osfd);\n+  } else {\n+    _PR_MD_INIT_FD_INHERITABLE(fd, PR_TRUE);\n #ifdef WINNT\n-        fd->secret->md.sync_file_io = PR_TRUE;\n+    fd->secret->md.sync_file_io = PR_TRUE;\n #endif\n-    }\n+  }\n \n-    return fd;\n+  return fd;\n }\n \n #ifndef NO_NSPR_10_SUPPORT\n@@ -593,215 +539,204 @@ PR_ImportPipe(PROsfd osfd)\n  *\n  * -- wtc, 2/14/97.\n  */\n-PR_IMPLEMENT(PRInt32)\n-PR_Stat(const char* name, struct stat* buf)\n-{\n-    PRInt32 rv;\n+PR_IMPLEMENT(PRInt32) PR_Stat(const char* name, struct stat* buf) {\n+  PRInt32 rv;\n \n-    rv = _PR_MD_STAT(name, buf);\n-    return rv;\n+  rv = _PR_MD_STAT(name, buf);\n+  return rv;\n }\n \n #endif /* ! NO_NSPR_10_SUPPORT */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_LockFile(PRFileDesc* fd)\n-{\n-    PRStatus status = PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_LockFile(PRFileDesc* fd) {\n+  PRStatus status = PR_SUCCESS;\n \n #ifdef WINNT\n-    if (!fd->secret->md.io_model_committed) {\n-        PRInt32 rv;\n-        rv = _md_Associate((HANDLE)fd->secret->md.osfd);\n-        PR_ASSERT(0 != rv);\n-        fd->secret->md.io_model_committed = PR_TRUE;\n-    }\n+  if (!fd->secret->md.io_model_committed) {\n+    PRInt32 rv;\n+    rv = _md_Associate((HANDLE)fd->secret->md.osfd);\n+    PR_ASSERT(0 != rv);\n+    fd->secret->md.io_model_committed = PR_TRUE;\n+  }\n #endif\n \n-    PR_Lock(_pr_flock_lock);\n-    while (fd->secret->lockCount == -1) {\n-        PR_WaitCondVar(_pr_flock_cv, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    if (fd->secret->lockCount == 0) {\n-        fd->secret->lockCount = -1;\n-        PR_Unlock(_pr_flock_lock);\n-        status = _PR_MD_LOCKFILE(fd->secret->md.osfd);\n-        PR_Lock(_pr_flock_lock);\n-        fd->secret->lockCount = (status == PR_SUCCESS) ? 1 : 0;\n-        PR_NotifyAllCondVar(_pr_flock_cv);\n-    } else {\n-        fd->secret->lockCount++;\n-    }\n+  PR_Lock(_pr_flock_lock);\n+  while (fd->secret->lockCount == -1) {\n+    PR_WaitCondVar(_pr_flock_cv, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  if (fd->secret->lockCount == 0) {\n+    fd->secret->lockCount = -1;\n     PR_Unlock(_pr_flock_lock);\n+    status = _PR_MD_LOCKFILE(fd->secret->md.osfd);\n+    PR_Lock(_pr_flock_lock);\n+    fd->secret->lockCount = (status == PR_SUCCESS) ? 1 : 0;\n+    PR_NotifyAllCondVar(_pr_flock_cv);\n+  } else {\n+    fd->secret->lockCount++;\n+  }\n+  PR_Unlock(_pr_flock_lock);\n \n-    return status;\n+  return status;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_TLockFile(PRFileDesc* fd)\n-{\n-    PRStatus status = PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_TLockFile(PRFileDesc* fd) {\n+  PRStatus status = PR_SUCCESS;\n \n #ifdef WINNT\n-    if (!fd->secret->md.io_model_committed) {\n-        PRInt32 rv;\n-        rv = _md_Associate((HANDLE)fd->secret->md.osfd);\n-        PR_ASSERT(0 != rv);\n-        fd->secret->md.io_model_committed = PR_TRUE;\n-    }\n+  if (!fd->secret->md.io_model_committed) {\n+    PRInt32 rv;\n+    rv = _md_Associate((HANDLE)fd->secret->md.osfd);\n+    PR_ASSERT(0 != rv);\n+    fd->secret->md.io_model_committed = PR_TRUE;\n+  }\n #endif\n \n-    PR_Lock(_pr_flock_lock);\n-    if (fd->secret->lockCount == 0) {\n-        status = _PR_MD_TLOCKFILE(fd->secret->md.osfd);\n-        PR_ASSERT(status == PR_SUCCESS || fd->secret->lockCount == 0);\n-        if (status == PR_SUCCESS) {\n-            fd->secret->lockCount = 1;\n-        }\n-    } else {\n-        fd->secret->lockCount++;\n+  PR_Lock(_pr_flock_lock);\n+  if (fd->secret->lockCount == 0) {\n+    status = _PR_MD_TLOCKFILE(fd->secret->md.osfd);\n+    PR_ASSERT(status == PR_SUCCESS || fd->secret->lockCount == 0);\n+    if (status == PR_SUCCESS) {\n+      fd->secret->lockCount = 1;\n     }\n-    PR_Unlock(_pr_flock_lock);\n+  } else {\n+    fd->secret->lockCount++;\n+  }\n+  PR_Unlock(_pr_flock_lock);\n \n-    return status;\n+  return status;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_UnlockFile(PRFileDesc* fd)\n-{\n-    PRStatus rv = PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_UnlockFile(PRFileDesc* fd) {\n+  PRStatus rv = PR_SUCCESS;\n \n-    PR_Lock(_pr_flock_lock);\n-    if (fd->secret->lockCount == 1) {\n-        rv = _PR_MD_UNLOCKFILE(fd->secret->md.osfd);\n-        if (rv == PR_SUCCESS) {\n-            fd->secret->lockCount = 0;\n-        }\n-    } else {\n-        fd->secret->lockCount--;\n+  PR_Lock(_pr_flock_lock);\n+  if (fd->secret->lockCount == 1) {\n+    rv = _PR_MD_UNLOCKFILE(fd->secret->md.osfd);\n+    if (rv == PR_SUCCESS) {\n+      fd->secret->lockCount = 0;\n     }\n-    PR_Unlock(_pr_flock_lock);\n+  } else {\n+    fd->secret->lockCount--;\n+  }\n+  PR_Unlock(_pr_flock_lock);\n \n-    return rv;\n+  return rv;\n }\n \n PR_IMPLEMENT(PRStatus)\n-PR_CreatePipe(PRFileDesc** readPipe, PRFileDesc** writePipe)\n-{\n+PR_CreatePipe(PRFileDesc** readPipe, PRFileDesc** writePipe) {\n #if defined(WIN32) && !defined(WINCE)\n-    HANDLE readEnd, writeEnd;\n-    SECURITY_ATTRIBUTES pipeAttributes;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    ZeroMemory(&pipeAttributes, sizeof(pipeAttributes));\n-    pipeAttributes.nLength = sizeof(pipeAttributes);\n-    pipeAttributes.bInheritHandle = TRUE;\n-    if (CreatePipe(&readEnd, &writeEnd, &pipeAttributes, 0) == 0) {\n-        PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n-        return PR_FAILURE;\n-    }\n-    *readPipe = PR_AllocFileDesc((PROsfd)readEnd, &_pr_pipeMethods);\n-    if (NULL == *readPipe) {\n-        CloseHandle(readEnd);\n-        CloseHandle(writeEnd);\n-        return PR_FAILURE;\n-    }\n-    *writePipe = PR_AllocFileDesc((PROsfd)writeEnd, &_pr_pipeMethods);\n-    if (NULL == *writePipe) {\n-        PR_Close(*readPipe);\n-        CloseHandle(writeEnd);\n-        return PR_FAILURE;\n-    }\n-#ifdef WINNT\n-    (*readPipe)->secret->md.sync_file_io = PR_TRUE;\n-    (*writePipe)->secret->md.sync_file_io = PR_TRUE;\n-#endif\n-    (*readPipe)->secret->inheritable = _PR_TRI_TRUE;\n-    (*writePipe)->secret->inheritable = _PR_TRI_TRUE;\n-    return PR_SUCCESS;\n+  HANDLE readEnd, writeEnd;\n+  SECURITY_ATTRIBUTES pipeAttributes;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  ZeroMemory(&pipeAttributes, sizeof(pipeAttributes));\n+  pipeAttributes.nLength = sizeof(pipeAttributes);\n+  pipeAttributes.bInheritHandle = TRUE;\n+  if (CreatePipe(&readEnd, &writeEnd, &pipeAttributes, 0) == 0) {\n+    PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n+    return PR_FAILURE;\n+  }\n+  *readPipe = PR_AllocFileDesc((PROsfd)readEnd, &_pr_pipeMethods);\n+  if (NULL == *readPipe) {\n+    CloseHandle(readEnd);\n+    CloseHandle(writeEnd);\n+    return PR_FAILURE;\n+  }\n+  *writePipe = PR_AllocFileDesc((PROsfd)writeEnd, &_pr_pipeMethods);\n+  if (NULL == *writePipe) {\n+    PR_Close(*readPipe);\n+    CloseHandle(writeEnd);\n+    return PR_FAILURE;\n+  }\n+#  ifdef WINNT\n+  (*readPipe)->secret->md.sync_file_io = PR_TRUE;\n+  (*writePipe)->secret->md.sync_file_io = PR_TRUE;\n+#  endif\n+  (*readPipe)->secret->inheritable = _PR_TRI_TRUE;\n+  (*writePipe)->secret->inheritable = _PR_TRI_TRUE;\n+  return PR_SUCCESS;\n #elif defined(XP_UNIX)\n-    int pipefd[2];\n+  int pipefd[2];\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    if (pipe(pipefd) == -1) {\n-        /* XXX map pipe error */\n-        PR_SetError(PR_UNKNOWN_ERROR, errno);\n-        return PR_FAILURE;\n-    }\n-    *readPipe = PR_AllocFileDesc(pipefd[0], &_pr_pipeMethods);\n-    if (NULL == *readPipe) {\n-        close(pipefd[0]);\n-        close(pipefd[1]);\n-        return PR_FAILURE;\n-    }\n-    *writePipe = PR_AllocFileDesc(pipefd[1], &_pr_pipeMethods);\n-    if (NULL == *writePipe) {\n-        PR_Close(*readPipe);\n-        close(pipefd[1]);\n-        return PR_FAILURE;\n-    }\n-    _PR_MD_MAKE_NONBLOCK(*readPipe);\n-    _PR_MD_INIT_FD_INHERITABLE(*readPipe, PR_FALSE);\n-    _PR_MD_MAKE_NONBLOCK(*writePipe);\n-    _PR_MD_INIT_FD_INHERITABLE(*writePipe, PR_FALSE);\n-    return PR_SUCCESS;\n-#else\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  if (pipe(pipefd) == -1) {\n+    /* XXX map pipe error */\n+    PR_SetError(PR_UNKNOWN_ERROR, errno);\n     return PR_FAILURE;\n+  }\n+  *readPipe = PR_AllocFileDesc(pipefd[0], &_pr_pipeMethods);\n+  if (NULL == *readPipe) {\n+    close(pipefd[0]);\n+    close(pipefd[1]);\n+    return PR_FAILURE;\n+  }\n+  *writePipe = PR_AllocFileDesc(pipefd[1], &_pr_pipeMethods);\n+  if (NULL == *writePipe) {\n+    PR_Close(*readPipe);\n+    close(pipefd[1]);\n+    return PR_FAILURE;\n+  }\n+  _PR_MD_MAKE_NONBLOCK(*readPipe);\n+  _PR_MD_INIT_FD_INHERITABLE(*readPipe, PR_FALSE);\n+  _PR_MD_MAKE_NONBLOCK(*writePipe);\n+  _PR_MD_INIT_FD_INHERITABLE(*writePipe, PR_FALSE);\n+  return PR_SUCCESS;\n+#else\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n #endif\n }\n \n #ifdef MOZ_UNICODE\n /* ================ UTF16 Interfaces ================================ */\n PR_IMPLEMENT(PRFileDesc*)\n-PR_OpenFileUTF16(const PRUnichar* name, PRIntn flags, PRIntn mode)\n-{\n-    PROsfd osfd;\n-    PRFileDesc* fd = 0;\n-#if !defined(_PR_HAVE_O_APPEND)\n-    PRBool appendMode = (PR_APPEND & flags) ? PR_TRUE : PR_FALSE;\n-#endif\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    /* Map pr open flags and mode to os specific flags */\n-    osfd = _PR_MD_OPEN_FILE_UTF16(name, flags, mode);\n-    if (osfd != -1) {\n-        fd = PR_AllocFileDesc(osfd, &_pr_fileMethods);\n-        if (!fd) {\n-            (void)_PR_MD_CLOSE_FILE(osfd);\n-        } else {\n-#if !defined(_PR_HAVE_O_APPEND)\n-            fd->secret->appendMode = appendMode;\n-#endif\n-            _PR_MD_INIT_FD_INHERITABLE(fd, PR_FALSE);\n-        }\n+PR_OpenFileUTF16(const PRUnichar* name, PRIntn flags, PRIntn mode) {\n+  PROsfd osfd;\n+  PRFileDesc* fd = 0;\n+#  if !defined(_PR_HAVE_O_APPEND)\n+  PRBool appendMode = (PR_APPEND & flags) ? PR_TRUE : PR_FALSE;\n+#  endif\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  /* Map pr open flags and mode to os specific flags */\n+  osfd = _PR_MD_OPEN_FILE_UTF16(name, flags, mode);\n+  if (osfd != -1) {\n+    fd = PR_AllocFileDesc(osfd, &_pr_fileMethods);\n+    if (!fd) {\n+      (void)_PR_MD_CLOSE_FILE(osfd);\n+    } else {\n+#  if !defined(_PR_HAVE_O_APPEND)\n+      fd->secret->appendMode = appendMode;\n+#  endif\n+      _PR_MD_INIT_FD_INHERITABLE(fd, PR_FALSE);\n     }\n-    return fd;\n+  }\n+  return fd;\n }\n \n PR_IMPLEMENT(PRStatus)\n-PR_GetFileInfo64UTF16(const PRUnichar* fn, PRFileInfo64* info)\n-{\n-    PRInt32 rv;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    rv = _PR_MD_GETFILEINFO64_UTF16(fn, info);\n-    if (rv < 0) {\n-        return PR_FAILURE;\n-    } else {\n-        return PR_SUCCESS;\n-    }\n+PR_GetFileInfo64UTF16(const PRUnichar* fn, PRFileInfo64* info) {\n+  PRInt32 rv;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  rv = _PR_MD_GETFILEINFO64_UTF16(fn, info);\n+  if (rv < 0) {\n+    return PR_FAILURE;\n+  } else {\n+    return PR_SUCCESS;\n+  }\n }\n \n /* ================ UTF16 Interfaces ================================ */\ndiff --git a/nspr/pr/src/io/prio.c b/nspr/pr/src/io/prio.c\nindex 01855c6..0223689 100644\n--- a/nspr/pr/src/io/prio.c\n+++ b/nspr/pr/src/io/prio.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -16,134 +17,123 @@ PRCondVar* _pr_flock_cv;\n  * There are no stdin, stdout, stderr in Windows CE.  INVALID_HANDLE_VALUE\n  * should cause all I/O functions on the handle to fail.\n  */\n-#define STD_INPUT_HANDLE ((DWORD) - 10)\n-#define STD_OUTPUT_HANDLE ((DWORD) - 11)\n-#define STD_ERROR_HANDLE ((DWORD) - 12)\n-\n-static HANDLE\n-GetStdHandle(DWORD nStdHandle)\n-{\n-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);\n-    return INVALID_HANDLE_VALUE;\n+#  define STD_INPUT_HANDLE ((DWORD) - 10)\n+#  define STD_OUTPUT_HANDLE ((DWORD) - 11)\n+#  define STD_ERROR_HANDLE ((DWORD) - 12)\n+\n+static HANDLE GetStdHandle(DWORD nStdHandle) {\n+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);\n+  return INVALID_HANDLE_VALUE;\n }\n #endif\n \n-void\n-_PR_InitIO(void)\n-{\n-    const PRIOMethods* methods = PR_GetFileMethods();\n+void _PR_InitIO(void) {\n+  const PRIOMethods* methods = PR_GetFileMethods();\n \n-    _PR_InitFdCache();\n+  _PR_InitFdCache();\n \n-    _pr_flock_lock = PR_NewLock();\n-    _pr_flock_cv = PR_NewCondVar(_pr_flock_lock);\n+  _pr_flock_lock = PR_NewLock();\n+  _pr_flock_cv = PR_NewCondVar(_pr_flock_lock);\n \n #ifdef WIN32\n-    _pr_stdin = PR_AllocFileDesc((PROsfd)GetStdHandle(STD_INPUT_HANDLE), methods);\n-    _pr_stdout =\n-        PR_AllocFileDesc((PROsfd)GetStdHandle(STD_OUTPUT_HANDLE), methods);\n-    _pr_stderr =\n-        PR_AllocFileDesc((PROsfd)GetStdHandle(STD_ERROR_HANDLE), methods);\n-#ifdef WINNT\n-    _pr_stdin->secret->md.sync_file_io = PR_TRUE;\n-    _pr_stdout->secret->md.sync_file_io = PR_TRUE;\n-    _pr_stderr->secret->md.sync_file_io = PR_TRUE;\n-#endif\n+  _pr_stdin = PR_AllocFileDesc((PROsfd)GetStdHandle(STD_INPUT_HANDLE), methods);\n+  _pr_stdout =\n+      PR_AllocFileDesc((PROsfd)GetStdHandle(STD_OUTPUT_HANDLE), methods);\n+  _pr_stderr =\n+      PR_AllocFileDesc((PROsfd)GetStdHandle(STD_ERROR_HANDLE), methods);\n+#  ifdef WINNT\n+  _pr_stdin->secret->md.sync_file_io = PR_TRUE;\n+  _pr_stdout->secret->md.sync_file_io = PR_TRUE;\n+  _pr_stderr->secret->md.sync_file_io = PR_TRUE;\n+#  endif\n #else\n-    _pr_stdin = PR_AllocFileDesc(0, methods);\n-    _pr_stdout = PR_AllocFileDesc(1, methods);\n-    _pr_stderr = PR_AllocFileDesc(2, methods);\n+  _pr_stdin = PR_AllocFileDesc(0, methods);\n+  _pr_stdout = PR_AllocFileDesc(1, methods);\n+  _pr_stderr = PR_AllocFileDesc(2, methods);\n #endif\n-    _PR_MD_INIT_FD_INHERITABLE(_pr_stdin, PR_TRUE);\n-    _PR_MD_INIT_FD_INHERITABLE(_pr_stdout, PR_TRUE);\n-    _PR_MD_INIT_FD_INHERITABLE(_pr_stderr, PR_TRUE);\n+  _PR_MD_INIT_FD_INHERITABLE(_pr_stdin, PR_TRUE);\n+  _PR_MD_INIT_FD_INHERITABLE(_pr_stdout, PR_TRUE);\n+  _PR_MD_INIT_FD_INHERITABLE(_pr_stderr, PR_TRUE);\n \n-    _PR_MD_INIT_IO();\n+  _PR_MD_INIT_IO();\n }\n \n-void\n-_PR_CleanupIO(void)\n-{\n-    PR_FreeFileDesc(_pr_stdin);\n-    _pr_stdin = NULL;\n-    PR_FreeFileDesc(_pr_stdout);\n-    _pr_stdout = NULL;\n-    PR_FreeFileDesc(_pr_stderr);\n-    _pr_stderr = NULL;\n-\n-    if (_pr_flock_cv) {\n-        PR_DestroyCondVar(_pr_flock_cv);\n-        _pr_flock_cv = NULL;\n-    }\n-    if (_pr_flock_lock) {\n-        PR_DestroyLock(_pr_flock_lock);\n-        _pr_flock_lock = NULL;\n-    }\n-\n-    _PR_CleanupFdCache();\n+void _PR_CleanupIO(void) {\n+  PR_FreeFileDesc(_pr_stdin);\n+  _pr_stdin = NULL;\n+  PR_FreeFileDesc(_pr_stdout);\n+  _pr_stdout = NULL;\n+  PR_FreeFileDesc(_pr_stderr);\n+  _pr_stderr = NULL;\n+\n+  if (_pr_flock_cv) {\n+    PR_DestroyCondVar(_pr_flock_cv);\n+    _pr_flock_cv = NULL;\n+  }\n+  if (_pr_flock_lock) {\n+    PR_DestroyLock(_pr_flock_lock);\n+    _pr_flock_lock = NULL;\n+  }\n+\n+  _PR_CleanupFdCache();\n }\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_GetSpecialFD(PRSpecialFD osfd)\n-{\n-    PRFileDesc* result = NULL;\n-    PR_ASSERT((int)osfd >= PR_StandardInput && osfd <= PR_StandardError);\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    switch (osfd) {\n-        case PR_StandardInput:\n-            result = _pr_stdin;\n-            break;\n-        case PR_StandardOutput:\n-            result = _pr_stdout;\n-            break;\n-        case PR_StandardError:\n-            result = _pr_stderr;\n-            break;\n-        default:\n-            (void)PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-    }\n-    return result;\n+PR_IMPLEMENT(PRFileDesc*) PR_GetSpecialFD(PRSpecialFD osfd) {\n+  PRFileDesc* result = NULL;\n+  PR_ASSERT((int)osfd >= PR_StandardInput && osfd <= PR_StandardError);\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  switch (osfd) {\n+    case PR_StandardInput:\n+      result = _pr_stdin;\n+      break;\n+    case PR_StandardOutput:\n+      result = _pr_stdout;\n+      break;\n+    case PR_StandardError:\n+      result = _pr_stderr;\n+      break;\n+    default:\n+      (void)PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  }\n+  return result;\n }\n \n PR_IMPLEMENT(PRFileDesc*)\n-PR_AllocFileDesc(PROsfd osfd, const PRIOMethods* methods)\n-{\n-    PRFileDesc* fd;\n+PR_AllocFileDesc(PROsfd osfd, const PRIOMethods* methods) {\n+  PRFileDesc* fd;\n \n #ifdef XP_UNIX\n-    /*\n-     * Assert that the file descriptor is small enough to fit in the\n-     * fd_set passed to select\n-     */\n-    PR_ASSERT(osfd < FD_SETSIZE);\n+  /*\n+   * Assert that the file descriptor is small enough to fit in the\n+   * fd_set passed to select\n+   */\n+  PR_ASSERT(osfd < FD_SETSIZE);\n #endif\n-    fd = _PR_Getfd();\n-    if (fd) {\n-        /* Initialize the members of PRFileDesc and PRFilePrivate */\n-        fd->methods = methods;\n-        fd->secret->state = _PR_FILEDESC_OPEN;\n-        fd->secret->md.osfd = osfd;\n+  fd = _PR_Getfd();\n+  if (fd) {\n+    /* Initialize the members of PRFileDesc and PRFilePrivate */\n+    fd->methods = methods;\n+    fd->secret->state = _PR_FILEDESC_OPEN;\n+    fd->secret->md.osfd = osfd;\n #if defined(_WIN64)\n-        fd->secret->alreadyConnected = PR_FALSE;\n-        fd->secret->overlappedActive = PR_FALSE;\n+    fd->secret->alreadyConnected = PR_FALSE;\n+    fd->secret->overlappedActive = PR_FALSE;\n #endif\n-        _PR_MD_INIT_FILEDESC(fd);\n-    } else {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-    }\n+    _PR_MD_INIT_FILEDESC(fd);\n+  } else {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  }\n \n-    return fd;\n+  return fd;\n }\n \n-PR_IMPLEMENT(void)\n-PR_FreeFileDesc(PRFileDesc* fd)\n-{\n-    PR_ASSERT(fd);\n-    _PR_Putfd(fd);\n+PR_IMPLEMENT(void) PR_FreeFileDesc(PRFileDesc* fd) {\n+  PR_ASSERT(fd);\n+  _PR_Putfd(fd);\n }\n \n #if defined(_WIN64) && defined(WIN95)\n@@ -151,68 +141,66 @@ PR_FreeFileDesc(PRFileDesc* fd)\n PRFileDescList* _fd_waiting_for_overlapped_done = NULL;\n PRLock* _fd_waiting_for_overlapped_done_lock = NULL;\n \n-void\n-CheckOverlappedPendingSocketsAreDone()\n-{\n-    if (!_fd_waiting_for_overlapped_done_lock ||\n-        !_fd_waiting_for_overlapped_done) {\n-        return;\n+void CheckOverlappedPendingSocketsAreDone() {\n+  if (!_fd_waiting_for_overlapped_done_lock ||\n+      !_fd_waiting_for_overlapped_done) {\n+    return;\n+  }\n+\n+  PR_Lock(_fd_waiting_for_overlapped_done_lock);\n+\n+  PRFileDescList* cur = _fd_waiting_for_overlapped_done;\n+  PRFileDescList* previous = NULL;\n+  while (cur) {\n+    PR_ASSERT(cur->fd->secret->overlappedActive);\n+    PRFileDesc* fd = cur->fd;\n+    DWORD rvSent;\n+    if (GetOverlappedResult((HANDLE)fd->secret->md.osfd, &fd->secret->ol,\n+                            &rvSent, FALSE) == TRUE) {\n+      fd->secret->overlappedActive = PR_FALSE;\n+      PR_LOG(_pr_io_lm, PR_LOG_MIN,\n+             (\"CheckOverlappedPendingSocketsAreDone GetOverlappedResult \"\n+              \"succeeded\\n\"));\n+    } else {\n+      DWORD err = WSAGetLastError();\n+      PR_LOG(_pr_io_lm, PR_LOG_MIN,\n+             (\"CheckOverlappedPendingSocketsAreDone GetOverlappedResult failed \"\n+              \"%d\\n\",\n+              err));\n+      if (err != ERROR_IO_INCOMPLETE) {\n+        fd->secret->overlappedActive = PR_FALSE;\n+      }\n     }\n \n-    PR_Lock(_fd_waiting_for_overlapped_done_lock);\n-\n-    PRFileDescList* cur = _fd_waiting_for_overlapped_done;\n-    PRFileDescList* previous = NULL;\n-    while (cur) {\n-        PR_ASSERT(cur->fd->secret->overlappedActive);\n-        PRFileDesc* fd = cur->fd;\n-        DWORD rvSent;\n-        if (GetOverlappedResult((HANDLE)fd->secret->md.osfd, &fd->secret->ol,\n-                                &rvSent, FALSE) == TRUE) {\n-            fd->secret->overlappedActive = PR_FALSE;\n-            PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-                   (\"CheckOverlappedPendingSocketsAreDone GetOverlappedResult \"\n-                    \"succeeded\\n\"));\n-        } else {\n-            DWORD err = WSAGetLastError();\n-            PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-                   (\"CheckOverlappedPendingSocketsAreDone GetOverlappedResult failed \"\n-                    \"%d\\n\",\n-                    err));\n-            if (err != ERROR_IO_INCOMPLETE) {\n-                fd->secret->overlappedActive = PR_FALSE;\n-            }\n-        }\n-\n-        if (!fd->secret->overlappedActive) {\n-            _PR_MD_CLOSE_SOCKET(fd->secret->md.osfd);\n-            fd->secret->state = _PR_FILEDESC_CLOSED;\n-#ifdef _PR_HAVE_PEEK_BUFFER\n-            if (fd->secret->peekBuffer) {\n-                PR_ASSERT(fd->secret->peekBufSize > 0);\n-                PR_DELETE(fd->secret->peekBuffer);\n-                fd->secret->peekBufSize = 0;\n-                fd->secret->peekBytes = 0;\n-            }\n-#endif\n-\n-            PR_FreeFileDesc(fd);\n-\n-            if (previous) {\n-                previous->next = cur->next;\n-            } else {\n-                _fd_waiting_for_overlapped_done = cur->next;\n-            }\n-            PRFileDescList* del = cur;\n-            cur = cur->next;\n-            PR_Free(del);\n-        } else {\n-            previous = cur;\n-            cur = cur->next;\n-        }\n+    if (!fd->secret->overlappedActive) {\n+      _PR_MD_CLOSE_SOCKET(fd->secret->md.osfd);\n+      fd->secret->state = _PR_FILEDESC_CLOSED;\n+#  ifdef _PR_HAVE_PEEK_BUFFER\n+      if (fd->secret->peekBuffer) {\n+        PR_ASSERT(fd->secret->peekBufSize > 0);\n+        PR_DELETE(fd->secret->peekBuffer);\n+        fd->secret->peekBufSize = 0;\n+        fd->secret->peekBytes = 0;\n+      }\n+#  endif\n+\n+      PR_FreeFileDesc(fd);\n+\n+      if (previous) {\n+        previous->next = cur->next;\n+      } else {\n+        _fd_waiting_for_overlapped_done = cur->next;\n+      }\n+      PRFileDescList* del = cur;\n+      cur = cur->next;\n+      PR_Free(del);\n+    } else {\n+      previous = cur;\n+      cur = cur->next;\n     }\n+  }\n \n-    PR_Unlock(_fd_waiting_for_overlapped_done_lock);\n+  PR_Unlock(_fd_waiting_for_overlapped_done_lock);\n }\n #endif\n \n@@ -220,41 +208,38 @@ CheckOverlappedPendingSocketsAreDone()\n ** Wait for some i/o to finish on one or more more poll descriptors.\n */\n PR_IMPLEMENT(PRInt32)\n-PR_Poll(PRPollDesc* pds, PRIntn npds, PRIntervalTime timeout)\n-{\n+PR_Poll(PRPollDesc* pds, PRIntn npds, PRIntervalTime timeout) {\n #if defined(_WIN64) && defined(WIN95)\n-    // For each iteration check if TFO overlapped IOs are down.\n-    CheckOverlappedPendingSocketsAreDone();\n+  // For each iteration check if TFO overlapped IOs are down.\n+  CheckOverlappedPendingSocketsAreDone();\n #endif\n \n-    return (_PR_MD_PR_POLL(pds, npds, timeout));\n+  return (_PR_MD_PR_POLL(pds, npds, timeout));\n }\n \n /*\n ** Set the inheritance attribute of a file descriptor.\n */\n-PR_IMPLEMENT(PRStatus)\n-PR_SetFDInheritable(PRFileDesc* fd, PRBool inheritable)\n-{\n+PR_IMPLEMENT(PRStatus) PR_SetFDInheritable(PRFileDesc* fd, PRBool inheritable) {\n #if defined(XP_UNIX) || defined(WIN32)\n-    /*\n-     * Only a non-layered, NSPR file descriptor can be inherited\n-     * by a child process.\n-     */\n-    if (fd->identity != PR_NSPR_IO_LAYER) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    if (fd->secret->inheritable != inheritable) {\n-        if (_PR_MD_SET_FD_INHERITABLE(fd, inheritable) == PR_FAILURE) {\n-            return PR_FAILURE;\n-        }\n-        fd->secret->inheritable = inheritable;\n+  /*\n+   * Only a non-layered, NSPR file descriptor can be inherited\n+   * by a child process.\n+   */\n+  if (fd->identity != PR_NSPR_IO_LAYER) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  if (fd->secret->inheritable != inheritable) {\n+    if (_PR_MD_SET_FD_INHERITABLE(fd, inheritable) == PR_FAILURE) {\n+      return PR_FAILURE;\n     }\n-    return PR_SUCCESS;\n+    fd->secret->inheritable = inheritable;\n+  }\n+  return PR_SUCCESS;\n #else\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n #endif\n }\n \n@@ -262,8 +247,6 @@ PR_SetFDInheritable(PRFileDesc* fd, PRBool inheritable)\n ** This function only has a useful implementation in the debug build of\n ** the pthreads version.\n */\n-PR_IMPLEMENT(void)\n-PT_FPrintStats(PRFileDesc* debug_out, const char* msg)\n-{\n-    /* do nothing */\n+PR_IMPLEMENT(void) PT_FPrintStats(PRFileDesc* debug_out, const char* msg) {\n+  /* do nothing */\n } /* PT_FPrintStats */\ndiff --git a/nspr/pr/src/io/priometh.c b/nspr/pr/src/io/priometh.c\nindex 3701571..0b9029b 100644\n--- a/nspr/pr/src/io/priometh.c\n+++ b/nspr/pr/src/io/priometh.c\n@@ -1,3 +1,5 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,309 +10,256 @@\n /*****************************************************************************/\n /************************** Invalid I/O method object ************************/\n /*****************************************************************************/\n-PRIOMethods _pr_faulty_methods = { (PRDescType)0,\n-                                   (PRCloseFN)_PR_InvalidStatus,\n-                                   (PRReadFN)_PR_InvalidInt,\n-                                   (PRWriteFN)_PR_InvalidInt,\n-                                   (PRAvailableFN)_PR_InvalidInt,\n-                                   (PRAvailable64FN)_PR_InvalidInt64,\n-                                   (PRFsyncFN)_PR_InvalidStatus,\n-                                   (PRSeekFN)_PR_InvalidInt,\n-                                   (PRSeek64FN)_PR_InvalidInt64,\n-                                   (PRFileInfoFN)_PR_InvalidStatus,\n-                                   (PRFileInfo64FN)_PR_InvalidStatus,\n-                                   (PRWritevFN)_PR_InvalidInt,\n-                                   (PRConnectFN)_PR_InvalidStatus,\n-                                   (PRAcceptFN)_PR_InvalidDesc,\n-                                   (PRBindFN)_PR_InvalidStatus,\n-                                   (PRListenFN)_PR_InvalidStatus,\n-                                   (PRShutdownFN)_PR_InvalidStatus,\n-                                   (PRRecvFN)_PR_InvalidInt,\n-                                   (PRSendFN)_PR_InvalidInt,\n-                                   (PRRecvfromFN)_PR_InvalidInt,\n-                                   (PRSendtoFN)_PR_InvalidInt,\n-                                   (PRPollFN)_PR_InvalidInt16,\n-                                   (PRAcceptreadFN)_PR_InvalidInt,\n-                                   (PRTransmitfileFN)_PR_InvalidInt,\n-                                   (PRGetsocknameFN)_PR_InvalidStatus,\n-                                   (PRGetpeernameFN)_PR_InvalidStatus,\n-                                   (PRReservedFN)_PR_InvalidInt,\n-                                   (PRReservedFN)_PR_InvalidInt,\n-                                   (PRGetsocketoptionFN)_PR_InvalidStatus,\n-                                   (PRSetsocketoptionFN)_PR_InvalidStatus,\n-                                   (PRSendfileFN)_PR_InvalidInt,\n-                                   (PRConnectcontinueFN)_PR_InvalidStatus,\n-                                   (PRReservedFN)_PR_InvalidInt,\n-                                   (PRReservedFN)_PR_InvalidInt,\n-                                   (PRReservedFN)_PR_InvalidInt,\n-                                   (PRReservedFN)_PR_InvalidInt };\n-\n-PRIntn\n-_PR_InvalidInt(void)\n-{\n-    PR_NOT_REACHED(\"I/O method is invalid\");\n-    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n-    return -1;\n+PRIOMethods _pr_faulty_methods = {(PRDescType)0,\n+                                  (PRCloseFN)_PR_InvalidStatus,\n+                                  (PRReadFN)_PR_InvalidInt,\n+                                  (PRWriteFN)_PR_InvalidInt,\n+                                  (PRAvailableFN)_PR_InvalidInt,\n+                                  (PRAvailable64FN)_PR_InvalidInt64,\n+                                  (PRFsyncFN)_PR_InvalidStatus,\n+                                  (PRSeekFN)_PR_InvalidInt,\n+                                  (PRSeek64FN)_PR_InvalidInt64,\n+                                  (PRFileInfoFN)_PR_InvalidStatus,\n+                                  (PRFileInfo64FN)_PR_InvalidStatus,\n+                                  (PRWritevFN)_PR_InvalidInt,\n+                                  (PRConnectFN)_PR_InvalidStatus,\n+                                  (PRAcceptFN)_PR_InvalidDesc,\n+                                  (PRBindFN)_PR_InvalidStatus,\n+                                  (PRListenFN)_PR_InvalidStatus,\n+                                  (PRShutdownFN)_PR_InvalidStatus,\n+                                  (PRRecvFN)_PR_InvalidInt,\n+                                  (PRSendFN)_PR_InvalidInt,\n+                                  (PRRecvfromFN)_PR_InvalidInt,\n+                                  (PRSendtoFN)_PR_InvalidInt,\n+                                  (PRPollFN)_PR_InvalidInt16,\n+                                  (PRAcceptreadFN)_PR_InvalidInt,\n+                                  (PRTransmitfileFN)_PR_InvalidInt,\n+                                  (PRGetsocknameFN)_PR_InvalidStatus,\n+                                  (PRGetpeernameFN)_PR_InvalidStatus,\n+                                  (PRReservedFN)_PR_InvalidInt,\n+                                  (PRReservedFN)_PR_InvalidInt,\n+                                  (PRGetsocketoptionFN)_PR_InvalidStatus,\n+                                  (PRSetsocketoptionFN)_PR_InvalidStatus,\n+                                  (PRSendfileFN)_PR_InvalidInt,\n+                                  (PRConnectcontinueFN)_PR_InvalidStatus,\n+                                  (PRReservedFN)_PR_InvalidInt,\n+                                  (PRReservedFN)_PR_InvalidInt,\n+                                  (PRReservedFN)_PR_InvalidInt,\n+                                  (PRReservedFN)_PR_InvalidInt};\n+\n+PRIntn _PR_InvalidInt(void) {\n+  PR_NOT_REACHED(\"I/O method is invalid\");\n+  PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+  return -1;\n } /* _PR_InvalidInt */\n \n-PRInt16\n-_PR_InvalidInt16(void)\n-{\n-    PR_NOT_REACHED(\"I/O method is invalid\");\n-    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n-    return -1;\n+PRInt16 _PR_InvalidInt16(void) {\n+  PR_NOT_REACHED(\"I/O method is invalid\");\n+  PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+  return -1;\n } /* _PR_InvalidInt */\n \n-PRInt64\n-_PR_InvalidInt64(void)\n-{\n-    PRInt64 rv;\n-    LL_I2L(rv, -1);\n-    PR_NOT_REACHED(\"I/O method is invalid\");\n-    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n-    return rv;\n+PRInt64 _PR_InvalidInt64(void) {\n+  PRInt64 rv;\n+  LL_I2L(rv, -1);\n+  PR_NOT_REACHED(\"I/O method is invalid\");\n+  PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+  return rv;\n } /* _PR_InvalidInt */\n \n /*\n  * An invalid method that returns PRStatus\n  */\n \n-PRStatus\n-_PR_InvalidStatus(void)\n-{\n-    PR_NOT_REACHED(\"I/O method is invalid\");\n-    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n-    return PR_FAILURE;\n+PRStatus _PR_InvalidStatus(void) {\n+  PR_NOT_REACHED(\"I/O method is invalid\");\n+  PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+  return PR_FAILURE;\n } /* _PR_InvalidDesc */\n \n /*\n  * An invalid method that returns a pointer\n  */\n \n-PRFileDesc*\n-_PR_InvalidDesc(void)\n-{\n-    PR_NOT_REACHED(\"I/O method is invalid\");\n-    PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n-    return NULL;\n+PRFileDesc* _PR_InvalidDesc(void) {\n+  PR_NOT_REACHED(\"I/O method is invalid\");\n+  PR_SetError(PR_INVALID_METHOD_ERROR, 0);\n+  return NULL;\n } /* _PR_InvalidDesc */\n \n-PR_IMPLEMENT(PRDescType)\n-PR_GetDescType(PRFileDesc* file)\n-{\n-    return file->methods->file_type;\n+PR_IMPLEMENT(PRDescType) PR_GetDescType(PRFileDesc* file) {\n+  return file->methods->file_type;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Close(PRFileDesc* fd)\n-{\n-    return (fd->methods->close)(fd);\n+PR_IMPLEMENT(PRStatus) PR_Close(PRFileDesc* fd) {\n+  return (fd->methods->close)(fd);\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_Read(PRFileDesc* fd, void* buf, PRInt32 amount)\n-{\n-    return ((fd->methods->read)(fd, buf, amount));\n+PR_IMPLEMENT(PRInt32) PR_Read(PRFileDesc* fd, void* buf, PRInt32 amount) {\n+  return ((fd->methods->read)(fd, buf, amount));\n }\n \n PR_IMPLEMENT(PRInt32)\n-PR_Write(PRFileDesc* fd, const void* buf, PRInt32 amount)\n-{\n-    return ((fd->methods->write)(fd, buf, amount));\n+PR_Write(PRFileDesc* fd, const void* buf, PRInt32 amount) {\n+  return ((fd->methods->write)(fd, buf, amount));\n }\n \n PR_IMPLEMENT(PRInt32)\n-PR_Seek(PRFileDesc* fd, PRInt32 offset, PRSeekWhence whence)\n-{\n-    return ((fd->methods->seek)(fd, offset, whence));\n+PR_Seek(PRFileDesc* fd, PRInt32 offset, PRSeekWhence whence) {\n+  return ((fd->methods->seek)(fd, offset, whence));\n }\n \n PR_IMPLEMENT(PRInt64)\n-PR_Seek64(PRFileDesc* fd, PRInt64 offset, PRSeekWhence whence)\n-{\n-    return ((fd->methods->seek64)(fd, offset, whence));\n+PR_Seek64(PRFileDesc* fd, PRInt64 offset, PRSeekWhence whence) {\n+  return ((fd->methods->seek64)(fd, offset, whence));\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_Available(PRFileDesc* fd)\n-{\n-    return ((fd->methods->available)(fd));\n+PR_IMPLEMENT(PRInt32) PR_Available(PRFileDesc* fd) {\n+  return ((fd->methods->available)(fd));\n }\n \n-PR_IMPLEMENT(PRInt64)\n-PR_Available64(PRFileDesc* fd)\n-{\n-    return ((fd->methods->available64)(fd));\n+PR_IMPLEMENT(PRInt64) PR_Available64(PRFileDesc* fd) {\n+  return ((fd->methods->available64)(fd));\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_GetOpenFileInfo(PRFileDesc* fd, PRFileInfo* info)\n-{\n-    return ((fd->methods->fileInfo)(fd, info));\n+PR_IMPLEMENT(PRStatus) PR_GetOpenFileInfo(PRFileDesc* fd, PRFileInfo* info) {\n+  return ((fd->methods->fileInfo)(fd, info));\n }\n \n PR_IMPLEMENT(PRStatus)\n-PR_GetOpenFileInfo64(PRFileDesc* fd, PRFileInfo64* info)\n-{\n-    return ((fd->methods->fileInfo64)(fd, info));\n+PR_GetOpenFileInfo64(PRFileDesc* fd, PRFileInfo64* info) {\n+  return ((fd->methods->fileInfo64)(fd, info));\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Sync(PRFileDesc* fd)\n-{\n-    return ((fd->methods->fsync)(fd));\n+PR_IMPLEMENT(PRStatus) PR_Sync(PRFileDesc* fd) {\n+  return ((fd->methods->fsync)(fd));\n }\n \n PR_IMPLEMENT(PRStatus)\n-PR_Connect(PRFileDesc* fd, const PRNetAddr* addr, PRIntervalTime timeout)\n-{\n-    return ((fd->methods->connect)(fd, addr, timeout));\n+PR_Connect(PRFileDesc* fd, const PRNetAddr* addr, PRIntervalTime timeout) {\n+  return ((fd->methods->connect)(fd, addr, timeout));\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_ConnectContinue(PRFileDesc* fd, PRInt16 out_flags)\n-{\n-    return ((fd->methods->connectcontinue)(fd, out_flags));\n+PR_IMPLEMENT(PRStatus) PR_ConnectContinue(PRFileDesc* fd, PRInt16 out_flags) {\n+  return ((fd->methods->connectcontinue)(fd, out_flags));\n }\n \n PR_IMPLEMENT(PRFileDesc*)\n-PR_Accept(PRFileDesc* fd, PRNetAddr* addr, PRIntervalTime timeout)\n-{\n-    return ((fd->methods->accept)(fd, addr, timeout));\n+PR_Accept(PRFileDesc* fd, PRNetAddr* addr, PRIntervalTime timeout) {\n+  return ((fd->methods->accept)(fd, addr, timeout));\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Bind(PRFileDesc* fd, const PRNetAddr* addr)\n-{\n-    return ((fd->methods->bind)(fd, addr));\n+PR_IMPLEMENT(PRStatus) PR_Bind(PRFileDesc* fd, const PRNetAddr* addr) {\n+  return ((fd->methods->bind)(fd, addr));\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Shutdown(PRFileDesc* fd, PRShutdownHow how)\n-{\n-    return ((fd->methods->shutdown)(fd, how));\n+PR_IMPLEMENT(PRStatus) PR_Shutdown(PRFileDesc* fd, PRShutdownHow how) {\n+  return ((fd->methods->shutdown)(fd, how));\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Listen(PRFileDesc* fd, PRIntn backlog)\n-{\n-    return ((fd->methods->listen)(fd, backlog));\n+PR_IMPLEMENT(PRStatus) PR_Listen(PRFileDesc* fd, PRIntn backlog) {\n+  return ((fd->methods->listen)(fd, backlog));\n }\n \n PR_IMPLEMENT(PRInt32)\n PR_Recv(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n-        PRIntervalTime timeout)\n-{\n-    return ((fd->methods->recv)(fd, buf, amount, flags, timeout));\n+        PRIntervalTime timeout) {\n+  return ((fd->methods->recv)(fd, buf, amount, flags, timeout));\n }\n \n PR_IMPLEMENT(PRInt32)\n PR_Send(PRFileDesc* fd, const void* buf, PRInt32 amount, PRIntn flags,\n-        PRIntervalTime timeout)\n-{\n-    return ((fd->methods->send)(fd, buf, amount, flags, timeout));\n+        PRIntervalTime timeout) {\n+  return ((fd->methods->send)(fd, buf, amount, flags, timeout));\n }\n \n PR_IMPLEMENT(PRInt32)\n PR_Writev(PRFileDesc* fd, const PRIOVec* iov, PRInt32 iov_size,\n-          PRIntervalTime timeout)\n-{\n-    if (iov_size > PR_MAX_IOVECTOR_SIZE) {\n-        PR_SetError(PR_BUFFER_OVERFLOW_ERROR, 0);\n-        return -1;\n-    }\n-    return ((fd->methods->writev)(fd, iov, iov_size, timeout));\n+          PRIntervalTime timeout) {\n+  if (iov_size > PR_MAX_IOVECTOR_SIZE) {\n+    PR_SetError(PR_BUFFER_OVERFLOW_ERROR, 0);\n+    return -1;\n+  }\n+  return ((fd->methods->writev)(fd, iov, iov_size, timeout));\n }\n \n PR_IMPLEMENT(PRInt32)\n PR_RecvFrom(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n-            PRNetAddr* addr, PRIntervalTime timeout)\n-{\n-    return ((fd->methods->recvfrom)(fd, buf, amount, flags, addr, timeout));\n+            PRNetAddr* addr, PRIntervalTime timeout) {\n+  return ((fd->methods->recvfrom)(fd, buf, amount, flags, addr, timeout));\n }\n \n PR_IMPLEMENT(PRInt32)\n PR_SendTo(PRFileDesc* fd, const void* buf, PRInt32 amount, PRIntn flags,\n-          const PRNetAddr* addr, PRIntervalTime timeout)\n-{\n-    return ((fd->methods->sendto)(fd, buf, amount, flags, addr, timeout));\n+          const PRNetAddr* addr, PRIntervalTime timeout) {\n+  return ((fd->methods->sendto)(fd, buf, amount, flags, addr, timeout));\n }\n \n PR_IMPLEMENT(PRInt32)\n PR_TransmitFile(PRFileDesc* sd, PRFileDesc* fd, const void* hdr, PRInt32 hlen,\n-                PRTransmitFileFlags flags, PRIntervalTime timeout)\n-{\n-    return ((sd->methods->transmitfile)(sd, fd, hdr, hlen, flags, timeout));\n+                PRTransmitFileFlags flags, PRIntervalTime timeout) {\n+  return ((sd->methods->transmitfile)(sd, fd, hdr, hlen, flags, timeout));\n }\n \n PR_IMPLEMENT(PRInt32)\n PR_AcceptRead(PRFileDesc* sd, PRFileDesc** nd, PRNetAddr** raddr, void* buf,\n-              PRInt32 amount, PRIntervalTime timeout)\n-{\n-    return ((sd->methods->acceptread)(sd, nd, raddr, buf, amount, timeout));\n+              PRInt32 amount, PRIntervalTime timeout) {\n+  return ((sd->methods->acceptread)(sd, nd, raddr, buf, amount, timeout));\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_GetSockName(PRFileDesc* fd, PRNetAddr* addr)\n-{\n-    return ((fd->methods->getsockname)(fd, addr));\n+PR_IMPLEMENT(PRStatus) PR_GetSockName(PRFileDesc* fd, PRNetAddr* addr) {\n+  return ((fd->methods->getsockname)(fd, addr));\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_GetPeerName(PRFileDesc* fd, PRNetAddr* addr)\n-{\n-    return ((fd->methods->getpeername)(fd, addr));\n+PR_IMPLEMENT(PRStatus) PR_GetPeerName(PRFileDesc* fd, PRNetAddr* addr) {\n+  return ((fd->methods->getpeername)(fd, addr));\n }\n \n PR_IMPLEMENT(PRStatus)\n-PR_GetSocketOption(PRFileDesc* fd, PRSocketOptionData* data)\n-{\n-    return ((fd->methods->getsocketoption)(fd, data));\n+PR_GetSocketOption(PRFileDesc* fd, PRSocketOptionData* data) {\n+  return ((fd->methods->getsocketoption)(fd, data));\n }\n \n PR_IMPLEMENT(PRStatus)\n-PR_SetSocketOption(PRFileDesc* fd, const PRSocketOptionData* data)\n-{\n-    return ((fd->methods->setsocketoption)(fd, data));\n+PR_SetSocketOption(PRFileDesc* fd, const PRSocketOptionData* data) {\n+  return ((fd->methods->setsocketoption)(fd, data));\n }\n \n PR_IMPLEMENT(PRInt32)\n PR_SendFile(PRFileDesc* sd, PRSendFileData* sfd, PRTransmitFileFlags flags,\n-            PRIntervalTime timeout)\n-{\n-    return ((sd->methods->sendfile)(sd, sfd, flags, timeout));\n+            PRIntervalTime timeout) {\n+  return ((sd->methods->sendfile)(sd, sfd, flags, timeout));\n }\n \n PR_IMPLEMENT(PRInt32)\n PR_EmulateAcceptRead(PRFileDesc* sd, PRFileDesc** nd, PRNetAddr** raddr,\n-                     void* buf, PRInt32 amount, PRIntervalTime timeout)\n-{\n-    PRInt32 rv = -1;\n-    PRNetAddr remote;\n-    PRFileDesc* accepted = NULL;\n-\n-    /*\n-    ** The timeout does not apply to the accept portion of the\n-    ** operation - it waits indefinitely.\n-    */\n-    accepted = PR_Accept(sd, &remote, PR_INTERVAL_NO_TIMEOUT);\n-    if (NULL == accepted) {\n-        return rv;\n-    }\n+                     void* buf, PRInt32 amount, PRIntervalTime timeout) {\n+  PRInt32 rv = -1;\n+  PRNetAddr remote;\n+  PRFileDesc* accepted = NULL;\n+\n+  /*\n+  ** The timeout does not apply to the accept portion of the\n+  ** operation - it waits indefinitely.\n+  */\n+  accepted = PR_Accept(sd, &remote, PR_INTERVAL_NO_TIMEOUT);\n+  if (NULL == accepted) {\n+    return rv;\n+  }\n \n-    rv = PR_Recv(accepted, buf, amount, 0, timeout);\n-    if (rv >= 0) {\n-        /* copy the new info out where caller can see it */\n+  rv = PR_Recv(accepted, buf, amount, 0, timeout);\n+  if (rv >= 0) {\n+    /* copy the new info out where caller can see it */\n #define AMASK ((PRPtrdiff)7) /* mask for alignment of PRNetAddr */\n-        PRPtrdiff aligned = (PRPtrdiff)buf + amount + AMASK;\n-        *raddr = (PRNetAddr*)(aligned & ~AMASK);\n-        memcpy(*raddr, &remote, PR_NETADDR_SIZE(&remote));\n-        *nd = accepted;\n-        return rv;\n-    }\n-\n-    PR_Close(accepted);\n+    PRPtrdiff aligned = (PRPtrdiff)buf + amount + AMASK;\n+    *raddr = (PRNetAddr*)(aligned & ~AMASK);\n+    memcpy(*raddr, &remote, PR_NETADDR_SIZE(&remote));\n+    *nd = accepted;\n     return rv;\n+  }\n+\n+  PR_Close(accepted);\n+  return rv;\n }\n \n /*\n@@ -331,293 +280,291 @@ PR_EmulateAcceptRead(PRFileDesc* sd, PRFileDesc** nd, PRNetAddr** raddr,\n  * An implementation based on memory-mapped files\n  */\n \n-#define SENDFILE_MMAP_CHUNK (256 * 1024)\n+#  define SENDFILE_MMAP_CHUNK (256 * 1024)\n \n PR_IMPLEMENT(PRInt32)\n PR_EmulateSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n-                   PRTransmitFileFlags flags, PRIntervalTime timeout)\n-{\n-    PRInt32 rv, count = 0;\n-    PRInt32 len, file_bytes, index = 0;\n-    PRFileInfo info;\n-    PRIOVec iov[3];\n-    PRFileMap* mapHandle = NULL;\n-    void* addr = (void*)0; /* initialized to some arbitrary value. Keeps compiler\n-                              warnings down. */\n-    PRUint32 file_mmap_offset, alignment;\n-    PRInt64 zero64;\n-    PROffset64 file_mmap_offset64;\n-    PRUint32 addr_offset, mmap_len;\n-\n-    /* Get file size */\n-    if (PR_SUCCESS != PR_GetOpenFileInfo(sfd->fd, &info)) {\n-        count = -1;\n-        goto done;\n-    }\n-    if (sfd->file_nbytes && (info.size < (sfd->file_offset + sfd->file_nbytes))) {\n-        /*\n-         * there are fewer bytes in file to send than specified\n-         */\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        count = -1;\n-        goto done;\n-    }\n-    if (sfd->file_nbytes) {\n-        file_bytes = sfd->file_nbytes;\n-    } else {\n-        file_bytes = info.size - sfd->file_offset;\n-    }\n-\n-    alignment = PR_GetMemMapAlignment();\n-\n-    /* number of initial bytes to skip in mmap'd segment */\n-    addr_offset = sfd->file_offset % alignment;\n-\n-    /* find previous mmap alignment boundary */\n-    file_mmap_offset = sfd->file_offset - addr_offset;\n-\n+                   PRTransmitFileFlags flags, PRIntervalTime timeout) {\n+  PRInt32 rv, count = 0;\n+  PRInt32 len, file_bytes, index = 0;\n+  PRFileInfo info;\n+  PRIOVec iov[3];\n+  PRFileMap* mapHandle = NULL;\n+  void* addr = (void*)0; /* initialized to some arbitrary value. Keeps compiler\n+                            warnings down. */\n+  PRUint32 file_mmap_offset, alignment;\n+  PRInt64 zero64;\n+  PROffset64 file_mmap_offset64;\n+  PRUint32 addr_offset, mmap_len;\n+\n+  /* Get file size */\n+  if (PR_SUCCESS != PR_GetOpenFileInfo(sfd->fd, &info)) {\n+    count = -1;\n+    goto done;\n+  }\n+  if (sfd->file_nbytes && (info.size < (sfd->file_offset + sfd->file_nbytes))) {\n     /*\n-     * If the file is large, mmap and send the file in chunks so as\n-     * to not consume too much virtual address space\n+     * there are fewer bytes in file to send than specified\n      */\n-    mmap_len = PR_MIN(file_bytes + addr_offset, SENDFILE_MMAP_CHUNK);\n-    len = mmap_len - addr_offset;\n-\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    count = -1;\n+    goto done;\n+  }\n+  if (sfd->file_nbytes) {\n+    file_bytes = sfd->file_nbytes;\n+  } else {\n+    file_bytes = info.size - sfd->file_offset;\n+  }\n+\n+  alignment = PR_GetMemMapAlignment();\n+\n+  /* number of initial bytes to skip in mmap'd segment */\n+  addr_offset = sfd->file_offset % alignment;\n+\n+  /* find previous mmap alignment boundary */\n+  file_mmap_offset = sfd->file_offset - addr_offset;\n+\n+  /*\n+   * If the file is large, mmap and send the file in chunks so as\n+   * to not consume too much virtual address space\n+   */\n+  mmap_len = PR_MIN(file_bytes + addr_offset, SENDFILE_MMAP_CHUNK);\n+  len = mmap_len - addr_offset;\n+\n+  /*\n+   * Map in (part of) file. Take care of zero-length files.\n+   */\n+  if (len) {\n+    LL_I2L(zero64, 0);\n+    mapHandle = PR_CreateFileMap(sfd->fd, zero64, PR_PROT_READONLY);\n+    if (!mapHandle) {\n+      count = -1;\n+      goto done;\n+    }\n+    LL_I2L(file_mmap_offset64, file_mmap_offset);\n+    addr = PR_MemMap(mapHandle, file_mmap_offset64, mmap_len);\n+    if (!addr) {\n+      count = -1;\n+      goto done;\n+    }\n+  }\n+  /*\n+   * send headers first, followed by the file\n+   */\n+  if (sfd->hlen) {\n+    iov[index].iov_base = (char*)sfd->header;\n+    iov[index].iov_len = sfd->hlen;\n+    index++;\n+  }\n+  if (len) {\n+    iov[index].iov_base = (char*)addr + addr_offset;\n+    iov[index].iov_len = len;\n+    index++;\n+  }\n+  if ((file_bytes == len) && (sfd->tlen)) {\n     /*\n-     * Map in (part of) file. Take care of zero-length files.\n+     * all file data is mapped in; send the trailer too\n      */\n-    if (len) {\n-        LL_I2L(zero64, 0);\n-        mapHandle = PR_CreateFileMap(sfd->fd, zero64, PR_PROT_READONLY);\n-        if (!mapHandle) {\n-            count = -1;\n-            goto done;\n-        }\n-        LL_I2L(file_mmap_offset64, file_mmap_offset);\n-        addr = PR_MemMap(mapHandle, file_mmap_offset64, mmap_len);\n-        if (!addr) {\n-            count = -1;\n-            goto done;\n-        }\n-    }\n+    iov[index].iov_base = (char*)sfd->trailer;\n+    iov[index].iov_len = sfd->tlen;\n+    index++;\n+  }\n+  rv = PR_Writev(sd, iov, index, timeout);\n+  if (len) {\n+    PR_MemUnmap(addr, mmap_len);\n+  }\n+  if (rv < 0) {\n+    count = -1;\n+    goto done;\n+  }\n+\n+  PR_ASSERT(rv == sfd->hlen + len + ((len == file_bytes) ? sfd->tlen : 0));\n+\n+  file_bytes -= len;\n+  count += rv;\n+  if (!file_bytes) { /* header, file and trailer are sent */\n+    goto done;\n+  }\n+\n+  /*\n+   * send remaining bytes of the file, if any\n+   */\n+  len = PR_MIN(file_bytes, SENDFILE_MMAP_CHUNK);\n+  while (len > 0) {\n     /*\n-     * send headers first, followed by the file\n+     * Map in (part of) file\n      */\n-    if (sfd->hlen) {\n-        iov[index].iov_base = (char*)sfd->header;\n-        iov[index].iov_len = sfd->hlen;\n-        index++;\n-    }\n-    if (len) {\n-        iov[index].iov_base = (char*)addr + addr_offset;\n-        iov[index].iov_len = len;\n-        index++;\n-    }\n-    if ((file_bytes == len) && (sfd->tlen)) {\n-        /*\n-         * all file data is mapped in; send the trailer too\n-         */\n-        iov[index].iov_base = (char*)sfd->trailer;\n-        iov[index].iov_len = sfd->tlen;\n-        index++;\n-    }\n-    rv = PR_Writev(sd, iov, index, timeout);\n-    if (len) {\n-        PR_MemUnmap(addr, mmap_len);\n+    file_mmap_offset = sfd->file_offset + count - sfd->hlen;\n+    PR_ASSERT((file_mmap_offset % alignment) == 0);\n+\n+    LL_I2L(file_mmap_offset64, file_mmap_offset);\n+    addr = PR_MemMap(mapHandle, file_mmap_offset64, len);\n+    if (!addr) {\n+      count = -1;\n+      goto done;\n     }\n+    rv = PR_Send(sd, addr, len, 0, timeout);\n+    PR_MemUnmap(addr, len);\n     if (rv < 0) {\n-        count = -1;\n-        goto done;\n+      count = -1;\n+      goto done;\n     }\n \n-    PR_ASSERT(rv == sfd->hlen + len + ((len == file_bytes) ? sfd->tlen : 0));\n-\n-    file_bytes -= len;\n+    PR_ASSERT(rv == len);\n+    file_bytes -= rv;\n     count += rv;\n-    if (!file_bytes) { /* header, file and trailer are sent */\n-        goto done;\n-    }\n-\n-    /*\n-     * send remaining bytes of the file, if any\n-     */\n     len = PR_MIN(file_bytes, SENDFILE_MMAP_CHUNK);\n-    while (len > 0) {\n-        /*\n-         * Map in (part of) file\n-         */\n-        file_mmap_offset = sfd->file_offset + count - sfd->hlen;\n-        PR_ASSERT((file_mmap_offset % alignment) == 0);\n-\n-        LL_I2L(file_mmap_offset64, file_mmap_offset);\n-        addr = PR_MemMap(mapHandle, file_mmap_offset64, len);\n-        if (!addr) {\n-            count = -1;\n-            goto done;\n-        }\n-        rv = PR_Send(sd, addr, len, 0, timeout);\n-        PR_MemUnmap(addr, len);\n-        if (rv < 0) {\n-            count = -1;\n-            goto done;\n-        }\n-\n-        PR_ASSERT(rv == len);\n-        file_bytes -= rv;\n-        count += rv;\n-        len = PR_MIN(file_bytes, SENDFILE_MMAP_CHUNK);\n-    }\n-    PR_ASSERT(0 == file_bytes);\n-    if (sfd->tlen) {\n-        rv = PR_Send(sd, sfd->trailer, sfd->tlen, 0, timeout);\n-        if (rv >= 0) {\n-            PR_ASSERT(rv == sfd->tlen);\n-            count += rv;\n-        } else {\n-            count = -1;\n-        }\n+  }\n+  PR_ASSERT(0 == file_bytes);\n+  if (sfd->tlen) {\n+    rv = PR_Send(sd, sfd->trailer, sfd->tlen, 0, timeout);\n+    if (rv >= 0) {\n+      PR_ASSERT(rv == sfd->tlen);\n+      count += rv;\n+    } else {\n+      count = -1;\n     }\n+  }\n done:\n-    if (mapHandle) {\n-        PR_CloseFileMap(mapHandle);\n-    }\n-    if ((count >= 0) && (flags & PR_TRANSMITFILE_CLOSE_SOCKET)) {\n-        PR_Close(sd);\n-    }\n-    return count;\n+  if (mapHandle) {\n+    PR_CloseFileMap(mapHandle);\n+  }\n+  if ((count >= 0) && (flags & PR_TRANSMITFILE_CLOSE_SOCKET)) {\n+    PR_Close(sd);\n+  }\n+  return count;\n }\n \n #else\n \n PR_IMPLEMENT(PRInt32)\n PR_EmulateSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n-                   PRTransmitFileFlags flags, PRIntervalTime timeout)\n-{\n-    PRInt32 rv, count = 0;\n-    PRInt32 rlen;\n-    const void* buffer;\n-    PRInt32 buflen;\n-    PRInt32 sendbytes, readbytes;\n-    char* buf;\n-\n-#define _SENDFILE_BUFSIZE (16 * 1024)\n-\n-    buf = (char*)PR_MALLOC(_SENDFILE_BUFSIZE);\n-    if (buf == NULL) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return -1;\n+                   PRTransmitFileFlags flags, PRIntervalTime timeout) {\n+  PRInt32 rv, count = 0;\n+  PRInt32 rlen;\n+  const void* buffer;\n+  PRInt32 buflen;\n+  PRInt32 sendbytes, readbytes;\n+  char* buf;\n+\n+#  define _SENDFILE_BUFSIZE (16 * 1024)\n+\n+  buf = (char*)PR_MALLOC(_SENDFILE_BUFSIZE);\n+  if (buf == NULL) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return -1;\n+  }\n+\n+  /*\n+   * send header first\n+   */\n+  buflen = sfd->hlen;\n+  buffer = sfd->header;\n+  while (buflen) {\n+    rv = PR_Send(sd, buffer, buflen, 0, timeout);\n+    if (rv < 0) {\n+      /* PR_Send() has invoked PR_SetError(). */\n+      rv = -1;\n+      goto done;\n+    } else {\n+      count += rv;\n+      buffer = (const void*)((const char*)buffer + rv);\n+      buflen -= rv;\n     }\n-\n-    /*\n-     * send header first\n-     */\n-    buflen = sfd->hlen;\n-    buffer = sfd->header;\n-    while (buflen) {\n-        rv = PR_Send(sd, buffer, buflen, 0, timeout);\n+  }\n+\n+  /*\n+   * send file next\n+   */\n+  if (PR_Seek(sfd->fd, sfd->file_offset, PR_SEEK_SET) < 0) {\n+    rv = -1;\n+    goto done;\n+  }\n+  sendbytes = sfd->file_nbytes;\n+  if (sendbytes == 0) {\n+    /* send entire file */\n+    while ((rlen = PR_Read(sfd->fd, buf, _SENDFILE_BUFSIZE)) > 0) {\n+      while (rlen) {\n+        char* bufptr = buf;\n+\n+        rv = PR_Send(sd, bufptr, rlen, 0, timeout);\n         if (rv < 0) {\n-            /* PR_Send() has invoked PR_SetError(). */\n-            rv = -1;\n-            goto done;\n+          /* PR_Send() has invoked PR_SetError(). */\n+          rv = -1;\n+          goto done;\n         } else {\n-            count += rv;\n-            buffer = (const void*)((const char*)buffer + rv);\n-            buflen -= rv;\n+          count += rv;\n+          bufptr = ((char*)bufptr + rv);\n+          rlen -= rv;\n         }\n+      }\n     }\n-\n-    /*\n-     * send file next\n-     */\n-    if (PR_Seek(sfd->fd, sfd->file_offset, PR_SEEK_SET) < 0) {\n-        rv = -1;\n-        goto done;\n-    }\n-    sendbytes = sfd->file_nbytes;\n-    if (sendbytes == 0) {\n-        /* send entire file */\n-        while ((rlen = PR_Read(sfd->fd, buf, _SENDFILE_BUFSIZE)) > 0) {\n-            while (rlen) {\n-                char* bufptr = buf;\n-\n-                rv = PR_Send(sd, bufptr, rlen, 0, timeout);\n-                if (rv < 0) {\n-                    /* PR_Send() has invoked PR_SetError(). */\n-                    rv = -1;\n-                    goto done;\n-                } else {\n-                    count += rv;\n-                    bufptr = ((char*)bufptr + rv);\n-                    rlen -= rv;\n-                }\n-            }\n-        }\n-        if (rlen < 0) {\n-            /* PR_Read() has invoked PR_SetError(). */\n-            rv = -1;\n-            goto done;\n-        }\n-    } else {\n-        readbytes = PR_MIN(sendbytes, _SENDFILE_BUFSIZE);\n-        while (readbytes && ((rlen = PR_Read(sfd->fd, buf, readbytes)) > 0)) {\n-            while (rlen) {\n-                char* bufptr = buf;\n-\n-                rv = PR_Send(sd, bufptr, rlen, 0, timeout);\n-                if (rv < 0) {\n-                    /* PR_Send() has invoked PR_SetError(). */\n-                    rv = -1;\n-                    goto done;\n-                } else {\n-                    count += rv;\n-                    sendbytes -= rv;\n-                    bufptr = ((char*)bufptr + rv);\n-                    rlen -= rv;\n-                }\n-            }\n-            readbytes = PR_MIN(sendbytes, _SENDFILE_BUFSIZE);\n-        }\n-        if (rlen < 0) {\n-            /* PR_Read() has invoked PR_SetError(). */\n-            rv = -1;\n-            goto done;\n-        } else if (sendbytes != 0) {\n-            /*\n-             * there are fewer bytes in file to send than specified\n-             */\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            rv = -1;\n-            goto done;\n-        }\n+    if (rlen < 0) {\n+      /* PR_Read() has invoked PR_SetError(). */\n+      rv = -1;\n+      goto done;\n     }\n+  } else {\n+    readbytes = PR_MIN(sendbytes, _SENDFILE_BUFSIZE);\n+    while (readbytes && ((rlen = PR_Read(sfd->fd, buf, readbytes)) > 0)) {\n+      while (rlen) {\n+        char* bufptr = buf;\n \n-    /*\n-     * send trailer last\n-     */\n-    buflen = sfd->tlen;\n-    buffer = sfd->trailer;\n-    while (buflen) {\n-        rv = PR_Send(sd, buffer, buflen, 0, timeout);\n+        rv = PR_Send(sd, bufptr, rlen, 0, timeout);\n         if (rv < 0) {\n-            /* PR_Send() has invoked PR_SetError(). */\n-            rv = -1;\n-            goto done;\n+          /* PR_Send() has invoked PR_SetError(). */\n+          rv = -1;\n+          goto done;\n         } else {\n-            count += rv;\n-            buffer = (const void*)((const char*)buffer + rv);\n-            buflen -= rv;\n+          count += rv;\n+          sendbytes -= rv;\n+          bufptr = ((char*)bufptr + rv);\n+          rlen -= rv;\n         }\n+      }\n+      readbytes = PR_MIN(sendbytes, _SENDFILE_BUFSIZE);\n     }\n-    rv = count;\n-\n-done:\n-    if (buf) {\n-        PR_DELETE(buf);\n+    if (rlen < 0) {\n+      /* PR_Read() has invoked PR_SetError(). */\n+      rv = -1;\n+      goto done;\n+    } else if (sendbytes != 0) {\n+      /*\n+       * there are fewer bytes in file to send than specified\n+       */\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      rv = -1;\n+      goto done;\n     }\n-    if ((rv >= 0) && (flags & PR_TRANSMITFILE_CLOSE_SOCKET)) {\n-        PR_Close(sd);\n+  }\n+\n+  /*\n+   * send trailer last\n+   */\n+  buflen = sfd->tlen;\n+  buffer = sfd->trailer;\n+  while (buflen) {\n+    rv = PR_Send(sd, buffer, buflen, 0, timeout);\n+    if (rv < 0) {\n+      /* PR_Send() has invoked PR_SetError(). */\n+      rv = -1;\n+      goto done;\n+    } else {\n+      count += rv;\n+      buffer = (const void*)((const char*)buffer + rv);\n+      buflen -= rv;\n     }\n-    return rv;\n+  }\n+  rv = count;\n+\n+done:\n+  if (buf) {\n+    PR_DELETE(buf);\n+  }\n+  if ((rv >= 0) && (flags & PR_TRANSMITFILE_CLOSE_SOCKET)) {\n+    PR_Close(sd);\n+  }\n+  return rv;\n }\n \n #endif\ndiff --git a/nspr/pr/src/io/pripv6.c b/nspr/pr/src/io/pripv6.c\nindex 3adec20..284b01a 100644\n--- a/nspr/pr/src/io/pripv6.c\n+++ b/nspr/pr/src/io/pripv6.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -21,367 +22,338 @@ extern const PRIPv6Addr _pr_in6addr_loopback;\n /*\n  * convert an IPv4-mapped IPv6 addr to an IPv4 addr\n  */\n-static void\n-_PR_ConvertToIpv4NetAddr(const PRNetAddr* src_v6addr,\n-                         PRNetAddr* dst_v4addr)\n-{\n-    const PRUint8* srcp;\n-\n-    PR_ASSERT(PR_AF_INET6 == src_v6addr->ipv6.family);\n-\n-    if (PR_IsNetAddrType(src_v6addr, PR_IpAddrV4Mapped)) {\n-        srcp = src_v6addr->ipv6.ip.pr_s6_addr;\n-        memcpy((char*)&dst_v4addr->inet.ip, srcp + 12, 4);\n-    } else if (PR_IsNetAddrType(src_v6addr, PR_IpAddrAny)) {\n-        dst_v4addr->inet.ip = htonl(INADDR_ANY);\n-    } else if (PR_IsNetAddrType(src_v6addr, PR_IpAddrLoopback)) {\n-        dst_v4addr->inet.ip = htonl(INADDR_LOOPBACK);\n-    }\n-    dst_v4addr->inet.family = PR_AF_INET;\n-    dst_v4addr->inet.port = src_v6addr->ipv6.port;\n+static void _PR_ConvertToIpv4NetAddr(const PRNetAddr* src_v6addr,\n+                                     PRNetAddr* dst_v4addr) {\n+  const PRUint8* srcp;\n+\n+  PR_ASSERT(PR_AF_INET6 == src_v6addr->ipv6.family);\n+\n+  if (PR_IsNetAddrType(src_v6addr, PR_IpAddrV4Mapped)) {\n+    srcp = src_v6addr->ipv6.ip.pr_s6_addr;\n+    memcpy((char*)&dst_v4addr->inet.ip, srcp + 12, 4);\n+  } else if (PR_IsNetAddrType(src_v6addr, PR_IpAddrAny)) {\n+    dst_v4addr->inet.ip = htonl(INADDR_ANY);\n+  } else if (PR_IsNetAddrType(src_v6addr, PR_IpAddrLoopback)) {\n+    dst_v4addr->inet.ip = htonl(INADDR_LOOPBACK);\n+  }\n+  dst_v4addr->inet.family = PR_AF_INET;\n+  dst_v4addr->inet.port = src_v6addr->ipv6.port;\n }\n \n /*\n  * convert an IPv4 addr to an IPv4-mapped IPv6 addr\n  */\n-static void\n-_PR_ConvertToIpv6NetAddr(const PRNetAddr* src_v4addr,\n-                         PRNetAddr* dst_v6addr)\n-{\n-    PRUint8* dstp;\n-\n-    PR_ASSERT(PR_AF_INET == src_v4addr->inet.family);\n-    dst_v6addr->ipv6.family = PR_AF_INET6;\n-    dst_v6addr->ipv6.port = src_v4addr->inet.port;\n-\n-    if (htonl(INADDR_ANY) == src_v4addr->inet.ip) {\n-        dst_v6addr->ipv6.ip = _pr_in6addr_any;\n-    } else {\n-        dstp = dst_v6addr->ipv6.ip.pr_s6_addr;\n-        memset(dstp, 0, 10);\n-        memset(dstp + 10, 0xff, 2);\n-        memcpy(dstp + 12, (char*)&src_v4addr->inet.ip, 4);\n-    }\n+static void _PR_ConvertToIpv6NetAddr(const PRNetAddr* src_v4addr,\n+                                     PRNetAddr* dst_v6addr) {\n+  PRUint8* dstp;\n+\n+  PR_ASSERT(PR_AF_INET == src_v4addr->inet.family);\n+  dst_v6addr->ipv6.family = PR_AF_INET6;\n+  dst_v6addr->ipv6.port = src_v4addr->inet.port;\n+\n+  if (htonl(INADDR_ANY) == src_v4addr->inet.ip) {\n+    dst_v6addr->ipv6.ip = _pr_in6addr_any;\n+  } else {\n+    dstp = dst_v6addr->ipv6.ip.pr_s6_addr;\n+    memset(dstp, 0, 10);\n+    memset(dstp + 10, 0xff, 2);\n+    memcpy(dstp + 12, (char*)&src_v4addr->inet.ip, 4);\n+  }\n }\n \n-static PRStatus PR_CALLBACK\n-Ipv6ToIpv4SocketBind(PRFileDesc* fd,\n-                     const PRNetAddr* addr)\n-{\n-    PRNetAddr tmp_ipv4addr;\n-    const PRNetAddr* tmp_addrp;\n-    PRFileDesc* lo = fd->lower;\n-\n-    if (PR_AF_INET6 != addr->raw.family) {\n-        PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    if (PR_IsNetAddrType(addr, PR_IpAddrV4Mapped) ||\n-        PR_IsNetAddrType(addr, PR_IpAddrAny)) {\n-        _PR_ConvertToIpv4NetAddr(addr, &tmp_ipv4addr);\n-        tmp_addrp = &tmp_ipv4addr;\n-    } else {\n-        PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    return ((lo->methods->bind)(lo, tmp_addrp));\n+static PRStatus PR_CALLBACK Ipv6ToIpv4SocketBind(PRFileDesc* fd,\n+                                                 const PRNetAddr* addr) {\n+  PRNetAddr tmp_ipv4addr;\n+  const PRNetAddr* tmp_addrp;\n+  PRFileDesc* lo = fd->lower;\n+\n+  if (PR_AF_INET6 != addr->raw.family) {\n+    PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  if (PR_IsNetAddrType(addr, PR_IpAddrV4Mapped) ||\n+      PR_IsNetAddrType(addr, PR_IpAddrAny)) {\n+    _PR_ConvertToIpv4NetAddr(addr, &tmp_ipv4addr);\n+    tmp_addrp = &tmp_ipv4addr;\n+  } else {\n+    PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  return ((lo->methods->bind)(lo, tmp_addrp));\n }\n \n-static PRStatus PR_CALLBACK\n-Ipv6ToIpv4SocketConnect(PRFileDesc* fd,\n-                        const PRNetAddr* addr,\n-                        PRIntervalTime timeout)\n-{\n-    PRNetAddr tmp_ipv4addr;\n-    const PRNetAddr* tmp_addrp;\n-\n-    if (PR_AF_INET6 != addr->raw.family) {\n-        PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    if (PR_IsNetAddrType(addr, PR_IpAddrV4Mapped) ||\n-        PR_IsNetAddrType(addr, PR_IpAddrLoopback)) {\n-        _PR_ConvertToIpv4NetAddr(addr, &tmp_ipv4addr);\n-        tmp_addrp = &tmp_ipv4addr;\n-    } else {\n-        PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    return (fd->lower->methods->connect)(fd->lower, tmp_addrp, timeout);\n+static PRStatus PR_CALLBACK Ipv6ToIpv4SocketConnect(PRFileDesc* fd,\n+                                                    const PRNetAddr* addr,\n+                                                    PRIntervalTime timeout) {\n+  PRNetAddr tmp_ipv4addr;\n+  const PRNetAddr* tmp_addrp;\n+\n+  if (PR_AF_INET6 != addr->raw.family) {\n+    PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  if (PR_IsNetAddrType(addr, PR_IpAddrV4Mapped) ||\n+      PR_IsNetAddrType(addr, PR_IpAddrLoopback)) {\n+    _PR_ConvertToIpv4NetAddr(addr, &tmp_ipv4addr);\n+    tmp_addrp = &tmp_ipv4addr;\n+  } else {\n+    PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  return (fd->lower->methods->connect)(fd->lower, tmp_addrp, timeout);\n }\n \n-static PRInt32 PR_CALLBACK\n-Ipv6ToIpv4SocketSendTo(PRFileDesc* fd,\n-                       const void* buf,\n-                       PRInt32 amount, PRIntn flags,\n-                       const PRNetAddr* addr,\n-                       PRIntervalTime timeout)\n-{\n-    PRNetAddr tmp_ipv4addr;\n-    const PRNetAddr* tmp_addrp;\n-\n-    if (PR_AF_INET6 != addr->raw.family) {\n-        PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    if (PR_IsNetAddrType(addr, PR_IpAddrV4Mapped) ||\n-        PR_IsNetAddrType(addr, PR_IpAddrLoopback)) {\n-        _PR_ConvertToIpv4NetAddr(addr, &tmp_ipv4addr);\n-        tmp_addrp = &tmp_ipv4addr;\n-    } else {\n-        PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    return (fd->lower->methods->sendto)(fd->lower, buf, amount, flags, tmp_addrp,\n-                                        timeout);\n+static PRInt32 PR_CALLBACK Ipv6ToIpv4SocketSendTo(PRFileDesc* fd,\n+                                                  const void* buf,\n+                                                  PRInt32 amount, PRIntn flags,\n+                                                  const PRNetAddr* addr,\n+                                                  PRIntervalTime timeout) {\n+  PRNetAddr tmp_ipv4addr;\n+  const PRNetAddr* tmp_addrp;\n+\n+  if (PR_AF_INET6 != addr->raw.family) {\n+    PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  if (PR_IsNetAddrType(addr, PR_IpAddrV4Mapped) ||\n+      PR_IsNetAddrType(addr, PR_IpAddrLoopback)) {\n+    _PR_ConvertToIpv4NetAddr(addr, &tmp_ipv4addr);\n+    tmp_addrp = &tmp_ipv4addr;\n+  } else {\n+    PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  return (fd->lower->methods->sendto)(fd->lower, buf, amount, flags, tmp_addrp,\n+                                      timeout);\n }\n \n-static PRFileDesc* PR_CALLBACK\n-Ipv6ToIpv4SocketAccept(PRFileDesc* fd,\n-                       PRNetAddr* addr,\n-                       PRIntervalTime timeout)\n-{\n-    PRStatus rv;\n-    PRFileDesc* newfd;\n-    PRFileDesc* newstack;\n-    PRNetAddr tmp_ipv4addr;\n-    PRNetAddr* addrlower = NULL;\n-\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n-\n-    newstack = PR_NEW(PRFileDesc);\n-    if (NULL == newstack) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n-    }\n-    *newstack = *fd; /* make a copy of the accepting layer */\n-\n-    if (addr) {\n-        addrlower = &tmp_ipv4addr;\n-    }\n-    newfd = (fd->lower->methods->accept)(fd->lower, addrlower, timeout);\n-    if (NULL == newfd) {\n-        PR_DELETE(newstack);\n-        return NULL;\n-    }\n-    if (addr) {\n-        _PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, addr);\n-    }\n-\n-    rv = PR_PushIOLayer(newfd, PR_TOP_IO_LAYER, newstack);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    return newfd; /* that's it */\n+static PRFileDesc* PR_CALLBACK Ipv6ToIpv4SocketAccept(PRFileDesc* fd,\n+                                                      PRNetAddr* addr,\n+                                                      PRIntervalTime timeout) {\n+  PRStatus rv;\n+  PRFileDesc* newfd;\n+  PRFileDesc* newstack;\n+  PRNetAddr tmp_ipv4addr;\n+  PRNetAddr* addrlower = NULL;\n+\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n+\n+  newstack = PR_NEW(PRFileDesc);\n+  if (NULL == newstack) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n+  *newstack = *fd; /* make a copy of the accepting layer */\n+\n+  if (addr) {\n+    addrlower = &tmp_ipv4addr;\n+  }\n+  newfd = (fd->lower->methods->accept)(fd->lower, addrlower, timeout);\n+  if (NULL == newfd) {\n+    PR_DELETE(newstack);\n+    return NULL;\n+  }\n+  if (addr) {\n+    _PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, addr);\n+  }\n+\n+  rv = PR_PushIOLayer(newfd, PR_TOP_IO_LAYER, newstack);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  return newfd; /* that's it */\n }\n \n-static PRInt32 PR_CALLBACK\n-Ipv6ToIpv4SocketAcceptRead(PRFileDesc* sd,\n-                           PRFileDesc** nd,\n-                           PRNetAddr** ipv6_raddr,\n-                           void* buf, PRInt32 amount,\n-                           PRIntervalTime timeout)\n-{\n-    PRInt32 nbytes;\n-    PRStatus rv;\n-    PRNetAddr tmp_ipv4addr;\n-    PRFileDesc* newstack;\n-\n-    PR_ASSERT(sd != NULL);\n-    PR_ASSERT(sd->lower != NULL);\n-\n-    newstack = PR_NEW(PRFileDesc);\n-    if (NULL == newstack) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return -1;\n-    }\n-    *newstack = *sd; /* make a copy of the accepting layer */\n-\n-    nbytes = sd->lower->methods->acceptread(sd->lower, nd, ipv6_raddr, buf,\n-                                            amount, timeout);\n-    if (-1 == nbytes) {\n-        PR_DELETE(newstack);\n-        return nbytes;\n-    }\n-    tmp_ipv4addr = **ipv6_raddr; /* copy */\n-    _PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, *ipv6_raddr);\n-\n-    /* this PR_PushIOLayer call cannot fail */\n-    rv = PR_PushIOLayer(*nd, PR_TOP_IO_LAYER, newstack);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+static PRInt32 PR_CALLBACK Ipv6ToIpv4SocketAcceptRead(PRFileDesc* sd,\n+                                                      PRFileDesc** nd,\n+                                                      PRNetAddr** ipv6_raddr,\n+                                                      void* buf, PRInt32 amount,\n+                                                      PRIntervalTime timeout) {\n+  PRInt32 nbytes;\n+  PRStatus rv;\n+  PRNetAddr tmp_ipv4addr;\n+  PRFileDesc* newstack;\n+\n+  PR_ASSERT(sd != NULL);\n+  PR_ASSERT(sd->lower != NULL);\n+\n+  newstack = PR_NEW(PRFileDesc);\n+  if (NULL == newstack) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return -1;\n+  }\n+  *newstack = *sd; /* make a copy of the accepting layer */\n+\n+  nbytes = sd->lower->methods->acceptread(sd->lower, nd, ipv6_raddr, buf,\n+                                          amount, timeout);\n+  if (-1 == nbytes) {\n+    PR_DELETE(newstack);\n     return nbytes;\n+  }\n+  tmp_ipv4addr = **ipv6_raddr; /* copy */\n+  _PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, *ipv6_raddr);\n+\n+  /* this PR_PushIOLayer call cannot fail */\n+  rv = PR_PushIOLayer(*nd, PR_TOP_IO_LAYER, newstack);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  return nbytes;\n }\n \n-static PRStatus PR_CALLBACK\n-Ipv6ToIpv4SocketGetName(PRFileDesc* fd,\n-                        PRNetAddr* ipv6addr)\n-{\n-    PRStatus result;\n-    PRNetAddr tmp_ipv4addr;\n-\n-    result = (fd->lower->methods->getsockname)(fd->lower, &tmp_ipv4addr);\n-    if (PR_SUCCESS == result) {\n-        _PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, ipv6addr);\n-        PR_ASSERT(IsValidNetAddr(ipv6addr) == PR_TRUE);\n-    }\n-    return result;\n+static PRStatus PR_CALLBACK Ipv6ToIpv4SocketGetName(PRFileDesc* fd,\n+                                                    PRNetAddr* ipv6addr) {\n+  PRStatus result;\n+  PRNetAddr tmp_ipv4addr;\n+\n+  result = (fd->lower->methods->getsockname)(fd->lower, &tmp_ipv4addr);\n+  if (PR_SUCCESS == result) {\n+    _PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, ipv6addr);\n+    PR_ASSERT(IsValidNetAddr(ipv6addr) == PR_TRUE);\n+  }\n+  return result;\n }\n \n-static PRStatus PR_CALLBACK\n-Ipv6ToIpv4SocketGetPeerName(PRFileDesc* fd,\n-                            PRNetAddr* ipv6addr)\n-{\n-    PRStatus result;\n-    PRNetAddr tmp_ipv4addr;\n-\n-    result = (fd->lower->methods->getpeername)(fd->lower, &tmp_ipv4addr);\n-    if (PR_SUCCESS == result) {\n-        _PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, ipv6addr);\n-        PR_ASSERT(IsValidNetAddr(ipv6addr) == PR_TRUE);\n-    }\n-    return result;\n+static PRStatus PR_CALLBACK Ipv6ToIpv4SocketGetPeerName(PRFileDesc* fd,\n+                                                        PRNetAddr* ipv6addr) {\n+  PRStatus result;\n+  PRNetAddr tmp_ipv4addr;\n+\n+  result = (fd->lower->methods->getpeername)(fd->lower, &tmp_ipv4addr);\n+  if (PR_SUCCESS == result) {\n+    _PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, ipv6addr);\n+    PR_ASSERT(IsValidNetAddr(ipv6addr) == PR_TRUE);\n+  }\n+  return result;\n }\n \n-static PRInt32 PR_CALLBACK\n-Ipv6ToIpv4SocketRecvFrom(PRFileDesc* fd, void* buf,\n-                         PRInt32 amount,\n-                         PRIntn flags,\n-                         PRNetAddr* ipv6addr,\n-                         PRIntervalTime timeout)\n-{\n-    PRNetAddr tmp_ipv4addr;\n-    PRInt32 result;\n-\n-    result = (fd->lower->methods->recvfrom)(fd->lower, buf, amount, flags,\n-                                            &tmp_ipv4addr, timeout);\n-    if (-1 != result) {\n-        _PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, ipv6addr);\n-        PR_ASSERT(IsValidNetAddr(ipv6addr) == PR_TRUE);\n-    }\n-    return result;\n+static PRInt32 PR_CALLBACK Ipv6ToIpv4SocketRecvFrom(PRFileDesc* fd, void* buf,\n+                                                    PRInt32 amount,\n+                                                    PRIntn flags,\n+                                                    PRNetAddr* ipv6addr,\n+                                                    PRIntervalTime timeout) {\n+  PRNetAddr tmp_ipv4addr;\n+  PRInt32 result;\n+\n+  result = (fd->lower->methods->recvfrom)(fd->lower, buf, amount, flags,\n+                                          &tmp_ipv4addr, timeout);\n+  if (-1 != result) {\n+    _PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, ipv6addr);\n+    PR_ASSERT(IsValidNetAddr(ipv6addr) == PR_TRUE);\n+  }\n+  return result;\n }\n \n-#if defined(_PR_INET6_PROBE)\n+#  if defined(_PR_INET6_PROBE)\n static PRBool ipv6_is_present;\n-PR_EXTERN(PRBool)\n-_pr_test_ipv6_socket(void);\n+PR_EXTERN(PRBool) _pr_test_ipv6_socket(void);\n \n-#if !defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)\n+#    if !defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)\n extern PRStatus _pr_find_getipnodebyname(void);\n-#endif\n+#    endif\n \n-#if !defined(_PR_INET6) && defined(_PR_HAVE_GETADDRINFO)\n+#    if !defined(_PR_INET6) && defined(_PR_HAVE_GETADDRINFO)\n extern PRStatus _pr_find_getaddrinfo(void);\n-#endif\n-\n-static PRBool\n-_pr_probe_ipv6_presence(void)\n-{\n-#if !defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)\n-    if (_pr_find_getipnodebyname() != PR_SUCCESS) {\n-        return PR_FALSE;\n-    }\n-#endif\n-\n-#if !defined(_PR_INET6) && defined(_PR_HAVE_GETADDRINFO)\n-    if (_pr_find_getaddrinfo() != PR_SUCCESS) {\n-        return PR_FALSE;\n-    }\n-#endif\n-\n-    return _pr_test_ipv6_socket();\n+#    endif\n+\n+static PRBool _pr_probe_ipv6_presence(void) {\n+#    if !defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)\n+  if (_pr_find_getipnodebyname() != PR_SUCCESS) {\n+    return PR_FALSE;\n+  }\n+#    endif\n+\n+#    if !defined(_PR_INET6) && defined(_PR_HAVE_GETADDRINFO)\n+  if (_pr_find_getaddrinfo() != PR_SUCCESS) {\n+    return PR_FALSE;\n+  }\n+#    endif\n+\n+  return _pr_test_ipv6_socket();\n }\n-#endif /* _PR_INET6_PROBE */\n+#  endif /* _PR_INET6_PROBE */\n \n static PRCallOnceType _pr_init_ipv6_once;\n \n-static PRStatus PR_CALLBACK\n-_pr_init_ipv6(void)\n-{\n-    const PRIOMethods* stubMethods;\n-\n-#if defined(_PR_INET6_PROBE)\n-    ipv6_is_present = _pr_probe_ipv6_presence();\n-    if (ipv6_is_present) {\n-        return PR_SUCCESS;\n-    }\n-#endif\n-\n-    _pr_ipv6_to_ipv4_id = PR_GetUniqueIdentity(\"Ipv6_to_Ipv4 layer\");\n-    PR_ASSERT(PR_INVALID_IO_LAYER != _pr_ipv6_to_ipv4_id);\n-\n-    stubMethods = PR_GetDefaultIOMethods();\n-\n-    ipv6_to_v4_tcpMethods = *stubMethods; /* first get the entire batch */\n-    /* then override the ones we care about */\n-    ipv6_to_v4_tcpMethods.connect = Ipv6ToIpv4SocketConnect;\n-    ipv6_to_v4_tcpMethods.bind = Ipv6ToIpv4SocketBind;\n-    ipv6_to_v4_tcpMethods.accept = Ipv6ToIpv4SocketAccept;\n-    ipv6_to_v4_tcpMethods.acceptread = Ipv6ToIpv4SocketAcceptRead;\n-    ipv6_to_v4_tcpMethods.getsockname = Ipv6ToIpv4SocketGetName;\n-    ipv6_to_v4_tcpMethods.getpeername = Ipv6ToIpv4SocketGetPeerName;\n-    /*\n-        ipv6_to_v4_tcpMethods.getsocketoption = Ipv6ToIpv4GetSocketOption;\n-        ipv6_to_v4_tcpMethods.setsocketoption = Ipv6ToIpv4SetSocketOption;\n-    */\n-    ipv6_to_v4_udpMethods = *stubMethods; /* first get the entire batch */\n-    /* then override the ones we care about */\n-    ipv6_to_v4_udpMethods.connect = Ipv6ToIpv4SocketConnect;\n-    ipv6_to_v4_udpMethods.bind = Ipv6ToIpv4SocketBind;\n-    ipv6_to_v4_udpMethods.sendto = Ipv6ToIpv4SocketSendTo;\n-    ipv6_to_v4_udpMethods.recvfrom = Ipv6ToIpv4SocketRecvFrom;\n-    ipv6_to_v4_udpMethods.getsockname = Ipv6ToIpv4SocketGetName;\n-    ipv6_to_v4_udpMethods.getpeername = Ipv6ToIpv4SocketGetPeerName;\n-    /*\n-        ipv6_to_v4_udpMethods.getsocketoption = Ipv6ToIpv4GetSocketOption;\n-        ipv6_to_v4_udpMethods.setsocketoption = Ipv6ToIpv4SetSocketOption;\n-    */\n+static PRStatus PR_CALLBACK _pr_init_ipv6(void) {\n+  const PRIOMethods* stubMethods;\n+\n+#  if defined(_PR_INET6_PROBE)\n+  ipv6_is_present = _pr_probe_ipv6_presence();\n+  if (ipv6_is_present) {\n     return PR_SUCCESS;\n+  }\n+#  endif\n+\n+  _pr_ipv6_to_ipv4_id = PR_GetUniqueIdentity(\"Ipv6_to_Ipv4 layer\");\n+  PR_ASSERT(PR_INVALID_IO_LAYER != _pr_ipv6_to_ipv4_id);\n+\n+  stubMethods = PR_GetDefaultIOMethods();\n+\n+  ipv6_to_v4_tcpMethods = *stubMethods; /* first get the entire batch */\n+  /* then override the ones we care about */\n+  ipv6_to_v4_tcpMethods.connect = Ipv6ToIpv4SocketConnect;\n+  ipv6_to_v4_tcpMethods.bind = Ipv6ToIpv4SocketBind;\n+  ipv6_to_v4_tcpMethods.accept = Ipv6ToIpv4SocketAccept;\n+  ipv6_to_v4_tcpMethods.acceptread = Ipv6ToIpv4SocketAcceptRead;\n+  ipv6_to_v4_tcpMethods.getsockname = Ipv6ToIpv4SocketGetName;\n+  ipv6_to_v4_tcpMethods.getpeername = Ipv6ToIpv4SocketGetPeerName;\n+  /*\n+      ipv6_to_v4_tcpMethods.getsocketoption = Ipv6ToIpv4GetSocketOption;\n+      ipv6_to_v4_tcpMethods.setsocketoption = Ipv6ToIpv4SetSocketOption;\n+  */\n+  ipv6_to_v4_udpMethods = *stubMethods; /* first get the entire batch */\n+  /* then override the ones we care about */\n+  ipv6_to_v4_udpMethods.connect = Ipv6ToIpv4SocketConnect;\n+  ipv6_to_v4_udpMethods.bind = Ipv6ToIpv4SocketBind;\n+  ipv6_to_v4_udpMethods.sendto = Ipv6ToIpv4SocketSendTo;\n+  ipv6_to_v4_udpMethods.recvfrom = Ipv6ToIpv4SocketRecvFrom;\n+  ipv6_to_v4_udpMethods.getsockname = Ipv6ToIpv4SocketGetName;\n+  ipv6_to_v4_udpMethods.getpeername = Ipv6ToIpv4SocketGetPeerName;\n+  /*\n+      ipv6_to_v4_udpMethods.getsocketoption = Ipv6ToIpv4GetSocketOption;\n+      ipv6_to_v4_udpMethods.setsocketoption = Ipv6ToIpv4SetSocketOption;\n+  */\n+  return PR_SUCCESS;\n }\n \n-#if defined(_PR_INET6_PROBE)\n-PRBool\n-_pr_ipv6_is_present(void)\n-{\n-    if (PR_CallOnce(&_pr_init_ipv6_once, _pr_init_ipv6) != PR_SUCCESS) {\n-        return PR_FALSE;\n-    }\n-    return ipv6_is_present;\n+#  if defined(_PR_INET6_PROBE)\n+PRBool _pr_ipv6_is_present(void) {\n+  if (PR_CallOnce(&_pr_init_ipv6_once, _pr_init_ipv6) != PR_SUCCESS) {\n+    return PR_FALSE;\n+  }\n+  return ipv6_is_present;\n }\n-#endif\n-\n-PR_IMPLEMENT(PRStatus)\n-_pr_push_ipv6toipv4_layer(PRFileDesc* fd)\n-{\n-    PRFileDesc* ipv6_fd = NULL;\n-\n-    if (PR_CallOnce(&_pr_init_ipv6_once, _pr_init_ipv6) != PR_SUCCESS) {\n-        return PR_FAILURE;\n-    }\n-\n-    /*\n-     * For platforms with no support for IPv6\n-     * create layered socket for IPv4-mapped IPv6 addresses\n-     */\n-    if (fd->methods->file_type == PR_DESC_SOCKET_TCP)\n-        ipv6_fd = PR_CreateIOLayerStub(_pr_ipv6_to_ipv4_id, &ipv6_to_v4_tcpMethods);\n-    else\n-        ipv6_fd = PR_CreateIOLayerStub(_pr_ipv6_to_ipv4_id, &ipv6_to_v4_udpMethods);\n-    if (NULL == ipv6_fd) {\n-        goto errorExit;\n-    }\n-    ipv6_fd->secret = NULL;\n-\n-    if (PR_PushIOLayer(fd, PR_TOP_IO_LAYER, ipv6_fd) == PR_FAILURE) {\n-        goto errorExit;\n-    }\n+#  endif\n \n-    return PR_SUCCESS;\n-errorExit:\n+PR_IMPLEMENT(PRStatus) _pr_push_ipv6toipv4_layer(PRFileDesc* fd) {\n+  PRFileDesc* ipv6_fd = NULL;\n \n-    if (ipv6_fd) {\n-        ipv6_fd->dtor(ipv6_fd);\n-    }\n+  if (PR_CallOnce(&_pr_init_ipv6_once, _pr_init_ipv6) != PR_SUCCESS) {\n     return PR_FAILURE;\n+  }\n+\n+  /*\n+   * For platforms with no support for IPv6\n+   * create layered socket for IPv4-mapped IPv6 addresses\n+   */\n+  if (fd->methods->file_type == PR_DESC_SOCKET_TCP)\n+    ipv6_fd = PR_CreateIOLayerStub(_pr_ipv6_to_ipv4_id, &ipv6_to_v4_tcpMethods);\n+  else\n+    ipv6_fd = PR_CreateIOLayerStub(_pr_ipv6_to_ipv4_id, &ipv6_to_v4_udpMethods);\n+  if (NULL == ipv6_fd) {\n+    goto errorExit;\n+  }\n+  ipv6_fd->secret = NULL;\n+\n+  if (PR_PushIOLayer(fd, PR_TOP_IO_LAYER, ipv6_fd) == PR_FAILURE) {\n+    goto errorExit;\n+  }\n+\n+  return PR_SUCCESS;\n+errorExit:\n+\n+  if (ipv6_fd) {\n+    ipv6_fd->dtor(ipv6_fd);\n+  }\n+  return PR_FAILURE;\n }\n \n #endif /* !defined(_PR_INET6) || defined(_PR_INET6_PROBE) */\ndiff --git a/nspr/pr/src/io/prlayer.c b/nspr/pr/src/io/prlayer.c\nindex e2ab5a3..8bf70c0 100644\n--- a/nspr/pr/src/io/prlayer.c\n+++ b/nspr/pr/src/io/prlayer.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -17,471 +18,409 @@\n #include <string.h> /* for memset() */\n static PRStatus _PR_DestroyIOLayer(PRFileDesc* stack);\n \n-void PR_CALLBACK\n-pl_FDDestructor(PRFileDesc* fd)\n-{\n-    PR_ASSERT(fd != NULL);\n-    if (NULL != fd->lower) {\n-        fd->lower->higher = fd->higher;\n-    }\n-    if (NULL != fd->higher) {\n-        fd->higher->lower = fd->lower;\n-    }\n-    PR_DELETE(fd);\n+void PR_CALLBACK pl_FDDestructor(PRFileDesc* fd) {\n+  PR_ASSERT(fd != NULL);\n+  if (NULL != fd->lower) {\n+    fd->lower->higher = fd->higher;\n+  }\n+  if (NULL != fd->higher) {\n+    fd->higher->lower = fd->lower;\n+  }\n+  PR_DELETE(fd);\n }\n \n /*\n ** Default methods that just call down to the next fd.\n */\n-static PRStatus PR_CALLBACK\n-pl_TopClose(PRFileDesc* fd)\n-{\n-    PRFileDesc *top, *lower;\n-    PRStatus rv;\n+static PRStatus PR_CALLBACK pl_TopClose(PRFileDesc* fd) {\n+  PRFileDesc *top, *lower;\n+  PRStatus rv;\n \n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n-    PR_ASSERT(fd->secret == NULL);\n-    PR_ASSERT(fd->methods->file_type == PR_DESC_LAYERED);\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n+  PR_ASSERT(fd->secret == NULL);\n+  PR_ASSERT(fd->methods->file_type == PR_DESC_LAYERED);\n \n-    if (PR_IO_LAYER_HEAD == fd->identity) {\n-        /*\n-         * new style stack; close all the layers, before deleting the\n-         * stack head\n-         */\n-        rv = fd->lower->methods->close(fd->lower);\n-        _PR_DestroyIOLayer(fd);\n-        return rv;\n-    }\n-    if ((fd->higher) && (PR_IO_LAYER_HEAD == fd->higher->identity)) {\n-        /*\n-         * lower layers of new style stack\n-         */\n-        lower = fd->lower;\n-        /*\n-         * pop and cleanup current layer\n-         */\n-        top = PR_PopIOLayer(fd->higher, PR_TOP_IO_LAYER);\n-        top->dtor(top);\n-        /*\n-         * then call lower layer\n-         */\n-        return (lower->methods->close(lower));\n-    } else {\n-        /* old style stack */\n-        top = PR_PopIOLayer(fd, PR_TOP_IO_LAYER);\n-        top->dtor(top);\n-        return (fd->methods->close)(fd);\n-    }\n+  if (PR_IO_LAYER_HEAD == fd->identity) {\n+    /*\n+     * new style stack; close all the layers, before deleting the\n+     * stack head\n+     */\n+    rv = fd->lower->methods->close(fd->lower);\n+    _PR_DestroyIOLayer(fd);\n+    return rv;\n+  }\n+  if ((fd->higher) && (PR_IO_LAYER_HEAD == fd->higher->identity)) {\n+    /*\n+     * lower layers of new style stack\n+     */\n+    lower = fd->lower;\n+    /*\n+     * pop and cleanup current layer\n+     */\n+    top = PR_PopIOLayer(fd->higher, PR_TOP_IO_LAYER);\n+    top->dtor(top);\n+    /*\n+     * then call lower layer\n+     */\n+    return (lower->methods->close(lower));\n+  } else {\n+    /* old style stack */\n+    top = PR_PopIOLayer(fd, PR_TOP_IO_LAYER);\n+    top->dtor(top);\n+    return (fd->methods->close)(fd);\n+  }\n }\n \n-static PRInt32 PR_CALLBACK\n-pl_DefRead(PRFileDesc* fd, void* buf,\n-           PRInt32 amount)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRInt32 PR_CALLBACK pl_DefRead(PRFileDesc* fd, void* buf,\n+                                      PRInt32 amount) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->read)(fd->lower, buf, amount);\n+  return (fd->lower->methods->read)(fd->lower, buf, amount);\n }\n \n-static PRInt32 PR_CALLBACK\n-pl_DefWrite(PRFileDesc* fd, const void* buf,\n-            PRInt32 amount)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRInt32 PR_CALLBACK pl_DefWrite(PRFileDesc* fd, const void* buf,\n+                                       PRInt32 amount) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->write)(fd->lower, buf, amount);\n+  return (fd->lower->methods->write)(fd->lower, buf, amount);\n }\n \n-static PRInt32 PR_CALLBACK\n-pl_DefAvailable(PRFileDesc* fd)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRInt32 PR_CALLBACK pl_DefAvailable(PRFileDesc* fd) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->available)(fd->lower);\n+  return (fd->lower->methods->available)(fd->lower);\n }\n \n-static PRInt64 PR_CALLBACK\n-pl_DefAvailable64(PRFileDesc* fd)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRInt64 PR_CALLBACK pl_DefAvailable64(PRFileDesc* fd) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->available64)(fd->lower);\n+  return (fd->lower->methods->available64)(fd->lower);\n }\n \n-static PRStatus PR_CALLBACK\n-pl_DefFsync(PRFileDesc* fd)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRStatus PR_CALLBACK pl_DefFsync(PRFileDesc* fd) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->fsync)(fd->lower);\n+  return (fd->lower->methods->fsync)(fd->lower);\n }\n \n-static PRInt32 PR_CALLBACK\n-pl_DefSeek(PRFileDesc* fd, PRInt32 offset,\n-           PRSeekWhence how)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRInt32 PR_CALLBACK pl_DefSeek(PRFileDesc* fd, PRInt32 offset,\n+                                      PRSeekWhence how) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->seek)(fd->lower, offset, how);\n+  return (fd->lower->methods->seek)(fd->lower, offset, how);\n }\n \n-static PRInt64 PR_CALLBACK\n-pl_DefSeek64(PRFileDesc* fd, PRInt64 offset,\n-             PRSeekWhence how)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRInt64 PR_CALLBACK pl_DefSeek64(PRFileDesc* fd, PRInt64 offset,\n+                                        PRSeekWhence how) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->seek64)(fd->lower, offset, how);\n+  return (fd->lower->methods->seek64)(fd->lower, offset, how);\n }\n \n-static PRStatus PR_CALLBACK\n-pl_DefFileInfo(PRFileDesc* fd, PRFileInfo* info)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRStatus PR_CALLBACK pl_DefFileInfo(PRFileDesc* fd, PRFileInfo* info) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->fileInfo)(fd->lower, info);\n+  return (fd->lower->methods->fileInfo)(fd->lower, info);\n }\n \n-static PRStatus PR_CALLBACK\n-pl_DefFileInfo64(PRFileDesc* fd,\n-                 PRFileInfo64* info)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRStatus PR_CALLBACK pl_DefFileInfo64(PRFileDesc* fd,\n+                                             PRFileInfo64* info) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->fileInfo64)(fd->lower, info);\n+  return (fd->lower->methods->fileInfo64)(fd->lower, info);\n }\n \n-static PRInt32 PR_CALLBACK\n-pl_DefWritev(PRFileDesc* fd, const PRIOVec* iov,\n-             PRInt32 size, PRIntervalTime timeout)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRInt32 PR_CALLBACK pl_DefWritev(PRFileDesc* fd, const PRIOVec* iov,\n+                                        PRInt32 size, PRIntervalTime timeout) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->writev)(fd->lower, iov, size, timeout);\n+  return (fd->lower->methods->writev)(fd->lower, iov, size, timeout);\n }\n \n-static PRStatus PR_CALLBACK\n-pl_DefConnect(PRFileDesc* fd, const PRNetAddr* addr,\n-              PRIntervalTime timeout)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRStatus PR_CALLBACK pl_DefConnect(PRFileDesc* fd, const PRNetAddr* addr,\n+                                          PRIntervalTime timeout) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->connect)(fd->lower, addr, timeout);\n+  return (fd->lower->methods->connect)(fd->lower, addr, timeout);\n }\n \n-static PRStatus PR_CALLBACK\n-pl_DefConnectcontinue(PRFileDesc* fd,\n-                      PRInt16 out_flags)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRStatus PR_CALLBACK pl_DefConnectcontinue(PRFileDesc* fd,\n+                                                  PRInt16 out_flags) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->connectcontinue)(fd->lower, out_flags);\n+  return (fd->lower->methods->connectcontinue)(fd->lower, out_flags);\n }\n \n-static PRFileDesc* PR_CALLBACK\n-pl_TopAccept(PRFileDesc* fd, PRNetAddr* addr,\n-             PRIntervalTime timeout)\n-{\n-    PRStatus rv;\n-    PRFileDesc *newfd, *layer = fd;\n-    PRFileDesc* newstack;\n-    PRBool newstyle_stack = PR_FALSE;\n-\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n-\n-    /* test for new style stack */\n-    while (NULL != layer->higher) {\n-        layer = layer->higher;\n-    }\n-    newstyle_stack = (PR_IO_LAYER_HEAD == layer->identity) ? PR_TRUE : PR_FALSE;\n-    newstack = PR_NEW(PRFileDesc);\n-    if (NULL == newstack) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n-    }\n-    *newstack = *fd; /* make a copy of the accepting layer */\n-\n-    newfd = (fd->lower->methods->accept)(fd->lower, addr, timeout);\n-    if (NULL == newfd) {\n-        PR_DELETE(newstack);\n-        return NULL;\n-    }\n+static PRFileDesc* PR_CALLBACK pl_TopAccept(PRFileDesc* fd, PRNetAddr* addr,\n+                                            PRIntervalTime timeout) {\n+  PRStatus rv;\n+  PRFileDesc *newfd, *layer = fd;\n+  PRFileDesc* newstack;\n+  PRBool newstyle_stack = PR_FALSE;\n+\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n+\n+  /* test for new style stack */\n+  while (NULL != layer->higher) {\n+    layer = layer->higher;\n+  }\n+  newstyle_stack = (PR_IO_LAYER_HEAD == layer->identity) ? PR_TRUE : PR_FALSE;\n+  newstack = PR_NEW(PRFileDesc);\n+  if (NULL == newstack) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n+  *newstack = *fd; /* make a copy of the accepting layer */\n \n-    if (newstyle_stack) {\n-        newstack->lower = newfd;\n-        newfd->higher = newstack;\n-        return newstack;\n-    }\n-    /* this PR_PushIOLayer call cannot fail */\n-    rv = PR_PushIOLayer(newfd, PR_TOP_IO_LAYER, newstack);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    return newfd; /* that's it */\n+  newfd = (fd->lower->methods->accept)(fd->lower, addr, timeout);\n+  if (NULL == newfd) {\n+    PR_DELETE(newstack);\n+    return NULL;\n+  }\n+\n+  if (newstyle_stack) {\n+    newstack->lower = newfd;\n+    newfd->higher = newstack;\n+    return newstack;\n+  }\n+  /* this PR_PushIOLayer call cannot fail */\n+  rv = PR_PushIOLayer(newfd, PR_TOP_IO_LAYER, newstack);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  return newfd; /* that's it */\n }\n \n-static PRStatus PR_CALLBACK\n-pl_DefBind(PRFileDesc* fd, const PRNetAddr* addr)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRStatus PR_CALLBACK pl_DefBind(PRFileDesc* fd, const PRNetAddr* addr) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->bind)(fd->lower, addr);\n+  return (fd->lower->methods->bind)(fd->lower, addr);\n }\n \n-static PRStatus PR_CALLBACK\n-pl_DefListen(PRFileDesc* fd, PRIntn backlog)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRStatus PR_CALLBACK pl_DefListen(PRFileDesc* fd, PRIntn backlog) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->listen)(fd->lower, backlog);\n+  return (fd->lower->methods->listen)(fd->lower, backlog);\n }\n \n-static PRStatus PR_CALLBACK\n-pl_DefShutdown(PRFileDesc* fd, PRIntn how)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRStatus PR_CALLBACK pl_DefShutdown(PRFileDesc* fd, PRIntn how) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->shutdown)(fd->lower, how);\n+  return (fd->lower->methods->shutdown)(fd->lower, how);\n }\n \n-static PRInt32 PR_CALLBACK\n-pl_DefRecv(PRFileDesc* fd, void* buf, PRInt32 amount,\n-           PRIntn flags, PRIntervalTime timeout)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRInt32 PR_CALLBACK pl_DefRecv(PRFileDesc* fd, void* buf, PRInt32 amount,\n+                                      PRIntn flags, PRIntervalTime timeout) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->recv)(fd->lower, buf, amount, flags, timeout);\n+  return (fd->lower->methods->recv)(fd->lower, buf, amount, flags, timeout);\n }\n \n-static PRInt32 PR_CALLBACK\n-pl_DefSend(PRFileDesc* fd, const void* buf,\n-           PRInt32 amount, PRIntn flags,\n-           PRIntervalTime timeout)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRInt32 PR_CALLBACK pl_DefSend(PRFileDesc* fd, const void* buf,\n+                                      PRInt32 amount, PRIntn flags,\n+                                      PRIntervalTime timeout) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->send)(fd->lower, buf, amount, flags, timeout);\n+  return (fd->lower->methods->send)(fd->lower, buf, amount, flags, timeout);\n }\n \n-static PRInt32 PR_CALLBACK\n-pl_DefRecvfrom(PRFileDesc* fd, void* buf,\n-               PRInt32 amount, PRIntn flags,\n-               PRNetAddr* addr,\n-               PRIntervalTime timeout)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n-\n-    return (fd->lower->methods->recvfrom)(fd->lower, buf, amount, flags, addr,\n-                                          timeout);\n-}\n-\n-static PRInt32 PR_CALLBACK\n-pl_DefSendto(PRFileDesc* fd, const void* buf,\n-             PRInt32 amount, PRIntn flags,\n-             const PRNetAddr* addr,\n-             PRIntervalTime timeout)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRInt32 PR_CALLBACK pl_DefRecvfrom(PRFileDesc* fd, void* buf,\n+                                          PRInt32 amount, PRIntn flags,\n+                                          PRNetAddr* addr,\n+                                          PRIntervalTime timeout) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->sendto)(fd->lower, buf, amount, flags, addr,\n+  return (fd->lower->methods->recvfrom)(fd->lower, buf, amount, flags, addr,\n                                         timeout);\n }\n \n-static PRInt16 PR_CALLBACK\n-pl_DefPoll(PRFileDesc* fd, PRInt16 in_flags,\n-           PRInt16* out_flags)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRInt32 PR_CALLBACK pl_DefSendto(PRFileDesc* fd, const void* buf,\n+                                        PRInt32 amount, PRIntn flags,\n+                                        const PRNetAddr* addr,\n+                                        PRIntervalTime timeout) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->poll)(fd->lower, in_flags, out_flags);\n+  return (fd->lower->methods->sendto)(fd->lower, buf, amount, flags, addr,\n+                                      timeout);\n }\n \n-static PRInt32 PR_CALLBACK\n-pl_DefAcceptread(PRFileDesc* sd, PRFileDesc** nd,\n-                 PRNetAddr** raddr, void* buf,\n-                 PRInt32 amount, PRIntervalTime t)\n-{\n-    PRInt32 nbytes;\n-    PRStatus rv;\n-    PRFileDesc* newstack;\n-    PRFileDesc* layer = sd;\n-    PRBool newstyle_stack = PR_FALSE;\n-\n-    PR_ASSERT(sd != NULL);\n-    PR_ASSERT(sd->lower != NULL);\n-\n-    /* test for new style stack */\n-    while (NULL != layer->higher) {\n-        layer = layer->higher;\n-    }\n-    newstyle_stack = (PR_IO_LAYER_HEAD == layer->identity) ? PR_TRUE : PR_FALSE;\n-    newstack = PR_NEW(PRFileDesc);\n-    if (NULL == newstack) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return -1;\n-    }\n-    *newstack = *sd; /* make a copy of the accepting layer */\n+static PRInt16 PR_CALLBACK pl_DefPoll(PRFileDesc* fd, PRInt16 in_flags,\n+                                      PRInt16* out_flags) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    nbytes = sd->lower->methods->acceptread(sd->lower, nd, raddr, buf, amount, t);\n-    if (-1 == nbytes) {\n-        PR_DELETE(newstack);\n-        return nbytes;\n-    }\n-    if (newstyle_stack) {\n-        newstack->lower = *nd;\n-        (*nd)->higher = newstack;\n-        *nd = newstack;\n-        return nbytes;\n-    }\n-    /* this PR_PushIOLayer call cannot fail */\n-    rv = PR_PushIOLayer(*nd, PR_TOP_IO_LAYER, newstack);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+  return (fd->lower->methods->poll)(fd->lower, in_flags, out_flags);\n+}\n+\n+static PRInt32 PR_CALLBACK pl_DefAcceptread(PRFileDesc* sd, PRFileDesc** nd,\n+                                            PRNetAddr** raddr, void* buf,\n+                                            PRInt32 amount, PRIntervalTime t) {\n+  PRInt32 nbytes;\n+  PRStatus rv;\n+  PRFileDesc* newstack;\n+  PRFileDesc* layer = sd;\n+  PRBool newstyle_stack = PR_FALSE;\n+\n+  PR_ASSERT(sd != NULL);\n+  PR_ASSERT(sd->lower != NULL);\n+\n+  /* test for new style stack */\n+  while (NULL != layer->higher) {\n+    layer = layer->higher;\n+  }\n+  newstyle_stack = (PR_IO_LAYER_HEAD == layer->identity) ? PR_TRUE : PR_FALSE;\n+  newstack = PR_NEW(PRFileDesc);\n+  if (NULL == newstack) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return -1;\n+  }\n+  *newstack = *sd; /* make a copy of the accepting layer */\n+\n+  nbytes = sd->lower->methods->acceptread(sd->lower, nd, raddr, buf, amount, t);\n+  if (-1 == nbytes) {\n+    PR_DELETE(newstack);\n+    return nbytes;\n+  }\n+  if (newstyle_stack) {\n+    newstack->lower = *nd;\n+    (*nd)->higher = newstack;\n+    *nd = newstack;\n     return nbytes;\n+  }\n+  /* this PR_PushIOLayer call cannot fail */\n+  rv = PR_PushIOLayer(*nd, PR_TOP_IO_LAYER, newstack);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  return nbytes;\n }\n \n-static PRInt32 PR_CALLBACK\n-pl_DefTransmitfile(PRFileDesc* sd, PRFileDesc* fd,\n-                   const void* headers, PRInt32 hlen,\n-                   PRTransmitFileFlags flags,\n-                   PRIntervalTime t)\n-{\n-    PR_ASSERT(sd != NULL);\n-    PR_ASSERT(sd->lower != NULL);\n-\n-    return sd->lower->methods->transmitfile(sd->lower, fd, headers, hlen, flags,\n-                                            t);\n+static PRInt32 PR_CALLBACK pl_DefTransmitfile(PRFileDesc* sd, PRFileDesc* fd,\n+                                              const void* headers, PRInt32 hlen,\n+                                              PRTransmitFileFlags flags,\n+                                              PRIntervalTime t) {\n+  PR_ASSERT(sd != NULL);\n+  PR_ASSERT(sd->lower != NULL);\n+\n+  return sd->lower->methods->transmitfile(sd->lower, fd, headers, hlen, flags,\n+                                          t);\n }\n \n-static PRStatus PR_CALLBACK\n-pl_DefGetsockname(PRFileDesc* fd, PRNetAddr* addr)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRStatus PR_CALLBACK pl_DefGetsockname(PRFileDesc* fd, PRNetAddr* addr) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->getsockname)(fd->lower, addr);\n+  return (fd->lower->methods->getsockname)(fd->lower, addr);\n }\n \n-static PRStatus PR_CALLBACK\n-pl_DefGetpeername(PRFileDesc* fd, PRNetAddr* addr)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRStatus PR_CALLBACK pl_DefGetpeername(PRFileDesc* fd, PRNetAddr* addr) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->getpeername)(fd->lower, addr);\n+  return (fd->lower->methods->getpeername)(fd->lower, addr);\n }\n \n-static PRStatus PR_CALLBACK\n-pl_DefGetsocketoption(PRFileDesc* fd,\n-                      PRSocketOptionData* data)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+static PRStatus PR_CALLBACK pl_DefGetsocketoption(PRFileDesc* fd,\n+                                                  PRSocketOptionData* data) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->getsocketoption)(fd->lower, data);\n+  return (fd->lower->methods->getsocketoption)(fd->lower, data);\n }\n \n static PRStatus PR_CALLBACK\n-pl_DefSetsocketoption(PRFileDesc* fd, const PRSocketOptionData* data)\n-{\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n+pl_DefSetsocketoption(PRFileDesc* fd, const PRSocketOptionData* data) {\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n \n-    return (fd->lower->methods->setsocketoption)(fd->lower, data);\n+  return (fd->lower->methods->setsocketoption)(fd->lower, data);\n }\n \n-static PRInt32 PR_CALLBACK\n-pl_DefSendfile(PRFileDesc* sd, PRSendFileData* sfd,\n-               PRTransmitFileFlags flags,\n-               PRIntervalTime timeout)\n-{\n-    PR_ASSERT(sd != NULL);\n-    PR_ASSERT(sd->lower != NULL);\n+static PRInt32 PR_CALLBACK pl_DefSendfile(PRFileDesc* sd, PRSendFileData* sfd,\n+                                          PRTransmitFileFlags flags,\n+                                          PRIntervalTime timeout) {\n+  PR_ASSERT(sd != NULL);\n+  PR_ASSERT(sd->lower != NULL);\n \n-    return sd->lower->methods->sendfile(sd->lower, sfd, flags, timeout);\n+  return sd->lower->methods->sendfile(sd->lower, sfd, flags, timeout);\n }\n \n /* Methods for the top of the stack.  Just call down to the next fd. */\n-static PRIOMethods pl_methods = { PR_DESC_LAYERED,\n-                                  pl_TopClose,\n-                                  pl_DefRead,\n-                                  pl_DefWrite,\n-                                  pl_DefAvailable,\n-                                  pl_DefAvailable64,\n-                                  pl_DefFsync,\n-                                  pl_DefSeek,\n-                                  pl_DefSeek64,\n-                                  pl_DefFileInfo,\n-                                  pl_DefFileInfo64,\n-                                  pl_DefWritev,\n-                                  pl_DefConnect,\n-                                  pl_TopAccept,\n-                                  pl_DefBind,\n-                                  pl_DefListen,\n-                                  pl_DefShutdown,\n-                                  pl_DefRecv,\n-                                  pl_DefSend,\n-                                  pl_DefRecvfrom,\n-                                  pl_DefSendto,\n-                                  pl_DefPoll,\n-                                  pl_DefAcceptread,\n-                                  pl_DefTransmitfile,\n-                                  pl_DefGetsockname,\n-                                  pl_DefGetpeername,\n-                                  (PRReservedFN)_PR_InvalidInt,\n-                                  (PRReservedFN)_PR_InvalidInt,\n-                                  pl_DefGetsocketoption,\n-                                  pl_DefSetsocketoption,\n-                                  pl_DefSendfile,\n-                                  pl_DefConnectcontinue,\n-                                  (PRReservedFN)_PR_InvalidInt,\n-                                  (PRReservedFN)_PR_InvalidInt,\n-                                  (PRReservedFN)_PR_InvalidInt,\n-                                  (PRReservedFN)_PR_InvalidInt };\n-\n-PR_IMPLEMENT(const PRIOMethods*)\n-PR_GetDefaultIOMethods(void)\n-{\n-    return &pl_methods;\n+static PRIOMethods pl_methods = {PR_DESC_LAYERED,\n+                                 pl_TopClose,\n+                                 pl_DefRead,\n+                                 pl_DefWrite,\n+                                 pl_DefAvailable,\n+                                 pl_DefAvailable64,\n+                                 pl_DefFsync,\n+                                 pl_DefSeek,\n+                                 pl_DefSeek64,\n+                                 pl_DefFileInfo,\n+                                 pl_DefFileInfo64,\n+                                 pl_DefWritev,\n+                                 pl_DefConnect,\n+                                 pl_TopAccept,\n+                                 pl_DefBind,\n+                                 pl_DefListen,\n+                                 pl_DefShutdown,\n+                                 pl_DefRecv,\n+                                 pl_DefSend,\n+                                 pl_DefRecvfrom,\n+                                 pl_DefSendto,\n+                                 pl_DefPoll,\n+                                 pl_DefAcceptread,\n+                                 pl_DefTransmitfile,\n+                                 pl_DefGetsockname,\n+                                 pl_DefGetpeername,\n+                                 (PRReservedFN)_PR_InvalidInt,\n+                                 (PRReservedFN)_PR_InvalidInt,\n+                                 pl_DefGetsocketoption,\n+                                 pl_DefSetsocketoption,\n+                                 pl_DefSendfile,\n+                                 pl_DefConnectcontinue,\n+                                 (PRReservedFN)_PR_InvalidInt,\n+                                 (PRReservedFN)_PR_InvalidInt,\n+                                 (PRReservedFN)_PR_InvalidInt,\n+                                 (PRReservedFN)_PR_InvalidInt};\n+\n+PR_IMPLEMENT(const PRIOMethods*) PR_GetDefaultIOMethods(void) {\n+  return &pl_methods;\n } /* PR_GetDefaultIOMethods */\n \n PR_IMPLEMENT(PRFileDesc*)\n-PR_CreateIOLayerStub(PRDescIdentity ident, const PRIOMethods* methods)\n-{\n-    PRFileDesc* fd = NULL;\n-    PR_ASSERT((PR_NSPR_IO_LAYER != ident) && (PR_TOP_IO_LAYER != ident));\n-    if ((PR_NSPR_IO_LAYER == ident) || (PR_TOP_IO_LAYER == ident)) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+PR_CreateIOLayerStub(PRDescIdentity ident, const PRIOMethods* methods) {\n+  PRFileDesc* fd = NULL;\n+  PR_ASSERT((PR_NSPR_IO_LAYER != ident) && (PR_TOP_IO_LAYER != ident));\n+  if ((PR_NSPR_IO_LAYER == ident) || (PR_TOP_IO_LAYER == ident)) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  } else {\n+    fd = PR_NEWZAP(PRFileDesc);\n+    if (NULL == fd) {\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n     } else {\n-        fd = PR_NEWZAP(PRFileDesc);\n-        if (NULL == fd) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        } else {\n-            fd->methods = methods;\n-            fd->dtor = pl_FDDestructor;\n-            fd->identity = ident;\n-        }\n+      fd->methods = methods;\n+      fd->dtor = pl_FDDestructor;\n+      fd->identity = ident;\n     }\n-    return fd;\n+  }\n+  return fd;\n } /* PR_CreateIOLayerStub */\n \n /*\n@@ -492,24 +431,22 @@ PR_CreateIOLayerStub(PRDescIdentity ident, const PRIOMethods* methods)\n  *      style stack.\n  */\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_CreateIOLayer(PRFileDesc* top)\n-{\n-    PRFileDesc* fd = NULL;\n-\n-    fd = PR_NEWZAP(PRFileDesc);\n-    if (NULL == fd) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-    } else {\n-        fd->methods = &pl_methods;\n-        fd->dtor = pl_FDDestructor;\n-        fd->identity = PR_IO_LAYER_HEAD;\n-        fd->higher = NULL;\n-        fd->lower = top;\n-        top->higher = fd;\n-        top->lower = NULL;\n-    }\n-    return fd;\n+PR_IMPLEMENT(PRFileDesc*) PR_CreateIOLayer(PRFileDesc* top) {\n+  PRFileDesc* fd = NULL;\n+\n+  fd = PR_NEWZAP(PRFileDesc);\n+  if (NULL == fd) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  } else {\n+    fd->methods = &pl_methods;\n+    fd->dtor = pl_FDDestructor;\n+    fd->identity = PR_IO_LAYER_HEAD;\n+    fd->higher = NULL;\n+    fd->lower = top;\n+    top->higher = fd;\n+    top->lower = NULL;\n+  }\n+  return fd;\n } /* PR_CreateIOLayer */\n \n /*\n@@ -517,279 +454,263 @@ PR_CreateIOLayer(PRFileDesc* top)\n  *      Delete the stack head of a new style stack.\n  */\n \n-static PRStatus\n-_PR_DestroyIOLayer(PRFileDesc* stack)\n-{\n-    if (NULL == stack) {\n-        return PR_FAILURE;\n-    }\n+static PRStatus _PR_DestroyIOLayer(PRFileDesc* stack) {\n+  if (NULL == stack) {\n+    return PR_FAILURE;\n+  }\n \n-    PR_DELETE(stack);\n-    return PR_SUCCESS;\n+  PR_DELETE(stack);\n+  return PR_SUCCESS;\n } /* _PR_DestroyIOLayer */\n \n PR_IMPLEMENT(PRStatus)\n-PR_PushIOLayer(PRFileDesc* stack, PRDescIdentity id, PRFileDesc* fd)\n-{\n-    PRFileDesc* insert = PR_GetIdentitiesLayer(stack, id);\n-\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(stack != NULL);\n-    PR_ASSERT(insert != NULL);\n-    PR_ASSERT(PR_IO_LAYER_HEAD != id);\n-    if ((NULL == stack) || (NULL == fd) || (NULL == insert)) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+PR_PushIOLayer(PRFileDesc* stack, PRDescIdentity id, PRFileDesc* fd) {\n+  PRFileDesc* insert = PR_GetIdentitiesLayer(stack, id);\n+\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(stack != NULL);\n+  PR_ASSERT(insert != NULL);\n+  PR_ASSERT(PR_IO_LAYER_HEAD != id);\n+  if ((NULL == stack) || (NULL == fd) || (NULL == insert)) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+\n+  if (stack == insert) {\n+    /* going on top of the stack */\n+    /* old-style stack */\n+    PRFileDesc copy = *stack;\n+    *stack = *fd;\n+    *fd = copy;\n+    fd->higher = stack;\n+    if (fd->lower) {\n+      PR_ASSERT(fd->lower->higher == stack);\n+      fd->lower->higher = fd;\n+    }\n+    stack->lower = fd;\n+    stack->higher = NULL;\n+  } else {\n+    /*\n+     * going somewhere in the middle of the stack for both old and new\n+     * style stacks, or going on top of stack for new style stack\n+     */\n+    fd->lower = insert;\n+    fd->higher = insert->higher;\n \n-    if (stack == insert) {\n-        /* going on top of the stack */\n-        /* old-style stack */\n-        PRFileDesc copy = *stack;\n-        *stack = *fd;\n-        *fd = copy;\n-        fd->higher = stack;\n-        if (fd->lower) {\n-            PR_ASSERT(fd->lower->higher == stack);\n-            fd->lower->higher = fd;\n-        }\n-        stack->lower = fd;\n-        stack->higher = NULL;\n-    } else {\n-        /*\n-         * going somewhere in the middle of the stack for both old and new\n-         * style stacks, or going on top of stack for new style stack\n-         */\n-        fd->lower = insert;\n-        fd->higher = insert->higher;\n-\n-        insert->higher->lower = fd;\n-        insert->higher = fd;\n-    }\n+    insert->higher->lower = fd;\n+    insert->higher = fd;\n+  }\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_PopIOLayer(PRFileDesc* stack, PRDescIdentity id)\n-{\n-    PRFileDesc* extract = PR_GetIdentitiesLayer(stack, id);\n-\n-    PR_ASSERT(0 != id);\n-    PR_ASSERT(NULL != stack);\n-    PR_ASSERT(NULL != extract);\n-    if ((NULL == stack) || (0 == id) || (NULL == extract)) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return NULL;\n-    }\n+PR_IMPLEMENT(PRFileDesc*) PR_PopIOLayer(PRFileDesc* stack, PRDescIdentity id) {\n+  PRFileDesc* extract = PR_GetIdentitiesLayer(stack, id);\n \n-    if (extract == stack) {\n-        /* popping top layer of the stack */\n-        /* old style stack */\n-        PRFileDesc copy = *stack;\n-        extract = stack->lower;\n-        *stack = *extract;\n-        *extract = copy;\n-        stack->higher = NULL;\n-        if (stack->lower) {\n-            PR_ASSERT(stack->lower->higher == extract);\n-            stack->lower->higher = stack;\n-        }\n-    } else if ((PR_IO_LAYER_HEAD == stack->identity) &&\n-               (extract == stack->lower) && (extract->lower == NULL)) {\n-        /*\n-         * new style stack\n-         * popping the only layer in the stack; delete the stack too\n-         */\n-        stack->lower = NULL;\n-        _PR_DestroyIOLayer(stack);\n-    } else {\n-        /* for both kinds of stacks */\n-        extract->lower->higher = extract->higher;\n-        extract->higher->lower = extract->lower;\n-    }\n-    extract->higher = extract->lower = NULL;\n-    return extract;\n+  PR_ASSERT(0 != id);\n+  PR_ASSERT(NULL != stack);\n+  PR_ASSERT(NULL != extract);\n+  if ((NULL == stack) || (0 == id) || (NULL == extract)) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return NULL;\n+  }\n+\n+  if (extract == stack) {\n+    /* popping top layer of the stack */\n+    /* old style stack */\n+    PRFileDesc copy = *stack;\n+    extract = stack->lower;\n+    *stack = *extract;\n+    *extract = copy;\n+    stack->higher = NULL;\n+    if (stack->lower) {\n+      PR_ASSERT(stack->lower->higher == extract);\n+      stack->lower->higher = stack;\n+    }\n+  } else if ((PR_IO_LAYER_HEAD == stack->identity) &&\n+             (extract == stack->lower) && (extract->lower == NULL)) {\n+    /*\n+     * new style stack\n+     * popping the only layer in the stack; delete the stack too\n+     */\n+    stack->lower = NULL;\n+    _PR_DestroyIOLayer(stack);\n+  } else {\n+    /* for both kinds of stacks */\n+    extract->lower->higher = extract->higher;\n+    extract->higher->lower = extract->lower;\n+  }\n+  extract->higher = extract->lower = NULL;\n+  return extract;\n } /* PR_PopIOLayer */\n \n #define ID_CACHE_INCREMENT 16\n typedef struct _PRIdentity_cache {\n-    PRLock* ml;\n-    char** name;\n-    PRIntn length;\n-    PRDescIdentity ident;\n+  PRLock* ml;\n+  char** name;\n+  PRIntn length;\n+  PRDescIdentity ident;\n } _PRIdentity_cache;\n \n static _PRIdentity_cache identity_cache;\n \n-PR_IMPLEMENT(PRDescIdentity)\n-PR_GetUniqueIdentity(const char* layer_name)\n-{\n-    PRDescIdentity identity, length;\n-    char **names = NULL, *name = NULL, **old = NULL;\n+PR_IMPLEMENT(PRDescIdentity) PR_GetUniqueIdentity(const char* layer_name) {\n+  PRDescIdentity identity, length;\n+  char **names = NULL, *name = NULL, **old = NULL;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    PR_ASSERT((PRDescIdentity)((1UL << ((sizeof(PRDescIdentity) * 8) - 1)) - 1) >\n-              identity_cache.ident);\n+  PR_ASSERT((PRDescIdentity)((1UL << ((sizeof(PRDescIdentity) * 8) - 1)) - 1)\n+            > identity_cache.ident);\n \n-    if (NULL != layer_name) {\n-        name = (char*)PR_Malloc(strlen(layer_name) + 1);\n-        if (NULL == name) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            return PR_INVALID_IO_LAYER;\n-        }\n-        strcpy(name, layer_name);\n+  if (NULL != layer_name) {\n+    name = (char*)PR_Malloc(strlen(layer_name) + 1);\n+    if (NULL == name) {\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      return PR_INVALID_IO_LAYER;\n     }\n+    strcpy(name, layer_name);\n+  }\n \n-    /* this initial code runs unsafe */\n+  /* this initial code runs unsafe */\n retry:\n-    PR_ASSERT(NULL == names);\n-    /*\n-     * In the initial round, both identity_cache.ident and\n-     * identity_cache.length are 0, so (identity_cache.ident + 1) is greater\n-     * than length.  In later rounds, identity_cache.ident is always less\n-     * than length, so (identity_cache.ident + 1) can be equal to but cannot\n-     * be greater than length.\n-     */\n-    length = identity_cache.length;\n-    if ((identity_cache.ident + 1) >= length) {\n-        length += ID_CACHE_INCREMENT;\n-        names = (char**)PR_CALLOC(length * sizeof(char*));\n-        if (NULL == names) {\n-            if (NULL != name) {\n-                PR_DELETE(name);\n-            }\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            return PR_INVALID_IO_LAYER;\n-        }\n-    }\n-\n-    /* now we get serious about thread safety */\n-    PR_Lock(identity_cache.ml);\n-    PR_ASSERT(identity_cache.length == 0 ||\n-              identity_cache.ident < identity_cache.length);\n-    identity = identity_cache.ident + 1;\n-    if (identity >= identity_cache.length) /* there's no room */\n-    {\n-        /* we have to do something - hopefully it's already done */\n-        if ((NULL != names) && (identity < length)) {\n-            /* what we did is still okay */\n-            if (identity_cache.length != 0) {\n-                memcpy(names, identity_cache.name,\n-                       identity_cache.length * sizeof(char*));\n-            }\n-            old = identity_cache.name;\n-            identity_cache.name = names;\n-            identity_cache.length = length;\n-            names = NULL;\n-        } else {\n-            PR_Unlock(identity_cache.ml);\n-            if (NULL != names) {\n-                PR_DELETE(names);\n-            }\n-            goto retry;\n-        }\n-    }\n-    if (NULL != name) /* there's a name to be stored */\n-    {\n-        identity_cache.name[identity] = name;\n-    }\n-    identity_cache.ident = identity;\n-    PR_ASSERT(identity_cache.ident < identity_cache.length);\n-    PR_Unlock(identity_cache.ml);\n-\n-    if (NULL != old) {\n-        PR_DELETE(old);\n-    }\n-    if (NULL != names) {\n+  PR_ASSERT(NULL == names);\n+  /*\n+   * In the initial round, both identity_cache.ident and\n+   * identity_cache.length are 0, so (identity_cache.ident + 1) is greater\n+   * than length.  In later rounds, identity_cache.ident is always less\n+   * than length, so (identity_cache.ident + 1) can be equal to but cannot\n+   * be greater than length.\n+   */\n+  length = identity_cache.length;\n+  if ((identity_cache.ident + 1) >= length) {\n+    length += ID_CACHE_INCREMENT;\n+    names = (char**)PR_CALLOC(length * sizeof(char*));\n+    if (NULL == names) {\n+      if (NULL != name) {\n+        PR_DELETE(name);\n+      }\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      return PR_INVALID_IO_LAYER;\n+    }\n+  }\n+\n+  /* now we get serious about thread safety */\n+  PR_Lock(identity_cache.ml);\n+  PR_ASSERT(identity_cache.length == 0 ||\n+            identity_cache.ident < identity_cache.length);\n+  identity = identity_cache.ident + 1;\n+  if (identity >= identity_cache.length) /* there's no room */\n+  {\n+    /* we have to do something - hopefully it's already done */\n+    if ((NULL != names) && (identity < length)) {\n+      /* what we did is still okay */\n+      if (identity_cache.length != 0) {\n+        memcpy(names, identity_cache.name,\n+               identity_cache.length * sizeof(char*));\n+      }\n+      old = identity_cache.name;\n+      identity_cache.name = names;\n+      identity_cache.length = length;\n+      names = NULL;\n+    } else {\n+      PR_Unlock(identity_cache.ml);\n+      if (NULL != names) {\n         PR_DELETE(names);\n-    }\n-\n-    return identity;\n+      }\n+      goto retry;\n+    }\n+  }\n+  if (NULL != name) /* there's a name to be stored */\n+  {\n+    identity_cache.name[identity] = name;\n+  }\n+  identity_cache.ident = identity;\n+  PR_ASSERT(identity_cache.ident < identity_cache.length);\n+  PR_Unlock(identity_cache.ml);\n+\n+  if (NULL != old) {\n+    PR_DELETE(old);\n+  }\n+  if (NULL != names) {\n+    PR_DELETE(names);\n+  }\n+\n+  return identity;\n } /* PR_GetUniqueIdentity */\n \n-PR_IMPLEMENT(const char*)\n-PR_GetNameForIdentity(PRDescIdentity ident)\n-{\n-    const char* rv = NULL;\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+PR_IMPLEMENT(const char*) PR_GetNameForIdentity(PRDescIdentity ident) {\n+  const char* rv = NULL;\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    if ((PR_TOP_IO_LAYER != ident) && (ident >= 0)) {\n-        PR_Lock(identity_cache.ml);\n-        PR_ASSERT(ident <= identity_cache.ident);\n-        rv = (ident > identity_cache.ident) ? NULL : identity_cache.name[ident];\n-        PR_Unlock(identity_cache.ml);\n-    }\n+  if ((PR_TOP_IO_LAYER != ident) && (ident >= 0)) {\n+    PR_Lock(identity_cache.ml);\n+    PR_ASSERT(ident <= identity_cache.ident);\n+    rv = (ident > identity_cache.ident) ? NULL : identity_cache.name[ident];\n+    PR_Unlock(identity_cache.ml);\n+  }\n \n-    return rv;\n+  return rv;\n } /* PR_GetNameForIdentity */\n \n-PR_IMPLEMENT(PRDescIdentity)\n-PR_GetLayersIdentity(PRFileDesc* fd)\n-{\n-    PR_ASSERT(NULL != fd);\n-    if (PR_IO_LAYER_HEAD == fd->identity) {\n-        PR_ASSERT(NULL != fd->lower);\n-        return fd->lower->identity;\n-    }\n-    return fd->identity;\n+PR_IMPLEMENT(PRDescIdentity) PR_GetLayersIdentity(PRFileDesc* fd) {\n+  PR_ASSERT(NULL != fd);\n+  if (PR_IO_LAYER_HEAD == fd->identity) {\n+    PR_ASSERT(NULL != fd->lower);\n+    return fd->lower->identity;\n+  }\n+  return fd->identity;\n } /* PR_GetLayersIdentity */\n \n PR_IMPLEMENT(PRFileDesc*)\n-PR_GetIdentitiesLayer(PRFileDesc* fd, PRDescIdentity id)\n-{\n-    PRFileDesc* layer = fd;\n-\n-    if (PR_TOP_IO_LAYER == id) {\n-        if (PR_IO_LAYER_HEAD == fd->identity) {\n-            return fd->lower;\n-        }\n-        return fd;\n+PR_GetIdentitiesLayer(PRFileDesc* fd, PRDescIdentity id) {\n+  PRFileDesc* layer = fd;\n+\n+  if (PR_TOP_IO_LAYER == id) {\n+    if (PR_IO_LAYER_HEAD == fd->identity) {\n+      return fd->lower;\n     }\n+    return fd;\n+  }\n \n-    for (layer = fd; layer != NULL; layer = layer->lower) {\n-        if (id == layer->identity) {\n-            return layer;\n-        }\n+  for (layer = fd; layer != NULL; layer = layer->lower) {\n+    if (id == layer->identity) {\n+      return layer;\n     }\n-    for (layer = fd; layer != NULL; layer = layer->higher) {\n-        if (id == layer->identity) {\n-            return layer;\n-        }\n+  }\n+  for (layer = fd; layer != NULL; layer = layer->higher) {\n+    if (id == layer->identity) {\n+      return layer;\n     }\n-    return NULL;\n+  }\n+  return NULL;\n } /* PR_GetIdentitiesLayer */\n \n-void\n-_PR_InitLayerCache(void)\n-{\n-    memset(&identity_cache, 0, sizeof(identity_cache));\n-    identity_cache.ml = PR_NewLock();\n-    PR_ASSERT(NULL != identity_cache.ml);\n+void _PR_InitLayerCache(void) {\n+  memset(&identity_cache, 0, sizeof(identity_cache));\n+  identity_cache.ml = PR_NewLock();\n+  PR_ASSERT(NULL != identity_cache.ml);\n } /* _PR_InitLayerCache */\n \n-void\n-_PR_CleanupLayerCache(void)\n-{\n-    if (identity_cache.ml) {\n-        PR_DestroyLock(identity_cache.ml);\n-        identity_cache.ml = NULL;\n-    }\n-\n-    if (identity_cache.name) {\n-        PRDescIdentity ident;\n+void _PR_CleanupLayerCache(void) {\n+  if (identity_cache.ml) {\n+    PR_DestroyLock(identity_cache.ml);\n+    identity_cache.ml = NULL;\n+  }\n \n-        for (ident = 0; ident <= identity_cache.ident; ident++) {\n-            PR_DELETE(identity_cache.name[ident]);\n-        }\n+  if (identity_cache.name) {\n+    PRDescIdentity ident;\n \n-        PR_DELETE(identity_cache.name);\n+    for (ident = 0; ident <= identity_cache.ident; ident++) {\n+      PR_DELETE(identity_cache.name[ident]);\n     }\n+\n+    PR_DELETE(identity_cache.name);\n+  }\n } /* _PR_CleanupLayerCache */\n \n /* prlayer.c */\ndiff --git a/nspr/pr/src/io/prlog.c b/nspr/pr/src/io/prlog.c\nindex 0675606..23e8f9f 100644\n--- a/nspr/pr/src/io/prlog.c\n+++ b/nspr/pr/src/io/prlog.c\n@@ -1,3 +1,5 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n+\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,7 +9,7 @@\n #include \"prprf.h\"\n #include <string.h>\n #ifdef ANDROID\n-#include <android/log.h>\n+#  include <android/log.h>\n #endif\n \n /*\n@@ -20,36 +22,34 @@\n  */\n static PRLock* _pr_logLock;\n #if defined(_PR_PTHREADS) || defined(_PR_BTHREADS)\n-#define _PR_LOCK_LOG() PR_Lock(_pr_logLock);\n-#define _PR_UNLOCK_LOG() PR_Unlock(_pr_logLock);\n+#  define _PR_LOCK_LOG() PR_Lock(_pr_logLock);\n+#  define _PR_UNLOCK_LOG() PR_Unlock(_pr_logLock);\n #elif defined(_PR_GLOBAL_THREADS_ONLY)\n-#define _PR_LOCK_LOG() \\\n-    {                  \\\n-        _PR_LOCK_LOCK(_pr_logLock)\n-#define _PR_UNLOCK_LOG()          \\\n+#  define _PR_LOCK_LOG() \\\n+    {                    \\\n+      _PR_LOCK_LOCK(_pr_logLock)\n+#  define _PR_UNLOCK_LOG()        \\\n     _PR_LOCK_UNLOCK(_pr_logLock); \\\n     }\n #else\n \n-#define _PR_LOCK_LOG()                           \\\n-    {                                            \\\n-        PRIntn _is;                              \\\n-        PRThread* _me = _PR_MD_CURRENT_THREAD(); \\\n-        if (!_PR_IS_NATIVE_THREAD(_me))          \\\n-            _PR_INTSOFF(_is);                    \\\n-        _PR_LOCK_LOCK(_pr_logLock)\n-\n-#define _PR_UNLOCK_LOG()                       \\\n-    _PR_LOCK_UNLOCK(_pr_logLock);              \\\n-    PR_ASSERT(_me == _PR_MD_CURRENT_THREAD()); \\\n-    if (!_PR_IS_NATIVE_THREAD(_me))            \\\n-        _PR_INTSON(_is);                       \\\n+#  define _PR_LOCK_LOG()                                \\\n+    {                                                   \\\n+      PRIntn _is;                                       \\\n+      PRThread* _me = _PR_MD_CURRENT_THREAD();          \\\n+      if (!_PR_IS_NATIVE_THREAD(_me)) _PR_INTSOFF(_is); \\\n+      _PR_LOCK_LOCK(_pr_logLock)\n+\n+#  define _PR_UNLOCK_LOG()                           \\\n+    _PR_LOCK_UNLOCK(_pr_logLock);                    \\\n+    PR_ASSERT(_me == _PR_MD_CURRENT_THREAD());       \\\n+    if (!_PR_IS_NATIVE_THREAD(_me)) _PR_INTSON(_is); \\\n     }\n \n #endif\n \n #if defined(XP_PC)\n-#define strcasecmp stricmp\n+#  define strcasecmp stricmp\n #endif\n \n /*\n@@ -60,7 +60,7 @@ static PRLock* _pr_logLock;\n  * code can also be used on other platforms with file stream io.\n  */\n #if defined(WIN32)\n-#define _PR_USE_STDIO_FOR_LOGGING\n+#  define _PR_USE_STDIO_FOR_LOGGING\n #endif\n \n /*\n@@ -68,58 +68,56 @@ static PRLock* _pr_logLock;\n ** NSPR_LOG_FILE is set to \"WinDebug\".\n */\n #if defined(XP_PC)\n-#define WIN32_DEBUG_FILE (FILE*)-2\n+#  define WIN32_DEBUG_FILE (FILE*)-2\n #endif\n \n #ifdef WINCE\n-static void\n-OutputDebugStringA(const char* msg)\n-{\n-    int len = MultiByteToWideChar(CP_ACP, 0, msg, -1, 0, 0);\n-    WCHAR* wMsg = (WCHAR*)PR_Malloc(len * sizeof(WCHAR));\n-    MultiByteToWideChar(CP_ACP, 0, msg, -1, wMsg, len);\n-    OutputDebugStringW(wMsg);\n-    PR_Free(wMsg);\n+static void OutputDebugStringA(const char* msg) {\n+  int len = MultiByteToWideChar(CP_ACP, 0, msg, -1, 0, 0);\n+  WCHAR* wMsg = (WCHAR*)PR_Malloc(len * sizeof(WCHAR));\n+  MultiByteToWideChar(CP_ACP, 0, msg, -1, wMsg, len);\n+  OutputDebugStringW(wMsg);\n+  PR_Free(wMsg);\n }\n #endif\n \n /* Macros used to reduce #ifdef pollution */\n \n #if defined(_PR_USE_STDIO_FOR_LOGGING) && defined(XP_PC)\n-#define _PUT_LOG(fd, buf, nb)          \\\n+#  define _PUT_LOG(fd, buf, nb)        \\\n     PR_BEGIN_MACRO                     \\\n     if (logFile == WIN32_DEBUG_FILE) { \\\n-        char savebyte = buf[nb];       \\\n-        buf[nb] = '\\0';                \\\n-        OutputDebugStringA(buf);       \\\n-        buf[nb] = savebyte;            \\\n+      char savebyte = buf[nb];         \\\n+      buf[nb] = '\\0';                  \\\n+      OutputDebugStringA(buf);         \\\n+      buf[nb] = savebyte;              \\\n     } else {                           \\\n-        fwrite(buf, 1, nb, fd);        \\\n-        fflush(fd);                    \\\n+      fwrite(buf, 1, nb, fd);          \\\n+      fflush(fd);                      \\\n     }                                  \\\n     PR_END_MACRO\n #elif defined(_PR_USE_STDIO_FOR_LOGGING)\n-#define _PUT_LOG(fd, buf, nb)   \\\n+#  define _PUT_LOG(fd, buf, nb) \\\n     {                           \\\n-        fwrite(buf, 1, nb, fd); \\\n-        fflush(fd);             \\\n+      fwrite(buf, 1, nb, fd);   \\\n+      fflush(fd);               \\\n     }\n #elif defined(ANDROID)\n-#define _PUT_LOG(fd, buf, nb)                                \\\n-    PR_BEGIN_MACRO                                           \\\n-    if (fd == _pr_stderr) {                                  \\\n-        char savebyte = buf[nb];                             \\\n-        buf[nb] = '\\0';                                      \\\n-        __android_log_write(ANDROID_LOG_INFO, \"PRLog\", buf); \\\n-        buf[nb] = savebyte;                                  \\\n-    } else {                                                 \\\n-        PR_Write(fd, buf, nb);                               \\\n-    }                                                        \\\n+#  define _PUT_LOG(fd, buf, nb)                            \\\n+    PR_BEGIN_MACRO                                         \\\n+    if (fd == _pr_stderr) {                                \\\n+      char savebyte = buf[nb];                             \\\n+      buf[nb] = '\\0';                                      \\\n+      __android_log_write(ANDROID_LOG_INFO, \"PRLog\", buf); \\\n+      buf[nb] = savebyte;                                  \\\n+    } else {                                               \\\n+      PR_Write(fd, buf, nb);                               \\\n+    }                                                      \\\n     PR_END_MACRO\n #elif defined(_PR_PTHREADS)\n-#define _PUT_LOG(fd, buf, nb) PR_Write(fd, buf, nb)\n+#  define _PUT_LOG(fd, buf, nb) PR_Write(fd, buf, nb)\n #else\n-#define _PUT_LOG(fd, buf, nb) _PR_MD_WRITE(fd, buf, nb)\n+#  define _PUT_LOG(fd, buf, nb) _PR_MD_WRITE(fd, buf, nb)\n #endif\n \n /************************************************************************/\n@@ -153,430 +151,407 @@ static const unsigned char uc[] = {\n     '\\000', '\\001', '\\002', '\\003', '\\004', '\\005', '\\006', '\\007', '\\010',\n     '\\011', '\\012', '\\013', '\\014', '\\015', '\\016', '\\017', '\\020', '\\021',\n     '\\022', '\\023', '\\024', '\\025', '\\026', '\\027', '\\030', '\\031', '\\032',\n-    '\\033', '\\034', '\\035', '\\036', '\\037', ' ', '!', '\"', '#',\n-    '$', '%', '&', '\\'', '(', ')', '*', '+', ',',\n-    '-', '.', '/', '0', '1', '2', '3', '4', '5',\n-    '6', '7', '8', '9', ':', ';', '<', '=', '>',\n-    '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',\n-    'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',\n-    'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',\n-    'Z', '[', '\\\\', ']', '^', '_', '`', 'A', 'B',\n-    'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',\n-    'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',\n-    'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}',\n-    '~', '\\177'\n-};\n-\n-PRIntn\n-strcasecmp(const char* a, const char* b)\n-{\n-    const unsigned char* ua = (const unsigned char*)a;\n-    const unsigned char* ub = (const unsigned char*)b;\n-\n-    if (((const char*)0 == a) || (const char*)0 == b) {\n-        return (PRIntn)(a - b);\n-    }\n-\n-    while ((uc[*ua] == uc[*ub]) && ('\\0' != *a)) {\n-        a++;\n-        ua++;\n-        ub++;\n-    }\n-\n-    return (PRIntn)(uc[*ua] - uc[*ub]);\n+    '\\033', '\\034', '\\035', '\\036', '\\037', ' ',    '!',    '\"',    '#',\n+    '$',    '%',    '&',    '\\'',   '(',    ')',    '*',    '+',    ',',\n+    '-',    '.',    '/',    '0',    '1',    '2',    '3',    '4',    '5',\n+    '6',    '7',    '8',    '9',    ':',    ';',    '<',    '=',    '>',\n+    '?',    '@',    'A',    'B',    'C',    'D',    'E',    'F',    'G',\n+    'H',    'I',    'J',    'K',    'L',    'M',    'N',    'O',    'P',\n+    'Q',    'R',    'S',    'T',    'U',    'V',    'W',    'X',    'Y',\n+    'Z',    '[',    '\\\\',   ']',    '^',    '_',    '`',    'A',    'B',\n+    'C',    'D',    'E',    'F',    'G',    'H',    'I',    'J',    'K',\n+    'L',    'M',    'N',    'O',    'P',    'Q',    'R',    'S',    'T',\n+    'U',    'V',    'W',    'X',    'Y',    'Z',    '{',    '|',    '}',\n+    '~',    '\\177'};\n+\n+PRIntn strcasecmp(const char* a, const char* b) {\n+  const unsigned char* ua = (const unsigned char*)a;\n+  const unsigned char* ub = (const unsigned char*)b;\n+\n+  if (((const char*)0 == a) || (const char*)0 == b) {\n+    return (PRIntn)(a - b);\n+  }\n+\n+  while ((uc[*ua] == uc[*ub]) && ('\\0' != *a)) {\n+    a++;\n+    ua++;\n+    ub++;\n+  }\n+\n+  return (PRIntn)(uc[*ua] - uc[*ub]);\n }\n \n #endif /* _PR_NEED_STRCASECMP */\n \n-void\n-_PR_InitLog(void)\n-{\n-    char* ev;\n-\n-    _pr_logLock = PR_NewLock();\n-\n-    ev = PR_GetEnv(\"NSPR_LOG_MODULES\");\n-    if (ev && ev[0]) {\n-        char module[64]; /* Security-Critical: If you change this\n-                          * size, you must also change the sscanf\n-                          * format string to be size-1.\n-                          */\n-        PRBool isSync = PR_FALSE;\n-        PRIntn evlen = strlen(ev), pos = 0;\n-        PRInt32 bufSize = DEFAULT_BUF_SIZE;\n-        while (pos < evlen) {\n-            PRIntn level = 1, count = 0, delta = 0;\n-            count = sscanf(\n-                &ev[pos],\n-                \"%63[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-\"\n-                \"]%n:%d%n\",\n-                module, &delta, &level, &delta);\n-            pos += delta;\n-            if (count == 0) {\n-                break;\n-            }\n-\n-            /*\n-            ** If count == 2, then we got module and level. If count\n-            ** == 1, then level defaults to 1 (module enabled).\n-            */\n-            if (strcasecmp(module, \"sync\") == 0) {\n-                isSync = PR_TRUE;\n-            } else if (strcasecmp(module, \"bufsize\") == 0) {\n-                if (level >= LINE_BUF_SIZE) {\n-                    bufSize = level;\n-                }\n-            } else if (strcasecmp(module, \"timestamp\") == 0) {\n-                outputTimeStamp = PR_TRUE;\n-            } else if (strcasecmp(module, \"append\") == 0) {\n-                appendToLog = PR_TRUE;\n-            } else {\n-                PRLogModuleInfo* lm = logModules;\n-                PRBool skip_modcheck =\n-                    (0 == strcasecmp(module, \"all\")) ? PR_TRUE : PR_FALSE;\n-\n-                while (lm != NULL) {\n-                    if (skip_modcheck) {\n-                        lm->level = (PRLogModuleLevel)level;\n-                    } else if (strcasecmp(module, lm->name) == 0) {\n-                        lm->level = (PRLogModuleLevel)level;\n-                        break;\n-                    }\n-                    lm = lm->next;\n-                }\n-            }\n-            /*found:*/\n-            count = sscanf(&ev[pos], \" , %n\", &delta);\n-            pos += delta;\n-            if (count == EOF) {\n-                break;\n-            }\n+void _PR_InitLog(void) {\n+  char* ev;\n+\n+  _pr_logLock = PR_NewLock();\n+\n+  ev = PR_GetEnv(\"NSPR_LOG_MODULES\");\n+  if (ev && ev[0]) {\n+    char module[64]; /* Security-Critical: If you change this\n+                      * size, you must also change the sscanf\n+                      * format string to be size-1.\n+                      */\n+    PRBool isSync = PR_FALSE;\n+    PRIntn evlen = strlen(ev), pos = 0;\n+    PRInt32 bufSize = DEFAULT_BUF_SIZE;\n+    while (pos < evlen) {\n+      PRIntn level = 1, count = 0, delta = 0;\n+      count = sscanf(\n+          &ev[pos],\n+          \"%63[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-\"\n+          \"]%n:%d%n\",\n+          module, &delta, &level, &delta);\n+      pos += delta;\n+      if (count == 0) {\n+        break;\n+      }\n+\n+      /*\n+      ** If count == 2, then we got module and level. If count\n+      ** == 1, then level defaults to 1 (module enabled).\n+      */\n+      if (strcasecmp(module, \"sync\") == 0) {\n+        isSync = PR_TRUE;\n+      } else if (strcasecmp(module, \"bufsize\") == 0) {\n+        if (level >= LINE_BUF_SIZE) {\n+          bufSize = level;\n+        }\n+      } else if (strcasecmp(module, \"timestamp\") == 0) {\n+        outputTimeStamp = PR_TRUE;\n+      } else if (strcasecmp(module, \"append\") == 0) {\n+        appendToLog = PR_TRUE;\n+      } else {\n+        PRLogModuleInfo* lm = logModules;\n+        PRBool skip_modcheck =\n+            (0 == strcasecmp(module, \"all\")) ? PR_TRUE : PR_FALSE;\n+\n+        while (lm != NULL) {\n+          if (skip_modcheck) {\n+            lm->level = (PRLogModuleLevel)level;\n+          } else if (strcasecmp(module, lm->name) == 0) {\n+            lm->level = (PRLogModuleLevel)level;\n+            break;\n+          }\n+          lm = lm->next;\n         }\n-        PR_SetLogBuffering(isSync ? 0 : bufSize);\n+      }\n+      /*found:*/\n+      count = sscanf(&ev[pos], \" , %n\", &delta);\n+      pos += delta;\n+      if (count == EOF) {\n+        break;\n+      }\n+    }\n+    PR_SetLogBuffering(isSync ? 0 : bufSize);\n \n-        ev = PR_GetEnvSecure(\"NSPR_LOG_FILE\");\n-        if (ev && ev[0]) {\n-            if (!PR_SetLogFile(ev)) {\n+    ev = PR_GetEnvSecure(\"NSPR_LOG_FILE\");\n+    if (ev && ev[0]) {\n+      if (!PR_SetLogFile(ev)) {\n #ifdef XP_PC\n-                char* str = PR_smprintf(\"Unable to create nspr log file '%s'\\n\", ev);\n-                if (str) {\n-                    OutputDebugStringA(str);\n-                    PR_smprintf_free(str);\n-                }\n+        char* str = PR_smprintf(\"Unable to create nspr log file '%s'\\n\", ev);\n+        if (str) {\n+          OutputDebugStringA(str);\n+          PR_smprintf_free(str);\n+        }\n #else\n-                fprintf(stderr, \"Unable to create nspr log file '%s'\\n\", ev);\n+        fprintf(stderr, \"Unable to create nspr log file '%s'\\n\", ev);\n #endif\n-            }\n-        } else {\n+      }\n+    } else {\n #ifdef _PR_USE_STDIO_FOR_LOGGING\n-            logFile = stderr;\n+      logFile = stderr;\n #else\n-            logFile = _pr_stderr;\n+      logFile = _pr_stderr;\n #endif\n-        }\n     }\n+  }\n }\n \n-void\n-_PR_LogCleanup(void)\n-{\n-    PRLogModuleInfo* lm = logModules;\n+void _PR_LogCleanup(void) {\n+  PRLogModuleInfo* lm = logModules;\n \n-    PR_LogFlush();\n+  PR_LogFlush();\n \n #ifdef _PR_USE_STDIO_FOR_LOGGING\n-    if (logFile && logFile != stdout && logFile != stderr\n-#ifdef XP_PC\n-        && logFile != WIN32_DEBUG_FILE\n-#endif\n-    ) {\n-        fclose(logFile);\n-    }\n+  if (logFile && logFile != stdout && logFile != stderr\n+#  ifdef XP_PC\n+      && logFile != WIN32_DEBUG_FILE\n+#  endif\n+  ) {\n+    fclose(logFile);\n+  }\n #else\n-    if (logFile && logFile != _pr_stdout && logFile != _pr_stderr) {\n-        PR_Close(logFile);\n-    }\n+  if (logFile && logFile != _pr_stdout && logFile != _pr_stderr) {\n+    PR_Close(logFile);\n+  }\n #endif\n-    logFile = NULL;\n-\n-    if (logBuf) {\n-        PR_DELETE(logBuf);\n-    }\n-\n-    while (lm != NULL) {\n-        PRLogModuleInfo* next = lm->next;\n-        free((/*const*/ char*)lm->name);\n-        PR_Free(lm);\n-        lm = next;\n-    }\n-    logModules = NULL;\n-\n-    if (_pr_logLock) {\n-        PR_DestroyLock(_pr_logLock);\n-        _pr_logLock = NULL;\n-    }\n+  logFile = NULL;\n+\n+  if (logBuf) {\n+    PR_DELETE(logBuf);\n+  }\n+\n+  while (lm != NULL) {\n+    PRLogModuleInfo* next = lm->next;\n+    free((/*const*/ char*)lm->name);\n+    PR_Free(lm);\n+    lm = next;\n+  }\n+  logModules = NULL;\n+\n+  if (_pr_logLock) {\n+    PR_DestroyLock(_pr_logLock);\n+    _pr_logLock = NULL;\n+  }\n }\n \n-static void\n-_PR_SetLogModuleLevel(PRLogModuleInfo* lm)\n-{\n-    char* ev;\n-\n-    ev = PR_GetEnv(\"NSPR_LOG_MODULES\");\n-    if (ev && ev[0]) {\n-        char module[64]; /* Security-Critical: If you change this\n-                          * size, you must also change the sscanf\n-                          * format string to be size-1.\n-                          */\n-        PRIntn evlen = strlen(ev), pos = 0;\n-        while (pos < evlen) {\n-            PRIntn level = 1, count = 0, delta = 0;\n-\n-            count = sscanf(\n-                &ev[pos],\n-                \"%63[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-\"\n-                \"]%n:%d%n\",\n-                module, &delta, &level, &delta);\n-            pos += delta;\n-            if (count == 0) {\n-                break;\n-            }\n-\n-            /*\n-            ** If count == 2, then we got module and level. If count\n-            ** == 1, then level defaults to 1 (module enabled).\n-            */\n-            if (lm != NULL) {\n-                if ((strcasecmp(module, \"all\") == 0) ||\n-                    (strcasecmp(module, lm->name) == 0)) {\n-                    lm->level = (PRLogModuleLevel)level;\n-                }\n-            }\n-            count = sscanf(&ev[pos], \" , %n\", &delta);\n-            pos += delta;\n-            if (count == EOF) {\n-                break;\n-            }\n+static void _PR_SetLogModuleLevel(PRLogModuleInfo* lm) {\n+  char* ev;\n+\n+  ev = PR_GetEnv(\"NSPR_LOG_MODULES\");\n+  if (ev && ev[0]) {\n+    char module[64]; /* Security-Critical: If you change this\n+                      * size, you must also change the sscanf\n+                      * format string to be size-1.\n+                      */\n+    PRIntn evlen = strlen(ev), pos = 0;\n+    while (pos < evlen) {\n+      PRIntn level = 1, count = 0, delta = 0;\n+\n+      count = sscanf(\n+          &ev[pos],\n+          \"%63[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-\"\n+          \"]%n:%d%n\",\n+          module, &delta, &level, &delta);\n+      pos += delta;\n+      if (count == 0) {\n+        break;\n+      }\n+\n+      /*\n+      ** If count == 2, then we got module and level. If count\n+      ** == 1, then level defaults to 1 (module enabled).\n+      */\n+      if (lm != NULL) {\n+        if ((strcasecmp(module, \"all\") == 0) ||\n+            (strcasecmp(module, lm->name) == 0)) {\n+          lm->level = (PRLogModuleLevel)level;\n         }\n+      }\n+      count = sscanf(&ev[pos], \" , %n\", &delta);\n+      pos += delta;\n+      if (count == EOF) {\n+        break;\n+      }\n     }\n+  }\n } /* end _PR_SetLogModuleLevel() */\n \n-PR_IMPLEMENT(PRLogModuleInfo*)\n-PR_NewLogModule(const char* name)\n-{\n-    PRLogModuleInfo* lm;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    lm = PR_NEWZAP(PRLogModuleInfo);\n-    if (lm) {\n-        lm->name = strdup(name);\n-        lm->level = PR_LOG_NONE;\n-        lm->next = logModules;\n-        logModules = lm;\n-        _PR_SetLogModuleLevel(lm);\n-    }\n-    return lm;\n+PR_IMPLEMENT(PRLogModuleInfo*) PR_NewLogModule(const char* name) {\n+  PRLogModuleInfo* lm;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  lm = PR_NEWZAP(PRLogModuleInfo);\n+  if (lm) {\n+    lm->name = strdup(name);\n+    lm->level = PR_LOG_NONE;\n+    lm->next = logModules;\n+    logModules = lm;\n+    _PR_SetLogModuleLevel(lm);\n+  }\n+  return lm;\n }\n \n-PR_IMPLEMENT(PRBool)\n-PR_SetLogFile(const char* file)\n-{\n+PR_IMPLEMENT(PRBool) PR_SetLogFile(const char* file) {\n #ifdef _PR_USE_STDIO_FOR_LOGGING\n-    FILE* newLogFile;\n-\n-#ifdef XP_PC\n-    if (strcmp(file, \"WinDebug\") == 0) {\n-        newLogFile = WIN32_DEBUG_FILE;\n-    } else\n-#endif\n-    {\n-        const char* mode = appendToLog ? \"a\" : \"w\";\n-        newLogFile = fopen(file, mode);\n-        if (!newLogFile) {\n-            return PR_FALSE;\n-        }\n-\n-#ifndef WINCE /* _IONBF does not exist in the Windows Mobile 6 SDK. */\n-        /* We do buffering ourselves. */\n-        setvbuf(newLogFile, NULL, _IONBF, 0);\n-#endif\n-    }\n-    if (logFile && logFile != stdout && logFile != stderr\n-#ifdef XP_PC\n-        && logFile != WIN32_DEBUG_FILE\n-#endif\n-    ) {\n-        fclose(logFile);\n-    }\n-    logFile = newLogFile;\n-    return PR_TRUE;\n-#else\n-    PRFileDesc* newLogFile;\n-    PRIntn flags = PR_WRONLY | PR_CREATE_FILE;\n-    if (appendToLog) {\n-        flags |= PR_APPEND;\n-    } else {\n-        flags |= PR_TRUNCATE;\n+  FILE* newLogFile;\n+\n+#  ifdef XP_PC\n+  if (strcmp(file, \"WinDebug\") == 0) {\n+    newLogFile = WIN32_DEBUG_FILE;\n+  } else\n+#  endif\n+  {\n+    const char* mode = appendToLog ? \"a\" : \"w\";\n+    newLogFile = fopen(file, mode);\n+    if (!newLogFile) {\n+      return PR_FALSE;\n     }\n \n-    newLogFile = PR_Open(file, flags, 0666);\n-    if (newLogFile) {\n-        if (logFile && logFile != _pr_stdout && logFile != _pr_stderr) {\n-            PR_Close(logFile);\n-        }\n-        logFile = newLogFile;\n+#  ifndef WINCE /* _IONBF does not exist in the Windows Mobile 6 SDK. */\n+    /* We do buffering ourselves. */\n+    setvbuf(newLogFile, NULL, _IONBF, 0);\n+#  endif\n+  }\n+  if (logFile && logFile != stdout && logFile != stderr\n+#  ifdef XP_PC\n+      && logFile != WIN32_DEBUG_FILE\n+#  endif\n+  ) {\n+    fclose(logFile);\n+  }\n+  logFile = newLogFile;\n+  return PR_TRUE;\n+#else\n+  PRFileDesc* newLogFile;\n+  PRIntn flags = PR_WRONLY | PR_CREATE_FILE;\n+  if (appendToLog) {\n+    flags |= PR_APPEND;\n+  } else {\n+    flags |= PR_TRUNCATE;\n+  }\n+\n+  newLogFile = PR_Open(file, flags, 0666);\n+  if (newLogFile) {\n+    if (logFile && logFile != _pr_stdout && logFile != _pr_stderr) {\n+      PR_Close(logFile);\n     }\n-    return (PRBool)(newLogFile != 0);\n+    logFile = newLogFile;\n+  }\n+  return (PRBool)(newLogFile != 0);\n #endif /* _PR_USE_STDIO_FOR_LOGGING */\n }\n \n-PR_IMPLEMENT(void)\n-PR_SetLogBuffering(PRIntn buffer_size)\n-{\n-    PR_LogFlush();\n+PR_IMPLEMENT(void) PR_SetLogBuffering(PRIntn buffer_size) {\n+  PR_LogFlush();\n \n-    if (logBuf) {\n-        PR_DELETE(logBuf);\n-    }\n+  if (logBuf) {\n+    PR_DELETE(logBuf);\n+  }\n \n-    if (buffer_size >= LINE_BUF_SIZE) {\n-        logp = logBuf = (char*)PR_MALLOC(buffer_size);\n-        logEndp = logp + buffer_size;\n-    }\n+  if (buffer_size >= LINE_BUF_SIZE) {\n+    logp = logBuf = (char*)PR_MALLOC(buffer_size);\n+    logEndp = logp + buffer_size;\n+  }\n }\n \n-PR_IMPLEMENT(void)\n-PR_LogPrint(const char* fmt, ...)\n-{\n-    va_list ap;\n-    char line[LINE_BUF_SIZE];\n-    char* line_long = NULL;\n-    PRUint32 nb_tid = 0, nb;\n-    PRThread* me;\n-    PRExplodedTime now;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    if (!logFile) {\n-        return;\n-    }\n-\n-    if (outputTimeStamp) {\n-        PR_ExplodeTime(PR_Now(), PR_GMTParameters, &now);\n-        nb_tid = PR_snprintf(line, sizeof(line) - 1,\n-                             \"%04d-%02d-%02d %02d:%02d:%02d.%06d UTC - \",\n-                             now.tm_year, now.tm_month + 1, now.tm_mday,\n-                             now.tm_hour, now.tm_min, now.tm_sec, now.tm_usec);\n-    }\n-\n-    me = PR_GetCurrentThread();\n-    nb_tid += PR_snprintf(line + nb_tid, sizeof(line) - nb_tid - 1, \"%ld[%p]: \",\n+PR_IMPLEMENT(void) PR_LogPrint(const char* fmt, ...) {\n+  va_list ap;\n+  char line[LINE_BUF_SIZE];\n+  char* line_long = NULL;\n+  PRUint32 nb_tid = 0, nb;\n+  PRThread* me;\n+  PRExplodedTime now;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  if (!logFile) {\n+    return;\n+  }\n+\n+  if (outputTimeStamp) {\n+    PR_ExplodeTime(PR_Now(), PR_GMTParameters, &now);\n+    nb_tid = PR_snprintf(line, sizeof(line) - 1,\n+                         \"%04d-%02d-%02d %02d:%02d:%02d.%06d UTC - \",\n+                         now.tm_year, now.tm_month + 1, now.tm_mday,\n+                         now.tm_hour, now.tm_min, now.tm_sec, now.tm_usec);\n+  }\n+\n+  me = PR_GetCurrentThread();\n+  nb_tid += PR_snprintf(line + nb_tid, sizeof(line) - nb_tid - 1, \"%ld[%p]: \",\n #if defined(_PR_BTHREADS)\n-                          me, me);\n+                        me, me);\n #else\n-                          me ? me->id : 0L, me);\n+                        me ? me->id : 0L, me);\n #endif\n \n+  va_start(ap, fmt);\n+  nb = nb_tid + PR_vsnprintf(line + nb_tid, sizeof(line) - nb_tid - 1, fmt, ap);\n+  va_end(ap);\n+\n+  /*\n+   * Check if we might have run out of buffer space (in case we have a\n+   * long line), and malloc a buffer just this once.\n+   */\n+  if (nb == sizeof(line) - 2) {\n     va_start(ap, fmt);\n-    nb = nb_tid + PR_vsnprintf(line + nb_tid, sizeof(line) - nb_tid - 1, fmt, ap);\n+    line_long = PR_vsmprintf(fmt, ap);\n     va_end(ap);\n-\n+    /* If this failed, we'll fall back to writing the truncated line. */\n+  }\n+\n+  if (line_long) {\n+    nb = strlen(line_long);\n+    _PR_LOCK_LOG();\n+    if (logBuf != 0) {\n+      _PUT_LOG(logFile, logBuf, logp - logBuf);\n+      logp = logBuf;\n+    }\n     /*\n-     * Check if we might have run out of buffer space (in case we have a\n-     * long line), and malloc a buffer just this once.\n+     * Write out the thread id (with an optional timestamp) and the\n+     * malloc'ed buffer.\n      */\n-    if (nb == sizeof(line) - 2) {\n-        va_start(ap, fmt);\n-        line_long = PR_vsmprintf(fmt, ap);\n-        va_end(ap);\n-        /* If this failed, we'll fall back to writing the truncated line. */\n+    _PUT_LOG(logFile, line, nb_tid);\n+    _PUT_LOG(logFile, line_long, nb);\n+    /* Ensure there is a trailing newline. */\n+    if (!nb || (line_long[nb - 1] != '\\n')) {\n+      char eol[2];\n+      eol[0] = '\\n';\n+      eol[1] = '\\0';\n+      _PUT_LOG(logFile, eol, 1);\n     }\n-\n-    if (line_long) {\n-        nb = strlen(line_long);\n-        _PR_LOCK_LOG();\n-        if (logBuf != 0) {\n-            _PUT_LOG(logFile, logBuf, logp - logBuf);\n-            logp = logBuf;\n-        }\n-        /*\n-         * Write out the thread id (with an optional timestamp) and the\n-         * malloc'ed buffer.\n-         */\n-        _PUT_LOG(logFile, line, nb_tid);\n-        _PUT_LOG(logFile, line_long, nb);\n-        /* Ensure there is a trailing newline. */\n-        if (!nb || (line_long[nb - 1] != '\\n')) {\n-            char eol[2];\n-            eol[0] = '\\n';\n-            eol[1] = '\\0';\n-            _PUT_LOG(logFile, eol, 1);\n-        }\n-        _PR_UNLOCK_LOG();\n-        PR_smprintf_free(line_long);\n+    _PR_UNLOCK_LOG();\n+    PR_smprintf_free(line_long);\n+  } else {\n+    /* Ensure there is a trailing newline. */\n+    if (nb && (line[nb - 1] != '\\n')) {\n+      line[nb++] = '\\n';\n+      line[nb] = '\\0';\n+    }\n+    _PR_LOCK_LOG();\n+    if (logBuf == 0) {\n+      _PUT_LOG(logFile, line, nb);\n     } else {\n-        /* Ensure there is a trailing newline. */\n-        if (nb && (line[nb - 1] != '\\n')) {\n-            line[nb++] = '\\n';\n-            line[nb] = '\\0';\n-        }\n-        _PR_LOCK_LOG();\n-        if (logBuf == 0) {\n-            _PUT_LOG(logFile, line, nb);\n-        } else {\n-            /* If nb can't fit into logBuf, write out logBuf first. */\n-            if (logp + nb > logEndp) {\n-                _PUT_LOG(logFile, logBuf, logp - logBuf);\n-                logp = logBuf;\n-            }\n-            /* nb is guaranteed to fit into logBuf. */\n-            memcpy(logp, line, nb);\n-            logp += nb;\n-        }\n-        _PR_UNLOCK_LOG();\n+      /* If nb can't fit into logBuf, write out logBuf first. */\n+      if (logp + nb > logEndp) {\n+        _PUT_LOG(logFile, logBuf, logp - logBuf);\n+        logp = logBuf;\n+      }\n+      /* nb is guaranteed to fit into logBuf. */\n+      memcpy(logp, line, nb);\n+      logp += nb;\n     }\n-    PR_LogFlush();\n+    _PR_UNLOCK_LOG();\n+  }\n+  PR_LogFlush();\n }\n \n-PR_IMPLEMENT(void)\n-PR_LogFlush(void)\n-{\n-    if (logBuf && logFile) {\n-        _PR_LOCK_LOG();\n-        if (logp > logBuf) {\n-            _PUT_LOG(logFile, logBuf, logp - logBuf);\n-            logp = logBuf;\n-        }\n-        _PR_UNLOCK_LOG();\n+PR_IMPLEMENT(void) PR_LogFlush(void) {\n+  if (logBuf && logFile) {\n+    _PR_LOCK_LOG();\n+    if (logp > logBuf) {\n+      _PUT_LOG(logFile, logBuf, logp - logBuf);\n+      logp = logBuf;\n     }\n+    _PR_UNLOCK_LOG();\n+  }\n }\n \n-PR_IMPLEMENT(void)\n-PR_Abort(void)\n-{\n-    PR_LogPrint(\"Aborting\");\n+PR_IMPLEMENT(void) PR_Abort(void) {\n+  PR_LogPrint(\"Aborting\");\n #ifdef ANDROID\n-    __android_log_write(ANDROID_LOG_ERROR, \"PRLog\", \"Aborting\");\n+  __android_log_write(ANDROID_LOG_ERROR, \"PRLog\", \"Aborting\");\n #endif\n-    abort();\n+  abort();\n }\n \n-PR_IMPLEMENT(void)\n-PR_Assert(const char* s, const char* file, PRIntn ln)\n-{\n-    PR_LogPrint(\"Assertion failure: %s, at %s:%d\\n\", s, file, ln);\n-    fprintf(stderr, \"Assertion failure: %s, at %s:%d\\n\", s, file, ln);\n-    fflush(stderr);\n+PR_IMPLEMENT(void) PR_Assert(const char* s, const char* file, PRIntn ln) {\n+  PR_LogPrint(\"Assertion failure: %s, at %s:%d\\n\", s, file, ln);\n+  fprintf(stderr, \"Assertion failure: %s, at %s:%d\\n\", s, file, ln);\n+  fflush(stderr);\n #ifdef WIN32\n-    DebugBreak();\n+  DebugBreak();\n #elif defined(ANDROID)\n-    __android_log_assert(NULL, \"PRLog\", \"Assertion failure: %s, at %s:%d\\n\", s,\n-                         file, ln);\n+  __android_log_assert(NULL, \"PRLog\", \"Assertion failure: %s, at %s:%d\\n\", s,\n+                       file, ln);\n #endif\n-    abort();\n+  abort();\n }\ndiff --git a/nspr/pr/src/io/prmapopt.c b/nspr/pr/src/io/prmapopt.c\nindex 9e4e90c..c887c64 100644\n--- a/nspr/pr/src/io/prmapopt.c\n+++ b/nspr/pr/src/io/prmapopt.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -17,312 +18,308 @@\n  */\n \n #if defined(WINNT) || defined(__MINGW32__)\n-#include <winsock.h>\n+#  include <winsock.h>\n #endif\n \n /* MinGW doesn't define these in its winsock.h. */\n #ifdef __MINGW32__\n-#ifndef IP_TTL\n-#define IP_TTL 7\n-#endif\n-#ifndef IP_TOS\n-#define IP_TOS 8\n-#endif\n+#  ifndef IP_TTL\n+#    define IP_TTL 7\n+#  endif\n+#  ifndef IP_TOS\n+#    define IP_TOS 8\n+#  endif\n #endif\n \n #include \"primpl.h\"\n \n #if defined(LINUX) || defined(ANDROID)\n-#include <netinet/in.h>\n+#  include <netinet/in.h>\n #endif\n \n #ifdef DARWIN\n-#include <netinet/in.h>\n-#include <netinet/ip.h>\n+#  include <netinet/in.h>\n+#  include <netinet/ip.h>\n #endif\n \n #ifdef HAVE_NETINET_TCP_H\n-#include <netinet/tcp.h> /* TCP_NODELAY, TCP_MAXSEG */\n+#  include <netinet/tcp.h> /* TCP_NODELAY, TCP_MAXSEG */\n #endif\n \n #ifndef _PR_PTHREADS\n \n-PRStatus PR_CALLBACK\n-_PR_SocketGetSocketOption(PRFileDesc* fd,\n-                          PRSocketOptionData* data)\n-{\n-    PRStatus rv;\n-    PRInt32 length;\n-    PRInt32 level, name;\n-\n-    /*\n-     * PR_SockOpt_Nonblocking is a special case that does not\n-     * translate to a getsockopt() call\n-     */\n-    if (PR_SockOpt_Nonblocking == data->option) {\n-        data->value.non_blocking = fd->secret->nonblocking;\n-        return PR_SUCCESS;\n-    }\n-\n-    rv = _PR_MapOptionName(data->option, &level, &name);\n-    if (PR_SUCCESS == rv) {\n-        switch (data->option) {\n-            case PR_SockOpt_Linger: {\n-                struct linger linger;\n-                length = sizeof(linger);\n-                rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&linger, &length);\n-                if (PR_SUCCESS == rv) {\n-                    PR_ASSERT(sizeof(linger) == length);\n-                    data->value.linger.polarity = (linger.l_onoff) ? PR_TRUE : PR_FALSE;\n-                    data->value.linger.linger = PR_SecondsToInterval(linger.l_linger);\n-                }\n-                break;\n-            }\n-            case PR_SockOpt_Reuseaddr:\n-            case PR_SockOpt_Keepalive:\n-            case PR_SockOpt_NoDelay:\n-            case PR_SockOpt_Broadcast:\n-            case PR_SockOpt_Reuseport: {\n-#ifdef WIN32 /* Winsock */\n-                BOOL value;\n-#else\n-                PRIntn value;\n-#endif\n-                length = sizeof(value);\n-                rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&value, &length);\n-                if (PR_SUCCESS == rv) {\n-                    data->value.reuse_addr = (0 == value) ? PR_FALSE : PR_TRUE;\n-                }\n-                break;\n-            }\n-            case PR_SockOpt_McastLoopback: {\n-#ifdef WIN32 /* Winsock */\n-                BOOL bool;\n-#else\n-                PRUint8 bool;\n-#endif\n-                length = sizeof(bool);\n-                rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&bool, &length);\n-                if (PR_SUCCESS == rv) {\n-                    data->value.mcast_loopback = (0 == bool) ? PR_FALSE : PR_TRUE;\n-                }\n-                break;\n-            }\n-            case PR_SockOpt_RecvBufferSize:\n-            case PR_SockOpt_SendBufferSize:\n-            case PR_SockOpt_MaxSegment: {\n-                PRIntn value;\n-                length = sizeof(value);\n-                rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&value, &length);\n-                if (PR_SUCCESS == rv) {\n-                    data->value.recv_buffer_size = value;\n-                }\n-                break;\n-            }\n-            case PR_SockOpt_IpTimeToLive:\n-            case PR_SockOpt_IpTypeOfService: {\n-                /* These options should really be an int (or PRIntn). */\n-                length = sizeof(PRUintn);\n-                rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&data->value.ip_ttl,\n-                                       &length);\n-                break;\n-            }\n-            case PR_SockOpt_McastTimeToLive: {\n-#ifdef WIN32 /* Winsock */\n-                int ttl;\n-#else\n-                PRUint8 ttl;\n-#endif\n-                length = sizeof(ttl);\n-                rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&ttl, &length);\n-                if (PR_SUCCESS == rv) {\n-                    data->value.mcast_ttl = ttl;\n-                }\n-                break;\n-            }\n-#ifdef IP_ADD_MEMBERSHIP\n-            case PR_SockOpt_AddMember:\n-            case PR_SockOpt_DropMember: {\n-                struct ip_mreq mreq;\n-                length = sizeof(mreq);\n-                rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&mreq, &length);\n-                if (PR_SUCCESS == rv) {\n-                    data->value.add_member.mcaddr.inet.ip = mreq.imr_multiaddr.s_addr;\n-                    data->value.add_member.ifaddr.inet.ip = mreq.imr_interface.s_addr;\n-                }\n-                break;\n-            }\n-#endif /* IP_ADD_MEMBERSHIP */\n-            case PR_SockOpt_McastInterface: {\n-                /* This option is a struct in_addr. */\n-                length = sizeof(data->value.mcast_if.inet.ip);\n-                rv = _PR_MD_GETSOCKOPT(fd, level, name,\n-                                       (char*)&data->value.mcast_if.inet.ip, &length);\n-                break;\n-            }\n-            case PR_SockOpt_DontFrag: {\n-#if !defined(WIN32) && !defined(DARWIN) && !defined(LINUX) && \\\n-    !defined(ANDROID)\n-                PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, 0);\n-                rv = PR_FAILURE;\n-#else\n-#ifdef WIN32 /* Winsock */\n-                DWORD value;\n-#else\n-                PRIntn value;\n-#endif\n-                length = sizeof(value);\n-                rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&value, &length);\n-#if defined(WIN32) || defined(DARWIN)\n-                data->value.dont_fragment = value;\n-#else\n-                data->value.dont_fragment = (value == IP_PMTUDISC_DO) ? 1 : 0;\n-#endif\n-#endif /* !(!defined(WIN32) && !defined(DARWIN) && !defined(LINUX) && \\\n-          !defined(ANDROID)) */\n-                break;\n-            }\n-            default:\n-                PR_NOT_REACHED(\"Unknown socket option\");\n-                break;\n+PRStatus PR_CALLBACK _PR_SocketGetSocketOption(PRFileDesc* fd,\n+                                               PRSocketOptionData* data) {\n+  PRStatus rv;\n+  PRInt32 length;\n+  PRInt32 level, name;\n+\n+  /*\n+   * PR_SockOpt_Nonblocking is a special case that does not\n+   * translate to a getsockopt() call\n+   */\n+  if (PR_SockOpt_Nonblocking == data->option) {\n+    data->value.non_blocking = fd->secret->nonblocking;\n+    return PR_SUCCESS;\n+  }\n+\n+  rv = _PR_MapOptionName(data->option, &level, &name);\n+  if (PR_SUCCESS == rv) {\n+    switch (data->option) {\n+      case PR_SockOpt_Linger: {\n+        struct linger linger;\n+        length = sizeof(linger);\n+        rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&linger, &length);\n+        if (PR_SUCCESS == rv) {\n+          PR_ASSERT(sizeof(linger) == length);\n+          data->value.linger.polarity = (linger.l_onoff) ? PR_TRUE : PR_FALSE;\n+          data->value.linger.linger = PR_SecondsToInterval(linger.l_linger);\n+        }\n+        break;\n+      }\n+      case PR_SockOpt_Reuseaddr:\n+      case PR_SockOpt_Keepalive:\n+      case PR_SockOpt_NoDelay:\n+      case PR_SockOpt_Broadcast:\n+      case PR_SockOpt_Reuseport: {\n+#  ifdef WIN32 /* Winsock */\n+        BOOL value;\n+#  else\n+        PRIntn value;\n+#  endif\n+        length = sizeof(value);\n+        rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&value, &length);\n+        if (PR_SUCCESS == rv) {\n+          data->value.reuse_addr = (0 == value) ? PR_FALSE : PR_TRUE;\n+        }\n+        break;\n+      }\n+      case PR_SockOpt_McastLoopback: {\n+#  ifdef WIN32 /* Winsock */\n+        BOOL bool;\n+#  else\n+        PRUint8 bool;\n+#  endif\n+        length = sizeof(bool);\n+        rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&bool, &length);\n+        if (PR_SUCCESS == rv) {\n+          data->value.mcast_loopback = (0 == bool) ? PR_FALSE : PR_TRUE;\n+        }\n+        break;\n+      }\n+      case PR_SockOpt_RecvBufferSize:\n+      case PR_SockOpt_SendBufferSize:\n+      case PR_SockOpt_MaxSegment: {\n+        PRIntn value;\n+        length = sizeof(value);\n+        rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&value, &length);\n+        if (PR_SUCCESS == rv) {\n+          data->value.recv_buffer_size = value;\n         }\n+        break;\n+      }\n+      case PR_SockOpt_IpTimeToLive:\n+      case PR_SockOpt_IpTypeOfService: {\n+        /* These options should really be an int (or PRIntn). */\n+        length = sizeof(PRUintn);\n+        rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&data->value.ip_ttl,\n+                               &length);\n+        break;\n+      }\n+      case PR_SockOpt_McastTimeToLive: {\n+#  ifdef WIN32 /* Winsock */\n+        int ttl;\n+#  else\n+        PRUint8 ttl;\n+#  endif\n+        length = sizeof(ttl);\n+        rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&ttl, &length);\n+        if (PR_SUCCESS == rv) {\n+          data->value.mcast_ttl = ttl;\n+        }\n+        break;\n+      }\n+#  ifdef IP_ADD_MEMBERSHIP\n+      case PR_SockOpt_AddMember:\n+      case PR_SockOpt_DropMember: {\n+        struct ip_mreq mreq;\n+        length = sizeof(mreq);\n+        rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&mreq, &length);\n+        if (PR_SUCCESS == rv) {\n+          data->value.add_member.mcaddr.inet.ip = mreq.imr_multiaddr.s_addr;\n+          data->value.add_member.ifaddr.inet.ip = mreq.imr_interface.s_addr;\n+        }\n+        break;\n+      }\n+#  endif /* IP_ADD_MEMBERSHIP */\n+      case PR_SockOpt_McastInterface: {\n+        /* This option is a struct in_addr. */\n+        length = sizeof(data->value.mcast_if.inet.ip);\n+        rv = _PR_MD_GETSOCKOPT(fd, level, name,\n+                               (char*)&data->value.mcast_if.inet.ip, &length);\n+        break;\n+      }\n+      case PR_SockOpt_DontFrag: {\n+#  if !defined(WIN32) && !defined(DARWIN) && !defined(LINUX) && \\\n+      !defined(ANDROID)\n+        PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, 0);\n+        rv = PR_FAILURE;\n+#  else\n+#    ifdef WIN32 /* Winsock */\n+        DWORD value;\n+#    else\n+        PRIntn value;\n+#    endif\n+        length = sizeof(value);\n+        rv = _PR_MD_GETSOCKOPT(fd, level, name, (char*)&value, &length);\n+#    if defined(WIN32) || defined(DARWIN)\n+        data->value.dont_fragment = value;\n+#    else\n+        data->value.dont_fragment = (value == IP_PMTUDISC_DO) ? 1 : 0;\n+#    endif\n+#  endif /* !(!defined(WIN32) && !defined(DARWIN) && !defined(LINUX) && \\\n+            !defined(ANDROID)) */\n+        break;\n+      }\n+      default:\n+        PR_NOT_REACHED(\"Unknown socket option\");\n+        break;\n     }\n-    return rv;\n+  }\n+  return rv;\n } /* _PR_SocketGetSocketOption */\n \n-PRStatus PR_CALLBACK\n-_PR_SocketSetSocketOption(PRFileDesc* fd,\n-                          const PRSocketOptionData* data)\n-{\n-    PRStatus rv;\n-    PRInt32 level, name;\n-\n-    /*\n-     * PR_SockOpt_Nonblocking is a special case that does not\n-     * translate to a setsockopt call.\n-     */\n-    if (PR_SockOpt_Nonblocking == data->option) {\n-#ifdef WINNT\n-        PR_ASSERT((fd->secret->md.io_model_committed == PR_FALSE) ||\n-                  (fd->secret->nonblocking == data->value.non_blocking));\n-        if (fd->secret->md.io_model_committed &&\n-            (fd->secret->nonblocking != data->value.non_blocking)) {\n-            /*\n-             * On NT, once we have associated a socket with the io\n-             * completion port, we can't disassociate it.  So we\n-             * can't change the nonblocking option of the socket\n-             * afterwards.\n-             */\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            return PR_FAILURE;\n-        }\n-#endif\n-        fd->secret->nonblocking = data->value.non_blocking;\n-        return PR_SUCCESS;\n+PRStatus PR_CALLBACK _PR_SocketSetSocketOption(PRFileDesc* fd,\n+                                               const PRSocketOptionData* data) {\n+  PRStatus rv;\n+  PRInt32 level, name;\n+\n+  /*\n+   * PR_SockOpt_Nonblocking is a special case that does not\n+   * translate to a setsockopt call.\n+   */\n+  if (PR_SockOpt_Nonblocking == data->option) {\n+#  ifdef WINNT\n+    PR_ASSERT((fd->secret->md.io_model_committed == PR_FALSE) ||\n+              (fd->secret->nonblocking == data->value.non_blocking));\n+    if (fd->secret->md.io_model_committed &&\n+        (fd->secret->nonblocking != data->value.non_blocking)) {\n+      /*\n+       * On NT, once we have associated a socket with the io\n+       * completion port, we can't disassociate it.  So we\n+       * can't change the nonblocking option of the socket\n+       * afterwards.\n+       */\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      return PR_FAILURE;\n     }\n-\n-    rv = _PR_MapOptionName(data->option, &level, &name);\n-    if (PR_SUCCESS == rv) {\n-        switch (data->option) {\n-            case PR_SockOpt_Linger: {\n-                struct linger linger;\n-                linger.l_onoff = data->value.linger.polarity;\n-                linger.l_linger = PR_IntervalToSeconds(data->value.linger.linger);\n-                rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&linger, sizeof(linger));\n-                break;\n-            }\n-            case PR_SockOpt_Reuseaddr:\n-            case PR_SockOpt_Keepalive:\n-            case PR_SockOpt_NoDelay:\n-            case PR_SockOpt_Broadcast:\n-            case PR_SockOpt_Reuseport: {\n-#ifdef WIN32 /* Winsock */\n-                BOOL value;\n-#else\n-                PRIntn value;\n-#endif\n-                value = (data->value.reuse_addr) ? 1 : 0;\n-                rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&value, sizeof(value));\n-                break;\n-            }\n-            case PR_SockOpt_McastLoopback: {\n-#ifdef WIN32 /* Winsock */\n-                BOOL bool;\n-#else\n-                PRUint8 bool;\n-#endif\n-                bool = data->value.mcast_loopback ? 1 : 0;\n-                rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&bool, sizeof(bool));\n-                break;\n-            }\n-            case PR_SockOpt_RecvBufferSize:\n-            case PR_SockOpt_SendBufferSize:\n-            case PR_SockOpt_MaxSegment: {\n-                PRIntn value = data->value.recv_buffer_size;\n-                rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&value, sizeof(value));\n-                break;\n-            }\n-            case PR_SockOpt_IpTimeToLive:\n-            case PR_SockOpt_IpTypeOfService: {\n-                /* These options should really be an int (or PRIntn). */\n-                rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&data->value.ip_ttl,\n-                                       sizeof(PRUintn));\n-                break;\n-            }\n-            case PR_SockOpt_McastTimeToLive: {\n-#ifdef WIN32 /* Winsock */\n-                int ttl;\n-#else\n-                PRUint8 ttl;\n-#endif\n-                ttl = data->value.mcast_ttl;\n-                rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&ttl, sizeof(ttl));\n-                break;\n-            }\n-#ifdef IP_ADD_MEMBERSHIP\n-            case PR_SockOpt_AddMember:\n-            case PR_SockOpt_DropMember: {\n-                struct ip_mreq mreq;\n-                mreq.imr_multiaddr.s_addr = data->value.add_member.mcaddr.inet.ip;\n-                mreq.imr_interface.s_addr = data->value.add_member.ifaddr.inet.ip;\n-                rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&mreq, sizeof(mreq));\n-                break;\n-            }\n-#endif /* IP_ADD_MEMBERSHIP */\n-            case PR_SockOpt_McastInterface: {\n-                /* This option is a struct in_addr. */\n-                rv = _PR_MD_SETSOCKOPT(fd, level, name,\n-                                       (char*)&data->value.mcast_if.inet.ip,\n-                                       sizeof(data->value.mcast_if.inet.ip));\n-                break;\n-            }\n-            case PR_SockOpt_DontFrag: {\n-#if !defined(WIN32) && !defined(DARWIN) && !defined(LINUX) && \\\n-    !defined(ANDROID)\n-                PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, 0);\n-                rv = PR_FAILURE;\n-#else\n-#if defined(WIN32) /* Winsock */\n-                DWORD value;\n-                value = (data->value.dont_fragment) ? 1 : 0;\n-#elif defined(LINUX) || defined(ANDROID)\n-                PRIntn value;\n-                value = (data->value.dont_fragment) ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT;\n-#elif defined(DARWIN)\n-                PRIntn value;\n-                value = data->value.dont_fragment;\n-#endif\n-                rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&value, sizeof(value));\n-#endif /* !(!defined(WIN32) && !defined(DARWIN) && !defined(LINUX) && \\\n-          !defined(ANDROID)) */\n-                break;\n-            }\n-            default:\n-                PR_NOT_REACHED(\"Unknown socket option\");\n-                break;\n-        }\n+#  endif\n+    fd->secret->nonblocking = data->value.non_blocking;\n+    return PR_SUCCESS;\n+  }\n+\n+  rv = _PR_MapOptionName(data->option, &level, &name);\n+  if (PR_SUCCESS == rv) {\n+    switch (data->option) {\n+      case PR_SockOpt_Linger: {\n+        struct linger linger;\n+        linger.l_onoff = data->value.linger.polarity;\n+        linger.l_linger = PR_IntervalToSeconds(data->value.linger.linger);\n+        rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&linger, sizeof(linger));\n+        break;\n+      }\n+      case PR_SockOpt_Reuseaddr:\n+      case PR_SockOpt_Keepalive:\n+      case PR_SockOpt_NoDelay:\n+      case PR_SockOpt_Broadcast:\n+      case PR_SockOpt_Reuseport: {\n+#  ifdef WIN32 /* Winsock */\n+        BOOL value;\n+#  else\n+        PRIntn value;\n+#  endif\n+        value = (data->value.reuse_addr) ? 1 : 0;\n+        rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&value, sizeof(value));\n+        break;\n+      }\n+      case PR_SockOpt_McastLoopback: {\n+#  ifdef WIN32 /* Winsock */\n+        BOOL bool;\n+#  else\n+        PRUint8 bool;\n+#  endif\n+        bool = data->value.mcast_loopback ? 1 : 0;\n+        rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&bool, sizeof(bool));\n+        break;\n+      }\n+      case PR_SockOpt_RecvBufferSize:\n+      case PR_SockOpt_SendBufferSize:\n+      case PR_SockOpt_MaxSegment: {\n+        PRIntn value = data->value.recv_buffer_size;\n+        rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&value, sizeof(value));\n+        break;\n+      }\n+      case PR_SockOpt_IpTimeToLive:\n+      case PR_SockOpt_IpTypeOfService: {\n+        /* These options should really be an int (or PRIntn). */\n+        rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&data->value.ip_ttl,\n+                               sizeof(PRUintn));\n+        break;\n+      }\n+      case PR_SockOpt_McastTimeToLive: {\n+#  ifdef WIN32 /* Winsock */\n+        int ttl;\n+#  else\n+        PRUint8 ttl;\n+#  endif\n+        ttl = data->value.mcast_ttl;\n+        rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&ttl, sizeof(ttl));\n+        break;\n+      }\n+#  ifdef IP_ADD_MEMBERSHIP\n+      case PR_SockOpt_AddMember:\n+      case PR_SockOpt_DropMember: {\n+        struct ip_mreq mreq;\n+        mreq.imr_multiaddr.s_addr = data->value.add_member.mcaddr.inet.ip;\n+        mreq.imr_interface.s_addr = data->value.add_member.ifaddr.inet.ip;\n+        rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&mreq, sizeof(mreq));\n+        break;\n+      }\n+#  endif /* IP_ADD_MEMBERSHIP */\n+      case PR_SockOpt_McastInterface: {\n+        /* This option is a struct in_addr. */\n+        rv = _PR_MD_SETSOCKOPT(fd, level, name,\n+                               (char*)&data->value.mcast_if.inet.ip,\n+                               sizeof(data->value.mcast_if.inet.ip));\n+        break;\n+      }\n+      case PR_SockOpt_DontFrag: {\n+#  if !defined(WIN32) && !defined(DARWIN) && !defined(LINUX) && \\\n+      !defined(ANDROID)\n+        PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, 0);\n+        rv = PR_FAILURE;\n+#  else\n+#    if defined(WIN32) /* Winsock */\n+        DWORD value;\n+        value = (data->value.dont_fragment) ? 1 : 0;\n+#    elif defined(LINUX) || defined(ANDROID)\n+        PRIntn value;\n+        value = (data->value.dont_fragment) ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT;\n+#    elif defined(DARWIN)\n+        PRIntn value;\n+        value = data->value.dont_fragment;\n+#    endif\n+        rv = _PR_MD_SETSOCKOPT(fd, level, name, (char*)&value, sizeof(value));\n+#  endif /* !(!defined(WIN32) && !defined(DARWIN) && !defined(LINUX) && \\\n+            !defined(ANDROID)) */\n+        break;\n+      }\n+      default:\n+        PR_NOT_REACHED(\"Unknown socket option\");\n+        break;\n     }\n-    return rv;\n+  }\n+  return rv;\n } /* _PR_SocketSetSocketOption */\n \n #endif /* ! _PR_PTHREADS */\n@@ -358,11 +355,11 @@ _PR_SocketSetSocketOption(PRFileDesc* fd,\n  */\n \n #if !defined(SO_LINGER)\n-#error \"SO_LINGER is not defined\"\n+#  error \"SO_LINGER is not defined\"\n #endif\n \n #if !defined(TCP_NODELAY)\n-#error \"TCP_NODELAY is not defined\"\n+#  error \"TCP_NODELAY is not defined\"\n #endif\n \n /*\n@@ -372,126 +369,123 @@ _PR_SocketSetSocketOption(PRFileDesc* fd,\n #define _PR_NO_SUCH_SOCKOPT -1\n \n #ifndef SO_KEEPALIVE\n-#define SO_KEEPALIVE _PR_NO_SUCH_SOCKOPT\n+#  define SO_KEEPALIVE _PR_NO_SUCH_SOCKOPT\n #endif\n \n #ifndef SO_SNDBUF\n-#define SO_SNDBUF _PR_NO_SUCH_SOCKOPT\n+#  define SO_SNDBUF _PR_NO_SUCH_SOCKOPT\n #endif\n \n #ifndef SO_RCVBUF\n-#define SO_RCVBUF _PR_NO_SUCH_SOCKOPT\n+#  define SO_RCVBUF _PR_NO_SUCH_SOCKOPT\n #endif\n \n #ifndef IP_MULTICAST_IF /* set/get IP multicast interface   */\n-#define IP_MULTICAST_IF _PR_NO_SUCH_SOCKOPT\n+#  define IP_MULTICAST_IF _PR_NO_SUCH_SOCKOPT\n #endif\n \n #ifndef IP_MULTICAST_TTL /* set/get IP multicast timetolive  */\n-#define IP_MULTICAST_TTL _PR_NO_SUCH_SOCKOPT\n+#  define IP_MULTICAST_TTL _PR_NO_SUCH_SOCKOPT\n #endif\n \n #ifndef IP_MULTICAST_LOOP /* set/get IP multicast loopback    */\n-#define IP_MULTICAST_LOOP _PR_NO_SUCH_SOCKOPT\n+#  define IP_MULTICAST_LOOP _PR_NO_SUCH_SOCKOPT\n #endif\n \n #ifndef IP_ADD_MEMBERSHIP /* add  an IP group membership      */\n-#define IP_ADD_MEMBERSHIP _PR_NO_SUCH_SOCKOPT\n+#  define IP_ADD_MEMBERSHIP _PR_NO_SUCH_SOCKOPT\n #endif\n \n #ifndef IP_DROP_MEMBERSHIP /* drop an IP group membership      */\n-#define IP_DROP_MEMBERSHIP _PR_NO_SUCH_SOCKOPT\n+#  define IP_DROP_MEMBERSHIP _PR_NO_SUCH_SOCKOPT\n #endif\n \n #ifndef IP_TTL /* set/get IP Time To Live          */\n-#define IP_TTL _PR_NO_SUCH_SOCKOPT\n+#  define IP_TTL _PR_NO_SUCH_SOCKOPT\n #endif\n \n #ifndef IP_TOS /* set/get IP Type Of Service       */\n-#define IP_TOS _PR_NO_SUCH_SOCKOPT\n+#  define IP_TOS _PR_NO_SUCH_SOCKOPT\n #endif\n \n /* set/get IP do not fragment */\n #if defined(WIN32)\n-#ifndef IP_DONTFRAGMENT\n-#define IP_DONTFRAGMENT _PR_NO_SUCH_SOCKOPT\n-#endif\n+#  ifndef IP_DONTFRAGMENT\n+#    define IP_DONTFRAGMENT _PR_NO_SUCH_SOCKOPT\n+#  endif\n \n #elif defined(LINUX) || defined(ANDROID)\n-#ifndef IP_MTU_DISCOVER\n-#define IP_MTU_DISCOVER _PR_NO_SUCH_SOCKOPT\n-#endif\n+#  ifndef IP_MTU_DISCOVER\n+#    define IP_MTU_DISCOVER _PR_NO_SUCH_SOCKOPT\n+#  endif\n \n #elif defined(DARWIN)\n-#ifndef IP_DONTFRAG\n-#define IP_DONTFRAG _PR_NO_SUCH_SOCKOPT\n-#endif\n+#  ifndef IP_DONTFRAG\n+#    define IP_DONTFRAG _PR_NO_SUCH_SOCKOPT\n+#  endif\n #endif\n \n #ifndef TCP_NODELAY /* don't delay to coalesce data     */\n-#define TCP_NODELAY _PR_NO_SUCH_SOCKOPT\n+#  define TCP_NODELAY _PR_NO_SUCH_SOCKOPT\n #endif\n \n #ifndef TCP_MAXSEG /* maxumum segment size for tcp     */\n-#define TCP_MAXSEG _PR_NO_SUCH_SOCKOPT\n+#  define TCP_MAXSEG _PR_NO_SUCH_SOCKOPT\n #endif\n \n #ifndef SO_BROADCAST /* enable broadcast on UDP sockets  */\n-#define SO_BROADCAST _PR_NO_SUCH_SOCKOPT\n+#  define SO_BROADCAST _PR_NO_SUCH_SOCKOPT\n #endif\n \n #ifndef SO_REUSEPORT /* allow local address & port reuse */\n-#define SO_REUSEPORT _PR_NO_SUCH_SOCKOPT\n-#endif\n-\n-PRStatus\n-_PR_MapOptionName(PRSockOption optname, PRInt32* level,\n-                  PRInt32* name)\n-{\n-    static PRInt32 socketOptions[PR_SockOpt_Last] = {\n-        0,\n-        SO_LINGER,\n-        SO_REUSEADDR,\n-        SO_KEEPALIVE,\n-        SO_RCVBUF,\n-        SO_SNDBUF,\n-        IP_TTL,\n-        IP_TOS,\n-        IP_ADD_MEMBERSHIP,\n-        IP_DROP_MEMBERSHIP,\n-        IP_MULTICAST_IF,\n-        IP_MULTICAST_TTL,\n-        IP_MULTICAST_LOOP,\n-        TCP_NODELAY,\n-        TCP_MAXSEG,\n-        SO_BROADCAST,\n-        SO_REUSEPORT,\n+#  define SO_REUSEPORT _PR_NO_SUCH_SOCKOPT\n+#endif\n+\n+PRStatus _PR_MapOptionName(PRSockOption optname, PRInt32* level,\n+                           PRInt32* name) {\n+  static PRInt32 socketOptions[PR_SockOpt_Last] = {\n+      0,\n+      SO_LINGER,\n+      SO_REUSEADDR,\n+      SO_KEEPALIVE,\n+      SO_RCVBUF,\n+      SO_SNDBUF,\n+      IP_TTL,\n+      IP_TOS,\n+      IP_ADD_MEMBERSHIP,\n+      IP_DROP_MEMBERSHIP,\n+      IP_MULTICAST_IF,\n+      IP_MULTICAST_TTL,\n+      IP_MULTICAST_LOOP,\n+      TCP_NODELAY,\n+      TCP_MAXSEG,\n+      SO_BROADCAST,\n+      SO_REUSEPORT,\n #if defined(WIN32)\n-        IP_DONTFRAGMENT,\n+      IP_DONTFRAGMENT,\n #elif defined(LINUX) || defined(ANDROID)\n-        IP_MTU_DISCOVER,\n+      IP_MTU_DISCOVER,\n #elif defined(DARWIN)\n-        IP_DONTFRAG,\n+      IP_DONTFRAG,\n #else\n-        _PR_NO_SUCH_SOCKOPT,\n-#endif\n-    };\n-    static PRInt32 socketLevels[PR_SockOpt_Last] = {\n-        0, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET,\n-        IPPROTO_IP, IPPROTO_IP, IPPROTO_IP, IPPROTO_IP, IPPROTO_IP, IPPROTO_IP,\n-        IPPROTO_IP, IPPROTO_TCP, IPPROTO_TCP, SOL_SOCKET, SOL_SOCKET, IPPROTO_IP\n-    };\n-\n-    if ((optname < PR_SockOpt_Linger) || (optname >= PR_SockOpt_Last)) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-\n-    if (socketOptions[optname] == _PR_NO_SUCH_SOCKOPT) {\n-        PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    *name = socketOptions[optname];\n-    *level = socketLevels[optname];\n-    return PR_SUCCESS;\n+      _PR_NO_SUCH_SOCKOPT,\n+#endif\n+  };\n+  static PRInt32 socketLevels[PR_SockOpt_Last] = {\n+      0,          SOL_SOCKET,  SOL_SOCKET,  SOL_SOCKET, SOL_SOCKET, SOL_SOCKET,\n+      IPPROTO_IP, IPPROTO_IP,  IPPROTO_IP,  IPPROTO_IP, IPPROTO_IP, IPPROTO_IP,\n+      IPPROTO_IP, IPPROTO_TCP, IPPROTO_TCP, SOL_SOCKET, SOL_SOCKET, IPPROTO_IP};\n+\n+  if ((optname < PR_SockOpt_Linger) || (optname >= PR_SockOpt_Last)) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+\n+  if (socketOptions[optname] == _PR_NO_SUCH_SOCKOPT) {\n+    PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  *name = socketOptions[optname];\n+  *level = socketLevels[optname];\n+  return PR_SUCCESS;\n } /* _PR_MapOptionName */\ndiff --git a/nspr/pr/src/io/prmmap.c b/nspr/pr/src/io/prmmap.c\nindex 1231b50..69b0e25 100644\n--- a/nspr/pr/src/io/prmmap.c\n+++ b/nspr/pr/src/io/prmmap.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -13,52 +14,42 @@\n #include \"primpl.h\"\n \n PR_IMPLEMENT(PRFileMap*)\n-PR_CreateFileMap(PRFileDesc* fd, PRInt64 size, PRFileMapProtect prot)\n-{\n-    PRFileMap* fmap;\n-\n-    PR_ASSERT(prot == PR_PROT_READONLY || prot == PR_PROT_READWRITE ||\n-              prot == PR_PROT_WRITECOPY);\n-    fmap = PR_NEWZAP(PRFileMap);\n-    if (NULL == fmap) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n-    }\n-    fmap->fd = fd;\n-    fmap->prot = prot;\n-    if (_PR_MD_CREATE_FILE_MAP(fmap, size) == PR_SUCCESS) {\n-        return fmap;\n-    }\n-    PR_DELETE(fmap);\n+PR_CreateFileMap(PRFileDesc* fd, PRInt64 size, PRFileMapProtect prot) {\n+  PRFileMap* fmap;\n+\n+  PR_ASSERT(prot == PR_PROT_READONLY || prot == PR_PROT_READWRITE ||\n+            prot == PR_PROT_WRITECOPY);\n+  fmap = PR_NEWZAP(PRFileMap);\n+  if (NULL == fmap) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n     return NULL;\n+  }\n+  fmap->fd = fd;\n+  fmap->prot = prot;\n+  if (_PR_MD_CREATE_FILE_MAP(fmap, size) == PR_SUCCESS) {\n+    return fmap;\n+  }\n+  PR_DELETE(fmap);\n+  return NULL;\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_GetMemMapAlignment(void)\n-{\n-    return _PR_MD_GET_MEM_MAP_ALIGNMENT();\n+PR_IMPLEMENT(PRInt32) PR_GetMemMapAlignment(void) {\n+  return _PR_MD_GET_MEM_MAP_ALIGNMENT();\n }\n \n PR_IMPLEMENT(void*)\n-PR_MemMap(PRFileMap* fmap, PROffset64 offset, PRUint32 len)\n-{\n-    return _PR_MD_MEM_MAP(fmap, offset, len);\n+PR_MemMap(PRFileMap* fmap, PROffset64 offset, PRUint32 len) {\n+  return _PR_MD_MEM_MAP(fmap, offset, len);\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_MemUnmap(void* addr, PRUint32 len)\n-{\n-    return _PR_MD_MEM_UNMAP(addr, len);\n+PR_IMPLEMENT(PRStatus) PR_MemUnmap(void* addr, PRUint32 len) {\n+  return _PR_MD_MEM_UNMAP(addr, len);\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CloseFileMap(PRFileMap* fmap)\n-{\n-    return _PR_MD_CLOSE_FILE_MAP(fmap);\n+PR_IMPLEMENT(PRStatus) PR_CloseFileMap(PRFileMap* fmap) {\n+  return _PR_MD_CLOSE_FILE_MAP(fmap);\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len)\n-{\n-    return _PR_MD_SYNC_MEM_MAP(fd, addr, len);\n+PR_IMPLEMENT(PRStatus) PR_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len) {\n+  return _PR_MD_SYNC_MEM_MAP(fd, addr, len);\n }\ndiff --git a/nspr/pr/src/io/prmwait.c b/nspr/pr/src/io/prmwait.c\nindex ebc6ab6..ce24a5d 100644\n--- a/nspr/pr/src/io/prmwait.c\n+++ b/nspr/pr/src/io/prmwait.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -15,22 +16,22 @@ static PRIntervalTime max_polling_interval;\n #ifdef WINNT\n \n typedef struct TimerEvent {\n-    PRIntervalTime absolute;\n-    void (*func)(void*);\n-    void* arg;\n-    LONG ref_count;\n-    PRCList links;\n+  PRIntervalTime absolute;\n+  void (*func)(void*);\n+  void* arg;\n+  LONG ref_count;\n+  PRCList links;\n } TimerEvent;\n \n-#define TIMER_EVENT_PTR(_qp) \\\n+#  define TIMER_EVENT_PTR(_qp) \\\n     ((TimerEvent*)((char*)(_qp) - offsetof(TimerEvent, links)))\n \n struct {\n-    PRLock* ml;\n-    PRCondVar* new_timer;\n-    PRCondVar* cancel_timer;\n-    PRThread* manager_thread;\n-    PRCList timer_queue;\n+  PRLock* ml;\n+  PRCondVar* new_timer;\n+  PRCondVar* cancel_timer;\n+  PRThread* manager_thread;\n+  PRCList timer_queue;\n } tm_vars;\n \n static PRStatus TimerInit(void);\n@@ -39,133 +40,125 @@ static TimerEvent* CreateTimer(PRIntervalTime timeout, void (*func)(void*),\n                                void* arg);\n static PRBool CancelTimer(TimerEvent* timer);\n \n-static void\n-TimerManager(void* arg)\n-{\n-    PRIntervalTime now;\n-    PRIntervalTime timeout;\n-    PRCList* head;\n-    TimerEvent* timer;\n-\n-    PR_Lock(tm_vars.ml);\n-    while (1) {\n-        if (PR_CLIST_IS_EMPTY(&tm_vars.timer_queue)) {\n-            PR_WaitCondVar(tm_vars.new_timer, PR_INTERVAL_NO_TIMEOUT);\n-        } else {\n-            now = PR_IntervalNow();\n-            head = PR_LIST_HEAD(&tm_vars.timer_queue);\n-            timer = TIMER_EVENT_PTR(head);\n-            if ((PRInt32)(now - timer->absolute) >= 0) {\n-                PR_REMOVE_LINK(head);\n-                /*\n-                 * make its prev and next point to itself so that\n-                 * it's obvious that it's not on the timer_queue.\n-                 */\n-                PR_INIT_CLIST(head);\n-                PR_ASSERT(2 == timer->ref_count);\n-                PR_Unlock(tm_vars.ml);\n-                timer->func(timer->arg);\n-                PR_Lock(tm_vars.ml);\n-                timer->ref_count -= 1;\n-                if (0 == timer->ref_count) {\n-                    PR_NotifyAllCondVar(tm_vars.cancel_timer);\n-                }\n-            } else {\n-                timeout = (PRIntervalTime)(timer->absolute - now);\n-                PR_WaitCondVar(tm_vars.new_timer, timeout);\n-            }\n+static void TimerManager(void* arg) {\n+  PRIntervalTime now;\n+  PRIntervalTime timeout;\n+  PRCList* head;\n+  TimerEvent* timer;\n+\n+  PR_Lock(tm_vars.ml);\n+  while (1) {\n+    if (PR_CLIST_IS_EMPTY(&tm_vars.timer_queue)) {\n+      PR_WaitCondVar(tm_vars.new_timer, PR_INTERVAL_NO_TIMEOUT);\n+    } else {\n+      now = PR_IntervalNow();\n+      head = PR_LIST_HEAD(&tm_vars.timer_queue);\n+      timer = TIMER_EVENT_PTR(head);\n+      if ((PRInt32)(now - timer->absolute) >= 0) {\n+        PR_REMOVE_LINK(head);\n+        /*\n+         * make its prev and next point to itself so that\n+         * it's obvious that it's not on the timer_queue.\n+         */\n+        PR_INIT_CLIST(head);\n+        PR_ASSERT(2 == timer->ref_count);\n+        PR_Unlock(tm_vars.ml);\n+        timer->func(timer->arg);\n+        PR_Lock(tm_vars.ml);\n+        timer->ref_count -= 1;\n+        if (0 == timer->ref_count) {\n+          PR_NotifyAllCondVar(tm_vars.cancel_timer);\n         }\n+      } else {\n+        timeout = (PRIntervalTime)(timer->absolute - now);\n+        PR_WaitCondVar(tm_vars.new_timer, timeout);\n+      }\n     }\n-    PR_Unlock(tm_vars.ml);\n+  }\n+  PR_Unlock(tm_vars.ml);\n }\n \n-static TimerEvent*\n-CreateTimer(PRIntervalTime timeout, void (*func)(void*),\n-            void* arg)\n-{\n-    TimerEvent* timer;\n-    PRCList *links, *tail;\n-    TimerEvent* elem;\n+static TimerEvent* CreateTimer(PRIntervalTime timeout, void (*func)(void*),\n+                               void* arg) {\n+  TimerEvent* timer;\n+  PRCList *links, *tail;\n+  TimerEvent* elem;\n \n-    timer = PR_NEW(TimerEvent);\n-    if (NULL == timer) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return timer;\n-    }\n-    timer->absolute = PR_IntervalNow() + timeout;\n-    timer->func = func;\n-    timer->arg = arg;\n-    timer->ref_count = 2;\n-    PR_Lock(tm_vars.ml);\n-    tail = links = PR_LIST_TAIL(&tm_vars.timer_queue);\n-    while (links->prev != tail) {\n-        elem = TIMER_EVENT_PTR(links);\n-        if ((PRInt32)(timer->absolute - elem->absolute) >= 0) {\n-            break;\n-        }\n-        links = links->prev;\n-    }\n-    PR_INSERT_AFTER(&timer->links, links);\n-    PR_NotifyCondVar(tm_vars.new_timer);\n-    PR_Unlock(tm_vars.ml);\n+  timer = PR_NEW(TimerEvent);\n+  if (NULL == timer) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n     return timer;\n+  }\n+  timer->absolute = PR_IntervalNow() + timeout;\n+  timer->func = func;\n+  timer->arg = arg;\n+  timer->ref_count = 2;\n+  PR_Lock(tm_vars.ml);\n+  tail = links = PR_LIST_TAIL(&tm_vars.timer_queue);\n+  while (links->prev != tail) {\n+    elem = TIMER_EVENT_PTR(links);\n+    if ((PRInt32)(timer->absolute - elem->absolute) >= 0) {\n+      break;\n+    }\n+    links = links->prev;\n+  }\n+  PR_INSERT_AFTER(&timer->links, links);\n+  PR_NotifyCondVar(tm_vars.new_timer);\n+  PR_Unlock(tm_vars.ml);\n+  return timer;\n }\n \n-static PRBool\n-CancelTimer(TimerEvent* timer)\n-{\n-    PRBool canceled = PR_FALSE;\n-\n-    PR_Lock(tm_vars.ml);\n-    timer->ref_count -= 1;\n-    if (timer->links.prev == &timer->links) {\n-        while (timer->ref_count == 1) {\n-            PR_WaitCondVar(tm_vars.cancel_timer, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-    } else {\n-        PR_REMOVE_LINK(&timer->links);\n-        canceled = PR_TRUE;\n-    }\n-    PR_Unlock(tm_vars.ml);\n-    PR_DELETE(timer);\n-    return canceled;\n+static PRBool CancelTimer(TimerEvent* timer) {\n+  PRBool canceled = PR_FALSE;\n+\n+  PR_Lock(tm_vars.ml);\n+  timer->ref_count -= 1;\n+  if (timer->links.prev == &timer->links) {\n+    while (timer->ref_count == 1) {\n+      PR_WaitCondVar(tm_vars.cancel_timer, PR_INTERVAL_NO_TIMEOUT);\n+    }\n+  } else {\n+    PR_REMOVE_LINK(&timer->links);\n+    canceled = PR_TRUE;\n+  }\n+  PR_Unlock(tm_vars.ml);\n+  PR_DELETE(timer);\n+  return canceled;\n }\n \n-static PRStatus\n-TimerInit(void)\n-{\n-    tm_vars.ml = PR_NewLock();\n-    if (NULL == tm_vars.ml) {\n-        goto failed;\n-    }\n-    tm_vars.new_timer = PR_NewCondVar(tm_vars.ml);\n-    if (NULL == tm_vars.new_timer) {\n-        goto failed;\n-    }\n-    tm_vars.cancel_timer = PR_NewCondVar(tm_vars.ml);\n-    if (NULL == tm_vars.cancel_timer) {\n-        goto failed;\n-    }\n-    PR_INIT_CLIST(&tm_vars.timer_queue);\n-    tm_vars.manager_thread =\n-        PR_CreateThread(PR_SYSTEM_THREAD, TimerManager, NULL, PR_PRIORITY_NORMAL,\n-                        PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    if (NULL == tm_vars.manager_thread) {\n-        goto failed;\n-    }\n-    return PR_SUCCESS;\n+static PRStatus TimerInit(void) {\n+  tm_vars.ml = PR_NewLock();\n+  if (NULL == tm_vars.ml) {\n+    goto failed;\n+  }\n+  tm_vars.new_timer = PR_NewCondVar(tm_vars.ml);\n+  if (NULL == tm_vars.new_timer) {\n+    goto failed;\n+  }\n+  tm_vars.cancel_timer = PR_NewCondVar(tm_vars.ml);\n+  if (NULL == tm_vars.cancel_timer) {\n+    goto failed;\n+  }\n+  PR_INIT_CLIST(&tm_vars.timer_queue);\n+  tm_vars.manager_thread =\n+      PR_CreateThread(PR_SYSTEM_THREAD, TimerManager, NULL, PR_PRIORITY_NORMAL,\n+                      PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  if (NULL == tm_vars.manager_thread) {\n+    goto failed;\n+  }\n+  return PR_SUCCESS;\n \n failed:\n-    if (NULL != tm_vars.cancel_timer) {\n-        PR_DestroyCondVar(tm_vars.cancel_timer);\n-    }\n-    if (NULL != tm_vars.new_timer) {\n-        PR_DestroyCondVar(tm_vars.new_timer);\n-    }\n-    if (NULL != tm_vars.ml) {\n-        PR_DestroyLock(tm_vars.ml);\n-    }\n-    return PR_FAILURE;\n+  if (NULL != tm_vars.cancel_timer) {\n+    PR_DestroyCondVar(tm_vars.cancel_timer);\n+  }\n+  if (NULL != tm_vars.new_timer) {\n+    PR_DestroyCondVar(tm_vars.new_timer);\n+  }\n+  if (NULL != tm_vars.ml) {\n+    PR_DestroyLock(tm_vars.ml);\n+  }\n+  return PR_FAILURE;\n }\n \n #endif /* WINNT */\n@@ -175,501 +168,475 @@ failed:\n /************************ The private portion *********************/\n /******************************************************************/\n /******************************************************************/\n-void\n-_PR_InitMW(void)\n-{\n+void _PR_InitMW(void) {\n #ifdef WINNT\n-    /*\n-     * We use NT 4's InterlockedCompareExchange() to operate\n-     * on PRMWStatus variables.\n-     */\n-    PR_ASSERT(sizeof(LONG) == sizeof(PRMWStatus));\n-    TimerInit();\n+  /*\n+   * We use NT 4's InterlockedCompareExchange() to operate\n+   * on PRMWStatus variables.\n+   */\n+  PR_ASSERT(sizeof(LONG) == sizeof(PRMWStatus));\n+  TimerInit();\n #endif\n-    mw_lock = PR_NewLock();\n-    PR_ASSERT(NULL != mw_lock);\n-    mw_state = PR_NEWZAP(_PRGlobalState);\n-    PR_ASSERT(NULL != mw_state);\n-    PR_INIT_CLIST(&mw_state->group_list);\n-    max_polling_interval = PR_MillisecondsToInterval(MAX_POLLING_INTERVAL);\n+  mw_lock = PR_NewLock();\n+  PR_ASSERT(NULL != mw_lock);\n+  mw_state = PR_NEWZAP(_PRGlobalState);\n+  PR_ASSERT(NULL != mw_state);\n+  PR_INIT_CLIST(&mw_state->group_list);\n+  max_polling_interval = PR_MillisecondsToInterval(MAX_POLLING_INTERVAL);\n } /* _PR_InitMW */\n \n-void\n-_PR_CleanupMW(void)\n-{\n-    PR_DestroyLock(mw_lock);\n-    mw_lock = NULL;\n-    if (mw_state->group) {\n-        PR_DestroyWaitGroup(mw_state->group);\n-        /* mw_state->group is set to NULL as a side effect. */\n-    }\n-    PR_DELETE(mw_state);\n+void _PR_CleanupMW(void) {\n+  PR_DestroyLock(mw_lock);\n+  mw_lock = NULL;\n+  if (mw_state->group) {\n+    PR_DestroyWaitGroup(mw_state->group);\n+    /* mw_state->group is set to NULL as a side effect. */\n+  }\n+  PR_DELETE(mw_state);\n } /* _PR_CleanupMW */\n \n-static PRWaitGroup*\n-MW_Init2(void)\n-{\n-    PRWaitGroup* group = mw_state->group; /* it's the null group */\n-    if (NULL == group)                    /* there is this special case */\n-    {\n-        group = PR_CreateWaitGroup(_PR_DEFAULT_HASH_LENGTH);\n-        if (NULL == group) {\n-            goto failed_alloc;\n-        }\n-        PR_Lock(mw_lock);\n-        if (NULL == mw_state->group) {\n-            mw_state->group = group;\n-            group = NULL;\n-        }\n-        PR_Unlock(mw_lock);\n-        if (group != NULL) {\n-            (void)PR_DestroyWaitGroup(group);\n-        }\n-        group = mw_state->group; /* somebody beat us to it */\n+static PRWaitGroup* MW_Init2(void) {\n+  PRWaitGroup* group = mw_state->group; /* it's the null group */\n+  if (NULL == group)                    /* there is this special case */\n+  {\n+    group = PR_CreateWaitGroup(_PR_DEFAULT_HASH_LENGTH);\n+    if (NULL == group) {\n+      goto failed_alloc;\n+    }\n+    PR_Lock(mw_lock);\n+    if (NULL == mw_state->group) {\n+      mw_state->group = group;\n+      group = NULL;\n     }\n+    PR_Unlock(mw_lock);\n+    if (group != NULL) {\n+      (void)PR_DestroyWaitGroup(group);\n+    }\n+    group = mw_state->group; /* somebody beat us to it */\n+  }\n failed_alloc:\n-    return group; /* whatever */\n+  return group; /* whatever */\n } /* MW_Init2 */\n \n-static _PR_HashStory\n-MW_AddHashInternal(PRRecvWait* desc, _PRWaiterHash* hash)\n-{\n-    /*\n-    ** The entries are put in the table using the fd (PRFileDesc*) of\n-    ** the receive descriptor as the key. This allows us to locate\n-    ** the appropriate entry aqain when the poll operation finishes.\n-    **\n-    ** The pointer to the file descriptor object is first divided by\n-    ** the natural alignment of a pointer in the belief that object\n-    ** will have at least that many zeros in the low order bits.\n-    ** This may not be a good assuption.\n-    **\n-    ** We try to put the entry in by rehashing _MW_REHASH_MAX times. After\n-    ** that we declare defeat and force the table to be reconstructed.\n-    ** Since some fds might be added more than once, won't that cause\n-    ** collisions even in an empty table?\n-    */\n-    PRIntn rehash = _MW_REHASH_MAX;\n-    PRRecvWait** waiter;\n-    PRUintn hidx = _MW_HASH(desc->fd, hash->length);\n-    PRUintn hoffset = 0;\n-\n-    while (rehash-- > 0) {\n-        waiter = &hash->recv_wait;\n-        if (NULL == waiter[hidx]) {\n-            waiter[hidx] = desc;\n-            hash->count += 1;\n+static _PR_HashStory MW_AddHashInternal(PRRecvWait* desc, _PRWaiterHash* hash) {\n+  /*\n+  ** The entries are put in the table using the fd (PRFileDesc*) of\n+  ** the receive descriptor as the key. This allows us to locate\n+  ** the appropriate entry aqain when the poll operation finishes.\n+  **\n+  ** The pointer to the file descriptor object is first divided by\n+  ** the natural alignment of a pointer in the belief that object\n+  ** will have at least that many zeros in the low order bits.\n+  ** This may not be a good assuption.\n+  **\n+  ** We try to put the entry in by rehashing _MW_REHASH_MAX times. After\n+  ** that we declare defeat and force the table to be reconstructed.\n+  ** Since some fds might be added more than once, won't that cause\n+  ** collisions even in an empty table?\n+  */\n+  PRIntn rehash = _MW_REHASH_MAX;\n+  PRRecvWait** waiter;\n+  PRUintn hidx = _MW_HASH(desc->fd, hash->length);\n+  PRUintn hoffset = 0;\n+\n+  while (rehash-- > 0) {\n+    waiter = &hash->recv_wait;\n+    if (NULL == waiter[hidx]) {\n+      waiter[hidx] = desc;\n+      hash->count += 1;\n #if 0\n             printf(\"Adding 0x%x->0x%x \", desc, desc->fd);\n             printf(\n                 \"table[%u:%u:*%u]: 0x%x->0x%x\\n\",\n                 hidx, hash->count, hash->length, waiter[hidx], waiter[hidx]->fd);\n #endif\n-            return _prmw_success;\n-        }\n-        if (desc == waiter[hidx]) {\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); /* desc already in table */\n-            return _prmw_error;\n-        }\n+      return _prmw_success;\n+    }\n+    if (desc == waiter[hidx]) {\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); /* desc already in table */\n+      return _prmw_error;\n+    }\n #if 0\n         printf(\"Failing 0x%x->0x%x \", desc, desc->fd);\n         printf(\n             \"table[*%u:%u:%u]: 0x%x->0x%x\\n\",\n             hidx, hash->count, hash->length, waiter[hidx], waiter[hidx]->fd);\n #endif\n-        if (0 == hoffset) {\n-            hoffset = _MW_HASH2(desc->fd, hash->length);\n-            PR_ASSERT(0 != hoffset);\n-        }\n-        hidx = (hidx + hoffset) % (hash->length);\n+    if (0 == hoffset) {\n+      hoffset = _MW_HASH2(desc->fd, hash->length);\n+      PR_ASSERT(0 != hoffset);\n     }\n-    return _prmw_rehash;\n+    hidx = (hidx + hoffset) % (hash->length);\n+  }\n+  return _prmw_rehash;\n } /* MW_AddHashInternal */\n \n-static _PR_HashStory\n-MW_ExpandHashInternal(PRWaitGroup* group)\n-{\n-    PRRecvWait** desc;\n-    PRUint32 pidx, length;\n-    _PRWaiterHash *newHash, *oldHash = group->waiter;\n-    PRBool retry;\n-    _PR_HashStory hrv;\n-\n-    static const PRInt32 prime_number[] = { _PR_DEFAULT_HASH_LENGTH,\n-                                            179,\n-                                            521,\n-                                            907,\n-                                            1427,\n-                                            2711,\n-                                            3917,\n-                                            5021,\n-                                            8219,\n-                                            11549,\n-                                            18911,\n-                                            26711,\n-                                            33749,\n-                                            44771 };\n-    PRUintn primes = (sizeof(prime_number) / sizeof(PRInt32));\n-\n-    /* look up the next size we'd like to use for the hash table */\n-    for (pidx = 0; pidx < primes; ++pidx) {\n-        if (prime_number[pidx] == oldHash->length) {\n-            break;\n+static _PR_HashStory MW_ExpandHashInternal(PRWaitGroup* group) {\n+  PRRecvWait** desc;\n+  PRUint32 pidx, length;\n+  _PRWaiterHash *newHash, *oldHash = group->waiter;\n+  PRBool retry;\n+  _PR_HashStory hrv;\n+\n+  static const PRInt32 prime_number[] = {_PR_DEFAULT_HASH_LENGTH,\n+                                         179,\n+                                         521,\n+                                         907,\n+                                         1427,\n+                                         2711,\n+                                         3917,\n+                                         5021,\n+                                         8219,\n+                                         11549,\n+                                         18911,\n+                                         26711,\n+                                         33749,\n+                                         44771};\n+  PRUintn primes = (sizeof(prime_number) / sizeof(PRInt32));\n+\n+  /* look up the next size we'd like to use for the hash table */\n+  for (pidx = 0; pidx < primes; ++pidx) {\n+    if (prime_number[pidx] == oldHash->length) {\n+      break;\n+    }\n+  }\n+  /* table size must be one of the prime numbers */\n+  PR_ASSERT(pidx < primes);\n+\n+  /* if pidx == primes - 1, we can't expand the table any more */\n+  while (pidx < primes - 1) {\n+    /* next size */\n+    ++pidx;\n+    length = prime_number[pidx];\n+\n+    /* allocate the new hash table and fill it in with the old */\n+    newHash = (_PRWaiterHash*)PR_CALLOC(sizeof(_PRWaiterHash) +\n+                                        (length * sizeof(PRRecvWait*)));\n+    if (NULL == newHash) {\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      return _prmw_error;\n+    }\n+\n+    newHash->length = length;\n+    retry = PR_FALSE;\n+    for (desc = &oldHash->recv_wait; newHash->count < oldHash->count; ++desc) {\n+      PR_ASSERT(desc < &oldHash->recv_wait + oldHash->length);\n+      if (NULL != *desc) {\n+        hrv = MW_AddHashInternal(*desc, newHash);\n+        PR_ASSERT(_prmw_error != hrv);\n+        if (_prmw_success != hrv) {\n+          PR_DELETE(newHash);\n+          retry = PR_TRUE;\n+          break;\n         }\n+      }\n     }\n-    /* table size must be one of the prime numbers */\n-    PR_ASSERT(pidx < primes);\n-\n-    /* if pidx == primes - 1, we can't expand the table any more */\n-    while (pidx < primes - 1) {\n-        /* next size */\n-        ++pidx;\n-        length = prime_number[pidx];\n-\n-        /* allocate the new hash table and fill it in with the old */\n-        newHash = (_PRWaiterHash*)PR_CALLOC(sizeof(_PRWaiterHash) +\n-                                            (length * sizeof(PRRecvWait*)));\n-        if (NULL == newHash) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            return _prmw_error;\n-        }\n-\n-        newHash->length = length;\n-        retry = PR_FALSE;\n-        for (desc = &oldHash->recv_wait; newHash->count < oldHash->count; ++desc) {\n-            PR_ASSERT(desc < &oldHash->recv_wait + oldHash->length);\n-            if (NULL != *desc) {\n-                hrv = MW_AddHashInternal(*desc, newHash);\n-                PR_ASSERT(_prmw_error != hrv);\n-                if (_prmw_success != hrv) {\n-                    PR_DELETE(newHash);\n-                    retry = PR_TRUE;\n-                    break;\n-                }\n-            }\n-        }\n-        if (retry) {\n-            continue;\n-        }\n-\n-        PR_DELETE(group->waiter);\n-        group->waiter = newHash;\n-        group->p_timestamp += 1;\n-        return _prmw_success;\n+    if (retry) {\n+      continue;\n     }\n \n-    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-    return _prmw_error; /* we're hosed */\n+    PR_DELETE(group->waiter);\n+    group->waiter = newHash;\n+    group->p_timestamp += 1;\n+    return _prmw_success;\n+  }\n+\n+  PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  return _prmw_error; /* we're hosed */\n } /* MW_ExpandHashInternal */\n \n #ifndef WINNT\n-static void\n-_MW_DoneInternal(PRWaitGroup* group, PRRecvWait** waiter,\n-                 PRMWStatus outcome)\n-{\n-    /*\n-    ** Add this receive wait object to the list of finished I/O\n-    ** operations for this particular group. If there are other\n-    ** threads waiting on the group, notify one. If not, arrange\n-    ** for this thread to return.\n-    */\n-\n-#if 0\n+static void _MW_DoneInternal(PRWaitGroup* group, PRRecvWait** waiter,\n+                             PRMWStatus outcome) {\n+  /*\n+  ** Add this receive wait object to the list of finished I/O\n+  ** operations for this particular group. If there are other\n+  ** threads waiting on the group, notify one. If not, arrange\n+  ** for this thread to return.\n+  */\n+\n+#  if 0\n     printf(\"Removing 0x%x->0x%x\\n\", *waiter, (*waiter)->fd);\n-#endif\n-    (*waiter)->outcome = outcome;\n-    PR_APPEND_LINK(&((*waiter)->internal), &group->io_ready);\n-    PR_NotifyCondVar(group->io_complete);\n-    PR_ASSERT(0 != group->waiter->count);\n-    group->waiter->count -= 1;\n-    *waiter = NULL;\n+#  endif\n+  (*waiter)->outcome = outcome;\n+  PR_APPEND_LINK(&((*waiter)->internal), &group->io_ready);\n+  PR_NotifyCondVar(group->io_complete);\n+  PR_ASSERT(0 != group->waiter->count);\n+  group->waiter->count -= 1;\n+  *waiter = NULL;\n } /* _MW_DoneInternal */\n #endif /* WINNT */\n \n-static PRRecvWait**\n-_MW_LookupInternal(PRWaitGroup* group, PRFileDesc* fd)\n-{\n-    /*\n-    ** Find the receive wait object corresponding to the file descriptor.\n-    ** Only search the wait group specified.\n-    */\n-    PRRecvWait** desc;\n-    PRIntn rehash = _MW_REHASH_MAX;\n-    _PRWaiterHash* hash = group->waiter;\n-    PRUintn hidx = _MW_HASH(fd, hash->length);\n-    PRUintn hoffset = 0;\n-\n-    while (rehash-- > 0) {\n-        desc = (&hash->recv_wait) + hidx;\n-        if ((*desc != NULL) && ((*desc)->fd == fd)) {\n-            return desc;\n-        }\n-        if (0 == hoffset) {\n-            hoffset = _MW_HASH2(fd, hash->length);\n-            PR_ASSERT(0 != hoffset);\n-        }\n-        hidx = (hidx + hoffset) % (hash->length);\n-    }\n-    return NULL;\n+static PRRecvWait** _MW_LookupInternal(PRWaitGroup* group, PRFileDesc* fd) {\n+  /*\n+  ** Find the receive wait object corresponding to the file descriptor.\n+  ** Only search the wait group specified.\n+  */\n+  PRRecvWait** desc;\n+  PRIntn rehash = _MW_REHASH_MAX;\n+  _PRWaiterHash* hash = group->waiter;\n+  PRUintn hidx = _MW_HASH(fd, hash->length);\n+  PRUintn hoffset = 0;\n+\n+  while (rehash-- > 0) {\n+    desc = (&hash->recv_wait) + hidx;\n+    if ((*desc != NULL) && ((*desc)->fd == fd)) {\n+      return desc;\n+    }\n+    if (0 == hoffset) {\n+      hoffset = _MW_HASH2(fd, hash->length);\n+      PR_ASSERT(0 != hoffset);\n+    }\n+    hidx = (hidx + hoffset) % (hash->length);\n+  }\n+  return NULL;\n } /* _MW_LookupInternal */\n \n #ifndef WINNT\n-static PRStatus\n-_MW_PollInternal(PRWaitGroup* group)\n-{\n-    PRRecvWait** waiter;\n-    PRStatus rv = PR_FAILURE;\n-    PRInt32 count, count_ready;\n-    PRIntervalTime polling_interval;\n-\n-    group->poller = PR_GetCurrentThread();\n-\n-    while (PR_TRUE) {\n-        PRIntervalTime now, since_last_poll;\n-        PRPollDesc* poll_list;\n-\n-        while (0 == group->waiter->count) {\n-            PRStatus st;\n-            st = PR_WaitCondVar(group->new_business, PR_INTERVAL_NO_TIMEOUT);\n-            if (_prmw_running != group->state) {\n-                PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-                goto aborted;\n-            }\n-            if (_MW_ABORTED(st)) {\n-                goto aborted;\n-            }\n-        }\n+static PRStatus _MW_PollInternal(PRWaitGroup* group) {\n+  PRRecvWait** waiter;\n+  PRStatus rv = PR_FAILURE;\n+  PRInt32 count, count_ready;\n+  PRIntervalTime polling_interval;\n+\n+  group->poller = PR_GetCurrentThread();\n+\n+  while (PR_TRUE) {\n+    PRIntervalTime now, since_last_poll;\n+    PRPollDesc* poll_list;\n+\n+    while (0 == group->waiter->count) {\n+      PRStatus st;\n+      st = PR_WaitCondVar(group->new_business, PR_INTERVAL_NO_TIMEOUT);\n+      if (_prmw_running != group->state) {\n+        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+        goto aborted;\n+      }\n+      if (_MW_ABORTED(st)) {\n+        goto aborted;\n+      }\n+    }\n \n-        /*\n-        ** There's something to do. See if our existing polling list\n-        ** is large enough for what we have to do?\n-        */\n+    /*\n+    ** There's something to do. See if our existing polling list\n+    ** is large enough for what we have to do?\n+    */\n \n-        while (group->polling_count < group->waiter->count) {\n-            PRUint32 old_count = group->waiter->count;\n-            PRUint32 new_count = PR_ROUNDUP(old_count, _PR_POLL_COUNT_FUDGE);\n-            PRSize new_size = sizeof(PRPollDesc) * new_count;\n-            PRPollDesc* old_polling_list = group->polling_list;\n-\n-            PR_Unlock(group->ml);\n-            poll_list = (PRPollDesc*)PR_CALLOC(new_size);\n-            if (NULL == poll_list) {\n-                PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-                PR_Lock(group->ml);\n-                goto failed_alloc;\n-            }\n-            if (NULL != old_polling_list) {\n-                PR_DELETE(old_polling_list);\n-            }\n-            PR_Lock(group->ml);\n-            if (_prmw_running != group->state) {\n-                PR_DELETE(poll_list);\n-                PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-                goto aborted;\n-            }\n-            group->polling_list = poll_list;\n-            group->polling_count = new_count;\n-        }\n+    while (group->polling_count < group->waiter->count) {\n+      PRUint32 old_count = group->waiter->count;\n+      PRUint32 new_count = PR_ROUNDUP(old_count, _PR_POLL_COUNT_FUDGE);\n+      PRSize new_size = sizeof(PRPollDesc) * new_count;\n+      PRPollDesc* old_polling_list = group->polling_list;\n \n-        now = PR_IntervalNow();\n-        polling_interval = max_polling_interval;\n-        since_last_poll = now - group->last_poll;\n-\n-        waiter = &group->waiter->recv_wait;\n-        poll_list = group->polling_list;\n-        for (count = 0; count < group->waiter->count; ++waiter) {\n-            PR_ASSERT(waiter < &group->waiter->recv_wait + group->waiter->length);\n-            if (NULL != *waiter) /* a live one! */\n-            {\n-                if ((PR_INTERVAL_NO_TIMEOUT != (*waiter)->timeout) &&\n-                    (since_last_poll >= (*waiter)->timeout)) {\n-                    _MW_DoneInternal(group, waiter, PR_MW_TIMEOUT);\n-                } else {\n-                    if (PR_INTERVAL_NO_TIMEOUT != (*waiter)->timeout) {\n-                        (*waiter)->timeout -= since_last_poll;\n-                        if ((*waiter)->timeout < polling_interval) {\n-                            polling_interval = (*waiter)->timeout;\n-                        }\n-                    }\n-                    PR_ASSERT(poll_list < group->polling_list + group->polling_count);\n-                    poll_list->fd = (*waiter)->fd;\n-                    poll_list->in_flags = PR_POLL_READ;\n-                    poll_list->out_flags = 0;\n-#if 0\n+      PR_Unlock(group->ml);\n+      poll_list = (PRPollDesc*)PR_CALLOC(new_size);\n+      if (NULL == poll_list) {\n+        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+        PR_Lock(group->ml);\n+        goto failed_alloc;\n+      }\n+      if (NULL != old_polling_list) {\n+        PR_DELETE(old_polling_list);\n+      }\n+      PR_Lock(group->ml);\n+      if (_prmw_running != group->state) {\n+        PR_DELETE(poll_list);\n+        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+        goto aborted;\n+      }\n+      group->polling_list = poll_list;\n+      group->polling_count = new_count;\n+    }\n+\n+    now = PR_IntervalNow();\n+    polling_interval = max_polling_interval;\n+    since_last_poll = now - group->last_poll;\n+\n+    waiter = &group->waiter->recv_wait;\n+    poll_list = group->polling_list;\n+    for (count = 0; count < group->waiter->count; ++waiter) {\n+      PR_ASSERT(waiter < &group->waiter->recv_wait + group->waiter->length);\n+      if (NULL != *waiter) /* a live one! */\n+      {\n+        if ((PR_INTERVAL_NO_TIMEOUT != (*waiter)->timeout) &&\n+            (since_last_poll >= (*waiter)->timeout)) {\n+          _MW_DoneInternal(group, waiter, PR_MW_TIMEOUT);\n+        } else {\n+          if (PR_INTERVAL_NO_TIMEOUT != (*waiter)->timeout) {\n+            (*waiter)->timeout -= since_last_poll;\n+            if ((*waiter)->timeout < polling_interval) {\n+              polling_interval = (*waiter)->timeout;\n+            }\n+          }\n+          PR_ASSERT(poll_list < group->polling_list + group->polling_count);\n+          poll_list->fd = (*waiter)->fd;\n+          poll_list->in_flags = PR_POLL_READ;\n+          poll_list->out_flags = 0;\n+#  if 0\n                     printf(\n                         \"Polling 0x%x[%d]: [fd: 0x%x, tmo: %u]\\n\",\n                         poll_list, count, poll_list->fd, (*waiter)->timeout);\n-#endif\n-                    poll_list += 1;\n-                    count += 1;\n-                }\n-            }\n+#  endif\n+          poll_list += 1;\n+          count += 1;\n         }\n+      }\n+    }\n \n-        PR_ASSERT(count == group->waiter->count);\n+    PR_ASSERT(count == group->waiter->count);\n \n-        /*\n-        ** If there are no more threads waiting for completion,\n-        ** we need to return.\n-        */\n-        if ((!PR_CLIST_IS_EMPTY(&group->io_ready)) &&\n-            (1 == group->waiting_threads)) {\n-            break;\n-        }\n+    /*\n+    ** If there are no more threads waiting for completion,\n+    ** we need to return.\n+    */\n+    if ((!PR_CLIST_IS_EMPTY(&group->io_ready)) &&\n+        (1 == group->waiting_threads)) {\n+      break;\n+    }\n \n-        if (0 == count) {\n-            continue; /* wait for new business */\n-        }\n+    if (0 == count) {\n+      continue; /* wait for new business */\n+    }\n \n-        group->last_poll = now;\n+    group->last_poll = now;\n \n-        PR_Unlock(group->ml);\n+    PR_Unlock(group->ml);\n \n-        count_ready = PR_Poll(group->polling_list, count, polling_interval);\n+    count_ready = PR_Poll(group->polling_list, count, polling_interval);\n \n-        PR_Lock(group->ml);\n+    PR_Lock(group->ml);\n \n-        if (_prmw_running != group->state) {\n-            PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-            goto aborted;\n-        }\n-        if (-1 == count_ready) {\n-            goto failed_poll; /* that's a shame */\n-        } else if (0 < count_ready) {\n-            for (poll_list = group->polling_list; count > 0; poll_list++, count--) {\n-                PR_ASSERT(poll_list < group->polling_list + group->polling_count);\n-                if (poll_list->out_flags != 0) {\n-                    waiter = _MW_LookupInternal(group, poll_list->fd);\n-                    /*\n-                    ** If 'waiter' is NULL, that means the wait receive\n-                    ** descriptor has been canceled.\n-                    */\n-                    if (NULL != waiter) {\n-                        _MW_DoneInternal(group, waiter, PR_MW_SUCCESS);\n-                    }\n-                }\n-            }\n-        }\n-        /*\n-        ** If there are no more threads waiting for completion,\n-        ** we need to return.\n-        ** This thread was \"borrowed\" to do the polling, but it really\n-        ** belongs to the client.\n-        */\n-        if ((!PR_CLIST_IS_EMPTY(&group->io_ready)) &&\n-            (1 == group->waiting_threads)) {\n-            break;\n+    if (_prmw_running != group->state) {\n+      PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+      goto aborted;\n+    }\n+    if (-1 == count_ready) {\n+      goto failed_poll; /* that's a shame */\n+    } else if (0 < count_ready) {\n+      for (poll_list = group->polling_list; count > 0; poll_list++, count--) {\n+        PR_ASSERT(poll_list < group->polling_list + group->polling_count);\n+        if (poll_list->out_flags != 0) {\n+          waiter = _MW_LookupInternal(group, poll_list->fd);\n+          /*\n+          ** If 'waiter' is NULL, that means the wait receive\n+          ** descriptor has been canceled.\n+          */\n+          if (NULL != waiter) {\n+            _MW_DoneInternal(group, waiter, PR_MW_SUCCESS);\n+          }\n         }\n+      }\n     }\n+    /*\n+    ** If there are no more threads waiting for completion,\n+    ** we need to return.\n+    ** This thread was \"borrowed\" to do the polling, but it really\n+    ** belongs to the client.\n+    */\n+    if ((!PR_CLIST_IS_EMPTY(&group->io_ready)) &&\n+        (1 == group->waiting_threads)) {\n+      break;\n+    }\n+  }\n \n-    rv = PR_SUCCESS;\n+  rv = PR_SUCCESS;\n \n aborted:\n failed_poll:\n failed_alloc:\n-    group->poller = NULL; /* we were that, not we ain't */\n-    if ((_prmw_running == group->state) && (group->waiting_threads > 1)) {\n-        /* Wake up one thread to become the new poller. */\n-        PR_NotifyCondVar(group->io_complete);\n-    }\n-    return rv; /* we return with the lock held */\n+  group->poller = NULL; /* we were that, not we ain't */\n+  if ((_prmw_running == group->state) && (group->waiting_threads > 1)) {\n+    /* Wake up one thread to become the new poller. */\n+    PR_NotifyCondVar(group->io_complete);\n+  }\n+  return rv; /* we return with the lock held */\n } /* _MW_PollInternal */\n #endif /* !WINNT */\n \n-static PRMWGroupState\n-MW_TestForShutdownInternal(PRWaitGroup* group)\n-{\n-    PRMWGroupState rv = group->state;\n-    /*\n-    ** Looking at the group's fields is safe because\n-    ** once the group's state is no longer running, it\n-    ** cannot revert and there is a safe check on entry\n-    ** to make sure no more threads are made to wait.\n-    */\n-    if ((_prmw_stopping == rv) && (0 == group->waiting_threads)) {\n-        rv = group->state = _prmw_stopped;\n-        PR_NotifyCondVar(group->mw_manage);\n-    }\n-    return rv;\n+static PRMWGroupState MW_TestForShutdownInternal(PRWaitGroup* group) {\n+  PRMWGroupState rv = group->state;\n+  /*\n+  ** Looking at the group's fields is safe because\n+  ** once the group's state is no longer running, it\n+  ** cannot revert and there is a safe check on entry\n+  ** to make sure no more threads are made to wait.\n+  */\n+  if ((_prmw_stopping == rv) && (0 == group->waiting_threads)) {\n+    rv = group->state = _prmw_stopped;\n+    PR_NotifyCondVar(group->mw_manage);\n+  }\n+  return rv;\n } /* MW_TestForShutdownInternal */\n \n #ifndef WINNT\n-static void\n-_MW_InitialRecv(PRCList* io_ready)\n-{\n-    PRRecvWait* desc = (PRRecvWait*)io_ready;\n-    if ((NULL == desc->buffer.start) || (0 == desc->buffer.length)) {\n-        desc->bytesRecv = 0;\n-    } else {\n-        desc->bytesRecv = (desc->fd->methods->recv)(\n-            desc->fd, desc->buffer.start, desc->buffer.length, 0, desc->timeout);\n-        if (desc->bytesRecv < 0) { /* SetError should already be there */\n-            desc->outcome = PR_MW_FAILURE;\n-        }\n-    }\n+static void _MW_InitialRecv(PRCList* io_ready) {\n+  PRRecvWait* desc = (PRRecvWait*)io_ready;\n+  if ((NULL == desc->buffer.start) || (0 == desc->buffer.length)) {\n+    desc->bytesRecv = 0;\n+  } else {\n+    desc->bytesRecv = (desc->fd->methods->recv)(\n+        desc->fd, desc->buffer.start, desc->buffer.length, 0, desc->timeout);\n+    if (desc->bytesRecv < 0) { /* SetError should already be there */\n+      desc->outcome = PR_MW_FAILURE;\n+    }\n+  }\n } /* _MW_InitialRecv */\n #endif\n \n #ifdef WINNT\n-static void\n-NT_TimeProc(void* arg)\n-{\n-    _MDOverlapped* overlapped = (_MDOverlapped*)arg;\n-    PRRecvWait* desc = overlapped->data.mw.desc;\n-    PRFileDesc* bottom;\n-\n-    if (InterlockedCompareExchange((LONG*)&desc->outcome, (LONG)PR_MW_TIMEOUT,\n-                                   (LONG)PR_MW_PENDING) != (LONG)PR_MW_PENDING) {\n-        /* This wait recv descriptor has already completed. */\n-        return;\n-    }\n-\n-    /* close the osfd to abort the outstanding async io request */\n-    /* $$$$\n-    ** Little late to be checking if NSPR's on the bottom of stack,\n-    ** but if we don't check, we can't assert that the private data\n-    ** is what we think it is.\n-    ** $$$$\n-    */\n-    bottom = PR_GetIdentitiesLayer(desc->fd, PR_NSPR_IO_LAYER);\n-    PR_ASSERT(NULL != bottom);\n-    if (NULL != bottom) /* now what!?!?! */\n-    {\n-        bottom->secret->state = _PR_FILEDESC_CLOSED;\n-        if (closesocket(bottom->secret->md.osfd) == SOCKET_ERROR) {\n-            fprintf(stderr, \"closesocket failed: %d\\n\", WSAGetLastError());\n-            PR_NOT_REACHED(\"What shall I do?\");\n-        }\n-    }\n+static void NT_TimeProc(void* arg) {\n+  _MDOverlapped* overlapped = (_MDOverlapped*)arg;\n+  PRRecvWait* desc = overlapped->data.mw.desc;\n+  PRFileDesc* bottom;\n+\n+  if (InterlockedCompareExchange((LONG*)&desc->outcome, (LONG)PR_MW_TIMEOUT,\n+                                 (LONG)PR_MW_PENDING) != (LONG)PR_MW_PENDING) {\n+    /* This wait recv descriptor has already completed. */\n     return;\n+  }\n+\n+  /* close the osfd to abort the outstanding async io request */\n+  /* $$$$\n+  ** Little late to be checking if NSPR's on the bottom of stack,\n+  ** but if we don't check, we can't assert that the private data\n+  ** is what we think it is.\n+  ** $$$$\n+  */\n+  bottom = PR_GetIdentitiesLayer(desc->fd, PR_NSPR_IO_LAYER);\n+  PR_ASSERT(NULL != bottom);\n+  if (NULL != bottom) /* now what!?!?! */\n+  {\n+    bottom->secret->state = _PR_FILEDESC_CLOSED;\n+    if (closesocket(bottom->secret->md.osfd) == SOCKET_ERROR) {\n+      fprintf(stderr, \"closesocket failed: %d\\n\", WSAGetLastError());\n+      PR_NOT_REACHED(\"What shall I do?\");\n+    }\n+  }\n+  return;\n } /* NT_TimeProc */\n \n-static PRStatus\n-NT_HashRemove(PRWaitGroup* group, PRFileDesc* fd)\n-{\n-    PRRecvWait** waiter;\n+static PRStatus NT_HashRemove(PRWaitGroup* group, PRFileDesc* fd) {\n+  PRRecvWait** waiter;\n \n-    _PR_MD_LOCK(&group->mdlock);\n-    waiter = _MW_LookupInternal(group, fd);\n-    if (NULL != waiter) {\n-        group->waiter->count -= 1;\n-        *waiter = NULL;\n-    }\n-    _PR_MD_UNLOCK(&group->mdlock);\n-    return (NULL != waiter) ? PR_SUCCESS : PR_FAILURE;\n+  _PR_MD_LOCK(&group->mdlock);\n+  waiter = _MW_LookupInternal(group, fd);\n+  if (NULL != waiter) {\n+    group->waiter->count -= 1;\n+    *waiter = NULL;\n+  }\n+  _PR_MD_UNLOCK(&group->mdlock);\n+  return (NULL != waiter) ? PR_SUCCESS : PR_FAILURE;\n }\n \n-PRStatus\n-NT_HashRemoveInternal(PRWaitGroup* group, PRFileDesc* fd)\n-{\n-    PRRecvWait** waiter;\n+PRStatus NT_HashRemoveInternal(PRWaitGroup* group, PRFileDesc* fd) {\n+  PRRecvWait** waiter;\n \n-    waiter = _MW_LookupInternal(group, fd);\n-    if (NULL != waiter) {\n-        group->waiter->count -= 1;\n-        *waiter = NULL;\n-    }\n-    return (NULL != waiter) ? PR_SUCCESS : PR_FAILURE;\n+  waiter = _MW_LookupInternal(group, fd);\n+  if (NULL != waiter) {\n+    group->waiter->count -= 1;\n+    *waiter = NULL;\n+  }\n+  return (NULL != waiter) ? PR_SUCCESS : PR_FAILURE;\n }\n #endif /* WINNT */\n \n@@ -679,278 +646,275 @@ NT_HashRemoveInternal(PRWaitGroup* group, PRFileDesc* fd)\n /******************************************************************/\n /******************************************************************/\n PR_IMPLEMENT(PRStatus)\n-PR_AddWaitFileDesc(PRWaitGroup* group, PRRecvWait* desc)\n-{\n-    _PR_HashStory hrv;\n-    PRStatus rv = PR_FAILURE;\n+PR_AddWaitFileDesc(PRWaitGroup* group, PRRecvWait* desc) {\n+  _PR_HashStory hrv;\n+  PRStatus rv = PR_FAILURE;\n #ifdef WINNT\n-    _MDOverlapped* overlapped;\n-    HANDLE hFile;\n-    BOOL bResult;\n-    DWORD dwError;\n-    PRFileDesc* bottom;\n+  _MDOverlapped* overlapped;\n+  HANDLE hFile;\n+  BOOL bResult;\n+  DWORD dwError;\n+  PRFileDesc* bottom;\n #endif\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    if ((NULL == group) && (NULL == (group = MW_Init2()))) {\n-        return rv;\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  if ((NULL == group) && (NULL == (group = MW_Init2()))) {\n+    return rv;\n+  }\n \n-    PR_ASSERT(NULL != desc->fd);\n+  PR_ASSERT(NULL != desc->fd);\n \n-    desc->outcome = PR_MW_PENDING; /* nice, well known value */\n-    desc->bytesRecv = 0;           /* likewise, though this value is ambiguious */\n+  desc->outcome = PR_MW_PENDING; /* nice, well known value */\n+  desc->bytesRecv = 0;           /* likewise, though this value is ambiguious */\n \n-    PR_Lock(group->ml);\n+  PR_Lock(group->ml);\n \n-    if (_prmw_running != group->state) {\n-        /* Not allowed to add after cancelling the group */\n-        desc->outcome = PR_MW_INTERRUPT;\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-        PR_Unlock(group->ml);\n-        return rv;\n-    }\n+  if (_prmw_running != group->state) {\n+    /* Not allowed to add after cancelling the group */\n+    desc->outcome = PR_MW_INTERRUPT;\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    PR_Unlock(group->ml);\n+    return rv;\n+  }\n \n #ifdef WINNT\n-    _PR_MD_LOCK(&group->mdlock);\n+  _PR_MD_LOCK(&group->mdlock);\n #endif\n \n-    /*\n-    ** If the waiter count is zero at this point, there's no telling\n-    ** how long we've been idle. Therefore, initialize the beginning\n-    ** of the timing interval. As long as the list doesn't go empty,\n-    ** it will maintain itself.\n-    */\n-    if (0 == group->waiter->count) {\n-        group->last_poll = PR_IntervalNow();\n-    }\n+  /*\n+  ** If the waiter count is zero at this point, there's no telling\n+  ** how long we've been idle. Therefore, initialize the beginning\n+  ** of the timing interval. As long as the list doesn't go empty,\n+  ** it will maintain itself.\n+  */\n+  if (0 == group->waiter->count) {\n+    group->last_poll = PR_IntervalNow();\n+  }\n \n-    do {\n-        hrv = MW_AddHashInternal(desc, group->waiter);\n-        if (_prmw_rehash != hrv) {\n-            break;\n-        }\n-        hrv = MW_ExpandHashInternal(group); /* gruesome */\n-        if (_prmw_success != hrv) {\n-            break;\n-        }\n-    } while (PR_TRUE);\n+  do {\n+    hrv = MW_AddHashInternal(desc, group->waiter);\n+    if (_prmw_rehash != hrv) {\n+      break;\n+    }\n+    hrv = MW_ExpandHashInternal(group); /* gruesome */\n+    if (_prmw_success != hrv) {\n+      break;\n+    }\n+  } while (PR_TRUE);\n \n #ifdef WINNT\n-    _PR_MD_UNLOCK(&group->mdlock);\n+  _PR_MD_UNLOCK(&group->mdlock);\n #endif\n \n-    PR_NotifyCondVar(group->new_business); /* tell the world */\n-    rv = (_prmw_success == hrv) ? PR_SUCCESS : PR_FAILURE;\n-    PR_Unlock(group->ml);\n+  PR_NotifyCondVar(group->new_business); /* tell the world */\n+  rv = (_prmw_success == hrv) ? PR_SUCCESS : PR_FAILURE;\n+  PR_Unlock(group->ml);\n \n #ifdef WINNT\n-    overlapped = PR_NEWZAP(_MDOverlapped);\n-    if (NULL == overlapped) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        NT_HashRemove(group, desc->fd);\n-        return rv;\n-    }\n-    overlapped->ioModel = _MD_MultiWaitIO;\n-    overlapped->data.mw.desc = desc;\n-    overlapped->data.mw.group = group;\n+  overlapped = PR_NEWZAP(_MDOverlapped);\n+  if (NULL == overlapped) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    NT_HashRemove(group, desc->fd);\n+    return rv;\n+  }\n+  overlapped->ioModel = _MD_MultiWaitIO;\n+  overlapped->data.mw.desc = desc;\n+  overlapped->data.mw.group = group;\n+  if (desc->timeout != PR_INTERVAL_NO_TIMEOUT) {\n+    overlapped->data.mw.timer =\n+        CreateTimer(desc->timeout, NT_TimeProc, overlapped);\n+    if (0 == overlapped->data.mw.timer) {\n+      NT_HashRemove(group, desc->fd);\n+      PR_DELETE(overlapped);\n+      /*\n+       * XXX It appears that a maximum of 16 timer events can\n+       * be outstanding. GetLastError() returns 0 when I try it.\n+       */\n+      PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, GetLastError());\n+      return PR_FAILURE;\n+    }\n+  }\n+\n+  /* Reach to the bottom layer to get the OS fd */\n+  bottom = PR_GetIdentitiesLayer(desc->fd, PR_NSPR_IO_LAYER);\n+  PR_ASSERT(NULL != bottom);\n+  if (NULL == bottom) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  hFile = (HANDLE)bottom->secret->md.osfd;\n+  if (!bottom->secret->md.io_model_committed) {\n+    PRInt32 st;\n+    st = _md_Associate(hFile);\n+    PR_ASSERT(0 != st);\n+    bottom->secret->md.io_model_committed = PR_TRUE;\n+  }\n+  bResult = ReadFile(hFile, desc->buffer.start, (DWORD)desc->buffer.length,\n+                     NULL, &overlapped->overlapped);\n+  if (FALSE == bResult && (dwError = GetLastError()) != ERROR_IO_PENDING) {\n     if (desc->timeout != PR_INTERVAL_NO_TIMEOUT) {\n-        overlapped->data.mw.timer =\n-            CreateTimer(desc->timeout, NT_TimeProc, overlapped);\n-        if (0 == overlapped->data.mw.timer) {\n-            NT_HashRemove(group, desc->fd);\n-            PR_DELETE(overlapped);\n-            /*\n-             * XXX It appears that a maximum of 16 timer events can\n-             * be outstanding. GetLastError() returns 0 when I try it.\n-             */\n-            PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, GetLastError());\n-            return PR_FAILURE;\n-        }\n-    }\n-\n-    /* Reach to the bottom layer to get the OS fd */\n-    bottom = PR_GetIdentitiesLayer(desc->fd, PR_NSPR_IO_LAYER);\n-    PR_ASSERT(NULL != bottom);\n-    if (NULL == bottom) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    hFile = (HANDLE)bottom->secret->md.osfd;\n-    if (!bottom->secret->md.io_model_committed) {\n-        PRInt32 st;\n-        st = _md_Associate(hFile);\n-        PR_ASSERT(0 != st);\n-        bottom->secret->md.io_model_committed = PR_TRUE;\n-    }\n-    bResult = ReadFile(hFile, desc->buffer.start, (DWORD)desc->buffer.length,\n-                       NULL, &overlapped->overlapped);\n-    if (FALSE == bResult && (dwError = GetLastError()) != ERROR_IO_PENDING) {\n-        if (desc->timeout != PR_INTERVAL_NO_TIMEOUT) {\n-            if (InterlockedCompareExchange((LONG*)&desc->outcome, (LONG)PR_MW_FAILURE,\n-                                           (LONG)PR_MW_PENDING) ==\n-                (LONG)PR_MW_PENDING) {\n-                CancelTimer(overlapped->data.mw.timer);\n-            }\n-            NT_HashRemove(group, desc->fd);\n-            PR_DELETE(overlapped);\n-        }\n-        _PR_MD_MAP_READ_ERROR(dwError);\n-        rv = PR_FAILURE;\n-    }\n+      if (InterlockedCompareExchange((LONG*)&desc->outcome, (LONG)PR_MW_FAILURE,\n+                                     (LONG)PR_MW_PENDING) ==\n+          (LONG)PR_MW_PENDING) {\n+        CancelTimer(overlapped->data.mw.timer);\n+      }\n+      NT_HashRemove(group, desc->fd);\n+      PR_DELETE(overlapped);\n+    }\n+    _PR_MD_MAP_READ_ERROR(dwError);\n+    rv = PR_FAILURE;\n+  }\n #endif\n \n-    return rv;\n+  return rv;\n } /* PR_AddWaitFileDesc */\n \n-PR_IMPLEMENT(PRRecvWait*)\n-PR_WaitRecvReady(PRWaitGroup* group)\n-{\n-    PRCList* io_ready = NULL;\n+PR_IMPLEMENT(PRRecvWait*) PR_WaitRecvReady(PRWaitGroup* group) {\n+  PRCList* io_ready = NULL;\n #ifdef WINNT\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    _MDOverlapped* overlapped;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  _MDOverlapped* overlapped;\n #endif\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    if ((NULL == group) && (NULL == (group = MW_Init2()))) {\n-        goto failed_init;\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  if ((NULL == group) && (NULL == (group = MW_Init2()))) {\n+    goto failed_init;\n+  }\n \n-    PR_Lock(group->ml);\n+  PR_Lock(group->ml);\n \n-    if (_prmw_running != group->state) {\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-        goto invalid_state;\n-    }\n+  if (_prmw_running != group->state) {\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    goto invalid_state;\n+  }\n \n-    group->waiting_threads += 1; /* the polling thread is counted */\n+  group->waiting_threads += 1; /* the polling thread is counted */\n \n #ifdef WINNT\n+  _PR_MD_LOCK(&group->mdlock);\n+  while (PR_CLIST_IS_EMPTY(&group->io_ready)) {\n+    _PR_THREAD_LOCK(me);\n+    me->state = _PR_IO_WAIT;\n+    PR_APPEND_LINK(&me->waitQLinks, &group->wait_list);\n+    if (!_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_SLEEPQ_LOCK(me->cpu);\n+      _PR_ADD_SLEEPQ(me, PR_INTERVAL_NO_TIMEOUT);\n+      _PR_SLEEPQ_UNLOCK(me->cpu);\n+    }\n+    _PR_THREAD_UNLOCK(me);\n+    _PR_MD_UNLOCK(&group->mdlock);\n+    PR_Unlock(group->ml);\n+    _PR_MD_WAIT(me, PR_INTERVAL_NO_TIMEOUT);\n+    me->state = _PR_RUNNING;\n+    PR_Lock(group->ml);\n     _PR_MD_LOCK(&group->mdlock);\n-    while (PR_CLIST_IS_EMPTY(&group->io_ready)) {\n-        _PR_THREAD_LOCK(me);\n-        me->state = _PR_IO_WAIT;\n-        PR_APPEND_LINK(&me->waitQLinks, &group->wait_list);\n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_SLEEPQ_LOCK(me->cpu);\n-            _PR_ADD_SLEEPQ(me, PR_INTERVAL_NO_TIMEOUT);\n-            _PR_SLEEPQ_UNLOCK(me->cpu);\n+    if (_PR_PENDING_INTERRUPT(me)) {\n+      PR_REMOVE_LINK(&me->waitQLinks);\n+      _PR_MD_UNLOCK(&group->mdlock);\n+      me->flags &= ~_PR_INTERRUPT;\n+      me->io_suspended = PR_FALSE;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+      goto aborted;\n+    }\n+  }\n+  io_ready = PR_LIST_HEAD(&group->io_ready);\n+  PR_ASSERT(io_ready != NULL);\n+  PR_REMOVE_LINK(io_ready);\n+  _PR_MD_UNLOCK(&group->mdlock);\n+  overlapped =\n+      (_MDOverlapped*)((char*)io_ready - offsetof(_MDOverlapped, data));\n+  io_ready = &overlapped->data.mw.desc->internal;\n+#else\n+  do {\n+    /*\n+    ** If the I/O ready list isn't empty, have this thread\n+    ** return with the first receive wait object that's available.\n+    */\n+    if (PR_CLIST_IS_EMPTY(&group->io_ready)) {\n+      /*\n+      ** Is there a polling thread yet? If not, grab this thread\n+      ** and use it.\n+      */\n+      if (NULL == group->poller) {\n+        /*\n+        ** This thread will stay do polling until it becomes the only one\n+        ** left to service a completion. Then it will return and there will\n+        ** be none left to actually poll or to run completions.\n+        **\n+        ** The polling function should only return w/ failure or\n+        ** with some I/O ready.\n+        */\n+        if (PR_FAILURE == _MW_PollInternal(group)) {\n+          goto failed_poll;\n         }\n-        _PR_THREAD_UNLOCK(me);\n-        _PR_MD_UNLOCK(&group->mdlock);\n-        PR_Unlock(group->ml);\n-        _PR_MD_WAIT(me, PR_INTERVAL_NO_TIMEOUT);\n-        me->state = _PR_RUNNING;\n-        PR_Lock(group->ml);\n-        _PR_MD_LOCK(&group->mdlock);\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            PR_REMOVE_LINK(&me->waitQLinks);\n-            _PR_MD_UNLOCK(&group->mdlock);\n-            me->flags &= ~_PR_INTERRUPT;\n-            me->io_suspended = PR_FALSE;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+      } else {\n+        /*\n+        ** There are four reasons a thread can be awakened from\n+        ** a wait on the io_complete condition variable.\n+        ** 1. Some I/O has completed, i.e., the io_ready list\n+        **    is nonempty.\n+        ** 2. The wait group is canceled.\n+        ** 3. The thread is interrupted.\n+        ** 4. The current polling thread has to leave and needs\n+        **    a replacement.\n+        ** The logic to find a new polling thread is made more\n+        ** complicated by all the other possible events.\n+        ** I tried my best to write the logic clearly, but\n+        ** it is still full of if's with continue and goto.\n+        */\n+        PRStatus st;\n+        do {\n+          st = PR_WaitCondVar(group->io_complete, PR_INTERVAL_NO_TIMEOUT);\n+          if (_prmw_running != group->state) {\n+            PR_SetError(PR_INVALID_STATE_ERROR, 0);\n             goto aborted;\n+          }\n+          if (_MW_ABORTED(st) || (NULL == group->poller)) {\n+            break;\n+          }\n+        } while (PR_CLIST_IS_EMPTY(&group->io_ready));\n+\n+        /*\n+        ** The thread is interrupted and has to leave.  It might\n+        ** have also been awakened to process ready i/o or be the\n+        ** new poller.  To be safe, if either condition is true,\n+        ** we awaken another thread to take its place.\n+        */\n+        if (_MW_ABORTED(st)) {\n+          if ((NULL == group->poller || !PR_CLIST_IS_EMPTY(&group->io_ready)) &&\n+              group->waiting_threads > 1) {\n+            PR_NotifyCondVar(group->io_complete);\n+          }\n+          goto aborted;\n         }\n+\n+        /*\n+        ** A new poller is needed, but can I be the new poller?\n+        ** If there is no i/o ready, sure.  But if there is any\n+        ** i/o ready, it has a higher priority.  I want to\n+        ** process the ready i/o first and wake up another\n+        ** thread to be the new poller.\n+        */\n+        if (NULL == group->poller) {\n+          if (PR_CLIST_IS_EMPTY(&group->io_ready)) {\n+            continue;\n+          }\n+          if (group->waiting_threads > 1) {\n+            PR_NotifyCondVar(group->io_complete);\n+          }\n+        }\n+      }\n+      PR_ASSERT(!PR_CLIST_IS_EMPTY(&group->io_ready));\n     }\n     io_ready = PR_LIST_HEAD(&group->io_ready);\n+    PR_NotifyCondVar(group->io_taken);\n     PR_ASSERT(io_ready != NULL);\n     PR_REMOVE_LINK(io_ready);\n-    _PR_MD_UNLOCK(&group->mdlock);\n-    overlapped =\n-        (_MDOverlapped*)((char*)io_ready - offsetof(_MDOverlapped, data));\n-    io_ready = &overlapped->data.mw.desc->internal;\n-#else\n-    do {\n-        /*\n-        ** If the I/O ready list isn't empty, have this thread\n-        ** return with the first receive wait object that's available.\n-        */\n-        if (PR_CLIST_IS_EMPTY(&group->io_ready)) {\n-            /*\n-            ** Is there a polling thread yet? If not, grab this thread\n-            ** and use it.\n-            */\n-            if (NULL == group->poller) {\n-                /*\n-                ** This thread will stay do polling until it becomes the only one\n-                ** left to service a completion. Then it will return and there will\n-                ** be none left to actually poll or to run completions.\n-                **\n-                ** The polling function should only return w/ failure or\n-                ** with some I/O ready.\n-                */\n-                if (PR_FAILURE == _MW_PollInternal(group)) {\n-                    goto failed_poll;\n-                }\n-            } else {\n-                /*\n-                ** There are four reasons a thread can be awakened from\n-                ** a wait on the io_complete condition variable.\n-                ** 1. Some I/O has completed, i.e., the io_ready list\n-                **    is nonempty.\n-                ** 2. The wait group is canceled.\n-                ** 3. The thread is interrupted.\n-                ** 4. The current polling thread has to leave and needs\n-                **    a replacement.\n-                ** The logic to find a new polling thread is made more\n-                ** complicated by all the other possible events.\n-                ** I tried my best to write the logic clearly, but\n-                ** it is still full of if's with continue and goto.\n-                */\n-                PRStatus st;\n-                do {\n-                    st = PR_WaitCondVar(group->io_complete, PR_INTERVAL_NO_TIMEOUT);\n-                    if (_prmw_running != group->state) {\n-                        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-                        goto aborted;\n-                    }\n-                    if (_MW_ABORTED(st) || (NULL == group->poller)) {\n-                        break;\n-                    }\n-                } while (PR_CLIST_IS_EMPTY(&group->io_ready));\n-\n-                /*\n-                ** The thread is interrupted and has to leave.  It might\n-                ** have also been awakened to process ready i/o or be the\n-                ** new poller.  To be safe, if either condition is true,\n-                ** we awaken another thread to take its place.\n-                */\n-                if (_MW_ABORTED(st)) {\n-                    if ((NULL == group->poller || !PR_CLIST_IS_EMPTY(&group->io_ready)) &&\n-                        group->waiting_threads > 1) {\n-                        PR_NotifyCondVar(group->io_complete);\n-                    }\n-                    goto aborted;\n-                }\n-\n-                /*\n-                ** A new poller is needed, but can I be the new poller?\n-                ** If there is no i/o ready, sure.  But if there is any\n-                ** i/o ready, it has a higher priority.  I want to\n-                ** process the ready i/o first and wake up another\n-                ** thread to be the new poller.\n-                */\n-                if (NULL == group->poller) {\n-                    if (PR_CLIST_IS_EMPTY(&group->io_ready)) {\n-                        continue;\n-                    }\n-                    if (group->waiting_threads > 1) {\n-                        PR_NotifyCondVar(group->io_complete);\n-                    }\n-                }\n-            }\n-            PR_ASSERT(!PR_CLIST_IS_EMPTY(&group->io_ready));\n-        }\n-        io_ready = PR_LIST_HEAD(&group->io_ready);\n-        PR_NotifyCondVar(group->io_taken);\n-        PR_ASSERT(io_ready != NULL);\n-        PR_REMOVE_LINK(io_ready);\n-    } while (NULL == io_ready);\n+  } while (NULL == io_ready);\n \n failed_poll:\n \n@@ -958,360 +922,353 @@ failed_poll:\n \n aborted:\n \n-    group->waiting_threads -= 1;\n+  group->waiting_threads -= 1;\n invalid_state:\n-    (void)MW_TestForShutdownInternal(group);\n-    PR_Unlock(group->ml);\n+  (void)MW_TestForShutdownInternal(group);\n+  PR_Unlock(group->ml);\n \n failed_init:\n-    if (NULL != io_ready) {\n-        /* If the operation failed, record the reason why */\n-        switch (((PRRecvWait*)io_ready)->outcome) {\n-            case PR_MW_PENDING:\n-                PR_ASSERT(0);\n-                break;\n-            case PR_MW_SUCCESS:\n+  if (NULL != io_ready) {\n+    /* If the operation failed, record the reason why */\n+    switch (((PRRecvWait*)io_ready)->outcome) {\n+      case PR_MW_PENDING:\n+        PR_ASSERT(0);\n+        break;\n+      case PR_MW_SUCCESS:\n #ifndef WINNT\n-                _MW_InitialRecv(io_ready);\n+        _MW_InitialRecv(io_ready);\n #endif\n-                break;\n+        break;\n #ifdef WINNT\n-            case PR_MW_FAILURE:\n-                _PR_MD_MAP_READ_ERROR(overlapped->data.mw.error);\n-                break;\n+      case PR_MW_FAILURE:\n+        _PR_MD_MAP_READ_ERROR(overlapped->data.mw.error);\n+        break;\n #endif\n-            case PR_MW_TIMEOUT:\n-                PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                break;\n-            case PR_MW_INTERRUPT:\n-                PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                break;\n-            default:\n-                break;\n-        }\n+      case PR_MW_TIMEOUT:\n+        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+        break;\n+      case PR_MW_INTERRUPT:\n+        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+        break;\n+      default:\n+        break;\n+    }\n #ifdef WINNT\n-        if (NULL != overlapped->data.mw.timer) {\n-            PR_ASSERT(PR_INTERVAL_NO_TIMEOUT != overlapped->data.mw.desc->timeout);\n-            CancelTimer(overlapped->data.mw.timer);\n-        } else {\n-            PR_ASSERT(PR_INTERVAL_NO_TIMEOUT == overlapped->data.mw.desc->timeout);\n-        }\n-        PR_DELETE(overlapped);\n-#endif\n+    if (NULL != overlapped->data.mw.timer) {\n+      PR_ASSERT(PR_INTERVAL_NO_TIMEOUT != overlapped->data.mw.desc->timeout);\n+      CancelTimer(overlapped->data.mw.timer);\n+    } else {\n+      PR_ASSERT(PR_INTERVAL_NO_TIMEOUT == overlapped->data.mw.desc->timeout);\n     }\n-    return (PRRecvWait*)io_ready;\n+    PR_DELETE(overlapped);\n+#endif\n+  }\n+  return (PRRecvWait*)io_ready;\n } /* PR_WaitRecvReady */\n \n PR_IMPLEMENT(PRStatus)\n-PR_CancelWaitFileDesc(PRWaitGroup* group, PRRecvWait* desc)\n-{\n+PR_CancelWaitFileDesc(PRWaitGroup* group, PRRecvWait* desc) {\n #if !defined(WINNT)\n-    PRRecvWait** recv_wait;\n+  PRRecvWait** recv_wait;\n #endif\n-    PRStatus rv = PR_SUCCESS;\n-    if (NULL == group) {\n-        group = mw_state->group;\n-    }\n-    PR_ASSERT(NULL != group);\n-    if (NULL == group) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  PRStatus rv = PR_SUCCESS;\n+  if (NULL == group) {\n+    group = mw_state->group;\n+  }\n+  PR_ASSERT(NULL != group);\n+  if (NULL == group) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-    PR_Lock(group->ml);\n+  PR_Lock(group->ml);\n \n-    if (_prmw_running != group->state) {\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-        rv = PR_FAILURE;\n-        goto unlock;\n-    }\n+  if (_prmw_running != group->state) {\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    rv = PR_FAILURE;\n+    goto unlock;\n+  }\n \n #ifdef WINNT\n-    if (InterlockedCompareExchange((LONG*)&desc->outcome, (LONG)PR_MW_INTERRUPT,\n-                                   (LONG)PR_MW_PENDING) == (LONG)PR_MW_PENDING) {\n-        PRFileDesc* bottom = PR_GetIdentitiesLayer(desc->fd, PR_NSPR_IO_LAYER);\n-        PR_ASSERT(NULL != bottom);\n-        if (NULL == bottom) {\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            goto unlock;\n-        }\n-        bottom->secret->state = _PR_FILEDESC_CLOSED;\n-#if 0\n+  if (InterlockedCompareExchange((LONG*)&desc->outcome, (LONG)PR_MW_INTERRUPT,\n+                                 (LONG)PR_MW_PENDING) == (LONG)PR_MW_PENDING) {\n+    PRFileDesc* bottom = PR_GetIdentitiesLayer(desc->fd, PR_NSPR_IO_LAYER);\n+    PR_ASSERT(NULL != bottom);\n+    if (NULL == bottom) {\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      goto unlock;\n+    }\n+    bottom->secret->state = _PR_FILEDESC_CLOSED;\n+#  if 0\n         fprintf(stderr, \"cancel wait recv: closing socket\\n\");\n-#endif\n-        if (closesocket(bottom->secret->md.osfd) == SOCKET_ERROR) {\n-            fprintf(stderr, \"closesocket failed: %d\\n\", WSAGetLastError());\n-            exit(1);\n-        }\n+#  endif\n+    if (closesocket(bottom->secret->md.osfd) == SOCKET_ERROR) {\n+      fprintf(stderr, \"closesocket failed: %d\\n\", WSAGetLastError());\n+      exit(1);\n     }\n+  }\n #else\n-    if (NULL != (recv_wait = _MW_LookupInternal(group, desc->fd))) {\n-        /* it was in the wait table */\n-        _MW_DoneInternal(group, recv_wait, PR_MW_INTERRUPT);\n+  if (NULL != (recv_wait = _MW_LookupInternal(group, desc->fd))) {\n+    /* it was in the wait table */\n+    _MW_DoneInternal(group, recv_wait, PR_MW_INTERRUPT);\n+    goto unlock;\n+  }\n+  if (!PR_CLIST_IS_EMPTY(&group->io_ready)) {\n+    /* is it already complete? */\n+    PRCList* head = PR_LIST_HEAD(&group->io_ready);\n+    do {\n+      PRRecvWait* done = (PRRecvWait*)head;\n+      if (done == desc) {\n         goto unlock;\n-    }\n-    if (!PR_CLIST_IS_EMPTY(&group->io_ready)) {\n-        /* is it already complete? */\n-        PRCList* head = PR_LIST_HEAD(&group->io_ready);\n-        do {\n-            PRRecvWait* done = (PRRecvWait*)head;\n-            if (done == desc) {\n-                goto unlock;\n-            }\n-            head = PR_NEXT_LINK(head);\n-        } while (head != &group->io_ready);\n-    }\n-    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-    rv = PR_FAILURE;\n+      }\n+      head = PR_NEXT_LINK(head);\n+    } while (head != &group->io_ready);\n+  }\n+  PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  rv = PR_FAILURE;\n \n #endif\n unlock:\n-    PR_Unlock(group->ml);\n-    return rv;\n+  PR_Unlock(group->ml);\n+  return rv;\n } /* PR_CancelWaitFileDesc */\n \n-PR_IMPLEMENT(PRRecvWait*)\n-PR_CancelWaitGroup(PRWaitGroup* group)\n-{\n-    PRRecvWait** desc;\n-    PRRecvWait* recv_wait = NULL;\n+PR_IMPLEMENT(PRRecvWait*) PR_CancelWaitGroup(PRWaitGroup* group) {\n+  PRRecvWait** desc;\n+  PRRecvWait* recv_wait = NULL;\n #ifdef WINNT\n-    _MDOverlapped* overlapped;\n-    PRRecvWait** end;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+  _MDOverlapped* overlapped;\n+  PRRecvWait** end;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n #endif\n \n-    if (NULL == group) {\n-        group = mw_state->group;\n+  if (NULL == group) {\n+    group = mw_state->group;\n+  }\n+  PR_ASSERT(NULL != group);\n+  if (NULL == group) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return NULL;\n+  }\n+\n+  PR_Lock(group->ml);\n+  if (_prmw_stopped != group->state) {\n+    if (_prmw_running == group->state) {\n+      group->state = _prmw_stopping; /* so nothing new comes in */\n     }\n-    PR_ASSERT(NULL != group);\n-    if (NULL == group) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return NULL;\n+    if (0 == group->waiting_threads) { /* is there anybody else? */\n+      group->state = _prmw_stopped;    /* we can stop right now */\n+    } else {\n+      PR_NotifyAllCondVar(group->new_business);\n+      PR_NotifyAllCondVar(group->io_complete);\n     }\n-\n-    PR_Lock(group->ml);\n-    if (_prmw_stopped != group->state) {\n-        if (_prmw_running == group->state) {\n-            group->state = _prmw_stopping; /* so nothing new comes in */\n-        }\n-        if (0 == group->waiting_threads) { /* is there anybody else? */\n-            group->state = _prmw_stopped;  /* we can stop right now */\n-        } else {\n-            PR_NotifyAllCondVar(group->new_business);\n-            PR_NotifyAllCondVar(group->io_complete);\n-        }\n-        while (_prmw_stopped != group->state) {\n-            (void)PR_WaitCondVar(group->mw_manage, PR_INTERVAL_NO_TIMEOUT);\n-        }\n+    while (_prmw_stopped != group->state) {\n+      (void)PR_WaitCondVar(group->mw_manage, PR_INTERVAL_NO_TIMEOUT);\n     }\n+  }\n \n #ifdef WINNT\n-    _PR_MD_LOCK(&group->mdlock);\n+  _PR_MD_LOCK(&group->mdlock);\n #endif\n-    /* make all the existing descriptors look done/interrupted */\n+  /* make all the existing descriptors look done/interrupted */\n #ifdef WINNT\n-    end = &group->waiter->recv_wait + group->waiter->length;\n-    for (desc = &group->waiter->recv_wait; desc < end; ++desc) {\n-        if (NULL != *desc) {\n-            if (InterlockedCompareExchange(\n-                    (LONG*)&(*desc)->outcome, (LONG)PR_MW_INTERRUPT,\n-                    (LONG)PR_MW_PENDING) == (LONG)PR_MW_PENDING) {\n-                PRFileDesc* bottom =\n-                    PR_GetIdentitiesLayer((*desc)->fd, PR_NSPR_IO_LAYER);\n-                PR_ASSERT(NULL != bottom);\n-                if (NULL == bottom) {\n-                    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-                    goto invalid_arg;\n-                }\n-                bottom->secret->state = _PR_FILEDESC_CLOSED;\n-#if 0\n-                fprintf(stderr, \"cancel wait group: closing socket\\n\");\n-#endif\n-                if (closesocket(bottom->secret->md.osfd) == SOCKET_ERROR) {\n-                    fprintf(stderr, \"closesocket failed: %d\\n\", WSAGetLastError());\n-                    exit(1);\n-                }\n-            }\n+  end = &group->waiter->recv_wait + group->waiter->length;\n+  for (desc = &group->waiter->recv_wait; desc < end; ++desc) {\n+    if (NULL != *desc) {\n+      if (InterlockedCompareExchange(\n+              (LONG*)&(*desc)->outcome, (LONG)PR_MW_INTERRUPT,\n+              (LONG)PR_MW_PENDING) == (LONG)PR_MW_PENDING) {\n+        PRFileDesc* bottom =\n+            PR_GetIdentitiesLayer((*desc)->fd, PR_NSPR_IO_LAYER);\n+        PR_ASSERT(NULL != bottom);\n+        if (NULL == bottom) {\n+          PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+          goto invalid_arg;\n         }\n-    }\n-    while (group->waiter->count > 0) {\n-        _PR_THREAD_LOCK(me);\n-        me->state = _PR_IO_WAIT;\n-        PR_APPEND_LINK(&me->waitQLinks, &group->wait_list);\n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_SLEEPQ_LOCK(me->cpu);\n-            _PR_ADD_SLEEPQ(me, PR_INTERVAL_NO_TIMEOUT);\n-            _PR_SLEEPQ_UNLOCK(me->cpu);\n+        bottom->secret->state = _PR_FILEDESC_CLOSED;\n+#  if 0\n+                fprintf(stderr, \"cancel wait group: closing socket\\n\");\n+#  endif\n+        if (closesocket(bottom->secret->md.osfd) == SOCKET_ERROR) {\n+          fprintf(stderr, \"closesocket failed: %d\\n\", WSAGetLastError());\n+          exit(1);\n         }\n-        _PR_THREAD_UNLOCK(me);\n-        _PR_MD_UNLOCK(&group->mdlock);\n-        PR_Unlock(group->ml);\n-        _PR_MD_WAIT(me, PR_INTERVAL_NO_TIMEOUT);\n-        me->state = _PR_RUNNING;\n-        PR_Lock(group->ml);\n-        _PR_MD_LOCK(&group->mdlock);\n-    }\n+      }\n+    }\n+  }\n+  while (group->waiter->count > 0) {\n+    _PR_THREAD_LOCK(me);\n+    me->state = _PR_IO_WAIT;\n+    PR_APPEND_LINK(&me->waitQLinks, &group->wait_list);\n+    if (!_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_SLEEPQ_LOCK(me->cpu);\n+      _PR_ADD_SLEEPQ(me, PR_INTERVAL_NO_TIMEOUT);\n+      _PR_SLEEPQ_UNLOCK(me->cpu);\n+    }\n+    _PR_THREAD_UNLOCK(me);\n+    _PR_MD_UNLOCK(&group->mdlock);\n+    PR_Unlock(group->ml);\n+    _PR_MD_WAIT(me, PR_INTERVAL_NO_TIMEOUT);\n+    me->state = _PR_RUNNING;\n+    PR_Lock(group->ml);\n+    _PR_MD_LOCK(&group->mdlock);\n+  }\n #else\n-    for (desc = &group->waiter->recv_wait; group->waiter->count > 0; ++desc) {\n-        PR_ASSERT(desc < &group->waiter->recv_wait + group->waiter->length);\n-        if (NULL != *desc) {\n-            _MW_DoneInternal(group, desc, PR_MW_INTERRUPT);\n-        }\n+  for (desc = &group->waiter->recv_wait; group->waiter->count > 0; ++desc) {\n+    PR_ASSERT(desc < &group->waiter->recv_wait + group->waiter->length);\n+    if (NULL != *desc) {\n+      _MW_DoneInternal(group, desc, PR_MW_INTERRUPT);\n     }\n+  }\n #endif\n \n-    /* take first element of finished list and return it or NULL */\n-    if (PR_CLIST_IS_EMPTY(&group->io_ready)) {\n-        PR_SetError(PR_GROUP_EMPTY_ERROR, 0);\n-    } else {\n-        PRCList* head = PR_LIST_HEAD(&group->io_ready);\n-        PR_REMOVE_AND_INIT_LINK(head);\n+  /* take first element of finished list and return it or NULL */\n+  if (PR_CLIST_IS_EMPTY(&group->io_ready)) {\n+    PR_SetError(PR_GROUP_EMPTY_ERROR, 0);\n+  } else {\n+    PRCList* head = PR_LIST_HEAD(&group->io_ready);\n+    PR_REMOVE_AND_INIT_LINK(head);\n #ifdef WINNT\n-        overlapped = (_MDOverlapped*)((char*)head - offsetof(_MDOverlapped, data));\n-        head = &overlapped->data.mw.desc->internal;\n-        if (NULL != overlapped->data.mw.timer) {\n-            PR_ASSERT(PR_INTERVAL_NO_TIMEOUT != overlapped->data.mw.desc->timeout);\n-            CancelTimer(overlapped->data.mw.timer);\n-        } else {\n-            PR_ASSERT(PR_INTERVAL_NO_TIMEOUT == overlapped->data.mw.desc->timeout);\n-        }\n-        PR_DELETE(overlapped);\n-#endif\n-        recv_wait = (PRRecvWait*)head;\n+    overlapped = (_MDOverlapped*)((char*)head - offsetof(_MDOverlapped, data));\n+    head = &overlapped->data.mw.desc->internal;\n+    if (NULL != overlapped->data.mw.timer) {\n+      PR_ASSERT(PR_INTERVAL_NO_TIMEOUT != overlapped->data.mw.desc->timeout);\n+      CancelTimer(overlapped->data.mw.timer);\n+    } else {\n+      PR_ASSERT(PR_INTERVAL_NO_TIMEOUT == overlapped->data.mw.desc->timeout);\n     }\n+    PR_DELETE(overlapped);\n+#endif\n+    recv_wait = (PRRecvWait*)head;\n+  }\n #ifdef WINNT\n invalid_arg:\n-    _PR_MD_UNLOCK(&group->mdlock);\n+  _PR_MD_UNLOCK(&group->mdlock);\n #endif\n-    PR_Unlock(group->ml);\n+  PR_Unlock(group->ml);\n \n-    return recv_wait;\n+  return recv_wait;\n } /* PR_CancelWaitGroup */\n \n-PR_IMPLEMENT(PRWaitGroup*)\n-PR_CreateWaitGroup(PRInt32 size /* ignored */)\n-{\n-    PRWaitGroup* wg;\n+PR_IMPLEMENT(PRWaitGroup*) PR_CreateWaitGroup(PRInt32 size /* ignored */) {\n+  PRWaitGroup* wg;\n \n-    if (NULL == (wg = PR_NEWZAP(PRWaitGroup))) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        goto failed;\n-    }\n-    /* the wait group itself */\n-    wg->ml = PR_NewLock();\n-    if (NULL == wg->ml) {\n-        goto failed_lock;\n-    }\n-    wg->io_taken = PR_NewCondVar(wg->ml);\n-    if (NULL == wg->io_taken) {\n-        goto failed_cvar0;\n-    }\n-    wg->io_complete = PR_NewCondVar(wg->ml);\n-    if (NULL == wg->io_complete) {\n-        goto failed_cvar1;\n-    }\n-    wg->new_business = PR_NewCondVar(wg->ml);\n-    if (NULL == wg->new_business) {\n-        goto failed_cvar2;\n-    }\n-    wg->mw_manage = PR_NewCondVar(wg->ml);\n-    if (NULL == wg->mw_manage) {\n-        goto failed_cvar3;\n-    }\n-\n-    PR_INIT_CLIST(&wg->group_link);\n-    PR_INIT_CLIST(&wg->io_ready);\n-\n-    /* the waiters sequence */\n-    wg->waiter = (_PRWaiterHash*)PR_CALLOC(\n-        sizeof(_PRWaiterHash) + (_PR_DEFAULT_HASH_LENGTH * sizeof(PRRecvWait*)));\n-    if (NULL == wg->waiter) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        goto failed_waiter;\n-    }\n-    wg->waiter->count = 0;\n-    wg->waiter->length = _PR_DEFAULT_HASH_LENGTH;\n+  if (NULL == (wg = PR_NEWZAP(PRWaitGroup))) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    goto failed;\n+  }\n+  /* the wait group itself */\n+  wg->ml = PR_NewLock();\n+  if (NULL == wg->ml) {\n+    goto failed_lock;\n+  }\n+  wg->io_taken = PR_NewCondVar(wg->ml);\n+  if (NULL == wg->io_taken) {\n+    goto failed_cvar0;\n+  }\n+  wg->io_complete = PR_NewCondVar(wg->ml);\n+  if (NULL == wg->io_complete) {\n+    goto failed_cvar1;\n+  }\n+  wg->new_business = PR_NewCondVar(wg->ml);\n+  if (NULL == wg->new_business) {\n+    goto failed_cvar2;\n+  }\n+  wg->mw_manage = PR_NewCondVar(wg->ml);\n+  if (NULL == wg->mw_manage) {\n+    goto failed_cvar3;\n+  }\n+\n+  PR_INIT_CLIST(&wg->group_link);\n+  PR_INIT_CLIST(&wg->io_ready);\n+\n+  /* the waiters sequence */\n+  wg->waiter = (_PRWaiterHash*)PR_CALLOC(\n+      sizeof(_PRWaiterHash) + (_PR_DEFAULT_HASH_LENGTH * sizeof(PRRecvWait*)));\n+  if (NULL == wg->waiter) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    goto failed_waiter;\n+  }\n+  wg->waiter->count = 0;\n+  wg->waiter->length = _PR_DEFAULT_HASH_LENGTH;\n \n #ifdef WINNT\n-    _PR_MD_NEW_LOCK(&wg->mdlock);\n-    PR_INIT_CLIST(&wg->wait_list);\n+  _PR_MD_NEW_LOCK(&wg->mdlock);\n+  PR_INIT_CLIST(&wg->wait_list);\n #endif /* WINNT */\n \n-    PR_Lock(mw_lock);\n-    PR_APPEND_LINK(&wg->group_link, &mw_state->group_list);\n-    PR_Unlock(mw_lock);\n-    return wg;\n+  PR_Lock(mw_lock);\n+  PR_APPEND_LINK(&wg->group_link, &mw_state->group_list);\n+  PR_Unlock(mw_lock);\n+  return wg;\n \n failed_waiter:\n-    PR_DestroyCondVar(wg->mw_manage);\n+  PR_DestroyCondVar(wg->mw_manage);\n failed_cvar3:\n-    PR_DestroyCondVar(wg->new_business);\n+  PR_DestroyCondVar(wg->new_business);\n failed_cvar2:\n-    PR_DestroyCondVar(wg->io_complete);\n+  PR_DestroyCondVar(wg->io_complete);\n failed_cvar1:\n-    PR_DestroyCondVar(wg->io_taken);\n+  PR_DestroyCondVar(wg->io_taken);\n failed_cvar0:\n-    PR_DestroyLock(wg->ml);\n+  PR_DestroyLock(wg->ml);\n failed_lock:\n-    PR_DELETE(wg);\n-    wg = NULL;\n+  PR_DELETE(wg);\n+  wg = NULL;\n \n failed:\n-    return wg;\n+  return wg;\n } /* MW_CreateWaitGroup */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_DestroyWaitGroup(PRWaitGroup* group)\n-{\n-    PRStatus rv = PR_SUCCESS;\n-    if (NULL == group) {\n-        group = mw_state->group;\n+PR_IMPLEMENT(PRStatus) PR_DestroyWaitGroup(PRWaitGroup* group) {\n+  PRStatus rv = PR_SUCCESS;\n+  if (NULL == group) {\n+    group = mw_state->group;\n+  }\n+  PR_ASSERT(NULL != group);\n+  if (NULL != group) {\n+    PR_Lock(group->ml);\n+    if ((group->waiting_threads == 0) && (group->waiter->count == 0) &&\n+        PR_CLIST_IS_EMPTY(&group->io_ready)) {\n+      group->state = _prmw_stopped;\n+    } else {\n+      PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+      rv = PR_FAILURE;\n+    }\n+    PR_Unlock(group->ml);\n+    if (PR_FAILURE == rv) {\n+      return rv;\n     }\n-    PR_ASSERT(NULL != group);\n-    if (NULL != group) {\n-        PR_Lock(group->ml);\n-        if ((group->waiting_threads == 0) && (group->waiter->count == 0) &&\n-            PR_CLIST_IS_EMPTY(&group->io_ready)) {\n-            group->state = _prmw_stopped;\n-        } else {\n-            PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-            rv = PR_FAILURE;\n-        }\n-        PR_Unlock(group->ml);\n-        if (PR_FAILURE == rv) {\n-            return rv;\n-        }\n \n-        PR_Lock(mw_lock);\n-        PR_REMOVE_LINK(&group->group_link);\n-        PR_Unlock(mw_lock);\n+    PR_Lock(mw_lock);\n+    PR_REMOVE_LINK(&group->group_link);\n+    PR_Unlock(mw_lock);\n \n #ifdef WINNT\n-        /*\n-         * XXX make sure wait_list is empty and waiter is empty.\n-         * These must be checked while holding mdlock.\n-         */\n-        _PR_MD_FREE_LOCK(&group->mdlock);\n+    /*\n+     * XXX make sure wait_list is empty and waiter is empty.\n+     * These must be checked while holding mdlock.\n+     */\n+    _PR_MD_FREE_LOCK(&group->mdlock);\n #endif\n \n-        PR_DELETE(group->waiter);\n-        PR_DELETE(group->polling_list);\n-        PR_DestroyCondVar(group->mw_manage);\n-        PR_DestroyCondVar(group->new_business);\n-        PR_DestroyCondVar(group->io_complete);\n-        PR_DestroyCondVar(group->io_taken);\n-        PR_DestroyLock(group->ml);\n-        if (group == mw_state->group) {\n-            mw_state->group = NULL;\n-        }\n-        PR_DELETE(group);\n-    } else {\n-        /* The default wait group is not created yet. */\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        rv = PR_FAILURE;\n-    }\n-    return rv;\n+    PR_DELETE(group->waiter);\n+    PR_DELETE(group->polling_list);\n+    PR_DestroyCondVar(group->mw_manage);\n+    PR_DestroyCondVar(group->new_business);\n+    PR_DestroyCondVar(group->io_complete);\n+    PR_DestroyCondVar(group->io_taken);\n+    PR_DestroyLock(group->ml);\n+    if (group == mw_state->group) {\n+      mw_state->group = NULL;\n+    }\n+    PR_DELETE(group);\n+  } else {\n+    /* The default wait group is not created yet. */\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    rv = PR_FAILURE;\n+  }\n+  return rv;\n } /* PR_DestroyWaitGroup */\n \n /**********************************************************************\n@@ -1320,96 +1277,92 @@ PR_DestroyWaitGroup(PRWaitGroup* group)\n ***********************************************************************\n **********************************************************************/\n \n-PR_IMPLEMENT(PRMWaitEnumerator*)\n-PR_CreateMWaitEnumerator(PRWaitGroup* group)\n-{\n-    PRMWaitEnumerator* enumerator = PR_NEWZAP(PRMWaitEnumerator);\n-    if (NULL == enumerator) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-    } else {\n-        enumerator->group = group;\n-        enumerator->seal = _PR_ENUM_SEALED;\n-    }\n-    return enumerator;\n+PR_IMPLEMENT(PRMWaitEnumerator*) PR_CreateMWaitEnumerator(PRWaitGroup* group) {\n+  PRMWaitEnumerator* enumerator = PR_NEWZAP(PRMWaitEnumerator);\n+  if (NULL == enumerator) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  } else {\n+    enumerator->group = group;\n+    enumerator->seal = _PR_ENUM_SEALED;\n+  }\n+  return enumerator;\n } /* PR_CreateMWaitEnumerator */\n \n PR_IMPLEMENT(PRStatus)\n-PR_DestroyMWaitEnumerator(PRMWaitEnumerator* enumerator)\n-{\n-    PR_ASSERT(NULL != enumerator);\n-    PR_ASSERT(_PR_ENUM_SEALED == enumerator->seal);\n-    if ((NULL == enumerator) || (_PR_ENUM_SEALED != enumerator->seal)) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    enumerator->seal = _PR_ENUM_UNSEALED;\n-    PR_Free(enumerator);\n-    return PR_SUCCESS;\n+PR_DestroyMWaitEnumerator(PRMWaitEnumerator* enumerator) {\n+  PR_ASSERT(NULL != enumerator);\n+  PR_ASSERT(_PR_ENUM_SEALED == enumerator->seal);\n+  if ((NULL == enumerator) || (_PR_ENUM_SEALED != enumerator->seal)) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  enumerator->seal = _PR_ENUM_UNSEALED;\n+  PR_Free(enumerator);\n+  return PR_SUCCESS;\n } /* PR_DestroyMWaitEnumerator */\n \n PR_IMPLEMENT(PRRecvWait*)\n PR_EnumerateWaitGroup(PRMWaitEnumerator* enumerator,\n-                      const PRRecvWait* previous)\n-{\n-    PRRecvWait* result = NULL;\n-\n-    /* entry point sanity checking */\n-    PR_ASSERT(NULL != enumerator);\n-    PR_ASSERT(_PR_ENUM_SEALED == enumerator->seal);\n-    if ((NULL == enumerator) || (_PR_ENUM_SEALED != enumerator->seal)) {\n-        goto bad_argument;\n+                      const PRRecvWait* previous) {\n+  PRRecvWait* result = NULL;\n+\n+  /* entry point sanity checking */\n+  PR_ASSERT(NULL != enumerator);\n+  PR_ASSERT(_PR_ENUM_SEALED == enumerator->seal);\n+  if ((NULL == enumerator) || (_PR_ENUM_SEALED != enumerator->seal)) {\n+    goto bad_argument;\n+  }\n+\n+  /* beginning of enumeration */\n+  if (NULL == previous) {\n+    if (NULL == enumerator->group) {\n+      enumerator->group = mw_state->group;\n+      if (NULL == enumerator->group) {\n+        PR_SetError(PR_GROUP_EMPTY_ERROR, 0);\n+        return NULL;\n+      }\n     }\n-\n-    /* beginning of enumeration */\n-    if (NULL == previous) {\n-        if (NULL == enumerator->group) {\n-            enumerator->group = mw_state->group;\n-            if (NULL == enumerator->group) {\n-                PR_SetError(PR_GROUP_EMPTY_ERROR, 0);\n-                return NULL;\n-            }\n-        }\n-        enumerator->waiter = &enumerator->group->waiter->recv_wait;\n-        enumerator->p_timestamp = enumerator->group->p_timestamp;\n-        enumerator->thread = PR_GetCurrentThread();\n-        enumerator->index = 0;\n+    enumerator->waiter = &enumerator->group->waiter->recv_wait;\n+    enumerator->p_timestamp = enumerator->group->p_timestamp;\n+    enumerator->thread = PR_GetCurrentThread();\n+    enumerator->index = 0;\n+  }\n+  /* continuing an enumeration */\n+  else {\n+    PRThread* me = PR_GetCurrentThread();\n+    PR_ASSERT(me == enumerator->thread);\n+    if (me != enumerator->thread) {\n+      goto bad_argument;\n     }\n-    /* continuing an enumeration */\n-    else {\n-        PRThread* me = PR_GetCurrentThread();\n-        PR_ASSERT(me == enumerator->thread);\n-        if (me != enumerator->thread) {\n-            goto bad_argument;\n-        }\n \n-        /* need to restart the enumeration */\n-        if (enumerator->p_timestamp != enumerator->group->p_timestamp) {\n-            return PR_EnumerateWaitGroup(enumerator, NULL);\n-        }\n+    /* need to restart the enumeration */\n+    if (enumerator->p_timestamp != enumerator->group->p_timestamp) {\n+      return PR_EnumerateWaitGroup(enumerator, NULL);\n     }\n+  }\n \n-    /* actually progress the enumeration */\n+  /* actually progress the enumeration */\n #if defined(WINNT)\n-    _PR_MD_LOCK(&enumerator->group->mdlock);\n+  _PR_MD_LOCK(&enumerator->group->mdlock);\n #else\n-    PR_Lock(enumerator->group->ml);\n+  PR_Lock(enumerator->group->ml);\n #endif\n-    while (enumerator->index++ < enumerator->group->waiter->length) {\n-        if (NULL != (result = *(enumerator->waiter)++)) {\n-            break;\n-        }\n+  while (enumerator->index++ < enumerator->group->waiter->length) {\n+    if (NULL != (result = *(enumerator->waiter)++)) {\n+      break;\n     }\n+  }\n #if defined(WINNT)\n-    _PR_MD_UNLOCK(&enumerator->group->mdlock);\n+  _PR_MD_UNLOCK(&enumerator->group->mdlock);\n #else\n-    PR_Unlock(enumerator->group->ml);\n+  PR_Unlock(enumerator->group->ml);\n #endif\n \n-    return result; /* what we live for */\n+  return result; /* what we live for */\n \n bad_argument:\n-    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-    return NULL; /* probably ambiguous */\n+  PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  return NULL; /* probably ambiguous */\n } /* PR_EnumerateWaitGroup */\n \n /* prmwait.c */\ndiff --git a/nspr/pr/src/io/prpolevt.c b/nspr/pr/src/io/prpolevt.c\nindex 3cd3327..42a2979 100644\n--- a/nspr/pr/src/io/prpolevt.c\n+++ b/nspr/pr/src/io/prpolevt.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -41,7 +42,7 @@ extern PRFileDesc* _PR_InvalidDesc(void);\n  * PRFilePrivate structure for the NSPR pollable events layer\n  */\n struct PRFilePrivate {\n-    PRFileDesc* writeEnd; /* the write end of the pipe/socketpair */\n+  PRFileDesc* writeEnd; /* the write end of the pipe/socketpair */\n };\n \n static PRStatus PR_CALLBACK _pr_PolEvtClose(PRFileDesc* fd);\n@@ -49,186 +50,172 @@ static PRStatus PR_CALLBACK _pr_PolEvtClose(PRFileDesc* fd);\n static PRInt16 PR_CALLBACK _pr_PolEvtPoll(PRFileDesc* fd, PRInt16 in_flags,\n                                           PRInt16* out_flags);\n \n-static PRIOMethods _pr_polevt_methods = { PR_DESC_LAYERED,\n-                                          _pr_PolEvtClose,\n-                                          (PRReadFN)_PR_InvalidInt,\n-                                          (PRWriteFN)_PR_InvalidInt,\n-                                          (PRAvailableFN)_PR_InvalidInt,\n-                                          (PRAvailable64FN)_PR_InvalidInt64,\n-                                          (PRFsyncFN)_PR_InvalidStatus,\n-                                          (PRSeekFN)_PR_InvalidInt,\n-                                          (PRSeek64FN)_PR_InvalidInt64,\n-                                          (PRFileInfoFN)_PR_InvalidStatus,\n-                                          (PRFileInfo64FN)_PR_InvalidStatus,\n-                                          (PRWritevFN)_PR_InvalidInt,\n-                                          (PRConnectFN)_PR_InvalidStatus,\n-                                          (PRAcceptFN)_PR_InvalidDesc,\n-                                          (PRBindFN)_PR_InvalidStatus,\n-                                          (PRListenFN)_PR_InvalidStatus,\n-                                          (PRShutdownFN)_PR_InvalidStatus,\n-                                          (PRRecvFN)_PR_InvalidInt,\n-                                          (PRSendFN)_PR_InvalidInt,\n-                                          (PRRecvfromFN)_PR_InvalidInt,\n-                                          (PRSendtoFN)_PR_InvalidInt,\n-                                          _pr_PolEvtPoll,\n-                                          (PRAcceptreadFN)_PR_InvalidInt,\n-                                          (PRTransmitfileFN)_PR_InvalidInt,\n-                                          (PRGetsocknameFN)_PR_InvalidStatus,\n-                                          (PRGetpeernameFN)_PR_InvalidStatus,\n-                                          (PRReservedFN)_PR_InvalidInt,\n-                                          (PRReservedFN)_PR_InvalidInt,\n-                                          (PRGetsocketoptionFN)_PR_InvalidStatus,\n-                                          (PRSetsocketoptionFN)_PR_InvalidStatus,\n-                                          (PRSendfileFN)_PR_InvalidInt,\n-                                          (PRConnectcontinueFN)_PR_InvalidStatus,\n-                                          (PRReservedFN)_PR_InvalidInt,\n-                                          (PRReservedFN)_PR_InvalidInt,\n-                                          (PRReservedFN)_PR_InvalidInt,\n-                                          (PRReservedFN)_PR_InvalidInt };\n+static PRIOMethods _pr_polevt_methods = {PR_DESC_LAYERED,\n+                                         _pr_PolEvtClose,\n+                                         (PRReadFN)_PR_InvalidInt,\n+                                         (PRWriteFN)_PR_InvalidInt,\n+                                         (PRAvailableFN)_PR_InvalidInt,\n+                                         (PRAvailable64FN)_PR_InvalidInt64,\n+                                         (PRFsyncFN)_PR_InvalidStatus,\n+                                         (PRSeekFN)_PR_InvalidInt,\n+                                         (PRSeek64FN)_PR_InvalidInt64,\n+                                         (PRFileInfoFN)_PR_InvalidStatus,\n+                                         (PRFileInfo64FN)_PR_InvalidStatus,\n+                                         (PRWritevFN)_PR_InvalidInt,\n+                                         (PRConnectFN)_PR_InvalidStatus,\n+                                         (PRAcceptFN)_PR_InvalidDesc,\n+                                         (PRBindFN)_PR_InvalidStatus,\n+                                         (PRListenFN)_PR_InvalidStatus,\n+                                         (PRShutdownFN)_PR_InvalidStatus,\n+                                         (PRRecvFN)_PR_InvalidInt,\n+                                         (PRSendFN)_PR_InvalidInt,\n+                                         (PRRecvfromFN)_PR_InvalidInt,\n+                                         (PRSendtoFN)_PR_InvalidInt,\n+                                         _pr_PolEvtPoll,\n+                                         (PRAcceptreadFN)_PR_InvalidInt,\n+                                         (PRTransmitfileFN)_PR_InvalidInt,\n+                                         (PRGetsocknameFN)_PR_InvalidStatus,\n+                                         (PRGetpeernameFN)_PR_InvalidStatus,\n+                                         (PRReservedFN)_PR_InvalidInt,\n+                                         (PRReservedFN)_PR_InvalidInt,\n+                                         (PRGetsocketoptionFN)_PR_InvalidStatus,\n+                                         (PRSetsocketoptionFN)_PR_InvalidStatus,\n+                                         (PRSendfileFN)_PR_InvalidInt,\n+                                         (PRConnectcontinueFN)_PR_InvalidStatus,\n+                                         (PRReservedFN)_PR_InvalidInt,\n+                                         (PRReservedFN)_PR_InvalidInt,\n+                                         (PRReservedFN)_PR_InvalidInt,\n+                                         (PRReservedFN)_PR_InvalidInt};\n \n static PRDescIdentity _pr_polevt_id;\n static PRCallOnceType _pr_polevt_once_control;\n static PRStatus PR_CALLBACK _pr_PolEvtInit(void);\n \n-static PRInt16 PR_CALLBACK\n-_pr_PolEvtPoll(PRFileDesc* fd, PRInt16 in_flags,\n-               PRInt16* out_flags)\n-{\n-    return (fd->lower->methods->poll)(fd->lower, in_flags, out_flags);\n+static PRInt16 PR_CALLBACK _pr_PolEvtPoll(PRFileDesc* fd, PRInt16 in_flags,\n+                                          PRInt16* out_flags) {\n+  return (fd->lower->methods->poll)(fd->lower, in_flags, out_flags);\n }\n \n-static PRStatus PR_CALLBACK\n-_pr_PolEvtInit(void)\n-{\n-    _pr_polevt_id = PR_GetUniqueIdentity(\"NSPR pollable events\");\n-    if (PR_INVALID_IO_LAYER == _pr_polevt_id) {\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+static PRStatus PR_CALLBACK _pr_PolEvtInit(void) {\n+  _pr_polevt_id = PR_GetUniqueIdentity(\"NSPR pollable events\");\n+  if (PR_INVALID_IO_LAYER == _pr_polevt_id) {\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n #if !defined(XP_UNIX)\n-#define USE_TCP_SOCKETPAIR\n+#  define USE_TCP_SOCKETPAIR\n #endif\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_NewPollableEvent(void)\n-{\n-    PRFileDesc* event;\n-    PRFileDesc* fd[2]; /* fd[0] is the read end; fd[1] is the write end */\n+PR_IMPLEMENT(PRFileDesc*) PR_NewPollableEvent(void) {\n+  PRFileDesc* event;\n+  PRFileDesc* fd[2]; /* fd[0] is the read end; fd[1] is the write end */\n #ifdef USE_TCP_SOCKETPAIR\n-    PRSocketOptionData socket_opt;\n-    PRStatus rv;\n+  PRSocketOptionData socket_opt;\n+  PRStatus rv;\n #endif\n \n-    fd[0] = fd[1] = NULL;\n-\n-    if (PR_CallOnce(&_pr_polevt_once_control, _pr_PolEvtInit) == PR_FAILURE) {\n-        return NULL;\n-    }\n+  fd[0] = fd[1] = NULL;\n \n-    event = PR_CreateIOLayerStub(_pr_polevt_id, &_pr_polevt_methods);\n-    if (NULL == event) {\n-        goto errorExit;\n-    }\n-    event->secret = PR_NEW(PRFilePrivate);\n-    if (event->secret == NULL) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        goto errorExit;\n-    }\n+  if (PR_CallOnce(&_pr_polevt_once_control, _pr_PolEvtInit) == PR_FAILURE) {\n+    return NULL;\n+  }\n+\n+  event = PR_CreateIOLayerStub(_pr_polevt_id, &_pr_polevt_methods);\n+  if (NULL == event) {\n+    goto errorExit;\n+  }\n+  event->secret = PR_NEW(PRFilePrivate);\n+  if (event->secret == NULL) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    goto errorExit;\n+  }\n \n #ifndef USE_TCP_SOCKETPAIR\n-    if (PR_CreatePipe(&fd[0], &fd[1]) == PR_FAILURE) {\n-        fd[0] = fd[1] = NULL;\n-        goto errorExit;\n-    }\n+  if (PR_CreatePipe(&fd[0], &fd[1]) == PR_FAILURE) {\n+    fd[0] = fd[1] = NULL;\n+    goto errorExit;\n+  }\n #else\n-    if (PR_NewTCPSocketPair(fd) == PR_FAILURE) {\n-        fd[0] = fd[1] = NULL;\n-        goto errorExit;\n-    }\n-    /*\n-     * set the TCP_NODELAY option to reduce notification latency\n-     */\n-    socket_opt.option = PR_SockOpt_NoDelay;\n-    socket_opt.value.no_delay = PR_TRUE;\n-    rv = PR_SetSocketOption(fd[1], &socket_opt);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+  if (PR_NewTCPSocketPair(fd) == PR_FAILURE) {\n+    fd[0] = fd[1] = NULL;\n+    goto errorExit;\n+  }\n+  /*\n+   * set the TCP_NODELAY option to reduce notification latency\n+   */\n+  socket_opt.option = PR_SockOpt_NoDelay;\n+  socket_opt.value.no_delay = PR_TRUE;\n+  rv = PR_SetSocketOption(fd[1], &socket_opt);\n+  PR_ASSERT(PR_SUCCESS == rv);\n #endif\n \n-    event->secret->writeEnd = fd[1];\n-    if (PR_PushIOLayer(fd[0], PR_TOP_IO_LAYER, event) == PR_FAILURE) {\n-        goto errorExit;\n-    }\n+  event->secret->writeEnd = fd[1];\n+  if (PR_PushIOLayer(fd[0], PR_TOP_IO_LAYER, event) == PR_FAILURE) {\n+    goto errorExit;\n+  }\n \n-    return fd[0];\n+  return fd[0];\n \n errorExit:\n-    if (fd[0]) {\n-        PR_Close(fd[0]);\n-        PR_Close(fd[1]);\n-    }\n-    if (event) {\n-        PR_DELETE(event->secret);\n-        event->dtor(event);\n-    }\n-    return NULL;\n+  if (fd[0]) {\n+    PR_Close(fd[0]);\n+    PR_Close(fd[1]);\n+  }\n+  if (event) {\n+    PR_DELETE(event->secret);\n+    event->dtor(event);\n+  }\n+  return NULL;\n }\n \n-static PRStatus PR_CALLBACK\n-_pr_PolEvtClose(PRFileDesc* fd)\n-{\n-    PRFileDesc* event;\n+static PRStatus PR_CALLBACK _pr_PolEvtClose(PRFileDesc* fd) {\n+  PRFileDesc* event;\n \n-    event = PR_PopIOLayer(fd, PR_TOP_IO_LAYER);\n-    PR_ASSERT(NULL == event->higher && NULL == event->lower);\n-    PR_Close(fd);\n-    PR_Close(event->secret->writeEnd);\n-    PR_DELETE(event->secret);\n-    event->dtor(event);\n-    return PR_SUCCESS;\n+  event = PR_PopIOLayer(fd, PR_TOP_IO_LAYER);\n+  PR_ASSERT(NULL == event->higher && NULL == event->lower);\n+  PR_Close(fd);\n+  PR_Close(event->secret->writeEnd);\n+  PR_DELETE(event->secret);\n+  event->dtor(event);\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_DestroyPollableEvent(PRFileDesc* event)\n-{\n-    return PR_Close(event);\n+PR_IMPLEMENT(PRStatus) PR_DestroyPollableEvent(PRFileDesc* event) {\n+  return PR_Close(event);\n }\n \n static const char magicChar = '\\x38';\n \n-PR_IMPLEMENT(PRStatus)\n-PR_SetPollableEvent(PRFileDesc* event)\n-{\n-    if (PR_Write(event->secret->writeEnd, &magicChar, 1) != 1) {\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_SetPollableEvent(PRFileDesc* event) {\n+  if (PR_Write(event->secret->writeEnd, &magicChar, 1) != 1) {\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_WaitForPollableEvent(PRFileDesc* event)\n-{\n-    char buf[1024];\n-    PRInt32 nBytes;\n+PR_IMPLEMENT(PRStatus) PR_WaitForPollableEvent(PRFileDesc* event) {\n+  char buf[1024];\n+  PRInt32 nBytes;\n #ifdef DEBUG\n-    PRIntn i;\n+  PRIntn i;\n #endif\n \n-    nBytes = PR_Read(event->lower, buf, sizeof(buf));\n-    if (nBytes == -1) {\n-        return PR_FAILURE;\n-    }\n+  nBytes = PR_Read(event->lower, buf, sizeof(buf));\n+  if (nBytes == -1) {\n+    return PR_FAILURE;\n+  }\n \n #ifdef DEBUG\n-    /*\n-     * Make sure people do not write to the pollable event fd\n-     * directly.\n-     */\n-    for (i = 0; i < nBytes; i++) {\n-        PR_ASSERT(buf[i] == magicChar);\n-    }\n+  /*\n+   * Make sure people do not write to the pollable event fd\n+   * directly.\n+   */\n+  for (i = 0; i < nBytes; i++) {\n+    PR_ASSERT(buf[i] == magicChar);\n+  }\n #endif\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n }\ndiff --git a/nspr/pr/src/io/prprf.c b/nspr/pr/src/io/prprf.c\nindex 363356b..a9bcc6b 100644\n--- a/nspr/pr/src/io/prprf.c\n+++ b/nspr/pr/src/io/prprf.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -18,7 +19,7 @@\n #include \"prmem.h\"\n \n #if defined(_MSC_VER) && _MSC_VER < 1900\n-#define snprintf _snprintf\n+#  define snprintf _snprintf\n #endif\n \n /*\n@@ -32,35 +33,35 @@\n typedef struct SprintfStateStr SprintfState;\n \n struct SprintfStateStr {\n-    int (*stuff)(SprintfState* ss, const char* sp, PRUint32 len);\n+  int (*stuff)(SprintfState* ss, const char* sp, PRUint32 len);\n \n-    char* base;\n-    char* cur;\n-    PRUint32 maxlen; /* Must not exceed PR_INT32_MAX. */\n+  char* base;\n+  char* cur;\n+  PRUint32 maxlen; /* Must not exceed PR_INT32_MAX. */\n \n-    int (*func)(void* arg, const char* sp, PRUint32 len);\n-    void* arg;\n+  int (*func)(void* arg, const char* sp, PRUint32 len);\n+  void* arg;\n };\n \n /*\n ** Numbered Argument\n */\n struct NumArg {\n-    int type; /* type of the numbered argument    */\n-    union {   /* the numbered argument            */\n-        int i;\n-        unsigned int ui;\n-        PRInt32 i32;\n-        PRUint32 ui32;\n-        PRInt64 ll;\n-        PRUint64 ull;\n-        double d;\n-        const char* s;\n-        int* ip;\n+  int type; /* type of the numbered argument    */\n+  union {   /* the numbered argument            */\n+    int i;\n+    unsigned int ui;\n+    PRInt32 i32;\n+    PRUint32 ui32;\n+    PRInt64 ll;\n+    PRUint64 ull;\n+    double d;\n+    const char* s;\n+    int* ip;\n #ifdef WIN32\n-        const WCHAR* ws;\n+    const WCHAR* ws;\n #endif\n-    } u;\n+  } u;\n };\n \n #define NAS_DEFAULT_NUM 20 /* default number of NumberedArgument array */\n@@ -82,7 +83,7 @@ struct NumArg {\n #define TYPE_DOUBLE 9\n #define TYPE_INTSTR 10\n #ifdef WIN32\n-#define TYPE_WSTRING 11\n+#  define TYPE_WSTRING 11\n #endif\n #define TYPE_UNKNOWN 20\n \n@@ -95,220 +96,212 @@ struct NumArg {\n /*\n ** Fill into the buffer using the data in src\n */\n-static int\n-fill2(SprintfState* ss, const char* src, int srclen, int width,\n-      int flags)\n-{\n-    char space = ' ';\n-    int rv;\n-\n-    width -= srclen;\n-    if ((width > 0) && ((flags & FLAG_LEFT) == 0)) { /* Right adjusting */\n-        if (flags & FLAG_ZEROS) {\n-            space = '0';\n-        }\n-        while (--width >= 0) {\n-            rv = (*ss->stuff)(ss, &space, 1);\n-            if (rv < 0) {\n-                return rv;\n-            }\n-        }\n+static int fill2(SprintfState* ss, const char* src, int srclen, int width,\n+                 int flags) {\n+  char space = ' ';\n+  int rv;\n+\n+  width -= srclen;\n+  if ((width > 0) && ((flags & FLAG_LEFT) == 0)) { /* Right adjusting */\n+    if (flags & FLAG_ZEROS) {\n+      space = '0';\n     }\n-\n-    /* Copy out the source data */\n-    rv = (*ss->stuff)(ss, src, srclen);\n-    if (rv < 0) {\n+    while (--width >= 0) {\n+      rv = (*ss->stuff)(ss, &space, 1);\n+      if (rv < 0) {\n         return rv;\n+      }\n     }\n+  }\n \n-    if ((width > 0) && ((flags & FLAG_LEFT) != 0)) { /* Left adjusting */\n-        while (--width >= 0) {\n-            rv = (*ss->stuff)(ss, &space, 1);\n-            if (rv < 0) {\n-                return rv;\n-            }\n-        }\n+  /* Copy out the source data */\n+  rv = (*ss->stuff)(ss, src, srclen);\n+  if (rv < 0) {\n+    return rv;\n+  }\n+\n+  if ((width > 0) && ((flags & FLAG_LEFT) != 0)) { /* Left adjusting */\n+    while (--width >= 0) {\n+      rv = (*ss->stuff)(ss, &space, 1);\n+      if (rv < 0) {\n+        return rv;\n+      }\n     }\n-    return 0;\n+  }\n+  return 0;\n }\n \n /*\n ** Fill a number. The order is: optional-sign zero-filling conversion-digits\n */\n-static int\n-fill_n(SprintfState* ss, const char* src, int srclen, int width,\n-       int prec, int type, int flags)\n-{\n-    int zerowidth = 0;\n-    int precwidth = 0;\n-    int signwidth = 0;\n-    int leftspaces = 0;\n-    int rightspaces = 0;\n-    int cvtwidth;\n-    int rv;\n-    char sign;\n-\n-    if ((type & 1) == 0) {\n-        if (flags & FLAG_NEG) {\n-            sign = '-';\n-            signwidth = 1;\n-        } else if (flags & FLAG_SIGNED) {\n-            sign = '+';\n-            signwidth = 1;\n-        } else if (flags & FLAG_SPACED) {\n-            sign = ' ';\n-            signwidth = 1;\n-        }\n+static int fill_n(SprintfState* ss, const char* src, int srclen, int width,\n+                  int prec, int type, int flags) {\n+  int zerowidth = 0;\n+  int precwidth = 0;\n+  int signwidth = 0;\n+  int leftspaces = 0;\n+  int rightspaces = 0;\n+  int cvtwidth;\n+  int rv;\n+  char sign;\n+\n+  if ((type & 1) == 0) {\n+    if (flags & FLAG_NEG) {\n+      sign = '-';\n+      signwidth = 1;\n+    } else if (flags & FLAG_SIGNED) {\n+      sign = '+';\n+      signwidth = 1;\n+    } else if (flags & FLAG_SPACED) {\n+      sign = ' ';\n+      signwidth = 1;\n     }\n-    cvtwidth = signwidth + srclen;\n+  }\n+  cvtwidth = signwidth + srclen;\n \n-    if (prec > 0) {\n-        if (prec > srclen) {\n-            precwidth = prec - srclen; /* Need zero filling */\n-            cvtwidth += precwidth;\n-        }\n+  if (prec > 0) {\n+    if (prec > srclen) {\n+      precwidth = prec - srclen; /* Need zero filling */\n+      cvtwidth += precwidth;\n     }\n+  }\n \n-    if ((flags & FLAG_ZEROS) && (prec < 0)) {\n-        if (width > cvtwidth) {\n-            zerowidth = width - cvtwidth; /* Zero filling */\n-            cvtwidth += zerowidth;\n-        }\n+  if ((flags & FLAG_ZEROS) && (prec < 0)) {\n+    if (width > cvtwidth) {\n+      zerowidth = width - cvtwidth; /* Zero filling */\n+      cvtwidth += zerowidth;\n     }\n+  }\n \n-    if (flags & FLAG_LEFT) {\n-        if (width > cvtwidth) {\n-            /* Space filling on the right (i.e. left adjusting) */\n-            rightspaces = width - cvtwidth;\n-        }\n-    } else {\n-        if (width > cvtwidth) {\n-            /* Space filling on the left (i.e. right adjusting) */\n-            leftspaces = width - cvtwidth;\n-        }\n+  if (flags & FLAG_LEFT) {\n+    if (width > cvtwidth) {\n+      /* Space filling on the right (i.e. left adjusting) */\n+      rightspaces = width - cvtwidth;\n     }\n-    while (--leftspaces >= 0) {\n-        rv = (*ss->stuff)(ss, \" \", 1);\n-        if (rv < 0) {\n-            return rv;\n-        }\n+  } else {\n+    if (width > cvtwidth) {\n+      /* Space filling on the left (i.e. right adjusting) */\n+      leftspaces = width - cvtwidth;\n     }\n-    if (signwidth) {\n-        rv = (*ss->stuff)(ss, &sign, 1);\n-        if (rv < 0) {\n-            return rv;\n-        }\n+  }\n+  while (--leftspaces >= 0) {\n+    rv = (*ss->stuff)(ss, \" \", 1);\n+    if (rv < 0) {\n+      return rv;\n     }\n-    while (--precwidth >= 0) {\n-        rv = (*ss->stuff)(ss, \"0\", 1);\n-        if (rv < 0) {\n-            return rv;\n-        }\n+  }\n+  if (signwidth) {\n+    rv = (*ss->stuff)(ss, &sign, 1);\n+    if (rv < 0) {\n+      return rv;\n     }\n-    while (--zerowidth >= 0) {\n-        rv = (*ss->stuff)(ss, \"0\", 1);\n-        if (rv < 0) {\n-            return rv;\n-        }\n+  }\n+  while (--precwidth >= 0) {\n+    rv = (*ss->stuff)(ss, \"0\", 1);\n+    if (rv < 0) {\n+      return rv;\n     }\n-    rv = (*ss->stuff)(ss, src, srclen);\n+  }\n+  while (--zerowidth >= 0) {\n+    rv = (*ss->stuff)(ss, \"0\", 1);\n     if (rv < 0) {\n-        return rv;\n+      return rv;\n     }\n-    while (--rightspaces >= 0) {\n-        rv = (*ss->stuff)(ss, \" \", 1);\n-        if (rv < 0) {\n-            return rv;\n-        }\n+  }\n+  rv = (*ss->stuff)(ss, src, srclen);\n+  if (rv < 0) {\n+    return rv;\n+  }\n+  while (--rightspaces >= 0) {\n+    rv = (*ss->stuff)(ss, \" \", 1);\n+    if (rv < 0) {\n+      return rv;\n     }\n-    return 0;\n+  }\n+  return 0;\n }\n \n /*\n ** Convert a long into its printable form\n */\n-static int\n-cvt_l(SprintfState* ss, long num, int width, int prec, int radix,\n-      int type, int flags, const char* hexp)\n-{\n-    char cvtbuf[100];\n-    char* cvt;\n-    int digits;\n-\n-    /* according to the man page this needs to happen */\n-    if ((prec == 0) && (num == 0)) {\n-        return 0;\n-    }\n-\n-    /*\n-    ** Converting decimal is a little tricky. In the unsigned case we\n-    ** need to stop when we hit 10 digits. In the signed case, we can\n-    ** stop when the number is zero.\n-    */\n-    cvt = cvtbuf + sizeof(cvtbuf);\n-    digits = 0;\n-    while (num) {\n-        int digit = (((unsigned long)num) % radix) & 0xF;\n-        *--cvt = hexp[digit];\n-        digits++;\n-        num = (long)(((unsigned long)num) / radix);\n-    }\n-    if (digits == 0) {\n-        *--cvt = '0';\n-        digits++;\n-    }\n-\n-    /*\n-    ** Now that we have the number converted without its sign, deal with\n-    ** the sign and zero padding.\n-    */\n-    return fill_n(ss, cvt, digits, width, prec, type, flags);\n+static int cvt_l(SprintfState* ss, long num, int width, int prec, int radix,\n+                 int type, int flags, const char* hexp) {\n+  char cvtbuf[100];\n+  char* cvt;\n+  int digits;\n+\n+  /* according to the man page this needs to happen */\n+  if ((prec == 0) && (num == 0)) {\n+    return 0;\n+  }\n+\n+  /*\n+  ** Converting decimal is a little tricky. In the unsigned case we\n+  ** need to stop when we hit 10 digits. In the signed case, we can\n+  ** stop when the number is zero.\n+  */\n+  cvt = cvtbuf + sizeof(cvtbuf);\n+  digits = 0;\n+  while (num) {\n+    int digit = (((unsigned long)num) % radix) & 0xF;\n+    *--cvt = hexp[digit];\n+    digits++;\n+    num = (long)(((unsigned long)num) / radix);\n+  }\n+  if (digits == 0) {\n+    *--cvt = '0';\n+    digits++;\n+  }\n+\n+  /*\n+  ** Now that we have the number converted without its sign, deal with\n+  ** the sign and zero padding.\n+  */\n+  return fill_n(ss, cvt, digits, width, prec, type, flags);\n }\n \n /*\n ** Convert a 64-bit integer into its printable form\n */\n-static int\n-cvt_ll(SprintfState* ss, PRInt64 num, int width, int prec, int radix,\n-       int type, int flags, const char* hexp)\n-{\n-    char cvtbuf[100];\n-    char* cvt;\n-    int digits;\n-    PRInt64 rad;\n-\n-    /* according to the man page this needs to happen */\n-    if ((prec == 0) && (LL_IS_ZERO(num))) {\n-        return 0;\n-    }\n-\n-    /*\n-    ** Converting decimal is a little tricky. In the unsigned case we\n-    ** need to stop when we hit 10 digits. In the signed case, we can\n-    ** stop when the number is zero.\n-    */\n-    LL_I2L(rad, radix);\n-    cvt = cvtbuf + sizeof(cvtbuf);\n-    digits = 0;\n-    while (!LL_IS_ZERO(num)) {\n-        PRInt32 digit;\n-        PRInt64 quot, rem;\n-        LL_UDIVMOD(&quot, &rem, num, rad);\n-        LL_L2I(digit, rem);\n-        *--cvt = hexp[digit & 0xf];\n-        digits++;\n-        num = quot;\n-    }\n-    if (digits == 0) {\n-        *--cvt = '0';\n-        digits++;\n-    }\n-\n-    /*\n-    ** Now that we have the number converted without its sign, deal with\n-    ** the sign and zero padding.\n-    */\n-    return fill_n(ss, cvt, digits, width, prec, type, flags);\n+static int cvt_ll(SprintfState* ss, PRInt64 num, int width, int prec, int radix,\n+                  int type, int flags, const char* hexp) {\n+  char cvtbuf[100];\n+  char* cvt;\n+  int digits;\n+  PRInt64 rad;\n+\n+  /* according to the man page this needs to happen */\n+  if ((prec == 0) && (LL_IS_ZERO(num))) {\n+    return 0;\n+  }\n+\n+  /*\n+  ** Converting decimal is a little tricky. In the unsigned case we\n+  ** need to stop when we hit 10 digits. In the signed case, we can\n+  ** stop when the number is zero.\n+  */\n+  LL_I2L(rad, radix);\n+  cvt = cvtbuf + sizeof(cvtbuf);\n+  digits = 0;\n+  while (!LL_IS_ZERO(num)) {\n+    PRInt32 digit;\n+    PRInt64 quot, rem;\n+    LL_UDIVMOD(&quot, &rem, num, rad);\n+    LL_L2I(digit, rem);\n+    *--cvt = hexp[digit & 0xf];\n+    digits++;\n+    num = quot;\n+  }\n+  if (digits == 0) {\n+    *--cvt = '0';\n+    digits++;\n+  }\n+\n+  /*\n+  ** Now that we have the number converted without its sign, deal with\n+  ** the sign and zero padding.\n+  */\n+  return fill_n(ss, cvt, digits, width, prec, type, flags);\n }\n \n /*\n@@ -317,38 +310,36 @@ cvt_ll(SprintfState* ss, PRInt64 num, int width, int prec, int radix,\n **\n ** XXX stop using snprintf to convert floating point\n */\n-static int\n-cvt_f(SprintfState* ss, double d, const char* fmt0,\n-      const char* fmt1)\n-{\n-    char fin[20];\n-    char fout[300];\n-    int amount = fmt1 - fmt0;\n-\n-    if (amount <= 0 || amount >= sizeof(fin)) {\n-        /* Totally bogus % command to snprintf. Just ignore it */\n-        return 0;\n-    }\n-    memcpy(fin, fmt0, amount);\n-    fin[amount] = 0;\n+static int cvt_f(SprintfState* ss, double d, const char* fmt0,\n+                 const char* fmt1) {\n+  char fin[20];\n+  char fout[300];\n+  int amount = fmt1 - fmt0;\n+\n+  if (amount <= 0 || amount >= sizeof(fin)) {\n+    /* Totally bogus % command to snprintf. Just ignore it */\n+    return 0;\n+  }\n+  memcpy(fin, fmt0, amount);\n+  fin[amount] = 0;\n \n-    /* Convert floating point using the native snprintf code */\n+  /* Convert floating point using the native snprintf code */\n #ifdef DEBUG\n-    {\n-        const char* p = fin;\n-        while (*p) {\n-            PR_ASSERT(*p != 'L');\n-            p++;\n-        }\n+  {\n+    const char* p = fin;\n+    while (*p) {\n+      PR_ASSERT(*p != 'L');\n+      p++;\n     }\n+  }\n #endif\n-    memset(fout, 0, sizeof(fout));\n-    snprintf(fout, sizeof(fout), fin, d);\n-    /* Explicitly null-terminate fout because on Windows snprintf doesn't\n-     * append a null-terminator if the buffer is too small. */\n-    fout[sizeof(fout) - 1] = '\\0';\n+  memset(fout, 0, sizeof(fout));\n+  snprintf(fout, sizeof(fout), fin, d);\n+  /* Explicitly null-terminate fout because on Windows snprintf doesn't\n+   * append a null-terminator if the buffer is too small. */\n+  fout[sizeof(fout) - 1] = '\\0';\n \n-    return (*ss->stuff)(ss, fout, strlen(fout));\n+  return (*ss->stuff)(ss, fout, strlen(fout));\n }\n \n /*\n@@ -356,33 +347,30 @@ cvt_f(SprintfState* ss, double d, const char* fmt0,\n ** width. \"prec\" is the maximum number of characters of \"s\" to output,\n ** where -1 means until NUL.\n */\n-static int\n-cvt_s(SprintfState* ss, const char* str, int width, int prec,\n-      int flags)\n-{\n-    int slen;\n-\n-    if (prec == 0) {\n-        return 0;\n-    }\n-\n-    /* Limit string length by precision value */\n-    if (!str) {\n-        str = \"(null)\";\n-    }\n-    if (prec > 0) {\n-        /* this is:  slen = strnlen(str, prec); */\n-        register const char* s;\n+static int cvt_s(SprintfState* ss, const char* str, int width, int prec,\n+                 int flags) {\n+  int slen;\n \n-        for (s = str; prec && *s; s++, prec--)\n-            ;\n-        slen = s - str;\n-    } else {\n-        slen = strlen(str);\n-    }\n-\n-    /* and away we go */\n-    return fill2(ss, str, slen, width, flags);\n+  if (prec == 0) {\n+    return 0;\n+  }\n+\n+  /* Limit string length by precision value */\n+  if (!str) {\n+    str = \"(null)\";\n+  }\n+  if (prec > 0) {\n+    /* this is:  slen = strnlen(str, prec); */\n+    register const char* s;\n+\n+    for (s = str; prec && *s; s++, prec--);\n+    slen = s - str;\n+  } else {\n+    slen = strlen(str);\n+  }\n+\n+  /* and away we go */\n+  return fill2(ss, str, slen, width, flags);\n }\n \n /*\n@@ -392,622 +380,618 @@ cvt_s(SprintfState* ss, const char* str, int width, int prec,\n ** the number must start from 1, and no gap among them\n */\n \n-static struct NumArg*\n-BuildArgArray(const char* fmt, va_list ap, int* rv,\n-              struct NumArg* nasArray)\n-{\n-    int number = 0, cn = 0, i;\n-    const char* p;\n-    char c;\n-    struct NumArg* nas;\n-\n-    /*\n-    **  first pass:\n-    **  determine how many legal % I have got, then allocate space\n-    */\n-\n-    p = fmt;\n-    *rv = 0;\n-    i = 0;\n-    while ((c = *p++) != 0) {\n-        if (c != '%') {\n-            continue;\n-        }\n-        if ((c = *p++) == '%') { /* skip %% case */\n-            continue;\n-        }\n-\n-        while (c != 0) {\n-            if (c > '9' || c < '0') {\n-                if (c == '$') { /* numbered argument case */\n-                    if (i > 0) {\n-                        *rv = -1;\n-                        return NULL;\n-                    }\n-                    number++;\n-                } else { /* non-numbered argument case */\n-                    if (number > 0) {\n-                        *rv = -1;\n-                        return NULL;\n-                    }\n-                    i = 1;\n-                }\n-                break;\n-            }\n-\n-            c = *p++;\n-        }\n+static struct NumArg* BuildArgArray(const char* fmt, va_list ap, int* rv,\n+                                    struct NumArg* nasArray) {\n+  int number = 0, cn = 0, i;\n+  const char* p;\n+  char c;\n+  struct NumArg* nas;\n+\n+  /*\n+  **  first pass:\n+  **  determine how many legal % I have got, then allocate space\n+  */\n+\n+  p = fmt;\n+  *rv = 0;\n+  i = 0;\n+  while ((c = *p++) != 0) {\n+    if (c != '%') {\n+      continue;\n     }\n-\n-    if (number == 0) {\n-        return NULL;\n+    if ((c = *p++) == '%') { /* skip %% case */\n+      continue;\n     }\n \n-    if (number > NAS_DEFAULT_NUM) {\n-        nas = (struct NumArg*)PR_MALLOC(number * sizeof(struct NumArg));\n-        if (!nas) {\n+    while (c != 0) {\n+      if (c > '9' || c < '0') {\n+        if (c == '$') { /* numbered argument case */\n+          if (i > 0) {\n+            *rv = -1;\n+            return NULL;\n+          }\n+          number++;\n+        } else { /* non-numbered argument case */\n+          if (number > 0) {\n             *rv = -1;\n             return NULL;\n+          }\n+          i = 1;\n         }\n-    } else {\n-        nas = nasArray;\n-    }\n+        break;\n+      }\n \n-    for (i = 0; i < number; i++) {\n-        nas[i].type = TYPE_UNKNOWN;\n+      c = *p++;\n     }\n+  }\n \n-    /*\n-    ** second pass:\n-    ** set nas[].type\n-    */\n-\n-    p = fmt;\n-    while ((c = *p++) != 0) {\n-        if (c != '%') {\n-            continue;\n-        }\n-        c = *p++;\n-        if (c == '%') {\n-            continue;\n-        }\n+  if (number == 0) {\n+    return NULL;\n+  }\n \n-        cn = 0;\n-        while (c && c != '$') { /* should improve error check later */\n-            cn = cn * 10 + c - '0';\n-            c = *p++;\n-        }\n+  if (number > NAS_DEFAULT_NUM) {\n+    nas = (struct NumArg*)PR_MALLOC(number * sizeof(struct NumArg));\n+    if (!nas) {\n+      *rv = -1;\n+      return NULL;\n+    }\n+  } else {\n+    nas = nasArray;\n+  }\n+\n+  for (i = 0; i < number; i++) {\n+    nas[i].type = TYPE_UNKNOWN;\n+  }\n+\n+  /*\n+  ** second pass:\n+  ** set nas[].type\n+  */\n+\n+  p = fmt;\n+  while ((c = *p++) != 0) {\n+    if (c != '%') {\n+      continue;\n+    }\n+    c = *p++;\n+    if (c == '%') {\n+      continue;\n+    }\n \n-        if (!c || cn < 1 || cn > number) {\n-            *rv = -1;\n-            break;\n-        }\n+    cn = 0;\n+    while (c && c != '$') { /* should improve error check later */\n+      cn = cn * 10 + c - '0';\n+      c = *p++;\n+    }\n \n-        /* nas[cn] starts from 0, and make sure nas[cn].type is not assigned */\n-        cn--;\n-        if (nas[cn].type != TYPE_UNKNOWN) {\n-            continue;\n-        }\n+    if (!c || cn < 1 || cn > number) {\n+      *rv = -1;\n+      break;\n+    }\n \n-        c = *p++;\n+    /* nas[cn] starts from 0, and make sure nas[cn].type is not assigned */\n+    cn--;\n+    if (nas[cn].type != TYPE_UNKNOWN) {\n+      continue;\n+    }\n \n-        /* width */\n-        if (c == '*') {\n-            /* not supported feature, for the argument is not numbered */\n-            *rv = -1;\n-            break;\n-        }\n+    c = *p++;\n \n-        while ((c >= '0') && (c <= '9')) {\n-            c = *p++;\n-        }\n+    /* width */\n+    if (c == '*') {\n+      /* not supported feature, for the argument is not numbered */\n+      *rv = -1;\n+      break;\n+    }\n \n-        /* precision */\n-        if (c == '.') {\n-            c = *p++;\n-            if (c == '*') {\n-                /* not supported feature, for the argument is not numbered */\n-                *rv = -1;\n-                break;\n-            }\n+    while ((c >= '0') && (c <= '9')) {\n+      c = *p++;\n+    }\n \n-            while ((c >= '0') && (c <= '9')) {\n-                c = *p++;\n-            }\n-        }\n+    /* precision */\n+    if (c == '.') {\n+      c = *p++;\n+      if (c == '*') {\n+        /* not supported feature, for the argument is not numbered */\n+        *rv = -1;\n+        break;\n+      }\n \n-        /* size */\n-        nas[cn].type = TYPE_INTN;\n-        if (c == 'h') {\n-            nas[cn].type = TYPE_INT16;\n-            c = *p++;\n-        } else if (c == 'L') {\n-            /* XXX not quite sure here */\n-            nas[cn].type = TYPE_INT64;\n-            c = *p++;\n-        } else if (c == 'l') {\n-            nas[cn].type = TYPE_INT32;\n-            c = *p++;\n-            if (c == 'l') {\n-                nas[cn].type = TYPE_INT64;\n-                c = *p++;\n-            }\n-        } else if (c == 'z') {\n-            if (sizeof(size_t) == sizeof(PRInt32)) {\n-                nas[cn].type = TYPE_INT32;\n-            } else if (sizeof(size_t) == sizeof(PRInt64)) {\n-                nas[cn].type = TYPE_INT64;\n-            } else {\n-                nas[cn].type = TYPE_UNKNOWN;\n-            }\n-            c = *p++;\n-        }\n-\n-        /* format */\n-        switch (c) {\n-            case 'd':\n-            case 'c':\n-            case 'i':\n-            case 'o':\n-            case 'u':\n-            case 'x':\n-            case 'X':\n-                break;\n+      while ((c >= '0') && (c <= '9')) {\n+        c = *p++;\n+      }\n+    }\n \n-            case 'e':\n-            case 'f':\n-            case 'g':\n-                nas[cn].type = TYPE_DOUBLE;\n-                break;\n+    /* size */\n+    nas[cn].type = TYPE_INTN;\n+    if (c == 'h') {\n+      nas[cn].type = TYPE_INT16;\n+      c = *p++;\n+    } else if (c == 'L') {\n+      /* XXX not quite sure here */\n+      nas[cn].type = TYPE_INT64;\n+      c = *p++;\n+    } else if (c == 'l') {\n+      nas[cn].type = TYPE_INT32;\n+      c = *p++;\n+      if (c == 'l') {\n+        nas[cn].type = TYPE_INT64;\n+        c = *p++;\n+      }\n+    } else if (c == 'z') {\n+      if (sizeof(size_t) == sizeof(PRInt32)) {\n+        nas[cn].type = TYPE_INT32;\n+      } else if (sizeof(size_t) == sizeof(PRInt64)) {\n+        nas[cn].type = TYPE_INT64;\n+      } else {\n+        nas[cn].type = TYPE_UNKNOWN;\n+      }\n+      c = *p++;\n+    }\n \n-            case 'p':\n-                /* XXX should use cpp */\n-                if (sizeof(void*) == sizeof(PRInt32)) {\n-                    nas[cn].type = TYPE_UINT32;\n-                } else if (sizeof(void*) == sizeof(PRInt64)) {\n-                    nas[cn].type = TYPE_UINT64;\n-                } else if (sizeof(void*) == sizeof(PRIntn)) {\n-                    nas[cn].type = TYPE_UINTN;\n-                } else {\n-                    nas[cn].type = TYPE_UNKNOWN;\n-                }\n-                break;\n+    /* format */\n+    switch (c) {\n+      case 'd':\n+      case 'c':\n+      case 'i':\n+      case 'o':\n+      case 'u':\n+      case 'x':\n+      case 'X':\n+        break;\n+\n+      case 'e':\n+      case 'f':\n+      case 'g':\n+        nas[cn].type = TYPE_DOUBLE;\n+        break;\n+\n+      case 'p':\n+        /* XXX should use cpp */\n+        if (sizeof(void*) == sizeof(PRInt32)) {\n+          nas[cn].type = TYPE_UINT32;\n+        } else if (sizeof(void*) == sizeof(PRInt64)) {\n+          nas[cn].type = TYPE_UINT64;\n+        } else if (sizeof(void*) == sizeof(PRIntn)) {\n+          nas[cn].type = TYPE_UINTN;\n+        } else {\n+          nas[cn].type = TYPE_UNKNOWN;\n+        }\n+        break;\n \n-            case 'S':\n+      case 'S':\n #ifdef WIN32\n-                nas[cn].type = TYPE_WSTRING;\n-                break;\n+        nas[cn].type = TYPE_WSTRING;\n+        break;\n #endif\n-            case 'C':\n-            case 'E':\n-            case 'G':\n-                /* XXX not supported I suppose */\n-                PR_ASSERT(0);\n-                nas[cn].type = TYPE_UNKNOWN;\n-                break;\n+      case 'C':\n+      case 'E':\n+      case 'G':\n+        /* XXX not supported I suppose */\n+        PR_ASSERT(0);\n+        nas[cn].type = TYPE_UNKNOWN;\n+        break;\n \n-            case 's':\n-                nas[cn].type = TYPE_STRING;\n-                break;\n+      case 's':\n+        nas[cn].type = TYPE_STRING;\n+        break;\n \n-            case 'n':\n-                nas[cn].type = TYPE_INTSTR;\n-                break;\n+      case 'n':\n+        nas[cn].type = TYPE_INTSTR;\n+        break;\n \n-            default:\n-                PR_ASSERT(0);\n-                nas[cn].type = TYPE_UNKNOWN;\n-                break;\n-        }\n+      default:\n+        PR_ASSERT(0);\n+        nas[cn].type = TYPE_UNKNOWN;\n+        break;\n+    }\n \n-        /* get a legal para. */\n-        if (nas[cn].type == TYPE_UNKNOWN) {\n-            *rv = -1;\n-            break;\n-        }\n+    /* get a legal para. */\n+    if (nas[cn].type == TYPE_UNKNOWN) {\n+      *rv = -1;\n+      break;\n     }\n+  }\n \n-    /*\n-    ** third pass\n-    ** fill the nas[cn].ap\n-    */\n+  /*\n+  ** third pass\n+  ** fill the nas[cn].ap\n+  */\n \n-    if (*rv < 0) {\n-        if (nas != nasArray) {\n-            PR_DELETE(nas);\n-        }\n-        return NULL;\n+  if (*rv < 0) {\n+    if (nas != nasArray) {\n+      PR_DELETE(nas);\n+    }\n+    return NULL;\n+  }\n+\n+  cn = 0;\n+  while (cn < number) {\n+    if (nas[cn].type == TYPE_UNKNOWN) {\n+      cn++;\n+      continue;\n     }\n \n-    cn = 0;\n-    while (cn < number) {\n-        if (nas[cn].type == TYPE_UNKNOWN) {\n-            cn++;\n-            continue;\n-        }\n-\n-        switch (nas[cn].type) {\n-            case TYPE_INT16:\n-            case TYPE_UINT16:\n-            case TYPE_INTN:\n-                nas[cn].u.i = va_arg(ap, int);\n-                break;\n+    switch (nas[cn].type) {\n+      case TYPE_INT16:\n+      case TYPE_UINT16:\n+      case TYPE_INTN:\n+        nas[cn].u.i = va_arg(ap, int);\n+        break;\n \n-            case TYPE_UINTN:\n-                nas[cn].u.ui = va_arg(ap, unsigned int);\n-                break;\n+      case TYPE_UINTN:\n+        nas[cn].u.ui = va_arg(ap, unsigned int);\n+        break;\n \n-            case TYPE_INT32:\n-                nas[cn].u.i32 = va_arg(ap, PRInt32);\n-                break;\n+      case TYPE_INT32:\n+        nas[cn].u.i32 = va_arg(ap, PRInt32);\n+        break;\n \n-            case TYPE_UINT32:\n-                nas[cn].u.ui32 = va_arg(ap, PRUint32);\n-                break;\n+      case TYPE_UINT32:\n+        nas[cn].u.ui32 = va_arg(ap, PRUint32);\n+        break;\n \n-            case TYPE_INT64:\n-                nas[cn].u.ll = va_arg(ap, PRInt64);\n-                break;\n+      case TYPE_INT64:\n+        nas[cn].u.ll = va_arg(ap, PRInt64);\n+        break;\n \n-            case TYPE_UINT64:\n-                nas[cn].u.ull = va_arg(ap, PRUint64);\n-                break;\n+      case TYPE_UINT64:\n+        nas[cn].u.ull = va_arg(ap, PRUint64);\n+        break;\n \n-            case TYPE_STRING:\n-                nas[cn].u.s = va_arg(ap, char*);\n-                break;\n+      case TYPE_STRING:\n+        nas[cn].u.s = va_arg(ap, char*);\n+        break;\n \n #ifdef WIN32\n-            case TYPE_WSTRING:\n-                nas[cn].u.ws = va_arg(ap, WCHAR*);\n-                break;\n+      case TYPE_WSTRING:\n+        nas[cn].u.ws = va_arg(ap, WCHAR*);\n+        break;\n #endif\n \n-            case TYPE_INTSTR:\n-                nas[cn].u.ip = va_arg(ap, int*);\n-                break;\n+      case TYPE_INTSTR:\n+        nas[cn].u.ip = va_arg(ap, int*);\n+        break;\n \n-            case TYPE_DOUBLE:\n-                nas[cn].u.d = va_arg(ap, double);\n-                break;\n+      case TYPE_DOUBLE:\n+        nas[cn].u.d = va_arg(ap, double);\n+        break;\n \n-            default:\n-                if (nas != nasArray) {\n-                    PR_DELETE(nas);\n-                }\n-                *rv = -1;\n-                return NULL;\n+      default:\n+        if (nas != nasArray) {\n+          PR_DELETE(nas);\n         }\n-\n-        cn++;\n+        *rv = -1;\n+        return NULL;\n     }\n \n-    return nas;\n+    cn++;\n+  }\n+\n+  return nas;\n }\n \n /*\n ** The workhorse sprintf code.\n */\n-static int\n-dosprintf(SprintfState* ss, const char* fmt, va_list ap)\n-{\n-    char c;\n-    int flags, width, prec, radix, type;\n-    union {\n-        char ch;\n-        int i;\n-        long l;\n-        PRInt64 ll;\n-        double d;\n-        const char* s;\n-        int* ip;\n+static int dosprintf(SprintfState* ss, const char* fmt, va_list ap) {\n+  char c;\n+  int flags, width, prec, radix, type;\n+  union {\n+    char ch;\n+    int i;\n+    long l;\n+    PRInt64 ll;\n+    double d;\n+    const char* s;\n+    int* ip;\n #ifdef WIN32\n-        const WCHAR* ws;\n+    const WCHAR* ws;\n #endif\n-    } u;\n-    const char* fmt0;\n-    static char* hex = \"0123456789abcdef\";\n-    static char* HEX = \"0123456789ABCDEF\";\n-    char* hexp;\n-    int rv, i;\n-    struct NumArg* nas = NULL;\n-    struct NumArg* nap = NULL;\n-    struct NumArg nasArray[NAS_DEFAULT_NUM];\n-    char pattern[20];\n-    const char* dolPt = NULL; /* in \"%4$.2f\", dolPt will point to . */\n+  } u;\n+  const char* fmt0;\n+  static char* hex = \"0123456789abcdef\";\n+  static char* HEX = \"0123456789ABCDEF\";\n+  char* hexp;\n+  int rv, i;\n+  struct NumArg* nas = NULL;\n+  struct NumArg* nap = NULL;\n+  struct NumArg nasArray[NAS_DEFAULT_NUM];\n+  char pattern[20];\n+  const char* dolPt = NULL; /* in \"%4$.2f\", dolPt will point to . */\n #ifdef WIN32\n-    char* pBuf = NULL;\n+  char* pBuf = NULL;\n #endif\n \n-    /*\n-    ** build an argument array, IF the fmt is numbered argument\n-    ** list style, to contain the Numbered Argument list pointers\n-    */\n+  /*\n+  ** build an argument array, IF the fmt is numbered argument\n+  ** list style, to contain the Numbered Argument list pointers\n+  */\n \n-    nas = BuildArgArray(fmt, ap, &rv, nasArray);\n-    if (rv < 0) {\n-        /* the fmt contains error Numbered Argument format, jliu@netscape.com */\n-        PR_ASSERT(0);\n+  nas = BuildArgArray(fmt, ap, &rv, nasArray);\n+  if (rv < 0) {\n+    /* the fmt contains error Numbered Argument format, jliu@netscape.com */\n+    PR_ASSERT(0);\n+    return rv;\n+  }\n+\n+  while ((c = *fmt++) != 0) {\n+    if (c != '%') {\n+      rv = (*ss->stuff)(ss, fmt - 1, 1);\n+      if (rv < 0) {\n         return rv;\n+      }\n+      continue;\n     }\n+    fmt0 = fmt - 1;\n \n-    while ((c = *fmt++) != 0) {\n-        if (c != '%') {\n-            rv = (*ss->stuff)(ss, fmt - 1, 1);\n-            if (rv < 0) {\n-                return rv;\n-            }\n-            continue;\n-        }\n-        fmt0 = fmt - 1;\n+    /*\n+    ** Gobble up the % format string. Hopefully we have handled all\n+    ** of the strange cases!\n+    */\n+    flags = 0;\n+    c = *fmt++;\n+    if (c == '%') {\n+      /* quoting a % with %% */\n+      rv = (*ss->stuff)(ss, fmt - 1, 1);\n+      if (rv < 0) {\n+        return rv;\n+      }\n+      continue;\n+    }\n \n-        /*\n-        ** Gobble up the % format string. Hopefully we have handled all\n-        ** of the strange cases!\n-        */\n-        flags = 0;\n+    if (nas != NULL) {\n+      /* the fmt contains the Numbered Arguments feature */\n+      i = 0;\n+      while (c && c != '$') { /* should improve error check later */\n+        i = (i * 10) + (c - '0');\n         c = *fmt++;\n-        if (c == '%') {\n-            /* quoting a % with %% */\n-            rv = (*ss->stuff)(ss, fmt - 1, 1);\n-            if (rv < 0) {\n-                return rv;\n-            }\n-            continue;\n+      }\n+\n+      if (nas[i - 1].type == TYPE_UNKNOWN) {\n+        if (nas && (nas != nasArray)) {\n+          PR_DELETE(nas);\n         }\n+        return -1;\n+      }\n \n-        if (nas != NULL) {\n-            /* the fmt contains the Numbered Arguments feature */\n-            i = 0;\n-            while (c && c != '$') { /* should improve error check later */\n-                i = (i * 10) + (c - '0');\n-                c = *fmt++;\n-            }\n+      nap = &nas[i - 1];\n+      dolPt = fmt;\n+      c = *fmt++;\n+    }\n \n-            if (nas[i - 1].type == TYPE_UNKNOWN) {\n-                if (nas && (nas != nasArray)) {\n-                    PR_DELETE(nas);\n-                }\n-                return -1;\n-            }\n+    /*\n+     * Examine optional flags.  Note that we do not implement the\n+     * '#' flag of sprintf().  The ANSI C spec. of the '#' flag is\n+     * somewhat ambiguous and not ideal, which is perhaps why\n+     * the various sprintf() implementations are inconsistent\n+     * on this feature.\n+     */\n+    while ((c == '-') || (c == '+') || (c == ' ') || (c == '0')) {\n+      if (c == '-') {\n+        flags |= FLAG_LEFT;\n+      }\n+      if (c == '+') {\n+        flags |= FLAG_SIGNED;\n+      }\n+      if (c == ' ') {\n+        flags |= FLAG_SPACED;\n+      }\n+      if (c == '0') {\n+        flags |= FLAG_ZEROS;\n+      }\n+      c = *fmt++;\n+    }\n+    if (flags & FLAG_SIGNED) {\n+      flags &= ~FLAG_SPACED;\n+    }\n+    if (flags & FLAG_LEFT) {\n+      flags &= ~FLAG_ZEROS;\n+    }\n+\n+    /* width */\n+    if (c == '*') {\n+      c = *fmt++;\n+      width = va_arg(ap, int);\n+    } else {\n+      width = 0;\n+      while ((c >= '0') && (c <= '9')) {\n+        width = (width * 10) + (c - '0');\n+        c = *fmt++;\n+      }\n+    }\n \n-            nap = &nas[i - 1];\n-            dolPt = fmt;\n-            c = *fmt++;\n+    /* precision */\n+    prec = -1;\n+    if (c == '.') {\n+      c = *fmt++;\n+      if (c == '*') {\n+        c = *fmt++;\n+        prec = va_arg(ap, int);\n+      } else {\n+        prec = 0;\n+        while ((c >= '0') && (c <= '9')) {\n+          prec = (prec * 10) + (c - '0');\n+          c = *fmt++;\n         }\n+      }\n+    }\n \n-        /*\n-         * Examine optional flags.  Note that we do not implement the\n-         * '#' flag of sprintf().  The ANSI C spec. of the '#' flag is\n-         * somewhat ambiguous and not ideal, which is perhaps why\n-         * the various sprintf() implementations are inconsistent\n-         * on this feature.\n-         */\n-        while ((c == '-') || (c == '+') || (c == ' ') || (c == '0')) {\n-            if (c == '-') {\n-                flags |= FLAG_LEFT;\n+    /* size */\n+    type = TYPE_INTN;\n+    if (c == 'h') {\n+      type = TYPE_INT16;\n+      c = *fmt++;\n+    } else if (c == 'L') {\n+      /* XXX not quite sure here */\n+      type = TYPE_INT64;\n+      c = *fmt++;\n+    } else if (c == 'l') {\n+      type = TYPE_INT32;\n+      c = *fmt++;\n+      if (c == 'l') {\n+        type = TYPE_INT64;\n+        c = *fmt++;\n+      }\n+    } else if (c == 'z') {\n+      if (sizeof(size_t) == sizeof(PRInt32)) {\n+        type = TYPE_INT32;\n+      } else if (sizeof(size_t) == sizeof(PRInt64)) {\n+        type = TYPE_INT64;\n+      }\n+      c = *fmt++;\n+    }\n+\n+    /* format */\n+    hexp = hex;\n+    switch (c) {\n+      case 'd':\n+      case 'i': /* decimal/integer */\n+        radix = 10;\n+        goto fetch_and_convert;\n+\n+      case 'o': /* octal */\n+        radix = 8;\n+        type |= 1;\n+        goto fetch_and_convert;\n+\n+      case 'u': /* unsigned decimal */\n+        radix = 10;\n+        type |= 1;\n+        goto fetch_and_convert;\n+\n+      case 'x': /* unsigned hex */\n+        radix = 16;\n+        type |= 1;\n+        goto fetch_and_convert;\n+\n+      case 'X': /* unsigned HEX */\n+        radix = 16;\n+        hexp = HEX;\n+        type |= 1;\n+        goto fetch_and_convert;\n+\n+      fetch_and_convert:\n+        switch (type) {\n+          case TYPE_INT16:\n+            u.l = nas ? nap->u.i : va_arg(ap, int);\n+            if (u.l < 0) {\n+              u.l = -u.l;\n+              flags |= FLAG_NEG;\n             }\n-            if (c == '+') {\n-                flags |= FLAG_SIGNED;\n+            goto do_long;\n+          case TYPE_UINT16:\n+            u.l = (nas ? nap->u.i : va_arg(ap, int)) & 0xffff;\n+            goto do_long;\n+          case TYPE_INTN:\n+            u.l = nas ? nap->u.i : va_arg(ap, int);\n+            if (u.l < 0) {\n+              u.l = -u.l;\n+              flags |= FLAG_NEG;\n             }\n-            if (c == ' ') {\n-                flags |= FLAG_SPACED;\n+            goto do_long;\n+          case TYPE_UINTN:\n+            u.l = (long)(nas ? nap->u.ui : va_arg(ap, unsigned int));\n+            goto do_long;\n+\n+          case TYPE_INT32:\n+            u.l = nas ? nap->u.i32 : va_arg(ap, PRInt32);\n+            if (u.l < 0) {\n+              u.l = -u.l;\n+              flags |= FLAG_NEG;\n             }\n-            if (c == '0') {\n-                flags |= FLAG_ZEROS;\n+            goto do_long;\n+          case TYPE_UINT32:\n+            u.l = (long)(nas ? nap->u.ui32 : va_arg(ap, PRUint32));\n+          do_long:\n+            rv = cvt_l(ss, u.l, width, prec, radix, type, flags, hexp);\n+            if (rv < 0) {\n+              return rv;\n             }\n-            c = *fmt++;\n-        }\n-        if (flags & FLAG_SIGNED) {\n-            flags &= ~FLAG_SPACED;\n-        }\n-        if (flags & FLAG_LEFT) {\n-            flags &= ~FLAG_ZEROS;\n+            break;\n+\n+          case TYPE_INT64:\n+            u.ll = nas ? nap->u.ll : va_arg(ap, PRInt64);\n+            if (!LL_GE_ZERO(u.ll)) {\n+              LL_NEG(u.ll, u.ll);\n+              flags |= FLAG_NEG;\n+            }\n+            goto do_longlong;\n+          case TYPE_UINT64:\n+            u.ll = nas ? nap->u.ull : va_arg(ap, PRUint64);\n+          do_longlong:\n+            rv = cvt_ll(ss, u.ll, width, prec, radix, type, flags, hexp);\n+            if (rv < 0) {\n+              return rv;\n+            }\n+            break;\n         }\n+        break;\n \n-        /* width */\n-        if (c == '*') {\n-            c = *fmt++;\n-            width = va_arg(ap, int);\n+      case 'e':\n+      case 'E':\n+      case 'f':\n+      case 'g':\n+        u.d = nas ? nap->u.d : va_arg(ap, double);\n+        if (nas != NULL) {\n+          i = fmt - dolPt;\n+          if (i < sizeof(pattern)) {\n+            pattern[0] = '%';\n+            memcpy(&pattern[1], dolPt, i);\n+            rv = cvt_f(ss, u.d, pattern, &pattern[i + 1]);\n+          }\n         } else {\n-            width = 0;\n-            while ((c >= '0') && (c <= '9')) {\n-                width = (width * 10) + (c - '0');\n-                c = *fmt++;\n-            }\n+          rv = cvt_f(ss, u.d, fmt0, fmt);\n         }\n \n-        /* precision */\n-        prec = -1;\n-        if (c == '.') {\n-            c = *fmt++;\n-            if (c == '*') {\n-                c = *fmt++;\n-                prec = va_arg(ap, int);\n-            } else {\n-                prec = 0;\n-                while ((c >= '0') && (c <= '9')) {\n-                    prec = (prec * 10) + (c - '0');\n-                    c = *fmt++;\n-                }\n-            }\n+        if (rv < 0) {\n+          return rv;\n         }\n+        break;\n \n-        /* size */\n-        type = TYPE_INTN;\n-        if (c == 'h') {\n-            type = TYPE_INT16;\n-            c = *fmt++;\n-        } else if (c == 'L') {\n-            /* XXX not quite sure here */\n-            type = TYPE_INT64;\n-            c = *fmt++;\n-        } else if (c == 'l') {\n-            type = TYPE_INT32;\n-            c = *fmt++;\n-            if (c == 'l') {\n-                type = TYPE_INT64;\n-                c = *fmt++;\n+      case 'c':\n+        u.ch = nas ? nap->u.i : va_arg(ap, int);\n+        if ((flags & FLAG_LEFT) == 0) {\n+          while (width-- > 1) {\n+            rv = (*ss->stuff)(ss, \" \", 1);\n+            if (rv < 0) {\n+              return rv;\n             }\n-        } else if (c == 'z') {\n-            if (sizeof(size_t) == sizeof(PRInt32)) {\n-                type = TYPE_INT32;\n-            } else if (sizeof(size_t) == sizeof(PRInt64)) {\n-                type = TYPE_INT64;\n+          }\n+        }\n+        rv = (*ss->stuff)(ss, &u.ch, 1);\n+        if (rv < 0) {\n+          return rv;\n+        }\n+        if (flags & FLAG_LEFT) {\n+          while (width-- > 1) {\n+            rv = (*ss->stuff)(ss, \" \", 1);\n+            if (rv < 0) {\n+              return rv;\n             }\n-            c = *fmt++;\n+          }\n         }\n-\n-        /* format */\n-        hexp = hex;\n-        switch (c) {\n-            case 'd':\n-            case 'i': /* decimal/integer */\n-                radix = 10;\n-                goto fetch_and_convert;\n-\n-            case 'o': /* octal */\n-                radix = 8;\n-                type |= 1;\n-                goto fetch_and_convert;\n-\n-            case 'u': /* unsigned decimal */\n-                radix = 10;\n-                type |= 1;\n-                goto fetch_and_convert;\n-\n-            case 'x': /* unsigned hex */\n-                radix = 16;\n-                type |= 1;\n-                goto fetch_and_convert;\n-\n-            case 'X': /* unsigned HEX */\n-                radix = 16;\n-                hexp = HEX;\n-                type |= 1;\n-                goto fetch_and_convert;\n-\n-            fetch_and_convert:\n-                switch (type) {\n-                    case TYPE_INT16:\n-                        u.l = nas ? nap->u.i : va_arg(ap, int);\n-                        if (u.l < 0) {\n-                            u.l = -u.l;\n-                            flags |= FLAG_NEG;\n-                        }\n-                        goto do_long;\n-                    case TYPE_UINT16:\n-                        u.l = (nas ? nap->u.i : va_arg(ap, int)) & 0xffff;\n-                        goto do_long;\n-                    case TYPE_INTN:\n-                        u.l = nas ? nap->u.i : va_arg(ap, int);\n-                        if (u.l < 0) {\n-                            u.l = -u.l;\n-                            flags |= FLAG_NEG;\n-                        }\n-                        goto do_long;\n-                    case TYPE_UINTN:\n-                        u.l = (long)(nas ? nap->u.ui : va_arg(ap, unsigned int));\n-                        goto do_long;\n-\n-                    case TYPE_INT32:\n-                        u.l = nas ? nap->u.i32 : va_arg(ap, PRInt32);\n-                        if (u.l < 0) {\n-                            u.l = -u.l;\n-                            flags |= FLAG_NEG;\n-                        }\n-                        goto do_long;\n-                    case TYPE_UINT32:\n-                        u.l = (long)(nas ? nap->u.ui32 : va_arg(ap, PRUint32));\n-                    do_long:\n-                        rv = cvt_l(ss, u.l, width, prec, radix, type, flags, hexp);\n-                        if (rv < 0) {\n-                            return rv;\n-                        }\n-                        break;\n-\n-                    case TYPE_INT64:\n-                        u.ll = nas ? nap->u.ll : va_arg(ap, PRInt64);\n-                        if (!LL_GE_ZERO(u.ll)) {\n-                            LL_NEG(u.ll, u.ll);\n-                            flags |= FLAG_NEG;\n-                        }\n-                        goto do_longlong;\n-                    case TYPE_UINT64:\n-                        u.ll = nas ? nap->u.ull : va_arg(ap, PRUint64);\n-                    do_longlong:\n-                        rv = cvt_ll(ss, u.ll, width, prec, radix, type, flags, hexp);\n-                        if (rv < 0) {\n-                            return rv;\n-                        }\n-                        break;\n-                }\n-                break;\n-\n-            case 'e':\n-            case 'E':\n-            case 'f':\n-            case 'g':\n-                u.d = nas ? nap->u.d : va_arg(ap, double);\n-                if (nas != NULL) {\n-                    i = fmt - dolPt;\n-                    if (i < sizeof(pattern)) {\n-                        pattern[0] = '%';\n-                        memcpy(&pattern[1], dolPt, i);\n-                        rv = cvt_f(ss, u.d, pattern, &pattern[i + 1]);\n-                    }\n-                } else {\n-                    rv = cvt_f(ss, u.d, fmt0, fmt);\n-                }\n-\n-                if (rv < 0) {\n-                    return rv;\n-                }\n-                break;\n-\n-            case 'c':\n-                u.ch = nas ? nap->u.i : va_arg(ap, int);\n-                if ((flags & FLAG_LEFT) == 0) {\n-                    while (width-- > 1) {\n-                        rv = (*ss->stuff)(ss, \" \", 1);\n-                        if (rv < 0) {\n-                            return rv;\n-                        }\n-                    }\n-                }\n-                rv = (*ss->stuff)(ss, &u.ch, 1);\n-                if (rv < 0) {\n-                    return rv;\n-                }\n-                if (flags & FLAG_LEFT) {\n-                    while (width-- > 1) {\n-                        rv = (*ss->stuff)(ss, \" \", 1);\n-                        if (rv < 0) {\n-                            return rv;\n-                        }\n-                    }\n-                }\n-                break;\n-\n-            case 'p':\n-                if (sizeof(void*) == sizeof(PRInt32)) {\n-                    type = TYPE_UINT32;\n-                } else if (sizeof(void*) == sizeof(PRInt64)) {\n-                    type = TYPE_UINT64;\n-                } else if (sizeof(void*) == sizeof(int)) {\n-                    type = TYPE_UINTN;\n-                } else {\n-                    PR_ASSERT(0);\n-                    break;\n-                }\n-                radix = 16;\n-                goto fetch_and_convert;\n+        break;\n+\n+      case 'p':\n+        if (sizeof(void*) == sizeof(PRInt32)) {\n+          type = TYPE_UINT32;\n+        } else if (sizeof(void*) == sizeof(PRInt64)) {\n+          type = TYPE_UINT64;\n+        } else if (sizeof(void*) == sizeof(int)) {\n+          type = TYPE_UINTN;\n+        } else {\n+          PR_ASSERT(0);\n+          break;\n+        }\n+        radix = 16;\n+        goto fetch_and_convert;\n \n #ifndef WIN32\n-            case 'S':\n-                /* XXX not supported I suppose */\n-                PR_ASSERT(0);\n-                break;\n+      case 'S':\n+        /* XXX not supported I suppose */\n+        PR_ASSERT(0);\n+        break;\n #endif\n \n #if 0\n@@ -1020,225 +1004,212 @@ dosprintf(SprintfState* ss, const char* fmt, va_list ap)\n #endif\n \n #ifdef WIN32\n-            case 'S':\n-                u.ws = nas ? nap->u.ws : va_arg(ap, const WCHAR*);\n-\n-                /* Get the required size in rv */\n-                rv = WideCharToMultiByte(CP_ACP, 0, u.ws, -1, NULL, 0, NULL, NULL);\n-                if (rv == 0) {\n-                    rv = 1;\n-                }\n-                pBuf = PR_MALLOC(rv);\n-                WideCharToMultiByte(CP_ACP, 0, u.ws, -1, pBuf, (int)rv, NULL, NULL);\n-                pBuf[rv - 1] = '\\0';\n-\n-                rv = cvt_s(ss, pBuf, width, prec, flags);\n-\n-                /* We don't need the allocated buffer anymore */\n-                PR_Free(pBuf);\n-                if (rv < 0) {\n-                    return rv;\n-                }\n-                break;\n+      case 'S':\n+        u.ws = nas ? nap->u.ws : va_arg(ap, const WCHAR*);\n+\n+        /* Get the required size in rv */\n+        rv = WideCharToMultiByte(CP_ACP, 0, u.ws, -1, NULL, 0, NULL, NULL);\n+        if (rv == 0) {\n+          rv = 1;\n+        }\n+        pBuf = PR_MALLOC(rv);\n+        WideCharToMultiByte(CP_ACP, 0, u.ws, -1, pBuf, (int)rv, NULL, NULL);\n+        pBuf[rv - 1] = '\\0';\n+\n+        rv = cvt_s(ss, pBuf, width, prec, flags);\n+\n+        /* We don't need the allocated buffer anymore */\n+        PR_Free(pBuf);\n+        if (rv < 0) {\n+          return rv;\n+        }\n+        break;\n \n #endif\n \n-            case 's':\n-                u.s = nas ? nap->u.s : va_arg(ap, const char*);\n-                rv = cvt_s(ss, u.s, width, prec, flags);\n-                if (rv < 0) {\n-                    return rv;\n-                }\n-                break;\n+      case 's':\n+        u.s = nas ? nap->u.s : va_arg(ap, const char*);\n+        rv = cvt_s(ss, u.s, width, prec, flags);\n+        if (rv < 0) {\n+          return rv;\n+        }\n+        break;\n \n-            case 'n':\n-                u.ip = nas ? nap->u.ip : va_arg(ap, int*);\n-                if (u.ip) {\n-                    *u.ip = ss->cur - ss->base;\n-                }\n-                break;\n+      case 'n':\n+        u.ip = nas ? nap->u.ip : va_arg(ap, int*);\n+        if (u.ip) {\n+          *u.ip = ss->cur - ss->base;\n+        }\n+        break;\n \n-            default:\n-                /* Not a % token after all... skip it */\n+      default:\n+        /* Not a % token after all... skip it */\n #if 0\n                 PR_ASSERT(0);\n #endif\n-                rv = (*ss->stuff)(ss, \"%\", 1);\n-                if (rv < 0) {\n-                    return rv;\n-                }\n-                rv = (*ss->stuff)(ss, fmt - 1, 1);\n-                if (rv < 0) {\n-                    return rv;\n-                }\n+        rv = (*ss->stuff)(ss, \"%\", 1);\n+        if (rv < 0) {\n+          return rv;\n+        }\n+        rv = (*ss->stuff)(ss, fmt - 1, 1);\n+        if (rv < 0) {\n+          return rv;\n         }\n     }\n+  }\n \n-    /* Stuff trailing NUL */\n-    rv = (*ss->stuff)(ss, \"\\0\", 1);\n+  /* Stuff trailing NUL */\n+  rv = (*ss->stuff)(ss, \"\\0\", 1);\n \n-    if (nas && (nas != nasArray)) {\n-        PR_DELETE(nas);\n-    }\n+  if (nas && (nas != nasArray)) {\n+    PR_DELETE(nas);\n+  }\n \n-    return rv;\n+  return rv;\n }\n \n /************************************************************************/\n \n-static int\n-FuncStuff(SprintfState* ss, const char* sp, PRUint32 len)\n-{\n-    int rv;\n-\n-    /*\n-    ** We will add len to ss->maxlen at the end of the function. First check\n-    ** if ss->maxlen + len would overflow or be greater than PR_INT32_MAX.\n-    */\n-    if (PR_UINT32_MAX - ss->maxlen < len || ss->maxlen + len > PR_INT32_MAX) {\n-        return -1;\n-    }\n-    rv = (*ss->func)(ss->arg, sp, len);\n-    if (rv < 0) {\n-        return rv;\n-    }\n-    ss->maxlen += len;\n-    return 0;\n+static int FuncStuff(SprintfState* ss, const char* sp, PRUint32 len) {\n+  int rv;\n+\n+  /*\n+  ** We will add len to ss->maxlen at the end of the function. First check\n+  ** if ss->maxlen + len would overflow or be greater than PR_INT32_MAX.\n+  */\n+  if (PR_UINT32_MAX - ss->maxlen < len || ss->maxlen + len > PR_INT32_MAX) {\n+    return -1;\n+  }\n+  rv = (*ss->func)(ss->arg, sp, len);\n+  if (rv < 0) {\n+    return rv;\n+  }\n+  ss->maxlen += len;\n+  return 0;\n }\n \n PR_IMPLEMENT(PRUint32)\n-PR_sxprintf(PRStuffFunc func, void* arg, const char* fmt, ...)\n-{\n-    va_list ap;\n-    PRUint32 rv;\n-\n-    va_start(ap, fmt);\n-    rv = PR_vsxprintf(func, arg, fmt, ap);\n-    va_end(ap);\n-    return rv;\n+PR_sxprintf(PRStuffFunc func, void* arg, const char* fmt, ...) {\n+  va_list ap;\n+  PRUint32 rv;\n+\n+  va_start(ap, fmt);\n+  rv = PR_vsxprintf(func, arg, fmt, ap);\n+  va_end(ap);\n+  return rv;\n }\n \n PR_IMPLEMENT(PRUint32)\n-PR_vsxprintf(PRStuffFunc func, void* arg, const char* fmt, va_list ap)\n-{\n-    SprintfState ss;\n-    int rv;\n-\n-    ss.stuff = FuncStuff;\n-    ss.func = func;\n-    ss.arg = arg;\n-    ss.maxlen = 0;\n-    rv = dosprintf(&ss, fmt, ap);\n-    return (rv < 0) ? (PRUint32)-1 : ss.maxlen;\n+PR_vsxprintf(PRStuffFunc func, void* arg, const char* fmt, va_list ap) {\n+  SprintfState ss;\n+  int rv;\n+\n+  ss.stuff = FuncStuff;\n+  ss.func = func;\n+  ss.arg = arg;\n+  ss.maxlen = 0;\n+  rv = dosprintf(&ss, fmt, ap);\n+  return (rv < 0) ? (PRUint32)-1 : ss.maxlen;\n }\n \n /*\n ** Stuff routine that automatically grows the malloc'd output buffer\n ** before it overflows.\n */\n-static int\n-GrowStuff(SprintfState* ss, const char* sp, PRUint32 len)\n-{\n-    ptrdiff_t off;\n-    char* newbase;\n-    PRUint32 newlen;\n-\n-    off = ss->cur - ss->base;\n-    if (PR_UINT32_MAX - len < off) {\n-        /* off + len would be too big. */\n-        return -1;\n+static int GrowStuff(SprintfState* ss, const char* sp, PRUint32 len) {\n+  ptrdiff_t off;\n+  char* newbase;\n+  PRUint32 newlen;\n+\n+  off = ss->cur - ss->base;\n+  if (PR_UINT32_MAX - len < off) {\n+    /* off + len would be too big. */\n+    return -1;\n+  }\n+  if (off + len >= ss->maxlen) {\n+    /* Grow the buffer */\n+    PRUint32 increment = (len > 32) ? len : 32;\n+    if (PR_UINT32_MAX - ss->maxlen < increment) {\n+      /* ss->maxlen + increment would overflow. */\n+      return -1;\n     }\n-    if (off + len >= ss->maxlen) {\n-        /* Grow the buffer */\n-        PRUint32 increment = (len > 32) ? len : 32;\n-        if (PR_UINT32_MAX - ss->maxlen < increment) {\n-            /* ss->maxlen + increment would overflow. */\n-            return -1;\n-        }\n-        newlen = ss->maxlen + increment;\n-        if (newlen > PR_INT32_MAX) {\n-            return -1;\n-        }\n-        if (ss->base) {\n-            newbase = (char*)PR_REALLOC(ss->base, newlen);\n-        } else {\n-            newbase = (char*)PR_MALLOC(newlen);\n-        }\n-        if (!newbase) {\n-            /* Ran out of memory */\n-            return -1;\n-        }\n-        ss->base = newbase;\n-        ss->maxlen = newlen;\n-        ss->cur = ss->base + off;\n+    newlen = ss->maxlen + increment;\n+    if (newlen > PR_INT32_MAX) {\n+      return -1;\n     }\n-\n-    /* Copy data */\n-    while (len) {\n-        --len;\n-        *ss->cur++ = *sp++;\n+    if (ss->base) {\n+      newbase = (char*)PR_REALLOC(ss->base, newlen);\n+    } else {\n+      newbase = (char*)PR_MALLOC(newlen);\n     }\n-    PR_ASSERT((PRUint32)(ss->cur - ss->base) <= ss->maxlen);\n-    return 0;\n+    if (!newbase) {\n+      /* Ran out of memory */\n+      return -1;\n+    }\n+    ss->base = newbase;\n+    ss->maxlen = newlen;\n+    ss->cur = ss->base + off;\n+  }\n+\n+  /* Copy data */\n+  while (len) {\n+    --len;\n+    *ss->cur++ = *sp++;\n+  }\n+  PR_ASSERT((PRUint32)(ss->cur - ss->base) <= ss->maxlen);\n+  return 0;\n }\n \n /*\n ** sprintf into a malloc'd buffer\n */\n-PR_IMPLEMENT(char*)\n-PR_smprintf(const char* fmt, ...)\n-{\n-    va_list ap;\n-    char* rv;\n-\n-    va_start(ap, fmt);\n-    rv = PR_vsmprintf(fmt, ap);\n-    va_end(ap);\n-    return rv;\n+PR_IMPLEMENT(char*) PR_smprintf(const char* fmt, ...) {\n+  va_list ap;\n+  char* rv;\n+\n+  va_start(ap, fmt);\n+  rv = PR_vsmprintf(fmt, ap);\n+  va_end(ap);\n+  return rv;\n }\n \n /*\n ** Free memory allocated, for the caller, by PR_smprintf\n */\n-PR_IMPLEMENT(void)\n-PR_smprintf_free(char* mem) { PR_DELETE(mem); }\n-\n-PR_IMPLEMENT(char*)\n-PR_vsmprintf(const char* fmt, va_list ap)\n-{\n-    SprintfState ss;\n-    int rv;\n-\n-    ss.stuff = GrowStuff;\n-    ss.base = 0;\n-    ss.cur = 0;\n-    ss.maxlen = 0;\n-    rv = dosprintf(&ss, fmt, ap);\n-    if (rv < 0) {\n-        if (ss.base) {\n-            PR_DELETE(ss.base);\n-        }\n-        return 0;\n+PR_IMPLEMENT(void) PR_smprintf_free(char* mem) { PR_DELETE(mem); }\n+\n+PR_IMPLEMENT(char*) PR_vsmprintf(const char* fmt, va_list ap) {\n+  SprintfState ss;\n+  int rv;\n+\n+  ss.stuff = GrowStuff;\n+  ss.base = 0;\n+  ss.cur = 0;\n+  ss.maxlen = 0;\n+  rv = dosprintf(&ss, fmt, ap);\n+  if (rv < 0) {\n+    if (ss.base) {\n+      PR_DELETE(ss.base);\n     }\n-    return ss.base;\n+    return 0;\n+  }\n+  return ss.base;\n }\n \n /*\n ** Stuff routine that discards overflow data\n */\n-static int\n-LimitStuff(SprintfState* ss, const char* sp, PRUint32 len)\n-{\n-    PRUint32 limit = ss->maxlen - (ss->cur - ss->base);\n-\n-    if (len > limit) {\n-        len = limit;\n-    }\n-    while (len) {\n-        --len;\n-        *ss->cur++ = *sp++;\n-    }\n-    return 0;\n+static int LimitStuff(SprintfState* ss, const char* sp, PRUint32 len) {\n+  PRUint32 limit = ss->maxlen - (ss->cur - ss->base);\n+\n+  if (len > limit) {\n+    len = limit;\n+  }\n+  while (len) {\n+    --len;\n+    *ss->cur++ = *sp++;\n+  }\n+  return 0;\n }\n \n /*\n@@ -1246,81 +1217,76 @@ LimitStuff(SprintfState* ss, const char* sp, PRUint32 len)\n ** when finished.\n */\n PR_IMPLEMENT(PRUint32)\n-PR_snprintf(char* out, PRUint32 outlen, const char* fmt, ...)\n-{\n-    va_list ap;\n-    PRUint32 rv;\n-\n-    va_start(ap, fmt);\n-    rv = PR_vsnprintf(out, outlen, fmt, ap);\n-    va_end(ap);\n-    return rv;\n+PR_snprintf(char* out, PRUint32 outlen, const char* fmt, ...) {\n+  va_list ap;\n+  PRUint32 rv;\n+\n+  va_start(ap, fmt);\n+  rv = PR_vsnprintf(out, outlen, fmt, ap);\n+  va_end(ap);\n+  return rv;\n }\n \n PR_IMPLEMENT(PRUint32)\n-PR_vsnprintf(char* out, PRUint32 outlen, const char* fmt, va_list ap)\n-{\n-    SprintfState ss;\n-    PRUint32 n;\n-\n-    PR_ASSERT(outlen != 0 && outlen <= PR_INT32_MAX);\n-    if (outlen == 0 || outlen > PR_INT32_MAX) {\n-        return 0;\n-    }\n+PR_vsnprintf(char* out, PRUint32 outlen, const char* fmt, va_list ap) {\n+  SprintfState ss;\n+  PRUint32 n;\n \n-    ss.stuff = LimitStuff;\n-    ss.base = out;\n-    ss.cur = out;\n-    ss.maxlen = outlen;\n-    (void)dosprintf(&ss, fmt, ap);\n+  PR_ASSERT(outlen != 0 && outlen <= PR_INT32_MAX);\n+  if (outlen == 0 || outlen > PR_INT32_MAX) {\n+    return 0;\n+  }\n \n-    /* If we added chars, and we didn't append a null, do it now. */\n-    if ((ss.cur != ss.base) && (*(ss.cur - 1) != '\\0')) {\n-        *(ss.cur - 1) = '\\0';\n-    }\n+  ss.stuff = LimitStuff;\n+  ss.base = out;\n+  ss.cur = out;\n+  ss.maxlen = outlen;\n+  (void)dosprintf(&ss, fmt, ap);\n+\n+  /* If we added chars, and we didn't append a null, do it now. */\n+  if ((ss.cur != ss.base) && (*(ss.cur - 1) != '\\0')) {\n+    *(ss.cur - 1) = '\\0';\n+  }\n \n-    n = ss.cur - ss.base;\n-    return n ? n - 1 : n;\n+  n = ss.cur - ss.base;\n+  return n ? n - 1 : n;\n }\n \n-PR_IMPLEMENT(char*)\n-PR_sprintf_append(char* last, const char* fmt, ...)\n-{\n-    va_list ap;\n-    char* rv;\n-\n-    va_start(ap, fmt);\n-    rv = PR_vsprintf_append(last, fmt, ap);\n-    va_end(ap);\n-    return rv;\n+PR_IMPLEMENT(char*) PR_sprintf_append(char* last, const char* fmt, ...) {\n+  va_list ap;\n+  char* rv;\n+\n+  va_start(ap, fmt);\n+  rv = PR_vsprintf_append(last, fmt, ap);\n+  va_end(ap);\n+  return rv;\n }\n \n PR_IMPLEMENT(char*)\n-PR_vsprintf_append(char* last, const char* fmt, va_list ap)\n-{\n-    SprintfState ss;\n-    int rv;\n-\n-    ss.stuff = GrowStuff;\n-    if (last) {\n-        size_t lastlen = strlen(last);\n-        if (lastlen > PR_INT32_MAX) {\n-            return 0;\n-        }\n-        ss.base = last;\n-        ss.cur = last + lastlen;\n-        ss.maxlen = lastlen;\n-    } else {\n-        ss.base = 0;\n-        ss.cur = 0;\n-        ss.maxlen = 0;\n+PR_vsprintf_append(char* last, const char* fmt, va_list ap) {\n+  SprintfState ss;\n+  int rv;\n+\n+  ss.stuff = GrowStuff;\n+  if (last) {\n+    size_t lastlen = strlen(last);\n+    if (lastlen > PR_INT32_MAX) {\n+      return 0;\n     }\n-    rv = dosprintf(&ss, fmt, ap);\n-    if (rv < 0) {\n-        if (ss.base) {\n-            PR_DELETE(ss.base);\n-        }\n-        return 0;\n+    ss.base = last;\n+    ss.cur = last + lastlen;\n+    ss.maxlen = lastlen;\n+  } else {\n+    ss.base = 0;\n+    ss.cur = 0;\n+    ss.maxlen = 0;\n+  }\n+  rv = dosprintf(&ss, fmt, ap);\n+  if (rv < 0) {\n+    if (ss.base) {\n+      PR_DELETE(ss.base);\n     }\n-    return ss.base;\n+    return 0;\n+  }\n+  return ss.base;\n }\ndiff --git a/nspr/pr/src/io/prscanf.c b/nspr/pr/src/io/prscanf.c\nindex 96bb9be..858bf2b 100644\n--- a/nspr/pr/src/io/prscanf.c\n+++ b/nspr/pr/src/io/prscanf.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -36,11 +37,11 @@ typedef void (*_PRUngetCharFN)(void* stream, int ch);\n  * conversions in format control strings.\n  */\n typedef enum {\n-    _PR_size_none, /* No size specifier is given */\n-    _PR_size_h,    /* The 'h' specifier, suggesting \"short\" */\n-    _PR_size_l,    /* The 'l' specifier, suggesting \"long\" */\n-    _PR_size_L,    /* The 'L' specifier, meaning a 'long double' */\n-    _PR_size_ll    /* The 'll' specifier, suggesting \"long long\" */\n+  _PR_size_none, /* No size specifier is given */\n+  _PR_size_h,    /* The 'h' specifier, suggesting \"short\" */\n+  _PR_size_l,    /* The 'l' specifier, suggesting \"long\" */\n+  _PR_size_L,    /* The 'L' specifier, meaning a 'long double' */\n+  _PR_size_ll    /* The 'll' specifier, suggesting \"long long\" */\n } _PRSizeSpec;\n \n /*\n@@ -49,17 +50,17 @@ typedef enum {\n  * serve as the input or output arguments for these functions.\n  */\n typedef struct {\n-    _PRGetCharFN get;     /* get a character from input stream */\n-    _PRUngetCharFN unget; /* unget (push back) a character */\n-    void* stream;         /* argument for get and unget */\n-    va_list ap;           /* the variable argument list */\n-    int nChar;            /* number of characters read from 'stream' */\n+  _PRGetCharFN get;     /* get a character from input stream */\n+  _PRUngetCharFN unget; /* unget (push back) a character */\n+  void* stream;         /* argument for get and unget */\n+  va_list ap;           /* the variable argument list */\n+  int nChar;            /* number of characters read from 'stream' */\n \n-    PRBool assign;        /* assign, or suppress assignment? */\n-    int width;            /* field width */\n-    _PRSizeSpec sizeSpec; /* 'h', 'l', 'L', or 'll' */\n+  PRBool assign;        /* assign, or suppress assignment? */\n+  int width;            /* field width */\n+  _PRSizeSpec sizeSpec; /* 'h', 'l', 'L', or 'll' */\n \n-    PRBool converted; /* is the value actually converted? */\n+  PRBool converted; /* is the value actually converted? */\n } ScanfState;\n \n #define GET(state) ((state)->nChar++, (state)->get((state)->stream))\n@@ -76,9 +77,9 @@ typedef struct {\n  */\n \n #define GET_IF_WITHIN_WIDTH(state, ch) \\\n-    if (--(state)->width >= 0) {       \\\n-        (ch) = GET(state);             \\\n-    }\n+  if (--(state)->width >= 0) {         \\\n+    (ch) = GET(state);                 \\\n+  }\n #define WITHIN_WIDTH(state) ((state)->width >= 0)\n \n /*\n@@ -92,92 +93,90 @@ typedef struct {\n  *     - No overflow checking.\n  */\n \n-static PRUint64\n-_pr_strtoull(const char* str, char** endptr, int base)\n-{\n-    static const int BASE_MAX = 16;\n-    static const char digits[] = \"0123456789abcdef\";\n-    char* digitPtr;\n-    PRUint64 x; /* return value */\n-    PRInt64 base64;\n-    const char* cPtr;\n-    PRBool negative;\n-    const char* digitStart;\n-\n-    PR_ASSERT(base == 0 || base == 8 || base == 10 || base == 16);\n-    if (base < 0 || base == 1 || base > BASE_MAX) {\n-        if (endptr) {\n-            *endptr = (char*)str;\n-            return LL_ZERO;\n-        }\n-    }\n-\n-    cPtr = str;\n-    while (isspace(*cPtr)) {\n-        ++cPtr;\n-    }\n-\n-    negative = PR_FALSE;\n-    if (*cPtr == '-') {\n-        negative = PR_TRUE;\n-        cPtr++;\n-    } else if (*cPtr == '+') {\n-        cPtr++;\n-    }\n-\n-    if (base == 16) {\n-        if (*cPtr == '0' && (cPtr[1] == 'x' || cPtr[1] == 'X')) {\n-            cPtr += 2;\n-        }\n-    } else if (base == 0) {\n-        if (*cPtr != '0') {\n-            base = 10;\n-        } else if (cPtr[1] == 'x' || cPtr[1] == 'X') {\n-            base = 16;\n-            cPtr += 2;\n-        } else {\n-            base = 8;\n-        }\n+static PRUint64 _pr_strtoull(const char* str, char** endptr, int base) {\n+  static const int BASE_MAX = 16;\n+  static const char digits[] = \"0123456789abcdef\";\n+  char* digitPtr;\n+  PRUint64 x; /* return value */\n+  PRInt64 base64;\n+  const char* cPtr;\n+  PRBool negative;\n+  const char* digitStart;\n+\n+  PR_ASSERT(base == 0 || base == 8 || base == 10 || base == 16);\n+  if (base < 0 || base == 1 || base > BASE_MAX) {\n+    if (endptr) {\n+      *endptr = (char*)str;\n+      return LL_ZERO;\n+    }\n+  }\n+\n+  cPtr = str;\n+  while (isspace(*cPtr)) {\n+    ++cPtr;\n+  }\n+\n+  negative = PR_FALSE;\n+  if (*cPtr == '-') {\n+    negative = PR_TRUE;\n+    cPtr++;\n+  } else if (*cPtr == '+') {\n+    cPtr++;\n+  }\n+\n+  if (base == 16) {\n+    if (*cPtr == '0' && (cPtr[1] == 'x' || cPtr[1] == 'X')) {\n+      cPtr += 2;\n+    }\n+  } else if (base == 0) {\n+    if (*cPtr != '0') {\n+      base = 10;\n+    } else if (cPtr[1] == 'x' || cPtr[1] == 'X') {\n+      base = 16;\n+      cPtr += 2;\n+    } else {\n+      base = 8;\n     }\n-    PR_ASSERT(base != 0);\n-    LL_I2L(base64, base);\n-    digitStart = cPtr;\n+  }\n+  PR_ASSERT(base != 0);\n+  LL_I2L(base64, base);\n+  digitStart = cPtr;\n \n-    /* Skip leading zeros */\n-    while (*cPtr == '0') {\n-        cPtr++;\n-    }\n+  /* Skip leading zeros */\n+  while (*cPtr == '0') {\n+    cPtr++;\n+  }\n \n-    LL_I2L(x, 0);\n-    while ((digitPtr = (char*)memchr(digits, tolower(*cPtr), base)) != NULL) {\n-        PRUint64 d;\n+  LL_I2L(x, 0);\n+  while ((digitPtr = (char*)memchr(digits, tolower(*cPtr), base)) != NULL) {\n+    PRUint64 d;\n \n-        LL_I2L(d, (digitPtr - digits));\n-        LL_MUL(x, x, base64);\n-        LL_ADD(x, x, d);\n-        cPtr++;\n-    }\n+    LL_I2L(d, (digitPtr - digits));\n+    LL_MUL(x, x, base64);\n+    LL_ADD(x, x, d);\n+    cPtr++;\n+  }\n \n-    if (cPtr == digitStart) {\n-        if (endptr) {\n-            *endptr = (char*)str;\n-        }\n-        return LL_ZERO;\n+  if (cPtr == digitStart) {\n+    if (endptr) {\n+      *endptr = (char*)str;\n     }\n+    return LL_ZERO;\n+  }\n \n-    if (negative) {\n+  if (negative) {\n #ifdef HAVE_LONG_LONG\n-        /* The cast to a signed type is to avoid a compiler warning */\n-        x = -(PRInt64)x;\n+    /* The cast to a signed type is to avoid a compiler warning */\n+    x = -(PRInt64)x;\n #else\n-        LL_NEG(x, x);\n+    LL_NEG(x, x);\n #endif\n-    }\n+  }\n \n-    if (endptr) {\n-        *endptr = (char*)cPtr;\n-    }\n-    return x;\n+  if (endptr) {\n+    *endptr = (char*)cPtr;\n+  }\n+  return x;\n }\n \n /*\n@@ -188,189 +187,185 @@ _pr_strtoull(const char* str, char** endptr, int base)\n #define FMAX 31\n #define DECIMAL_POINT '.'\n \n-static PRStatus\n-GetInt(ScanfState* state, int code)\n-{\n-    char buf[FMAX + 1], *p;\n-    int ch = 0;\n-    static const char digits[] = \"0123456789abcdefABCDEF\";\n-    PRBool seenDigit = PR_FALSE;\n-    int base;\n-    int dlen;\n-\n-    switch (code) {\n-        case 'd':\n-        case 'u':\n-            base = 10;\n-            break;\n-        case 'i':\n-            base = 0;\n-            break;\n-        case 'x':\n-        case 'X':\n-        case 'p':\n-            base = 16;\n-            break;\n-        case 'o':\n-            base = 8;\n-            break;\n-        default:\n-            return PR_FAILURE;\n-    }\n-    if (state->width == 0 || state->width > FMAX) {\n-        state->width = FMAX;\n-    }\n-    p = buf;\n+static PRStatus GetInt(ScanfState* state, int code) {\n+  char buf[FMAX + 1], *p;\n+  int ch = 0;\n+  static const char digits[] = \"0123456789abcdefABCDEF\";\n+  PRBool seenDigit = PR_FALSE;\n+  int base;\n+  int dlen;\n+\n+  switch (code) {\n+    case 'd':\n+    case 'u':\n+      base = 10;\n+      break;\n+    case 'i':\n+      base = 0;\n+      break;\n+    case 'x':\n+    case 'X':\n+    case 'p':\n+      base = 16;\n+      break;\n+    case 'o':\n+      base = 8;\n+      break;\n+    default:\n+      return PR_FAILURE;\n+  }\n+  if (state->width == 0 || state->width > FMAX) {\n+    state->width = FMAX;\n+  }\n+  p = buf;\n+  GET_IF_WITHIN_WIDTH(state, ch);\n+  if (WITHIN_WIDTH(state) && (ch == '+' || ch == '-')) {\n+    *p++ = ch;\n     GET_IF_WITHIN_WIDTH(state, ch);\n-    if (WITHIN_WIDTH(state) && (ch == '+' || ch == '-')) {\n-        *p++ = ch;\n-        GET_IF_WITHIN_WIDTH(state, ch);\n-    }\n-    if (WITHIN_WIDTH(state) && ch == '0') {\n-        seenDigit = PR_TRUE;\n-        *p++ = ch;\n-        GET_IF_WITHIN_WIDTH(state, ch);\n-        if (WITHIN_WIDTH(state) && (ch == 'x' || ch == 'X') &&\n-            (base == 0 || base == 16)) {\n-            base = 16;\n-            *p++ = ch;\n-            GET_IF_WITHIN_WIDTH(state, ch);\n-        } else if (base == 0) {\n-            base = 8;\n+  }\n+  if (WITHIN_WIDTH(state) && ch == '0') {\n+    seenDigit = PR_TRUE;\n+    *p++ = ch;\n+    GET_IF_WITHIN_WIDTH(state, ch);\n+    if (WITHIN_WIDTH(state) && (ch == 'x' || ch == 'X') &&\n+        (base == 0 || base == 16)) {\n+      base = 16;\n+      *p++ = ch;\n+      GET_IF_WITHIN_WIDTH(state, ch);\n+    } else if (base == 0) {\n+      base = 8;\n+    }\n+  }\n+  if (base == 0 || base == 10) {\n+    dlen = 10;\n+  } else if (base == 8) {\n+    dlen = 8;\n+  } else {\n+    PR_ASSERT(base == 16);\n+    dlen = 16 + 6; /* 16 digits, plus 6 in uppercase */\n+  }\n+  while (WITHIN_WIDTH(state) && memchr(digits, ch, dlen)) {\n+    *p++ = ch;\n+    GET_IF_WITHIN_WIDTH(state, ch);\n+    seenDigit = PR_TRUE;\n+  }\n+  if (WITHIN_WIDTH(state)) {\n+    UNGET(state, ch);\n+  }\n+  if (!seenDigit) {\n+    return PR_FAILURE;\n+  }\n+  *p = '\\0';\n+  if (state->assign) {\n+    if (code == 'd' || code == 'i') {\n+      if (state->sizeSpec == _PR_size_ll) {\n+        PRInt64 llval = _pr_strtoull(buf, NULL, base);\n+        *va_arg(state->ap, PRInt64*) = llval;\n+      } else {\n+        long lval = strtol(buf, NULL, base);\n+\n+        if (state->sizeSpec == _PR_size_none) {\n+          *va_arg(state->ap, PRIntn*) = lval;\n+        } else if (state->sizeSpec == _PR_size_h) {\n+          *va_arg(state->ap, PRInt16*) = (PRInt16)lval;\n+        } else if (state->sizeSpec == _PR_size_l) {\n+          *va_arg(state->ap, PRInt32*) = lval;\n+        } else {\n+          return PR_FAILURE;\n         }\n-    }\n-    if (base == 0 || base == 10) {\n-        dlen = 10;\n-    } else if (base == 8) {\n-        dlen = 8;\n+      }\n     } else {\n-        PR_ASSERT(base == 16);\n-        dlen = 16 + 6; /* 16 digits, plus 6 in uppercase */\n-    }\n-    while (WITHIN_WIDTH(state) && memchr(digits, ch, dlen)) {\n-        *p++ = ch;\n-        GET_IF_WITHIN_WIDTH(state, ch);\n-        seenDigit = PR_TRUE;\n-    }\n-    if (WITHIN_WIDTH(state)) {\n-        UNGET(state, ch);\n-    }\n-    if (!seenDigit) {\n-        return PR_FAILURE;\n-    }\n-    *p = '\\0';\n-    if (state->assign) {\n-        if (code == 'd' || code == 'i') {\n-            if (state->sizeSpec == _PR_size_ll) {\n-                PRInt64 llval = _pr_strtoull(buf, NULL, base);\n-                *va_arg(state->ap, PRInt64*) = llval;\n-            } else {\n-                long lval = strtol(buf, NULL, base);\n-\n-                if (state->sizeSpec == _PR_size_none) {\n-                    *va_arg(state->ap, PRIntn*) = lval;\n-                } else if (state->sizeSpec == _PR_size_h) {\n-                    *va_arg(state->ap, PRInt16*) = (PRInt16)lval;\n-                } else if (state->sizeSpec == _PR_size_l) {\n-                    *va_arg(state->ap, PRInt32*) = lval;\n-                } else {\n-                    return PR_FAILURE;\n-                }\n-            }\n+      if (state->sizeSpec == _PR_size_ll) {\n+        PRUint64 llval = _pr_strtoull(buf, NULL, base);\n+        *va_arg(state->ap, PRUint64*) = llval;\n+      } else {\n+        unsigned long lval = strtoul(buf, NULL, base);\n+\n+        if (state->sizeSpec == _PR_size_none) {\n+          *va_arg(state->ap, PRUintn*) = lval;\n+        } else if (state->sizeSpec == _PR_size_h) {\n+          *va_arg(state->ap, PRUint16*) = (PRUint16)lval;\n+        } else if (state->sizeSpec == _PR_size_l) {\n+          *va_arg(state->ap, PRUint32*) = lval;\n         } else {\n-            if (state->sizeSpec == _PR_size_ll) {\n-                PRUint64 llval = _pr_strtoull(buf, NULL, base);\n-                *va_arg(state->ap, PRUint64*) = llval;\n-            } else {\n-                unsigned long lval = strtoul(buf, NULL, base);\n-\n-                if (state->sizeSpec == _PR_size_none) {\n-                    *va_arg(state->ap, PRUintn*) = lval;\n-                } else if (state->sizeSpec == _PR_size_h) {\n-                    *va_arg(state->ap, PRUint16*) = (PRUint16)lval;\n-                } else if (state->sizeSpec == _PR_size_l) {\n-                    *va_arg(state->ap, PRUint32*) = lval;\n-                } else {\n-                    return PR_FAILURE;\n-                }\n-            }\n+          return PR_FAILURE;\n         }\n-        state->converted = PR_TRUE;\n+      }\n     }\n-    return PR_SUCCESS;\n+    state->converted = PR_TRUE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-static PRStatus\n-GetFloat(ScanfState* state)\n-{\n-    char buf[FMAX + 1], *p;\n-    int ch = 0;\n-    PRBool seenDigit = PR_FALSE;\n-\n-    if (state->width == 0 || state->width > FMAX) {\n-        state->width = FMAX;\n-    }\n-    p = buf;\n+static PRStatus GetFloat(ScanfState* state) {\n+  char buf[FMAX + 1], *p;\n+  int ch = 0;\n+  PRBool seenDigit = PR_FALSE;\n+\n+  if (state->width == 0 || state->width > FMAX) {\n+    state->width = FMAX;\n+  }\n+  p = buf;\n+  GET_IF_WITHIN_WIDTH(state, ch);\n+  if (WITHIN_WIDTH(state) && (ch == '+' || ch == '-')) {\n+    *p++ = ch;\n+    GET_IF_WITHIN_WIDTH(state, ch);\n+  }\n+  while (WITHIN_WIDTH(state) && isdigit(ch)) {\n+    *p++ = ch;\n+    GET_IF_WITHIN_WIDTH(state, ch);\n+    seenDigit = PR_TRUE;\n+  }\n+  if (WITHIN_WIDTH(state) && ch == DECIMAL_POINT) {\n+    *p++ = ch;\n+    GET_IF_WITHIN_WIDTH(state, ch);\n+    while (WITHIN_WIDTH(state) && isdigit(ch)) {\n+      *p++ = ch;\n+      GET_IF_WITHIN_WIDTH(state, ch);\n+      seenDigit = PR_TRUE;\n+    }\n+  }\n+\n+  /*\n+   * This is not robust.  For example, \"1.2e+\" would confuse\n+   * the code below to read 'e' and '+', only to realize that\n+   * it should have stopped at \"1.2\".  But we can't push back\n+   * more than one character, so there is nothing I can do.\n+   */\n+\n+  /* Parse exponent */\n+  if (WITHIN_WIDTH(state) && (ch == 'e' || ch == 'E') && seenDigit) {\n+    *p++ = ch;\n     GET_IF_WITHIN_WIDTH(state, ch);\n     if (WITHIN_WIDTH(state) && (ch == '+' || ch == '-')) {\n-        *p++ = ch;\n-        GET_IF_WITHIN_WIDTH(state, ch);\n+      *p++ = ch;\n+      GET_IF_WITHIN_WIDTH(state, ch);\n     }\n     while (WITHIN_WIDTH(state) && isdigit(ch)) {\n-        *p++ = ch;\n-        GET_IF_WITHIN_WIDTH(state, ch);\n-        seenDigit = PR_TRUE;\n-    }\n-    if (WITHIN_WIDTH(state) && ch == DECIMAL_POINT) {\n-        *p++ = ch;\n-        GET_IF_WITHIN_WIDTH(state, ch);\n-        while (WITHIN_WIDTH(state) && isdigit(ch)) {\n-            *p++ = ch;\n-            GET_IF_WITHIN_WIDTH(state, ch);\n-            seenDigit = PR_TRUE;\n-        }\n-    }\n-\n-    /*\n-     * This is not robust.  For example, \"1.2e+\" would confuse\n-     * the code below to read 'e' and '+', only to realize that\n-     * it should have stopped at \"1.2\".  But we can't push back\n-     * more than one character, so there is nothing I can do.\n-     */\n-\n-    /* Parse exponent */\n-    if (WITHIN_WIDTH(state) && (ch == 'e' || ch == 'E') && seenDigit) {\n-        *p++ = ch;\n-        GET_IF_WITHIN_WIDTH(state, ch);\n-        if (WITHIN_WIDTH(state) && (ch == '+' || ch == '-')) {\n-            *p++ = ch;\n-            GET_IF_WITHIN_WIDTH(state, ch);\n-        }\n-        while (WITHIN_WIDTH(state) && isdigit(ch)) {\n-            *p++ = ch;\n-            GET_IF_WITHIN_WIDTH(state, ch);\n-        }\n-    }\n-    if (WITHIN_WIDTH(state)) {\n-        UNGET(state, ch);\n-    }\n-    if (!seenDigit) {\n-        return PR_FAILURE;\n-    }\n-    *p = '\\0';\n-    if (state->assign) {\n-        PRFloat64 dval = PR_strtod(buf, NULL);\n-\n-        state->converted = PR_TRUE;\n-        if (state->sizeSpec == _PR_size_l) {\n-            *va_arg(state->ap, PRFloat64*) = dval;\n-        } else if (state->sizeSpec == _PR_size_L) {\n-            *va_arg(state->ap, long double*) = dval;\n-        } else {\n-            *va_arg(state->ap, float*) = (float)dval;\n-        }\n+      *p++ = ch;\n+      GET_IF_WITHIN_WIDTH(state, ch);\n+    }\n+  }\n+  if (WITHIN_WIDTH(state)) {\n+    UNGET(state, ch);\n+  }\n+  if (!seenDigit) {\n+    return PR_FAILURE;\n+  }\n+  *p = '\\0';\n+  if (state->assign) {\n+    PRFloat64 dval = PR_strtod(buf, NULL);\n+\n+    state->converted = PR_TRUE;\n+    if (state->sizeSpec == _PR_size_l) {\n+      *va_arg(state->ap, PRFloat64*) = dval;\n+    } else if (state->sizeSpec == _PR_size_L) {\n+      *va_arg(state->ap, long double*) = dval;\n+    } else {\n+      *va_arg(state->ap, float*) = (float)dval;\n     }\n-    return PR_SUCCESS;\n+  }\n+  return PR_SUCCESS;\n }\n \n /*\n@@ -378,257 +373,248 @@ GetFloat(ScanfState* state)\n  * Return NULL on error.\n  */\n \n-static const char*\n-Convert(ScanfState* state, const char* fmt)\n-{\n-    const char* cPtr;\n-    int ch;\n-    char* cArg = NULL;\n-\n-    state->converted = PR_FALSE;\n-    cPtr = fmt;\n-    if (*cPtr != 'c' && *cPtr != 'n' && *cPtr != '[') {\n-        do {\n-            ch = GET(state);\n-        } while (isspace(ch));\n-        UNGET(state, ch);\n-    }\n-    switch (*cPtr) {\n-        case 'c':\n-            if (state->assign) {\n-                cArg = va_arg(state->ap, char*);\n-            }\n-            if (state->width == 0) {\n-                state->width = 1;\n-            }\n-            for (; state->width > 0; state->width--) {\n-                ch = GET(state);\n-                if (ch == EOF) {\n-                    return NULL;\n-                }\n-                if (state->assign) {\n-                    *cArg++ = ch;\n-                }\n-            }\n-            if (state->assign) {\n-                state->converted = PR_TRUE;\n-            }\n-            break;\n-        case 'p':\n-        case 'd':\n-        case 'i':\n-        case 'o':\n-        case 'u':\n-        case 'x':\n-        case 'X':\n-            if (GetInt(state, *cPtr) == PR_FAILURE) {\n-                return NULL;\n-            }\n-            break;\n-        case 'e':\n-        case 'E':\n-        case 'f':\n-        case 'g':\n-        case 'G':\n-            if (GetFloat(state) == PR_FAILURE) {\n-                return NULL;\n-            }\n+static const char* Convert(ScanfState* state, const char* fmt) {\n+  const char* cPtr;\n+  int ch;\n+  char* cArg = NULL;\n+\n+  state->converted = PR_FALSE;\n+  cPtr = fmt;\n+  if (*cPtr != 'c' && *cPtr != 'n' && *cPtr != '[') {\n+    do {\n+      ch = GET(state);\n+    } while (isspace(ch));\n+    UNGET(state, ch);\n+  }\n+  switch (*cPtr) {\n+    case 'c':\n+      if (state->assign) {\n+        cArg = va_arg(state->ap, char*);\n+      }\n+      if (state->width == 0) {\n+        state->width = 1;\n+      }\n+      for (; state->width > 0; state->width--) {\n+        ch = GET(state);\n+        if (ch == EOF) {\n+          return NULL;\n+        }\n+        if (state->assign) {\n+          *cArg++ = ch;\n+        }\n+      }\n+      if (state->assign) {\n+        state->converted = PR_TRUE;\n+      }\n+      break;\n+    case 'p':\n+    case 'd':\n+    case 'i':\n+    case 'o':\n+    case 'u':\n+    case 'x':\n+    case 'X':\n+      if (GetInt(state, *cPtr) == PR_FAILURE) {\n+        return NULL;\n+      }\n+      break;\n+    case 'e':\n+    case 'E':\n+    case 'f':\n+    case 'g':\n+    case 'G':\n+      if (GetFloat(state) == PR_FAILURE) {\n+        return NULL;\n+      }\n+      break;\n+    case 'n':\n+      /* do not consume any input */\n+      if (state->assign) {\n+        switch (state->sizeSpec) {\n+          case _PR_size_none:\n+            *va_arg(state->ap, PRIntn*) = state->nChar;\n             break;\n-        case 'n':\n-            /* do not consume any input */\n-            if (state->assign) {\n-                switch (state->sizeSpec) {\n-                    case _PR_size_none:\n-                        *va_arg(state->ap, PRIntn*) = state->nChar;\n-                        break;\n-                    case _PR_size_h:\n-                        *va_arg(state->ap, PRInt16*) = state->nChar;\n-                        break;\n-                    case _PR_size_l:\n-                        *va_arg(state->ap, PRInt32*) = state->nChar;\n-                        break;\n-                    case _PR_size_ll:\n-                        LL_I2L(*va_arg(state->ap, PRInt64*), state->nChar);\n-                        break;\n-                    default:\n-                        PR_ASSERT(0);\n-                }\n-            }\n+          case _PR_size_h:\n+            *va_arg(state->ap, PRInt16*) = state->nChar;\n             break;\n-        case 's':\n-            if (state->width == 0) {\n-                state->width = INT_MAX;\n-            }\n-            if (state->assign) {\n-                cArg = va_arg(state->ap, char*);\n-            }\n-            for (; state->width > 0; state->width--) {\n-                ch = GET(state);\n-                if ((ch == EOF) || isspace(ch)) {\n-                    UNGET(state, ch);\n-                    break;\n-                }\n-                if (state->assign) {\n-                    *cArg++ = ch;\n-                }\n-            }\n-            if (state->assign) {\n-                *cArg = '\\0';\n-                state->converted = PR_TRUE;\n-            }\n+          case _PR_size_l:\n+            *va_arg(state->ap, PRInt32*) = state->nChar;\n             break;\n-        case '%':\n-            ch = GET(state);\n-            if (ch != '%') {\n-                UNGET(state, ch);\n-                return NULL;\n-            }\n+          case _PR_size_ll:\n+            LL_I2L(*va_arg(state->ap, PRInt64*), state->nChar);\n             break;\n-        case '[': {\n-            PRBool complement = PR_FALSE;\n-            const char* closeBracket;\n-            size_t n;\n-\n-            if (*++cPtr == '^') {\n-                complement = PR_TRUE;\n-                cPtr++;\n-            }\n-            closeBracket = strchr(*cPtr == ']' ? cPtr + 1 : cPtr, ']');\n-            if (closeBracket == NULL) {\n-                return NULL;\n-            }\n-            n = closeBracket - cPtr;\n-            if (state->width == 0) {\n-                state->width = INT_MAX;\n-            }\n-            if (state->assign) {\n-                cArg = va_arg(state->ap, char*);\n-            }\n-            for (; state->width > 0; state->width--) {\n-                ch = GET(state);\n-                if ((ch == EOF) || (!complement && !memchr(cPtr, ch, n)) ||\n-                    (complement && memchr(cPtr, ch, n))) {\n-                    UNGET(state, ch);\n-                    break;\n-                }\n-                if (state->assign) {\n-                    *cArg++ = ch;\n-                }\n-            }\n-            if (state->assign) {\n-                *cArg = '\\0';\n-                state->converted = PR_TRUE;\n-            }\n-            cPtr = closeBracket;\n-        } break;\n-        default:\n-            return NULL;\n-    }\n-    return cPtr;\n+          default:\n+            PR_ASSERT(0);\n+        }\n+      }\n+      break;\n+    case 's':\n+      if (state->width == 0) {\n+        state->width = INT_MAX;\n+      }\n+      if (state->assign) {\n+        cArg = va_arg(state->ap, char*);\n+      }\n+      for (; state->width > 0; state->width--) {\n+        ch = GET(state);\n+        if ((ch == EOF) || isspace(ch)) {\n+          UNGET(state, ch);\n+          break;\n+        }\n+        if (state->assign) {\n+          *cArg++ = ch;\n+        }\n+      }\n+      if (state->assign) {\n+        *cArg = '\\0';\n+        state->converted = PR_TRUE;\n+      }\n+      break;\n+    case '%':\n+      ch = GET(state);\n+      if (ch != '%') {\n+        UNGET(state, ch);\n+        return NULL;\n+      }\n+      break;\n+    case '[': {\n+      PRBool complement = PR_FALSE;\n+      const char* closeBracket;\n+      size_t n;\n+\n+      if (*++cPtr == '^') {\n+        complement = PR_TRUE;\n+        cPtr++;\n+      }\n+      closeBracket = strchr(*cPtr == ']' ? cPtr + 1 : cPtr, ']');\n+      if (closeBracket == NULL) {\n+        return NULL;\n+      }\n+      n = closeBracket - cPtr;\n+      if (state->width == 0) {\n+        state->width = INT_MAX;\n+      }\n+      if (state->assign) {\n+        cArg = va_arg(state->ap, char*);\n+      }\n+      for (; state->width > 0; state->width--) {\n+        ch = GET(state);\n+        if ((ch == EOF) || (!complement && !memchr(cPtr, ch, n)) ||\n+            (complement && memchr(cPtr, ch, n))) {\n+          UNGET(state, ch);\n+          break;\n+        }\n+        if (state->assign) {\n+          *cArg++ = ch;\n+        }\n+      }\n+      if (state->assign) {\n+        *cArg = '\\0';\n+        state->converted = PR_TRUE;\n+      }\n+      cPtr = closeBracket;\n+    } break;\n+    default:\n+      return NULL;\n+  }\n+  return cPtr;\n }\n \n-static PRInt32\n-DoScanf(ScanfState* state, const char* fmt)\n-{\n-    PRInt32 nConverted = 0;\n-    const char* cPtr;\n-    int ch;\n-\n-    state->nChar = 0;\n-    cPtr = fmt;\n-    while (1) {\n-        if (isspace(*cPtr)) {\n-            /* white space: skip */\n-            do {\n-                cPtr++;\n-            } while (isspace(*cPtr));\n-            do {\n-                ch = GET(state);\n-            } while (isspace(ch));\n-            UNGET(state, ch);\n-        } else if (*cPtr == '%') {\n-            /* format spec: convert */\n-            cPtr++;\n-            state->assign = PR_TRUE;\n-            if (*cPtr == '*') {\n-                cPtr++;\n-                state->assign = PR_FALSE;\n-            }\n-            for (state->width = 0; isdigit(*cPtr); cPtr++) {\n-                state->width = state->width * 10 + *cPtr - '0';\n-            }\n-            state->sizeSpec = _PR_size_none;\n-            if (*cPtr == 'h') {\n-                cPtr++;\n-                state->sizeSpec = _PR_size_h;\n-            } else if (*cPtr == 'l') {\n-                cPtr++;\n-                if (*cPtr == 'l') {\n-                    cPtr++;\n-                    state->sizeSpec = _PR_size_ll;\n-                } else {\n-                    state->sizeSpec = _PR_size_l;\n-                }\n-            } else if (*cPtr == 'L') {\n-                cPtr++;\n-                state->sizeSpec = _PR_size_L;\n-            }\n-            cPtr = Convert(state, cPtr);\n-            if (cPtr == NULL) {\n-                return (nConverted > 0 ? nConverted : EOF);\n-            }\n-            if (state->converted) {\n-                nConverted++;\n-            }\n-            cPtr++;\n+static PRInt32 DoScanf(ScanfState* state, const char* fmt) {\n+  PRInt32 nConverted = 0;\n+  const char* cPtr;\n+  int ch;\n+\n+  state->nChar = 0;\n+  cPtr = fmt;\n+  while (1) {\n+    if (isspace(*cPtr)) {\n+      /* white space: skip */\n+      do {\n+        cPtr++;\n+      } while (isspace(*cPtr));\n+      do {\n+        ch = GET(state);\n+      } while (isspace(ch));\n+      UNGET(state, ch);\n+    } else if (*cPtr == '%') {\n+      /* format spec: convert */\n+      cPtr++;\n+      state->assign = PR_TRUE;\n+      if (*cPtr == '*') {\n+        cPtr++;\n+        state->assign = PR_FALSE;\n+      }\n+      for (state->width = 0; isdigit(*cPtr); cPtr++) {\n+        state->width = state->width * 10 + *cPtr - '0';\n+      }\n+      state->sizeSpec = _PR_size_none;\n+      if (*cPtr == 'h') {\n+        cPtr++;\n+        state->sizeSpec = _PR_size_h;\n+      } else if (*cPtr == 'l') {\n+        cPtr++;\n+        if (*cPtr == 'l') {\n+          cPtr++;\n+          state->sizeSpec = _PR_size_ll;\n         } else {\n-            /* others: must match */\n-            if (*cPtr == '\\0') {\n-                return nConverted;\n-            }\n-            ch = GET(state);\n-            if (ch != *cPtr) {\n-                UNGET(state, ch);\n-                return nConverted;\n-            }\n-            cPtr++;\n+          state->sizeSpec = _PR_size_l;\n         }\n+      } else if (*cPtr == 'L') {\n+        cPtr++;\n+        state->sizeSpec = _PR_size_L;\n+      }\n+      cPtr = Convert(state, cPtr);\n+      if (cPtr == NULL) {\n+        return (nConverted > 0 ? nConverted : EOF);\n+      }\n+      if (state->converted) {\n+        nConverted++;\n+      }\n+      cPtr++;\n+    } else {\n+      /* others: must match */\n+      if (*cPtr == '\\0') {\n+        return nConverted;\n+      }\n+      ch = GET(state);\n+      if (ch != *cPtr) {\n+        UNGET(state, ch);\n+        return nConverted;\n+      }\n+      cPtr++;\n     }\n+  }\n }\n \n-static int\n-StringGetChar(void* stream)\n-{\n-    char* cPtr = *((char**)stream);\n+static int StringGetChar(void* stream) {\n+  char* cPtr = *((char**)stream);\n \n-    if (*cPtr == '\\0') {\n-        return EOF;\n-    }\n-    *((char**)stream) = cPtr + 1;\n-    return (unsigned char)*cPtr;\n+  if (*cPtr == '\\0') {\n+    return EOF;\n+  }\n+  *((char**)stream) = cPtr + 1;\n+  return (unsigned char)*cPtr;\n }\n \n-static void\n-StringUngetChar(void* stream, int ch)\n-{\n-    char* cPtr = *((char**)stream);\n+static void StringUngetChar(void* stream, int ch) {\n+  char* cPtr = *((char**)stream);\n \n-    if (ch != EOF) {\n-        *((char**)stream) = cPtr - 1;\n-    }\n+  if (ch != EOF) {\n+    *((char**)stream) = cPtr - 1;\n+  }\n }\n \n PR_IMPLEMENT(PRInt32)\n-PR_sscanf(const char* buf, const char* fmt, ...)\n-{\n-    PRInt32 rv;\n-    ScanfState state;\n-\n-    state.get = &StringGetChar;\n-    state.unget = &StringUngetChar;\n-    state.stream = (void*)&buf;\n-    va_start(state.ap, fmt);\n-    rv = DoScanf(&state, fmt);\n-    va_end(state.ap);\n-    return rv;\n+PR_sscanf(const char* buf, const char* fmt, ...) {\n+  PRInt32 rv;\n+  ScanfState state;\n+\n+  state.get = &StringGetChar;\n+  state.unget = &StringUngetChar;\n+  state.stream = (void*)&buf;\n+  va_start(state.ap, fmt);\n+  rv = DoScanf(&state, fmt);\n+  va_end(state.ap);\n+  return rv;\n }\ndiff --git a/nspr/pr/src/io/prsocket.c b/nspr/pr/src/io/prsocket.c\nindex 78f40df..b3a2573 100644\n--- a/nspr/pr/src/io/prsocket.c\n+++ b/nspr/pr/src/io/prsocket.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,9 +8,9 @@\n #include <string.h>\n \n #if defined(_WIN64)\n-#ifndef SO_UPDATE_CONNECT_CONTEXT\n-#define SO_UPDATE_CONNECT_CONTEXT 0x7010\n-#endif\n+#  ifndef SO_UPDATE_CONNECT_CONTEXT\n+#    define SO_UPDATE_CONNECT_CONTEXT 0x7010\n+#  endif\n #endif\n \n /************************************************************************/\n@@ -17,1078 +18,1022 @@\n /* These two functions are only used in assertions. */\n #if defined(DEBUG)\n \n-PRBool\n-IsValidNetAddr(const PRNetAddr* addr)\n-{\n-    if ((addr != NULL)\n-#if defined(XP_UNIX)\n-        && (addr->raw.family != PR_AF_LOCAL)\n-#endif\n-        && (addr->raw.family != PR_AF_INET6) &&\n-        (addr->raw.family != PR_AF_INET)) {\n-        return PR_FALSE;\n-    }\n-    return PR_TRUE;\n+PRBool IsValidNetAddr(const PRNetAddr* addr) {\n+  if ((addr != NULL)\n+#  if defined(XP_UNIX)\n+      && (addr->raw.family != PR_AF_LOCAL)\n+#  endif\n+      && (addr->raw.family != PR_AF_INET6) &&\n+      (addr->raw.family != PR_AF_INET)) {\n+    return PR_FALSE;\n+  }\n+  return PR_TRUE;\n }\n \n-static PRBool\n-IsValidNetAddrLen(const PRNetAddr* addr, PRInt32 addr_len)\n-{\n+static PRBool IsValidNetAddrLen(const PRNetAddr* addr, PRInt32 addr_len) {\n+  /*\n+   * The definition of the length of a Unix domain socket address\n+   * is not uniform, so we don't check it.\n+   */\n+  if ((addr != NULL)\n+#  if defined(XP_UNIX)\n+      && (addr->raw.family != AF_UNIX)\n+#  endif\n+      && (PR_NETADDR_SIZE(addr) != addr_len)) {\n+#  if defined(LINUX) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 1\n     /*\n-     * The definition of the length of a Unix domain socket address\n-     * is not uniform, so we don't check it.\n+     * In glibc 2.1, struct sockaddr_in6 is 24 bytes.  In glibc 2.2\n+     * and in the 2.4 kernel, struct sockaddr_in6 has the scope_id\n+     * field and is 28 bytes.  It is possible for socket functions\n+     * to return an addr_len greater than sizeof(struct sockaddr_in6).\n+     * We need to allow that.  (Bugzilla bug #77264)\n      */\n-    if ((addr != NULL)\n-#if defined(XP_UNIX)\n-        && (addr->raw.family != AF_UNIX)\n-#endif\n-        && (PR_NETADDR_SIZE(addr) != addr_len)) {\n-#if defined(LINUX) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 1\n-        /*\n-         * In glibc 2.1, struct sockaddr_in6 is 24 bytes.  In glibc 2.2\n-         * and in the 2.4 kernel, struct sockaddr_in6 has the scope_id\n-         * field and is 28 bytes.  It is possible for socket functions\n-         * to return an addr_len greater than sizeof(struct sockaddr_in6).\n-         * We need to allow that.  (Bugzilla bug #77264)\n-         */\n-        if ((PR_AF_INET6 == addr->raw.family) && (sizeof(addr->ipv6) == addr_len)) {\n-            return PR_TRUE;\n-        }\n-#endif\n-        /*\n-         * The accept(), getsockname(), etc. calls on some platforms\n-         * do not set the actual socket address length on return.\n-         * In this case, we verifiy addr_len is still the value we\n-         * passed in (i.e., sizeof(PRNetAddr)).\n-         */\n-#if defined(QNX)\n-        if (sizeof(PRNetAddr) == addr_len) {\n-            return PR_TRUE;\n-        }\n-#endif\n-        return PR_FALSE;\n-    }\n-    return PR_TRUE;\n-}\n-\n-#endif /* DEBUG */\n-\n-static PRInt32 PR_CALLBACK\n-SocketWritev(PRFileDesc* fd, const PRIOVec* iov,\n-             PRInt32 iov_size,\n-             PRIntervalTime timeout)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    int w = 0;\n-    const PRIOVec* tmp_iov;\n-#define LOCAL_MAXIOV 8\n-    PRIOVec local_iov[LOCAL_MAXIOV];\n-    PRIOVec* iov_copy = NULL;\n-    int tmp_out;\n-    int index, iov_cnt;\n-    int count = 0, sz = 0; /* 'count' is the return value. */\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n+    if ((PR_AF_INET6 == addr->raw.family) && (sizeof(addr->ipv6) == addr_len)) {\n+      return PR_TRUE;\n     }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        return -1;\n-    }\n-\n+#  endif\n     /*\n-     * Assume the first writev will succeed.  Copy iov's only on\n-     * failure.\n+     * The accept(), getsockname(), etc. calls on some platforms\n+     * do not set the actual socket address length on return.\n+     * In this case, we verifiy addr_len is still the value we\n+     * passed in (i.e., sizeof(PRNetAddr)).\n      */\n-    tmp_iov = iov;\n-    for (index = 0; index < iov_size; index++) {\n-        sz += iov[index].iov_len;\n+#  if defined(QNX)\n+    if (sizeof(PRNetAddr) == addr_len) {\n+      return PR_TRUE;\n     }\n+#  endif\n+    return PR_FALSE;\n+  }\n+  return PR_TRUE;\n+}\n \n-    iov_cnt = iov_size;\n+#endif /* DEBUG */\n \n-    while (sz > 0) {\n-        w = _PR_MD_WRITEV(fd, tmp_iov, iov_cnt, timeout);\n-        if (w < 0) {\n-            count = -1;\n-            break;\n-        }\n-        count += w;\n-        if (fd->secret->nonblocking) {\n-            break;\n+static PRInt32 PR_CALLBACK SocketWritev(PRFileDesc* fd, const PRIOVec* iov,\n+                                        PRInt32 iov_size,\n+                                        PRIntervalTime timeout) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  int w = 0;\n+  const PRIOVec* tmp_iov;\n+#define LOCAL_MAXIOV 8\n+  PRIOVec local_iov[LOCAL_MAXIOV];\n+  PRIOVec* iov_copy = NULL;\n+  int tmp_out;\n+  int index, iov_cnt;\n+  int count = 0, sz = 0; /* 'count' is the return value. */\n+\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    return -1;\n+  }\n+\n+  /*\n+   * Assume the first writev will succeed.  Copy iov's only on\n+   * failure.\n+   */\n+  tmp_iov = iov;\n+  for (index = 0; index < iov_size; index++) {\n+    sz += iov[index].iov_len;\n+  }\n+\n+  iov_cnt = iov_size;\n+\n+  while (sz > 0) {\n+    w = _PR_MD_WRITEV(fd, tmp_iov, iov_cnt, timeout);\n+    if (w < 0) {\n+      count = -1;\n+      break;\n+    }\n+    count += w;\n+    if (fd->secret->nonblocking) {\n+      break;\n+    }\n+    sz -= w;\n+\n+    if (sz > 0) {\n+      /* find the next unwritten vector */\n+      for (index = 0, tmp_out = count; tmp_out >= iov[index].iov_len;\n+           tmp_out -= iov[index].iov_len, index++) {\n+        ;\n+      } /* nothing to execute */\n+\n+      if (tmp_iov == iov) {\n+        /*\n+         * The first writev failed so we\n+         * must copy iov's around.\n+         * Avoid calloc/free if there\n+         * are few enough iov's.\n+         */\n+        if (iov_size - index <= LOCAL_MAXIOV) {\n+          iov_copy = local_iov;\n+        } else if ((iov_copy = (PRIOVec*)PR_CALLOC((iov_size - index) *\n+                                                   sizeof *iov_copy)) == NULL) {\n+          PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+          return -1;\n         }\n-        sz -= w;\n-\n-        if (sz > 0) {\n-            /* find the next unwritten vector */\n-            for (index = 0, tmp_out = count; tmp_out >= iov[index].iov_len;\n-                 tmp_out -= iov[index].iov_len, index++) {\n-                ;\n-            } /* nothing to execute */\n-\n-            if (tmp_iov == iov) {\n-                /*\n-                 * The first writev failed so we\n-                 * must copy iov's around.\n-                 * Avoid calloc/free if there\n-                 * are few enough iov's.\n-                 */\n-                if (iov_size - index <= LOCAL_MAXIOV) {\n-                    iov_copy = local_iov;\n-                } else if ((iov_copy = (PRIOVec*)PR_CALLOC((iov_size - index) *\n-                                                           sizeof *iov_copy)) == NULL) {\n-                    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-                    return -1;\n-                }\n-                tmp_iov = iov_copy;\n-            }\n+        tmp_iov = iov_copy;\n+      }\n \n-            PR_ASSERT(tmp_iov == iov_copy);\n+      PR_ASSERT(tmp_iov == iov_copy);\n \n-            /* fill in the first partial read */\n-            iov_copy[0].iov_base = &(((char*)iov[index].iov_base)[tmp_out]);\n-            iov_copy[0].iov_len = iov[index].iov_len - tmp_out;\n-            index++;\n+      /* fill in the first partial read */\n+      iov_copy[0].iov_base = &(((char*)iov[index].iov_base)[tmp_out]);\n+      iov_copy[0].iov_len = iov[index].iov_len - tmp_out;\n+      index++;\n \n-            /* copy the remaining vectors */\n-            for (iov_cnt = 1; index < iov_size; iov_cnt++, index++) {\n-                iov_copy[iov_cnt].iov_base = iov[index].iov_base;\n-                iov_copy[iov_cnt].iov_len = iov[index].iov_len;\n-            }\n-        }\n+      /* copy the remaining vectors */\n+      for (iov_cnt = 1; index < iov_size; iov_cnt++, index++) {\n+        iov_copy[iov_cnt].iov_base = iov[index].iov_base;\n+        iov_copy[iov_cnt].iov_len = iov[index].iov_len;\n+      }\n     }\n+  }\n \n-    if (iov_copy != local_iov) {\n-        PR_DELETE(iov_copy);\n-    }\n-    return count;\n+  if (iov_copy != local_iov) {\n+    PR_DELETE(iov_copy);\n+  }\n+  return count;\n }\n \n /************************************************************************/\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_ImportTCPSocket(PROsfd osfd)\n-{\n-    PRFileDesc* fd;\n+PR_IMPLEMENT(PRFileDesc*) PR_ImportTCPSocket(PROsfd osfd) {\n+  PRFileDesc* fd;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    fd = PR_AllocFileDesc(osfd, PR_GetTCPMethods());\n-    if (fd != NULL) {\n-        _PR_MD_MAKE_NONBLOCK(fd);\n-        _PR_MD_INIT_FD_INHERITABLE(fd, PR_TRUE);\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  fd = PR_AllocFileDesc(osfd, PR_GetTCPMethods());\n+  if (fd != NULL) {\n+    _PR_MD_MAKE_NONBLOCK(fd);\n+    _PR_MD_INIT_FD_INHERITABLE(fd, PR_TRUE);\n #ifdef _PR_NEED_SECRET_AF\n-        /* this means we can only import IPv4 sockets here.\n-         * but this is what the function in ptio.c does.\n-         * We need a way to import IPv6 sockets, too.\n-         */\n-        fd->secret->af = AF_INET;\n+    /* this means we can only import IPv4 sockets here.\n+     * but this is what the function in ptio.c does.\n+     * We need a way to import IPv6 sockets, too.\n+     */\n+    fd->secret->af = AF_INET;\n #endif\n-    } else {\n-        _PR_MD_CLOSE_SOCKET(osfd);\n-    }\n-    return (fd);\n+  } else {\n+    _PR_MD_CLOSE_SOCKET(osfd);\n+  }\n+  return (fd);\n }\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_ImportUDPSocket(PROsfd osfd)\n-{\n-    PRFileDesc* fd;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    fd = PR_AllocFileDesc(osfd, PR_GetUDPMethods());\n-    if (fd != NULL) {\n-        _PR_MD_MAKE_NONBLOCK(fd);\n-        _PR_MD_INIT_FD_INHERITABLE(fd, PR_TRUE);\n-    } else {\n-        _PR_MD_CLOSE_SOCKET(osfd);\n-    }\n-    return (fd);\n+PR_IMPLEMENT(PRFileDesc*) PR_ImportUDPSocket(PROsfd osfd) {\n+  PRFileDesc* fd;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  fd = PR_AllocFileDesc(osfd, PR_GetUDPMethods());\n+  if (fd != NULL) {\n+    _PR_MD_MAKE_NONBLOCK(fd);\n+    _PR_MD_INIT_FD_INHERITABLE(fd, PR_TRUE);\n+  } else {\n+    _PR_MD_CLOSE_SOCKET(osfd);\n+  }\n+  return (fd);\n }\n \n static const PRIOMethods* PR_GetSocketPollFdMethods(void);\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_CreateSocketPollFd(PROsfd osfd)\n-{\n-    PRFileDesc* fd;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+PR_IMPLEMENT(PRFileDesc*) PR_CreateSocketPollFd(PROsfd osfd) {\n+  PRFileDesc* fd;\n \n-    fd = _PR_Getfd();\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    if (fd == NULL) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-    } else {\n-        fd->secret->md.osfd = osfd;\n-        fd->secret->inheritable = _PR_TRI_FALSE;\n-        fd->secret->state = _PR_FILEDESC_OPEN;\n-        fd->methods = PR_GetSocketPollFdMethods();\n-    }\n+  fd = _PR_Getfd();\n \n-    return fd;\n+  if (fd == NULL) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  } else {\n+    fd->secret->md.osfd = osfd;\n+    fd->secret->inheritable = _PR_TRI_FALSE;\n+    fd->secret->state = _PR_FILEDESC_OPEN;\n+    fd->methods = PR_GetSocketPollFdMethods();\n+  }\n+\n+  return fd;\n } /* PR_CreateSocketPollFD */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_DestroySocketPollFd(PRFileDesc* fd)\n-{\n-    if (NULL == fd) {\n-        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    fd->secret->state = _PR_FILEDESC_CLOSED;\n-    _PR_Putfd(fd);\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_DestroySocketPollFd(PRFileDesc* fd) {\n+  if (NULL == fd) {\n+    PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  fd->secret->state = _PR_FILEDESC_CLOSED;\n+  _PR_Putfd(fd);\n+  return PR_SUCCESS;\n } /* PR_DestroySocketPollFd */\n \n-static PRStatus PR_CALLBACK\n-SocketConnect(PRFileDesc* fd, const PRNetAddr* addr,\n-              PRIntervalTime timeout)\n-{\n-    PRInt32 rv; /* Return value of _PR_MD_CONNECT */\n-    const PRNetAddr* addrp = addr;\n+static PRStatus PR_CALLBACK SocketConnect(PRFileDesc* fd, const PRNetAddr* addr,\n+                                          PRIntervalTime timeout) {\n+  PRInt32 rv; /* Return value of _PR_MD_CONNECT */\n+  const PRNetAddr* addrp = addr;\n #if defined(_PR_INET6)\n-    PRNetAddr addrCopy;\n+  PRNetAddr addrCopy;\n #endif\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n #if defined(_PR_INET6)\n-    if (addr->raw.family == PR_AF_INET6) {\n-        addrCopy = *addr;\n-        addrCopy.raw.family = AF_INET6;\n-        addrp = &addrCopy;\n-    }\n+  if (addr->raw.family == PR_AF_INET6) {\n+    addrCopy = *addr;\n+    addrCopy.raw.family = AF_INET6;\n+    addrp = &addrCopy;\n+  }\n #endif\n \n-    rv = _PR_MD_CONNECT(fd, addrp, PR_NETADDR_SIZE(addr), timeout);\n-    PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"connect -> %d\", rv));\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    } else {\n-        return PR_FAILURE;\n-    }\n+  rv = _PR_MD_CONNECT(fd, addrp, PR_NETADDR_SIZE(addr), timeout);\n+  PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"connect -> %d\", rv));\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  } else {\n+    return PR_FAILURE;\n+  }\n }\n \n-static PRStatus PR_CALLBACK\n-SocketConnectContinue(PRFileDesc* fd,\n-                      PRInt16 out_flags)\n-{\n-    PROsfd osfd;\n-    int err;\n+static PRStatus PR_CALLBACK SocketConnectContinue(PRFileDesc* fd,\n+                                                  PRInt16 out_flags) {\n+  PROsfd osfd;\n+  int err;\n \n-    if (out_flags & PR_POLL_NVAL) {\n-        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    if ((out_flags & (PR_POLL_WRITE | PR_POLL_EXCEPT | PR_POLL_ERR)) == 0) {\n-        PR_ASSERT(out_flags == 0);\n-        PR_SetError(PR_IN_PROGRESS_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (out_flags & PR_POLL_NVAL) {\n+    PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  if ((out_flags & (PR_POLL_WRITE | PR_POLL_EXCEPT | PR_POLL_ERR)) == 0) {\n+    PR_ASSERT(out_flags == 0);\n+    PR_SetError(PR_IN_PROGRESS_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-    osfd = fd->secret->md.osfd;\n+  osfd = fd->secret->md.osfd;\n \n #if defined(XP_UNIX)\n \n-    err = _MD_unix_get_nonblocking_connect_error(osfd);\n-    if (err != 0) {\n-        _PR_MD_MAP_CONNECT_ERROR(err);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  err = _MD_unix_get_nonblocking_connect_error(osfd);\n+  if (err != 0) {\n+    _PR_MD_MAP_CONNECT_ERROR(err);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n \n #elif defined(WIN32)\n \n-    if (out_flags & PR_POLL_EXCEPT) {\n-        int len = sizeof(err);\n-        if (getsockopt(osfd, (int)SOL_SOCKET, SO_ERROR, (char*)&err, &len) ==\n-            SOCKET_ERROR) {\n-            _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n-            return PR_FAILURE;\n-        }\n-        if (err != 0) {\n-            _PR_MD_MAP_CONNECT_ERROR(err);\n-        } else {\n-#if defined(_WIN64)\n-            if (fd->secret->overlappedActive) {\n-                DWORD rvSent;\n-                if (GetOverlappedResult((HANDLE)osfd, &fd->secret->ol, &rvSent,\n-                                        FALSE) == FALSE) {\n-                    err = WSAGetLastError();\n-                    PR_LOG(\n-                        _pr_io_lm, PR_LOG_MIN,\n-                        (\"SocketConnectContinue GetOverlappedResult failed %d\\n\", err));\n-                    if (err != ERROR_IO_INCOMPLETE) {\n-                        _PR_MD_MAP_CONNECT_ERROR(err);\n-                        fd->secret->overlappedActive = PR_FALSE;\n-                    }\n-                }\n-            }\n-            if (err == 0) {\n-                PR_SetError(PR_UNKNOWN_ERROR, 0);\n-            }\n-#else\n-            PR_SetError(PR_UNKNOWN_ERROR, 0);\n-#endif\n-        }\n-        return PR_FAILURE;\n-    }\n-\n-    PR_ASSERT(out_flags & PR_POLL_WRITE);\n-\n-#if defined(_WIN64)\n-    if (fd->secret->alreadyConnected) {\n-        fd->secret->alreadyConnected = PR_FALSE;\n+  if (out_flags & PR_POLL_EXCEPT) {\n+    int len = sizeof(err);\n+    if (getsockopt(osfd, (int)SOL_SOCKET, SO_ERROR, (char*)&err, &len) ==\n+        SOCKET_ERROR) {\n+      _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n+      return PR_FAILURE;\n     }\n-    /* TCP Fast Open on Windows must use ConnectEx, which uses overlapped\n-     * input/output.\n-     * To get result we need to use GetOverlappedResult. */\n-    if (fd->secret->overlappedActive) {\n-        PR_ASSERT(fd->secret->nonblocking);\n-        DWORD rvSent;\n-        if (GetOverlappedResult((HANDLE)osfd, &fd->secret->ol, &rvSent, FALSE) ==\n-            TRUE) {\n+    if (err != 0) {\n+      _PR_MD_MAP_CONNECT_ERROR(err);\n+    } else {\n+#  if defined(_WIN64)\n+      if (fd->secret->overlappedActive) {\n+        PRInt32 rvSent;\n+        if (GetOverlappedResult((HANDLE)osfd, &fd->secret->ol, &rvSent,\n+                                FALSE) == FALSE) {\n+          err = WSAGetLastError();\n+          PR_LOG(\n+              _pr_io_lm, PR_LOG_MIN,\n+              (\"SocketConnectContinue GetOverlappedResult failed %d\\n\", err));\n+          if (err != ERROR_IO_INCOMPLETE) {\n+            _PR_MD_MAP_CONNECT_ERROR(err);\n             fd->secret->overlappedActive = PR_FALSE;\n-            PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-                   (\"SocketConnectContinue GetOverlappedResult succeeded\\n\"));\n-            /* When ConnectEx is used, all previously set socket options and\n-             * property are not enabled and to enable them\n-             * SO_UPDATE_CONNECT_CONTEXT option need to be set. */\n-            if (setsockopt((SOCKET)osfd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL,\n-                           0) != 0) {\n-                err = WSAGetLastError();\n-                PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-                       (\"SocketConnectContinue setting SO_UPDATE_CONNECT_CONTEXT \"\n-                        \"failed %d\\n\",\n-                        err));\n-                _PR_MD_MAP_SETSOCKOPT_ERROR(err);\n-                return PR_FAILURE;\n-            }\n-            return PR_SUCCESS;\n-        } else {\n-            err = WSAGetLastError();\n-            PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-                   (\"SocketConnectContinue GetOverlappedResult failed %d\\n\", err));\n-            if (err != ERROR_IO_INCOMPLETE) {\n-                _PR_MD_MAP_CONNECT_ERROR(err);\n-                fd->secret->overlappedActive = PR_FALSE;\n-                return PR_FAILURE;\n-            } else {\n-                PR_SetError(PR_IN_PROGRESS_ERROR, 0);\n-                return PR_FAILURE;\n-            }\n+          }\n         }\n+      }\n+      if (err == 0) {\n+        PR_SetError(PR_UNKNOWN_ERROR, 0);\n+      }\n+#  else\n+      PR_SetError(PR_UNKNOWN_ERROR, 0);\n+#  endif\n     }\n-#endif\n+    return PR_FAILURE;\n+  }\n+\n+  PR_ASSERT(out_flags & PR_POLL_WRITE);\n+\n+#  if defined(_WIN64)\n+  if (fd->secret->alreadyConnected) {\n+    fd->secret->alreadyConnected = PR_FALSE;\n+  }\n+  /* TCP Fast Open on Windows must use ConnectEx, which uses overlapped\n+   * input/output.\n+   * To get result we need to use GetOverlappedResult. */\n+  if (fd->secret->overlappedActive) {\n+    PR_ASSERT(fd->secret->nonblocking);\n+    PRInt32 rvSent;\n+    if (GetOverlappedResult((HANDLE)osfd, &fd->secret->ol, &rvSent, FALSE) ==\n+        TRUE) {\n+      fd->secret->overlappedActive = PR_FALSE;\n+      PR_LOG(_pr_io_lm, PR_LOG_MIN,\n+             (\"SocketConnectContinue GetOverlappedResult succeeded\\n\"));\n+      /* When ConnectEx is used, all previously set socket options and\n+       * property are not enabled and to enable them\n+       * SO_UPDATE_CONNECT_CONTEXT option need to be set. */\n+      if (setsockopt((SOCKET)osfd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL,\n+                     0) != 0) {\n+        err = WSAGetLastError();\n+        PR_LOG(_pr_io_lm, PR_LOG_MIN,\n+               (\"SocketConnectContinue setting SO_UPDATE_CONNECT_CONTEXT \"\n+                \"failed %d\\n\",\n+                err));\n+        _PR_MD_MAP_SETSOCKOPT_ERROR(err);\n+        return PR_FAILURE;\n+      }\n+      return PR_SUCCESS;\n+    } else {\n+      err = WSAGetLastError();\n+      PR_LOG(_pr_io_lm, PR_LOG_MIN,\n+             (\"SocketConnectContinue GetOverlappedResult failed %d\\n\", err));\n+      if (err != ERROR_IO_INCOMPLETE) {\n+        _PR_MD_MAP_CONNECT_ERROR(err);\n+        fd->secret->overlappedActive = PR_FALSE;\n+        return PR_FAILURE;\n+      } else {\n+        PR_SetError(PR_IN_PROGRESS_ERROR, 0);\n+        return PR_FAILURE;\n+      }\n+    }\n+  }\n+#  endif\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n \n #else\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n #endif\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_GetConnectStatus(const PRPollDesc* pd)\n-{\n-    /* Find the NSPR layer and invoke its connectcontinue method */\n-    PRFileDesc* bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n+PR_IMPLEMENT(PRStatus) PR_GetConnectStatus(const PRPollDesc* pd) {\n+  /* Find the NSPR layer and invoke its connectcontinue method */\n+  PRFileDesc* bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n \n-    if (NULL == bottom) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    return SocketConnectContinue(bottom, pd->out_flags);\n+  if (NULL == bottom) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  return SocketConnectContinue(bottom, pd->out_flags);\n }\n \n-static PRFileDesc* PR_CALLBACK\n-SocketAccept(PRFileDesc* fd, PRNetAddr* addr,\n-             PRIntervalTime timeout)\n-{\n-    PROsfd osfd;\n-    PRFileDesc* fd2;\n-    PRUint32 al;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+static PRFileDesc* PR_CALLBACK SocketAccept(PRFileDesc* fd, PRNetAddr* addr,\n+                                            PRIntervalTime timeout) {\n+  PROsfd osfd;\n+  PRFileDesc* fd2;\n+  PRUint32 al;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n #ifdef WINNT\n-    PRNetAddr addrCopy;\n+  PRNetAddr addrCopy;\n #endif\n \n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return 0;\n-    }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        return 0;\n-    }\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return 0;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    return 0;\n+  }\n \n #ifdef WINNT\n-    if (addr == NULL) {\n-        addr = &addrCopy;\n-    }\n+  if (addr == NULL) {\n+    addr = &addrCopy;\n+  }\n #endif\n-    al = sizeof(PRNetAddr);\n-    osfd = _PR_MD_ACCEPT(fd, addr, &al, timeout);\n-    if (osfd == -1) {\n-        return 0;\n-    }\n+  al = sizeof(PRNetAddr);\n+  osfd = _PR_MD_ACCEPT(fd, addr, &al, timeout);\n+  if (osfd == -1) {\n+    return 0;\n+  }\n \n-    fd2 = PR_AllocFileDesc(osfd, PR_GetTCPMethods());\n-    if (!fd2) {\n-        _PR_MD_CLOSE_SOCKET(osfd);\n-        return NULL;\n-    }\n+  fd2 = PR_AllocFileDesc(osfd, PR_GetTCPMethods());\n+  if (!fd2) {\n+    _PR_MD_CLOSE_SOCKET(osfd);\n+    return NULL;\n+  }\n \n-    fd2->secret->nonblocking = fd->secret->nonblocking;\n-    fd2->secret->inheritable = fd->secret->inheritable;\n+  fd2->secret->nonblocking = fd->secret->nonblocking;\n+  fd2->secret->inheritable = fd->secret->inheritable;\n #ifdef WINNT\n-    if (!fd2->secret->nonblocking && fd2->secret->inheritable != _PR_TRI_TRUE) {\n-        /*\n-         * The new socket has been associated with an I/O\n-         * completion port.  There is no going back.\n-         */\n-        fd2->secret->md.io_model_committed = PR_TRUE;\n-    }\n-    PR_ASSERT(al == PR_NETADDR_SIZE(addr));\n-    fd2->secret->md.accepted_socket = PR_TRUE;\n-    memcpy(&fd2->secret->md.peer_addr, addr, al);\n-#endif\n-\n+  if (!fd2->secret->nonblocking && fd2->secret->inheritable != _PR_TRI_TRUE) {\n     /*\n-     * On some platforms, the new socket created by accept()\n-     * inherits the nonblocking (or overlapped io) attribute\n-     * of the listening socket.  As an optimization, these\n-     * platforms can skip the following _PR_MD_MAKE_NONBLOCK\n-     * call.\n+     * The new socket has been associated with an I/O\n+     * completion port.  There is no going back.\n      */\n+    fd2->secret->md.io_model_committed = PR_TRUE;\n+  }\n+  PR_ASSERT(al == PR_NETADDR_SIZE(addr));\n+  fd2->secret->md.accepted_socket = PR_TRUE;\n+  memcpy(&fd2->secret->md.peer_addr, addr, al);\n+#endif\n+\n+  /*\n+   * On some platforms, the new socket created by accept()\n+   * inherits the nonblocking (or overlapped io) attribute\n+   * of the listening socket.  As an optimization, these\n+   * platforms can skip the following _PR_MD_MAKE_NONBLOCK\n+   * call.\n+   */\n #if !defined(SOLARIS) && !defined(WINNT)\n-    _PR_MD_MAKE_NONBLOCK(fd2);\n+  _PR_MD_MAKE_NONBLOCK(fd2);\n #endif\n \n #ifdef _PR_INET6\n-    if (addr && (AF_INET6 == addr->raw.family)) {\n-        addr->raw.family = PR_AF_INET6;\n-    }\n+  if (addr && (AF_INET6 == addr->raw.family)) {\n+    addr->raw.family = PR_AF_INET6;\n+  }\n #endif\n-    PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n-    PR_ASSERT(IsValidNetAddrLen(addr, al) == PR_TRUE);\n+  PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n+  PR_ASSERT(IsValidNetAddrLen(addr, al) == PR_TRUE);\n \n-    return fd2;\n+  return fd2;\n }\n \n #ifdef WINNT\n PR_IMPLEMENT(PRFileDesc*)\n-PR_NTFast_Accept(PRFileDesc* fd, PRNetAddr* addr, PRIntervalTime timeout)\n-{\n-    PROsfd osfd;\n-    PRFileDesc* fd2;\n-    PRIntn al;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRNetAddr addrCopy;\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return 0;\n-    }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        return 0;\n-    }\n-\n-    if (addr == NULL) {\n-        addr = &addrCopy;\n-    }\n-    al = PR_NETADDR_SIZE(addr);\n-    osfd = _PR_MD_FAST_ACCEPT(fd, addr, &al, timeout, PR_TRUE, NULL, NULL);\n-    if (osfd == -1) {\n-        return 0;\n-    }\n+PR_NTFast_Accept(PRFileDesc* fd, PRNetAddr* addr, PRIntervalTime timeout) {\n+  PROsfd osfd;\n+  PRFileDesc* fd2;\n+  PRIntn al;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRNetAddr addrCopy;\n+\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return 0;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    return 0;\n+  }\n+\n+  if (addr == NULL) {\n+    addr = &addrCopy;\n+  }\n+  al = PR_NETADDR_SIZE(addr);\n+  osfd = _PR_MD_FAST_ACCEPT(fd, addr, &al, timeout, PR_TRUE, NULL, NULL);\n+  if (osfd == -1) {\n+    return 0;\n+  }\n \n-    fd2 = PR_AllocFileDesc(osfd, PR_GetTCPMethods());\n-    if (!fd2) {\n-        _PR_MD_CLOSE_SOCKET(osfd);\n-    } else {\n-        fd2->secret->nonblocking = fd->secret->nonblocking;\n-        fd2->secret->md.io_model_committed = PR_TRUE;\n-        PR_ASSERT(al == PR_NETADDR_SIZE(addr));\n-        fd2->secret->md.accepted_socket = PR_TRUE;\n-        memcpy(&fd2->secret->md.peer_addr, addr, al);\n-#ifdef _PR_INET6\n-        if (AF_INET6 == addr->raw.family) {\n-            addr->raw.family = PR_AF_INET6;\n-        }\n-#endif\n-#ifdef _PR_NEED_SECRET_AF\n-        fd2->secret->af = fd->secret->af;\n-#endif\n-    }\n-    return fd2;\n+  fd2 = PR_AllocFileDesc(osfd, PR_GetTCPMethods());\n+  if (!fd2) {\n+    _PR_MD_CLOSE_SOCKET(osfd);\n+  } else {\n+    fd2->secret->nonblocking = fd->secret->nonblocking;\n+    fd2->secret->md.io_model_committed = PR_TRUE;\n+    PR_ASSERT(al == PR_NETADDR_SIZE(addr));\n+    fd2->secret->md.accepted_socket = PR_TRUE;\n+    memcpy(&fd2->secret->md.peer_addr, addr, al);\n+#  ifdef _PR_INET6\n+    if (AF_INET6 == addr->raw.family) {\n+      addr->raw.family = PR_AF_INET6;\n+    }\n+#  endif\n+#  ifdef _PR_NEED_SECRET_AF\n+    fd2->secret->af = fd->secret->af;\n+#  endif\n+  }\n+  return fd2;\n }\n #endif /* WINNT */\n \n-static PRStatus PR_CALLBACK\n-SocketBind(PRFileDesc* fd, const PRNetAddr* addr)\n-{\n-    PRInt32 result;\n-    const PRNetAddr* addrp = addr;\n+static PRStatus PR_CALLBACK SocketBind(PRFileDesc* fd, const PRNetAddr* addr) {\n+  PRInt32 result;\n+  const PRNetAddr* addrp = addr;\n #if defined(_PR_INET6)\n-    PRNetAddr addrCopy;\n+  PRNetAddr addrCopy;\n #endif\n \n-    PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n+  PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n \n #ifdef XP_UNIX\n-    if (addr->raw.family == AF_UNIX) {\n-        /* Disallow relative pathnames */\n-        if (addr->local.path[0] != '/') {\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            return PR_FAILURE;\n-        }\n+  if (addr->raw.family == AF_UNIX) {\n+    /* Disallow relative pathnames */\n+    if (addr->local.path[0] != '/') {\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      return PR_FAILURE;\n     }\n+  }\n #endif /* XP_UNIX */\n \n #if defined(_PR_INET6)\n-    if (addr->raw.family == PR_AF_INET6) {\n-        addrCopy = *addr;\n-        addrCopy.raw.family = AF_INET6;\n-        addrp = &addrCopy;\n-    }\n+  if (addr->raw.family == PR_AF_INET6) {\n+    addrCopy = *addr;\n+    addrCopy.raw.family = AF_INET6;\n+    addrp = &addrCopy;\n+  }\n #endif\n-    result = _PR_MD_BIND(fd, addrp, PR_NETADDR_SIZE(addr));\n-    if (result < 0) {\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  result = _PR_MD_BIND(fd, addrp, PR_NETADDR_SIZE(addr));\n+  if (result < 0) {\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-static PRStatus PR_CALLBACK\n-SocketListen(PRFileDesc* fd, PRIntn backlog)\n-{\n-    PRInt32 result;\n+static PRStatus PR_CALLBACK SocketListen(PRFileDesc* fd, PRIntn backlog) {\n+  PRInt32 result;\n \n-    result = _PR_MD_LISTEN(fd, backlog);\n-    if (result < 0) {\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  result = _PR_MD_LISTEN(fd, backlog);\n+  if (result < 0) {\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-static PRStatus PR_CALLBACK\n-SocketShutdown(PRFileDesc* fd, PRIntn how)\n-{\n-    PRInt32 result;\n+static PRStatus PR_CALLBACK SocketShutdown(PRFileDesc* fd, PRIntn how) {\n+  PRInt32 result;\n \n-    result = _PR_MD_SHUTDOWN(fd, how);\n-    if (result < 0) {\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  result = _PR_MD_SHUTDOWN(fd, how);\n+  if (result < 0) {\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-static PRInt32 PR_CALLBACK\n-SocketRecv(PRFileDesc* fd, void* buf, PRInt32 amount,\n-           PRIntn flags, PRIntervalTime timeout)\n-{\n-    PRInt32 rv;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+static PRInt32 PR_CALLBACK SocketRecv(PRFileDesc* fd, void* buf, PRInt32 amount,\n+                                      PRIntn flags, PRIntervalTime timeout) {\n+  PRInt32 rv;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    if ((flags != 0) && (flags != PR_MSG_PEEK)) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return -1;\n-    }\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n-    }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        return -1;\n-    }\n+  if ((flags != 0) && (flags != PR_MSG_PEEK)) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return -1;\n+  }\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    return -1;\n+  }\n \n-    PR_LOG(_pr_io_lm, PR_LOG_MAX,\n-           (\"recv: fd=%p osfd=%\" PR_PRIdOSFD \" buf=%p amount=%d flags=%d\", fd,\n-            fd->secret->md.osfd, buf, amount, flags));\n+  PR_LOG(_pr_io_lm, PR_LOG_MAX,\n+         (\"recv: fd=%p osfd=%\" PR_PRIdOSFD \" buf=%p amount=%d flags=%d\", fd,\n+          fd->secret->md.osfd, buf, amount, flags));\n \n #ifdef _PR_HAVE_PEEK_BUFFER\n-    if (fd->secret->peekBytes != 0) {\n-        rv = (amount < fd->secret->peekBytes) ? amount : fd->secret->peekBytes;\n-        memcpy(buf, fd->secret->peekBuffer, rv);\n-        if (flags == 0) {\n-            /* consume the bytes in the peek buffer */\n-            fd->secret->peekBytes -= rv;\n-            if (fd->secret->peekBytes != 0) {\n-                memmove(fd->secret->peekBuffer, fd->secret->peekBuffer + rv,\n-                        fd->secret->peekBytes);\n-            }\n-        }\n-        return rv;\n+  if (fd->secret->peekBytes != 0) {\n+    rv = (amount < fd->secret->peekBytes) ? amount : fd->secret->peekBytes;\n+    memcpy(buf, fd->secret->peekBuffer, rv);\n+    if (flags == 0) {\n+      /* consume the bytes in the peek buffer */\n+      fd->secret->peekBytes -= rv;\n+      if (fd->secret->peekBytes != 0) {\n+        memmove(fd->secret->peekBuffer, fd->secret->peekBuffer + rv,\n+                fd->secret->peekBytes);\n+      }\n     }\n-\n-    /* allocate peek buffer, if necessary */\n-    if ((PR_MSG_PEEK == flags) && _PR_FD_NEED_EMULATE_MSG_PEEK(fd)) {\n-        PR_ASSERT(0 == fd->secret->peekBytes);\n-        /* impose a max size on the peek buffer */\n-        if (amount > _PR_PEEK_BUFFER_MAX) {\n-            amount = _PR_PEEK_BUFFER_MAX;\n-        }\n-        if (fd->secret->peekBufSize < amount) {\n-            if (fd->secret->peekBuffer) {\n-                PR_Free(fd->secret->peekBuffer);\n-            }\n-            fd->secret->peekBufSize = amount;\n-            fd->secret->peekBuffer = PR_Malloc(amount);\n-            if (NULL == fd->secret->peekBuffer) {\n-                fd->secret->peekBufSize = 0;\n-                PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-                return -1;\n-            }\n-        }\n+    return rv;\n+  }\n+\n+  /* allocate peek buffer, if necessary */\n+  if ((PR_MSG_PEEK == flags) && _PR_FD_NEED_EMULATE_MSG_PEEK(fd)) {\n+    PR_ASSERT(0 == fd->secret->peekBytes);\n+    /* impose a max size on the peek buffer */\n+    if (amount > _PR_PEEK_BUFFER_MAX) {\n+      amount = _PR_PEEK_BUFFER_MAX;\n+    }\n+    if (fd->secret->peekBufSize < amount) {\n+      if (fd->secret->peekBuffer) {\n+        PR_Free(fd->secret->peekBuffer);\n+      }\n+      fd->secret->peekBufSize = amount;\n+      fd->secret->peekBuffer = PR_Malloc(amount);\n+      if (NULL == fd->secret->peekBuffer) {\n+        fd->secret->peekBufSize = 0;\n+        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+        return -1;\n+      }\n     }\n+  }\n #endif\n \n-    rv = _PR_MD_RECV(fd, buf, amount, flags, timeout);\n-    PR_LOG(_pr_io_lm, PR_LOG_MAX,\n-           (\"recv -> %d, error = %d, os error = %d\", rv, PR_GetError(),\n-            PR_GetOSError()));\n+  rv = _PR_MD_RECV(fd, buf, amount, flags, timeout);\n+  PR_LOG(_pr_io_lm, PR_LOG_MAX,\n+         (\"recv -> %d, error = %d, os error = %d\", rv, PR_GetError(),\n+          PR_GetOSError()));\n \n #ifdef _PR_HAVE_PEEK_BUFFER\n-    if ((PR_MSG_PEEK == flags) && _PR_FD_NEED_EMULATE_MSG_PEEK(fd)) {\n-        if (rv > 0) {\n-            memcpy(fd->secret->peekBuffer, buf, rv);\n-            fd->secret->peekBytes = rv;\n-        }\n+  if ((PR_MSG_PEEK == flags) && _PR_FD_NEED_EMULATE_MSG_PEEK(fd)) {\n+    if (rv > 0) {\n+      memcpy(fd->secret->peekBuffer, buf, rv);\n+      fd->secret->peekBytes = rv;\n     }\n+  }\n #endif\n \n-    return rv;\n+  return rv;\n }\n \n-static PRInt32 PR_CALLBACK\n-SocketRead(PRFileDesc* fd, void* buf,\n-           PRInt32 amount)\n-{\n-    return SocketRecv(fd, buf, amount, 0, PR_INTERVAL_NO_TIMEOUT);\n+static PRInt32 PR_CALLBACK SocketRead(PRFileDesc* fd, void* buf,\n+                                      PRInt32 amount) {\n+  return SocketRecv(fd, buf, amount, 0, PR_INTERVAL_NO_TIMEOUT);\n }\n \n-static PRInt32 PR_CALLBACK\n-SocketSend(PRFileDesc* fd, const void* buf,\n-           PRInt32 amount, PRIntn flags,\n-           PRIntervalTime timeout)\n-{\n-    PRInt32 temp, count;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n-    }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        return -1;\n-    }\n+static PRInt32 PR_CALLBACK SocketSend(PRFileDesc* fd, const void* buf,\n+                                      PRInt32 amount, PRIntn flags,\n+                                      PRIntervalTime timeout) {\n+  PRInt32 temp, count;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    count = 0;\n-    while (amount > 0) {\n-        PR_LOG(_pr_io_lm, PR_LOG_MAX,\n-               (\"send: fd=%p osfd=%\" PR_PRIdOSFD \" buf=%p amount=%d\", fd,\n-                fd->secret->md.osfd, buf, amount));\n-        temp = _PR_MD_SEND(fd, buf, amount, flags, timeout);\n-        if (temp < 0) {\n-            count = -1;\n-            break;\n-        }\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    return -1;\n+  }\n \n-        count += temp;\n-        if (fd->secret->nonblocking) {\n-            break;\n-        }\n-        buf = (const void*)((const char*)buf + temp);\n+  count = 0;\n+  while (amount > 0) {\n+    PR_LOG(_pr_io_lm, PR_LOG_MAX,\n+           (\"send: fd=%p osfd=%\" PR_PRIdOSFD \" buf=%p amount=%d\", fd,\n+            fd->secret->md.osfd, buf, amount));\n+    temp = _PR_MD_SEND(fd, buf, amount, flags, timeout);\n+    if (temp < 0) {\n+      count = -1;\n+      break;\n+    }\n \n-        amount -= temp;\n+    count += temp;\n+    if (fd->secret->nonblocking) {\n+      break;\n     }\n-    PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"send -> %d\", count));\n-    return count;\n+    buf = (const void*)((const char*)buf + temp);\n+\n+    amount -= temp;\n+  }\n+  PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"send -> %d\", count));\n+  return count;\n }\n \n-static PRInt32 PR_CALLBACK\n-SocketWrite(PRFileDesc* fd, const void* buf,\n-            PRInt32 amount)\n-{\n-    return SocketSend(fd, buf, amount, 0, PR_INTERVAL_NO_TIMEOUT);\n+static PRInt32 PR_CALLBACK SocketWrite(PRFileDesc* fd, const void* buf,\n+                                       PRInt32 amount) {\n+  return SocketSend(fd, buf, amount, 0, PR_INTERVAL_NO_TIMEOUT);\n }\n \n-static PRStatus PR_CALLBACK\n-SocketClose(PRFileDesc* fd)\n-{\n-    if (!fd || !fd->secret ||\n-        (fd->secret->state != _PR_FILEDESC_OPEN &&\n-         fd->secret->state != _PR_FILEDESC_CLOSED)) {\n-        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+static PRStatus PR_CALLBACK SocketClose(PRFileDesc* fd) {\n+  if (!fd || !fd->secret ||\n+      (fd->secret->state != _PR_FILEDESC_OPEN &&\n+       fd->secret->state != _PR_FILEDESC_CLOSED)) {\n+    PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-    if (fd->secret->state == _PR_FILEDESC_OPEN) {\n+  if (fd->secret->state == _PR_FILEDESC_OPEN) {\n #if defined(_WIN64) && defined(WIN95)\n-        /* TCP Fast Open on Windows must use ConnectEx, which uses overlapped\n-         * input/output. Before closing such a socket we must cancelIO.\n-         */\n-        if (fd->secret->overlappedActive) {\n-            PR_ASSERT(fd->secret->nonblocking);\n-            if (CancelIo((HANDLE)fd->secret->md.osfd) == TRUE) {\n-                PR_LOG(_pr_io_lm, PR_LOG_MIN, (\"SocketClose - CancelIo succeeded\\n\"));\n-            } else {\n-                DWORD err = WSAGetLastError();\n-                PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-                       (\"SocketClose - CancelIo failed err=%x\\n\", err));\n-            }\n-\n-            DWORD rvSent;\n-            if (GetOverlappedResult((HANDLE)fd->secret->md.osfd, &fd->secret->ol,\n-                                    &rvSent, FALSE) == TRUE) {\n-                fd->secret->overlappedActive = PR_FALSE;\n-                PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-                       (\"SocketClose GetOverlappedResult succeeded\\n\"));\n-            } else {\n-                DWORD err = WSAGetLastError();\n-                PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-                       (\"SocketClose GetOverlappedResult failed %d\\n\", err));\n-                if (err != ERROR_IO_INCOMPLETE) {\n-                    _PR_MD_MAP_CONNECT_ERROR(err);\n-                    fd->secret->overlappedActive = PR_FALSE;\n-                }\n-            }\n+    /* TCP Fast Open on Windows must use ConnectEx, which uses overlapped\n+     * input/output. Before closing such a socket we must cancelIO.\n+     */\n+    if (fd->secret->overlappedActive) {\n+      PR_ASSERT(fd->secret->nonblocking);\n+      if (CancelIo((HANDLE)fd->secret->md.osfd) == TRUE) {\n+        PR_LOG(_pr_io_lm, PR_LOG_MIN, (\"SocketClose - CancelIo succeeded\\n\"));\n+      } else {\n+        DWORD err = WSAGetLastError();\n+        PR_LOG(_pr_io_lm, PR_LOG_MIN,\n+               (\"SocketClose - CancelIo failed err=%x\\n\", err));\n+      }\n+\n+      DWORD rvSent;\n+      if (GetOverlappedResult((HANDLE)fd->secret->md.osfd, &fd->secret->ol,\n+                              &rvSent, FALSE) == TRUE) {\n+        fd->secret->overlappedActive = PR_FALSE;\n+        PR_LOG(_pr_io_lm, PR_LOG_MIN,\n+               (\"SocketClose GetOverlappedResult succeeded\\n\"));\n+      } else {\n+        DWORD err = WSAGetLastError();\n+        PR_LOG(_pr_io_lm, PR_LOG_MIN,\n+               (\"SocketClose GetOverlappedResult failed %d\\n\", err));\n+        if (err != ERROR_IO_INCOMPLETE) {\n+          _PR_MD_MAP_CONNECT_ERROR(err);\n+          fd->secret->overlappedActive = PR_FALSE;\n         }\n+      }\n+    }\n \n-        if (fd->secret->overlappedActive && _fd_waiting_for_overlapped_done_lock) {\n-            // Put osfd into the list to be checked later.\n-            PRFileDescList* forWaiting = PR_NEW(PRFileDescList);\n-            if (!forWaiting) {\n-                PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-                return PR_FAILURE;\n-            }\n-            forWaiting->fd = fd;\n+    if (fd->secret->overlappedActive && _fd_waiting_for_overlapped_done_lock) {\n+      // Put osfd into the list to be checked later.\n+      PRFileDescList* forWaiting = PR_NEW(PRFileDescList);\n+      if (!forWaiting) {\n+        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+        return PR_FAILURE;\n+      }\n+      forWaiting->fd = fd;\n \n-            PR_Lock(_fd_waiting_for_overlapped_done_lock);\n-            forWaiting->next = _fd_waiting_for_overlapped_done;\n-            _fd_waiting_for_overlapped_done = forWaiting;\n-            PR_Unlock(_fd_waiting_for_overlapped_done_lock);\n+      PR_Lock(_fd_waiting_for_overlapped_done_lock);\n+      forWaiting->next = _fd_waiting_for_overlapped_done;\n+      _fd_waiting_for_overlapped_done = forWaiting;\n+      PR_Unlock(_fd_waiting_for_overlapped_done_lock);\n \n-            return PR_SUCCESS;\n-        }\n+      return PR_SUCCESS;\n+    }\n #endif\n \n-        if (_PR_MD_CLOSE_SOCKET(fd->secret->md.osfd) < 0) {\n-            return PR_FAILURE;\n-        }\n-        fd->secret->state = _PR_FILEDESC_CLOSED;\n+    if (_PR_MD_CLOSE_SOCKET(fd->secret->md.osfd) < 0) {\n+      return PR_FAILURE;\n     }\n+    fd->secret->state = _PR_FILEDESC_CLOSED;\n+  }\n \n #ifdef _PR_HAVE_PEEK_BUFFER\n-    if (fd->secret->peekBuffer) {\n-        PR_ASSERT(fd->secret->peekBufSize > 0);\n-        PR_DELETE(fd->secret->peekBuffer);\n-        fd->secret->peekBufSize = 0;\n-        fd->secret->peekBytes = 0;\n-    }\n+  if (fd->secret->peekBuffer) {\n+    PR_ASSERT(fd->secret->peekBufSize > 0);\n+    PR_DELETE(fd->secret->peekBuffer);\n+    fd->secret->peekBufSize = 0;\n+    fd->secret->peekBytes = 0;\n+  }\n #endif\n \n-    PR_FreeFileDesc(fd);\n-    return PR_SUCCESS;\n+  PR_FreeFileDesc(fd);\n+  return PR_SUCCESS;\n }\n \n-static PRInt32 PR_CALLBACK\n-SocketAvailable(PRFileDesc* fd)\n-{\n-    PRInt32 rv;\n+static PRInt32 PR_CALLBACK SocketAvailable(PRFileDesc* fd) {\n+  PRInt32 rv;\n #ifdef _PR_HAVE_PEEK_BUFFER\n-    if (fd->secret->peekBytes != 0) {\n-        return fd->secret->peekBytes;\n-    }\n+  if (fd->secret->peekBytes != 0) {\n+    return fd->secret->peekBytes;\n+  }\n #endif\n-    rv = _PR_MD_SOCKETAVAILABLE(fd);\n-    return rv;\n+  rv = _PR_MD_SOCKETAVAILABLE(fd);\n+  return rv;\n }\n \n-static PRInt64 PR_CALLBACK\n-SocketAvailable64(PRFileDesc* fd)\n-{\n-    PRInt64 rv;\n+static PRInt64 PR_CALLBACK SocketAvailable64(PRFileDesc* fd) {\n+  PRInt64 rv;\n #ifdef _PR_HAVE_PEEK_BUFFER\n-    if (fd->secret->peekBytes != 0) {\n-        LL_I2L(rv, fd->secret->peekBytes);\n-        return rv;\n-    }\n-#endif\n-    LL_I2L(rv, _PR_MD_SOCKETAVAILABLE(fd));\n+  if (fd->secret->peekBytes != 0) {\n+    LL_I2L(rv, fd->secret->peekBytes);\n     return rv;\n+  }\n+#endif\n+  LL_I2L(rv, _PR_MD_SOCKETAVAILABLE(fd));\n+  return rv;\n }\n \n-static PRStatus PR_CALLBACK\n-SocketSync(PRFileDesc* fd)\n-{\n-    return PR_SUCCESS;\n-}\n+static PRStatus PR_CALLBACK SocketSync(PRFileDesc* fd) { return PR_SUCCESS; }\n \n-static PRInt32 PR_CALLBACK\n-SocketSendTo(PRFileDesc* fd, const void* buf,\n-             PRInt32 amount, PRIntn flags,\n-             const PRNetAddr* addr,\n-             PRIntervalTime timeout)\n-{\n-    PRInt32 temp, count;\n-    const PRNetAddr* addrp = addr;\n+static PRInt32 PR_CALLBACK SocketSendTo(PRFileDesc* fd, const void* buf,\n+                                        PRInt32 amount, PRIntn flags,\n+                                        const PRNetAddr* addr,\n+                                        PRIntervalTime timeout) {\n+  PRInt32 temp, count;\n+  const PRNetAddr* addrp = addr;\n #if defined(_PR_INET6)\n-    PRNetAddr addrCopy;\n+  PRNetAddr addrCopy;\n #endif\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n-    }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        return -1;\n-    }\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    return -1;\n+  }\n \n-    PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n+  PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n #if defined(_PR_INET6)\n-    if (addr->raw.family == PR_AF_INET6) {\n-        addrCopy = *addr;\n-        addrCopy.raw.family = AF_INET6;\n-        addrp = &addrCopy;\n-    }\n+  if (addr->raw.family == PR_AF_INET6) {\n+    addrCopy = *addr;\n+    addrCopy.raw.family = AF_INET6;\n+    addrp = &addrCopy;\n+  }\n #endif\n \n-    count = 0;\n-    do {\n-        temp = _PR_MD_SENDTO(fd, buf, amount, flags, addrp, PR_NETADDR_SIZE(addr),\n-                             timeout);\n-        if (temp < 0) {\n-            count = -1;\n-            break;\n-        }\n-        count += temp;\n-        if (fd->secret->nonblocking) {\n-            break;\n-        }\n-        buf = (const void*)((const char*)buf + temp);\n-        amount -= temp;\n-    } while (amount > 0);\n-    return count;\n+  count = 0;\n+  do {\n+    temp = _PR_MD_SENDTO(fd, buf, amount, flags, addrp, PR_NETADDR_SIZE(addr),\n+                         timeout);\n+    if (temp < 0) {\n+      count = -1;\n+      break;\n+    }\n+    count += temp;\n+    if (fd->secret->nonblocking) {\n+      break;\n+    }\n+    buf = (const void*)((const char*)buf + temp);\n+    amount -= temp;\n+  } while (amount > 0);\n+  return count;\n }\n \n #if defined(_WIN64) && defined(WIN95)\n-static PRInt32 PR_CALLBACK\n-SocketTCPSendTo(PRFileDesc* fd, const void* buf,\n-                PRInt32 amount, PRIntn flags,\n-                const PRNetAddr* addr,\n-                PRIntervalTime timeout)\n-{\n-    PRInt32 temp, count;\n-    const PRNetAddr* addrp = addr;\n-#if defined(_PR_INET6)\n-    PRNetAddr addrCopy;\n-#endif\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n-    }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        return -1;\n-    }\n-\n-    PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n-#if defined(_PR_INET6)\n-    if (addr->raw.family == PR_AF_INET6) {\n-        addrCopy = *addr;\n-        addrCopy.raw.family = AF_INET6;\n-        addrp = &addrCopy;\n-    }\n-#endif\n-\n-    count = 0;\n-    while (amount > 0) {\n-        temp = _PR_MD_TCPSENDTO(fd, buf, amount, flags, addrp,\n-                                PR_NETADDR_SIZE(addr), timeout);\n-        if (temp < 0) {\n-            count = -1;\n-            break;\n-        }\n-        count += temp;\n-        if (fd->secret->nonblocking) {\n-            break;\n-        }\n-        buf = (const void*)((const char*)buf + temp);\n-        amount -= temp;\n-    }\n-    return count;\n+static PRInt32 PR_CALLBACK SocketTCPSendTo(PRFileDesc* fd, const void* buf,\n+                                           PRInt32 amount, PRIntn flags,\n+                                           const PRNetAddr* addr,\n+                                           PRIntervalTime timeout) {\n+  PRInt32 temp, count;\n+  const PRNetAddr* addrp = addr;\n+#  if defined(_PR_INET6)\n+  PRNetAddr addrCopy;\n+#  endif\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    return -1;\n+  }\n+\n+  PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n+#  if defined(_PR_INET6)\n+  if (addr->raw.family == PR_AF_INET6) {\n+    addrCopy = *addr;\n+    addrCopy.raw.family = AF_INET6;\n+    addrp = &addrCopy;\n+  }\n+#  endif\n+\n+  count = 0;\n+  while (amount > 0) {\n+    temp = _PR_MD_TCPSENDTO(fd, buf, amount, flags, addrp,\n+                            PR_NETADDR_SIZE(addr), timeout);\n+    if (temp < 0) {\n+      count = -1;\n+      break;\n+    }\n+    count += temp;\n+    if (fd->secret->nonblocking) {\n+      break;\n+    }\n+    buf = (const void*)((const char*)buf + temp);\n+    amount -= temp;\n+  }\n+  return count;\n }\n #endif\n \n-static PRInt32 PR_CALLBACK\n-SocketRecvFrom(PRFileDesc* fd, void* buf,\n-               PRInt32 amount, PRIntn flags,\n-               PRNetAddr* addr,\n-               PRIntervalTime timeout)\n-{\n-    PRInt32 rv;\n-    PRUint32 al;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n-    }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        return -1;\n-    }\n+static PRInt32 PR_CALLBACK SocketRecvFrom(PRFileDesc* fd, void* buf,\n+                                          PRInt32 amount, PRIntn flags,\n+                                          PRNetAddr* addr,\n+                                          PRIntervalTime timeout) {\n+  PRInt32 rv;\n+  PRUint32 al;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    return -1;\n+  }\n \n-    al = sizeof(PRNetAddr);\n-    rv = _PR_MD_RECVFROM(fd, buf, amount, flags, addr, &al, timeout);\n+  al = sizeof(PRNetAddr);\n+  rv = _PR_MD_RECVFROM(fd, buf, amount, flags, addr, &al, timeout);\n #ifdef _PR_INET6\n-    if (addr && (AF_INET6 == addr->raw.family)) {\n-        addr->raw.family = PR_AF_INET6;\n-    }\n+  if (addr && (AF_INET6 == addr->raw.family)) {\n+    addr->raw.family = PR_AF_INET6;\n+  }\n #endif\n-    return rv;\n+  return rv;\n }\n \n-static PRInt32 PR_CALLBACK\n-SocketAcceptRead(PRFileDesc* sd, PRFileDesc** nd,\n-                 PRNetAddr** raddr, void* buf,\n-                 PRInt32 amount,\n-                 PRIntervalTime timeout)\n-{\n-    PRInt32 rv;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n-    }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        return -1;\n-    }\n-    /* The socket must be in blocking mode. */\n-    if (sd->secret->nonblocking) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return -1;\n-    }\n-    *nd = NULL;\n+static PRInt32 PR_CALLBACK SocketAcceptRead(PRFileDesc* sd, PRFileDesc** nd,\n+                                            PRNetAddr** raddr, void* buf,\n+                                            PRInt32 amount,\n+                                            PRIntervalTime timeout) {\n+  PRInt32 rv;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    return -1;\n+  }\n+  /* The socket must be in blocking mode. */\n+  if (sd->secret->nonblocking) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return -1;\n+  }\n+  *nd = NULL;\n \n #if defined(WINNT)\n-    {\n-        PROsfd newSock;\n-        PRNetAddr* raddrCopy;\n+  {\n+    PROsfd newSock;\n+    PRNetAddr* raddrCopy;\n \n-        if (raddr == NULL) {\n-            raddr = &raddrCopy;\n-        }\n-        rv = _PR_MD_ACCEPT_READ(sd, &newSock, raddr, buf, amount, timeout);\n-        if (rv < 0) {\n-            rv = -1;\n-        } else {\n-            /* Successfully accepted and read; create the new PRFileDesc */\n-            *nd = PR_AllocFileDesc(newSock, PR_GetTCPMethods());\n-            if (*nd == 0) {\n-                _PR_MD_CLOSE_SOCKET(newSock);\n-                /* PR_AllocFileDesc() has invoked PR_SetError(). */\n-                rv = -1;\n-            } else {\n-                (*nd)->secret->md.io_model_committed = PR_TRUE;\n-                (*nd)->secret->md.accepted_socket = PR_TRUE;\n-                memcpy(&(*nd)->secret->md.peer_addr, *raddr, PR_NETADDR_SIZE(*raddr));\n-#ifdef _PR_INET6\n-                if (AF_INET6 == *raddr->raw.family) {\n-                    *raddr->raw.family = PR_AF_INET6;\n-                }\n-#endif\n-            }\n+    if (raddr == NULL) {\n+      raddr = &raddrCopy;\n+    }\n+    rv = _PR_MD_ACCEPT_READ(sd, &newSock, raddr, buf, amount, timeout);\n+    if (rv < 0) {\n+      rv = -1;\n+    } else {\n+      /* Successfully accepted and read; create the new PRFileDesc */\n+      *nd = PR_AllocFileDesc(newSock, PR_GetTCPMethods());\n+      if (*nd == 0) {\n+        _PR_MD_CLOSE_SOCKET(newSock);\n+        /* PR_AllocFileDesc() has invoked PR_SetError(). */\n+        rv = -1;\n+      } else {\n+        (*nd)->secret->md.io_model_committed = PR_TRUE;\n+        (*nd)->secret->md.accepted_socket = PR_TRUE;\n+        memcpy(&(*nd)->secret->md.peer_addr, *raddr, PR_NETADDR_SIZE(*raddr));\n+#  ifdef _PR_INET6\n+        if (AF_INET6 == *raddr->raw.family) {\n+          *raddr->raw.family = PR_AF_INET6;\n         }\n+#  endif\n+      }\n     }\n+  }\n #else\n-    rv = PR_EmulateAcceptRead(sd, nd, raddr, buf, amount, timeout);\n+  rv = PR_EmulateAcceptRead(sd, nd, raddr, buf, amount, timeout);\n #endif\n-    return rv;\n+  return rv;\n }\n \n #ifdef WINNT\n PR_IMPLEMENT(PRInt32)\n PR_NTFast_AcceptRead(PRFileDesc* sd, PRFileDesc** nd, PRNetAddr** raddr,\n-                     void* buf, PRInt32 amount, PRIntervalTime timeout)\n-{\n-    PRInt32 rv;\n-    PROsfd newSock;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRNetAddr* raddrCopy;\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n-    }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        return -1;\n-    }\n-    *nd = NULL;\n-\n-    if (raddr == NULL) {\n-        raddr = &raddrCopy;\n-    }\n-    rv = _PR_MD_FAST_ACCEPT_READ(sd, &newSock, raddr, buf, amount, timeout,\n-                                 PR_TRUE, NULL, NULL);\n-    if (rv < 0) {\n-        rv = -1;\n+                     void* buf, PRInt32 amount, PRIntervalTime timeout) {\n+  PRInt32 rv;\n+  PROsfd newSock;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRNetAddr* raddrCopy;\n+\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    return -1;\n+  }\n+  *nd = NULL;\n+\n+  if (raddr == NULL) {\n+    raddr = &raddrCopy;\n+  }\n+  rv = _PR_MD_FAST_ACCEPT_READ(sd, &newSock, raddr, buf, amount, timeout,\n+                               PR_TRUE, NULL, NULL);\n+  if (rv < 0) {\n+    rv = -1;\n+  } else {\n+    /* Successfully accepted and read; create the new PRFileDesc */\n+    *nd = PR_AllocFileDesc(newSock, PR_GetTCPMethods());\n+    if (*nd == 0) {\n+      _PR_MD_CLOSE_SOCKET(newSock);\n+      /* PR_AllocFileDesc() has invoked PR_SetError(). */\n+      rv = -1;\n     } else {\n-        /* Successfully accepted and read; create the new PRFileDesc */\n-        *nd = PR_AllocFileDesc(newSock, PR_GetTCPMethods());\n-        if (*nd == 0) {\n-            _PR_MD_CLOSE_SOCKET(newSock);\n-            /* PR_AllocFileDesc() has invoked PR_SetError(). */\n-            rv = -1;\n-        } else {\n-            (*nd)->secret->md.io_model_committed = PR_TRUE;\n-            (*nd)->secret->md.accepted_socket = PR_TRUE;\n-            memcpy(&(*nd)->secret->md.peer_addr, *raddr, PR_NETADDR_SIZE(*raddr));\n-#ifdef _PR_INET6\n-            if (AF_INET6 == *raddr->raw.family) {\n-                *raddr->raw.family = PR_AF_INET6;\n-            }\n-#endif\n-#ifdef _PR_NEED_SECRET_AF\n-            (*nd)->secret->af = sd->secret->af;\n-#endif\n-        }\n-    }\n-    return rv;\n+      (*nd)->secret->md.io_model_committed = PR_TRUE;\n+      (*nd)->secret->md.accepted_socket = PR_TRUE;\n+      memcpy(&(*nd)->secret->md.peer_addr, *raddr, PR_NETADDR_SIZE(*raddr));\n+#  ifdef _PR_INET6\n+      if (AF_INET6 == *raddr->raw.family) {\n+        *raddr->raw.family = PR_AF_INET6;\n+      }\n+#  endif\n+#  ifdef _PR_NEED_SECRET_AF\n+      (*nd)->secret->af = sd->secret->af;\n+#  endif\n+    }\n+  }\n+  return rv;\n }\n \n PR_IMPLEMENT(PRInt32)\n@@ -1096,180 +1041,168 @@ PR_NTFast_AcceptRead_WithTimeoutCallback(PRFileDesc* sd, PRFileDesc** nd,\n                                          PRNetAddr** raddr, void* buf,\n                                          PRInt32 amount, PRIntervalTime timeout,\n                                          _PR_AcceptTimeoutCallback callback,\n-                                         void* callbackArg)\n-{\n-    PRInt32 rv;\n-    PROsfd newSock;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRNetAddr* raddrCopy;\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n-    }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        return -1;\n-    }\n-    *nd = NULL;\n-\n-    if (raddr == NULL) {\n-        raddr = &raddrCopy;\n-    }\n-    rv = _PR_MD_FAST_ACCEPT_READ(sd, &newSock, raddr, buf, amount, timeout,\n-                                 PR_TRUE, callback, callbackArg);\n-    if (rv < 0) {\n-        rv = -1;\n+                                         void* callbackArg) {\n+  PRInt32 rv;\n+  PROsfd newSock;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRNetAddr* raddrCopy;\n+\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    return -1;\n+  }\n+  *nd = NULL;\n+\n+  if (raddr == NULL) {\n+    raddr = &raddrCopy;\n+  }\n+  rv = _PR_MD_FAST_ACCEPT_READ(sd, &newSock, raddr, buf, amount, timeout,\n+                               PR_TRUE, callback, callbackArg);\n+  if (rv < 0) {\n+    rv = -1;\n+  } else {\n+    /* Successfully accepted and read; create the new PRFileDesc */\n+    *nd = PR_AllocFileDesc(newSock, PR_GetTCPMethods());\n+    if (*nd == 0) {\n+      _PR_MD_CLOSE_SOCKET(newSock);\n+      /* PR_AllocFileDesc() has invoked PR_SetError(). */\n+      rv = -1;\n     } else {\n-        /* Successfully accepted and read; create the new PRFileDesc */\n-        *nd = PR_AllocFileDesc(newSock, PR_GetTCPMethods());\n-        if (*nd == 0) {\n-            _PR_MD_CLOSE_SOCKET(newSock);\n-            /* PR_AllocFileDesc() has invoked PR_SetError(). */\n-            rv = -1;\n-        } else {\n-            (*nd)->secret->md.io_model_committed = PR_TRUE;\n-            (*nd)->secret->md.accepted_socket = PR_TRUE;\n-            memcpy(&(*nd)->secret->md.peer_addr, *raddr, PR_NETADDR_SIZE(*raddr));\n-#ifdef _PR_INET6\n-            if (AF_INET6 == *raddr->raw.family) {\n-                *raddr->raw.family = PR_AF_INET6;\n-            }\n-#endif\n-#ifdef _PR_NEED_SECRET_AF\n-            (*nd)->secret->af = sd->secret->af;\n-#endif\n-        }\n-    }\n-    return rv;\n+      (*nd)->secret->md.io_model_committed = PR_TRUE;\n+      (*nd)->secret->md.accepted_socket = PR_TRUE;\n+      memcpy(&(*nd)->secret->md.peer_addr, *raddr, PR_NETADDR_SIZE(*raddr));\n+#  ifdef _PR_INET6\n+      if (AF_INET6 == *raddr->raw.family) {\n+        *raddr->raw.family = PR_AF_INET6;\n+      }\n+#  endif\n+#  ifdef _PR_NEED_SECRET_AF\n+      (*nd)->secret->af = sd->secret->af;\n+#  endif\n+    }\n+  }\n+  return rv;\n }\n #endif /* WINNT */\n \n #ifdef WINNT\n PR_IMPLEMENT(void)\n-PR_NTFast_UpdateAcceptContext(PRFileDesc* socket, PRFileDesc* acceptSocket)\n-{\n-    _PR_MD_UPDATE_ACCEPT_CONTEXT(socket->secret->md.osfd,\n-                                 acceptSocket->secret->md.osfd);\n+PR_NTFast_UpdateAcceptContext(PRFileDesc* socket, PRFileDesc* acceptSocket) {\n+  _PR_MD_UPDATE_ACCEPT_CONTEXT(socket->secret->md.osfd,\n+                               acceptSocket->secret->md.osfd);\n }\n #endif /* WINNT */\n \n-static PRInt32 PR_CALLBACK\n-SocketSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n-               PRTransmitFileFlags flags,\n-               PRIntervalTime timeout)\n-{\n-    PRInt32 rv;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n-    }\n-    if (_PR_IO_PENDING(me)) {\n-        PR_SetError(PR_IO_PENDING_ERROR, 0);\n-        return -1;\n-    }\n-    /* The socket must be in blocking mode. */\n-    if (sd->secret->nonblocking) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return -1;\n-    }\n+static PRInt32 PR_CALLBACK SocketSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n+                                          PRTransmitFileFlags flags,\n+                                          PRIntervalTime timeout) {\n+  PRInt32 rv;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n+  if (_PR_IO_PENDING(me)) {\n+    PR_SetError(PR_IO_PENDING_ERROR, 0);\n+    return -1;\n+  }\n+  /* The socket must be in blocking mode. */\n+  if (sd->secret->nonblocking) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return -1;\n+  }\n #if defined(WINNT)\n-    rv = _PR_MD_SENDFILE(sd, sfd, flags, timeout);\n-    if ((rv >= 0) && (flags == PR_TRANSMITFILE_CLOSE_SOCKET)) {\n-        /*\n-         * This should be kept the same as SocketClose, except\n-         * that _PR_MD_CLOSE_SOCKET(sd->secret->md.osfd) should\n-         * not be called because the socket will be recycled.\n-         */\n-        PR_FreeFileDesc(sd);\n-    }\n+  rv = _PR_MD_SENDFILE(sd, sfd, flags, timeout);\n+  if ((rv >= 0) && (flags == PR_TRANSMITFILE_CLOSE_SOCKET)) {\n+    /*\n+     * This should be kept the same as SocketClose, except\n+     * that _PR_MD_CLOSE_SOCKET(sd->secret->md.osfd) should\n+     * not be called because the socket will be recycled.\n+     */\n+    PR_FreeFileDesc(sd);\n+  }\n #else\n-    rv = PR_EmulateSendFile(sd, sfd, flags, timeout);\n+  rv = PR_EmulateSendFile(sd, sfd, flags, timeout);\n #endif /* WINNT */\n \n-    return rv;\n+  return rv;\n }\n \n-static PRInt32 PR_CALLBACK\n-SocketTransmitFile(PRFileDesc* sd, PRFileDesc* fd,\n-                   const void* headers, PRInt32 hlen,\n-                   PRTransmitFileFlags flags,\n-                   PRIntervalTime timeout)\n-{\n-    PRSendFileData sfd;\n-\n-    sfd.fd = fd;\n-    sfd.file_offset = 0;\n-    sfd.file_nbytes = 0;\n-    sfd.header = headers;\n-    sfd.hlen = hlen;\n-    sfd.trailer = NULL;\n-    sfd.tlen = 0;\n-\n-    return (SocketSendFile(sd, &sfd, flags, timeout));\n+static PRInt32 PR_CALLBACK SocketTransmitFile(PRFileDesc* sd, PRFileDesc* fd,\n+                                              const void* headers, PRInt32 hlen,\n+                                              PRTransmitFileFlags flags,\n+                                              PRIntervalTime timeout) {\n+  PRSendFileData sfd;\n+\n+  sfd.fd = fd;\n+  sfd.file_offset = 0;\n+  sfd.file_nbytes = 0;\n+  sfd.header = headers;\n+  sfd.hlen = hlen;\n+  sfd.trailer = NULL;\n+  sfd.tlen = 0;\n+\n+  return (SocketSendFile(sd, &sfd, flags, timeout));\n }\n \n-static PRStatus PR_CALLBACK\n-SocketGetName(PRFileDesc* fd, PRNetAddr* addr)\n-{\n-    PRInt32 result;\n-    PRUint32 addrlen;\n+static PRStatus PR_CALLBACK SocketGetName(PRFileDesc* fd, PRNetAddr* addr) {\n+  PRInt32 result;\n+  PRUint32 addrlen;\n \n-    addrlen = sizeof(PRNetAddr);\n-    result = _PR_MD_GETSOCKNAME(fd, addr, &addrlen);\n-    if (result < 0) {\n-        return PR_FAILURE;\n-    }\n+  addrlen = sizeof(PRNetAddr);\n+  result = _PR_MD_GETSOCKNAME(fd, addr, &addrlen);\n+  if (result < 0) {\n+    return PR_FAILURE;\n+  }\n #ifdef _PR_INET6\n-    if (AF_INET6 == addr->raw.family) {\n-        addr->raw.family = PR_AF_INET6;\n-    }\n+  if (AF_INET6 == addr->raw.family) {\n+    addr->raw.family = PR_AF_INET6;\n+  }\n #endif\n-    PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n-    PR_ASSERT(IsValidNetAddrLen(addr, addrlen) == PR_TRUE);\n-    return PR_SUCCESS;\n+  PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n+  PR_ASSERT(IsValidNetAddrLen(addr, addrlen) == PR_TRUE);\n+  return PR_SUCCESS;\n }\n \n-static PRStatus PR_CALLBACK\n-SocketGetPeerName(PRFileDesc* fd, PRNetAddr* addr)\n-{\n-    PRInt32 result;\n-    PRUint32 addrlen;\n+static PRStatus PR_CALLBACK SocketGetPeerName(PRFileDesc* fd, PRNetAddr* addr) {\n+  PRInt32 result;\n+  PRUint32 addrlen;\n \n-    addrlen = sizeof(PRNetAddr);\n-    result = _PR_MD_GETPEERNAME(fd, addr, &addrlen);\n-    if (result < 0) {\n-        return PR_FAILURE;\n-    }\n+  addrlen = sizeof(PRNetAddr);\n+  result = _PR_MD_GETPEERNAME(fd, addr, &addrlen);\n+  if (result < 0) {\n+    return PR_FAILURE;\n+  }\n #ifdef _PR_INET6\n-    if (AF_INET6 == addr->raw.family) {\n-        addr->raw.family = PR_AF_INET6;\n-    }\n+  if (AF_INET6 == addr->raw.family) {\n+    addr->raw.family = PR_AF_INET6;\n+  }\n #endif\n-    PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n-    PR_ASSERT(IsValidNetAddrLen(addr, addrlen) == PR_TRUE);\n-    return PR_SUCCESS;\n+  PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n+  PR_ASSERT(IsValidNetAddrLen(addr, addrlen) == PR_TRUE);\n+  return PR_SUCCESS;\n }\n \n-static PRInt16 PR_CALLBACK\n-SocketPoll(PRFileDesc* fd, PRInt16 in_flags,\n-           PRInt16* out_flags)\n-{\n-    *out_flags = 0;\n+static PRInt16 PR_CALLBACK SocketPoll(PRFileDesc* fd, PRInt16 in_flags,\n+                                      PRInt16* out_flags) {\n+  *out_flags = 0;\n \n #if defined(_WIN64)\n-    if (in_flags & PR_POLL_WRITE) {\n-        if (fd->secret->alreadyConnected) {\n-            *out_flags = PR_POLL_WRITE;\n-            return PR_POLL_WRITE;\n-        }\n+  if (in_flags & PR_POLL_WRITE) {\n+    if (fd->secret->alreadyConnected) {\n+      *out_flags = PR_POLL_WRITE;\n+      return PR_POLL_WRITE;\n     }\n+  }\n #endif\n-    return in_flags;\n+  return in_flags;\n } /* SocketPoll */\n \n static PRIOMethods tcpMethods = {\n@@ -1312,45 +1245,44 @@ static PRIOMethods tcpMethods = {\n     (PRReservedFN)_PR_InvalidInt,\n     (PRReservedFN)_PR_InvalidInt,\n     (PRReservedFN)_PR_InvalidInt,\n-    (PRReservedFN)_PR_InvalidInt\n-};\n-\n-static PRIOMethods udpMethods = { PR_DESC_SOCKET_UDP,\n-                                  SocketClose,\n-                                  SocketRead,\n-                                  SocketWrite,\n-                                  SocketAvailable,\n-                                  SocketAvailable64,\n-                                  SocketSync,\n-                                  (PRSeekFN)_PR_InvalidInt,\n-                                  (PRSeek64FN)_PR_InvalidInt64,\n-                                  (PRFileInfoFN)_PR_InvalidStatus,\n-                                  (PRFileInfo64FN)_PR_InvalidStatus,\n-                                  SocketWritev,\n-                                  SocketConnect,\n-                                  (PRAcceptFN)_PR_InvalidDesc,\n-                                  SocketBind,\n-                                  SocketListen,\n-                                  SocketShutdown,\n-                                  SocketRecv,\n-                                  SocketSend,\n-                                  SocketRecvFrom,\n-                                  SocketSendTo,\n-                                  SocketPoll,\n-                                  (PRAcceptreadFN)_PR_InvalidInt,\n-                                  (PRTransmitfileFN)_PR_InvalidInt,\n-                                  SocketGetName,\n-                                  SocketGetPeerName,\n-                                  (PRReservedFN)_PR_InvalidInt,\n-                                  (PRReservedFN)_PR_InvalidInt,\n-                                  _PR_SocketGetSocketOption,\n-                                  _PR_SocketSetSocketOption,\n-                                  (PRSendfileFN)_PR_InvalidInt,\n-                                  (PRConnectcontinueFN)_PR_InvalidStatus,\n-                                  (PRReservedFN)_PR_InvalidInt,\n-                                  (PRReservedFN)_PR_InvalidInt,\n-                                  (PRReservedFN)_PR_InvalidInt,\n-                                  (PRReservedFN)_PR_InvalidInt };\n+    (PRReservedFN)_PR_InvalidInt};\n+\n+static PRIOMethods udpMethods = {PR_DESC_SOCKET_UDP,\n+                                 SocketClose,\n+                                 SocketRead,\n+                                 SocketWrite,\n+                                 SocketAvailable,\n+                                 SocketAvailable64,\n+                                 SocketSync,\n+                                 (PRSeekFN)_PR_InvalidInt,\n+                                 (PRSeek64FN)_PR_InvalidInt64,\n+                                 (PRFileInfoFN)_PR_InvalidStatus,\n+                                 (PRFileInfo64FN)_PR_InvalidStatus,\n+                                 SocketWritev,\n+                                 SocketConnect,\n+                                 (PRAcceptFN)_PR_InvalidDesc,\n+                                 SocketBind,\n+                                 SocketListen,\n+                                 SocketShutdown,\n+                                 SocketRecv,\n+                                 SocketSend,\n+                                 SocketRecvFrom,\n+                                 SocketSendTo,\n+                                 SocketPoll,\n+                                 (PRAcceptreadFN)_PR_InvalidInt,\n+                                 (PRTransmitfileFN)_PR_InvalidInt,\n+                                 SocketGetName,\n+                                 SocketGetPeerName,\n+                                 (PRReservedFN)_PR_InvalidInt,\n+                                 (PRReservedFN)_PR_InvalidInt,\n+                                 _PR_SocketGetSocketOption,\n+                                 _PR_SocketSetSocketOption,\n+                                 (PRSendfileFN)_PR_InvalidInt,\n+                                 (PRConnectcontinueFN)_PR_InvalidStatus,\n+                                 (PRReservedFN)_PR_InvalidInt,\n+                                 (PRReservedFN)_PR_InvalidInt,\n+                                 (PRReservedFN)_PR_InvalidInt,\n+                                 (PRReservedFN)_PR_InvalidInt};\n \n static PRIOMethods socketpollfdMethods = {\n     (PRDescType)0,\n@@ -1388,388 +1320,367 @@ static PRIOMethods socketpollfdMethods = {\n     (PRReservedFN)_PR_InvalidInt,\n     (PRReservedFN)_PR_InvalidInt,\n     (PRReservedFN)_PR_InvalidInt,\n-    (PRReservedFN)_PR_InvalidInt\n-};\n+    (PRReservedFN)_PR_InvalidInt};\n \n-PR_IMPLEMENT(const PRIOMethods*)\n-PR_GetTCPMethods() { return &tcpMethods; }\n+PR_IMPLEMENT(const PRIOMethods*) PR_GetTCPMethods() { return &tcpMethods; }\n \n-PR_IMPLEMENT(const PRIOMethods*)\n-PR_GetUDPMethods() { return &udpMethods; }\n+PR_IMPLEMENT(const PRIOMethods*) PR_GetUDPMethods() { return &udpMethods; }\n \n-static const PRIOMethods*\n-PR_GetSocketPollFdMethods()\n-{\n-    return &socketpollfdMethods;\n+static const PRIOMethods* PR_GetSocketPollFdMethods() {\n+  return &socketpollfdMethods;\n } /* PR_GetSocketPollFdMethods */\n \n #if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)\n-PR_EXTERN(PRStatus)\n-_pr_push_ipv6toipv4_layer(PRFileDesc* fd);\n+PR_EXTERN(PRStatus) _pr_push_ipv6toipv4_layer(PRFileDesc* fd);\n \n-#if defined(_PR_INET6_PROBE)\n+#  if defined(_PR_INET6_PROBE)\n \n extern PRBool _pr_ipv6_is_present(void);\n \n-PR_IMPLEMENT(PRBool)\n-_pr_test_ipv6_socket()\n-{\n-    PROsfd osfd;\n+PR_IMPLEMENT(PRBool) _pr_test_ipv6_socket() {\n+  PROsfd osfd;\n \n-    osfd = _PR_MD_SOCKET(AF_INET6, SOCK_STREAM, 0);\n-    if (osfd != -1) {\n-        _PR_MD_CLOSE_SOCKET(osfd);\n-        return PR_TRUE;\n-    }\n-    return PR_FALSE;\n+  osfd = _PR_MD_SOCKET(AF_INET6, SOCK_STREAM, 0);\n+  if (osfd != -1) {\n+    _PR_MD_CLOSE_SOCKET(osfd);\n+    return PR_TRUE;\n+  }\n+  return PR_FALSE;\n }\n-#endif /* _PR_INET6_PROBE */\n+#  endif /* _PR_INET6_PROBE */\n \n #endif\n \n PR_IMPLEMENT(PRFileDesc*)\n-PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto)\n-{\n-    PROsfd osfd;\n-    PRFileDesc* fd;\n-    PRInt32 tmp_domain = domain;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    if (PR_AF_INET != domain && PR_AF_INET6 != domain\n+PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto) {\n+  PROsfd osfd;\n+  PRFileDesc* fd;\n+  PRInt32 tmp_domain = domain;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  if (PR_AF_INET != domain && PR_AF_INET6 != domain\n #if defined(XP_UNIX)\n-        && PR_AF_LOCAL != domain\n+      && PR_AF_LOCAL != domain\n #endif\n-    ) {\n-        PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);\n-        return NULL;\n-    }\n+  ) {\n+    PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);\n+    return NULL;\n+  }\n \n #if defined(_PR_INET6_PROBE)\n-    if (PR_AF_INET6 == domain) {\n-        domain = _pr_ipv6_is_present() ? AF_INET6 : AF_INET;\n-    }\n+  if (PR_AF_INET6 == domain) {\n+    domain = _pr_ipv6_is_present() ? AF_INET6 : AF_INET;\n+  }\n #elif defined(_PR_INET6)\n-    if (PR_AF_INET6 == domain) {\n-        domain = AF_INET6;\n-    }\n+  if (PR_AF_INET6 == domain) {\n+    domain = AF_INET6;\n+  }\n #else\n-    if (PR_AF_INET6 == domain) {\n-        domain = AF_INET;\n-    }\n+  if (PR_AF_INET6 == domain) {\n+    domain = AF_INET;\n+  }\n #endif /* _PR_INET6 */\n-    osfd = _PR_MD_SOCKET(domain, type, proto);\n-    if (osfd == -1) {\n-        return 0;\n-    }\n-    if (type == SOCK_STREAM) {\n-        fd = PR_AllocFileDesc(osfd, PR_GetTCPMethods());\n-    } else {\n-        fd = PR_AllocFileDesc(osfd, PR_GetUDPMethods());\n-    }\n-    /*\n-     * Make the sockets non-blocking\n-     */\n-    if (fd != NULL) {\n-        _PR_MD_MAKE_NONBLOCK(fd);\n-        _PR_MD_INIT_FD_INHERITABLE(fd, PR_FALSE);\n+  osfd = _PR_MD_SOCKET(domain, type, proto);\n+  if (osfd == -1) {\n+    return 0;\n+  }\n+  if (type == SOCK_STREAM) {\n+    fd = PR_AllocFileDesc(osfd, PR_GetTCPMethods());\n+  } else {\n+    fd = PR_AllocFileDesc(osfd, PR_GetUDPMethods());\n+  }\n+  /*\n+   * Make the sockets non-blocking\n+   */\n+  if (fd != NULL) {\n+    _PR_MD_MAKE_NONBLOCK(fd);\n+    _PR_MD_INIT_FD_INHERITABLE(fd, PR_FALSE);\n #ifdef _PR_NEED_SECRET_AF\n-        fd->secret->af = domain;\n+    fd->secret->af = domain;\n #endif\n #if defined(_PR_INET6_PROBE) || !defined(_PR_INET6)\n-        /*\n-         * For platforms with no support for IPv6\n-         * create layered socket for IPv4-mapped IPv6 addresses\n-         */\n-        if (PR_AF_INET6 == tmp_domain && PR_AF_INET == domain) {\n-            if (PR_FAILURE == _pr_push_ipv6toipv4_layer(fd)) {\n-                PR_Close(fd);\n-                fd = NULL;\n-            }\n-        }\n-#endif\n-    } else {\n-        _PR_MD_CLOSE_SOCKET(osfd);\n+    /*\n+     * For platforms with no support for IPv6\n+     * create layered socket for IPv4-mapped IPv6 addresses\n+     */\n+    if (PR_AF_INET6 == tmp_domain && PR_AF_INET == domain) {\n+      if (PR_FAILURE == _pr_push_ipv6toipv4_layer(fd)) {\n+        PR_Close(fd);\n+        fd = NULL;\n+      }\n     }\n+#endif\n+  } else {\n+    _PR_MD_CLOSE_SOCKET(osfd);\n+  }\n \n-    return fd;\n+  return fd;\n }\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_NewTCPSocket(void)\n-{\n-    PRInt32 domain = AF_INET;\n+PR_IMPLEMENT(PRFileDesc*) PR_NewTCPSocket(void) {\n+  PRInt32 domain = AF_INET;\n \n-    return PR_Socket(domain, SOCK_STREAM, 0);\n+  return PR_Socket(domain, SOCK_STREAM, 0);\n }\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_NewUDPSocket(void)\n-{\n-    PRInt32 domain = AF_INET;\n+PR_IMPLEMENT(PRFileDesc*) PR_NewUDPSocket(void) {\n+  PRInt32 domain = AF_INET;\n \n-    return PR_Socket(domain, SOCK_DGRAM, 0);\n+  return PR_Socket(domain, SOCK_DGRAM, 0);\n }\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_OpenTCPSocket(PRIntn af)\n-{\n-    return PR_Socket(af, SOCK_STREAM, 0);\n+PR_IMPLEMENT(PRFileDesc*) PR_OpenTCPSocket(PRIntn af) {\n+  return PR_Socket(af, SOCK_STREAM, 0);\n }\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_OpenUDPSocket(PRIntn af)\n-{\n-    return PR_Socket(af, SOCK_DGRAM, 0);\n+PR_IMPLEMENT(PRFileDesc*) PR_OpenUDPSocket(PRIntn af) {\n+  return PR_Socket(af, SOCK_DGRAM, 0);\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_NewTCPSocketPair(PRFileDesc* f[])\n-{\n+PR_IMPLEMENT(PRStatus) PR_NewTCPSocketPair(PRFileDesc* f[]) {\n #ifdef XP_UNIX\n-    PRInt32 rv, osfd[2];\n+  PRInt32 rv, osfd[2];\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    rv = _PR_MD_SOCKETPAIR(AF_UNIX, SOCK_STREAM, 0, osfd);\n-    if (rv == -1) {\n-        return PR_FAILURE;\n-    }\n+  rv = _PR_MD_SOCKETPAIR(AF_UNIX, SOCK_STREAM, 0, osfd);\n+  if (rv == -1) {\n+    return PR_FAILURE;\n+  }\n \n-    f[0] = PR_AllocFileDesc(osfd[0], PR_GetTCPMethods());\n-    if (!f[0]) {\n-        _PR_MD_CLOSE_SOCKET(osfd[0]);\n-        _PR_MD_CLOSE_SOCKET(osfd[1]);\n-        /* PR_AllocFileDesc() has invoked PR_SetError(). */\n-        return PR_FAILURE;\n-    }\n-    f[1] = PR_AllocFileDesc(osfd[1], PR_GetTCPMethods());\n-    if (!f[1]) {\n-        PR_Close(f[0]);\n-        _PR_MD_CLOSE_SOCKET(osfd[1]);\n-        /* PR_AllocFileDesc() has invoked PR_SetError(). */\n-        return PR_FAILURE;\n-    }\n-    _PR_MD_MAKE_NONBLOCK(f[0]);\n-    _PR_MD_INIT_FD_INHERITABLE(f[0], PR_FALSE);\n-    _PR_MD_MAKE_NONBLOCK(f[1]);\n-    _PR_MD_INIT_FD_INHERITABLE(f[1], PR_FALSE);\n-    return PR_SUCCESS;\n+  f[0] = PR_AllocFileDesc(osfd[0], PR_GetTCPMethods());\n+  if (!f[0]) {\n+    _PR_MD_CLOSE_SOCKET(osfd[0]);\n+    _PR_MD_CLOSE_SOCKET(osfd[1]);\n+    /* PR_AllocFileDesc() has invoked PR_SetError(). */\n+    return PR_FAILURE;\n+  }\n+  f[1] = PR_AllocFileDesc(osfd[1], PR_GetTCPMethods());\n+  if (!f[1]) {\n+    PR_Close(f[0]);\n+    _PR_MD_CLOSE_SOCKET(osfd[1]);\n+    /* PR_AllocFileDesc() has invoked PR_SetError(). */\n+    return PR_FAILURE;\n+  }\n+  _PR_MD_MAKE_NONBLOCK(f[0]);\n+  _PR_MD_INIT_FD_INHERITABLE(f[0], PR_FALSE);\n+  _PR_MD_MAKE_NONBLOCK(f[1]);\n+  _PR_MD_INIT_FD_INHERITABLE(f[1], PR_FALSE);\n+  return PR_SUCCESS;\n #elif defined(WINNT)\n-    /*\n-     * A socket pair is often used for interprocess communication,\n-     * so we need to make sure neither socket is associated with\n-     * the I/O completion port; otherwise it can't be used by a\n-     * child process.\n-     *\n-     * The default implementation below cannot be used for NT\n-     * because PR_Accept would have associated the I/O completion\n-     * port with the listening and accepted sockets.\n-     */\n-    SOCKET listenSock;\n-    SOCKET osfd[2];\n-    struct sockaddr_in selfAddr, peerAddr;\n-    int addrLen;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    osfd[0] = osfd[1] = INVALID_SOCKET;\n-    listenSock = socket(AF_INET, SOCK_STREAM, 0);\n-    if (listenSock == INVALID_SOCKET) {\n-        goto failed;\n-    }\n-    selfAddr.sin_family = AF_INET;\n-    selfAddr.sin_port = 0;\n-    selfAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* BugZilla: 35408 */\n-    addrLen = sizeof(selfAddr);\n-    if (bind(listenSock, (struct sockaddr*)&selfAddr, addrLen) == SOCKET_ERROR) {\n-        goto failed;\n-    }\n-    if (getsockname(listenSock, (struct sockaddr*)&selfAddr, &addrLen) ==\n-        SOCKET_ERROR) {\n-        goto failed;\n-    }\n-    if (listen(listenSock, 5) == SOCKET_ERROR) {\n-        goto failed;\n-    }\n-    osfd[0] = socket(AF_INET, SOCK_STREAM, 0);\n-    if (osfd[0] == INVALID_SOCKET) {\n-        goto failed;\n-    }\n-    selfAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);\n-\n-    /*\n-     * Only a thread is used to do the connect and accept.\n-     * I am relying on the fact that connect returns\n-     * successfully as soon as the connect request is put\n-     * into the listen queue (but before accept is called).\n-     * This is the behavior of the BSD socket code.  If\n-     * connect does not return until accept is called, we\n-     * will need to create another thread to call connect.\n-     */\n-    if (connect(osfd[0], (struct sockaddr*)&selfAddr, addrLen) == SOCKET_ERROR) {\n-        goto failed;\n-    }\n-    /*\n-     * A malicious local process may connect to the listening\n-     * socket, so we need to verify that the accepted connection\n-     * is made from our own socket osfd[0].\n-     */\n-    if (getsockname(osfd[0], (struct sockaddr*)&selfAddr, &addrLen) ==\n-        SOCKET_ERROR) {\n-        goto failed;\n-    }\n-    osfd[1] = accept(listenSock, (struct sockaddr*)&peerAddr, &addrLen);\n-    if (osfd[1] == INVALID_SOCKET) {\n-        goto failed;\n-    }\n-    if (peerAddr.sin_port != selfAddr.sin_port) {\n-        /* the connection we accepted is not from osfd[0] */\n-        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n-        goto failed;\n-    }\n-    closesocket(listenSock);\n-\n-    f[0] = PR_AllocFileDesc(osfd[0], PR_GetTCPMethods());\n-    if (!f[0]) {\n-        closesocket(osfd[0]);\n-        closesocket(osfd[1]);\n-        /* PR_AllocFileDesc() has invoked PR_SetError(). */\n-        return PR_FAILURE;\n-    }\n-    f[1] = PR_AllocFileDesc(osfd[1], PR_GetTCPMethods());\n-    if (!f[1]) {\n-        PR_Close(f[0]);\n-        closesocket(osfd[1]);\n-        /* PR_AllocFileDesc() has invoked PR_SetError(). */\n-        return PR_FAILURE;\n-    }\n-    _PR_MD_INIT_FD_INHERITABLE(f[0], PR_FALSE);\n-    _PR_MD_INIT_FD_INHERITABLE(f[1], PR_FALSE);\n-    return PR_SUCCESS;\n+  /*\n+   * A socket pair is often used for interprocess communication,\n+   * so we need to make sure neither socket is associated with\n+   * the I/O completion port; otherwise it can't be used by a\n+   * child process.\n+   *\n+   * The default implementation below cannot be used for NT\n+   * because PR_Accept would have associated the I/O completion\n+   * port with the listening and accepted sockets.\n+   */\n+  SOCKET listenSock;\n+  SOCKET osfd[2];\n+  struct sockaddr_in selfAddr, peerAddr;\n+  int addrLen;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  osfd[0] = osfd[1] = INVALID_SOCKET;\n+  listenSock = socket(AF_INET, SOCK_STREAM, 0);\n+  if (listenSock == INVALID_SOCKET) {\n+    goto failed;\n+  }\n+  selfAddr.sin_family = AF_INET;\n+  selfAddr.sin_port = 0;\n+  selfAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* BugZilla: 35408 */\n+  addrLen = sizeof(selfAddr);\n+  if (bind(listenSock, (struct sockaddr*)&selfAddr, addrLen) == SOCKET_ERROR) {\n+    goto failed;\n+  }\n+  if (getsockname(listenSock, (struct sockaddr*)&selfAddr, &addrLen) ==\n+      SOCKET_ERROR) {\n+    goto failed;\n+  }\n+  if (listen(listenSock, 5) == SOCKET_ERROR) {\n+    goto failed;\n+  }\n+  osfd[0] = socket(AF_INET, SOCK_STREAM, 0);\n+  if (osfd[0] == INVALID_SOCKET) {\n+    goto failed;\n+  }\n+  selfAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);\n+\n+  /*\n+   * Only a thread is used to do the connect and accept.\n+   * I am relying on the fact that connect returns\n+   * successfully as soon as the connect request is put\n+   * into the listen queue (but before accept is called).\n+   * This is the behavior of the BSD socket code.  If\n+   * connect does not return until accept is called, we\n+   * will need to create another thread to call connect.\n+   */\n+  if (connect(osfd[0], (struct sockaddr*)&selfAddr, addrLen) == SOCKET_ERROR) {\n+    goto failed;\n+  }\n+  /*\n+   * A malicious local process may connect to the listening\n+   * socket, so we need to verify that the accepted connection\n+   * is made from our own socket osfd[0].\n+   */\n+  if (getsockname(osfd[0], (struct sockaddr*)&selfAddr, &addrLen) ==\n+      SOCKET_ERROR) {\n+    goto failed;\n+  }\n+  osfd[1] = accept(listenSock, (struct sockaddr*)&peerAddr, &addrLen);\n+  if (osfd[1] == INVALID_SOCKET) {\n+    goto failed;\n+  }\n+  if (peerAddr.sin_port != selfAddr.sin_port) {\n+    /* the connection we accepted is not from osfd[0] */\n+    PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n+    goto failed;\n+  }\n+  closesocket(listenSock);\n+\n+  f[0] = PR_AllocFileDesc(osfd[0], PR_GetTCPMethods());\n+  if (!f[0]) {\n+    closesocket(osfd[0]);\n+    closesocket(osfd[1]);\n+    /* PR_AllocFileDesc() has invoked PR_SetError(). */\n+    return PR_FAILURE;\n+  }\n+  f[1] = PR_AllocFileDesc(osfd[1], PR_GetTCPMethods());\n+  if (!f[1]) {\n+    PR_Close(f[0]);\n+    closesocket(osfd[1]);\n+    /* PR_AllocFileDesc() has invoked PR_SetError(). */\n+    return PR_FAILURE;\n+  }\n+  _PR_MD_INIT_FD_INHERITABLE(f[0], PR_FALSE);\n+  _PR_MD_INIT_FD_INHERITABLE(f[1], PR_FALSE);\n+  return PR_SUCCESS;\n \n failed:\n-    if (listenSock != INVALID_SOCKET) {\n-        closesocket(listenSock);\n-    }\n-    if (osfd[0] != INVALID_SOCKET) {\n-        closesocket(osfd[0]);\n-    }\n-    if (osfd[1] != INVALID_SOCKET) {\n-        closesocket(osfd[1]);\n-    }\n-    return PR_FAILURE;\n+  if (listenSock != INVALID_SOCKET) {\n+    closesocket(listenSock);\n+  }\n+  if (osfd[0] != INVALID_SOCKET) {\n+    closesocket(osfd[0]);\n+  }\n+  if (osfd[1] != INVALID_SOCKET) {\n+    closesocket(osfd[1]);\n+  }\n+  return PR_FAILURE;\n #else /* not Unix or NT */\n-    /*\n-     * default implementation\n-     */\n-    PRFileDesc* listenSock;\n-    PRNetAddr selfAddr, peerAddr;\n-    PRUint16 port;\n-\n-    f[0] = f[1] = NULL;\n-    listenSock = PR_NewTCPSocket();\n-    if (listenSock == NULL) {\n-        goto failed;\n-    }\n-    PR_InitializeNetAddr(PR_IpAddrLoopback, 0, &selfAddr); /* BugZilla: 35408 */\n-    if (PR_Bind(listenSock, &selfAddr) == PR_FAILURE) {\n-        goto failed;\n-    }\n-    if (PR_GetSockName(listenSock, &selfAddr) == PR_FAILURE) {\n-        goto failed;\n-    }\n-    port = ntohs(selfAddr.inet.port);\n-    if (PR_Listen(listenSock, 5) == PR_FAILURE) {\n-        goto failed;\n-    }\n-    f[0] = PR_NewTCPSocket();\n-    if (f[0] == NULL) {\n-        goto failed;\n-    }\n-#ifdef _PR_CONNECT_DOES_NOT_BIND\n-    /*\n-     * If connect does not implicitly bind the socket (e.g., on\n-     * BeOS), we have to bind the socket so that we can get its\n-     * port with getsockname later.\n-     */\n-    PR_InitializeNetAddr(PR_IpAddrLoopback, 0, &selfAddr);\n-    if (PR_Bind(f[0], &selfAddr) == PR_FAILURE) {\n-        goto failed;\n-    }\n-#endif\n-    PR_InitializeNetAddr(PR_IpAddrLoopback, port, &selfAddr);\n-\n-    /*\n-     * Only a thread is used to do the connect and accept.\n-     * I am relying on the fact that PR_Connect returns\n-     * successfully as soon as the connect request is put\n-     * into the listen queue (but before PR_Accept is called).\n-     * This is the behavior of the BSD socket code.  If\n-     * connect does not return until accept is called, we\n-     * will need to create another thread to call connect.\n-     */\n-    if (PR_Connect(f[0], &selfAddr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n-        goto failed;\n-    }\n-    /*\n-     * A malicious local process may connect to the listening\n-     * socket, so we need to verify that the accepted connection\n-     * is made from our own socket f[0].\n-     */\n-    if (PR_GetSockName(f[0], &selfAddr) == PR_FAILURE) {\n-        goto failed;\n-    }\n-    f[1] = PR_Accept(listenSock, &peerAddr, PR_INTERVAL_NO_TIMEOUT);\n-    if (f[1] == NULL) {\n-        goto failed;\n-    }\n-    if (peerAddr.inet.port != selfAddr.inet.port) {\n-        /* the connection we accepted is not from f[0] */\n-        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n-        goto failed;\n-    }\n-    PR_Close(listenSock);\n-    return PR_SUCCESS;\n+  /*\n+   * default implementation\n+   */\n+  PRFileDesc* listenSock;\n+  PRNetAddr selfAddr, peerAddr;\n+  PRUint16 port;\n+\n+  f[0] = f[1] = NULL;\n+  listenSock = PR_NewTCPSocket();\n+  if (listenSock == NULL) {\n+    goto failed;\n+  }\n+  PR_InitializeNetAddr(PR_IpAddrLoopback, 0, &selfAddr); /* BugZilla: 35408 */\n+  if (PR_Bind(listenSock, &selfAddr) == PR_FAILURE) {\n+    goto failed;\n+  }\n+  if (PR_GetSockName(listenSock, &selfAddr) == PR_FAILURE) {\n+    goto failed;\n+  }\n+  port = ntohs(selfAddr.inet.port);\n+  if (PR_Listen(listenSock, 5) == PR_FAILURE) {\n+    goto failed;\n+  }\n+  f[0] = PR_NewTCPSocket();\n+  if (f[0] == NULL) {\n+    goto failed;\n+  }\n+#  ifdef _PR_CONNECT_DOES_NOT_BIND\n+  /*\n+   * If connect does not implicitly bind the socket (e.g., on\n+   * BeOS), we have to bind the socket so that we can get its\n+   * port with getsockname later.\n+   */\n+  PR_InitializeNetAddr(PR_IpAddrLoopback, 0, &selfAddr);\n+  if (PR_Bind(f[0], &selfAddr) == PR_FAILURE) {\n+    goto failed;\n+  }\n+#  endif\n+  PR_InitializeNetAddr(PR_IpAddrLoopback, port, &selfAddr);\n+\n+  /*\n+   * Only a thread is used to do the connect and accept.\n+   * I am relying on the fact that PR_Connect returns\n+   * successfully as soon as the connect request is put\n+   * into the listen queue (but before PR_Accept is called).\n+   * This is the behavior of the BSD socket code.  If\n+   * connect does not return until accept is called, we\n+   * will need to create another thread to call connect.\n+   */\n+  if (PR_Connect(f[0], &selfAddr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n+    goto failed;\n+  }\n+  /*\n+   * A malicious local process may connect to the listening\n+   * socket, so we need to verify that the accepted connection\n+   * is made from our own socket f[0].\n+   */\n+  if (PR_GetSockName(f[0], &selfAddr) == PR_FAILURE) {\n+    goto failed;\n+  }\n+  f[1] = PR_Accept(listenSock, &peerAddr, PR_INTERVAL_NO_TIMEOUT);\n+  if (f[1] == NULL) {\n+    goto failed;\n+  }\n+  if (peerAddr.inet.port != selfAddr.inet.port) {\n+    /* the connection we accepted is not from f[0] */\n+    PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n+    goto failed;\n+  }\n+  PR_Close(listenSock);\n+  return PR_SUCCESS;\n \n failed:\n-    if (listenSock) {\n-        PR_Close(listenSock);\n-    }\n-    if (f[0]) {\n-        PR_Close(f[0]);\n-    }\n-    if (f[1]) {\n-        PR_Close(f[1]);\n-    }\n-    return PR_FAILURE;\n+  if (listenSock) {\n+    PR_Close(listenSock);\n+  }\n+  if (f[0]) {\n+    PR_Close(f[0]);\n+  }\n+  if (f[1]) {\n+    PR_Close(f[1]);\n+  }\n+  return PR_FAILURE;\n #endif\n }\n \n PR_IMPLEMENT(PROsfd)\n-PR_FileDesc2NativeHandle(PRFileDesc* fd)\n-{\n-    if (fd) {\n-        fd = PR_GetIdentitiesLayer(fd, PR_NSPR_IO_LAYER);\n-    }\n-    if (!fd) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return -1;\n-    }\n-    return fd->secret->md.osfd;\n+PR_FileDesc2NativeHandle(PRFileDesc* fd) {\n+  if (fd) {\n+    fd = PR_GetIdentitiesLayer(fd, PR_NSPR_IO_LAYER);\n+  }\n+  if (!fd) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return -1;\n+  }\n+  return fd->secret->md.osfd;\n }\n \n PR_IMPLEMENT(void)\n-PR_ChangeFileDescNativeHandle(PRFileDesc* fd, PROsfd handle)\n-{\n-    if (fd) {\n-        fd->secret->md.osfd = handle;\n-    }\n+PR_ChangeFileDescNativeHandle(PRFileDesc* fd, PROsfd handle) {\n+  if (fd) {\n+    fd->secret->md.osfd = handle;\n+  }\n }\n \n /*\n@@ -1777,121 +1688,105 @@ PR_ChangeFileDescNativeHandle(PRFileDesc* fd, PROsfd handle)\n **\n */\n \n-PR_IMPLEMENT(void)\n-PR_FD_ZERO(PR_fd_set* set)\n-{\n-    memset(set, 0, sizeof(PR_fd_set));\n+PR_IMPLEMENT(void) PR_FD_ZERO(PR_fd_set* set) {\n+  memset(set, 0, sizeof(PR_fd_set));\n }\n \n-PR_IMPLEMENT(void)\n-PR_FD_SET(PRFileDesc* fh, PR_fd_set* set)\n-{\n-    PR_ASSERT(set->hsize < PR_MAX_SELECT_DESC);\n+PR_IMPLEMENT(void) PR_FD_SET(PRFileDesc* fh, PR_fd_set* set) {\n+  PR_ASSERT(set->hsize < PR_MAX_SELECT_DESC);\n \n-    set->harray[set->hsize++] = fh;\n+  set->harray[set->hsize++] = fh;\n }\n \n-PR_IMPLEMENT(void)\n-PR_FD_CLR(PRFileDesc* fh, PR_fd_set* set)\n-{\n-    PRUint32 index, index2;\n-\n-    for (index = 0; index < set->hsize; index++)\n-        if (set->harray[index] == fh) {\n-            for (index2 = index; index2 < (set->hsize - 1); index2++) {\n-                set->harray[index2] = set->harray[index2 + 1];\n-            }\n-            set->hsize--;\n-            break;\n-        }\n+PR_IMPLEMENT(void) PR_FD_CLR(PRFileDesc* fh, PR_fd_set* set) {\n+  PRUint32 index, index2;\n+\n+  for (index = 0; index < set->hsize; index++)\n+    if (set->harray[index] == fh) {\n+      for (index2 = index; index2 < (set->hsize - 1); index2++) {\n+        set->harray[index2] = set->harray[index2 + 1];\n+      }\n+      set->hsize--;\n+      break;\n+    }\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_FD_ISSET(PRFileDesc* fh, PR_fd_set* set)\n-{\n-    PRUint32 index;\n-    for (index = 0; index < set->hsize; index++)\n-        if (set->harray[index] == fh) {\n-            return 1;\n-        }\n-    return 0;\n+PR_IMPLEMENT(PRInt32) PR_FD_ISSET(PRFileDesc* fh, PR_fd_set* set) {\n+  PRUint32 index;\n+  for (index = 0; index < set->hsize; index++)\n+    if (set->harray[index] == fh) {\n+      return 1;\n+    }\n+  return 0;\n }\n \n-PR_IMPLEMENT(void)\n-PR_FD_NSET(PROsfd fd, PR_fd_set* set)\n-{\n-    PR_ASSERT(set->nsize < PR_MAX_SELECT_DESC);\n+PR_IMPLEMENT(void) PR_FD_NSET(PROsfd fd, PR_fd_set* set) {\n+  PR_ASSERT(set->nsize < PR_MAX_SELECT_DESC);\n \n-    set->narray[set->nsize++] = fd;\n+  set->narray[set->nsize++] = fd;\n }\n \n-PR_IMPLEMENT(void)\n-PR_FD_NCLR(PROsfd fd, PR_fd_set* set)\n-{\n-    PRUint32 index, index2;\n-\n-    for (index = 0; index < set->nsize; index++)\n-        if (set->narray[index] == fd) {\n-            for (index2 = index; index2 < (set->nsize - 1); index2++) {\n-                set->narray[index2] = set->narray[index2 + 1];\n-            }\n-            set->nsize--;\n-            break;\n-        }\n+PR_IMPLEMENT(void) PR_FD_NCLR(PROsfd fd, PR_fd_set* set) {\n+  PRUint32 index, index2;\n+\n+  for (index = 0; index < set->nsize; index++)\n+    if (set->narray[index] == fd) {\n+      for (index2 = index; index2 < (set->nsize - 1); index2++) {\n+        set->narray[index2] = set->narray[index2 + 1];\n+      }\n+      set->nsize--;\n+      break;\n+    }\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_FD_NISSET(PROsfd fd, PR_fd_set* set)\n-{\n-    PRUint32 index;\n-    for (index = 0; index < set->nsize; index++)\n-        if (set->narray[index] == fd) {\n-            return 1;\n-        }\n-    return 0;\n+PR_IMPLEMENT(PRInt32) PR_FD_NISSET(PROsfd fd, PR_fd_set* set) {\n+  PRUint32 index;\n+  for (index = 0; index < set->nsize; index++)\n+    if (set->narray[index] == fd) {\n+      return 1;\n+    }\n+  return 0;\n }\n \n #if !defined(NEED_SELECT)\n-#include \"obsolete/probslet.h\"\n-\n-#define PD_INCR 20\n+#  include \"obsolete/probslet.h\"\n \n-static PRPollDesc*\n-_pr_setfd(PR_fd_set* set, PRInt16 flags,\n-          PRPollDesc* polldesc)\n-{\n-    PRUintn fsidx, pdidx;\n-    PRPollDesc* poll = polldesc;\n+#  define PD_INCR 20\n \n-    if (NULL == set) {\n-        return poll;\n-    }\n+static PRPollDesc* _pr_setfd(PR_fd_set* set, PRInt16 flags,\n+                             PRPollDesc* polldesc) {\n+  PRUintn fsidx, pdidx;\n+  PRPollDesc* poll = polldesc;\n \n-    /* First set the pr file handle osfds */\n-    for (fsidx = 0; fsidx < set->hsize; fsidx++) {\n-        for (pdidx = 0; 1; pdidx++) {\n-            if ((PRFileDesc*)-1 == poll[pdidx].fd) {\n-                /* our vector is full - extend and condition it */\n-                poll = (PRPollDesc*)PR_Realloc(\n-                    poll, (pdidx + 1 + PD_INCR) * sizeof(PRPollDesc));\n-                if (NULL == poll) {\n-                    goto out_of_memory;\n-                }\n-                memset(poll + pdidx * sizeof(PRPollDesc), 0,\n-                       PD_INCR * sizeof(PRPollDesc));\n-                poll[pdidx + PD_INCR].fd = (PRFileDesc*)-1;\n-            }\n-            if ((NULL == poll[pdidx].fd) || (poll[pdidx].fd == set->harray[fsidx])) {\n-                /* PR_ASSERT(0 == (poll[pdidx].in_flags & flags)); */\n-                /* either empty or prevously defined */\n-                poll[pdidx].fd = set->harray[fsidx]; /* possibly redundant */\n-                poll[pdidx].in_flags |= flags;       /* possibly redundant */\n-                break;\n-            }\n+  if (NULL == set) {\n+    return poll;\n+  }\n+\n+  /* First set the pr file handle osfds */\n+  for (fsidx = 0; fsidx < set->hsize; fsidx++) {\n+    for (pdidx = 0; 1; pdidx++) {\n+      if ((PRFileDesc*)-1 == poll[pdidx].fd) {\n+        /* our vector is full - extend and condition it */\n+        poll = (PRPollDesc*)PR_Realloc(\n+            poll, (pdidx + 1 + PD_INCR) * sizeof(PRPollDesc));\n+        if (NULL == poll) {\n+          goto out_of_memory;\n         }\n-    }\n-\n-#if 0\n+        memset(poll + pdidx * sizeof(PRPollDesc), 0,\n+               PD_INCR * sizeof(PRPollDesc));\n+        poll[pdidx + PD_INCR].fd = (PRFileDesc*)-1;\n+      }\n+      if ((NULL == poll[pdidx].fd) || (poll[pdidx].fd == set->harray[fsidx])) {\n+        /* PR_ASSERT(0 == (poll[pdidx].in_flags & flags)); */\n+        /* either empty or prevously defined */\n+        poll[pdidx].fd = set->harray[fsidx]; /* possibly redundant */\n+        poll[pdidx].in_flags |= flags;       /* possibly redundant */\n+        break;\n+      }\n+    }\n+  }\n+\n+#  if 0\n     /* Second set the native osfds */\n     for (fsidx = 0; fsidx < set->nsize; fsidx++)\n     {\n@@ -1921,118 +1816,117 @@ _pr_setfd(PR_fd_set* set, PRInt16 flags,\n             }\n         }\n     }\n-#endif /* 0 */\n+#  endif /* 0 */\n \n-    return poll;\n+  return poll;\n \n out_of_memory:\n-    if (NULL != polldesc) {\n-        PR_DELETE(polldesc);\n-    }\n-    return NULL;\n+  if (NULL != polldesc) {\n+    PR_DELETE(polldesc);\n+  }\n+  return NULL;\n } /* _pr_setfd */\n \n #endif /* !defined(NEED_SELECT) */\n \n PR_IMPLEMENT(PRInt32)\n PR_Select(PRInt32 unused, PR_fd_set* pr_rd, PR_fd_set* pr_wr, PR_fd_set* pr_ex,\n-          PRIntervalTime timeout)\n-{\n+          PRIntervalTime timeout) {\n #if !defined(NEED_SELECT)\n-    PRInt32 npds = 0;\n-    /*\n-    ** Find out how many fds are represented in the three lists.\n-    ** Then allocate a polling descriptor for the logical union\n-    ** (there can't be any overlapping) and call PR_Poll().\n-    */\n-\n-    PRPollDesc *copy, *poll;\n-\n-    static PRBool warning = PR_TRUE;\n-    if (warning) {\n-        warning = _PR_Obsolete(\"PR_Select()\", \"PR_Poll()\");\n-    }\n-\n-    /* try to get an initial guesss at how much space we need */\n-    npds = 0;\n-    if ((NULL != pr_rd) && ((pr_rd->hsize + pr_rd->nsize - npds) > 0)) {\n-        npds = pr_rd->hsize + pr_rd->nsize;\n-    }\n-    if ((NULL != pr_wr) && ((pr_wr->hsize + pr_wr->nsize - npds) > 0)) {\n-        npds = pr_wr->hsize + pr_wr->nsize;\n-    }\n-    if ((NULL != pr_ex) && ((pr_ex->hsize + pr_ex->nsize - npds) > 0)) {\n-        npds = pr_ex->hsize + pr_ex->nsize;\n-    }\n-\n-    if (0 == npds) {\n-        PR_Sleep(timeout);\n-        return 0;\n-    }\n-\n-    copy = poll = (PRPollDesc*)PR_Calloc(npds + PD_INCR, sizeof(PRPollDesc));\n-    if (NULL == poll) {\n-        goto out_of_memory;\n-    }\n-    poll[npds + PD_INCR - 1].fd = (PRFileDesc*)-1;\n-\n-    poll = _pr_setfd(pr_rd, PR_POLL_READ, poll);\n-    if (NULL == poll) {\n-        goto out_of_memory;\n-    }\n-    poll = _pr_setfd(pr_wr, PR_POLL_WRITE, poll);\n-    if (NULL == poll) {\n-        goto out_of_memory;\n-    }\n-    poll = _pr_setfd(pr_ex, PR_POLL_EXCEPT, poll);\n-    if (NULL == poll) {\n-        goto out_of_memory;\n-    }\n-    unused = 0;\n-    while (NULL != poll[unused].fd && (PRFileDesc*)-1 != poll[unused].fd) {\n-        ++unused;\n-    }\n-\n-    PR_ASSERT(unused > 0);\n-    npds = PR_Poll(poll, unused, timeout);\n-\n-    if (npds > 0) {\n-        /* Copy the results back into the fd sets */\n+  PRInt32 npds = 0;\n+  /*\n+  ** Find out how many fds are represented in the three lists.\n+  ** Then allocate a polling descriptor for the logical union\n+  ** (there can't be any overlapping) and call PR_Poll().\n+  */\n+\n+  PRPollDesc *copy, *poll;\n+\n+  static PRBool warning = PR_TRUE;\n+  if (warning) {\n+    warning = _PR_Obsolete(\"PR_Select()\", \"PR_Poll()\");\n+  }\n+\n+  /* try to get an initial guesss at how much space we need */\n+  npds = 0;\n+  if ((NULL != pr_rd) && ((pr_rd->hsize + pr_rd->nsize - npds) > 0)) {\n+    npds = pr_rd->hsize + pr_rd->nsize;\n+  }\n+  if ((NULL != pr_wr) && ((pr_wr->hsize + pr_wr->nsize - npds) > 0)) {\n+    npds = pr_wr->hsize + pr_wr->nsize;\n+  }\n+  if ((NULL != pr_ex) && ((pr_ex->hsize + pr_ex->nsize - npds) > 0)) {\n+    npds = pr_ex->hsize + pr_ex->nsize;\n+  }\n+\n+  if (0 == npds) {\n+    PR_Sleep(timeout);\n+    return 0;\n+  }\n+\n+  copy = poll = (PRPollDesc*)PR_Calloc(npds + PD_INCR, sizeof(PRPollDesc));\n+  if (NULL == poll) {\n+    goto out_of_memory;\n+  }\n+  poll[npds + PD_INCR - 1].fd = (PRFileDesc*)-1;\n+\n+  poll = _pr_setfd(pr_rd, PR_POLL_READ, poll);\n+  if (NULL == poll) {\n+    goto out_of_memory;\n+  }\n+  poll = _pr_setfd(pr_wr, PR_POLL_WRITE, poll);\n+  if (NULL == poll) {\n+    goto out_of_memory;\n+  }\n+  poll = _pr_setfd(pr_ex, PR_POLL_EXCEPT, poll);\n+  if (NULL == poll) {\n+    goto out_of_memory;\n+  }\n+  unused = 0;\n+  while (NULL != poll[unused].fd && (PRFileDesc*)-1 != poll[unused].fd) {\n+    ++unused;\n+  }\n+\n+  PR_ASSERT(unused > 0);\n+  npds = PR_Poll(poll, unused, timeout);\n+\n+  if (npds > 0) {\n+    /* Copy the results back into the fd sets */\n+    if (NULL != pr_rd) {\n+      pr_rd->nsize = pr_rd->hsize = 0;\n+    }\n+    if (NULL != pr_wr) {\n+      pr_wr->nsize = pr_wr->hsize = 0;\n+    }\n+    if (NULL != pr_ex) {\n+      pr_ex->nsize = pr_ex->hsize = 0;\n+    }\n+    for (copy = &poll[unused - 1]; copy >= poll; --copy) {\n+      if (copy->out_flags & PR_POLL_NVAL) {\n+        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n+        npds = -1;\n+        break;\n+      }\n+      if (copy->out_flags & PR_POLL_READ)\n         if (NULL != pr_rd) {\n-            pr_rd->nsize = pr_rd->hsize = 0;\n+          pr_rd->harray[pr_rd->hsize++] = copy->fd;\n         }\n+      if (copy->out_flags & PR_POLL_WRITE)\n         if (NULL != pr_wr) {\n-            pr_wr->nsize = pr_wr->hsize = 0;\n+          pr_wr->harray[pr_wr->hsize++] = copy->fd;\n         }\n+      if (copy->out_flags & PR_POLL_EXCEPT)\n         if (NULL != pr_ex) {\n-            pr_ex->nsize = pr_ex->hsize = 0;\n-        }\n-        for (copy = &poll[unused - 1]; copy >= poll; --copy) {\n-            if (copy->out_flags & PR_POLL_NVAL) {\n-                PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n-                npds = -1;\n-                break;\n-            }\n-            if (copy->out_flags & PR_POLL_READ)\n-                if (NULL != pr_rd) {\n-                    pr_rd->harray[pr_rd->hsize++] = copy->fd;\n-                }\n-            if (copy->out_flags & PR_POLL_WRITE)\n-                if (NULL != pr_wr) {\n-                    pr_wr->harray[pr_wr->hsize++] = copy->fd;\n-                }\n-            if (copy->out_flags & PR_POLL_EXCEPT)\n-                if (NULL != pr_ex) {\n-                    pr_ex->harray[pr_ex->hsize++] = copy->fd;\n-                }\n+          pr_ex->harray[pr_ex->hsize++] = copy->fd;\n         }\n     }\n-    PR_DELETE(poll);\n+  }\n+  PR_DELETE(poll);\n \n-    return npds;\n+  return npds;\n out_of_memory:\n-    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-    return -1;\n+  PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  return -1;\n \n #endif /* !defined(NEED_SELECT) */\n }\ndiff --git a/nspr/pr/src/io/prstdio.c b/nspr/pr/src/io/prstdio.c\nindex 4b095d9..7e5dab6 100644\n--- a/nspr/pr/src/io/prstdio.c\n+++ b/nspr/pr/src/io/prstdio.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,29 +10,26 @@\n /*\n ** fprintf to a PRFileDesc\n */\n-PR_IMPLEMENT(PRUint32)\n-PR_fprintf(PRFileDesc* fd, const char* fmt, ...)\n-{\n-    va_list ap;\n-    PRUint32 rv;\n+PR_IMPLEMENT(PRUint32) PR_fprintf(PRFileDesc* fd, const char* fmt, ...) {\n+  va_list ap;\n+  PRUint32 rv;\n \n-    va_start(ap, fmt);\n-    rv = PR_vfprintf(fd, fmt, ap);\n-    va_end(ap);\n-    return rv;\n+  va_start(ap, fmt);\n+  rv = PR_vfprintf(fd, fmt, ap);\n+  va_end(ap);\n+  return rv;\n }\n \n PR_IMPLEMENT(PRUint32)\n-PR_vfprintf(PRFileDesc* fd, const char* fmt, va_list ap)\n-{\n-    /* XXX this could be better */\n-    PRUint32 rv, len;\n-    char* msg = PR_vsmprintf(fmt, ap);\n-    if (NULL == msg) {\n-        return -1;\n-    }\n-    len = strlen(msg);\n-    rv = PR_Write(fd, msg, len);\n-    PR_DELETE(msg);\n-    return rv;\n+PR_vfprintf(PRFileDesc* fd, const char* fmt, va_list ap) {\n+  /* XXX this could be better */\n+  PRUint32 rv, len;\n+  char* msg = PR_vsmprintf(fmt, ap);\n+  if (NULL == msg) {\n+    return -1;\n+  }\n+  len = strlen(msg);\n+  rv = PR_Write(fd, msg, len);\n+  PR_DELETE(msg);\n+  return rv;\n }\ndiff --git a/nspr/pr/src/linking/.cvsignore b/nspr/pr/src/linking/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/src/linking/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/src/linking/prlink.c b/nspr/pr/src/linking/prlink.c\nindex 4045593..5124a17 100644\n--- a/nspr/pr/src/linking/prlink.c\n+++ b/nspr/pr/src/linking/prlink.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,30 +8,30 @@\n #include <string.h>\n \n #ifdef XP_UNIX\n-#ifdef USE_DLFCN\n-#include <dlfcn.h>\n+#  ifdef USE_DLFCN\n+#    include <dlfcn.h>\n /* Define these on systems that don't have them. */\n-#ifndef RTLD_NOW\n-#define RTLD_NOW 0\n-#endif\n-#ifndef RTLD_LAZY\n-#define RTLD_LAZY RTLD_NOW\n-#endif\n-#ifndef RTLD_GLOBAL\n-#define RTLD_GLOBAL 0\n-#endif\n-#ifndef RTLD_LOCAL\n-#define RTLD_LOCAL 0\n-#endif\n-#ifdef AIX\n-#include <sys/ldr.h>\n-#ifndef L_IGNOREUNLOAD /* AIX 4.3.3 does not have L_IGNOREUNLOAD. */\n-#define L_IGNOREUNLOAD 0x10000000\n-#endif\n-#endif\n-#elif defined(USE_HPSHL)\n-#include <dl.h>\n-#endif\n+#    ifndef RTLD_NOW\n+#      define RTLD_NOW 0\n+#    endif\n+#    ifndef RTLD_LAZY\n+#      define RTLD_LAZY RTLD_NOW\n+#    endif\n+#    ifndef RTLD_GLOBAL\n+#      define RTLD_GLOBAL 0\n+#    endif\n+#    ifndef RTLD_LOCAL\n+#      define RTLD_LOCAL 0\n+#    endif\n+#    ifdef AIX\n+#      include <sys/ldr.h>\n+#      ifndef L_IGNOREUNLOAD /* AIX 4.3.3 does not have L_IGNOREUNLOAD. */\n+#        define L_IGNOREUNLOAD 0x10000000\n+#      endif\n+#    endif\n+#  elif defined(USE_HPSHL)\n+#    include <dl.h>\n+#  endif\n #endif /* XP_UNIX */\n \n #define _PR_DEFAULT_LD_FLAGS PR_LD_LAZY\n@@ -39,7 +40,7 @@\n  * On these platforms, symbols have a leading '_'.\n  */\n #if ((defined(OPENBSD) || defined(NETBSD)) && !defined(__ELF__))\n-#define NEED_LEADING_UNDERSCORE\n+#  define NEED_LEADING_UNDERSCORE\n #endif\n \n #define PR_LD_PATHW 0x8000 /* for PR_LibSpec_PathnameU */\n@@ -47,21 +48,21 @@\n /************************************************************************/\n \n struct PRLibrary {\n-    char* name; /* Our own copy of the name string */\n-    PRLibrary* next;\n-    int refCount;\n-    const PRStaticLinkTable* staticTable;\n+  char* name; /* Our own copy of the name string */\n+  PRLibrary* next;\n+  int refCount;\n+  const PRStaticLinkTable* staticTable;\n \n #ifdef XP_PC\n-    HINSTANCE dlh;\n+  HINSTANCE dlh;\n #endif\n \n #ifdef XP_UNIX\n-#if defined(USE_HPSHL)\n-    shl_t dlh;\n-#else\n-    void* dlh;\n-#endif\n+#  if defined(USE_HPSHL)\n+  shl_t dlh;\n+#  else\n+  void* dlh;\n+#  endif\n #endif\n };\n \n@@ -75,96 +76,93 @@ static PRLibrary* pr_LoadLibraryByPathname(const char* name, PRIntn flags);\n /************************************************************************/\n \n #if !defined(USE_DLFCN) && !defined(HAVE_STRERROR)\n-#define ERR_STR_BUF_LENGTH 20\n+#  define ERR_STR_BUF_LENGTH 20\n #endif\n \n-static void\n-DLLErrorInternal(PRIntn oserr)\n+static void DLLErrorInternal(PRIntn oserr)\n /*\n ** This whole function, and most of the code in this file, are run\n ** with a big hairy lock wrapped around it. Not the best of situations,\n ** but will eventually come up with the right answer.\n */\n {\n-    const char* error = NULL;\n+  const char* error = NULL;\n #ifdef USE_DLFCN\n-    error = dlerror(); /* $$$ That'll be wrong some of the time - AOF */\n+  error = dlerror(); /* $$$ That'll be wrong some of the time - AOF */\n #elif defined(HAVE_STRERROR)\n-    error = strerror(oserr); /* this should be okay */\n+  error = strerror(oserr); /* this should be okay */\n #else\n-    char errStrBuf[ERR_STR_BUF_LENGTH];\n-    PR_snprintf(errStrBuf, sizeof(errStrBuf), \"error %d\", oserr);\n-    error = errStrBuf;\n+  char errStrBuf[ERR_STR_BUF_LENGTH];\n+  PR_snprintf(errStrBuf, sizeof(errStrBuf), \"error %d\", oserr);\n+  error = errStrBuf;\n #endif\n-    if (NULL != error) {\n-        PR_SetErrorText(strlen(error), error);\n-    }\n+  if (NULL != error) {\n+    PR_SetErrorText(strlen(error), error);\n+  }\n } /* DLLErrorInternal */\n \n-void\n-_PR_InitLinker(void)\n-{\n-    PRLibrary* lm = NULL;\n+void _PR_InitLinker(void) {\n+  PRLibrary* lm = NULL;\n #if defined(XP_UNIX)\n-    void* h;\n+  void* h;\n #endif\n \n-    if (!pr_linker_lock) {\n-        pr_linker_lock = PR_NewNamedMonitor(\"linker-lock\");\n-    }\n-    PR_EnterMonitor(pr_linker_lock);\n+  if (!pr_linker_lock) {\n+    pr_linker_lock = PR_NewNamedMonitor(\"linker-lock\");\n+  }\n+  PR_EnterMonitor(pr_linker_lock);\n \n #if defined(XP_PC)\n-    lm = PR_NEWZAP(PRLibrary);\n-    lm->name = strdup(\"Executable\");\n-    /* A module handle for the executable. */\n-    lm->dlh = GetModuleHandle(NULL);\n+  lm = PR_NEWZAP(PRLibrary);\n+  lm->name = strdup(\"Executable\");\n+  /* A module handle for the executable. */\n+  lm->dlh = GetModuleHandle(NULL);\n+\n+  lm->refCount = 1;\n+  lm->staticTable = NULL;\n+  pr_exe_loadmap = lm;\n+  pr_loadmap = lm;\n \n+#elif defined(XP_UNIX)\n+#  ifdef HAVE_DLL\n+#    if defined(USE_DLFCN) && !defined(NO_DLOPEN_NULL)\n+  h = dlopen(0, RTLD_LAZY);\n+  if (!h) {\n+    char* error;\n+\n+    DLLErrorInternal(_MD_ERRNO());\n+    error = (char*)PR_MALLOC(PR_GetErrorTextLength());\n+    (void)PR_GetErrorText(error);\n+    fprintf(stderr, \"failed to initialize shared libraries [%s]\\n\", error);\n+    PR_DELETE(error);\n+    abort(); /* XXX */\n+  }\n+#    elif defined(USE_HPSHL)\n+  h = NULL;\n+  /* don't abort with this NULL */\n+#    elif defined(NO_DLOPEN_NULL)\n+  h = NULL; /* XXXX  toshok */ /* XXXX  vlad */\n+#    else\n+#      error no dll strategy\n+#    endif /* USE_DLFCN */\n+\n+  lm = PR_NEWZAP(PRLibrary);\n+  if (lm) {\n+    lm->name = strdup(\"a.out\");\n     lm->refCount = 1;\n+    lm->dlh = h;\n     lm->staticTable = NULL;\n-    pr_exe_loadmap = lm;\n-    pr_loadmap = lm;\n+  }\n+  pr_exe_loadmap = lm;\n+  pr_loadmap = lm;\n+#  endif   /* HAVE_DLL */\n+#endif     /* XP_UNIX */\n \n-#elif defined(XP_UNIX)\n-#ifdef HAVE_DLL\n-#if defined(USE_DLFCN) && !defined(NO_DLOPEN_NULL)\n-    h = dlopen(0, RTLD_LAZY);\n-    if (!h) {\n-        char* error;\n-\n-        DLLErrorInternal(_MD_ERRNO());\n-        error = (char*)PR_MALLOC(PR_GetErrorTextLength());\n-        (void)PR_GetErrorText(error);\n-        fprintf(stderr, \"failed to initialize shared libraries [%s]\\n\", error);\n-        PR_DELETE(error);\n-        abort(); /* XXX */\n-    }\n-#elif defined(USE_HPSHL)\n-    h = NULL;\n-    /* don't abort with this NULL */\n-#elif defined(NO_DLOPEN_NULL)\n-    h = NULL; /* XXXX  toshok */ /* XXXX  vlad */\n-#else\n-#error no dll strategy\n-#endif /* USE_DLFCN */\n-\n-    lm = PR_NEWZAP(PRLibrary);\n-    if (lm) {\n-        lm->name = strdup(\"a.out\");\n-        lm->refCount = 1;\n-        lm->dlh = h;\n-        lm->staticTable = NULL;\n-    }\n-    pr_exe_loadmap = lm;\n-    pr_loadmap = lm;\n-#endif /* HAVE_DLL */\n-#endif /* XP_UNIX */\n+  if (lm) {\n+    PR_LOG(_pr_linker_lm, PR_LOG_MIN, (\"Loaded library %s (init)\", lm->name));\n+  }\n \n-    if (lm) {\n-        PR_LOG(_pr_linker_lm, PR_LOG_MIN, (\"Loaded library %s (init)\", lm->name));\n-    }\n-\n-    PR_ExitMonitor(pr_linker_lock);\n+  PR_ExitMonitor(pr_linker_lock);\n }\n \n /*\n@@ -174,154 +172,148 @@ _PR_InitLinker(void)\n  * The only exception is pr_exe_loadmap, which was added to the list by\n  * NSPR and hence should be cleaned up by NSPR.\n  */\n-void\n-_PR_ShutdownLinker(void)\n-{\n-    /* FIXME: pr_exe_loadmap should be destroyed. */\n+void _PR_ShutdownLinker(void) {\n+  /* FIXME: pr_exe_loadmap should be destroyed. */\n \n-    PR_DestroyMonitor(pr_linker_lock);\n-    pr_linker_lock = NULL;\n+  PR_DestroyMonitor(pr_linker_lock);\n+  pr_linker_lock = NULL;\n \n-    if (_pr_currentLibPath) {\n-        free(_pr_currentLibPath);\n-        _pr_currentLibPath = NULL;\n-    }\n+  if (_pr_currentLibPath) {\n+    free(_pr_currentLibPath);\n+    _pr_currentLibPath = NULL;\n+  }\n }\n \n /******************************************************************************/\n \n-PR_IMPLEMENT(PRStatus)\n-PR_SetLibraryPath(const char* path)\n-{\n-    PRStatus rv = PR_SUCCESS;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    PR_EnterMonitor(pr_linker_lock);\n-    if (_pr_currentLibPath) {\n-        free(_pr_currentLibPath);\n-    }\n-    if (path) {\n-        _pr_currentLibPath = strdup(path);\n-        if (!_pr_currentLibPath) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            rv = PR_FAILURE;\n-        }\n-    } else {\n-        _pr_currentLibPath = 0;\n-    }\n-    PR_ExitMonitor(pr_linker_lock);\n-    return rv;\n+PR_IMPLEMENT(PRStatus) PR_SetLibraryPath(const char* path) {\n+  PRStatus rv = PR_SUCCESS;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  PR_EnterMonitor(pr_linker_lock);\n+  if (_pr_currentLibPath) {\n+    free(_pr_currentLibPath);\n+  }\n+  if (path) {\n+    _pr_currentLibPath = strdup(path);\n+    if (!_pr_currentLibPath) {\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      rv = PR_FAILURE;\n+    }\n+  } else {\n+    _pr_currentLibPath = 0;\n+  }\n+  PR_ExitMonitor(pr_linker_lock);\n+  return rv;\n }\n \n /*\n ** Return the library path for finding shared libraries.\n */\n PR_IMPLEMENT(char*)\n-PR_GetLibraryPath(void)\n-{\n-    char* ev;\n-    char* copy = NULL; /* a copy of _pr_currentLibPath */\n+PR_GetLibraryPath(void) {\n+  char* ev;\n+  char* copy = NULL; /* a copy of _pr_currentLibPath */\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    PR_EnterMonitor(pr_linker_lock);\n-    if (_pr_currentLibPath != NULL) {\n-        goto exit;\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  PR_EnterMonitor(pr_linker_lock);\n+  if (_pr_currentLibPath != NULL) {\n+    goto exit;\n+  }\n \n-    /* initialize pr_currentLibPath */\n+  /* initialize pr_currentLibPath */\n \n #ifdef XP_PC\n-    ev = getenv(\"LD_LIBRARY_PATH\");\n-    if (!ev) {\n-        ev = \".;\\\\lib\";\n-    }\n-    ev = strdup(ev);\n+  ev = getenv(\"LD_LIBRARY_PATH\");\n+  if (!ev) {\n+    ev = \".;\\\\lib\";\n+  }\n+  ev = strdup(ev);\n #endif\n \n #if defined(XP_UNIX)\n-#if defined(USE_DLFCN)\n-    {\n-        char* p = NULL;\n-        int len;\n-\n-        ev = getenv(\"LD_LIBRARY_PATH\");\n-        if (!ev) {\n-            ev = \"/usr/lib:/lib\";\n-        }\n-        len = strlen(ev) + 1; /* +1 for the null */\n-\n-        p = (char*)malloc(len);\n-        if (p) {\n-            strcpy(p, ev);\n-        } /* if (p)  */\n-        ev = p;\n-        PR_LOG(_pr_io_lm, PR_LOG_NOTICE, (\"linker path '%s'\", ev));\n+#  if defined(USE_DLFCN)\n+  {\n+    char* p = NULL;\n+    int len;\n+\n+    ev = getenv(\"LD_LIBRARY_PATH\");\n+    if (!ev) {\n+      ev = \"/usr/lib:/lib\";\n     }\n-#else\n-    /* AFAIK there isn't a library path with the HP SHL interface --Rob */\n-    ev = strdup(\"\");\n-#endif\n+    len = strlen(ev) + 1; /* +1 for the null */\n+\n+    p = (char*)malloc(len);\n+    if (p) {\n+      strcpy(p, ev);\n+    } /* if (p)  */\n+    ev = p;\n+    PR_LOG(_pr_io_lm, PR_LOG_NOTICE, (\"linker path '%s'\", ev));\n+  }\n+#  else\n+  /* AFAIK there isn't a library path with the HP SHL interface --Rob */\n+  ev = strdup(\"\");\n+#  endif\n #endif\n \n-    /*\n-     * If ev is NULL, we have run out of memory\n-     */\n-    _pr_currentLibPath = ev;\n+  /*\n+   * If ev is NULL, we have run out of memory\n+   */\n+  _pr_currentLibPath = ev;\n \n exit:\n-    if (_pr_currentLibPath) {\n-        copy = strdup(_pr_currentLibPath);\n-    }\n-    PR_ExitMonitor(pr_linker_lock);\n-    if (!copy) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-    }\n-    return copy;\n+  if (_pr_currentLibPath) {\n+    copy = strdup(_pr_currentLibPath);\n+  }\n+  PR_ExitMonitor(pr_linker_lock);\n+  if (!copy) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  }\n+  return copy;\n }\n \n /*\n ** Build library name from path, lib and extensions\n */\n PR_IMPLEMENT(char*)\n-PR_GetLibraryName(const char* path, const char* lib)\n-{\n-    char* fullname;\n+PR_GetLibraryName(const char* path, const char* lib) {\n+  char* fullname;\n \n #ifdef XP_PC\n-    if (strstr(lib, PR_DLL_SUFFIX) == NULL) {\n-        if (path) {\n-            fullname = PR_smprintf(\"%s\\\\%s%s\", path, lib, PR_DLL_SUFFIX);\n-        } else {\n-            fullname = PR_smprintf(\"%s%s\", lib, PR_DLL_SUFFIX);\n-        }\n+  if (strstr(lib, PR_DLL_SUFFIX) == NULL) {\n+    if (path) {\n+      fullname = PR_smprintf(\"%s\\\\%s%s\", path, lib, PR_DLL_SUFFIX);\n+    } else {\n+      fullname = PR_smprintf(\"%s%s\", lib, PR_DLL_SUFFIX);\n+    }\n+  } else {\n+    if (path) {\n+      fullname = PR_smprintf(\"%s\\\\%s\", path, lib);\n     } else {\n-        if (path) {\n-            fullname = PR_smprintf(\"%s\\\\%s\", path, lib);\n-        } else {\n-            fullname = PR_smprintf(\"%s\", lib);\n-        }\n+      fullname = PR_smprintf(\"%s\", lib);\n     }\n+  }\n #endif /* XP_PC */\n #if defined(XP_UNIX)\n-    if (strstr(lib, PR_DLL_SUFFIX) == NULL) {\n-        if (path) {\n-            fullname = PR_smprintf(\"%s/lib%s%s\", path, lib, PR_DLL_SUFFIX);\n-        } else {\n-            fullname = PR_smprintf(\"lib%s%s\", lib, PR_DLL_SUFFIX);\n-        }\n+  if (strstr(lib, PR_DLL_SUFFIX) == NULL) {\n+    if (path) {\n+      fullname = PR_smprintf(\"%s/lib%s%s\", path, lib, PR_DLL_SUFFIX);\n+    } else {\n+      fullname = PR_smprintf(\"lib%s%s\", lib, PR_DLL_SUFFIX);\n+    }\n+  } else {\n+    if (path) {\n+      fullname = PR_smprintf(\"%s/%s\", path, lib);\n     } else {\n-        if (path) {\n-            fullname = PR_smprintf(\"%s/%s\", path, lib);\n-        } else {\n-            fullname = PR_smprintf(\"%s\", lib);\n-        }\n+      fullname = PR_smprintf(\"%s\", lib);\n     }\n+  }\n #endif /* XP_UNIX */\n-    return fullname;\n+  return fullname;\n }\n \n /*\n@@ -330,517 +322,504 @@ PR_GetLibraryName(const char* path, const char* lib)\n PR_IMPLEMENT(void)\n PR_FreeLibraryName(char* mem) { PR_smprintf_free(mem); }\n \n-static PRLibrary*\n-pr_UnlockedFindLibrary(const char* name)\n-{\n-    PRLibrary* lm = pr_loadmap;\n-    const char* np = strrchr(name, PR_DIRECTORY_SEPARATOR);\n-    np = np ? np + 1 : name;\n-    while (lm) {\n-        const char* cp = strrchr(lm->name, PR_DIRECTORY_SEPARATOR);\n-        cp = cp ? cp + 1 : lm->name;\n+static PRLibrary* pr_UnlockedFindLibrary(const char* name) {\n+  PRLibrary* lm = pr_loadmap;\n+  const char* np = strrchr(name, PR_DIRECTORY_SEPARATOR);\n+  np = np ? np + 1 : name;\n+  while (lm) {\n+    const char* cp = strrchr(lm->name, PR_DIRECTORY_SEPARATOR);\n+    cp = cp ? cp + 1 : lm->name;\n #ifdef WIN32\n-        /* Windows DLL names are case insensitive... */\n-        if (strcmpi(np, cp) == 0)\n+    /* Windows DLL names are case insensitive... */\n+    if (strcmpi(np, cp) == 0)\n #else\n-        if (strcmp(np, cp) == 0)\n+    if (strcmp(np, cp) == 0)\n #endif\n-        {\n-            /* found */\n-            lm->refCount++;\n-            PR_LOG(_pr_linker_lm, PR_LOG_MIN,\n-                   (\"%s incr => %d (find lib)\", lm->name, lm->refCount));\n-            return lm;\n-        }\n-        lm = lm->next;\n-    }\n-    return NULL;\n+    {\n+      /* found */\n+      lm->refCount++;\n+      PR_LOG(_pr_linker_lm, PR_LOG_MIN,\n+             (\"%s incr => %d (find lib)\", lm->name, lm->refCount));\n+      return lm;\n+    }\n+    lm = lm->next;\n+  }\n+  return NULL;\n }\n \n PR_IMPLEMENT(PRLibrary*)\n-PR_LoadLibraryWithFlags(PRLibSpec libSpec, PRIntn flags)\n-{\n-    if (flags == 0) {\n-        flags = _PR_DEFAULT_LD_FLAGS;\n-    }\n-    switch (libSpec.type) {\n-        case PR_LibSpec_Pathname:\n-            return pr_LoadLibraryByPathname(libSpec.value.pathname, flags);\n+PR_LoadLibraryWithFlags(PRLibSpec libSpec, PRIntn flags) {\n+  if (flags == 0) {\n+    flags = _PR_DEFAULT_LD_FLAGS;\n+  }\n+  switch (libSpec.type) {\n+    case PR_LibSpec_Pathname:\n+      return pr_LoadLibraryByPathname(libSpec.value.pathname, flags);\n #ifdef WIN32\n-        case PR_LibSpec_PathnameU:\n-            /*\n-             * cast to |char *| and set PR_LD_PATHW flag so that\n-             * it can be cast back to PRUnichar* in the callee.\n-             */\n-            return pr_LoadLibraryByPathname((const char*)libSpec.value.pathname_u,\n-                                            flags | PR_LD_PATHW);\n-#endif\n-        default:\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            return NULL;\n-    }\n+    case PR_LibSpec_PathnameU:\n+      /*\n+       * cast to |char *| and set PR_LD_PATHW flag so that\n+       * it can be cast back to PRUnichar* in the callee.\n+       */\n+      return pr_LoadLibraryByPathname((const char*)libSpec.value.pathname_u,\n+                                      flags | PR_LD_PATHW);\n+#endif\n+    default:\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      return NULL;\n+  }\n }\n \n PR_IMPLEMENT(PRLibrary*)\n-PR_LoadLibrary(const char* name)\n-{\n-    PRLibSpec libSpec;\n+PR_LoadLibrary(const char* name) {\n+  PRLibSpec libSpec;\n \n-    libSpec.type = PR_LibSpec_Pathname;\n-    libSpec.value.pathname = name;\n-    return PR_LoadLibraryWithFlags(libSpec, 0);\n+  libSpec.type = PR_LibSpec_Pathname;\n+  libSpec.value.pathname = name;\n+  return PR_LoadLibraryWithFlags(libSpec, 0);\n }\n \n /*\n ** Dynamically load a library. Only load libraries once, so scan the load\n ** map first.\n */\n-static PRLibrary*\n-pr_LoadLibraryByPathname(const char* name, PRIntn flags)\n-{\n-    PRLibrary* lm;\n-    PRLibrary* result = NULL;\n-    PRInt32 oserr;\n+static PRLibrary* pr_LoadLibraryByPathname(const char* name, PRIntn flags) {\n+  PRLibrary* lm;\n+  PRLibrary* result = NULL;\n+  PRInt32 oserr;\n #ifdef WIN32\n-    char utf8name_stack[MAX_PATH];\n-    char* utf8name_malloc = NULL;\n-    char* utf8name = utf8name_stack;\n-    PRUnichar wname_stack[MAX_PATH];\n-    PRUnichar* wname_malloc = NULL;\n-    PRUnichar* wname = wname_stack;\n-    int len;\n+  char utf8name_stack[MAX_PATH];\n+  char* utf8name_malloc = NULL;\n+  char* utf8name = utf8name_stack;\n+  PRUnichar wname_stack[MAX_PATH];\n+  PRUnichar* wname_malloc = NULL;\n+  PRUnichar* wname = wname_stack;\n+  int len;\n #endif\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    /* See if library is already loaded */\n-    PR_EnterMonitor(pr_linker_lock);\n+  /* See if library is already loaded */\n+  PR_EnterMonitor(pr_linker_lock);\n \n #ifdef WIN32\n-    if (flags & PR_LD_PATHW) {\n-        /* cast back what's cast to |char *| for the argument passing. */\n-        wname = (LPWSTR)name;\n-    } else {\n-        int wlen = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0);\n-        if (wlen > MAX_PATH) {\n-            wname = wname_malloc = PR_Malloc(wlen * sizeof(PRUnichar));\n-        }\n-        if (wname == NULL ||\n-            !MultiByteToWideChar(CP_ACP, 0, name, -1, wname, wlen)) {\n-            oserr = _MD_ERRNO();\n-            goto unlock;\n-        }\n-    }\n-    len = WideCharToMultiByte(CP_UTF8, 0, wname, -1, NULL, 0, NULL, NULL);\n-    if (len > MAX_PATH) {\n-        utf8name = utf8name_malloc = PR_Malloc(len);\n-    }\n-    if (utf8name == NULL ||\n-        !WideCharToMultiByte(CP_UTF8, 0, wname, -1, utf8name, len, NULL, NULL)) {\n-        oserr = _MD_ERRNO();\n-        goto unlock;\n-    }\n-    /* the list of loaded library names are always kept in UTF-8\n-     * on Win32 platforms */\n-    result = pr_UnlockedFindLibrary(utf8name);\n+  if (flags & PR_LD_PATHW) {\n+    /* cast back what's cast to |char *| for the argument passing. */\n+    wname = (LPWSTR)name;\n+  } else {\n+    int wlen = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0);\n+    if (wlen > MAX_PATH) {\n+      wname = wname_malloc = PR_Malloc(wlen * sizeof(PRUnichar));\n+    }\n+    if (wname == NULL ||\n+        !MultiByteToWideChar(CP_ACP, 0, name, -1, wname, wlen)) {\n+      oserr = _MD_ERRNO();\n+      goto unlock;\n+    }\n+  }\n+  len = WideCharToMultiByte(CP_UTF8, 0, wname, -1, NULL, 0, NULL, NULL);\n+  if (len > MAX_PATH) {\n+    utf8name = utf8name_malloc = PR_Malloc(len);\n+  }\n+  if (utf8name == NULL ||\n+      !WideCharToMultiByte(CP_UTF8, 0, wname, -1, utf8name, len, NULL, NULL)) {\n+    oserr = _MD_ERRNO();\n+    goto unlock;\n+  }\n+  /* the list of loaded library names are always kept in UTF-8\n+   * on Win32 platforms */\n+  result = pr_UnlockedFindLibrary(utf8name);\n #else\n-    result = pr_UnlockedFindLibrary(name);\n+  result = pr_UnlockedFindLibrary(name);\n #endif\n \n-    if (result != NULL) {\n-        goto unlock;\n-    }\n+  if (result != NULL) {\n+    goto unlock;\n+  }\n \n-    lm = PR_NEWZAP(PRLibrary);\n-    if (lm == NULL) {\n-        oserr = _MD_ERRNO();\n-        goto unlock;\n-    }\n-    lm->staticTable = NULL;\n+  lm = PR_NEWZAP(PRLibrary);\n+  if (lm == NULL) {\n+    oserr = _MD_ERRNO();\n+    goto unlock;\n+  }\n+  lm->staticTable = NULL;\n \n #ifdef WIN32\n-    {\n-        HINSTANCE h;\n-\n-        h = LoadLibraryExW(\n-            wname, NULL,\n-            (flags & PR_LD_ALT_SEARCH_PATH) ? LOAD_WITH_ALTERED_SEARCH_PATH : 0);\n-        if (h == NULL) {\n-            oserr = _MD_ERRNO();\n-            PR_DELETE(lm);\n-            goto unlock;\n-        }\n-        lm->name = strdup(utf8name);\n-        lm->dlh = h;\n-        lm->next = pr_loadmap;\n-        pr_loadmap = lm;\n-    }\n+  {\n+    HINSTANCE h;\n+\n+    h = LoadLibraryExW(\n+        wname, NULL,\n+        (flags & PR_LD_ALT_SEARCH_PATH) ? LOAD_WITH_ALTERED_SEARCH_PATH : 0);\n+    if (h == NULL) {\n+      oserr = _MD_ERRNO();\n+      PR_DELETE(lm);\n+      goto unlock;\n+    }\n+    lm->name = strdup(utf8name);\n+    lm->dlh = h;\n+    lm->next = pr_loadmap;\n+    pr_loadmap = lm;\n+  }\n #endif /* WIN32 */\n \n #if defined(XP_UNIX)\n-#ifdef HAVE_DLL\n-    {\n-#if defined(USE_DLFCN)\n-#ifdef NTO\n-        /* Neutrino needs RTLD_GROUP to load Netscape plugins. (bug 71179) */\n-        int dl_flags = RTLD_GROUP;\n-#elif defined(AIX)\n-        /* AIX needs RTLD_MEMBER to load an archive member.  (bug 228899) */\n-        int dl_flags = RTLD_MEMBER;\n-#else\n-        int dl_flags = 0;\n-#endif\n-        void* h = NULL;\n-#if defined(DARWIN)\n-        PRBool okToLoad = PR_FALSE;\n-#endif\n+#  ifdef HAVE_DLL\n+  {\n+#    if defined(USE_DLFCN)\n+#      ifdef NTO\n+    /* Neutrino needs RTLD_GROUP to load Netscape plugins. (bug 71179) */\n+    int dl_flags = RTLD_GROUP;\n+#      elif defined(AIX)\n+    /* AIX needs RTLD_MEMBER to load an archive member.  (bug 228899) */\n+    int dl_flags = RTLD_MEMBER;\n+#      else\n+    int dl_flags = 0;\n+#      endif\n+    void* h = NULL;\n+#      if defined(DARWIN)\n+    PRBool okToLoad = PR_FALSE;\n+#      endif\n+\n+    if (flags & PR_LD_LAZY) {\n+      dl_flags |= RTLD_LAZY;\n+    }\n+    if (flags & PR_LD_NOW) {\n+      dl_flags |= RTLD_NOW;\n+    }\n+    if (flags & PR_LD_GLOBAL) {\n+      dl_flags |= RTLD_GLOBAL;\n+    }\n+    if (flags & PR_LD_LOCAL) {\n+      dl_flags |= RTLD_LOCAL;\n+    }\n+#      if defined(DARWIN)\n+    /* If the file contains an absolute or relative path (slash)\n+     * and the path doesn't look like a System path, then require\n+     * the file exists.\n+     * The reason is that DARWIN's dlopen ignores the provided path\n+     * and checks for the plain filename in DYLD_LIBRARY_PATH,\n+     * which could load an unexpected version of a library. */\n+    if (strchr(name, PR_DIRECTORY_SEPARATOR) == NULL) {\n+      /* no slash, allow to load from any location */\n+      okToLoad = PR_TRUE;\n+    } else {\n+      const char systemPrefix1[] = \"/System/\";\n+      const size_t systemPrefixLen1 = strlen(systemPrefix1);\n+      const char systemPrefix2[] = \"/usr/lib/\";\n+      const size_t systemPrefixLen2 = strlen(systemPrefix2);\n+      const size_t name_len = strlen(name);\n+      if (((name_len > systemPrefixLen1) &&\n+           (strncmp(name, systemPrefix1, systemPrefixLen1) == 0)) ||\n+          ((name_len > systemPrefixLen2) &&\n+           (strncmp(name, systemPrefix2, systemPrefixLen2) == 0))) {\n+        /* found at beginning, it's a system library.\n+         * Skip filesystem check (required for macOS 11),\n+         * allow loading from any location */\n+        okToLoad = PR_TRUE;\n+      } else if (PR_Access(name, PR_ACCESS_EXISTS) == PR_SUCCESS) {\n+        /* file exists, allow to load */\n+        okToLoad = PR_TRUE;\n+      }\n+    }\n+    if (okToLoad) {\n+      h = dlopen(name, dl_flags);\n+    }\n+#      else\n+    h = dlopen(name, dl_flags);\n+#      endif\n+#    elif defined(USE_HPSHL)\n+    int shl_flags = 0;\n+    shl_t h;\n \n-        if (flags & PR_LD_LAZY) {\n-            dl_flags |= RTLD_LAZY;\n-        }\n-        if (flags & PR_LD_NOW) {\n-            dl_flags |= RTLD_NOW;\n-        }\n-        if (flags & PR_LD_GLOBAL) {\n-            dl_flags |= RTLD_GLOBAL;\n-        }\n-        if (flags & PR_LD_LOCAL) {\n-            dl_flags |= RTLD_LOCAL;\n-        }\n-#if defined(DARWIN)\n-        /* If the file contains an absolute or relative path (slash)\n-         * and the path doesn't look like a System path, then require\n-         * the file exists.\n-         * The reason is that DARWIN's dlopen ignores the provided path\n-         * and checks for the plain filename in DYLD_LIBRARY_PATH,\n-         * which could load an unexpected version of a library. */\n-        if (strchr(name, PR_DIRECTORY_SEPARATOR) == NULL) {\n-            /* no slash, allow to load from any location */\n-            okToLoad = PR_TRUE;\n-        } else {\n-            const char systemPrefix1[] = \"/System/\";\n-            const size_t systemPrefixLen1 = strlen(systemPrefix1);\n-            const char systemPrefix2[] = \"/usr/lib/\";\n-            const size_t systemPrefixLen2 = strlen(systemPrefix2);\n-            const size_t name_len = strlen(name);\n-            if (((name_len > systemPrefixLen1) &&\n-                 (strncmp(name, systemPrefix1, systemPrefixLen1) == 0)) ||\n-                ((name_len > systemPrefixLen2) &&\n-                 (strncmp(name, systemPrefix2, systemPrefixLen2) == 0))) {\n-                /* found at beginning, it's a system library.\n-                 * Skip filesystem check (required for macOS 11),\n-                 * allow loading from any location */\n-                okToLoad = PR_TRUE;\n-            } else if (PR_Access(name, PR_ACCESS_EXISTS) == PR_SUCCESS) {\n-                /* file exists, allow to load */\n-                okToLoad = PR_TRUE;\n-            }\n-        }\n-        if (okToLoad) {\n-            h = dlopen(name, dl_flags);\n-        }\n-#else\n-        h = dlopen(name, dl_flags);\n-#endif\n-#elif defined(USE_HPSHL)\n-        int shl_flags = 0;\n-        shl_t h;\n-\n-        /*\n-         * Use the DYNAMIC_PATH flag only if 'name' is a plain file\n-         * name (containing no directory) to match the behavior of\n-         * dlopen().\n-         */\n-        if (strchr(name, PR_DIRECTORY_SEPARATOR) == NULL) {\n-            shl_flags |= DYNAMIC_PATH;\n-        }\n-        if (flags & PR_LD_LAZY) {\n-            shl_flags |= BIND_DEFERRED;\n-        }\n-        if (flags & PR_LD_NOW) {\n-            shl_flags |= BIND_IMMEDIATE;\n-        }\n-        /* No equivalent of PR_LD_GLOBAL and PR_LD_LOCAL. */\n-        h = shl_load(name, shl_flags, 0L);\n-#else\n-#error Configuration error\n-#endif\n-        if (!h) {\n-            oserr = _MD_ERRNO();\n-            PR_DELETE(lm);\n-            goto unlock;\n-        }\n-        lm->name = strdup(name);\n-        lm->dlh = h;\n-        lm->next = pr_loadmap;\n-        pr_loadmap = lm;\n+    /*\n+     * Use the DYNAMIC_PATH flag only if 'name' is a plain file\n+     * name (containing no directory) to match the behavior of\n+     * dlopen().\n+     */\n+    if (strchr(name, PR_DIRECTORY_SEPARATOR) == NULL) {\n+      shl_flags |= DYNAMIC_PATH;\n     }\n-#endif /* HAVE_DLL */\n-#endif /* XP_UNIX */\n+    if (flags & PR_LD_LAZY) {\n+      shl_flags |= BIND_DEFERRED;\n+    }\n+    if (flags & PR_LD_NOW) {\n+      shl_flags |= BIND_IMMEDIATE;\n+    }\n+    /* No equivalent of PR_LD_GLOBAL and PR_LD_LOCAL. */\n+    h = shl_load(name, shl_flags, 0L);\n+#    else\n+#      error Configuration error\n+#    endif\n+    if (!h) {\n+      oserr = _MD_ERRNO();\n+      PR_DELETE(lm);\n+      goto unlock;\n+    }\n+    lm->name = strdup(name);\n+    lm->dlh = h;\n+    lm->next = pr_loadmap;\n+    pr_loadmap = lm;\n+  }\n+#  endif /* HAVE_DLL */\n+#endif   /* XP_UNIX */\n \n-    lm->refCount = 1;\n+  lm->refCount = 1;\n \n-    result = lm; /* success */\n-    PR_LOG(_pr_linker_lm, PR_LOG_MIN, (\"Loaded library %s (load lib)\", lm->name));\n+  result = lm; /* success */\n+  PR_LOG(_pr_linker_lm, PR_LOG_MIN, (\"Loaded library %s (load lib)\", lm->name));\n \n unlock:\n-    if (result == NULL) {\n-        PR_SetError(PR_LOAD_LIBRARY_ERROR, oserr);\n-        DLLErrorInternal(oserr); /* sets error text */\n-    }\n+  if (result == NULL) {\n+    PR_SetError(PR_LOAD_LIBRARY_ERROR, oserr);\n+    DLLErrorInternal(oserr); /* sets error text */\n+  }\n #ifdef WIN32\n-    if (utf8name_malloc) {\n-        PR_Free(utf8name_malloc);\n-    }\n-    if (wname_malloc) {\n-        PR_Free(wname_malloc);\n-    }\n-#endif\n-    PR_ExitMonitor(pr_linker_lock);\n-    return result;\n+  if (utf8name_malloc) {\n+    PR_Free(utf8name_malloc);\n+  }\n+  if (wname_malloc) {\n+    PR_Free(wname_malloc);\n+  }\n+#endif\n+  PR_ExitMonitor(pr_linker_lock);\n+  return result;\n }\n \n /*\n ** Unload a shared library which was loaded via PR_LoadLibrary\n */\n PR_IMPLEMENT(PRStatus)\n-PR_UnloadLibrary(PRLibrary* lib)\n-{\n-    int result = 0;\n-    PRStatus status = PR_SUCCESS;\n+PR_UnloadLibrary(PRLibrary* lib) {\n+  int result = 0;\n+  PRStatus status = PR_SUCCESS;\n \n-    if (lib == 0) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (lib == 0) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-    PR_EnterMonitor(pr_linker_lock);\n+  PR_EnterMonitor(pr_linker_lock);\n \n-    if (lib->refCount <= 0) {\n-        PR_ExitMonitor(pr_linker_lock);\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (lib->refCount <= 0) {\n+    PR_ExitMonitor(pr_linker_lock);\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-    if (--lib->refCount > 0) {\n-        PR_LOG(_pr_linker_lm, PR_LOG_MIN,\n-               (\"%s decr => %d\", lib->name, lib->refCount));\n-        goto done;\n-    }\n+  if (--lib->refCount > 0) {\n+    PR_LOG(_pr_linker_lm, PR_LOG_MIN,\n+           (\"%s decr => %d\", lib->name, lib->refCount));\n+    goto done;\n+  }\n \n #ifdef XP_UNIX\n-#ifdef HAVE_DLL\n-#ifdef USE_DLFCN\n-    result = dlclose(lib->dlh);\n-#elif defined(USE_HPSHL)\n-    result = shl_unload(lib->dlh);\n-#else\n-#error Configuration error\n-#endif\n-#endif /* HAVE_DLL */\n-#endif /* XP_UNIX */\n+#  ifdef HAVE_DLL\n+#    ifdef USE_DLFCN\n+  result = dlclose(lib->dlh);\n+#    elif defined(USE_HPSHL)\n+  result = shl_unload(lib->dlh);\n+#    else\n+#      error Configuration error\n+#    endif\n+#  endif /* HAVE_DLL */\n+#endif   /* XP_UNIX */\n #ifdef XP_PC\n-    if (lib->dlh) {\n-        FreeLibrary((HINSTANCE)(lib->dlh));\n-        lib->dlh = (HINSTANCE)NULL;\n-    }\n+  if (lib->dlh) {\n+    FreeLibrary((HINSTANCE)(lib->dlh));\n+    lib->dlh = (HINSTANCE)NULL;\n+  }\n #endif /* XP_PC */\n \n-    /* unlink from library search list */\n-    if (pr_loadmap == lib) {\n-        pr_loadmap = pr_loadmap->next;\n-    } else if (pr_loadmap != NULL) {\n-        PRLibrary* prev = pr_loadmap;\n-        PRLibrary* next = pr_loadmap->next;\n-        while (next != NULL) {\n-            if (next == lib) {\n-                prev->next = next->next;\n-                goto freeLib;\n-            }\n-            prev = next;\n-            next = next->next;\n-        }\n-        /*\n-         * fail (the library is not on the _pr_loadmap list),\n-         * but don't wipe out an error from dlclose/shl_unload.\n-         */\n-        PR_NOT_REACHED(\"_pr_loadmap and lib->refCount inconsistent\");\n-        if (result == 0) {\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            status = PR_FAILURE;\n-        }\n+  /* unlink from library search list */\n+  if (pr_loadmap == lib) {\n+    pr_loadmap = pr_loadmap->next;\n+  } else if (pr_loadmap != NULL) {\n+    PRLibrary* prev = pr_loadmap;\n+    PRLibrary* next = pr_loadmap->next;\n+    while (next != NULL) {\n+      if (next == lib) {\n+        prev->next = next->next;\n+        goto freeLib;\n+      }\n+      prev = next;\n+      next = next->next;\n     }\n     /*\n-     * We free the PRLibrary structure whether dlclose/shl_unload\n-     * succeeds or not.\n+     * fail (the library is not on the _pr_loadmap list),\n+     * but don't wipe out an error from dlclose/shl_unload.\n      */\n+    PR_NOT_REACHED(\"_pr_loadmap and lib->refCount inconsistent\");\n+    if (result == 0) {\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      status = PR_FAILURE;\n+    }\n+  }\n+  /*\n+   * We free the PRLibrary structure whether dlclose/shl_unload\n+   * succeeds or not.\n+   */\n \n freeLib:\n-    PR_LOG(_pr_linker_lm, PR_LOG_MIN, (\"Unloaded library %s\", lib->name));\n-    free(lib->name);\n-    lib->name = NULL;\n-    PR_DELETE(lib);\n-    if (result != 0) {\n-        PR_SetError(PR_UNLOAD_LIBRARY_ERROR, _MD_ERRNO());\n-        DLLErrorInternal(_MD_ERRNO());\n-        status = PR_FAILURE;\n-    }\n+  PR_LOG(_pr_linker_lm, PR_LOG_MIN, (\"Unloaded library %s\", lib->name));\n+  free(lib->name);\n+  lib->name = NULL;\n+  PR_DELETE(lib);\n+  if (result != 0) {\n+    PR_SetError(PR_UNLOAD_LIBRARY_ERROR, _MD_ERRNO());\n+    DLLErrorInternal(_MD_ERRNO());\n+    status = PR_FAILURE;\n+  }\n \n done:\n-    PR_ExitMonitor(pr_linker_lock);\n-    return status;\n+  PR_ExitMonitor(pr_linker_lock);\n+  return status;\n }\n \n-static void*\n-pr_FindSymbolInLib(PRLibrary* lm, const char* name)\n-{\n-    void* f = NULL;\n-\n-    if (lm->staticTable != NULL) {\n-        const PRStaticLinkTable* tp;\n-        for (tp = lm->staticTable; tp->name; tp++) {\n-            if (strcmp(name, tp->name) == 0) {\n-                return (void*)tp->fp;\n-            }\n-        }\n-        /*\n-        ** If the symbol was not found in the static table then check if\n-        ** the symbol was exported in the DLL...\n-        */\n-        PR_SetError(PR_FIND_SYMBOL_ERROR, 0);\n-        return (void*)NULL;\n+static void* pr_FindSymbolInLib(PRLibrary* lm, const char* name) {\n+  void* f = NULL;\n+\n+  if (lm->staticTable != NULL) {\n+    const PRStaticLinkTable* tp;\n+    for (tp = lm->staticTable; tp->name; tp++) {\n+      if (strcmp(name, tp->name) == 0) {\n+        return (void*)tp->fp;\n+      }\n     }\n+    /*\n+    ** If the symbol was not found in the static table then check if\n+    ** the symbol was exported in the DLL...\n+    */\n+    PR_SetError(PR_FIND_SYMBOL_ERROR, 0);\n+    return (void*)NULL;\n+  }\n \n #ifdef WIN32\n-    f = GetProcAddress(lm->dlh, name);\n+  f = GetProcAddress(lm->dlh, name);\n #endif /* WIN32 */\n \n #ifdef XP_UNIX\n-#ifdef HAVE_DLL\n-#ifdef USE_DLFCN\n-    f = dlsym(lm->dlh, name);\n-#elif defined(USE_HPSHL)\n-    if (shl_findsym(&lm->dlh, name, TYPE_PROCEDURE, &f) == -1) {\n-        f = NULL;\n-    }\n-#endif\n-#endif /* HAVE_DLL */\n-#endif /* XP_UNIX */\n-    if (f == NULL) {\n-        PR_SetError(PR_FIND_SYMBOL_ERROR, _MD_ERRNO());\n-        DLLErrorInternal(_MD_ERRNO());\n-    }\n-    return f;\n+#  ifdef HAVE_DLL\n+#    ifdef USE_DLFCN\n+  f = dlsym(lm->dlh, name);\n+#    elif defined(USE_HPSHL)\n+  if (shl_findsym(&lm->dlh, name, TYPE_PROCEDURE, &f) == -1) {\n+    f = NULL;\n+  }\n+#    endif\n+#  endif /* HAVE_DLL */\n+#endif   /* XP_UNIX */\n+  if (f == NULL) {\n+    PR_SetError(PR_FIND_SYMBOL_ERROR, _MD_ERRNO());\n+    DLLErrorInternal(_MD_ERRNO());\n+  }\n+  return f;\n }\n \n /*\n ** Called by class loader to resolve missing native's\n */\n PR_IMPLEMENT(void*)\n-PR_FindSymbol(PRLibrary* lib, const char* raw_name)\n-{\n-    void* f = NULL;\n+PR_FindSymbol(PRLibrary* lib, const char* raw_name) {\n+  void* f = NULL;\n #if defined(NEED_LEADING_UNDERSCORE)\n-    char* name;\n+  char* name;\n #else\n-    const char* name;\n+  const char* name;\n #endif\n-    /*\n-    ** Mangle the raw symbol name in any way that is platform specific.\n-    */\n+  /*\n+  ** Mangle the raw symbol name in any way that is platform specific.\n+  */\n #if defined(NEED_LEADING_UNDERSCORE)\n-    /* Need a leading _ */\n-    name = PR_smprintf(\"_%s\", raw_name);\n+  /* Need a leading _ */\n+  name = PR_smprintf(\"_%s\", raw_name);\n #elif defined(AIX)\n-    /*\n-    ** AIX with the normal linker put's a \".\" in front of the symbol\n-    ** name.  When use \"svcc\" and \"svld\" then the \".\" disappears. Go\n-    ** figure.\n-    */\n-    name = raw_name;\n+  /*\n+  ** AIX with the normal linker put's a \".\" in front of the symbol\n+  ** name.  When use \"svcc\" and \"svld\" then the \".\" disappears. Go\n+  ** figure.\n+  */\n+  name = raw_name;\n #else\n-    name = raw_name;\n+  name = raw_name;\n #endif\n \n-    PR_EnterMonitor(pr_linker_lock);\n-    PR_ASSERT(lib != NULL);\n-    f = pr_FindSymbolInLib(lib, name);\n+  PR_EnterMonitor(pr_linker_lock);\n+  PR_ASSERT(lib != NULL);\n+  f = pr_FindSymbolInLib(lib, name);\n \n #if defined(NEED_LEADING_UNDERSCORE)\n-    PR_smprintf_free(name);\n+  PR_smprintf_free(name);\n #endif\n \n-    PR_ExitMonitor(pr_linker_lock);\n-    return f;\n+  PR_ExitMonitor(pr_linker_lock);\n+  return f;\n }\n \n /*\n ** Return the address of the function 'raw_name' in the library 'lib'\n */\n PR_IMPLEMENT(PRFuncPtr)\n-PR_FindFunctionSymbol(PRLibrary* lib, const char* raw_name)\n-{\n-    return ((PRFuncPtr)PR_FindSymbol(lib, raw_name));\n+PR_FindFunctionSymbol(PRLibrary* lib, const char* raw_name) {\n+  return ((PRFuncPtr)PR_FindSymbol(lib, raw_name));\n }\n \n PR_IMPLEMENT(void*)\n-PR_FindSymbolAndLibrary(const char* raw_name, PRLibrary** lib)\n-{\n-    void* f = NULL;\n+PR_FindSymbolAndLibrary(const char* raw_name, PRLibrary** lib) {\n+  void* f = NULL;\n #if defined(NEED_LEADING_UNDERSCORE)\n-    char* name;\n+  char* name;\n #else\n-    const char* name;\n+  const char* name;\n #endif\n-    PRLibrary* lm;\n+  PRLibrary* lm;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    /*\n-    ** Mangle the raw symbol name in any way that is platform specific.\n-    */\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  /*\n+  ** Mangle the raw symbol name in any way that is platform specific.\n+  */\n #if defined(NEED_LEADING_UNDERSCORE)\n-    /* Need a leading _ */\n-    name = PR_smprintf(\"_%s\", raw_name);\n+  /* Need a leading _ */\n+  name = PR_smprintf(\"_%s\", raw_name);\n #elif defined(AIX)\n-    /*\n-    ** AIX with the normal linker put's a \".\" in front of the symbol\n-    ** name.  When use \"svcc\" and \"svld\" then the \".\" disappears. Go\n-    ** figure.\n-    */\n-    name = raw_name;\n+  /*\n+  ** AIX with the normal linker put's a \".\" in front of the symbol\n+  ** name.  When use \"svcc\" and \"svld\" then the \".\" disappears. Go\n+  ** figure.\n+  */\n+  name = raw_name;\n #else\n-    name = raw_name;\n+  name = raw_name;\n #endif\n \n-    PR_EnterMonitor(pr_linker_lock);\n-\n-    /* search all libraries */\n-    for (lm = pr_loadmap; lm != NULL; lm = lm->next) {\n-        f = pr_FindSymbolInLib(lm, name);\n-        if (f != NULL) {\n-            *lib = lm;\n-            lm->refCount++;\n-            PR_LOG(_pr_linker_lm, PR_LOG_MIN,\n-                   (\"%s incr => %d (for %s)\", lm->name, lm->refCount, name));\n-            break;\n-        }\n+  PR_EnterMonitor(pr_linker_lock);\n+\n+  /* search all libraries */\n+  for (lm = pr_loadmap; lm != NULL; lm = lm->next) {\n+    f = pr_FindSymbolInLib(lm, name);\n+    if (f != NULL) {\n+      *lib = lm;\n+      lm->refCount++;\n+      PR_LOG(_pr_linker_lm, PR_LOG_MIN,\n+             (\"%s incr => %d (for %s)\", lm->name, lm->refCount, name));\n+      break;\n     }\n+  }\n #if defined(NEED_LEADING_UNDERSCORE)\n-    PR_smprintf_free(name);\n+  PR_smprintf_free(name);\n #endif\n \n-    PR_ExitMonitor(pr_linker_lock);\n-    return f;\n+  PR_ExitMonitor(pr_linker_lock);\n+  return f;\n }\n \n PR_IMPLEMENT(PRFuncPtr)\n-PR_FindFunctionSymbolAndLibrary(const char* raw_name, PRLibrary** lib)\n-{\n-    return ((PRFuncPtr)PR_FindSymbolAndLibrary(raw_name, lib));\n+PR_FindFunctionSymbolAndLibrary(const char* raw_name, PRLibrary** lib) {\n+  return ((PRFuncPtr)PR_FindSymbolAndLibrary(raw_name, lib));\n }\n \n /*\n@@ -848,157 +827,155 @@ PR_FindFunctionSymbolAndLibrary(const char* raw_name, PRLibrary** lib)\n ** is called with the name then we will pretend it was already loaded\n */\n PR_IMPLEMENT(PRLibrary*)\n-PR_LoadStaticLibrary(const char* name, const PRStaticLinkTable* slt)\n-{\n-    PRLibrary* lm = NULL;\n-    PRLibrary* result = NULL;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    /* See if library is already loaded */\n-    PR_EnterMonitor(pr_linker_lock);\n-\n-    /* If the lbrary is already loaded, then add the static table information...\n-     */\n-    result = pr_UnlockedFindLibrary(name);\n-    if (result != NULL) {\n-        PR_ASSERT((result->staticTable == NULL) || (result->staticTable == slt));\n-        result->staticTable = slt;\n-        goto unlock;\n-    }\n-\n-    /* Add library to list...Mark it static */\n-    lm = PR_NEWZAP(PRLibrary);\n-    if (lm == NULL) {\n-        goto unlock;\n-    }\n-\n-    lm->name = strdup(name);\n-    lm->refCount = 1;\n-    lm->dlh = pr_exe_loadmap ? pr_exe_loadmap->dlh : 0;\n-    lm->staticTable = slt;\n-    lm->next = pr_loadmap;\n-    pr_loadmap = lm;\n-\n-    result = lm; /* success */\n-    PR_ASSERT(lm->refCount == 1);\n-    PR_LOG(_pr_linker_lm, PR_LOG_MIN,\n-           (\"Loaded library %s (static lib)\", lm->name));\n+PR_LoadStaticLibrary(const char* name, const PRStaticLinkTable* slt) {\n+  PRLibrary* lm = NULL;\n+  PRLibrary* result = NULL;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  /* See if library is already loaded */\n+  PR_EnterMonitor(pr_linker_lock);\n+\n+  /* If the lbrary is already loaded, then add the static table information...\n+   */\n+  result = pr_UnlockedFindLibrary(name);\n+  if (result != NULL) {\n+    PR_ASSERT((result->staticTable == NULL) || (result->staticTable == slt));\n+    result->staticTable = slt;\n+    goto unlock;\n+  }\n+\n+  /* Add library to list...Mark it static */\n+  lm = PR_NEWZAP(PRLibrary);\n+  if (lm == NULL) {\n+    goto unlock;\n+  }\n+\n+  lm->name = strdup(name);\n+  lm->refCount = 1;\n+  lm->dlh = pr_exe_loadmap ? pr_exe_loadmap->dlh : 0;\n+  lm->staticTable = slt;\n+  lm->next = pr_loadmap;\n+  pr_loadmap = lm;\n+\n+  result = lm; /* success */\n+  PR_ASSERT(lm->refCount == 1);\n+  PR_LOG(_pr_linker_lm, PR_LOG_MIN,\n+         (\"Loaded library %s (static lib)\", lm->name));\n unlock:\n-    PR_ExitMonitor(pr_linker_lock);\n-    return result;\n+  PR_ExitMonitor(pr_linker_lock);\n+  return result;\n }\n \n PR_IMPLEMENT(char*)\n-PR_GetLibraryFilePathname(const char* name, PRFuncPtr addr)\n-{\n+PR_GetLibraryFilePathname(const char* name, PRFuncPtr addr) {\n #if defined(USE_DLFCN) && defined(HAVE_DLADDR)\n-    Dl_info dli;\n-    char* result;\n+  Dl_info dli;\n+  char* result;\n \n-    if (dladdr((void*)addr, &dli) == 0) {\n-        PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, _MD_ERRNO());\n-        DLLErrorInternal(_MD_ERRNO());\n-        return NULL;\n-    }\n-    result = PR_Malloc(strlen(dli.dli_fname) + 1);\n-    if (result != NULL) {\n-        strcpy(result, dli.dli_fname);\n-    }\n-    return result;\n+  if (dladdr((void*)addr, &dli) == 0) {\n+    PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, _MD_ERRNO());\n+    DLLErrorInternal(_MD_ERRNO());\n+    return NULL;\n+  }\n+  result = PR_Malloc(strlen(dli.dli_fname) + 1);\n+  if (result != NULL) {\n+    strcpy(result, dli.dli_fname);\n+  }\n+  return result;\n #elif defined(AIX)\n-    char* result;\n-#define LD_INFO_INCREMENT 64\n-    struct ld_info* info;\n-    unsigned int info_length = LD_INFO_INCREMENT * sizeof(struct ld_info);\n-    struct ld_info* infop;\n-    int loadflags = L_GETINFO | L_IGNOREUNLOAD;\n-\n-    for (;;) {\n-        info = PR_Malloc(info_length);\n-        if (info == NULL) {\n-            return NULL;\n-        }\n-        /* If buffer is too small, loadquery fails with ENOMEM. */\n-        if (loadquery(loadflags, info, info_length) != -1) {\n-            break;\n-        }\n-        /*\n-         * Calling loadquery when compiled for 64-bit with the\n-         * L_IGNOREUNLOAD flag can cause an invalid argument error\n-         * on AIX 5.1. Detect this error the first time that\n-         * loadquery is called, and try calling it again without\n-         * this flag set.\n-         */\n-        if (errno == EINVAL && (loadflags & L_IGNOREUNLOAD)) {\n-            loadflags &= ~L_IGNOREUNLOAD;\n-            if (loadquery(loadflags, info, info_length) != -1) {\n-                break;\n-            }\n-        }\n-        PR_Free(info);\n-        if (errno != ENOMEM) {\n-            /* should not happen */\n-            _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO());\n-            return NULL;\n-        }\n-        /* retry with a larger buffer */\n-        info_length += LD_INFO_INCREMENT * sizeof(struct ld_info);\n+  char* result;\n+#  define LD_INFO_INCREMENT 64\n+  struct ld_info* info;\n+  unsigned int info_length = LD_INFO_INCREMENT * sizeof(struct ld_info);\n+  struct ld_info* infop;\n+  int loadflags = L_GETINFO | L_IGNOREUNLOAD;\n+\n+  for (;;) {\n+    info = PR_Malloc(info_length);\n+    if (info == NULL) {\n+      return NULL;\n+    }\n+    /* If buffer is too small, loadquery fails with ENOMEM. */\n+    if (loadquery(loadflags, info, info_length) != -1) {\n+      break;\n     }\n-\n-    for (infop = info;;\n-         infop = (struct ld_info*)((char*)infop + infop->ldinfo_next)) {\n-        unsigned long start = (unsigned long)infop->ldinfo_dataorg;\n-        unsigned long end = start + infop->ldinfo_datasize;\n-        if (start <= (unsigned long)addr && end > (unsigned long)addr) {\n-            result = PR_Malloc(strlen(infop->ldinfo_filename) + 1);\n-            if (result != NULL) {\n-                strcpy(result, infop->ldinfo_filename);\n-            }\n-            break;\n-        }\n-        if (!infop->ldinfo_next) {\n-            PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, 0);\n-            result = NULL;\n-            break;\n-        }\n+    /*\n+     * Calling loadquery when compiled for 64-bit with the\n+     * L_IGNOREUNLOAD flag can cause an invalid argument error\n+     * on AIX 5.1. Detect this error the first time that\n+     * loadquery is called, and try calling it again without\n+     * this flag set.\n+     */\n+    if (errno == EINVAL && (loadflags & L_IGNOREUNLOAD)) {\n+      loadflags &= ~L_IGNOREUNLOAD;\n+      if (loadquery(loadflags, info, info_length) != -1) {\n+        break;\n+      }\n     }\n     PR_Free(info);\n-    return result;\n+    if (errno != ENOMEM) {\n+      /* should not happen */\n+      _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO());\n+      return NULL;\n+    }\n+    /* retry with a larger buffer */\n+    info_length += LD_INFO_INCREMENT * sizeof(struct ld_info);\n+  }\n+\n+  for (infop = info;;\n+       infop = (struct ld_info*)((char*)infop + infop->ldinfo_next)) {\n+    unsigned long start = (unsigned long)infop->ldinfo_dataorg;\n+    unsigned long end = start + infop->ldinfo_datasize;\n+    if (start <= (unsigned long)addr && end > (unsigned long)addr) {\n+      result = PR_Malloc(strlen(infop->ldinfo_filename) + 1);\n+      if (result != NULL) {\n+        strcpy(result, infop->ldinfo_filename);\n+      }\n+      break;\n+    }\n+    if (!infop->ldinfo_next) {\n+      PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, 0);\n+      result = NULL;\n+      break;\n+    }\n+  }\n+  PR_Free(info);\n+  return result;\n #elif defined(WIN32)\n-    PRUnichar wname[MAX_PATH];\n-    HMODULE handle = NULL;\n-    PRUnichar module_name[MAX_PATH];\n-    int len;\n-    char* result;\n-\n-    if (MultiByteToWideChar(CP_ACP, 0, name, -1, wname, MAX_PATH)) {\n-        handle = GetModuleHandleW(wname);\n-    }\n-    if (handle == NULL) {\n-        PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, _MD_ERRNO());\n-        DLLErrorInternal(_MD_ERRNO());\n-        return NULL;\n-    }\n-    if (GetModuleFileNameW(handle, module_name, MAX_PATH) == 0) {\n-        /* should not happen */\n-        _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO());\n-        return NULL;\n-    }\n-    len = WideCharToMultiByte(CP_ACP, 0, module_name, -1, NULL, 0, NULL, NULL);\n-    if (len == 0) {\n-        _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO());\n-        return NULL;\n-    }\n-    result = PR_Malloc(len * sizeof(PRUnichar));\n-    if (result != NULL) {\n-        WideCharToMultiByte(CP_ACP, 0, module_name, -1, result, len, NULL, NULL);\n-    }\n-    return result;\n-#else\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  PRUnichar wname[MAX_PATH];\n+  HMODULE handle = NULL;\n+  PRUnichar module_name[MAX_PATH];\n+  int len;\n+  char* result;\n+\n+  if (MultiByteToWideChar(CP_ACP, 0, name, -1, wname, MAX_PATH)) {\n+    handle = GetModuleHandleW(wname);\n+  }\n+  if (handle == NULL) {\n+    PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, _MD_ERRNO());\n+    DLLErrorInternal(_MD_ERRNO());\n+    return NULL;\n+  }\n+  if (GetModuleFileNameW(handle, module_name, MAX_PATH) == 0) {\n+    /* should not happen */\n+    _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO());\n     return NULL;\n+  }\n+  len = WideCharToMultiByte(CP_ACP, 0, module_name, -1, NULL, 0, NULL, NULL);\n+  if (len == 0) {\n+    _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO());\n+    return NULL;\n+  }\n+  result = PR_Malloc(len * sizeof(PRUnichar));\n+  if (result != NULL) {\n+    WideCharToMultiByte(CP_ACP, 0, module_name, -1, result, len, NULL, NULL);\n+  }\n+  return result;\n+#else\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return NULL;\n #endif\n }\ndiff --git a/nspr/pr/src/malloc/.cvsignore b/nspr/pr/src/malloc/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/src/malloc/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/src/malloc/prmalloc.c b/nspr/pr/src/malloc/prmalloc.c\nindex 1f11dab..659ce2e 100644\n--- a/nspr/pr/src/malloc/prmalloc.c\n+++ b/nspr/pr/src/malloc/prmalloc.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -14,15 +15,15 @@\n /*\n ** Thread safe version of malloc, calloc, realloc, free\n */\n-#include <stdarg.h>\n+#  include <stdarg.h>\n \n-#ifdef DEBUG\n-#define SANITY\n-#define EXTRA_SANITY\n-#else\n-#undef SANITY\n-#undef EXTRA_SANITY\n-#endif\n+#  ifdef DEBUG\n+#    define SANITY\n+#    define EXTRA_SANITY\n+#  else\n+#    undef SANITY\n+#    undef EXTRA_SANITY\n+#  endif\n \n /* Forward decls */\n void* _PR_UnlockedMalloc(size_t size);\n@@ -55,63 +56,63 @@ void* _PR_UnlockedCalloc(size_t n, size_t elsize);\n /*\n  * Very verbose progress on stdout...\n  */\n-#if 0\n-#define TRACE(foo) printf foo\n+#  if 0\n+#    define TRACE(foo) printf foo\n static int malloc_event;\n-#else\n-#define TRACE(foo)\n-#endif\n+#  else\n+#    define TRACE(foo)\n+#  endif\n \n /* XXX Pick a number, any number */\n-#define malloc_pagesize 4096UL\n-#define malloc_pageshift 12UL\n-\n-#ifdef XP_UNIX\n-#include <stdio.h>\n-#include <stdlib.h>\n-#include <unistd.h>\n-#include <string.h>\n-#include <errno.h>\n-#include <sys/types.h>\n-#include <sys/mman.h>\n-#endif\n+#  define malloc_pagesize 4096UL\n+#  define malloc_pageshift 12UL\n+\n+#  ifdef XP_UNIX\n+#    include <stdio.h>\n+#    include <stdlib.h>\n+#    include <unistd.h>\n+#    include <string.h>\n+#    include <errno.h>\n+#    include <sys/types.h>\n+#    include <sys/mman.h>\n+#  endif\n \n /*\n  * This structure describes a page's worth of chunks.\n  */\n \n struct pginfo {\n-    struct pginfo* next; /* next on the free list */\n-    char* page;          /* Pointer to the page */\n-    u_short size;        /* size of this page's chunks */\n-    u_short shift;       /* How far to shift for this size chunks */\n-    u_short free;        /* How many free chunks */\n-    u_short total;       /* How many chunk */\n-    u_long bits[1];      /* Which chunks are free */\n+  struct pginfo* next; /* next on the free list */\n+  char* page;          /* Pointer to the page */\n+  u_short size;        /* size of this page's chunks */\n+  u_short shift;       /* How far to shift for this size chunks */\n+  u_short free;        /* How many free chunks */\n+  u_short total;       /* How many chunk */\n+  u_long bits[1];      /* Which chunks are free */\n };\n \n struct pgfree {\n-    struct pgfree* next; /* next run of free pages */\n-    struct pgfree* prev; /* prev run of free pages */\n-    char* page;          /* pointer to free pages */\n-    char* end;           /* pointer to end of free pages */\n-    u_long size;         /* number of bytes free */\n+  struct pgfree* next; /* next run of free pages */\n+  struct pgfree* prev; /* prev run of free pages */\n+  char* page;          /* pointer to free pages */\n+  char* end;           /* pointer to end of free pages */\n+  u_long size;         /* number of bytes free */\n };\n \n /*\n  * How many bits per u_long in the bitmap.\n  * Change only if not 8 bits/byte\n  */\n-#define MALLOC_BITS (8 * sizeof(u_long))\n+#  define MALLOC_BITS (8 * sizeof(u_long))\n \n /*\n  * Magic values to put in the page_directory\n  */\n-#define MALLOC_NOT_MINE ((struct pginfo*)0)\n-#define MALLOC_FREE ((struct pginfo*)1)\n-#define MALLOC_FIRST ((struct pginfo*)2)\n-#define MALLOC_FOLLOW ((struct pginfo*)3)\n-#define MALLOC_MAGIC ((struct pginfo*)4)\n+#  define MALLOC_NOT_MINE ((struct pginfo*)0)\n+#  define MALLOC_FREE ((struct pginfo*)1)\n+#  define MALLOC_FIRST ((struct pginfo*)2)\n+#  define MALLOC_FOLLOW ((struct pginfo*)3)\n+#  define MALLOC_MAGIC ((struct pginfo*)4)\n \n /*\n  * Set to one when malloc_init has been called\n@@ -123,41 +124,41 @@ static unsigned initialized;\n  * Must be a integral multiplum of the granularity of mmap(2).\n  * Your toes will curl if it isn't a power of two\n  */\n-#define malloc_pagemask ((malloc_pagesize) - 1)\n+#  define malloc_pagemask ((malloc_pagesize) - 1)\n \n /*\n  * The size of the largest chunk.\n  * Half a page.\n  */\n-#define malloc_maxsize ((malloc_pagesize) >> 1)\n+#  define malloc_maxsize ((malloc_pagesize) >> 1)\n \n /*\n  * malloc_pagesize == 1 << malloc_pageshift\n  */\n-#ifndef malloc_pageshift\n+#  ifndef malloc_pageshift\n static unsigned malloc_pageshift;\n-#endif /* malloc_pageshift */\n+#  endif /* malloc_pageshift */\n \n /*\n  * The smallest allocation we bother about.\n  * Must be power of two\n  */\n-#ifndef malloc_minsize\n+#  ifndef malloc_minsize\n static unsigned malloc_minsize;\n-#endif /* malloc_minsize */\n+#  endif /* malloc_minsize */\n \n /*\n  * The largest chunk we care about.\n  * Must be smaller than pagesize\n  * Must be power of two\n  */\n-#ifndef malloc_maxsize\n+#  ifndef malloc_maxsize\n static unsigned malloc_maxsize;\n-#endif /* malloc_maxsize */\n+#  endif /* malloc_maxsize */\n \n-#ifndef malloc_cache\n+#  ifndef malloc_cache\n static unsigned malloc_cache;\n-#endif /* malloc_cache */\n+#  endif /* malloc_cache */\n \n /*\n  * The offset from pagenumber to index into the page directory\n@@ -190,12 +191,12 @@ static struct pgfree free_list;\n  */\n static int malloc_abort;\n \n-#ifdef SANITY\n+#  ifdef SANITY\n /*\n  * Are we trying to die ?\n  */\n static int suicide;\n-#endif\n+#  endif\n \n /*\n  * dump statistics\n@@ -220,984 +221,945 @@ static struct pgfree* px;\n static int set_pgdir(void* ptr, struct pginfo* info);\n static int extend_page_directory(u_long index);\n \n-#ifdef SANITY\n-void\n-malloc_dump(FILE* fd)\n-{\n-    struct pginfo** pd;\n-    struct pgfree* pf;\n-    int j;\n-\n-    pd = page_dir;\n-\n-    /* print out all the pages */\n-    for (j = 0; j <= last_index; j++) {\n-        fprintf(fd, \"%08lx %5d \", (j + malloc_origo) << malloc_pageshift, j);\n-        if (pd[j] == MALLOC_NOT_MINE) {\n-            for (j++; j <= last_index && pd[j] == MALLOC_NOT_MINE; j++)\n-                ;\n-            j--;\n-            fprintf(fd, \".. %5d not mine\\n\", j);\n-        } else if (pd[j] == MALLOC_FREE) {\n-            for (j++; j <= last_index && pd[j] == MALLOC_FREE; j++)\n-                ;\n-            j--;\n-            fprintf(fd, \".. %5d free\\n\", j);\n-        } else if (pd[j] == MALLOC_FIRST) {\n-            for (j++; j <= last_index && pd[j] == MALLOC_FOLLOW; j++)\n-                ;\n-            j--;\n-            fprintf(fd, \".. %5d in use\\n\", j);\n-        } else if (pd[j] < MALLOC_MAGIC) {\n-            fprintf(fd, \"(%p)\\n\", pd[j]);\n-        } else {\n-            fprintf(fd, \"%p %d (of %d) x %d @ %p --> %p\\n\", pd[j], pd[j]->free,\n-                    pd[j]->total, pd[j]->size, pd[j]->page, pd[j]->next);\n-        }\n-    }\n-\n-    for (pf = free_list.next; pf; pf = pf->next) {\n-        fprintf(fd, \"Free: @%p [%p...%p[ %ld ->%p <-%p\\n\", pf, pf->page, pf->end,\n-                pf->size, pf->prev, pf->next);\n-        if (pf == pf->next) {\n-            fprintf(fd, \"Free_list loops.\\n\");\n-            break;\n-        }\n-    }\n-\n-    /* print out various info */\n-    fprintf(fd, \"Minsize\\t%d\\n\", malloc_minsize);\n-    fprintf(fd, \"Maxsize\\t%ld\\n\", malloc_maxsize);\n-    fprintf(fd, \"Pagesize\\t%ld\\n\", malloc_pagesize);\n-    fprintf(fd, \"Pageshift\\t%ld\\n\", malloc_pageshift);\n-    fprintf(fd, \"FirstPage\\t%ld\\n\", malloc_origo);\n-    fprintf(fd, \"LastPage\\t%ld %lx\\n\", last_index + malloc_pageshift,\n-            (last_index + malloc_pageshift) << malloc_pageshift);\n-    fprintf(fd, \"Break\\t%ld\\n\", (u_long)sbrk(0) >> malloc_pageshift);\n+#  ifdef SANITY\n+void malloc_dump(FILE* fd) {\n+  struct pginfo** pd;\n+  struct pgfree* pf;\n+  int j;\n+\n+  pd = page_dir;\n+\n+  /* print out all the pages */\n+  for (j = 0; j <= last_index; j++) {\n+    fprintf(fd, \"%08lx %5d \", (j + malloc_origo) << malloc_pageshift, j);\n+    if (pd[j] == MALLOC_NOT_MINE) {\n+      for (j++; j <= last_index && pd[j] == MALLOC_NOT_MINE; j++);\n+      j--;\n+      fprintf(fd, \".. %5d not mine\\n\", j);\n+    } else if (pd[j] == MALLOC_FREE) {\n+      for (j++; j <= last_index && pd[j] == MALLOC_FREE; j++);\n+      j--;\n+      fprintf(fd, \".. %5d free\\n\", j);\n+    } else if (pd[j] == MALLOC_FIRST) {\n+      for (j++; j <= last_index && pd[j] == MALLOC_FOLLOW; j++);\n+      j--;\n+      fprintf(fd, \".. %5d in use\\n\", j);\n+    } else if (pd[j] < MALLOC_MAGIC) {\n+      fprintf(fd, \"(%p)\\n\", pd[j]);\n+    } else {\n+      fprintf(fd, \"%p %d (of %d) x %d @ %p --> %p\\n\", pd[j], pd[j]->free,\n+              pd[j]->total, pd[j]->size, pd[j]->page, pd[j]->next);\n+    }\n+  }\n+\n+  for (pf = free_list.next; pf; pf = pf->next) {\n+    fprintf(fd, \"Free: @%p [%p...%p[ %ld ->%p <-%p\\n\", pf, pf->page, pf->end,\n+            pf->size, pf->prev, pf->next);\n+    if (pf == pf->next) {\n+      fprintf(fd, \"Free_list loops.\\n\");\n+      break;\n+    }\n+  }\n+\n+  /* print out various info */\n+  fprintf(fd, \"Minsize\\t%d\\n\", malloc_minsize);\n+  fprintf(fd, \"Maxsize\\t%ld\\n\", malloc_maxsize);\n+  fprintf(fd, \"Pagesize\\t%ld\\n\", malloc_pagesize);\n+  fprintf(fd, \"Pageshift\\t%ld\\n\", malloc_pageshift);\n+  fprintf(fd, \"FirstPage\\t%ld\\n\", malloc_origo);\n+  fprintf(fd, \"LastPage\\t%ld %lx\\n\", last_index + malloc_pageshift,\n+          (last_index + malloc_pageshift) << malloc_pageshift);\n+  fprintf(fd, \"Break\\t%ld\\n\", (u_long)sbrk(0) >> malloc_pageshift);\n }\n \n-static void\n-wrterror(char* fmt, ...)\n-{\n-    char* q = \"malloc() error: \";\n-    char buf[100];\n-    va_list ap;\n+static void wrterror(char* fmt, ...) {\n+  char* q = \"malloc() error: \";\n+  char buf[100];\n+  va_list ap;\n \n-    suicide = 1;\n+  suicide = 1;\n \n-    va_start(ap, fmt);\n-    PR_vsnprintf(buf, sizeof(buf), fmt, ap);\n-    va_end(ap);\n-    fputs(q, stderr);\n-    fputs(buf, stderr);\n+  va_start(ap, fmt);\n+  PR_vsnprintf(buf, sizeof(buf), fmt, ap);\n+  va_end(ap);\n+  fputs(q, stderr);\n+  fputs(buf, stderr);\n \n-    malloc_dump(stderr);\n-    PR_Abort();\n+  malloc_dump(stderr);\n+  PR_Abort();\n }\n \n-static void\n-wrtwarning(char* fmt, ...)\n-{\n-    char* q = \"malloc() warning: \";\n-    char buf[100];\n-    va_list ap;\n-\n-    va_start(ap, fmt);\n-    PR_vsnprintf(buf, sizeof(buf), fmt, ap);\n-    va_end(ap);\n-    fputs(q, stderr);\n-    fputs(buf, stderr);\n+static void wrtwarning(char* fmt, ...) {\n+  char* q = \"malloc() warning: \";\n+  char buf[100];\n+  va_list ap;\n+\n+  va_start(ap, fmt);\n+  PR_vsnprintf(buf, sizeof(buf), fmt, ap);\n+  va_end(ap);\n+  fputs(q, stderr);\n+  fputs(buf, stderr);\n }\n-#endif /* SANITY */\n+#  endif /* SANITY */\n \n /*\n  * Allocate a number of pages from the OS\n  */\n-static caddr_t\n-map_pages(int pages, int update)\n-{\n-    caddr_t result, tail;\n-\n-    result = ((caddr_t)sbrk(0)) + malloc_pagemask - 1;\n-    result = (caddr_t)((u_long)result & ~malloc_pagemask);\n-    tail = result + (pages << malloc_pageshift);\n-    if (!brk(tail)) {\n-        last_index = ((u_long)tail >> malloc_pageshift) - malloc_origo - 1;\n-        malloc_brk = tail;\n-        TRACE((\"%6d S %p .. %p\\n\", malloc_event++, result, tail));\n-        if (!update || last_index < malloc_ninfo ||\n-            extend_page_directory(last_index)) {\n-            return result;\n-        }\n-    }\n-    TRACE((\"%6d s %d %p %d\\n\", malloc_event++, pages, sbrk(0), errno));\n-#ifdef EXTRA_SANITY\n-    wrterror(\"map_pages fails\\n\");\n-#endif\n-    return 0;\n+static caddr_t map_pages(int pages, int update) {\n+  caddr_t result, tail;\n+\n+  result = ((caddr_t)sbrk(0)) + malloc_pagemask - 1;\n+  result = (caddr_t)((u_long)result & ~malloc_pagemask);\n+  tail = result + (pages << malloc_pageshift);\n+  if (!brk(tail)) {\n+    last_index = ((u_long)tail >> malloc_pageshift) - malloc_origo - 1;\n+    malloc_brk = tail;\n+    TRACE((\"%6d S %p .. %p\\n\", malloc_event++, result, tail));\n+    if (!update || last_index < malloc_ninfo ||\n+        extend_page_directory(last_index)) {\n+      return result;\n+    }\n+  }\n+  TRACE((\"%6d s %d %p %d\\n\", malloc_event++, pages, sbrk(0), errno));\n+#  ifdef EXTRA_SANITY\n+  wrterror(\"map_pages fails\\n\");\n+#  endif\n+  return 0;\n }\n \n-#define set_bit(_pi, _bit) \\\n+#  define set_bit(_pi, _bit) \\\n     (_pi)->bits[(_bit) / MALLOC_BITS] |= 1L << ((_bit) % MALLOC_BITS)\n \n-#define clr_bit(_pi, _bit) \\\n+#  define clr_bit(_pi, _bit) \\\n     (_pi)->bits[(_bit) / MALLOC_BITS] &= ~(1L << ((_bit) % MALLOC_BITS));\n \n-#define tst_bit(_pi, _bit) \\\n+#  define tst_bit(_pi, _bit) \\\n     ((_pi)->bits[(_bit) / MALLOC_BITS] & (1L << ((_bit) % MALLOC_BITS)))\n \n /*\n  * Extend page directory\n  */\n-static int\n-extend_page_directory(u_long index)\n-{\n-    struct pginfo **young, **old;\n-    int i;\n-\n-    TRACE((\"%6d E %lu\\n\", malloc_event++, index));\n-\n-    /* Make it this many pages */\n-    i = index * sizeof *page_dir;\n-    i /= malloc_pagesize;\n-    i += 2;\n-\n-    /* Get new pages, if you used this much mem you don't care :-) */\n-    young = (struct pginfo**)map_pages(i, 0);\n-    if (!young) {\n-        return 0;\n-    }\n+static int extend_page_directory(u_long index) {\n+  struct pginfo **young, **old;\n+  int i;\n \n-    /* Copy the old stuff */\n-    memset(young, 0, i * malloc_pagesize);\n-    memcpy(young, page_dir, malloc_ninfo * sizeof *page_dir);\n+  TRACE((\"%6d E %lu\\n\", malloc_event++, index));\n \n-    /* register the new size */\n-    malloc_ninfo = i * malloc_pagesize / sizeof *page_dir;\n+  /* Make it this many pages */\n+  i = index * sizeof *page_dir;\n+  i /= malloc_pagesize;\n+  i += 2;\n \n-    /* swap the pointers */\n-    old = page_dir;\n-    page_dir = young;\n+  /* Get new pages, if you used this much mem you don't care :-) */\n+  young = (struct pginfo**)map_pages(i, 0);\n+  if (!young) {\n+    return 0;\n+  }\n \n-    /* Mark the pages */\n-    index = ((u_long)young >> malloc_pageshift) - malloc_origo;\n-    page_dir[index] = MALLOC_FIRST;\n-    while (--i) {\n-        page_dir[++index] = MALLOC_FOLLOW;\n-    }\n+  /* Copy the old stuff */\n+  memset(young, 0, i * malloc_pagesize);\n+  memcpy(young, page_dir, malloc_ninfo * sizeof *page_dir);\n \n-    /* Now free the old stuff */\n-    _PR_UnlockedFree(old);\n-    return 1;\n+  /* register the new size */\n+  malloc_ninfo = i * malloc_pagesize / sizeof *page_dir;\n+\n+  /* swap the pointers */\n+  old = page_dir;\n+  page_dir = young;\n+\n+  /* Mark the pages */\n+  index = ((u_long)young >> malloc_pageshift) - malloc_origo;\n+  page_dir[index] = MALLOC_FIRST;\n+  while (--i) {\n+    page_dir[++index] = MALLOC_FOLLOW;\n+  }\n+\n+  /* Now free the old stuff */\n+  _PR_UnlockedFree(old);\n+  return 1;\n }\n \n /*\n  * Set entry in page directory.\n  * Extend page directory if need be.\n  */\n-static int\n-set_pgdir(void* ptr, struct pginfo* info)\n-{\n-    u_long index = ((u_long)ptr >> malloc_pageshift) - malloc_origo;\n+static int set_pgdir(void* ptr, struct pginfo* info) {\n+  u_long index = ((u_long)ptr >> malloc_pageshift) - malloc_origo;\n \n-    if (index >= malloc_ninfo && !extend_page_directory(index)) {\n-        return 0;\n-    }\n-    page_dir[index] = info;\n-    return 1;\n+  if (index >= malloc_ninfo && !extend_page_directory(index)) {\n+    return 0;\n+  }\n+  page_dir[index] = info;\n+  return 1;\n }\n \n /*\n  * Initialize the world\n  */\n-static void\n-malloc_init(void)\n-{\n-    int i;\n-    char* p;\n-\n-    TRACE((\"%6d I\\n\", malloc_event++));\n-#ifdef DEBUG\n-    for (p = getenv(\"MALLOC_OPTIONS\"); p && *p; p++) {\n-        switch (*p) {\n-            case 'a':\n-                malloc_abort = 0;\n-                break;\n-            case 'A':\n-                malloc_abort = 1;\n-                break;\n-            case 'd':\n-                malloc_stats = 0;\n-                break;\n-            case 'D':\n-                malloc_stats = 1;\n-                break;\n-            case 'r':\n-                malloc_realloc = 0;\n-                break;\n-            case 'R':\n-                malloc_realloc = 1;\n-                break;\n-            default:\n-                wrtwarning(\"Unknown chars in MALLOC_OPTIONS\\n\");\n-                break;\n-        }\n-    }\n-#endif\n-\n-#ifndef malloc_pagesize\n-    /* determine our pagesize */\n-    malloc_pagesize = getpagesize();\n-#endif /* malloc_pagesize */\n-\n-#ifndef malloc_pageshift\n-    /* determine how much we shift by to get there */\n-    for (i = malloc_pagesize; i > 1; i >>= 1) {\n-        malloc_pageshift++;\n-    }\n-#endif /* malloc_pageshift */\n-\n-#ifndef malloc_cache\n-    malloc_cache = 50 << malloc_pageshift;\n-#endif /* malloc_cache */\n-\n-#ifndef malloc_minsize\n-    /*\n-     * find the smallest size allocation we will bother about.\n-     * this is determined as the smallest allocation that can hold\n-     * it's own pginfo;\n-     */\n-    i = 2;\n-    for (;;) {\n-        int j;\n-\n-        /* Figure out the size of the bits */\n-        j = malloc_pagesize / i;\n-        j /= 8;\n-        if (j < sizeof(u_long)) {\n-            j = sizeof(u_long);\n-        }\n-        if (sizeof(struct pginfo) + j - sizeof(u_long) <= i) {\n-            break;\n-        }\n-        i += i;\n-    }\n-    malloc_minsize = i;\n-#endif /* malloc_minsize */\n-\n-    /* Allocate one page for the page directory */\n-    page_dir = (struct pginfo**)map_pages(1, 0);\n-#ifdef SANITY\n-    if (!page_dir) {\n-        wrterror(\"fatal: my first mmap failed.  (check limits ?)\\n\");\n-    }\n-#endif\n-\n-    /*\n-     * We need a maximum of malloc_pageshift buckets, steal these from the\n-     * front of the page_directory;\n-     */\n-    malloc_origo = (u_long)page_dir >> malloc_pageshift;\n-    malloc_origo -= malloc_pageshift;\n-\n-    /* Clear it */\n-    memset(page_dir, 0, malloc_pagesize);\n-\n-    /* Find out how much it tells us */\n-    malloc_ninfo = malloc_pagesize / sizeof *page_dir;\n-\n-    /* Plug the page directory into itself */\n-    i = set_pgdir(page_dir, MALLOC_FIRST);\n-#ifdef SANITY\n-    if (!i) {\n-        wrterror(\"fatal: couldn't set myself in the page directory\\n\");\n-    }\n-#endif\n+static void malloc_init(void) {\n+  int i;\n+  char* p;\n+\n+  TRACE((\"%6d I\\n\", malloc_event++));\n+#  ifdef DEBUG\n+  for (p = getenv(\"MALLOC_OPTIONS\"); p && *p; p++) {\n+    switch (*p) {\n+      case 'a':\n+        malloc_abort = 0;\n+        break;\n+      case 'A':\n+        malloc_abort = 1;\n+        break;\n+      case 'd':\n+        malloc_stats = 0;\n+        break;\n+      case 'D':\n+        malloc_stats = 1;\n+        break;\n+      case 'r':\n+        malloc_realloc = 0;\n+        break;\n+      case 'R':\n+        malloc_realloc = 1;\n+        break;\n+      default:\n+        wrtwarning(\"Unknown chars in MALLOC_OPTIONS\\n\");\n+        break;\n+    }\n+  }\n+#  endif\n+\n+#  ifndef malloc_pagesize\n+  /* determine our pagesize */\n+  malloc_pagesize = getpagesize();\n+#  endif /* malloc_pagesize */\n+\n+#  ifndef malloc_pageshift\n+  /* determine how much we shift by to get there */\n+  for (i = malloc_pagesize; i > 1; i >>= 1) {\n+    malloc_pageshift++;\n+  }\n+#  endif /* malloc_pageshift */\n+\n+#  ifndef malloc_cache\n+  malloc_cache = 50 << malloc_pageshift;\n+#  endif /* malloc_cache */\n+\n+#  ifndef malloc_minsize\n+  /*\n+   * find the smallest size allocation we will bother about.\n+   * this is determined as the smallest allocation that can hold\n+   * it's own pginfo;\n+   */\n+  i = 2;\n+  for (;;) {\n+    int j;\n \n-    /* Been here, done that */\n-    initialized++;\n+    /* Figure out the size of the bits */\n+    j = malloc_pagesize / i;\n+    j /= 8;\n+    if (j < sizeof(u_long)) {\n+      j = sizeof(u_long);\n+    }\n+    if (sizeof(struct pginfo) + j - sizeof(u_long) <= i) {\n+      break;\n+    }\n+    i += i;\n+  }\n+  malloc_minsize = i;\n+#  endif /* malloc_minsize */\n+\n+  /* Allocate one page for the page directory */\n+  page_dir = (struct pginfo**)map_pages(1, 0);\n+#  ifdef SANITY\n+  if (!page_dir) {\n+    wrterror(\"fatal: my first mmap failed.  (check limits ?)\\n\");\n+  }\n+#  endif\n+\n+  /*\n+   * We need a maximum of malloc_pageshift buckets, steal these from the\n+   * front of the page_directory;\n+   */\n+  malloc_origo = (u_long)page_dir >> malloc_pageshift;\n+  malloc_origo -= malloc_pageshift;\n+\n+  /* Clear it */\n+  memset(page_dir, 0, malloc_pagesize);\n+\n+  /* Find out how much it tells us */\n+  malloc_ninfo = malloc_pagesize / sizeof *page_dir;\n+\n+  /* Plug the page directory into itself */\n+  i = set_pgdir(page_dir, MALLOC_FIRST);\n+#  ifdef SANITY\n+  if (!i) {\n+    wrterror(\"fatal: couldn't set myself in the page directory\\n\");\n+  }\n+#  endif\n+\n+  /* Been here, done that */\n+  initialized++;\n }\n \n /*\n  * Allocate a number of complete pages\n  */\n-static void*\n-malloc_pages(size_t size)\n-{\n-    void *p, *delay_free = 0;\n-    int i;\n-    struct pgfree* pf;\n-    u_long index;\n-\n-    /* How many pages ? */\n-    size += (malloc_pagesize - 1);\n-    size &= ~malloc_pagemask;\n-\n-    p = 0;\n-    /* Look for free pages before asking for more */\n-    for (pf = free_list.next; pf; pf = pf->next) {\n-#ifdef EXTRA_SANITY\n-        if (pf->page == pf->end) {\n-            wrterror(\"zero entry on free_list\\n\");\n-        }\n-        if (pf->page > pf->end) {\n-            TRACE((\"%6d !s %p %p %p <%d>\\n\", malloc_event++, pf, pf->page, pf->end,\n-                   __LINE__));\n-            wrterror(\"sick entry on free_list\\n\");\n-        }\n-        if ((void*)pf->page >= (void*)sbrk(0)) {\n-            wrterror(\"entry on free_list past brk\\n\");\n-        }\n-        if (page_dir[((u_long)pf->page >> malloc_pageshift) - malloc_origo] !=\n-            MALLOC_FREE) {\n-            TRACE((\"%6d !f %p %p %p <%d>\\n\", malloc_event++, pf, pf->page, pf->end,\n-                   __LINE__));\n-            wrterror(\"non-free first page on free-list\\n\");\n-        }\n-        if (page_dir[((u_long)pf->end >> malloc_pageshift) - 1 - malloc_origo] !=\n-            MALLOC_FREE) {\n-            wrterror(\"non-free last page on free-list\\n\");\n-        }\n-#endif /* EXTRA_SANITY */\n-        if (pf->size < size) {\n-            continue;\n-        } else if (pf->size == size) {\n-            p = pf->page;\n-            if (pf->next) {\n-                pf->next->prev = pf->prev;\n-            }\n-            pf->prev->next = pf->next;\n-            delay_free = pf;\n-            break;\n-        } else {\n-            p = pf->page;\n-            pf->page += size;\n-            pf->size -= size;\n-            break;\n-        }\n-    }\n-#ifdef EXTRA_SANITY\n-    if (p &&\n-        page_dir[((u_long)p >> malloc_pageshift) - malloc_origo] != MALLOC_FREE) {\n-        wrterror(\"allocated non-free page on free-list\\n\");\n-    }\n-#endif /* EXTRA_SANITY */\n-\n-    size >>= malloc_pageshift;\n-\n-    /* Map new pages */\n-    if (!p) {\n-        p = map_pages(size, 1);\n-    }\n-\n-    if (p) {\n-        /* Mark the pages in the directory */\n-        index = ((u_long)p >> malloc_pageshift) - malloc_origo;\n-        page_dir[index] = MALLOC_FIRST;\n-        for (i = 1; i < size; i++) {\n-            page_dir[index + i] = MALLOC_FOLLOW;\n-        }\n+static void* malloc_pages(size_t size) {\n+  void *p, *delay_free = 0;\n+  int i;\n+  struct pgfree* pf;\n+  u_long index;\n+\n+  /* How many pages ? */\n+  size += (malloc_pagesize - 1);\n+  size &= ~malloc_pagemask;\n+\n+  p = 0;\n+  /* Look for free pages before asking for more */\n+  for (pf = free_list.next; pf; pf = pf->next) {\n+#  ifdef EXTRA_SANITY\n+    if (pf->page == pf->end) {\n+      wrterror(\"zero entry on free_list\\n\");\n+    }\n+    if (pf->page > pf->end) {\n+      TRACE((\"%6d !s %p %p %p <%d>\\n\", malloc_event++, pf, pf->page, pf->end,\n+             __LINE__));\n+      wrterror(\"sick entry on free_list\\n\");\n+    }\n+    if ((void*)pf->page >= (void*)sbrk(0)) {\n+      wrterror(\"entry on free_list past brk\\n\");\n+    }\n+    if (page_dir[((u_long)pf->page >> malloc_pageshift) - malloc_origo] !=\n+        MALLOC_FREE) {\n+      TRACE((\"%6d !f %p %p %p <%d>\\n\", malloc_event++, pf, pf->page, pf->end,\n+             __LINE__));\n+      wrterror(\"non-free first page on free-list\\n\");\n+    }\n+    if (page_dir[((u_long)pf->end >> malloc_pageshift) - 1 - malloc_origo] !=\n+        MALLOC_FREE) {\n+      wrterror(\"non-free last page on free-list\\n\");\n+    }\n+#  endif /* EXTRA_SANITY */\n+    if (pf->size < size) {\n+      continue;\n+    } else if (pf->size == size) {\n+      p = pf->page;\n+      if (pf->next) {\n+        pf->next->prev = pf->prev;\n+      }\n+      pf->prev->next = pf->next;\n+      delay_free = pf;\n+      break;\n+    } else {\n+      p = pf->page;\n+      pf->page += size;\n+      pf->size -= size;\n+      break;\n+    }\n+  }\n+#  ifdef EXTRA_SANITY\n+  if (p &&\n+      page_dir[((u_long)p >> malloc_pageshift) - malloc_origo] != MALLOC_FREE) {\n+    wrterror(\"allocated non-free page on free-list\\n\");\n+  }\n+#  endif /* EXTRA_SANITY */\n+\n+  size >>= malloc_pageshift;\n+\n+  /* Map new pages */\n+  if (!p) {\n+    p = map_pages(size, 1);\n+  }\n+\n+  if (p) {\n+    /* Mark the pages in the directory */\n+    index = ((u_long)p >> malloc_pageshift) - malloc_origo;\n+    page_dir[index] = MALLOC_FIRST;\n+    for (i = 1; i < size; i++) {\n+      page_dir[index + i] = MALLOC_FOLLOW;\n     }\n-    if (delay_free) {\n-        if (!px) {\n-            px = (struct pgfree*)delay_free;\n-        } else {\n-            _PR_UnlockedFree(delay_free);\n-        }\n+  }\n+  if (delay_free) {\n+    if (!px) {\n+      px = (struct pgfree*)delay_free;\n+    } else {\n+      _PR_UnlockedFree(delay_free);\n     }\n-    return p;\n+  }\n+  return p;\n }\n \n /*\n  * Allocate a page of fragments\n  */\n \n-static int\n-malloc_make_chunks(int bits)\n-{\n-    struct pginfo* bp;\n-    void* pp;\n-    int i, k, l;\n-\n-    /* Allocate a new bucket */\n-    pp = malloc_pages(malloc_pagesize);\n-    if (!pp) {\n-        return 0;\n-    }\n-    l = sizeof *bp - sizeof(u_long);\n-    l += sizeof(u_long) *\n-         (((malloc_pagesize >> bits) + MALLOC_BITS - 1) / MALLOC_BITS);\n-    if ((1 << (bits)) <= l + l) {\n-        bp = (struct pginfo*)pp;\n-    } else {\n-        bp = (struct pginfo*)_PR_UnlockedMalloc(l);\n-    }\n-    if (!bp) {\n-        return 0;\n-    }\n-    bp->size = (1 << bits);\n-    bp->shift = bits;\n-    bp->total = bp->free = malloc_pagesize >> bits;\n-    bp->next = page_dir[bits];\n-    bp->page = (char*)pp;\n-    i = set_pgdir(pp, bp);\n-    if (!i) {\n-        return 0;\n-    }\n+static int malloc_make_chunks(int bits) {\n+  struct pginfo* bp;\n+  void* pp;\n+  int i, k, l;\n \n-    /* We can safely assume that there is nobody in this chain */\n-    page_dir[bits] = bp;\n-\n-    /* set all valid bits in the bits */\n-    k = bp->total;\n-    i = 0;\n-    /*\n-        for(;k-i >= MALLOC_BITS; i += MALLOC_BITS)\n-        bp->bits[i / MALLOC_BITS] = ~0;\n-    */\n-    for (; i < k; i++) {\n-        set_bit(bp, i);\n-    }\n-\n-    if (bp != pp) {\n-        return 1;\n-    }\n-\n-    /* We may have used the first ones already */\n-    for (i = 0; l > 0; i++) {\n-        clr_bit(bp, i);\n-        bp->free--;\n-        bp->total--;\n-        l -= (1 << bits);\n-    }\n+  /* Allocate a new bucket */\n+  pp = malloc_pages(malloc_pagesize);\n+  if (!pp) {\n+    return 0;\n+  }\n+  l = sizeof *bp - sizeof(u_long);\n+  l += sizeof(u_long) *\n+       (((malloc_pagesize >> bits) + MALLOC_BITS - 1) / MALLOC_BITS);\n+  if ((1 << (bits)) <= l + l) {\n+    bp = (struct pginfo*)pp;\n+  } else {\n+    bp = (struct pginfo*)_PR_UnlockedMalloc(l);\n+  }\n+  if (!bp) {\n+    return 0;\n+  }\n+  bp->size = (1 << bits);\n+  bp->shift = bits;\n+  bp->total = bp->free = malloc_pagesize >> bits;\n+  bp->next = page_dir[bits];\n+  bp->page = (char*)pp;\n+  i = set_pgdir(pp, bp);\n+  if (!i) {\n+    return 0;\n+  }\n+\n+  /* We can safely assume that there is nobody in this chain */\n+  page_dir[bits] = bp;\n+\n+  /* set all valid bits in the bits */\n+  k = bp->total;\n+  i = 0;\n+  /*\n+      for(;k-i >= MALLOC_BITS; i += MALLOC_BITS)\n+      bp->bits[i / MALLOC_BITS] = ~0;\n+  */\n+  for (; i < k; i++) {\n+    set_bit(bp, i);\n+  }\n+\n+  if (bp != pp) {\n     return 1;\n+  }\n+\n+  /* We may have used the first ones already */\n+  for (i = 0; l > 0; i++) {\n+    clr_bit(bp, i);\n+    bp->free--;\n+    bp->total--;\n+    l -= (1 << bits);\n+  }\n+  return 1;\n }\n \n /*\n  * Allocate a fragment\n  */\n-static void*\n-malloc_bytes(size_t size)\n-{\n-    size_t s;\n-    int j;\n-    struct pginfo* bp;\n-    int k;\n-    u_long *lp, bf;\n-\n-    /* Don't bother with anything less than this */\n-    if (size < malloc_minsize) {\n-        size = malloc_minsize;\n-    }\n-\n-    /* Find the right bucket */\n-    j = 1;\n-    s = size - 1;\n-    while (s >>= 1) {\n-        j++;\n-    }\n-\n-    /* If it's empty, make a page more of that size chunks */\n-    if (!page_dir[j] && !malloc_make_chunks(j)) {\n-        return 0;\n-    }\n-\n-    /* Find first word of bitmap which isn't empty */\n-    bp = page_dir[j];\n-    for (lp = bp->bits; !*lp; lp++)\n-        ;\n-\n-    /* Find that bit */\n-    bf = *lp;\n-    k = 0;\n-    while ((bf & 1) == 0) {\n-        bf >>= 1;\n-        k++;\n-    }\n-\n-    *lp ^= 1L << k; /* clear it */\n-    bp->free--;\n-    if (!bp->free) {\n-        page_dir[j] = bp->next;\n-        bp->next = 0;\n-    }\n-    k += (lp - bp->bits) * MALLOC_BITS;\n-    return bp->page + (k << bp->shift);\n+static void* malloc_bytes(size_t size) {\n+  size_t s;\n+  int j;\n+  struct pginfo* bp;\n+  int k;\n+  u_long *lp, bf;\n+\n+  /* Don't bother with anything less than this */\n+  if (size < malloc_minsize) {\n+    size = malloc_minsize;\n+  }\n+\n+  /* Find the right bucket */\n+  j = 1;\n+  s = size - 1;\n+  while (s >>= 1) {\n+    j++;\n+  }\n+\n+  /* If it's empty, make a page more of that size chunks */\n+  if (!page_dir[j] && !malloc_make_chunks(j)) {\n+    return 0;\n+  }\n+\n+  /* Find first word of bitmap which isn't empty */\n+  bp = page_dir[j];\n+  for (lp = bp->bits; !*lp; lp++);\n+\n+  /* Find that bit */\n+  bf = *lp;\n+  k = 0;\n+  while ((bf & 1) == 0) {\n+    bf >>= 1;\n+    k++;\n+  }\n+\n+  *lp ^= 1L << k; /* clear it */\n+  bp->free--;\n+  if (!bp->free) {\n+    page_dir[j] = bp->next;\n+    bp->next = 0;\n+  }\n+  k += (lp - bp->bits) * MALLOC_BITS;\n+  return bp->page + (k << bp->shift);\n }\n \n-void*\n-_PR_UnlockedMalloc(size_t size)\n-{\n-    void* result;\n+void* _PR_UnlockedMalloc(size_t size) {\n+  void* result;\n \n-    /* Round up to a multiple of 8 bytes */\n-    if (size & 7) {\n-        size = size + 8 - (size & 7);\n-    }\n+  /* Round up to a multiple of 8 bytes */\n+  if (size & 7) {\n+    size = size + 8 - (size & 7);\n+  }\n \n-    if (!initialized) {\n-        malloc_init();\n-    }\n+  if (!initialized) {\n+    malloc_init();\n+  }\n \n-#ifdef SANITY\n-    if (suicide) {\n-        PR_Abort();\n-    }\n-#endif\n-\n-    if (size <= malloc_maxsize) {\n-        result = malloc_bytes(size);\n-    } else {\n-        result = malloc_pages(size);\n-    }\n-#ifdef SANITY\n-    if (malloc_abort && !result) {\n-        wrterror(\"malloc() returns NULL\\n\");\n-    }\n-#endif\n-    TRACE((\"%6d M %p %d\\n\", malloc_event++, result, size));\n-\n-    return result;\n+#  ifdef SANITY\n+  if (suicide) {\n+    PR_Abort();\n+  }\n+#  endif\n+\n+  if (size <= malloc_maxsize) {\n+    result = malloc_bytes(size);\n+  } else {\n+    result = malloc_pages(size);\n+  }\n+#  ifdef SANITY\n+  if (malloc_abort && !result) {\n+    wrterror(\"malloc() returns NULL\\n\");\n+  }\n+#  endif\n+  TRACE((\"%6d M %p %d\\n\", malloc_event++, result, size));\n+\n+  return result;\n }\n \n-void*\n-_PR_UnlockedMemalign(size_t alignment, size_t size)\n-{\n-    void* result;\n-\n-    /*\n-     * alignment has to be a power of 2\n-     */\n-\n-    if ((size <= alignment) && (alignment <= malloc_maxsize)) {\n-        size = alignment;\n-    } else {\n-        size += alignment - 1;\n-    }\n-\n-    /* Round up to a multiple of 8 bytes */\n-    if (size & 7) {\n-        size = size + 8 - (size & 7);\n-    }\n-\n-    if (!initialized) {\n-        malloc_init();\n-    }\n-\n-#ifdef SANITY\n-    if (suicide) {\n-        abort();\n-    }\n-#endif\n-\n-    if (size <= malloc_maxsize) {\n-        result = malloc_bytes(size);\n-    } else {\n-        result = malloc_pages(size);\n-    }\n-#ifdef SANITY\n-    if (malloc_abort && !result) {\n-        wrterror(\"malloc() returns NULL\\n\");\n-    }\n-#endif\n-    TRACE((\"%6d A %p %d\\n\", malloc_event++, result, size));\n-\n-    if ((u_long)result & (alignment - 1)) {\n-        return ((void*)(((u_long)result + alignment) & ~(alignment - 1)));\n-    } else {\n-        return result;\n-    }\n+void* _PR_UnlockedMemalign(size_t alignment, size_t size) {\n+  void* result;\n+\n+  /*\n+   * alignment has to be a power of 2\n+   */\n+\n+  if ((size <= alignment) && (alignment <= malloc_maxsize)) {\n+    size = alignment;\n+  } else {\n+    size += alignment - 1;\n+  }\n+\n+  /* Round up to a multiple of 8 bytes */\n+  if (size & 7) {\n+    size = size + 8 - (size & 7);\n+  }\n+\n+  if (!initialized) {\n+    malloc_init();\n+  }\n+\n+#  ifdef SANITY\n+  if (suicide) {\n+    abort();\n+  }\n+#  endif\n+\n+  if (size <= malloc_maxsize) {\n+    result = malloc_bytes(size);\n+  } else {\n+    result = malloc_pages(size);\n+  }\n+#  ifdef SANITY\n+  if (malloc_abort && !result) {\n+    wrterror(\"malloc() returns NULL\\n\");\n+  }\n+#  endif\n+  TRACE((\"%6d A %p %d\\n\", malloc_event++, result, size));\n+\n+  if ((u_long)result & (alignment - 1)) {\n+    return ((void*)(((u_long)result + alignment) & ~(alignment - 1)));\n+  } else {\n+    return result;\n+  }\n }\n \n-void*\n-_PR_UnlockedCalloc(size_t n, size_t nelem)\n-{\n-    void* p;\n-\n-    /* Compute total size and then round up to a double word amount */\n-    n *= nelem;\n-    if (n & 7) {\n-        n = n + 8 - (n & 7);\n-    }\n-\n-    /* Get the memory */\n-    p = _PR_UnlockedMalloc(n);\n-    if (p) {\n-        /* Zero it */\n-        memset(p, 0, n);\n-    }\n-    return p;\n+void* _PR_UnlockedCalloc(size_t n, size_t nelem) {\n+  void* p;\n+\n+  /* Compute total size and then round up to a double word amount */\n+  n *= nelem;\n+  if (n & 7) {\n+    n = n + 8 - (n & 7);\n+  }\n+\n+  /* Get the memory */\n+  p = _PR_UnlockedMalloc(n);\n+  if (p) {\n+    /* Zero it */\n+    memset(p, 0, n);\n+  }\n+  return p;\n }\n \n /*\n  * Change an allocation's size\n  */\n-void*\n-_PR_UnlockedRealloc(void* ptr, size_t size)\n-{\n-    void* p;\n-    u_long osize, page, index, tmp_index;\n-    struct pginfo** mp;\n-\n-    if (!initialized) {\n-        malloc_init();\n-    }\n+void* _PR_UnlockedRealloc(void* ptr, size_t size) {\n+  void* p;\n+  u_long osize, page, index, tmp_index;\n+  struct pginfo** mp;\n \n-#ifdef SANITY\n-    if (suicide) {\n-        PR_Abort();\n-    }\n-#endif\n-\n-    /* used as free() */\n-    TRACE((\"%6d R %p %d\\n\", malloc_event++, ptr, size));\n-    if (ptr && !size) {\n-        _PR_UnlockedFree(ptr);\n-        return _PR_UnlockedMalloc(1);\n-    }\n-\n-    /* used as malloc() */\n-    if (!ptr) {\n-        p = _PR_UnlockedMalloc(size);\n-        return p;\n-    }\n-\n-    /* Find the page directory entry for the page in question */\n-    page = (u_long)ptr >> malloc_pageshift;\n-    index = page - malloc_origo;\n+  if (!initialized) {\n+    malloc_init();\n+  }\n \n+#  ifdef SANITY\n+  if (suicide) {\n+    PR_Abort();\n+  }\n+#  endif\n+\n+  /* used as free() */\n+  TRACE((\"%6d R %p %d\\n\", malloc_event++, ptr, size));\n+  if (ptr && !size) {\n+    _PR_UnlockedFree(ptr);\n+    return _PR_UnlockedMalloc(1);\n+  }\n+\n+  /* used as malloc() */\n+  if (!ptr) {\n+    p = _PR_UnlockedMalloc(size);\n+    return p;\n+  }\n+\n+  /* Find the page directory entry for the page in question */\n+  page = (u_long)ptr >> malloc_pageshift;\n+  index = page - malloc_origo;\n+\n+  /*\n+   * check if memory was allocated by memalign\n+   */\n+  tmp_index = index;\n+  while (page_dir[tmp_index] == MALLOC_FOLLOW) {\n+    tmp_index--;\n+  }\n+  if (tmp_index != index) {\n     /*\n-     * check if memory was allocated by memalign\n+     * memalign-allocated memory\n      */\n-    tmp_index = index;\n-    while (page_dir[tmp_index] == MALLOC_FOLLOW) {\n-        tmp_index--;\n-    }\n-    if (tmp_index != index) {\n-        /*\n-         * memalign-allocated memory\n-         */\n-        index = tmp_index;\n-        page = index + malloc_origo;\n-        ptr = (void*)(page << malloc_pageshift);\n-    }\n-    TRACE((\"%6d R2 %p %d\\n\", malloc_event++, ptr, size));\n-\n-    /* make sure it makes sense in some fashion */\n-    if (index < malloc_pageshift || index > last_index) {\n-#ifdef SANITY\n-        wrtwarning(\"junk pointer passed to realloc()\\n\");\n-#endif\n-        return 0;\n-    }\n-\n-    /* find the size of that allocation, and see if we need to relocate */\n-    mp = &page_dir[index];\n-    if (*mp == MALLOC_FIRST) {\n-        osize = malloc_pagesize;\n-        while (mp[1] == MALLOC_FOLLOW) {\n-            osize += malloc_pagesize;\n-            mp++;\n-        }\n-        if (!malloc_realloc && size < osize && size > malloc_maxsize &&\n-            size > (osize - malloc_pagesize)) {\n-            return ptr;\n-        }\n-    } else if (*mp >= MALLOC_MAGIC) {\n-        osize = (*mp)->size;\n-        if (!malloc_realloc && size < osize &&\n-            (size > (*mp)->size / 2 || (*mp)->size == malloc_minsize)) {\n-            return ptr;\n-        }\n+    index = tmp_index;\n+    page = index + malloc_origo;\n+    ptr = (void*)(page << malloc_pageshift);\n+  }\n+  TRACE((\"%6d R2 %p %d\\n\", malloc_event++, ptr, size));\n+\n+  /* make sure it makes sense in some fashion */\n+  if (index < malloc_pageshift || index > last_index) {\n+#  ifdef SANITY\n+    wrtwarning(\"junk pointer passed to realloc()\\n\");\n+#  endif\n+    return 0;\n+  }\n+\n+  /* find the size of that allocation, and see if we need to relocate */\n+  mp = &page_dir[index];\n+  if (*mp == MALLOC_FIRST) {\n+    osize = malloc_pagesize;\n+    while (mp[1] == MALLOC_FOLLOW) {\n+      osize += malloc_pagesize;\n+      mp++;\n+    }\n+    if (!malloc_realloc && size < osize && size > malloc_maxsize &&\n+        size > (osize - malloc_pagesize)) {\n+      return ptr;\n+    }\n+  } else if (*mp >= MALLOC_MAGIC) {\n+    osize = (*mp)->size;\n+    if (!malloc_realloc && size < osize &&\n+        (size > (*mp)->size / 2 || (*mp)->size == malloc_minsize)) {\n+      return ptr;\n+    }\n+  } else {\n+#  ifdef SANITY\n+    wrterror(\"realloc() of wrong page.\\n\");\n+#  endif\n+  }\n+\n+  /* try to reallocate */\n+  p = _PR_UnlockedMalloc(size);\n+\n+  if (p) {\n+    /* copy the lesser of the two sizes */\n+    if (osize < size) {\n+      memcpy(p, ptr, osize);\n     } else {\n-#ifdef SANITY\n-        wrterror(\"realloc() of wrong page.\\n\");\n-#endif\n+      memcpy(p, ptr, size);\n     }\n+    _PR_UnlockedFree(ptr);\n+  }\n+#  ifdef DEBUG\n+  else if (malloc_abort) {\n+    wrterror(\"realloc() returns NULL\\n\");\n+  }\n+#  endif\n \n-    /* try to reallocate */\n-    p = _PR_UnlockedMalloc(size);\n-\n-    if (p) {\n-        /* copy the lesser of the two sizes */\n-        if (osize < size) {\n-            memcpy(p, ptr, osize);\n-        } else {\n-            memcpy(p, ptr, size);\n-        }\n-        _PR_UnlockedFree(ptr);\n-    }\n-#ifdef DEBUG\n-    else if (malloc_abort) {\n-        wrterror(\"realloc() returns NULL\\n\");\n-    }\n-#endif\n-\n-    return p;\n+  return p;\n }\n \n /*\n  * Free a sequence of pages\n  */\n \n-static void\n-free_pages(char* ptr, u_long page, int index, struct pginfo* info)\n-{\n-    int i;\n-    struct pgfree *pf, *pt;\n-    u_long l;\n-    char* tail;\n-\n-    TRACE((\"%6d FP %p %d\\n\", malloc_event++, ptr, page));\n-    /* Is it free already ? */\n-    if (info == MALLOC_FREE) {\n-#ifdef SANITY\n-        wrtwarning(\"freeing free page at %p.\\n\", ptr);\n-#endif\n-        return;\n-    }\n-\n-#ifdef SANITY\n-    /* Is it not the right place to begin ? */\n-    if (info != MALLOC_FIRST) {\n-        wrterror(\"freeing wrong page.\\n\");\n-    }\n-\n-    /* Is this really a pointer to a page ? */\n-    if ((u_long)ptr & malloc_pagemask) {\n-        wrterror(\"freeing messed up page pointer.\\n\");\n-    }\n-#endif\n-\n-    /* Count how many pages it is anyway */\n-    page_dir[index] = MALLOC_FREE;\n-    for (i = 1; page_dir[index + i] == MALLOC_FOLLOW; i++) {\n-        page_dir[index + i] = MALLOC_FREE;\n-    }\n-\n-    l = i << malloc_pageshift;\n-\n+static void free_pages(char* ptr, u_long page, int index, struct pginfo* info) {\n+  int i;\n+  struct pgfree *pf, *pt;\n+  u_long l;\n+  char* tail;\n+\n+  TRACE((\"%6d FP %p %d\\n\", malloc_event++, ptr, page));\n+  /* Is it free already ? */\n+  if (info == MALLOC_FREE) {\n+#  ifdef SANITY\n+    wrtwarning(\"freeing free page at %p.\\n\", ptr);\n+#  endif\n+    return;\n+  }\n+\n+#  ifdef SANITY\n+  /* Is it not the right place to begin ? */\n+  if (info != MALLOC_FIRST) {\n+    wrterror(\"freeing wrong page.\\n\");\n+  }\n+\n+  /* Is this really a pointer to a page ? */\n+  if ((u_long)ptr & malloc_pagemask) {\n+    wrterror(\"freeing messed up page pointer.\\n\");\n+  }\n+#  endif\n+\n+  /* Count how many pages it is anyway */\n+  page_dir[index] = MALLOC_FREE;\n+  for (i = 1; page_dir[index + i] == MALLOC_FOLLOW; i++) {\n+    page_dir[index + i] = MALLOC_FREE;\n+  }\n+\n+  l = i << malloc_pageshift;\n+\n+  tail = ptr + l;\n+\n+  /* add to free-list */\n+  if (!px) {\n+    px = (struct pgfree*)_PR_UnlockedMalloc(sizeof *pt);\n+  }\n+  /* XXX check success */\n+  px->page = ptr;\n+  px->end = tail;\n+  px->size = l;\n+  if (!free_list.next) {\n+    px->next = free_list.next;\n+    px->prev = &free_list;\n+    free_list.next = px;\n+    pf = px;\n+    px = 0;\n+  } else {\n     tail = ptr + l;\n-\n-    /* add to free-list */\n-    if (!px) {\n-        px = (struct pgfree*)_PR_UnlockedMalloc(sizeof *pt);\n-    }\n-    /* XXX check success */\n-    px->page = ptr;\n-    px->end = tail;\n-    px->size = l;\n-    if (!free_list.next) {\n-        px->next = free_list.next;\n-        px->prev = &free_list;\n-        free_list.next = px;\n+    for (pf = free_list.next; pf->next && pf->end < ptr; pf = pf->next);\n+    for (; pf; pf = pf->next) {\n+      if (pf->end == ptr) {\n+        /* append to entry */\n+        pf->end += l;\n+        pf->size += l;\n+        if (pf->next && pf->end == pf->next->page) {\n+          pt = pf->next;\n+          pf->end = pt->end;\n+          pf->size += pt->size;\n+          pf->next = pt->next;\n+          if (pf->next) {\n+            pf->next->prev = pf;\n+          }\n+          _PR_UnlockedFree(pt);\n+        }\n+      } else if (pf->page == tail) {\n+        /* prepend to entry */\n+        pf->size += l;\n+        pf->page = ptr;\n+      } else if (pf->page > ptr) {\n+        px->next = pf;\n+        px->prev = pf->prev;\n+        pf->prev = px;\n+        px->prev->next = px;\n         pf = px;\n         px = 0;\n-    } else {\n-        tail = ptr + l;\n-        for (pf = free_list.next; pf->next && pf->end < ptr; pf = pf->next)\n-            ;\n-        for (; pf; pf = pf->next) {\n-            if (pf->end == ptr) {\n-                /* append to entry */\n-                pf->end += l;\n-                pf->size += l;\n-                if (pf->next && pf->end == pf->next->page) {\n-                    pt = pf->next;\n-                    pf->end = pt->end;\n-                    pf->size += pt->size;\n-                    pf->next = pt->next;\n-                    if (pf->next) {\n-                        pf->next->prev = pf;\n-                    }\n-                    _PR_UnlockedFree(pt);\n-                }\n-            } else if (pf->page == tail) {\n-                /* prepend to entry */\n-                pf->size += l;\n-                pf->page = ptr;\n-            } else if (pf->page > ptr) {\n-                px->next = pf;\n-                px->prev = pf->prev;\n-                pf->prev = px;\n-                px->prev->next = px;\n-                pf = px;\n-                px = 0;\n-            } else if (!pf->next) {\n-                px->next = 0;\n-                px->prev = pf;\n-                pf->next = px;\n-                pf = px;\n-                px = 0;\n-            } else {\n-                continue;\n-            }\n-            break;\n-        }\n-    }\n-    if (!pf->next && pf->size > malloc_cache && pf->end == malloc_brk &&\n-        malloc_brk == (void*)sbrk(0)) {\n-        pf->end = pf->page + malloc_cache;\n-        pf->size = malloc_cache;\n-        TRACE((\"%6d U %p %d\\n\", malloc_event++, pf->end, pf->end - pf->page));\n-        brk(pf->end);\n-        malloc_brk = pf->end;\n-        /* Find the page directory entry for the page in question */\n-        page = (u_long)pf->end >> malloc_pageshift;\n-        index = page - malloc_origo;\n-        /* Now update the directory */\n-        for (i = index; i <= last_index;) {\n-            page_dir[i++] = MALLOC_NOT_MINE;\n-        }\n-        last_index = index - 1;\n+      } else if (!pf->next) {\n+        px->next = 0;\n+        px->prev = pf;\n+        pf->next = px;\n+        pf = px;\n+        px = 0;\n+      } else {\n+        continue;\n+      }\n+      break;\n+    }\n+  }\n+  if (!pf->next && pf->size > malloc_cache && pf->end == malloc_brk &&\n+      malloc_brk == (void*)sbrk(0)) {\n+    pf->end = pf->page + malloc_cache;\n+    pf->size = malloc_cache;\n+    TRACE((\"%6d U %p %d\\n\", malloc_event++, pf->end, pf->end - pf->page));\n+    brk(pf->end);\n+    malloc_brk = pf->end;\n+    /* Find the page directory entry for the page in question */\n+    page = (u_long)pf->end >> malloc_pageshift;\n+    index = page - malloc_origo;\n+    /* Now update the directory */\n+    for (i = index; i <= last_index;) {\n+      page_dir[i++] = MALLOC_NOT_MINE;\n     }\n+    last_index = index - 1;\n+  }\n }\n \n /*\n  * Free a chunk, and possibly the page it's on, if the page becomes empty.\n  */\n \n-static void\n-free_bytes(void* ptr, u_long page, int index, struct pginfo* info)\n-{\n-    int i;\n-    struct pginfo** mp;\n-    void* vp;\n-\n-    /* Make sure that pointer is multiplum of chunk-size */\n-#ifdef SANITY\n-    if ((u_long)ptr & (info->size - 1)) {\n-        wrterror(\"freeing messed up chunk pointer\\n\");\n-    }\n-#endif\n-\n-    /* Find the chunk number on the page */\n-    i = ((u_long)ptr & malloc_pagemask) >> info->shift;\n-\n-    /* See if it's free already */\n-    if (tst_bit(info, i)) {\n-#ifdef SANITY\n-        wrtwarning(\"freeing free chunk at %p\\n\", ptr);\n-#endif\n-        return;\n-    }\n-\n-    /* Mark it free */\n-    set_bit(info, i);\n-    info->free++;\n-\n-    /* If the page was full before, we need to put it on the queue now */\n-    if (info->free == 1) {\n-        mp = page_dir + info->shift;\n-        while (*mp && (*mp)->next && (*mp)->next->page < info->page) {\n-            mp = &(*mp)->next;\n-        }\n-        info->next = *mp;\n-        *mp = info;\n-        return;\n-    }\n+static void free_bytes(void* ptr, u_long page, int index, struct pginfo* info) {\n+  int i;\n+  struct pginfo** mp;\n+  void* vp;\n+\n+  /* Make sure that pointer is multiplum of chunk-size */\n+#  ifdef SANITY\n+  if ((u_long)ptr & (info->size - 1)) {\n+    wrterror(\"freeing messed up chunk pointer\\n\");\n+  }\n+#  endif\n+\n+  /* Find the chunk number on the page */\n+  i = ((u_long)ptr & malloc_pagemask) >> info->shift;\n+\n+  /* See if it's free already */\n+  if (tst_bit(info, i)) {\n+#  ifdef SANITY\n+    wrtwarning(\"freeing free chunk at %p\\n\", ptr);\n+#  endif\n+    return;\n+  }\n \n-    /* If this page isn't empty, don't do anything. */\n-    if (info->free != info->total) {\n-        return;\n-    }\n+  /* Mark it free */\n+  set_bit(info, i);\n+  info->free++;\n \n-    /* We may want to keep at least one page of each size chunks around.  */\n+  /* If the page was full before, we need to put it on the queue now */\n+  if (info->free == 1) {\n     mp = page_dir + info->shift;\n-    if (0 && (*mp == info) && !info->next) {\n-        return;\n+    while (*mp && (*mp)->next && (*mp)->next->page < info->page) {\n+      mp = &(*mp)->next;\n     }\n+    info->next = *mp;\n+    *mp = info;\n+    return;\n+  }\n \n-    /* Find & remove this page in the queue */\n-    while (*mp != info) {\n-        mp = &((*mp)->next);\n-#ifdef EXTRA_SANITY\n-        if (!*mp) {\n-            TRACE((\"%6d !q %p\\n\", malloc_event++, info));\n-            wrterror(\"Not on queue\\n\");\n-        }\n-#endif\n-    }\n-    *mp = info->next;\n+  /* If this page isn't empty, don't do anything. */\n+  if (info->free != info->total) {\n+    return;\n+  }\n \n-    /* Free the page & the info structure if need be */\n-    set_pgdir(info->page, MALLOC_FIRST);\n-    if ((void*)info->page == (void*)info) {\n-        _PR_UnlockedFree(info->page);\n-    } else {\n-        vp = info->page;\n-        _PR_UnlockedFree(info);\n-        _PR_UnlockedFree(vp);\n-    }\n+  /* We may want to keep at least one page of each size chunks around.  */\n+  mp = page_dir + info->shift;\n+  if (0 && (*mp == info) && !info->next) {\n+    return;\n+  }\n+\n+  /* Find & remove this page in the queue */\n+  while (*mp != info) {\n+    mp = &((*mp)->next);\n+#  ifdef EXTRA_SANITY\n+    if (!*mp) {\n+      TRACE((\"%6d !q %p\\n\", malloc_event++, info));\n+      wrterror(\"Not on queue\\n\");\n+    }\n+#  endif\n+  }\n+  *mp = info->next;\n+\n+  /* Free the page & the info structure if need be */\n+  set_pgdir(info->page, MALLOC_FIRST);\n+  if ((void*)info->page == (void*)info) {\n+    _PR_UnlockedFree(info->page);\n+  } else {\n+    vp = info->page;\n+    _PR_UnlockedFree(info);\n+    _PR_UnlockedFree(vp);\n+  }\n }\n \n-void\n-_PR_UnlockedFree(void* ptr)\n-{\n-    u_long page;\n-    struct pginfo* info;\n-    int index, tmp_index;\n-\n-    TRACE((\"%6d F %p\\n\", malloc_event++, ptr));\n-    /* This is legal */\n-    if (!ptr) {\n-        return;\n-    }\n-\n-#ifdef SANITY\n-    /* There wouldn't be anything to free */\n-    if (!initialized) {\n-        wrtwarning(\"free() called before malloc() ever got called\\n\");\n-        return;\n-    }\n-#endif\n+void _PR_UnlockedFree(void* ptr) {\n+  u_long page;\n+  struct pginfo* info;\n+  int index, tmp_index;\n \n-#ifdef SANITY\n-    if (suicide) {\n-        PR_Abort();\n-    }\n-#endif\n+  TRACE((\"%6d F %p\\n\", malloc_event++, ptr));\n+  /* This is legal */\n+  if (!ptr) {\n+    return;\n+  }\n \n-    /* Find the page directory entry for the page in question */\n-    page = (u_long)ptr >> malloc_pageshift;\n-    index = page - malloc_origo;\n+#  ifdef SANITY\n+  /* There wouldn't be anything to free */\n+  if (!initialized) {\n+    wrtwarning(\"free() called before malloc() ever got called\\n\");\n+    return;\n+  }\n+#  endif\n \n+#  ifdef SANITY\n+  if (suicide) {\n+    PR_Abort();\n+  }\n+#  endif\n+\n+  /* Find the page directory entry for the page in question */\n+  page = (u_long)ptr >> malloc_pageshift;\n+  index = page - malloc_origo;\n+\n+  /*\n+   * check if memory was allocated by memalign\n+   */\n+  tmp_index = index;\n+  while (page_dir[tmp_index] == MALLOC_FOLLOW) {\n+    tmp_index--;\n+  }\n+  if (tmp_index != index) {\n     /*\n-     * check if memory was allocated by memalign\n+     * memalign-allocated memory\n      */\n-    tmp_index = index;\n-    while (page_dir[tmp_index] == MALLOC_FOLLOW) {\n-        tmp_index--;\n-    }\n-    if (tmp_index != index) {\n-        /*\n-         * memalign-allocated memory\n-         */\n-        index = tmp_index;\n-        page = index + malloc_origo;\n-        ptr = (void*)(page << malloc_pageshift);\n-    }\n-    /* make sure it makes sense in some fashion */\n-    if (index < malloc_pageshift) {\n-#ifdef SANITY\n-        wrtwarning(\"junk pointer %p (low) passed to free()\\n\", ptr);\n-#endif\n-        return;\n-    }\n-    if (index > last_index) {\n-#ifdef SANITY\n-        wrtwarning(\"junk pointer %p (high) passed to free()\\n\", ptr);\n-#endif\n-        return;\n-    }\n-\n-    /* handle as page-allocation or chunk allocation */\n-    info = page_dir[index];\n-    if (info < MALLOC_MAGIC) {\n-        free_pages((char*)ptr, page, index, info);\n-    } else {\n-        free_bytes(ptr, page, index, info);\n-    }\n+    index = tmp_index;\n+    page = index + malloc_origo;\n+    ptr = (void*)(page << malloc_pageshift);\n+  }\n+  /* make sure it makes sense in some fashion */\n+  if (index < malloc_pageshift) {\n+#  ifdef SANITY\n+    wrtwarning(\"junk pointer %p (low) passed to free()\\n\", ptr);\n+#  endif\n+    return;\n+  }\n+  if (index > last_index) {\n+#  ifdef SANITY\n+    wrtwarning(\"junk pointer %p (high) passed to free()\\n\", ptr);\n+#  endif\n     return;\n+  }\n+\n+  /* handle as page-allocation or chunk allocation */\n+  info = page_dir[index];\n+  if (info < MALLOC_MAGIC) {\n+    free_pages((char*)ptr, page, index, info);\n+  } else {\n+    free_bytes(ptr, page, index, info);\n+  }\n+  return;\n }\n #endif /* _PR_OVERRIDE_MALLOC */\ndiff --git a/nspr/pr/src/malloc/prmem.c b/nspr/pr/src/malloc/prmem.c\nindex d83cd55..0781000 100644\n--- a/nspr/pr/src/malloc/prmem.c\n+++ b/nspr/pr/src/malloc/prmem.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -16,35 +17,35 @@\n ** in cyclic dependency of initialization.\n */\n \n-#include <string.h>\n+#  include <string.h>\n \n union memBlkHdrUn;\n \n typedef struct MemoryZoneStr {\n-    union memBlkHdrUn* head; /* free list */\n-    pthread_mutex_t lock;\n-    size_t blockSize;    /* size of blocks on this free list */\n-    PRUint32 locked;     /* current state of lock */\n-    PRUint32 contention; /* counter: had to wait for lock */\n-    PRUint32 hits;       /* allocated from free list */\n-    PRUint32 misses;     /* had to call malloc */\n-    PRUint32 elements;   /* on free list */\n+  union memBlkHdrUn* head; /* free list */\n+  pthread_mutex_t lock;\n+  size_t blockSize;    /* size of blocks on this free list */\n+  PRUint32 locked;     /* current state of lock */\n+  PRUint32 contention; /* counter: had to wait for lock */\n+  PRUint32 hits;       /* allocated from free list */\n+  PRUint32 misses;     /* had to call malloc */\n+  PRUint32 elements;   /* on free list */\n } MemoryZone;\n \n typedef union memBlkHdrUn {\n-    unsigned char filler[48]; /* fix the size of this beast */\n-    struct memBlkHdrStr {\n-        union memBlkHdrUn* next;\n-        MemoryZone* zone;\n-        size_t blockSize;\n-        size_t requestedSize;\n-        PRUint32 magic;\n-    } s;\n+  unsigned char filler[48]; /* fix the size of this beast */\n+  struct memBlkHdrStr {\n+    union memBlkHdrUn* next;\n+    MemoryZone* zone;\n+    size_t blockSize;\n+    size_t requestedSize;\n+    PRUint32 magic;\n+  } s;\n } MemBlockHdr;\n \n-#define MEM_ZONES 7\n-#define THREAD_POOLS 11 /* prime number for modulus */\n-#define ZONE_MAGIC 0x0BADC0DE\n+#  define MEM_ZONES 7\n+#  define THREAD_POOLS 11 /* prime number for modulus */\n+#  define ZONE_MAGIC 0x0BADC0DE\n \n static MemoryZone zones[MEM_ZONES][THREAD_POOLS];\n \n@@ -52,28 +53,26 @@ static PRBool use_zone_allocator = PR_FALSE;\n \n static void pr_ZoneFree(void* ptr);\n \n-void\n-_PR_DestroyZones(void)\n-{\n-    int i, j;\n-\n-    if (!use_zone_allocator) {\n-        return;\n-    }\n+void _PR_DestroyZones(void) {\n+  int i, j;\n \n-    for (j = 0; j < THREAD_POOLS; j++) {\n-        for (i = 0; i < MEM_ZONES; i++) {\n-            MemoryZone* mz = &zones[i][j];\n-            pthread_mutex_destroy(&mz->lock);\n-            while (mz->head) {\n-                MemBlockHdr* hdr = mz->head;\n-                mz->head = hdr->s.next; /* unlink it */\n-                free(hdr);\n-                mz->elements--;\n-            }\n-        }\n+  if (!use_zone_allocator) {\n+    return;\n+  }\n+\n+  for (j = 0; j < THREAD_POOLS; j++) {\n+    for (i = 0; i < MEM_ZONES; i++) {\n+      MemoryZone* mz = &zones[i][j];\n+      pthread_mutex_destroy(&mz->lock);\n+      while (mz->head) {\n+        MemBlockHdr* hdr = mz->head;\n+        mz->head = hdr->s.next; /* unlink it */\n+        free(hdr);\n+        mz->elements--;\n+      }\n     }\n-    use_zone_allocator = PR_FALSE;\n+  }\n+  use_zone_allocator = PR_FALSE;\n }\n \n /*\n@@ -83,209 +82,176 @@ _PR_DestroyZones(void)\n ** its address.\n */\n \n-#ifdef HAVE_DLL\n+#  ifdef HAVE_DLL\n \n-#if defined(USE_DLFCN) && !defined(NO_DLOPEN_NULL)\n+#    if defined(USE_DLFCN) && !defined(NO_DLOPEN_NULL)\n \n-#include <dlfcn.h>\n+#      include <dlfcn.h>\n \n-static void*\n-pr_FindSymbolInProg(const char* name)\n-{\n-    void* h;\n-    void* sym;\n+static void* pr_FindSymbolInProg(const char* name) {\n+  void* h;\n+  void* sym;\n \n-    h = dlopen(0, RTLD_LAZY);\n-    if (h == NULL) {\n-        return NULL;\n-    }\n-    sym = dlsym(h, name);\n-    (void)dlclose(h);\n-    return sym;\n+  h = dlopen(0, RTLD_LAZY);\n+  if (h == NULL) {\n+    return NULL;\n+  }\n+  sym = dlsym(h, name);\n+  (void)dlclose(h);\n+  return sym;\n }\n \n-#elif defined(USE_HPSHL)\n+#    elif defined(USE_HPSHL)\n \n-#include <dl.h>\n+#      include <dl.h>\n \n-static void*\n-pr_FindSymbolInProg(const char* name)\n-{\n-    shl_t h = NULL;\n-    void* sym;\n+static void* pr_FindSymbolInProg(const char* name) {\n+  shl_t h = NULL;\n+  void* sym;\n \n-    if (shl_findsym(&h, name, TYPE_DATA, &sym) == -1) {\n-        return NULL;\n-    }\n-    return sym;\n+  if (shl_findsym(&h, name, TYPE_DATA, &sym) == -1) {\n+    return NULL;\n+  }\n+  return sym;\n }\n \n-#elif defined(USE_MACH_DYLD) || defined(NO_DLOPEN_NULL)\n+#    elif defined(USE_MACH_DYLD) || defined(NO_DLOPEN_NULL)\n \n-static void*\n-pr_FindSymbolInProg(const char* name)\n-{\n-    /* FIXME: not implemented */\n-    return NULL;\n+static void* pr_FindSymbolInProg(const char* name) {\n+  /* FIXME: not implemented */\n+  return NULL;\n }\n \n-#else\n+#    else\n \n-#error \"The zone allocator is not supported on this platform\"\n+#      error \"The zone allocator is not supported on this platform\"\n \n-#endif\n+#    endif\n \n-#else /* !defined(HAVE_DLL) */\n+#  else /* !defined(HAVE_DLL) */\n \n-static void*\n-pr_FindSymbolInProg(const char* name)\n-{\n-    /* can't be implemented */\n-    return NULL;\n+static void* pr_FindSymbolInProg(const char* name) {\n+  /* can't be implemented */\n+  return NULL;\n }\n \n-#endif /* HAVE_DLL */\n+#  endif /* HAVE_DLL */\n \n-void\n-_PR_InitZones(void)\n-{\n-    int i, j;\n-    char* envp;\n-    PRBool* sym;\n+void _PR_InitZones(void) {\n+  int i, j;\n+  char* envp;\n+  PRBool* sym;\n \n-    if ((sym = (PRBool*)pr_FindSymbolInProg(\"nspr_use_zone_allocator\")) != NULL) {\n-        use_zone_allocator = *sym;\n-    } else if ((envp = getenv(\"NSPR_USE_ZONE_ALLOCATOR\")) != NULL) {\n-        use_zone_allocator = (atoi(envp) == 1);\n-    }\n-\n-    if (!use_zone_allocator) {\n-        return;\n-    }\n+  if ((sym = (PRBool*)pr_FindSymbolInProg(\"nspr_use_zone_allocator\")) != NULL) {\n+    use_zone_allocator = *sym;\n+  } else if ((envp = getenv(\"NSPR_USE_ZONE_ALLOCATOR\")) != NULL) {\n+    use_zone_allocator = (atoi(envp) == 1);\n+  }\n \n-    for (j = 0; j < THREAD_POOLS; j++) {\n-        for (i = 0; i < MEM_ZONES; i++) {\n-            MemoryZone* mz = &zones[i][j];\n-            int rv = pthread_mutex_init(&mz->lock, NULL);\n-            PR_ASSERT(0 == rv);\n-            if (rv != 0) {\n-                goto loser;\n-            }\n-            mz->blockSize = 16 << (2 * i);\n-        }\n-    }\n+  if (!use_zone_allocator) {\n     return;\n+  }\n+\n+  for (j = 0; j < THREAD_POOLS; j++) {\n+    for (i = 0; i < MEM_ZONES; i++) {\n+      MemoryZone* mz = &zones[i][j];\n+      int rv = pthread_mutex_init(&mz->lock, NULL);\n+      PR_ASSERT(0 == rv);\n+      if (rv != 0) {\n+        goto loser;\n+      }\n+      mz->blockSize = 16 << (2 * i);\n+    }\n+  }\n+  return;\n \n loser:\n-    _PR_DestroyZones();\n-    return;\n+  _PR_DestroyZones();\n+  return;\n }\n \n PR_IMPLEMENT(void)\n-PR_FPrintZoneStats(PRFileDesc* debug_out)\n-{\n-    int i, j;\n-\n-    for (j = 0; j < THREAD_POOLS; j++) {\n-        for (i = 0; i < MEM_ZONES; i++) {\n-            MemoryZone* mz = &zones[i][j];\n-            MemoryZone zone = *mz;\n-            if (zone.elements || zone.misses || zone.hits) {\n-                PR_fprintf(debug_out,\n-                           \"pool: %d, zone: %d, size: %d, free: %d, hit: %d, miss: %d, \"\n-                           \"contend: %d\\n\",\n-                           j, i, zone.blockSize, zone.elements, zone.hits, zone.misses,\n-                           zone.contention);\n-            }\n-        }\n+PR_FPrintZoneStats(PRFileDesc* debug_out) {\n+  int i, j;\n+\n+  for (j = 0; j < THREAD_POOLS; j++) {\n+    for (i = 0; i < MEM_ZONES; i++) {\n+      MemoryZone* mz = &zones[i][j];\n+      MemoryZone zone = *mz;\n+      if (zone.elements || zone.misses || zone.hits) {\n+        PR_fprintf(debug_out,\n+                   \"pool: %d, zone: %d, size: %d, free: %d, hit: %d, miss: %d, \"\n+                   \"contend: %d\\n\",\n+                   j, i, zone.blockSize, zone.elements, zone.hits, zone.misses,\n+                   zone.contention);\n+      }\n     }\n+  }\n }\n \n-static void*\n-pr_ZoneMalloc(PRUint32 size)\n-{\n-    void* rv;\n-    unsigned int zone;\n-    size_t blockSize;\n-    MemBlockHdr *mb, *mt;\n-    MemoryZone* mz;\n-\n-    /* Always allocate a non-zero amount of bytes */\n-    if (size < 1) {\n-        size = 1;\n+static void* pr_ZoneMalloc(PRUint32 size) {\n+  void* rv;\n+  unsigned int zone;\n+  size_t blockSize;\n+  MemBlockHdr *mb, *mt;\n+  MemoryZone* mz;\n+\n+  /* Always allocate a non-zero amount of bytes */\n+  if (size < 1) {\n+    size = 1;\n+  }\n+  for (zone = 0, blockSize = 16; zone < MEM_ZONES; ++zone, blockSize <<= 2) {\n+    if (size <= blockSize) {\n+      break;\n     }\n-    for (zone = 0, blockSize = 16; zone < MEM_ZONES; ++zone, blockSize <<= 2) {\n-        if (size <= blockSize) {\n-            break;\n-        }\n+  }\n+  if (zone < MEM_ZONES) {\n+    pthread_t me = pthread_self();\n+    unsigned int pool = (PRUptrdiff)me % THREAD_POOLS;\n+    PRUint32 wasLocked;\n+    mz = &zones[zone][pool];\n+    wasLocked = mz->locked;\n+    pthread_mutex_lock(&mz->lock);\n+    mz->locked = 1;\n+    if (wasLocked) {\n+      mz->contention++;\n     }\n-    if (zone < MEM_ZONES) {\n-        pthread_t me = pthread_self();\n-        unsigned int pool = (PRUptrdiff)me % THREAD_POOLS;\n-        PRUint32 wasLocked;\n-        mz = &zones[zone][pool];\n-        wasLocked = mz->locked;\n-        pthread_mutex_lock(&mz->lock);\n-        mz->locked = 1;\n-        if (wasLocked) {\n-            mz->contention++;\n-        }\n-        if (mz->head) {\n-            mb = mz->head;\n-            PR_ASSERT(mb->s.magic == ZONE_MAGIC);\n-            PR_ASSERT(mb->s.zone == mz);\n-            PR_ASSERT(mb->s.blockSize == blockSize);\n-            PR_ASSERT(mz->blockSize == blockSize);\n-\n-            mt = (MemBlockHdr*)(((char*)(mb + 1)) + blockSize);\n-            PR_ASSERT(mt->s.magic == ZONE_MAGIC);\n-            PR_ASSERT(mt->s.zone == mz);\n-            PR_ASSERT(mt->s.blockSize == blockSize);\n-\n-            mz->hits++;\n-            mz->elements--;\n-            mz->head = mb->s.next; /* take off free list */\n-            mz->locked = 0;\n-            pthread_mutex_unlock(&mz->lock);\n-\n-            mt->s.next = mb->s.next = NULL;\n-            mt->s.requestedSize = mb->s.requestedSize = size;\n-\n-            rv = (void*)(mb + 1);\n-            return rv;\n-        }\n-\n-        mz->misses++;\n-        mz->locked = 0;\n-        pthread_mutex_unlock(&mz->lock);\n-\n-        mb = (MemBlockHdr*)malloc(blockSize + 2 * (sizeof *mb));\n-        if (!mb) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            return NULL;\n-        }\n-        mb->s.next = NULL;\n-        mb->s.zone = mz;\n-        mb->s.magic = ZONE_MAGIC;\n-        mb->s.blockSize = blockSize;\n-        mb->s.requestedSize = size;\n-\n-        mt = (MemBlockHdr*)(((char*)(mb + 1)) + blockSize);\n-        memcpy(mt, mb, sizeof *mb);\n-\n-        rv = (void*)(mb + 1);\n-        return rv;\n+    if (mz->head) {\n+      mb = mz->head;\n+      PR_ASSERT(mb->s.magic == ZONE_MAGIC);\n+      PR_ASSERT(mb->s.zone == mz);\n+      PR_ASSERT(mb->s.blockSize == blockSize);\n+      PR_ASSERT(mz->blockSize == blockSize);\n+\n+      mt = (MemBlockHdr*)(((char*)(mb + 1)) + blockSize);\n+      PR_ASSERT(mt->s.magic == ZONE_MAGIC);\n+      PR_ASSERT(mt->s.zone == mz);\n+      PR_ASSERT(mt->s.blockSize == blockSize);\n+\n+      mz->hits++;\n+      mz->elements--;\n+      mz->head = mb->s.next; /* take off free list */\n+      mz->locked = 0;\n+      pthread_mutex_unlock(&mz->lock);\n+\n+      mt->s.next = mb->s.next = NULL;\n+      mt->s.requestedSize = mb->s.requestedSize = size;\n+\n+      rv = (void*)(mb + 1);\n+      return rv;\n     }\n \n-    /* size was too big.  Create a block with no zone */\n-    blockSize = (size & 15) ? size + 16 - (size & 15) : size;\n+    mz->misses++;\n+    mz->locked = 0;\n+    pthread_mutex_unlock(&mz->lock);\n+\n     mb = (MemBlockHdr*)malloc(blockSize + 2 * (sizeof *mb));\n     if (!mb) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      return NULL;\n     }\n     mb->s.next = NULL;\n-    mb->s.zone = NULL;\n+    mb->s.zone = mz;\n     mb->s.magic = ZONE_MAGIC;\n     mb->s.blockSize = blockSize;\n     mb->s.requestedSize = size;\n@@ -295,187 +261,193 @@ pr_ZoneMalloc(PRUint32 size)\n \n     rv = (void*)(mb + 1);\n     return rv;\n+  }\n+\n+  /* size was too big.  Create a block with no zone */\n+  blockSize = (size & 15) ? size + 16 - (size & 15) : size;\n+  mb = (MemBlockHdr*)malloc(blockSize + 2 * (sizeof *mb));\n+  if (!mb) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n+  mb->s.next = NULL;\n+  mb->s.zone = NULL;\n+  mb->s.magic = ZONE_MAGIC;\n+  mb->s.blockSize = blockSize;\n+  mb->s.requestedSize = size;\n+\n+  mt = (MemBlockHdr*)(((char*)(mb + 1)) + blockSize);\n+  memcpy(mt, mb, sizeof *mb);\n+\n+  rv = (void*)(mb + 1);\n+  return rv;\n }\n \n-static void*\n-pr_ZoneCalloc(PRUint32 nelem, PRUint32 elsize)\n-{\n-    PRUint32 size = nelem * elsize;\n-    void* p = pr_ZoneMalloc(size);\n-    if (p) {\n-        memset(p, 0, size);\n-    }\n-    return p;\n+static void* pr_ZoneCalloc(PRUint32 nelem, PRUint32 elsize) {\n+  PRUint32 size = nelem * elsize;\n+  void* p = pr_ZoneMalloc(size);\n+  if (p) {\n+    memset(p, 0, size);\n+  }\n+  return p;\n }\n \n-static void*\n-pr_ZoneRealloc(void* oldptr, PRUint32 bytes)\n-{\n-    void* rv;\n-    MemBlockHdr* mb;\n-    int ours;\n-    MemBlockHdr phony;\n+static void* pr_ZoneRealloc(void* oldptr, PRUint32 bytes) {\n+  void* rv;\n+  MemBlockHdr* mb;\n+  int ours;\n+  MemBlockHdr phony;\n+\n+  if (!oldptr) {\n+    return pr_ZoneMalloc(bytes);\n+  }\n+  mb = (MemBlockHdr*)((char*)oldptr - (sizeof *mb));\n+  if (mb->s.magic != ZONE_MAGIC) {\n+    /* Maybe this just came from ordinary malloc */\n+#  ifdef DEBUG\n+    fprintf(stderr,\n+            \"Warning: reallocing memory block %p from ordinary malloc\\n\",\n+            oldptr);\n+#  endif\n+    /*\n+     * We are going to realloc oldptr.  If realloc succeeds, the\n+     * original value of oldptr will point to freed memory.  So this\n+     * function must not fail after a successfull realloc call.  We\n+     * must perform any operation that may fail before the realloc\n+     * call.\n+     */\n+    rv = pr_ZoneMalloc(bytes); /* this may fail */\n+    if (!rv) {\n+      return rv;\n+    }\n \n+    /* We don't know how big it is.  But we can fix that. */\n+    oldptr = realloc(oldptr, bytes);\n+    /*\n+     * If realloc returns NULL, this function loses the original\n+     * value of oldptr.  This isn't a leak because the caller of\n+     * this function still has the original value of oldptr.\n+     */\n     if (!oldptr) {\n-        return pr_ZoneMalloc(bytes);\n+      if (bytes) {\n+        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+        pr_ZoneFree(rv);\n+        return oldptr;\n+      }\n     }\n-    mb = (MemBlockHdr*)((char*)oldptr - (sizeof *mb));\n-    if (mb->s.magic != ZONE_MAGIC) {\n-        /* Maybe this just came from ordinary malloc */\n-#ifdef DEBUG\n-        fprintf(stderr,\n-                \"Warning: reallocing memory block %p from ordinary malloc\\n\",\n-                oldptr);\n-#endif\n-        /*\n-         * We are going to realloc oldptr.  If realloc succeeds, the\n-         * original value of oldptr will point to freed memory.  So this\n-         * function must not fail after a successfull realloc call.  We\n-         * must perform any operation that may fail before the realloc\n-         * call.\n-         */\n-        rv = pr_ZoneMalloc(bytes); /* this may fail */\n-        if (!rv) {\n-            return rv;\n-        }\n+    phony.s.requestedSize = bytes;\n+    mb = &phony;\n+    ours = 0;\n+  } else {\n+    size_t blockSize = mb->s.blockSize;\n+    MemBlockHdr* mt = (MemBlockHdr*)(((char*)(mb + 1)) + blockSize);\n \n-        /* We don't know how big it is.  But we can fix that. */\n-        oldptr = realloc(oldptr, bytes);\n-        /*\n-         * If realloc returns NULL, this function loses the original\n-         * value of oldptr.  This isn't a leak because the caller of\n-         * this function still has the original value of oldptr.\n-         */\n-        if (!oldptr) {\n-            if (bytes) {\n-                PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-                pr_ZoneFree(rv);\n-                return oldptr;\n-            }\n-        }\n-        phony.s.requestedSize = bytes;\n-        mb = &phony;\n-        ours = 0;\n-    } else {\n-        size_t blockSize = mb->s.blockSize;\n-        MemBlockHdr* mt = (MemBlockHdr*)(((char*)(mb + 1)) + blockSize);\n-\n-        PR_ASSERT(mt->s.magic == ZONE_MAGIC);\n-        PR_ASSERT(mt->s.zone == mb->s.zone);\n-        PR_ASSERT(mt->s.blockSize == blockSize);\n-\n-        if (bytes <= blockSize) {\n-            /* The block is already big enough. */\n-            mt->s.requestedSize = mb->s.requestedSize = bytes;\n-            return oldptr;\n-        }\n-        ours = 1;\n-        rv = pr_ZoneMalloc(bytes);\n-        if (!rv) {\n-            return rv;\n-        }\n-    }\n+    PR_ASSERT(mt->s.magic == ZONE_MAGIC);\n+    PR_ASSERT(mt->s.zone == mb->s.zone);\n+    PR_ASSERT(mt->s.blockSize == blockSize);\n \n-    if (oldptr && mb->s.requestedSize) {\n-        memcpy(rv, oldptr, mb->s.requestedSize);\n+    if (bytes <= blockSize) {\n+      /* The block is already big enough. */\n+      mt->s.requestedSize = mb->s.requestedSize = bytes;\n+      return oldptr;\n     }\n-    if (ours) {\n-        pr_ZoneFree(oldptr);\n-    } else if (oldptr) {\n-        free(oldptr);\n+    ours = 1;\n+    rv = pr_ZoneMalloc(bytes);\n+    if (!rv) {\n+      return rv;\n     }\n-    return rv;\n+  }\n+\n+  if (oldptr && mb->s.requestedSize) {\n+    memcpy(rv, oldptr, mb->s.requestedSize);\n+  }\n+  if (ours) {\n+    pr_ZoneFree(oldptr);\n+  } else if (oldptr) {\n+    free(oldptr);\n+  }\n+  return rv;\n }\n \n-static void\n-pr_ZoneFree(void* ptr)\n-{\n-    MemBlockHdr *mb, *mt;\n-    MemoryZone* mz;\n-    size_t blockSize;\n-    PRUint32 wasLocked;\n-\n-    if (!ptr) {\n-        return;\n-    }\n+static void pr_ZoneFree(void* ptr) {\n+  MemBlockHdr *mb, *mt;\n+  MemoryZone* mz;\n+  size_t blockSize;\n+  PRUint32 wasLocked;\n \n-    mb = (MemBlockHdr*)((char*)ptr - (sizeof *mb));\n+  if (!ptr) {\n+    return;\n+  }\n \n-    if (mb->s.magic != ZONE_MAGIC) {\n-        /* maybe this came from ordinary malloc */\n-#ifdef DEBUG\n-        fprintf(stderr, \"Warning: freeing memory block %p from ordinary malloc\\n\",\n-                ptr);\n-#endif\n-        free(ptr);\n-        return;\n-    }\n+  mb = (MemBlockHdr*)((char*)ptr - (sizeof *mb));\n \n-    blockSize = mb->s.blockSize;\n-    mz = mb->s.zone;\n-    mt = (MemBlockHdr*)(((char*)(mb + 1)) + blockSize);\n-    PR_ASSERT(mt->s.magic == ZONE_MAGIC);\n-    PR_ASSERT(mt->s.zone == mz);\n-    PR_ASSERT(mt->s.blockSize == blockSize);\n-    if (!mz) {\n-        PR_ASSERT(blockSize > 65536);\n-        /* This block was not in any zone.  Just free it. */\n-        free(mb);\n-        return;\n-    }\n-    PR_ASSERT(mz->blockSize == blockSize);\n-    wasLocked = mz->locked;\n-    pthread_mutex_lock(&mz->lock);\n-    mz->locked = 1;\n-    if (wasLocked) {\n-        mz->contention++;\n-    }\n-    mt->s.next = mb->s.next = mz->head; /* put on head of list */\n-    mz->head = mb;\n-    mz->elements++;\n-    mz->locked = 0;\n-    pthread_mutex_unlock(&mz->lock);\n+  if (mb->s.magic != ZONE_MAGIC) {\n+    /* maybe this came from ordinary malloc */\n+#  ifdef DEBUG\n+    fprintf(stderr, \"Warning: freeing memory block %p from ordinary malloc\\n\",\n+            ptr);\n+#  endif\n+    free(ptr);\n+    return;\n+  }\n+\n+  blockSize = mb->s.blockSize;\n+  mz = mb->s.zone;\n+  mt = (MemBlockHdr*)(((char*)(mb + 1)) + blockSize);\n+  PR_ASSERT(mt->s.magic == ZONE_MAGIC);\n+  PR_ASSERT(mt->s.zone == mz);\n+  PR_ASSERT(mt->s.blockSize == blockSize);\n+  if (!mz) {\n+    PR_ASSERT(blockSize > 65536);\n+    /* This block was not in any zone.  Just free it. */\n+    free(mb);\n+    return;\n+  }\n+  PR_ASSERT(mz->blockSize == blockSize);\n+  wasLocked = mz->locked;\n+  pthread_mutex_lock(&mz->lock);\n+  mz->locked = 1;\n+  if (wasLocked) {\n+    mz->contention++;\n+  }\n+  mt->s.next = mb->s.next = mz->head; /* put on head of list */\n+  mz->head = mb;\n+  mz->elements++;\n+  mz->locked = 0;\n+  pthread_mutex_unlock(&mz->lock);\n }\n \n-PR_IMPLEMENT(void*)\n-PR_Malloc(PRUint32 size)\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+PR_IMPLEMENT(void*) PR_Malloc(PRUint32 size) {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    return use_zone_allocator ? pr_ZoneMalloc(size) : malloc(size);\n+  return use_zone_allocator ? pr_ZoneMalloc(size) : malloc(size);\n }\n \n-PR_IMPLEMENT(void*)\n-PR_Calloc(PRUint32 nelem, PRUint32 elsize)\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+PR_IMPLEMENT(void*) PR_Calloc(PRUint32 nelem, PRUint32 elsize) {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    return use_zone_allocator ? pr_ZoneCalloc(nelem, elsize)\n-                              : calloc(nelem, elsize);\n+  return use_zone_allocator ? pr_ZoneCalloc(nelem, elsize)\n+                            : calloc(nelem, elsize);\n }\n \n-PR_IMPLEMENT(void*)\n-PR_Realloc(void* ptr, PRUint32 size)\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+PR_IMPLEMENT(void*) PR_Realloc(void* ptr, PRUint32 size) {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    return use_zone_allocator ? pr_ZoneRealloc(ptr, size) : realloc(ptr, size);\n+  return use_zone_allocator ? pr_ZoneRealloc(ptr, size) : realloc(ptr, size);\n }\n \n-PR_IMPLEMENT(void)\n-PR_Free(void* ptr)\n-{\n-    if (use_zone_allocator) {\n-        pr_ZoneFree(ptr);\n-    } else {\n-        free(ptr);\n-    }\n+PR_IMPLEMENT(void) PR_Free(void* ptr) {\n+  if (use_zone_allocator) {\n+    pr_ZoneFree(ptr);\n+  } else {\n+    free(ptr);\n+  }\n }\n \n #else /* !defined(_PR_ZONE_ALLOCATOR) */\n@@ -488,23 +460,17 @@ PR_Free(void* ptr)\n ** objects compiled with /MD and /MDd) in the same process, and\n ** they maintain separate heaps, which cannot be mixed.\n */\n-PR_IMPLEMENT(void*)\n-PR_Malloc(PRUint32 size) { return malloc(size); }\n+PR_IMPLEMENT(void*) PR_Malloc(PRUint32 size) { return malloc(size); }\n \n-PR_IMPLEMENT(void*)\n-PR_Calloc(PRUint32 nelem, PRUint32 elsize)\n-{\n-    return calloc(nelem, elsize);\n+PR_IMPLEMENT(void*) PR_Calloc(PRUint32 nelem, PRUint32 elsize) {\n+  return calloc(nelem, elsize);\n }\n \n-PR_IMPLEMENT(void*)\n-PR_Realloc(void* ptr, PRUint32 size)\n-{\n-    return realloc(ptr, size);\n+PR_IMPLEMENT(void*) PR_Realloc(void* ptr, PRUint32 size) {\n+  return realloc(ptr, size);\n }\n \n-PR_IMPLEMENT(void)\n-PR_Free(void* ptr) { free(ptr); }\n+PR_IMPLEMENT(void) PR_Free(void* ptr) { free(ptr); }\n \n #endif /* _PR_ZONE_ALLOCATOR */\n \n@@ -538,131 +504,117 @@ extern void* _PR_UnlockedCalloc(size_t n, size_t elsize);\n \n static PRBool _PR_malloc_initialised = PR_FALSE;\n \n-#ifdef _PR_PTHREADS\n+#  ifdef _PR_PTHREADS\n static pthread_mutex_t _PR_MD_malloc_crustylock;\n \n-#define _PR_Lock_Malloc()                                       \\\n-    {                                                           \\\n-        if (PR_TRUE == _PR_malloc_initialised) {                \\\n-            PRStatus rv;                                        \\\n-            rv = pthread_mutex_lock(&_PR_MD_malloc_crustylock); \\\n-            PR_ASSERT(0 == rv);                                 \\\n+#    define _PR_Lock_Malloc()                                 \\\n+      {                                                       \\\n+        if (PR_TRUE == _PR_malloc_initialised) {              \\\n+          PRStatus rv;                                        \\\n+          rv = pthread_mutex_lock(&_PR_MD_malloc_crustylock); \\\n+          PR_ASSERT(0 == rv);                                 \\\n         }\n \n-#define _PR_Unlock_Malloc()                                   \\\n-    if (PR_TRUE == _PR_malloc_initialised) {                  \\\n+#    define _PR_Unlock_Malloc()                               \\\n+      if (PR_TRUE == _PR_malloc_initialised) {                \\\n         PRStatus rv;                                          \\\n         rv = pthread_mutex_unlock(&_PR_MD_malloc_crustylock); \\\n         PR_ASSERT(0 == rv);                                   \\\n-    }                                                         \\\n-    }\n-#else /* _PR_PTHREADS */\n+      }                                                       \\\n+      }\n+#  else /* _PR_PTHREADS */\n static _MDLock _PR_MD_malloc_crustylock;\n \n-#define _PR_Lock_Malloc()                                       \\\n-    {                                                           \\\n-        PRIntn _is;                                             \\\n-        if (PR_TRUE == _PR_malloc_initialised) {                \\\n-            if (_PR_MD_CURRENT_THREAD() &&                      \\\n-                !_PR_IS_NATIVE_THREAD(_PR_MD_CURRENT_THREAD())) \\\n-                _PR_INTSOFF(_is);                               \\\n-            _PR_MD_LOCK(&_PR_MD_malloc_crustylock);             \\\n+#    define _PR_Lock_Malloc()                                 \\\n+      {                                                       \\\n+        PRIntn _is;                                           \\\n+        if (PR_TRUE == _PR_malloc_initialised) {              \\\n+          if (_PR_MD_CURRENT_THREAD() &&                      \\\n+              !_PR_IS_NATIVE_THREAD(_PR_MD_CURRENT_THREAD())) \\\n+            _PR_INTSOFF(_is);                                 \\\n+          _PR_MD_LOCK(&_PR_MD_malloc_crustylock);             \\\n         }\n \n-#define _PR_Unlock_Malloc()                                 \\\n-    if (PR_TRUE == _PR_malloc_initialised) {                \\\n+#    define _PR_Unlock_Malloc()                             \\\n+      if (PR_TRUE == _PR_malloc_initialised) {              \\\n         _PR_MD_UNLOCK(&_PR_MD_malloc_crustylock);           \\\n         if (_PR_MD_CURRENT_THREAD() &&                      \\\n             !_PR_IS_NATIVE_THREAD(_PR_MD_CURRENT_THREAD())) \\\n-            _PR_INTSON(_is);                                \\\n-    }                                                       \\\n-    }\n-#endif /* _PR_PTHREADS */\n-\n-PR_IMPLEMENT(PRStatus)\n-_PR_MallocInit(void)\n-{\n-    PRStatus rv = PR_SUCCESS;\n-\n-    if (PR_TRUE == _PR_malloc_initialised) {\n-        return PR_SUCCESS;\n-    }\n-\n-#ifdef _PR_PTHREADS\n-    {\n-        int status;\n-        pthread_mutexattr_t mattr;\n-\n-        status = _PT_PTHREAD_MUTEXATTR_INIT(&mattr);\n-        PR_ASSERT(0 == status);\n-        status = _PT_PTHREAD_MUTEX_INIT(_PR_MD_malloc_crustylock, mattr);\n-        PR_ASSERT(0 == status);\n-        status = _PT_PTHREAD_MUTEXATTR_DESTROY(&mattr);\n-        PR_ASSERT(0 == status);\n-    }\n-#else  /* _PR_PTHREADS */\n-    _MD_NEW_LOCK(&_PR_MD_malloc_crustylock);\n-#endif /* _PR_PTHREADS */\n-\n-    if (PR_SUCCESS == rv) {\n-        _PR_malloc_initialised = PR_TRUE;\n-    }\n-\n-    return rv;\n+          _PR_INTSON(_is);                                  \\\n+      }                                                     \\\n+      }\n+#  endif /* _PR_PTHREADS */\n+\n+PR_IMPLEMENT(PRStatus) _PR_MallocInit(void) {\n+  PRStatus rv = PR_SUCCESS;\n+\n+  if (PR_TRUE == _PR_malloc_initialised) {\n+    return PR_SUCCESS;\n+  }\n+\n+#  ifdef _PR_PTHREADS\n+  {\n+    int status;\n+    pthread_mutexattr_t mattr;\n+\n+    status = _PT_PTHREAD_MUTEXATTR_INIT(&mattr);\n+    PR_ASSERT(0 == status);\n+    status = _PT_PTHREAD_MUTEX_INIT(_PR_MD_malloc_crustylock, mattr);\n+    PR_ASSERT(0 == status);\n+    status = _PT_PTHREAD_MUTEXATTR_DESTROY(&mattr);\n+    PR_ASSERT(0 == status);\n+  }\n+#  else  /* _PR_PTHREADS */\n+  _MD_NEW_LOCK(&_PR_MD_malloc_crustylock);\n+#  endif /* _PR_PTHREADS */\n+\n+  if (PR_SUCCESS == rv) {\n+    _PR_malloc_initialised = PR_TRUE;\n+  }\n+\n+  return rv;\n }\n \n-void*\n-malloc(size_t size)\n-{\n-    void* p;\n-    _PR_Lock_Malloc();\n-    p = _PR_UnlockedMalloc(size);\n-    _PR_Unlock_Malloc();\n-    return p;\n+void* malloc(size_t size) {\n+  void* p;\n+  _PR_Lock_Malloc();\n+  p = _PR_UnlockedMalloc(size);\n+  _PR_Unlock_Malloc();\n+  return p;\n }\n \n-void\n-free(void* ptr)\n-{\n-    _PR_Lock_Malloc();\n-    _PR_UnlockedFree(ptr);\n-    _PR_Unlock_Malloc();\n+void free(void* ptr) {\n+  _PR_Lock_Malloc();\n+  _PR_UnlockedFree(ptr);\n+  _PR_Unlock_Malloc();\n }\n \n-void*\n-realloc(void* ptr, size_t size)\n-{\n-    void* p;\n-    _PR_Lock_Malloc();\n-    p = _PR_UnlockedRealloc(ptr, size);\n-    _PR_Unlock_Malloc();\n-    return p;\n+void* realloc(void* ptr, size_t size) {\n+  void* p;\n+  _PR_Lock_Malloc();\n+  p = _PR_UnlockedRealloc(ptr, size);\n+  _PR_Unlock_Malloc();\n+  return p;\n }\n \n-void*\n-calloc(size_t n, size_t elsize)\n-{\n-    void* p;\n-    _PR_Lock_Malloc();\n-    p = _PR_UnlockedCalloc(n, elsize);\n-    _PR_Unlock_Malloc();\n-    return p;\n+void* calloc(size_t n, size_t elsize) {\n+  void* p;\n+  _PR_Lock_Malloc();\n+  p = _PR_UnlockedCalloc(n, elsize);\n+  _PR_Unlock_Malloc();\n+  return p;\n }\n \n-void\n-cfree(void* p)\n-{\n-    _PR_Lock_Malloc();\n-    _PR_UnlockedFree(p);\n-    _PR_Unlock_Malloc();\n+void cfree(void* p) {\n+  _PR_Lock_Malloc();\n+  _PR_UnlockedFree(p);\n+  _PR_Unlock_Malloc();\n }\n \n-void\n-_PR_InitMem(void)\n-{\n-    PRStatus rv;\n-    rv = _PR_MallocInit();\n-    PR_ASSERT(PR_SUCCESS == rv);\n+void _PR_InitMem(void) {\n+  PRStatus rv;\n+  rv = _PR_MallocInit();\n+  PR_ASSERT(PR_SUCCESS == rv);\n }\n \n #endif /* _PR_OVERRIDE_MALLOC */\ndiff --git a/nspr/pr/src/md/.cvsignore b/nspr/pr/src/md/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/src/md/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/src/md/prosdep.c b/nspr/pr/src/md/prosdep.c\nindex 322d2ad..19e8efb 100644\n--- a/nspr/pr/src/md/prosdep.c\n+++ b/nspr/pr/src/md/prosdep.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,10 +7,10 @@\n #include \"prsystem.h\"\n \n #ifdef XP_UNIX\n-#include <unistd.h>\n+#  include <unistd.h>\n #endif\n #ifdef _WIN32\n-#include <windows.h>\n+#  include <windows.h>\n #endif\n \n PRInt32 _pr_pageShift;\n@@ -18,49 +19,43 @@ PRInt32 _pr_pageSize;\n /*\n ** Get system page size\n */\n-static void\n-GetPageSize(void)\n-{\n-    PRInt32 pageSize;\n+static void GetPageSize(void) {\n+  PRInt32 pageSize;\n \n-    /* Get page size */\n+  /* Get page size */\n #ifdef XP_UNIX\n-#if defined AIX || defined LINUX || defined __GNU__ || defined __GLIBC__ || \\\n-    defined FREEBSD || defined NETBSD || defined OPENBSD || defined DARWIN\n-    _pr_pageSize = getpagesize();\n-#else\n-    _pr_pageSize = sysconf(_SC_PAGESIZE);\n-#endif\n+#  if defined AIX || defined LINUX || defined __GNU__ || defined __GLIBC__ || \\\n+      defined FREEBSD || defined NETBSD || defined OPENBSD || defined DARWIN\n+  _pr_pageSize = getpagesize();\n+#  else\n+  _pr_pageSize = sysconf(_SC_PAGESIZE);\n+#  endif\n #endif /* XP_UNIX */\n \n #ifdef XP_PC\n-#ifdef _WIN32\n-    SYSTEM_INFO info;\n-    GetSystemInfo(&info);\n-    _pr_pageSize = info.dwPageSize;\n-#else\n-    _pr_pageSize = 4096;\n-#endif\n+#  ifdef _WIN32\n+  SYSTEM_INFO info;\n+  GetSystemInfo(&info);\n+  _pr_pageSize = info.dwPageSize;\n+#  else\n+  _pr_pageSize = 4096;\n+#  endif\n #endif /* XP_PC */\n \n-    pageSize = _pr_pageSize;\n-    PR_CEILING_LOG2(_pr_pageShift, pageSize);\n+  pageSize = _pr_pageSize;\n+  PR_CEILING_LOG2(_pr_pageShift, pageSize);\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_GetPageShift(void)\n-{\n-    if (!_pr_pageSize) {\n-        GetPageSize();\n-    }\n-    return _pr_pageShift;\n+PR_IMPLEMENT(PRInt32) PR_GetPageShift(void) {\n+  if (!_pr_pageSize) {\n+    GetPageSize();\n+  }\n+  return _pr_pageShift;\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_GetPageSize(void)\n-{\n-    if (!_pr_pageSize) {\n-        GetPageSize();\n-    }\n-    return _pr_pageSize;\n+PR_IMPLEMENT(PRInt32) PR_GetPageSize(void) {\n+  if (!_pr_pageSize) {\n+    GetPageSize();\n+  }\n+  return _pr_pageSize;\n }\ndiff --git a/nspr/pr/src/md/unix/.cvsignore b/nspr/pr/src/md/unix/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/src/md/unix/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/src/md/unix/aix.c b/nspr/pr/src/md/unix/aix.c\nindex 4ddfed7..a2b7c2f 100644\n--- a/nspr/pr/src/md/unix/aix.c\n+++ b/nspr/pr/src/md/unix/aix.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -5,128 +6,114 @@\n #include \"primpl.h\"\n \n #ifdef AIX_HAVE_ATOMIC_OP_H\n-#include <sys/atomic_op.h>\n-\n-PRInt32\n-_AIX_AtomicSet(PRInt32* val, PRInt32 newval)\n-{\n-    PRIntn oldval;\n-    boolean_t stored;\n-    oldval = fetch_and_add((atomic_p)val, 0);\n-    do {\n-        stored = compare_and_swap((atomic_p)val, &oldval, newval);\n-    } while (!stored);\n-    return oldval;\n+#  include <sys/atomic_op.h>\n+\n+PRInt32 _AIX_AtomicSet(PRInt32* val, PRInt32 newval) {\n+  PRIntn oldval;\n+  boolean_t stored;\n+  oldval = fetch_and_add((atomic_p)val, 0);\n+  do {\n+    stored = compare_and_swap((atomic_p)val, &oldval, newval);\n+  } while (!stored);\n+  return oldval;\n } /* _AIX_AtomicSet */\n #endif /* AIX_HAVE_ATOMIC_OP_H */\n \n #if defined(AIX_TIMERS)\n \n-#include <sys/time.h>\n+#  include <sys/time.h>\n \n static PRUint32 _aix_baseline_epoch;\n \n-static void\n-_MD_AixIntervalInit(void)\n-{\n-    timebasestruct_t real_time;\n-    read_real_time(&real_time, TIMEBASE_SZ);\n-    (void)time_base_to_time(&real_time, TIMEBASE_SZ);\n-    _aix_baseline_epoch = real_time.tb_high;\n+static void _MD_AixIntervalInit(void) {\n+  timebasestruct_t real_time;\n+  read_real_time(&real_time, TIMEBASE_SZ);\n+  (void)time_base_to_time(&real_time, TIMEBASE_SZ);\n+  _aix_baseline_epoch = real_time.tb_high;\n } /* _MD_AixIntervalInit */\n \n-PRIntervalTime\n-_MD_AixGetInterval(void)\n-{\n-    PRIntn rv;\n-    PRUint64 temp;\n-    timebasestruct_t real_time;\n-    read_real_time(&real_time, TIMEBASE_SZ);\n-    (void)time_base_to_time(&real_time, TIMEBASE_SZ);\n-    /* tb_high is in seconds, tb_low in 10(-9)seconds */\n-    temp = 1000000000ULL * (PRUint64)(real_time.tb_high - _aix_baseline_epoch);\n-    temp += (PRUint64)real_time.tb_low; /* everything's 10(-9) seconds */\n-    temp >>= 16;                        /* now it's something way different */\n-    return (PRIntervalTime)temp;\n+PRIntervalTime _MD_AixGetInterval(void) {\n+  PRIntn rv;\n+  PRUint64 temp;\n+  timebasestruct_t real_time;\n+  read_real_time(&real_time, TIMEBASE_SZ);\n+  (void)time_base_to_time(&real_time, TIMEBASE_SZ);\n+  /* tb_high is in seconds, tb_low in 10(-9)seconds */\n+  temp = 1000000000ULL * (PRUint64)(real_time.tb_high - _aix_baseline_epoch);\n+  temp += (PRUint64)real_time.tb_low; /* everything's 10(-9) seconds */\n+  temp >>= 16;                        /* now it's something way different */\n+  return (PRIntervalTime)temp;\n } /* _MD_AixGetInterval */\n \n-PRIntervalTime\n-_MD_AixIntervalPerSec(void)\n-{\n-    return 1000000000ULL >> 16; /* that's 15258, I think */\n+PRIntervalTime _MD_AixIntervalPerSec(void) {\n+  return 1000000000ULL >> 16; /* that's 15258, I think */\n } /* _MD_AixIntervalPerSec */\n \n #endif /* defined(AIX_TIMERS) */\n \n #if !defined(PTHREADS_USER)\n \n-#if defined(_PR_PTHREADS)\n+#  if defined(_PR_PTHREADS)\n \n /*\n  * AIX 4.3 has sched_yield().  AIX 4.2 has pthread_yield().\n  * So we look up the appropriate function pointer at run time.\n  */\n \n-#include <dlfcn.h>\n+#    include <dlfcn.h>\n \n int (*_PT_aix_yield_fcn)() = NULL;\n int _pr_aix_send_file_use_disabled = 0;\n \n-void\n-_MD_EarlyInit(void)\n-{\n-    void* main_app_handle;\n-    char* evp;\n+void _MD_EarlyInit(void) {\n+  void* main_app_handle;\n+  char* evp;\n \n-    main_app_handle = dlopen(NULL, RTLD_NOW);\n-    PR_ASSERT(NULL != main_app_handle);\n+  main_app_handle = dlopen(NULL, RTLD_NOW);\n+  PR_ASSERT(NULL != main_app_handle);\n \n-    _PT_aix_yield_fcn = (int (*)())dlsym(main_app_handle, \"sched_yield\");\n-    if (!_PT_aix_yield_fcn) {\n-        _PT_aix_yield_fcn = (int (*)())dlsym(main_app_handle, \"pthread_yield\");\n-        PR_ASSERT(NULL != _PT_aix_yield_fcn);\n-    }\n-    dlclose(main_app_handle);\n+  _PT_aix_yield_fcn = (int (*)())dlsym(main_app_handle, \"sched_yield\");\n+  if (!_PT_aix_yield_fcn) {\n+    _PT_aix_yield_fcn = (int (*)())dlsym(main_app_handle, \"pthread_yield\");\n+    PR_ASSERT(NULL != _PT_aix_yield_fcn);\n+  }\n+  dlclose(main_app_handle);\n \n-    if (evp = getenv(\"NSPR_AIX_SEND_FILE_USE_DISABLED\")) {\n-        if (1 == atoi(evp)) {\n-            _pr_aix_send_file_use_disabled = 1;\n-        }\n+  if (evp = getenv(\"NSPR_AIX_SEND_FILE_USE_DISABLED\")) {\n+    if (1 == atoi(evp)) {\n+      _pr_aix_send_file_use_disabled = 1;\n     }\n+  }\n \n-#if defined(AIX_TIMERS)\n-    _MD_AixIntervalInit();\n-#endif\n+#    if defined(AIX_TIMERS)\n+  _MD_AixIntervalInit();\n+#    endif\n }\n \n-#else /* _PR_PTHREADS */\n+#  else /* _PR_PTHREADS */\n \n-void\n-_MD_EarlyInit(void)\n-{\n-#if defined(AIX_TIMERS)\n-    _MD_AixIntervalInit();\n-#endif\n+void _MD_EarlyInit(void) {\n+#    if defined(AIX_TIMERS)\n+  _MD_AixIntervalInit();\n+#    endif\n }\n \n-#endif /* _PR_PTHREADS */\n-\n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n-#ifndef _PR_PTHREADS\n-    if (isCurrent) {\n-        (void)setjmp(CONTEXT(t));\n-    }\n-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n-    return (PRWord*)CONTEXT(t);\n-#else\n-    *np = 0;\n-    return NULL;\n-#endif\n+#  endif /* _PR_PTHREADS */\n+\n+PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) {\n+#  ifndef _PR_PTHREADS\n+  if (isCurrent) {\n+    (void)setjmp(CONTEXT(t));\n+  }\n+  *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n+  return (PRWord*)CONTEXT(t);\n+#  else\n+  *np = 0;\n+  return NULL;\n+#  endif\n }\n \n-#ifndef _PR_PTHREADS\n+#  ifndef _PR_PTHREADS\n PR_IMPLEMENT(void)\n _MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri) { return; }\n \n@@ -134,20 +121,18 @@ PR_IMPLEMENT(PRStatus)\n _MD_InitializeThread(PRThread* thread) { return PR_SUCCESS; }\n \n PR_IMPLEMENT(PRStatus)\n-_MD_WAIT(PRThread* thread, PRIntervalTime ticks)\n-{\n-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    _PR_MD_SWITCH_CONTEXT(thread);\n-    return PR_SUCCESS;\n+_MD_WAIT(PRThread* thread, PRIntervalTime ticks) {\n+  PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  _PR_MD_SWITCH_CONTEXT(thread);\n+  return PR_SUCCESS;\n }\n \n PR_IMPLEMENT(PRStatus)\n-_MD_WAKEUP_WAITER(PRThread* thread)\n-{\n-    if (thread) {\n-        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    }\n-    return PR_SUCCESS;\n+_MD_WAKEUP_WAITER(PRThread* thread) {\n+  if (thread) {\n+    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  }\n+  return PR_SUCCESS;\n }\n \n /* These functions should not be called for AIX */\n@@ -157,12 +142,11 @@ _MD_YIELD(void) { PR_NOT_REACHED(\"_MD_YIELD should not be called for AIX.\"); }\n PR_IMPLEMENT(PRStatus)\n _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n                   PRThreadPriority priority, PRThreadScope scope,\n-                  PRThreadState state, PRUint32 stackSize)\n-{\n-    PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for AIX.\");\n+                  PRThreadState state, PRUint32 stackSize) {\n+  PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for AIX.\");\n }\n-#endif /* _PR_PTHREADS */\n-#endif /* PTHREADS_USER */\n+#  endif /* _PR_PTHREADS */\n+#endif   /* PTHREADS_USER */\n \n /*\n  * NSPR 2.0 overrides the system select() and poll() functions.\n@@ -172,59 +156,55 @@ _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n \n #if !defined(AIX_RENAME_SELECT)\n \n-#include <sys/select.h>\n-#include <sys/poll.h>\n-#include <dlfcn.h>\n+#  include <sys/select.h>\n+#  include <sys/poll.h>\n+#  include <dlfcn.h>\n \n static int (*aix_select_fcn)() = NULL;\n static int (*aix_poll_fcn)() = NULL;\n \n-int\n-_MD_SELECT(int width, fd_set* r, fd_set* w, fd_set* e, struct timeval* t)\n-{\n-    int rv;\n+int _MD_SELECT(int width, fd_set* r, fd_set* w, fd_set* e, struct timeval* t) {\n+  int rv;\n+\n+  if (!aix_select_fcn) {\n+    void* aix_handle;\n \n+    aix_handle = dlopen(\"/unix\", RTLD_NOW);\n+    if (!aix_handle) {\n+      PR_SetError(PR_UNKNOWN_ERROR, 0);\n+      return -1;\n+    }\n+    aix_select_fcn = (int (*)())dlsym(aix_handle, \"select\");\n+    dlclose(aix_handle);\n     if (!aix_select_fcn) {\n-        void* aix_handle;\n-\n-        aix_handle = dlopen(\"/unix\", RTLD_NOW);\n-        if (!aix_handle) {\n-            PR_SetError(PR_UNKNOWN_ERROR, 0);\n-            return -1;\n-        }\n-        aix_select_fcn = (int (*)())dlsym(aix_handle, \"select\");\n-        dlclose(aix_handle);\n-        if (!aix_select_fcn) {\n-            PR_SetError(PR_UNKNOWN_ERROR, 0);\n-            return -1;\n-        }\n+      PR_SetError(PR_UNKNOWN_ERROR, 0);\n+      return -1;\n     }\n-    rv = (*aix_select_fcn)(width, r, w, e, t);\n-    return rv;\n+  }\n+  rv = (*aix_select_fcn)(width, r, w, e, t);\n+  return rv;\n }\n \n-int\n-_MD_POLL(void* listptr, unsigned long nfds, long timeout)\n-{\n-    int rv;\n+int _MD_POLL(void* listptr, unsigned long nfds, long timeout) {\n+  int rv;\n+\n+  if (!aix_poll_fcn) {\n+    void* aix_handle;\n \n+    aix_handle = dlopen(\"/unix\", RTLD_NOW);\n+    if (!aix_handle) {\n+      PR_SetError(PR_UNKNOWN_ERROR, 0);\n+      return -1;\n+    }\n+    aix_poll_fcn = (int (*)())dlsym(aix_handle, \"poll\");\n+    dlclose(aix_handle);\n     if (!aix_poll_fcn) {\n-        void* aix_handle;\n-\n-        aix_handle = dlopen(\"/unix\", RTLD_NOW);\n-        if (!aix_handle) {\n-            PR_SetError(PR_UNKNOWN_ERROR, 0);\n-            return -1;\n-        }\n-        aix_poll_fcn = (int (*)())dlsym(aix_handle, \"poll\");\n-        dlclose(aix_handle);\n-        if (!aix_poll_fcn) {\n-            PR_SetError(PR_UNKNOWN_ERROR, 0);\n-            return -1;\n-        }\n+      PR_SetError(PR_UNKNOWN_ERROR, 0);\n+      return -1;\n     }\n-    rv = (*aix_poll_fcn)(listptr, nfds, timeout);\n-    return rv;\n+  }\n+  rv = (*aix_poll_fcn)(listptr, nfds, timeout);\n+  return rv;\n }\n \n #else\n@@ -234,64 +214,56 @@ _MD_POLL(void* listptr, unsigned long nfds, long timeout)\n  * The binary must contain at least one \"poll\" symbol for linker's rename\n  * to work.  So we must have this dummy function that references poll().\n  */\n-#include <sys/poll.h>\n-void\n-_pr_aix_dummy()\n-{\n-    poll(0, 0, 0);\n-}\n+#  include <sys/poll.h>\n+void _pr_aix_dummy() { poll(0, 0, 0); }\n \n #endif /* !defined(AIX_RENAME_SELECT) */\n \n #ifdef _PR_HAVE_ATOMIC_CAS\n \n-#include \"pratom.h\"\n+#  include \"pratom.h\"\n \n-#define _PR_AIX_ATOMIC_LOCK -1\n+#  define _PR_AIX_ATOMIC_LOCK -1\n \n PR_IMPLEMENT(void)\n-PR_StackPush(PRStack* stack, PRStackElem* stack_elem)\n-{\n-    PRStackElem* addr;\n-    boolean_t locked = TRUE;\n-\n-    /* Is it safe to cast a pointer to an int? */\n-    PR_ASSERT(sizeof(int) == sizeof(PRStackElem*));\n-    do {\n-        while ((addr = stack->prstk_head.prstk_elem_next) ==\n-               (PRStackElem*)_PR_AIX_ATOMIC_LOCK)\n-            ;\n-        locked = _check_lock((atomic_p)&stack->prstk_head.prstk_elem_next,\n-                             (int)addr, _PR_AIX_ATOMIC_LOCK);\n-    } while (locked == TRUE);\n-    stack_elem->prstk_elem_next = addr;\n-    _clear_lock((atomic_p)&stack->prstk_head.prstk_elem_next, (int)stack_elem);\n-    return;\n+PR_StackPush(PRStack* stack, PRStackElem* stack_elem) {\n+  PRStackElem* addr;\n+  boolean_t locked = TRUE;\n+\n+  /* Is it safe to cast a pointer to an int? */\n+  PR_ASSERT(sizeof(int) == sizeof(PRStackElem*));\n+  do {\n+    while ((addr = stack->prstk_head.prstk_elem_next) ==\n+           (PRStackElem*)_PR_AIX_ATOMIC_LOCK);\n+    locked = _check_lock((atomic_p)&stack->prstk_head.prstk_elem_next,\n+                         (int)addr, _PR_AIX_ATOMIC_LOCK);\n+  } while (locked == TRUE);\n+  stack_elem->prstk_elem_next = addr;\n+  _clear_lock((atomic_p)&stack->prstk_head.prstk_elem_next, (int)stack_elem);\n+  return;\n }\n \n PR_IMPLEMENT(PRStackElem*)\n-PR_StackPop(PRStack* stack)\n-{\n-    PRStackElem* element;\n-    boolean_t locked = TRUE;\n-\n-    /* Is it safe to cast a pointer to an int? */\n-    PR_ASSERT(sizeof(int) == sizeof(PRStackElem*));\n-    do {\n-        while ((element = stack->prstk_head.prstk_elem_next) ==\n-               (PRStackElem*)_PR_AIX_ATOMIC_LOCK)\n-            ;\n-        locked = _check_lock((atomic_p)&stack->prstk_head.prstk_elem_next,\n-                             (int)element, _PR_AIX_ATOMIC_LOCK);\n-    } while (locked == TRUE);\n-\n-    if (element == NULL) {\n-        _clear_lock((atomic_p)&stack->prstk_head.prstk_elem_next, NULL);\n-    } else {\n-        _clear_lock((atomic_p)&stack->prstk_head.prstk_elem_next,\n-                    (int)element->prstk_elem_next);\n-    }\n-    return element;\n+PR_StackPop(PRStack* stack) {\n+  PRStackElem* element;\n+  boolean_t locked = TRUE;\n+\n+  /* Is it safe to cast a pointer to an int? */\n+  PR_ASSERT(sizeof(int) == sizeof(PRStackElem*));\n+  do {\n+    while ((element = stack->prstk_head.prstk_elem_next) ==\n+           (PRStackElem*)_PR_AIX_ATOMIC_LOCK);\n+    locked = _check_lock((atomic_p)&stack->prstk_head.prstk_elem_next,\n+                         (int)element, _PR_AIX_ATOMIC_LOCK);\n+  } while (locked == TRUE);\n+\n+  if (element == NULL) {\n+    _clear_lock((atomic_p)&stack->prstk_head.prstk_elem_next, NULL);\n+  } else {\n+    _clear_lock((atomic_p)&stack->prstk_head.prstk_elem_next,\n+                (int)element->prstk_elem_next);\n+  }\n+  return element;\n }\n \n #endif /* _PR_HAVE_ATOMIC_CAS */\ndiff --git a/nspr/pr/src/md/unix/aixwrap.c b/nspr/pr/src/md/unix/aixwrap.c\nindex 74610e8..b93140c 100644\n--- a/nspr/pr/src/md/unix/aixwrap.c\n+++ b/nspr/pr/src/md/unix/aixwrap.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -13,22 +14,18 @@\n  */\n \n #ifndef AIX_RENAME_SELECT\n-#error aixwrap.c should only be used on AIX 3.2 or 4.1\n+#  error aixwrap.c should only be used on AIX 3.2 or 4.1\n #else\n \n-#include <sys/select.h>\n-#include <sys/poll.h>\n+#  include <sys/select.h>\n+#  include <sys/poll.h>\n \n-int\n-_MD_SELECT(int width, fd_set* r, fd_set* w, fd_set* e, struct timeval* t)\n-{\n-    return select(width, r, w, e, t);\n+int _MD_SELECT(int width, fd_set* r, fd_set* w, fd_set* e, struct timeval* t) {\n+  return select(width, r, w, e, t);\n }\n \n-int\n-_MD_POLL(void* listptr, unsigned long nfds, long timeout)\n-{\n-    return poll(listptr, nfds, timeout);\n+int _MD_POLL(void* listptr, unsigned long nfds, long timeout) {\n+  return poll(listptr, nfds, timeout);\n }\n \n #endif /* AIX_RENAME_SELECT */\ndiff --git a/nspr/pr/src/md/unix/darwin.c b/nspr/pr/src/md/unix/darwin.c\nindex cc445aa..ef925af 100644\n--- a/nspr/pr/src/md/unix/darwin.c\n+++ b/nspr/pr/src/md/unix/darwin.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,10 +7,7 @@\n \n #include <mach/mach_time.h>\n \n-void\n-_MD_EarlyInit(void)\n-{\n-}\n+void _MD_EarlyInit(void) {}\n \n /*\n  * The multiplier (as a fraction) for converting the Mach absolute time\n@@ -17,95 +15,69 @@ _MD_EarlyInit(void)\n  */\n static mach_timebase_info_data_t machTimebaseInfo;\n \n-void\n-_PR_Mach_IntervalInit(void)\n-{\n-    kern_return_t rv;\n+void _PR_Mach_IntervalInit(void) {\n+  kern_return_t rv;\n \n-    rv = mach_timebase_info(&machTimebaseInfo);\n-    PR_ASSERT(rv == KERN_SUCCESS);\n+  rv = mach_timebase_info(&machTimebaseInfo);\n+  PR_ASSERT(rv == KERN_SUCCESS);\n }\n \n-PRIntervalTime\n-_PR_Mach_GetInterval(void)\n-{\n-    uint64_t time;\n-\n-    /*\n-     * mach_absolute_time returns the time in the Mach absolute time unit.\n-     * Convert it to milliseconds. See Mac Technical Q&A QA1398.\n-     */\n-    time = mach_absolute_time();\n-    time =\n-        time * machTimebaseInfo.numer / machTimebaseInfo.denom / PR_NSEC_PER_MSEC;\n-    return (PRIntervalTime)time;\n+PRIntervalTime _PR_Mach_GetInterval(void) {\n+  uint64_t time;\n+\n+  /*\n+   * mach_absolute_time returns the time in the Mach absolute time unit.\n+   * Convert it to milliseconds. See Mac Technical Q&A QA1398.\n+   */\n+  time = mach_absolute_time();\n+  time =\n+      time * machTimebaseInfo.numer / machTimebaseInfo.denom / PR_NSEC_PER_MSEC;\n+  return (PRIntervalTime)time;\n } /* _PR_Mach_GetInterval */\n \n-PRIntervalTime\n-_PR_Mach_TicksPerSecond(void)\n-{\n-    return 1000;\n-}\n+PRIntervalTime _PR_Mach_TicksPerSecond(void) { return 1000; }\n \n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n+PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) {\n #if !defined(_PR_PTHREADS)\n-    if (isCurrent) {\n-        (void)setjmp(CONTEXT(t));\n-    }\n-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n-    return (PRWord*)CONTEXT(t);\n+  if (isCurrent) {\n+    (void)setjmp(CONTEXT(t));\n+  }\n+  *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n+  return (PRWord*)CONTEXT(t);\n #else\n-    *np = 0;\n-    return NULL;\n+  *np = 0;\n+  return NULL;\n #endif\n }\n \n #if !defined(_PR_PTHREADS)\n-void\n-_MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri)\n-{\n-    return;\n-}\n+void _MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri) { return; }\n \n-PRStatus\n-_MD_InitializeThread(PRThread* thread)\n-{\n-    return PR_SUCCESS;\n-}\n+PRStatus _MD_InitializeThread(PRThread* thread) { return PR_SUCCESS; }\n \n-PRStatus\n-_MD_WAIT(PRThread* thread, PRIntervalTime ticks)\n-{\n-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    _PR_MD_SWITCH_CONTEXT(thread);\n-    return PR_SUCCESS;\n+PRStatus _MD_WAIT(PRThread* thread, PRIntervalTime ticks) {\n+  PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  _PR_MD_SWITCH_CONTEXT(thread);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_WAKEUP_WAITER(PRThread* thread)\n-{\n-    if (thread) {\n-        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    }\n-    return PR_SUCCESS;\n+PRStatus _MD_WAKEUP_WAITER(PRThread* thread) {\n+  if (thread) {\n+    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  }\n+  return PR_SUCCESS;\n }\n \n /* These functions should not be called for Darwin */\n-void\n-_MD_YIELD(void)\n-{\n-    PR_NOT_REACHED(\"_MD_YIELD should not be called for Darwin.\");\n+void _MD_YIELD(void) {\n+  PR_NOT_REACHED(\"_MD_YIELD should not be called for Darwin.\");\n }\n \n-PRStatus\n-_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                  PRThreadPriority priority, PRThreadScope scope,\n-                  PRThreadState state, PRUint32 stackSize)\n-{\n-    PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for Darwin.\");\n-    return PR_FAILURE;\n+PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n+                           PRThreadPriority priority, PRThreadScope scope,\n+                           PRThreadState state, PRUint32 stackSize) {\n+  PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for Darwin.\");\n+  return PR_FAILURE;\n }\n #endif /* ! _PR_PTHREADS */\n \ndiff --git a/nspr/pr/src/md/unix/dgux.c b/nspr/pr/src/md/unix/dgux.c\nindex a1f53d6..32002c8 100644\n--- a/nspr/pr/src/md/unix/dgux.c\n+++ b/nspr/pr/src/md/unix/dgux.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,61 +12,40 @@\n \n #include <setjmp.h>\n \n-void\n-_MD_EarlyInit(void)\n-{\n-}\n+void _MD_EarlyInit(void) {}\n \n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n-    if (isCurrent) {\n-        (void)setjmp(CONTEXT(t));\n-    }\n-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n-    return (PRWord*)CONTEXT(t);\n+PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) {\n+  if (isCurrent) {\n+    (void)setjmp(CONTEXT(t));\n+  }\n+  *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n+  return (PRWord*)CONTEXT(t);\n }\n \n-void\n-_MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri)\n-{\n-    return;\n-}\n+void _MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri) { return; }\n \n-PRStatus\n-_MD_InitializeThread(PRThread* thread)\n-{\n-    return PR_SUCCESS;\n-}\n+PRStatus _MD_InitializeThread(PRThread* thread) { return PR_SUCCESS; }\n \n-PRStatus\n-_MD_WAIT(PRThread* thread, PRIntervalTime ticks)\n-{\n-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    _PR_MD_SWITCH_CONTEXT(thread);\n-    return PR_SUCCESS;\n+PRStatus _MD_WAIT(PRThread* thread, PRIntervalTime ticks) {\n+  PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  _PR_MD_SWITCH_CONTEXT(thread);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_WAKEUP_WAITER(PRThread* thread)\n-{\n-    if (thread) {\n-        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    }\n-    return PR_SUCCESS;\n+PRStatus _MD_WAKEUP_WAITER(PRThread* thread) {\n+  if (thread) {\n+    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  }\n+  return PR_SUCCESS;\n }\n \n /* These functions should not be called for DG/UX */\n-void\n-_MD_YIELD(void)\n-{\n-    PR_NOT_REACHED(\"_MD_YIELD should not be called for DG/UX.\");\n+void _MD_YIELD(void) {\n+  PR_NOT_REACHED(\"_MD_YIELD should not be called for DG/UX.\");\n }\n \n-PRStatus\n-_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                  PRThreadPriority priority, PRThreadScope scope,\n-                  PRThreadState state, PRUint32 stackSize)\n-{\n-    PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for DG/UX.\");\n+PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n+                           PRThreadPriority priority, PRThreadScope scope,\n+                           PRThreadState state, PRUint32 stackSize) {\n+  PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for DG/UX.\");\n }\ndiff --git a/nspr/pr/src/md/unix/freebsd.c b/nspr/pr/src/md/unix/freebsd.c\nindex afb4a9b..b3ad369 100644\n--- a/nspr/pr/src/md/unix/freebsd.c\n+++ b/nspr/pr/src/md/unix/freebsd.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,79 +7,59 @@\n \n #include <signal.h>\n \n-void\n-_MD_EarlyInit(void)\n-{\n-    /*\n-     * Ignore FPE because coercion of a NaN to an int causes SIGFPE\n-     * to be raised.\n-     */\n-    struct sigaction act;\n+void _MD_EarlyInit(void) {\n+  /*\n+   * Ignore FPE because coercion of a NaN to an int causes SIGFPE\n+   * to be raised.\n+   */\n+  struct sigaction act;\n \n-    act.sa_handler = SIG_IGN;\n-    sigemptyset(&act.sa_mask);\n-    act.sa_flags = SA_RESTART;\n-    sigaction(SIGFPE, &act, 0);\n+  act.sa_handler = SIG_IGN;\n+  sigemptyset(&act.sa_mask);\n+  act.sa_flags = SA_RESTART;\n+  sigaction(SIGFPE, &act, 0);\n }\n \n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n+PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) {\n #ifndef _PR_PTHREADS\n-    if (isCurrent) {\n-        (void)sigsetjmp(CONTEXT(t), 1);\n-    }\n-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n-    return (PRWord*)CONTEXT(t);\n+  if (isCurrent) {\n+    (void)sigsetjmp(CONTEXT(t), 1);\n+  }\n+  *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n+  return (PRWord*)CONTEXT(t);\n #else\n-    *np = 0;\n-    return NULL;\n+  *np = 0;\n+  return NULL;\n #endif\n }\n \n #ifndef _PR_PTHREADS\n-void\n-_MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri)\n-{\n-    return;\n-}\n+void _MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri) { return; }\n \n-PRStatus\n-_MD_InitializeThread(PRThread* thread)\n-{\n-    return PR_SUCCESS;\n-}\n+PRStatus _MD_InitializeThread(PRThread* thread) { return PR_SUCCESS; }\n \n-PRStatus\n-_MD_WAIT(PRThread* thread, PRIntervalTime ticks)\n-{\n-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    _PR_MD_SWITCH_CONTEXT(thread);\n-    return PR_SUCCESS;\n+PRStatus _MD_WAIT(PRThread* thread, PRIntervalTime ticks) {\n+  PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  _PR_MD_SWITCH_CONTEXT(thread);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_WAKEUP_WAITER(PRThread* thread)\n-{\n-    if (thread) {\n-        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    }\n-    return PR_SUCCESS;\n+PRStatus _MD_WAKEUP_WAITER(PRThread* thread) {\n+  if (thread) {\n+    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  }\n+  return PR_SUCCESS;\n }\n \n /* These functions should not be called for FreeBSD */\n-void\n-_MD_YIELD(void)\n-{\n-    PR_NOT_REACHED(\"_MD_YIELD should not be called for FreeBSD.\");\n+void _MD_YIELD(void) {\n+  PR_NOT_REACHED(\"_MD_YIELD should not be called for FreeBSD.\");\n }\n \n-PRStatus\n-_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                  PRThreadPriority priority, PRThreadScope scope,\n-                  PRThreadState state, PRUint32 stackSize)\n-{\n-    PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for FreeBSD.\");\n-    return PR_FAILURE;\n+PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n+                           PRThreadPriority priority, PRThreadScope scope,\n+                           PRThreadState state, PRUint32 stackSize) {\n+  PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for FreeBSD.\");\n+  return PR_FAILURE;\n }\n #endif /* ! _PR_PTHREADS */\ndiff --git a/nspr/pr/src/md/unix/linux.c b/nspr/pr/src/md/unix/linux.c\nindex 8167150..75e47bb 100644\n--- a/nspr/pr/src/md/unix/linux.c\n+++ b/nspr/pr/src/md/unix/linux.c\n@@ -1,26 +1,22 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n \n #include \"primpl.h\"\n \n-void\n-_MD_EarlyInit(void)\n-{\n-}\n+void _MD_EarlyInit(void) {}\n \n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n+PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) {\n #ifndef _PR_PTHREADS\n-    if (isCurrent) {\n-        (void)setjmp(CONTEXT(t));\n-    }\n-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n-    return (PRWord*)CONTEXT(t);\n+  if (isCurrent) {\n+    (void)setjmp(CONTEXT(t));\n+  }\n+  *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n+  return (PRWord*)CONTEXT(t);\n #else\n-    *np = 0;\n-    return NULL;\n+  *np = 0;\n+  return NULL;\n #endif\n }\n \n@@ -28,62 +24,44 @@ _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n \n extern void _MD_unix_terminate_waitpid_daemon(void);\n \n-void\n-_MD_CleanupBeforeExit(void)\n-{\n-    _MD_unix_terminate_waitpid_daemon();\n-}\n+void _MD_CleanupBeforeExit(void) { _MD_unix_terminate_waitpid_daemon(); }\n \n #else  /* ! _PR_PTHREADS */\n \n-void\n-_MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri)\n-{\n-    return;\n-}\n+void _MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri) { return; }\n \n-PRStatus\n-_MD_InitializeThread(PRThread* thread)\n-{\n-    /*\n-     * set the pointers to the stack-pointer and frame-pointer words in the\n-     * context structure; this is for debugging use.\n-     */\n-    thread->md.sp = _MD_GET_SP_PTR(thread);\n-    thread->md.fp = _MD_GET_FP_PTR(thread);\n-    return PR_SUCCESS;\n+PRStatus _MD_InitializeThread(PRThread* thread) {\n+  /*\n+   * set the pointers to the stack-pointer and frame-pointer words in the\n+   * context structure; this is for debugging use.\n+   */\n+  thread->md.sp = _MD_GET_SP_PTR(thread);\n+  thread->md.fp = _MD_GET_FP_PTR(thread);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_WAIT(PRThread* thread, PRIntervalTime ticks)\n-{\n-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    _PR_MD_SWITCH_CONTEXT(thread);\n-    return PR_SUCCESS;\n+PRStatus _MD_WAIT(PRThread* thread, PRIntervalTime ticks) {\n+  PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  _PR_MD_SWITCH_CONTEXT(thread);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_WAKEUP_WAITER(PRThread* thread)\n-{\n-    if (thread) {\n-        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    }\n-    return PR_SUCCESS;\n+PRStatus _MD_WAKEUP_WAITER(PRThread* thread) {\n+  if (thread) {\n+    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  }\n+  return PR_SUCCESS;\n }\n \n /* These functions should not be called for Linux */\n-void\n-_MD_YIELD(void)\n-{\n-    PR_NOT_REACHED(\"_MD_YIELD should not be called for Linux.\");\n+void _MD_YIELD(void) {\n+  PR_NOT_REACHED(\"_MD_YIELD should not be called for Linux.\");\n }\n \n-PRStatus\n-_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                  PRThreadPriority priority, PRThreadScope scope,\n-                  PRThreadState state, PRUint32 stackSize)\n-{\n-    PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for Linux.\");\n-    return PR_FAILURE;\n+PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n+                           PRThreadPriority priority, PRThreadScope scope,\n+                           PRThreadState state, PRUint32 stackSize) {\n+  PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for Linux.\");\n+  return PR_FAILURE;\n }\n #endif /* ! _PR_PTHREADS */\ndiff --git a/nspr/pr/src/md/unix/netbsd.c b/nspr/pr/src/md/unix/netbsd.c\nindex 2d8656c..f1a8f0e 100644\n--- a/nspr/pr/src/md/unix/netbsd.c\n+++ b/nspr/pr/src/md/unix/netbsd.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,79 +9,59 @@\n #include <poll.h>\n #include <sys/syscall.h>\n \n-void\n-_MD_EarlyInit(void)\n-{\n-    /*\n-     * Ignore FPE because coercion of a NaN to an int causes SIGFPE\n-     * to be raised.\n-     */\n-    struct sigaction act;\n+void _MD_EarlyInit(void) {\n+  /*\n+   * Ignore FPE because coercion of a NaN to an int causes SIGFPE\n+   * to be raised.\n+   */\n+  struct sigaction act;\n \n-    act.sa_handler = SIG_IGN;\n-    sigemptyset(&act.sa_mask);\n-    act.sa_flags = SA_RESTART;\n-    sigaction(SIGFPE, &act, 0);\n+  act.sa_handler = SIG_IGN;\n+  sigemptyset(&act.sa_mask);\n+  act.sa_flags = SA_RESTART;\n+  sigaction(SIGFPE, &act, 0);\n }\n \n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n+PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) {\n #ifndef _PR_PTHREADS\n-    if (isCurrent) {\n-        (void)sigsetjmp(CONTEXT(t), 1);\n-    }\n-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n-    return (PRWord*)CONTEXT(t);\n+  if (isCurrent) {\n+    (void)sigsetjmp(CONTEXT(t), 1);\n+  }\n+  *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n+  return (PRWord*)CONTEXT(t);\n #else\n-    *np = 0;\n-    return NULL;\n+  *np = 0;\n+  return NULL;\n #endif\n }\n \n #ifndef _PR_PTHREADS\n-void\n-_MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri)\n-{\n-    return;\n-}\n+void _MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri) { return; }\n \n-PRStatus\n-_MD_InitializeThread(PRThread* thread)\n-{\n-    return PR_SUCCESS;\n-}\n+PRStatus _MD_InitializeThread(PRThread* thread) { return PR_SUCCESS; }\n \n-PRStatus\n-_MD_WAIT(PRThread* thread, PRIntervalTime ticks)\n-{\n-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    _PR_MD_SWITCH_CONTEXT(thread);\n-    return PR_SUCCESS;\n+PRStatus _MD_WAIT(PRThread* thread, PRIntervalTime ticks) {\n+  PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  _PR_MD_SWITCH_CONTEXT(thread);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_WAKEUP_WAITER(PRThread* thread)\n-{\n-    if (thread) {\n-        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    }\n-    return PR_SUCCESS;\n+PRStatus _MD_WAKEUP_WAITER(PRThread* thread) {\n+  if (thread) {\n+    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  }\n+  return PR_SUCCESS;\n }\n \n /* These functions should not be called for NetBSD */\n-void\n-_MD_YIELD(void)\n-{\n-    PR_NOT_REACHED(\"_MD_YIELD should not be called for NetBSD.\");\n+void _MD_YIELD(void) {\n+  PR_NOT_REACHED(\"_MD_YIELD should not be called for NetBSD.\");\n }\n \n-PRStatus\n-_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                  PRThreadPriority priority, PRThreadScope scope,\n-                  PRThreadState state, PRUint32 stackSize)\n-{\n-    PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for NetBSD.\");\n-    return PR_FAILURE;\n+PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n+                           PRThreadPriority priority, PRThreadScope scope,\n+                           PRThreadState state, PRUint32 stackSize) {\n+  PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for NetBSD.\");\n+  return PR_FAILURE;\n }\n #endif /* ! _PR_PTHREADS */\ndiff --git a/nspr/pr/src/md/unix/nto.c b/nspr/pr/src/md/unix/nto.c\nindex ebf1124..63d0921 100644\n--- a/nspr/pr/src/md/unix/nto.c\n+++ b/nspr/pr/src/md/unix/nto.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,30 +8,23 @@\n #include <setjmp.h>\n \n /* Fake this out */\n-int\n-socketpair(int foo, int foo2, int foo3, int sv[2])\n-{\n-    printf(\"error in socketpair\\n\");\n-    exit(-1);\n+int socketpair(int foo, int foo2, int foo3, int sv[2]) {\n+  printf(\"error in socketpair\\n\");\n+  exit(-1);\n }\n \n-void\n-_MD_EarlyInit(void)\n-{\n-}\n+void _MD_EarlyInit(void) {}\n \n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n+PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) {\n #ifndef _PR_PTHREADS\n-    if (isCurrent) {\n-        (void)setjmp(CONTEXT(t));\n-    }\n+  if (isCurrent) {\n+    (void)setjmp(CONTEXT(t));\n+  }\n \n-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n-    return (PRWord*)CONTEXT(t);\n+  *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n+  return (PRWord*)CONTEXT(t);\n #else\n-    *np = 0;\n-    return NULL;\n+  *np = 0;\n+  return NULL;\n #endif\n }\ndiff --git a/nspr/pr/src/md/unix/openbsd.c b/nspr/pr/src/md/unix/openbsd.c\nindex a6e2c0d..094a758 100644\n--- a/nspr/pr/src/md/unix/openbsd.c\n+++ b/nspr/pr/src/md/unix/openbsd.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,79 +9,59 @@\n #include <poll.h>\n #include <sys/syscall.h>\n \n-void\n-_MD_EarlyInit(void)\n-{\n-    /*\n-     * Ignore FPE because coercion of a NaN to an int causes SIGFPE\n-     * to be raised.\n-     */\n-    struct sigaction act;\n+void _MD_EarlyInit(void) {\n+  /*\n+   * Ignore FPE because coercion of a NaN to an int causes SIGFPE\n+   * to be raised.\n+   */\n+  struct sigaction act;\n \n-    act.sa_handler = SIG_IGN;\n-    sigemptyset(&act.sa_mask);\n-    act.sa_flags = SA_RESTART;\n-    sigaction(SIGFPE, &act, 0);\n+  act.sa_handler = SIG_IGN;\n+  sigemptyset(&act.sa_mask);\n+  act.sa_flags = SA_RESTART;\n+  sigaction(SIGFPE, &act, 0);\n }\n \n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n+PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) {\n #ifndef _PR_PTHREADS\n-    if (isCurrent) {\n-        (void)sigsetjmp(CONTEXT(t), 1);\n-    }\n-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n-    return (PRWord*)CONTEXT(t);\n+  if (isCurrent) {\n+    (void)sigsetjmp(CONTEXT(t), 1);\n+  }\n+  *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n+  return (PRWord*)CONTEXT(t);\n #else\n-    *np = 0;\n-    return NULL;\n+  *np = 0;\n+  return NULL;\n #endif\n }\n \n #ifndef _PR_PTHREADS\n-void\n-_MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri)\n-{\n-    return;\n-}\n+void _MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri) { return; }\n \n-PRStatus\n-_MD_InitializeThread(PRThread* thread)\n-{\n-    return PR_SUCCESS;\n-}\n+PRStatus _MD_InitializeThread(PRThread* thread) { return PR_SUCCESS; }\n \n-PRStatus\n-_MD_WAIT(PRThread* thread, PRIntervalTime ticks)\n-{\n-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    _PR_MD_SWITCH_CONTEXT(thread);\n-    return PR_SUCCESS;\n+PRStatus _MD_WAIT(PRThread* thread, PRIntervalTime ticks) {\n+  PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  _PR_MD_SWITCH_CONTEXT(thread);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_WAKEUP_WAITER(PRThread* thread)\n-{\n-    if (thread) {\n-        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    }\n-    return PR_SUCCESS;\n+PRStatus _MD_WAKEUP_WAITER(PRThread* thread) {\n+  if (thread) {\n+    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  }\n+  return PR_SUCCESS;\n }\n \n /* These functions should not be called for OpenBSD */\n-void\n-_MD_YIELD(void)\n-{\n-    PR_NOT_REACHED(\"_MD_YIELD should not be called for OpenBSD.\");\n+void _MD_YIELD(void) {\n+  PR_NOT_REACHED(\"_MD_YIELD should not be called for OpenBSD.\");\n }\n \n-PRStatus\n-_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                  PRThreadPriority priority, PRThreadScope scope,\n-                  PRThreadState state, PRUint32 stackSize)\n-{\n-    PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for OpenBSD.\");\n-    return PR_FAILURE;\n+PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n+                           PRThreadPriority priority, PRThreadScope scope,\n+                           PRThreadState state, PRUint32 stackSize) {\n+  PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for OpenBSD.\");\n+  return PR_FAILURE;\n }\n #endif /* ! _PR_PTHREADS */\ndiff --git a/nspr/pr/src/md/unix/os_AIX.s b/nspr/pr/src/md/unix/os_AIX.s\nindex ad9794f..0227cc4 100644\n--- a/nspr/pr/src/md/unix/os_AIX.s\n+++ b/nspr/pr/src/md/unix/os_AIX.s\n@@ -1,3 +1,4 @@\n+# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n # \n # This Source Code Form is subject to the terms of the Mozilla Public\n # License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/os_BSD_386_2.s b/nspr/pr/src/md/unix/os_BSD_386_2.s\nindex dfafcb7..fa36599 100644\n--- a/nspr/pr/src/md/unix/os_BSD_386_2.s\n+++ b/nspr/pr/src/md/unix/os_BSD_386_2.s\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/src/md/unix/os_Darwin.s b/nspr/pr/src/md/unix/os_Darwin.s\nindex ee9ab7e..26a0b92 100644\n--- a/nspr/pr/src/md/unix/os_Darwin.s\n+++ b/nspr/pr/src/md/unix/os_Darwin.s\n@@ -1,3 +1,4 @@\n+# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n #\n # This Source Code Form is subject to the terms of the Mozilla Public\n # License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/os_Darwin_ppc.s b/nspr/pr/src/md/unix/os_Darwin_ppc.s\nindex 0a1c012..8479dec 100644\n--- a/nspr/pr/src/md/unix/os_Darwin_ppc.s\n+++ b/nspr/pr/src/md/unix/os_Darwin_ppc.s\n@@ -1,3 +1,4 @@\n+# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n #\n # This Source Code Form is subject to the terms of the Mozilla Public\n # License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/os_Darwin_x86.s b/nspr/pr/src/md/unix/os_Darwin_x86.s\nindex 9a21a59..fc6379f 100644\n--- a/nspr/pr/src/md/unix/os_Darwin_x86.s\n+++ b/nspr/pr/src/md/unix/os_Darwin_x86.s\n@@ -1,3 +1,4 @@\n+# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n #\n # This Source Code Form is subject to the terms of the Mozilla Public\n # License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/os_Darwin_x86_64.s b/nspr/pr/src/md/unix/os_Darwin_x86_64.s\nindex c9a907f..449aaa5 100644\n--- a/nspr/pr/src/md/unix/os_Darwin_x86_64.s\n+++ b/nspr/pr/src/md/unix/os_Darwin_x86_64.s\n@@ -1,3 +1,4 @@\n+# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n # \n # This Source Code Form is subject to the terms of the Mozilla Public\n # License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/os_HPUX_ia64.s b/nspr/pr/src/md/unix/os_HPUX_ia64.s\nindex f4a503c..302ae76 100644\n--- a/nspr/pr/src/md/unix/os_HPUX_ia64.s\n+++ b/nspr/pr/src/md/unix/os_HPUX_ia64.s\n@@ -1,3 +1,4 @@\n+// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n // \n // This Source Code Form is subject to the terms of the Mozilla Public\n // License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/os_Linux_ia64.s b/nspr/pr/src/md/unix/os_Linux_ia64.s\nindex ff996a7..39b724a 100644\n--- a/nspr/pr/src/md/unix/os_Linux_ia64.s\n+++ b/nspr/pr/src/md/unix/os_Linux_ia64.s\n@@ -1,3 +1,4 @@\n+// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n // \n // This Source Code Form is subject to the terms of the Mozilla Public\n // License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/os_Linux_ppc.s b/nspr/pr/src/md/unix/os_Linux_ppc.s\nindex c9b9dc7..76da33b 100644\n--- a/nspr/pr/src/md/unix/os_Linux_ppc.s\n+++ b/nspr/pr/src/md/unix/os_Linux_ppc.s\n@@ -1,3 +1,4 @@\n+# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n #\n # This Source Code Form is subject to the terms of the Mozilla Public\n # License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/os_Linux_x86.s b/nspr/pr/src/md/unix/os_Linux_x86.s\nindex bd19dc3..83e10b4 100644\n--- a/nspr/pr/src/md/unix/os_Linux_x86.s\n+++ b/nspr/pr/src/md/unix/os_Linux_x86.s\n@@ -1,3 +1,4 @@\n+// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n // \n // This Source Code Form is subject to the terms of the Mozilla Public\n // License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/os_Linux_x86_64.s b/nspr/pr/src/md/unix/os_Linux_x86_64.s\nindex b9310dd..f30e75d 100644\n--- a/nspr/pr/src/md/unix/os_Linux_x86_64.s\n+++ b/nspr/pr/src/md/unix/os_Linux_x86_64.s\n@@ -1,3 +1,4 @@\n+// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n // \n // This Source Code Form is subject to the terms of the Mozilla Public\n // License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/os_SunOS_sparcv9.s b/nspr/pr/src/md/unix/os_SunOS_sparcv9.s\nindex 95226a2..8bc75af 100644\n--- a/nspr/pr/src/md/unix/os_SunOS_sparcv9.s\n+++ b/nspr/pr/src/md/unix/os_SunOS_sparcv9.s\n@@ -1,3 +1,4 @@\n+! -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n ! \n ! This Source Code Form is subject to the terms of the Mozilla Public\n ! License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/os_SunOS_ultrasparc.s b/nspr/pr/src/md/unix/os_SunOS_ultrasparc.s\nindex dcda602..32bf788 100644\n--- a/nspr/pr/src/md/unix/os_SunOS_ultrasparc.s\n+++ b/nspr/pr/src/md/unix/os_SunOS_ultrasparc.s\n@@ -1,3 +1,4 @@\n+! -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n ! \n ! This Source Code Form is subject to the terms of the Mozilla Public\n ! License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/os_SunOS_x86.s b/nspr/pr/src/md/unix/os_SunOS_x86.s\nindex 890a251..dcd7535 100644\n--- a/nspr/pr/src/md/unix/os_SunOS_x86.s\n+++ b/nspr/pr/src/md/unix/os_SunOS_x86.s\n@@ -1,3 +1,4 @@\n+// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n // \n // This Source Code Form is subject to the terms of the Mozilla Public\n // License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/os_SunOS_x86_64.s b/nspr/pr/src/md/unix/os_SunOS_x86_64.s\nindex 4dc0909..5e3df04 100644\n--- a/nspr/pr/src/md/unix/os_SunOS_x86_64.s\n+++ b/nspr/pr/src/md/unix/os_SunOS_x86_64.s\n@@ -1,3 +1,4 @@\n+// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-\n // \n // This Source Code Form is subject to the terms of the Mozilla Public\n // License, v. 2.0. If a copy of the MPL was not distributed with this\ndiff --git a/nspr/pr/src/md/unix/pthreads_user.c b/nspr/pr/src/md/unix/pthreads_user.c\nindex 1b64d00..ef8855b 100644\n--- a/nspr/pr/src/md/unix/pthreads_user.c\n+++ b/nspr/pr/src/md/unix/pthreads_user.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -18,106 +19,93 @@ pthread_key_t intsoff_key;\n PRInt32 _pr_md_pthreads_created, _pr_md_pthreads_failed;\n PRInt32 _pr_md_pthreads = 1;\n \n-void\n-_MD_EarlyInit(void)\n-{\n-    extern PRInt32 _nspr_noclock;\n-\n-    if (pthread_key_create(&current_thread_key, NULL) != 0) {\n-        perror(\"pthread_key_create failed\");\n-        exit(1);\n-    }\n-    if (pthread_key_create(&current_cpu_key, NULL) != 0) {\n-        perror(\"pthread_key_create failed\");\n-        exit(1);\n-    }\n-    if (pthread_key_create(&last_thread_key, NULL) != 0) {\n-        perror(\"pthread_key_create failed\");\n-        exit(1);\n-    }\n-    if (pthread_key_create(&intsoff_key, NULL) != 0) {\n-        perror(\"pthread_key_create failed\");\n-        exit(1);\n-    }\n-\n-    sigemptyset(&ints_off);\n-    sigaddset(&ints_off, SIGALRM);\n-    sigaddset(&ints_off, SIGIO);\n-    sigaddset(&ints_off, SIGCLD);\n-\n-    /*\n-     * disable clock interrupts\n-     */\n-    _nspr_noclock = 1;\n+void _MD_EarlyInit(void) {\n+  extern PRInt32 _nspr_noclock;\n+\n+  if (pthread_key_create(&current_thread_key, NULL) != 0) {\n+    perror(\"pthread_key_create failed\");\n+    exit(1);\n+  }\n+  if (pthread_key_create(&current_cpu_key, NULL) != 0) {\n+    perror(\"pthread_key_create failed\");\n+    exit(1);\n+  }\n+  if (pthread_key_create(&last_thread_key, NULL) != 0) {\n+    perror(\"pthread_key_create failed\");\n+    exit(1);\n+  }\n+  if (pthread_key_create(&intsoff_key, NULL) != 0) {\n+    perror(\"pthread_key_create failed\");\n+    exit(1);\n+  }\n+\n+  sigemptyset(&ints_off);\n+  sigaddset(&ints_off, SIGALRM);\n+  sigaddset(&ints_off, SIGIO);\n+  sigaddset(&ints_off, SIGCLD);\n+\n+  /*\n+   * disable clock interrupts\n+   */\n+  _nspr_noclock = 1;\n }\n \n-void\n-_MD_InitLocks()\n-{\n-    if (pthread_mutex_init(&_pr_heapLock, NULL) != 0) {\n-        perror(\"pthread_mutex_init failed\");\n-        exit(1);\n-    }\n+void _MD_InitLocks() {\n+  if (pthread_mutex_init(&_pr_heapLock, NULL) != 0) {\n+    perror(\"pthread_mutex_init failed\");\n+    exit(1);\n+  }\n }\n \n-PR_IMPLEMENT(void)\n-_MD_FREE_LOCK(struct _MDLock* lockp)\n-{\n-    PRIntn _is;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (me && !_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(_is);\n-    }\n-    pthread_mutex_destroy(&lockp->mutex);\n-    if (me && !_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_FAST_INTSON(_is);\n-    }\n+PR_IMPLEMENT(void) _MD_FREE_LOCK(struct _MDLock* lockp) {\n+  PRIntn _is;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (me && !_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(_is);\n+  }\n+  pthread_mutex_destroy(&lockp->mutex);\n+  if (me && !_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_FAST_INTSON(_is);\n+  }\n }\n \n-PR_IMPLEMENT(PRStatus)\n-_MD_NEW_LOCK(struct _MDLock* lockp)\n-{\n-    PRStatus rv;\n-    PRIntn is;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (me && !_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-    rv = pthread_mutex_init(&lockp->mutex, NULL);\n-    if (me && !_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_FAST_INTSON(is);\n-    }\n-    return (rv == 0) ? PR_SUCCESS : PR_FAILURE;\n+PR_IMPLEMENT(PRStatus) _MD_NEW_LOCK(struct _MDLock* lockp) {\n+  PRStatus rv;\n+  PRIntn is;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (me && !_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+  rv = pthread_mutex_init(&lockp->mutex, NULL);\n+  if (me && !_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_FAST_INTSON(is);\n+  }\n+  return (rv == 0) ? PR_SUCCESS : PR_FAILURE;\n }\n \n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n-    if (isCurrent) {\n-        (void)setjmp(CONTEXT(t));\n-    }\n-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n-    return (PRWord*)CONTEXT(t);\n+PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) {\n+  if (isCurrent) {\n+    (void)setjmp(CONTEXT(t));\n+  }\n+  *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n+  return (PRWord*)CONTEXT(t);\n }\n \n PR_IMPLEMENT(void)\n-_MD_SetPriority(_MDThread* thread, PRThreadPriority newPri)\n-{\n-    /*\n-     * XXX - to be implemented\n-     */\n-    return;\n+_MD_SetPriority(_MDThread* thread, PRThreadPriority newPri) {\n+  /*\n+   * XXX - to be implemented\n+   */\n+  return;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-_MD_InitThread(struct PRThread* thread)\n-{\n-    struct sigaction sigact;\n+PR_IMPLEMENT(PRStatus) _MD_InitThread(struct PRThread* thread) {\n+  struct sigaction sigact;\n \n-    if (thread->flags & _PR_GLOBAL_SCOPE) {\n-        thread->md.pthread = pthread_self();\n+  if (thread->flags & _PR_GLOBAL_SCOPE) {\n+    thread->md.pthread = pthread_self();\n #if 0\n         /*\n          * set up SIGUSR1 handler; this is used to save state\n@@ -131,35 +119,29 @@ _MD_InitThread(struct PRThread* thread)\n         sigact.sa_mask = timer_set;\n         sigaction(SIGUSR1, &sigact, 0);\n #endif\n-    }\n+  }\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(void)\n-_MD_ExitThread(struct PRThread* thread)\n-{\n-    if (thread->flags & _PR_GLOBAL_SCOPE) {\n-        _MD_CLEAN_THREAD(thread);\n-        _MD_SET_CURRENT_THREAD(NULL);\n-    }\n+PR_IMPLEMENT(void) _MD_ExitThread(struct PRThread* thread) {\n+  if (thread->flags & _PR_GLOBAL_SCOPE) {\n+    _MD_CLEAN_THREAD(thread);\n+    _MD_SET_CURRENT_THREAD(NULL);\n+  }\n }\n \n-PR_IMPLEMENT(void)\n-_MD_CleanThread(struct PRThread* thread)\n-{\n-    if (thread->flags & _PR_GLOBAL_SCOPE) {\n-        pthread_mutex_destroy(&thread->md.pthread_mutex);\n-        pthread_cond_destroy(&thread->md.pthread_cond);\n-    }\n+PR_IMPLEMENT(void) _MD_CleanThread(struct PRThread* thread) {\n+  if (thread->flags & _PR_GLOBAL_SCOPE) {\n+    pthread_mutex_destroy(&thread->md.pthread_mutex);\n+    pthread_cond_destroy(&thread->md.pthread_cond);\n+  }\n }\n \n-PR_IMPLEMENT(void)\n-_MD_SuspendThread(struct PRThread* thread)\n-{\n-    PRInt32 rv;\n+PR_IMPLEMENT(void) _MD_SuspendThread(struct PRThread* thread) {\n+  PRInt32 rv;\n \n-    PR_ASSERT((thread->flags & _PR_GLOBAL_SCOPE) && _PR_IS_GCABLE_THREAD(thread));\n+  PR_ASSERT((thread->flags & _PR_GLOBAL_SCOPE) && _PR_IS_GCABLE_THREAD(thread));\n #if 0\n     thread->md.suspending_id = getpid();\n     rv = kill(thread->md.id, SIGUSR1);\n@@ -172,21 +154,17 @@ _MD_SuspendThread(struct PRThread* thread)\n #endif\n }\n \n-PR_IMPLEMENT(void)\n-_MD_ResumeThread(struct PRThread* thread)\n-{\n-    PRInt32 rv;\n+PR_IMPLEMENT(void) _MD_ResumeThread(struct PRThread* thread) {\n+  PRInt32 rv;\n \n-    PR_ASSERT((thread->flags & _PR_GLOBAL_SCOPE) && _PR_IS_GCABLE_THREAD(thread));\n+  PR_ASSERT((thread->flags & _PR_GLOBAL_SCOPE) && _PR_IS_GCABLE_THREAD(thread));\n #if 0\n     rv = unblockproc(thread->md.id);\n #endif\n }\n \n-PR_IMPLEMENT(void)\n-_MD_SuspendCPU(struct _PRCPU* thread)\n-{\n-    PRInt32 rv;\n+PR_IMPLEMENT(void) _MD_SuspendCPU(struct _PRCPU* thread) {\n+  PRInt32 rv;\n \n #if 0\n     cpu->md.suspending_id = getpid();\n@@ -200,9 +178,7 @@ _MD_SuspendCPU(struct _PRCPU* thread)\n #endif\n }\n \n-PR_IMPLEMENT(void)\n-_MD_ResumeCPU(struct _PRCPU* thread)\n-{\n+PR_IMPLEMENT(void) _MD_ResumeCPU(struct _PRCPU* thread) {\n #if 0\n     unblockproc(cpu->md.id);\n #endif\n@@ -212,122 +188,119 @@ _MD_ResumeCPU(struct _PRCPU* thread)\n #define PT_BILLION 1000000000UL\n \n PR_IMPLEMENT(PRStatus)\n-_pt_wait(PRThread* thread, PRIntervalTime timeout)\n-{\n-    int rv;\n-    struct timeval now;\n-    struct timespec tmo;\n-    PRUint32 ticks = PR_TicksPerSecond();\n-\n+_pt_wait(PRThread* thread, PRIntervalTime timeout) {\n+  int rv;\n+  struct timeval now;\n+  struct timespec tmo;\n+  PRUint32 ticks = PR_TicksPerSecond();\n+\n+  if (timeout != PR_INTERVAL_NO_TIMEOUT) {\n+    tmo.tv_sec = timeout / ticks;\n+    tmo.tv_nsec = timeout - (tmo.tv_sec * ticks);\n+    tmo.tv_nsec = PR_IntervalToMicroseconds(PT_NANOPERMICRO * tmo.tv_nsec);\n+\n+    /* pthreads wants this in absolute time, off we go ... */\n+    (void)GETTIMEOFDAY(&now);\n+    /* that one's usecs, this one's nsecs - grrrr! */\n+    tmo.tv_sec += now.tv_sec;\n+    tmo.tv_nsec += (PT_NANOPERMICRO * now.tv_usec);\n+    tmo.tv_sec += tmo.tv_nsec / PT_BILLION;\n+    tmo.tv_nsec %= PT_BILLION;\n+  }\n+\n+  pthread_mutex_lock(&thread->md.pthread_mutex);\n+  thread->md.wait--;\n+  if (thread->md.wait < 0) {\n     if (timeout != PR_INTERVAL_NO_TIMEOUT) {\n-        tmo.tv_sec = timeout / ticks;\n-        tmo.tv_nsec = timeout - (tmo.tv_sec * ticks);\n-        tmo.tv_nsec = PR_IntervalToMicroseconds(PT_NANOPERMICRO * tmo.tv_nsec);\n-\n-        /* pthreads wants this in absolute time, off we go ... */\n-        (void)GETTIMEOFDAY(&now);\n-        /* that one's usecs, this one's nsecs - grrrr! */\n-        tmo.tv_sec += now.tv_sec;\n-        tmo.tv_nsec += (PT_NANOPERMICRO * now.tv_usec);\n-        tmo.tv_sec += tmo.tv_nsec / PT_BILLION;\n-        tmo.tv_nsec %= PT_BILLION;\n+      rv = pthread_cond_timedwait(&thread->md.pthread_cond,\n+                                  &thread->md.pthread_mutex, &tmo);\n+    } else\n+      rv = pthread_cond_wait(&thread->md.pthread_cond,\n+                             &thread->md.pthread_mutex);\n+    if (rv != 0) {\n+      thread->md.wait++;\n     }\n+  } else {\n+    rv = 0;\n+  }\n+  pthread_mutex_unlock(&thread->md.pthread_mutex);\n \n-    pthread_mutex_lock(&thread->md.pthread_mutex);\n-    thread->md.wait--;\n-    if (thread->md.wait < 0) {\n-        if (timeout != PR_INTERVAL_NO_TIMEOUT) {\n-            rv = pthread_cond_timedwait(&thread->md.pthread_cond,\n-                                        &thread->md.pthread_mutex, &tmo);\n-        } else\n-            rv = pthread_cond_wait(&thread->md.pthread_cond,\n-                                   &thread->md.pthread_mutex);\n-        if (rv != 0) {\n-            thread->md.wait++;\n-        }\n-    } else {\n-        rv = 0;\n-    }\n-    pthread_mutex_unlock(&thread->md.pthread_mutex);\n-\n-    return (rv == 0) ? PR_SUCCESS : PR_FAILURE;\n+  return (rv == 0) ? PR_SUCCESS : PR_FAILURE;\n }\n \n PR_IMPLEMENT(PRStatus)\n-_MD_wait(PRThread* thread, PRIntervalTime ticks)\n-{\n-    if (thread->flags & _PR_GLOBAL_SCOPE) {\n-        _MD_CHECK_FOR_EXIT();\n-        if (_pt_wait(thread, ticks) == PR_FAILURE) {\n-            _MD_CHECK_FOR_EXIT();\n-            /*\n-             * wait timed out\n-             */\n-            _PR_THREAD_LOCK(thread);\n-            if (thread->wait.cvar) {\n-                /*\n-                 * The thread will remove itself from the waitQ\n-                 * of the cvar in _PR_WaitCondVar\n-                 */\n-                thread->wait.cvar = NULL;\n-                thread->state = _PR_RUNNING;\n-                _PR_THREAD_UNLOCK(thread);\n-            } else {\n-                _pt_wait(thread, PR_INTERVAL_NO_TIMEOUT);\n-                _PR_THREAD_UNLOCK(thread);\n-            }\n-        }\n-    } else {\n-        _PR_MD_SWITCH_CONTEXT(thread);\n+_MD_wait(PRThread* thread, PRIntervalTime ticks) {\n+  if (thread->flags & _PR_GLOBAL_SCOPE) {\n+    _MD_CHECK_FOR_EXIT();\n+    if (_pt_wait(thread, ticks) == PR_FAILURE) {\n+      _MD_CHECK_FOR_EXIT();\n+      /*\n+       * wait timed out\n+       */\n+      _PR_THREAD_LOCK(thread);\n+      if (thread->wait.cvar) {\n+        /*\n+         * The thread will remove itself from the waitQ\n+         * of the cvar in _PR_WaitCondVar\n+         */\n+        thread->wait.cvar = NULL;\n+        thread->state = _PR_RUNNING;\n+        _PR_THREAD_UNLOCK(thread);\n+      } else {\n+        _pt_wait(thread, PR_INTERVAL_NO_TIMEOUT);\n+        _PR_THREAD_UNLOCK(thread);\n+      }\n     }\n-    return PR_SUCCESS;\n+  } else {\n+    _PR_MD_SWITCH_CONTEXT(thread);\n+  }\n+  return PR_SUCCESS;\n }\n \n PR_IMPLEMENT(PRStatus)\n-_MD_WakeupWaiter(PRThread* thread)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRInt32 pid, rv;\n-    PRIntn is;\n-\n-    PR_ASSERT(_pr_md_idle_cpus >= 0);\n-    if (thread == NULL) {\n+_MD_WakeupWaiter(PRThread* thread) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRInt32 pid, rv;\n+  PRIntn is;\n+\n+  PR_ASSERT(_pr_md_idle_cpus >= 0);\n+  if (thread == NULL) {\n+    if (_pr_md_idle_cpus) {\n+      _MD_Wakeup_CPUs();\n+    }\n+  } else if (!_PR_IS_NATIVE_THREAD(thread)) {\n+    /*\n+     * If the thread is on my cpu's runq there is no need to\n+     * wakeup any cpus\n+     */\n+    if (!_PR_IS_NATIVE_THREAD(me)) {\n+      if (me->cpu != thread->cpu) {\n         if (_pr_md_idle_cpus) {\n-            _MD_Wakeup_CPUs();\n-        }\n-    } else if (!_PR_IS_NATIVE_THREAD(thread)) {\n-        /*\n-         * If the thread is on my cpu's runq there is no need to\n-         * wakeup any cpus\n-         */\n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            if (me->cpu != thread->cpu) {\n-                if (_pr_md_idle_cpus) {\n-                    _MD_Wakeup_CPUs();\n-                }\n-            }\n-        } else {\n-            if (_pr_md_idle_cpus) {\n-                _MD_Wakeup_CPUs();\n-            }\n+          _MD_Wakeup_CPUs();\n         }\n+      }\n     } else {\n-        PR_ASSERT(_PR_IS_NATIVE_THREAD(thread));\n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_INTSOFF(is);\n-        }\n+      if (_pr_md_idle_cpus) {\n+        _MD_Wakeup_CPUs();\n+      }\n+    }\n+  } else {\n+    PR_ASSERT(_PR_IS_NATIVE_THREAD(thread));\n+    if (!_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_INTSOFF(is);\n+    }\n \n-        pthread_mutex_lock(&thread->md.pthread_mutex);\n-        thread->md.wait++;\n-        rv = pthread_cond_signal(&thread->md.pthread_cond);\n-        PR_ASSERT(rv == 0);\n-        pthread_mutex_unlock(&thread->md.pthread_mutex);\n+    pthread_mutex_lock(&thread->md.pthread_mutex);\n+    thread->md.wait++;\n+    rv = pthread_cond_signal(&thread->md.pthread_cond);\n+    PR_ASSERT(rv == 0);\n+    pthread_mutex_unlock(&thread->md.pthread_mutex);\n \n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_FAST_INTSON(is);\n-        }\n+    if (!_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_FAST_INTSON(is);\n     }\n-    return PR_SUCCESS;\n+  }\n+  return PR_SUCCESS;\n }\n \n /* These functions should not be called for AIX */\n@@ -337,84 +310,80 @@ _MD_YIELD(void) { PR_NOT_REACHED(\"_MD_YIELD should not be called for AIX.\"); }\n PR_IMPLEMENT(PRStatus)\n _MD_CreateThread(PRThread* thread, void (*start)(void*),\n                  PRThreadPriority priority, PRThreadScope scope,\n-                 PRThreadState state, PRUint32 stackSize)\n-{\n-    PRIntn is;\n-    int rv;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    pthread_attr_t attr;\n+                 PRThreadState state, PRUint32 stackSize) {\n+  PRIntn is;\n+  int rv;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  pthread_attr_t attr;\n \n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+\n+  if (pthread_mutex_init(&thread->md.pthread_mutex, NULL) != 0) {\n     if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n+      _PR_FAST_INTSON(is);\n     }\n+    return PR_FAILURE;\n+  }\n \n-    if (pthread_mutex_init(&thread->md.pthread_mutex, NULL) != 0) {\n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_FAST_INTSON(is);\n-        }\n-        return PR_FAILURE;\n+  if (pthread_cond_init(&thread->md.pthread_cond, NULL) != 0) {\n+    pthread_mutex_destroy(&thread->md.pthread_mutex);\n+    if (!_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_FAST_INTSON(is);\n     }\n-\n-    if (pthread_cond_init(&thread->md.pthread_cond, NULL) != 0) {\n-        pthread_mutex_destroy(&thread->md.pthread_mutex);\n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_FAST_INTSON(is);\n-        }\n-        return PR_FAILURE;\n+    return PR_FAILURE;\n+  }\n+  thread->flags |= _PR_GLOBAL_SCOPE;\n+\n+  pthread_attr_init(&attr); /* initialize attr with default attributes */\n+  if (pthread_attr_setstacksize(&attr, (size_t)stackSize) != 0) {\n+    pthread_mutex_destroy(&thread->md.pthread_mutex);\n+    pthread_cond_destroy(&thread->md.pthread_cond);\n+    pthread_attr_destroy(&attr);\n+    if (!_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_FAST_INTSON(is);\n     }\n-    thread->flags |= _PR_GLOBAL_SCOPE;\n-\n-    pthread_attr_init(&attr); /* initialize attr with default attributes */\n-    if (pthread_attr_setstacksize(&attr, (size_t)stackSize) != 0) {\n-        pthread_mutex_destroy(&thread->md.pthread_mutex);\n-        pthread_cond_destroy(&thread->md.pthread_cond);\n-        pthread_attr_destroy(&attr);\n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_FAST_INTSON(is);\n-        }\n-        return PR_FAILURE;\n+    return PR_FAILURE;\n+  }\n+\n+  thread->md.wait = 0;\n+  rv = pthread_create(&thread->md.pthread, &attr, start, (void*)thread);\n+  if (0 == rv) {\n+    _MD_ATOMIC_INCREMENT(&_pr_md_pthreads_created);\n+    _MD_ATOMIC_INCREMENT(&_pr_md_pthreads);\n+    if (!_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_FAST_INTSON(is);\n     }\n-\n-    thread->md.wait = 0;\n-    rv = pthread_create(&thread->md.pthread, &attr, start, (void*)thread);\n-    if (0 == rv) {\n-        _MD_ATOMIC_INCREMENT(&_pr_md_pthreads_created);\n-        _MD_ATOMIC_INCREMENT(&_pr_md_pthreads);\n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_FAST_INTSON(is);\n-        }\n-        return PR_SUCCESS;\n-    } else {\n-        pthread_mutex_destroy(&thread->md.pthread_mutex);\n-        pthread_cond_destroy(&thread->md.pthread_cond);\n-        pthread_attr_destroy(&attr);\n-        _MD_ATOMIC_INCREMENT(&_pr_md_pthreads_failed);\n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_FAST_INTSON(is);\n-        }\n-        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, rv);\n-        return PR_FAILURE;\n+    return PR_SUCCESS;\n+  } else {\n+    pthread_mutex_destroy(&thread->md.pthread_mutex);\n+    pthread_cond_destroy(&thread->md.pthread_cond);\n+    pthread_attr_destroy(&attr);\n+    _MD_ATOMIC_INCREMENT(&_pr_md_pthreads_failed);\n+    if (!_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_FAST_INTSON(is);\n     }\n+    PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, rv);\n+    return PR_FAILURE;\n+  }\n }\n \n PR_IMPLEMENT(void)\n-_MD_InitRunningCPU(struct _PRCPU* cpu)\n-{\n-    extern int _pr_md_pipefd[2];\n-\n-    _MD_unix_init_running_cpu(cpu);\n-    cpu->md.pthread = pthread_self();\n-    if (_pr_md_pipefd[0] >= 0) {\n-        _PR_IOQ_MAX_OSFD(cpu) = _pr_md_pipefd[0];\n+_MD_InitRunningCPU(struct _PRCPU* cpu) {\n+  extern int _pr_md_pipefd[2];\n+\n+  _MD_unix_init_running_cpu(cpu);\n+  cpu->md.pthread = pthread_self();\n+  if (_pr_md_pipefd[0] >= 0) {\n+    _PR_IOQ_MAX_OSFD(cpu) = _pr_md_pipefd[0];\n #ifndef _PR_USE_POLL\n-        FD_SET(_pr_md_pipefd[0], &_PR_FD_READ_SET(cpu));\n+    FD_SET(_pr_md_pipefd[0], &_PR_FD_READ_SET(cpu));\n #endif\n-    }\n+  }\n }\n \n-void\n-_MD_CleanupBeforeExit(void)\n-{\n+void _MD_CleanupBeforeExit(void) {\n #if 0\n     extern PRInt32    _pr_cpus_exit;\n \ndiff --git a/nspr/pr/src/md/unix/qnx.c b/nspr/pr/src/md/unix/qnx.c\nindex de770a4..70adb02 100644\n--- a/nspr/pr/src/md/unix/qnx.c\n+++ b/nspr/pr/src/md/unix/qnx.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,62 +7,41 @@\n \n #include <setjmp.h>\n \n-void\n-_MD_EarlyInit(void)\n-{\n-}\n+void _MD_EarlyInit(void) {}\n \n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n-    if (isCurrent) {\n-        (void)setjmp(CONTEXT(t));\n-    }\n-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n-    return (PRWord*)CONTEXT(t);\n+PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) {\n+  if (isCurrent) {\n+    (void)setjmp(CONTEXT(t));\n+  }\n+  *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n+  return (PRWord*)CONTEXT(t);\n }\n \n-void\n-_MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri)\n-{\n-    return;\n-}\n+void _MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri) { return; }\n \n-PRStatus\n-_MD_InitializeThread(PRThread* thread)\n-{\n-    return PR_SUCCESS;\n-}\n+PRStatus _MD_InitializeThread(PRThread* thread) { return PR_SUCCESS; }\n \n-PRStatus\n-_MD_WAIT(PRThread* thread, PRIntervalTime ticks)\n-{\n-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    _PR_MD_SWITCH_CONTEXT(thread);\n-    return PR_SUCCESS;\n+PRStatus _MD_WAIT(PRThread* thread, PRIntervalTime ticks) {\n+  PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  _PR_MD_SWITCH_CONTEXT(thread);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_WAKEUP_WAITER(PRThread* thread)\n-{\n-    if (thread) {\n-        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    }\n-    return PR_SUCCESS;\n+PRStatus _MD_WAKEUP_WAITER(PRThread* thread) {\n+  if (thread) {\n+    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  }\n+  return PR_SUCCESS;\n }\n \n /* These functions should not be called for qnx */\n-void\n-_MD_YIELD(void)\n-{\n-    PR_NOT_REACHED(\"_MD_YIELD should not be called for qnx.\");\n+void _MD_YIELD(void) {\n+  PR_NOT_REACHED(\"_MD_YIELD should not be called for qnx.\");\n }\n \n-PRStatus\n-_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                  PRUintn priority, PRThreadScope scope,\n-                  PRThreadState state, PRUint32 stackSize)\n-{\n-    PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for qnx.\");\n-    return PR_FAILURE;\n+PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n+                           PRUintn priority, PRThreadScope scope,\n+                           PRThreadState state, PRUint32 stackSize) {\n+  PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for qnx.\");\n+  return PR_FAILURE;\n }\ndiff --git a/nspr/pr/src/md/unix/riscos.c b/nspr/pr/src/md/unix/riscos.c\nindex 6e9bd09..977b2c0 100644\n--- a/nspr/pr/src/md/unix/riscos.c\n+++ b/nspr/pr/src/md/unix/riscos.c\n@@ -1,86 +1,65 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n \n #include \"primpl.h\"\n \n-void\n-_MD_EarlyInit(void)\n-{\n-}\n+void _MD_EarlyInit(void) {}\n \n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n+PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) {\n #ifndef _PR_PTHREADS\n-    if (isCurrent) {\n-        (void)setjmp(CONTEXT(t));\n-    }\n-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n-    return (PRWord*)CONTEXT(t);\n+  if (isCurrent) {\n+    (void)setjmp(CONTEXT(t));\n+  }\n+  *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n+  return (PRWord*)CONTEXT(t);\n #else\n-    *np = 0;\n-    return NULL;\n+  *np = 0;\n+  return NULL;\n #endif\n }\n \n #ifdef _PR_PTHREADS\n \n-void\n-_MD_CleanupBeforeExit(void)\n-{\n-}\n+void _MD_CleanupBeforeExit(void) {}\n \n #else  /* ! _PR_PTHREADS */\n \n-void\n-_MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri)\n-{\n-    return;\n-}\n+void _MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri) { return; }\n \n-PRStatus\n-_MD_InitializeThread(PRThread* thread)\n-{\n-    /*\n-     * set the pointers to the stack-pointer and frame-pointer words in the\n-     * context structure; this is for debugging use.\n-     */\n-    thread->md.sp = _MD_GET_SP_PTR(thread);\n-    thread->md.fp = _MD_GET_FP_PTR(thread);\n-    return PR_SUCCESS;\n+PRStatus _MD_InitializeThread(PRThread* thread) {\n+  /*\n+   * set the pointers to the stack-pointer and frame-pointer words in the\n+   * context structure; this is for debugging use.\n+   */\n+  thread->md.sp = _MD_GET_SP_PTR(thread);\n+  thread->md.fp = _MD_GET_FP_PTR(thread);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_WAIT(PRThread* thread, PRIntervalTime ticks)\n-{\n-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    _PR_MD_SWITCH_CONTEXT(thread);\n-    return PR_SUCCESS;\n+PRStatus _MD_WAIT(PRThread* thread, PRIntervalTime ticks) {\n+  PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  _PR_MD_SWITCH_CONTEXT(thread);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_WAKEUP_WAITER(PRThread* thread)\n-{\n-    if (thread) {\n-        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    }\n-    return PR_SUCCESS;\n+PRStatus _MD_WAKEUP_WAITER(PRThread* thread) {\n+  if (thread) {\n+    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  }\n+  return PR_SUCCESS;\n }\n \n /* These functions should not be called for RISC OS */\n-void\n-_MD_YIELD(void)\n-{\n-    PR_NOT_REACHED(\"_MD_YIELD should not be called for RISC OS.\");\n+void _MD_YIELD(void) {\n+  PR_NOT_REACHED(\"_MD_YIELD should not be called for RISC OS.\");\n }\n \n-PRStatus\n-_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                  PRThreadPriority priority, PRThreadScope scope,\n-                  PRThreadState state, PRUint32 stackSize)\n-{\n-    PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for RISC OS.\");\n-    return PR_FAILURE;\n+PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n+                           PRThreadPriority priority, PRThreadScope scope,\n+                           PRThreadState state, PRUint32 stackSize) {\n+  PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for RISC OS.\");\n+  return PR_FAILURE;\n }\n #endif /* ! _PR_PTHREADS */\ndiff --git a/nspr/pr/src/md/unix/solaris.c b/nspr/pr/src/md/unix/solaris.c\nindex 20f544a..dbcc8a0 100644\n--- a/nspr/pr/src/md/unix/solaris.c\n+++ b/nspr/pr/src/md/unix/solaris.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,155 +10,117 @@ extern PRThread* suspendAllThread;\n \n extern void _MD_SET_PRIORITY(_MDThread* md, PRThreadPriority newPri);\n \n-PRIntervalTime\n-_MD_Solaris_TicksPerSecond(void)\n-{\n-    /*\n-     * Ticks have a 10-microsecond resolution.  So there are\n-     * 100000 ticks per second.\n-     */\n-    return 100000UL;\n+PRIntervalTime _MD_Solaris_TicksPerSecond(void) {\n+  /*\n+   * Ticks have a 10-microsecond resolution.  So there are\n+   * 100000 ticks per second.\n+   */\n+  return 100000UL;\n }\n \n /* Interval timers, implemented using gethrtime() */\n \n-PRIntervalTime\n-_MD_Solaris_GetInterval(void)\n-{\n-    union {\n-        hrtime_t hrt; /* hrtime_t is a 64-bit (long long) integer */\n-        PRInt64 pr64;\n-    } time;\n-    PRInt64 resolution;\n-    PRIntervalTime ticks;\n-\n-    time.hrt = gethrtime(); /* in nanoseconds */\n-    /*\n-     * Convert from nanoseconds to ticks.  A tick's resolution is\n-     * 10 microseconds, or 10000 nanoseconds.\n-     */\n-    LL_I2L(resolution, 10000);\n-    LL_DIV(time.pr64, time.pr64, resolution);\n-    LL_L2UI(ticks, time.pr64);\n-    return ticks;\n+PRIntervalTime _MD_Solaris_GetInterval(void) {\n+  union {\n+    hrtime_t hrt; /* hrtime_t is a 64-bit (long long) integer */\n+    PRInt64 pr64;\n+  } time;\n+  PRInt64 resolution;\n+  PRIntervalTime ticks;\n+\n+  time.hrt = gethrtime(); /* in nanoseconds */\n+  /*\n+   * Convert from nanoseconds to ticks.  A tick's resolution is\n+   * 10 microseconds, or 10000 nanoseconds.\n+   */\n+  LL_I2L(resolution, 10000);\n+  LL_DIV(time.pr64, time.pr64, resolution);\n+  LL_L2UI(ticks, time.pr64);\n+  return ticks;\n }\n \n #ifdef _PR_PTHREADS\n-void\n-_MD_EarlyInit(void)\n-{\n-}\n+void _MD_EarlyInit(void) {}\n \n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, PRIntn isCurrent, PRIntn* np)\n-{\n-    *np = 0;\n-    return NULL;\n+PRWord* _MD_HomeGCRegisters(PRThread* t, PRIntn isCurrent, PRIntn* np) {\n+  *np = 0;\n+  return NULL;\n }\n #endif /* _PR_PTHREADS */\n \n #if defined(_PR_LOCAL_THREADS_ONLY)\n \n-void\n-_MD_EarlyInit(void)\n-{\n-}\n+void _MD_EarlyInit(void) {}\n \n-void\n-_MD_SolarisInit()\n-{\n-    _PR_UnixInit();\n-}\n+void _MD_SolarisInit() { _PR_UnixInit(); }\n \n-void\n-_MD_SET_PRIORITY(_MDThread* thread, PRThreadPriority newPri)\n-{\n-    return;\n-}\n+void _MD_SET_PRIORITY(_MDThread* thread, PRThreadPriority newPri) { return; }\n \n-PRStatus\n-_MD_InitializeThread(PRThread* thread)\n-{\n-    return PR_SUCCESS;\n-}\n+PRStatus _MD_InitializeThread(PRThread* thread) { return PR_SUCCESS; }\n \n-PRStatus\n-_MD_WAIT(PRThread* thread, PRIntervalTime ticks)\n-{\n-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n-    _PR_MD_SWITCH_CONTEXT(thread);\n-    return PR_SUCCESS;\n+PRStatus _MD_WAIT(PRThread* thread, PRIntervalTime ticks) {\n+  PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));\n+  _PR_MD_SWITCH_CONTEXT(thread);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_WAKEUP_WAITER(PRThread* thread)\n-{\n-    PR_ASSERT((thread == NULL) || (!(thread->flags & _PR_GLOBAL_SCOPE)));\n-    return PR_SUCCESS;\n+PRStatus _MD_WAKEUP_WAITER(PRThread* thread) {\n+  PR_ASSERT((thread == NULL) || (!(thread->flags & _PR_GLOBAL_SCOPE)));\n+  return PR_SUCCESS;\n }\n \n /* These functions should not be called for Solaris */\n-void\n-_MD_YIELD(void)\n-{\n-    PR_NOT_REACHED(\"_MD_YIELD should not be called for Solaris\");\n+void _MD_YIELD(void) {\n+  PR_NOT_REACHED(\"_MD_YIELD should not be called for Solaris\");\n }\n \n-PRStatus\n-_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                  PRThreadPriority priority, PRThreadScope scope,\n-                  PRThreadState state, PRUint32 stackSize)\n-{\n-    PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for Solaris\");\n-    return (PR_FAILURE);\n+PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n+                           PRThreadPriority priority, PRThreadScope scope,\n+                           PRThreadState state, PRUint32 stackSize) {\n+  PR_NOT_REACHED(\"_MD_CREATE_THREAD should not be called for Solaris\");\n+  return (PR_FAILURE);\n }\n \n-#ifdef USE_SETJMP\n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n-    if (isCurrent) {\n-        (void)setjmp(CONTEXT(t));\n-    }\n-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n-    return (PRWord*)CONTEXT(t);\n+#  ifdef USE_SETJMP\n+PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) {\n+  if (isCurrent) {\n+    (void)setjmp(CONTEXT(t));\n+  }\n+  *np = sizeof(CONTEXT(t)) / sizeof(PRWord);\n+  return (PRWord*)CONTEXT(t);\n }\n-#else\n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, PRIntn isCurrent, PRIntn* np)\n-{\n-    if (isCurrent) {\n-        (void)getcontext(CONTEXT(t));\n-    }\n-    *np = NGREG;\n-    return (PRWord*)&t->md.context.uc_mcontext.gregs[0];\n+#  else\n+PRWord* _MD_HomeGCRegisters(PRThread* t, PRIntn isCurrent, PRIntn* np) {\n+  if (isCurrent) {\n+    (void)getcontext(CONTEXT(t));\n+  }\n+  *np = NGREG;\n+  return (PRWord*)&t->md.context.uc_mcontext.gregs[0];\n }\n-#endif /* USE_SETJMP */\n+#  endif /* USE_SETJMP */\n \n #endif /* _PR_LOCAL_THREADS_ONLY */\n \n #ifndef _PR_PTHREADS\n-#if defined(i386) && defined(SOLARIS2_4)\n+#  if defined(i386) && defined(SOLARIS2_4)\n /*\n  * Because clock_gettime() on Solaris/x86 2.4 always generates a\n  * segmentation fault, we use an emulated version _pr_solx86_clock_gettime(),\n  * which is implemented using gettimeofday().\n  */\n \n-int\n-_pr_solx86_clock_gettime(clockid_t clock_id, struct timespec* tp)\n-{\n-    struct timeval tv;\n+int _pr_solx86_clock_gettime(clockid_t clock_id, struct timespec* tp) {\n+  struct timeval tv;\n \n-    if (clock_id != CLOCK_REALTIME) {\n-        errno = EINVAL;\n-        return -1;\n-    }\n+  if (clock_id != CLOCK_REALTIME) {\n+    errno = EINVAL;\n+    return -1;\n+  }\n \n-    gettimeofday(&tv, NULL);\n-    tp->tv_sec = tv.tv_sec;\n-    tp->tv_nsec = tv.tv_usec * 1000;\n-    return 0;\n+  gettimeofday(&tv, NULL);\n+  tp->tv_sec = tv.tv_sec;\n+  tp->tv_nsec = tv.tv_usec * 1000;\n+  return 0;\n }\n-#endif /* i386 && SOLARIS2_4 */\n-#endif /* _PR_PTHREADS */\n+#  endif /* i386 && SOLARIS2_4 */\n+#endif   /* _PR_PTHREADS */\ndiff --git a/nspr/pr/src/md/unix/unix.c b/nspr/pr/src/md/unix/unix.c\nindex 166a113..be2feb4 100644\n--- a/nspr/pr/src/md/unix/unix.c\n+++ b/nspr/pr/src/md/unix/unix.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -17,15 +18,15 @@\n #include <sys/utsname.h>\n \n #ifdef _PR_POLL_AVAILABLE\n-#include <poll.h>\n+#  include <poll.h>\n #endif\n \n #if defined(ANDROID)\n-#include <android/api-level.h>\n+#  include <android/api-level.h>\n #endif\n \n #if defined(NTO)\n-#include <sys/statvfs.h>\n+#  include <sys/statvfs.h>\n #endif\n \n /*\n@@ -33,17 +34,17 @@\n  * PRInt32* pointer to a _PRSockLen_t* pointer.\n  */\n #if defined(HAVE_SOCKLEN_T) || (defined(__GLIBC__) && __GLIBC__ >= 2)\n-#define _PRSockLen_t socklen_t\n-#elif defined(SOLARIS) || defined(AIX4_1) || defined(LINUX) || \\\n-    defined(DARWIN) || defined(QNX)\n-#define _PRSockLen_t int\n+#  define _PRSockLen_t socklen_t\n+#elif defined(SOLARIS) || defined(AIX4_1) || \\\n+    defined(LINUX) || defined(DARWIN) || defined(QNX)\n+#  define _PRSockLen_t int\n #elif (defined(AIX) && !defined(AIX4_1)) || defined(FREEBSD) || \\\n     defined(NETBSD) || defined(OPENBSD)\n || defined(NTO) ||\n     defined(RISCOS)\n-#define _PRSockLen_t size_t\n+#  define _PRSockLen_t size_t\n #else\n-#error \"Cannot determine architecture\"\n+#  error \"Cannot determine architecture\"\n #endif\n \n /*\n@@ -61,14 +62,14 @@ sigset_t timer_set;\n \n static sigset_t empty_set;\n \n-#ifdef SOLARIS\n-#include <sys/file.h>\n-#include <sys/filio.h>\n-#endif\n+#  ifdef SOLARIS\n+#    include <sys/file.h>\n+#    include <sys/filio.h>\n+#  endif\n \n-#ifndef PIPE_BUF\n-#define PIPE_BUF 512\n-#endif\n+#  ifndef PIPE_BUF\n+#    define PIPE_BUF 512\n+#  endif\n \n /*\n  * _nspr_noclock - if set clock interrupts are disabled\n@@ -82,397 +83,365 @@ int _nspr_noclock = 1;\n  * cast to avoid warnings.\n  */\n \n-int _pr_md_pipefd[2] = { -1, -1 };\n+int _pr_md_pipefd[2] = {-1, -1};\n static char _pr_md_pipebuf[PIPE_BUF];\n static PRInt32 local_io_wait(PRInt32 osfd, PRInt32 wait_flag,\n                              PRIntervalTime timeout);\n \n-_PRInterruptTable _pr_interruptTable[] = { {\n-                                               \"clock\",\n-                                               _PR_MISSED_CLOCK,\n-                                               _PR_ClockInterrupt,\n-                                           },\n-                                           { 0 } };\n-\n-void\n-_MD_unix_init_running_cpu(_PRCPU* cpu)\n-{\n-    PR_INIT_CLIST(&(cpu->md.md_unix.ioQ));\n-    cpu->md.md_unix.ioq_max_osfd = -1;\n-    cpu->md.md_unix.ioq_timeout = PR_INTERVAL_NO_TIMEOUT;\n-}\n-\n-PRStatus\n-_MD_open_dir(_MDDir* d, const char* name)\n-{\n-    int err;\n-\n-    d->d = opendir(name);\n-    if (!d->d) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_OPENDIR_ERROR(err);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n-}\n+_PRInterruptTable _pr_interruptTable[] = {{\n+                                              \"clock\",\n+                                              _PR_MISSED_CLOCK,\n+                                              _PR_ClockInterrupt,\n+                                          },\n+                                          {0}};\n \n-PRInt32\n-_MD_close_dir(_MDDir* d)\n-{\n-    int rv = 0, err;\n-\n-    if (d->d) {\n-        rv = closedir(d->d);\n-        if (rv == -1) {\n-            err = _MD_ERRNO();\n-            _PR_MD_MAP_CLOSEDIR_ERROR(err);\n-        }\n-    }\n-    return rv;\n+void _MD_unix_init_running_cpu(_PRCPU* cpu) {\n+  PR_INIT_CLIST(&(cpu->md.md_unix.ioQ));\n+  cpu->md.md_unix.ioq_max_osfd = -1;\n+  cpu->md.md_unix.ioq_timeout = PR_INTERVAL_NO_TIMEOUT;\n }\n \n-char*\n-_MD_read_dir(_MDDir* d, PRIntn flags)\n-{\n-    struct dirent* de;\n-    int err;\n+PRStatus _MD_open_dir(_MDDir* d, const char* name) {\n+  int err;\n \n-    for (;;) {\n-        /*\n-         * XXX: readdir() is not MT-safe. There is an MT-safe version\n-         * readdir_r() on some systems.\n-         */\n-        _MD_ERRNO() = 0;\n-        de = readdir(d->d);\n-        if (!de) {\n-            err = _MD_ERRNO();\n-            _PR_MD_MAP_READDIR_ERROR(err);\n-            return 0;\n-        }\n-        if ((flags & PR_SKIP_DOT) && (de->d_name[0] == '.') &&\n-            (de->d_name[1] == 0)) {\n-            continue;\n-        }\n-        if ((flags & PR_SKIP_DOT_DOT) && (de->d_name[0] == '.') &&\n-            (de->d_name[1] == '.') && (de->d_name[2] == 0)) {\n-            continue;\n-        }\n-        if ((flags & PR_SKIP_HIDDEN) && (de->d_name[0] == '.')) {\n-            continue;\n-        }\n-        break;\n-    }\n-    return de->d_name;\n+  d->d = opendir(name);\n+  if (!d->d) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_OPENDIR_ERROR(err);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-PRInt32\n-_MD_delete(const char* name)\n-{\n-    PRInt32 rv, err;\n+PRInt32 _MD_close_dir(_MDDir* d) {\n+  int rv = 0, err;\n \n-    rv = unlink(name);\n+  if (d->d) {\n+    rv = closedir(d->d);\n     if (rv == -1) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_UNLINK_ERROR(err);\n+      err = _MD_ERRNO();\n+      _PR_MD_MAP_CLOSEDIR_ERROR(err);\n     }\n-    return (rv);\n+  }\n+  return rv;\n }\n \n-PRInt32\n-_MD_rename(const char* from, const char* to)\n-{\n-    PRInt32 rv = -1, err;\n+char* _MD_read_dir(_MDDir* d, PRIntn flags) {\n+  struct dirent* de;\n+  int err;\n \n+  for (;;) {\n     /*\n-    ** This is trying to enforce the semantics of WINDOZE' rename\n-    ** operation. That means one is not allowed to rename over top\n-    ** of an existing file. Holding a lock across these two function\n-    ** and the open function is known to be a bad idea, but ....\n-    */\n-    if (NULL != _pr_unix_rename_lock) {\n-        PR_Lock(_pr_unix_rename_lock);\n-    }\n-    if (0 == access(to, F_OK)) {\n-        PR_SetError(PR_FILE_EXISTS_ERROR, 0);\n-    } else {\n-        rv = rename(from, to);\n-        if (rv < 0) {\n-            err = _MD_ERRNO();\n-            _PR_MD_MAP_RENAME_ERROR(err);\n-        }\n-    }\n-    if (NULL != _pr_unix_rename_lock) {\n-        PR_Unlock(_pr_unix_rename_lock);\n-    }\n-    return rv;\n-}\n-\n-PRInt32\n-_MD_access(const char* name, PRAccessHow how)\n-{\n-    PRInt32 rv, err;\n-    int amode;\n-\n-    switch (how) {\n-        case PR_ACCESS_WRITE_OK:\n-            amode = W_OK;\n-            break;\n-        case PR_ACCESS_READ_OK:\n-            amode = R_OK;\n-            break;\n-        case PR_ACCESS_EXISTS:\n-            amode = F_OK;\n-            break;\n-        default:\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            rv = -1;\n-            goto done;\n-    }\n-    rv = access(name, amode);\n-\n+     * XXX: readdir() is not MT-safe. There is an MT-safe version\n+     * readdir_r() on some systems.\n+     */\n+    _MD_ERRNO() = 0;\n+    de = readdir(d->d);\n+    if (!de) {\n+      err = _MD_ERRNO();\n+      _PR_MD_MAP_READDIR_ERROR(err);\n+      return 0;\n+    }\n+    if ((flags & PR_SKIP_DOT) && (de->d_name[0] == '.') &&\n+        (de->d_name[1] == 0)) {\n+      continue;\n+    }\n+    if ((flags & PR_SKIP_DOT_DOT) && (de->d_name[0] == '.') &&\n+        (de->d_name[1] == '.') && (de->d_name[2] == 0)) {\n+      continue;\n+    }\n+    if ((flags & PR_SKIP_HIDDEN) && (de->d_name[0] == '.')) {\n+      continue;\n+    }\n+    break;\n+  }\n+  return de->d_name;\n+}\n+\n+PRInt32 _MD_delete(const char* name) {\n+  PRInt32 rv, err;\n+\n+  rv = unlink(name);\n+  if (rv == -1) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_UNLINK_ERROR(err);\n+  }\n+  return (rv);\n+}\n+\n+PRInt32 _MD_rename(const char* from, const char* to) {\n+  PRInt32 rv = -1, err;\n+\n+  /*\n+  ** This is trying to enforce the semantics of WINDOZE' rename\n+  ** operation. That means one is not allowed to rename over top\n+  ** of an existing file. Holding a lock across these two function\n+  ** and the open function is known to be a bad idea, but ....\n+  */\n+  if (NULL != _pr_unix_rename_lock) {\n+    PR_Lock(_pr_unix_rename_lock);\n+  }\n+  if (0 == access(to, F_OK)) {\n+    PR_SetError(PR_FILE_EXISTS_ERROR, 0);\n+  } else {\n+    rv = rename(from, to);\n     if (rv < 0) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_ACCESS_ERROR(err);\n-    }\n+      err = _MD_ERRNO();\n+      _PR_MD_MAP_RENAME_ERROR(err);\n+    }\n+  }\n+  if (NULL != _pr_unix_rename_lock) {\n+    PR_Unlock(_pr_unix_rename_lock);\n+  }\n+  return rv;\n+}\n+\n+PRInt32 _MD_access(const char* name, PRAccessHow how) {\n+  PRInt32 rv, err;\n+  int amode;\n+\n+  switch (how) {\n+    case PR_ACCESS_WRITE_OK:\n+      amode = W_OK;\n+      break;\n+    case PR_ACCESS_READ_OK:\n+      amode = R_OK;\n+      break;\n+    case PR_ACCESS_EXISTS:\n+      amode = F_OK;\n+      break;\n+    default:\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      rv = -1;\n+      goto done;\n+  }\n+  rv = access(name, amode);\n+\n+  if (rv < 0) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_ACCESS_ERROR(err);\n+  }\n \n done:\n-    return (rv);\n-}\n-\n-PRInt32\n-_MD_mkdir(const char* name, PRIntn mode)\n-{\n-    int rv, err;\n-\n-    /*\n-    ** This lock is used to enforce rename semantics as described\n-    ** in PR_Rename. Look there for more fun details.\n-    */\n-    if (NULL != _pr_unix_rename_lock) {\n-        PR_Lock(_pr_unix_rename_lock);\n-    }\n-    rv = mkdir(name, mode);\n-    if (rv < 0) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_MKDIR_ERROR(err);\n-    }\n-    if (NULL != _pr_unix_rename_lock) {\n-        PR_Unlock(_pr_unix_rename_lock);\n-    }\n-    return rv;\n-}\n-\n-PRInt32\n-_MD_rmdir(const char* name)\n-{\n-    int rv, err;\n-\n-    rv = rmdir(name);\n-    if (rv == -1) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_RMDIR_ERROR(err);\n-    }\n-    return rv;\n-}\n-\n-PRInt32\n-_MD_read(PRFileDesc* fd, void* buf, PRInt32 amount)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRInt32 rv, err;\n-#ifndef _PR_USE_POLL\n-    fd_set rd;\n-#else\n-    struct pollfd pfd;\n-#endif /* _PR_USE_POLL */\n-    PRInt32 osfd = fd->secret->md.osfd;\n-\n-#ifndef _PR_USE_POLL\n-    FD_ZERO(&rd);\n-    FD_SET(osfd, &rd);\n-#else\n-    pfd.fd = osfd;\n-    pfd.events = POLLIN;\n-#endif /* _PR_USE_POLL */\n-    while ((rv = read(osfd, buf, amount)) == -1) {\n-        err = _MD_ERRNO();\n-        if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n-            if (fd->secret->nonblocking) {\n-                break;\n-            }\n-            if (!_PR_IS_NATIVE_THREAD(me)) {\n-                if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_READ,\n-                                        PR_INTERVAL_NO_TIMEOUT)) < 0) {\n-                    goto done;\n-                }\n-            } else {\n-#ifndef _PR_USE_POLL\n-                while ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL, NULL)) == -1 &&\n-                       (err = _MD_ERRNO()) == EINTR) {\n-                    /* retry _MD_SELECT() if it is interrupted */\n-                }\n-#else  /* _PR_USE_POLL */\n-                while ((rv = _MD_POLL(&pfd, 1, -1)) == -1 &&\n-                       (err = _MD_ERRNO()) == EINTR) {\n-                    /* retry _MD_POLL() if it is interrupted */\n-                }\n-#endif /* _PR_USE_POLL */\n-                if (rv == -1) {\n-                    break;\n-                }\n-            }\n-            if (_PR_PENDING_INTERRUPT(me)) {\n-                break;\n-            }\n-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n-            continue;\n-        } else {\n-            break;\n+  return (rv);\n+}\n+\n+PRInt32 _MD_mkdir(const char* name, PRIntn mode) {\n+  int rv, err;\n+\n+  /*\n+  ** This lock is used to enforce rename semantics as described\n+  ** in PR_Rename. Look there for more fun details.\n+  */\n+  if (NULL != _pr_unix_rename_lock) {\n+    PR_Lock(_pr_unix_rename_lock);\n+  }\n+  rv = mkdir(name, mode);\n+  if (rv < 0) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_MKDIR_ERROR(err);\n+  }\n+  if (NULL != _pr_unix_rename_lock) {\n+    PR_Unlock(_pr_unix_rename_lock);\n+  }\n+  return rv;\n+}\n+\n+PRInt32 _MD_rmdir(const char* name) {\n+  int rv, err;\n+\n+  rv = rmdir(name);\n+  if (rv == -1) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_RMDIR_ERROR(err);\n+  }\n+  return rv;\n+}\n+\n+PRInt32 _MD_read(PRFileDesc* fd, void* buf, PRInt32 amount) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRInt32 rv, err;\n+#  ifndef _PR_USE_POLL\n+  fd_set rd;\n+#  else\n+  struct pollfd pfd;\n+#  endif /* _PR_USE_POLL */\n+  PRInt32 osfd = fd->secret->md.osfd;\n+\n+#  ifndef _PR_USE_POLL\n+  FD_ZERO(&rd);\n+  FD_SET(osfd, &rd);\n+#  else\n+  pfd.fd = osfd;\n+  pfd.events = POLLIN;\n+#  endif /* _PR_USE_POLL */\n+  while ((rv = read(osfd, buf, amount)) == -1) {\n+    err = _MD_ERRNO();\n+    if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n+      if (fd->secret->nonblocking) {\n+        break;\n+      }\n+      if (!_PR_IS_NATIVE_THREAD(me)) {\n+        if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_READ,\n+                                PR_INTERVAL_NO_TIMEOUT)) < 0) {\n+          goto done;\n         }\n-    }\n-    if (rv < 0) {\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        } else {\n-            _PR_MD_MAP_READ_ERROR(err);\n+      } else {\n+#  ifndef _PR_USE_POLL\n+        while ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL, NULL)) == -1 &&\n+               (err = _MD_ERRNO()) == EINTR) {\n+          /* retry _MD_SELECT() if it is interrupted */\n+        }\n+#  else  /* _PR_USE_POLL */\n+        while ((rv = _MD_POLL(&pfd, 1, -1)) == -1 &&\n+               (err = _MD_ERRNO()) == EINTR) {\n+          /* retry _MD_POLL() if it is interrupted */\n+        }\n+#  endif /* _PR_USE_POLL */\n+        if (rv == -1) {\n+          break;\n         }\n+      }\n+      if (_PR_PENDING_INTERRUPT(me)) {\n+        break;\n+      }\n+    } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n+      continue;\n+    } else {\n+      break;\n+    }\n+  }\n+  if (rv < 0) {\n+    if (_PR_PENDING_INTERRUPT(me)) {\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    } else {\n+      _PR_MD_MAP_READ_ERROR(err);\n     }\n+  }\n done:\n-    return (rv);\n-}\n-\n-PRInt32\n-_MD_write(PRFileDesc* fd, const void* buf, PRInt32 amount)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRInt32 rv, err;\n-#ifndef _PR_USE_POLL\n-    fd_set wd;\n-#else\n-    struct pollfd pfd;\n-#endif /* _PR_USE_POLL */\n-    PRInt32 osfd = fd->secret->md.osfd;\n-\n-#ifndef _PR_USE_POLL\n-    FD_ZERO(&wd);\n-    FD_SET(osfd, &wd);\n-#else\n-    pfd.fd = osfd;\n-    pfd.events = POLLOUT;\n-#endif /* _PR_USE_POLL */\n-    while ((rv = write(osfd, buf, amount)) == -1) {\n-        err = _MD_ERRNO();\n-        if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n-            if (fd->secret->nonblocking) {\n-                break;\n-            }\n-            if (!_PR_IS_NATIVE_THREAD(me)) {\n-                if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE,\n-                                        PR_INTERVAL_NO_TIMEOUT)) < 0) {\n-                    goto done;\n-                }\n-            } else {\n-#ifndef _PR_USE_POLL\n-                while ((rv = _MD_SELECT(osfd + 1, NULL, &wd, NULL, NULL)) == -1 &&\n-                       (err = _MD_ERRNO()) == EINTR) {\n-                    /* retry _MD_SELECT() if it is interrupted */\n-                }\n-#else  /* _PR_USE_POLL */\n-                while ((rv = _MD_POLL(&pfd, 1, -1)) == -1 &&\n-                       (err = _MD_ERRNO()) == EINTR) {\n-                    /* retry _MD_POLL() if it is interrupted */\n-                }\n-#endif /* _PR_USE_POLL */\n-                if (rv == -1) {\n-                    break;\n-                }\n-            }\n-            if (_PR_PENDING_INTERRUPT(me)) {\n-                break;\n-            }\n-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n-            continue;\n-        } else {\n-            break;\n+  return (rv);\n+}\n+\n+PRInt32 _MD_write(PRFileDesc* fd, const void* buf, PRInt32 amount) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRInt32 rv, err;\n+#  ifndef _PR_USE_POLL\n+  fd_set wd;\n+#  else\n+  struct pollfd pfd;\n+#  endif /* _PR_USE_POLL */\n+  PRInt32 osfd = fd->secret->md.osfd;\n+\n+#  ifndef _PR_USE_POLL\n+  FD_ZERO(&wd);\n+  FD_SET(osfd, &wd);\n+#  else\n+  pfd.fd = osfd;\n+  pfd.events = POLLOUT;\n+#  endif /* _PR_USE_POLL */\n+  while ((rv = write(osfd, buf, amount)) == -1) {\n+    err = _MD_ERRNO();\n+    if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n+      if (fd->secret->nonblocking) {\n+        break;\n+      }\n+      if (!_PR_IS_NATIVE_THREAD(me)) {\n+        if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE,\n+                                PR_INTERVAL_NO_TIMEOUT)) < 0) {\n+          goto done;\n         }\n-    }\n-    if (rv < 0) {\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        } else {\n-            _PR_MD_MAP_WRITE_ERROR(err);\n+      } else {\n+#  ifndef _PR_USE_POLL\n+        while ((rv = _MD_SELECT(osfd + 1, NULL, &wd, NULL, NULL)) == -1 &&\n+               (err = _MD_ERRNO()) == EINTR) {\n+          /* retry _MD_SELECT() if it is interrupted */\n         }\n+#  else  /* _PR_USE_POLL */\n+        while ((rv = _MD_POLL(&pfd, 1, -1)) == -1 &&\n+               (err = _MD_ERRNO()) == EINTR) {\n+          /* retry _MD_POLL() if it is interrupted */\n+        }\n+#  endif /* _PR_USE_POLL */\n+        if (rv == -1) {\n+          break;\n+        }\n+      }\n+      if (_PR_PENDING_INTERRUPT(me)) {\n+        break;\n+      }\n+    } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n+      continue;\n+    } else {\n+      break;\n     }\n+  }\n+  if (rv < 0) {\n+    if (_PR_PENDING_INTERRUPT(me)) {\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    } else {\n+      _PR_MD_MAP_WRITE_ERROR(err);\n+    }\n+  }\n done:\n-    return (rv);\n+  return (rv);\n }\n \n-PRInt32\n-_MD_fsync(PRFileDesc* fd)\n-{\n-    PRInt32 rv, err;\n+PRInt32 _MD_fsync(PRFileDesc* fd) {\n+  PRInt32 rv, err;\n \n-    rv = fsync(fd->secret->md.osfd);\n-    if (rv == -1) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_FSYNC_ERROR(err);\n-    }\n-    return (rv);\n+  rv = fsync(fd->secret->md.osfd);\n+  if (rv == -1) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_FSYNC_ERROR(err);\n+  }\n+  return (rv);\n }\n \n-PRInt32\n-_MD_close(PRInt32 osfd)\n-{\n-    PRInt32 rv, err;\n+PRInt32 _MD_close(PRInt32 osfd) {\n+  PRInt32 rv, err;\n \n-    rv = close(osfd);\n-    if (rv == -1) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_CLOSE_ERROR(err);\n-    }\n-    return (rv);\n+  rv = close(osfd);\n+  if (rv == -1) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_CLOSE_ERROR(err);\n+  }\n+  return (rv);\n }\n \n-PRInt32\n-_MD_socket(PRInt32 domain, PRInt32 type, PRInt32 proto)\n-{\n-    PRInt32 osfd, err;\n-\n-    osfd = socket(domain, type, proto);\n+PRInt32 _MD_socket(PRInt32 domain, PRInt32 type, PRInt32 proto) {\n+  PRInt32 osfd, err;\n \n-    if (osfd == -1) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_SOCKET_ERROR(err);\n-        return (osfd);\n-    }\n+  osfd = socket(domain, type, proto);\n \n+  if (osfd == -1) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_SOCKET_ERROR(err);\n     return (osfd);\n+  }\n+\n+  return (osfd);\n }\n \n-PRInt32\n-_MD_socketavailable(PRFileDesc* fd)\n-{\n-    PRInt32 result;\n+PRInt32 _MD_socketavailable(PRFileDesc* fd) {\n+  PRInt32 result;\n \n-    if (ioctl(fd->secret->md.osfd, FIONREAD, &result) < 0) {\n-        _PR_MD_MAP_SOCKETAVAILABLE_ERROR(_MD_ERRNO());\n-        return -1;\n-    }\n-    return result;\n+  if (ioctl(fd->secret->md.osfd, FIONREAD, &result) < 0) {\n+    _PR_MD_MAP_SOCKETAVAILABLE_ERROR(_MD_ERRNO());\n+    return -1;\n+  }\n+  return result;\n }\n \n-PRInt64\n-_MD_socketavailable64(PRFileDesc* fd)\n-{\n-    PRInt64 result;\n-    LL_I2L(result, _MD_socketavailable(fd));\n-    return result;\n+PRInt64 _MD_socketavailable64(PRFileDesc* fd) {\n+  PRInt64 result;\n+  LL_I2L(result, _MD_socketavailable(fd));\n+  return result;\n } /* _MD_socketavailable64 */\n \n-#define READ_FD 1\n-#define WRITE_FD 2\n+#  define READ_FD 1\n+#  define WRITE_FD 2\n \n /*\n  * socket_io_wait --\n@@ -483,983 +452,941 @@ _MD_socketavailable64(PRFileDesc* fd)\n  * poll().  The second (preferred) implementation uses poll().\n  */\n \n-#ifndef _PR_USE_POLL\n-\n-static PRInt32\n-socket_io_wait(PRInt32 osfd, PRInt32 fd_type,\n-               PRIntervalTime timeout)\n-{\n-    PRInt32 rv = -1;\n-    struct timeval tv;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRIntervalTime epoch, now, elapsed, remaining;\n-    PRBool wait_for_remaining;\n-    PRInt32 syserror;\n-    fd_set rd_wr;\n-\n-    switch (timeout) {\n-        case PR_INTERVAL_NO_WAIT:\n-            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-            break;\n-        case PR_INTERVAL_NO_TIMEOUT:\n-            /*\n-             * This is a special case of the 'default' case below.\n-             * Please see the comments there.\n-             */\n-            tv.tv_sec = _PR_INTERRUPT_CHECK_INTERVAL_SECS;\n-            tv.tv_usec = 0;\n-            FD_ZERO(&rd_wr);\n-            do {\n-                FD_SET(osfd, &rd_wr);\n-                if (fd_type == READ_FD) {\n-                    rv = _MD_SELECT(osfd + 1, &rd_wr, NULL, NULL, &tv);\n-                } else {\n-                    rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, &tv);\n-                }\n-                if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {\n-                    _PR_MD_MAP_SELECT_ERROR(syserror);\n-                    break;\n-                }\n-                if (_PR_PENDING_INTERRUPT(me)) {\n-                    me->flags &= ~_PR_INTERRUPT;\n-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                    rv = -1;\n-                    break;\n-                }\n-            } while (rv == 0 || (rv == -1 && syserror == EINTR));\n-            break;\n-        default:\n-            now = epoch = PR_IntervalNow();\n-            remaining = timeout;\n-            FD_ZERO(&rd_wr);\n-            do {\n-                /*\n-                 * We block in _MD_SELECT for at most\n-                 * _PR_INTERRUPT_CHECK_INTERVAL_SECS seconds,\n-                 * so that there is an upper limit on the delay\n-                 * before the interrupt bit is checked.\n-                 */\n-                wait_for_remaining = PR_TRUE;\n-                tv.tv_sec = PR_IntervalToSeconds(remaining);\n-                if (tv.tv_sec > _PR_INTERRUPT_CHECK_INTERVAL_SECS) {\n-                    wait_for_remaining = PR_FALSE;\n-                    tv.tv_sec = _PR_INTERRUPT_CHECK_INTERVAL_SECS;\n-                    tv.tv_usec = 0;\n-                } else {\n-                    tv.tv_usec = PR_IntervalToMicroseconds(\n-                        remaining - PR_SecondsToInterval(tv.tv_sec));\n-                }\n-                FD_SET(osfd, &rd_wr);\n-                if (fd_type == READ_FD) {\n-                    rv = _MD_SELECT(osfd + 1, &rd_wr, NULL, NULL, &tv);\n-                } else {\n-                    rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, &tv);\n-                }\n-                /*\n-                 * we don't consider EINTR a real error\n-                 */\n-                if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {\n-                    _PR_MD_MAP_SELECT_ERROR(syserror);\n-                    break;\n-                }\n-                if (_PR_PENDING_INTERRUPT(me)) {\n-                    me->flags &= ~_PR_INTERRUPT;\n-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                    rv = -1;\n-                    break;\n-                }\n-                /*\n-                 * We loop again if _MD_SELECT timed out or got interrupted\n-                 * by a signal, and the timeout deadline has not passed yet.\n-                 */\n-                if (rv == 0 || (rv == -1 && syserror == EINTR)) {\n-                    /*\n-                     * If _MD_SELECT timed out, we know how much time\n-                     * we spent in blocking, so we can avoid a\n-                     * PR_IntervalNow() call.\n-                     */\n-                    if (rv == 0) {\n-                        if (wait_for_remaining) {\n-                            now += remaining;\n-                        } else {\n-                            now += PR_SecondsToInterval(tv.tv_sec) +\n-                                   PR_MicrosecondsToInterval(tv.tv_usec);\n-                        }\n-                    } else {\n-                        now = PR_IntervalNow();\n-                    }\n-                    elapsed = (PRIntervalTime)(now - epoch);\n-                    if (elapsed >= timeout) {\n-                        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                        rv = -1;\n-                        break;\n-                    } else {\n-                        remaining = timeout - elapsed;\n-                    }\n-                }\n-            } while (rv == 0 || (rv == -1 && syserror == EINTR));\n-            break;\n-    }\n-    return (rv);\n-}\n-\n-#else /* _PR_USE_POLL */\n-\n-static PRInt32\n-socket_io_wait(PRInt32 osfd, PRInt32 fd_type,\n-               PRIntervalTime timeout)\n-{\n-    PRInt32 rv = -1;\n-    int msecs;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRIntervalTime epoch, now, elapsed, remaining;\n-    PRBool wait_for_remaining;\n-    PRInt32 syserror;\n-    struct pollfd pfd;\n-\n-    switch (timeout) {\n-        case PR_INTERVAL_NO_WAIT:\n-            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-            break;\n-        case PR_INTERVAL_NO_TIMEOUT:\n-            /*\n-             * This is a special case of the 'default' case below.\n-             * Please see the comments there.\n-             */\n-            msecs = _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000;\n-            pfd.fd = osfd;\n-            if (fd_type == READ_FD) {\n-                pfd.events = POLLIN;\n-            } else {\n-                pfd.events = POLLOUT;\n-            }\n-            do {\n-                rv = _MD_POLL(&pfd, 1, msecs);\n-                if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {\n-                    _PR_MD_MAP_POLL_ERROR(syserror);\n-                    break;\n-                }\n-                /*\n-                 * If POLLERR is set, don't process it; retry the operation\n-                 */\n-                if ((rv == 1) && (pfd.revents & (POLLHUP | POLLNVAL))) {\n-                    rv = -1;\n-                    _PR_MD_MAP_POLL_REVENTS_ERROR(pfd.revents);\n-                    break;\n-                }\n-                if (_PR_PENDING_INTERRUPT(me)) {\n-                    me->flags &= ~_PR_INTERRUPT;\n-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                    rv = -1;\n-                    break;\n-                }\n-            } while (rv == 0 || (rv == -1 && syserror == EINTR));\n-            break;\n-        default:\n-            now = epoch = PR_IntervalNow();\n-            remaining = timeout;\n-            pfd.fd = osfd;\n-            if (fd_type == READ_FD) {\n-                pfd.events = POLLIN;\n-            } else {\n-                pfd.events = POLLOUT;\n-            }\n-            do {\n-                /*\n-                 * We block in _MD_POLL for at most\n-                 * _PR_INTERRUPT_CHECK_INTERVAL_SECS seconds,\n-                 * so that there is an upper limit on the delay\n-                 * before the interrupt bit is checked.\n-                 */\n-                wait_for_remaining = PR_TRUE;\n-                msecs = PR_IntervalToMilliseconds(remaining);\n-                if (msecs > _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000) {\n-                    wait_for_remaining = PR_FALSE;\n-                    msecs = _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000;\n-                }\n-                rv = _MD_POLL(&pfd, 1, msecs);\n-                /*\n-                 * we don't consider EINTR a real error\n-                 */\n-                if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {\n-                    _PR_MD_MAP_POLL_ERROR(syserror);\n-                    break;\n-                }\n-                if (_PR_PENDING_INTERRUPT(me)) {\n-                    me->flags &= ~_PR_INTERRUPT;\n-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                    rv = -1;\n-                    break;\n-                }\n-                /*\n-                 * If POLLERR is set, don't process it; retry the operation\n-                 */\n-                if ((rv == 1) && (pfd.revents & (POLLHUP | POLLNVAL))) {\n-                    rv = -1;\n-                    _PR_MD_MAP_POLL_REVENTS_ERROR(pfd.revents);\n-                    break;\n-                }\n-                /*\n-                 * We loop again if _MD_POLL timed out or got interrupted\n-                 * by a signal, and the timeout deadline has not passed yet.\n-                 */\n-                if (rv == 0 || (rv == -1 && syserror == EINTR)) {\n-                    /*\n-                     * If _MD_POLL timed out, we know how much time\n-                     * we spent in blocking, so we can avoid a\n-                     * PR_IntervalNow() call.\n-                     */\n-                    if (rv == 0) {\n-                        if (wait_for_remaining) {\n-                            now += remaining;\n-                        } else {\n-                            now += PR_MillisecondsToInterval(msecs);\n-                        }\n-                    } else {\n-                        now = PR_IntervalNow();\n-                    }\n-                    elapsed = (PRIntervalTime)(now - epoch);\n-                    if (elapsed >= timeout) {\n-                        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                        rv = -1;\n-                        break;\n-                    } else {\n-                        remaining = timeout - elapsed;\n-                    }\n-                }\n-            } while (rv == 0 || (rv == -1 && syserror == EINTR));\n-            break;\n-    }\n-    return (rv);\n-}\n-\n-#endif /* _PR_USE_POLL */\n-\n-static PRInt32\n-local_io_wait(PRInt32 osfd, PRInt32 wait_flag,\n-              PRIntervalTime timeout)\n-{\n-    _PRUnixPollDesc pd;\n-    PRInt32 rv;\n-\n-    PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-           (\"waiting to %s on osfd=%d\",\n-            (wait_flag == _PR_UNIX_POLL_READ) ? \"read\" : \"write\", osfd));\n-\n-    if (timeout == PR_INTERVAL_NO_WAIT) {\n-        return 0;\n-    }\n-\n-    pd.osfd = osfd;\n-    pd.in_flags = wait_flag;\n-    pd.out_flags = 0;\n-\n-    rv = _PR_WaitForMultipleFDs(&pd, 1, timeout);\n-\n-    if (rv == 0) {\n-        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-        rv = -1;\n-    }\n-    return rv;\n-}\n-\n-PRInt32\n-_MD_recv(PRFileDesc* fd, void* buf, PRInt32 amount, PRInt32 flags,\n-         PRIntervalTime timeout)\n-{\n-    PRInt32 osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    /*\n-     * Many OS's (ex: Solaris) have a broken recv which won't read\n-     * from socketpairs.  As long as we don't use flags on socketpairs, this\n-     * is a decent fix. - mikep\n-     */\n-#if defined(SOLARIS)\n-    while ((rv = read(osfd, buf, amount)) == -1) {\n-#else\n-    while ((rv = recv(osfd, buf, amount, flags)) == -1) {\n-#endif\n-        err = _MD_ERRNO();\n-        if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n-            if (fd->secret->nonblocking) {\n-                break;\n-            }\n-            if (!_PR_IS_NATIVE_THREAD(me)) {\n-                if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_READ, timeout)) < 0) {\n-                    goto done;\n-                }\n-            } else {\n-                if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) {\n-                    goto done;\n-                }\n-            }\n-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n-            continue;\n+#  ifndef _PR_USE_POLL\n+\n+static PRInt32 socket_io_wait(PRInt32 osfd, PRInt32 fd_type,\n+                              PRIntervalTime timeout) {\n+  PRInt32 rv = -1;\n+  struct timeval tv;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRIntervalTime epoch, now, elapsed, remaining;\n+  PRBool wait_for_remaining;\n+  PRInt32 syserror;\n+  fd_set rd_wr;\n+\n+  switch (timeout) {\n+    case PR_INTERVAL_NO_WAIT:\n+      PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+      break;\n+    case PR_INTERVAL_NO_TIMEOUT:\n+      /*\n+       * This is a special case of the 'default' case below.\n+       * Please see the comments there.\n+       */\n+      tv.tv_sec = _PR_INTERRUPT_CHECK_INTERVAL_SECS;\n+      tv.tv_usec = 0;\n+      FD_ZERO(&rd_wr);\n+      do {\n+        FD_SET(osfd, &rd_wr);\n+        if (fd_type == READ_FD) {\n+          rv = _MD_SELECT(osfd + 1, &rd_wr, NULL, NULL, &tv);\n         } else {\n-            break;\n+          rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, &tv);\n         }\n-    }\n-    if (rv < 0) {\n-        _PR_MD_MAP_RECV_ERROR(err);\n-    }\n-done:\n-    return (rv);\n-}\n-\n-PRInt32\n-_MD_recvfrom(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n-             PRNetAddr* addr, PRUint32* addrlen,\n-             PRIntervalTime timeout)\n-{\n-    PRInt32 osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    while ((*addrlen = PR_NETADDR_SIZE(addr)),\n-           ((rv = recvfrom(osfd, buf, amount, flags, (struct sockaddr*)addr,\n-                           (_PRSockLen_t*)addrlen)) == -1)) {\n-        err = _MD_ERRNO();\n-        if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n-            if (fd->secret->nonblocking) {\n-                break;\n-            }\n-            if (!_PR_IS_NATIVE_THREAD(me)) {\n-                if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_READ, timeout)) < 0) {\n-                    goto done;\n-                }\n-            } else {\n-                if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) {\n-                    goto done;\n-                }\n-            }\n-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n-            continue;\n-        } else {\n-            break;\n+        if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {\n+          _PR_MD_MAP_SELECT_ERROR(syserror);\n+          break;\n         }\n-    }\n-    if (rv < 0) {\n-        _PR_MD_MAP_RECVFROM_ERROR(err);\n-    }\n-done:\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    if (rv != -1) {\n-        /* ignore the sa_len field of struct sockaddr */\n-        if (addr) {\n-            addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n+        if (_PR_PENDING_INTERRUPT(me)) {\n+          me->flags &= ~_PR_INTERRUPT;\n+          PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+          rv = -1;\n+          break;\n         }\n-    }\n-#endif /* _PR_HAVE_SOCKADDR_LEN */\n-    return (rv);\n-}\n-\n-PRInt32\n-_MD_send(PRFileDesc* fd, const void* buf, PRInt32 amount, PRInt32 flags,\n-         PRIntervalTime timeout)\n-{\n-    PRInt32 osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-#if defined(SOLARIS)\n-    PRInt32 tmp_amount = amount;\n-#endif\n-\n-    /*\n-     * On pre-2.6 Solaris, send() is much slower than write().\n-     * On 2.6 and beyond, with in-kernel sockets, send() and\n-     * write() are fairly equivalent in performance.\n-     */\n-#if defined(SOLARIS)\n-    PR_ASSERT(0 == flags);\n-    while ((rv = write(osfd, buf, tmp_amount)) == -1) {\n-#else\n-    while ((rv = send(osfd, buf, amount, flags)) == -1) {\n-#endif\n-        err = _MD_ERRNO();\n-        if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n-            if (fd->secret->nonblocking) {\n-                break;\n-            }\n-            if (!_PR_IS_NATIVE_THREAD(me)) {\n-                if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout)) < 0) {\n-                    goto done;\n-                }\n-            } else {\n-                if ((rv = socket_io_wait(osfd, WRITE_FD, timeout)) < 0) {\n-                    goto done;\n-                }\n-            }\n-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n-            continue;\n+      } while (rv == 0 || (rv == -1 && syserror == EINTR));\n+      break;\n+    default:\n+      now = epoch = PR_IntervalNow();\n+      remaining = timeout;\n+      FD_ZERO(&rd_wr);\n+      do {\n+        /*\n+         * We block in _MD_SELECT for at most\n+         * _PR_INTERRUPT_CHECK_INTERVAL_SECS seconds,\n+         * so that there is an upper limit on the delay\n+         * before the interrupt bit is checked.\n+         */\n+        wait_for_remaining = PR_TRUE;\n+        tv.tv_sec = PR_IntervalToSeconds(remaining);\n+        if (tv.tv_sec > _PR_INTERRUPT_CHECK_INTERVAL_SECS) {\n+          wait_for_remaining = PR_FALSE;\n+          tv.tv_sec = _PR_INTERRUPT_CHECK_INTERVAL_SECS;\n+          tv.tv_usec = 0;\n         } else {\n-#if defined(SOLARIS)\n-            /*\n-             * The write system call has been reported to return the ERANGE\n-             * error on occasion. Try to write in smaller chunks to workaround\n-             * this bug.\n-             */\n-            if (err == ERANGE) {\n-                if (tmp_amount > 1) {\n-                    tmp_amount = tmp_amount / 2; /* half the bytes */\n-                    continue;\n-                }\n-            }\n-#endif\n-            break;\n+          tv.tv_usec = PR_IntervalToMicroseconds(\n+              remaining - PR_SecondsToInterval(tv.tv_sec));\n         }\n-    }\n-    /*\n-     * optimization; if bytes sent is less than \"amount\" call\n-     * select before returning. This is because it is likely that\n-     * the next send() call will return EWOULDBLOCK.\n-     */\n-    if ((!fd->secret->nonblocking) && (rv > 0) && (rv < amount) &&\n-        (timeout != PR_INTERVAL_NO_WAIT)) {\n-        if (_PR_IS_NATIVE_THREAD(me)) {\n-            if (socket_io_wait(osfd, WRITE_FD, timeout) < 0) {\n-                rv = -1;\n-                goto done;\n-            }\n+        FD_SET(osfd, &rd_wr);\n+        if (fd_type == READ_FD) {\n+          rv = _MD_SELECT(osfd + 1, &rd_wr, NULL, NULL, &tv);\n         } else {\n-            if (local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout) < 0) {\n-                rv = -1;\n-                goto done;\n-            }\n+          rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, &tv);\n         }\n-    }\n-    if (rv < 0) {\n-        _PR_MD_MAP_SEND_ERROR(err);\n-    }\n-done:\n-    return (rv);\n-}\n-\n-PRInt32\n-_MD_sendto(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-           PRIntn flags, const PRNetAddr* addr, PRUint32 addrlen,\n-           PRIntervalTime timeout)\n-{\n-    PRInt32 osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    PRNetAddr addrCopy;\n-\n-    addrCopy = *addr;\n-    ((struct sockaddr*)&addrCopy)->sa_len = addrlen;\n-    ((struct sockaddr*)&addrCopy)->sa_family = addr->raw.family;\n-\n-    while ((rv = sendto(osfd, buf, amount, flags, (struct sockaddr*)&addrCopy,\n-                        addrlen)) == -1) {\n-#else\n-    while ((rv = sendto(osfd, buf, amount, flags, (struct sockaddr*)addr,\n-                        addrlen)) == -1) {\n-#endif\n-        err = _MD_ERRNO();\n-        if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n-            if (fd->secret->nonblocking) {\n-                break;\n-            }\n-            if (!_PR_IS_NATIVE_THREAD(me)) {\n-                if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout)) < 0) {\n-                    goto done;\n-                }\n-            } else {\n-                if ((rv = socket_io_wait(osfd, WRITE_FD, timeout)) < 0) {\n-                    goto done;\n-                }\n-            }\n-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n-            continue;\n-        } else {\n-            break;\n+        /*\n+         * we don't consider EINTR a real error\n+         */\n+        if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {\n+          _PR_MD_MAP_SELECT_ERROR(syserror);\n+          break;\n         }\n-    }\n-    if (rv < 0) {\n-        _PR_MD_MAP_SENDTO_ERROR(err);\n-    }\n-done:\n-    return (rv);\n-}\n-\n-PRInt32\n-_MD_writev(PRFileDesc* fd, const PRIOVec* iov, PRInt32 iov_size,\n-           PRIntervalTime timeout)\n-{\n-    PRInt32 rv, err;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRInt32 index, amount = 0;\n-    PRInt32 osfd = fd->secret->md.osfd;\n-\n-    /*\n-     * Calculate the total number of bytes to be sent; needed for\n-     * optimization later.\n-     * We could avoid this if this number was passed in; but it is\n-     * probably not a big deal because iov_size is usually small (less than\n-     * 3)\n-     */\n-    if (!fd->secret->nonblocking) {\n-        for (index = 0; index < iov_size; index++) {\n-            amount += iov[index].iov_len;\n+        if (_PR_PENDING_INTERRUPT(me)) {\n+          me->flags &= ~_PR_INTERRUPT;\n+          PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+          rv = -1;\n+          break;\n         }\n-    }\n-\n-    while ((rv = writev(osfd, (const struct iovec*)iov, iov_size)) == -1) {\n-        err = _MD_ERRNO();\n-        if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n-            if (fd->secret->nonblocking) {\n-                break;\n-            }\n-            if (!_PR_IS_NATIVE_THREAD(me)) {\n-                if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout)) < 0) {\n-                    goto done;\n-                }\n+        /*\n+         * We loop again if _MD_SELECT timed out or got interrupted\n+         * by a signal, and the timeout deadline has not passed yet.\n+         */\n+        if (rv == 0 || (rv == -1 && syserror == EINTR)) {\n+          /*\n+           * If _MD_SELECT timed out, we know how much time\n+           * we spent in blocking, so we can avoid a\n+           * PR_IntervalNow() call.\n+           */\n+          if (rv == 0) {\n+            if (wait_for_remaining) {\n+              now += remaining;\n             } else {\n-                if ((rv = socket_io_wait(osfd, WRITE_FD, timeout)) < 0) {\n-                    goto done;\n-                }\n+              now += PR_SecondsToInterval(tv.tv_sec) +\n+                     PR_MicrosecondsToInterval(tv.tv_usec);\n             }\n-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n-            continue;\n-        } else {\n+          } else {\n+            now = PR_IntervalNow();\n+          }\n+          elapsed = (PRIntervalTime)(now - epoch);\n+          if (elapsed >= timeout) {\n+            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+            rv = -1;\n             break;\n+          } else {\n+            remaining = timeout - elapsed;\n+          }\n         }\n-    }\n-    /*\n-     * optimization; if bytes sent is less than \"amount\" call\n-     * select before returning. This is because it is likely that\n-     * the next writev() call will return EWOULDBLOCK.\n-     */\n-    if ((!fd->secret->nonblocking) && (rv > 0) && (rv < amount) &&\n-        (timeout != PR_INTERVAL_NO_WAIT)) {\n-        if (_PR_IS_NATIVE_THREAD(me)) {\n-            if (socket_io_wait(osfd, WRITE_FD, timeout) < 0) {\n-                rv = -1;\n-                goto done;\n-            }\n-        } else {\n-            if (local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout) < 0) {\n-                rv = -1;\n-                goto done;\n-            }\n+      } while (rv == 0 || (rv == -1 && syserror == EINTR));\n+      break;\n+  }\n+  return (rv);\n+}\n+\n+#  else /* _PR_USE_POLL */\n+\n+static PRInt32 socket_io_wait(PRInt32 osfd, PRInt32 fd_type,\n+                              PRIntervalTime timeout) {\n+  PRInt32 rv = -1;\n+  int msecs;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRIntervalTime epoch, now, elapsed, remaining;\n+  PRBool wait_for_remaining;\n+  PRInt32 syserror;\n+  struct pollfd pfd;\n+\n+  switch (timeout) {\n+    case PR_INTERVAL_NO_WAIT:\n+      PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+      break;\n+    case PR_INTERVAL_NO_TIMEOUT:\n+      /*\n+       * This is a special case of the 'default' case below.\n+       * Please see the comments there.\n+       */\n+      msecs = _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000;\n+      pfd.fd = osfd;\n+      if (fd_type == READ_FD) {\n+        pfd.events = POLLIN;\n+      } else {\n+        pfd.events = POLLOUT;\n+      }\n+      do {\n+        rv = _MD_POLL(&pfd, 1, msecs);\n+        if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {\n+          _PR_MD_MAP_POLL_ERROR(syserror);\n+          break;\n         }\n-    }\n-    if (rv < 0) {\n-        _PR_MD_MAP_WRITEV_ERROR(err);\n-    }\n-done:\n-    return (rv);\n-}\n-\n-PRInt32\n-_MD_accept(PRFileDesc* fd, PRNetAddr* addr, PRUint32* addrlen,\n-           PRIntervalTime timeout)\n-{\n-    PRInt32 osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    while ((rv = accept(osfd, (struct sockaddr*)addr, (_PRSockLen_t*)addrlen)) ==\n-           -1) {\n-        err = _MD_ERRNO();\n-        if ((err == EAGAIN) || (err == EWOULDBLOCK) || (err == ECONNABORTED)) {\n-            if (fd->secret->nonblocking) {\n-                break;\n-            }\n-            if (!_PR_IS_NATIVE_THREAD(me)) {\n-                if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_READ, timeout)) < 0) {\n-                    goto done;\n-                }\n+        /*\n+         * If POLLERR is set, don't process it; retry the operation\n+         */\n+        if ((rv == 1) && (pfd.revents & (POLLHUP | POLLNVAL))) {\n+          rv = -1;\n+          _PR_MD_MAP_POLL_REVENTS_ERROR(pfd.revents);\n+          break;\n+        }\n+        if (_PR_PENDING_INTERRUPT(me)) {\n+          me->flags &= ~_PR_INTERRUPT;\n+          PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+          rv = -1;\n+          break;\n+        }\n+      } while (rv == 0 || (rv == -1 && syserror == EINTR));\n+      break;\n+    default:\n+      now = epoch = PR_IntervalNow();\n+      remaining = timeout;\n+      pfd.fd = osfd;\n+      if (fd_type == READ_FD) {\n+        pfd.events = POLLIN;\n+      } else {\n+        pfd.events = POLLOUT;\n+      }\n+      do {\n+        /*\n+         * We block in _MD_POLL for at most\n+         * _PR_INTERRUPT_CHECK_INTERVAL_SECS seconds,\n+         * so that there is an upper limit on the delay\n+         * before the interrupt bit is checked.\n+         */\n+        wait_for_remaining = PR_TRUE;\n+        msecs = PR_IntervalToMilliseconds(remaining);\n+        if (msecs > _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000) {\n+          wait_for_remaining = PR_FALSE;\n+          msecs = _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000;\n+        }\n+        rv = _MD_POLL(&pfd, 1, msecs);\n+        /*\n+         * we don't consider EINTR a real error\n+         */\n+        if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {\n+          _PR_MD_MAP_POLL_ERROR(syserror);\n+          break;\n+        }\n+        if (_PR_PENDING_INTERRUPT(me)) {\n+          me->flags &= ~_PR_INTERRUPT;\n+          PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+          rv = -1;\n+          break;\n+        }\n+        /*\n+         * If POLLERR is set, don't process it; retry the operation\n+         */\n+        if ((rv == 1) && (pfd.revents & (POLLHUP | POLLNVAL))) {\n+          rv = -1;\n+          _PR_MD_MAP_POLL_REVENTS_ERROR(pfd.revents);\n+          break;\n+        }\n+        /*\n+         * We loop again if _MD_POLL timed out or got interrupted\n+         * by a signal, and the timeout deadline has not passed yet.\n+         */\n+        if (rv == 0 || (rv == -1 && syserror == EINTR)) {\n+          /*\n+           * If _MD_POLL timed out, we know how much time\n+           * we spent in blocking, so we can avoid a\n+           * PR_IntervalNow() call.\n+           */\n+          if (rv == 0) {\n+            if (wait_for_remaining) {\n+              now += remaining;\n             } else {\n-                if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) {\n-                    goto done;\n-                }\n+              now += PR_MillisecondsToInterval(msecs);\n             }\n-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n-            continue;\n-        } else {\n+          } else {\n+            now = PR_IntervalNow();\n+          }\n+          elapsed = (PRIntervalTime)(now - epoch);\n+          if (elapsed >= timeout) {\n+            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+            rv = -1;\n             break;\n+          } else {\n+            remaining = timeout - elapsed;\n+          }\n         }\n-    }\n-    if (rv < 0) {\n-        _PR_MD_MAP_ACCEPT_ERROR(err);\n-    }\n-done:\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    if (rv != -1) {\n-        /* ignore the sa_len field of struct sockaddr */\n-        if (addr) {\n-            addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n-        }\n-    }\n-#endif /* _PR_HAVE_SOCKADDR_LEN */\n-    return (rv);\n+      } while (rv == 0 || (rv == -1 && syserror == EINTR));\n+      break;\n+  }\n+  return (rv);\n }\n \n-extern int _connect(int s, const struct sockaddr* name, int namelen);\n-PRInt32\n-_MD_connect(PRFileDesc* fd, const PRNetAddr* addr, PRUint32 addrlen,\n-            PRIntervalTime timeout)\n-{\n-    PRInt32 rv, err;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRInt32 osfd = fd->secret->md.osfd;\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    PRNetAddr addrCopy;\n-\n-    addrCopy = *addr;\n-    ((struct sockaddr*)&addrCopy)->sa_len = addrlen;\n-    ((struct sockaddr*)&addrCopy)->sa_family = addr->raw.family;\n-#endif\n+#  endif /* _PR_USE_POLL */\n \n-    /*\n-     * We initiate the connection setup by making a nonblocking connect()\n-     * call.  If the connect() call fails, there are two cases we handle\n-     * specially:\n-     * 1. The connect() call was interrupted by a signal.  In this case\n-     *    we simply retry connect().\n-     * 2. The NSPR socket is nonblocking and connect() fails with\n-     *    EINPROGRESS.  We first wait until the socket becomes writable.\n-     *    Then we try to find out whether the connection setup succeeded\n-     *    or failed.\n-     */\n+static PRInt32 local_io_wait(PRInt32 osfd, PRInt32 wait_flag,\n+                             PRIntervalTime timeout) {\n+  _PRUnixPollDesc pd;\n+  PRInt32 rv;\n \n-retry:\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    if ((rv = connect(osfd, (struct sockaddr*)&addrCopy, addrlen)) == -1) {\n-#else\n-    if ((rv = connect(osfd, (struct sockaddr*)addr, addrlen)) == -1) {\n-#endif\n-        err = _MD_ERRNO();\n+  PR_LOG(_pr_io_lm, PR_LOG_MIN,\n+         (\"waiting to %s on osfd=%d\",\n+          (wait_flag == _PR_UNIX_POLL_READ) ? \"read\" : \"write\", osfd));\n \n-        if (err == EINTR) {\n-            if (_PR_PENDING_INTERRUPT(me)) {\n-                me->flags &= ~_PR_INTERRUPT;\n-                PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                return -1;\n-            }\n-            goto retry;\n+  if (timeout == PR_INTERVAL_NO_WAIT) {\n+    return 0;\n+  }\n+\n+  pd.osfd = osfd;\n+  pd.in_flags = wait_flag;\n+  pd.out_flags = 0;\n+\n+  rv = _PR_WaitForMultipleFDs(&pd, 1, timeout);\n+\n+  if (rv == 0) {\n+    PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+    rv = -1;\n+  }\n+  return rv;\n+}\n+\n+PRInt32 _MD_recv(PRFileDesc* fd, void* buf, PRInt32 amount, PRInt32 flags,\n+                 PRIntervalTime timeout) {\n+  PRInt32 osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  /*\n+   * Many OS's (ex: Solaris) have a broken recv which won't read\n+   * from socketpairs.  As long as we don't use flags on socketpairs, this\n+   * is a decent fix. - mikep\n+   */\n+#  if defined(SOLARIS)\n+  while ((rv = read(osfd, buf, amount)) == -1) {\n+#  else\n+  while ((rv = recv(osfd, buf, amount, flags)) == -1) {\n+#  endif\n+    err = _MD_ERRNO();\n+    if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n+      if (fd->secret->nonblocking) {\n+        break;\n+      }\n+      if (!_PR_IS_NATIVE_THREAD(me)) {\n+        if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_READ, timeout)) < 0) {\n+          goto done;\n         }\n-\n-        if (!fd->secret->nonblocking && (err == EINPROGRESS)) {\n-            if (!_PR_IS_NATIVE_THREAD(me)) {\n-                if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout)) < 0) {\n-                    return -1;\n-                }\n-            } else {\n-                /*\n-                 * socket_io_wait() may return -1 or 1.\n-                 */\n-\n-                rv = socket_io_wait(osfd, WRITE_FD, timeout);\n-                if (rv == -1) {\n-                    return -1;\n-                }\n-            }\n-\n-            PR_ASSERT(rv == 1);\n-            if (_PR_PENDING_INTERRUPT(me)) {\n-                me->flags &= ~_PR_INTERRUPT;\n-                PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                return -1;\n-            }\n-            err = _MD_unix_get_nonblocking_connect_error(osfd);\n-            if (err != 0) {\n-                _PR_MD_MAP_CONNECT_ERROR(err);\n-                return -1;\n-            }\n-            return 0;\n+      } else {\n+        if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) {\n+          goto done;\n         }\n-\n-        _PR_MD_MAP_CONNECT_ERROR(err);\n-    }\n-\n-    return rv;\n-} /* _MD_connect */\n-\n-PRInt32\n-_MD_bind(PRFileDesc* fd, const PRNetAddr* addr, PRUint32 addrlen)\n-{\n-    PRInt32 rv, err;\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    PRNetAddr addrCopy;\n-\n-    addrCopy = *addr;\n-    ((struct sockaddr*)&addrCopy)->sa_len = addrlen;\n-    ((struct sockaddr*)&addrCopy)->sa_family = addr->raw.family;\n-    rv = bind(fd->secret->md.osfd, (struct sockaddr*)&addrCopy, (int)addrlen);\n-#else\n-    rv = bind(fd->secret->md.osfd, (struct sockaddr*)addr, (int)addrlen);\n-#endif\n-    if (rv < 0) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_BIND_ERROR(err);\n-    }\n-    return (rv);\n-}\n-\n-PRInt32\n-_MD_listen(PRFileDesc* fd, PRIntn backlog)\n-{\n-    PRInt32 rv, err;\n-\n-    rv = listen(fd->secret->md.osfd, backlog);\n-    if (rv < 0) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_LISTEN_ERROR(err);\n+      }\n+    } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n+      continue;\n+    } else {\n+      break;\n     }\n-    return (rv);\n-}\n-\n-PRInt32\n-_MD_shutdown(PRFileDesc* fd, PRIntn how)\n-{\n-    PRInt32 rv, err;\n-\n-    rv = shutdown(fd->secret->md.osfd, how);\n-    if (rv < 0) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_SHUTDOWN_ERROR(err);\n+  }\n+  if (rv < 0) {\n+    _PR_MD_MAP_RECV_ERROR(err);\n+  }\n+done:\n+  return (rv);\n+}\n+\n+PRInt32 _MD_recvfrom(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n+                     PRNetAddr* addr, PRUint32* addrlen,\n+                     PRIntervalTime timeout) {\n+  PRInt32 osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  while ((*addrlen = PR_NETADDR_SIZE(addr)),\n+         ((rv = recvfrom(osfd, buf, amount, flags, (struct sockaddr*)addr,\n+                         (_PRSockLen_t*)addrlen)) == -1)) {\n+    err = _MD_ERRNO();\n+    if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n+      if (fd->secret->nonblocking) {\n+        break;\n+      }\n+      if (!_PR_IS_NATIVE_THREAD(me)) {\n+        if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_READ, timeout)) < 0) {\n+          goto done;\n+        }\n+      } else {\n+        if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) {\n+          goto done;\n+        }\n+      }\n+    } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n+      continue;\n+    } else {\n+      break;\n     }\n-    return (rv);\n-}\n-\n-PRInt32\n-_MD_socketpair(int af, int type, int flags, PRInt32* osfd)\n-{\n-    PRInt32 rv, err;\n-\n-    rv = socketpair(af, type, flags, osfd);\n-    if (rv < 0) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_SOCKETPAIR_ERROR(err);\n+  }\n+  if (rv < 0) {\n+    _PR_MD_MAP_RECVFROM_ERROR(err);\n+  }\n+done:\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  if (rv != -1) {\n+    /* ignore the sa_len field of struct sockaddr */\n+    if (addr) {\n+      addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n+    }\n+  }\n+#  endif /* _PR_HAVE_SOCKADDR_LEN */\n+  return (rv);\n+}\n+\n+PRInt32 _MD_send(PRFileDesc* fd, const void* buf, PRInt32 amount, PRInt32 flags,\n+                 PRIntervalTime timeout) {\n+  PRInt32 osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+#  if defined(SOLARIS)\n+  PRInt32 tmp_amount = amount;\n+#  endif\n+\n+  /*\n+   * On pre-2.6 Solaris, send() is much slower than write().\n+   * On 2.6 and beyond, with in-kernel sockets, send() and\n+   * write() are fairly equivalent in performance.\n+   */\n+#  if defined(SOLARIS)\n+  PR_ASSERT(0 == flags);\n+  while ((rv = write(osfd, buf, tmp_amount)) == -1) {\n+#  else\n+  while ((rv = send(osfd, buf, amount, flags)) == -1) {\n+#  endif\n+    err = _MD_ERRNO();\n+    if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n+      if (fd->secret->nonblocking) {\n+        break;\n+      }\n+      if (!_PR_IS_NATIVE_THREAD(me)) {\n+        if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout)) < 0) {\n+          goto done;\n+        }\n+      } else {\n+        if ((rv = socket_io_wait(osfd, WRITE_FD, timeout)) < 0) {\n+          goto done;\n+        }\n+      }\n+    } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n+      continue;\n+    } else {\n+#  if defined(SOLARIS)\n+      /*\n+       * The write system call has been reported to return the ERANGE\n+       * error on occasion. Try to write in smaller chunks to workaround\n+       * this bug.\n+       */\n+      if (err == ERANGE) {\n+        if (tmp_amount > 1) {\n+          tmp_amount = tmp_amount / 2; /* half the bytes */\n+          continue;\n+        }\n+      }\n+#  endif\n+      break;\n+    }\n+  }\n+  /*\n+   * optimization; if bytes sent is less than \"amount\" call\n+   * select before returning. This is because it is likely that\n+   * the next send() call will return EWOULDBLOCK.\n+   */\n+  if ((!fd->secret->nonblocking) && (rv > 0) && (rv < amount) &&\n+      (timeout != PR_INTERVAL_NO_WAIT)) {\n+    if (_PR_IS_NATIVE_THREAD(me)) {\n+      if (socket_io_wait(osfd, WRITE_FD, timeout) < 0) {\n+        rv = -1;\n+        goto done;\n+      }\n+    } else {\n+      if (local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout) < 0) {\n+        rv = -1;\n+        goto done;\n+      }\n     }\n-    return rv;\n-}\n-\n-PRStatus\n-_MD_getsockname(PRFileDesc* fd, PRNetAddr* addr, PRUint32* addrlen)\n-{\n-    PRInt32 rv, err;\n-\n-    rv = getsockname(fd->secret->md.osfd, (struct sockaddr*)addr,\n-                     (_PRSockLen_t*)addrlen);\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    if (rv == 0) {\n-        /* ignore the sa_len field of struct sockaddr */\n-        if (addr) {\n-            addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n+  }\n+  if (rv < 0) {\n+    _PR_MD_MAP_SEND_ERROR(err);\n+  }\n+done:\n+  return (rv);\n+}\n+\n+PRInt32 _MD_sendto(PRFileDesc* fd, const void* buf, PRInt32 amount,\n+                   PRIntn flags, const PRNetAddr* addr, PRUint32 addrlen,\n+                   PRIntervalTime timeout) {\n+  PRInt32 osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  PRNetAddr addrCopy;\n+\n+  addrCopy = *addr;\n+  ((struct sockaddr*)&addrCopy)->sa_len = addrlen;\n+  ((struct sockaddr*)&addrCopy)->sa_family = addr->raw.family;\n+\n+  while ((rv = sendto(osfd, buf, amount, flags, (struct sockaddr*)&addrCopy,\n+                      addrlen)) == -1) {\n+#  else\n+  while ((rv = sendto(osfd, buf, amount, flags, (struct sockaddr*)addr,\n+                      addrlen)) == -1) {\n+#  endif\n+    err = _MD_ERRNO();\n+    if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n+      if (fd->secret->nonblocking) {\n+        break;\n+      }\n+      if (!_PR_IS_NATIVE_THREAD(me)) {\n+        if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout)) < 0) {\n+          goto done;\n         }\n+      } else {\n+        if ((rv = socket_io_wait(osfd, WRITE_FD, timeout)) < 0) {\n+          goto done;\n+        }\n+      }\n+    } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n+      continue;\n+    } else {\n+      break;\n     }\n-#endif /* _PR_HAVE_SOCKADDR_LEN */\n-    if (rv < 0) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_GETSOCKNAME_ERROR(err);\n+  }\n+  if (rv < 0) {\n+    _PR_MD_MAP_SENDTO_ERROR(err);\n+  }\n+done:\n+  return (rv);\n+}\n+\n+PRInt32 _MD_writev(PRFileDesc* fd, const PRIOVec* iov, PRInt32 iov_size,\n+                   PRIntervalTime timeout) {\n+  PRInt32 rv, err;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRInt32 index, amount = 0;\n+  PRInt32 osfd = fd->secret->md.osfd;\n+\n+  /*\n+   * Calculate the total number of bytes to be sent; needed for\n+   * optimization later.\n+   * We could avoid this if this number was passed in; but it is\n+   * probably not a big deal because iov_size is usually small (less than\n+   * 3)\n+   */\n+  if (!fd->secret->nonblocking) {\n+    for (index = 0; index < iov_size; index++) {\n+      amount += iov[index].iov_len;\n+    }\n+  }\n+\n+  while ((rv = writev(osfd, (const struct iovec*)iov, iov_size)) == -1) {\n+    err = _MD_ERRNO();\n+    if ((err == EAGAIN) || (err == EWOULDBLOCK)) {\n+      if (fd->secret->nonblocking) {\n+        break;\n+      }\n+      if (!_PR_IS_NATIVE_THREAD(me)) {\n+        if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout)) < 0) {\n+          goto done;\n+        }\n+      } else {\n+        if ((rv = socket_io_wait(osfd, WRITE_FD, timeout)) < 0) {\n+          goto done;\n+        }\n+      }\n+    } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n+      continue;\n+    } else {\n+      break;\n+    }\n+  }\n+  /*\n+   * optimization; if bytes sent is less than \"amount\" call\n+   * select before returning. This is because it is likely that\n+   * the next writev() call will return EWOULDBLOCK.\n+   */\n+  if ((!fd->secret->nonblocking) && (rv > 0) && (rv < amount) &&\n+      (timeout != PR_INTERVAL_NO_WAIT)) {\n+    if (_PR_IS_NATIVE_THREAD(me)) {\n+      if (socket_io_wait(osfd, WRITE_FD, timeout) < 0) {\n+        rv = -1;\n+        goto done;\n+      }\n+    } else {\n+      if (local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout) < 0) {\n+        rv = -1;\n+        goto done;\n+      }\n     }\n-    return rv == 0 ? PR_SUCCESS : PR_FAILURE;\n+  }\n+  if (rv < 0) {\n+    _PR_MD_MAP_WRITEV_ERROR(err);\n+  }\n+done:\n+  return (rv);\n }\n \n-PRStatus\n-_MD_getpeername(PRFileDesc* fd, PRNetAddr* addr, PRUint32* addrlen)\n-{\n-    PRInt32 rv, err;\n+PRInt32 _MD_accept(PRFileDesc* fd, PRNetAddr* addr, PRUint32* addrlen,\n+                   PRIntervalTime timeout) {\n+  PRInt32 osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    rv = getpeername(fd->secret->md.osfd, (struct sockaddr*)addr,\n-                     (_PRSockLen_t*)addrlen);\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    if (rv == 0) {\n-        /* ignore the sa_len field of struct sockaddr */\n-        if (addr) {\n-            addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n+  while ((rv = accept(osfd, (struct sockaddr*)addr, (_PRSockLen_t*)addrlen)) ==\n+         -1) {\n+    err = _MD_ERRNO();\n+    if ((err == EAGAIN) || (err == EWOULDBLOCK) || (err == ECONNABORTED)) {\n+      if (fd->secret->nonblocking) {\n+        break;\n+      }\n+      if (!_PR_IS_NATIVE_THREAD(me)) {\n+        if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_READ, timeout)) < 0) {\n+          goto done;\n+        }\n+      } else {\n+        if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) {\n+          goto done;\n         }\n+      }\n+    } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {\n+      continue;\n+    } else {\n+      break;\n     }\n-#endif /* _PR_HAVE_SOCKADDR_LEN */\n-    if (rv < 0) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_GETPEERNAME_ERROR(err);\n+  }\n+  if (rv < 0) {\n+    _PR_MD_MAP_ACCEPT_ERROR(err);\n+  }\n+done:\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  if (rv != -1) {\n+    /* ignore the sa_len field of struct sockaddr */\n+    if (addr) {\n+      addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n     }\n-    return rv == 0 ? PR_SUCCESS : PR_FAILURE;\n+  }\n+#  endif /* _PR_HAVE_SOCKADDR_LEN */\n+  return (rv);\n }\n \n-PRStatus\n-_MD_getsockopt(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n-               char* optval, PRInt32* optlen)\n-{\n-    PRInt32 rv, err;\n+extern int _connect(int s, const struct sockaddr* name, int namelen);\n+PRInt32 _MD_connect(PRFileDesc* fd, const PRNetAddr* addr, PRUint32 addrlen,\n+                    PRIntervalTime timeout) {\n+  PRInt32 rv, err;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRInt32 osfd = fd->secret->md.osfd;\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  PRNetAddr addrCopy;\n+\n+  addrCopy = *addr;\n+  ((struct sockaddr*)&addrCopy)->sa_len = addrlen;\n+  ((struct sockaddr*)&addrCopy)->sa_family = addr->raw.family;\n+#  endif\n+\n+  /*\n+   * We initiate the connection setup by making a nonblocking connect()\n+   * call.  If the connect() call fails, there are two cases we handle\n+   * specially:\n+   * 1. The connect() call was interrupted by a signal.  In this case\n+   *    we simply retry connect().\n+   * 2. The NSPR socket is nonblocking and connect() fails with\n+   *    EINPROGRESS.  We first wait until the socket becomes writable.\n+   *    Then we try to find out whether the connection setup succeeded\n+   *    or failed.\n+   */\n \n-    rv = getsockopt(fd->secret->md.osfd, level, optname, optval,\n-                    (_PRSockLen_t*)optlen);\n-    if (rv < 0) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_GETSOCKOPT_ERROR(err);\n+retry:\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  if ((rv = connect(osfd, (struct sockaddr*)&addrCopy, addrlen)) == -1) {\n+#  else\n+  if ((rv = connect(osfd, (struct sockaddr*)addr, addrlen)) == -1) {\n+#  endif\n+    err = _MD_ERRNO();\n+\n+    if (err == EINTR) {\n+      if (_PR_PENDING_INTERRUPT(me)) {\n+        me->flags &= ~_PR_INTERRUPT;\n+        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+        return -1;\n+      }\n+      goto retry;\n     }\n-    return rv == 0 ? PR_SUCCESS : PR_FAILURE;\n-}\n \n-PRStatus\n-_MD_setsockopt(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n-               const char* optval, PRInt32 optlen)\n-{\n-    PRInt32 rv, err;\n+    if (!fd->secret->nonblocking && (err == EINPROGRESS)) {\n+      if (!_PR_IS_NATIVE_THREAD(me)) {\n+        if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout)) < 0) {\n+          return -1;\n+        }\n+      } else {\n+        /*\n+         * socket_io_wait() may return -1 or 1.\n+         */\n \n-    rv = setsockopt(fd->secret->md.osfd, level, optname, optval, optlen);\n-    if (rv < 0) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_SETSOCKOPT_ERROR(err);\n+        rv = socket_io_wait(osfd, WRITE_FD, timeout);\n+        if (rv == -1) {\n+          return -1;\n+        }\n+      }\n+\n+      PR_ASSERT(rv == 1);\n+      if (_PR_PENDING_INTERRUPT(me)) {\n+        me->flags &= ~_PR_INTERRUPT;\n+        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+        return -1;\n+      }\n+      err = _MD_unix_get_nonblocking_connect_error(osfd);\n+      if (err != 0) {\n+        _PR_MD_MAP_CONNECT_ERROR(err);\n+        return -1;\n+      }\n+      return 0;\n     }\n-    return rv == 0 ? PR_SUCCESS : PR_FAILURE;\n-}\n \n-PRStatus\n-_MD_set_fd_inheritable(PRFileDesc* fd, PRBool inheritable)\n-{\n-    int rv;\n+    _PR_MD_MAP_CONNECT_ERROR(err);\n+  }\n \n-    rv = fcntl(fd->secret->md.osfd, F_SETFD, inheritable ? 0 : FD_CLOEXEC);\n-    if (-1 == rv) {\n-        PR_SetError(PR_UNKNOWN_ERROR, _MD_ERRNO());\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  return rv;\n+} /* _MD_connect */\n+\n+PRInt32 _MD_bind(PRFileDesc* fd, const PRNetAddr* addr, PRUint32 addrlen) {\n+  PRInt32 rv, err;\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  PRNetAddr addrCopy;\n+\n+  addrCopy = *addr;\n+  ((struct sockaddr*)&addrCopy)->sa_len = addrlen;\n+  ((struct sockaddr*)&addrCopy)->sa_family = addr->raw.family;\n+  rv = bind(fd->secret->md.osfd, (struct sockaddr*)&addrCopy, (int)addrlen);\n+#  else\n+  rv = bind(fd->secret->md.osfd, (struct sockaddr*)addr, (int)addrlen);\n+#  endif\n+  if (rv < 0) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_BIND_ERROR(err);\n+  }\n+  return (rv);\n+}\n+\n+PRInt32 _MD_listen(PRFileDesc* fd, PRIntn backlog) {\n+  PRInt32 rv, err;\n+\n+  rv = listen(fd->secret->md.osfd, backlog);\n+  if (rv < 0) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_LISTEN_ERROR(err);\n+  }\n+  return (rv);\n+}\n+\n+PRInt32 _MD_shutdown(PRFileDesc* fd, PRIntn how) {\n+  PRInt32 rv, err;\n+\n+  rv = shutdown(fd->secret->md.osfd, how);\n+  if (rv < 0) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_SHUTDOWN_ERROR(err);\n+  }\n+  return (rv);\n+}\n+\n+PRInt32 _MD_socketpair(int af, int type, int flags, PRInt32* osfd) {\n+  PRInt32 rv, err;\n+\n+  rv = socketpair(af, type, flags, osfd);\n+  if (rv < 0) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_SOCKETPAIR_ERROR(err);\n+  }\n+  return rv;\n+}\n+\n+PRStatus _MD_getsockname(PRFileDesc* fd, PRNetAddr* addr, PRUint32* addrlen) {\n+  PRInt32 rv, err;\n+\n+  rv = getsockname(fd->secret->md.osfd, (struct sockaddr*)addr,\n+                   (_PRSockLen_t*)addrlen);\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  if (rv == 0) {\n+    /* ignore the sa_len field of struct sockaddr */\n+    if (addr) {\n+      addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n+    }\n+  }\n+#  endif /* _PR_HAVE_SOCKADDR_LEN */\n+  if (rv < 0) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_GETSOCKNAME_ERROR(err);\n+  }\n+  return rv == 0 ? PR_SUCCESS : PR_FAILURE;\n+}\n+\n+PRStatus _MD_getpeername(PRFileDesc* fd, PRNetAddr* addr, PRUint32* addrlen) {\n+  PRInt32 rv, err;\n+\n+  rv = getpeername(fd->secret->md.osfd, (struct sockaddr*)addr,\n+                   (_PRSockLen_t*)addrlen);\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  if (rv == 0) {\n+    /* ignore the sa_len field of struct sockaddr */\n+    if (addr) {\n+      addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n+    }\n+  }\n+#  endif /* _PR_HAVE_SOCKADDR_LEN */\n+  if (rv < 0) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_GETPEERNAME_ERROR(err);\n+  }\n+  return rv == 0 ? PR_SUCCESS : PR_FAILURE;\n+}\n+\n+PRStatus _MD_getsockopt(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n+                        char* optval, PRInt32* optlen) {\n+  PRInt32 rv, err;\n+\n+  rv = getsockopt(fd->secret->md.osfd, level, optname, optval,\n+                  (_PRSockLen_t*)optlen);\n+  if (rv < 0) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_GETSOCKOPT_ERROR(err);\n+  }\n+  return rv == 0 ? PR_SUCCESS : PR_FAILURE;\n+}\n+\n+PRStatus _MD_setsockopt(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n+                        const char* optval, PRInt32 optlen) {\n+  PRInt32 rv, err;\n+\n+  rv = setsockopt(fd->secret->md.osfd, level, optname, optval, optlen);\n+  if (rv < 0) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_SETSOCKOPT_ERROR(err);\n+  }\n+  return rv == 0 ? PR_SUCCESS : PR_FAILURE;\n+}\n+\n+PRStatus _MD_set_fd_inheritable(PRFileDesc* fd, PRBool inheritable) {\n+  int rv;\n+\n+  rv = fcntl(fd->secret->md.osfd, F_SETFD, inheritable ? 0 : FD_CLOEXEC);\n+  if (-1 == rv) {\n+    PR_SetError(PR_UNKNOWN_ERROR, _MD_ERRNO());\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-void\n-_MD_init_fd_inheritable(PRFileDesc* fd, PRBool imported)\n-{\n-    if (imported) {\n-        fd->secret->inheritable = _PR_TRI_UNKNOWN;\n-    } else {\n-        /* By default, a Unix fd is not closed on exec. */\n-#ifdef DEBUG\n-        {\n-            int flags = fcntl(fd->secret->md.osfd, F_GETFD, 0);\n-            PR_ASSERT(0 == flags);\n-        }\n-#endif\n-        fd->secret->inheritable = _PR_TRI_TRUE;\n+void _MD_init_fd_inheritable(PRFileDesc* fd, PRBool imported) {\n+  if (imported) {\n+    fd->secret->inheritable = _PR_TRI_UNKNOWN;\n+  } else {\n+    /* By default, a Unix fd is not closed on exec. */\n+#  ifdef DEBUG\n+    {\n+      int flags = fcntl(fd->secret->md.osfd, F_GETFD, 0);\n+      PR_ASSERT(0 == flags);\n     }\n+#  endif\n+    fd->secret->inheritable = _PR_TRI_TRUE;\n+  }\n }\n \n /************************************************************************/\n-#if !defined(_PR_USE_POLL)\n+#  if !defined(_PR_USE_POLL)\n \n /*\n ** Scan through io queue and find any bad fd's that triggered the error\n ** from _MD_SELECT\n */\n-static void\n-FindBadFDs(void)\n-{\n-    PRCList* q;\n-    PRThread* me = _MD_CURRENT_THREAD();\n-\n-    PR_ASSERT(!_PR_IS_NATIVE_THREAD(me));\n-    q = (_PR_IOQ(me->cpu)).next;\n-    _PR_IOQ_MAX_OSFD(me->cpu) = -1;\n-    _PR_IOQ_TIMEOUT(me->cpu) = PR_INTERVAL_NO_TIMEOUT;\n-    while (q != &_PR_IOQ(me->cpu)) {\n-        PRPollQueue* pq = _PR_POLLQUEUE_PTR(q);\n-        PRBool notify = PR_FALSE;\n-        _PRUnixPollDesc* pds = pq->pds;\n-        _PRUnixPollDesc* epds = pds + pq->npds;\n-        PRInt32 pq_max_osfd = -1;\n-\n-        q = q->next;\n-        for (; pds < epds; pds++) {\n-            PRInt32 osfd = pds->osfd;\n-            pds->out_flags = 0;\n-            PR_ASSERT(osfd >= 0 || pds->in_flags == 0);\n-            if (pds->in_flags == 0) {\n-                continue; /* skip this fd */\n-            }\n-            if (fcntl(osfd, F_GETFL, 0) == -1) {\n-                /* Found a bad descriptor, remove it from the fd_sets. */\n-                PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"file descriptor %d is bad\", osfd));\n-                pds->out_flags = _PR_UNIX_POLL_NVAL;\n-                notify = PR_TRUE;\n-            }\n-            if (osfd > pq_max_osfd) {\n-                pq_max_osfd = osfd;\n-            }\n+static void FindBadFDs(void) {\n+  PRCList* q;\n+  PRThread* me = _MD_CURRENT_THREAD();\n+\n+  PR_ASSERT(!_PR_IS_NATIVE_THREAD(me));\n+  q = (_PR_IOQ(me->cpu)).next;\n+  _PR_IOQ_MAX_OSFD(me->cpu) = -1;\n+  _PR_IOQ_TIMEOUT(me->cpu) = PR_INTERVAL_NO_TIMEOUT;\n+  while (q != &_PR_IOQ(me->cpu)) {\n+    PRPollQueue* pq = _PR_POLLQUEUE_PTR(q);\n+    PRBool notify = PR_FALSE;\n+    _PRUnixPollDesc* pds = pq->pds;\n+    _PRUnixPollDesc* epds = pds + pq->npds;\n+    PRInt32 pq_max_osfd = -1;\n+\n+    q = q->next;\n+    for (; pds < epds; pds++) {\n+      PRInt32 osfd = pds->osfd;\n+      pds->out_flags = 0;\n+      PR_ASSERT(osfd >= 0 || pds->in_flags == 0);\n+      if (pds->in_flags == 0) {\n+        continue; /* skip this fd */\n+      }\n+      if (fcntl(osfd, F_GETFL, 0) == -1) {\n+        /* Found a bad descriptor, remove it from the fd_sets. */\n+        PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"file descriptor %d is bad\", osfd));\n+        pds->out_flags = _PR_UNIX_POLL_NVAL;\n+        notify = PR_TRUE;\n+      }\n+      if (osfd > pq_max_osfd) {\n+        pq_max_osfd = osfd;\n+      }\n+    }\n+\n+    if (notify) {\n+      PRIntn pri;\n+      PR_REMOVE_LINK(&pq->links);\n+      pq->on_ioq = PR_FALSE;\n+\n+      /*\n+       * Decrement the count of descriptors for each desciptor/event\n+       * because this I/O request is being removed from the\n+       * ioq\n+       */\n+      pds = pq->pds;\n+      for (; pds < epds; pds++) {\n+        PRInt32 osfd = pds->osfd;\n+        PRInt16 in_flags = pds->in_flags;\n+        PR_ASSERT(osfd >= 0 || in_flags == 0);\n+        if (in_flags & _PR_UNIX_POLL_READ) {\n+          if (--(_PR_FD_READ_CNT(me->cpu))[osfd] == 0) {\n+            FD_CLR(osfd, &_PR_FD_READ_SET(me->cpu));\n+          }\n         }\n-\n-        if (notify) {\n-            PRIntn pri;\n-            PR_REMOVE_LINK(&pq->links);\n-            pq->on_ioq = PR_FALSE;\n-\n-            /*\n-             * Decrement the count of descriptors for each desciptor/event\n-             * because this I/O request is being removed from the\n-             * ioq\n-             */\n-            pds = pq->pds;\n-            for (; pds < epds; pds++) {\n-                PRInt32 osfd = pds->osfd;\n-                PRInt16 in_flags = pds->in_flags;\n-                PR_ASSERT(osfd >= 0 || in_flags == 0);\n-                if (in_flags & _PR_UNIX_POLL_READ) {\n-                    if (--(_PR_FD_READ_CNT(me->cpu))[osfd] == 0) {\n-                        FD_CLR(osfd, &_PR_FD_READ_SET(me->cpu));\n-                    }\n-                }\n-                if (in_flags & _PR_UNIX_POLL_WRITE) {\n-                    if (--(_PR_FD_WRITE_CNT(me->cpu))[osfd] == 0) {\n-                        FD_CLR(osfd, &_PR_FD_WRITE_SET(me->cpu));\n-                    }\n-                }\n-                if (in_flags & _PR_UNIX_POLL_EXCEPT) {\n-                    if (--(_PR_FD_EXCEPTION_CNT(me->cpu))[osfd] == 0) {\n-                        FD_CLR(osfd, &_PR_FD_EXCEPTION_SET(me->cpu));\n-                    }\n-                }\n-            }\n-\n-            _PR_THREAD_LOCK(pq->thr);\n-            if (pq->thr->flags & (_PR_ON_PAUSEQ | _PR_ON_SLEEPQ)) {\n-                _PRCPU* cpu = pq->thr->cpu;\n-                _PR_SLEEPQ_LOCK(pq->thr->cpu);\n-                _PR_DEL_SLEEPQ(pq->thr, PR_TRUE);\n-                _PR_SLEEPQ_UNLOCK(pq->thr->cpu);\n-\n-                if (pq->thr->flags & _PR_SUSPENDING) {\n-                    /*\n-                     * set thread state to SUSPENDED;\n-                     * a Resume operation on the thread\n-                     * will move it to the runQ\n-                     */\n-                    pq->thr->state = _PR_SUSPENDED;\n-                    _PR_MISCQ_LOCK(pq->thr->cpu);\n-                    _PR_ADD_SUSPENDQ(pq->thr, pq->thr->cpu);\n-                    _PR_MISCQ_UNLOCK(pq->thr->cpu);\n-                } else {\n-                    pri = pq->thr->priority;\n-                    pq->thr->state = _PR_RUNNABLE;\n-\n-                    _PR_RUNQ_LOCK(cpu);\n-                    _PR_ADD_RUNQ(pq->thr, cpu, pri);\n-                    _PR_RUNQ_UNLOCK(cpu);\n-                }\n-            }\n-            _PR_THREAD_UNLOCK(pq->thr);\n+        if (in_flags & _PR_UNIX_POLL_WRITE) {\n+          if (--(_PR_FD_WRITE_CNT(me->cpu))[osfd] == 0) {\n+            FD_CLR(osfd, &_PR_FD_WRITE_SET(me->cpu));\n+          }\n+        }\n+        if (in_flags & _PR_UNIX_POLL_EXCEPT) {\n+          if (--(_PR_FD_EXCEPTION_CNT(me->cpu))[osfd] == 0) {\n+            FD_CLR(osfd, &_PR_FD_EXCEPTION_SET(me->cpu));\n+          }\n+        }\n+      }\n+\n+      _PR_THREAD_LOCK(pq->thr);\n+      if (pq->thr->flags & (_PR_ON_PAUSEQ | _PR_ON_SLEEPQ)) {\n+        _PRCPU* cpu = pq->thr->cpu;\n+        _PR_SLEEPQ_LOCK(pq->thr->cpu);\n+        _PR_DEL_SLEEPQ(pq->thr, PR_TRUE);\n+        _PR_SLEEPQ_UNLOCK(pq->thr->cpu);\n+\n+        if (pq->thr->flags & _PR_SUSPENDING) {\n+          /*\n+           * set thread state to SUSPENDED;\n+           * a Resume operation on the thread\n+           * will move it to the runQ\n+           */\n+          pq->thr->state = _PR_SUSPENDED;\n+          _PR_MISCQ_LOCK(pq->thr->cpu);\n+          _PR_ADD_SUSPENDQ(pq->thr, pq->thr->cpu);\n+          _PR_MISCQ_UNLOCK(pq->thr->cpu);\n         } else {\n-            if (pq->timeout < _PR_IOQ_TIMEOUT(me->cpu)) {\n-                _PR_IOQ_TIMEOUT(me->cpu) = pq->timeout;\n-            }\n-            if (_PR_IOQ_MAX_OSFD(me->cpu) < pq_max_osfd) {\n-                _PR_IOQ_MAX_OSFD(me->cpu) = pq_max_osfd;\n-            }\n+          pri = pq->thr->priority;\n+          pq->thr->state = _PR_RUNNABLE;\n+\n+          _PR_RUNQ_LOCK(cpu);\n+          _PR_ADD_RUNQ(pq->thr, cpu, pri);\n+          _PR_RUNQ_UNLOCK(cpu);\n         }\n+      }\n+      _PR_THREAD_UNLOCK(pq->thr);\n+    } else {\n+      if (pq->timeout < _PR_IOQ_TIMEOUT(me->cpu)) {\n+        _PR_IOQ_TIMEOUT(me->cpu) = pq->timeout;\n+      }\n+      if (_PR_IOQ_MAX_OSFD(me->cpu) < pq_max_osfd) {\n+        _PR_IOQ_MAX_OSFD(me->cpu) = pq_max_osfd;\n+      }\n     }\n-    if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {\n-        if (_PR_IOQ_MAX_OSFD(me->cpu) < _pr_md_pipefd[0]) {\n-            _PR_IOQ_MAX_OSFD(me->cpu) = _pr_md_pipefd[0];\n-        }\n+  }\n+  if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {\n+    if (_PR_IOQ_MAX_OSFD(me->cpu) < _pr_md_pipefd[0]) {\n+      _PR_IOQ_MAX_OSFD(me->cpu) = _pr_md_pipefd[0];\n     }\n+  }\n }\n-#endif /* !defined(_PR_USE_POLL) */\n+#  endif /* !defined(_PR_USE_POLL) */\n \n /************************************************************************/\n \n@@ -1474,811 +1401,769 @@ FindBadFDs(void)\n **\n ** This must be called with the scheduler locked\n */\n-void\n-_MD_PauseCPU(PRIntervalTime ticks)\n-{\n-    PRThread* me = _MD_CURRENT_THREAD();\n-#ifdef _PR_USE_POLL\n-    int timeout;\n-    struct pollfd* pollfds;   /* an array of pollfd structures */\n-    struct pollfd* pollfdPtr; /* a pointer that steps through the array */\n-    unsigned long npollfds;   /* number of pollfd structures in array */\n-    unsigned long pollfds_size;\n-    int nfd; /* to hold the return value of poll() */\n-#else\n-    struct timeval timeout, *tvp;\n-    fd_set r, w, e;\n-    fd_set *rp, *wp, *ep;\n-    PRInt32 max_osfd, nfd;\n-#endif /* _PR_USE_POLL */\n-    PRInt32 rv;\n-    PRCList* q;\n-    PRUint32 min_timeout;\n-    sigset_t oldset;\n-\n-    PR_ASSERT(_PR_MD_GET_INTSOFF() != 0);\n-\n-    _PR_MD_IOQ_LOCK();\n-\n-#ifdef _PR_USE_POLL\n-    /* Build up the pollfd structure array to wait on */\n-\n-    /* Find out how many pollfd structures are needed */\n-    npollfds = _PR_IOQ_OSFD_CNT(me->cpu);\n-    PR_ASSERT(npollfds >= 0);\n-\n-    /*\n-     * We use a pipe to wake up a native thread.  An fd is needed\n-     * for the pipe and we poll it for reading.\n-     */\n-    if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {\n-        npollfds++;\n-    }\n-\n-    /*\n-     * if the cpu's pollfd array is not big enough, release it and allocate a new\n-     * one\n-     */\n-    if (npollfds > _PR_IOQ_POLLFDS_SIZE(me->cpu)) {\n-        if (_PR_IOQ_POLLFDS(me->cpu) != NULL) {\n-            PR_DELETE(_PR_IOQ_POLLFDS(me->cpu));\n-        }\n-        pollfds_size = PR_MAX(_PR_IOQ_MIN_POLLFDS_SIZE(me->cpu), npollfds);\n-        pollfds = (struct pollfd*)PR_MALLOC(pollfds_size * sizeof(struct pollfd));\n-        _PR_IOQ_POLLFDS(me->cpu) = pollfds;\n-        _PR_IOQ_POLLFDS_SIZE(me->cpu) = pollfds_size;\n-    } else {\n-        pollfds = _PR_IOQ_POLLFDS(me->cpu);\n-    }\n+void _MD_PauseCPU(PRIntervalTime ticks) {\n+  PRThread* me = _MD_CURRENT_THREAD();\n+#  ifdef _PR_USE_POLL\n+  int timeout;\n+  struct pollfd* pollfds;   /* an array of pollfd structures */\n+  struct pollfd* pollfdPtr; /* a pointer that steps through the array */\n+  unsigned long npollfds;   /* number of pollfd structures in array */\n+  unsigned long pollfds_size;\n+  int nfd; /* to hold the return value of poll() */\n+#  else\n+  struct timeval timeout, *tvp;\n+  fd_set r, w, e;\n+  fd_set *rp, *wp, *ep;\n+  PRInt32 max_osfd, nfd;\n+#  endif /* _PR_USE_POLL */\n+  PRInt32 rv;\n+  PRCList* q;\n+  PRUint32 min_timeout;\n+  sigset_t oldset;\n+\n+  PR_ASSERT(_PR_MD_GET_INTSOFF() != 0);\n+\n+  _PR_MD_IOQ_LOCK();\n+\n+#  ifdef _PR_USE_POLL\n+  /* Build up the pollfd structure array to wait on */\n+\n+  /* Find out how many pollfd structures are needed */\n+  npollfds = _PR_IOQ_OSFD_CNT(me->cpu);\n+  PR_ASSERT(npollfds >= 0);\n+\n+  /*\n+   * We use a pipe to wake up a native thread.  An fd is needed\n+   * for the pipe and we poll it for reading.\n+   */\n+  if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {\n+    npollfds++;\n+  }\n+\n+  /*\n+   * if the cpu's pollfd array is not big enough, release it and allocate a new\n+   * one\n+   */\n+  if (npollfds > _PR_IOQ_POLLFDS_SIZE(me->cpu)) {\n+    if (_PR_IOQ_POLLFDS(me->cpu) != NULL) {\n+      PR_DELETE(_PR_IOQ_POLLFDS(me->cpu));\n+    }\n+    pollfds_size = PR_MAX(_PR_IOQ_MIN_POLLFDS_SIZE(me->cpu), npollfds);\n+    pollfds = (struct pollfd*)PR_MALLOC(pollfds_size * sizeof(struct pollfd));\n+    _PR_IOQ_POLLFDS(me->cpu) = pollfds;\n+    _PR_IOQ_POLLFDS_SIZE(me->cpu) = pollfds_size;\n+  } else {\n+    pollfds = _PR_IOQ_POLLFDS(me->cpu);\n+  }\n+  pollfdPtr = pollfds;\n+\n+  /*\n+   * If we need to poll the pipe for waking up a native thread,\n+   * the pipe's fd is the first element in the pollfds array.\n+   */\n+  if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {\n+    pollfdPtr->fd = _pr_md_pipefd[0];\n+    pollfdPtr->events = POLLIN;\n+    pollfdPtr++;\n+  }\n+\n+  min_timeout = PR_INTERVAL_NO_TIMEOUT;\n+  for (q = _PR_IOQ(me->cpu).next; q != &_PR_IOQ(me->cpu); q = q->next) {\n+    PRPollQueue* pq = _PR_POLLQUEUE_PTR(q);\n+    _PRUnixPollDesc* pds = pq->pds;\n+    _PRUnixPollDesc* epds = pds + pq->npds;\n+\n+    if (pq->timeout < min_timeout) {\n+      min_timeout = pq->timeout;\n+    }\n+    for (; pds < epds; pds++, pollfdPtr++) {\n+      /*\n+       * Assert that the pollfdPtr pointer does not go\n+       * beyond the end of the pollfds array\n+       */\n+      PR_ASSERT(pollfdPtr < pollfds + npollfds);\n+      pollfdPtr->fd = pds->osfd;\n+      /* direct copy of poll flags */\n+      pollfdPtr->events = pds->in_flags;\n+    }\n+  }\n+  _PR_IOQ_TIMEOUT(me->cpu) = min_timeout;\n+#  else\n+  /*\n+   * assigment of fd_sets\n+   */\n+  r = _PR_FD_READ_SET(me->cpu);\n+  w = _PR_FD_WRITE_SET(me->cpu);\n+  e = _PR_FD_EXCEPTION_SET(me->cpu);\n+\n+  rp = &r;\n+  wp = &w;\n+  ep = &e;\n+\n+  max_osfd = _PR_IOQ_MAX_OSFD(me->cpu) + 1;\n+  min_timeout = _PR_IOQ_TIMEOUT(me->cpu);\n+#  endif /* _PR_USE_POLL */\n+  /*\n+  ** Compute the minimum timeout value: make it the smaller of the\n+  ** timeouts specified by the i/o pollers or the timeout of the first\n+  ** sleeping thread.\n+  */\n+  q = _PR_SLEEPQ(me->cpu).next;\n+\n+  if (q != &_PR_SLEEPQ(me->cpu)) {\n+    PRThread* t = _PR_THREAD_PTR(q);\n+\n+    if (t->sleep < min_timeout) {\n+      min_timeout = t->sleep;\n+    }\n+  }\n+  if (min_timeout > ticks) {\n+    min_timeout = ticks;\n+  }\n+\n+#  ifdef _PR_USE_POLL\n+  if (min_timeout == PR_INTERVAL_NO_TIMEOUT) {\n+    timeout = -1;\n+  } else {\n+    timeout = PR_IntervalToMilliseconds(min_timeout);\n+  }\n+#  else\n+  if (min_timeout == PR_INTERVAL_NO_TIMEOUT) {\n+    tvp = NULL;\n+  } else {\n+    timeout.tv_sec = PR_IntervalToSeconds(min_timeout);\n+    timeout.tv_usec = PR_IntervalToMicroseconds(min_timeout) % PR_USEC_PER_SEC;\n+    tvp = &timeout;\n+  }\n+#  endif /* _PR_USE_POLL */\n+\n+  _PR_MD_IOQ_UNLOCK();\n+  _MD_CHECK_FOR_EXIT();\n+  /*\n+   * check for i/o operations\n+   */\n+#  ifndef _PR_NO_CLOCK_TIMER\n+  /*\n+   * Disable the clock interrupts while we are in select, if clock interrupts\n+   * are enabled. Otherwise, when the select/poll calls are interrupted, the\n+   * timer value starts ticking from zero again when the system call is\n+   * restarted.\n+   */\n+  if (!_nspr_noclock) {\n+    PR_ASSERT(sigismember(&timer_set, SIGALRM));\n+  }\n+  sigprocmask(SIG_BLOCK, &timer_set, &oldset);\n+#  endif /* !_PR_NO_CLOCK_TIMER */\n+\n+#  ifndef _PR_USE_POLL\n+  PR_ASSERT(FD_ISSET(_pr_md_pipefd[0], rp));\n+  nfd = _MD_SELECT(max_osfd, rp, wp, ep, tvp);\n+#  else\n+  nfd = _MD_POLL(pollfds, npollfds, timeout);\n+#  endif /* !_PR_USE_POLL */\n+\n+#  ifndef _PR_NO_CLOCK_TIMER\n+  if (!_nspr_noclock) {\n+    sigprocmask(SIG_SETMASK, &oldset, 0);\n+  }\n+#  endif /* !_PR_NO_CLOCK_TIMER */\n+\n+  _MD_CHECK_FOR_EXIT();\n+\n+  _PR_MD_primordial_cpu();\n+\n+  _PR_MD_IOQ_LOCK();\n+  /*\n+  ** Notify monitors that are associated with the selected descriptors.\n+  */\n+#  ifdef _PR_USE_POLL\n+  if (nfd > 0) {\n     pollfdPtr = pollfds;\n-\n-    /*\n-     * If we need to poll the pipe for waking up a native thread,\n-     * the pipe's fd is the first element in the pollfds array.\n-     */\n     if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {\n-        pollfdPtr->fd = _pr_md_pipefd[0];\n-        pollfdPtr->events = POLLIN;\n-        pollfdPtr++;\n+      /*\n+       * Assert that the pipe is the first element in the\n+       * pollfds array.\n+       */\n+      PR_ASSERT(pollfds[0].fd == _pr_md_pipefd[0]);\n+      if ((pollfds[0].revents & POLLIN) && (nfd == 1)) {\n+        /*\n+         * woken up by another thread; read all the data\n+         * in the pipe to empty the pipe\n+         */\n+        while ((rv = read(_pr_md_pipefd[0], _pr_md_pipebuf, PIPE_BUF)) ==\n+               PIPE_BUF) {\n+        }\n+        PR_ASSERT((rv > 0) || ((rv == -1) && (errno == EAGAIN)));\n+      }\n+      pollfdPtr++;\n     }\n-\n-    min_timeout = PR_INTERVAL_NO_TIMEOUT;\n     for (q = _PR_IOQ(me->cpu).next; q != &_PR_IOQ(me->cpu); q = q->next) {\n-        PRPollQueue* pq = _PR_POLLQUEUE_PTR(q);\n-        _PRUnixPollDesc* pds = pq->pds;\n-        _PRUnixPollDesc* epds = pds + pq->npds;\n+      PRPollQueue* pq = _PR_POLLQUEUE_PTR(q);\n+      PRBool notify = PR_FALSE;\n+      _PRUnixPollDesc* pds = pq->pds;\n+      _PRUnixPollDesc* epds = pds + pq->npds;\n \n-        if (pq->timeout < min_timeout) {\n-            min_timeout = pq->timeout;\n+      for (; pds < epds; pds++, pollfdPtr++) {\n+        /*\n+         * Assert that the pollfdPtr pointer does not go beyond\n+         * the end of the pollfds array.\n+         */\n+        PR_ASSERT(pollfdPtr < pollfds + npollfds);\n+        /*\n+         * Assert that the fd's in the pollfds array (stepped\n+         * through by pollfdPtr) are in the same order as\n+         * the fd's in _PR_IOQ() (stepped through by q and pds).\n+         * This is how the pollfds array was created earlier.\n+         */\n+        PR_ASSERT(pollfdPtr->fd == pds->osfd);\n+        pds->out_flags = pollfdPtr->revents;\n+        /* Negative fd's are ignored by poll() */\n+        if (pds->osfd >= 0 && pds->out_flags) {\n+          notify = PR_TRUE;\n         }\n-        for (; pds < epds; pds++, pollfdPtr++) {\n+      }\n+      if (notify) {\n+        PRIntn pri;\n+        PRThread* thred;\n+\n+        PR_REMOVE_LINK(&pq->links);\n+        pq->on_ioq = PR_FALSE;\n+\n+        thred = pq->thr;\n+        _PR_THREAD_LOCK(thred);\n+        if (pq->thr->flags & (_PR_ON_PAUSEQ | _PR_ON_SLEEPQ)) {\n+          _PRCPU* cpu = pq->thr->cpu;\n+          _PR_SLEEPQ_LOCK(pq->thr->cpu);\n+          _PR_DEL_SLEEPQ(pq->thr, PR_TRUE);\n+          _PR_SLEEPQ_UNLOCK(pq->thr->cpu);\n+\n+          if (pq->thr->flags & _PR_SUSPENDING) {\n             /*\n-             * Assert that the pollfdPtr pointer does not go\n-             * beyond the end of the pollfds array\n+             * set thread state to SUSPENDED;\n+             * a Resume operation on the thread\n+             * will move it to the runQ\n              */\n-            PR_ASSERT(pollfdPtr < pollfds + npollfds);\n-            pollfdPtr->fd = pds->osfd;\n-            /* direct copy of poll flags */\n-            pollfdPtr->events = pds->in_flags;\n-        }\n-    }\n-    _PR_IOQ_TIMEOUT(me->cpu) = min_timeout;\n-#else\n-    /*\n-     * assigment of fd_sets\n-     */\n-    r = _PR_FD_READ_SET(me->cpu);\n-    w = _PR_FD_WRITE_SET(me->cpu);\n-    e = _PR_FD_EXCEPTION_SET(me->cpu);\n-\n-    rp = &r;\n-    wp = &w;\n-    ep = &e;\n-\n-    max_osfd = _PR_IOQ_MAX_OSFD(me->cpu) + 1;\n-    min_timeout = _PR_IOQ_TIMEOUT(me->cpu);\n-#endif /* _PR_USE_POLL */\n-    /*\n-    ** Compute the minimum timeout value: make it the smaller of the\n-    ** timeouts specified by the i/o pollers or the timeout of the first\n-    ** sleeping thread.\n-    */\n-    q = _PR_SLEEPQ(me->cpu).next;\n+            pq->thr->state = _PR_SUSPENDED;\n+            _PR_MISCQ_LOCK(pq->thr->cpu);\n+            _PR_ADD_SUSPENDQ(pq->thr, pq->thr->cpu);\n+            _PR_MISCQ_UNLOCK(pq->thr->cpu);\n+          } else {\n+            pri = pq->thr->priority;\n+            pq->thr->state = _PR_RUNNABLE;\n \n-    if (q != &_PR_SLEEPQ(me->cpu)) {\n-        PRThread* t = _PR_THREAD_PTR(q);\n-\n-        if (t->sleep < min_timeout) {\n-            min_timeout = t->sleep;\n-        }\n-    }\n-    if (min_timeout > ticks) {\n-        min_timeout = ticks;\n-    }\n-\n-#ifdef _PR_USE_POLL\n-    if (min_timeout == PR_INTERVAL_NO_TIMEOUT) {\n-        timeout = -1;\n-    } else {\n-        timeout = PR_IntervalToMilliseconds(min_timeout);\n-    }\n-#else\n-    if (min_timeout == PR_INTERVAL_NO_TIMEOUT) {\n-        tvp = NULL;\n-    } else {\n-        timeout.tv_sec = PR_IntervalToSeconds(min_timeout);\n-        timeout.tv_usec = PR_IntervalToMicroseconds(min_timeout) % PR_USEC_PER_SEC;\n-        tvp = &timeout;\n-    }\n-#endif /* _PR_USE_POLL */\n-\n-    _PR_MD_IOQ_UNLOCK();\n-    _MD_CHECK_FOR_EXIT();\n-    /*\n-     * check for i/o operations\n-     */\n-#ifndef _PR_NO_CLOCK_TIMER\n-    /*\n-     * Disable the clock interrupts while we are in select, if clock interrupts\n-     * are enabled. Otherwise, when the select/poll calls are interrupted, the\n-     * timer value starts ticking from zero again when the system call is\n-     * restarted.\n-     */\n-    if (!_nspr_noclock) {\n-        PR_ASSERT(sigismember(&timer_set, SIGALRM));\n-    }\n-    sigprocmask(SIG_BLOCK, &timer_set, &oldset);\n-#endif /* !_PR_NO_CLOCK_TIMER */\n-\n-#ifndef _PR_USE_POLL\n-    PR_ASSERT(FD_ISSET(_pr_md_pipefd[0], rp));\n-    nfd = _MD_SELECT(max_osfd, rp, wp, ep, tvp);\n-#else\n-    nfd = _MD_POLL(pollfds, npollfds, timeout);\n-#endif /* !_PR_USE_POLL */\n-\n-#ifndef _PR_NO_CLOCK_TIMER\n-    if (!_nspr_noclock) {\n-        sigprocmask(SIG_SETMASK, &oldset, 0);\n-    }\n-#endif /* !_PR_NO_CLOCK_TIMER */\n-\n-    _MD_CHECK_FOR_EXIT();\n-\n-    _PR_MD_primordial_cpu();\n-\n-    _PR_MD_IOQ_LOCK();\n-    /*\n-    ** Notify monitors that are associated with the selected descriptors.\n-    */\n-#ifdef _PR_USE_POLL\n-    if (nfd > 0) {\n-        pollfdPtr = pollfds;\n-        if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {\n-            /*\n-             * Assert that the pipe is the first element in the\n-             * pollfds array.\n-             */\n-            PR_ASSERT(pollfds[0].fd == _pr_md_pipefd[0]);\n-            if ((pollfds[0].revents & POLLIN) && (nfd == 1)) {\n-                /*\n-                 * woken up by another thread; read all the data\n-                 * in the pipe to empty the pipe\n-                 */\n-                while ((rv = read(_pr_md_pipefd[0], _pr_md_pipebuf, PIPE_BUF)) ==\n-                       PIPE_BUF) {\n-                }\n-                PR_ASSERT((rv > 0) || ((rv == -1) && (errno == EAGAIN)));\n-            }\n-            pollfdPtr++;\n-        }\n-        for (q = _PR_IOQ(me->cpu).next; q != &_PR_IOQ(me->cpu); q = q->next) {\n-            PRPollQueue* pq = _PR_POLLQUEUE_PTR(q);\n-            PRBool notify = PR_FALSE;\n-            _PRUnixPollDesc* pds = pq->pds;\n-            _PRUnixPollDesc* epds = pds + pq->npds;\n-\n-            for (; pds < epds; pds++, pollfdPtr++) {\n-                /*\n-                 * Assert that the pollfdPtr pointer does not go beyond\n-                 * the end of the pollfds array.\n-                 */\n-                PR_ASSERT(pollfdPtr < pollfds + npollfds);\n-                /*\n-                 * Assert that the fd's in the pollfds array (stepped\n-                 * through by pollfdPtr) are in the same order as\n-                 * the fd's in _PR_IOQ() (stepped through by q and pds).\n-                 * This is how the pollfds array was created earlier.\n-                 */\n-                PR_ASSERT(pollfdPtr->fd == pds->osfd);\n-                pds->out_flags = pollfdPtr->revents;\n-                /* Negative fd's are ignored by poll() */\n-                if (pds->osfd >= 0 && pds->out_flags) {\n-                    notify = PR_TRUE;\n-                }\n-            }\n-            if (notify) {\n-                PRIntn pri;\n-                PRThread* thred;\n-\n-                PR_REMOVE_LINK(&pq->links);\n-                pq->on_ioq = PR_FALSE;\n-\n-                thred = pq->thr;\n-                _PR_THREAD_LOCK(thred);\n-                if (pq->thr->flags & (_PR_ON_PAUSEQ | _PR_ON_SLEEPQ)) {\n-                    _PRCPU* cpu = pq->thr->cpu;\n-                    _PR_SLEEPQ_LOCK(pq->thr->cpu);\n-                    _PR_DEL_SLEEPQ(pq->thr, PR_TRUE);\n-                    _PR_SLEEPQ_UNLOCK(pq->thr->cpu);\n-\n-                    if (pq->thr->flags & _PR_SUSPENDING) {\n-                        /*\n-                         * set thread state to SUSPENDED;\n-                         * a Resume operation on the thread\n-                         * will move it to the runQ\n-                         */\n-                        pq->thr->state = _PR_SUSPENDED;\n-                        _PR_MISCQ_LOCK(pq->thr->cpu);\n-                        _PR_ADD_SUSPENDQ(pq->thr, pq->thr->cpu);\n-                        _PR_MISCQ_UNLOCK(pq->thr->cpu);\n-                    } else {\n-                        pri = pq->thr->priority;\n-                        pq->thr->state = _PR_RUNNABLE;\n-\n-                        _PR_RUNQ_LOCK(cpu);\n-                        _PR_ADD_RUNQ(pq->thr, cpu, pri);\n-                        _PR_RUNQ_UNLOCK(cpu);\n-                        if (_pr_md_idle_cpus > 1) {\n-                            _PR_MD_WAKEUP_WAITER(thred);\n-                        }\n-                    }\n-                }\n-                _PR_THREAD_UNLOCK(thred);\n-                _PR_IOQ_OSFD_CNT(me->cpu) -= pq->npds;\n-                PR_ASSERT(_PR_IOQ_OSFD_CNT(me->cpu) >= 0);\n+            _PR_RUNQ_LOCK(cpu);\n+            _PR_ADD_RUNQ(pq->thr, cpu, pri);\n+            _PR_RUNQ_UNLOCK(cpu);\n+            if (_pr_md_idle_cpus > 1) {\n+              _PR_MD_WAKEUP_WAITER(thred);\n             }\n+          }\n         }\n-    } else if (nfd == -1) {\n-        PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"poll() failed with errno %d\", errno));\n-    }\n-\n-#else\n-    if (nfd > 0) {\n-        q = _PR_IOQ(me->cpu).next;\n-        _PR_IOQ_MAX_OSFD(me->cpu) = -1;\n-        _PR_IOQ_TIMEOUT(me->cpu) = PR_INTERVAL_NO_TIMEOUT;\n-        while (q != &_PR_IOQ(me->cpu)) {\n-            PRPollQueue* pq = _PR_POLLQUEUE_PTR(q);\n-            PRBool notify = PR_FALSE;\n-            _PRUnixPollDesc* pds = pq->pds;\n-            _PRUnixPollDesc* epds = pds + pq->npds;\n-            PRInt32 pq_max_osfd = -1;\n-\n-            q = q->next;\n-            for (; pds < epds; pds++) {\n-                PRInt32 osfd = pds->osfd;\n-                PRInt16 in_flags = pds->in_flags;\n-                PRInt16 out_flags = 0;\n-                PR_ASSERT(osfd >= 0 || in_flags == 0);\n-                if ((in_flags & _PR_UNIX_POLL_READ) && FD_ISSET(osfd, rp)) {\n-                    out_flags |= _PR_UNIX_POLL_READ;\n-                }\n-                if ((in_flags & _PR_UNIX_POLL_WRITE) && FD_ISSET(osfd, wp)) {\n-                    out_flags |= _PR_UNIX_POLL_WRITE;\n-                }\n-                if ((in_flags & _PR_UNIX_POLL_EXCEPT) && FD_ISSET(osfd, ep)) {\n-                    out_flags |= _PR_UNIX_POLL_EXCEPT;\n-                }\n-                pds->out_flags = out_flags;\n-                if (out_flags) {\n-                    notify = PR_TRUE;\n-                }\n-                if (osfd > pq_max_osfd) {\n-                    pq_max_osfd = osfd;\n-                }\n-            }\n-            if (notify == PR_TRUE) {\n-                PRIntn pri;\n-                PRThread* thred;\n-\n-                PR_REMOVE_LINK(&pq->links);\n-                pq->on_ioq = PR_FALSE;\n-\n-                /*\n-                 * Decrement the count of descriptors for each desciptor/event\n-                 * because this I/O request is being removed from the\n-                 * ioq\n-                 */\n-                pds = pq->pds;\n-                for (; pds < epds; pds++) {\n-                    PRInt32 osfd = pds->osfd;\n-                    PRInt16 in_flags = pds->in_flags;\n-                    PR_ASSERT(osfd >= 0 || in_flags == 0);\n-                    if (in_flags & _PR_UNIX_POLL_READ) {\n-                        if (--(_PR_FD_READ_CNT(me->cpu))[osfd] == 0) {\n-                            FD_CLR(osfd, &_PR_FD_READ_SET(me->cpu));\n-                        }\n-                    }\n-                    if (in_flags & _PR_UNIX_POLL_WRITE) {\n-                        if (--(_PR_FD_WRITE_CNT(me->cpu))[osfd] == 0) {\n-                            FD_CLR(osfd, &_PR_FD_WRITE_SET(me->cpu));\n-                        }\n-                    }\n-                    if (in_flags & _PR_UNIX_POLL_EXCEPT) {\n-                        if (--(_PR_FD_EXCEPTION_CNT(me->cpu))[osfd] == 0) {\n-                            FD_CLR(osfd, &_PR_FD_EXCEPTION_SET(me->cpu));\n-                        }\n-                    }\n-                }\n-\n-                /*\n-                 * Because this thread can run on a different cpu right\n-                 * after being added to the run queue, do not dereference\n-                 * pq\n-                 */\n-                thred = pq->thr;\n-                _PR_THREAD_LOCK(thred);\n-                if (pq->thr->flags & (_PR_ON_PAUSEQ | _PR_ON_SLEEPQ)) {\n-                    _PRCPU* cpu = thred->cpu;\n-                    _PR_SLEEPQ_LOCK(pq->thr->cpu);\n-                    _PR_DEL_SLEEPQ(pq->thr, PR_TRUE);\n-                    _PR_SLEEPQ_UNLOCK(pq->thr->cpu);\n-\n-                    if (pq->thr->flags & _PR_SUSPENDING) {\n-                        /*\n-                         * set thread state to SUSPENDED;\n-                         * a Resume operation on the thread\n-                         * will move it to the runQ\n-                         */\n-                        pq->thr->state = _PR_SUSPENDED;\n-                        _PR_MISCQ_LOCK(pq->thr->cpu);\n-                        _PR_ADD_SUSPENDQ(pq->thr, pq->thr->cpu);\n-                        _PR_MISCQ_UNLOCK(pq->thr->cpu);\n-                    } else {\n-                        pri = pq->thr->priority;\n-                        pq->thr->state = _PR_RUNNABLE;\n-\n-                        pq->thr->cpu = cpu;\n-                        _PR_RUNQ_LOCK(cpu);\n-                        _PR_ADD_RUNQ(pq->thr, cpu, pri);\n-                        _PR_RUNQ_UNLOCK(cpu);\n-                        if (_pr_md_idle_cpus > 1) {\n-                            _PR_MD_WAKEUP_WAITER(thred);\n-                        }\n-                    }\n-                }\n-                _PR_THREAD_UNLOCK(thred);\n-            } else {\n-                if (pq->timeout < _PR_IOQ_TIMEOUT(me->cpu)) {\n-                    _PR_IOQ_TIMEOUT(me->cpu) = pq->timeout;\n-                }\n-                if (_PR_IOQ_MAX_OSFD(me->cpu) < pq_max_osfd) {\n-                    _PR_IOQ_MAX_OSFD(me->cpu) = pq_max_osfd;\n-                }\n-            }\n+        _PR_THREAD_UNLOCK(thred);\n+        _PR_IOQ_OSFD_CNT(me->cpu) -= pq->npds;\n+        PR_ASSERT(_PR_IOQ_OSFD_CNT(me->cpu) >= 0);\n+      }\n+    }\n+  } else if (nfd == -1) {\n+    PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"poll() failed with errno %d\", errno));\n+  }\n+\n+#  else\n+  if (nfd > 0) {\n+    q = _PR_IOQ(me->cpu).next;\n+    _PR_IOQ_MAX_OSFD(me->cpu) = -1;\n+    _PR_IOQ_TIMEOUT(me->cpu) = PR_INTERVAL_NO_TIMEOUT;\n+    while (q != &_PR_IOQ(me->cpu)) {\n+      PRPollQueue* pq = _PR_POLLQUEUE_PTR(q);\n+      PRBool notify = PR_FALSE;\n+      _PRUnixPollDesc* pds = pq->pds;\n+      _PRUnixPollDesc* epds = pds + pq->npds;\n+      PRInt32 pq_max_osfd = -1;\n+\n+      q = q->next;\n+      for (; pds < epds; pds++) {\n+        PRInt32 osfd = pds->osfd;\n+        PRInt16 in_flags = pds->in_flags;\n+        PRInt16 out_flags = 0;\n+        PR_ASSERT(osfd >= 0 || in_flags == 0);\n+        if ((in_flags & _PR_UNIX_POLL_READ) && FD_ISSET(osfd, rp)) {\n+          out_flags |= _PR_UNIX_POLL_READ;\n         }\n-        if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {\n-            if ((FD_ISSET(_pr_md_pipefd[0], rp)) && (nfd == 1)) {\n-                /*\n-                 * woken up by another thread; read all the data\n-                 * in the pipe to empty the pipe\n-                 */\n-                while ((rv = read(_pr_md_pipefd[0], _pr_md_pipebuf, PIPE_BUF)) ==\n-                       PIPE_BUF) {\n-                }\n-                PR_ASSERT((rv > 0) || ((rv == -1) && (errno == EAGAIN)));\n-            }\n-            if (_PR_IOQ_MAX_OSFD(me->cpu) < _pr_md_pipefd[0]) {\n-                _PR_IOQ_MAX_OSFD(me->cpu) = _pr_md_pipefd[0];\n-            }\n+        if ((in_flags & _PR_UNIX_POLL_WRITE) && FD_ISSET(osfd, wp)) {\n+          out_flags |= _PR_UNIX_POLL_WRITE;\n         }\n-    } else if (nfd < 0) {\n-        if (errno == EBADF) {\n-            FindBadFDs();\n-        } else {\n-            PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"select() failed with errno %d\", errno));\n+        if ((in_flags & _PR_UNIX_POLL_EXCEPT) && FD_ISSET(osfd, ep)) {\n+          out_flags |= _PR_UNIX_POLL_EXCEPT;\n         }\n-    } else {\n-        PR_ASSERT(nfd == 0);\n+        pds->out_flags = out_flags;\n+        if (out_flags) {\n+          notify = PR_TRUE;\n+        }\n+        if (osfd > pq_max_osfd) {\n+          pq_max_osfd = osfd;\n+        }\n+      }\n+      if (notify == PR_TRUE) {\n+        PRIntn pri;\n+        PRThread* thred;\n+\n+        PR_REMOVE_LINK(&pq->links);\n+        pq->on_ioq = PR_FALSE;\n+\n         /*\n-         * compute the new value of _PR_IOQ_TIMEOUT\n+         * Decrement the count of descriptors for each desciptor/event\n+         * because this I/O request is being removed from the\n+         * ioq\n          */\n-        q = _PR_IOQ(me->cpu).next;\n-        _PR_IOQ_MAX_OSFD(me->cpu) = -1;\n-        _PR_IOQ_TIMEOUT(me->cpu) = PR_INTERVAL_NO_TIMEOUT;\n-        while (q != &_PR_IOQ(me->cpu)) {\n-            PRPollQueue* pq = _PR_POLLQUEUE_PTR(q);\n-            _PRUnixPollDesc* pds = pq->pds;\n-            _PRUnixPollDesc* epds = pds + pq->npds;\n-            PRInt32 pq_max_osfd = -1;\n-\n-            q = q->next;\n-            for (; pds < epds; pds++) {\n-                if (pds->osfd > pq_max_osfd) {\n-                    pq_max_osfd = pds->osfd;\n-                }\n+        pds = pq->pds;\n+        for (; pds < epds; pds++) {\n+          PRInt32 osfd = pds->osfd;\n+          PRInt16 in_flags = pds->in_flags;\n+          PR_ASSERT(osfd >= 0 || in_flags == 0);\n+          if (in_flags & _PR_UNIX_POLL_READ) {\n+            if (--(_PR_FD_READ_CNT(me->cpu))[osfd] == 0) {\n+              FD_CLR(osfd, &_PR_FD_READ_SET(me->cpu));\n             }\n-            if (pq->timeout < _PR_IOQ_TIMEOUT(me->cpu)) {\n-                _PR_IOQ_TIMEOUT(me->cpu) = pq->timeout;\n+          }\n+          if (in_flags & _PR_UNIX_POLL_WRITE) {\n+            if (--(_PR_FD_WRITE_CNT(me->cpu))[osfd] == 0) {\n+              FD_CLR(osfd, &_PR_FD_WRITE_SET(me->cpu));\n             }\n-            if (_PR_IOQ_MAX_OSFD(me->cpu) < pq_max_osfd) {\n-                _PR_IOQ_MAX_OSFD(me->cpu) = pq_max_osfd;\n+          }\n+          if (in_flags & _PR_UNIX_POLL_EXCEPT) {\n+            if (--(_PR_FD_EXCEPTION_CNT(me->cpu))[osfd] == 0) {\n+              FD_CLR(osfd, &_PR_FD_EXCEPTION_SET(me->cpu));\n             }\n+          }\n         }\n-        if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {\n-            if (_PR_IOQ_MAX_OSFD(me->cpu) < _pr_md_pipefd[0]) {\n-                _PR_IOQ_MAX_OSFD(me->cpu) = _pr_md_pipefd[0];\n+\n+        /*\n+         * Because this thread can run on a different cpu right\n+         * after being added to the run queue, do not dereference\n+         * pq\n+         */\n+        thred = pq->thr;\n+        _PR_THREAD_LOCK(thred);\n+        if (pq->thr->flags & (_PR_ON_PAUSEQ | _PR_ON_SLEEPQ)) {\n+          _PRCPU* cpu = thred->cpu;\n+          _PR_SLEEPQ_LOCK(pq->thr->cpu);\n+          _PR_DEL_SLEEPQ(pq->thr, PR_TRUE);\n+          _PR_SLEEPQ_UNLOCK(pq->thr->cpu);\n+\n+          if (pq->thr->flags & _PR_SUSPENDING) {\n+            /*\n+             * set thread state to SUSPENDED;\n+             * a Resume operation on the thread\n+             * will move it to the runQ\n+             */\n+            pq->thr->state = _PR_SUSPENDED;\n+            _PR_MISCQ_LOCK(pq->thr->cpu);\n+            _PR_ADD_SUSPENDQ(pq->thr, pq->thr->cpu);\n+            _PR_MISCQ_UNLOCK(pq->thr->cpu);\n+          } else {\n+            pri = pq->thr->priority;\n+            pq->thr->state = _PR_RUNNABLE;\n+\n+            pq->thr->cpu = cpu;\n+            _PR_RUNQ_LOCK(cpu);\n+            _PR_ADD_RUNQ(pq->thr, cpu, pri);\n+            _PR_RUNQ_UNLOCK(cpu);\n+            if (_pr_md_idle_cpus > 1) {\n+              _PR_MD_WAKEUP_WAITER(thred);\n             }\n+          }\n+        }\n+        _PR_THREAD_UNLOCK(thred);\n+      } else {\n+        if (pq->timeout < _PR_IOQ_TIMEOUT(me->cpu)) {\n+          _PR_IOQ_TIMEOUT(me->cpu) = pq->timeout;\n+        }\n+        if (_PR_IOQ_MAX_OSFD(me->cpu) < pq_max_osfd) {\n+          _PR_IOQ_MAX_OSFD(me->cpu) = pq_max_osfd;\n         }\n+      }\n     }\n-#endif /* _PR_USE_POLL */\n-    _PR_MD_IOQ_UNLOCK();\n-}\n-\n-void\n-_MD_Wakeup_CPUs()\n-{\n-    PRInt32 rv, data;\n-\n-    data = 0;\n-    rv = write(_pr_md_pipefd[1], &data, 1);\n-\n-    while ((rv < 0) && (errno == EAGAIN)) {\n+    if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {\n+      if ((FD_ISSET(_pr_md_pipefd[0], rp)) && (nfd == 1)) {\n         /*\n-         * pipe full, read all data in pipe to empty it\n+         * woken up by another thread; read all the data\n+         * in the pipe to empty the pipe\n          */\n         while ((rv = read(_pr_md_pipefd[0], _pr_md_pipebuf, PIPE_BUF)) ==\n                PIPE_BUF) {\n         }\n         PR_ASSERT((rv > 0) || ((rv == -1) && (errno == EAGAIN)));\n-        rv = write(_pr_md_pipefd[1], &data, 1);\n-    }\n-}\n-\n-void\n-_MD_InitCPUS()\n-{\n-    PRInt32 rv, flags;\n-    PRThread* me = _MD_CURRENT_THREAD();\n-\n-    rv = pipe(_pr_md_pipefd);\n-    PR_ASSERT(rv == 0);\n-    _PR_IOQ_MAX_OSFD(me->cpu) = _pr_md_pipefd[0];\n-#ifndef _PR_USE_POLL\n-    FD_SET(_pr_md_pipefd[0], &_PR_FD_READ_SET(me->cpu));\n-#endif\n-\n-    flags = fcntl(_pr_md_pipefd[0], F_GETFL, 0);\n-    fcntl(_pr_md_pipefd[0], F_SETFL, flags | O_NONBLOCK);\n-    flags = fcntl(_pr_md_pipefd[1], F_GETFL, 0);\n-    fcntl(_pr_md_pipefd[1], F_SETFL, flags | O_NONBLOCK);\n-}\n-\n-/*\n-** Unix SIGALRM (clock) signal handler\n-*/\n-static void\n-ClockInterruptHandler()\n-{\n-    int olderrno;\n-    PRUintn pri;\n-    _PRCPU* cpu = _PR_MD_CURRENT_CPU();\n-    PRThread* me = _MD_CURRENT_THREAD();\n-\n-#ifdef SOLARIS\n-    if (!me || _PR_IS_NATIVE_THREAD(me)) {\n-        _pr_primordialCPU->u.missed[_pr_primordialCPU->where] |= _PR_MISSED_CLOCK;\n-        return;\n-    }\n-#endif\n-\n-    if (_PR_MD_GET_INTSOFF() != 0) {\n-        cpu->u.missed[cpu->where] |= _PR_MISSED_CLOCK;\n-        return;\n-    }\n-    _PR_MD_SET_INTSOFF(1);\n-\n-    olderrno = errno;\n-    _PR_ClockInterrupt();\n-    errno = olderrno;\n-\n-    /*\n-    ** If the interrupt wants a resched or if some other thread at\n-    ** the same priority needs the cpu, reschedule.\n-    */\n-    pri = me->priority;\n-    if ((cpu->u.missed[3] || (_PR_RUNQREADYMASK(me->cpu) >> pri))) {\n-#ifdef _PR_NO_PREEMPT\n-        cpu->resched = PR_TRUE;\n-        if (pr_interruptSwitchHook) {\n-            (*pr_interruptSwitchHook)(pr_interruptSwitchHookArg);\n-        }\n-#else  /* _PR_NO_PREEMPT */\n-        /*\n-        ** Re-enable unix interrupts (so that we can use\n-        ** setjmp/longjmp for context switching without having to\n-        ** worry about the signal state)\n-        */\n-        sigprocmask(SIG_SETMASK, &empty_set, 0);\n-        PR_LOG(_pr_sched_lm, PR_LOG_MIN, (\"clock caused context switch\"));\n-\n-        if (!(me->flags & _PR_IDLE_THREAD)) {\n-            _PR_THREAD_LOCK(me);\n-            me->state = _PR_RUNNABLE;\n-            me->cpu = cpu;\n-            _PR_RUNQ_LOCK(cpu);\n-            _PR_ADD_RUNQ(me, cpu, pri);\n-            _PR_RUNQ_UNLOCK(cpu);\n-            _PR_THREAD_UNLOCK(me);\n-        } else {\n-            me->state = _PR_RUNNABLE;\n-        }\n-        _MD_SWITCH_CONTEXT(me);\n-        PR_LOG(_pr_sched_lm, PR_LOG_MIN, (\"clock back from context switch\"));\n-#endif /* _PR_NO_PREEMPT */\n+      }\n+      if (_PR_IOQ_MAX_OSFD(me->cpu) < _pr_md_pipefd[0]) {\n+        _PR_IOQ_MAX_OSFD(me->cpu) = _pr_md_pipefd[0];\n+      }\n+    }\n+  } else if (nfd < 0) {\n+    if (errno == EBADF) {\n+      FindBadFDs();\n+    } else {\n+      PR_LOG(_pr_io_lm, PR_LOG_MAX, (\"select() failed with errno %d\", errno));\n     }\n+  } else {\n+    PR_ASSERT(nfd == 0);\n     /*\n-     * Because this thread could be running on a different cpu after\n-     * a context switch the current cpu should be accessed and the\n-     * value of the 'cpu' variable should not be used.\n+     * compute the new value of _PR_IOQ_TIMEOUT\n      */\n-    _PR_MD_SET_INTSOFF(0);\n-}\n-\n-/* # of milliseconds per clock tick that we will use */\n-#define MSEC_PER_TICK 50\n-\n-void\n-_MD_StartInterrupts()\n-{\n-    char* eval;\n-\n-    if ((eval = getenv(\"NSPR_NOCLOCK\")) != NULL) {\n-        if (atoi(eval) == 0) {\n-            _nspr_noclock = 0;\n-        } else {\n-            _nspr_noclock = 1;\n+    q = _PR_IOQ(me->cpu).next;\n+    _PR_IOQ_MAX_OSFD(me->cpu) = -1;\n+    _PR_IOQ_TIMEOUT(me->cpu) = PR_INTERVAL_NO_TIMEOUT;\n+    while (q != &_PR_IOQ(me->cpu)) {\n+      PRPollQueue* pq = _PR_POLLQUEUE_PTR(q);\n+      _PRUnixPollDesc* pds = pq->pds;\n+      _PRUnixPollDesc* epds = pds + pq->npds;\n+      PRInt32 pq_max_osfd = -1;\n+\n+      q = q->next;\n+      for (; pds < epds; pds++) {\n+        if (pds->osfd > pq_max_osfd) {\n+          pq_max_osfd = pds->osfd;\n         }\n+      }\n+      if (pq->timeout < _PR_IOQ_TIMEOUT(me->cpu)) {\n+        _PR_IOQ_TIMEOUT(me->cpu) = pq->timeout;\n+      }\n+      if (_PR_IOQ_MAX_OSFD(me->cpu) < pq_max_osfd) {\n+        _PR_IOQ_MAX_OSFD(me->cpu) = pq_max_osfd;\n+      }\n     }\n-\n-#ifndef _PR_NO_CLOCK_TIMER\n-    if (!_nspr_noclock) {\n-        _MD_EnableClockInterrupts();\n+    if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {\n+      if (_PR_IOQ_MAX_OSFD(me->cpu) < _pr_md_pipefd[0]) {\n+        _PR_IOQ_MAX_OSFD(me->cpu) = _pr_md_pipefd[0];\n+      }\n     }\n-#endif\n-}\n-\n-void\n-_MD_StopInterrupts()\n-{\n-    sigprocmask(SIG_BLOCK, &timer_set, 0);\n-}\n-\n-void\n-_MD_EnableClockInterrupts()\n-{\n-    struct itimerval itval;\n-    extern PRUintn _pr_numCPU;\n-    struct sigaction vtact;\n-\n-    vtact.sa_handler = (void (*)())ClockInterruptHandler;\n-    sigemptyset(&vtact.sa_mask);\n-    vtact.sa_flags = SA_RESTART;\n-    sigaction(SIGALRM, &vtact, 0);\n-\n-    PR_ASSERT(_pr_numCPU == 1);\n-    itval.it_interval.tv_sec = 0;\n-    itval.it_interval.tv_usec = MSEC_PER_TICK * PR_USEC_PER_MSEC;\n-    itval.it_value = itval.it_interval;\n-    setitimer(ITIMER_REAL, &itval, 0);\n-}\n-\n-void\n-_MD_DisableClockInterrupts()\n-{\n-    struct itimerval itval;\n-    extern PRUintn _pr_numCPU;\n-\n-    PR_ASSERT(_pr_numCPU == 1);\n-    itval.it_interval.tv_sec = 0;\n-    itval.it_interval.tv_usec = 0;\n-    itval.it_value = itval.it_interval;\n-    setitimer(ITIMER_REAL, &itval, 0);\n-}\n-\n-void\n-_MD_BlockClockInterrupts()\n-{\n-    sigprocmask(SIG_BLOCK, &timer_set, 0);\n-}\n-\n-void\n-_MD_UnblockClockInterrupts()\n-{\n-    sigprocmask(SIG_UNBLOCK, &timer_set, 0);\n+  }\n+#  endif /* _PR_USE_POLL */\n+  _PR_MD_IOQ_UNLOCK();\n }\n \n-void\n-_MD_MakeNonblock(PRFileDesc* fd)\n-{\n-    PRInt32 osfd = fd->secret->md.osfd;\n-    int flags;\n+void _MD_Wakeup_CPUs() {\n+  PRInt32 rv, data;\n \n-    if (osfd <= 2) {\n-        /* Don't mess around with stdin, stdout or stderr */\n-        return;\n-    }\n-    flags = fcntl(osfd, F_GETFL, 0);\n+  data = 0;\n+  rv = write(_pr_md_pipefd[1], &data, 1);\n \n+  while ((rv < 0) && (errno == EAGAIN)) {\n     /*\n-     * Use O_NONBLOCK (POSIX-style non-blocking I/O) whenever possible.\n-     * On SunOS 4, we must use FNDELAY (BSD-style non-blocking I/O),\n-     * otherwise connect() still blocks and can be interrupted by SIGALRM.\n+     * pipe full, read all data in pipe to empty it\n      */\n-\n-    fcntl(osfd, F_SETFL, flags | O_NONBLOCK);\n+    while ((rv = read(_pr_md_pipefd[0], _pr_md_pipebuf, PIPE_BUF)) ==\n+           PIPE_BUF) {\n+    }\n+    PR_ASSERT((rv > 0) || ((rv == -1) && (errno == EAGAIN)));\n+    rv = write(_pr_md_pipefd[1], &data, 1);\n+  }\n }\n \n-PRInt32\n-_MD_open(const char* name, PRIntn flags, PRIntn mode)\n-{\n-    PRInt32 osflags;\n-    PRInt32 rv, err;\n+void _MD_InitCPUS() {\n+  PRInt32 rv, flags;\n+  PRThread* me = _MD_CURRENT_THREAD();\n \n-    if (flags & PR_RDWR) {\n-        osflags = O_RDWR;\n-    } else if (flags & PR_WRONLY) {\n-        osflags = O_WRONLY;\n-    } else {\n-        osflags = O_RDONLY;\n-    }\n+  rv = pipe(_pr_md_pipefd);\n+  PR_ASSERT(rv == 0);\n+  _PR_IOQ_MAX_OSFD(me->cpu) = _pr_md_pipefd[0];\n+#  ifndef _PR_USE_POLL\n+  FD_SET(_pr_md_pipefd[0], &_PR_FD_READ_SET(me->cpu));\n+#  endif\n \n-    if (flags & PR_EXCL) {\n-        osflags |= O_EXCL;\n-    }\n-    if (flags & PR_APPEND) {\n-        osflags |= O_APPEND;\n-    }\n-    if (flags & PR_TRUNCATE) {\n-        osflags |= O_TRUNC;\n-    }\n-    if (flags & PR_SYNC) {\n-#if defined(O_SYNC)\n-        osflags |= O_SYNC;\n-#elif defined(O_FSYNC)\n-        osflags |= O_FSYNC;\n-#else\n-#error \"Neither O_SYNC nor O_FSYNC is defined on this platform\"\n-#endif\n-    }\n+  flags = fcntl(_pr_md_pipefd[0], F_GETFL, 0);\n+  fcntl(_pr_md_pipefd[0], F_SETFL, flags | O_NONBLOCK);\n+  flags = fcntl(_pr_md_pipefd[1], F_GETFL, 0);\n+  fcntl(_pr_md_pipefd[1], F_SETFL, flags | O_NONBLOCK);\n+}\n \n+/*\n+** Unix SIGALRM (clock) signal handler\n+*/\n+static void ClockInterruptHandler() {\n+  int olderrno;\n+  PRUintn pri;\n+  _PRCPU* cpu = _PR_MD_CURRENT_CPU();\n+  PRThread* me = _MD_CURRENT_THREAD();\n+\n+#  ifdef SOLARIS\n+  if (!me || _PR_IS_NATIVE_THREAD(me)) {\n+    _pr_primordialCPU->u.missed[_pr_primordialCPU->where] |= _PR_MISSED_CLOCK;\n+    return;\n+  }\n+#  endif\n+\n+  if (_PR_MD_GET_INTSOFF() != 0) {\n+    cpu->u.missed[cpu->where] |= _PR_MISSED_CLOCK;\n+    return;\n+  }\n+  _PR_MD_SET_INTSOFF(1);\n+\n+  olderrno = errno;\n+  _PR_ClockInterrupt();\n+  errno = olderrno;\n+\n+  /*\n+  ** If the interrupt wants a resched or if some other thread at\n+  ** the same priority needs the cpu, reschedule.\n+  */\n+  pri = me->priority;\n+  if ((cpu->u.missed[3] || (_PR_RUNQREADYMASK(me->cpu) >> pri))) {\n+#  ifdef _PR_NO_PREEMPT\n+    cpu->resched = PR_TRUE;\n+    if (pr_interruptSwitchHook) {\n+      (*pr_interruptSwitchHook)(pr_interruptSwitchHookArg);\n+    }\n+#  else  /* _PR_NO_PREEMPT */\n     /*\n-    ** On creations we hold the 'create' lock in order to enforce\n-    ** the semantics of PR_Rename. (see the latter for more details)\n+    ** Re-enable unix interrupts (so that we can use\n+    ** setjmp/longjmp for context switching without having to\n+    ** worry about the signal state)\n     */\n-    if (flags & PR_CREATE_FILE) {\n-        osflags |= O_CREAT;\n-        if (NULL != _pr_unix_rename_lock) {\n-            PR_Lock(_pr_unix_rename_lock);\n-        }\n+    sigprocmask(SIG_SETMASK, &empty_set, 0);\n+    PR_LOG(_pr_sched_lm, PR_LOG_MIN, (\"clock caused context switch\"));\n+\n+    if (!(me->flags & _PR_IDLE_THREAD)) {\n+      _PR_THREAD_LOCK(me);\n+      me->state = _PR_RUNNABLE;\n+      me->cpu = cpu;\n+      _PR_RUNQ_LOCK(cpu);\n+      _PR_ADD_RUNQ(me, cpu, pri);\n+      _PR_RUNQ_UNLOCK(cpu);\n+      _PR_THREAD_UNLOCK(me);\n+    } else {\n+      me->state = _PR_RUNNABLE;\n     }\n+    _MD_SWITCH_CONTEXT(me);\n+    PR_LOG(_pr_sched_lm, PR_LOG_MIN, (\"clock back from context switch\"));\n+#  endif /* _PR_NO_PREEMPT */\n+  }\n+  /*\n+   * Because this thread could be running on a different cpu after\n+   * a context switch the current cpu should be accessed and the\n+   * value of the 'cpu' variable should not be used.\n+   */\n+  _PR_MD_SET_INTSOFF(0);\n+}\n \n-#if defined(ANDROID)\n-    osflags |= O_LARGEFILE;\n-#endif\n-\n-    rv = _md_iovector._open64(name, osflags, mode);\n+/* # of milliseconds per clock tick that we will use */\n+#  define MSEC_PER_TICK 50\n \n-    if (rv < 0) {\n-        err = _MD_ERRNO();\n-        _PR_MD_MAP_OPEN_ERROR(err);\n-    }\n+void _MD_StartInterrupts() {\n+  char* eval;\n \n-    if ((flags & PR_CREATE_FILE) && (NULL != _pr_unix_rename_lock)) {\n-        PR_Unlock(_pr_unix_rename_lock);\n+  if ((eval = getenv(\"NSPR_NOCLOCK\")) != NULL) {\n+    if (atoi(eval) == 0) {\n+      _nspr_noclock = 0;\n+    } else {\n+      _nspr_noclock = 1;\n+    }\n+  }\n+\n+#  ifndef _PR_NO_CLOCK_TIMER\n+  if (!_nspr_noclock) {\n+    _MD_EnableClockInterrupts();\n+  }\n+#  endif\n+}\n+\n+void _MD_StopInterrupts() { sigprocmask(SIG_BLOCK, &timer_set, 0); }\n+\n+void _MD_EnableClockInterrupts() {\n+  struct itimerval itval;\n+  extern PRUintn _pr_numCPU;\n+  struct sigaction vtact;\n+\n+  vtact.sa_handler = (void (*)())ClockInterruptHandler;\n+  sigemptyset(&vtact.sa_mask);\n+  vtact.sa_flags = SA_RESTART;\n+  sigaction(SIGALRM, &vtact, 0);\n+\n+  PR_ASSERT(_pr_numCPU == 1);\n+  itval.it_interval.tv_sec = 0;\n+  itval.it_interval.tv_usec = MSEC_PER_TICK * PR_USEC_PER_MSEC;\n+  itval.it_value = itval.it_interval;\n+  setitimer(ITIMER_REAL, &itval, 0);\n+}\n+\n+void _MD_DisableClockInterrupts() {\n+  struct itimerval itval;\n+  extern PRUintn _pr_numCPU;\n+\n+  PR_ASSERT(_pr_numCPU == 1);\n+  itval.it_interval.tv_sec = 0;\n+  itval.it_interval.tv_usec = 0;\n+  itval.it_value = itval.it_interval;\n+  setitimer(ITIMER_REAL, &itval, 0);\n+}\n+\n+void _MD_BlockClockInterrupts() { sigprocmask(SIG_BLOCK, &timer_set, 0); }\n+\n+void _MD_UnblockClockInterrupts() { sigprocmask(SIG_UNBLOCK, &timer_set, 0); }\n+\n+void _MD_MakeNonblock(PRFileDesc* fd) {\n+  PRInt32 osfd = fd->secret->md.osfd;\n+  int flags;\n+\n+  if (osfd <= 2) {\n+    /* Don't mess around with stdin, stdout or stderr */\n+    return;\n+  }\n+  flags = fcntl(osfd, F_GETFL, 0);\n+\n+  /*\n+   * Use O_NONBLOCK (POSIX-style non-blocking I/O) whenever possible.\n+   * On SunOS 4, we must use FNDELAY (BSD-style non-blocking I/O),\n+   * otherwise connect() still blocks and can be interrupted by SIGALRM.\n+   */\n+\n+  fcntl(osfd, F_SETFL, flags | O_NONBLOCK);\n+}\n+\n+PRInt32 _MD_open(const char* name, PRIntn flags, PRIntn mode) {\n+  PRInt32 osflags;\n+  PRInt32 rv, err;\n+\n+  if (flags & PR_RDWR) {\n+    osflags = O_RDWR;\n+  } else if (flags & PR_WRONLY) {\n+    osflags = O_WRONLY;\n+  } else {\n+    osflags = O_RDONLY;\n+  }\n+\n+  if (flags & PR_EXCL) {\n+    osflags |= O_EXCL;\n+  }\n+  if (flags & PR_APPEND) {\n+    osflags |= O_APPEND;\n+  }\n+  if (flags & PR_TRUNCATE) {\n+    osflags |= O_TRUNC;\n+  }\n+  if (flags & PR_SYNC) {\n+#  if defined(O_SYNC)\n+    osflags |= O_SYNC;\n+#  elif defined(O_FSYNC)\n+    osflags |= O_FSYNC;\n+#  else\n+#    error \"Neither O_SYNC nor O_FSYNC is defined on this platform\"\n+#  endif\n+  }\n+\n+  /*\n+  ** On creations we hold the 'create' lock in order to enforce\n+  ** the semantics of PR_Rename. (see the latter for more details)\n+  */\n+  if (flags & PR_CREATE_FILE) {\n+    osflags |= O_CREAT;\n+    if (NULL != _pr_unix_rename_lock) {\n+      PR_Lock(_pr_unix_rename_lock);\n     }\n-    return rv;\n-}\n+  }\n \n-PRIntervalTime intr_timeout_ticks;\n+#  if defined(ANDROID)\n+  osflags |= O_LARGEFILE;\n+#  endif\n \n-#if defined(SOLARIS)\n-static void\n-sigsegvhandler()\n-{\n-    fprintf(stderr, \"Received SIGSEGV\\n\");\n-    fflush(stderr);\n-    pause();\n-}\n+  rv = _md_iovector._open64(name, osflags, mode);\n \n-static void\n-sigaborthandler()\n-{\n-    fprintf(stderr, \"Received SIGABRT\\n\");\n-    fflush(stderr);\n-    pause();\n-}\n+  if (rv < 0) {\n+    err = _MD_ERRNO();\n+    _PR_MD_MAP_OPEN_ERROR(err);\n+  }\n \n-static void\n-sigbushandler()\n-{\n-    fprintf(stderr, \"Received SIGBUS\\n\");\n-    fflush(stderr);\n-    pause();\n+  if ((flags & PR_CREATE_FILE) && (NULL != _pr_unix_rename_lock)) {\n+    PR_Unlock(_pr_unix_rename_lock);\n+  }\n+  return rv;\n }\n-#endif /* SOLARIS */\n \n-#endif /* !defined(_PR_PTHREADS) */\n-\n-void\n-_MD_query_fd_inheritable(PRFileDesc* fd)\n-{\n-    int flags;\n+PRIntervalTime intr_timeout_ticks;\n \n-    PR_ASSERT(_PR_TRI_UNKNOWN == fd->secret->inheritable);\n-    flags = fcntl(fd->secret->md.osfd, F_GETFD, 0);\n-    PR_ASSERT(-1 != flags);\n-    fd->secret->inheritable = (flags & FD_CLOEXEC) ? _PR_TRI_FALSE : _PR_TRI_TRUE;\n+#  if defined(SOLARIS)\n+static void sigsegvhandler() {\n+  fprintf(stderr, \"Received SIGSEGV\\n\");\n+  fflush(stderr);\n+  pause();\n }\n \n-PROffset32\n-_MD_lseek(PRFileDesc* fd, PROffset32 offset, PRSeekWhence whence)\n-{\n-    PROffset32 rv, where;\n-\n-    switch (whence) {\n-        case PR_SEEK_SET:\n-            where = SEEK_SET;\n-            break;\n-        case PR_SEEK_CUR:\n-            where = SEEK_CUR;\n-            break;\n-        case PR_SEEK_END:\n-            where = SEEK_END;\n-            break;\n-        default:\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            rv = -1;\n-            goto done;\n-    }\n-    rv = lseek(fd->secret->md.osfd, offset, where);\n-    if (rv == -1) {\n-        PRInt32 syserr = _MD_ERRNO();\n-        _PR_MD_MAP_LSEEK_ERROR(syserr);\n-    }\n-done:\n-    return (rv);\n+static void sigaborthandler() {\n+  fprintf(stderr, \"Received SIGABRT\\n\");\n+  fflush(stderr);\n+  pause();\n }\n \n-PROffset64\n-_MD_lseek64(PRFileDesc* fd, PROffset64 offset, PRSeekWhence whence)\n-{\n-    PRInt32 where;\n-    PROffset64 rv;\n+static void sigbushandler() {\n+  fprintf(stderr, \"Received SIGBUS\\n\");\n+  fflush(stderr);\n+  pause();\n+}\n+#  endif /* SOLARIS */\n \n-    switch (whence) {\n-        case PR_SEEK_SET:\n-            where = SEEK_SET;\n-            break;\n-        case PR_SEEK_CUR:\n-            where = SEEK_CUR;\n-            break;\n-        case PR_SEEK_END:\n-            where = SEEK_END;\n-            break;\n-        default:\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            rv = minus_one;\n-            goto done;\n-    }\n-    rv = _md_iovector._lseek64(fd->secret->md.osfd, offset, where);\n-    if (LL_EQ(rv, minus_one)) {\n-        PRInt32 syserr = _MD_ERRNO();\n-        _PR_MD_MAP_LSEEK_ERROR(syserr);\n-    }\n+#endif /* !defined(_PR_PTHREADS) */\n+\n+void _MD_query_fd_inheritable(PRFileDesc* fd) {\n+  int flags;\n+\n+  PR_ASSERT(_PR_TRI_UNKNOWN == fd->secret->inheritable);\n+  flags = fcntl(fd->secret->md.osfd, F_GETFD, 0);\n+  PR_ASSERT(-1 != flags);\n+  fd->secret->inheritable = (flags & FD_CLOEXEC) ? _PR_TRI_FALSE : _PR_TRI_TRUE;\n+}\n+\n+PROffset32 _MD_lseek(PRFileDesc* fd, PROffset32 offset, PRSeekWhence whence) {\n+  PROffset32 rv, where;\n+\n+  switch (whence) {\n+    case PR_SEEK_SET:\n+      where = SEEK_SET;\n+      break;\n+    case PR_SEEK_CUR:\n+      where = SEEK_CUR;\n+      break;\n+    case PR_SEEK_END:\n+      where = SEEK_END;\n+      break;\n+    default:\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      rv = -1;\n+      goto done;\n+  }\n+  rv = lseek(fd->secret->md.osfd, offset, where);\n+  if (rv == -1) {\n+    PRInt32 syserr = _MD_ERRNO();\n+    _PR_MD_MAP_LSEEK_ERROR(syserr);\n+  }\n done:\n-    return rv;\n+  return (rv);\n+}\n+\n+PROffset64 _MD_lseek64(PRFileDesc* fd, PROffset64 offset, PRSeekWhence whence) {\n+  PRInt32 where;\n+  PROffset64 rv;\n+\n+  switch (whence) {\n+    case PR_SEEK_SET:\n+      where = SEEK_SET;\n+      break;\n+    case PR_SEEK_CUR:\n+      where = SEEK_CUR;\n+      break;\n+    case PR_SEEK_END:\n+      where = SEEK_END;\n+      break;\n+    default:\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      rv = minus_one;\n+      goto done;\n+  }\n+  rv = _md_iovector._lseek64(fd->secret->md.osfd, offset, where);\n+  if (LL_EQ(rv, minus_one)) {\n+    PRInt32 syserr = _MD_ERRNO();\n+    _PR_MD_MAP_LSEEK_ERROR(syserr);\n+  }\n+done:\n+  return rv;\n } /* _MD_lseek64 */\n \n /*\n@@ -2296,274 +2181,242 @@ done:\n ** struct stat has st_atim, st_mtim, and st_ctim fields of\n ** type timestruc_t.\n */\n-static void\n-_MD_set_fileinfo_times(const struct stat* sb, PRFileInfo* info)\n-{\n-    PRInt64 us, s2us;\n-\n-    LL_I2L(s2us, PR_USEC_PER_SEC);\n-    LL_I2L(info->modifyTime, sb->st_mtim.tv_sec);\n-    LL_MUL(info->modifyTime, info->modifyTime, s2us);\n-    LL_I2L(us, sb->st_mtim.tv_nsec / 1000);\n-    LL_ADD(info->modifyTime, info->modifyTime, us);\n-    LL_I2L(info->creationTime, sb->st_ctim.tv_sec);\n-    LL_MUL(info->creationTime, info->creationTime, s2us);\n-    LL_I2L(us, sb->st_ctim.tv_nsec / 1000);\n-    LL_ADD(info->creationTime, info->creationTime, us);\n-}\n-\n-static void\n-_MD_set_fileinfo64_times(const _MDStat64* sb, PRFileInfo64* info)\n-{\n-    PRInt64 us, s2us;\n-\n-    LL_I2L(s2us, PR_USEC_PER_SEC);\n-    LL_I2L(info->modifyTime, sb->st_mtim.tv_sec);\n-    LL_MUL(info->modifyTime, info->modifyTime, s2us);\n-    LL_I2L(us, sb->st_mtim.tv_nsec / 1000);\n-    LL_ADD(info->modifyTime, info->modifyTime, us);\n-    LL_I2L(info->creationTime, sb->st_ctim.tv_sec);\n-    LL_MUL(info->creationTime, info->creationTime, s2us);\n-    LL_I2L(us, sb->st_ctim.tv_nsec / 1000);\n-    LL_ADD(info->creationTime, info->creationTime, us);\n+static void _MD_set_fileinfo_times(const struct stat* sb, PRFileInfo* info) {\n+  PRInt64 us, s2us;\n+\n+  LL_I2L(s2us, PR_USEC_PER_SEC);\n+  LL_I2L(info->modifyTime, sb->st_mtim.tv_sec);\n+  LL_MUL(info->modifyTime, info->modifyTime, s2us);\n+  LL_I2L(us, sb->st_mtim.tv_nsec / 1000);\n+  LL_ADD(info->modifyTime, info->modifyTime, us);\n+  LL_I2L(info->creationTime, sb->st_ctim.tv_sec);\n+  LL_MUL(info->creationTime, info->creationTime, s2us);\n+  LL_I2L(us, sb->st_ctim.tv_nsec / 1000);\n+  LL_ADD(info->creationTime, info->creationTime, us);\n+}\n+\n+static void _MD_set_fileinfo64_times(const _MDStat64* sb, PRFileInfo64* info) {\n+  PRInt64 us, s2us;\n+\n+  LL_I2L(s2us, PR_USEC_PER_SEC);\n+  LL_I2L(info->modifyTime, sb->st_mtim.tv_sec);\n+  LL_MUL(info->modifyTime, info->modifyTime, s2us);\n+  LL_I2L(us, sb->st_mtim.tv_nsec / 1000);\n+  LL_ADD(info->modifyTime, info->modifyTime, us);\n+  LL_I2L(info->creationTime, sb->st_ctim.tv_sec);\n+  LL_MUL(info->creationTime, info->creationTime, s2us);\n+  LL_I2L(us, sb->st_ctim.tv_nsec / 1000);\n+  LL_ADD(info->creationTime, info->creationTime, us);\n }\n #elif defined(_PR_STAT_HAS_ST_ATIM_UNION)\n /*\n ** The st_atim, st_mtim, and st_ctim fields in struct stat are\n ** unions with a st__tim union member of type timestruc_t.\n */\n-static void\n-_MD_set_fileinfo_times(const struct stat* sb, PRFileInfo* info)\n-{\n-    PRInt64 us, s2us;\n-\n-    LL_I2L(s2us, PR_USEC_PER_SEC);\n-    LL_I2L(info->modifyTime, sb->st_mtim.st__tim.tv_sec);\n-    LL_MUL(info->modifyTime, info->modifyTime, s2us);\n-    LL_I2L(us, sb->st_mtim.st__tim.tv_nsec / 1000);\n-    LL_ADD(info->modifyTime, info->modifyTime, us);\n-    LL_I2L(info->creationTime, sb->st_ctim.st__tim.tv_sec);\n-    LL_MUL(info->creationTime, info->creationTime, s2us);\n-    LL_I2L(us, sb->st_ctim.st__tim.tv_nsec / 1000);\n-    LL_ADD(info->creationTime, info->creationTime, us);\n-}\n-\n-static void\n-_MD_set_fileinfo64_times(const _MDStat64* sb, PRFileInfo64* info)\n-{\n-    PRInt64 us, s2us;\n-\n-    LL_I2L(s2us, PR_USEC_PER_SEC);\n-    LL_I2L(info->modifyTime, sb->st_mtim.st__tim.tv_sec);\n-    LL_MUL(info->modifyTime, info->modifyTime, s2us);\n-    LL_I2L(us, sb->st_mtim.st__tim.tv_nsec / 1000);\n-    LL_ADD(info->modifyTime, info->modifyTime, us);\n-    LL_I2L(info->creationTime, sb->st_ctim.st__tim.tv_sec);\n-    LL_MUL(info->creationTime, info->creationTime, s2us);\n-    LL_I2L(us, sb->st_ctim.st__tim.tv_nsec / 1000);\n-    LL_ADD(info->creationTime, info->creationTime, us);\n+static void _MD_set_fileinfo_times(const struct stat* sb, PRFileInfo* info) {\n+  PRInt64 us, s2us;\n+\n+  LL_I2L(s2us, PR_USEC_PER_SEC);\n+  LL_I2L(info->modifyTime, sb->st_mtim.st__tim.tv_sec);\n+  LL_MUL(info->modifyTime, info->modifyTime, s2us);\n+  LL_I2L(us, sb->st_mtim.st__tim.tv_nsec / 1000);\n+  LL_ADD(info->modifyTime, info->modifyTime, us);\n+  LL_I2L(info->creationTime, sb->st_ctim.st__tim.tv_sec);\n+  LL_MUL(info->creationTime, info->creationTime, s2us);\n+  LL_I2L(us, sb->st_ctim.st__tim.tv_nsec / 1000);\n+  LL_ADD(info->creationTime, info->creationTime, us);\n+}\n+\n+static void _MD_set_fileinfo64_times(const _MDStat64* sb, PRFileInfo64* info) {\n+  PRInt64 us, s2us;\n+\n+  LL_I2L(s2us, PR_USEC_PER_SEC);\n+  LL_I2L(info->modifyTime, sb->st_mtim.st__tim.tv_sec);\n+  LL_MUL(info->modifyTime, info->modifyTime, s2us);\n+  LL_I2L(us, sb->st_mtim.st__tim.tv_nsec / 1000);\n+  LL_ADD(info->modifyTime, info->modifyTime, us);\n+  LL_I2L(info->creationTime, sb->st_ctim.st__tim.tv_sec);\n+  LL_MUL(info->creationTime, info->creationTime, s2us);\n+  LL_I2L(us, sb->st_ctim.st__tim.tv_nsec / 1000);\n+  LL_ADD(info->creationTime, info->creationTime, us);\n }\n #elif defined(_PR_STAT_HAS_ST_ATIMESPEC)\n /*\n ** struct stat has st_atimespec, st_mtimespec, and st_ctimespec\n ** fields of type struct timespec.\n */\n-#if defined(_PR_TIMESPEC_HAS_TS_SEC)\n-static void\n-_MD_set_fileinfo_times(const struct stat* sb, PRFileInfo* info)\n-{\n-    PRInt64 us, s2us;\n-\n-    LL_I2L(s2us, PR_USEC_PER_SEC);\n-    LL_I2L(info->modifyTime, sb->st_mtimespec.ts_sec);\n-    LL_MUL(info->modifyTime, info->modifyTime, s2us);\n-    LL_I2L(us, sb->st_mtimespec.ts_nsec / 1000);\n-    LL_ADD(info->modifyTime, info->modifyTime, us);\n-    LL_I2L(info->creationTime, sb->st_ctimespec.ts_sec);\n-    LL_MUL(info->creationTime, info->creationTime, s2us);\n-    LL_I2L(us, sb->st_ctimespec.ts_nsec / 1000);\n-    LL_ADD(info->creationTime, info->creationTime, us);\n-}\n-\n-static void\n-_MD_set_fileinfo64_times(const _MDStat64* sb, PRFileInfo64* info)\n-{\n-    PRInt64 us, s2us;\n-\n-    LL_I2L(s2us, PR_USEC_PER_SEC);\n-    LL_I2L(info->modifyTime, sb->st_mtimespec.ts_sec);\n-    LL_MUL(info->modifyTime, info->modifyTime, s2us);\n-    LL_I2L(us, sb->st_mtimespec.ts_nsec / 1000);\n-    LL_ADD(info->modifyTime, info->modifyTime, us);\n-    LL_I2L(info->creationTime, sb->st_ctimespec.ts_sec);\n-    LL_MUL(info->creationTime, info->creationTime, s2us);\n-    LL_I2L(us, sb->st_ctimespec.ts_nsec / 1000);\n-    LL_ADD(info->creationTime, info->creationTime, us);\n-}\n-#else  /* _PR_TIMESPEC_HAS_TS_SEC */\n+#  if defined(_PR_TIMESPEC_HAS_TS_SEC)\n+static void _MD_set_fileinfo_times(const struct stat* sb, PRFileInfo* info) {\n+  PRInt64 us, s2us;\n+\n+  LL_I2L(s2us, PR_USEC_PER_SEC);\n+  LL_I2L(info->modifyTime, sb->st_mtimespec.ts_sec);\n+  LL_MUL(info->modifyTime, info->modifyTime, s2us);\n+  LL_I2L(us, sb->st_mtimespec.ts_nsec / 1000);\n+  LL_ADD(info->modifyTime, info->modifyTime, us);\n+  LL_I2L(info->creationTime, sb->st_ctimespec.ts_sec);\n+  LL_MUL(info->creationTime, info->creationTime, s2us);\n+  LL_I2L(us, sb->st_ctimespec.ts_nsec / 1000);\n+  LL_ADD(info->creationTime, info->creationTime, us);\n+}\n+\n+static void _MD_set_fileinfo64_times(const _MDStat64* sb, PRFileInfo64* info) {\n+  PRInt64 us, s2us;\n+\n+  LL_I2L(s2us, PR_USEC_PER_SEC);\n+  LL_I2L(info->modifyTime, sb->st_mtimespec.ts_sec);\n+  LL_MUL(info->modifyTime, info->modifyTime, s2us);\n+  LL_I2L(us, sb->st_mtimespec.ts_nsec / 1000);\n+  LL_ADD(info->modifyTime, info->modifyTime, us);\n+  LL_I2L(info->creationTime, sb->st_ctimespec.ts_sec);\n+  LL_MUL(info->creationTime, info->creationTime, s2us);\n+  LL_I2L(us, sb->st_ctimespec.ts_nsec / 1000);\n+  LL_ADD(info->creationTime, info->creationTime, us);\n+}\n+#  else  /* _PR_TIMESPEC_HAS_TS_SEC */\n /*\n ** The POSIX timespec structure has tv_sec and tv_nsec.\n */\n-static void\n-_MD_set_fileinfo_times(const struct stat* sb, PRFileInfo* info)\n-{\n-    PRInt64 us, s2us;\n-\n-    LL_I2L(s2us, PR_USEC_PER_SEC);\n-    LL_I2L(info->modifyTime, sb->st_mtimespec.tv_sec);\n-    LL_MUL(info->modifyTime, info->modifyTime, s2us);\n-    LL_I2L(us, sb->st_mtimespec.tv_nsec / 1000);\n-    LL_ADD(info->modifyTime, info->modifyTime, us);\n-    LL_I2L(info->creationTime, sb->st_ctimespec.tv_sec);\n-    LL_MUL(info->creationTime, info->creationTime, s2us);\n-    LL_I2L(us, sb->st_ctimespec.tv_nsec / 1000);\n-    LL_ADD(info->creationTime, info->creationTime, us);\n-}\n-\n-static void\n-_MD_set_fileinfo64_times(const _MDStat64* sb, PRFileInfo64* info)\n-{\n-    PRInt64 us, s2us;\n-\n-    LL_I2L(s2us, PR_USEC_PER_SEC);\n-    LL_I2L(info->modifyTime, sb->st_mtimespec.tv_sec);\n-    LL_MUL(info->modifyTime, info->modifyTime, s2us);\n-    LL_I2L(us, sb->st_mtimespec.tv_nsec / 1000);\n-    LL_ADD(info->modifyTime, info->modifyTime, us);\n-    LL_I2L(info->creationTime, sb->st_ctimespec.tv_sec);\n-    LL_MUL(info->creationTime, info->creationTime, s2us);\n-    LL_I2L(us, sb->st_ctimespec.tv_nsec / 1000);\n-    LL_ADD(info->creationTime, info->creationTime, us);\n-}\n-#endif /* _PR_TIMESPEC_HAS_TS_SEC */\n+static void _MD_set_fileinfo_times(const struct stat* sb, PRFileInfo* info) {\n+  PRInt64 us, s2us;\n+\n+  LL_I2L(s2us, PR_USEC_PER_SEC);\n+  LL_I2L(info->modifyTime, sb->st_mtimespec.tv_sec);\n+  LL_MUL(info->modifyTime, info->modifyTime, s2us);\n+  LL_I2L(us, sb->st_mtimespec.tv_nsec / 1000);\n+  LL_ADD(info->modifyTime, info->modifyTime, us);\n+  LL_I2L(info->creationTime, sb->st_ctimespec.tv_sec);\n+  LL_MUL(info->creationTime, info->creationTime, s2us);\n+  LL_I2L(us, sb->st_ctimespec.tv_nsec / 1000);\n+  LL_ADD(info->creationTime, info->creationTime, us);\n+}\n+\n+static void _MD_set_fileinfo64_times(const _MDStat64* sb, PRFileInfo64* info) {\n+  PRInt64 us, s2us;\n+\n+  LL_I2L(s2us, PR_USEC_PER_SEC);\n+  LL_I2L(info->modifyTime, sb->st_mtimespec.tv_sec);\n+  LL_MUL(info->modifyTime, info->modifyTime, s2us);\n+  LL_I2L(us, sb->st_mtimespec.tv_nsec / 1000);\n+  LL_ADD(info->modifyTime, info->modifyTime, us);\n+  LL_I2L(info->creationTime, sb->st_ctimespec.tv_sec);\n+  LL_MUL(info->creationTime, info->creationTime, s2us);\n+  LL_I2L(us, sb->st_ctimespec.tv_nsec / 1000);\n+  LL_ADD(info->creationTime, info->creationTime, us);\n+}\n+#  endif /* _PR_TIMESPEC_HAS_TS_SEC */\n #elif defined(_PR_STAT_HAS_ONLY_ST_ATIME)\n /*\n ** struct stat only has st_atime, st_mtime, and st_ctime fields\n ** of type time_t.\n */\n-static void\n-_MD_set_fileinfo_times(const struct stat* sb, PRFileInfo* info)\n-{\n-    PRInt64 s, s2us;\n-    LL_I2L(s2us, PR_USEC_PER_SEC);\n-    LL_I2L(s, sb->st_mtime);\n-    LL_MUL(s, s, s2us);\n-    info->modifyTime = s;\n-    LL_I2L(s, sb->st_ctime);\n-    LL_MUL(s, s, s2us);\n-    info->creationTime = s;\n-}\n-\n-static void\n-_MD_set_fileinfo64_times(const _MDStat64* sb, PRFileInfo64* info)\n-{\n-    PRInt64 s, s2us;\n-    LL_I2L(s2us, PR_USEC_PER_SEC);\n-    LL_I2L(s, sb->st_mtime);\n-    LL_MUL(s, s, s2us);\n-    info->modifyTime = s;\n-    LL_I2L(s, sb->st_ctime);\n-    LL_MUL(s, s, s2us);\n-    info->creationTime = s;\n+static void _MD_set_fileinfo_times(const struct stat* sb, PRFileInfo* info) {\n+  PRInt64 s, s2us;\n+  LL_I2L(s2us, PR_USEC_PER_SEC);\n+  LL_I2L(s, sb->st_mtime);\n+  LL_MUL(s, s, s2us);\n+  info->modifyTime = s;\n+  LL_I2L(s, sb->st_ctime);\n+  LL_MUL(s, s, s2us);\n+  info->creationTime = s;\n+}\n+\n+static void _MD_set_fileinfo64_times(const _MDStat64* sb, PRFileInfo64* info) {\n+  PRInt64 s, s2us;\n+  LL_I2L(s2us, PR_USEC_PER_SEC);\n+  LL_I2L(s, sb->st_mtime);\n+  LL_MUL(s, s, s2us);\n+  info->modifyTime = s;\n+  LL_I2L(s, sb->st_ctime);\n+  LL_MUL(s, s, s2us);\n+  info->creationTime = s;\n }\n #else\n-#error \"I don't know yet\"\n+#  error \"I don't know yet\"\n #endif\n \n-static int\n-_MD_convert_stat_to_fileinfo(const struct stat* sb,\n-                             PRFileInfo* info)\n-{\n-    if (S_IFREG & sb->st_mode) {\n-        info->type = PR_FILE_FILE;\n-    } else if (S_IFDIR & sb->st_mode) {\n-        info->type = PR_FILE_DIRECTORY;\n-    } else {\n-        info->type = PR_FILE_OTHER;\n-    }\n+static int _MD_convert_stat_to_fileinfo(const struct stat* sb,\n+                                        PRFileInfo* info) {\n+  if (S_IFREG & sb->st_mode) {\n+    info->type = PR_FILE_FILE;\n+  } else if (S_IFDIR & sb->st_mode) {\n+    info->type = PR_FILE_DIRECTORY;\n+  } else {\n+    info->type = PR_FILE_OTHER;\n+  }\n \n #if defined(_PR_HAVE_LARGE_OFF_T)\n-    if (0x7fffffffL < sb->st_size) {\n-        PR_SetError(PR_FILE_TOO_BIG_ERROR, 0);\n-        return -1;\n-    }\n+  if (0x7fffffffL < sb->st_size) {\n+    PR_SetError(PR_FILE_TOO_BIG_ERROR, 0);\n+    return -1;\n+  }\n #endif /* defined(_PR_HAVE_LARGE_OFF_T) */\n-    info->size = sb->st_size;\n+  info->size = sb->st_size;\n \n-    _MD_set_fileinfo_times(sb, info);\n-    return 0;\n+  _MD_set_fileinfo_times(sb, info);\n+  return 0;\n } /* _MD_convert_stat_to_fileinfo */\n \n-static int\n-_MD_convert_stat64_to_fileinfo64(const _MDStat64* sb,\n-                                 PRFileInfo64* info)\n-{\n-    if (S_IFREG & sb->st_mode) {\n-        info->type = PR_FILE_FILE;\n-    } else if (S_IFDIR & sb->st_mode) {\n-        info->type = PR_FILE_DIRECTORY;\n-    } else {\n-        info->type = PR_FILE_OTHER;\n-    }\n+static int _MD_convert_stat64_to_fileinfo64(const _MDStat64* sb,\n+                                            PRFileInfo64* info) {\n+  if (S_IFREG & sb->st_mode) {\n+    info->type = PR_FILE_FILE;\n+  } else if (S_IFDIR & sb->st_mode) {\n+    info->type = PR_FILE_DIRECTORY;\n+  } else {\n+    info->type = PR_FILE_OTHER;\n+  }\n \n-    LL_I2L(info->size, sb->st_size);\n+  LL_I2L(info->size, sb->st_size);\n \n-    _MD_set_fileinfo64_times(sb, info);\n-    return 0;\n+  _MD_set_fileinfo64_times(sb, info);\n+  return 0;\n } /* _MD_convert_stat64_to_fileinfo64 */\n \n-PRInt32\n-_MD_getfileinfo(const char* fn, PRFileInfo* info)\n-{\n-    PRInt32 rv;\n-    struct stat sb;\n-\n-    rv = stat(fn, &sb);\n-    if (rv < 0) {\n-        _PR_MD_MAP_STAT_ERROR(_MD_ERRNO());\n-    } else if (NULL != info) {\n-        rv = _MD_convert_stat_to_fileinfo(&sb, info);\n-    }\n-    return rv;\n-}\n-\n-PRInt32\n-_MD_getfileinfo64(const char* fn, PRFileInfo64* info)\n-{\n-    _MDStat64 sb;\n-    PRInt32 rv = _md_iovector._stat64(fn, &sb);\n-    if (rv < 0) {\n-        _PR_MD_MAP_STAT_ERROR(_MD_ERRNO());\n-    } else if (NULL != info) {\n-        rv = _MD_convert_stat64_to_fileinfo64(&sb, info);\n-    }\n-    return rv;\n-}\n-\n-PRInt32\n-_MD_getopenfileinfo(const PRFileDesc* fd, PRFileInfo* info)\n-{\n-    struct stat sb;\n-    PRInt32 rv = fstat(fd->secret->md.osfd, &sb);\n-    if (rv < 0) {\n-        _PR_MD_MAP_FSTAT_ERROR(_MD_ERRNO());\n-    } else if (NULL != info) {\n-        rv = _MD_convert_stat_to_fileinfo(&sb, info);\n-    }\n-    return rv;\n-}\n-\n-PRInt32\n-_MD_getopenfileinfo64(const PRFileDesc* fd, PRFileInfo64* info)\n-{\n-    _MDStat64 sb;\n-    PRInt32 rv = _md_iovector._fstat64(fd->secret->md.osfd, &sb);\n-    if (rv < 0) {\n-        _PR_MD_MAP_FSTAT_ERROR(_MD_ERRNO());\n-    } else if (NULL != info) {\n-        rv = _MD_convert_stat64_to_fileinfo64(&sb, info);\n-    }\n-    return rv;\n+PRInt32 _MD_getfileinfo(const char* fn, PRFileInfo* info) {\n+  PRInt32 rv;\n+  struct stat sb;\n+\n+  rv = stat(fn, &sb);\n+  if (rv < 0) {\n+    _PR_MD_MAP_STAT_ERROR(_MD_ERRNO());\n+  } else if (NULL != info) {\n+    rv = _MD_convert_stat_to_fileinfo(&sb, info);\n+  }\n+  return rv;\n+}\n+\n+PRInt32 _MD_getfileinfo64(const char* fn, PRFileInfo64* info) {\n+  _MDStat64 sb;\n+  PRInt32 rv = _md_iovector._stat64(fn, &sb);\n+  if (rv < 0) {\n+    _PR_MD_MAP_STAT_ERROR(_MD_ERRNO());\n+  } else if (NULL != info) {\n+    rv = _MD_convert_stat64_to_fileinfo64(&sb, info);\n+  }\n+  return rv;\n+}\n+\n+PRInt32 _MD_getopenfileinfo(const PRFileDesc* fd, PRFileInfo* info) {\n+  struct stat sb;\n+  PRInt32 rv = fstat(fd->secret->md.osfd, &sb);\n+  if (rv < 0) {\n+    _PR_MD_MAP_FSTAT_ERROR(_MD_ERRNO());\n+  } else if (NULL != info) {\n+    rv = _MD_convert_stat_to_fileinfo(&sb, info);\n+  }\n+  return rv;\n+}\n+\n+PRInt32 _MD_getopenfileinfo64(const PRFileDesc* fd, PRFileInfo64* info) {\n+  _MDStat64 sb;\n+  PRInt32 rv = _md_iovector._fstat64(fd->secret->md.osfd, &sb);\n+  if (rv < 0) {\n+    _PR_MD_MAP_FSTAT_ERROR(_MD_ERRNO());\n+  } else if (NULL != info) {\n+    rv = _MD_convert_stat64_to_fileinfo64(&sb, info);\n+  }\n+  return rv;\n }\n \n /*\n@@ -2572,7 +2425,7 @@ _MD_getopenfileinfo64(const PRFileDesc* fd, PRFileInfo64* info)\n  * initialized by _PR_MD_FINAL_INIT.  This means the log file cannot be a\n  * large file on some platforms.\n  */\n-struct _MD_IOVector _md_iovector = { open };\n+struct _MD_IOVector _md_iovector = {open};\n \n /*\n ** These implementations are to emulate large file routines on systems that\n@@ -2584,76 +2437,68 @@ struct _MD_IOVector _md_iovector = { open };\n \n #if defined(SOLARIS2_5)\n \n-static PRIntn\n-_MD_solaris25_fstat64(PRIntn osfd, _MDStat64* buf)\n-{\n-    PRInt32 rv;\n-    struct stat sb;\n+static PRIntn _MD_solaris25_fstat64(PRIntn osfd, _MDStat64* buf) {\n+  PRInt32 rv;\n+  struct stat sb;\n \n-    rv = fstat(osfd, &sb);\n-    if (rv >= 0) {\n-        /*\n-        ** I'm only copying the fields that are immediately needed.\n-        ** If somebody else calls this function, some of the fields\n-        ** may not be defined.\n-        */\n-        (void)memset(buf, 0, sizeof(_MDStat64));\n-        buf->st_mode = sb.st_mode;\n-        buf->st_ctim = sb.st_ctim;\n-        buf->st_mtim = sb.st_mtim;\n-        buf->st_size = sb.st_size;\n-    }\n-    return rv;\n+  rv = fstat(osfd, &sb);\n+  if (rv >= 0) {\n+    /*\n+    ** I'm only copying the fields that are immediately needed.\n+    ** If somebody else calls this function, some of the fields\n+    ** may not be defined.\n+    */\n+    (void)memset(buf, 0, sizeof(_MDStat64));\n+    buf->st_mode = sb.st_mode;\n+    buf->st_ctim = sb.st_ctim;\n+    buf->st_mtim = sb.st_mtim;\n+    buf->st_size = sb.st_size;\n+  }\n+  return rv;\n } /* _MD_solaris25_fstat64 */\n \n-static PRIntn\n-_MD_solaris25_stat64(const char* fn, _MDStat64* buf)\n-{\n-    PRInt32 rv;\n-    struct stat sb;\n+static PRIntn _MD_solaris25_stat64(const char* fn, _MDStat64* buf) {\n+  PRInt32 rv;\n+  struct stat sb;\n \n-    rv = stat(fn, &sb);\n-    if (rv >= 0) {\n-        /*\n-        ** I'm only copying the fields that are immediately needed.\n-        ** If somebody else calls this function, some of the fields\n-        ** may not be defined.\n-        */\n-        (void)memset(buf, 0, sizeof(_MDStat64));\n-        buf->st_mode = sb.st_mode;\n-        buf->st_ctim = sb.st_ctim;\n-        buf->st_mtim = sb.st_mtim;\n-        buf->st_size = sb.st_size;\n-    }\n-    return rv;\n+  rv = stat(fn, &sb);\n+  if (rv >= 0) {\n+    /*\n+    ** I'm only copying the fields that are immediately needed.\n+    ** If somebody else calls this function, some of the fields\n+    ** may not be defined.\n+    */\n+    (void)memset(buf, 0, sizeof(_MDStat64));\n+    buf->st_mode = sb.st_mode;\n+    buf->st_ctim = sb.st_ctim;\n+    buf->st_mtim = sb.st_mtim;\n+    buf->st_size = sb.st_size;\n+  }\n+  return rv;\n } /* _MD_solaris25_stat64 */\n #endif /* defined(SOLARIS2_5) */\n \n #if defined(_PR_NO_LARGE_FILES) || defined(SOLARIS2_5)\n \n-static PROffset64\n-_MD_Unix_lseek64(PRIntn osfd, PROffset64 offset,\n-                 PRIntn whence)\n-{\n-    PRUint64 maxoff;\n-    PROffset64 rv = minus_one;\n-    LL_I2L(maxoff, 0x7fffffff);\n-    if (LL_CMP(offset, <=, maxoff)) {\n-        off_t off;\n-        LL_L2I(off, offset);\n-        LL_I2L(rv, lseek(osfd, off, whence));\n-    } else {\n-        errno = EFBIG; /* we can't go there */\n-    }\n-    return rv;\n+static PROffset64 _MD_Unix_lseek64(PRIntn osfd, PROffset64 offset,\n+                                   PRIntn whence) {\n+  PRUint64 maxoff;\n+  PROffset64 rv = minus_one;\n+  LL_I2L(maxoff, 0x7fffffff);\n+  if (LL_CMP(offset, <=, maxoff)) {\n+    off_t off;\n+    LL_L2I(off, offset);\n+    LL_I2L(rv, lseek(osfd, off, whence));\n+  } else {\n+    errno = EFBIG; /* we can't go there */\n+  }\n+  return rv;\n } /* _MD_Unix_lseek64 */\n \n-static void*\n-_MD_Unix_mmap64(void* addr, PRSize len, PRIntn prot, PRIntn flags,\n-                PRIntn fildes, PRInt64 offset)\n-{\n-    PR_SetError(PR_FILE_TOO_BIG_ERROR, 0);\n-    return NULL;\n+static void* _MD_Unix_mmap64(void* addr, PRSize len, PRIntn prot, PRIntn flags,\n+                             PRIntn fildes, PRInt64 offset) {\n+  PR_SetError(PR_FILE_TOO_BIG_ERROR, 0);\n+  return NULL;\n } /* _MD_Unix_mmap64 */\n #endif /* defined(_PR_NO_LARGE_FILES) || defined(SOLARIS2_5) */\n \n@@ -2666,146 +2511,138 @@ _MD_Unix_mmap64(void* addr, PRSize len, PRIntn prot, PRIntn flags,\n     (!defined(__clang__) || !defined(__ANDROID_API_L__))\n PR_IMPORT(void) * __mmap2(void*, size_t, int, int, int, size_t);\n \n-#define ANDROID_PAGE_SIZE 4096\n+#  define ANDROID_PAGE_SIZE 4096\n \n-static void*\n-mmap64(void* addr, size_t len, int prot, int flags, int fd,\n-       loff_t offset)\n-{\n-    if (offset & (ANDROID_PAGE_SIZE - 1)) {\n-        errno = EINVAL;\n-        return MAP_FAILED;\n-    }\n-    return __mmap2(addr, len, prot, flags, fd, offset / ANDROID_PAGE_SIZE);\n+static void* mmap64(void* addr, size_t len, int prot, int flags, int fd,\n+                    loff_t offset) {\n+  if (offset & (ANDROID_PAGE_SIZE - 1)) {\n+    errno = EINVAL;\n+    return MAP_FAILED;\n+  }\n+  return __mmap2(addr, len, prot, flags, fd, offset / ANDROID_PAGE_SIZE);\n }\n #endif\n \n-static void\n-_PR_InitIOV(void)\n-{\n+static void _PR_InitIOV(void) {\n #if defined(SOLARIS2_5)\n-    PRLibrary* lib;\n-    void* open64_func;\n-\n-    open64_func = PR_FindSymbolAndLibrary(\"open64\", &lib);\n-    if (NULL != open64_func) {\n-        PR_ASSERT(NULL != lib);\n-        _md_iovector._open64 = (_MD_Open64)open64_func;\n-        _md_iovector._mmap64 = (_MD_Mmap64)PR_FindSymbol(lib, \"mmap64\");\n-        _md_iovector._fstat64 = (_MD_Fstat64)PR_FindSymbol(lib, \"fstat64\");\n-        _md_iovector._stat64 = (_MD_Stat64)PR_FindSymbol(lib, \"stat64\");\n-        _md_iovector._lseek64 = (_MD_Lseek64)PR_FindSymbol(lib, \"lseek64\");\n-        (void)PR_UnloadLibrary(lib);\n-    } else {\n-        _md_iovector._open64 = open;\n-        _md_iovector._mmap64 = _MD_Unix_mmap64;\n-        _md_iovector._fstat64 = _MD_solaris25_fstat64;\n-        _md_iovector._stat64 = _MD_solaris25_stat64;\n-        _md_iovector._lseek64 = _MD_Unix_lseek64;\n-    }\n-#elif defined(_PR_NO_LARGE_FILES)\n+  PRLibrary* lib;\n+  void* open64_func;\n+\n+  open64_func = PR_FindSymbolAndLibrary(\"open64\", &lib);\n+  if (NULL != open64_func) {\n+    PR_ASSERT(NULL != lib);\n+    _md_iovector._open64 = (_MD_Open64)open64_func;\n+    _md_iovector._mmap64 = (_MD_Mmap64)PR_FindSymbol(lib, \"mmap64\");\n+    _md_iovector._fstat64 = (_MD_Fstat64)PR_FindSymbol(lib, \"fstat64\");\n+    _md_iovector._stat64 = (_MD_Stat64)PR_FindSymbol(lib, \"stat64\");\n+    _md_iovector._lseek64 = (_MD_Lseek64)PR_FindSymbol(lib, \"lseek64\");\n+    (void)PR_UnloadLibrary(lib);\n+  } else {\n     _md_iovector._open64 = open;\n     _md_iovector._mmap64 = _MD_Unix_mmap64;\n-    _md_iovector._fstat64 = fstat;\n-    _md_iovector._stat64 = stat;\n+    _md_iovector._fstat64 = _MD_solaris25_fstat64;\n+    _md_iovector._stat64 = _MD_solaris25_stat64;\n     _md_iovector._lseek64 = _MD_Unix_lseek64;\n+  }\n+#elif defined(_PR_NO_LARGE_FILES)\n+  _md_iovector._open64 = open;\n+  _md_iovector._mmap64 = _MD_Unix_mmap64;\n+  _md_iovector._fstat64 = fstat;\n+  _md_iovector._stat64 = stat;\n+  _md_iovector._lseek64 = _MD_Unix_lseek64;\n #elif defined(_PR_HAVE_OFF64_T)\n-#if (defined(ANDROID) && __ANDROID_API__ < 21)\n-    /*\n-     * Android < 21 doesn't have open64.  We pass the O_LARGEFILE flag to open\n-     * in _MD_open.\n-     */\n-    _md_iovector._open64 = open;\n-#else\n-    _md_iovector._open64 = open64;\n-#endif\n-    _md_iovector._mmap64 = mmap64;\n-#if (defined(ANDROID) && __ANDROID_API__ < 21)\n-    /* Same as the open64 case for Android. */\n-    _md_iovector._fstat64 = (_MD_Fstat64)fstat;\n-    _md_iovector._stat64 = (_MD_Stat64)stat;\n-#else\n-    _md_iovector._fstat64 = fstat64;\n-    _md_iovector._stat64 = stat64;\n-#endif\n-    _md_iovector._lseek64 = lseek64;\n+#  if (defined(ANDROID) && __ANDROID_API__ < 21)\n+  /*\n+   * Android < 21 doesn't have open64.  We pass the O_LARGEFILE flag to open\n+   * in _MD_open.\n+   */\n+  _md_iovector._open64 = open;\n+#  else\n+  _md_iovector._open64 = open64;\n+#  endif\n+  _md_iovector._mmap64 = mmap64;\n+#  if (defined(ANDROID) && __ANDROID_API__ < 21)\n+  /* Same as the open64 case for Android. */\n+  _md_iovector._fstat64 = (_MD_Fstat64)fstat;\n+  _md_iovector._stat64 = (_MD_Stat64)stat;\n+#  else\n+  _md_iovector._fstat64 = fstat64;\n+  _md_iovector._stat64 = stat64;\n+#  endif\n+  _md_iovector._lseek64 = lseek64;\n #elif defined(_PR_HAVE_LARGE_OFF_T)\n-    _md_iovector._open64 = open;\n-    _md_iovector._mmap64 = mmap;\n-    _md_iovector._fstat64 = fstat;\n-    _md_iovector._stat64 = stat;\n-    _md_iovector._lseek64 = lseek;\n+  _md_iovector._open64 = open;\n+  _md_iovector._mmap64 = mmap;\n+  _md_iovector._fstat64 = fstat;\n+  _md_iovector._stat64 = stat;\n+  _md_iovector._lseek64 = lseek;\n #else\n-#error \"I don't know yet\"\n+#  error \"I don't know yet\"\n #endif\n-    LL_I2L(minus_one, -1);\n+  LL_I2L(minus_one, -1);\n } /* _PR_InitIOV */\n \n-void\n-_PR_UnixInit(void)\n-{\n-    struct sigaction sigact;\n-    int rv;\n+void _PR_UnixInit(void) {\n+  struct sigaction sigact;\n+  int rv;\n \n-    sigemptyset(&timer_set);\n+  sigemptyset(&timer_set);\n \n #if !defined(_PR_PTHREADS)\n \n-    sigaddset(&timer_set, SIGALRM);\n-    sigemptyset(&empty_set);\n-    intr_timeout_ticks = PR_SecondsToInterval(_PR_INTERRUPT_CHECK_INTERVAL_SECS);\n+  sigaddset(&timer_set, SIGALRM);\n+  sigemptyset(&empty_set);\n+  intr_timeout_ticks = PR_SecondsToInterval(_PR_INTERRUPT_CHECK_INTERVAL_SECS);\n \n-#if defined(SOLARIS)\n+#  if defined(SOLARIS)\n \n-    if (getenv(\"NSPR_SIGSEGV_HANDLE\")) {\n-        sigact.sa_handler = sigsegvhandler;\n-        sigact.sa_flags = 0;\n-        sigact.sa_mask = timer_set;\n-        sigaction(SIGSEGV, &sigact, 0);\n-    }\n+  if (getenv(\"NSPR_SIGSEGV_HANDLE\")) {\n+    sigact.sa_handler = sigsegvhandler;\n+    sigact.sa_flags = 0;\n+    sigact.sa_mask = timer_set;\n+    sigaction(SIGSEGV, &sigact, 0);\n+  }\n \n-    if (getenv(\"NSPR_SIGABRT_HANDLE\")) {\n-        sigact.sa_handler = sigaborthandler;\n-        sigact.sa_flags = 0;\n-        sigact.sa_mask = timer_set;\n-        sigaction(SIGABRT, &sigact, 0);\n-    }\n+  if (getenv(\"NSPR_SIGABRT_HANDLE\")) {\n+    sigact.sa_handler = sigaborthandler;\n+    sigact.sa_flags = 0;\n+    sigact.sa_mask = timer_set;\n+    sigaction(SIGABRT, &sigact, 0);\n+  }\n \n-    if (getenv(\"NSPR_SIGBUS_HANDLE\")) {\n-        sigact.sa_handler = sigbushandler;\n-        sigact.sa_flags = 0;\n-        sigact.sa_mask = timer_set;\n-        sigaction(SIGBUS, &sigact, 0);\n-    }\n+  if (getenv(\"NSPR_SIGBUS_HANDLE\")) {\n+    sigact.sa_handler = sigbushandler;\n+    sigact.sa_flags = 0;\n+    sigact.sa_mask = timer_set;\n+    sigaction(SIGBUS, &sigact, 0);\n+  }\n \n-#endif\n+#  endif\n #endif /* !defined(_PR_PTHREADS) */\n \n-    sigact.sa_handler = SIG_IGN;\n-    sigemptyset(&sigact.sa_mask);\n-    sigact.sa_flags = 0;\n-    rv = sigaction(SIGPIPE, &sigact, 0);\n-    PR_ASSERT(0 == rv);\n+  sigact.sa_handler = SIG_IGN;\n+  sigemptyset(&sigact.sa_mask);\n+  sigact.sa_flags = 0;\n+  rv = sigaction(SIGPIPE, &sigact, 0);\n+  PR_ASSERT(0 == rv);\n \n-    _pr_unix_rename_lock = PR_NewLock();\n-    PR_ASSERT(NULL != _pr_unix_rename_lock);\n-    _pr_Xfe_mon = PR_NewMonitor();\n-    PR_ASSERT(NULL != _pr_Xfe_mon);\n+  _pr_unix_rename_lock = PR_NewLock();\n+  PR_ASSERT(NULL != _pr_unix_rename_lock);\n+  _pr_Xfe_mon = PR_NewMonitor();\n+  PR_ASSERT(NULL != _pr_Xfe_mon);\n \n-    _PR_InitIOV(); /* one last hack */\n+  _PR_InitIOV(); /* one last hack */\n }\n \n-void\n-_PR_UnixCleanup(void)\n-{\n-    if (_pr_unix_rename_lock) {\n-        PR_DestroyLock(_pr_unix_rename_lock);\n-        _pr_unix_rename_lock = NULL;\n-    }\n-    if (_pr_Xfe_mon) {\n-        PR_DestroyMonitor(_pr_Xfe_mon);\n-        _pr_Xfe_mon = NULL;\n-    }\n+void _PR_UnixCleanup(void) {\n+  if (_pr_unix_rename_lock) {\n+    PR_DestroyLock(_pr_unix_rename_lock);\n+    _pr_unix_rename_lock = NULL;\n+  }\n+  if (_pr_Xfe_mon) {\n+    PR_DestroyMonitor(_pr_Xfe_mon);\n+    _pr_Xfe_mon = NULL;\n+  }\n }\n \n #if !defined(_PR_PTHREADS)\n@@ -2823,79 +2660,73 @@ static PRLock* _pr_md_lock = NULL;\n  * called by _PR_InitSegs(), which in turn is called by\n  * PR_Init().\n  */\n-void\n-_MD_InitSegs(void)\n-{\n-#ifdef DEBUG\n-    /*\n-    ** Disable using mmap(2) if NSPR_NO_MMAP is set\n-    */\n-    if (getenv(\"NSPR_NO_MMAP\")) {\n-        _pr_zero_fd = -2;\n-        return;\n-    }\n-#endif\n-    _pr_zero_fd = open(\"/dev/zero\", O_RDWR, 0);\n-    /* Prevent the fd from being inherited by child processes */\n-    fcntl(_pr_zero_fd, F_SETFD, FD_CLOEXEC);\n-    _pr_md_lock = PR_NewLock();\n-}\n-\n-PRStatus\n-_MD_AllocSegment(PRSegment* seg, PRUint32 size, void* vaddr)\n-{\n-    static char* lastaddr = (char*)_PR_STACK_VMBASE;\n-    PRStatus retval = PR_SUCCESS;\n-    int prot;\n-    void* rv;\n-\n-    PR_ASSERT(seg != 0);\n-    PR_ASSERT(size != 0);\n-\n-    PR_Lock(_pr_md_lock);\n-    if (_pr_zero_fd < 0) {\n-    from_heap:\n-        seg->vaddr = PR_MALLOC(size);\n-        if (!seg->vaddr) {\n-            retval = PR_FAILURE;\n-        } else {\n-            seg->size = size;\n-        }\n-        goto exit;\n-    }\n-\n-    prot = PROT_READ | PROT_WRITE;\n-    /*\n-     * On Alpha Linux, the user-level thread stack needs\n-     * to be made executable because longjmp/signal seem\n-     * to put machine instructions on the stack.\n-     */\n-#if defined(LINUX) && defined(__alpha)\n-    prot |= PROT_EXEC;\n-#endif\n-    rv = mmap((vaddr != 0) ? vaddr : lastaddr, size, prot, _MD_MMAP_FLAGS,\n-              _pr_zero_fd, 0);\n-    if (rv == (void*)-1) {\n-        goto from_heap;\n-    }\n-    lastaddr += size;\n-    seg->vaddr = rv;\n-    seg->size = size;\n-    seg->flags = _PR_SEG_VM;\n+void _MD_InitSegs(void) {\n+#  ifdef DEBUG\n+  /*\n+  ** Disable using mmap(2) if NSPR_NO_MMAP is set\n+  */\n+  if (getenv(\"NSPR_NO_MMAP\")) {\n+    _pr_zero_fd = -2;\n+    return;\n+  }\n+#  endif\n+  _pr_zero_fd = open(\"/dev/zero\", O_RDWR, 0);\n+  /* Prevent the fd from being inherited by child processes */\n+  fcntl(_pr_zero_fd, F_SETFD, FD_CLOEXEC);\n+  _pr_md_lock = PR_NewLock();\n+}\n+\n+PRStatus _MD_AllocSegment(PRSegment* seg, PRUint32 size, void* vaddr) {\n+  static char* lastaddr = (char*)_PR_STACK_VMBASE;\n+  PRStatus retval = PR_SUCCESS;\n+  int prot;\n+  void* rv;\n+\n+  PR_ASSERT(seg != 0);\n+  PR_ASSERT(size != 0);\n+\n+  PR_Lock(_pr_md_lock);\n+  if (_pr_zero_fd < 0) {\n+  from_heap:\n+    seg->vaddr = PR_MALLOC(size);\n+    if (!seg->vaddr) {\n+      retval = PR_FAILURE;\n+    } else {\n+      seg->size = size;\n+    }\n+    goto exit;\n+  }\n+\n+  prot = PROT_READ | PROT_WRITE;\n+  /*\n+   * On Alpha Linux, the user-level thread stack needs\n+   * to be made executable because longjmp/signal seem\n+   * to put machine instructions on the stack.\n+   */\n+#  if defined(LINUX) && defined(__alpha)\n+  prot |= PROT_EXEC;\n+#  endif\n+  rv = mmap((vaddr != 0) ? vaddr : lastaddr, size, prot, _MD_MMAP_FLAGS,\n+            _pr_zero_fd, 0);\n+  if (rv == (void*)-1) {\n+    goto from_heap;\n+  }\n+  lastaddr += size;\n+  seg->vaddr = rv;\n+  seg->size = size;\n+  seg->flags = _PR_SEG_VM;\n \n exit:\n-    PR_Unlock(_pr_md_lock);\n-    return retval;\n+  PR_Unlock(_pr_md_lock);\n+  return retval;\n }\n \n-void\n-_MD_FreeSegment(PRSegment* seg)\n-{\n-    if (seg->flags & _PR_SEG_VM) {\n-        (void)munmap(seg->vaddr, seg->size);\n-    } else {\n-        PR_DELETE(seg->vaddr);\n-    }\n+void _MD_FreeSegment(PRSegment* seg) {\n+  if (seg->flags & _PR_SEG_VM) {\n+    (void)munmap(seg->vaddr, seg->size);\n+  } else {\n+    PR_DELETE(seg->vaddr);\n+  }\n }\n \n #endif /* _PR_PTHREADS */\n@@ -2915,18 +2746,17 @@ _MD_FreeSegment(PRSegment* seg)\n  */\n \n PR_IMPLEMENT(PRTime)\n-PR_Now(void)\n-{\n-    struct timeval tv;\n-    PRInt64 s, us, s2us;\n+PR_Now(void) {\n+  struct timeval tv;\n+  PRInt64 s, us, s2us;\n \n-    GETTIMEOFDAY(&tv);\n-    LL_I2L(s2us, PR_USEC_PER_SEC);\n-    LL_I2L(s, tv.tv_sec);\n-    LL_I2L(us, tv.tv_usec);\n-    LL_MUL(s, s, s2us);\n-    LL_ADD(s, s, us);\n-    return s;\n+  GETTIMEOFDAY(&tv);\n+  LL_I2L(s2us, PR_USEC_PER_SEC);\n+  LL_I2L(s, tv.tv_sec);\n+  LL_I2L(us, tv.tv_usec);\n+  LL_MUL(s, s, s2us);\n+  LL_ADD(s, s, us);\n+  return s;\n }\n \n #if defined(_MD_INTERVAL_USE_GTOD)\n@@ -2936,47 +2766,37 @@ PR_Now(void)\n  * 1) The time of day is neither linear nor montonically increasing\n  * 2) The units here are milliseconds. That's not appropriate for our use.\n  */\n-PRIntervalTime\n-_PR_UNIX_GetInterval()\n-{\n-    struct timeval time;\n-    PRIntervalTime ticks;\n-\n-    (void)GETTIMEOFDAY(&time);                          /* fallicy of course */\n-    ticks = (PRUint32)time.tv_sec * PR_MSEC_PER_SEC;    /* that's in milliseconds */\n-    ticks += (PRUint32)time.tv_usec / PR_USEC_PER_MSEC; /* so's that */\n-    return ticks;\n+PRIntervalTime _PR_UNIX_GetInterval() {\n+  struct timeval time;\n+  PRIntervalTime ticks;\n+\n+  (void)GETTIMEOFDAY(&time);                       /* fallicy of course */\n+  ticks = (PRUint32)time.tv_sec * PR_MSEC_PER_SEC; /* that's in milliseconds */\n+  ticks += (PRUint32)time.tv_usec / PR_USEC_PER_MSEC; /* so's that */\n+  return ticks;\n } /* _PR_UNIX_GetInterval */\n \n-PRIntervalTime\n-_PR_UNIX_TicksPerSecond()\n-{\n-    return 1000; /* this needs some work :) */\n+PRIntervalTime _PR_UNIX_TicksPerSecond() {\n+  return 1000; /* this needs some work :) */\n }\n #endif\n \n #if defined(_PR_HAVE_CLOCK_MONOTONIC)\n-PRIntervalTime\n-_PR_UNIX_GetInterval2()\n-{\n-    struct timespec time;\n-    PRIntervalTime ticks;\n-\n-    if (clock_gettime(CLOCK_MONOTONIC, &time) != 0) {\n-        fprintf(stderr, \"clock_gettime failed: %d\\n\", errno);\n-        abort();\n-    }\n+PRIntervalTime _PR_UNIX_GetInterval2() {\n+  struct timespec time;\n+  PRIntervalTime ticks;\n \n-    ticks = (PRUint32)time.tv_sec * PR_MSEC_PER_SEC;\n-    ticks += (PRUint32)time.tv_nsec / PR_NSEC_PER_MSEC;\n-    return ticks;\n-}\n+  if (clock_gettime(CLOCK_MONOTONIC, &time) != 0) {\n+    fprintf(stderr, \"clock_gettime failed: %d\\n\", errno);\n+    abort();\n+  }\n \n-PRIntervalTime\n-_PR_UNIX_TicksPerSecond2()\n-{\n-    return 1000;\n+  ticks = (PRUint32)time.tv_sec * PR_MSEC_PER_SEC;\n+  ticks += (PRUint32)time.tv_nsec / PR_NSEC_PER_MSEC;\n+  return ticks;\n }\n+\n+PRIntervalTime _PR_UNIX_TicksPerSecond2() { return 1000; }\n #endif\n \n #if !defined(_PR_PTHREADS)\n@@ -2986,153 +2806,150 @@ _PR_UNIX_TicksPerSecond2()\n  * Return 0 if timed out, return -1 if interrupted,\n  * else return the number of ready descriptors.\n  */\n-PRInt32\n-_PR_WaitForMultipleFDs(_PRUnixPollDesc* unixpds, PRInt32 pdcnt,\n-                       PRIntervalTime timeout)\n-{\n-    PRPollQueue pq;\n-    PRIntn is;\n-    PRInt32 rv;\n-    _PRCPU* io_cpu;\n-    _PRUnixPollDesc *unixpd, *eunixpd;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    PR_ASSERT(!(me->flags & _PR_IDLE_THREAD));\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n-    }\n-\n-    pq.pds = unixpds;\n-    pq.npds = pdcnt;\n-\n-    _PR_INTSOFF(is);\n+PRInt32 _PR_WaitForMultipleFDs(_PRUnixPollDesc* unixpds, PRInt32 pdcnt,\n+                               PRIntervalTime timeout) {\n+  PRPollQueue pq;\n+  PRIntn is;\n+  PRInt32 rv;\n+  _PRCPU* io_cpu;\n+  _PRUnixPollDesc *unixpd, *eunixpd;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  PR_ASSERT(!(me->flags & _PR_IDLE_THREAD));\n+\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n+\n+  pq.pds = unixpds;\n+  pq.npds = pdcnt;\n+\n+  _PR_INTSOFF(is);\n+  _PR_MD_IOQ_LOCK();\n+  _PR_THREAD_LOCK(me);\n+\n+  pq.thr = me;\n+  io_cpu = me->cpu;\n+  pq.on_ioq = PR_TRUE;\n+  pq.timeout = timeout;\n+  _PR_ADD_TO_IOQ(pq, me->cpu);\n+\n+#  if !defined(_PR_USE_POLL)\n+  eunixpd = unixpds + pdcnt;\n+  for (unixpd = unixpds; unixpd < eunixpd; unixpd++) {\n+    PRInt32 osfd = unixpd->osfd;\n+    if (unixpd->in_flags & _PR_UNIX_POLL_READ) {\n+      FD_SET(osfd, &_PR_FD_READ_SET(me->cpu));\n+      _PR_FD_READ_CNT(me->cpu)[osfd]++;\n+    }\n+    if (unixpd->in_flags & _PR_UNIX_POLL_WRITE) {\n+      FD_SET(osfd, &_PR_FD_WRITE_SET(me->cpu));\n+      (_PR_FD_WRITE_CNT(me->cpu))[osfd]++;\n+    }\n+    if (unixpd->in_flags & _PR_UNIX_POLL_EXCEPT) {\n+      FD_SET(osfd, &_PR_FD_EXCEPTION_SET(me->cpu));\n+      (_PR_FD_EXCEPTION_CNT(me->cpu))[osfd]++;\n+    }\n+    if (osfd > _PR_IOQ_MAX_OSFD(me->cpu)) {\n+      _PR_IOQ_MAX_OSFD(me->cpu) = osfd;\n+    }\n+  }\n+#  endif /* !defined(_PR_USE_POLL) */\n+\n+  if (_PR_IOQ_TIMEOUT(me->cpu) > timeout) {\n+    _PR_IOQ_TIMEOUT(me->cpu) = timeout;\n+  }\n+\n+  _PR_IOQ_OSFD_CNT(me->cpu) += pdcnt;\n+\n+  _PR_SLEEPQ_LOCK(me->cpu);\n+  _PR_ADD_SLEEPQ(me, timeout);\n+  me->state = _PR_IO_WAIT;\n+  me->io_pending = PR_TRUE;\n+  me->io_suspended = PR_FALSE;\n+  _PR_SLEEPQ_UNLOCK(me->cpu);\n+  _PR_THREAD_UNLOCK(me);\n+  _PR_MD_IOQ_UNLOCK();\n+\n+  _PR_MD_WAIT(me, timeout);\n+\n+  me->io_pending = PR_FALSE;\n+  me->io_suspended = PR_FALSE;\n+\n+  /*\n+   * This thread should run on the same cpu on which it was blocked; when\n+   * the IO request times out the fd sets and fd counts for the\n+   * cpu are updated below.\n+   */\n+  PR_ASSERT(me->cpu == io_cpu);\n+\n+  /*\n+  ** If we timed out the pollq might still be on the ioq. Remove it\n+  ** before continuing.\n+  */\n+  if (pq.on_ioq) {\n     _PR_MD_IOQ_LOCK();\n-    _PR_THREAD_LOCK(me);\n-\n-    pq.thr = me;\n-    io_cpu = me->cpu;\n-    pq.on_ioq = PR_TRUE;\n-    pq.timeout = timeout;\n-    _PR_ADD_TO_IOQ(pq, me->cpu);\n-\n-#if !defined(_PR_USE_POLL)\n-    eunixpd = unixpds + pdcnt;\n-    for (unixpd = unixpds; unixpd < eunixpd; unixpd++) {\n-        PRInt32 osfd = unixpd->osfd;\n-        if (unixpd->in_flags & _PR_UNIX_POLL_READ) {\n-            FD_SET(osfd, &_PR_FD_READ_SET(me->cpu));\n-            _PR_FD_READ_CNT(me->cpu)\n-            [osfd]++;\n-        }\n-        if (unixpd->in_flags & _PR_UNIX_POLL_WRITE) {\n-            FD_SET(osfd, &_PR_FD_WRITE_SET(me->cpu));\n-            (_PR_FD_WRITE_CNT(me->cpu))[osfd]++;\n-        }\n-        if (unixpd->in_flags & _PR_UNIX_POLL_EXCEPT) {\n-            FD_SET(osfd, &_PR_FD_EXCEPTION_SET(me->cpu));\n-            (_PR_FD_EXCEPTION_CNT(me->cpu))[osfd]++;\n-        }\n-        if (osfd > _PR_IOQ_MAX_OSFD(me->cpu)) {\n-            _PR_IOQ_MAX_OSFD(me->cpu) = osfd;\n-        }\n-    }\n-#endif /* !defined(_PR_USE_POLL) */\n-\n-    if (_PR_IOQ_TIMEOUT(me->cpu) > timeout) {\n-        _PR_IOQ_TIMEOUT(me->cpu) = timeout;\n-    }\n-\n-    _PR_IOQ_OSFD_CNT(me->cpu) += pdcnt;\n-\n-    _PR_SLEEPQ_LOCK(me->cpu);\n-    _PR_ADD_SLEEPQ(me, timeout);\n-    me->state = _PR_IO_WAIT;\n-    me->io_pending = PR_TRUE;\n-    me->io_suspended = PR_FALSE;\n-    _PR_SLEEPQ_UNLOCK(me->cpu);\n-    _PR_THREAD_UNLOCK(me);\n-    _PR_MD_IOQ_UNLOCK();\n-\n-    _PR_MD_WAIT(me, timeout);\n-\n-    me->io_pending = PR_FALSE;\n-    me->io_suspended = PR_FALSE;\n-\n     /*\n-     * This thread should run on the same cpu on which it was blocked; when\n-     * the IO request times out the fd sets and fd counts for the\n-     * cpu are updated below.\n+     * Need to check pq.on_ioq again\n      */\n-    PR_ASSERT(me->cpu == io_cpu);\n-\n-    /*\n-    ** If we timed out the pollq might still be on the ioq. Remove it\n-    ** before continuing.\n-    */\n     if (pq.on_ioq) {\n-        _PR_MD_IOQ_LOCK();\n-        /*\n-         * Need to check pq.on_ioq again\n-         */\n-        if (pq.on_ioq) {\n-            PR_REMOVE_LINK(&pq.links);\n-#ifndef _PR_USE_POLL\n-            eunixpd = unixpds + pdcnt;\n-            for (unixpd = unixpds; unixpd < eunixpd; unixpd++) {\n-                PRInt32 osfd = unixpd->osfd;\n-                PRInt16 in_flags = unixpd->in_flags;\n-\n-                if (in_flags & _PR_UNIX_POLL_READ) {\n-                    if (--(_PR_FD_READ_CNT(me->cpu))[osfd] == 0) {\n-                        FD_CLR(osfd, &_PR_FD_READ_SET(me->cpu));\n-                    }\n-                }\n-                if (in_flags & _PR_UNIX_POLL_WRITE) {\n-                    if (--(_PR_FD_WRITE_CNT(me->cpu))[osfd] == 0) {\n-                        FD_CLR(osfd, &_PR_FD_WRITE_SET(me->cpu));\n-                    }\n-                }\n-                if (in_flags & _PR_UNIX_POLL_EXCEPT) {\n-                    if (--(_PR_FD_EXCEPTION_CNT(me->cpu))[osfd] == 0) {\n-                        FD_CLR(osfd, &_PR_FD_EXCEPTION_SET(me->cpu));\n-                    }\n-                }\n-            }\n-#endif /* _PR_USE_POLL */\n-            PR_ASSERT(pq.npds == pdcnt);\n-            _PR_IOQ_OSFD_CNT(me->cpu) -= pdcnt;\n-            PR_ASSERT(_PR_IOQ_OSFD_CNT(me->cpu) >= 0);\n-        }\n-        _PR_MD_IOQ_UNLOCK();\n-    }\n-    /* XXX Should we use _PR_FAST_INTSON or _PR_INTSON? */\n-    if (1 == pdcnt) {\n-        _PR_FAST_INTSON(is);\n-    } else {\n-        _PR_INTSON(is);\n-    }\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n-    }\n+      PR_REMOVE_LINK(&pq.links);\n+#  ifndef _PR_USE_POLL\n+      eunixpd = unixpds + pdcnt;\n+      for (unixpd = unixpds; unixpd < eunixpd; unixpd++) {\n+        PRInt32 osfd = unixpd->osfd;\n+        PRInt16 in_flags = unixpd->in_flags;\n \n-    rv = 0;\n-    if (pq.on_ioq == PR_FALSE) {\n-        /* Count the number of ready descriptors */\n-        while (--pdcnt >= 0) {\n-            if (unixpds->out_flags != 0) {\n-                rv++;\n-            }\n-            unixpds++;\n+        if (in_flags & _PR_UNIX_POLL_READ) {\n+          if (--(_PR_FD_READ_CNT(me->cpu))[osfd] == 0) {\n+            FD_CLR(osfd, &_PR_FD_READ_SET(me->cpu));\n+          }\n+        }\n+        if (in_flags & _PR_UNIX_POLL_WRITE) {\n+          if (--(_PR_FD_WRITE_CNT(me->cpu))[osfd] == 0) {\n+            FD_CLR(osfd, &_PR_FD_WRITE_SET(me->cpu));\n+          }\n         }\n+        if (in_flags & _PR_UNIX_POLL_EXCEPT) {\n+          if (--(_PR_FD_EXCEPTION_CNT(me->cpu))[osfd] == 0) {\n+            FD_CLR(osfd, &_PR_FD_EXCEPTION_SET(me->cpu));\n+          }\n+        }\n+      }\n+#  endif /* _PR_USE_POLL */\n+      PR_ASSERT(pq.npds == pdcnt);\n+      _PR_IOQ_OSFD_CNT(me->cpu) -= pdcnt;\n+      PR_ASSERT(_PR_IOQ_OSFD_CNT(me->cpu) >= 0);\n     }\n-\n-    return rv;\n+    _PR_MD_IOQ_UNLOCK();\n+  }\n+  /* XXX Should we use _PR_FAST_INTSON or _PR_INTSON? */\n+  if (1 == pdcnt) {\n+    _PR_FAST_INTSON(is);\n+  } else {\n+    _PR_INTSON(is);\n+  }\n+\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n+\n+  rv = 0;\n+  if (pq.on_ioq == PR_FALSE) {\n+    /* Count the number of ready descriptors */\n+    while (--pdcnt >= 0) {\n+      if (unixpds->out_flags != 0) {\n+        rv++;\n+      }\n+      unixpds++;\n+    }\n+  }\n+\n+  return rv;\n }\n \n /*\n@@ -3142,32 +2959,30 @@ _PR_WaitForMultipleFDs(_PRUnixPollDesc* unixpds, PRInt32 pdcnt,\n  * NOTE: The thread lock should held when this function is called.\n  * On return, the thread lock is released.\n  */\n-void\n-_PR_Unblock_IO_Wait(PRThread* thr)\n-{\n-    int pri = thr->priority;\n-    _PRCPU* cpu = thr->cpu;\n-\n-    /*\n-     * GLOBAL threads wakeup periodically to check for interrupt\n-     */\n-    if (_PR_IS_NATIVE_THREAD(thr)) {\n-        _PR_THREAD_UNLOCK(thr);\n-        return;\n-    }\n-\n-    PR_ASSERT(thr->flags & (_PR_ON_SLEEPQ | _PR_ON_PAUSEQ));\n-    _PR_SLEEPQ_LOCK(cpu);\n-    _PR_DEL_SLEEPQ(thr, PR_TRUE);\n-    _PR_SLEEPQ_UNLOCK(cpu);\n-\n-    PR_ASSERT(!(thr->flags & _PR_IDLE_THREAD));\n-    thr->state = _PR_RUNNABLE;\n-    _PR_RUNQ_LOCK(cpu);\n-    _PR_ADD_RUNQ(thr, cpu, pri);\n-    _PR_RUNQ_UNLOCK(cpu);\n+void _PR_Unblock_IO_Wait(PRThread* thr) {\n+  int pri = thr->priority;\n+  _PRCPU* cpu = thr->cpu;\n+\n+  /*\n+   * GLOBAL threads wakeup periodically to check for interrupt\n+   */\n+  if (_PR_IS_NATIVE_THREAD(thr)) {\n     _PR_THREAD_UNLOCK(thr);\n-    _PR_MD_WAKEUP_WAITER(thr);\n+    return;\n+  }\n+\n+  PR_ASSERT(thr->flags & (_PR_ON_SLEEPQ | _PR_ON_PAUSEQ));\n+  _PR_SLEEPQ_LOCK(cpu);\n+  _PR_DEL_SLEEPQ(thr, PR_TRUE);\n+  _PR_SLEEPQ_UNLOCK(cpu);\n+\n+  PR_ASSERT(!(thr->flags & _PR_IDLE_THREAD));\n+  thr->state = _PR_RUNNABLE;\n+  _PR_RUNQ_LOCK(cpu);\n+  _PR_ADD_RUNQ(thr, cpu, pri);\n+  _PR_RUNQ_UNLOCK(cpu);\n+  _PR_THREAD_UNLOCK(thr);\n+  _PR_MD_WAKEUP_WAITER(thr);\n }\n #endif /* !defined(_PR_PTHREADS) */\n \n@@ -3179,75 +2994,73 @@ _PR_Unblock_IO_Wait(PRThread* thr)\n  * that the nonblocking connect succeeded.\n  */\n \n-int\n-_MD_unix_get_nonblocking_connect_error(int osfd)\n-{\n+int _MD_unix_get_nonblocking_connect_error(int osfd) {\n #if defined(NTO)\n-    /* Neutrino does not support the SO_ERROR socket option */\n-    PRInt32 rv;\n-    PRNetAddr addr;\n-    _PRSockLen_t addrlen = sizeof(addr);\n-\n-    /* Test to see if we are using the Tiny TCP/IP Stack or the Full one. */\n-    struct statvfs superblock;\n-    rv = fstatvfs(osfd, &superblock);\n-    if (rv == 0) {\n-        if (strcmp(superblock.f_basetype, \"ttcpip\") == 0) {\n-            /* Using the Tiny Stack! */\n-            rv = getpeername(osfd, (struct sockaddr*)&addr, (_PRSockLen_t*)&addrlen);\n-            if (rv == -1) {\n-                int errno_copy = errno; /* make a copy so I don't\n-                                         * accidentally reset */\n-\n-                if (errno_copy == ENOTCONN) {\n-                    struct stat StatInfo;\n-                    rv = fstat(osfd, &StatInfo);\n-                    if (rv == 0) {\n-                        time_t current_time = time(NULL);\n-\n-                        /*\n-                         * this is a real hack, can't explain why it\n-                         * works it just does\n-                         */\n-                        if (abs(current_time - StatInfo.st_atime) < 5) {\n-                            return ECONNREFUSED;\n-                        } else {\n-                            return ETIMEDOUT;\n-                        }\n-                    } else {\n-                        return ECONNREFUSED;\n-                    }\n-                } else {\n-                    return errno_copy;\n-                }\n-            } else {\n-                /* No Error */\n-                return 0;\n-            }\n-        } else {\n-            /* Have the FULL Stack which supports SO_ERROR */\n-            /* Hasn't been written yet, never been tested! */\n-            /* Jerry.Kirk@Nexwarecorp.com */\n+  /* Neutrino does not support the SO_ERROR socket option */\n+  PRInt32 rv;\n+  PRNetAddr addr;\n+  _PRSockLen_t addrlen = sizeof(addr);\n+\n+  /* Test to see if we are using the Tiny TCP/IP Stack or the Full one. */\n+  struct statvfs superblock;\n+  rv = fstatvfs(osfd, &superblock);\n+  if (rv == 0) {\n+    if (strcmp(superblock.f_basetype, \"ttcpip\") == 0) {\n+      /* Using the Tiny Stack! */\n+      rv = getpeername(osfd, (struct sockaddr*)&addr, (_PRSockLen_t*)&addrlen);\n+      if (rv == -1) {\n+        int errno_copy = errno; /* make a copy so I don't\n+                                 * accidentally reset */\n+\n+        if (errno_copy == ENOTCONN) {\n+          struct stat StatInfo;\n+          rv = fstat(osfd, &StatInfo);\n+          if (rv == 0) {\n+            time_t current_time = time(NULL);\n \n-            int err;\n-            _PRSockLen_t optlen = sizeof(err);\n-\n-            if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char*)&err, &optlen) == -1) {\n-                return errno;\n+            /*\n+             * this is a real hack, can't explain why it\n+             * works it just does\n+             */\n+            if (abs(current_time - StatInfo.st_atime) < 5) {\n+              return ECONNREFUSED;\n             } else {\n-                return err;\n+              return ETIMEDOUT;\n             }\n+          } else {\n+            return ECONNREFUSED;\n+          }\n+        } else {\n+          return errno_copy;\n         }\n+      } else {\n+        /* No Error */\n+        return 0;\n+      }\n     } else {\n-        return ECONNREFUSED;\n-    }\n-#else\n-    int err;\n-    _PRSockLen_t optlen = sizeof(err);\n-    if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char*)&err, &optlen) == -1) {\n+      /* Have the FULL Stack which supports SO_ERROR */\n+      /* Hasn't been written yet, never been tested! */\n+      /* Jerry.Kirk@Nexwarecorp.com */\n+\n+      int err;\n+      _PRSockLen_t optlen = sizeof(err);\n+\n+      if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char*)&err, &optlen) == -1) {\n         return errno;\n+      } else {\n+        return err;\n+      }\n     }\n-    return err;\n+  } else {\n+    return ECONNREFUSED;\n+  }\n+#else\n+  int err;\n+  _PRSockLen_t optlen = sizeof(err);\n+  if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char*)&err, &optlen) == -1) {\n+    return errno;\n+  }\n+  return err;\n \n #endif\n }\n@@ -3260,193 +3073,161 @@ _MD_unix_get_nonblocking_connect_error(int osfd)\n ** in a pre-emptive threaded environment, we need to use a lock.\n */\n \n-void\n-_PR_XLock(void)\n-{\n-    PR_EnterMonitor(_pr_Xfe_mon);\n-}\n+void _PR_XLock(void) { PR_EnterMonitor(_pr_Xfe_mon); }\n \n-void\n-_PR_XUnlock(void)\n-{\n-    PR_ExitMonitor(_pr_Xfe_mon);\n-}\n+void _PR_XUnlock(void) { PR_ExitMonitor(_pr_Xfe_mon); }\n \n-PRBool\n-_PR_XIsLocked(void)\n-{\n-    return (PR_InMonitor(_pr_Xfe_mon)) ? PR_TRUE : PR_FALSE;\n+PRBool _PR_XIsLocked(void) {\n+  return (PR_InMonitor(_pr_Xfe_mon)) ? PR_TRUE : PR_FALSE;\n }\n \n #if defined(HAVE_FCNTL_FILE_LOCKING)\n \n-PRStatus\n-_MD_LockFile(PRInt32 f)\n-{\n-    PRInt32 rv;\n-    struct flock arg;\n-\n-    arg.l_type = F_WRLCK;\n-    arg.l_whence = SEEK_SET;\n-    arg.l_start = 0;\n-    arg.l_len = 0; /* until EOF */\n-    rv = fcntl(f, F_SETLKW, &arg);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    }\n-    _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());\n-    return PR_FAILURE;\n+PRStatus _MD_LockFile(PRInt32 f) {\n+  PRInt32 rv;\n+  struct flock arg;\n+\n+  arg.l_type = F_WRLCK;\n+  arg.l_whence = SEEK_SET;\n+  arg.l_start = 0;\n+  arg.l_len = 0; /* until EOF */\n+  rv = fcntl(f, F_SETLKW, &arg);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  }\n+  _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());\n+  return PR_FAILURE;\n }\n \n-PRStatus\n-_MD_TLockFile(PRInt32 f)\n-{\n-    PRInt32 rv;\n-    struct flock arg;\n+PRStatus _MD_TLockFile(PRInt32 f) {\n+  PRInt32 rv;\n+  struct flock arg;\n \n-    arg.l_type = F_WRLCK;\n-    arg.l_whence = SEEK_SET;\n-    arg.l_start = 0;\n-    arg.l_len = 0; /* until EOF */\n-    rv = fcntl(f, F_SETLK, &arg);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    }\n-    _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());\n-    return PR_FAILURE;\n+  arg.l_type = F_WRLCK;\n+  arg.l_whence = SEEK_SET;\n+  arg.l_start = 0;\n+  arg.l_len = 0; /* until EOF */\n+  rv = fcntl(f, F_SETLK, &arg);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  }\n+  _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());\n+  return PR_FAILURE;\n }\n \n-PRStatus\n-_MD_UnlockFile(PRInt32 f)\n-{\n-    PRInt32 rv;\n-    struct flock arg;\n+PRStatus _MD_UnlockFile(PRInt32 f) {\n+  PRInt32 rv;\n+  struct flock arg;\n \n-    arg.l_type = F_UNLCK;\n-    arg.l_whence = SEEK_SET;\n-    arg.l_start = 0;\n-    arg.l_len = 0; /* until EOF */\n-    rv = fcntl(f, F_SETLK, &arg);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    }\n-    _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());\n-    return PR_FAILURE;\n+  arg.l_type = F_UNLCK;\n+  arg.l_whence = SEEK_SET;\n+  arg.l_start = 0;\n+  arg.l_len = 0; /* until EOF */\n+  rv = fcntl(f, F_SETLK, &arg);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  }\n+  _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());\n+  return PR_FAILURE;\n }\n \n #elif defined(HAVE_BSD_FLOCK)\n \n-#include <sys/file.h>\n+#  include <sys/file.h>\n \n-PRStatus\n-_MD_LockFile(PRInt32 f)\n-{\n-    PRInt32 rv;\n-    rv = flock(f, LOCK_EX);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    }\n-    _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());\n-    return PR_FAILURE;\n+PRStatus _MD_LockFile(PRInt32 f) {\n+  PRInt32 rv;\n+  rv = flock(f, LOCK_EX);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  }\n+  _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());\n+  return PR_FAILURE;\n }\n \n-PRStatus\n-_MD_TLockFile(PRInt32 f)\n-{\n-    PRInt32 rv;\n-    rv = flock(f, LOCK_EX | LOCK_NB);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    }\n-    _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());\n-    return PR_FAILURE;\n+PRStatus _MD_TLockFile(PRInt32 f) {\n+  PRInt32 rv;\n+  rv = flock(f, LOCK_EX | LOCK_NB);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  }\n+  _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());\n+  return PR_FAILURE;\n }\n \n-PRStatus\n-_MD_UnlockFile(PRInt32 f)\n-{\n-    PRInt32 rv;\n-    rv = flock(f, LOCK_UN);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    }\n-    _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());\n-    return PR_FAILURE;\n+PRStatus _MD_UnlockFile(PRInt32 f) {\n+  PRInt32 rv;\n+  rv = flock(f, LOCK_UN);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  }\n+  _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());\n+  return PR_FAILURE;\n }\n #else\n \n-PRStatus\n-_MD_LockFile(PRInt32 f)\n-{\n-    PRInt32 rv;\n-    rv = lockf(f, F_LOCK, 0);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    }\n-    _PR_MD_MAP_LOCKF_ERROR(_MD_ERRNO());\n-    return PR_FAILURE;\n+PRStatus _MD_LockFile(PRInt32 f) {\n+  PRInt32 rv;\n+  rv = lockf(f, F_LOCK, 0);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  }\n+  _PR_MD_MAP_LOCKF_ERROR(_MD_ERRNO());\n+  return PR_FAILURE;\n }\n \n-PRStatus\n-_MD_TLockFile(PRInt32 f)\n-{\n-    PRInt32 rv;\n-    rv = lockf(f, F_TLOCK, 0);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    }\n-    _PR_MD_MAP_LOCKF_ERROR(_MD_ERRNO());\n-    return PR_FAILURE;\n+PRStatus _MD_TLockFile(PRInt32 f) {\n+  PRInt32 rv;\n+  rv = lockf(f, F_TLOCK, 0);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  }\n+  _PR_MD_MAP_LOCKF_ERROR(_MD_ERRNO());\n+  return PR_FAILURE;\n }\n \n-PRStatus\n-_MD_UnlockFile(PRInt32 f)\n-{\n-    PRInt32 rv;\n-    rv = lockf(f, F_ULOCK, 0);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    }\n-    _PR_MD_MAP_LOCKF_ERROR(_MD_ERRNO());\n-    return PR_FAILURE;\n+PRStatus _MD_UnlockFile(PRInt32 f) {\n+  PRInt32 rv;\n+  rv = lockf(f, F_ULOCK, 0);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  }\n+  _PR_MD_MAP_LOCKF_ERROR(_MD_ERRNO());\n+  return PR_FAILURE;\n }\n #endif\n \n-PRStatus\n-_MD_gethostname(char* name, PRUint32 namelen)\n-{\n-    PRIntn rv;\n+PRStatus _MD_gethostname(char* name, PRUint32 namelen) {\n+  PRIntn rv;\n \n-    rv = gethostname(name, namelen);\n-    if (0 == rv) {\n-        return PR_SUCCESS;\n-    }\n-    _PR_MD_MAP_GETHOSTNAME_ERROR(_MD_ERRNO());\n-    return PR_FAILURE;\n+  rv = gethostname(name, namelen);\n+  if (0 == rv) {\n+    return PR_SUCCESS;\n+  }\n+  _PR_MD_MAP_GETHOSTNAME_ERROR(_MD_ERRNO());\n+  return PR_FAILURE;\n }\n \n-PRStatus\n-_MD_getsysinfo(PRSysInfo cmd, char* name, PRUint32 namelen)\n-{\n-    struct utsname info;\n+PRStatus _MD_getsysinfo(PRSysInfo cmd, char* name, PRUint32 namelen) {\n+  struct utsname info;\n \n-    PR_ASSERT((cmd == PR_SI_SYSNAME) || (cmd == PR_SI_RELEASE) ||\n-              (cmd == PR_SI_RELEASE_BUILD));\n+  PR_ASSERT((cmd == PR_SI_SYSNAME) || (cmd == PR_SI_RELEASE) ||\n+            (cmd == PR_SI_RELEASE_BUILD));\n \n-    if (uname(&info) == -1) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        return PR_FAILURE;\n-    }\n-    if (PR_SI_SYSNAME == cmd) {\n-        (void)PR_snprintf(name, namelen, info.sysname);\n-    } else if (PR_SI_RELEASE == cmd) {\n-        (void)PR_snprintf(name, namelen, info.release);\n-    } else if (PR_SI_RELEASE_BUILD == cmd) {\n-        (void)PR_snprintf(name, namelen, info.version);\n-    } else {\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  if (uname(&info) == -1) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    return PR_FAILURE;\n+  }\n+  if (PR_SI_SYSNAME == cmd) {\n+    (void)PR_snprintf(name, namelen, info.sysname);\n+  } else if (PR_SI_RELEASE == cmd) {\n+    (void)PR_snprintf(name, namelen, info.release);\n+  } else if (PR_SI_RELEASE_BUILD == cmd) {\n+    (void)PR_snprintf(name, namelen, info.version);\n+  } else {\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n /*\n@@ -3457,110 +3238,100 @@ _MD_getsysinfo(PRSysInfo cmd, char* name, PRUint32 namelen)\n  *******************************************************************\n  */\n \n-PRStatus\n-_MD_CreateFileMap(PRFileMap* fmap, PRInt64 size)\n-{\n-    PRFileInfo info;\n-    PRUint32 sz;\n-\n-    LL_L2UI(sz, size);\n-    if (sz) {\n-        if (PR_GetOpenFileInfo(fmap->fd, &info) == PR_FAILURE) {\n-            return PR_FAILURE;\n-        }\n-        if (sz > info.size) {\n-            /*\n-             * Need to extend the file\n-             */\n-            if (fmap->prot != PR_PROT_READWRITE) {\n-                PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, 0);\n-                return PR_FAILURE;\n-            }\n-            if (PR_Seek(fmap->fd, sz - 1, PR_SEEK_SET) == -1) {\n-                return PR_FAILURE;\n-            }\n-            if (PR_Write(fmap->fd, \"\", 1) != 1) {\n-                return PR_FAILURE;\n-            }\n-        }\n+PRStatus _MD_CreateFileMap(PRFileMap* fmap, PRInt64 size) {\n+  PRFileInfo info;\n+  PRUint32 sz;\n+\n+  LL_L2UI(sz, size);\n+  if (sz) {\n+    if (PR_GetOpenFileInfo(fmap->fd, &info) == PR_FAILURE) {\n+      return PR_FAILURE;\n+    }\n+    if (sz > info.size) {\n+      /*\n+       * Need to extend the file\n+       */\n+      if (fmap->prot != PR_PROT_READWRITE) {\n+        PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, 0);\n+        return PR_FAILURE;\n+      }\n+      if (PR_Seek(fmap->fd, sz - 1, PR_SEEK_SET) == -1) {\n+        return PR_FAILURE;\n+      }\n+      if (PR_Write(fmap->fd, \"\", 1) != 1) {\n+        return PR_FAILURE;\n+      }\n     }\n-    if (fmap->prot == PR_PROT_READONLY) {\n-        fmap->md.prot = PROT_READ;\n+  }\n+  if (fmap->prot == PR_PROT_READONLY) {\n+    fmap->md.prot = PROT_READ;\n #if defined(DARWIN) || defined(ANDROID)\n-        /*\n-         * This is needed on OS X because its implementation of\n-         * POSIX shared memory returns an error for MAP_PRIVATE, even\n-         * when the mapping is read-only.\n-         *\n-         * And this is needed on Android, because mapping ashmem with\n-         * MAP_PRIVATE creates a mapping of zeroed memory instead of\n-         * the shm contents.\n-         */\n-        fmap->md.flags = MAP_SHARED;\n+    /*\n+     * This is needed on OS X because its implementation of\n+     * POSIX shared memory returns an error for MAP_PRIVATE, even\n+     * when the mapping is read-only.\n+     *\n+     * And this is needed on Android, because mapping ashmem with\n+     * MAP_PRIVATE creates a mapping of zeroed memory instead of\n+     * the shm contents.\n+     */\n+    fmap->md.flags = MAP_SHARED;\n #else\n-        fmap->md.flags = MAP_PRIVATE;\n+    fmap->md.flags = MAP_PRIVATE;\n #endif\n-    } else if (fmap->prot == PR_PROT_READWRITE) {\n-        fmap->md.prot = PROT_READ | PROT_WRITE;\n-        fmap->md.flags = MAP_SHARED;\n-    } else {\n-        PR_ASSERT(fmap->prot == PR_PROT_WRITECOPY);\n-        fmap->md.prot = PROT_READ | PROT_WRITE;\n-        fmap->md.flags = MAP_PRIVATE;\n-    }\n+  } else if (fmap->prot == PR_PROT_READWRITE) {\n+    fmap->md.prot = PROT_READ | PROT_WRITE;\n+    fmap->md.flags = MAP_SHARED;\n+  } else {\n+    PR_ASSERT(fmap->prot == PR_PROT_WRITECOPY);\n+    fmap->md.prot = PROT_READ | PROT_WRITE;\n+    fmap->md.flags = MAP_PRIVATE;\n+  }\n+  return PR_SUCCESS;\n+}\n+\n+void* _MD_MemMap(PRFileMap* fmap, PRInt64 offset, PRUint32 len) {\n+  PRInt32 off;\n+  void* addr;\n+\n+  LL_L2I(off, offset);\n+  if ((addr = mmap(0, len, fmap->md.prot, fmap->md.flags,\n+                   fmap->fd->secret->md.osfd, off)) == (void*)-1) {\n+    _PR_MD_MAP_MMAP_ERROR(_MD_ERRNO());\n+    addr = NULL;\n+  }\n+  return addr;\n+}\n+\n+PRStatus _MD_MemUnmap(void* addr, PRUint32 len) {\n+  if (munmap(addr, len) == 0) {\n     return PR_SUCCESS;\n+  }\n+  _PR_MD_MAP_DEFAULT_ERROR(errno);\n+  return PR_FAILURE;\n }\n \n-void*\n-_MD_MemMap(PRFileMap* fmap, PRInt64 offset, PRUint32 len)\n-{\n-    PRInt32 off;\n-    void* addr;\n-\n-    LL_L2I(off, offset);\n-    if ((addr = mmap(0, len, fmap->md.prot, fmap->md.flags,\n-                     fmap->fd->secret->md.osfd, off)) == (void*)-1) {\n-        _PR_MD_MAP_MMAP_ERROR(_MD_ERRNO());\n-        addr = NULL;\n-    }\n-    return addr;\n-}\n-\n-PRStatus\n-_MD_MemUnmap(void* addr, PRUint32 len)\n-{\n-    if (munmap(addr, len) == 0) {\n-        return PR_SUCCESS;\n+PRStatus _MD_CloseFileMap(PRFileMap* fmap) {\n+  if (PR_TRUE == fmap->md.isAnonFM) {\n+    PRStatus rc = PR_Close(fmap->fd);\n+    if (PR_FAILURE == rc) {\n+      PR_LOG(_pr_io_lm, PR_LOG_DEBUG,\n+             (\"_MD_CloseFileMap(): error closing anonymnous file map osfd\"));\n+      return PR_FAILURE;\n     }\n-    _PR_MD_MAP_DEFAULT_ERROR(errno);\n-    return PR_FAILURE;\n+  }\n+  PR_DELETE(fmap);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_CloseFileMap(PRFileMap* fmap)\n-{\n-    if (PR_TRUE == fmap->md.isAnonFM) {\n-        PRStatus rc = PR_Close(fmap->fd);\n-        if (PR_FAILURE == rc) {\n-            PR_LOG(_pr_io_lm, PR_LOG_DEBUG,\n-                   (\"_MD_CloseFileMap(): error closing anonymnous file map osfd\"));\n-            return PR_FAILURE;\n-        }\n-    }\n-    PR_DELETE(fmap);\n+PRStatus _MD_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len) {\n+  /* msync(..., MS_SYNC) alone is sufficient to flush modified data to disk\n+   * synchronously. It is not necessary to call fsync. */\n+  if (msync(addr, len, MS_SYNC) == 0) {\n     return PR_SUCCESS;\n-}\n-\n-PRStatus\n-_MD_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len)\n-{\n-    /* msync(..., MS_SYNC) alone is sufficient to flush modified data to disk\n-     * synchronously. It is not necessary to call fsync. */\n-    if (msync(addr, len, MS_SYNC) == 0) {\n-        return PR_SUCCESS;\n-    }\n-    _PR_MD_MAP_DEFAULT_ERROR(errno);\n-    return PR_FAILURE;\n+  }\n+  _PR_MD_MAP_DEFAULT_ERROR(errno);\n+  return PR_FAILURE;\n }\n \n #if defined(_PR_NEED_FAKE_POLL)\n@@ -3570,136 +3341,134 @@ _MD_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len)\n  * that calls poll(), we emulate poll() using select().\n  */\n \n-int\n-poll(struct pollfd* filedes, unsigned long nfds, int timeout)\n-{\n-    int i;\n-    int rv;\n-    int maxfd;\n-    fd_set rd, wr, ex;\n-    struct timeval tv, *tvp;\n-\n-    if (timeout < 0 && timeout != -1) {\n-        errno = EINVAL;\n-        return -1;\n+int poll(struct pollfd* filedes, unsigned long nfds, int timeout) {\n+  int i;\n+  int rv;\n+  int maxfd;\n+  fd_set rd, wr, ex;\n+  struct timeval tv, *tvp;\n+\n+  if (timeout < 0 && timeout != -1) {\n+    errno = EINVAL;\n+    return -1;\n+  }\n+\n+  if (timeout == -1) {\n+    tvp = NULL;\n+  } else {\n+    tv.tv_sec = timeout / 1000;\n+    tv.tv_usec = (timeout % 1000) * 1000;\n+    tvp = &tv;\n+  }\n+\n+  maxfd = -1;\n+  FD_ZERO(&rd);\n+  FD_ZERO(&wr);\n+  FD_ZERO(&ex);\n+\n+  for (i = 0; i < nfds; i++) {\n+    int osfd = filedes[i].fd;\n+    int events = filedes[i].events;\n+    PRBool fdHasEvent = PR_FALSE;\n+\n+    PR_ASSERT(osfd < FD_SETSIZE);\n+    if (osfd < 0 || osfd >= FD_SETSIZE) {\n+      continue; /* Skip this osfd. */\n     }\n \n-    if (timeout == -1) {\n-        tvp = NULL;\n-    } else {\n-        tv.tv_sec = timeout / 1000;\n-        tv.tv_usec = (timeout % 1000) * 1000;\n-        tvp = &tv;\n+    /*\n+     * Map the poll events to the select fd_sets.\n+     *     POLLIN, POLLRDNORM  ===> readable\n+     *     POLLOUT, POLLWRNORM ===> writable\n+     *     POLLPRI, POLLRDBAND ===> exception\n+     *     POLLNORM, POLLWRBAND (and POLLMSG on some platforms)\n+     *     are ignored.\n+     *\n+     * The output events POLLERR and POLLHUP are never turned on.\n+     * POLLNVAL may be turned on.\n+     */\n+\n+    if (events & (POLLIN | POLLRDNORM)) {\n+      FD_SET(osfd, &rd);\n+      fdHasEvent = PR_TRUE;\n+    }\n+    if (events & (POLLOUT | POLLWRNORM)) {\n+      FD_SET(osfd, &wr);\n+      fdHasEvent = PR_TRUE;\n+    }\n+    if (events & (POLLPRI | POLLRDBAND)) {\n+      FD_SET(osfd, &ex);\n+      fdHasEvent = PR_TRUE;\n     }\n+    if (fdHasEvent && osfd > maxfd) {\n+      maxfd = osfd;\n+    }\n+  }\n \n-    maxfd = -1;\n-    FD_ZERO(&rd);\n-    FD_ZERO(&wr);\n-    FD_ZERO(&ex);\n+  rv = select(maxfd + 1, &rd, &wr, &ex, tvp);\n \n+  /* Compute poll results */\n+  if (rv > 0) {\n+    rv = 0;\n     for (i = 0; i < nfds; i++) {\n-        int osfd = filedes[i].fd;\n-        int events = filedes[i].events;\n-        PRBool fdHasEvent = PR_FALSE;\n-\n-        PR_ASSERT(osfd < FD_SETSIZE);\n-        if (osfd < 0 || osfd >= FD_SETSIZE) {\n-            continue; /* Skip this osfd. */\n-        }\n-\n-        /*\n-         * Map the poll events to the select fd_sets.\n-         *     POLLIN, POLLRDNORM  ===> readable\n-         *     POLLOUT, POLLWRNORM ===> writable\n-         *     POLLPRI, POLLRDBAND ===> exception\n-         *     POLLNORM, POLLWRBAND (and POLLMSG on some platforms)\n-         *     are ignored.\n-         *\n-         * The output events POLLERR and POLLHUP are never turned on.\n-         * POLLNVAL may be turned on.\n-         */\n-\n-        if (events & (POLLIN | POLLRDNORM)) {\n-            FD_SET(osfd, &rd);\n-            fdHasEvent = PR_TRUE;\n+      PRBool fdHasEvent = PR_FALSE;\n+\n+      filedes[i].revents = 0;\n+      if (filedes[i].fd < 0) {\n+        continue;\n+      }\n+      if (filedes[i].fd >= FD_SETSIZE) {\n+        filedes[i].revents |= POLLNVAL;\n+        continue;\n+      }\n+      if (FD_ISSET(filedes[i].fd, &rd)) {\n+        if (filedes[i].events & POLLIN) {\n+          filedes[i].revents |= POLLIN;\n         }\n-        if (events & (POLLOUT | POLLWRNORM)) {\n-            FD_SET(osfd, &wr);\n-            fdHasEvent = PR_TRUE;\n+        if (filedes[i].events & POLLRDNORM) {\n+          filedes[i].revents |= POLLRDNORM;\n         }\n-        if (events & (POLLPRI | POLLRDBAND)) {\n-            FD_SET(osfd, &ex);\n-            fdHasEvent = PR_TRUE;\n+        fdHasEvent = PR_TRUE;\n+      }\n+      if (FD_ISSET(filedes[i].fd, &wr)) {\n+        if (filedes[i].events & POLLOUT) {\n+          filedes[i].revents |= POLLOUT;\n         }\n-        if (fdHasEvent && osfd > maxfd) {\n-            maxfd = osfd;\n+        if (filedes[i].events & POLLWRNORM) {\n+          filedes[i].revents |= POLLWRNORM;\n         }\n-    }\n-\n-    rv = select(maxfd + 1, &rd, &wr, &ex, tvp);\n-\n-    /* Compute poll results */\n-    if (rv > 0) {\n-        rv = 0;\n-        for (i = 0; i < nfds; i++) {\n-            PRBool fdHasEvent = PR_FALSE;\n-\n-            filedes[i].revents = 0;\n-            if (filedes[i].fd < 0) {\n-                continue;\n-            }\n-            if (filedes[i].fd >= FD_SETSIZE) {\n-                filedes[i].revents |= POLLNVAL;\n-                continue;\n-            }\n-            if (FD_ISSET(filedes[i].fd, &rd)) {\n-                if (filedes[i].events & POLLIN) {\n-                    filedes[i].revents |= POLLIN;\n-                }\n-                if (filedes[i].events & POLLRDNORM) {\n-                    filedes[i].revents |= POLLRDNORM;\n-                }\n-                fdHasEvent = PR_TRUE;\n-            }\n-            if (FD_ISSET(filedes[i].fd, &wr)) {\n-                if (filedes[i].events & POLLOUT) {\n-                    filedes[i].revents |= POLLOUT;\n-                }\n-                if (filedes[i].events & POLLWRNORM) {\n-                    filedes[i].revents |= POLLWRNORM;\n-                }\n-                fdHasEvent = PR_TRUE;\n-            }\n-            if (FD_ISSET(filedes[i].fd, &ex)) {\n-                if (filedes[i].events & POLLPRI) {\n-                    filedes[i].revents |= POLLPRI;\n-                }\n-                if (filedes[i].events & POLLRDBAND) {\n-                    filedes[i].revents |= POLLRDBAND;\n-                }\n-                fdHasEvent = PR_TRUE;\n-            }\n-            if (fdHasEvent) {\n-                rv++;\n-            }\n+        fdHasEvent = PR_TRUE;\n+      }\n+      if (FD_ISSET(filedes[i].fd, &ex)) {\n+        if (filedes[i].events & POLLPRI) {\n+          filedes[i].revents |= POLLPRI;\n         }\n-        PR_ASSERT(rv > 0);\n-    } else if (rv == -1 && errno == EBADF) {\n-        rv = 0;\n-        for (i = 0; i < nfds; i++) {\n-            filedes[i].revents = 0;\n-            if (filedes[i].fd < 0) {\n-                continue;\n-            }\n-            if (fcntl(filedes[i].fd, F_GETFL, 0) == -1) {\n-                filedes[i].revents = POLLNVAL;\n-                rv++;\n-            }\n+        if (filedes[i].events & POLLRDBAND) {\n+          filedes[i].revents |= POLLRDBAND;\n         }\n-        PR_ASSERT(rv > 0);\n-    }\n-    PR_ASSERT(-1 != timeout || rv != 0);\n-\n-    return rv;\n+        fdHasEvent = PR_TRUE;\n+      }\n+      if (fdHasEvent) {\n+        rv++;\n+      }\n+    }\n+    PR_ASSERT(rv > 0);\n+  } else if (rv == -1 && errno == EBADF) {\n+    rv = 0;\n+    for (i = 0; i < nfds; i++) {\n+      filedes[i].revents = 0;\n+      if (filedes[i].fd < 0) {\n+        continue;\n+      }\n+      if (fcntl(filedes[i].fd, F_GETFL, 0) == -1) {\n+        filedes[i].revents = POLLNVAL;\n+        rv++;\n+      }\n+    }\n+    PR_ASSERT(rv > 0);\n+  }\n+  PR_ASSERT(-1 != timeout || rv != 0);\n+\n+  return rv;\n }\n #endif /* _PR_NEED_FAKE_POLL */\ndiff --git a/nspr/pr/src/md/unix/unix_errors.c b/nspr/pr/src/md/unix/unix_errors.c\nindex 2c76ea3..b71521c 100644\n--- a/nspr/pr/src/md/unix/unix_errors.c\n+++ b/nspr/pr/src/md/unix/unix_errors.c\n@@ -1,863 +1,746 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n \n #include \"primpl.h\"\n #if defined(_PR_POLL_AVAILABLE)\n-#include <poll.h>\n+#  include <poll.h>\n #endif\n #include <errno.h>\n \n-void\n-_MD_unix_map_default_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EACCES:\n-            prError = PR_NO_ACCESS_RIGHTS_ERROR;\n-            break;\n-        case EADDRINUSE:\n-            prError = PR_ADDRESS_IN_USE_ERROR;\n-            break;\n-        case EADDRNOTAVAIL:\n-            prError = PR_ADDRESS_NOT_AVAILABLE_ERROR;\n-            break;\n-        case EAFNOSUPPORT:\n-            prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;\n-            break;\n-        case EAGAIN:\n-            prError = PR_WOULD_BLOCK_ERROR;\n-            break;\n-            /*\n-             * On QNX and Neutrino, EALREADY is defined as EBUSY.\n-             */\n+void _MD_unix_map_default_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EACCES:\n+      prError = PR_NO_ACCESS_RIGHTS_ERROR;\n+      break;\n+    case EADDRINUSE:\n+      prError = PR_ADDRESS_IN_USE_ERROR;\n+      break;\n+    case EADDRNOTAVAIL:\n+      prError = PR_ADDRESS_NOT_AVAILABLE_ERROR;\n+      break;\n+    case EAFNOSUPPORT:\n+      prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;\n+      break;\n+    case EAGAIN:\n+      prError = PR_WOULD_BLOCK_ERROR;\n+      break;\n+      /*\n+       * On QNX and Neutrino, EALREADY is defined as EBUSY.\n+       */\n #if EALREADY != EBUSY\n-        case EALREADY:\n-            prError = PR_ALREADY_INITIATED_ERROR;\n-            break;\n+    case EALREADY:\n+      prError = PR_ALREADY_INITIATED_ERROR;\n+      break;\n #endif\n-        case EBADF:\n-            prError = PR_BAD_DESCRIPTOR_ERROR;\n-            break;\n+    case EBADF:\n+      prError = PR_BAD_DESCRIPTOR_ERROR;\n+      break;\n #ifdef EBADMSG\n-        case EBADMSG:\n-            prError = PR_IO_ERROR;\n-            break;\n+    case EBADMSG:\n+      prError = PR_IO_ERROR;\n+      break;\n #endif\n-        case EBUSY:\n-            prError = PR_FILESYSTEM_MOUNTED_ERROR;\n-            break;\n-        case ECONNABORTED:\n-            prError = PR_CONNECT_ABORTED_ERROR;\n-            break;\n-        case ECONNREFUSED:\n-            prError = PR_CONNECT_REFUSED_ERROR;\n-            break;\n-        case ECONNRESET:\n-            prError = PR_CONNECT_RESET_ERROR;\n-            break;\n-        case EDEADLK:\n-            prError = PR_DEADLOCK_ERROR;\n-            break;\n+    case EBUSY:\n+      prError = PR_FILESYSTEM_MOUNTED_ERROR;\n+      break;\n+    case ECONNABORTED:\n+      prError = PR_CONNECT_ABORTED_ERROR;\n+      break;\n+    case ECONNREFUSED:\n+      prError = PR_CONNECT_REFUSED_ERROR;\n+      break;\n+    case ECONNRESET:\n+      prError = PR_CONNECT_RESET_ERROR;\n+      break;\n+    case EDEADLK:\n+      prError = PR_DEADLOCK_ERROR;\n+      break;\n #ifdef EDIRCORRUPTED\n-        case EDIRCORRUPTED:\n-            prError = PR_DIRECTORY_CORRUPTED_ERROR;\n-            break;\n+    case EDIRCORRUPTED:\n+      prError = PR_DIRECTORY_CORRUPTED_ERROR;\n+      break;\n #endif\n #ifdef EDQUOT\n-        case EDQUOT:\n-            prError = PR_NO_DEVICE_SPACE_ERROR;\n-            break;\n+    case EDQUOT:\n+      prError = PR_NO_DEVICE_SPACE_ERROR;\n+      break;\n #endif\n-        case EEXIST:\n-            prError = PR_FILE_EXISTS_ERROR;\n-            break;\n-        case EFAULT:\n-            prError = PR_ACCESS_FAULT_ERROR;\n-            break;\n-        case EFBIG:\n-            prError = PR_FILE_TOO_BIG_ERROR;\n-            break;\n-        case EHOSTUNREACH:\n-        case EHOSTDOWN:\n-            prError = PR_HOST_UNREACHABLE_ERROR;\n-            break;\n-        case EINPROGRESS:\n-            prError = PR_IN_PROGRESS_ERROR;\n-            break;\n-        case EINTR:\n-            prError = PR_PENDING_INTERRUPT_ERROR;\n-            break;\n-        case EINVAL:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        case EIO:\n-            prError = PR_IO_ERROR;\n-            break;\n-        case EISCONN:\n-            prError = PR_IS_CONNECTED_ERROR;\n-            break;\n-        case EISDIR:\n-            prError = PR_IS_DIRECTORY_ERROR;\n-            break;\n-        case ELOOP:\n-            prError = PR_LOOP_ERROR;\n-            break;\n-        case EMFILE:\n-            prError = PR_PROC_DESC_TABLE_FULL_ERROR;\n-            break;\n-        case EMLINK:\n-            prError = PR_MAX_DIRECTORY_ENTRIES_ERROR;\n-            break;\n-        case EMSGSIZE:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n+    case EEXIST:\n+      prError = PR_FILE_EXISTS_ERROR;\n+      break;\n+    case EFAULT:\n+      prError = PR_ACCESS_FAULT_ERROR;\n+      break;\n+    case EFBIG:\n+      prError = PR_FILE_TOO_BIG_ERROR;\n+      break;\n+    case EHOSTUNREACH:\n+    case EHOSTDOWN:\n+      prError = PR_HOST_UNREACHABLE_ERROR;\n+      break;\n+    case EINPROGRESS:\n+      prError = PR_IN_PROGRESS_ERROR;\n+      break;\n+    case EINTR:\n+      prError = PR_PENDING_INTERRUPT_ERROR;\n+      break;\n+    case EINVAL:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    case EIO:\n+      prError = PR_IO_ERROR;\n+      break;\n+    case EISCONN:\n+      prError = PR_IS_CONNECTED_ERROR;\n+      break;\n+    case EISDIR:\n+      prError = PR_IS_DIRECTORY_ERROR;\n+      break;\n+    case ELOOP:\n+      prError = PR_LOOP_ERROR;\n+      break;\n+    case EMFILE:\n+      prError = PR_PROC_DESC_TABLE_FULL_ERROR;\n+      break;\n+    case EMLINK:\n+      prError = PR_MAX_DIRECTORY_ENTRIES_ERROR;\n+      break;\n+    case EMSGSIZE:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n #ifdef EMULTIHOP\n-        case EMULTIHOP:\n-            prError = PR_REMOTE_FILE_ERROR;\n-            break;\n+    case EMULTIHOP:\n+      prError = PR_REMOTE_FILE_ERROR;\n+      break;\n #endif\n-        case ENAMETOOLONG:\n-            prError = PR_NAME_TOO_LONG_ERROR;\n-            break;\n-        case ENETUNREACH:\n-            prError = PR_NETWORK_UNREACHABLE_ERROR;\n-            break;\n-        case ENFILE:\n-            prError = PR_SYS_DESC_TABLE_FULL_ERROR;\n-            break;\n-            /*\n-             * On SCO OpenServer 5, ENOBUFS is defined as ENOSR.\n-             */\n+    case ENAMETOOLONG:\n+      prError = PR_NAME_TOO_LONG_ERROR;\n+      break;\n+    case ENETUNREACH:\n+      prError = PR_NETWORK_UNREACHABLE_ERROR;\n+      break;\n+    case ENFILE:\n+      prError = PR_SYS_DESC_TABLE_FULL_ERROR;\n+      break;\n+      /*\n+       * On SCO OpenServer 5, ENOBUFS is defined as ENOSR.\n+       */\n #if defined(ENOBUFS) && (ENOBUFS != ENOSR)\n-        case ENOBUFS:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n+    case ENOBUFS:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n #endif\n-        case ENODEV:\n-            prError = PR_FILE_NOT_FOUND_ERROR;\n-            break;\n-        case ENOENT:\n-            prError = PR_FILE_NOT_FOUND_ERROR;\n-            break;\n-        case ENOLCK:\n-            prError = PR_FILE_IS_LOCKED_ERROR;\n-            break;\n+    case ENODEV:\n+      prError = PR_FILE_NOT_FOUND_ERROR;\n+      break;\n+    case ENOENT:\n+      prError = PR_FILE_NOT_FOUND_ERROR;\n+      break;\n+    case ENOLCK:\n+      prError = PR_FILE_IS_LOCKED_ERROR;\n+      break;\n #ifdef ENOLINK\n-        case ENOLINK:\n-            prError = PR_REMOTE_FILE_ERROR;\n-            break;\n+    case ENOLINK:\n+      prError = PR_REMOTE_FILE_ERROR;\n+      break;\n #endif\n-        case ENOMEM:\n-            prError = PR_OUT_OF_MEMORY_ERROR;\n-            break;\n-        case ENOPROTOOPT:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        case ENOSPC:\n-            prError = PR_NO_DEVICE_SPACE_ERROR;\n-            break;\n+    case ENOMEM:\n+      prError = PR_OUT_OF_MEMORY_ERROR;\n+      break;\n+    case ENOPROTOOPT:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    case ENOSPC:\n+      prError = PR_NO_DEVICE_SPACE_ERROR;\n+      break;\n #ifdef ENOSR\n-        case ENOSR:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n+    case ENOSR:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n #endif\n-        case ENOSYS:\n-            prError = PR_NOT_IMPLEMENTED_ERROR;\n-            break;\n-        case ENOTCONN:\n-            prError = PR_NOT_CONNECTED_ERROR;\n-            break;\n-        case ENOTDIR:\n-            prError = PR_NOT_DIRECTORY_ERROR;\n-            break;\n-        case ENOTSOCK:\n-            prError = PR_NOT_SOCKET_ERROR;\n-            break;\n-        case ENXIO:\n-            prError = PR_FILE_NOT_FOUND_ERROR;\n-            break;\n-        case EOPNOTSUPP:\n-            prError = PR_NOT_TCP_SOCKET_ERROR;\n-            break;\n+    case ENOSYS:\n+      prError = PR_NOT_IMPLEMENTED_ERROR;\n+      break;\n+    case ENOTCONN:\n+      prError = PR_NOT_CONNECTED_ERROR;\n+      break;\n+    case ENOTDIR:\n+      prError = PR_NOT_DIRECTORY_ERROR;\n+      break;\n+    case ENOTSOCK:\n+      prError = PR_NOT_SOCKET_ERROR;\n+      break;\n+    case ENXIO:\n+      prError = PR_FILE_NOT_FOUND_ERROR;\n+      break;\n+    case EOPNOTSUPP:\n+      prError = PR_NOT_TCP_SOCKET_ERROR;\n+      break;\n #ifdef EOVERFLOW\n-        case EOVERFLOW:\n-            prError = PR_BUFFER_OVERFLOW_ERROR;\n-            break;\n+    case EOVERFLOW:\n+      prError = PR_BUFFER_OVERFLOW_ERROR;\n+      break;\n #endif\n-        case EPERM:\n-            prError = PR_NO_ACCESS_RIGHTS_ERROR;\n-            break;\n-        case EPIPE:\n-            prError = PR_CONNECT_RESET_ERROR;\n-            break;\n+    case EPERM:\n+      prError = PR_NO_ACCESS_RIGHTS_ERROR;\n+      break;\n+    case EPIPE:\n+      prError = PR_CONNECT_RESET_ERROR;\n+      break;\n #ifdef EPROTO\n-        case EPROTO:\n-            prError = PR_IO_ERROR;\n-            break;\n+    case EPROTO:\n+      prError = PR_IO_ERROR;\n+      break;\n #endif\n-        case EPROTONOSUPPORT:\n-            prError = PR_PROTOCOL_NOT_SUPPORTED_ERROR;\n-            break;\n-        case EPROTOTYPE:\n-            prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;\n-            break;\n-        case ERANGE:\n-            prError = PR_INVALID_METHOD_ERROR;\n-            break;\n-        case EROFS:\n-            prError = PR_READ_ONLY_FILESYSTEM_ERROR;\n-            break;\n-        case ESPIPE:\n-            prError = PR_INVALID_METHOD_ERROR;\n-            break;\n-        case ETIMEDOUT:\n-            prError = PR_IO_TIMEOUT_ERROR;\n-            break;\n+    case EPROTONOSUPPORT:\n+      prError = PR_PROTOCOL_NOT_SUPPORTED_ERROR;\n+      break;\n+    case EPROTOTYPE:\n+      prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;\n+      break;\n+    case ERANGE:\n+      prError = PR_INVALID_METHOD_ERROR;\n+      break;\n+    case EROFS:\n+      prError = PR_READ_ONLY_FILESYSTEM_ERROR;\n+      break;\n+    case ESPIPE:\n+      prError = PR_INVALID_METHOD_ERROR;\n+      break;\n+    case ETIMEDOUT:\n+      prError = PR_IO_TIMEOUT_ERROR;\n+      break;\n #if EWOULDBLOCK != EAGAIN\n-        case EWOULDBLOCK:\n-            prError = PR_WOULD_BLOCK_ERROR;\n-            break;\n+    case EWOULDBLOCK:\n+      prError = PR_WOULD_BLOCK_ERROR;\n+      break;\n #endif\n-        case EXDEV:\n-            prError = PR_NOT_SAME_DEVICE_ERROR;\n-            break;\n-        default:\n-            prError = PR_UNKNOWN_ERROR;\n-            break;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_opendir_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n-\n-void\n-_MD_unix_map_closedir_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EINVAL:\n-            prError = PR_BAD_DESCRIPTOR_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_readdir_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case 0:\n-        case ENOENT:\n-            prError = PR_NO_MORE_FILES_ERROR;\n-            break;\n+    case EXDEV:\n+      prError = PR_NOT_SAME_DEVICE_ERROR;\n+      break;\n+    default:\n+      prError = PR_UNKNOWN_ERROR;\n+      break;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_opendir_error(int err) { _MD_unix_map_default_error(err); }\n+\n+void _MD_unix_map_closedir_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EINVAL:\n+      prError = PR_BAD_DESCRIPTOR_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_readdir_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case 0:\n+    case ENOENT:\n+      prError = PR_NO_MORE_FILES_ERROR;\n+      break;\n #ifdef EOVERFLOW\n-        case EOVERFLOW:\n-            prError = PR_IO_ERROR;\n-            break;\n+    case EOVERFLOW:\n+      prError = PR_IO_ERROR;\n+      break;\n #endif\n-        case EINVAL:\n-            prError = PR_IO_ERROR;\n-            break;\n-        case ENXIO:\n-            prError = PR_IO_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_unlink_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EPERM:\n-            prError = PR_IS_DIRECTORY_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_stat_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case ETIMEDOUT:\n-            prError = PR_REMOTE_FILE_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_fstat_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case ETIMEDOUT:\n-            prError = PR_REMOTE_FILE_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_rename_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EEXIST:\n-            prError = PR_DIRECTORY_NOT_EMPTY_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_access_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case ETIMEDOUT:\n-            prError = PR_REMOTE_FILE_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_mkdir_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n-\n-void\n-_MD_unix_map_rmdir_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        /*\n-         * On AIX 4.3, ENOTEMPTY is defined as EEXIST.\n-         */\n+    case EINVAL:\n+      prError = PR_IO_ERROR;\n+      break;\n+    case ENXIO:\n+      prError = PR_IO_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_unlink_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EPERM:\n+      prError = PR_IS_DIRECTORY_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_stat_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case ETIMEDOUT:\n+      prError = PR_REMOTE_FILE_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_fstat_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case ETIMEDOUT:\n+      prError = PR_REMOTE_FILE_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_rename_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EEXIST:\n+      prError = PR_DIRECTORY_NOT_EMPTY_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_access_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case ETIMEDOUT:\n+      prError = PR_REMOTE_FILE_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_mkdir_error(int err) { _MD_unix_map_default_error(err); }\n+\n+void _MD_unix_map_rmdir_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    /*\n+     * On AIX 4.3, ENOTEMPTY is defined as EEXIST.\n+     */\n #if ENOTEMPTY != EEXIST\n-        case ENOTEMPTY:\n-            prError = PR_DIRECTORY_NOT_EMPTY_ERROR;\n-            break;\n+    case ENOTEMPTY:\n+      prError = PR_DIRECTORY_NOT_EMPTY_ERROR;\n+      break;\n #endif\n-        case EEXIST:\n-            prError = PR_DIRECTORY_NOT_EMPTY_ERROR;\n-            break;\n-        case EINVAL:\n-            prError = PR_DIRECTORY_NOT_EMPTY_ERROR;\n-            break;\n-        case ETIMEDOUT:\n-            prError = PR_REMOTE_FILE_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_read_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EINVAL:\n-            prError = PR_INVALID_METHOD_ERROR;\n-            break;\n-        case ENXIO:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_write_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EINVAL:\n-            prError = PR_INVALID_METHOD_ERROR;\n-            break;\n-        case ENXIO:\n-            prError = PR_INVALID_METHOD_ERROR;\n-            break;\n-        case ETIMEDOUT:\n-            prError = PR_REMOTE_FILE_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_lseek_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n-\n-void\n-_MD_unix_map_fsync_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case ETIMEDOUT:\n-            prError = PR_REMOTE_FILE_ERROR;\n-            break;\n-        case EINVAL:\n-            prError = PR_INVALID_METHOD_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_close_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case ETIMEDOUT:\n-            prError = PR_REMOTE_FILE_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_socket_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case ENOMEM:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_socketavailable_error(int err)\n-{\n-    PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);\n-}\n-\n-void\n-_MD_unix_map_recv_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n-\n-void\n-_MD_unix_map_recvfrom_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n-\n-void\n-_MD_unix_map_send_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n-\n-void\n-_MD_unix_map_sendto_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n-\n-void\n-_MD_unix_map_writev_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n-\n-void\n-_MD_unix_map_accept_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case ENODEV:\n-            prError = PR_NOT_TCP_SOCKET_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_connect_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case ENXIO:\n-            prError = PR_IO_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_bind_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EINVAL:\n-            prError = PR_SOCKET_ADDRESS_IS_BOUND_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_listen_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n-\n-void\n-_MD_unix_map_shutdown_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n-\n-void\n-_MD_unix_map_socketpair_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case ENOMEM:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_getsockname_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case ENOMEM:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_getpeername_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case ENOMEM:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_getsockopt_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EINVAL:\n-            prError = PR_BUFFER_OVERFLOW_ERROR;\n-            break;\n-        case ENOMEM:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_setsockopt_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EINVAL:\n-            prError = PR_BUFFER_OVERFLOW_ERROR;\n-            break;\n-        case ENOMEM:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_open_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EAGAIN:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        case EBUSY:\n-            prError = PR_IO_ERROR;\n-            break;\n-        case ENODEV:\n-            prError = PR_FILE_NOT_FOUND_ERROR;\n-            break;\n-        case ENOMEM:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n+    case EEXIST:\n+      prError = PR_DIRECTORY_NOT_EMPTY_ERROR;\n+      break;\n+    case EINVAL:\n+      prError = PR_DIRECTORY_NOT_EMPTY_ERROR;\n+      break;\n+    case ETIMEDOUT:\n+      prError = PR_REMOTE_FILE_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_read_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EINVAL:\n+      prError = PR_INVALID_METHOD_ERROR;\n+      break;\n+    case ENXIO:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_write_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EINVAL:\n+      prError = PR_INVALID_METHOD_ERROR;\n+      break;\n+    case ENXIO:\n+      prError = PR_INVALID_METHOD_ERROR;\n+      break;\n+    case ETIMEDOUT:\n+      prError = PR_REMOTE_FILE_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_lseek_error(int err) { _MD_unix_map_default_error(err); }\n+\n+void _MD_unix_map_fsync_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case ETIMEDOUT:\n+      prError = PR_REMOTE_FILE_ERROR;\n+      break;\n+    case EINVAL:\n+      prError = PR_INVALID_METHOD_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_close_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case ETIMEDOUT:\n+      prError = PR_REMOTE_FILE_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_socket_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case ENOMEM:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_socketavailable_error(int err) {\n+  PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);\n+}\n+\n+void _MD_unix_map_recv_error(int err) { _MD_unix_map_default_error(err); }\n+\n+void _MD_unix_map_recvfrom_error(int err) { _MD_unix_map_default_error(err); }\n+\n+void _MD_unix_map_send_error(int err) { _MD_unix_map_default_error(err); }\n+\n+void _MD_unix_map_sendto_error(int err) { _MD_unix_map_default_error(err); }\n+\n+void _MD_unix_map_writev_error(int err) { _MD_unix_map_default_error(err); }\n+\n+void _MD_unix_map_accept_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case ENODEV:\n+      prError = PR_NOT_TCP_SOCKET_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_connect_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case ENXIO:\n+      prError = PR_IO_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_bind_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EINVAL:\n+      prError = PR_SOCKET_ADDRESS_IS_BOUND_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_listen_error(int err) { _MD_unix_map_default_error(err); }\n+\n+void _MD_unix_map_shutdown_error(int err) { _MD_unix_map_default_error(err); }\n+\n+void _MD_unix_map_socketpair_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case ENOMEM:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_getsockname_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case ENOMEM:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_getpeername_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case ENOMEM:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_getsockopt_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EINVAL:\n+      prError = PR_BUFFER_OVERFLOW_ERROR;\n+      break;\n+    case ENOMEM:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_setsockopt_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EINVAL:\n+      prError = PR_BUFFER_OVERFLOW_ERROR;\n+      break;\n+    case ENOMEM:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_open_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EAGAIN:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    case EBUSY:\n+      prError = PR_IO_ERROR;\n+      break;\n+    case ENODEV:\n+      prError = PR_FILE_NOT_FOUND_ERROR;\n+      break;\n+    case ENOMEM:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n #ifdef EOVERFLOW\n-        case EOVERFLOW:\n-            prError = PR_FILE_TOO_BIG_ERROR;\n-            break;\n+    case EOVERFLOW:\n+      prError = PR_FILE_TOO_BIG_ERROR;\n+      break;\n #endif\n-        case ETIMEDOUT:\n-            prError = PR_REMOTE_FILE_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_mmap_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EAGAIN:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        case EMFILE:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        case ENODEV:\n-            prError = PR_OPERATION_NOT_SUPPORTED_ERROR;\n-            break;\n-        case ENXIO:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_gethostname_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n-\n-void\n-_MD_unix_map_select_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n+    case ETIMEDOUT:\n+      prError = PR_REMOTE_FILE_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_mmap_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EAGAIN:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    case EMFILE:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    case ENODEV:\n+      prError = PR_OPERATION_NOT_SUPPORTED_ERROR;\n+      break;\n+    case ENXIO:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_gethostname_error(int err) {\n+  _MD_unix_map_default_error(err);\n+}\n+\n+void _MD_unix_map_select_error(int err) { _MD_unix_map_default_error(err); }\n \n #if defined(_PR_POLL_AVAILABLE) || defined(_PR_NEED_FAKE_POLL)\n-void\n-_MD_unix_map_poll_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EAGAIN:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_poll_revents_error(int err)\n-{\n-    if (err & POLLNVAL) {\n-        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, EBADF);\n-    } else if (err & POLLHUP) {\n-        PR_SetError(PR_CONNECT_RESET_ERROR, EPIPE);\n-    } else if (err & POLLERR) {\n-        PR_SetError(PR_IO_ERROR, EIO);\n-    } else {\n-        PR_SetError(PR_UNKNOWN_ERROR, err);\n-    }\n+void _MD_unix_map_poll_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EAGAIN:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_poll_revents_error(int err) {\n+  if (err & POLLNVAL) {\n+    PR_SetError(PR_BAD_DESCRIPTOR_ERROR, EBADF);\n+  } else if (err & POLLHUP) {\n+    PR_SetError(PR_CONNECT_RESET_ERROR, EPIPE);\n+  } else if (err & POLLERR) {\n+    PR_SetError(PR_IO_ERROR, EIO);\n+  } else {\n+    PR_SetError(PR_UNKNOWN_ERROR, err);\n+  }\n }\n #endif /* _PR_POLL_AVAILABLE || _PR_NEED_FAKE_POLL */\n \n-void\n-_MD_unix_map_flock_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EINVAL:\n-            prError = PR_BAD_DESCRIPTOR_ERROR;\n-            break;\n-        case EWOULDBLOCK:\n-            prError = PR_FILE_IS_LOCKED_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_unix_map_lockf_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EACCES:\n-            prError = PR_FILE_IS_LOCKED_ERROR;\n-            break;\n-        case EDEADLK:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n+void _MD_unix_map_flock_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EINVAL:\n+      prError = PR_BAD_DESCRIPTOR_ERROR;\n+      break;\n+    case EWOULDBLOCK:\n+      prError = PR_FILE_IS_LOCKED_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_unix_map_lockf_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EACCES:\n+      prError = PR_FILE_IS_LOCKED_ERROR;\n+      break;\n+    case EDEADLK:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n }\n \n #ifdef AIX\n-void\n-_MD_aix_map_sendfile_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n+void _MD_aix_map_sendfile_error(int err) { _MD_unix_map_default_error(err); }\n #endif /* AIX */\n \n #ifdef HPUX11\n-void\n-_MD_hpux_map_sendfile_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n+void _MD_hpux_map_sendfile_error(int err) { _MD_unix_map_default_error(err); }\n #endif /* HPUX11 */\n \n #ifdef SOLARIS\n-void\n-_MD_solaris_map_sendfile_error(int err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        /*\n-         * Solaris defines a 0 return value for sendfile to mean end-of-file.\n-         */\n-        case 0:\n-            prError = PR_END_OF_FILE_ERROR;\n-            break;\n-\n-        default:\n-            _MD_unix_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n+void _MD_solaris_map_sendfile_error(int err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    /*\n+     * Solaris defines a 0 return value for sendfile to mean end-of-file.\n+     */\n+    case 0:\n+      prError = PR_END_OF_FILE_ERROR;\n+      break;\n+\n+    default:\n+      _MD_unix_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n }\n #endif /* SOLARIS */\n \n #ifdef LINUX\n-void\n-_MD_linux_map_sendfile_error(int err)\n-{\n-    _MD_unix_map_default_error(err);\n-}\n+void _MD_linux_map_sendfile_error(int err) { _MD_unix_map_default_error(err); }\n #endif /* LINUX */\ndiff --git a/nspr/pr/src/md/unix/uxpoll.c b/nspr/pr/src/md/unix/uxpoll.c\nindex a10f8ba..bffd0d2 100644\n--- a/nspr/pr/src/md/unix/uxpoll.c\n+++ b/nspr/pr/src/md/unix/uxpoll.c\n@@ -1,602 +1,595 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n \n #if defined(_PR_PTHREADS)\n \n-#error \"This file should not be compiled\"\n+#  error \"This file should not be compiled\"\n \n #else /* defined(_PR_PTHREADS) */\n \n-#include \"primpl.h\"\n-\n-#include <sys/time.h>\n-\n-#include <fcntl.h>\n-#ifdef _PR_USE_POLL\n-#include <poll.h>\n-#endif\n-\n-#if defined(_PR_USE_POLL)\n-static PRInt32\n-NativeThreadPoll(PRPollDesc* pds, PRIntn npds,\n-                 PRIntervalTime timeout)\n-{\n-    /*\n-     * This function is mostly duplicated from ptio.s's PR_Poll().\n-     */\n-    PRInt32 ready = 0;\n-    /*\n-     * For restarting poll() if it is interrupted by a signal.\n-     * We use these variables to figure out how much time has\n-     * elapsed and how much of the timeout still remains.\n-     */\n-    PRIntn index, msecs;\n-    struct pollfd* syspoll = NULL;\n-    PRIntervalTime start, elapsed, remaining;\n-\n-    syspoll = (struct pollfd*)PR_MALLOC(npds * sizeof(struct pollfd));\n-    if (NULL == syspoll) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return -1;\n-    }\n-    for (index = 0; index < npds; ++index) {\n-        PRFileDesc* bottom;\n-        PRInt16 in_flags_read = 0, in_flags_write = 0;\n-        PRInt16 out_flags_read = 0, out_flags_write = 0;\n-\n-        if ((NULL != pds[index].fd) && (0 != pds[index].in_flags)) {\n-            if (pds[index].in_flags & PR_POLL_READ) {\n-                in_flags_read = (pds[index].fd->methods->poll)(\n-                    pds[index].fd, pds[index].in_flags & ~PR_POLL_WRITE,\n-                    &out_flags_read);\n+#  include \"primpl.h\"\n+\n+#  include <sys/time.h>\n+\n+#  include <fcntl.h>\n+#  ifdef _PR_USE_POLL\n+#    include <poll.h>\n+#  endif\n+\n+#  if defined(_PR_USE_POLL)\n+static PRInt32 NativeThreadPoll(PRPollDesc* pds, PRIntn npds,\n+                                PRIntervalTime timeout) {\n+  /*\n+   * This function is mostly duplicated from ptio.s's PR_Poll().\n+   */\n+  PRInt32 ready = 0;\n+  /*\n+   * For restarting poll() if it is interrupted by a signal.\n+   * We use these variables to figure out how much time has\n+   * elapsed and how much of the timeout still remains.\n+   */\n+  PRIntn index, msecs;\n+  struct pollfd* syspoll = NULL;\n+  PRIntervalTime start, elapsed, remaining;\n+\n+  syspoll = (struct pollfd*)PR_MALLOC(npds * sizeof(struct pollfd));\n+  if (NULL == syspoll) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return -1;\n+  }\n+  for (index = 0; index < npds; ++index) {\n+    PRFileDesc* bottom;\n+    PRInt16 in_flags_read = 0, in_flags_write = 0;\n+    PRInt16 out_flags_read = 0, out_flags_write = 0;\n+\n+    if ((NULL != pds[index].fd) && (0 != pds[index].in_flags)) {\n+      if (pds[index].in_flags & PR_POLL_READ) {\n+        in_flags_read = (pds[index].fd->methods->poll)(\n+            pds[index].fd, pds[index].in_flags & ~PR_POLL_WRITE,\n+            &out_flags_read);\n+      }\n+      if (pds[index].in_flags & PR_POLL_WRITE) {\n+        in_flags_write = (pds[index].fd->methods->poll)(\n+            pds[index].fd, pds[index].in_flags & ~PR_POLL_READ,\n+            &out_flags_write);\n+      }\n+      if ((0 != (in_flags_read & out_flags_read)) ||\n+          (0 != (in_flags_write & out_flags_write))) {\n+        /* this one is ready right now */\n+        if (0 == ready) {\n+          /*\n+           * We will return without calling the system\n+           * poll function.  So zero the out_flags\n+           * fields of all the poll descriptors before\n+           * this one.\n+           */\n+          int i;\n+          for (i = 0; i < index; i++) {\n+            pds[i].out_flags = 0;\n+          }\n+        }\n+        ready += 1;\n+        pds[index].out_flags = out_flags_read | out_flags_write;\n+      } else {\n+        pds[index].out_flags = 0; /* pre-condition */\n+        /* now locate the NSPR layer at the bottom of the stack */\n+        bottom = PR_GetIdentitiesLayer(pds[index].fd, PR_NSPR_IO_LAYER);\n+        PR_ASSERT(NULL != bottom); /* what to do about that? */\n+        if ((NULL != bottom) && (_PR_FILEDESC_OPEN == bottom->secret->state)) {\n+          if (0 == ready) {\n+            syspoll[index].fd = bottom->secret->md.osfd;\n+            syspoll[index].events = 0; /* pre-condition */\n+            if (in_flags_read & PR_POLL_READ) {\n+              pds[index].out_flags |= _PR_POLL_READ_SYS_READ;\n+              syspoll[index].events |= POLLIN;\n+            }\n+            if (in_flags_read & PR_POLL_WRITE) {\n+              pds[index].out_flags |= _PR_POLL_READ_SYS_WRITE;\n+              syspoll[index].events |= POLLOUT;\n             }\n-            if (pds[index].in_flags & PR_POLL_WRITE) {\n-                in_flags_write = (pds[index].fd->methods->poll)(\n-                    pds[index].fd, pds[index].in_flags & ~PR_POLL_READ,\n-                    &out_flags_write);\n+            if (in_flags_write & PR_POLL_READ) {\n+              pds[index].out_flags |= _PR_POLL_WRITE_SYS_READ;\n+              syspoll[index].events |= POLLIN;\n             }\n-            if ((0 != (in_flags_read & out_flags_read)) ||\n-                (0 != (in_flags_write & out_flags_write))) {\n-                /* this one is ready right now */\n-                if (0 == ready) {\n-                    /*\n-                     * We will return without calling the system\n-                     * poll function.  So zero the out_flags\n-                     * fields of all the poll descriptors before\n-                     * this one.\n-                     */\n-                    int i;\n-                    for (i = 0; i < index; i++) {\n-                        pds[i].out_flags = 0;\n-                    }\n-                }\n-                ready += 1;\n-                pds[index].out_flags = out_flags_read | out_flags_write;\n-            } else {\n-                pds[index].out_flags = 0; /* pre-condition */\n-                /* now locate the NSPR layer at the bottom of the stack */\n-                bottom = PR_GetIdentitiesLayer(pds[index].fd, PR_NSPR_IO_LAYER);\n-                PR_ASSERT(NULL != bottom); /* what to do about that? */\n-                if ((NULL != bottom) && (_PR_FILEDESC_OPEN == bottom->secret->state)) {\n-                    if (0 == ready) {\n-                        syspoll[index].fd = bottom->secret->md.osfd;\n-                        syspoll[index].events = 0; /* pre-condition */\n-                        if (in_flags_read & PR_POLL_READ) {\n-                            pds[index].out_flags |= _PR_POLL_READ_SYS_READ;\n-                            syspoll[index].events |= POLLIN;\n-                        }\n-                        if (in_flags_read & PR_POLL_WRITE) {\n-                            pds[index].out_flags |= _PR_POLL_READ_SYS_WRITE;\n-                            syspoll[index].events |= POLLOUT;\n-                        }\n-                        if (in_flags_write & PR_POLL_READ) {\n-                            pds[index].out_flags |= _PR_POLL_WRITE_SYS_READ;\n-                            syspoll[index].events |= POLLIN;\n-                        }\n-                        if (in_flags_write & PR_POLL_WRITE) {\n-                            pds[index].out_flags |= _PR_POLL_WRITE_SYS_WRITE;\n-                            syspoll[index].events |= POLLOUT;\n-                        }\n-                        if (pds[index].in_flags & PR_POLL_EXCEPT) {\n-                            syspoll[index].events |= POLLPRI;\n-                        }\n-                    }\n-                } else {\n-                    if (0 == ready) {\n-                        int i;\n-                        for (i = 0; i < index; i++) {\n-                            pds[i].out_flags = 0;\n-                        }\n-                    }\n-                    ready += 1;                          /* this will cause an abrupt return */\n-                    pds[index].out_flags = PR_POLL_NVAL; /* bogii */\n-                }\n+            if (in_flags_write & PR_POLL_WRITE) {\n+              pds[index].out_flags |= _PR_POLL_WRITE_SYS_WRITE;\n+              syspoll[index].events |= POLLOUT;\n             }\n+            if (pds[index].in_flags & PR_POLL_EXCEPT) {\n+              syspoll[index].events |= POLLPRI;\n+            }\n+          }\n         } else {\n-            /* make poll() ignore this entry */\n-            syspoll[index].fd = -1;\n-            syspoll[index].events = 0;\n-            pds[index].out_flags = 0;\n+          if (0 == ready) {\n+            int i;\n+            for (i = 0; i < index; i++) {\n+              pds[i].out_flags = 0;\n+            }\n+          }\n+          ready += 1; /* this will cause an abrupt return */\n+          pds[index].out_flags = PR_POLL_NVAL; /* bogii */\n         }\n+      }\n+    } else {\n+      /* make poll() ignore this entry */\n+      syspoll[index].fd = -1;\n+      syspoll[index].events = 0;\n+      pds[index].out_flags = 0;\n+    }\n+  }\n+\n+  if (0 == ready) {\n+    switch (timeout) {\n+      case PR_INTERVAL_NO_WAIT:\n+        msecs = 0;\n+        break;\n+      case PR_INTERVAL_NO_TIMEOUT:\n+        msecs = -1;\n+        break;\n+      default:\n+        msecs = PR_IntervalToMilliseconds(timeout);\n+        start = PR_IntervalNow();\n     }\n \n-    if (0 == ready) {\n-        switch (timeout) {\n-            case PR_INTERVAL_NO_WAIT:\n-                msecs = 0;\n-                break;\n-            case PR_INTERVAL_NO_TIMEOUT:\n-                msecs = -1;\n-                break;\n-            default:\n-                msecs = PR_IntervalToMilliseconds(timeout);\n-                start = PR_IntervalNow();\n-        }\n+  retry:\n+    ready = _MD_POLL(syspoll, npds, msecs);\n+    if (-1 == ready) {\n+      PRIntn oserror = errno;\n \n-    retry:\n-        ready = _MD_POLL(syspoll, npds, msecs);\n-        if (-1 == ready) {\n-            PRIntn oserror = errno;\n-\n-            if (EINTR == oserror) {\n-                if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-                    goto retry;\n-                } else if (timeout == PR_INTERVAL_NO_WAIT) {\n-                    ready = 0;\n-                } else {\n-                    elapsed = (PRIntervalTime)(PR_IntervalNow() - start);\n-                    if (elapsed > timeout) {\n-                        ready = 0; /* timed out */\n-                    } else {\n-                        remaining = timeout - elapsed;\n-                        msecs = PR_IntervalToMilliseconds(remaining);\n-                        goto retry;\n-                    }\n-                }\n-            } else {\n-                _PR_MD_MAP_POLL_ERROR(oserror);\n+      if (EINTR == oserror) {\n+        if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+          goto retry;\n+        } else if (timeout == PR_INTERVAL_NO_WAIT) {\n+          ready = 0;\n+        } else {\n+          elapsed = (PRIntervalTime)(PR_IntervalNow() - start);\n+          if (elapsed > timeout) {\n+            ready = 0; /* timed out */\n+          } else {\n+            remaining = timeout - elapsed;\n+            msecs = PR_IntervalToMilliseconds(remaining);\n+            goto retry;\n+          }\n+        }\n+      } else {\n+        _PR_MD_MAP_POLL_ERROR(oserror);\n+      }\n+    } else if (ready > 0) {\n+      for (index = 0; index < npds; ++index) {\n+        PRInt16 out_flags = 0;\n+        if ((NULL != pds[index].fd) && (0 != pds[index].in_flags)) {\n+          if (0 != syspoll[index].revents) {\n+            /*\n+            ** Set up the out_flags so that it contains the\n+            ** bits that the highest layer thinks are nice\n+            ** to have. Then the client of that layer will\n+            ** call the appropriate I/O function and maybe\n+            ** the protocol will make progress.\n+            */\n+            if (syspoll[index].revents & POLLIN) {\n+              if (pds[index].out_flags & _PR_POLL_READ_SYS_READ) {\n+                out_flags |= PR_POLL_READ;\n+              }\n+              if (pds[index].out_flags & _PR_POLL_WRITE_SYS_READ) {\n+                out_flags |= PR_POLL_WRITE;\n+              }\n             }\n-        } else if (ready > 0) {\n-            for (index = 0; index < npds; ++index) {\n-                PRInt16 out_flags = 0;\n-                if ((NULL != pds[index].fd) && (0 != pds[index].in_flags)) {\n-                    if (0 != syspoll[index].revents) {\n-                        /*\n-                        ** Set up the out_flags so that it contains the\n-                        ** bits that the highest layer thinks are nice\n-                        ** to have. Then the client of that layer will\n-                        ** call the appropriate I/O function and maybe\n-                        ** the protocol will make progress.\n-                        */\n-                        if (syspoll[index].revents & POLLIN) {\n-                            if (pds[index].out_flags & _PR_POLL_READ_SYS_READ) {\n-                                out_flags |= PR_POLL_READ;\n-                            }\n-                            if (pds[index].out_flags & _PR_POLL_WRITE_SYS_READ) {\n-                                out_flags |= PR_POLL_WRITE;\n-                            }\n-                        }\n-                        if (syspoll[index].revents & POLLOUT) {\n-                            if (pds[index].out_flags & _PR_POLL_READ_SYS_WRITE) {\n-                                out_flags |= PR_POLL_READ;\n-                            }\n-                            if (pds[index].out_flags & _PR_POLL_WRITE_SYS_WRITE) {\n-                                out_flags |= PR_POLL_WRITE;\n-                            }\n-                        }\n-                        if (syspoll[index].revents & POLLPRI) {\n-                            out_flags |= PR_POLL_EXCEPT;\n-                        }\n-                        if (syspoll[index].revents & POLLERR) {\n-                            out_flags |= PR_POLL_ERR;\n-                        }\n-                        if (syspoll[index].revents & POLLNVAL) {\n-                            out_flags |= PR_POLL_NVAL;\n-                        }\n-                        if (syspoll[index].revents & POLLHUP) {\n-                            out_flags |= PR_POLL_HUP;\n-                        }\n-                    }\n-                }\n-                pds[index].out_flags = out_flags;\n+            if (syspoll[index].revents & POLLOUT) {\n+              if (pds[index].out_flags & _PR_POLL_READ_SYS_WRITE) {\n+                out_flags |= PR_POLL_READ;\n+              }\n+              if (pds[index].out_flags & _PR_POLL_WRITE_SYS_WRITE) {\n+                out_flags |= PR_POLL_WRITE;\n+              }\n             }\n+            if (syspoll[index].revents & POLLPRI) {\n+              out_flags |= PR_POLL_EXCEPT;\n+            }\n+            if (syspoll[index].revents & POLLERR) {\n+              out_flags |= PR_POLL_ERR;\n+            }\n+            if (syspoll[index].revents & POLLNVAL) {\n+              out_flags |= PR_POLL_NVAL;\n+            }\n+            if (syspoll[index].revents & POLLHUP) {\n+              out_flags |= PR_POLL_HUP;\n+            }\n+          }\n         }\n+        pds[index].out_flags = out_flags;\n+      }\n     }\n+  }\n \n-    PR_DELETE(syspoll);\n-    return ready;\n+  PR_DELETE(syspoll);\n+  return ready;\n \n } /* NativeThreadPoll */\n-#endif /* defined(_PR_USE_POLL) */\n-\n-#if !defined(_PR_USE_POLL)\n-static PRInt32\n-NativeThreadSelect(PRPollDesc* pds, PRIntn npds,\n-                   PRIntervalTime timeout)\n-{\n-    /*\n-     * This code is almost a duplicate of w32poll.c's _PR_MD_PR_POLL().\n-     */\n-    fd_set rd, wt, ex;\n-    PRFileDesc* bottom;\n-    PRPollDesc *pd, *epd;\n-    PRInt32 maxfd = -1, ready, err;\n-    PRIntervalTime remaining, elapsed, start;\n-\n-    struct timeval tv, *tvp = NULL;\n-\n-    FD_ZERO(&rd);\n-    FD_ZERO(&wt);\n-    FD_ZERO(&ex);\n-\n-    ready = 0;\n-    for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n-        PRInt16 in_flags_read = 0, in_flags_write = 0;\n-        PRInt16 out_flags_read = 0, out_flags_write = 0;\n-\n-        if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n-            if (pd->in_flags & PR_POLL_READ) {\n-                in_flags_read = (pd->fd->methods->poll)(\n-                    pd->fd, pd->in_flags & ~PR_POLL_WRITE, &out_flags_read);\n+#  endif /* defined(_PR_USE_POLL) */\n+\n+#  if !defined(_PR_USE_POLL)\n+static PRInt32 NativeThreadSelect(PRPollDesc* pds, PRIntn npds,\n+                                  PRIntervalTime timeout) {\n+  /*\n+   * This code is almost a duplicate of w32poll.c's _PR_MD_PR_POLL().\n+   */\n+  fd_set rd, wt, ex;\n+  PRFileDesc* bottom;\n+  PRPollDesc *pd, *epd;\n+  PRInt32 maxfd = -1, ready, err;\n+  PRIntervalTime remaining, elapsed, start;\n+\n+  struct timeval tv, *tvp = NULL;\n+\n+  FD_ZERO(&rd);\n+  FD_ZERO(&wt);\n+  FD_ZERO(&ex);\n+\n+  ready = 0;\n+  for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n+    PRInt16 in_flags_read = 0, in_flags_write = 0;\n+    PRInt16 out_flags_read = 0, out_flags_write = 0;\n+\n+    if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n+      if (pd->in_flags & PR_POLL_READ) {\n+        in_flags_read = (pd->fd->methods->poll)(\n+            pd->fd, pd->in_flags & ~PR_POLL_WRITE, &out_flags_read);\n+      }\n+      if (pd->in_flags & PR_POLL_WRITE) {\n+        in_flags_write = (pd->fd->methods->poll)(\n+            pd->fd, pd->in_flags & ~PR_POLL_READ, &out_flags_write);\n+      }\n+      if ((0 != (in_flags_read & out_flags_read)) ||\n+          (0 != (in_flags_write & out_flags_write))) {\n+        /* this one's ready right now */\n+        if (0 == ready) {\n+          /*\n+           * We will have to return without calling the\n+           * system poll/select function.  So zero the\n+           * out_flags fields of all the poll descriptors\n+           * before this one.\n+           */\n+          PRPollDesc* prev;\n+          for (prev = pds; prev < pd; prev++) {\n+            prev->out_flags = 0;\n+          }\n+        }\n+        ready += 1;\n+        pd->out_flags = out_flags_read | out_flags_write;\n+      } else {\n+        pd->out_flags = 0; /* pre-condition */\n+\n+        /* make sure this is an NSPR supported stack */\n+        bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n+        PR_ASSERT(NULL != bottom); /* what to do about that? */\n+        if ((NULL != bottom) && (_PR_FILEDESC_OPEN == bottom->secret->state)) {\n+          if (0 == ready) {\n+            PRInt32 osfd = bottom->secret->md.osfd;\n+            if (osfd > maxfd) {\n+              maxfd = osfd;\n+            }\n+            if (in_flags_read & PR_POLL_READ) {\n+              pd->out_flags |= _PR_POLL_READ_SYS_READ;\n+              FD_SET(osfd, &rd);\n+            }\n+            if (in_flags_read & PR_POLL_WRITE) {\n+              pd->out_flags |= _PR_POLL_READ_SYS_WRITE;\n+              FD_SET(osfd, &wt);\n+            }\n+            if (in_flags_write & PR_POLL_READ) {\n+              pd->out_flags |= _PR_POLL_WRITE_SYS_READ;\n+              FD_SET(osfd, &rd);\n             }\n-            if (pd->in_flags & PR_POLL_WRITE) {\n-                in_flags_write = (pd->fd->methods->poll)(\n-                    pd->fd, pd->in_flags & ~PR_POLL_READ, &out_flags_write);\n+            if (in_flags_write & PR_POLL_WRITE) {\n+              pd->out_flags |= _PR_POLL_WRITE_SYS_WRITE;\n+              FD_SET(osfd, &wt);\n             }\n-            if ((0 != (in_flags_read & out_flags_read)) ||\n-                (0 != (in_flags_write & out_flags_write))) {\n-                /* this one's ready right now */\n-                if (0 == ready) {\n-                    /*\n-                     * We will have to return without calling the\n-                     * system poll/select function.  So zero the\n-                     * out_flags fields of all the poll descriptors\n-                     * before this one.\n-                     */\n-                    PRPollDesc* prev;\n-                    for (prev = pds; prev < pd; prev++) {\n-                        prev->out_flags = 0;\n-                    }\n-                }\n-                ready += 1;\n-                pd->out_flags = out_flags_read | out_flags_write;\n-            } else {\n-                pd->out_flags = 0; /* pre-condition */\n-\n-                /* make sure this is an NSPR supported stack */\n-                bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n-                PR_ASSERT(NULL != bottom); /* what to do about that? */\n-                if ((NULL != bottom) && (_PR_FILEDESC_OPEN == bottom->secret->state)) {\n-                    if (0 == ready) {\n-                        PRInt32 osfd = bottom->secret->md.osfd;\n-                        if (osfd > maxfd) {\n-                            maxfd = osfd;\n-                        }\n-                        if (in_flags_read & PR_POLL_READ) {\n-                            pd->out_flags |= _PR_POLL_READ_SYS_READ;\n-                            FD_SET(osfd, &rd);\n-                        }\n-                        if (in_flags_read & PR_POLL_WRITE) {\n-                            pd->out_flags |= _PR_POLL_READ_SYS_WRITE;\n-                            FD_SET(osfd, &wt);\n-                        }\n-                        if (in_flags_write & PR_POLL_READ) {\n-                            pd->out_flags |= _PR_POLL_WRITE_SYS_READ;\n-                            FD_SET(osfd, &rd);\n-                        }\n-                        if (in_flags_write & PR_POLL_WRITE) {\n-                            pd->out_flags |= _PR_POLL_WRITE_SYS_WRITE;\n-                            FD_SET(osfd, &wt);\n-                        }\n-                        if (pd->in_flags & PR_POLL_EXCEPT) {\n-                            FD_SET(osfd, &ex);\n-                        }\n-                    }\n-                } else {\n-                    if (0 == ready) {\n-                        PRPollDesc* prev;\n-                        for (prev = pds; prev < pd; prev++) {\n-                            prev->out_flags = 0;\n-                        }\n-                    }\n-                    ready += 1;                   /* this will cause an abrupt return */\n-                    pd->out_flags = PR_POLL_NVAL; /* bogii */\n-                }\n+            if (pd->in_flags & PR_POLL_EXCEPT) {\n+              FD_SET(osfd, &ex);\n             }\n+          }\n         } else {\n-            pd->out_flags = 0;\n+          if (0 == ready) {\n+            PRPollDesc* prev;\n+            for (prev = pds; prev < pd; prev++) {\n+              prev->out_flags = 0;\n+            }\n+          }\n+          ready += 1;                   /* this will cause an abrupt return */\n+          pd->out_flags = PR_POLL_NVAL; /* bogii */\n         }\n+      }\n+    } else {\n+      pd->out_flags = 0;\n     }\n+  }\n \n-    if (0 != ready) {\n-        return ready; /* no need to block */\n-    }\n+  if (0 != ready) {\n+    return ready; /* no need to block */\n+  }\n \n-    remaining = timeout;\n-    start = PR_IntervalNow();\n+  remaining = timeout;\n+  start = PR_IntervalNow();\n \n retry:\n-    if (timeout != PR_INTERVAL_NO_TIMEOUT) {\n-        PRInt32 ticksPerSecond = PR_TicksPerSecond();\n-        tv.tv_sec = remaining / ticksPerSecond;\n-        tv.tv_usec = PR_IntervalToMicroseconds(remaining % ticksPerSecond);\n-        tvp = &tv;\n+  if (timeout != PR_INTERVAL_NO_TIMEOUT) {\n+    PRInt32 ticksPerSecond = PR_TicksPerSecond();\n+    tv.tv_sec = remaining / ticksPerSecond;\n+    tv.tv_usec = PR_IntervalToMicroseconds(remaining % ticksPerSecond);\n+    tvp = &tv;\n+  }\n+\n+  ready = _MD_SELECT(maxfd + 1, &rd, &wt, &ex, tvp);\n+\n+  if (ready == -1 && errno == EINTR) {\n+    if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+      goto retry;\n+    } else {\n+      elapsed = (PRIntervalTime)(PR_IntervalNow() - start);\n+      if (elapsed > timeout) {\n+        ready = 0; /* timed out */\n+      } else {\n+        remaining = timeout - elapsed;\n+        goto retry;\n+      }\n     }\n-\n-    ready = _MD_SELECT(maxfd + 1, &rd, &wt, &ex, tvp);\n-\n-    if (ready == -1 && errno == EINTR) {\n-        if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-            goto retry;\n-        } else {\n-            elapsed = (PRIntervalTime)(PR_IntervalNow() - start);\n-            if (elapsed > timeout) {\n-                ready = 0; /* timed out */\n-            } else {\n-                remaining = timeout - elapsed;\n-                goto retry;\n-            }\n+  }\n+\n+  /*\n+  ** Now to unravel the select sets back into the client's poll\n+  ** descriptor list. Is this possibly an area for pissing away\n+  ** a few cycles or what?\n+  */\n+  if (ready > 0) {\n+    ready = 0;\n+    for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n+      PRInt16 out_flags = 0;\n+      if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n+        PRInt32 osfd;\n+        bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n+        PR_ASSERT(NULL != bottom);\n+\n+        osfd = bottom->secret->md.osfd;\n+\n+        if (FD_ISSET(osfd, &rd)) {\n+          if (pd->out_flags & _PR_POLL_READ_SYS_READ) {\n+            out_flags |= PR_POLL_READ;\n+          }\n+          if (pd->out_flags & _PR_POLL_WRITE_SYS_READ) {\n+            out_flags |= PR_POLL_WRITE;\n+          }\n         }\n-    }\n-\n-    /*\n-    ** Now to unravel the select sets back into the client's poll\n-    ** descriptor list. Is this possibly an area for pissing away\n-    ** a few cycles or what?\n-    */\n-    if (ready > 0) {\n-        ready = 0;\n-        for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n-            PRInt16 out_flags = 0;\n-            if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n-                PRInt32 osfd;\n-                bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n-                PR_ASSERT(NULL != bottom);\n-\n-                osfd = bottom->secret->md.osfd;\n-\n-                if (FD_ISSET(osfd, &rd)) {\n-                    if (pd->out_flags & _PR_POLL_READ_SYS_READ) {\n-                        out_flags |= PR_POLL_READ;\n-                    }\n-                    if (pd->out_flags & _PR_POLL_WRITE_SYS_READ) {\n-                        out_flags |= PR_POLL_WRITE;\n-                    }\n-                }\n-                if (FD_ISSET(osfd, &wt)) {\n-                    if (pd->out_flags & _PR_POLL_READ_SYS_WRITE) {\n-                        out_flags |= PR_POLL_READ;\n-                    }\n-                    if (pd->out_flags & _PR_POLL_WRITE_SYS_WRITE) {\n-                        out_flags |= PR_POLL_WRITE;\n-                    }\n-                }\n-                if (FD_ISSET(osfd, &ex)) {\n-                    out_flags |= PR_POLL_EXCEPT;\n-                }\n-            }\n-            pd->out_flags = out_flags;\n-            if (out_flags) {\n-                ready++;\n-            }\n+        if (FD_ISSET(osfd, &wt)) {\n+          if (pd->out_flags & _PR_POLL_READ_SYS_WRITE) {\n+            out_flags |= PR_POLL_READ;\n+          }\n+          if (pd->out_flags & _PR_POLL_WRITE_SYS_WRITE) {\n+            out_flags |= PR_POLL_WRITE;\n+          }\n         }\n-        PR_ASSERT(ready > 0);\n-    } else if (ready < 0) {\n-        err = _MD_ERRNO();\n-        if (err == EBADF) {\n-            /* Find the bad fds */\n-            ready = 0;\n-            for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n-                pd->out_flags = 0;\n-                if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n-                    bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n-                    if (fcntl(bottom->secret->md.osfd, F_GETFL, 0) == -1) {\n-                        pd->out_flags = PR_POLL_NVAL;\n-                        ready++;\n-                    }\n-                }\n-            }\n-            PR_ASSERT(ready > 0);\n-        } else {\n-            _PR_MD_MAP_SELECT_ERROR(err);\n+        if (FD_ISSET(osfd, &ex)) {\n+          out_flags |= PR_POLL_EXCEPT;\n         }\n+      }\n+      pd->out_flags = out_flags;\n+      if (out_flags) {\n+        ready++;\n+      }\n     }\n-\n-    return ready;\n-} /* NativeThreadSelect */\n-#endif /* !defined(_PR_USE_POLL) */\n-\n-static PRInt32\n-LocalThreads(PRPollDesc* pds, PRIntn npds,\n-             PRIntervalTime timeout)\n-{\n-    PRPollDesc *pd, *epd;\n-    PRInt32 ready, pdcnt;\n-    _PRUnixPollDesc *unixpds, *unixpd;\n-\n-    /*\n-     * XXX\n-     *        PRPollDesc has a PRFileDesc field, fd, while the IOQ\n-     *        is a list of PRPollQueue structures, each of which contains\n-     *        a _PRUnixPollDesc. A _PRUnixPollDesc struct contains\n-     *        the OS file descriptor, osfd, and not a PRFileDesc.\n-     *        So, we have allocate memory for _PRUnixPollDesc structures,\n-     *        copy the flags information from the pds list and have pq\n-     *        point to this list of _PRUnixPollDesc structures.\n-     *\n-     *        It would be better if the memory allocation can be avoided.\n-     */\n-\n-    unixpd = unixpds =\n-        (_PRUnixPollDesc*)PR_MALLOC(npds * sizeof(_PRUnixPollDesc));\n-    if (NULL == unixpds) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return -1;\n+    PR_ASSERT(ready > 0);\n+  } else if (ready < 0) {\n+    err = _MD_ERRNO();\n+    if (err == EBADF) {\n+      /* Find the bad fds */\n+      ready = 0;\n+      for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n+        pd->out_flags = 0;\n+        if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n+          bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n+          if (fcntl(bottom->secret->md.osfd, F_GETFL, 0) == -1) {\n+            pd->out_flags = PR_POLL_NVAL;\n+            ready++;\n+          }\n+        }\n+      }\n+      PR_ASSERT(ready > 0);\n+    } else {\n+      _PR_MD_MAP_SELECT_ERROR(err);\n     }\n+  }\n \n-    ready = 0;\n-    for (pdcnt = 0, pd = pds, epd = pd + npds; pd < epd; pd++) {\n-        PRFileDesc* bottom;\n-        PRInt16 in_flags_read = 0, in_flags_write = 0;\n-        PRInt16 out_flags_read = 0, out_flags_write = 0;\n-\n-        if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n-            if (pd->in_flags & PR_POLL_READ) {\n-                in_flags_read = (pd->fd->methods->poll)(\n-                    pd->fd, pd->in_flags & ~PR_POLL_WRITE, &out_flags_read);\n+  return ready;\n+} /* NativeThreadSelect */\n+#  endif /* !defined(_PR_USE_POLL) */\n+\n+static PRInt32 LocalThreads(PRPollDesc* pds, PRIntn npds,\n+                            PRIntervalTime timeout) {\n+  PRPollDesc *pd, *epd;\n+  PRInt32 ready, pdcnt;\n+  _PRUnixPollDesc *unixpds, *unixpd;\n+\n+  /*\n+   * XXX\n+   *        PRPollDesc has a PRFileDesc field, fd, while the IOQ\n+   *        is a list of PRPollQueue structures, each of which contains\n+   *        a _PRUnixPollDesc. A _PRUnixPollDesc struct contains\n+   *        the OS file descriptor, osfd, and not a PRFileDesc.\n+   *        So, we have allocate memory for _PRUnixPollDesc structures,\n+   *        copy the flags information from the pds list and have pq\n+   *        point to this list of _PRUnixPollDesc structures.\n+   *\n+   *        It would be better if the memory allocation can be avoided.\n+   */\n+\n+  unixpd = unixpds =\n+      (_PRUnixPollDesc*)PR_MALLOC(npds * sizeof(_PRUnixPollDesc));\n+  if (NULL == unixpds) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return -1;\n+  }\n+\n+  ready = 0;\n+  for (pdcnt = 0, pd = pds, epd = pd + npds; pd < epd; pd++) {\n+    PRFileDesc* bottom;\n+    PRInt16 in_flags_read = 0, in_flags_write = 0;\n+    PRInt16 out_flags_read = 0, out_flags_write = 0;\n+\n+    if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n+      if (pd->in_flags & PR_POLL_READ) {\n+        in_flags_read = (pd->fd->methods->poll)(\n+            pd->fd, pd->in_flags & ~PR_POLL_WRITE, &out_flags_read);\n+      }\n+      if (pd->in_flags & PR_POLL_WRITE) {\n+        in_flags_write = (pd->fd->methods->poll)(\n+            pd->fd, pd->in_flags & ~PR_POLL_READ, &out_flags_write);\n+      }\n+      if ((0 != (in_flags_read & out_flags_read)) ||\n+          (0 != (in_flags_write & out_flags_write))) {\n+        /* this one's ready right now */\n+        if (0 == ready) {\n+          /*\n+           * We will have to return without calling the\n+           * system poll/select function.  So zero the\n+           * out_flags fields of all the poll descriptors\n+           * before this one.\n+           */\n+          PRPollDesc* prev;\n+          for (prev = pds; prev < pd; prev++) {\n+            prev->out_flags = 0;\n+          }\n+        }\n+        ready += 1;\n+        pd->out_flags = out_flags_read | out_flags_write;\n+      } else {\n+        pd->out_flags = 0; /* pre-condition */\n+        bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n+        PR_ASSERT(NULL != bottom); /* what to do about that? */\n+        if ((NULL != bottom) && (_PR_FILEDESC_OPEN == bottom->secret->state)) {\n+          if (0 == ready) {\n+            unixpd->osfd = bottom->secret->md.osfd;\n+            unixpd->in_flags = 0;\n+            if (in_flags_read & PR_POLL_READ) {\n+              unixpd->in_flags |= _PR_UNIX_POLL_READ;\n+              pd->out_flags |= _PR_POLL_READ_SYS_READ;\n             }\n-            if (pd->in_flags & PR_POLL_WRITE) {\n-                in_flags_write = (pd->fd->methods->poll)(\n-                    pd->fd, pd->in_flags & ~PR_POLL_READ, &out_flags_write);\n+            if (in_flags_read & PR_POLL_WRITE) {\n+              unixpd->in_flags |= _PR_UNIX_POLL_WRITE;\n+              pd->out_flags |= _PR_POLL_READ_SYS_WRITE;\n             }\n-            if ((0 != (in_flags_read & out_flags_read)) ||\n-                (0 != (in_flags_write & out_flags_write))) {\n-                /* this one's ready right now */\n-                if (0 == ready) {\n-                    /*\n-                     * We will have to return without calling the\n-                     * system poll/select function.  So zero the\n-                     * out_flags fields of all the poll descriptors\n-                     * before this one.\n-                     */\n-                    PRPollDesc* prev;\n-                    for (prev = pds; prev < pd; prev++) {\n-                        prev->out_flags = 0;\n-                    }\n-                }\n-                ready += 1;\n-                pd->out_flags = out_flags_read | out_flags_write;\n-            } else {\n-                pd->out_flags = 0; /* pre-condition */\n-                bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n-                PR_ASSERT(NULL != bottom); /* what to do about that? */\n-                if ((NULL != bottom) && (_PR_FILEDESC_OPEN == bottom->secret->state)) {\n-                    if (0 == ready) {\n-                        unixpd->osfd = bottom->secret->md.osfd;\n-                        unixpd->in_flags = 0;\n-                        if (in_flags_read & PR_POLL_READ) {\n-                            unixpd->in_flags |= _PR_UNIX_POLL_READ;\n-                            pd->out_flags |= _PR_POLL_READ_SYS_READ;\n-                        }\n-                        if (in_flags_read & PR_POLL_WRITE) {\n-                            unixpd->in_flags |= _PR_UNIX_POLL_WRITE;\n-                            pd->out_flags |= _PR_POLL_READ_SYS_WRITE;\n-                        }\n-                        if (in_flags_write & PR_POLL_READ) {\n-                            unixpd->in_flags |= _PR_UNIX_POLL_READ;\n-                            pd->out_flags |= _PR_POLL_WRITE_SYS_READ;\n-                        }\n-                        if (in_flags_write & PR_POLL_WRITE) {\n-                            unixpd->in_flags |= _PR_UNIX_POLL_WRITE;\n-                            pd->out_flags |= _PR_POLL_WRITE_SYS_WRITE;\n-                        }\n-                        if ((in_flags_read | in_flags_write) & PR_POLL_EXCEPT) {\n-                            unixpd->in_flags |= _PR_UNIX_POLL_EXCEPT;\n-                        }\n-                        unixpd++;\n-                        pdcnt++;\n-                    }\n-                } else {\n-                    if (0 == ready) {\n-                        PRPollDesc* prev;\n-                        for (prev = pds; prev < pd; prev++) {\n-                            prev->out_flags = 0;\n-                        }\n-                    }\n-                    ready += 1;                   /* this will cause an abrupt return */\n-                    pd->out_flags = PR_POLL_NVAL; /* bogii */\n-                }\n+            if (in_flags_write & PR_POLL_READ) {\n+              unixpd->in_flags |= _PR_UNIX_POLL_READ;\n+              pd->out_flags |= _PR_POLL_WRITE_SYS_READ;\n             }\n-        }\n-    }\n-\n-    if (0 != ready) {\n-        /* no need to block */\n-        PR_DELETE(unixpds);\n-        return ready;\n-    }\n-\n-    ready = _PR_WaitForMultipleFDs(unixpds, pdcnt, timeout);\n-\n-    /*\n-     * Copy the out_flags from the _PRUnixPollDesc structures to the\n-     * user's PRPollDesc structures and free the allocated memory\n-     */\n-    unixpd = unixpds;\n-    for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n-        PRInt16 out_flags = 0;\n-        if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n-            /*\n-             * take errors from the poll operation,\n-             * the R/W bits from the request\n-             */\n-            if (0 != unixpd->out_flags) {\n-                if (unixpd->out_flags & _PR_UNIX_POLL_READ) {\n-                    if (pd->out_flags & _PR_POLL_READ_SYS_READ) {\n-                        out_flags |= PR_POLL_READ;\n-                    }\n-                    if (pd->out_flags & _PR_POLL_WRITE_SYS_READ) {\n-                        out_flags |= PR_POLL_WRITE;\n-                    }\n-                }\n-                if (unixpd->out_flags & _PR_UNIX_POLL_WRITE) {\n-                    if (pd->out_flags & _PR_POLL_READ_SYS_WRITE) {\n-                        out_flags |= PR_POLL_READ;\n-                    }\n-                    if (pd->out_flags & _PR_POLL_WRITE_SYS_WRITE) {\n-                        out_flags |= PR_POLL_WRITE;\n-                    }\n-                }\n-                if (unixpd->out_flags & _PR_UNIX_POLL_EXCEPT) {\n-                    out_flags |= PR_POLL_EXCEPT;\n-                }\n-                if (unixpd->out_flags & _PR_UNIX_POLL_ERR) {\n-                    out_flags |= PR_POLL_ERR;\n-                }\n-                if (unixpd->out_flags & _PR_UNIX_POLL_NVAL) {\n-                    out_flags |= PR_POLL_NVAL;\n-                }\n-                if (unixpd->out_flags & _PR_UNIX_POLL_HUP) {\n-                    out_flags |= PR_POLL_HUP;\n-                }\n+            if (in_flags_write & PR_POLL_WRITE) {\n+              unixpd->in_flags |= _PR_UNIX_POLL_WRITE;\n+              pd->out_flags |= _PR_POLL_WRITE_SYS_WRITE;\n+            }\n+            if ((in_flags_read | in_flags_write) & PR_POLL_EXCEPT) {\n+              unixpd->in_flags |= _PR_UNIX_POLL_EXCEPT;\n             }\n             unixpd++;\n+            pdcnt++;\n+          }\n+        } else {\n+          if (0 == ready) {\n+            PRPollDesc* prev;\n+            for (prev = pds; prev < pd; prev++) {\n+              prev->out_flags = 0;\n+            }\n+          }\n+          ready += 1;                   /* this will cause an abrupt return */\n+          pd->out_flags = PR_POLL_NVAL; /* bogii */\n         }\n-        pd->out_flags = out_flags;\n+      }\n     }\n+  }\n \n+  if (0 != ready) {\n+    /* no need to block */\n     PR_DELETE(unixpds);\n-\n     return ready;\n-} /* LocalThreads */\n-\n-#if defined(_PR_USE_POLL)\n-#define NativeThreads NativeThreadPoll\n-#else\n-#define NativeThreads NativeThreadSelect\n-#endif\n-\n-PRInt32\n-_MD_pr_poll(PRPollDesc* pds, PRIntn npds, PRIntervalTime timeout)\n-{\n-    PRInt32 rv = 0;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n-    }\n-    if (0 == npds) {\n-        PR_Sleep(timeout);\n-    } else if (_PR_IS_NATIVE_THREAD(me)) {\n-        rv = NativeThreads(pds, npds, timeout);\n-    } else {\n-        rv = LocalThreads(pds, npds, timeout);\n+  }\n+\n+  ready = _PR_WaitForMultipleFDs(unixpds, pdcnt, timeout);\n+\n+  /*\n+   * Copy the out_flags from the _PRUnixPollDesc structures to the\n+   * user's PRPollDesc structures and free the allocated memory\n+   */\n+  unixpd = unixpds;\n+  for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n+    PRInt16 out_flags = 0;\n+    if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n+      /*\n+       * take errors from the poll operation,\n+       * the R/W bits from the request\n+       */\n+      if (0 != unixpd->out_flags) {\n+        if (unixpd->out_flags & _PR_UNIX_POLL_READ) {\n+          if (pd->out_flags & _PR_POLL_READ_SYS_READ) {\n+            out_flags |= PR_POLL_READ;\n+          }\n+          if (pd->out_flags & _PR_POLL_WRITE_SYS_READ) {\n+            out_flags |= PR_POLL_WRITE;\n+          }\n+        }\n+        if (unixpd->out_flags & _PR_UNIX_POLL_WRITE) {\n+          if (pd->out_flags & _PR_POLL_READ_SYS_WRITE) {\n+            out_flags |= PR_POLL_READ;\n+          }\n+          if (pd->out_flags & _PR_POLL_WRITE_SYS_WRITE) {\n+            out_flags |= PR_POLL_WRITE;\n+          }\n+        }\n+        if (unixpd->out_flags & _PR_UNIX_POLL_EXCEPT) {\n+          out_flags |= PR_POLL_EXCEPT;\n+        }\n+        if (unixpd->out_flags & _PR_UNIX_POLL_ERR) {\n+          out_flags |= PR_POLL_ERR;\n+        }\n+        if (unixpd->out_flags & _PR_UNIX_POLL_NVAL) {\n+          out_flags |= PR_POLL_NVAL;\n+        }\n+        if (unixpd->out_flags & _PR_UNIX_POLL_HUP) {\n+          out_flags |= PR_POLL_HUP;\n+        }\n+      }\n+      unixpd++;\n     }\n+    pd->out_flags = out_flags;\n+  }\n+\n+  PR_DELETE(unixpds);\n+\n+  return ready;\n+} /* LocalThreads */\n \n-    return rv;\n+#  if defined(_PR_USE_POLL)\n+#    define NativeThreads NativeThreadPoll\n+#  else\n+#    define NativeThreads NativeThreadSelect\n+#  endif\n+\n+PRInt32 _MD_pr_poll(PRPollDesc* pds, PRIntn npds, PRIntervalTime timeout) {\n+  PRInt32 rv = 0;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n+  if (0 == npds) {\n+    PR_Sleep(timeout);\n+  } else if (_PR_IS_NATIVE_THREAD(me)) {\n+    rv = NativeThreads(pds, npds, timeout);\n+  } else {\n+    rv = LocalThreads(pds, npds, timeout);\n+  }\n+\n+  return rv;\n } /* _MD_pr_poll */\n \n #endif /* defined(_PR_PTHREADS) */\ndiff --git a/nspr/pr/src/md/unix/uxproces.c b/nspr/pr/src/md/unix/uxproces.c\nindex 50c8bbb..1ea075f 100644\n--- a/nspr/pr/src/md/unix/uxproces.c\n+++ b/nspr/pr/src/md/unix/uxproces.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,23 +12,22 @@\n #include <sys/wait.h>\n #include <string.h>\n #if defined(AIX)\n-#include <dlfcn.h> /* For dlopen, dlsym, dlclose */\n+#  include <dlfcn.h> /* For dlopen, dlsym, dlclose */\n #endif\n \n #if defined(DARWIN)\n-#if defined(HAVE_CRT_EXTERNS_H)\n-#include <crt_externs.h>\n-#endif\n+#  if defined(HAVE_CRT_EXTERNS_H)\n+#    include <crt_externs.h>\n+#  endif\n #else\n-PR_IMPORT_DATA(char**)\n-environ;\n+PR_IMPORT_DATA(char**) environ;\n #endif\n \n /*\n  * HP-UX 9 doesn't have the SA_RESTART flag.\n  */\n #ifndef SA_RESTART\n-#define SA_RESTART 0\n+#  define SA_RESTART 0\n #endif\n \n /*\n@@ -41,17 +41,17 @@ environ;\n #define _PR_SIGNALED_EXITSTATUS 256\n \n typedef enum pr_PidState {\n-    _PR_PID_DETACHED,\n-    _PR_PID_REAPED,\n-    _PR_PID_WAITING\n+  _PR_PID_DETACHED,\n+  _PR_PID_REAPED,\n+  _PR_PID_WAITING\n } pr_PidState;\n \n typedef struct pr_PidRecord {\n-    pid_t pid;\n-    int exitStatus;\n-    pr_PidState state;\n-    PRCondVar* reapedCV;\n-    struct pr_PidRecord* next;\n+  pid_t pid;\n+  int exitStatus;\n+  pr_PidState state;\n+  PRCondVar* reapedCV;\n+  struct pr_PidRecord* next;\n } pr_PidRecord;\n \n /*\n@@ -60,7 +60,7 @@ typedef struct pr_PidRecord {\n  */\n #if ((defined(LINUX) || defined(__GNU__) || defined(__GLIBC__)) && \\\n      defined(_PR_PTHREADS))\n-#define _PR_SHARE_CLONES\n+#  define _PR_SHARE_CLONES\n #endif\n \n /*\n@@ -75,7 +75,7 @@ typedef struct pr_PidRecord {\n #if defined(_PR_GLOBAL_THREADS_ONLY) ||                               \\\n     (defined(_PR_PTHREADS) && !defined(LINUX) && !defined(__GNU__) && \\\n      !defined(__GLIBC__))\n-#define _PR_NATIVE_THREADS\n+#  define _PR_NATIVE_THREADS\n #endif\n \n /*\n@@ -84,43 +84,41 @@ typedef struct pr_PidRecord {\n  */\n \n static struct {\n-    PRCallOnceType once;\n-    PRThread* thread;\n-    PRLock* ml;\n+  PRCallOnceType once;\n+  PRThread* thread;\n+  PRLock* ml;\n #if defined(_PR_NATIVE_THREADS)\n-    PRInt32 numProcs;\n-    PRCondVar* cv;\n+  PRInt32 numProcs;\n+  PRCondVar* cv;\n #else\n-    int pipefd[2];\n+  int pipefd[2];\n #endif\n-    pr_PidRecord** pidTable;\n+  pr_PidRecord** pidTable;\n \n #ifdef _PR_SHARE_CLONES\n-    struct pr_CreateProcOp *opHead, *opTail;\n+  struct pr_CreateProcOp *opHead, *opTail;\n #endif\n \n #ifdef AIX\n-    pid_t (*forkptr)(void); /* Newer versions of AIX (starting in 4.3.2)\n-                             * have f_fork, which is faster than the\n-                             * regular fork in a multithreaded process\n-                             * because it skips calling the fork handlers.\n-                             * So we look up the f_fork symbol to see if\n-                             * it's available and fall back on fork.\n-                             */\n-#endif                      /* AIX */\n+  pid_t (*forkptr)(void); /* Newer versions of AIX (starting in 4.3.2)\n+                           * have f_fork, which is faster than the\n+                           * regular fork in a multithreaded process\n+                           * because it skips calling the fork handlers.\n+                           * So we look up the f_fork symbol to see if\n+                           * it's available and fall back on fork.\n+                           */\n+#endif                    /* AIX */\n } pr_wp;\n \n #ifdef _PR_SHARE_CLONES\n static int pr_waitpid_daemon_exit;\n \n-void\n-_MD_unix_terminate_waitpid_daemon(void)\n-{\n-    if (pr_wp.thread) {\n-        pr_waitpid_daemon_exit = 1;\n-        write(pr_wp.pipefd[1], \"\", 1);\n-        PR_JoinThread(pr_wp.thread);\n-    }\n+void _MD_unix_terminate_waitpid_daemon(void) {\n+  if (pr_wp.thread) {\n+    pr_waitpid_daemon_exit = 1;\n+    write(pr_wp.pipefd[1], \"\", 1);\n+    PR_JoinThread(pr_wp.thread);\n+  }\n }\n #endif\n \n@@ -129,288 +127,282 @@ static PRStatus _MD_InitProcesses(void);\n static void pr_InstallSigchldHandler(void);\n #endif\n \n-static PRProcess*\n-ForkAndExec(const char* path, char* const* argv,\n-            char* const* envp, const PRProcessAttr* attr)\n-{\n-    PRProcess* process;\n-    int nEnv, idx;\n-    char* const* childEnvp;\n-    char** newEnvp = NULL;\n-    int flags;\n-\n-    process = PR_NEW(PRProcess);\n-    if (!process) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n-    }\n-\n-    childEnvp = envp;\n-    if (attr && attr->fdInheritBuffer) {\n-        PRBool found = PR_FALSE;\n-\n-        if (NULL == childEnvp) {\n+static PRProcess* ForkAndExec(const char* path, char* const* argv,\n+                              char* const* envp, const PRProcessAttr* attr) {\n+  PRProcess* process;\n+  int nEnv, idx;\n+  char* const* childEnvp;\n+  char** newEnvp = NULL;\n+  int flags;\n+\n+  process = PR_NEW(PRProcess);\n+  if (!process) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n+\n+  childEnvp = envp;\n+  if (attr && attr->fdInheritBuffer) {\n+    PRBool found = PR_FALSE;\n+\n+    if (NULL == childEnvp) {\n #ifdef DARWIN\n-#ifdef HAVE_CRT_EXTERNS_H\n-            childEnvp = *(_NSGetEnviron());\n-#else\n-            /* _NSGetEnviron() is not available on iOS. */\n-            PR_DELETE(process);\n-            PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-            return NULL;\n-#endif\n+#  ifdef HAVE_CRT_EXTERNS_H\n+      childEnvp = *(_NSGetEnviron());\n+#  else\n+      /* _NSGetEnviron() is not available on iOS. */\n+      PR_DELETE(process);\n+      PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+      return NULL;\n+#  endif\n #else\n-            childEnvp = environ;\n+      childEnvp = environ;\n #endif\n-        }\n+    }\n \n-        for (nEnv = 0; childEnvp[nEnv]; nEnv++) {\n-        }\n-        newEnvp = (char**)PR_MALLOC((nEnv + 2) * sizeof(char*));\n-        if (NULL == newEnvp) {\n-            PR_DELETE(process);\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            return NULL;\n-        }\n-        for (idx = 0; idx < nEnv; idx++) {\n-            newEnvp[idx] = childEnvp[idx];\n-            if (!found && !strncmp(newEnvp[idx], \"NSPR_INHERIT_FDS=\", 17)) {\n-                newEnvp[idx] = attr->fdInheritBuffer;\n-                found = PR_TRUE;\n-            }\n-        }\n-        if (!found) {\n-            newEnvp[idx++] = attr->fdInheritBuffer;\n-        }\n-        newEnvp[idx] = NULL;\n-        childEnvp = newEnvp;\n+    for (nEnv = 0; childEnvp[nEnv]; nEnv++) {\n+    }\n+    newEnvp = (char**)PR_MALLOC((nEnv + 2) * sizeof(char*));\n+    if (NULL == newEnvp) {\n+      PR_DELETE(process);\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      return NULL;\n+    }\n+    for (idx = 0; idx < nEnv; idx++) {\n+      newEnvp[idx] = childEnvp[idx];\n+      if (!found && !strncmp(newEnvp[idx], \"NSPR_INHERIT_FDS=\", 17)) {\n+        newEnvp[idx] = attr->fdInheritBuffer;\n+        found = PR_TRUE;\n+      }\n+    }\n+    if (!found) {\n+      newEnvp[idx++] = attr->fdInheritBuffer;\n     }\n+    newEnvp[idx] = NULL;\n+    childEnvp = newEnvp;\n+  }\n \n #ifdef AIX\n-    process->md.pid = (*pr_wp.forkptr)();\n+  process->md.pid = (*pr_wp.forkptr)();\n #elif defined(NTO)\n-    /*\n-     * fork() & exec() does not work in a multithreaded process.\n-     * Use spawn() instead.\n-     */\n-    {\n-        int fd_map[3] = { 0, 1, 2 };\n-\n-        if (attr) {\n-            if (attr->stdinFd && attr->stdinFd->secret->md.osfd != 0) {\n-                fd_map[0] = dup(attr->stdinFd->secret->md.osfd);\n-                flags = fcntl(fd_map[0], F_GETFL, 0);\n-                if (flags & O_NONBLOCK) {\n-                    fcntl(fd_map[0], F_SETFL, flags & ~O_NONBLOCK);\n-                }\n-            }\n-            if (attr->stdoutFd && attr->stdoutFd->secret->md.osfd != 1) {\n-                fd_map[1] = dup(attr->stdoutFd->secret->md.osfd);\n-                flags = fcntl(fd_map[1], F_GETFL, 0);\n-                if (flags & O_NONBLOCK) {\n-                    fcntl(fd_map[1], F_SETFL, flags & ~O_NONBLOCK);\n-                }\n-            }\n-            if (attr->stderrFd && attr->stderrFd->secret->md.osfd != 2) {\n-                fd_map[2] = dup(attr->stderrFd->secret->md.osfd);\n-                flags = fcntl(fd_map[2], F_GETFL, 0);\n-                if (flags & O_NONBLOCK) {\n-                    fcntl(fd_map[2], F_SETFL, flags & ~O_NONBLOCK);\n-                }\n-            }\n-\n-            PR_ASSERT(attr->currentDirectory == NULL); /* not implemented */\n+  /*\n+   * fork() & exec() does not work in a multithreaded process.\n+   * Use spawn() instead.\n+   */\n+  {\n+    int fd_map[3] = {0, 1, 2};\n+\n+    if (attr) {\n+      if (attr->stdinFd && attr->stdinFd->secret->md.osfd != 0) {\n+        fd_map[0] = dup(attr->stdinFd->secret->md.osfd);\n+        flags = fcntl(fd_map[0], F_GETFL, 0);\n+        if (flags & O_NONBLOCK) {\n+          fcntl(fd_map[0], F_SETFL, flags & ~O_NONBLOCK);\n         }\n-\n-        process->md.pid = spawn(path, 3, fd_map, NULL, argv, childEnvp);\n-\n-        if (fd_map[0] != 0) {\n-            close(fd_map[0]);\n+      }\n+      if (attr->stdoutFd && attr->stdoutFd->secret->md.osfd != 1) {\n+        fd_map[1] = dup(attr->stdoutFd->secret->md.osfd);\n+        flags = fcntl(fd_map[1], F_GETFL, 0);\n+        if (flags & O_NONBLOCK) {\n+          fcntl(fd_map[1], F_SETFL, flags & ~O_NONBLOCK);\n         }\n-        if (fd_map[1] != 1) {\n-            close(fd_map[1]);\n-        }\n-        if (fd_map[2] != 2) {\n-            close(fd_map[2]);\n+      }\n+      if (attr->stderrFd && attr->stderrFd->secret->md.osfd != 2) {\n+        fd_map[2] = dup(attr->stderrFd->secret->md.osfd);\n+        flags = fcntl(fd_map[2], F_GETFL, 0);\n+        if (flags & O_NONBLOCK) {\n+          fcntl(fd_map[2], F_SETFL, flags & ~O_NONBLOCK);\n         }\n+      }\n+\n+      PR_ASSERT(attr->currentDirectory == NULL); /* not implemented */\n+    }\n+\n+    process->md.pid = spawn(path, 3, fd_map, NULL, argv, childEnvp);\n+\n+    if (fd_map[0] != 0) {\n+      close(fd_map[0]);\n+    }\n+    if (fd_map[1] != 1) {\n+      close(fd_map[1]);\n     }\n+    if (fd_map[2] != 2) {\n+      close(fd_map[2]);\n+    }\n+  }\n #else\n-    process->md.pid = fork();\n+  process->md.pid = fork();\n #endif\n-    if ((pid_t)-1 == process->md.pid) {\n-        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, errno);\n-        PR_DELETE(process);\n-        if (newEnvp) {\n-            PR_DELETE(newEnvp);\n-        }\n-        return NULL;\n+  if ((pid_t)-1 == process->md.pid) {\n+    PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, errno);\n+    PR_DELETE(process);\n+    if (newEnvp) {\n+      PR_DELETE(newEnvp);\n     }\n-    if (0 == process->md.pid) { /* the child process */\n-                                /*\n-                                 * If the child process needs to exit, it must call _exit().\n-                                 * Do not call exit(), because exit() will flush and close\n-                                 * the standard I/O file descriptors, and hence corrupt\n-                                 * the parent process's standard I/O data structures.\n-                                 */\n+    return NULL;\n+  }\n+  if (0 == process->md.pid) { /* the child process */\n+                              /*\n+                               * If the child process needs to exit, it must call _exit().\n+                               * Do not call exit(), because exit() will flush and close\n+                               * the standard I/O file descriptors, and hence corrupt\n+                               * the parent process's standard I/O data structures.\n+                               */\n \n #if !defined(NTO)\n-        if (attr) {\n-            /* the osfd's to redirect stdin, stdout, and stderr to */\n-            int in_osfd = -1, out_osfd = -1, err_osfd = -1;\n-\n-            if (attr->stdinFd && attr->stdinFd->secret->md.osfd != 0) {\n-                in_osfd = attr->stdinFd->secret->md.osfd;\n-                if (dup2(in_osfd, 0) != 0) {\n-                    _exit(1); /* failed */\n-                }\n-                flags = fcntl(0, F_GETFL, 0);\n-                if (flags & O_NONBLOCK) {\n-                    fcntl(0, F_SETFL, flags & ~O_NONBLOCK);\n-                }\n-            }\n-            if (attr->stdoutFd && attr->stdoutFd->secret->md.osfd != 1) {\n-                out_osfd = attr->stdoutFd->secret->md.osfd;\n-                if (dup2(out_osfd, 1) != 1) {\n-                    _exit(1); /* failed */\n-                }\n-                flags = fcntl(1, F_GETFL, 0);\n-                if (flags & O_NONBLOCK) {\n-                    fcntl(1, F_SETFL, flags & ~O_NONBLOCK);\n-                }\n-            }\n-            if (attr->stderrFd && attr->stderrFd->secret->md.osfd != 2) {\n-                err_osfd = attr->stderrFd->secret->md.osfd;\n-                if (dup2(err_osfd, 2) != 2) {\n-                    _exit(1); /* failed */\n-                }\n-                flags = fcntl(2, F_GETFL, 0);\n-                if (flags & O_NONBLOCK) {\n-                    fcntl(2, F_SETFL, flags & ~O_NONBLOCK);\n-                }\n-            }\n-            if (in_osfd != -1) {\n-                close(in_osfd);\n-            }\n-            if (out_osfd != -1 && out_osfd != in_osfd) {\n-                close(out_osfd);\n-            }\n-            if (err_osfd != -1 && err_osfd != in_osfd && err_osfd != out_osfd) {\n-                close(err_osfd);\n-            }\n-            if (attr->currentDirectory) {\n-                if (chdir(attr->currentDirectory) < 0) {\n-                    _exit(1); /* failed */\n-                }\n-            }\n+    if (attr) {\n+      /* the osfd's to redirect stdin, stdout, and stderr to */\n+      int in_osfd = -1, out_osfd = -1, err_osfd = -1;\n+\n+      if (attr->stdinFd && attr->stdinFd->secret->md.osfd != 0) {\n+        in_osfd = attr->stdinFd->secret->md.osfd;\n+        if (dup2(in_osfd, 0) != 0) {\n+          _exit(1); /* failed */\n         }\n-\n-        if (childEnvp) {\n-            (void)execve(path, argv, childEnvp);\n-        } else {\n-            /* Inherit the environment of the parent. */\n-            (void)execv(path, argv);\n+        flags = fcntl(0, F_GETFL, 0);\n+        if (flags & O_NONBLOCK) {\n+          fcntl(0, F_SETFL, flags & ~O_NONBLOCK);\n         }\n-        /* Whoops! It returned. That's a bad sign. */\n-        _exit(1);\n-#endif /* !NTO */\n+      }\n+      if (attr->stdoutFd && attr->stdoutFd->secret->md.osfd != 1) {\n+        out_osfd = attr->stdoutFd->secret->md.osfd;\n+        if (dup2(out_osfd, 1) != 1) {\n+          _exit(1); /* failed */\n+        }\n+        flags = fcntl(1, F_GETFL, 0);\n+        if (flags & O_NONBLOCK) {\n+          fcntl(1, F_SETFL, flags & ~O_NONBLOCK);\n+        }\n+      }\n+      if (attr->stderrFd && attr->stderrFd->secret->md.osfd != 2) {\n+        err_osfd = attr->stderrFd->secret->md.osfd;\n+        if (dup2(err_osfd, 2) != 2) {\n+          _exit(1); /* failed */\n+        }\n+        flags = fcntl(2, F_GETFL, 0);\n+        if (flags & O_NONBLOCK) {\n+          fcntl(2, F_SETFL, flags & ~O_NONBLOCK);\n+        }\n+      }\n+      if (in_osfd != -1) {\n+        close(in_osfd);\n+      }\n+      if (out_osfd != -1 && out_osfd != in_osfd) {\n+        close(out_osfd);\n+      }\n+      if (err_osfd != -1 && err_osfd != in_osfd && err_osfd != out_osfd) {\n+        close(err_osfd);\n+      }\n+      if (attr->currentDirectory) {\n+        if (chdir(attr->currentDirectory) < 0) {\n+          _exit(1); /* failed */\n+        }\n+      }\n     }\n \n-    if (newEnvp) {\n-        PR_DELETE(newEnvp);\n+    if (childEnvp) {\n+      (void)execve(path, argv, childEnvp);\n+    } else {\n+      /* Inherit the environment of the parent. */\n+      (void)execv(path, argv);\n     }\n+    /* Whoops! It returned. That's a bad sign. */\n+    _exit(1);\n+#endif /* !NTO */\n+  }\n+\n+  if (newEnvp) {\n+    PR_DELETE(newEnvp);\n+  }\n \n #if defined(_PR_NATIVE_THREADS)\n-    PR_Lock(pr_wp.ml);\n-    if (0 == pr_wp.numProcs++) {\n-        PR_NotifyCondVar(pr_wp.cv);\n-    }\n-    PR_Unlock(pr_wp.ml);\n+  PR_Lock(pr_wp.ml);\n+  if (0 == pr_wp.numProcs++) {\n+    PR_NotifyCondVar(pr_wp.cv);\n+  }\n+  PR_Unlock(pr_wp.ml);\n #endif\n-    return process;\n+  return process;\n }\n \n #ifdef _PR_SHARE_CLONES\n \n struct pr_CreateProcOp {\n-    const char* path;\n-    char* const* argv;\n-    char* const* envp;\n-    const PRProcessAttr* attr;\n-    PRProcess* process;\n-    PRErrorCode prerror;\n-    PRInt32 oserror;\n-    PRBool done;\n-    PRCondVar* doneCV;\n-    struct pr_CreateProcOp* next;\n+  const char* path;\n+  char* const* argv;\n+  char* const* envp;\n+  const PRProcessAttr* attr;\n+  PRProcess* process;\n+  PRErrorCode prerror;\n+  PRInt32 oserror;\n+  PRBool done;\n+  PRCondVar* doneCV;\n+  struct pr_CreateProcOp* next;\n };\n \n-PRProcess*\n-_MD_CreateUnixProcess(const char* path, char* const* argv,\n-                      char* const* envp, const PRProcessAttr* attr)\n-{\n-    struct pr_CreateProcOp* op;\n-    PRProcess* proc;\n-    int rv;\n-\n-    if (PR_CallOnce(&pr_wp.once, _MD_InitProcesses) == PR_FAILURE) {\n-        return NULL;\n-    }\n-\n-    op = PR_NEW(struct pr_CreateProcOp);\n-    if (NULL == op) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n-    }\n-    op->path = path;\n-    op->argv = argv;\n-    op->envp = envp;\n-    op->attr = attr;\n-    op->done = PR_FALSE;\n-    op->doneCV = PR_NewCondVar(pr_wp.ml);\n-    if (NULL == op->doneCV) {\n-        PR_DELETE(op);\n-        return NULL;\n-    }\n-    PR_Lock(pr_wp.ml);\n-\n-    /* add to the tail of op queue */\n-    op->next = NULL;\n-    if (pr_wp.opTail) {\n-        pr_wp.opTail->next = op;\n-        pr_wp.opTail = op;\n-    } else {\n-        PR_ASSERT(NULL == pr_wp.opHead);\n-        pr_wp.opHead = pr_wp.opTail = op;\n-    }\n-\n-    /* wake up the daemon thread */\n-    do {\n-        rv = write(pr_wp.pipefd[1], \"\", 1);\n-    } while (-1 == rv && EINTR == errno);\n-\n-    while (op->done == PR_FALSE) {\n-        PR_WaitCondVar(op->doneCV, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_Unlock(pr_wp.ml);\n-    PR_DestroyCondVar(op->doneCV);\n-    proc = op->process;\n-    if (!proc) {\n-        PR_SetError(op->prerror, op->oserror);\n-    }\n+PRProcess* _MD_CreateUnixProcess(const char* path, char* const* argv,\n+                                 char* const* envp, const PRProcessAttr* attr) {\n+  struct pr_CreateProcOp* op;\n+  PRProcess* proc;\n+  int rv;\n+\n+  if (PR_CallOnce(&pr_wp.once, _MD_InitProcesses) == PR_FAILURE) {\n+    return NULL;\n+  }\n+\n+  op = PR_NEW(struct pr_CreateProcOp);\n+  if (NULL == op) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n+  op->path = path;\n+  op->argv = argv;\n+  op->envp = envp;\n+  op->attr = attr;\n+  op->done = PR_FALSE;\n+  op->doneCV = PR_NewCondVar(pr_wp.ml);\n+  if (NULL == op->doneCV) {\n     PR_DELETE(op);\n-    return proc;\n+    return NULL;\n+  }\n+  PR_Lock(pr_wp.ml);\n+\n+  /* add to the tail of op queue */\n+  op->next = NULL;\n+  if (pr_wp.opTail) {\n+    pr_wp.opTail->next = op;\n+    pr_wp.opTail = op;\n+  } else {\n+    PR_ASSERT(NULL == pr_wp.opHead);\n+    pr_wp.opHead = pr_wp.opTail = op;\n+  }\n+\n+  /* wake up the daemon thread */\n+  do {\n+    rv = write(pr_wp.pipefd[1], \"\", 1);\n+  } while (-1 == rv && EINTR == errno);\n+\n+  while (op->done == PR_FALSE) {\n+    PR_WaitCondVar(op->doneCV, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_Unlock(pr_wp.ml);\n+  PR_DestroyCondVar(op->doneCV);\n+  proc = op->process;\n+  if (!proc) {\n+    PR_SetError(op->prerror, op->oserror);\n+  }\n+  PR_DELETE(op);\n+  return proc;\n }\n \n #else /* ! _PR_SHARE_CLONES */\n \n-PRProcess*\n-_MD_CreateUnixProcess(const char* path, char* const* argv,\n-                      char* const* envp, const PRProcessAttr* attr)\n-{\n-    if (PR_CallOnce(&pr_wp.once, _MD_InitProcesses) == PR_FAILURE) {\n-        return NULL;\n-    }\n-    return ForkAndExec(path, argv, envp, attr);\n+PRProcess* _MD_CreateUnixProcess(const char* path, char* const* argv,\n+                                 char* const* envp, const PRProcessAttr* attr) {\n+  if (PR_CallOnce(&pr_wp.once, _MD_InitProcesses) == PR_FAILURE) {\n+    return NULL;\n+  }\n+  return ForkAndExec(path, argv, envp, attr);\n } /* _MD_CreateUnixProcess */\n \n #endif /* _PR_SHARE_CLONES */\n@@ -424,100 +416,90 @@ _MD_CreateUnixProcess(const char* path, char* const* argv,\n #define NBUCKETS (1 << NBUCKETS_LOG2)\n #define PID_HASH_MASK ((pid_t)(NBUCKETS - 1))\n \n-static pr_PidRecord*\n-FindPidTable(pid_t pid)\n-{\n-    pr_PidRecord* pRec;\n-    int keyHash = (int)(pid & PID_HASH_MASK);\n+static pr_PidRecord* FindPidTable(pid_t pid) {\n+  pr_PidRecord* pRec;\n+  int keyHash = (int)(pid & PID_HASH_MASK);\n \n-    pRec = pr_wp.pidTable[keyHash];\n-    while (pRec) {\n-        if (pRec->pid == pid) {\n-            break;\n-        }\n-        pRec = pRec->next;\n+  pRec = pr_wp.pidTable[keyHash];\n+  while (pRec) {\n+    if (pRec->pid == pid) {\n+      break;\n     }\n-    return pRec;\n+    pRec = pRec->next;\n+  }\n+  return pRec;\n }\n \n-static void\n-InsertPidTable(pr_PidRecord* pRec)\n-{\n-    int keyHash = (int)(pRec->pid & PID_HASH_MASK);\n+static void InsertPidTable(pr_PidRecord* pRec) {\n+  int keyHash = (int)(pRec->pid & PID_HASH_MASK);\n \n-    pRec->next = pr_wp.pidTable[keyHash];\n-    pr_wp.pidTable[keyHash] = pRec;\n+  pRec->next = pr_wp.pidTable[keyHash];\n+  pr_wp.pidTable[keyHash] = pRec;\n }\n \n-static void\n-DeletePidTable(pr_PidRecord* pRec)\n-{\n-    int keyHash = (int)(pRec->pid & PID_HASH_MASK);\n-\n-    if (pr_wp.pidTable[keyHash] == pRec) {\n-        pr_wp.pidTable[keyHash] = pRec->next;\n-    } else {\n-        pr_PidRecord *pred, *cur; /* predecessor and current */\n-\n-        pred = pr_wp.pidTable[keyHash];\n-        cur = pred->next;\n-        while (cur) {\n-            if (cur == pRec) {\n-                pred->next = cur->next;\n-                break;\n-            }\n-            pred = cur;\n-            cur = cur->next;\n-        }\n-        PR_ASSERT(cur != NULL);\n+static void DeletePidTable(pr_PidRecord* pRec) {\n+  int keyHash = (int)(pRec->pid & PID_HASH_MASK);\n+\n+  if (pr_wp.pidTable[keyHash] == pRec) {\n+    pr_wp.pidTable[keyHash] = pRec->next;\n+  } else {\n+    pr_PidRecord *pred, *cur; /* predecessor and current */\n+\n+    pred = pr_wp.pidTable[keyHash];\n+    cur = pred->next;\n+    while (cur) {\n+      if (cur == pRec) {\n+        pred->next = cur->next;\n+        break;\n+      }\n+      pred = cur;\n+      cur = cur->next;\n     }\n+    PR_ASSERT(cur != NULL);\n+  }\n }\n \n-static int\n-ExtractExitStatus(int rawExitStatus)\n-{\n-    /*\n-     * We did not specify the WCONTINUED and WUNTRACED options\n-     * for waitpid, so these two events should not be reported.\n-     */\n-    PR_ASSERT(!WIFSTOPPED(rawExitStatus));\n+static int ExtractExitStatus(int rawExitStatus) {\n+  /*\n+   * We did not specify the WCONTINUED and WUNTRACED options\n+   * for waitpid, so these two events should not be reported.\n+   */\n+  PR_ASSERT(!WIFSTOPPED(rawExitStatus));\n #ifdef WIFCONTINUED\n-    PR_ASSERT(!WIFCONTINUED(rawExitStatus));\n+  PR_ASSERT(!WIFCONTINUED(rawExitStatus));\n #endif\n-    if (WIFEXITED(rawExitStatus)) {\n-        return WEXITSTATUS(rawExitStatus);\n-    }\n-    PR_ASSERT(WIFSIGNALED(rawExitStatus));\n-    return _PR_SIGNALED_EXITSTATUS;\n+  if (WIFEXITED(rawExitStatus)) {\n+    return WEXITSTATUS(rawExitStatus);\n+  }\n+  PR_ASSERT(WIFSIGNALED(rawExitStatus));\n+  return _PR_SIGNALED_EXITSTATUS;\n }\n \n-static void\n-ProcessReapedChildInternal(pid_t pid, int status)\n-{\n-    pr_PidRecord* pRec;\n-\n-    pRec = FindPidTable(pid);\n-    if (NULL == pRec) {\n-        pRec = PR_NEW(pr_PidRecord);\n-        pRec->pid = pid;\n-        pRec->state = _PR_PID_REAPED;\n-        pRec->exitStatus = ExtractExitStatus(status);\n-        pRec->reapedCV = NULL;\n-        InsertPidTable(pRec);\n+static void ProcessReapedChildInternal(pid_t pid, int status) {\n+  pr_PidRecord* pRec;\n+\n+  pRec = FindPidTable(pid);\n+  if (NULL == pRec) {\n+    pRec = PR_NEW(pr_PidRecord);\n+    pRec->pid = pid;\n+    pRec->state = _PR_PID_REAPED;\n+    pRec->exitStatus = ExtractExitStatus(status);\n+    pRec->reapedCV = NULL;\n+    InsertPidTable(pRec);\n+  } else {\n+    PR_ASSERT(pRec->state != _PR_PID_REAPED);\n+    if (_PR_PID_DETACHED == pRec->state) {\n+      PR_ASSERT(NULL == pRec->reapedCV);\n+      DeletePidTable(pRec);\n+      PR_DELETE(pRec);\n     } else {\n-        PR_ASSERT(pRec->state != _PR_PID_REAPED);\n-        if (_PR_PID_DETACHED == pRec->state) {\n-            PR_ASSERT(NULL == pRec->reapedCV);\n-            DeletePidTable(pRec);\n-            PR_DELETE(pRec);\n-        } else {\n-            PR_ASSERT(_PR_PID_WAITING == pRec->state);\n-            PR_ASSERT(NULL != pRec->reapedCV);\n-            pRec->exitStatus = ExtractExitStatus(status);\n-            pRec->state = _PR_PID_REAPED;\n-            PR_NotifyCondVar(pRec->reapedCV);\n-        }\n+      PR_ASSERT(_PR_PID_WAITING == pRec->state);\n+      PR_ASSERT(NULL != pRec->reapedCV);\n+      pRec->exitStatus = ExtractExitStatus(status);\n+      pRec->state = _PR_PID_REAPED;\n+      PR_NotifyCondVar(pRec->reapedCV);\n     }\n+  }\n }\n \n #if defined(_PR_NATIVE_THREADS)\n@@ -528,342 +510,326 @@ ProcessReapedChildInternal(pid_t pid, int status)\n  * just have the daemon thread block in waitpid().\n  */\n \n-static void\n-WaitPidDaemonThread(void* unused)\n-{\n-    pid_t pid;\n-    int status;\n+static void WaitPidDaemonThread(void* unused) {\n+  pid_t pid;\n+  int status;\n+\n+  while (1) {\n+    PR_Lock(pr_wp.ml);\n+    while (0 == pr_wp.numProcs) {\n+      PR_WaitCondVar(pr_wp.cv, PR_INTERVAL_NO_TIMEOUT);\n+    }\n+    PR_Unlock(pr_wp.ml);\n \n     while (1) {\n-        PR_Lock(pr_wp.ml);\n-        while (0 == pr_wp.numProcs) {\n-            PR_WaitCondVar(pr_wp.cv, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        PR_Unlock(pr_wp.ml);\n-\n-        while (1) {\n-            do {\n-                pid = waitpid((pid_t)-1, &status, 0);\n-            } while ((pid_t)-1 == pid && EINTR == errno);\n-\n-            /*\n-             * waitpid() cannot return 0 because we did not invoke it\n-             * with the WNOHANG option.\n-             */\n-            PR_ASSERT(0 != pid);\n-\n-            /*\n-             * The only possible error code is ECHILD.  But if we do\n-             * our accounting correctly, we should only call waitpid()\n-             * when there is a child process to wait for.\n-             */\n-            PR_ASSERT((pid_t)-1 != pid);\n-            if ((pid_t)-1 == pid) {\n-                break;\n-            }\n-\n-            PR_Lock(pr_wp.ml);\n-            ProcessReapedChildInternal(pid, status);\n-            pr_wp.numProcs--;\n-            while (0 == pr_wp.numProcs) {\n-                PR_WaitCondVar(pr_wp.cv, PR_INTERVAL_NO_TIMEOUT);\n-            }\n-            PR_Unlock(pr_wp.ml);\n-        }\n+      do {\n+        pid = waitpid((pid_t)-1, &status, 0);\n+      } while ((pid_t)-1 == pid && EINTR == errno);\n+\n+      /*\n+       * waitpid() cannot return 0 because we did not invoke it\n+       * with the WNOHANG option.\n+       */\n+      PR_ASSERT(0 != pid);\n+\n+      /*\n+       * The only possible error code is ECHILD.  But if we do\n+       * our accounting correctly, we should only call waitpid()\n+       * when there is a child process to wait for.\n+       */\n+      PR_ASSERT((pid_t)-1 != pid);\n+      if ((pid_t)-1 == pid) {\n+        break;\n+      }\n+\n+      PR_Lock(pr_wp.ml);\n+      ProcessReapedChildInternal(pid, status);\n+      pr_wp.numProcs--;\n+      while (0 == pr_wp.numProcs) {\n+        PR_WaitCondVar(pr_wp.cv, PR_INTERVAL_NO_TIMEOUT);\n+      }\n+      PR_Unlock(pr_wp.ml);\n     }\n+  }\n }\n \n #else /* _PR_NATIVE_THREADS */\n \n-static void\n-WaitPidDaemonThread(void* unused)\n-{\n-    PRPollDesc pd;\n-    PRFileDesc* fd;\n-    int rv;\n-    char buf[128];\n-    pid_t pid;\n-    int status;\n-#ifdef _PR_SHARE_CLONES\n-    struct pr_CreateProcOp* op;\n-#endif\n-\n-#ifdef _PR_SHARE_CLONES\n-    pr_InstallSigchldHandler();\n-#endif\n+static void WaitPidDaemonThread(void* unused) {\n+  PRPollDesc pd;\n+  PRFileDesc* fd;\n+  int rv;\n+  char buf[128];\n+  pid_t pid;\n+  int status;\n+#  ifdef _PR_SHARE_CLONES\n+  struct pr_CreateProcOp* op;\n+#  endif\n+\n+#  ifdef _PR_SHARE_CLONES\n+  pr_InstallSigchldHandler();\n+#  endif\n+\n+  fd = PR_ImportFile(pr_wp.pipefd[0]);\n+  PR_ASSERT(NULL != fd);\n+  pd.fd = fd;\n+  pd.in_flags = PR_POLL_READ;\n+\n+  while (1) {\n+    rv = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n+    PR_ASSERT(1 == rv);\n+\n+#  ifdef _PR_SHARE_CLONES\n+    if (pr_waitpid_daemon_exit) {\n+      return;\n+    }\n+    PR_Lock(pr_wp.ml);\n+#  endif\n \n-    fd = PR_ImportFile(pr_wp.pipefd[0]);\n-    PR_ASSERT(NULL != fd);\n-    pd.fd = fd;\n-    pd.in_flags = PR_POLL_READ;\n+    do {\n+      rv = read(pr_wp.pipefd[0], buf, sizeof(buf));\n+    } while (sizeof(buf) == rv || (-1 == rv && EINTR == errno));\n+\n+#  ifdef _PR_SHARE_CLONES\n+    while ((op = pr_wp.opHead) != NULL) {\n+      PR_Unlock(pr_wp.ml);\n+      op->process = ForkAndExec(op->path, op->argv, op->envp, op->attr);\n+      if (NULL == op->process) {\n+        op->prerror = PR_GetError();\n+        op->oserror = PR_GetOSError();\n+      }\n+      PR_Lock(pr_wp.ml);\n+      pr_wp.opHead = op->next;\n+      if (NULL == pr_wp.opHead) {\n+        pr_wp.opTail = NULL;\n+      }\n+      op->done = PR_TRUE;\n+      PR_NotifyCondVar(op->doneCV);\n+    }\n+    PR_Unlock(pr_wp.ml);\n+#  endif\n \n     while (1) {\n-        rv = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n-        PR_ASSERT(1 == rv);\n-\n-#ifdef _PR_SHARE_CLONES\n-        if (pr_waitpid_daemon_exit) {\n-            return;\n-        }\n-        PR_Lock(pr_wp.ml);\n-#endif\n-\n-        do {\n-            rv = read(pr_wp.pipefd[0], buf, sizeof(buf));\n-        } while (sizeof(buf) == rv || (-1 == rv && EINTR == errno));\n-\n-#ifdef _PR_SHARE_CLONES\n-        while ((op = pr_wp.opHead) != NULL) {\n-            PR_Unlock(pr_wp.ml);\n-            op->process = ForkAndExec(op->path, op->argv, op->envp, op->attr);\n-            if (NULL == op->process) {\n-                op->prerror = PR_GetError();\n-                op->oserror = PR_GetOSError();\n-            }\n-            PR_Lock(pr_wp.ml);\n-            pr_wp.opHead = op->next;\n-            if (NULL == pr_wp.opHead) {\n-                pr_wp.opTail = NULL;\n-            }\n-            op->done = PR_TRUE;\n-            PR_NotifyCondVar(op->doneCV);\n-        }\n-        PR_Unlock(pr_wp.ml);\n-#endif\n-\n-        while (1) {\n-            do {\n-                pid = waitpid((pid_t)-1, &status, WNOHANG);\n-            } while ((pid_t)-1 == pid && EINTR == errno);\n-            if (0 == pid) {\n-                break;\n-            }\n-            if ((pid_t)-1 == pid) {\n-                /* must be because we have no child processes */\n-                PR_ASSERT(ECHILD == errno);\n-                break;\n-            }\n-\n-            PR_Lock(pr_wp.ml);\n-            ProcessReapedChildInternal(pid, status);\n-            PR_Unlock(pr_wp.ml);\n-        }\n+      do {\n+        pid = waitpid((pid_t)-1, &status, WNOHANG);\n+      } while ((pid_t)-1 == pid && EINTR == errno);\n+      if (0 == pid) {\n+        break;\n+      }\n+      if ((pid_t)-1 == pid) {\n+        /* must be because we have no child processes */\n+        PR_ASSERT(ECHILD == errno);\n+        break;\n+      }\n+\n+      PR_Lock(pr_wp.ml);\n+      ProcessReapedChildInternal(pid, status);\n+      PR_Unlock(pr_wp.ml);\n     }\n+  }\n }\n \n-static void\n-pr_SigchldHandler(int sig)\n-{\n-    int errnoCopy;\n-    int rv;\n+static void pr_SigchldHandler(int sig) {\n+  int errnoCopy;\n+  int rv;\n \n-    errnoCopy = errno;\n+  errnoCopy = errno;\n \n-    do {\n-        rv = write(pr_wp.pipefd[1], \"\", 1);\n-    } while (-1 == rv && EINTR == errno);\n-\n-#ifdef DEBUG\n-    if (-1 == rv && EAGAIN != errno && EWOULDBLOCK != errno) {\n-        char* msg = \"cannot write to pipe\\n\";\n-        write(2, msg, strlen(msg) + 1);\n-        _exit(1);\n-    }\n-#endif\n+  do {\n+    rv = write(pr_wp.pipefd[1], \"\", 1);\n+  } while (-1 == rv && EINTR == errno);\n \n-    errno = errnoCopy;\n+#  ifdef DEBUG\n+  if (-1 == rv && EAGAIN != errno && EWOULDBLOCK != errno) {\n+    char* msg = \"cannot write to pipe\\n\";\n+    write(2, msg, strlen(msg) + 1);\n+    _exit(1);\n+  }\n+#  endif\n+\n+  errno = errnoCopy;\n }\n \n-static void\n-pr_InstallSigchldHandler()\n-{\n-    struct sigaction act, oact;\n-    int rv;\n-\n-    act.sa_handler = pr_SigchldHandler;\n-    sigemptyset(&act.sa_mask);\n-    act.sa_flags = SA_NOCLDSTOP | SA_RESTART;\n-    rv = sigaction(SIGCHLD, &act, &oact);\n-    PR_ASSERT(0 == rv);\n-    /* Make sure we are not overriding someone else's SIGCHLD handler */\n-#ifndef _PR_SHARE_CLONES\n-    PR_ASSERT(oact.sa_handler == SIG_DFL);\n-#endif\n+static void pr_InstallSigchldHandler() {\n+  struct sigaction act, oact;\n+  int rv;\n+\n+  act.sa_handler = pr_SigchldHandler;\n+  sigemptyset(&act.sa_mask);\n+  act.sa_flags = SA_NOCLDSTOP | SA_RESTART;\n+  rv = sigaction(SIGCHLD, &act, &oact);\n+  PR_ASSERT(0 == rv);\n+  /* Make sure we are not overriding someone else's SIGCHLD handler */\n+#  ifndef _PR_SHARE_CLONES\n+  PR_ASSERT(oact.sa_handler == SIG_DFL);\n+#  endif\n }\n \n #endif /* !defined(_PR_NATIVE_THREADS) */\n \n-static PRStatus\n-_MD_InitProcesses(void)\n-{\n+static PRStatus _MD_InitProcesses(void) {\n #if !defined(_PR_NATIVE_THREADS)\n-    int rv;\n-    int flags;\n+  int rv;\n+  int flags;\n #endif\n \n #ifdef AIX\n-    {\n-        void* handle = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL);\n-        pr_wp.forkptr = (pid_t (*)(void))dlsym(handle, \"f_fork\");\n-        if (!pr_wp.forkptr) {\n-            pr_wp.forkptr = fork;\n-        }\n-        dlclose(handle);\n+  {\n+    void* handle = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL);\n+    pr_wp.forkptr = (pid_t(*)(void))dlsym(handle, \"f_fork\");\n+    if (!pr_wp.forkptr) {\n+      pr_wp.forkptr = fork;\n     }\n+    dlclose(handle);\n+  }\n #endif /* AIX */\n \n-    pr_wp.ml = PR_NewLock();\n-    PR_ASSERT(NULL != pr_wp.ml);\n+  pr_wp.ml = PR_NewLock();\n+  PR_ASSERT(NULL != pr_wp.ml);\n \n #if defined(_PR_NATIVE_THREADS)\n-    pr_wp.numProcs = 0;\n-    pr_wp.cv = PR_NewCondVar(pr_wp.ml);\n-    PR_ASSERT(NULL != pr_wp.cv);\n+  pr_wp.numProcs = 0;\n+  pr_wp.cv = PR_NewCondVar(pr_wp.ml);\n+  PR_ASSERT(NULL != pr_wp.cv);\n #else\n-    rv = pipe(pr_wp.pipefd);\n-    PR_ASSERT(0 == rv);\n-    flags = fcntl(pr_wp.pipefd[0], F_GETFL, 0);\n-    fcntl(pr_wp.pipefd[0], F_SETFL, flags | O_NONBLOCK);\n-    flags = fcntl(pr_wp.pipefd[1], F_GETFL, 0);\n-    fcntl(pr_wp.pipefd[1], F_SETFL, flags | O_NONBLOCK);\n-\n-#ifndef _PR_SHARE_CLONES\n-    pr_InstallSigchldHandler();\n-#endif\n+  rv = pipe(pr_wp.pipefd);\n+  PR_ASSERT(0 == rv);\n+  flags = fcntl(pr_wp.pipefd[0], F_GETFL, 0);\n+  fcntl(pr_wp.pipefd[0], F_SETFL, flags | O_NONBLOCK);\n+  flags = fcntl(pr_wp.pipefd[1], F_GETFL, 0);\n+  fcntl(pr_wp.pipefd[1], F_SETFL, flags | O_NONBLOCK);\n+\n+#  ifndef _PR_SHARE_CLONES\n+  pr_InstallSigchldHandler();\n+#  endif\n #endif /* !_PR_NATIVE_THREADS */\n \n-    pr_wp.thread = PR_CreateThread(PR_SYSTEM_THREAD, WaitPidDaemonThread, NULL,\n-                                   PR_PRIORITY_NORMAL,\n+  pr_wp.thread = PR_CreateThread(PR_SYSTEM_THREAD, WaitPidDaemonThread, NULL,\n+                                 PR_PRIORITY_NORMAL,\n #ifdef _PR_SHARE_CLONES\n-                                   PR_GLOBAL_THREAD,\n+                                 PR_GLOBAL_THREAD,\n #else\n-                                   PR_LOCAL_THREAD,\n+                                 PR_LOCAL_THREAD,\n #endif\n-                                   PR_JOINABLE_THREAD, 0);\n-    PR_ASSERT(NULL != pr_wp.thread);\n+                                 PR_JOINABLE_THREAD, 0);\n+  PR_ASSERT(NULL != pr_wp.thread);\n \n-    pr_wp.pidTable = (pr_PidRecord**)PR_CALLOC(NBUCKETS * sizeof(pr_PidRecord*));\n-    PR_ASSERT(NULL != pr_wp.pidTable);\n-    return PR_SUCCESS;\n+  pr_wp.pidTable = (pr_PidRecord**)PR_CALLOC(NBUCKETS * sizeof(pr_PidRecord*));\n+  PR_ASSERT(NULL != pr_wp.pidTable);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_DetachUnixProcess(PRProcess* process)\n-{\n-    PRStatus retVal = PR_SUCCESS;\n-    pr_PidRecord* pRec;\n+PRStatus _MD_DetachUnixProcess(PRProcess* process) {\n+  PRStatus retVal = PR_SUCCESS;\n+  pr_PidRecord* pRec;\n \n-    PR_Lock(pr_wp.ml);\n-    pRec = FindPidTable(process->md.pid);\n+  PR_Lock(pr_wp.ml);\n+  pRec = FindPidTable(process->md.pid);\n+  if (NULL == pRec) {\n+    pRec = PR_NEW(pr_PidRecord);\n     if (NULL == pRec) {\n-        pRec = PR_NEW(pr_PidRecord);\n-        if (NULL == pRec) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            retVal = PR_FAILURE;\n-            goto done;\n-        }\n-        pRec->pid = process->md.pid;\n-        pRec->state = _PR_PID_DETACHED;\n-        pRec->reapedCV = NULL;\n-        InsertPidTable(pRec);\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      retVal = PR_FAILURE;\n+      goto done;\n+    }\n+    pRec->pid = process->md.pid;\n+    pRec->state = _PR_PID_DETACHED;\n+    pRec->reapedCV = NULL;\n+    InsertPidTable(pRec);\n+  } else {\n+    PR_ASSERT(_PR_PID_REAPED == pRec->state);\n+    if (_PR_PID_REAPED != pRec->state) {\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      retVal = PR_FAILURE;\n     } else {\n-        PR_ASSERT(_PR_PID_REAPED == pRec->state);\n-        if (_PR_PID_REAPED != pRec->state) {\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            retVal = PR_FAILURE;\n-        } else {\n-            DeletePidTable(pRec);\n-            PR_ASSERT(NULL == pRec->reapedCV);\n-            PR_DELETE(pRec);\n-        }\n+      DeletePidTable(pRec);\n+      PR_ASSERT(NULL == pRec->reapedCV);\n+      PR_DELETE(pRec);\n     }\n-    PR_DELETE(process);\n+  }\n+  PR_DELETE(process);\n \n done:\n-    PR_Unlock(pr_wp.ml);\n-    return retVal;\n+  PR_Unlock(pr_wp.ml);\n+  return retVal;\n }\n \n-PRStatus\n-_MD_WaitUnixProcess(PRProcess* process, PRInt32* exitCode)\n-{\n-    pr_PidRecord* pRec;\n-    PRStatus retVal = PR_SUCCESS;\n-    PRBool interrupted = PR_FALSE;\n+PRStatus _MD_WaitUnixProcess(PRProcess* process, PRInt32* exitCode) {\n+  pr_PidRecord* pRec;\n+  PRStatus retVal = PR_SUCCESS;\n+  PRBool interrupted = PR_FALSE;\n \n-    PR_Lock(pr_wp.ml);\n-    pRec = FindPidTable(process->md.pid);\n+  PR_Lock(pr_wp.ml);\n+  pRec = FindPidTable(process->md.pid);\n+  if (NULL == pRec) {\n+    pRec = PR_NEW(pr_PidRecord);\n     if (NULL == pRec) {\n-        pRec = PR_NEW(pr_PidRecord);\n-        if (NULL == pRec) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            retVal = PR_FAILURE;\n-            goto done;\n-        }\n-        pRec->pid = process->md.pid;\n-        pRec->state = _PR_PID_WAITING;\n-        pRec->reapedCV = PR_NewCondVar(pr_wp.ml);\n-        if (NULL == pRec->reapedCV) {\n-            PR_DELETE(pRec);\n-            retVal = PR_FAILURE;\n-            goto done;\n-        }\n-        InsertPidTable(pRec);\n-        while (!interrupted && _PR_PID_REAPED != pRec->state) {\n-            if (PR_WaitCondVar(pRec->reapedCV, PR_INTERVAL_NO_TIMEOUT) ==\n-                    PR_FAILURE &&\n-                PR_GetError() == PR_PENDING_INTERRUPT_ERROR) {\n-                interrupted = PR_TRUE;\n-            }\n-        }\n-        if (_PR_PID_REAPED == pRec->state) {\n-            if (exitCode) {\n-                *exitCode = pRec->exitStatus;\n-            }\n-        } else {\n-            PR_ASSERT(interrupted);\n-            retVal = PR_FAILURE;\n-        }\n-        DeletePidTable(pRec);\n-        PR_DestroyCondVar(pRec->reapedCV);\n-        PR_DELETE(pRec);\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      retVal = PR_FAILURE;\n+      goto done;\n+    }\n+    pRec->pid = process->md.pid;\n+    pRec->state = _PR_PID_WAITING;\n+    pRec->reapedCV = PR_NewCondVar(pr_wp.ml);\n+    if (NULL == pRec->reapedCV) {\n+      PR_DELETE(pRec);\n+      retVal = PR_FAILURE;\n+      goto done;\n+    }\n+    InsertPidTable(pRec);\n+    while (!interrupted && _PR_PID_REAPED != pRec->state) {\n+      if (PR_WaitCondVar(pRec->reapedCV, PR_INTERVAL_NO_TIMEOUT) ==\n+              PR_FAILURE &&\n+          PR_GetError() == PR_PENDING_INTERRUPT_ERROR) {\n+        interrupted = PR_TRUE;\n+      }\n+    }\n+    if (_PR_PID_REAPED == pRec->state) {\n+      if (exitCode) {\n+        *exitCode = pRec->exitStatus;\n+      }\n     } else {\n-        PR_ASSERT(_PR_PID_REAPED == pRec->state);\n-        PR_ASSERT(NULL == pRec->reapedCV);\n-        DeletePidTable(pRec);\n-        if (exitCode) {\n-            *exitCode = pRec->exitStatus;\n-        }\n-        PR_DELETE(pRec);\n+      PR_ASSERT(interrupted);\n+      retVal = PR_FAILURE;\n     }\n-    PR_DELETE(process);\n+    DeletePidTable(pRec);\n+    PR_DestroyCondVar(pRec->reapedCV);\n+    PR_DELETE(pRec);\n+  } else {\n+    PR_ASSERT(_PR_PID_REAPED == pRec->state);\n+    PR_ASSERT(NULL == pRec->reapedCV);\n+    DeletePidTable(pRec);\n+    if (exitCode) {\n+      *exitCode = pRec->exitStatus;\n+    }\n+    PR_DELETE(pRec);\n+  }\n+  PR_DELETE(process);\n \n done:\n-    PR_Unlock(pr_wp.ml);\n-    return retVal;\n+  PR_Unlock(pr_wp.ml);\n+  return retVal;\n } /* _MD_WaitUnixProcess */\n \n-PRStatus\n-_MD_KillUnixProcess(PRProcess* process)\n-{\n-    PRErrorCode prerror;\n-    PRInt32 oserror;\n+PRStatus _MD_KillUnixProcess(PRProcess* process) {\n+  PRErrorCode prerror;\n+  PRInt32 oserror;\n \n-    if (kill(process->md.pid, SIGKILL) == 0) {\n-        return PR_SUCCESS;\n-    }\n-    oserror = errno;\n-    switch (oserror) {\n-        case EPERM:\n-            prerror = PR_NO_ACCESS_RIGHTS_ERROR;\n-            break;\n-        case ESRCH:\n-            prerror = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        default:\n-            prerror = PR_UNKNOWN_ERROR;\n-            break;\n-    }\n-    PR_SetError(prerror, oserror);\n-    return PR_FAILURE;\n+  if (kill(process->md.pid, SIGKILL) == 0) {\n+    return PR_SUCCESS;\n+  }\n+  oserror = errno;\n+  switch (oserror) {\n+    case EPERM:\n+      prerror = PR_NO_ACCESS_RIGHTS_ERROR;\n+      break;\n+    case ESRCH:\n+      prerror = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    default:\n+      prerror = PR_UNKNOWN_ERROR;\n+      break;\n+  }\n+  PR_SetError(prerror, oserror);\n+  return PR_FAILURE;\n } /* _MD_KillUnixProcess */\ndiff --git a/nspr/pr/src/md/unix/uxrng.c b/nspr/pr/src/md/unix/uxrng.c\nindex fb914a2..7c9cdb6 100644\n--- a/nspr/pr/src/md/unix/uxrng.c\n+++ b/nspr/pr/src/md/unix/uxrng.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,107 +12,91 @@\n \n #if defined(SOLARIS)\n \n-static size_t\n-GetHighResClock(void* buf, size_t maxbytes)\n-{\n-    hrtime_t t;\n-    t = gethrtime();\n-    if (t) {\n-        return _pr_CopyLowBits(buf, maxbytes, &t, sizeof(t));\n-    }\n-    return 0;\n+static size_t GetHighResClock(void* buf, size_t maxbytes) {\n+  hrtime_t t;\n+  t = gethrtime();\n+  if (t) {\n+    return _pr_CopyLowBits(buf, maxbytes, &t, sizeof(t));\n+  }\n+  return 0;\n }\n \n #elif defined(AIX)\n \n-static size_t\n-GetHighResClock(void* buf, size_t maxbytes)\n-{\n-    return 0;\n-}\n+static size_t GetHighResClock(void* buf, size_t maxbytes) { return 0; }\n \n #elif (defined(LINUX) || defined(FREEBSD) || defined(__FreeBSD_kernel__) || \\\n        defined(NETBSD) || defined(__NetBSD_kernel__) || defined(OPENBSD) || \\\n        defined(__GNU__))\n-#include <sys/types.h>\n-#include <sys/stat.h>\n-#include <fcntl.h>\n+#  include <sys/types.h>\n+#  include <sys/stat.h>\n+#  include <fcntl.h>\n \n static int fdDevURandom;\n static PRCallOnceType coOpenDevURandom;\n \n-static PRStatus\n-OpenDevURandom(void)\n-{\n-    fdDevURandom = open(\"/dev/urandom\", O_RDONLY);\n-    return ((-1 == fdDevURandom) ? PR_FAILURE : PR_SUCCESS);\n+static PRStatus OpenDevURandom(void) {\n+  fdDevURandom = open(\"/dev/urandom\", O_RDONLY);\n+  return ((-1 == fdDevURandom) ? PR_FAILURE : PR_SUCCESS);\n } /* end OpenDevURandom() */\n \n-static size_t\n-GetDevURandom(void* buf, size_t size)\n-{\n-    int bytesIn;\n-    int rc;\n-\n-    rc = PR_CallOnce(&coOpenDevURandom, OpenDevURandom);\n-    if (PR_FAILURE == rc) {\n-        _PR_MD_MAP_OPEN_ERROR(errno);\n-        return (0);\n-    }\n-\n-    bytesIn = read(fdDevURandom, buf, size);\n-    if (-1 == bytesIn) {\n-        _PR_MD_MAP_READ_ERROR(errno);\n-        return (0);\n-    }\n-\n-    return (bytesIn);\n+static size_t GetDevURandom(void* buf, size_t size) {\n+  int bytesIn;\n+  int rc;\n+\n+  rc = PR_CallOnce(&coOpenDevURandom, OpenDevURandom);\n+  if (PR_FAILURE == rc) {\n+    _PR_MD_MAP_OPEN_ERROR(errno);\n+    return (0);\n+  }\n+\n+  bytesIn = read(fdDevURandom, buf, size);\n+  if (-1 == bytesIn) {\n+    _PR_MD_MAP_READ_ERROR(errno);\n+    return (0);\n+  }\n+\n+  return (bytesIn);\n } /* end GetDevURandom() */\n \n-static size_t\n-GetHighResClock(void* buf, size_t maxbytes)\n-{\n-    return (GetDevURandom(buf, maxbytes));\n+static size_t GetHighResClock(void* buf, size_t maxbytes) {\n+  return (GetDevURandom(buf, maxbytes));\n }\n \n #elif defined(NTO) || defined(QNX) || defined(DARWIN) || defined(RISCOS)\n-#include <sys/times.h>\n+#  include <sys/times.h>\n \n-static size_t\n-GetHighResClock(void* buf, size_t maxbytes)\n-{\n-    int ticks;\n-    struct tms buffer;\n+static size_t GetHighResClock(void* buf, size_t maxbytes) {\n+  int ticks;\n+  struct tms buffer;\n \n-    ticks = times(&buffer);\n-    return _pr_CopyLowBits(buf, maxbytes, &ticks, sizeof(ticks));\n+  ticks = times(&buffer);\n+  return _pr_CopyLowBits(buf, maxbytes, &ticks, sizeof(ticks));\n }\n #else\n-#error ! Platform undefined\n+#  error ! Platform undefined\n #endif /* defined(SOLARIS) */\n \n-extern PRSize\n-_PR_MD_GetRandomNoise(void* buf, PRSize size)\n-{\n-    struct timeval tv;\n-    int n = 0;\n-    int s;\n-\n-    n += GetHighResClock(buf, size);\n-    size -= n;\n-\n-    GETTIMEOFDAY(&tv);\n-\n-    if (size > 0) {\n-        s = _pr_CopyLowBits((char*)buf + n, size, &tv.tv_usec, sizeof(tv.tv_usec));\n-        size -= s;\n-        n += s;\n-    }\n-    if (size > 0) {\n-        s = _pr_CopyLowBits((char*)buf + n, size, &tv.tv_sec, sizeof(tv.tv_usec));\n-        size -= s;\n-        n += s;\n-    }\n-\n-    return n;\n+extern PRSize _PR_MD_GetRandomNoise(void* buf, PRSize size) {\n+  struct timeval tv;\n+  int n = 0;\n+  int s;\n+\n+  n += GetHighResClock(buf, size);\n+  size -= n;\n+\n+  GETTIMEOFDAY(&tv);\n+\n+  if (size > 0) {\n+    s = _pr_CopyLowBits((char*)buf + n, size, &tv.tv_usec, sizeof(tv.tv_usec));\n+    size -= s;\n+    n += s;\n+  }\n+  if (size > 0) {\n+    s = _pr_CopyLowBits((char*)buf + n, size, &tv.tv_sec, sizeof(tv.tv_usec));\n+    size -= s;\n+    n += s;\n+  }\n+\n+  return n;\n } /* end _PR_MD_GetRandomNoise() */\ndiff --git a/nspr/pr/src/md/unix/uxshm.c b/nspr/pr/src/md/unix/uxshm.c\nindex 4761c1e..4c0f41d 100644\n--- a/nspr/pr/src/md/unix/uxshm.c\n+++ b/nspr/pr/src/md/unix/uxshm.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -23,429 +24,409 @@ extern PRLogModuleInfo* _pr_shm_lm;\n ** Implementation for System V\n */\n #if defined PR_HAVE_SYSV_NAMED_SHARED_MEMORY\n-#include <sys/ipc.h>\n-#include <sys/shm.h>\n-#include <sys/types.h>\n-#include <sys/stat.h>\n-\n-#define _MD_OPEN_SHARED_MEMORY _MD_OpenSharedMemory\n-#define _MD_ATTACH_SHARED_MEMORY _MD_AttachSharedMemory\n-#define _MD_DETACH_SHARED_MEMORY _MD_DetachSharedMemory\n-#define _MD_CLOSE_SHARED_MEMORY _MD_CloseSharedMemory\n-#define _MD_DELETE_SHARED_MEMORY _MD_DeleteSharedMemory\n-\n-extern PRSharedMemory*\n-_MD_OpenSharedMemory(const char* name, PRSize size,\n-                     PRIntn flags, PRIntn mode)\n-{\n-    PRStatus rc = PR_SUCCESS;\n-    key_t key;\n-    PRSharedMemory* shm;\n-    char ipcname[PR_IPC_NAME_SIZE];\n-\n-    rc = _PR_MakeNativeIPCName(name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm);\n-    if (PR_FAILURE == rc) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(\n-            _pr_shm_lm, PR_LOG_DEBUG,\n-            (\"_MD_OpenSharedMemory(): _PR_MakeNativeIPCName() failed: %s\", name));\n-        return (NULL);\n-    }\n-\n-    shm = PR_NEWZAP(PRSharedMemory);\n-    if (NULL == shm) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"PR_OpenSharedMemory: New PRSharedMemory out of memory\"));\n-        return (NULL);\n-    }\n-\n-    shm->ipcname = (char*)PR_MALLOC(strlen(ipcname) + 1);\n-    if (NULL == shm->ipcname) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"PR_OpenSharedMemory: New shm->ipcname out of memory\"));\n-        PR_DELETE(shm);\n-        return (NULL);\n-    }\n-\n-    /* copy args to struct */\n-    strcpy(shm->ipcname, ipcname);\n-    shm->size = size;\n-    shm->mode = mode;\n-    shm->flags = flags;\n-    shm->ident = _PR_SHM_IDENT;\n-\n-    /* create the file first */\n-    if (flags & PR_SHM_CREATE) {\n-        int osfd = open(shm->ipcname, (O_RDWR | O_CREAT), shm->mode);\n-        if (-1 == osfd) {\n-            _PR_MD_MAP_OPEN_ERROR(errno);\n-            PR_FREEIF(shm->ipcname);\n-            PR_DELETE(shm);\n-            return (NULL);\n-        }\n-        if (close(osfd) == -1) {\n-            _PR_MD_MAP_CLOSE_ERROR(errno);\n-            PR_FREEIF(shm->ipcname);\n-            PR_DELETE(shm);\n-            return (NULL);\n-        }\n-    }\n-\n-    /* hash the shm.name to an ID */\n-    key = ftok(shm->ipcname, NSPR_IPC_SHM_KEY);\n-    if (-1 == key) {\n-        rc = PR_FAILURE;\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_OpenSharedMemory(): ftok() failed on name: %s\", shm->ipcname));\n-        PR_FREEIF(shm->ipcname);\n-        PR_DELETE(shm);\n-        return (NULL);\n-    }\n-\n-    /* get the shared memory */\n-    if (flags & PR_SHM_CREATE) {\n-        shm->id = shmget(key, shm->size, (shm->mode | IPC_CREAT | IPC_EXCL));\n-        if (shm->id >= 0) {\n-            return (shm);\n-        }\n-        if ((errno == EEXIST) && (flags & PR_SHM_EXCL)) {\n-            PR_SetError(PR_FILE_EXISTS_ERROR, errno);\n-            PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-                   (\"_MD_OpenSharedMemory(): shmget() exclusive failed, errno: %d\",\n-                    errno));\n-            PR_FREEIF(shm->ipcname);\n-            PR_DELETE(shm);\n-            return (NULL);\n-        }\n-    }\n-\n-    shm->id = shmget(key, shm->size, shm->mode);\n-    if (-1 == shm->id) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_OpenSharedMemory(): shmget() failed, errno: %d\", errno));\n-        PR_FREEIF(shm->ipcname);\n-        PR_DELETE(shm);\n-        return (NULL);\n-    }\n+#  include <sys/ipc.h>\n+#  include <sys/shm.h>\n+#  include <sys/types.h>\n+#  include <sys/stat.h>\n+\n+#  define _MD_OPEN_SHARED_MEMORY _MD_OpenSharedMemory\n+#  define _MD_ATTACH_SHARED_MEMORY _MD_AttachSharedMemory\n+#  define _MD_DETACH_SHARED_MEMORY _MD_DetachSharedMemory\n+#  define _MD_CLOSE_SHARED_MEMORY _MD_CloseSharedMemory\n+#  define _MD_DELETE_SHARED_MEMORY _MD_DeleteSharedMemory\n+\n+extern PRSharedMemory* _MD_OpenSharedMemory(const char* name, PRSize size,\n+                                            PRIntn flags, PRIntn mode) {\n+  PRStatus rc = PR_SUCCESS;\n+  key_t key;\n+  PRSharedMemory* shm;\n+  char ipcname[PR_IPC_NAME_SIZE];\n+\n+  rc = _PR_MakeNativeIPCName(name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm);\n+  if (PR_FAILURE == rc) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_LOG(\n+        _pr_shm_lm, PR_LOG_DEBUG,\n+        (\"_MD_OpenSharedMemory(): _PR_MakeNativeIPCName() failed: %s\", name));\n+    return (NULL);\n+  }\n+\n+  shm = PR_NEWZAP(PRSharedMemory);\n+  if (NULL == shm) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"PR_OpenSharedMemory: New PRSharedMemory out of memory\"));\n+    return (NULL);\n+  }\n+\n+  shm->ipcname = (char*)PR_MALLOC(strlen(ipcname) + 1);\n+  if (NULL == shm->ipcname) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"PR_OpenSharedMemory: New shm->ipcname out of memory\"));\n+    PR_DELETE(shm);\n+    return (NULL);\n+  }\n+\n+  /* copy args to struct */\n+  strcpy(shm->ipcname, ipcname);\n+  shm->size = size;\n+  shm->mode = mode;\n+  shm->flags = flags;\n+  shm->ident = _PR_SHM_IDENT;\n+\n+  /* create the file first */\n+  if (flags & PR_SHM_CREATE) {\n+    int osfd = open(shm->ipcname, (O_RDWR | O_CREAT), shm->mode);\n+    if (-1 == osfd) {\n+      _PR_MD_MAP_OPEN_ERROR(errno);\n+      PR_FREEIF(shm->ipcname);\n+      PR_DELETE(shm);\n+      return (NULL);\n+    }\n+    if (close(osfd) == -1) {\n+      _PR_MD_MAP_CLOSE_ERROR(errno);\n+      PR_FREEIF(shm->ipcname);\n+      PR_DELETE(shm);\n+      return (NULL);\n+    }\n+  }\n+\n+  /* hash the shm.name to an ID */\n+  key = ftok(shm->ipcname, NSPR_IPC_SHM_KEY);\n+  if (-1 == key) {\n+    rc = PR_FAILURE;\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_OpenSharedMemory(): ftok() failed on name: %s\", shm->ipcname));\n+    PR_FREEIF(shm->ipcname);\n+    PR_DELETE(shm);\n+    return (NULL);\n+  }\n+\n+  /* get the shared memory */\n+  if (flags & PR_SHM_CREATE) {\n+    shm->id = shmget(key, shm->size, (shm->mode | IPC_CREAT | IPC_EXCL));\n+    if (shm->id >= 0) {\n+      return (shm);\n+    }\n+    if ((errno == EEXIST) && (flags & PR_SHM_EXCL)) {\n+      PR_SetError(PR_FILE_EXISTS_ERROR, errno);\n+      PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+             (\"_MD_OpenSharedMemory(): shmget() exclusive failed, errno: %d\",\n+              errno));\n+      PR_FREEIF(shm->ipcname);\n+      PR_DELETE(shm);\n+      return (NULL);\n+    }\n+  }\n+\n+  shm->id = shmget(key, shm->size, shm->mode);\n+  if (-1 == shm->id) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_OpenSharedMemory(): shmget() failed, errno: %d\", errno));\n+    PR_FREEIF(shm->ipcname);\n+    PR_DELETE(shm);\n+    return (NULL);\n+  }\n \n-    return (shm);\n+  return (shm);\n } /* end _MD_OpenSharedMemory() */\n \n-extern void*\n-_MD_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags)\n-{\n-    void* addr;\n-    PRUint32 aFlags = shm->mode;\n+extern void* _MD_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags) {\n+  void* addr;\n+  PRUint32 aFlags = shm->mode;\n \n-    PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n+  PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n \n-    aFlags |= (flags & PR_SHM_READONLY) ? SHM_RDONLY : 0;\n+  aFlags |= (flags & PR_SHM_READONLY) ? SHM_RDONLY : 0;\n \n-    addr = shmat(shm->id, NULL, aFlags);\n-    if ((void*)-1 == addr) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_AttachSharedMemory(): shmat() failed on name: %s, OsError: %d\",\n-                shm->ipcname, PR_GetOSError()));\n-        addr = NULL;\n-    }\n+  addr = shmat(shm->id, NULL, aFlags);\n+  if ((void*)-1 == addr) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_AttachSharedMemory(): shmat() failed on name: %s, OsError: %d\",\n+            shm->ipcname, PR_GetOSError()));\n+    addr = NULL;\n+  }\n \n-    return addr;\n+  return addr;\n }\n \n-extern PRStatus\n-_MD_DetachSharedMemory(PRSharedMemory* shm, void* addr)\n-{\n-    PRStatus rc = PR_SUCCESS;\n-    PRIntn urc;\n-\n-    PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n-\n-    urc = shmdt(addr);\n-    if (-1 == urc) {\n-        rc = PR_FAILURE;\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(\n-            _pr_shm_lm, PR_LOG_DEBUG,\n-            (\"_MD_DetachSharedMemory(): shmdt() failed on name: %s\", shm->ipcname));\n-    }\n+extern PRStatus _MD_DetachSharedMemory(PRSharedMemory* shm, void* addr) {\n+  PRStatus rc = PR_SUCCESS;\n+  PRIntn urc;\n \n-    return rc;\n-}\n+  PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n \n-extern PRStatus\n-_MD_CloseSharedMemory(PRSharedMemory* shm)\n-{\n-    PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n+  urc = shmdt(addr);\n+  if (-1 == urc) {\n+    rc = PR_FAILURE;\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_LOG(\n+        _pr_shm_lm, PR_LOG_DEBUG,\n+        (\"_MD_DetachSharedMemory(): shmdt() failed on name: %s\", shm->ipcname));\n+  }\n \n-    PR_FREEIF(shm->ipcname);\n-    PR_DELETE(shm);\n-\n-    return PR_SUCCESS;\n+  return rc;\n }\n \n-extern PRStatus\n-_MD_DeleteSharedMemory(const char* name)\n-{\n-    PRStatus rc = PR_SUCCESS;\n-    key_t key;\n-    int id;\n-    PRIntn urc;\n-    char ipcname[PR_IPC_NAME_SIZE];\n-\n-    rc = _PR_MakeNativeIPCName(name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm);\n-    if (PR_FAILURE == rc) {\n-        PR_SetError(PR_UNKNOWN_ERROR, errno);\n-        PR_LOG(\n-            _pr_shm_lm, PR_LOG_DEBUG,\n-            (\"_MD_DeleteSharedMemory(): _PR_MakeNativeIPCName() failed: %s\", name));\n-        return (PR_FAILURE);\n-    }\n-\n-    /* create the file first */\n-    {\n-        int osfd = open(ipcname, (O_RDWR | O_CREAT), 0666);\n-        if (-1 == osfd) {\n-            _PR_MD_MAP_OPEN_ERROR(errno);\n-            return (PR_FAILURE);\n-        }\n-        if (close(osfd) == -1) {\n-            _PR_MD_MAP_CLOSE_ERROR(errno);\n-            return (PR_FAILURE);\n-        }\n-    }\n+extern PRStatus _MD_CloseSharedMemory(PRSharedMemory* shm) {\n+  PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n \n-    /* hash the shm.name to an ID */\n-    key = ftok(ipcname, NSPR_IPC_SHM_KEY);\n-    if (-1 == key) {\n-        rc = PR_FAILURE;\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_DeleteSharedMemory(): ftok() failed on name: %s\", ipcname));\n-    }\n-\n-    id = shmget(key, 0, 0);\n-    if (-1 == id) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_DeleteSharedMemory(): shmget() failed, errno: %d\", errno));\n-        return (PR_FAILURE);\n-    }\n-\n-    urc = shmctl(id, IPC_RMID, NULL);\n-    if (-1 == urc) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_DeleteSharedMemory(): shmctl() failed on name: %s\", ipcname));\n-        return (PR_FAILURE);\n-    }\n+  PR_FREEIF(shm->ipcname);\n+  PR_DELETE(shm);\n \n-    urc = unlink(ipcname);\n-    if (-1 == urc) {\n-        _PR_MD_MAP_UNLINK_ERROR(errno);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_DeleteSharedMemory(): unlink() failed: %s\", ipcname));\n-        return (PR_FAILURE);\n-    }\n+  return PR_SUCCESS;\n+}\n \n-    return rc;\n+extern PRStatus _MD_DeleteSharedMemory(const char* name) {\n+  PRStatus rc = PR_SUCCESS;\n+  key_t key;\n+  int id;\n+  PRIntn urc;\n+  char ipcname[PR_IPC_NAME_SIZE];\n+\n+  rc = _PR_MakeNativeIPCName(name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm);\n+  if (PR_FAILURE == rc) {\n+    PR_SetError(PR_UNKNOWN_ERROR, errno);\n+    PR_LOG(\n+        _pr_shm_lm, PR_LOG_DEBUG,\n+        (\"_MD_DeleteSharedMemory(): _PR_MakeNativeIPCName() failed: %s\", name));\n+    return (PR_FAILURE);\n+  }\n+\n+  /* create the file first */\n+  {\n+    int osfd = open(ipcname, (O_RDWR | O_CREAT), 0666);\n+    if (-1 == osfd) {\n+      _PR_MD_MAP_OPEN_ERROR(errno);\n+      return (PR_FAILURE);\n+    }\n+    if (close(osfd) == -1) {\n+      _PR_MD_MAP_CLOSE_ERROR(errno);\n+      return (PR_FAILURE);\n+    }\n+  }\n+\n+  /* hash the shm.name to an ID */\n+  key = ftok(ipcname, NSPR_IPC_SHM_KEY);\n+  if (-1 == key) {\n+    rc = PR_FAILURE;\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_DeleteSharedMemory(): ftok() failed on name: %s\", ipcname));\n+  }\n+\n+  id = shmget(key, 0, 0);\n+  if (-1 == id) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_DeleteSharedMemory(): shmget() failed, errno: %d\", errno));\n+    return (PR_FAILURE);\n+  }\n+\n+  urc = shmctl(id, IPC_RMID, NULL);\n+  if (-1 == urc) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_DeleteSharedMemory(): shmctl() failed on name: %s\", ipcname));\n+    return (PR_FAILURE);\n+  }\n+\n+  urc = unlink(ipcname);\n+  if (-1 == urc) {\n+    _PR_MD_MAP_UNLINK_ERROR(errno);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_DeleteSharedMemory(): unlink() failed: %s\", ipcname));\n+    return (PR_FAILURE);\n+  }\n+\n+  return rc;\n } /* end _MD_DeleteSharedMemory() */\n \n /*\n ** Implementation for Posix\n */\n #elif defined PR_HAVE_POSIX_NAMED_SHARED_MEMORY\n-#include <sys/mman.h>\n+#  include <sys/mman.h>\n \n-#define _MD_OPEN_SHARED_MEMORY _MD_OpenSharedMemory\n-#define _MD_ATTACH_SHARED_MEMORY _MD_AttachSharedMemory\n-#define _MD_DETACH_SHARED_MEMORY _MD_DetachSharedMemory\n-#define _MD_CLOSE_SHARED_MEMORY _MD_CloseSharedMemory\n-#define _MD_DELETE_SHARED_MEMORY _MD_DeleteSharedMemory\n+#  define _MD_OPEN_SHARED_MEMORY _MD_OpenSharedMemory\n+#  define _MD_ATTACH_SHARED_MEMORY _MD_AttachSharedMemory\n+#  define _MD_DETACH_SHARED_MEMORY _MD_DetachSharedMemory\n+#  define _MD_CLOSE_SHARED_MEMORY _MD_CloseSharedMemory\n+#  define _MD_DELETE_SHARED_MEMORY _MD_DeleteSharedMemory\n \n struct _MDSharedMemory {\n-    int handle;\n+  int handle;\n };\n \n-extern PRSharedMemory*\n-_MD_OpenSharedMemory(const char* name, PRSize size,\n-                     PRIntn flags, PRIntn mode)\n-{\n-    PRStatus rc = PR_SUCCESS;\n-    PRInt32 end;\n-    PRSharedMemory* shm;\n-    char ipcname[PR_IPC_NAME_SIZE];\n-\n-    rc = _PR_MakeNativeIPCName(name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm);\n-    if (PR_FAILURE == rc) {\n-        PR_SetError(PR_UNKNOWN_ERROR, errno);\n-        PR_LOG(\n-            _pr_shm_lm, PR_LOG_DEBUG,\n-            (\"_MD_OpenSharedMemory(): _PR_MakeNativeIPCName() failed: %s\", name));\n-        return (NULL);\n-    }\n-\n-    shm = PR_NEWZAP(PRSharedMemory);\n-    if (NULL == shm) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"PR_OpenSharedMemory: New PRSharedMemory out of memory\"));\n-        return (NULL);\n-    }\n-\n-    shm->ipcname = PR_MALLOC(strlen(ipcname) + 1);\n-    if (NULL == shm->ipcname) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"PR_OpenSharedMemory: New shm->ipcname out of memory\"));\n-        return (NULL);\n-    }\n-\n-    /* copy args to struct */\n-    strcpy(shm->ipcname, ipcname);\n-    shm->size = size;\n-    shm->mode = mode;\n-    shm->flags = flags;\n-    shm->ident = _PR_SHM_IDENT;\n-\n-    /*\n-    ** Create the shared memory\n-    */\n-    if (flags & PR_SHM_CREATE) {\n-        int oflag = (O_CREAT | O_RDWR);\n-\n-        if (flags & PR_SHM_EXCL) {\n-            oflag |= O_EXCL;\n-        }\n-        shm->id = shm_open(shm->ipcname, oflag, shm->mode);\n-    } else {\n-        shm->id = shm_open(shm->ipcname, O_RDWR, shm->mode);\n-    }\n-\n-    if (-1 == shm->id) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_OpenSharedMemory(): shm_open failed: %s, OSError: %d\",\n-                shm->ipcname, PR_GetOSError()));\n-        PR_DELETE(shm->ipcname);\n-        PR_DELETE(shm);\n-        return (NULL);\n-    }\n-\n-    end = ftruncate(shm->id, shm->size);\n-    if (-1 == end) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_OpenSharedMemory(): ftruncate failed, OSError: %d\",\n-                PR_GetOSError()));\n-        PR_DELETE(shm->ipcname);\n-        PR_DELETE(shm);\n-        return (NULL);\n-    }\n+extern PRSharedMemory* _MD_OpenSharedMemory(const char* name, PRSize size,\n+                                            PRIntn flags, PRIntn mode) {\n+  PRStatus rc = PR_SUCCESS;\n+  PRInt32 end;\n+  PRSharedMemory* shm;\n+  char ipcname[PR_IPC_NAME_SIZE];\n+\n+  rc = _PR_MakeNativeIPCName(name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm);\n+  if (PR_FAILURE == rc) {\n+    PR_SetError(PR_UNKNOWN_ERROR, errno);\n+    PR_LOG(\n+        _pr_shm_lm, PR_LOG_DEBUG,\n+        (\"_MD_OpenSharedMemory(): _PR_MakeNativeIPCName() failed: %s\", name));\n+    return (NULL);\n+  }\n+\n+  shm = PR_NEWZAP(PRSharedMemory);\n+  if (NULL == shm) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"PR_OpenSharedMemory: New PRSharedMemory out of memory\"));\n+    return (NULL);\n+  }\n+\n+  shm->ipcname = PR_MALLOC(strlen(ipcname) + 1);\n+  if (NULL == shm->ipcname) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"PR_OpenSharedMemory: New shm->ipcname out of memory\"));\n+    return (NULL);\n+  }\n+\n+  /* copy args to struct */\n+  strcpy(shm->ipcname, ipcname);\n+  shm->size = size;\n+  shm->mode = mode;\n+  shm->flags = flags;\n+  shm->ident = _PR_SHM_IDENT;\n+\n+  /*\n+  ** Create the shared memory\n+  */\n+  if (flags & PR_SHM_CREATE) {\n+    int oflag = (O_CREAT | O_RDWR);\n+\n+    if (flags & PR_SHM_EXCL) {\n+      oflag |= O_EXCL;\n+    }\n+    shm->id = shm_open(shm->ipcname, oflag, shm->mode);\n+  } else {\n+    shm->id = shm_open(shm->ipcname, O_RDWR, shm->mode);\n+  }\n+\n+  if (-1 == shm->id) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_OpenSharedMemory(): shm_open failed: %s, OSError: %d\",\n+            shm->ipcname, PR_GetOSError()));\n+    PR_DELETE(shm->ipcname);\n+    PR_DELETE(shm);\n+    return (NULL);\n+  }\n+\n+  end = ftruncate(shm->id, shm->size);\n+  if (-1 == end) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_OpenSharedMemory(): ftruncate failed, OSError: %d\",\n+            PR_GetOSError()));\n+    PR_DELETE(shm->ipcname);\n+    PR_DELETE(shm);\n+    return (NULL);\n+  }\n \n-    return (shm);\n+  return (shm);\n } /* end _MD_OpenSharedMemory() */\n \n-extern void*\n-_MD_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags)\n-{\n-    void* addr;\n-    PRIntn prot = (PROT_READ | PROT_WRITE);\n-\n-    PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n-\n-    if (PR_SHM_READONLY == flags) {\n-        prot ^= PROT_WRITE;\n-    }\n-\n-    addr = mmap((void*)0, shm->size, prot, MAP_SHARED, shm->id, 0);\n-    if ((void*)-1 == addr) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_AttachSharedMemory(): mmap failed: %s, errno: %d\",\n-                shm->ipcname, PR_GetOSError()));\n-        addr = NULL;\n-    } else {\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_AttachSharedMemory(): name: %s, attached at: %p\", shm->ipcname,\n-                addr));\n-    }\n-\n-    return addr;\n+extern void* _MD_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags) {\n+  void* addr;\n+  PRIntn prot = (PROT_READ | PROT_WRITE);\n+\n+  PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n+\n+  if (PR_SHM_READONLY == flags) {\n+    prot ^= PROT_WRITE;\n+  }\n+\n+  addr = mmap((void*)0, shm->size, prot, MAP_SHARED, shm->id, 0);\n+  if ((void*)-1 == addr) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_AttachSharedMemory(): mmap failed: %s, errno: %d\",\n+            shm->ipcname, PR_GetOSError()));\n+    addr = NULL;\n+  } else {\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_AttachSharedMemory(): name: %s, attached at: %p\", shm->ipcname,\n+            addr));\n+  }\n+\n+  return addr;\n }\n \n-extern PRStatus\n-_MD_DetachSharedMemory(PRSharedMemory* shm, void* addr)\n-{\n-    PRStatus rc = PR_SUCCESS;\n-    PRIntn urc;\n-\n-    PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n-\n-    urc = munmap(addr, shm->size);\n-    if (-1 == urc) {\n-        rc = PR_FAILURE;\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_DetachSharedMemory(): munmap failed: %s, errno: %d\",\n-                shm->ipcname, PR_GetOSError()));\n-    }\n-    return rc;\n+extern PRStatus _MD_DetachSharedMemory(PRSharedMemory* shm, void* addr) {\n+  PRStatus rc = PR_SUCCESS;\n+  PRIntn urc;\n+\n+  PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n+\n+  urc = munmap(addr, shm->size);\n+  if (-1 == urc) {\n+    rc = PR_FAILURE;\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_DetachSharedMemory(): munmap failed: %s, errno: %d\",\n+            shm->ipcname, PR_GetOSError()));\n+  }\n+  return rc;\n }\n \n-extern PRStatus\n-_MD_CloseSharedMemory(PRSharedMemory* shm)\n-{\n-    int urc;\n-\n-    PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n-\n-    urc = close(shm->id);\n-    if (-1 == urc) {\n-        _PR_MD_MAP_CLOSE_ERROR(errno);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_CloseSharedMemory(): close() failed, error: %d\",\n-                PR_GetOSError()));\n-        return (PR_FAILURE);\n-    }\n-    PR_DELETE(shm->ipcname);\n-    PR_DELETE(shm);\n-    return PR_SUCCESS;\n+extern PRStatus _MD_CloseSharedMemory(PRSharedMemory* shm) {\n+  int urc;\n+\n+  PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n+\n+  urc = close(shm->id);\n+  if (-1 == urc) {\n+    _PR_MD_MAP_CLOSE_ERROR(errno);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_CloseSharedMemory(): close() failed, error: %d\",\n+            PR_GetOSError()));\n+    return (PR_FAILURE);\n+  }\n+  PR_DELETE(shm->ipcname);\n+  PR_DELETE(shm);\n+  return PR_SUCCESS;\n }\n \n-extern PRStatus\n-_MD_DeleteSharedMemory(const char* name)\n-{\n-    PRStatus rc = PR_SUCCESS;\n-    PRUintn urc;\n-    char ipcname[PR_IPC_NAME_SIZE];\n-\n-    rc = _PR_MakeNativeIPCName(name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm);\n-    if (PR_FAILURE == rc) {\n-        PR_SetError(PR_UNKNOWN_ERROR, errno);\n-        PR_LOG(\n-            _pr_shm_lm, PR_LOG_DEBUG,\n-            (\"_MD_OpenSharedMemory(): _PR_MakeNativeIPCName() failed: %s\", name));\n-        return rc;\n-    }\n-\n-    urc = shm_unlink(ipcname);\n-    if (-1 == urc) {\n-        rc = PR_FAILURE;\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_DeleteSharedMemory(): shm_unlink failed: %s, errno: %d\",\n-                ipcname, PR_GetOSError()));\n-    } else {\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"_MD_DeleteSharedMemory(): %s, success\", ipcname));\n-    }\n-\n+extern PRStatus _MD_DeleteSharedMemory(const char* name) {\n+  PRStatus rc = PR_SUCCESS;\n+  PRUintn urc;\n+  char ipcname[PR_IPC_NAME_SIZE];\n+\n+  rc = _PR_MakeNativeIPCName(name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm);\n+  if (PR_FAILURE == rc) {\n+    PR_SetError(PR_UNKNOWN_ERROR, errno);\n+    PR_LOG(\n+        _pr_shm_lm, PR_LOG_DEBUG,\n+        (\"_MD_OpenSharedMemory(): _PR_MakeNativeIPCName() failed: %s\", name));\n     return rc;\n+  }\n+\n+  urc = shm_unlink(ipcname);\n+  if (-1 == urc) {\n+    rc = PR_FAILURE;\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_DeleteSharedMemory(): shm_unlink failed: %s, errno: %d\",\n+            ipcname, PR_GetOSError()));\n+  } else {\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"_MD_DeleteSharedMemory(): %s, success\", ipcname));\n+  }\n+\n+  return rc;\n } /* end _MD_DeleteSharedMemory() */\n #endif\n \n@@ -456,108 +437,106 @@ extern PRLogModuleInfo* _pr_shma_lm;\n \n #include <unistd.h>\n \n-extern PRFileMap*\n-_md_OpenAnonFileMap(const char* dirName, PRSize size,\n-                    PRFileMapProtect prot)\n-{\n-    PRFileMap* fm = NULL;\n-    PRFileDesc* fd;\n-    int osfd;\n-    PRIntn urc;\n-    PRIntn mode = 0600;\n-    char* genName;\n-    pid_t pid = getpid();                  /* for generating filename */\n-    PRThread* tid = PR_GetCurrentThread(); /* for generating filename */\n-    int incr;                              /* for generating filename */\n-    const int maxTries = 20;               /* maximum # attempts at a unique filename */\n-    PRInt64 size64;                        /* 64-bit version of 'size' */\n-\n-    /*\n-    ** generate a filename from input and runtime environment\n-    ** open the file, unlink the file.\n-    ** make maxTries number of attempts at uniqueness in the filename\n-    */\n-    for (incr = 0; incr < maxTries; incr++) {\n+extern PRFileMap* _md_OpenAnonFileMap(const char* dirName, PRSize size,\n+                                      PRFileMapProtect prot) {\n+  PRFileMap* fm = NULL;\n+  PRFileDesc* fd;\n+  int osfd;\n+  PRIntn urc;\n+  PRIntn mode = 0600;\n+  char* genName;\n+  pid_t pid = getpid();                  /* for generating filename */\n+  PRThread* tid = PR_GetCurrentThread(); /* for generating filename */\n+  int incr;                              /* for generating filename */\n+  const int maxTries = 20; /* maximum # attempts at a unique filename */\n+  PRInt64 size64;          /* 64-bit version of 'size' */\n+\n+  /*\n+  ** generate a filename from input and runtime environment\n+  ** open the file, unlink the file.\n+  ** make maxTries number of attempts at uniqueness in the filename\n+  */\n+  for (incr = 0; incr < maxTries; incr++) {\n #define NSPR_AFM_FILENAME \"%s/.NSPR-AFM-%d-%p.%d\"\n-        genName = PR_smprintf(NSPR_AFM_FILENAME, dirName, (int)pid, tid, incr);\n-        if (NULL == genName) {\n-            PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-                   (\"_md_OpenAnonFileMap(): PR_snprintf(): failed, generating \"\n-                    \"filename\"));\n-            goto Finished;\n-        }\n-\n-        /* create the file */\n-        osfd = open(genName, (O_CREAT | O_EXCL | O_RDWR), mode);\n-        if (-1 == osfd) {\n-            if (EEXIST == errno) {\n-                PR_smprintf_free(genName);\n-                continue; /* name exists, try again */\n-            }\n-            _PR_MD_MAP_OPEN_ERROR(errno);\n-            PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-                   (\"_md_OpenAnonFileMap(): open(): failed, filename: %s, errno: %d\",\n-                    genName, PR_GetOSError()));\n-            PR_smprintf_free(genName);\n-            goto Finished;\n-        }\n-        break; /* name generation and open successful, break; */\n-    } /* end for() */\n-\n-    if (incr == maxTries) {\n-        PR_ASSERT(-1 == osfd);\n-        PR_ASSERT(EEXIST == errno);\n-        _PR_MD_MAP_OPEN_ERROR(errno);\n-        goto Finished;\n-    }\n-\n-    urc = unlink(genName);\n-    if (-1 == urc) {\n-        _PR_MD_MAP_UNLINK_ERROR(errno);\n-        PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-               (\"_md_OpenAnonFileMap(): failed on unlink(), errno: %d\", errno));\n+    genName = PR_smprintf(NSPR_AFM_FILENAME, dirName, (int)pid, tid, incr);\n+    if (NULL == genName) {\n+      PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n+             (\"_md_OpenAnonFileMap(): PR_snprintf(): failed, generating \"\n+              \"filename\"));\n+      goto Finished;\n+    }\n+\n+    /* create the file */\n+    osfd = open(genName, (O_CREAT | O_EXCL | O_RDWR), mode);\n+    if (-1 == osfd) {\n+      if (EEXIST == errno) {\n         PR_smprintf_free(genName);\n-        close(osfd);\n-        goto Finished;\n-    }\n+        continue; /* name exists, try again */\n+      }\n+      _PR_MD_MAP_OPEN_ERROR(errno);\n+      PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n+             (\"_md_OpenAnonFileMap(): open(): failed, filename: %s, errno: %d\",\n+              genName, PR_GetOSError()));\n+      PR_smprintf_free(genName);\n+      goto Finished;\n+    }\n+    break; /* name generation and open successful, break; */\n+  } /* end for() */\n+\n+  if (incr == maxTries) {\n+    PR_ASSERT(-1 == osfd);\n+    PR_ASSERT(EEXIST == errno);\n+    _PR_MD_MAP_OPEN_ERROR(errno);\n+    goto Finished;\n+  }\n+\n+  urc = unlink(genName);\n+  if (-1 == urc) {\n+    _PR_MD_MAP_UNLINK_ERROR(errno);\n     PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-           (\"_md_OpenAnonFileMap(): unlink(): %s\", genName));\n-\n+           (\"_md_OpenAnonFileMap(): failed on unlink(), errno: %d\", errno));\n     PR_smprintf_free(genName);\n+    close(osfd);\n+    goto Finished;\n+  }\n+  PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n+         (\"_md_OpenAnonFileMap(): unlink(): %s\", genName));\n \n-    fd = PR_ImportFile(osfd);\n-    if (NULL == fd) {\n-        PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-               (\"_md_OpenAnonFileMap(): PR_ImportFile(): failed\"));\n-        goto Finished;\n-    }\n-    PR_LOG(_pr_shma_lm, PR_LOG_DEBUG, (\"_md_OpenAnonFileMap(): fd: %p\", fd));\n-\n-    urc = ftruncate(fd->secret->md.osfd, size);\n-    if (-1 == urc) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-               (\"_md_OpenAnonFileMap(): failed on ftruncate(), errno: %d\", errno));\n-        PR_Close(fd);\n-        goto Finished;\n-    }\n-    PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-           (\"_md_OpenAnonFileMap(): ftruncate(): size: %d\", size));\n-\n-    LL_UI2L(size64, size); /* PRSize (size_t) is unsigned */\n-    fm = PR_CreateFileMap(fd, size64, prot);\n-    if (NULL == fm) {\n-        PR_LOG(_pr_shma_lm, PR_LOG_DEBUG, (\"PR_OpenAnonFileMap(): failed\"));\n-        PR_Close(fd);\n-        goto Finished;\n-    }\n-    fm->md.isAnonFM = PR_TRUE; /* set fd close */\n+  PR_smprintf_free(genName);\n \n+  fd = PR_ImportFile(osfd);\n+  if (NULL == fd) {\n+    PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n+           (\"_md_OpenAnonFileMap(): PR_ImportFile(): failed\"));\n+    goto Finished;\n+  }\n+  PR_LOG(_pr_shma_lm, PR_LOG_DEBUG, (\"_md_OpenAnonFileMap(): fd: %p\", fd));\n+\n+  urc = ftruncate(fd->secret->md.osfd, size);\n+  if (-1 == urc) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n     PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-           (\"_md_OpenAnonFileMap(): PR_CreateFileMap(): fm: %p\", fm));\n+           (\"_md_OpenAnonFileMap(): failed on ftruncate(), errno: %d\", errno));\n+    PR_Close(fd);\n+    goto Finished;\n+  }\n+  PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n+         (\"_md_OpenAnonFileMap(): ftruncate(): size: %d\", size));\n+\n+  LL_UI2L(size64, size); /* PRSize (size_t) is unsigned */\n+  fm = PR_CreateFileMap(fd, size64, prot);\n+  if (NULL == fm) {\n+    PR_LOG(_pr_shma_lm, PR_LOG_DEBUG, (\"PR_OpenAnonFileMap(): failed\"));\n+    PR_Close(fd);\n+    goto Finished;\n+  }\n+  fm->md.isAnonFM = PR_TRUE; /* set fd close */\n+\n+  PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n+         (\"_md_OpenAnonFileMap(): PR_CreateFileMap(): fm: %p\", fm));\n \n Finished:\n-    return (fm);\n+  return (fm);\n } /* end md_OpenAnonFileMap() */\n \n /*\n@@ -565,51 +544,47 @@ Finished:\n **\n **\n */\n-extern PRStatus\n-_md_ExportFileMapAsString(PRFileMap* fm, PRSize bufSize,\n-                          char* buf)\n-{\n-    PRIntn written;\n-    PRIntn prot = (PRIntn)fm->prot;\n+extern PRStatus _md_ExportFileMapAsString(PRFileMap* fm, PRSize bufSize,\n+                                          char* buf) {\n+  PRIntn written;\n+  PRIntn prot = (PRIntn)fm->prot;\n \n-    written = PR_snprintf(buf, bufSize, \"%ld:%d\", fm->fd->secret->md.osfd, prot);\n+  written = PR_snprintf(buf, bufSize, \"%ld:%d\", fm->fd->secret->md.osfd, prot);\n \n-    return ((written == -1) ? PR_FAILURE : PR_SUCCESS);\n+  return ((written == -1) ? PR_FAILURE : PR_SUCCESS);\n } /* end _md_ExportFileMapAsString() */\n \n-extern PRFileMap*\n-_md_ImportFileMapFromString(const char* fmstring)\n-{\n-    PRStatus rc;\n-    PRInt32 osfd;\n-    PRIntn prot; /* really: a PRFileMapProtect */\n-    PRFileDesc* fd;\n-    PRFileMap* fm = NULL; /* default return value */\n-    PRFileInfo64 info;\n-\n-    PR_sscanf(fmstring, \"%ld:%d\", &osfd, &prot);\n-\n-    /* import the os file descriptor */\n-    fd = PR_ImportFile(osfd);\n-    if (NULL == fd) {\n-        PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-               (\"_md_ImportFileMapFromString(): PR_ImportFile() failed\"));\n-        goto Finished;\n-    }\n+extern PRFileMap* _md_ImportFileMapFromString(const char* fmstring) {\n+  PRStatus rc;\n+  PRInt32 osfd;\n+  PRIntn prot; /* really: a PRFileMapProtect */\n+  PRFileDesc* fd;\n+  PRFileMap* fm = NULL; /* default return value */\n+  PRFileInfo64 info;\n \n-    rc = PR_GetOpenFileInfo64(fd, &info);\n-    if (PR_FAILURE == rc) {\n-        PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-               (\"_md_ImportFileMapFromString(): PR_GetOpenFileInfo64() failed\"));\n-        goto Finished;\n-    }\n+  PR_sscanf(fmstring, \"%ld:%d\", &osfd, &prot);\n \n-    fm = PR_CreateFileMap(fd, info.size, (PRFileMapProtect)prot);\n-    if (NULL == fm) {\n-        PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-               (\"_md_ImportFileMapFromString(): PR_CreateFileMap() failed\"));\n-    }\n+  /* import the os file descriptor */\n+  fd = PR_ImportFile(osfd);\n+  if (NULL == fd) {\n+    PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n+           (\"_md_ImportFileMapFromString(): PR_ImportFile() failed\"));\n+    goto Finished;\n+  }\n+\n+  rc = PR_GetOpenFileInfo64(fd, &info);\n+  if (PR_FAILURE == rc) {\n+    PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n+           (\"_md_ImportFileMapFromString(): PR_GetOpenFileInfo64() failed\"));\n+    goto Finished;\n+  }\n+\n+  fm = PR_CreateFileMap(fd, info.size, (PRFileMapProtect)prot);\n+  if (NULL == fm) {\n+    PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n+           (\"_md_ImportFileMapFromString(): PR_CreateFileMap() failed\"));\n+  }\n \n Finished:\n-    return (fm);\n+  return (fm);\n } /* end _md_ImportFileMapFromString() */\ndiff --git a/nspr/pr/src/md/unix/uxwrap.c b/nspr/pr/src/md/unix/uxwrap.c\nindex ea33111..70f6597 100644\n--- a/nspr/pr/src/md/unix/uxwrap.c\n+++ b/nspr/pr/src/md/unix/uxwrap.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -17,11 +18,11 @@\n /* Do not wrap select() and poll(). */\n #else /* defined(_PR_PTHREADS) || defined(_PR_GLOBAL_THREADS_ONLY) */\n /* The include files for select() */\n-#include <string.h>\n-#include <sys/types.h>\n-#include <sys/time.h>\n+#  include <string.h>\n+#  include <sys/types.h>\n+#  include <sys/time.h>\n \n-#define ZAP_SET(_to, _width)                                                 \\\n+#  define ZAP_SET(_to, _width)                                               \\\n     PR_BEGIN_MACRO                                                           \\\n     memset(                                                                  \\\n         _to, 0,                                                              \\\n@@ -31,25 +32,21 @@\n /* see comments in ns/cmd/xfe/mozilla.c (look for \"PR_XGetXtHackFD\") */\n static int _pr_xt_hack_fd = -1;\n \n-int\n-PR_XGetXtHackFD(void)\n-{\n-    int fds[2];\n+int PR_XGetXtHackFD(void) {\n+  int fds[2];\n \n-    if (_pr_xt_hack_fd == -1) {\n-        if (!pipe(fds)) {\n-            _pr_xt_hack_fd = fds[0];\n-        }\n+  if (_pr_xt_hack_fd == -1) {\n+    if (!pipe(fds)) {\n+      _pr_xt_hack_fd = fds[0];\n     }\n-    return _pr_xt_hack_fd;\n+  }\n+  return _pr_xt_hack_fd;\n }\n \n static int (*_pr_xt_hack_okayToReleaseXLock)(void) = 0;\n \n-void\n-PR_SetXtHackOkayToReleaseXLockFn(int (*fn)(void))\n-{\n-    _pr_xt_hack_okayToReleaseXLock = fn;\n+void PR_SetXtHackOkayToReleaseXLockFn(int (*fn)(void)) {\n+  _pr_xt_hack_okayToReleaseXLock = fn;\n }\n \n /*\n@@ -62,210 +59,207 @@ PR_SetXtHackOkayToReleaseXLockFn(int (*fn)(void))\n  *-----------------------------------------------------------------------\n  */\n \n-#if defined(AIX_RENAME_SELECT)\n-int\n-wrap_select(unsigned long width, void* rl, void* wl, void* el,\n-            struct timeval* tv)\n-#elif defined(_PR_SELECT_CONST_TIMEVAL)\n-int\n-select(int width, fd_set* rd, fd_set* wr, fd_set* ex,\n-       const struct timeval* tv)\n-#else\n-int\n-select(int width, fd_set* rd, fd_set* wr, fd_set* ex, struct timeval* tv)\n-#endif\n+#  if defined(AIX_RENAME_SELECT)\n+int wrap_select(unsigned long width, void* rl, void* wl, void* el,\n+                struct timeval* tv)\n+#  elif defined(_PR_SELECT_CONST_TIMEVAL)\n+int select(int width, fd_set* rd, fd_set* wr, fd_set* ex,\n+           const struct timeval* tv)\n+#  else\n+int select(int width, fd_set* rd, fd_set* wr, fd_set* ex, struct timeval* tv)\n+#  endif\n {\n-    int osfd;\n-    _PRUnixPollDesc *unixpds, *unixpd, *eunixpd;\n-    PRInt32 pdcnt;\n-    PRIntervalTime timeout;\n-    int retVal;\n-#if defined(AIX_RENAME_SELECT)\n-    fd_set* rd = (fd_set*)rl;\n-    fd_set* wr = (fd_set*)wl;\n-    fd_set* ex = (fd_set*)el;\n-#endif\n-\n-#if 0\n+  int osfd;\n+  _PRUnixPollDesc *unixpds, *unixpd, *eunixpd;\n+  PRInt32 pdcnt;\n+  PRIntervalTime timeout;\n+  int retVal;\n+#  if defined(AIX_RENAME_SELECT)\n+  fd_set* rd = (fd_set*)rl;\n+  fd_set* wr = (fd_set*)wl;\n+  fd_set* ex = (fd_set*)el;\n+#  endif\n+\n+#  if 0\n     /*\n      * Easy special case: zero timeout.  Simply call the native\n      * select() with no fear of blocking.\n      */\n     if (tv != NULL && tv->tv_sec == 0 && tv->tv_usec == 0) {\n-#if defined(AIX_RENAME_SELECT)\n+#    if defined(AIX_RENAME_SELECT)\n         return _MD_SELECT(width, rl, wl, el, tv);\n-#else\n+#    else\n         return _MD_SELECT(width, rd, wr, ex, tv);\n-#endif\n+#    endif\n     }\n-#endif\n+#  endif\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-#ifndef _PR_LOCAL_THREADS_ONLY\n-    if (_PR_IS_NATIVE_THREAD(_PR_MD_CURRENT_THREAD())) {\n-        return _MD_SELECT(width, rd, wr, ex, tv);\n+#  ifndef _PR_LOCAL_THREADS_ONLY\n+  if (_PR_IS_NATIVE_THREAD(_PR_MD_CURRENT_THREAD())) {\n+    return _MD_SELECT(width, rd, wr, ex, tv);\n+  }\n+#  endif\n+\n+  if (width < 0 || width > FD_SETSIZE) {\n+    errno = EINVAL;\n+    return -1;\n+  }\n+\n+  /* Compute timeout */\n+  if (tv) {\n+    /*\n+     * These acceptable ranges for t_sec and t_usec are taken\n+     * from the select() man pages.\n+     */\n+    if (tv->tv_sec < 0 || tv->tv_sec > 100000000 || tv->tv_usec < 0 ||\n+        tv->tv_usec >= 1000000) {\n+      errno = EINVAL;\n+      return -1;\n     }\n-#endif\n \n-    if (width < 0 || width > FD_SETSIZE) {\n-        errno = EINVAL;\n-        return -1;\n+    /* Convert microseconds to ticks */\n+    timeout = PR_MicrosecondsToInterval(1000000 * tv->tv_sec + tv->tv_usec);\n+  } else {\n+    /* tv being a NULL pointer means blocking indefinitely */\n+    timeout = PR_INTERVAL_NO_TIMEOUT;\n+  }\n+\n+  /* Check for no descriptors case (just doing a timeout) */\n+  if ((!rd && !wr && !ex) || !width) {\n+    PR_Sleep(timeout);\n+    return 0;\n+  }\n+\n+  /*\n+   * Set up for PR_Poll().  The PRPollDesc array is allocated\n+   * dynamically.  If this turns out to have high performance\n+   * penalty, one can change to use a large PRPollDesc array\n+   * on the stack, and allocate dynamically only when it turns\n+   * out to be not large enough.\n+   *\n+   * I allocate an array of size 'width', which is the maximum\n+   * number of fds we may need to poll.\n+   */\n+  unixpds = (_PRUnixPollDesc*)PR_CALLOC(width * sizeof(_PRUnixPollDesc));\n+  if (!unixpds) {\n+    errno = ENOMEM;\n+    return -1;\n+  }\n+\n+  pdcnt = 0;\n+  unixpd = unixpds;\n+  for (osfd = 0; osfd < width; osfd++) {\n+    int in_flags = 0;\n+    if (rd && FD_ISSET(osfd, rd)) {\n+      in_flags |= _PR_UNIX_POLL_READ;\n+    }\n+    if (wr && FD_ISSET(osfd, wr)) {\n+      in_flags |= _PR_UNIX_POLL_WRITE;\n+    }\n+    if (ex && FD_ISSET(osfd, ex)) {\n+      in_flags |= _PR_UNIX_POLL_EXCEPT;\n+    }\n+    if (in_flags) {\n+      unixpd->osfd = osfd;\n+      unixpd->in_flags = in_flags;\n+      unixpd->out_flags = 0;\n+      unixpd++;\n+      pdcnt++;\n+    }\n+  }\n+\n+  /*\n+   * see comments in mozilla/cmd/xfe/mozilla.c (look for\n+   * \"PR_XGetXtHackFD\")\n+   */\n+  {\n+    int needToLockXAgain;\n+\n+    needToLockXAgain = 0;\n+    if (rd && (_pr_xt_hack_fd != -1) && FD_ISSET(_pr_xt_hack_fd, rd) &&\n+        _PR_XIsLocked() &&\n+        (!_pr_xt_hack_okayToReleaseXLock || _pr_xt_hack_okayToReleaseXLock())) {\n+      _PR_XUnlock();\n+      needToLockXAgain = 1;\n     }\n \n-    /* Compute timeout */\n-    if (tv) {\n-        /*\n-         * These acceptable ranges for t_sec and t_usec are taken\n-         * from the select() man pages.\n-         */\n-        if (tv->tv_sec < 0 || tv->tv_sec > 100000000 || tv->tv_usec < 0 ||\n-            tv->tv_usec >= 1000000) {\n-            errno = EINVAL;\n-            return -1;\n-        }\n+    /* This is the potentially blocking step */\n+    retVal = _PR_WaitForMultipleFDs(unixpds, pdcnt, timeout);\n \n-        /* Convert microseconds to ticks */\n-        timeout = PR_MicrosecondsToInterval(1000000 * tv->tv_sec + tv->tv_usec);\n-    } else {\n-        /* tv being a NULL pointer means blocking indefinitely */\n-        timeout = PR_INTERVAL_NO_TIMEOUT;\n+    if (needToLockXAgain) {\n+      _PR_XLock();\n     }\n+  }\n \n-    /* Check for no descriptors case (just doing a timeout) */\n-    if ((!rd && !wr && !ex) || !width) {\n-        PR_Sleep(timeout);\n-        return 0;\n+  if (retVal > 0) {\n+    /* Compute select results */\n+    if (rd) {\n+      ZAP_SET(rd, width);\n     }\n-\n-    /*\n-     * Set up for PR_Poll().  The PRPollDesc array is allocated\n-     * dynamically.  If this turns out to have high performance\n-     * penalty, one can change to use a large PRPollDesc array\n-     * on the stack, and allocate dynamically only when it turns\n-     * out to be not large enough.\n-     *\n-     * I allocate an array of size 'width', which is the maximum\n-     * number of fds we may need to poll.\n-     */\n-    unixpds = (_PRUnixPollDesc*)PR_CALLOC(width * sizeof(_PRUnixPollDesc));\n-    if (!unixpds) {\n-        errno = ENOMEM;\n-        return -1;\n+    if (wr) {\n+      ZAP_SET(wr, width);\n     }\n-\n-    pdcnt = 0;\n-    unixpd = unixpds;\n-    for (osfd = 0; osfd < width; osfd++) {\n-        int in_flags = 0;\n-        if (rd && FD_ISSET(osfd, rd)) {\n-            in_flags |= _PR_UNIX_POLL_READ;\n-        }\n-        if (wr && FD_ISSET(osfd, wr)) {\n-            in_flags |= _PR_UNIX_POLL_WRITE;\n-        }\n-        if (ex && FD_ISSET(osfd, ex)) {\n-            in_flags |= _PR_UNIX_POLL_EXCEPT;\n-        }\n-        if (in_flags) {\n-            unixpd->osfd = osfd;\n-            unixpd->in_flags = in_flags;\n-            unixpd->out_flags = 0;\n-            unixpd++;\n-            pdcnt++;\n-        }\n+    if (ex) {\n+      ZAP_SET(ex, width);\n     }\n \n     /*\n-     * see comments in mozilla/cmd/xfe/mozilla.c (look for\n-     * \"PR_XGetXtHackFD\")\n+     * The return value can be either the number of ready file\n+     * descriptors or the number of set bits in the three fd_set's.\n      */\n-    {\n-        int needToLockXAgain;\n-\n-        needToLockXAgain = 0;\n-        if (rd && (_pr_xt_hack_fd != -1) && FD_ISSET(_pr_xt_hack_fd, rd) &&\n-            _PR_XIsLocked() &&\n-            (!_pr_xt_hack_okayToReleaseXLock || _pr_xt_hack_okayToReleaseXLock())) {\n-            _PR_XUnlock();\n-            needToLockXAgain = 1;\n-        }\n-\n-        /* This is the potentially blocking step */\n-        retVal = _PR_WaitForMultipleFDs(unixpds, pdcnt, timeout);\n-\n-        if (needToLockXAgain) {\n-            _PR_XLock();\n-        }\n-    }\n-\n-    if (retVal > 0) {\n-        /* Compute select results */\n-        if (rd) {\n-            ZAP_SET(rd, width);\n+    retVal = 0; /* we're going to recompute */\n+    eunixpd = unixpds + pdcnt;\n+    for (unixpd = unixpds; unixpd < eunixpd; unixpd++) {\n+      if (unixpd->out_flags) {\n+        int nbits = 0; /* The number of set bits on for this fd */\n+\n+        if (unixpd->out_flags & _PR_UNIX_POLL_NVAL) {\n+          errno = EBADF;\n+          PR_LOG(_pr_io_lm, PR_LOG_ERROR,\n+                 (\"select returns EBADF for %d\", unixpd->osfd));\n+          retVal = -1;\n+          break;\n         }\n-        if (wr) {\n-            ZAP_SET(wr, width);\n-        }\n-        if (ex) {\n-            ZAP_SET(ex, width);\n-        }\n-\n         /*\n-         * The return value can be either the number of ready file\n-         * descriptors or the number of set bits in the three fd_set's.\n+         * If a socket has a pending error, it is considered\n+         * both readable and writable.  (See W. Richard Stevens,\n+         * Unix Network Programming, Vol. 1, 2nd Ed., Section 6.3,\n+         * pp. 153-154.)  We also consider a socket readable if\n+         * it has a hangup condition.\n          */\n-        retVal = 0; /* we're going to recompute */\n-        eunixpd = unixpds + pdcnt;\n-        for (unixpd = unixpds; unixpd < eunixpd; unixpd++) {\n-            if (unixpd->out_flags) {\n-                int nbits = 0; /* The number of set bits on for this fd */\n-\n-                if (unixpd->out_flags & _PR_UNIX_POLL_NVAL) {\n-                    errno = EBADF;\n-                    PR_LOG(_pr_io_lm, PR_LOG_ERROR,\n-                           (\"select returns EBADF for %d\", unixpd->osfd));\n-                    retVal = -1;\n-                    break;\n-                }\n-                /*\n-                 * If a socket has a pending error, it is considered\n-                 * both readable and writable.  (See W. Richard Stevens,\n-                 * Unix Network Programming, Vol. 1, 2nd Ed., Section 6.3,\n-                 * pp. 153-154.)  We also consider a socket readable if\n-                 * it has a hangup condition.\n-                 */\n-                if (rd && (unixpd->in_flags & _PR_UNIX_POLL_READ) &&\n-                    (unixpd->out_flags &\n-                     (_PR_UNIX_POLL_READ | _PR_UNIX_POLL_ERR | _PR_UNIX_POLL_HUP))) {\n-                    FD_SET(unixpd->osfd, rd);\n-                    nbits++;\n-                }\n-                if (wr && (unixpd->in_flags & _PR_UNIX_POLL_WRITE) &&\n-                    (unixpd->out_flags & (_PR_UNIX_POLL_WRITE | _PR_UNIX_POLL_ERR))) {\n-                    FD_SET(unixpd->osfd, wr);\n-                    nbits++;\n-                }\n-                if (ex && (unixpd->in_flags & _PR_UNIX_POLL_WRITE) &&\n-                    (unixpd->out_flags & PR_POLL_EXCEPT)) {\n-                    FD_SET(unixpd->osfd, ex);\n-                    nbits++;\n-                }\n-                PR_ASSERT(nbits > 0);\n-#if defined(HPUX) || defined(SOLARIS) || defined(AIX)\n-                retVal += nbits;\n-#endif\n-            }\n+        if (rd && (unixpd->in_flags & _PR_UNIX_POLL_READ) &&\n+            (unixpd->out_flags &\n+             (_PR_UNIX_POLL_READ | _PR_UNIX_POLL_ERR | _PR_UNIX_POLL_HUP))) {\n+          FD_SET(unixpd->osfd, rd);\n+          nbits++;\n+        }\n+        if (wr && (unixpd->in_flags & _PR_UNIX_POLL_WRITE) &&\n+            (unixpd->out_flags & (_PR_UNIX_POLL_WRITE | _PR_UNIX_POLL_ERR))) {\n+          FD_SET(unixpd->osfd, wr);\n+          nbits++;\n         }\n+        if (ex && (unixpd->in_flags & _PR_UNIX_POLL_WRITE) &&\n+            (unixpd->out_flags & PR_POLL_EXCEPT)) {\n+          FD_SET(unixpd->osfd, ex);\n+          nbits++;\n+        }\n+        PR_ASSERT(nbits > 0);\n+#  if defined(HPUX) || defined(SOLARIS) || defined(AIX)\n+        retVal += nbits;\n+#  endif\n+      }\n     }\n+  }\n \n-    PR_ASSERT(tv || retVal != 0);\n-    PR_LOG(_pr_io_lm, PR_LOG_MIN, (\"select returns %d\", retVal));\n-    PR_DELETE(unixpds);\n+  PR_ASSERT(tv || retVal != 0);\n+  PR_LOG(_pr_io_lm, PR_LOG_MIN, (\"select returns %d\", retVal));\n+  PR_DELETE(unixpds);\n \n-    return retVal;\n+  return retVal;\n }\n \n /*\n@@ -279,7 +273,7 @@ select(int width, fd_set* rd, fd_set* wr, fd_set* ex, struct timeval* tv)\n  * 2.0 Linux machines doesn't have the __syscall_poll symbol\n  * defined.  (WTC 30 Nov. 1998)\n  */\n-#if defined(_PR_POLL_AVAILABLE) && !defined(LINUX)\n+#  if defined(_PR_POLL_AVAILABLE) && !defined(LINUX)\n \n /*\n  *-----------------------------------------------------------------------\n@@ -294,216 +288,210 @@ select(int width, fd_set* rd, fd_set* wr, fd_set* ex, struct timeval* tv)\n  *-----------------------------------------------------------------------\n  */\n \n-#include <poll.h>\n-\n-#if defined(AIX_RENAME_SELECT)\n-int\n-wrap_poll(void* listptr, unsigned long nfds, long timeout)\n-#elif (defined(AIX) && !defined(AIX_RENAME_SELECT))\n-int\n-poll(void* listptr, unsigned long nfds, long timeout)\n-#elif defined(NETBSD)\n-int\n-poll(struct pollfd* filedes, nfds_t nfds, int timeout)\n-#elif defined(OPENBSD)\n-int\n-poll(struct pollfd filedes[], nfds_t nfds, int timeout)\n-#elif defined(FREEBSD)\n-int\n-poll(struct pollfd* filedes, unsigned nfds, int timeout)\n-#else\n-int\n-poll(struct pollfd* filedes, unsigned long nfds, int timeout)\n-#endif\n+#    include <poll.h>\n+\n+#    if defined(AIX_RENAME_SELECT)\n+int wrap_poll(void* listptr, unsigned long nfds, long timeout)\n+#    elif (defined(AIX) && !defined(AIX_RENAME_SELECT))\n+int poll(void* listptr, unsigned long nfds, long timeout)\n+#    elif defined(NETBSD)\n+int poll(struct pollfd* filedes, nfds_t nfds, int timeout)\n+#    elif defined(OPENBSD)\n+int poll(struct pollfd filedes[], nfds_t nfds, int timeout)\n+#    elif defined(FREEBSD)\n+int poll(struct pollfd* filedes, unsigned nfds, int timeout)\n+#    else\n+int poll(struct pollfd* filedes, unsigned long nfds, int timeout)\n+#    endif\n {\n-#ifdef AIX\n-    struct pollfd* filedes = (struct pollfd*)listptr;\n-#endif\n-    struct pollfd *pfd, *epfd;\n-    _PRUnixPollDesc *unixpds, *unixpd, *eunixpd;\n-    PRIntervalTime ticks;\n-    PRInt32 pdcnt;\n-    int ready;\n-\n+#    ifdef AIX\n+  struct pollfd* filedes = (struct pollfd*)listptr;\n+#    endif\n+  struct pollfd *pfd, *epfd;\n+  _PRUnixPollDesc *unixpds, *unixpd, *eunixpd;\n+  PRIntervalTime ticks;\n+  PRInt32 pdcnt;\n+  int ready;\n+\n+  /*\n+   * Easy special case: zero timeout.  Simply call the native\n+   * poll() with no fear of blocking.\n+   */\n+  if (timeout == 0) {\n+#    if defined(AIX)\n+    return _MD_POLL(listptr, nfds, timeout);\n+#    else\n+    return _MD_POLL(filedes, nfds, timeout);\n+#    endif\n+  }\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+#    ifndef _PR_LOCAL_THREADS_ONLY\n+  if (_PR_IS_NATIVE_THREAD(_PR_MD_CURRENT_THREAD())) {\n+    return _MD_POLL(filedes, nfds, timeout);\n+  }\n+#    endif\n+\n+  /* We do not support the pollmsg structures on AIX */\n+#    ifdef AIX\n+  PR_ASSERT((nfds & 0xff00) == 0);\n+#    endif\n+\n+  if (timeout < 0 && timeout != -1) {\n+    errno = EINVAL;\n+    return -1;\n+  }\n+\n+  /* Convert timeout from miliseconds to ticks */\n+  if (timeout == -1) {\n+    ticks = PR_INTERVAL_NO_TIMEOUT;\n+  } else {\n+    ticks = PR_MillisecondsToInterval(timeout);\n+  }\n+\n+  /* Check for no descriptor case (just do a timeout) */\n+  if (nfds == 0) {\n+    PR_Sleep(ticks);\n+    return 0;\n+  }\n+\n+  unixpds = (_PRUnixPollDesc*)PR_MALLOC(nfds * sizeof(_PRUnixPollDesc));\n+  if (NULL == unixpds) {\n+    errno = EAGAIN;\n+    return -1;\n+  }\n+\n+  pdcnt = 0;\n+  epfd = filedes + nfds;\n+  unixpd = unixpds;\n+  for (pfd = filedes; pfd < epfd; pfd++) {\n     /*\n-     * Easy special case: zero timeout.  Simply call the native\n-     * poll() with no fear of blocking.\n+     * poll() ignores negative fd's.\n      */\n-    if (timeout == 0) {\n-#if defined(AIX)\n-        return _MD_POLL(listptr, nfds, timeout);\n-#else\n-        return _MD_POLL(filedes, nfds, timeout);\n-#endif\n-    }\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-#ifndef _PR_LOCAL_THREADS_ONLY\n-    if (_PR_IS_NATIVE_THREAD(_PR_MD_CURRENT_THREAD())) {\n-        return _MD_POLL(filedes, nfds, timeout);\n-    }\n-#endif\n-\n-    /* We do not support the pollmsg structures on AIX */\n-#ifdef AIX\n-    PR_ASSERT((nfds & 0xff00) == 0);\n-#endif\n-\n-    if (timeout < 0 && timeout != -1) {\n-        errno = EINVAL;\n-        return -1;\n+    if (pfd->fd >= 0) {\n+      unixpd->osfd = pfd->fd;\n+#    ifdef _PR_USE_POLL\n+      unixpd->in_flags = pfd->events;\n+#    else\n+      /*\n+       * Map the poll events to one of the three that can be\n+       * represented by the select fd_sets:\n+       *     POLLIN, POLLRDNORM  ===> readable\n+       *     POLLOUT, POLLWRNORM ===> writable\n+       *     POLLPRI, POLLRDBAND ===> exception\n+       *     POLLNORM, POLLWRBAND (and POLLMSG on some platforms)\n+       *     are ignored.\n+       *\n+       * The output events POLLERR and POLLHUP are never turned on.\n+       * POLLNVAL may be turned on.\n+       */\n+      unixpd->in_flags = 0;\n+      if (pfd->events & (POLLIN\n+#      ifdef POLLRDNORM\n+                         | POLLRDNORM\n+#      endif\n+                         )) {\n+        unixpd->in_flags |= _PR_UNIX_POLL_READ;\n+      }\n+      if (pfd->events & (POLLOUT\n+#      ifdef POLLWRNORM\n+                         | POLLWRNORM\n+#      endif\n+                         )) {\n+        unixpd->in_flags |= _PR_UNIX_POLL_WRITE;\n+      }\n+      if (pfd->events & (POLLPRI\n+#      ifdef POLLRDBAND\n+                         | POLLRDBAND\n+#      endif\n+                         )) {\n+        unixpd->in_flags |= PR_POLL_EXCEPT;\n+      }\n+#    endif /* _PR_USE_POLL */\n+      unixpd->out_flags = 0;\n+      unixpd++;\n+      pdcnt++;\n     }\n+  }\n \n-    /* Convert timeout from miliseconds to ticks */\n-    if (timeout == -1) {\n-        ticks = PR_INTERVAL_NO_TIMEOUT;\n+  ready = _PR_WaitForMultipleFDs(unixpds, pdcnt, ticks);\n+  if (-1 == ready) {\n+    if (PR_GetError() == PR_PENDING_INTERRUPT_ERROR) {\n+      errno = EINTR; /* XXX we aren't interrupted by a signal, but... */\n     } else {\n-        ticks = PR_MillisecondsToInterval(timeout);\n-    }\n-\n-    /* Check for no descriptor case (just do a timeout) */\n-    if (nfds == 0) {\n-        PR_Sleep(ticks);\n-        return 0;\n+      errno = PR_GetOSError();\n     }\n-\n-    unixpds = (_PRUnixPollDesc*)PR_MALLOC(nfds * sizeof(_PRUnixPollDesc));\n-    if (NULL == unixpds) {\n-        errno = EAGAIN;\n-        return -1;\n-    }\n-\n-    pdcnt = 0;\n-    epfd = filedes + nfds;\n-    unixpd = unixpds;\n-    for (pfd = filedes; pfd < epfd; pfd++) {\n-        /*\n-         * poll() ignores negative fd's.\n-         */\n-        if (pfd->fd >= 0) {\n-            unixpd->osfd = pfd->fd;\n-#ifdef _PR_USE_POLL\n-            unixpd->in_flags = pfd->events;\n-#else\n-            /*\n-             * Map the poll events to one of the three that can be\n-             * represented by the select fd_sets:\n-             *     POLLIN, POLLRDNORM  ===> readable\n-             *     POLLOUT, POLLWRNORM ===> writable\n-             *     POLLPRI, POLLRDBAND ===> exception\n-             *     POLLNORM, POLLWRBAND (and POLLMSG on some platforms)\n-             *     are ignored.\n-             *\n-             * The output events POLLERR and POLLHUP are never turned on.\n-             * POLLNVAL may be turned on.\n-             */\n-            unixpd->in_flags = 0;\n-            if (pfd->events & (POLLIN\n-#ifdef POLLRDNORM\n-                               | POLLRDNORM\n-#endif\n-                               )) {\n-                unixpd->in_flags |= _PR_UNIX_POLL_READ;\n-            }\n-            if (pfd->events & (POLLOUT\n-#ifdef POLLWRNORM\n-                               | POLLWRNORM\n-#endif\n-                               )) {\n-                unixpd->in_flags |= _PR_UNIX_POLL_WRITE;\n-            }\n-            if (pfd->events & (POLLPRI\n-#ifdef POLLRDBAND\n-                               | POLLRDBAND\n-#endif\n-                               )) {\n-                unixpd->in_flags |= PR_POLL_EXCEPT;\n-            }\n-#endif /* _PR_USE_POLL */\n-            unixpd->out_flags = 0;\n-            unixpd++;\n-            pdcnt++;\n+  }\n+  if (ready <= 0) {\n+    goto done;\n+  }\n+\n+  /*\n+   * Copy the out_flags from the _PRUnixPollDesc structures to the\n+   * user's pollfd structures and free the allocated memory\n+   */\n+  unixpd = unixpds;\n+  for (pfd = filedes; pfd < epfd; pfd++) {\n+    pfd->revents = 0;\n+    if (pfd->fd >= 0) {\n+#    ifdef _PR_USE_POLL\n+      pfd->revents = unixpd->out_flags;\n+#    else\n+      if (0 != unixpd->out_flags) {\n+        if (unixpd->out_flags & _PR_UNIX_POLL_READ) {\n+          if (pfd->events & POLLIN) {\n+            pfd->revents |= POLLIN;\n+          }\n+#      ifdef POLLRDNORM\n+          if (pfd->events & POLLRDNORM) {\n+            pfd->revents |= POLLRDNORM;\n+          }\n+#      endif\n         }\n-    }\n-\n-    ready = _PR_WaitForMultipleFDs(unixpds, pdcnt, ticks);\n-    if (-1 == ready) {\n-        if (PR_GetError() == PR_PENDING_INTERRUPT_ERROR) {\n-            errno = EINTR; /* XXX we aren't interrupted by a signal, but... */\n-        } else {\n-            errno = PR_GetOSError();\n+        if (unixpd->out_flags & _PR_UNIX_POLL_WRITE) {\n+          if (pfd->events & POLLOUT) {\n+            pfd->revents |= POLLOUT;\n+          }\n+#      ifdef POLLWRNORM\n+          if (pfd->events & POLLWRNORM) {\n+            pfd->revents |= POLLWRNORM;\n+          }\n+#      endif\n         }\n-    }\n-    if (ready <= 0) {\n-        goto done;\n-    }\n-\n-    /*\n-     * Copy the out_flags from the _PRUnixPollDesc structures to the\n-     * user's pollfd structures and free the allocated memory\n-     */\n-    unixpd = unixpds;\n-    for (pfd = filedes; pfd < epfd; pfd++) {\n-        pfd->revents = 0;\n-        if (pfd->fd >= 0) {\n-#ifdef _PR_USE_POLL\n-            pfd->revents = unixpd->out_flags;\n-#else\n-            if (0 != unixpd->out_flags) {\n-                if (unixpd->out_flags & _PR_UNIX_POLL_READ) {\n-                    if (pfd->events & POLLIN) {\n-                        pfd->revents |= POLLIN;\n-                    }\n-#ifdef POLLRDNORM\n-                    if (pfd->events & POLLRDNORM) {\n-                        pfd->revents |= POLLRDNORM;\n-                    }\n-#endif\n-                }\n-                if (unixpd->out_flags & _PR_UNIX_POLL_WRITE) {\n-                    if (pfd->events & POLLOUT) {\n-                        pfd->revents |= POLLOUT;\n-                    }\n-#ifdef POLLWRNORM\n-                    if (pfd->events & POLLWRNORM) {\n-                        pfd->revents |= POLLWRNORM;\n-                    }\n-#endif\n-                }\n-                if (unixpd->out_flags & _PR_UNIX_POLL_EXCEPT) {\n-                    if (pfd->events & POLLPRI) {\n-                        pfd->revents |= POLLPRI;\n-                    }\n-#ifdef POLLRDBAND\n-                    if (pfd->events & POLLRDBAND) {\n-                        pfd->revents |= POLLRDBAND;\n-                    }\n-#endif\n-                }\n-                if (unixpd->out_flags & _PR_UNIX_POLL_ERR) {\n-                    pfd->revents |= POLLERR;\n-                }\n-                if (unixpd->out_flags & _PR_UNIX_POLL_NVAL) {\n-                    pfd->revents |= POLLNVAL;\n-                }\n-                if (unixpd->out_flags & _PR_UNIX_POLL_HUP) {\n-                    pfd->revents |= POLLHUP;\n-                }\n-            }\n-#endif /* _PR_USE_POLL */\n-            unixpd++;\n+        if (unixpd->out_flags & _PR_UNIX_POLL_EXCEPT) {\n+          if (pfd->events & POLLPRI) {\n+            pfd->revents |= POLLPRI;\n+          }\n+#      ifdef POLLRDBAND\n+          if (pfd->events & POLLRDBAND) {\n+            pfd->revents |= POLLRDBAND;\n+          }\n+#      endif\n+        }\n+        if (unixpd->out_flags & _PR_UNIX_POLL_ERR) {\n+          pfd->revents |= POLLERR;\n+        }\n+        if (unixpd->out_flags & _PR_UNIX_POLL_NVAL) {\n+          pfd->revents |= POLLNVAL;\n+        }\n+        if (unixpd->out_flags & _PR_UNIX_POLL_HUP) {\n+          pfd->revents |= POLLHUP;\n         }\n+      }\n+#    endif /* _PR_USE_POLL */\n+      unixpd++;\n     }\n+  }\n \n done:\n-    PR_DELETE(unixpds);\n-    return ready;\n+  PR_DELETE(unixpds);\n+  return ready;\n }\n \n-#endif /* !defined(LINUX) */\n+#  endif /* !defined(LINUX) */\n \n #endif /* defined(_PR_PTHREADS) || defined(_PR_GLOBAL_THREADS_ONLY) */\n \ndiff --git a/nspr/pr/src/md/windows/.cvsignore b/nspr/pr/src/md/windows/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/src/md/windows/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/src/md/windows/ntdllmn.c b/nspr/pr/src/md/windows/ntdllmn.c\nindex 54ef82c..fe2f643 100644\n--- a/nspr/pr/src/md/windows/ntdllmn.c\n+++ b/nspr/pr/src/md/windows/ntdllmn.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -20,35 +21,33 @@\n \n extern BOOL _pr_use_static_tls; /* defined in ntthread.c */\n \n-BOOL WINAPI\n-DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)\n-{\n-    PRThread* me;\n+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {\n+  PRThread* me;\n \n-    switch (fdwReason) {\n-        case DLL_PROCESS_ATTACH:\n-            /*\n-             * If lpvReserved is NULL, we are dynamically loaded\n-             * and therefore can't use static thread-local storage.\n-             */\n-            if (lpvReserved == NULL) {\n-                _pr_use_static_tls = FALSE;\n-            } else {\n-                _pr_use_static_tls = TRUE;\n-            }\n-            break;\n-        case DLL_THREAD_ATTACH:\n-            break;\n-        case DLL_THREAD_DETACH:\n-            if (_pr_initialized) {\n-                me = _MD_GET_ATTACHED_THREAD();\n-                if ((me != NULL) && (me->flags & _PR_ATTACHED)) {\n-                    _PRI_DetachThread();\n-                }\n-            }\n-            break;\n-        case DLL_PROCESS_DETACH:\n-            break;\n-    }\n-    return TRUE;\n+  switch (fdwReason) {\n+    case DLL_PROCESS_ATTACH:\n+      /*\n+       * If lpvReserved is NULL, we are dynamically loaded\n+       * and therefore can't use static thread-local storage.\n+       */\n+      if (lpvReserved == NULL) {\n+        _pr_use_static_tls = FALSE;\n+      } else {\n+        _pr_use_static_tls = TRUE;\n+      }\n+      break;\n+    case DLL_THREAD_ATTACH:\n+      break;\n+    case DLL_THREAD_DETACH:\n+      if (_pr_initialized) {\n+        me = _MD_GET_ATTACHED_THREAD();\n+        if ((me != NULL) && (me->flags & _PR_ATTACHED)) {\n+          _PRI_DetachThread();\n+        }\n+      }\n+      break;\n+    case DLL_PROCESS_DETACH:\n+      break;\n+  }\n+  return TRUE;\n }\ndiff --git a/nspr/pr/src/md/windows/ntgc.c b/nspr/pr/src/md/windows/ntgc.c\nindex c8528f1..e26efb0 100644\n--- a/nspr/pr/src/md/windows/ntgc.c\n+++ b/nspr/pr/src/md/windows/ntgc.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,64 +10,62 @@\n #include <windows.h>\n #include \"primpl.h\"\n \n-PRWord*\n-_MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n+PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) {\n #if defined(_X86_)\n-    CONTEXT context;\n-    context.ContextFlags = CONTEXT_INTEGER;\n+  CONTEXT context;\n+  context.ContextFlags = CONTEXT_INTEGER;\n \n-    if (_PR_IS_NATIVE_THREAD(t)) {\n-        context.ContextFlags |= CONTEXT_CONTROL;\n-        if (GetThreadContext(t->md.handle, &context)) {\n-            t->md.gcContext[0] = context.Eax;\n-            t->md.gcContext[1] = context.Ebx;\n-            t->md.gcContext[2] = context.Ecx;\n-            t->md.gcContext[3] = context.Edx;\n-            t->md.gcContext[4] = context.Esi;\n-            t->md.gcContext[5] = context.Edi;\n-            t->md.gcContext[6] = context.Esp;\n-            t->md.gcContext[7] = context.Ebp;\n-            *np = PR_NUM_GCREGS;\n-        } else {\n-            PR_ASSERT(0); /* XXX */\n-        }\n+  if (_PR_IS_NATIVE_THREAD(t)) {\n+    context.ContextFlags |= CONTEXT_CONTROL;\n+    if (GetThreadContext(t->md.handle, &context)) {\n+      t->md.gcContext[0] = context.Eax;\n+      t->md.gcContext[1] = context.Ebx;\n+      t->md.gcContext[2] = context.Ecx;\n+      t->md.gcContext[3] = context.Edx;\n+      t->md.gcContext[4] = context.Esi;\n+      t->md.gcContext[5] = context.Edi;\n+      t->md.gcContext[6] = context.Esp;\n+      t->md.gcContext[7] = context.Ebp;\n+      *np = PR_NUM_GCREGS;\n     } else {\n-        /* WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n-         *\n-         * This code is extremely machine dependant and completely\n-         * undocumented by MS.  Its only known to work experimentally.\n-         * Ready for a walk on the wild * side?\n-         *\n-         * WARNING WARNING WARNING WARNING WARNING WARNING WARNING */\n+      PR_ASSERT(0); /* XXX */\n+    }\n+  } else {\n+    /* WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n+     *\n+     * This code is extremely machine dependant and completely\n+     * undocumented by MS.  Its only known to work experimentally.\n+     * Ready for a walk on the wild * side?\n+     *\n+     * WARNING WARNING WARNING WARNING WARNING WARNING WARNING */\n \n-#if !defined WIN95 // Win95 does not have fibers\n-        int* fiberData = t->md.fiber_id;\n+#  if !defined WIN95  // Win95 does not have fibers\n+    int* fiberData = t->md.fiber_id;\n \n-        /* I found these offsets by disassembling SwitchToFiber().\n-         * Are your palms sweating yet?\n-         */\n+    /* I found these offsets by disassembling SwitchToFiber().\n+     * Are your palms sweating yet?\n+     */\n \n-        /*\n-        ** EAX is on the stack (ESP+0)\n-        ** EDX is on the stack (ESP+4)\n-        ** ECX is on the stack (ESP+8)\n-        */\n-        t->md.gcContext[0] = 0;               /* context.Eax */\n-        t->md.gcContext[1] = fiberData[0x2e]; /* context.Ebx */\n-        t->md.gcContext[2] = 0;               /* context.Ecx */\n-        t->md.gcContext[3] = 0;               /* context.Edx */\n-        t->md.gcContext[4] = fiberData[0x2d]; /* context.Esi */\n-        t->md.gcContext[5] = fiberData[0x2c]; /* context.Edi */\n-        t->md.gcContext[6] = fiberData[0x36]; /* context.Esp */\n-        t->md.gcContext[7] = fiberData[0x32]; /* context.Ebp */\n-        *np = PR_NUM_GCREGS;\n-#endif\n-    }\n-    return (PRWord*)&t->md.gcContext;\n+    /*\n+    ** EAX is on the stack (ESP+0)\n+    ** EDX is on the stack (ESP+4)\n+    ** ECX is on the stack (ESP+8)\n+    */\n+    t->md.gcContext[0] = 0;               /* context.Eax */\n+    t->md.gcContext[1] = fiberData[0x2e]; /* context.Ebx */\n+    t->md.gcContext[2] = 0;               /* context.Ecx */\n+    t->md.gcContext[3] = 0;               /* context.Edx */\n+    t->md.gcContext[4] = fiberData[0x2d]; /* context.Esi */\n+    t->md.gcContext[5] = fiberData[0x2c]; /* context.Edi */\n+    t->md.gcContext[6] = fiberData[0x36]; /* context.Esp */\n+    t->md.gcContext[7] = fiberData[0x32]; /* context.Ebp */\n+    *np = PR_NUM_GCREGS;\n+#  endif\n+  }\n+  return (PRWord*)&t->md.gcContext;\n #else\n-    PR_NOT_REACHED(\"not implemented\");\n-    return NULL;\n+  PR_NOT_REACHED(\"not implemented\");\n+  return NULL;\n #endif /* defined(_X86_) */\n }\n \n@@ -74,25 +73,23 @@ _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np)\n  * If you ever need to get the fiberID from the currently running fiber,\n  * this is it.\n  */\n-void*\n-GetMyFiberID()\n-{\n+void* GetMyFiberID() {\n #if defined(_X86_) && !defined(__MINGW32__)\n-    void* fiberData;\n+  void* fiberData;\n \n-    /* A pointer to our tib entry is found at FS:[18]\n-     * At offset 10h is the fiberData pointer.  The context of the\n-     * fiber is stored in there.\n-     */\n-    __asm {\n+  /* A pointer to our tib entry is found at FS:[18]\n+   * At offset 10h is the fiberData pointer.  The context of the\n+   * fiber is stored in there.\n+   */\n+  __asm {\n         mov    EDX, FS:[18h]\n         mov    EAX, DWORD PTR [EDX+10h]\n         mov    [fiberData], EAX\n-    }\n+  }\n \n-    return fiberData;\n+  return fiberData;\n #else\n-    PR_NOT_REACHED(\"not implemented\");\n-    return NULL;\n+  PR_NOT_REACHED(\"not implemented\");\n+  return NULL;\n #endif /* defined(_X86_) */\n }\ndiff --git a/nspr/pr/src/md/windows/ntinrval.c b/nspr/pr/src/md/windows/ntinrval.c\nindex ec6b34b..8874667 100644\n--- a/nspr/pr/src/md/windows/ntinrval.c\n+++ b/nspr/pr/src/md/windows/ntinrval.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,7 +10,7 @@\n \n /* Mozilla's build system defines this globally. */\n #ifdef WIN32_LEAN_AND_MEAN\n-#undef WIN32_LEAN_AND_MEAN\n+#  undef WIN32_LEAN_AND_MEAN\n #endif\n #include \"primpl.h\"\n \n@@ -18,32 +19,24 @@ typedef DWORD (*IntervalFuncType)(void);\n static IntervalFuncType intervalFunc;\n #endif\n \n-void\n-_PR_MD_INTERVAL_INIT()\n-{\n+void _PR_MD_INTERVAL_INIT() {\n #ifdef WINCE\n-    HMODULE mmtimerlib = LoadLibraryW(L\"mmtimer.dll\"); /* XXX leaked! */\n-    if (mmtimerlib) {\n-        intervalFunc = (IntervalFuncType)GetProcAddress(mmtimerlib, \"timeGetTime\");\n-    } else {\n-        intervalFunc = &GetTickCount;\n-    }\n+  HMODULE mmtimerlib = LoadLibraryW(L\"mmtimer.dll\"); /* XXX leaked! */\n+  if (mmtimerlib) {\n+    intervalFunc = (IntervalFuncType)GetProcAddress(mmtimerlib, \"timeGetTime\");\n+  } else {\n+    intervalFunc = &GetTickCount;\n+  }\n #endif\n }\n \n-PRIntervalTime\n-_PR_MD_GET_INTERVAL()\n-{\n-    /* milliseconds since system start */\n+PRIntervalTime _PR_MD_GET_INTERVAL() {\n+  /* milliseconds since system start */\n #ifdef WINCE\n-    return (*intervalFunc)();\n+  return (*intervalFunc)();\n #else\n-    return timeGetTime();\n+  return timeGetTime();\n #endif\n }\n \n-PRIntervalTime\n-_PR_MD_INTERVAL_PER_SEC()\n-{\n-    return 1000;\n-}\n+PRIntervalTime _PR_MD_INTERVAL_PER_SEC() { return 1000; }\ndiff --git a/nspr/pr/src/md/windows/ntio.c b/nspr/pr/src/md/windows/ntio.c\nindex 284b52a..d346d18 100644\n--- a/nspr/pr/src/md/windows/ntio.c\n+++ b/nspr/pr/src/md/windows/ntio.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -51,22 +52,22 @@ extern PRUint32 _nt_idleCount;\n /*\n  * NSPR-to-NT access right mapping table for files.\n  */\n-static DWORD fileAccessTable[] = { FILE_GENERIC_READ, FILE_GENERIC_WRITE,\n-                                   FILE_GENERIC_EXECUTE };\n+static DWORD fileAccessTable[] = {FILE_GENERIC_READ, FILE_GENERIC_WRITE,\n+                                  FILE_GENERIC_EXECUTE};\n \n /*\n  * NSPR-to-NT access right mapping table for directories.\n  */\n-static DWORD dirAccessTable[] = { FILE_GENERIC_READ,\n-                                  FILE_GENERIC_WRITE | FILE_DELETE_CHILD,\n-                                  FILE_GENERIC_EXECUTE };\n+static DWORD dirAccessTable[] = {FILE_GENERIC_READ,\n+                                 FILE_GENERIC_WRITE | FILE_DELETE_CHILD,\n+                                 FILE_GENERIC_EXECUTE};\n \n static PRBool IsPrevCharSlash(const char* str, const char* current);\n \n #define _NEED_351_FILE_LOCKING_HACK\n #ifdef _NEED_351_FILE_LOCKING_HACK\n-#define _PR_LOCAL_FILE 1\n-#define _PR_REMOTE_FILE 2\n+#  define _PR_LOCAL_FILE 1\n+#  define _PR_REMOTE_FILE 2\n PRBool IsFileLocalInit();\n PRInt32 IsFileLocal(HANDLE hFile);\n #endif /* _NEED_351_FILE_LOCKING_HACK */\n@@ -101,7 +102,7 @@ static PRInt32 _nt_nonblock_recvfrom(PRFileDesc*, char*, int, struct sockaddr*,\n  * parent process.\n  */\n #define _NT_USE_NB_IO(fd) \\\n-    ((fd)->secret->nonblocking || (fd)->secret->inheritable == _PR_TRI_TRUE)\n+  ((fd)->secret->nonblocking || (fd)->secret->inheritable == _PR_TRI_TRUE)\n \n /*\n  * UDP support\n@@ -121,70 +122,70 @@ typedef struct pt_Continuation pt_Continuation;\n typedef PRBool (*ContinuationFn)(pt_Continuation* op, PRInt16 revent);\n \n typedef enum pr_ContuationStatus {\n-    pt_continuation_sumbitted,\n-    pt_continuation_inprogress,\n-    pt_continuation_abort,\n-    pt_continuation_done\n+  pt_continuation_sumbitted,\n+  pt_continuation_inprogress,\n+  pt_continuation_abort,\n+  pt_continuation_done\n } pr_ContuationStatus;\n \n struct pt_Continuation {\n-    /* These objects are linked in ascending timeout order */\n-    pt_Continuation *next, *prev; /* self linked list of these things */\n-\n-    /* The building of the continuation operation */\n-    ContinuationFn function; /* what function to continue */\n-    union {\n-        SOCKET osfd;\n-    } arg1; /* #1 - the op's fd */\n-    union {\n-        void* buffer;\n-    } arg2; /* #2 - primary transfer buffer */\n-    union {\n-        PRIntn amount;\n-    } arg3; /* #3 - size of 'buffer' */\n-    union {\n-        PRIntn flags;\n-    } arg4; /* #4 - read/write flags */\n-    union {\n-        PRNetAddr* addr;\n-    } arg5; /* #5 - send/recv address */\n-\n-    PRIntervalTime timeout; /* representation of the timeout */\n-\n-    PRIntn event; /* flags for select()'s events */\n-\n-    /*\n-    ** The representation and notification of the results of the operation.\n-    ** These function can either return an int return code or a pointer to\n-    ** some object.\n-    */\n-    union {\n-        PRIntn code;\n-        void* object;\n-    } result;\n-\n-    PRIntn syserrno;            /* in case it failed, why (errno) */\n-    pr_ContuationStatus status; /* the status of the operation */\n-    PRCondVar* complete;        /* to notify the initiating thread */\n+  /* These objects are linked in ascending timeout order */\n+  pt_Continuation *next, *prev; /* self linked list of these things */\n+\n+  /* The building of the continuation operation */\n+  ContinuationFn function; /* what function to continue */\n+  union {\n+    SOCKET osfd;\n+  } arg1; /* #1 - the op's fd */\n+  union {\n+    void* buffer;\n+  } arg2; /* #2 - primary transfer buffer */\n+  union {\n+    PRIntn amount;\n+  } arg3; /* #3 - size of 'buffer' */\n+  union {\n+    PRIntn flags;\n+  } arg4; /* #4 - read/write flags */\n+  union {\n+    PRNetAddr* addr;\n+  } arg5; /* #5 - send/recv address */\n+\n+  PRIntervalTime timeout; /* representation of the timeout */\n+\n+  PRIntn event; /* flags for select()'s events */\n+\n+  /*\n+  ** The representation and notification of the results of the operation.\n+  ** These function can either return an int return code or a pointer to\n+  ** some object.\n+  */\n+  union {\n+    PRIntn code;\n+    void* object;\n+  } result;\n+\n+  PRIntn syserrno;            /* in case it failed, why (errno) */\n+  pr_ContuationStatus status; /* the status of the operation */\n+  PRCondVar* complete;        /* to notify the initiating thread */\n };\n \n static struct pt_TimedQueue {\n-    PRLock* ml;                   /* a little protection */\n-    PRThread* thread;             /* internal thread's identification */\n-    PRCondVar* new_op;            /* new operation supplied */\n-    PRCondVar* finish_op;         /* an existing operation finished */\n-    PRUintn op_count;             /* number of operations in the list */\n-    pt_Continuation *head, *tail; /* head/tail of list of operations */\n-\n-    pt_Continuation* op;  /* timed operation furthest in future */\n-    PRIntervalTime epoch; /* the epoch of 'timed' */\n+  PRLock* ml;                   /* a little protection */\n+  PRThread* thread;             /* internal thread's identification */\n+  PRCondVar* new_op;            /* new operation supplied */\n+  PRCondVar* finish_op;         /* an existing operation finished */\n+  PRUintn op_count;             /* number of operations in the list */\n+  pt_Continuation *head, *tail; /* head/tail of list of operations */\n+\n+  pt_Continuation* op;  /* timed operation furthest in future */\n+  PRIntervalTime epoch; /* the epoch of 'timed' */\n } pt_tq;\n \n #if defined(DEBUG)\n static struct pt_debug_s {\n-    PRIntn predictionsFoiled;\n-    PRIntn pollingListMax;\n-    PRIntn continuationsServed;\n+  PRIntn predictionsFoiled;\n+  PRIntn pollingListMax;\n+  PRIntn continuationsServed;\n } pt_debug;\n #endif /* DEBUG */\n \n@@ -203,522 +204,509 @@ static PRInt32 pt_RecvFrom(SOCKET osfd, void* buf, PRInt32 amount,\n #define KEY_IO 0xaaaaaaaa\n #define KEY_CVAR 0xbbbbbbbb\n \n-PRInt32\n-_PR_MD_PAUSE_CPU(PRIntervalTime ticks)\n-{\n-    int awoken = 0;\n-    unsigned long bytes, key;\n-    int rv;\n-    LPOVERLAPPED olp;\n-    _MDOverlapped* mdOlp;\n-    PRUint32 timeout;\n-\n-    if (_nt_idleCount > 0) {\n-        PRThread* deadThread;\n-\n-        _MD_LOCK(&_nt_idleLock);\n-        while (!PR_CLIST_IS_EMPTY(&_nt_idleList)) {\n-            deadThread = _PR_THREAD_PTR(PR_LIST_HEAD(&_nt_idleList));\n-            PR_REMOVE_LINK(&deadThread->links);\n-\n-            PR_ASSERT(deadThread->state == _PR_DEAD_STATE);\n-\n-            /* XXXMB - cleanup to do here? */\n-            if (!_PR_IS_NATIVE_THREAD(deadThread)) {\n-                /* Spinlock while user thread is still running.\n-                 * There is no way to use a condition variable here. The thread\n-                 * is dead, and we have to wait until we switch off the dead\n-                 * thread before we can kill the fiber completely.\n-                 */\n-                while (deadThread->no_sched)\n-                    ;\n-\n-                DeleteFiber(deadThread->md.fiber_id);\n-            }\n-            memset(deadThread, 0xa, sizeof(PRThread)); /* debugging */\n-            if (!deadThread->threadAllocatedOnStack) {\n-                PR_DELETE(deadThread);\n-            }\n-            _nt_idleCount--;\n-        }\n-        _MD_UNLOCK(&_nt_idleLock);\n+PRInt32 _PR_MD_PAUSE_CPU(PRIntervalTime ticks) {\n+  int awoken = 0;\n+  unsigned long bytes, key;\n+  int rv;\n+  LPOVERLAPPED olp;\n+  _MDOverlapped* mdOlp;\n+  PRUint32 timeout;\n+\n+  if (_nt_idleCount > 0) {\n+    PRThread* deadThread;\n+\n+    _MD_LOCK(&_nt_idleLock);\n+    while (!PR_CLIST_IS_EMPTY(&_nt_idleList)) {\n+      deadThread = _PR_THREAD_PTR(PR_LIST_HEAD(&_nt_idleList));\n+      PR_REMOVE_LINK(&deadThread->links);\n+\n+      PR_ASSERT(deadThread->state == _PR_DEAD_STATE);\n+\n+      /* XXXMB - cleanup to do here? */\n+      if (!_PR_IS_NATIVE_THREAD(deadThread)) {\n+        /* Spinlock while user thread is still running.\n+         * There is no way to use a condition variable here. The thread\n+         * is dead, and we have to wait until we switch off the dead\n+         * thread before we can kill the fiber completely.\n+         */\n+        while (deadThread->no_sched);\n+\n+        DeleteFiber(deadThread->md.fiber_id);\n+      }\n+      memset(deadThread, 0xa, sizeof(PRThread)); /* debugging */\n+      if (!deadThread->threadAllocatedOnStack) {\n+        PR_DELETE(deadThread);\n+      }\n+      _nt_idleCount--;\n     }\n+    _MD_UNLOCK(&_nt_idleLock);\n+  }\n \n-    if (ticks == PR_INTERVAL_NO_TIMEOUT)\n+  if (ticks == PR_INTERVAL_NO_TIMEOUT)\n #if 0\n         timeout = INFINITE;\n #else\n-        /*\n-         * temporary hack to poll the runq every 5 seconds because of bug in\n-         * native threads creating user threads and not poking the right cpu.\n-         *\n-         * A local thread that was interrupted is bound to its current\n-         * cpu but there is no easy way for the interrupter to poke the\n-         * right cpu.  This is a hack to poll the runq every 5 seconds.\n-         */\n-        timeout = 5000;\n+    /*\n+     * temporary hack to poll the runq every 5 seconds because of bug in\n+     * native threads creating user threads and not poking the right cpu.\n+     *\n+     * A local thread that was interrupted is bound to its current\n+     * cpu but there is no easy way for the interrupter to poke the\n+     * right cpu.  This is a hack to poll the runq every 5 seconds.\n+     */\n+    timeout = 5000;\n #endif\n-    else {\n-        timeout = PR_IntervalToMilliseconds(ticks);\n+  else {\n+    timeout = PR_IntervalToMilliseconds(ticks);\n+  }\n+\n+  /*\n+   * The idea of looping here is to complete as many IOs as possible before\n+   * returning.  This should minimize trips to the idle thread.\n+   */\n+  while (1) {\n+    rv = GetQueuedCompletionStatus(_pr_completion_port, &bytes, &key, &olp,\n+                                   timeout);\n+    if (rv == 0 && olp == NULL) {\n+      /* Error in GetQueuedCompetionStatus */\n+      if (GetLastError() != WAIT_TIMEOUT) {\n+        /* ARGH - what can we do here? Log an error? XXXMB */\n+        return -1;\n+      } else {\n+        /* If awoken == 0, then we just had a timeout */\n+        return awoken;\n+      }\n     }\n \n-    /*\n-     * The idea of looping here is to complete as many IOs as possible before\n-     * returning.  This should minimize trips to the idle thread.\n-     */\n-    while (1) {\n-        rv = GetQueuedCompletionStatus(_pr_completion_port, &bytes, &key, &olp,\n-                                       timeout);\n-        if (rv == 0 && olp == NULL) {\n-            /* Error in GetQueuedCompetionStatus */\n-            if (GetLastError() != WAIT_TIMEOUT) {\n-                /* ARGH - what can we do here? Log an error? XXXMB */\n-                return -1;\n-            } else {\n-                /* If awoken == 0, then we just had a timeout */\n-                return awoken;\n-            }\n-        }\n+    if (olp == NULL) {\n+      return 0;\n+    }\n \n-        if (olp == NULL) {\n-            return 0;\n-        }\n+    mdOlp = (_MDOverlapped*)olp;\n \n-        mdOlp = (_MDOverlapped*)olp;\n-\n-        if (mdOlp->ioModel == _MD_MultiWaitIO) {\n-            PRRecvWait* desc;\n-            PRWaitGroup* group;\n-            PRThread* thred = NULL;\n-            PRMWStatus mwstatus;\n-\n-            desc = mdOlp->data.mw.desc;\n-            PR_ASSERT(desc != NULL);\n-            mwstatus = rv ? PR_MW_SUCCESS : PR_MW_FAILURE;\n-            if (InterlockedCompareExchange((PVOID*)&desc->outcome, (PVOID)mwstatus,\n-                                           (PVOID)PR_MW_PENDING) ==\n-                (PVOID)PR_MW_PENDING) {\n-                if (mwstatus == PR_MW_SUCCESS) {\n-                    desc->bytesRecv = bytes;\n-                } else {\n-                    mdOlp->data.mw.error = GetLastError();\n-                }\n-            }\n-            group = mdOlp->data.mw.group;\n-            PR_ASSERT(group != NULL);\n-\n-            _PR_MD_LOCK(&group->mdlock);\n-            PR_APPEND_LINK(&mdOlp->data.mw.links, &group->io_ready);\n-            PR_ASSERT(desc->fd != NULL);\n-            NT_HashRemoveInternal(group, desc->fd);\n-            if (!PR_CLIST_IS_EMPTY(&group->wait_list)) {\n-                thred = _PR_THREAD_CONDQ_PTR(PR_LIST_HEAD(&group->wait_list));\n-                PR_REMOVE_LINK(&thred->waitQLinks);\n-            }\n-            _PR_MD_UNLOCK(&group->mdlock);\n-\n-            if (thred) {\n-                if (!_PR_IS_NATIVE_THREAD(thred)) {\n-                    int pri = thred->priority;\n-                    _PRCPU* lockedCPU = _PR_MD_CURRENT_CPU();\n-                    _PR_THREAD_LOCK(thred);\n-                    if (thred->flags & _PR_ON_PAUSEQ) {\n-                        _PR_SLEEPQ_LOCK(thred->cpu);\n-                        _PR_DEL_SLEEPQ(thred, PR_TRUE);\n-                        _PR_SLEEPQ_UNLOCK(thred->cpu);\n-                        _PR_THREAD_UNLOCK(thred);\n-                        thred->cpu = lockedCPU;\n-                        thred->state = _PR_RUNNABLE;\n-                        _PR_RUNQ_LOCK(lockedCPU);\n-                        _PR_ADD_RUNQ(thred, lockedCPU, pri);\n-                        _PR_RUNQ_UNLOCK(lockedCPU);\n-                    } else {\n-                        /*\n-                         * The thread was just interrupted and moved\n-                         * from the pause queue to the run queue.\n-                         */\n-                        _PR_THREAD_UNLOCK(thred);\n-                    }\n-                } else {\n-                    _PR_THREAD_LOCK(thred);\n-                    thred->state = _PR_RUNNABLE;\n-                    _PR_THREAD_UNLOCK(thred);\n-                    ReleaseSemaphore(thred->md.blocked_sema, 1, NULL);\n-                }\n-            }\n-        } else {\n-            PRThread* completed_io;\n+    if (mdOlp->ioModel == _MD_MultiWaitIO) {\n+      PRRecvWait* desc;\n+      PRWaitGroup* group;\n+      PRThread* thred = NULL;\n+      PRMWStatus mwstatus;\n \n-            PR_ASSERT(mdOlp->ioModel == _MD_BlockingIO);\n-            completed_io = _PR_THREAD_MD_TO_PTR(mdOlp->data.mdThread);\n-            completed_io->md.blocked_io_status = rv;\n-            if (rv == 0) {\n-                completed_io->md.blocked_io_error = GetLastError();\n-            }\n-            completed_io->md.blocked_io_bytes = bytes;\n-\n-            if (!_PR_IS_NATIVE_THREAD(completed_io)) {\n-                int pri = completed_io->priority;\n-                _PRCPU* lockedCPU = _PR_MD_CURRENT_CPU();\n-\n-                /* The KEY_CVAR notification only occurs when a native thread\n-                 * is notifying a user thread.  For user-user notifications\n-                 * the wakeup occurs by having the notifier place the thread\n-                 * on the runq directly; for native-native notifications the\n-                 * wakeup occurs by calling ReleaseSemaphore.\n-                 */\n-                if (key == KEY_CVAR) {\n-                    PR_ASSERT(completed_io->io_pending == PR_FALSE);\n-                    PR_ASSERT(completed_io->io_suspended == PR_FALSE);\n-                    PR_ASSERT(completed_io->md.thr_bound_cpu == NULL);\n-\n-                    /* Thread has already been deleted from sleepQ */\n-\n-                    /* Switch CPU and add to runQ */\n-                    completed_io->cpu = lockedCPU;\n-                    completed_io->state = _PR_RUNNABLE;\n-                    _PR_RUNQ_LOCK(lockedCPU);\n-                    _PR_ADD_RUNQ(completed_io, lockedCPU, pri);\n-                    _PR_RUNQ_UNLOCK(lockedCPU);\n-                } else {\n-                    PR_ASSERT(key == KEY_IO);\n-                    PR_ASSERT(completed_io->io_pending == PR_TRUE);\n-\n-                    _PR_THREAD_LOCK(completed_io);\n-\n-                    completed_io->io_pending = PR_FALSE;\n-\n-                    /* If io_suspended is true, then this IO has already resumed.\n-                     * We don't need to do anything; because the thread is\n-                     * already running.\n-                     */\n-                    if (completed_io->io_suspended == PR_FALSE) {\n-                        if (completed_io->flags & (_PR_ON_SLEEPQ | _PR_ON_PAUSEQ)) {\n-                            _PR_SLEEPQ_LOCK(completed_io->cpu);\n-                            _PR_DEL_SLEEPQ(completed_io, PR_TRUE);\n-                            _PR_SLEEPQ_UNLOCK(completed_io->cpu);\n-\n-                            _PR_THREAD_UNLOCK(completed_io);\n-\n-                            /*\n-                             * If an I/O operation is suspended, the thread\n-                             * must be running on the same cpu on which the\n-                             * I/O operation was issued.\n-                             */\n-                            PR_ASSERT(!completed_io->md.thr_bound_cpu ||\n-                                      (completed_io->cpu == completed_io->md.thr_bound_cpu));\n-\n-                            if (!completed_io->md.thr_bound_cpu) {\n-                                completed_io->cpu = lockedCPU;\n-                            }\n-                            completed_io->state = _PR_RUNNABLE;\n-                            _PR_RUNQ_LOCK(completed_io->cpu);\n-                            _PR_ADD_RUNQ(completed_io, completed_io->cpu, pri);\n-                            _PR_RUNQ_UNLOCK(completed_io->cpu);\n-                        } else {\n-                            _PR_THREAD_UNLOCK(completed_io);\n-                        }\n-                    } else {\n-                        _PR_THREAD_UNLOCK(completed_io);\n-                    }\n-                }\n+      desc = mdOlp->data.mw.desc;\n+      PR_ASSERT(desc != NULL);\n+      mwstatus = rv ? PR_MW_SUCCESS : PR_MW_FAILURE;\n+      if (InterlockedCompareExchange((PVOID*)&desc->outcome, (PVOID)mwstatus,\n+                                     (PVOID)PR_MW_PENDING) ==\n+          (PVOID)PR_MW_PENDING) {\n+        if (mwstatus == PR_MW_SUCCESS) {\n+          desc->bytesRecv = bytes;\n+        } else {\n+          mdOlp->data.mw.error = GetLastError();\n+        }\n+      }\n+      group = mdOlp->data.mw.group;\n+      PR_ASSERT(group != NULL);\n+\n+      _PR_MD_LOCK(&group->mdlock);\n+      PR_APPEND_LINK(&mdOlp->data.mw.links, &group->io_ready);\n+      PR_ASSERT(desc->fd != NULL);\n+      NT_HashRemoveInternal(group, desc->fd);\n+      if (!PR_CLIST_IS_EMPTY(&group->wait_list)) {\n+        thred = _PR_THREAD_CONDQ_PTR(PR_LIST_HEAD(&group->wait_list));\n+        PR_REMOVE_LINK(&thred->waitQLinks);\n+      }\n+      _PR_MD_UNLOCK(&group->mdlock);\n+\n+      if (thred) {\n+        if (!_PR_IS_NATIVE_THREAD(thred)) {\n+          int pri = thred->priority;\n+          _PRCPU* lockedCPU = _PR_MD_CURRENT_CPU();\n+          _PR_THREAD_LOCK(thred);\n+          if (thred->flags & _PR_ON_PAUSEQ) {\n+            _PR_SLEEPQ_LOCK(thred->cpu);\n+            _PR_DEL_SLEEPQ(thred, PR_TRUE);\n+            _PR_SLEEPQ_UNLOCK(thred->cpu);\n+            _PR_THREAD_UNLOCK(thred);\n+            thred->cpu = lockedCPU;\n+            thred->state = _PR_RUNNABLE;\n+            _PR_RUNQ_LOCK(lockedCPU);\n+            _PR_ADD_RUNQ(thred, lockedCPU, pri);\n+            _PR_RUNQ_UNLOCK(lockedCPU);\n+          } else {\n+            /*\n+             * The thread was just interrupted and moved\n+             * from the pause queue to the run queue.\n+             */\n+            _PR_THREAD_UNLOCK(thred);\n+          }\n+        } else {\n+          _PR_THREAD_LOCK(thred);\n+          thred->state = _PR_RUNNABLE;\n+          _PR_THREAD_UNLOCK(thred);\n+          ReleaseSemaphore(thred->md.blocked_sema, 1, NULL);\n+        }\n+      }\n+    } else {\n+      PRThread* completed_io;\n+\n+      PR_ASSERT(mdOlp->ioModel == _MD_BlockingIO);\n+      completed_io = _PR_THREAD_MD_TO_PTR(mdOlp->data.mdThread);\n+      completed_io->md.blocked_io_status = rv;\n+      if (rv == 0) {\n+        completed_io->md.blocked_io_error = GetLastError();\n+      }\n+      completed_io->md.blocked_io_bytes = bytes;\n+\n+      if (!_PR_IS_NATIVE_THREAD(completed_io)) {\n+        int pri = completed_io->priority;\n+        _PRCPU* lockedCPU = _PR_MD_CURRENT_CPU();\n+\n+        /* The KEY_CVAR notification only occurs when a native thread\n+         * is notifying a user thread.  For user-user notifications\n+         * the wakeup occurs by having the notifier place the thread\n+         * on the runq directly; for native-native notifications the\n+         * wakeup occurs by calling ReleaseSemaphore.\n+         */\n+        if (key == KEY_CVAR) {\n+          PR_ASSERT(completed_io->io_pending == PR_FALSE);\n+          PR_ASSERT(completed_io->io_suspended == PR_FALSE);\n+          PR_ASSERT(completed_io->md.thr_bound_cpu == NULL);\n+\n+          /* Thread has already been deleted from sleepQ */\n+\n+          /* Switch CPU and add to runQ */\n+          completed_io->cpu = lockedCPU;\n+          completed_io->state = _PR_RUNNABLE;\n+          _PR_RUNQ_LOCK(lockedCPU);\n+          _PR_ADD_RUNQ(completed_io, lockedCPU, pri);\n+          _PR_RUNQ_UNLOCK(lockedCPU);\n+        } else {\n+          PR_ASSERT(key == KEY_IO);\n+          PR_ASSERT(completed_io->io_pending == PR_TRUE);\n+\n+          _PR_THREAD_LOCK(completed_io);\n+\n+          completed_io->io_pending = PR_FALSE;\n+\n+          /* If io_suspended is true, then this IO has already resumed.\n+           * We don't need to do anything; because the thread is\n+           * already running.\n+           */\n+          if (completed_io->io_suspended == PR_FALSE) {\n+            if (completed_io->flags & (_PR_ON_SLEEPQ | _PR_ON_PAUSEQ)) {\n+              _PR_SLEEPQ_LOCK(completed_io->cpu);\n+              _PR_DEL_SLEEPQ(completed_io, PR_TRUE);\n+              _PR_SLEEPQ_UNLOCK(completed_io->cpu);\n+\n+              _PR_THREAD_UNLOCK(completed_io);\n+\n+              /*\n+               * If an I/O operation is suspended, the thread\n+               * must be running on the same cpu on which the\n+               * I/O operation was issued.\n+               */\n+              PR_ASSERT(!completed_io->md.thr_bound_cpu ||\n+                        (completed_io->cpu == completed_io->md.thr_bound_cpu));\n+\n+              if (!completed_io->md.thr_bound_cpu) {\n+                completed_io->cpu = lockedCPU;\n+              }\n+              completed_io->state = _PR_RUNNABLE;\n+              _PR_RUNQ_LOCK(completed_io->cpu);\n+              _PR_ADD_RUNQ(completed_io, completed_io->cpu, pri);\n+              _PR_RUNQ_UNLOCK(completed_io->cpu);\n             } else {\n-                /* For native threads, they are only notified through this loop\n-                 * when completing IO.  So, don't worry about this being a CVAR\n-                 * notification, because that is not possible.\n-                 */\n-                _PR_THREAD_LOCK(completed_io);\n-                completed_io->io_pending = PR_FALSE;\n-                if (completed_io->io_suspended == PR_FALSE) {\n-                    completed_io->state = _PR_RUNNABLE;\n-                    _PR_THREAD_UNLOCK(completed_io);\n-                    rv = ReleaseSemaphore(completed_io->md.blocked_sema, 1, NULL);\n-                    PR_ASSERT(0 != rv);\n-                } else {\n-                    _PR_THREAD_UNLOCK(completed_io);\n-                }\n+              _PR_THREAD_UNLOCK(completed_io);\n             }\n+          } else {\n+            _PR_THREAD_UNLOCK(completed_io);\n+          }\n         }\n-\n-        awoken++;\n-        timeout = 0; /* Don't block on subsequent trips through the loop */\n+      } else {\n+        /* For native threads, they are only notified through this loop\n+         * when completing IO.  So, don't worry about this being a CVAR\n+         * notification, because that is not possible.\n+         */\n+        _PR_THREAD_LOCK(completed_io);\n+        completed_io->io_pending = PR_FALSE;\n+        if (completed_io->io_suspended == PR_FALSE) {\n+          completed_io->state = _PR_RUNNABLE;\n+          _PR_THREAD_UNLOCK(completed_io);\n+          rv = ReleaseSemaphore(completed_io->md.blocked_sema, 1, NULL);\n+          PR_ASSERT(0 != rv);\n+        } else {\n+          _PR_THREAD_UNLOCK(completed_io);\n+        }\n+      }\n     }\n \n-    /* never reached */\n-    return 0;\n+    awoken++;\n+    timeout = 0; /* Don't block on subsequent trips through the loop */\n+  }\n+\n+  /* never reached */\n+  return 0;\n+}\n+\n+static PRStatus _native_thread_md_wait(PRThread* thread, PRIntervalTime ticks) {\n+  DWORD rv;\n+  PRUint32 msecs = (ticks == PR_INTERVAL_NO_TIMEOUT)\n+                       ? INFINITE\n+                       : PR_IntervalToMilliseconds(ticks);\n+\n+  /*\n+   * thread waiting for a cvar or a joining thread\n+   */\n+  rv = WaitForSingleObject(thread->md.blocked_sema, msecs);\n+  switch (rv) {\n+    case WAIT_OBJECT_0:\n+      return PR_SUCCESS;\n+      break;\n+    case WAIT_TIMEOUT:\n+      _PR_THREAD_LOCK(thread);\n+      PR_ASSERT(thread->state != _PR_IO_WAIT);\n+      if (thread->wait.cvar != NULL) {\n+        PR_ASSERT(thread->state == _PR_COND_WAIT);\n+        thread->wait.cvar = NULL;\n+        thread->state = _PR_RUNNING;\n+        _PR_THREAD_UNLOCK(thread);\n+      } else {\n+        /* The CVAR was notified just as the timeout\n+         * occurred.  This left the semaphore in the\n+         * signaled state.  Call WaitForSingleObject()\n+         * to clear the semaphore.\n+         */\n+        _PR_THREAD_UNLOCK(thread);\n+        rv = WaitForSingleObject(thread->md.blocked_sema, INFINITE);\n+        PR_ASSERT(rv == WAIT_OBJECT_0);\n+      }\n+      return PR_SUCCESS;\n+      break;\n+    default:\n+      return PR_FAILURE;\n+      break;\n+  }\n+\n+  return PR_SUCCESS;\n }\n \n-static PRStatus\n-_native_thread_md_wait(PRThread* thread, PRIntervalTime ticks)\n-{\n-    DWORD rv;\n+PRStatus _PR_MD_WAIT(PRThread* thread, PRIntervalTime ticks) {\n+  DWORD rv;\n+\n+  if (_native_threads_only) {\n+    return (_native_thread_md_wait(thread, ticks));\n+  }\n+  if (thread->flags & _PR_GLOBAL_SCOPE) {\n     PRUint32 msecs = (ticks == PR_INTERVAL_NO_TIMEOUT)\n                          ? INFINITE\n                          : PR_IntervalToMilliseconds(ticks);\n-\n-    /*\n-     * thread waiting for a cvar or a joining thread\n-     */\n     rv = WaitForSingleObject(thread->md.blocked_sema, msecs);\n     switch (rv) {\n-        case WAIT_OBJECT_0:\n-            return PR_SUCCESS;\n-            break;\n-        case WAIT_TIMEOUT:\n-            _PR_THREAD_LOCK(thread);\n-            PR_ASSERT(thread->state != _PR_IO_WAIT);\n-            if (thread->wait.cvar != NULL) {\n-                PR_ASSERT(thread->state == _PR_COND_WAIT);\n-                thread->wait.cvar = NULL;\n-                thread->state = _PR_RUNNING;\n-                _PR_THREAD_UNLOCK(thread);\n-            } else {\n-                /* The CVAR was notified just as the timeout\n-                 * occurred.  This left the semaphore in the\n-                 * signaled state.  Call WaitForSingleObject()\n-                 * to clear the semaphore.\n-                 */\n-                _PR_THREAD_UNLOCK(thread);\n-                rv = WaitForSingleObject(thread->md.blocked_sema, INFINITE);\n-                PR_ASSERT(rv == WAIT_OBJECT_0);\n-            }\n-            return PR_SUCCESS;\n-            break;\n-        default:\n-            return PR_FAILURE;\n-            break;\n+      case WAIT_OBJECT_0:\n+        return PR_SUCCESS;\n+        break;\n+      case WAIT_TIMEOUT:\n+        _PR_THREAD_LOCK(thread);\n+        if (thread->state == _PR_IO_WAIT) {\n+          if (thread->io_pending == PR_TRUE) {\n+            thread->state = _PR_RUNNING;\n+            thread->io_suspended = PR_TRUE;\n+            _PR_THREAD_UNLOCK(thread);\n+          } else {\n+            /* The IO completed just at the same time the timeout\n+             * occurred.  This left the semaphore in the signaled\n+             * state.  Call WaitForSingleObject() to clear the\n+             * semaphore.\n+             */\n+            _PR_THREAD_UNLOCK(thread);\n+            rv = WaitForSingleObject(thread->md.blocked_sema, INFINITE);\n+            PR_ASSERT(rv == WAIT_OBJECT_0);\n+          }\n+        } else {\n+          if (thread->wait.cvar != NULL) {\n+            PR_ASSERT(thread->state == _PR_COND_WAIT);\n+            thread->wait.cvar = NULL;\n+            thread->state = _PR_RUNNING;\n+            _PR_THREAD_UNLOCK(thread);\n+          } else {\n+            /* The CVAR was notified just as the timeout\n+             * occurred.  This left the semaphore in the\n+             * signaled state.  Call WaitForSingleObject()\n+             * to clear the semaphore.\n+             */\n+            _PR_THREAD_UNLOCK(thread);\n+            rv = WaitForSingleObject(thread->md.blocked_sema, INFINITE);\n+            PR_ASSERT(rv == WAIT_OBJECT_0);\n+          }\n+        }\n+        return PR_SUCCESS;\n+        break;\n+      default:\n+        return PR_FAILURE;\n+        break;\n     }\n+  } else {\n+    PRInt32 is;\n \n-    return PR_SUCCESS;\n+    _PR_INTSOFF(is);\n+    _PR_MD_SWITCH_CONTEXT(thread);\n+  }\n+\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_PR_MD_WAIT(PRThread* thread, PRIntervalTime ticks)\n-{\n-    DWORD rv;\n+static void _native_thread_io_nowait(PRThread* thread, int rv, int bytes) {\n+  int rc;\n+\n+  PR_ASSERT(rv != 0);\n+  _PR_THREAD_LOCK(thread);\n+  if (thread->state == _PR_IO_WAIT) {\n+    PR_ASSERT(thread->io_suspended == PR_FALSE);\n+    PR_ASSERT(thread->io_pending == PR_TRUE);\n+    thread->state = _PR_RUNNING;\n+    thread->io_pending = PR_FALSE;\n+    _PR_THREAD_UNLOCK(thread);\n+  } else {\n+    /* The IO completed just at the same time the\n+     * thread was interrupted. This left the semaphore\n+     * in the signaled state. Call WaitForSingleObject()\n+     * to clear the semaphore.\n+     */\n+    PR_ASSERT(thread->io_suspended == PR_TRUE);\n+    PR_ASSERT(thread->io_pending == PR_TRUE);\n+    thread->io_pending = PR_FALSE;\n+    _PR_THREAD_UNLOCK(thread);\n+    rc = WaitForSingleObject(thread->md.blocked_sema, INFINITE);\n+    PR_ASSERT(rc == WAIT_OBJECT_0);\n+  }\n+\n+  thread->md.blocked_io_status = rv;\n+  thread->md.blocked_io_bytes = bytes;\n+  rc = ResetEvent(thread->md.thr_event);\n+  PR_ASSERT(rc != 0);\n+  return;\n+}\n \n-    if (_native_threads_only) {\n-        return (_native_thread_md_wait(thread, ticks));\n-    }\n-    if (thread->flags & _PR_GLOBAL_SCOPE) {\n-        PRUint32 msecs = (ticks == PR_INTERVAL_NO_TIMEOUT)\n-                             ? INFINITE\n-                             : PR_IntervalToMilliseconds(ticks);\n-        rv = WaitForSingleObject(thread->md.blocked_sema, msecs);\n-        switch (rv) {\n-            case WAIT_OBJECT_0:\n-                return PR_SUCCESS;\n-                break;\n-            case WAIT_TIMEOUT:\n-                _PR_THREAD_LOCK(thread);\n-                if (thread->state == _PR_IO_WAIT) {\n-                    if (thread->io_pending == PR_TRUE) {\n-                        thread->state = _PR_RUNNING;\n-                        thread->io_suspended = PR_TRUE;\n-                        _PR_THREAD_UNLOCK(thread);\n-                    } else {\n-                        /* The IO completed just at the same time the timeout\n-                         * occurred.  This left the semaphore in the signaled\n-                         * state.  Call WaitForSingleObject() to clear the\n-                         * semaphore.\n-                         */\n-                        _PR_THREAD_UNLOCK(thread);\n-                        rv = WaitForSingleObject(thread->md.blocked_sema, INFINITE);\n-                        PR_ASSERT(rv == WAIT_OBJECT_0);\n-                    }\n-                } else {\n-                    if (thread->wait.cvar != NULL) {\n-                        PR_ASSERT(thread->state == _PR_COND_WAIT);\n-                        thread->wait.cvar = NULL;\n-                        thread->state = _PR_RUNNING;\n-                        _PR_THREAD_UNLOCK(thread);\n-                    } else {\n-                        /* The CVAR was notified just as the timeout\n-                         * occurred.  This left the semaphore in the\n-                         * signaled state.  Call WaitForSingleObject()\n-                         * to clear the semaphore.\n-                         */\n-                        _PR_THREAD_UNLOCK(thread);\n-                        rv = WaitForSingleObject(thread->md.blocked_sema, INFINITE);\n-                        PR_ASSERT(rv == WAIT_OBJECT_0);\n-                    }\n-                }\n-                return PR_SUCCESS;\n-                break;\n-            default:\n-                return PR_FAILURE;\n-                break;\n-        }\n-    } else {\n-        PRInt32 is;\n+static PRStatus _native_thread_io_wait(PRThread* thread, PRIntervalTime ticks) {\n+  DWORD rv, bytes;\n+#define _NATIVE_IO_WAIT_HANDLES 2\n+#define _NATIVE_WAKEUP_EVENT_INDEX 0\n+#define _NATIVE_IO_EVENT_INDEX 1\n \n-        _PR_INTSOFF(is);\n-        _PR_MD_SWITCH_CONTEXT(thread);\n-    }\n+  HANDLE wait_handles[_NATIVE_IO_WAIT_HANDLES];\n \n-    return PR_SUCCESS;\n-}\n+  PRUint32 msecs = (ticks == PR_INTERVAL_NO_TIMEOUT)\n+                       ? INFINITE\n+                       : PR_IntervalToMilliseconds(ticks);\n \n-static void\n-_native_thread_io_nowait(PRThread* thread, int rv, int bytes)\n-{\n-    int rc;\n+  PR_ASSERT(thread->flags & _PR_GLOBAL_SCOPE);\n \n-    PR_ASSERT(rv != 0);\n-    _PR_THREAD_LOCK(thread);\n-    if (thread->state == _PR_IO_WAIT) {\n+  wait_handles[0] = thread->md.blocked_sema;\n+  wait_handles[1] = thread->md.thr_event;\n+  rv = WaitForMultipleObjects(_NATIVE_IO_WAIT_HANDLES, wait_handles, FALSE,\n+                              msecs);\n+\n+  switch (rv) {\n+    case WAIT_OBJECT_0 + _NATIVE_IO_EVENT_INDEX:\n+      /*\n+       * I/O op completed\n+       */\n+      _PR_THREAD_LOCK(thread);\n+      if (thread->state == _PR_IO_WAIT) {\n         PR_ASSERT(thread->io_suspended == PR_FALSE);\n         PR_ASSERT(thread->io_pending == PR_TRUE);\n         thread->state = _PR_RUNNING;\n         thread->io_pending = PR_FALSE;\n         _PR_THREAD_UNLOCK(thread);\n-    } else {\n+      } else {\n         /* The IO completed just at the same time the\n-         * thread was interrupted. This left the semaphore\n-         * in the signaled state. Call WaitForSingleObject()\n+         * thread was interrupted. This led to us being\n+         * notified twice. Call WaitForSingleObject()\n          * to clear the semaphore.\n          */\n         PR_ASSERT(thread->io_suspended == PR_TRUE);\n         PR_ASSERT(thread->io_pending == PR_TRUE);\n         thread->io_pending = PR_FALSE;\n         _PR_THREAD_UNLOCK(thread);\n-        rc = WaitForSingleObject(thread->md.blocked_sema, INFINITE);\n-        PR_ASSERT(rc == WAIT_OBJECT_0);\n-    }\n-\n-    thread->md.blocked_io_status = rv;\n-    thread->md.blocked_io_bytes = bytes;\n-    rc = ResetEvent(thread->md.thr_event);\n-    PR_ASSERT(rc != 0);\n-    return;\n-}\n-\n-static PRStatus\n-_native_thread_io_wait(PRThread* thread, PRIntervalTime ticks)\n-{\n-    DWORD rv, bytes;\n-#define _NATIVE_IO_WAIT_HANDLES 2\n-#define _NATIVE_WAKEUP_EVENT_INDEX 0\n-#define _NATIVE_IO_EVENT_INDEX 1\n-\n-    HANDLE wait_handles[_NATIVE_IO_WAIT_HANDLES];\n-\n-    PRUint32 msecs = (ticks == PR_INTERVAL_NO_TIMEOUT)\n-                         ? INFINITE\n-                         : PR_IntervalToMilliseconds(ticks);\n-\n-    PR_ASSERT(thread->flags & _PR_GLOBAL_SCOPE);\n-\n-    wait_handles[0] = thread->md.blocked_sema;\n-    wait_handles[1] = thread->md.thr_event;\n-    rv = WaitForMultipleObjects(_NATIVE_IO_WAIT_HANDLES, wait_handles, FALSE,\n-                                msecs);\n-\n-    switch (rv) {\n-        case WAIT_OBJECT_0 + _NATIVE_IO_EVENT_INDEX:\n-            /*\n-             * I/O op completed\n-             */\n-            _PR_THREAD_LOCK(thread);\n-            if (thread->state == _PR_IO_WAIT) {\n-                PR_ASSERT(thread->io_suspended == PR_FALSE);\n-                PR_ASSERT(thread->io_pending == PR_TRUE);\n-                thread->state = _PR_RUNNING;\n-                thread->io_pending = PR_FALSE;\n-                _PR_THREAD_UNLOCK(thread);\n-            } else {\n-                /* The IO completed just at the same time the\n-                 * thread was interrupted. This led to us being\n-                 * notified twice. Call WaitForSingleObject()\n-                 * to clear the semaphore.\n-                 */\n-                PR_ASSERT(thread->io_suspended == PR_TRUE);\n-                PR_ASSERT(thread->io_pending == PR_TRUE);\n-                thread->io_pending = PR_FALSE;\n-                _PR_THREAD_UNLOCK(thread);\n-                rv = WaitForSingleObject(thread->md.blocked_sema, INFINITE);\n-                PR_ASSERT(rv == WAIT_OBJECT_0);\n-            }\n-\n-            rv =\n-                GetOverlappedResult((HANDLE)thread->io_fd,\n-                                    &thread->md.overlapped.overlapped, &bytes, FALSE);\n-\n-            thread->md.blocked_io_status = rv;\n-            if (rv != 0) {\n-                thread->md.blocked_io_bytes = bytes;\n-            } else {\n-                thread->md.blocked_io_error = GetLastError();\n-                PR_ASSERT(ERROR_IO_PENDING != thread->md.blocked_io_error);\n-            }\n-            rv = ResetEvent(thread->md.thr_event);\n-            PR_ASSERT(rv != 0);\n-            break;\n-        case WAIT_OBJECT_0 + _NATIVE_WAKEUP_EVENT_INDEX:\n-            /*\n-             * I/O interrupted;\n-             */\n+        rv = WaitForSingleObject(thread->md.blocked_sema, INFINITE);\n+        PR_ASSERT(rv == WAIT_OBJECT_0);\n+      }\n+\n+      rv =\n+          GetOverlappedResult((HANDLE)thread->io_fd,\n+                              &thread->md.overlapped.overlapped, &bytes, FALSE);\n+\n+      thread->md.blocked_io_status = rv;\n+      if (rv != 0) {\n+        thread->md.blocked_io_bytes = bytes;\n+      } else {\n+        thread->md.blocked_io_error = GetLastError();\n+        PR_ASSERT(ERROR_IO_PENDING != thread->md.blocked_io_error);\n+      }\n+      rv = ResetEvent(thread->md.thr_event);\n+      PR_ASSERT(rv != 0);\n+      break;\n+    case WAIT_OBJECT_0 + _NATIVE_WAKEUP_EVENT_INDEX:\n+      /*\n+       * I/O interrupted;\n+       */\n #ifdef DEBUG\n-            _PR_THREAD_LOCK(thread);\n-            PR_ASSERT(thread->io_suspended == PR_TRUE);\n-            _PR_THREAD_UNLOCK(thread);\n+      _PR_THREAD_LOCK(thread);\n+      PR_ASSERT(thread->io_suspended == PR_TRUE);\n+      _PR_THREAD_UNLOCK(thread);\n #endif\n-            break;\n-        case WAIT_TIMEOUT:\n-            _PR_THREAD_LOCK(thread);\n-            if (thread->state == _PR_IO_WAIT) {\n-                thread->state = _PR_RUNNING;\n-                thread->io_suspended = PR_TRUE;\n-                _PR_THREAD_UNLOCK(thread);\n-            } else {\n-                /*\n-                 * The thread was interrupted just as the timeout\n-                 * occurred. This left the semaphore in the signaled\n-                 * state. Call WaitForSingleObject() to clear the\n-                 * semaphore.\n-                 */\n-                PR_ASSERT(thread->io_suspended == PR_TRUE);\n-                _PR_THREAD_UNLOCK(thread);\n-                rv = WaitForSingleObject(thread->md.blocked_sema, INFINITE);\n-                PR_ASSERT(rv == WAIT_OBJECT_0);\n-            }\n-            break;\n-        default:\n-            return PR_FAILURE;\n-            break;\n-    }\n-\n-    return PR_SUCCESS;\n+      break;\n+    case WAIT_TIMEOUT:\n+      _PR_THREAD_LOCK(thread);\n+      if (thread->state == _PR_IO_WAIT) {\n+        thread->state = _PR_RUNNING;\n+        thread->io_suspended = PR_TRUE;\n+        _PR_THREAD_UNLOCK(thread);\n+      } else {\n+        /*\n+         * The thread was interrupted just as the timeout\n+         * occurred. This left the semaphore in the signaled\n+         * state. Call WaitForSingleObject() to clear the\n+         * semaphore.\n+         */\n+        PR_ASSERT(thread->io_suspended == PR_TRUE);\n+        _PR_THREAD_UNLOCK(thread);\n+        rv = WaitForSingleObject(thread->md.blocked_sema, INFINITE);\n+        PR_ASSERT(rv == WAIT_OBJECT_0);\n+      }\n+      break;\n+    default:\n+      return PR_FAILURE;\n+      break;\n+  }\n+\n+  return PR_SUCCESS;\n }\n \n-static PRStatus\n-_NT_IO_WAIT(PRThread* thread, PRIntervalTime timeout)\n-{\n-    PRBool fWait = PR_TRUE;\n+static PRStatus _NT_IO_WAIT(PRThread* thread, PRIntervalTime timeout) {\n+  PRBool fWait = PR_TRUE;\n \n-    if (_native_threads_only) {\n-        return (_native_thread_io_wait(thread, timeout));\n-    }\n-    if (!_PR_IS_NATIVE_THREAD(thread)) {\n-        _PR_THREAD_LOCK(thread);\n+  if (_native_threads_only) {\n+    return (_native_thread_io_wait(thread, timeout));\n+  }\n+  if (!_PR_IS_NATIVE_THREAD(thread)) {\n+    _PR_THREAD_LOCK(thread);\n \n-        /* The IO may have already completed; if so, don't add to sleepQ,\n-         * since we are already on the runQ!\n-         */\n-        if (thread->io_pending == PR_TRUE) {\n-            _PR_SLEEPQ_LOCK(thread->cpu);\n-            _PR_ADD_SLEEPQ(thread, timeout);\n-            _PR_SLEEPQ_UNLOCK(thread->cpu);\n-        } else {\n-            fWait = PR_FALSE;\n-        }\n-        _PR_THREAD_UNLOCK(thread);\n-    }\n-    if (fWait) {\n-        return _PR_MD_WAIT(thread, timeout);\n+    /* The IO may have already completed; if so, don't add to sleepQ,\n+     * since we are already on the runQ!\n+     */\n+    if (thread->io_pending == PR_TRUE) {\n+      _PR_SLEEPQ_LOCK(thread->cpu);\n+      _PR_ADD_SLEEPQ(thread, timeout);\n+      _PR_SLEEPQ_UNLOCK(thread->cpu);\n     } else {\n-        return PR_SUCCESS;\n+      fWait = PR_FALSE;\n     }\n+    _PR_THREAD_UNLOCK(thread);\n+  }\n+  if (fWait) {\n+    return _PR_MD_WAIT(thread, timeout);\n+  } else {\n+    return PR_SUCCESS;\n+  }\n }\n \n /*\n@@ -728,205 +716,197 @@ _NT_IO_WAIT(PRThread* thread, PRIntervalTime timeout)\n  * NOTE: The thread lock should held when this function is called.\n  * On return, the thread lock is released.\n  */\n-void\n-_PR_Unblock_IO_Wait(PRThread* thr)\n-{\n-    PRStatus rv;\n-    _PRCPU* cpu = thr->cpu;\n+void _PR_Unblock_IO_Wait(PRThread* thr) {\n+  PRStatus rv;\n+  _PRCPU* cpu = thr->cpu;\n+\n+  PR_ASSERT(thr->state == _PR_IO_WAIT);\n+  /*\n+   * A thread for which an I/O timed out or was interrupted cannot be\n+   * in an IO_WAIT state except as a result of calling PR_Close or\n+   * PR_NT_CancelIo for the FD. For these two cases, _PR_IO_WAIT state\n+   * is not interruptible\n+   */\n+  if (thr->md.interrupt_disabled == PR_TRUE) {\n+    _PR_THREAD_UNLOCK(thr);\n+    return;\n+  }\n+  thr->io_suspended = PR_TRUE;\n+  thr->state = _PR_RUNNABLE;\n \n-    PR_ASSERT(thr->state == _PR_IO_WAIT);\n+  if (!_PR_IS_NATIVE_THREAD(thr)) {\n+    PRThread* me = _PR_MD_CURRENT_THREAD();\n+    PR_ASSERT(thr->flags & (_PR_ON_SLEEPQ | _PR_ON_PAUSEQ));\n+    _PR_SLEEPQ_LOCK(cpu);\n+    _PR_DEL_SLEEPQ(thr, PR_TRUE);\n+    _PR_SLEEPQ_UNLOCK(cpu);\n     /*\n-     * A thread for which an I/O timed out or was interrupted cannot be\n-     * in an IO_WAIT state except as a result of calling PR_Close or\n-     * PR_NT_CancelIo for the FD. For these two cases, _PR_IO_WAIT state\n-     * is not interruptible\n+     * this thread will continue to run on the same cpu until the\n+     * I/O is aborted by closing the FD or calling CancelIO\n      */\n-    if (thr->md.interrupt_disabled == PR_TRUE) {\n-        _PR_THREAD_UNLOCK(thr);\n-        return;\n-    }\n-    thr->io_suspended = PR_TRUE;\n-    thr->state = _PR_RUNNABLE;\n-\n-    if (!_PR_IS_NATIVE_THREAD(thr)) {\n-        PRThread* me = _PR_MD_CURRENT_THREAD();\n-        PR_ASSERT(thr->flags & (_PR_ON_SLEEPQ | _PR_ON_PAUSEQ));\n-        _PR_SLEEPQ_LOCK(cpu);\n-        _PR_DEL_SLEEPQ(thr, PR_TRUE);\n-        _PR_SLEEPQ_UNLOCK(cpu);\n-        /*\n-         * this thread will continue to run on the same cpu until the\n-         * I/O is aborted by closing the FD or calling CancelIO\n-         */\n-        thr->md.thr_bound_cpu = cpu;\n-\n-        PR_ASSERT(!(thr->flags & _PR_IDLE_THREAD));\n-        _PR_AddThreadToRunQ(me, thr);\n-    }\n-    _PR_THREAD_UNLOCK(thr);\n-    rv = _PR_MD_WAKEUP_WAITER(thr);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+    thr->md.thr_bound_cpu = cpu;\n+\n+    PR_ASSERT(!(thr->flags & _PR_IDLE_THREAD));\n+    _PR_AddThreadToRunQ(me, thr);\n+  }\n+  _PR_THREAD_UNLOCK(thr);\n+  rv = _PR_MD_WAKEUP_WAITER(thr);\n+  PR_ASSERT(PR_SUCCESS == rv);\n }\n \n /* Resume an outstanding IO; requires that after the switch, we disable */\n-static PRStatus\n-_NT_ResumeIO(PRThread* thread, PRIntervalTime ticks)\n-{\n-    PRBool fWait = PR_TRUE;\n+static PRStatus _NT_ResumeIO(PRThread* thread, PRIntervalTime ticks) {\n+  PRBool fWait = PR_TRUE;\n \n-    if (!_PR_IS_NATIVE_THREAD(thread)) {\n-        if (_pr_use_static_tls) {\n-            _pr_io_restarted_io = thread;\n-        } else {\n-            TlsSetValue(_pr_io_restartedIOIndex, thread);\n-        }\n+  if (!_PR_IS_NATIVE_THREAD(thread)) {\n+    if (_pr_use_static_tls) {\n+      _pr_io_restarted_io = thread;\n     } else {\n-        _PR_THREAD_LOCK(thread);\n-        if (!thread->io_pending) {\n-            fWait = PR_FALSE;\n-        }\n-        thread->io_suspended = PR_FALSE;\n-\n-        _PR_THREAD_UNLOCK(thread);\n+      TlsSetValue(_pr_io_restartedIOIndex, thread);\n     }\n-    /* We don't put ourselves back on the sleepQ yet; until we\n-     * set the suspended bit to false, we can't do that.  Just save\n-     * the sleep time here, and then continue.  The restarted_io handler\n-     * will add us to the sleepQ if needed.\n-     */\n-    thread->sleep = ticks;\n+  } else {\n+    _PR_THREAD_LOCK(thread);\n+    if (!thread->io_pending) {\n+      fWait = PR_FALSE;\n+    }\n+    thread->io_suspended = PR_FALSE;\n \n-    if (fWait) {\n-        if (!_PR_IS_NATIVE_THREAD(thread)) {\n-            return _PR_MD_WAIT(thread, ticks);\n-        } else {\n-            return _NT_IO_WAIT(thread, ticks);\n-        }\n+    _PR_THREAD_UNLOCK(thread);\n+  }\n+  /* We don't put ourselves back on the sleepQ yet; until we\n+   * set the suspended bit to false, we can't do that.  Just save\n+   * the sleep time here, and then continue.  The restarted_io handler\n+   * will add us to the sleepQ if needed.\n+   */\n+  thread->sleep = ticks;\n+\n+  if (fWait) {\n+    if (!_PR_IS_NATIVE_THREAD(thread)) {\n+      return _PR_MD_WAIT(thread, ticks);\n+    } else {\n+      return _NT_IO_WAIT(thread, ticks);\n     }\n-    return PR_SUCCESS;\n+  }\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_PR_MD_WAKEUP_WAITER(PRThread* thread)\n-{\n-    if (thread == NULL) {\n-        /* If thread is NULL, we aren't waking a thread, we're just poking\n-         * idle thread\n-         */\n-        if (PostQueuedCompletionStatus(_pr_completion_port, 0, KEY_CVAR, NULL) ==\n-            FALSE) {\n-            return PR_FAILURE;\n-        }\n-        return PR_SUCCESS;\n+PRStatus _PR_MD_WAKEUP_WAITER(PRThread* thread) {\n+  if (thread == NULL) {\n+    /* If thread is NULL, we aren't waking a thread, we're just poking\n+     * idle thread\n+     */\n+    if (PostQueuedCompletionStatus(_pr_completion_port, 0, KEY_CVAR, NULL) ==\n+        FALSE) {\n+      return PR_FAILURE;\n     }\n+    return PR_SUCCESS;\n+  }\n \n-    if (_PR_IS_NATIVE_THREAD(thread)) {\n-        if (ReleaseSemaphore(thread->md.blocked_sema, 1, NULL) == FALSE) {\n-            return PR_FAILURE;\n-        } else {\n-            return PR_SUCCESS;\n-        }\n+  if (_PR_IS_NATIVE_THREAD(thread)) {\n+    if (ReleaseSemaphore(thread->md.blocked_sema, 1, NULL) == FALSE) {\n+      return PR_FAILURE;\n     } else {\n-        PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-        /* When a Native thread has to awaken a user thread, it has to poke\n-         * the completion port because all user threads might be idle, and\n-         * thus the CPUs are just waiting for a completion.\n-         *\n-         * XXXMB - can we know when we are truely idle (and not checking\n-         *         the runq)?\n-         */\n-        if ((_PR_IS_NATIVE_THREAD(me) || (thread->cpu != me->cpu)) &&\n-            (!thread->md.thr_bound_cpu)) {\n-            /* The thread should not be in any queue */\n-            PR_ASSERT(thread->queueCount == 0);\n-            if (PostQueuedCompletionStatus(_pr_completion_port, 0, KEY_CVAR,\n-                                           &(thread->md.overlapped.overlapped)) ==\n-                FALSE) {\n-                return PR_FAILURE;\n-            }\n-        }\n-        return PR_SUCCESS;\n+      return PR_SUCCESS;\n+    }\n+  } else {\n+    PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+    /* When a Native thread has to awaken a user thread, it has to poke\n+     * the completion port because all user threads might be idle, and\n+     * thus the CPUs are just waiting for a completion.\n+     *\n+     * XXXMB - can we know when we are truely idle (and not checking\n+     *         the runq)?\n+     */\n+    if ((_PR_IS_NATIVE_THREAD(me) || (thread->cpu != me->cpu)) &&\n+        (!thread->md.thr_bound_cpu)) {\n+      /* The thread should not be in any queue */\n+      PR_ASSERT(thread->queueCount == 0);\n+      if (PostQueuedCompletionStatus(_pr_completion_port, 0, KEY_CVAR,\n+                                     &(thread->md.overlapped.overlapped)) ==\n+          FALSE) {\n+        return PR_FAILURE;\n+      }\n     }\n+    return PR_SUCCESS;\n+  }\n }\n \n-void\n-_PR_MD_INIT_IO()\n-{\n-    WORD WSAVersion = 0x0101;\n-    WSADATA WSAData;\n-    int err;\n-    OSVERSIONINFO OSversion;\n+void _PR_MD_INIT_IO() {\n+  WORD WSAVersion = 0x0101;\n+  WSADATA WSAData;\n+  int err;\n+  OSVERSIONINFO OSversion;\n \n-    err = WSAStartup(WSAVersion, &WSAData);\n-    PR_ASSERT(0 == err);\n+  err = WSAStartup(WSAVersion, &WSAData);\n+  PR_ASSERT(0 == err);\n \n-    _pr_completion_port =\n-        CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);\n+  _pr_completion_port =\n+      CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);\n \n-    _MD_NEW_LOCK(&_pr_recycle_lock);\n-    _MD_NEW_LOCK(&_pr_ioq_lock);\n+  _MD_NEW_LOCK(&_pr_recycle_lock);\n+  _MD_NEW_LOCK(&_pr_ioq_lock);\n \n-    OSversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);\n-    if (GetVersionEx(&OSversion)) {\n-        _nt_version_gets_lockfile_completion = PR_FALSE;\n-        if (OSversion.dwMajorVersion >= 4) {\n-            _nt_version_gets_lockfile_completion = PR_TRUE;\n-        }\n-    } else {\n-        PR_ASSERT(0);\n+  OSversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);\n+  if (GetVersionEx(&OSversion)) {\n+    _nt_version_gets_lockfile_completion = PR_FALSE;\n+    if (OSversion.dwMajorVersion >= 4) {\n+      _nt_version_gets_lockfile_completion = PR_TRUE;\n     }\n+  } else {\n+    PR_ASSERT(0);\n+  }\n \n #ifdef _NEED_351_FILE_LOCKING_HACK\n-    IsFileLocalInit();\n+  IsFileLocalInit();\n #endif /* _NEED_351_FILE_LOCKING_HACK */\n \n-    /*\n-     * UDP support: start up the continuation thread\n-     */\n+  /*\n+   * UDP support: start up the continuation thread\n+   */\n \n-    pt_tq.op_count = 0;\n-    pt_tq.head = pt_tq.tail = NULL;\n-    pt_tq.ml = PR_NewLock();\n-    PR_ASSERT(NULL != pt_tq.ml);\n-    pt_tq.new_op = PR_NewCondVar(pt_tq.ml);\n-    PR_ASSERT(NULL != pt_tq.new_op);\n+  pt_tq.op_count = 0;\n+  pt_tq.head = pt_tq.tail = NULL;\n+  pt_tq.ml = PR_NewLock();\n+  PR_ASSERT(NULL != pt_tq.ml);\n+  pt_tq.new_op = PR_NewCondVar(pt_tq.ml);\n+  PR_ASSERT(NULL != pt_tq.new_op);\n #if defined(DEBUG)\n-    memset(&pt_debug, 0, sizeof(struct pt_debug_s));\n+  memset(&pt_debug, 0, sizeof(struct pt_debug_s));\n #endif\n \n-    pt_tq.thread = PR_CreateThread(PR_SYSTEM_THREAD, ContinuationThread, NULL,\n-                                   PR_PRIORITY_URGENT, PR_GLOBAL_THREAD,\n-                                   PR_JOINABLE_THREAD, 0);\n+  pt_tq.thread = PR_CreateThread(PR_SYSTEM_THREAD, ContinuationThread, NULL,\n+                                 PR_PRIORITY_URGENT, PR_GLOBAL_THREAD,\n+                                 PR_JOINABLE_THREAD, 0);\n \n-    PR_ASSERT(NULL != pt_tq.thread);\n+  PR_ASSERT(NULL != pt_tq.thread);\n \n #ifdef DEBUG\n-    /* Doublecheck _pr_filetime_offset's hard-coded value is correct. */\n-    {\n-        SYSTEMTIME systime;\n-        union {\n-            PRTime prt;\n-            FILETIME ft;\n-        } filetime;\n-        BOOL rv;\n-\n-        systime.wYear = 1970;\n-        systime.wMonth = 1;\n-        /* wDayOfWeek is ignored */\n-        systime.wDay = 1;\n-        systime.wHour = 0;\n-        systime.wMinute = 0;\n-        systime.wSecond = 0;\n-        systime.wMilliseconds = 0;\n-\n-        rv = SystemTimeToFileTime(&systime, &filetime.ft);\n-        PR_ASSERT(0 != rv);\n-        PR_ASSERT(filetime.prt == _pr_filetime_offset);\n-    }\n+  /* Doublecheck _pr_filetime_offset's hard-coded value is correct. */\n+  {\n+    SYSTEMTIME systime;\n+    union {\n+      PRTime prt;\n+      FILETIME ft;\n+    } filetime;\n+    BOOL rv;\n+\n+    systime.wYear = 1970;\n+    systime.wMonth = 1;\n+    /* wDayOfWeek is ignored */\n+    systime.wDay = 1;\n+    systime.wHour = 0;\n+    systime.wMinute = 0;\n+    systime.wSecond = 0;\n+    systime.wMilliseconds = 0;\n+\n+    rv = SystemTimeToFileTime(&systime, &filetime.ft);\n+    PR_ASSERT(0 != rv);\n+    PR_ASSERT(filetime.prt == _pr_filetime_offset);\n+  }\n #endif /* DEBUG */\n \n-    _PR_NT_InitSids();\n+  _PR_NT_InitSids();\n }\n \n /* --- SOCKET IO --------------------------------------------------------- */\n@@ -936,77 +916,71 @@ _PR_MD_INIT_IO()\n  * create one.  The socket will be passed to AcceptEx() as the\n  * second argument.\n  */\n-static SOCKET\n-_md_get_recycled_socket(int af)\n-{\n-    SOCKET rv;\n-\n-    _MD_LOCK(&_pr_recycle_lock);\n-    if (af == AF_INET && _pr_recycle_INET_tail) {\n-        _pr_recycle_INET_tail--;\n-        rv = _pr_recycle_INET_array[_pr_recycle_INET_tail];\n-        _MD_UNLOCK(&_pr_recycle_lock);\n-        return rv;\n-    }\n-    if (af == AF_INET6 && _pr_recycle_INET6_tail) {\n-        _pr_recycle_INET6_tail--;\n-        rv = _pr_recycle_INET6_array[_pr_recycle_INET6_tail];\n-        _MD_UNLOCK(&_pr_recycle_lock);\n-        return rv;\n-    }\n-    _MD_UNLOCK(&_pr_recycle_lock);\n+static SOCKET _md_get_recycled_socket(int af) {\n+  SOCKET rv;\n \n-    rv = _PR_MD_SOCKET(af, SOCK_STREAM, 0);\n-    if (rv != INVALID_SOCKET && _md_Associate((HANDLE)rv) == 0) {\n-        closesocket(rv);\n-        return INVALID_SOCKET;\n-    }\n+  _MD_LOCK(&_pr_recycle_lock);\n+  if (af == AF_INET && _pr_recycle_INET_tail) {\n+    _pr_recycle_INET_tail--;\n+    rv = _pr_recycle_INET_array[_pr_recycle_INET_tail];\n+    _MD_UNLOCK(&_pr_recycle_lock);\n+    return rv;\n+  }\n+  if (af == AF_INET6 && _pr_recycle_INET6_tail) {\n+    _pr_recycle_INET6_tail--;\n+    rv = _pr_recycle_INET6_array[_pr_recycle_INET6_tail];\n+    _MD_UNLOCK(&_pr_recycle_lock);\n     return rv;\n+  }\n+  _MD_UNLOCK(&_pr_recycle_lock);\n+\n+  rv = _PR_MD_SOCKET(af, SOCK_STREAM, 0);\n+  if (rv != INVALID_SOCKET && _md_Associate((HANDLE)rv) == 0) {\n+    closesocket(rv);\n+    return INVALID_SOCKET;\n+  }\n+  return rv;\n }\n \n /* _md_put_recycled_socket()\n  * Add a socket to the recycle bin.\n  */\n-static void\n-_md_put_recycled_socket(SOCKET newsock, int af)\n-{\n-    PR_ASSERT(_pr_recycle_INET_tail >= 0);\n-    PR_ASSERT(_pr_recycle_INET6_tail >= 0);\n-\n-    _MD_LOCK(&_pr_recycle_lock);\n-    if (af == AF_INET && _pr_recycle_INET_tail < RECYCLE_SIZE) {\n-        _pr_recycle_INET_array[_pr_recycle_INET_tail] = newsock;\n-        _pr_recycle_INET_tail++;\n-        _MD_UNLOCK(&_pr_recycle_lock);\n-    } else if (af == AF_INET6 && _pr_recycle_INET6_tail < RECYCLE_SIZE) {\n-        _pr_recycle_INET6_array[_pr_recycle_INET6_tail] = newsock;\n-        _pr_recycle_INET6_tail++;\n-        _MD_UNLOCK(&_pr_recycle_lock);\n-    } else {\n-        _MD_UNLOCK(&_pr_recycle_lock);\n-        closesocket(newsock);\n-    }\n+static void _md_put_recycled_socket(SOCKET newsock, int af) {\n+  PR_ASSERT(_pr_recycle_INET_tail >= 0);\n+  PR_ASSERT(_pr_recycle_INET6_tail >= 0);\n+\n+  _MD_LOCK(&_pr_recycle_lock);\n+  if (af == AF_INET && _pr_recycle_INET_tail < RECYCLE_SIZE) {\n+    _pr_recycle_INET_array[_pr_recycle_INET_tail] = newsock;\n+    _pr_recycle_INET_tail++;\n+    _MD_UNLOCK(&_pr_recycle_lock);\n+  } else if (af == AF_INET6 && _pr_recycle_INET6_tail < RECYCLE_SIZE) {\n+    _pr_recycle_INET6_array[_pr_recycle_INET6_tail] = newsock;\n+    _pr_recycle_INET6_tail++;\n+    _MD_UNLOCK(&_pr_recycle_lock);\n+  } else {\n+    _MD_UNLOCK(&_pr_recycle_lock);\n+    closesocket(newsock);\n+  }\n \n-    return;\n+  return;\n }\n \n /* _md_Associate()\n  * Associates a file with the completion port.\n  * Returns 0 on failure, 1 on success.\n  */\n-PRInt32\n-_md_Associate(HANDLE file)\n-{\n-    HANDLE port;\n+PRInt32 _md_Associate(HANDLE file) {\n+  HANDLE port;\n \n-    if (!_native_threads_only) {\n-        port = CreateIoCompletionPort((HANDLE)file, _pr_completion_port, KEY_IO, 0);\n+  if (!_native_threads_only) {\n+    port = CreateIoCompletionPort((HANDLE)file, _pr_completion_port, KEY_IO, 0);\n \n-        /* XXX should map error codes on failures */\n-        return (port == _pr_completion_port);\n-    } else {\n-        return 1;\n-    }\n+    /* XXX should map error codes on failures */\n+    return (port == _pr_completion_port);\n+  } else {\n+    return 1;\n+  }\n }\n \n /*\n@@ -1014,204 +988,192 @@ _md_Associate(HANDLE file)\n  * Make a socket nonblocking.\n  * Returns 0 on failure, 1 on success.\n  */\n-static PRInt32\n-_md_MakeNonblock(HANDLE file)\n-{\n-    int rv;\n-    u_long one = 1;\n+static PRInt32 _md_MakeNonblock(HANDLE file) {\n+  int rv;\n+  u_long one = 1;\n \n-    rv = ioctlsocket((SOCKET)file, FIONBIO, &one);\n-    /* XXX should map error codes on failures */\n-    return (rv == 0);\n+  rv = ioctlsocket((SOCKET)file, FIONBIO, &one);\n+  /* XXX should map error codes on failures */\n+  return (rv == 0);\n }\n \n static int missing_completions = 0;\n static int max_wait_loops = 0;\n \n-static PRInt32\n-_NT_IO_ABORT(PROsfd sock)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRBool fWait;\n-    PRInt32 rv;\n-    int loop_count;\n-\n-    /* This is a clumsy way to abort the IO, but it is all we can do.\n-     * It looks a bit racy, but we handle all the cases.\n-     * case 1:  IO completes before calling closesocket\n-     *     case 1a:  fWait is set to PR_FALSE\n-     *           This should e the most likely case.  We'll properly\n-     *           not wait call _NT_IO_WAIT, since the closesocket()\n-     *           won't be forcing a completion.\n-     *     case 1b: fWait is set to PR_TRUE\n-     *           This hopefully won't happen much.  When it does, this\n-     *           thread will timeout in _NT_IO_WAIT for CLOSE_INTERVAL\n-     *           before cleaning up.\n-     * case 2:  IO does not complete before calling closesocket\n-     *     case 2a: IO never completes\n-     *           This is the likely case.  We'll close it and wait\n-     *           for the completion forced by the close.  Return should\n-     *           be immediate.\n-     *     case 2b: IO completes just after calling closesocket\n-     *           Since the closesocket is issued, we'll either get a\n-     *           completion back for the real IO or for the close.  We\n-     *           don't really care.  It may not even be possible to get\n-     *           a real completion here.  In any event, we'll awaken\n-     *           from NT_IO_WAIT immediately.\n+static PRInt32 _NT_IO_ABORT(PROsfd sock) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRBool fWait;\n+  PRInt32 rv;\n+  int loop_count;\n+\n+  /* This is a clumsy way to abort the IO, but it is all we can do.\n+   * It looks a bit racy, but we handle all the cases.\n+   * case 1:  IO completes before calling closesocket\n+   *     case 1a:  fWait is set to PR_FALSE\n+   *           This should e the most likely case.  We'll properly\n+   *           not wait call _NT_IO_WAIT, since the closesocket()\n+   *           won't be forcing a completion.\n+   *     case 1b: fWait is set to PR_TRUE\n+   *           This hopefully won't happen much.  When it does, this\n+   *           thread will timeout in _NT_IO_WAIT for CLOSE_INTERVAL\n+   *           before cleaning up.\n+   * case 2:  IO does not complete before calling closesocket\n+   *     case 2a: IO never completes\n+   *           This is the likely case.  We'll close it and wait\n+   *           for the completion forced by the close.  Return should\n+   *           be immediate.\n+   *     case 2b: IO completes just after calling closesocket\n+   *           Since the closesocket is issued, we'll either get a\n+   *           completion back for the real IO or for the close.  We\n+   *           don't really care.  It may not even be possible to get\n+   *           a real completion here.  In any event, we'll awaken\n+   *           from NT_IO_WAIT immediately.\n+   */\n+\n+  _PR_THREAD_LOCK(me);\n+  fWait = me->io_pending;\n+  if (fWait) {\n+    /*\n+     * If there's still I/O pending, it should have already timed\n+     * out once before this function is called.\n      */\n+    PR_ASSERT(me->io_suspended == PR_TRUE);\n \n-    _PR_THREAD_LOCK(me);\n-    fWait = me->io_pending;\n-    if (fWait) {\n-        /*\n-         * If there's still I/O pending, it should have already timed\n-         * out once before this function is called.\n-         */\n+    /* Set up to wait for I/O completion again */\n+    me->state = _PR_IO_WAIT;\n+    me->io_suspended = PR_FALSE;\n+    me->md.interrupt_disabled = PR_TRUE;\n+  }\n+  _PR_THREAD_UNLOCK(me);\n+\n+  /* Close the socket if there is one */\n+  if (sock != INVALID_SOCKET) {\n+    rv = closesocket((SOCKET)sock);\n+  }\n+\n+  /* If there was I/O pending before the close, wait for it to complete */\n+  if (fWait) {\n+    /* Wait and wait for the I/O to complete */\n+    for (loop_count = 0; fWait; ++loop_count) {\n+      _NT_IO_WAIT(me, CLOSE_TIMEOUT);\n+\n+      _PR_THREAD_LOCK(me);\n+      fWait = me->io_pending;\n+      if (fWait) {\n         PR_ASSERT(me->io_suspended == PR_TRUE);\n-\n-        /* Set up to wait for I/O completion again */\n         me->state = _PR_IO_WAIT;\n         me->io_suspended = PR_FALSE;\n-        me->md.interrupt_disabled = PR_TRUE;\n-    }\n-    _PR_THREAD_UNLOCK(me);\n+      }\n+      _PR_THREAD_UNLOCK(me);\n \n-    /* Close the socket if there is one */\n-    if (sock != INVALID_SOCKET) {\n-        rv = closesocket((SOCKET)sock);\n+      if (loop_count > max_wait_loops) {\n+        max_wait_loops = loop_count;\n+      }\n     }\n \n-    /* If there was I/O pending before the close, wait for it to complete */\n-    if (fWait) {\n-        /* Wait and wait for the I/O to complete */\n-        for (loop_count = 0; fWait; ++loop_count) {\n-            _NT_IO_WAIT(me, CLOSE_TIMEOUT);\n-\n-            _PR_THREAD_LOCK(me);\n-            fWait = me->io_pending;\n-            if (fWait) {\n-                PR_ASSERT(me->io_suspended == PR_TRUE);\n-                me->state = _PR_IO_WAIT;\n-                me->io_suspended = PR_FALSE;\n-            }\n-            _PR_THREAD_UNLOCK(me);\n-\n-            if (loop_count > max_wait_loops) {\n-                max_wait_loops = loop_count;\n-            }\n-        }\n-\n-        if (loop_count > 1) {\n-            ++missing_completions;\n-        }\n-\n-        me->md.interrupt_disabled = PR_FALSE;\n-        me->io_pending = PR_FALSE;\n-        me->state = _PR_RUNNING;\n+    if (loop_count > 1) {\n+      ++missing_completions;\n     }\n \n-    PR_ASSERT(me->io_pending == PR_FALSE);\n-    me->md.thr_bound_cpu = NULL;\n-    me->io_suspended = PR_FALSE;\n+    me->md.interrupt_disabled = PR_FALSE;\n+    me->io_pending = PR_FALSE;\n+    me->state = _PR_RUNNING;\n+  }\n \n-    return rv;\n+  PR_ASSERT(me->io_pending == PR_FALSE);\n+  me->md.thr_bound_cpu = NULL;\n+  me->io_suspended = PR_FALSE;\n+\n+  return rv;\n }\n \n-PROsfd\n-_PR_MD_SOCKET(int af, int type, int flags)\n-{\n-    SOCKET sock;\n+PROsfd _PR_MD_SOCKET(int af, int type, int flags) {\n+  SOCKET sock;\n \n-    sock = socket(af, type, flags);\n+  sock = socket(af, type, flags);\n \n-    if (sock == INVALID_SOCKET) {\n-        _PR_MD_MAP_SOCKET_ERROR(WSAGetLastError());\n-    }\n+  if (sock == INVALID_SOCKET) {\n+    _PR_MD_MAP_SOCKET_ERROR(WSAGetLastError());\n+  }\n \n-    return (PROsfd)sock;\n+  return (PROsfd)sock;\n }\n \n struct connect_data_s {\n-    PRInt32 status;\n-    PRInt32 error;\n-    PROsfd osfd;\n-    struct sockaddr* addr;\n-    PRUint32 addrlen;\n-    PRIntervalTime timeout;\n+  PRInt32 status;\n+  PRInt32 error;\n+  PROsfd osfd;\n+  struct sockaddr* addr;\n+  PRUint32 addrlen;\n+  PRIntervalTime timeout;\n };\n \n-void\n-_PR_MD_connect_thread(void* cdata)\n-{\n-    struct connect_data_s* cd = (struct connect_data_s*)cdata;\n+void _PR_MD_connect_thread(void* cdata) {\n+  struct connect_data_s* cd = (struct connect_data_s*)cdata;\n \n-    cd->status = connect(cd->osfd, cd->addr, cd->addrlen);\n+  cd->status = connect(cd->osfd, cd->addr, cd->addrlen);\n \n-    if (cd->status == SOCKET_ERROR) {\n-        cd->error = WSAGetLastError();\n-    }\n+  if (cd->status == SOCKET_ERROR) {\n+    cd->error = WSAGetLastError();\n+  }\n \n-    return;\n+  return;\n }\n \n-PRInt32\n-_PR_MD_CONNECT(PRFileDesc* fd, const PRNetAddr* addr, PRUint32 addrlen,\n-               PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    u_long nbio;\n-    PRInt32 rc;\n+PRInt32 _PR_MD_CONNECT(PRFileDesc* fd, const PRNetAddr* addr, PRUint32 addrlen,\n+                       PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  u_long nbio;\n+  PRInt32 rc;\n \n-    if (fd->secret->nonblocking) {\n-        if (!fd->secret->md.io_model_committed) {\n-            rv = _md_MakeNonblock((HANDLE)osfd);\n-            PR_ASSERT(0 != rv);\n-            fd->secret->md.io_model_committed = PR_TRUE;\n-        }\n+  if (fd->secret->nonblocking) {\n+    if (!fd->secret->md.io_model_committed) {\n+      rv = _md_MakeNonblock((HANDLE)osfd);\n+      PR_ASSERT(0 != rv);\n+      fd->secret->md.io_model_committed = PR_TRUE;\n+    }\n \n-        if ((rv = connect(osfd, (struct sockaddr*)addr, addrlen)) == -1) {\n-            err = WSAGetLastError();\n-            _PR_MD_MAP_CONNECT_ERROR(err);\n-        }\n-        return rv;\n+    if ((rv = connect(osfd, (struct sockaddr*)addr, addrlen)) == -1) {\n+      err = WSAGetLastError();\n+      _PR_MD_MAP_CONNECT_ERROR(err);\n     }\n+    return rv;\n+  }\n+\n+  /*\n+   * Temporarily make the socket non-blocking so that we can\n+   * initiate a non-blocking connect and wait for its completion\n+   * (with a timeout) in select.\n+   */\n+  PR_ASSERT(!fd->secret->md.io_model_committed);\n+  nbio = 1;\n+  rv = ioctlsocket((SOCKET)osfd, FIONBIO, &nbio);\n+  PR_ASSERT(0 == rv);\n+\n+  rc = _nt_nonblock_connect(fd, (struct sockaddr*)addr, addrlen, timeout);\n+\n+  /* Set the socket back to blocking. */\n+  nbio = 0;\n+  rv = ioctlsocket((SOCKET)osfd, FIONBIO, &nbio);\n+  PR_ASSERT(0 == rv);\n+\n+  return rc;\n+}\n \n-    /*\n-     * Temporarily make the socket non-blocking so that we can\n-     * initiate a non-blocking connect and wait for its completion\n-     * (with a timeout) in select.\n-     */\n-    PR_ASSERT(!fd->secret->md.io_model_committed);\n-    nbio = 1;\n-    rv = ioctlsocket((SOCKET)osfd, FIONBIO, &nbio);\n-    PR_ASSERT(0 == rv);\n-\n-    rc = _nt_nonblock_connect(fd, (struct sockaddr*)addr, addrlen, timeout);\n-\n-    /* Set the socket back to blocking. */\n-    nbio = 0;\n-    rv = ioctlsocket((SOCKET)osfd, FIONBIO, &nbio);\n-    PR_ASSERT(0 == rv);\n-\n-    return rc;\n-}\n-\n-PRInt32\n-_PR_MD_BIND(PRFileDesc* fd, const PRNetAddr* addr, PRUint32 addrlen)\n-{\n-    PRInt32 rv;\n+PRInt32 _PR_MD_BIND(PRFileDesc* fd, const PRNetAddr* addr, PRUint32 addrlen) {\n+  PRInt32 rv;\n #if 0\n     int one = 1;\n #endif\n \n-    rv =\n-        bind(fd->secret->md.osfd, (const struct sockaddr*)&(addr->inet), addrlen);\n+  rv =\n+      bind(fd->secret->md.osfd, (const struct sockaddr*)&(addr->inet), addrlen);\n \n-    if (rv == SOCKET_ERROR) {\n-        _PR_MD_MAP_BIND_ERROR(WSAGetLastError());\n-        return -1;\n-    }\n+  if (rv == SOCKET_ERROR) {\n+    _PR_MD_MAP_BIND_ERROR(WSAGetLastError());\n+    return -1;\n+  }\n \n #if 0\n     /* Disable nagle- so far unknown if this is good or not...\n@@ -1224,1325 +1186,1279 @@ _PR_MD_BIND(PRFileDesc* fd, const PRNetAddr* addr, PRUint32 addrlen)\n     PR_ASSERT(rv == 0);\n #endif\n \n-    return 0;\n+  return 0;\n }\n \n-void\n-_PR_MD_UPDATE_ACCEPT_CONTEXT(PROsfd accept_sock, PROsfd listen_sock)\n-{\n-    /* Sockets accept()'d with AcceptEx need to call this setsockopt before\n-     * calling anything other than ReadFile(), WriteFile(), send(), recv(),\n-     * Transmitfile(), and closesocket().  In order to call any other\n-     * winsock functions, we have to make this setsockopt call.\n-     *\n-     * XXXMB - For the server, we *NEVER* need this in\n-     * the \"normal\" code path.  But now we have to call it.  This is a waste\n-     * of a system call.  We'd like to only call it before calling the\n-     * obscure socket calls, but since we don't know at that point what the\n-     * original socket was (or even if it is still alive) we can't do it\n-     * at that point...\n-     */\n-    setsockopt((SOCKET)accept_sock, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT,\n-               (char*)&listen_sock, sizeof(listen_sock));\n+void _PR_MD_UPDATE_ACCEPT_CONTEXT(PROsfd accept_sock, PROsfd listen_sock) {\n+  /* Sockets accept()'d with AcceptEx need to call this setsockopt before\n+   * calling anything other than ReadFile(), WriteFile(), send(), recv(),\n+   * Transmitfile(), and closesocket().  In order to call any other\n+   * winsock functions, we have to make this setsockopt call.\n+   *\n+   * XXXMB - For the server, we *NEVER* need this in\n+   * the \"normal\" code path.  But now we have to call it.  This is a waste\n+   * of a system call.  We'd like to only call it before calling the\n+   * obscure socket calls, but since we don't know at that point what the\n+   * original socket was (or even if it is still alive) we can't do it\n+   * at that point...\n+   */\n+  setsockopt((SOCKET)accept_sock, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT,\n+             (char*)&listen_sock, sizeof(listen_sock));\n }\n \n #define INET_ADDR_PADDED (sizeof(PRNetAddr) + 16)\n-PROsfd\n-_PR_MD_FAST_ACCEPT(PRFileDesc* fd, PRNetAddr* raddr, PRUint32* rlen,\n-                   PRIntervalTime timeout, PRBool fast,\n-                   _PR_AcceptTimeoutCallback callback,\n-                   void* callbackArg)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    SOCKET accept_sock;\n-    int bytes;\n-    PRNetAddr* Laddr;\n-    PRNetAddr* Raddr;\n-    PRUint32 llen, err;\n-    int rv;\n-\n-    if (_NT_USE_NB_IO(fd)) {\n-        if (!fd->secret->md.io_model_committed) {\n-            rv = _md_MakeNonblock((HANDLE)osfd);\n-            PR_ASSERT(0 != rv);\n-            fd->secret->md.io_model_committed = PR_TRUE;\n-        }\n-        /*\n-         * The accepted socket inherits the nonblocking and\n-         * inheritable (HANDLE_FLAG_INHERIT) attributes of\n-         * the listening socket.\n-         */\n-        accept_sock =\n-            _nt_nonblock_accept(fd, (struct sockaddr*)raddr, rlen, timeout);\n-        if (!fd->secret->nonblocking) {\n-            u_long zero = 0;\n-\n-            rv = ioctlsocket(accept_sock, FIONBIO, &zero);\n-            PR_ASSERT(0 == rv);\n-        }\n-        return accept_sock;\n+PROsfd _PR_MD_FAST_ACCEPT(PRFileDesc* fd, PRNetAddr* raddr, PRUint32* rlen,\n+                          PRIntervalTime timeout, PRBool fast,\n+                          _PR_AcceptTimeoutCallback callback,\n+                          void* callbackArg) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  SOCKET accept_sock;\n+  int bytes;\n+  PRNetAddr* Laddr;\n+  PRNetAddr* Raddr;\n+  PRUint32 llen, err;\n+  int rv;\n+\n+  if (_NT_USE_NB_IO(fd)) {\n+    if (!fd->secret->md.io_model_committed) {\n+      rv = _md_MakeNonblock((HANDLE)osfd);\n+      PR_ASSERT(0 != rv);\n+      fd->secret->md.io_model_committed = PR_TRUE;\n     }\n+    /*\n+     * The accepted socket inherits the nonblocking and\n+     * inheritable (HANDLE_FLAG_INHERIT) attributes of\n+     * the listening socket.\n+     */\n+    accept_sock =\n+        _nt_nonblock_accept(fd, (struct sockaddr*)raddr, rlen, timeout);\n+    if (!fd->secret->nonblocking) {\n+      u_long zero = 0;\n \n-    if (me->io_suspended) {\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-        return -1;\n+      rv = ioctlsocket(accept_sock, FIONBIO, &zero);\n+      PR_ASSERT(0 == rv);\n     }\n+    return accept_sock;\n+  }\n \n-    if (!fd->secret->md.io_model_committed) {\n-        rv = _md_Associate((HANDLE)osfd);\n-        PR_ASSERT(0 != rv);\n-        fd->secret->md.io_model_committed = PR_TRUE;\n-    }\n+  if (me->io_suspended) {\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    return -1;\n+  }\n+\n+  if (!fd->secret->md.io_model_committed) {\n+    rv = _md_Associate((HANDLE)osfd);\n+    PR_ASSERT(0 != rv);\n+    fd->secret->md.io_model_committed = PR_TRUE;\n+  }\n \n+  if (!me->md.acceptex_buf) {\n+    me->md.acceptex_buf = PR_MALLOC(2 * INET_ADDR_PADDED);\n     if (!me->md.acceptex_buf) {\n-        me->md.acceptex_buf = PR_MALLOC(2 * INET_ADDR_PADDED);\n-        if (!me->md.acceptex_buf) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            return -1;\n-        }\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      return -1;\n     }\n+  }\n \n-    accept_sock = _md_get_recycled_socket(fd->secret->af);\n-    if (accept_sock == INVALID_SOCKET) {\n-        return -1;\n-    }\n+  accept_sock = _md_get_recycled_socket(fd->secret->af);\n+  if (accept_sock == INVALID_SOCKET) {\n+    return -1;\n+  }\n \n-    memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n-    if (_native_threads_only) {\n-        me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n-    }\n+  memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n+  if (_native_threads_only) {\n+    me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n+  }\n \n+  _PR_THREAD_LOCK(me);\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    _PR_THREAD_UNLOCK(me);\n+    closesocket(accept_sock);\n+    return -1;\n+  }\n+  me->io_pending = PR_TRUE;\n+  me->state = _PR_IO_WAIT;\n+  _PR_THREAD_UNLOCK(me);\n+  me->io_fd = osfd;\n+\n+  rv = AcceptEx((SOCKET)osfd, accept_sock, me->md.acceptex_buf, 0,\n+                INET_ADDR_PADDED, INET_ADDR_PADDED, &bytes,\n+                &(me->md.overlapped.overlapped));\n+\n+  if ((rv == 0) && ((err = WSAGetLastError()) != ERROR_IO_PENDING)) {\n+    /* Argh! The IO failed */\n+    closesocket(accept_sock);\n     _PR_THREAD_LOCK(me);\n+    me->io_pending = PR_FALSE;\n+    me->state = _PR_RUNNING;\n     if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        _PR_THREAD_UNLOCK(me);\n-        closesocket(accept_sock);\n-        return -1;\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+      _PR_THREAD_UNLOCK(me);\n+      return -1;\n     }\n-    me->io_pending = PR_TRUE;\n-    me->state = _PR_IO_WAIT;\n     _PR_THREAD_UNLOCK(me);\n-    me->io_fd = osfd;\n-\n-    rv = AcceptEx((SOCKET)osfd, accept_sock, me->md.acceptex_buf, 0,\n-                  INET_ADDR_PADDED, INET_ADDR_PADDED, &bytes,\n-                  &(me->md.overlapped.overlapped));\n-\n-    if ((rv == 0) && ((err = WSAGetLastError()) != ERROR_IO_PENDING)) {\n-        /* Argh! The IO failed */\n-        closesocket(accept_sock);\n-        _PR_THREAD_LOCK(me);\n-        me->io_pending = PR_FALSE;\n-        me->state = _PR_RUNNING;\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-            _PR_THREAD_UNLOCK(me);\n-            return -1;\n-        }\n-        _PR_THREAD_UNLOCK(me);\n \n-        _PR_MD_MAP_ACCEPTEX_ERROR(err);\n-        return -1;\n-    }\n+    _PR_MD_MAP_ACCEPTEX_ERROR(err);\n+    return -1;\n+  }\n \n-    if (_native_threads_only && rv) {\n-        _native_thread_io_nowait(me, rv, bytes);\n-    } else if (_NT_IO_WAIT(me, timeout) == PR_FAILURE) {\n-        PR_ASSERT(0);\n-        closesocket(accept_sock);\n-        return -1;\n-    }\n+  if (_native_threads_only && rv) {\n+    _native_thread_io_nowait(me, rv, bytes);\n+  } else if (_NT_IO_WAIT(me, timeout) == PR_FAILURE) {\n+    PR_ASSERT(0);\n+    closesocket(accept_sock);\n+    return -1;\n+  }\n \n-    PR_ASSERT(me->io_pending == PR_FALSE || me->io_suspended == PR_TRUE);\n+  PR_ASSERT(me->io_pending == PR_FALSE || me->io_suspended == PR_TRUE);\n \n-    if (me->io_suspended) {\n-        closesocket(accept_sock);\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        } else {\n-            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-        }\n-        return -1;\n+  if (me->io_suspended) {\n+    closesocket(accept_sock);\n+    if (_PR_PENDING_INTERRUPT(me)) {\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    } else {\n+      PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n     }\n+    return -1;\n+  }\n \n-    if (me->md.blocked_io_status == 0) {\n-        closesocket(accept_sock);\n-        _PR_MD_MAP_ACCEPTEX_ERROR(me->md.blocked_io_error);\n-        return -1;\n-    }\n+  if (me->md.blocked_io_status == 0) {\n+    closesocket(accept_sock);\n+    _PR_MD_MAP_ACCEPTEX_ERROR(me->md.blocked_io_error);\n+    return -1;\n+  }\n \n-    if (!fast) {\n-        _PR_MD_UPDATE_ACCEPT_CONTEXT((SOCKET)accept_sock, (SOCKET)osfd);\n-    }\n+  if (!fast) {\n+    _PR_MD_UPDATE_ACCEPT_CONTEXT((SOCKET)accept_sock, (SOCKET)osfd);\n+  }\n \n-    /* IO is done */\n-    GetAcceptExSockaddrs(me->md.acceptex_buf, 0, INET_ADDR_PADDED,\n-                         INET_ADDR_PADDED, (LPSOCKADDR*)&(Laddr), &llen,\n-                         (LPSOCKADDR*)&(Raddr), (unsigned int*)rlen);\n+  /* IO is done */\n+  GetAcceptExSockaddrs(me->md.acceptex_buf, 0, INET_ADDR_PADDED,\n+                       INET_ADDR_PADDED, (LPSOCKADDR*)&(Laddr), &llen,\n+                       (LPSOCKADDR*)&(Raddr), (unsigned int*)rlen);\n \n-    if (raddr != NULL) {\n-        memcpy((char*)raddr, (char*)&Raddr->inet, *rlen);\n-    }\n+  if (raddr != NULL) {\n+    memcpy((char*)raddr, (char*)&Raddr->inet, *rlen);\n+  }\n \n-    PR_ASSERT(me->io_pending == PR_FALSE);\n+  PR_ASSERT(me->io_pending == PR_FALSE);\n \n-    return accept_sock;\n+  return accept_sock;\n }\n \n-PRInt32\n-_PR_MD_FAST_ACCEPT_READ(PRFileDesc* sd, PROsfd* newSock,\n-                        PRNetAddr** raddr, void* buf, PRInt32 amount,\n-                        PRIntervalTime timeout, PRBool fast,\n-                        _PR_AcceptTimeoutCallback callback,\n-                        void* callbackArg)\n-{\n-    PROsfd sock = sd->secret->md.osfd;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    int bytes;\n-    PRNetAddr* Laddr;\n-    PRUint32 llen, rlen, err;\n-    int rv;\n-    PRBool isConnected;\n-    PRBool madeCallback = PR_FALSE;\n+PRInt32 _PR_MD_FAST_ACCEPT_READ(PRFileDesc* sd, PROsfd* newSock,\n+                                PRNetAddr** raddr, void* buf, PRInt32 amount,\n+                                PRIntervalTime timeout, PRBool fast,\n+                                _PR_AcceptTimeoutCallback callback,\n+                                void* callbackArg) {\n+  PROsfd sock = sd->secret->md.osfd;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  int bytes;\n+  PRNetAddr* Laddr;\n+  PRUint32 llen, rlen, err;\n+  int rv;\n+  PRBool isConnected;\n+  PRBool madeCallback = PR_FALSE;\n+\n+  if (me->io_suspended) {\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    return -1;\n+  }\n \n-    if (me->io_suspended) {\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-        return -1;\n-    }\n+  if (!sd->secret->md.io_model_committed) {\n+    rv = _md_Associate((HANDLE)sock);\n+    PR_ASSERT(0 != rv);\n+    sd->secret->md.io_model_committed = PR_TRUE;\n+  }\n \n-    if (!sd->secret->md.io_model_committed) {\n-        rv = _md_Associate((HANDLE)sock);\n-        PR_ASSERT(0 != rv);\n-        sd->secret->md.io_model_committed = PR_TRUE;\n-    }\n+  *newSock = _md_get_recycled_socket(sd->secret->af);\n+  if (*newSock == INVALID_SOCKET) {\n+    return -1;\n+  }\n \n-    *newSock = _md_get_recycled_socket(sd->secret->af);\n-    if (*newSock == INVALID_SOCKET) {\n-        return -1;\n-    }\n+  memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n+  if (_native_threads_only) {\n+    me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n+  }\n \n-    memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n-    if (_native_threads_only) {\n-        me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n-    }\n+  _PR_THREAD_LOCK(me);\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    _PR_THREAD_UNLOCK(me);\n+    closesocket(*newSock);\n+    return -1;\n+  }\n+  me->io_pending = PR_TRUE;\n+  me->state = _PR_IO_WAIT;\n+  _PR_THREAD_UNLOCK(me);\n+  me->io_fd = sock;\n+\n+  rv = AcceptEx((SOCKET)sock, *newSock, buf, amount, INET_ADDR_PADDED,\n+                INET_ADDR_PADDED, &bytes, &(me->md.overlapped.overlapped));\n \n+  if ((rv == 0) && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n+    closesocket(*newSock);\n     _PR_THREAD_LOCK(me);\n+    me->io_pending = PR_FALSE;\n+    me->state = _PR_RUNNING;\n     if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        _PR_THREAD_UNLOCK(me);\n-        closesocket(*newSock);\n-        return -1;\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+      _PR_THREAD_UNLOCK(me);\n+      return -1;\n     }\n-    me->io_pending = PR_TRUE;\n-    me->state = _PR_IO_WAIT;\n     _PR_THREAD_UNLOCK(me);\n-    me->io_fd = sock;\n-\n-    rv = AcceptEx((SOCKET)sock, *newSock, buf, amount, INET_ADDR_PADDED,\n-                  INET_ADDR_PADDED, &bytes, &(me->md.overlapped.overlapped));\n-\n-    if ((rv == 0) && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n-        closesocket(*newSock);\n-        _PR_THREAD_LOCK(me);\n-        me->io_pending = PR_FALSE;\n-        me->state = _PR_RUNNING;\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-            _PR_THREAD_UNLOCK(me);\n-            return -1;\n-        }\n-        _PR_THREAD_UNLOCK(me);\n \n-        _PR_MD_MAP_ACCEPTEX_ERROR(err);\n-        return -1;\n-    }\n+    _PR_MD_MAP_ACCEPTEX_ERROR(err);\n+    return -1;\n+  }\n \n-    if (_native_threads_only && rv) {\n-        _native_thread_io_nowait(me, rv, bytes);\n-    } else if (_NT_IO_WAIT(me, timeout) == PR_FAILURE) {\n-        PR_ASSERT(0);\n-        closesocket(*newSock);\n-        return -1;\n-    }\n+  if (_native_threads_only && rv) {\n+    _native_thread_io_nowait(me, rv, bytes);\n+  } else if (_NT_IO_WAIT(me, timeout) == PR_FAILURE) {\n+    PR_ASSERT(0);\n+    closesocket(*newSock);\n+    return -1;\n+  }\n \n retry:\n-    if (me->io_suspended) {\n-        PRInt32 err;\n-        INT seconds;\n-        INT bytes = sizeof(seconds);\n-\n-        PR_ASSERT(timeout != PR_INTERVAL_NO_TIMEOUT);\n+  if (me->io_suspended) {\n+    PRInt32 err;\n+    INT seconds;\n+    INT bytes = sizeof(seconds);\n \n-        err = getsockopt(*newSock, SOL_SOCKET, SO_CONNECT_TIME, (char*)&seconds,\n-                         (PINT)&bytes);\n-        if (err == NO_ERROR) {\n-            PRIntervalTime elapsed = PR_SecondsToInterval(seconds);\n+    PR_ASSERT(timeout != PR_INTERVAL_NO_TIMEOUT);\n \n-            if (seconds == 0xffffffff) {\n-                isConnected = PR_FALSE;\n-            } else {\n-                isConnected = PR_TRUE;\n-            }\n+    err = getsockopt(*newSock, SOL_SOCKET, SO_CONNECT_TIME, (char*)&seconds,\n+                     (PINT)&bytes);\n+    if (err == NO_ERROR) {\n+      PRIntervalTime elapsed = PR_SecondsToInterval(seconds);\n \n-            if (!isConnected) {\n-                if (madeCallback == PR_FALSE && callback) {\n-                    callback(callbackArg);\n-                }\n-                madeCallback = PR_TRUE;\n-                me->state = _PR_IO_WAIT;\n-                if (_NT_ResumeIO(me, timeout) == PR_FAILURE) {\n-                    closesocket(*newSock);\n-                    return -1;\n-                }\n-                goto retry;\n-            }\n+      if (seconds == 0xffffffff) {\n+        isConnected = PR_FALSE;\n+      } else {\n+        isConnected = PR_TRUE;\n+      }\n \n-            if (elapsed < timeout) {\n-                /* Socket is connected but time not elapsed, RESUME IO */\n-                timeout -= elapsed;\n-                me->state = _PR_IO_WAIT;\n-                if (_NT_ResumeIO(me, timeout) == PR_FAILURE) {\n-                    closesocket(*newSock);\n-                    return -1;\n-                }\n-                goto retry;\n-            }\n-        } else {\n-            /*  What to do here? Assume socket not open?*/\n-            PR_ASSERT(0);\n-            isConnected = PR_FALSE;\n+      if (!isConnected) {\n+        if (madeCallback == PR_FALSE && callback) {\n+          callback(callbackArg);\n         }\n+        madeCallback = PR_TRUE;\n+        me->state = _PR_IO_WAIT;\n+        if (_NT_ResumeIO(me, timeout) == PR_FAILURE) {\n+          closesocket(*newSock);\n+          return -1;\n+        }\n+        goto retry;\n+      }\n \n-        rv = _NT_IO_ABORT(*newSock);\n-\n-        PR_ASSERT(me->io_pending == PR_FALSE);\n-        PR_ASSERT(me->io_suspended == PR_FALSE);\n-        PR_ASSERT(me->md.thr_bound_cpu == NULL);\n-        /* If the IO is still suspended, it means we didn't get any\n-         * completion from NT_IO_WAIT.  This is not disasterous, I hope,\n-         * but it may mean we still have an IO outstanding...  Try to\n-         * recover by just allowing ourselves to continue.\n-         */\n-        me->io_suspended = PR_FALSE;\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        } else {\n-            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+      if (elapsed < timeout) {\n+        /* Socket is connected but time not elapsed, RESUME IO */\n+        timeout -= elapsed;\n+        me->state = _PR_IO_WAIT;\n+        if (_NT_ResumeIO(me, timeout) == PR_FAILURE) {\n+          closesocket(*newSock);\n+          return -1;\n         }\n-        me->state = _PR_RUNNING;\n-        closesocket(*newSock);\n-        return -1;\n+        goto retry;\n+      }\n+    } else {\n+      /*  What to do here? Assume socket not open?*/\n+      PR_ASSERT(0);\n+      isConnected = PR_FALSE;\n     }\n \n+    rv = _NT_IO_ABORT(*newSock);\n+\n     PR_ASSERT(me->io_pending == PR_FALSE);\n     PR_ASSERT(me->io_suspended == PR_FALSE);\n     PR_ASSERT(me->md.thr_bound_cpu == NULL);\n-\n-    if (me->md.blocked_io_status == 0) {\n-        _PR_MD_MAP_ACCEPTEX_ERROR(me->md.blocked_io_error);\n-        closesocket(*newSock);\n-        return -1;\n-    }\n-\n-    if (!fast) {\n-        _PR_MD_UPDATE_ACCEPT_CONTEXT((SOCKET)*newSock, (SOCKET)sock);\n+    /* If the IO is still suspended, it means we didn't get any\n+     * completion from NT_IO_WAIT.  This is not disasterous, I hope,\n+     * but it may mean we still have an IO outstanding...  Try to\n+     * recover by just allowing ourselves to continue.\n+     */\n+    me->io_suspended = PR_FALSE;\n+    if (_PR_PENDING_INTERRUPT(me)) {\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    } else {\n+      PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n     }\n+    me->state = _PR_RUNNING;\n+    closesocket(*newSock);\n+    return -1;\n+  }\n \n-    /* IO is done */\n-    GetAcceptExSockaddrs(buf, amount, INET_ADDR_PADDED, INET_ADDR_PADDED,\n-                         (LPSOCKADDR*)&(Laddr), &llen, (LPSOCKADDR*)(raddr),\n-                         (unsigned int*)&rlen);\n-\n-    return me->md.blocked_io_bytes;\n-}\n+  PR_ASSERT(me->io_pending == PR_FALSE);\n+  PR_ASSERT(me->io_suspended == PR_FALSE);\n+  PR_ASSERT(me->md.thr_bound_cpu == NULL);\n \n-PRInt32\n-_PR_MD_SENDFILE(PRFileDesc* sock, PRSendFileData* sfd, PRInt32 flags,\n-                PRIntervalTime timeout)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRInt32 tflags;\n-    int rv, err;\n+  if (me->md.blocked_io_status == 0) {\n+    _PR_MD_MAP_ACCEPTEX_ERROR(me->md.blocked_io_error);\n+    closesocket(*newSock);\n+    return -1;\n+  }\n \n-    if (me->io_suspended) {\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-        return -1;\n-    }\n+  if (!fast) {\n+    _PR_MD_UPDATE_ACCEPT_CONTEXT((SOCKET)*newSock, (SOCKET)sock);\n+  }\n \n-    if (!sock->secret->md.io_model_committed) {\n-        rv = _md_Associate((HANDLE)sock->secret->md.osfd);\n-        PR_ASSERT(0 != rv);\n-        sock->secret->md.io_model_committed = PR_TRUE;\n-    }\n-    if (!me->md.xmit_bufs) {\n-        me->md.xmit_bufs = PR_NEW(TRANSMIT_FILE_BUFFERS);\n-        if (!me->md.xmit_bufs) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            return -1;\n-        }\n-    }\n-    me->md.xmit_bufs->Head = (void*)sfd->header;\n-    me->md.xmit_bufs->HeadLength = sfd->hlen;\n-    me->md.xmit_bufs->Tail = (void*)sfd->trailer;\n-    me->md.xmit_bufs->TailLength = sfd->tlen;\n+  /* IO is done */\n+  GetAcceptExSockaddrs(buf, amount, INET_ADDR_PADDED, INET_ADDR_PADDED,\n+                       (LPSOCKADDR*)&(Laddr), &llen, (LPSOCKADDR*)(raddr),\n+                       (unsigned int*)&rlen);\n \n-    memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n-    me->md.overlapped.overlapped.Offset = sfd->file_offset;\n-    if (_native_threads_only) {\n-        me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n-    }\n+  return me->md.blocked_io_bytes;\n+}\n \n-    tflags = 0;\n-    if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) {\n-        tflags = TF_DISCONNECT | TF_REUSE_SOCKET;\n-    }\n+PRInt32 _PR_MD_SENDFILE(PRFileDesc* sock, PRSendFileData* sfd, PRInt32 flags,\n+                        PRIntervalTime timeout) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRInt32 tflags;\n+  int rv, err;\n \n+  if (me->io_suspended) {\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    return -1;\n+  }\n+\n+  if (!sock->secret->md.io_model_committed) {\n+    rv = _md_Associate((HANDLE)sock->secret->md.osfd);\n+    PR_ASSERT(0 != rv);\n+    sock->secret->md.io_model_committed = PR_TRUE;\n+  }\n+  if (!me->md.xmit_bufs) {\n+    me->md.xmit_bufs = PR_NEW(TRANSMIT_FILE_BUFFERS);\n+    if (!me->md.xmit_bufs) {\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      return -1;\n+    }\n+  }\n+  me->md.xmit_bufs->Head = (void*)sfd->header;\n+  me->md.xmit_bufs->HeadLength = sfd->hlen;\n+  me->md.xmit_bufs->Tail = (void*)sfd->trailer;\n+  me->md.xmit_bufs->TailLength = sfd->tlen;\n+\n+  memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n+  me->md.overlapped.overlapped.Offset = sfd->file_offset;\n+  if (_native_threads_only) {\n+    me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n+  }\n+\n+  tflags = 0;\n+  if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) {\n+    tflags = TF_DISCONNECT | TF_REUSE_SOCKET;\n+  }\n+\n+  _PR_THREAD_LOCK(me);\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    _PR_THREAD_UNLOCK(me);\n+    return -1;\n+  }\n+  me->io_pending = PR_TRUE;\n+  me->state = _PR_IO_WAIT;\n+  _PR_THREAD_UNLOCK(me);\n+  me->io_fd = sock->secret->md.osfd;\n+\n+  rv = TransmitFile((SOCKET)sock->secret->md.osfd,\n+                    (HANDLE)sfd->fd->secret->md.osfd, (DWORD)sfd->file_nbytes,\n+                    (DWORD)0, (LPOVERLAPPED) & (me->md.overlapped.overlapped),\n+                    (TRANSMIT_FILE_BUFFERS*)me->md.xmit_bufs, (DWORD)tflags);\n+  if ((rv == 0) && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n     _PR_THREAD_LOCK(me);\n+    me->io_pending = PR_FALSE;\n+    me->state = _PR_RUNNING;\n     if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        _PR_THREAD_UNLOCK(me);\n-        return -1;\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+      _PR_THREAD_UNLOCK(me);\n+      return -1;\n     }\n-    me->io_pending = PR_TRUE;\n-    me->state = _PR_IO_WAIT;\n     _PR_THREAD_UNLOCK(me);\n-    me->io_fd = sock->secret->md.osfd;\n-\n-    rv = TransmitFile((SOCKET)sock->secret->md.osfd,\n-                      (HANDLE)sfd->fd->secret->md.osfd, (DWORD)sfd->file_nbytes,\n-                      (DWORD)0, (LPOVERLAPPED) & (me->md.overlapped.overlapped),\n-                      (TRANSMIT_FILE_BUFFERS*)me->md.xmit_bufs, (DWORD)tflags);\n-    if ((rv == 0) && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n-        _PR_THREAD_LOCK(me);\n-        me->io_pending = PR_FALSE;\n-        me->state = _PR_RUNNING;\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-            _PR_THREAD_UNLOCK(me);\n-            return -1;\n-        }\n-        _PR_THREAD_UNLOCK(me);\n \n-        _PR_MD_MAP_TRANSMITFILE_ERROR(err);\n-        return -1;\n-    }\n+    _PR_MD_MAP_TRANSMITFILE_ERROR(err);\n+    return -1;\n+  }\n \n-    if (_NT_IO_WAIT(me, timeout) == PR_FAILURE) {\n-        PR_ASSERT(0);\n-        return -1;\n-    }\n+  if (_NT_IO_WAIT(me, timeout) == PR_FAILURE) {\n+    PR_ASSERT(0);\n+    return -1;\n+  }\n \n-    PR_ASSERT(me->io_pending == PR_FALSE || me->io_suspended == PR_TRUE);\n+  PR_ASSERT(me->io_pending == PR_FALSE || me->io_suspended == PR_TRUE);\n \n-    if (me->io_suspended) {\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        } else {\n-            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-        }\n-        return -1;\n+  if (me->io_suspended) {\n+    if (_PR_PENDING_INTERRUPT(me)) {\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    } else {\n+      PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n     }\n+    return -1;\n+  }\n \n-    if (me->md.blocked_io_status == 0) {\n-        _PR_MD_MAP_TRANSMITFILE_ERROR(me->md.blocked_io_error);\n-        return -1;\n-    }\n+  if (me->md.blocked_io_status == 0) {\n+    _PR_MD_MAP_TRANSMITFILE_ERROR(me->md.blocked_io_error);\n+    return -1;\n+  }\n \n-    if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) {\n-        _md_put_recycled_socket(sock->secret->md.osfd, sock->secret->af);\n-    }\n+  if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) {\n+    _md_put_recycled_socket(sock->secret->md.osfd, sock->secret->af);\n+  }\n \n-    PR_ASSERT(me->io_pending == PR_FALSE);\n+  PR_ASSERT(me->io_pending == PR_FALSE);\n \n-    return me->md.blocked_io_bytes;\n+  return me->md.blocked_io_bytes;\n }\n \n-PRInt32\n-_PR_MD_RECV(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n-            PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    int bytes;\n-    int rv, err;\n-\n-    if (_NT_USE_NB_IO(fd)) {\n-        if (!fd->secret->md.io_model_committed) {\n-            rv = _md_MakeNonblock((HANDLE)osfd);\n-            PR_ASSERT(0 != rv);\n-            fd->secret->md.io_model_committed = PR_TRUE;\n-        }\n-        return _nt_nonblock_recv(fd, buf, amount, flags, timeout);\n-    }\n-\n-    if (me->io_suspended) {\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-        return -1;\n-    }\n+PRInt32 _PR_MD_RECV(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n+                    PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  int bytes;\n+  int rv, err;\n \n+  if (_NT_USE_NB_IO(fd)) {\n     if (!fd->secret->md.io_model_committed) {\n-        rv = _md_Associate((HANDLE)osfd);\n-        PR_ASSERT(0 != rv);\n-        fd->secret->md.io_model_committed = PR_TRUE;\n-    }\n-\n-    memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n-    if (_native_threads_only) {\n-        me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n+      rv = _md_MakeNonblock((HANDLE)osfd);\n+      PR_ASSERT(0 != rv);\n+      fd->secret->md.io_model_committed = PR_TRUE;\n     }\n+    return _nt_nonblock_recv(fd, buf, amount, flags, timeout);\n+  }\n \n+  if (me->io_suspended) {\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    return -1;\n+  }\n+\n+  if (!fd->secret->md.io_model_committed) {\n+    rv = _md_Associate((HANDLE)osfd);\n+    PR_ASSERT(0 != rv);\n+    fd->secret->md.io_model_committed = PR_TRUE;\n+  }\n+\n+  memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n+  if (_native_threads_only) {\n+    me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n+  }\n+\n+  _PR_THREAD_LOCK(me);\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    _PR_THREAD_UNLOCK(me);\n+    return -1;\n+  }\n+  me->io_pending = PR_TRUE;\n+  me->state = _PR_IO_WAIT;\n+  _PR_THREAD_UNLOCK(me);\n+  me->io_fd = osfd;\n+\n+  rv = ReadFile((HANDLE)osfd, buf, amount, &bytes,\n+                &(me->md.overlapped.overlapped));\n+  if ((rv == 0) && (GetLastError() != ERROR_IO_PENDING)) {\n     _PR_THREAD_LOCK(me);\n+    me->io_pending = PR_FALSE;\n+    me->state = _PR_RUNNING;\n     if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        _PR_THREAD_UNLOCK(me);\n-        return -1;\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+      _PR_THREAD_UNLOCK(me);\n+      return -1;\n     }\n-    me->io_pending = PR_TRUE;\n-    me->state = _PR_IO_WAIT;\n     _PR_THREAD_UNLOCK(me);\n-    me->io_fd = osfd;\n-\n-    rv = ReadFile((HANDLE)osfd, buf, amount, &bytes,\n-                  &(me->md.overlapped.overlapped));\n-    if ((rv == 0) && (GetLastError() != ERROR_IO_PENDING)) {\n-        _PR_THREAD_LOCK(me);\n-        me->io_pending = PR_FALSE;\n-        me->state = _PR_RUNNING;\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-            _PR_THREAD_UNLOCK(me);\n-            return -1;\n-        }\n-        _PR_THREAD_UNLOCK(me);\n \n-        if ((err = GetLastError()) == ERROR_HANDLE_EOF) {\n-            return 0;\n-        }\n-        _PR_MD_MAP_READ_ERROR(err);\n-        return -1;\n+    if ((err = GetLastError()) == ERROR_HANDLE_EOF) {\n+      return 0;\n     }\n+    _PR_MD_MAP_READ_ERROR(err);\n+    return -1;\n+  }\n \n-    if (_native_threads_only && rv) {\n-        _native_thread_io_nowait(me, rv, bytes);\n-    } else if (_NT_IO_WAIT(me, timeout) == PR_FAILURE) {\n-        PR_ASSERT(0);\n-        return -1;\n-    }\n+  if (_native_threads_only && rv) {\n+    _native_thread_io_nowait(me, rv, bytes);\n+  } else if (_NT_IO_WAIT(me, timeout) == PR_FAILURE) {\n+    PR_ASSERT(0);\n+    return -1;\n+  }\n \n-    PR_ASSERT(me->io_pending == PR_FALSE || me->io_suspended == PR_TRUE);\n+  PR_ASSERT(me->io_pending == PR_FALSE || me->io_suspended == PR_TRUE);\n \n-    if (me->io_suspended) {\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        } else {\n-            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-        }\n-        return -1;\n+  if (me->io_suspended) {\n+    if (_PR_PENDING_INTERRUPT(me)) {\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    } else {\n+      PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n     }\n+    return -1;\n+  }\n \n-    if (me->md.blocked_io_status == 0) {\n-        if (me->md.blocked_io_error == ERROR_HANDLE_EOF) {\n-            return 0;\n-        }\n-        _PR_MD_MAP_READ_ERROR(me->md.blocked_io_error);\n-        return -1;\n+  if (me->md.blocked_io_status == 0) {\n+    if (me->md.blocked_io_error == ERROR_HANDLE_EOF) {\n+      return 0;\n     }\n+    _PR_MD_MAP_READ_ERROR(me->md.blocked_io_error);\n+    return -1;\n+  }\n \n-    PR_ASSERT(me->io_pending == PR_FALSE);\n+  PR_ASSERT(me->io_pending == PR_FALSE);\n \n-    return me->md.blocked_io_bytes;\n+  return me->md.blocked_io_bytes;\n }\n \n-PRInt32\n-_PR_MD_SEND(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-            PRIntn flags, PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    int bytes;\n-    int rv, err;\n-\n-    if (_NT_USE_NB_IO(fd)) {\n-        if (!fd->secret->md.io_model_committed) {\n-            rv = _md_MakeNonblock((HANDLE)osfd);\n-            PR_ASSERT(0 != rv);\n-            fd->secret->md.io_model_committed = PR_TRUE;\n-        }\n-        return _nt_nonblock_send(fd, (char*)buf, amount, timeout);\n-    }\n-\n-    if (me->io_suspended) {\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-        return -1;\n-    }\n-\n-    if (!fd->secret->md.io_model_committed) {\n-        rv = _md_Associate((HANDLE)osfd);\n-        PR_ASSERT(0 != rv);\n-        fd->secret->md.io_model_committed = PR_TRUE;\n-    }\n-\n-    memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n-    if (_native_threads_only) {\n-        me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n+PRInt32 _PR_MD_SEND(PRFileDesc* fd, const void* buf, PRInt32 amount,\n+                    PRIntn flags, PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  int bytes;\n+  int rv, err;\n+\n+  if (_NT_USE_NB_IO(fd)) {\n+    if (!fd->secret->md.io_model_committed) {\n+      rv = _md_MakeNonblock((HANDLE)osfd);\n+      PR_ASSERT(0 != rv);\n+      fd->secret->md.io_model_committed = PR_TRUE;\n     }\n+    return _nt_nonblock_send(fd, (char*)buf, amount, timeout);\n+  }\n \n+  if (me->io_suspended) {\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    return -1;\n+  }\n+\n+  if (!fd->secret->md.io_model_committed) {\n+    rv = _md_Associate((HANDLE)osfd);\n+    PR_ASSERT(0 != rv);\n+    fd->secret->md.io_model_committed = PR_TRUE;\n+  }\n+\n+  memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n+  if (_native_threads_only) {\n+    me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n+  }\n+\n+  _PR_THREAD_LOCK(me);\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    _PR_THREAD_UNLOCK(me);\n+    return -1;\n+  }\n+  me->io_pending = PR_TRUE;\n+  me->state = _PR_IO_WAIT;\n+  _PR_THREAD_UNLOCK(me);\n+  me->io_fd = osfd;\n+\n+  rv = WriteFile((HANDLE)osfd, buf, amount, &bytes,\n+                 &(me->md.overlapped.overlapped));\n+  if ((rv == 0) && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n     _PR_THREAD_LOCK(me);\n+    me->io_pending = PR_FALSE;\n+    me->state = _PR_RUNNING;\n     if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        _PR_THREAD_UNLOCK(me);\n-        return -1;\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+      _PR_THREAD_UNLOCK(me);\n+      return -1;\n     }\n-    me->io_pending = PR_TRUE;\n-    me->state = _PR_IO_WAIT;\n     _PR_THREAD_UNLOCK(me);\n-    me->io_fd = osfd;\n \n-    rv = WriteFile((HANDLE)osfd, buf, amount, &bytes,\n-                   &(me->md.overlapped.overlapped));\n-    if ((rv == 0) && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n-        _PR_THREAD_LOCK(me);\n-        me->io_pending = PR_FALSE;\n-        me->state = _PR_RUNNING;\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-            _PR_THREAD_UNLOCK(me);\n-            return -1;\n-        }\n-        _PR_THREAD_UNLOCK(me);\n-\n-        _PR_MD_MAP_WRITE_ERROR(err);\n-        return -1;\n-    }\n+    _PR_MD_MAP_WRITE_ERROR(err);\n+    return -1;\n+  }\n \n-    if (_native_threads_only && rv) {\n-        _native_thread_io_nowait(me, rv, bytes);\n-    } else if (_NT_IO_WAIT(me, timeout) == PR_FAILURE) {\n-        PR_ASSERT(0);\n-        return -1;\n-    }\n+  if (_native_threads_only && rv) {\n+    _native_thread_io_nowait(me, rv, bytes);\n+  } else if (_NT_IO_WAIT(me, timeout) == PR_FAILURE) {\n+    PR_ASSERT(0);\n+    return -1;\n+  }\n \n-    PR_ASSERT(me->io_pending == PR_FALSE || me->io_suspended == PR_TRUE);\n+  PR_ASSERT(me->io_pending == PR_FALSE || me->io_suspended == PR_TRUE);\n \n-    if (me->io_suspended) {\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        } else {\n-            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-        }\n-        return -1;\n+  if (me->io_suspended) {\n+    if (_PR_PENDING_INTERRUPT(me)) {\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    } else {\n+      PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n     }\n+    return -1;\n+  }\n \n-    if (me->md.blocked_io_status == 0) {\n-        _PR_MD_MAP_WRITE_ERROR(me->md.blocked_io_error);\n-        return -1;\n-    }\n+  if (me->md.blocked_io_status == 0) {\n+    _PR_MD_MAP_WRITE_ERROR(me->md.blocked_io_error);\n+    return -1;\n+  }\n \n-    PR_ASSERT(me->io_pending == PR_FALSE);\n+  PR_ASSERT(me->io_pending == PR_FALSE);\n \n-    return me->md.blocked_io_bytes;\n+  return me->md.blocked_io_bytes;\n }\n \n-PRInt32\n-_PR_MD_SENDTO(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-              PRIntn flags, const PRNetAddr* addr, PRUint32 addrlen,\n-              PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv;\n-\n-    if (!fd->secret->md.io_model_committed) {\n-        rv = _md_MakeNonblock((HANDLE)osfd);\n-        PR_ASSERT(0 != rv);\n-        fd->secret->md.io_model_committed = PR_TRUE;\n-    }\n-    if (_NT_USE_NB_IO(fd)) {\n-        return _nt_nonblock_sendto(fd, buf, amount, (struct sockaddr*)addr, addrlen,\n-                                   timeout);\n-    } else {\n-        return pt_SendTo(osfd, buf, amount, flags, addr, addrlen, timeout);\n-    }\n+PRInt32 _PR_MD_SENDTO(PRFileDesc* fd, const void* buf, PRInt32 amount,\n+                      PRIntn flags, const PRNetAddr* addr, PRUint32 addrlen,\n+                      PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv;\n+\n+  if (!fd->secret->md.io_model_committed) {\n+    rv = _md_MakeNonblock((HANDLE)osfd);\n+    PR_ASSERT(0 != rv);\n+    fd->secret->md.io_model_committed = PR_TRUE;\n+  }\n+  if (_NT_USE_NB_IO(fd)) {\n+    return _nt_nonblock_sendto(fd, buf, amount, (struct sockaddr*)addr, addrlen,\n+                               timeout);\n+  } else {\n+    return pt_SendTo(osfd, buf, amount, flags, addr, addrlen, timeout);\n+  }\n }\n \n-PRInt32\n-_PR_MD_RECVFROM(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n-                PRNetAddr* addr, PRUint32* addrlen,\n-                PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv;\n-\n-    if (!fd->secret->md.io_model_committed) {\n-        rv = _md_MakeNonblock((HANDLE)osfd);\n-        PR_ASSERT(0 != rv);\n-        fd->secret->md.io_model_committed = PR_TRUE;\n-    }\n-    if (_NT_USE_NB_IO(fd)) {\n-        return _nt_nonblock_recvfrom(fd, buf, amount, (struct sockaddr*)addr,\n-                                     addrlen, timeout);\n-    } else {\n-        return pt_RecvFrom(osfd, buf, amount, flags, addr, addrlen, timeout);\n-    }\n+PRInt32 _PR_MD_RECVFROM(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n+                        PRNetAddr* addr, PRUint32* addrlen,\n+                        PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv;\n+\n+  if (!fd->secret->md.io_model_committed) {\n+    rv = _md_MakeNonblock((HANDLE)osfd);\n+    PR_ASSERT(0 != rv);\n+    fd->secret->md.io_model_committed = PR_TRUE;\n+  }\n+  if (_NT_USE_NB_IO(fd)) {\n+    return _nt_nonblock_recvfrom(fd, buf, amount, (struct sockaddr*)addr,\n+                                 addrlen, timeout);\n+  } else {\n+    return pt_RecvFrom(osfd, buf, amount, flags, addr, addrlen, timeout);\n+  }\n }\n \n /* XXXMB - for now this is a sockets call only */\n-PRInt32\n-_PR_MD_WRITEV(PRFileDesc* fd, const PRIOVec* iov, PRInt32 iov_size,\n-              PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    int index;\n-    int sent = 0;\n-    int rv;\n-\n-    if (_NT_USE_NB_IO(fd)) {\n-        if (!fd->secret->md.io_model_committed) {\n-            rv = _md_MakeNonblock((HANDLE)osfd);\n-            PR_ASSERT(0 != rv);\n-            fd->secret->md.io_model_committed = PR_TRUE;\n-        }\n-        return _nt_nonblock_writev(fd, iov, iov_size, timeout);\n+PRInt32 _PR_MD_WRITEV(PRFileDesc* fd, const PRIOVec* iov, PRInt32 iov_size,\n+                      PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  int index;\n+  int sent = 0;\n+  int rv;\n+\n+  if (_NT_USE_NB_IO(fd)) {\n+    if (!fd->secret->md.io_model_committed) {\n+      rv = _md_MakeNonblock((HANDLE)osfd);\n+      PR_ASSERT(0 != rv);\n+      fd->secret->md.io_model_committed = PR_TRUE;\n     }\n+    return _nt_nonblock_writev(fd, iov, iov_size, timeout);\n+  }\n \n-    for (index = 0; index < iov_size; index++) {\n-        rv = _PR_MD_SEND(fd, iov[index].iov_base, iov[index].iov_len, 0, timeout);\n-        if (rv > 0) {\n-            sent += rv;\n-        }\n-        if (rv != iov[index].iov_len) {\n-            if (sent <= 0) {\n-                return -1;\n-            }\n-            return -1;\n-        }\n+  for (index = 0; index < iov_size; index++) {\n+    rv = _PR_MD_SEND(fd, iov[index].iov_base, iov[index].iov_len, 0, timeout);\n+    if (rv > 0) {\n+      sent += rv;\n+    }\n+    if (rv != iov[index].iov_len) {\n+      if (sent <= 0) {\n+        return -1;\n+      }\n+      return -1;\n     }\n+  }\n \n-    return sent;\n+  return sent;\n }\n \n-PRInt32\n-_PR_MD_LISTEN(PRFileDesc* fd, PRIntn backlog)\n-{\n-    PRInt32 rv;\n+PRInt32 _PR_MD_LISTEN(PRFileDesc* fd, PRIntn backlog) {\n+  PRInt32 rv;\n \n-    rv = listen(fd->secret->md.osfd, backlog);\n-    if (rv < 0) {\n-        _PR_MD_MAP_LISTEN_ERROR(WSAGetLastError());\n-    }\n-    return (rv);\n+  rv = listen(fd->secret->md.osfd, backlog);\n+  if (rv < 0) {\n+    _PR_MD_MAP_LISTEN_ERROR(WSAGetLastError());\n+  }\n+  return (rv);\n }\n \n-PRInt32\n-_PR_MD_SHUTDOWN(PRFileDesc* fd, PRIntn how)\n-{\n-    PRInt32 rv;\n+PRInt32 _PR_MD_SHUTDOWN(PRFileDesc* fd, PRIntn how) {\n+  PRInt32 rv;\n \n-    rv = shutdown(fd->secret->md.osfd, how);\n-    if (rv < 0) {\n-        _PR_MD_MAP_SHUTDOWN_ERROR(WSAGetLastError());\n-    }\n-    return (rv);\n+  rv = shutdown(fd->secret->md.osfd, how);\n+  if (rv < 0) {\n+    _PR_MD_MAP_SHUTDOWN_ERROR(WSAGetLastError());\n+  }\n+  return (rv);\n }\n \n-PRStatus\n-_PR_MD_GETSOCKNAME(PRFileDesc* fd, PRNetAddr* addr, PRUint32* len)\n-{\n-    PRInt32 rv;\n+PRStatus _PR_MD_GETSOCKNAME(PRFileDesc* fd, PRNetAddr* addr, PRUint32* len) {\n+  PRInt32 rv;\n \n-    rv = getsockname((SOCKET)fd->secret->md.osfd, (struct sockaddr*)addr, len);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    } else {\n-        _PR_MD_MAP_GETSOCKNAME_ERROR(WSAGetLastError());\n-        return PR_FAILURE;\n-    }\n+  rv = getsockname((SOCKET)fd->secret->md.osfd, (struct sockaddr*)addr, len);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  } else {\n+    _PR_MD_MAP_GETSOCKNAME_ERROR(WSAGetLastError());\n+    return PR_FAILURE;\n+  }\n }\n \n-PRStatus\n-_PR_MD_GETPEERNAME(PRFileDesc* fd, PRNetAddr* addr, PRUint32* len)\n-{\n-    PRInt32 rv;\n+PRStatus _PR_MD_GETPEERNAME(PRFileDesc* fd, PRNetAddr* addr, PRUint32* len) {\n+  PRInt32 rv;\n \n-    /*\n-     * NT has a bug that, when invoked on a socket accepted by\n-     * AcceptEx(), getpeername() returns an all-zero peer address.\n-     * To work around this bug, we store the peer's address (returned\n-     * by AcceptEx()) with the socket fd and use the cached peer\n-     * address if the socket is an accepted socket.\n-     */\n+  /*\n+   * NT has a bug that, when invoked on a socket accepted by\n+   * AcceptEx(), getpeername() returns an all-zero peer address.\n+   * To work around this bug, we store the peer's address (returned\n+   * by AcceptEx()) with the socket fd and use the cached peer\n+   * address if the socket is an accepted socket.\n+   */\n \n-    if (fd->secret->md.accepted_socket) {\n-        INT seconds;\n-        INT bytes = sizeof(seconds);\n+  if (fd->secret->md.accepted_socket) {\n+    INT seconds;\n+    INT bytes = sizeof(seconds);\n \n-        /*\n-         * Determine if the socket is connected.\n-         */\n+    /*\n+     * Determine if the socket is connected.\n+     */\n \n-        rv = getsockopt(fd->secret->md.osfd, SOL_SOCKET, SO_CONNECT_TIME,\n-                        (char*)&seconds, (PINT)&bytes);\n-        if (rv == NO_ERROR) {\n-            if (seconds == 0xffffffff) {\n-                PR_SetError(PR_NOT_CONNECTED_ERROR, 0);\n-                return PR_FAILURE;\n-            }\n-            *len = PR_NETADDR_SIZE(&fd->secret->md.peer_addr);\n-            memcpy(addr, &fd->secret->md.peer_addr, *len);\n-            return PR_SUCCESS;\n-        } else {\n-            _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n-            return PR_FAILURE;\n-        }\n+    rv = getsockopt(fd->secret->md.osfd, SOL_SOCKET, SO_CONNECT_TIME,\n+                    (char*)&seconds, (PINT)&bytes);\n+    if (rv == NO_ERROR) {\n+      if (seconds == 0xffffffff) {\n+        PR_SetError(PR_NOT_CONNECTED_ERROR, 0);\n+        return PR_FAILURE;\n+      }\n+      *len = PR_NETADDR_SIZE(&fd->secret->md.peer_addr);\n+      memcpy(addr, &fd->secret->md.peer_addr, *len);\n+      return PR_SUCCESS;\n     } else {\n-        rv = getpeername((SOCKET)fd->secret->md.osfd, (struct sockaddr*)addr, len);\n-        if (rv == 0) {\n-            return PR_SUCCESS;\n-        } else {\n-            _PR_MD_MAP_GETPEERNAME_ERROR(WSAGetLastError());\n-            return PR_FAILURE;\n-        }\n+      _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n+      return PR_FAILURE;\n     }\n-}\n-\n-PRStatus\n-_PR_MD_GETSOCKOPT(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n-                  char* optval, PRInt32* optlen)\n-{\n-    PRInt32 rv;\n-\n-    rv = getsockopt((SOCKET)fd->secret->md.osfd, level, optname, optval, optlen);\n+  } else {\n+    rv = getpeername((SOCKET)fd->secret->md.osfd, (struct sockaddr*)addr, len);\n     if (rv == 0) {\n-        return PR_SUCCESS;\n+      return PR_SUCCESS;\n     } else {\n-        _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n-        return PR_FAILURE;\n+      _PR_MD_MAP_GETPEERNAME_ERROR(WSAGetLastError());\n+      return PR_FAILURE;\n     }\n+  }\n }\n \n-PRStatus\n-_PR_MD_SETSOCKOPT(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n-                  const char* optval, PRInt32 optlen)\n-{\n-    PRInt32 rv;\n+PRStatus _PR_MD_GETSOCKOPT(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n+                           char* optval, PRInt32* optlen) {\n+  PRInt32 rv;\n \n-    rv = setsockopt((SOCKET)fd->secret->md.osfd, level, optname, optval, optlen);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    } else {\n-        _PR_MD_MAP_SETSOCKOPT_ERROR(WSAGetLastError());\n-        return PR_FAILURE;\n-    }\n+  rv = getsockopt((SOCKET)fd->secret->md.osfd, level, optname, optval, optlen);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  } else {\n+    _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n+    return PR_FAILURE;\n+  }\n }\n \n-/* --- FILE IO ----------------------------------------------------------- */\n+PRStatus _PR_MD_SETSOCKOPT(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n+                           const char* optval, PRInt32 optlen) {\n+  PRInt32 rv;\n \n-PROsfd\n-_PR_MD_OPEN(const char* name, PRIntn osflags, PRIntn mode)\n-{\n-    HANDLE file;\n-    PRInt32 access = 0;\n-    PRInt32 flags = 0;\n-    PRInt32 flag6 = 0;\n+  rv = setsockopt((SOCKET)fd->secret->md.osfd, level, optname, optval, optlen);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  } else {\n+    _PR_MD_MAP_SETSOCKOPT_ERROR(WSAGetLastError());\n+    return PR_FAILURE;\n+  }\n+}\n \n-    if (osflags & PR_SYNC) {\n-        flag6 = FILE_FLAG_WRITE_THROUGH;\n-    }\n+/* --- FILE IO ----------------------------------------------------------- */\n \n-    if (osflags & PR_RDONLY || osflags & PR_RDWR) {\n-        access |= GENERIC_READ;\n-    }\n-    if (osflags & PR_WRONLY || osflags & PR_RDWR) {\n-        access |= GENERIC_WRITE;\n-    }\n+PROsfd _PR_MD_OPEN(const char* name, PRIntn osflags, PRIntn mode) {\n+  HANDLE file;\n+  PRInt32 access = 0;\n+  PRInt32 flags = 0;\n+  PRInt32 flag6 = 0;\n+\n+  if (osflags & PR_SYNC) {\n+    flag6 = FILE_FLAG_WRITE_THROUGH;\n+  }\n+\n+  if (osflags & PR_RDONLY || osflags & PR_RDWR) {\n+    access |= GENERIC_READ;\n+  }\n+  if (osflags & PR_WRONLY || osflags & PR_RDWR) {\n+    access |= GENERIC_WRITE;\n+  }\n+\n+  if (osflags & PR_CREATE_FILE && osflags & PR_EXCL) {\n+    flags = CREATE_NEW;\n+  } else if (osflags & PR_CREATE_FILE) {\n+    flags = (0 != (osflags & PR_TRUNCATE)) ? CREATE_ALWAYS : OPEN_ALWAYS;\n+  } else if (osflags & PR_TRUNCATE) {\n+    flags = TRUNCATE_EXISTING;\n+  } else {\n+    flags = OPEN_EXISTING;\n+  }\n+\n+  flag6 |= FILE_FLAG_OVERLAPPED;\n+\n+  file = CreateFile(name, access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,\n+                    flags, flag6, NULL);\n+  if (file == INVALID_HANDLE_VALUE) {\n+    _PR_MD_MAP_OPEN_ERROR(GetLastError());\n+    return -1;\n+  }\n \n-    if (osflags & PR_CREATE_FILE && osflags & PR_EXCL) {\n-        flags = CREATE_NEW;\n-    } else if (osflags & PR_CREATE_FILE) {\n-        flags = (0 != (osflags & PR_TRUNCATE)) ? CREATE_ALWAYS : OPEN_ALWAYS;\n-    } else if (osflags & PR_TRUNCATE) {\n-        flags = TRUNCATE_EXISTING;\n-    } else {\n-        flags = OPEN_EXISTING;\n+  if (osflags & PR_APPEND) {\n+    if (SetFilePointer(file, 0, 0, FILE_END) == 0xFFFFFFFF) {\n+      _PR_MD_MAP_LSEEK_ERROR(GetLastError());\n+      CloseHandle(file);\n+      return -1;\n     }\n+  }\n \n-    flag6 |= FILE_FLAG_OVERLAPPED;\n+  return (PROsfd)file;\n+}\n \n-    file = CreateFile(name, access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,\n-                      flags, flag6, NULL);\n-    if (file == INVALID_HANDLE_VALUE) {\n-        _PR_MD_MAP_OPEN_ERROR(GetLastError());\n-        return -1;\n-    }\n+PROsfd _PR_MD_OPEN_FILE(const char* name, PRIntn osflags, PRIntn mode) {\n+  HANDLE file;\n+  PRInt32 access = 0;\n+  PRInt32 flags = 0;\n+  PRInt32 flag6 = 0;\n+  SECURITY_ATTRIBUTES sa;\n+  LPSECURITY_ATTRIBUTES lpSA = NULL;\n+  PSECURITY_DESCRIPTOR pSD = NULL;\n+  PACL pACL = NULL;\n+\n+  if (osflags & PR_SYNC) {\n+    flag6 = FILE_FLAG_WRITE_THROUGH;\n+  }\n+\n+  if (osflags & PR_RDONLY || osflags & PR_RDWR) {\n+    access |= GENERIC_READ;\n+  }\n+  if (osflags & PR_WRONLY || osflags & PR_RDWR) {\n+    access |= GENERIC_WRITE;\n+  }\n+\n+  if (osflags & PR_CREATE_FILE && osflags & PR_EXCL) {\n+    flags = CREATE_NEW;\n+  } else if (osflags & PR_CREATE_FILE) {\n+    flags = (0 != (osflags & PR_TRUNCATE)) ? CREATE_ALWAYS : OPEN_ALWAYS;\n+  } else if (osflags & PR_TRUNCATE) {\n+    flags = TRUNCATE_EXISTING;\n+  } else {\n+    flags = OPEN_EXISTING;\n+  }\n+\n+  flag6 |= FILE_FLAG_OVERLAPPED;\n+\n+  if (osflags & PR_CREATE_FILE) {\n+    if (_PR_NT_MakeSecurityDescriptorACL(mode, fileAccessTable, &pSD, &pACL) ==\n+        PR_SUCCESS) {\n+      sa.nLength = sizeof(sa);\n+      sa.lpSecurityDescriptor = pSD;\n+      sa.bInheritHandle = FALSE;\n+      lpSA = &sa;\n+    }\n+  }\n+  file = CreateFile(name, access, FILE_SHARE_READ | FILE_SHARE_WRITE, lpSA,\n+                    flags, flag6, NULL);\n+  if (lpSA != NULL) {\n+    _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n+  }\n+  if (file == INVALID_HANDLE_VALUE) {\n+    _PR_MD_MAP_OPEN_ERROR(GetLastError());\n+    return -1;\n+  }\n \n-    if (osflags & PR_APPEND) {\n-        if (SetFilePointer(file, 0, 0, FILE_END) == 0xFFFFFFFF) {\n-            _PR_MD_MAP_LSEEK_ERROR(GetLastError());\n-            CloseHandle(file);\n-            return -1;\n-        }\n+  if (osflags & PR_APPEND) {\n+    if (SetFilePointer(file, 0, 0, FILE_END) == 0xFFFFFFFF) {\n+      _PR_MD_MAP_LSEEK_ERROR(GetLastError());\n+      CloseHandle(file);\n+      return -1;\n     }\n+  }\n \n-    return (PROsfd)file;\n+  return (PROsfd)file;\n }\n \n-PROsfd\n-_PR_MD_OPEN_FILE(const char* name, PRIntn osflags, PRIntn mode)\n-{\n-    HANDLE file;\n-    PRInt32 access = 0;\n-    PRInt32 flags = 0;\n-    PRInt32 flag6 = 0;\n-    SECURITY_ATTRIBUTES sa;\n-    LPSECURITY_ATTRIBUTES lpSA = NULL;\n-    PSECURITY_DESCRIPTOR pSD = NULL;\n-    PACL pACL = NULL;\n-\n-    if (osflags & PR_SYNC) {\n-        flag6 = FILE_FLAG_WRITE_THROUGH;\n-    }\n+PRInt32 _PR_MD_READ(PRFileDesc* fd, void* buf, PRInt32 len) {\n+  PROsfd f = fd->secret->md.osfd;\n+  PRUint32 bytes;\n+  int rv, err;\n+  LONG hiOffset = 0;\n+  LONG loOffset;\n+  LARGE_INTEGER offset; /* use for a normalized add of len to offset */\n \n-    if (osflags & PR_RDONLY || osflags & PR_RDWR) {\n-        access |= GENERIC_READ;\n-    }\n-    if (osflags & PR_WRONLY || osflags & PR_RDWR) {\n-        access |= GENERIC_WRITE;\n-    }\n+  if (!fd->secret->md.sync_file_io) {\n+    PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    if (osflags & PR_CREATE_FILE && osflags & PR_EXCL) {\n-        flags = CREATE_NEW;\n-    } else if (osflags & PR_CREATE_FILE) {\n-        flags = (0 != (osflags & PR_TRUNCATE)) ? CREATE_ALWAYS : OPEN_ALWAYS;\n-    } else if (osflags & PR_TRUNCATE) {\n-        flags = TRUNCATE_EXISTING;\n-    } else {\n-        flags = OPEN_EXISTING;\n+    if (me->io_suspended) {\n+      PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+      return -1;\n     }\n \n-    flag6 |= FILE_FLAG_OVERLAPPED;\n+    memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n+\n+    me->md.overlapped.overlapped.Offset = SetFilePointer(\n+        (HANDLE)f, 0, &me->md.overlapped.overlapped.OffsetHigh, FILE_CURRENT);\n+    PR_ASSERT((me->md.overlapped.overlapped.Offset != 0xffffffff) ||\n+              (GetLastError() == NO_ERROR));\n \n-    if (osflags & PR_CREATE_FILE) {\n-        if (_PR_NT_MakeSecurityDescriptorACL(mode, fileAccessTable, &pSD, &pACL) ==\n-            PR_SUCCESS) {\n-            sa.nLength = sizeof(sa);\n-            sa.lpSecurityDescriptor = pSD;\n-            sa.bInheritHandle = FALSE;\n-            lpSA = &sa;\n+    if (fd->secret->inheritable == _PR_TRI_TRUE) {\n+      rv = ReadFile((HANDLE)f, (LPVOID)buf, len, &bytes,\n+                    &me->md.overlapped.overlapped);\n+      if (rv != 0) {\n+        loOffset = SetFilePointer((HANDLE)f, bytes, &hiOffset, FILE_CURRENT);\n+        PR_ASSERT((loOffset != 0xffffffff) || (GetLastError() == NO_ERROR));\n+        return bytes;\n+      }\n+      err = GetLastError();\n+      if (err == ERROR_IO_PENDING) {\n+        rv = GetOverlappedResult((HANDLE)f, &me->md.overlapped.overlapped,\n+                                 &bytes, TRUE);\n+        if (rv != 0) {\n+          loOffset = SetFilePointer((HANDLE)f, bytes, &hiOffset, FILE_CURRENT);\n+          PR_ASSERT((loOffset != 0xffffffff) || (GetLastError() == NO_ERROR));\n+          return bytes;\n         }\n-    }\n-    file = CreateFile(name, access, FILE_SHARE_READ | FILE_SHARE_WRITE, lpSA,\n-                      flags, flag6, NULL);\n-    if (lpSA != NULL) {\n-        _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n-    }\n-    if (file == INVALID_HANDLE_VALUE) {\n-        _PR_MD_MAP_OPEN_ERROR(GetLastError());\n+        err = GetLastError();\n+      }\n+      if (err == ERROR_HANDLE_EOF) {\n+        return 0;\n+      } else {\n+        _PR_MD_MAP_READ_ERROR(err);\n         return -1;\n-    }\n+      }\n+    } else {\n+      if (!fd->secret->md.io_model_committed) {\n+        rv = _md_Associate((HANDLE)f);\n+        PR_ASSERT(rv != 0);\n+        fd->secret->md.io_model_committed = PR_TRUE;\n+      }\n \n-    if (osflags & PR_APPEND) {\n-        if (SetFilePointer(file, 0, 0, FILE_END) == 0xFFFFFFFF) {\n-            _PR_MD_MAP_LSEEK_ERROR(GetLastError());\n-            CloseHandle(file);\n-            return -1;\n-        }\n-    }\n+      if (_native_threads_only) {\n+        me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n+      }\n \n-    return (PROsfd)file;\n-}\n+      _PR_THREAD_LOCK(me);\n+      if (_PR_PENDING_INTERRUPT(me)) {\n+        me->flags &= ~_PR_INTERRUPT;\n+        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+        _PR_THREAD_UNLOCK(me);\n+        return -1;\n+      }\n+      me->io_pending = PR_TRUE;\n+      me->state = _PR_IO_WAIT;\n+      _PR_THREAD_UNLOCK(me);\n+      me->io_fd = f;\n \n-PRInt32\n-_PR_MD_READ(PRFileDesc* fd, void* buf, PRInt32 len)\n-{\n-    PROsfd f = fd->secret->md.osfd;\n-    PRUint32 bytes;\n-    int rv, err;\n-    LONG hiOffset = 0;\n-    LONG loOffset;\n-    LARGE_INTEGER offset; /* use for a normalized add of len to offset */\n-\n-    if (!fd->secret->md.sync_file_io) {\n-        PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-        if (me->io_suspended) {\n-            PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-            return -1;\n+      rv = ReadFile((HANDLE)f, (LPVOID)buf, len, &bytes,\n+                    &me->md.overlapped.overlapped);\n+      if ((rv == 0) && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n+        _PR_THREAD_LOCK(me);\n+        me->io_pending = PR_FALSE;\n+        me->state = _PR_RUNNING;\n+        if (_PR_PENDING_INTERRUPT(me)) {\n+          me->flags &= ~_PR_INTERRUPT;\n+          PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+          _PR_THREAD_UNLOCK(me);\n+          return -1;\n         }\n+        _PR_THREAD_UNLOCK(me);\n \n-        memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n+        if (err == ERROR_HANDLE_EOF) {\n+          return 0;\n+        }\n+        _PR_MD_MAP_READ_ERROR(err);\n+        return -1;\n+      }\n \n-        me->md.overlapped.overlapped.Offset = SetFilePointer(\n-            (HANDLE)f, 0, &me->md.overlapped.overlapped.OffsetHigh, FILE_CURRENT);\n-        PR_ASSERT((me->md.overlapped.overlapped.Offset != 0xffffffff) ||\n-                  (GetLastError() == NO_ERROR));\n+      if (_native_threads_only && rv) {\n+        _native_thread_io_nowait(me, rv, bytes);\n+      } else if (_NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n+        PR_ASSERT(0);\n+        return -1;\n+      }\n \n-        if (fd->secret->inheritable == _PR_TRI_TRUE) {\n-            rv = ReadFile((HANDLE)f, (LPVOID)buf, len, &bytes,\n-                          &me->md.overlapped.overlapped);\n-            if (rv != 0) {\n-                loOffset = SetFilePointer((HANDLE)f, bytes, &hiOffset, FILE_CURRENT);\n-                PR_ASSERT((loOffset != 0xffffffff) || (GetLastError() == NO_ERROR));\n-                return bytes;\n-            }\n-            err = GetLastError();\n-            if (err == ERROR_IO_PENDING) {\n-                rv = GetOverlappedResult((HANDLE)f, &me->md.overlapped.overlapped,\n-                                         &bytes, TRUE);\n-                if (rv != 0) {\n-                    loOffset = SetFilePointer((HANDLE)f, bytes, &hiOffset, FILE_CURRENT);\n-                    PR_ASSERT((loOffset != 0xffffffff) || (GetLastError() == NO_ERROR));\n-                    return bytes;\n-                }\n-                err = GetLastError();\n-            }\n-            if (err == ERROR_HANDLE_EOF) {\n-                return 0;\n-            } else {\n-                _PR_MD_MAP_READ_ERROR(err);\n-                return -1;\n-            }\n+      PR_ASSERT(me->io_pending == PR_FALSE || me->io_suspended == PR_TRUE);\n+\n+      if (me->io_suspended) {\n+        if (_PR_PENDING_INTERRUPT(me)) {\n+          me->flags &= ~_PR_INTERRUPT;\n+          PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n         } else {\n-            if (!fd->secret->md.io_model_committed) {\n-                rv = _md_Associate((HANDLE)f);\n-                PR_ASSERT(rv != 0);\n-                fd->secret->md.io_model_committed = PR_TRUE;\n-            }\n+          PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+        }\n+        return -1;\n+      }\n \n-            if (_native_threads_only) {\n-                me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n-            }\n+      if (me->md.blocked_io_status == 0) {\n+        if (me->md.blocked_io_error == ERROR_HANDLE_EOF) {\n+          return 0;\n+        }\n+        _PR_MD_MAP_READ_ERROR(me->md.blocked_io_error);\n+        return -1;\n+      }\n \n-            _PR_THREAD_LOCK(me);\n-            if (_PR_PENDING_INTERRUPT(me)) {\n-                me->flags &= ~_PR_INTERRUPT;\n-                PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                _PR_THREAD_UNLOCK(me);\n-                return -1;\n-            }\n-            me->io_pending = PR_TRUE;\n-            me->state = _PR_IO_WAIT;\n-            _PR_THREAD_UNLOCK(me);\n-            me->io_fd = f;\n-\n-            rv = ReadFile((HANDLE)f, (LPVOID)buf, len, &bytes,\n-                          &me->md.overlapped.overlapped);\n-            if ((rv == 0) && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n-                _PR_THREAD_LOCK(me);\n-                me->io_pending = PR_FALSE;\n-                me->state = _PR_RUNNING;\n-                if (_PR_PENDING_INTERRUPT(me)) {\n-                    me->flags &= ~_PR_INTERRUPT;\n-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                    _PR_THREAD_UNLOCK(me);\n-                    return -1;\n-                }\n-                _PR_THREAD_UNLOCK(me);\n-\n-                if (err == ERROR_HANDLE_EOF) {\n-                    return 0;\n-                }\n-                _PR_MD_MAP_READ_ERROR(err);\n-                return -1;\n-            }\n+      /* Apply the workaround from bug 70765 (see _PR_MD_WRITE)\n+       * to the reading code, too. */\n \n-            if (_native_threads_only && rv) {\n-                _native_thread_io_nowait(me, rv, bytes);\n-            } else if (_NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n-                PR_ASSERT(0);\n-                return -1;\n-            }\n+      offset.LowPart = me->md.overlapped.overlapped.Offset;\n+      offset.HighPart = me->md.overlapped.overlapped.OffsetHigh;\n+      offset.QuadPart += me->md.blocked_io_bytes;\n \n-            PR_ASSERT(me->io_pending == PR_FALSE || me->io_suspended == PR_TRUE);\n+      SetFilePointer((HANDLE)f, offset.LowPart, &offset.HighPart, FILE_BEGIN);\n \n-            if (me->io_suspended) {\n-                if (_PR_PENDING_INTERRUPT(me)) {\n-                    me->flags &= ~_PR_INTERRUPT;\n-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                } else {\n-                    PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                }\n-                return -1;\n-            }\n+      PR_ASSERT(me->io_pending == PR_FALSE);\n \n-            if (me->md.blocked_io_status == 0) {\n-                if (me->md.blocked_io_error == ERROR_HANDLE_EOF) {\n-                    return 0;\n-                }\n-                _PR_MD_MAP_READ_ERROR(me->md.blocked_io_error);\n-                return -1;\n-            }\n+      return me->md.blocked_io_bytes;\n+    }\n+  } else {\n+    rv = ReadFile((HANDLE)f, (LPVOID)buf, len, &bytes, NULL);\n+    if (rv == 0) {\n+      err = GetLastError();\n+      /* ERROR_HANDLE_EOF can only be returned by async io */\n+      PR_ASSERT(err != ERROR_HANDLE_EOF);\n+      if (err == ERROR_BROKEN_PIPE) {\n+        /* The write end of the pipe has been closed. */\n+        return 0;\n+      }\n+      _PR_MD_MAP_READ_ERROR(err);\n+      return -1;\n+    }\n+    return bytes;\n+  }\n+}\n \n-            /* Apply the workaround from bug 70765 (see _PR_MD_WRITE)\n-             * to the reading code, too. */\n+PRInt32 _PR_MD_WRITE(PRFileDesc* fd, const void* buf, PRInt32 len) {\n+  PROsfd f = fd->secret->md.osfd;\n+  PRInt32 bytes;\n+  int rv, err;\n+  LONG hiOffset = 0;\n+  LONG loOffset;\n+  LARGE_INTEGER offset; /* use for the calculation of the new offset */\n \n-            offset.LowPart = me->md.overlapped.overlapped.Offset;\n-            offset.HighPart = me->md.overlapped.overlapped.OffsetHigh;\n-            offset.QuadPart += me->md.blocked_io_bytes;\n+  if (!fd->secret->md.sync_file_io) {\n+    PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-            SetFilePointer((HANDLE)f, offset.LowPart, &offset.HighPart, FILE_BEGIN);\n+    if (me->io_suspended) {\n+      PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+      return -1;\n+    }\n \n-            PR_ASSERT(me->io_pending == PR_FALSE);\n+    memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n \n-            return me->md.blocked_io_bytes;\n+    me->md.overlapped.overlapped.Offset = SetFilePointer(\n+        (HANDLE)f, 0, &me->md.overlapped.overlapped.OffsetHigh, FILE_CURRENT);\n+    PR_ASSERT((me->md.overlapped.overlapped.Offset != 0xffffffff) ||\n+              (GetLastError() == NO_ERROR));\n+\n+    if (fd->secret->inheritable == _PR_TRI_TRUE) {\n+      rv = WriteFile((HANDLE)f, (LPVOID)buf, len, &bytes,\n+                     &me->md.overlapped.overlapped);\n+      if (rv != 0) {\n+        loOffset = SetFilePointer((HANDLE)f, bytes, &hiOffset, FILE_CURRENT);\n+        PR_ASSERT((loOffset != 0xffffffff) || (GetLastError() == NO_ERROR));\n+        return bytes;\n+      }\n+      err = GetLastError();\n+      if (err == ERROR_IO_PENDING) {\n+        rv = GetOverlappedResult((HANDLE)f, &me->md.overlapped.overlapped,\n+                                 &bytes, TRUE);\n+        if (rv != 0) {\n+          loOffset = SetFilePointer((HANDLE)f, bytes, &hiOffset, FILE_CURRENT);\n+          PR_ASSERT((loOffset != 0xffffffff) || (GetLastError() == NO_ERROR));\n+          return bytes;\n         }\n+        err = GetLastError();\n+      }\n+      _PR_MD_MAP_READ_ERROR(err);\n+      return -1;\n     } else {\n-        rv = ReadFile((HANDLE)f, (LPVOID)buf, len, &bytes, NULL);\n-        if (rv == 0) {\n-            err = GetLastError();\n-            /* ERROR_HANDLE_EOF can only be returned by async io */\n-            PR_ASSERT(err != ERROR_HANDLE_EOF);\n-            if (err == ERROR_BROKEN_PIPE) {\n-                /* The write end of the pipe has been closed. */\n-                return 0;\n-            }\n-            _PR_MD_MAP_READ_ERROR(err);\n-            return -1;\n-        }\n-        return bytes;\n-    }\n-}\n+      if (!fd->secret->md.io_model_committed) {\n+        rv = _md_Associate((HANDLE)f);\n+        PR_ASSERT(rv != 0);\n+        fd->secret->md.io_model_committed = PR_TRUE;\n+      }\n+      if (_native_threads_only) {\n+        me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n+      }\n \n-PRInt32\n-_PR_MD_WRITE(PRFileDesc* fd, const void* buf, PRInt32 len)\n-{\n-    PROsfd f = fd->secret->md.osfd;\n-    PRInt32 bytes;\n-    int rv, err;\n-    LONG hiOffset = 0;\n-    LONG loOffset;\n-    LARGE_INTEGER offset; /* use for the calculation of the new offset */\n-\n-    if (!fd->secret->md.sync_file_io) {\n-        PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-        if (me->io_suspended) {\n-            PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-            return -1;\n+      _PR_THREAD_LOCK(me);\n+      if (_PR_PENDING_INTERRUPT(me)) {\n+        me->flags &= ~_PR_INTERRUPT;\n+        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+        _PR_THREAD_UNLOCK(me);\n+        return -1;\n+      }\n+      me->io_pending = PR_TRUE;\n+      me->state = _PR_IO_WAIT;\n+      _PR_THREAD_UNLOCK(me);\n+      me->io_fd = f;\n+\n+      rv = WriteFile((HANDLE)f, buf, len, &bytes,\n+                     &(me->md.overlapped.overlapped));\n+      if ((rv == 0) && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n+        _PR_THREAD_LOCK(me);\n+        me->io_pending = PR_FALSE;\n+        me->state = _PR_RUNNING;\n+        if (_PR_PENDING_INTERRUPT(me)) {\n+          me->flags &= ~_PR_INTERRUPT;\n+          PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+          _PR_THREAD_UNLOCK(me);\n+          return -1;\n         }\n+        _PR_THREAD_UNLOCK(me);\n \n-        memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n-\n-        me->md.overlapped.overlapped.Offset = SetFilePointer(\n-            (HANDLE)f, 0, &me->md.overlapped.overlapped.OffsetHigh, FILE_CURRENT);\n-        PR_ASSERT((me->md.overlapped.overlapped.Offset != 0xffffffff) ||\n-                  (GetLastError() == NO_ERROR));\n-\n-        if (fd->secret->inheritable == _PR_TRI_TRUE) {\n-            rv = WriteFile((HANDLE)f, (LPVOID)buf, len, &bytes,\n-                           &me->md.overlapped.overlapped);\n-            if (rv != 0) {\n-                loOffset = SetFilePointer((HANDLE)f, bytes, &hiOffset, FILE_CURRENT);\n-                PR_ASSERT((loOffset != 0xffffffff) || (GetLastError() == NO_ERROR));\n-                return bytes;\n-            }\n-            err = GetLastError();\n-            if (err == ERROR_IO_PENDING) {\n-                rv = GetOverlappedResult((HANDLE)f, &me->md.overlapped.overlapped,\n-                                         &bytes, TRUE);\n-                if (rv != 0) {\n-                    loOffset = SetFilePointer((HANDLE)f, bytes, &hiOffset, FILE_CURRENT);\n-                    PR_ASSERT((loOffset != 0xffffffff) || (GetLastError() == NO_ERROR));\n-                    return bytes;\n-                }\n-                err = GetLastError();\n-            }\n-            _PR_MD_MAP_READ_ERROR(err);\n-            return -1;\n-        } else {\n-            if (!fd->secret->md.io_model_committed) {\n-                rv = _md_Associate((HANDLE)f);\n-                PR_ASSERT(rv != 0);\n-                fd->secret->md.io_model_committed = PR_TRUE;\n-            }\n-            if (_native_threads_only) {\n-                me->md.overlapped.overlapped.hEvent = me->md.thr_event;\n-            }\n-\n-            _PR_THREAD_LOCK(me);\n-            if (_PR_PENDING_INTERRUPT(me)) {\n-                me->flags &= ~_PR_INTERRUPT;\n-                PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                _PR_THREAD_UNLOCK(me);\n-                return -1;\n-            }\n-            me->io_pending = PR_TRUE;\n-            me->state = _PR_IO_WAIT;\n-            _PR_THREAD_UNLOCK(me);\n-            me->io_fd = f;\n-\n-            rv = WriteFile((HANDLE)f, buf, len, &bytes,\n-                           &(me->md.overlapped.overlapped));\n-            if ((rv == 0) && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n-                _PR_THREAD_LOCK(me);\n-                me->io_pending = PR_FALSE;\n-                me->state = _PR_RUNNING;\n-                if (_PR_PENDING_INTERRUPT(me)) {\n-                    me->flags &= ~_PR_INTERRUPT;\n-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                    _PR_THREAD_UNLOCK(me);\n-                    return -1;\n-                }\n-                _PR_THREAD_UNLOCK(me);\n-\n-                _PR_MD_MAP_WRITE_ERROR(err);\n-                return -1;\n-            }\n+        _PR_MD_MAP_WRITE_ERROR(err);\n+        return -1;\n+      }\n \n-            if (_native_threads_only && rv) {\n-                _native_thread_io_nowait(me, rv, bytes);\n-            } else if (_NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n-                PR_ASSERT(0);\n-                return -1;\n-            }\n+      if (_native_threads_only && rv) {\n+        _native_thread_io_nowait(me, rv, bytes);\n+      } else if (_NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n+        PR_ASSERT(0);\n+        return -1;\n+      }\n \n-            PR_ASSERT(me->io_pending == PR_FALSE || me->io_suspended == PR_TRUE);\n+      PR_ASSERT(me->io_pending == PR_FALSE || me->io_suspended == PR_TRUE);\n \n-            if (me->io_suspended) {\n-                if (_PR_PENDING_INTERRUPT(me)) {\n-                    me->flags &= ~_PR_INTERRUPT;\n-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                } else {\n-                    PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                }\n-                return -1;\n-            }\n+      if (me->io_suspended) {\n+        if (_PR_PENDING_INTERRUPT(me)) {\n+          me->flags &= ~_PR_INTERRUPT;\n+          PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+        } else {\n+          PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+        }\n+        return -1;\n+      }\n \n-            if (me->md.blocked_io_status == 0) {\n-                _PR_MD_MAP_WRITE_ERROR(me->md.blocked_io_error);\n-                return -1;\n-            }\n+      if (me->md.blocked_io_status == 0) {\n+        _PR_MD_MAP_WRITE_ERROR(me->md.blocked_io_error);\n+        return -1;\n+      }\n \n-            /*\n-             * Moving the file pointer by a relative offset (FILE_CURRENT)\n-             * does not work with a file on a network drive exported by a\n-             * Win2K system.  We still don't know why.  A workaround is to\n-             * move the file pointer by an absolute offset (FILE_BEGIN).\n-             * (Bugzilla bug 70765)\n-             */\n-            offset.LowPart = me->md.overlapped.overlapped.Offset;\n-            offset.HighPart = me->md.overlapped.overlapped.OffsetHigh;\n-            offset.QuadPart += me->md.blocked_io_bytes;\n+      /*\n+       * Moving the file pointer by a relative offset (FILE_CURRENT)\n+       * does not work with a file on a network drive exported by a\n+       * Win2K system.  We still don't know why.  A workaround is to\n+       * move the file pointer by an absolute offset (FILE_BEGIN).\n+       * (Bugzilla bug 70765)\n+       */\n+      offset.LowPart = me->md.overlapped.overlapped.Offset;\n+      offset.HighPart = me->md.overlapped.overlapped.OffsetHigh;\n+      offset.QuadPart += me->md.blocked_io_bytes;\n \n-            SetFilePointer((HANDLE)f, offset.LowPart, &offset.HighPart, FILE_BEGIN);\n+      SetFilePointer((HANDLE)f, offset.LowPart, &offset.HighPart, FILE_BEGIN);\n \n-            PR_ASSERT(me->io_pending == PR_FALSE);\n+      PR_ASSERT(me->io_pending == PR_FALSE);\n \n-            return me->md.blocked_io_bytes;\n-        }\n-    } else {\n-        rv = WriteFile((HANDLE)f, buf, len, &bytes, NULL);\n-        if (rv == 0) {\n-            _PR_MD_MAP_WRITE_ERROR(GetLastError());\n-            return -1;\n-        }\n-        return bytes;\n+      return me->md.blocked_io_bytes;\n     }\n-}\n-\n-PRInt32\n-_PR_MD_SOCKETAVAILABLE(PRFileDesc* fd)\n-{\n-    PRInt32 result;\n-\n-    if (ioctlsocket(fd->secret->md.osfd, FIONREAD, &result) < 0) {\n-        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, WSAGetLastError());\n-        return -1;\n+  } else {\n+    rv = WriteFile((HANDLE)f, buf, len, &bytes, NULL);\n+    if (rv == 0) {\n+      _PR_MD_MAP_WRITE_ERROR(GetLastError());\n+      return -1;\n     }\n-    return result;\n+    return bytes;\n+  }\n }\n \n-PRInt32\n-_PR_MD_PIPEAVAILABLE(PRFileDesc* fd)\n-{\n-    if (NULL == fd) {\n-        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n-    } else {\n-        PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    }\n+PRInt32 _PR_MD_SOCKETAVAILABLE(PRFileDesc* fd) {\n+  PRInt32 result;\n+\n+  if (ioctlsocket(fd->secret->md.osfd, FIONREAD, &result) < 0) {\n+    PR_SetError(PR_BAD_DESCRIPTOR_ERROR, WSAGetLastError());\n     return -1;\n+  }\n+  return result;\n }\n \n-PROffset32\n-_PR_MD_LSEEK(PRFileDesc* fd, PROffset32 offset,\n-             PRSeekWhence whence)\n-{\n-    DWORD moveMethod;\n-    PROffset32 rv;\n-\n-    switch (whence) {\n-        case PR_SEEK_SET:\n-            moveMethod = FILE_BEGIN;\n-            break;\n-        case PR_SEEK_CUR:\n-            moveMethod = FILE_CURRENT;\n-            break;\n-        case PR_SEEK_END:\n-            moveMethod = FILE_END;\n-            break;\n-        default:\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            return -1;\n-    }\n-\n-    rv = SetFilePointer((HANDLE)fd->secret->md.osfd, offset, NULL, moveMethod);\n-\n-    /*\n-     * If the lpDistanceToMoveHigh argument (third argument) is\n-     * NULL, SetFilePointer returns 0xffffffff on failure.\n-     */\n-    if (-1 == rv) {\n-        _PR_MD_MAP_LSEEK_ERROR(GetLastError());\n-    }\n-    return rv;\n+PRInt32 _PR_MD_PIPEAVAILABLE(PRFileDesc* fd) {\n+  if (NULL == fd) {\n+    PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n+  } else {\n+    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  }\n+  return -1;\n }\n \n-PROffset64\n-_PR_MD_LSEEK64(PRFileDesc* fd, PROffset64 offset,\n-               PRSeekWhence whence)\n-{\n-    DWORD moveMethod;\n-    LARGE_INTEGER li;\n-    DWORD err;\n-\n-    switch (whence) {\n-        case PR_SEEK_SET:\n-            moveMethod = FILE_BEGIN;\n-            break;\n-        case PR_SEEK_CUR:\n-            moveMethod = FILE_CURRENT;\n-            break;\n-        case PR_SEEK_END:\n-            moveMethod = FILE_END;\n-            break;\n-        default:\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            return -1;\n-    }\n-\n-    li.QuadPart = offset;\n-    li.LowPart = SetFilePointer((HANDLE)fd->secret->md.osfd, li.LowPart,\n-                                &li.HighPart, moveMethod);\n+PROffset32 _PR_MD_LSEEK(PRFileDesc* fd, PROffset32 offset,\n+                        PRSeekWhence whence) {\n+  DWORD moveMethod;\n+  PROffset32 rv;\n+\n+  switch (whence) {\n+    case PR_SEEK_SET:\n+      moveMethod = FILE_BEGIN;\n+      break;\n+    case PR_SEEK_CUR:\n+      moveMethod = FILE_CURRENT;\n+      break;\n+    case PR_SEEK_END:\n+      moveMethod = FILE_END;\n+      break;\n+    default:\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      return -1;\n+  }\n+\n+  rv = SetFilePointer((HANDLE)fd->secret->md.osfd, offset, NULL, moveMethod);\n+\n+  /*\n+   * If the lpDistanceToMoveHigh argument (third argument) is\n+   * NULL, SetFilePointer returns 0xffffffff on failure.\n+   */\n+  if (-1 == rv) {\n+    _PR_MD_MAP_LSEEK_ERROR(GetLastError());\n+  }\n+  return rv;\n+}\n \n-    if (0xffffffff == li.LowPart && (err = GetLastError()) != NO_ERROR) {\n-        _PR_MD_MAP_LSEEK_ERROR(err);\n-        li.QuadPart = -1;\n-    }\n-    return li.QuadPart;\n+PROffset64 _PR_MD_LSEEK64(PRFileDesc* fd, PROffset64 offset,\n+                          PRSeekWhence whence) {\n+  DWORD moveMethod;\n+  LARGE_INTEGER li;\n+  DWORD err;\n+\n+  switch (whence) {\n+    case PR_SEEK_SET:\n+      moveMethod = FILE_BEGIN;\n+      break;\n+    case PR_SEEK_CUR:\n+      moveMethod = FILE_CURRENT;\n+      break;\n+    case PR_SEEK_END:\n+      moveMethod = FILE_END;\n+      break;\n+    default:\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      return -1;\n+  }\n+\n+  li.QuadPart = offset;\n+  li.LowPart = SetFilePointer((HANDLE)fd->secret->md.osfd, li.LowPart,\n+                              &li.HighPart, moveMethod);\n+\n+  if (0xffffffff == li.LowPart && (err = GetLastError()) != NO_ERROR) {\n+    _PR_MD_MAP_LSEEK_ERROR(err);\n+    li.QuadPart = -1;\n+  }\n+  return li.QuadPart;\n }\n \n /*\n@@ -2551,153 +2467,141 @@ _PR_MD_LSEEK64(PRFileDesc* fd, PROffset64 offset,\n  * case.  So we only signal an error if the error is *not* \"access\n  * denied\".\n  */\n-PRInt32\n-_PR_MD_FSYNC(PRFileDesc* fd)\n-{\n-    /*\n-     * From the documentation:\n-     *\n-     *     On Windows NT, the function FlushFileBuffers fails if hFile\n-     *     is a handle to console output. That is because console\n-     *     output is not buffered. The function returns FALSE, and\n-     *     GetLastError returns ERROR_INVALID_HANDLE.\n-     *\n-     * On the other hand, on Win95, it returns without error.  I cannot\n-     * assume that 0, 1, and 2 are console, because if someone closes\n-     * System.out and then opens a file, they might get file descriptor\n-     * 1.  An error on *that* version of 1 should be reported, whereas\n-     * an error on System.out (which was the original 1) should be\n-     * ignored.  So I use isatty() to ensure that such an error was\n-     * because of this, and if it was, I ignore the error.\n-     */\n-\n-    BOOL ok = FlushFileBuffers((HANDLE)fd->secret->md.osfd);\n-\n-    if (!ok) {\n-        DWORD err = GetLastError();\n-\n-        if (err != ERROR_ACCESS_DENIED) { /* from winerror.h */\n-            _PR_MD_MAP_FSYNC_ERROR(err);\n-            return -1;\n-        }\n-    }\n-    return 0;\n+PRInt32 _PR_MD_FSYNC(PRFileDesc* fd) {\n+  /*\n+   * From the documentation:\n+   *\n+   *     On Windows NT, the function FlushFileBuffers fails if hFile\n+   *     is a handle to console output. That is because console\n+   *     output is not buffered. The function returns FALSE, and\n+   *     GetLastError returns ERROR_INVALID_HANDLE.\n+   *\n+   * On the other hand, on Win95, it returns without error.  I cannot\n+   * assume that 0, 1, and 2 are console, because if someone closes\n+   * System.out and then opens a file, they might get file descriptor\n+   * 1.  An error on *that* version of 1 should be reported, whereas\n+   * an error on System.out (which was the original 1) should be\n+   * ignored.  So I use isatty() to ensure that such an error was\n+   * because of this, and if it was, I ignore the error.\n+   */\n+\n+  BOOL ok = FlushFileBuffers((HANDLE)fd->secret->md.osfd);\n+\n+  if (!ok) {\n+    DWORD err = GetLastError();\n+\n+    if (err != ERROR_ACCESS_DENIED) { /* from winerror.h */\n+      _PR_MD_MAP_FSYNC_ERROR(err);\n+      return -1;\n+    }\n+  }\n+  return 0;\n }\n \n-PRInt32\n-_PR_MD_CLOSE(PROsfd osfd, PRBool socket)\n-{\n-    PRInt32 rv;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+PRInt32 _PR_MD_CLOSE(PROsfd osfd, PRBool socket) {\n+  PRInt32 rv;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    if (socket) {\n-        rv = closesocket((SOCKET)osfd);\n-        if (rv < 0) {\n-            _PR_MD_MAP_CLOSE_ERROR(WSAGetLastError());\n-        }\n-    } else {\n-        rv = CloseHandle((HANDLE)osfd) ? 0 : -1;\n-        if (rv < 0) {\n-            _PR_MD_MAP_CLOSE_ERROR(GetLastError());\n-        }\n-    }\n-\n-    if (rv == 0 && me->io_suspended) {\n-        if (me->io_fd == osfd) {\n-            PRBool fWait;\n-\n-            _PR_THREAD_LOCK(me);\n-            me->state = _PR_IO_WAIT;\n-            /* The IO could have completed on another thread just after\n-             * calling closesocket while the io_suspended flag was true.\n-             * So we now grab the lock to do a safe check on io_pending to\n-             * see if we need to wait or not.\n-             */\n-            fWait = me->io_pending;\n-            me->io_suspended = PR_FALSE;\n-            me->md.interrupt_disabled = PR_TRUE;\n-            _PR_THREAD_UNLOCK(me);\n-\n-            if (fWait) {\n-                _NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT);\n-            }\n-            PR_ASSERT(me->io_suspended == PR_FALSE);\n-            PR_ASSERT(me->io_pending == PR_FALSE);\n-            /*\n-             * I/O operation is no longer pending; the thread can now\n-             * run on any cpu\n-             */\n-            _PR_THREAD_LOCK(me);\n-            me->md.interrupt_disabled = PR_FALSE;\n-            me->md.thr_bound_cpu = NULL;\n-            me->io_suspended = PR_FALSE;\n-            me->io_pending = PR_FALSE;\n-            me->state = _PR_RUNNING;\n-            _PR_THREAD_UNLOCK(me);\n-        }\n+  if (socket) {\n+    rv = closesocket((SOCKET)osfd);\n+    if (rv < 0) {\n+      _PR_MD_MAP_CLOSE_ERROR(WSAGetLastError());\n     }\n-    return rv;\n+  } else {\n+    rv = CloseHandle((HANDLE)osfd) ? 0 : -1;\n+    if (rv < 0) {\n+      _PR_MD_MAP_CLOSE_ERROR(GetLastError());\n+    }\n+  }\n+\n+  if (rv == 0 && me->io_suspended) {\n+    if (me->io_fd == osfd) {\n+      PRBool fWait;\n+\n+      _PR_THREAD_LOCK(me);\n+      me->state = _PR_IO_WAIT;\n+      /* The IO could have completed on another thread just after\n+       * calling closesocket while the io_suspended flag was true.\n+       * So we now grab the lock to do a safe check on io_pending to\n+       * see if we need to wait or not.\n+       */\n+      fWait = me->io_pending;\n+      me->io_suspended = PR_FALSE;\n+      me->md.interrupt_disabled = PR_TRUE;\n+      _PR_THREAD_UNLOCK(me);\n+\n+      if (fWait) {\n+        _NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT);\n+      }\n+      PR_ASSERT(me->io_suspended == PR_FALSE);\n+      PR_ASSERT(me->io_pending == PR_FALSE);\n+      /*\n+       * I/O operation is no longer pending; the thread can now\n+       * run on any cpu\n+       */\n+      _PR_THREAD_LOCK(me);\n+      me->md.interrupt_disabled = PR_FALSE;\n+      me->md.thr_bound_cpu = NULL;\n+      me->io_suspended = PR_FALSE;\n+      me->io_pending = PR_FALSE;\n+      me->state = _PR_RUNNING;\n+      _PR_THREAD_UNLOCK(me);\n+    }\n+  }\n+  return rv;\n }\n \n-PRStatus\n-_PR_MD_SET_FD_INHERITABLE(PRFileDesc* fd, PRBool inheritable)\n-{\n-    BOOL rv;\n+PRStatus _PR_MD_SET_FD_INHERITABLE(PRFileDesc* fd, PRBool inheritable) {\n+  BOOL rv;\n \n-    if (fd->secret->md.io_model_committed) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    rv = SetHandleInformation((HANDLE)fd->secret->md.osfd, HANDLE_FLAG_INHERIT,\n-                              inheritable ? HANDLE_FLAG_INHERIT : 0);\n-    if (0 == rv) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  if (fd->secret->md.io_model_committed) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  rv = SetHandleInformation((HANDLE)fd->secret->md.osfd, HANDLE_FLAG_INHERIT,\n+                            inheritable ? HANDLE_FLAG_INHERIT : 0);\n+  if (0 == rv) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-void\n-_PR_MD_INIT_FD_INHERITABLE(PRFileDesc* fd, PRBool imported)\n-{\n-    if (imported) {\n-        fd->secret->inheritable = _PR_TRI_UNKNOWN;\n-    } else {\n-        fd->secret->inheritable = _PR_TRI_FALSE;\n-    }\n+void _PR_MD_INIT_FD_INHERITABLE(PRFileDesc* fd, PRBool imported) {\n+  if (imported) {\n+    fd->secret->inheritable = _PR_TRI_UNKNOWN;\n+  } else {\n+    fd->secret->inheritable = _PR_TRI_FALSE;\n+  }\n }\n \n-void\n-_PR_MD_QUERY_FD_INHERITABLE(PRFileDesc* fd)\n-{\n-    DWORD flags;\n+void _PR_MD_QUERY_FD_INHERITABLE(PRFileDesc* fd) {\n+  DWORD flags;\n \n-    PR_ASSERT(_PR_TRI_UNKNOWN == fd->secret->inheritable);\n-    if (fd->secret->md.io_model_committed) {\n-        return;\n-    }\n-    if (GetHandleInformation((HANDLE)fd->secret->md.osfd, &flags)) {\n-        if (flags & HANDLE_FLAG_INHERIT) {\n-            fd->secret->inheritable = _PR_TRI_TRUE;\n-        } else {\n-            fd->secret->inheritable = _PR_TRI_FALSE;\n-        }\n+  PR_ASSERT(_PR_TRI_UNKNOWN == fd->secret->inheritable);\n+  if (fd->secret->md.io_model_committed) {\n+    return;\n+  }\n+  if (GetHandleInformation((HANDLE)fd->secret->md.osfd, &flags)) {\n+    if (flags & HANDLE_FLAG_INHERIT) {\n+      fd->secret->inheritable = _PR_TRI_TRUE;\n+    } else {\n+      fd->secret->inheritable = _PR_TRI_FALSE;\n     }\n+  }\n }\n \n /* --- DIR IO ------------------------------------------------------------ */\n #define GetFileFromDIR(d) (d)->d_entry.cFileName\n #define FileIsHidden(d) ((d)->d_entry.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)\n \n-void\n-FlipSlashes(char* cp, int len)\n-{\n-    while (--len >= 0) {\n-        if (cp[0] == '/') {\n-            cp[0] = PR_DIRECTORY_SEPARATOR;\n-        }\n-        cp = _mbsinc(cp);\n+void FlipSlashes(char* cp, int len) {\n+  while (--len >= 0) {\n+    if (cp[0] == '/') {\n+      cp[0] = PR_DIRECTORY_SEPARATOR;\n     }\n+    cp = _mbsinc(cp);\n+  }\n } /* end FlipSlashes() */\n \n /*\n@@ -2707,206 +2611,192 @@ FlipSlashes(char* cp, int len)\n **\n */\n \n-PRInt32\n-_PR_MD_CLOSE_DIR(_MDDir* d)\n-{\n-    if (d) {\n-        if (FindClose(d->d_hdl)) {\n-            d->magic = (PRUint32)-1;\n-            return 0;\n-        } else {\n-            _PR_MD_MAP_CLOSEDIR_ERROR(GetLastError());\n-            return -1;\n-        }\n+PRInt32 _PR_MD_CLOSE_DIR(_MDDir* d) {\n+  if (d) {\n+    if (FindClose(d->d_hdl)) {\n+      d->magic = (PRUint32)-1;\n+      return 0;\n+    } else {\n+      _PR_MD_MAP_CLOSEDIR_ERROR(GetLastError());\n+      return -1;\n     }\n-    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-    return -1;\n+  }\n+  PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  return -1;\n }\n \n-PRStatus\n-_PR_MD_OPEN_DIR(_MDDir* d, const char* name)\n-{\n-    char filename[MAX_PATH];\n-    int len;\n-\n-    len = strlen(name);\n-    /* Need 5 bytes for \\*.* and the trailing null byte. */\n-    if (len + 5 > MAX_PATH) {\n-        PR_SetError(PR_NAME_TOO_LONG_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    strcpy(filename, name);\n-\n-    /*\n-     * If 'name' ends in a slash or backslash, do not append\n-     * another backslash.\n-     */\n-    if (IsPrevCharSlash(filename, filename + len)) {\n-        len--;\n-    }\n-    strcpy(&filename[len], \"\\\\*.*\");\n-    FlipSlashes(filename, strlen(filename));\n-\n-    d->d_hdl = FindFirstFile(filename, &(d->d_entry));\n-    if (d->d_hdl == INVALID_HANDLE_VALUE) {\n-        _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n-        return PR_FAILURE;\n-    }\n-    d->firstEntry = PR_TRUE;\n-    d->magic = _MD_MAGIC_DIR;\n-    return PR_SUCCESS;\n+PRStatus _PR_MD_OPEN_DIR(_MDDir* d, const char* name) {\n+  char filename[MAX_PATH];\n+  int len;\n+\n+  len = strlen(name);\n+  /* Need 5 bytes for \\*.* and the trailing null byte. */\n+  if (len + 5 > MAX_PATH) {\n+    PR_SetError(PR_NAME_TOO_LONG_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  strcpy(filename, name);\n+\n+  /*\n+   * If 'name' ends in a slash or backslash, do not append\n+   * another backslash.\n+   */\n+  if (IsPrevCharSlash(filename, filename + len)) {\n+    len--;\n+  }\n+  strcpy(&filename[len], \"\\\\*.*\");\n+  FlipSlashes(filename, strlen(filename));\n+\n+  d->d_hdl = FindFirstFile(filename, &(d->d_entry));\n+  if (d->d_hdl == INVALID_HANDLE_VALUE) {\n+    _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n+    return PR_FAILURE;\n+  }\n+  d->firstEntry = PR_TRUE;\n+  d->magic = _MD_MAGIC_DIR;\n+  return PR_SUCCESS;\n }\n \n-char*\n-_PR_MD_READ_DIR(_MDDir* d, PRIntn flags)\n-{\n-    PRInt32 err;\n-    BOOL rv;\n-    char* fileName;\n+char* _PR_MD_READ_DIR(_MDDir* d, PRIntn flags) {\n+  PRInt32 err;\n+  BOOL rv;\n+  char* fileName;\n \n-    if (d) {\n-        while (1) {\n-            if (d->firstEntry) {\n-                d->firstEntry = PR_FALSE;\n-                rv = 1;\n-            } else {\n-                rv = FindNextFile(d->d_hdl, &(d->d_entry));\n-            }\n-            if (rv == 0) {\n-                break;\n-            }\n-            fileName = GetFileFromDIR(d);\n-            if ((flags & PR_SKIP_DOT) && (fileName[0] == '.') &&\n-                (fileName[1] == '\\0')) {\n-                continue;\n-            }\n-            if ((flags & PR_SKIP_DOT_DOT) && (fileName[0] == '.') &&\n-                (fileName[1] == '.') && (fileName[2] == '\\0')) {\n-                continue;\n-            }\n-            if ((flags & PR_SKIP_HIDDEN) && FileIsHidden(d)) {\n-                continue;\n-            }\n-            return fileName;\n-        }\n-        err = GetLastError();\n-        PR_ASSERT(NO_ERROR != err);\n-        _PR_MD_MAP_READDIR_ERROR(err);\n-        return NULL;\n-    }\n-    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  if (d) {\n+    while (1) {\n+      if (d->firstEntry) {\n+        d->firstEntry = PR_FALSE;\n+        rv = 1;\n+      } else {\n+        rv = FindNextFile(d->d_hdl, &(d->d_entry));\n+      }\n+      if (rv == 0) {\n+        break;\n+      }\n+      fileName = GetFileFromDIR(d);\n+      if ((flags & PR_SKIP_DOT) && (fileName[0] == '.') &&\n+          (fileName[1] == '\\0')) {\n+        continue;\n+      }\n+      if ((flags & PR_SKIP_DOT_DOT) && (fileName[0] == '.') &&\n+          (fileName[1] == '.') && (fileName[2] == '\\0')) {\n+        continue;\n+      }\n+      if ((flags & PR_SKIP_HIDDEN) && FileIsHidden(d)) {\n+        continue;\n+      }\n+      return fileName;\n+    }\n+    err = GetLastError();\n+    PR_ASSERT(NO_ERROR != err);\n+    _PR_MD_MAP_READDIR_ERROR(err);\n     return NULL;\n+  }\n+  PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  return NULL;\n }\n \n-PRInt32\n-_PR_MD_DELETE(const char* name)\n-{\n-    if (DeleteFile(name)) {\n-        return 0;\n-    } else {\n-        _PR_MD_MAP_DELETE_ERROR(GetLastError());\n-        return -1;\n-    }\n+PRInt32 _PR_MD_DELETE(const char* name) {\n+  if (DeleteFile(name)) {\n+    return 0;\n+  } else {\n+    _PR_MD_MAP_DELETE_ERROR(GetLastError());\n+    return -1;\n+  }\n }\n \n-void\n-_PR_FileTimeToPRTime(const FILETIME* filetime, PRTime* prtm)\n-{\n-    PR_ASSERT(sizeof(FILETIME) == sizeof(PRTime));\n-    CopyMemory(prtm, filetime, sizeof(PRTime));\n+void _PR_FileTimeToPRTime(const FILETIME* filetime, PRTime* prtm) {\n+  PR_ASSERT(sizeof(FILETIME) == sizeof(PRTime));\n+  CopyMemory(prtm, filetime, sizeof(PRTime));\n #ifdef __GNUC__\n-    *prtm = (*prtm - _pr_filetime_offset) / 10LL;\n+  *prtm = (*prtm - _pr_filetime_offset) / 10LL;\n #else\n-    *prtm = (*prtm - _pr_filetime_offset) / 10i64;\n+  *prtm = (*prtm - _pr_filetime_offset) / 10i64;\n #endif\n \n #ifdef DEBUG\n-    /* Doublecheck our calculation. */\n-    {\n-        SYSTEMTIME systime;\n-        PRExplodedTime etm;\n-        PRTime cmp; /* for comparison */\n-        BOOL rv;\n+  /* Doublecheck our calculation. */\n+  {\n+    SYSTEMTIME systime;\n+    PRExplodedTime etm;\n+    PRTime cmp; /* for comparison */\n+    BOOL rv;\n \n-        rv = FileTimeToSystemTime(filetime, &systime);\n-        PR_ASSERT(0 != rv);\n+    rv = FileTimeToSystemTime(filetime, &systime);\n+    PR_ASSERT(0 != rv);\n \n-        /*\n-         * PR_ImplodeTime ignores wday and yday.\n-         */\n-        etm.tm_usec = systime.wMilliseconds * PR_USEC_PER_MSEC;\n-        etm.tm_sec = systime.wSecond;\n-        etm.tm_min = systime.wMinute;\n-        etm.tm_hour = systime.wHour;\n-        etm.tm_mday = systime.wDay;\n-        etm.tm_month = systime.wMonth - 1;\n-        etm.tm_year = systime.wYear;\n-        /*\n-         * It is not well-documented what time zone the FILETIME's\n-         * are in.  WIN32_FIND_DATA is documented to be in UTC (GMT).\n-         * But BY_HANDLE_FILE_INFORMATION is unclear about this.\n-         * By our best judgement, we assume that FILETIME is in UTC.\n-         */\n-        etm.tm_params.tp_gmt_offset = 0;\n-        etm.tm_params.tp_dst_offset = 0;\n-        cmp = PR_ImplodeTime(&etm);\n+    /*\n+     * PR_ImplodeTime ignores wday and yday.\n+     */\n+    etm.tm_usec = systime.wMilliseconds * PR_USEC_PER_MSEC;\n+    etm.tm_sec = systime.wSecond;\n+    etm.tm_min = systime.wMinute;\n+    etm.tm_hour = systime.wHour;\n+    etm.tm_mday = systime.wDay;\n+    etm.tm_month = systime.wMonth - 1;\n+    etm.tm_year = systime.wYear;\n+    /*\n+     * It is not well-documented what time zone the FILETIME's\n+     * are in.  WIN32_FIND_DATA is documented to be in UTC (GMT).\n+     * But BY_HANDLE_FILE_INFORMATION is unclear about this.\n+     * By our best judgement, we assume that FILETIME is in UTC.\n+     */\n+    etm.tm_params.tp_gmt_offset = 0;\n+    etm.tm_params.tp_dst_offset = 0;\n+    cmp = PR_ImplodeTime(&etm);\n \n-        /*\n-         * SYSTEMTIME is in milliseconds precision, so we convert PRTime's\n-         * microseconds to milliseconds before doing the comparison.\n-         */\n-        PR_ASSERT((cmp / PR_USEC_PER_MSEC) == (*prtm / PR_USEC_PER_MSEC));\n-    }\n+    /*\n+     * SYSTEMTIME is in milliseconds precision, so we convert PRTime's\n+     * microseconds to milliseconds before doing the comparison.\n+     */\n+    PR_ASSERT((cmp / PR_USEC_PER_MSEC) == (*prtm / PR_USEC_PER_MSEC));\n+  }\n #endif /* DEBUG */\n }\n \n-PRInt32\n-_PR_MD_STAT(const char* fn, struct stat* info)\n-{\n-    PRInt32 rv;\n+PRInt32 _PR_MD_STAT(const char* fn, struct stat* info) {\n+  PRInt32 rv;\n \n-    rv = _stat(fn, (struct _stat*)info);\n-    if (-1 == rv) {\n-        /*\n-         * Check for MSVC runtime library _stat() bug.\n-         * (It's really a bug in FindFirstFile().)\n-         * If a pathname ends in a backslash or slash,\n-         * e.g., c:\\temp\\ or c:/temp/, _stat() will fail.\n-         * Note: a pathname ending in a slash (e.g., c:/temp/)\n-         * can be handled by _stat() on NT but not on Win95.\n-         *\n-         * We remove the backslash or slash at the end and\n-         * try again.\n-         */\n+  rv = _stat(fn, (struct _stat*)info);\n+  if (-1 == rv) {\n+    /*\n+     * Check for MSVC runtime library _stat() bug.\n+     * (It's really a bug in FindFirstFile().)\n+     * If a pathname ends in a backslash or slash,\n+     * e.g., c:\\temp\\ or c:/temp/, _stat() will fail.\n+     * Note: a pathname ending in a slash (e.g., c:/temp/)\n+     * can be handled by _stat() on NT but not on Win95.\n+     *\n+     * We remove the backslash or slash at the end and\n+     * try again.\n+     */\n \n-        int len = strlen(fn);\n-        if (len > 0 && len <= _MAX_PATH && IsPrevCharSlash(fn, fn + len)) {\n-            char newfn[_MAX_PATH + 1];\n+    int len = strlen(fn);\n+    if (len > 0 && len <= _MAX_PATH && IsPrevCharSlash(fn, fn + len)) {\n+      char newfn[_MAX_PATH + 1];\n \n-            strcpy(newfn, fn);\n-            newfn[len - 1] = '\\0';\n-            rv = _stat(newfn, (struct _stat*)info);\n-        }\n+      strcpy(newfn, fn);\n+      newfn[len - 1] = '\\0';\n+      rv = _stat(newfn, (struct _stat*)info);\n     }\n+  }\n \n-    if (-1 == rv) {\n-        _PR_MD_MAP_STAT_ERROR(errno);\n-    }\n-    return rv;\n+  if (-1 == rv) {\n+    _PR_MD_MAP_STAT_ERROR(errno);\n+  }\n+  return rv;\n }\n \n #define _PR_IS_SLASH(ch) ((ch) == '/' || (ch) == '\\\\')\n \n-static PRBool\n-IsPrevCharSlash(const char* str, const char* current)\n-{\n-    const char* prev;\n+static PRBool IsPrevCharSlash(const char* str, const char* current) {\n+  const char* prev;\n \n-    if (str >= current) {\n-        return PR_FALSE;\n-    }\n-    prev = _mbsdec(str, current);\n-    return (prev == current - 1) && _PR_IS_SLASH(*prev);\n+  if (str >= current) {\n+    return PR_FALSE;\n+  }\n+  prev = _mbsdec(str, current);\n+  return (prev == current - 1) && _PR_IS_SLASH(*prev);\n }\n \n /*\n@@ -2921,535 +2811,506 @@ IsPrevCharSlash(const char* str, const char* current)\n  *\n  * Root directories come in three formats:\n  * 1. / or \\, meaning the root directory of the current drive.\n- * 2. C:/ or C:\\, where C is a drive letter.\n- * 3. \\\\<server name>\\<share point name>\\ or\n- *    \\\\<server name>\\<share point name>, meaning the root directory\n- *    of a UNC (Universal Naming Convention) name.\n- */\n-\n-static PRBool\n-IsRootDirectory(char* fn, size_t buflen)\n-{\n-    char* p;\n-    PRBool slashAdded = PR_FALSE;\n-    PRBool rv = PR_FALSE;\n-\n-    if (_PR_IS_SLASH(fn[0]) && fn[1] == '\\0') {\n-        return PR_TRUE;\n-    }\n-\n-    if (isalpha((unsigned char)fn[0]) && fn[1] == ':' && _PR_IS_SLASH(fn[2]) &&\n-        fn[3] == '\\0') {\n-        rv = GetDriveType(fn) > 1 ? PR_TRUE : PR_FALSE;\n-        return rv;\n-    }\n-\n-    /* The UNC root directory */\n-\n-    if (_PR_IS_SLASH(fn[0]) && _PR_IS_SLASH(fn[1])) {\n-        /* The 'server' part should have at least one character. */\n-        p = &fn[2];\n-        if (*p == '\\0' || _PR_IS_SLASH(*p)) {\n-            return PR_FALSE;\n-        }\n+ * 2. C:/ or C:\\, where C is a drive letter.\n+ * 3. \\\\<server name>\\<share point name>\\ or\n+ *    \\\\<server name>\\<share point name>, meaning the root directory\n+ *    of a UNC (Universal Naming Convention) name.\n+ */\n \n-        /* look for the next slash */\n-        do {\n-            p = _mbsinc(p);\n-        } while (*p != '\\0' && !_PR_IS_SLASH(*p));\n-        if (*p == '\\0') {\n-            return PR_FALSE;\n-        }\n+static PRBool IsRootDirectory(char* fn, size_t buflen) {\n+  char* p;\n+  PRBool slashAdded = PR_FALSE;\n+  PRBool rv = PR_FALSE;\n \n-        /* The 'share' part should have at least one character. */\n-        p++;\n-        if (*p == '\\0' || _PR_IS_SLASH(*p)) {\n-            return PR_FALSE;\n-        }\n+  if (_PR_IS_SLASH(fn[0]) && fn[1] == '\\0') {\n+    return PR_TRUE;\n+  }\n \n-        /* look for the final slash */\n-        do {\n-            p = _mbsinc(p);\n-        } while (*p != '\\0' && !_PR_IS_SLASH(*p));\n-        if (_PR_IS_SLASH(*p) && p[1] != '\\0') {\n-            return PR_FALSE;\n-        }\n-        if (*p == '\\0') {\n-            /*\n-             * GetDriveType() doesn't work correctly if the\n-             * path is of the form \\\\server\\share, so we add\n-             * a final slash temporarily.\n-             */\n-            if ((p + 1) < (fn + buflen)) {\n-                *p++ = '\\\\';\n-                *p = '\\0';\n-                slashAdded = PR_TRUE;\n-            } else {\n-                return PR_FALSE; /* name too long */\n-            }\n-        }\n-        rv = GetDriveType(fn) > 1 ? PR_TRUE : PR_FALSE;\n-        /* restore the 'fn' buffer */\n-        if (slashAdded) {\n-            *--p = '\\0';\n-        }\n-    }\n+  if (isalpha((unsigned char)fn[0]) && fn[1] == ':' && _PR_IS_SLASH(fn[2]) && fn[3] == '\\0') {\n+    rv = GetDriveType(fn) > 1 ? PR_TRUE : PR_FALSE;\n     return rv;\n+  }\n+\n+  /* The UNC root directory */\n+\n+  if (_PR_IS_SLASH(fn[0]) && _PR_IS_SLASH(fn[1])) {\n+    /* The 'server' part should have at least one character. */\n+    p = &fn[2];\n+    if (*p == '\\0' || _PR_IS_SLASH(*p)) {\n+      return PR_FALSE;\n+    }\n+\n+    /* look for the next slash */\n+    do {\n+      p = _mbsinc(p);\n+    } while (*p != '\\0' && !_PR_IS_SLASH(*p));\n+    if (*p == '\\0') {\n+      return PR_FALSE;\n+    }\n+\n+    /* The 'share' part should have at least one character. */\n+    p++;\n+    if (*p == '\\0' || _PR_IS_SLASH(*p)) {\n+      return PR_FALSE;\n+    }\n+\n+    /* look for the final slash */\n+    do {\n+      p = _mbsinc(p);\n+    } while (*p != '\\0' && !_PR_IS_SLASH(*p));\n+    if (_PR_IS_SLASH(*p) && p[1] != '\\0') {\n+      return PR_FALSE;\n+    }\n+    if (*p == '\\0') {\n+      /*\n+       * GetDriveType() doesn't work correctly if the\n+       * path is of the form \\\\server\\share, so we add\n+       * a final slash temporarily.\n+       */\n+      if ((p + 1) < (fn + buflen)) {\n+        *p++ = '\\\\';\n+        *p = '\\0';\n+        slashAdded = PR_TRUE;\n+      } else {\n+        return PR_FALSE; /* name too long */\n+      }\n+    }\n+    rv = GetDriveType(fn) > 1 ? PR_TRUE : PR_FALSE;\n+    /* restore the 'fn' buffer */\n+    if (slashAdded) {\n+      *--p = '\\0';\n+    }\n+  }\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_GETFILEINFO64(const char* fn, PRFileInfo64* info)\n-{\n-    WIN32_FILE_ATTRIBUTE_DATA findFileData;\n+PRInt32 _PR_MD_GETFILEINFO64(const char* fn, PRFileInfo64* info) {\n+  WIN32_FILE_ATTRIBUTE_DATA findFileData;\n \n-    if (NULL == fn || '\\0' == *fn) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return -1;\n-    }\n+  if (NULL == fn || '\\0' == *fn) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return -1;\n+  }\n \n-    if (!GetFileAttributesEx(fn, GetFileExInfoStandard, &findFileData)) {\n-        _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n-        return -1;\n-    }\n+  if (!GetFileAttributesEx(fn, GetFileExInfoStandard, &findFileData)) {\n+    _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n+    return -1;\n+  }\n \n-    if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n-        info->type = PR_FILE_DIRECTORY;\n-    } else {\n-        info->type = PR_FILE_FILE;\n-    }\n+  if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n+    info->type = PR_FILE_DIRECTORY;\n+  } else {\n+    info->type = PR_FILE_FILE;\n+  }\n \n-    info->size = findFileData.nFileSizeHigh;\n-    info->size = (info->size << 32) + findFileData.nFileSizeLow;\n+  info->size = findFileData.nFileSizeHigh;\n+  info->size = (info->size << 32) + findFileData.nFileSizeLow;\n \n-    _PR_FileTimeToPRTime(&findFileData.ftLastWriteTime, &info->modifyTime);\n+  _PR_FileTimeToPRTime(&findFileData.ftLastWriteTime, &info->modifyTime);\n \n-    if (0 == findFileData.ftCreationTime.dwLowDateTime &&\n-        0 == findFileData.ftCreationTime.dwHighDateTime) {\n-        info->creationTime = info->modifyTime;\n-    } else {\n-        _PR_FileTimeToPRTime(&findFileData.ftCreationTime, &info->creationTime);\n-    }\n+  if (0 == findFileData.ftCreationTime.dwLowDateTime &&\n+      0 == findFileData.ftCreationTime.dwHighDateTime) {\n+    info->creationTime = info->modifyTime;\n+  } else {\n+    _PR_FileTimeToPRTime(&findFileData.ftCreationTime, &info->creationTime);\n+  }\n \n-    return 0;\n+  return 0;\n }\n \n-PRInt32\n-_PR_MD_GETFILEINFO(const char* fn, PRFileInfo* info)\n-{\n-    PRFileInfo64 info64;\n-    PRInt32 rv = _PR_MD_GETFILEINFO64(fn, &info64);\n-    if (0 == rv) {\n-        info->type = info64.type;\n-        info->size = (PRUint32)info64.size;\n-        info->modifyTime = info64.modifyTime;\n-        info->creationTime = info64.creationTime;\n-    }\n-    return rv;\n+PRInt32 _PR_MD_GETFILEINFO(const char* fn, PRFileInfo* info) {\n+  PRFileInfo64 info64;\n+  PRInt32 rv = _PR_MD_GETFILEINFO64(fn, &info64);\n+  if (0 == rv) {\n+    info->type = info64.type;\n+    info->size = (PRUint32)info64.size;\n+    info->modifyTime = info64.modifyTime;\n+    info->creationTime = info64.creationTime;\n+  }\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_GETOPENFILEINFO64(const PRFileDesc* fd, PRFileInfo64* info)\n-{\n-    int rv;\n+PRInt32 _PR_MD_GETOPENFILEINFO64(const PRFileDesc* fd, PRFileInfo64* info) {\n+  int rv;\n \n-    BY_HANDLE_FILE_INFORMATION hinfo;\n+  BY_HANDLE_FILE_INFORMATION hinfo;\n \n-    rv = GetFileInformationByHandle((HANDLE)fd->secret->md.osfd, &hinfo);\n-    if (rv == FALSE) {\n-        _PR_MD_MAP_FSTAT_ERROR(GetLastError());\n-        return -1;\n-    }\n+  rv = GetFileInformationByHandle((HANDLE)fd->secret->md.osfd, &hinfo);\n+  if (rv == FALSE) {\n+    _PR_MD_MAP_FSTAT_ERROR(GetLastError());\n+    return -1;\n+  }\n \n-    if (hinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n-        info->type = PR_FILE_DIRECTORY;\n-    } else {\n-        info->type = PR_FILE_FILE;\n-    }\n+  if (hinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n+    info->type = PR_FILE_DIRECTORY;\n+  } else {\n+    info->type = PR_FILE_FILE;\n+  }\n \n-    info->size = hinfo.nFileSizeHigh;\n-    info->size = (info->size << 32) + hinfo.nFileSizeLow;\n+  info->size = hinfo.nFileSizeHigh;\n+  info->size = (info->size << 32) + hinfo.nFileSizeLow;\n \n-    _PR_FileTimeToPRTime(&hinfo.ftLastWriteTime, &(info->modifyTime));\n-    _PR_FileTimeToPRTime(&hinfo.ftCreationTime, &(info->creationTime));\n+  _PR_FileTimeToPRTime(&hinfo.ftLastWriteTime, &(info->modifyTime));\n+  _PR_FileTimeToPRTime(&hinfo.ftCreationTime, &(info->creationTime));\n \n-    return 0;\n+  return 0;\n }\n \n-PRInt32\n-_PR_MD_GETOPENFILEINFO(const PRFileDesc* fd, PRFileInfo* info)\n-{\n-    int rv;\n+PRInt32 _PR_MD_GETOPENFILEINFO(const PRFileDesc* fd, PRFileInfo* info) {\n+  int rv;\n \n-    BY_HANDLE_FILE_INFORMATION hinfo;\n+  BY_HANDLE_FILE_INFORMATION hinfo;\n \n-    rv = GetFileInformationByHandle((HANDLE)fd->secret->md.osfd, &hinfo);\n-    if (rv == FALSE) {\n-        _PR_MD_MAP_FSTAT_ERROR(GetLastError());\n-        return -1;\n-    }\n+  rv = GetFileInformationByHandle((HANDLE)fd->secret->md.osfd, &hinfo);\n+  if (rv == FALSE) {\n+    _PR_MD_MAP_FSTAT_ERROR(GetLastError());\n+    return -1;\n+  }\n \n-    if (hinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n-        info->type = PR_FILE_DIRECTORY;\n-    } else {\n-        info->type = PR_FILE_FILE;\n-    }\n+  if (hinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n+    info->type = PR_FILE_DIRECTORY;\n+  } else {\n+    info->type = PR_FILE_FILE;\n+  }\n \n-    info->size = hinfo.nFileSizeLow;\n+  info->size = hinfo.nFileSizeLow;\n \n-    _PR_FileTimeToPRTime(&hinfo.ftLastWriteTime, &(info->modifyTime));\n-    _PR_FileTimeToPRTime(&hinfo.ftCreationTime, &(info->creationTime));\n+  _PR_FileTimeToPRTime(&hinfo.ftLastWriteTime, &(info->modifyTime));\n+  _PR_FileTimeToPRTime(&hinfo.ftCreationTime, &(info->creationTime));\n \n-    return 0;\n+  return 0;\n }\n \n-PRInt32\n-_PR_MD_RENAME(const char* from, const char* to)\n-{\n-    /* Does this work with dot-relative pathnames? */\n-    if (MoveFile(from, to)) {\n-        return 0;\n-    } else {\n-        _PR_MD_MAP_RENAME_ERROR(GetLastError());\n-        return -1;\n-    }\n+PRInt32 _PR_MD_RENAME(const char* from, const char* to) {\n+  /* Does this work with dot-relative pathnames? */\n+  if (MoveFile(from, to)) {\n+    return 0;\n+  } else {\n+    _PR_MD_MAP_RENAME_ERROR(GetLastError());\n+    return -1;\n+  }\n }\n \n-PRInt32\n-_PR_MD_ACCESS(const char* name, PRAccessHow how)\n-{\n-    PRInt32 rv;\n-\n-    switch (how) {\n-        case PR_ACCESS_WRITE_OK:\n-            rv = _access(name, 02);\n-            break;\n-        case PR_ACCESS_READ_OK:\n-            rv = _access(name, 04);\n-            break;\n-        case PR_ACCESS_EXISTS:\n-            rv = _access(name, 00);\n-            break;\n-        default:\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            return -1;\n-    }\n-    if (rv < 0) {\n-        _PR_MD_MAP_ACCESS_ERROR(errno);\n-    }\n-    return rv;\n+PRInt32 _PR_MD_ACCESS(const char* name, PRAccessHow how) {\n+  PRInt32 rv;\n+\n+  switch (how) {\n+    case PR_ACCESS_WRITE_OK:\n+      rv = _access(name, 02);\n+      break;\n+    case PR_ACCESS_READ_OK:\n+      rv = _access(name, 04);\n+      break;\n+    case PR_ACCESS_EXISTS:\n+      rv = _access(name, 00);\n+      break;\n+    default:\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      return -1;\n+  }\n+  if (rv < 0) {\n+    _PR_MD_MAP_ACCESS_ERROR(errno);\n+  }\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_MKDIR(const char* name, PRIntn mode)\n-{\n-    /* XXXMB - how to translate the \"mode\"??? */\n-    if (CreateDirectory(name, NULL)) {\n-        return 0;\n-    } else {\n-        _PR_MD_MAP_MKDIR_ERROR(GetLastError());\n-        return -1;\n-    }\n+PRInt32 _PR_MD_MKDIR(const char* name, PRIntn mode) {\n+  /* XXXMB - how to translate the \"mode\"??? */\n+  if (CreateDirectory(name, NULL)) {\n+    return 0;\n+  } else {\n+    _PR_MD_MAP_MKDIR_ERROR(GetLastError());\n+    return -1;\n+  }\n }\n \n-PRInt32\n-_PR_MD_MAKE_DIR(const char* name, PRIntn mode)\n-{\n-    BOOL rv;\n-    SECURITY_ATTRIBUTES sa;\n-    LPSECURITY_ATTRIBUTES lpSA = NULL;\n-    PSECURITY_DESCRIPTOR pSD = NULL;\n-    PACL pACL = NULL;\n-\n-    if (_PR_NT_MakeSecurityDescriptorACL(mode, dirAccessTable, &pSD, &pACL) ==\n-        PR_SUCCESS) {\n-        sa.nLength = sizeof(sa);\n-        sa.lpSecurityDescriptor = pSD;\n-        sa.bInheritHandle = FALSE;\n-        lpSA = &sa;\n-    }\n-    rv = CreateDirectory(name, lpSA);\n-    if (lpSA != NULL) {\n-        _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n-    }\n-    if (rv) {\n-        return 0;\n-    } else {\n-        _PR_MD_MAP_MKDIR_ERROR(GetLastError());\n-        return -1;\n-    }\n+PRInt32 _PR_MD_MAKE_DIR(const char* name, PRIntn mode) {\n+  BOOL rv;\n+  SECURITY_ATTRIBUTES sa;\n+  LPSECURITY_ATTRIBUTES lpSA = NULL;\n+  PSECURITY_DESCRIPTOR pSD = NULL;\n+  PACL pACL = NULL;\n+\n+  if (_PR_NT_MakeSecurityDescriptorACL(mode, dirAccessTable, &pSD, &pACL) ==\n+      PR_SUCCESS) {\n+    sa.nLength = sizeof(sa);\n+    sa.lpSecurityDescriptor = pSD;\n+    sa.bInheritHandle = FALSE;\n+    lpSA = &sa;\n+  }\n+  rv = CreateDirectory(name, lpSA);\n+  if (lpSA != NULL) {\n+    _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n+  }\n+  if (rv) {\n+    return 0;\n+  } else {\n+    _PR_MD_MAP_MKDIR_ERROR(GetLastError());\n+    return -1;\n+  }\n }\n \n-PRInt32\n-_PR_MD_RMDIR(const char* name)\n-{\n-    if (RemoveDirectory(name)) {\n-        return 0;\n-    } else {\n-        _PR_MD_MAP_RMDIR_ERROR(GetLastError());\n-        return -1;\n-    }\n+PRInt32 _PR_MD_RMDIR(const char* name) {\n+  if (RemoveDirectory(name)) {\n+    return 0;\n+  } else {\n+    _PR_MD_MAP_RMDIR_ERROR(GetLastError());\n+    return -1;\n+  }\n }\n \n-PRStatus\n-_PR_MD_LOCKFILE(PROsfd f)\n-{\n-    PRInt32 rv, err;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+PRStatus _PR_MD_LOCKFILE(PROsfd f) {\n+  PRInt32 rv, err;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    if (me->io_suspended) {\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (me->io_suspended) {\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-    memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n+  memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n+\n+  _PR_THREAD_LOCK(me);\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    _PR_THREAD_UNLOCK(me);\n+    return -1;\n+  }\n+  me->io_pending = PR_TRUE;\n+  me->state = _PR_IO_WAIT;\n+  _PR_THREAD_UNLOCK(me);\n+\n+  rv = LockFileEx((HANDLE)f, LOCKFILE_EXCLUSIVE_LOCK, 0, 0x7fffffff, 0,\n+                  &me->md.overlapped.overlapped);\n \n+  if (_native_threads_only) {\n     _PR_THREAD_LOCK(me);\n+    me->io_pending = PR_FALSE;\n+    me->state = _PR_RUNNING;\n     if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        _PR_THREAD_UNLOCK(me);\n-        return -1;\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+      _PR_THREAD_UNLOCK(me);\n+      return PR_FAILURE;\n     }\n-    me->io_pending = PR_TRUE;\n-    me->state = _PR_IO_WAIT;\n     _PR_THREAD_UNLOCK(me);\n \n-    rv = LockFileEx((HANDLE)f, LOCKFILE_EXCLUSIVE_LOCK, 0, 0x7fffffff, 0,\n-                    &me->md.overlapped.overlapped);\n-\n-    if (_native_threads_only) {\n-        _PR_THREAD_LOCK(me);\n-        me->io_pending = PR_FALSE;\n-        me->state = _PR_RUNNING;\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-            _PR_THREAD_UNLOCK(me);\n-            return PR_FAILURE;\n-        }\n-        _PR_THREAD_UNLOCK(me);\n-\n-        if (rv == FALSE) {\n-            err = GetLastError();\n-            PR_ASSERT(err != ERROR_IO_PENDING);\n-            _PR_MD_MAP_LOCKF_ERROR(err);\n-            return PR_FAILURE;\n-        }\n-        return PR_SUCCESS;\n+    if (rv == FALSE) {\n+      err = GetLastError();\n+      PR_ASSERT(err != ERROR_IO_PENDING);\n+      _PR_MD_MAP_LOCKF_ERROR(err);\n+      return PR_FAILURE;\n+    }\n+    return PR_SUCCESS;\n+  }\n+\n+  /* HACK AROUND NT BUG\n+   * NT 3.51 has a bug.  In NT 3.51, if LockFileEx returns true, you\n+   * don't get any completion on the completion port.  This is a bug.\n+   *\n+   * They fixed it on NT4.0 so that you do get a completion.\n+   *\n+   * If we pretend we won't get a completion, NSPR gets confused later\n+   * when the unexpected completion arrives.  If we assume we do get\n+   * a completion, we hang on 3.51.  Worse, Microsoft informs me that the\n+   * behavior varies on 3.51 depending on if you are using a network\n+   * file system or a local disk!\n+   *\n+   * Solution:  For now, _nt_version_gets_lockfile_completion is set\n+   * depending on whether or not this system is EITHER\n+   *      - running NT 4.0\n+   *      - running NT 3.51 with a service pack greater than 5.\n+   *\n+   * In the meantime, this code may not work on network file systems.\n+   *\n+   */\n+\n+  if (rv == FALSE && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n+    _PR_THREAD_LOCK(me);\n+    me->io_pending = PR_FALSE;\n+    me->state = _PR_RUNNING;\n+    if (_PR_PENDING_INTERRUPT(me)) {\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+      _PR_THREAD_UNLOCK(me);\n+      return PR_FAILURE;\n     }\n+    _PR_THREAD_UNLOCK(me);\n \n-    /* HACK AROUND NT BUG\n-     * NT 3.51 has a bug.  In NT 3.51, if LockFileEx returns true, you\n-     * don't get any completion on the completion port.  This is a bug.\n-     *\n-     * They fixed it on NT4.0 so that you do get a completion.\n-     *\n-     * If we pretend we won't get a completion, NSPR gets confused later\n-     * when the unexpected completion arrives.  If we assume we do get\n-     * a completion, we hang on 3.51.  Worse, Microsoft informs me that the\n-     * behavior varies on 3.51 depending on if you are using a network\n-     * file system or a local disk!\n-     *\n-     * Solution:  For now, _nt_version_gets_lockfile_completion is set\n-     * depending on whether or not this system is EITHER\n-     *      - running NT 4.0\n-     *      - running NT 3.51 with a service pack greater than 5.\n-     *\n-     * In the meantime, this code may not work on network file systems.\n-     *\n+    _PR_MD_MAP_LOCKF_ERROR(err);\n+    return PR_FAILURE;\n+  }\n+#ifdef _NEED_351_FILE_LOCKING_HACK\n+  else if (rv) {\n+    /* If this is NT 3.51 and the file is local, then we won't get a\n+     * completion back from LockFile when it succeeded.\n      */\n-\n-    if (rv == FALSE && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n-        _PR_THREAD_LOCK(me);\n+    if (_nt_version_gets_lockfile_completion == PR_FALSE) {\n+      if (IsFileLocal((HANDLE)f) == _PR_LOCAL_FILE) {\n         me->io_pending = PR_FALSE;\n         me->state = _PR_RUNNING;\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-            _PR_THREAD_UNLOCK(me);\n-            return PR_FAILURE;\n-        }\n-        _PR_THREAD_UNLOCK(me);\n-\n-        _PR_MD_MAP_LOCKF_ERROR(err);\n-        return PR_FAILURE;\n-    }\n-#ifdef _NEED_351_FILE_LOCKING_HACK\n-    else if (rv) {\n-        /* If this is NT 3.51 and the file is local, then we won't get a\n-         * completion back from LockFile when it succeeded.\n-         */\n-        if (_nt_version_gets_lockfile_completion == PR_FALSE) {\n-            if (IsFileLocal((HANDLE)f) == _PR_LOCAL_FILE) {\n-                me->io_pending = PR_FALSE;\n-                me->state = _PR_RUNNING;\n-                return PR_SUCCESS;\n-            }\n-        }\n+        return PR_SUCCESS;\n+      }\n     }\n+  }\n #endif /* _NEED_351_FILE_LOCKING_HACK */\n \n-    if (_NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n-        _PR_THREAD_LOCK(me);\n-        me->io_pending = PR_FALSE;\n-        me->state = _PR_RUNNING;\n-        _PR_THREAD_UNLOCK(me);\n-        return PR_FAILURE;\n-    }\n+  if (_NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n+    _PR_THREAD_LOCK(me);\n+    me->io_pending = PR_FALSE;\n+    me->state = _PR_RUNNING;\n+    _PR_THREAD_UNLOCK(me);\n+    return PR_FAILURE;\n+  }\n \n-    if (me->md.blocked_io_status == 0) {\n-        _PR_MD_MAP_LOCKF_ERROR(me->md.blocked_io_error);\n-        return PR_FAILURE;\n-    }\n+  if (me->md.blocked_io_status == 0) {\n+    _PR_MD_MAP_LOCKF_ERROR(me->md.blocked_io_error);\n+    return PR_FAILURE;\n+  }\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_PR_MD_TLOCKFILE(PROsfd f)\n-{\n-    PRInt32 rv, err;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+PRStatus _PR_MD_TLOCKFILE(PROsfd f) {\n+  PRInt32 rv, err;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    if (me->io_suspended) {\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (me->io_suspended) {\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-    memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n+  memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n \n+  _PR_THREAD_LOCK(me);\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    _PR_THREAD_UNLOCK(me);\n+    return -1;\n+  }\n+  me->io_pending = PR_TRUE;\n+  me->state = _PR_IO_WAIT;\n+  _PR_THREAD_UNLOCK(me);\n+\n+  rv =\n+      LockFileEx((HANDLE)f, LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK,\n+                 0, 0x7fffffff, 0, &me->md.overlapped.overlapped);\n+  if (_native_threads_only) {\n     _PR_THREAD_LOCK(me);\n+    me->io_pending = PR_FALSE;\n+    me->state = _PR_RUNNING;\n     if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        _PR_THREAD_UNLOCK(me);\n-        return -1;\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+      _PR_THREAD_UNLOCK(me);\n+      return PR_FAILURE;\n     }\n-    me->io_pending = PR_TRUE;\n-    me->state = _PR_IO_WAIT;\n     _PR_THREAD_UNLOCK(me);\n \n-    rv =\n-        LockFileEx((HANDLE)f, LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK,\n-                   0, 0x7fffffff, 0, &me->md.overlapped.overlapped);\n-    if (_native_threads_only) {\n-        _PR_THREAD_LOCK(me);\n-        me->io_pending = PR_FALSE;\n-        me->state = _PR_RUNNING;\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-            _PR_THREAD_UNLOCK(me);\n-            return PR_FAILURE;\n-        }\n-        _PR_THREAD_UNLOCK(me);\n-\n-        if (rv == FALSE) {\n-            err = GetLastError();\n-            PR_ASSERT(err != ERROR_IO_PENDING);\n-            _PR_MD_MAP_LOCKF_ERROR(err);\n-            return PR_FAILURE;\n-        }\n-        return PR_SUCCESS;\n-    }\n-    if (rv == FALSE && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n-        _PR_THREAD_LOCK(me);\n-        me->io_pending = PR_FALSE;\n-        me->state = _PR_RUNNING;\n-        if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-            _PR_THREAD_UNLOCK(me);\n-            return PR_FAILURE;\n-        }\n-        _PR_THREAD_UNLOCK(me);\n-\n-        _PR_MD_MAP_LOCKF_ERROR(err);\n-        return PR_FAILURE;\n+    if (rv == FALSE) {\n+      err = GetLastError();\n+      PR_ASSERT(err != ERROR_IO_PENDING);\n+      _PR_MD_MAP_LOCKF_ERROR(err);\n+      return PR_FAILURE;\n     }\n-#ifdef _NEED_351_FILE_LOCKING_HACK\n-    else if (rv) {\n-        /* If this is NT 3.51 and the file is local, then we won't get a\n-         * completion back from LockFile when it succeeded.\n-         */\n-        if (_nt_version_gets_lockfile_completion == PR_FALSE) {\n-            if (IsFileLocal((HANDLE)f) == _PR_LOCAL_FILE) {\n-                _PR_THREAD_LOCK(me);\n-                me->io_pending = PR_FALSE;\n-                me->state = _PR_RUNNING;\n-                if (_PR_PENDING_INTERRUPT(me)) {\n-                    me->flags &= ~_PR_INTERRUPT;\n-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                    _PR_THREAD_UNLOCK(me);\n-                    return PR_FAILURE;\n-                }\n-                _PR_THREAD_UNLOCK(me);\n-\n-                return PR_SUCCESS;\n-            }\n-        }\n+    return PR_SUCCESS;\n+  }\n+  if (rv == FALSE && ((err = GetLastError()) != ERROR_IO_PENDING)) {\n+    _PR_THREAD_LOCK(me);\n+    me->io_pending = PR_FALSE;\n+    me->state = _PR_RUNNING;\n+    if (_PR_PENDING_INTERRUPT(me)) {\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+      _PR_THREAD_UNLOCK(me);\n+      return PR_FAILURE;\n     }\n-#endif /* _NEED_351_FILE_LOCKING_HACK */\n+    _PR_THREAD_UNLOCK(me);\n \n-    if (_NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n+    _PR_MD_MAP_LOCKF_ERROR(err);\n+    return PR_FAILURE;\n+  }\n+#ifdef _NEED_351_FILE_LOCKING_HACK\n+  else if (rv) {\n+    /* If this is NT 3.51 and the file is local, then we won't get a\n+     * completion back from LockFile when it succeeded.\n+     */\n+    if (_nt_version_gets_lockfile_completion == PR_FALSE) {\n+      if (IsFileLocal((HANDLE)f) == _PR_LOCAL_FILE) {\n         _PR_THREAD_LOCK(me);\n         me->io_pending = PR_FALSE;\n         me->state = _PR_RUNNING;\n         if (_PR_PENDING_INTERRUPT(me)) {\n-            me->flags &= ~_PR_INTERRUPT;\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-            _PR_THREAD_UNLOCK(me);\n-            return PR_FAILURE;\n+          me->flags &= ~_PR_INTERRUPT;\n+          PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+          _PR_THREAD_UNLOCK(me);\n+          return PR_FAILURE;\n         }\n         _PR_THREAD_UNLOCK(me);\n \n-        return PR_FAILURE;\n+        return PR_SUCCESS;\n+      }\n     }\n+  }\n+#endif /* _NEED_351_FILE_LOCKING_HACK */\n \n-    if (me->md.blocked_io_status == 0) {\n-        _PR_MD_MAP_LOCKF_ERROR(me->md.blocked_io_error);\n-        return PR_FAILURE;\n+  if (_NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n+    _PR_THREAD_LOCK(me);\n+    me->io_pending = PR_FALSE;\n+    me->state = _PR_RUNNING;\n+    if (_PR_PENDING_INTERRUPT(me)) {\n+      me->flags &= ~_PR_INTERRUPT;\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+      _PR_THREAD_UNLOCK(me);\n+      return PR_FAILURE;\n     }\n+    _PR_THREAD_UNLOCK(me);\n \n-    return PR_SUCCESS;\n+    return PR_FAILURE;\n+  }\n+\n+  if (me->md.blocked_io_status == 0) {\n+    _PR_MD_MAP_LOCKF_ERROR(me->md.blocked_io_error);\n+    return PR_FAILURE;\n+  }\n+\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_PR_MD_UNLOCKFILE(PROsfd f)\n-{\n-    PRInt32 rv;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+PRStatus _PR_MD_UNLOCKFILE(PROsfd f) {\n+  PRInt32 rv;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    if (me->io_suspended) {\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (me->io_suspended) {\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-    memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n+  memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));\n \n-    rv = UnlockFileEx((HANDLE)f, 0, 0x7fffffff, 0, &me->md.overlapped.overlapped);\n+  rv = UnlockFileEx((HANDLE)f, 0, 0x7fffffff, 0, &me->md.overlapped.overlapped);\n \n-    if (rv) {\n-        return PR_SUCCESS;\n-    } else {\n-        int err = GetLastError();\n-        _PR_MD_MAP_LOCKF_ERROR(err);\n-        return PR_FAILURE;\n-    }\n+  if (rv) {\n+    return PR_SUCCESS;\n+  } else {\n+    int err = GetLastError();\n+    _PR_MD_MAP_LOCKF_ERROR(err);\n+    return PR_FAILURE;\n+  }\n }\n \n-void\n-_PR_MD_MAKE_NONBLOCK(PRFileDesc* f)\n-{\n-    /*\n-     * On NT, we either call _md_Associate() or _md_MakeNonblock(),\n-     * depending on whether the socket is blocking or not.\n-     *\n-     * Once we associate a socket with the io completion port,\n-     * there is no way to disassociate it from the io completion\n-     * port.  So we have to call _md_Associate/_md_MakeNonblock\n-     * lazily.\n-     */\n+void _PR_MD_MAKE_NONBLOCK(PRFileDesc* f) {\n+  /*\n+   * On NT, we either call _md_Associate() or _md_MakeNonblock(),\n+   * depending on whether the socket is blocking or not.\n+   *\n+   * Once we associate a socket with the io completion port,\n+   * there is no way to disassociate it from the io completion\n+   * port.  So we have to call _md_Associate/_md_MakeNonblock\n+   * lazily.\n+   */\n }\n \n #ifdef _NEED_351_FILE_LOCKING_HACK\n@@ -3479,717 +3340,695 @@ _PR_MD_MAKE_NONBLOCK(PRFileDesc* f)\n */\n \n /* There can only be 26 drive letters on NT */\n-#define _PR_MAX_DRIVES 26\n+#  define _PR_MAX_DRIVES 26\n \n _MDLock cachedVolumeLock;\n-DWORD dwCachedVolumeSerialNumbers[_PR_MAX_DRIVES] = { 0 };\n+DWORD dwCachedVolumeSerialNumbers[_PR_MAX_DRIVES] = {0};\n DWORD dwLastCachedDrive = 0;\n DWORD dwRemoveableDrivesToCheck = 0; /* bitmask for removeable drives */\n \n-PRBool\n-IsFileLocalInit()\n-{\n-    TCHAR lpBuffer[_PR_MAX_DRIVES * 5];\n-    DWORD nBufferLength = _PR_MAX_DRIVES * 5;\n-    DWORD nBufferNeeded = GetLogicalDriveStrings(0, NULL);\n-    DWORD dwIndex = 0;\n-    DWORD dwDriveType;\n-    DWORD dwVolumeSerialNumber;\n-    DWORD dwDriveIndex = 0;\n-    DWORD oldmode = (DWORD)-1;\n-\n-    _MD_NEW_LOCK(&cachedVolumeLock);\n-\n-    nBufferNeeded = GetLogicalDriveStrings(nBufferLength, lpBuffer);\n-    if (nBufferNeeded == 0 || nBufferNeeded > nBufferLength) {\n-        return PR_FALSE;\n-    }\n-\n-    // Calling GetVolumeInformation on a removeable drive where the\n-    // disk is currently removed will cause a dialog box to the\n-    // console.  This is not good.\n-    // Temporarily disable the SEM_FAILCRITICALERRORS to avoid the\n-    // damn dialog.\n-\n-    dwCachedVolumeSerialNumbers[dwDriveIndex] = 0;\n-    oldmode = SetErrorMode(SEM_FAILCRITICALERRORS);\n-\n-    // now loop through the logical drives\n-    while (lpBuffer[dwIndex] != TEXT('\\0')) {\n-        // skip the floppy drives.  This is *SLOW*\n-        if ((lpBuffer[dwIndex] == TEXT('A')) || (lpBuffer[dwIndex] == TEXT('B')))\n-            /* Skip over floppies */;\n-        else {\n-            dwDriveIndex = (lpBuffer[dwIndex] - TEXT('A'));\n-\n-            dwDriveType = GetDriveType(&lpBuffer[dwIndex]);\n+PRBool IsFileLocalInit() {\n+  TCHAR lpBuffer[_PR_MAX_DRIVES * 5];\n+  DWORD nBufferLength = _PR_MAX_DRIVES * 5;\n+  DWORD nBufferNeeded = GetLogicalDriveStrings(0, NULL);\n+  DWORD dwIndex = 0;\n+  DWORD dwDriveType;\n+  DWORD dwVolumeSerialNumber;\n+  DWORD dwDriveIndex = 0;\n+  DWORD oldmode = (DWORD)-1;\n+\n+  _MD_NEW_LOCK(&cachedVolumeLock);\n+\n+  nBufferNeeded = GetLogicalDriveStrings(nBufferLength, lpBuffer);\n+  if (nBufferNeeded == 0 || nBufferNeeded > nBufferLength) {\n+    return PR_FALSE;\n+  }\n+\n+  // Calling GetVolumeInformation on a removeable drive where the\n+  // disk is currently removed will cause a dialog box to the\n+  // console.  This is not good.\n+  // Temporarily disable the SEM_FAILCRITICALERRORS to avoid the\n+  // damn dialog.\n+\n+  dwCachedVolumeSerialNumbers[dwDriveIndex] = 0;\n+  oldmode = SetErrorMode(SEM_FAILCRITICALERRORS);\n+\n+  // now loop through the logical drives\n+  while (lpBuffer[dwIndex] != TEXT('\\0')) {\n+    // skip the floppy drives.  This is *SLOW*\n+    if ((lpBuffer[dwIndex] == TEXT('A')) || (lpBuffer[dwIndex] == TEXT('B')))\n+      /* Skip over floppies */;\n+    else {\n+      dwDriveIndex = (lpBuffer[dwIndex] - TEXT('A'));\n \n-            switch (dwDriveType) {\n-                // Ignore these drive types\n-                case 0:\n-                case 1:\n-                case DRIVE_REMOTE:\n-                default: // If the drive type is unknown, ignore it.\n-                    break;\n+      dwDriveType = GetDriveType(&lpBuffer[dwIndex]);\n \n-                // Removable media drives can have different serial numbers\n-                // at different times, so cache the current serial number\n-                // but keep track of them so they can be rechecked if necessary.\n-                case DRIVE_REMOVABLE:\n+      switch (dwDriveType) {\n+        // Ignore these drive types\n+        case 0:\n+        case 1:\n+        case DRIVE_REMOTE:\n+        default:  // If the drive type is unknown, ignore it.\n+          break;\n \n-                // CDROM is a removable media\n-                case DRIVE_CDROM:\n+        // Removable media drives can have different serial numbers\n+        // at different times, so cache the current serial number\n+        // but keep track of them so they can be rechecked if necessary.\n+        case DRIVE_REMOVABLE:\n \n-                    // no idea if ramdisks can change serial numbers or not\n-                    // but it doesn't hurt to treat them as removable.\n+        // CDROM is a removable media\n+        case DRIVE_CDROM:\n \n-                case DRIVE_RAMDISK:\n+          // no idea if ramdisks can change serial numbers or not\n+          // but it doesn't hurt to treat them as removable.\n \n-                    // Here is where we keep track of removable drives.\n-                    dwRemoveableDrivesToCheck |= 1 << dwDriveIndex;\n+        case DRIVE_RAMDISK:\n \n-                    // removable drives fall through to fixed drives and get cached.\n+          // Here is where we keep track of removable drives.\n+          dwRemoveableDrivesToCheck |= 1 << dwDriveIndex;\n \n-                case DRIVE_FIXED:\n+          // removable drives fall through to fixed drives and get cached.\n \n-                    // cache volume serial numbers.\n-                    if (GetVolumeInformation(&lpBuffer[dwIndex], NULL, 0,\n-                                             &dwVolumeSerialNumber, NULL, NULL, NULL,\n-                                             0)) {\n-                        if (dwLastCachedDrive < dwDriveIndex) {\n-                            dwLastCachedDrive = dwDriveIndex;\n-                        }\n-                        dwCachedVolumeSerialNumbers[dwDriveIndex] = dwVolumeSerialNumber;\n-                    }\n+        case DRIVE_FIXED:\n \n-                    break;\n+          // cache volume serial numbers.\n+          if (GetVolumeInformation(&lpBuffer[dwIndex], NULL, 0,\n+                                   &dwVolumeSerialNumber, NULL, NULL, NULL,\n+                                   0)) {\n+            if (dwLastCachedDrive < dwDriveIndex) {\n+              dwLastCachedDrive = dwDriveIndex;\n             }\n-        }\n+            dwCachedVolumeSerialNumbers[dwDriveIndex] = dwVolumeSerialNumber;\n+          }\n \n-        dwIndex += lstrlen(&lpBuffer[dwIndex]) + 1;\n+          break;\n+      }\n     }\n \n-    if (oldmode != (DWORD)-1) {\n-        SetErrorMode(oldmode);\n-        oldmode = (DWORD)-1;\n-    }\n+    dwIndex += lstrlen(&lpBuffer[dwIndex]) + 1;\n+  }\n \n-    return PR_TRUE;\n+  if (oldmode != (DWORD)-1) {\n+    SetErrorMode(oldmode);\n+    oldmode = (DWORD)-1;\n+  }\n+\n+  return PR_TRUE;\n }\n \n-PRInt32\n-IsFileLocal(HANDLE hFile)\n-{\n-    DWORD dwIndex = 0, dwMask;\n-    BY_HANDLE_FILE_INFORMATION Info;\n-    TCHAR szDrive[4] = TEXT(\"C:\\\\\");\n-    DWORD dwVolumeSerialNumber;\n-    DWORD oldmode = (DWORD)-1;\n-    int rv = _PR_REMOTE_FILE;\n-\n-    if (!GetFileInformationByHandle(hFile, &Info)) {\n-        return -1;\n-    }\n+PRInt32 IsFileLocal(HANDLE hFile) {\n+  DWORD dwIndex = 0, dwMask;\n+  BY_HANDLE_FILE_INFORMATION Info;\n+  TCHAR szDrive[4] = TEXT(\"C:\\\\\");\n+  DWORD dwVolumeSerialNumber;\n+  DWORD oldmode = (DWORD)-1;\n+  int rv = _PR_REMOTE_FILE;\n \n-    // look to see if the volume serial number has been cached.\n-    _MD_LOCK(&cachedVolumeLock);\n-    while (dwIndex <= dwLastCachedDrive)\n-        if (dwCachedVolumeSerialNumbers[dwIndex++] == Info.dwVolumeSerialNumber) {\n-            _MD_UNLOCK(&cachedVolumeLock);\n-            return _PR_LOCAL_FILE;\n-        }\n-    _MD_UNLOCK(&cachedVolumeLock);\n-\n-    // volume serial number not found in the cache.  Check removable files.\n-    // removable drives are noted as a bitmask.  If the bit associated with\n-    // a specific drive is set, then we should query its volume serial number\n-    // as its possible it has changed.\n-    dwMask = dwRemoveableDrivesToCheck;\n-    dwIndex = 0;\n-\n-    while (dwMask) {\n-        while (!(dwMask & 1)) {\n-            dwIndex++;\n-            dwMask = dwMask >> 1;\n-        }\n+  if (!GetFileInformationByHandle(hFile, &Info)) {\n+    return -1;\n+  }\n \n-        szDrive[0] = TEXT('A') + (TCHAR)dwIndex;\n-\n-        // Calling GetVolumeInformation on a removeable drive where the\n-        // disk is currently removed will cause a dialog box to the\n-        // console.  This is not good.\n-        // Temporarily disable the SEM_FAILCRITICALERRORS to avoid the\n-        // dialog.\n-\n-        oldmode = SetErrorMode(SEM_FAILCRITICALERRORS);\n-\n-        if (GetVolumeInformation(szDrive, NULL, 0, &dwVolumeSerialNumber, NULL,\n-                                 NULL, NULL, 0)) {\n-            if (dwVolumeSerialNumber == Info.dwVolumeSerialNumber) {\n-                _MD_LOCK(&cachedVolumeLock);\n-                if (dwLastCachedDrive < dwIndex) {\n-                    dwLastCachedDrive = dwIndex;\n-                }\n-                dwCachedVolumeSerialNumbers[dwIndex] = dwVolumeSerialNumber;\n-                _MD_UNLOCK(&cachedVolumeLock);\n-                rv = _PR_LOCAL_FILE;\n-            }\n-        }\n-        if (oldmode != (DWORD)-1) {\n-            SetErrorMode(oldmode);\n-            oldmode = (DWORD)-1;\n-        }\n+  // look to see if the volume serial number has been cached.\n+  _MD_LOCK(&cachedVolumeLock);\n+  while (dwIndex <= dwLastCachedDrive)\n+    if (dwCachedVolumeSerialNumbers[dwIndex++] == Info.dwVolumeSerialNumber) {\n+      _MD_UNLOCK(&cachedVolumeLock);\n+      return _PR_LOCAL_FILE;\n+    }\n+  _MD_UNLOCK(&cachedVolumeLock);\n \n-        if (rv == _PR_LOCAL_FILE) {\n-            return _PR_LOCAL_FILE;\n-        }\n+  // volume serial number not found in the cache.  Check removable files.\n+  // removable drives are noted as a bitmask.  If the bit associated with\n+  // a specific drive is set, then we should query its volume serial number\n+  // as its possible it has changed.\n+  dwMask = dwRemoveableDrivesToCheck;\n+  dwIndex = 0;\n \n-        dwIndex++;\n-        dwMask = dwMask >> 1;\n+  while (dwMask) {\n+    while (!(dwMask & 1)) {\n+      dwIndex++;\n+      dwMask = dwMask >> 1;\n     }\n \n-    return _PR_REMOTE_FILE;\n-}\n-#endif /* _NEED_351_FILE_LOCKING_HACK */\n-\n-PR_IMPLEMENT(PRStatus)\n-PR_NT_CancelIo(PRFileDesc* fd)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRBool fWait;\n-    PRFileDesc* bottom;\n+    szDrive[0] = TEXT('A') + (TCHAR)dwIndex;\n \n-    bottom = PR_GetIdentitiesLayer(fd, PR_NSPR_IO_LAYER);\n-    if (!me->io_suspended || (NULL == bottom) ||\n-        (me->io_fd != bottom->secret->md.osfd)) {\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    /*\n-     * The CancelIO operation has to be issued by the same NT thread that\n-     * issued the I/O operation\n-     */\n-    PR_ASSERT(_PR_IS_NATIVE_THREAD(me) || (me->cpu == me->md.thr_bound_cpu));\n-    if (me->io_pending) {\n-        if (!CancelIo((HANDLE)bottom->secret->md.osfd)) {\n-            PR_SetError(PR_INVALID_STATE_ERROR, GetLastError());\n-            return PR_FAILURE;\n+    // Calling GetVolumeInformation on a removeable drive where the\n+    // disk is currently removed will cause a dialog box to the\n+    // console.  This is not good.\n+    // Temporarily disable the SEM_FAILCRITICALERRORS to avoid the\n+    // dialog.\n+\n+    oldmode = SetErrorMode(SEM_FAILCRITICALERRORS);\n+\n+    if (GetVolumeInformation(szDrive, NULL, 0, &dwVolumeSerialNumber, NULL,\n+                             NULL, NULL, 0)) {\n+      if (dwVolumeSerialNumber == Info.dwVolumeSerialNumber) {\n+        _MD_LOCK(&cachedVolumeLock);\n+        if (dwLastCachedDrive < dwIndex) {\n+          dwLastCachedDrive = dwIndex;\n         }\n+        dwCachedVolumeSerialNumbers[dwIndex] = dwVolumeSerialNumber;\n+        _MD_UNLOCK(&cachedVolumeLock);\n+        rv = _PR_LOCAL_FILE;\n+      }\n     }\n-    _PR_THREAD_LOCK(me);\n-    fWait = me->io_pending;\n-    me->io_suspended = PR_FALSE;\n-    me->state = _PR_IO_WAIT;\n-    me->md.interrupt_disabled = PR_TRUE;\n-    _PR_THREAD_UNLOCK(me);\n-    if (fWait) {\n-        _NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT);\n+    if (oldmode != (DWORD)-1) {\n+      SetErrorMode(oldmode);\n+      oldmode = (DWORD)-1;\n     }\n-    PR_ASSERT(me->io_suspended == PR_FALSE);\n-    PR_ASSERT(me->io_pending == PR_FALSE);\n \n-    _PR_THREAD_LOCK(me);\n-    me->md.interrupt_disabled = PR_FALSE;\n-    me->md.thr_bound_cpu = NULL;\n-    me->io_suspended = PR_FALSE;\n-    me->io_pending = PR_FALSE;\n-    me->state = _PR_RUNNING;\n-    _PR_THREAD_UNLOCK(me);\n-    return PR_SUCCESS;\n+    if (rv == _PR_LOCAL_FILE) {\n+      return _PR_LOCAL_FILE;\n+    }\n+\n+    dwIndex++;\n+    dwMask = dwMask >> 1;\n+  }\n+\n+  return _PR_REMOTE_FILE;\n }\n+#endif /* _NEED_351_FILE_LOCKING_HACK */\n \n-static PROsfd\n-_nt_nonblock_accept(PRFileDesc* fd, struct sockaddr* addr,\n-                    int* addrlen, PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    SOCKET sock;\n-    PRInt32 rv, err;\n-    fd_set rd;\n-    struct timeval tv, *tvp;\n-\n-    FD_ZERO(&rd);\n-    FD_SET((SOCKET)osfd, &rd);\n-    if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-        while ((sock = accept(osfd, addr, addrlen)) == -1) {\n-            if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n-                (!fd->secret->nonblocking)) {\n-                if ((rv = _PR_NTFiberSafeSelect(0, &rd, NULL, NULL, NULL)) == -1) {\n-                    _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n-                    break;\n-                }\n-            } else {\n-                _PR_MD_MAP_ACCEPT_ERROR(err);\n-                break;\n-            }\n-        }\n-    } else if (timeout == PR_INTERVAL_NO_WAIT) {\n-        if ((sock = accept(osfd, addr, addrlen)) == -1) {\n-            if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n-                (!fd->secret->nonblocking)) {\n-                PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-            } else {\n-                _PR_MD_MAP_ACCEPT_ERROR(err);\n-            }\n+PR_IMPLEMENT(PRStatus) PR_NT_CancelIo(PRFileDesc* fd) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRBool fWait;\n+  PRFileDesc* bottom;\n+\n+  bottom = PR_GetIdentitiesLayer(fd, PR_NSPR_IO_LAYER);\n+  if (!me->io_suspended || (NULL == bottom) ||\n+      (me->io_fd != bottom->secret->md.osfd)) {\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  /*\n+   * The CancelIO operation has to be issued by the same NT thread that\n+   * issued the I/O operation\n+   */\n+  PR_ASSERT(_PR_IS_NATIVE_THREAD(me) || (me->cpu == me->md.thr_bound_cpu));\n+  if (me->io_pending) {\n+    if (!CancelIo((HANDLE)bottom->secret->md.osfd)) {\n+      PR_SetError(PR_INVALID_STATE_ERROR, GetLastError());\n+      return PR_FAILURE;\n+    }\n+  }\n+  _PR_THREAD_LOCK(me);\n+  fWait = me->io_pending;\n+  me->io_suspended = PR_FALSE;\n+  me->state = _PR_IO_WAIT;\n+  me->md.interrupt_disabled = PR_TRUE;\n+  _PR_THREAD_UNLOCK(me);\n+  if (fWait) {\n+    _NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_ASSERT(me->io_suspended == PR_FALSE);\n+  PR_ASSERT(me->io_pending == PR_FALSE);\n+\n+  _PR_THREAD_LOCK(me);\n+  me->md.interrupt_disabled = PR_FALSE;\n+  me->md.thr_bound_cpu = NULL;\n+  me->io_suspended = PR_FALSE;\n+  me->io_pending = PR_FALSE;\n+  me->state = _PR_RUNNING;\n+  _PR_THREAD_UNLOCK(me);\n+  return PR_SUCCESS;\n+}\n+\n+static PROsfd _nt_nonblock_accept(PRFileDesc* fd, struct sockaddr* addr,\n+                                  int* addrlen, PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  SOCKET sock;\n+  PRInt32 rv, err;\n+  fd_set rd;\n+  struct timeval tv, *tvp;\n+\n+  FD_ZERO(&rd);\n+  FD_SET((SOCKET)osfd, &rd);\n+  if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+    while ((sock = accept(osfd, addr, addrlen)) == -1) {\n+      if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n+          (!fd->secret->nonblocking)) {\n+        if ((rv = _PR_NTFiberSafeSelect(0, &rd, NULL, NULL, NULL)) == -1) {\n+          _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n+          break;\n         }\n-    } else {\n-    retry:\n-        if ((sock = accept(osfd, addr, addrlen)) == -1) {\n-            if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n-                (!fd->secret->nonblocking)) {\n-                tv.tv_sec = PR_IntervalToSeconds(timeout);\n-                tv.tv_usec = PR_IntervalToMicroseconds(timeout -\n-                                                       PR_SecondsToInterval(tv.tv_sec));\n-                tvp = &tv;\n-\n-                rv = _PR_NTFiberSafeSelect(0, &rd, NULL, NULL, tvp);\n-                if (rv > 0) {\n-                    goto retry;\n-                } else if (rv == 0) {\n-                    PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                } else {\n-                    _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n-                }\n-            } else {\n-                _PR_MD_MAP_ACCEPT_ERROR(err);\n-            }\n+      } else {\n+        _PR_MD_MAP_ACCEPT_ERROR(err);\n+        break;\n+      }\n+    }\n+  } else if (timeout == PR_INTERVAL_NO_WAIT) {\n+    if ((sock = accept(osfd, addr, addrlen)) == -1) {\n+      if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n+          (!fd->secret->nonblocking)) {\n+        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+      } else {\n+        _PR_MD_MAP_ACCEPT_ERROR(err);\n+      }\n+    }\n+  } else {\n+  retry:\n+    if ((sock = accept(osfd, addr, addrlen)) == -1) {\n+      if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n+          (!fd->secret->nonblocking)) {\n+        tv.tv_sec = PR_IntervalToSeconds(timeout);\n+        tv.tv_usec = PR_IntervalToMicroseconds(timeout -\n+                                               PR_SecondsToInterval(tv.tv_sec));\n+        tvp = &tv;\n+\n+        rv = _PR_NTFiberSafeSelect(0, &rd, NULL, NULL, tvp);\n+        if (rv > 0) {\n+          goto retry;\n+        } else if (rv == 0) {\n+          PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+        } else {\n+          _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n         }\n+      } else {\n+        _PR_MD_MAP_ACCEPT_ERROR(err);\n+      }\n     }\n-    return (PROsfd)sock;\n+  }\n+  return (PROsfd)sock;\n }\n \n-static PRInt32\n-_nt_nonblock_connect(PRFileDesc* fd, struct sockaddr* addr,\n-                     int addrlen, PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv;\n-    int err;\n-    fd_set wr, ex;\n-    struct timeval tv, *tvp;\n-    int len;\n-\n-    if ((rv = connect(osfd, addr, addrlen)) == -1) {\n-        if ((err = WSAGetLastError()) == WSAEWOULDBLOCK) {\n-            if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-                tvp = NULL;\n-            } else {\n-                tv.tv_sec = PR_IntervalToSeconds(timeout);\n-                tv.tv_usec = PR_IntervalToMicroseconds(timeout -\n-                                                       PR_SecondsToInterval(tv.tv_sec));\n-                tvp = &tv;\n-            }\n-            FD_ZERO(&wr);\n-            FD_ZERO(&ex);\n-            FD_SET((SOCKET)osfd, &wr);\n-            FD_SET((SOCKET)osfd, &ex);\n-            if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wr, &ex, tvp)) == -1) {\n-                _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n-                return rv;\n-            }\n-            if (rv == 0) {\n-                PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                return -1;\n-            }\n-            /* Call Sleep(0) to work around a Winsock timeing bug. */\n-            Sleep(0);\n-            if (FD_ISSET((SOCKET)osfd, &ex)) {\n-                len = sizeof(err);\n-                if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char*)&err, &len) ==\n-                    SOCKET_ERROR) {\n-                    _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n-                    return -1;\n-                }\n-                _PR_MD_MAP_CONNECT_ERROR(err);\n-                return -1;\n-            }\n-            PR_ASSERT(FD_ISSET((SOCKET)osfd, &wr));\n-            rv = 0;\n-        } else {\n-            _PR_MD_MAP_CONNECT_ERROR(err);\n+static PRInt32 _nt_nonblock_connect(PRFileDesc* fd, struct sockaddr* addr,\n+                                    int addrlen, PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv;\n+  int err;\n+  fd_set wr, ex;\n+  struct timeval tv, *tvp;\n+  int len;\n+\n+  if ((rv = connect(osfd, addr, addrlen)) == -1) {\n+    if ((err = WSAGetLastError()) == WSAEWOULDBLOCK) {\n+      if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+        tvp = NULL;\n+      } else {\n+        tv.tv_sec = PR_IntervalToSeconds(timeout);\n+        tv.tv_usec = PR_IntervalToMicroseconds(timeout -\n+                                               PR_SecondsToInterval(tv.tv_sec));\n+        tvp = &tv;\n+      }\n+      FD_ZERO(&wr);\n+      FD_ZERO(&ex);\n+      FD_SET((SOCKET)osfd, &wr);\n+      FD_SET((SOCKET)osfd, &ex);\n+      if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wr, &ex, tvp)) == -1) {\n+        _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n+        return rv;\n+      }\n+      if (rv == 0) {\n+        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+        return -1;\n+      }\n+      /* Call Sleep(0) to work around a Winsock timeing bug. */\n+      Sleep(0);\n+      if (FD_ISSET((SOCKET)osfd, &ex)) {\n+        len = sizeof(err);\n+        if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char*)&err, &len) ==\n+            SOCKET_ERROR) {\n+          _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n+          return -1;\n         }\n+        _PR_MD_MAP_CONNECT_ERROR(err);\n+        return -1;\n+      }\n+      PR_ASSERT(FD_ISSET((SOCKET)osfd, &wr));\n+      rv = 0;\n+    } else {\n+      _PR_MD_MAP_CONNECT_ERROR(err);\n     }\n-    return rv;\n+  }\n+  return rv;\n }\n \n-static PRInt32\n-_nt_nonblock_recv(PRFileDesc* fd, char* buf, int len, int flags,\n-                  PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    struct timeval tv, *tvp;\n-    fd_set rd;\n-    int osflags;\n-\n-    if (0 == flags) {\n-        osflags = 0;\n+static PRInt32 _nt_nonblock_recv(PRFileDesc* fd, char* buf, int len, int flags,\n+                                 PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  struct timeval tv, *tvp;\n+  fd_set rd;\n+  int osflags;\n+\n+  if (0 == flags) {\n+    osflags = 0;\n+  } else {\n+    PR_ASSERT(PR_MSG_PEEK == flags);\n+    osflags = MSG_PEEK;\n+  }\n+  while ((rv = recv(osfd, buf, len, osflags)) == -1) {\n+    if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n+        (!fd->secret->nonblocking)) {\n+      FD_ZERO(&rd);\n+      FD_SET((SOCKET)osfd, &rd);\n+      if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+        tvp = NULL;\n+      } else {\n+        tv.tv_sec = PR_IntervalToSeconds(timeout);\n+        tv.tv_usec = PR_IntervalToMicroseconds(timeout -\n+                                               PR_SecondsToInterval(tv.tv_sec));\n+        tvp = &tv;\n+      }\n+      if ((rv = _PR_NTFiberSafeSelect(0, &rd, NULL, NULL, tvp)) == -1) {\n+        _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n+        break;\n+      } else if (rv == 0) {\n+        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+        rv = -1;\n+        break;\n+      }\n     } else {\n-        PR_ASSERT(PR_MSG_PEEK == flags);\n-        osflags = MSG_PEEK;\n-    }\n-    while ((rv = recv(osfd, buf, len, osflags)) == -1) {\n-        if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n-            (!fd->secret->nonblocking)) {\n-            FD_ZERO(&rd);\n-            FD_SET((SOCKET)osfd, &rd);\n-            if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-                tvp = NULL;\n-            } else {\n-                tv.tv_sec = PR_IntervalToSeconds(timeout);\n-                tv.tv_usec = PR_IntervalToMicroseconds(timeout -\n-                                                       PR_SecondsToInterval(tv.tv_sec));\n-                tvp = &tv;\n-            }\n-            if ((rv = _PR_NTFiberSafeSelect(0, &rd, NULL, NULL, tvp)) == -1) {\n-                _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n-                break;\n-            } else if (rv == 0) {\n-                PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                rv = -1;\n-                break;\n-            }\n-        } else {\n-            _PR_MD_MAP_RECV_ERROR(err);\n-            break;\n-        }\n+      _PR_MD_MAP_RECV_ERROR(err);\n+      break;\n     }\n-    return (rv);\n+  }\n+  return (rv);\n }\n \n-static PRInt32\n-_nt_nonblock_send(PRFileDesc* fd, char* buf, int len,\n-                  PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    struct timeval tv, *tvp;\n-    fd_set wd;\n-    PRInt32 bytesSent = 0;\n-\n-    while (bytesSent < len) {\n-        while ((rv = send(osfd, buf, len, 0)) == -1) {\n-            if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n-                (!fd->secret->nonblocking)) {\n-                if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-                    tvp = NULL;\n-                } else {\n-                    tv.tv_sec = PR_IntervalToSeconds(timeout);\n-                    tv.tv_usec = PR_IntervalToMicroseconds(\n-                        timeout - PR_SecondsToInterval(tv.tv_sec));\n-                    tvp = &tv;\n-                }\n-                FD_ZERO(&wd);\n-                FD_SET((SOCKET)osfd, &wd);\n-                if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wd, NULL, tvp)) == -1) {\n-                    _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n-                    return -1;\n-                }\n-                if (rv == 0) {\n-                    PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                    return -1;\n-                }\n-            } else {\n-                _PR_MD_MAP_SEND_ERROR(err);\n-                return -1;\n-            }\n+static PRInt32 _nt_nonblock_send(PRFileDesc* fd, char* buf, int len,\n+                                 PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  struct timeval tv, *tvp;\n+  fd_set wd;\n+  PRInt32 bytesSent = 0;\n+\n+  while (bytesSent < len) {\n+    while ((rv = send(osfd, buf, len, 0)) == -1) {\n+      if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n+          (!fd->secret->nonblocking)) {\n+        if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+          tvp = NULL;\n+        } else {\n+          tv.tv_sec = PR_IntervalToSeconds(timeout);\n+          tv.tv_usec = PR_IntervalToMicroseconds(\n+              timeout - PR_SecondsToInterval(tv.tv_sec));\n+          tvp = &tv;\n         }\n-        bytesSent += rv;\n-        if (fd->secret->nonblocking) {\n-            break;\n+        FD_ZERO(&wd);\n+        FD_SET((SOCKET)osfd, &wd);\n+        if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wd, NULL, tvp)) == -1) {\n+          _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n+          return -1;\n         }\n-        if (bytesSent < len) {\n-            if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-                tvp = NULL;\n-            } else {\n-                tv.tv_sec = PR_IntervalToSeconds(timeout);\n-                tv.tv_usec = PR_IntervalToMicroseconds(timeout -\n-                                                       PR_SecondsToInterval(tv.tv_sec));\n-                tvp = &tv;\n-            }\n-            FD_ZERO(&wd);\n-            FD_SET((SOCKET)osfd, &wd);\n-            if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wd, NULL, tvp)) == -1) {\n-                _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n-                return -1;\n-            }\n-            if (rv == 0) {\n-                PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                return -1;\n-            }\n+        if (rv == 0) {\n+          PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+          return -1;\n         }\n+      } else {\n+        _PR_MD_MAP_SEND_ERROR(err);\n+        return -1;\n+      }\n+    }\n+    bytesSent += rv;\n+    if (fd->secret->nonblocking) {\n+      break;\n+    }\n+    if (bytesSent < len) {\n+      if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+        tvp = NULL;\n+      } else {\n+        tv.tv_sec = PR_IntervalToSeconds(timeout);\n+        tv.tv_usec = PR_IntervalToMicroseconds(timeout -\n+                                               PR_SecondsToInterval(tv.tv_sec));\n+        tvp = &tv;\n+      }\n+      FD_ZERO(&wd);\n+      FD_SET((SOCKET)osfd, &wd);\n+      if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wd, NULL, tvp)) == -1) {\n+        _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n+        return -1;\n+      }\n+      if (rv == 0) {\n+        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+        return -1;\n+      }\n     }\n-    return bytesSent;\n+  }\n+  return bytesSent;\n }\n \n-static PRInt32\n-_nt_nonblock_writev(PRFileDesc* fd, const PRIOVec* iov, int size,\n-                    PRIntervalTime timeout)\n-{\n-    int index;\n-    int sent = 0;\n-    int rv;\n-\n-    for (index = 0; index < size; index++) {\n-        rv =\n-            _nt_nonblock_send(fd, iov[index].iov_base, iov[index].iov_len, timeout);\n-        if (rv > 0) {\n-            sent += rv;\n-        }\n-        if (rv != iov[index].iov_len) {\n-            if (rv < 0) {\n-                if (fd->secret->nonblocking &&\n-                    (PR_GetError() == PR_WOULD_BLOCK_ERROR) && (sent > 0)) {\n-                    return sent;\n-                } else {\n-                    return -1;\n-                }\n-            }\n-            /* Only a nonblocking socket can have partial sends */\n-            PR_ASSERT(fd->secret->nonblocking);\n-            return sent;\n+static PRInt32 _nt_nonblock_writev(PRFileDesc* fd, const PRIOVec* iov, int size,\n+                                   PRIntervalTime timeout) {\n+  int index;\n+  int sent = 0;\n+  int rv;\n+\n+  for (index = 0; index < size; index++) {\n+    rv =\n+        _nt_nonblock_send(fd, iov[index].iov_base, iov[index].iov_len, timeout);\n+    if (rv > 0) {\n+      sent += rv;\n+    }\n+    if (rv != iov[index].iov_len) {\n+      if (rv < 0) {\n+        if (fd->secret->nonblocking &&\n+            (PR_GetError() == PR_WOULD_BLOCK_ERROR) && (sent > 0)) {\n+          return sent;\n+        } else {\n+          return -1;\n         }\n+      }\n+      /* Only a nonblocking socket can have partial sends */\n+      PR_ASSERT(fd->secret->nonblocking);\n+      return sent;\n     }\n+  }\n \n-    return sent;\n+  return sent;\n }\n \n-static PRInt32\n-_nt_nonblock_sendto(PRFileDesc* fd, const char* buf, int len,\n-                    const struct sockaddr* addr, int addrlen,\n-                    PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    struct timeval tv, *tvp;\n-    fd_set wd;\n-    PRInt32 bytesSent = 0;\n-\n-    while (bytesSent < len) {\n-        while ((rv = sendto(osfd, buf, len, 0, addr, addrlen)) == -1) {\n-            if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n-                (!fd->secret->nonblocking)) {\n-                if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-                    tvp = NULL;\n-                } else {\n-                    tv.tv_sec = PR_IntervalToSeconds(timeout);\n-                    tv.tv_usec = PR_IntervalToMicroseconds(\n-                        timeout - PR_SecondsToInterval(tv.tv_sec));\n-                    tvp = &tv;\n-                }\n-                FD_ZERO(&wd);\n-                FD_SET((SOCKET)osfd, &wd);\n-                if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wd, NULL, tvp)) == -1) {\n-                    _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n-                    return -1;\n-                }\n-                if (rv == 0) {\n-                    PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                    return -1;\n-                }\n-            } else {\n-                _PR_MD_MAP_SENDTO_ERROR(err);\n-                return -1;\n-            }\n+static PRInt32 _nt_nonblock_sendto(PRFileDesc* fd, const char* buf, int len,\n+                                   const struct sockaddr* addr, int addrlen,\n+                                   PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  struct timeval tv, *tvp;\n+  fd_set wd;\n+  PRInt32 bytesSent = 0;\n+\n+  while (bytesSent < len) {\n+    while ((rv = sendto(osfd, buf, len, 0, addr, addrlen)) == -1) {\n+      if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n+          (!fd->secret->nonblocking)) {\n+        if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+          tvp = NULL;\n+        } else {\n+          tv.tv_sec = PR_IntervalToSeconds(timeout);\n+          tv.tv_usec = PR_IntervalToMicroseconds(\n+              timeout - PR_SecondsToInterval(tv.tv_sec));\n+          tvp = &tv;\n         }\n-        bytesSent += rv;\n-        if (fd->secret->nonblocking) {\n-            break;\n+        FD_ZERO(&wd);\n+        FD_SET((SOCKET)osfd, &wd);\n+        if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wd, NULL, tvp)) == -1) {\n+          _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n+          return -1;\n         }\n-        if (bytesSent < len) {\n-            if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-                tvp = NULL;\n-            } else {\n-                tv.tv_sec = PR_IntervalToSeconds(timeout);\n-                tv.tv_usec = PR_IntervalToMicroseconds(timeout -\n-                                                       PR_SecondsToInterval(tv.tv_sec));\n-                tvp = &tv;\n-            }\n-            FD_ZERO(&wd);\n-            FD_SET((SOCKET)osfd, &wd);\n-            if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wd, NULL, tvp)) == -1) {\n-                _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n-                return -1;\n-            }\n-            if (rv == 0) {\n-                PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                return -1;\n-            }\n+        if (rv == 0) {\n+          PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+          return -1;\n         }\n+      } else {\n+        _PR_MD_MAP_SENDTO_ERROR(err);\n+        return -1;\n+      }\n+    }\n+    bytesSent += rv;\n+    if (fd->secret->nonblocking) {\n+      break;\n+    }\n+    if (bytesSent < len) {\n+      if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+        tvp = NULL;\n+      } else {\n+        tv.tv_sec = PR_IntervalToSeconds(timeout);\n+        tv.tv_usec = PR_IntervalToMicroseconds(timeout -\n+                                               PR_SecondsToInterval(tv.tv_sec));\n+        tvp = &tv;\n+      }\n+      FD_ZERO(&wd);\n+      FD_SET((SOCKET)osfd, &wd);\n+      if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wd, NULL, tvp)) == -1) {\n+        _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n+        return -1;\n+      }\n+      if (rv == 0) {\n+        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+        return -1;\n+      }\n     }\n-    return bytesSent;\n+  }\n+  return bytesSent;\n }\n \n-static PRInt32\n-_nt_nonblock_recvfrom(PRFileDesc* fd, char* buf, int len,\n-                      struct sockaddr* addr, int* addrlen,\n-                      PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    struct timeval tv, *tvp;\n-    fd_set rd;\n-\n-    while ((rv = recvfrom(osfd, buf, len, 0, addr, addrlen)) == -1) {\n-        if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n-            (!fd->secret->nonblocking)) {\n-            if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-                tvp = NULL;\n-            } else {\n-                tv.tv_sec = PR_IntervalToSeconds(timeout);\n-                tv.tv_usec = PR_IntervalToMicroseconds(timeout -\n-                                                       PR_SecondsToInterval(tv.tv_sec));\n-                tvp = &tv;\n-            }\n-            FD_ZERO(&rd);\n-            FD_SET((SOCKET)osfd, &rd);\n-            if ((rv = _PR_NTFiberSafeSelect(0, &rd, NULL, NULL, tvp)) == -1) {\n-                _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n-                break;\n-            } else if (rv == 0) {\n-                PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                rv = -1;\n-                break;\n-            }\n-        } else {\n-            _PR_MD_MAP_RECVFROM_ERROR(err);\n-            break;\n-        }\n+static PRInt32 _nt_nonblock_recvfrom(PRFileDesc* fd, char* buf, int len,\n+                                     struct sockaddr* addr, int* addrlen,\n+                                     PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  struct timeval tv, *tvp;\n+  fd_set rd;\n+\n+  while ((rv = recvfrom(osfd, buf, len, 0, addr, addrlen)) == -1) {\n+    if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n+        (!fd->secret->nonblocking)) {\n+      if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+        tvp = NULL;\n+      } else {\n+        tv.tv_sec = PR_IntervalToSeconds(timeout);\n+        tv.tv_usec = PR_IntervalToMicroseconds(timeout -\n+                                               PR_SecondsToInterval(tv.tv_sec));\n+        tvp = &tv;\n+      }\n+      FD_ZERO(&rd);\n+      FD_SET((SOCKET)osfd, &rd);\n+      if ((rv = _PR_NTFiberSafeSelect(0, &rd, NULL, NULL, tvp)) == -1) {\n+        _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n+        break;\n+      } else if (rv == 0) {\n+        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+        rv = -1;\n+        break;\n+      }\n+    } else {\n+      _PR_MD_MAP_RECVFROM_ERROR(err);\n+      break;\n     }\n-    return (rv);\n+  }\n+  return (rv);\n }\n \n /*\n  * UDP support: the continuation thread functions and recvfrom and sendto.\n  */\n \n-static void\n-pt_InsertTimedInternal(pt_Continuation* op)\n-{\n-    PRInt32 delta = 0;\n-    pt_Continuation* t_op = NULL;\n-    PRIntervalTime now = PR_IntervalNow(), op_tmo, qd_tmo;\n-\n+static void pt_InsertTimedInternal(pt_Continuation* op) {\n+  PRInt32 delta = 0;\n+  pt_Continuation* t_op = NULL;\n+  PRIntervalTime now = PR_IntervalNow(), op_tmo, qd_tmo;\n+\n+  /*\n+   * If this element operation isn't timed, it gets queued at the\n+   * end of the list (just after pt_tq.tail) and we're\n+   * finishd early.\n+   */\n+  if (PR_INTERVAL_NO_TIMEOUT == op->timeout) {\n+    t_op = pt_tq.tail; /* put it at the end */\n+    goto done;\n+  }\n+\n+  /*\n+   * The rest of this routine actaully deals with timed ops.\n+   */\n+\n+  if (NULL != pt_tq.op) {\n     /*\n-     * If this element operation isn't timed, it gets queued at the\n-     * end of the list (just after pt_tq.tail) and we're\n-     * finishd early.\n+     * To find where in the list to put the new operation, form\n+     * the absolute time the operations in question will expire.\n+     *\n+     * The new operation ('op') will expire at now() + op->timeout.\n+     *\n+     * The operation that will time out furthest in the future will\n+     * do so at pt_tq.epoch + pt_tq.op->timeout.\n+     *\n+     * Subsequently earlier timeouts are computed based on the latter\n+     * knowledge by subracting the timeout deltas that are stored in\n+     * the operation list. There are operation[n]->timeout ticks\n+     * between the expiration of operation[n-1] and operation[n].e e\n+     *\n+     * Therefore, the operation[n-1] will expire operation[n]->timeout\n+     * ticks prior to operation[n].\n+     *\n+     * This should be easy!\n      */\n-    if (PR_INTERVAL_NO_TIMEOUT == op->timeout) {\n-        t_op = pt_tq.tail; /* put it at the end */\n+    t_op = pt_tq.op;                      /* running pointer to queued op */\n+    op_tmo = now + op->timeout;           /* that's in absolute ticks */\n+    qd_tmo = pt_tq.epoch + t_op->timeout; /* likewise */\n+\n+    do {\n+      /*\n+       * If 'op' expires later than t_op, then insert 'op' just\n+       * ahead of t_op. Otherwise, compute when operation[n-1]\n+       * expires and try again.\n+       *\n+       * The actual different between the expiriation of 'op'\n+       * and the current operation what becomes the new operaton's\n+       * timeout interval. That interval is also subtracted from\n+       * the interval of the operation immediately following where\n+       * we stick 'op' (unless the next one isn't timed). The new\n+       * timeout assigned to 'op' takes into account the values of\n+       * now() and when the previous intervals were compured.\n+       */\n+      delta = op_tmo - qd_tmo;\n+      if (delta >= 0) {\n+        op->timeout += (now - pt_tq.epoch);\n         goto done;\n-    }\n+      }\n+\n+      qd_tmo -= t_op->timeout; /* previous operaton expiration */\n+      t_op = t_op->prev;       /* point to previous operation */\n+      if (NULL != t_op) {\n+        qd_tmo += t_op->timeout;\n+      }\n+    } while (NULL != t_op);\n \n     /*\n-     * The rest of this routine actaully deals with timed ops.\n+     * If we got here we backed off the head of the list. That means that\n+     * this timed entry has to go at the head of the list. This is just\n+     * about like having an empty timer list.\n      */\n-\n-    if (NULL != pt_tq.op) {\n-        /*\n-         * To find where in the list to put the new operation, form\n-         * the absolute time the operations in question will expire.\n-         *\n-         * The new operation ('op') will expire at now() + op->timeout.\n-         *\n-         * The operation that will time out furthest in the future will\n-         * do so at pt_tq.epoch + pt_tq.op->timeout.\n-         *\n-         * Subsequently earlier timeouts are computed based on the latter\n-         * knowledge by subracting the timeout deltas that are stored in\n-         * the operation list. There are operation[n]->timeout ticks\n-         * between the expiration of operation[n-1] and operation[n].e e\n-         *\n-         * Therefore, the operation[n-1] will expire operation[n]->timeout\n-         * ticks prior to operation[n].\n-         *\n-         * This should be easy!\n-         */\n-        t_op = pt_tq.op;                      /* running pointer to queued op */\n-        op_tmo = now + op->timeout;           /* that's in absolute ticks */\n-        qd_tmo = pt_tq.epoch + t_op->timeout; /* likewise */\n-\n-        do {\n-            /*\n-             * If 'op' expires later than t_op, then insert 'op' just\n-             * ahead of t_op. Otherwise, compute when operation[n-1]\n-             * expires and try again.\n-             *\n-             * The actual different between the expiriation of 'op'\n-             * and the current operation what becomes the new operaton's\n-             * timeout interval. That interval is also subtracted from\n-             * the interval of the operation immediately following where\n-             * we stick 'op' (unless the next one isn't timed). The new\n-             * timeout assigned to 'op' takes into account the values of\n-             * now() and when the previous intervals were compured.\n-             */\n-            delta = op_tmo - qd_tmo;\n-            if (delta >= 0) {\n-                op->timeout += (now - pt_tq.epoch);\n-                goto done;\n-            }\n-\n-            qd_tmo -= t_op->timeout; /* previous operaton expiration */\n-            t_op = t_op->prev;       /* point to previous operation */\n-            if (NULL != t_op) {\n-                qd_tmo += t_op->timeout;\n-            }\n-        } while (NULL != t_op);\n-\n-        /*\n-         * If we got here we backed off the head of the list. That means that\n-         * this timed entry has to go at the head of the list. This is just\n-         * about like having an empty timer list.\n-         */\n-        delta = op->timeout; /* $$$ is this right? */\n-    }\n+    delta = op->timeout; /* $$$ is this right? */\n+  }\n \n done:\n \n-    /*\n-     * Insert 'op' into the queue just after t_op or if t_op is null,\n-     * at the head of the list.\n-     *\n-     * If t_op is NULL, the list is currently empty and this is pretty\n-     * easy.\n-     */\n-    if (NULL == t_op) {\n-        op->prev = NULL;\n-        op->next = pt_tq.head;\n-        pt_tq.head = op;\n-        if (NULL == pt_tq.tail) {\n-            pt_tq.tail = op;\n-        } else {\n-            op->next->prev = op;\n-        }\n+  /*\n+   * Insert 'op' into the queue just after t_op or if t_op is null,\n+   * at the head of the list.\n+   *\n+   * If t_op is NULL, the list is currently empty and this is pretty\n+   * easy.\n+   */\n+  if (NULL == t_op) {\n+    op->prev = NULL;\n+    op->next = pt_tq.head;\n+    pt_tq.head = op;\n+    if (NULL == pt_tq.tail) {\n+      pt_tq.tail = op;\n     } else {\n-        op->prev = t_op;\n-        op->next = t_op->next;\n-        if (NULL != op->prev) {\n-            op->prev->next = op;\n-        }\n-        if (NULL != op->next) {\n-            op->next->prev = op;\n-        }\n-        if (t_op == pt_tq.tail) {\n-            pt_tq.tail = op;\n-        }\n-    }\n-\n-    /*\n-     * Are we adjusting our epoch, etc? Are we replacing\n-     * what was previously the element due to expire furthest\n-     * out in the future? Is this even a timed operation?\n-     */\n-    if (PR_INTERVAL_NO_TIMEOUT != op->timeout) {\n-        if ((NULL == pt_tq.op)     /* we're the one and only */\n-            || (t_op == pt_tq.op)) /* we're replacing */\n-        {\n-            pt_tq.op = op;\n-            pt_tq.epoch = now;\n-        }\n+      op->next->prev = op;\n+    }\n+  } else {\n+    op->prev = t_op;\n+    op->next = t_op->next;\n+    if (NULL != op->prev) {\n+      op->prev->next = op;\n+    }\n+    if (NULL != op->next) {\n+      op->next->prev = op;\n+    }\n+    if (t_op == pt_tq.tail) {\n+      pt_tq.tail = op;\n+    }\n+  }\n+\n+  /*\n+   * Are we adjusting our epoch, etc? Are we replacing\n+   * what was previously the element due to expire furthest\n+   * out in the future? Is this even a timed operation?\n+   */\n+  if (PR_INTERVAL_NO_TIMEOUT != op->timeout) {\n+    if ((NULL == pt_tq.op)     /* we're the one and only */\n+        || (t_op == pt_tq.op)) /* we're replacing */\n+    {\n+      pt_tq.op = op;\n+      pt_tq.epoch = now;\n     }\n+  }\n \n-    pt_tq.op_count += 1;\n+  pt_tq.op_count += 1;\n \n } /* pt_InsertTimedInternal */\n \n@@ -4201,413 +4040,399 @@ done:\n  * complete and returns to the caller the value of the next\n  * operation in the list (or NULL).\n  */\n-static pt_Continuation*\n-pt_FinishTimedInternal(pt_Continuation* op)\n-{\n-    pt_Continuation* next;\n-\n-    /* remove this one from the list */\n-    if (NULL == op->prev) {\n-        pt_tq.head = op->next;\n-    } else {\n-        op->prev->next = op->next;\n-    }\n-    if (NULL == op->next) {\n-        pt_tq.tail = op->prev;\n-    } else {\n-        op->next->prev = op->prev;\n-    }\n-\n-    /* did we happen to hit the timed op? */\n-    if (op == pt_tq.op) {\n-        pt_tq.op = op->prev;\n-    }\n-\n-    next = op->next;\n-    op->next = op->prev = NULL;\n-    op->status = pt_continuation_done;\n-\n-    pt_tq.op_count -= 1;\n+static pt_Continuation* pt_FinishTimedInternal(pt_Continuation* op) {\n+  pt_Continuation* next;\n+\n+  /* remove this one from the list */\n+  if (NULL == op->prev) {\n+    pt_tq.head = op->next;\n+  } else {\n+    op->prev->next = op->next;\n+  }\n+  if (NULL == op->next) {\n+    pt_tq.tail = op->prev;\n+  } else {\n+    op->next->prev = op->prev;\n+  }\n+\n+  /* did we happen to hit the timed op? */\n+  if (op == pt_tq.op) {\n+    pt_tq.op = op->prev;\n+  }\n+\n+  next = op->next;\n+  op->next = op->prev = NULL;\n+  op->status = pt_continuation_done;\n+\n+  pt_tq.op_count -= 1;\n #if defined(DEBUG)\n-    pt_debug.continuationsServed += 1;\n+  pt_debug.continuationsServed += 1;\n #endif\n-    PR_NotifyCondVar(op->complete);\n+  PR_NotifyCondVar(op->complete);\n \n-    return next;\n+  return next;\n } /* pt_FinishTimedInternal */\n \n-static void\n-ContinuationThread(void* arg)\n-{\n-    /* initialization */\n-    fd_set readSet, writeSet, exceptSet;\n-    struct timeval tv;\n-    SOCKET* pollingList = 0;          /* list built for polling */\n-    PRIntn pollingListUsed;           /* # entries used in the list */\n-    PRIntn pollingListNeeded;         /* # entries needed this time */\n-    PRIntn pollingSlotsAllocated = 0; /* # entries available in list */\n-    PRIntervalTime mx_select_ticks =\n-        PR_MillisecondsToInterval(PT_DEFAULT_SELECT_MSEC);\n-\n-    /* do some real work */\n-    while (1) {\n-        PRIntn rv;\n-        PRStatus status;\n-        PRIntn pollIndex;\n-        pt_Continuation* op;\n-        PRIntervalTime now = PR_IntervalNow();\n-        PRIntervalTime timeout = PR_INTERVAL_NO_TIMEOUT;\n-\n-        PR_Lock(pt_tq.ml);\n-        while (NULL == pt_tq.head) {\n-            status = PR_WaitCondVar(pt_tq.new_op, PR_INTERVAL_NO_TIMEOUT);\n-            if ((PR_FAILURE == status) &&\n-                (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n-                break;\n-            }\n-        }\n-        pollingListNeeded = pt_tq.op_count;\n-        PR_Unlock(pt_tq.ml);\n-\n-        /* Okay. We're history */\n-        if ((PR_FAILURE == status) &&\n-            (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n-            break;\n-        }\n+static void ContinuationThread(void* arg) {\n+  /* initialization */\n+  fd_set readSet, writeSet, exceptSet;\n+  struct timeval tv;\n+  SOCKET* pollingList = 0;          /* list built for polling */\n+  PRIntn pollingListUsed;           /* # entries used in the list */\n+  PRIntn pollingListNeeded;         /* # entries needed this time */\n+  PRIntn pollingSlotsAllocated = 0; /* # entries available in list */\n+  PRIntervalTime mx_select_ticks =\n+      PR_MillisecondsToInterval(PT_DEFAULT_SELECT_MSEC);\n+\n+  /* do some real work */\n+  while (1) {\n+    PRIntn rv;\n+    PRStatus status;\n+    PRIntn pollIndex;\n+    pt_Continuation* op;\n+    PRIntervalTime now = PR_IntervalNow();\n+    PRIntervalTime timeout = PR_INTERVAL_NO_TIMEOUT;\n+\n+    PR_Lock(pt_tq.ml);\n+    while (NULL == pt_tq.head) {\n+      status = PR_WaitCondVar(pt_tq.new_op, PR_INTERVAL_NO_TIMEOUT);\n+      if ((PR_FAILURE == status) &&\n+          (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n+        break;\n+      }\n+    }\n+    pollingListNeeded = pt_tq.op_count;\n+    PR_Unlock(pt_tq.ml);\n+\n+    /* Okay. We're history */\n+    if ((PR_FAILURE == status) &&\n+        (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n+      break;\n+    }\n \n-        /*\n-         * We are not holding the pt_tq.ml lock now, so more items may\n-         * get added to pt_tq during this window of time.  We hope\n-         * that 10 more spaces in the polling list should be enough.\n-         */\n+    /*\n+     * We are not holding the pt_tq.ml lock now, so more items may\n+     * get added to pt_tq during this window of time.  We hope\n+     * that 10 more spaces in the polling list should be enough.\n+     */\n \n-        FD_ZERO(&readSet);\n-        FD_ZERO(&writeSet);\n-        FD_ZERO(&exceptSet);\n-        pollingListNeeded += 10;\n-        if (pollingListNeeded > pollingSlotsAllocated) {\n-            if (NULL != pollingList) {\n-                PR_DELETE(pollingList);\n-            }\n-            pollingList = PR_MALLOC(pollingListNeeded * sizeof(PRPollDesc));\n-            PR_ASSERT(NULL != pollingList);\n-            pollingSlotsAllocated = pollingListNeeded;\n-        }\n+    FD_ZERO(&readSet);\n+    FD_ZERO(&writeSet);\n+    FD_ZERO(&exceptSet);\n+    pollingListNeeded += 10;\n+    if (pollingListNeeded > pollingSlotsAllocated) {\n+      if (NULL != pollingList) {\n+        PR_DELETE(pollingList);\n+      }\n+      pollingList = PR_MALLOC(pollingListNeeded * sizeof(PRPollDesc));\n+      PR_ASSERT(NULL != pollingList);\n+      pollingSlotsAllocated = pollingListNeeded;\n+    }\n \n #if defined(DEBUG)\n-        if (pollingListNeeded > pt_debug.pollingListMax) {\n-            pt_debug.pollingListMax = pollingListUsed;\n-        }\n+    if (pollingListNeeded > pt_debug.pollingListMax) {\n+      pt_debug.pollingListMax = pollingListUsed;\n+    }\n #endif\n \n-        /*\n-         * Build up a polling list.\n-         * This list is sorted on time. Operations that have been\n-         * interrupted are completed and not included in the list.\n-         * There is an assertion that the operation is in progress.\n-         */\n-        pollingListUsed = 0;\n-        PR_Lock(pt_tq.ml);\n-\n-        for (op = pt_tq.head; NULL != op;) {\n-            if (pt_continuation_abort == op->status) {\n-                op->result.code = -1;\n-                op->syserrno = WSAEINTR;\n-                op = pt_FinishTimedInternal(op);\n-            } else {\n-                PR_ASSERT(pt_continuation_done != op->status);\n-                op->status = pt_continuation_inprogress;\n-                if (op->event & PR_POLL_READ) {\n-                    FD_SET(op->arg1.osfd, &readSet);\n-                }\n-                if (op->event & PR_POLL_WRITE) {\n-                    FD_SET(op->arg1.osfd, &writeSet);\n-                }\n-                if (op->event & PR_POLL_EXCEPT) {\n-                    FD_SET(op->arg1.osfd, &exceptSet);\n-                }\n-                pollingList[pollingListUsed] = op->arg1.osfd;\n-                pollingListUsed += 1;\n-                if (pollingListUsed == pollingSlotsAllocated) {\n-                    break;\n-                }\n-                op = op->next;\n-            }\n+    /*\n+     * Build up a polling list.\n+     * This list is sorted on time. Operations that have been\n+     * interrupted are completed and not included in the list.\n+     * There is an assertion that the operation is in progress.\n+     */\n+    pollingListUsed = 0;\n+    PR_Lock(pt_tq.ml);\n+\n+    for (op = pt_tq.head; NULL != op;) {\n+      if (pt_continuation_abort == op->status) {\n+        op->result.code = -1;\n+        op->syserrno = WSAEINTR;\n+        op = pt_FinishTimedInternal(op);\n+      } else {\n+        PR_ASSERT(pt_continuation_done != op->status);\n+        op->status = pt_continuation_inprogress;\n+        if (op->event & PR_POLL_READ) {\n+          FD_SET(op->arg1.osfd, &readSet);\n+        }\n+        if (op->event & PR_POLL_WRITE) {\n+          FD_SET(op->arg1.osfd, &writeSet);\n         }\n+        if (op->event & PR_POLL_EXCEPT) {\n+          FD_SET(op->arg1.osfd, &exceptSet);\n+        }\n+        pollingList[pollingListUsed] = op->arg1.osfd;\n+        pollingListUsed += 1;\n+        if (pollingListUsed == pollingSlotsAllocated) {\n+          break;\n+        }\n+        op = op->next;\n+      }\n+    }\n \n-        PR_Unlock(pt_tq.ml);\n+    PR_Unlock(pt_tq.ml);\n \n-        /*\n-         * If 'op' isn't NULL at this point, then we didn't get to\n-         * the end of the list. That means that more items got added\n-         * to the list than we anticipated. So, forget this iteration,\n-         * go around the horn again.\n-         * One would hope this doesn't happen all that often.\n-         */\n-        if (NULL != op) {\n+    /*\n+     * If 'op' isn't NULL at this point, then we didn't get to\n+     * the end of the list. That means that more items got added\n+     * to the list than we anticipated. So, forget this iteration,\n+     * go around the horn again.\n+     * One would hope this doesn't happen all that often.\n+     */\n+    if (NULL != op) {\n #if defined(DEBUG)\n-            pt_debug.predictionsFoiled += 1; /* keep track */\n+      pt_debug.predictionsFoiled += 1; /* keep track */\n #endif\n-            continue; /* make it rethink things */\n-        }\n-\n-        /* there's a chance that all ops got blown away */\n-        if (NULL == pt_tq.head) {\n-            continue;\n-        }\n-        /* if not, we know this is the shortest timeout */\n-        timeout = pt_tq.head->timeout;\n-\n-        /*\n-         * We don't want to wait forever on this poll. So keep\n-         * the interval down. The operations, if they are timed,\n-         * still have to timeout, while those that are not timed\n-         * should persist forever. But they may be aborted. That's\n-         * what this anxiety is all about.\n-         */\n-        if (timeout > mx_select_ticks) {\n-            timeout = mx_select_ticks;\n-        }\n+      continue; /* make it rethink things */\n+    }\n \n-        if (PR_INTERVAL_NO_TIMEOUT != pt_tq.head->timeout) {\n-            pt_tq.head->timeout -= timeout;\n-        }\n-        tv.tv_sec = PR_IntervalToSeconds(timeout);\n-        tv.tv_usec = PR_IntervalToMicroseconds(timeout) % PR_USEC_PER_SEC;\n-\n-        rv = select(0, &readSet, &writeSet, &exceptSet, &tv);\n-\n-        if (0 == rv) /* poll timed out - what about leading op? */\n-        {\n-            if (0 == pt_tq.head->timeout) {\n-                /*\n-                 * The leading element of the timed queue has timed\n-                 * out. Get rid of it. In any case go around the\n-                 * loop again, computing the polling list, checking\n-                 * for interrupted operations.\n-                 */\n-                PR_Lock(pt_tq.ml);\n-                do {\n-                    pt_tq.head->result.code = -1;\n-                    pt_tq.head->syserrno = WSAETIMEDOUT;\n-                    op = pt_FinishTimedInternal(pt_tq.head);\n-                } while ((NULL != op) && (0 == op->timeout));\n-                PR_Unlock(pt_tq.ml);\n-            }\n-            continue;\n-        }\n+    /* there's a chance that all ops got blown away */\n+    if (NULL == pt_tq.head) {\n+      continue;\n+    }\n+    /* if not, we know this is the shortest timeout */\n+    timeout = pt_tq.head->timeout;\n \n-        if (-1 == rv && (WSAGetLastError() == WSAEINTR ||\n-                         WSAGetLastError() == WSAEINPROGRESS)) {\n-            continue; /* go around the loop again */\n-        }\n+    /*\n+     * We don't want to wait forever on this poll. So keep\n+     * the interval down. The operations, if they are timed,\n+     * still have to timeout, while those that are not timed\n+     * should persist forever. But they may be aborted. That's\n+     * what this anxiety is all about.\n+     */\n+    if (timeout > mx_select_ticks) {\n+      timeout = mx_select_ticks;\n+    }\n \n-        /*\n-         * select() says that something in our list is ready for some more\n-         * action or is an invalid fd. Find it, load up the operation and\n-         * see what happens.\n-         */\n+    if (PR_INTERVAL_NO_TIMEOUT != pt_tq.head->timeout) {\n+      pt_tq.head->timeout -= timeout;\n+    }\n+    tv.tv_sec = PR_IntervalToSeconds(timeout);\n+    tv.tv_usec = PR_IntervalToMicroseconds(timeout) % PR_USEC_PER_SEC;\n \n-        PR_ASSERT(rv > 0 || WSAGetLastError() == WSAENOTSOCK);\n+    rv = select(0, &readSet, &writeSet, &exceptSet, &tv);\n \n+    if (0 == rv) /* poll timed out - what about leading op? */\n+    {\n+      if (0 == pt_tq.head->timeout) {\n         /*\n-         * $$$ There's a problem here. I'm running the operations list\n-         * and I'm not holding any locks. I don't want to hold the lock\n-         * and do the operation, so this is really messed up..\n-         *\n-         * This may work out okay. The rule is that only this thread,\n-         * the continuation thread, can remove elements from the list.\n-         * Therefore, the list is at worst, longer than when we built\n-         * the polling list.\n+         * The leading element of the timed queue has timed\n+         * out. Get rid of it. In any case go around the\n+         * loop again, computing the polling list, checking\n+         * for interrupted operations.\n          */\n-        op = pt_tq.head;\n-        for (pollIndex = 0; pollIndex < pollingListUsed; ++pollIndex) {\n-            PRInt16 revents = 0;\n+        PR_Lock(pt_tq.ml);\n+        do {\n+          pt_tq.head->result.code = -1;\n+          pt_tq.head->syserrno = WSAETIMEDOUT;\n+          op = pt_FinishTimedInternal(pt_tq.head);\n+        } while ((NULL != op) && (0 == op->timeout));\n+        PR_Unlock(pt_tq.ml);\n+      }\n+      continue;\n+    }\n \n-            PR_ASSERT(NULL != op);\n+    if (-1 == rv && (WSAGetLastError() == WSAEINTR ||\n+                     WSAGetLastError() == WSAEINPROGRESS)) {\n+      continue; /* go around the loop again */\n+    }\n \n-            /*\n-             * This one wants attention. Redo the operation.\n-             * We know that there can only be more elements\n-             * in the op list than we knew about when we created\n-             * the poll list. Therefore, we might have to skip\n-             * a few ops to find the right one to operation on.\n-             */\n-            while (pollingList[pollIndex] != op->arg1.osfd) {\n-                op = op->next;\n-                PR_ASSERT(NULL != op);\n-            }\n+    /*\n+     * select() says that something in our list is ready for some more\n+     * action or is an invalid fd. Find it, load up the operation and\n+     * see what happens.\n+     */\n \n-            if (FD_ISSET(op->arg1.osfd, &readSet)) {\n-                revents |= PR_POLL_READ;\n-            }\n-            if (FD_ISSET(op->arg1.osfd, &writeSet)) {\n-                revents |= PR_POLL_WRITE;\n-            }\n-            if (FD_ISSET(op->arg1.osfd, &exceptSet)) {\n-                revents |= PR_POLL_EXCEPT;\n-            }\n+    PR_ASSERT(rv > 0 || WSAGetLastError() == WSAENOTSOCK);\n \n-            /*\n-             * Sip over all those not in progress. They'll be\n-             * pruned next time we build a polling list. Call\n-             * the continuation function. If it reports completion,\n-             * finish off the operation.\n-             */\n-            if (revents && (pt_continuation_inprogress == op->status) &&\n-                (op->function(op, revents))) {\n-                PR_Lock(pt_tq.ml);\n-                op = pt_FinishTimedInternal(op);\n-                PR_Unlock(pt_tq.ml);\n-            }\n-        }\n-    }\n-    if (NULL != pollingList) {\n-        PR_DELETE(pollingList);\n+    /*\n+     * $$$ There's a problem here. I'm running the operations list\n+     * and I'm not holding any locks. I don't want to hold the lock\n+     * and do the operation, so this is really messed up..\n+     *\n+     * This may work out okay. The rule is that only this thread,\n+     * the continuation thread, can remove elements from the list.\n+     * Therefore, the list is at worst, longer than when we built\n+     * the polling list.\n+     */\n+    op = pt_tq.head;\n+    for (pollIndex = 0; pollIndex < pollingListUsed; ++pollIndex) {\n+      PRInt16 revents = 0;\n+\n+      PR_ASSERT(NULL != op);\n+\n+      /*\n+       * This one wants attention. Redo the operation.\n+       * We know that there can only be more elements\n+       * in the op list than we knew about when we created\n+       * the poll list. Therefore, we might have to skip\n+       * a few ops to find the right one to operation on.\n+       */\n+      while (pollingList[pollIndex] != op->arg1.osfd) {\n+        op = op->next;\n+        PR_ASSERT(NULL != op);\n+      }\n+\n+      if (FD_ISSET(op->arg1.osfd, &readSet)) {\n+        revents |= PR_POLL_READ;\n+      }\n+      if (FD_ISSET(op->arg1.osfd, &writeSet)) {\n+        revents |= PR_POLL_WRITE;\n+      }\n+      if (FD_ISSET(op->arg1.osfd, &exceptSet)) {\n+        revents |= PR_POLL_EXCEPT;\n+      }\n+\n+      /*\n+       * Sip over all those not in progress. They'll be\n+       * pruned next time we build a polling list. Call\n+       * the continuation function. If it reports completion,\n+       * finish off the operation.\n+       */\n+      if (revents && (pt_continuation_inprogress == op->status) &&\n+          (op->function(op, revents))) {\n+        PR_Lock(pt_tq.ml);\n+        op = pt_FinishTimedInternal(op);\n+        PR_Unlock(pt_tq.ml);\n+      }\n     }\n+  }\n+  if (NULL != pollingList) {\n+    PR_DELETE(pollingList);\n+  }\n } /* ContinuationThread */\n \n-static int\n-pt_Continue(pt_Continuation* op)\n-{\n-    PRStatus rv;\n-    /* Finish filling in the blank slots */\n-    op->status = pt_continuation_sumbitted;\n-    op->complete = PR_NewCondVar(pt_tq.ml);\n+static int pt_Continue(pt_Continuation* op) {\n+  PRStatus rv;\n+  /* Finish filling in the blank slots */\n+  op->status = pt_continuation_sumbitted;\n+  op->complete = PR_NewCondVar(pt_tq.ml);\n \n-    PR_Lock(pt_tq.ml); /* we provide the locking */\n+  PR_Lock(pt_tq.ml); /* we provide the locking */\n \n-    pt_InsertTimedInternal(op); /* insert in the structure */\n+  pt_InsertTimedInternal(op); /* insert in the structure */\n \n-    PR_NotifyCondVar(pt_tq.new_op); /* notify the continuation thread */\n+  PR_NotifyCondVar(pt_tq.new_op); /* notify the continuation thread */\n \n-    while (pt_continuation_done != op->status) /* wait for completion */\n-    {\n-        rv = PR_WaitCondVar(op->complete, PR_INTERVAL_NO_TIMEOUT);\n-        /*\n-         * If we get interrupted, we set state the continuation thread will\n-         * see and allow it to finish the I/O operation w/ error. That way\n-         * the rule that only the continuation thread is removing elements\n-         * from the list is still valid.\n-         *\n-         * Don't call interrupt on the continuation thread. That'll just\n-         * piss him off. He's cycling around at least every mx_select_ticks\n-         * anyhow and should notice the request in there.\n-         */\n-        if ((PR_FAILURE == rv) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n-            op->status = pt_continuation_abort; /* our status */\n-        }\n+  while (pt_continuation_done != op->status) /* wait for completion */\n+  {\n+    rv = PR_WaitCondVar(op->complete, PR_INTERVAL_NO_TIMEOUT);\n+    /*\n+     * If we get interrupted, we set state the continuation thread will\n+     * see and allow it to finish the I/O operation w/ error. That way\n+     * the rule that only the continuation thread is removing elements\n+     * from the list is still valid.\n+     *\n+     * Don't call interrupt on the continuation thread. That'll just\n+     * piss him off. He's cycling around at least every mx_select_ticks\n+     * anyhow and should notice the request in there.\n+     */\n+    if ((PR_FAILURE == rv) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n+      op->status = pt_continuation_abort; /* our status */\n     }\n+  }\n \n-    PR_Unlock(pt_tq.ml); /* we provide the locking */\n+  PR_Unlock(pt_tq.ml); /* we provide the locking */\n \n-    PR_DestroyCondVar(op->complete);\n+  PR_DestroyCondVar(op->complete);\n \n-    return op->result.code; /* and the primary answer */\n+  return op->result.code; /* and the primary answer */\n } /* pt_Continue */\n \n-static PRBool\n-pt_sendto_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    PRIntn bytes =\n-        sendto(op->arg1.osfd, op->arg2.buffer, op->arg3.amount, op->arg4.flags,\n-               (struct sockaddr*)op->arg5.addr, sizeof(*(op->arg5.addr)));\n-    op->syserrno = WSAGetLastError();\n-    if (bytes > 0) /* this is progress */\n-    {\n-        char* bp = op->arg2.buffer;\n-        bp += bytes; /* adjust the buffer pointer */\n-        op->arg2.buffer = bp;\n-        op->result.code += bytes; /* accumulate the number sent */\n-        op->arg3.amount -= bytes; /* and reduce the required count */\n-        return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;\n-    } else\n-        return ((-1 == bytes) && (WSAEWOULDBLOCK == op->syserrno)) ? PR_FALSE\n-                                                                   : PR_TRUE;\n+static PRBool pt_sendto_cont(pt_Continuation* op, PRInt16 revents) {\n+  PRIntn bytes =\n+      sendto(op->arg1.osfd, op->arg2.buffer, op->arg3.amount, op->arg4.flags,\n+             (struct sockaddr*)op->arg5.addr, sizeof(*(op->arg5.addr)));\n+  op->syserrno = WSAGetLastError();\n+  if (bytes > 0) /* this is progress */\n+  {\n+    char* bp = op->arg2.buffer;\n+    bp += bytes; /* adjust the buffer pointer */\n+    op->arg2.buffer = bp;\n+    op->result.code += bytes; /* accumulate the number sent */\n+    op->arg3.amount -= bytes; /* and reduce the required count */\n+    return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;\n+  } else\n+    return ((-1 == bytes) && (WSAEWOULDBLOCK == op->syserrno)) ? PR_FALSE\n+                                                               : PR_TRUE;\n } /* pt_sendto_cont */\n \n-static PRBool\n-pt_recvfrom_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    PRIntn addr_len = sizeof(*(op->arg5.addr));\n-    op->result.code =\n-        recvfrom(op->arg1.osfd, op->arg2.buffer, op->arg3.amount, op->arg4.flags,\n-                 (struct sockaddr*)op->arg5.addr, &addr_len);\n-    op->syserrno = WSAGetLastError();\n-    return ((-1 == op->result.code) && (WSAEWOULDBLOCK == op->syserrno))\n-               ? PR_FALSE\n-               : PR_TRUE;\n+static PRBool pt_recvfrom_cont(pt_Continuation* op, PRInt16 revents) {\n+  PRIntn addr_len = sizeof(*(op->arg5.addr));\n+  op->result.code =\n+      recvfrom(op->arg1.osfd, op->arg2.buffer, op->arg3.amount, op->arg4.flags,\n+               (struct sockaddr*)op->arg5.addr, &addr_len);\n+  op->syserrno = WSAGetLastError();\n+  return ((-1 == op->result.code) && (WSAEWOULDBLOCK == op->syserrno))\n+             ? PR_FALSE\n+             : PR_TRUE;\n } /* pt_recvfrom_cont */\n \n-static PRInt32\n-pt_SendTo(SOCKET osfd, const void* buf, PRInt32 amount,\n-          PRInt32 flags, const PRNetAddr* addr, PRIntn addrlen,\n-          PRIntervalTime timeout)\n-{\n-    PRInt32 bytes = -1, err;\n-    PRBool fNeedContinue = PR_FALSE;\n-\n-    bytes = sendto(osfd, buf, amount, flags, (struct sockaddr*)addr,\n-                   PR_NETADDR_SIZE(addr));\n-    if (bytes == -1) {\n-        if ((err = WSAGetLastError()) == WSAEWOULDBLOCK) {\n-            fNeedContinue = PR_TRUE;\n-        } else {\n-            _PR_MD_MAP_SENDTO_ERROR(err);\n-        }\n-    }\n-    if (fNeedContinue == PR_TRUE) {\n-        pt_Continuation op;\n-        op.arg1.osfd = osfd;\n-        op.arg2.buffer = (void*)buf;\n-        op.arg3.amount = amount;\n-        op.arg4.flags = flags;\n-        op.arg5.addr = (PRNetAddr*)addr;\n-        op.timeout = timeout;\n-        op.result.code = 0; /* initialize the number sent */\n-        op.function = pt_sendto_cont;\n-        op.event = PR_POLL_WRITE | PR_POLL_EXCEPT;\n-        bytes = pt_Continue(&op);\n-        if (bytes < 0) {\n-            WSASetLastError(op.syserrno);\n-            _PR_MD_MAP_SENDTO_ERROR(op.syserrno);\n-        }\n-    }\n-    return bytes;\n+static PRInt32 pt_SendTo(SOCKET osfd, const void* buf, PRInt32 amount,\n+                         PRInt32 flags, const PRNetAddr* addr, PRIntn addrlen,\n+                         PRIntervalTime timeout) {\n+  PRInt32 bytes = -1, err;\n+  PRBool fNeedContinue = PR_FALSE;\n+\n+  bytes = sendto(osfd, buf, amount, flags, (struct sockaddr*)addr,\n+                 PR_NETADDR_SIZE(addr));\n+  if (bytes == -1) {\n+    if ((err = WSAGetLastError()) == WSAEWOULDBLOCK) {\n+      fNeedContinue = PR_TRUE;\n+    } else {\n+      _PR_MD_MAP_SENDTO_ERROR(err);\n+    }\n+  }\n+  if (fNeedContinue == PR_TRUE) {\n+    pt_Continuation op;\n+    op.arg1.osfd = osfd;\n+    op.arg2.buffer = (void*)buf;\n+    op.arg3.amount = amount;\n+    op.arg4.flags = flags;\n+    op.arg5.addr = (PRNetAddr*)addr;\n+    op.timeout = timeout;\n+    op.result.code = 0; /* initialize the number sent */\n+    op.function = pt_sendto_cont;\n+    op.event = PR_POLL_WRITE | PR_POLL_EXCEPT;\n+    bytes = pt_Continue(&op);\n+    if (bytes < 0) {\n+      WSASetLastError(op.syserrno);\n+      _PR_MD_MAP_SENDTO_ERROR(op.syserrno);\n+    }\n+  }\n+  return bytes;\n } /* pt_SendTo */\n \n-static PRInt32\n-pt_RecvFrom(SOCKET osfd, void* buf, PRInt32 amount,\n-            PRInt32 flags, PRNetAddr* addr, PRIntn* addr_len,\n-            PRIntervalTime timeout)\n-{\n-    PRInt32 bytes = -1, err;\n-    PRBool fNeedContinue = PR_FALSE;\n-\n-    bytes = recvfrom(osfd, buf, amount, flags, (struct sockaddr*)addr, addr_len);\n-    if (bytes == -1) {\n-        if ((err = WSAGetLastError()) == WSAEWOULDBLOCK) {\n-            fNeedContinue = PR_TRUE;\n-        } else {\n-            _PR_MD_MAP_RECVFROM_ERROR(err);\n-        }\n-    }\n-\n-    if (fNeedContinue == PR_TRUE) {\n-        pt_Continuation op;\n-        op.arg1.osfd = osfd;\n-        op.arg2.buffer = buf;\n-        op.arg3.amount = amount;\n-        op.arg4.flags = flags;\n-        op.arg5.addr = addr;\n-        op.timeout = timeout;\n-        op.function = pt_recvfrom_cont;\n-        op.event = PR_POLL_READ | PR_POLL_EXCEPT;\n-        bytes = pt_Continue(&op);\n-        if (bytes < 0) {\n-            WSASetLastError(op.syserrno);\n-            _PR_MD_MAP_RECVFROM_ERROR(op.syserrno);\n-        }\n-    }\n-    return bytes;\n+static PRInt32 pt_RecvFrom(SOCKET osfd, void* buf, PRInt32 amount,\n+                           PRInt32 flags, PRNetAddr* addr, PRIntn* addr_len,\n+                           PRIntervalTime timeout) {\n+  PRInt32 bytes = -1, err;\n+  PRBool fNeedContinue = PR_FALSE;\n+\n+  bytes = recvfrom(osfd, buf, amount, flags, (struct sockaddr*)addr, addr_len);\n+  if (bytes == -1) {\n+    if ((err = WSAGetLastError()) == WSAEWOULDBLOCK) {\n+      fNeedContinue = PR_TRUE;\n+    } else {\n+      _PR_MD_MAP_RECVFROM_ERROR(err);\n+    }\n+  }\n+\n+  if (fNeedContinue == PR_TRUE) {\n+    pt_Continuation op;\n+    op.arg1.osfd = osfd;\n+    op.arg2.buffer = buf;\n+    op.arg3.amount = amount;\n+    op.arg4.flags = flags;\n+    op.arg5.addr = addr;\n+    op.timeout = timeout;\n+    op.function = pt_recvfrom_cont;\n+    op.event = PR_POLL_READ | PR_POLL_EXCEPT;\n+    bytes = pt_Continue(&op);\n+    if (bytes < 0) {\n+      WSASetLastError(op.syserrno);\n+      _PR_MD_MAP_RECVFROM_ERROR(op.syserrno);\n+    }\n+  }\n+  return bytes;\n } /* pt_RecvFrom */\ndiff --git a/nspr/pr/src/md/windows/ntmisc.c b/nspr/pr/src/md/windows/ntmisc.c\nindex 7cbee31..63842eb 100644\n--- a/nspr/pr/src/md/windows/ntmisc.c\n+++ b/nspr/pr/src/md/windows/ntmisc.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,22 +12,14 @@\n #include <math.h> /* for fabs() */\n #include <windows.h>\n \n-char*\n-_PR_MD_GET_ENV(const char* name)\n-{\n-    return getenv(name);\n-}\n+char* _PR_MD_GET_ENV(const char* name) { return getenv(name); }\n \n /*\n ** _PR_MD_PUT_ENV() -- add or change environment variable\n **\n **\n */\n-PRIntn\n-_PR_MD_PUT_ENV(const char* name)\n-{\n-    return (putenv(name));\n-}\n+PRIntn _PR_MD_PUT_ENV(const char* name) { return (putenv(name)); }\n \n /*\n  **************************************************************************\n@@ -52,28 +45,24 @@ const PRTime _pr_filetime_divisor = 10i64;\n \n #ifdef WINCE\n \n-#define FILETIME_TO_INT64(ft) \\\n+#  define FILETIME_TO_INT64(ft) \\\n     (((PRInt64)ft.dwHighDateTime) << 32 | (PRInt64)ft.dwLowDateTime)\n \n-static void\n-LowResTime(LPFILETIME lpft)\n-{\n-    GetCurrentFT(lpft);\n-}\n+static void LowResTime(LPFILETIME lpft) { GetCurrentFT(lpft); }\n \n typedef struct CalibrationData {\n-    long double freq;         /* The performance counter frequency */\n-    long double offset;       /* The low res 'epoch' */\n-    long double timer_offset; /* The high res 'epoch' */\n+  long double freq;         /* The performance counter frequency */\n+  long double offset;       /* The low res 'epoch' */\n+  long double timer_offset; /* The high res 'epoch' */\n \n-    /* The last high res time that we returned since recalibrating */\n-    PRInt64 last;\n+  /* The last high res time that we returned since recalibrating */\n+  PRInt64 last;\n \n-    PRBool calibrated;\n+  PRBool calibrated;\n \n-    CRITICAL_SECTION data_lock;\n-    CRITICAL_SECTION calibration_lock;\n-    PRInt64 granularity;\n+  CRITICAL_SECTION data_lock;\n+  CRITICAL_SECTION calibration_lock;\n+  PRInt64 granularity;\n } CalibrationData;\n \n static CalibrationData calibration;\n@@ -81,84 +70,78 @@ static CalibrationData calibration;\n typedef void (*GetSystemTimeAsFileTimeFcn)(LPFILETIME);\n static GetSystemTimeAsFileTimeFcn ce6_GetSystemTimeAsFileTime = NULL;\n \n-static void\n-NowCalibrate(void)\n-{\n-    FILETIME ft, ftStart;\n-    LARGE_INTEGER liFreq, now;\n+static void NowCalibrate(void) {\n+  FILETIME ft, ftStart;\n+  LARGE_INTEGER liFreq, now;\n \n-    if (calibration.freq == 0.0) {\n-        if (!QueryPerformanceFrequency(&liFreq)) {\n-            /* High-performance timer is unavailable */\n-            calibration.freq = -1.0;\n-        } else {\n-            calibration.freq = (long double)liFreq.QuadPart;\n-        }\n+  if (calibration.freq == 0.0) {\n+    if (!QueryPerformanceFrequency(&liFreq)) {\n+      /* High-performance timer is unavailable */\n+      calibration.freq = -1.0;\n+    } else {\n+      calibration.freq = (long double)liFreq.QuadPart;\n     }\n-    if (calibration.freq > 0.0) {\n-        PRInt64 calibrationDelta = 0;\n-        /*\n-         * By wrapping a timeBegin/EndPeriod pair of calls around this loop,\n-         * the loop seems to take much less time (1 ms vs 15ms) on Vista.\n-         */\n-        timeBeginPeriod(1);\n-        LowResTime(&ftStart);\n-        do {\n-            LowResTime(&ft);\n-        } while (memcmp(&ftStart, &ft, sizeof(ft)) == 0);\n-        timeEndPeriod(1);\n+  }\n+  if (calibration.freq > 0.0) {\n+    PRInt64 calibrationDelta = 0;\n+    /*\n+     * By wrapping a timeBegin/EndPeriod pair of calls around this loop,\n+     * the loop seems to take much less time (1 ms vs 15ms) on Vista.\n+     */\n+    timeBeginPeriod(1);\n+    LowResTime(&ftStart);\n+    do {\n+      LowResTime(&ft);\n+    } while (memcmp(&ftStart, &ft, sizeof(ft)) == 0);\n+    timeEndPeriod(1);\n \n-        calibration.granularity =\n-            (FILETIME_TO_INT64(ft) - FILETIME_TO_INT64(ftStart)) / 10;\n+    calibration.granularity =\n+        (FILETIME_TO_INT64(ft) - FILETIME_TO_INT64(ftStart)) / 10;\n \n-        QueryPerformanceCounter(&now);\n+    QueryPerformanceCounter(&now);\n \n-        calibration.offset = (long double)FILETIME_TO_INT64(ft);\n-        calibration.timer_offset = (long double)now.QuadPart;\n-        /*\n-         * The windows epoch is around 1600. The unix epoch is around 1970.\n-         * _pr_filetime_offset is the difference (in windows time units which\n-         * are 10 times more highres than the JS time unit)\n-         */\n-        calibration.offset -= _pr_filetime_offset;\n-        calibration.offset *= 0.1;\n-        calibration.last = 0;\n+    calibration.offset = (long double)FILETIME_TO_INT64(ft);\n+    calibration.timer_offset = (long double)now.QuadPart;\n+    /*\n+     * The windows epoch is around 1600. The unix epoch is around 1970.\n+     * _pr_filetime_offset is the difference (in windows time units which\n+     * are 10 times more highres than the JS time unit)\n+     */\n+    calibration.offset -= _pr_filetime_offset;\n+    calibration.offset *= 0.1;\n+    calibration.last = 0;\n \n-        calibration.calibrated = PR_TRUE;\n-    }\n+    calibration.calibrated = PR_TRUE;\n+  }\n }\n \n-#define CALIBRATIONLOCK_SPINCOUNT 0\n-#define DATALOCK_SPINCOUNT 4096\n-#define LASTLOCK_SPINCOUNT 4096\n-\n-void\n-_MD_InitTime(void)\n-{\n-    /* try for CE6 GetSystemTimeAsFileTime first */\n-    HANDLE h = GetModuleHandleW(L\"coredll.dll\");\n-    ce6_GetSystemTimeAsFileTime =\n-        (GetSystemTimeAsFileTimeFcn)GetProcAddressA(h, \"GetSystemTimeAsFileTime\");\n-\n-    /* otherwise go the slow route */\n-    if (ce6_GetSystemTimeAsFileTime == NULL) {\n-        memset(&calibration, 0, sizeof(calibration));\n-        NowCalibrate();\n-        InitializeCriticalSection(&calibration.calibration_lock);\n-        InitializeCriticalSection(&calibration.data_lock);\n-    }\n+#  define CALIBRATIONLOCK_SPINCOUNT 0\n+#  define DATALOCK_SPINCOUNT 4096\n+#  define LASTLOCK_SPINCOUNT 4096\n+\n+void _MD_InitTime(void) {\n+  /* try for CE6 GetSystemTimeAsFileTime first */\n+  HANDLE h = GetModuleHandleW(L\"coredll.dll\");\n+  ce6_GetSystemTimeAsFileTime =\n+      (GetSystemTimeAsFileTimeFcn)GetProcAddressA(h, \"GetSystemTimeAsFileTime\");\n+\n+  /* otherwise go the slow route */\n+  if (ce6_GetSystemTimeAsFileTime == NULL) {\n+    memset(&calibration, 0, sizeof(calibration));\n+    NowCalibrate();\n+    InitializeCriticalSection(&calibration.calibration_lock);\n+    InitializeCriticalSection(&calibration.data_lock);\n+  }\n }\n \n-void\n-_MD_CleanupTime(void)\n-{\n-    if (ce6_GetSystemTimeAsFileTime == NULL) {\n-        DeleteCriticalSection(&calibration.calibration_lock);\n-        DeleteCriticalSection(&calibration.data_lock);\n-    }\n+void _MD_CleanupTime(void) {\n+  if (ce6_GetSystemTimeAsFileTime == NULL) {\n+    DeleteCriticalSection(&calibration.calibration_lock);\n+    DeleteCriticalSection(&calibration.data_lock);\n+  }\n }\n \n-#define MUTEX_SETSPINCOUNT(m, c)\n+#  define MUTEX_SETSPINCOUNT(m, c)\n \n /*\n  *-----------------------------------------------------------------------\n@@ -175,156 +158,154 @@ _MD_CleanupTime(void)\n  */\n \n PR_IMPLEMENT(PRTime)\n-PR_Now(void)\n-{\n-    long double lowresTime, highresTimerValue;\n-    FILETIME ft;\n-    LARGE_INTEGER now;\n-    PRBool calibrated = PR_FALSE;\n-    PRBool needsCalibration = PR_FALSE;\n-    PRInt64 returnedTime;\n-    long double cachedOffset = 0.0;\n-\n-    if (ce6_GetSystemTimeAsFileTime) {\n-        union {\n-            FILETIME ft;\n-            PRTime prt;\n-        } currentTime;\n-\n-        PR_ASSERT(sizeof(FILETIME) == sizeof(PRTime));\n-\n-        ce6_GetSystemTimeAsFileTime(&currentTime.ft);\n-\n-        /* written this way on purpose, since the second term becomes\n-         * a constant, and the entire expression is faster to execute.\n+PR_Now(void) {\n+  long double lowresTime, highresTimerValue;\n+  FILETIME ft;\n+  LARGE_INTEGER now;\n+  PRBool calibrated = PR_FALSE;\n+  PRBool needsCalibration = PR_FALSE;\n+  PRInt64 returnedTime;\n+  long double cachedOffset = 0.0;\n+\n+  if (ce6_GetSystemTimeAsFileTime) {\n+    union {\n+      FILETIME ft;\n+      PRTime prt;\n+    } currentTime;\n+\n+    PR_ASSERT(sizeof(FILETIME) == sizeof(PRTime));\n+\n+    ce6_GetSystemTimeAsFileTime(&currentTime.ft);\n+\n+    /* written this way on purpose, since the second term becomes\n+     * a constant, and the entire expression is faster to execute.\n+     */\n+    return currentTime.prt / _pr_filetime_divisor -\n+           _pr_filetime_offset / _pr_filetime_divisor;\n+  }\n+\n+  do {\n+    if (!calibration.calibrated || needsCalibration) {\n+      EnterCriticalSection(&calibration.calibration_lock);\n+      EnterCriticalSection(&calibration.data_lock);\n+\n+      /* Recalibrate only if no one else did before us */\n+      if (calibration.offset == cachedOffset) {\n+        /*\n+         * Since calibration can take a while, make any other\n+         * threads immediately wait\n          */\n-        return currentTime.prt / _pr_filetime_divisor -\n-               _pr_filetime_offset / _pr_filetime_divisor;\n+        MUTEX_SETSPINCOUNT(&calibration.data_lock, 0);\n+\n+        NowCalibrate();\n+\n+        calibrated = PR_TRUE;\n+\n+        /* Restore spin count */\n+        MUTEX_SETSPINCOUNT(&calibration.data_lock, DATALOCK_SPINCOUNT);\n+      }\n+      LeaveCriticalSection(&calibration.data_lock);\n+      LeaveCriticalSection(&calibration.calibration_lock);\n     }\n \n-    do {\n-        if (!calibration.calibrated || needsCalibration) {\n-            EnterCriticalSection(&calibration.calibration_lock);\n-            EnterCriticalSection(&calibration.data_lock);\n-\n-            /* Recalibrate only if no one else did before us */\n-            if (calibration.offset == cachedOffset) {\n-                /*\n-                 * Since calibration can take a while, make any other\n-                 * threads immediately wait\n-                 */\n-                MUTEX_SETSPINCOUNT(&calibration.data_lock, 0);\n-\n-                NowCalibrate();\n-\n-                calibrated = PR_TRUE;\n-\n-                /* Restore spin count */\n-                MUTEX_SETSPINCOUNT(&calibration.data_lock, DATALOCK_SPINCOUNT);\n-            }\n-            LeaveCriticalSection(&calibration.data_lock);\n-            LeaveCriticalSection(&calibration.calibration_lock);\n-        }\n+    /* Calculate a low resolution time */\n+    LowResTime(&ft);\n+    lowresTime =\n+        ((long double)(FILETIME_TO_INT64(ft) - _pr_filetime_offset)) * 0.1;\n \n-        /* Calculate a low resolution time */\n-        LowResTime(&ft);\n-        lowresTime =\n-            ((long double)(FILETIME_TO_INT64(ft) - _pr_filetime_offset)) * 0.1;\n-\n-        if (calibration.freq > 0.0) {\n-            long double highresTime, diff;\n-            DWORD timeAdjustment, timeIncrement;\n-            BOOL timeAdjustmentDisabled;\n-\n-            /* Default to 15.625 ms if the syscall fails */\n-            long double skewThreshold = 15625.25;\n-\n-            /* Grab high resolution time */\n-            QueryPerformanceCounter(&now);\n-            highresTimerValue = (long double)now.QuadPart;\n-\n-            EnterCriticalSection(&calibration.data_lock);\n-            highresTime = calibration.offset +\n-                          1000000L * (highresTimerValue - calibration.timer_offset) /\n-                              calibration.freq;\n-            cachedOffset = calibration.offset;\n-\n-            /*\n-             * On some dual processor/core systems, we might get an earlier\n-             * time so we cache the last time that we returned.\n-             */\n-            calibration.last = PR_MAX(calibration.last, (PRInt64)highresTime);\n-            returnedTime = calibration.last;\n-            LeaveCriticalSection(&calibration.data_lock);\n-\n-            /* Get an estimate of clock ticks per second from our own test */\n-            skewThreshold = calibration.granularity;\n-            /* Check for clock skew */\n-            diff = lowresTime - highresTime;\n-\n-            /*\n-             * For some reason that I have not determined, the skew can be\n-             * up to twice a kernel tick. This does not seem to happen by\n-             * itself, but I have only seen it triggered by another program\n-             * doing some kind of file I/O. The symptoms are a negative diff\n-             * followed by an equally large positive diff.\n-             */\n-            if (fabs(diff) > 2 * skewThreshold) {\n-                if (calibrated) {\n-                    /*\n-                     * If we already calibrated once this instance, and the\n-                     * clock is still skewed, then either the processor(s) are\n-                     * wildly changing clockspeed or the system is so busy that\n-                     * we get switched out for long periods of time. In either\n-                     * case, it would be infeasible to make use of high\n-                     * resolution results for anything, so let's resort to old\n-                     * behavior for this call. It's possible that in the\n-                     * future, the user will want the high resolution timer, so\n-                     * we don't disable it entirely.\n-                     */\n-                    returnedTime = (PRInt64)lowresTime;\n-                    needsCalibration = PR_FALSE;\n-                } else {\n-                    /*\n-                     * It is possible that when we recalibrate, we will return\n-                     * a value less than what we have returned before; this is\n-                     * unavoidable. We cannot tell the different between a\n-                     * faulty QueryPerformanceCounter implementation and user\n-                     * changes to the operating system time. Since we must\n-                     * respect user changes to the operating system time, we\n-                     * cannot maintain the invariant that Date.now() never\n-                     * decreases; the old implementation has this behavior as\n-                     * well.\n-                     */\n-                    needsCalibration = PR_TRUE;\n-                }\n-            } else {\n-                /* No detectable clock skew */\n-                returnedTime = (PRInt64)highresTime;\n-                needsCalibration = PR_FALSE;\n-            }\n+    if (calibration.freq > 0.0) {\n+      long double highresTime, diff;\n+      DWORD timeAdjustment, timeIncrement;\n+      BOOL timeAdjustmentDisabled;\n+\n+      /* Default to 15.625 ms if the syscall fails */\n+      long double skewThreshold = 15625.25;\n+\n+      /* Grab high resolution time */\n+      QueryPerformanceCounter(&now);\n+      highresTimerValue = (long double)now.QuadPart;\n+\n+      EnterCriticalSection(&calibration.data_lock);\n+      highresTime = calibration.offset +\n+                    1000000L * (highresTimerValue - calibration.timer_offset) /\n+                        calibration.freq;\n+      cachedOffset = calibration.offset;\n+\n+      /*\n+       * On some dual processor/core systems, we might get an earlier\n+       * time so we cache the last time that we returned.\n+       */\n+      calibration.last = PR_MAX(calibration.last, (PRInt64)highresTime);\n+      returnedTime = calibration.last;\n+      LeaveCriticalSection(&calibration.data_lock);\n+\n+      /* Get an estimate of clock ticks per second from our own test */\n+      skewThreshold = calibration.granularity;\n+      /* Check for clock skew */\n+      diff = lowresTime - highresTime;\n+\n+      /*\n+       * For some reason that I have not determined, the skew can be\n+       * up to twice a kernel tick. This does not seem to happen by\n+       * itself, but I have only seen it triggered by another program\n+       * doing some kind of file I/O. The symptoms are a negative diff\n+       * followed by an equally large positive diff.\n+       */\n+      if (fabs(diff) > 2 * skewThreshold) {\n+        if (calibrated) {\n+          /*\n+           * If we already calibrated once this instance, and the\n+           * clock is still skewed, then either the processor(s) are\n+           * wildly changing clockspeed or the system is so busy that\n+           * we get switched out for long periods of time. In either\n+           * case, it would be infeasible to make use of high\n+           * resolution results for anything, so let's resort to old\n+           * behavior for this call. It's possible that in the\n+           * future, the user will want the high resolution timer, so\n+           * we don't disable it entirely.\n+           */\n+          returnedTime = (PRInt64)lowresTime;\n+          needsCalibration = PR_FALSE;\n         } else {\n-            /* No high resolution timer is available, so fall back */\n-            returnedTime = (PRInt64)lowresTime;\n+          /*\n+           * It is possible that when we recalibrate, we will return\n+           * a value less than what we have returned before; this is\n+           * unavoidable. We cannot tell the different between a\n+           * faulty QueryPerformanceCounter implementation and user\n+           * changes to the operating system time. Since we must\n+           * respect user changes to the operating system time, we\n+           * cannot maintain the invariant that Date.now() never\n+           * decreases; the old implementation has this behavior as\n+           * well.\n+           */\n+          needsCalibration = PR_TRUE;\n         }\n-    } while (needsCalibration);\n+      } else {\n+        /* No detectable clock skew */\n+        returnedTime = (PRInt64)highresTime;\n+        needsCalibration = PR_FALSE;\n+      }\n+    } else {\n+      /* No high resolution timer is available, so fall back */\n+      returnedTime = (PRInt64)lowresTime;\n+    }\n+  } while (needsCalibration);\n \n-    return returnedTime;\n+  return returnedTime;\n }\n \n #else\n \n PR_IMPLEMENT(PRTime)\n-PR_Now(void)\n-{\n-    PRTime prt;\n-    FILETIME ft;\n-    SYSTEMTIME st;\n-\n-    GetSystemTime(&st);\n-    SystemTimeToFileTime(&st, &ft);\n-    _PR_FileTimeToPRTime(&ft, &prt);\n-    return prt;\n+PR_Now(void) {\n+  PRTime prt;\n+  FILETIME ft;\n+  SYSTEMTIME st;\n+\n+  GetSystemTime(&st);\n+  SystemTimeToFileTime(&st, &ft);\n+  _PR_FileTimeToPRTime(&ft, &prt);\n+  return prt;\n }\n \n #endif\n@@ -344,110 +325,108 @@ PR_Now(void)\n  * On success, this function returns 0 and the resulting command\n  * line is returned in *cmdLine.  On failure, it returns -1.\n  */\n-static int\n-assembleCmdLine(char* const* argv, char** cmdLine)\n-{\n-    char* const* arg;\n-    char *p, *q;\n-    size_t cmdLineSize;\n-    int numBackslashes;\n-    int i;\n-    int argNeedQuotes;\n-\n+static int assembleCmdLine(char* const* argv, char** cmdLine) {\n+  char* const* arg;\n+  char *p, *q;\n+  size_t cmdLineSize;\n+  int numBackslashes;\n+  int i;\n+  int argNeedQuotes;\n+\n+  /*\n+   * Find out how large the command line buffer should be.\n+   */\n+  cmdLineSize = 0;\n+  for (arg = argv; *arg; arg++) {\n     /*\n-     * Find out how large the command line buffer should be.\n+     * \\ and \" need to be escaped by a \\.  In the worst case,\n+     * every character is a \\ or \", so the string of length\n+     * may double.  If we quote an argument, that needs two \".\n+     * Finally, we need a space between arguments, and\n+     * a null byte at the end of command line.\n      */\n-    cmdLineSize = 0;\n-    for (arg = argv; *arg; arg++) {\n-        /*\n-         * \\ and \" need to be escaped by a \\.  In the worst case,\n-         * every character is a \\ or \", so the string of length\n-         * may double.  If we quote an argument, that needs two \".\n-         * Finally, we need a space between arguments, and\n-         * a null byte at the end of command line.\n-         */\n-        cmdLineSize += 2 * strlen(*arg) /* \\ and \" need to be escaped */\n-                       + 2              /* we quote every argument */\n-                       + 1;             /* space in between, or final null */\n+    cmdLineSize += 2 * strlen(*arg) /* \\ and \" need to be escaped */\n+                   + 2              /* we quote every argument */\n+                   + 1;             /* space in between, or final null */\n+  }\n+  p = *cmdLine = PR_MALLOC((PRUint32)cmdLineSize);\n+  if (p == NULL) {\n+    return -1;\n+  }\n+\n+  for (arg = argv; *arg; arg++) {\n+    /* Add a space to separates the arguments */\n+    if (arg != argv) {\n+      *p++ = ' ';\n     }\n-    p = *cmdLine = PR_MALLOC((PRUint32)cmdLineSize);\n-    if (p == NULL) {\n-        return -1;\n-    }\n-\n-    for (arg = argv; *arg; arg++) {\n-        /* Add a space to separates the arguments */\n-        if (arg != argv) {\n-            *p++ = ' ';\n-        }\n-        q = *arg;\n-        numBackslashes = 0;\n-        argNeedQuotes = 0;\n+    q = *arg;\n+    numBackslashes = 0;\n+    argNeedQuotes = 0;\n \n-        /*\n-         * If the argument is empty or contains white space, it needs to\n-         * be quoted.\n-         */\n-        if (**arg == '\\0' || strpbrk(*arg, \" \\f\\n\\r\\t\\v\")) {\n-            argNeedQuotes = 1;\n-        }\n-\n-        if (argNeedQuotes) {\n-            *p++ = '\"';\n-        }\n-        while (*q) {\n-            if (*q == '\\\\') {\n-                numBackslashes++;\n-                q++;\n-            } else if (*q == '\"') {\n-                if (numBackslashes) {\n-                    /*\n-                     * Double the backslashes since they are followed\n-                     * by a quote\n-                     */\n-                    for (i = 0; i < 2 * numBackslashes; i++) {\n-                        *p++ = '\\\\';\n-                    }\n-                    numBackslashes = 0;\n-                }\n-                /* To escape the quote */\n-                *p++ = '\\\\';\n-                *p++ = *q++;\n-            } else {\n-                if (numBackslashes) {\n-                    /*\n-                     * Backslashes are not followed by a quote, so\n-                     * don't need to double the backslashes.\n-                     */\n-                    for (i = 0; i < numBackslashes; i++) {\n-                        *p++ = '\\\\';\n-                    }\n-                    numBackslashes = 0;\n-                }\n-                *p++ = *q++;\n-            }\n-        }\n+    /*\n+     * If the argument is empty or contains white space, it needs to\n+     * be quoted.\n+     */\n+    if (**arg == '\\0' || strpbrk(*arg, \" \\f\\n\\r\\t\\v\")) {\n+      argNeedQuotes = 1;\n+    }\n \n-        /* Now we are at the end of this argument */\n+    if (argNeedQuotes) {\n+      *p++ = '\"';\n+    }\n+    while (*q) {\n+      if (*q == '\\\\') {\n+        numBackslashes++;\n+        q++;\n+      } else if (*q == '\"') {\n         if (numBackslashes) {\n-            /*\n-             * Double the backslashes if we have a quote string\n-             * delimiter at the end.\n-             */\n-            if (argNeedQuotes) {\n-                numBackslashes *= 2;\n-            }\n-            for (i = 0; i < numBackslashes; i++) {\n-                *p++ = '\\\\';\n-            }\n+          /*\n+           * Double the backslashes since they are followed\n+           * by a quote\n+           */\n+          for (i = 0; i < 2 * numBackslashes; i++) {\n+            *p++ = '\\\\';\n+          }\n+          numBackslashes = 0;\n         }\n-        if (argNeedQuotes) {\n-            *p++ = '\"';\n+        /* To escape the quote */\n+        *p++ = '\\\\';\n+        *p++ = *q++;\n+      } else {\n+        if (numBackslashes) {\n+          /*\n+           * Backslashes are not followed by a quote, so\n+           * don't need to double the backslashes.\n+           */\n+          for (i = 0; i < numBackslashes; i++) {\n+            *p++ = '\\\\';\n+          }\n+          numBackslashes = 0;\n         }\n+        *p++ = *q++;\n+      }\n     }\n \n-    *p = '\\0';\n-    return 0;\n+    /* Now we are at the end of this argument */\n+    if (numBackslashes) {\n+      /*\n+       * Double the backslashes if we have a quote string\n+       * delimiter at the end.\n+       */\n+      if (argNeedQuotes) {\n+        numBackslashes *= 2;\n+      }\n+      for (i = 0; i < numBackslashes; i++) {\n+        *p++ = '\\\\';\n+      }\n+    }\n+    if (argNeedQuotes) {\n+      *p++ = '\"';\n+    }\n+  }\n+\n+  *p = '\\0';\n+  return 0;\n }\n \n /*\n@@ -459,450 +438,429 @@ assembleCmdLine(char* const* argv, char** cmdLine)\n  * in *envBlock.  Note that if envp is NULL, a NULL pointer is returned\n  * in *envBlock.  Returns -1 on failure.\n  */\n-static int\n-assembleEnvBlock(char** envp, char** envBlock)\n-{\n-    char* p;\n-    char* q;\n-    char** env;\n-    char* curEnv;\n-    char *cwdStart, *cwdEnd;\n-    size_t envBlockSize;\n-\n-    if (envp == NULL) {\n-        *envBlock = NULL;\n-        return 0;\n-    }\n+static int assembleEnvBlock(char** envp, char** envBlock) {\n+  char* p;\n+  char* q;\n+  char** env;\n+  char* curEnv;\n+  char *cwdStart, *cwdEnd;\n+  size_t envBlockSize;\n+\n+  if (envp == NULL) {\n+    *envBlock = NULL;\n+    return 0;\n+  }\n \n #ifdef WINCE\n-    {\n-        PRUnichar* wideCurEnv = mozce_GetEnvString();\n-        int len =\n-            WideCharToMultiByte(CP_ACP, 0, wideCurEnv, -1, NULL, 0, NULL, NULL);\n-        curEnv = (char*)PR_MALLOC(len * sizeof(char));\n-        WideCharToMultiByte(CP_ACP, 0, wideCurEnv, -1, curEnv, len, NULL, NULL);\n-        free(wideCurEnv);\n-    }\n+  {\n+    PRUnichar* wideCurEnv = mozce_GetEnvString();\n+    int len =\n+        WideCharToMultiByte(CP_ACP, 0, wideCurEnv, -1, NULL, 0, NULL, NULL);\n+    curEnv = (char*)PR_MALLOC(len * sizeof(char));\n+    WideCharToMultiByte(CP_ACP, 0, wideCurEnv, -1, curEnv, len, NULL, NULL);\n+    free(wideCurEnv);\n+  }\n #else\n-    curEnv = GetEnvironmentStrings();\n+  curEnv = GetEnvironmentStrings();\n #endif\n \n-    cwdStart = curEnv;\n-    while (*cwdStart) {\n-        if (cwdStart[0] == '=' && cwdStart[1] != '\\0' && cwdStart[2] == ':' &&\n-            cwdStart[3] == '=') {\n-            break;\n-        }\n-        cwdStart += strlen(cwdStart) + 1;\n+  cwdStart = curEnv;\n+  while (*cwdStart) {\n+    if (cwdStart[0] == '=' && cwdStart[1] != '\\0' && cwdStart[2] == ':' &&\n+        cwdStart[3] == '=') {\n+      break;\n     }\n-    cwdEnd = cwdStart;\n-    if (*cwdEnd) {\n-        cwdEnd += strlen(cwdEnd) + 1;\n-        while (*cwdEnd) {\n-            if (cwdEnd[0] != '=' || cwdEnd[1] == '\\0' || cwdEnd[2] != ':' ||\n-                cwdEnd[3] != '=') {\n-                break;\n-            }\n-            cwdEnd += strlen(cwdEnd) + 1;\n-        }\n+    cwdStart += strlen(cwdStart) + 1;\n+  }\n+  cwdEnd = cwdStart;\n+  if (*cwdEnd) {\n+    cwdEnd += strlen(cwdEnd) + 1;\n+    while (*cwdEnd) {\n+      if (cwdEnd[0] != '=' || cwdEnd[1] == '\\0' || cwdEnd[2] != ':' ||\n+          cwdEnd[3] != '=') {\n+        break;\n+      }\n+      cwdEnd += strlen(cwdEnd) + 1;\n     }\n-    envBlockSize = cwdEnd - cwdStart;\n+  }\n+  envBlockSize = cwdEnd - cwdStart;\n \n-    for (env = envp; *env; env++) {\n-        envBlockSize += strlen(*env) + 1;\n-    }\n-    envBlockSize++;\n+  for (env = envp; *env; env++) {\n+    envBlockSize += strlen(*env) + 1;\n+  }\n+  envBlockSize++;\n \n-    p = *envBlock = PR_MALLOC((PRUint32)envBlockSize);\n-    if (p == NULL) {\n+  p = *envBlock = PR_MALLOC((PRUint32)envBlockSize);\n+  if (p == NULL) {\n #ifdef WINCE\n-        PR_Free(curEnv);\n+    PR_Free(curEnv);\n #else\n-        FreeEnvironmentStrings(curEnv);\n+    FreeEnvironmentStrings(curEnv);\n #endif\n-        return -1;\n-    }\n+    return -1;\n+  }\n \n-    q = cwdStart;\n-    while (q < cwdEnd) {\n-        *p++ = *q++;\n-    }\n+  q = cwdStart;\n+  while (q < cwdEnd) {\n+    *p++ = *q++;\n+  }\n #ifdef WINCE\n-    PR_Free(curEnv);\n+  PR_Free(curEnv);\n #else\n-    FreeEnvironmentStrings(curEnv);\n+  FreeEnvironmentStrings(curEnv);\n #endif\n \n-    for (env = envp; *env; env++) {\n-        q = *env;\n-        while (*q) {\n-            *p++ = *q++;\n-        }\n-        *p++ = '\\0';\n+  for (env = envp; *env; env++) {\n+    q = *env;\n+    while (*q) {\n+      *p++ = *q++;\n     }\n-    *p = '\\0';\n-    return 0;\n+    *p++ = '\\0';\n+  }\n+  *p = '\\0';\n+  return 0;\n }\n \n /*\n  * For qsort.  We sort (case-insensitive) the environment strings\n  * before generating the environment block.\n  */\n-static int\n-compare(const void* arg1, const void* arg2)\n-{\n-    return _stricmp(*(char**)arg1, *(char**)arg2);\n+static int compare(const void* arg1, const void* arg2) {\n+  return _stricmp(*(char**)arg1, *(char**)arg2);\n }\n \n-PRProcess*\n-_PR_CreateWindowsProcess(const char* path, char* const* argv,\n-                         char* const* envp,\n-                         const PRProcessAttr* attr)\n-{\n+PRProcess* _PR_CreateWindowsProcess(const char* path, char* const* argv,\n+                                    char* const* envp,\n+                                    const PRProcessAttr* attr) {\n #ifdef WINCE\n-    STARTUPINFOW startupInfo;\n-    PRUnichar* wideCmdLine;\n-    PRUnichar* wideCwd;\n-    int len = 0;\n+  STARTUPINFOW startupInfo;\n+  PRUnichar* wideCmdLine;\n+  PRUnichar* wideCwd;\n+  int len = 0;\n #else\n-    STARTUPINFO startupInfo;\n+  STARTUPINFO startupInfo;\n #endif\n-    DWORD creationFlags = 0;\n-    PROCESS_INFORMATION procInfo;\n-    BOOL retVal;\n-    char* cmdLine = NULL;\n-    char* envBlock = NULL;\n-    char** newEnvp = NULL;\n-    const char* cwd = NULL; /* current working directory */\n-    PRProcess* proc = NULL;\n-    PRBool hasFdInheritBuffer;\n-\n-    proc = PR_NEW(PRProcess);\n-    if (!proc) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        goto errorExit;\n-    }\n-\n-    if (assembleCmdLine(argv, &cmdLine) == -1) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        goto errorExit;\n-    }\n+  DWORD creationFlags = 0;\n+  PROCESS_INFORMATION procInfo;\n+  BOOL retVal;\n+  char* cmdLine = NULL;\n+  char* envBlock = NULL;\n+  char** newEnvp = NULL;\n+  const char* cwd = NULL; /* current working directory */\n+  PRProcess* proc = NULL;\n+  PRBool hasFdInheritBuffer;\n+\n+  proc = PR_NEW(PRProcess);\n+  if (!proc) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    goto errorExit;\n+  }\n+\n+  if (assembleCmdLine(argv, &cmdLine) == -1) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    goto errorExit;\n+  }\n \n #ifndef WINCE\n-    /*\n-     * If attr->fdInheritBuffer is not NULL, we need to insert\n-     * it into the envp array, so envp cannot be NULL.\n-     */\n-    hasFdInheritBuffer = (attr && attr->fdInheritBuffer);\n-    if ((envp == NULL) && hasFdInheritBuffer) {\n-        envp = environ;\n+  /*\n+   * If attr->fdInheritBuffer is not NULL, we need to insert\n+   * it into the envp array, so envp cannot be NULL.\n+   */\n+  hasFdInheritBuffer = (attr && attr->fdInheritBuffer);\n+  if ((envp == NULL) && hasFdInheritBuffer) {\n+    envp = environ;\n+  }\n+\n+  if (envp != NULL) {\n+    int idx;\n+    int numEnv;\n+    PRBool found = PR_FALSE;\n+\n+    numEnv = 0;\n+    while (envp[numEnv]) {\n+      numEnv++;\n     }\n-\n-    if (envp != NULL) {\n-        int idx;\n-        int numEnv;\n-        PRBool found = PR_FALSE;\n-\n-        numEnv = 0;\n-        while (envp[numEnv]) {\n-            numEnv++;\n-        }\n-        newEnvp = (char**)PR_MALLOC((numEnv + 2) * sizeof(char*));\n-        for (idx = 0; idx < numEnv; idx++) {\n-            newEnvp[idx] = envp[idx];\n-            if (hasFdInheritBuffer && !found &&\n-                !strncmp(newEnvp[idx], \"NSPR_INHERIT_FDS=\", 17)) {\n-                newEnvp[idx] = attr->fdInheritBuffer;\n-                found = PR_TRUE;\n-            }\n-        }\n-        if (hasFdInheritBuffer && !found) {\n-            newEnvp[idx++] = attr->fdInheritBuffer;\n-        }\n-        newEnvp[idx] = NULL;\n-        qsort((void*)newEnvp, (size_t)idx, sizeof(char*), compare);\n+    newEnvp = (char**)PR_MALLOC((numEnv + 2) * sizeof(char*));\n+    for (idx = 0; idx < numEnv; idx++) {\n+      newEnvp[idx] = envp[idx];\n+      if (hasFdInheritBuffer && !found &&\n+          !strncmp(newEnvp[idx], \"NSPR_INHERIT_FDS=\", 17)) {\n+        newEnvp[idx] = attr->fdInheritBuffer;\n+        found = PR_TRUE;\n+      }\n     }\n-    if (assembleEnvBlock(newEnvp, &envBlock) == -1) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        goto errorExit;\n+    if (hasFdInheritBuffer && !found) {\n+      newEnvp[idx++] = attr->fdInheritBuffer;\n     }\n+    newEnvp[idx] = NULL;\n+    qsort((void*)newEnvp, (size_t)idx, sizeof(char*), compare);\n+  }\n+  if (assembleEnvBlock(newEnvp, &envBlock) == -1) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    goto errorExit;\n+  }\n \n-    ZeroMemory(&startupInfo, sizeof(startupInfo));\n-    startupInfo.cb = sizeof(startupInfo);\n+  ZeroMemory(&startupInfo, sizeof(startupInfo));\n+  startupInfo.cb = sizeof(startupInfo);\n \n-    if (attr) {\n-        PRBool redirected = PR_FALSE;\n+  if (attr) {\n+    PRBool redirected = PR_FALSE;\n \n-        /*\n-         * XXX the default value for stdin, stdout, and stderr\n-         * should probably be the console input and output, not\n-         * those of the parent process.\n-         */\n-        startupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);\n-        startupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);\n-        startupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);\n-        if (attr->stdinFd) {\n-            startupInfo.hStdInput = (HANDLE)attr->stdinFd->secret->md.osfd;\n-            redirected = PR_TRUE;\n-        }\n-        if (attr->stdoutFd) {\n-            startupInfo.hStdOutput = (HANDLE)attr->stdoutFd->secret->md.osfd;\n-            redirected = PR_TRUE;\n-            /*\n-             * If stdout is redirected, we can assume that the process will\n-             * not write anything useful to the console windows, and therefore\n-             * automatically set the CREATE_NO_WINDOW flag.\n-             */\n-            creationFlags |= CREATE_NO_WINDOW;\n-        }\n-        if (attr->stderrFd) {\n-            startupInfo.hStdError = (HANDLE)attr->stderrFd->secret->md.osfd;\n-            redirected = PR_TRUE;\n-        }\n-        if (redirected) {\n-            startupInfo.dwFlags |= STARTF_USESTDHANDLES;\n-        }\n-        cwd = attr->currentDirectory;\n+    /*\n+     * XXX the default value for stdin, stdout, and stderr\n+     * should probably be the console input and output, not\n+     * those of the parent process.\n+     */\n+    startupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);\n+    startupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);\n+    startupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);\n+    if (attr->stdinFd) {\n+      startupInfo.hStdInput = (HANDLE)attr->stdinFd->secret->md.osfd;\n+      redirected = PR_TRUE;\n+    }\n+    if (attr->stdoutFd) {\n+      startupInfo.hStdOutput = (HANDLE)attr->stdoutFd->secret->md.osfd;\n+      redirected = PR_TRUE;\n+      /*\n+       * If stdout is redirected, we can assume that the process will\n+       * not write anything useful to the console windows, and therefore\n+       * automatically set the CREATE_NO_WINDOW flag.\n+       */\n+      creationFlags |= CREATE_NO_WINDOW;\n+    }\n+    if (attr->stderrFd) {\n+      startupInfo.hStdError = (HANDLE)attr->stderrFd->secret->md.osfd;\n+      redirected = PR_TRUE;\n     }\n+    if (redirected) {\n+      startupInfo.dwFlags |= STARTF_USESTDHANDLES;\n+    }\n+    cwd = attr->currentDirectory;\n+  }\n #endif\n \n #ifdef WINCE\n-    len = MultiByteToWideChar(CP_ACP, 0, cmdLine, -1, NULL, 0);\n-    wideCmdLine = (PRUnichar*)PR_MALLOC(len * sizeof(PRUnichar));\n-    MultiByteToWideChar(CP_ACP, 0, cmdLine, -1, wideCmdLine, len);\n-    len = MultiByteToWideChar(CP_ACP, 0, cwd, -1, NULL, 0);\n-    wideCwd = PR_MALLOC(len * sizeof(PRUnichar));\n-    MultiByteToWideChar(CP_ACP, 0, cwd, -1, wideCwd, len);\n-    retVal =\n-        CreateProcessW(NULL, wideCmdLine, NULL, /* security attributes for the new\n-                                                 * process */\n-                       NULL,                    /* security attributes for the primary\n-                                                 * thread in the new process */\n-                       TRUE,                    /* inherit handles */\n-                       creationFlags, envBlock, /* an environment block,\n-                                                 * consisting of a null-terminated\n-                                                 * block of null-terminated\n-                                                 * strings.  Each string is in the\n-                                                 * form: name=value\n-                                                 * XXX: usually NULL */\n-                       wideCwd,                 /* current drive and directory */\n-                       &startupInfo, &procInfo);\n-    PR_Free(wideCmdLine);\n-    PR_Free(wideCwd);\n+  len = MultiByteToWideChar(CP_ACP, 0, cmdLine, -1, NULL, 0);\n+  wideCmdLine = (PRUnichar*)PR_MALLOC(len * sizeof(PRUnichar));\n+  MultiByteToWideChar(CP_ACP, 0, cmdLine, -1, wideCmdLine, len);\n+  len = MultiByteToWideChar(CP_ACP, 0, cwd, -1, NULL, 0);\n+  wideCwd = PR_MALLOC(len * sizeof(PRUnichar));\n+  MultiByteToWideChar(CP_ACP, 0, cwd, -1, wideCwd, len);\n+  retVal =\n+      CreateProcessW(NULL, wideCmdLine, NULL, /* security attributes for the new\n+                                               * process */\n+                     NULL, /* security attributes for the primary\n+                            * thread in the new process */\n+                     TRUE, /* inherit handles */\n+                     creationFlags, envBlock, /* an environment block,\n+                                               * consisting of a null-terminated\n+                                               * block of null-terminated\n+                                               * strings.  Each string is in the\n+                                               * form: name=value\n+                                               * XXX: usually NULL */\n+                     wideCwd,                 /* current drive and directory */\n+                     &startupInfo, &procInfo);\n+  PR_Free(wideCmdLine);\n+  PR_Free(wideCwd);\n #else\n-    retVal =\n-        CreateProcess(NULL, cmdLine, NULL,     /* security attributes for the new\n-                                                * process */\n-                      NULL,                    /* security attributes for the primary\n-                                                * thread in the new process */\n-                      TRUE,                    /* inherit handles */\n-                      creationFlags, envBlock, /* an environment block, consisting\n-                                                * of a null-terminated block of\n-                                                * null-terminated strings.  Each\n-                                                * string is in the form:\n-                                                *     name=value\n-                                                * XXX: usually NULL */\n-                      cwd,                     /* current drive and directory */\n-                      &startupInfo, &procInfo);\n+  retVal =\n+      CreateProcess(NULL, cmdLine, NULL, /* security attributes for the new\n+                                          * process */\n+                    NULL,                /* security attributes for the primary\n+                                          * thread in the new process */\n+                    TRUE,                /* inherit handles */\n+                    creationFlags, envBlock, /* an environment block, consisting\n+                                              * of a null-terminated block of\n+                                              * null-terminated strings.  Each\n+                                              * string is in the form:\n+                                              *     name=value\n+                                              * XXX: usually NULL */\n+                    cwd,                     /* current drive and directory */\n+                    &startupInfo, &procInfo);\n #endif\n \n-    if (retVal == FALSE) {\n-        /* XXX what error code? */\n-        PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n-        goto errorExit;\n-    }\n-\n-    CloseHandle(procInfo.hThread);\n-    proc->md.handle = procInfo.hProcess;\n-    proc->md.id = procInfo.dwProcessId;\n-\n-    PR_DELETE(cmdLine);\n-    if (newEnvp) {\n-        PR_DELETE(newEnvp);\n-    }\n-    if (envBlock) {\n-        PR_DELETE(envBlock);\n-    }\n-    return proc;\n+  if (retVal == FALSE) {\n+    /* XXX what error code? */\n+    PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n+    goto errorExit;\n+  }\n+\n+  CloseHandle(procInfo.hThread);\n+  proc->md.handle = procInfo.hProcess;\n+  proc->md.id = procInfo.dwProcessId;\n+\n+  PR_DELETE(cmdLine);\n+  if (newEnvp) {\n+    PR_DELETE(newEnvp);\n+  }\n+  if (envBlock) {\n+    PR_DELETE(envBlock);\n+  }\n+  return proc;\n \n errorExit:\n-    if (cmdLine) {\n-        PR_DELETE(cmdLine);\n-    }\n-    if (newEnvp) {\n-        PR_DELETE(newEnvp);\n-    }\n-    if (envBlock) {\n-        PR_DELETE(envBlock);\n-    }\n-    if (proc) {\n-        PR_DELETE(proc);\n-    }\n-    return NULL;\n+  if (cmdLine) {\n+    PR_DELETE(cmdLine);\n+  }\n+  if (newEnvp) {\n+    PR_DELETE(newEnvp);\n+  }\n+  if (envBlock) {\n+    PR_DELETE(envBlock);\n+  }\n+  if (proc) {\n+    PR_DELETE(proc);\n+  }\n+  return NULL;\n } /* _PR_CreateWindowsProcess */\n \n-PRStatus\n-_PR_DetachWindowsProcess(PRProcess* process)\n-{\n-    CloseHandle(process->md.handle);\n-    PR_DELETE(process);\n-    return PR_SUCCESS;\n+PRStatus _PR_DetachWindowsProcess(PRProcess* process) {\n+  CloseHandle(process->md.handle);\n+  PR_DELETE(process);\n+  return PR_SUCCESS;\n }\n \n /*\n  * XXX: This implementation is a temporary quick solution.\n  * It can be called by native threads only (not by fibers).\n  */\n-PRStatus\n-_PR_WaitWindowsProcess(PRProcess* process, PRInt32* exitCode)\n-{\n-    DWORD dwRetVal;\n-\n-    dwRetVal = WaitForSingleObject(process->md.handle, INFINITE);\n-    if (dwRetVal == WAIT_FAILED) {\n-        PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n-        return PR_FAILURE;\n-    }\n-    PR_ASSERT(dwRetVal == WAIT_OBJECT_0);\n-    if (exitCode != NULL) {\n-        DWORD tmpExitCode;\n-        if (GetExitCodeProcess(process->md.handle, &tmpExitCode) == FALSE) {\n-            PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n-            return PR_FAILURE;\n-        }\n-        *exitCode = (PRInt32)tmpExitCode;\n-    }\n-    CloseHandle(process->md.handle);\n-    PR_DELETE(process);\n-    return PR_SUCCESS;\n-}\n+PRStatus _PR_WaitWindowsProcess(PRProcess* process, PRInt32* exitCode) {\n+  DWORD dwRetVal;\n \n-PRStatus\n-_PR_KillWindowsProcess(PRProcess* process)\n-{\n-    /*\n-     * On Unix, if a process terminates normally, its exit code is\n-     * between 0 and 255.  So here on Windows, we use the exit code\n-     * 256 to indicate that the process is killed.\n-     */\n-    if (TerminateProcess(process->md.handle, 256)) {\n-        return PR_SUCCESS;\n-    }\n+  dwRetVal = WaitForSingleObject(process->md.handle, INFINITE);\n+  if (dwRetVal == WAIT_FAILED) {\n+    PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n+    return PR_FAILURE;\n+  }\n+  PR_ASSERT(dwRetVal == WAIT_OBJECT_0);\n+  if (exitCode != NULL &&\n+      GetExitCodeProcess(process->md.handle, exitCode) == FALSE) {\n     PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n     return PR_FAILURE;\n+  }\n+  CloseHandle(process->md.handle);\n+  PR_DELETE(process);\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_WindowsGetHostName(char* name, PRUint32 namelen)\n-{\n-    PRIntn rv;\n-    PRInt32 syserror;\n-\n-    rv = gethostname(name, (PRInt32)namelen);\n-    if (0 == rv) {\n-        return PR_SUCCESS;\n-    }\n-    syserror = WSAGetLastError();\n-    PR_ASSERT(WSANOTINITIALISED != syserror);\n-    _PR_MD_MAP_GETHOSTNAME_ERROR(syserror);\n-    return PR_FAILURE;\n+PRStatus _PR_KillWindowsProcess(PRProcess* process) {\n+  /*\n+   * On Unix, if a process terminates normally, its exit code is\n+   * between 0 and 255.  So here on Windows, we use the exit code\n+   * 256 to indicate that the process is killed.\n+   */\n+  if (TerminateProcess(process->md.handle, 256)) {\n+    return PR_SUCCESS;\n+  }\n+  PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n+  return PR_FAILURE;\n }\n \n-PRStatus\n-_MD_WindowsGetSysInfo(PRSysInfo cmd, char* name, PRUint32 namelen)\n-{\n-    OSVERSIONINFO osvi;\n+PRStatus _MD_WindowsGetHostName(char* name, PRUint32 namelen) {\n+  PRIntn rv;\n+  PRInt32 syserror;\n+\n+  rv = gethostname(name, (PRInt32)namelen);\n+  if (0 == rv) {\n+    return PR_SUCCESS;\n+  }\n+  syserror = WSAGetLastError();\n+  PR_ASSERT(WSANOTINITIALISED != syserror);\n+  _PR_MD_MAP_GETHOSTNAME_ERROR(syserror);\n+  return PR_FAILURE;\n+}\n \n-    PR_ASSERT((cmd == PR_SI_SYSNAME) || (cmd == PR_SI_RELEASE) ||\n-              (cmd == PR_SI_RELEASE_BUILD));\n+PRStatus _MD_WindowsGetSysInfo(PRSysInfo cmd, char* name, PRUint32 namelen) {\n+  OSVERSIONINFO osvi;\n \n-    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));\n-    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);\n+  PR_ASSERT((cmd == PR_SI_SYSNAME) || (cmd == PR_SI_RELEASE) ||\n+            (cmd == PR_SI_RELEASE_BUILD));\n \n-    if (!GetVersionEx(&osvi)) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        return PR_FAILURE;\n-    }\n+  ZeroMemory(&osvi, sizeof(OSVERSIONINFO));\n+  osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);\n \n-    switch (osvi.dwPlatformId) {\n-        case VER_PLATFORM_WIN32_NT:\n-            if (PR_SI_SYSNAME == cmd) {\n-                (void)PR_snprintf(name, namelen, \"Windows_NT\");\n-            } else if (PR_SI_RELEASE == cmd) {\n-                (void)PR_snprintf(name, namelen, \"%d.%d\", osvi.dwMajorVersion,\n-                                  osvi.dwMinorVersion);\n-            } else if (PR_SI_RELEASE_BUILD == cmd) {\n-                (void)PR_snprintf(name, namelen, \"%d\", osvi.dwBuildNumber);\n-            }\n-            break;\n-        case VER_PLATFORM_WIN32_WINDOWS:\n-            if (PR_SI_SYSNAME == cmd) {\n-                if ((osvi.dwMajorVersion > 4) ||\n-                    ((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0))) {\n-                    (void)PR_snprintf(name, namelen, \"Windows_98\");\n-                } else {\n-                    (void)PR_snprintf(name, namelen, \"Windows_95\");\n-                }\n-            } else if (PR_SI_RELEASE == cmd) {\n-                (void)PR_snprintf(name, namelen, \"%d.%d\", osvi.dwMajorVersion,\n-                                  osvi.dwMinorVersion);\n-            } else if (PR_SI_RELEASE_BUILD == cmd) {\n-                (void)PR_snprintf(name, namelen, \"%d\", osvi.dwBuildNumber);\n-            }\n-            break;\n+  if (!GetVersionEx(&osvi)) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    return PR_FAILURE;\n+  }\n+\n+  switch (osvi.dwPlatformId) {\n+    case VER_PLATFORM_WIN32_NT:\n+      if (PR_SI_SYSNAME == cmd) {\n+        (void)PR_snprintf(name, namelen, \"Windows_NT\");\n+      } else if (PR_SI_RELEASE == cmd) {\n+        (void)PR_snprintf(name, namelen, \"%d.%d\", osvi.dwMajorVersion,\n+                          osvi.dwMinorVersion);\n+      } else if (PR_SI_RELEASE_BUILD == cmd) {\n+        (void)PR_snprintf(name, namelen, \"%d\", osvi.dwBuildNumber);\n+      }\n+      break;\n+    case VER_PLATFORM_WIN32_WINDOWS:\n+      if (PR_SI_SYSNAME == cmd) {\n+        if ((osvi.dwMajorVersion > 4) ||\n+            ((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0))) {\n+          (void)PR_snprintf(name, namelen, \"Windows_98\");\n+        } else {\n+          (void)PR_snprintf(name, namelen, \"Windows_95\");\n+        }\n+      } else if (PR_SI_RELEASE == cmd) {\n+        (void)PR_snprintf(name, namelen, \"%d.%d\", osvi.dwMajorVersion,\n+                          osvi.dwMinorVersion);\n+      } else if (PR_SI_RELEASE_BUILD == cmd) {\n+        (void)PR_snprintf(name, namelen, \"%d\", osvi.dwBuildNumber);\n+      }\n+      break;\n #ifdef VER_PLATFORM_WIN32_CE\n-        case VER_PLATFORM_WIN32_CE:\n-            if (PR_SI_SYSNAME == cmd) {\n-                (void)PR_snprintf(name, namelen, \"Windows_CE\");\n-            } else if (PR_SI_RELEASE == cmd) {\n-                (void)PR_snprintf(name, namelen, \"%d.%d\", osvi.dwMajorVersion,\n-                                  osvi.dwMinorVersion);\n-            } else if (PR_SI_RELEASE_BUILD == cmd) {\n-                if (namelen) {\n-                    *name = 0;\n-                }\n-            }\n-            break;\n+    case VER_PLATFORM_WIN32_CE:\n+      if (PR_SI_SYSNAME == cmd) {\n+        (void)PR_snprintf(name, namelen, \"Windows_CE\");\n+      } else if (PR_SI_RELEASE == cmd) {\n+        (void)PR_snprintf(name, namelen, \"%d.%d\", osvi.dwMajorVersion,\n+                          osvi.dwMinorVersion);\n+      } else if (PR_SI_RELEASE_BUILD == cmd) {\n+        if (namelen) {\n+          *name = 0;\n+        }\n+      }\n+      break;\n #endif\n-        default:\n-            if (PR_SI_SYSNAME == cmd) {\n-                (void)PR_snprintf(name, namelen, \"Windows_Unknown\");\n-            } else if (PR_SI_RELEASE == cmd) {\n-                (void)PR_snprintf(name, namelen, \"%d.%d\", 0, 0);\n-            } else if (PR_SI_RELEASE_BUILD == cmd) {\n-                if (namelen) {\n-                    *name = 0;\n-                }\n-            }\n-            break;\n-    }\n-    return PR_SUCCESS;\n+    default:\n+      if (PR_SI_SYSNAME == cmd) {\n+        (void)PR_snprintf(name, namelen, \"Windows_Unknown\");\n+      } else if (PR_SI_RELEASE == cmd) {\n+        (void)PR_snprintf(name, namelen, \"%d.%d\", 0, 0);\n+      } else if (PR_SI_RELEASE_BUILD == cmd) {\n+        if (namelen) {\n+          *name = 0;\n+        }\n+      }\n+      break;\n+  }\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_MD_WindowsGetReleaseName(char* name, PRUint32 namelen)\n-{\n-    OSVERSIONINFO osvi;\n-\n-    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));\n-    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);\n+PRStatus _MD_WindowsGetReleaseName(char* name, PRUint32 namelen) {\n+  OSVERSIONINFO osvi;\n \n-    if (!GetVersionEx(&osvi)) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        return PR_FAILURE;\n-    }\n+  ZeroMemory(&osvi, sizeof(OSVERSIONINFO));\n+  osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);\n \n-    switch (osvi.dwPlatformId) {\n-        case VER_PLATFORM_WIN32_NT:\n-        case VER_PLATFORM_WIN32_WINDOWS:\n-            (void)PR_snprintf(name, namelen, \"%d.%d\", osvi.dwMajorVersion,\n-                              osvi.dwMinorVersion);\n-            break;\n-        default:\n-            (void)PR_snprintf(name, namelen, \"%d.%d\", 0, 0);\n-            break;\n-    }\n-    return PR_SUCCESS;\n+  if (!GetVersionEx(&osvi)) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    return PR_FAILURE;\n+  }\n+\n+  switch (osvi.dwPlatformId) {\n+    case VER_PLATFORM_WIN32_NT:\n+    case VER_PLATFORM_WIN32_WINDOWS:\n+      (void)PR_snprintf(name, namelen, \"%d.%d\", osvi.dwMajorVersion,\n+                        osvi.dwMinorVersion);\n+      break;\n+    default:\n+      (void)PR_snprintf(name, namelen, \"%d.%d\", 0, 0);\n+      break;\n+  }\n+  return PR_SUCCESS;\n }\n \n /*\n@@ -913,114 +871,102 @@ _MD_WindowsGetReleaseName(char* name, PRUint32 namelen)\n  **********************************************************************\n  */\n \n-PRStatus\n-_MD_CreateFileMap(PRFileMap* fmap, PRInt64 size)\n-{\n-    DWORD dwHi, dwLo;\n-    DWORD flProtect;\n-    PROsfd osfd;\n+PRStatus _MD_CreateFileMap(PRFileMap* fmap, PRInt64 size) {\n+  DWORD dwHi, dwLo;\n+  DWORD flProtect;\n+  PROsfd osfd;\n \n-    osfd = (fmap->fd == (PRFileDesc*)-1) ? -1 : fmap->fd->secret->md.osfd;\n+  osfd = (fmap->fd == (PRFileDesc*)-1) ? -1 : fmap->fd->secret->md.osfd;\n \n-    dwLo = (DWORD)(size & 0xffffffff);\n-    dwHi = (DWORD)(((PRUint64)size >> 32) & 0xffffffff);\n+  dwLo = (DWORD)(size & 0xffffffff);\n+  dwHi = (DWORD)(((PRUint64)size >> 32) & 0xffffffff);\n \n-    if (fmap->prot == PR_PROT_READONLY) {\n-        flProtect = PAGE_READONLY;\n-        fmap->md.dwAccess = FILE_MAP_READ;\n-    } else if (fmap->prot == PR_PROT_READWRITE) {\n-        flProtect = PAGE_READWRITE;\n-        fmap->md.dwAccess = FILE_MAP_WRITE;\n-    } else {\n-        PR_ASSERT(fmap->prot == PR_PROT_WRITECOPY);\n+  if (fmap->prot == PR_PROT_READONLY) {\n+    flProtect = PAGE_READONLY;\n+    fmap->md.dwAccess = FILE_MAP_READ;\n+  } else if (fmap->prot == PR_PROT_READWRITE) {\n+    flProtect = PAGE_READWRITE;\n+    fmap->md.dwAccess = FILE_MAP_WRITE;\n+  } else {\n+    PR_ASSERT(fmap->prot == PR_PROT_WRITECOPY);\n #ifdef WINCE\n-        /* WINCE does not have FILE_MAP_COPY. */\n-        PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-        return PR_FAILURE;\n+    /* WINCE does not have FILE_MAP_COPY. */\n+    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+    return PR_FAILURE;\n #else\n-        flProtect = PAGE_WRITECOPY;\n-        fmap->md.dwAccess = FILE_MAP_COPY;\n+    flProtect = PAGE_WRITECOPY;\n+    fmap->md.dwAccess = FILE_MAP_COPY;\n #endif\n-    }\n+  }\n \n-    fmap->md.hFileMap =\n-        CreateFileMapping((HANDLE)osfd, NULL, flProtect, dwHi, dwLo, NULL);\n+  fmap->md.hFileMap =\n+      CreateFileMapping((HANDLE)osfd, NULL, flProtect, dwHi, dwLo, NULL);\n \n-    if (fmap->md.hFileMap == NULL) {\n-        PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  if (fmap->md.hFileMap == NULL) {\n+    PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-PRInt32\n-_MD_GetMemMapAlignment(void)\n-{\n-    SYSTEM_INFO info;\n-    GetSystemInfo(&info);\n-    return info.dwAllocationGranularity;\n+PRInt32 _MD_GetMemMapAlignment(void) {\n+  SYSTEM_INFO info;\n+  GetSystemInfo(&info);\n+  return info.dwAllocationGranularity;\n }\n \n extern PRLogModuleInfo* _pr_shma_lm;\n \n-void*\n-_MD_MemMap(PRFileMap* fmap, PROffset64 offset, PRUint32 len)\n-{\n-    DWORD dwHi, dwLo;\n-    void* addr;\n-\n-    dwLo = (DWORD)(offset & 0xffffffff);\n-    dwHi = (DWORD)(((PRUint64)offset >> 32) & 0xffffffff);\n-    if ((addr = MapViewOfFile(fmap->md.hFileMap, fmap->md.dwAccess, dwHi, dwLo,\n-                              len)) == NULL) {\n-        {\n-            LPVOID lpMsgBuf;\n-\n-            FormatMessage(\n-                FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,\n-                GetLastError(),\n-                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language\n-                (LPTSTR)&lpMsgBuf, 0, NULL);\n-            PR_LOG(_pr_shma_lm, PR_LOG_DEBUG, (\"md_memmap(): %s\", lpMsgBuf));\n-        }\n-        PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n-    }\n-    return addr;\n-}\n+void* _MD_MemMap(PRFileMap* fmap, PROffset64 offset, PRUint32 len) {\n+  DWORD dwHi, dwLo;\n+  void* addr;\n \n-PRStatus\n-_MD_MemUnmap(void* addr, PRUint32 len)\n-{\n-    if (UnmapViewOfFile(addr)) {\n-        return PR_SUCCESS;\n+  dwLo = (DWORD)(offset & 0xffffffff);\n+  dwHi = (DWORD)(((PRUint64)offset >> 32) & 0xffffffff);\n+  if ((addr = MapViewOfFile(fmap->md.hFileMap, fmap->md.dwAccess, dwHi, dwLo,\n+                            len)) == NULL) {\n+    {\n+      LPVOID lpMsgBuf;\n+\n+      FormatMessage(\n+          FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,\n+          GetLastError(),\n+          MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),  // Default language\n+          (LPTSTR)&lpMsgBuf, 0, NULL);\n+      PR_LOG(_pr_shma_lm, PR_LOG_DEBUG, (\"md_memmap(): %s\", lpMsgBuf));\n     }\n-    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-    return PR_FAILURE;\n+    PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n+  }\n+  return addr;\n }\n \n-PRStatus\n-_MD_CloseFileMap(PRFileMap* fmap)\n-{\n-    CloseHandle(fmap->md.hFileMap);\n-    PR_DELETE(fmap);\n+PRStatus _MD_MemUnmap(void* addr, PRUint32 len) {\n+  if (UnmapViewOfFile(addr)) {\n     return PR_SUCCESS;\n+  }\n+  _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+  return PR_FAILURE;\n }\n \n-PRStatus\n-_MD_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n+PRStatus _MD_CloseFileMap(PRFileMap* fmap) {\n+  CloseHandle(fmap->md.hFileMap);\n+  PR_DELETE(fmap);\n+  return PR_SUCCESS;\n+}\n \n-    /* The FlushViewOfFile page on MSDN says:\n-     *  To flush all the dirty pages plus the metadata for the file and\n-     *  ensure that they are physically written to disk, call\n-     *  FlushViewOfFile and then call the FlushFileBuffers function.\n-     */\n-    if (FlushViewOfFile(addr, len) && FlushFileBuffers((HANDLE)osfd)) {\n-        return PR_SUCCESS;\n-    }\n-    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-    return PR_FAILURE;\n+PRStatus _MD_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+\n+  /* The FlushViewOfFile page on MSDN says:\n+   *  To flush all the dirty pages plus the metadata for the file and\n+   *  ensure that they are physically written to disk, call\n+   *  FlushViewOfFile and then call the FlushFileBuffers function.\n+   */\n+  if (FlushViewOfFile(addr, len) && FlushFileBuffers((HANDLE)osfd)) {\n+    return PR_SUCCESS;\n+  }\n+  _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+  return PR_FAILURE;\n }\n \n /*\n@@ -1043,103 +989,95 @@ _MD_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len)\n \n #if defined(_M_IX86) || defined(_X86_)\n \n-#pragma warning(disable : 4035)\n-PRInt32\n-_PR_MD_ATOMIC_INCREMENT(PRInt32* val)\n-{\n-#if defined(__GNUC__)\n-    PRInt32 result;\n-    asm volatile(\"lock ; xadd %0, %1\"\n-                 : \"=r\"(result), \"=m\"(*val)\n-                 : \"0\"(1), \"m\"(*val));\n-    return result + 1;\n-#else\n-    __asm\n-    {\n+#  pragma warning(disable : 4035)\n+PRInt32 _PR_MD_ATOMIC_INCREMENT(PRInt32* val) {\n+#  if defined(__GNUC__)\n+  PRInt32 result;\n+  asm volatile(\"lock ; xadd %0, %1\"\n+               : \"=r\"(result), \"=m\"(*val)\n+               : \"0\"(1), \"m\"(*val));\n+  return result + 1;\n+#  else\n+  __asm\n+  {\n         mov ecx, val\n         mov eax, 1\n         lock xadd dword ptr [ecx], eax\n         inc eax\n-    }\n-#endif /* __GNUC__ */\n+  }\n+#  endif /* __GNUC__ */\n }\n-#pragma warning(default : 4035)\n-\n-#pragma warning(disable : 4035)\n-PRInt32\n-_PR_MD_ATOMIC_DECREMENT(PRInt32* val)\n-{\n-#if defined(__GNUC__)\n-    PRInt32 result;\n-    asm volatile(\"lock ; xadd %0, %1\"\n-                 : \"=r\"(result), \"=m\"(*val)\n-                 : \"0\"(-1), \"m\"(*val));\n-    // asm volatile(\"lock ; xadd %0, %1\" : \"=m\" (val), \"=a\" (result) : \"-1\" (1));\n-    return result - 1;\n-#else\n-    __asm\n-    {\n+#  pragma warning(default : 4035)\n+\n+#  pragma warning(disable : 4035)\n+PRInt32 _PR_MD_ATOMIC_DECREMENT(PRInt32* val) {\n+#  if defined(__GNUC__)\n+  PRInt32 result;\n+  asm volatile(\"lock ; xadd %0, %1\"\n+               : \"=r\"(result), \"=m\"(*val)\n+               : \"0\"(-1), \"m\"(*val));\n+  // asm volatile(\"lock ; xadd %0, %1\" : \"=m\" (val), \"=a\" (result) : \"-1\" (1));\n+  return result - 1;\n+#  else\n+  __asm\n+  {\n         mov ecx, val\n         mov eax, 0ffffffffh\n         lock xadd dword ptr [ecx], eax\n         dec eax\n-    }\n-#endif /* __GNUC__ */\n+  }\n+#  endif /* __GNUC__ */\n }\n-#pragma warning(default : 4035)\n-\n-#pragma warning(disable : 4035)\n-PRInt32\n-_PR_MD_ATOMIC_ADD(PRInt32* intp, PRInt32 val)\n-{\n-#if defined(__GNUC__)\n-    PRInt32 result;\n-    // asm volatile(\"lock ; xadd %1, %0\" : \"=m\" (intp), \"=a\" (result) : \"1\"\n-    // (val));\n-    asm volatile(\"lock ; xadd %0, %1\"\n-                 : \"=r\"(result), \"=m\"(*intp)\n-                 : \"0\"(val), \"m\"(*intp));\n-    return result + val;\n-#else\n-    __asm\n-    {\n+#  pragma warning(default : 4035)\n+\n+#  pragma warning(disable : 4035)\n+PRInt32 _PR_MD_ATOMIC_ADD(PRInt32* intp, PRInt32 val) {\n+#  if defined(__GNUC__)\n+  PRInt32 result;\n+  // asm volatile(\"lock ; xadd %1, %0\" : \"=m\" (intp), \"=a\" (result) : \"1\"\n+  // (val));\n+  asm volatile(\"lock ; xadd %0, %1\"\n+               : \"=r\"(result), \"=m\"(*intp)\n+               : \"0\"(val), \"m\"(*intp));\n+  return result + val;\n+#  else\n+  __asm\n+  {\n         mov ecx, intp\n         mov eax, val\n         mov edx, eax\n         lock xadd dword ptr [ecx], eax\n         add eax, edx\n-    }\n-#endif /* __GNUC__ */\n+  }\n+#  endif /* __GNUC__ */\n }\n-#pragma warning(default : 4035)\n+#  pragma warning(default : 4035)\n \n-#ifdef _PR_HAVE_ATOMIC_CAS\n+#  ifdef _PR_HAVE_ATOMIC_CAS\n \n-#pragma warning(disable : 4035)\n-void\n-PR_StackPush(PRStack* stack, PRStackElem* stack_elem)\n-{\n-#if defined(__GNUC__)\n-    void** tos = (void**)stack;\n-    void* tmp;\n+#    pragma warning(disable : 4035)\n+void PR_StackPush(PRStack* stack, PRStackElem* stack_elem) {\n+#    if defined(__GNUC__)\n+  void** tos = (void**)stack;\n+  void* tmp;\n \n retry:\n-    if (*tos == (void*)-1) {\n-        goto retry;\n-    }\n-\n-    __asm__(\"xchg %0,%1\" : \"=r\"(tmp), \"=m\"(*tos) : \"0\"(-1), \"m\"(*tos));\n-\n-    if (tmp == (void*)-1) {\n-        goto retry;\n-    }\n-\n-    *(void**)stack_elem = tmp;\n-    __asm__(\"\" : : : \"memory\");\n-    *tos = stack_elem;\n-#else\n-    __asm\n-    {\n+  if (*tos == (void*)-1) {\n+    goto retry;\n+  }\n+\n+  __asm__(\"xchg %0,%1\" : \"=r\"(tmp), \"=m\"(*tos) : \"0\"(-1), \"m\"(*tos));\n+\n+  if (tmp == (void*)-1) {\n+    goto retry;\n+  }\n+\n+  *(void**)stack_elem = tmp;\n+  __asm__(\"\" : : : \"memory\");\n+  *tos = stack_elem;\n+#    else\n+  __asm\n+  {\n         mov ebx, stack\n         mov ecx, stack_elem\n         retry:  mov eax,[ebx]\n@@ -1151,42 +1089,40 @@ retry:\n         je  retry\n         mov [ecx],eax\n         mov [ebx],ecx\n-    }\n-#endif /* __GNUC__ */\n+  }\n+#    endif /* __GNUC__ */\n }\n-#pragma warning(default : 4035)\n+#    pragma warning(default : 4035)\n \n-#pragma warning(disable : 4035)\n-PRStackElem*\n-PR_StackPop(PRStack* stack)\n-{\n-#if defined(__GNUC__)\n-    void** tos = (void**)stack;\n-    void* tmp;\n+#    pragma warning(disable : 4035)\n+PRStackElem* PR_StackPop(PRStack* stack) {\n+#    if defined(__GNUC__)\n+  void** tos = (void**)stack;\n+  void* tmp;\n \n retry:\n-    if (*tos == (void*)-1) {\n-        goto retry;\n-    }\n-\n-    __asm__(\"xchg %0,%1\" : \"=r\"(tmp), \"=m\"(*tos) : \"0\"(-1), \"m\"(*tos));\n-\n-    if (tmp == (void*)-1) {\n-        goto retry;\n-    }\n-\n-    if (tmp != (void*)0) {\n-        void* next = *(void**)tmp;\n-        *tos = next;\n-        *(void**)tmp = 0;\n-    } else {\n-        *tos = tmp;\n-    }\n-\n-    return tmp;\n-#else\n-    __asm\n-    {\n+  if (*tos == (void*)-1) {\n+    goto retry;\n+  }\n+\n+  __asm__(\"xchg %0,%1\" : \"=r\"(tmp), \"=m\"(*tos) : \"0\"(-1), \"m\"(*tos));\n+\n+  if (tmp == (void*)-1) {\n+    goto retry;\n+  }\n+\n+  if (tmp != (void*)0) {\n+    void* next = *(void**)tmp;\n+    *tos = next;\n+    *(void**)tmp = 0;\n+  } else {\n+    *tos = tmp;\n+  }\n+\n+  return tmp;\n+#    else\n+  __asm\n+  {\n         mov ebx, stack\n         retry:  mov eax,[ebx]\n         cmp eax,-1\n@@ -1204,11 +1140,11 @@ retry:\n         empty:\n         mov [ebx],eax\n         done:\n-    }\n-#endif /* __GNUC__ */\n+  }\n+#    endif /* __GNUC__ */\n }\n-#pragma warning(default : 4035)\n+#    pragma warning(default : 4035)\n \n-#endif /* _PR_HAVE_ATOMIC_CAS */\n+#  endif /* _PR_HAVE_ATOMIC_CAS */\n \n #endif /* x86 processors */\ndiff --git a/nspr/pr/src/md/windows/ntsec.c b/nspr/pr/src/md/windows/ntsec.c\nindex ff330b1..d551bd9 100644\n--- a/nspr/pr/src/md/windows/ntsec.c\n+++ b/nspr/pr/src/md/windows/ntsec.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -23,9 +24,9 @@\n  * look them up every time.\n  */\n static struct {\n-    PSID owner;\n-    PSID group;\n-    PSID everyone;\n+  PSID owner;\n+  PSID group;\n+  PSID everyone;\n } _pr_nt_sids;\n \n /*\n@@ -34,68 +35,66 @@ static struct {\n  *\n  * This function needs to be called by NSPR initialization.\n  */\n-void\n-_PR_NT_InitSids(void)\n-{\n+void _PR_NT_InitSids(void) {\n #ifdef WINCE /* not supported */\n-    return;\n+  return;\n #else\n-    SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;\n-    HANDLE hToken = NULL;                 /* initialized to an arbitrary value to\n-                                           * silence a Purify UMR warning */\n-    PSID infoBuffer[1024 / sizeof(PSID)]; /* defined as an array of PSIDs\n-                                           * to force proper alignment */\n-    PTOKEN_OWNER pTokenOwner = (PTOKEN_OWNER)infoBuffer;\n-    PTOKEN_PRIMARY_GROUP pTokenPrimaryGroup = (PTOKEN_PRIMARY_GROUP)infoBuffer;\n-    DWORD dwLength;\n-    BOOL rv;\n+  SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;\n+  HANDLE hToken = NULL;                 /* initialized to an arbitrary value to\n+                                         * silence a Purify UMR warning */\n+  PSID infoBuffer[1024 / sizeof(PSID)]; /* defined as an array of PSIDs\n+                                         * to force proper alignment */\n+  PTOKEN_OWNER pTokenOwner = (PTOKEN_OWNER)infoBuffer;\n+  PTOKEN_PRIMARY_GROUP pTokenPrimaryGroup = (PTOKEN_PRIMARY_GROUP)infoBuffer;\n+  DWORD dwLength;\n+  BOOL rv;\n \n+  /*\n+   * Look up and make a copy of the owner and primary group\n+   * SIDs in the access token of the calling process.\n+   */\n+  rv = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken);\n+  if (rv == 0) {\n     /*\n-     * Look up and make a copy of the owner and primary group\n-     * SIDs in the access token of the calling process.\n+     * On non-NT systems, this function is not implemented\n+     * (error code ERROR_CALL_NOT_IMPLEMENTED), and neither are\n+     * the other security functions.  There is no point in\n+     * going further.\n+     *\n+     * A process with insufficient access permissions may fail\n+     * with the error code ERROR_ACCESS_DENIED.\n      */\n-    rv = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken);\n-    if (rv == 0) {\n-        /*\n-         * On non-NT systems, this function is not implemented\n-         * (error code ERROR_CALL_NOT_IMPLEMENTED), and neither are\n-         * the other security functions.  There is no point in\n-         * going further.\n-         *\n-         * A process with insufficient access permissions may fail\n-         * with the error code ERROR_ACCESS_DENIED.\n-         */\n-        PR_LOG(_pr_io_lm, PR_LOG_DEBUG,\n-               (\"_PR_NT_InitSids: OpenProcessToken() failed. Error: %d\",\n-                GetLastError()));\n-        return;\n-    }\n+    PR_LOG(_pr_io_lm, PR_LOG_DEBUG,\n+           (\"_PR_NT_InitSids: OpenProcessToken() failed. Error: %d\",\n+            GetLastError()));\n+    return;\n+  }\n \n-    rv = GetTokenInformation(hToken, TokenOwner, infoBuffer, sizeof(infoBuffer),\n-                             &dwLength);\n-    PR_ASSERT(rv != 0);\n-    dwLength = GetLengthSid(pTokenOwner->Owner);\n-    _pr_nt_sids.owner = (PSID)PR_Malloc(dwLength);\n-    PR_ASSERT(_pr_nt_sids.owner != NULL);\n-    rv = CopySid(dwLength, _pr_nt_sids.owner, pTokenOwner->Owner);\n-    PR_ASSERT(rv != 0);\n+  rv = GetTokenInformation(hToken, TokenOwner, infoBuffer, sizeof(infoBuffer),\n+                           &dwLength);\n+  PR_ASSERT(rv != 0);\n+  dwLength = GetLengthSid(pTokenOwner->Owner);\n+  _pr_nt_sids.owner = (PSID)PR_Malloc(dwLength);\n+  PR_ASSERT(_pr_nt_sids.owner != NULL);\n+  rv = CopySid(dwLength, _pr_nt_sids.owner, pTokenOwner->Owner);\n+  PR_ASSERT(rv != 0);\n \n-    rv = GetTokenInformation(hToken, TokenPrimaryGroup, infoBuffer,\n-                             sizeof(infoBuffer), &dwLength);\n-    PR_ASSERT(rv != 0);\n-    dwLength = GetLengthSid(pTokenPrimaryGroup->PrimaryGroup);\n-    _pr_nt_sids.group = (PSID)PR_Malloc(dwLength);\n-    PR_ASSERT(_pr_nt_sids.group != NULL);\n-    rv = CopySid(dwLength, _pr_nt_sids.group, pTokenPrimaryGroup->PrimaryGroup);\n-    PR_ASSERT(rv != 0);\n+  rv = GetTokenInformation(hToken, TokenPrimaryGroup, infoBuffer,\n+                           sizeof(infoBuffer), &dwLength);\n+  PR_ASSERT(rv != 0);\n+  dwLength = GetLengthSid(pTokenPrimaryGroup->PrimaryGroup);\n+  _pr_nt_sids.group = (PSID)PR_Malloc(dwLength);\n+  PR_ASSERT(_pr_nt_sids.group != NULL);\n+  rv = CopySid(dwLength, _pr_nt_sids.group, pTokenPrimaryGroup->PrimaryGroup);\n+  PR_ASSERT(rv != 0);\n \n-    rv = CloseHandle(hToken);\n-    PR_ASSERT(rv != 0);\n+  rv = CloseHandle(hToken);\n+  PR_ASSERT(rv != 0);\n \n-    /* Create a well-known SID for the Everyone group. */\n-    rv = AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0,\n-                                  0, 0, 0, 0, &_pr_nt_sids.everyone);\n-    PR_ASSERT(rv != 0);\n+  /* Create a well-known SID for the Everyone group. */\n+  rv = AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0,\n+                                0, 0, 0, 0, &_pr_nt_sids.everyone);\n+  PR_ASSERT(rv != 0);\n #endif\n }\n \n@@ -105,21 +104,19 @@ _PR_NT_InitSids(void)\n  *\n  * This function needs to be called by NSPR cleanup.\n  */\n-void\n-_PR_NT_FreeSids(void)\n-{\n+void _PR_NT_FreeSids(void) {\n #ifdef WINCE\n-    return;\n+  return;\n #else\n-    if (_pr_nt_sids.owner) {\n-        PR_Free(_pr_nt_sids.owner);\n-    }\n-    if (_pr_nt_sids.group) {\n-        PR_Free(_pr_nt_sids.group);\n-    }\n-    if (_pr_nt_sids.everyone) {\n-        FreeSid(_pr_nt_sids.everyone);\n-    }\n+  if (_pr_nt_sids.owner) {\n+    PR_Free(_pr_nt_sids.owner);\n+  }\n+  if (_pr_nt_sids.group) {\n+    PR_Free(_pr_nt_sids.group);\n+  }\n+  if (_pr_nt_sids.everyone) {\n+    FreeSid(_pr_nt_sids.everyone);\n+  }\n #endif\n }\n \n@@ -134,124 +131,122 @@ _PR_NT_FreeSids(void)\n  * rights to the corresponding NT access rights for the securable\n  * object.\n  */\n-PRStatus\n-_PR_NT_MakeSecurityDescriptorACL(PRIntn mode, DWORD accessTable[],\n-                                 PSECURITY_DESCRIPTOR* resultSD,\n-                                 PACL* resultACL)\n-{\n+PRStatus _PR_NT_MakeSecurityDescriptorACL(PRIntn mode, DWORD accessTable[],\n+                                          PSECURITY_DESCRIPTOR* resultSD,\n+                                          PACL* resultACL) {\n #ifdef WINCE\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n #else\n-    PSECURITY_DESCRIPTOR pSD = NULL;\n-    PACL pACL = NULL;\n-    DWORD cbACL; /* size of ACL */\n-    DWORD accessMask;\n+  PSECURITY_DESCRIPTOR pSD = NULL;\n+  PACL pACL = NULL;\n+  DWORD cbACL; /* size of ACL */\n+  DWORD accessMask;\n \n-    if (_pr_nt_sids.owner == NULL) {\n-        PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (_pr_nt_sids.owner == NULL) {\n+    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-    pSD = (PSECURITY_DESCRIPTOR)PR_Malloc(SECURITY_DESCRIPTOR_MIN_LENGTH);\n-    if (pSD == NULL) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        goto failed;\n-    }\n-    if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        goto failed;\n-    }\n-    if (!SetSecurityDescriptorOwner(pSD, _pr_nt_sids.owner, FALSE)) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        goto failed;\n-    }\n-    if (!SetSecurityDescriptorGroup(pSD, _pr_nt_sids.group, FALSE)) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        goto failed;\n-    }\n+  pSD = (PSECURITY_DESCRIPTOR)PR_Malloc(SECURITY_DESCRIPTOR_MIN_LENGTH);\n+  if (pSD == NULL) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    goto failed;\n+  }\n+  if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    goto failed;\n+  }\n+  if (!SetSecurityDescriptorOwner(pSD, _pr_nt_sids.owner, FALSE)) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    goto failed;\n+  }\n+  if (!SetSecurityDescriptorGroup(pSD, _pr_nt_sids.group, FALSE)) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    goto failed;\n+  }\n \n-    /*\n-     * Construct a discretionary access-control list with three\n-     * access-control entries, one each for owner, primary group,\n-     * and Everyone.\n-     */\n+  /*\n+   * Construct a discretionary access-control list with three\n+   * access-control entries, one each for owner, primary group,\n+   * and Everyone.\n+   */\n \n-    cbACL = sizeof(ACL) + 3 * (sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD)) +\n-            GetLengthSid(_pr_nt_sids.owner) + GetLengthSid(_pr_nt_sids.group) +\n-            GetLengthSid(_pr_nt_sids.everyone);\n-    pACL = (PACL)PR_Malloc(cbACL);\n-    if (pACL == NULL) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        goto failed;\n-    }\n-    if (!InitializeAcl(pACL, cbACL, ACL_REVISION)) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        goto failed;\n-    }\n-    accessMask = 0;\n-    if (mode & 00400) {\n-        accessMask |= accessTable[0];\n-    }\n-    if (mode & 00200) {\n-        accessMask |= accessTable[1];\n-    }\n-    if (mode & 00100) {\n-        accessMask |= accessTable[2];\n-    }\n-    if (accessMask &&\n-        !AddAccessAllowedAce(pACL, ACL_REVISION, accessMask, _pr_nt_sids.owner)) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        goto failed;\n-    }\n-    accessMask = 0;\n-    if (mode & 00040) {\n-        accessMask |= accessTable[0];\n-    }\n-    if (mode & 00020) {\n-        accessMask |= accessTable[1];\n-    }\n-    if (mode & 00010) {\n-        accessMask |= accessTable[2];\n-    }\n-    if (accessMask &&\n-        !AddAccessAllowedAce(pACL, ACL_REVISION, accessMask, _pr_nt_sids.group)) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        goto failed;\n-    }\n-    accessMask = 0;\n-    if (mode & 00004) {\n-        accessMask |= accessTable[0];\n-    }\n-    if (mode & 00002) {\n-        accessMask |= accessTable[1];\n-    }\n-    if (mode & 00001) {\n-        accessMask |= accessTable[2];\n-    }\n-    if (accessMask && !AddAccessAllowedAce(pACL, ACL_REVISION, accessMask,\n-                                           _pr_nt_sids.everyone)) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        goto failed;\n-    }\n+  cbACL = sizeof(ACL) + 3 * (sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD)) +\n+          GetLengthSid(_pr_nt_sids.owner) + GetLengthSid(_pr_nt_sids.group) +\n+          GetLengthSid(_pr_nt_sids.everyone);\n+  pACL = (PACL)PR_Malloc(cbACL);\n+  if (pACL == NULL) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    goto failed;\n+  }\n+  if (!InitializeAcl(pACL, cbACL, ACL_REVISION)) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    goto failed;\n+  }\n+  accessMask = 0;\n+  if (mode & 00400) {\n+    accessMask |= accessTable[0];\n+  }\n+  if (mode & 00200) {\n+    accessMask |= accessTable[1];\n+  }\n+  if (mode & 00100) {\n+    accessMask |= accessTable[2];\n+  }\n+  if (accessMask &&\n+      !AddAccessAllowedAce(pACL, ACL_REVISION, accessMask, _pr_nt_sids.owner)) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    goto failed;\n+  }\n+  accessMask = 0;\n+  if (mode & 00040) {\n+    accessMask |= accessTable[0];\n+  }\n+  if (mode & 00020) {\n+    accessMask |= accessTable[1];\n+  }\n+  if (mode & 00010) {\n+    accessMask |= accessTable[2];\n+  }\n+  if (accessMask &&\n+      !AddAccessAllowedAce(pACL, ACL_REVISION, accessMask, _pr_nt_sids.group)) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    goto failed;\n+  }\n+  accessMask = 0;\n+  if (mode & 00004) {\n+    accessMask |= accessTable[0];\n+  }\n+  if (mode & 00002) {\n+    accessMask |= accessTable[1];\n+  }\n+  if (mode & 00001) {\n+    accessMask |= accessTable[2];\n+  }\n+  if (accessMask && !AddAccessAllowedAce(pACL, ACL_REVISION, accessMask,\n+                                         _pr_nt_sids.everyone)) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    goto failed;\n+  }\n \n-    if (!SetSecurityDescriptorDacl(pSD, TRUE, pACL, FALSE)) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        goto failed;\n-    }\n+  if (!SetSecurityDescriptorDacl(pSD, TRUE, pACL, FALSE)) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    goto failed;\n+  }\n \n-    *resultSD = pSD;\n-    *resultACL = pACL;\n-    return PR_SUCCESS;\n+  *resultSD = pSD;\n+  *resultACL = pACL;\n+  return PR_SUCCESS;\n \n failed:\n-    if (pSD) {\n-        PR_Free(pSD);\n-    }\n-    if (pACL) {\n-        PR_Free(pACL);\n-    }\n-    return PR_FAILURE;\n+  if (pSD) {\n+    PR_Free(pSD);\n+  }\n+  if (pACL) {\n+    PR_Free(pACL);\n+  }\n+  return PR_FAILURE;\n #endif\n }\n \n@@ -259,13 +254,11 @@ failed:\n  * Free the specified security descriptor and access-control list\n  * previously created by _PR_NT_MakeSecurityDescriptorACL.\n  */\n-void\n-_PR_NT_FreeSecurityDescriptorACL(PSECURITY_DESCRIPTOR pSD, PACL pACL)\n-{\n-    if (pSD) {\n-        PR_Free(pSD);\n-    }\n-    if (pACL) {\n-        PR_Free(pACL);\n-    }\n+void _PR_NT_FreeSecurityDescriptorACL(PSECURITY_DESCRIPTOR pSD, PACL pACL) {\n+  if (pSD) {\n+    PR_Free(pSD);\n+  }\n+  if (pACL) {\n+    PR_Free(pACL);\n+  }\n }\ndiff --git a/nspr/pr/src/md/windows/ntsem.c b/nspr/pr/src/md/windows/ntsem.c\nindex e8f4f30..983ba03 100644\n--- a/nspr/pr/src/md/windows/ntsem.c\n+++ b/nspr/pr/src/md/windows/ntsem.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,40 +10,26 @@\n \n #include \"primpl.h\"\n \n-void\n-_PR_MD_NEW_SEM(_MDSemaphore* md, PRUintn value)\n-{\n-    md->sem = CreateSemaphore(NULL, value, 0x7fffffff, NULL);\n+void _PR_MD_NEW_SEM(_MDSemaphore* md, PRUintn value) {\n+  md->sem = CreateSemaphore(NULL, value, 0x7fffffff, NULL);\n }\n \n-void\n-_PR_MD_DESTROY_SEM(_MDSemaphore* md)\n-{\n-    CloseHandle(md->sem);\n-}\n+void _PR_MD_DESTROY_SEM(_MDSemaphore* md) { CloseHandle(md->sem); }\n \n-PRStatus\n-_PR_MD_TIMED_WAIT_SEM(_MDSemaphore* md, PRIntervalTime ticks)\n-{\n-    int rv;\n+PRStatus _PR_MD_TIMED_WAIT_SEM(_MDSemaphore* md, PRIntervalTime ticks) {\n+  int rv;\n \n-    rv = WaitForSingleObject(md->sem, PR_IntervalToMilliseconds(ticks));\n+  rv = WaitForSingleObject(md->sem, PR_IntervalToMilliseconds(ticks));\n \n-    if (rv == WAIT_OBJECT_0) {\n-        return PR_SUCCESS;\n-    } else {\n-        return PR_FAILURE;\n-    }\n+  if (rv == WAIT_OBJECT_0) {\n+    return PR_SUCCESS;\n+  } else {\n+    return PR_FAILURE;\n+  }\n }\n \n-PRStatus\n-_PR_MD_WAIT_SEM(_MDSemaphore* md)\n-{\n-    return _PR_MD_TIMED_WAIT_SEM(md, PR_INTERVAL_NO_TIMEOUT);\n+PRStatus _PR_MD_WAIT_SEM(_MDSemaphore* md) {\n+  return _PR_MD_TIMED_WAIT_SEM(md, PR_INTERVAL_NO_TIMEOUT);\n }\n \n-void\n-_PR_MD_POST_SEM(_MDSemaphore* md)\n-{\n-    ReleaseSemaphore(md->sem, 1, NULL);\n-}\n+void _PR_MD_POST_SEM(_MDSemaphore* md) { ReleaseSemaphore(md->sem, 1, NULL); }\ndiff --git a/nspr/pr/src/md/windows/ntthread.c b/nspr/pr/src/md/windows/ntthread.c\nindex 5d82a53..34fc676 100644\n--- a/nspr/pr/src/md/windows/ntthread.c\n+++ b/nspr/pr/src/md/windows/ntthread.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,7 +8,7 @@\n \n /* --- globals ------------------------------------------------ */\n PRLock* _pr_schedLock = NULL;\n-_PRInterruptTable _pr_interruptTable[] = { { 0 } };\n+_PRInterruptTable _pr_interruptTable[] = {{0}};\n \n BOOL _pr_use_static_tls = TRUE;\n __declspec(thread) PRThread* _pr_current_fiber;\n@@ -30,61 +31,57 @@ typedef HRESULT(WINAPI* SETTHREADDESCRIPTION)(HANDLE, PCWSTR);\n static SETTHREADDESCRIPTION sSetThreadDescription = NULL;\n \n /* Must check the restarted_io *before* decrementing no_sched to 0 */\n-#define POST_SWITCH_WORK()                                                      \\\n-    PR_BEGIN_MACRO                                                              \\\n-    PRThread* restarted_io =                                                    \\\n-        (_pr_use_static_tls ? _pr_io_restarted_io                               \\\n-                            : (PRThread*)TlsGetValue(_pr_io_restartedIOIndex)); \\\n-    if (restarted_io) {                                                         \\\n-        _nt_handle_restarted_io(restarted_io);                                  \\\n-    }                                                                           \\\n-    _PR_MD_LAST_THREAD()->no_sched = 0;                                         \\\n-    PR_END_MACRO\n-\n-void\n-_nt_handle_restarted_io(PRThread* restarted_io)\n-{\n-    /* After the switch we can resume an IO if needed.\n-     * XXXMB - this needs to be done in create thread, since that could\n-     * be the result for a context switch too..\n-     */\n-    PR_ASSERT(restarted_io->io_suspended == PR_TRUE);\n-    PR_ASSERT(restarted_io->md.thr_bound_cpu == restarted_io->cpu);\n-\n-    _PR_THREAD_LOCK(restarted_io);\n-    if (restarted_io->io_pending == PR_FALSE) {\n-        /* The IO already completed, put us back on the runq. */\n-        int pri = restarted_io->priority;\n-\n-        restarted_io->state = _PR_RUNNABLE;\n-        _PR_RUNQ_LOCK(restarted_io->cpu);\n-        _PR_ADD_RUNQ(restarted_io, restarted_io->cpu, pri);\n-        _PR_RUNQ_UNLOCK(restarted_io->cpu);\n-    } else {\n-        _PR_SLEEPQ_LOCK(restarted_io->cpu);\n-        _PR_ADD_SLEEPQ(restarted_io, restarted_io->sleep);\n-        _PR_SLEEPQ_UNLOCK(restarted_io->cpu);\n-    }\n-    restarted_io->io_suspended = PR_FALSE;\n-    restarted_io->md.thr_bound_cpu = NULL;\n-\n-    _PR_THREAD_UNLOCK(restarted_io);\n-\n-    if (_pr_use_static_tls) {\n-        _pr_io_restarted_io = NULL;\n-    } else {\n-        TlsSetValue(_pr_io_restartedIOIndex, NULL);\n-    }\n+#define POST_SWITCH_WORK()                                                    \\\n+  PR_BEGIN_MACRO                                                              \\\n+  PRThread* restarted_io =                                                    \\\n+      (_pr_use_static_tls ? _pr_io_restarted_io                               \\\n+                          : (PRThread*)TlsGetValue(_pr_io_restartedIOIndex)); \\\n+  if (restarted_io) {                                                         \\\n+    _nt_handle_restarted_io(restarted_io);                                    \\\n+  }                                                                           \\\n+  _PR_MD_LAST_THREAD()->no_sched = 0;                                         \\\n+  PR_END_MACRO\n+\n+void _nt_handle_restarted_io(PRThread* restarted_io) {\n+  /* After the switch we can resume an IO if needed.\n+   * XXXMB - this needs to be done in create thread, since that could\n+   * be the result for a context switch too..\n+   */\n+  PR_ASSERT(restarted_io->io_suspended == PR_TRUE);\n+  PR_ASSERT(restarted_io->md.thr_bound_cpu == restarted_io->cpu);\n+\n+  _PR_THREAD_LOCK(restarted_io);\n+  if (restarted_io->io_pending == PR_FALSE) {\n+    /* The IO already completed, put us back on the runq. */\n+    int pri = restarted_io->priority;\n+\n+    restarted_io->state = _PR_RUNNABLE;\n+    _PR_RUNQ_LOCK(restarted_io->cpu);\n+    _PR_ADD_RUNQ(restarted_io, restarted_io->cpu, pri);\n+    _PR_RUNQ_UNLOCK(restarted_io->cpu);\n+  } else {\n+    _PR_SLEEPQ_LOCK(restarted_io->cpu);\n+    _PR_ADD_SLEEPQ(restarted_io, restarted_io->sleep);\n+    _PR_SLEEPQ_UNLOCK(restarted_io->cpu);\n+  }\n+  restarted_io->io_suspended = PR_FALSE;\n+  restarted_io->md.thr_bound_cpu = NULL;\n+\n+  _PR_THREAD_UNLOCK(restarted_io);\n+\n+  if (_pr_use_static_tls) {\n+    _pr_io_restarted_io = NULL;\n+  } else {\n+    TlsSetValue(_pr_io_restartedIOIndex, NULL);\n+  }\n }\n \n-void\n-_PR_MD_EARLY_INIT()\n-{\n-    HMODULE hModule;\n+void _PR_MD_EARLY_INIT() {\n+  HMODULE hModule;\n \n-    _MD_NEW_LOCK(&_nt_idleLock);\n-    _nt_idleCount = 0;\n-    PR_INIT_CLIST(&_nt_idleList);\n+  _MD_NEW_LOCK(&_nt_idleLock);\n+  _nt_idleCount = 0;\n+  PR_INIT_CLIST(&_nt_idleList);\n \n #if 0\n     /* Make the clock tick at least once per millisecond */\n@@ -94,482 +91,424 @@ _PR_MD_EARLY_INIT()\n     }\n #endif\n \n-    if (!_pr_use_static_tls) {\n-        _pr_currentFiberIndex = TlsAlloc();\n-        _pr_lastFiberIndex = TlsAlloc();\n-        _pr_currentCPUIndex = TlsAlloc();\n-        _pr_intsOffIndex = TlsAlloc();\n-        _pr_io_restartedIOIndex = TlsAlloc();\n-    }\n-\n-    // SetThreadDescription is Windows 10 build 1607+\n-    hModule = GetModuleHandleW(L\"kernel32.dll\");\n-    if (hModule) {\n-        sSetThreadDescription =\n-            (SETTHREADDESCRIPTION)GetProcAddress(hModule, \"SetThreadDescription\");\n-    }\n+  if (!_pr_use_static_tls) {\n+    _pr_currentFiberIndex = TlsAlloc();\n+    _pr_lastFiberIndex = TlsAlloc();\n+    _pr_currentCPUIndex = TlsAlloc();\n+    _pr_intsOffIndex = TlsAlloc();\n+    _pr_io_restartedIOIndex = TlsAlloc();\n+  }\n+\n+  // SetThreadDescription is Windows 10 build 1607+\n+  hModule = GetModuleHandleW(L\"kernel32.dll\");\n+  if (hModule) {\n+    sSetThreadDescription =\n+        (SETTHREADDESCRIPTION)GetProcAddress(hModule, \"SetThreadDescription\");\n+  }\n }\n \n-void\n-_PR_MD_CLEANUP_BEFORE_EXIT(void)\n-{\n-    _PR_NT_FreeSids();\n+void _PR_MD_CLEANUP_BEFORE_EXIT(void) {\n+  _PR_NT_FreeSids();\n \n-    WSACleanup();\n+  WSACleanup();\n \n-    if (!_pr_use_static_tls) {\n-        TlsFree(_pr_currentFiberIndex);\n-        TlsFree(_pr_lastFiberIndex);\n-        TlsFree(_pr_currentCPUIndex);\n-        TlsFree(_pr_intsOffIndex);\n-        TlsFree(_pr_io_restartedIOIndex);\n-    }\n+  if (!_pr_use_static_tls) {\n+    TlsFree(_pr_currentFiberIndex);\n+    TlsFree(_pr_lastFiberIndex);\n+    TlsFree(_pr_currentCPUIndex);\n+    TlsFree(_pr_intsOffIndex);\n+    TlsFree(_pr_io_restartedIOIndex);\n+  }\n }\n \n-PRStatus\n-_PR_MD_INIT_THREAD(PRThread* thread)\n-{\n-    thread->md.overlapped.ioModel = _MD_BlockingIO;\n-    thread->md.overlapped.data.mdThread = &thread->md;\n-\n-    if (thread->flags & _PR_GLOBAL_SCOPE) {\n-        if (thread->flags & (_PR_PRIMORDIAL | _PR_ATTACHED)) {\n-            /*\n-            ** Warning:\n-            ** --------\n-            ** NSPR requires a real handle to every thread.\n-            ** GetCurrentThread() returns a pseudo-handle which\n-            ** is not suitable for some thread operations (e.g.,\n-            ** suspending).  Therefore, get a real handle from\n-            ** the pseudo handle via DuplicateHandle(...)\n-            */\n-            DuplicateHandle(GetCurrentProcess(),    /* Process of source handle */\n-                            GetCurrentThread(),     /* Pseudo Handle to dup */\n-                            GetCurrentProcess(),    /* Process of handle */\n-                            &(thread->md.handle),   /* resulting handle */\n-                            0L,                     /* access flags */\n-                            FALSE,                  /* Inheritable */\n-                            DUPLICATE_SAME_ACCESS); /* Options */\n-        }\n-\n-        /* Create the blocking IO semaphore */\n-        thread->md.blocked_sema = CreateSemaphore(NULL, 0, 1, NULL);\n-        if (thread->md.blocked_sema == NULL) {\n-            return PR_FAILURE;\n-        }\n-        if (_native_threads_only) {\n-            /* Create the blocking IO semaphore */\n-            thread->md.thr_event = CreateEvent(NULL, TRUE, FALSE, NULL);\n-            if (thread->md.thr_event == NULL) {\n-                return PR_FAILURE;\n-            }\n-        }\n+PRStatus _PR_MD_INIT_THREAD(PRThread* thread) {\n+  thread->md.overlapped.ioModel = _MD_BlockingIO;\n+  thread->md.overlapped.data.mdThread = &thread->md;\n+\n+  if (thread->flags & _PR_GLOBAL_SCOPE) {\n+    if (thread->flags & (_PR_PRIMORDIAL | _PR_ATTACHED)) {\n+      /*\n+      ** Warning:\n+      ** --------\n+      ** NSPR requires a real handle to every thread.\n+      ** GetCurrentThread() returns a pseudo-handle which\n+      ** is not suitable for some thread operations (e.g.,\n+      ** suspending).  Therefore, get a real handle from\n+      ** the pseudo handle via DuplicateHandle(...)\n+      */\n+      DuplicateHandle(GetCurrentProcess(),    /* Process of source handle */\n+                      GetCurrentThread(),     /* Pseudo Handle to dup */\n+                      GetCurrentProcess(),    /* Process of handle */\n+                      &(thread->md.handle),   /* resulting handle */\n+                      0L,                     /* access flags */\n+                      FALSE,                  /* Inheritable */\n+                      DUPLICATE_SAME_ACCESS); /* Options */\n+    }\n+\n+    /* Create the blocking IO semaphore */\n+    thread->md.blocked_sema = CreateSemaphore(NULL, 0, 1, NULL);\n+    if (thread->md.blocked_sema == NULL) {\n+      return PR_FAILURE;\n     }\n-\n-    return PR_SUCCESS;\n-}\n-\n-static unsigned __stdcall\n-pr_root(void* arg)\n-{\n-    PRThread* thread = (PRThread*)arg;\n-    thread->md.start(thread);\n-    return 0;\n-}\n-\n-PRStatus\n-_PR_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                     PRThreadPriority priority, PRThreadScope scope,\n-                     PRThreadState state, PRUint32 stackSize)\n-{\n-    thread->md.start = start;\n-    thread->md.handle = (HANDLE)_beginthreadex(\n-        NULL, thread->stack->stackSize, pr_root, (void*)thread,\n-        CREATE_SUSPENDED | STACK_SIZE_PARAM_IS_A_RESERVATION, &(thread->id));\n-    if (!thread->md.handle) {\n-        PRErrorCode prerror;\n-        thread->md.fiber_last_error = GetLastError();\n-        switch (errno) {\n-            case ENOMEM:\n-                prerror = PR_OUT_OF_MEMORY_ERROR;\n-                break;\n-            case EAGAIN:\n-                prerror = PR_INSUFFICIENT_RESOURCES_ERROR;\n-                break;\n-            case EINVAL:\n-                prerror = PR_INVALID_ARGUMENT_ERROR;\n-                break;\n-            default:\n-                prerror = PR_UNKNOWN_ERROR;\n-        }\n-        PR_SetError(prerror, errno);\n+    if (_native_threads_only) {\n+      /* Create the blocking IO semaphore */\n+      thread->md.thr_event = CreateEvent(NULL, TRUE, FALSE, NULL);\n+      if (thread->md.thr_event == NULL) {\n         return PR_FAILURE;\n+      }\n     }\n+  }\n \n-    thread->md.id = thread->id;\n-    /*\n-     * On windows, a thread is created with a thread priority of\n-     * THREAD_PRIORITY_NORMAL.\n-     */\n-    if (priority != PR_PRIORITY_NORMAL) {\n-        _PR_MD_SET_PRIORITY(&(thread->md), priority);\n-    }\n+  return PR_SUCCESS;\n+}\n \n-    /* Activate the thread */\n-    if (ResumeThread(thread->md.handle) != -1) {\n-        return PR_SUCCESS;\n-    }\n+static unsigned __stdcall pr_root(void* arg) {\n+  PRThread* thread = (PRThread*)arg;\n+  thread->md.start(thread);\n+  return 0;\n+}\n \n-    PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n+PRStatus _PR_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n+                              PRThreadPriority priority, PRThreadScope scope,\n+                              PRThreadState state, PRUint32 stackSize) {\n+  thread->md.start = start;\n+  thread->md.handle = (HANDLE)_beginthreadex(\n+      NULL, thread->stack->stackSize, pr_root, (void*)thread,\n+      CREATE_SUSPENDED | STACK_SIZE_PARAM_IS_A_RESERVATION, &(thread->id));\n+  if (!thread->md.handle) {\n+    PRErrorCode prerror;\n+    thread->md.fiber_last_error = GetLastError();\n+    switch (errno) {\n+      case ENOMEM:\n+        prerror = PR_OUT_OF_MEMORY_ERROR;\n+        break;\n+      case EAGAIN:\n+        prerror = PR_INSUFFICIENT_RESOURCES_ERROR;\n+        break;\n+      case EINVAL:\n+        prerror = PR_INVALID_ARGUMENT_ERROR;\n+        break;\n+      default:\n+        prerror = PR_UNKNOWN_ERROR;\n+    }\n+    PR_SetError(prerror, errno);\n     return PR_FAILURE;\n+  }\n+\n+  thread->md.id = thread->id;\n+  /*\n+   * On windows, a thread is created with a thread priority of\n+   * THREAD_PRIORITY_NORMAL.\n+   */\n+  if (priority != PR_PRIORITY_NORMAL) {\n+    _PR_MD_SET_PRIORITY(&(thread->md), priority);\n+  }\n+\n+  /* Activate the thread */\n+  if (ResumeThread(thread->md.handle) != -1) {\n+    return PR_SUCCESS;\n+  }\n+\n+  PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n+  return PR_FAILURE;\n }\n \n-void\n-_PR_MD_JOIN_THREAD(_MDThread* md)\n-{\n-    DWORD rv;\n+void _PR_MD_JOIN_THREAD(_MDThread* md) {\n+  DWORD rv;\n \n-    rv = WaitForSingleObject(md->handle, INFINITE);\n-    PR_ASSERT(WAIT_OBJECT_0 == rv);\n+  rv = WaitForSingleObject(md->handle, INFINITE);\n+  PR_ASSERT(WAIT_OBJECT_0 == rv);\n }\n \n-void\n-_PR_MD_END_THREAD(void)\n-{\n-    _endthreadex(0);\n-}\n+void _PR_MD_END_THREAD(void) { _endthreadex(0); }\n \n-void\n-_PR_MD_YIELD(void)\n-{\n-    /* Can NT really yield at all? */\n-    Sleep(0);\n+void _PR_MD_YIELD(void) {\n+  /* Can NT really yield at all? */\n+  Sleep(0);\n }\n \n-void\n-_PR_MD_SET_PRIORITY(_MDThread* thread, PRThreadPriority newPri)\n-{\n-    int nativePri;\n-    BOOL rv;\n-\n-    if (newPri < PR_PRIORITY_FIRST) {\n-        newPri = PR_PRIORITY_FIRST;\n-    } else if (newPri > PR_PRIORITY_LAST) {\n-        newPri = PR_PRIORITY_LAST;\n-    }\n-    switch (newPri) {\n-        case PR_PRIORITY_LOW:\n-            nativePri = THREAD_PRIORITY_BELOW_NORMAL;\n-            break;\n-        case PR_PRIORITY_NORMAL:\n-            nativePri = THREAD_PRIORITY_NORMAL;\n-            break;\n-        case PR_PRIORITY_HIGH:\n-            nativePri = THREAD_PRIORITY_ABOVE_NORMAL;\n-            break;\n-        case PR_PRIORITY_URGENT:\n-            nativePri = THREAD_PRIORITY_HIGHEST;\n-    }\n-    rv = SetThreadPriority(thread->handle, nativePri);\n-    PR_ASSERT(rv);\n-    if (!rv) {\n-        PR_LOG(_pr_thread_lm, PR_LOG_MIN,\n-               (\"PR_SetThreadPriority: can't set thread priority\\n\"));\n-    }\n-    return;\n+void _PR_MD_SET_PRIORITY(_MDThread* thread, PRThreadPriority newPri) {\n+  int nativePri;\n+  BOOL rv;\n+\n+  if (newPri < PR_PRIORITY_FIRST) {\n+    newPri = PR_PRIORITY_FIRST;\n+  } else if (newPri > PR_PRIORITY_LAST) {\n+    newPri = PR_PRIORITY_LAST;\n+  }\n+  switch (newPri) {\n+    case PR_PRIORITY_LOW:\n+      nativePri = THREAD_PRIORITY_BELOW_NORMAL;\n+      break;\n+    case PR_PRIORITY_NORMAL:\n+      nativePri = THREAD_PRIORITY_NORMAL;\n+      break;\n+    case PR_PRIORITY_HIGH:\n+      nativePri = THREAD_PRIORITY_ABOVE_NORMAL;\n+      break;\n+    case PR_PRIORITY_URGENT:\n+      nativePri = THREAD_PRIORITY_HIGHEST;\n+  }\n+  rv = SetThreadPriority(thread->handle, nativePri);\n+  PR_ASSERT(rv);\n+  if (!rv) {\n+    PR_LOG(_pr_thread_lm, PR_LOG_MIN,\n+           (\"PR_SetThreadPriority: can't set thread priority\\n\"));\n+  }\n+  return;\n }\n \n const DWORD MS_VC_EXCEPTION = 0x406D1388;\n \n #pragma pack(push, 8)\n typedef struct tagTHREADNAME_INFO {\n-    DWORD dwType;     // Must be 0x1000.\n-    LPCSTR szName;    // Pointer to name (in user addr space).\n-    DWORD dwThreadID; // Thread ID (-1=caller thread).\n-    DWORD dwFlags;    // Reserved for future use, must be zero.\n+  DWORD dwType;      // Must be 0x1000.\n+  LPCSTR szName;     // Pointer to name (in user addr space).\n+  DWORD dwThreadID;  // Thread ID (-1=caller thread).\n+  DWORD dwFlags;     // Reserved for future use, must be zero.\n } THREADNAME_INFO;\n #pragma pack(pop)\n \n-void\n-_PR_MD_SET_CURRENT_THREAD_NAME(const char* name)\n-{\n+void _PR_MD_SET_CURRENT_THREAD_NAME(const char* name) {\n #ifdef _MSC_VER\n-    THREADNAME_INFO info;\n+  THREADNAME_INFO info;\n #endif\n \n-    if (sSetThreadDescription) {\n-        WCHAR wideName[MAX_PATH];\n-        if (MultiByteToWideChar(CP_ACP, 0, name, -1, wideName, MAX_PATH)) {\n-            sSetThreadDescription(GetCurrentThread(), wideName);\n-        }\n+  if (sSetThreadDescription) {\n+    WCHAR wideName[MAX_PATH];\n+    if (MultiByteToWideChar(CP_ACP, 0, name, -1, wideName, MAX_PATH)) {\n+      sSetThreadDescription(GetCurrentThread(), wideName);\n     }\n+  }\n \n #ifdef _MSC_VER\n-    if (!IsDebuggerPresent()) {\n-        return;\n-    }\n-\n-    info.dwType = 0x1000;\n-    info.szName = (char*)name;\n-    info.dwThreadID = -1;\n-    info.dwFlags = 0;\n-\n-    __try {\n-        RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR),\n-                       (ULONG_PTR*)&info);\n-    } __except (EXCEPTION_CONTINUE_EXECUTION) {\n-    }\n+  if (!IsDebuggerPresent()) {\n+    return;\n+  }\n+\n+  info.dwType = 0x1000;\n+  info.szName = (char*)name;\n+  info.dwThreadID = -1;\n+  info.dwFlags = 0;\n+\n+  __try {\n+    RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR),\n+                   (ULONG_PTR*)&info);\n+  } __except (EXCEPTION_CONTINUE_EXECUTION) {\n+  }\n #endif\n }\n \n-void\n-_PR_MD_CLEAN_THREAD(PRThread* thread)\n-{\n-    BOOL rv;\n+void _PR_MD_CLEAN_THREAD(PRThread* thread) {\n+  BOOL rv;\n \n-    if (thread->md.acceptex_buf) {\n-        PR_DELETE(thread->md.acceptex_buf);\n-    }\n+  if (thread->md.acceptex_buf) {\n+    PR_DELETE(thread->md.acceptex_buf);\n+  }\n \n-    if (thread->md.xmit_bufs) {\n-        PR_DELETE(thread->md.xmit_bufs);\n-    }\n-\n-    if (thread->md.blocked_sema) {\n-        rv = CloseHandle(thread->md.blocked_sema);\n-        PR_ASSERT(rv);\n-        thread->md.blocked_sema = 0;\n-    }\n-    if (_native_threads_only) {\n-        if (thread->md.thr_event) {\n-            rv = CloseHandle(thread->md.thr_event);\n-            PR_ASSERT(rv);\n-            thread->md.thr_event = 0;\n-        }\n-    }\n+  if (thread->md.xmit_bufs) {\n+    PR_DELETE(thread->md.xmit_bufs);\n+  }\n \n-    if (thread->md.handle) {\n-        rv = CloseHandle(thread->md.handle);\n-        PR_ASSERT(rv);\n-        thread->md.handle = 0;\n-    }\n-\n-    /* Don't call DeleteFiber on current fiber or we'll kill the whole thread.\n-     * Don't call free(thread) until we've switched off the thread.\n-     * So put this fiber (or thread) on a list to be deleted by the idle\n-     * fiber next time we have a chance.\n-     */\n-    if (!(thread->flags & (_PR_ATTACHED | _PR_GLOBAL_SCOPE))) {\n-        _MD_LOCK(&_nt_idleLock);\n-        _nt_idleCount++;\n-        PR_APPEND_LINK(&thread->links, &_nt_idleList);\n-        _MD_UNLOCK(&_nt_idleLock);\n-    }\n+  if (thread->md.blocked_sema) {\n+    rv = CloseHandle(thread->md.blocked_sema);\n+    PR_ASSERT(rv);\n+    thread->md.blocked_sema = 0;\n+  }\n+  if (_native_threads_only) {\n+    if (thread->md.thr_event) {\n+      rv = CloseHandle(thread->md.thr_event);\n+      PR_ASSERT(rv);\n+      thread->md.thr_event = 0;\n+    }\n+  }\n+\n+  if (thread->md.handle) {\n+    rv = CloseHandle(thread->md.handle);\n+    PR_ASSERT(rv);\n+    thread->md.handle = 0;\n+  }\n+\n+  /* Don't call DeleteFiber on current fiber or we'll kill the whole thread.\n+   * Don't call free(thread) until we've switched off the thread.\n+   * So put this fiber (or thread) on a list to be deleted by the idle\n+   * fiber next time we have a chance.\n+   */\n+  if (!(thread->flags & (_PR_ATTACHED | _PR_GLOBAL_SCOPE))) {\n+    _MD_LOCK(&_nt_idleLock);\n+    _nt_idleCount++;\n+    PR_APPEND_LINK(&thread->links, &_nt_idleList);\n+    _MD_UNLOCK(&_nt_idleLock);\n+  }\n }\n \n-void\n-_PR_MD_EXIT_THREAD(PRThread* thread)\n-{\n-    BOOL rv;\n+void _PR_MD_EXIT_THREAD(PRThread* thread) {\n+  BOOL rv;\n \n-    if (thread->md.acceptex_buf) {\n-        PR_DELETE(thread->md.acceptex_buf);\n-    }\n+  if (thread->md.acceptex_buf) {\n+    PR_DELETE(thread->md.acceptex_buf);\n+  }\n \n-    if (thread->md.xmit_bufs) {\n-        PR_DELETE(thread->md.xmit_bufs);\n-    }\n+  if (thread->md.xmit_bufs) {\n+    PR_DELETE(thread->md.xmit_bufs);\n+  }\n \n-    if (thread->md.blocked_sema) {\n-        rv = CloseHandle(thread->md.blocked_sema);\n-        PR_ASSERT(rv);\n-        thread->md.blocked_sema = 0;\n-    }\n+  if (thread->md.blocked_sema) {\n+    rv = CloseHandle(thread->md.blocked_sema);\n+    PR_ASSERT(rv);\n+    thread->md.blocked_sema = 0;\n+  }\n \n-    if (_native_threads_only) {\n-        if (thread->md.thr_event) {\n-            rv = CloseHandle(thread->md.thr_event);\n-            PR_ASSERT(rv);\n-            thread->md.thr_event = 0;\n-        }\n+  if (_native_threads_only) {\n+    if (thread->md.thr_event) {\n+      rv = CloseHandle(thread->md.thr_event);\n+      PR_ASSERT(rv);\n+      thread->md.thr_event = 0;\n     }\n+  }\n \n-    if (thread->md.handle) {\n-        rv = CloseHandle(thread->md.handle);\n-        PR_ASSERT(rv);\n-        thread->md.handle = 0;\n-    }\n+  if (thread->md.handle) {\n+    rv = CloseHandle(thread->md.handle);\n+    PR_ASSERT(rv);\n+    thread->md.handle = 0;\n+  }\n \n-    if (thread->flags & _PR_GLOBAL_SCOPE) {\n-        _MD_SET_CURRENT_THREAD(NULL);\n-    }\n+  if (thread->flags & _PR_GLOBAL_SCOPE) {\n+    _MD_SET_CURRENT_THREAD(NULL);\n+  }\n }\n \n-void\n-_PR_MD_EXIT(PRIntn status)\n-{\n-    _exit(status);\n-}\n+void _PR_MD_EXIT(PRIntn status) { _exit(status); }\n \n #ifdef HAVE_FIBERS\n \n-void\n-_pr_fiber_mainline(void* unused)\n-{\n-    PRThread* fiber = _PR_MD_CURRENT_THREAD();\n+void _pr_fiber_mainline(void* unused) {\n+  PRThread* fiber = _PR_MD_CURRENT_THREAD();\n \n-    POST_SWITCH_WORK();\n+  POST_SWITCH_WORK();\n \n-    fiber->md.fiber_fn(fiber->md.fiber_arg);\n+  fiber->md.fiber_fn(fiber->md.fiber_arg);\n }\n \n-PRThread*\n-_PR_MD_CREATE_USER_THREAD(PRUint32 stacksize, void (*start)(void*),\n-                          void* arg)\n-{\n-    PRThread* thread;\n+PRThread* _PR_MD_CREATE_USER_THREAD(PRUint32 stacksize, void (*start)(void*),\n+                                    void* arg) {\n+  PRThread* thread;\n \n-    if ((thread = PR_NEW(PRThread)) == NULL) {\n-        return NULL;\n-    }\n+  if ((thread = PR_NEW(PRThread)) == NULL) {\n+    return NULL;\n+  }\n \n-    memset(thread, 0, sizeof(PRThread));\n-    thread->md.fiber_fn = start;\n-    thread->md.fiber_arg = arg;\n-    thread->md.fiber_stacksize = stacksize;\n-    return thread;\n+  memset(thread, 0, sizeof(PRThread));\n+  thread->md.fiber_fn = start;\n+  thread->md.fiber_arg = arg;\n+  thread->md.fiber_stacksize = stacksize;\n+  return thread;\n }\n \n-void\n-_PR_MD_CREATE_PRIMORDIAL_USER_THREAD(PRThread* thread)\n-{\n-    thread->md.fiber_id = ConvertThreadToFiber(NULL);\n-    PR_ASSERT(thread->md.fiber_id);\n-    _MD_SET_CURRENT_THREAD(thread);\n-    _MD_SET_LAST_THREAD(thread);\n-    thread->no_sched = 1;\n-    return;\n+void _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(PRThread* thread) {\n+  thread->md.fiber_id = ConvertThreadToFiber(NULL);\n+  PR_ASSERT(thread->md.fiber_id);\n+  _MD_SET_CURRENT_THREAD(thread);\n+  _MD_SET_LAST_THREAD(thread);\n+  thread->no_sched = 1;\n+  return;\n }\n \n-void\n-_PR_MD_INIT_CONTEXT(PRThread* thread, char* top, void (*start)(void),\n-                    PRBool* status)\n-{\n-    thread->md.fiber_fn = (void (*)(void*))start;\n-    thread->md.fiber_id =\n-        CreateFiber(thread->md.fiber_stacksize,\n-                    (LPFIBER_START_ROUTINE)_pr_fiber_mainline, NULL);\n-    if (thread->md.fiber_id != 0) {\n-        *status = PR_TRUE;\n+void _PR_MD_INIT_CONTEXT(PRThread* thread, char* top, void (*start)(void),\n+                         PRBool* status) {\n+  thread->md.fiber_fn = (void (*)(void*))start;\n+  thread->md.fiber_id =\n+      CreateFiber(thread->md.fiber_stacksize,\n+                  (LPFIBER_START_ROUTINE)_pr_fiber_mainline, NULL);\n+  if (thread->md.fiber_id != 0) {\n+    *status = PR_TRUE;\n+  } else {\n+    DWORD oserror = GetLastError();\n+    PRErrorCode prerror;\n+    if (oserror == ERROR_NOT_ENOUGH_MEMORY) {\n+      prerror = PR_OUT_OF_MEMORY_ERROR;\n     } else {\n-        DWORD oserror = GetLastError();\n-        PRErrorCode prerror;\n-        if (oserror == ERROR_NOT_ENOUGH_MEMORY) {\n-            prerror = PR_OUT_OF_MEMORY_ERROR;\n-        } else {\n-            prerror = PR_UNKNOWN_ERROR;\n-        }\n-        PR_SetError(prerror, oserror);\n-        *status = PR_FALSE;\n+      prerror = PR_UNKNOWN_ERROR;\n     }\n+    PR_SetError(prerror, oserror);\n+    *status = PR_FALSE;\n+  }\n }\n \n-void\n-_PR_MD_SWITCH_CONTEXT(PRThread* thread)\n-{\n-    PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread));\n+void _PR_MD_SWITCH_CONTEXT(PRThread* thread) {\n+  PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread));\n \n-    thread->md.fiber_last_error = GetLastError();\n-    _PR_Schedule();\n+  thread->md.fiber_last_error = GetLastError();\n+  _PR_Schedule();\n }\n \n-void\n-_PR_MD_RESTORE_CONTEXT(PRThread* thread)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread));\n-\n-    /* The user-level code for yielding will happily add ourselves to the runq\n-     * and then switch to ourselves; the NT fibers can't handle switching to\n-     * ourselves.\n-     */\n-    if (thread != me) {\n-        SetLastError(thread->md.fiber_last_error);\n-        _MD_SET_CURRENT_THREAD(thread);\n-        _PR_MD_SET_LAST_THREAD(me);\n-        thread->no_sched = 1;\n-        SwitchToFiber(thread->md.fiber_id);\n-        POST_SWITCH_WORK();\n-    }\n+void _PR_MD_RESTORE_CONTEXT(PRThread* thread) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread));\n+\n+  /* The user-level code for yielding will happily add ourselves to the runq\n+   * and then switch to ourselves; the NT fibers can't handle switching to\n+   * ourselves.\n+   */\n+  if (thread != me) {\n+    SetLastError(thread->md.fiber_last_error);\n+    _MD_SET_CURRENT_THREAD(thread);\n+    _PR_MD_SET_LAST_THREAD(me);\n+    thread->no_sched = 1;\n+    SwitchToFiber(thread->md.fiber_id);\n+    POST_SWITCH_WORK();\n+  }\n }\n \n #endif /* HAVE_FIBERS */\n \n-PRInt32\n-_PR_MD_SETTHREADAFFINITYMASK(PRThread* thread, PRUint32 mask)\n-{\n-    int rv;\n+PRInt32 _PR_MD_SETTHREADAFFINITYMASK(PRThread* thread, PRUint32 mask) {\n+  int rv;\n \n-    rv = SetThreadAffinityMask(thread->md.handle, mask);\n+  rv = SetThreadAffinityMask(thread->md.handle, mask);\n \n-    return rv ? 0 : -1;\n+  return rv ? 0 : -1;\n }\n \n-PRInt32\n-_PR_MD_GETTHREADAFFINITYMASK(PRThread* thread, PRUint32* mask)\n-{\n-    PRInt32 rv, system_mask;\n+PRInt32 _PR_MD_GETTHREADAFFINITYMASK(PRThread* thread, PRUint32* mask) {\n+  PRInt32 rv, system_mask;\n \n-    rv = GetProcessAffinityMask(GetCurrentProcess(), mask, &system_mask);\n+  rv = GetProcessAffinityMask(GetCurrentProcess(), mask, &system_mask);\n \n-    return rv ? 0 : -1;\n+  return rv ? 0 : -1;\n }\n \n-void\n-_PR_MD_SUSPEND_CPU(_PRCPU* cpu)\n-{\n-    _PR_MD_SUSPEND_THREAD(cpu->thread);\n-}\n+void _PR_MD_SUSPEND_CPU(_PRCPU* cpu) { _PR_MD_SUSPEND_THREAD(cpu->thread); }\n \n-void\n-_PR_MD_RESUME_CPU(_PRCPU* cpu)\n-{\n-    _PR_MD_RESUME_THREAD(cpu->thread);\n-}\n+void _PR_MD_RESUME_CPU(_PRCPU* cpu) { _PR_MD_RESUME_THREAD(cpu->thread); }\n \n-void\n-_PR_MD_SUSPEND_THREAD(PRThread* thread)\n-{\n-    if (_PR_IS_NATIVE_THREAD(thread)) {\n-        /*\n-        ** There seems to be some doubt about whether or not SuspendThread\n-        ** is a synchronous function. The test afterwards is to help veriry\n-        ** that it is, which is what Microsoft says it is.\n-        */\n-        PRUintn rv = SuspendThread(thread->md.handle);\n-        PR_ASSERT(0xffffffffUL != rv);\n-    }\n+void _PR_MD_SUSPEND_THREAD(PRThread* thread) {\n+  if (_PR_IS_NATIVE_THREAD(thread)) {\n+    /*\n+    ** There seems to be some doubt about whether or not SuspendThread\n+    ** is a synchronous function. The test afterwards is to help veriry\n+    ** that it is, which is what Microsoft says it is.\n+    */\n+    PRUintn rv = SuspendThread(thread->md.handle);\n+    PR_ASSERT(0xffffffffUL != rv);\n+  }\n }\n \n-void\n-_PR_MD_RESUME_THREAD(PRThread* thread)\n-{\n-    if (_PR_IS_NATIVE_THREAD(thread)) {\n-        ResumeThread(thread->md.handle);\n-    }\n+void _PR_MD_RESUME_THREAD(PRThread* thread) {\n+  if (_PR_IS_NATIVE_THREAD(thread)) {\n+    ResumeThread(thread->md.handle);\n+  }\n }\n \n-PRThread*\n-_MD_CURRENT_THREAD(void)\n-{\n-    PRThread* thread;\n+PRThread* _MD_CURRENT_THREAD(void) {\n+  PRThread* thread;\n \n-    thread = _MD_GET_ATTACHED_THREAD();\n+  thread = _MD_GET_ATTACHED_THREAD();\n \n-    if (NULL == thread) {\n-        thread = _PRI_AttachThread(PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL, 0);\n-    }\n-    PR_ASSERT(thread != NULL);\n-    return thread;\n+  if (NULL == thread) {\n+    thread = _PRI_AttachThread(PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL, 0);\n+  }\n+  PR_ASSERT(thread != NULL);\n+  return thread;\n }\ndiff --git a/nspr/pr/src/md/windows/w32ipcsem.c b/nspr/pr/src/md/windows/w32ipcsem.c\nindex 48758db..666a438 100644\n--- a/nspr/pr/src/md/windows/w32ipcsem.c\n+++ b/nspr/pr/src/md/windows/w32ipcsem.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,27 +11,25 @@\n #include \"primpl.h\"\n \n #ifdef WINCE\n-static HANDLE\n-OpenSemaphore(DWORD inDesiredAccess, BOOL inInheritHandle,\n-              const char* inName)\n-{\n-    HANDLE retval = NULL;\n-    HANDLE semaphore = NULL;\n-    PRUnichar wideName[MAX_PATH]; /* name size is limited to MAX_PATH */\n-\n-    MultiByteToWideChar(CP_ACP, 0, inName, -1, wideName, MAX_PATH);\n-    /* 0x7fffffff is the max count for our semaphore */\n-    semaphore = CreateSemaphoreW(NULL, 0, 0x7fffffff, wideName);\n-    if (NULL != semaphore) {\n-        DWORD lastErr = GetLastError();\n-\n-        if (ERROR_ALREADY_EXISTS != lastErr) {\n-            CloseHandle(semaphore);\n-        } else {\n-            retval = semaphore;\n-        }\n+static HANDLE OpenSemaphore(DWORD inDesiredAccess, BOOL inInheritHandle,\n+                            const char* inName) {\n+  HANDLE retval = NULL;\n+  HANDLE semaphore = NULL;\n+  PRUnichar wideName[MAX_PATH]; /* name size is limited to MAX_PATH */\n+\n+  MultiByteToWideChar(CP_ACP, 0, inName, -1, wideName, MAX_PATH);\n+  /* 0x7fffffff is the max count for our semaphore */\n+  semaphore = CreateSemaphoreW(NULL, 0, 0x7fffffff, wideName);\n+  if (NULL != semaphore) {\n+    DWORD lastErr = GetLastError();\n+\n+    if (ERROR_ALREADY_EXISTS != lastErr) {\n+      CloseHandle(semaphore);\n+    } else {\n+      retval = semaphore;\n     }\n-    return retval;\n+  }\n+  return retval;\n }\n #endif\n \n@@ -45,9 +44,9 @@ OpenSemaphore(DWORD inDesiredAccess, BOOL inInheritHandle,\n  * the existing object.\n  */\n static DWORD semAccessTable[] = {\n-    STANDARD_RIGHTS_REQUIRED | 0x1,                                  /* read (0x1 is \"query state\") */\n+    STANDARD_RIGHTS_REQUIRED | 0x1, /* read (0x1 is \"query state\") */\n     STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | SEMAPHORE_MODIFY_STATE, /* write */\n-    0                                                                /* execute */\n+    0 /* execute */\n };\n \n #ifndef _PR_GLOBAL_THREADS_ONLY\n@@ -64,169 +63,157 @@ static DWORD semAccessTable[] = {\n  * Arguments, return value, and error code for WaitForSingleObject\n  */\n struct WaitSingleArg {\n-    HANDLE handle;\n-    DWORD timeout;\n-    DWORD rv;\n-    DWORD error;\n+  HANDLE handle;\n+  DWORD timeout;\n+  DWORD rv;\n+  DWORD error;\n };\n \n-static void\n-WaitSingleThread(void* arg)\n-{\n-    struct WaitSingleArg* warg = (struct WaitSingleArg*)arg;\n+static void WaitSingleThread(void* arg) {\n+  struct WaitSingleArg* warg = (struct WaitSingleArg*)arg;\n \n-    warg->rv = WaitForSingleObject(warg->handle, warg->timeout);\n-    if (warg->rv == WAIT_FAILED) {\n-        warg->error = GetLastError();\n-    }\n+  warg->rv = WaitForSingleObject(warg->handle, warg->timeout);\n+  if (warg->rv == WAIT_FAILED) {\n+    warg->error = GetLastError();\n+  }\n }\n \n-static DWORD\n-FiberSafeWaitForSingleObject(HANDLE hHandle,\n-                             DWORD dwMilliseconds)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+static DWORD FiberSafeWaitForSingleObject(HANDLE hHandle,\n+                                          DWORD dwMilliseconds) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (_PR_IS_NATIVE_THREAD(me)) {\n+    return WaitForSingleObject(hHandle, dwMilliseconds);\n+  } else {\n+    PRThread* waitThread;\n+    struct WaitSingleArg warg;\n+    PRStatus rv;\n+\n+    warg.handle = hHandle;\n+    warg.timeout = dwMilliseconds;\n+    waitThread = PR_CreateThread(PR_USER_THREAD, WaitSingleThread, &warg,\n+                                 PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n+                                 PR_JOINABLE_THREAD, 0);\n+    if (waitThread == NULL) {\n+      return WAIT_FAILED;\n+    }\n \n-    if (_PR_IS_NATIVE_THREAD(me)) {\n-        return WaitForSingleObject(hHandle, dwMilliseconds);\n-    } else {\n-        PRThread* waitThread;\n-        struct WaitSingleArg warg;\n-        PRStatus rv;\n-\n-        warg.handle = hHandle;\n-        warg.timeout = dwMilliseconds;\n-        waitThread = PR_CreateThread(PR_USER_THREAD, WaitSingleThread, &warg,\n-                                     PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n-                                     PR_JOINABLE_THREAD, 0);\n-        if (waitThread == NULL) {\n-            return WAIT_FAILED;\n-        }\n-\n-        rv = PR_JoinThread(waitThread);\n-        PR_ASSERT(rv == PR_SUCCESS);\n-        if (rv == PR_FAILURE) {\n-            return WAIT_FAILED;\n-        }\n-        if (warg.rv == WAIT_FAILED) {\n-            SetLastError(warg.error);\n-        }\n-        return warg.rv;\n+    rv = PR_JoinThread(waitThread);\n+    PR_ASSERT(rv == PR_SUCCESS);\n+    if (rv == PR_FAILURE) {\n+      return WAIT_FAILED;\n+    }\n+    if (warg.rv == WAIT_FAILED) {\n+      SetLastError(warg.error);\n     }\n+    return warg.rv;\n+  }\n }\n \n #endif /* !_PR_GLOBAL_THREADS_ONLY */\n \n-PRSem*\n-_PR_MD_OPEN_SEMAPHORE(const char* osname, PRIntn flags, PRIntn mode,\n-                      PRUintn value)\n-{\n-    PRSem* sem;\n-    SECURITY_ATTRIBUTES sa;\n-    LPSECURITY_ATTRIBUTES lpSA = NULL;\n-    PSECURITY_DESCRIPTOR pSD = NULL;\n-    PACL pACL = NULL;\n-\n-    sem = PR_NEW(PRSem);\n-    if (sem == NULL) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n+PRSem* _PR_MD_OPEN_SEMAPHORE(const char* osname, PRIntn flags, PRIntn mode,\n+                             PRUintn value) {\n+  PRSem* sem;\n+  SECURITY_ATTRIBUTES sa;\n+  LPSECURITY_ATTRIBUTES lpSA = NULL;\n+  PSECURITY_DESCRIPTOR pSD = NULL;\n+  PACL pACL = NULL;\n+\n+  sem = PR_NEW(PRSem);\n+  if (sem == NULL) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n+  if (flags & PR_SEM_CREATE) {\n+    if (_PR_NT_MakeSecurityDescriptorACL(mode, semAccessTable, &pSD, &pACL) ==\n+        PR_SUCCESS) {\n+      sa.nLength = sizeof(sa);\n+      sa.lpSecurityDescriptor = pSD;\n+      sa.bInheritHandle = FALSE;\n+      lpSA = &sa;\n     }\n-    if (flags & PR_SEM_CREATE) {\n-        if (_PR_NT_MakeSecurityDescriptorACL(mode, semAccessTable, &pSD, &pACL) ==\n-            PR_SUCCESS) {\n-            sa.nLength = sizeof(sa);\n-            sa.lpSecurityDescriptor = pSD;\n-            sa.bInheritHandle = FALSE;\n-            lpSA = &sa;\n-        }\n #ifdef WINCE\n-        {\n-            /* The size of a sem's name is limited to MAX_PATH. */\n-            PRUnichar wosname[MAX_PATH];\n-            MultiByteToWideChar(CP_ACP, 0, osname, -1, wosname, MAX_PATH);\n-            sem->sem = CreateSemaphoreW(lpSA, value, 0x7fffffff, wosname);\n-        }\n+    {\n+      /* The size of a sem's name is limited to MAX_PATH. */\n+      PRUnichar wosname[MAX_PATH];\n+      MultiByteToWideChar(CP_ACP, 0, osname, -1, wosname, MAX_PATH);\n+      sem->sem = CreateSemaphoreW(lpSA, value, 0x7fffffff, wosname);\n+    }\n #else\n-        sem->sem = CreateSemaphoreA(lpSA, value, 0x7fffffff, osname);\n+    sem->sem = CreateSemaphoreA(lpSA, value, 0x7fffffff, osname);\n #endif\n-        if (lpSA != NULL) {\n-            _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n-        }\n-        if (sem->sem == NULL) {\n-            _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-            PR_DELETE(sem);\n-            return NULL;\n-        }\n-        if ((flags & PR_SEM_EXCL) && (GetLastError() == ERROR_ALREADY_EXISTS)) {\n-            PR_SetError(PR_FILE_EXISTS_ERROR, ERROR_ALREADY_EXISTS);\n-            CloseHandle(sem->sem);\n-            PR_DELETE(sem);\n-            return NULL;\n-        }\n-    } else {\n-        sem->sem =\n-            OpenSemaphore(SEMAPHORE_MODIFY_STATE | SYNCHRONIZE, FALSE, osname);\n-        if (sem->sem == NULL) {\n-            DWORD err = GetLastError();\n-\n-            /*\n-             * If we open a nonexistent named semaphore, NT\n-             * returns ERROR_FILE_NOT_FOUND, while Win95\n-             * returns ERROR_INVALID_NAME\n-             */\n-            if (err == ERROR_INVALID_NAME) {\n-                PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);\n-            } else {\n-                _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-            }\n-            PR_DELETE(sem);\n-            return NULL;\n-        }\n+    if (lpSA != NULL) {\n+      _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n+    }\n+    if (sem->sem == NULL) {\n+      _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+      PR_DELETE(sem);\n+      return NULL;\n+    }\n+    if ((flags & PR_SEM_EXCL) && (GetLastError() == ERROR_ALREADY_EXISTS)) {\n+      PR_SetError(PR_FILE_EXISTS_ERROR, ERROR_ALREADY_EXISTS);\n+      CloseHandle(sem->sem);\n+      PR_DELETE(sem);\n+      return NULL;\n     }\n-    return sem;\n+  } else {\n+    sem->sem =\n+        OpenSemaphore(SEMAPHORE_MODIFY_STATE | SYNCHRONIZE, FALSE, osname);\n+    if (sem->sem == NULL) {\n+      DWORD err = GetLastError();\n+\n+      /*\n+       * If we open a nonexistent named semaphore, NT\n+       * returns ERROR_FILE_NOT_FOUND, while Win95\n+       * returns ERROR_INVALID_NAME\n+       */\n+      if (err == ERROR_INVALID_NAME) {\n+        PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);\n+      } else {\n+        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+      }\n+      PR_DELETE(sem);\n+      return NULL;\n+    }\n+  }\n+  return sem;\n }\n \n-PRStatus\n-_PR_MD_WAIT_SEMAPHORE(PRSem* sem)\n-{\n-    DWORD rv;\n+PRStatus _PR_MD_WAIT_SEMAPHORE(PRSem* sem) {\n+  DWORD rv;\n \n #ifdef _PR_GLOBAL_THREADS_ONLY\n-    rv = WaitForSingleObject(sem->sem, INFINITE);\n+  rv = WaitForSingleObject(sem->sem, INFINITE);\n #else\n-    rv = FiberSafeWaitForSingleObject(sem->sem, INFINITE);\n+  rv = FiberSafeWaitForSingleObject(sem->sem, INFINITE);\n #endif\n-    PR_ASSERT(rv == WAIT_FAILED || rv == WAIT_OBJECT_0);\n-    if (rv == WAIT_FAILED) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        return PR_FAILURE;\n-    }\n-    if (rv != WAIT_OBJECT_0) {\n-        /* Should not happen */\n-        PR_SetError(PR_UNKNOWN_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  PR_ASSERT(rv == WAIT_FAILED || rv == WAIT_OBJECT_0);\n+  if (rv == WAIT_FAILED) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    return PR_FAILURE;\n+  }\n+  if (rv != WAIT_OBJECT_0) {\n+    /* Should not happen */\n+    PR_SetError(PR_UNKNOWN_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_PR_MD_POST_SEMAPHORE(PRSem* sem)\n-{\n-    if (ReleaseSemaphore(sem->sem, 1, NULL) == FALSE) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+PRStatus _PR_MD_POST_SEMAPHORE(PRSem* sem) {\n+  if (ReleaseSemaphore(sem->sem, 1, NULL) == FALSE) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-PRStatus\n-_PR_MD_CLOSE_SEMAPHORE(PRSem* sem)\n-{\n-    if (CloseHandle(sem->sem) == FALSE) {\n-        _PR_MD_MAP_CLOSE_ERROR(GetLastError());\n-        return PR_FAILURE;\n-    }\n-    PR_DELETE(sem);\n-    return PR_SUCCESS;\n+PRStatus _PR_MD_CLOSE_SEMAPHORE(PRSem* sem) {\n+  if (CloseHandle(sem->sem) == FALSE) {\n+    _PR_MD_MAP_CLOSE_ERROR(GetLastError());\n+    return PR_FAILURE;\n+  }\n+  PR_DELETE(sem);\n+  return PR_SUCCESS;\n }\ndiff --git a/nspr/pr/src/md/windows/w32poll.c b/nspr/pr/src/md/windows/w32poll.c\nindex 60ccff5..f76a56e 100644\n--- a/nspr/pr/src/md/windows/w32poll.c\n+++ b/nspr/pr/src/md/windows/w32poll.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -14,284 +15,278 @@\n #if !defined(_PR_GLOBAL_THREADS_ONLY)\n \n struct select_data_s {\n-    PRInt32 status;\n-    PRInt32 error;\n-    fd_set *rd, *wt, *ex;\n-    const struct timeval* tv;\n+  PRInt32 status;\n+  PRInt32 error;\n+  fd_set *rd, *wt, *ex;\n+  const struct timeval* tv;\n };\n \n-static void\n-_PR_MD_select_thread(void* cdata)\n-{\n-    struct select_data_s* cd = (struct select_data_s*)cdata;\n+static void _PR_MD_select_thread(void* cdata) {\n+  struct select_data_s* cd = (struct select_data_s*)cdata;\n \n-    cd->status = select(0, cd->rd, cd->wt, cd->ex, cd->tv);\n+  cd->status = select(0, cd->rd, cd->wt, cd->ex, cd->tv);\n \n-    if (cd->status == SOCKET_ERROR) {\n-        cd->error = WSAGetLastError();\n-    }\n+  if (cd->status == SOCKET_ERROR) {\n+    cd->error = WSAGetLastError();\n+  }\n }\n \n-int\n-_PR_NTFiberSafeSelect(int nfds, fd_set* readfds, fd_set* writefds,\n-                      fd_set* exceptfds, const struct timeval* timeout)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    int ready;\n+int _PR_NTFiberSafeSelect(int nfds, fd_set* readfds, fd_set* writefds,\n+                          fd_set* exceptfds, const struct timeval* timeout) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  int ready;\n \n-    if (_PR_IS_NATIVE_THREAD(me)) {\n-        ready = _MD_SELECT(nfds, readfds, writefds, exceptfds, timeout);\n-    } else {\n-        /*\n-        ** Creating a new thread on each call!!\n-        ** I guess web server doesn't use non-block I/O.\n-        */\n-        PRThread* selectThread;\n-        struct select_data_s data;\n-        data.status = 0;\n-        data.error = 0;\n-        data.rd = readfds;\n-        data.wt = writefds;\n-        data.ex = exceptfds;\n-        data.tv = timeout;\n+  if (_PR_IS_NATIVE_THREAD(me)) {\n+    ready = _MD_SELECT(nfds, readfds, writefds, exceptfds, timeout);\n+  } else {\n+    /*\n+    ** Creating a new thread on each call!!\n+    ** I guess web server doesn't use non-block I/O.\n+    */\n+    PRThread* selectThread;\n+    struct select_data_s data;\n+    data.status = 0;\n+    data.error = 0;\n+    data.rd = readfds;\n+    data.wt = writefds;\n+    data.ex = exceptfds;\n+    data.tv = timeout;\n \n-        selectThread = PR_CreateThread(PR_USER_THREAD, _PR_MD_select_thread, &data,\n-                                       PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n-                                       PR_JOINABLE_THREAD, 0);\n-        if (selectThread == NULL) {\n-            return -1;\n-        }\n+    selectThread = PR_CreateThread(PR_USER_THREAD, _PR_MD_select_thread, &data,\n+                                   PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n+                                   PR_JOINABLE_THREAD, 0);\n+    if (selectThread == NULL) {\n+      return -1;\n+    }\n \n-        PR_JoinThread(selectThread);\n-        ready = data.status;\n-        if (ready == SOCKET_ERROR) {\n-            WSASetLastError(data.error);\n-        }\n+    PR_JoinThread(selectThread);\n+    ready = data.status;\n+    if (ready == SOCKET_ERROR) {\n+      WSASetLastError(data.error);\n     }\n-    return ready;\n+  }\n+  return ready;\n }\n \n #endif /* !defined(_PR_GLOBAL_THREADS_ONLY) */\n \n-PRInt32\n-_PR_MD_PR_POLL(PRPollDesc* pds, PRIntn npds, PRIntervalTime timeout)\n-{\n-    int ready, err;\n-    fd_set rd, wt, ex;\n-    fd_set *rdp, *wtp, *exp;\n-    int nrd, nwt, nex;\n-    PRFileDesc* bottom;\n-    PRPollDesc *pd, *epd;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+PRInt32 _PR_MD_PR_POLL(PRPollDesc* pds, PRIntn npds, PRIntervalTime timeout) {\n+  int ready, err;\n+  fd_set rd, wt, ex;\n+  fd_set *rdp, *wtp, *exp;\n+  int nrd, nwt, nex;\n+  PRFileDesc* bottom;\n+  PRPollDesc *pd, *epd;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    struct timeval tv, *tvp = NULL;\n+  struct timeval tv, *tvp = NULL;\n \n-    if (_PR_PENDING_INTERRUPT(me)) {\n-        me->flags &= ~_PR_INTERRUPT;\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        return -1;\n-    }\n+  if (_PR_PENDING_INTERRUPT(me)) {\n+    me->flags &= ~_PR_INTERRUPT;\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    return -1;\n+  }\n \n-    /*\n-    ** Is it an empty set? If so, just sleep for the timeout and return\n-    */\n-    if (0 == npds) {\n-        PR_Sleep(timeout);\n-        return 0;\n-    }\n+  /*\n+  ** Is it an empty set? If so, just sleep for the timeout and return\n+  */\n+  if (0 == npds) {\n+    PR_Sleep(timeout);\n+    return 0;\n+  }\n \n-    nrd = nwt = nex = 0;\n-    FD_ZERO(&rd);\n-    FD_ZERO(&wt);\n-    FD_ZERO(&ex);\n+  nrd = nwt = nex = 0;\n+  FD_ZERO(&rd);\n+  FD_ZERO(&wt);\n+  FD_ZERO(&ex);\n \n-    ready = 0;\n-    for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n-        SOCKET osfd;\n-        PRInt16 in_flags_read = 0, in_flags_write = 0;\n-        PRInt16 out_flags_read = 0, out_flags_write = 0;\n+  ready = 0;\n+  for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n+    SOCKET osfd;\n+    PRInt16 in_flags_read = 0, in_flags_write = 0;\n+    PRInt16 out_flags_read = 0, out_flags_write = 0;\n \n-        if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n-            if (pd->in_flags & PR_POLL_READ) {\n-                in_flags_read = (pd->fd->methods->poll)(\n-                    pd->fd, (PRInt16)(pd->in_flags & ~PR_POLL_WRITE), &out_flags_read);\n+    if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n+      if (pd->in_flags & PR_POLL_READ) {\n+        in_flags_read = (pd->fd->methods->poll)(\n+            pd->fd, (PRInt16)(pd->in_flags & ~PR_POLL_WRITE), &out_flags_read);\n+      }\n+      if (pd->in_flags & PR_POLL_WRITE) {\n+        in_flags_write = (pd->fd->methods->poll)(\n+            pd->fd, (PRInt16)(pd->in_flags & ~PR_POLL_READ), &out_flags_write);\n+      }\n+      if ((0 != (in_flags_read & out_flags_read)) ||\n+          (0 != (in_flags_write & out_flags_write))) {\n+        /* this one's ready right now (buffered input) */\n+        if (0 == ready) {\n+          /*\n+           * We will have to return without calling the\n+           * system poll/select function.  So zero the\n+           * out_flags fields of all the poll descriptors\n+           * before this one.\n+           */\n+          PRPollDesc* prev;\n+          for (prev = pds; prev < pd; prev++) {\n+            prev->out_flags = 0;\n+          }\n+        }\n+        ready += 1;\n+        pd->out_flags = out_flags_read | out_flags_write;\n+      } else {\n+        pd->out_flags = 0; /* pre-condition */\n+        /* make sure this is an NSPR supported stack */\n+        bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n+        /* ignore a socket without PR_NSPR_IO_LAYER available */\n+\n+        if ((NULL != bottom) && (_PR_FILEDESC_OPEN == bottom->secret->state)) {\n+          if (0 == ready) {\n+            osfd = (SOCKET)bottom->secret->md.osfd;\n+            if (in_flags_read & PR_POLL_READ) {\n+              pd->out_flags |= _PR_POLL_READ_SYS_READ;\n+              FD_SET(osfd, &rd);\n+              nrd++;\n             }\n-            if (pd->in_flags & PR_POLL_WRITE) {\n-                in_flags_write = (pd->fd->methods->poll)(\n-                    pd->fd, (PRInt16)(pd->in_flags & ~PR_POLL_READ), &out_flags_write);\n+            if (in_flags_read & PR_POLL_WRITE) {\n+              pd->out_flags |= _PR_POLL_READ_SYS_WRITE;\n+              FD_SET(osfd, &wt);\n+              nwt++;\n             }\n-            if ((0 != (in_flags_read & out_flags_read)) ||\n-                (0 != (in_flags_write & out_flags_write))) {\n-                /* this one's ready right now (buffered input) */\n-                if (0 == ready) {\n-                    /*\n-                     * We will have to return without calling the\n-                     * system poll/select function.  So zero the\n-                     * out_flags fields of all the poll descriptors\n-                     * before this one.\n-                     */\n-                    PRPollDesc* prev;\n-                    for (prev = pds; prev < pd; prev++) {\n-                        prev->out_flags = 0;\n-                    }\n-                }\n-                ready += 1;\n-                pd->out_flags = out_flags_read | out_flags_write;\n-            } else {\n-                pd->out_flags = 0; /* pre-condition */\n-                /* make sure this is an NSPR supported stack */\n-                bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n-                /* ignore a socket without PR_NSPR_IO_LAYER available */\n-\n-                if ((NULL != bottom) && (_PR_FILEDESC_OPEN == bottom->secret->state)) {\n-                    if (0 == ready) {\n-                        osfd = (SOCKET)bottom->secret->md.osfd;\n-                        if (in_flags_read & PR_POLL_READ) {\n-                            pd->out_flags |= _PR_POLL_READ_SYS_READ;\n-                            FD_SET(osfd, &rd);\n-                            nrd++;\n-                        }\n-                        if (in_flags_read & PR_POLL_WRITE) {\n-                            pd->out_flags |= _PR_POLL_READ_SYS_WRITE;\n-                            FD_SET(osfd, &wt);\n-                            nwt++;\n-                        }\n-                        if (in_flags_write & PR_POLL_READ) {\n-                            pd->out_flags |= _PR_POLL_WRITE_SYS_READ;\n-                            FD_SET(osfd, &rd);\n-                            nrd++;\n-                        }\n-                        if (in_flags_write & PR_POLL_WRITE) {\n-                            pd->out_flags |= _PR_POLL_WRITE_SYS_WRITE;\n-                            FD_SET(osfd, &wt);\n-                            nwt++;\n-                        }\n-                        if (pd->in_flags & PR_POLL_EXCEPT) {\n-                            FD_SET(osfd, &ex);\n-                            nex++;\n-                        }\n-                    }\n-                } else {\n-                    if (0 == ready) {\n-                        PRPollDesc* prev;\n-                        for (prev = pds; prev < pd; prev++) {\n-                            prev->out_flags = 0;\n-                        }\n-                    }\n-                    ready += 1;                   /* this will cause an abrupt return */\n-                    pd->out_flags = PR_POLL_NVAL; /* bogii */\n-                }\n+            if (in_flags_write & PR_POLL_READ) {\n+              pd->out_flags |= _PR_POLL_WRITE_SYS_READ;\n+              FD_SET(osfd, &rd);\n+              nrd++;\n+            }\n+            if (in_flags_write & PR_POLL_WRITE) {\n+              pd->out_flags |= _PR_POLL_WRITE_SYS_WRITE;\n+              FD_SET(osfd, &wt);\n+              nwt++;\n+            }\n+            if (pd->in_flags & PR_POLL_EXCEPT) {\n+              FD_SET(osfd, &ex);\n+              nex++;\n             }\n+          }\n         } else {\n-            pd->out_flags = 0;\n+          if (0 == ready) {\n+            PRPollDesc* prev;\n+            for (prev = pds; prev < pd; prev++) {\n+              prev->out_flags = 0;\n+            }\n+          }\n+          ready += 1;                   /* this will cause an abrupt return */\n+          pd->out_flags = PR_POLL_NVAL; /* bogii */\n         }\n+      }\n+    } else {\n+      pd->out_flags = 0;\n     }\n+  }\n \n-    if (0 != ready) {\n-        return ready; /* no need to block */\n-    }\n+  if (0 != ready) {\n+    return ready; /* no need to block */\n+  }\n \n-    /*\n-     * FD_SET does nothing if the fd_set's internal fd_array is full.  If\n-     * nrd, nwt, or nex is greater than FD_SETSIZE, we know FD_SET must\n-     * have failed to insert an osfd into the corresponding fd_set, and\n-     * therefore we should fail.\n-     */\n-    if ((nrd > FD_SETSIZE) || (nwt > FD_SETSIZE) || (nex > FD_SETSIZE)) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return -1;\n-    }\n+  /*\n+   * FD_SET does nothing if the fd_set's internal fd_array is full.  If\n+   * nrd, nwt, or nex is greater than FD_SETSIZE, we know FD_SET must\n+   * have failed to insert an osfd into the corresponding fd_set, and\n+   * therefore we should fail.\n+   */\n+  if ((nrd > FD_SETSIZE) || (nwt > FD_SETSIZE) || (nex > FD_SETSIZE)) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return -1;\n+  }\n \n-    rdp = (0 == nrd) ? NULL : &rd;\n-    wtp = (0 == nwt) ? NULL : &wt;\n-    exp = (0 == nex) ? NULL : &ex;\n+  rdp = (0 == nrd) ? NULL : &rd;\n+  wtp = (0 == nwt) ? NULL : &wt;\n+  exp = (0 == nex) ? NULL : &ex;\n \n-    if ((NULL == rdp) && (NULL == wtp) && (NULL == exp)) {\n-        PR_Sleep(timeout);\n-        return 0;\n-    }\n+  if ((NULL == rdp) && (NULL == wtp) && (NULL == exp)) {\n+    PR_Sleep(timeout);\n+    return 0;\n+  }\n \n-    if (timeout != PR_INTERVAL_NO_TIMEOUT) {\n-        PRInt32 ticksPerSecond = PR_TicksPerSecond();\n-        tv.tv_sec = timeout / ticksPerSecond;\n-        tv.tv_usec = PR_IntervalToMicroseconds(timeout % ticksPerSecond);\n-        tvp = &tv;\n-    }\n+  if (timeout != PR_INTERVAL_NO_TIMEOUT) {\n+    PRInt32 ticksPerSecond = PR_TicksPerSecond();\n+    tv.tv_sec = timeout / ticksPerSecond;\n+    tv.tv_usec = PR_IntervalToMicroseconds(timeout % ticksPerSecond);\n+    tvp = &tv;\n+  }\n \n #if defined(_PR_GLOBAL_THREADS_ONLY)\n-    ready = _MD_SELECT(0, rdp, wtp, exp, tvp);\n+  ready = _MD_SELECT(0, rdp, wtp, exp, tvp);\n #else\n-    ready = _PR_NTFiberSafeSelect(0, rdp, wtp, exp, tvp);\n+  ready = _PR_NTFiberSafeSelect(0, rdp, wtp, exp, tvp);\n #endif\n \n-    /*\n-    ** Now to unravel the select sets back into the client's poll\n-    ** descriptor list. Is this possibly an area for pissing away\n-    ** a few cycles or what?\n-    */\n-    if (ready > 0) {\n-        ready = 0;\n-        for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n-            PRInt16 out_flags = 0;\n-            if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n-                SOCKET osfd;\n-                bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n-                PR_ASSERT(NULL != bottom);\n+  /*\n+  ** Now to unravel the select sets back into the client's poll\n+  ** descriptor list. Is this possibly an area for pissing away\n+  ** a few cycles or what?\n+  */\n+  if (ready > 0) {\n+    ready = 0;\n+    for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n+      PRInt16 out_flags = 0;\n+      if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n+        SOCKET osfd;\n+        bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n+        PR_ASSERT(NULL != bottom);\n \n-                osfd = (SOCKET)bottom->secret->md.osfd;\n+        osfd = (SOCKET)bottom->secret->md.osfd;\n \n-                if (FD_ISSET(osfd, &rd)) {\n-                    if (pd->out_flags & _PR_POLL_READ_SYS_READ) {\n-                        out_flags |= PR_POLL_READ;\n-                    }\n-                    if (pd->out_flags & _PR_POLL_WRITE_SYS_READ) {\n-                        out_flags |= PR_POLL_WRITE;\n-                    }\n-                }\n-                if (FD_ISSET(osfd, &wt)) {\n-                    if (pd->out_flags & _PR_POLL_READ_SYS_WRITE) {\n-                        out_flags |= PR_POLL_READ;\n-                    }\n-                    if (pd->out_flags & _PR_POLL_WRITE_SYS_WRITE) {\n-                        out_flags |= PR_POLL_WRITE;\n-                    }\n-                }\n-                if (FD_ISSET(osfd, &ex)) {\n-                    out_flags |= PR_POLL_EXCEPT;\n-                }\n-            }\n-            pd->out_flags = out_flags;\n-            if (out_flags) {\n-                ready++;\n-            }\n+        if (FD_ISSET(osfd, &rd)) {\n+          if (pd->out_flags & _PR_POLL_READ_SYS_READ) {\n+            out_flags |= PR_POLL_READ;\n+          }\n+          if (pd->out_flags & _PR_POLL_WRITE_SYS_READ) {\n+            out_flags |= PR_POLL_WRITE;\n+          }\n+        }\n+        if (FD_ISSET(osfd, &wt)) {\n+          if (pd->out_flags & _PR_POLL_READ_SYS_WRITE) {\n+            out_flags |= PR_POLL_READ;\n+          }\n+          if (pd->out_flags & _PR_POLL_WRITE_SYS_WRITE) {\n+            out_flags |= PR_POLL_WRITE;\n+          }\n         }\n-        PR_ASSERT(ready > 0);\n-    } else if (ready == SOCKET_ERROR) {\n-        err = WSAGetLastError();\n-        if (err == WSAENOTSOCK) {\n-            /* Find the bad fds */\n-            int optval;\n-            int optlen = sizeof(optval);\n-            ready = 0;\n-            for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n-                pd->out_flags = 0;\n-                if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n-                    bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n-                    if (getsockopt(bottom->secret->md.osfd, SOL_SOCKET, SO_TYPE,\n-                                   (char*)&optval, &optlen) == -1) {\n-                        PR_ASSERT(WSAGetLastError() == WSAENOTSOCK);\n-                        if (WSAGetLastError() == WSAENOTSOCK) {\n-                            pd->out_flags = PR_POLL_NVAL;\n-                            ready++;\n-                        }\n-                    }\n-                }\n+        if (FD_ISSET(osfd, &ex)) {\n+          out_flags |= PR_POLL_EXCEPT;\n+        }\n+      }\n+      pd->out_flags = out_flags;\n+      if (out_flags) {\n+        ready++;\n+      }\n+    }\n+    PR_ASSERT(ready > 0);\n+  } else if (ready == SOCKET_ERROR) {\n+    err = WSAGetLastError();\n+    if (err == WSAENOTSOCK) {\n+      /* Find the bad fds */\n+      int optval;\n+      int optlen = sizeof(optval);\n+      ready = 0;\n+      for (pd = pds, epd = pd + npds; pd < epd; pd++) {\n+        pd->out_flags = 0;\n+        if ((NULL != pd->fd) && (0 != pd->in_flags)) {\n+          bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n+          if (getsockopt(bottom->secret->md.osfd, SOL_SOCKET, SO_TYPE,\n+                         (char*)&optval, &optlen) == -1) {\n+            PR_ASSERT(WSAGetLastError() == WSAENOTSOCK);\n+            if (WSAGetLastError() == WSAENOTSOCK) {\n+              pd->out_flags = PR_POLL_NVAL;\n+              ready++;\n             }\n-            PR_ASSERT(ready > 0);\n-        } else {\n-            _PR_MD_MAP_SELECT_ERROR(err);\n+          }\n         }\n+      }\n+      PR_ASSERT(ready > 0);\n+    } else {\n+      _PR_MD_MAP_SELECT_ERROR(err);\n     }\n+  }\n \n-    return ready;\n+  return ready;\n }\ndiff --git a/nspr/pr/src/md/windows/w32rng.c b/nspr/pr/src/md/windows/w32rng.c\nindex 9fc1c31..40d1694 100644\n--- a/nspr/pr/src/md/windows/w32rng.c\n+++ b/nspr/pr/src/md/windows/w32rng.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,70 +11,66 @@\n #include <stdio.h>\n #include <primpl.h>\n \n-static BOOL\n-CurrentClockTickTime(LPDWORD lpdwHigh, LPDWORD lpdwLow)\n-{\n-    LARGE_INTEGER liCount;\n+static BOOL CurrentClockTickTime(LPDWORD lpdwHigh, LPDWORD lpdwLow) {\n+  LARGE_INTEGER liCount;\n \n-    if (!QueryPerformanceCounter(&liCount)) {\n-        return FALSE;\n-    }\n+  if (!QueryPerformanceCounter(&liCount)) {\n+    return FALSE;\n+  }\n \n-    *lpdwHigh = liCount.u.HighPart;\n-    *lpdwLow = liCount.u.LowPart;\n-    return TRUE;\n+  *lpdwHigh = liCount.u.HighPart;\n+  *lpdwLow = liCount.u.LowPart;\n+  return TRUE;\n }\n \n-extern PRSize\n-_PR_MD_GetRandomNoise(void* buf, PRSize size)\n-{\n-    DWORD dwHigh, dwLow, dwVal;\n-    size_t n = 0;\n-    size_t nBytes;\n-    time_t sTime;\n-\n-    if (size <= 0) {\n-        return 0;\n-    }\n-\n-    CurrentClockTickTime(&dwHigh, &dwLow);\n-\n-    // get the maximally changing bits first\n-    nBytes = sizeof(dwLow) > size ? size : sizeof(dwLow);\n-    memcpy((char*)buf, &dwLow, nBytes);\n-    n += nBytes;\n-    size -= nBytes;\n-\n-    if (size <= 0) {\n-        return n;\n-    }\n-\n-    nBytes = sizeof(dwHigh) > size ? size : sizeof(dwHigh);\n-    memcpy(((char*)buf) + n, &dwHigh, nBytes);\n-    n += nBytes;\n-    size -= nBytes;\n-\n-    if (size <= 0) {\n-        return n;\n-    }\n-\n-    // get the number of milliseconds that have elapsed since Windows started\n-    dwVal = GetTickCount();\n-\n-    nBytes = sizeof(dwVal) > size ? size : sizeof(dwVal);\n-    memcpy(((char*)buf) + n, &dwVal, nBytes);\n-    n += nBytes;\n-    size -= nBytes;\n-\n-    if (size <= 0) {\n-        return n;\n-    }\n-\n-    // get the time in seconds since midnight Jan 1, 1970\n-    time(&sTime);\n-    nBytes = sizeof(sTime) > size ? size : sizeof(sTime);\n-    memcpy(((char*)buf) + n, &sTime, nBytes);\n-    n += nBytes;\n+extern PRSize _PR_MD_GetRandomNoise(void* buf, PRSize size) {\n+  DWORD dwHigh, dwLow, dwVal;\n+  size_t n = 0;\n+  size_t nBytes;\n+  time_t sTime;\n \n+  if (size <= 0) {\n+    return 0;\n+  }\n+\n+  CurrentClockTickTime(&dwHigh, &dwLow);\n+\n+  // get the maximally changing bits first\n+  nBytes = sizeof(dwLow) > size ? size : sizeof(dwLow);\n+  memcpy((char*)buf, &dwLow, nBytes);\n+  n += nBytes;\n+  size -= nBytes;\n+\n+  if (size <= 0) {\n+    return n;\n+  }\n+\n+  nBytes = sizeof(dwHigh) > size ? size : sizeof(dwHigh);\n+  memcpy(((char*)buf) + n, &dwHigh, nBytes);\n+  n += nBytes;\n+  size -= nBytes;\n+\n+  if (size <= 0) {\n     return n;\n+  }\n+\n+  // get the number of milliseconds that have elapsed since Windows started\n+  dwVal = GetTickCount();\n+\n+  nBytes = sizeof(dwVal) > size ? size : sizeof(dwVal);\n+  memcpy(((char*)buf) + n, &dwVal, nBytes);\n+  n += nBytes;\n+  size -= nBytes;\n+\n+  if (size <= 0) {\n+    return n;\n+  }\n+\n+  // get the time in seconds since midnight Jan 1, 1970\n+  time(&sTime);\n+  nBytes = sizeof(sTime) > size ? size : sizeof(sTime);\n+  memcpy(((char*)buf) + n, &sTime, nBytes);\n+  n += nBytes;\n+\n+  return n;\n }\ndiff --git a/nspr/pr/src/md/windows/w32shm.c b/nspr/pr/src/md/windows/w32shm.c\nindex 361b4ff..127a55a 100644\n--- a/nspr/pr/src/md/windows/w32shm.c\n+++ b/nspr/pr/src/md/windows/w32shm.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -26,202 +27,192 @@ static DWORD filemapAccessTable[] = {\n     0                                      /* execute */\n };\n \n-extern PRSharedMemory*\n-_MD_OpenSharedMemory(const char* name, PRSize size,\n-                     PRIntn flags, PRIntn mode)\n-{\n-    char ipcname[PR_IPC_NAME_SIZE];\n-    PRStatus rc = PR_SUCCESS;\n-    DWORD dwHi, dwLo;\n-    PRSharedMemory* shm;\n-    DWORD flProtect = (PAGE_READWRITE);\n-    SECURITY_ATTRIBUTES sa;\n-    LPSECURITY_ATTRIBUTES lpSA = NULL;\n-    PSECURITY_DESCRIPTOR pSD = NULL;\n-    PACL pACL = NULL;\n-\n-    rc = _PR_MakeNativeIPCName(name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm);\n-    if (PR_FAILURE == rc) {\n-        PR_SetError(PR_UNKNOWN_ERROR, 0);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, (\"PR_OpenSharedMemory: name is invalid\"));\n-        return (NULL);\n+extern PRSharedMemory* _MD_OpenSharedMemory(const char* name, PRSize size,\n+                                            PRIntn flags, PRIntn mode) {\n+  char ipcname[PR_IPC_NAME_SIZE];\n+  PRStatus rc = PR_SUCCESS;\n+  DWORD dwHi, dwLo;\n+  PRSharedMemory* shm;\n+  DWORD flProtect = (PAGE_READWRITE);\n+  SECURITY_ATTRIBUTES sa;\n+  LPSECURITY_ATTRIBUTES lpSA = NULL;\n+  PSECURITY_DESCRIPTOR pSD = NULL;\n+  PACL pACL = NULL;\n+\n+  rc = _PR_MakeNativeIPCName(name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm);\n+  if (PR_FAILURE == rc) {\n+    PR_SetError(PR_UNKNOWN_ERROR, 0);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, (\"PR_OpenSharedMemory: name is invalid\"));\n+    return (NULL);\n+  }\n+\n+  shm = PR_NEWZAP(PRSharedMemory);\n+  if (NULL == shm) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"PR_OpenSharedMemory: New PRSharedMemory out of memory\"));\n+    return (NULL);\n+  }\n+\n+  shm->ipcname = PR_MALLOC((PRUint32)(strlen(ipcname) + 1));\n+  if (NULL == shm->ipcname) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+           (\"PR_OpenSharedMemory: New shm->ipcname out of memory\"));\n+    PR_DELETE(shm);\n+    return (NULL);\n+  }\n+\n+  /* copy args to struct */\n+  strcpy(shm->ipcname, ipcname);\n+  shm->size = size;\n+  shm->mode = mode;\n+  shm->flags = flags;\n+  shm->ident = _PR_SHM_IDENT;\n+\n+  if (flags & PR_SHM_CREATE) {\n+    dwHi = (DWORD)(((PRUint64)shm->size >> 32) & 0xffffffff);\n+    dwLo = (DWORD)(shm->size & 0xffffffff);\n+\n+    if (_PR_NT_MakeSecurityDescriptorACL(mode, filemapAccessTable, &pSD,\n+                                         &pACL) == PR_SUCCESS) {\n+      sa.nLength = sizeof(sa);\n+      sa.lpSecurityDescriptor = pSD;\n+      sa.bInheritHandle = FALSE;\n+      lpSA = &sa;\n     }\n-\n-    shm = PR_NEWZAP(PRSharedMemory);\n-    if (NULL == shm) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"PR_OpenSharedMemory: New PRSharedMemory out of memory\"));\n-        return (NULL);\n+#  ifdef WINCE\n+    {\n+      /*\n+       * This is assuming that the name will never be larger than\n+       * MAX_PATH.  Should we dynamically allocate?\n+       */\n+      PRUnichar wideIpcName[MAX_PATH];\n+      MultiByteToWideChar(CP_ACP, 0, shm->ipcname, -1, wideIpcName, MAX_PATH);\n+      shm->handle = CreateFileMappingW((HANDLE)-1, lpSA, flProtect, dwHi, dwLo,\n+                                       wideIpcName);\n+    }\n+#  else\n+    shm->handle = CreateFileMappingA((HANDLE)-1, lpSA, flProtect, dwHi, dwLo,\n+                                     shm->ipcname);\n+#  endif\n+    if (lpSA != NULL) {\n+      _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n     }\n \n-    shm->ipcname = PR_MALLOC((PRUint32)(strlen(ipcname) + 1));\n-    if (NULL == shm->ipcname) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    if (NULL == shm->handle) {\n+      PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+             (\"PR_OpenSharedMemory: CreateFileMapping() failed: %s\",\n+              shm->ipcname));\n+      _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+      PR_FREEIF(shm->ipcname)\n+      PR_DELETE(shm);\n+      return (NULL);\n+    } else {\n+      if ((flags & PR_SHM_EXCL) && (GetLastError() == ERROR_ALREADY_EXISTS)) {\n         PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-               (\"PR_OpenSharedMemory: New shm->ipcname out of memory\"));\n+               (\"PR_OpenSharedMemory: Request exclusive & already exists\",\n+                shm->ipcname));\n+        PR_SetError(PR_FILE_EXISTS_ERROR, ERROR_ALREADY_EXISTS);\n+        CloseHandle(shm->handle);\n+        PR_FREEIF(shm->ipcname)\n         PR_DELETE(shm);\n         return (NULL);\n+      } else {\n+        PR_LOG(\n+            _pr_shm_lm, PR_LOG_DEBUG,\n+            (\"PR_OpenSharedMemory: CreateFileMapping() success: %s, handle: %d\",\n+             shm->ipcname, shm->handle));\n+        return (shm);\n+      }\n     }\n-\n-    /* copy args to struct */\n-    strcpy(shm->ipcname, ipcname);\n-    shm->size = size;\n-    shm->mode = mode;\n-    shm->flags = flags;\n-    shm->ident = _PR_SHM_IDENT;\n-\n-    if (flags & PR_SHM_CREATE) {\n-        dwHi = (DWORD)(((PRUint64)shm->size >> 32) & 0xffffffff);\n-        dwLo = (DWORD)(shm->size & 0xffffffff);\n-\n-        if (_PR_NT_MakeSecurityDescriptorACL(mode, filemapAccessTable, &pSD,\n-                                             &pACL) == PR_SUCCESS) {\n-            sa.nLength = sizeof(sa);\n-            sa.lpSecurityDescriptor = pSD;\n-            sa.bInheritHandle = FALSE;\n-            lpSA = &sa;\n-        }\n-#ifdef WINCE\n-        {\n-            /*\n-             * This is assuming that the name will never be larger than\n-             * MAX_PATH.  Should we dynamically allocate?\n-             */\n-            PRUnichar wideIpcName[MAX_PATH];\n-            MultiByteToWideChar(CP_ACP, 0, shm->ipcname, -1, wideIpcName, MAX_PATH);\n-            shm->handle = CreateFileMappingW((HANDLE)-1, lpSA, flProtect, dwHi, dwLo,\n-                                             wideIpcName);\n-        }\n-#else\n-        shm->handle = CreateFileMappingA((HANDLE)-1, lpSA, flProtect, dwHi, dwLo,\n-                                         shm->ipcname);\n-#endif\n-        if (lpSA != NULL) {\n-            _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n-        }\n-\n-        if (NULL == shm->handle) {\n-            PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-                   (\"PR_OpenSharedMemory: CreateFileMapping() failed: %s\",\n-                    shm->ipcname));\n-            _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-            PR_FREEIF(shm->ipcname)\n-            PR_DELETE(shm);\n-            return (NULL);\n-        } else {\n-            if ((flags & PR_SHM_EXCL) && (GetLastError() == ERROR_ALREADY_EXISTS)) {\n-                PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-                       (\"PR_OpenSharedMemory: Request exclusive & already exists\",\n-                        shm->ipcname));\n-                PR_SetError(PR_FILE_EXISTS_ERROR, ERROR_ALREADY_EXISTS);\n-                CloseHandle(shm->handle);\n-                PR_FREEIF(shm->ipcname)\n-                PR_DELETE(shm);\n-                return (NULL);\n-            } else {\n-                PR_LOG(\n-                    _pr_shm_lm, PR_LOG_DEBUG,\n-                    (\"PR_OpenSharedMemory: CreateFileMapping() success: %s, handle: %d\",\n-                     shm->ipcname, shm->handle));\n-                return (shm);\n-            }\n-        }\n+  } else {\n+#  ifdef WINCE\n+    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+    shm->handle = NULL; /* OpenFileMapping not supported */\n+#  else\n+    shm->handle = OpenFileMapping(FILE_MAP_WRITE, TRUE, shm->ipcname);\n+#  endif\n+    if (NULL == shm->handle) {\n+      _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+      PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+             (\"PR_OpenSharedMemory: OpenFileMapping() failed: %s, error: %d\",\n+              shm->ipcname, PR_GetOSError()));\n+      PR_FREEIF(shm->ipcname);\n+      PR_DELETE(shm);\n+      return (NULL);\n     } else {\n-#ifdef WINCE\n-        PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-        shm->handle = NULL; /* OpenFileMapping not supported */\n-#else\n-        shm->handle = OpenFileMapping(FILE_MAP_WRITE, TRUE, shm->ipcname);\n-#endif\n-        if (NULL == shm->handle) {\n-            _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-            PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-                   (\"PR_OpenSharedMemory: OpenFileMapping() failed: %s, error: %d\",\n-                    shm->ipcname, PR_GetOSError()));\n-            PR_FREEIF(shm->ipcname);\n-            PR_DELETE(shm);\n-            return (NULL);\n-        } else {\n-            PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n-                   (\"PR_OpenSharedMemory: OpenFileMapping() success: %s, handle: %d\",\n-                    shm->ipcname, shm->handle));\n-            return (shm);\n-        }\n+      PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,\n+             (\"PR_OpenSharedMemory: OpenFileMapping() success: %s, handle: %d\",\n+              shm->ipcname, shm->handle));\n+      return (shm);\n     }\n-    /* returns from separate paths */\n+  }\n+  /* returns from separate paths */\n }\n \n-extern void*\n-_MD_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags)\n-{\n-    PRUint32 access = FILE_MAP_WRITE;\n-    void* addr;\n+extern void* _MD_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags) {\n+  PRUint32 access = FILE_MAP_WRITE;\n+  void* addr;\n \n-    PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n+  PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n \n-    if (PR_SHM_READONLY & flags) {\n-        access = FILE_MAP_READ;\n-    }\n+  if (PR_SHM_READONLY & flags) {\n+    access = FILE_MAP_READ;\n+  }\n \n-    addr = MapViewOfFile(shm->handle, access, 0, 0, shm->size);\n+  addr = MapViewOfFile(shm->handle, access, 0, 0, shm->size);\n \n-    if (NULL == addr) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        PR_LOG(_pr_shm_lm, PR_LOG_ERROR,\n-               (\"_MD_AttachSharedMemory: MapViewOfFile() failed. OSerror: %d\",\n-                PR_GetOSError()));\n-    }\n+  if (NULL == addr) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    PR_LOG(_pr_shm_lm, PR_LOG_ERROR,\n+           (\"_MD_AttachSharedMemory: MapViewOfFile() failed. OSerror: %d\",\n+            PR_GetOSError()));\n+  }\n \n-    return (addr);\n+  return (addr);\n } /* end _MD_ATTACH_SHARED_MEMORY() */\n \n-extern PRStatus\n-_MD_DetachSharedMemory(PRSharedMemory* shm, void* addr)\n-{\n-    PRStatus rc = PR_SUCCESS;\n-    BOOL wrc;\n-\n-    PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n-\n-    wrc = UnmapViewOfFile(addr);\n-    if (FALSE == wrc) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        PR_LOG(_pr_shm_lm, PR_LOG_ERROR,\n-               (\"_MD_DetachSharedMemory: UnmapViewOfFile() failed. OSerror: %d\",\n-                PR_GetOSError()));\n-        rc = PR_FAILURE;\n-    }\n+extern PRStatus _MD_DetachSharedMemory(PRSharedMemory* shm, void* addr) {\n+  PRStatus rc = PR_SUCCESS;\n+  BOOL wrc;\n \n-    return (rc);\n+  PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n+\n+  wrc = UnmapViewOfFile(addr);\n+  if (FALSE == wrc) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    PR_LOG(_pr_shm_lm, PR_LOG_ERROR,\n+           (\"_MD_DetachSharedMemory: UnmapViewOfFile() failed. OSerror: %d\",\n+            PR_GetOSError()));\n+    rc = PR_FAILURE;\n+  }\n+\n+  return (rc);\n }\n \n-extern PRStatus\n-_MD_CloseSharedMemory(PRSharedMemory* shm)\n-{\n-    PRStatus rc = PR_SUCCESS;\n-    BOOL wrc;\n-\n-    PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n-\n-    wrc = CloseHandle(shm->handle);\n-    if (FALSE == wrc) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        PR_LOG(_pr_shm_lm, PR_LOG_ERROR,\n-               (\"_MD_CloseSharedMemory: CloseHandle() failed. OSerror: %d\",\n-                PR_GetOSError()));\n-        rc = PR_FAILURE;\n-    }\n-    PR_FREEIF(shm->ipcname);\n-    PR_DELETE(shm);\n+extern PRStatus _MD_CloseSharedMemory(PRSharedMemory* shm) {\n+  PRStatus rc = PR_SUCCESS;\n+  BOOL wrc;\n \n-    return (rc);\n+  PR_ASSERT(shm->ident == _PR_SHM_IDENT);\n+\n+  wrc = CloseHandle(shm->handle);\n+  if (FALSE == wrc) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    PR_LOG(_pr_shm_lm, PR_LOG_ERROR,\n+           (\"_MD_CloseSharedMemory: CloseHandle() failed. OSerror: %d\",\n+            PR_GetOSError()));\n+    rc = PR_FAILURE;\n+  }\n+  PR_FREEIF(shm->ipcname);\n+  PR_DELETE(shm);\n+\n+  return (rc);\n } /* end _MD_CLOSE_SHARED_MEMORY() */\n \n-extern PRStatus\n-_MD_DeleteSharedMemory(const char* name)\n-{\n-    return (PR_SUCCESS);\n+extern PRStatus _MD_DeleteSharedMemory(const char* name) {\n+  return (PR_SUCCESS);\n }\n \n /*\n@@ -229,95 +220,89 @@ _MD_DeleteSharedMemory(const char* name)\n */\n extern PRLogModuleInfo* _pr_shma_lm;\n \n-extern PRFileMap*\n-_md_OpenAnonFileMap(const char* dirName, PRSize size,\n-                    PRFileMapProtect prot)\n-{\n-    PRFileMap* fm;\n-    HANDLE hFileMap;\n-\n-    fm = PR_CreateFileMap((PRFileDesc*)-1, size, prot);\n-    if (NULL == fm) {\n-        PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-               (\"_md_OpenAnonFileMap(): PR_CreateFileMap(): failed\"));\n-        goto Finished;\n-    }\n+extern PRFileMap* _md_OpenAnonFileMap(const char* dirName, PRSize size,\n+                                      PRFileMapProtect prot) {\n+  PRFileMap* fm;\n+  HANDLE hFileMap;\n \n-    /*\n-    ** Make fm->md.hFileMap inheritable. We can't use\n-    ** GetHandleInformation and SetHandleInformation\n-    ** because these two functions fail with\n-    ** ERROR_CALL_NOT_IMPLEMENTED on Win95.\n-    */\n-    if (DuplicateHandle(GetCurrentProcess(), fm->md.hFileMap, GetCurrentProcess(),\n-                        &hFileMap, 0, TRUE /* inheritable */,\n-                        DUPLICATE_SAME_ACCESS) == FALSE) {\n-        PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n-        PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-               (\"_md_OpenAnonFileMap(): DuplicateHandle(): failed\"));\n-        PR_CloseFileMap(fm);\n-        fm = NULL;\n-        goto Finished;\n-    }\n-    CloseHandle(fm->md.hFileMap);\n-    fm->md.hFileMap = hFileMap;\n+  fm = PR_CreateFileMap((PRFileDesc*)-1, size, prot);\n+  if (NULL == fm) {\n+    PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n+           (\"_md_OpenAnonFileMap(): PR_CreateFileMap(): failed\"));\n+    goto Finished;\n+  }\n+\n+  /*\n+  ** Make fm->md.hFileMap inheritable. We can't use\n+  ** GetHandleInformation and SetHandleInformation\n+  ** because these two functions fail with\n+  ** ERROR_CALL_NOT_IMPLEMENTED on Win95.\n+  */\n+  if (DuplicateHandle(GetCurrentProcess(), fm->md.hFileMap, GetCurrentProcess(),\n+                      &hFileMap, 0, TRUE /* inheritable */,\n+                      DUPLICATE_SAME_ACCESS) == FALSE) {\n+    PR_SetError(PR_UNKNOWN_ERROR, GetLastError());\n+    PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n+           (\"_md_OpenAnonFileMap(): DuplicateHandle(): failed\"));\n+    PR_CloseFileMap(fm);\n+    fm = NULL;\n+    goto Finished;\n+  }\n+  CloseHandle(fm->md.hFileMap);\n+  fm->md.hFileMap = hFileMap;\n \n Finished:\n-    return (fm);\n+  return (fm);\n } /* end md_OpenAnonFileMap() */\n \n /*\n ** _md_ExportFileMapAsString()\n **\n */\n-extern PRStatus\n-_md_ExportFileMapAsString(PRFileMap* fm, PRSize bufSize,\n-                          char* buf)\n-{\n-    PRIntn written;\n+extern PRStatus _md_ExportFileMapAsString(PRFileMap* fm, PRSize bufSize,\n+                                          char* buf) {\n+  PRIntn written;\n \n-    written = PR_snprintf(buf, (PRUint32)bufSize, \"%d:%\" PR_PRIdOSFD \":%ld\",\n-                          (PRIntn)fm->prot, (PROsfd)fm->md.hFileMap,\n-                          (PRInt32)fm->md.dwAccess);\n+  written = PR_snprintf(buf, (PRUint32)bufSize, \"%d:%\" PR_PRIdOSFD \":%ld\",\n+                        (PRIntn)fm->prot, (PROsfd)fm->md.hFileMap,\n+                        (PRInt32)fm->md.dwAccess);\n \n-    PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-           (\"_md_ExportFileMapAsString(): prot: %x, hFileMap: %x, dwAccess: %x\",\n-            fm->prot, fm->md.hFileMap, fm->md.dwAccess));\n+  PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n+         (\"_md_ExportFileMapAsString(): prot: %x, hFileMap: %x, dwAccess: %x\",\n+          fm->prot, fm->md.hFileMap, fm->md.dwAccess));\n \n-    return ((written == -1) ? PR_FAILURE : PR_SUCCESS);\n+  return ((written == -1) ? PR_FAILURE : PR_SUCCESS);\n } /* end _md_ExportFileMapAsString() */\n \n /*\n ** _md_ImportFileMapFromString()\n **\n */\n-extern PRFileMap*\n-_md_ImportFileMapFromString(const char* fmstring)\n-{\n-    PRIntn prot;\n-    PROsfd hFileMap;\n-    PRInt32 dwAccess;\n-    PRFileMap* fm = NULL;\n-\n-    PR_sscanf(fmstring, \"%d:%\" PR_SCNdOSFD \":%ld\", &prot, &hFileMap, &dwAccess);\n-\n-    fm = PR_NEWZAP(PRFileMap);\n-    if (NULL == fm) {\n-        PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-               (\"_md_ImportFileMapFromString(): PR_NEWZAP(): Failed\"));\n-        return (fm);\n-    }\n+extern PRFileMap* _md_ImportFileMapFromString(const char* fmstring) {\n+  PRIntn prot;\n+  PROsfd hFileMap;\n+  PRInt32 dwAccess;\n+  PRFileMap* fm = NULL;\n \n-    fm->prot = (PRFileMapProtect)prot;\n-    fm->md.hFileMap = (HANDLE)hFileMap;\n-    fm->md.dwAccess = (DWORD)dwAccess;\n-    fm->fd = (PRFileDesc*)-1;\n+  PR_sscanf(fmstring, \"%d:%\" PR_SCNdOSFD \":%ld\", &prot, &hFileMap, &dwAccess);\n \n+  fm = PR_NEWZAP(PRFileMap);\n+  if (NULL == fm) {\n     PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n-           (\"_md_ImportFileMapFromString(): fm: %p, prot: %d, hFileMap: %8.8x, \"\n-            \"dwAccess: %8.8x, fd: %x\",\n-            fm, prot, fm->md.hFileMap, fm->md.dwAccess, fm->fd));\n+           (\"_md_ImportFileMapFromString(): PR_NEWZAP(): Failed\"));\n     return (fm);\n+  }\n+\n+  fm->prot = (PRFileMapProtect)prot;\n+  fm->md.hFileMap = (HANDLE)hFileMap;\n+  fm->md.dwAccess = (DWORD)dwAccess;\n+  fm->fd = (PRFileDesc*)-1;\n+\n+  PR_LOG(_pr_shma_lm, PR_LOG_DEBUG,\n+         (\"_md_ImportFileMapFromString(): fm: %p, prot: %d, hFileMap: %8.8x, \"\n+          \"dwAccess: %8.8x, fd: %x\",\n+          fm, prot, fm->md.hFileMap, fm->md.dwAccess, fm->fd));\n+  return (fm);\n } /* end _md_ImportFileMapFromString() */\n \n #else\ndiff --git a/nspr/pr/src/md/windows/w95cv.c b/nspr/pr/src/md/windows/w95cv.c\nindex 67688e3..cd93291 100644\n--- a/nspr/pr/src/md/windows/w95cv.c\n+++ b/nspr/pr/src/md/windows/w95cv.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -25,22 +26,20 @@\n  * The CV's lock must be locked when this function is called.\n  */\n \n-static void\n-AddThreadToCVWaitQueueInternal(PRThread* thred,\n-                               struct _MDCVar* cv)\n-{\n-    PR_ASSERT((cv->waitTail != NULL && cv->waitHead != NULL) ||\n-              (cv->waitTail == NULL && cv->waitHead == NULL));\n-    cv->nwait += 1;\n-    thred->md.inCVWaitQueue = PR_TRUE;\n-    thred->md.next = NULL;\n-    thred->md.prev = cv->waitTail;\n-    if (cv->waitHead == NULL) {\n-        cv->waitHead = thred;\n-    } else {\n-        cv->waitTail->md.next = thred;\n-    }\n-    cv->waitTail = thred;\n+static void AddThreadToCVWaitQueueInternal(PRThread* thred,\n+                                           struct _MDCVar* cv) {\n+  PR_ASSERT((cv->waitTail != NULL && cv->waitHead != NULL) ||\n+            (cv->waitTail == NULL && cv->waitHead == NULL));\n+  cv->nwait += 1;\n+  thred->md.inCVWaitQueue = PR_TRUE;\n+  thred->md.next = NULL;\n+  thred->md.prev = cv->waitTail;\n+  if (cv->waitHead == NULL) {\n+    cv->waitHead = thred;\n+  } else {\n+    cv->waitTail->md.next = thred;\n+  }\n+  cv->waitTail = thred;\n }\n \n /*\n@@ -53,111 +52,109 @@ AddThreadToCVWaitQueueInternal(PRThread* thred,\n  * This function is called by _PR_MD_WAIT_CV and _PR_MD_UNLOCK,\n  * the two places where a lock is unlocked.\n  */\n-static void\n-md_UnlockAndPostNotifies(_MDLock* lock, PRThread* waitThred,\n-                         _MDCVar* waitCV)\n-{\n-    PRIntn index;\n-    _MDNotified post;\n-    _MDNotified *notified, *prev = NULL;\n-\n-    /*\n-     * Time to actually notify any conditions that were affected\n-     * while the lock was held.  Get a copy of the list that's in\n-     * the lock structure and then zero the original.  If it's\n-     * linked to other such structures, we own that storage.\n-     */\n-    post = lock->notified; /* a safe copy; we own the lock */\n+static void md_UnlockAndPostNotifies(_MDLock* lock, PRThread* waitThred,\n+                                     _MDCVar* waitCV) {\n+  PRIntn index;\n+  _MDNotified post;\n+  _MDNotified *notified, *prev = NULL;\n+\n+  /*\n+   * Time to actually notify any conditions that were affected\n+   * while the lock was held.  Get a copy of the list that's in\n+   * the lock structure and then zero the original.  If it's\n+   * linked to other such structures, we own that storage.\n+   */\n+  post = lock->notified; /* a safe copy; we own the lock */\n \n #if defined(DEBUG)\n-    ZeroMemory(&lock->notified, sizeof(_MDNotified)); /* reset */\n+  ZeroMemory(&lock->notified, sizeof(_MDNotified)); /* reset */\n #else\n-    lock->notified.length = 0; /* these are really sufficient */\n-    lock->notified.link = NULL;\n+  lock->notified.length = 0; /* these are really sufficient */\n+  lock->notified.link = NULL;\n #endif\n \n-    /*\n-     * Figure out how many threads we need to wake up.\n-     */\n-    notified = &post; /* this is where we start */\n-    do {\n-        for (index = 0; index < notified->length; ++index) {\n-            _MDCVar* cv = notified->cv[index].cv;\n-            PRThread* thred;\n-            int i;\n-\n-            /* Fast special case: no waiting threads */\n-            if (cv->waitHead == NULL) {\n-                notified->cv[index].notifyHead = NULL;\n-                continue;\n-            }\n-\n-            /* General case */\n-            if (-1 == notified->cv[index].times) {\n-                /* broadcast */\n-                thred = cv->waitHead;\n-                while (thred != NULL) {\n-                    thred->md.inCVWaitQueue = PR_FALSE;\n-                    thred = thred->md.next;\n-                }\n-                notified->cv[index].notifyHead = cv->waitHead;\n-                cv->waitHead = cv->waitTail = NULL;\n-                cv->nwait = 0;\n-            } else {\n-                thred = cv->waitHead;\n-                i = notified->cv[index].times;\n-                while (thred != NULL && i > 0) {\n-                    thred->md.inCVWaitQueue = PR_FALSE;\n-                    thred = thred->md.next;\n-                    i--;\n-                }\n-                notified->cv[index].notifyHead = cv->waitHead;\n-                cv->waitHead = thred;\n-                if (cv->waitHead == NULL) {\n-                    cv->waitTail = NULL;\n-                } else {\n-                    if (cv->waitHead->md.prev != NULL) {\n-                        cv->waitHead->md.prev->md.next = NULL;\n-                        cv->waitHead->md.prev = NULL;\n-                    }\n-                }\n-                cv->nwait -= notified->cv[index].times - i;\n-            }\n+  /*\n+   * Figure out how many threads we need to wake up.\n+   */\n+  notified = &post; /* this is where we start */\n+  do {\n+    for (index = 0; index < notified->length; ++index) {\n+      _MDCVar* cv = notified->cv[index].cv;\n+      PRThread* thred;\n+      int i;\n+\n+      /* Fast special case: no waiting threads */\n+      if (cv->waitHead == NULL) {\n+        notified->cv[index].notifyHead = NULL;\n+        continue;\n+      }\n+\n+      /* General case */\n+      if (-1 == notified->cv[index].times) {\n+        /* broadcast */\n+        thred = cv->waitHead;\n+        while (thred != NULL) {\n+          thred->md.inCVWaitQueue = PR_FALSE;\n+          thred = thred->md.next;\n         }\n-        notified = notified->link;\n-    } while (NULL != notified);\n-\n-    if (waitThred) {\n-        AddThreadToCVWaitQueueInternal(waitThred, waitCV);\n+        notified->cv[index].notifyHead = cv->waitHead;\n+        cv->waitHead = cv->waitTail = NULL;\n+        cv->nwait = 0;\n+      } else {\n+        thred = cv->waitHead;\n+        i = notified->cv[index].times;\n+        while (thred != NULL && i > 0) {\n+          thred->md.inCVWaitQueue = PR_FALSE;\n+          thred = thred->md.next;\n+          i--;\n+        }\n+        notified->cv[index].notifyHead = cv->waitHead;\n+        cv->waitHead = thred;\n+        if (cv->waitHead == NULL) {\n+          cv->waitTail = NULL;\n+        } else {\n+          if (cv->waitHead->md.prev != NULL) {\n+            cv->waitHead->md.prev->md.next = NULL;\n+            cv->waitHead->md.prev = NULL;\n+          }\n+        }\n+        cv->nwait -= notified->cv[index].times - i;\n+      }\n     }\n+    notified = notified->link;\n+  } while (NULL != notified);\n \n-    /* Release the lock before notifying */\n-    LeaveCriticalSection(&lock->mutex);\n+  if (waitThred) {\n+    AddThreadToCVWaitQueueInternal(waitThred, waitCV);\n+  }\n \n-    notified = &post; /* this is where we start */\n-    do {\n-        for (index = 0; index < notified->length; ++index) {\n-            PRThread* thred;\n-            PRThread* next;\n+  /* Release the lock before notifying */\n+  LeaveCriticalSection(&lock->mutex);\n \n-            thred = notified->cv[index].notifyHead;\n-            while (thred != NULL) {\n-                BOOL rv;\n+  notified = &post; /* this is where we start */\n+  do {\n+    for (index = 0; index < notified->length; ++index) {\n+      PRThread* thred;\n+      PRThread* next;\n \n-                next = thred->md.next;\n-                thred->md.prev = thred->md.next = NULL;\n+      thred = notified->cv[index].notifyHead;\n+      while (thred != NULL) {\n+        BOOL rv;\n \n-                rv = ReleaseSemaphore(thred->md.blocked_sema, 1, NULL);\n-                PR_ASSERT(rv != 0);\n-                thred = next;\n-            }\n-        }\n-        prev = notified;\n-        notified = notified->link;\n-        if (&post != prev) {\n-            PR_DELETE(prev);\n-        }\n-    } while (NULL != notified);\n+        next = thred->md.next;\n+        thred->md.prev = thred->md.next = NULL;\n+\n+        rv = ReleaseSemaphore(thred->md.blocked_sema, 1, NULL);\n+        PR_ASSERT(rv != 0);\n+        thred = next;\n+      }\n+    }\n+    prev = notified;\n+    notified = notified->link;\n+    if (&post != prev) {\n+      PR_DELETE(prev);\n+    }\n+  } while (NULL != notified);\n }\n \n /*\n@@ -165,41 +162,39 @@ md_UnlockAndPostNotifies(_MDLock* lock, PRThread* waitThred,\n  * actual notification is done when the lock is released so that\n  * MP systems don't contend for a lock that they can't have.\n  */\n-static void\n-md_PostNotifyToCvar(_MDCVar* cvar, _MDLock* lock,\n-                    PRBool broadcast)\n-{\n-    PRIntn index = 0;\n-    _MDNotified* notified = &lock->notified;\n-\n-    while (1) {\n-        for (index = 0; index < notified->length; ++index) {\n-            if (notified->cv[index].cv == cvar) {\n-                if (broadcast) {\n-                    notified->cv[index].times = -1;\n-                } else if (-1 != notified->cv[index].times) {\n-                    notified->cv[index].times += 1;\n-                }\n-                return;\n-            }\n-        }\n-        /* if not full, enter new CV in this array */\n-        if (notified->length < _MD_CV_NOTIFIED_LENGTH) {\n-            break;\n-        }\n-\n-        /* if there's no link, create an empty array and link it */\n-        if (NULL == notified->link) {\n-            notified->link = PR_NEWZAP(_MDNotified);\n+static void md_PostNotifyToCvar(_MDCVar* cvar, _MDLock* lock,\n+                                PRBool broadcast) {\n+  PRIntn index = 0;\n+  _MDNotified* notified = &lock->notified;\n+\n+  while (1) {\n+    for (index = 0; index < notified->length; ++index) {\n+      if (notified->cv[index].cv == cvar) {\n+        if (broadcast) {\n+          notified->cv[index].times = -1;\n+        } else if (-1 != notified->cv[index].times) {\n+          notified->cv[index].times += 1;\n         }\n+        return;\n+      }\n+    }\n+    /* if not full, enter new CV in this array */\n+    if (notified->length < _MD_CV_NOTIFIED_LENGTH) {\n+      break;\n+    }\n \n-        notified = notified->link;\n+    /* if there's no link, create an empty array and link it */\n+    if (NULL == notified->link) {\n+      notified->link = PR_NEWZAP(_MDNotified);\n     }\n \n-    /* A brand new entry in the array */\n-    notified->cv[index].times = (broadcast) ? -1 : 1;\n-    notified->cv[index].cv = cvar;\n-    notified->length += 1;\n+    notified = notified->link;\n+  }\n+\n+  /* A brand new entry in the array */\n+  notified->cv[index].times = (broadcast) ? -1 : 1;\n+  notified->cv[index].cv = cvar;\n+  notified->length += 1;\n }\n \n /*\n@@ -210,106 +205,96 @@ md_PostNotifyToCvar(_MDCVar* cvar, _MDLock* lock,\n  *          0 when it succeeds.\n  *\n  */\n-PRInt32\n-_PR_MD_NEW_CV(_MDCVar* cv)\n-{\n-    cv->magic = _MD_MAGIC_CV;\n-    /*\n-     * The waitHead, waitTail, and nwait fields are zeroed\n-     * when the PRCondVar structure is created.\n-     */\n-    return 0;\n+PRInt32 _PR_MD_NEW_CV(_MDCVar* cv) {\n+  cv->magic = _MD_MAGIC_CV;\n+  /*\n+   * The waitHead, waitTail, and nwait fields are zeroed\n+   * when the PRCondVar structure is created.\n+   */\n+  return 0;\n }\n \n-void\n-_PR_MD_FREE_CV(_MDCVar* cv)\n-{\n-    cv->magic = (PRUint32)-1;\n-    return;\n+void _PR_MD_FREE_CV(_MDCVar* cv) {\n+  cv->magic = (PRUint32)-1;\n+  return;\n }\n \n /*\n  *  _PR_MD_WAIT_CV() -- Wait on condition variable\n  */\n-void\n-_PR_MD_WAIT_CV(_MDCVar* cv, _MDLock* lock, PRIntervalTime timeout)\n-{\n-    PRThread* thred = _PR_MD_CURRENT_THREAD();\n-    DWORD rv;\n-    DWORD msecs = (timeout == PR_INTERVAL_NO_TIMEOUT)\n-                      ? INFINITE\n-                      : PR_IntervalToMilliseconds(timeout);\n-\n-    /*\n-     * If we have pending notifies, post them now.\n-     */\n-    if (0 != lock->notified.length) {\n-        md_UnlockAndPostNotifies(lock, thred, cv);\n-    } else {\n-        AddThreadToCVWaitQueueInternal(thred, cv);\n-        LeaveCriticalSection(&lock->mutex);\n-    }\n-\n-    /* Wait for notification or timeout; don't really care which */\n-    rv = WaitForSingleObject(thred->md.blocked_sema, msecs);\n-\n-    EnterCriticalSection(&(lock->mutex));\n-\n-    PR_ASSERT(rv != WAIT_ABANDONED);\n-    PR_ASSERT(rv != WAIT_FAILED);\n-    PR_ASSERT(rv != WAIT_OBJECT_0 || thred->md.inCVWaitQueue == PR_FALSE);\n-\n-    if (rv == WAIT_TIMEOUT) {\n-        if (thred->md.inCVWaitQueue) {\n-            PR_ASSERT((cv->waitTail != NULL && cv->waitHead != NULL) ||\n-                      (cv->waitTail == NULL && cv->waitHead == NULL));\n-            cv->nwait -= 1;\n-            thred->md.inCVWaitQueue = PR_FALSE;\n-            if (cv->waitHead == thred) {\n-                cv->waitHead = thred->md.next;\n-                if (cv->waitHead == NULL) {\n-                    cv->waitTail = NULL;\n-                } else {\n-                    cv->waitHead->md.prev = NULL;\n-                }\n-            } else {\n-                PR_ASSERT(thred->md.prev != NULL);\n-                thred->md.prev->md.next = thred->md.next;\n-                if (thred->md.next != NULL) {\n-                    thred->md.next->md.prev = thred->md.prev;\n-                } else {\n-                    PR_ASSERT(cv->waitTail == thred);\n-                    cv->waitTail = thred->md.prev;\n-                }\n-            }\n-            thred->md.next = thred->md.prev = NULL;\n+void _PR_MD_WAIT_CV(_MDCVar* cv, _MDLock* lock, PRIntervalTime timeout) {\n+  PRThread* thred = _PR_MD_CURRENT_THREAD();\n+  DWORD rv;\n+  DWORD msecs = (timeout == PR_INTERVAL_NO_TIMEOUT)\n+                    ? INFINITE\n+                    : PR_IntervalToMilliseconds(timeout);\n+\n+  /*\n+   * If we have pending notifies, post them now.\n+   */\n+  if (0 != lock->notified.length) {\n+    md_UnlockAndPostNotifies(lock, thred, cv);\n+  } else {\n+    AddThreadToCVWaitQueueInternal(thred, cv);\n+    LeaveCriticalSection(&lock->mutex);\n+  }\n+\n+  /* Wait for notification or timeout; don't really care which */\n+  rv = WaitForSingleObject(thred->md.blocked_sema, msecs);\n+\n+  EnterCriticalSection(&(lock->mutex));\n+\n+  PR_ASSERT(rv != WAIT_ABANDONED);\n+  PR_ASSERT(rv != WAIT_FAILED);\n+  PR_ASSERT(rv != WAIT_OBJECT_0 || thred->md.inCVWaitQueue == PR_FALSE);\n+\n+  if (rv == WAIT_TIMEOUT) {\n+    if (thred->md.inCVWaitQueue) {\n+      PR_ASSERT((cv->waitTail != NULL && cv->waitHead != NULL) ||\n+                (cv->waitTail == NULL && cv->waitHead == NULL));\n+      cv->nwait -= 1;\n+      thred->md.inCVWaitQueue = PR_FALSE;\n+      if (cv->waitHead == thred) {\n+        cv->waitHead = thred->md.next;\n+        if (cv->waitHead == NULL) {\n+          cv->waitTail = NULL;\n+        } else {\n+          cv->waitHead->md.prev = NULL;\n+        }\n+      } else {\n+        PR_ASSERT(thred->md.prev != NULL);\n+        thred->md.prev->md.next = thred->md.next;\n+        if (thred->md.next != NULL) {\n+          thred->md.next->md.prev = thred->md.prev;\n         } else {\n-            /*\n-             * This thread must have been notified, but the\n-             * ReleaseSemaphore call happens after WaitForSingleObject\n-             * times out.  Wait on the semaphore again to make it\n-             * non-signaled.  We assume this wait won't take long.\n-             */\n-            rv = WaitForSingleObject(thred->md.blocked_sema, INFINITE);\n-            PR_ASSERT(rv == WAIT_OBJECT_0);\n+          PR_ASSERT(cv->waitTail == thred);\n+          cv->waitTail = thred->md.prev;\n         }\n+      }\n+      thred->md.next = thred->md.prev = NULL;\n+    } else {\n+      /*\n+       * This thread must have been notified, but the\n+       * ReleaseSemaphore call happens after WaitForSingleObject\n+       * times out.  Wait on the semaphore again to make it\n+       * non-signaled.  We assume this wait won't take long.\n+       */\n+      rv = WaitForSingleObject(thred->md.blocked_sema, INFINITE);\n+      PR_ASSERT(rv == WAIT_OBJECT_0);\n     }\n-    PR_ASSERT(thred->md.inCVWaitQueue == PR_FALSE);\n-    return;\n+  }\n+  PR_ASSERT(thred->md.inCVWaitQueue == PR_FALSE);\n+  return;\n } /* --- end _PR_MD_WAIT_CV() --- */\n \n-void\n-_PR_MD_NOTIFY_CV(_MDCVar* cv, _MDLock* lock)\n-{\n-    md_PostNotifyToCvar(cv, lock, PR_FALSE);\n-    return;\n+void _PR_MD_NOTIFY_CV(_MDCVar* cv, _MDLock* lock) {\n+  md_PostNotifyToCvar(cv, lock, PR_FALSE);\n+  return;\n }\n \n-void\n-_PR_MD_NOTIFYALL_CV(_MDCVar* cv, _MDLock* lock)\n-{\n-    md_PostNotifyToCvar(cv, lock, PR_TRUE);\n-    return;\n+void _PR_MD_NOTIFYALL_CV(_MDCVar* cv, _MDLock* lock) {\n+  md_PostNotifyToCvar(cv, lock, PR_TRUE);\n+  return;\n }\n \n typedef BOOL(WINAPI* INITIALIZECRITICALSECTIONEX)(\n@@ -317,22 +302,20 @@ typedef BOOL(WINAPI* INITIALIZECRITICALSECTIONEX)(\n \n static INITIALIZECRITICALSECTIONEX sInitializeCriticalSectionEx;\n \n-void\n-_PR_MD_INIT_LOCKS(void)\n-{\n-    /*\n-     * Starting with Windows Vista, every CRITICAL_SECTION allocates an extra\n-     * RTL_CRITICAL_SECTION_DEBUG object. Unfortunately, this debug object is\n-     * not reclaimed by DeleteCriticalSection(), causing an apparent memory\n-     * leak. This is a debugging \"feature\", not a bug. If we are running on\n-     * Vista or later, use InitializeCriticalSectionEx() to allocate\n-     * CRITICAL_SECTIONs without debug objects.\n-     */\n-    HMODULE hKernel32 = GetModuleHandle(\"kernel32.dll\");\n-    PR_ASSERT(hKernel32);\n-    PR_ASSERT(!sInitializeCriticalSectionEx);\n-    sInitializeCriticalSectionEx = (INITIALIZECRITICALSECTIONEX)GetProcAddress(\n-        hKernel32, \"InitializeCriticalSectionEx\");\n+void _PR_MD_INIT_LOCKS(void) {\n+  /*\n+   * Starting with Windows Vista, every CRITICAL_SECTION allocates an extra\n+   * RTL_CRITICAL_SECTION_DEBUG object. Unfortunately, this debug object is\n+   * not reclaimed by DeleteCriticalSection(), causing an apparent memory\n+   * leak. This is a debugging \"feature\", not a bug. If we are running on\n+   * Vista or later, use InitializeCriticalSectionEx() to allocate\n+   * CRITICAL_SECTIONs without debug objects.\n+   */\n+  HMODULE hKernel32 = GetModuleHandle(\"kernel32.dll\");\n+  PR_ASSERT(hKernel32);\n+  PR_ASSERT(!sInitializeCriticalSectionEx);\n+  sInitializeCriticalSectionEx = (INITIALIZECRITICALSECTIONEX)GetProcAddress(\n+      hKernel32, \"InitializeCriticalSectionEx\");\n }\n \n /*\n@@ -343,34 +326,30 @@ _PR_MD_INIT_LOCKS(void)\n  */\n #define LOCK_SPIN_COUNT 1500\n \n-PRStatus\n-_PR_MD_NEW_LOCK(_MDLock* lock)\n-{\n-    CRITICAL_SECTION* cs = &lock->mutex;\n-    BOOL ok;\n-\n-    if (sInitializeCriticalSectionEx) {\n-        ok = sInitializeCriticalSectionEx(cs, LOCK_SPIN_COUNT,\n-                                          CRITICAL_SECTION_NO_DEBUG_INFO);\n-    } else {\n-        ok = InitializeCriticalSectionAndSpinCount(cs, LOCK_SPIN_COUNT);\n-    }\n-    if (!ok) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        return PR_FAILURE;\n-    }\n-\n-    lock->notified.length = 0;\n-    lock->notified.link = NULL;\n-    return PR_SUCCESS;\n+PRStatus _PR_MD_NEW_LOCK(_MDLock* lock) {\n+  CRITICAL_SECTION* cs = &lock->mutex;\n+  BOOL ok;\n+\n+  if (sInitializeCriticalSectionEx) {\n+    ok = sInitializeCriticalSectionEx(cs, LOCK_SPIN_COUNT,\n+                                      CRITICAL_SECTION_NO_DEBUG_INFO);\n+  } else {\n+    ok = InitializeCriticalSectionAndSpinCount(cs, LOCK_SPIN_COUNT);\n+  }\n+  if (!ok) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    return PR_FAILURE;\n+  }\n+\n+  lock->notified.length = 0;\n+  lock->notified.link = NULL;\n+  return PR_SUCCESS;\n }\n \n-void\n-_PR_MD_UNLOCK(_MDLock* lock)\n-{\n-    if (0 != lock->notified.length) {\n-        md_UnlockAndPostNotifies(lock, NULL, NULL);\n-    } else {\n-        LeaveCriticalSection(&lock->mutex);\n-    }\n+void _PR_MD_UNLOCK(_MDLock* lock) {\n+  if (0 != lock->notified.length) {\n+    md_UnlockAndPostNotifies(lock, NULL, NULL);\n+  } else {\n+    LeaveCriticalSection(&lock->mutex);\n+  }\n }\ndiff --git a/nspr/pr/src/md/windows/w95dllmain.c b/nspr/pr/src/md/windows/w95dllmain.c\nindex 8ca8e98..5395c44 100644\n--- a/nspr/pr/src/md/windows/w95dllmain.c\n+++ b/nspr/pr/src/md/windows/w95dllmain.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -12,26 +13,24 @@\n #include <windows.h>\n #include <primpl.h>\n \n-BOOL WINAPI\n-DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)\n-{\n-    PRThread* me;\n+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {\n+  PRThread* me;\n \n-    switch (fdwReason) {\n-        case DLL_PROCESS_ATTACH:\n-            break;\n-        case DLL_THREAD_ATTACH:\n-            break;\n-        case DLL_THREAD_DETACH:\n-            if (_pr_initialized) {\n-                me = _MD_GET_ATTACHED_THREAD();\n-                if ((me != NULL) && (me->flags & _PR_ATTACHED)) {\n-                    _PRI_DetachThread();\n-                }\n-            }\n-            break;\n-        case DLL_PROCESS_DETACH:\n-            break;\n-    }\n-    return TRUE;\n+  switch (fdwReason) {\n+    case DLL_PROCESS_ATTACH:\n+      break;\n+    case DLL_THREAD_ATTACH:\n+      break;\n+    case DLL_THREAD_DETACH:\n+      if (_pr_initialized) {\n+        me = _MD_GET_ATTACHED_THREAD();\n+        if ((me != NULL) && (me->flags & _PR_ATTACHED)) {\n+          _PRI_DetachThread();\n+        }\n+      }\n+      break;\n+    case DLL_PROCESS_DETACH:\n+      break;\n+  }\n+  return TRUE;\n }\ndiff --git a/nspr/pr/src/md/windows/w95io.c b/nspr/pr/src/md/windows/w95io.c\nindex e1d5c4d..78916ac 100644\n--- a/nspr/pr/src/md/windows/w95io.c\n+++ b/nspr/pr/src/md/windows/w95io.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -12,7 +13,7 @@\n #include <direct.h>\n #include <mbstring.h>\n #ifdef MOZ_UNICODE\n-#include <wchar.h>\n+#  include <wchar.h>\n #endif /* MOZ_UNICODE */\n \n struct _MDLock _pr_ioq_lock;\n@@ -20,103 +21,97 @@ struct _MDLock _pr_ioq_lock;\n /*\n  * NSPR-to-NT access right mapping table for files.\n  */\n-static DWORD fileAccessTable[] = { FILE_GENERIC_READ, FILE_GENERIC_WRITE,\n-                                   FILE_GENERIC_EXECUTE };\n+static DWORD fileAccessTable[] = {FILE_GENERIC_READ, FILE_GENERIC_WRITE,\n+                                  FILE_GENERIC_EXECUTE};\n \n /*\n  * NSPR-to-NT access right mapping table for directories.\n  */\n-static DWORD dirAccessTable[] = { FILE_GENERIC_READ,\n-                                  FILE_GENERIC_WRITE | FILE_DELETE_CHILD,\n-                                  FILE_GENERIC_EXECUTE };\n+static DWORD dirAccessTable[] = {FILE_GENERIC_READ,\n+                                 FILE_GENERIC_WRITE | FILE_DELETE_CHILD,\n+                                 FILE_GENERIC_EXECUTE};\n \n static PRBool IsPrevCharSlash(const char* str, const char* current);\n \n-void\n-_PR_MD_INIT_IO()\n-{\n-    WORD WSAVersion = 0x0101;\n-    WSADATA WSAData;\n-    int err;\n+void _PR_MD_INIT_IO() {\n+  WORD WSAVersion = 0x0101;\n+  WSADATA WSAData;\n+  int err;\n \n-    err = WSAStartup(WSAVersion, &WSAData);\n-    PR_ASSERT(0 == err);\n+  err = WSAStartup(WSAVersion, &WSAData);\n+  PR_ASSERT(0 == err);\n \n #ifdef DEBUG\n-    /* Doublecheck _pr_filetime_offset's hard-coded value is correct. */\n-    {\n-        SYSTEMTIME systime;\n-        union {\n-            PRTime prt;\n-            FILETIME ft;\n-        } filetime;\n-        BOOL rv;\n-\n-        systime.wYear = 1970;\n-        systime.wMonth = 1;\n-        /* wDayOfWeek is ignored */\n-        systime.wDay = 1;\n-        systime.wHour = 0;\n-        systime.wMinute = 0;\n-        systime.wSecond = 0;\n-        systime.wMilliseconds = 0;\n-\n-        rv = SystemTimeToFileTime(&systime, &filetime.ft);\n-        PR_ASSERT(0 != rv);\n-        PR_ASSERT(filetime.prt == _pr_filetime_offset);\n-    }\n+  /* Doublecheck _pr_filetime_offset's hard-coded value is correct. */\n+  {\n+    SYSTEMTIME systime;\n+    union {\n+      PRTime prt;\n+      FILETIME ft;\n+    } filetime;\n+    BOOL rv;\n+\n+    systime.wYear = 1970;\n+    systime.wMonth = 1;\n+    /* wDayOfWeek is ignored */\n+    systime.wDay = 1;\n+    systime.wHour = 0;\n+    systime.wMinute = 0;\n+    systime.wSecond = 0;\n+    systime.wMilliseconds = 0;\n+\n+    rv = SystemTimeToFileTime(&systime, &filetime.ft);\n+    PR_ASSERT(0 != rv);\n+    PR_ASSERT(filetime.prt == _pr_filetime_offset);\n+  }\n #endif /* DEBUG */\n \n-    _PR_NT_InitSids();\n+  _PR_NT_InitSids();\n \n-    _PR_MD_InitSockets();\n+  _PR_MD_InitSockets();\n }\n \n-PRStatus\n-_PR_MD_WAIT(PRThread* thread, PRIntervalTime ticks)\n-{\n-    DWORD rv;\n-\n-    PRUint32 msecs = (ticks == PR_INTERVAL_NO_TIMEOUT)\n-                         ? INFINITE\n-                         : PR_IntervalToMilliseconds(ticks);\n-    rv = WaitForSingleObject(thread->md.blocked_sema, msecs);\n-    switch (rv) {\n-        case WAIT_OBJECT_0:\n-            return PR_SUCCESS;\n-        case WAIT_TIMEOUT:\n-            _PR_THREAD_LOCK(thread);\n-            if (thread->state == _PR_IO_WAIT) {\n-                ;\n-            } else {\n-                if (thread->wait.cvar != NULL) {\n-                    thread->wait.cvar = NULL;\n-                    _PR_THREAD_UNLOCK(thread);\n-                } else {\n-                    /* The CVAR was notified just as the timeout\n-                     * occurred.  This led to us being notified twice.\n-                     * call WaitForSingleObject() to clear the semaphore.\n-                     */\n-                    _PR_THREAD_UNLOCK(thread);\n-                    rv = WaitForSingleObject(thread->md.blocked_sema, 0);\n-                    PR_ASSERT(rv == WAIT_OBJECT_0);\n-                }\n-            }\n-            return PR_SUCCESS;\n-        default:\n-            return PR_FAILURE;\n-    }\n-}\n-PRStatus\n-_PR_MD_WAKEUP_WAITER(PRThread* thread)\n-{\n-    if (_PR_IS_NATIVE_THREAD(thread)) {\n-        if (ReleaseSemaphore(thread->md.blocked_sema, 1, NULL) == FALSE) {\n-            return PR_FAILURE;\n+PRStatus _PR_MD_WAIT(PRThread* thread, PRIntervalTime ticks) {\n+  DWORD rv;\n+\n+  PRUint32 msecs = (ticks == PR_INTERVAL_NO_TIMEOUT)\n+                       ? INFINITE\n+                       : PR_IntervalToMilliseconds(ticks);\n+  rv = WaitForSingleObject(thread->md.blocked_sema, msecs);\n+  switch (rv) {\n+    case WAIT_OBJECT_0:\n+      return PR_SUCCESS;\n+    case WAIT_TIMEOUT:\n+      _PR_THREAD_LOCK(thread);\n+      if (thread->state == _PR_IO_WAIT) {\n+        ;\n+      } else {\n+        if (thread->wait.cvar != NULL) {\n+          thread->wait.cvar = NULL;\n+          _PR_THREAD_UNLOCK(thread);\n         } else {\n-            return PR_SUCCESS;\n+          /* The CVAR was notified just as the timeout\n+           * occurred.  This led to us being notified twice.\n+           * call WaitForSingleObject() to clear the semaphore.\n+           */\n+          _PR_THREAD_UNLOCK(thread);\n+          rv = WaitForSingleObject(thread->md.blocked_sema, 0);\n+          PR_ASSERT(rv == WAIT_OBJECT_0);\n         }\n+      }\n+      return PR_SUCCESS;\n+    default:\n+      return PR_FAILURE;\n+  }\n+}\n+PRStatus _PR_MD_WAKEUP_WAITER(PRThread* thread) {\n+  if (_PR_IS_NATIVE_THREAD(thread)) {\n+    if (ReleaseSemaphore(thread->md.blocked_sema, 1, NULL) == FALSE) {\n+      return PR_FAILURE;\n+    } else {\n+      return PR_SUCCESS;\n     }\n+  }\n }\n \n /* --- FILE IO ----------------------------------------------------------- */\n@@ -131,217 +126,205 @@ _PR_MD_WAKEUP_WAITER(PRThread* thread)\n  *  as in 0666, in the case of opening the logFile.\n  *\n  */\n-PROsfd\n-_PR_MD_OPEN(const char* name, PRIntn osflags, int mode)\n-{\n-    HANDLE file;\n-    PRInt32 access = 0;\n-    PRInt32 flags = 0;\n-    PRInt32 flag6 = 0;\n-\n-    if (osflags & PR_SYNC) {\n-        flag6 = FILE_FLAG_WRITE_THROUGH;\n-    }\n-\n-    if (osflags & PR_RDONLY || osflags & PR_RDWR) {\n-        access |= GENERIC_READ;\n-    }\n-    if (osflags & PR_WRONLY || osflags & PR_RDWR) {\n-        access |= GENERIC_WRITE;\n+PROsfd _PR_MD_OPEN(const char* name, PRIntn osflags, int mode) {\n+  HANDLE file;\n+  PRInt32 access = 0;\n+  PRInt32 flags = 0;\n+  PRInt32 flag6 = 0;\n+\n+  if (osflags & PR_SYNC) {\n+    flag6 = FILE_FLAG_WRITE_THROUGH;\n+  }\n+\n+  if (osflags & PR_RDONLY || osflags & PR_RDWR) {\n+    access |= GENERIC_READ;\n+  }\n+  if (osflags & PR_WRONLY || osflags & PR_RDWR) {\n+    access |= GENERIC_WRITE;\n+  }\n+\n+  if (osflags & PR_CREATE_FILE && osflags & PR_EXCL) {\n+    flags = CREATE_NEW;\n+  } else if (osflags & PR_CREATE_FILE) {\n+    if (osflags & PR_TRUNCATE) {\n+      flags = CREATE_ALWAYS;\n+    } else {\n+      flags = OPEN_ALWAYS;\n     }\n-\n-    if (osflags & PR_CREATE_FILE && osflags & PR_EXCL) {\n-        flags = CREATE_NEW;\n-    } else if (osflags & PR_CREATE_FILE) {\n-        if (osflags & PR_TRUNCATE) {\n-            flags = CREATE_ALWAYS;\n-        } else {\n-            flags = OPEN_ALWAYS;\n-        }\n+  } else {\n+    if (osflags & PR_TRUNCATE) {\n+      flags = TRUNCATE_EXISTING;\n     } else {\n-        if (osflags & PR_TRUNCATE) {\n-            flags = TRUNCATE_EXISTING;\n-        } else {\n-            flags = OPEN_EXISTING;\n-        }\n+      flags = OPEN_EXISTING;\n     }\n+  }\n \n-    file = CreateFileA(name, access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,\n-                       flags, flag6, NULL);\n-    if (file == INVALID_HANDLE_VALUE) {\n-        _PR_MD_MAP_OPEN_ERROR(GetLastError());\n-        return -1;\n-    }\n+  file = CreateFileA(name, access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,\n+                     flags, flag6, NULL);\n+  if (file == INVALID_HANDLE_VALUE) {\n+    _PR_MD_MAP_OPEN_ERROR(GetLastError());\n+    return -1;\n+  }\n \n-    return (PROsfd)file;\n+  return (PROsfd)file;\n }\n \n-PROsfd\n-_PR_MD_OPEN_FILE(const char* name, PRIntn osflags, int mode)\n-{\n-    HANDLE file;\n-    PRInt32 access = 0;\n-    PRInt32 flags = 0;\n-    PRInt32 flag6 = 0;\n-    SECURITY_ATTRIBUTES sa;\n-    LPSECURITY_ATTRIBUTES lpSA = NULL;\n-    PSECURITY_DESCRIPTOR pSD = NULL;\n-    PACL pACL = NULL;\n-\n-    if (osflags & PR_CREATE_FILE) {\n-        if (_PR_NT_MakeSecurityDescriptorACL(mode, fileAccessTable, &pSD, &pACL) ==\n-            PR_SUCCESS) {\n-            sa.nLength = sizeof(sa);\n-            sa.lpSecurityDescriptor = pSD;\n-            sa.bInheritHandle = FALSE;\n-            lpSA = &sa;\n-        }\n-    }\n-\n-    if (osflags & PR_SYNC) {\n-        flag6 = FILE_FLAG_WRITE_THROUGH;\n-    }\n-\n-    if (osflags & PR_RDONLY || osflags & PR_RDWR) {\n-        access |= GENERIC_READ;\n-    }\n-    if (osflags & PR_WRONLY || osflags & PR_RDWR) {\n-        access |= GENERIC_WRITE;\n+PROsfd _PR_MD_OPEN_FILE(const char* name, PRIntn osflags, int mode) {\n+  HANDLE file;\n+  PRInt32 access = 0;\n+  PRInt32 flags = 0;\n+  PRInt32 flag6 = 0;\n+  SECURITY_ATTRIBUTES sa;\n+  LPSECURITY_ATTRIBUTES lpSA = NULL;\n+  PSECURITY_DESCRIPTOR pSD = NULL;\n+  PACL pACL = NULL;\n+\n+  if (osflags & PR_CREATE_FILE) {\n+    if (_PR_NT_MakeSecurityDescriptorACL(mode, fileAccessTable, &pSD, &pACL) ==\n+        PR_SUCCESS) {\n+      sa.nLength = sizeof(sa);\n+      sa.lpSecurityDescriptor = pSD;\n+      sa.bInheritHandle = FALSE;\n+      lpSA = &sa;\n+    }\n+  }\n+\n+  if (osflags & PR_SYNC) {\n+    flag6 = FILE_FLAG_WRITE_THROUGH;\n+  }\n+\n+  if (osflags & PR_RDONLY || osflags & PR_RDWR) {\n+    access |= GENERIC_READ;\n+  }\n+  if (osflags & PR_WRONLY || osflags & PR_RDWR) {\n+    access |= GENERIC_WRITE;\n+  }\n+\n+  if (osflags & PR_CREATE_FILE && osflags & PR_EXCL) {\n+    flags = CREATE_NEW;\n+  } else if (osflags & PR_CREATE_FILE) {\n+    if (osflags & PR_TRUNCATE) {\n+      flags = CREATE_ALWAYS;\n+    } else {\n+      flags = OPEN_ALWAYS;\n     }\n-\n-    if (osflags & PR_CREATE_FILE && osflags & PR_EXCL) {\n-        flags = CREATE_NEW;\n-    } else if (osflags & PR_CREATE_FILE) {\n-        if (osflags & PR_TRUNCATE) {\n-            flags = CREATE_ALWAYS;\n-        } else {\n-            flags = OPEN_ALWAYS;\n-        }\n+  } else {\n+    if (osflags & PR_TRUNCATE) {\n+      flags = TRUNCATE_EXISTING;\n     } else {\n-        if (osflags & PR_TRUNCATE) {\n-            flags = TRUNCATE_EXISTING;\n-        } else {\n-            flags = OPEN_EXISTING;\n-        }\n+      flags = OPEN_EXISTING;\n     }\n+  }\n \n-    file = CreateFileA(name, access, FILE_SHARE_READ | FILE_SHARE_WRITE, lpSA,\n-                       flags, flag6, NULL);\n-    if (lpSA != NULL) {\n-        _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n-    }\n-    if (file == INVALID_HANDLE_VALUE) {\n-        _PR_MD_MAP_OPEN_ERROR(GetLastError());\n-        return -1;\n-    }\n+  file = CreateFileA(name, access, FILE_SHARE_READ | FILE_SHARE_WRITE, lpSA,\n+                     flags, flag6, NULL);\n+  if (lpSA != NULL) {\n+    _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n+  }\n+  if (file == INVALID_HANDLE_VALUE) {\n+    _PR_MD_MAP_OPEN_ERROR(GetLastError());\n+    return -1;\n+  }\n \n-    return (PROsfd)file;\n+  return (PROsfd)file;\n }\n \n-PRInt32\n-_PR_MD_READ(PRFileDesc* fd, void* buf, PRInt32 len)\n-{\n-    DWORD bytes;\n-    int rv, err;\n+PRInt32 _PR_MD_READ(PRFileDesc* fd, void* buf, PRInt32 len) {\n+  PRUint32 bytes;\n+  int rv, err;\n \n-    rv = ReadFile((HANDLE)fd->secret->md.osfd, (LPVOID)buf, len, &bytes, NULL);\n+  rv = ReadFile((HANDLE)fd->secret->md.osfd, (LPVOID)buf, len, &bytes, NULL);\n \n-    if (rv == 0) {\n-        err = GetLastError();\n-        /* ERROR_HANDLE_EOF can only be returned by async io */\n-        PR_ASSERT(err != ERROR_HANDLE_EOF);\n-        if (err == ERROR_BROKEN_PIPE) {\n-            return 0;\n-        } else {\n-            _PR_MD_MAP_READ_ERROR(err);\n-            return -1;\n-        }\n+  if (rv == 0) {\n+    err = GetLastError();\n+    /* ERROR_HANDLE_EOF can only be returned by async io */\n+    PR_ASSERT(err != ERROR_HANDLE_EOF);\n+    if (err == ERROR_BROKEN_PIPE) {\n+      return 0;\n+    } else {\n+      _PR_MD_MAP_READ_ERROR(err);\n+      return -1;\n     }\n-    return bytes;\n+  }\n+  return bytes;\n }\n \n-PRInt32\n-_PR_MD_WRITE(PRFileDesc* fd, const void* buf, PRInt32 len)\n-{\n-    PROsfd f = fd->secret->md.osfd;\n-    DWORD bytes;\n-    int rv;\n+PRInt32 _PR_MD_WRITE(PRFileDesc* fd, const void* buf, PRInt32 len) {\n+  PROsfd f = fd->secret->md.osfd;\n+  PRInt32 bytes;\n+  int rv;\n \n-    rv = WriteFile((HANDLE)f, buf, len, &bytes, NULL);\n+  rv = WriteFile((HANDLE)f, buf, len, &bytes, NULL);\n \n-    if (rv == 0) {\n-        _PR_MD_MAP_WRITE_ERROR(GetLastError());\n-        return -1;\n-    }\n-    return bytes;\n+  if (rv == 0) {\n+    _PR_MD_MAP_WRITE_ERROR(GetLastError());\n+    return -1;\n+  }\n+  return bytes;\n } /* --- end _PR_MD_WRITE() --- */\n \n-PROffset32\n-_PR_MD_LSEEK(PRFileDesc* fd, PROffset32 offset,\n-             PRSeekWhence whence)\n-{\n-    DWORD moveMethod;\n-    PROffset32 rv;\n-\n-    switch (whence) {\n-        case PR_SEEK_SET:\n-            moveMethod = FILE_BEGIN;\n-            break;\n-        case PR_SEEK_CUR:\n-            moveMethod = FILE_CURRENT;\n-            break;\n-        case PR_SEEK_END:\n-            moveMethod = FILE_END;\n-            break;\n-        default:\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            return -1;\n-    }\n-\n-    rv = SetFilePointer((HANDLE)fd->secret->md.osfd, offset, NULL, moveMethod);\n-\n-    /*\n-     * If the lpDistanceToMoveHigh argument (third argument) is\n-     * NULL, SetFilePointer returns 0xffffffff on failure.\n-     */\n-    if (-1 == rv) {\n-        _PR_MD_MAP_LSEEK_ERROR(GetLastError());\n-    }\n-    return rv;\n+PROffset32 _PR_MD_LSEEK(PRFileDesc* fd, PROffset32 offset,\n+                        PRSeekWhence whence) {\n+  DWORD moveMethod;\n+  PROffset32 rv;\n+\n+  switch (whence) {\n+    case PR_SEEK_SET:\n+      moveMethod = FILE_BEGIN;\n+      break;\n+    case PR_SEEK_CUR:\n+      moveMethod = FILE_CURRENT;\n+      break;\n+    case PR_SEEK_END:\n+      moveMethod = FILE_END;\n+      break;\n+    default:\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      return -1;\n+  }\n+\n+  rv = SetFilePointer((HANDLE)fd->secret->md.osfd, offset, NULL, moveMethod);\n+\n+  /*\n+   * If the lpDistanceToMoveHigh argument (third argument) is\n+   * NULL, SetFilePointer returns 0xffffffff on failure.\n+   */\n+  if (-1 == rv) {\n+    _PR_MD_MAP_LSEEK_ERROR(GetLastError());\n+  }\n+  return rv;\n }\n \n-PROffset64\n-_PR_MD_LSEEK64(PRFileDesc* fd, PROffset64 offset,\n-               PRSeekWhence whence)\n-{\n-    DWORD moveMethod;\n-    LARGE_INTEGER li;\n-    DWORD err;\n-\n-    switch (whence) {\n-        case PR_SEEK_SET:\n-            moveMethod = FILE_BEGIN;\n-            break;\n-        case PR_SEEK_CUR:\n-            moveMethod = FILE_CURRENT;\n-            break;\n-        case PR_SEEK_END:\n-            moveMethod = FILE_END;\n-            break;\n-        default:\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            return -1;\n-    }\n-\n-    li.QuadPart = offset;\n-    li.LowPart = SetFilePointer((HANDLE)fd->secret->md.osfd, li.LowPart,\n-                                &li.HighPart, moveMethod);\n-\n-    if (0xffffffff == li.LowPart && (err = GetLastError()) != NO_ERROR) {\n-        _PR_MD_MAP_LSEEK_ERROR(err);\n-        li.QuadPart = -1;\n-    }\n-    return li.QuadPart;\n+PROffset64 _PR_MD_LSEEK64(PRFileDesc* fd, PROffset64 offset,\n+                          PRSeekWhence whence) {\n+  DWORD moveMethod;\n+  LARGE_INTEGER li;\n+  DWORD err;\n+\n+  switch (whence) {\n+    case PR_SEEK_SET:\n+      moveMethod = FILE_BEGIN;\n+      break;\n+    case PR_SEEK_CUR:\n+      moveMethod = FILE_CURRENT;\n+      break;\n+    case PR_SEEK_END:\n+      moveMethod = FILE_END;\n+      break;\n+    default:\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      return -1;\n+  }\n+\n+  li.QuadPart = offset;\n+  li.LowPart = SetFilePointer((HANDLE)fd->secret->md.osfd, li.LowPart,\n+                              &li.HighPart, moveMethod);\n+\n+  if (0xffffffff == li.LowPart && (err = GetLastError()) != NO_ERROR) {\n+    _PR_MD_MAP_LSEEK_ERROR(err);\n+    li.QuadPart = -1;\n+  }\n+  return li.QuadPart;\n }\n \n /*\n@@ -350,63 +333,57 @@ _PR_MD_LSEEK64(PRFileDesc* fd, PROffset64 offset,\n  * case.  So we only signal an error if the error is *not* \"access\n  * denied\".\n  */\n-PRInt32\n-_PR_MD_FSYNC(PRFileDesc* fd)\n-{\n-    /*\n-     * From the documentation:\n-     *\n-     *     On Windows NT, the function FlushFileBuffers fails if hFile\n-     *     is a handle to console output. That is because console\n-     *     output is not buffered. The function returns FALSE, and\n-     *     GetLastError returns ERROR_INVALID_HANDLE.\n-     *\n-     * On the other hand, on Win95, it returns without error.  I cannot\n-     * assume that 0, 1, and 2 are console, because if someone closes\n-     * System.out and then opens a file, they might get file descriptor\n-     * 1.  An error on *that* version of 1 should be reported, whereas\n-     * an error on System.out (which was the original 1) should be\n-     * ignored.  So I use isatty() to ensure that such an error was due\n-     * to this bogosity, and if it was, I ignore the error.\n-     */\n-\n-    BOOL ok = FlushFileBuffers((HANDLE)fd->secret->md.osfd);\n-\n-    if (!ok) {\n-        DWORD err = GetLastError();\n-        if (err != ERROR_ACCESS_DENIED) { // from winerror.h\n-            _PR_MD_MAP_FSYNC_ERROR(err);\n-            return -1;\n-        }\n-    }\n-    return 0;\n+PRInt32 _PR_MD_FSYNC(PRFileDesc* fd) {\n+  /*\n+   * From the documentation:\n+   *\n+   *     On Windows NT, the function FlushFileBuffers fails if hFile\n+   *     is a handle to console output. That is because console\n+   *     output is not buffered. The function returns FALSE, and\n+   *     GetLastError returns ERROR_INVALID_HANDLE.\n+   *\n+   * On the other hand, on Win95, it returns without error.  I cannot\n+   * assume that 0, 1, and 2 are console, because if someone closes\n+   * System.out and then opens a file, they might get file descriptor\n+   * 1.  An error on *that* version of 1 should be reported, whereas\n+   * an error on System.out (which was the original 1) should be\n+   * ignored.  So I use isatty() to ensure that such an error was due\n+   * to this bogosity, and if it was, I ignore the error.\n+   */\n+\n+  BOOL ok = FlushFileBuffers((HANDLE)fd->secret->md.osfd);\n+\n+  if (!ok) {\n+    DWORD err = GetLastError();\n+    if (err != ERROR_ACCESS_DENIED) {  // from winerror.h\n+      _PR_MD_MAP_FSYNC_ERROR(err);\n+      return -1;\n+    }\n+  }\n+  return 0;\n }\n \n-PRInt32\n-_MD_CloseFile(PROsfd osfd)\n-{\n-    PRInt32 rv;\n+PRInt32 _MD_CloseFile(PROsfd osfd) {\n+  PRInt32 rv;\n \n-    rv = (CloseHandle((HANDLE)osfd)) ? 0 : -1;\n-    if (rv == -1) {\n-        _PR_MD_MAP_CLOSE_ERROR(GetLastError());\n-    }\n-    return rv;\n+  rv = (CloseHandle((HANDLE)osfd)) ? 0 : -1;\n+  if (rv == -1) {\n+    _PR_MD_MAP_CLOSE_ERROR(GetLastError());\n+  }\n+  return rv;\n }\n \n /* --- DIR IO ------------------------------------------------------------ */\n #define GetFileFromDIR(d) (d)->d_entry.cFileName\n #define FileIsHidden(d) ((d)->d_entry.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)\n \n-static void\n-FlipSlashes(char* cp, size_t len)\n-{\n-    while (len-- > 0) {\n-        if (cp[0] == '/') {\n-            cp[0] = PR_DIRECTORY_SEPARATOR;\n-        }\n-        cp = _mbsinc(cp);\n+static void FlipSlashes(char* cp, size_t len) {\n+  while (len-- > 0) {\n+    if (cp[0] == '/') {\n+      cp[0] = PR_DIRECTORY_SEPARATOR;\n     }\n+    cp = _mbsinc(cp);\n+  }\n } /* end FlipSlashes() */\n \n /*\n@@ -416,206 +393,192 @@ FlipSlashes(char* cp, size_t len)\n **\n */\n \n-PRInt32\n-_PR_MD_CLOSE_DIR(_MDDir* d)\n-{\n-    if (d) {\n-        if (FindClose(d->d_hdl)) {\n-            d->magic = (PRUint32)-1;\n-            return 0;\n-        } else {\n-            _PR_MD_MAP_CLOSEDIR_ERROR(GetLastError());\n-            return -1;\n-        }\n+PRInt32 _PR_MD_CLOSE_DIR(_MDDir* d) {\n+  if (d) {\n+    if (FindClose(d->d_hdl)) {\n+      d->magic = (PRUint32)-1;\n+      return 0;\n+    } else {\n+      _PR_MD_MAP_CLOSEDIR_ERROR(GetLastError());\n+      return -1;\n     }\n-    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-    return -1;\n+  }\n+  PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  return -1;\n }\n \n-PRStatus\n-_PR_MD_OPEN_DIR(_MDDir* d, const char* name)\n-{\n-    char filename[MAX_PATH];\n-    size_t len;\n-\n-    len = strlen(name);\n-    /* Need 5 bytes for \\*.* and the trailing null byte. */\n-    if (len + 5 > MAX_PATH) {\n-        PR_SetError(PR_NAME_TOO_LONG_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    strcpy(filename, name);\n+PRStatus _PR_MD_OPEN_DIR(_MDDir* d, const char* name) {\n+  char filename[MAX_PATH];\n+  size_t len;\n \n-    /*\n-     * If 'name' ends in a slash or backslash, do not append\n-     * another backslash.\n-     */\n-    if (IsPrevCharSlash(filename, filename + len)) {\n-        len--;\n-    }\n-    strcpy(&filename[len], \"\\\\*.*\");\n-    FlipSlashes(filename, strlen(filename));\n-\n-    d->d_hdl = FindFirstFileA(filename, &(d->d_entry));\n-    if (d->d_hdl == INVALID_HANDLE_VALUE) {\n-        _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n-        return PR_FAILURE;\n-    }\n-    d->firstEntry = PR_TRUE;\n-    d->magic = _MD_MAGIC_DIR;\n-    return PR_SUCCESS;\n+  len = strlen(name);\n+  /* Need 5 bytes for \\*.* and the trailing null byte. */\n+  if (len + 5 > MAX_PATH) {\n+    PR_SetError(PR_NAME_TOO_LONG_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  strcpy(filename, name);\n+\n+  /*\n+   * If 'name' ends in a slash or backslash, do not append\n+   * another backslash.\n+   */\n+  if (IsPrevCharSlash(filename, filename + len)) {\n+    len--;\n+  }\n+  strcpy(&filename[len], \"\\\\*.*\");\n+  FlipSlashes(filename, strlen(filename));\n+\n+  d->d_hdl = FindFirstFileA(filename, &(d->d_entry));\n+  if (d->d_hdl == INVALID_HANDLE_VALUE) {\n+    _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n+    return PR_FAILURE;\n+  }\n+  d->firstEntry = PR_TRUE;\n+  d->magic = _MD_MAGIC_DIR;\n+  return PR_SUCCESS;\n }\n \n-char*\n-_PR_MD_READ_DIR(_MDDir* d, PRIntn flags)\n-{\n-    PRInt32 err;\n-    BOOL rv;\n-    char* fileName;\n-\n-    if (d) {\n-        while (1) {\n-            if (d->firstEntry) {\n-                d->firstEntry = PR_FALSE;\n-                rv = 1;\n-            } else {\n-                rv = FindNextFileA(d->d_hdl, &(d->d_entry));\n-            }\n-            if (rv == 0) {\n-                break;\n-            }\n-            fileName = GetFileFromDIR(d);\n-            if ((flags & PR_SKIP_DOT) && (fileName[0] == '.') &&\n-                (fileName[1] == '\\0')) {\n-                continue;\n-            }\n-            if ((flags & PR_SKIP_DOT_DOT) && (fileName[0] == '.') &&\n-                (fileName[1] == '.') && (fileName[2] == '\\0')) {\n-                continue;\n-            }\n-            if ((flags & PR_SKIP_HIDDEN) && FileIsHidden(d)) {\n-                continue;\n-            }\n-            return fileName;\n-        }\n-        err = GetLastError();\n-        PR_ASSERT(NO_ERROR != err);\n-        _PR_MD_MAP_READDIR_ERROR(err);\n-        return NULL;\n-    }\n-    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+char* _PR_MD_READ_DIR(_MDDir* d, PRIntn flags) {\n+  PRInt32 err;\n+  BOOL rv;\n+  char* fileName;\n+\n+  if (d) {\n+    while (1) {\n+      if (d->firstEntry) {\n+        d->firstEntry = PR_FALSE;\n+        rv = 1;\n+      } else {\n+        rv = FindNextFileA(d->d_hdl, &(d->d_entry));\n+      }\n+      if (rv == 0) {\n+        break;\n+      }\n+      fileName = GetFileFromDIR(d);\n+      if ((flags & PR_SKIP_DOT) && (fileName[0] == '.') &&\n+          (fileName[1] == '\\0')) {\n+        continue;\n+      }\n+      if ((flags & PR_SKIP_DOT_DOT) && (fileName[0] == '.') &&\n+          (fileName[1] == '.') && (fileName[2] == '\\0')) {\n+        continue;\n+      }\n+      if ((flags & PR_SKIP_HIDDEN) && FileIsHidden(d)) {\n+        continue;\n+      }\n+      return fileName;\n+    }\n+    err = GetLastError();\n+    PR_ASSERT(NO_ERROR != err);\n+    _PR_MD_MAP_READDIR_ERROR(err);\n     return NULL;\n+  }\n+  PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  return NULL;\n }\n \n-PRInt32\n-_PR_MD_DELETE(const char* name)\n-{\n-    if (DeleteFileA(name)) {\n-        return 0;\n-    } else {\n-        _PR_MD_MAP_DELETE_ERROR(GetLastError());\n-        return -1;\n-    }\n+PRInt32 _PR_MD_DELETE(const char* name) {\n+  if (DeleteFileA(name)) {\n+    return 0;\n+  } else {\n+    _PR_MD_MAP_DELETE_ERROR(GetLastError());\n+    return -1;\n+  }\n }\n \n-void\n-_PR_FileTimeToPRTime(const FILETIME* filetime, PRTime* prtm)\n-{\n-    PR_ASSERT(sizeof(FILETIME) == sizeof(PRTime));\n-    CopyMemory(prtm, filetime, sizeof(PRTime));\n+void _PR_FileTimeToPRTime(const FILETIME* filetime, PRTime* prtm) {\n+  PR_ASSERT(sizeof(FILETIME) == sizeof(PRTime));\n+  CopyMemory(prtm, filetime, sizeof(PRTime));\n #if defined(__MINGW32__)\n-    *prtm = (*prtm - _pr_filetime_offset) / 10LL;\n+  *prtm = (*prtm - _pr_filetime_offset) / 10LL;\n #else\n-    *prtm = (*prtm - _pr_filetime_offset) / 10i64;\n+  *prtm = (*prtm - _pr_filetime_offset) / 10i64;\n #endif\n \n #ifdef DEBUG\n-    /* Doublecheck our calculation. */\n-    {\n-        SYSTEMTIME systime;\n-        PRExplodedTime etm;\n-        PRTime cmp; /* for comparison */\n-        BOOL rv;\n-\n-        rv = FileTimeToSystemTime(filetime, &systime);\n-        PR_ASSERT(0 != rv);\n-\n-        /*\n-         * PR_ImplodeTime ignores wday and yday.\n-         */\n-        etm.tm_usec = systime.wMilliseconds * PR_USEC_PER_MSEC;\n-        etm.tm_sec = systime.wSecond;\n-        etm.tm_min = systime.wMinute;\n-        etm.tm_hour = systime.wHour;\n-        etm.tm_mday = systime.wDay;\n-        etm.tm_month = systime.wMonth - 1;\n-        etm.tm_year = systime.wYear;\n-        /*\n-         * It is not well-documented what time zone the FILETIME's\n-         * are in.  WIN32_FIND_DATA is documented to be in UTC (GMT).\n-         * But BY_HANDLE_FILE_INFORMATION is unclear about this.\n-         * By our best judgement, we assume that FILETIME is in UTC.\n-         */\n-        etm.tm_params.tp_gmt_offset = 0;\n-        etm.tm_params.tp_dst_offset = 0;\n-        cmp = PR_ImplodeTime(&etm);\n-\n-        /*\n-         * SYSTEMTIME is in milliseconds precision, so we convert PRTime's\n-         * microseconds to milliseconds before doing the comparison.\n-         */\n-        PR_ASSERT((cmp / PR_USEC_PER_MSEC) == (*prtm / PR_USEC_PER_MSEC));\n-    }\n+  /* Doublecheck our calculation. */\n+  {\n+    SYSTEMTIME systime;\n+    PRExplodedTime etm;\n+    PRTime cmp; /* for comparison */\n+    BOOL rv;\n+\n+    rv = FileTimeToSystemTime(filetime, &systime);\n+    PR_ASSERT(0 != rv);\n+\n+    /*\n+     * PR_ImplodeTime ignores wday and yday.\n+     */\n+    etm.tm_usec = systime.wMilliseconds * PR_USEC_PER_MSEC;\n+    etm.tm_sec = systime.wSecond;\n+    etm.tm_min = systime.wMinute;\n+    etm.tm_hour = systime.wHour;\n+    etm.tm_mday = systime.wDay;\n+    etm.tm_month = systime.wMonth - 1;\n+    etm.tm_year = systime.wYear;\n+    /*\n+     * It is not well-documented what time zone the FILETIME's\n+     * are in.  WIN32_FIND_DATA is documented to be in UTC (GMT).\n+     * But BY_HANDLE_FILE_INFORMATION is unclear about this.\n+     * By our best judgement, we assume that FILETIME is in UTC.\n+     */\n+    etm.tm_params.tp_gmt_offset = 0;\n+    etm.tm_params.tp_dst_offset = 0;\n+    cmp = PR_ImplodeTime(&etm);\n+\n+    /*\n+     * SYSTEMTIME is in milliseconds precision, so we convert PRTime's\n+     * microseconds to milliseconds before doing the comparison.\n+     */\n+    PR_ASSERT((cmp / PR_USEC_PER_MSEC) == (*prtm / PR_USEC_PER_MSEC));\n+  }\n #endif /* DEBUG */\n }\n \n-PRInt32\n-_PR_MD_STAT(const char* fn, struct stat* info)\n-{\n-    PRInt32 rv;\n-\n-    rv = _stat(fn, (struct _stat*)info);\n-    if (-1 == rv) {\n-        /*\n-         * Check for MSVC runtime library _stat() bug.\n-         * (It's really a bug in FindFirstFile().)\n-         * If a pathname ends in a backslash or slash,\n-         * e.g., c:\\temp\\ or c:/temp/, _stat() will fail.\n-         * Note: a pathname ending in a slash (e.g., c:/temp/)\n-         * can be handled by _stat() on NT but not on Win95.\n-         *\n-         * We remove the backslash or slash at the end and\n-         * try again.\n-         */\n-\n-        size_t len = strlen(fn);\n-        if (len > 0 && len <= _MAX_PATH && IsPrevCharSlash(fn, fn + len)) {\n-            char newfn[_MAX_PATH + 1];\n-\n-            strcpy(newfn, fn);\n-            newfn[len - 1] = '\\0';\n-            rv = _stat(newfn, (struct _stat*)info);\n-        }\n-    }\n+PRInt32 _PR_MD_STAT(const char* fn, struct stat* info) {\n+  PRInt32 rv;\n \n-    if (-1 == rv) {\n-        _PR_MD_MAP_STAT_ERROR(errno);\n+  rv = _stat(fn, (struct _stat*)info);\n+  if (-1 == rv) {\n+    /*\n+     * Check for MSVC runtime library _stat() bug.\n+     * (It's really a bug in FindFirstFile().)\n+     * If a pathname ends in a backslash or slash,\n+     * e.g., c:\\temp\\ or c:/temp/, _stat() will fail.\n+     * Note: a pathname ending in a slash (e.g., c:/temp/)\n+     * can be handled by _stat() on NT but not on Win95.\n+     *\n+     * We remove the backslash or slash at the end and\n+     * try again.\n+     */\n+\n+    size_t len = strlen(fn);\n+    if (len > 0 && len <= _MAX_PATH && IsPrevCharSlash(fn, fn + len)) {\n+      char newfn[_MAX_PATH + 1];\n+\n+      strcpy(newfn, fn);\n+      newfn[len - 1] = '\\0';\n+      rv = _stat(newfn, (struct _stat*)info);\n     }\n-    return rv;\n+  }\n+\n+  if (-1 == rv) {\n+    _PR_MD_MAP_STAT_ERROR(errno);\n+  }\n+  return rv;\n }\n \n #define _PR_IS_SLASH(ch) ((ch) == '/' || (ch) == '\\\\')\n \n-static PRBool\n-IsPrevCharSlash(const char* str, const char* current)\n-{\n-    const char* prev;\n+static PRBool IsPrevCharSlash(const char* str, const char* current) {\n+  const char* prev;\n \n-    if (str >= current) {\n-        return PR_FALSE;\n-    }\n-    prev = _mbsdec(str, current);\n-    return (prev == current - 1) && _PR_IS_SLASH(*prev);\n+  if (str >= current) {\n+    return PR_FALSE;\n+  }\n+  prev = _mbsdec(str, current);\n+  return (prev == current - 1) && _PR_IS_SLASH(*prev);\n }\n \n /*\n@@ -636,349 +599,314 @@ IsPrevCharSlash(const char* str, const char* current)\n  *    of a UNC (Universal Naming Convention) name.\n  */\n \n-static PRBool\n-IsRootDirectory(char* fn, size_t buflen)\n-{\n-    char* p;\n-    PRBool slashAdded = PR_FALSE;\n-    PRBool rv = PR_FALSE;\n-\n-    if (_PR_IS_SLASH(fn[0]) && fn[1] == '\\0') {\n-        return PR_TRUE;\n-    }\n+static PRBool IsRootDirectory(char* fn, size_t buflen) {\n+  char* p;\n+  PRBool slashAdded = PR_FALSE;\n+  PRBool rv = PR_FALSE;\n \n-    if (isalpha((unsigned char)fn[0]) && fn[1] == ':' && _PR_IS_SLASH(fn[2]) &&\n-        fn[3] == '\\0') {\n-        rv = GetDriveType(fn) > 1 ? PR_TRUE : PR_FALSE;\n-        return rv;\n-    }\n+  if (_PR_IS_SLASH(fn[0]) && fn[1] == '\\0') {\n+    return PR_TRUE;\n+  }\n \n-    /* The UNC root directory */\n-\n-    if (_PR_IS_SLASH(fn[0]) && _PR_IS_SLASH(fn[1])) {\n-        /* The 'server' part should have at least one character. */\n-        p = &fn[2];\n-        if (*p == '\\0' || _PR_IS_SLASH(*p)) {\n-            return PR_FALSE;\n-        }\n-\n-        /* look for the next slash */\n-        do {\n-            p = _mbsinc(p);\n-        } while (*p != '\\0' && !_PR_IS_SLASH(*p));\n-        if (*p == '\\0') {\n-            return PR_FALSE;\n-        }\n-\n-        /* The 'share' part should have at least one character. */\n-        p++;\n-        if (*p == '\\0' || _PR_IS_SLASH(*p)) {\n-            return PR_FALSE;\n-        }\n-\n-        /* look for the final slash */\n-        do {\n-            p = _mbsinc(p);\n-        } while (*p != '\\0' && !_PR_IS_SLASH(*p));\n-        if (_PR_IS_SLASH(*p) && p[1] != '\\0') {\n-            return PR_FALSE;\n-        }\n-        if (*p == '\\0') {\n-            /*\n-             * GetDriveType() doesn't work correctly if the\n-             * path is of the form \\\\server\\share, so we add\n-             * a final slash temporarily.\n-             */\n-            if ((p + 1) < (fn + buflen)) {\n-                *p++ = '\\\\';\n-                *p = '\\0';\n-                slashAdded = PR_TRUE;\n-            } else {\n-                return PR_FALSE; /* name too long */\n-            }\n-        }\n-        rv = GetDriveType(fn) > 1 ? PR_TRUE : PR_FALSE;\n-        /* restore the 'fn' buffer */\n-        if (slashAdded) {\n-            *--p = '\\0';\n-        }\n-    }\n+  if (isalpha((unsigned char)fn[0]) && fn[1] == ':' && _PR_IS_SLASH(fn[2]) && fn[3] == '\\0') {\n+    rv = GetDriveType(fn) > 1 ? PR_TRUE : PR_FALSE;\n     return rv;\n+  }\n+\n+  /* The UNC root directory */\n+\n+  if (_PR_IS_SLASH(fn[0]) && _PR_IS_SLASH(fn[1])) {\n+    /* The 'server' part should have at least one character. */\n+    p = &fn[2];\n+    if (*p == '\\0' || _PR_IS_SLASH(*p)) {\n+      return PR_FALSE;\n+    }\n+\n+    /* look for the next slash */\n+    do {\n+      p = _mbsinc(p);\n+    } while (*p != '\\0' && !_PR_IS_SLASH(*p));\n+    if (*p == '\\0') {\n+      return PR_FALSE;\n+    }\n+\n+    /* The 'share' part should have at least one character. */\n+    p++;\n+    if (*p == '\\0' || _PR_IS_SLASH(*p)) {\n+      return PR_FALSE;\n+    }\n+\n+    /* look for the final slash */\n+    do {\n+      p = _mbsinc(p);\n+    } while (*p != '\\0' && !_PR_IS_SLASH(*p));\n+    if (_PR_IS_SLASH(*p) && p[1] != '\\0') {\n+      return PR_FALSE;\n+    }\n+    if (*p == '\\0') {\n+      /*\n+       * GetDriveType() doesn't work correctly if the\n+       * path is of the form \\\\server\\share, so we add\n+       * a final slash temporarily.\n+       */\n+      if ((p + 1) < (fn + buflen)) {\n+        *p++ = '\\\\';\n+        *p = '\\0';\n+        slashAdded = PR_TRUE;\n+      } else {\n+        return PR_FALSE; /* name too long */\n+      }\n+    }\n+    rv = GetDriveType(fn) > 1 ? PR_TRUE : PR_FALSE;\n+    /* restore the 'fn' buffer */\n+    if (slashAdded) {\n+      *--p = '\\0';\n+    }\n+  }\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_GETFILEINFO64(const char* fn, PRFileInfo64* info)\n-{\n-    WIN32_FILE_ATTRIBUTE_DATA findFileData;\n-    BOOL rv;\n+PRInt32 _PR_MD_GETFILEINFO64(const char* fn, PRFileInfo64* info) {\n+  WIN32_FILE_ATTRIBUTE_DATA findFileData;\n+  BOOL rv;\n \n-    if (NULL == fn || '\\0' == *fn) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return -1;\n-    }\n+  if (NULL == fn || '\\0' == *fn) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return -1;\n+  }\n \n-    rv = GetFileAttributesEx(fn, GetFileExInfoStandard, &findFileData);\n-    if (!rv) {\n-        _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n-        return -1;\n-    }\n+  rv = GetFileAttributesEx(fn, GetFileExInfoStandard, &findFileData);\n+  if (!rv) {\n+    _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n+    return -1;\n+  }\n \n-    if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n-        info->type = PR_FILE_DIRECTORY;\n-    } else {\n-        info->type = PR_FILE_FILE;\n-    }\n+  if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n+    info->type = PR_FILE_DIRECTORY;\n+  } else {\n+    info->type = PR_FILE_FILE;\n+  }\n \n-    info->size = findFileData.nFileSizeHigh;\n-    info->size = (info->size << 32) + findFileData.nFileSizeLow;\n+  info->size = findFileData.nFileSizeHigh;\n+  info->size = (info->size << 32) + findFileData.nFileSizeLow;\n \n-    _PR_FileTimeToPRTime(&findFileData.ftLastWriteTime, &info->modifyTime);\n+  _PR_FileTimeToPRTime(&findFileData.ftLastWriteTime, &info->modifyTime);\n \n-    if (0 == findFileData.ftCreationTime.dwLowDateTime &&\n-        0 == findFileData.ftCreationTime.dwHighDateTime) {\n-        info->creationTime = info->modifyTime;\n-    } else {\n-        _PR_FileTimeToPRTime(&findFileData.ftCreationTime, &info->creationTime);\n-    }\n+  if (0 == findFileData.ftCreationTime.dwLowDateTime &&\n+      0 == findFileData.ftCreationTime.dwHighDateTime) {\n+    info->creationTime = info->modifyTime;\n+  } else {\n+    _PR_FileTimeToPRTime(&findFileData.ftCreationTime, &info->creationTime);\n+  }\n \n-    return 0;\n+  return 0;\n }\n \n-PRInt32\n-_PR_MD_GETFILEINFO(const char* fn, PRFileInfo* info)\n-{\n-    PRFileInfo64 info64;\n-    PRInt32 rv = _PR_MD_GETFILEINFO64(fn, &info64);\n-    if (0 == rv) {\n-        info->type = info64.type;\n-        info->size = (PRUint32)info64.size;\n-        info->modifyTime = info64.modifyTime;\n-        info->creationTime = info64.creationTime;\n-    }\n-    return rv;\n+PRInt32 _PR_MD_GETFILEINFO(const char* fn, PRFileInfo* info) {\n+  PRFileInfo64 info64;\n+  PRInt32 rv = _PR_MD_GETFILEINFO64(fn, &info64);\n+  if (0 == rv) {\n+    info->type = info64.type;\n+    info->size = (PRUint32)info64.size;\n+    info->modifyTime = info64.modifyTime;\n+    info->creationTime = info64.creationTime;\n+  }\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_GETOPENFILEINFO64(const PRFileDesc* fd, PRFileInfo64* info)\n-{\n-    int rv;\n+PRInt32 _PR_MD_GETOPENFILEINFO64(const PRFileDesc* fd, PRFileInfo64* info) {\n+  int rv;\n \n-    BY_HANDLE_FILE_INFORMATION hinfo;\n+  BY_HANDLE_FILE_INFORMATION hinfo;\n \n-    rv = GetFileInformationByHandle((HANDLE)fd->secret->md.osfd, &hinfo);\n-    if (rv == FALSE) {\n-        _PR_MD_MAP_FSTAT_ERROR(GetLastError());\n-        return -1;\n-    }\n+  rv = GetFileInformationByHandle((HANDLE)fd->secret->md.osfd, &hinfo);\n+  if (rv == FALSE) {\n+    _PR_MD_MAP_FSTAT_ERROR(GetLastError());\n+    return -1;\n+  }\n \n-    if (hinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n-        info->type = PR_FILE_DIRECTORY;\n-    } else {\n-        info->type = PR_FILE_FILE;\n-    }\n+  if (hinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n+    info->type = PR_FILE_DIRECTORY;\n+  } else {\n+    info->type = PR_FILE_FILE;\n+  }\n \n-    info->size = hinfo.nFileSizeHigh;\n-    info->size = (info->size << 32) + hinfo.nFileSizeLow;\n+  info->size = hinfo.nFileSizeHigh;\n+  info->size = (info->size << 32) + hinfo.nFileSizeLow;\n \n-    _PR_FileTimeToPRTime(&hinfo.ftLastWriteTime, &(info->modifyTime));\n-    _PR_FileTimeToPRTime(&hinfo.ftCreationTime, &(info->creationTime));\n+  _PR_FileTimeToPRTime(&hinfo.ftLastWriteTime, &(info->modifyTime));\n+  _PR_FileTimeToPRTime(&hinfo.ftCreationTime, &(info->creationTime));\n \n-    return 0;\n+  return 0;\n }\n \n-PRInt32\n-_PR_MD_GETOPENFILEINFO(const PRFileDesc* fd, PRFileInfo* info)\n-{\n-    PRFileInfo64 info64;\n-    int rv = _PR_MD_GETOPENFILEINFO64(fd, &info64);\n-    if (0 == rv) {\n-        info->type = info64.type;\n-        info->modifyTime = info64.modifyTime;\n-        info->creationTime = info64.creationTime;\n-        LL_L2I(info->size, info64.size);\n-    }\n-    return rv;\n+PRInt32 _PR_MD_GETOPENFILEINFO(const PRFileDesc* fd, PRFileInfo* info) {\n+  PRFileInfo64 info64;\n+  int rv = _PR_MD_GETOPENFILEINFO64(fd, &info64);\n+  if (0 == rv) {\n+    info->type = info64.type;\n+    info->modifyTime = info64.modifyTime;\n+    info->creationTime = info64.creationTime;\n+    LL_L2I(info->size, info64.size);\n+  }\n+  return rv;\n }\n \n-PRStatus\n-_PR_MD_SET_FD_INHERITABLE(PRFileDesc* fd, PRBool inheritable)\n-{\n-    BOOL rv;\n-\n-    /*\n-     * The SetHandleInformation function fails with the\n-     * ERROR_CALL_NOT_IMPLEMENTED error on Win95.\n-     */\n-    rv = SetHandleInformation((HANDLE)fd->secret->md.osfd, HANDLE_FLAG_INHERIT,\n-                              inheritable ? HANDLE_FLAG_INHERIT : 0);\n-    if (0 == rv) {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+PRStatus _PR_MD_SET_FD_INHERITABLE(PRFileDesc* fd, PRBool inheritable) {\n+  BOOL rv;\n+\n+  /*\n+   * The SetHandleInformation function fails with the\n+   * ERROR_CALL_NOT_IMPLEMENTED error on Win95.\n+   */\n+  rv = SetHandleInformation((HANDLE)fd->secret->md.osfd, HANDLE_FLAG_INHERIT,\n+                            inheritable ? HANDLE_FLAG_INHERIT : 0);\n+  if (0 == rv) {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-void\n-_PR_MD_INIT_FD_INHERITABLE(PRFileDesc* fd, PRBool imported)\n-{\n-    if (imported) {\n-        fd->secret->inheritable = _PR_TRI_UNKNOWN;\n-    } else {\n-        fd->secret->inheritable = _PR_TRI_FALSE;\n-    }\n+void _PR_MD_INIT_FD_INHERITABLE(PRFileDesc* fd, PRBool imported) {\n+  if (imported) {\n+    fd->secret->inheritable = _PR_TRI_UNKNOWN;\n+  } else {\n+    fd->secret->inheritable = _PR_TRI_FALSE;\n+  }\n }\n \n-void\n-_PR_MD_QUERY_FD_INHERITABLE(PRFileDesc* fd)\n-{\n-    DWORD flags;\n+void _PR_MD_QUERY_FD_INHERITABLE(PRFileDesc* fd) {\n+  DWORD flags;\n \n-    PR_ASSERT(_PR_TRI_UNKNOWN == fd->secret->inheritable);\n-    if (GetHandleInformation((HANDLE)fd->secret->md.osfd, &flags)) {\n-        if (flags & HANDLE_FLAG_INHERIT) {\n-            fd->secret->inheritable = _PR_TRI_TRUE;\n-        } else {\n-            fd->secret->inheritable = _PR_TRI_FALSE;\n-        }\n-    }\n-}\n-\n-PRInt32\n-_PR_MD_RENAME(const char* from, const char* to)\n-{\n-    /* Does this work with dot-relative pathnames? */\n-    if (MoveFileA(from, to)) {\n-        return 0;\n+  PR_ASSERT(_PR_TRI_UNKNOWN == fd->secret->inheritable);\n+  if (GetHandleInformation((HANDLE)fd->secret->md.osfd, &flags)) {\n+    if (flags & HANDLE_FLAG_INHERIT) {\n+      fd->secret->inheritable = _PR_TRI_TRUE;\n     } else {\n-        _PR_MD_MAP_RENAME_ERROR(GetLastError());\n-        return -1;\n+      fd->secret->inheritable = _PR_TRI_FALSE;\n     }\n+  }\n }\n \n-PRInt32\n-_PR_MD_ACCESS(const char* name, PRAccessHow how)\n-{\n-    PRInt32 rv;\n-    switch (how) {\n-        case PR_ACCESS_WRITE_OK:\n-            rv = _access(name, 02);\n-            break;\n-        case PR_ACCESS_READ_OK:\n-            rv = _access(name, 04);\n-            break;\n-        case PR_ACCESS_EXISTS:\n-            return _access(name, 00);\n-            break;\n-        default:\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            return -1;\n-    }\n-    if (rv < 0) {\n-        _PR_MD_MAP_ACCESS_ERROR(errno);\n-    }\n-    return rv;\n+PRInt32 _PR_MD_RENAME(const char* from, const char* to) {\n+  /* Does this work with dot-relative pathnames? */\n+  if (MoveFileA(from, to)) {\n+    return 0;\n+  } else {\n+    _PR_MD_MAP_RENAME_ERROR(GetLastError());\n+    return -1;\n+  }\n }\n \n-PRInt32\n-_PR_MD_MKDIR(const char* name, PRIntn mode)\n-{\n-    /* XXXMB - how to translate the \"mode\"??? */\n-    if (CreateDirectoryA(name, NULL)) {\n-        return 0;\n-    } else {\n-        _PR_MD_MAP_MKDIR_ERROR(GetLastError());\n-        return -1;\n-    }\n+PRInt32 _PR_MD_ACCESS(const char* name, PRAccessHow how) {\n+  PRInt32 rv;\n+  switch (how) {\n+    case PR_ACCESS_WRITE_OK:\n+      rv = _access(name, 02);\n+      break;\n+    case PR_ACCESS_READ_OK:\n+      rv = _access(name, 04);\n+      break;\n+    case PR_ACCESS_EXISTS:\n+      return _access(name, 00);\n+      break;\n+    default:\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      return -1;\n+  }\n+  if (rv < 0) {\n+    _PR_MD_MAP_ACCESS_ERROR(errno);\n+  }\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_MAKE_DIR(const char* name, PRIntn mode)\n-{\n-    BOOL rv;\n-    SECURITY_ATTRIBUTES sa;\n-    LPSECURITY_ATTRIBUTES lpSA = NULL;\n-    PSECURITY_DESCRIPTOR pSD = NULL;\n-    PACL pACL = NULL;\n+PRInt32 _PR_MD_MKDIR(const char* name, PRIntn mode) {\n+  /* XXXMB - how to translate the \"mode\"??? */\n+  if (CreateDirectoryA(name, NULL)) {\n+    return 0;\n+  } else {\n+    _PR_MD_MAP_MKDIR_ERROR(GetLastError());\n+    return -1;\n+  }\n+}\n \n-    if (_PR_NT_MakeSecurityDescriptorACL(mode, dirAccessTable, &pSD, &pACL) ==\n-        PR_SUCCESS) {\n-        sa.nLength = sizeof(sa);\n-        sa.lpSecurityDescriptor = pSD;\n-        sa.bInheritHandle = FALSE;\n-        lpSA = &sa;\n-    }\n-    rv = CreateDirectoryA(name, lpSA);\n-    if (lpSA != NULL) {\n-        _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n-    }\n-    if (rv) {\n-        return 0;\n-    } else {\n-        _PR_MD_MAP_MKDIR_ERROR(GetLastError());\n-        return -1;\n-    }\n+PRInt32 _PR_MD_MAKE_DIR(const char* name, PRIntn mode) {\n+  BOOL rv;\n+  SECURITY_ATTRIBUTES sa;\n+  LPSECURITY_ATTRIBUTES lpSA = NULL;\n+  PSECURITY_DESCRIPTOR pSD = NULL;\n+  PACL pACL = NULL;\n+\n+  if (_PR_NT_MakeSecurityDescriptorACL(mode, dirAccessTable, &pSD, &pACL) ==\n+      PR_SUCCESS) {\n+    sa.nLength = sizeof(sa);\n+    sa.lpSecurityDescriptor = pSD;\n+    sa.bInheritHandle = FALSE;\n+    lpSA = &sa;\n+  }\n+  rv = CreateDirectoryA(name, lpSA);\n+  if (lpSA != NULL) {\n+    _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n+  }\n+  if (rv) {\n+    return 0;\n+  } else {\n+    _PR_MD_MAP_MKDIR_ERROR(GetLastError());\n+    return -1;\n+  }\n }\n \n-PRInt32\n-_PR_MD_RMDIR(const char* name)\n-{\n-    if (RemoveDirectoryA(name)) {\n-        return 0;\n-    } else {\n-        _PR_MD_MAP_RMDIR_ERROR(GetLastError());\n-        return -1;\n-    }\n+PRInt32 _PR_MD_RMDIR(const char* name) {\n+  if (RemoveDirectoryA(name)) {\n+    return 0;\n+  } else {\n+    _PR_MD_MAP_RMDIR_ERROR(GetLastError());\n+    return -1;\n+  }\n }\n \n-PRStatus\n-_PR_MD_LOCKFILE(PROsfd f)\n-{\n-    PRStatus rc = PR_SUCCESS;\n-    DWORD rv;\n-\n-    rv = LockFile((HANDLE)f, 0l, 0l, 0x0l, 0xffffffffl);\n-    if (rv == 0) {\n-        DWORD err = GetLastError();\n-        _PR_MD_MAP_DEFAULT_ERROR(err);\n-        PR_LOG(_pr_io_lm, PR_LOG_ERROR,\n-               (\"_PR_MD_LOCKFILE() failed. Error: %d\", err));\n-        rc = PR_FAILURE;\n-    }\n+PRStatus _PR_MD_LOCKFILE(PROsfd f) {\n+  PRStatus rc = PR_SUCCESS;\n+  DWORD rv;\n+\n+  rv = LockFile((HANDLE)f, 0l, 0l, 0x0l, 0xffffffffl);\n+  if (rv == 0) {\n+    DWORD err = GetLastError();\n+    _PR_MD_MAP_DEFAULT_ERROR(err);\n+    PR_LOG(_pr_io_lm, PR_LOG_ERROR,\n+           (\"_PR_MD_LOCKFILE() failed. Error: %d\", err));\n+    rc = PR_FAILURE;\n+  }\n \n-    return rc;\n+  return rc;\n } /* end _PR_MD_LOCKFILE() */\n \n-PRStatus\n-_PR_MD_TLOCKFILE(PROsfd f)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+PRStatus _PR_MD_TLOCKFILE(PROsfd f) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n } /* end _PR_MD_TLOCKFILE() */\n \n-PRStatus\n-_PR_MD_UNLOCKFILE(PROsfd f)\n-{\n-    PRInt32 rv;\n+PRStatus _PR_MD_UNLOCKFILE(PROsfd f) {\n+  PRInt32 rv;\n \n-    rv = UnlockFile((HANDLE)f, 0l, 0l, 0x0l, 0xffffffffl);\n+  rv = UnlockFile((HANDLE)f, 0l, 0l, 0x0l, 0xffffffffl);\n \n-    if (rv) {\n-        return PR_SUCCESS;\n-    } else {\n-        _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n-        return PR_FAILURE;\n-    }\n+  if (rv) {\n+    return PR_SUCCESS;\n+  } else {\n+    _PR_MD_MAP_DEFAULT_ERROR(GetLastError());\n+    return PR_FAILURE;\n+  }\n } /* end _PR_MD_UNLOCKFILE() */\n \n-PRInt32\n-_PR_MD_PIPEAVAILABLE(PRFileDesc* fd)\n-{\n-    if (NULL == fd) {\n-        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n-    } else {\n-        PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    }\n-    return -1;\n+PRInt32 _PR_MD_PIPEAVAILABLE(PRFileDesc* fd) {\n+  if (NULL == fd) {\n+    PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n+  } else {\n+    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  }\n+  return -1;\n }\n \n #ifdef MOZ_UNICODE\n@@ -1001,171 +929,161 @@ static GetDriveTypeWFn getDriveTypeW = GetDriveTypeW;\n #ifdef MOZ_UNICODE\n \n /* ================ UTF16 Interfaces ================================ */\n-static void\n-FlipSlashesW(PRUnichar* cp, size_t len)\n-{\n-    while (len-- > 0) {\n-        if (cp[0] == L'/') {\n-            cp[0] = L'\\\\';\n-        }\n-        cp++;\n+static void FlipSlashesW(PRUnichar* cp, size_t len) {\n+  while (len-- > 0) {\n+    if (cp[0] == L'/') {\n+      cp[0] = L'\\\\';\n     }\n+    cp++;\n+  }\n } /* end FlipSlashesW() */\n \n-PROsfd\n-_PR_MD_OPEN_FILE_UTF16(const PRUnichar* name, PRIntn osflags, int mode)\n-{\n-    HANDLE file;\n-    PRInt32 access = 0;\n-    PRInt32 flags = 0;\n-    PRInt32 flag6 = 0;\n-    SECURITY_ATTRIBUTES sa;\n-    LPSECURITY_ATTRIBUTES lpSA = NULL;\n-    PSECURITY_DESCRIPTOR pSD = NULL;\n-    PACL pACL = NULL;\n-\n-    if (osflags & PR_CREATE_FILE) {\n-        if (_PR_NT_MakeSecurityDescriptorACL(mode, fileAccessTable, &pSD, &pACL) ==\n-            PR_SUCCESS) {\n-            sa.nLength = sizeof(sa);\n-            sa.lpSecurityDescriptor = pSD;\n-            sa.bInheritHandle = FALSE;\n-            lpSA = &sa;\n-        }\n-    }\n-\n-    if (osflags & PR_SYNC) {\n-        flag6 = FILE_FLAG_WRITE_THROUGH;\n-    }\n-\n-    if (osflags & PR_RDONLY || osflags & PR_RDWR) {\n-        access |= GENERIC_READ;\n-    }\n-    if (osflags & PR_WRONLY || osflags & PR_RDWR) {\n-        access |= GENERIC_WRITE;\n+PROsfd _PR_MD_OPEN_FILE_UTF16(const PRUnichar* name, PRIntn osflags, int mode) {\n+  HANDLE file;\n+  PRInt32 access = 0;\n+  PRInt32 flags = 0;\n+  PRInt32 flag6 = 0;\n+  SECURITY_ATTRIBUTES sa;\n+  LPSECURITY_ATTRIBUTES lpSA = NULL;\n+  PSECURITY_DESCRIPTOR pSD = NULL;\n+  PACL pACL = NULL;\n+\n+  if (osflags & PR_CREATE_FILE) {\n+    if (_PR_NT_MakeSecurityDescriptorACL(mode, fileAccessTable, &pSD, &pACL) ==\n+        PR_SUCCESS) {\n+      sa.nLength = sizeof(sa);\n+      sa.lpSecurityDescriptor = pSD;\n+      sa.bInheritHandle = FALSE;\n+      lpSA = &sa;\n+    }\n+  }\n+\n+  if (osflags & PR_SYNC) {\n+    flag6 = FILE_FLAG_WRITE_THROUGH;\n+  }\n+\n+  if (osflags & PR_RDONLY || osflags & PR_RDWR) {\n+    access |= GENERIC_READ;\n+  }\n+  if (osflags & PR_WRONLY || osflags & PR_RDWR) {\n+    access |= GENERIC_WRITE;\n+  }\n+\n+  if (osflags & PR_CREATE_FILE && osflags & PR_EXCL) {\n+    flags = CREATE_NEW;\n+  } else if (osflags & PR_CREATE_FILE) {\n+    if (osflags & PR_TRUNCATE) {\n+      flags = CREATE_ALWAYS;\n+    } else {\n+      flags = OPEN_ALWAYS;\n     }\n-\n-    if (osflags & PR_CREATE_FILE && osflags & PR_EXCL) {\n-        flags = CREATE_NEW;\n-    } else if (osflags & PR_CREATE_FILE) {\n-        if (osflags & PR_TRUNCATE) {\n-            flags = CREATE_ALWAYS;\n-        } else {\n-            flags = OPEN_ALWAYS;\n-        }\n+  } else {\n+    if (osflags & PR_TRUNCATE) {\n+      flags = TRUNCATE_EXISTING;\n     } else {\n-        if (osflags & PR_TRUNCATE) {\n-            flags = TRUNCATE_EXISTING;\n-        } else {\n-            flags = OPEN_EXISTING;\n-        }\n+      flags = OPEN_EXISTING;\n     }\n+  }\n \n-    file = createFileW(name, access, FILE_SHARE_READ | FILE_SHARE_WRITE, lpSA,\n-                       flags, flag6, NULL);\n-    if (lpSA != NULL) {\n-        _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n-    }\n-    if (file == INVALID_HANDLE_VALUE) {\n-        _PR_MD_MAP_OPEN_ERROR(GetLastError());\n-        return -1;\n-    }\n+  file = createFileW(name, access, FILE_SHARE_READ | FILE_SHARE_WRITE, lpSA,\n+                     flags, flag6, NULL);\n+  if (lpSA != NULL) {\n+    _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);\n+  }\n+  if (file == INVALID_HANDLE_VALUE) {\n+    _PR_MD_MAP_OPEN_ERROR(GetLastError());\n+    return -1;\n+  }\n \n-    return (PROsfd)file;\n+  return (PROsfd)file;\n }\n \n-PRStatus\n-_PR_MD_OPEN_DIR_UTF16(_MDDirUTF16* d, const PRUnichar* name)\n-{\n-    PRUnichar filename[MAX_PATH];\n-    int len;\n-\n-    len = wcslen(name);\n-    /* Need 5 bytes for \\*.* and the trailing null byte. */\n-    if (len + 5 > MAX_PATH) {\n-        PR_SetError(PR_NAME_TOO_LONG_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    wcscpy(filename, name);\n-\n-    /*\n-     * If 'name' ends in a slash or backslash, do not append\n-     * another backslash.\n-     */\n-    if (filename[len - 1] == L'/' || filename[len - 1] == L'\\\\') {\n-        len--;\n-    }\n-    wcscpy(&filename[len], L\"\\\\*.*\");\n-    FlipSlashesW(filename, wcslen(filename));\n+PRStatus _PR_MD_OPEN_DIR_UTF16(_MDDirUTF16* d, const PRUnichar* name) {\n+  PRUnichar filename[MAX_PATH];\n+  int len;\n \n-    d->d_hdl = findFirstFileW(filename, &(d->d_entry));\n-    if (d->d_hdl == INVALID_HANDLE_VALUE) {\n-        _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n-        return PR_FAILURE;\n-    }\n-    d->firstEntry = PR_TRUE;\n-    d->magic = _MD_MAGIC_DIR;\n-    return PR_SUCCESS;\n+  len = wcslen(name);\n+  /* Need 5 bytes for \\*.* and the trailing null byte. */\n+  if (len + 5 > MAX_PATH) {\n+    PR_SetError(PR_NAME_TOO_LONG_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  wcscpy(filename, name);\n+\n+  /*\n+   * If 'name' ends in a slash or backslash, do not append\n+   * another backslash.\n+   */\n+  if (filename[len - 1] == L'/' || filename[len - 1] == L'\\\\') {\n+    len--;\n+  }\n+  wcscpy(&filename[len], L\"\\\\*.*\");\n+  FlipSlashesW(filename, wcslen(filename));\n+\n+  d->d_hdl = findFirstFileW(filename, &(d->d_entry));\n+  if (d->d_hdl == INVALID_HANDLE_VALUE) {\n+    _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n+    return PR_FAILURE;\n+  }\n+  d->firstEntry = PR_TRUE;\n+  d->magic = _MD_MAGIC_DIR;\n+  return PR_SUCCESS;\n }\n \n-PRUnichar*\n-_PR_MD_READ_DIR_UTF16(_MDDirUTF16* d, PRIntn flags)\n-{\n-    PRInt32 err;\n-    BOOL rv;\n-    PRUnichar* fileName;\n-\n-    if (d) {\n-        while (1) {\n-            if (d->firstEntry) {\n-                d->firstEntry = PR_FALSE;\n-                rv = 1;\n-            } else {\n-                rv = findNextFileW(d->d_hdl, &(d->d_entry));\n-            }\n-            if (rv == 0) {\n-                break;\n-            }\n-            fileName = GetFileFromDIR(d);\n-            if ((flags & PR_SKIP_DOT) && (fileName[0] == L'.') &&\n-                (fileName[1] == L'\\0')) {\n-                continue;\n-            }\n-            if ((flags & PR_SKIP_DOT_DOT) && (fileName[0] == L'.') &&\n-                (fileName[1] == L'.') && (fileName[2] == L'\\0')) {\n-                continue;\n-            }\n-            if ((flags & PR_SKIP_HIDDEN) && FileIsHidden(d)) {\n-                continue;\n-            }\n-            return fileName;\n-        }\n-        err = GetLastError();\n-        PR_ASSERT(NO_ERROR != err);\n-        _PR_MD_MAP_READDIR_ERROR(err);\n-        return NULL;\n-    }\n-    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+PRUnichar* _PR_MD_READ_DIR_UTF16(_MDDirUTF16* d, PRIntn flags) {\n+  PRInt32 err;\n+  BOOL rv;\n+  PRUnichar* fileName;\n+\n+  if (d) {\n+    while (1) {\n+      if (d->firstEntry) {\n+        d->firstEntry = PR_FALSE;\n+        rv = 1;\n+      } else {\n+        rv = findNextFileW(d->d_hdl, &(d->d_entry));\n+      }\n+      if (rv == 0) {\n+        break;\n+      }\n+      fileName = GetFileFromDIR(d);\n+      if ((flags & PR_SKIP_DOT) && (fileName[0] == L'.') &&\n+          (fileName[1] == L'\\0')) {\n+        continue;\n+      }\n+      if ((flags & PR_SKIP_DOT_DOT) && (fileName[0] == L'.') &&\n+          (fileName[1] == L'.') && (fileName[2] == L'\\0')) {\n+        continue;\n+      }\n+      if ((flags & PR_SKIP_HIDDEN) && FileIsHidden(d)) {\n+        continue;\n+      }\n+      return fileName;\n+    }\n+    err = GetLastError();\n+    PR_ASSERT(NO_ERROR != err);\n+    _PR_MD_MAP_READDIR_ERROR(err);\n     return NULL;\n+  }\n+  PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  return NULL;\n }\n \n-PRInt32\n-_PR_MD_CLOSE_DIR_UTF16(_MDDirUTF16* d)\n-{\n-    if (d) {\n-        if (FindClose(d->d_hdl)) {\n-            d->magic = (PRUint32)-1;\n-            return 0;\n-        } else {\n-            _PR_MD_MAP_CLOSEDIR_ERROR(GetLastError());\n-            return -1;\n-        }\n+PRInt32 _PR_MD_CLOSE_DIR_UTF16(_MDDirUTF16* d) {\n+  if (d) {\n+    if (FindClose(d->d_hdl)) {\n+      d->magic = (PRUint32)-1;\n+      return 0;\n+    } else {\n+      _PR_MD_MAP_CLOSEDIR_ERROR(GetLastError());\n+      return -1;\n     }\n-    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-    return -1;\n+  }\n+  PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  return -1;\n }\n \n-#define _PR_IS_W_SLASH(ch) ((ch) == L'/' || (ch) == L'\\\\')\n+#  define _PR_IS_W_SLASH(ch) ((ch) == L'/' || (ch) == L'\\\\')\n \n /*\n  * IsRootDirectoryW --\n@@ -1185,172 +1103,168 @@ _PR_MD_CLOSE_DIR_UTF16(_MDDirUTF16* d)\n  *    of a UNC (Universal Naming Convention) name.\n  */\n \n-static PRBool\n-IsRootDirectoryW(PRUnichar* fn, size_t buflen)\n-{\n-    PRUnichar* p;\n-    PRBool slashAdded = PR_FALSE;\n-    PRBool rv = PR_FALSE;\n-\n-    if (_PR_IS_W_SLASH(fn[0]) && fn[1] == L'\\0') {\n-        return PR_TRUE;\n-    }\n-\n-    if (iswalpha(fn[0]) && fn[1] == L':' && _PR_IS_W_SLASH(fn[2]) &&\n-        fn[3] == L'\\0') {\n-        rv = getDriveTypeW(fn) > 1 ? PR_TRUE : PR_FALSE;\n-        return rv;\n-    }\n-\n-    /* The UNC root directory */\n+static PRBool IsRootDirectoryW(PRUnichar* fn, size_t buflen) {\n+  PRUnichar* p;\n+  PRBool slashAdded = PR_FALSE;\n+  PRBool rv = PR_FALSE;\n \n-    if (_PR_IS_W_SLASH(fn[0]) && _PR_IS_W_SLASH(fn[1])) {\n-        /* The 'server' part should have at least one character. */\n-        p = &fn[2];\n-        if (*p == L'\\0' || _PR_IS_W_SLASH(*p)) {\n-            return PR_FALSE;\n-        }\n+  if (_PR_IS_W_SLASH(fn[0]) && fn[1] == L'\\0') {\n+    return PR_TRUE;\n+  }\n \n-        /* look for the next slash */\n-        do {\n-            p++;\n-        } while (*p != L'\\0' && !_PR_IS_W_SLASH(*p));\n-        if (*p == L'\\0') {\n-            return PR_FALSE;\n-        }\n-\n-        /* The 'share' part should have at least one character. */\n-        p++;\n-        if (*p == L'\\0' || _PR_IS_W_SLASH(*p)) {\n-            return PR_FALSE;\n-        }\n-\n-        /* look for the final slash */\n-        do {\n-            p++;\n-        } while (*p != L'\\0' && !_PR_IS_W_SLASH(*p));\n-        if (_PR_IS_W_SLASH(*p) && p[1] != L'\\0') {\n-            return PR_FALSE;\n-        }\n-        if (*p == L'\\0') {\n-            /*\n-             * GetDriveType() doesn't work correctly if the\n-             * path is of the form \\\\server\\share, so we add\n-             * a final slash temporarily.\n-             */\n-            if ((p + 1) < (fn + buflen)) {\n-                *p++ = L'\\\\';\n-                *p = L'\\0';\n-                slashAdded = PR_TRUE;\n-            } else {\n-                return PR_FALSE; /* name too long */\n-            }\n-        }\n-        rv = getDriveTypeW(fn) > 1 ? PR_TRUE : PR_FALSE;\n-        /* restore the 'fn' buffer */\n-        if (slashAdded) {\n-            *--p = L'\\0';\n-        }\n-    }\n+  if (iswalpha(fn[0]) && fn[1] == L':' && _PR_IS_W_SLASH(fn[2]) &&\n+      fn[3] == L'\\0') {\n+    rv = getDriveTypeW(fn) > 1 ? PR_TRUE : PR_FALSE;\n     return rv;\n+  }\n+\n+  /* The UNC root directory */\n+\n+  if (_PR_IS_W_SLASH(fn[0]) && _PR_IS_W_SLASH(fn[1])) {\n+    /* The 'server' part should have at least one character. */\n+    p = &fn[2];\n+    if (*p == L'\\0' || _PR_IS_W_SLASH(*p)) {\n+      return PR_FALSE;\n+    }\n+\n+    /* look for the next slash */\n+    do {\n+      p++;\n+    } while (*p != L'\\0' && !_PR_IS_W_SLASH(*p));\n+    if (*p == L'\\0') {\n+      return PR_FALSE;\n+    }\n+\n+    /* The 'share' part should have at least one character. */\n+    p++;\n+    if (*p == L'\\0' || _PR_IS_W_SLASH(*p)) {\n+      return PR_FALSE;\n+    }\n+\n+    /* look for the final slash */\n+    do {\n+      p++;\n+    } while (*p != L'\\0' && !_PR_IS_W_SLASH(*p));\n+    if (_PR_IS_W_SLASH(*p) && p[1] != L'\\0') {\n+      return PR_FALSE;\n+    }\n+    if (*p == L'\\0') {\n+      /*\n+       * GetDriveType() doesn't work correctly if the\n+       * path is of the form \\\\server\\share, so we add\n+       * a final slash temporarily.\n+       */\n+      if ((p + 1) < (fn + buflen)) {\n+        *p++ = L'\\\\';\n+        *p = L'\\0';\n+        slashAdded = PR_TRUE;\n+      } else {\n+        return PR_FALSE; /* name too long */\n+      }\n+    }\n+    rv = getDriveTypeW(fn) > 1 ? PR_TRUE : PR_FALSE;\n+    /* restore the 'fn' buffer */\n+    if (slashAdded) {\n+      *--p = L'\\0';\n+    }\n+  }\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_GETFILEINFO64_UTF16(const PRUnichar* fn, PRFileInfo64* info)\n-{\n-    HANDLE hFindFile;\n-    WIN32_FIND_DATAW findFileData;\n-    PRUnichar pathbuf[MAX_PATH + 1];\n+PRInt32 _PR_MD_GETFILEINFO64_UTF16(const PRUnichar* fn, PRFileInfo64* info) {\n+  HANDLE hFindFile;\n+  WIN32_FIND_DATAW findFileData;\n+  PRUnichar pathbuf[MAX_PATH + 1];\n \n-    if (NULL == fn || L'\\0' == *fn) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return -1;\n-    }\n+  if (NULL == fn || L'\\0' == *fn) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return -1;\n+  }\n+\n+  /*\n+   * FindFirstFile() expands wildcard characters.  So\n+   * we make sure the pathname contains no wildcard.\n+   */\n+  if (NULL != wcspbrk(fn, L\"?*\")) {\n+    PR_SetError(PR_FILE_NOT_FOUND_ERROR, 0);\n+    return -1;\n+  }\n+\n+  hFindFile = findFirstFileW(fn, &findFileData);\n+  if (INVALID_HANDLE_VALUE == hFindFile) {\n+    DWORD len;\n+    PRUnichar* filePart;\n \n     /*\n-     * FindFirstFile() expands wildcard characters.  So\n-     * we make sure the pathname contains no wildcard.\n+     * FindFirstFile() does not work correctly on root directories.\n+     * It also doesn't work correctly on a pathname that ends in a\n+     * slash.  So we first check to see if the pathname specifies a\n+     * root directory.  If not, and if the pathname ends in a slash,\n+     * we remove the final slash and try again.\n      */\n-    if (NULL != wcspbrk(fn, L\"?*\")) {\n-        PR_SetError(PR_FILE_NOT_FOUND_ERROR, 0);\n-        return -1;\n-    }\n \n-    hFindFile = findFirstFileW(fn, &findFileData);\n-    if (INVALID_HANDLE_VALUE == hFindFile) {\n-        DWORD len;\n-        PRUnichar* filePart;\n-\n-        /*\n-         * FindFirstFile() does not work correctly on root directories.\n-         * It also doesn't work correctly on a pathname that ends in a\n-         * slash.  So we first check to see if the pathname specifies a\n-         * root directory.  If not, and if the pathname ends in a slash,\n-         * we remove the final slash and try again.\n-         */\n-\n-        /*\n-         * If the pathname does not contain ., \\, and /, it cannot be\n-         * a root directory or a pathname that ends in a slash.\n-         */\n-        if (NULL == wcspbrk(fn, L\".\\\\/\")) {\n-            _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n-            return -1;\n-        }\n-        len = getFullPathNameW(fn, sizeof(pathbuf) / sizeof(pathbuf[0]), pathbuf,\n-                               &filePart);\n-        if (0 == len) {\n-            _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n-            return -1;\n-        }\n-        if (len > sizeof(pathbuf) / sizeof(pathbuf[0])) {\n-            PR_SetError(PR_NAME_TOO_LONG_ERROR, 0);\n-            return -1;\n-        }\n-        if (IsRootDirectoryW(pathbuf, sizeof(pathbuf) / sizeof(pathbuf[0]))) {\n-            info->type = PR_FILE_DIRECTORY;\n-            info->size = 0;\n-            /*\n-             * These timestamps don't make sense for root directories.\n-             */\n-            info->modifyTime = 0;\n-            info->creationTime = 0;\n-            return 0;\n-        }\n-        if (!_PR_IS_W_SLASH(pathbuf[len - 1])) {\n-            _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n-            return -1;\n-        } else {\n-            pathbuf[len - 1] = L'\\0';\n-            hFindFile = findFirstFileW(pathbuf, &findFileData);\n-            if (INVALID_HANDLE_VALUE == hFindFile) {\n-                _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n-                return -1;\n-            }\n-        }\n+    /*\n+     * If the pathname does not contain ., \\, and /, it cannot be\n+     * a root directory or a pathname that ends in a slash.\n+     */\n+    if (NULL == wcspbrk(fn, L\".\\\\/\")) {\n+      _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n+      return -1;\n+    }\n+    len = getFullPathNameW(fn, sizeof(pathbuf) / sizeof(pathbuf[0]), pathbuf,\n+                           &filePart);\n+    if (0 == len) {\n+      _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n+      return -1;\n+    }\n+    if (len > sizeof(pathbuf) / sizeof(pathbuf[0])) {\n+      PR_SetError(PR_NAME_TOO_LONG_ERROR, 0);\n+      return -1;\n+    }\n+    if (IsRootDirectoryW(pathbuf, sizeof(pathbuf) / sizeof(pathbuf[0]))) {\n+      info->type = PR_FILE_DIRECTORY;\n+      info->size = 0;\n+      /*\n+       * These timestamps don't make sense for root directories.\n+       */\n+      info->modifyTime = 0;\n+      info->creationTime = 0;\n+      return 0;\n+    }\n+    if (!_PR_IS_W_SLASH(pathbuf[len - 1])) {\n+      _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n+      return -1;\n+    } else {\n+      pathbuf[len - 1] = L'\\0';\n+      hFindFile = findFirstFileW(pathbuf, &findFileData);\n+      if (INVALID_HANDLE_VALUE == hFindFile) {\n+        _PR_MD_MAP_OPENDIR_ERROR(GetLastError());\n+        return -1;\n+      }\n     }\n+  }\n \n-    FindClose(hFindFile);\n+  FindClose(hFindFile);\n \n-    if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n-        info->type = PR_FILE_DIRECTORY;\n-    } else {\n-        info->type = PR_FILE_FILE;\n-    }\n+  if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n+    info->type = PR_FILE_DIRECTORY;\n+  } else {\n+    info->type = PR_FILE_FILE;\n+  }\n \n-    info->size = findFileData.nFileSizeHigh;\n-    info->size = (info->size << 32) + findFileData.nFileSizeLow;\n+  info->size = findFileData.nFileSizeHigh;\n+  info->size = (info->size << 32) + findFileData.nFileSizeLow;\n \n-    _PR_FileTimeToPRTime(&findFileData.ftLastWriteTime, &info->modifyTime);\n+  _PR_FileTimeToPRTime(&findFileData.ftLastWriteTime, &info->modifyTime);\n \n-    if (0 == findFileData.ftCreationTime.dwLowDateTime &&\n-        0 == findFileData.ftCreationTime.dwHighDateTime) {\n-        info->creationTime = info->modifyTime;\n-    } else {\n-        _PR_FileTimeToPRTime(&findFileData.ftCreationTime, &info->creationTime);\n-    }\n+  if (0 == findFileData.ftCreationTime.dwLowDateTime &&\n+      0 == findFileData.ftCreationTime.dwHighDateTime) {\n+    info->creationTime = info->modifyTime;\n+  } else {\n+    _PR_FileTimeToPRTime(&findFileData.ftCreationTime, &info->creationTime);\n+  }\n \n-    return 0;\n+  return 0;\n }\n /* ================ end of UTF16 Interfaces ================================ */\n #endif /* MOZ_UNICODE */\ndiff --git a/nspr/pr/src/md/windows/w95sock.c b/nspr/pr/src/md/windows/w95sock.c\nindex 64c4958..bf7fda7 100644\n--- a/nspr/pr/src/md/windows/w95sock.c\n+++ b/nspr/pr/src/md/windows/w95sock.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,7 +8,7 @@\n  */\n \n #if defined(_WIN64)\n-#include <winsock2.h>\n+#  include <winsock2.h>\n #endif\n #include \"primpl.h\"\n \n@@ -22,277 +23,251 @@ static PRInt32 socket_io_wait(PROsfd osfd, PRInt32 fd_type,\n \n static PRBool socketFixInet6RcvBuf = PR_FALSE;\n \n-void\n-_PR_MD_InitSockets(void)\n-{\n-    OSVERSIONINFO osvi;\n+void _PR_MD_InitSockets(void) {\n+  OSVERSIONINFO osvi;\n \n-    memset(&osvi, 0, sizeof(osvi));\n-    osvi.dwOSVersionInfoSize = sizeof(osvi);\n-    GetVersionEx(&osvi);\n+  memset(&osvi, 0, sizeof(osvi));\n+  osvi.dwOSVersionInfoSize = sizeof(osvi);\n+  GetVersionEx(&osvi);\n \n-    if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) {\n-        /* if Windows XP (32-bit) */\n-        socketFixInet6RcvBuf = PR_TRUE;\n-    }\n+  if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) {\n+    /* if Windows XP (32-bit) */\n+    socketFixInet6RcvBuf = PR_TRUE;\n+  }\n }\n \n-void\n-_PR_MD_CleanupSockets(void)\n-{\n-    socketFixInet6RcvBuf = PR_FALSE;\n-}\n+void _PR_MD_CleanupSockets(void) { socketFixInet6RcvBuf = PR_FALSE; }\n \n-PROsfd\n-_PR_MD_SOCKET(int af, int type, int flags)\n-{\n-    SOCKET sock;\n-    u_long one = 1;\n+PROsfd _PR_MD_SOCKET(int af, int type, int flags) {\n+  SOCKET sock;\n+  u_long one = 1;\n \n-    sock = socket(af, type, flags);\n+  sock = socket(af, type, flags);\n \n-    if (sock == INVALID_SOCKET) {\n-        _PR_MD_MAP_SOCKET_ERROR(WSAGetLastError());\n-        return (PROsfd)sock;\n-    }\n+  if (sock == INVALID_SOCKET) {\n+    _PR_MD_MAP_SOCKET_ERROR(WSAGetLastError());\n+    return (PROsfd)sock;\n+  }\n+\n+  /*\n+  ** Make the socket Non-Blocking\n+  */\n+  if (ioctlsocket(sock, FIONBIO, &one) != 0) {\n+    PR_SetError(PR_UNKNOWN_ERROR, WSAGetLastError());\n+    closesocket(sock);\n+    return -1;\n+  }\n \n-    /*\n-    ** Make the socket Non-Blocking\n-    */\n-    if (ioctlsocket(sock, FIONBIO, &one) != 0) {\n-        PR_SetError(PR_UNKNOWN_ERROR, WSAGetLastError());\n-        closesocket(sock);\n-        return -1;\n-    }\n+  if (af == AF_INET6 && socketFixInet6RcvBuf) {\n+    int bufsize;\n+    int len = sizeof(bufsize);\n+    int rv;\n \n-    if (af == AF_INET6 && socketFixInet6RcvBuf) {\n-        int bufsize;\n-        int len = sizeof(bufsize);\n-        int rv;\n-\n-        /* Windows XP 32-bit returns an error on getpeername() for AF_INET6\n-         * sockets if the receive buffer size is greater than 65535 before\n-         * the connection is initiated. The default receive buffer size may\n-         * be 128000 so fix it here to always be <= 65535. See bug 513659\n-         * and IBM DB2 support technote \"Receive/Send IPv6 Socket Size\n-         * Problem in Windows XP SP2 & SP3\".\n-         */\n-        rv = getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char*)&bufsize, &len);\n-        if (rv == 0 && bufsize > 65535) {\n-            bufsize = 65535;\n-            setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char*)&bufsize, len);\n-        }\n+    /* Windows XP 32-bit returns an error on getpeername() for AF_INET6\n+     * sockets if the receive buffer size is greater than 65535 before\n+     * the connection is initiated. The default receive buffer size may\n+     * be 128000 so fix it here to always be <= 65535. See bug 513659\n+     * and IBM DB2 support technote \"Receive/Send IPv6 Socket Size\n+     * Problem in Windows XP SP2 & SP3\".\n+     */\n+    rv = getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char*)&bufsize, &len);\n+    if (rv == 0 && bufsize > 65535) {\n+      bufsize = 65535;\n+      setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char*)&bufsize, len);\n     }\n+  }\n \n-    return (PROsfd)sock;\n+  return (PROsfd)sock;\n }\n \n /*\n ** _MD_CloseSocket() -- Close a socket\n **\n */\n-PRInt32\n-_MD_CloseSocket(PROsfd osfd)\n-{\n-    PRInt32 rv;\n-\n-    rv = closesocket((SOCKET)osfd);\n-    if (rv < 0) {\n-        _PR_MD_MAP_CLOSE_ERROR(WSAGetLastError());\n-    }\n+PRInt32 _MD_CloseSocket(PROsfd osfd) {\n+  PRInt32 rv;\n+\n+  rv = closesocket((SOCKET)osfd);\n+  if (rv < 0) {\n+    _PR_MD_MAP_CLOSE_ERROR(WSAGetLastError());\n+  }\n \n-    return rv;\n+  return rv;\n }\n \n-PRInt32\n-_MD_SocketAvailable(PRFileDesc* fd)\n-{\n-    u_long result;\n+PRInt32 _MD_SocketAvailable(PRFileDesc* fd) {\n+  PRInt32 result;\n \n-    if (ioctlsocket(fd->secret->md.osfd, FIONREAD, &result) < 0) {\n-        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, WSAGetLastError());\n-        return -1;\n-    }\n-    return result;\n+  if (ioctlsocket(fd->secret->md.osfd, FIONREAD, &result) < 0) {\n+    PR_SetError(PR_BAD_DESCRIPTOR_ERROR, WSAGetLastError());\n+    return -1;\n+  }\n+  return result;\n }\n \n-PROsfd\n-_MD_Accept(PRFileDesc* fd, PRNetAddr* raddr, PRUint32* rlen,\n-           PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    SOCKET sock;\n-    PRInt32 rv, err;\n-\n-    while ((sock = accept(osfd, (struct sockaddr*)raddr, rlen)) == -1) {\n-        err = WSAGetLastError();\n-        if ((err == WSAEWOULDBLOCK) && (!fd->secret->nonblocking)) {\n-            if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) {\n-                break;\n-            }\n-        } else {\n-            _PR_MD_MAP_ACCEPT_ERROR(err);\n-            break;\n-        }\n+PROsfd _MD_Accept(PRFileDesc* fd, PRNetAddr* raddr, PRUint32* rlen,\n+                  PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  SOCKET sock;\n+  PRInt32 rv, err;\n+\n+  while ((sock = accept(osfd, (struct sockaddr*)raddr, rlen)) == -1) {\n+    err = WSAGetLastError();\n+    if ((err == WSAEWOULDBLOCK) && (!fd->secret->nonblocking)) {\n+      if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) {\n+        break;\n+      }\n+    } else {\n+      _PR_MD_MAP_ACCEPT_ERROR(err);\n+      break;\n     }\n-    return (sock);\n+  }\n+  return (sock);\n } /* end _MD_accept() */\n \n-PRInt32\n-_PR_MD_CONNECT(PRFileDesc* fd, const PRNetAddr* addr, PRUint32 addrlen,\n-               PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv;\n-    int err;\n-\n-    if ((rv = connect(osfd, (struct sockaddr*)addr, addrlen)) == -1) {\n-        err = WSAGetLastError();\n-        if ((!fd->secret->nonblocking) && (err == WSAEWOULDBLOCK)) {\n-            rv = socket_io_wait(osfd, CONNECT_FD, timeout);\n-            if (rv < 0) {\n-                return (-1);\n-            } else {\n-                PR_ASSERT(rv > 0);\n-                /* it's connected */\n-                return (0);\n-            }\n-        }\n-        _PR_MD_MAP_CONNECT_ERROR(err);\n+PRInt32 _PR_MD_CONNECT(PRFileDesc* fd, const PRNetAddr* addr, PRUint32 addrlen,\n+                       PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv;\n+  int err;\n+\n+  if ((rv = connect(osfd, (struct sockaddr*)addr, addrlen)) == -1) {\n+    err = WSAGetLastError();\n+    if ((!fd->secret->nonblocking) && (err == WSAEWOULDBLOCK)) {\n+      rv = socket_io_wait(osfd, CONNECT_FD, timeout);\n+      if (rv < 0) {\n+        return (-1);\n+      } else {\n+        PR_ASSERT(rv > 0);\n+        /* it's connected */\n+        return (0);\n+      }\n     }\n-    return rv;\n+    _PR_MD_MAP_CONNECT_ERROR(err);\n+  }\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_BIND(PRFileDesc* fd, const PRNetAddr* addr, PRUint32 addrlen)\n-{\n-    PRInt32 rv;\n+PRInt32 _PR_MD_BIND(PRFileDesc* fd, const PRNetAddr* addr, PRUint32 addrlen) {\n+  PRInt32 rv;\n \n-    rv =\n-        bind(fd->secret->md.osfd, (const struct sockaddr*)&(addr->inet), addrlen);\n+  rv =\n+      bind(fd->secret->md.osfd, (const struct sockaddr*)&(addr->inet), addrlen);\n \n-    if (rv == SOCKET_ERROR) {\n-        _PR_MD_MAP_BIND_ERROR(WSAGetLastError());\n-        return -1;\n-    }\n+  if (rv == SOCKET_ERROR) {\n+    _PR_MD_MAP_BIND_ERROR(WSAGetLastError());\n+    return -1;\n+  }\n \n-    return 0;\n+  return 0;\n }\n \n-PRInt32\n-_PR_MD_LISTEN(PRFileDesc* fd, PRIntn backlog)\n-{\n-    PRInt32 rv;\n+PRInt32 _PR_MD_LISTEN(PRFileDesc* fd, PRIntn backlog) {\n+  PRInt32 rv;\n \n-    rv = listen(fd->secret->md.osfd, backlog);\n+  rv = listen(fd->secret->md.osfd, backlog);\n \n-    if (rv == SOCKET_ERROR) {\n-        _PR_MD_MAP_DEFAULT_ERROR(WSAGetLastError());\n-        return -1;\n-    }\n+  if (rv == SOCKET_ERROR) {\n+    _PR_MD_MAP_DEFAULT_ERROR(WSAGetLastError());\n+    return -1;\n+  }\n \n-    return 0;\n+  return 0;\n }\n \n-PRInt32\n-_PR_MD_RECV(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n-            PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    int osflags;\n-\n-    if (0 == flags) {\n-        osflags = 0;\n+PRInt32 _PR_MD_RECV(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n+                    PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  int osflags;\n+\n+  if (0 == flags) {\n+    osflags = 0;\n+  } else {\n+    PR_ASSERT(PR_MSG_PEEK == flags);\n+    osflags = MSG_PEEK;\n+  }\n+  while ((rv = recv(osfd, buf, amount, osflags)) == -1) {\n+    if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n+        (!fd->secret->nonblocking)) {\n+      rv = socket_io_wait(osfd, READ_FD, timeout);\n+      if (rv < 0) {\n+        return -1;\n+      }\n     } else {\n-        PR_ASSERT(PR_MSG_PEEK == flags);\n-        osflags = MSG_PEEK;\n+      _PR_MD_MAP_RECV_ERROR(err);\n+      break;\n     }\n-    while ((rv = recv(osfd, buf, amount, osflags)) == -1) {\n-        if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n-            (!fd->secret->nonblocking)) {\n-            rv = socket_io_wait(osfd, READ_FD, timeout);\n-            if (rv < 0) {\n-                return -1;\n-            }\n-        } else {\n-            _PR_MD_MAP_RECV_ERROR(err);\n-            break;\n-        }\n-    } /* end while() */\n-    return (rv);\n+  } /* end while() */\n+  return (rv);\n }\n \n-PRInt32\n-_PR_MD_SEND(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-            PRIntn flags, PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    PRInt32 bytesSent = 0;\n-\n-    while (bytesSent < amount) {\n-        while ((rv = send(osfd, buf, amount, 0)) == -1) {\n-            if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n-                (!fd->secret->nonblocking)) {\n-                rv = socket_io_wait(osfd, WRITE_FD, timeout);\n-                if (rv < 0) {\n-                    return -1;\n-                }\n-            } else {\n-                _PR_MD_MAP_SEND_ERROR(err);\n-                return -1;\n-            }\n-        }\n-        bytesSent += rv;\n-        if (fd->secret->nonblocking) {\n-            break;\n-        }\n-        if (bytesSent < amount) {\n-            rv = socket_io_wait(osfd, WRITE_FD, timeout);\n-            if (rv < 0) {\n-                return -1;\n-            }\n+PRInt32 _PR_MD_SEND(PRFileDesc* fd, const void* buf, PRInt32 amount,\n+                    PRIntn flags, PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  PRInt32 bytesSent = 0;\n+\n+  while (bytesSent < amount) {\n+    while ((rv = send(osfd, buf, amount, 0)) == -1) {\n+      if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n+          (!fd->secret->nonblocking)) {\n+        rv = socket_io_wait(osfd, WRITE_FD, timeout);\n+        if (rv < 0) {\n+          return -1;\n         }\n+      } else {\n+        _PR_MD_MAP_SEND_ERROR(err);\n+        return -1;\n+      }\n+    }\n+    bytesSent += rv;\n+    if (fd->secret->nonblocking) {\n+      break;\n     }\n-    return bytesSent;\n+    if (bytesSent < amount) {\n+      rv = socket_io_wait(osfd, WRITE_FD, timeout);\n+      if (rv < 0) {\n+        return -1;\n+      }\n+    }\n+  }\n+  return bytesSent;\n }\n \n-PRInt32\n-_PR_MD_SENDTO(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-              PRIntn flags, const PRNetAddr* addr, PRUint32 addrlen,\n-              PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    PRInt32 bytesSent = 0;\n-\n-    do {\n-        while ((rv = sendto(osfd, buf, amount, 0, (struct sockaddr*)addr,\n-                            addrlen)) == -1) {\n-            if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n-                (!fd->secret->nonblocking)) {\n-                rv = socket_io_wait(osfd, WRITE_FD, timeout);\n-                if (rv < 0) {\n-                    return -1;\n-                }\n-            } else {\n-                _PR_MD_MAP_SENDTO_ERROR(err);\n-                return -1;\n-            }\n-        }\n-        bytesSent += rv;\n-        if (fd->secret->nonblocking) {\n-            break;\n-        }\n-        if (bytesSent < amount) {\n-            rv = socket_io_wait(osfd, WRITE_FD, timeout);\n-            if (rv < 0) {\n-                return -1;\n-            }\n+PRInt32 _PR_MD_SENDTO(PRFileDesc* fd, const void* buf, PRInt32 amount,\n+                      PRIntn flags, const PRNetAddr* addr, PRUint32 addrlen,\n+                      PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  PRInt32 bytesSent = 0;\n+\n+  do {\n+    while ((rv = sendto(osfd, buf, amount, 0, (struct sockaddr*)addr,\n+                        addrlen)) == -1) {\n+      if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n+          (!fd->secret->nonblocking)) {\n+        rv = socket_io_wait(osfd, WRITE_FD, timeout);\n+        if (rv < 0) {\n+          return -1;\n         }\n-    } while (bytesSent < amount);\n-    return bytesSent;\n+      } else {\n+        _PR_MD_MAP_SENDTO_ERROR(err);\n+        return -1;\n+      }\n+    }\n+    bytesSent += rv;\n+    if (fd->secret->nonblocking) {\n+      break;\n+    }\n+    if (bytesSent < amount) {\n+      rv = socket_io_wait(osfd, WRITE_FD, timeout);\n+      if (rv < 0) {\n+        return -1;\n+      }\n+    }\n+  } while (bytesSent < amount);\n+  return bytesSent;\n }\n \n #if defined(_WIN64)\n@@ -304,312 +279,291 @@ typedef BOOL(PASCAL FAR* _pr_win_connectex_ptr)(\n     _In_ DWORD dwSendDataLength, _Out_ LPDWORD lpdwBytesSent,\n     _Inout_ LPOVERLAPPED lpOverlapped);\n \n-#ifndef WSAID_CONNECTEX\n-#define WSAID_CONNECTEX \\\n-    { 0x25a207b9,       \\\n-      0xddf3,           \\\n-      0x4660,           \\\n-      { 0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e } }\n-#endif\n-#ifndef SIO_GET_EXTENSION_FUNCTION_POINTER\n-#define SIO_GET_EXTENSION_FUNCTION_POINTER 0xC8000006\n-#endif\n-#ifndef TCP_FASTOPEN\n-#define TCP_FASTOPEN 15\n-#endif\n-\n-#ifndef SO_UPDATE_CONNECT_CONTEXT\n-#define SO_UPDATE_CONNECT_CONTEXT 0x7010\n-#endif\n+#  ifndef WSAID_CONNECTEX\n+#    define WSAID_CONNECTEX                              \\\n+      {                                                  \\\n+        0x25a207b9, 0xddf3, 0x4660, {                    \\\n+          0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e \\\n+        }                                                \\\n+      }\n+#  endif\n+#  ifndef SIO_GET_EXTENSION_FUNCTION_POINTER\n+#    define SIO_GET_EXTENSION_FUNCTION_POINTER 0xC8000006\n+#  endif\n+#  ifndef TCP_FASTOPEN\n+#    define TCP_FASTOPEN 15\n+#  endif\n+\n+#  ifndef SO_UPDATE_CONNECT_CONTEXT\n+#    define SO_UPDATE_CONNECT_CONTEXT 0x7010\n+#  endif\n \n static _pr_win_connectex_ptr _pr_win_connectex = NULL;\n \n-static PRStatus PR_CALLBACK\n-_pr_set_connectex(void)\n-{\n-    _pr_win_connectex = NULL;\n-    SOCKET sock;\n-    DWORD dwBytes;\n-    int rc;\n-\n-    /* Dummy socket needed for WSAIoctl */\n-    sock = socket(AF_INET, SOCK_STREAM, 0);\n-    if (sock == INVALID_SOCKET) {\n-        return PR_SUCCESS;\n-    }\n+static PRStatus PR_CALLBACK _pr_set_connectex(void) {\n+  _pr_win_connectex = NULL;\n+  SOCKET sock;\n+  PRInt32 dwBytes;\n+  int rc;\n \n-    GUID guid = WSAID_CONNECTEX;\n-    rc = WSAIoctl(sock, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid, sizeof(guid),\n-                  &_pr_win_connectex, sizeof(_pr_win_connectex), &dwBytes, NULL,\n-                  NULL);\n-    if (rc != 0) {\n-        _pr_win_connectex = NULL;\n-        return PR_SUCCESS;\n-    }\n-\n-    rc = closesocket(sock);\n+  /* Dummy socket needed for WSAIoctl */\n+  sock = socket(AF_INET, SOCK_STREAM, 0);\n+  if (sock == INVALID_SOCKET) {\n     return PR_SUCCESS;\n-}\n+  }\n \n-PRInt32\n-_PR_MD_TCPSENDTO(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-                 PRIntn flags, const PRNetAddr* addr, PRUint32 addrlen,\n-                 PRIntervalTime timeout)\n-{\n-    if (!_fd_waiting_for_overlapped_done_lock) {\n-        PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-\n-    if (PR_CallOnce(&_pr_has_connectex_once, _pr_set_connectex) != PR_SUCCESS) {\n-        PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-\n-    if (_pr_win_connectex == NULL) {\n-        PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  GUID guid = WSAID_CONNECTEX;\n+  rc = WSAIoctl(sock, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid, sizeof(guid),\n+                &_pr_win_connectex, sizeof(_pr_win_connectex), &dwBytes, NULL,\n+                NULL);\n+  if (rc != 0) {\n+    _pr_win_connectex = NULL;\n+    return PR_SUCCESS;\n+  }\n \n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-    PRInt32 bytesSent = 0;\n-    DWORD rvSent;\n+  rc = closesocket(sock);\n+  return PR_SUCCESS;\n+}\n \n-    BOOL option = 1;\n-    rv = setsockopt((SOCKET)osfd, IPPROTO_TCP, TCP_FASTOPEN, (char*)&option,\n-                    sizeof(option));\n-    if (rv != 0) {\n-        err = WSAGetLastError();\n-        PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-               (\"_PR_MD_TCPSENDTO error set opt TCP_FASTOPEN failed %d\\n\", err));\n-        if (err == WSAENOPROTOOPT) {\n-            PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-        } else {\n-            _PR_MD_MAP_SETSOCKOPT_ERROR(err);\n-        }\n-        return -1;\n+PRInt32 _PR_MD_TCPSENDTO(PRFileDesc* fd, const void* buf, PRInt32 amount,\n+                         PRIntn flags, const PRNetAddr* addr, PRUint32 addrlen,\n+                         PRIntervalTime timeout) {\n+  if (!_fd_waiting_for_overlapped_done_lock) {\n+    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+\n+  if (PR_CallOnce(&_pr_has_connectex_once, _pr_set_connectex) != PR_SUCCESS) {\n+    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+\n+  if (_pr_win_connectex == NULL) {\n+    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+  PRInt32 bytesSent = 0;\n+  DWORD rvSent;\n+\n+  BOOL option = 1;\n+  rv = setsockopt((SOCKET)osfd, IPPROTO_TCP, TCP_FASTOPEN, (char*)&option,\n+                  sizeof(option));\n+  if (rv != 0) {\n+    err = WSAGetLastError();\n+    PR_LOG(_pr_io_lm, PR_LOG_MIN,\n+           (\"_PR_MD_TCPSENDTO error set opt TCP_FASTOPEN failed %d\\n\", err));\n+    if (err == WSAENOPROTOOPT) {\n+      PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+    } else {\n+      _PR_MD_MAP_SETSOCKOPT_ERROR(err);\n     }\n-\n-    /* ConnectEx requires the socket to be initially bound. We will use\n-     * INADDR_ANY. */\n-    PRNetAddr bindAddr;\n-    memset(&bindAddr, 0, sizeof(bindAddr));\n-    bindAddr.raw.family = addr->raw.family;\n-\n-    rv = bind((SOCKET)osfd, (const struct sockaddr*)&(bindAddr.inet),\n-              PR_NETADDR_SIZE(&bindAddr));\n+    return -1;\n+  }\n+\n+  /* ConnectEx requires the socket to be initially bound. We will use\n+   * INADDR_ANY. */\n+  PRNetAddr bindAddr;\n+  memset(&bindAddr, 0, sizeof(bindAddr));\n+  bindAddr.raw.family = addr->raw.family;\n+\n+  rv = bind((SOCKET)osfd, (const struct sockaddr*)&(bindAddr.inet),\n+            PR_NETADDR_SIZE(&bindAddr));\n+  if (rv != 0) {\n+    err = WSAGetLastError();\n+    PR_LOG(_pr_io_lm, PR_LOG_MIN,\n+           (\"_PR_MD_TCPSENDTO error bind failed %d\\n\", err));\n+    _PR_MD_MAP_SETSOCKOPT_ERROR(err);\n+    return -1;\n+  }\n+\n+  PR_LOG(_pr_io_lm, PR_LOG_MIN,\n+         (\"_PR_MD_TCPSENDTO calling _pr_win_connectex  %d %p\\n\", amount,\n+          (char*)buf));\n+\n+  rvSent = 0;\n+  memset(&fd->secret->ol, 0, sizeof(fd->secret->ol));\n+  /* ConnectEx return TRUE on a success and FALSE on an error. */\n+  if (_pr_win_connectex((SOCKET)osfd, (struct sockaddr*)addr, addrlen, buf,\n+                        amount, &rvSent, &fd->secret->ol) == TRUE) {\n+    /* When ConnectEx is used, all previously set socket options and\n+     * property are not enabled and to enable them\n+     * SO_UPDATE_CONNECT_CONTEXT option need to be set. */\n+    rv = setsockopt((SOCKET)osfd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL,\n+                    0);\n     if (rv != 0) {\n-        err = WSAGetLastError();\n-        PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-               (\"_PR_MD_TCPSENDTO error bind failed %d\\n\", err));\n-        _PR_MD_MAP_SETSOCKOPT_ERROR(err);\n-        return -1;\n+      err = WSAGetLastError();\n+      PR_LOG(_pr_io_lm, PR_LOG_MIN,\n+             (\"_PR_MD_TCPSENDTO setting SO_UPDATE_CONNECT_CONTEXT failed %d\\n\",\n+              err));\n+      _PR_MD_MAP_SETSOCKOPT_ERROR(err);\n+      return -1;\n     }\n-\n+    /* We imitate Linux here. SendTo will return number of bytes send but\n+     * it can not return connection success at the same time, so we return\n+     * number of bytes send and \"connection success\" will be return on the\n+     * connectcontinue. */\n+    fd->secret->alreadyConnected = PR_TRUE;\n+    return rvSent;\n+  } else {\n+    err = WSAGetLastError();\n     PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-           (\"_PR_MD_TCPSENDTO calling _pr_win_connectex  %d %p\\n\", amount,\n-            (char*)buf));\n-\n-    rvSent = 0;\n-    memset(&fd->secret->ol, 0, sizeof(fd->secret->ol));\n-    /* ConnectEx return TRUE on a success and FALSE on an error. */\n-    if (_pr_win_connectex((SOCKET)osfd, (struct sockaddr*)addr, addrlen, buf,\n-                          amount, &rvSent, &fd->secret->ol) == TRUE) {\n-        /* When ConnectEx is used, all previously set socket options and\n-         * property are not enabled and to enable them\n-         * SO_UPDATE_CONNECT_CONTEXT option need to be set. */\n-        rv = setsockopt((SOCKET)osfd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL,\n-                        0);\n-        if (rv != 0) {\n-            err = WSAGetLastError();\n-            PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-                   (\"_PR_MD_TCPSENDTO setting SO_UPDATE_CONNECT_CONTEXT failed %d\\n\",\n-                    err));\n-            _PR_MD_MAP_SETSOCKOPT_ERROR(err);\n-            return -1;\n-        }\n-        /* We imitate Linux here. SendTo will return number of bytes send but\n-         * it can not return connection success at the same time, so we return\n-         * number of bytes send and \"connection success\" will be return on the\n-         * connectcontinue. */\n-        fd->secret->alreadyConnected = PR_TRUE;\n+           (\"_PR_MD_TCPSENDTO error _pr_win_connectex failed %d\\n\", err));\n+    if (err != ERROR_IO_PENDING) {\n+      _PR_MD_MAP_CONNECT_ERROR(err);\n+      return -1;\n+    } else if (fd->secret->nonblocking) {\n+      /* Remember that overlapped structure is set. We will need to get\n+       * the final result of ConnectEx call. */\n+      fd->secret->overlappedActive = PR_TRUE;\n+\n+      /* ConnectEx will copy supplied data to a internal buffer and send\n+       * them during Fast Open or after connect. Therefore we can assumed\n+       * this data already send. */\n+      if (amount > 0) {\n+        return amount;\n+      }\n+\n+      _PR_MD_MAP_CONNECT_ERROR(WSAEWOULDBLOCK);\n+      return -1;\n+    }\n+    // err is ERROR_IO_PENDING and socket is blocking, so query\n+    // GetOverlappedResult.\n+    err = ERROR_IO_INCOMPLETE;\n+    while (err == ERROR_IO_INCOMPLETE) {\n+      rv = socket_io_wait(osfd, WRITE_FD, timeout);\n+      if (rv < 0) {\n+        return -1;\n+      }\n+      rv = GetOverlappedResult((HANDLE)osfd, &fd->secret->ol, &rvSent, FALSE);\n+      if (rv == TRUE) {\n         return rvSent;\n-    } else {\n+      } else {\n         err = WSAGetLastError();\n-        PR_LOG(_pr_io_lm, PR_LOG_MIN,\n-               (\"_PR_MD_TCPSENDTO error _pr_win_connectex failed %d\\n\", err));\n-        if (err != ERROR_IO_PENDING) {\n-            _PR_MD_MAP_CONNECT_ERROR(err);\n-            return -1;\n-        } else if (fd->secret->nonblocking) {\n-            /* Remember that overlapped structure is set. We will need to get\n-             * the final result of ConnectEx call. */\n-            fd->secret->overlappedActive = PR_TRUE;\n-\n-            /* ConnectEx will copy supplied data to a internal buffer and send\n-             * them during Fast Open or after connect. Therefore we can assumed\n-             * this data already send. */\n-            if (amount > 0) {\n-                return amount;\n-            }\n-\n-            _PR_MD_MAP_CONNECT_ERROR(WSAEWOULDBLOCK);\n-            return -1;\n-        }\n-        // err is ERROR_IO_PENDING and socket is blocking, so query\n-        // GetOverlappedResult.\n-        err = ERROR_IO_INCOMPLETE;\n-        while (err == ERROR_IO_INCOMPLETE) {\n-            rv = socket_io_wait(osfd, WRITE_FD, timeout);\n-            if (rv < 0) {\n-                return -1;\n-            }\n-            rv = GetOverlappedResult((HANDLE)osfd, &fd->secret->ol, &rvSent, FALSE);\n-            if (rv == TRUE) {\n-                return rvSent;\n-            } else {\n-                err = WSAGetLastError();\n-                if (err != ERROR_IO_INCOMPLETE) {\n-                    _PR_MD_MAP_CONNECT_ERROR(err);\n-                    return -1;\n-                }\n-            }\n+        if (err != ERROR_IO_INCOMPLETE) {\n+          _PR_MD_MAP_CONNECT_ERROR(err);\n+          return -1;\n         }\n+      }\n     }\n-    return -1;\n+  }\n+  return -1;\n }\n #endif\n \n-PRInt32\n-_PR_MD_RECVFROM(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n-                PRNetAddr* addr, PRUint32* addrlen,\n-                PRIntervalTime timeout)\n-{\n-    PROsfd osfd = fd->secret->md.osfd;\n-    PRInt32 rv, err;\n-\n-    while ((rv = recvfrom(osfd, buf, amount, 0, (struct sockaddr*)addr,\n-                          addrlen)) == -1) {\n-        if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n-            (!fd->secret->nonblocking)) {\n-            rv = socket_io_wait(osfd, READ_FD, timeout);\n-            if (rv < 0) {\n-                return -1;\n-            }\n-        } else {\n-            _PR_MD_MAP_RECVFROM_ERROR(err);\n-            break;\n-        }\n+PRInt32 _PR_MD_RECVFROM(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n+                        PRNetAddr* addr, PRUint32* addrlen,\n+                        PRIntervalTime timeout) {\n+  PROsfd osfd = fd->secret->md.osfd;\n+  PRInt32 rv, err;\n+\n+  while ((rv = recvfrom(osfd, buf, amount, 0, (struct sockaddr*)addr,\n+                        addrlen)) == -1) {\n+    if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) &&\n+        (!fd->secret->nonblocking)) {\n+      rv = socket_io_wait(osfd, READ_FD, timeout);\n+      if (rv < 0) {\n+        return -1;\n+      }\n+    } else {\n+      _PR_MD_MAP_RECVFROM_ERROR(err);\n+      break;\n     }\n-    return (rv);\n+  }\n+  return (rv);\n }\n \n-PRInt32\n-_PR_MD_WRITEV(PRFileDesc* fd, const PRIOVec* iov, PRInt32 iov_size,\n-              PRIntervalTime timeout)\n-{\n-    int index;\n-    int sent = 0;\n-    int rv;\n+PRInt32 _PR_MD_WRITEV(PRFileDesc* fd, const PRIOVec* iov, PRInt32 iov_size,\n+                      PRIntervalTime timeout) {\n+  int index;\n+  int sent = 0;\n+  int rv;\n \n-    for (index = 0; index < iov_size; index++) {\n-        rv = _PR_MD_SEND(fd, iov[index].iov_base, iov[index].iov_len, 0, timeout);\n-        if (rv > 0) {\n-            sent += rv;\n-        }\n-        if (rv != iov[index].iov_len) {\n-            if (rv < 0) {\n-                if (fd->secret->nonblocking &&\n-                    (PR_GetError() == PR_WOULD_BLOCK_ERROR) && (sent > 0)) {\n-                    return sent;\n-                } else {\n-                    return -1;\n-                }\n-            }\n-            /* Only a nonblocking socket can have partial sends */\n-            PR_ASSERT(fd->secret->nonblocking);\n-            return sent;\n+  for (index = 0; index < iov_size; index++) {\n+    rv = _PR_MD_SEND(fd, iov[index].iov_base, iov[index].iov_len, 0, timeout);\n+    if (rv > 0) {\n+      sent += rv;\n+    }\n+    if (rv != iov[index].iov_len) {\n+      if (rv < 0) {\n+        if (fd->secret->nonblocking &&\n+            (PR_GetError() == PR_WOULD_BLOCK_ERROR) && (sent > 0)) {\n+          return sent;\n+        } else {\n+          return -1;\n         }\n+      }\n+      /* Only a nonblocking socket can have partial sends */\n+      PR_ASSERT(fd->secret->nonblocking);\n+      return sent;\n     }\n-    return sent;\n+  }\n+  return sent;\n }\n \n-PRInt32\n-_PR_MD_SHUTDOWN(PRFileDesc* fd, PRIntn how)\n-{\n-    PRInt32 rv;\n+PRInt32 _PR_MD_SHUTDOWN(PRFileDesc* fd, PRIntn how) {\n+  PRInt32 rv;\n \n-    rv = shutdown(fd->secret->md.osfd, how);\n-    if (rv < 0) {\n-        _PR_MD_MAP_SHUTDOWN_ERROR(WSAGetLastError());\n-    }\n-    return rv;\n+  rv = shutdown(fd->secret->md.osfd, how);\n+  if (rv < 0) {\n+    _PR_MD_MAP_SHUTDOWN_ERROR(WSAGetLastError());\n+  }\n+  return rv;\n }\n \n-PRStatus\n-_PR_MD_GETSOCKNAME(PRFileDesc* fd, PRNetAddr* addr, PRUint32* len)\n-{\n-    PRInt32 rv;\n+PRStatus _PR_MD_GETSOCKNAME(PRFileDesc* fd, PRNetAddr* addr, PRUint32* len) {\n+  PRInt32 rv;\n \n-    rv = getsockname((SOCKET)fd->secret->md.osfd, (struct sockaddr*)addr, len);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    } else {\n-        _PR_MD_MAP_GETSOCKNAME_ERROR(WSAGetLastError());\n-        return PR_FAILURE;\n-    }\n+  rv = getsockname((SOCKET)fd->secret->md.osfd, (struct sockaddr*)addr, len);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  } else {\n+    _PR_MD_MAP_GETSOCKNAME_ERROR(WSAGetLastError());\n+    return PR_FAILURE;\n+  }\n }\n \n-PRStatus\n-_PR_MD_GETPEERNAME(PRFileDesc* fd, PRNetAddr* addr, PRUint32* len)\n-{\n-    PRInt32 rv;\n+PRStatus _PR_MD_GETPEERNAME(PRFileDesc* fd, PRNetAddr* addr, PRUint32* len) {\n+  PRInt32 rv;\n \n-    rv = getpeername((SOCKET)fd->secret->md.osfd, (struct sockaddr*)addr, len);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    } else {\n-        _PR_MD_MAP_GETPEERNAME_ERROR(WSAGetLastError());\n-        return PR_FAILURE;\n-    }\n+  rv = getpeername((SOCKET)fd->secret->md.osfd, (struct sockaddr*)addr, len);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  } else {\n+    _PR_MD_MAP_GETPEERNAME_ERROR(WSAGetLastError());\n+    return PR_FAILURE;\n+  }\n }\n \n-PRStatus\n-_PR_MD_GETSOCKOPT(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n-                  char* optval, PRInt32* optlen)\n-{\n-    PRInt32 rv;\n+PRStatus _PR_MD_GETSOCKOPT(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n+                           char* optval, PRInt32* optlen) {\n+  PRInt32 rv;\n \n-    rv = getsockopt((SOCKET)fd->secret->md.osfd, level, optname, optval, optlen);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    } else {\n-        _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n-        return PR_FAILURE;\n-    }\n+  rv = getsockopt((SOCKET)fd->secret->md.osfd, level, optname, optval, optlen);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  } else {\n+    _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n+    return PR_FAILURE;\n+  }\n }\n \n-PRStatus\n-_PR_MD_SETSOCKOPT(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n-                  const char* optval, PRInt32 optlen)\n-{\n-    PRInt32 rv;\n+PRStatus _PR_MD_SETSOCKOPT(PRFileDesc* fd, PRInt32 level, PRInt32 optname,\n+                           const char* optval, PRInt32 optlen) {\n+  PRInt32 rv;\n \n-    rv = setsockopt((SOCKET)fd->secret->md.osfd, level, optname, optval, optlen);\n-    if (rv == 0) {\n-        return PR_SUCCESS;\n-    } else {\n-        _PR_MD_MAP_SETSOCKOPT_ERROR(WSAGetLastError());\n-        return PR_FAILURE;\n-    }\n+  rv = setsockopt((SOCKET)fd->secret->md.osfd, level, optname, optval, optlen);\n+  if (rv == 0) {\n+    return PR_SUCCESS;\n+  } else {\n+    _PR_MD_MAP_SETSOCKOPT_ERROR(WSAGetLastError());\n+    return PR_FAILURE;\n+  }\n }\n \n-void\n-_MD_MakeNonblock(PRFileDesc* f)\n-{\n-    return; /* do nothing */\n-}\n+void _MD_MakeNonblock(PRFileDesc* f) { return; /* do nothing */ }\n \n /*\n  * socket_io_wait --\n@@ -621,178 +575,176 @@ _MD_MakeNonblock(PRFileDesc* f)\n  */\n #define _PR_INTERRUPT_CHECK_INTERVAL_SECS 5\n \n-static PRInt32\n-socket_io_wait(PROsfd osfd, PRInt32 fd_type,\n-               PRIntervalTime timeout)\n-{\n-    PRInt32 rv = -1;\n-    struct timeval tv;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRIntervalTime elapsed, remaining;\n-    PRBool wait_for_remaining;\n-    fd_set rd_wr, ex;\n-    int err, len;\n-\n-    switch (timeout) {\n-        case PR_INTERVAL_NO_WAIT:\n-            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+static PRInt32 socket_io_wait(PROsfd osfd, PRInt32 fd_type,\n+                              PRIntervalTime timeout) {\n+  PRInt32 rv = -1;\n+  struct timeval tv;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRIntervalTime elapsed, remaining;\n+  PRBool wait_for_remaining;\n+  fd_set rd_wr, ex;\n+  int err, len;\n+\n+  switch (timeout) {\n+    case PR_INTERVAL_NO_WAIT:\n+      PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+      break;\n+    case PR_INTERVAL_NO_TIMEOUT:\n+      /*\n+       * This is a special case of the 'default' case below.\n+       * Please see the comments there.\n+       */\n+      tv.tv_sec = _PR_INTERRUPT_CHECK_INTERVAL_SECS;\n+      tv.tv_usec = 0;\n+      FD_ZERO(&rd_wr);\n+      FD_ZERO(&ex);\n+      do {\n+        FD_SET(osfd, &rd_wr);\n+        FD_SET(osfd, &ex);\n+        switch (fd_type) {\n+          case READ_FD:\n+            rv = _MD_SELECT(0, &rd_wr, NULL, NULL, &tv);\n             break;\n-        case PR_INTERVAL_NO_TIMEOUT:\n-            /*\n-             * This is a special case of the 'default' case below.\n-             * Please see the comments there.\n-             */\n-            tv.tv_sec = _PR_INTERRUPT_CHECK_INTERVAL_SECS;\n-            tv.tv_usec = 0;\n-            FD_ZERO(&rd_wr);\n-            FD_ZERO(&ex);\n-            do {\n-                FD_SET(osfd, &rd_wr);\n-                FD_SET(osfd, &ex);\n-                switch (fd_type) {\n-                    case READ_FD:\n-                        rv = _MD_SELECT(0, &rd_wr, NULL, NULL, &tv);\n-                        break;\n-                    case WRITE_FD:\n-                        rv = _MD_SELECT(0, NULL, &rd_wr, NULL, &tv);\n-                        break;\n-                    case CONNECT_FD:\n-                        rv = _MD_SELECT(0, NULL, &rd_wr, &ex, &tv);\n-                        break;\n-                    default:\n-                        PR_ASSERT(0);\n-                        break;\n-                } /* end switch() */\n-                if (rv == -1) {\n-                    _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n-                    break;\n-                }\n-                if (rv > 0 && fd_type == CONNECT_FD) {\n-                    /*\n-                     * Call Sleep(0) to work around a Winsock timing bug.\n-                     */\n-                    Sleep(0);\n-                    if (FD_ISSET((SOCKET)osfd, &ex)) {\n-                        len = sizeof(err);\n-                        if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char*)&err, &len) ==\n-                            SOCKET_ERROR) {\n-                            _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n-                            return -1;\n-                        }\n-                        if (err != 0) {\n-                            _PR_MD_MAP_CONNECT_ERROR(err);\n-                        } else {\n-                            PR_SetError(PR_UNKNOWN_ERROR, 0);\n-                        }\n-                        return -1;\n-                    }\n-                    if (FD_ISSET((SOCKET)osfd, &rd_wr)) {\n-                        /* it's connected */\n-                        return 1;\n-                    }\n-                    PR_ASSERT(0);\n-                }\n-                if (_PR_PENDING_INTERRUPT(me)) {\n-                    me->flags &= ~_PR_INTERRUPT;\n-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                    rv = -1;\n-                    break;\n-                }\n-            } while (rv == 0);\n+          case WRITE_FD:\n+            rv = _MD_SELECT(0, NULL, &rd_wr, NULL, &tv);\n             break;\n-        default:\n-            remaining = timeout;\n-            FD_ZERO(&rd_wr);\n-            FD_ZERO(&ex);\n-            do {\n-                /*\n-                 * We block in _MD_SELECT for at most\n-                 * _PR_INTERRUPT_CHECK_INTERVAL_SECS seconds,\n-                 * so that there is an upper limit on the delay\n-                 * before the interrupt bit is checked.\n-                 */\n-                wait_for_remaining = PR_TRUE;\n-                tv.tv_sec = PR_IntervalToSeconds(remaining);\n-                if (tv.tv_sec > _PR_INTERRUPT_CHECK_INTERVAL_SECS) {\n-                    wait_for_remaining = PR_FALSE;\n-                    tv.tv_sec = _PR_INTERRUPT_CHECK_INTERVAL_SECS;\n-                    tv.tv_usec = 0;\n-                } else {\n-                    tv.tv_usec = PR_IntervalToMicroseconds(\n-                        remaining - PR_SecondsToInterval(tv.tv_sec));\n-                }\n-                FD_SET(osfd, &rd_wr);\n-                FD_SET(osfd, &ex);\n-                switch (fd_type) {\n-                    case READ_FD:\n-                        rv = _MD_SELECT(0, &rd_wr, NULL, NULL, &tv);\n-                        break;\n-                    case WRITE_FD:\n-                        rv = _MD_SELECT(0, NULL, &rd_wr, NULL, &tv);\n-                        break;\n-                    case CONNECT_FD:\n-                        rv = _MD_SELECT(0, NULL, &rd_wr, &ex, &tv);\n-                        break;\n-                    default:\n-                        PR_ASSERT(0);\n-                        break;\n-                } /* end switch() */\n-                if (rv == -1) {\n-                    _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n-                    break;\n-                }\n-                if (rv > 0 && fd_type == CONNECT_FD) {\n-                    /*\n-                     * Call Sleep(0) to work around a Winsock timing bug.\n-                     */\n-                    Sleep(0);\n-                    if (FD_ISSET((SOCKET)osfd, &ex)) {\n-                        len = sizeof(err);\n-                        if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char*)&err, &len) ==\n-                            SOCKET_ERROR) {\n-                            _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n-                            return -1;\n-                        }\n-                        if (err != 0) {\n-                            _PR_MD_MAP_CONNECT_ERROR(err);\n-                        } else {\n-                            PR_SetError(PR_UNKNOWN_ERROR, 0);\n-                        }\n-                        return -1;\n-                    }\n-                    if (FD_ISSET((SOCKET)osfd, &rd_wr)) {\n-                        /* it's connected */\n-                        return 1;\n-                    }\n-                    PR_ASSERT(0);\n-                }\n-                if (_PR_PENDING_INTERRUPT(me)) {\n-                    me->flags &= ~_PR_INTERRUPT;\n-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-                    rv = -1;\n-                    break;\n-                }\n-                /*\n-                 * We loop again if _MD_SELECT timed out and the\n-                 * timeout deadline has not passed yet.\n-                 */\n-                if (rv == 0) {\n-                    if (wait_for_remaining) {\n-                        elapsed = remaining;\n-                    } else {\n-                        elapsed = PR_SecondsToInterval(tv.tv_sec) +\n-                                  PR_MicrosecondsToInterval(tv.tv_usec);\n-                    }\n-                    if (elapsed >= remaining) {\n-                        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-                        rv = -1;\n-                        break;\n-                    } else {\n-                        remaining = remaining - elapsed;\n-                    }\n-                }\n-            } while (rv == 0);\n+          case CONNECT_FD:\n+            rv = _MD_SELECT(0, NULL, &rd_wr, &ex, &tv);\n             break;\n-    }\n-    return (rv);\n+          default:\n+            PR_ASSERT(0);\n+            break;\n+        } /* end switch() */\n+        if (rv == -1) {\n+          _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n+          break;\n+        }\n+        if (rv > 0 && fd_type == CONNECT_FD) {\n+          /*\n+           * Call Sleep(0) to work around a Winsock timing bug.\n+           */\n+          Sleep(0);\n+          if (FD_ISSET((SOCKET)osfd, &ex)) {\n+            len = sizeof(err);\n+            if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char*)&err, &len) ==\n+                SOCKET_ERROR) {\n+              _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n+              return -1;\n+            }\n+            if (err != 0) {\n+              _PR_MD_MAP_CONNECT_ERROR(err);\n+            } else {\n+              PR_SetError(PR_UNKNOWN_ERROR, 0);\n+            }\n+            return -1;\n+          }\n+          if (FD_ISSET((SOCKET)osfd, &rd_wr)) {\n+            /* it's connected */\n+            return 1;\n+          }\n+          PR_ASSERT(0);\n+        }\n+        if (_PR_PENDING_INTERRUPT(me)) {\n+          me->flags &= ~_PR_INTERRUPT;\n+          PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+          rv = -1;\n+          break;\n+        }\n+      } while (rv == 0);\n+      break;\n+    default:\n+      remaining = timeout;\n+      FD_ZERO(&rd_wr);\n+      FD_ZERO(&ex);\n+      do {\n+        /*\n+         * We block in _MD_SELECT for at most\n+         * _PR_INTERRUPT_CHECK_INTERVAL_SECS seconds,\n+         * so that there is an upper limit on the delay\n+         * before the interrupt bit is checked.\n+         */\n+        wait_for_remaining = PR_TRUE;\n+        tv.tv_sec = PR_IntervalToSeconds(remaining);\n+        if (tv.tv_sec > _PR_INTERRUPT_CHECK_INTERVAL_SECS) {\n+          wait_for_remaining = PR_FALSE;\n+          tv.tv_sec = _PR_INTERRUPT_CHECK_INTERVAL_SECS;\n+          tv.tv_usec = 0;\n+        } else {\n+          tv.tv_usec = PR_IntervalToMicroseconds(\n+              remaining - PR_SecondsToInterval(tv.tv_sec));\n+        }\n+        FD_SET(osfd, &rd_wr);\n+        FD_SET(osfd, &ex);\n+        switch (fd_type) {\n+          case READ_FD:\n+            rv = _MD_SELECT(0, &rd_wr, NULL, NULL, &tv);\n+            break;\n+          case WRITE_FD:\n+            rv = _MD_SELECT(0, NULL, &rd_wr, NULL, &tv);\n+            break;\n+          case CONNECT_FD:\n+            rv = _MD_SELECT(0, NULL, &rd_wr, &ex, &tv);\n+            break;\n+          default:\n+            PR_ASSERT(0);\n+            break;\n+        } /* end switch() */\n+        if (rv == -1) {\n+          _PR_MD_MAP_SELECT_ERROR(WSAGetLastError());\n+          break;\n+        }\n+        if (rv > 0 && fd_type == CONNECT_FD) {\n+          /*\n+           * Call Sleep(0) to work around a Winsock timing bug.\n+           */\n+          Sleep(0);\n+          if (FD_ISSET((SOCKET)osfd, &ex)) {\n+            len = sizeof(err);\n+            if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char*)&err, &len) ==\n+                SOCKET_ERROR) {\n+              _PR_MD_MAP_GETSOCKOPT_ERROR(WSAGetLastError());\n+              return -1;\n+            }\n+            if (err != 0) {\n+              _PR_MD_MAP_CONNECT_ERROR(err);\n+            } else {\n+              PR_SetError(PR_UNKNOWN_ERROR, 0);\n+            }\n+            return -1;\n+          }\n+          if (FD_ISSET((SOCKET)osfd, &rd_wr)) {\n+            /* it's connected */\n+            return 1;\n+          }\n+          PR_ASSERT(0);\n+        }\n+        if (_PR_PENDING_INTERRUPT(me)) {\n+          me->flags &= ~_PR_INTERRUPT;\n+          PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+          rv = -1;\n+          break;\n+        }\n+        /*\n+         * We loop again if _MD_SELECT timed out and the\n+         * timeout deadline has not passed yet.\n+         */\n+        if (rv == 0) {\n+          if (wait_for_remaining) {\n+            elapsed = remaining;\n+          } else {\n+            elapsed = PR_SecondsToInterval(tv.tv_sec) +\n+                      PR_MicrosecondsToInterval(tv.tv_usec);\n+          }\n+          if (elapsed >= remaining) {\n+            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+            rv = -1;\n+            break;\n+          } else {\n+            remaining = remaining - elapsed;\n+          }\n+        }\n+      } while (rv == 0);\n+      break;\n+  }\n+  return (rv);\n } /* end socket_io_wait() */\ndiff --git a/nspr/pr/src/md/windows/w95thred.c b/nspr/pr/src/md/windows/w95thred.c\nindex 76636d9..3ec968a 100644\n--- a/nspr/pr/src/md/windows/w95thred.c\n+++ b/nspr/pr/src/md/windows/w95thred.c\n@@ -1,3 +1,5 @@\n+\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -24,361 +26,300 @@ DWORD _pr_lastThreadIndex;\n DWORD _pr_currentCPUIndex;\n #endif\n int _pr_intsOff = 0;\n-_PRInterruptTable _pr_interruptTable[] = { { 0 } };\n+_PRInterruptTable _pr_interruptTable[] = {{0}};\n \n typedef HRESULT(WINAPI* SETTHREADDESCRIPTION)(HANDLE, PCWSTR);\n static SETTHREADDESCRIPTION sSetThreadDescription = NULL;\n \n-void\n-_PR_MD_EARLY_INIT()\n-{\n-    HMODULE hModule;\n+void _PR_MD_EARLY_INIT() {\n+  HMODULE hModule;\n \n #ifndef _PR_USE_STATIC_TLS\n-    _pr_currentThreadIndex = TlsAlloc();\n-    _pr_lastThreadIndex = TlsAlloc();\n-    _pr_currentCPUIndex = TlsAlloc();\n+  _pr_currentThreadIndex = TlsAlloc();\n+  _pr_lastThreadIndex = TlsAlloc();\n+  _pr_currentCPUIndex = TlsAlloc();\n #endif\n \n #if defined(_WIN64) && defined(WIN95)\n-    _fd_waiting_for_overlapped_done_lock = PR_NewLock();\n+  _fd_waiting_for_overlapped_done_lock = PR_NewLock();\n #endif\n \n-    // SetThreadDescription is Windows 10 build 1607+\n-    hModule = GetModuleHandleW(L\"kernel32.dll\");\n-    if (hModule) {\n-        sSetThreadDescription =\n-            (SETTHREADDESCRIPTION)GetProcAddress(hModule, \"SetThreadDescription\");\n-    }\n+  // SetThreadDescription is Windows 10 build 1607+\n+  hModule = GetModuleHandleW(L\"kernel32.dll\");\n+  if (hModule) {\n+    sSetThreadDescription =\n+        (SETTHREADDESCRIPTION)GetProcAddress(hModule, \"SetThreadDescription\");\n+  }\n }\n \n-void\n-_PR_MD_CLEANUP_BEFORE_EXIT(void)\n-{\n-    _PR_NT_FreeSids();\n+void _PR_MD_CLEANUP_BEFORE_EXIT(void) {\n+  _PR_NT_FreeSids();\n \n-    _PR_MD_CleanupSockets();\n+  _PR_MD_CleanupSockets();\n \n-    WSACleanup();\n+  WSACleanup();\n \n #ifndef _PR_USE_STATIC_TLS\n-    TlsFree(_pr_currentThreadIndex);\n-    TlsFree(_pr_lastThreadIndex);\n-    TlsFree(_pr_currentCPUIndex);\n+  TlsFree(_pr_currentThreadIndex);\n+  TlsFree(_pr_lastThreadIndex);\n+  TlsFree(_pr_currentCPUIndex);\n #endif\n \n #if defined(_WIN64) && defined(WIN95)\n-    // For each iteration check if TFO overlapped IOs are down.\n-    if (_fd_waiting_for_overlapped_done_lock) {\n-        PRIntervalTime delay = PR_MillisecondsToInterval(1000);\n-        PRFileDescList* cur;\n-        do {\n-            CheckOverlappedPendingSocketsAreDone();\n-\n-            PR_Lock(_fd_waiting_for_overlapped_done_lock);\n-            cur = _fd_waiting_for_overlapped_done;\n-            PR_Unlock(_fd_waiting_for_overlapped_done_lock);\n-#if defined(DO_NOT_WAIT_FOR_CONNECT_OVERLAPPED_OPERATIONS)\n-            cur = NULL;\n-#endif\n-            if (cur) {\n-                PR_Sleep(delay); // wait another 1s.\n-            }\n-        } while (cur);\n-\n-        PR_DestroyLock(_fd_waiting_for_overlapped_done_lock);\n-    }\n+  // For each iteration check if TFO overlapped IOs are down.\n+  if (_fd_waiting_for_overlapped_done_lock) {\n+    PRIntervalTime delay = PR_MillisecondsToInterval(1000);\n+    PRFileDescList* cur;\n+    do {\n+      CheckOverlappedPendingSocketsAreDone();\n+\n+      PR_Lock(_fd_waiting_for_overlapped_done_lock);\n+      cur = _fd_waiting_for_overlapped_done;\n+      PR_Unlock(_fd_waiting_for_overlapped_done_lock);\n+#  if defined(DO_NOT_WAIT_FOR_CONNECT_OVERLAPPED_OPERATIONS)\n+      cur = NULL;\n+#  endif\n+      if (cur) {\n+        PR_Sleep(delay);  // wait another 1s.\n+      }\n+    } while (cur);\n+\n+    PR_DestroyLock(_fd_waiting_for_overlapped_done_lock);\n+  }\n #endif\n }\n \n-PRStatus\n-_PR_MD_INIT_THREAD(PRThread* thread)\n-{\n-    if (thread->flags & (_PR_PRIMORDIAL | _PR_ATTACHED)) {\n-        /*\n-        ** Warning:\n-        ** --------\n-        ** NSPR requires a real handle to every thread.\n-        ** GetCurrentThread() returns a pseudo-handle which\n-        ** is not suitable for some thread operations (e.g.,\n-        ** suspending).  Therefore, get a real handle from\n-        ** the pseudo handle via DuplicateHandle(...)\n-        */\n-        BOOL ok =\n-            DuplicateHandle(GetCurrentProcess(),    /* Process of source handle */\n-                            GetCurrentThread(),     /* Pseudo Handle to dup */\n-                            GetCurrentProcess(),    /* Process of handle */\n-                            &(thread->md.handle),   /* resulting handle */\n-                            0L,                     /* access flags */\n-                            FALSE,                  /* Inheritable */\n-                            DUPLICATE_SAME_ACCESS); /* Options */\n-        if (!ok) {\n-            _MD_win32_map_default_error(GetLastError());\n-            return PR_FAILURE;\n-        }\n-        thread->id = GetCurrentThreadId();\n-        thread->md.id = thread->id;\n+PRStatus _PR_MD_INIT_THREAD(PRThread* thread) {\n+  if (thread->flags & (_PR_PRIMORDIAL | _PR_ATTACHED)) {\n+    /*\n+    ** Warning:\n+    ** --------\n+    ** NSPR requires a real handle to every thread.\n+    ** GetCurrentThread() returns a pseudo-handle which\n+    ** is not suitable for some thread operations (e.g.,\n+    ** suspending).  Therefore, get a real handle from\n+    ** the pseudo handle via DuplicateHandle(...)\n+    */\n+    BOOL ok =\n+        DuplicateHandle(GetCurrentProcess(),    /* Process of source handle */\n+                        GetCurrentThread(),     /* Pseudo Handle to dup */\n+                        GetCurrentProcess(),    /* Process of handle */\n+                        &(thread->md.handle),   /* resulting handle */\n+                        0L,                     /* access flags */\n+                        FALSE,                  /* Inheritable */\n+                        DUPLICATE_SAME_ACCESS); /* Options */\n+    if (!ok) {\n+      return PR_FAILURE;\n     }\n+    thread->id = GetCurrentThreadId();\n+    thread->md.id = thread->id;\n+  }\n \n-    /* Create the blocking IO semaphore */\n-    thread->md.blocked_sema = CreateSemaphore(NULL, 0, 1, NULL);\n-    if (thread->md.blocked_sema == NULL) {\n-        _MD_win32_map_default_error(GetLastError());\n-        return PR_FAILURE;\n-    } else {\n-        return PR_SUCCESS;\n-    }\n+  /* Create the blocking IO semaphore */\n+  thread->md.blocked_sema = CreateSemaphore(NULL, 0, 1, NULL);\n+  if (thread->md.blocked_sema == NULL) {\n+    return PR_FAILURE;\n+  } else {\n+    return PR_SUCCESS;\n+  }\n }\n \n-static unsigned __stdcall\n-pr_root(void* arg)\n-{\n-    PRThread* thread = (PRThread*)arg;\n-    thread->md.start(thread);\n-    return 0;\n+static unsigned __stdcall pr_root(void* arg) {\n+  PRThread* thread = (PRThread*)arg;\n+  thread->md.start(thread);\n+  return 0;\n }\n \n-PRStatus\n-_PR_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n-                     PRThreadPriority priority, PRThreadScope scope,\n-                     PRThreadState state, PRUint32 stackSize)\n-{\n-    thread->md.start = start;\n-    thread->md.handle = (HANDLE)_beginthreadex(\n-        NULL, thread->stack->stackSize, pr_root, (void*)thread,\n-        CREATE_SUSPENDED | STACK_SIZE_PARAM_IS_A_RESERVATION, &(thread->id));\n-    if (!thread->md.handle) {\n-        PRErrorCode prerror;\n-        PRInt32 oserr = (PRInt32)GetLastError();\n-        switch (errno) {\n-            case ENOMEM:\n-                prerror = PR_OUT_OF_MEMORY_ERROR;\n-                break;\n-            case EAGAIN:\n-                prerror = PR_INSUFFICIENT_RESOURCES_ERROR;\n-                break;\n-            case EINVAL:\n-                prerror = PR_INVALID_ARGUMENT_ERROR;\n-                break;\n-            default:\n-                prerror = PR_UNKNOWN_ERROR;\n-        }\n-        PR_SetError(prerror, oserr);\n-        return PR_FAILURE;\n-    }\n-\n-    thread->md.id = thread->id;\n-    /*\n-     * On windows, a thread is created with a thread priority of\n-     * THREAD_PRIORITY_NORMAL.\n-     */\n-    if (priority != PR_PRIORITY_NORMAL) {\n-        _PR_MD_SET_PRIORITY(&(thread->md), priority);\n-    }\n-\n-    /* Activate the thread */\n-    if (ResumeThread(thread->md.handle) != -1) {\n-        return PR_SUCCESS;\n-    }\n-\n-    _MD_win32_map_default_error(GetLastError());\n+PRStatus _PR_MD_CREATE_THREAD(PRThread* thread, void (*start)(void*),\n+                              PRThreadPriority priority, PRThreadScope scope,\n+                              PRThreadState state, PRUint32 stackSize) {\n+  thread->md.start = start;\n+  thread->md.handle = (HANDLE)_beginthreadex(\n+      NULL, thread->stack->stackSize, pr_root, (void*)thread,\n+      CREATE_SUSPENDED | STACK_SIZE_PARAM_IS_A_RESERVATION, &(thread->id));\n+  if (!thread->md.handle) {\n     return PR_FAILURE;\n+  }\n+\n+  thread->md.id = thread->id;\n+  /*\n+   * On windows, a thread is created with a thread priority of\n+   * THREAD_PRIORITY_NORMAL.\n+   */\n+  if (priority != PR_PRIORITY_NORMAL) {\n+    _PR_MD_SET_PRIORITY(&(thread->md), priority);\n+  }\n+\n+  /* Activate the thread */\n+  if (ResumeThread(thread->md.handle) != -1) {\n+    return PR_SUCCESS;\n+  }\n+\n+  return PR_FAILURE;\n }\n \n-void\n-_PR_MD_YIELD(void)\n-{\n-    /* Can NT really yield at all? */\n-    Sleep(0);\n+void _PR_MD_YIELD(void) {\n+  /* Can NT really yield at all? */\n+  Sleep(0);\n }\n \n-void\n-_PR_MD_SET_PRIORITY(_MDThread* thread, PRThreadPriority newPri)\n-{\n-    int nativePri;\n-    BOOL rv;\n-\n-    if (newPri < PR_PRIORITY_FIRST) {\n-        newPri = PR_PRIORITY_FIRST;\n-    } else if (newPri > PR_PRIORITY_LAST) {\n-        newPri = PR_PRIORITY_LAST;\n-    }\n-    switch (newPri) {\n-        case PR_PRIORITY_LOW:\n-            nativePri = THREAD_PRIORITY_BELOW_NORMAL;\n-            break;\n-        case PR_PRIORITY_NORMAL:\n-            nativePri = THREAD_PRIORITY_NORMAL;\n-            break;\n-        case PR_PRIORITY_HIGH:\n-            nativePri = THREAD_PRIORITY_ABOVE_NORMAL;\n-            break;\n-        case PR_PRIORITY_URGENT:\n-            nativePri = THREAD_PRIORITY_HIGHEST;\n-    }\n-    rv = SetThreadPriority(thread->handle, nativePri);\n-    PR_ASSERT(rv);\n-    if (!rv) {\n-        PR_LOG(_pr_thread_lm, PR_LOG_MIN,\n-               (\"PR_SetThreadPriority: can't set thread priority\\n\"));\n-    }\n-    return;\n+void _PR_MD_SET_PRIORITY(_MDThread* thread, PRThreadPriority newPri) {\n+  int nativePri;\n+  BOOL rv;\n+\n+  if (newPri < PR_PRIORITY_FIRST) {\n+    newPri = PR_PRIORITY_FIRST;\n+  } else if (newPri > PR_PRIORITY_LAST) {\n+    newPri = PR_PRIORITY_LAST;\n+  }\n+  switch (newPri) {\n+    case PR_PRIORITY_LOW:\n+      nativePri = THREAD_PRIORITY_BELOW_NORMAL;\n+      break;\n+    case PR_PRIORITY_NORMAL:\n+      nativePri = THREAD_PRIORITY_NORMAL;\n+      break;\n+    case PR_PRIORITY_HIGH:\n+      nativePri = THREAD_PRIORITY_ABOVE_NORMAL;\n+      break;\n+    case PR_PRIORITY_URGENT:\n+      nativePri = THREAD_PRIORITY_HIGHEST;\n+  }\n+  rv = SetThreadPriority(thread->handle, nativePri);\n+  PR_ASSERT(rv);\n+  if (!rv) {\n+    PR_LOG(_pr_thread_lm, PR_LOG_MIN,\n+           (\"PR_SetThreadPriority: can't set thread priority\\n\"));\n+  }\n+  return;\n }\n \n const DWORD MS_VC_EXCEPTION = 0x406D1388;\n \n #pragma pack(push, 8)\n typedef struct tagTHREADNAME_INFO {\n-    DWORD dwType;     // Must be 0x1000.\n-    LPCSTR szName;    // Pointer to name (in user addr space).\n-    DWORD dwThreadID; // Thread ID (-1=caller thread).\n-    DWORD dwFlags;    // Reserved for future use, must be zero.\n+  DWORD dwType;      // Must be 0x1000.\n+  LPCSTR szName;     // Pointer to name (in user addr space).\n+  DWORD dwThreadID;  // Thread ID (-1=caller thread).\n+  DWORD dwFlags;     // Reserved for future use, must be zero.\n } THREADNAME_INFO;\n #pragma pack(pop)\n \n-void\n-_PR_MD_SET_CURRENT_THREAD_NAME(const char* name)\n-{\n+void _PR_MD_SET_CURRENT_THREAD_NAME(const char* name) {\n #ifdef _MSC_VER\n-    THREADNAME_INFO info;\n+  THREADNAME_INFO info;\n #endif\n \n-    if (sSetThreadDescription) {\n-        WCHAR wideName[MAX_PATH];\n-        if (MultiByteToWideChar(CP_ACP, 0, name, -1, wideName, MAX_PATH)) {\n-            sSetThreadDescription(GetCurrentThread(), wideName);\n-        }\n+  if (sSetThreadDescription) {\n+    WCHAR wideName[MAX_PATH];\n+    if (MultiByteToWideChar(CP_ACP, 0, name, -1, wideName, MAX_PATH)) {\n+      sSetThreadDescription(GetCurrentThread(), wideName);\n     }\n+  }\n \n #ifdef _MSC_VER\n-    if (!IsDebuggerPresent()) {\n-        return;\n-    }\n-\n-    info.dwType = 0x1000;\n-    info.szName = (char*)name;\n-    info.dwThreadID = -1;\n-    info.dwFlags = 0;\n-\n-    __try {\n-        RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR),\n-                       (ULONG_PTR*)&info);\n-    } __except (EXCEPTION_CONTINUE_EXECUTION) {\n-    }\n+  if (!IsDebuggerPresent()) {\n+    return;\n+  }\n+\n+  info.dwType = 0x1000;\n+  info.szName = (char*)name;\n+  info.dwThreadID = -1;\n+  info.dwFlags = 0;\n+\n+  __try {\n+    RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR),\n+                   (ULONG_PTR*)&info);\n+  } __except (EXCEPTION_CONTINUE_EXECUTION) {\n+  }\n #endif\n }\n \n-void\n-_PR_MD_CLEAN_THREAD(PRThread* thread)\n-{\n-    BOOL rv;\n+void _PR_MD_CLEAN_THREAD(PRThread* thread) {\n+  BOOL rv;\n \n-    if (thread->md.blocked_sema) {\n-        rv = CloseHandle(thread->md.blocked_sema);\n-        PR_ASSERT(rv);\n-        thread->md.blocked_sema = 0;\n-    }\n+  if (thread->md.blocked_sema) {\n+    rv = CloseHandle(thread->md.blocked_sema);\n+    PR_ASSERT(rv);\n+    thread->md.blocked_sema = 0;\n+  }\n \n-    if (thread->md.handle) {\n-        rv = CloseHandle(thread->md.handle);\n-        PR_ASSERT(rv);\n-        thread->md.handle = 0;\n-    }\n+  if (thread->md.handle) {\n+    rv = CloseHandle(thread->md.handle);\n+    PR_ASSERT(rv);\n+    thread->md.handle = 0;\n+  }\n }\n \n-void\n-_PR_MD_EXIT_THREAD(PRThread* thread)\n-{\n-    _PR_MD_CLEAN_THREAD(thread);\n-    _PR_MD_SET_CURRENT_THREAD(NULL);\n+void _PR_MD_EXIT_THREAD(PRThread* thread) {\n+  _PR_MD_CLEAN_THREAD(thread);\n+  _PR_MD_SET_CURRENT_THREAD(NULL);\n }\n \n-void\n-_PR_MD_EXIT(PRIntn status)\n-{\n-    _exit(status);\n-}\n+void _PR_MD_EXIT(PRIntn status) { _exit(status); }\n \n-PRInt32\n-_PR_MD_SETTHREADAFFINITYMASK(PRThread* thread, PRUint32 mask)\n-{\n+PRInt32 _PR_MD_SETTHREADAFFINITYMASK(PRThread* thread, PRUint32 mask) {\n #ifdef WINCE\n-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);\n-    return -1;\n+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);\n+  return -1;\n #else\n-    DWORD_PTR rv;\n+  DWORD_PTR rv;\n \n-    rv = SetThreadAffinityMask(thread->md.handle, mask);\n+  rv = SetThreadAffinityMask(thread->md.handle, mask);\n \n-    return rv ? 0 : -1;\n+  return rv ? 0 : -1;\n #endif\n }\n \n-PRInt32\n-_PR_MD_GETTHREADAFFINITYMASK(PRThread* thread, PRUint32* mask)\n-{\n+PRInt32 _PR_MD_GETTHREADAFFINITYMASK(PRThread* thread, PRUint32* mask) {\n #ifdef WINCE\n-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);\n-    return -1;\n+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);\n+  return -1;\n #else\n-    BOOL rv;\n-    DWORD_PTR process_mask;\n-    DWORD_PTR system_mask;\n+  BOOL rv;\n+  DWORD_PTR process_mask;\n+  DWORD_PTR system_mask;\n \n-    rv = GetProcessAffinityMask(GetCurrentProcess(), &process_mask, &system_mask);\n-    if (rv) {\n-        *mask = (PRUint32)process_mask;\n-    }\n+  rv = GetProcessAffinityMask(GetCurrentProcess(), &process_mask, &system_mask);\n+  if (rv) {\n+    *mask = (PRUint32)process_mask;\n+  }\n \n-    return rv ? 0 : -1;\n+  return rv ? 0 : -1;\n #endif\n }\n \n-void\n-_PR_MD_SUSPEND_CPU(_PRCPU* cpu)\n-{\n-    _PR_MD_SUSPEND_THREAD(cpu->thread);\n-}\n+void _PR_MD_SUSPEND_CPU(_PRCPU* cpu) { _PR_MD_SUSPEND_THREAD(cpu->thread); }\n \n-void\n-_PR_MD_RESUME_CPU(_PRCPU* cpu)\n-{\n-    _PR_MD_RESUME_THREAD(cpu->thread);\n-}\n+void _PR_MD_RESUME_CPU(_PRCPU* cpu) { _PR_MD_RESUME_THREAD(cpu->thread); }\n \n-void\n-_PR_MD_SUSPEND_THREAD(PRThread* thread)\n-{\n-    if (_PR_IS_NATIVE_THREAD(thread)) {\n-        DWORD previousSuspendCount;\n-        /* XXXMB - SuspendThread() is not a blocking call; how do we\n-         * know when the thread is *REALLY* suspended?\n-         */\n-        previousSuspendCount = SuspendThread(thread->md.handle);\n-        PR_ASSERT(previousSuspendCount == 0);\n-    }\n+void _PR_MD_SUSPEND_THREAD(PRThread* thread) {\n+  if (_PR_IS_NATIVE_THREAD(thread)) {\n+    DWORD previousSuspendCount;\n+    /* XXXMB - SuspendThread() is not a blocking call; how do we\n+     * know when the thread is *REALLY* suspended?\n+     */\n+    previousSuspendCount = SuspendThread(thread->md.handle);\n+    PR_ASSERT(previousSuspendCount == 0);\n+  }\n }\n \n-void\n-_PR_MD_RESUME_THREAD(PRThread* thread)\n-{\n-    if (_PR_IS_NATIVE_THREAD(thread)) {\n-        DWORD previousSuspendCount;\n-        previousSuspendCount = ResumeThread(thread->md.handle);\n-        PR_ASSERT(previousSuspendCount == 1);\n-    }\n+void _PR_MD_RESUME_THREAD(PRThread* thread) {\n+  if (_PR_IS_NATIVE_THREAD(thread)) {\n+    DWORD previousSuspendCount;\n+    previousSuspendCount = ResumeThread(thread->md.handle);\n+    PR_ASSERT(previousSuspendCount == 1);\n+  }\n }\n \n-PRThread*\n-_MD_CURRENT_THREAD(void)\n-{\n-    PRThread* thread;\n+PRThread* _MD_CURRENT_THREAD(void) {\n+  PRThread* thread;\n \n-    thread = _MD_GET_ATTACHED_THREAD();\n+  thread = _MD_GET_ATTACHED_THREAD();\n \n-    if (NULL == thread) {\n-        thread = _PRI_AttachThread(PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL, 0);\n-    }\n-    PR_ASSERT(thread != NULL);\n-    return thread;\n+  if (NULL == thread) {\n+    thread = _PRI_AttachThread(PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL, 0);\n+  }\n+  PR_ASSERT(thread != NULL);\n+  return thread;\n }\ndiff --git a/nspr/pr/src/md/windows/win32_errors.c b/nspr/pr/src/md/windows/win32_errors.c\nindex 7380976..2669cb6 100644\n--- a/nspr/pr/src/md/windows/win32_errors.c\n+++ b/nspr/pr/src/md/windows/win32_errors.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -27,551 +28,467 @@\n  * be detected at the time we create new sockets.\n  */\n \n-static void\n-_MD_win32_map_default_errno(PRInt32 err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case EACCES:\n-            prError = PR_NO_ACCESS_RIGHTS_ERROR;\n-            break;\n-        case ENOENT:\n-            prError = PR_FILE_NOT_FOUND_ERROR;\n-            break;\n-        default:\n-            prError = PR_UNKNOWN_ERROR;\n-            break;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_win32_map_default_error(PRInt32 err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case ERROR_ACCESS_DENIED:\n-            prError = PR_NO_ACCESS_RIGHTS_ERROR;\n-            break;\n-        case ERROR_ALREADY_EXISTS:\n-            prError = PR_FILE_EXISTS_ERROR;\n-            break;\n-        case ERROR_CALL_NOT_IMPLEMENTED:\n-            prError = PR_NOT_IMPLEMENTED_ERROR;\n-            break;\n-        case ERROR_DISK_CORRUPT:\n-            prError = PR_IO_ERROR;\n-            break;\n-        case ERROR_DISK_FULL:\n-            prError = PR_NO_DEVICE_SPACE_ERROR;\n-            break;\n-        case ERROR_DISK_OPERATION_FAILED:\n-            prError = PR_IO_ERROR;\n-            break;\n-        case ERROR_DRIVE_LOCKED:\n-            prError = PR_FILE_IS_LOCKED_ERROR;\n-            break;\n-        case ERROR_FILENAME_EXCED_RANGE:\n-            prError = PR_NAME_TOO_LONG_ERROR;\n-            break;\n-        case ERROR_FILE_CORRUPT:\n-            prError = PR_IO_ERROR;\n-            break;\n-        case ERROR_FILE_EXISTS:\n-            prError = PR_FILE_EXISTS_ERROR;\n-            break;\n-        case ERROR_FILE_INVALID:\n-            prError = PR_BAD_DESCRIPTOR_ERROR;\n-            break;\n-        case ERROR_FILE_NOT_FOUND:\n-            prError = PR_FILE_NOT_FOUND_ERROR;\n-            break;\n-        case ERROR_HANDLE_DISK_FULL:\n-            prError = PR_NO_DEVICE_SPACE_ERROR;\n-            break;\n-        case ERROR_INVALID_ADDRESS:\n-            prError = PR_ACCESS_FAULT_ERROR;\n-            break;\n-        case ERROR_INVALID_HANDLE:\n-            prError = PR_BAD_DESCRIPTOR_ERROR;\n-            break;\n-        case ERROR_INVALID_NAME:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        case ERROR_INVALID_PARAMETER:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        case ERROR_INVALID_USER_BUFFER:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        case ERROR_LOCKED:\n-            prError = PR_FILE_IS_LOCKED_ERROR;\n-            break;\n-        case ERROR_NETNAME_DELETED:\n-            prError = PR_CONNECT_RESET_ERROR;\n-            break;\n-        case ERROR_NOACCESS:\n-            prError = PR_ACCESS_FAULT_ERROR;\n-            break;\n-        case ERROR_NOT_ENOUGH_MEMORY:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        case ERROR_NOT_ENOUGH_QUOTA:\n-            prError = PR_OUT_OF_MEMORY_ERROR;\n-            break;\n-        case ERROR_NOT_READY:\n-            prError = PR_IO_ERROR;\n-            break;\n-        case ERROR_NO_MORE_FILES:\n-            prError = PR_NO_MORE_FILES_ERROR;\n-            break;\n-        case ERROR_OPEN_FAILED:\n-            prError = PR_IO_ERROR;\n-            break;\n-        case ERROR_OPEN_FILES:\n-            prError = PR_IO_ERROR;\n-            break;\n-        case ERROR_OPERATION_ABORTED:\n-            prError = PR_OPERATION_ABORTED_ERROR;\n-            break;\n-        case ERROR_OUTOFMEMORY:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        case ERROR_PATH_BUSY:\n-            prError = PR_IO_ERROR;\n-            break;\n-        case ERROR_PATH_NOT_FOUND:\n-            prError = PR_FILE_NOT_FOUND_ERROR;\n-            break;\n-        case ERROR_SEEK_ON_DEVICE:\n-            prError = PR_IO_ERROR;\n-            break;\n-        case ERROR_SHARING_VIOLATION:\n-            prError = PR_FILE_IS_BUSY_ERROR;\n-            break;\n-        case ERROR_STACK_OVERFLOW:\n-            prError = PR_ACCESS_FAULT_ERROR;\n-            break;\n-        case ERROR_TOO_MANY_OPEN_FILES:\n-            prError = PR_SYS_DESC_TABLE_FULL_ERROR;\n-            break;\n-        case ERROR_WRITE_PROTECT:\n-            prError = PR_NO_ACCESS_RIGHTS_ERROR;\n-            break;\n-        case WSAEACCES:\n-            prError = PR_NO_ACCESS_RIGHTS_ERROR;\n-            break;\n-        case WSAEADDRINUSE:\n-            prError = PR_ADDRESS_IN_USE_ERROR;\n-            break;\n-        case WSAEADDRNOTAVAIL:\n-        case ERROR_INVALID_NETNAME:\n-            prError = PR_ADDRESS_NOT_AVAILABLE_ERROR;\n-            break;\n-        case WSAEAFNOSUPPORT:\n-        case ERROR_INCORRECT_ADDRESS:\n-            prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;\n-            break;\n-        case WSAEALREADY:\n-        case ERROR_ALREADY_INITIALIZED:\n-            prError = PR_ALREADY_INITIATED_ERROR;\n-            break;\n-        case WSAEBADF:\n-            prError = PR_BAD_DESCRIPTOR_ERROR;\n-            break;\n-        case WSAECONNABORTED:\n-        case ERROR_CONNECTION_ABORTED:\n-            prError = PR_CONNECT_ABORTED_ERROR;\n-            break;\n-        case WSAECONNREFUSED:\n-        case ERROR_CONNECTION_REFUSED:\n-            prError = PR_CONNECT_REFUSED_ERROR;\n-            break;\n-        case WSAECONNRESET:\n-            prError = PR_CONNECT_RESET_ERROR;\n-            break;\n-        case WSAEDESTADDRREQ:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        case WSAEFAULT:\n-            prError = PR_ACCESS_FAULT_ERROR;\n-            break;\n-        case WSAEHOSTUNREACH:\n-        case ERROR_HOST_UNREACHABLE:\n-            prError = PR_HOST_UNREACHABLE_ERROR;\n-            break;\n-        case WSAEINVAL:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        case WSAEISCONN:\n-            prError = PR_IS_CONNECTED_ERROR;\n-            break;\n-        case WSAEMFILE:\n-            prError = PR_PROC_DESC_TABLE_FULL_ERROR;\n-            break;\n-        case WSAEMSGSIZE:\n-            prError = PR_BUFFER_OVERFLOW_ERROR;\n-            break;\n-        case WSAENETDOWN:\n-        case ERROR_NO_NETWORK:\n-            prError = PR_NETWORK_DOWN_ERROR;\n-            break;\n-        case WSAENETRESET:\n-            prError = PR_CONNECT_ABORTED_ERROR;\n-            break;\n-        case WSAENETUNREACH:\n-        case ERROR_NETWORK_UNREACHABLE:\n-            prError = PR_NETWORK_UNREACHABLE_ERROR;\n-            break;\n-        case WSAENOBUFS:\n-            prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n-            break;\n-        case WSAENOPROTOOPT:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        case WSAENOTCONN:\n-            prError = PR_NOT_CONNECTED_ERROR;\n-            break;\n-        case WSAENOTSOCK:\n-            prError = PR_NOT_SOCKET_ERROR;\n-            break;\n-        case WSAEOPNOTSUPP:\n-            prError = PR_OPERATION_NOT_SUPPORTED_ERROR;\n-            break;\n-        case WSAEPROTONOSUPPORT:\n-            prError = PR_PROTOCOL_NOT_SUPPORTED_ERROR;\n-            break;\n-        case WSAEPROTOTYPE:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        case WSAESHUTDOWN:\n-            prError = PR_SOCKET_SHUTDOWN_ERROR;\n-            break;\n-        case WSAESOCKTNOSUPPORT:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        case WSAETIMEDOUT:\n-            prError = PR_CONNECT_ABORTED_ERROR;\n-            break;\n-        case WSAEWOULDBLOCK:\n-            prError = PR_WOULD_BLOCK_ERROR;\n-            break;\n-        default:\n-            prError = PR_UNKNOWN_ERROR;\n-            break;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_win32_map_opendir_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n-}\n-\n-void\n-_MD_win32_map_closedir_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n-}\n-\n-void\n-_MD_unix_readdir_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n-}\n-\n-void\n-_MD_win32_map_delete_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n+static void _MD_win32_map_default_errno(PRInt32 err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case EACCES:\n+      prError = PR_NO_ACCESS_RIGHTS_ERROR;\n+      break;\n+    case ENOENT:\n+      prError = PR_FILE_NOT_FOUND_ERROR;\n+      break;\n+    default:\n+      prError = PR_UNKNOWN_ERROR;\n+      break;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_win32_map_default_error(PRInt32 err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case ERROR_ACCESS_DENIED:\n+      prError = PR_NO_ACCESS_RIGHTS_ERROR;\n+      break;\n+    case ERROR_ALREADY_EXISTS:\n+      prError = PR_FILE_EXISTS_ERROR;\n+      break;\n+    case ERROR_CALL_NOT_IMPLEMENTED:\n+      prError = PR_NOT_IMPLEMENTED_ERROR;\n+      break;\n+    case ERROR_DISK_CORRUPT:\n+      prError = PR_IO_ERROR;\n+      break;\n+    case ERROR_DISK_FULL:\n+      prError = PR_NO_DEVICE_SPACE_ERROR;\n+      break;\n+    case ERROR_DISK_OPERATION_FAILED:\n+      prError = PR_IO_ERROR;\n+      break;\n+    case ERROR_DRIVE_LOCKED:\n+      prError = PR_FILE_IS_LOCKED_ERROR;\n+      break;\n+    case ERROR_FILENAME_EXCED_RANGE:\n+      prError = PR_NAME_TOO_LONG_ERROR;\n+      break;\n+    case ERROR_FILE_CORRUPT:\n+      prError = PR_IO_ERROR;\n+      break;\n+    case ERROR_FILE_EXISTS:\n+      prError = PR_FILE_EXISTS_ERROR;\n+      break;\n+    case ERROR_FILE_INVALID:\n+      prError = PR_BAD_DESCRIPTOR_ERROR;\n+      break;\n+    case ERROR_FILE_NOT_FOUND:\n+      prError = PR_FILE_NOT_FOUND_ERROR;\n+      break;\n+    case ERROR_HANDLE_DISK_FULL:\n+      prError = PR_NO_DEVICE_SPACE_ERROR;\n+      break;\n+    case ERROR_INVALID_ADDRESS:\n+      prError = PR_ACCESS_FAULT_ERROR;\n+      break;\n+    case ERROR_INVALID_HANDLE:\n+      prError = PR_BAD_DESCRIPTOR_ERROR;\n+      break;\n+    case ERROR_INVALID_NAME:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    case ERROR_INVALID_PARAMETER:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    case ERROR_INVALID_USER_BUFFER:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    case ERROR_LOCKED:\n+      prError = PR_FILE_IS_LOCKED_ERROR;\n+      break;\n+    case ERROR_NETNAME_DELETED:\n+      prError = PR_CONNECT_RESET_ERROR;\n+      break;\n+    case ERROR_NOACCESS:\n+      prError = PR_ACCESS_FAULT_ERROR;\n+      break;\n+    case ERROR_NOT_ENOUGH_MEMORY:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    case ERROR_NOT_ENOUGH_QUOTA:\n+      prError = PR_OUT_OF_MEMORY_ERROR;\n+      break;\n+    case ERROR_NOT_READY:\n+      prError = PR_IO_ERROR;\n+      break;\n+    case ERROR_NO_MORE_FILES:\n+      prError = PR_NO_MORE_FILES_ERROR;\n+      break;\n+    case ERROR_OPEN_FAILED:\n+      prError = PR_IO_ERROR;\n+      break;\n+    case ERROR_OPEN_FILES:\n+      prError = PR_IO_ERROR;\n+      break;\n+    case ERROR_OPERATION_ABORTED:\n+      prError = PR_OPERATION_ABORTED_ERROR;\n+      break;\n+    case ERROR_OUTOFMEMORY:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    case ERROR_PATH_BUSY:\n+      prError = PR_IO_ERROR;\n+      break;\n+    case ERROR_PATH_NOT_FOUND:\n+      prError = PR_FILE_NOT_FOUND_ERROR;\n+      break;\n+    case ERROR_SEEK_ON_DEVICE:\n+      prError = PR_IO_ERROR;\n+      break;\n+    case ERROR_SHARING_VIOLATION:\n+      prError = PR_FILE_IS_BUSY_ERROR;\n+      break;\n+    case ERROR_STACK_OVERFLOW:\n+      prError = PR_ACCESS_FAULT_ERROR;\n+      break;\n+    case ERROR_TOO_MANY_OPEN_FILES:\n+      prError = PR_SYS_DESC_TABLE_FULL_ERROR;\n+      break;\n+    case ERROR_WRITE_PROTECT:\n+      prError = PR_NO_ACCESS_RIGHTS_ERROR;\n+      break;\n+    case WSAEACCES:\n+      prError = PR_NO_ACCESS_RIGHTS_ERROR;\n+      break;\n+    case WSAEADDRINUSE:\n+      prError = PR_ADDRESS_IN_USE_ERROR;\n+      break;\n+    case WSAEADDRNOTAVAIL:\n+    case ERROR_INVALID_NETNAME:\n+      prError = PR_ADDRESS_NOT_AVAILABLE_ERROR;\n+      break;\n+    case WSAEAFNOSUPPORT:\n+    case ERROR_INCORRECT_ADDRESS:\n+      prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;\n+      break;\n+    case WSAEALREADY:\n+    case ERROR_ALREADY_INITIALIZED:\n+      prError = PR_ALREADY_INITIATED_ERROR;\n+      break;\n+    case WSAEBADF:\n+      prError = PR_BAD_DESCRIPTOR_ERROR;\n+      break;\n+    case WSAECONNABORTED:\n+    case ERROR_CONNECTION_ABORTED:\n+      prError = PR_CONNECT_ABORTED_ERROR;\n+      break;\n+    case WSAECONNREFUSED:\n+    case ERROR_CONNECTION_REFUSED:\n+      prError = PR_CONNECT_REFUSED_ERROR;\n+      break;\n+    case WSAECONNRESET:\n+      prError = PR_CONNECT_RESET_ERROR;\n+      break;\n+    case WSAEDESTADDRREQ:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    case WSAEFAULT:\n+      prError = PR_ACCESS_FAULT_ERROR;\n+      break;\n+    case WSAEHOSTUNREACH:\n+    case ERROR_HOST_UNREACHABLE:\n+      prError = PR_HOST_UNREACHABLE_ERROR;\n+      break;\n+    case WSAEINVAL:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    case WSAEISCONN:\n+      prError = PR_IS_CONNECTED_ERROR;\n+      break;\n+    case WSAEMFILE:\n+      prError = PR_PROC_DESC_TABLE_FULL_ERROR;\n+      break;\n+    case WSAEMSGSIZE:\n+      prError = PR_BUFFER_OVERFLOW_ERROR;\n+      break;\n+    case WSAENETDOWN:\n+    case ERROR_NO_NETWORK:\n+      prError = PR_NETWORK_DOWN_ERROR;\n+      break;\n+    case WSAENETRESET:\n+      prError = PR_CONNECT_ABORTED_ERROR;\n+      break;\n+    case WSAENETUNREACH:\n+    case ERROR_NETWORK_UNREACHABLE:\n+      prError = PR_NETWORK_UNREACHABLE_ERROR;\n+      break;\n+    case WSAENOBUFS:\n+      prError = PR_INSUFFICIENT_RESOURCES_ERROR;\n+      break;\n+    case WSAENOPROTOOPT:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    case WSAENOTCONN:\n+      prError = PR_NOT_CONNECTED_ERROR;\n+      break;\n+    case WSAENOTSOCK:\n+      prError = PR_NOT_SOCKET_ERROR;\n+      break;\n+    case WSAEOPNOTSUPP:\n+      prError = PR_OPERATION_NOT_SUPPORTED_ERROR;\n+      break;\n+    case WSAEPROTONOSUPPORT:\n+      prError = PR_PROTOCOL_NOT_SUPPORTED_ERROR;\n+      break;\n+    case WSAEPROTOTYPE:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    case WSAESHUTDOWN:\n+      prError = PR_SOCKET_SHUTDOWN_ERROR;\n+      break;\n+    case WSAESOCKTNOSUPPORT:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    case WSAETIMEDOUT:\n+      prError = PR_CONNECT_ABORTED_ERROR;\n+      break;\n+    case WSAEWOULDBLOCK:\n+      prError = PR_WOULD_BLOCK_ERROR;\n+      break;\n+    default:\n+      prError = PR_UNKNOWN_ERROR;\n+      break;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_win32_map_opendir_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n+}\n+\n+void _MD_win32_map_closedir_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n+}\n+\n+void _MD_unix_readdir_error(PRInt32 err) { _MD_win32_map_default_error(err); }\n+\n+void _MD_win32_map_delete_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n }\n \n /* The error code for stat() is in errno. */\n-void\n-_MD_win32_map_stat_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_errno(err);\n-}\n+void _MD_win32_map_stat_error(PRInt32 err) { _MD_win32_map_default_errno(err); }\n \n-void\n-_MD_win32_map_fstat_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n+void _MD_win32_map_fstat_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n }\n \n-void\n-_MD_win32_map_rename_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n+void _MD_win32_map_rename_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n }\n \n /* The error code for access() is in errno. */\n-void\n-_MD_win32_map_access_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_errno(err);\n+void _MD_win32_map_access_error(PRInt32 err) {\n+  _MD_win32_map_default_errno(err);\n }\n \n-void\n-_MD_win32_map_mkdir_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n+void _MD_win32_map_mkdir_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n }\n \n-void\n-_MD_win32_map_rmdir_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n+void _MD_win32_map_rmdir_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n }\n \n-void\n-_MD_win32_map_read_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n-}\n+void _MD_win32_map_read_error(PRInt32 err) { _MD_win32_map_default_error(err); }\n \n-void\n-_MD_win32_map_transmitfile_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n+void _MD_win32_map_transmitfile_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n }\n \n-void\n-_MD_win32_map_write_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n+void _MD_win32_map_write_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n }\n \n-void\n-_MD_win32_map_lseek_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n+void _MD_win32_map_lseek_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n }\n \n-void\n-_MD_win32_map_fsync_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n+void _MD_win32_map_fsync_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n }\n \n /*\n  * For both CloseHandle() and closesocket().\n  */\n-void\n-_MD_win32_map_close_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n-}\n-\n-void\n-_MD_win32_map_socket_error(PRInt32 err)\n-{\n-    PR_ASSERT(err != WSANOTINITIALISED);\n-    _MD_win32_map_default_error(err);\n-}\n-\n-void\n-_MD_win32_map_recv_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n-}\n-\n-void\n-_MD_win32_map_recvfrom_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n-}\n-\n-void\n-_MD_win32_map_send_error(PRInt32 err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case WSAEMSGSIZE:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        default:\n-            _MD_win32_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_win32_map_sendto_error(PRInt32 err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case WSAEMSGSIZE:\n-            prError = PR_INVALID_ARGUMENT_ERROR;\n-            break;\n-        default:\n-            _MD_win32_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_win32_map_accept_error(PRInt32 err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case WSAEOPNOTSUPP:\n-            prError = PR_NOT_TCP_SOCKET_ERROR;\n-            break;\n-        case WSAEINVAL:\n-            prError = PR_INVALID_STATE_ERROR;\n-            break;\n-        default:\n-            _MD_win32_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_win32_map_acceptex_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n-}\n-\n-void\n-_MD_win32_map_connect_error(PRInt32 err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case WSAEWOULDBLOCK:\n-            prError = PR_IN_PROGRESS_ERROR;\n-            break;\n-        case WSAEINVAL:\n-            prError = PR_ALREADY_INITIATED_ERROR;\n-            break;\n-        case WSAETIMEDOUT:\n-            prError = PR_IO_TIMEOUT_ERROR;\n-            break;\n-        default:\n-            _MD_win32_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_win32_map_bind_error(PRInt32 err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case WSAEINVAL:\n-            prError = PR_SOCKET_ADDRESS_IS_BOUND_ERROR;\n-            break;\n-        default:\n-            _MD_win32_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_win32_map_listen_error(PRInt32 err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case WSAEOPNOTSUPP:\n-            prError = PR_NOT_TCP_SOCKET_ERROR;\n-            break;\n-        case WSAEINVAL:\n-            prError = PR_INVALID_STATE_ERROR;\n-            break;\n-        default:\n-            _MD_win32_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_win32_map_shutdown_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n-}\n-\n-void\n-_MD_win32_map_getsockname_error(PRInt32 err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case WSAEINVAL:\n-            prError = PR_INVALID_STATE_ERROR;\n-            break;\n-        default:\n-            _MD_win32_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_win32_map_getpeername_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n-}\n-\n-void\n-_MD_win32_map_getsockopt_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n-}\n-\n-void\n-_MD_win32_map_setsockopt_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n-}\n-\n-void\n-_MD_win32_map_open_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n-}\n-\n-void\n-_MD_win32_map_gethostname_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n+void _MD_win32_map_close_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n+}\n+\n+void _MD_win32_map_socket_error(PRInt32 err) {\n+  PR_ASSERT(err != WSANOTINITIALISED);\n+  _MD_win32_map_default_error(err);\n+}\n+\n+void _MD_win32_map_recv_error(PRInt32 err) { _MD_win32_map_default_error(err); }\n+\n+void _MD_win32_map_recvfrom_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n+}\n+\n+void _MD_win32_map_send_error(PRInt32 err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case WSAEMSGSIZE:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    default:\n+      _MD_win32_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_win32_map_sendto_error(PRInt32 err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case WSAEMSGSIZE:\n+      prError = PR_INVALID_ARGUMENT_ERROR;\n+      break;\n+    default:\n+      _MD_win32_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_win32_map_accept_error(PRInt32 err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case WSAEOPNOTSUPP:\n+      prError = PR_NOT_TCP_SOCKET_ERROR;\n+      break;\n+    case WSAEINVAL:\n+      prError = PR_INVALID_STATE_ERROR;\n+      break;\n+    default:\n+      _MD_win32_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_win32_map_acceptex_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n+}\n+\n+void _MD_win32_map_connect_error(PRInt32 err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case WSAEWOULDBLOCK:\n+      prError = PR_IN_PROGRESS_ERROR;\n+      break;\n+    case WSAEINVAL:\n+      prError = PR_ALREADY_INITIATED_ERROR;\n+      break;\n+    case WSAETIMEDOUT:\n+      prError = PR_IO_TIMEOUT_ERROR;\n+      break;\n+    default:\n+      _MD_win32_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_win32_map_bind_error(PRInt32 err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case WSAEINVAL:\n+      prError = PR_SOCKET_ADDRESS_IS_BOUND_ERROR;\n+      break;\n+    default:\n+      _MD_win32_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_win32_map_listen_error(PRInt32 err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case WSAEOPNOTSUPP:\n+      prError = PR_NOT_TCP_SOCKET_ERROR;\n+      break;\n+    case WSAEINVAL:\n+      prError = PR_INVALID_STATE_ERROR;\n+      break;\n+    default:\n+      _MD_win32_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_win32_map_shutdown_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n+}\n+\n+void _MD_win32_map_getsockname_error(PRInt32 err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case WSAEINVAL:\n+      prError = PR_INVALID_STATE_ERROR;\n+      break;\n+    default:\n+      _MD_win32_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_win32_map_getpeername_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n+}\n+\n+void _MD_win32_map_getsockopt_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n+}\n+\n+void _MD_win32_map_setsockopt_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n+}\n+\n+void _MD_win32_map_open_error(PRInt32 err) { _MD_win32_map_default_error(err); }\n+\n+void _MD_win32_map_gethostname_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n }\n \n /* Win32 select() only works on sockets.  So in this\n ** context, WSAENOTSOCK is equivalent to EBADF on Unix.\n */\n-void\n-_MD_win32_map_select_error(PRInt32 err)\n-{\n-    PRErrorCode prError;\n-\n-    switch (err) {\n-        case WSAENOTSOCK:\n-            prError = PR_BAD_DESCRIPTOR_ERROR;\n-            break;\n-        default:\n-            _MD_win32_map_default_error(err);\n-            return;\n-    }\n-    PR_SetError(prError, err);\n-}\n-\n-void\n-_MD_win32_map_lockf_error(PRInt32 err)\n-{\n-    _MD_win32_map_default_error(err);\n+void _MD_win32_map_select_error(PRInt32 err) {\n+  PRErrorCode prError;\n+\n+  switch (err) {\n+    case WSAENOTSOCK:\n+      prError = PR_BAD_DESCRIPTOR_ERROR;\n+      break;\n+    default:\n+      _MD_win32_map_default_error(err);\n+      return;\n+  }\n+  PR_SetError(prError, err);\n+}\n+\n+void _MD_win32_map_lockf_error(PRInt32 err) {\n+  _MD_win32_map_default_error(err);\n }\ndiff --git a/nspr/pr/src/memory/.cvsignore b/nspr/pr/src/memory/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/src/memory/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/src/memory/prseg.c b/nspr/pr/src/memory/prseg.c\nindex f0523ae..2b49789 100644\n--- a/nspr/pr/src/memory/prseg.c\n+++ b/nspr/pr/src/memory/prseg.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,18 +10,11 @@\n /*\n ** The pthreads version doesn't use these functions.\n */\n-void\n-_PR_InitSegs(void)\n-{\n-}\n+void _PR_InitSegs(void) {}\n \n #else /* _PR_PTHREADS */\n \n-void\n-_PR_InitSegs(void)\n-{\n-    _PR_MD_INIT_SEGS();\n-}\n+void _PR_InitSegs(void) { _PR_MD_INIT_SEGS(); }\n \n /*\n ** Allocate a memory segment. The size value is rounded up to the native\n@@ -28,37 +22,33 @@ _PR_InitSegs(void)\n ** This memory is not part of the malloc heap. If \"vaddr\" is not NULL\n ** then PR tries to allocate the segment at the desired virtual address.\n */\n-PRSegment*\n-_PR_NewSegment(PRUint32 size, void* vaddr)\n-{\n-    PRSegment* seg;\n-\n-    /* calloc the data structure for the segment */\n-    seg = PR_NEWZAP(PRSegment);\n-\n-    if (seg) {\n-        size = ((size + _pr_pageSize - 1) >> _pr_pageShift) << _pr_pageShift;\n-        /*\n-        **  Now, allocate the actual segment memory (or map under some OS)\n-        **  The OS specific code decides from where or how to allocate memory.\n-        */\n-        if (_PR_MD_ALLOC_SEGMENT(seg, size, vaddr) != PR_SUCCESS) {\n-            PR_DELETE(seg);\n-            return NULL;\n-        }\n+PRSegment* _PR_NewSegment(PRUint32 size, void* vaddr) {\n+  PRSegment* seg;\n+\n+  /* calloc the data structure for the segment */\n+  seg = PR_NEWZAP(PRSegment);\n+\n+  if (seg) {\n+    size = ((size + _pr_pageSize - 1) >> _pr_pageShift) << _pr_pageShift;\n+    /*\n+    **  Now, allocate the actual segment memory (or map under some OS)\n+    **  The OS specific code decides from where or how to allocate memory.\n+    */\n+    if (_PR_MD_ALLOC_SEGMENT(seg, size, vaddr) != PR_SUCCESS) {\n+      PR_DELETE(seg);\n+      return NULL;\n     }\n+  }\n \n-    return seg;\n+  return seg;\n }\n \n /*\n ** Free a memory segment.\n */\n-void\n-_PR_DestroySegment(PRSegment* seg)\n-{\n-    _PR_MD_FREE_SEGMENT(seg);\n-    PR_DELETE(seg);\n+void _PR_DestroySegment(PRSegment* seg) {\n+  _PR_MD_FREE_SEGMENT(seg);\n+  PR_DELETE(seg);\n }\n \n #endif /* _PR_PTHREADS */\ndiff --git a/nspr/pr/src/memory/prshm.c b/nspr/pr/src/memory/prshm.c\nindex 3ce3f6a..5e542f2 100644\n--- a/nspr/pr/src/memory/prshm.c\n+++ b/nspr/pr/src/memory/prshm.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -22,40 +23,30 @@ extern PRLogModuleInfo* _pr_shm_lm;\n /*\n **  there is no named_shared_memory\n */\n-extern PRSharedMemory*\n-_MD_OpenSharedMemory(const char* name, PRSize size,\n-                     PRIntn flags, PRIntn mode)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return NULL;\n+extern PRSharedMemory* _MD_OpenSharedMemory(const char* name, PRSize size,\n+                                            PRIntn flags, PRIntn mode) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return NULL;\n }\n \n-extern void*\n-_MD_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return NULL;\n+extern void* _MD_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return NULL;\n }\n \n-extern PRStatus\n-_MD_DetachSharedMemory(PRSharedMemory* shm, void* addr)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+extern PRStatus _MD_DetachSharedMemory(PRSharedMemory* shm, void* addr) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n \n-extern PRStatus\n-_MD_CloseSharedMemory(PRSharedMemory* shm)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+extern PRStatus _MD_CloseSharedMemory(PRSharedMemory* shm) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n \n-extern PRStatus\n-_MD_DeleteSharedMemory(const char* name)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+extern PRStatus _MD_DeleteSharedMemory(const char* name) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n #endif /* HAVE_SYSV_NAMED_SHARED_MEMORY */\n \n@@ -64,12 +55,11 @@ _MD_DeleteSharedMemory(const char* name)\n **\n */\n PR_IMPLEMENT(PRSharedMemory*)\n-PR_OpenSharedMemory(const char* name, PRSize size, PRIntn flags, PRIntn mode)\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    return (_PR_MD_OPEN_SHARED_MEMORY(name, size, flags, mode));\n+PR_OpenSharedMemory(const char* name, PRSize size, PRIntn flags, PRIntn mode) {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  return (_PR_MD_OPEN_SHARED_MEMORY(name, size, flags, mode));\n } /* end PR_OpenSharedMemory() */\n \n /*\n@@ -77,9 +67,8 @@ PR_OpenSharedMemory(const char* name, PRSize size, PRIntn flags, PRIntn mode)\n **\n */\n PR_IMPLEMENT(void*)\n-PR_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags)\n-{\n-    return (_PR_MD_ATTACH_SHARED_MEMORY(shm, flags));\n+PR_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags) {\n+  return (_PR_MD_ATTACH_SHARED_MEMORY(shm, flags));\n } /* end PR_AttachSharedMemory() */\n \n /*\n@@ -87,9 +76,8 @@ PR_AttachSharedMemory(PRSharedMemory* shm, PRIntn flags)\n **\n */\n PR_IMPLEMENT(PRStatus)\n-PR_DetachSharedMemory(PRSharedMemory* shm, void* addr)\n-{\n-    return (_PR_MD_DETACH_SHARED_MEMORY(shm, addr));\n+PR_DetachSharedMemory(PRSharedMemory* shm, void* addr) {\n+  return (_PR_MD_DETACH_SHARED_MEMORY(shm, addr));\n } /* end PR_DetachSharedMemory() */\n \n /*\n@@ -97,9 +85,8 @@ PR_DetachSharedMemory(PRSharedMemory* shm, void* addr)\n **\n */\n PR_IMPLEMENT(PRStatus)\n-PR_CloseSharedMemory(PRSharedMemory* shm)\n-{\n-    return (_PR_MD_CLOSE_SHARED_MEMORY(shm));\n+PR_CloseSharedMemory(PRSharedMemory* shm) {\n+  return (_PR_MD_CLOSE_SHARED_MEMORY(shm));\n } /* end PR_CloseSharedMemory() */\n \n /*\n@@ -107,11 +94,10 @@ PR_CloseSharedMemory(PRSharedMemory* shm)\n **\n */\n PR_EXTERN(PRStatus)\n-PR_DeleteSharedMemory(const char* name)\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    return (_PR_MD_DELETE_SHARED_MEMORY(name));\n+PR_DeleteSharedMemory(const char* name) {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  return (_PR_MD_DELETE_SHARED_MEMORY(name));\n } /* end PR_DestroySharedMemory() */\n /* end prshm.c */\ndiff --git a/nspr/pr/src/memory/prshma.c b/nspr/pr/src/memory/prshma.c\nindex b37dc3e..bb59ed4 100644\n--- a/nspr/pr/src/memory/prshma.c\n+++ b/nspr/pr/src/memory/prshma.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -17,25 +18,19 @@ extern PRLogModuleInfo* _pr_shma_lm;\n #elif defined(WIN32)\n /* defined in pr/src/md/windows/w32shm.c */\n #else\n-extern PRFileMap*\n-_PR_MD_OPEN_ANON_FILE_MAP(const char* dirName, PRSize size,\n-                          PRFileMapProtect prot)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return NULL;\n+extern PRFileMap* _PR_MD_OPEN_ANON_FILE_MAP(const char* dirName, PRSize size,\n+                                            PRFileMapProtect prot) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return NULL;\n }\n-extern PRStatus\n-_PR_MD_EXPORT_FILE_MAP_AS_STRING(PRFileMap* fm, PRSize bufSize,\n-                                 char* buf)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+extern PRStatus _PR_MD_EXPORT_FILE_MAP_AS_STRING(PRFileMap* fm, PRSize bufSize,\n+                                                 char* buf) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n-extern PRFileMap*\n-_PR_MD_IMPORT_FILE_MAP_FROM_STRING(const char* fmstring)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return NULL;\n+extern PRFileMap* _PR_MD_IMPORT_FILE_MAP_FROM_STRING(const char* fmstring) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return NULL;\n }\n #endif\n \n@@ -44,9 +39,8 @@ _PR_MD_IMPORT_FILE_MAP_FROM_STRING(const char* fmstring)\n **\n */\n PR_IMPLEMENT(PRFileMap*)\n-PR_OpenAnonFileMap(const char* dirName, PRSize size, PRFileMapProtect prot)\n-{\n-    return (_PR_MD_OPEN_ANON_FILE_MAP(dirName, size, prot));\n+PR_OpenAnonFileMap(const char* dirName, PRSize size, PRFileMapProtect prot) {\n+  return (_PR_MD_OPEN_ANON_FILE_MAP(dirName, size, prot));\n } /* end PR_OpenAnonFileMap() */\n \n /*\n@@ -57,10 +51,9 @@ PR_OpenAnonFileMap(const char* dirName, PRSize size, PRFileMapProtect prot)\n */\n PR_IMPLEMENT(PRStatus)\n PR_ProcessAttrSetInheritableFileMap(PRProcessAttr* attr, PRFileMap* fm,\n-                                    const char* shmname)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return (PR_FAILURE);\n+                                    const char* shmname) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return (PR_FAILURE);\n } /* end PR_ProcessAttrSetInheritableFileMap() */\n \n /*\n@@ -69,11 +62,10 @@ PR_ProcessAttrSetInheritableFileMap(PRProcessAttr* attr, PRFileMap* fm,\n **\n */\n PR_IMPLEMENT(PRFileMap*)\n-PR_GetInheritedFileMap(const char* shmname)\n-{\n-    PRFileMap* fm = NULL;\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return (fm);\n+PR_GetInheritedFileMap(const char* shmname) {\n+  PRFileMap* fm = NULL;\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return (fm);\n } /* end PR_GetInhteritedFileMap() */\n \n /*\n@@ -81,9 +73,8 @@ PR_GetInheritedFileMap(const char* shmname)\n **\n */\n PR_IMPLEMENT(PRStatus)\n-PR_ExportFileMapAsString(PRFileMap* fm, PRSize bufSize, char* buf)\n-{\n-    return (_PR_MD_EXPORT_FILE_MAP_AS_STRING(fm, bufSize, buf));\n+PR_ExportFileMapAsString(PRFileMap* fm, PRSize bufSize, char* buf) {\n+  return (_PR_MD_EXPORT_FILE_MAP_AS_STRING(fm, bufSize, buf));\n } /* end PR_ExportFileMapAsString() */\n \n /*\n@@ -93,8 +84,7 @@ PR_ExportFileMapAsString(PRFileMap* fm, PRSize bufSize, char* buf)\n **\n */\n PR_IMPLEMENT(PRFileMap*)\n-PR_ImportFileMapFromString(const char* fmstring)\n-{\n-    return (_PR_MD_IMPORT_FILE_MAP_FROM_STRING(fmstring));\n+PR_ImportFileMapFromString(const char* fmstring) {\n+  return (_PR_MD_IMPORT_FILE_MAP_FROM_STRING(fmstring));\n } /* end PR_ImportFileMapFromString() */\n /* end prshma.c */\ndiff --git a/nspr/pr/src/misc/.cvsignore b/nspr/pr/src/misc/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/src/misc/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/src/misc/dtoa.c b/nspr/pr/src/misc/dtoa.c\nindex 67880c7..2ec38d6 100644\n--- a/nspr/pr/src/misc/dtoa.c\n+++ b/nspr/pr/src/misc/dtoa.c\n@@ -186,18 +186,18 @@\n  */\n \n #ifndef Long\n-#define Long long\n+#  define Long long\n #endif\n #ifndef ULong\n typedef unsigned Long ULong;\n #endif\n \n #ifdef DEBUG\n-#include \"stdio.h\"\n-#define Bug(x)                      \\\n-    {                               \\\n-        fprintf(stderr, \"%s\\n\", x); \\\n-        exit(1);                    \\\n+#  include \"stdio.h\"\n+#  define Bug(x)                  \\\n+    {                             \\\n+      fprintf(stderr, \"%s\\n\", x); \\\n+      exit(1);                    \\\n     }\n #endif\n \n@@ -205,89 +205,89 @@ typedef unsigned Long ULong;\n #include \"string.h\"\n \n #ifdef USE_LOCALE\n-#include \"locale.h\"\n+#  include \"locale.h\"\n #endif\n \n #ifdef Honor_FLT_ROUNDS\n-#ifndef Trust_FLT_ROUNDS\n-#include <fenv.h>\n-#endif\n+#  ifndef Trust_FLT_ROUNDS\n+#    include <fenv.h>\n+#  endif\n #endif\n \n #ifdef MALLOC\n-#ifdef KR_headers\n+#  ifdef KR_headers\n extern char* MALLOC();\n-#else\n+#  else\n extern void* MALLOC(size_t);\n-#endif\n+#  endif\n #else\n-#define MALLOC malloc\n+#  define MALLOC malloc\n #endif\n \n #ifndef Omit_Private_Memory\n-#ifndef PRIVATE_MEM\n-#define PRIVATE_MEM 2304\n-#endif\n-#define PRIVATE_mem ((PRIVATE_MEM + sizeof(double) - 1) / sizeof(double))\n+#  ifndef PRIVATE_MEM\n+#    define PRIVATE_MEM 2304\n+#  endif\n+#  define PRIVATE_mem ((PRIVATE_MEM + sizeof(double) - 1) / sizeof(double))\n static double private_mem[PRIVATE_mem], *pmem_next = private_mem;\n #endif\n \n #undef IEEE_Arith\n #undef Avoid_Underflow\n #ifdef IEEE_MC68k\n-#define IEEE_Arith\n+#  define IEEE_Arith\n #endif\n #ifdef IEEE_8087\n-#define IEEE_Arith\n+#  define IEEE_Arith\n #endif\n \n #ifdef IEEE_Arith\n-#ifndef NO_INFNAN_CHECK\n-#undef INFNAN_CHECK\n-#define INFNAN_CHECK\n-#endif\n+#  ifndef NO_INFNAN_CHECK\n+#    undef INFNAN_CHECK\n+#    define INFNAN_CHECK\n+#  endif\n #else\n-#undef INFNAN_CHECK\n-#define NO_STRTOD_BIGCOMP\n+#  undef INFNAN_CHECK\n+#  define NO_STRTOD_BIGCOMP\n #endif\n \n #include \"errno.h\"\n \n #ifdef Bad_float_h\n \n-#ifdef IEEE_Arith\n-#define DBL_DIG 15\n-#define DBL_MAX_10_EXP 308\n-#define DBL_MAX_EXP 1024\n-#define FLT_RADIX 2\n-#endif /*IEEE_Arith*/\n-\n-#ifdef IBM\n-#define DBL_DIG 16\n-#define DBL_MAX_10_EXP 75\n-#define DBL_MAX_EXP 63\n-#define FLT_RADIX 16\n-#define DBL_MAX 7.2370055773322621e+75\n-#endif\n-\n-#ifdef VAX\n-#define DBL_DIG 16\n-#define DBL_MAX_10_EXP 38\n-#define DBL_MAX_EXP 127\n-#define FLT_RADIX 2\n-#define DBL_MAX 1.7014118346046923e+38\n-#endif\n-\n-#ifndef LONG_MAX\n-#define LONG_MAX 2147483647\n-#endif\n+#  ifdef IEEE_Arith\n+#    define DBL_DIG 15\n+#    define DBL_MAX_10_EXP 308\n+#    define DBL_MAX_EXP 1024\n+#    define FLT_RADIX 2\n+#  endif /*IEEE_Arith*/\n+\n+#  ifdef IBM\n+#    define DBL_DIG 16\n+#    define DBL_MAX_10_EXP 75\n+#    define DBL_MAX_EXP 63\n+#    define FLT_RADIX 16\n+#    define DBL_MAX 7.2370055773322621e+75\n+#  endif\n+\n+#  ifdef VAX\n+#    define DBL_DIG 16\n+#    define DBL_MAX_10_EXP 38\n+#    define DBL_MAX_EXP 127\n+#    define FLT_RADIX 2\n+#    define DBL_MAX 1.7014118346046923e+38\n+#  endif\n+\n+#  ifndef LONG_MAX\n+#    define LONG_MAX 2147483647\n+#  endif\n \n #else /* ifndef Bad_float_h */\n-#include \"float.h\"\n+#  include \"float.h\"\n #endif /* Bad_float_h */\n \n #ifndef __MATH_H__\n-#include \"math.h\"\n+#  include \"math.h\"\n #endif\n \n #ifdef __cplusplus\n@@ -295,40 +295,39 @@ extern \"C\" {\n #endif\n \n #ifndef CONST\n-#ifdef KR_headers\n-#define CONST /* blank */\n-#else\n-#define CONST const\n-#endif\n+#  ifdef KR_headers\n+#    define CONST /* blank */\n+#  else\n+#    define CONST const\n+#  endif\n #endif\n \n #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1\n-Exactly one of IEEE_8087, IEEE_MC68k, VAX,\n-    or IBM should be defined.\n+Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.\n #endif\n \n-        typedef union {\n-    double d;\n-    ULong L[2];\n+                                               typedef union {\n+  double d;\n+  ULong L[2];\n } U;\n \n #ifdef IEEE_8087\n-#define word0(x) (x)->L[1]\n-#define word1(x) (x)->L[0]\n+#  define word0(x) (x)->L[1]\n+#  define word1(x) (x)->L[0]\n #else\n-#define word0(x) (x)->L[0]\n-#define word1(x) (x)->L[1]\n+#  define word0(x) (x)->L[0]\n+#  define word1(x) (x)->L[1]\n #endif\n #define dval(x) (x)->d\n \n #ifndef STRTOD_DIGLIM\n-#define STRTOD_DIGLIM 40\n+#  define STRTOD_DIGLIM 40\n #endif\n \n #ifdef DIGLIM_DEBUG\n extern int strtod_diglim;\n #else\n-#define strtod_diglim STRTOD_DIGLIM\n+#  define strtod_diglim STRTOD_DIGLIM\n #endif\n \n /* The following definition of Storeinc is appropriate for MIPS processors.\n@@ -336,11 +335,11 @@ extern int strtod_diglim;\n  * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)\n  */\n #if defined(IEEE_8087) + defined(VAX)\n-#define Storeinc(a, b, c)                         \\\n+#  define Storeinc(a, b, c)                       \\\n     (((unsigned short*)a)[1] = (unsigned short)b, \\\n      ((unsigned short*)a)[0] = (unsigned short)c, a++)\n #else\n-#define Storeinc(a, b, c)                         \\\n+#  define Storeinc(a, b, c)                       \\\n     (((unsigned short*)a)[0] = (unsigned short)b, \\\n      ((unsigned short*)a)[1] = (unsigned short)c, a++)\n #endif\n@@ -352,183 +351,183 @@ extern int strtod_diglim;\n /* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */\n \n #ifdef IEEE_Arith\n-#define Exp_shift 20\n-#define Exp_shift1 20\n-#define Exp_msk1 0x100000\n-#define Exp_msk11 0x100000\n-#define Exp_mask 0x7ff00000\n-#define P 53\n-#define Nbits 53\n-#define Bias 1023\n-#define Emax 1023\n-#define Emin (-1022)\n-#define Exp_1 0x3ff00000\n-#define Exp_11 0x3ff00000\n-#define Ebits 11\n-#define Frac_mask 0xfffff\n-#define Frac_mask1 0xfffff\n-#define Ten_pmax 22\n-#define Bletch 0x10\n-#define Bndry_mask 0xfffff\n-#define Bndry_mask1 0xfffff\n-#define LSB 1\n-#define Sign_bit 0x80000000\n-#define Log2P 1\n-#define Tiny0 0\n-#define Tiny1 1\n-#define Quick_max 14\n-#define Int_max 14\n-#ifndef NO_IEEE_Scale\n-#define Avoid_Underflow\n-#ifdef Flush_Denorm /* debugging option */\n-#undef Sudden_Underflow\n-#endif\n-#endif\n-\n-#ifndef Flt_Rounds\n-#ifdef FLT_ROUNDS\n-#define Flt_Rounds FLT_ROUNDS\n-#else\n-#define Flt_Rounds 1\n-#endif\n-#endif /*Flt_Rounds*/\n-\n-#ifdef Honor_FLT_ROUNDS\n-#undef Check_FLT_ROUNDS\n-#define Check_FLT_ROUNDS\n-#else\n-#define Rounding Flt_Rounds\n-#endif\n+#  define Exp_shift 20\n+#  define Exp_shift1 20\n+#  define Exp_msk1 0x100000\n+#  define Exp_msk11 0x100000\n+#  define Exp_mask 0x7ff00000\n+#  define P 53\n+#  define Nbits 53\n+#  define Bias 1023\n+#  define Emax 1023\n+#  define Emin (-1022)\n+#  define Exp_1 0x3ff00000\n+#  define Exp_11 0x3ff00000\n+#  define Ebits 11\n+#  define Frac_mask 0xfffff\n+#  define Frac_mask1 0xfffff\n+#  define Ten_pmax 22\n+#  define Bletch 0x10\n+#  define Bndry_mask 0xfffff\n+#  define Bndry_mask1 0xfffff\n+#  define LSB 1\n+#  define Sign_bit 0x80000000\n+#  define Log2P 1\n+#  define Tiny0 0\n+#  define Tiny1 1\n+#  define Quick_max 14\n+#  define Int_max 14\n+#  ifndef NO_IEEE_Scale\n+#    define Avoid_Underflow\n+#    ifdef Flush_Denorm /* debugging option */\n+#      undef Sudden_Underflow\n+#    endif\n+#  endif\n+\n+#  ifndef Flt_Rounds\n+#    ifdef FLT_ROUNDS\n+#      define Flt_Rounds FLT_ROUNDS\n+#    else\n+#      define Flt_Rounds 1\n+#    endif\n+#  endif /*Flt_Rounds*/\n+\n+#  ifdef Honor_FLT_ROUNDS\n+#    undef Check_FLT_ROUNDS\n+#    define Check_FLT_ROUNDS\n+#  else\n+#    define Rounding Flt_Rounds\n+#  endif\n \n #else /* ifndef IEEE_Arith */\n-#undef Check_FLT_ROUNDS\n-#undef Honor_FLT_ROUNDS\n-#undef SET_INEXACT\n-#undef Sudden_Underflow\n-#define Sudden_Underflow\n-#ifdef IBM\n-#undef Flt_Rounds\n-#define Flt_Rounds 0\n-#define Exp_shift 24\n-#define Exp_shift1 24\n-#define Exp_msk1 0x1000000\n-#define Exp_msk11 0x1000000\n-#define Exp_mask 0x7f000000\n-#define P 14\n-#define Nbits 56\n-#define Bias 65\n-#define Emax 248\n-#define Emin (-260)\n-#define Exp_1 0x41000000\n-#define Exp_11 0x41000000\n-#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */\n-#define Frac_mask 0xffffff\n-#define Frac_mask1 0xffffff\n-#define Bletch 4\n-#define Ten_pmax 22\n-#define Bndry_mask 0xefffff\n-#define Bndry_mask1 0xffffff\n-#define LSB 1\n-#define Sign_bit 0x80000000\n-#define Log2P 4\n-#define Tiny0 0x100000\n-#define Tiny1 0\n-#define Quick_max 14\n-#define Int_max 15\n-#else /* VAX */\n-#undef Flt_Rounds\n-#define Flt_Rounds 1\n-#define Exp_shift 23\n-#define Exp_shift1 7\n-#define Exp_msk1 0x80\n-#define Exp_msk11 0x800000\n-#define Exp_mask 0x7f80\n-#define P 56\n-#define Nbits 56\n-#define Bias 129\n-#define Emax 126\n-#define Emin (-129)\n-#define Exp_1 0x40800000\n-#define Exp_11 0x4080\n-#define Ebits 8\n-#define Frac_mask 0x7fffff\n-#define Frac_mask1 0xffff007f\n-#define Ten_pmax 24\n-#define Bletch 2\n-#define Bndry_mask 0xffff007f\n-#define Bndry_mask1 0xffff007f\n-#define LSB 0x10000\n-#define Sign_bit 0x8000\n-#define Log2P 1\n-#define Tiny0 0x80\n-#define Tiny1 0\n-#define Quick_max 15\n-#define Int_max 15\n-#endif /* IBM, VAX */\n-#endif /* IEEE_Arith */\n+#  undef Check_FLT_ROUNDS\n+#  undef Honor_FLT_ROUNDS\n+#  undef SET_INEXACT\n+#  undef Sudden_Underflow\n+#  define Sudden_Underflow\n+#  ifdef IBM\n+#    undef Flt_Rounds\n+#    define Flt_Rounds 0\n+#    define Exp_shift 24\n+#    define Exp_shift1 24\n+#    define Exp_msk1 0x1000000\n+#    define Exp_msk11 0x1000000\n+#    define Exp_mask 0x7f000000\n+#    define P 14\n+#    define Nbits 56\n+#    define Bias 65\n+#    define Emax 248\n+#    define Emin (-260)\n+#    define Exp_1 0x41000000\n+#    define Exp_11 0x41000000\n+#    define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */\n+#    define Frac_mask 0xffffff\n+#    define Frac_mask1 0xffffff\n+#    define Bletch 4\n+#    define Ten_pmax 22\n+#    define Bndry_mask 0xefffff\n+#    define Bndry_mask1 0xffffff\n+#    define LSB 1\n+#    define Sign_bit 0x80000000\n+#    define Log2P 4\n+#    define Tiny0 0x100000\n+#    define Tiny1 0\n+#    define Quick_max 14\n+#    define Int_max 15\n+#  else /* VAX */\n+#    undef Flt_Rounds\n+#    define Flt_Rounds 1\n+#    define Exp_shift 23\n+#    define Exp_shift1 7\n+#    define Exp_msk1 0x80\n+#    define Exp_msk11 0x800000\n+#    define Exp_mask 0x7f80\n+#    define P 56\n+#    define Nbits 56\n+#    define Bias 129\n+#    define Emax 126\n+#    define Emin (-129)\n+#    define Exp_1 0x40800000\n+#    define Exp_11 0x4080\n+#    define Ebits 8\n+#    define Frac_mask 0x7fffff\n+#    define Frac_mask1 0xffff007f\n+#    define Ten_pmax 24\n+#    define Bletch 2\n+#    define Bndry_mask 0xffff007f\n+#    define Bndry_mask1 0xffff007f\n+#    define LSB 0x10000\n+#    define Sign_bit 0x8000\n+#    define Log2P 1\n+#    define Tiny0 0x80\n+#    define Tiny1 0\n+#    define Quick_max 15\n+#    define Int_max 15\n+#  endif /* IBM, VAX */\n+#endif   /* IEEE_Arith */\n \n #ifndef IEEE_Arith\n-#define ROUND_BIASED\n+#  define ROUND_BIASED\n #else\n-#ifdef ROUND_BIASED_without_Round_Up\n-#undef ROUND_BIASED\n-#define ROUND_BIASED\n-#endif\n+#  ifdef ROUND_BIASED_without_Round_Up\n+#    undef ROUND_BIASED\n+#    define ROUND_BIASED\n+#  endif\n #endif\n \n #ifdef RND_PRODQUOT\n-#define rounded_product(a, b) a = rnd_prod(a, b)\n-#define rounded_quotient(a, b) a = rnd_quot(a, b)\n-#ifdef KR_headers\n+#  define rounded_product(a, b) a = rnd_prod(a, b)\n+#  define rounded_quotient(a, b) a = rnd_quot(a, b)\n+#  ifdef KR_headers\n extern double rnd_prod(), rnd_quot();\n-#else\n+#  else\n extern double rnd_prod(double, double), rnd_quot(double, double);\n-#endif\n+#  endif\n #else\n-#define rounded_product(a, b) a *= b\n-#define rounded_quotient(a, b) a /= b\n+#  define rounded_product(a, b) a *= b\n+#  define rounded_quotient(a, b) a /= b\n #endif\n \n #define Big0 (Frac_mask1 | Exp_msk1 * (DBL_MAX_EXP + Bias - 1))\n #define Big1 0xffffffff\n \n #ifndef Pack_32\n-#define Pack_32\n+#  define Pack_32\n #endif\n \n typedef struct BCinfo BCinfo;\n struct BCinfo {\n-    int dp0, dp1, dplen, dsign, e0, inexact, nd, nd0, rounding, scale, uflchk;\n+  int dp0, dp1, dplen, dsign, e0, inexact, nd, nd0, rounding, scale, uflchk;\n };\n \n #ifdef KR_headers\n-#define FFFFFFFF ((((unsigned long)0xffff) << 16) | (unsigned long)0xffff)\n+#  define FFFFFFFF ((((unsigned long)0xffff) << 16) | (unsigned long)0xffff)\n #else\n-#define FFFFFFFF 0xffffffffUL\n+#  define FFFFFFFF 0xffffffffUL\n #endif\n \n #ifdef NO_LONG_LONG\n-#undef ULLong\n-#ifdef Just_16\n-#undef Pack_32\n+#  undef ULLong\n+#  ifdef Just_16\n+#    undef Pack_32\n /* When Pack_32 is not defined, we store 16 bits per 32-bit Long.\n  * This makes some inner loops simpler and sometimes saves work\n  * during multiplications, but it often seems to make things slightly\n  * slower.  Hence the default is now to store 32 bits per Long.\n  */\n-#endif\n+#  endif\n #else /* long long available */\n-#ifndef Llong\n-#define Llong long long\n-#endif\n-#ifndef ULLong\n-#define ULLong unsigned Llong\n-#endif\n+#  ifndef Llong\n+#    define Llong long long\n+#  endif\n+#  ifndef ULLong\n+#    define ULLong unsigned Llong\n+#  endif\n #endif /* NO_LONG_LONG */\n \n #ifndef MULTIPLE_THREADS\n-#define ACQUIRE_DTOA_LOCK(n) /*nothing*/\n-#define FREE_DTOA_LOCK(n)    /*nothing*/\n+#  define ACQUIRE_DTOA_LOCK(n) /*nothing*/\n+#  define FREE_DTOA_LOCK(n)    /*nothing*/\n #endif\n \n #define Kmax 7\n@@ -540,9 +539,9 @@ extern \"C\" char* dtoa(double d, int mode, int ndigits, int* decpt, int* sign,\n #endif\n \n struct Bigint {\n-    struct Bigint* next;\n-    int k, maxwds, sign, wds;\n-    ULong x[1];\n+  struct Bigint* next;\n+  int k, maxwds, sign, wds;\n+  ULong x[1];\n };\n \n typedef struct Bigint Bigint;\n@@ -556,37 +555,37 @@ static Bigint* Balloc\n     (int k)\n #endif\n {\n-    int x;\n-    Bigint* rv;\n+  int x;\n+  Bigint* rv;\n #ifndef Omit_Private_Memory\n-    unsigned int len;\n+  unsigned int len;\n #endif\n \n-    ACQUIRE_DTOA_LOCK(0);\n-    /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */\n-    /* but this case seems very unlikely. */\n-    if (k <= Kmax && (rv = freelist[k])) {\n-        freelist[k] = rv->next;\n-    } else {\n-        x = 1 << k;\n+  ACQUIRE_DTOA_LOCK(0);\n+  /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */\n+  /* but this case seems very unlikely. */\n+  if (k <= Kmax && (rv = freelist[k])) {\n+    freelist[k] = rv->next;\n+  } else {\n+    x = 1 << k;\n #ifdef Omit_Private_Memory\n-        rv = (Bigint*)MALLOC(sizeof(Bigint) + (x - 1) * sizeof(ULong));\n+    rv = (Bigint*)MALLOC(sizeof(Bigint) + (x - 1) * sizeof(ULong));\n #else\n-        len = (sizeof(Bigint) + (x - 1) * sizeof(ULong) + sizeof(double) - 1) /\n-              sizeof(double);\n-        if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) {\n-            rv = (Bigint*)pmem_next;\n-            pmem_next += len;\n-        } else {\n-            rv = (Bigint*)MALLOC(len * sizeof(double));\n-        }\n-#endif\n-        rv->k = k;\n-        rv->maxwds = x;\n+    len = (sizeof(Bigint) + (x - 1) * sizeof(ULong) + sizeof(double) - 1) /\n+          sizeof(double);\n+    if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) {\n+      rv = (Bigint*)pmem_next;\n+      pmem_next += len;\n+    } else {\n+      rv = (Bigint*)MALLOC(len * sizeof(double));\n     }\n-    FREE_DTOA_LOCK(0);\n-    rv->sign = rv->wds = 0;\n-    return rv;\n+#endif\n+    rv->k = k;\n+    rv->maxwds = x;\n+  }\n+  FREE_DTOA_LOCK(0);\n+  rv->sign = rv->wds = 0;\n+  return rv;\n }\n \n static void Bfree\n@@ -596,25 +595,25 @@ static void Bfree\n     (Bigint* v)\n #endif\n {\n-    if (v) {\n-        if (v->k > Kmax)\n+  if (v) {\n+    if (v->k > Kmax)\n #ifdef FREE\n-            FREE((void*)v);\n+      FREE((void*)v);\n #else\n-            free((void*)v);\n+      free((void*)v);\n #endif\n-        else {\n-            ACQUIRE_DTOA_LOCK(0);\n-            v->next = freelist[v->k];\n-            freelist[v->k] = v;\n-            FREE_DTOA_LOCK(0);\n-        }\n+    else {\n+      ACQUIRE_DTOA_LOCK(0);\n+      v->next = freelist[v->k];\n+      freelist[v->k] = v;\n+      FREE_DTOA_LOCK(0);\n     }\n+  }\n }\n \n-#define Bcopy(x, y)                          \\\n-    memcpy((char*)&x->sign, (char*)&y->sign, \\\n-           y->wds * sizeof(Long) + 2 * sizeof(int))\n+#define Bcopy(x, y)                        \\\n+  memcpy((char*)&x->sign, (char*)&y->sign, \\\n+         y->wds * sizeof(Long) + 2 * sizeof(int))\n \n static Bigint* multadd\n #ifdef KR_headers\n@@ -624,52 +623,52 @@ int m, a;\n     (Bigint* b, int m, int a) /* multiply by m and add a */\n #endif\n {\n-    int i, wds;\n+  int i, wds;\n #ifdef ULLong\n-    ULong* x;\n-    ULLong carry, y;\n+  ULong* x;\n+  ULLong carry, y;\n #else\n-    ULong carry, *x, y;\n-#ifdef Pack_32\n-    ULong xi, z;\n-#endif\n-#endif\n-    Bigint* b1;\n-\n-    wds = b->wds;\n-    x = b->x;\n-    i = 0;\n-    carry = a;\n-    do {\n+  ULong carry, *x, y;\n+#  ifdef Pack_32\n+  ULong xi, z;\n+#  endif\n+#endif\n+  Bigint* b1;\n+\n+  wds = b->wds;\n+  x = b->x;\n+  i = 0;\n+  carry = a;\n+  do {\n #ifdef ULLong\n-        y = *x * (ULLong)m + carry;\n-        carry = y >> 32;\n-        *x++ = y & FFFFFFFF;\n-#else\n-#ifdef Pack_32\n-        xi = *x;\n-        y = (xi & 0xffff) * m + carry;\n-        z = (xi >> 16) * m + (y >> 16);\n-        carry = z >> 16;\n-        *x++ = (z << 16) + (y & 0xffff);\n+    y = *x * (ULLong)m + carry;\n+    carry = y >> 32;\n+    *x++ = y & FFFFFFFF;\n #else\n-        y = *x * m + carry;\n-        carry = y >> 16;\n-        *x++ = y & 0xffff;\n-#endif\n-#endif\n-    } while (++i < wds);\n-    if (carry) {\n-        if (wds >= b->maxwds) {\n-            b1 = Balloc(b->k + 1);\n-            Bcopy(b1, b);\n-            Bfree(b);\n-            b = b1;\n-        }\n-        b->x[wds++] = carry;\n-        b->wds = wds;\n-    }\n-    return b;\n+#  ifdef Pack_32\n+    xi = *x;\n+    y = (xi & 0xffff) * m + carry;\n+    z = (xi >> 16) * m + (y >> 16);\n+    carry = z >> 16;\n+    *x++ = (z << 16) + (y & 0xffff);\n+#  else\n+    y = *x * m + carry;\n+    carry = y >> 16;\n+    *x++ = y & 0xffff;\n+#  endif\n+#endif\n+  } while (++i < wds);\n+  if (carry) {\n+    if (wds >= b->maxwds) {\n+      b1 = Balloc(b->k + 1);\n+      Bcopy(b1, b);\n+      Bfree(b);\n+      b = b1;\n+    }\n+    b->x[wds++] = carry;\n+    b->wds = wds;\n+  }\n+  return b;\n }\n \n static Bigint* s2b\n@@ -681,37 +680,36 @@ ULong y9;\n     (const char* s, int nd0, int nd, ULong y9, int dplen)\n #endif\n {\n-    Bigint* b;\n-    int i, k;\n-    Long x, y;\n+  Bigint* b;\n+  int i, k;\n+  Long x, y;\n \n-    x = (nd + 8) / 9;\n-    for (k = 0, y = 1; x > y; y <<= 1, k++)\n-        ;\n+  x = (nd + 8) / 9;\n+  for (k = 0, y = 1; x > y; y <<= 1, k++);\n #ifdef Pack_32\n-    b = Balloc(k);\n-    b->x[0] = y9;\n-    b->wds = 1;\n+  b = Balloc(k);\n+  b->x[0] = y9;\n+  b->wds = 1;\n #else\n-    b = Balloc(k + 1);\n-    b->x[0] = y9 & 0xffff;\n-    b->wds = (b->x[1] = y9 >> 16) ? 2 : 1;\n-#endif\n-\n-    i = 9;\n-    if (9 < nd0) {\n-        s += 9;\n-        do {\n-            b = multadd(b, 10, *s++ - '0');\n-        } while (++i < nd0);\n-        s += dplen;\n-    } else {\n-        s += dplen + 9;\n-    }\n-    for (; i < nd; i++) {\n-        b = multadd(b, 10, *s++ - '0');\n-    }\n-    return b;\n+  b = Balloc(k + 1);\n+  b->x[0] = y9 & 0xffff;\n+  b->wds = (b->x[1] = y9 >> 16) ? 2 : 1;\n+#endif\n+\n+  i = 9;\n+  if (9 < nd0) {\n+    s += 9;\n+    do {\n+      b = multadd(b, 10, *s++ - '0');\n+    } while (++i < nd0);\n+    s += dplen;\n+  } else {\n+    s += dplen + 9;\n+  }\n+  for (; i < nd; i++) {\n+    b = multadd(b, 10, *s++ - '0');\n+  }\n+  return b;\n }\n \n static int hi0bits\n@@ -721,31 +719,31 @@ static int hi0bits\n     (ULong x)\n #endif\n {\n-    int k = 0;\n-\n-    if (!(x & 0xffff0000)) {\n-        k = 16;\n-        x <<= 16;\n-    }\n-    if (!(x & 0xff000000)) {\n-        k += 8;\n-        x <<= 8;\n-    }\n-    if (!(x & 0xf0000000)) {\n-        k += 4;\n-        x <<= 4;\n-    }\n-    if (!(x & 0xc0000000)) {\n-        k += 2;\n-        x <<= 2;\n-    }\n-    if (!(x & 0x80000000)) {\n-        k++;\n-        if (!(x & 0x40000000)) {\n-            return 32;\n-        }\n+  int k = 0;\n+\n+  if (!(x & 0xffff0000)) {\n+    k = 16;\n+    x <<= 16;\n+  }\n+  if (!(x & 0xff000000)) {\n+    k += 8;\n+    x <<= 8;\n+  }\n+  if (!(x & 0xf0000000)) {\n+    k += 4;\n+    x <<= 4;\n+  }\n+  if (!(x & 0xc0000000)) {\n+    k += 2;\n+    x <<= 2;\n+  }\n+  if (!(x & 0x80000000)) {\n+    k++;\n+    if (!(x & 0x40000000)) {\n+      return 32;\n     }\n-    return k;\n+  }\n+  return k;\n }\n \n static int lo0bits\n@@ -755,46 +753,46 @@ static int lo0bits\n     (ULong* y)\n #endif\n {\n-    int k;\n-    ULong x = *y;\n-\n-    if (x & 7) {\n-        if (x & 1) {\n-            return 0;\n-        }\n-        if (x & 2) {\n-            *y = x >> 1;\n-            return 1;\n-        }\n-        *y = x >> 2;\n-        return 2;\n-    }\n-    k = 0;\n-    if (!(x & 0xffff)) {\n-        k = 16;\n-        x >>= 16;\n-    }\n-    if (!(x & 0xff)) {\n-        k += 8;\n-        x >>= 8;\n-    }\n-    if (!(x & 0xf)) {\n-        k += 4;\n-        x >>= 4;\n-    }\n-    if (!(x & 0x3)) {\n-        k += 2;\n-        x >>= 2;\n-    }\n-    if (!(x & 1)) {\n-        k++;\n-        x >>= 1;\n-        if (!x) {\n-            return 32;\n-        }\n+  int k;\n+  ULong x = *y;\n+\n+  if (x & 7) {\n+    if (x & 1) {\n+      return 0;\n+    }\n+    if (x & 2) {\n+      *y = x >> 1;\n+      return 1;\n+    }\n+    *y = x >> 2;\n+    return 2;\n+  }\n+  k = 0;\n+  if (!(x & 0xffff)) {\n+    k = 16;\n+    x >>= 16;\n+  }\n+  if (!(x & 0xff)) {\n+    k += 8;\n+    x >>= 8;\n+  }\n+  if (!(x & 0xf)) {\n+    k += 4;\n+    x >>= 4;\n+  }\n+  if (!(x & 0x3)) {\n+    k += 2;\n+    x >>= 2;\n+  }\n+  if (!(x & 1)) {\n+    k++;\n+    x >>= 1;\n+    if (!x) {\n+      return 32;\n     }\n-    *y = x;\n-    return k;\n+  }\n+  *y = x;\n+  return k;\n }\n \n static Bigint* i2b\n@@ -804,12 +802,12 @@ static Bigint* i2b\n     (int i)\n #endif\n {\n-    Bigint* b;\n+  Bigint* b;\n \n-    b = Balloc(1);\n-    b->x[0] = i;\n-    b->wds = 1;\n-    return b;\n+  b = Balloc(1);\n+  b->x[0] = i;\n+  b->wds = 1;\n+  return b;\n }\n \n static Bigint *mult\n@@ -820,105 +818,104 @@ static Bigint *mult\n     (Bigint* a, Bigint* b)\n #endif\n {\n-    Bigint* c;\n-    int k, wa, wb, wc;\n-    ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;\n-    ULong y;\n+  Bigint* c;\n+  int k, wa, wb, wc;\n+  ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;\n+  ULong y;\n #ifdef ULLong\n-    ULLong carry, z;\n+  ULLong carry, z;\n #else\n-    ULong carry, z;\n-#ifdef Pack_32\n-    ULong z2;\n-#endif\n-#endif\n-\n-    if (a->wds < b->wds) {\n-        c = a;\n-        a = b;\n-        b = c;\n-    }\n-    k = a->k;\n-    wa = a->wds;\n-    wb = b->wds;\n-    wc = wa + wb;\n-    if (wc > a->maxwds) {\n-        k++;\n-    }\n-    c = Balloc(k);\n-    for (x = c->x, xa = x + wc; x < xa; x++) {\n-        *x = 0;\n-    }\n-    xa = a->x;\n-    xae = xa + wa;\n-    xb = b->x;\n-    xbe = xb + wb;\n-    xc0 = c->x;\n+  ULong carry, z;\n+#  ifdef Pack_32\n+  ULong z2;\n+#  endif\n+#endif\n+\n+  if (a->wds < b->wds) {\n+    c = a;\n+    a = b;\n+    b = c;\n+  }\n+  k = a->k;\n+  wa = a->wds;\n+  wb = b->wds;\n+  wc = wa + wb;\n+  if (wc > a->maxwds) {\n+    k++;\n+  }\n+  c = Balloc(k);\n+  for (x = c->x, xa = x + wc; x < xa; x++) {\n+    *x = 0;\n+  }\n+  xa = a->x;\n+  xae = xa + wa;\n+  xb = b->x;\n+  xbe = xb + wb;\n+  xc0 = c->x;\n #ifdef ULLong\n-    for (; xb < xbe; xc0++) {\n-        if ((y = *xb++)) {\n-            x = xa;\n-            xc = xc0;\n-            carry = 0;\n-            do {\n-                z = *x++ * (ULLong)y + *xc + carry;\n-                carry = z >> 32;\n-                *xc++ = z & FFFFFFFF;\n-            } while (x < xae);\n-            *xc = carry;\n-        }\n-    }\n-#else\n-#ifdef Pack_32\n-    for (; xb < xbe; xb++, xc0++) {\n-        if (y = *xb & 0xffff) {\n-            x = xa;\n-            xc = xc0;\n-            carry = 0;\n-            do {\n-                z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;\n-                carry = z >> 16;\n-                z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;\n-                carry = z2 >> 16;\n-                Storeinc(xc, z2, z);\n-            } while (x < xae);\n-            *xc = carry;\n-        }\n-        if (y = *xb >> 16) {\n-            x = xa;\n-            xc = xc0;\n-            carry = 0;\n-            z2 = *xc;\n-            do {\n-                z = (*x & 0xffff) * y + (*xc >> 16) + carry;\n-                carry = z >> 16;\n-                Storeinc(xc, z, z2);\n-                z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;\n-                carry = z2 >> 16;\n-            } while (x < xae);\n-            *xc = z2;\n-        }\n-    }\n+  for (; xb < xbe; xc0++) {\n+    if ((y = *xb++)) {\n+      x = xa;\n+      xc = xc0;\n+      carry = 0;\n+      do {\n+        z = *x++ * (ULLong)y + *xc + carry;\n+        carry = z >> 32;\n+        *xc++ = z & FFFFFFFF;\n+      } while (x < xae);\n+      *xc = carry;\n+    }\n+  }\n #else\n-    for (; xb < xbe; xc0++) {\n-        if (y = *xb++) {\n-            x = xa;\n-            xc = xc0;\n-            carry = 0;\n-            do {\n-                z = *x++ * y + *xc + carry;\n-                carry = z >> 16;\n-                *xc++ = z & 0xffff;\n-            } while (x < xae);\n-            *xc = carry;\n-        }\n+#  ifdef Pack_32\n+  for (; xb < xbe; xb++, xc0++) {\n+    if (y = *xb & 0xffff) {\n+      x = xa;\n+      xc = xc0;\n+      carry = 0;\n+      do {\n+        z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;\n+        carry = z >> 16;\n+        z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;\n+        carry = z2 >> 16;\n+        Storeinc(xc, z2, z);\n+      } while (x < xae);\n+      *xc = carry;\n+    }\n+    if (y = *xb >> 16) {\n+      x = xa;\n+      xc = xc0;\n+      carry = 0;\n+      z2 = *xc;\n+      do {\n+        z = (*x & 0xffff) * y + (*xc >> 16) + carry;\n+        carry = z >> 16;\n+        Storeinc(xc, z, z2);\n+        z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;\n+        carry = z2 >> 16;\n+      } while (x < xae);\n+      *xc = z2;\n+    }\n+  }\n+#  else\n+  for (; xb < xbe; xc0++) {\n+    if (y = *xb++) {\n+      x = xa;\n+      xc = xc0;\n+      carry = 0;\n+      do {\n+        z = *x++ * y + *xc + carry;\n+        carry = z >> 16;\n+        *xc++ = z & 0xffff;\n+      } while (x < xae);\n+      *xc = carry;\n     }\n+  }\n+#  endif\n #endif\n-#endif\n-    for (xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc)\n-        ;\n-    c->wds = wc;\n-    return c;\n+  for (xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc);\n+  c->wds = wc;\n+  return c;\n }\n \n static Bigint* p5s;\n@@ -931,56 +928,56 @@ int k;\n     (Bigint* b, int k)\n #endif\n {\n-    Bigint *b1, *p5, *p51;\n-    int i;\n-    static int p05[3] = { 5, 25, 125 };\n+  Bigint *b1, *p5, *p51;\n+  int i;\n+  static int p05[3] = {5, 25, 125};\n \n-    if ((i = k & 3)) {\n-        b = multadd(b, p05[i - 1], 0);\n-    }\n+  if ((i = k & 3)) {\n+    b = multadd(b, p05[i - 1], 0);\n+  }\n \n-    if (!(k >>= 2)) {\n-        return b;\n-    }\n-    if (!(p5 = p5s)) {\n-        /* first time */\n+  if (!(k >>= 2)) {\n+    return b;\n+  }\n+  if (!(p5 = p5s)) {\n+    /* first time */\n #ifdef MULTIPLE_THREADS\n-        ACQUIRE_DTOA_LOCK(1);\n-        if (!(p5 = p5s)) {\n-            p5 = p5s = i2b(625);\n-            p5->next = 0;\n-        }\n-        FREE_DTOA_LOCK(1);\n+    ACQUIRE_DTOA_LOCK(1);\n+    if (!(p5 = p5s)) {\n+      p5 = p5s = i2b(625);\n+      p5->next = 0;\n+    }\n+    FREE_DTOA_LOCK(1);\n #else\n-        p5 = p5s = i2b(625);\n-        p5->next = 0;\n+    p5 = p5s = i2b(625);\n+    p5->next = 0;\n #endif\n+  }\n+  for (;;) {\n+    if (k & 1) {\n+      b1 = mult(b, p5);\n+      Bfree(b);\n+      b = b1;\n     }\n-    for (;;) {\n-        if (k & 1) {\n-            b1 = mult(b, p5);\n-            Bfree(b);\n-            b = b1;\n-        }\n-        if (!(k >>= 1)) {\n-            break;\n-        }\n-        if (!(p51 = p5->next)) {\n+    if (!(k >>= 1)) {\n+      break;\n+    }\n+    if (!(p51 = p5->next)) {\n #ifdef MULTIPLE_THREADS\n-            ACQUIRE_DTOA_LOCK(1);\n-            if (!(p51 = p5->next)) {\n-                p51 = p5->next = mult(p5, p5);\n-                p51->next = 0;\n-            }\n-            FREE_DTOA_LOCK(1);\n+      ACQUIRE_DTOA_LOCK(1);\n+      if (!(p51 = p5->next)) {\n+        p51 = p5->next = mult(p5, p5);\n+        p51->next = 0;\n+      }\n+      FREE_DTOA_LOCK(1);\n #else\n-            p51 = p5->next = mult(p5, p5);\n-            p51->next = 0;\n+      p51 = p5->next = mult(p5, p5);\n+      p51->next = 0;\n #endif\n-        }\n-        p5 = p51;\n     }\n-    return b;\n+    p5 = p51;\n+  }\n+  return b;\n }\n \n static Bigint* lshift\n@@ -991,59 +988,59 @@ int k;\n     (Bigint* b, int k)\n #endif\n {\n-    int i, k1, n, n1;\n-    Bigint* b1;\n-    ULong *x, *x1, *xe, z;\n+  int i, k1, n, n1;\n+  Bigint* b1;\n+  ULong *x, *x1, *xe, z;\n \n #ifdef Pack_32\n-    n = k >> 5;\n+  n = k >> 5;\n #else\n-    n = k >> 4;\n-#endif\n-    k1 = b->k;\n-    n1 = n + b->wds + 1;\n-    for (i = b->maxwds; n1 > i; i <<= 1) {\n-        k1++;\n-    }\n-    b1 = Balloc(k1);\n-    x1 = b1->x;\n-    for (i = 0; i < n; i++) {\n-        *x1++ = 0;\n-    }\n-    x = b->x;\n-    xe = x + b->wds;\n+  n = k >> 4;\n+#endif\n+  k1 = b->k;\n+  n1 = n + b->wds + 1;\n+  for (i = b->maxwds; n1 > i; i <<= 1) {\n+    k1++;\n+  }\n+  b1 = Balloc(k1);\n+  x1 = b1->x;\n+  for (i = 0; i < n; i++) {\n+    *x1++ = 0;\n+  }\n+  x = b->x;\n+  xe = x + b->wds;\n #ifdef Pack_32\n-    if (k &= 0x1f) {\n-        k1 = 32 - k;\n-        z = 0;\n-        do {\n-            *x1++ = *x << k | z;\n-            z = *x++ >> k1;\n-        } while (x < xe);\n-        if ((*x1 = z)) {\n-            ++n1;\n-        }\n+  if (k &= 0x1f) {\n+    k1 = 32 - k;\n+    z = 0;\n+    do {\n+      *x1++ = *x << k | z;\n+      z = *x++ >> k1;\n+    } while (x < xe);\n+    if ((*x1 = z)) {\n+      ++n1;\n     }\n+  }\n #else\n-    if (k &= 0xf) {\n-        k1 = 16 - k;\n-        z = 0;\n-        do {\n-            *x1++ = *x << k & 0xffff | z;\n-            z = *x++ >> k1;\n-        } while (x < xe);\n-        if (*x1 = z) {\n-            ++n1;\n-        }\n+  if (k &= 0xf) {\n+    k1 = 16 - k;\n+    z = 0;\n+    do {\n+      *x1++ = *x << k & 0xffff | z;\n+      z = *x++ >> k1;\n+    } while (x < xe);\n+    if (*x1 = z) {\n+      ++n1;\n     }\n+  }\n #endif\n-    else\n-        do {\n-            *x1++ = *x++;\n-        } while (x < xe);\n-    b1->wds = n1 - 1;\n-    Bfree(b);\n-    return b1;\n+  else\n+    do {\n+      *x1++ = *x++;\n+    } while (x < xe);\n+  b1->wds = n1 - 1;\n+  Bfree(b);\n+  return b1;\n }\n \n static int cmp\n@@ -1054,35 +1051,35 @@ static int cmp\n     (Bigint* a, Bigint* b)\n #endif\n {\n-    ULong *xa, *xa0, *xb, *xb0;\n-    int i, j;\n+  ULong *xa, *xa0, *xb, *xb0;\n+  int i, j;\n \n-    i = a->wds;\n-    j = b->wds;\n+  i = a->wds;\n+  j = b->wds;\n #ifdef DEBUG\n-    if (i > 1 && !a->x[i - 1]) {\n-        Bug(\"cmp called with a->x[a->wds-1] == 0\");\n-    }\n-    if (j > 1 && !b->x[j - 1]) {\n-        Bug(\"cmp called with b->x[b->wds-1] == 0\");\n-    }\n-#endif\n-    if (i -= j) {\n-        return i;\n-    }\n-    xa0 = a->x;\n-    xa = xa0 + j;\n-    xb0 = b->x;\n-    xb = xb0 + j;\n-    for (;;) {\n-        if (*--xa != *--xb) {\n-            return *xa < *xb ? -1 : 1;\n-        }\n-        if (xa <= xa0) {\n-            break;\n-        }\n-    }\n-    return 0;\n+  if (i > 1 && !a->x[i - 1]) {\n+    Bug(\"cmp called with a->x[a->wds-1] == 0\");\n+  }\n+  if (j > 1 && !b->x[j - 1]) {\n+    Bug(\"cmp called with b->x[b->wds-1] == 0\");\n+  }\n+#endif\n+  if (i -= j) {\n+    return i;\n+  }\n+  xa0 = a->x;\n+  xa = xa0 + j;\n+  xb0 = b->x;\n+  xb = xb0 + j;\n+  for (;;) {\n+    if (*--xa != *--xb) {\n+      return *xa < *xb ? -1 : 1;\n+    }\n+    if (xa <= xa0) {\n+      break;\n+    }\n+  }\n+  return 0;\n }\n \n static Bigint *diff\n@@ -1093,88 +1090,88 @@ static Bigint *diff\n     (Bigint* a, Bigint* b)\n #endif\n {\n-    Bigint* c;\n-    int i, wa, wb;\n-    ULong *xa, *xae, *xb, *xbe, *xc;\n+  Bigint* c;\n+  int i, wa, wb;\n+  ULong *xa, *xae, *xb, *xbe, *xc;\n #ifdef ULLong\n-    ULLong borrow, y;\n+  ULLong borrow, y;\n #else\n-    ULong borrow, y;\n-#ifdef Pack_32\n-    ULong z;\n-#endif\n+  ULong borrow, y;\n+#  ifdef Pack_32\n+  ULong z;\n+#  endif\n #endif\n \n-    i = cmp(a, b);\n-    if (!i) {\n-        c = Balloc(0);\n-        c->wds = 1;\n-        c->x[0] = 0;\n-        return c;\n-    }\n-    if (i < 0) {\n-        c = a;\n-        a = b;\n-        b = c;\n-        i = 1;\n-    } else {\n-        i = 0;\n-    }\n-    c = Balloc(a->k);\n-    c->sign = i;\n-    wa = a->wds;\n-    xa = a->x;\n-    xae = xa + wa;\n-    wb = b->wds;\n-    xb = b->x;\n-    xbe = xb + wb;\n-    xc = c->x;\n-    borrow = 0;\n+  i = cmp(a, b);\n+  if (!i) {\n+    c = Balloc(0);\n+    c->wds = 1;\n+    c->x[0] = 0;\n+    return c;\n+  }\n+  if (i < 0) {\n+    c = a;\n+    a = b;\n+    b = c;\n+    i = 1;\n+  } else {\n+    i = 0;\n+  }\n+  c = Balloc(a->k);\n+  c->sign = i;\n+  wa = a->wds;\n+  xa = a->x;\n+  xae = xa + wa;\n+  wb = b->wds;\n+  xb = b->x;\n+  xbe = xb + wb;\n+  xc = c->x;\n+  borrow = 0;\n #ifdef ULLong\n-    do {\n-        y = (ULLong)*xa++ - *xb++ - borrow;\n-        borrow = y >> 32 & (ULong)1;\n-        *xc++ = y & FFFFFFFF;\n-    } while (xb < xbe);\n-    while (xa < xae) {\n-        y = *xa++ - borrow;\n-        borrow = y >> 32 & (ULong)1;\n-        *xc++ = y & FFFFFFFF;\n-    }\n-#else\n-#ifdef Pack_32\n-    do {\n-        y = (*xa & 0xffff) - (*xb & 0xffff) - borrow;\n-        borrow = (y & 0x10000) >> 16;\n-        z = (*xa++ >> 16) - (*xb++ >> 16) - borrow;\n-        borrow = (z & 0x10000) >> 16;\n-        Storeinc(xc, z, y);\n-    } while (xb < xbe);\n-    while (xa < xae) {\n-        y = (*xa & 0xffff) - borrow;\n-        borrow = (y & 0x10000) >> 16;\n-        z = (*xa++ >> 16) - borrow;\n-        borrow = (z & 0x10000) >> 16;\n-        Storeinc(xc, z, y);\n-    }\n+  do {\n+    y = (ULLong)*xa++ - *xb++ - borrow;\n+    borrow = y >> 32 & (ULong)1;\n+    *xc++ = y & FFFFFFFF;\n+  } while (xb < xbe);\n+  while (xa < xae) {\n+    y = *xa++ - borrow;\n+    borrow = y >> 32 & (ULong)1;\n+    *xc++ = y & FFFFFFFF;\n+  }\n #else\n-    do {\n-        y = *xa++ - *xb++ - borrow;\n-        borrow = (y & 0x10000) >> 16;\n-        *xc++ = y & 0xffff;\n-    } while (xb < xbe);\n-    while (xa < xae) {\n-        y = *xa++ - borrow;\n-        borrow = (y & 0x10000) >> 16;\n-        *xc++ = y & 0xffff;\n-    }\n-#endif\n-#endif\n-    while (!*--xc) {\n-        wa--;\n-    }\n-    c->wds = wa;\n-    return c;\n+#  ifdef Pack_32\n+  do {\n+    y = (*xa & 0xffff) - (*xb & 0xffff) - borrow;\n+    borrow = (y & 0x10000) >> 16;\n+    z = (*xa++ >> 16) - (*xb++ >> 16) - borrow;\n+    borrow = (z & 0x10000) >> 16;\n+    Storeinc(xc, z, y);\n+  } while (xb < xbe);\n+  while (xa < xae) {\n+    y = (*xa & 0xffff) - borrow;\n+    borrow = (y & 0x10000) >> 16;\n+    z = (*xa++ >> 16) - borrow;\n+    borrow = (z & 0x10000) >> 16;\n+    Storeinc(xc, z, y);\n+  }\n+#  else\n+  do {\n+    y = *xa++ - *xb++ - borrow;\n+    borrow = (y & 0x10000) >> 16;\n+    *xc++ = y & 0xffff;\n+  } while (xb < xbe);\n+  while (xa < xae) {\n+    y = *xa++ - borrow;\n+    borrow = (y & 0x10000) >> 16;\n+    *xc++ = y & 0xffff;\n+  }\n+#  endif\n+#endif\n+  while (!*--xc) {\n+    wa--;\n+  }\n+  c->wds = wa;\n+  return c;\n }\n \n static double ulp\n@@ -1184,36 +1181,36 @@ static double ulp\n     (U* x)\n #endif\n {\n-    Long L;\n-    U u;\n+  Long L;\n+  U u;\n \n-    L = (word0(x) & Exp_mask) - (P - 1) * Exp_msk1;\n+  L = (word0(x) & Exp_mask) - (P - 1) * Exp_msk1;\n #ifndef Avoid_Underflow\n-#ifndef Sudden_Underflow\n-    if (L > 0) {\n-#endif\n+#  ifndef Sudden_Underflow\n+  if (L > 0) {\n+#  endif\n #endif\n #ifdef IBM\n-        L |= Exp_msk1 >> 4;\n+    L |= Exp_msk1 >> 4;\n #endif\n-        word0(&u) = L;\n-        word1(&u) = 0;\n+    word0(&u) = L;\n+    word1(&u) = 0;\n #ifndef Avoid_Underflow\n-#ifndef Sudden_Underflow\n+#  ifndef Sudden_Underflow\n+  } else {\n+    L = -L >> Exp_shift;\n+    if (L < Exp_shift) {\n+      word0(&u) = 0x80000 >> L;\n+      word1(&u) = 0;\n     } else {\n-        L = -L >> Exp_shift;\n-        if (L < Exp_shift) {\n-            word0(&u) = 0x80000 >> L;\n-            word1(&u) = 0;\n-        } else {\n-            word0(&u) = 0;\n-            L -= Exp_shift;\n-            word1(&u) = L >= 31 ? 1 : 1 << 31 - L;\n-        }\n+      word0(&u) = 0;\n+      L -= Exp_shift;\n+      word1(&u) = L >= 31 ? 1 : 1 << 31 - L;\n     }\n+  }\n+#  endif\n #endif\n-#endif\n-    return dval(&u);\n+  return dval(&u);\n }\n \n static double b2d\n@@ -1224,67 +1221,67 @@ int* e;\n     (Bigint* a, int* e)\n #endif\n {\n-    ULong *xa, *xa0, w, y, z;\n-    int k;\n-    U d;\n+  ULong *xa, *xa0, w, y, z;\n+  int k;\n+  U d;\n #ifdef VAX\n-    ULong d0, d1;\n+  ULong d0, d1;\n #else\n-#define d0 word0(&d)\n-#define d1 word1(&d)\n+#  define d0 word0(&d)\n+#  define d1 word1(&d)\n #endif\n \n-    xa0 = a->x;\n-    xa = xa0 + a->wds;\n-    y = *--xa;\n+  xa0 = a->x;\n+  xa = xa0 + a->wds;\n+  y = *--xa;\n #ifdef DEBUG\n-    if (!y) {\n-        Bug(\"zero y in b2d\");\n-    }\n+  if (!y) {\n+    Bug(\"zero y in b2d\");\n+  }\n #endif\n-    k = hi0bits(y);\n-    *e = 32 - k;\n+  k = hi0bits(y);\n+  *e = 32 - k;\n #ifdef Pack_32\n-    if (k < Ebits) {\n-        d0 = Exp_1 | y >> (Ebits - k);\n-        w = xa > xa0 ? *--xa : 0;\n-        d1 = y << ((32 - Ebits) + k) | w >> (Ebits - k);\n-        goto ret_d;\n-    }\n-    z = xa > xa0 ? *--xa : 0;\n-    if (k -= Ebits) {\n-        d0 = Exp_1 | y << k | z >> (32 - k);\n-        y = xa > xa0 ? *--xa : 0;\n-        d1 = z << k | y >> (32 - k);\n-    } else {\n-        d0 = Exp_1 | y;\n-        d1 = z;\n-    }\n+  if (k < Ebits) {\n+    d0 = Exp_1 | y >> (Ebits - k);\n+    w = xa > xa0 ? *--xa : 0;\n+    d1 = y << ((32 - Ebits) + k) | w >> (Ebits - k);\n+    goto ret_d;\n+  }\n+  z = xa > xa0 ? *--xa : 0;\n+  if (k -= Ebits) {\n+    d0 = Exp_1 | y << k | z >> (32 - k);\n+    y = xa > xa0 ? *--xa : 0;\n+    d1 = z << k | y >> (32 - k);\n+  } else {\n+    d0 = Exp_1 | y;\n+    d1 = z;\n+  }\n #else\n-    if (k < Ebits + 16) {\n-        z = xa > xa0 ? *--xa : 0;\n-        d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;\n-        w = xa > xa0 ? *--xa : 0;\n-        y = xa > xa0 ? *--xa : 0;\n-        d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;\n-        goto ret_d;\n-    }\n+  if (k < Ebits + 16) {\n     z = xa > xa0 ? *--xa : 0;\n+    d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;\n     w = xa > xa0 ? *--xa : 0;\n-    k -= Ebits + 16;\n-    d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;\n     y = xa > xa0 ? *--xa : 0;\n-    d1 = w << k + 16 | y << k;\n+    d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;\n+    goto ret_d;\n+  }\n+  z = xa > xa0 ? *--xa : 0;\n+  w = xa > xa0 ? *--xa : 0;\n+  k -= Ebits + 16;\n+  d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;\n+  y = xa > xa0 ? *--xa : 0;\n+  d1 = w << k + 16 | y << k;\n #endif\n ret_d:\n #ifdef VAX\n-    word0(&d) = d0 >> 16 | d0 << 16;\n-    word1(&d) = d1 >> 16 | d1 << 16;\n+  word0(&d) = d0 >> 16 | d0 << 16;\n+  word1(&d) = d1 >> 16 | d1 << 16;\n #else\n-#undef d0\n-#undef d1\n+#  undef d0\n+#  undef d1\n #endif\n-    return dval(&d);\n+  return dval(&d);\n }\n \n static Bigint* d2b\n@@ -1295,126 +1292,126 @@ int *e, *bits;\n     (U* d, int* e, int* bits)\n #endif\n {\n-    Bigint* b;\n-    int de, k;\n-    ULong *x, y, z;\n+  Bigint* b;\n+  int de, k;\n+  ULong *x, y, z;\n #ifndef Sudden_Underflow\n-    int i;\n+  int i;\n #endif\n #ifdef VAX\n-    ULong d0, d1;\n-    d0 = word0(d) >> 16 | word0(d) << 16;\n-    d1 = word1(d) >> 16 | word1(d) << 16;\n+  ULong d0, d1;\n+  d0 = word0(d) >> 16 | word0(d) << 16;\n+  d1 = word1(d) >> 16 | word1(d) << 16;\n #else\n-#define d0 word0(d)\n-#define d1 word1(d)\n+#  define d0 word0(d)\n+#  define d1 word1(d)\n #endif\n \n #ifdef Pack_32\n-    b = Balloc(1);\n+  b = Balloc(1);\n #else\n-    b = Balloc(2);\n+  b = Balloc(2);\n #endif\n-    x = b->x;\n+  x = b->x;\n \n-    z = d0 & Frac_mask;\n-    d0 &= 0x7fffffff; /* clear sign bit, which we ignore */\n+  z = d0 & Frac_mask;\n+  d0 &= 0x7fffffff; /* clear sign bit, which we ignore */\n #ifdef Sudden_Underflow\n-    de = (int)(d0 >> Exp_shift);\n-#ifndef IBM\n-    z |= Exp_msk11;\n-#endif\n+  de = (int)(d0 >> Exp_shift);\n+#  ifndef IBM\n+  z |= Exp_msk11;\n+#  endif\n #else\n-    if ((de = (int)(d0 >> Exp_shift))) {\n-        z |= Exp_msk1;\n-    }\n+  if ((de = (int)(d0 >> Exp_shift))) {\n+    z |= Exp_msk1;\n+  }\n #endif\n #ifdef Pack_32\n-    if ((y = d1)) {\n-        if ((k = lo0bits(&y))) {\n-            x[0] = y | z << (32 - k);\n-            z >>= k;\n-        } else {\n-            x[0] = y;\n-        }\n-#ifndef Sudden_Underflow\n-        i =\n-#endif\n-            b->wds = (x[1] = z) ? 2 : 1;\n+  if ((y = d1)) {\n+    if ((k = lo0bits(&y))) {\n+      x[0] = y | z << (32 - k);\n+      z >>= k;\n     } else {\n-        k = lo0bits(&z);\n-        x[0] = z;\n-#ifndef Sudden_Underflow\n-        i =\n-#endif\n-            b->wds = 1;\n-        k += 32;\n+      x[0] = y;\n     }\n+#  ifndef Sudden_Underflow\n+    i =\n+#  endif\n+        b->wds = (x[1] = z) ? 2 : 1;\n+  } else {\n+    k = lo0bits(&z);\n+    x[0] = z;\n+#  ifndef Sudden_Underflow\n+    i =\n+#  endif\n+        b->wds = 1;\n+    k += 32;\n+  }\n #else\n-    if (y = d1) {\n-        if (k = lo0bits(&y))\n-            if (k >= 16) {\n-                x[0] = y | z << 32 - k & 0xffff;\n-                x[1] = z >> k - 16 & 0xffff;\n-                x[2] = z >> k;\n-                i = 2;\n-            } else {\n-                x[0] = y & 0xffff;\n-                x[1] = y >> 16 | z << 16 - k & 0xffff;\n-                x[2] = z >> k & 0xffff;\n-                x[3] = z >> k + 16;\n-                i = 3;\n-            }\n-        else {\n-            x[0] = y & 0xffff;\n-            x[1] = y >> 16;\n-            x[2] = z & 0xffff;\n-            x[3] = z >> 16;\n-            i = 3;\n-        }\n+  if (y = d1) {\n+    if (k = lo0bits(&y))\n+      if (k >= 16) {\n+        x[0] = y | z << 32 - k & 0xffff;\n+        x[1] = z >> k - 16 & 0xffff;\n+        x[2] = z >> k;\n+        i = 2;\n+      } else {\n+        x[0] = y & 0xffff;\n+        x[1] = y >> 16 | z << 16 - k & 0xffff;\n+        x[2] = z >> k & 0xffff;\n+        x[3] = z >> k + 16;\n+        i = 3;\n+      }\n+    else {\n+      x[0] = y & 0xffff;\n+      x[1] = y >> 16;\n+      x[2] = z & 0xffff;\n+      x[3] = z >> 16;\n+      i = 3;\n+    }\n+  } else {\n+#  ifdef DEBUG\n+    if (!z) {\n+      Bug(\"Zero passed to d2b\");\n+    }\n+#  endif\n+    k = lo0bits(&z);\n+    if (k >= 16) {\n+      x[0] = z;\n+      i = 0;\n     } else {\n-#ifdef DEBUG\n-        if (!z) {\n-            Bug(\"Zero passed to d2b\");\n-        }\n-#endif\n-        k = lo0bits(&z);\n-        if (k >= 16) {\n-            x[0] = z;\n-            i = 0;\n-        } else {\n-            x[0] = z & 0xffff;\n-            x[1] = z >> 16;\n-            i = 1;\n-        }\n-        k += 32;\n+      x[0] = z & 0xffff;\n+      x[1] = z >> 16;\n+      i = 1;\n     }\n-    while (!x[i]) {\n-        --i;\n-    }\n-    b->wds = i + 1;\n+    k += 32;\n+  }\n+  while (!x[i]) {\n+    --i;\n+  }\n+  b->wds = i + 1;\n #endif\n #ifndef Sudden_Underflow\n-    if (de) {\n+  if (de) {\n #endif\n #ifdef IBM\n-        *e = (de - Bias - (P - 1) << 2) + k;\n-        *bits = 4 * P + 8 - k - hi0bits(word0(d) & Frac_mask);\n+    *e = (de - Bias - (P - 1) << 2) + k;\n+    *bits = 4 * P + 8 - k - hi0bits(word0(d) & Frac_mask);\n #else\n-    *e = de - Bias - (P - 1) + k;\n-    *bits = P - k;\n+  *e = de - Bias - (P - 1) + k;\n+  *bits = P - k;\n #endif\n #ifndef Sudden_Underflow\n-    } else {\n-        *e = de - Bias - (P - 1) + 1 + k;\n-#ifdef Pack_32\n-        *bits = 32 * i - hi0bits(x[i - 1]);\n-#else\n-        *bits = (i + 2) * 16 - hi0bits(x[i]);\n-#endif\n-    }\n-#endif\n-    return b;\n+  } else {\n+    *e = de - Bias - (P - 1) + 1 + k;\n+#  ifdef Pack_32\n+    *bits = 32 * i - hi0bits(x[i - 1]);\n+#  else\n+    *bits = (i + 2) * 16 - hi0bits(x[i]);\n+#  endif\n+  }\n+#endif\n+  return b;\n }\n #undef d0\n #undef d1\n@@ -1427,289 +1424,289 @@ static double ratio\n     (Bigint* a, Bigint* b)\n #endif\n {\n-    U da, db;\n-    int k, ka, kb;\n+  U da, db;\n+  int k, ka, kb;\n \n-    dval(&da) = b2d(a, &ka);\n-    dval(&db) = b2d(b, &kb);\n+  dval(&da) = b2d(a, &ka);\n+  dval(&db) = b2d(b, &kb);\n #ifdef Pack_32\n-    k = ka - kb + 32 * (a->wds - b->wds);\n+  k = ka - kb + 32 * (a->wds - b->wds);\n #else\n-    k = ka - kb + 16 * (a->wds - b->wds);\n+  k = ka - kb + 16 * (a->wds - b->wds);\n #endif\n #ifdef IBM\n-    if (k > 0) {\n-        word0(&da) += (k >> 2) * Exp_msk1;\n-        if (k &= 3) {\n-            dval(&da) *= 1 << k;\n-        }\n-    } else {\n-        k = -k;\n-        word0(&db) += (k >> 2) * Exp_msk1;\n-        if (k &= 3) {\n-            dval(&db) *= 1 << k;\n-        }\n-    }\n+  if (k > 0) {\n+    word0(&da) += (k >> 2) * Exp_msk1;\n+    if (k &= 3) {\n+      dval(&da) *= 1 << k;\n+    }\n+  } else {\n+    k = -k;\n+    word0(&db) += (k >> 2) * Exp_msk1;\n+    if (k &= 3) {\n+      dval(&db) *= 1 << k;\n+    }\n+  }\n #else\n-    if (k > 0) {\n-        word0(&da) += k * Exp_msk1;\n-    } else {\n-        k = -k;\n-        word0(&db) += k * Exp_msk1;\n-    }\n-#endif\n-    return dval(&da) / dval(&db);\n+  if (k > 0) {\n+    word0(&da) += k * Exp_msk1;\n+  } else {\n+    k = -k;\n+    word0(&db) += k * Exp_msk1;\n+  }\n+#endif\n+  return dval(&da) / dval(&db);\n }\n \n-static CONST double tens[] = { 1e0,\n-                               1e1,\n-                               1e2,\n-                               1e3,\n-                               1e4,\n-                               1e5,\n-                               1e6,\n-                               1e7,\n-                               1e8,\n-                               1e9,\n-                               1e10,\n-                               1e11,\n-                               1e12,\n-                               1e13,\n-                               1e14,\n-                               1e15,\n-                               1e16,\n-                               1e17,\n-                               1e18,\n-                               1e19,\n-                               1e20,\n-                               1e21,\n-                               1e22\n+static CONST double tens[] = {1e0,\n+                              1e1,\n+                              1e2,\n+                              1e3,\n+                              1e4,\n+                              1e5,\n+                              1e6,\n+                              1e7,\n+                              1e8,\n+                              1e9,\n+                              1e10,\n+                              1e11,\n+                              1e12,\n+                              1e13,\n+                              1e14,\n+                              1e15,\n+                              1e16,\n+                              1e17,\n+                              1e18,\n+                              1e19,\n+                              1e20,\n+                              1e21,\n+                              1e22\n #ifdef VAX\n-                               ,\n-                               1e23,\n-                               1e24\n+                              ,\n+                              1e23,\n+                              1e24\n #endif\n };\n \n static CONST double\n #ifdef IEEE_Arith\n-    bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 };\n-static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128,\n-#ifdef Avoid_Underflow\n-                                   9007199254740992. * 9007199254740992.e-256\n+    bigtens[] = {1e16, 1e32, 1e64, 1e128, 1e256};\n+static CONST double tinytens[] = {1e-16, 1e-32, 1e-64, 1e-128,\n+#  ifdef Avoid_Underflow\n+                                  9007199254740992. * 9007199254740992.e-256\n /* = 2^106 * 1e-256 */\n-#else\n-                                   1e-256\n-#endif\n+#  else\n+                                  1e-256\n+#  endif\n };\n /* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */\n /* flag unnecessarily.  It leads to a song and dance at the end of strtod. */\n-#define Scale_Bit 0x10\n-#define n_bigtens 5\n+#  define Scale_Bit 0x10\n+#  define n_bigtens 5\n #else\n-#ifdef IBM\n-    bigtens[] = { 1e16, 1e32, 1e64 };\n-static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64 };\n-#define n_bigtens 3\n-#else\n-    bigtens[] = { 1e16, 1e32 };\n-static CONST double tinytens[] = { 1e-16, 1e-32 };\n-#define n_bigtens 2\n-#endif\n+#  ifdef IBM\n+    bigtens[] = {1e16, 1e32, 1e64};\n+static CONST double tinytens[] = {1e-16, 1e-32, 1e-64};\n+#    define n_bigtens 3\n+#  else\n+    bigtens[] = {1e16, 1e32};\n+static CONST double tinytens[] = {1e-16, 1e-32};\n+#    define n_bigtens 2\n+#  endif\n #endif\n \n #undef Need_Hexdig\n #ifdef INFNAN_CHECK\n-#ifndef No_Hex_NaN\n-#define Need_Hexdig\n-#endif\n+#  ifndef No_Hex_NaN\n+#    define Need_Hexdig\n+#  endif\n #endif\n \n #ifndef Need_Hexdig\n-#ifndef NO_HEX_FP\n-#define Need_Hexdig\n-#endif\n+#  ifndef NO_HEX_FP\n+#    define Need_Hexdig\n+#  endif\n #endif\n \n #ifdef Need_Hexdig /*{*/\n static unsigned char hexdig[256];\n \n static void\n-#ifdef KR_headers\n+#  ifdef KR_headers\n     htinit(h, s, inc) unsigned char* h;\n unsigned char* s;\n int inc;\n-#else\n+#  else\n htinit(unsigned char* h, unsigned char* s, int inc)\n-#endif\n+#  endif\n {\n-    int i, j;\n-    for (i = 0; (j = s[i]) != 0; i++) {\n-        h[j] = i + inc;\n-    }\n+  int i, j;\n+  for (i = 0; (j = s[i]) != 0; i++) {\n+    h[j] = i + inc;\n+  }\n }\n \n static void\n-#ifdef KR_headers\n+#  ifdef KR_headers\n hexdig_init()\n-#else\n+#  else\n hexdig_init(void)\n-#endif\n+#  endif\n {\n-#define USC (unsigned char*)\n-    htinit(hexdig, USC \"0123456789\", 0x10);\n-    htinit(hexdig, USC \"abcdef\", 0x10 + 10);\n-    htinit(hexdig, USC \"ABCDEF\", 0x10 + 10);\n+#  define USC (unsigned char*)\n+  htinit(hexdig, USC \"0123456789\", 0x10);\n+  htinit(hexdig, USC \"abcdef\", 0x10 + 10);\n+  htinit(hexdig, USC \"ABCDEF\", 0x10 + 10);\n }\n #endif /* } Need_Hexdig */\n \n #ifdef INFNAN_CHECK\n \n-#ifndef NAN_WORD0\n-#define NAN_WORD0 0x7ff80000\n-#endif\n+#  ifndef NAN_WORD0\n+#    define NAN_WORD0 0x7ff80000\n+#  endif\n \n-#ifndef NAN_WORD1\n-#define NAN_WORD1 0\n-#endif\n+#  ifndef NAN_WORD1\n+#    define NAN_WORD1 0\n+#  endif\n \n static int match\n-#ifdef KR_headers\n+#  ifdef KR_headers\n     (sp, t) char **sp,\n     *t;\n-#else\n+#  else\n     (const char** sp, const char* t)\n-#endif\n+#  endif\n {\n-    int c, d;\n-    CONST char* s = *sp;\n+  int c, d;\n+  CONST char* s = *sp;\n \n-    while ((d = *t++)) {\n-        if ((c = *++s) >= 'A' && c <= 'Z') {\n-            c += 'a' - 'A';\n-        }\n-        if (c != d) {\n-            return 0;\n-        }\n+  while ((d = *t++)) {\n+    if ((c = *++s) >= 'A' && c <= 'Z') {\n+      c += 'a' - 'A';\n+    }\n+    if (c != d) {\n+      return 0;\n     }\n-    *sp = s + 1;\n-    return 1;\n+  }\n+  *sp = s + 1;\n+  return 1;\n }\n \n-#ifndef No_Hex_NaN\n+#  ifndef No_Hex_NaN\n static void hexnan\n-#ifdef KR_headers\n+#    ifdef KR_headers\n     (rvp, sp) U* rvp;\n CONST char** sp;\n-#else\n+#    else\n     (U* rvp, const char** sp)\n-#endif\n+#    endif\n {\n-    ULong c, x[2];\n-    CONST char* s;\n-    int c1, havedig, udx0, xshift;\n-\n-    if (!hexdig['0']) {\n-        hexdig_init();\n-    }\n-    x[0] = x[1] = 0;\n-    havedig = xshift = 0;\n-    udx0 = 1;\n-    s = *sp;\n-    /* allow optional initial 0x or 0X */\n-    while ((c = *(CONST unsigned char*)(s + 1)) && c <= ' ') {\n-        ++s;\n-    }\n-    if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X')) {\n-        s += 2;\n-    }\n-    while ((c = *(CONST unsigned char*)++s)) {\n-        if ((c1 = hexdig[c])) {\n-            c = c1 & 0xf;\n-        } else if (c <= ' ') {\n-            if (udx0 && havedig) {\n-                udx0 = 0;\n-                xshift = 1;\n-            }\n-            continue;\n-        }\n-#ifdef GDTOA_NON_PEDANTIC_NANCHECK\n-        else if (/*(*/ c == ')' && havedig) {\n-            *sp = s + 1;\n-            break;\n-        } else {\n-            return; /* invalid form: don't change *sp */\n-        }\n-#else\n-        else {\n-            do {\n-                if (/*(*/ c == ')') {\n-                    *sp = s + 1;\n-                    break;\n-                }\n-            } while ((c = *++s));\n-            break;\n-        }\n-#endif\n-        havedig = 1;\n-        if (xshift) {\n-            xshift = 0;\n-            x[0] = x[1];\n-            x[1] = 0;\n-        }\n-        if (udx0) {\n-            x[0] = (x[0] << 4) | (x[1] >> 28);\n-        }\n-        x[1] = (x[1] << 4) | c;\n-    }\n-    if ((x[0] &= 0xfffff) || x[1]) {\n-        word0(rvp) = Exp_mask | x[0];\n-        word1(rvp) = x[1];\n-    }\n+  ULong c, x[2];\n+  CONST char* s;\n+  int c1, havedig, udx0, xshift;\n+\n+  if (!hexdig['0']) {\n+    hexdig_init();\n+  }\n+  x[0] = x[1] = 0;\n+  havedig = xshift = 0;\n+  udx0 = 1;\n+  s = *sp;\n+  /* allow optional initial 0x or 0X */\n+  while ((c = *(CONST unsigned char*)(s + 1)) && c <= ' ') {\n+    ++s;\n+  }\n+  if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X')) {\n+    s += 2;\n+  }\n+  while ((c = *(CONST unsigned char*)++s)) {\n+    if ((c1 = hexdig[c])) {\n+      c = c1 & 0xf;\n+    } else if (c <= ' ') {\n+      if (udx0 && havedig) {\n+        udx0 = 0;\n+        xshift = 1;\n+      }\n+      continue;\n+    }\n+#    ifdef GDTOA_NON_PEDANTIC_NANCHECK\n+    else if (/*(*/ c == ')' && havedig) {\n+      *sp = s + 1;\n+      break;\n+    } else {\n+      return; /* invalid form: don't change *sp */\n+    }\n+#    else\n+    else {\n+      do {\n+        if (/*(*/ c == ')') {\n+          *sp = s + 1;\n+          break;\n+        }\n+      } while ((c = *++s));\n+      break;\n+    }\n+#    endif\n+    havedig = 1;\n+    if (xshift) {\n+      xshift = 0;\n+      x[0] = x[1];\n+      x[1] = 0;\n+    }\n+    if (udx0) {\n+      x[0] = (x[0] << 4) | (x[1] >> 28);\n+    }\n+    x[1] = (x[1] << 4) | c;\n+  }\n+  if ((x[0] &= 0xfffff) || x[1]) {\n+    word0(rvp) = Exp_mask | x[0];\n+    word1(rvp) = x[1];\n+  }\n }\n-#endif /*No_Hex_NaN*/\n-#endif /* INFNAN_CHECK */\n+#  endif /*No_Hex_NaN*/\n+#endif   /* INFNAN_CHECK */\n \n #ifdef Pack_32\n-#define ULbits 32\n-#define kshift 5\n-#define kmask 31\n+#  define ULbits 32\n+#  define kshift 5\n+#  define kmask 31\n #else\n-#define ULbits 16\n-#define kshift 4\n-#define kmask 15\n+#  define ULbits 16\n+#  define kshift 4\n+#  define kmask 15\n #endif\n \n #if !defined(NO_HEX_FP) || defined(Honor_FLT_ROUNDS) /*{*/\n static Bigint*\n-#ifdef KR_headers\n+#  ifdef KR_headers\n     increment(b) Bigint* b;\n-#else\n+#  else\n increment(Bigint* b)\n-#endif\n+#  endif\n {\n-    ULong *x, *xe;\n-    Bigint* b1;\n-\n-    x = b->x;\n-    xe = x + b->wds;\n-    do {\n-        if (*x < (ULong)0xffffffffL) {\n-            ++*x;\n-            return b;\n-        }\n-        *x++ = 0;\n-    } while (x < xe);\n-    {\n-        if (b->wds >= b->maxwds) {\n-            b1 = Balloc(b->k + 1);\n-            Bcopy(b1, b);\n-            Bfree(b);\n-            b = b1;\n-        }\n-        b->x[b->wds++] = 1;\n-    }\n-    return b;\n+  ULong *x, *xe;\n+  Bigint* b1;\n+\n+  x = b->x;\n+  xe = x + b->wds;\n+  do {\n+    if (*x < (ULong)0xffffffffL) {\n+      ++*x;\n+      return b;\n+    }\n+    *x++ = 0;\n+  } while (x < xe);\n+  {\n+    if (b->wds >= b->maxwds) {\n+      b1 = Balloc(b->k + 1);\n+      Bcopy(b1, b);\n+      Bfree(b);\n+      b = b1;\n+    }\n+    b->x[b->wds++] = 1;\n+  }\n+  return b;\n }\n \n #endif /*}*/\n@@ -1717,72 +1714,72 @@ increment(Bigint* b)\n #ifndef NO_HEX_FP /*{*/\n \n static void\n-#ifdef KR_headers\n+#  ifdef KR_headers\n     rshift(b, k) Bigint* b;\n int k;\n-#else\n+#  else\n rshift(Bigint* b, int k)\n-#endif\n+#  endif\n {\n-    ULong *x, *x1, *xe, y;\n-    int n;\n-\n-    x = x1 = b->x;\n-    n = k >> kshift;\n-    if (n < b->wds) {\n-        xe = x + b->wds;\n-        x += n;\n-        if (k &= kmask) {\n-            n = 32 - k;\n-            y = *x++ >> k;\n-            while (x < xe) {\n-                *x1++ = (y | (*x << n)) & 0xffffffff;\n-                y = *x++ >> k;\n-            }\n-            if ((*x1 = y) != 0) {\n-                x1++;\n-            }\n-        } else\n-            while (x < xe) {\n-                *x1++ = *x++;\n-            }\n-    }\n-    if ((b->wds = x1 - b->x) == 0) {\n-        b->x[0] = 0;\n-    }\n+  ULong *x, *x1, *xe, y;\n+  int n;\n+\n+  x = x1 = b->x;\n+  n = k >> kshift;\n+  if (n < b->wds) {\n+    xe = x + b->wds;\n+    x += n;\n+    if (k &= kmask) {\n+      n = 32 - k;\n+      y = *x++ >> k;\n+      while (x < xe) {\n+        *x1++ = (y | (*x << n)) & 0xffffffff;\n+        y = *x++ >> k;\n+      }\n+      if ((*x1 = y) != 0) {\n+        x1++;\n+      }\n+    } else\n+      while (x < xe) {\n+        *x1++ = *x++;\n+      }\n+  }\n+  if ((b->wds = x1 - b->x) == 0) {\n+    b->x[0] = 0;\n+  }\n }\n \n static ULong\n-#ifdef KR_headers\n+#  ifdef KR_headers\n     any_on(b, k) Bigint* b;\n int k;\n-#else\n+#  else\n any_on(Bigint* b, int k)\n-#endif\n+#  endif\n {\n-    int n, nwds;\n-    ULong *x, *x0, x1, x2;\n-\n-    x = b->x;\n-    nwds = b->wds;\n-    n = k >> kshift;\n-    if (n > nwds) {\n-        n = nwds;\n-    } else if (n < nwds && (k &= kmask)) {\n-        x1 = x2 = x[n];\n-        x1 >>= k;\n-        x1 <<= k;\n-        if (x1 != x2) {\n-            return 1;\n-        }\n-    }\n-    x0 = x;\n-    x += n;\n-    while (x > x0)\n-        if (*--x) {\n-            return 1;\n-        }\n-    return 0;\n+  int n, nwds;\n+  ULong *x, *x0, x1, x2;\n+\n+  x = b->x;\n+  nwds = b->wds;\n+  n = k >> kshift;\n+  if (n > nwds) {\n+    n = nwds;\n+  } else if (n < nwds && (k &= kmask)) {\n+    x1 = x2 = x[n];\n+    x1 >>= k;\n+    x1 <<= k;\n+    if (x1 != x2) {\n+      return 1;\n+    }\n+  }\n+  x0 = x;\n+  x += n;\n+  while (x > x0)\n+    if (*--x) {\n+      return 1;\n+    }\n+  return 0;\n }\n \n enum { /* rounding values: same as FLT_ROUNDS */\n@@ -1793,397 +1790,396 @@ enum { /* rounding values: same as FLT_ROUNDS */\n };\n \n void\n-#ifdef KR_headers\n+#  ifdef KR_headers\n     gethex(sp, rvp, rounding, sign) CONST char** sp;\n U* rvp;\n int rounding, sign;\n-#else\n-gethex(CONST char** sp, U* rvp, int rounding, int sign)\n-#endif\n+#  else\n+gethex( CONST char **sp, U *rvp, int rounding, int sign)\n+#  endif\n {\n-    Bigint* b;\n-    CONST unsigned char *decpt, *s0, *s, *s1;\n-    Long e, e1;\n-    ULong L, lostbits, *x;\n-    int big, denorm, esign, havedig, k, n, nbits, up, zret;\n-#ifdef IBM\n-    int j;\n-#endif\n-    enum {\n-#ifdef IEEE_Arith /*{{*/\n-        emax = 0x7fe - Bias - P + 1,\n-        emin = Emin - P + 1\n-#else /*}{*/\n-        emin = Emin - P,\n-#ifdef VAX\n-        emax = 0x7ff - Bias - P +\n-               1\n-#endif\n-#ifdef IBM\n-               emax = 0x7f - Bias - P\n-#endif\n-#endif /*}}*/\n-    };\n-#ifdef USE_LOCALE\n-    int i;\n-#ifdef NO_LOCALE_CACHE\n-    const unsigned char* decimalpoint =\n-        (unsigned char*)localeconv()->decimal_point;\n-#else\n-    const unsigned char* decimalpoint;\n-    static unsigned char* decimalpoint_cache;\n-    if (!(s0 = decimalpoint_cache)) {\n-        s0 = (unsigned char*)localeconv()->decimal_point;\n-        if ((decimalpoint_cache =\n-                 (unsigned char*)MALLOC(strlen((CONST char*)s0) + 1))) {\n-            strcpy((char*)decimalpoint_cache, (CONST char*)s0);\n-            s0 = decimalpoint_cache;\n-        }\n-    }\n-    decimalpoint = s0;\n-#endif\n-#endif\n-\n-    if (!hexdig['0']) {\n-        hexdig_init();\n+  Bigint* b;\n+  CONST unsigned char *decpt, *s0, *s, *s1;\n+  Long e, e1;\n+  ULong L, lostbits, *x;\n+  int big, denorm, esign, havedig, k, n, nbits, up, zret;\n+#  ifdef IBM\n+  int j;\n+#  endif\n+  enum {\n+#  ifdef IEEE_Arith /*{{*/\n+    emax = 0x7fe - Bias - P + 1,\n+    emin = Emin - P + 1\n+#  else /*}{*/\n+    emin = Emin - P,\n+#    ifdef VAX\n+    emax = 0x7ff - Bias - P +\n+           1\n+#    endif\n+#    ifdef IBM\n+           emax = 0x7f - Bias - P\n+#    endif\n+#  endif /*}}*/\n+  };\n+#  ifdef USE_LOCALE\n+  int i;\n+#    ifdef NO_LOCALE_CACHE\n+  const unsigned char* decimalpoint =\n+      (unsigned char*)localeconv()->decimal_point;\n+#    else\n+  const unsigned char* decimalpoint;\n+  static unsigned char* decimalpoint_cache;\n+  if (!(s0 = decimalpoint_cache)) {\n+    s0 = (unsigned char*)localeconv()->decimal_point;\n+    if ((decimalpoint_cache =\n+             (unsigned char*)MALLOC(strlen((CONST char*)s0) + 1))) {\n+      strcpy((char*)decimalpoint_cache, (CONST char*)s0);\n+      s0 = decimalpoint_cache;\n+    }\n+  }\n+  decimalpoint = s0;\n+#    endif\n+#  endif\n+\n+  if (!hexdig['0']) {\n+    hexdig_init();\n+  }\n+  havedig = 0;\n+  s0 = *(CONST unsigned char**)sp + 2;\n+  while (s0[havedig] == '0') {\n+    havedig++;\n+  }\n+  s0 += havedig;\n+  s = s0;\n+  decpt = 0;\n+  zret = 0;\n+  e = 0;\n+  if (hexdig[*s]) {\n+    havedig++;\n+  } else {\n+    zret = 1;\n+#  ifdef USE_LOCALE\n+    for (i = 0; decimalpoint[i]; ++i) {\n+      if (s[i] != decimalpoint[i]) {\n+        goto pcheck;\n+      }\n+    }\n+    decpt = s += i;\n+#  else\n+    if (*s != '.') {\n+      goto pcheck;\n+    }\n+    decpt = ++s;\n+#  endif\n+    if (!hexdig[*s]) {\n+      goto pcheck;\n+    }\n+    while (*s == '0') {\n+      s++;\n     }\n-    havedig = 0;\n-    s0 = *(CONST unsigned char**)sp + 2;\n-    while (s0[havedig] == '0') {\n-        havedig++;\n-    }\n-    s0 += havedig;\n-    s = s0;\n-    decpt = 0;\n-    zret = 0;\n-    e = 0;\n     if (hexdig[*s]) {\n-        havedig++;\n-    } else {\n-        zret = 1;\n-#ifdef USE_LOCALE\n-        for (i = 0; decimalpoint[i]; ++i) {\n-            if (s[i] != decimalpoint[i]) {\n-                goto pcheck;\n-            }\n-        }\n-        decpt = s += i;\n-#else\n-        if (*s != '.') {\n-            goto pcheck;\n-        }\n-        decpt = ++s;\n-#endif\n-        if (!hexdig[*s]) {\n-            goto pcheck;\n-        }\n-        while (*s == '0') {\n-            s++;\n-        }\n-        if (hexdig[*s]) {\n-            zret = 0;\n-        }\n-        havedig = 1;\n-        s0 = s;\n+      zret = 0;\n     }\n+    havedig = 1;\n+    s0 = s;\n+  }\n+  while (hexdig[*s]) {\n+    s++;\n+  }\n+#  ifdef USE_LOCALE\n+  if (*s == *decimalpoint && !decpt) {\n+    for (i = 1; decimalpoint[i]; ++i) {\n+      if (s[i] != decimalpoint[i]) {\n+        goto pcheck;\n+      }\n+    }\n+    decpt = s += i;\n+#  else\n+  if (*s == '.' && !decpt) {\n+    decpt = ++s;\n+#  endif\n     while (hexdig[*s]) {\n-        s++;\n-    }\n-#ifdef USE_LOCALE\n-    if (*s == *decimalpoint && !decpt) {\n-        for (i = 1; decimalpoint[i]; ++i) {\n-            if (s[i] != decimalpoint[i]) {\n-                goto pcheck;\n-            }\n-        }\n-        decpt = s += i;\n-#else\n-    if (*s == '.' && !decpt) {\n-        decpt = ++s;\n-#endif\n-        while (hexdig[*s]) {\n-            s++;\n-        }\n-    } /*}*/\n-    if (decpt) {\n-        e = -(((Long)(s - decpt)) << 2);\n+      s++;\n     }\n+  } /*}*/\n+  if (decpt) {\n+    e = -(((Long)(s - decpt)) << 2);\n+  }\n pcheck:\n-    s1 = s;\n-    big = esign = 0;\n-    switch (*s) {\n-        case 'p':\n-        case 'P':\n-            switch (*++s) {\n-                case '-':\n-                    esign = 1;\n-                /* no break */\n-                case '+':\n-                    s++;\n-            }\n-            if ((n = hexdig[*s]) == 0 || n > 0x19) {\n-                s = s1;\n-                break;\n-            }\n-            e1 = n - 0x10;\n-            while ((n = hexdig[*++s]) != 0 && n <= 0x19) {\n-                if (e1 & 0xf8000000) {\n-                    big = 1;\n-                }\n-                e1 = 10 * e1 + n - 0x10;\n-            }\n-            if (esign) {\n-                e1 = -e1;\n-            }\n-            e += e1;\n-    }\n-    *sp = (char*)s;\n-    if (!havedig) {\n-        *sp = (char*)s0 - 1;\n-    }\n-    if (zret) {\n-        goto retz1;\n-    }\n-    if (big) {\n-        if (esign) {\n-#ifdef IEEE_Arith\n-            switch (rounding) {\n-                case Round_up:\n-                    if (sign) {\n-                        break;\n-                    }\n-                    goto ret_tiny;\n-                case Round_down:\n-                    if (!sign) {\n-                        break;\n-                    }\n-                    goto ret_tiny;\n-            }\n-#endif\n-            goto retz;\n-#ifdef IEEE_Arith\n-        ret_tiny:\n-#ifndef NO_ERRNO\n-            errno = ERANGE;\n-#endif\n-            word0(rvp) = 0;\n-            word1(rvp) = 1;\n-            return;\n-#endif /* IEEE_Arith */\n-        }\n-        switch (rounding) {\n-            case Round_near:\n-                goto ovfl1;\n-            case Round_up:\n-                if (!sign) {\n-                    goto ovfl1;\n-                }\n-                goto ret_big;\n-            case Round_down:\n-                if (sign) {\n-                    goto ovfl1;\n-                }\n-                goto ret_big;\n+  s1 = s;\n+  big = esign = 0;\n+  switch (*s) {\n+    case 'p':\n+    case 'P':\n+      switch (*++s) {\n+        case '-':\n+          esign = 1;\n+        /* no break */\n+        case '+':\n+          s++;\n+      }\n+      if ((n = hexdig[*s]) == 0 || n > 0x19) {\n+        s = s1;\n+        break;\n+      }\n+      e1 = n - 0x10;\n+      while ((n = hexdig[*++s]) != 0 && n <= 0x19) {\n+        if (e1 & 0xf8000000) {\n+          big = 1;\n+        }\n+        e1 = 10 * e1 + n - 0x10;\n+      }\n+      if (esign) {\n+        e1 = -e1;\n+      }\n+      e += e1;\n+  }\n+  *sp = (char*)s;\n+  if (!havedig) {\n+    *sp = (char*)s0 - 1;\n+  }\n+  if (zret) {\n+    goto retz1;\n+  }\n+  if (big) {\n+    if (esign) {\n+#  ifdef IEEE_Arith\n+      switch (rounding) {\n+        case Round_up:\n+          if (sign) {\n+            break;\n+          }\n+          goto ret_tiny;\n+        case Round_down:\n+          if (!sign) {\n+            break;\n+          }\n+          goto ret_tiny;\n+      }\n+#  endif\n+      goto retz;\n+#  ifdef IEEE_Arith\n+    ret_tiny:\n+#    ifndef NO_ERRNO\n+      errno = ERANGE;\n+#    endif\n+      word0(rvp) = 0;\n+      word1(rvp) = 1;\n+      return;\n+#  endif /* IEEE_Arith */\n+    }\n+    switch (rounding) {\n+      case Round_near:\n+        goto ovfl1;\n+      case Round_up:\n+        if (!sign) {\n+          goto ovfl1;\n+        }\n+        goto ret_big;\n+      case Round_down:\n+        if (sign) {\n+          goto ovfl1;\n         }\n-    ret_big:\n-        word0(rvp) = Big0;\n-        word1(rvp) = Big1;\n-        return;\n-    }\n-    n = s1 - s0 - 1;\n-    for (k = 0; n > (1 << (kshift - 2)) - 1; n >>= 1) {\n-        k++;\n+        goto ret_big;\n     }\n-    b = Balloc(k);\n-    x = b->x;\n-    n = 0;\n-    L = 0;\n-#ifdef USE_LOCALE\n-    for (i = 0; decimalpoint[i + 1]; ++i)\n-        ;\n-#endif\n-    while (s1 > s0) {\n-#ifdef USE_LOCALE\n-        if (*--s1 == decimalpoint[i]) {\n-            s1 -= i;\n-            continue;\n-        }\n-#else\n-        if (*--s1 == '.') {\n-            continue;\n-        }\n-#endif\n-        if (n == ULbits) {\n-            *x++ = L;\n-            L = 0;\n-            n = 0;\n-        }\n-        L |= (hexdig[*s1] & 0x0f) << n;\n-        n += 4;\n-    }\n-    *x++ = L;\n-    b->wds = n = x - b->x;\n-    n = ULbits * n - hi0bits(L);\n-    nbits = Nbits;\n-    lostbits = 0;\n+  ret_big:\n+    word0(rvp) = Big0;\n+    word1(rvp) = Big1;\n+    return;\n+  }\n+  n = s1 - s0 - 1;\n+  for (k = 0; n > (1 << (kshift - 2)) - 1; n >>= 1) {\n+    k++;\n+  }\n+  b = Balloc(k);\n+  x = b->x;\n+  n = 0;\n+  L = 0;\n+#  ifdef USE_LOCALE\n+  for (i = 0; decimalpoint[i + 1]; ++i);\n+#  endif\n+  while (s1 > s0) {\n+#  ifdef USE_LOCALE\n+    if (*--s1 == decimalpoint[i]) {\n+      s1 -= i;\n+      continue;\n+    }\n+#  else\n+    if (*--s1 == '.') {\n+      continue;\n+    }\n+#  endif\n+    if (n == ULbits) {\n+      *x++ = L;\n+      L = 0;\n+      n = 0;\n+    }\n+    L |= (hexdig[*s1] & 0x0f) << n;\n+    n += 4;\n+  }\n+  *x++ = L;\n+  b->wds = n = x - b->x;\n+  n = ULbits * n - hi0bits(L);\n+  nbits = Nbits;\n+  lostbits = 0;\n+  x = b->x;\n+  if (n > nbits) {\n+    n -= nbits;\n+    if (any_on(b, n)) {\n+      lostbits = 1;\n+      k = n - 1;\n+      if (x[k >> kshift] & 1 << (k & kmask)) {\n+        lostbits = 2;\n+        if (k > 0 && any_on(b, k)) {\n+          lostbits = 3;\n+        }\n+      }\n+    }\n+    rshift(b, n);\n+    e += n;\n+  } else if (n < nbits) {\n+    n = nbits - n;\n+    b = lshift(b, n);\n+    e -= n;\n     x = b->x;\n-    if (n > nbits) {\n-        n -= nbits;\n-        if (any_on(b, n)) {\n-            lostbits = 1;\n-            k = n - 1;\n-            if (x[k >> kshift] & 1 << (k & kmask)) {\n-                lostbits = 2;\n-                if (k > 0 && any_on(b, k)) {\n-                    lostbits = 3;\n-                }\n-            }\n-        }\n-        rshift(b, n);\n-        e += n;\n-    } else if (n < nbits) {\n-        n = nbits - n;\n-        b = lshift(b, n);\n-        e -= n;\n-        x = b->x;\n-    }\n-    if (e > Emax) {\n-    ovfl:\n-        Bfree(b);\n-    ovfl1:\n-#ifndef NO_ERRNO\n-        errno = ERANGE;\n-#endif\n-        word0(rvp) = Exp_mask;\n-        word1(rvp) = 0;\n-        return;\n-    }\n-    denorm = 0;\n-    if (e < emin) {\n-        denorm = 1;\n-        n = emin - e;\n-        if (n >= nbits) {\n-#ifdef IEEE_Arith /*{*/\n-            switch (rounding) {\n-                case Round_near:\n-                    if (n == nbits && (n < 2 || any_on(b, n - 1))) {\n-                        goto ret_tiny;\n-                    }\n-                    break;\n-                case Round_up:\n-                    if (!sign) {\n-                        goto ret_tiny;\n-                    }\n-                    break;\n-                case Round_down:\n-                    if (sign) {\n-                        goto ret_tiny;\n-                    }\n-            }\n-#endif /* } IEEE_Arith */\n-            Bfree(b);\n-        retz:\n-#ifndef NO_ERRNO\n-            errno = ERANGE;\n-#endif\n-        retz1:\n-            rvp->d = 0.;\n-            return;\n-        }\n-        k = n - 1;\n-        if (lostbits) {\n-            lostbits = 1;\n-        } else if (k > 0) {\n-            lostbits = any_on(b, k);\n-        }\n-        if (x[k >> kshift] & 1 << (k & kmask)) {\n-            lostbits |= 2;\n-        }\n-        nbits -= n;\n-        rshift(b, n);\n-        e = emin;\n-    }\n+  }\n+  if (e > Emax) {\n+  ovfl:\n+    Bfree(b);\n+  ovfl1:\n+#  ifndef NO_ERRNO\n+    errno = ERANGE;\n+#  endif\n+    word0(rvp) = Exp_mask;\n+    word1(rvp) = 0;\n+    return;\n+  }\n+  denorm = 0;\n+  if (e < emin) {\n+    denorm = 1;\n+    n = emin - e;\n+    if (n >= nbits) {\n+#  ifdef IEEE_Arith /*{*/\n+      switch (rounding) {\n+        case Round_near:\n+          if (n == nbits && (n < 2 || any_on(b, n - 1))) {\n+            goto ret_tiny;\n+          }\n+          break;\n+        case Round_up:\n+          if (!sign) {\n+            goto ret_tiny;\n+          }\n+          break;\n+        case Round_down:\n+          if (sign) {\n+            goto ret_tiny;\n+          }\n+      }\n+#  endif /* } IEEE_Arith */\n+      Bfree(b);\n+    retz:\n+#  ifndef NO_ERRNO\n+      errno = ERANGE;\n+#  endif\n+    retz1:\n+      rvp->d = 0.;\n+      return;\n+    }\n+    k = n - 1;\n     if (lostbits) {\n-        up = 0;\n-        switch (rounding) {\n-            case Round_zero:\n-                break;\n-            case Round_near:\n-                if (lostbits & 2 && (lostbits & 1) | (x[0] & 1)) {\n-                    up = 1;\n-                }\n-                break;\n-            case Round_up:\n-                up = 1 - sign;\n-                break;\n-            case Round_down:\n-                up = sign;\n+      lostbits = 1;\n+    } else if (k > 0) {\n+      lostbits = any_on(b, k);\n+    }\n+    if (x[k >> kshift] & 1 << (k & kmask)) {\n+      lostbits |= 2;\n+    }\n+    nbits -= n;\n+    rshift(b, n);\n+    e = emin;\n+  }\n+  if (lostbits) {\n+    up = 0;\n+    switch (rounding) {\n+      case Round_zero:\n+        break;\n+      case Round_near:\n+        if (lostbits & 2 && (lostbits & 1) | (x[0] & 1)) {\n+          up = 1;\n         }\n-        if (up) {\n-            k = b->wds;\n-            b = increment(b);\n-            x = b->x;\n-            if (denorm) {\n-#if 0\n+        break;\n+      case Round_up:\n+        up = 1 - sign;\n+        break;\n+      case Round_down:\n+        up = sign;\n+    }\n+    if (up) {\n+      k = b->wds;\n+      b = increment(b);\n+      x = b->x;\n+      if (denorm) {\n+#  if 0\n                 if (nbits == Nbits - 1\n                     && x[nbits >> kshift] & 1 << (nbits & kmask)) {\n                     denorm = 0;    /* not currently used */\n                 }\n-#endif\n-            } else if (b->wds > k ||\n-                       ((n = nbits & kmask) != 0 && hi0bits(x[k - 1]) < 32 - n)) {\n-                rshift(b, 1);\n-                if (++e > Emax) {\n-                    goto ovfl;\n-                }\n-            }\n-        }\n-    }\n-#ifdef IEEE_Arith\n-    if (denorm) {\n-        word0(rvp) = b->wds > 1 ? b->x[1] & ~0x100000 : 0;\n-    } else {\n-        word0(rvp) = (b->x[1] & ~0x100000) | ((e + 0x3ff + 52) << 20);\n-    }\n-    word1(rvp) = b->x[0];\n-#endif\n-#ifdef IBM\n-    if ((j = e & 3)) {\n-        k = b->x[0] & ((1 << j) - 1);\n-        rshift(b, j);\n-        if (k) {\n-            switch (rounding) {\n-                case Round_up:\n-                    if (!sign) {\n-                        increment(b);\n-                    }\n-                    break;\n-                case Round_down:\n-                    if (sign) {\n-                        increment(b);\n-                    }\n-                    break;\n-                case Round_near:\n-                    j = 1 << (j - 1);\n-                    if (k & j && ((k & (j - 1)) | lostbits)) {\n-                        increment(b);\n-                    }\n-            }\n-        }\n-    }\n-    e >>= 2;\n-    word0(rvp) = b->x[1] | ((e + 65 + 13) << 24);\n-    word1(rvp) = b->x[0];\n-#endif\n-#ifdef VAX\n-    /* The next two lines ignore swap of low- and high-order 2 bytes. */\n-    /* word0(rvp) = (b->x[1] & ~0x800000) | ((e + 129 + 55) << 23); */\n-    /* word1(rvp) = b->x[0]; */\n-    word0(rvp) =\n-        ((b->x[1] & ~0x800000) >> 16) | ((e + 129 + 55) << 7) | (b->x[1] << 16);\n-    word1(rvp) = (b->x[0] >> 16) | (b->x[0] << 16);\n-#endif\n-    Bfree(b);\n+#  endif\n+      } else if (b->wds > k ||\n+                 ((n = nbits & kmask) != 0 && hi0bits(x[k - 1]) < 32 - n)) {\n+        rshift(b, 1);\n+        if (++e > Emax) {\n+          goto ovfl;\n+        }\n+      }\n+    }\n+  }\n+#  ifdef IEEE_Arith\n+  if (denorm) {\n+    word0(rvp) = b->wds > 1 ? b->x[1] & ~0x100000 : 0;\n+  } else {\n+    word0(rvp) = (b->x[1] & ~0x100000) | ((e + 0x3ff + 52) << 20);\n+  }\n+  word1(rvp) = b->x[0];\n+#  endif\n+#  ifdef IBM\n+  if ((j = e & 3)) {\n+    k = b->x[0] & ((1 << j) - 1);\n+    rshift(b, j);\n+    if (k) {\n+      switch (rounding) {\n+        case Round_up:\n+          if (!sign) {\n+            increment(b);\n+          }\n+          break;\n+        case Round_down:\n+          if (sign) {\n+            increment(b);\n+          }\n+          break;\n+        case Round_near:\n+          j = 1 << (j - 1);\n+          if (k & j && ((k & (j - 1)) | lostbits)) {\n+            increment(b);\n+          }\n+      }\n+    }\n+  }\n+  e >>= 2;\n+  word0(rvp) = b->x[1] | ((e + 65 + 13) << 24);\n+  word1(rvp) = b->x[0];\n+#  endif\n+#  ifdef VAX\n+  /* The next two lines ignore swap of low- and high-order 2 bytes. */\n+  /* word0(rvp) = (b->x[1] & ~0x800000) | ((e + 129 + 55) << 23); */\n+  /* word1(rvp) = b->x[0]; */\n+  word0(rvp) =\n+      ((b->x[1] & ~0x800000) >> 16) | ((e + 129 + 55) << 7) | (b->x[1] << 16);\n+  word1(rvp) = (b->x[0] >> 16) | (b->x[0] << 16);\n+#  endif\n+  Bfree(b);\n }\n #endif /*!NO_HEX_FP}*/\n \n@@ -2195,11 +2191,11 @@ int p2;\n dshift(Bigint* b, int p2)\n #endif\n {\n-    int rv = hi0bits(b->x[b->wds - 1]) - 4;\n-    if (p2 > 0) {\n-        rv -= p2;\n-    }\n-    return rv & kmask;\n+  int rv = hi0bits(b->x[b->wds - 1]) - 4;\n+  if (p2 > 0) {\n+    rv -= p2;\n+  }\n+  return rv & kmask;\n }\n \n static int quorem\n@@ -2210,363 +2206,363 @@ static int quorem\n     (Bigint* b, Bigint* S)\n #endif\n {\n-    int n;\n-    ULong *bx, *bxe, q, *sx, *sxe;\n+  int n;\n+  ULong *bx, *bxe, q, *sx, *sxe;\n #ifdef ULLong\n-    ULLong borrow, carry, y, ys;\n+  ULLong borrow, carry, y, ys;\n #else\n-    ULong borrow, carry, y, ys;\n-#ifdef Pack_32\n-    ULong si, z, zs;\n-#endif\n+  ULong borrow, carry, y, ys;\n+#  ifdef Pack_32\n+  ULong si, z, zs;\n+#  endif\n #endif\n \n-    n = S->wds;\n+  n = S->wds;\n #ifdef DEBUG\n-    /*debug*/ if (b->wds > n)\n-    /*debug*/ {\n-        Bug(\"oversize b in quorem\");\n-    }\n+  /*debug*/ if (b->wds > n)\n+  /*debug*/ {\n+    Bug(\"oversize b in quorem\");\n+  }\n #endif\n-    if (b->wds < n) {\n-        return 0;\n-    }\n-    sx = S->x;\n-    sxe = sx + --n;\n-    bx = b->x;\n-    bxe = bx + n;\n-    q = *bxe / (*sxe + 1); /* ensure q <= true quotient */\n+  if (b->wds < n) {\n+    return 0;\n+  }\n+  sx = S->x;\n+  sxe = sx + --n;\n+  bx = b->x;\n+  bxe = bx + n;\n+  q = *bxe / (*sxe + 1); /* ensure q <= true quotient */\n #ifdef DEBUG\n-#ifdef NO_STRTOD_BIGCOMP\n-    /*debug*/ if (q > 9)\n-#else\n-    /* An oversized q is possible when quorem is called from bigcomp and */\n-    /* the input is near, e.g., twice the smallest denormalized number. */\n-    /*debug*/ if (q > 15)\n-#endif\n-        /*debug*/ Bug(\"oversized quotient in quorem\");\n-#endif\n-    if (q) {\n-        borrow = 0;\n-        carry = 0;\n-        do {\n+#  ifdef NO_STRTOD_BIGCOMP\n+  /*debug*/ if (q > 9)\n+#  else\n+  /* An oversized q is possible when quorem is called from bigcomp and */\n+  /* the input is near, e.g., twice the smallest denormalized number. */\n+  /*debug*/ if (q > 15)\n+#  endif\n+    /*debug*/ Bug(\"oversized quotient in quorem\");\n+#endif\n+  if (q) {\n+    borrow = 0;\n+    carry = 0;\n+    do {\n #ifdef ULLong\n-            ys = *sx++ * (ULLong)q + carry;\n-            carry = ys >> 32;\n-            y = *bx - (ys & FFFFFFFF) - borrow;\n-            borrow = y >> 32 & (ULong)1;\n-            *bx++ = y & FFFFFFFF;\n-#else\n-#ifdef Pack_32\n-            si = *sx++;\n-            ys = (si & 0xffff) * q + carry;\n-            zs = (si >> 16) * q + (ys >> 16);\n-            carry = zs >> 16;\n-            y = (*bx & 0xffff) - (ys & 0xffff) - borrow;\n-            borrow = (y & 0x10000) >> 16;\n-            z = (*bx >> 16) - (zs & 0xffff) - borrow;\n-            borrow = (z & 0x10000) >> 16;\n-            Storeinc(bx, z, y);\n+      ys = *sx++ * (ULLong)q + carry;\n+      carry = ys >> 32;\n+      y = *bx - (ys & FFFFFFFF) - borrow;\n+      borrow = y >> 32 & (ULong)1;\n+      *bx++ = y & FFFFFFFF;\n #else\n-            ys = *sx++ * q + carry;\n-            carry = ys >> 16;\n-            y = *bx - (ys & 0xffff) - borrow;\n-            borrow = (y & 0x10000) >> 16;\n-            *bx++ = y & 0xffff;\n-#endif\n-#endif\n-        } while (sx <= sxe);\n-        if (!*bxe) {\n-            bx = b->x;\n-            while (--bxe > bx && !*bxe) {\n-                --n;\n-            }\n-            b->wds = n;\n-        }\n-    }\n-    if (cmp(b, S) >= 0) {\n-        q++;\n-        borrow = 0;\n-        carry = 0;\n-        bx = b->x;\n-        sx = S->x;\n-        do {\n+#  ifdef Pack_32\n+      si = *sx++;\n+      ys = (si & 0xffff) * q + carry;\n+      zs = (si >> 16) * q + (ys >> 16);\n+      carry = zs >> 16;\n+      y = (*bx & 0xffff) - (ys & 0xffff) - borrow;\n+      borrow = (y & 0x10000) >> 16;\n+      z = (*bx >> 16) - (zs & 0xffff) - borrow;\n+      borrow = (z & 0x10000) >> 16;\n+      Storeinc(bx, z, y);\n+#  else\n+      ys = *sx++ * q + carry;\n+      carry = ys >> 16;\n+      y = *bx - (ys & 0xffff) - borrow;\n+      borrow = (y & 0x10000) >> 16;\n+      *bx++ = y & 0xffff;\n+#  endif\n+#endif\n+    } while (sx <= sxe);\n+    if (!*bxe) {\n+      bx = b->x;\n+      while (--bxe > bx && !*bxe) {\n+        --n;\n+      }\n+      b->wds = n;\n+    }\n+  }\n+  if (cmp(b, S) >= 0) {\n+    q++;\n+    borrow = 0;\n+    carry = 0;\n+    bx = b->x;\n+    sx = S->x;\n+    do {\n #ifdef ULLong\n-            ys = *sx++ + carry;\n-            carry = ys >> 32;\n-            y = *bx - (ys & FFFFFFFF) - borrow;\n-            borrow = y >> 32 & (ULong)1;\n-            *bx++ = y & FFFFFFFF;\n+      ys = *sx++ + carry;\n+      carry = ys >> 32;\n+      y = *bx - (ys & FFFFFFFF) - borrow;\n+      borrow = y >> 32 & (ULong)1;\n+      *bx++ = y & FFFFFFFF;\n #else\n-#ifdef Pack_32\n-            si = *sx++;\n-            ys = (si & 0xffff) + carry;\n-            zs = (si >> 16) + (ys >> 16);\n-            carry = zs >> 16;\n-            y = (*bx & 0xffff) - (ys & 0xffff) - borrow;\n-            borrow = (y & 0x10000) >> 16;\n-            z = (*bx >> 16) - (zs & 0xffff) - borrow;\n-            borrow = (z & 0x10000) >> 16;\n-            Storeinc(bx, z, y);\n-#else\n-            ys = *sx++ + carry;\n-            carry = ys >> 16;\n-            y = *bx - (ys & 0xffff) - borrow;\n-            borrow = (y & 0x10000) >> 16;\n-            *bx++ = y & 0xffff;\n-#endif\n-#endif\n-        } while (sx <= sxe);\n-        bx = b->x;\n-        bxe = bx + n;\n-        if (!*bxe) {\n-            while (--bxe > bx && !*bxe) {\n-                --n;\n-            }\n-            b->wds = n;\n-        }\n-    }\n-    return q;\n+#  ifdef Pack_32\n+      si = *sx++;\n+      ys = (si & 0xffff) + carry;\n+      zs = (si >> 16) + (ys >> 16);\n+      carry = zs >> 16;\n+      y = (*bx & 0xffff) - (ys & 0xffff) - borrow;\n+      borrow = (y & 0x10000) >> 16;\n+      z = (*bx >> 16) - (zs & 0xffff) - borrow;\n+      borrow = (z & 0x10000) >> 16;\n+      Storeinc(bx, z, y);\n+#  else\n+      ys = *sx++ + carry;\n+      carry = ys >> 16;\n+      y = *bx - (ys & 0xffff) - borrow;\n+      borrow = (y & 0x10000) >> 16;\n+      *bx++ = y & 0xffff;\n+#  endif\n+#endif\n+    } while (sx <= sxe);\n+    bx = b->x;\n+    bxe = bx + n;\n+    if (!*bxe) {\n+      while (--bxe > bx && !*bxe) {\n+        --n;\n+      }\n+      b->wds = n;\n+    }\n+  }\n+  return q;\n }\n \n #if defined(Avoid_Underflow) || !defined(NO_STRTOD_BIGCOMP) /*{*/\n static double sulp\n-#ifdef KR_headers\n+#  ifdef KR_headers\n     (x, bc) U* x;\n BCinfo* bc;\n-#else\n+#  else\n     (U* x, BCinfo* bc)\n-#endif\n+#  endif\n {\n-    U u;\n-    double rv;\n-    int i;\n-\n-    rv = ulp(x);\n-    if (!bc->scale ||\n-        (i = 2 * P + 1 - ((word0(x) & Exp_mask) >> Exp_shift)) <= 0) {\n-        return rv; /* Is there an example where i <= 0 ? */\n-    }\n-    word0(&u) = Exp_1 + (i << Exp_shift);\n-    word1(&u) = 0;\n-    return rv * u.d;\n+  U u;\n+  double rv;\n+  int i;\n+\n+  rv = ulp(x);\n+  if (!bc->scale ||\n+      (i = 2 * P + 1 - ((word0(x) & Exp_mask) >> Exp_shift)) <= 0) {\n+    return rv; /* Is there an example where i <= 0 ? */\n+  }\n+  word0(&u) = Exp_1 + (i << Exp_shift);\n+  word1(&u) = 0;\n+  return rv * u.d;\n }\n #endif /*}*/\n \n #ifndef NO_STRTOD_BIGCOMP\n static void bigcomp\n-#ifdef KR_headers\n+#  ifdef KR_headers\n     (rv, s0, bc) U* rv;\n CONST char* s0;\n BCinfo* bc;\n-#else\n+#  else\n     (U* rv, const char* s0, BCinfo* bc)\n-#endif\n+#  endif\n {\n-    Bigint *b, *d;\n-    int b2, bbits, d2, dd, dig, dsign, i, j, nd, nd0, p2, p5, speccase;\n-\n-    dsign = bc->dsign;\n-    nd = bc->nd;\n-    nd0 = bc->nd0;\n-    p5 = nd + bc->e0 - 1;\n-    speccase = 0;\n-#ifndef Sudden_Underflow\n-    if (rv->d == 0.) { /* special case: value near underflow-to-zero */\n-        /* threshold was rounded to zero */\n-        b = i2b(1);\n-        p2 = Emin - P + 1;\n-        bbits = 1;\n-#ifdef Avoid_Underflow\n-        word0(rv) = (P + 2) << Exp_shift;\n-#else\n-        word1(rv) = 1;\n-#endif\n-        i = 0;\n-#ifdef Honor_FLT_ROUNDS\n-        if (bc->rounding == 1)\n-#endif\n-        {\n-            speccase = 1;\n-            --p2;\n-            dsign = 0;\n-            goto have_i;\n-        }\n-    } else\n-#endif\n-        b = d2b(rv, &p2, &bbits);\n-#ifdef Avoid_Underflow\n-    p2 -= bc->scale;\n-#endif\n-    /* floor(log2(rv)) == bbits - 1 + p2 */\n-    /* Check for denormal case. */\n-    i = P - bbits;\n-    if (i > (j = P - Emin - 1 + p2)) {\n-#ifdef Sudden_Underflow\n-        Bfree(b);\n-        b = i2b(1);\n-        p2 = Emin;\n-        i = P - 1;\n-#ifdef Avoid_Underflow\n-        word0(rv) = (1 + bc->scale) << Exp_shift;\n-#else\n-        word0(rv) = Exp_msk1;\n-#endif\n-        word1(rv) = 0;\n-#else\n-        i = j;\n-#endif\n-    }\n-#ifdef Honor_FLT_ROUNDS\n-    if (bc->rounding != 1) {\n-        if (i > 0) {\n-            b = lshift(b, i);\n-        }\n-        if (dsign) {\n-            b = increment(b);\n-        }\n-    } else\n-#endif\n+  Bigint *b, *d;\n+  int b2, bbits, d2, dd, dig, dsign, i, j, nd, nd0, p2, p5, speccase;\n+\n+  dsign = bc->dsign;\n+  nd = bc->nd;\n+  nd0 = bc->nd0;\n+  p5 = nd + bc->e0 - 1;\n+  speccase = 0;\n+#  ifndef Sudden_Underflow\n+  if (rv->d == 0.) { /* special case: value near underflow-to-zero */\n+    /* threshold was rounded to zero */\n+    b = i2b(1);\n+    p2 = Emin - P + 1;\n+    bbits = 1;\n+#    ifdef Avoid_Underflow\n+    word0(rv) = (P + 2) << Exp_shift;\n+#    else\n+    word1(rv) = 1;\n+#    endif\n+    i = 0;\n+#    ifdef Honor_FLT_ROUNDS\n+    if (bc->rounding == 1)\n+#    endif\n     {\n-        b = lshift(b, ++i);\n-        b->x[0] |= 1;\n-    }\n-#ifndef Sudden_Underflow\n+      speccase = 1;\n+      --p2;\n+      dsign = 0;\n+      goto have_i;\n+    }\n+  } else\n+#  endif\n+    b = d2b(rv, &p2, &bbits);\n+#  ifdef Avoid_Underflow\n+  p2 -= bc->scale;\n+#  endif\n+  /* floor(log2(rv)) == bbits - 1 + p2 */\n+  /* Check for denormal case. */\n+  i = P - bbits;\n+  if (i > (j = P - Emin - 1 + p2)) {\n+#  ifdef Sudden_Underflow\n+    Bfree(b);\n+    b = i2b(1);\n+    p2 = Emin;\n+    i = P - 1;\n+#    ifdef Avoid_Underflow\n+    word0(rv) = (1 + bc->scale) << Exp_shift;\n+#    else\n+    word0(rv) = Exp_msk1;\n+#    endif\n+    word1(rv) = 0;\n+#  else\n+    i = j;\n+#  endif\n+  }\n+#  ifdef Honor_FLT_ROUNDS\n+  if (bc->rounding != 1) {\n+    if (i > 0) {\n+      b = lshift(b, i);\n+    }\n+    if (dsign) {\n+      b = increment(b);\n+    }\n+  } else\n+#  endif\n+  {\n+    b = lshift(b, ++i);\n+    b->x[0] |= 1;\n+  }\n+#  ifndef Sudden_Underflow\n have_i:\n-#endif\n-    p2 -= p5 + i;\n-    d = i2b(1);\n-    /* Arrange for convenient computation of quotients:\n-     * shift left if necessary so divisor has 4 leading 0 bits.\n-     */\n-    if (p5 > 0) {\n-        d = pow5mult(d, p5);\n-    } else if (p5 < 0) {\n-        b = pow5mult(b, -p5);\n-    }\n-    if (p2 > 0) {\n-        b2 = p2;\n-        d2 = 0;\n-    } else {\n-        b2 = 0;\n-        d2 = -p2;\n-    }\n-    i = dshift(d, d2);\n-    if ((b2 += i) > 0) {\n-        b = lshift(b, b2);\n-    }\n-    if ((d2 += i) > 0) {\n-        d = lshift(d, d2);\n-    }\n-\n-    /* Now b/d = exactly half-way between the two floating-point values */\n-    /* on either side of the input string.  Compute first digit of b/d. */\n-\n-    if (!(dig = quorem(b, d))) {\n-        b = multadd(b, 10, 0); /* very unlikely */\n-        dig = quorem(b, d);\n-    }\n-\n-    /* Compare b/d with s0 */\n-\n-    for (i = 0; i < nd0;) {\n-        if ((dd = s0[i++] - '0' - dig)) {\n-            goto ret;\n-        }\n-        if (!b->x[0] && b->wds == 1) {\n-            if (i < nd) {\n-                dd = 1;\n-            }\n-            goto ret;\n-        }\n-        b = multadd(b, 10, 0);\n-        dig = quorem(b, d);\n-    }\n-    for (j = bc->dp1; i++ < nd;) {\n-        if ((dd = s0[j++] - '0' - dig)) {\n-            goto ret;\n-        }\n-        if (!b->x[0] && b->wds == 1) {\n-            if (i < nd) {\n-                dd = 1;\n-            }\n-            goto ret;\n-        }\n-        b = multadd(b, 10, 0);\n-        dig = quorem(b, d);\n-    }\n-    if (b->x[0] || b->wds > 1 || dig > 0) {\n-        dd = -1;\n-    }\n+#  endif\n+  p2 -= p5 + i;\n+  d = i2b(1);\n+  /* Arrange for convenient computation of quotients:\n+   * shift left if necessary so divisor has 4 leading 0 bits.\n+   */\n+  if (p5 > 0) {\n+    d = pow5mult(d, p5);\n+  } else if (p5 < 0) {\n+    b = pow5mult(b, -p5);\n+  }\n+  if (p2 > 0) {\n+    b2 = p2;\n+    d2 = 0;\n+  } else {\n+    b2 = 0;\n+    d2 = -p2;\n+  }\n+  i = dshift(d, d2);\n+  if ((b2 += i) > 0) {\n+    b = lshift(b, b2);\n+  }\n+  if ((d2 += i) > 0) {\n+    d = lshift(d, d2);\n+  }\n+\n+  /* Now b/d = exactly half-way between the two floating-point values */\n+  /* on either side of the input string.  Compute first digit of b/d. */\n+\n+  if (!(dig = quorem(b, d))) {\n+    b = multadd(b, 10, 0); /* very unlikely */\n+    dig = quorem(b, d);\n+  }\n+\n+  /* Compare b/d with s0 */\n+\n+  for (i = 0; i < nd0;) {\n+    if ((dd = s0[i++] - '0' - dig)) {\n+      goto ret;\n+    }\n+    if (!b->x[0] && b->wds == 1) {\n+      if (i < nd) {\n+        dd = 1;\n+      }\n+      goto ret;\n+    }\n+    b = multadd(b, 10, 0);\n+    dig = quorem(b, d);\n+  }\n+  for (j = bc->dp1; i++ < nd;) {\n+    if ((dd = s0[j++] - '0' - dig)) {\n+      goto ret;\n+    }\n+    if (!b->x[0] && b->wds == 1) {\n+      if (i < nd) {\n+        dd = 1;\n+      }\n+      goto ret;\n+    }\n+    b = multadd(b, 10, 0);\n+    dig = quorem(b, d);\n+  }\n+  if (b->x[0] || b->wds > 1 || dig > 0) {\n+    dd = -1;\n+  }\n ret:\n-    Bfree(b);\n-    Bfree(d);\n-#ifdef Honor_FLT_ROUNDS\n-    if (bc->rounding != 1) {\n-        if (dd < 0) {\n-            if (bc->rounding == 0) {\n-                if (!dsign) {\n-                    goto retlow1;\n-                }\n-            } else if (dsign) {\n-                goto rethi1;\n-            }\n-        } else if (dd > 0) {\n-            if (bc->rounding == 0) {\n-                if (dsign) {\n-                    goto rethi1;\n-                }\n-                goto ret1;\n-            }\n-            if (!dsign) {\n-                goto rethi1;\n-            }\n-            dval(rv) += 2. * sulp(rv, bc);\n-        } else {\n-            bc->inexact = 0;\n-            if (dsign) {\n-                goto rethi1;\n-            }\n-        }\n-    } else\n-#endif\n-        if (speccase) {\n-        if (dd <= 0) {\n-            rv->d = 0.;\n-        }\n-    } else if (dd < 0) {\n-        if (!dsign) /* does not happen for round-near */\n-        retlow1:\n-            dval(rv) -= sulp(rv, bc);\n+  Bfree(b);\n+  Bfree(d);\n+#  ifdef Honor_FLT_ROUNDS\n+  if (bc->rounding != 1) {\n+    if (dd < 0) {\n+      if (bc->rounding == 0) {\n+        if (!dsign) {\n+          goto retlow1;\n+        }\n+      } else if (dsign) {\n+        goto rethi1;\n+      }\n     } else if (dd > 0) {\n+      if (bc->rounding == 0) {\n         if (dsign) {\n-        rethi1:\n-            dval(rv) += sulp(rv, bc);\n-        }\n+          goto rethi1;\n+        }\n+        goto ret1;\n+      }\n+      if (!dsign) {\n+        goto rethi1;\n+      }\n+      dval(rv) += 2. * sulp(rv, bc);\n     } else {\n-        /* Exact half-way case:  apply round-even rule. */\n-        if ((j = ((word0(rv) & Exp_mask) >> Exp_shift) - bc->scale) <= 0) {\n-            i = 1 - j;\n-            if (i <= 31) {\n-                if (word1(rv) & (0x1 << i)) {\n-                    goto odd;\n-                }\n-            } else if (word0(rv) & (0x1 << (i - 32))) {\n-                goto odd;\n-            }\n-        } else if (word1(rv) & 1) {\n-        odd:\n-            if (dsign) {\n-                goto rethi1;\n-            }\n-            goto retlow1;\n-        }\n-    }\n-\n-#ifdef Honor_FLT_ROUNDS\n+      bc->inexact = 0;\n+      if (dsign) {\n+        goto rethi1;\n+      }\n+    }\n+  } else\n+#  endif\n+      if (speccase) {\n+    if (dd <= 0) {\n+      rv->d = 0.;\n+    }\n+  } else if (dd < 0) {\n+    if (!dsign) /* does not happen for round-near */\n+    retlow1:\n+      dval(rv) -= sulp(rv, bc);\n+  } else if (dd > 0) {\n+    if (dsign) {\n+    rethi1:\n+      dval(rv) += sulp(rv, bc);\n+    }\n+  } else {\n+    /* Exact half-way case:  apply round-even rule. */\n+    if ((j = ((word0(rv) & Exp_mask) >> Exp_shift) - bc->scale) <= 0) {\n+      i = 1 - j;\n+      if (i <= 31) {\n+        if (word1(rv) & (0x1 << i)) {\n+          goto odd;\n+        }\n+      } else if (word0(rv) & (0x1 << (i - 32))) {\n+        goto odd;\n+      }\n+    } else if (word1(rv) & 1) {\n+    odd:\n+      if (dsign) {\n+        goto rethi1;\n+      }\n+      goto retlow1;\n+    }\n+  }\n+\n+#  ifdef Honor_FLT_ROUNDS\n ret1:\n-#endif\n-    return;\n+#  endif\n+  return;\n }\n #endif /* NO_STRTOD_BIGCOMP */\n \n@@ -2578,486 +2574,483 @@ char** se;\n     (const char* s00, char** se)\n #endif\n {\n-    int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, e, e1;\n-    int esign, i, j, k, nd, nd0, nf, nz, nz0, nz1, sign;\n-    CONST char *s, *s0, *s1;\n-    double aadj, aadj1;\n-    Long L;\n-    U aadj2, adj, rv, rv0;\n-    ULong y, z;\n-    BCinfo bc;\n-    Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;\n+  int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, e, e1;\n+  int esign, i, j, k, nd, nd0, nf, nz, nz0, nz1, sign;\n+  CONST char *s, *s0, *s1;\n+  double aadj, aadj1;\n+  Long L;\n+  U aadj2, adj, rv, rv0;\n+  ULong y, z;\n+  BCinfo bc;\n+  Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;\n #ifdef Avoid_Underflow\n-    ULong Lsb, Lsb1;\n+  ULong Lsb, Lsb1;\n #endif\n #ifdef SET_INEXACT\n-    int oldinexact;\n+  int oldinexact;\n #endif\n #ifndef NO_STRTOD_BIGCOMP\n-    int req_bigcomp = 0;\n-#endif\n-#ifdef Honor_FLT_ROUNDS /*{*/\n-#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */\n-    bc.rounding = Flt_Rounds;\n-#else  /*}{*/\n-    bc.rounding = 1;\n-    switch (fegetround()) {\n-        case FE_TOWARDZERO:\n-            bc.rounding = 0;\n-            break;\n-        case FE_UPWARD:\n-            bc.rounding = 2;\n-            break;\n-        case FE_DOWNWARD:\n-            bc.rounding = 3;\n+  int req_bigcomp = 0;\n+#endif\n+#ifdef Honor_FLT_ROUNDS   /*{*/\n+#  ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */\n+  bc.rounding = Flt_Rounds;\n+#  else  /*}{*/\n+  bc.rounding = 1;\n+  switch (fegetround()) {\n+    case FE_TOWARDZERO:\n+      bc.rounding = 0;\n+      break;\n+    case FE_UPWARD:\n+      bc.rounding = 2;\n+      break;\n+    case FE_DOWNWARD:\n+      bc.rounding = 3;\n+  }\n+#  endif /*}}*/\n+#endif   /*}*/\n+#ifdef USE_LOCALE\n+  CONST char* s2;\n+#endif\n+\n+  sign = nz0 = nz1 = nz = bc.dplen = bc.uflchk = 0;\n+  dval(&rv) = 0.;\n+  for (s = s00;; s++) switch (*s) {\n+      case '-':\n+        sign = 1;\n+      /* no break */\n+      case '+':\n+        if (*++s) {\n+          goto break2;\n+        }\n+      /* no break */\n+      case 0:\n+        goto ret0;\n+      case '\\t':\n+      case '\\n':\n+      case '\\v':\n+      case '\\f':\n+      case '\\r':\n+      case ' ':\n+        continue;\n+      default:\n+        goto break2;\n     }\n-#endif /*}}*/\n-#endif /*}*/\n-#ifdef USE_LOCALE\n-    CONST char* s2;\n-#endif\n-\n-    sign = nz0 = nz1 = nz = bc.dplen = bc.uflchk = 0;\n-    dval(&rv) = 0.;\n-    for (s = s00;; s++)\n-        switch (*s) {\n-            case '-':\n-                sign = 1;\n-            /* no break */\n-            case '+':\n-                if (*++s) {\n-                    goto break2;\n-                }\n-            /* no break */\n-            case 0:\n-                goto ret0;\n-            case '\\t':\n-            case '\\n':\n-            case '\\v':\n-            case '\\f':\n-            case '\\r':\n-            case ' ':\n-                continue;\n-            default:\n-                goto break2;\n-        }\n break2:\n-    if (*s == '0') {\n+  if (*s == '0') {\n #ifndef NO_HEX_FP /*{*/\n-        switch (s[1]) {\n-            case 'x':\n-            case 'X':\n-#ifdef Honor_FLT_ROUNDS\n-                gethex(&s, &rv, bc.rounding, sign);\n-#else\n-                gethex(&s, &rv, 1, sign);\n-#endif\n-                goto ret;\n-        }\n-#endif /*}*/\n-        nz0 = 1;\n-        while (*++s == '0')\n-            ;\n-        if (!*s) {\n-            goto ret;\n-        }\n-    }\n-    s0 = s;\n-    y = z = 0;\n-    for (nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)\n-        if (nd < 9) {\n-            y = 10 * y + c - '0';\n-        } else if (nd < 16) {\n-            z = 10 * z + c - '0';\n-        }\n-    nd0 = nd;\n-    bc.dp0 = bc.dp1 = s - s0;\n-    for (s1 = s; s1 > s0 && *--s1 == '0';) {\n-        ++nz1;\n+    switch (s[1]) {\n+      case 'x':\n+      case 'X':\n+#  ifdef Honor_FLT_ROUNDS\n+        gethex(&s, &rv, bc.rounding, sign);\n+#  else\n+        gethex(&s, &rv, 1, sign);\n+#  endif\n+        goto ret;\n     }\n+#endif /*}*/\n+    nz0 = 1;\n+    while (*++s == '0');\n+    if (!*s) {\n+      goto ret;\n+    }\n+  }\n+  s0 = s;\n+  y = z = 0;\n+  for (nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)\n+    if (nd < 9) {\n+      y = 10 * y + c - '0';\n+    } else if (nd < 16) {\n+      z = 10 * z + c - '0';\n+    }\n+  nd0 = nd;\n+  bc.dp0 = bc.dp1 = s - s0;\n+  for (s1 = s; s1 > s0 && *--s1 == '0';) {\n+    ++nz1;\n+  }\n #ifdef USE_LOCALE\n-    s1 = localeconv()->decimal_point;\n-    if (c == *s1) {\n-        c = '.';\n-        if (*++s1) {\n-            s2 = s;\n-            for (;;) {\n-                if (*++s2 != *s1) {\n-                    c = 0;\n-                    break;\n-                }\n-                if (!*++s1) {\n-                    s = s2;\n-                    break;\n-                }\n-            }\n-        }\n+  s1 = localeconv()->decimal_point;\n+  if (c == *s1) {\n+    c = '.';\n+    if (*++s1) {\n+      s2 = s;\n+      for (;;) {\n+        if (*++s2 != *s1) {\n+          c = 0;\n+          break;\n+        }\n+        if (!*++s1) {\n+          s = s2;\n+          break;\n+        }\n+      }\n+    }\n+  }\n+#endif\n+  if (c == '.') {\n+    c = *++s;\n+    bc.dp1 = s - s0;\n+    bc.dplen = bc.dp1 - bc.dp0;\n+    if (!nd) {\n+      for (; c == '0'; c = *++s) {\n+        nz++;\n+      }\n+      if (c > '0' && c <= '9') {\n+        bc.dp0 = s0 - s;\n+        bc.dp1 = bc.dp0 + bc.dplen;\n+        s0 = s;\n+        nf += nz;\n+        nz = 0;\n+        goto have_dig;\n+      }\n+      goto dig_done;\n+    }\n+    for (; c >= '0' && c <= '9'; c = *++s) {\n+    have_dig:\n+      nz++;\n+      if (c -= '0') {\n+        nf += nz;\n+        for (i = 1; i < nz; i++)\n+          if (nd++ < 9) {\n+            y *= 10;\n+          } else if (nd <= DBL_DIG + 1) {\n+            z *= 10;\n+          }\n+        if (nd++ < 9) {\n+          y = 10 * y + c;\n+        } else if (nd <= DBL_DIG + 1) {\n+          z = 10 * z + c;\n+        }\n+        nz = nz1 = 0;\n+      }\n+    }\n+  }\n+dig_done:\n+  e = 0;\n+  if (c == 'e' || c == 'E') {\n+    if (!nd && !nz && !nz0) {\n+      goto ret0;\n+    }\n+    s00 = s;\n+    esign = 0;\n+    switch (c = *++s) {\n+      case '-':\n+        esign = 1;\n+      case '+':\n+        c = *++s;\n     }\n-#endif\n-    if (c == '.') {\n+    if (c >= '0' && c <= '9') {\n+      while (c == '0') {\n         c = *++s;\n-        bc.dp1 = s - s0;\n-        bc.dplen = bc.dp1 - bc.dp0;\n-        if (!nd) {\n-            for (; c == '0'; c = *++s) {\n-                nz++;\n-            }\n-            if (c > '0' && c <= '9') {\n-                bc.dp0 = s0 - s;\n-                bc.dp1 = bc.dp0 + bc.dplen;\n-                s0 = s;\n-                nf += nz;\n-                nz = 0;\n-                goto have_dig;\n-            }\n-            goto dig_done;\n+      }\n+      if (c > '0' && c <= '9') {\n+        L = c - '0';\n+        s1 = s;\n+        while ((c = *++s) >= '0' && c <= '9') {\n+          L = 10 * L + c - '0';\n+        }\n+        if (s - s1 > 8 || L > 19999)\n+        /* Avoid confusion from exponents\n+         * so large that e might overflow.\n+         */\n+        {\n+          e = 19999; /* safe for 16 bit ints */\n+        } else {\n+          e = (int)L;\n         }\n-        for (; c >= '0' && c <= '9'; c = *++s) {\n-        have_dig:\n-            nz++;\n-            if (c -= '0') {\n-                nf += nz;\n-                for (i = 1; i < nz; i++)\n-                    if (nd++ < 9) {\n-                        y *= 10;\n-                    } else if (nd <= DBL_DIG + 1) {\n-                        z *= 10;\n-                    }\n-                if (nd++ < 9) {\n-                    y = 10 * y + c;\n-                } else if (nd <= DBL_DIG + 1) {\n-                    z = 10 * z + c;\n-                }\n-                nz = nz1 = 0;\n-            }\n+        if (esign) {\n+          e = -e;\n         }\n+      } else {\n+        e = 0;\n+      }\n+    } else {\n+      s = s00;\n     }\n-dig_done:\n-    e = 0;\n-    if (c == 'e' || c == 'E') {\n-        if (!nd && !nz && !nz0) {\n-            goto ret0;\n-        }\n-        s00 = s;\n-        esign = 0;\n-        switch (c = *++s) {\n-            case '-':\n-                esign = 1;\n-            case '+':\n-                c = *++s;\n-        }\n-        if (c >= '0' && c <= '9') {\n-            while (c == '0') {\n-                c = *++s;\n+  }\n+  if (!nd) {\n+    if (!nz && !nz0) {\n+#ifdef INFNAN_CHECK\n+      /* Check for Nan and Infinity */\n+      if (!bc.dplen) switch (c) {\n+          case 'i':\n+          case 'I':\n+            if (match(&s, \"nf\")) {\n+              --s;\n+              if (!match(&s, \"inity\")) {\n+                ++s;\n+              }\n+              word0(&rv) = 0x7ff00000;\n+              word1(&rv) = 0;\n+              goto ret;\n             }\n-            if (c > '0' && c <= '9') {\n-                L = c - '0';\n-                s1 = s;\n-                while ((c = *++s) >= '0' && c <= '9') {\n-                    L = 10 * L + c - '0';\n-                }\n-                if (s - s1 > 8 || L > 19999)\n-                /* Avoid confusion from exponents\n-                 * so large that e might overflow.\n-                 */\n-                {\n-                    e = 19999; /* safe for 16 bit ints */\n-                } else {\n-                    e = (int)L;\n-                }\n-                if (esign) {\n-                    e = -e;\n-                }\n-            } else {\n-                e = 0;\n+            break;\n+          case 'n':\n+          case 'N':\n+            if (match(&s, \"an\")) {\n+              word0(&rv) = NAN_WORD0;\n+              word1(&rv) = NAN_WORD1;\n+#  ifndef No_Hex_NaN\n+              if (*s == '(') { /*)*/\n+                hexnan(&rv, &s);\n+              }\n+#  endif\n+              goto ret;\n             }\n-        } else {\n-            s = s00;\n         }\n-    }\n-    if (!nd) {\n-        if (!nz && !nz0) {\n-#ifdef INFNAN_CHECK\n-            /* Check for Nan and Infinity */\n-            if (!bc.dplen)\n-                switch (c) {\n-                    case 'i':\n-                    case 'I':\n-                        if (match(&s, \"nf\")) {\n-                            --s;\n-                            if (!match(&s, \"inity\")) {\n-                                ++s;\n-                            }\n-                            word0(&rv) = 0x7ff00000;\n-                            word1(&rv) = 0;\n-                            goto ret;\n-                        }\n-                        break;\n-                    case 'n':\n-                    case 'N':\n-                        if (match(&s, \"an\")) {\n-                            word0(&rv) = NAN_WORD0;\n-                            word1(&rv) = NAN_WORD1;\n-#ifndef No_Hex_NaN\n-                            if (*s == '(') { /*)*/\n-                                hexnan(&rv, &s);\n-                            }\n-#endif\n-                            goto ret;\n-                        }\n-                }\n #endif /* INFNAN_CHECK */\n-        ret0:\n-            s = s00;\n-            sign = 0;\n-        }\n-        goto ret;\n+    ret0:\n+      s = s00;\n+      sign = 0;\n     }\n-    bc.e0 = e1 = e -= nf;\n+    goto ret;\n+  }\n+  bc.e0 = e1 = e -= nf;\n \n-    /* Now we have nd0 digits, starting at s0, followed by a\n-     * decimal point, followed by nd-nd0 digits.  The number we're\n-     * after is the integer represented by those digits times\n-     * 10**e */\n+  /* Now we have nd0 digits, starting at s0, followed by a\n+   * decimal point, followed by nd-nd0 digits.  The number we're\n+   * after is the integer represented by those digits times\n+   * 10**e */\n \n-    if (!nd0) {\n-        nd0 = nd;\n-    }\n-    k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;\n-    dval(&rv) = y;\n-    if (k > 9) {\n+  if (!nd0) {\n+    nd0 = nd;\n+  }\n+  k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;\n+  dval(&rv) = y;\n+  if (k > 9) {\n #ifdef SET_INEXACT\n-        if (k > DBL_DIG) {\n-            oldinexact = get_inexact();\n-        }\n-#endif\n-        dval(&rv) = tens[k - 9] * dval(&rv) + z;\n+    if (k > DBL_DIG) {\n+      oldinexact = get_inexact();\n     }\n-    bd0 = 0;\n-    if (nd <= DBL_DIG\n-#ifndef RND_PRODQUOT\n-#ifndef Honor_FLT_ROUNDS\n-        && Flt_Rounds == 1\n #endif\n+    dval(&rv) = tens[k - 9] * dval(&rv) + z;\n+  }\n+  bd0 = 0;\n+  if (nd <= DBL_DIG\n+#ifndef RND_PRODQUOT\n+#  ifndef Honor_FLT_ROUNDS\n+      && Flt_Rounds == 1\n+#  endif\n #endif\n-    ) {\n-        if (!e) {\n-            goto ret;\n-        }\n+  ) {\n+    if (!e) {\n+      goto ret;\n+    }\n #ifndef ROUND_BIASED_without_Round_Up\n-        if (e > 0) {\n-            if (e <= Ten_pmax) {\n-#ifdef VAX\n-                goto vax_ovfl_check;\n-#else\n-#ifdef Honor_FLT_ROUNDS\n-                /* round correctly FLT_ROUNDS = 2 or 3 */\n-                if (sign) {\n-                    rv.d = -rv.d;\n-                    sign = 0;\n-                }\n-#endif\n-                /* rv = */ rounded_product(dval(&rv), tens[e]);\n-                goto ret;\n-#endif\n-            }\n-            i = DBL_DIG - nd;\n-            if (e <= Ten_pmax + i) {\n-                /* A fancier test would sometimes let us do\n-                 * this for larger i values.\n-                 */\n-#ifdef Honor_FLT_ROUNDS\n-                /* round correctly FLT_ROUNDS = 2 or 3 */\n-                if (sign) {\n-                    rv.d = -rv.d;\n-                    sign = 0;\n-                }\n-#endif\n-                e -= i;\n-                dval(&rv) *= tens[i];\n-#ifdef VAX\n-                /* VAX exponent range is so narrow we must\n-                 * worry about overflow here...\n-                 */\n-            vax_ovfl_check:\n-                word0(&rv) -= P * Exp_msk1;\n-                /* rv = */ rounded_product(dval(&rv), tens[e]);\n-                if ((word0(&rv) & Exp_mask) > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P)) {\n-                    goto ovfl;\n-                }\n-                word0(&rv) += P * Exp_msk1;\n-#else\n-                /* rv = */ rounded_product(dval(&rv), tens[e]);\n-#endif\n-                goto ret;\n-            }\n-        }\n-#ifndef Inaccurate_Divide\n-        else if (e >= -Ten_pmax) {\n-#ifdef Honor_FLT_ROUNDS\n-            /* round correctly FLT_ROUNDS = 2 or 3 */\n-            if (sign) {\n-                rv.d = -rv.d;\n-                sign = 0;\n-            }\n-#endif\n-            /* rv = */ rounded_quotient(dval(&rv), tens[-e]);\n-            goto ret;\n+    if (e > 0) {\n+      if (e <= Ten_pmax) {\n+#  ifdef VAX\n+        goto vax_ovfl_check;\n+#  else\n+#    ifdef Honor_FLT_ROUNDS\n+        /* round correctly FLT_ROUNDS = 2 or 3 */\n+        if (sign) {\n+          rv.d = -rv.d;\n+          sign = 0;\n         }\n-#endif\n+#    endif\n+        /* rv = */ rounded_product(dval(&rv), tens[e]);\n+        goto ret;\n+#  endif\n+      }\n+      i = DBL_DIG - nd;\n+      if (e <= Ten_pmax + i) {\n+        /* A fancier test would sometimes let us do\n+         * this for larger i values.\n+         */\n+#  ifdef Honor_FLT_ROUNDS\n+        /* round correctly FLT_ROUNDS = 2 or 3 */\n+        if (sign) {\n+          rv.d = -rv.d;\n+          sign = 0;\n+        }\n+#  endif\n+        e -= i;\n+        dval(&rv) *= tens[i];\n+#  ifdef VAX\n+        /* VAX exponent range is so narrow we must\n+         * worry about overflow here...\n+         */\n+      vax_ovfl_check:\n+        word0(&rv) -= P * Exp_msk1;\n+        /* rv = */ rounded_product(dval(&rv), tens[e]);\n+        if ((word0(&rv) & Exp_mask) > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P)) {\n+          goto ovfl;\n+        }\n+        word0(&rv) += P * Exp_msk1;\n+#  else\n+        /* rv = */ rounded_product(dval(&rv), tens[e]);\n+#  endif\n+        goto ret;\n+      }\n+    }\n+#  ifndef Inaccurate_Divide\n+    else if (e >= -Ten_pmax) {\n+#    ifdef Honor_FLT_ROUNDS\n+      /* round correctly FLT_ROUNDS = 2 or 3 */\n+      if (sign) {\n+        rv.d = -rv.d;\n+        sign = 0;\n+      }\n+#    endif\n+      /* rv = */ rounded_quotient(dval(&rv), tens[-e]);\n+      goto ret;\n+    }\n+#  endif\n #endif /* ROUND_BIASED_without_Round_Up */\n-    }\n-    e1 += nd - k;\n+  }\n+  e1 += nd - k;\n \n #ifdef IEEE_Arith\n-#ifdef SET_INEXACT\n-    bc.inexact = 1;\n-    if (k <= DBL_DIG) {\n-        oldinexact = get_inexact();\n-    }\n-#endif\n-#ifdef Avoid_Underflow\n-    bc.scale = 0;\n-#endif\n-#ifdef Honor_FLT_ROUNDS\n-    if (bc.rounding >= 2) {\n-        if (sign) {\n-            bc.rounding = bc.rounding == 2 ? 0 : 2;\n-        } else if (bc.rounding != 2) {\n-            bc.rounding = 0;\n-        }\n-    }\n-#endif\n+#  ifdef SET_INEXACT\n+  bc.inexact = 1;\n+  if (k <= DBL_DIG) {\n+    oldinexact = get_inexact();\n+  }\n+#  endif\n+#  ifdef Avoid_Underflow\n+  bc.scale = 0;\n+#  endif\n+#  ifdef Honor_FLT_ROUNDS\n+  if (bc.rounding >= 2) {\n+    if (sign) {\n+      bc.rounding = bc.rounding == 2 ? 0 : 2;\n+    } else if (bc.rounding != 2) {\n+      bc.rounding = 0;\n+    }\n+  }\n+#  endif\n #endif /*IEEE_Arith*/\n \n-    /* Get starting approximation = rv * 10**e1 */\n+  /* Get starting approximation = rv * 10**e1 */\n \n-    if (e1 > 0) {\n-        if ((i = e1 & 15)) {\n-            dval(&rv) *= tens[i];\n-        }\n-        if (e1 &= ~15) {\n-            if (e1 > DBL_MAX_10_EXP) {\n-            ovfl:\n-                /* Can't trust HUGE_VAL */\n+  if (e1 > 0) {\n+    if ((i = e1 & 15)) {\n+      dval(&rv) *= tens[i];\n+    }\n+    if (e1 &= ~15) {\n+      if (e1 > DBL_MAX_10_EXP) {\n+      ovfl:\n+        /* Can't trust HUGE_VAL */\n #ifdef IEEE_Arith\n-#ifdef Honor_FLT_ROUNDS\n-                switch (bc.rounding) {\n-                    case 0: /* toward 0 */\n-                    case 3: /* toward -infinity */\n-                        word0(&rv) = Big0;\n-                        word1(&rv) = Big1;\n-                        break;\n-                    default:\n-                        word0(&rv) = Exp_mask;\n-                        word1(&rv) = 0;\n-                }\n-#else  /*Honor_FLT_ROUNDS*/\n-                word0(&rv) = Exp_mask;\n-                word1(&rv) = 0;\n-#endif /*Honor_FLT_ROUNDS*/\n-#ifdef SET_INEXACT\n-                /* set overflow bit */\n-                dval(&rv0) = 1e300;\n-                dval(&rv0) *= dval(&rv0);\n-#endif\n+#  ifdef Honor_FLT_ROUNDS\n+        switch (bc.rounding) {\n+          case 0: /* toward 0 */\n+          case 3: /* toward -infinity */\n+            word0(&rv) = Big0;\n+            word1(&rv) = Big1;\n+            break;\n+          default:\n+            word0(&rv) = Exp_mask;\n+            word1(&rv) = 0;\n+        }\n+#  else  /*Honor_FLT_ROUNDS*/\n+        word0(&rv) = Exp_mask;\n+        word1(&rv) = 0;\n+#  endif /*Honor_FLT_ROUNDS*/\n+#  ifdef SET_INEXACT\n+        /* set overflow bit */\n+        dval(&rv0) = 1e300;\n+        dval(&rv0) *= dval(&rv0);\n+#  endif\n #else  /*IEEE_Arith*/\n-                word0(&rv) = Big0;\n-                word1(&rv) = Big1;\n+        word0(&rv) = Big0;\n+        word1(&rv) = Big1;\n #endif /*IEEE_Arith*/\n-            range_err:\n-                if (bd0) {\n-                    Bfree(bb);\n-                    Bfree(bd);\n-                    Bfree(bs);\n-                    Bfree(bd0);\n-                    Bfree(delta);\n-                }\n+      range_err:\n+        if (bd0) {\n+          Bfree(bb);\n+          Bfree(bd);\n+          Bfree(bs);\n+          Bfree(bd0);\n+          Bfree(delta);\n+        }\n #ifndef NO_ERRNO\n-                errno = ERANGE;\n+        errno = ERANGE;\n #endif\n-                goto ret;\n-            }\n-            e1 >>= 4;\n-            for (j = 0; e1 > 1; j++, e1 >>= 1)\n-                if (e1 & 1) {\n-                    dval(&rv) *= bigtens[j];\n-                }\n-            /* The last multiplication could overflow. */\n-            word0(&rv) -= P * Exp_msk1;\n-            dval(&rv) *= bigtens[j];\n-            if ((z = word0(&rv) & Exp_mask) > Exp_msk1 * (DBL_MAX_EXP + Bias - P)) {\n-                goto ovfl;\n-            }\n-            if (z > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P)) {\n-                /* set to largest number */\n-                /* (Can't trust DBL_MAX) */\n-                word0(&rv) = Big0;\n-                word1(&rv) = Big1;\n-            } else {\n-                word0(&rv) += P * Exp_msk1;\n-            }\n-        }\n-    } else if (e1 < 0) {\n-        e1 = -e1;\n-        if ((i = e1 & 15)) {\n-            dval(&rv) /= tens[i];\n-        }\n-        if (e1 >>= 4) {\n-            if (e1 >= 1 << n_bigtens) {\n-                goto undfl;\n-            }\n+        goto ret;\n+      }\n+      e1 >>= 4;\n+      for (j = 0; e1 > 1; j++, e1 >>= 1)\n+        if (e1 & 1) {\n+          dval(&rv) *= bigtens[j];\n+        }\n+      /* The last multiplication could overflow. */\n+      word0(&rv) -= P * Exp_msk1;\n+      dval(&rv) *= bigtens[j];\n+      if ((z = word0(&rv) & Exp_mask) > Exp_msk1 * (DBL_MAX_EXP + Bias - P)) {\n+        goto ovfl;\n+      }\n+      if (z > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P)) {\n+        /* set to largest number */\n+        /* (Can't trust DBL_MAX) */\n+        word0(&rv) = Big0;\n+        word1(&rv) = Big1;\n+      } else {\n+        word0(&rv) += P * Exp_msk1;\n+      }\n+    }\n+  } else if (e1 < 0) {\n+    e1 = -e1;\n+    if ((i = e1 & 15)) {\n+      dval(&rv) /= tens[i];\n+    }\n+    if (e1 >>= 4) {\n+      if (e1 >= 1 << n_bigtens) {\n+        goto undfl;\n+      }\n #ifdef Avoid_Underflow\n-            if (e1 & Scale_Bit) {\n-                bc.scale = 2 * P;\n-            }\n-            for (j = 0; e1 > 0; j++, e1 >>= 1)\n-                if (e1 & 1) {\n-                    dval(&rv) *= tinytens[j];\n-                }\n-            if (bc.scale &&\n-                (j = 2 * P + 1 - ((word0(&rv) & Exp_mask) >> Exp_shift)) > 0) {\n-                /* scaled rv is denormal; clear j low bits */\n-                if (j >= 32) {\n-                    if (j > 54) {\n-                        goto undfl;\n-                    }\n-                    word1(&rv) = 0;\n-                    if (j >= 53) {\n-                        word0(&rv) = (P + 2) * Exp_msk1;\n-                    } else {\n-                        word0(&rv) &= 0xffffffff << (j - 32);\n-                    }\n-                } else {\n-                    word1(&rv) &= 0xffffffff << j;\n-                }\n-            }\n+      if (e1 & Scale_Bit) {\n+        bc.scale = 2 * P;\n+      }\n+      for (j = 0; e1 > 0; j++, e1 >>= 1)\n+        if (e1 & 1) {\n+          dval(&rv) *= tinytens[j];\n+        }\n+      if (bc.scale &&\n+          (j = 2 * P + 1 - ((word0(&rv) & Exp_mask) >> Exp_shift)) > 0) {\n+        /* scaled rv is denormal; clear j low bits */\n+        if (j >= 32) {\n+          if (j > 54) {\n+            goto undfl;\n+          }\n+          word1(&rv) = 0;\n+          if (j >= 53) {\n+            word0(&rv) = (P + 2) * Exp_msk1;\n+          } else {\n+            word0(&rv) &= 0xffffffff << (j - 32);\n+          }\n+        } else {\n+          word1(&rv) &= 0xffffffff << j;\n+        }\n+      }\n #else\n-            for (j = 0; e1 > 1; j++, e1 >>= 1)\n-                if (e1 & 1) {\n-                    dval(&rv) *= tinytens[j];\n-                }\n-            /* The last multiplication could underflow. */\n-            dval(&rv0) = dval(&rv);\n-            dval(&rv) *= tinytens[j];\n-            if (!dval(&rv)) {\n-                dval(&rv) = 2. * dval(&rv0);\n-                dval(&rv) *= tinytens[j];\n-#endif\n-            if (!dval(&rv)) {\n-            undfl:\n-                dval(&rv) = 0.;\n-                goto range_err;\n-            }\n+      for (j = 0; e1 > 1; j++, e1 >>= 1)\n+        if (e1 & 1) {\n+          dval(&rv) *= tinytens[j];\n+        }\n+      /* The last multiplication could underflow. */\n+      dval(&rv0) = dval(&rv);\n+      dval(&rv) *= tinytens[j];\n+      if (!dval(&rv)) {\n+        dval(&rv) = 2. * dval(&rv0);\n+        dval(&rv) *= tinytens[j];\n+#endif\n+      if (!dval(&rv)) {\n+      undfl:\n+        dval(&rv) = 0.;\n+        goto range_err;\n+      }\n #ifndef Avoid_Underflow\n-            word0(&rv) = Tiny0;\n-            word1(&rv) = Tiny1;\n-            /* The refinement below will clean\n-             * this approximation up.\n-             */\n-        }\n-#endif\n+      word0(&rv) = Tiny0;\n+      word1(&rv) = Tiny1;\n+      /* The refinement below will clean\n+       * this approximation up.\n+       */\n     }\n+#endif\n+  }\n }\n \n /* Now the hard part -- adjusting rv to the correct value.*/\n@@ -3070,578 +3063,578 @@ bc.nd0 = nd0; /* Only needed if nd > strtod_diglim, but done here */\n /* to silence an erroneous warning about bc.nd0 */\n /* possibly not being initialized. */\n if (nd > strtod_diglim) {\n-    /* ASSERT(strtod_diglim >= 18); 18 == one more than the */\n-    /* minimum number of decimal digits to distinguish double values */\n-    /* in IEEE arithmetic. */\n-    i = j = 18;\n-    if (i > nd0) {\n-        j += bc.dplen;\n-    }\n-    for (;;) {\n-        if (--j < bc.dp1 && j >= bc.dp0) {\n-            j = bc.dp0 - 1;\n-        }\n-        if (s0[j] != '0') {\n-            break;\n-        }\n-        --i;\n-    }\n-    e += nd - i;\n-    nd = i;\n-    if (nd0 > nd) {\n-        nd0 = nd;\n+  /* ASSERT(strtod_diglim >= 18); 18 == one more than the */\n+  /* minimum number of decimal digits to distinguish double values */\n+  /* in IEEE arithmetic. */\n+  i = j = 18;\n+  if (i > nd0) {\n+    j += bc.dplen;\n+  }\n+  for (;;) {\n+    if (--j < bc.dp1 && j >= bc.dp0) {\n+      j = bc.dp0 - 1;\n+    }\n+    if (s0[j] != '0') {\n+      break;\n+    }\n+    --i;\n+  }\n+  e += nd - i;\n+  nd = i;\n+  if (nd0 > nd) {\n+    nd0 = nd;\n+  }\n+  if (nd < 9) { /* must recompute y */\n+    y = 0;\n+    for (i = 0; i < nd0; ++i) {\n+      y = 10 * y + s0[i] - '0';\n     }\n-    if (nd < 9) { /* must recompute y */\n-        y = 0;\n-        for (i = 0; i < nd0; ++i) {\n-            y = 10 * y + s0[i] - '0';\n-        }\n-        for (j = bc.dp1; i < nd; ++i) {\n-            y = 10 * y + s0[j++] - '0';\n-        }\n+    for (j = bc.dp1; i < nd; ++i) {\n+      y = 10 * y + s0[j++] - '0';\n     }\n+  }\n }\n #endif\n bd0 = s2b(s0, nd0, nd, y, bc.dplen);\n \n for (;;) {\n-    bd = Balloc(bd0->k);\n-    Bcopy(bd, bd0);\n-    bb = d2b(&rv, &bbe, &bbbits); /* rv = bb * 2^bbe */\n-    bs = i2b(1);\n-\n-    if (e >= 0) {\n-        bb2 = bb5 = 0;\n-        bd2 = bd5 = e;\n-    } else {\n-        bb2 = bb5 = -e;\n-        bd2 = bd5 = 0;\n-    }\n-    if (bbe >= 0) {\n-        bb2 += bbe;\n-    } else {\n-        bd2 -= bbe;\n-    }\n-    bs2 = bb2;\n+  bd = Balloc(bd0->k);\n+  Bcopy(bd, bd0);\n+  bb = d2b(&rv, &bbe, &bbbits); /* rv = bb * 2^bbe */\n+  bs = i2b(1);\n+\n+  if (e >= 0) {\n+    bb2 = bb5 = 0;\n+    bd2 = bd5 = e;\n+  } else {\n+    bb2 = bb5 = -e;\n+    bd2 = bd5 = 0;\n+  }\n+  if (bbe >= 0) {\n+    bb2 += bbe;\n+  } else {\n+    bd2 -= bbe;\n+  }\n+  bs2 = bb2;\n #ifdef Honor_FLT_ROUNDS\n-    if (bc.rounding != 1) {\n-        bs2++;\n-    }\n+  if (bc.rounding != 1) {\n+    bs2++;\n+  }\n #endif\n #ifdef Avoid_Underflow\n-    Lsb = LSB;\n-    Lsb1 = 0;\n-    j = bbe - bc.scale;\n-    i = j + bbbits - 1; /* logb(rv) */\n-    j = P + 1 - bbbits;\n-    if (i < Emin) { /* denormal */\n-        i = Emin - i;\n-        j -= i;\n-        if (i < 32) {\n-            Lsb <<= i;\n-        } else if (i < 52) {\n-            Lsb1 = Lsb << (i - 32);\n-        } else {\n-            Lsb1 = Exp_mask;\n-        }\n+  Lsb = LSB;\n+  Lsb1 = 0;\n+  j = bbe - bc.scale;\n+  i = j + bbbits - 1; /* logb(rv) */\n+  j = P + 1 - bbbits;\n+  if (i < Emin) { /* denormal */\n+    i = Emin - i;\n+    j -= i;\n+    if (i < 32) {\n+      Lsb <<= i;\n+    } else if (i < 52) {\n+      Lsb1 = Lsb << (i - 32);\n+    } else {\n+      Lsb1 = Exp_mask;\n     }\n+  }\n #else /*Avoid_Underflow*/\n-#ifdef Sudden_Underflow\n-#ifdef IBM\n-            j = 1 + 4 * P - 3 - bbbits + ((bbe + bbbits - 1) & 3);\n-#else\n-            j = P + 1 - bbbits;\n-#endif\n-#else  /*Sudden_Underflow*/\n-            j = bbe;\n-            i = j + bbbits - 1; /* logb(rv) */\n-            if (i < Emin) {     /* denormal */\n-                j += P - Emin;\n-            } else {\n-                j = P + 1 - bbbits;\n-            }\n-#endif /*Sudden_Underflow*/\n-#endif /*Avoid_Underflow*/\n-    bb2 += j;\n-    bd2 += j;\n+#  ifdef Sudden_Underflow\n+#    ifdef IBM\n+      j = 1 + 4 * P - 3 - bbbits + ((bbe + bbbits - 1) & 3);\n+#    else\n+      j = P + 1 - bbbits;\n+#    endif\n+#  else  /*Sudden_Underflow*/\n+      j = bbe;\n+      i = j + bbbits - 1; /* logb(rv) */\n+      if (i < Emin) {     /* denormal */\n+        j += P - Emin;\n+      } else {\n+        j = P + 1 - bbbits;\n+      }\n+#  endif /*Sudden_Underflow*/\n+#endif   /*Avoid_Underflow*/\n+  bb2 += j;\n+  bd2 += j;\n #ifdef Avoid_Underflow\n-    bd2 += bc.scale;\n-#endif\n-    i = bb2 < bd2 ? bb2 : bd2;\n-    if (i > bs2) {\n-        i = bs2;\n-    }\n-    if (i > 0) {\n-        bb2 -= i;\n-        bd2 -= i;\n-        bs2 -= i;\n-    }\n-    if (bb5 > 0) {\n-        bs = pow5mult(bs, bb5);\n-        bb1 = mult(bs, bb);\n-        Bfree(bb);\n-        bb = bb1;\n-    }\n-    if (bb2 > 0) {\n-        bb = lshift(bb, bb2);\n-    }\n-    if (bd5 > 0) {\n-        bd = pow5mult(bd, bd5);\n-    }\n-    if (bd2 > 0) {\n-        bd = lshift(bd, bd2);\n-    }\n-    if (bs2 > 0) {\n-        bs = lshift(bs, bs2);\n-    }\n-    delta = diff(bb, bd);\n-    bc.dsign = delta->sign;\n-    delta->sign = 0;\n-    i = cmp(delta, bs);\n+  bd2 += bc.scale;\n+#endif\n+  i = bb2 < bd2 ? bb2 : bd2;\n+  if (i > bs2) {\n+    i = bs2;\n+  }\n+  if (i > 0) {\n+    bb2 -= i;\n+    bd2 -= i;\n+    bs2 -= i;\n+  }\n+  if (bb5 > 0) {\n+    bs = pow5mult(bs, bb5);\n+    bb1 = mult(bs, bb);\n+    Bfree(bb);\n+    bb = bb1;\n+  }\n+  if (bb2 > 0) {\n+    bb = lshift(bb, bb2);\n+  }\n+  if (bd5 > 0) {\n+    bd = pow5mult(bd, bd5);\n+  }\n+  if (bd2 > 0) {\n+    bd = lshift(bd, bd2);\n+  }\n+  if (bs2 > 0) {\n+    bs = lshift(bs, bs2);\n+  }\n+  delta = diff(bb, bd);\n+  bc.dsign = delta->sign;\n+  delta->sign = 0;\n+  i = cmp(delta, bs);\n #ifndef NO_STRTOD_BIGCOMP /*{*/\n-    if (bc.nd > nd && i <= 0) {\n-        if (bc.dsign) {\n-            /* Must use bigcomp(). */\n-            req_bigcomp = 1;\n-            break;\n-        }\n-#ifdef Honor_FLT_ROUNDS\n-        if (bc.rounding != 1) {\n-            if (i < 0) {\n-                req_bigcomp = 1;\n-                break;\n-            }\n-        } else\n-#endif\n-            i = -1; /* Discarded digits make delta smaller. */\n+  if (bc.nd > nd && i <= 0) {\n+    if (bc.dsign) {\n+      /* Must use bigcomp(). */\n+      req_bigcomp = 1;\n+      break;\n     }\n+#  ifdef Honor_FLT_ROUNDS\n+    if (bc.rounding != 1) {\n+      if (i < 0) {\n+        req_bigcomp = 1;\n+        break;\n+      }\n+    } else\n+#  endif\n+      i = -1; /* Discarded digits make delta smaller. */\n+  }\n #endif                  /*}*/\n #ifdef Honor_FLT_ROUNDS /*{*/\n-    if (bc.rounding != 1) {\n-        if (i < 0) {\n-            /* Error is less than an ulp */\n-            if (!delta->x[0] && delta->wds <= 1) {\n-                /* exact */\n-#ifdef SET_INEXACT\n-                bc.inexact = 0;\n-#endif\n-                break;\n-            }\n-            if (bc.rounding) {\n-                if (bc.dsign) {\n-                    adj.d = 1.;\n-                    goto apply_adj;\n-                }\n-            } else if (!bc.dsign) {\n-                adj.d = -1.;\n-                if (!word1(&rv) && !(word0(&rv) & Frac_mask)) {\n-                    y = word0(&rv) & Exp_mask;\n-#ifdef Avoid_Underflow\n-                    if (!bc.scale || y > 2 * P * Exp_msk1)\n-#else\n-                    if (y)\n-#endif\n-                    {\n-                        delta = lshift(delta, Log2P);\n-                        if (cmp(delta, bs) <= 0) {\n-                            adj.d = -0.5;\n-                        }\n-                    }\n-                }\n-            apply_adj:\n-#ifdef Avoid_Underflow /*{*/\n-                if (bc.scale && (y = word0(&rv) & Exp_mask) <= 2 * P * Exp_msk1) {\n-                    word0(&adj) += (2 * P + 1) * Exp_msk1 - y;\n-                }\n-#else\n-#ifdef Sudden_Underflow\n-                if ((word0(&rv) & Exp_mask) <= P * Exp_msk1) {\n-                    word0(&rv) += P * Exp_msk1;\n-                    dval(&rv) += adj.d * ulp(dval(&rv));\n-                    word0(&rv) -= P * Exp_msk1;\n-                } else\n-#endif /*Sudden_Underflow*/\n-#endif /*Avoid_Underflow}*/\n-                dval(&rv) += adj.d * ulp(&rv);\n-            }\n-            break;\n-        }\n-        adj.d = ratio(delta, bs);\n-        if (adj.d < 1.) {\n-            adj.d = 1.;\n-        }\n-        if (adj.d <= 0x7ffffffe) {\n-            /* adj = rounding ? ceil(adj) : floor(adj); */\n-            y = adj.d;\n-            if (y != adj.d) {\n-                if (!((bc.rounding >> 1) ^ bc.dsign)) {\n-                    y++;\n-                }\n-                adj.d = y;\n+  if (bc.rounding != 1) {\n+    if (i < 0) {\n+      /* Error is less than an ulp */\n+      if (!delta->x[0] && delta->wds <= 1) {\n+        /* exact */\n+#  ifdef SET_INEXACT\n+        bc.inexact = 0;\n+#  endif\n+        break;\n+      }\n+      if (bc.rounding) {\n+        if (bc.dsign) {\n+          adj.d = 1.;\n+          goto apply_adj;\n+        }\n+      } else if (!bc.dsign) {\n+        adj.d = -1.;\n+        if (!word1(&rv) && !(word0(&rv) & Frac_mask)) {\n+          y = word0(&rv) & Exp_mask;\n+#  ifdef Avoid_Underflow\n+          if (!bc.scale || y > 2 * P * Exp_msk1)\n+#  else\n+          if (y)\n+#  endif\n+          {\n+            delta = lshift(delta, Log2P);\n+            if (cmp(delta, bs) <= 0) {\n+              adj.d = -0.5;\n             }\n+          }\n         }\n-#ifdef Avoid_Underflow /*{*/\n+      apply_adj:\n+#  ifdef Avoid_Underflow /*{*/\n         if (bc.scale && (y = word0(&rv) & Exp_mask) <= 2 * P * Exp_msk1) {\n-            word0(&adj) += (2 * P + 1) * Exp_msk1 - y;\n+          word0(&adj) += (2 * P + 1) * Exp_msk1 - y;\n         }\n-#else\n-#ifdef Sudden_Underflow\n+#  else\n+#    ifdef Sudden_Underflow\n         if ((word0(&rv) & Exp_mask) <= P * Exp_msk1) {\n-            word0(&rv) += P * Exp_msk1;\n-            adj.d *= ulp(dval(&rv));\n-            if (bc.dsign) {\n-                dval(&rv) += adj.d;\n-            } else {\n-                dval(&rv) -= adj.d;\n-            }\n-            word0(&rv) -= P * Exp_msk1;\n-            goto cont;\n-        }\n-#endif /*Sudden_Underflow*/\n-#endif /*Avoid_Underflow}*/\n-        adj.d *= ulp(&rv);\n-        if (bc.dsign) {\n-            if (word0(&rv) == Big0 && word1(&rv) == Big1) {\n-                goto ovfl;\n-            }\n-            dval(&rv) += adj.d;\n-        } else {\n-            dval(&rv) -= adj.d;\n-        }\n-        goto cont;\n+          word0(&rv) += P * Exp_msk1;\n+          dval(&rv) += adj.d * ulp(dval(&rv));\n+          word0(&rv) -= P * Exp_msk1;\n+        } else\n+#    endif /*Sudden_Underflow*/\n+#  endif   /*Avoid_Underflow}*/\n+        dval(&rv) += adj.d * ulp(&rv);\n+      }\n+      break;\n+    }\n+    adj.d = ratio(delta, bs);\n+    if (adj.d < 1.) {\n+      adj.d = 1.;\n+    }\n+    if (adj.d <= 0x7ffffffe) {\n+      /* adj = rounding ? ceil(adj) : floor(adj); */\n+      y = adj.d;\n+      if (y != adj.d) {\n+        if (!((bc.rounding >> 1) ^ bc.dsign)) {\n+          y++;\n+        }\n+        adj.d = y;\n+      }\n+    }\n+#  ifdef Avoid_Underflow /*{*/\n+    if (bc.scale && (y = word0(&rv) & Exp_mask) <= 2 * P * Exp_msk1) {\n+      word0(&adj) += (2 * P + 1) * Exp_msk1 - y;\n+    }\n+#  else\n+#    ifdef Sudden_Underflow\n+    if ((word0(&rv) & Exp_mask) <= P * Exp_msk1) {\n+      word0(&rv) += P * Exp_msk1;\n+      adj.d *= ulp(dval(&rv));\n+      if (bc.dsign) {\n+        dval(&rv) += adj.d;\n+      } else {\n+        dval(&rv) -= adj.d;\n+      }\n+      word0(&rv) -= P * Exp_msk1;\n+      goto cont;\n+    }\n+#    endif /*Sudden_Underflow*/\n+#  endif   /*Avoid_Underflow}*/\n+    adj.d *= ulp(&rv);\n+    if (bc.dsign) {\n+      if (word0(&rv) == Big0 && word1(&rv) == Big1) {\n+        goto ovfl;\n+      }\n+      dval(&rv) += adj.d;\n+    } else {\n+      dval(&rv) -= adj.d;\n     }\n+    goto cont;\n+  }\n #endif /*}Honor_FLT_ROUNDS*/\n \n-    if (i < 0) {\n-        /* Error is less than half an ulp -- check for\n-         * special case of mantissa a power of two.\n-         */\n-        if (bc.dsign || word1(&rv) || word0(&rv) & Bndry_mask\n+  if (i < 0) {\n+    /* Error is less than half an ulp -- check for\n+     * special case of mantissa a power of two.\n+     */\n+    if (bc.dsign || word1(&rv) || word0(&rv) & Bndry_mask\n #ifdef IEEE_Arith /*{*/\n-#ifdef Avoid_Underflow\n-            || (word0(&rv) & Exp_mask) <= (2 * P + 1) * Exp_msk1\n-#else\n-            || (word0(&rv) & Exp_mask) <= Exp_msk1\n-#endif\n+#  ifdef Avoid_Underflow\n+        || (word0(&rv) & Exp_mask) <= (2 * P + 1) * Exp_msk1\n+#  else\n+        || (word0(&rv) & Exp_mask) <= Exp_msk1\n+#  endif\n #endif /*}*/\n-        ) {\n+    ) {\n #ifdef SET_INEXACT\n-            if (!delta->x[0] && delta->wds <= 1) {\n-                bc.inexact = 0;\n-            }\n+      if (!delta->x[0] && delta->wds <= 1) {\n+        bc.inexact = 0;\n+      }\n #endif\n-            break;\n-        }\n-        if (!delta->x[0] && delta->wds <= 1) {\n-            /* exact result */\n+      break;\n+    }\n+    if (!delta->x[0] && delta->wds <= 1) {\n+      /* exact result */\n #ifdef SET_INEXACT\n-            bc.inexact = 0;\n+      bc.inexact = 0;\n+#endif\n+      break;\n+    }\n+    delta = lshift(delta, Log2P);\n+    if (cmp(delta, bs) > 0) {\n+      goto drop_down;\n+    }\n+    break;\n+  }\n+  if (i == 0) {\n+    /* exactly half-way between */\n+    if (bc.dsign) {\n+      if ((word0(&rv) & Bndry_mask1) == Bndry_mask1 &&\n+          word1(&rv) ==\n+              (\n+#ifdef Avoid_Underflow\n+                  (bc.scale && (y = word0(&rv) & Exp_mask) <= 2 * P * Exp_msk1)\n+                      ? (0xffffffff &\n+                         (0xffffffff << (2 * P + 1 - (y >> Exp_shift))))\n+                      :\n #endif\n-            break;\n+                      0xffffffff)) {\n+        /*boundary case -- increment exponent*/\n+        if (word0(&rv) == Big0 && word1(&rv) == Big1) {\n+          goto ovfl;\n         }\n-        delta = lshift(delta, Log2P);\n-        if (cmp(delta, bs) > 0) {\n-            goto drop_down;\n-        }\n-        break;\n-    }\n-    if (i == 0) {\n-        /* exactly half-way between */\n-        if (bc.dsign) {\n-            if ((word0(&rv) & Bndry_mask1) == Bndry_mask1 &&\n-                word1(&rv) ==\n-                    (\n-#ifdef Avoid_Underflow\n-                        (bc.scale && (y = word0(&rv) & Exp_mask) <= 2 * P * Exp_msk1)\n-                            ? (0xffffffff &\n-                               (0xffffffff << (2 * P + 1 - (y >> Exp_shift))))\n-                            :\n-#endif\n-                            0xffffffff)) {\n-                /*boundary case -- increment exponent*/\n-                if (word0(&rv) == Big0 && word1(&rv) == Big1) {\n-                    goto ovfl;\n-                }\n-                word0(&rv) = (word0(&rv) & Exp_mask) + Exp_msk1\n+        word0(&rv) = (word0(&rv) & Exp_mask) + Exp_msk1\n #ifdef IBM\n-                             | Exp_msk1 >> 4\n+                     | Exp_msk1 >> 4\n #endif\n-                    ;\n-                word1(&rv) = 0;\n+            ;\n+        word1(&rv) = 0;\n #ifdef Avoid_Underflow\n-                bc.dsign = 0;\n+        bc.dsign = 0;\n #endif\n-                break;\n-            }\n-        } else if (!(word0(&rv) & Bndry_mask) && !word1(&rv)) {\n-        drop_down:\n-            /* boundary case -- decrement exponent */\n+        break;\n+      }\n+    } else if (!(word0(&rv) & Bndry_mask) && !word1(&rv)) {\n+    drop_down:\n+      /* boundary case -- decrement exponent */\n #ifdef Sudden_Underflow /*{{*/\n+      L = word0(&rv) & Exp_mask;\n+#  ifdef IBM\n+      if (L < Exp_msk1)\n+#  else\n+#    ifdef Avoid_Underflow\n+      if (L <= (bc.scale ? (2 * P + 1) * Exp_msk1 : Exp_msk1))\n+#    else\n+      if (L <= Exp_msk1)\n+#    endif /*Avoid_Underflow*/\n+#  endif   /*IBM*/\n+      {\n+        if (bc.nd > nd) {\n+          bc.uflchk = 1;\n+          break;\n+        }\n+        goto undfl;\n+      }\n+      L -= Exp_msk1;\n+#else /*Sudden_Underflow}{*/\n+#  ifdef Avoid_Underflow\n+          if (bc.scale) {\n             L = word0(&rv) & Exp_mask;\n-#ifdef IBM\n-            if (L < Exp_msk1)\n-#else\n-#ifdef Avoid_Underflow\n-            if (L <= (bc.scale ? (2 * P + 1) * Exp_msk1 : Exp_msk1))\n-#else\n-            if (L <= Exp_msk1)\n-#endif /*Avoid_Underflow*/\n-#endif /*IBM*/\n-            {\n-                if (bc.nd > nd) {\n-                    bc.uflchk = 1;\n-                    break;\n-                }\n-                goto undfl;\n+            if (L <= (2 * P + 1) * Exp_msk1) {\n+              if (L > (P + 2) * Exp_msk1)\n+              /* round even ==> */\n+              /* accept rv */\n+              {\n+                break;\n+              }\n+              /* rv = smallest denormal */\n+              if (bc.nd > nd) {\n+                bc.uflchk = 1;\n+                break;\n+              }\n+              goto undfl;\n             }\n-            L -= Exp_msk1;\n-#else /*Sudden_Underflow}{*/\n-#ifdef Avoid_Underflow\n-                    if (bc.scale) {\n-                        L = word0(&rv) & Exp_mask;\n-                        if (L <= (2 * P + 1) * Exp_msk1) {\n-                            if (L > (P + 2) * Exp_msk1)\n-                            /* round even ==> */\n-                            /* accept rv */\n-                            {\n-                                break;\n-                            }\n-                            /* rv = smallest denormal */\n-                            if (bc.nd > nd) {\n-                                bc.uflchk = 1;\n-                                break;\n-                            }\n-                            goto undfl;\n-                        }\n-                    }\n-#endif /*Avoid_Underflow*/\n-                    L = (word0(&rv) & Exp_mask) - Exp_msk1;\n-#endif /*Sudden_Underflow}}*/\n-            word0(&rv) = L | Bndry_mask1;\n-            word1(&rv) = 0xffffffff;\n+          }\n+#  endif /*Avoid_Underflow*/\n+          L = (word0(&rv) & Exp_mask) - Exp_msk1;\n+#endif   /*Sudden_Underflow}}*/\n+      word0(&rv) = L | Bndry_mask1;\n+      word1(&rv) = 0xffffffff;\n #ifdef IBM\n-            goto cont;\n+      goto cont;\n #else\n-#ifndef NO_STRTOD_BIGCOMP\n-                    if (bc.nd > nd) {\n-                        goto cont;\n-                    }\n-#endif\n-                    break;\n+#  ifndef NO_STRTOD_BIGCOMP\n+          if (bc.nd > nd) {\n+            goto cont;\n+          }\n+#  endif\n+          break;\n #endif\n-        }\n+    }\n #ifndef ROUND_BIASED\n-#ifdef Avoid_Underflow\n-        if (Lsb1) {\n-            if (!(word0(&rv) & Lsb1)) {\n-                break;\n-            }\n-        } else if (!(word1(&rv) & Lsb)) {\n-            break;\n-        }\n-#else\n-        if (!(word1(&rv) & LSB)) {\n-            break;\n-        }\n-#endif\n+#  ifdef Avoid_Underflow\n+    if (Lsb1) {\n+      if (!(word0(&rv) & Lsb1)) {\n+        break;\n+      }\n+    } else if (!(word1(&rv) & Lsb)) {\n+      break;\n+    }\n+#  else\n+    if (!(word1(&rv) & LSB)) {\n+      break;\n+    }\n+#  endif\n #endif\n-        if (bc.dsign)\n+    if (bc.dsign)\n #ifdef Avoid_Underflow\n-            dval(&rv) += sulp(&rv, &bc);\n+      dval(&rv) += sulp(&rv, &bc);\n #else\n-                    dval(&rv) += ulp(&rv);\n+          dval(&rv) += ulp(&rv);\n #endif\n #ifndef ROUND_BIASED\n-        else {\n-#ifdef Avoid_Underflow\n-            dval(&rv) -= sulp(&rv, &bc);\n-#else\n-            dval(&rv) -= ulp(&rv);\n-#endif\n-#ifndef Sudden_Underflow\n-            if (!dval(&rv)) {\n-                if (bc.nd > nd) {\n-                    bc.uflchk = 1;\n-                    break;\n-                }\n-                goto undfl;\n-            }\n-#endif\n+    else {\n+#  ifdef Avoid_Underflow\n+      dval(&rv) -= sulp(&rv, &bc);\n+#  else\n+      dval(&rv) -= ulp(&rv);\n+#  endif\n+#  ifndef Sudden_Underflow\n+      if (!dval(&rv)) {\n+        if (bc.nd > nd) {\n+          bc.uflchk = 1;\n+          break;\n         }\n-#ifdef Avoid_Underflow\n-        bc.dsign = 1 - bc.dsign;\n-#endif\n-#endif\n-        break;\n-    }\n-    if ((aadj = ratio(delta, bs)) <= 2.) {\n-        if (bc.dsign) {\n-            aadj = aadj1 = 1.;\n-        } else if (word1(&rv) || word0(&rv) & Bndry_mask) {\n+        goto undfl;\n+      }\n+#  endif\n+    }\n+#  ifdef Avoid_Underflow\n+    bc.dsign = 1 - bc.dsign;\n+#  endif\n+#endif\n+    break;\n+  }\n+  if ((aadj = ratio(delta, bs)) <= 2.) {\n+    if (bc.dsign) {\n+      aadj = aadj1 = 1.;\n+    } else if (word1(&rv) || word0(&rv) & Bndry_mask) {\n #ifndef Sudden_Underflow\n-            if (word1(&rv) == Tiny1 && !word0(&rv)) {\n-                if (bc.nd > nd) {\n-                    bc.uflchk = 1;\n-                    break;\n-                }\n-                goto undfl;\n-            }\n-#endif\n-            aadj = 1.;\n-            aadj1 = -1.;\n-        } else {\n-            /* special case -- power of FLT_RADIX to be */\n-            /* rounded down... */\n-\n-            if (aadj < 2. / FLT_RADIX) {\n-                aadj = 1. / FLT_RADIX;\n-            } else {\n-                aadj *= 0.5;\n-            }\n-            aadj1 = -aadj;\n+      if (word1(&rv) == Tiny1 && !word0(&rv)) {\n+        if (bc.nd > nd) {\n+          bc.uflchk = 1;\n+          break;\n         }\n+        goto undfl;\n+      }\n+#endif\n+      aadj = 1.;\n+      aadj1 = -1.;\n     } else {\n+      /* special case -- power of FLT_RADIX to be */\n+      /* rounded down... */\n+\n+      if (aadj < 2. / FLT_RADIX) {\n+        aadj = 1. / FLT_RADIX;\n+      } else {\n         aadj *= 0.5;\n-        aadj1 = bc.dsign ? aadj : -aadj;\n+      }\n+      aadj1 = -aadj;\n+    }\n+  } else {\n+    aadj *= 0.5;\n+    aadj1 = bc.dsign ? aadj : -aadj;\n #ifdef Check_FLT_ROUNDS\n-        switch (bc.rounding) {\n-            case 2: /* towards +infinity */\n-                aadj1 -= 0.5;\n-                break;\n-            case 0: /* towards 0 */\n-            case 3: /* towards -infinity */\n-                aadj1 += 0.5;\n-        }\n+    switch (bc.rounding) {\n+      case 2: /* towards +infinity */\n+        aadj1 -= 0.5;\n+        break;\n+      case 0: /* towards 0 */\n+      case 3: /* towards -infinity */\n+        aadj1 += 0.5;\n+    }\n #else\n-                if (Flt_Rounds == 0) {\n-                    aadj1 += 0.5;\n-                }\n+        if (Flt_Rounds == 0) {\n+          aadj1 += 0.5;\n+        }\n #endif /*Check_FLT_ROUNDS*/\n+  }\n+  y = word0(&rv) & Exp_mask;\n+\n+  /* Check for overflow */\n+\n+  if (y == Exp_msk1 * (DBL_MAX_EXP + Bias - 1)) {\n+    dval(&rv0) = dval(&rv);\n+    word0(&rv) -= P * Exp_msk1;\n+    adj.d = aadj1 * ulp(&rv);\n+    dval(&rv) += adj.d;\n+    if ((word0(&rv) & Exp_mask) >= Exp_msk1 * (DBL_MAX_EXP + Bias - P)) {\n+      if (word0(&rv0) == Big0 && word1(&rv0) == Big1) {\n+        goto ovfl;\n+      }\n+      word0(&rv) = Big0;\n+      word1(&rv) = Big1;\n+      goto cont;\n+    } else {\n+      word0(&rv) += P * Exp_msk1;\n     }\n-    y = word0(&rv) & Exp_mask;\n-\n-    /* Check for overflow */\n-\n-    if (y == Exp_msk1 * (DBL_MAX_EXP + Bias - 1)) {\n-        dval(&rv0) = dval(&rv);\n-        word0(&rv) -= P * Exp_msk1;\n-        adj.d = aadj1 * ulp(&rv);\n-        dval(&rv) += adj.d;\n-        if ((word0(&rv) & Exp_mask) >= Exp_msk1 * (DBL_MAX_EXP + Bias - P)) {\n-            if (word0(&rv0) == Big0 && word1(&rv0) == Big1) {\n-                goto ovfl;\n-            }\n-            word0(&rv) = Big0;\n-            word1(&rv) = Big1;\n-            goto cont;\n-        } else {\n-            word0(&rv) += P * Exp_msk1;\n+  } else {\n+#ifdef Avoid_Underflow\n+    if (bc.scale && y <= 2 * P * Exp_msk1) {\n+      if (aadj <= 0x7fffffff) {\n+        if ((z = aadj) <= 0) {\n+          z = 1;\n+        }\n+        aadj = z;\n+        aadj1 = bc.dsign ? aadj : -aadj;\n+      }\n+      dval(&aadj2) = aadj1;\n+      word0(&aadj2) += (2 * P + 1) * Exp_msk1 - y;\n+      aadj1 = dval(&aadj2);\n+      adj.d = aadj1 * ulp(&rv);\n+      dval(&rv) += adj.d;\n+      if (rv.d == 0.)\n+#  ifdef NO_STRTOD_BIGCOMP\n+        goto undfl;\n+#  else\n+      {\n+        if (bc.nd > nd) {\n+          bc.dsign = 1;\n         }\n+        break;\n+      }\n+#  endif\n     } else {\n-#ifdef Avoid_Underflow\n-        if (bc.scale && y <= 2 * P * Exp_msk1) {\n-            if (aadj <= 0x7fffffff) {\n-                if ((z = aadj) <= 0) {\n-                    z = 1;\n-                }\n-                aadj = z;\n-                aadj1 = bc.dsign ? aadj : -aadj;\n-            }\n-            dval(&aadj2) = aadj1;\n-            word0(&aadj2) += (2 * P + 1) * Exp_msk1 - y;\n-            aadj1 = dval(&aadj2);\n-            adj.d = aadj1 * ulp(&rv);\n-            dval(&rv) += adj.d;\n-            if (rv.d == 0.)\n-#ifdef NO_STRTOD_BIGCOMP\n-                goto undfl;\n+      adj.d = aadj1 * ulp(&rv);\n+      dval(&rv) += adj.d;\n+    }\n #else\n-            {\n-                if (bc.nd > nd) {\n-                    bc.dsign = 1;\n-                }\n+#  ifdef Sudden_Underflow\n+        if ((word0(&rv) & Exp_mask) <= P * Exp_msk1) {\n+          dval(&rv0) = dval(&rv);\n+          word0(&rv) += P * Exp_msk1;\n+          adj.d = aadj1 * ulp(&rv);\n+          dval(&rv) += adj.d;\n+#    ifdef IBM\n+          if ((word0(&rv) & Exp_mask) < P * Exp_msk1)\n+#    else\n+          if ((word0(&rv) & Exp_mask) <= P * Exp_msk1)\n+#    endif\n+          {\n+            if (word0(&rv0) == Tiny0 && word1(&rv0) == Tiny1) {\n+              if (bc.nd > nd) {\n+                bc.uflchk = 1;\n                 break;\n+              }\n+              goto undfl;\n             }\n-#endif\n+            word0(&rv) = Tiny0;\n+            word1(&rv) = Tiny1;\n+            goto cont;\n+          } else {\n+            word0(&rv) -= P * Exp_msk1;\n+          }\n         } else {\n-            adj.d = aadj1 * ulp(&rv);\n-            dval(&rv) += adj.d;\n+          adj.d = aadj1 * ulp(&rv);\n+          dval(&rv) += adj.d;\n+        }\n+#  else  /*Sudden_Underflow*/\n+        /* Compute adj so that the IEEE rounding rules will\n+         * correctly round rv + adj in some half-way cases.\n+         * If rv * ulp(rv) is denormalized (i.e.,\n+         * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid\n+         * trouble from bits lost to denormalization;\n+         * example: 1.2e-307 .\n+         */\n+        if (y <= (P - 1) * Exp_msk1 && aadj > 1.) {\n+          aadj1 = (double)(int)(aadj + 0.5);\n+          if (!bc.dsign) {\n+            aadj1 = -aadj1;\n+          }\n         }\n-#else\n-#ifdef Sudden_Underflow\n-                if ((word0(&rv) & Exp_mask) <= P * Exp_msk1) {\n-                    dval(&rv0) = dval(&rv);\n-                    word0(&rv) += P * Exp_msk1;\n-                    adj.d = aadj1 * ulp(&rv);\n-                    dval(&rv) += adj.d;\n-#ifdef IBM\n-                    if ((word0(&rv) & Exp_mask) < P * Exp_msk1)\n-#else\n-                    if ((word0(&rv) & Exp_mask) <= P * Exp_msk1)\n-#endif\n-                    {\n-                        if (word0(&rv0) == Tiny0 && word1(&rv0) == Tiny1) {\n-                            if (bc.nd > nd) {\n-                                bc.uflchk = 1;\n-                                break;\n-                            }\n-                            goto undfl;\n-                        }\n-                        word0(&rv) = Tiny0;\n-                        word1(&rv) = Tiny1;\n-                        goto cont;\n-                    } else {\n-                        word0(&rv) -= P * Exp_msk1;\n-                    }\n-                } else {\n-                    adj.d = aadj1 * ulp(&rv);\n-                    dval(&rv) += adj.d;\n-                }\n-#else  /*Sudden_Underflow*/\n-                /* Compute adj so that the IEEE rounding rules will\n-                 * correctly round rv + adj in some half-way cases.\n-                 * If rv * ulp(rv) is denormalized (i.e.,\n-                 * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid\n-                 * trouble from bits lost to denormalization;\n-                 * example: 1.2e-307 .\n-                 */\n-                if (y <= (P - 1) * Exp_msk1 && aadj > 1.) {\n-                    aadj1 = (double)(int)(aadj + 0.5);\n-                    if (!bc.dsign) {\n-                        aadj1 = -aadj1;\n-                    }\n-                }\n-                adj.d = aadj1 * ulp(&rv);\n-                dval(&rv) += adj.d;\n-#endif /*Sudden_Underflow*/\n-#endif /*Avoid_Underflow*/\n-    }\n-    z = word0(&rv) & Exp_mask;\n+        adj.d = aadj1 * ulp(&rv);\n+        dval(&rv) += adj.d;\n+#  endif /*Sudden_Underflow*/\n+#endif   /*Avoid_Underflow*/\n+  }\n+  z = word0(&rv) & Exp_mask;\n #ifndef SET_INEXACT\n-    if (bc.nd == nd) {\n-#ifdef Avoid_Underflow\n-        if (!bc.scale)\n-#endif\n-            if (y == z) {\n-                /* Can we stop now? */\n-                L = (Long)aadj;\n-                aadj -= L;\n-                /* The tolerances below are conservative. */\n-                if (bc.dsign || word1(&rv) || word0(&rv) & Bndry_mask) {\n-                    if (aadj < .4999999 || aadj > .5000001) {\n-                        break;\n-                    }\n-                } else if (aadj < .4999999 / FLT_RADIX) {\n-                    break;\n-                }\n-            }\n-    }\n+  if (bc.nd == nd) {\n+#  ifdef Avoid_Underflow\n+    if (!bc.scale)\n+#  endif\n+      if (y == z) {\n+        /* Can we stop now? */\n+        L = (Long)aadj;\n+        aadj -= L;\n+        /* The tolerances below are conservative. */\n+        if (bc.dsign || word1(&rv) || word0(&rv) & Bndry_mask) {\n+          if (aadj < .4999999 || aadj > .5000001) {\n+            break;\n+          }\n+        } else if (aadj < .4999999 / FLT_RADIX) {\n+          break;\n+        }\n+      }\n+  }\n #endif\n cont:\n-    Bfree(bb);\n-    Bfree(bd);\n-    Bfree(bs);\n-    Bfree(delta);\n+  Bfree(bb);\n+  Bfree(bd);\n+  Bfree(bs);\n+  Bfree(delta);\n }\n Bfree(bb);\n Bfree(bd);\n@@ -3650,56 +3643,53 @@ Bfree(bd0);\n Bfree(delta);\n #ifndef NO_STRTOD_BIGCOMP\n if (req_bigcomp) {\n-    bd0 = 0;\n-    bc.e0 += nz1;\n-    bigcomp(&rv, s0, &bc);\n-    y = word0(&rv) & Exp_mask;\n-    if (y == Exp_mask) {\n-        goto ovfl;\n-    }\n-    if (y == 0 && rv.d == 0.) {\n-        goto undfl;\n-    }\n+  bd0 = 0;\n+  bc.e0 += nz1;\n+  bigcomp(&rv, s0, &bc);\n+  y = word0(&rv) & Exp_mask;\n+  if (y == Exp_mask) {\n+    goto ovfl;\n+  }\n+  if (y == 0 && rv.d == 0.) {\n+    goto undfl;\n+  }\n }\n #endif\n #ifdef SET_INEXACT\n if (bc.inexact) {\n-    if (!oldinexact) {\n-        word0(&rv0) = Exp_1 + (70 << Exp_shift);\n-        word1(&rv0) = 0;\n-        dval(&rv0) += 1.;\n-    }\n+  if (!oldinexact) {\n+    word0(&rv0) = Exp_1 + (70 << Exp_shift);\n+    word1(&rv0) = 0;\n+    dval(&rv0) += 1.;\n+  }\n } else if (!oldinexact) {\n-    clear_inexact();\n+  clear_inexact();\n }\n #endif\n #ifdef Avoid_Underflow\n if (bc.scale) {\n-    word0(&rv0) = Exp_1 - 2 * P * Exp_msk1;\n-    word1(&rv0) = 0;\n-    dval(&rv) *= dval(&rv0);\n-#ifndef NO_ERRNO\n-    /* try to avoid the bug of testing an 8087 register value */\n-#ifdef IEEE_Arith\n-    if (!(word0(&rv) & Exp_mask))\n-#else\n-    if (word0(&rv) == 0 && word1(&rv) == 0)\n-#endif\n-        errno = ERANGE;\n-#endif\n+  word0(&rv0) = Exp_1 - 2 * P * Exp_msk1;\n+  word1(&rv0) = 0;\n+  dval(&rv) *= dval(&rv0);\n+#  ifndef NO_ERRNO\n+  /* try to avoid the bug of testing an 8087 register value */\n+#    ifdef IEEE_Arith\n+  if (!(word0(&rv) & Exp_mask))\n+#    else\n+  if (word0(&rv) == 0 && word1(&rv) == 0)\n+#    endif\n+    errno = ERANGE;\n+#  endif\n }\n #endif /* Avoid_Underflow */\n #ifdef SET_INEXACT\n if (bc.inexact && !(word0(&rv) & Exp_mask)) {\n-    /* set underflow bit */\n-    dval(&rv0) = 1e-300;\n-    dval(&rv0) *= dval(&rv0);\n+  /* set underflow bit */\n+  dval(&rv0) = 1e-300;\n+  dval(&rv0) *= dval(&rv0);\n }\n #endif\n-ret: if (se)\n-{\n-    *se = (char*)s;\n-}\n+ret: if (se) { *se = (char*)s; }\n return sign ? -dval(&rv) : dval(&rv);\n }\n \n@@ -3712,22 +3702,22 @@ static char*\n rv_alloc(i)\n int i;\n #else\n-    rv_alloc(int i)\n+  rv_alloc(int i)\n #endif\n {\n-    int j, k, *r;\n+  int j, k, *r;\n \n-    j = sizeof(ULong);\n-    for (k = 0; sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i; j <<= 1) {\n-        k++;\n-    }\n-    r = (int*)Balloc(k);\n-    *r = k;\n-    return\n+  j = sizeof(ULong);\n+  for (k = 0; sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i; j <<= 1) {\n+    k++;\n+  }\n+  r = (int*)Balloc(k);\n+  *r = k;\n+  return\n #ifndef MULTIPLE_THREADS\n-        dtoa_result =\n+      dtoa_result =\n #endif\n-            (char*)(r + 1);\n+          (char*)(r + 1);\n }\n \n static char*\n@@ -3736,19 +3726,19 @@ nrv_alloc(s, rve, n)\n char *s, **rve;\n int n;\n #else\n-    nrv_alloc(const char* s, char** rve, int n)\n+  nrv_alloc(const char* s, char** rve, int n)\n #endif\n {\n-    char *rv, *t;\n-\n-    t = rv = rv_alloc(n);\n-    while ((*t = *s++)) {\n-        t++;\n-    }\n-    if (rve) {\n-        *rve = t;\n-    }\n-    return rv;\n+  char *rv, *t;\n+\n+  t = rv = rv_alloc(n);\n+  while ((*t = *s++)) {\n+    t++;\n+  }\n+  if (rve) {\n+    *rve = t;\n+  }\n+  return rv;\n }\n \n /* freedtoa(s) must be used to free values s returned by dtoa\n@@ -3761,16 +3751,16 @@ void\n #ifdef KR_headers\n     freedtoa(s) char* s;\n #else\n-    freedtoa(char* s)\n+  freedtoa(char* s)\n #endif\n {\n-    Bigint* b = (Bigint*)((int*)s - 1);\n-    b->maxwds = 1 << (b->k = *(int*)b);\n-    Bfree(b);\n+  Bigint* b = (Bigint*)((int*)s - 1);\n+  b->maxwds = 1 << (b->k = *(int*)b);\n+  Bfree(b);\n #ifndef MULTIPLE_THREADS\n-    if (s == dtoa_result) {\n-        dtoa_result = 0;\n-    }\n+  if (s == dtoa_result) {\n+    dtoa_result = 0;\n+  }\n #endif\n }\n \n@@ -3808,508 +3798,504 @@ void\n  *     calculation.\n  */\n \n-char*\n-dtoa\n+char* dtoa\n #ifdef KR_headers\n     (dd, mode, ndigits, decpt, sign, rve)\n double dd;\n int mode, ndigits, *decpt, *sign;\n char** rve;\n #else\n-        (double dd, int mode, int ndigits, int* decpt, int* sign, char** rve)\n+      (double dd, int mode, int ndigits, int* decpt, int* sign, char** rve)\n #endif\n {\n-    /* Arguments ndigits, decpt, sign are similar to those\n-    of ecvt and fcvt; trailing zeros are suppressed from\n-    the returned string.  If not null, *rve is set to point\n-    to the end of the return value.  If d is +-Infinity or NaN,\n-    then *decpt is set to 9999.\n-\n-    mode:\n-       0 ==> shortest string that yields d when read in\n-           and rounded to nearest.\n-       1 ==> like 0, but with Steele & White stopping rule;\n-           e.g. with IEEE P754 arithmetic , mode 0 gives\n-           1e23 whereas mode 1 gives 9.999999999999999e22.\n-       2 ==> max(1,ndigits) significant digits.  This gives a\n-           return value similar to that of ecvt, except\n-           that trailing zeros are suppressed.\n-       3 ==> through ndigits past the decimal point.  This\n-           gives a return value similar to that from fcvt,\n-           except that trailing zeros are suppressed, and\n-           ndigits can be negative.\n-       4,5 ==> similar to 2 and 3, respectively, but (in\n-           round-nearest mode) with the tests of mode 0 to\n-           possibly return a shorter string that rounds to d.\n-           With IEEE arithmetic and compilation with\n-           -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same\n-           as modes 2 and 3 when FLT_ROUNDS != 1.\n-       6-9 ==> Debugging modes similar to mode - 4:  don't try\n-           fast floating-point estimate (if applicable).\n-\n-       Values of mode other than 0-9 are treated as mode 0.\n-\n-       Sufficient space is allocated to the return value\n-       to hold the suppressed trailing zeros.\n-    */\n-\n-    int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, j, j1, k, k0,\n-        k_check, leftright, m2, m5, s2, s5, spec_case, try_quick;\n-    Long L;\n+  /* Arguments ndigits, decpt, sign are similar to those\n+  of ecvt and fcvt; trailing zeros are suppressed from\n+  the returned string.  If not null, *rve is set to point\n+  to the end of the return value.  If d is +-Infinity or NaN,\n+  then *decpt is set to 9999.\n+\n+  mode:\n+     0 ==> shortest string that yields d when read in\n+         and rounded to nearest.\n+     1 ==> like 0, but with Steele & White stopping rule;\n+         e.g. with IEEE P754 arithmetic , mode 0 gives\n+         1e23 whereas mode 1 gives 9.999999999999999e22.\n+     2 ==> max(1,ndigits) significant digits.  This gives a\n+         return value similar to that of ecvt, except\n+         that trailing zeros are suppressed.\n+     3 ==> through ndigits past the decimal point.  This\n+         gives a return value similar to that from fcvt,\n+         except that trailing zeros are suppressed, and\n+         ndigits can be negative.\n+     4,5 ==> similar to 2 and 3, respectively, but (in\n+         round-nearest mode) with the tests of mode 0 to\n+         possibly return a shorter string that rounds to d.\n+         With IEEE arithmetic and compilation with\n+         -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same\n+         as modes 2 and 3 when FLT_ROUNDS != 1.\n+     6-9 ==> Debugging modes similar to mode - 4:  don't try\n+         fast floating-point estimate (if applicable).\n+\n+     Values of mode other than 0-9 are treated as mode 0.\n+\n+     Sufficient space is allocated to the return value\n+     to hold the suppressed trailing zeros.\n+  */\n+\n+  int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, j, j1, k, k0,\n+      k_check, leftright, m2, m5, s2, s5, spec_case, try_quick;\n+  Long L;\n #ifndef Sudden_Underflow\n-    int denorm;\n-    ULong x;\n+  int denorm;\n+  ULong x;\n #endif\n-    Bigint *b, *b1, *delta, *mlo, *mhi, *S;\n-    U d2, eps, u;\n-    double ds;\n-    char *s, *s0;\n+  Bigint *b, *b1, *delta, *mlo, *mhi, *S;\n+  U d2, eps, u;\n+  double ds;\n+  char *s, *s0;\n #ifndef No_leftright\n-#ifdef IEEE_Arith\n-    U eps1;\n-#endif\n+#  ifdef IEEE_Arith\n+  U eps1;\n+#  endif\n #endif\n #ifdef SET_INEXACT\n-    int inexact, oldinexact;\n+  int inexact, oldinexact;\n #endif\n #ifdef Honor_FLT_ROUNDS /*{*/\n-    int Rounding;\n-#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */\n-    Rounding = Flt_Rounds;\n-#else  /*}{*/\n-    Rounding = 1;\n-    switch (fegetround()) {\n-        case FE_TOWARDZERO:\n-            Rounding = 0;\n-            break;\n-        case FE_UPWARD:\n-            Rounding = 2;\n-            break;\n-        case FE_DOWNWARD:\n-            Rounding = 3;\n-    }\n-#endif /*}}*/\n-#endif /*}*/\n+  int Rounding;\n+#  ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */\n+  Rounding = Flt_Rounds;\n+#  else  /*}{*/\n+  Rounding = 1;\n+  switch (fegetround()) {\n+    case FE_TOWARDZERO:\n+      Rounding = 0;\n+      break;\n+    case FE_UPWARD:\n+      Rounding = 2;\n+      break;\n+    case FE_DOWNWARD:\n+      Rounding = 3;\n+  }\n+#  endif /*}}*/\n+#endif   /*}*/\n \n #ifndef MULTIPLE_THREADS\n-    if (dtoa_result) {\n-        freedtoa(dtoa_result);\n-        dtoa_result = 0;\n-    }\n+  if (dtoa_result) {\n+    freedtoa(dtoa_result);\n+    dtoa_result = 0;\n+  }\n #endif\n \n-    u.d = dd;\n-    if (word0(&u) & Sign_bit) {\n-        /* set sign for everything, including 0's and NaNs */\n-        *sign = 1;\n-        word0(&u) &= ~Sign_bit; /* clear sign bit */\n-    } else {\n-        *sign = 0;\n-    }\n+  u.d = dd;\n+  if (word0(&u) & Sign_bit) {\n+    /* set sign for everything, including 0's and NaNs */\n+    *sign = 1;\n+    word0(&u) &= ~Sign_bit; /* clear sign bit */\n+  } else {\n+    *sign = 0;\n+  }\n \n #if defined(IEEE_Arith) + defined(VAX)\n-#ifdef IEEE_Arith\n-    if ((word0(&u) & Exp_mask) == Exp_mask)\n-#else\n-    if (word0(&u) == 0x8000)\n-#endif\n-    {\n-        /* Infinity or NaN */\n-        *decpt = 9999;\n-#ifdef IEEE_Arith\n-        if (!word1(&u) && !(word0(&u) & 0xfffff)) {\n-            return nrv_alloc(\"Infinity\", rve, 8);\n-        }\n-#endif\n-        return nrv_alloc(\"NaN\", rve, 3);\n-    }\n+#  ifdef IEEE_Arith\n+  if ((word0(&u) & Exp_mask) == Exp_mask)\n+#  else\n+  if (word0(&u) == 0x8000)\n+#  endif\n+  {\n+    /* Infinity or NaN */\n+    *decpt = 9999;\n+#  ifdef IEEE_Arith\n+    if (!word1(&u) && !(word0(&u) & 0xfffff)) {\n+      return nrv_alloc(\"Infinity\", rve, 8);\n+    }\n+#  endif\n+    return nrv_alloc(\"NaN\", rve, 3);\n+  }\n #endif\n #ifdef IBM\n-    dval(&u) += 0; /* normalize */\n+  dval(&u) += 0; /* normalize */\n #endif\n-    if (!dval(&u)) {\n-        *decpt = 1;\n-        return nrv_alloc(\"0\", rve, 1);\n-    }\n+  if (!dval(&u)) {\n+    *decpt = 1;\n+    return nrv_alloc(\"0\", rve, 1);\n+  }\n \n #ifdef SET_INEXACT\n-    try_quick = oldinexact = get_inexact();\n-    inexact = 1;\n+  try_quick = oldinexact = get_inexact();\n+  inexact = 1;\n #endif\n #ifdef Honor_FLT_ROUNDS\n-    if (Rounding >= 2) {\n-        if (*sign) {\n-            Rounding = Rounding == 2 ? 0 : 2;\n-        } else if (Rounding != 2) {\n-            Rounding = 0;\n-        }\n+  if (Rounding >= 2) {\n+    if (*sign) {\n+      Rounding = Rounding == 2 ? 0 : 2;\n+    } else if (Rounding != 2) {\n+      Rounding = 0;\n     }\n+  }\n #endif\n \n-    b = d2b(&u, &be, &bbits);\n+  b = d2b(&u, &be, &bbits);\n #ifdef Sudden_Underflow\n-    i = (int)(word0(&u) >> Exp_shift1 & (Exp_mask >> Exp_shift1));\n+  i = (int)(word0(&u) >> Exp_shift1 & (Exp_mask >> Exp_shift1));\n #else\n-        if ((i = (int)(word0(&u) >> Exp_shift1 & (Exp_mask >> Exp_shift1)))) {\n+    if ((i = (int)(word0(&u) >> Exp_shift1 & (Exp_mask >> Exp_shift1)))) {\n #endif\n-    dval(&d2) = dval(&u);\n-    word0(&d2) &= Frac_mask1;\n-    word0(&d2) |= Exp_11;\n+  dval(&d2) = dval(&u);\n+  word0(&d2) &= Frac_mask1;\n+  word0(&d2) |= Exp_11;\n #ifdef IBM\n-    if (j = 11 - hi0bits(word0(&d2) & Frac_mask)) {\n-        dval(&d2) /= 1 << j;\n-    }\n-#endif\n-\n-    /* log(x)   ~=~ log(1.5) + (x-1.5)/1.5\n-     * log10(x)  =  log(x) / log(10)\n-     *      ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))\n-     * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)\n-     *\n-     * This suggests computing an approximation k to log10(d) by\n-     *\n-     * k = (i - Bias)*0.301029995663981\n-     *  + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );\n-     *\n-     * We want k to be too large rather than too small.\n-     * The error in the first-order Taylor series approximation\n-     * is in our favor, so we just round up the constant enough\n-     * to compensate for any error in the multiplication of\n-     * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,\n-     * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,\n-     * adding 1e-13 to the constant term more than suffices.\n-     * Hence we adjust the constant term to 0.1760912590558.\n-     * (We could get a more accurate k by invoking log10,\n-     *  but this is probably not worthwhile.)\n-     */\n-\n-    i -= Bias;\n+  if (j = 11 - hi0bits(word0(&d2) & Frac_mask)) {\n+    dval(&d2) /= 1 << j;\n+  }\n+#endif\n+\n+  /* log(x)   ~=~ log(1.5) + (x-1.5)/1.5\n+   * log10(x)  =  log(x) / log(10)\n+   *      ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))\n+   * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)\n+   *\n+   * This suggests computing an approximation k to log10(d) by\n+   *\n+   * k = (i - Bias)*0.301029995663981\n+   *  + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );\n+   *\n+   * We want k to be too large rather than too small.\n+   * The error in the first-order Taylor series approximation\n+   * is in our favor, so we just round up the constant enough\n+   * to compensate for any error in the multiplication of\n+   * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,\n+   * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,\n+   * adding 1e-13 to the constant term more than suffices.\n+   * Hence we adjust the constant term to 0.1760912590558.\n+   * (We could get a more accurate k by invoking log10,\n+   *  but this is probably not worthwhile.)\n+   */\n+\n+  i -= Bias;\n #ifdef IBM\n-    i <<= 2;\n-    i += j;\n+  i <<= 2;\n+  i += j;\n #endif\n #ifndef Sudden_Underflow\n-    denorm = 0;\n+  denorm = 0;\n }\n-else\n-{\n-    /* d is denormalized */\n-\n-    i = bbits + be + (Bias + (P - 1) - 1);\n-    x = i > 32 ? word0(&u) << (64 - i) | word1(&u) >> (i - 32)\n-               : word1(&u) << (32 - i);\n-    dval(&d2) = x;\n-    word0(&d2) -= 31 * Exp_msk1; /* adjust exponent */\n-    i -= (Bias + (P - 1) - 1) + 1;\n-    denorm = 1;\n+else {\n+  /* d is denormalized */\n+\n+  i = bbits + be + (Bias + (P - 1) - 1);\n+  x = i > 32 ? word0(&u) << (64 - i) | word1(&u) >> (i - 32)\n+             : word1(&u) << (32 - i);\n+  dval(&d2) = x;\n+  word0(&d2) -= 31 * Exp_msk1; /* adjust exponent */\n+  i -= (Bias + (P - 1) - 1) + 1;\n+  denorm = 1;\n }\n #endif\n ds = (dval(&d2) - 1.5) * 0.289529654602168 + 0.1760912590558 +\n      i * 0.301029995663981;\n k = (int)ds;\n if (ds < 0. && ds != k) {\n-    k--; /* want k = floor(ds) */\n+  k--; /* want k = floor(ds) */\n }\n k_check = 1;\n if (k >= 0 && k <= Ten_pmax) {\n-    if (dval(&u) < tens[k]) {\n-        k--;\n-    }\n-    k_check = 0;\n+  if (dval(&u) < tens[k]) {\n+    k--;\n+  }\n+  k_check = 0;\n }\n j = bbits - i - 1;\n if (j >= 0) {\n-    b2 = 0;\n-    s2 = j;\n+  b2 = 0;\n+  s2 = j;\n } else {\n-    b2 = -j;\n-    s2 = 0;\n+  b2 = -j;\n+  s2 = 0;\n }\n if (k >= 0) {\n-    b5 = 0;\n-    s5 = k;\n-    s2 += k;\n+  b5 = 0;\n+  s5 = k;\n+  s2 += k;\n } else {\n-    b2 -= k;\n-    b5 = -k;\n-    s5 = 0;\n+  b2 -= k;\n+  b5 = -k;\n+  s5 = 0;\n }\n if (mode < 0 || mode > 9) {\n-    mode = 0;\n+  mode = 0;\n }\n \n #ifndef SET_INEXACT\n-#ifdef Check_FLT_ROUNDS\n+#  ifdef Check_FLT_ROUNDS\n try_quick = Rounding == 1;\n-#else\n+#  else\n try_quick = 1;\n-#endif\n+#  endif\n #endif /*SET_INEXACT*/\n \n if (mode > 5) {\n-    mode -= 4;\n-    try_quick = 0;\n+  mode -= 4;\n+  try_quick = 0;\n }\n leftright = 1;\n ilim = ilim1 = -1; /* Values for cases 0 and 1; done here to */\n /* silence erroneous \"gcc -Wall\" warning. */\n switch (mode) {\n-    case 0:\n-    case 1:\n-        i = 18;\n-        ndigits = 0;\n-        break;\n-    case 2:\n-        leftright = 0;\n-    /* no break */\n-    case 4:\n-        if (ndigits <= 0) {\n-            ndigits = 1;\n-        }\n-        ilim = ilim1 = i = ndigits;\n-        break;\n-    case 3:\n-        leftright = 0;\n-    /* no break */\n-    case 5:\n-        i = ndigits + k + 1;\n-        ilim = i;\n-        ilim1 = i - 1;\n-        if (i <= 0) {\n-            i = 1;\n-        }\n+  case 0:\n+  case 1:\n+    i = 18;\n+    ndigits = 0;\n+    break;\n+  case 2:\n+    leftright = 0;\n+  /* no break */\n+  case 4:\n+    if (ndigits <= 0) {\n+      ndigits = 1;\n+    }\n+    ilim = ilim1 = i = ndigits;\n+    break;\n+  case 3:\n+    leftright = 0;\n+  /* no break */\n+  case 5:\n+    i = ndigits + k + 1;\n+    ilim = i;\n+    ilim1 = i - 1;\n+    if (i <= 0) {\n+      i = 1;\n+    }\n }\n s = s0 = rv_alloc(i);\n \n #ifdef Honor_FLT_ROUNDS\n if (mode > 1 && Rounding != 1) {\n-    leftright = 0;\n+  leftright = 0;\n }\n #endif\n \n if (ilim >= 0 && ilim <= Quick_max && try_quick) {\n-    /* Try to get by with floating-point arithmetic. */\n-\n-    i = 0;\n-    dval(&d2) = dval(&u);\n-    k0 = k;\n-    ilim0 = ilim;\n-    ieps = 2; /* conservative */\n-    if (k > 0) {\n-        ds = tens[k & 0xf];\n-        j = k >> 4;\n-        if (j & Bletch) {\n-            /* prevent overflows */\n-            j &= Bletch - 1;\n-            dval(&u) /= bigtens[n_bigtens - 1];\n-            ieps++;\n-        }\n-        for (; j; j >>= 1, i++)\n-            if (j & 1) {\n-                ieps++;\n-                ds *= bigtens[i];\n-            }\n-        dval(&u) /= ds;\n-    } else if ((j1 = -k)) {\n-        dval(&u) *= tens[j1 & 0xf];\n-        for (j = j1 >> 4; j; j >>= 1, i++)\n-            if (j & 1) {\n-                ieps++;\n-                dval(&u) *= bigtens[i];\n-            }\n-    }\n-    if (k_check && dval(&u) < 1. && ilim > 0) {\n-        if (ilim1 <= 0) {\n-            goto fast_failed;\n-        }\n-        ilim = ilim1;\n-        k--;\n-        dval(&u) *= 10.;\n+  /* Try to get by with floating-point arithmetic. */\n+\n+  i = 0;\n+  dval(&d2) = dval(&u);\n+  k0 = k;\n+  ilim0 = ilim;\n+  ieps = 2; /* conservative */\n+  if (k > 0) {\n+    ds = tens[k & 0xf];\n+    j = k >> 4;\n+    if (j & Bletch) {\n+      /* prevent overflows */\n+      j &= Bletch - 1;\n+      dval(&u) /= bigtens[n_bigtens - 1];\n+      ieps++;\n+    }\n+    for (; j; j >>= 1, i++)\n+      if (j & 1) {\n         ieps++;\n-    }\n-    dval(&eps) = ieps * dval(&u) + 7.;\n-    word0(&eps) -= (P - 1) * Exp_msk1;\n-    if (ilim == 0) {\n-        S = mhi = 0;\n-        dval(&u) -= 5.;\n-        if (dval(&u) > dval(&eps)) {\n-            goto one_digit;\n-        }\n-        if (dval(&u) < -dval(&eps)) {\n-            goto no_digits;\n-        }\n-        goto fast_failed;\n-    }\n+        ds *= bigtens[i];\n+      }\n+    dval(&u) /= ds;\n+  } else if ((j1 = -k)) {\n+    dval(&u) *= tens[j1 & 0xf];\n+    for (j = j1 >> 4; j; j >>= 1, i++)\n+      if (j & 1) {\n+        ieps++;\n+        dval(&u) *= bigtens[i];\n+      }\n+  }\n+  if (k_check && dval(&u) < 1. && ilim > 0) {\n+    if (ilim1 <= 0) {\n+      goto fast_failed;\n+    }\n+    ilim = ilim1;\n+    k--;\n+    dval(&u) *= 10.;\n+    ieps++;\n+  }\n+  dval(&eps) = ieps * dval(&u) + 7.;\n+  word0(&eps) -= (P - 1) * Exp_msk1;\n+  if (ilim == 0) {\n+    S = mhi = 0;\n+    dval(&u) -= 5.;\n+    if (dval(&u) > dval(&eps)) {\n+      goto one_digit;\n+    }\n+    if (dval(&u) < -dval(&eps)) {\n+      goto no_digits;\n+    }\n+    goto fast_failed;\n+  }\n #ifndef No_leftright\n-    if (leftright) {\n-        /* Use Steele & White method of only\n-         * generating digits needed.\n-         */\n-        dval(&eps) = 0.5 / tens[ilim - 1] - dval(&eps);\n-#ifdef IEEE_Arith\n-        if (k0 < 0 && j1 >= 307) {\n-            eps1.d = 1.01e256; /* 1.01 allows roundoff in the next few lines */\n-            word0(&eps1) -= Exp_msk1 * (Bias + P - 1);\n-            dval(&eps1) *= tens[j1 & 0xf];\n-            for (i = 0, j = (j1 - 256) >> 4; j; j >>= 1, i++)\n-                if (j & 1) {\n-                    dval(&eps1) *= bigtens[i];\n-                }\n-            if (eps.d < eps1.d) {\n-                eps.d = eps1.d;\n-            }\n-        }\n-#endif\n-        for (i = 0;;) {\n-            L = dval(&u);\n-            dval(&u) -= L;\n-            *s++ = '0' + (int)L;\n-            if (1. - dval(&u) < dval(&eps)) {\n-                goto bump_up;\n-            }\n-            if (dval(&u) < dval(&eps)) {\n-                goto ret1;\n-            }\n-            if (++i >= ilim) {\n-                break;\n-            }\n-            dval(&eps) *= 10.;\n-            dval(&u) *= 10.;\n-        }\n-    } else {\n+  if (leftright) {\n+    /* Use Steele & White method of only\n+     * generating digits needed.\n+     */\n+    dval(&eps) = 0.5 / tens[ilim - 1] - dval(&eps);\n+#  ifdef IEEE_Arith\n+    if (k0 < 0 && j1 >= 307) {\n+      eps1.d = 1.01e256; /* 1.01 allows roundoff in the next few lines */\n+      word0(&eps1) -= Exp_msk1 * (Bias + P - 1);\n+      dval(&eps1) *= tens[j1 & 0xf];\n+      for (i = 0, j = (j1 - 256) >> 4; j; j >>= 1, i++)\n+        if (j & 1) {\n+          dval(&eps1) *= bigtens[i];\n+        }\n+      if (eps.d < eps1.d) {\n+        eps.d = eps1.d;\n+      }\n+    }\n+#  endif\n+    for (i = 0;;) {\n+      L = dval(&u);\n+      dval(&u) -= L;\n+      *s++ = '0' + (int)L;\n+      if (1. - dval(&u) < dval(&eps)) {\n+        goto bump_up;\n+      }\n+      if (dval(&u) < dval(&eps)) {\n+        goto ret1;\n+      }\n+      if (++i >= ilim) {\n+        break;\n+      }\n+      dval(&eps) *= 10.;\n+      dval(&u) *= 10.;\n+    }\n+  } else {\n #endif\n-        /* Generate ilim digits, then fix them up. */\n-        dval(&eps) *= tens[ilim - 1];\n-        for (i = 1;; i++, dval(&u) *= 10.) {\n-            L = (Long)(dval(&u));\n-            if (!(dval(&u) -= L)) {\n-                ilim = i;\n-            }\n-            *s++ = '0' + (int)L;\n-            if (i == ilim) {\n-                if (dval(&u) > 0.5 + dval(&eps)) {\n-                    goto bump_up;\n-                } else if (dval(&u) < 0.5 - dval(&eps)) {\n-                    while (*--s == '0')\n-                        ;\n-                    s++;\n-                    goto ret1;\n-                }\n-                break;\n-            }\n+    /* Generate ilim digits, then fix them up. */\n+    dval(&eps) *= tens[ilim - 1];\n+    for (i = 1;; i++, dval(&u) *= 10.) {\n+      L = (Long)(dval(&u));\n+      if (!(dval(&u) -= L)) {\n+        ilim = i;\n+      }\n+      *s++ = '0' + (int)L;\n+      if (i == ilim) {\n+        if (dval(&u) > 0.5 + dval(&eps)) {\n+          goto bump_up;\n+        } else if (dval(&u) < 0.5 - dval(&eps)) {\n+          while (*--s == '0');\n+          s++;\n+          goto ret1;\n         }\n-#ifndef No_leftright\n+        break;\n+      }\n     }\n+#ifndef No_leftright\n+  }\n #endif\n fast_failed:\n-    s = s0;\n-    dval(&u) = dval(&d2);\n-    k = k0;\n-    ilim = ilim0;\n+  s = s0;\n+  dval(&u) = dval(&d2);\n+  k = k0;\n+  ilim = ilim0;\n }\n \n /* Do we have a \"small\" integer? */\n \n if (be >= 0 && k <= Int_max) {\n-    /* Yes. */\n-    ds = tens[k];\n-    if (ndigits < 0 && ilim <= 0) {\n-        S = mhi = 0;\n-        if (ilim < 0 || dval(&u) <= 5 * ds) {\n-            goto no_digits;\n-        }\n-        goto one_digit;\n-    }\n-    for (i = 1;; i++, dval(&u) *= 10.) {\n-        L = (Long)(dval(&u) / ds);\n-        dval(&u) -= L * ds;\n+  /* Yes. */\n+  ds = tens[k];\n+  if (ndigits < 0 && ilim <= 0) {\n+    S = mhi = 0;\n+    if (ilim < 0 || dval(&u) <= 5 * ds) {\n+      goto no_digits;\n+    }\n+    goto one_digit;\n+  }\n+  for (i = 1;; i++, dval(&u) *= 10.) {\n+    L = (Long)(dval(&u) / ds);\n+    dval(&u) -= L * ds;\n #ifdef Check_FLT_ROUNDS\n-        /* If FLT_ROUNDS == 2, L will usually be high by 1 */\n-        if (dval(&u) < 0) {\n-            L--;\n-            dval(&u) += ds;\n-        }\n+    /* If FLT_ROUNDS == 2, L will usually be high by 1 */\n+    if (dval(&u) < 0) {\n+      L--;\n+      dval(&u) += ds;\n+    }\n #endif\n-        *s++ = '0' + (int)L;\n-        if (!dval(&u)) {\n+    *s++ = '0' + (int)L;\n+    if (!dval(&u)) {\n #ifdef SET_INEXACT\n-            inexact = 0;\n+      inexact = 0;\n #endif\n-            break;\n-        }\n-        if (i == ilim) {\n+      break;\n+    }\n+    if (i == ilim) {\n #ifdef Honor_FLT_ROUNDS\n-            if (mode > 1)\n-                switch (Rounding) {\n-                    case 0:\n-                        goto ret1;\n-                    case 2:\n-                        goto bump_up;\n-                }\n+      if (mode > 1) switch (Rounding) {\n+          case 0:\n+            goto ret1;\n+          case 2:\n+            goto bump_up;\n+        }\n #endif\n-            dval(&u) += dval(&u);\n+      dval(&u) += dval(&u);\n #ifdef ROUND_BIASED\n-            if (dval(&u) >= ds)\n+      if (dval(&u) >= ds)\n #else\n-                        if (dval(&u) > ds || (dval(&u) == ds && L & 1))\n-#endif\n-            {\n-            bump_up:\n-                while (*--s == '9')\n-                    if (s == s0) {\n-                        k++;\n-                        *s = '0';\n-                        break;\n-                    }\n-                ++*s++;\n-            }\n+            if (dval(&u) > ds || (dval(&u) == ds && L & 1))\n+#endif\n+      {\n+      bump_up:\n+        while (*--s == '9')\n+          if (s == s0) {\n+            k++;\n+            *s = '0';\n             break;\n-        }\n+          }\n+        ++*s++;\n+      }\n+      break;\n     }\n-    goto ret1;\n+  }\n+  goto ret1;\n }\n \n m2 = b2;\n m5 = b5;\n mhi = mlo = 0;\n if (leftright) {\n-    i =\n+  i =\n #ifndef Sudden_Underflow\n-        denorm ? be + (Bias + (P - 1) - 1 + 1) :\n+      denorm ? be + (Bias + (P - 1) - 1 + 1) :\n #endif\n #ifdef IBM\n-               1 + 4 * P - 3 - bbits + ((bbits + be - 1) & 3);\n+             1 + 4 * P - 3 - bbits + ((bbits + be - 1) & 3);\n #else\n-                    1 + P - bbits;\n+            1 + P - bbits;\n #endif\n-    b2 += i;\n-    s2 += i;\n-    mhi = i2b(1);\n+  b2 += i;\n+  s2 += i;\n+  mhi = i2b(1);\n }\n if (m2 > 0 && s2 > 0) {\n-    i = m2 < s2 ? m2 : s2;\n-    b2 -= i;\n-    m2 -= i;\n-    s2 -= i;\n+  i = m2 < s2 ? m2 : s2;\n+  b2 -= i;\n+  m2 -= i;\n+  s2 -= i;\n }\n if (b5 > 0) {\n-    if (leftright) {\n-        if (m5 > 0) {\n-            mhi = pow5mult(mhi, m5);\n-            b1 = mult(mhi, b);\n-            Bfree(b);\n-            b = b1;\n-        }\n-        if ((j = b5 - m5)) {\n-            b = pow5mult(b, j);\n-        }\n-    } else {\n-        b = pow5mult(b, b5);\n-    }\n+  if (leftright) {\n+    if (m5 > 0) {\n+      mhi = pow5mult(mhi, m5);\n+      b1 = mult(mhi, b);\n+      Bfree(b);\n+      b = b1;\n+    }\n+    if ((j = b5 - m5)) {\n+      b = pow5mult(b, j);\n+    }\n+  } else {\n+    b = pow5mult(b, b5);\n+  }\n }\n S = i2b(1);\n if (s5 > 0) {\n-    S = pow5mult(S, s5);\n+  S = pow5mult(S, s5);\n }\n \n /* Check for special case that d is a normalized power of 2. */\n@@ -4320,16 +4306,16 @@ if ((mode < 2 || leftright)\n     && Rounding == 1\n #endif\n ) {\n-    if (!word1(&u) && !(word0(&u) & Bndry_mask)\n+  if (!word1(&u) && !(word0(&u) & Bndry_mask)\n #ifndef Sudden_Underflow\n-        && word0(&u) & (Exp_mask & ~Exp_msk1)\n-#endif\n-    ) {\n-        /* The special case */\n-        b2 += Log2P;\n-        s2 += Log2P;\n-        spec_case = 1;\n-    }\n+      && word0(&u) & (Exp_mask & ~Exp_msk1)\n+#endif\n+  ) {\n+    /* The special case */\n+    b2 += Log2P;\n+    s2 += Log2P;\n+    spec_case = 1;\n+  }\n }\n \n /* Arrange for convenient computation of quotients:\n@@ -4344,166 +4330,165 @@ b2 += i;\n m2 += i;\n s2 += i;\n if (b2 > 0) {\n-    b = lshift(b, b2);\n+  b = lshift(b, b2);\n }\n if (s2 > 0) {\n-    S = lshift(S, s2);\n+  S = lshift(S, s2);\n }\n if (k_check) {\n-    if (cmp(b, S) < 0) {\n-        k--;\n-        b = multadd(b, 10, 0); /* we botched the k estimate */\n-        if (leftright) {\n-            mhi = multadd(mhi, 10, 0);\n-        }\n-        ilim = ilim1;\n+  if (cmp(b, S) < 0) {\n+    k--;\n+    b = multadd(b, 10, 0); /* we botched the k estimate */\n+    if (leftright) {\n+      mhi = multadd(mhi, 10, 0);\n     }\n+    ilim = ilim1;\n+  }\n }\n if (ilim <= 0 && (mode == 3 || mode == 5)) {\n-    if (ilim < 0 || cmp(b, S = multadd(S, 5, 0)) <= 0) {\n-        /* no digits, fcvt style */\n-    no_digits:\n-        k = -1 - ndigits;\n-        goto ret;\n-    }\n-one_digit:\n-    *s++ = '1';\n-    k++;\n+  if (ilim < 0 || cmp(b, S = multadd(S, 5, 0)) <= 0) {\n+    /* no digits, fcvt style */\n+  no_digits:\n+    k = -1 - ndigits;\n     goto ret;\n+  }\n+one_digit:\n+  *s++ = '1';\n+  k++;\n+  goto ret;\n }\n if (leftright) {\n-    if (m2 > 0) {\n-        mhi = lshift(mhi, m2);\n-    }\n-\n-    /* Compute mlo -- check for special case\n-     * that d is a normalized power of 2.\n+  if (m2 > 0) {\n+    mhi = lshift(mhi, m2);\n+  }\n+\n+  /* Compute mlo -- check for special case\n+   * that d is a normalized power of 2.\n+   */\n+\n+  mlo = mhi;\n+  if (spec_case) {\n+    mhi = Balloc(mhi->k);\n+    Bcopy(mhi, mlo);\n+    mhi = lshift(mhi, Log2P);\n+  }\n+\n+  for (i = 1;; i++) {\n+    dig = quorem(b, S) + '0';\n+    /* Do we yet have the shortest decimal string\n+     * that will round to d?\n      */\n-\n-    mlo = mhi;\n-    if (spec_case) {\n-        mhi = Balloc(mhi->k);\n-        Bcopy(mhi, mlo);\n-        mhi = lshift(mhi, Log2P);\n-    }\n-\n-    for (i = 1;; i++) {\n-        dig = quorem(b, S) + '0';\n-        /* Do we yet have the shortest decimal string\n-         * that will round to d?\n-         */\n-        j = cmp(b, mlo);\n-        delta = diff(S, mhi);\n-        j1 = delta->sign ? 1 : cmp(b, delta);\n-        Bfree(delta);\n+    j = cmp(b, mlo);\n+    delta = diff(S, mhi);\n+    j1 = delta->sign ? 1 : cmp(b, delta);\n+    Bfree(delta);\n #ifndef ROUND_BIASED\n-        if (j1 == 0 && mode != 1 && !(word1(&u) & 1)\n-#ifdef Honor_FLT_ROUNDS\n-            && Rounding >= 1\n-#endif\n-        ) {\n-            if (dig == '9') {\n-                goto round_9_up;\n-            }\n-            if (j > 0) {\n-                dig++;\n-            }\n-#ifdef SET_INEXACT\n-            else if (!b->x[0] && b->wds <= 1) {\n-                inexact = 0;\n-            }\n-#endif\n-            *s++ = dig;\n-            goto ret;\n-        }\n-#endif\n-        if (j < 0 || (j == 0 && mode != 1\n+    if (j1 == 0 && mode != 1 && !(word1(&u) & 1)\n+#  ifdef Honor_FLT_ROUNDS\n+        && Rounding >= 1\n+#  endif\n+    ) {\n+      if (dig == '9') {\n+        goto round_9_up;\n+      }\n+      if (j > 0) {\n+        dig++;\n+      }\n+#  ifdef SET_INEXACT\n+      else if (!b->x[0] && b->wds <= 1) {\n+        inexact = 0;\n+      }\n+#  endif\n+      *s++ = dig;\n+      goto ret;\n+    }\n+#endif\n+    if (j < 0 || (j == 0 && mode != 1\n #ifndef ROUND_BIASED\n-                      && !(word1(&u) & 1)\n+                  && !(word1(&u) & 1)\n #endif\n-                          )) {\n-            if (!b->x[0] && b->wds <= 1) {\n+                      )) {\n+      if (!b->x[0] && b->wds <= 1) {\n #ifdef SET_INEXACT\n-                inexact = 0;\n+        inexact = 0;\n #endif\n-                goto accept_dig;\n-            }\n+        goto accept_dig;\n+      }\n #ifdef Honor_FLT_ROUNDS\n-            if (mode > 1)\n-                switch (Rounding) {\n-                    case 0:\n-                        goto accept_dig;\n-                    case 2:\n-                        goto keep_dig;\n-                }\n+      if (mode > 1) switch (Rounding) {\n+          case 0:\n+            goto accept_dig;\n+          case 2:\n+            goto keep_dig;\n+        }\n #endif /*Honor_FLT_ROUNDS*/\n-            if (j1 > 0) {\n-                b = lshift(b, 1);\n-                j1 = cmp(b, S);\n+      if (j1 > 0) {\n+        b = lshift(b, 1);\n+        j1 = cmp(b, S);\n #ifdef ROUND_BIASED\n-                if (j1 >= 0 /*)*/\n+        if (j1 >= 0 /*)*/\n #else\n-                            if ((j1 > 0 || (j1 == 0 && dig & 1))\n+              if ((j1 > 0 || (j1 == 0 && dig & 1))\n #endif\n-                    && dig++ == '9')\n-                    goto round_9_up;\n-            }\n-        accept_dig:\n-            *s++ = dig;\n-            goto ret;\n-        }\n-        if (j1 > 0) {\n+            && dig++ == '9')\n+          goto round_9_up;\n+      }\n+    accept_dig:\n+      *s++ = dig;\n+      goto ret;\n+    }\n+    if (j1 > 0) {\n #ifdef Honor_FLT_ROUNDS\n-            if (!Rounding) {\n-                goto accept_dig;\n-            }\n+      if (!Rounding) {\n+        goto accept_dig;\n+      }\n #endif\n-            if (dig == '9') { /* possible if i == 1 */\n-            round_9_up:\n-                *s++ = '9';\n-                goto roundoff;\n-            }\n-            *s++ = dig + 1;\n-            goto ret;\n-        }\n+      if (dig == '9') { /* possible if i == 1 */\n+      round_9_up:\n+        *s++ = '9';\n+        goto roundoff;\n+      }\n+      *s++ = dig + 1;\n+      goto ret;\n+    }\n #ifdef Honor_FLT_ROUNDS\n-    keep_dig:\n+  keep_dig:\n #endif\n-        *s++ = dig;\n-        if (i == ilim) {\n-            break;\n-        }\n-        b = multadd(b, 10, 0);\n-        if (mlo == mhi) {\n-            mlo = mhi = multadd(mhi, 10, 0);\n-        } else {\n-            mlo = multadd(mlo, 10, 0);\n-            mhi = multadd(mhi, 10, 0);\n-        }\n+    *s++ = dig;\n+    if (i == ilim) {\n+      break;\n     }\n+    b = multadd(b, 10, 0);\n+    if (mlo == mhi) {\n+      mlo = mhi = multadd(mhi, 10, 0);\n+    } else {\n+      mlo = multadd(mlo, 10, 0);\n+      mhi = multadd(mhi, 10, 0);\n+    }\n+  }\n } else\n-    for (i = 1;; i++) {\n-        *s++ = dig = quorem(b, S) + '0';\n-        if (!b->x[0] && b->wds <= 1) {\n+  for (i = 1;; i++) {\n+    *s++ = dig = quorem(b, S) + '0';\n+    if (!b->x[0] && b->wds <= 1) {\n #ifdef SET_INEXACT\n-            inexact = 0;\n+      inexact = 0;\n #endif\n-            goto ret;\n-        }\n-        if (i >= ilim) {\n-            break;\n-        }\n-        b = multadd(b, 10, 0);\n+      goto ret;\n+    }\n+    if (i >= ilim) {\n+      break;\n     }\n+    b = multadd(b, 10, 0);\n+  }\n \n-/* Round off last digit */\n+  /* Round off last digit */\n \n #ifdef Honor_FLT_ROUNDS\n switch (Rounding) {\n-    case 0:\n-        goto trimzeros;\n-    case 2:\n-        goto roundoff;\n+  case 0:\n+    goto trimzeros;\n+  case 2:\n+    goto roundoff;\n }\n #endif\n b = lshift(b, 1);\n@@ -4511,52 +4496,49 @@ j = cmp(b, S);\n #ifdef ROUND_BIASED\n if (j >= 0)\n #else\n-            if (j > 0 || (j == 0 && dig & 1))\n+      if (j > 0 || (j == 0 && dig & 1))\n #endif\n {\n roundoff:\n-    while (*--s == '9')\n-        if (s == s0) {\n-            k++;\n-            *s++ = '1';\n-            goto ret;\n-        }\n-    ++*s++;\n+  while (*--s == '9')\n+    if (s == s0) {\n+      k++;\n+      *s++ = '1';\n+      goto ret;\n+    }\n+  ++*s++;\n } else {\n #ifdef Honor_FLT_ROUNDS\n trimzeros:\n #endif\n-    while (*--s == '0')\n-        ;\n-    s++;\n+  while (*--s == '0');\n+  s++;\n }\n ret: Bfree(S);\n if (mhi) {\n-    if (mlo && mlo != mhi) {\n-        Bfree(mlo);\n-    }\n-    Bfree(mhi);\n+  if (mlo && mlo != mhi) {\n+    Bfree(mlo);\n+  }\n+  Bfree(mhi);\n }\n ret1:\n #ifdef SET_INEXACT\n-    if (inexact)\n-{\n-    if (!oldinexact) {\n-        word0(&u) = Exp_1 + (70 << Exp_shift);\n-        word1(&u) = 0;\n-        dval(&u) += 1.;\n-    }\n+    if (inexact) {\n+  if (!oldinexact) {\n+    word0(&u) = Exp_1 + (70 << Exp_shift);\n+    word1(&u) = 0;\n+    dval(&u) += 1.;\n+  }\n }\n-else if (!oldinexact)\n-{\n-    clear_inexact();\n+else if (!oldinexact) {\n+  clear_inexact();\n }\n #endif\n Bfree(b);\n *s = 0;\n *decpt = k + 1;\n if (rve) {\n-    *rve = s;\n+  *rve = s;\n }\n return s0;\n }\ndiff --git a/nspr/pr/src/misc/pralarm.c b/nspr/pr/src/misc/pralarm.c\nindex ab84fc9..e649470 100644\n--- a/nspr/pr/src/misc/pralarm.c\n+++ b/nspr/pr/src/misc/pralarm.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,264 +11,230 @@\n \n #include \"obsolete/pralarm.h\"\n \n-struct PRAlarmID {              /* typedef'd in pralarm.h       */\n-    PRCList list;               /* circular list linkage        */\n-    PRAlarm* alarm;             /* back pointer to owning alarm */\n-    PRPeriodicAlarmFn function; /* function to call for notify  */\n-    void* clientData;           /* opaque client context        */\n-    PRIntervalTime period;      /* the client defined period    */\n-    PRUint32 rate;              /* rate of notification         */\n-\n-    PRUint32 accumulator;      /* keeps track of # notifies    */\n-    PRIntervalTime epoch;      /* when timer was started       */\n-    PRIntervalTime nextNotify; /* when we'll next do our thing */\n-    PRIntervalTime lastNotify; /* when we last did our thing   */\n+struct PRAlarmID {            /* typedef'd in pralarm.h       */\n+  PRCList list;               /* circular list linkage        */\n+  PRAlarm* alarm;             /* back pointer to owning alarm */\n+  PRPeriodicAlarmFn function; /* function to call for notify  */\n+  void* clientData;           /* opaque client context        */\n+  PRIntervalTime period;      /* the client defined period    */\n+  PRUint32 rate;              /* rate of notification         */\n+\n+  PRUint32 accumulator;      /* keeps track of # notifies    */\n+  PRIntervalTime epoch;      /* when timer was started       */\n+  PRIntervalTime nextNotify; /* when we'll next do our thing */\n+  PRIntervalTime lastNotify; /* when we last did our thing   */\n };\n \n-typedef enum { alarm_active,\n-               alarm_inactive } _AlarmState;\n+typedef enum { alarm_active, alarm_inactive } _AlarmState;\n \n-struct PRAlarm {        /* typedef'd in pralarm.h       */\n-    PRCList timers;     /* base of alarm ids list       */\n-    PRLock* lock;       /* lock used to protect data    */\n-    PRCondVar* cond;    /* condition that used to wait  */\n-    PRThread* notifier; /* thread to deliver notifies   */\n-    PRAlarmID* current; /* current alarm being served   */\n-    _AlarmState state;  /* used to delete the alarm     */\n+struct PRAlarm {      /* typedef'd in pralarm.h       */\n+  PRCList timers;     /* base of alarm ids list       */\n+  PRLock* lock;       /* lock used to protect data    */\n+  PRCondVar* cond;    /* condition that used to wait  */\n+  PRThread* notifier; /* thread to deliver notifies   */\n+  PRAlarmID* current; /* current alarm being served   */\n+  _AlarmState state;  /* used to delete the alarm     */\n };\n \n-static PRAlarmID*\n-pr_getNextAlarm(PRAlarm* alarm, PRAlarmID* id)\n-{\n-    /*\n-     * Puts 'id' back into the sorted list iff it's not NULL.\n-     * Removes the first element from the list and returns it (or NULL).\n-     * List is \"assumed\" to be short.\n-     *\n-     * NB: Caller is providing locking\n-     */\n-    PRCList* timer;\n-    PRAlarmID* result = id;\n-\n-    if (!PR_CLIST_IS_EMPTY(&alarm->timers)) {\n-        if (id != NULL) /* have to put this id back in */\n-        {\n-            /*\n-             * This used to walk the list looking for the sorted insertion\n-             * point, but every branch of that walk (including the one that\n-             * \"found\" the spot) inserted before the list head, i.e. at the\n-             * tail -- and when the walk ran off the end it inserted nowhere\n-             * at all, leaking 'id' and dropping the alarm. Since the list is\n-             * only ever consumed from the head right below, appending at the\n-             * tail unconditionally is what the old code effectively did,\n-             * minus the leak.\n-             */\n-            PR_INSERT_BEFORE(&id->list, &alarm->timers);\n+static PRAlarmID* pr_getNextAlarm(PRAlarm* alarm, PRAlarmID* id) {\n+  /*\n+   * Puts 'id' back into the sorted list iff it's not NULL.\n+   * Removes the first element from the list and returns it (or NULL).\n+   * List is \"assumed\" to be short.\n+   *\n+   * NB: Caller is providing locking\n+   */\n+  PRCList* timer;\n+  PRAlarmID* result = id;\n+  PRIntervalTime now = PR_IntervalNow();\n+\n+  if (!PR_CLIST_IS_EMPTY(&alarm->timers)) {\n+    if (id != NULL) /* have to put this id back in */\n+    {\n+      PRIntervalTime idDelta = now - id->nextNotify;\n+      timer = alarm->timers.next;\n+      do {\n+        result = (PRAlarmID*)timer;\n+        if ((PRIntervalTime)(now - result->nextNotify) > idDelta) {\n+          PR_INSERT_BEFORE(&id->list, &alarm->timers);\n+          break;\n         }\n-        result = (PRAlarmID*)(timer = PR_LIST_HEAD(&alarm->timers));\n-        PR_REMOVE_LINK(timer); /* remove it from the list */\n+        timer = timer->next;\n+      } while (timer != &alarm->timers);\n     }\n+    result = (PRAlarmID*)(timer = PR_LIST_HEAD(&alarm->timers));\n+    PR_REMOVE_LINK(timer); /* remove it from the list */\n+  }\n \n-    return result;\n+  return result;\n } /* pr_getNextAlarm */\n \n-static PRIntervalTime\n-pr_PredictNextNotifyTime(PRAlarmID* id)\n-{\n-    PRIntervalTime delta;\n-    PRFloat64 baseRate = (PRFloat64)id->period / (PRFloat64)id->rate;\n-    PRFloat64 offsetFromEpoch = (PRFloat64)id->accumulator * baseRate;\n+static PRIntervalTime pr_PredictNextNotifyTime(PRAlarmID* id) {\n+  PRIntervalTime delta;\n+  PRFloat64 baseRate = (PRFloat64)id->period / (PRFloat64)id->rate;\n+  PRFloat64 offsetFromEpoch = (PRFloat64)id->accumulator * baseRate;\n \n-    id->accumulator += 1;            /* every call advances to next period */\n-    id->lastNotify = id->nextNotify; /* just keeping track of things */\n-    id->nextNotify = (PRIntervalTime)(offsetFromEpoch + 0.5);\n+  id->accumulator += 1;            /* every call advances to next period */\n+  id->lastNotify = id->nextNotify; /* just keeping track of things */\n+  id->nextNotify = (PRIntervalTime)(offsetFromEpoch + 0.5);\n \n-    delta = id->nextNotify - id->lastNotify;\n-    return delta;\n+  delta = id->nextNotify - id->lastNotify;\n+  return delta;\n } /* pr_PredictNextNotifyTime */\n \n-static void PR_CALLBACK\n-pr_alarmNotifier(void* arg)\n-{\n-    /*\n-     * This is the root of the notifier thread. There is one such thread\n-     * for each PRAlarm. It may service an arbitrary (though assumed to be\n-     * small) number of alarms using the same thread and structure. It\n-     * continues to run until the alarm is destroyed.\n-     */\n-    PRAlarmID* id = NULL;\n-    PRAlarm* alarm = (PRAlarm*)arg;\n-    enum { notify,\n-           abort,\n-           scan } why = scan;\n+static void PR_CALLBACK pr_alarmNotifier(void* arg) {\n+  /*\n+   * This is the root of the notifier thread. There is one such thread\n+   * for each PRAlarm. It may service an arbitrary (though assumed to be\n+   * small) number of alarms using the same thread and structure. It\n+   * continues to run until the alarm is destroyed.\n+   */\n+  PRAlarmID* id = NULL;\n+  PRAlarm* alarm = (PRAlarm*)arg;\n+  enum { notify, abort, scan } why = scan;\n \n-    while (why != abort) {\n-        PRIntervalTime pause;\n+  while (why != abort) {\n+    PRIntervalTime pause;\n \n-        PR_Lock(alarm->lock);\n-        while (why == scan) {\n-            alarm->current = NULL; /* reset current id */\n-            if (alarm->state == alarm_inactive) {\n-                /*\n-                 * We're about to exit. If we're still holding an alarm id\n-                 * that we pulled off the list, put it back so that\n-                 * PR_DestroyAlarm can find it and free it.\n-                 */\n-                if (id != NULL) {\n-                    PR_INSERT_BEFORE(&id->list, &alarm->timers);\n-                    id = NULL;\n-                }\n-                why = abort;        /* we're toast */\n-            } else if (why == scan) /* the dominant case */\n-            {\n-                id = pr_getNextAlarm(alarm, id); /* even if it's the same */\n-                if (id == NULL) {                /* there are no alarms set */\n-                    (void)PR_WaitCondVar(alarm->cond, PR_INTERVAL_NO_TIMEOUT);\n-                } else {\n-                    pause = id->nextNotify - (PR_IntervalNow() - id->epoch);\n-                    if ((PRInt32)pause <= 0) /* is this one's time up? */\n-                    {\n-                        why = notify;        /* set up to do our thing */\n-                        alarm->current = id; /* id we're about to schedule */\n-                    } else {\n-                        (void)PR_WaitCondVar(alarm->cond, pause); /* dally */\n-                    }\n-                }\n-            }\n+    PR_Lock(alarm->lock);\n+    while (why == scan) {\n+      alarm->current = NULL; /* reset current id */\n+      if (alarm->state == alarm_inactive) {\n+        why = abort;          /* we're toast */\n+      } else if (why == scan) /* the dominant case */\n+      {\n+        id = pr_getNextAlarm(alarm, id); /* even if it's the same */\n+        if (id == NULL) {                /* there are no alarms set */\n+          (void)PR_WaitCondVar(alarm->cond, PR_INTERVAL_NO_TIMEOUT);\n+        } else {\n+          pause = id->nextNotify - (PR_IntervalNow() - id->epoch);\n+          if ((PRInt32)pause <= 0) /* is this one's time up? */\n+          {\n+            why = notify;        /* set up to do our thing */\n+            alarm->current = id; /* id we're about to schedule */\n+          } else {\n+            (void)PR_WaitCondVar(alarm->cond, pause); /* dally */\n+          }\n         }\n-        PR_Unlock(alarm->lock);\n+      }\n+    }\n+    PR_Unlock(alarm->lock);\n \n-        if (why == notify) {\n-            (void)pr_PredictNextNotifyTime(id);\n-            if (!id->function(id, id->clientData, ~pause)) {\n-                /*\n-                 * Notified function decided not to continue. Free\n-                 * the alarm id to make sure it doesn't get back on\n-                 * the list.\n-                 */\n-                PR_DELETE(id); /* free notifier object */\n-                id = NULL;     /* so it doesn't get back into the list */\n-            }\n-            why = scan; /* so we can cycle through the loop again */\n-        }\n+    if (why == notify) {\n+      (void)pr_PredictNextNotifyTime(id);\n+      if (!id->function(id, id->clientData, ~pause)) {\n+        /*\n+         * Notified function decided not to continue. Free\n+         * the alarm id to make sure it doesn't get back on\n+         * the list.\n+         */\n+        PR_DELETE(id); /* free notifier object */\n+        id = NULL;     /* so it doesn't get back into the list */\n+      }\n+      why = scan; /* so we can cycle through the loop again */\n     }\n+  }\n \n } /* pr_alarm_notifier */\n \n-PR_IMPLEMENT(PRAlarm*)\n-PR_CreateAlarm(void)\n-{\n-    PRAlarm* alarm = PR_NEWZAP(PRAlarm);\n-    if (alarm != NULL) {\n-        if ((alarm->lock = PR_NewLock()) == NULL) {\n-            goto done;\n-        }\n-        if ((alarm->cond = PR_NewCondVar(alarm->lock)) == NULL) {\n-            goto done;\n-        }\n-        alarm->state = alarm_active;\n-        PR_INIT_CLIST(&alarm->timers);\n-        alarm->notifier =\n-            PR_CreateThread(PR_USER_THREAD, pr_alarmNotifier, alarm,\n-                            PR_GetThreadPriority(PR_GetCurrentThread()),\n-                            PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-        if (alarm->notifier == NULL) {\n-            goto done;\n-        }\n+PR_IMPLEMENT(PRAlarm*) PR_CreateAlarm(void) {\n+  PRAlarm* alarm = PR_NEWZAP(PRAlarm);\n+  if (alarm != NULL) {\n+    if ((alarm->lock = PR_NewLock()) == NULL) {\n+      goto done;\n     }\n-    return alarm;\n-\n-done:\n-    if (alarm->cond != NULL) {\n-        PR_DestroyCondVar(alarm->cond);\n+    if ((alarm->cond = PR_NewCondVar(alarm->lock)) == NULL) {\n+      goto done;\n     }\n-    if (alarm->lock != NULL) {\n-        PR_DestroyLock(alarm->lock);\n+    alarm->state = alarm_active;\n+    PR_INIT_CLIST(&alarm->timers);\n+    alarm->notifier =\n+        PR_CreateThread(PR_USER_THREAD, pr_alarmNotifier, alarm,\n+                        PR_GetThreadPriority(PR_GetCurrentThread()),\n+                        PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+    if (alarm->notifier == NULL) {\n+      goto done;\n     }\n-    PR_DELETE(alarm);\n-    return NULL;\n+  }\n+  return alarm;\n+\n+done:\n+  if (alarm->cond != NULL) {\n+    PR_DestroyCondVar(alarm->cond);\n+  }\n+  if (alarm->lock != NULL) {\n+    PR_DestroyLock(alarm->lock);\n+  }\n+  PR_DELETE(alarm);\n+  return NULL;\n } /* CreateAlarm */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_DestroyAlarm(PRAlarm* alarm)\n-{\n-    PRStatus rv;\n+PR_IMPLEMENT(PRStatus) PR_DestroyAlarm(PRAlarm* alarm) {\n+  PRStatus rv;\n \n-    PR_Lock(alarm->lock);\n-    alarm->state = alarm_inactive;\n-    rv = PR_NotifyCondVar(alarm->cond);\n-    PR_Unlock(alarm->lock);\n+  PR_Lock(alarm->lock);\n+  alarm->state = alarm_inactive;\n+  rv = PR_NotifyCondVar(alarm->cond);\n+  PR_Unlock(alarm->lock);\n \n-    if (rv == PR_SUCCESS) {\n-        rv = PR_JoinThread(alarm->notifier);\n-    }\n-    if (rv == PR_SUCCESS) {\n-        /*\n-         * The notifier thread has exited, so nothing else can be touching\n-         * the timers list and no locking is needed. Free any alarm ids that\n-         * were still pending when the alarm was destroyed.\n-         */\n-        while (!PR_CLIST_IS_EMPTY(&alarm->timers)) {\n-            PRAlarmID* id = (PRAlarmID*)PR_LIST_HEAD(&alarm->timers);\n-            PR_REMOVE_LINK(&id->list);\n-            PR_DELETE(id);\n-        }\n-        PR_DestroyCondVar(alarm->cond);\n-        PR_DestroyLock(alarm->lock);\n-        PR_DELETE(alarm);\n-    }\n-    return rv;\n+  if (rv == PR_SUCCESS) {\n+    rv = PR_JoinThread(alarm->notifier);\n+  }\n+  if (rv == PR_SUCCESS) {\n+    PR_DestroyCondVar(alarm->cond);\n+    PR_DestroyLock(alarm->lock);\n+    PR_DELETE(alarm);\n+  }\n+  return rv;\n } /* PR_DestroyAlarm */\n \n PR_IMPLEMENT(PRAlarmID*)\n PR_SetAlarm(PRAlarm* alarm, PRIntervalTime period, PRUint32 rate,\n-            PRPeriodicAlarmFn function, void* clientData)\n-{\n-    /*\n-     * Create a new periodic alarm an existing current structure.\n-     * Set up the context and compute the first notify time (immediate).\n-     * Link the new ID into the head of the list (since it's notifying\n-     * immediately).\n-     */\n+            PRPeriodicAlarmFn function, void* clientData) {\n+  /*\n+   * Create a new periodic alarm an existing current structure.\n+   * Set up the context and compute the first notify time (immediate).\n+   * Link the new ID into the head of the list (since it's notifying\n+   * immediately).\n+   */\n \n-    PRAlarmID* id = PR_NEWZAP(PRAlarmID);\n+  PRAlarmID* id = PR_NEWZAP(PRAlarmID);\n \n-    if (!id) {\n-        return NULL;\n-    }\n-\n-    id->alarm = alarm;\n-    PR_INIT_CLIST(&id->list);\n-    id->function = function;\n-    id->clientData = clientData;\n-    id->period = period;\n-    id->rate = rate;\n-    id->epoch = id->nextNotify = PR_IntervalNow();\n-    (void)pr_PredictNextNotifyTime(id);\n-\n-    PR_Lock(alarm->lock);\n-    PR_INSERT_BEFORE(&id->list, &alarm->timers);\n-    PR_NotifyCondVar(alarm->cond);\n-    PR_Unlock(alarm->lock);\n-\n-    return id;\n+  if (!id) {\n+    return NULL;\n+  }\n+\n+  id->alarm = alarm;\n+  PR_INIT_CLIST(&id->list);\n+  id->function = function;\n+  id->clientData = clientData;\n+  id->period = period;\n+  id->rate = rate;\n+  id->epoch = id->nextNotify = PR_IntervalNow();\n+  (void)pr_PredictNextNotifyTime(id);\n+\n+  PR_Lock(alarm->lock);\n+  PR_INSERT_BEFORE(&id->list, &alarm->timers);\n+  PR_NotifyCondVar(alarm->cond);\n+  PR_Unlock(alarm->lock);\n+\n+  return id;\n } /* PR_SetAlarm */\n \n PR_IMPLEMENT(PRStatus)\n-PR_ResetAlarm(PRAlarmID* id, PRIntervalTime period, PRUint32 rate)\n-{\n-    /*\n-     * Can only be called from within the notify routine. Doesn't\n-     * need locking because it can only be called from within the\n-     * notify routine.\n-     */\n-    if (id != id->alarm->current) {\n-        return PR_FAILURE;\n-    }\n-    id->period = period;\n-    id->rate = rate;\n-    id->accumulator = 1;\n-    id->epoch = PR_IntervalNow();\n-    (void)pr_PredictNextNotifyTime(id);\n-    return PR_SUCCESS;\n+PR_ResetAlarm(PRAlarmID* id, PRIntervalTime period, PRUint32 rate) {\n+  /*\n+   * Can only be called from within the notify routine. Doesn't\n+   * need locking because it can only be called from within the\n+   * notify routine.\n+   */\n+  if (id != id->alarm->current) {\n+    return PR_FAILURE;\n+  }\n+  id->period = period;\n+  id->rate = rate;\n+  id->accumulator = 1;\n+  id->epoch = PR_IntervalNow();\n+  (void)pr_PredictNextNotifyTime(id);\n+  return PR_SUCCESS;\n } /* PR_ResetAlarm */\ndiff --git a/nspr/pr/src/misc/pratom.c b/nspr/pr/src/misc/pratom.c\nindex 4cb1ce0..8cd87ec 100644\n--- a/nspr/pr/src/misc/pratom.c\n+++ b/nspr/pr/src/misc/pratom.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -21,7 +22,7 @@\n \n #if !defined(_PR_HAVE_ATOMIC_OPS)\n \n-#if defined(_PR_PTHREADS)\n+#  if defined(_PR_PTHREADS)\n /*\n  * PR_AtomicDecrement() is used in NSPR's thread-specific data\n  * destructor.  Because thread-specific data destructors may be\n@@ -41,10 +42,10 @@\n /*\n  * lock counts should be a power of 2\n  */\n-#define DEFAULT_ATOMIC_LOCKS                                \\\n-    16 /* should be in sync with the number of initializers \\\n-           below */\n-#define MAX_ATOMIC_LOCKS (4 * 1024)\n+#    define DEFAULT_ATOMIC_LOCKS                              \\\n+      16 /* should be in sync with the number of initializers \\\n+             below */\n+#    define MAX_ATOMIC_LOCKS (4 * 1024)\n \n static pthread_mutex_t static_atomic_locks[DEFAULT_ATOMIC_LOCKS] = {\n     PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,\n@@ -54,217 +55,192 @@ static pthread_mutex_t static_atomic_locks[DEFAULT_ATOMIC_LOCKS] = {\n     PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,\n     PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,\n     PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,\n-    PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER\n-};\n+    PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER};\n \n-#ifdef DEBUG\n+#    ifdef DEBUG\n static PRInt32 static_hash_lock_counts[DEFAULT_ATOMIC_LOCKS];\n static PRInt32* hash_lock_counts = static_hash_lock_counts;\n-#endif\n+#    endif\n \n static PRUint32 num_atomic_locks = DEFAULT_ATOMIC_LOCKS;\n static pthread_mutex_t* atomic_locks = static_atomic_locks;\n static PRUint32 atomic_hash_mask = DEFAULT_ATOMIC_LOCKS - 1;\n \n-#define _PR_HASH_FOR_LOCK(ptr)                                         \\\n-    ((PRUint32)(((PRUptrdiff)(ptr) >> 2) ^ ((PRUptrdiff)(ptr) >> 8)) & \\\n-     atomic_hash_mask)\n-\n-void\n-_PR_MD_INIT_ATOMIC()\n-{\n-    char* eval;\n-    int index;\n-\n-    PR_ASSERT(PR_FloorLog2(MAX_ATOMIC_LOCKS) == PR_CeilingLog2(MAX_ATOMIC_LOCKS));\n-\n-    PR_ASSERT(PR_FloorLog2(DEFAULT_ATOMIC_LOCKS) ==\n-              PR_CeilingLog2(DEFAULT_ATOMIC_LOCKS));\n-\n-    if (((eval = getenv(\"NSPR_ATOMIC_HASH_LOCKS\")) != NULL) &&\n-        ((num_atomic_locks = atoi(eval)) != DEFAULT_ATOMIC_LOCKS)) {\n-        if (num_atomic_locks > MAX_ATOMIC_LOCKS) {\n-            num_atomic_locks = MAX_ATOMIC_LOCKS;\n-        } else if (num_atomic_locks < 1) {\n-            num_atomic_locks = 1;\n-        } else {\n-            num_atomic_locks = PR_FloorLog2(num_atomic_locks);\n-            num_atomic_locks = 1L << num_atomic_locks;\n-        }\n-        atomic_locks =\n-            (pthread_mutex_t*)PR_Malloc(sizeof(pthread_mutex_t) * num_atomic_locks);\n-        if (atomic_locks) {\n-            for (index = 0; index < num_atomic_locks; index++) {\n-                if (pthread_mutex_init(&atomic_locks[index], NULL)) {\n-                    PR_DELETE(atomic_locks);\n-                    atomic_locks = NULL;\n-                    break;\n-                }\n-            }\n-        }\n-#ifdef DEBUG\n-        if (atomic_locks) {\n-            hash_lock_counts = PR_CALLOC(num_atomic_locks * sizeof(PRInt32));\n-            if (hash_lock_counts == NULL) {\n-                PR_DELETE(atomic_locks);\n-                atomic_locks = NULL;\n-            }\n-        }\n-#endif\n-        if (atomic_locks == NULL) {\n-            /*\n-             *  Use statically allocated locks\n-             */\n-            atomic_locks = static_atomic_locks;\n-            num_atomic_locks = DEFAULT_ATOMIC_LOCKS;\n-#ifdef DEBUG\n-            hash_lock_counts = static_hash_lock_counts;\n-#endif\n+#    define _PR_HASH_FOR_LOCK(ptr)                                       \\\n+      ((PRUint32)(((PRUptrdiff)(ptr) >> 2) ^ ((PRUptrdiff)(ptr) >> 8)) & \\\n+       atomic_hash_mask)\n+\n+void _PR_MD_INIT_ATOMIC() {\n+  char* eval;\n+  int index;\n+\n+  PR_ASSERT(PR_FloorLog2(MAX_ATOMIC_LOCKS) == PR_CeilingLog2(MAX_ATOMIC_LOCKS));\n+\n+  PR_ASSERT(PR_FloorLog2(DEFAULT_ATOMIC_LOCKS) ==\n+            PR_CeilingLog2(DEFAULT_ATOMIC_LOCKS));\n+\n+  if (((eval = getenv(\"NSPR_ATOMIC_HASH_LOCKS\")) != NULL) &&\n+      ((num_atomic_locks = atoi(eval)) != DEFAULT_ATOMIC_LOCKS)) {\n+    if (num_atomic_locks > MAX_ATOMIC_LOCKS) {\n+      num_atomic_locks = MAX_ATOMIC_LOCKS;\n+    } else if (num_atomic_locks < 1) {\n+      num_atomic_locks = 1;\n+    } else {\n+      num_atomic_locks = PR_FloorLog2(num_atomic_locks);\n+      num_atomic_locks = 1L << num_atomic_locks;\n+    }\n+    atomic_locks =\n+        (pthread_mutex_t*)PR_Malloc(sizeof(pthread_mutex_t) * num_atomic_locks);\n+    if (atomic_locks) {\n+      for (index = 0; index < num_atomic_locks; index++) {\n+        if (pthread_mutex_init(&atomic_locks[index], NULL)) {\n+          PR_DELETE(atomic_locks);\n+          atomic_locks = NULL;\n+          break;\n         }\n-        atomic_hash_mask = num_atomic_locks - 1;\n+      }\n+    }\n+#    ifdef DEBUG\n+    if (atomic_locks) {\n+      hash_lock_counts = PR_CALLOC(num_atomic_locks * sizeof(PRInt32));\n+      if (hash_lock_counts == NULL) {\n+        PR_DELETE(atomic_locks);\n+        atomic_locks = NULL;\n+      }\n     }\n-    PR_ASSERT(PR_FloorLog2(num_atomic_locks) == PR_CeilingLog2(num_atomic_locks));\n+#    endif\n+    if (atomic_locks == NULL) {\n+      /*\n+       *  Use statically allocated locks\n+       */\n+      atomic_locks = static_atomic_locks;\n+      num_atomic_locks = DEFAULT_ATOMIC_LOCKS;\n+#    ifdef DEBUG\n+      hash_lock_counts = static_hash_lock_counts;\n+#    endif\n+    }\n+    atomic_hash_mask = num_atomic_locks - 1;\n+  }\n+  PR_ASSERT(PR_FloorLog2(num_atomic_locks) == PR_CeilingLog2(num_atomic_locks));\n }\n \n-PRInt32\n-_PR_MD_ATOMIC_INCREMENT(PRInt32* val)\n-{\n-    PRInt32 rv;\n-    PRInt32 idx = _PR_HASH_FOR_LOCK(val);\n-\n-    pthread_mutex_lock(&atomic_locks[idx]);\n-    rv = ++(*val);\n-#ifdef DEBUG\n-    hash_lock_counts[idx]++;\n-#endif\n-    pthread_mutex_unlock(&atomic_locks[idx]);\n-    return rv;\n+PRInt32 _PR_MD_ATOMIC_INCREMENT(PRInt32* val) {\n+  PRInt32 rv;\n+  PRInt32 idx = _PR_HASH_FOR_LOCK(val);\n+\n+  pthread_mutex_lock(&atomic_locks[idx]);\n+  rv = ++(*val);\n+#    ifdef DEBUG\n+  hash_lock_counts[idx]++;\n+#    endif\n+  pthread_mutex_unlock(&atomic_locks[idx]);\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_ATOMIC_ADD(PRInt32* ptr, PRInt32 val)\n-{\n-    PRInt32 rv;\n-    PRInt32 idx = _PR_HASH_FOR_LOCK(ptr);\n-\n-    pthread_mutex_lock(&atomic_locks[idx]);\n-    rv = ((*ptr) += val);\n-#ifdef DEBUG\n-    hash_lock_counts[idx]++;\n-#endif\n-    pthread_mutex_unlock(&atomic_locks[idx]);\n-    return rv;\n+PRInt32 _PR_MD_ATOMIC_ADD(PRInt32* ptr, PRInt32 val) {\n+  PRInt32 rv;\n+  PRInt32 idx = _PR_HASH_FOR_LOCK(ptr);\n+\n+  pthread_mutex_lock(&atomic_locks[idx]);\n+  rv = ((*ptr) += val);\n+#    ifdef DEBUG\n+  hash_lock_counts[idx]++;\n+#    endif\n+  pthread_mutex_unlock(&atomic_locks[idx]);\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_ATOMIC_DECREMENT(PRInt32* val)\n-{\n-    PRInt32 rv;\n-    PRInt32 idx = _PR_HASH_FOR_LOCK(val);\n-\n-    pthread_mutex_lock(&atomic_locks[idx]);\n-    rv = --(*val);\n-#ifdef DEBUG\n-    hash_lock_counts[idx]++;\n-#endif\n-    pthread_mutex_unlock(&atomic_locks[idx]);\n-    return rv;\n+PRInt32 _PR_MD_ATOMIC_DECREMENT(PRInt32* val) {\n+  PRInt32 rv;\n+  PRInt32 idx = _PR_HASH_FOR_LOCK(val);\n+\n+  pthread_mutex_lock(&atomic_locks[idx]);\n+  rv = --(*val);\n+#    ifdef DEBUG\n+  hash_lock_counts[idx]++;\n+#    endif\n+  pthread_mutex_unlock(&atomic_locks[idx]);\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_ATOMIC_SET(PRInt32* val, PRInt32 newval)\n-{\n-    PRInt32 rv;\n-    PRInt32 idx = _PR_HASH_FOR_LOCK(val);\n-\n-    pthread_mutex_lock(&atomic_locks[idx]);\n-    rv = *val;\n-    *val = newval;\n-#ifdef DEBUG\n-    hash_lock_counts[idx]++;\n-#endif\n-    pthread_mutex_unlock(&atomic_locks[idx]);\n-    return rv;\n+PRInt32 _PR_MD_ATOMIC_SET(PRInt32* val, PRInt32 newval) {\n+  PRInt32 rv;\n+  PRInt32 idx = _PR_HASH_FOR_LOCK(val);\n+\n+  pthread_mutex_lock(&atomic_locks[idx]);\n+  rv = *val;\n+  *val = newval;\n+#    ifdef DEBUG\n+  hash_lock_counts[idx]++;\n+#    endif\n+  pthread_mutex_unlock(&atomic_locks[idx]);\n+  return rv;\n }\n-#else  /* _PR_PTHREADS */\n+#  else  /* _PR_PTHREADS */\n /*\n  * We use a single lock for all the emulated atomic operations.\n  * The lock contention should be acceptable.\n  */\n static PRLock* atomic_lock = NULL;\n-void\n-_PR_MD_INIT_ATOMIC(void)\n-{\n-    if (atomic_lock == NULL) {\n-        atomic_lock = PR_NewLock();\n-    }\n+void _PR_MD_INIT_ATOMIC(void) {\n+  if (atomic_lock == NULL) {\n+    atomic_lock = PR_NewLock();\n+  }\n }\n \n-PRInt32\n-_PR_MD_ATOMIC_INCREMENT(PRInt32* val)\n-{\n-    PRInt32 rv;\n+PRInt32 _PR_MD_ATOMIC_INCREMENT(PRInt32* val) {\n+  PRInt32 rv;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    PR_Lock(atomic_lock);\n-    rv = ++(*val);\n-    PR_Unlock(atomic_lock);\n-    return rv;\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  PR_Lock(atomic_lock);\n+  rv = ++(*val);\n+  PR_Unlock(atomic_lock);\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_ATOMIC_ADD(PRInt32* ptr, PRInt32 val)\n-{\n-    PRInt32 rv;\n+PRInt32 _PR_MD_ATOMIC_ADD(PRInt32* ptr, PRInt32 val) {\n+  PRInt32 rv;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    PR_Lock(atomic_lock);\n-    rv = ((*ptr) += val);\n-    PR_Unlock(atomic_lock);\n-    return rv;\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  PR_Lock(atomic_lock);\n+  rv = ((*ptr) += val);\n+  PR_Unlock(atomic_lock);\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_ATOMIC_DECREMENT(PRInt32* val)\n-{\n-    PRInt32 rv;\n+PRInt32 _PR_MD_ATOMIC_DECREMENT(PRInt32* val) {\n+  PRInt32 rv;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    PR_Lock(atomic_lock);\n-    rv = --(*val);\n-    PR_Unlock(atomic_lock);\n-    return rv;\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  PR_Lock(atomic_lock);\n+  rv = --(*val);\n+  PR_Unlock(atomic_lock);\n+  return rv;\n }\n \n-PRInt32\n-_PR_MD_ATOMIC_SET(PRInt32* val, PRInt32 newval)\n-{\n-    PRInt32 rv;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    PR_Lock(atomic_lock);\n-    rv = *val;\n-    *val = newval;\n-    PR_Unlock(atomic_lock);\n-    return rv;\n+PRInt32 _PR_MD_ATOMIC_SET(PRInt32* val, PRInt32 newval) {\n+  PRInt32 rv;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  PR_Lock(atomic_lock);\n+  rv = *val;\n+  *val = newval;\n+  PR_Unlock(atomic_lock);\n+  return rv;\n }\n-#endif /* _PR_PTHREADS */\n+#  endif /* _PR_PTHREADS */\n \n #endif /* !_PR_HAVE_ATOMIC_OPS */\n \n-void\n-_PR_InitAtomic(void)\n-{\n-    _PR_MD_INIT_ATOMIC();\n-}\n+void _PR_InitAtomic(void) { _PR_MD_INIT_ATOMIC(); }\n \n PR_IMPLEMENT(PRInt32)\n PR_AtomicIncrement(PRInt32* val) { return _PR_MD_ATOMIC_INCREMENT(val); }\n@@ -273,9 +249,8 @@ PR_IMPLEMENT(PRInt32)\n PR_AtomicDecrement(PRInt32* val) { return _PR_MD_ATOMIC_DECREMENT(val); }\n \n PR_IMPLEMENT(PRInt32)\n-PR_AtomicSet(PRInt32* val, PRInt32 newval)\n-{\n-    return _PR_MD_ATOMIC_SET(val, newval);\n+PR_AtomicSet(PRInt32* val, PRInt32 newval) {\n+  return _PR_MD_ATOMIC_SET(val, newval);\n }\n \n PR_IMPLEMENT(PRInt32)\n@@ -286,85 +261,81 @@ PR_AtomicAdd(PRInt32* ptr, PRInt32 val) { return _PR_MD_ATOMIC_ADD(ptr, val); }\n  */\n \n PR_IMPLEMENT(PRStack*)\n-PR_CreateStack(const char* stack_name)\n-{\n-    PRStack* stack;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    if ((stack = PR_NEW(PRStack)) == NULL) {\n-        return NULL;\n-    }\n-    if (stack_name) {\n-        stack->prstk_name = (char*)PR_Malloc(strlen(stack_name) + 1);\n-        if (stack->prstk_name == NULL) {\n-            PR_DELETE(stack);\n-            return NULL;\n-        }\n-        strcpy(stack->prstk_name, stack_name);\n-    } else {\n-        stack->prstk_name = NULL;\n+PR_CreateStack(const char* stack_name) {\n+  PRStack* stack;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  if ((stack = PR_NEW(PRStack)) == NULL) {\n+    return NULL;\n+  }\n+  if (stack_name) {\n+    stack->prstk_name = (char*)PR_Malloc(strlen(stack_name) + 1);\n+    if (stack->prstk_name == NULL) {\n+      PR_DELETE(stack);\n+      return NULL;\n     }\n+    strcpy(stack->prstk_name, stack_name);\n+  } else {\n+    stack->prstk_name = NULL;\n+  }\n \n #ifndef _PR_HAVE_ATOMIC_CAS\n-    stack->prstk_lock = PR_NewLock();\n-    if (stack->prstk_lock == NULL) {\n-        PR_Free(stack->prstk_name);\n-        PR_DELETE(stack);\n-        return NULL;\n-    }\n+  stack->prstk_lock = PR_NewLock();\n+  if (stack->prstk_lock == NULL) {\n+    PR_Free(stack->prstk_name);\n+    PR_DELETE(stack);\n+    return NULL;\n+  }\n #endif /* !_PR_HAVE_ATOMIC_CAS */\n \n-    stack->prstk_head.prstk_elem_next = NULL;\n+  stack->prstk_head.prstk_elem_next = NULL;\n \n-    return stack;\n+  return stack;\n }\n \n PR_IMPLEMENT(PRStatus)\n-PR_DestroyStack(PRStack* stack)\n-{\n-    if (stack->prstk_head.prstk_elem_next != NULL) {\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-\n-    if (stack->prstk_name) {\n-        PR_Free(stack->prstk_name);\n-    }\n+PR_DestroyStack(PRStack* stack) {\n+  if (stack->prstk_head.prstk_elem_next != NULL) {\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+\n+  if (stack->prstk_name) {\n+    PR_Free(stack->prstk_name);\n+  }\n #ifndef _PR_HAVE_ATOMIC_CAS\n-    PR_DestroyLock(stack->prstk_lock);\n+  PR_DestroyLock(stack->prstk_lock);\n #endif /* !_PR_HAVE_ATOMIC_CAS */\n-    PR_DELETE(stack);\n+  PR_DELETE(stack);\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n }\n \n #ifndef _PR_HAVE_ATOMIC_CAS\n \n PR_IMPLEMENT(void)\n-PR_StackPush(PRStack* stack, PRStackElem* stack_elem)\n-{\n-    PR_Lock(stack->prstk_lock);\n-    stack_elem->prstk_elem_next = stack->prstk_head.prstk_elem_next;\n-    stack->prstk_head.prstk_elem_next = stack_elem;\n-    PR_Unlock(stack->prstk_lock);\n-    return;\n+PR_StackPush(PRStack* stack, PRStackElem* stack_elem) {\n+  PR_Lock(stack->prstk_lock);\n+  stack_elem->prstk_elem_next = stack->prstk_head.prstk_elem_next;\n+  stack->prstk_head.prstk_elem_next = stack_elem;\n+  PR_Unlock(stack->prstk_lock);\n+  return;\n }\n \n PR_IMPLEMENT(PRStackElem*)\n-PR_StackPop(PRStack* stack)\n-{\n-    PRStackElem* element;\n-\n-    PR_Lock(stack->prstk_lock);\n-    element = stack->prstk_head.prstk_elem_next;\n-    if (element != NULL) {\n-        stack->prstk_head.prstk_elem_next = element->prstk_elem_next;\n-        element->prstk_elem_next = NULL; /* debugging aid */\n-    }\n-    PR_Unlock(stack->prstk_lock);\n-    return element;\n+PR_StackPop(PRStack* stack) {\n+  PRStackElem* element;\n+\n+  PR_Lock(stack->prstk_lock);\n+  element = stack->prstk_head.prstk_elem_next;\n+  if (element != NULL) {\n+    stack->prstk_head.prstk_elem_next = element->prstk_elem_next;\n+    element->prstk_elem_next = NULL; /* debugging aid */\n+  }\n+  PR_Unlock(stack->prstk_lock);\n+  return element;\n }\n #endif /* !_PR_HAVE_ATOMIC_CAS */\ndiff --git a/nspr/pr/src/misc/praton.c b/nspr/pr/src/misc/praton.c\nindex d21a6da..e1abcd7 100644\n--- a/nspr/pr/src/misc/praton.c\n+++ b/nspr/pr/src/misc/praton.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /*******************************************************************************\n  * The following function pr_inet_aton is based on the BSD function inet_aton\n  * with some modifications. The license and copyright notices applying to this\n@@ -74,388 +75,132 @@\n \n #define XX 127\n static const unsigned char index_hex[256] = {\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    0,\n-    1,\n-    2,\n-    3,\n-    4,\n-    5,\n-    6,\n-    7,\n-    8,\n-    9,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    10,\n-    11,\n-    12,\n-    13,\n-    14,\n-    15,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    10,\n-    11,\n-    12,\n-    13,\n-    14,\n-    15,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, 0,  1,  2,  3,  4,  5,  6,  7,  8,\n+    9,  XX, XX, XX, XX, XX, XX, XX, 10, 11, 12, 13, 14, 15, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, 10, 11, 12, 13, 14, 15, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX,\n };\n \n-static PRBool\n-_isdigit(char c)\n-{\n-    return c >= '0' && c <= '9';\n-}\n-static PRBool\n-_isxdigit(char c)\n-{\n-    return index_hex[(unsigned char)c] != XX;\n-}\n-static PRBool\n-_isspace(char c)\n-{\n-    return c == ' ' || (c >= '\\t' && c <= '\\r');\n-}\n+static PRBool _isdigit(char c) { return c >= '0' && c <= '9'; }\n+static PRBool _isxdigit(char c) { return index_hex[(unsigned char)c] != XX; }\n+static PRBool _isspace(char c) { return c == ' ' || (c >= '\\t' && c <= '\\r'); }\n #undef XX\n \n-int\n-pr_inet_aton(const char* cp, PRUint32* addr)\n-{\n-    PRUint32 val;\n-    int base, n;\n-    char c;\n-    PRUint8 parts[4];\n-    PRUint8* pp = parts;\n-    int digit;\n+int pr_inet_aton(const char* cp, PRUint32* addr) {\n+  PRUint32 val;\n+  int base, n;\n+  char c;\n+  PRUint8 parts[4];\n+  PRUint8* pp = parts;\n+  int digit;\n \n-    c = *cp;\n-    for (;;) {\n-        /*\n-         * Collect number up to ``.''.\n-         * Values are specified as for C:\n-         * 0x=hex, 0=octal, isdigit=decimal.\n-         */\n-        if (!_isdigit(c)) {\n-            return (0);\n-        }\n-        val = 0;\n-        base = 10;\n-        digit = 0;\n-        if (c == '0') {\n-            c = *++cp;\n-            if (c == 'x' || c == 'X') {\n-                base = 16, c = *++cp;\n-            } else {\n-                base = 8;\n-                digit = 1;\n-            }\n-        }\n-        for (;;) {\n-            if (_isdigit(c)) {\n-                if (base == 8 && (c == '8' || c == '9')) {\n-                    return (0);\n-                }\n-                val = (val * base) + (c - '0');\n-                c = *++cp;\n-                digit = 1;\n-            } else if (base == 16 && _isxdigit(c)) {\n-                val = (val << 4) + index_hex[(unsigned char)c];\n-                c = *++cp;\n-                digit = 1;\n-            } else {\n-                break;\n-            }\n-        }\n-        if (c == '.') {\n-            /*\n-             * Internet format:\n-             *    a.b.c.d\n-             *    a.b.c    (with c treated as 16 bits)\n-             *    a.b    (with b treated as 24 bits)\n-             */\n-            if (pp >= parts + 3 || val > 0xffU) {\n-                return (0);\n-            }\n-            *pp++ = val;\n-            c = *++cp;\n-        } else {\n-            break;\n-        }\n-    }\n+  c = *cp;\n+  for (;;) {\n     /*\n-     * Check for trailing characters.\n+     * Collect number up to ``.''.\n+     * Values are specified as for C:\n+     * 0x=hex, 0=octal, isdigit=decimal.\n      */\n-    if (c != '\\0' && !_isspace(c)) {\n-        return (0);\n+    if (!_isdigit(c)) {\n+      return (0);\n     }\n-    /*\n-     * Did we get a valid digit?\n-     */\n-    if (!digit) {\n+    val = 0;\n+    base = 10;\n+    digit = 0;\n+    if (c == '0') {\n+      c = *++cp;\n+      if (c == 'x' || c == 'X') {\n+        base = 16, c = *++cp;\n+      } else {\n+        base = 8;\n+        digit = 1;\n+      }\n+    }\n+    for (;;) {\n+      if (_isdigit(c)) {\n+        if (base == 8 && (c == '8' || c == '9')) {\n+          return (0);\n+        }\n+        val = (val * base) + (c - '0');\n+        c = *++cp;\n+        digit = 1;\n+      } else if (base == 16 && _isxdigit(c)) {\n+        val = (val << 4) + index_hex[(unsigned char)c];\n+        c = *++cp;\n+        digit = 1;\n+      } else {\n+        break;\n+      }\n+    }\n+    if (c == '.') {\n+      /*\n+       * Internet format:\n+       *    a.b.c.d\n+       *    a.b.c    (with c treated as 16 bits)\n+       *    a.b    (with b treated as 24 bits)\n+       */\n+      if (pp >= parts + 3 || val > 0xffU) {\n         return (0);\n+      }\n+      *pp++ = val;\n+      c = *++cp;\n+    } else {\n+      break;\n     }\n-    /*\n-     * Concoct the address according to\n-     * the number of parts specified.\n-     */\n-    n = pp - parts + 1;\n-    switch (n) {\n-        case 1: /*%< a -- 32 bits */\n-            break;\n+  }\n+  /*\n+   * Check for trailing characters.\n+   */\n+  if (c != '\\0' && !_isspace(c)) {\n+    return (0);\n+  }\n+  /*\n+   * Did we get a valid digit?\n+   */\n+  if (!digit) {\n+    return (0);\n+  }\n+  /*\n+   * Concoct the address according to\n+   * the number of parts specified.\n+   */\n+  n = pp - parts + 1;\n+  switch (n) {\n+    case 1: /*%< a -- 32 bits */\n+      break;\n \n-        case 2: /*%< a.b -- 8.24 bits */\n-            if (val > 0xffffffU) {\n-                return (0);\n-            }\n-            val |= (unsigned int)parts[0] << 24;\n-            break;\n+    case 2: /*%< a.b -- 8.24 bits */\n+      if (val > 0xffffffU) {\n+        return (0);\n+      }\n+      val |= (unsigned int)parts[0] << 24;\n+      break;\n \n-        case 3: /*%< a.b.c -- 8.8.16 bits */\n-            if (val > 0xffffU) {\n-                return (0);\n-            }\n-            val |= ((unsigned int)parts[0] << 24) | ((unsigned int)parts[1] << 16);\n-            break;\n+    case 3: /*%< a.b.c -- 8.8.16 bits */\n+      if (val > 0xffffU) {\n+        return (0);\n+      }\n+      val |= ((unsigned int)parts[0] << 24) | ((unsigned int)parts[1] << 16);\n+      break;\n \n-        case 4: /*%< a.b.c.d -- 8.8.8.8 bits */\n-            if (val > 0xffU) {\n-                return (0);\n-            }\n-            val |= ((unsigned int)parts[0] << 24) | ((unsigned int)parts[1] << 16) |\n-                   ((unsigned int)parts[2] << 8);\n-            break;\n-    }\n-    *addr = PR_htonl(val);\n-    return (1);\n+    case 4: /*%< a.b.c.d -- 8.8.8.8 bits */\n+      if (val > 0xffU) {\n+        return (0);\n+      }\n+      val |= ((unsigned int)parts[0] << 24) | ((unsigned int)parts[1] << 16) |\n+             ((unsigned int)parts[2] << 8);\n+      break;\n+  }\n+  *addr = PR_htonl(val);\n+  return (1);\n }\ndiff --git a/nspr/pr/src/misc/prcountr.c b/nspr/pr/src/misc/prcountr.c\nindex 9169b18..e16f6d8 100644\n--- a/nspr/pr/src/misc/prcountr.c\n+++ b/nspr/pr/src/misc/prcountr.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -49,21 +50,21 @@\n **\n */\n typedef struct QName {\n-    PRCList link;\n-    PRCList rNameList;\n-    char name[PRCOUNTER_NAME_MAX + 1];\n+  PRCList link;\n+  PRCList rNameList;\n+  char name[PRCOUNTER_NAME_MAX + 1];\n } QName;\n \n /*\n **\n */\n typedef struct RName {\n-    PRCList link;\n-    QName* qName;\n-    PRLock* lock;\n-    volatile PRUint32 counter;\n-    char name[PRCOUNTER_NAME_MAX + 1];\n-    char desc[PRCOUNTER_DESC_MAX + 1];\n+  PRCList link;\n+  QName* qName;\n+  PRLock* lock;\n+  volatile PRUint32 counter;\n+  char name[PRCOUNTER_NAME_MAX + 1];\n+  char desc[PRCOUNTER_DESC_MAX + 1];\n } RName;\n \n /*\n@@ -77,20 +78,18 @@ static PRLogModuleInfo* lm;\n ** _PR_CounterInitialize() -- Initialize the Counter Facility\n **\n */\n-static void\n-_PR_CounterInitialize(void)\n-{\n-    /*\n-    ** This function should be called only once\n-    */\n-    PR_ASSERT(counterLock == NULL);\n-\n-    counterLock = PR_NewLock();\n-    PR_INIT_CLIST(&qNameList);\n-    lm = PR_NewLogModule(\"counters\");\n-    PR_LOG(lm, PR_LOG_DEBUG, (\"PR_Counter: Initialization complete\"));\n-\n-    return;\n+static void _PR_CounterInitialize(void) {\n+  /*\n+  ** This function should be called only once\n+  */\n+  PR_ASSERT(counterLock == NULL);\n+\n+  counterLock = PR_NewLock();\n+  PR_INIT_CLIST(&qNameList);\n+  lm = PR_NewLogModule(\"counters\");\n+  PR_LOG(lm, PR_LOG_DEBUG, (\"PR_Counter: Initialization complete\"));\n+\n+  return;\n } /* end _PR_CounterInitialize() */\n \n /*\n@@ -110,160 +109,157 @@ _PR_CounterInitialize(void)\n */\n PR_IMPLEMENT(PRCounterHandle)\n PR_CreateCounter(const char* qName, const char* rName,\n-                 const char* description)\n-{\n-    QName* qnp;\n-    RName* rnp;\n-    PRBool matchQname = PR_FALSE;\n-\n-    /* Self initialize, if necessary */\n-    if (counterLock == NULL) {\n-        _PR_CounterInitialize();\n-    }\n-\n-    /* Validate input arguments */\n-    PR_ASSERT(strlen(qName) <= PRCOUNTER_NAME_MAX);\n-    PR_ASSERT(strlen(rName) <= PRCOUNTER_NAME_MAX);\n-    PR_ASSERT(strlen(description) <= PRCOUNTER_DESC_MAX);\n-\n-    /* Lock the Facility */\n-    PR_Lock(counterLock);\n-\n-    /* Do we already have a matching QName? */\n-    if (!PR_CLIST_IS_EMPTY(&qNameList)) {\n-        qnp = (QName*)PR_LIST_HEAD(&qNameList);\n-        do {\n-            if (strcmp(qnp->name, qName) == 0) {\n-                matchQname = PR_TRUE;\n-                break;\n-            }\n-            qnp = (QName*)PR_NEXT_LINK(&qnp->link);\n-        } while (qnp != (QName*)&qNameList);\n-    }\n-    /*\n-    ** If we did not find a matching QName,\n-    **    allocate one and initialize it.\n-    **    link it onto the qNameList.\n-    **\n-    */\n-    if (matchQname != PR_TRUE) {\n-        qnp = PR_NEWZAP(QName);\n-        PR_ASSERT(qnp != NULL);\n-        PR_INIT_CLIST(&qnp->link);\n-        PR_INIT_CLIST(&qnp->rNameList);\n-        strcpy(qnp->name, qName);\n-        PR_APPEND_LINK(&qnp->link, &qNameList);\n-    }\n-\n-    /* Do we already have a matching RName? */\n-    if (!PR_CLIST_IS_EMPTY(&qnp->rNameList)) {\n-        rnp = (RName*)PR_LIST_HEAD(&qnp->rNameList);\n-        do {\n-            /*\n-            ** No duplicate RNames are allowed within a QName\n-            **\n-            */\n-            PR_ASSERT(strcmp(rnp->name, rName));\n-            rnp = (RName*)PR_NEXT_LINK(&rnp->link);\n-        } while (rnp != (RName*)&qnp->rNameList);\n-    }\n-\n-    /* Get a new RName structure; initialize its members */\n-    rnp = PR_NEWZAP(RName);\n-    PR_ASSERT(rnp != NULL);\n-    PR_INIT_CLIST(&rnp->link);\n-    strcpy(rnp->name, rName);\n-    strcpy(rnp->desc, description);\n-    rnp->lock = PR_NewLock();\n-    if (rnp->lock == NULL) {\n-        PR_ASSERT(0);\n-    }\n-\n-    PR_APPEND_LINK(&rnp->link, &qnp->rNameList); /* add RName to QName's rnList */\n-    rnp->qName = qnp;                            /* point the RName to the QName */\n-\n-    /* Unlock the Facility */\n-    PR_Unlock(counterLock);\n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PR_Counter: Create: QName: %s %p, RName: %s %p\\n\\t\", qName, qnp,\n-            rName, rnp));\n-\n-    return ((PRCounterHandle)rnp);\n+                 const char* description) {\n+  QName* qnp;\n+  RName* rnp;\n+  PRBool matchQname = PR_FALSE;\n+\n+  /* Self initialize, if necessary */\n+  if (counterLock == NULL) {\n+    _PR_CounterInitialize();\n+  }\n+\n+  /* Validate input arguments */\n+  PR_ASSERT(strlen(qName) <= PRCOUNTER_NAME_MAX);\n+  PR_ASSERT(strlen(rName) <= PRCOUNTER_NAME_MAX);\n+  PR_ASSERT(strlen(description) <= PRCOUNTER_DESC_MAX);\n+\n+  /* Lock the Facility */\n+  PR_Lock(counterLock);\n+\n+  /* Do we already have a matching QName? */\n+  if (!PR_CLIST_IS_EMPTY(&qNameList)) {\n+    qnp = (QName*)PR_LIST_HEAD(&qNameList);\n+    do {\n+      if (strcmp(qnp->name, qName) == 0) {\n+        matchQname = PR_TRUE;\n+        break;\n+      }\n+      qnp = (QName*)PR_NEXT_LINK(&qnp->link);\n+    } while (qnp != (QName*)&qNameList);\n+  }\n+  /*\n+  ** If we did not find a matching QName,\n+  **    allocate one and initialize it.\n+  **    link it onto the qNameList.\n+  **\n+  */\n+  if (matchQname != PR_TRUE) {\n+    qnp = PR_NEWZAP(QName);\n+    PR_ASSERT(qnp != NULL);\n+    PR_INIT_CLIST(&qnp->link);\n+    PR_INIT_CLIST(&qnp->rNameList);\n+    strcpy(qnp->name, qName);\n+    PR_APPEND_LINK(&qnp->link, &qNameList);\n+  }\n+\n+  /* Do we already have a matching RName? */\n+  if (!PR_CLIST_IS_EMPTY(&qnp->rNameList)) {\n+    rnp = (RName*)PR_LIST_HEAD(&qnp->rNameList);\n+    do {\n+      /*\n+      ** No duplicate RNames are allowed within a QName\n+      **\n+      */\n+      PR_ASSERT(strcmp(rnp->name, rName));\n+      rnp = (RName*)PR_NEXT_LINK(&rnp->link);\n+    } while (rnp != (RName*)&qnp->rNameList);\n+  }\n+\n+  /* Get a new RName structure; initialize its members */\n+  rnp = PR_NEWZAP(RName);\n+  PR_ASSERT(rnp != NULL);\n+  PR_INIT_CLIST(&rnp->link);\n+  strcpy(rnp->name, rName);\n+  strcpy(rnp->desc, description);\n+  rnp->lock = PR_NewLock();\n+  if (rnp->lock == NULL) {\n+    PR_ASSERT(0);\n+  }\n+\n+  PR_APPEND_LINK(&rnp->link, &qnp->rNameList); /* add RName to QName's rnList */\n+  rnp->qName = qnp; /* point the RName to the QName */\n+\n+  /* Unlock the Facility */\n+  PR_Unlock(counterLock);\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PR_Counter: Create: QName: %s %p, RName: %s %p\\n\\t\", qName, qnp,\n+          rName, rnp));\n+\n+  return ((PRCounterHandle)rnp);\n } /*  end PR_CreateCounter() */\n \n /*\n **\n */\n PR_IMPLEMENT(void)\n-PR_DestroyCounter(PRCounterHandle handle)\n-{\n-    RName* rnp = (RName*)handle;\n-    QName* qnp = rnp->qName;\n-\n+PR_DestroyCounter(PRCounterHandle handle) {\n+  RName* rnp = (RName*)handle;\n+  QName* qnp = rnp->qName;\n+\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PR_Counter: Deleting: QName: %s, RName: %s\", qnp->name, rnp->name));\n+\n+  /* Lock the Facility */\n+  PR_Lock(counterLock);\n+\n+  /*\n+  ** Remove RName from the list of RNames in QName\n+  ** and free RName\n+  */\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PR_Counter: Deleting RName: %s, %p\", rnp->name, rnp));\n+  PR_REMOVE_LINK(&rnp->link);\n+  PR_Free(rnp->lock);\n+  PR_DELETE(rnp);\n+\n+  /*\n+  ** If this is the last RName within QName\n+  **   remove QName from the qNameList and free it\n+  */\n+  if (PR_CLIST_IS_EMPTY(&qnp->rNameList)) {\n     PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PR_Counter: Deleting: QName: %s, RName: %s\", qnp->name, rnp->name));\n-\n-    /* Lock the Facility */\n-    PR_Lock(counterLock);\n-\n-    /*\n-    ** Remove RName from the list of RNames in QName\n-    ** and free RName\n-    */\n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PR_Counter: Deleting RName: %s, %p\", rnp->name, rnp));\n-    PR_REMOVE_LINK(&rnp->link);\n-    PR_Free(rnp->lock);\n-    PR_DELETE(rnp);\n-\n-    /*\n-    ** If this is the last RName within QName\n-    **   remove QName from the qNameList and free it\n-    */\n-    if (PR_CLIST_IS_EMPTY(&qnp->rNameList)) {\n-        PR_LOG(lm, PR_LOG_DEBUG,\n-               (\"PR_Counter: Deleting unused QName: %s, %p\", qnp->name, qnp));\n-        PR_REMOVE_LINK(&qnp->link);\n-        PR_DELETE(qnp);\n-    }\n-\n-    /* Unlock the Facility */\n-    PR_Unlock(counterLock);\n-    return;\n+           (\"PR_Counter: Deleting unused QName: %s, %p\", qnp->name, qnp));\n+    PR_REMOVE_LINK(&qnp->link);\n+    PR_DELETE(qnp);\n+  }\n+\n+  /* Unlock the Facility */\n+  PR_Unlock(counterLock);\n+  return;\n } /*  end PR_DestroyCounter() */\n \n /*\n **\n */\n PR_IMPLEMENT(PRCounterHandle)\n-PR_GetCounterHandleFromName(const char* qName, const char* rName)\n-{\n-    const char *qn, *rn, *desc;\n-    PRCounterHandle qh, rh = NULL;\n-    RName* rnp = NULL;\n-\n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PR_Counter: GetCounterHandleFromName:\\n\\t\"\n-            \"QName: %s, RName: %s\",\n-            qName, rName));\n-\n-    qh = PR_FindNextCounterQname(NULL);\n-    while (qh != NULL) {\n-        rh = PR_FindNextCounterRname(NULL, qh);\n-        while (rh != NULL) {\n-            PR_GetCounterNameFromHandle(rh, &qn, &rn, &desc);\n-            if ((strcmp(qName, qn) == 0) && (strcmp(rName, rn) == 0)) {\n-                rnp = (RName*)rh;\n-                goto foundIt;\n-            }\n-            rh = PR_FindNextCounterRname(rh, qh);\n-        }\n-        qh = PR_FindNextCounterQname(NULL);\n+PR_GetCounterHandleFromName(const char* qName, const char* rName) {\n+  const char *qn, *rn, *desc;\n+  PRCounterHandle qh, rh = NULL;\n+  RName* rnp = NULL;\n+\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PR_Counter: GetCounterHandleFromName:\\n\\t\"\n+          \"QName: %s, RName: %s\",\n+          qName, rName));\n+\n+  qh = PR_FindNextCounterQname(NULL);\n+  while (qh != NULL) {\n+    rh = PR_FindNextCounterRname(NULL, qh);\n+    while (rh != NULL) {\n+      PR_GetCounterNameFromHandle(rh, &qn, &rn, &desc);\n+      if ((strcmp(qName, qn) == 0) && (strcmp(rName, rn) == 0)) {\n+        rnp = (RName*)rh;\n+        goto foundIt;\n+      }\n+      rh = PR_FindNextCounterRname(rh, qh);\n     }\n+    qh = PR_FindNextCounterQname(NULL);\n+  }\n \n foundIt:\n-    PR_LOG(lm, PR_LOG_DEBUG, (\"PR_Counter: GetConterHandleFromName: %p\", rnp));\n-    return (rh);\n+  PR_LOG(lm, PR_LOG_DEBUG, (\"PR_Counter: GetConterHandleFromName: %p\", rnp));\n+  return (rh);\n } /*  end PR_GetCounterHandleFromName() */\n \n /*\n@@ -271,163 +267,154 @@ foundIt:\n */\n PR_IMPLEMENT(void)\n PR_GetCounterNameFromHandle(PRCounterHandle handle, const char** qName,\n-                            const char** rName, const char** description)\n-{\n-    RName* rnp = (RName*)handle;\n-    QName* qnp = rnp->qName;\n+                            const char** rName, const char** description) {\n+  RName* rnp = (RName*)handle;\n+  QName* qnp = rnp->qName;\n \n-    *qName = qnp->name;\n-    *rName = rnp->name;\n-    *description = rnp->desc;\n+  *qName = qnp->name;\n+  *rName = rnp->name;\n+  *description = rnp->desc;\n \n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PR_Counter: GetConterNameFromHandle: \"\n-            \"QNp: %p, RNp: %p,\\n\\tQName: %s, RName: %s, Desc: %s\",\n-            qnp, rnp, qnp->name, rnp->name, rnp->desc));\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PR_Counter: GetConterNameFromHandle: \"\n+          \"QNp: %p, RNp: %p,\\n\\tQName: %s, RName: %s, Desc: %s\",\n+          qnp, rnp, qnp->name, rnp->name, rnp->desc));\n \n-    return;\n+  return;\n } /*  end PR_GetCounterNameFromHandle() */\n \n /*\n **\n */\n PR_IMPLEMENT(void)\n-PR_IncrementCounter(PRCounterHandle handle)\n-{\n-    PR_Lock(((RName*)handle)->lock);\n-    ((RName*)handle)->counter++;\n-    PR_Unlock(((RName*)handle)->lock);\n+PR_IncrementCounter(PRCounterHandle handle) {\n+  PR_Lock(((RName*)handle)->lock);\n+  ((RName*)handle)->counter++;\n+  PR_Unlock(((RName*)handle)->lock);\n \n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PR_Counter: Increment: %p, %ld\", handle, ((RName*)handle)->counter));\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PR_Counter: Increment: %p, %ld\", handle, ((RName*)handle)->counter));\n \n-    return;\n+  return;\n } /*  end PR_IncrementCounter() */\n \n /*\n **\n */\n PR_IMPLEMENT(void)\n-PR_DecrementCounter(PRCounterHandle handle)\n-{\n-    PR_Lock(((RName*)handle)->lock);\n-    ((RName*)handle)->counter--;\n-    PR_Unlock(((RName*)handle)->lock);\n+PR_DecrementCounter(PRCounterHandle handle) {\n+  PR_Lock(((RName*)handle)->lock);\n+  ((RName*)handle)->counter--;\n+  PR_Unlock(((RName*)handle)->lock);\n \n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PR_Counter: Decrement: %p, %ld\", handle, ((RName*)handle)->counter));\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PR_Counter: Decrement: %p, %ld\", handle, ((RName*)handle)->counter));\n \n-    return;\n+  return;\n } /*  end PR_DecrementCounter()  */\n \n /*\n **\n */\n PR_IMPLEMENT(void)\n-PR_AddToCounter(PRCounterHandle handle, PRUint32 value)\n-{\n-    PR_Lock(((RName*)handle)->lock);\n-    ((RName*)handle)->counter += value;\n-    PR_Unlock(((RName*)handle)->lock);\n+PR_AddToCounter(PRCounterHandle handle, PRUint32 value) {\n+  PR_Lock(((RName*)handle)->lock);\n+  ((RName*)handle)->counter += value;\n+  PR_Unlock(((RName*)handle)->lock);\n \n-    PR_LOG(\n-        lm, PR_LOG_DEBUG,\n-        (\"PR_Counter: AddToCounter: %p, %ld\", handle, ((RName*)handle)->counter));\n+  PR_LOG(\n+      lm, PR_LOG_DEBUG,\n+      (\"PR_Counter: AddToCounter: %p, %ld\", handle, ((RName*)handle)->counter));\n \n-    return;\n+  return;\n } /*  end PR_AddToCounter() */\n \n /*\n **\n */\n PR_IMPLEMENT(void)\n-PR_SubtractFromCounter(PRCounterHandle handle, PRUint32 value)\n-{\n-    PR_Lock(((RName*)handle)->lock);\n-    ((RName*)handle)->counter -= value;\n-    PR_Unlock(((RName*)handle)->lock);\n+PR_SubtractFromCounter(PRCounterHandle handle, PRUint32 value) {\n+  PR_Lock(((RName*)handle)->lock);\n+  ((RName*)handle)->counter -= value;\n+  PR_Unlock(((RName*)handle)->lock);\n \n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PR_Counter: SubtractFromCounter: %p, %ld\", handle,\n-            ((RName*)handle)->counter));\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PR_Counter: SubtractFromCounter: %p, %ld\", handle,\n+          ((RName*)handle)->counter));\n \n-    return;\n+  return;\n } /*  end  PR_SubtractFromCounter() */\n \n /*\n **\n */\n PR_IMPLEMENT(PRUint32)\n-PR_GetCounter(PRCounterHandle handle)\n-{\n-    PR_LOG(\n-        lm, PR_LOG_DEBUG,\n-        (\"PR_Counter: GetCounter: %p, %ld\", handle, ((RName*)handle)->counter));\n+PR_GetCounter(PRCounterHandle handle) {\n+  PR_LOG(\n+      lm, PR_LOG_DEBUG,\n+      (\"PR_Counter: GetCounter: %p, %ld\", handle, ((RName*)handle)->counter));\n \n-    return (((RName*)handle)->counter);\n+  return (((RName*)handle)->counter);\n } /*  end  PR_GetCounter() */\n \n /*\n **\n */\n PR_IMPLEMENT(void)\n-PR_SetCounter(PRCounterHandle handle, PRUint32 value)\n-{\n-    ((RName*)handle)->counter = value;\n+PR_SetCounter(PRCounterHandle handle, PRUint32 value) {\n+  ((RName*)handle)->counter = value;\n \n-    PR_LOG(\n-        lm, PR_LOG_DEBUG,\n-        (\"PR_Counter: SetCounter: %p, %ld\", handle, ((RName*)handle)->counter));\n+  PR_LOG(\n+      lm, PR_LOG_DEBUG,\n+      (\"PR_Counter: SetCounter: %p, %ld\", handle, ((RName*)handle)->counter));\n \n-    return;\n+  return;\n } /*  end  PR_SetCounter() */\n \n /*\n **\n */\n PR_IMPLEMENT(PRCounterHandle)\n-PR_FindNextCounterQname(PRCounterHandle handle)\n-{\n-    QName* qnp = (QName*)handle;\n-\n-    if (PR_CLIST_IS_EMPTY(&qNameList)) {\n-        qnp = NULL;\n-    } else if (qnp == NULL) {\n-        qnp = (QName*)PR_LIST_HEAD(&qNameList);\n-    } else if (PR_NEXT_LINK(&qnp->link) == &qNameList) {\n-        qnp = NULL;\n-    } else {\n-        qnp = (QName*)PR_NEXT_LINK(&qnp->link);\n-    }\n-\n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PR_Counter: FindNextQname: Handle: %p, Returns: %p\", handle, qnp));\n-\n-    return ((PRCounterHandle)qnp);\n+PR_FindNextCounterQname(PRCounterHandle handle) {\n+  QName* qnp = (QName*)handle;\n+\n+  if (PR_CLIST_IS_EMPTY(&qNameList)) {\n+    qnp = NULL;\n+  } else if (qnp == NULL) {\n+    qnp = (QName*)PR_LIST_HEAD(&qNameList);\n+  } else if (PR_NEXT_LINK(&qnp->link) == &qNameList) {\n+    qnp = NULL;\n+  } else {\n+    qnp = (QName*)PR_NEXT_LINK(&qnp->link);\n+  }\n+\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PR_Counter: FindNextQname: Handle: %p, Returns: %p\", handle, qnp));\n+\n+  return ((PRCounterHandle)qnp);\n } /*  end  PR_FindNextCounterQname() */\n \n /*\n **\n */\n PR_IMPLEMENT(PRCounterHandle)\n-PR_FindNextCounterRname(PRCounterHandle rhandle, PRCounterHandle qhandle)\n-{\n-    RName* rnp = (RName*)rhandle;\n-    QName* qnp = (QName*)qhandle;\n-\n-    if (PR_CLIST_IS_EMPTY(&qnp->rNameList)) {\n-        rnp = NULL;\n-    } else if (rnp == NULL) {\n-        rnp = (RName*)PR_LIST_HEAD(&qnp->rNameList);\n-    } else if (PR_NEXT_LINK(&rnp->link) == &qnp->rNameList) {\n-        rnp = NULL;\n-    } else {\n-        rnp = (RName*)PR_NEXT_LINK(&rnp->link);\n-    }\n-\n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PR_Counter: FindNextRname: Rhandle: %p, QHandle: %p, Returns: %p\",\n-            rhandle, qhandle, rnp));\n-\n-    return ((PRCounterHandle)rnp);\n+PR_FindNextCounterRname(PRCounterHandle rhandle, PRCounterHandle qhandle) {\n+  RName* rnp = (RName*)rhandle;\n+  QName* qnp = (QName*)qhandle;\n+\n+  if (PR_CLIST_IS_EMPTY(&qnp->rNameList)) {\n+    rnp = NULL;\n+  } else if (rnp == NULL) {\n+    rnp = (RName*)PR_LIST_HEAD(&qnp->rNameList);\n+  } else if (PR_NEXT_LINK(&rnp->link) == &qnp->rNameList) {\n+    rnp = NULL;\n+  } else {\n+    rnp = (RName*)PR_NEXT_LINK(&rnp->link);\n+  }\n+\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PR_Counter: FindNextRname: Rhandle: %p, QHandle: %p, Returns: %p\",\n+          rhandle, qhandle, rnp));\n+\n+  return ((PRCounterHandle)rnp);\n } /*  end PR_FindNextCounterRname() */\ndiff --git a/nspr/pr/src/misc/prdtoa.c b/nspr/pr/src/misc/prdtoa.c\nindex 7c03790..b356325 100644\n--- a/nspr/pr/src/misc/prdtoa.c\n+++ b/nspr/pr/src/misc/prdtoa.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,7 +10,7 @@\n  * GCC, so we suppress these warnings.\n  */\n #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)\n-#pragma GCC diagnostic ignored \"-Wparentheses\"\n+#  pragma GCC diagnostic ignored \"-Wparentheses\"\n #endif\n \n #include \"primpl.h\"\n@@ -21,31 +22,27 @@\n \n static PRLock* dtoa_lock[2];\n \n-void\n-_PR_InitDtoa(void)\n-{\n-    dtoa_lock[0] = PR_NewLock();\n-    dtoa_lock[1] = PR_NewLock();\n+void _PR_InitDtoa(void) {\n+  dtoa_lock[0] = PR_NewLock();\n+  dtoa_lock[1] = PR_NewLock();\n }\n \n-void\n-_PR_CleanupDtoa(void)\n-{\n-    PR_DestroyLock(dtoa_lock[0]);\n-    dtoa_lock[0] = NULL;\n-    PR_DestroyLock(dtoa_lock[1]);\n-    dtoa_lock[1] = NULL;\n+void _PR_CleanupDtoa(void) {\n+  PR_DestroyLock(dtoa_lock[0]);\n+  dtoa_lock[0] = NULL;\n+  PR_DestroyLock(dtoa_lock[1]);\n+  dtoa_lock[1] = NULL;\n \n-    /* FIXME: deal with freelist and p5s. */\n+  /* FIXME: deal with freelist and p5s. */\n }\n \n #if !defined(__ARM_EABI__) && (defined(__arm) || defined(__arm__) || \\\n                                defined(__arm26__) || defined(__arm32__))\n-#define IEEE_ARM\n+#  define IEEE_ARM\n #elif defined(IS_LITTLE_ENDIAN)\n-#define IEEE_8087\n+#  define IEEE_8087\n #else\n-#define IEEE_MC68k\n+#  define IEEE_MC68k\n #endif\n \n #define Long PRInt32\n@@ -223,18 +220,18 @@ _PR_CleanupDtoa(void)\n  */\n \n #ifndef Long\n-#define Long long\n+#  define Long long\n #endif\n #ifndef ULong\n typedef unsigned Long ULong;\n #endif\n \n #ifdef DEBUG\n-#include \"stdio.h\"\n-#define Bug(x)                      \\\n-    {                               \\\n-        fprintf(stderr, \"%s\\n\", x); \\\n-        exit(1);                    \\\n+#  include \"stdio.h\"\n+#  define Bug(x)                  \\\n+    {                             \\\n+      fprintf(stderr, \"%s\\n\", x); \\\n+      exit(1);                    \\\n     }\n #endif\n \n@@ -242,76 +239,76 @@ typedef unsigned Long ULong;\n #include \"string.h\"\n \n #ifdef USE_LOCALE\n-#include \"locale.h\"\n+#  include \"locale.h\"\n #endif\n \n #ifdef MALLOC\n-#ifdef KR_headers\n+#  ifdef KR_headers\n extern char* MALLOC();\n-#else\n+#  else\n extern void* MALLOC(size_t);\n-#endif\n+#  endif\n #else\n-#define MALLOC malloc\n+#  define MALLOC malloc\n #endif\n \n #ifndef Omit_Private_Memory\n-#ifndef PRIVATE_MEM\n-#define PRIVATE_MEM 2304\n-#endif\n-#define PRIVATE_mem ((PRIVATE_MEM + sizeof(double) - 1) / sizeof(double))\n+#  ifndef PRIVATE_MEM\n+#    define PRIVATE_MEM 2304\n+#  endif\n+#  define PRIVATE_mem ((PRIVATE_MEM + sizeof(double) - 1) / sizeof(double))\n static double private_mem[PRIVATE_mem], *pmem_next = private_mem;\n #endif\n \n #undef IEEE_Arith\n #undef Avoid_Underflow\n #ifdef IEEE_MC68k\n-#define IEEE_Arith\n+#  define IEEE_Arith\n #endif\n #ifdef IEEE_8087\n-#define IEEE_Arith\n+#  define IEEE_Arith\n #endif\n #ifdef IEEE_ARM\n-#define IEEE_Arith\n+#  define IEEE_Arith\n #endif\n \n #include \"errno.h\"\n \n #ifdef Bad_float_h\n \n-#ifdef IEEE_Arith\n-#define DBL_DIG 15\n-#define DBL_MAX_10_EXP 308\n-#define DBL_MAX_EXP 1024\n-#define FLT_RADIX 2\n-#endif /*IEEE_Arith*/\n-\n-#ifdef IBM\n-#define DBL_DIG 16\n-#define DBL_MAX_10_EXP 75\n-#define DBL_MAX_EXP 63\n-#define FLT_RADIX 16\n-#define DBL_MAX 7.2370055773322621e+75\n-#endif\n-\n-#ifdef VAX\n-#define DBL_DIG 16\n-#define DBL_MAX_10_EXP 38\n-#define DBL_MAX_EXP 127\n-#define FLT_RADIX 2\n-#define DBL_MAX 1.7014118346046923e+38\n-#endif\n-\n-#ifndef LONG_MAX\n-#define LONG_MAX 2147483647\n-#endif\n+#  ifdef IEEE_Arith\n+#    define DBL_DIG 15\n+#    define DBL_MAX_10_EXP 308\n+#    define DBL_MAX_EXP 1024\n+#    define FLT_RADIX 2\n+#  endif /*IEEE_Arith*/\n+\n+#  ifdef IBM\n+#    define DBL_DIG 16\n+#    define DBL_MAX_10_EXP 75\n+#    define DBL_MAX_EXP 63\n+#    define FLT_RADIX 16\n+#    define DBL_MAX 7.2370055773322621e+75\n+#  endif\n+\n+#  ifdef VAX\n+#    define DBL_DIG 16\n+#    define DBL_MAX_10_EXP 38\n+#    define DBL_MAX_EXP 127\n+#    define FLT_RADIX 2\n+#    define DBL_MAX 1.7014118346046923e+38\n+#  endif\n+\n+#  ifndef LONG_MAX\n+#    define LONG_MAX 2147483647\n+#  endif\n \n #else /* ifndef Bad_float_h */\n-#include \"float.h\"\n+#  include \"float.h\"\n #endif /* Bad_float_h */\n \n #ifndef __MATH_H__\n-#include \"math.h\"\n+#  include \"math.h\"\n #endif\n \n #ifdef __cplusplus\n@@ -319,32 +316,31 @@ extern \"C\" {\n #endif\n \n #ifndef CONST\n-#ifdef KR_headers\n-#define CONST /* blank */\n-#else\n-#define CONST const\n-#endif\n+#  ifdef KR_headers\n+#    define CONST /* blank */\n+#  else\n+#    define CONST const\n+#  endif\n #endif\n \n #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(IEEE_ARM) + \\\n         defined(VAX) + defined(IBM) !=                             \\\n     1\n-Exactly one of IEEE_8087, IEEE_MC68k, IEEE_ARM, VAX,\n-    or IBM should be defined.\n+Exactly one of IEEE_8087, IEEE_MC68k, IEEE_ARM, VAX, or IBM should be defined.\n #endif\n \n-        typedef union {\n-    double d;\n-    ULong L[2];\n+                                                         typedef union {\n+  double d;\n+  ULong L[2];\n } U;\n \n #define dval(x) (x).d\n #ifdef IEEE_8087\n-#define word0(x) (x).L[1]\n-#define word1(x) (x).L[0]\n+#  define word0(x) (x).L[1]\n+#  define word1(x) (x).L[0]\n #else\n-#define word0(x) (x).L[0]\n-#define word1(x) (x).L[1]\n+#  define word0(x) (x).L[0]\n+#  define word1(x) (x).L[1]\n #endif\n \n /* The following definition of Storeinc is appropriate for MIPS processors.\n@@ -352,11 +348,11 @@ Exactly one of IEEE_8087, IEEE_MC68k, IEEE_ARM, VAX,\n  * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)\n  */\n #if defined(IEEE_8087) + defined(IEEE_ARM) + defined(VAX)\n-#define Storeinc(a, b, c)                         \\\n+#  define Storeinc(a, b, c)                       \\\n     (((unsigned short*)a)[1] = (unsigned short)b, \\\n      ((unsigned short*)a)[0] = (unsigned short)c, a++)\n #else\n-#define Storeinc(a, b, c)                         \\\n+#  define Storeinc(a, b, c)                       \\\n     (((unsigned short*)a)[0] = (unsigned short)b, \\\n      ((unsigned short*)a)[1] = (unsigned short)c, a++)\n #endif\n@@ -368,174 +364,174 @@ Exactly one of IEEE_8087, IEEE_MC68k, IEEE_ARM, VAX,\n /* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */\n \n #ifdef IEEE_Arith\n-#define Exp_shift 20\n-#define Exp_shift1 20\n-#define Exp_msk1 0x100000\n-#define Exp_msk11 0x100000\n-#define Exp_mask 0x7ff00000\n-#define P 53\n-#define Bias 1023\n-#define Emin (-1022)\n-#define Exp_1 0x3ff00000\n-#define Exp_11 0x3ff00000\n-#define Ebits 11\n-#define Frac_mask 0xfffff\n-#define Frac_mask1 0xfffff\n-#define Ten_pmax 22\n-#define Bletch 0x10\n-#define Bndry_mask 0xfffff\n-#define Bndry_mask1 0xfffff\n-#define LSB 1\n-#define Sign_bit 0x80000000\n-#define Log2P 1\n-#define Tiny0 0\n-#define Tiny1 1\n-#define Quick_max 14\n-#define Int_max 14\n-#ifndef NO_IEEE_Scale\n-#define Avoid_Underflow\n-#ifdef Flush_Denorm /* debugging option */\n-#undef Sudden_Underflow\n-#endif\n-#endif\n-\n-#ifndef Flt_Rounds\n-#ifdef FLT_ROUNDS\n-#define Flt_Rounds FLT_ROUNDS\n-#else\n-#define Flt_Rounds 1\n-#endif\n-#endif /*Flt_Rounds*/\n-\n-#ifdef Honor_FLT_ROUNDS\n-#define Rounding rounding\n-#undef Check_FLT_ROUNDS\n-#define Check_FLT_ROUNDS\n-#else\n-#define Rounding Flt_Rounds\n-#endif\n+#  define Exp_shift 20\n+#  define Exp_shift1 20\n+#  define Exp_msk1 0x100000\n+#  define Exp_msk11 0x100000\n+#  define Exp_mask 0x7ff00000\n+#  define P 53\n+#  define Bias 1023\n+#  define Emin (-1022)\n+#  define Exp_1 0x3ff00000\n+#  define Exp_11 0x3ff00000\n+#  define Ebits 11\n+#  define Frac_mask 0xfffff\n+#  define Frac_mask1 0xfffff\n+#  define Ten_pmax 22\n+#  define Bletch 0x10\n+#  define Bndry_mask 0xfffff\n+#  define Bndry_mask1 0xfffff\n+#  define LSB 1\n+#  define Sign_bit 0x80000000\n+#  define Log2P 1\n+#  define Tiny0 0\n+#  define Tiny1 1\n+#  define Quick_max 14\n+#  define Int_max 14\n+#  ifndef NO_IEEE_Scale\n+#    define Avoid_Underflow\n+#    ifdef Flush_Denorm /* debugging option */\n+#      undef Sudden_Underflow\n+#    endif\n+#  endif\n+\n+#  ifndef Flt_Rounds\n+#    ifdef FLT_ROUNDS\n+#      define Flt_Rounds FLT_ROUNDS\n+#    else\n+#      define Flt_Rounds 1\n+#    endif\n+#  endif /*Flt_Rounds*/\n+\n+#  ifdef Honor_FLT_ROUNDS\n+#    define Rounding rounding\n+#    undef Check_FLT_ROUNDS\n+#    define Check_FLT_ROUNDS\n+#  else\n+#    define Rounding Flt_Rounds\n+#  endif\n \n #else /* ifndef IEEE_Arith */\n-#undef Check_FLT_ROUNDS\n-#undef Honor_FLT_ROUNDS\n-#undef SET_INEXACT\n-#undef Sudden_Underflow\n-#define Sudden_Underflow\n-#ifdef IBM\n-#undef Flt_Rounds\n-#define Flt_Rounds 0\n-#define Exp_shift 24\n-#define Exp_shift1 24\n-#define Exp_msk1 0x1000000\n-#define Exp_msk11 0x1000000\n-#define Exp_mask 0x7f000000\n-#define P 14\n-#define Bias 65\n-#define Exp_1 0x41000000\n-#define Exp_11 0x41000000\n-#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */\n-#define Frac_mask 0xffffff\n-#define Frac_mask1 0xffffff\n-#define Bletch 4\n-#define Ten_pmax 22\n-#define Bndry_mask 0xefffff\n-#define Bndry_mask1 0xffffff\n-#define LSB 1\n-#define Sign_bit 0x80000000\n-#define Log2P 4\n-#define Tiny0 0x100000\n-#define Tiny1 0\n-#define Quick_max 14\n-#define Int_max 15\n-#else /* VAX */\n-#undef Flt_Rounds\n-#define Flt_Rounds 1\n-#define Exp_shift 23\n-#define Exp_shift1 7\n-#define Exp_msk1 0x80\n-#define Exp_msk11 0x800000\n-#define Exp_mask 0x7f80\n-#define P 56\n-#define Bias 129\n-#define Exp_1 0x40800000\n-#define Exp_11 0x4080\n-#define Ebits 8\n-#define Frac_mask 0x7fffff\n-#define Frac_mask1 0xffff007f\n-#define Ten_pmax 24\n-#define Bletch 2\n-#define Bndry_mask 0xffff007f\n-#define Bndry_mask1 0xffff007f\n-#define LSB 0x10000\n-#define Sign_bit 0x8000\n-#define Log2P 1\n-#define Tiny0 0x80\n-#define Tiny1 0\n-#define Quick_max 15\n-#define Int_max 15\n-#endif /* IBM, VAX */\n-#endif /* IEEE_Arith */\n+#  undef Check_FLT_ROUNDS\n+#  undef Honor_FLT_ROUNDS\n+#  undef SET_INEXACT\n+#  undef Sudden_Underflow\n+#  define Sudden_Underflow\n+#  ifdef IBM\n+#    undef Flt_Rounds\n+#    define Flt_Rounds 0\n+#    define Exp_shift 24\n+#    define Exp_shift1 24\n+#    define Exp_msk1 0x1000000\n+#    define Exp_msk11 0x1000000\n+#    define Exp_mask 0x7f000000\n+#    define P 14\n+#    define Bias 65\n+#    define Exp_1 0x41000000\n+#    define Exp_11 0x41000000\n+#    define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */\n+#    define Frac_mask 0xffffff\n+#    define Frac_mask1 0xffffff\n+#    define Bletch 4\n+#    define Ten_pmax 22\n+#    define Bndry_mask 0xefffff\n+#    define Bndry_mask1 0xffffff\n+#    define LSB 1\n+#    define Sign_bit 0x80000000\n+#    define Log2P 4\n+#    define Tiny0 0x100000\n+#    define Tiny1 0\n+#    define Quick_max 14\n+#    define Int_max 15\n+#  else /* VAX */\n+#    undef Flt_Rounds\n+#    define Flt_Rounds 1\n+#    define Exp_shift 23\n+#    define Exp_shift1 7\n+#    define Exp_msk1 0x80\n+#    define Exp_msk11 0x800000\n+#    define Exp_mask 0x7f80\n+#    define P 56\n+#    define Bias 129\n+#    define Exp_1 0x40800000\n+#    define Exp_11 0x4080\n+#    define Ebits 8\n+#    define Frac_mask 0x7fffff\n+#    define Frac_mask1 0xffff007f\n+#    define Ten_pmax 24\n+#    define Bletch 2\n+#    define Bndry_mask 0xffff007f\n+#    define Bndry_mask1 0xffff007f\n+#    define LSB 0x10000\n+#    define Sign_bit 0x8000\n+#    define Log2P 1\n+#    define Tiny0 0x80\n+#    define Tiny1 0\n+#    define Quick_max 15\n+#    define Int_max 15\n+#  endif /* IBM, VAX */\n+#endif   /* IEEE_Arith */\n \n #ifndef IEEE_Arith\n-#define ROUND_BIASED\n+#  define ROUND_BIASED\n #endif\n \n #ifdef RND_PRODQUOT\n-#define rounded_product(a, b) a = rnd_prod(a, b)\n-#define rounded_quotient(a, b) a = rnd_quot(a, b)\n-#ifdef KR_headers\n+#  define rounded_product(a, b) a = rnd_prod(a, b)\n+#  define rounded_quotient(a, b) a = rnd_quot(a, b)\n+#  ifdef KR_headers\n extern double rnd_prod(), rnd_quot();\n-#else\n+#  else\n extern double rnd_prod(double, double), rnd_quot(double, double);\n-#endif\n+#  endif\n #else\n-#define rounded_product(a, b) a *= b\n-#define rounded_quotient(a, b) a /= b\n+#  define rounded_product(a, b) a *= b\n+#  define rounded_quotient(a, b) a /= b\n #endif\n \n #define Big0 (Frac_mask1 | Exp_msk1 * (DBL_MAX_EXP + Bias - 1))\n #define Big1 0xffffffff\n \n #ifndef Pack_32\n-#define Pack_32\n+#  define Pack_32\n #endif\n \n #ifdef KR_headers\n-#define FFFFFFFF ((((unsigned long)0xffff) << 16) | (unsigned long)0xffff)\n+#  define FFFFFFFF ((((unsigned long)0xffff) << 16) | (unsigned long)0xffff)\n #else\n-#define FFFFFFFF 0xffffffffUL\n+#  define FFFFFFFF 0xffffffffUL\n #endif\n \n #ifdef NO_LONG_LONG\n-#undef ULLong\n-#ifdef Just_16\n-#undef Pack_32\n+#  undef ULLong\n+#  ifdef Just_16\n+#    undef Pack_32\n /* When Pack_32 is not defined, we store 16 bits per 32-bit Long.\n  * This makes some inner loops simpler and sometimes saves work\n  * during multiplications, but it often seems to make things slightly\n  * slower.  Hence the default is now to store 32 bits per Long.\n  */\n-#endif\n+#  endif\n #else /* long long available */\n-#ifndef Llong\n-#define Llong long long\n-#endif\n-#ifndef ULLong\n-#define ULLong unsigned Llong\n-#endif\n+#  ifndef Llong\n+#    define Llong long long\n+#  endif\n+#  ifndef ULLong\n+#    define ULLong unsigned Llong\n+#  endif\n #endif /* NO_LONG_LONG */\n \n #ifndef MULTIPLE_THREADS\n-#define ACQUIRE_DTOA_LOCK(n) /*nothing*/\n-#define FREE_DTOA_LOCK(n)    /*nothing*/\n+#  define ACQUIRE_DTOA_LOCK(n) /*nothing*/\n+#  define FREE_DTOA_LOCK(n)    /*nothing*/\n #endif\n \n #define Kmax 7\n \n struct Bigint {\n-    struct Bigint* next;\n-    int k, maxwds, sign, wds;\n-    ULong x[1];\n+  struct Bigint* next;\n+  int k, maxwds, sign, wds;\n+  ULong x[1];\n };\n \n typedef struct Bigint Bigint;\n@@ -549,37 +545,37 @@ static Bigint* Balloc\n     (int k)\n #endif\n {\n-    int x;\n-    Bigint* rv;\n+  int x;\n+  Bigint* rv;\n #ifndef Omit_Private_Memory\n-    unsigned int len;\n+  unsigned int len;\n #endif\n \n-    ACQUIRE_DTOA_LOCK(0);\n-    /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */\n-    /* but this case seems very unlikely. */\n-    if (k <= Kmax && (rv = freelist[k])) {\n-        freelist[k] = rv->next;\n-    } else {\n-        x = 1 << k;\n+  ACQUIRE_DTOA_LOCK(0);\n+  /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */\n+  /* but this case seems very unlikely. */\n+  if (k <= Kmax && (rv = freelist[k])) {\n+    freelist[k] = rv->next;\n+  } else {\n+    x = 1 << k;\n #ifdef Omit_Private_Memory\n-        rv = (Bigint*)MALLOC(sizeof(Bigint) + (x - 1) * sizeof(ULong));\n+    rv = (Bigint*)MALLOC(sizeof(Bigint) + (x - 1) * sizeof(ULong));\n #else\n-        len = (sizeof(Bigint) + (x - 1) * sizeof(ULong) + sizeof(double) - 1) /\n-              sizeof(double);\n-        if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) {\n-            rv = (Bigint*)pmem_next;\n-            pmem_next += len;\n-        } else {\n-            rv = (Bigint*)MALLOC(len * sizeof(double));\n-        }\n-#endif\n-        rv->k = k;\n-        rv->maxwds = x;\n+    len = (sizeof(Bigint) + (x - 1) * sizeof(ULong) + sizeof(double) - 1) /\n+          sizeof(double);\n+    if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) {\n+      rv = (Bigint*)pmem_next;\n+      pmem_next += len;\n+    } else {\n+      rv = (Bigint*)MALLOC(len * sizeof(double));\n     }\n-    FREE_DTOA_LOCK(0);\n-    rv->sign = rv->wds = 0;\n-    return rv;\n+#endif\n+    rv->k = k;\n+    rv->maxwds = x;\n+  }\n+  FREE_DTOA_LOCK(0);\n+  rv->sign = rv->wds = 0;\n+  return rv;\n }\n \n static void Bfree\n@@ -589,25 +585,25 @@ static void Bfree\n     (Bigint* v)\n #endif\n {\n-    if (v) {\n-        if (v->k > Kmax)\n+  if (v) {\n+    if (v->k > Kmax)\n #ifdef FREE\n-            FREE((void*)v);\n+      FREE((void*)v);\n #else\n-            free((void*)v);\n+      free((void*)v);\n #endif\n-        else {\n-            ACQUIRE_DTOA_LOCK(0);\n-            v->next = freelist[v->k];\n-            freelist[v->k] = v;\n-            FREE_DTOA_LOCK(0);\n-        }\n+    else {\n+      ACQUIRE_DTOA_LOCK(0);\n+      v->next = freelist[v->k];\n+      freelist[v->k] = v;\n+      FREE_DTOA_LOCK(0);\n     }\n+  }\n }\n \n-#define Bcopy(x, y)                          \\\n-    memcpy((char*)&x->sign, (char*)&y->sign, \\\n-           y->wds * sizeof(Long) + 2 * sizeof(int))\n+#define Bcopy(x, y)                        \\\n+  memcpy((char*)&x->sign, (char*)&y->sign, \\\n+         y->wds * sizeof(Long) + 2 * sizeof(int))\n \n static Bigint* multadd\n #ifdef KR_headers\n@@ -617,52 +613,52 @@ int m, a;\n     (Bigint* b, int m, int a) /* multiply by m and add a */\n #endif\n {\n-    int i, wds;\n+  int i, wds;\n #ifdef ULLong\n-    ULong* x;\n-    ULLong carry, y;\n+  ULong* x;\n+  ULLong carry, y;\n #else\n-    ULong carry, *x, y;\n-#ifdef Pack_32\n-    ULong xi, z;\n-#endif\n+  ULong carry, *x, y;\n+#  ifdef Pack_32\n+  ULong xi, z;\n+#  endif\n #endif\n-    Bigint* b1;\n+  Bigint* b1;\n \n-    wds = b->wds;\n-    x = b->x;\n-    i = 0;\n-    carry = a;\n-    do {\n+  wds = b->wds;\n+  x = b->x;\n+  i = 0;\n+  carry = a;\n+  do {\n #ifdef ULLong\n-        y = *x * (ULLong)m + carry;\n-        carry = y >> 32;\n-        *x++ = y & FFFFFFFF;\n-#else\n-#ifdef Pack_32\n-        xi = *x;\n-        y = (xi & 0xffff) * m + carry;\n-        z = (xi >> 16) * m + (y >> 16);\n-        carry = z >> 16;\n-        *x++ = (z << 16) + (y & 0xffff);\n-#else\n-        y = *x * m + carry;\n-        carry = y >> 16;\n-        *x++ = y & 0xffff;\n-#endif\n-#endif\n-    } while (++i < wds);\n-    if (carry) {\n-        if (wds >= b->maxwds) {\n-            b1 = Balloc(b->k + 1);\n-            Bcopy(b1, b);\n-            Bfree(b);\n-            b = b1;\n-        }\n-        b->x[wds++] = carry;\n-        b->wds = wds;\n-    }\n-    return b;\n+    y = *x * (ULLong)m + carry;\n+    carry = y >> 32;\n+    *x++ = y & FFFFFFFF;\n+#else\n+#  ifdef Pack_32\n+    xi = *x;\n+    y = (xi & 0xffff) * m + carry;\n+    z = (xi >> 16) * m + (y >> 16);\n+    carry = z >> 16;\n+    *x++ = (z << 16) + (y & 0xffff);\n+#  else\n+    y = *x * m + carry;\n+    carry = y >> 16;\n+    *x++ = y & 0xffff;\n+#  endif\n+#endif\n+  } while (++i < wds);\n+  if (carry) {\n+    if (wds >= b->maxwds) {\n+      b1 = Balloc(b->k + 1);\n+      Bcopy(b1, b);\n+      Bfree(b);\n+      b = b1;\n+    }\n+    b->x[wds++] = carry;\n+    b->wds = wds;\n+  }\n+  return b;\n }\n \n static Bigint* s2b\n@@ -674,37 +670,36 @@ ULong y9;\n     (CONST char* s, int nd0, int nd, ULong y9)\n #endif\n {\n-    Bigint* b;\n-    int i, k;\n-    Long x, y;\n+  Bigint* b;\n+  int i, k;\n+  Long x, y;\n \n-    x = (nd + 8) / 9;\n-    for (k = 0, y = 1; x > y; y <<= 1, k++)\n-        ;\n+  x = (nd + 8) / 9;\n+  for (k = 0, y = 1; x > y; y <<= 1, k++);\n #ifdef Pack_32\n-    b = Balloc(k);\n-    b->x[0] = y9;\n-    b->wds = 1;\n-#else\n-    b = Balloc(k + 1);\n-    b->x[0] = y9 & 0xffff;\n-    b->wds = (b->x[1] = y9 >> 16) ? 2 : 1;\n-#endif\n-\n-    i = 9;\n-    if (9 < nd0) {\n-        s += 9;\n-        do {\n-            b = multadd(b, 10, *s++ - '0');\n-        } while (++i < nd0);\n-        s++;\n-    } else {\n-        s += 10;\n-    }\n-    for (; i < nd; i++) {\n-        b = multadd(b, 10, *s++ - '0');\n-    }\n-    return b;\n+  b = Balloc(k);\n+  b->x[0] = y9;\n+  b->wds = 1;\n+#else\n+  b = Balloc(k + 1);\n+  b->x[0] = y9 & 0xffff;\n+  b->wds = (b->x[1] = y9 >> 16) ? 2 : 1;\n+#endif\n+\n+  i = 9;\n+  if (9 < nd0) {\n+    s += 9;\n+    do {\n+      b = multadd(b, 10, *s++ - '0');\n+    } while (++i < nd0);\n+    s++;\n+  } else {\n+    s += 10;\n+  }\n+  for (; i < nd; i++) {\n+    b = multadd(b, 10, *s++ - '0');\n+  }\n+  return b;\n }\n \n static int hi0bits\n@@ -715,33 +710,33 @@ static int hi0bits\n #endif\n {\n #ifdef PR_HAVE_BUILTIN_BITSCAN32\n-    return ((!x) ? 32 : pr_bitscan_clz32(x));\n-#else\n-    register int k = 0;\n-\n-    if (!(x & 0xffff0000)) {\n-        k = 16;\n-        x <<= 16;\n-    }\n-    if (!(x & 0xff000000)) {\n-        k += 8;\n-        x <<= 8;\n-    }\n-    if (!(x & 0xf0000000)) {\n-        k += 4;\n-        x <<= 4;\n-    }\n-    if (!(x & 0xc0000000)) {\n-        k += 2;\n-        x <<= 2;\n-    }\n-    if (!(x & 0x80000000)) {\n-        k++;\n-        if (!(x & 0x40000000)) {\n-            return 32;\n-        }\n+  return ((!x) ? 32 : pr_bitscan_clz32(x));\n+#else\n+  register int k = 0;\n+\n+  if (!(x & 0xffff0000)) {\n+    k = 16;\n+    x <<= 16;\n+  }\n+  if (!(x & 0xff000000)) {\n+    k += 8;\n+    x <<= 8;\n+  }\n+  if (!(x & 0xf0000000)) {\n+    k += 4;\n+    x <<= 4;\n+  }\n+  if (!(x & 0xc0000000)) {\n+    k += 2;\n+    x <<= 2;\n+  }\n+  if (!(x & 0x80000000)) {\n+    k++;\n+    if (!(x & 0x40000000)) {\n+      return 32;\n     }\n-    return k;\n+  }\n+  return k;\n #endif /* PR_HAVE_BUILTIN_BITSCAN32 */\n }\n \n@@ -753,56 +748,56 @@ static int lo0bits\n #endif\n {\n #ifdef PR_HAVE_BUILTIN_BITSCAN32\n-    int k;\n-    ULong x = *y;\n-\n-    if (x > 1) {\n-        *y = (x >> (k = pr_bitscan_ctz32(x)));\n-    } else {\n-        k = ((x ^ 1) << 5);\n-    }\n-#else\n-    register int k;\n-    register ULong x = *y;\n-\n-    if (x & 7) {\n-        if (x & 1) {\n-            return 0;\n-        }\n-        if (x & 2) {\n-            *y = x >> 1;\n-            return 1;\n-        }\n-        *y = x >> 2;\n-        return 2;\n-    }\n-    k = 0;\n-    if (!(x & 0xffff)) {\n-        k = 16;\n-        x >>= 16;\n-    }\n-    if (!(x & 0xff)) {\n-        k += 8;\n-        x >>= 8;\n-    }\n-    if (!(x & 0xf)) {\n-        k += 4;\n-        x >>= 4;\n-    }\n-    if (!(x & 0x3)) {\n-        k += 2;\n-        x >>= 2;\n-    }\n-    if (!(x & 1)) {\n-        k++;\n-        x >>= 1;\n-        if (!x) {\n-            return 32;\n-        }\n+  int k;\n+  ULong x = *y;\n+\n+  if (x > 1) {\n+    *y = (x >> (k = pr_bitscan_ctz32(x)));\n+  } else {\n+    k = ((x ^ 1) << 5);\n+  }\n+#else\n+  register int k;\n+  register ULong x = *y;\n+\n+  if (x & 7) {\n+    if (x & 1) {\n+      return 0;\n+    }\n+    if (x & 2) {\n+      *y = x >> 1;\n+      return 1;\n+    }\n+    *y = x >> 2;\n+    return 2;\n+  }\n+  k = 0;\n+  if (!(x & 0xffff)) {\n+    k = 16;\n+    x >>= 16;\n+  }\n+  if (!(x & 0xff)) {\n+    k += 8;\n+    x >>= 8;\n+  }\n+  if (!(x & 0xf)) {\n+    k += 4;\n+    x >>= 4;\n+  }\n+  if (!(x & 0x3)) {\n+    k += 2;\n+    x >>= 2;\n+  }\n+  if (!(x & 1)) {\n+    k++;\n+    x >>= 1;\n+    if (!x) {\n+      return 32;\n     }\n-    *y = x;\n+  }\n+  *y = x;\n #endif /* PR_HAVE_BUILTIN_BITSCAN32 */\n-    return k;\n+  return k;\n }\n \n static Bigint* i2b\n@@ -812,12 +807,12 @@ static Bigint* i2b\n     (int i)\n #endif\n {\n-    Bigint* b;\n+  Bigint* b;\n \n-    b = Balloc(1);\n-    b->x[0] = i;\n-    b->wds = 1;\n-    return b;\n+  b = Balloc(1);\n+  b->x[0] = i;\n+  b->wds = 1;\n+  return b;\n }\n \n static Bigint *mult\n@@ -828,105 +823,104 @@ static Bigint *mult\n     (Bigint* a, Bigint* b)\n #endif\n {\n-    Bigint* c;\n-    int k, wa, wb, wc;\n-    ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;\n-    ULong y;\n+  Bigint* c;\n+  int k, wa, wb, wc;\n+  ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;\n+  ULong y;\n #ifdef ULLong\n-    ULLong carry, z;\n-#else\n-    ULong carry, z;\n-#ifdef Pack_32\n-    ULong z2;\n-#endif\n-#endif\n-\n-    if (a->wds < b->wds) {\n-        c = a;\n-        a = b;\n-        b = c;\n-    }\n-    k = a->k;\n-    wa = a->wds;\n-    wb = b->wds;\n-    wc = wa + wb;\n-    if (wc > a->maxwds) {\n-        k++;\n-    }\n-    c = Balloc(k);\n-    for (x = c->x, xa = x + wc; x < xa; x++) {\n-        *x = 0;\n-    }\n-    xa = a->x;\n-    xae = xa + wa;\n-    xb = b->x;\n-    xbe = xb + wb;\n-    xc0 = c->x;\n+  ULLong carry, z;\n+#else\n+  ULong carry, z;\n+#  ifdef Pack_32\n+  ULong z2;\n+#  endif\n+#endif\n+\n+  if (a->wds < b->wds) {\n+    c = a;\n+    a = b;\n+    b = c;\n+  }\n+  k = a->k;\n+  wa = a->wds;\n+  wb = b->wds;\n+  wc = wa + wb;\n+  if (wc > a->maxwds) {\n+    k++;\n+  }\n+  c = Balloc(k);\n+  for (x = c->x, xa = x + wc; x < xa; x++) {\n+    *x = 0;\n+  }\n+  xa = a->x;\n+  xae = xa + wa;\n+  xb = b->x;\n+  xbe = xb + wb;\n+  xc0 = c->x;\n #ifdef ULLong\n-    for (; xb < xbe; xc0++) {\n-        if (y = *xb++) {\n-            x = xa;\n-            xc = xc0;\n-            carry = 0;\n-            do {\n-                z = *x++ * (ULLong)y + *xc + carry;\n-                carry = z >> 32;\n-                *xc++ = z & FFFFFFFF;\n-            } while (x < xae);\n-            *xc = carry;\n-        }\n-    }\n-#else\n-#ifdef Pack_32\n-    for (; xb < xbe; xb++, xc0++) {\n-        if (y = *xb & 0xffff) {\n-            x = xa;\n-            xc = xc0;\n-            carry = 0;\n-            do {\n-                z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;\n-                carry = z >> 16;\n-                z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;\n-                carry = z2 >> 16;\n-                Storeinc(xc, z2, z);\n-            } while (x < xae);\n-            *xc = carry;\n-        }\n-        if (y = *xb >> 16) {\n-            x = xa;\n-            xc = xc0;\n-            carry = 0;\n-            z2 = *xc;\n-            do {\n-                z = (*x & 0xffff) * y + (*xc >> 16) + carry;\n-                carry = z >> 16;\n-                Storeinc(xc, z, z2);\n-                z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;\n-                carry = z2 >> 16;\n-            } while (x < xae);\n-            *xc = z2;\n-        }\n-    }\n-#else\n-    for (; xb < xbe; xc0++) {\n-        if (y = *xb++) {\n-            x = xa;\n-            xc = xc0;\n-            carry = 0;\n-            do {\n-                z = *x++ * y + *xc + carry;\n-                carry = z >> 16;\n-                *xc++ = z & 0xffff;\n-            } while (x < xae);\n-            *xc = carry;\n-        }\n+  for (; xb < xbe; xc0++) {\n+    if (y = *xb++) {\n+      x = xa;\n+      xc = xc0;\n+      carry = 0;\n+      do {\n+        z = *x++ * (ULLong)y + *xc + carry;\n+        carry = z >> 32;\n+        *xc++ = z & FFFFFFFF;\n+      } while (x < xae);\n+      *xc = carry;\n+    }\n+  }\n+#else\n+#  ifdef Pack_32\n+  for (; xb < xbe; xb++, xc0++) {\n+    if (y = *xb & 0xffff) {\n+      x = xa;\n+      xc = xc0;\n+      carry = 0;\n+      do {\n+        z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;\n+        carry = z >> 16;\n+        z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;\n+        carry = z2 >> 16;\n+        Storeinc(xc, z2, z);\n+      } while (x < xae);\n+      *xc = carry;\n+    }\n+    if (y = *xb >> 16) {\n+      x = xa;\n+      xc = xc0;\n+      carry = 0;\n+      z2 = *xc;\n+      do {\n+        z = (*x & 0xffff) * y + (*xc >> 16) + carry;\n+        carry = z >> 16;\n+        Storeinc(xc, z, z2);\n+        z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;\n+        carry = z2 >> 16;\n+      } while (x < xae);\n+      *xc = z2;\n+    }\n+  }\n+#  else\n+  for (; xb < xbe; xc0++) {\n+    if (y = *xb++) {\n+      x = xa;\n+      xc = xc0;\n+      carry = 0;\n+      do {\n+        z = *x++ * y + *xc + carry;\n+        carry = z >> 16;\n+        *xc++ = z & 0xffff;\n+      } while (x < xae);\n+      *xc = carry;\n     }\n+  }\n+#  endif\n #endif\n-#endif\n-    for (xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc)\n-        ;\n-    c->wds = wc;\n-    return c;\n+  for (xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc);\n+  c->wds = wc;\n+  return c;\n }\n \n static Bigint* p5s;\n@@ -939,56 +933,56 @@ int k;\n     (Bigint* b, int k)\n #endif\n {\n-    Bigint *b1, *p5, *p51;\n-    int i;\n-    static int p05[3] = { 5, 25, 125 };\n+  Bigint *b1, *p5, *p51;\n+  int i;\n+  static int p05[3] = {5, 25, 125};\n \n-    if (i = k & 3) {\n-        b = multadd(b, p05[i - 1], 0);\n-    }\n+  if (i = k & 3) {\n+    b = multadd(b, p05[i - 1], 0);\n+  }\n \n-    if (!(k >>= 2)) {\n-        return b;\n-    }\n-    if (!(p5 = p5s)) {\n-        /* first time */\n+  if (!(k >>= 2)) {\n+    return b;\n+  }\n+  if (!(p5 = p5s)) {\n+    /* first time */\n #ifdef MULTIPLE_THREADS\n-        ACQUIRE_DTOA_LOCK(1);\n-        if (!(p5 = p5s)) {\n-            p5 = p5s = i2b(625);\n-            p5->next = 0;\n-        }\n-        FREE_DTOA_LOCK(1);\n+    ACQUIRE_DTOA_LOCK(1);\n+    if (!(p5 = p5s)) {\n+      p5 = p5s = i2b(625);\n+      p5->next = 0;\n+    }\n+    FREE_DTOA_LOCK(1);\n #else\n-        p5 = p5s = i2b(625);\n-        p5->next = 0;\n+    p5 = p5s = i2b(625);\n+    p5->next = 0;\n #endif\n+  }\n+  for (;;) {\n+    if (k & 1) {\n+      b1 = mult(b, p5);\n+      Bfree(b);\n+      b = b1;\n     }\n-    for (;;) {\n-        if (k & 1) {\n-            b1 = mult(b, p5);\n-            Bfree(b);\n-            b = b1;\n-        }\n-        if (!(k >>= 1)) {\n-            break;\n-        }\n-        if (!(p51 = p5->next)) {\n+    if (!(k >>= 1)) {\n+      break;\n+    }\n+    if (!(p51 = p5->next)) {\n #ifdef MULTIPLE_THREADS\n-            ACQUIRE_DTOA_LOCK(1);\n-            if (!(p51 = p5->next)) {\n-                p51 = p5->next = mult(p5, p5);\n-                p51->next = 0;\n-            }\n-            FREE_DTOA_LOCK(1);\n+      ACQUIRE_DTOA_LOCK(1);\n+      if (!(p51 = p5->next)) {\n+        p51 = p5->next = mult(p5, p5);\n+        p51->next = 0;\n+      }\n+      FREE_DTOA_LOCK(1);\n #else\n-            p51 = p5->next = mult(p5, p5);\n-            p51->next = 0;\n+      p51 = p5->next = mult(p5, p5);\n+      p51->next = 0;\n #endif\n-        }\n-        p5 = p51;\n     }\n-    return b;\n+    p5 = p51;\n+  }\n+  return b;\n }\n \n static Bigint* lshift\n@@ -999,59 +993,59 @@ int k;\n     (Bigint* b, int k)\n #endif\n {\n-    int i, k1, n, n1;\n-    Bigint* b1;\n-    ULong *x, *x1, *xe, z;\n+  int i, k1, n, n1;\n+  Bigint* b1;\n+  ULong *x, *x1, *xe, z;\n \n #ifdef Pack_32\n-    n = k >> 5;\n-#else\n-    n = k >> 4;\n-#endif\n-    k1 = b->k;\n-    n1 = n + b->wds + 1;\n-    for (i = b->maxwds; n1 > i; i <<= 1) {\n-        k1++;\n-    }\n-    b1 = Balloc(k1);\n-    x1 = b1->x;\n-    for (i = 0; i < n; i++) {\n-        *x1++ = 0;\n-    }\n-    x = b->x;\n-    xe = x + b->wds;\n+  n = k >> 5;\n+#else\n+  n = k >> 4;\n+#endif\n+  k1 = b->k;\n+  n1 = n + b->wds + 1;\n+  for (i = b->maxwds; n1 > i; i <<= 1) {\n+    k1++;\n+  }\n+  b1 = Balloc(k1);\n+  x1 = b1->x;\n+  for (i = 0; i < n; i++) {\n+    *x1++ = 0;\n+  }\n+  x = b->x;\n+  xe = x + b->wds;\n #ifdef Pack_32\n-    if (k &= 0x1f) {\n-        k1 = 32 - k;\n-        z = 0;\n-        do {\n-            *x1++ = *x << k | z;\n-            z = *x++ >> k1;\n-        } while (x < xe);\n-        if (*x1 = z) {\n-            ++n1;\n-        }\n+  if (k &= 0x1f) {\n+    k1 = 32 - k;\n+    z = 0;\n+    do {\n+      *x1++ = *x << k | z;\n+      z = *x++ >> k1;\n+    } while (x < xe);\n+    if (*x1 = z) {\n+      ++n1;\n     }\n+  }\n #else\n-    if (k &= 0xf) {\n-        k1 = 16 - k;\n-        z = 0;\n-        do {\n-            *x1++ = *x << k & 0xffff | z;\n-            z = *x++ >> k1;\n-        } while (x < xe);\n-        if (*x1 = z) {\n-            ++n1;\n-        }\n+  if (k &= 0xf) {\n+    k1 = 16 - k;\n+    z = 0;\n+    do {\n+      *x1++ = *x << k & 0xffff | z;\n+      z = *x++ >> k1;\n+    } while (x < xe);\n+    if (*x1 = z) {\n+      ++n1;\n     }\n+  }\n #endif\n-    else\n-        do {\n-            *x1++ = *x++;\n-        } while (x < xe);\n-    b1->wds = n1 - 1;\n-    Bfree(b);\n-    return b1;\n+  else\n+    do {\n+      *x1++ = *x++;\n+    } while (x < xe);\n+  b1->wds = n1 - 1;\n+  Bfree(b);\n+  return b1;\n }\n \n static int cmp\n@@ -1062,35 +1056,35 @@ static int cmp\n     (Bigint* a, Bigint* b)\n #endif\n {\n-    ULong *xa, *xa0, *xb, *xb0;\n-    int i, j;\n+  ULong *xa, *xa0, *xb, *xb0;\n+  int i, j;\n \n-    i = a->wds;\n-    j = b->wds;\n+  i = a->wds;\n+  j = b->wds;\n #ifdef DEBUG\n-    if (i > 1 && !a->x[i - 1]) {\n-        Bug(\"cmp called with a->x[a->wds-1] == 0\");\n-    }\n-    if (j > 1 && !b->x[j - 1]) {\n-        Bug(\"cmp called with b->x[b->wds-1] == 0\");\n-    }\n-#endif\n-    if (i -= j) {\n-        return i;\n-    }\n-    xa0 = a->x;\n-    xa = xa0 + j;\n-    xb0 = b->x;\n-    xb = xb0 + j;\n-    for (;;) {\n-        if (*--xa != *--xb) {\n-            return *xa < *xb ? -1 : 1;\n-        }\n-        if (xa <= xa0) {\n-            break;\n-        }\n-    }\n-    return 0;\n+  if (i > 1 && !a->x[i - 1]) {\n+    Bug(\"cmp called with a->x[a->wds-1] == 0\");\n+  }\n+  if (j > 1 && !b->x[j - 1]) {\n+    Bug(\"cmp called with b->x[b->wds-1] == 0\");\n+  }\n+#endif\n+  if (i -= j) {\n+    return i;\n+  }\n+  xa0 = a->x;\n+  xa = xa0 + j;\n+  xb0 = b->x;\n+  xb = xb0 + j;\n+  for (;;) {\n+    if (*--xa != *--xb) {\n+      return *xa < *xb ? -1 : 1;\n+    }\n+    if (xa <= xa0) {\n+      break;\n+    }\n+  }\n+  return 0;\n }\n \n static Bigint *diff\n@@ -1101,88 +1095,88 @@ static Bigint *diff\n     (Bigint* a, Bigint* b)\n #endif\n {\n-    Bigint* c;\n-    int i, wa, wb;\n-    ULong *xa, *xae, *xb, *xbe, *xc;\n+  Bigint* c;\n+  int i, wa, wb;\n+  ULong *xa, *xae, *xb, *xbe, *xc;\n #ifdef ULLong\n-    ULLong borrow, y;\n+  ULLong borrow, y;\n #else\n-    ULong borrow, y;\n-#ifdef Pack_32\n-    ULong z;\n-#endif\n+  ULong borrow, y;\n+#  ifdef Pack_32\n+  ULong z;\n+#  endif\n #endif\n \n-    i = cmp(a, b);\n-    if (!i) {\n-        c = Balloc(0);\n-        c->wds = 1;\n-        c->x[0] = 0;\n-        return c;\n-    }\n-    if (i < 0) {\n-        c = a;\n-        a = b;\n-        b = c;\n-        i = 1;\n-    } else {\n-        i = 0;\n-    }\n-    c = Balloc(a->k);\n-    c->sign = i;\n-    wa = a->wds;\n-    xa = a->x;\n-    xae = xa + wa;\n-    wb = b->wds;\n-    xb = b->x;\n-    xbe = xb + wb;\n-    xc = c->x;\n-    borrow = 0;\n-#ifdef ULLong\n-    do {\n-        y = (ULLong)*xa++ - *xb++ - borrow;\n-        borrow = y >> 32 & (ULong)1;\n-        *xc++ = y & FFFFFFFF;\n-    } while (xb < xbe);\n-    while (xa < xae) {\n-        y = *xa++ - borrow;\n-        borrow = y >> 32 & (ULong)1;\n-        *xc++ = y & FFFFFFFF;\n-    }\n-#else\n-#ifdef Pack_32\n-    do {\n-        y = (*xa & 0xffff) - (*xb & 0xffff) - borrow;\n-        borrow = (y & 0x10000) >> 16;\n-        z = (*xa++ >> 16) - (*xb++ >> 16) - borrow;\n-        borrow = (z & 0x10000) >> 16;\n-        Storeinc(xc, z, y);\n-    } while (xb < xbe);\n-    while (xa < xae) {\n-        y = (*xa & 0xffff) - borrow;\n-        borrow = (y & 0x10000) >> 16;\n-        z = (*xa++ >> 16) - borrow;\n-        borrow = (z & 0x10000) >> 16;\n-        Storeinc(xc, z, y);\n-    }\n-#else\n-    do {\n-        y = *xa++ - *xb++ - borrow;\n-        borrow = (y & 0x10000) >> 16;\n-        *xc++ = y & 0xffff;\n-    } while (xb < xbe);\n-    while (xa < xae) {\n-        y = *xa++ - borrow;\n-        borrow = (y & 0x10000) >> 16;\n-        *xc++ = y & 0xffff;\n-    }\n-#endif\n-#endif\n-    while (!*--xc) {\n-        wa--;\n-    }\n-    c->wds = wa;\n+  i = cmp(a, b);\n+  if (!i) {\n+    c = Balloc(0);\n+    c->wds = 1;\n+    c->x[0] = 0;\n     return c;\n+  }\n+  if (i < 0) {\n+    c = a;\n+    a = b;\n+    b = c;\n+    i = 1;\n+  } else {\n+    i = 0;\n+  }\n+  c = Balloc(a->k);\n+  c->sign = i;\n+  wa = a->wds;\n+  xa = a->x;\n+  xae = xa + wa;\n+  wb = b->wds;\n+  xb = b->x;\n+  xbe = xb + wb;\n+  xc = c->x;\n+  borrow = 0;\n+#ifdef ULLong\n+  do {\n+    y = (ULLong)*xa++ - *xb++ - borrow;\n+    borrow = y >> 32 & (ULong)1;\n+    *xc++ = y & FFFFFFFF;\n+  } while (xb < xbe);\n+  while (xa < xae) {\n+    y = *xa++ - borrow;\n+    borrow = y >> 32 & (ULong)1;\n+    *xc++ = y & FFFFFFFF;\n+  }\n+#else\n+#  ifdef Pack_32\n+  do {\n+    y = (*xa & 0xffff) - (*xb & 0xffff) - borrow;\n+    borrow = (y & 0x10000) >> 16;\n+    z = (*xa++ >> 16) - (*xb++ >> 16) - borrow;\n+    borrow = (z & 0x10000) >> 16;\n+    Storeinc(xc, z, y);\n+  } while (xb < xbe);\n+  while (xa < xae) {\n+    y = (*xa & 0xffff) - borrow;\n+    borrow = (y & 0x10000) >> 16;\n+    z = (*xa++ >> 16) - borrow;\n+    borrow = (z & 0x10000) >> 16;\n+    Storeinc(xc, z, y);\n+  }\n+#  else\n+  do {\n+    y = *xa++ - *xb++ - borrow;\n+    borrow = (y & 0x10000) >> 16;\n+    *xc++ = y & 0xffff;\n+  } while (xb < xbe);\n+  while (xa < xae) {\n+    y = *xa++ - borrow;\n+    borrow = (y & 0x10000) >> 16;\n+    *xc++ = y & 0xffff;\n+  }\n+#  endif\n+#endif\n+  while (!*--xc) {\n+    wa--;\n+  }\n+  c->wds = wa;\n+  return c;\n }\n \n static double ulp\n@@ -1192,37 +1186,37 @@ static double ulp\n     (double dx)\n #endif\n {\n-    register Long L;\n-    U x, a;\n+  register Long L;\n+  U x, a;\n \n-    dval(x) = dx;\n-    L = (word0(x) & Exp_mask) - (P - 1) * Exp_msk1;\n+  dval(x) = dx;\n+  L = (word0(x) & Exp_mask) - (P - 1) * Exp_msk1;\n #ifndef Avoid_Underflow\n-#ifndef Sudden_Underflow\n-    if (L > 0) {\n-#endif\n+#  ifndef Sudden_Underflow\n+  if (L > 0) {\n+#  endif\n #endif\n #ifdef IBM\n-        L |= Exp_msk1 >> 4;\n+    L |= Exp_msk1 >> 4;\n #endif\n-        word0(a) = L;\n-        word1(a) = 0;\n+    word0(a) = L;\n+    word1(a) = 0;\n #ifndef Avoid_Underflow\n-#ifndef Sudden_Underflow\n+#  ifndef Sudden_Underflow\n+  } else {\n+    L = -L >> Exp_shift;\n+    if (L < Exp_shift) {\n+      word0(a) = 0x80000 >> L;\n+      word1(a) = 0;\n     } else {\n-        L = -L >> Exp_shift;\n-        if (L < Exp_shift) {\n-            word0(a) = 0x80000 >> L;\n-            word1(a) = 0;\n-        } else {\n-            word0(a) = 0;\n-            L -= Exp_shift;\n-            word1(a) = L >= 31 ? 1 : 1 << 31 - L;\n-        }\n+      word0(a) = 0;\n+      L -= Exp_shift;\n+      word1(a) = L >= 31 ? 1 : 1 << 31 - L;\n     }\n+  }\n+#  endif\n #endif\n-#endif\n-    return dval(a);\n+  return dval(a);\n }\n \n static double b2d\n@@ -1233,67 +1227,67 @@ int* e;\n     (Bigint* a, int* e)\n #endif\n {\n-    ULong *xa, *xa0, w, y, z;\n-    int k;\n-    U d;\n+  ULong *xa, *xa0, w, y, z;\n+  int k;\n+  U d;\n #ifdef VAX\n-    ULong d0, d1;\n+  ULong d0, d1;\n #else\n-#define d0 word0(d)\n-#define d1 word1(d)\n+#  define d0 word0(d)\n+#  define d1 word1(d)\n #endif\n \n-    xa0 = a->x;\n-    xa = xa0 + a->wds;\n-    y = *--xa;\n+  xa0 = a->x;\n+  xa = xa0 + a->wds;\n+  y = *--xa;\n #ifdef DEBUG\n-    if (!y) {\n-        Bug(\"zero y in b2d\");\n-    }\n+  if (!y) {\n+    Bug(\"zero y in b2d\");\n+  }\n #endif\n-    k = hi0bits(y);\n-    *e = 32 - k;\n+  k = hi0bits(y);\n+  *e = 32 - k;\n #ifdef Pack_32\n-    if (k < Ebits) {\n-        d0 = Exp_1 | y >> Ebits - k;\n-        w = xa > xa0 ? *--xa : 0;\n-        d1 = y << (32 - Ebits) + k | w >> Ebits - k;\n-        goto ret_d;\n-    }\n-    z = xa > xa0 ? *--xa : 0;\n-    if (k -= Ebits) {\n-        d0 = Exp_1 | y << k | z >> 32 - k;\n-        y = xa > xa0 ? *--xa : 0;\n-        d1 = z << k | y >> 32 - k;\n-    } else {\n-        d0 = Exp_1 | y;\n-        d1 = z;\n-    }\n+  if (k < Ebits) {\n+    d0 = Exp_1 | y >> Ebits - k;\n+    w = xa > xa0 ? *--xa : 0;\n+    d1 = y << (32 - Ebits) + k | w >> Ebits - k;\n+    goto ret_d;\n+  }\n+  z = xa > xa0 ? *--xa : 0;\n+  if (k -= Ebits) {\n+    d0 = Exp_1 | y << k | z >> 32 - k;\n+    y = xa > xa0 ? *--xa : 0;\n+    d1 = z << k | y >> 32 - k;\n+  } else {\n+    d0 = Exp_1 | y;\n+    d1 = z;\n+  }\n #else\n-    if (k < Ebits + 16) {\n-        z = xa > xa0 ? *--xa : 0;\n-        d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;\n-        w = xa > xa0 ? *--xa : 0;\n-        y = xa > xa0 ? *--xa : 0;\n-        d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;\n-        goto ret_d;\n-    }\n+  if (k < Ebits + 16) {\n     z = xa > xa0 ? *--xa : 0;\n+    d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;\n     w = xa > xa0 ? *--xa : 0;\n-    k -= Ebits + 16;\n-    d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;\n     y = xa > xa0 ? *--xa : 0;\n-    d1 = w << k + 16 | y << k;\n+    d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;\n+    goto ret_d;\n+  }\n+  z = xa > xa0 ? *--xa : 0;\n+  w = xa > xa0 ? *--xa : 0;\n+  k -= Ebits + 16;\n+  d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;\n+  y = xa > xa0 ? *--xa : 0;\n+  d1 = w << k + 16 | y << k;\n #endif\n ret_d:\n #ifdef VAX\n-    word0(d) = d0 >> 16 | d0 << 16;\n-    word1(d) = d1 >> 16 | d1 << 16;\n+  word0(d) = d0 >> 16 | d0 << 16;\n+  word1(d) = d1 >> 16 | d1 << 16;\n #else\n-#undef d0\n-#undef d1\n+#  undef d0\n+#  undef d1\n #endif\n-    return dval(d);\n+  return dval(d);\n }\n \n static Bigint* d2b\n@@ -1304,131 +1298,131 @@ int *e, *bits;\n     (double dd, int* e, int* bits)\n #endif\n {\n-    U d;\n-    Bigint* b;\n-    int de, k;\n-    ULong *x, y, z;\n+  U d;\n+  Bigint* b;\n+  int de, k;\n+  ULong *x, y, z;\n #ifndef Sudden_Underflow\n-    int i;\n+  int i;\n #endif\n #ifdef VAX\n-    ULong d0, d1;\n+  ULong d0, d1;\n #endif\n \n-    dval(d) = dd;\n+  dval(d) = dd;\n #ifdef VAX\n-    d0 = word0(d) >> 16 | word0(d) << 16;\n-    d1 = word1(d) >> 16 | word1(d) << 16;\n+  d0 = word0(d) >> 16 | word0(d) << 16;\n+  d1 = word1(d) >> 16 | word1(d) << 16;\n #else\n-#define d0 word0(d)\n-#define d1 word1(d)\n+#  define d0 word0(d)\n+#  define d1 word1(d)\n #endif\n \n #ifdef Pack_32\n-    b = Balloc(1);\n+  b = Balloc(1);\n #else\n-    b = Balloc(2);\n+  b = Balloc(2);\n #endif\n-    x = b->x;\n+  x = b->x;\n \n-    z = d0 & Frac_mask;\n-    d0 &= 0x7fffffff; /* clear sign bit, which we ignore */\n+  z = d0 & Frac_mask;\n+  d0 &= 0x7fffffff; /* clear sign bit, which we ignore */\n #ifdef Sudden_Underflow\n-    de = (int)(d0 >> Exp_shift);\n-#ifndef IBM\n-    z |= Exp_msk11;\n-#endif\n+  de = (int)(d0 >> Exp_shift);\n+#  ifndef IBM\n+  z |= Exp_msk11;\n+#  endif\n #else\n-    if (de = (int)(d0 >> Exp_shift)) {\n-        z |= Exp_msk1;\n-    }\n+  if (de = (int)(d0 >> Exp_shift)) {\n+    z |= Exp_msk1;\n+  }\n #endif\n #ifdef Pack_32\n-    if (y = d1) {\n-        if (k = lo0bits(&y)) {\n-            x[0] = y | z << 32 - k;\n-            z >>= k;\n-        } else {\n-            x[0] = y;\n-        }\n-#ifndef Sudden_Underflow\n-        i =\n-#endif\n-            b->wds = (x[1] = z) ? 2 : 1;\n-    } else {\n-        k = lo0bits(&z);\n-        x[0] = z;\n-#ifndef Sudden_Underflow\n-        i =\n-#endif\n-            b->wds = 1;\n-        k += 32;\n-    }\n-#else\n-    if (y = d1) {\n-        if (k = lo0bits(&y))\n-            if (k >= 16) {\n-                x[0] = y | z << 32 - k & 0xffff;\n-                x[1] = z >> k - 16 & 0xffff;\n-                x[2] = z >> k;\n-                i = 2;\n-            } else {\n-                x[0] = y & 0xffff;\n-                x[1] = y >> 16 | z << 16 - k & 0xffff;\n-                x[2] = z >> k & 0xffff;\n-                x[3] = z >> k + 16;\n-                i = 3;\n-            }\n-        else {\n-            x[0] = y & 0xffff;\n-            x[1] = y >> 16;\n-            x[2] = z & 0xffff;\n-            x[3] = z >> 16;\n-            i = 3;\n-        }\n+  if (y = d1) {\n+    if (k = lo0bits(&y)) {\n+      x[0] = y | z << 32 - k;\n+      z >>= k;\n     } else {\n-#ifdef DEBUG\n-        if (!z) {\n-            Bug(\"Zero passed to d2b\");\n-        }\n-#endif\n-        k = lo0bits(&z);\n-        if (k >= 16) {\n-            x[0] = z;\n-            i = 0;\n-        } else {\n-            x[0] = z & 0xffff;\n-            x[1] = z >> 16;\n-            i = 1;\n-        }\n-        k += 32;\n+      x[0] = y;\n     }\n-    while (!x[i]) {\n-        --i;\n+#  ifndef Sudden_Underflow\n+    i =\n+#  endif\n+        b->wds = (x[1] = z) ? 2 : 1;\n+  } else {\n+    k = lo0bits(&z);\n+    x[0] = z;\n+#  ifndef Sudden_Underflow\n+    i =\n+#  endif\n+        b->wds = 1;\n+    k += 32;\n+  }\n+#else\n+  if (y = d1) {\n+    if (k = lo0bits(&y))\n+      if (k >= 16) {\n+        x[0] = y | z << 32 - k & 0xffff;\n+        x[1] = z >> k - 16 & 0xffff;\n+        x[2] = z >> k;\n+        i = 2;\n+      } else {\n+        x[0] = y & 0xffff;\n+        x[1] = y >> 16 | z << 16 - k & 0xffff;\n+        x[2] = z >> k & 0xffff;\n+        x[3] = z >> k + 16;\n+        i = 3;\n+      }\n+    else {\n+      x[0] = y & 0xffff;\n+      x[1] = y >> 16;\n+      x[2] = z & 0xffff;\n+      x[3] = z >> 16;\n+      i = 3;\n+    }\n+  } else {\n+#  ifdef DEBUG\n+    if (!z) {\n+      Bug(\"Zero passed to d2b\");\n+    }\n+#  endif\n+    k = lo0bits(&z);\n+    if (k >= 16) {\n+      x[0] = z;\n+      i = 0;\n+    } else {\n+      x[0] = z & 0xffff;\n+      x[1] = z >> 16;\n+      i = 1;\n     }\n-    b->wds = i + 1;\n+    k += 32;\n+  }\n+  while (!x[i]) {\n+    --i;\n+  }\n+  b->wds = i + 1;\n #endif\n #ifndef Sudden_Underflow\n-    if (de) {\n+  if (de) {\n #endif\n #ifdef IBM\n-        *e = (de - Bias - (P - 1) << 2) + k;\n-        *bits = 4 * P + 8 - k - hi0bits(word0(d) & Frac_mask);\n+    *e = (de - Bias - (P - 1) << 2) + k;\n+    *bits = 4 * P + 8 - k - hi0bits(word0(d) & Frac_mask);\n #else\n-    *e = de - Bias - (P - 1) + k;\n-    *bits = P - k;\n+  *e = de - Bias - (P - 1) + k;\n+  *bits = P - k;\n #endif\n #ifndef Sudden_Underflow\n-    } else {\n-        *e = de - Bias - (P - 1) + 1 + k;\n-#ifdef Pack_32\n-        *bits = 32 * i - hi0bits(x[i - 1]);\n-#else\n-        *bits = (i + 2) * 16 - hi0bits(x[i]);\n-#endif\n-    }\n+  } else {\n+    *e = de - Bias - (P - 1) + 1 + k;\n+#  ifdef Pack_32\n+    *bits = 32 * i - hi0bits(x[i - 1]);\n+#  else\n+    *bits = (i + 2) * 16 - hi0bits(x[i]);\n+#  endif\n+  }\n #endif\n-    return b;\n+  return b;\n }\n #undef d0\n #undef d1\n@@ -1441,188 +1435,188 @@ static double ratio\n     (Bigint* a, Bigint* b)\n #endif\n {\n-    U da, db;\n-    int k, ka, kb;\n+  U da, db;\n+  int k, ka, kb;\n \n-    dval(da) = b2d(a, &ka);\n-    dval(db) = b2d(b, &kb);\n+  dval(da) = b2d(a, &ka);\n+  dval(db) = b2d(b, &kb);\n #ifdef Pack_32\n-    k = ka - kb + 32 * (a->wds - b->wds);\n+  k = ka - kb + 32 * (a->wds - b->wds);\n #else\n-    k = ka - kb + 16 * (a->wds - b->wds);\n+  k = ka - kb + 16 * (a->wds - b->wds);\n #endif\n #ifdef IBM\n-    if (k > 0) {\n-        word0(da) += (k >> 2) * Exp_msk1;\n-        if (k &= 3) {\n-            dval(da) *= 1 << k;\n-        }\n-    } else {\n-        k = -k;\n-        word0(db) += (k >> 2) * Exp_msk1;\n-        if (k &= 3) {\n-            dval(db) *= 1 << k;\n-        }\n-    }\n-#else\n-    if (k > 0) {\n-        word0(da) += k * Exp_msk1;\n-    } else {\n-        k = -k;\n-        word0(db) += k * Exp_msk1;\n-    }\n-#endif\n-    return dval(da) / dval(db);\n-}\n-\n-static CONST double tens[] = { 1e0,\n-                               1e1,\n-                               1e2,\n-                               1e3,\n-                               1e4,\n-                               1e5,\n-                               1e6,\n-                               1e7,\n-                               1e8,\n-                               1e9,\n-                               1e10,\n-                               1e11,\n-                               1e12,\n-                               1e13,\n-                               1e14,\n-                               1e15,\n-                               1e16,\n-                               1e17,\n-                               1e18,\n-                               1e19,\n-                               1e20,\n-                               1e21,\n-                               1e22\n+  if (k > 0) {\n+    word0(da) += (k >> 2) * Exp_msk1;\n+    if (k &= 3) {\n+      dval(da) *= 1 << k;\n+    }\n+  } else {\n+    k = -k;\n+    word0(db) += (k >> 2) * Exp_msk1;\n+    if (k &= 3) {\n+      dval(db) *= 1 << k;\n+    }\n+  }\n+#else\n+  if (k > 0) {\n+    word0(da) += k * Exp_msk1;\n+  } else {\n+    k = -k;\n+    word0(db) += k * Exp_msk1;\n+  }\n+#endif\n+  return dval(da) / dval(db);\n+}\n+\n+static CONST double tens[] = {1e0,\n+                              1e1,\n+                              1e2,\n+                              1e3,\n+                              1e4,\n+                              1e5,\n+                              1e6,\n+                              1e7,\n+                              1e8,\n+                              1e9,\n+                              1e10,\n+                              1e11,\n+                              1e12,\n+                              1e13,\n+                              1e14,\n+                              1e15,\n+                              1e16,\n+                              1e17,\n+                              1e18,\n+                              1e19,\n+                              1e20,\n+                              1e21,\n+                              1e22\n #ifdef VAX\n-                               ,\n-                               1e23,\n-                               1e24\n+                              ,\n+                              1e23,\n+                              1e24\n #endif\n };\n \n static CONST double\n #ifdef IEEE_Arith\n-    bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 };\n-static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128,\n-#ifdef Avoid_Underflow\n-                                   9007199254740992. * 9007199254740992.e-256\n+    bigtens[] = {1e16, 1e32, 1e64, 1e128, 1e256};\n+static CONST double tinytens[] = {1e-16, 1e-32, 1e-64, 1e-128,\n+#  ifdef Avoid_Underflow\n+                                  9007199254740992. * 9007199254740992.e-256\n /* = 2^106 * 1e-53 */\n-#else\n-                                   1e-256\n-#endif\n+#  else\n+                                  1e-256\n+#  endif\n };\n /* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */\n /* flag unnecessarily.  It leads to a song and dance at the end of strtod. */\n-#define Scale_Bit 0x10\n-#define n_bigtens 5\n-#else\n-#ifdef IBM\n-    bigtens[] = { 1e16, 1e32, 1e64 };\n-static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64 };\n-#define n_bigtens 3\n+#  define Scale_Bit 0x10\n+#  define n_bigtens 5\n #else\n-    bigtens[] = { 1e16, 1e32 };\n-static CONST double tinytens[] = { 1e-16, 1e-32 };\n-#define n_bigtens 2\n-#endif\n+#  ifdef IBM\n+    bigtens[] = {1e16, 1e32, 1e64};\n+static CONST double tinytens[] = {1e-16, 1e-32, 1e-64};\n+#    define n_bigtens 3\n+#  else\n+    bigtens[] = {1e16, 1e32};\n+static CONST double tinytens[] = {1e-16, 1e-32};\n+#    define n_bigtens 2\n+#  endif\n #endif\n \n #ifndef IEEE_Arith\n-#undef INFNAN_CHECK\n+#  undef INFNAN_CHECK\n #endif\n \n #ifdef INFNAN_CHECK\n \n-#ifndef NAN_WORD0\n-#define NAN_WORD0 0x7ff80000\n-#endif\n+#  ifndef NAN_WORD0\n+#    define NAN_WORD0 0x7ff80000\n+#  endif\n \n-#ifndef NAN_WORD1\n-#define NAN_WORD1 0\n-#endif\n+#  ifndef NAN_WORD1\n+#    define NAN_WORD1 0\n+#  endif\n \n static int match\n-#ifdef KR_headers\n+#  ifdef KR_headers\n     (sp, t) char **sp,\n     *t;\n-#else\n+#  else\n     (CONST char** sp, char* t)\n-#endif\n+#  endif\n {\n-    int c, d;\n-    CONST char* s = *sp;\n+  int c, d;\n+  CONST char* s = *sp;\n \n-    while (d = *t++) {\n-        if ((c = *++s) >= 'A' && c <= 'Z') {\n-            c += 'a' - 'A';\n-        }\n-        if (c != d) {\n-            return 0;\n-        }\n+  while (d = *t++) {\n+    if ((c = *++s) >= 'A' && c <= 'Z') {\n+      c += 'a' - 'A';\n+    }\n+    if (c != d) {\n+      return 0;\n     }\n-    *sp = s + 1;\n-    return 1;\n+  }\n+  *sp = s + 1;\n+  return 1;\n }\n \n-#ifndef No_Hex_NaN\n+#  ifndef No_Hex_NaN\n static void hexnan\n-#ifdef KR_headers\n+#    ifdef KR_headers\n     (rvp, sp) double* rvp;\n CONST char** sp;\n-#else\n+#    else\n     (double* rvp, CONST char** sp)\n-#endif\n+#    endif\n {\n-    ULong c, x[2];\n-    CONST char* s;\n-    int havedig, udx0, xshift;\n-\n-    x[0] = x[1] = 0;\n-    havedig = xshift = 0;\n-    udx0 = 1;\n-    s = *sp;\n-    while (c = *(CONST unsigned char*)++s) {\n-        if (c >= '0' && c <= '9') {\n-            c -= '0';\n-        } else if (c >= 'a' && c <= 'f') {\n-            c += 10 - 'a';\n-        } else if (c >= 'A' && c <= 'F') {\n-            c += 10 - 'A';\n-        } else if (c <= ' ') {\n-            if (udx0 && havedig) {\n-                udx0 = 0;\n-                xshift = 1;\n-            }\n-            continue;\n-        } else if (/*(*/ c == ')' && havedig) {\n-            *sp = s + 1;\n-            break;\n-        } else {\n-            return; /* invalid form: don't change *sp */\n-        }\n-        havedig = 1;\n-        if (xshift) {\n-            xshift = 0;\n-            x[0] = x[1];\n-            x[1] = 0;\n-        }\n-        if (udx0) {\n-            x[0] = (x[0] << 4) | (x[1] >> 28);\n-        }\n-        x[1] = (x[1] << 4) | c;\n+  ULong c, x[2];\n+  CONST char* s;\n+  int havedig, udx0, xshift;\n+\n+  x[0] = x[1] = 0;\n+  havedig = xshift = 0;\n+  udx0 = 1;\n+  s = *sp;\n+  while (c = *(CONST unsigned char*)++s) {\n+    if (c >= '0' && c <= '9') {\n+      c -= '0';\n+    } else if (c >= 'a' && c <= 'f') {\n+      c += 10 - 'a';\n+    } else if (c >= 'A' && c <= 'F') {\n+      c += 10 - 'A';\n+    } else if (c <= ' ') {\n+      if (udx0 && havedig) {\n+        udx0 = 0;\n+        xshift = 1;\n+      }\n+      continue;\n+    } else if (/*(*/ c == ')' && havedig) {\n+      *sp = s + 1;\n+      break;\n+    } else {\n+      return; /* invalid form: don't change *sp */\n     }\n-    if ((x[0] &= 0xfffff) || x[1]) {\n-        word0(*rvp) = Exp_mask | x[0];\n-        word1(*rvp) = x[1];\n+    havedig = 1;\n+    if (xshift) {\n+      xshift = 0;\n+      x[0] = x[1];\n+      x[1] = 0;\n     }\n+    if (udx0) {\n+      x[0] = (x[0] << 4) | (x[1] >> 28);\n+    }\n+    x[1] = (x[1] << 4) | c;\n+  }\n+  if ((x[0] &= 0xfffff) || x[1]) {\n+    word0(*rvp) = Exp_mask | x[0];\n+    word1(*rvp) = x[1];\n+  }\n }\n-#endif /*No_Hex_NaN*/\n-#endif /* INFNAN_CHECK */\n+#  endif /*No_Hex_NaN*/\n+#endif   /* INFNAN_CHECK */\n \n PR_IMPLEMENT(double)\n PR_strtod\n@@ -1634,449 +1628,447 @@ char** se;\n #endif\n {\n #ifdef Avoid_Underflow\n-    int scale;\n-#endif\n-    int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, e, e1, esign, i, j, k, nd,\n-        nd0, nf, nz, nz0, sign;\n-    CONST char *s, *s0, *s1;\n-    double aadj, aadj1, adj;\n-    U aadj2, rv, rv0;\n-    Long L;\n-    ULong y, z;\n-    Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;\n+  int scale;\n+#endif\n+  int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, e, e1, esign, i, j, k, nd,\n+      nd0, nf, nz, nz0, sign;\n+  CONST char *s, *s0, *s1;\n+  double aadj, aadj1, adj;\n+  U aadj2, rv, rv0;\n+  Long L;\n+  ULong y, z;\n+  Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;\n #ifdef SET_INEXACT\n-    int inexact, oldinexact;\n+  int inexact, oldinexact;\n #endif\n #ifdef Honor_FLT_ROUNDS\n-    int rounding;\n+  int rounding;\n #endif\n #ifdef USE_LOCALE\n-    CONST char* s2;\n-#endif\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    sign = nz0 = nz = 0;\n-    dval(rv) = 0.;\n-    for (s = s00;; s++)\n-        switch (*s) {\n-            case '-':\n-                sign = 1;\n-            /* no break */\n-            case '+':\n-                if (*++s) {\n-                    goto break2;\n-                }\n-            /* no break */\n-            case 0:\n-                goto ret0;\n-            case '\\t':\n-            case '\\n':\n-            case '\\v':\n-            case '\\f':\n-            case '\\r':\n-            case ' ':\n-                continue;\n-            default:\n-                goto break2;\n+  CONST char* s2;\n+#endif\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  sign = nz0 = nz = 0;\n+  dval(rv) = 0.;\n+  for (s = s00;; s++) switch (*s) {\n+      case '-':\n+        sign = 1;\n+      /* no break */\n+      case '+':\n+        if (*++s) {\n+          goto break2;\n         }\n+      /* no break */\n+      case 0:\n+        goto ret0;\n+      case '\\t':\n+      case '\\n':\n+      case '\\v':\n+      case '\\f':\n+      case '\\r':\n+      case ' ':\n+        continue;\n+      default:\n+        goto break2;\n+    }\n break2:\n-    if (*s == '0') {\n-        nz0 = 1;\n-        while (*++s == '0')\n-            ;\n-        if (!*s) {\n-            goto ret;\n-        }\n+  if (*s == '0') {\n+    nz0 = 1;\n+    while (*++s == '0');\n+    if (!*s) {\n+      goto ret;\n+    }\n+  }\n+  s0 = s;\n+  y = z = 0;\n+  for (nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)\n+    if (nd < 9) {\n+      y = 10 * y + c - '0';\n+    } else if (nd < 16) {\n+      z = 10 * z + c - '0';\n+    }\n+  nd0 = nd;\n+#ifdef USE_LOCALE\n+  s1 = localeconv()->decimal_point;\n+  if (c == *s1) {\n+    c = '.';\n+    if (*++s1) {\n+      s2 = s;\n+      for (;;) {\n+        if (*++s2 != *s1) {\n+          c = 0;\n+          break;\n+        }\n+        if (!*++s1) {\n+          s = s2;\n+          break;\n+        }\n+      }\n+    }\n+  }\n+#endif\n+  if (c == '.') {\n+    c = *++s;\n+    if (!nd) {\n+      for (; c == '0'; c = *++s) {\n+        nz++;\n+      }\n+      if (c > '0' && c <= '9') {\n+        s0 = s;\n+        nf += nz;\n+        nz = 0;\n+        goto have_dig;\n+      }\n+      goto dig_done;\n+    }\n+    for (; c >= '0' && c <= '9'; c = *++s) {\n+    have_dig:\n+      nz++;\n+      if (c -= '0') {\n+        nf += nz;\n+        for (i = 1; i < nz; i++)\n+          if (nd++ < 9) {\n+            y *= 10;\n+          } else if (nd <= DBL_DIG + 1) {\n+            z *= 10;\n+          }\n+        if (nd++ < 9) {\n+          y = 10 * y + c;\n+        } else if (nd <= DBL_DIG + 1) {\n+          z = 10 * z + c;\n+        }\n+        nz = 0;\n+      }\n+    }\n+  }\n+dig_done:\n+  if (nd > 64 * 1024) {\n+    goto ret0;\n+  }\n+  e = 0;\n+  if (c == 'e' || c == 'E') {\n+    if (!nd && !nz && !nz0) {\n+      goto ret0;\n+    }\n+    s00 = s;\n+    esign = 0;\n+    switch (c = *++s) {\n+      case '-':\n+        esign = 1;\n+      case '+':\n+        c = *++s;\n     }\n-    s0 = s;\n-    y = z = 0;\n-    for (nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)\n-        if (nd < 9) {\n-            y = 10 * y + c - '0';\n-        } else if (nd < 16) {\n-            z = 10 * z + c - '0';\n+    if (c >= '0' && c <= '9') {\n+      while (c == '0') {\n+        c = *++s;\n+      }\n+      if (c > '0' && c <= '9') {\n+        L = c - '0';\n+        s1 = s;\n+        while ((c = *++s) >= '0' && c <= '9') {\n+          L = 10 * L + c - '0';\n+        }\n+        if (s - s1 > 8 || L > 19999)\n+        /* Avoid confusion from exponents\n+         * so large that e might overflow.\n+         */\n+        {\n+          e = 19999; /* safe for 16 bit ints */\n+        } else {\n+          e = (int)L;\n         }\n-    nd0 = nd;\n-#ifdef USE_LOCALE\n-    s1 = localeconv()->decimal_point;\n-    if (c == *s1) {\n-        c = '.';\n-        if (*++s1) {\n-            s2 = s;\n-            for (;;) {\n-                if (*++s2 != *s1) {\n-                    c = 0;\n-                    break;\n-                }\n-                if (!*++s1) {\n-                    s = s2;\n-                    break;\n-                }\n-            }\n+        if (esign) {\n+          e = -e;\n         }\n+      } else {\n+        e = 0;\n+      }\n+    } else {\n+      s = s00;\n     }\n-#endif\n-    if (c == '.') {\n-        c = *++s;\n-        if (!nd) {\n-            for (; c == '0'; c = *++s) {\n-                nz++;\n-            }\n-            if (c > '0' && c <= '9') {\n-                s0 = s;\n-                nf += nz;\n-                nz = 0;\n-                goto have_dig;\n-            }\n-            goto dig_done;\n-        }\n-        for (; c >= '0' && c <= '9'; c = *++s) {\n-        have_dig:\n-            nz++;\n-            if (c -= '0') {\n-                nf += nz;\n-                for (i = 1; i < nz; i++)\n-                    if (nd++ < 9) {\n-                        y *= 10;\n-                    } else if (nd <= DBL_DIG + 1) {\n-                        z *= 10;\n-                    }\n-                if (nd++ < 9) {\n-                    y = 10 * y + c;\n-                } else if (nd <= DBL_DIG + 1) {\n-                    z = 10 * z + c;\n-                }\n-                nz = 0;\n-            }\n-        }\n-    }\n-dig_done:\n-    if (nd > 64 * 1024) {\n-        goto ret0;\n-    }\n-    e = 0;\n-    if (c == 'e' || c == 'E') {\n-        if (!nd && !nz && !nz0) {\n-            goto ret0;\n-        }\n-        s00 = s;\n-        esign = 0;\n-        switch (c = *++s) {\n-            case '-':\n-                esign = 1;\n-            case '+':\n-                c = *++s;\n-        }\n-        if (c >= '0' && c <= '9') {\n-            while (c == '0') {\n-                c = *++s;\n-            }\n-            if (c > '0' && c <= '9') {\n-                L = c - '0';\n-                s1 = s;\n-                while ((c = *++s) >= '0' && c <= '9') {\n-                    L = 10 * L + c - '0';\n-                }\n-                if (s - s1 > 8 || L > 19999)\n-                /* Avoid confusion from exponents\n-                 * so large that e might overflow.\n-                 */\n-                {\n-                    e = 19999; /* safe for 16 bit ints */\n-                } else {\n-                    e = (int)L;\n-                }\n-                if (esign) {\n-                    e = -e;\n-                }\n-            } else {\n-                e = 0;\n-            }\n-        } else {\n-            s = s00;\n-        }\n-    }\n-    if (!nd) {\n-        if (!nz && !nz0) {\n+  }\n+  if (!nd) {\n+    if (!nz && !nz0) {\n #ifdef INFNAN_CHECK\n-            /* Check for Nan and Infinity */\n-            switch (c) {\n-                case 'i':\n-                case 'I':\n-                    if (match(&s, \"nf\")) {\n-                        --s;\n-                        if (!match(&s, \"inity\")) {\n-                            ++s;\n-                        }\n-                        word0(rv) = 0x7ff00000;\n-                        word1(rv) = 0;\n-                        goto ret;\n-                    }\n-                    break;\n-                case 'n':\n-                case 'N':\n-                    if (match(&s, \"an\")) {\n-                        word0(rv) = NAN_WORD0;\n-                        word1(rv) = NAN_WORD1;\n-#ifndef No_Hex_NaN\n-                        if (*s == '(') { /*)*/\n-                            hexnan(&rv, &s);\n-                        }\n-#endif\n-                        goto ret;\n-                    }\n+      /* Check for Nan and Infinity */\n+      switch (c) {\n+        case 'i':\n+        case 'I':\n+          if (match(&s, \"nf\")) {\n+            --s;\n+            if (!match(&s, \"inity\")) {\n+              ++s;\n+            }\n+            word0(rv) = 0x7ff00000;\n+            word1(rv) = 0;\n+            goto ret;\n+          }\n+          break;\n+        case 'n':\n+        case 'N':\n+          if (match(&s, \"an\")) {\n+            word0(rv) = NAN_WORD0;\n+            word1(rv) = NAN_WORD1;\n+#  ifndef No_Hex_NaN\n+            if (*s == '(') { /*)*/\n+              hexnan(&rv, &s);\n             }\n+#  endif\n+            goto ret;\n+          }\n+      }\n #endif /* INFNAN_CHECK */\n-        ret0:\n-            s = s00;\n-            sign = 0;\n-        }\n-        goto ret;\n+    ret0:\n+      s = s00;\n+      sign = 0;\n     }\n-    e1 = e -= nf;\n+    goto ret;\n+  }\n+  e1 = e -= nf;\n \n-    /* Now we have nd0 digits, starting at s0, followed by a\n-     * decimal point, followed by nd-nd0 digits.  The number we're\n-     * after is the integer represented by those digits times\n-     * 10**e */\n+  /* Now we have nd0 digits, starting at s0, followed by a\n+   * decimal point, followed by nd-nd0 digits.  The number we're\n+   * after is the integer represented by those digits times\n+   * 10**e */\n \n-    if (!nd0) {\n-        nd0 = nd;\n-    }\n-    k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;\n-    dval(rv) = y;\n-    if (k > 9) {\n+  if (!nd0) {\n+    nd0 = nd;\n+  }\n+  k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;\n+  dval(rv) = y;\n+  if (k > 9) {\n #ifdef SET_INEXACT\n-        if (k > DBL_DIG) {\n-            oldinexact = get_inexact();\n-        }\n-#endif\n-        dval(rv) = tens[k - 9] * dval(rv) + z;\n+    if (k > DBL_DIG) {\n+      oldinexact = get_inexact();\n     }\n-    bd0 = 0;\n-    if (nd <= DBL_DIG\n-#ifndef RND_PRODQUOT\n-#ifndef Honor_FLT_ROUNDS\n-        && Flt_Rounds == 1\n #endif\n+    dval(rv) = tens[k - 9] * dval(rv) + z;\n+  }\n+  bd0 = 0;\n+  if (nd <= DBL_DIG\n+#ifndef RND_PRODQUOT\n+#  ifndef Honor_FLT_ROUNDS\n+      && Flt_Rounds == 1\n+#  endif\n #endif\n-    ) {\n-        if (!e) {\n-            goto ret;\n-        }\n-        if (e > 0) {\n-            if (e <= Ten_pmax) {\n+  ) {\n+    if (!e) {\n+      goto ret;\n+    }\n+    if (e > 0) {\n+      if (e <= Ten_pmax) {\n #ifdef VAX\n-                goto vax_ovfl_check;\n+        goto vax_ovfl_check;\n #else\n-#ifdef Honor_FLT_ROUNDS\n-                /* round correctly FLT_ROUNDS = 2 or 3 */\n-                if (sign) {\n-                    rv = -rv;\n-                    sign = 0;\n-                }\n-#endif\n-                /* rv = */ rounded_product(dval(rv), tens[e]);\n-                goto ret;\n+#  ifdef Honor_FLT_ROUNDS\n+        /* round correctly FLT_ROUNDS = 2 or 3 */\n+        if (sign) {\n+          rv = -rv;\n+          sign = 0;\n+        }\n+#  endif\n+        /* rv = */ rounded_product(dval(rv), tens[e]);\n+        goto ret;\n #endif\n-            }\n-            i = DBL_DIG - nd;\n-            if (e <= Ten_pmax + i) {\n-                /* A fancier test would sometimes let us do\n-                 * this for larger i values.\n-                 */\n+      }\n+      i = DBL_DIG - nd;\n+      if (e <= Ten_pmax + i) {\n+        /* A fancier test would sometimes let us do\n+         * this for larger i values.\n+         */\n #ifdef Honor_FLT_ROUNDS\n-                /* round correctly FLT_ROUNDS = 2 or 3 */\n-                if (sign) {\n-                    rv = -rv;\n-                    sign = 0;\n-                }\n-#endif\n-                e -= i;\n-                dval(rv) *= tens[i];\n-#ifdef VAX\n-                /* VAX exponent range is so narrow we must\n-                 * worry about overflow here...\n-                 */\n-            vax_ovfl_check:\n-                word0(rv) -= P * Exp_msk1;\n-                /* rv = */ rounded_product(dval(rv), tens[e]);\n-                if ((word0(rv) & Exp_mask) > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P)) {\n-                    goto ovfl;\n-                }\n-                word0(rv) += P * Exp_msk1;\n-#else\n-                /* rv = */ rounded_product(dval(rv), tens[e]);\n-#endif\n-                goto ret;\n-            }\n+        /* round correctly FLT_ROUNDS = 2 or 3 */\n+        if (sign) {\n+          rv = -rv;\n+          sign = 0;\n         }\n-#ifndef Inaccurate_Divide\n-        else if (e >= -Ten_pmax) {\n-#ifdef Honor_FLT_ROUNDS\n-            /* round correctly FLT_ROUNDS = 2 or 3 */\n-            if (sign) {\n-                rv = -rv;\n-                sign = 0;\n-            }\n #endif\n-            /* rv = */ rounded_quotient(dval(rv), tens[-e]);\n-            goto ret;\n+        e -= i;\n+        dval(rv) *= tens[i];\n+#ifdef VAX\n+        /* VAX exponent range is so narrow we must\n+         * worry about overflow here...\n+         */\n+      vax_ovfl_check:\n+        word0(rv) -= P * Exp_msk1;\n+        /* rv = */ rounded_product(dval(rv), tens[e]);\n+        if ((word0(rv) & Exp_mask) > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P)) {\n+          goto ovfl;\n         }\n+        word0(rv) += P * Exp_msk1;\n+#else\n+        /* rv = */ rounded_product(dval(rv), tens[e]);\n #endif\n+        goto ret;\n+      }\n     }\n-    e1 += nd - k;\n-\n-#ifdef IEEE_Arith\n-#ifdef SET_INEXACT\n-    inexact = 1;\n-    if (k <= DBL_DIG) {\n-        oldinexact = get_inexact();\n-    }\n-#endif\n-#ifdef Avoid_Underflow\n-    scale = 0;\n-#endif\n-#ifdef Honor_FLT_ROUNDS\n-    if ((rounding = Flt_Rounds) >= 2) {\n-        if (sign) {\n-            rounding = rounding == 2 ? 0 : 2;\n-        } else if (rounding != 2) {\n-            rounding = 0;\n-        }\n+#ifndef Inaccurate_Divide\n+    else if (e >= -Ten_pmax) {\n+#  ifdef Honor_FLT_ROUNDS\n+      /* round correctly FLT_ROUNDS = 2 or 3 */\n+      if (sign) {\n+        rv = -rv;\n+        sign = 0;\n+      }\n+#  endif\n+      /* rv = */ rounded_quotient(dval(rv), tens[-e]);\n+      goto ret;\n     }\n #endif\n+  }\n+  e1 += nd - k;\n+\n+#ifdef IEEE_Arith\n+#  ifdef SET_INEXACT\n+  inexact = 1;\n+  if (k <= DBL_DIG) {\n+    oldinexact = get_inexact();\n+  }\n+#  endif\n+#  ifdef Avoid_Underflow\n+  scale = 0;\n+#  endif\n+#  ifdef Honor_FLT_ROUNDS\n+  if ((rounding = Flt_Rounds) >= 2) {\n+    if (sign) {\n+      rounding = rounding == 2 ? 0 : 2;\n+    } else if (rounding != 2) {\n+      rounding = 0;\n+    }\n+  }\n+#  endif\n #endif /*IEEE_Arith*/\n \n-    /* Get starting approximation = rv * 10**e1 */\n+  /* Get starting approximation = rv * 10**e1 */\n \n-    if (e1 > 0) {\n-        if (i = e1 & 15) {\n-            dval(rv) *= tens[i];\n-        }\n-        if (e1 &= ~15) {\n-            if (e1 > DBL_MAX_10_EXP) {\n-            ovfl:\n+  if (e1 > 0) {\n+    if (i = e1 & 15) {\n+      dval(rv) *= tens[i];\n+    }\n+    if (e1 &= ~15) {\n+      if (e1 > DBL_MAX_10_EXP) {\n+      ovfl:\n #ifndef NO_ERRNO\n-                PR_SetError(PR_RANGE_ERROR, 0);\n+        PR_SetError(PR_RANGE_ERROR, 0);\n #endif\n-                /* Can't trust HUGE_VAL */\n+        /* Can't trust HUGE_VAL */\n #ifdef IEEE_Arith\n-#ifdef Honor_FLT_ROUNDS\n-                switch (rounding) {\n-                    case 0: /* toward 0 */\n-                    case 3: /* toward -infinity */\n-                        word0(rv) = Big0;\n-                        word1(rv) = Big1;\n-                        break;\n-                    default:\n-                        word0(rv) = Exp_mask;\n-                        word1(rv) = 0;\n-                }\n-#else  /*Honor_FLT_ROUNDS*/\n-                word0(rv) = Exp_mask;\n-                word1(rv) = 0;\n-#endif /*Honor_FLT_ROUNDS*/\n-#ifdef SET_INEXACT\n-                /* set overflow bit */\n-                dval(rv0) = 1e300;\n-                dval(rv0) *= dval(rv0);\n-#endif\n+#  ifdef Honor_FLT_ROUNDS\n+        switch (rounding) {\n+          case 0: /* toward 0 */\n+          case 3: /* toward -infinity */\n+            word0(rv) = Big0;\n+            word1(rv) = Big1;\n+            break;\n+          default:\n+            word0(rv) = Exp_mask;\n+            word1(rv) = 0;\n+        }\n+#  else  /*Honor_FLT_ROUNDS*/\n+        word0(rv) = Exp_mask;\n+        word1(rv) = 0;\n+#  endif /*Honor_FLT_ROUNDS*/\n+#  ifdef SET_INEXACT\n+        /* set overflow bit */\n+        dval(rv0) = 1e300;\n+        dval(rv0) *= dval(rv0);\n+#  endif\n #else  /*IEEE_Arith*/\n-                word0(rv) = Big0;\n-                word1(rv) = Big1;\n+        word0(rv) = Big0;\n+        word1(rv) = Big1;\n #endif /*IEEE_Arith*/\n-                if (bd0) {\n-                    goto retfree;\n-                }\n-                goto ret;\n-            }\n-            e1 >>= 4;\n-            for (j = 0; e1 > 1; j++, e1 >>= 1)\n-                if (e1 & 1) {\n-                    dval(rv) *= bigtens[j];\n-                }\n-            /* The last multiplication could overflow. */\n-            word0(rv) -= P * Exp_msk1;\n-            dval(rv) *= bigtens[j];\n-            if ((z = word0(rv) & Exp_mask) > Exp_msk1 * (DBL_MAX_EXP + Bias - P)) {\n-                goto ovfl;\n-            }\n-            if (z > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P)) {\n-                /* set to largest number */\n-                /* (Can't trust DBL_MAX) */\n-                word0(rv) = Big0;\n-                word1(rv) = Big1;\n-            } else {\n-                word0(rv) += P * Exp_msk1;\n-            }\n-        }\n-    } else if (e1 < 0) {\n-        e1 = -e1;\n-        if (i = e1 & 15) {\n-            dval(rv) /= tens[i];\n+        if (bd0) {\n+          goto retfree;\n         }\n-        if (e1 >>= 4) {\n-            if (e1 >= 1 << n_bigtens) {\n-                goto undfl;\n-            }\n+        goto ret;\n+      }\n+      e1 >>= 4;\n+      for (j = 0; e1 > 1; j++, e1 >>= 1)\n+        if (e1 & 1) {\n+          dval(rv) *= bigtens[j];\n+        }\n+      /* The last multiplication could overflow. */\n+      word0(rv) -= P * Exp_msk1;\n+      dval(rv) *= bigtens[j];\n+      if ((z = word0(rv) & Exp_mask) > Exp_msk1 * (DBL_MAX_EXP + Bias - P)) {\n+        goto ovfl;\n+      }\n+      if (z > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P)) {\n+        /* set to largest number */\n+        /* (Can't trust DBL_MAX) */\n+        word0(rv) = Big0;\n+        word1(rv) = Big1;\n+      } else {\n+        word0(rv) += P * Exp_msk1;\n+      }\n+    }\n+  } else if (e1 < 0) {\n+    e1 = -e1;\n+    if (i = e1 & 15) {\n+      dval(rv) /= tens[i];\n+    }\n+    if (e1 >>= 4) {\n+      if (e1 >= 1 << n_bigtens) {\n+        goto undfl;\n+      }\n #ifdef Avoid_Underflow\n-            if (e1 & Scale_Bit) {\n-                scale = 2 * P;\n-            }\n-            for (j = 0; e1 > 0; j++, e1 >>= 1)\n-                if (e1 & 1) {\n-                    dval(rv) *= tinytens[j];\n-                }\n-            if (scale &&\n-                (j = 2 * P + 1 - ((word0(rv) & Exp_mask) >> Exp_shift)) > 0) {\n-                /* scaled rv is denormal; zap j low bits */\n-                if (j >= 32) {\n-                    word1(rv) = 0;\n-                    if (j >= 53) {\n-                        word0(rv) = (P + 2) * Exp_msk1;\n-                    } else {\n-                        word0(rv) &= 0xffffffff << j - 32;\n-                    }\n-                } else {\n-                    word1(rv) &= 0xffffffff << j;\n-                }\n-            }\n+      if (e1 & Scale_Bit) {\n+        scale = 2 * P;\n+      }\n+      for (j = 0; e1 > 0; j++, e1 >>= 1)\n+        if (e1 & 1) {\n+          dval(rv) *= tinytens[j];\n+        }\n+      if (scale &&\n+          (j = 2 * P + 1 - ((word0(rv) & Exp_mask) >> Exp_shift)) > 0) {\n+        /* scaled rv is denormal; zap j low bits */\n+        if (j >= 32) {\n+          word1(rv) = 0;\n+          if (j >= 53) {\n+            word0(rv) = (P + 2) * Exp_msk1;\n+          } else {\n+            word0(rv) &= 0xffffffff << j - 32;\n+          }\n+        } else {\n+          word1(rv) &= 0xffffffff << j;\n+        }\n+      }\n #else\n-            for (j = 0; e1 > 1; j++, e1 >>= 1)\n-                if (e1 & 1) {\n-                    dval(rv) *= tinytens[j];\n-                }\n-            /* The last multiplication could underflow. */\n-            dval(rv0) = dval(rv);\n-            dval(rv) *= tinytens[j];\n-            if (!dval(rv)) {\n-                dval(rv) = 2. * dval(rv0);\n-                dval(rv) *= tinytens[j];\n-#endif\n-            if (!dval(rv)) {\n-            undfl:\n-                dval(rv) = 0.;\n+      for (j = 0; e1 > 1; j++, e1 >>= 1)\n+        if (e1 & 1) {\n+          dval(rv) *= tinytens[j];\n+        }\n+      /* The last multiplication could underflow. */\n+      dval(rv0) = dval(rv);\n+      dval(rv) *= tinytens[j];\n+      if (!dval(rv)) {\n+        dval(rv) = 2. * dval(rv0);\n+        dval(rv) *= tinytens[j];\n+#endif\n+      if (!dval(rv)) {\n+      undfl:\n+        dval(rv) = 0.;\n #ifndef NO_ERRNO\n-                PR_SetError(PR_RANGE_ERROR, 0);\n+        PR_SetError(PR_RANGE_ERROR, 0);\n #endif\n-                if (bd0) {\n-                    goto retfree;\n-                }\n-                goto ret;\n-            }\n-#ifndef Avoid_Underflow\n-            word0(rv) = Tiny0;\n-            word1(rv) = Tiny1;\n-            /* The refinement below will clean\n-             * this approximation up.\n-             */\n+        if (bd0) {\n+          goto retfree;\n         }\n-#endif\n+        goto ret;\n+      }\n+#ifndef Avoid_Underflow\n+      word0(rv) = Tiny0;\n+      word1(rv) = Tiny1;\n+      /* The refinement below will clean\n+       * this approximation up.\n+       */\n     }\n+#endif\n+  }\n }\n \n /* Now the hard part -- adjusting rv to the correct value.*/\n@@ -2086,480 +2078,480 @@ dig_done:\n bd0 = s2b(s0, nd0, nd, y);\n \n for (;;) {\n-    bd = Balloc(bd0->k);\n-    Bcopy(bd, bd0);\n-    bb = d2b(dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */\n-    bs = i2b(1);\n-\n-    if (e >= 0) {\n-        bb2 = bb5 = 0;\n-        bd2 = bd5 = e;\n-    } else {\n-        bb2 = bb5 = -e;\n-        bd2 = bd5 = 0;\n-    }\n-    if (bbe >= 0) {\n-        bb2 += bbe;\n-    } else {\n-        bd2 -= bbe;\n-    }\n-    bs2 = bb2;\n+  bd = Balloc(bd0->k);\n+  Bcopy(bd, bd0);\n+  bb = d2b(dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */\n+  bs = i2b(1);\n+\n+  if (e >= 0) {\n+    bb2 = bb5 = 0;\n+    bd2 = bd5 = e;\n+  } else {\n+    bb2 = bb5 = -e;\n+    bd2 = bd5 = 0;\n+  }\n+  if (bbe >= 0) {\n+    bb2 += bbe;\n+  } else {\n+    bd2 -= bbe;\n+  }\n+  bs2 = bb2;\n #ifdef Honor_FLT_ROUNDS\n-    if (rounding != 1) {\n-        bs2++;\n-    }\n+  if (rounding != 1) {\n+    bs2++;\n+  }\n #endif\n #ifdef Avoid_Underflow\n-    j = bbe - scale;\n-    i = j + bbbits - 1; /* logb(rv) */\n-    if (i < Emin) {     /* denormal */\n+  j = bbe - scale;\n+  i = j + bbbits - 1; /* logb(rv) */\n+  if (i < Emin) {     /* denormal */\n+    j += P - Emin;\n+  } else {\n+    j = P + 1 - bbbits;\n+  }\n+#else /*Avoid_Underflow*/\n+#  ifdef Sudden_Underflow\n+#    ifdef IBM\n+      j = 1 + 4 * P - 3 - bbbits + ((bbe + bbbits - 1) & 3);\n+#    else\n+      j = P + 1 - bbbits;\n+#    endif\n+#  else  /*Sudden_Underflow*/\n+      j = bbe;\n+      i = j + bbbits - 1; /* logb(rv) */\n+      if (i < Emin) {     /* denormal */\n         j += P - Emin;\n-    } else {\n+      } else {\n         j = P + 1 - bbbits;\n-    }\n-#else /*Avoid_Underflow*/\n-#ifdef Sudden_Underflow\n-#ifdef IBM\n-            j = 1 + 4 * P - 3 - bbbits + ((bbe + bbbits - 1) & 3);\n-#else\n-            j = P + 1 - bbbits;\n-#endif\n-#else  /*Sudden_Underflow*/\n-            j = bbe;\n-            i = j + bbbits - 1; /* logb(rv) */\n-            if (i < Emin) {     /* denormal */\n-                j += P - Emin;\n-            } else {\n-                j = P + 1 - bbbits;\n-            }\n-#endif /*Sudden_Underflow*/\n-#endif /*Avoid_Underflow*/\n-    bb2 += j;\n-    bd2 += j;\n+      }\n+#  endif /*Sudden_Underflow*/\n+#endif   /*Avoid_Underflow*/\n+  bb2 += j;\n+  bd2 += j;\n #ifdef Avoid_Underflow\n-    bd2 += scale;\n-#endif\n-    i = bb2 < bd2 ? bb2 : bd2;\n-    if (i > bs2) {\n-        i = bs2;\n-    }\n-    if (i > 0) {\n-        bb2 -= i;\n-        bd2 -= i;\n-        bs2 -= i;\n-    }\n-    if (bb5 > 0) {\n-        bs = pow5mult(bs, bb5);\n-        bb1 = mult(bs, bb);\n-        Bfree(bb);\n-        bb = bb1;\n-    }\n-    if (bb2 > 0) {\n-        bb = lshift(bb, bb2);\n-    }\n-    if (bd5 > 0) {\n-        bd = pow5mult(bd, bd5);\n-    }\n-    if (bd2 > 0) {\n-        bd = lshift(bd, bd2);\n-    }\n-    if (bs2 > 0) {\n-        bs = lshift(bs, bs2);\n-    }\n-    delta = diff(bb, bd);\n-    dsign = delta->sign;\n-    delta->sign = 0;\n-    i = cmp(delta, bs);\n+  bd2 += scale;\n+#endif\n+  i = bb2 < bd2 ? bb2 : bd2;\n+  if (i > bs2) {\n+    i = bs2;\n+  }\n+  if (i > 0) {\n+    bb2 -= i;\n+    bd2 -= i;\n+    bs2 -= i;\n+  }\n+  if (bb5 > 0) {\n+    bs = pow5mult(bs, bb5);\n+    bb1 = mult(bs, bb);\n+    Bfree(bb);\n+    bb = bb1;\n+  }\n+  if (bb2 > 0) {\n+    bb = lshift(bb, bb2);\n+  }\n+  if (bd5 > 0) {\n+    bd = pow5mult(bd, bd5);\n+  }\n+  if (bd2 > 0) {\n+    bd = lshift(bd, bd2);\n+  }\n+  if (bs2 > 0) {\n+    bs = lshift(bs, bs2);\n+  }\n+  delta = diff(bb, bd);\n+  dsign = delta->sign;\n+  delta->sign = 0;\n+  i = cmp(delta, bs);\n #ifdef Honor_FLT_ROUNDS\n-    if (rounding != 1) {\n-        if (i < 0) {\n-            /* Error is less than an ulp */\n-            if (!delta->x[0] && delta->wds <= 1) {\n-                /* exact */\n-#ifdef SET_INEXACT\n-                inexact = 0;\n-#endif\n-                break;\n-            }\n-            if (rounding) {\n-                if (dsign) {\n-                    adj = 1.;\n-                    goto apply_adj;\n-                }\n-            } else if (!dsign) {\n-                adj = -1.;\n-                if (!word1(rv) && !(word0(rv) & Frac_mask)) {\n-                    y = word0(rv) & Exp_mask;\n-#ifdef Avoid_Underflow\n-                    if (!scale || y > 2 * P * Exp_msk1)\n-#else\n-                    if (y)\n-#endif\n-                    {\n-                        delta = lshift(delta, Log2P);\n-                        if (cmp(delta, bs) <= 0) {\n-                            adj = -0.5;\n-                        }\n-                    }\n-                }\n-            apply_adj:\n-#ifdef Avoid_Underflow\n-                if (scale && (y = word0(rv) & Exp_mask) <= 2 * P * Exp_msk1) {\n-                    word0(adj) += (2 * P + 1) * Exp_msk1 - y;\n-                }\n-#else\n-#ifdef Sudden_Underflow\n-                if ((word0(rv) & Exp_mask) <= P * Exp_msk1) {\n-                    word0(rv) += P * Exp_msk1;\n-                    dval(rv) += adj * ulp(dval(rv));\n-                    word0(rv) -= P * Exp_msk1;\n-                } else\n-#endif /*Sudden_Underflow*/\n-#endif /*Avoid_Underflow*/\n-                dval(rv) += adj * ulp(dval(rv));\n-            }\n-            break;\n-        }\n-        adj = ratio(delta, bs);\n-        if (adj < 1.) {\n-            adj = 1.;\n-        }\n-        if (adj <= 0x7ffffffe) {\n-            /* adj = rounding ? ceil(adj) : floor(adj); */\n-            y = adj;\n-            if (y != adj) {\n-                if (!((rounding >> 1) ^ dsign)) {\n-                    y++;\n-                }\n-                adj = y;\n+  if (rounding != 1) {\n+    if (i < 0) {\n+      /* Error is less than an ulp */\n+      if (!delta->x[0] && delta->wds <= 1) {\n+        /* exact */\n+#  ifdef SET_INEXACT\n+        inexact = 0;\n+#  endif\n+        break;\n+      }\n+      if (rounding) {\n+        if (dsign) {\n+          adj = 1.;\n+          goto apply_adj;\n+        }\n+      } else if (!dsign) {\n+        adj = -1.;\n+        if (!word1(rv) && !(word0(rv) & Frac_mask)) {\n+          y = word0(rv) & Exp_mask;\n+#  ifdef Avoid_Underflow\n+          if (!scale || y > 2 * P * Exp_msk1)\n+#  else\n+          if (y)\n+#  endif\n+          {\n+            delta = lshift(delta, Log2P);\n+            if (cmp(delta, bs) <= 0) {\n+              adj = -0.5;\n             }\n+          }\n         }\n-#ifdef Avoid_Underflow\n+      apply_adj:\n+#  ifdef Avoid_Underflow\n         if (scale && (y = word0(rv) & Exp_mask) <= 2 * P * Exp_msk1) {\n-            word0(adj) += (2 * P + 1) * Exp_msk1 - y;\n+          word0(adj) += (2 * P + 1) * Exp_msk1 - y;\n         }\n-#else\n-#ifdef Sudden_Underflow\n+#  else\n+#    ifdef Sudden_Underflow\n         if ((word0(rv) & Exp_mask) <= P * Exp_msk1) {\n-            word0(rv) += P * Exp_msk1;\n-            adj *= ulp(dval(rv));\n-            if (dsign) {\n-                dval(rv) += adj;\n-            } else {\n-                dval(rv) -= adj;\n-            }\n-            word0(rv) -= P * Exp_msk1;\n-            goto cont;\n-        }\n-#endif /*Sudden_Underflow*/\n-#endif /*Avoid_Underflow*/\n-        adj *= ulp(dval(rv));\n-        if (dsign) {\n-            dval(rv) += adj;\n-        } else {\n-            dval(rv) -= adj;\n-        }\n-        goto cont;\n+          word0(rv) += P * Exp_msk1;\n+          dval(rv) += adj * ulp(dval(rv));\n+          word0(rv) -= P * Exp_msk1;\n+        } else\n+#    endif /*Sudden_Underflow*/\n+#  endif   /*Avoid_Underflow*/\n+        dval(rv) += adj * ulp(dval(rv));\n+      }\n+      break;\n+    }\n+    adj = ratio(delta, bs);\n+    if (adj < 1.) {\n+      adj = 1.;\n+    }\n+    if (adj <= 0x7ffffffe) {\n+      /* adj = rounding ? ceil(adj) : floor(adj); */\n+      y = adj;\n+      if (y != adj) {\n+        if (!((rounding >> 1) ^ dsign)) {\n+          y++;\n+        }\n+        adj = y;\n+      }\n+    }\n+#  ifdef Avoid_Underflow\n+    if (scale && (y = word0(rv) & Exp_mask) <= 2 * P * Exp_msk1) {\n+      word0(adj) += (2 * P + 1) * Exp_msk1 - y;\n+    }\n+#  else\n+#    ifdef Sudden_Underflow\n+    if ((word0(rv) & Exp_mask) <= P * Exp_msk1) {\n+      word0(rv) += P * Exp_msk1;\n+      adj *= ulp(dval(rv));\n+      if (dsign) {\n+        dval(rv) += adj;\n+      } else {\n+        dval(rv) -= adj;\n+      }\n+      word0(rv) -= P * Exp_msk1;\n+      goto cont;\n+    }\n+#    endif /*Sudden_Underflow*/\n+#  endif   /*Avoid_Underflow*/\n+    adj *= ulp(dval(rv));\n+    if (dsign) {\n+      dval(rv) += adj;\n+    } else {\n+      dval(rv) -= adj;\n     }\n+    goto cont;\n+  }\n #endif /*Honor_FLT_ROUNDS*/\n \n-    if (i < 0) {\n-        /* Error is less than half an ulp -- check for\n-         * special case of mantissa a power of two.\n-         */\n-        if (dsign || word1(rv) || word0(rv) & Bndry_mask\n+  if (i < 0) {\n+    /* Error is less than half an ulp -- check for\n+     * special case of mantissa a power of two.\n+     */\n+    if (dsign || word1(rv) || word0(rv) & Bndry_mask\n #ifdef IEEE_Arith\n-#ifdef Avoid_Underflow\n-            || (word0(rv) & Exp_mask) <= (2 * P + 1) * Exp_msk1\n-#else\n-            || (word0(rv) & Exp_mask) <= Exp_msk1\n-#endif\n+#  ifdef Avoid_Underflow\n+        || (word0(rv) & Exp_mask) <= (2 * P + 1) * Exp_msk1\n+#  else\n+        || (word0(rv) & Exp_mask) <= Exp_msk1\n+#  endif\n #endif\n-        ) {\n-#ifdef SET_INEXACT\n-            if (!delta->x[0] && delta->wds <= 1) {\n-                inexact = 0;\n-            }\n-#endif\n-            break;\n-        }\n-        if (!delta->x[0] && delta->wds <= 1) {\n-            /* exact result */\n+    ) {\n #ifdef SET_INEXACT\n-            inexact = 0;\n+      if (!delta->x[0] && delta->wds <= 1) {\n+        inexact = 0;\n+      }\n #endif\n-            break;\n-        }\n-        delta = lshift(delta, Log2P);\n-        if (cmp(delta, bs) > 0) {\n-            goto drop_down;\n-        }\n-        break;\n+      break;\n     }\n-    if (i == 0) {\n-        /* exactly half-way between */\n-        if (dsign) {\n-            if ((word0(rv) & Bndry_mask1) == Bndry_mask1 &&\n-                word1(rv) ==\n-                    (\n+    if (!delta->x[0] && delta->wds <= 1) {\n+      /* exact result */\n+#ifdef SET_INEXACT\n+      inexact = 0;\n+#endif\n+      break;\n+    }\n+    delta = lshift(delta, Log2P);\n+    if (cmp(delta, bs) > 0) {\n+      goto drop_down;\n+    }\n+    break;\n+  }\n+  if (i == 0) {\n+    /* exactly half-way between */\n+    if (dsign) {\n+      if ((word0(rv) & Bndry_mask1) == Bndry_mask1 &&\n+          word1(rv) ==\n+              (\n #ifdef Avoid_Underflow\n-                        (scale && (y = word0(rv) & Exp_mask) <= 2 * P * Exp_msk1)\n-                            ? (0xffffffff &\n-                               (0xffffffff << (2 * P + 1 - (y >> Exp_shift))))\n-                            :\n-#endif\n-                            0xffffffff)) {\n-                /*boundary case -- increment exponent*/\n-                word0(rv) = (word0(rv) & Exp_mask) + Exp_msk1\n+                  (scale && (y = word0(rv) & Exp_mask) <= 2 * P * Exp_msk1)\n+                      ? (0xffffffff &\n+                         (0xffffffff << (2 * P + 1 - (y >> Exp_shift))))\n+                      :\n+#endif\n+                      0xffffffff)) {\n+        /*boundary case -- increment exponent*/\n+        word0(rv) = (word0(rv) & Exp_mask) + Exp_msk1\n #ifdef IBM\n-                            | Exp_msk1 >> 4\n+                    | Exp_msk1 >> 4\n #endif\n-                    ;\n-                word1(rv) = 0;\n+            ;\n+        word1(rv) = 0;\n #ifdef Avoid_Underflow\n-                dsign = 0;\n+        dsign = 0;\n #endif\n-                break;\n-            }\n-        } else if (!(word0(rv) & Bndry_mask) && !word1(rv)) {\n-        drop_down:\n-            /* boundary case -- decrement exponent */\n+        break;\n+      }\n+    } else if (!(word0(rv) & Bndry_mask) && !word1(rv)) {\n+    drop_down:\n+      /* boundary case -- decrement exponent */\n #ifdef Sudden_Underflow /*{{*/\n-            L = word0(rv) & Exp_mask;\n-#ifdef IBM\n-            if (L < Exp_msk1)\n-#else\n-#ifdef Avoid_Underflow\n-            if (L <= (scale ? (2 * P + 1) * Exp_msk1 : Exp_msk1))\n-#else\n-            if (L <= Exp_msk1)\n-#endif /*Avoid_Underflow*/\n-#endif /*IBM*/\n-                goto undfl;\n-            L -= Exp_msk1;\n+      L = word0(rv) & Exp_mask;\n+#  ifdef IBM\n+      if (L < Exp_msk1)\n+#  else\n+#    ifdef Avoid_Underflow\n+      if (L <= (scale ? (2 * P + 1) * Exp_msk1 : Exp_msk1))\n+#    else\n+      if (L <= Exp_msk1)\n+#    endif /*Avoid_Underflow*/\n+#  endif   /*IBM*/\n+        goto undfl;\n+      L -= Exp_msk1;\n #else /*Sudden_Underflow}{*/\n-#ifdef Avoid_Underflow\n-                    if (scale) {\n-                        L = word0(rv) & Exp_mask;\n-                        if (L <= (2 * P + 1) * Exp_msk1) {\n-                            if (L > (P + 2) * Exp_msk1)\n-                            /* round even ==> */\n-                            /* accept rv */\n-                            {\n-                                break;\n-                            }\n-                            /* rv = smallest denormal */\n-                            goto undfl;\n-                        }\n-                    }\n-#endif /*Avoid_Underflow*/\n-                    L = (word0(rv) & Exp_mask) - Exp_msk1;\n-#endif /*Sudden_Underflow}}*/\n-            word0(rv) = L | Bndry_mask1;\n-            word1(rv) = 0xffffffff;\n+#  ifdef Avoid_Underflow\n+          if (scale) {\n+            L = word0(rv) & Exp_mask;\n+            if (L <= (2 * P + 1) * Exp_msk1) {\n+              if (L > (P + 2) * Exp_msk1)\n+              /* round even ==> */\n+              /* accept rv */\n+              {\n+                break;\n+              }\n+              /* rv = smallest denormal */\n+              goto undfl;\n+            }\n+          }\n+#  endif /*Avoid_Underflow*/\n+          L = (word0(rv) & Exp_mask) - Exp_msk1;\n+#endif   /*Sudden_Underflow}}*/\n+      word0(rv) = L | Bndry_mask1;\n+      word1(rv) = 0xffffffff;\n #ifdef IBM\n-            goto cont;\n+      goto cont;\n #else\n-                    break;\n+          break;\n #endif\n-        }\n-#ifndef ROUND_BIASED\n-        if (!(word1(rv) & LSB)) {\n-            break;\n-        }\n-#endif\n-        if (dsign) {\n-            dval(rv) += ulp(dval(rv));\n-        }\n+    }\n #ifndef ROUND_BIASED\n-        else {\n-            dval(rv) -= ulp(dval(rv));\n-#ifndef Sudden_Underflow\n-            if (!dval(rv)) {\n-                goto undfl;\n-            }\n-#endif\n-        }\n-#ifdef Avoid_Underflow\n-        dsign = 1 - dsign;\n-#endif\n+    if (!(word1(rv) & LSB)) {\n+      break;\n+    }\n #endif\n-        break;\n+    if (dsign) {\n+      dval(rv) += ulp(dval(rv));\n     }\n-    if ((aadj = ratio(delta, bs)) <= 2.) {\n-        if (dsign) {\n-            aadj = aadj1 = 1.;\n-        } else if (word1(rv) || word0(rv) & Bndry_mask) {\n+#ifndef ROUND_BIASED\n+    else {\n+      dval(rv) -= ulp(dval(rv));\n+#  ifndef Sudden_Underflow\n+      if (!dval(rv)) {\n+        goto undfl;\n+      }\n+#  endif\n+    }\n+#  ifdef Avoid_Underflow\n+    dsign = 1 - dsign;\n+#  endif\n+#endif\n+    break;\n+  }\n+  if ((aadj = ratio(delta, bs)) <= 2.) {\n+    if (dsign) {\n+      aadj = aadj1 = 1.;\n+    } else if (word1(rv) || word0(rv) & Bndry_mask) {\n #ifndef Sudden_Underflow\n-            if (word1(rv) == Tiny1 && !word0(rv)) {\n-                goto undfl;\n-            }\n+      if (word1(rv) == Tiny1 && !word0(rv)) {\n+        goto undfl;\n+      }\n #endif\n-            aadj = 1.;\n-            aadj1 = -1.;\n-        } else {\n-            /* special case -- power of FLT_RADIX to be */\n-            /* rounded down... */\n-\n-            if (aadj < 2. / FLT_RADIX) {\n-                aadj = 1. / FLT_RADIX;\n-            } else {\n-                aadj *= 0.5;\n-            }\n-            aadj1 = -aadj;\n-        }\n+      aadj = 1.;\n+      aadj1 = -1.;\n     } else {\n+      /* special case -- power of FLT_RADIX to be */\n+      /* rounded down... */\n+\n+      if (aadj < 2. / FLT_RADIX) {\n+        aadj = 1. / FLT_RADIX;\n+      } else {\n         aadj *= 0.5;\n-        aadj1 = dsign ? aadj : -aadj;\n+      }\n+      aadj1 = -aadj;\n+    }\n+  } else {\n+    aadj *= 0.5;\n+    aadj1 = dsign ? aadj : -aadj;\n #ifdef Check_FLT_ROUNDS\n-        switch (Rounding) {\n-            case 2: /* towards +infinity */\n-                aadj1 -= 0.5;\n-                break;\n-            case 0: /* towards 0 */\n-            case 3: /* towards -infinity */\n-                aadj1 += 0.5;\n-        }\n+    switch (Rounding) {\n+      case 2: /* towards +infinity */\n+        aadj1 -= 0.5;\n+        break;\n+      case 0: /* towards 0 */\n+      case 3: /* towards -infinity */\n+        aadj1 += 0.5;\n+    }\n #else\n-                if (Flt_Rounds == 0) {\n-                    aadj1 += 0.5;\n-                }\n+        if (Flt_Rounds == 0) {\n+          aadj1 += 0.5;\n+        }\n #endif /*Check_FLT_ROUNDS*/\n+  }\n+  y = word0(rv) & Exp_mask;\n+\n+  /* Check for overflow */\n+\n+  if (y == Exp_msk1 * (DBL_MAX_EXP + Bias - 1)) {\n+    dval(rv0) = dval(rv);\n+    word0(rv) -= P * Exp_msk1;\n+    adj = aadj1 * ulp(dval(rv));\n+    dval(rv) += adj;\n+    if ((word0(rv) & Exp_mask) >= Exp_msk1 * (DBL_MAX_EXP + Bias - P)) {\n+      if (word0(rv0) == Big0 && word1(rv0) == Big1) {\n+        goto ovfl;\n+      }\n+      word0(rv) = Big0;\n+      word1(rv) = Big1;\n+      goto cont;\n+    } else {\n+      word0(rv) += P * Exp_msk1;\n     }\n-    y = word0(rv) & Exp_mask;\n-\n-    /* Check for overflow */\n-\n-    if (y == Exp_msk1 * (DBL_MAX_EXP + Bias - 1)) {\n-        dval(rv0) = dval(rv);\n-        word0(rv) -= P * Exp_msk1;\n-        adj = aadj1 * ulp(dval(rv));\n-        dval(rv) += adj;\n-        if ((word0(rv) & Exp_mask) >= Exp_msk1 * (DBL_MAX_EXP + Bias - P)) {\n-            if (word0(rv0) == Big0 && word1(rv0) == Big1) {\n-                goto ovfl;\n+  } else {\n+#ifdef Avoid_Underflow\n+    if (scale && y <= 2 * P * Exp_msk1) {\n+      if (aadj <= 0x7fffffff) {\n+        if ((z = aadj) <= 0) {\n+          z = 1;\n+        }\n+        aadj = z;\n+        aadj1 = dsign ? aadj : -aadj;\n+      }\n+      dval(aadj2) = aadj1;\n+      word0(aadj2) += (2 * P + 1) * Exp_msk1 - y;\n+      aadj1 = dval(aadj2);\n+    }\n+    adj = aadj1 * ulp(dval(rv));\n+    dval(rv) += adj;\n+#else\n+#  ifdef Sudden_Underflow\n+        if ((word0(rv) & Exp_mask) <= P * Exp_msk1) {\n+          dval(rv0) = dval(rv);\n+          word0(rv) += P * Exp_msk1;\n+          adj = aadj1 * ulp(dval(rv));\n+          dval(rv) += adj;\n+#    ifdef IBM\n+          if ((word0(rv) & Exp_mask) < P * Exp_msk1)\n+#    else\n+          if ((word0(rv) & Exp_mask) <= P * Exp_msk1)\n+#    endif\n+          {\n+            if (word0(rv0) == Tiny0 && word1(rv0) == Tiny1) {\n+              goto undfl;\n             }\n-            word0(rv) = Big0;\n-            word1(rv) = Big1;\n+            word0(rv) = Tiny0;\n+            word1(rv) = Tiny1;\n             goto cont;\n+          } else {\n+            word0(rv) -= P * Exp_msk1;\n+          }\n         } else {\n-            word0(rv) += P * Exp_msk1;\n-        }\n-    } else {\n-#ifdef Avoid_Underflow\n-        if (scale && y <= 2 * P * Exp_msk1) {\n-            if (aadj <= 0x7fffffff) {\n-                if ((z = aadj) <= 0) {\n-                    z = 1;\n-                }\n-                aadj = z;\n-                aadj1 = dsign ? aadj : -aadj;\n-            }\n-            dval(aadj2) = aadj1;\n-            word0(aadj2) += (2 * P + 1) * Exp_msk1 - y;\n-            aadj1 = dval(aadj2);\n+          adj = aadj1 * ulp(dval(rv));\n+          dval(rv) += adj;\n+        }\n+#  else  /*Sudden_Underflow*/\n+        /* Compute adj so that the IEEE rounding rules will\n+         * correctly round rv + adj in some half-way cases.\n+         * If rv * ulp(rv) is denormalized (i.e.,\n+         * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid\n+         * trouble from bits lost to denormalization;\n+         * example: 1.2e-307 .\n+         */\n+        if (y <= (P - 1) * Exp_msk1 && aadj > 1.) {\n+          aadj1 = (double)(int)(aadj + 0.5);\n+          if (!dsign) {\n+            aadj1 = -aadj1;\n+          }\n         }\n         adj = aadj1 * ulp(dval(rv));\n         dval(rv) += adj;\n-#else\n-#ifdef Sudden_Underflow\n-                if ((word0(rv) & Exp_mask) <= P * Exp_msk1) {\n-                    dval(rv0) = dval(rv);\n-                    word0(rv) += P * Exp_msk1;\n-                    adj = aadj1 * ulp(dval(rv));\n-                    dval(rv) += adj;\n-#ifdef IBM\n-                    if ((word0(rv) & Exp_mask) < P * Exp_msk1)\n-#else\n-                    if ((word0(rv) & Exp_mask) <= P * Exp_msk1)\n-#endif\n-                    {\n-                        if (word0(rv0) == Tiny0 && word1(rv0) == Tiny1) {\n-                            goto undfl;\n-                        }\n-                        word0(rv) = Tiny0;\n-                        word1(rv) = Tiny1;\n-                        goto cont;\n-                    } else {\n-                        word0(rv) -= P * Exp_msk1;\n-                    }\n-                } else {\n-                    adj = aadj1 * ulp(dval(rv));\n-                    dval(rv) += adj;\n-                }\n-#else  /*Sudden_Underflow*/\n-                /* Compute adj so that the IEEE rounding rules will\n-                 * correctly round rv + adj in some half-way cases.\n-                 * If rv * ulp(rv) is denormalized (i.e.,\n-                 * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid\n-                 * trouble from bits lost to denormalization;\n-                 * example: 1.2e-307 .\n-                 */\n-                if (y <= (P - 1) * Exp_msk1 && aadj > 1.) {\n-                    aadj1 = (double)(int)(aadj + 0.5);\n-                    if (!dsign) {\n-                        aadj1 = -aadj1;\n-                    }\n-                }\n-                adj = aadj1 * ulp(dval(rv));\n-                dval(rv) += adj;\n-#endif /*Sudden_Underflow*/\n-#endif /*Avoid_Underflow*/\n-    }\n-    z = word0(rv) & Exp_mask;\n+#  endif /*Sudden_Underflow*/\n+#endif   /*Avoid_Underflow*/\n+  }\n+  z = word0(rv) & Exp_mask;\n #ifndef SET_INEXACT\n-#ifdef Avoid_Underflow\n-    if (!scale)\n-#endif\n-        if (y == z) {\n-            /* Can we stop now? */\n-            L = (Long)aadj;\n-            aadj -= L;\n-            /* The tolerances below are conservative. */\n-            if (dsign || word1(rv) || word0(rv) & Bndry_mask) {\n-                if (aadj < .4999999 || aadj > .5000001) {\n-                    break;\n-                }\n-            } else if (aadj < .4999999 / FLT_RADIX) {\n-                break;\n-            }\n-        }\n+#  ifdef Avoid_Underflow\n+  if (!scale)\n+#  endif\n+    if (y == z) {\n+      /* Can we stop now? */\n+      L = (Long)aadj;\n+      aadj -= L;\n+      /* The tolerances below are conservative. */\n+      if (dsign || word1(rv) || word0(rv) & Bndry_mask) {\n+        if (aadj < .4999999 || aadj > .5000001) {\n+          break;\n+        }\n+      } else if (aadj < .4999999 / FLT_RADIX) {\n+        break;\n+      }\n+    }\n #endif\n cont:\n-    Bfree(bb);\n-    Bfree(bd);\n-    Bfree(bs);\n-    Bfree(delta);\n+  Bfree(bb);\n+  Bfree(bd);\n+  Bfree(bs);\n+  Bfree(delta);\n }\n #ifdef SET_INEXACT\n if (inexact) {\n-    if (!oldinexact) {\n-        word0(rv0) = Exp_1 + (70 << Exp_shift);\n-        word1(rv0) = 0;\n-        dval(rv0) += 1.;\n-    }\n+  if (!oldinexact) {\n+    word0(rv0) = Exp_1 + (70 << Exp_shift);\n+    word1(rv0) = 0;\n+    dval(rv0) += 1.;\n+  }\n } else if (!oldinexact) {\n-    clear_inexact();\n+  clear_inexact();\n }\n #endif\n #ifdef Avoid_Underflow\n if (scale) {\n-    word0(rv0) = Exp_1 - 2 * P * Exp_msk1;\n-    word1(rv0) = 0;\n-    dval(rv) *= dval(rv0);\n-#ifndef NO_ERRNO\n-    /* try to avoid the bug of testing an 8087 register value */\n-    if (word0(rv) == 0 && word1(rv) == 0) {\n-        PR_SetError(PR_RANGE_ERROR, 0);\n-    }\n-#endif\n+  word0(rv0) = Exp_1 - 2 * P * Exp_msk1;\n+  word1(rv0) = 0;\n+  dval(rv) *= dval(rv0);\n+#  ifndef NO_ERRNO\n+  /* try to avoid the bug of testing an 8087 register value */\n+  if (word0(rv) == 0 && word1(rv) == 0) {\n+    PR_SetError(PR_RANGE_ERROR, 0);\n+  }\n+#  endif\n }\n #endif /* Avoid_Underflow */\n #ifdef SET_INEXACT\n if (inexact && !(word0(rv) & Exp_mask)) {\n-    /* set underflow bit */\n-    dval(rv0) = 1e-300;\n-    dval(rv0) *= dval(rv0);\n+  /* set underflow bit */\n+  dval(rv0) = 1e-300;\n+  dval(rv0) *= dval(rv0);\n }\n #endif\n retfree: Bfree(bb);\n@@ -2567,135 +2559,131 @@ Bfree(bd);\n Bfree(bs);\n Bfree(bd0);\n Bfree(delta);\n-ret: if (se)\n-{\n-    *se = (char*)s;\n-}\n+ret: if (se) { *se = (char*)s; }\n return sign ? -dval(rv) : dval(rv);\n }\n \n-static int\n-quorem\n+static int quorem\n #ifdef KR_headers\n     (b, S)\n Bigint *b, *S;\n #else\n-        (Bigint * b, Bigint * S)\n+      (Bigint * b, Bigint * S)\n #endif\n {\n-    int n;\n-    ULong *bx, *bxe, q, *sx, *sxe;\n+  int n;\n+  ULong *bx, *bxe, q, *sx, *sxe;\n #ifdef ULLong\n-    ULLong borrow, carry, y, ys;\n+  ULLong borrow, carry, y, ys;\n #else\n-        ULong borrow, carry, y, ys;\n-#ifdef Pack_32\n-        ULong si, z, zs;\n-#endif\n+    ULong borrow, carry, y, ys;\n+#  ifdef Pack_32\n+    ULong si, z, zs;\n+#  endif\n #endif\n \n-    n = S->wds;\n+  n = S->wds;\n #ifdef DEBUG\n-    /*debug*/ if (b->wds > n)\n-    /*debug*/ {\n-        Bug(\"oversize b in quorem\");\n-    }\n+  /*debug*/ if (b->wds > n)\n+  /*debug*/ {\n+    Bug(\"oversize b in quorem\");\n+  }\n #endif\n-    if (b->wds < n) {\n-        return 0;\n-    }\n-    sx = S->x;\n-    sxe = sx + --n;\n-    bx = b->x;\n-    bxe = bx + n;\n-    q = *bxe / (*sxe + 1); /* ensure q <= true quotient */\n+  if (b->wds < n) {\n+    return 0;\n+  }\n+  sx = S->x;\n+  sxe = sx + --n;\n+  bx = b->x;\n+  bxe = bx + n;\n+  q = *bxe / (*sxe + 1); /* ensure q <= true quotient */\n #ifdef DEBUG\n-    /*debug*/ if (q > 9)\n-    /*debug*/ {\n-        Bug(\"oversized quotient in quorem\");\n-    }\n+  /*debug*/ if (q > 9)\n+  /*debug*/ {\n+    Bug(\"oversized quotient in quorem\");\n+  }\n #endif\n-    if (q) {\n-        borrow = 0;\n-        carry = 0;\n-        do {\n+  if (q) {\n+    borrow = 0;\n+    carry = 0;\n+    do {\n #ifdef ULLong\n-            ys = *sx++ * (ULLong)q + carry;\n-            carry = ys >> 32;\n-            y = *bx - (ys & FFFFFFFF) - borrow;\n-            borrow = y >> 32 & (ULong)1;\n-            *bx++ = y & FFFFFFFF;\n-#else\n-#ifdef Pack_32\n-                si = *sx++;\n-                ys = (si & 0xffff) * q + carry;\n-                zs = (si >> 16) * q + (ys >> 16);\n-                carry = zs >> 16;\n-                y = (*bx & 0xffff) - (ys & 0xffff) - borrow;\n-                borrow = (y & 0x10000) >> 16;\n-                z = (*bx >> 16) - (zs & 0xffff) - borrow;\n-                borrow = (z & 0x10000) >> 16;\n-                Storeinc(bx, z, y);\n-#else\n-                ys = *sx++ * q + carry;\n-                carry = ys >> 16;\n-                y = *bx - (ys & 0xffff) - borrow;\n-                borrow = (y & 0x10000) >> 16;\n-                *bx++ = y & 0xffff;\n-#endif\n-#endif\n-        } while (sx <= sxe);\n-        if (!*bxe) {\n-            bx = b->x;\n-            while (--bxe > bx && !*bxe) {\n-                --n;\n-            }\n-            b->wds = n;\n-        }\n-    }\n-    if (cmp(b, S) >= 0) {\n-        q++;\n-        borrow = 0;\n-        carry = 0;\n-        bx = b->x;\n-        sx = S->x;\n-        do {\n+      ys = *sx++ * (ULLong)q + carry;\n+      carry = ys >> 32;\n+      y = *bx - (ys & FFFFFFFF) - borrow;\n+      borrow = y >> 32 & (ULong)1;\n+      *bx++ = y & FFFFFFFF;\n+#else\n+#  ifdef Pack_32\n+        si = *sx++;\n+        ys = (si & 0xffff) * q + carry;\n+        zs = (si >> 16) * q + (ys >> 16);\n+        carry = zs >> 16;\n+        y = (*bx & 0xffff) - (ys & 0xffff) - borrow;\n+        borrow = (y & 0x10000) >> 16;\n+        z = (*bx >> 16) - (zs & 0xffff) - borrow;\n+        borrow = (z & 0x10000) >> 16;\n+        Storeinc(bx, z, y);\n+#  else\n+        ys = *sx++ * q + carry;\n+        carry = ys >> 16;\n+        y = *bx - (ys & 0xffff) - borrow;\n+        borrow = (y & 0x10000) >> 16;\n+        *bx++ = y & 0xffff;\n+#  endif\n+#endif\n+    } while (sx <= sxe);\n+    if (!*bxe) {\n+      bx = b->x;\n+      while (--bxe > bx && !*bxe) {\n+        --n;\n+      }\n+      b->wds = n;\n+    }\n+  }\n+  if (cmp(b, S) >= 0) {\n+    q++;\n+    borrow = 0;\n+    carry = 0;\n+    bx = b->x;\n+    sx = S->x;\n+    do {\n #ifdef ULLong\n-            ys = *sx++ + carry;\n-            carry = ys >> 32;\n-            y = *bx - (ys & FFFFFFFF) - borrow;\n-            borrow = y >> 32 & (ULong)1;\n-            *bx++ = y & FFFFFFFF;\n-#else\n-#ifdef Pack_32\n-                si = *sx++;\n-                ys = (si & 0xffff) + carry;\n-                zs = (si >> 16) + (ys >> 16);\n-                carry = zs >> 16;\n-                y = (*bx & 0xffff) - (ys & 0xffff) - borrow;\n-                borrow = (y & 0x10000) >> 16;\n-                z = (*bx >> 16) - (zs & 0xffff) - borrow;\n-                borrow = (z & 0x10000) >> 16;\n-                Storeinc(bx, z, y);\n-#else\n-                ys = *sx++ + carry;\n-                carry = ys >> 16;\n-                y = *bx - (ys & 0xffff) - borrow;\n-                borrow = (y & 0x10000) >> 16;\n-                *bx++ = y & 0xffff;\n-#endif\n-#endif\n-        } while (sx <= sxe);\n-        bx = b->x;\n-        bxe = bx + n;\n-        if (!*bxe) {\n-            while (--bxe > bx && !*bxe) {\n-                --n;\n-            }\n-            b->wds = n;\n-        }\n+      ys = *sx++ + carry;\n+      carry = ys >> 32;\n+      y = *bx - (ys & FFFFFFFF) - borrow;\n+      borrow = y >> 32 & (ULong)1;\n+      *bx++ = y & FFFFFFFF;\n+#else\n+#  ifdef Pack_32\n+        si = *sx++;\n+        ys = (si & 0xffff) + carry;\n+        zs = (si >> 16) + (ys >> 16);\n+        carry = zs >> 16;\n+        y = (*bx & 0xffff) - (ys & 0xffff) - borrow;\n+        borrow = (y & 0x10000) >> 16;\n+        z = (*bx >> 16) - (zs & 0xffff) - borrow;\n+        borrow = (z & 0x10000) >> 16;\n+        Storeinc(bx, z, y);\n+#  else\n+        ys = *sx++ + carry;\n+        carry = ys >> 16;\n+        y = *bx - (ys & 0xffff) - borrow;\n+        borrow = (y & 0x10000) >> 16;\n+        *bx++ = y & 0xffff;\n+#  endif\n+#endif\n+    } while (sx <= sxe);\n+    bx = b->x;\n+    bxe = bx + n;\n+    if (!*bxe) {\n+      while (--bxe > bx && !*bxe) {\n+        --n;\n+      }\n+      b->wds = n;\n     }\n-    return q;\n+  }\n+  return q;\n }\n \n #ifndef MULTIPLE_THREADS\n@@ -2707,22 +2695,22 @@ static char*\n rv_alloc(i)\n int i;\n #else\n-    rv_alloc(int i)\n+  rv_alloc(int i)\n #endif\n {\n-    int j, k, *r;\n+  int j, k, *r;\n \n-    j = sizeof(ULong);\n-    for (k = 0; sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i; j <<= 1) {\n-        k++;\n-    }\n-    r = (int*)Balloc(k);\n-    *r = k;\n-    return\n+  j = sizeof(ULong);\n+  for (k = 0; sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i; j <<= 1) {\n+    k++;\n+  }\n+  r = (int*)Balloc(k);\n+  *r = k;\n+  return\n #ifndef MULTIPLE_THREADS\n-        dtoa_result =\n+      dtoa_result =\n #endif\n-            (char*)(r + 1);\n+          (char*)(r + 1);\n }\n \n static char*\n@@ -2731,19 +2719,19 @@ nrv_alloc(s, rve, n)\n char *s, **rve;\n int n;\n #else\n-    nrv_alloc(char* s, char** rve, int n)\n+  nrv_alloc(char* s, char** rve, int n)\n #endif\n {\n-    char *rv, *t;\n+  char *rv, *t;\n \n-    t = rv = rv_alloc(n);\n-    while (*t = *s++) {\n-        t++;\n-    }\n-    if (rve) {\n-        *rve = t;\n-    }\n-    return rv;\n+  t = rv = rv_alloc(n);\n+  while (*t = *s++) {\n+    t++;\n+  }\n+  if (rve) {\n+    *rve = t;\n+  }\n+  return rv;\n }\n \n /* freedtoa(s) must be used to free values s returned by dtoa\n@@ -2756,16 +2744,16 @@ static void\n #ifdef KR_headers\n     freedtoa(s) char* s;\n #else\n-    freedtoa(char* s)\n+  freedtoa(char* s)\n #endif\n {\n-    Bigint* b = (Bigint*)((int*)s - 1);\n-    b->maxwds = 1 << (b->k = *(int*)b);\n-    Bfree(b);\n+  Bigint* b = (Bigint*)((int*)s - 1);\n+  b->maxwds = 1 << (b->k = *(int*)b);\n+  Bfree(b);\n #ifndef MULTIPLE_THREADS\n-    if (s == dtoa_result) {\n-        dtoa_result = 0;\n-    }\n+  if (s == dtoa_result) {\n+    dtoa_result = 0;\n+  }\n #endif\n }\n \n@@ -2803,467 +2791,463 @@ static void\n  *     calculation.\n  */\n \n-static char*\n-dtoa\n+static char* dtoa\n #ifdef KR_headers\n     (dd, mode, ndigits, decpt, sign, rve)\n double dd;\n int mode, ndigits, *decpt, *sign;\n char** rve;\n #else\n-        (double dd, int mode, int ndigits, int* decpt, int* sign, char** rve)\n+      (double dd, int mode, int ndigits, int* decpt, int* sign, char** rve)\n #endif\n {\n-    /* Arguments ndigits, decpt, sign are similar to those\n-    of ecvt and fcvt; trailing zeros are suppressed from\n-    the returned string.  If not null, *rve is set to point\n-    to the end of the return value.  If d is +-Infinity or NaN,\n-    then *decpt is set to 9999.\n-\n-    mode:\n-       0 ==> shortest string that yields d when read in\n-           and rounded to nearest.\n-       1 ==> like 0, but with Steele & White stopping rule;\n-           e.g. with IEEE P754 arithmetic , mode 0 gives\n-           1e23 whereas mode 1 gives 9.999999999999999e22.\n-       2 ==> max(1,ndigits) significant digits.  This gives a\n-           return value similar to that of ecvt, except\n-           that trailing zeros are suppressed.\n-       3 ==> through ndigits past the decimal point.  This\n-           gives a return value similar to that from fcvt,\n-           except that trailing zeros are suppressed, and\n-           ndigits can be negative.\n-       4,5 ==> similar to 2 and 3, respectively, but (in\n-           round-nearest mode) with the tests of mode 0 to\n-           possibly return a shorter string that rounds to d.\n-           With IEEE arithmetic and compilation with\n-           -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same\n-           as modes 2 and 3 when FLT_ROUNDS != 1.\n-       6-9 ==> Debugging modes similar to mode - 4:  don't try\n-           fast floating-point estimate (if applicable).\n-\n-       Values of mode other than 0-9 are treated as mode 0.\n-\n-       Sufficient space is allocated to the return value\n-       to hold the suppressed trailing zeros.\n-    */\n-\n-    int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, j, j1, k, k0,\n-        k_check, leftright, m2, m5, s2, s5, spec_case, try_quick;\n-    Long L;\n+  /* Arguments ndigits, decpt, sign are similar to those\n+  of ecvt and fcvt; trailing zeros are suppressed from\n+  the returned string.  If not null, *rve is set to point\n+  to the end of the return value.  If d is +-Infinity or NaN,\n+  then *decpt is set to 9999.\n+\n+  mode:\n+     0 ==> shortest string that yields d when read in\n+         and rounded to nearest.\n+     1 ==> like 0, but with Steele & White stopping rule;\n+         e.g. with IEEE P754 arithmetic , mode 0 gives\n+         1e23 whereas mode 1 gives 9.999999999999999e22.\n+     2 ==> max(1,ndigits) significant digits.  This gives a\n+         return value similar to that of ecvt, except\n+         that trailing zeros are suppressed.\n+     3 ==> through ndigits past the decimal point.  This\n+         gives a return value similar to that from fcvt,\n+         except that trailing zeros are suppressed, and\n+         ndigits can be negative.\n+     4,5 ==> similar to 2 and 3, respectively, but (in\n+         round-nearest mode) with the tests of mode 0 to\n+         possibly return a shorter string that rounds to d.\n+         With IEEE arithmetic and compilation with\n+         -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same\n+         as modes 2 and 3 when FLT_ROUNDS != 1.\n+     6-9 ==> Debugging modes similar to mode - 4:  don't try\n+         fast floating-point estimate (if applicable).\n+\n+     Values of mode other than 0-9 are treated as mode 0.\n+\n+     Sufficient space is allocated to the return value\n+     to hold the suppressed trailing zeros.\n+  */\n+\n+  int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, j, j1, k, k0,\n+      k_check, leftright, m2, m5, s2, s5, spec_case, try_quick;\n+  Long L;\n #ifndef Sudden_Underflow\n-    int denorm;\n-    ULong x;\n+  int denorm;\n+  ULong x;\n #endif\n-    Bigint *b, *b1, *delta, *mlo, *mhi, *S;\n-    U d, d2, eps;\n-    double ds;\n-    char *s, *s0;\n+  Bigint *b, *b1, *delta, *mlo, *mhi, *S;\n+  U d, d2, eps;\n+  double ds;\n+  char *s, *s0;\n #ifdef Honor_FLT_ROUNDS\n-    int rounding;\n+  int rounding;\n #endif\n #ifdef SET_INEXACT\n-    int inexact, oldinexact;\n+  int inexact, oldinexact;\n #endif\n \n #ifndef MULTIPLE_THREADS\n-    if (dtoa_result) {\n-        freedtoa(dtoa_result);\n-        dtoa_result = 0;\n-    }\n+  if (dtoa_result) {\n+    freedtoa(dtoa_result);\n+    dtoa_result = 0;\n+  }\n #endif\n \n-    dval(d) = dd;\n-    if (word0(d) & Sign_bit) {\n-        /* set sign for everything, including 0's and NaNs */\n-        *sign = 1;\n-        word0(d) &= ~Sign_bit; /* clear sign bit */\n-    } else {\n-        *sign = 0;\n-    }\n+  dval(d) = dd;\n+  if (word0(d) & Sign_bit) {\n+    /* set sign for everything, including 0's and NaNs */\n+    *sign = 1;\n+    word0(d) &= ~Sign_bit; /* clear sign bit */\n+  } else {\n+    *sign = 0;\n+  }\n \n #if defined(IEEE_Arith) + defined(VAX)\n-#ifdef IEEE_Arith\n-    if ((word0(d) & Exp_mask) == Exp_mask)\n-#else\n-    if (word0(d) == 0x8000)\n-#endif\n-    {\n-        /* Infinity or NaN */\n-        *decpt = 9999;\n-#ifdef IEEE_Arith\n-        if (!word1(d) && !(word0(d) & 0xfffff)) {\n-            return nrv_alloc(\"Infinity\", rve, 8);\n-        }\n-#endif\n-        return nrv_alloc(\"NaN\", rve, 3);\n-    }\n+#  ifdef IEEE_Arith\n+  if ((word0(d) & Exp_mask) == Exp_mask)\n+#  else\n+  if (word0(d) == 0x8000)\n+#  endif\n+  {\n+    /* Infinity or NaN */\n+    *decpt = 9999;\n+#  ifdef IEEE_Arith\n+    if (!word1(d) && !(word0(d) & 0xfffff)) {\n+      return nrv_alloc(\"Infinity\", rve, 8);\n+    }\n+#  endif\n+    return nrv_alloc(\"NaN\", rve, 3);\n+  }\n #endif\n #ifdef IBM\n-    dval(d) += 0; /* normalize */\n+  dval(d) += 0; /* normalize */\n #endif\n-    if (!dval(d)) {\n-        *decpt = 1;\n-        return nrv_alloc(\"0\", rve, 1);\n-    }\n+  if (!dval(d)) {\n+    *decpt = 1;\n+    return nrv_alloc(\"0\", rve, 1);\n+  }\n \n #ifdef SET_INEXACT\n-    try_quick = oldinexact = get_inexact();\n-    inexact = 1;\n+  try_quick = oldinexact = get_inexact();\n+  inexact = 1;\n #endif\n #ifdef Honor_FLT_ROUNDS\n-    if ((rounding = Flt_Rounds) >= 2) {\n-        if (*sign) {\n-            rounding = rounding == 2 ? 0 : 2;\n-        } else if (rounding != 2) {\n-            rounding = 0;\n-        }\n+  if ((rounding = Flt_Rounds) >= 2) {\n+    if (*sign) {\n+      rounding = rounding == 2 ? 0 : 2;\n+    } else if (rounding != 2) {\n+      rounding = 0;\n     }\n+  }\n #endif\n \n-    b = d2b(dval(d), &be, &bbits);\n+  b = d2b(dval(d), &be, &bbits);\n #ifdef Sudden_Underflow\n-    i = (int)(word0(d) >> Exp_shift1 & (Exp_mask >> Exp_shift1));\n+  i = (int)(word0(d) >> Exp_shift1 & (Exp_mask >> Exp_shift1));\n #else\n-        if (i = (int)(word0(d) >> Exp_shift1 & (Exp_mask >> Exp_shift1))) {\n+    if (i = (int)(word0(d) >> Exp_shift1 & (Exp_mask >> Exp_shift1))) {\n #endif\n-    dval(d2) = dval(d);\n-    word0(d2) &= Frac_mask1;\n-    word0(d2) |= Exp_11;\n+  dval(d2) = dval(d);\n+  word0(d2) &= Frac_mask1;\n+  word0(d2) |= Exp_11;\n #ifdef IBM\n-    if (j = 11 - hi0bits(word0(d2) & Frac_mask)) {\n-        dval(d2) /= 1 << j;\n-    }\n-#endif\n-\n-    /* log(x)   ~=~ log(1.5) + (x-1.5)/1.5\n-     * log10(x)  =  log(x) / log(10)\n-     *      ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))\n-     * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)\n-     *\n-     * This suggests computing an approximation k to log10(d) by\n-     *\n-     * k = (i - Bias)*0.301029995663981\n-     *  + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );\n-     *\n-     * We want k to be too large rather than too small.\n-     * The error in the first-order Taylor series approximation\n-     * is in our favor, so we just round up the constant enough\n-     * to compensate for any error in the multiplication of\n-     * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,\n-     * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,\n-     * adding 1e-13 to the constant term more than suffices.\n-     * Hence we adjust the constant term to 0.1760912590558.\n-     * (We could get a more accurate k by invoking log10,\n-     *  but this is probably not worthwhile.)\n-     */\n-\n-    i -= Bias;\n+  if (j = 11 - hi0bits(word0(d2) & Frac_mask)) {\n+    dval(d2) /= 1 << j;\n+  }\n+#endif\n+\n+  /* log(x)   ~=~ log(1.5) + (x-1.5)/1.5\n+   * log10(x)  =  log(x) / log(10)\n+   *      ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))\n+   * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)\n+   *\n+   * This suggests computing an approximation k to log10(d) by\n+   *\n+   * k = (i - Bias)*0.301029995663981\n+   *  + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );\n+   *\n+   * We want k to be too large rather than too small.\n+   * The error in the first-order Taylor series approximation\n+   * is in our favor, so we just round up the constant enough\n+   * to compensate for any error in the multiplication of\n+   * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,\n+   * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,\n+   * adding 1e-13 to the constant term more than suffices.\n+   * Hence we adjust the constant term to 0.1760912590558.\n+   * (We could get a more accurate k by invoking log10,\n+   *  but this is probably not worthwhile.)\n+   */\n+\n+  i -= Bias;\n #ifdef IBM\n-    i <<= 2;\n-    i += j;\n+  i <<= 2;\n+  i += j;\n #endif\n #ifndef Sudden_Underflow\n-    denorm = 0;\n+  denorm = 0;\n }\n-else\n-{\n-    /* d is denormalized */\n-\n-    i = bbits + be + (Bias + (P - 1) - 1);\n-    x = i > 32 ? word0(d) << 64 - i | word1(d) >> i - 32 : word1(d) << 32 - i;\n-    dval(d2) = x;\n-    word0(d2) -= 31 * Exp_msk1; /* adjust exponent */\n-    i -= (Bias + (P - 1) - 1) + 1;\n-    denorm = 1;\n+else {\n+  /* d is denormalized */\n+\n+  i = bbits + be + (Bias + (P - 1) - 1);\n+  x = i > 32 ? word0(d) << 64 - i | word1(d) >> i - 32 : word1(d) << 32 - i;\n+  dval(d2) = x;\n+  word0(d2) -= 31 * Exp_msk1; /* adjust exponent */\n+  i -= (Bias + (P - 1) - 1) + 1;\n+  denorm = 1;\n }\n #endif\n ds = (dval(d2) - 1.5) * 0.289529654602168 + 0.1760912590558 +\n      i * 0.301029995663981;\n k = (int)ds;\n if (ds < 0. && ds != k) {\n-    k--; /* want k = floor(ds) */\n+  k--; /* want k = floor(ds) */\n }\n k_check = 1;\n if (k >= 0 && k <= Ten_pmax) {\n-    if (dval(d) < tens[k]) {\n-        k--;\n-    }\n-    k_check = 0;\n+  if (dval(d) < tens[k]) {\n+    k--;\n+  }\n+  k_check = 0;\n }\n j = bbits - i - 1;\n if (j >= 0) {\n-    b2 = 0;\n-    s2 = j;\n+  b2 = 0;\n+  s2 = j;\n } else {\n-    b2 = -j;\n-    s2 = 0;\n+  b2 = -j;\n+  s2 = 0;\n }\n if (k >= 0) {\n-    b5 = 0;\n-    s5 = k;\n-    s2 += k;\n+  b5 = 0;\n+  s5 = k;\n+  s2 += k;\n } else {\n-    b2 -= k;\n-    b5 = -k;\n-    s5 = 0;\n+  b2 -= k;\n+  b5 = -k;\n+  s5 = 0;\n }\n if (mode < 0 || mode > 9) {\n-    mode = 0;\n+  mode = 0;\n }\n \n #ifndef SET_INEXACT\n-#ifdef Check_FLT_ROUNDS\n+#  ifdef Check_FLT_ROUNDS\n try_quick = Rounding == 1;\n-#else\n+#  else\n try_quick = 1;\n-#endif\n+#  endif\n #endif /*SET_INEXACT*/\n \n if (mode > 5) {\n-    mode -= 4;\n-    try_quick = 0;\n+  mode -= 4;\n+  try_quick = 0;\n }\n leftright = 1;\n switch (mode) {\n-    case 0:\n-    case 1:\n-        ilim = ilim1 = -1;\n-        i = 18;\n-        ndigits = 0;\n-        break;\n-    case 2:\n-        leftright = 0;\n-    /* no break */\n-    case 4:\n-        if (ndigits <= 0) {\n-            ndigits = 1;\n-        }\n-        ilim = ilim1 = i = ndigits;\n-        break;\n-    case 3:\n-        leftright = 0;\n-    /* no break */\n-    case 5:\n-        i = ndigits + k + 1;\n-        ilim = i;\n-        ilim1 = i - 1;\n-        if (i <= 0) {\n-            i = 1;\n-        }\n+  case 0:\n+  case 1:\n+    ilim = ilim1 = -1;\n+    i = 18;\n+    ndigits = 0;\n+    break;\n+  case 2:\n+    leftright = 0;\n+  /* no break */\n+  case 4:\n+    if (ndigits <= 0) {\n+      ndigits = 1;\n+    }\n+    ilim = ilim1 = i = ndigits;\n+    break;\n+  case 3:\n+    leftright = 0;\n+  /* no break */\n+  case 5:\n+    i = ndigits + k + 1;\n+    ilim = i;\n+    ilim1 = i - 1;\n+    if (i <= 0) {\n+      i = 1;\n+    }\n }\n s = s0 = rv_alloc(i);\n \n #ifdef Honor_FLT_ROUNDS\n if (mode > 1 && rounding != 1) {\n-    leftright = 0;\n+  leftright = 0;\n }\n #endif\n \n if (ilim >= 0 && ilim <= Quick_max && try_quick) {\n-    /* Try to get by with floating-point arithmetic. */\n-\n-    i = 0;\n-    dval(d2) = dval(d);\n-    k0 = k;\n-    ilim0 = ilim;\n-    ieps = 2; /* conservative */\n-    if (k > 0) {\n-        ds = tens[k & 0xf];\n-        j = k >> 4;\n-        if (j & Bletch) {\n-            /* prevent overflows */\n-            j &= Bletch - 1;\n-            dval(d) /= bigtens[n_bigtens - 1];\n-            ieps++;\n-        }\n-        for (; j; j >>= 1, i++)\n-            if (j & 1) {\n-                ieps++;\n-                ds *= bigtens[i];\n-            }\n-        dval(d) /= ds;\n-    } else if (j1 = -k) {\n-        dval(d) *= tens[j1 & 0xf];\n-        for (j = j1 >> 4; j; j >>= 1, i++)\n-            if (j & 1) {\n-                ieps++;\n-                dval(d) *= bigtens[i];\n-            }\n-    }\n-    if (k_check && dval(d) < 1. && ilim > 0) {\n-        if (ilim1 <= 0) {\n-            goto fast_failed;\n-        }\n-        ilim = ilim1;\n-        k--;\n-        dval(d) *= 10.;\n+  /* Try to get by with floating-point arithmetic. */\n+\n+  i = 0;\n+  dval(d2) = dval(d);\n+  k0 = k;\n+  ilim0 = ilim;\n+  ieps = 2; /* conservative */\n+  if (k > 0) {\n+    ds = tens[k & 0xf];\n+    j = k >> 4;\n+    if (j & Bletch) {\n+      /* prevent overflows */\n+      j &= Bletch - 1;\n+      dval(d) /= bigtens[n_bigtens - 1];\n+      ieps++;\n+    }\n+    for (; j; j >>= 1, i++)\n+      if (j & 1) {\n         ieps++;\n-    }\n-    dval(eps) = ieps * dval(d) + 7.;\n-    word0(eps) -= (P - 1) * Exp_msk1;\n-    if (ilim == 0) {\n-        S = mhi = 0;\n-        dval(d) -= 5.;\n-        if (dval(d) > dval(eps)) {\n-            goto one_digit;\n-        }\n-        if (dval(d) < -dval(eps)) {\n-            goto no_digits;\n-        }\n-        goto fast_failed;\n-    }\n+        ds *= bigtens[i];\n+      }\n+    dval(d) /= ds;\n+  } else if (j1 = -k) {\n+    dval(d) *= tens[j1 & 0xf];\n+    for (j = j1 >> 4; j; j >>= 1, i++)\n+      if (j & 1) {\n+        ieps++;\n+        dval(d) *= bigtens[i];\n+      }\n+  }\n+  if (k_check && dval(d) < 1. && ilim > 0) {\n+    if (ilim1 <= 0) {\n+      goto fast_failed;\n+    }\n+    ilim = ilim1;\n+    k--;\n+    dval(d) *= 10.;\n+    ieps++;\n+  }\n+  dval(eps) = ieps * dval(d) + 7.;\n+  word0(eps) -= (P - 1) * Exp_msk1;\n+  if (ilim == 0) {\n+    S = mhi = 0;\n+    dval(d) -= 5.;\n+    if (dval(d) > dval(eps)) {\n+      goto one_digit;\n+    }\n+    if (dval(d) < -dval(eps)) {\n+      goto no_digits;\n+    }\n+    goto fast_failed;\n+  }\n #ifndef No_leftright\n-    if (leftright) {\n-        /* Use Steele & White method of only\n-         * generating digits needed.\n-         */\n-        dval(eps) = 0.5 / tens[ilim - 1] - dval(eps);\n-        for (i = 0;;) {\n-            L = dval(d);\n-            dval(d) -= L;\n-            *s++ = '0' + (int)L;\n-            if (dval(d) < dval(eps)) {\n-                goto ret1;\n-            }\n-            if (1. - dval(d) < dval(eps)) {\n-                goto bump_up;\n-            }\n-            if (++i >= ilim) {\n-                break;\n-            }\n-            dval(eps) *= 10.;\n-            dval(d) *= 10.;\n-        }\n-    } else {\n+  if (leftright) {\n+    /* Use Steele & White method of only\n+     * generating digits needed.\n+     */\n+    dval(eps) = 0.5 / tens[ilim - 1] - dval(eps);\n+    for (i = 0;;) {\n+      L = dval(d);\n+      dval(d) -= L;\n+      *s++ = '0' + (int)L;\n+      if (dval(d) < dval(eps)) {\n+        goto ret1;\n+      }\n+      if (1. - dval(d) < dval(eps)) {\n+        goto bump_up;\n+      }\n+      if (++i >= ilim) {\n+        break;\n+      }\n+      dval(eps) *= 10.;\n+      dval(d) *= 10.;\n+    }\n+  } else {\n #endif\n-        /* Generate ilim digits, then fix them up. */\n-        dval(eps) *= tens[ilim - 1];\n-        for (i = 1;; i++, dval(d) *= 10.) {\n-            L = (Long)(dval(d));\n-            if (!(dval(d) -= L)) {\n-                ilim = i;\n-            }\n-            *s++ = '0' + (int)L;\n-            if (i == ilim) {\n-                if (dval(d) > 0.5 + dval(eps)) {\n-                    goto bump_up;\n-                } else if (dval(d) < 0.5 - dval(eps)) {\n-                    while (*--s == '0')\n-                        ;\n-                    s++;\n-                    goto ret1;\n-                }\n-                break;\n-            }\n+    /* Generate ilim digits, then fix them up. */\n+    dval(eps) *= tens[ilim - 1];\n+    for (i = 1;; i++, dval(d) *= 10.) {\n+      L = (Long)(dval(d));\n+      if (!(dval(d) -= L)) {\n+        ilim = i;\n+      }\n+      *s++ = '0' + (int)L;\n+      if (i == ilim) {\n+        if (dval(d) > 0.5 + dval(eps)) {\n+          goto bump_up;\n+        } else if (dval(d) < 0.5 - dval(eps)) {\n+          while (*--s == '0');\n+          s++;\n+          goto ret1;\n         }\n-#ifndef No_leftright\n+        break;\n+      }\n     }\n+#ifndef No_leftright\n+  }\n #endif\n fast_failed:\n-    s = s0;\n-    dval(d) = dval(d2);\n-    k = k0;\n-    ilim = ilim0;\n+  s = s0;\n+  dval(d) = dval(d2);\n+  k = k0;\n+  ilim = ilim0;\n }\n \n /* Do we have a \"small\" integer? */\n \n if (be >= 0 && k <= Int_max) {\n-    /* Yes. */\n-    ds = tens[k];\n-    if (ndigits < 0 && ilim <= 0) {\n-        S = mhi = 0;\n-        if (ilim < 0 || dval(d) <= 5 * ds) {\n-            goto no_digits;\n-        }\n-        goto one_digit;\n-    }\n-    for (i = 1; i <= k + 1; i++, dval(d) *= 10.) {\n-        L = (Long)(dval(d) / ds);\n-        dval(d) -= L * ds;\n+  /* Yes. */\n+  ds = tens[k];\n+  if (ndigits < 0 && ilim <= 0) {\n+    S = mhi = 0;\n+    if (ilim < 0 || dval(d) <= 5 * ds) {\n+      goto no_digits;\n+    }\n+    goto one_digit;\n+  }\n+  for (i = 1; i <= k + 1; i++, dval(d) *= 10.) {\n+    L = (Long)(dval(d) / ds);\n+    dval(d) -= L * ds;\n #ifdef Check_FLT_ROUNDS\n-        /* If FLT_ROUNDS == 2, L will usually be high by 1 */\n-        if (dval(d) < 0) {\n-            L--;\n-            dval(d) += ds;\n-        }\n+    /* If FLT_ROUNDS == 2, L will usually be high by 1 */\n+    if (dval(d) < 0) {\n+      L--;\n+      dval(d) += ds;\n+    }\n #endif\n-        *s++ = '0' + (int)L;\n-        if (!dval(d)) {\n+    *s++ = '0' + (int)L;\n+    if (!dval(d)) {\n #ifdef SET_INEXACT\n-            inexact = 0;\n+      inexact = 0;\n #endif\n-            break;\n-        }\n-        if (i == ilim) {\n+      break;\n+    }\n+    if (i == ilim) {\n #ifdef Honor_FLT_ROUNDS\n-            if (mode > 1)\n-                switch (rounding) {\n-                    case 0:\n-                        goto ret1;\n-                    case 2:\n-                        goto bump_up;\n-                }\n-#endif\n-            dval(d) += dval(d);\n-            if (dval(d) > ds || dval(d) == ds && L & 1) {\n-            bump_up:\n-                while (*--s == '9')\n-                    if (s == s0) {\n-                        k++;\n-                        *s = '0';\n-                        break;\n-                    }\n-                ++*s++;\n-            }\n+      if (mode > 1) switch (rounding) {\n+          case 0:\n+            goto ret1;\n+          case 2:\n+            goto bump_up;\n+        }\n+#endif\n+      dval(d) += dval(d);\n+      if (dval(d) > ds || dval(d) == ds && L & 1) {\n+      bump_up:\n+        while (*--s == '9')\n+          if (s == s0) {\n+            k++;\n+            *s = '0';\n             break;\n-        }\n+          }\n+        ++*s++;\n+      }\n+      break;\n     }\n-    goto ret1;\n+  }\n+  goto ret1;\n }\n \n m2 = b2;\n m5 = b5;\n mhi = mlo = 0;\n if (leftright) {\n-    i =\n+  i =\n #ifndef Sudden_Underflow\n-        denorm ? be + (Bias + (P - 1) - 1 + 1) :\n+      denorm ? be + (Bias + (P - 1) - 1 + 1) :\n #endif\n #ifdef IBM\n-               1 + 4 * P - 3 - bbits + ((bbits + be - 1) & 3);\n+             1 + 4 * P - 3 - bbits + ((bbits + be - 1) & 3);\n #else\n-                    1 + P - bbits;\n+            1 + P - bbits;\n #endif\n-    b2 += i;\n-    s2 += i;\n-    mhi = i2b(1);\n+  b2 += i;\n+  s2 += i;\n+  mhi = i2b(1);\n }\n if (m2 > 0 && s2 > 0) {\n-    i = m2 < s2 ? m2 : s2;\n-    b2 -= i;\n-    m2 -= i;\n-    s2 -= i;\n+  i = m2 < s2 ? m2 : s2;\n+  b2 -= i;\n+  m2 -= i;\n+  s2 -= i;\n }\n if (b5 > 0) {\n-    if (leftright) {\n-        if (m5 > 0) {\n-            mhi = pow5mult(mhi, m5);\n-            b1 = mult(mhi, b);\n-            Bfree(b);\n-            b = b1;\n-        }\n-        if (j = b5 - m5) {\n-            b = pow5mult(b, j);\n-        }\n-    } else {\n-        b = pow5mult(b, b5);\n+  if (leftright) {\n+    if (m5 > 0) {\n+      mhi = pow5mult(mhi, m5);\n+      b1 = mult(mhi, b);\n+      Bfree(b);\n+      b = b1;\n+    }\n+    if (j = b5 - m5) {\n+      b = pow5mult(b, j);\n     }\n+  } else {\n+    b = pow5mult(b, b5);\n+  }\n }\n S = i2b(1);\n if (s5 > 0) {\n-    S = pow5mult(S, s5);\n+  S = pow5mult(S, s5);\n }\n \n /* Check for special case that d is a normalized power of 2. */\n@@ -3274,16 +3258,16 @@ if ((mode < 2 || leftright)\n     && rounding == 1\n #endif\n ) {\n-    if (!word1(d) && !(word0(d) & Bndry_mask)\n+  if (!word1(d) && !(word0(d) & Bndry_mask)\n #ifndef Sudden_Underflow\n-        && word0(d) & (Exp_mask & ~Exp_msk1)\n+      && word0(d) & (Exp_mask & ~Exp_msk1)\n #endif\n-    ) {\n-        /* The special case */\n-        b2 += Log2P;\n-        s2 += Log2P;\n-        spec_case = 1;\n-    }\n+  ) {\n+    /* The special case */\n+    b2 += Log2P;\n+    s2 += Log2P;\n+    spec_case = 1;\n+  }\n }\n \n /* Arrange for convenient computation of quotients:\n@@ -3295,229 +3279,225 @@ if ((mode < 2 || leftright)\n  */\n #ifdef Pack_32\n if (i = ((s5 ? 32 - hi0bits(S->x[S->wds - 1]) : 1) + s2) & 0x1f) {\n-    i = 32 - i;\n+  i = 32 - i;\n }\n #else\n-            if (i = ((s5 ? 32 - hi0bits(S->x[S->wds - 1]) : 1) + s2) & 0xf) {\n-                i = 16 - i;\n-            }\n+      if (i = ((s5 ? 32 - hi0bits(S->x[S->wds - 1]) : 1) + s2) & 0xf) {\n+        i = 16 - i;\n+      }\n #endif\n if (i > 4) {\n-    i -= 4;\n-    b2 += i;\n-    m2 += i;\n-    s2 += i;\n+  i -= 4;\n+  b2 += i;\n+  m2 += i;\n+  s2 += i;\n } else if (i < 4) {\n-    i += 28;\n-    b2 += i;\n-    m2 += i;\n-    s2 += i;\n+  i += 28;\n+  b2 += i;\n+  m2 += i;\n+  s2 += i;\n }\n if (b2 > 0) {\n-    b = lshift(b, b2);\n+  b = lshift(b, b2);\n }\n if (s2 > 0) {\n-    S = lshift(S, s2);\n+  S = lshift(S, s2);\n }\n if (k_check) {\n-    if (cmp(b, S) < 0) {\n-        k--;\n-        b = multadd(b, 10, 0); /* we botched the k estimate */\n-        if (leftright) {\n-            mhi = multadd(mhi, 10, 0);\n-        }\n-        ilim = ilim1;\n+  if (cmp(b, S) < 0) {\n+    k--;\n+    b = multadd(b, 10, 0); /* we botched the k estimate */\n+    if (leftright) {\n+      mhi = multadd(mhi, 10, 0);\n     }\n+    ilim = ilim1;\n+  }\n }\n if (ilim <= 0 && (mode == 3 || mode == 5)) {\n-    if (ilim < 0 || cmp(b, S = multadd(S, 5, 0)) <= 0) {\n-        /* no digits, fcvt style */\n-    no_digits:\n-        k = -1 - ndigits;\n-        goto ret;\n-    }\n-one_digit:\n-    *s++ = '1';\n-    k++;\n+  if (ilim < 0 || cmp(b, S = multadd(S, 5, 0)) <= 0) {\n+    /* no digits, fcvt style */\n+  no_digits:\n+    k = -1 - ndigits;\n     goto ret;\n+  }\n+one_digit:\n+  *s++ = '1';\n+  k++;\n+  goto ret;\n }\n if (leftright) {\n-    if (m2 > 0) {\n-        mhi = lshift(mhi, m2);\n-    }\n-\n-    /* Compute mlo -- check for special case\n-     * that d is a normalized power of 2.\n+  if (m2 > 0) {\n+    mhi = lshift(mhi, m2);\n+  }\n+\n+  /* Compute mlo -- check for special case\n+   * that d is a normalized power of 2.\n+   */\n+\n+  mlo = mhi;\n+  if (spec_case) {\n+    mhi = Balloc(mhi->k);\n+    Bcopy(mhi, mlo);\n+    mhi = lshift(mhi, Log2P);\n+  }\n+\n+  for (i = 1;; i++) {\n+    dig = quorem(b, S) + '0';\n+    /* Do we yet have the shortest decimal string\n+     * that will round to d?\n      */\n-\n-    mlo = mhi;\n-    if (spec_case) {\n-        mhi = Balloc(mhi->k);\n-        Bcopy(mhi, mlo);\n-        mhi = lshift(mhi, Log2P);\n-    }\n-\n-    for (i = 1;; i++) {\n-        dig = quorem(b, S) + '0';\n-        /* Do we yet have the shortest decimal string\n-         * that will round to d?\n-         */\n-        j = cmp(b, mlo);\n-        delta = diff(S, mhi);\n-        j1 = delta->sign ? 1 : cmp(b, delta);\n-        Bfree(delta);\n+    j = cmp(b, mlo);\n+    delta = diff(S, mhi);\n+    j1 = delta->sign ? 1 : cmp(b, delta);\n+    Bfree(delta);\n #ifndef ROUND_BIASED\n-        if (j1 == 0 && mode != 1 && !(word1(d) & 1)\n-#ifdef Honor_FLT_ROUNDS\n-            && rounding >= 1\n-#endif\n-        ) {\n-            if (dig == '9') {\n-                goto round_9_up;\n-            }\n-            if (j > 0) {\n-                dig++;\n-            }\n-#ifdef SET_INEXACT\n-            else if (!b->x[0] && b->wds <= 1) {\n-                inexact = 0;\n-            }\n-#endif\n-            *s++ = dig;\n-            goto ret;\n-        }\n-#endif\n-        if (j < 0 || j == 0 && mode != 1\n+    if (j1 == 0 && mode != 1 && !(word1(d) & 1)\n+#  ifdef Honor_FLT_ROUNDS\n+        && rounding >= 1\n+#  endif\n+    ) {\n+      if (dig == '9') {\n+        goto round_9_up;\n+      }\n+      if (j > 0) {\n+        dig++;\n+      }\n+#  ifdef SET_INEXACT\n+      else if (!b->x[0] && b->wds <= 1) {\n+        inexact = 0;\n+      }\n+#  endif\n+      *s++ = dig;\n+      goto ret;\n+    }\n+#endif\n+    if (j < 0 || j == 0 && mode != 1\n #ifndef ROUND_BIASED\n-                         && !(word1(d) & 1)\n+                     && !(word1(d) & 1)\n #endif\n-        ) {\n-            if (!b->x[0] && b->wds <= 1) {\n+    ) {\n+      if (!b->x[0] && b->wds <= 1) {\n #ifdef SET_INEXACT\n-                inexact = 0;\n+        inexact = 0;\n #endif\n-                goto accept_dig;\n-            }\n+        goto accept_dig;\n+      }\n #ifdef Honor_FLT_ROUNDS\n-            if (mode > 1)\n-                switch (rounding) {\n-                    case 0:\n-                        goto accept_dig;\n-                    case 2:\n-                        goto keep_dig;\n-                }\n-#endif /*Honor_FLT_ROUNDS*/\n-            if (j1 > 0) {\n-                b = lshift(b, 1);\n-                j1 = cmp(b, S);\n-                if ((j1 > 0 || j1 == 0 && dig & 1) && dig++ == '9') {\n-                    goto round_9_up;\n-                }\n-            }\n-        accept_dig:\n-            *s++ = dig;\n-            goto ret;\n+      if (mode > 1) switch (rounding) {\n+          case 0:\n+            goto accept_dig;\n+          case 2:\n+            goto keep_dig;\n         }\n-        if (j1 > 0) {\n+#endif /*Honor_FLT_ROUNDS*/\n+      if (j1 > 0) {\n+        b = lshift(b, 1);\n+        j1 = cmp(b, S);\n+        if ((j1 > 0 || j1 == 0 && dig & 1) && dig++ == '9') {\n+          goto round_9_up;\n+        }\n+      }\n+    accept_dig:\n+      *s++ = dig;\n+      goto ret;\n+    }\n+    if (j1 > 0) {\n #ifdef Honor_FLT_ROUNDS\n-            if (!rounding) {\n-                goto accept_dig;\n-            }\n+      if (!rounding) {\n+        goto accept_dig;\n+      }\n #endif\n-            if (dig == '9') { /* possible if i == 1 */\n-            round_9_up:\n-                *s++ = '9';\n-                goto roundoff;\n-            }\n-            *s++ = dig + 1;\n-            goto ret;\n-        }\n+      if (dig == '9') { /* possible if i == 1 */\n+      round_9_up:\n+        *s++ = '9';\n+        goto roundoff;\n+      }\n+      *s++ = dig + 1;\n+      goto ret;\n+    }\n #ifdef Honor_FLT_ROUNDS\n-    keep_dig:\n+  keep_dig:\n #endif\n-        *s++ = dig;\n-        if (i == ilim) {\n-            break;\n-        }\n-        b = multadd(b, 10, 0);\n-        if (mlo == mhi) {\n-            mlo = mhi = multadd(mhi, 10, 0);\n-        } else {\n-            mlo = multadd(mlo, 10, 0);\n-            mhi = multadd(mhi, 10, 0);\n-        }\n+    *s++ = dig;\n+    if (i == ilim) {\n+      break;\n     }\n+    b = multadd(b, 10, 0);\n+    if (mlo == mhi) {\n+      mlo = mhi = multadd(mhi, 10, 0);\n+    } else {\n+      mlo = multadd(mlo, 10, 0);\n+      mhi = multadd(mhi, 10, 0);\n+    }\n+  }\n } else\n-    for (i = 1;; i++) {\n-        *s++ = dig = quorem(b, S) + '0';\n-        if (!b->x[0] && b->wds <= 1) {\n+  for (i = 1;; i++) {\n+    *s++ = dig = quorem(b, S) + '0';\n+    if (!b->x[0] && b->wds <= 1) {\n #ifdef SET_INEXACT\n-            inexact = 0;\n+      inexact = 0;\n #endif\n-            goto ret;\n-        }\n-        if (i >= ilim) {\n-            break;\n-        }\n-        b = multadd(b, 10, 0);\n+      goto ret;\n+    }\n+    if (i >= ilim) {\n+      break;\n     }\n+    b = multadd(b, 10, 0);\n+  }\n \n-/* Round off last digit */\n+  /* Round off last digit */\n \n #ifdef Honor_FLT_ROUNDS\n switch (rounding) {\n-    case 0:\n-        goto trimzeros;\n-    case 2:\n-        goto roundoff;\n+  case 0:\n+    goto trimzeros;\n+  case 2:\n+    goto roundoff;\n }\n #endif\n b = lshift(b, 1);\n j = cmp(b, S);\n if (j > 0 || j == 0 && dig & 1) {\n roundoff:\n-    while (*--s == '9')\n-        if (s == s0) {\n-            k++;\n-            *s++ = '1';\n-            goto ret;\n-        }\n-    ++*s++;\n+  while (*--s == '9')\n+    if (s == s0) {\n+      k++;\n+      *s++ = '1';\n+      goto ret;\n+    }\n+  ++*s++;\n } else {\n #ifdef Honor_FLT_ROUNDS\n trimzeros:\n #endif\n-    while (*--s == '0')\n-        ;\n-    s++;\n+  while (*--s == '0');\n+  s++;\n }\n ret: Bfree(S);\n if (mhi) {\n-    if (mlo && mlo != mhi) {\n-        Bfree(mlo);\n-    }\n-    Bfree(mhi);\n+  if (mlo && mlo != mhi) {\n+    Bfree(mlo);\n+  }\n+  Bfree(mhi);\n }\n ret1:\n #ifdef SET_INEXACT\n-    if (inexact)\n-{\n-    if (!oldinexact) {\n-        word0(d) = Exp_1 + (70 << Exp_shift);\n-        word1(d) = 0;\n-        dval(d) += 1.;\n-    }\n+    if (inexact) {\n+  if (!oldinexact) {\n+    word0(d) = Exp_1 + (70 << Exp_shift);\n+    word1(d) = 0;\n+    dval(d) += 1.;\n+  }\n }\n-else if (!oldinexact)\n-{\n-    clear_inexact();\n+else if (!oldinexact) {\n+  clear_inexact();\n }\n #endif\n Bfree(b);\n *s = 0;\n *decpt = k + 1;\n if (rve) {\n-    *rve = s;\n+  *rve = s;\n }\n return s0;\n }\n@@ -3527,37 +3507,36 @@ return s0;\n \n PR_IMPLEMENT(PRStatus)\n PR_dtoa(PRFloat64 d, PRIntn mode, PRIntn ndigits, PRIntn* decpt, PRIntn* sign,\n-        char** rve, char* buf, PRSize bufsize)\n-{\n-    char* result;\n-    PRSize resultlen;\n-    PRStatus rv = PR_FAILURE;\n+        char** rve, char* buf, PRSize bufsize) {\n+  char* result;\n+  PRSize resultlen;\n+  PRStatus rv = PR_FAILURE;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    if (mode < 0 || mode > 3) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return rv;\n-    }\n-    result = dtoa(d, mode, ndigits, decpt, sign, rve);\n-    if (!result) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return rv;\n-    }\n-    resultlen = strlen(result) + 1;\n-    if (bufsize < resultlen) {\n-        PR_SetError(PR_BUFFER_OVERFLOW_ERROR, 0);\n-    } else {\n-        memcpy(buf, result, resultlen);\n-        if (rve) {\n-            *rve = buf + (*rve - result);\n-        }\n-        rv = PR_SUCCESS;\n-    }\n-    freedtoa(result);\n+  if (mode < 0 || mode > 3) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return rv;\n+  }\n+  result = dtoa(d, mode, ndigits, decpt, sign, rve);\n+  if (!result) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n     return rv;\n+  }\n+  resultlen = strlen(result) + 1;\n+  if (bufsize < resultlen) {\n+    PR_SetError(PR_BUFFER_OVERFLOW_ERROR, 0);\n+  } else {\n+    memcpy(buf, result, resultlen);\n+    if (rve) {\n+      *rve = buf + (*rve - result);\n+    }\n+    rv = PR_SUCCESS;\n+  }\n+  freedtoa(result);\n+  return rv;\n }\n \n /*\n@@ -3572,84 +3551,83 @@ PR_dtoa(PRFloat64 d, PRIntn mode, PRIntn ndigits, PRIntn* decpt, PRIntn* sign,\n **   '+' or '-' after the 'e' in scientific notation\n */\n PR_IMPLEMENT(void)\n-PR_cnvtf(char* buf, int bufsz, int prcsn, double dfval)\n-{\n-    PRIntn decpt, sign, numdigits;\n-    char *num, *nump;\n-    char* bufp = buf;\n-    char* endnum;\n-    U fval;\n-\n-    dval(fval) = dfval;\n-    /* If anything fails, we store an empty string in 'buf' */\n-    num = (char*)PR_MALLOC(bufsz);\n-    if (num == NULL) {\n-        buf[0] = '\\0';\n-        return;\n+PR_cnvtf(char* buf, int bufsz, int prcsn, double dfval) {\n+  PRIntn decpt, sign, numdigits;\n+  char *num, *nump;\n+  char* bufp = buf;\n+  char* endnum;\n+  U fval;\n+\n+  dval(fval) = dfval;\n+  /* If anything fails, we store an empty string in 'buf' */\n+  num = (char*)PR_MALLOC(bufsz);\n+  if (num == NULL) {\n+    buf[0] = '\\0';\n+    return;\n+  }\n+  /* XXX Why use mode 1? */\n+  if (PR_dtoa(dval(fval), 1, prcsn, &decpt, &sign, &endnum, num, bufsz) ==\n+      PR_FAILURE) {\n+    buf[0] = '\\0';\n+    goto done;\n+  }\n+  numdigits = endnum - num;\n+  nump = num;\n+\n+  if (sign && !(word0(fval) == Sign_bit && word1(fval) == 0) &&\n+      !((word0(fval) & Exp_mask) == Exp_mask &&\n+        (word1(fval) || (word0(fval) & 0xfffff)))) {\n+    *bufp++ = '-';\n+  }\n+\n+  if (decpt == 9999) {\n+    while ((*bufp++ = *nump++) != 0) {\n+    } /* nothing to execute */\n+    goto done;\n+  }\n+\n+  if (decpt > (prcsn + 1) || decpt < -(prcsn - 1) || decpt < -5) {\n+    *bufp++ = *nump++;\n+    if (numdigits != 1) {\n+      *bufp++ = '.';\n+    }\n+\n+    while (*nump != '\\0') {\n+      *bufp++ = *nump++;\n+    }\n+    *bufp++ = 'e';\n+    PR_snprintf(bufp, bufsz - (bufp - buf), \"%+d\", decpt - 1);\n+  } else if (decpt >= 0) {\n+    if (decpt == 0) {\n+      *bufp++ = '0';\n+    } else {\n+      while (decpt--) {\n+        if (*nump != '\\0') {\n+          *bufp++ = *nump++;\n+        } else {\n+          *bufp++ = '0';\n+        }\n+      }\n     }\n-    /* XXX Why use mode 1? */\n-    if (PR_dtoa(dval(fval), 1, prcsn, &decpt, &sign, &endnum, num, bufsz) ==\n-        PR_FAILURE) {\n-        buf[0] = '\\0';\n-        goto done;\n+    if (*nump != '\\0') {\n+      *bufp++ = '.';\n+      while (*nump != '\\0') {\n+        *bufp++ = *nump++;\n+      }\n     }\n-    numdigits = endnum - num;\n-    nump = num;\n-\n-    if (sign && !(word0(fval) == Sign_bit && word1(fval) == 0) &&\n-        !((word0(fval) & Exp_mask) == Exp_mask &&\n-          (word1(fval) || (word0(fval) & 0xfffff)))) {\n-        *bufp++ = '-';\n+    *bufp++ = '\\0';\n+  } else if (decpt < 0) {\n+    *bufp++ = '0';\n+    *bufp++ = '.';\n+    while (decpt++) {\n+      *bufp++ = '0';\n     }\n \n-    if (decpt == 9999) {\n-        while ((*bufp++ = *nump++) != 0) {\n-        } /* nothing to execute */\n-        goto done;\n-    }\n-\n-    if (decpt > (prcsn + 1) || decpt < -(prcsn - 1) || decpt < -5) {\n-        *bufp++ = *nump++;\n-        if (numdigits != 1) {\n-            *bufp++ = '.';\n-        }\n-\n-        while (*nump != '\\0') {\n-            *bufp++ = *nump++;\n-        }\n-        *bufp++ = 'e';\n-        PR_snprintf(bufp, bufsz - (bufp - buf), \"%+d\", decpt - 1);\n-    } else if (decpt >= 0) {\n-        if (decpt == 0) {\n-            *bufp++ = '0';\n-        } else {\n-            while (decpt--) {\n-                if (*nump != '\\0') {\n-                    *bufp++ = *nump++;\n-                } else {\n-                    *bufp++ = '0';\n-                }\n-            }\n-        }\n-        if (*nump != '\\0') {\n-            *bufp++ = '.';\n-            while (*nump != '\\0') {\n-                *bufp++ = *nump++;\n-            }\n-        }\n-        *bufp++ = '\\0';\n-    } else if (decpt < 0) {\n-        *bufp++ = '0';\n-        *bufp++ = '.';\n-        while (decpt++) {\n-            *bufp++ = '0';\n-        }\n-\n-        while (*nump != '\\0') {\n-            *bufp++ = *nump++;\n-        }\n-        *bufp++ = '\\0';\n+    while (*nump != '\\0') {\n+      *bufp++ = *nump++;\n     }\n+    *bufp++ = '\\0';\n+  }\n done:\n-    PR_DELETE(num);\n+  PR_DELETE(num);\n }\ndiff --git a/nspr/pr/src/misc/prenv.c b/nspr/pr/src/misc/prenv.c\nindex 7b19d5e..7d142e2 100644\n--- a/nspr/pr/src/misc/prenv.c\n+++ b/nspr/pr/src/misc/prenv.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,188 +9,162 @@\n #include \"prmem.h\"\n \n #if defined(XP_UNIX)\n-#include <unistd.h>\n-#if defined(DARWIN)\n-#if defined(HAVE_CRT_EXTERNS_H)\n-#include <crt_externs.h>\n-#endif /* HAVE_CRT_EXTERNS_H */\n-#else  /* DARWIN */\n-PR_IMPORT_DATA(char**)\n-environ;\n-#endif /* DARWIN */\n-#endif /* XP_UNIX */\n+#  include <unistd.h>\n+#  if defined(DARWIN)\n+#    if defined(HAVE_CRT_EXTERNS_H)\n+#      include <crt_externs.h>\n+#    endif /* HAVE_CRT_EXTERNS_H */\n+#  else    /* DARWIN */\n+PR_IMPORT_DATA(char**) environ;\n+#  endif   /* DARWIN */\n+#endif     /* XP_UNIX */\n \n #if !defined(HAVE_SECURE_GETENV) && defined(HAVE___SECURE_GETENV)\n-#define secure_getenv __secure_getenv\n-#define HAVE_SECURE_GETENV 1\n+#  define secure_getenv __secure_getenv\n+#  define HAVE_SECURE_GETENV 1\n #endif\n \n /* Lock used to lock the environment */\n #if defined(_PR_NO_PREEMPT)\n-#define _PR_NEW_LOCK_ENV()\n-#define _PR_DELETE_LOCK_ENV()\n-#define _PR_LOCK_ENV()\n-#define _PR_UNLOCK_ENV()\n+#  define _PR_NEW_LOCK_ENV()\n+#  define _PR_DELETE_LOCK_ENV()\n+#  define _PR_LOCK_ENV()\n+#  define _PR_UNLOCK_ENV()\n #elif defined(_PR_LOCAL_THREADS_ONLY)\n extern _PRCPU* _pr_primordialCPU;\n static PRIntn _is;\n-#define _PR_NEW_LOCK_ENV()\n-#define _PR_DELETE_LOCK_ENV()\n-#define _PR_LOCK_ENV()     \\\n-    if (_pr_primordialCPU) \\\n-        _PR_INTSOFF(_is);\n-#define _PR_UNLOCK_ENV()   \\\n-    if (_pr_primordialCPU) \\\n-        _PR_INTSON(_is);\n+#  define _PR_NEW_LOCK_ENV()\n+#  define _PR_DELETE_LOCK_ENV()\n+#  define _PR_LOCK_ENV() \\\n+    if (_pr_primordialCPU) _PR_INTSOFF(_is);\n+#  define _PR_UNLOCK_ENV() \\\n+    if (_pr_primordialCPU) _PR_INTSON(_is);\n #else\n static PRLock* _pr_envLock = NULL;\n-#define _PR_NEW_LOCK_ENV()          \\\n-    {                               \\\n-        _pr_envLock = PR_NewLock(); \\\n+#  define _PR_NEW_LOCK_ENV() \\\n+    { _pr_envLock = PR_NewLock(); }\n+#  define _PR_DELETE_LOCK_ENV()      \\\n+    {                                \\\n+      if (_pr_envLock) {             \\\n+        PR_DestroyLock(_pr_envLock); \\\n+        _pr_envLock = NULL;          \\\n+      }                              \\\n     }\n-#define _PR_DELETE_LOCK_ENV()            \\\n-    {                                    \\\n-        if (_pr_envLock) {               \\\n-            PR_DestroyLock(_pr_envLock); \\\n-            _pr_envLock = NULL;          \\\n-        }                                \\\n+#  define _PR_LOCK_ENV()                     \\\n+    {                                        \\\n+      if (_pr_envLock) PR_Lock(_pr_envLock); \\\n     }\n-#define _PR_LOCK_ENV()            \\\n-    {                             \\\n-        if (_pr_envLock)          \\\n-            PR_Lock(_pr_envLock); \\\n-    }\n-#define _PR_UNLOCK_ENV()            \\\n-    {                               \\\n-        if (_pr_envLock)            \\\n-            PR_Unlock(_pr_envLock); \\\n+#  define _PR_UNLOCK_ENV()                     \\\n+    {                                          \\\n+      if (_pr_envLock) PR_Unlock(_pr_envLock); \\\n     }\n #endif\n \n /************************************************************************/\n \n-void\n-_PR_InitEnv(void)\n-{\n-    _PR_NEW_LOCK_ENV();\n-}\n+void _PR_InitEnv(void) { _PR_NEW_LOCK_ENV(); }\n \n-void\n-_PR_CleanupEnv(void)\n-{\n-    _PR_DELETE_LOCK_ENV();\n-}\n+void _PR_CleanupEnv(void) { _PR_DELETE_LOCK_ENV(); }\n \n-PR_IMPLEMENT(char*)\n-PR_GetEnv(const char* var)\n-{\n-    char* ev;\n+PR_IMPLEMENT(char*) PR_GetEnv(const char* var) {\n+  char* ev;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    _PR_LOCK_ENV();\n-    ev = _PR_MD_GET_ENV(var);\n-    _PR_UNLOCK_ENV();\n-    return ev;\n+  _PR_LOCK_ENV();\n+  ev = _PR_MD_GET_ENV(var);\n+  _PR_UNLOCK_ENV();\n+  return ev;\n }\n \n-PR_IMPLEMENT(char*)\n-PR_GetEnvSecure(const char* var)\n-{\n+PR_IMPLEMENT(char*) PR_GetEnvSecure(const char* var) {\n #ifdef HAVE_SECURE_GETENV\n-    char* ev;\n+  char* ev;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    _PR_LOCK_ENV();\n-    ev = secure_getenv(var);\n-    _PR_UNLOCK_ENV();\n+  _PR_LOCK_ENV();\n+  ev = secure_getenv(var);\n+  _PR_UNLOCK_ENV();\n \n-    return ev;\n+  return ev;\n #else\n-#ifdef XP_UNIX\n-    /*\n-    ** Fall back to checking uids and gids.  This won't detect any other\n-    ** privilege-granting mechanisms the platform may have.  This also\n-    ** can't detect the case where the process already called\n-    ** setuid(geteuid()) and/or setgid(getegid()).\n-    */\n-    if (getuid() != geteuid() || getgid() != getegid()) {\n-        return NULL;\n-    }\n-#endif /* XP_UNIX */\n-    return PR_GetEnv(var);\n-#endif /* HAVE_SECURE_GETENV */\n+#  ifdef XP_UNIX\n+  /*\n+  ** Fall back to checking uids and gids.  This won't detect any other\n+  ** privilege-granting mechanisms the platform may have.  This also\n+  ** can't detect the case where the process already called\n+  ** setuid(geteuid()) and/or setgid(getegid()).\n+  */\n+  if (getuid() != geteuid() || getgid() != getegid()) {\n+    return NULL;\n+  }\n+#  endif /* XP_UNIX */\n+  return PR_GetEnv(var);\n+#endif   /* HAVE_SECURE_GETENV */\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_SetEnv(const char* string)\n-{\n-    PRIntn result;\n+PR_IMPLEMENT(PRStatus) PR_SetEnv(const char* string) {\n+  PRIntn result;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    if (!strchr(string, '=')) {\n-        return (PR_FAILURE);\n-    }\n+  if (!strchr(string, '=')) {\n+    return (PR_FAILURE);\n+  }\n \n-    _PR_LOCK_ENV();\n-    result = _PR_MD_PUT_ENV((char*)string);\n-    _PR_UNLOCK_ENV();\n-    return result ? PR_FAILURE : PR_SUCCESS;\n+  _PR_LOCK_ENV();\n+  result = _PR_MD_PUT_ENV((char*)string);\n+  _PR_UNLOCK_ENV();\n+  return result ? PR_FAILURE : PR_SUCCESS;\n }\n \n #if defined(XP_UNIX) && (!defined(DARWIN) || defined(HAVE_CRT_EXTERNS_H))\n-PR_IMPLEMENT(char**)\n-PR_DuplicateEnvironment(void)\n-{\n-    char **the_environ, **result, **end, **src, **dst;\n-\n-    _PR_LOCK_ENV();\n-#ifdef DARWIN\n-    the_environ = *(_NSGetEnviron());\n-#else\n-    the_environ = environ;\n-#endif\n-\n-    for (end = the_environ; *end != NULL; end++) {\n-        /* empty loop body */;\n-    }\n-\n-    result = (char**)PR_Malloc(sizeof(char*) * (end - the_environ + 1));\n-    if (result != NULL) {\n-        for (src = the_environ, dst = result; src != end; src++, dst++) {\n-            size_t len;\n-\n-            len = strlen(*src) + 1;\n-            *dst = PR_Malloc(len);\n-            if (*dst == NULL) {\n-                /* Allocation failed.  Must clean up the half-copied env. */\n-                char** to_delete;\n-\n-                for (to_delete = result; to_delete != dst; to_delete++) {\n-                    PR_Free(*to_delete);\n-                }\n-                PR_Free(result);\n-                result = NULL;\n-                goto out;\n-            }\n-            memcpy(*dst, *src, len);\n+PR_IMPLEMENT(char**) PR_DuplicateEnvironment(void) {\n+  char **the_environ, **result, **end, **src, **dst;\n+\n+  _PR_LOCK_ENV();\n+#  ifdef DARWIN\n+  the_environ = *(_NSGetEnviron());\n+#  else\n+  the_environ = environ;\n+#  endif\n+\n+  for (end = the_environ; *end != NULL; end++) /* empty loop body */;\n+\n+  result = (char**)PR_Malloc(sizeof(char*) * (end - the_environ + 1));\n+  if (result != NULL) {\n+    for (src = the_environ, dst = result; src != end; src++, dst++) {\n+      size_t len;\n+\n+      len = strlen(*src) + 1;\n+      *dst = PR_Malloc(len);\n+      if (*dst == NULL) {\n+        /* Allocation failed.  Must clean up the half-copied env. */\n+        char** to_delete;\n+\n+        for (to_delete = result; to_delete != dst; to_delete++) {\n+          PR_Free(*to_delete);\n         }\n-        *dst = NULL;\n+        PR_Free(result);\n+        result = NULL;\n+        goto out;\n+      }\n+      memcpy(*dst, *src, len);\n     }\n+    *dst = NULL;\n+  }\n out:\n-    _PR_UNLOCK_ENV();\n-    return result;\n+  _PR_UNLOCK_ENV();\n+  return result;\n }\n #else\n /* This platform doesn't support raw access to the environ block. */\n-PR_IMPLEMENT(char**)\n-PR_DuplicateEnvironment(void) { return NULL; }\n+PR_IMPLEMENT(char**) PR_DuplicateEnvironment(void) { return NULL; }\n #endif\ndiff --git a/nspr/pr/src/misc/prerr.c b/nspr/pr/src/misc/prerr.c\nindex 1ca312d..3be9513 100644\n--- a/nspr/pr/src/misc/prerr.c\n+++ b/nspr/pr/src/misc/prerr.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,116 +10,111 @@\n  */\n #include \"prerror.h\"\n static const struct PRErrorMessage text[] = {\n-    { \"PR_OUT_OF_MEMORY_ERROR\", \"Memory allocation attempt failed\" },\n-    { \"PR_BAD_DESCRIPTOR_ERROR\", \"Invalid file descriptor\" },\n-    { \"PR_WOULD_BLOCK_ERROR\", \"The operation would have blocked\" },\n-    { \"PR_ACCESS_FAULT_ERROR\", \"Invalid memory address argument\" },\n-    { \"PR_INVALID_METHOD_ERROR\", \"Invalid function for file type\" },\n-    { \"PR_ILLEGAL_ACCESS_ERROR\", \"Invalid memory address argument\" },\n-    { \"PR_UNKNOWN_ERROR\", \"Some unknown error has occurred\" },\n-    { \"PR_PENDING_INTERRUPT_ERROR\", \"Operation interrupted by another thread\" },\n-    { \"PR_NOT_IMPLEMENTED_ERROR\", \"function not implemented\" },\n-    { \"PR_IO_ERROR\", \"I/O function error\" },\n-    { \"PR_IO_TIMEOUT_ERROR\", \"I/O operation timed out\" },\n-    { \"PR_IO_PENDING_ERROR\", \"I/O operation on busy file descriptor\" },\n-    { \"PR_DIRECTORY_OPEN_ERROR\", \"The directory could not be opened\" },\n-    { \"PR_INVALID_ARGUMENT_ERROR\", \"Invalid function argument\" },\n-    { \"PR_ADDRESS_NOT_AVAILABLE_ERROR\",\n-      \"Network address not available (in use?)\" },\n-    { \"PR_ADDRESS_NOT_SUPPORTED_ERROR\", \"Network address type not supported\" },\n-    { \"PR_IS_CONNECTED_ERROR\", \"Already connected\" },\n-    { \"PR_BAD_ADDRESS_ERROR\", \"Network address is invalid\" },\n-    { \"PR_ADDRESS_IN_USE_ERROR\", \"Local Network address is in use\" },\n-    { \"PR_CONNECT_REFUSED_ERROR\", \"Connection refused by peer\" },\n-    { \"PR_NETWORK_UNREACHABLE_ERROR\",\n-      \"Network address is presently unreachable\" },\n-    { \"PR_CONNECT_TIMEOUT_ERROR\", \"Connection attempt timed out\" },\n-    { \"PR_NOT_CONNECTED_ERROR\", \"Network file descriptor is not connected\" },\n-    { \"PR_LOAD_LIBRARY_ERROR\", \"Failure to load dynamic library\" },\n-    { \"PR_UNLOAD_LIBRARY_ERROR\", \"Failure to unload dynamic library\" },\n-    { \"PR_FIND_SYMBOL_ERROR\",\n-      \"Symbol not found in any of the loaded dynamic libraries\" },\n-    { \"PR_INSUFFICIENT_RESOURCES_ERROR\", \"Insufficient system resources\" },\n-    { \"PR_DIRECTORY_LOOKUP_ERROR\",\n-      \"A directory lookup on a network address has failed\" },\n-    { \"PR_TPD_RANGE_ERROR\", \"Attempt to access a TPD key that is out of range\" },\n-    { \"PR_PROC_DESC_TABLE_FULL_ERROR\", \"Process open FD table is full\" },\n-    { \"PR_SYS_DESC_TABLE_FULL_ERROR\", \"System open FD table is full\" },\n-    { \"PR_NOT_SOCKET_ERROR\",\n-      \"Network operation attempted on non-network file descriptor\" },\n-    { \"PR_NOT_TCP_SOCKET_ERROR\",\n-      \"TCP-specific function attempted on a non-TCP file descriptor\" },\n-    { \"PR_SOCKET_ADDRESS_IS_BOUND_ERROR\",\n-      \"TCP file descriptor is already bound\" },\n-    { \"PR_NO_ACCESS_RIGHTS_ERROR\", \"Access Denied\" },\n-    { \"PR_OPERATION_NOT_SUPPORTED_ERROR\",\n-      \"The requested operation is not supported by the platform\" },\n-    { \"PR_PROTOCOL_NOT_SUPPORTED_ERROR\",\n-      \"The host operating system does not support the protocol requested\" },\n-    { \"PR_REMOTE_FILE_ERROR\", \"Access to the remote file has been severed\" },\n-    { \"PR_BUFFER_OVERFLOW_ERROR\",\n-      \"The value requested is too large to be stored in the data buffer \"\n-      \"provided\" },\n-    { \"PR_CONNECT_RESET_ERROR\", \"TCP connection reset by peer\" },\n-    { \"PR_RANGE_ERROR\", \"Unused\" },\n-    { \"PR_DEADLOCK_ERROR\", \"The operation would have deadlocked\" },\n-    { \"PR_FILE_IS_LOCKED_ERROR\", \"The file is already locked\" },\n-    { \"PR_FILE_TOO_BIG_ERROR\",\n-      \"Write would result in file larger than the system allows\" },\n-    { \"PR_NO_DEVICE_SPACE_ERROR\", \"The device for storing the file is full\" },\n-    { \"PR_PIPE_ERROR\", \"Unused\" },\n-    { \"PR_NO_SEEK_DEVICE_ERROR\", \"Unused\" },\n-    { \"PR_IS_DIRECTORY_ERROR\",\n-      \"Cannot perform a normal file operation on a directory\" },\n-    { \"PR_LOOP_ERROR\", \"Symbolic link loop\" },\n-    { \"PR_NAME_TOO_LONG_ERROR\", \"File name is too long\" },\n-    { \"PR_FILE_NOT_FOUND_ERROR\", \"File not found\" },\n-    { \"PR_NOT_DIRECTORY_ERROR\",\n-      \"Cannot perform directory operation on a normal file\" },\n-    { \"PR_READ_ONLY_FILESYSTEM_ERROR\",\n-      \"Cannot write to a read-only file system\" },\n-    { \"PR_DIRECTORY_NOT_EMPTY_ERROR\",\n-      \"Cannot delete a directory that is not empty\" },\n-    { \"PR_FILESYSTEM_MOUNTED_ERROR\",\n-      \"Cannot delete or rename a file object while the file system is busy\" },\n-    { \"PR_NOT_SAME_DEVICE_ERROR\",\n-      \"Cannot rename a file to a file system on another device\" },\n-    { \"PR_DIRECTORY_CORRUPTED_ERROR\",\n-      \"The directory object in the file system is corrupted\" },\n-    { \"PR_FILE_EXISTS_ERROR\",\n-      \"Cannot create or rename a filename that already exists\" },\n-    { \"PR_MAX_DIRECTORY_ENTRIES_ERROR\",\n-      \"Directory is full.  No additional filenames may be added\" },\n-    { \"PR_INVALID_DEVICE_STATE_ERROR\",\n-      \"The required device was in an invalid state\" },\n-    { \"PR_DEVICE_IS_LOCKED_ERROR\", \"The device is locked\" },\n-    { \"PR_NO_MORE_FILES_ERROR\", \"No more entries in the directory\" },\n-    { \"PR_END_OF_FILE_ERROR\", \"Encountered end of file\" },\n-    { \"PR_FILE_SEEK_ERROR\", \"Seek error\" },\n-    { \"PR_FILE_IS_BUSY_ERROR\", \"The file is busy\" },\n-    { \"PR_OPERATION_ABORTED_ERROR\", \"The I/O operation was aborted\" },\n-    { \"PR_IN_PROGRESS_ERROR\",\n-      \"Operation is still in progress (probably a non-blocking connect)\" },\n-    { \"PR_ALREADY_INITIATED_ERROR\",\n-      \"Operation has already been initiated (probably a non-blocking connect)\" },\n-    { \"PR_GROUP_EMPTY_ERROR\", \"The wait group is empty\" },\n-    { \"PR_INVALID_STATE_ERROR\", \"Object state improper for request\" },\n-    { \"PR_NETWORK_DOWN_ERROR\", \"Network is down\" },\n-    { \"PR_SOCKET_SHUTDOWN_ERROR\", \"Socket shutdown\" },\n-    { \"PR_CONNECT_ABORTED_ERROR\", \"Connection aborted\" },\n-    { \"PR_HOST_UNREACHABLE_ERROR\", \"Host is unreachable\" },\n-    { \"PR_LIBRARY_NOT_LOADED_ERROR\", \"The library is not loaded\" },\n-    { \"PR_CALL_ONCE_ERROR\",\n-      \"The one-time function was previously called and failed. Its error code \"\n-      \"is no longer available\" },\n-    { \"PR_MAX_ERROR\", \"Placeholder for the end of the list\" },\n-    { 0, 0 }\n-};\n+    {\"PR_OUT_OF_MEMORY_ERROR\", \"Memory allocation attempt failed\"},\n+    {\"PR_BAD_DESCRIPTOR_ERROR\", \"Invalid file descriptor\"},\n+    {\"PR_WOULD_BLOCK_ERROR\", \"The operation would have blocked\"},\n+    {\"PR_ACCESS_FAULT_ERROR\", \"Invalid memory address argument\"},\n+    {\"PR_INVALID_METHOD_ERROR\", \"Invalid function for file type\"},\n+    {\"PR_ILLEGAL_ACCESS_ERROR\", \"Invalid memory address argument\"},\n+    {\"PR_UNKNOWN_ERROR\", \"Some unknown error has occurred\"},\n+    {\"PR_PENDING_INTERRUPT_ERROR\", \"Operation interrupted by another thread\"},\n+    {\"PR_NOT_IMPLEMENTED_ERROR\", \"function not implemented\"},\n+    {\"PR_IO_ERROR\", \"I/O function error\"},\n+    {\"PR_IO_TIMEOUT_ERROR\", \"I/O operation timed out\"},\n+    {\"PR_IO_PENDING_ERROR\", \"I/O operation on busy file descriptor\"},\n+    {\"PR_DIRECTORY_OPEN_ERROR\", \"The directory could not be opened\"},\n+    {\"PR_INVALID_ARGUMENT_ERROR\", \"Invalid function argument\"},\n+    {\"PR_ADDRESS_NOT_AVAILABLE_ERROR\",\n+     \"Network address not available (in use?)\"},\n+    {\"PR_ADDRESS_NOT_SUPPORTED_ERROR\", \"Network address type not supported\"},\n+    {\"PR_IS_CONNECTED_ERROR\", \"Already connected\"},\n+    {\"PR_BAD_ADDRESS_ERROR\", \"Network address is invalid\"},\n+    {\"PR_ADDRESS_IN_USE_ERROR\", \"Local Network address is in use\"},\n+    {\"PR_CONNECT_REFUSED_ERROR\", \"Connection refused by peer\"},\n+    {\"PR_NETWORK_UNREACHABLE_ERROR\",\n+     \"Network address is presently unreachable\"},\n+    {\"PR_CONNECT_TIMEOUT_ERROR\", \"Connection attempt timed out\"},\n+    {\"PR_NOT_CONNECTED_ERROR\", \"Network file descriptor is not connected\"},\n+    {\"PR_LOAD_LIBRARY_ERROR\", \"Failure to load dynamic library\"},\n+    {\"PR_UNLOAD_LIBRARY_ERROR\", \"Failure to unload dynamic library\"},\n+    {\"PR_FIND_SYMBOL_ERROR\",\n+     \"Symbol not found in any of the loaded dynamic libraries\"},\n+    {\"PR_INSUFFICIENT_RESOURCES_ERROR\", \"Insufficient system resources\"},\n+    {\"PR_DIRECTORY_LOOKUP_ERROR\",\n+     \"A directory lookup on a network address has failed\"},\n+    {\"PR_TPD_RANGE_ERROR\", \"Attempt to access a TPD key that is out of range\"},\n+    {\"PR_PROC_DESC_TABLE_FULL_ERROR\", \"Process open FD table is full\"},\n+    {\"PR_SYS_DESC_TABLE_FULL_ERROR\", \"System open FD table is full\"},\n+    {\"PR_NOT_SOCKET_ERROR\",\n+     \"Network operation attempted on non-network file descriptor\"},\n+    {\"PR_NOT_TCP_SOCKET_ERROR\",\n+     \"TCP-specific function attempted on a non-TCP file descriptor\"},\n+    {\"PR_SOCKET_ADDRESS_IS_BOUND_ERROR\",\n+     \"TCP file descriptor is already bound\"},\n+    {\"PR_NO_ACCESS_RIGHTS_ERROR\", \"Access Denied\"},\n+    {\"PR_OPERATION_NOT_SUPPORTED_ERROR\",\n+     \"The requested operation is not supported by the platform\"},\n+    {\"PR_PROTOCOL_NOT_SUPPORTED_ERROR\",\n+     \"The host operating system does not support the protocol requested\"},\n+    {\"PR_REMOTE_FILE_ERROR\", \"Access to the remote file has been severed\"},\n+    {\"PR_BUFFER_OVERFLOW_ERROR\",\n+     \"The value requested is too large to be stored in the data buffer \"\n+     \"provided\"},\n+    {\"PR_CONNECT_RESET_ERROR\", \"TCP connection reset by peer\"},\n+    {\"PR_RANGE_ERROR\", \"Unused\"},\n+    {\"PR_DEADLOCK_ERROR\", \"The operation would have deadlocked\"},\n+    {\"PR_FILE_IS_LOCKED_ERROR\", \"The file is already locked\"},\n+    {\"PR_FILE_TOO_BIG_ERROR\",\n+     \"Write would result in file larger than the system allows\"},\n+    {\"PR_NO_DEVICE_SPACE_ERROR\", \"The device for storing the file is full\"},\n+    {\"PR_PIPE_ERROR\", \"Unused\"},\n+    {\"PR_NO_SEEK_DEVICE_ERROR\", \"Unused\"},\n+    {\"PR_IS_DIRECTORY_ERROR\",\n+     \"Cannot perform a normal file operation on a directory\"},\n+    {\"PR_LOOP_ERROR\", \"Symbolic link loop\"},\n+    {\"PR_NAME_TOO_LONG_ERROR\", \"File name is too long\"},\n+    {\"PR_FILE_NOT_FOUND_ERROR\", \"File not found\"},\n+    {\"PR_NOT_DIRECTORY_ERROR\",\n+     \"Cannot perform directory operation on a normal file\"},\n+    {\"PR_READ_ONLY_FILESYSTEM_ERROR\",\n+     \"Cannot write to a read-only file system\"},\n+    {\"PR_DIRECTORY_NOT_EMPTY_ERROR\",\n+     \"Cannot delete a directory that is not empty\"},\n+    {\"PR_FILESYSTEM_MOUNTED_ERROR\",\n+     \"Cannot delete or rename a file object while the file system is busy\"},\n+    {\"PR_NOT_SAME_DEVICE_ERROR\",\n+     \"Cannot rename a file to a file system on another device\"},\n+    {\"PR_DIRECTORY_CORRUPTED_ERROR\",\n+     \"The directory object in the file system is corrupted\"},\n+    {\"PR_FILE_EXISTS_ERROR\",\n+     \"Cannot create or rename a filename that already exists\"},\n+    {\"PR_MAX_DIRECTORY_ENTRIES_ERROR\",\n+     \"Directory is full.  No additional filenames may be added\"},\n+    {\"PR_INVALID_DEVICE_STATE_ERROR\",\n+     \"The required device was in an invalid state\"},\n+    {\"PR_DEVICE_IS_LOCKED_ERROR\", \"The device is locked\"},\n+    {\"PR_NO_MORE_FILES_ERROR\", \"No more entries in the directory\"},\n+    {\"PR_END_OF_FILE_ERROR\", \"Encountered end of file\"},\n+    {\"PR_FILE_SEEK_ERROR\", \"Seek error\"},\n+    {\"PR_FILE_IS_BUSY_ERROR\", \"The file is busy\"},\n+    {\"PR_OPERATION_ABORTED_ERROR\", \"The I/O operation was aborted\"},\n+    {\"PR_IN_PROGRESS_ERROR\",\n+     \"Operation is still in progress (probably a non-blocking connect)\"},\n+    {\"PR_ALREADY_INITIATED_ERROR\",\n+     \"Operation has already been initiated (probably a non-blocking connect)\"},\n+    {\"PR_GROUP_EMPTY_ERROR\", \"The wait group is empty\"},\n+    {\"PR_INVALID_STATE_ERROR\", \"Object state improper for request\"},\n+    {\"PR_NETWORK_DOWN_ERROR\", \"Network is down\"},\n+    {\"PR_SOCKET_SHUTDOWN_ERROR\", \"Socket shutdown\"},\n+    {\"PR_CONNECT_ABORTED_ERROR\", \"Connection aborted\"},\n+    {\"PR_HOST_UNREACHABLE_ERROR\", \"Host is unreachable\"},\n+    {\"PR_LIBRARY_NOT_LOADED_ERROR\", \"The library is not loaded\"},\n+    {\"PR_CALL_ONCE_ERROR\",\n+     \"The one-time function was previously called and failed. Its error code \"\n+     \"is no longer available\"},\n+    {\"PR_MAX_ERROR\", \"Placeholder for the end of the list\"},\n+    {0, 0}};\n \n-static const struct PRErrorTable et = { text, \"prerr\", -6000L, 77 };\n+static const struct PRErrorTable et = {text, \"prerr\", -6000L, 77};\n \n-void\n-nspr_InitializePRErrorTable(void)\n-{\n-    PR_ErrorInstallTable(&et);\n-}\n+void nspr_InitializePRErrorTable(void) { PR_ErrorInstallTable(&et); }\ndiff --git a/nspr/pr/src/misc/prerror.c b/nspr/pr/src/misc/prerror.c\nindex 8a37170..b6a25d7 100644\n--- a/nspr/pr/src/misc/prerror.c\n+++ b/nspr/pr/src/misc/prerror.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,73 +8,61 @@\n #include <string.h>\n #include <stdlib.h>\n \n-PR_IMPLEMENT(PRErrorCode)\n-PR_GetError(void)\n-{\n-    PRThread* thread = PR_GetCurrentThread();\n-    return thread->errorCode;\n+PR_IMPLEMENT(PRErrorCode) PR_GetError(void) {\n+  PRThread* thread = PR_GetCurrentThread();\n+  return thread->errorCode;\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_GetOSError(void)\n-{\n-    PRThread* thread = PR_GetCurrentThread();\n-    return thread->osErrorCode;\n+PR_IMPLEMENT(PRInt32) PR_GetOSError(void) {\n+  PRThread* thread = PR_GetCurrentThread();\n+  return thread->osErrorCode;\n }\n \n-PR_IMPLEMENT(void)\n-PR_SetError(PRErrorCode code, PRInt32 osErr)\n-{\n-    PRThread* thread = PR_GetCurrentThread();\n-    thread->errorCode = code;\n-    thread->osErrorCode = osErr;\n-    thread->errorStringLength = 0;\n+PR_IMPLEMENT(void) PR_SetError(PRErrorCode code, PRInt32 osErr) {\n+  PRThread* thread = PR_GetCurrentThread();\n+  thread->errorCode = code;\n+  thread->osErrorCode = osErr;\n+  thread->errorStringLength = 0;\n }\n \n-PR_IMPLEMENT(void)\n-PR_SetErrorText(PRIntn textLength, const char* text)\n-{\n-    PRThread* thread = PR_GetCurrentThread();\n+PR_IMPLEMENT(void) PR_SetErrorText(PRIntn textLength, const char* text) {\n+  PRThread* thread = PR_GetCurrentThread();\n \n-    if (0 == textLength) {\n-        if (NULL != thread->errorString) {\n-            PR_DELETE(thread->errorString);\n-        }\n+  if (0 == textLength) {\n+    if (NULL != thread->errorString) {\n+      PR_DELETE(thread->errorString);\n+    }\n+    thread->errorStringSize = 0;\n+  } else {\n+    PRIntn size =\n+        textLength + 31; /* actual length to allocate. Plus a little extra */\n+    if (thread->errorStringSize < textLength + 1) /* do we have room? */\n+    {\n+      if (NULL != thread->errorString) {\n+        PR_DELETE(thread->errorString);\n+      }\n+      thread->errorString = (char*)PR_MALLOC(size);\n+      if (NULL == thread->errorString) {\n         thread->errorStringSize = 0;\n-    } else {\n-        PRIntn size =\n-            textLength + 31;                          /* actual length to allocate. Plus a little extra */\n-        if (thread->errorStringSize < textLength + 1) /* do we have room? */\n-        {\n-            if (NULL != thread->errorString) {\n-                PR_DELETE(thread->errorString);\n-            }\n-            thread->errorString = (char*)PR_MALLOC(size);\n-            if (NULL == thread->errorString) {\n-                thread->errorStringSize = 0;\n-                thread->errorStringLength = 0;\n-                return;\n-            }\n-            thread->errorStringSize = size;\n-        }\n-        memcpy(thread->errorString, text, textLength + 1);\n+        thread->errorStringLength = 0;\n+        return;\n+      }\n+      thread->errorStringSize = size;\n     }\n-    thread->errorStringLength = textLength;\n+    memcpy(thread->errorString, text, textLength + 1);\n+  }\n+  thread->errorStringLength = textLength;\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_GetErrorTextLength(void)\n-{\n-    PRThread* thread = PR_GetCurrentThread();\n-    return thread->errorStringLength;\n+PR_IMPLEMENT(PRInt32) PR_GetErrorTextLength(void) {\n+  PRThread* thread = PR_GetCurrentThread();\n+  return thread->errorStringLength;\n } /* PR_GetErrorTextLength */\n \n-PR_IMPLEMENT(PRInt32)\n-PR_GetErrorText(char* text)\n-{\n-    PRThread* thread = PR_GetCurrentThread();\n-    if (0 != thread->errorStringLength) {\n-        memcpy(text, thread->errorString, thread->errorStringLength + 1);\n-    }\n-    return thread->errorStringLength;\n+PR_IMPLEMENT(PRInt32) PR_GetErrorText(char* text) {\n+  PRThread* thread = PR_GetCurrentThread();\n+  if (0 != thread->errorStringLength) {\n+    memcpy(text, thread->errorString, thread->errorStringLength + 1);\n+  }\n+  return thread->errorStringLength;\n } /* PR_GetErrorText */\ndiff --git a/nspr/pr/src/misc/prerrortable.c b/nspr/pr/src/misc/prerrortable.c\nindex f64ee74..a0b0b4d 100644\n--- a/nspr/pr/src/misc/prerrortable.c\n+++ b/nspr/pr/src/misc/prerrortable.c\n@@ -37,14 +37,14 @@ extern const int sys_nerr;\n \n /* List of error tables */\n struct PRErrorTableList {\n-    struct PRErrorTableList* next;\n-    const struct PRErrorTable* table;\n-    struct PRErrorCallbackTablePrivate* table_private;\n+  struct PRErrorTableList* next;\n+  const struct PRErrorTable* table;\n+  struct PRErrorCallbackTablePrivate* table_private;\n };\n static struct PRErrorTableList* Table_List = (struct PRErrorTableList*)NULL;\n \n /* Supported languages */\n-static const char* default_languages[] = { \"i-default\", \"en\", 0 };\n+static const char* default_languages[] = {\"i-default\", \"en\", 0};\n static const char* const* callback_languages = default_languages;\n \n /* Callback info */\n@@ -55,145 +55,138 @@ static PRErrorCallbackNewTableFn* callback_newtable = 0;\n static const char char_set[] =\n     \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_\";\n \n-static const char*\n-error_table_name(PRErrorCode num)\n-{\n-    static char buf[6]; /* only used if internal code problems exist */\n-\n-    long ch;\n-    int i;\n-    char* p;\n-\n-    /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */\n-    p = buf;\n-    num >>= ERRCODE_RANGE;\n-    /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */\n-    num &= 077777777;\n-    /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */\n-    for (i = 4; i >= 0; i--) {\n-        ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);\n-        if (ch != 0) {\n-            *p++ = char_set[ch - 1];\n-        }\n+static const char* error_table_name(PRErrorCode num) {\n+  static char buf[6]; /* only used if internal code problems exist */\n+\n+  long ch;\n+  int i;\n+  char* p;\n+\n+  /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */\n+  p = buf;\n+  num >>= ERRCODE_RANGE;\n+  /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */\n+  num &= 077777777;\n+  /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */\n+  for (i = 4; i >= 0; i--) {\n+    ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);\n+    if (ch != 0) {\n+      *p++ = char_set[ch - 1];\n     }\n-    *p = '\\0';\n-    return (buf);\n+  }\n+  *p = '\\0';\n+  return (buf);\n }\n \n PR_IMPLEMENT(const char*)\n-PR_ErrorToString(PRErrorCode code, PRLanguageCode language)\n-{\n-    /* static buffer only used if code is using inconsistent error message\n-     * numbers, so just ignore the possible thread contention\n-     */\n-    static char buffer[25];\n-\n-    const char* msg;\n-    int offset;\n-    PRErrorCode table_num;\n-    struct PRErrorTableList* et;\n-    int started = 0;\n-    char* cp;\n-\n-    for (et = Table_List; et; et = et->next) {\n-        if (et->table->base <= code && et->table->base + et->table->n_msgs > code) {\n-            /* This is the right table */\n-            if (callback_lookup) {\n-                msg = callback_lookup(code, language, et->table, callback_private,\n-                                      et->table_private);\n-                if (msg) {\n-                    return msg;\n-                }\n-            }\n-\n-            return (et->table->msgs[code - et->table->base].en_text);\n+PR_ErrorToString(PRErrorCode code, PRLanguageCode language) {\n+  /* static buffer only used if code is using inconsistent error message\n+   * numbers, so just ignore the possible thread contention\n+   */\n+  static char buffer[25];\n+\n+  const char* msg;\n+  int offset;\n+  PRErrorCode table_num;\n+  struct PRErrorTableList* et;\n+  int started = 0;\n+  char* cp;\n+\n+  for (et = Table_List; et; et = et->next) {\n+    if (et->table->base <= code && et->table->base + et->table->n_msgs > code) {\n+      /* This is the right table */\n+      if (callback_lookup) {\n+        msg = callback_lookup(code, language, et->table, callback_private,\n+                              et->table_private);\n+        if (msg) {\n+          return msg;\n         }\n-    }\n+      }\n \n-    if (code >= 0 && code < 256) {\n-        return strerror(code);\n-    }\n-\n-    offset = (int)(code & ((1 << ERRCODE_RANGE) - 1));\n-    table_num = code - offset;\n-    strcpy(buffer, \"Unknown code \");\n-    if (table_num) {\n-        strcat(buffer, error_table_name(table_num));\n-        strcat(buffer, \" \");\n-    }\n-    for (cp = buffer; *cp; cp++)\n-        ;\n-    if (offset >= 100) {\n-        *cp++ = (char)('0' + offset / 100);\n-        offset %= 100;\n-        started++;\n-    }\n-    if (started || offset >= 10) {\n-        *cp++ = (char)('0' + offset / 10);\n-        offset %= 10;\n+      return (et->table->msgs[code - et->table->base].en_text);\n     }\n-    *cp++ = (char)('0' + offset);\n-    *cp = '\\0';\n-    return (buffer);\n+  }\n+\n+  if (code >= 0 && code < 256) {\n+    return strerror(code);\n+  }\n+\n+  offset = (int)(code & ((1 << ERRCODE_RANGE) - 1));\n+  table_num = code - offset;\n+  strcpy(buffer, \"Unknown code \");\n+  if (table_num) {\n+    strcat(buffer, error_table_name(table_num));\n+    strcat(buffer, \" \");\n+  }\n+  for (cp = buffer; *cp; cp++);\n+  if (offset >= 100) {\n+    *cp++ = (char)('0' + offset / 100);\n+    offset %= 100;\n+    started++;\n+  }\n+  if (started || offset >= 10) {\n+    *cp++ = (char)('0' + offset / 10);\n+    offset %= 10;\n+  }\n+  *cp++ = (char)('0' + offset);\n+  *cp = '\\0';\n+  return (buffer);\n }\n \n PR_IMPLEMENT(const char*)\n-PR_ErrorToName(PRErrorCode code)\n-{\n-    struct PRErrorTableList* et;\n+PR_ErrorToName(PRErrorCode code) {\n+  struct PRErrorTableList* et;\n \n-    for (et = Table_List; et; et = et->next) {\n-        if (et->table->base <= code && et->table->base + et->table->n_msgs > code) {\n-            /* This is the right table */\n-            return (et->table->msgs[code - et->table->base].name);\n-        }\n+  for (et = Table_List; et; et = et->next) {\n+    if (et->table->base <= code && et->table->base + et->table->n_msgs > code) {\n+      /* This is the right table */\n+      return (et->table->msgs[code - et->table->base].name);\n     }\n+  }\n \n-    return 0;\n+  return 0;\n }\n \n PR_IMPLEMENT(const char* const*)\n PR_ErrorLanguages(void) { return callback_languages; }\n \n PR_IMPLEMENT(PRErrorCode)\n-PR_ErrorInstallTable(const struct PRErrorTable* table)\n-{\n-    struct PRErrorTableList* new_et;\n-\n-    new_et = (struct PRErrorTableList*)PR_Malloc(sizeof(struct PRErrorTableList));\n-    if (!new_et) {\n-        return errno; /* oops */\n-    }\n-    new_et->table = table;\n-    if (callback_newtable) {\n-        new_et->table_private = callback_newtable(table, callback_private);\n-    } else {\n-        new_et->table_private = 0;\n-    }\n-    new_et->next = Table_List;\n-    Table_List = new_et;\n-    return 0;\n+PR_ErrorInstallTable(const struct PRErrorTable* table) {\n+  struct PRErrorTableList* new_et;\n+\n+  new_et = (struct PRErrorTableList*)PR_Malloc(sizeof(struct PRErrorTableList));\n+  if (!new_et) {\n+    return errno; /* oops */\n+  }\n+  new_et->table = table;\n+  if (callback_newtable) {\n+    new_et->table_private = callback_newtable(table, callback_private);\n+  } else {\n+    new_et->table_private = 0;\n+  }\n+  new_et->next = Table_List;\n+  Table_List = new_et;\n+  return 0;\n }\n \n PR_IMPLEMENT(void)\n PR_ErrorInstallCallback(const char* const* languages,\n                         PRErrorCallbackLookupFn* lookup,\n                         PRErrorCallbackNewTableFn* newtable,\n-                        struct PRErrorCallbackPrivate* cb_private)\n-{\n-    struct PRErrorTableList* et;\n+                        struct PRErrorCallbackPrivate* cb_private) {\n+  struct PRErrorTableList* et;\n \n-    assert(strcmp(languages[0], \"i-default\") == 0);\n-    assert(strcmp(languages[1], \"en\") == 0);\n+  assert(strcmp(languages[0], \"i-default\") == 0);\n+  assert(strcmp(languages[1], \"en\") == 0);\n \n-    callback_languages = languages;\n-    callback_lookup = lookup;\n-    callback_newtable = newtable;\n-    callback_private = cb_private;\n+  callback_languages = languages;\n+  callback_lookup = lookup;\n+  callback_newtable = newtable;\n+  callback_private = cb_private;\n \n-    if (callback_newtable) {\n-        for (et = Table_List; et; et = et->next) {\n-            et->table_private = callback_newtable(et->table, callback_private);\n-        }\n+  if (callback_newtable) {\n+    for (et = Table_List; et; et = et->next) {\n+      et->table_private = callback_newtable(et->table, callback_private);\n     }\n+  }\n }\ndiff --git a/nspr/pr/src/misc/prinit.c b/nspr/pr/src/misc/prinit.c\nindex 5802cd9..d36a7de 100644\n--- a/nspr/pr/src/misc/prinit.c\n+++ b/nspr/pr/src/misc/prinit.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -38,14 +39,14 @@ PRInt32 _pr_userActive;\n PRInt32 _pr_systemActive;\n PRUintn _pr_maxPTDs;\n \n-#ifdef _PR_LOCAL_THREADS_ONLY\n+#  ifdef _PR_LOCAL_THREADS_ONLY\n \n struct _PRCPU* _pr_currentCPU;\n PRThread* _pr_currentThread;\n PRThread* _pr_lastThread;\n PRInt32 _pr_intsOff;\n \n-#endif /* _PR_LOCAL_THREADS_ONLY */\n+#  endif /* _PR_LOCAL_THREADS_ONLY */\n \n /* Lock protecting all \"termination\" condition variables of all threads */\n PRLock* _pr_terminationCVLock;\n@@ -58,217 +59,197 @@ static void _PR_InitCallOnce(void);\n \n PRBool _pr_initialized = PR_FALSE;\n \n-PR_IMPLEMENT(PRBool)\n-PR_VersionCheck(const char* importedVersion)\n-{\n-    /*\n-    ** This is the secret handshake algorithm.\n-    **\n-    ** This release has a simple version compatibility\n-    ** check algorithm.  This release is not backward\n-    ** compatible with previous major releases.  It is\n-    ** not compatible with future major, minor, or\n-    ** patch releases.\n-    */\n-    int vmajor = 0, vminor = 0, vpatch = 0;\n-    const char* ptr = importedVersion;\n-\n+PR_IMPLEMENT(PRBool) PR_VersionCheck(const char* importedVersion) {\n+  /*\n+  ** This is the secret handshake algorithm.\n+  **\n+  ** This release has a simple version compatibility\n+  ** check algorithm.  This release is not backward\n+  ** compatible with previous major releases.  It is\n+  ** not compatible with future major, minor, or\n+  ** patch releases.\n+  */\n+  int vmajor = 0, vminor = 0, vpatch = 0;\n+  const char* ptr = importedVersion;\n+\n+  while (isdigit(*ptr)) {\n+    vmajor = 10 * vmajor + *ptr - '0';\n+    ptr++;\n+  }\n+  if (*ptr == '.') {\n+    ptr++;\n     while (isdigit(*ptr)) {\n-        vmajor = 10 * vmajor + *ptr - '0';\n-        ptr++;\n+      vminor = 10 * vminor + *ptr - '0';\n+      ptr++;\n     }\n     if (*ptr == '.') {\n+      ptr++;\n+      while (isdigit(*ptr)) {\n+        vpatch = 10 * vpatch + *ptr - '0';\n         ptr++;\n-        while (isdigit(*ptr)) {\n-            vminor = 10 * vminor + *ptr - '0';\n-            ptr++;\n-        }\n-        if (*ptr == '.') {\n-            ptr++;\n-            while (isdigit(*ptr)) {\n-                vpatch = 10 * vpatch + *ptr - '0';\n-                ptr++;\n-            }\n-        }\n+      }\n     }\n+  }\n \n-    if (vmajor != PR_VMAJOR) {\n-        return PR_FALSE;\n-    }\n-    if (vmajor == PR_VMAJOR && vminor > PR_VMINOR) {\n-        return PR_FALSE;\n-    }\n-    if (vmajor == PR_VMAJOR && vminor == PR_VMINOR && vpatch > PR_VPATCH) {\n-        return PR_FALSE;\n-    }\n-    return PR_TRUE;\n+  if (vmajor != PR_VMAJOR) {\n+    return PR_FALSE;\n+  }\n+  if (vmajor == PR_VMAJOR && vminor > PR_VMINOR) {\n+    return PR_FALSE;\n+  }\n+  if (vmajor == PR_VMAJOR && vminor == PR_VMINOR && vpatch > PR_VPATCH) {\n+    return PR_FALSE;\n+  }\n+  return PR_TRUE;\n } /* PR_VersionCheck */\n \n-PR_IMPLEMENT(const char*)\n-PR_GetVersion(void) { return PR_VERSION; }\n+PR_IMPLEMENT(const char*) PR_GetVersion(void) { return PR_VERSION; }\n \n-PR_IMPLEMENT(PRBool)\n-PR_Initialized(void) { return _pr_initialized; }\n+PR_IMPLEMENT(PRBool) PR_Initialized(void) { return _pr_initialized; }\n \n PRInt32 _native_threads_only = 0;\n \n #ifdef WINNT\n-static void\n-_pr_SetNativeThreadsOnlyMode(void)\n-{\n-    HMODULE mainExe;\n-    PRBool* globalp;\n-    char* envp;\n-\n-    mainExe = GetModuleHandle(NULL);\n-    PR_ASSERT(NULL != mainExe);\n-    globalp = (PRBool*)GetProcAddress(mainExe, \"nspr_native_threads_only\");\n-    if (globalp) {\n-        _native_threads_only = (*globalp != PR_FALSE);\n-    } else if (envp = getenv(\"NSPR_NATIVE_THREADS_ONLY\")) {\n-        _native_threads_only = (atoi(envp) == 1);\n-    }\n+static void _pr_SetNativeThreadsOnlyMode(void) {\n+  HMODULE mainExe;\n+  PRBool* globalp;\n+  char* envp;\n+\n+  mainExe = GetModuleHandle(NULL);\n+  PR_ASSERT(NULL != mainExe);\n+  globalp = (PRBool*)GetProcAddress(mainExe, \"nspr_native_threads_only\");\n+  if (globalp) {\n+    _native_threads_only = (*globalp != PR_FALSE);\n+  } else if (envp = getenv(\"NSPR_NATIVE_THREADS_ONLY\")) {\n+    _native_threads_only = (atoi(envp) == 1);\n+  }\n }\n #endif\n \n-static void\n-_PR_InitStuff(void)\n-{\n-    if (_pr_initialized) {\n-        return;\n-    }\n-    _pr_initialized = PR_TRUE;\n+static void _PR_InitStuff(void) {\n+  if (_pr_initialized) {\n+    return;\n+  }\n+  _pr_initialized = PR_TRUE;\n #ifdef _PR_ZONE_ALLOCATOR\n-    _PR_InitZones();\n+  _PR_InitZones();\n #endif\n #ifdef WINNT\n-    _pr_SetNativeThreadsOnlyMode();\n+  _pr_SetNativeThreadsOnlyMode();\n #endif\n \n-    (void)PR_GetPageSize();\n-\n-    _pr_clock_lm = PR_NewLogModule(\"clock\");\n-    _pr_cmon_lm = PR_NewLogModule(\"cmon\");\n-    _pr_io_lm = PR_NewLogModule(\"io\");\n-    _pr_mon_lm = PR_NewLogModule(\"mon\");\n-    _pr_linker_lm = PR_NewLogModule(\"linker\");\n-    _pr_cvar_lm = PR_NewLogModule(\"cvar\");\n-    _pr_sched_lm = PR_NewLogModule(\"sched\");\n-    _pr_thread_lm = PR_NewLogModule(\"thread\");\n-    _pr_gc_lm = PR_NewLogModule(\"gc\");\n-    _pr_shm_lm = PR_NewLogModule(\"shm\");\n-    _pr_shma_lm = PR_NewLogModule(\"shma\");\n-\n-    /* NOTE: These init's cannot depend on _PR_MD_CURRENT_THREAD() */\n-    _PR_MD_EARLY_INIT();\n-\n-    _PR_InitLocks();\n-    _PR_InitAtomic();\n-    _PR_InitSegs();\n-    _PR_InitStacks();\n-    _PR_InitTPD();\n-    _PR_InitEnv();\n-    _PR_InitLayerCache();\n-    _PR_InitClock();\n-\n-    _pr_sleeplock = PR_NewLock();\n-    PR_ASSERT(NULL != _pr_sleeplock);\n-\n-    _PR_InitThreads(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  (void)PR_GetPageSize();\n+\n+  _pr_clock_lm = PR_NewLogModule(\"clock\");\n+  _pr_cmon_lm = PR_NewLogModule(\"cmon\");\n+  _pr_io_lm = PR_NewLogModule(\"io\");\n+  _pr_mon_lm = PR_NewLogModule(\"mon\");\n+  _pr_linker_lm = PR_NewLogModule(\"linker\");\n+  _pr_cvar_lm = PR_NewLogModule(\"cvar\");\n+  _pr_sched_lm = PR_NewLogModule(\"sched\");\n+  _pr_thread_lm = PR_NewLogModule(\"thread\");\n+  _pr_gc_lm = PR_NewLogModule(\"gc\");\n+  _pr_shm_lm = PR_NewLogModule(\"shm\");\n+  _pr_shma_lm = PR_NewLogModule(\"shma\");\n+\n+  /* NOTE: These init's cannot depend on _PR_MD_CURRENT_THREAD() */\n+  _PR_MD_EARLY_INIT();\n+\n+  _PR_InitLocks();\n+  _PR_InitAtomic();\n+  _PR_InitSegs();\n+  _PR_InitStacks();\n+  _PR_InitTPD();\n+  _PR_InitEnv();\n+  _PR_InitLayerCache();\n+  _PR_InitClock();\n+\n+  _pr_sleeplock = PR_NewLock();\n+  PR_ASSERT(NULL != _pr_sleeplock);\n+\n+  _PR_InitThreads(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n #ifndef _PR_GLOBAL_THREADS_ONLY\n-    _PR_InitCPUs();\n+  _PR_InitCPUs();\n #endif\n \n-    /*\n-     * XXX: call _PR_InitMem only on those platforms for which nspr implements\n-     *  malloc, for now.\n-     */\n+  /*\n+   * XXX: call _PR_InitMem only on those platforms for which nspr implements\n+   *  malloc, for now.\n+   */\n #ifdef _PR_OVERRIDE_MALLOC\n-    _PR_InitMem();\n+  _PR_InitMem();\n #endif\n \n-    _PR_InitCMon();\n-    _PR_InitIO();\n-    _PR_InitNet();\n-    _PR_InitTime();\n-    _PR_InitLog();\n-    _PR_InitLinker();\n-    _PR_InitCallOnce();\n-    _PR_InitDtoa();\n-    _PR_InitMW();\n-    _PR_InitRWLocks();\n+  _PR_InitCMon();\n+  _PR_InitIO();\n+  _PR_InitNet();\n+  _PR_InitTime();\n+  _PR_InitLog();\n+  _PR_InitLinker();\n+  _PR_InitCallOnce();\n+  _PR_InitDtoa();\n+  _PR_InitMW();\n+  _PR_InitRWLocks();\n \n-    nspr_InitializePRErrorTable();\n+  nspr_InitializePRErrorTable();\n \n-    _PR_MD_FINAL_INIT();\n+  _PR_MD_FINAL_INIT();\n }\n \n-void\n-_PR_ImplicitInitialization(void)\n-{\n-    _PR_InitStuff();\n+void _PR_ImplicitInitialization(void) {\n+  _PR_InitStuff();\n \n-    /* Enable interrupts */\n+  /* Enable interrupts */\n #if !defined(_PR_PTHREADS) && !defined(_PR_GLOBAL_THREADS_ONLY)\n-    _PR_MD_START_INTERRUPTS();\n+  _PR_MD_START_INTERRUPTS();\n #endif\n }\n \n-PR_IMPLEMENT(void)\n-PR_DisableClockInterrupts(void)\n-{\n+PR_IMPLEMENT(void) PR_DisableClockInterrupts(void) {\n #if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS)\n-    if (!_pr_initialized) {\n-        _PR_InitStuff();\n-    } else {\n-        _PR_MD_DISABLE_CLOCK_INTERRUPTS();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_InitStuff();\n+  } else {\n+    _PR_MD_DISABLE_CLOCK_INTERRUPTS();\n+  }\n #endif\n }\n \n-PR_IMPLEMENT(void)\n-PR_EnableClockInterrupts(void)\n-{\n+PR_IMPLEMENT(void) PR_EnableClockInterrupts(void) {\n #if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS)\n-    if (!_pr_initialized) {\n-        _PR_InitStuff();\n-    }\n-    _PR_MD_ENABLE_CLOCK_INTERRUPTS();\n+  if (!_pr_initialized) {\n+    _PR_InitStuff();\n+  }\n+  _PR_MD_ENABLE_CLOCK_INTERRUPTS();\n #endif\n }\n \n-PR_IMPLEMENT(void)\n-PR_BlockClockInterrupts(void)\n-{\n+PR_IMPLEMENT(void) PR_BlockClockInterrupts(void) {\n #if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS)\n-    _PR_MD_BLOCK_CLOCK_INTERRUPTS();\n+  _PR_MD_BLOCK_CLOCK_INTERRUPTS();\n #endif\n }\n \n-PR_IMPLEMENT(void)\n-PR_UnblockClockInterrupts(void)\n-{\n+PR_IMPLEMENT(void) PR_UnblockClockInterrupts(void) {\n #if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS)\n-    _PR_MD_UNBLOCK_CLOCK_INTERRUPTS();\n+  _PR_MD_UNBLOCK_CLOCK_INTERRUPTS();\n #endif\n }\n \n PR_IMPLEMENT(void)\n-PR_Init(PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs)\n-{\n-    _PR_ImplicitInitialization();\n+PR_Init(PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs) {\n+  _PR_ImplicitInitialization();\n }\n \n PR_IMPLEMENT(PRIntn)\n PR_Initialize(PRPrimordialFn prmain, PRIntn argc, char** argv,\n-              PRUintn maxPTDs)\n-{\n-    PRIntn rv;\n-    _PR_ImplicitInitialization();\n-    rv = prmain(argc, argv);\n-    PR_Cleanup();\n-    return rv;\n+              PRUintn maxPTDs) {\n+  PRIntn rv;\n+  _PR_ImplicitInitialization();\n+  rv = prmain(argc, argv);\n+  PR_Cleanup();\n+  return rv;\n } /* PR_Initialize */\n \n /*\n@@ -288,25 +269,23 @@ PR_Initialize(PRPrimordialFn prmain, PRIntn argc, char** argv,\n #if defined(_PR_PTHREADS) || defined(_PR_BTHREADS)\n /* see ptthread.c */\n #else\n-static void\n-_PR_CleanupBeforeExit(void)\n-{\n-    /*\n-    Do not make any calls here other than to destroy resources.  For example,\n-    do not make any calls that eventually may end up in PR_Lock.  Because the\n-    thread is destroyed, can not access current thread any more.\n-    */\n-    _PR_CleanupTPD();\n-    if (_pr_terminationCVLock)\n-    /*\n-     * In light of the comment above, this looks real suspicious.\n-     * I'd go so far as to say it's just a problem waiting to happen.\n-     */\n-    {\n-        PR_DestroyLock(_pr_terminationCVLock);\n-    }\n-\n-    _PR_MD_CLEANUP_BEFORE_EXIT();\n+static void _PR_CleanupBeforeExit(void) {\n+  /*\n+  Do not make any calls here other than to destroy resources.  For example,\n+  do not make any calls that eventually may end up in PR_Lock.  Because the\n+  thread is destroyed, can not access current thread any more.\n+  */\n+  _PR_CleanupTPD();\n+  if (_pr_terminationCVLock)\n+  /*\n+   * In light of the comment above, this looks real suspicious.\n+   * I'd go so far as to say it's just a problem waiting to happen.\n+   */\n+  {\n+    PR_DestroyLock(_pr_terminationCVLock);\n+  }\n+\n+  _PR_MD_CLEANUP_BEFORE_EXIT();\n }\n #endif /* defined(_PR_PTHREADS) */\n \n@@ -338,87 +317,85 @@ _PR_CleanupBeforeExit(void)\n /* see ptthread.c */\n #else\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Cleanup()\n-{\n-    PRThread* me = PR_GetCurrentThread();\n-    PR_ASSERT((NULL != me) && (me->flags & _PR_PRIMORDIAL));\n-    if ((NULL != me) && (me->flags & _PR_PRIMORDIAL)) {\n-        PR_LOG(_pr_thread_lm, PR_LOG_MIN, (\"PR_Cleanup: shutting down NSPR\"));\n-\n-        /*\n-         * No more recycling of threads\n-         */\n-        _pr_recycleThreads = 0;\n+PR_IMPLEMENT(PRStatus) PR_Cleanup() {\n+  PRThread* me = PR_GetCurrentThread();\n+  PR_ASSERT((NULL != me) && (me->flags & _PR_PRIMORDIAL));\n+  if ((NULL != me) && (me->flags & _PR_PRIMORDIAL)) {\n+    PR_LOG(_pr_thread_lm, PR_LOG_MIN, (\"PR_Cleanup: shutting down NSPR\"));\n \n-        /*\n-         * Wait for all other user (non-system/daemon) threads\n-         * to terminate.\n-         */\n-        PR_Lock(_pr_activeLock);\n-        while (_pr_userActive > _pr_primordialExitCount) {\n-            PR_WaitCondVar(_pr_primordialExitCVar, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        if (me->flags & _PR_SYSTEM) {\n-            _pr_systemActive--;\n-        } else {\n-            _pr_userActive--;\n-        }\n-        PR_Unlock(_pr_activeLock);\n+    /*\n+     * No more recycling of threads\n+     */\n+    _pr_recycleThreads = 0;\n \n-        _PR_MD_EARLY_CLEANUP();\n+    /*\n+     * Wait for all other user (non-system/daemon) threads\n+     * to terminate.\n+     */\n+    PR_Lock(_pr_activeLock);\n+    while (_pr_userActive > _pr_primordialExitCount) {\n+      PR_WaitCondVar(_pr_primordialExitCVar, PR_INTERVAL_NO_TIMEOUT);\n+    }\n+    if (me->flags & _PR_SYSTEM) {\n+      _pr_systemActive--;\n+    } else {\n+      _pr_userActive--;\n+    }\n+    PR_Unlock(_pr_activeLock);\n \n-        _PR_CleanupMW();\n-        _PR_CleanupTime();\n-        _PR_CleanupDtoa();\n-        _PR_CleanupCallOnce();\n-        _PR_ShutdownLinker();\n-        _PR_CleanupNet();\n-        _PR_CleanupIO();\n-        /* Release the primordial thread's private data, etc. */\n-        _PR_CleanupThread(me);\n+    _PR_MD_EARLY_CLEANUP();\n \n-        _PR_MD_STOP_INTERRUPTS();\n+    _PR_CleanupMW();\n+    _PR_CleanupTime();\n+    _PR_CleanupDtoa();\n+    _PR_CleanupCallOnce();\n+    _PR_ShutdownLinker();\n+    _PR_CleanupNet();\n+    _PR_CleanupIO();\n+    /* Release the primordial thread's private data, etc. */\n+    _PR_CleanupThread(me);\n \n-        PR_LOG(_pr_thread_lm, PR_LOG_MIN,\n-               (\"PR_Cleanup: clean up before destroying thread\"));\n-        _PR_LogCleanup();\n+    _PR_MD_STOP_INTERRUPTS();\n \n-        /*\n-         * This part should look like the end of _PR_NativeRunThread\n-         * and _PR_UserRunThread.\n-         */\n-        if (_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_MD_EXIT_THREAD(me);\n-            _PR_NativeDestroyThread(me);\n-        } else {\n-            _PR_UserDestroyThread(me);\n-            PR_DELETE(me->stack);\n-            PR_DELETE(me);\n-        }\n+    PR_LOG(_pr_thread_lm, PR_LOG_MIN,\n+           (\"PR_Cleanup: clean up before destroying thread\"));\n+    _PR_LogCleanup();\n \n-        /*\n-         * XXX: We are freeing the heap memory here so that Purify won't\n-         * complain, but we should also free other kinds of resources\n-         * that are allocated by the _PR_InitXXX() functions.\n-         * Ideally, for each _PR_InitXXX(), there should be a corresponding\n-         * _PR_XXXCleanup() that we can call here.\n-         */\n-#ifdef WINNT\n-        _PR_CleanupCPUs();\n-#endif\n-        _PR_CleanupThreads();\n-        _PR_CleanupCMon();\n-        PR_DestroyLock(_pr_sleeplock);\n-        _pr_sleeplock = NULL;\n-        _PR_CleanupLayerCache();\n-        _PR_CleanupEnv();\n-        _PR_CleanupStacks();\n-        _PR_CleanupBeforeExit();\n-        _pr_initialized = PR_FALSE;\n-        return PR_SUCCESS;\n+    /*\n+     * This part should look like the end of _PR_NativeRunThread\n+     * and _PR_UserRunThread.\n+     */\n+    if (_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_MD_EXIT_THREAD(me);\n+      _PR_NativeDestroyThread(me);\n+    } else {\n+      _PR_UserDestroyThread(me);\n+      PR_DELETE(me->stack);\n+      PR_DELETE(me);\n     }\n-    return PR_FAILURE;\n+\n+    /*\n+     * XXX: We are freeing the heap memory here so that Purify won't\n+     * complain, but we should also free other kinds of resources\n+     * that are allocated by the _PR_InitXXX() functions.\n+     * Ideally, for each _PR_InitXXX(), there should be a corresponding\n+     * _PR_XXXCleanup() that we can call here.\n+     */\n+#  ifdef WINNT\n+    _PR_CleanupCPUs();\n+#  endif\n+    _PR_CleanupThreads();\n+    _PR_CleanupCMon();\n+    PR_DestroyLock(_pr_sleeplock);\n+    _pr_sleeplock = NULL;\n+    _PR_CleanupLayerCache();\n+    _PR_CleanupEnv();\n+    _PR_CleanupStacks();\n+    _PR_CleanupBeforeExit();\n+    _pr_initialized = PR_FALSE;\n+    return PR_SUCCESS;\n+  }\n+  return PR_FAILURE;\n }\n #endif /* defined(_PR_PTHREADS) */\n \n@@ -438,56 +415,51 @@ PR_Cleanup()\n #if defined(_PR_PTHREADS) || defined(_PR_BTHREADS)\n /* see ptthread.c */\n #else\n-PR_IMPLEMENT(void)\n-PR_ProcessExit(PRIntn status) { _PR_MD_EXIT(status); }\n+PR_IMPLEMENT(void) PR_ProcessExit(PRIntn status) { _PR_MD_EXIT(status); }\n \n #endif /* defined(_PR_PTHREADS) */\n \n PR_IMPLEMENT(PRProcessAttr*)\n-PR_NewProcessAttr(void)\n-{\n-    PRProcessAttr* attr;\n-\n-    attr = PR_NEWZAP(PRProcessAttr);\n-    if (!attr) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-    }\n-    return attr;\n+PR_NewProcessAttr(void) {\n+  PRProcessAttr* attr;\n+\n+  attr = PR_NEWZAP(PRProcessAttr);\n+  if (!attr) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  }\n+  return attr;\n }\n \n PR_IMPLEMENT(void)\n-PR_ResetProcessAttr(PRProcessAttr* attr)\n-{\n-    PR_FREEIF(attr->currentDirectory);\n-    PR_FREEIF(attr->fdInheritBuffer);\n-    memset(attr, 0, sizeof(*attr));\n+PR_ResetProcessAttr(PRProcessAttr* attr) {\n+  PR_FREEIF(attr->currentDirectory);\n+  PR_FREEIF(attr->fdInheritBuffer);\n+  memset(attr, 0, sizeof(*attr));\n }\n \n PR_IMPLEMENT(void)\n-PR_DestroyProcessAttr(PRProcessAttr* attr)\n-{\n-    PR_FREEIF(attr->currentDirectory);\n-    PR_FREEIF(attr->fdInheritBuffer);\n-    PR_DELETE(attr);\n+PR_DestroyProcessAttr(PRProcessAttr* attr) {\n+  PR_FREEIF(attr->currentDirectory);\n+  PR_FREEIF(attr->fdInheritBuffer);\n+  PR_DELETE(attr);\n }\n \n PR_IMPLEMENT(void)\n PR_ProcessAttrSetStdioRedirect(PRProcessAttr* attr, PRSpecialFD stdioFd,\n-                               PRFileDesc* redirectFd)\n-{\n-    switch (stdioFd) {\n-        case PR_StandardInput:\n-            attr->stdinFd = redirectFd;\n-            break;\n-        case PR_StandardOutput:\n-            attr->stdoutFd = redirectFd;\n-            break;\n-        case PR_StandardError:\n-            attr->stderrFd = redirectFd;\n-            break;\n-        default:\n-            PR_ASSERT(0);\n-    }\n+                               PRFileDesc* redirectFd) {\n+  switch (stdioFd) {\n+    case PR_StandardInput:\n+      attr->stdinFd = redirectFd;\n+      break;\n+    case PR_StandardOutput:\n+      attr->stdoutFd = redirectFd;\n+      break;\n+    case PR_StandardError:\n+      attr->stderrFd = redirectFd;\n+      break;\n+    default:\n+      PR_ASSERT(0);\n+  }\n }\n \n /*\n@@ -495,226 +467,213 @@ PR_ProcessAttrSetStdioRedirect(PRProcessAttr* attr, PRSpecialFD stdioFd,\n  */\n PR_IMPLEMENT(void)\n PR_SetStdioRedirect(PRProcessAttr* attr, PRSpecialFD stdioFd,\n-                    PRFileDesc* redirectFd)\n-{\n+                    PRFileDesc* redirectFd) {\n #if defined(DEBUG)\n-    static PRBool warn = PR_TRUE;\n-    if (warn) {\n-        warn = _PR_Obsolete(\"PR_SetStdioRedirect()\",\n-                            \"PR_ProcessAttrSetStdioRedirect()\");\n-    }\n+  static PRBool warn = PR_TRUE;\n+  if (warn) {\n+    warn = _PR_Obsolete(\"PR_SetStdioRedirect()\",\n+                        \"PR_ProcessAttrSetStdioRedirect()\");\n+  }\n #endif\n-    PR_ProcessAttrSetStdioRedirect(attr, stdioFd, redirectFd);\n+  PR_ProcessAttrSetStdioRedirect(attr, stdioFd, redirectFd);\n }\n \n PR_IMPLEMENT(PRStatus)\n-PR_ProcessAttrSetCurrentDirectory(PRProcessAttr* attr, const char* dir)\n-{\n-    PR_FREEIF(attr->currentDirectory);\n-    attr->currentDirectory = (char*)PR_MALLOC(strlen(dir) + 1);\n-    if (!attr->currentDirectory) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    strcpy(attr->currentDirectory, dir);\n-    return PR_SUCCESS;\n+PR_ProcessAttrSetCurrentDirectory(PRProcessAttr* attr, const char* dir) {\n+  PR_FREEIF(attr->currentDirectory);\n+  attr->currentDirectory = (char*)PR_MALLOC(strlen(dir) + 1);\n+  if (!attr->currentDirectory) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  strcpy(attr->currentDirectory, dir);\n+  return PR_SUCCESS;\n }\n \n PR_IMPLEMENT(PRStatus)\n PR_ProcessAttrSetInheritableFD(PRProcessAttr* attr, PRFileDesc* fd,\n-                               const char* name)\n-{\n-    /* We malloc the fd inherit buffer in multiples of this number. */\n+                               const char* name) {\n+  /* We malloc the fd inherit buffer in multiples of this number. */\n #define FD_INHERIT_BUFFER_INCR 128\n-    /* The length of \"NSPR_INHERIT_FDS=\" */\n+  /* The length of \"NSPR_INHERIT_FDS=\" */\n #define NSPR_INHERIT_FDS_STRLEN 17\n-    /* The length of osfd (PROsfd) printed in hexadecimal with 0x prefix */\n+  /* The length of osfd (PROsfd) printed in hexadecimal with 0x prefix */\n #ifdef _WIN64\n-#define OSFD_STRLEN 18\n+#  define OSFD_STRLEN 18\n #else\n-#define OSFD_STRLEN 10\n+#  define OSFD_STRLEN 10\n #endif\n-    /* The length of fd type (PRDescType) printed in decimal */\n+  /* The length of fd type (PRDescType) printed in decimal */\n #define FD_TYPE_STRLEN 1\n-    PRSize newSize;\n-    int remainder;\n-    char* newBuffer;\n-    int nwritten;\n-    char* cur;\n-    int freeSize;\n-\n-    if (fd->identity != PR_NSPR_IO_LAYER) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    if (fd->secret->inheritable == _PR_TRI_UNKNOWN) {\n-        _PR_MD_QUERY_FD_INHERITABLE(fd);\n-    }\n-    if (fd->secret->inheritable != _PR_TRI_TRUE) {\n-        PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, 0);\n-        return PR_FAILURE;\n+  PRSize newSize;\n+  int remainder;\n+  char* newBuffer;\n+  int nwritten;\n+  char* cur;\n+  int freeSize;\n+\n+  if (fd->identity != PR_NSPR_IO_LAYER) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  if (fd->secret->inheritable == _PR_TRI_UNKNOWN) {\n+    _PR_MD_QUERY_FD_INHERITABLE(fd);\n+  }\n+  if (fd->secret->inheritable != _PR_TRI_TRUE) {\n+    PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+\n+  /*\n+   * We also need to account for the : separators and the\n+   * terminating null byte.\n+   */\n+  if (NULL == attr->fdInheritBuffer) {\n+    /* The first time, we print \"NSPR_INHERIT_FDS=<name>:<type>:<val>\" */\n+    newSize = NSPR_INHERIT_FDS_STRLEN + strlen(name) + FD_TYPE_STRLEN +\n+              OSFD_STRLEN + 2 + 1;\n+  } else {\n+    /* At other times, we print \":<name>:<type>:<val>\" */\n+    newSize = attr->fdInheritBufferUsed + strlen(name) + FD_TYPE_STRLEN +\n+              OSFD_STRLEN + 3 + 1;\n+  }\n+  if (newSize > attr->fdInheritBufferSize) {\n+    /* Make newSize a multiple of FD_INHERIT_BUFFER_INCR */\n+    remainder = newSize % FD_INHERIT_BUFFER_INCR;\n+    if (remainder != 0) {\n+      newSize += (FD_INHERIT_BUFFER_INCR - remainder);\n     }\n-\n-    /*\n-     * We also need to account for the : separators and the\n-     * terminating null byte.\n-     */\n     if (NULL == attr->fdInheritBuffer) {\n-        /* The first time, we print \"NSPR_INHERIT_FDS=<name>:<type>:<val>\" */\n-        newSize = NSPR_INHERIT_FDS_STRLEN + strlen(name) + FD_TYPE_STRLEN +\n-                  OSFD_STRLEN + 2 + 1;\n+      newBuffer = (char*)PR_MALLOC(newSize);\n     } else {\n-        /* At other times, we print \":<name>:<type>:<val>\" */\n-        newSize = attr->fdInheritBufferUsed + strlen(name) + FD_TYPE_STRLEN +\n-                  OSFD_STRLEN + 3 + 1;\n-    }\n-    if (newSize > attr->fdInheritBufferSize) {\n-        /* Make newSize a multiple of FD_INHERIT_BUFFER_INCR */\n-        remainder = newSize % FD_INHERIT_BUFFER_INCR;\n-        if (remainder != 0) {\n-            newSize += (FD_INHERIT_BUFFER_INCR - remainder);\n-        }\n-        if (NULL == attr->fdInheritBuffer) {\n-            newBuffer = (char*)PR_MALLOC(newSize);\n-        } else {\n-            newBuffer = (char*)PR_REALLOC(attr->fdInheritBuffer, newSize);\n-        }\n-        if (NULL == newBuffer) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            return PR_FAILURE;\n-        }\n-        attr->fdInheritBuffer = newBuffer;\n-        attr->fdInheritBufferSize = newSize;\n+      newBuffer = (char*)PR_REALLOC(attr->fdInheritBuffer, newSize);\n     }\n-    cur = attr->fdInheritBuffer + attr->fdInheritBufferUsed;\n-    freeSize = attr->fdInheritBufferSize - attr->fdInheritBufferUsed;\n-    if (0 == attr->fdInheritBufferUsed) {\n-        nwritten =\n-            PR_snprintf(cur, freeSize, \"NSPR_INHERIT_FDS=%s:%d:0x%\" PR_PRIxOSFD,\n-                        name, (PRIntn)fd->methods->file_type, fd->secret->md.osfd);\n-    } else {\n-        nwritten = PR_snprintf(cur, freeSize, \":%s:%d:0x%\" PR_PRIxOSFD, name,\n-                               (PRIntn)fd->methods->file_type, fd->secret->md.osfd);\n+    if (NULL == newBuffer) {\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      return PR_FAILURE;\n     }\n-    attr->fdInheritBufferUsed += nwritten;\n-    return PR_SUCCESS;\n+    attr->fdInheritBuffer = newBuffer;\n+    attr->fdInheritBufferSize = newSize;\n+  }\n+  cur = attr->fdInheritBuffer + attr->fdInheritBufferUsed;\n+  freeSize = attr->fdInheritBufferSize - attr->fdInheritBufferUsed;\n+  if (0 == attr->fdInheritBufferUsed) {\n+    nwritten =\n+        PR_snprintf(cur, freeSize, \"NSPR_INHERIT_FDS=%s:%d:0x%\" PR_PRIxOSFD,\n+                    name, (PRIntn)fd->methods->file_type, fd->secret->md.osfd);\n+  } else {\n+    nwritten = PR_snprintf(cur, freeSize, \":%s:%d:0x%\" PR_PRIxOSFD, name,\n+                           (PRIntn)fd->methods->file_type, fd->secret->md.osfd);\n+  }\n+  attr->fdInheritBufferUsed += nwritten;\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_GetInheritedFD(const char* name)\n-{\n-    PRFileDesc* fd;\n-    const char* envVar;\n-    const char* ptr;\n-    int len = strlen(name);\n-    PROsfd osfd;\n-    int nColons;\n-    PRIntn fileType;\n-\n-    envVar = PR_GetEnv(\"NSPR_INHERIT_FDS\");\n-    if (NULL == envVar || '\\0' == envVar[0]) {\n+PR_IMPLEMENT(PRFileDesc*) PR_GetInheritedFD(const char* name) {\n+  PRFileDesc* fd;\n+  const char* envVar;\n+  const char* ptr;\n+  int len = strlen(name);\n+  PROsfd osfd;\n+  int nColons;\n+  PRIntn fileType;\n+\n+  envVar = PR_GetEnv(\"NSPR_INHERIT_FDS\");\n+  if (NULL == envVar || '\\0' == envVar[0]) {\n+    PR_SetError(PR_UNKNOWN_ERROR, 0);\n+    return NULL;\n+  }\n+\n+  ptr = envVar;\n+  while (1) {\n+    if ((ptr[len] == ':') && (strncmp(ptr, name, len) == 0)) {\n+      ptr += len + 1;\n+      if (PR_sscanf(ptr, \"%d:0x%\" PR_SCNxOSFD, &fileType, &osfd) != 2) {\n         PR_SetError(PR_UNKNOWN_ERROR, 0);\n         return NULL;\n+      }\n+      switch ((PRDescType)fileType) {\n+        case PR_DESC_FILE:\n+          fd = PR_ImportFile(osfd);\n+          break;\n+        case PR_DESC_PIPE:\n+          fd = PR_ImportPipe(osfd);\n+          break;\n+        case PR_DESC_SOCKET_TCP:\n+          fd = PR_ImportTCPSocket(osfd);\n+          break;\n+        case PR_DESC_SOCKET_UDP:\n+          fd = PR_ImportUDPSocket(osfd);\n+          break;\n+        default:\n+          PR_ASSERT(0);\n+          PR_SetError(PR_UNKNOWN_ERROR, 0);\n+          fd = NULL;\n+          break;\n+      }\n+      if (fd) {\n+        /*\n+         * An inherited FD is inheritable by default.\n+         * The child process needs to call PR_SetFDInheritable\n+         * to make it non-inheritable if so desired.\n+         */\n+        fd->secret->inheritable = _PR_TRI_TRUE;\n+      }\n+      return fd;\n     }\n-\n-    ptr = envVar;\n-    while (1) {\n-        if ((ptr[len] == ':') && (strncmp(ptr, name, len) == 0)) {\n-            ptr += len + 1;\n-            if (PR_sscanf(ptr, \"%d:0x%\" PR_SCNxOSFD, &fileType, &osfd) != 2) {\n-                PR_SetError(PR_UNKNOWN_ERROR, 0);\n-                return NULL;\n-            }\n-            switch ((PRDescType)fileType) {\n-                case PR_DESC_FILE:\n-                    fd = PR_ImportFile(osfd);\n-                    break;\n-                case PR_DESC_PIPE:\n-                    fd = PR_ImportPipe(osfd);\n-                    break;\n-                case PR_DESC_SOCKET_TCP:\n-                    fd = PR_ImportTCPSocket(osfd);\n-                    break;\n-                case PR_DESC_SOCKET_UDP:\n-                    fd = PR_ImportUDPSocket(osfd);\n-                    break;\n-                default:\n-                    PR_ASSERT(0);\n-                    PR_SetError(PR_UNKNOWN_ERROR, 0);\n-                    fd = NULL;\n-                    break;\n-            }\n-            if (fd) {\n-                /*\n-                 * An inherited FD is inheritable by default.\n-                 * The child process needs to call PR_SetFDInheritable\n-                 * to make it non-inheritable if so desired.\n-                 */\n-                fd->secret->inheritable = _PR_TRI_TRUE;\n-            }\n-            return fd;\n-        }\n-        /* Skip three colons */\n-        nColons = 0;\n-        while (*ptr) {\n-            if (*ptr == ':') {\n-                if (++nColons == 3) {\n-                    break;\n-                }\n-            }\n-            ptr++;\n+    /* Skip three colons */\n+    nColons = 0;\n+    while (*ptr) {\n+      if (*ptr == ':') {\n+        if (++nColons == 3) {\n+          break;\n         }\n-        if (*ptr == '\\0') {\n-            PR_SetError(PR_UNKNOWN_ERROR, 0);\n-            return NULL;\n-        }\n-        ptr++;\n+      }\n+      ptr++;\n     }\n+    if (*ptr == '\\0') {\n+      PR_SetError(PR_UNKNOWN_ERROR, 0);\n+      return NULL;\n+    }\n+    ptr++;\n+  }\n }\n \n PR_IMPLEMENT(PRProcess*)\n PR_CreateProcess(const char* path, char* const* argv, char* const* envp,\n-                 const PRProcessAttr* attr)\n-{\n-    return _PR_MD_CREATE_PROCESS(path, argv, envp, attr);\n+                 const PRProcessAttr* attr) {\n+  return _PR_MD_CREATE_PROCESS(path, argv, envp, attr);\n } /* PR_CreateProcess */\n \n PR_IMPLEMENT(PRStatus)\n PR_CreateProcessDetached(const char* path, char* const* argv, char* const* envp,\n-                         const PRProcessAttr* attr)\n-{\n-    PRProcess* process;\n-    PRStatus rv;\n-\n-    process = PR_CreateProcess(path, argv, envp, attr);\n-    if (NULL == process) {\n-        return PR_FAILURE;\n-    }\n-    rv = PR_DetachProcess(process);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    if (rv == PR_FAILURE) {\n-        PR_DELETE(process);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+                         const PRProcessAttr* attr) {\n+  PRProcess* process;\n+  PRStatus rv;\n+\n+  process = PR_CreateProcess(path, argv, envp, attr);\n+  if (NULL == process) {\n+    return PR_FAILURE;\n+  }\n+  rv = PR_DetachProcess(process);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  if (rv == PR_FAILURE) {\n+    PR_DELETE(process);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_DetachProcess(PRProcess* process)\n-{\n-    return _PR_MD_DETACH_PROCESS(process);\n+PR_IMPLEMENT(PRStatus) PR_DetachProcess(PRProcess* process) {\n+  return _PR_MD_DETACH_PROCESS(process);\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_WaitProcess(PRProcess* process, PRInt32* exitCode)\n-{\n-    return _PR_MD_WAIT_PROCESS(process, exitCode);\n+PR_IMPLEMENT(PRStatus) PR_WaitProcess(PRProcess* process, PRInt32* exitCode) {\n+  return _PR_MD_WAIT_PROCESS(process, exitCode);\n } /* PR_WaitProcess */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_KillProcess(PRProcess* process)\n-{\n-    return _PR_MD_KILL_PROCESS(process);\n+PR_IMPLEMENT(PRStatus) PR_KillProcess(PRProcess* process) {\n+  return _PR_MD_KILL_PROCESS(process);\n }\n \n /*\n@@ -726,112 +685,103 @@ PR_KillProcess(PRProcess* process)\n  */\n \n static struct {\n-    PRLock* ml;\n-    PRCondVar* cv;\n+  PRLock* ml;\n+  PRCondVar* cv;\n } mod_init;\n \n-static void\n-_PR_InitCallOnce(void)\n-{\n-    mod_init.ml = PR_NewLock();\n-    PR_ASSERT(NULL != mod_init.ml);\n-    mod_init.cv = PR_NewCondVar(mod_init.ml);\n-    PR_ASSERT(NULL != mod_init.cv);\n+static void _PR_InitCallOnce(void) {\n+  mod_init.ml = PR_NewLock();\n+  PR_ASSERT(NULL != mod_init.ml);\n+  mod_init.cv = PR_NewCondVar(mod_init.ml);\n+  PR_ASSERT(NULL != mod_init.cv);\n }\n \n-void\n-_PR_CleanupCallOnce()\n-{\n-    PR_DestroyLock(mod_init.ml);\n-    mod_init.ml = NULL;\n-    PR_DestroyCondVar(mod_init.cv);\n-    mod_init.cv = NULL;\n+void _PR_CleanupCallOnce() {\n+  PR_DestroyLock(mod_init.ml);\n+  mod_init.ml = NULL;\n+  PR_DestroyCondVar(mod_init.cv);\n+  mod_init.cv = NULL;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CallOnce(PRCallOnceType* once, PRCallOnceFN func)\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    PR_Lock(mod_init.ml);\n-    PRIntn initialized = once->initialized;\n-    PRStatus status = once->status;\n-    PR_Unlock(mod_init.ml);\n-    if (!initialized) {\n-        if (PR_ATOMIC_SET(&once->inProgress, 1) == 0) {\n-            status = (*func)();\n-            PR_Lock(mod_init.ml);\n-            once->status = status;\n-            once->initialized = 1;\n-            PR_NotifyAllCondVar(mod_init.cv);\n-            PR_Unlock(mod_init.ml);\n-        } else {\n-            PR_Lock(mod_init.ml);\n-            while (!once->initialized) {\n-                PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT);\n-            }\n-            status = once->status;\n-            PR_Unlock(mod_init.ml);\n-            if (PR_SUCCESS != status) {\n-                PR_SetError(PR_CALL_ONCE_ERROR, 0);\n-            }\n-        }\n-        return status;\n-    }\n-    if (PR_SUCCESS != status) {\n+PR_IMPLEMENT(PRStatus) PR_CallOnce(PRCallOnceType* once, PRCallOnceFN func) {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  PR_Lock(mod_init.ml);\n+  PRIntn initialized = once->initialized;\n+  PRStatus status = once->status;\n+  PR_Unlock(mod_init.ml);\n+  if (!initialized) {\n+    if (PR_ATOMIC_SET(&once->inProgress, 1) == 0) {\n+      status = (*func)();\n+      PR_Lock(mod_init.ml);\n+      once->status = status;\n+      once->initialized = 1;\n+      PR_NotifyAllCondVar(mod_init.cv);\n+      PR_Unlock(mod_init.ml);\n+    } else {\n+      PR_Lock(mod_init.ml);\n+      while (!once->initialized) {\n+        PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT);\n+      }\n+      status = once->status;\n+      PR_Unlock(mod_init.ml);\n+      if (PR_SUCCESS != status) {\n         PR_SetError(PR_CALL_ONCE_ERROR, 0);\n+      }\n     }\n     return status;\n+  }\n+  if (PR_SUCCESS != status) {\n+    PR_SetError(PR_CALL_ONCE_ERROR, 0);\n+  }\n+  return status;\n }\n \n PR_IMPLEMENT(PRStatus)\n-PR_CallOnceWithArg(PRCallOnceType* once, PRCallOnceWithArgFN func, void* arg)\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    PR_Lock(mod_init.ml);\n-    PRIntn initialized = once->initialized;\n-    PRStatus status = once->status;\n-    PR_Unlock(mod_init.ml);\n-    if (!initialized) {\n-        if (PR_ATOMIC_SET(&once->inProgress, 1) == 0) {\n-            status = (*func)(arg);\n-            PR_Lock(mod_init.ml);\n-            once->status = status;\n-            once->initialized = 1;\n-            PR_NotifyAllCondVar(mod_init.cv);\n-            PR_Unlock(mod_init.ml);\n-        } else {\n-            PR_Lock(mod_init.ml);\n-            while (!once->initialized) {\n-                PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT);\n-            }\n-            status = once->status;\n-            PR_Unlock(mod_init.ml);\n-            if (PR_SUCCESS != status) {\n-                PR_SetError(PR_CALL_ONCE_ERROR, 0);\n-            }\n-        }\n-        return status;\n-    }\n-    if (PR_SUCCESS != status) {\n+PR_CallOnceWithArg(PRCallOnceType* once, PRCallOnceWithArgFN func, void* arg) {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  PR_Lock(mod_init.ml);\n+  PRIntn initialized = once->initialized;\n+  PRStatus status = once->status;\n+  PR_Unlock(mod_init.ml);\n+  if (!initialized) {\n+    if (PR_ATOMIC_SET(&once->inProgress, 1) == 0) {\n+      status = (*func)(arg);\n+      PR_Lock(mod_init.ml);\n+      once->status = status;\n+      once->initialized = 1;\n+      PR_NotifyAllCondVar(mod_init.cv);\n+      PR_Unlock(mod_init.ml);\n+    } else {\n+      PR_Lock(mod_init.ml);\n+      while (!once->initialized) {\n+        PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT);\n+      }\n+      status = once->status;\n+      PR_Unlock(mod_init.ml);\n+      if (PR_SUCCESS != status) {\n         PR_SetError(PR_CALL_ONCE_ERROR, 0);\n+      }\n     }\n     return status;\n+  }\n+  if (PR_SUCCESS != status) {\n+    PR_SetError(PR_CALL_ONCE_ERROR, 0);\n+  }\n+  return status;\n }\n \n-PRBool\n-_PR_Obsolete(const char* obsolete, const char* preferred)\n-{\n+PRBool _PR_Obsolete(const char* obsolete, const char* preferred) {\n #if defined(DEBUG)\n-    PR_fprintf(PR_STDERR, \"'%s' is obsolete. Use '%s' instead.\\n\", obsolete,\n-               (NULL == preferred) ? \"something else\" : preferred);\n+  PR_fprintf(PR_STDERR, \"'%s' is obsolete. Use '%s' instead.\\n\", obsolete,\n+             (NULL == preferred) ? \"something else\" : preferred);\n #endif\n-    return PR_FALSE;\n+  return PR_FALSE;\n } /* _PR_Obsolete */\n \n /* prinit.c */\ndiff --git a/nspr/pr/src/misc/prinrval.c b/nspr/pr/src/misc/prinrval.c\nindex 83619d3..65ebcc8 100644\n--- a/nspr/pr/src/misc/prinrval.c\n+++ b/nspr/pr/src/misc/prinrval.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -18,112 +19,94 @@\n  *-----------------------------------------------------------------------\n  */\n \n-void\n-_PR_InitClock(void)\n-{\n-    _PR_MD_INTERVAL_INIT();\n+void _PR_InitClock(void) {\n+  _PR_MD_INTERVAL_INIT();\n #ifdef DEBUG\n-    {\n-        PRIntervalTime ticksPerSec = PR_TicksPerSecond();\n+  {\n+    PRIntervalTime ticksPerSec = PR_TicksPerSecond();\n \n-        PR_ASSERT(ticksPerSec >= PR_INTERVAL_MIN);\n-        PR_ASSERT(ticksPerSec <= PR_INTERVAL_MAX);\n-    }\n+    PR_ASSERT(ticksPerSec >= PR_INTERVAL_MIN);\n+    PR_ASSERT(ticksPerSec <= PR_INTERVAL_MAX);\n+  }\n #endif /* DEBUG */\n }\n \n-PR_IMPLEMENT(PRIntervalTime)\n-PR_IntervalNow(void)\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    return _PR_MD_GET_INTERVAL();\n+PR_IMPLEMENT(PRIntervalTime) PR_IntervalNow(void) {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  return _PR_MD_GET_INTERVAL();\n } /* PR_IntervalNow */\n \n-PR_EXTERN(PRUint32)\n-PR_TicksPerSecond(void)\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    return _PR_MD_INTERVAL_PER_SEC();\n+PR_EXTERN(PRUint32) PR_TicksPerSecond(void) {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  return _PR_MD_INTERVAL_PER_SEC();\n } /* PR_TicksPerSecond */\n \n-PR_IMPLEMENT(PRIntervalTime)\n-PR_SecondsToInterval(PRUint32 seconds)\n-{\n-    return seconds * PR_TicksPerSecond();\n+PR_IMPLEMENT(PRIntervalTime) PR_SecondsToInterval(PRUint32 seconds) {\n+  return seconds * PR_TicksPerSecond();\n } /* PR_SecondsToInterval */\n \n-PR_IMPLEMENT(PRIntervalTime)\n-PR_MillisecondsToInterval(PRUint32 milli)\n-{\n-    PRIntervalTime ticks;\n-    PRUint64 tock, tps, msecPerSec, rounding;\n-    LL_UI2L(tock, milli);\n-    LL_I2L(msecPerSec, PR_MSEC_PER_SEC);\n-    LL_I2L(rounding, (PR_MSEC_PER_SEC >> 1));\n-    LL_I2L(tps, PR_TicksPerSecond());\n-    LL_MUL(tock, tock, tps);\n-    LL_ADD(tock, tock, rounding);\n-    LL_DIV(tock, tock, msecPerSec);\n-    LL_L2UI(ticks, tock);\n-    return ticks;\n+PR_IMPLEMENT(PRIntervalTime) PR_MillisecondsToInterval(PRUint32 milli) {\n+  PRIntervalTime ticks;\n+  PRUint64 tock, tps, msecPerSec, rounding;\n+  LL_UI2L(tock, milli);\n+  LL_I2L(msecPerSec, PR_MSEC_PER_SEC);\n+  LL_I2L(rounding, (PR_MSEC_PER_SEC >> 1));\n+  LL_I2L(tps, PR_TicksPerSecond());\n+  LL_MUL(tock, tock, tps);\n+  LL_ADD(tock, tock, rounding);\n+  LL_DIV(tock, tock, msecPerSec);\n+  LL_L2UI(ticks, tock);\n+  return ticks;\n } /* PR_MillisecondsToInterval */\n \n-PR_IMPLEMENT(PRIntervalTime)\n-PR_MicrosecondsToInterval(PRUint32 micro)\n-{\n-    PRIntervalTime ticks;\n-    PRUint64 tock, tps, usecPerSec, rounding;\n-    LL_UI2L(tock, micro);\n-    LL_I2L(usecPerSec, PR_USEC_PER_SEC);\n-    LL_I2L(rounding, (PR_USEC_PER_SEC >> 1));\n-    LL_I2L(tps, PR_TicksPerSecond());\n-    LL_MUL(tock, tock, tps);\n-    LL_ADD(tock, tock, rounding);\n-    LL_DIV(tock, tock, usecPerSec);\n-    LL_L2UI(ticks, tock);\n-    return ticks;\n+PR_IMPLEMENT(PRIntervalTime) PR_MicrosecondsToInterval(PRUint32 micro) {\n+  PRIntervalTime ticks;\n+  PRUint64 tock, tps, usecPerSec, rounding;\n+  LL_UI2L(tock, micro);\n+  LL_I2L(usecPerSec, PR_USEC_PER_SEC);\n+  LL_I2L(rounding, (PR_USEC_PER_SEC >> 1));\n+  LL_I2L(tps, PR_TicksPerSecond());\n+  LL_MUL(tock, tock, tps);\n+  LL_ADD(tock, tock, rounding);\n+  LL_DIV(tock, tock, usecPerSec);\n+  LL_L2UI(ticks, tock);\n+  return ticks;\n } /* PR_MicrosecondsToInterval */\n \n-PR_IMPLEMENT(PRUint32)\n-PR_IntervalToSeconds(PRIntervalTime ticks)\n-{\n-    return ticks / PR_TicksPerSecond();\n+PR_IMPLEMENT(PRUint32) PR_IntervalToSeconds(PRIntervalTime ticks) {\n+  return ticks / PR_TicksPerSecond();\n } /* PR_IntervalToSeconds */\n \n-PR_IMPLEMENT(PRUint32)\n-PR_IntervalToMilliseconds(PRIntervalTime ticks)\n-{\n-    PRUint32 milli;\n-    PRUint64 tock, tps, msecPerSec, rounding;\n-    LL_UI2L(tock, ticks);\n-    LL_I2L(msecPerSec, PR_MSEC_PER_SEC);\n-    LL_I2L(tps, PR_TicksPerSecond());\n-    LL_USHR(rounding, tps, 1);\n-    LL_MUL(tock, tock, msecPerSec);\n-    LL_ADD(tock, tock, rounding);\n-    LL_DIV(tock, tock, tps);\n-    LL_L2UI(milli, tock);\n-    return milli;\n+PR_IMPLEMENT(PRUint32) PR_IntervalToMilliseconds(PRIntervalTime ticks) {\n+  PRUint32 milli;\n+  PRUint64 tock, tps, msecPerSec, rounding;\n+  LL_UI2L(tock, ticks);\n+  LL_I2L(msecPerSec, PR_MSEC_PER_SEC);\n+  LL_I2L(tps, PR_TicksPerSecond());\n+  LL_USHR(rounding, tps, 1);\n+  LL_MUL(tock, tock, msecPerSec);\n+  LL_ADD(tock, tock, rounding);\n+  LL_DIV(tock, tock, tps);\n+  LL_L2UI(milli, tock);\n+  return milli;\n } /* PR_IntervalToMilliseconds */\n \n-PR_IMPLEMENT(PRUint32)\n-PR_IntervalToMicroseconds(PRIntervalTime ticks)\n-{\n-    PRUint32 micro;\n-    PRUint64 tock, tps, usecPerSec, rounding;\n-    LL_UI2L(tock, ticks);\n-    LL_I2L(usecPerSec, PR_USEC_PER_SEC);\n-    LL_I2L(tps, PR_TicksPerSecond());\n-    LL_USHR(rounding, tps, 1);\n-    LL_MUL(tock, tock, usecPerSec);\n-    LL_ADD(tock, tock, rounding);\n-    LL_DIV(tock, tock, tps);\n-    LL_L2UI(micro, tock);\n-    return micro;\n+PR_IMPLEMENT(PRUint32) PR_IntervalToMicroseconds(PRIntervalTime ticks) {\n+  PRUint32 micro;\n+  PRUint64 tock, tps, usecPerSec, rounding;\n+  LL_UI2L(tock, ticks);\n+  LL_I2L(usecPerSec, PR_USEC_PER_SEC);\n+  LL_I2L(tps, PR_TicksPerSecond());\n+  LL_USHR(rounding, tps, 1);\n+  LL_MUL(tock, tock, usecPerSec);\n+  LL_ADD(tock, tock, rounding);\n+  LL_DIV(tock, tock, tps);\n+  LL_L2UI(micro, tock);\n+  return micro;\n } /* PR_IntervalToMicroseconds */\n \n /* prinrval.c */\ndiff --git a/nspr/pr/src/misc/pripc.c b/nspr/pr/src/misc/pripc.c\nindex 2e9688c..ba55627 100644\n--- a/nspr/pr/src/misc/pripc.c\n+++ b/nspr/pr/src/misc/pripc.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -25,75 +26,69 @@\n  * A Win32 IPC name cannot contain '\\'.\n  */\n \n-static void\n-_pr_ConvertSemName(char* result)\n-{\n+static void _pr_ConvertSemName(char* result) {\n #ifdef _PR_HAVE_POSIX_SEMAPHORES\n-#if defined(SOLARIS)\n-    char* p;\n+#  if defined(SOLARIS)\n+  char* p;\n \n-    /* Convert '/' to '_' except for the leading '/' */\n-    for (p = result + 1; *p; p++) {\n-        if (*p == '/') {\n-            *p = '_';\n-        }\n+  /* Convert '/' to '_' except for the leading '/' */\n+  for (p = result + 1; *p; p++) {\n+    if (*p == '/') {\n+      *p = '_';\n     }\n-    return;\n-#else\n-    return;\n-#endif\n+  }\n+  return;\n+#  else\n+  return;\n+#  endif\n #elif defined(_PR_HAVE_SYSV_SEMAPHORES)\n-    return;\n+  return;\n #elif defined(WIN32)\n-    return;\n+  return;\n #endif\n }\n \n-static void\n-_pr_ConvertShmName(char* result)\n-{\n+static void _pr_ConvertShmName(char* result) {\n #if defined(PR_HAVE_POSIX_NAMED_SHARED_MEMORY)\n-#if defined(SOLARIS)\n-    char* p;\n+#  if defined(SOLARIS)\n+  char* p;\n \n-    /* Convert '/' to '_' except for the leading '/' */\n-    for (p = result + 1; *p; p++) {\n-        if (*p == '/') {\n-            *p = '_';\n-        }\n+  /* Convert '/' to '_' except for the leading '/' */\n+  for (p = result + 1; *p; p++) {\n+    if (*p == '/') {\n+      *p = '_';\n     }\n-    return;\n-#else\n-    return;\n-#endif\n+  }\n+  return;\n+#  else\n+  return;\n+#  endif\n #elif defined(PR_HAVE_SYSV_NAMED_SHARED_MEMORY)\n-    return;\n+  return;\n #elif defined(WIN32)\n-    return;\n+  return;\n #else\n-    return;\n+  return;\n #endif\n }\n \n-PRStatus\n-_PR_MakeNativeIPCName(const char* name, char* result, PRIntn size,\n-                      _PRIPCType type)\n-{\n-    if (strlen(name) >= (PRSize)size) {\n-        PR_SetError(PR_BUFFER_OVERFLOW_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    strcpy(result, name);\n-    switch (type) {\n-        case _PRIPCSem:\n-            _pr_ConvertSemName(result);\n-            break;\n-        case _PRIPCShm:\n-            _pr_ConvertShmName(result);\n-            break;\n-        default:\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+PRStatus _PR_MakeNativeIPCName(const char* name, char* result, PRIntn size,\n+                               _PRIPCType type) {\n+  if (strlen(name) >= (PRSize)size) {\n+    PR_SetError(PR_BUFFER_OVERFLOW_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  strcpy(result, name);\n+  switch (type) {\n+    case _PRIPCSem:\n+      _pr_ConvertSemName(result);\n+      break;\n+    case _PRIPCShm:\n+      _pr_ConvertShmName(result);\n+      break;\n+    default:\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\ndiff --git a/nspr/pr/src/misc/pripcsem.c b/nspr/pr/src/misc/pripcsem.c\nindex f065976..421ede3 100644\n--- a/nspr/pr/src/misc/pripcsem.c\n+++ b/nspr/pr/src/misc/pripcsem.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -15,96 +16,77 @@\n \n #ifdef _PR_PTHREADS\n \n-#error \"This file should not be compiled for the pthreads version\"\n+#  error \"This file should not be compiled for the pthreads version\"\n \n #else\n \n-#ifndef _PR_HAVE_NAMED_SEMAPHORES\n+#  ifndef _PR_HAVE_NAMED_SEMAPHORES\n \n-PRSem*\n-_PR_MD_OPEN_SEMAPHORE(const char* osname, PRIntn flags, PRIntn mode,\n-                      PRUintn value)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return NULL;\n+PRSem* _PR_MD_OPEN_SEMAPHORE(const char* osname, PRIntn flags, PRIntn mode,\n+                             PRUintn value) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return NULL;\n }\n \n-PRStatus\n-_PR_MD_WAIT_SEMAPHORE(PRSem* sem)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+PRStatus _PR_MD_WAIT_SEMAPHORE(PRSem* sem) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n \n-PRStatus\n-_PR_MD_POST_SEMAPHORE(PRSem* sem)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+PRStatus _PR_MD_POST_SEMAPHORE(PRSem* sem) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n \n-PRStatus\n-_PR_MD_CLOSE_SEMAPHORE(PRSem* sem)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+PRStatus _PR_MD_CLOSE_SEMAPHORE(PRSem* sem) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n \n-PRStatus\n-_PR_MD_DELETE_SEMAPHORE(const char* osname)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+PRStatus _PR_MD_DELETE_SEMAPHORE(const char* osname) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n \n-#endif /* !_PR_HAVE_NAMED_SEMAPHORES */\n+#  endif /* !_PR_HAVE_NAMED_SEMAPHORES */\n \n PR_IMPLEMENT(PRSem*)\n-PR_OpenSemaphore(const char* name, PRIntn flags, PRIntn mode, PRUintn value)\n-{\n-    char osname[PR_IPC_NAME_SIZE];\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) ==\n-        PR_FAILURE) {\n-        return NULL;\n-    }\n-    return _PR_MD_OPEN_SEMAPHORE(osname, flags, mode, value);\n+PR_OpenSemaphore(const char* name, PRIntn flags, PRIntn mode, PRUintn value) {\n+  char osname[PR_IPC_NAME_SIZE];\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) ==\n+      PR_FAILURE) {\n+    return NULL;\n+  }\n+  return _PR_MD_OPEN_SEMAPHORE(osname, flags, mode, value);\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_WaitSemaphore(PRSem* sem)\n-{\n-    return _PR_MD_WAIT_SEMAPHORE(sem);\n+PR_IMPLEMENT(PRStatus) PR_WaitSemaphore(PRSem* sem) {\n+  return _PR_MD_WAIT_SEMAPHORE(sem);\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_PostSemaphore(PRSem* sem)\n-{\n-    return _PR_MD_POST_SEMAPHORE(sem);\n+PR_IMPLEMENT(PRStatus) PR_PostSemaphore(PRSem* sem) {\n+  return _PR_MD_POST_SEMAPHORE(sem);\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CloseSemaphore(PRSem* sem)\n-{\n-    return _PR_MD_CLOSE_SEMAPHORE(sem);\n+PR_IMPLEMENT(PRStatus) PR_CloseSemaphore(PRSem* sem) {\n+  return _PR_MD_CLOSE_SEMAPHORE(sem);\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_DeleteSemaphore(const char* name)\n-{\n-    char osname[PR_IPC_NAME_SIZE];\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) ==\n-        PR_FAILURE) {\n-        return PR_FAILURE;\n-    }\n-    return _PR_MD_DELETE_SEMAPHORE(osname);\n+PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char* name) {\n+  char osname[PR_IPC_NAME_SIZE];\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) ==\n+      PR_FAILURE) {\n+    return PR_FAILURE;\n+  }\n+  return _PR_MD_DELETE_SEMAPHORE(osname);\n }\n \n #endif /* _PR_PTHREADS */\ndiff --git a/nspr/pr/src/misc/prlog2.c b/nspr/pr/src/misc/prlog2.c\nindex f8a1395..7cd61eb 100644\n--- a/nspr/pr/src/misc/prlog2.c\n+++ b/nspr/pr/src/misc/prlog2.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,22 +8,18 @@\n /*\n ** Compute the log of the least power of 2 greater than or equal to n\n */\n-PR_IMPLEMENT(PRIntn)\n-PR_CeilingLog2(PRUint32 n)\n-{\n-    PRIntn log2;\n-    PR_CEILING_LOG2(log2, n);\n-    return log2;\n+PR_IMPLEMENT(PRIntn) PR_CeilingLog2(PRUint32 n) {\n+  PRIntn log2;\n+  PR_CEILING_LOG2(log2, n);\n+  return log2;\n }\n \n /*\n ** Compute the log of the greatest power of 2 less than or equal to n.\n ** This really just finds the highest set bit in the word.\n */\n-PR_IMPLEMENT(PRIntn)\n-PR_FloorLog2(PRUint32 n)\n-{\n-    PRIntn log2;\n-    PR_FLOOR_LOG2(log2, n);\n-    return log2;\n+PR_IMPLEMENT(PRIntn) PR_FloorLog2(PRUint32 n) {\n+  PRIntn log2;\n+  PR_FLOOR_LOG2(log2, n);\n+  return log2;\n }\ndiff --git a/nspr/pr/src/misc/prlong.c b/nspr/pr/src/misc/prlong.c\nindex 04874b3..38124a1 100644\n--- a/nspr/pr/src/misc/prlong.c\n+++ b/nspr/pr/src/misc/prlong.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,243 +10,234 @@ static PRInt64 ll_maxint = PR_INT64(0x7fffffffffffffff);\n static PRInt64 ll_minint = PR_INT64(0x8000000000000000);\n static PRUint64 ll_maxuint = PR_UINT64(0xffffffffffffffff);\n \n-PR_IMPLEMENT(PRInt64)\n-LL_Zero(void) { return ll_zero; }\n-PR_IMPLEMENT(PRInt64)\n-LL_MaxInt(void) { return ll_maxint; }\n-PR_IMPLEMENT(PRInt64)\n-LL_MinInt(void) { return ll_minint; }\n-PR_IMPLEMENT(PRUint64)\n-LL_MaxUint(void) { return ll_maxuint; }\n+PR_IMPLEMENT(PRInt64) LL_Zero(void) { return ll_zero; }\n+PR_IMPLEMENT(PRInt64) LL_MaxInt(void) { return ll_maxint; }\n+PR_IMPLEMENT(PRInt64) LL_MinInt(void) { return ll_minint; }\n+PR_IMPLEMENT(PRUint64) LL_MaxUint(void) { return ll_maxuint; }\n \n #ifndef HAVE_LONG_LONG\n /*\n ** Divide 64-bit a by 32-bit b, which must be normalized so its high bit is 1.\n */\n-static void\n-norm_udivmod32(PRUint32* qp, PRUint32* rp, PRUint64 a, PRUint32 b)\n-{\n-    PRUint32 d1, d0, q1, q0;\n-    PRUint32 r1, r0, m;\n-\n-    d1 = _hi16(b);\n-    d0 = _lo16(b);\n-    r1 = a.hi % d1;\n-    q1 = a.hi / d1;\n-    m = q1 * d0;\n-    r1 = (r1 << 16) | _hi16(a.lo);\n-    if (r1 < m) {\n-        q1--, r1 += b;\n-        if (r1 >= b /* i.e., we didn't get a carry when adding to r1 */\n-            && r1 < m) {\n-            q1--, r1 += b;\n-        }\n+static void norm_udivmod32(PRUint32* qp, PRUint32* rp, PRUint64 a, PRUint32 b) {\n+  PRUint32 d1, d0, q1, q0;\n+  PRUint32 r1, r0, m;\n+\n+  d1 = _hi16(b);\n+  d0 = _lo16(b);\n+  r1 = a.hi % d1;\n+  q1 = a.hi / d1;\n+  m = q1 * d0;\n+  r1 = (r1 << 16) | _hi16(a.lo);\n+  if (r1 < m) {\n+    q1--, r1 += b;\n+    if (r1 >= b /* i.e., we didn't get a carry when adding to r1 */\n+        && r1 < m) {\n+      q1--, r1 += b;\n     }\n-    r1 -= m;\n-    r0 = r1 % d1;\n-    q0 = r1 / d1;\n-    m = q0 * d0;\n-    r0 = (r0 << 16) | _lo16(a.lo);\n-    if (r0 < m) {\n-        q0--, r0 += b;\n-        if (r0 >= b && r0 < m) {\n-            q0--, r0 += b;\n-        }\n+  }\n+  r1 -= m;\n+  r0 = r1 % d1;\n+  q0 = r1 / d1;\n+  m = q0 * d0;\n+  r0 = (r0 << 16) | _lo16(a.lo);\n+  if (r0 < m) {\n+    q0--, r0 += b;\n+    if (r0 >= b && r0 < m) {\n+      q0--, r0 += b;\n     }\n-    *qp = (q1 << 16) | q0;\n-    *rp = r0 - m;\n+  }\n+  *qp = (q1 << 16) | q0;\n+  *rp = r0 - m;\n }\n \n-static PRUint32\n-CountLeadingZeros(PRUint32 a)\n-{\n-    PRUint32 t;\n-    PRUint32 r = 32;\n-\n-    if ((t = a >> 16) != 0) {\n-        r -= 16, a = t;\n-    }\n-    if ((t = a >> 8) != 0) {\n-        r -= 8, a = t;\n-    }\n-    if ((t = a >> 4) != 0) {\n-        r -= 4, a = t;\n-    }\n-    if ((t = a >> 2) != 0) {\n-        r -= 2, a = t;\n-    }\n-    if ((t = a >> 1) != 0) {\n-        r -= 1, a = t;\n-    }\n-    if (a & 1) {\n-        r--;\n-    }\n-    return r;\n+static PRUint32 CountLeadingZeros(PRUint32 a) {\n+  PRUint32 t;\n+  PRUint32 r = 32;\n+\n+  if ((t = a >> 16) != 0) {\n+    r -= 16, a = t;\n+  }\n+  if ((t = a >> 8) != 0) {\n+    r -= 8, a = t;\n+  }\n+  if ((t = a >> 4) != 0) {\n+    r -= 4, a = t;\n+  }\n+  if ((t = a >> 2) != 0) {\n+    r -= 2, a = t;\n+  }\n+  if ((t = a >> 1) != 0) {\n+    r -= 1, a = t;\n+  }\n+  if (a & 1) {\n+    r--;\n+  }\n+  return r;\n }\n \n PR_IMPLEMENT(void)\n-ll_udivmod(PRUint64* qp, PRUint64* rp, PRUint64 a, PRUint64 b)\n-{\n-    PRUint32 n0, n1, n2;\n-    PRUint32 q0, q1;\n-    PRUint32 rsh, lsh;\n-\n-    n0 = a.lo;\n-    n1 = a.hi;\n-\n-    if (b.hi == 0) {\n-        if (b.lo > n1) {\n-            /* (0 q0) = (n1 n0) / (0 D0) */\n-\n-            lsh = CountLeadingZeros(b.lo);\n-\n-            if (lsh) {\n-                /*\n-                 * Normalize, i.e. make the most significant bit of the\n-                 * denominator be set.\n-                 */\n-                b.lo = b.lo << lsh;\n-                n1 = (n1 << lsh) | (n0 >> (32 - lsh));\n-                n0 = n0 << lsh;\n-            }\n-\n-            a.lo = n0, a.hi = n1;\n-            norm_udivmod32(&q0, &n0, a, b.lo);\n-            q1 = 0;\n-\n-            /* remainder is in n0 >> lsh */\n+ll_udivmod(PRUint64* qp, PRUint64* rp, PRUint64 a, PRUint64 b) {\n+  PRUint32 n0, n1, n2;\n+  PRUint32 q0, q1;\n+  PRUint32 rsh, lsh;\n+\n+  n0 = a.lo;\n+  n1 = a.hi;\n+\n+  if (b.hi == 0) {\n+    if (b.lo > n1) {\n+      /* (0 q0) = (n1 n0) / (0 D0) */\n+\n+      lsh = CountLeadingZeros(b.lo);\n+\n+      if (lsh) {\n+        /*\n+         * Normalize, i.e. make the most significant bit of the\n+         * denominator be set.\n+         */\n+        b.lo = b.lo << lsh;\n+        n1 = (n1 << lsh) | (n0 >> (32 - lsh));\n+        n0 = n0 << lsh;\n+      }\n+\n+      a.lo = n0, a.hi = n1;\n+      norm_udivmod32(&q0, &n0, a, b.lo);\n+      q1 = 0;\n+\n+      /* remainder is in n0 >> lsh */\n+    } else {\n+      /* (q1 q0) = (n1 n0) / (0 d0) */\n+\n+      if (b.lo == 0) {   /* user wants to divide by zero! */\n+        b.lo = 1 / b.lo; /* so go ahead and crash */\n+      }\n+\n+      lsh = CountLeadingZeros(b.lo);\n+\n+      if (lsh == 0) {\n+        /*\n+         * From (n1 >= b.lo)\n+         *   && (the most significant bit of b.lo is set),\n+         * conclude that\n+         *  (the most significant bit of n1 is set)\n+         *   && (the leading quotient digit q1 = 1).\n+         *\n+         * This special case is necessary, not an optimization\n+         * (Shifts counts of 32 are undefined).\n+         */\n+        n1 -= b.lo;\n+        q1 = 1;\n+      } else {\n+        /*\n+         * Normalize.\n+         */\n+        rsh = 32 - lsh;\n+\n+        b.lo = b.lo << lsh;\n+        n2 = n1 >> rsh;\n+        n1 = (n1 << lsh) | (n0 >> rsh);\n+        n0 = n0 << lsh;\n+\n+        a.lo = n1, a.hi = n2;\n+        norm_udivmod32(&q1, &n1, a, b.lo);\n+      }\n+\n+      /* n1 != b.lo... */\n+\n+      a.lo = n0, a.hi = n1;\n+      norm_udivmod32(&q0, &n0, a, b.lo);\n+\n+      /* remainder in n0 >> lsh */\n+    }\n+\n+    if (rp) {\n+      rp->lo = n0 >> lsh;\n+      rp->hi = 0;\n+    }\n+  } else {\n+    if (b.hi > n1) {\n+      /* (0 0) = (n1 n0) / (D1 d0) */\n+\n+      q0 = 0;\n+      q1 = 0;\n+\n+      /* remainder in (n1 n0) */\n+      if (rp) {\n+        rp->lo = n0;\n+        rp->hi = n1;\n+      }\n+    } else {\n+      /* (0 q0) = (n1 n0) / (d1 d0) */\n+\n+      lsh = CountLeadingZeros(b.hi);\n+      if (lsh == 0) {\n+        /*\n+         * From (n1 >= b.hi)\n+         *   && (the most significant bit of b.hi is set),\n+         * conclude that\n+         *      (the most significant bit of n1 is set)\n+         *   && (the quotient digit q0 = 0 or 1).\n+         *\n+         * This special case is necessary, not an optimization.\n+         */\n+\n+        /*\n+         * The condition on the next line takes advantage of that\n+         * n1 >= b.hi (true due to control flow).\n+         */\n+        if (n1 > b.hi || n0 >= b.lo) {\n+          q0 = 1;\n+          a.lo = n0, a.hi = n1;\n+          LL_SUB(a, a, b);\n         } else {\n-            /* (q1 q0) = (n1 n0) / (0 d0) */\n-\n-            if (b.lo == 0) {     /* user wants to divide by zero! */\n-                b.lo = 1 / b.lo; /* so go ahead and crash */\n-            }\n-\n-            lsh = CountLeadingZeros(b.lo);\n-\n-            if (lsh == 0) {\n-                /*\n-                 * From (n1 >= b.lo)\n-                 *   && (the most significant bit of b.lo is set),\n-                 * conclude that\n-                 *  (the most significant bit of n1 is set)\n-                 *   && (the leading quotient digit q1 = 1).\n-                 *\n-                 * This special case is necessary, not an optimization\n-                 * (Shifts counts of 32 are undefined).\n-                 */\n-                n1 -= b.lo;\n-                q1 = 1;\n-            } else {\n-                /*\n-                 * Normalize.\n-                 */\n-                rsh = 32 - lsh;\n-\n-                b.lo = b.lo << lsh;\n-                n2 = n1 >> rsh;\n-                n1 = (n1 << lsh) | (n0 >> rsh);\n-                n0 = n0 << lsh;\n-\n-                a.lo = n1, a.hi = n2;\n-                norm_udivmod32(&q1, &n1, a, b.lo);\n-            }\n-\n-            /* n1 != b.lo... */\n-\n-            a.lo = n0, a.hi = n1;\n-            norm_udivmod32(&q0, &n0, a, b.lo);\n-\n-            /* remainder in n0 >> lsh */\n+          q0 = 0;\n         }\n+        q1 = 0;\n \n         if (rp) {\n-            rp->lo = n0 >> lsh;\n-            rp->hi = 0;\n+          rp->lo = n0;\n+          rp->hi = n1;\n+        }\n+      } else {\n+        PRInt64 m;\n+\n+        /*\n+         * Normalize.\n+         */\n+        rsh = 32 - lsh;\n+\n+        b.hi = (b.hi << lsh) | (b.lo >> rsh);\n+        b.lo = b.lo << lsh;\n+        n2 = n1 >> rsh;\n+        n1 = (n1 << lsh) | (n0 >> rsh);\n+        n0 = n0 << lsh;\n+\n+        a.lo = n1, a.hi = n2;\n+        norm_udivmod32(&q0, &n1, a, b.hi);\n+        LL_MUL32(m, q0, b.lo);\n+\n+        if ((m.hi > n1) || ((m.hi == n1) && (m.lo > n0))) {\n+          q0--;\n+          LL_SUB(m, m, b);\n         }\n-    } else {\n-        if (b.hi > n1) {\n-            /* (0 0) = (n1 n0) / (D1 d0) */\n \n-            q0 = 0;\n-            q1 = 0;\n+        q1 = 0;\n \n-            /* remainder in (n1 n0) */\n-            if (rp) {\n-                rp->lo = n0;\n-                rp->hi = n1;\n-            }\n-        } else {\n-            /* (0 q0) = (n1 n0) / (d1 d0) */\n-\n-            lsh = CountLeadingZeros(b.hi);\n-            if (lsh == 0) {\n-                /*\n-                 * From (n1 >= b.hi)\n-                 *   && (the most significant bit of b.hi is set),\n-                 * conclude that\n-                 *      (the most significant bit of n1 is set)\n-                 *   && (the quotient digit q0 = 0 or 1).\n-                 *\n-                 * This special case is necessary, not an optimization.\n-                 */\n-\n-                /*\n-                 * The condition on the next line takes advantage of that\n-                 * n1 >= b.hi (true due to control flow).\n-                 */\n-                if (n1 > b.hi || n0 >= b.lo) {\n-                    q0 = 1;\n-                    a.lo = n0, a.hi = n1;\n-                    LL_SUB(a, a, b);\n-                } else {\n-                    q0 = 0;\n-                }\n-                q1 = 0;\n-\n-                if (rp) {\n-                    rp->lo = n0;\n-                    rp->hi = n1;\n-                }\n-            } else {\n-                PRInt64 m;\n-\n-                /*\n-                 * Normalize.\n-                 */\n-                rsh = 32 - lsh;\n-\n-                b.hi = (b.hi << lsh) | (b.lo >> rsh);\n-                b.lo = b.lo << lsh;\n-                n2 = n1 >> rsh;\n-                n1 = (n1 << lsh) | (n0 >> rsh);\n-                n0 = n0 << lsh;\n-\n-                a.lo = n1, a.hi = n2;\n-                norm_udivmod32(&q0, &n1, a, b.hi);\n-                LL_MUL32(m, q0, b.lo);\n-\n-                if ((m.hi > n1) || ((m.hi == n1) && (m.lo > n0))) {\n-                    q0--;\n-                    LL_SUB(m, m, b);\n-                }\n-\n-                q1 = 0;\n-\n-                /* Remainder is ((n1 n0) - (m1 m0)) >> lsh */\n-                if (rp) {\n-                    a.lo = n0, a.hi = n1;\n-                    LL_SUB(a, a, m);\n-                    rp->lo = (a.hi << rsh) | (a.lo >> lsh);\n-                    rp->hi = a.hi >> lsh;\n-                }\n-            }\n+        /* Remainder is ((n1 n0) - (m1 m0)) >> lsh */\n+        if (rp) {\n+          a.lo = n0, a.hi = n1;\n+          LL_SUB(a, a, m);\n+          rp->lo = (a.hi << rsh) | (a.lo >> lsh);\n+          rp->hi = a.hi >> lsh;\n         }\n+      }\n     }\n+  }\n \n-    if (qp) {\n-        qp->lo = q0;\n-        qp->hi = q1;\n-    }\n+  if (qp) {\n+    qp->lo = q0;\n+    qp->hi = q1;\n+  }\n }\n #endif /* !HAVE_LONG_LONG */\ndiff --git a/nspr/pr/src/misc/prnetdb.c b/nspr/pr/src/misc/prnetdb.c\nindex 5b23343..3438e30 100644\n--- a/nspr/pr/src/misc/prnetdb.c\n+++ b/nspr/pr/src/misc/prnetdb.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,7 +8,7 @@\n #include <string.h>\n \n #if defined(LINUX)\n-#include <sys/un.h>\n+#  include <sys/un.h>\n #endif\n \n /*\n@@ -16,12 +17,12 @@\n  * errno.\n  */\n #if defined(XP_UNIX)\n-#if defined(_PR_NEED_H_ERRNO)\n+#  if defined(_PR_NEED_H_ERRNO)\n extern int h_errno;\n-#endif\n-#define _MD_GETHOST_ERRNO() h_errno\n+#  endif\n+#  define _MD_GETHOST_ERRNO() h_errno\n #else\n-#define _MD_GETHOST_ERRNO() _MD_ERRNO()\n+#  define _MD_GETHOST_ERRNO() _MD_ERRNO()\n #endif\n \n /*\n@@ -38,16 +39,16 @@ extern int h_errno;\n  */\n #if defined(_PR_NO_PREEMPT) || defined(_PR_HAVE_GETHOST_R) || \\\n     defined(_PR_HAVE_THREADSAFE_GETHOST)\n-#define _PR_NO_DNS_LOCK\n+#  define _PR_NO_DNS_LOCK\n #endif\n \n #if defined(_PR_NO_DNS_LOCK)\n-#define LOCK_DNS()\n-#define UNLOCK_DNS()\n+#  define LOCK_DNS()\n+#  define UNLOCK_DNS()\n #else\n PRLock* _pr_dnsLock = NULL;\n-#define LOCK_DNS() PR_Lock(_pr_dnsLock)\n-#define UNLOCK_DNS() PR_Unlock(_pr_dnsLock)\n+#  define LOCK_DNS() PR_Lock(_pr_dnsLock)\n+#  define UNLOCK_DNS() PR_Unlock(_pr_dnsLock)\n #endif /* defined(_PR_NO_DNS_LOCK) */\n \n /*\n@@ -57,69 +58,68 @@ PRLock* _pr_dnsLock = NULL;\n  * an int, and glibc's flavor takes five arguments.\n  */\n \n-#if defined(SOLARIS) || (defined(LINUX) && defined(_REENTRANT) && \\\n-                         defined(__GLIBC__) && __GLIBC__ < 2)\n-#define _PR_HAVE_GETPROTO_R\n-#define _PR_HAVE_GETPROTO_R_POINTER\n+#if defined(SOLARIS) \\\n+|| (defined(LINUX) && defined(_REENTRANT) && defined(__GLIBC__) && \\\n+    __GLIBC__ < 2)\n+#  define _PR_HAVE_GETPROTO_R\n+#  define _PR_HAVE_GETPROTO_R_POINTER\n #endif\n \n #if defined(AIX4_3_PLUS) || (defined(AIX) && defined(_THREAD_SAFE)) || \\\n     (defined(HPUX10_10) && defined(_REENTRANT)) ||                     \\\n     (defined(HPUX10_20) && defined(_REENTRANT)) || defined(OPENBSD)\n-#define _PR_HAVE_GETPROTO_R\n-#define _PR_HAVE_GETPROTO_R_INT\n+#  define _PR_HAVE_GETPROTO_R\n+#  define _PR_HAVE_GETPROTO_R_INT\n #endif\n \n #if __FreeBSD_version >= 602000\n-#define _PR_HAVE_GETPROTO_R\n-#define _PR_HAVE_5_ARG_GETPROTO_R\n+#  define _PR_HAVE_GETPROTO_R\n+#  define _PR_HAVE_5_ARG_GETPROTO_R\n #endif\n \n /* BeOS has glibc but not the glibc-style getprotobyxxx_r functions. */\n #if (defined(__GLIBC__) && __GLIBC__ >= 2)\n-#define _PR_HAVE_GETPROTO_R\n-#define _PR_HAVE_5_ARG_GETPROTO_R\n+#  define _PR_HAVE_GETPROTO_R\n+#  define _PR_HAVE_5_ARG_GETPROTO_R\n #endif\n \n #if !defined(_PR_HAVE_GETPROTO_R)\n-PRLock* _getproto_lock = NULL;\n+        PRLock* _getproto_lock = NULL;\n #endif\n \n #if defined(_PR_INET6_PROBE)\n extern PRBool _pr_ipv6_is_present(void);\n #endif\n \n-#define _PR_IN6_IS_ADDR_UNSPECIFIED(a)                             \\\n-    (((a)->pr_s6_addr32[0] == 0) && ((a)->pr_s6_addr32[1] == 0) && \\\n-     ((a)->pr_s6_addr32[2] == 0) && ((a)->pr_s6_addr32[3] == 0))\n+#define _PR_IN6_IS_ADDR_UNSPECIFIED(a)                           \\\n+  (((a)->pr_s6_addr32[0] == 0) && ((a)->pr_s6_addr32[1] == 0) && \\\n+   ((a)->pr_s6_addr32[2] == 0) && ((a)->pr_s6_addr32[3] == 0))\n \n-#define _PR_IN6_IS_ADDR_LOOPBACK(a)                                \\\n-    (((a)->pr_s6_addr32[0] == 0) && ((a)->pr_s6_addr32[1] == 0) && \\\n-     ((a)->pr_s6_addr32[2] == 0) && ((a)->pr_s6_addr[12] == 0) &&  \\\n-     ((a)->pr_s6_addr[13] == 0) && ((a)->pr_s6_addr[14] == 0) &&   \\\n-     ((a)->pr_s6_addr[15] == 0x1U))\n+#define _PR_IN6_IS_ADDR_LOOPBACK(a)                              \\\n+  (((a)->pr_s6_addr32[0] == 0) && ((a)->pr_s6_addr32[1] == 0) && \\\n+   ((a)->pr_s6_addr32[2] == 0) && ((a)->pr_s6_addr[12] == 0) &&  \\\n+   ((a)->pr_s6_addr[13] == 0) && ((a)->pr_s6_addr[14] == 0) &&   \\\n+   ((a)->pr_s6_addr[15] == 0x1U))\n \n const PRIPv6Addr _pr_in6addr_any = {\n-    { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\n-};\n+    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}};\n \n const PRIPv6Addr _pr_in6addr_loopback = {\n-    { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1U } }\n-};\n+    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1U}}};\n /*\n  * The values at bytes 10 and 11 are compared using pointers to\n  * 8-bit fields, and not 32-bit fields, to make the comparison work on\n  * both big-endian and little-endian systems\n  */\n \n-#define _PR_IN6_IS_ADDR_V4MAPPED(a)                                \\\n-    (((a)->pr_s6_addr32[0] == 0) && ((a)->pr_s6_addr32[1] == 0) && \\\n-     ((a)->pr_s6_addr[8] == 0) && ((a)->pr_s6_addr[9] == 0) &&     \\\n-     ((a)->pr_s6_addr[10] == 0xff) && ((a)->pr_s6_addr[11] == 0xff))\n+#define _PR_IN6_IS_ADDR_V4MAPPED(a)                              \\\n+  (((a)->pr_s6_addr32[0] == 0) && ((a)->pr_s6_addr32[1] == 0) && \\\n+   ((a)->pr_s6_addr[8] == 0) && ((a)->pr_s6_addr[9] == 0) &&     \\\n+   ((a)->pr_s6_addr[10] == 0xff) && ((a)->pr_s6_addr[11] == 0xff))\n \n-#define _PR_IN6_IS_ADDR_V4COMPAT(a)                                \\\n-    (((a)->pr_s6_addr32[0] == 0) && ((a)->pr_s6_addr32[1] == 0) && \\\n-     ((a)->pr_s6_addr32[2] == 0))\n+#define _PR_IN6_IS_ADDR_V4COMPAT(a)                              \\\n+  (((a)->pr_s6_addr32[0] == 0) && ((a)->pr_s6_addr32[1] == 0) && \\\n+   ((a)->pr_s6_addr32[2] == 0))\n \n #define _PR_IN6_V4MAPPED_TO_IPADDR(a) ((a)->pr_s6_addr32[3])\n \n@@ -141,9 +141,9 @@ static PRLock* _pr_query_ifs_lock = NULL;\n static PRBool _pr_have_inet_if = PR_FALSE;\n static PRBool _pr_have_inet6_if = PR_FALSE;\n \n-#undef DEBUG_QUERY_IFS\n+#  undef DEBUG_QUERY_IFS\n \n-#if defined(AIX) || (defined(DARWIN) && !defined(HAVE_GETIFADDRS))\n+#  if defined(AIX) || (defined(DARWIN) && !defined(HAVE_GETIFADDRS))\n \n /*\n  * Use SIOCGIFCONF ioctl on platforms that don't have routing\n@@ -156,258 +156,244 @@ static PRBool _pr_have_inet6_if = PR_FALSE;\n  * Vol. 1, 2nd. Ed.\n  */\n \n-#include <sys/ioctl.h>\n-#include <sys/socket.h>\n-#include <netinet/in.h>\n-#include <net/if.h>\n-\n-#ifdef DEBUG_QUERY_IFS\n-static void\n-_pr_PrintIfreq(struct ifreq* ifr)\n-{\n-    PRNetAddr addr;\n-    struct sockaddr* sa;\n-    const char* family;\n-    char addrstr[64];\n-\n-    sa = &ifr->ifr_addr;\n-    if (sa->sa_family == AF_INET) {\n-        struct sockaddr_in* sin = (struct sockaddr_in*)sa;\n-        family = \"inet\";\n-        memcpy(&addr.inet.ip, &sin->sin_addr, sizeof(sin->sin_addr));\n-    } else if (sa->sa_family == AF_INET6) {\n-        struct sockaddr_in6* sin6 = (struct sockaddr_in6*)sa;\n-        family = \"inet6\";\n-        memcpy(&addr.ipv6.ip, &sin6->sin6_addr, sizeof(sin6->sin6_addr));\n-    } else {\n-        return; /* skip if not AF_INET or AF_INET6 */\n-    }\n-    addr.raw.family = sa->sa_family;\n-    PR_NetAddrToString(&addr, addrstr, sizeof(addrstr));\n-    printf(\"%s: %s %s\\n\", ifr->ifr_name, family, addrstr);\n+#    include <sys/ioctl.h>\n+#    include <sys/socket.h>\n+#    include <netinet/in.h>\n+#    include <net/if.h>\n+\n+#    ifdef DEBUG_QUERY_IFS\n+static void _pr_PrintIfreq(struct ifreq* ifr) {\n+  PRNetAddr addr;\n+  struct sockaddr* sa;\n+  const char* family;\n+  char addrstr[64];\n+\n+  sa = &ifr->ifr_addr;\n+  if (sa->sa_family == AF_INET) {\n+    struct sockaddr_in* sin = (struct sockaddr_in*)sa;\n+    family = \"inet\";\n+    memcpy(&addr.inet.ip, &sin->sin_addr, sizeof(sin->sin_addr));\n+  } else if (sa->sa_family == AF_INET6) {\n+    struct sockaddr_in6* sin6 = (struct sockaddr_in6*)sa;\n+    family = \"inet6\";\n+    memcpy(&addr.ipv6.ip, &sin6->sin6_addr, sizeof(sin6->sin6_addr));\n+  } else {\n+    return; /* skip if not AF_INET or AF_INET6 */\n+  }\n+  addr.raw.family = sa->sa_family;\n+  PR_NetAddrToString(&addr, addrstr, sizeof(addrstr));\n+  printf(\"%s: %s %s\\n\", ifr->ifr_name, family, addrstr);\n }\n-#endif\n-\n-static void\n-_pr_QueryNetIfs(void)\n-{\n-    int sock;\n-    int rv;\n-    struct ifconf ifc;\n-    struct ifreq* ifr;\n-    struct ifreq* lifr;\n-    PRUint32 len, lastlen;\n-    char* buf;\n-\n-    if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {\n-        return;\n-    }\n-\n-    /* Issue SIOCGIFCONF request in a loop. */\n-    lastlen = 0;\n-    len = 100 * sizeof(struct ifreq); /* initial buffer size guess */\n-    for (;;) {\n-        buf = (char*)PR_Malloc(len);\n-        if (NULL == buf) {\n-            close(sock);\n-            return;\n-        }\n-        ifc.ifc_buf = buf;\n-        ifc.ifc_len = len;\n-        rv = ioctl(sock, SIOCGIFCONF, &ifc);\n-        if (rv < 0) {\n-            if (errno != EINVAL || lastlen != 0) {\n-                close(sock);\n-                PR_Free(buf);\n-                return;\n-            }\n-        } else {\n-            if (ifc.ifc_len == lastlen) {\n-                break; /* success, len has not changed */\n-            }\n-            lastlen = ifc.ifc_len;\n-        }\n-        len += 10 * sizeof(struct ifreq); /* increment */\n+#    endif\n+\n+static void _pr_QueryNetIfs(void) {\n+  int sock;\n+  int rv;\n+  struct ifconf ifc;\n+  struct ifreq* ifr;\n+  struct ifreq* lifr;\n+  PRUint32 len, lastlen;\n+  char* buf;\n+\n+  if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {\n+    return;\n+  }\n+\n+  /* Issue SIOCGIFCONF request in a loop. */\n+  lastlen = 0;\n+  len = 100 * sizeof(struct ifreq); /* initial buffer size guess */\n+  for (;;) {\n+    buf = (char*)PR_Malloc(len);\n+    if (NULL == buf) {\n+      close(sock);\n+      return;\n+    }\n+    ifc.ifc_buf = buf;\n+    ifc.ifc_len = len;\n+    rv = ioctl(sock, SIOCGIFCONF, &ifc);\n+    if (rv < 0) {\n+      if (errno != EINVAL || lastlen != 0) {\n+        close(sock);\n         PR_Free(buf);\n+        return;\n+      }\n+    } else {\n+      if (ifc.ifc_len == lastlen) {\n+        break; /* success, len has not changed */\n+      }\n+      lastlen = ifc.ifc_len;\n     }\n-    close(sock);\n-\n-    ifr = ifc.ifc_req;\n-    lifr = (struct ifreq*)&ifc.ifc_buf[ifc.ifc_len];\n+    len += 10 * sizeof(struct ifreq); /* increment */\n+    PR_Free(buf);\n+  }\n+  close(sock);\n \n-    while (ifr < lifr) {\n-        struct sockaddr* sa;\n-        int sa_len;\n+  ifr = ifc.ifc_req;\n+  lifr = (struct ifreq*)&ifc.ifc_buf[ifc.ifc_len];\n \n-#ifdef DEBUG_QUERY_IFS\n-        _pr_PrintIfreq(ifr);\n-#endif\n-        sa = &ifr->ifr_addr;\n-        if (sa->sa_family == AF_INET) {\n-            struct sockaddr_in* sin = (struct sockaddr_in*)sa;\n-            if (sin->sin_addr.s_addr != htonl(INADDR_LOOPBACK)) {\n-                _pr_have_inet_if = PR_TRUE;\n-            }\n-        } else if (sa->sa_family == AF_INET6) {\n-            struct sockaddr_in6* sin6 = (struct sockaddr_in6*)sa;\n-            if (!IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr) &&\n-                !IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {\n-                _pr_have_inet6_if = PR_TRUE;\n-            }\n-        }\n+  while (ifr < lifr) {\n+    struct sockaddr* sa;\n+    int sa_len;\n \n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-        sa_len = PR_MAX(sa->sa_len, sizeof(struct sockaddr));\n-#else\n-        switch (sa->sa_family) {\n-#ifdef AF_LINK\n-            case AF_LINK:\n-                sa_len = sizeof(struct sockaddr_dl);\n-                break;\n-#endif\n-            case AF_INET6:\n-                sa_len = sizeof(struct sockaddr_in6);\n-                break;\n-            default:\n-                sa_len = sizeof(struct sockaddr);\n-                break;\n-        }\n-#endif\n-        ifr = (struct ifreq*)(((char*)sa) + sa_len);\n-    }\n-    PR_Free(buf);\n+#    ifdef DEBUG_QUERY_IFS\n+    _pr_PrintIfreq(ifr);\n+#    endif\n+    sa = &ifr->ifr_addr;\n+    if (sa->sa_family == AF_INET) {\n+      struct sockaddr_in* sin = (struct sockaddr_in*)sa;\n+      if (sin->sin_addr.s_addr != htonl(INADDR_LOOPBACK)) {\n+        _pr_have_inet_if = PR_TRUE;\n+      }\n+    } else if (sa->sa_family == AF_INET6) {\n+      struct sockaddr_in6* sin6 = (struct sockaddr_in6*)sa;\n+      if (!IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr) &&\n+          !IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {\n+        _pr_have_inet6_if = PR_TRUE;\n+      }\n+    }\n+\n+#    ifdef _PR_HAVE_SOCKADDR_LEN\n+    sa_len = PR_MAX(sa->sa_len, sizeof(struct sockaddr));\n+#    else\n+    switch (sa->sa_family) {\n+#      ifdef AF_LINK\n+      case AF_LINK:\n+        sa_len = sizeof(struct sockaddr_dl);\n+        break;\n+#      endif\n+      case AF_INET6:\n+        sa_len = sizeof(struct sockaddr_in6);\n+        break;\n+      default:\n+        sa_len = sizeof(struct sockaddr);\n+        break;\n+    }\n+#    endif\n+    ifr = (struct ifreq*)(((char*)sa) + sa_len);\n+  }\n+  PR_Free(buf);\n }\n \n-#elif (defined(DARWIN) && defined(HAVE_GETIFADDRS)) || defined(FREEBSD) || \\\n-    defined(NETBSD) || defined(OPENBSD)\n+#  elif (defined(DARWIN) && defined(HAVE_GETIFADDRS)) || defined(FREEBSD) || \\\n+      defined(NETBSD) || defined(OPENBSD)\n \n /*\n  * Use the BSD getifaddrs function.\n  */\n \n-#include <sys/types.h>\n-#include <sys/socket.h>\n-#include <ifaddrs.h>\n-#include <netinet/in.h>\n+#    include <sys/types.h>\n+#    include <sys/socket.h>\n+#    include <ifaddrs.h>\n+#    include <netinet/in.h>\n+\n+#    ifdef DEBUG_QUERY_IFS\n+static void _pr_PrintIfaddrs(struct ifaddrs* ifa) {\n+  struct sockaddr* sa;\n+  const char* family;\n+  void* addrp;\n+  char addrstr[64];\n+\n+  sa = ifa->ifa_addr;\n+  if (sa->sa_family == AF_INET) {\n+    struct sockaddr_in* sin = (struct sockaddr_in*)sa;\n+    family = \"inet\";\n+    addrp = &sin->sin_addr;\n+  } else if (sa->sa_family == AF_INET6) {\n+    struct sockaddr_in6* sin6 = (struct sockaddr_in6*)sa;\n+    family = \"inet6\";\n+    addrp = &sin6->sin6_addr;\n+  } else {\n+    return; /* skip if not AF_INET or AF_INET6 */\n+  }\n+  inet_ntop(sa->sa_family, addrp, addrstr, sizeof(addrstr));\n+  printf(\"%s: %s %s\\n\", ifa->ifa_name, family, addrstr);\n+}\n+#    endif\n+\n+static void _pr_QueryNetIfs(void) {\n+  struct ifaddrs* ifp;\n+  struct ifaddrs* ifa;\n \n-#ifdef DEBUG_QUERY_IFS\n-static void\n-_pr_PrintIfaddrs(struct ifaddrs* ifa)\n-{\n+  if (getifaddrs(&ifp) == -1) {\n+    return;\n+  }\n+  for (ifa = ifp; ifa; ifa = ifa->ifa_next) {\n     struct sockaddr* sa;\n-    const char* family;\n-    void* addrp;\n-    char addrstr[64];\n \n+#    ifdef DEBUG_QUERY_IFS\n+    _pr_PrintIfaddrs(ifa);\n+#    endif\n     sa = ifa->ifa_addr;\n     if (sa->sa_family == AF_INET) {\n-        struct sockaddr_in* sin = (struct sockaddr_in*)sa;\n-        family = \"inet\";\n-        addrp = &sin->sin_addr;\n+      struct sockaddr_in* sin = (struct sockaddr_in*)sa;\n+      if (sin->sin_addr.s_addr != htonl(INADDR_LOOPBACK)) {\n+        _pr_have_inet_if = 1;\n+      }\n     } else if (sa->sa_family == AF_INET6) {\n-        struct sockaddr_in6* sin6 = (struct sockaddr_in6*)sa;\n-        family = \"inet6\";\n-        addrp = &sin6->sin6_addr;\n-    } else {\n-        return; /* skip if not AF_INET or AF_INET6 */\n-    }\n-    inet_ntop(sa->sa_family, addrp, addrstr, sizeof(addrstr));\n-    printf(\"%s: %s %s\\n\", ifa->ifa_name, family, addrstr);\n-}\n-#endif\n-\n-static void\n-_pr_QueryNetIfs(void)\n-{\n-    struct ifaddrs* ifp;\n-    struct ifaddrs* ifa;\n-\n-    if (getifaddrs(&ifp) == -1) {\n-        return;\n-    }\n-    for (ifa = ifp; ifa; ifa = ifa->ifa_next) {\n-        struct sockaddr* sa;\n-\n-#ifdef DEBUG_QUERY_IFS\n-        _pr_PrintIfaddrs(ifa);\n-#endif\n-        sa = ifa->ifa_addr;\n-        if (sa->sa_family == AF_INET) {\n-            struct sockaddr_in* sin = (struct sockaddr_in*)sa;\n-            if (sin->sin_addr.s_addr != htonl(INADDR_LOOPBACK)) {\n-                _pr_have_inet_if = 1;\n-            }\n-        } else if (sa->sa_family == AF_INET6) {\n-            struct sockaddr_in6* sin6 = (struct sockaddr_in6*)sa;\n-            if (!IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr) &&\n-                !IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {\n-                _pr_have_inet6_if = 1;\n-            }\n-        }\n-    }\n-    freeifaddrs(ifp);\n+      struct sockaddr_in6* sin6 = (struct sockaddr_in6*)sa;\n+      if (!IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr) &&\n+          !IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {\n+        _pr_have_inet6_if = 1;\n+      }\n+    }\n+  }\n+  freeifaddrs(ifp);\n }\n \n-#else /* default */\n+#  else /* default */\n \n /*\n  * Emulate the code in NSPR 4.2 or older.  PR_GetIPNodeByName behaves\n  * as if the system had both IPv4 and IPv6 source addresses configured.\n  */\n-static void\n-_pr_QueryNetIfs(void)\n-{\n-    _pr_have_inet_if = PR_TRUE;\n-    _pr_have_inet6_if = PR_TRUE;\n+static void _pr_QueryNetIfs(void) {\n+  _pr_have_inet_if = PR_TRUE;\n+  _pr_have_inet6_if = PR_TRUE;\n }\n \n-#endif\n+#  endif\n \n #endif /* _PR_INET6 && _PR_HAVE_GETHOSTBYNAME2 */\n \n-void\n-_PR_InitNet(void)\n-{\n+void _PR_InitNet(void) {\n #if defined(XP_UNIX)\n-#ifdef HAVE_NETCONFIG\n-    /*\n-     * This one-liner prevents the endless re-open's and re-read's of\n-     * /etc/netconfig on EACH and EVERY call to accept(), connect(), etc.\n-     */\n-    (void)setnetconfig();\n-#endif\n+#  ifdef HAVE_NETCONFIG\n+  /*\n+   * This one-liner prevents the endless re-open's and re-read's of\n+   * /etc/netconfig on EACH and EVERY call to accept(), connect(), etc.\n+   */\n+  (void)setnetconfig();\n+#  endif\n #endif\n #if !defined(_PR_NO_DNS_LOCK)\n-    _pr_dnsLock = PR_NewLock();\n+  _pr_dnsLock = PR_NewLock();\n #endif\n #if !defined(_PR_HAVE_GETPROTO_R)\n-    _getproto_lock = PR_NewLock();\n+  _getproto_lock = PR_NewLock();\n #endif\n #if defined(_PR_INET6) && defined(_PR_HAVE_GETHOSTBYNAME2)\n-    _pr_query_ifs_lock = PR_NewLock();\n+  _pr_query_ifs_lock = PR_NewLock();\n #endif\n }\n \n-void\n-_PR_CleanupNet(void)\n-{\n+void _PR_CleanupNet(void) {\n #if !defined(_PR_NO_DNS_LOCK)\n-    if (_pr_dnsLock) {\n-        PR_DestroyLock(_pr_dnsLock);\n-        _pr_dnsLock = NULL;\n-    }\n+  if (_pr_dnsLock) {\n+    PR_DestroyLock(_pr_dnsLock);\n+    _pr_dnsLock = NULL;\n+  }\n #endif\n #if !defined(_PR_HAVE_GETPROTO_R)\n-    if (_getproto_lock) {\n-        PR_DestroyLock(_getproto_lock);\n-        _getproto_lock = NULL;\n-    }\n+  if (_getproto_lock) {\n+    PR_DestroyLock(_getproto_lock);\n+    _getproto_lock = NULL;\n+  }\n #endif\n #if defined(_PR_INET6) && defined(_PR_HAVE_GETHOSTBYNAME2)\n-    if (_pr_query_ifs_lock) {\n-        PR_DestroyLock(_pr_query_ifs_lock);\n-        _pr_query_ifs_lock = NULL;\n-    }\n+  if (_pr_query_ifs_lock) {\n+    PR_DestroyLock(_pr_query_ifs_lock);\n+    _pr_query_ifs_lock = NULL;\n+  }\n #endif\n }\n \n@@ -415,149 +401,141 @@ _PR_CleanupNet(void)\n ** Allocate space from the buffer, aligning it to \"align\" before doing\n ** the allocation. \"align\" must be a power of 2.\n */\n-static char*\n-Alloc(PRIntn amount, char** bufp, PRIntn* buflenp, PRIntn align)\n-{\n-    char* buf = *bufp;\n-    PRIntn buflen = *buflenp;\n-\n-    if (align && ((long)buf & (align - 1))) {\n-        PRIntn skip = align - ((ptrdiff_t)buf & (align - 1));\n-        if (buflen < skip) {\n-            return 0;\n-        }\n-        buf += skip;\n-        buflen -= skip;\n-    }\n-    if (buflen < amount) {\n-        return 0;\n-    }\n-    *bufp = buf + amount;\n-    *buflenp = buflen - amount;\n-    return buf;\n+static char* Alloc(PRIntn amount, char** bufp, PRIntn* buflenp, PRIntn align) {\n+  char* buf = *bufp;\n+  PRIntn buflen = *buflenp;\n+\n+  if (align && ((long)buf & (align - 1))) {\n+    PRIntn skip = align - ((ptrdiff_t)buf & (align - 1));\n+    if (buflen < skip) {\n+      return 0;\n+    }\n+    buf += skip;\n+    buflen -= skip;\n+  }\n+  if (buflen < amount) {\n+    return 0;\n+  }\n+  *bufp = buf + amount;\n+  *buflenp = buflen - amount;\n+  return buf;\n }\n \n typedef enum _PRIPAddrConversion {\n-    _PRIPAddrNoConversion,\n-    _PRIPAddrIPv4Mapped,\n-    _PRIPAddrIPv4Compat\n+  _PRIPAddrNoConversion,\n+  _PRIPAddrIPv4Mapped,\n+  _PRIPAddrIPv4Compat\n } _PRIPAddrConversion;\n \n /*\n ** Convert an IPv4 address (v4) to an IPv4-mapped IPv6 address (v6).\n */\n-static void\n-MakeIPv4MappedAddr(const char* v4, char* v6)\n-{\n-    memset(v6, 0, 10);\n-    memset(v6 + 10, 0xff, 2);\n-    memcpy(v6 + 12, v4, 4);\n+static void MakeIPv4MappedAddr(const char* v4, char* v6) {\n+  memset(v6, 0, 10);\n+  memset(v6 + 10, 0xff, 2);\n+  memcpy(v6 + 12, v4, 4);\n }\n \n /*\n ** Convert an IPv4 address (v4) to an IPv4-compatible IPv6 address (v6).\n */\n-static void\n-MakeIPv4CompatAddr(const char* v4, char* v6)\n-{\n-    memset(v6, 0, 12);\n-    memcpy(v6 + 12, v4, 4);\n+static void MakeIPv4CompatAddr(const char* v4, char* v6) {\n+  memset(v6, 0, 12);\n+  memcpy(v6 + 12, v4, 4);\n }\n \n /*\n ** Copy a hostent, and all of the memory that it refers to into\n ** (hopefully) stacked buffers.\n */\n-static PRStatus\n-CopyHostent(struct hostent* from, char** buf, PRIntn* bufsize,\n-            _PRIPAddrConversion conversion, PRHostEnt* to)\n-{\n-    PRIntn len, na;\n-    char** ap;\n-\n-    if (conversion != _PRIPAddrNoConversion && from->h_addrtype == AF_INET) {\n-        PR_ASSERT(from->h_length == 4);\n-        to->h_addrtype = PR_AF_INET6;\n-        to->h_length = 16;\n-    } else {\n+static PRStatus CopyHostent(struct hostent* from, char** buf, PRIntn* bufsize,\n+                            _PRIPAddrConversion conversion, PRHostEnt* to) {\n+  PRIntn len, na;\n+  char** ap;\n+\n+  if (conversion != _PRIPAddrNoConversion && from->h_addrtype == AF_INET) {\n+    PR_ASSERT(from->h_length == 4);\n+    to->h_addrtype = PR_AF_INET6;\n+    to->h_length = 16;\n+  } else {\n #if defined(_PR_INET6) || defined(_PR_INET6_PROBE)\n-        if (AF_INET6 == from->h_addrtype) {\n-            to->h_addrtype = PR_AF_INET6;\n-        } else\n+    if (AF_INET6 == from->h_addrtype) {\n+      to->h_addrtype = PR_AF_INET6;\n+    } else\n #endif\n-            to->h_addrtype = from->h_addrtype;\n-        to->h_length = from->h_length;\n-    }\n+      to->h_addrtype = from->h_addrtype;\n+    to->h_length = from->h_length;\n+  }\n \n-    /* Copy the official name */\n-    if (!from->h_name) {\n-        return PR_FAILURE;\n-    }\n-    len = strlen(from->h_name) + 1;\n-    to->h_name = Alloc(len, buf, bufsize, 0);\n-    if (!to->h_name) {\n+  /* Copy the official name */\n+  if (!from->h_name) {\n+    return PR_FAILURE;\n+  }\n+  len = strlen(from->h_name) + 1;\n+  to->h_name = Alloc(len, buf, bufsize, 0);\n+  if (!to->h_name) {\n+    return PR_FAILURE;\n+  }\n+  memcpy(to->h_name, from->h_name, len);\n+\n+  /* Count the aliases, then allocate storage for the pointers */\n+  if (!from->h_aliases) {\n+    na = 1;\n+  } else {\n+    for (na = 1, ap = from->h_aliases; *ap != 0; na++, ap++) {\n+      ;\n+    } /* nothing to execute */\n+  }\n+  to->h_aliases =\n+      (char**)Alloc(na * sizeof(char*), buf, bufsize, sizeof(char**));\n+  if (!to->h_aliases) {\n+    return PR_FAILURE;\n+  }\n+\n+  /* Copy the aliases, one at a time */\n+  if (!from->h_aliases) {\n+    to->h_aliases[0] = 0;\n+  } else {\n+    for (na = 0, ap = from->h_aliases; *ap != 0; na++, ap++) {\n+      len = strlen(*ap) + 1;\n+      to->h_aliases[na] = Alloc(len, buf, bufsize, 0);\n+      if (!to->h_aliases[na]) {\n         return PR_FAILURE;\n-    }\n-    memcpy(to->h_name, from->h_name, len);\n+      }\n+      memcpy(to->h_aliases[na], *ap, len);\n+    }\n+    to->h_aliases[na] = 0;\n+  }\n+\n+  /* Count the addresses, then allocate storage for the pointers */\n+  for (na = 1, ap = from->h_addr_list; *ap != 0; na++, ap++) {\n+    ;\n+  } /* nothing to execute */\n+  to->h_addr_list =\n+      (char**)Alloc(na * sizeof(char*), buf, bufsize, sizeof(char**));\n+  if (!to->h_addr_list) {\n+    return PR_FAILURE;\n+  }\n \n-    /* Count the aliases, then allocate storage for the pointers */\n-    if (!from->h_aliases) {\n-        na = 1;\n-    } else {\n-        for (na = 1, ap = from->h_aliases; *ap != 0; na++, ap++) {\n-            ;\n-        } /* nothing to execute */\n-    }\n-    to->h_aliases =\n-        (char**)Alloc(na * sizeof(char*), buf, bufsize, sizeof(char**));\n-    if (!to->h_aliases) {\n-        return PR_FAILURE;\n+  /* Copy the addresses, one at a time */\n+  for (na = 0, ap = from->h_addr_list; *ap != 0; na++, ap++) {\n+    to->h_addr_list[na] = Alloc(to->h_length, buf, bufsize, 0);\n+    if (!to->h_addr_list[na]) {\n+      return PR_FAILURE;\n     }\n-\n-    /* Copy the aliases, one at a time */\n-    if (!from->h_aliases) {\n-        to->h_aliases[0] = 0;\n+    if (conversion != _PRIPAddrNoConversion && from->h_addrtype == AF_INET) {\n+      if (conversion == _PRIPAddrIPv4Mapped) {\n+        MakeIPv4MappedAddr(*ap, to->h_addr_list[na]);\n+      } else {\n+        PR_ASSERT(conversion == _PRIPAddrIPv4Compat);\n+        MakeIPv4CompatAddr(*ap, to->h_addr_list[na]);\n+      }\n     } else {\n-        for (na = 0, ap = from->h_aliases; *ap != 0; na++, ap++) {\n-            len = strlen(*ap) + 1;\n-            to->h_aliases[na] = Alloc(len, buf, bufsize, 0);\n-            if (!to->h_aliases[na]) {\n-                return PR_FAILURE;\n-            }\n-            memcpy(to->h_aliases[na], *ap, len);\n-        }\n-        to->h_aliases[na] = 0;\n-    }\n-\n-    /* Count the addresses, then allocate storage for the pointers */\n-    for (na = 1, ap = from->h_addr_list; *ap != 0; na++, ap++) {\n-        ;\n-    } /* nothing to execute */\n-    to->h_addr_list =\n-        (char**)Alloc(na * sizeof(char*), buf, bufsize, sizeof(char**));\n-    if (!to->h_addr_list) {\n-        return PR_FAILURE;\n-    }\n-\n-    /* Copy the addresses, one at a time */\n-    for (na = 0, ap = from->h_addr_list; *ap != 0; na++, ap++) {\n-        to->h_addr_list[na] = Alloc(to->h_length, buf, bufsize, 0);\n-        if (!to->h_addr_list[na]) {\n-            return PR_FAILURE;\n-        }\n-        if (conversion != _PRIPAddrNoConversion && from->h_addrtype == AF_INET) {\n-            if (conversion == _PRIPAddrIPv4Mapped) {\n-                MakeIPv4MappedAddr(*ap, to->h_addr_list[na]);\n-            } else {\n-                PR_ASSERT(conversion == _PRIPAddrIPv4Compat);\n-                MakeIPv4CompatAddr(*ap, to->h_addr_list[na]);\n-            }\n-        } else {\n-            memcpy(to->h_addr_list[na], *ap, to->h_length);\n-        }\n+      memcpy(to->h_addr_list[na], *ap, to->h_length);\n     }\n-    to->h_addr_list[na] = 0;\n-    return PR_SUCCESS;\n+  }\n+  to->h_addr_list[na] = 0;\n+  return PR_SUCCESS;\n }\n \n #if !defined(_PR_HAVE_GETPROTO_R)\n@@ -565,49 +543,47 @@ CopyHostent(struct hostent* from, char** buf, PRIntn* bufsize,\n ** Copy a protoent, and all of the memory that it refers to into\n ** (hopefully) stacked buffers.\n */\n-static PRStatus\n-CopyProtoent(struct protoent* from, char* buf, PRIntn bufsize,\n-             PRProtoEnt* to)\n-{\n-    PRIntn len, na;\n-    char** ap;\n-\n-    /* Do the easy stuff */\n-    to->p_num = from->p_proto;\n-\n-    /* Copy the official name */\n-    if (!from->p_name) {\n-        return PR_FAILURE;\n-    }\n-    len = strlen(from->p_name) + 1;\n-    to->p_name = Alloc(len, &buf, &bufsize, 0);\n-    if (!to->p_name) {\n-        return PR_FAILURE;\n-    }\n-    memcpy(to->p_name, from->p_name, len);\n+static PRStatus CopyProtoent(struct protoent* from, char* buf, PRIntn bufsize,\n+                             PRProtoEnt* to) {\n+  PRIntn len, na;\n+  char** ap;\n \n-    /* Count the aliases, then allocate storage for the pointers */\n-    for (na = 1, ap = from->p_aliases; *ap != 0; na++, ap++) {\n-        ;\n-    } /* nothing to execute */\n-    to->p_aliases =\n-        (char**)Alloc(na * sizeof(char*), &buf, &bufsize, sizeof(char**));\n-    if (!to->p_aliases) {\n-        return PR_FAILURE;\n-    }\n+  /* Do the easy stuff */\n+  to->p_num = from->p_proto;\n \n-    /* Copy the aliases, one at a time */\n-    for (na = 0, ap = from->p_aliases; *ap != 0; na++, ap++) {\n-        len = strlen(*ap) + 1;\n-        to->p_aliases[na] = Alloc(len, &buf, &bufsize, 0);\n-        if (!to->p_aliases[na]) {\n-            return PR_FAILURE;\n-        }\n-        memcpy(to->p_aliases[na], *ap, len);\n+  /* Copy the official name */\n+  if (!from->p_name) {\n+    return PR_FAILURE;\n+  }\n+  len = strlen(from->p_name) + 1;\n+  to->p_name = Alloc(len, &buf, &bufsize, 0);\n+  if (!to->p_name) {\n+    return PR_FAILURE;\n+  }\n+  memcpy(to->p_name, from->p_name, len);\n+\n+  /* Count the aliases, then allocate storage for the pointers */\n+  for (na = 1, ap = from->p_aliases; *ap != 0; na++, ap++) {\n+    ;\n+  } /* nothing to execute */\n+  to->p_aliases =\n+      (char**)Alloc(na * sizeof(char*), &buf, &bufsize, sizeof(char**));\n+  if (!to->p_aliases) {\n+    return PR_FAILURE;\n+  }\n+\n+  /* Copy the aliases, one at a time */\n+  for (na = 0, ap = from->p_aliases; *ap != 0; na++, ap++) {\n+    len = strlen(*ap) + 1;\n+    to->p_aliases[na] = Alloc(len, &buf, &bufsize, 0);\n+    if (!to->p_aliases[na]) {\n+      return PR_FAILURE;\n     }\n-    to->p_aliases[na] = 0;\n+    memcpy(to->p_aliases[na], *ap, len);\n+  }\n+  to->p_aliases[na] = 0;\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n }\n #endif /* !defined(_PR_HAVE_GETPROTO_R) */\n \n@@ -621,77 +597,76 @@ CopyProtoent(struct protoent* from, char* buf, PRIntn bufsize,\n  */\n #if defined(_PR_HAVE_GETHOST_R_INT)\n \n-#define GETHOSTBYNAME(name) \\\n+#  define GETHOSTBYNAME(name) \\\n     (gethostbyname_r(name, &tmphe, tmpbuf, bufsize, &h, &h_err), h)\n-#define GETHOSTBYNAME2(name, af) \\\n+#  define GETHOSTBYNAME2(name, af) \\\n     (gethostbyname2_r(name, af, &tmphe, tmpbuf, bufsize, &h, &h_err), h)\n-#define GETHOSTBYADDR(addr, addrlen, af) \\\n+#  define GETHOSTBYADDR(addr, addrlen, af) \\\n     (gethostbyaddr_r(addr, addrlen, af, &tmphe, tmpbuf, bufsize, &h, &h_err), h)\n \n #elif defined(_PR_HAVE_GETHOST_R_POINTER)\n \n-#define GETHOSTBYNAME(name) \\\n+#  define GETHOSTBYNAME(name) \\\n     gethostbyname_r(name, &tmphe, tmpbuf, bufsize, &h_err)\n-#define GETHOSTBYNAME2(name, af) \\\n+#  define GETHOSTBYNAME2(name, af) \\\n     gethostbyname2_r(name, af, &tmphe, tmpbuf, bufsize, &h_err)\n-#define GETHOSTBYADDR(addr, addrlen, af) \\\n+#  define GETHOSTBYADDR(addr, addrlen, af) \\\n     gethostbyaddr_r(addr, addrlen, af, &tmphe, tmpbuf, bufsize, &h_err)\n \n #else\n \n-#define GETHOSTBYNAME(name) gethostbyname(name)\n-#define GETHOSTBYNAME2(name, af) gethostbyname2(name, af)\n-#define GETHOSTBYADDR(addr, addrlen, af) gethostbyaddr(addr, addrlen, af)\n+#  define GETHOSTBYNAME(name) gethostbyname(name)\n+#  define GETHOSTBYNAME2(name, af) gethostbyname2(name, af)\n+#  define GETHOSTBYADDR(addr, addrlen, af) gethostbyaddr(addr, addrlen, af)\n \n #endif /* definition of GETHOSTBYXXX */\n \n PR_IMPLEMENT(PRStatus)\n-PR_GetHostByName(const char* name, char* buf, PRIntn bufsize, PRHostEnt* hp)\n-{\n-    struct hostent* h;\n-    PRStatus rv = PR_FAILURE;\n+PR_GetHostByName(const char* name, char* buf, PRIntn bufsize, PRHostEnt* hp) {\n+  struct hostent* h;\n+  PRStatus rv = PR_FAILURE;\n #if defined(_PR_HAVE_GETHOST_R)\n-    char localbuf[PR_NETDB_BUF_SIZE];\n-    char* tmpbuf;\n-    struct hostent tmphe;\n-    int h_err;\n+  char localbuf[PR_NETDB_BUF_SIZE];\n+  char* tmpbuf;\n+  struct hostent tmphe;\n+  int h_err;\n #endif\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n #if defined(_PR_HAVE_GETHOST_R)\n-    tmpbuf = localbuf;\n-    if (bufsize > sizeof(localbuf)) {\n-        tmpbuf = (char*)PR_Malloc(bufsize);\n-        if (NULL == tmpbuf) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            return rv;\n-        }\n+  tmpbuf = localbuf;\n+  if (bufsize > sizeof(localbuf)) {\n+    tmpbuf = (char*)PR_Malloc(bufsize);\n+    if (NULL == tmpbuf) {\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      return rv;\n     }\n+  }\n #endif\n \n-    LOCK_DNS();\n+  LOCK_DNS();\n \n-    h = GETHOSTBYNAME(name);\n+  h = GETHOSTBYNAME(name);\n \n-    if (NULL == h) {\n-        PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_GETHOST_ERRNO());\n-    } else {\n-        _PRIPAddrConversion conversion = _PRIPAddrNoConversion;\n-        rv = CopyHostent(h, &buf, &bufsize, conversion, hp);\n-        if (PR_SUCCESS != rv) {\n-            PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n-        }\n+  if (NULL == h) {\n+    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_GETHOST_ERRNO());\n+  } else {\n+    _PRIPAddrConversion conversion = _PRIPAddrNoConversion;\n+    rv = CopyHostent(h, &buf, &bufsize, conversion, hp);\n+    if (PR_SUCCESS != rv) {\n+      PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n     }\n-    UNLOCK_DNS();\n+  }\n+  UNLOCK_DNS();\n #if defined(_PR_HAVE_GETHOST_R)\n-    if (tmpbuf != localbuf) {\n-        PR_Free(tmpbuf);\n-    }\n+  if (tmpbuf != localbuf) {\n+    PR_Free(tmpbuf);\n+  }\n #endif\n-    return rv;\n+  return rv;\n }\n \n #if !defined(_PR_INET6) && defined(_PR_INET6_PROBE) && \\\n@@ -708,33 +683,31 @@ static void* _pr_freehostent_fp;\n  * Look up the addresses of getipnodebyname, getipnodebyaddr,\n  * and freehostent.\n  */\n-PRStatus\n-_pr_find_getipnodebyname(void)\n-{\n-    PRLibrary* lib;\n-    PRStatus rv;\n-#define GETIPNODEBYNAME \"getipnodebyname\"\n-#define GETIPNODEBYADDR \"getipnodebyaddr\"\n-#define FREEHOSTENT \"freehostent\"\n-\n-    _pr_getipnodebyname_fp = PR_FindSymbolAndLibrary(GETIPNODEBYNAME, &lib);\n-    if (NULL != _pr_getipnodebyname_fp) {\n-        _pr_freehostent_fp = PR_FindSymbol(lib, FREEHOSTENT);\n-        if (NULL != _pr_freehostent_fp) {\n-            _pr_getipnodebyaddr_fp = PR_FindSymbol(lib, GETIPNODEBYADDR);\n-            if (NULL != _pr_getipnodebyaddr_fp) {\n-                rv = PR_SUCCESS;\n-            } else {\n-                rv = PR_FAILURE;\n-            }\n-        } else {\n-            rv = PR_FAILURE;\n-        }\n-        (void)PR_UnloadLibrary(lib);\n-    } else {\n+PRStatus _pr_find_getipnodebyname(void) {\n+  PRLibrary* lib;\n+  PRStatus rv;\n+#  define GETIPNODEBYNAME \"getipnodebyname\"\n+#  define GETIPNODEBYADDR \"getipnodebyaddr\"\n+#  define FREEHOSTENT \"freehostent\"\n+\n+  _pr_getipnodebyname_fp = PR_FindSymbolAndLibrary(GETIPNODEBYNAME, &lib);\n+  if (NULL != _pr_getipnodebyname_fp) {\n+    _pr_freehostent_fp = PR_FindSymbol(lib, FREEHOSTENT);\n+    if (NULL != _pr_freehostent_fp) {\n+      _pr_getipnodebyaddr_fp = PR_FindSymbol(lib, GETIPNODEBYADDR);\n+      if (NULL != _pr_getipnodebyaddr_fp) {\n+        rv = PR_SUCCESS;\n+      } else {\n         rv = PR_FAILURE;\n+      }\n+    } else {\n+      rv = PR_FAILURE;\n     }\n-    return rv;\n+    (void)PR_UnloadLibrary(lib);\n+  } else {\n+    rv = PR_FAILURE;\n+  }\n+  return rv;\n }\n #endif\n \n@@ -742,387 +715,383 @@ _pr_find_getipnodebyname(void)\n /*\n ** Append the V4 addresses to the end of the list\n */\n-static PRStatus\n-AppendV4AddrsToHostent(struct hostent* from, char** buf,\n-                       PRIntn* bufsize, PRHostEnt* to)\n-{\n-    PRIntn na, na_old;\n-    char** ap;\n-    char** new_addr_list;\n-\n-    /* Count the addresses, then grow storage for the pointers */\n-    for (na_old = 0, ap = to->h_addr_list; *ap != 0; na_old++, ap++) {\n-        ;\n-    } /* nothing to execute */\n-    for (na = na_old + 1, ap = from->h_addr_list; *ap != 0; na++, ap++) {\n-        ;\n-    } /* nothing to execute */\n-    new_addr_list =\n-        (char**)Alloc(na * sizeof(char*), buf, bufsize, sizeof(char**));\n-    if (!new_addr_list) {\n-        return PR_FAILURE;\n-    }\n-\n-    /* Copy the V6 addresses, one at a time */\n-    for (na = 0, ap = to->h_addr_list; *ap != 0; na++, ap++) {\n-        new_addr_list[na] = to->h_addr_list[na];\n-    }\n-    to->h_addr_list = new_addr_list;\n-\n-    /* Copy the V4 addresses, one at a time */\n-    for (ap = from->h_addr_list; *ap != 0; na++, ap++) {\n-        to->h_addr_list[na] = Alloc(to->h_length, buf, bufsize, 0);\n-        if (!to->h_addr_list[na]) {\n-            return PR_FAILURE;\n-        }\n-        MakeIPv4MappedAddr(*ap, to->h_addr_list[na]);\n-    }\n-    to->h_addr_list[na] = 0;\n-    return PR_SUCCESS;\n+static PRStatus AppendV4AddrsToHostent(struct hostent* from, char** buf,\n+                                       PRIntn* bufsize, PRHostEnt* to) {\n+  PRIntn na, na_old;\n+  char** ap;\n+  char** new_addr_list;\n+\n+  /* Count the addresses, then grow storage for the pointers */\n+  for (na_old = 0, ap = to->h_addr_list; *ap != 0; na_old++, ap++) {\n+    ;\n+  } /* nothing to execute */\n+  for (na = na_old + 1, ap = from->h_addr_list; *ap != 0; na++, ap++) {\n+    ;\n+  } /* nothing to execute */\n+  new_addr_list =\n+      (char**)Alloc(na * sizeof(char*), buf, bufsize, sizeof(char**));\n+  if (!new_addr_list) {\n+    return PR_FAILURE;\n+  }\n+\n+  /* Copy the V6 addresses, one at a time */\n+  for (na = 0, ap = to->h_addr_list; *ap != 0; na++, ap++) {\n+    new_addr_list[na] = to->h_addr_list[na];\n+  }\n+  to->h_addr_list = new_addr_list;\n+\n+  /* Copy the V4 addresses, one at a time */\n+  for (ap = from->h_addr_list; *ap != 0; na++, ap++) {\n+    to->h_addr_list[na] = Alloc(to->h_length, buf, bufsize, 0);\n+    if (!to->h_addr_list[na]) {\n+      return PR_FAILURE;\n+    }\n+    MakeIPv4MappedAddr(*ap, to->h_addr_list[na]);\n+  }\n+  to->h_addr_list[na] = 0;\n+  return PR_SUCCESS;\n }\n #endif\n \n PR_IMPLEMENT(PRStatus)\n PR_GetIPNodeByName(const char* name, PRUint16 af, PRIntn flags, char* buf,\n-                   PRIntn bufsize, PRHostEnt* hp)\n-{\n-    struct hostent* h = 0;\n-    PRStatus rv = PR_FAILURE;\n+                   PRIntn bufsize, PRHostEnt* hp) {\n+  struct hostent* h = 0;\n+  PRStatus rv = PR_FAILURE;\n #if defined(_PR_HAVE_GETHOST_R)\n-    char localbuf[PR_NETDB_BUF_SIZE];\n-    char* tmpbuf;\n-    struct hostent tmphe;\n-    int h_err;\n+  char localbuf[PR_NETDB_BUF_SIZE];\n+  char* tmpbuf;\n+  struct hostent tmphe;\n+  int h_err;\n #endif\n #if defined(_PR_HAVE_GETIPNODEBYNAME)\n-    PRUint16 md_af = af;\n-    int error_num;\n-    int tmp_flags = 0;\n+  PRUint16 md_af = af;\n+  int error_num;\n+  int tmp_flags = 0;\n #endif\n #if defined(_PR_HAVE_GETHOSTBYNAME2)\n-    PRBool did_af_inet = PR_FALSE;\n+  PRBool did_af_inet = PR_FALSE;\n #endif\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    if (af != PR_AF_INET && af != PR_AF_INET6) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (af != PR_AF_INET && af != PR_AF_INET6) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n #if defined(_PR_INET6) && defined(_PR_HAVE_GETHOSTBYNAME2)\n-    PR_Lock(_pr_query_ifs_lock);\n-    /*\n-     * Keep querying the presence of IPv4 and IPv6 interfaces until\n-     * at least one is up.  This allows us to detect the local\n-     * machine going from offline to online.\n-     */\n-    if (!_pr_have_inet_if && !_pr_have_inet6_if) {\n-        _pr_QueryNetIfs();\n-#ifdef DEBUG_QUERY_IFS\n-        if (_pr_have_inet_if) {\n-            printf(\"Have IPv4 source address\\n\");\n-        }\n-        if (_pr_have_inet6_if) {\n-            printf(\"Have IPv6 source address\\n\");\n-        }\n-#endif\n-    }\n-    PR_Unlock(_pr_query_ifs_lock);\n+  PR_Lock(_pr_query_ifs_lock);\n+  /*\n+   * Keep querying the presence of IPv4 and IPv6 interfaces until\n+   * at least one is up.  This allows us to detect the local\n+   * machine going from offline to online.\n+   */\n+  if (!_pr_have_inet_if && !_pr_have_inet6_if) {\n+    _pr_QueryNetIfs();\n+#  ifdef DEBUG_QUERY_IFS\n+    if (_pr_have_inet_if) {\n+      printf(\"Have IPv4 source address\\n\");\n+    }\n+    if (_pr_have_inet6_if) {\n+      printf(\"Have IPv6 source address\\n\");\n+    }\n+#  endif\n+  }\n+  PR_Unlock(_pr_query_ifs_lock);\n #endif\n \n #if defined(_PR_HAVE_GETIPNODEBYNAME)\n-    if (flags & PR_AI_V4MAPPED) {\n-        tmp_flags |= AI_V4MAPPED;\n-    }\n-    if (flags & PR_AI_ADDRCONFIG) {\n-        tmp_flags |= AI_ADDRCONFIG;\n-    }\n-    if (flags & PR_AI_ALL) {\n-        tmp_flags |= AI_ALL;\n-    }\n-    if (af == PR_AF_INET6) {\n-        md_af = AF_INET6;\n-    } else {\n-        md_af = af;\n-    }\n+  if (flags & PR_AI_V4MAPPED) {\n+    tmp_flags |= AI_V4MAPPED;\n+  }\n+  if (flags & PR_AI_ADDRCONFIG) {\n+    tmp_flags |= AI_ADDRCONFIG;\n+  }\n+  if (flags & PR_AI_ALL) {\n+    tmp_flags |= AI_ALL;\n+  }\n+  if (af == PR_AF_INET6) {\n+    md_af = AF_INET6;\n+  } else {\n+    md_af = af;\n+  }\n #endif\n \n #if defined(_PR_HAVE_GETHOST_R)\n-    tmpbuf = localbuf;\n-    if (bufsize > sizeof(localbuf)) {\n-        tmpbuf = (char*)PR_Malloc(bufsize);\n-        if (NULL == tmpbuf) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            return rv;\n-        }\n+  tmpbuf = localbuf;\n+  if (bufsize > sizeof(localbuf)) {\n+    tmpbuf = (char*)PR_Malloc(bufsize);\n+    if (NULL == tmpbuf) {\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      return rv;\n     }\n+  }\n #endif\n \n-    /* Do not need to lock the DNS lock if getipnodebyname() is called */\n+  /* Do not need to lock the DNS lock if getipnodebyname() is called */\n #ifdef _PR_INET6\n-#ifdef _PR_HAVE_GETHOSTBYNAME2\n-    LOCK_DNS();\n-    if (af == PR_AF_INET6) {\n-        if ((flags & PR_AI_ADDRCONFIG) == 0 || _pr_have_inet6_if) {\n-#ifdef _PR_INET6_PROBE\n-            if (_pr_ipv6_is_present())\n-#endif\n-                h = GETHOSTBYNAME2(name, AF_INET6);\n-        }\n-        if ((NULL == h) && (flags & PR_AI_V4MAPPED) &&\n-            ((flags & PR_AI_ADDRCONFIG) == 0 || _pr_have_inet_if)) {\n-            did_af_inet = PR_TRUE;\n-            h = GETHOSTBYNAME2(name, AF_INET);\n-        }\n-    } else {\n-        if ((flags & PR_AI_ADDRCONFIG) == 0 || _pr_have_inet_if) {\n-            did_af_inet = PR_TRUE;\n-            h = GETHOSTBYNAME2(name, af);\n-        }\n-    }\n-#elif defined(_PR_HAVE_GETIPNODEBYNAME)\n-    h = getipnodebyname(name, md_af, tmp_flags, &error_num);\n-#else\n-#error \"Unknown name-to-address translation function\"\n-#endif /* _PR_HAVE_GETHOSTBYNAME2 */\n+#  ifdef _PR_HAVE_GETHOSTBYNAME2\n+  LOCK_DNS();\n+  if (af == PR_AF_INET6) {\n+    if ((flags & PR_AI_ADDRCONFIG) == 0 || _pr_have_inet6_if) {\n+#    ifdef _PR_INET6_PROBE\n+      if (_pr_ipv6_is_present())\n+#    endif\n+        h = GETHOSTBYNAME2(name, AF_INET6);\n+    }\n+    if ((NULL == h) && (flags & PR_AI_V4MAPPED) &&\n+        ((flags & PR_AI_ADDRCONFIG) == 0 || _pr_have_inet_if)) {\n+      did_af_inet = PR_TRUE;\n+      h = GETHOSTBYNAME2(name, AF_INET);\n+    }\n+  } else {\n+    if ((flags & PR_AI_ADDRCONFIG) == 0 || _pr_have_inet_if) {\n+      did_af_inet = PR_TRUE;\n+      h = GETHOSTBYNAME2(name, af);\n+    }\n+  }\n+#  elif defined(_PR_HAVE_GETIPNODEBYNAME)\n+  h = getipnodebyname(name, md_af, tmp_flags, &error_num);\n+#  else\n+#    error \"Unknown name-to-address translation function\"\n+#  endif /* _PR_HAVE_GETHOSTBYNAME2 */\n #elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYNAME)\n-    if (_pr_ipv6_is_present()) {\n-#ifdef PR_GETIPNODE_NOT_THREADSAFE\n-        LOCK_DNS();\n-#endif\n-        h = (*((_pr_getipnodebyname_t)_pr_getipnodebyname_fp))(\n-            name, md_af, tmp_flags, &error_num);\n-    } else {\n-        LOCK_DNS();\n-        h = GETHOSTBYNAME(name);\n-    }\n-#else  /* _PR_INET6 */\n+  if (_pr_ipv6_is_present()) {\n+#  ifdef PR_GETIPNODE_NOT_THREADSAFE\n+    LOCK_DNS();\n+#  endif\n+    h = (*((_pr_getipnodebyname_t)_pr_getipnodebyname_fp))(\n+        name, md_af, tmp_flags, &error_num);\n+  } else {\n     LOCK_DNS();\n     h = GETHOSTBYNAME(name);\n+  }\n+#else  /* _PR_INET6 */\n+  LOCK_DNS();\n+  h = GETHOSTBYNAME(name);\n #endif /* _PR_INET6 */\n \n-    if (NULL == h) {\n+  if (NULL == h) {\n #if defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)\n-        PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, error_num);\n+    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, error_num);\n #elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYNAME)\n-        if (_pr_ipv6_is_present()) {\n-            PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, error_num);\n-        } else {\n-            PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_GETHOST_ERRNO());\n-        }\n+    if (_pr_ipv6_is_present()) {\n+      PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, error_num);\n+    } else {\n+      PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_GETHOST_ERRNO());\n+    }\n #else\n-        PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_GETHOST_ERRNO());\n+    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_GETHOST_ERRNO());\n #endif\n-    } else {\n-        _PRIPAddrConversion conversion = _PRIPAddrNoConversion;\n+  } else {\n+    _PRIPAddrConversion conversion = _PRIPAddrNoConversion;\n \n-        if (af == PR_AF_INET6) {\n-            conversion = _PRIPAddrIPv4Mapped;\n-        }\n-        rv = CopyHostent(h, &buf, &bufsize, conversion, hp);\n-        if (PR_SUCCESS != rv) {\n-            PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n-        }\n+    if (af == PR_AF_INET6) {\n+      conversion = _PRIPAddrIPv4Mapped;\n+    }\n+    rv = CopyHostent(h, &buf, &bufsize, conversion, hp);\n+    if (PR_SUCCESS != rv) {\n+      PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n+    }\n #if defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)\n-        freehostent(h);\n+    freehostent(h);\n #elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYNAME)\n-        if (_pr_ipv6_is_present()) {\n-            (*((_pr_freehostent_t)_pr_freehostent_fp))(h);\n-        }\n+    if (_pr_ipv6_is_present()) {\n+      (*((_pr_freehostent_t)_pr_freehostent_fp))(h);\n+    }\n #endif\n #if defined(_PR_INET6) && defined(_PR_HAVE_GETHOSTBYNAME2)\n-        if ((PR_SUCCESS == rv) && (flags & PR_AI_V4MAPPED) &&\n-            ((flags & PR_AI_ALL) ||\n-             ((flags & PR_AI_ADDRCONFIG) && _pr_have_inet_if)) &&\n-            !did_af_inet && (h = GETHOSTBYNAME2(name, AF_INET)) != 0) {\n-            rv = AppendV4AddrsToHostent(h, &buf, &bufsize, hp);\n-            if (PR_SUCCESS != rv) {\n-                PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n-            }\n-        }\n-#endif\n+    if ((PR_SUCCESS == rv) && (flags & PR_AI_V4MAPPED) &&\n+        ((flags & PR_AI_ALL) ||\n+         ((flags & PR_AI_ADDRCONFIG) && _pr_have_inet_if)) &&\n+        !did_af_inet && (h = GETHOSTBYNAME2(name, AF_INET)) != 0) {\n+      rv = AppendV4AddrsToHostent(h, &buf, &bufsize, hp);\n+      if (PR_SUCCESS != rv) {\n+        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n+      }\n     }\n+#endif\n+  }\n \n-    /* Must match the convoluted logic above for LOCK_DNS() */\n+  /* Must match the convoluted logic above for LOCK_DNS() */\n #ifdef _PR_INET6\n-#ifdef _PR_HAVE_GETHOSTBYNAME2\n-    UNLOCK_DNS();\n-#endif /* _PR_HAVE_GETHOSTBYNAME2 */\n+#  ifdef _PR_HAVE_GETHOSTBYNAME2\n+  UNLOCK_DNS();\n+#  endif /* _PR_HAVE_GETHOSTBYNAME2 */\n #elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYNAME)\n-#ifdef PR_GETIPNODE_NOT_THREADSAFE\n+#  ifdef PR_GETIPNODE_NOT_THREADSAFE\n+  UNLOCK_DNS();\n+#  else\n+  if (!_pr_ipv6_is_present()) {\n     UNLOCK_DNS();\n-#else\n-    if (!_pr_ipv6_is_present()) {\n-        UNLOCK_DNS();\n-    }\n-#endif\n+  }\n+#  endif\n #else  /* _PR_INET6 */\n-    UNLOCK_DNS();\n+  UNLOCK_DNS();\n #endif /* _PR_INET6 */\n \n #if defined(_PR_HAVE_GETHOST_R)\n-    if (tmpbuf != localbuf) {\n-        PR_Free(tmpbuf);\n-    }\n+  if (tmpbuf != localbuf) {\n+    PR_Free(tmpbuf);\n+  }\n #endif\n \n-    return rv;\n+  return rv;\n }\n \n PR_IMPLEMENT(PRStatus)\n PR_GetHostByAddr(const PRNetAddr* hostaddr, char* buf, PRIntn bufsize,\n-                 PRHostEnt* hostentry)\n-{\n-    struct hostent* h;\n-    PRStatus rv = PR_FAILURE;\n-    const void* addr;\n-    PRUint32 tmp_ip;\n-    int addrlen;\n-    PRInt32 af;\n+                 PRHostEnt* hostentry) {\n+  struct hostent* h;\n+  PRStatus rv = PR_FAILURE;\n+  const void* addr;\n+  PRUint32 tmp_ip;\n+  int addrlen;\n+  PRInt32 af;\n #if defined(_PR_HAVE_GETHOST_R)\n-    char localbuf[PR_NETDB_BUF_SIZE];\n-    char* tmpbuf;\n-    struct hostent tmphe;\n-    int h_err;\n+  char localbuf[PR_NETDB_BUF_SIZE];\n+  char* tmpbuf;\n+  struct hostent tmphe;\n+  int h_err;\n #endif\n #if defined(_PR_HAVE_GETIPNODEBYADDR)\n-    int error_num;\n+  int error_num;\n #endif\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    if (hostaddr->raw.family == PR_AF_INET6) {\n+  if (hostaddr->raw.family == PR_AF_INET6) {\n #if defined(_PR_INET6_PROBE)\n-        af = _pr_ipv6_is_present() ? AF_INET6 : AF_INET;\n+    af = _pr_ipv6_is_present() ? AF_INET6 : AF_INET;\n #elif defined(_PR_INET6)\n-        af = AF_INET6;\n+    af = AF_INET6;\n #else\n-        af = AF_INET;\n+    af = AF_INET;\n #endif\n #if defined(_PR_GHBA_DISALLOW_V4MAPPED)\n-        if (_PR_IN6_IS_ADDR_V4MAPPED(&hostaddr->ipv6.ip)) {\n-            af = AF_INET;\n-        }\n-#endif\n-    } else {\n-        PR_ASSERT(hostaddr->raw.family == AF_INET);\n-        af = AF_INET;\n+    if (_PR_IN6_IS_ADDR_V4MAPPED(&hostaddr->ipv6.ip)) {\n+      af = AF_INET;\n     }\n-    if (hostaddr->raw.family == PR_AF_INET6) {\n+#endif\n+  } else {\n+    PR_ASSERT(hostaddr->raw.family == AF_INET);\n+    af = AF_INET;\n+  }\n+  if (hostaddr->raw.family == PR_AF_INET6) {\n #if defined(_PR_INET6) || defined(_PR_INET6_PROBE)\n-        if (af == AF_INET6) {\n-            addr = &hostaddr->ipv6.ip;\n-            addrlen = sizeof(hostaddr->ipv6.ip);\n-        } else\n+    if (af == AF_INET6) {\n+      addr = &hostaddr->ipv6.ip;\n+      addrlen = sizeof(hostaddr->ipv6.ip);\n+    } else\n #endif\n-        {\n-            PR_ASSERT(af == AF_INET);\n-            if (!_PR_IN6_IS_ADDR_V4MAPPED(&hostaddr->ipv6.ip)) {\n-                PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-                return rv;\n-            }\n-            tmp_ip = _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr*)&hostaddr->ipv6.ip);\n-            addr = &tmp_ip;\n-            addrlen = sizeof(tmp_ip);\n-        }\n-    } else {\n-        PR_ASSERT(hostaddr->raw.family == AF_INET);\n-        PR_ASSERT(af == AF_INET);\n-        addr = &hostaddr->inet.ip;\n-        addrlen = sizeof(hostaddr->inet.ip);\n-    }\n+    {\n+      PR_ASSERT(af == AF_INET);\n+      if (!_PR_IN6_IS_ADDR_V4MAPPED(&hostaddr->ipv6.ip)) {\n+        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+        return rv;\n+      }\n+      tmp_ip = _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr*)&hostaddr->ipv6.ip);\n+      addr = &tmp_ip;\n+      addrlen = sizeof(tmp_ip);\n+    }\n+  } else {\n+    PR_ASSERT(hostaddr->raw.family == AF_INET);\n+    PR_ASSERT(af == AF_INET);\n+    addr = &hostaddr->inet.ip;\n+    addrlen = sizeof(hostaddr->inet.ip);\n+  }\n \n #if defined(_PR_HAVE_GETHOST_R)\n-    tmpbuf = localbuf;\n-    if (bufsize > sizeof(localbuf)) {\n-        tmpbuf = (char*)PR_Malloc(bufsize);\n-        if (NULL == tmpbuf) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            return rv;\n-        }\n+  tmpbuf = localbuf;\n+  if (bufsize > sizeof(localbuf)) {\n+    tmpbuf = (char*)PR_Malloc(bufsize);\n+    if (NULL == tmpbuf) {\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      return rv;\n     }\n+  }\n #endif\n \n-    /* Do not need to lock the DNS lock if getipnodebyaddr() is called */\n+  /* Do not need to lock the DNS lock if getipnodebyaddr() is called */\n #if defined(_PR_HAVE_GETIPNODEBYADDR) && defined(_PR_INET6)\n-    h = getipnodebyaddr(addr, addrlen, af, &error_num);\n+  h = getipnodebyaddr(addr, addrlen, af, &error_num);\n #elif defined(_PR_HAVE_GETIPNODEBYADDR) && defined(_PR_INET6_PROBE)\n-    if (_pr_ipv6_is_present()) {\n-#ifdef PR_GETIPNODE_NOT_THREADSAFE\n-        LOCK_DNS();\n-#endif\n-        h = (*((_pr_getipnodebyaddr_t)_pr_getipnodebyaddr_fp))(addr, addrlen, af,\n-                                                               &error_num);\n-    } else {\n-        LOCK_DNS();\n-        h = GETHOSTBYADDR(addr, addrlen, af);\n-    }\n-#else  /* _PR_HAVE_GETIPNODEBYADDR */\n+  if (_pr_ipv6_is_present()) {\n+#  ifdef PR_GETIPNODE_NOT_THREADSAFE\n+    LOCK_DNS();\n+#  endif\n+    h = (*((_pr_getipnodebyaddr_t)_pr_getipnodebyaddr_fp))(addr, addrlen, af,\n+                                                           &error_num);\n+  } else {\n     LOCK_DNS();\n     h = GETHOSTBYADDR(addr, addrlen, af);\n+  }\n+#else  /* _PR_HAVE_GETIPNODEBYADDR */\n+  LOCK_DNS();\n+  h = GETHOSTBYADDR(addr, addrlen, af);\n #endif /* _PR_HAVE_GETIPNODEBYADDR */\n-    if (NULL == h) {\n+  if (NULL == h) {\n #if defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYADDR)\n-        PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, error_num);\n+    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, error_num);\n #elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYADDR)\n-        if (_pr_ipv6_is_present()) {\n-            PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, error_num);\n-        } else {\n-            PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_GETHOST_ERRNO());\n-        }\n+    if (_pr_ipv6_is_present()) {\n+      PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, error_num);\n+    } else {\n+      PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_GETHOST_ERRNO());\n+    }\n #else\n-        PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_GETHOST_ERRNO());\n+    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_GETHOST_ERRNO());\n #endif\n-    } else {\n-        _PRIPAddrConversion conversion = _PRIPAddrNoConversion;\n-        if (hostaddr->raw.family == PR_AF_INET6) {\n-            if (af == AF_INET) {\n-                if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr*)&hostaddr->ipv6.ip)) {\n-                    conversion = _PRIPAddrIPv4Mapped;\n-                } else if (_PR_IN6_IS_ADDR_V4COMPAT((PRIPv6Addr*)&hostaddr->ipv6.ip)) {\n-                    conversion = _PRIPAddrIPv4Compat;\n-                }\n-            }\n-        }\n-        rv = CopyHostent(h, &buf, &bufsize, conversion, hostentry);\n-        if (PR_SUCCESS != rv) {\n-            PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n+  } else {\n+    _PRIPAddrConversion conversion = _PRIPAddrNoConversion;\n+    if (hostaddr->raw.family == PR_AF_INET6) {\n+      if (af == AF_INET) {\n+        if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr*)&hostaddr->ipv6.ip)) {\n+          conversion = _PRIPAddrIPv4Mapped;\n+        } else if (_PR_IN6_IS_ADDR_V4COMPAT((PRIPv6Addr*)&hostaddr->ipv6.ip)) {\n+          conversion = _PRIPAddrIPv4Compat;\n         }\n+      }\n+    }\n+    rv = CopyHostent(h, &buf, &bufsize, conversion, hostentry);\n+    if (PR_SUCCESS != rv) {\n+      PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n+    }\n #if defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYADDR)\n-        freehostent(h);\n+    freehostent(h);\n #elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYADDR)\n-        if (_pr_ipv6_is_present()) {\n-            (*((_pr_freehostent_t)_pr_freehostent_fp))(h);\n-        }\n-#endif\n+    if (_pr_ipv6_is_present()) {\n+      (*((_pr_freehostent_t)_pr_freehostent_fp))(h);\n     }\n+#endif\n+  }\n \n-    /* Must match the convoluted logic above for LOCK_DNS() */\n+  /* Must match the convoluted logic above for LOCK_DNS() */\n #if defined(_PR_HAVE_GETIPNODEBYADDR) && defined(_PR_INET6)\n #elif defined(_PR_HAVE_GETIPNODEBYADDR) && defined(_PR_INET6_PROBE)\n-#ifdef PR_GETIPNODE_NOT_THREADSAFE\n+#  ifdef PR_GETIPNODE_NOT_THREADSAFE\n+  UNLOCK_DNS();\n+#  else\n+  if (!_pr_ipv6_is_present()) {\n     UNLOCK_DNS();\n-#else\n-    if (!_pr_ipv6_is_present()) {\n-        UNLOCK_DNS();\n-    }\n-#endif\n+  }\n+#  endif\n #else  /* _PR_HAVE_GETIPNODEBYADDR */\n-    UNLOCK_DNS();\n+  UNLOCK_DNS();\n #endif /* _PR_HAVE_GETIPNODEBYADDR */\n \n #if defined(_PR_HAVE_GETHOST_R)\n-    if (tmpbuf != localbuf) {\n-        PR_Free(tmpbuf);\n-    }\n+  if (tmpbuf != localbuf) {\n+    PR_Free(tmpbuf);\n+  }\n #endif\n \n-    return rv;\n+  return rv;\n }\n \n /******************************************************************************/\n@@ -1141,626 +1110,372 @@ PR_GetHostByAddr(const PRNetAddr* hostaddr, char* buf, PRIntn bufsize,\n  * any usable implementation.\n  */\n \n-#if defined(ANDROID)\n+#  if defined(ANDROID)\n /* Android's Bionic libc system includes prototypes for these in netdb.h,\n  * but doesn't actually include implementations.  It uses the 5-arg form,\n  * so these functions end up not matching the prototype.  So just rename\n  * them if not found.\n  */\n-#define getprotobyname_r _pr_getprotobyname_r\n-#define getprotobynumber_r _pr_getprotobynumber_r\n-#endif\n+#    define getprotobyname_r _pr_getprotobyname_r\n+#    define getprotobynumber_r _pr_getprotobynumber_r\n+#  endif\n \n-static struct protoent*\n-getprotobyname_r(const char* name)\n-{\n-    return getprotobyname(name);\n+static struct protoent* getprotobyname_r(const char* name) {\n+  return getprotobyname(name);\n } /* getprotobyname_r */\n \n-static struct protoent*\n-getprotobynumber_r(PRInt32 number)\n-{\n-    return getprotobynumber(number);\n+static struct protoent* getprotobynumber_r(PRInt32 number) {\n+  return getprotobynumber(number);\n } /* getprotobynumber_r */\n \n #endif /* !defined(_PR_HAVE_GETPROTO_R) */\n \n PR_IMPLEMENT(PRStatus)\n PR_GetProtoByName(const char* name, char* buffer, PRInt32 buflen,\n-                  PRProtoEnt* result)\n-{\n-    PRStatus rv = PR_SUCCESS;\n+                  PRProtoEnt* result) {\n+  PRStatus rv = PR_SUCCESS;\n #if defined(_PR_HAVE_GETPROTO_R)\n-    struct protoent* res = (struct protoent*)result;\n+  struct protoent* res = (struct protoent*)result;\n #endif\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n #if defined(_PR_HAVE_GETPROTO_R_INT)\n-    {\n-        /*\n-        ** The protoent_data has a pointer as the first field.\n-        ** That implies the buffer better be aligned, and char*\n-        ** doesn't promise much.\n-        */\n-        PRUptrdiff aligned = (PRUptrdiff)buffer;\n-        if (0 != (aligned & (sizeof(struct protoent_data*) - 1))) {\n-            aligned += sizeof(struct protoent_data*) - 1;\n-            aligned &= ~(sizeof(struct protoent_data*) - 1);\n-            buflen -= (aligned - (PRUptrdiff)buffer);\n-            buffer = (char*)aligned;\n-        }\n-    }\n+  {\n+    /*\n+    ** The protoent_data has a pointer as the first field.\n+    ** That implies the buffer better be aligned, and char*\n+    ** doesn't promise much.\n+    */\n+    PRUptrdiff aligned = (PRUptrdiff)buffer;\n+    if (0 != (aligned & (sizeof(struct protoent_data*) - 1))) {\n+      aligned += sizeof(struct protoent_data*) - 1;\n+      aligned &= ~(sizeof(struct protoent_data*) - 1);\n+      buflen -= (aligned - (PRUptrdiff)buffer);\n+      buffer = (char*)aligned;\n+    }\n+  }\n #endif /* defined(_PR_HAVE_GETPROTO_R_INT) */\n \n-    if (PR_MIN_NETDB_BUF_SIZE > buflen) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (PR_MIN_NETDB_BUF_SIZE > buflen) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n #if defined(_PR_HAVE_GETPROTO_R_POINTER)\n-    if (NULL == getprotobyname_r(name, res, buffer, buflen)) {\n-        PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n-        return PR_FAILURE;\n-    }\n+  if (NULL == getprotobyname_r(name, res, buffer, buflen)) {\n+    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n+    return PR_FAILURE;\n+  }\n #elif defined(_PR_HAVE_GETPROTO_R_INT)\n-    /*\n-    ** The buffer needs to be zero'd, and it should be\n-    ** at least the size of a struct protoent_data.\n-    */\n-    memset(buffer, 0, buflen);\n-    if (-1 == getprotobyname_r(name, res, (struct protoent_data*)buffer)) {\n-        PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n-        return PR_FAILURE;\n-    }\n+  /*\n+  ** The buffer needs to be zero'd, and it should be\n+  ** at least the size of a struct protoent_data.\n+  */\n+  memset(buffer, 0, buflen);\n+  if (-1 == getprotobyname_r(name, res, (struct protoent_data*)buffer)) {\n+    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n+    return PR_FAILURE;\n+  }\n #elif defined(_PR_HAVE_5_ARG_GETPROTO_R)\n-    /* The 5th argument for getprotobyname_r() cannot be NULL */\n-    if (-1 == getprotobyname_r(name, res, buffer, buflen, &res)) {\n-        PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n-        return PR_FAILURE;\n-    }\n+  /* The 5th argument for getprotobyname_r() cannot be NULL */\n+  if (-1 == getprotobyname_r(name, res, buffer, buflen, &res)) {\n+    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n+    return PR_FAILURE;\n+  }\n #else  /* do it the hard way */\n-    {\n-        struct protoent* staticBuf;\n-        PR_Lock(_getproto_lock);\n-        staticBuf = getprotobyname_r(name);\n-        if (NULL == staticBuf) {\n-            rv = PR_FAILURE;\n-            PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n-        } else {\n-            rv = CopyProtoent(staticBuf, buffer, buflen, result);\n-            if (PR_FAILURE == rv) {\n-                PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n-            }\n-        }\n-        PR_Unlock(_getproto_lock);\n+  {\n+    struct protoent* staticBuf;\n+    PR_Lock(_getproto_lock);\n+    staticBuf = getprotobyname_r(name);\n+    if (NULL == staticBuf) {\n+      rv = PR_FAILURE;\n+      PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n+    } else {\n+      rv = CopyProtoent(staticBuf, buffer, buflen, result);\n+      if (PR_FAILURE == rv) {\n+        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n+      }\n     }\n+    PR_Unlock(_getproto_lock);\n+  }\n #endif /* all that */\n-    return rv;\n+  return rv;\n }\n \n PR_IMPLEMENT(PRStatus)\n PR_GetProtoByNumber(PRInt32 number, char* buffer, PRInt32 buflen,\n-                    PRProtoEnt* result)\n-{\n-    PRStatus rv = PR_SUCCESS;\n+                    PRProtoEnt* result) {\n+  PRStatus rv = PR_SUCCESS;\n #if defined(_PR_HAVE_GETPROTO_R)\n-    struct protoent* res = (struct protoent*)result;\n+  struct protoent* res = (struct protoent*)result;\n #endif\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n #if defined(_PR_HAVE_GETPROTO_R_INT)\n-    {\n-        /*\n-        ** The protoent_data has a pointer as the first field.\n-        ** That implies the buffer better be aligned, and char*\n-        ** doesn't promise much.\n-        */\n-        PRUptrdiff aligned = (PRUptrdiff)buffer;\n-        if (0 != (aligned & (sizeof(struct protoent_data*) - 1))) {\n-            aligned += sizeof(struct protoent_data*) - 1;\n-            aligned &= ~(sizeof(struct protoent_data*) - 1);\n-            buflen -= (aligned - (PRUptrdiff)buffer);\n-            buffer = (char*)aligned;\n-        }\n-    }\n+  {\n+    /*\n+    ** The protoent_data has a pointer as the first field.\n+    ** That implies the buffer better be aligned, and char*\n+    ** doesn't promise much.\n+    */\n+    PRUptrdiff aligned = (PRUptrdiff)buffer;\n+    if (0 != (aligned & (sizeof(struct protoent_data*) - 1))) {\n+      aligned += sizeof(struct protoent_data*) - 1;\n+      aligned &= ~(sizeof(struct protoent_data*) - 1);\n+      buflen -= (aligned - (PRUptrdiff)buffer);\n+      buffer = (char*)aligned;\n+    }\n+  }\n #endif /* defined(_PR_HAVE_GETPROTO_R_INT) */\n \n-    if (PR_MIN_NETDB_BUF_SIZE > buflen) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (PR_MIN_NETDB_BUF_SIZE > buflen) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n #if defined(_PR_HAVE_GETPROTO_R_POINTER)\n-    if (NULL == getprotobynumber_r(number, res, buffer, buflen)) {\n-        PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n-        return PR_FAILURE;\n-    }\n+  if (NULL == getprotobynumber_r(number, res, buffer, buflen)) {\n+    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n+    return PR_FAILURE;\n+  }\n \n #elif defined(_PR_HAVE_GETPROTO_R_INT)\n-    /*\n-    ** The buffer needs to be zero'd for these OS's.\n-    */\n-    memset(buffer, 0, buflen);\n-    if (-1 == getprotobynumber_r(number, res, (struct protoent_data*)buffer)) {\n-        PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n-        return PR_FAILURE;\n-    }\n+  /*\n+  ** The buffer needs to be zero'd for these OS's.\n+  */\n+  memset(buffer, 0, buflen);\n+  if (-1 == getprotobynumber_r(number, res, (struct protoent_data*)buffer)) {\n+    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n+    return PR_FAILURE;\n+  }\n #elif defined(_PR_HAVE_5_ARG_GETPROTO_R)\n-    /* The 5th argument for getprotobynumber_r() cannot be NULL */\n-    if (-1 == getprotobynumber_r(number, res, buffer, buflen, &res)) {\n-        PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n-        return PR_FAILURE;\n-    }\n+  /* The 5th argument for getprotobynumber_r() cannot be NULL */\n+  if (-1 == getprotobynumber_r(number, res, buffer, buflen, &res)) {\n+    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n+    return PR_FAILURE;\n+  }\n #else  /* do it the hard way */\n-    {\n-        struct protoent* staticBuf;\n-        PR_Lock(_getproto_lock);\n-        staticBuf = getprotobynumber_r(number);\n-        if (NULL == staticBuf) {\n-            rv = PR_FAILURE;\n-            PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n-        } else {\n-            rv = CopyProtoent(staticBuf, buffer, buflen, result);\n-            if (PR_FAILURE == rv) {\n-                PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n-            }\n-        }\n-        PR_Unlock(_getproto_lock);\n+  {\n+    struct protoent* staticBuf;\n+    PR_Lock(_getproto_lock);\n+    staticBuf = getprotobynumber_r(number);\n+    if (NULL == staticBuf) {\n+      rv = PR_FAILURE;\n+      PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_ERRNO());\n+    } else {\n+      rv = CopyProtoent(staticBuf, buffer, buflen, result);\n+      if (PR_FAILURE == rv) {\n+        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n+      }\n     }\n+    PR_Unlock(_getproto_lock);\n+  }\n #endif /* all that crap */\n-    return rv;\n+  return rv;\n }\n \n-PRUintn\n-_PR_NetAddrSize(const PRNetAddr* addr)\n-{\n-    PRUintn addrsize;\n-\n-    /*\n-     * RFC 2553 added a new field (sin6_scope_id) to\n-     * struct sockaddr_in6.  PRNetAddr's ipv6 member has a\n-     * scope_id field to match the new field.  In order to\n-     * work with older implementations supporting RFC 2133,\n-     * we take the size of struct sockaddr_in6 instead of\n-     * addr->ipv6.\n-     */\n-    if (AF_INET == addr->raw.family) {\n-        addrsize = sizeof(addr->inet);\n-    } else if (PR_AF_INET6 == addr->raw.family)\n+PRUintn _PR_NetAddrSize(const PRNetAddr* addr) {\n+  PRUintn addrsize;\n+\n+  /*\n+   * RFC 2553 added a new field (sin6_scope_id) to\n+   * struct sockaddr_in6.  PRNetAddr's ipv6 member has a\n+   * scope_id field to match the new field.  In order to\n+   * work with older implementations supporting RFC 2133,\n+   * we take the size of struct sockaddr_in6 instead of\n+   * addr->ipv6.\n+   */\n+  if (AF_INET == addr->raw.family) {\n+    addrsize = sizeof(addr->inet);\n+  } else if (PR_AF_INET6 == addr->raw.family)\n #if defined(_PR_INET6)\n-        addrsize = sizeof(struct sockaddr_in6);\n+    addrsize = sizeof(struct sockaddr_in6);\n #else\n-        addrsize = sizeof(addr->ipv6);\n+    addrsize = sizeof(addr->ipv6);\n #endif\n #if defined(XP_UNIX)\n-    else if (AF_UNIX == addr->raw.family) {\n-#if defined(LINUX)\n-        if (addr->local.path[0] == 0)\n-            /* abstract socket address is supported on Linux only */\n-            addrsize = strnlen(addr->local.path + 1, sizeof(addr->local.path) - 1) +\n-                       offsetof(struct sockaddr_un, sun_path) + 1;\n-        else\n-#endif\n-            addrsize = sizeof(addr->local);\n-    }\n-#endif\n-    else {\n-        addrsize = 0;\n-    }\n-\n-    return addrsize;\n+  else if (AF_UNIX == addr->raw.family) {\n+#  if defined(LINUX)\n+    if (addr->local.path[0] == 0)\n+      /* abstract socket address is supported on Linux only */\n+      addrsize = strnlen(addr->local.path + 1, sizeof(addr->local.path)) +\n+                 offsetof(struct sockaddr_un, sun_path) + 1;\n+    else\n+#  endif\n+      addrsize = sizeof(addr->local);\n+  }\n+#endif\n+  else {\n+    addrsize = 0;\n+  }\n+\n+  return addrsize;\n } /* _PR_NetAddrSize */\n \n PR_IMPLEMENT(PRIntn)\n PR_EnumerateHostEnt(PRIntn enumIndex, const PRHostEnt* hostEnt, PRUint16 port,\n-                    PRNetAddr* address)\n-{\n-    void* addr = hostEnt->h_addr_list[enumIndex++];\n-    memset(address, 0, sizeof(PRNetAddr));\n-    if (NULL == addr) {\n-        enumIndex = 0;\n+                    PRNetAddr* address) {\n+  void* addr = hostEnt->h_addr_list[enumIndex++];\n+  memset(address, 0, sizeof(PRNetAddr));\n+  if (NULL == addr) {\n+    enumIndex = 0;\n+  } else {\n+    address->raw.family = hostEnt->h_addrtype;\n+    if (PR_AF_INET6 == hostEnt->h_addrtype) {\n+      address->ipv6.port = htons(port);\n+      address->ipv6.flowinfo = 0;\n+      address->ipv6.scope_id = 0;\n+      memcpy(&address->ipv6.ip, addr, hostEnt->h_length);\n     } else {\n-        address->raw.family = hostEnt->h_addrtype;\n-        if (PR_AF_INET6 == hostEnt->h_addrtype) {\n-            address->ipv6.port = htons(port);\n-            address->ipv6.flowinfo = 0;\n-            address->ipv6.scope_id = 0;\n-            memcpy(&address->ipv6.ip, addr, hostEnt->h_length);\n-        } else {\n-            PR_ASSERT(AF_INET == hostEnt->h_addrtype);\n-            address->inet.port = htons(port);\n-            memcpy(&address->inet.ip, addr, hostEnt->h_length);\n-        }\n+      PR_ASSERT(AF_INET == hostEnt->h_addrtype);\n+      address->inet.port = htons(port);\n+      memcpy(&address->inet.ip, addr, hostEnt->h_length);\n     }\n-    return enumIndex;\n+  }\n+  return enumIndex;\n } /* PR_EnumerateHostEnt */\n \n PR_IMPLEMENT(PRStatus)\n-PR_InitializeNetAddr(PRNetAddrValue val, PRUint16 port, PRNetAddr* addr)\n-{\n-    PRStatus rv = PR_SUCCESS;\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+PR_InitializeNetAddr(PRNetAddrValue val, PRUint16 port, PRNetAddr* addr) {\n+  PRStatus rv = PR_SUCCESS;\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  if (val != PR_IpAddrNull) {\n+    memset(addr, 0, sizeof(*addr));\n+  }\n+  addr->inet.family = AF_INET;\n+  addr->inet.port = htons(port);\n+  switch (val) {\n+    case PR_IpAddrNull:\n+      break; /* don't overwrite the address */\n+    case PR_IpAddrAny:\n+      addr->inet.ip = htonl(INADDR_ANY);\n+      break;\n+    case PR_IpAddrLoopback:\n+      addr->inet.ip = htonl(INADDR_LOOPBACK);\n+      break;\n+    default:\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      rv = PR_FAILURE;\n+  }\n+  return rv;\n+} /* PR_InitializeNetAddr */\n \n+PR_IMPLEMENT(PRStatus)\n+PR_SetNetAddr(PRNetAddrValue val, PRUint16 af, PRUint16 port, PRNetAddr* addr) {\n+  PRStatus rv = PR_SUCCESS;\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  if (af == PR_AF_INET6) {\n     if (val != PR_IpAddrNull) {\n-        memset(addr, 0, sizeof(*addr));\n+      memset(addr, 0, sizeof(addr->ipv6));\n     }\n-    addr->inet.family = AF_INET;\n-    addr->inet.port = htons(port);\n+    addr->ipv6.family = af;\n+    addr->ipv6.port = htons(port);\n+    addr->ipv6.flowinfo = 0;\n+    addr->ipv6.scope_id = 0;\n     switch (val) {\n-        case PR_IpAddrNull:\n-            break; /* don't overwrite the address */\n-        case PR_IpAddrAny:\n-            addr->inet.ip = htonl(INADDR_ANY);\n-            break;\n-        case PR_IpAddrLoopback:\n-            addr->inet.ip = htonl(INADDR_LOOPBACK);\n-            break;\n-        default:\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            rv = PR_FAILURE;\n-    }\n-    return rv;\n-} /* PR_InitializeNetAddr */\n-\n-PR_IMPLEMENT(PRStatus)\n-PR_SetNetAddr(PRNetAddrValue val, PRUint16 af, PRUint16 port, PRNetAddr* addr)\n-{\n-    PRStatus rv = PR_SUCCESS;\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n+      case PR_IpAddrNull:\n+        break; /* don't overwrite the address */\n+      case PR_IpAddrAny:\n+        addr->ipv6.ip = _pr_in6addr_any;\n+        break;\n+      case PR_IpAddrLoopback:\n+        addr->ipv6.ip = _pr_in6addr_loopback;\n+        break;\n+      default:\n+        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+        rv = PR_FAILURE;\n     }\n-\n-    if (af == PR_AF_INET6) {\n-        if (val != PR_IpAddrNull) {\n-            memset(addr, 0, sizeof(addr->ipv6));\n-        }\n-        addr->ipv6.family = af;\n-        addr->ipv6.port = htons(port);\n-        addr->ipv6.flowinfo = 0;\n-        addr->ipv6.scope_id = 0;\n-        switch (val) {\n-            case PR_IpAddrNull:\n-                break; /* don't overwrite the address */\n-            case PR_IpAddrAny:\n-                addr->ipv6.ip = _pr_in6addr_any;\n-                break;\n-            case PR_IpAddrLoopback:\n-                addr->ipv6.ip = _pr_in6addr_loopback;\n-                break;\n-            default:\n-                PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-                rv = PR_FAILURE;\n-        }\n-    } else {\n-        if (val != PR_IpAddrNull) {\n-            memset(addr, 0, sizeof(addr->inet));\n-        }\n-        addr->inet.family = af;\n-        addr->inet.port = htons(port);\n-        switch (val) {\n-            case PR_IpAddrNull:\n-                break; /* don't overwrite the address */\n-            case PR_IpAddrAny:\n-                addr->inet.ip = htonl(INADDR_ANY);\n-                break;\n-            case PR_IpAddrLoopback:\n-                addr->inet.ip = htonl(INADDR_LOOPBACK);\n-                break;\n-            default:\n-                PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-                rv = PR_FAILURE;\n-        }\n+  } else {\n+    if (val != PR_IpAddrNull) {\n+      memset(addr, 0, sizeof(addr->inet));\n     }\n-    return rv;\n+    addr->inet.family = af;\n+    addr->inet.port = htons(port);\n+    switch (val) {\n+      case PR_IpAddrNull:\n+        break; /* don't overwrite the address */\n+      case PR_IpAddrAny:\n+        addr->inet.ip = htonl(INADDR_ANY);\n+        break;\n+      case PR_IpAddrLoopback:\n+        addr->inet.ip = htonl(INADDR_LOOPBACK);\n+        break;\n+      default:\n+        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+        rv = PR_FAILURE;\n+    }\n+  }\n+  return rv;\n } /* PR_SetNetAddr */\n \n PR_IMPLEMENT(PRBool)\n-PR_IsNetAddrType(const PRNetAddr* addr, PRNetAddrValue val)\n-{\n-    if (addr->raw.family == PR_AF_INET6) {\n-        if (val == PR_IpAddrAny) {\n-            if (_PR_IN6_IS_ADDR_UNSPECIFIED((PRIPv6Addr*)&addr->ipv6.ip)) {\n-                return PR_TRUE;\n-            }\n-            if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr*)&addr->ipv6.ip) &&\n-                _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr*)&addr->ipv6.ip) ==\n-                    htonl(INADDR_ANY)) {\n-                return PR_TRUE;\n-            }\n-        } else if (val == PR_IpAddrLoopback) {\n-            if (_PR_IN6_IS_ADDR_LOOPBACK((PRIPv6Addr*)&addr->ipv6.ip)) {\n-                return PR_TRUE;\n-            }\n-            if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr*)&addr->ipv6.ip) &&\n-                _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr*)&addr->ipv6.ip) ==\n-                    htonl(INADDR_LOOPBACK)) {\n-                return PR_TRUE;\n-            }\n-        } else if (val == PR_IpAddrV4Mapped &&\n-                   _PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr*)&addr->ipv6.ip)) {\n-            return PR_TRUE;\n-        }\n-    } else {\n-        if (addr->raw.family == AF_INET) {\n-            if (val == PR_IpAddrAny && addr->inet.ip == htonl(INADDR_ANY)) {\n-                return PR_TRUE;\n-            }\n-            if (val == PR_IpAddrLoopback && addr->inet.ip == htonl(INADDR_LOOPBACK)) {\n-                return PR_TRUE;\n-            }\n-        }\n-    }\n-    return PR_FALSE;\n+PR_IsNetAddrType(const PRNetAddr* addr, PRNetAddrValue val) {\n+  if (addr->raw.family == PR_AF_INET6) {\n+    if (val == PR_IpAddrAny) {\n+      if (_PR_IN6_IS_ADDR_UNSPECIFIED((PRIPv6Addr*)&addr->ipv6.ip)) {\n+        return PR_TRUE;\n+      }\n+      if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr*)&addr->ipv6.ip) &&\n+          _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr*)&addr->ipv6.ip) ==\n+              htonl(INADDR_ANY)) {\n+        return PR_TRUE;\n+      }\n+    } else if (val == PR_IpAddrLoopback) {\n+      if (_PR_IN6_IS_ADDR_LOOPBACK((PRIPv6Addr*)&addr->ipv6.ip)) {\n+        return PR_TRUE;\n+      }\n+      if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr*)&addr->ipv6.ip) &&\n+          _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr*)&addr->ipv6.ip) ==\n+              htonl(INADDR_LOOPBACK)) {\n+        return PR_TRUE;\n+      }\n+    } else if (val == PR_IpAddrV4Mapped &&\n+               _PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr*)&addr->ipv6.ip)) {\n+      return PR_TRUE;\n+    }\n+  } else {\n+    if (addr->raw.family == AF_INET) {\n+      if (val == PR_IpAddrAny && addr->inet.ip == htonl(INADDR_ANY)) {\n+        return PR_TRUE;\n+      }\n+      if (val == PR_IpAddrLoopback && addr->inet.ip == htonl(INADDR_LOOPBACK)) {\n+        return PR_TRUE;\n+      }\n+    }\n+  }\n+  return PR_FALSE;\n }\n \n extern int pr_inet_aton(const char* cp, PRUint32* addr);\n \n #define XX 127\n static const unsigned char index_hex[256] = {\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    0,\n-    1,\n-    2,\n-    3,\n-    4,\n-    5,\n-    6,\n-    7,\n-    8,\n-    9,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    10,\n-    11,\n-    12,\n-    13,\n-    14,\n-    15,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    10,\n-    11,\n-    12,\n-    13,\n-    14,\n-    15,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n-    XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, 0,  1,  2,  3,  4,  5,  6,  7,  8,\n+    9,  XX, XX, XX, XX, XX, XX, XX, 10, 11, 12, 13, 14, 15, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, 10, 11, 12, 13, 14, 15, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,\n+    XX, XX, XX, XX, XX, XX, XX, XX, XX,\n };\n \n /*\n@@ -1768,143 +1483,141 @@ static const unsigned char index_hex[256] = {\n  * or 0 if the input is not a valid IPv6 address string.\n  * (Same as inet_pton(AF_INET6, string, addr).)\n  */\n-static int\n-StringToV6Addr(const char* string, PRIPv6Addr* addr)\n-{\n-    const unsigned char* s = (const unsigned char*)string;\n-    int section = 0;       /* index of the current section (a 16-bit\n-                            * piece of the address */\n-    int double_colon = -1; /* index of the section after the first\n-                            * 16-bit group of zeros represented by\n-                            * the double colon */\n-    unsigned int val;\n-    int len;\n-\n-    /* Handle initial (double) colon */\n+static int StringToV6Addr(const char* string, PRIPv6Addr* addr) {\n+  const unsigned char* s = (const unsigned char*)string;\n+  int section = 0;       /* index of the current section (a 16-bit\n+                          * piece of the address */\n+  int double_colon = -1; /* index of the section after the first\n+                          * 16-bit group of zeros represented by\n+                          * the double colon */\n+  unsigned int val;\n+  int len;\n+\n+  /* Handle initial (double) colon */\n+  if (*s == ':') {\n+    if (s[1] != ':') {\n+      return 0;\n+    }\n+    s += 2;\n+    addr->pr_s6_addr16[0] = 0;\n+    section = double_colon = 1;\n+  }\n+\n+  while (*s) {\n+    if (section == 8) {\n+      return 0; /* too long */\n+    }\n     if (*s == ':') {\n-        if (s[1] != ':') {\n-            return 0;\n-        }\n-        s += 2;\n-        addr->pr_s6_addr16[0] = 0;\n-        section = double_colon = 1;\n+      if (double_colon != -1) {\n+        return 0; /* two double colons */\n+      }\n+      addr->pr_s6_addr16[section++] = 0;\n+      double_colon = section;\n+      s++;\n+      continue;\n     }\n-\n-    while (*s) {\n-        if (section == 8) {\n-            return 0; /* too long */\n-        }\n-        if (*s == ':') {\n-            if (double_colon != -1) {\n-                return 0; /* two double colons */\n-            }\n-            addr->pr_s6_addr16[section++] = 0;\n-            double_colon = section;\n-            s++;\n-            continue;\n-        }\n-        for (len = val = 0; len < 4 && index_hex[*s] != XX; len++) {\n-            val = (val << 4) + index_hex[*s++];\n-        }\n-        if (*s == '.') {\n-            if (len == 0) {\n-                return 0; /* nothing between : and . */\n-            }\n-            break;\n-        }\n-        if (*s == ':') {\n-            s++;\n-            if (!*s) {\n-                return 0; /* cannot end with single colon */\n-            }\n-        } else if (*s) {\n-            return 0; /* bad character */\n-        }\n-        addr->pr_s6_addr16[section++] = htons((unsigned short)val);\n+    for (len = val = 0; len < 4 && index_hex[*s] != XX; len++) {\n+      val = (val << 4) + index_hex[*s++];\n     }\n-\n     if (*s == '.') {\n-        /* Have a trailing v4 format address */\n-        if (section > 6) {\n-            return 0; /* not enough room */\n-        }\n+      if (len == 0) {\n+        return 0; /* nothing between : and . */\n+      }\n+      break;\n+    }\n+    if (*s == ':') {\n+      s++;\n+      if (!*s) {\n+        return 0; /* cannot end with single colon */\n+      }\n+    } else if (*s) {\n+      return 0; /* bad character */\n+    }\n+    addr->pr_s6_addr16[section++] = htons((unsigned short)val);\n+  }\n \n-        /*\n-         * The number before the '.' is decimal, but we parsed it\n-         * as hex.  That means it is in BCD.  Check it for validity\n-         * and convert it to binary.\n-         */\n-        if (val > 0x0255 || (val & 0xf0) > 0x90 || (val & 0xf) > 9) {\n-            return 0;\n-        }\n-        val = (val >> 8) * 100 + ((val >> 4) & 0xf) * 10 + (val & 0xf);\n-        addr->pr_s6_addr[2 * section] = val;\n+  if (*s == '.') {\n+    /* Have a trailing v4 format address */\n+    if (section > 6) {\n+      return 0; /* not enough room */\n+    }\n \n-        s++;\n-        val = index_hex[*s++];\n-        if (val > 9) {\n-            return 0;\n-        }\n-        while (*s >= '0' && *s <= '9') {\n-            val = val * 10 + *s++ - '0';\n-            if (val > 255) {\n-                return 0;\n-            }\n-        }\n-        if (*s != '.') {\n-            return 0; /* must have exactly 4 decimal numbers */\n-        }\n-        addr->pr_s6_addr[2 * section + 1] = val;\n-        section++;\n+    /*\n+     * The number before the '.' is decimal, but we parsed it\n+     * as hex.  That means it is in BCD.  Check it for validity\n+     * and convert it to binary.\n+     */\n+    if (val > 0x0255 || (val & 0xf0) > 0x90 || (val & 0xf) > 9) {\n+      return 0;\n+    }\n+    val = (val >> 8) * 100 + ((val >> 4) & 0xf) * 10 + (val & 0xf);\n+    addr->pr_s6_addr[2 * section] = val;\n \n-        s++;\n-        val = index_hex[*s++];\n-        if (val > 9) {\n-            return 0;\n-        }\n-        while (*s >= '0' && *s <= '9') {\n-            val = val * 10 + *s++ - '0';\n-            if (val > 255) {\n-                return 0;\n-            }\n-        }\n-        if (*s != '.') {\n-            return 0; /* must have exactly 4 decimal numbers */\n-        }\n-        addr->pr_s6_addr[2 * section] = val;\n+    s++;\n+    val = index_hex[*s++];\n+    if (val > 9) {\n+      return 0;\n+    }\n+    while (*s >= '0' && *s <= '9') {\n+      val = val * 10 + *s++ - '0';\n+      if (val > 255) {\n+        return 0;\n+      }\n+    }\n+    if (*s != '.') {\n+      return 0; /* must have exactly 4 decimal numbers */\n+    }\n+    addr->pr_s6_addr[2 * section + 1] = val;\n+    section++;\n \n-        s++;\n-        val = index_hex[*s++];\n-        if (val > 9) {\n-            return 0;\n-        }\n-        while (*s >= '0' && *s <= '9') {\n-            val = val * 10 + *s++ - '0';\n-            if (val > 255) {\n-                return 0;\n-            }\n-        }\n-        if (*s) {\n-            return 0; /* must have exactly 4 decimal numbers */\n-        }\n-        addr->pr_s6_addr[2 * section + 1] = val;\n-        section++;\n+    s++;\n+    val = index_hex[*s++];\n+    if (val > 9) {\n+      return 0;\n+    }\n+    while (*s >= '0' && *s <= '9') {\n+      val = val * 10 + *s++ - '0';\n+      if (val > 255) {\n+        return 0;\n+      }\n     }\n+    if (*s != '.') {\n+      return 0; /* must have exactly 4 decimal numbers */\n+    }\n+    addr->pr_s6_addr[2 * section] = val;\n \n-    if (double_colon != -1) {\n-        /* Stretch the double colon */\n-        int tosection;\n-        int ncopy = section - double_colon;\n-        for (tosection = 7; ncopy--; tosection--) {\n-            addr->pr_s6_addr16[tosection] = addr->pr_s6_addr16[double_colon + ncopy];\n-        }\n-        while (tosection >= double_colon) {\n-            addr->pr_s6_addr16[tosection--] = 0;\n-        }\n-    } else if (section != 8) {\n-        return 0; /* too short */\n+    s++;\n+    val = index_hex[*s++];\n+    if (val > 9) {\n+      return 0;\n+    }\n+    while (*s >= '0' && *s <= '9') {\n+      val = val * 10 + *s++ - '0';\n+      if (val > 255) {\n+        return 0;\n+      }\n+    }\n+    if (*s) {\n+      return 0; /* must have exactly 4 decimal numbers */\n+    }\n+    addr->pr_s6_addr[2 * section + 1] = val;\n+    section++;\n+  }\n+\n+  if (double_colon != -1) {\n+    /* Stretch the double colon */\n+    int tosection;\n+    int ncopy = section - double_colon;\n+    for (tosection = 7; ncopy--; tosection--) {\n+      addr->pr_s6_addr16[tosection] = addr->pr_s6_addr16[double_colon + ncopy];\n+    }\n+    while (tosection >= double_colon) {\n+      addr->pr_s6_addr16[tosection--] = 0;\n     }\n-    return 1;\n+  } else if (section != 8) {\n+    return 0; /* too short */\n+  }\n+  return 1;\n }\n #undef XX\n \n@@ -1917,123 +1630,120 @@ static const char* basis_hex = \"0123456789abcdef\";\n  * (Same as inet_ntop(AF_INET6, addr, buf, size), except that errno\n  * is not set on failure.)\n  */\n-static const char*\n-V6AddrToString(const PRIPv6Addr* addr, char* buf,\n-               PRUint32 size)\n-{\n-#define STUFF(c)         \\\n-    do {                 \\\n-        if (!size--)     \\\n-            return NULL; \\\n-        *buf++ = (c);    \\\n+static const char* V6AddrToString(const PRIPv6Addr* addr, char* buf,\n+                                  PRUint32 size) {\n+#  define STUFF(c)              \\\n+    do {                        \\\n+      if (!size--) return NULL; \\\n+      *buf++ = (c);             \\\n     } while (0)\n \n-    int double_colon = -1;       /* index of the first 16-bit\n-                                  * group of zeros represented\n-                                  * by the double colon */\n-    int double_colon_length = 1; /* use double colon only if\n-                                  * there are two or more 16-bit\n-                                  * groups of zeros */\n-    int zero_length;\n-    int section;\n-    unsigned int val;\n-    const char* bufcopy = buf;\n-\n-    /* Scan to find the placement of the double colon */\n-    for (section = 0; section < 8; section++) {\n-        if (addr->pr_s6_addr16[section] == 0) {\n-            zero_length = 1;\n-            section++;\n-            while (section < 8 && addr->pr_s6_addr16[section] == 0) {\n-                zero_length++;\n-                section++;\n-            }\n-            /* Select the longest sequence of zeros */\n-            if (zero_length > double_colon_length) {\n-                double_colon = section - zero_length;\n-                double_colon_length = zero_length;\n-            }\n-        }\n-    }\n-\n-    /* Now start converting to a string */\n-    section = 0;\n-\n-    if (double_colon == 0) {\n-        if (double_colon_length == 6 ||\n-            (double_colon_length == 5 && addr->pr_s6_addr16[5] == 0xffff)) {\n-            /* ipv4 format address */\n-            STUFF(':');\n-            STUFF(':');\n-            if (double_colon_length == 5) {\n-                STUFF('f');\n-                STUFF('f');\n-                STUFF('f');\n-                STUFF('f');\n-                STUFF(':');\n-            }\n-            if (addr->pr_s6_addr[12] > 99) {\n-                STUFF(addr->pr_s6_addr[12] / 100 + '0');\n-            }\n-            if (addr->pr_s6_addr[12] > 9) {\n-                STUFF((addr->pr_s6_addr[12] % 100) / 10 + '0');\n-            }\n-            STUFF(addr->pr_s6_addr[12] % 10 + '0');\n-            STUFF('.');\n-            if (addr->pr_s6_addr[13] > 99) {\n-                STUFF(addr->pr_s6_addr[13] / 100 + '0');\n-            }\n-            if (addr->pr_s6_addr[13] > 9) {\n-                STUFF((addr->pr_s6_addr[13] % 100) / 10 + '0');\n-            }\n-            STUFF(addr->pr_s6_addr[13] % 10 + '0');\n-            STUFF('.');\n-            if (addr->pr_s6_addr[14] > 99) {\n-                STUFF(addr->pr_s6_addr[14] / 100 + '0');\n-            }\n-            if (addr->pr_s6_addr[14] > 9) {\n-                STUFF((addr->pr_s6_addr[14] % 100) / 10 + '0');\n-            }\n-            STUFF(addr->pr_s6_addr[14] % 10 + '0');\n-            STUFF('.');\n-            if (addr->pr_s6_addr[15] > 99) {\n-                STUFF(addr->pr_s6_addr[15] / 100 + '0');\n-            }\n-            if (addr->pr_s6_addr[15] > 9) {\n-                STUFF((addr->pr_s6_addr[15] % 100) / 10 + '0');\n-            }\n-            STUFF(addr->pr_s6_addr[15] % 10 + '0');\n-            STUFF('\\0');\n-            return bufcopy;\n-        }\n-    }\n-\n-    while (section < 8) {\n-        if (section == double_colon) {\n-            STUFF(':');\n-            STUFF(':');\n-            section += double_colon_length;\n-            continue;\n-        }\n-        val = ntohs(addr->pr_s6_addr16[section]);\n-        if (val > 0xfff) {\n-            STUFF(basis_hex[val >> 12]);\n-        }\n-        if (val > 0xff) {\n-            STUFF(basis_hex[(val >> 8) & 0xf]);\n-        }\n-        if (val > 0xf) {\n-            STUFF(basis_hex[(val >> 4) & 0xf]);\n-        }\n-        STUFF(basis_hex[val & 0xf]);\n+  int double_colon = -1;       /* index of the first 16-bit\n+                                * group of zeros represented\n+                                * by the double colon */\n+  int double_colon_length = 1; /* use double colon only if\n+                                * there are two or more 16-bit\n+                                * groups of zeros */\n+  int zero_length;\n+  int section;\n+  unsigned int val;\n+  const char* bufcopy = buf;\n+\n+  /* Scan to find the placement of the double colon */\n+  for (section = 0; section < 8; section++) {\n+    if (addr->pr_s6_addr16[section] == 0) {\n+      zero_length = 1;\n+      section++;\n+      while (section < 8 && addr->pr_s6_addr16[section] == 0) {\n+        zero_length++;\n         section++;\n-        if (section < 8 && section != double_colon) {\n-            STUFF(':');\n-        }\n-    }\n-    STUFF('\\0');\n-    return bufcopy;\n-#undef STUFF\n+      }\n+      /* Select the longest sequence of zeros */\n+      if (zero_length > double_colon_length) {\n+        double_colon = section - zero_length;\n+        double_colon_length = zero_length;\n+      }\n+    }\n+  }\n+\n+  /* Now start converting to a string */\n+  section = 0;\n+\n+  if (double_colon == 0) {\n+    if (double_colon_length == 6 ||\n+        (double_colon_length == 5 && addr->pr_s6_addr16[5] == 0xffff)) {\n+      /* ipv4 format address */\n+      STUFF(':');\n+      STUFF(':');\n+      if (double_colon_length == 5) {\n+        STUFF('f');\n+        STUFF('f');\n+        STUFF('f');\n+        STUFF('f');\n+        STUFF(':');\n+      }\n+      if (addr->pr_s6_addr[12] > 99) {\n+        STUFF(addr->pr_s6_addr[12] / 100 + '0');\n+      }\n+      if (addr->pr_s6_addr[12] > 9) {\n+        STUFF((addr->pr_s6_addr[12] % 100) / 10 + '0');\n+      }\n+      STUFF(addr->pr_s6_addr[12] % 10 + '0');\n+      STUFF('.');\n+      if (addr->pr_s6_addr[13] > 99) {\n+        STUFF(addr->pr_s6_addr[13] / 100 + '0');\n+      }\n+      if (addr->pr_s6_addr[13] > 9) {\n+        STUFF((addr->pr_s6_addr[13] % 100) / 10 + '0');\n+      }\n+      STUFF(addr->pr_s6_addr[13] % 10 + '0');\n+      STUFF('.');\n+      if (addr->pr_s6_addr[14] > 99) {\n+        STUFF(addr->pr_s6_addr[14] / 100 + '0');\n+      }\n+      if (addr->pr_s6_addr[14] > 9) {\n+        STUFF((addr->pr_s6_addr[14] % 100) / 10 + '0');\n+      }\n+      STUFF(addr->pr_s6_addr[14] % 10 + '0');\n+      STUFF('.');\n+      if (addr->pr_s6_addr[15] > 99) {\n+        STUFF(addr->pr_s6_addr[15] / 100 + '0');\n+      }\n+      if (addr->pr_s6_addr[15] > 9) {\n+        STUFF((addr->pr_s6_addr[15] % 100) / 10 + '0');\n+      }\n+      STUFF(addr->pr_s6_addr[15] % 10 + '0');\n+      STUFF('\\0');\n+      return bufcopy;\n+    }\n+  }\n+\n+  while (section < 8) {\n+    if (section == double_colon) {\n+      STUFF(':');\n+      STUFF(':');\n+      section += double_colon_length;\n+      continue;\n+    }\n+    val = ntohs(addr->pr_s6_addr16[section]);\n+    if (val > 0xfff) {\n+      STUFF(basis_hex[val >> 12]);\n+    }\n+    if (val > 0xff) {\n+      STUFF(basis_hex[(val >> 8) & 0xf]);\n+    }\n+    if (val > 0xf) {\n+      STUFF(basis_hex[(val >> 4) & 0xf]);\n+    }\n+    STUFF(basis_hex[val & 0xf]);\n+    section++;\n+    if (section < 8 && section != double_colon) {\n+      STUFF(':');\n+    }\n+  }\n+  STUFF('\\0');\n+  return bufcopy;\n+#  undef STUFF\n }\n #endif /* !_PR_HAVE_INET_NTOP */\n \n@@ -2041,50 +1751,41 @@ V6AddrToString(const PRIPv6Addr* addr, char* buf,\n  * Convert an IPv4 addr to an (IPv4-mapped) IPv6 addr\n  */\n PR_IMPLEMENT(void)\n-PR_ConvertIPv4AddrToIPv6(PRUint32 v4addr, PRIPv6Addr* v6addr)\n-{\n-    PRUint8* dstp;\n-    dstp = v6addr->pr_s6_addr;\n-    memset(dstp, 0, 10);\n-    memset(dstp + 10, 0xff, 2);\n-    memcpy(dstp + 12, (char*)&v4addr, 4);\n+PR_ConvertIPv4AddrToIPv6(PRUint32 v4addr, PRIPv6Addr* v6addr) {\n+  PRUint8* dstp;\n+  dstp = v6addr->pr_s6_addr;\n+  memset(dstp, 0, 10);\n+  memset(dstp + 10, 0xff, 2);\n+  memcpy(dstp + 12, (char*)&v4addr, 4);\n }\n \n-PR_IMPLEMENT(PRUint16)\n-PR_ntohs(PRUint16 n) { return ntohs(n); }\n-PR_IMPLEMENT(PRUint32)\n-PR_ntohl(PRUint32 n) { return ntohl(n); }\n-PR_IMPLEMENT(PRUint16)\n-PR_htons(PRUint16 n) { return htons(n); }\n-PR_IMPLEMENT(PRUint32)\n-PR_htonl(PRUint32 n) { return htonl(n); }\n-PR_IMPLEMENT(PRUint64)\n-PR_ntohll(PRUint64 n)\n-{\n+PR_IMPLEMENT(PRUint16) PR_ntohs(PRUint16 n) { return ntohs(n); }\n+PR_IMPLEMENT(PRUint32) PR_ntohl(PRUint32 n) { return ntohl(n); }\n+PR_IMPLEMENT(PRUint16) PR_htons(PRUint16 n) { return htons(n); }\n+PR_IMPLEMENT(PRUint32) PR_htonl(PRUint32 n) { return htonl(n); }\n+PR_IMPLEMENT(PRUint64) PR_ntohll(PRUint64 n) {\n #ifdef IS_BIG_ENDIAN\n-    return n;\n+  return n;\n #else\n-    PRUint32 hi, lo;\n-    lo = (PRUint32)n;\n-    hi = (PRUint32)(n >> 32);\n-    hi = PR_ntohl(hi);\n-    lo = PR_ntohl(lo);\n-    return ((PRUint64)lo << 32) + (PRUint64)hi;\n+  PRUint32 hi, lo;\n+  lo = (PRUint32)n;\n+  hi = (PRUint32)(n >> 32);\n+  hi = PR_ntohl(hi);\n+  lo = PR_ntohl(lo);\n+  return ((PRUint64)lo << 32) + (PRUint64)hi;\n #endif\n } /* ntohll */\n \n-PR_IMPLEMENT(PRUint64)\n-PR_htonll(PRUint64 n)\n-{\n+PR_IMPLEMENT(PRUint64) PR_htonll(PRUint64 n) {\n #ifdef IS_BIG_ENDIAN\n-    return n;\n+  return n;\n #else\n-    PRUint32 hi, lo;\n-    lo = (PRUint32)n;\n-    hi = (PRUint32)(n >> 32);\n-    hi = htonl(hi);\n-    lo = htonl(lo);\n-    return ((PRUint64)lo << 32) + (PRUint64)hi;\n+  PRUint32 hi, lo;\n+  lo = (PRUint32)n;\n+  hi = (PRUint32)(n >> 32);\n+  hi = htonl(hi);\n+  lo = htonl(lo);\n+  return ((PRUint64)lo << 32) + (PRUint64)hi;\n #endif\n } /* htonll */\n \n@@ -2108,23 +1809,23 @@ PR_htonll(PRUint64 n)\n \n #if defined(_PR_HAVE_GETADDRINFO)\n \n-#if defined(_PR_INET6)\n+#  if defined(_PR_INET6)\n \n typedef struct addrinfo PRADDRINFO;\n-#define GETADDRINFO getaddrinfo\n-#define FREEADDRINFO freeaddrinfo\n-#define GETNAMEINFO getnameinfo\n+#    define GETADDRINFO getaddrinfo\n+#    define FREEADDRINFO freeaddrinfo\n+#    define GETNAMEINFO getnameinfo\n \n-#elif defined(_PR_INET6_PROBE)\n+#  elif defined(_PR_INET6_PROBE)\n \n typedef struct addrinfo PRADDRINFO;\n \n /* getaddrinfo/freeaddrinfo/getnameinfo prototypes */\n-#if defined(WIN32)\n-#define FUNC_MODIFIER __stdcall\n-#else\n-#define FUNC_MODIFIER\n-#endif\n+#    if defined(WIN32)\n+#      define FUNC_MODIFIER __stdcall\n+#    else\n+#      define FUNC_MODIFIER\n+#    endif\n typedef int(FUNC_MODIFIER* FN_GETADDRINFO)(const char* nodename,\n                                            const char* servname,\n                                            const PRADDRINFO* hints,\n@@ -2139,74 +1840,72 @@ static FN_GETADDRINFO _pr_getaddrinfo = NULL;\n static FN_FREEADDRINFO _pr_freeaddrinfo = NULL;\n static FN_GETNAMEINFO _pr_getnameinfo = NULL;\n \n-#define GETADDRINFO_SYMBOL \"getaddrinfo\"\n-#define FREEADDRINFO_SYMBOL \"freeaddrinfo\"\n-#define GETNAMEINFO_SYMBOL \"getnameinfo\"\n-\n-PRStatus\n-_pr_find_getaddrinfo(void)\n-{\n-    PRLibrary* lib;\n-#ifdef WIN32\n-    /*\n-     * On windows, we need to search ws2_32.dll or wship6.dll\n-     * (Microsoft IPv6 Technology Preview for Windows 2000) for\n-     * getaddrinfo and freeaddrinfo.  These libraries might not\n-     * be loaded yet.\n-     */\n-    const char* libname[] = { \"ws2_32.dll\", \"wship6.dll\" };\n-    int i;\n-\n-    for (i = 0; i < sizeof(libname) / sizeof(libname[0]); i++) {\n-        lib = PR_LoadLibrary(libname[i]);\n-        if (!lib) {\n-            continue;\n-        }\n-        _pr_getaddrinfo =\n-            (FN_GETADDRINFO)PR_FindFunctionSymbol(lib, GETADDRINFO_SYMBOL);\n-        if (!_pr_getaddrinfo) {\n-            PR_UnloadLibrary(lib);\n-            continue;\n-        }\n-        _pr_freeaddrinfo =\n-            (FN_FREEADDRINFO)PR_FindFunctionSymbol(lib, FREEADDRINFO_SYMBOL);\n-        _pr_getnameinfo =\n-            (FN_GETNAMEINFO)PR_FindFunctionSymbol(lib, GETNAMEINFO_SYMBOL);\n-        if (!_pr_freeaddrinfo || !_pr_getnameinfo) {\n-            PR_UnloadLibrary(lib);\n-            continue;\n-        }\n-        /* Keep the library loaded. */\n-        return PR_SUCCESS;\n+#    define GETADDRINFO_SYMBOL \"getaddrinfo\"\n+#    define FREEADDRINFO_SYMBOL \"freeaddrinfo\"\n+#    define GETNAMEINFO_SYMBOL \"getnameinfo\"\n+\n+PRStatus _pr_find_getaddrinfo(void) {\n+  PRLibrary* lib;\n+#    ifdef WIN32\n+  /*\n+   * On windows, we need to search ws2_32.dll or wship6.dll\n+   * (Microsoft IPv6 Technology Preview for Windows 2000) for\n+   * getaddrinfo and freeaddrinfo.  These libraries might not\n+   * be loaded yet.\n+   */\n+  const char* libname[] = {\"ws2_32.dll\", \"wship6.dll\"};\n+  int i;\n+\n+  for (i = 0; i < sizeof(libname) / sizeof(libname[0]); i++) {\n+    lib = PR_LoadLibrary(libname[i]);\n+    if (!lib) {\n+      continue;\n     }\n-    return PR_FAILURE;\n-#else\n-    /*\n-     * Resolve getaddrinfo by searching all loaded libraries.  Then\n-     * search library containing getaddrinfo for freeaddrinfo.\n-     */\n     _pr_getaddrinfo =\n-        (FN_GETADDRINFO)PR_FindFunctionSymbolAndLibrary(GETADDRINFO_SYMBOL, &lib);\n+        (FN_GETADDRINFO)PR_FindFunctionSymbol(lib, GETADDRINFO_SYMBOL);\n     if (!_pr_getaddrinfo) {\n-        return PR_FAILURE;\n+      PR_UnloadLibrary(lib);\n+      continue;\n     }\n     _pr_freeaddrinfo =\n         (FN_FREEADDRINFO)PR_FindFunctionSymbol(lib, FREEADDRINFO_SYMBOL);\n     _pr_getnameinfo =\n         (FN_GETNAMEINFO)PR_FindFunctionSymbol(lib, GETNAMEINFO_SYMBOL);\n-    PR_UnloadLibrary(lib);\n     if (!_pr_freeaddrinfo || !_pr_getnameinfo) {\n-        return PR_FAILURE;\n+      PR_UnloadLibrary(lib);\n+      continue;\n     }\n+    /* Keep the library loaded. */\n     return PR_SUCCESS;\n-#endif\n+  }\n+  return PR_FAILURE;\n+#    else\n+  /*\n+   * Resolve getaddrinfo by searching all loaded libraries.  Then\n+   * search library containing getaddrinfo for freeaddrinfo.\n+   */\n+  _pr_getaddrinfo =\n+      (FN_GETADDRINFO)PR_FindFunctionSymbolAndLibrary(GETADDRINFO_SYMBOL, &lib);\n+  if (!_pr_getaddrinfo) {\n+    return PR_FAILURE;\n+  }\n+  _pr_freeaddrinfo =\n+      (FN_FREEADDRINFO)PR_FindFunctionSymbol(lib, FREEADDRINFO_SYMBOL);\n+  _pr_getnameinfo =\n+      (FN_GETNAMEINFO)PR_FindFunctionSymbol(lib, GETNAMEINFO_SYMBOL);\n+  PR_UnloadLibrary(lib);\n+  if (!_pr_freeaddrinfo || !_pr_getnameinfo) {\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n+#    endif\n }\n \n-#define GETADDRINFO (*_pr_getaddrinfo)\n-#define FREEADDRINFO (*_pr_freeaddrinfo)\n-#define GETNAMEINFO (*_pr_getnameinfo)\n+#    define GETADDRINFO (*_pr_getaddrinfo)\n+#    define FREEADDRINFO (*_pr_freeaddrinfo)\n+#    define GETNAMEINFO (*_pr_getnameinfo)\n \n-#endif /* _PR_INET6 */\n+#  endif /* _PR_INET6 */\n \n #endif /* _PR_HAVE_GETADDRINFO */\n \n@@ -2217,484 +1916,453 @@ _pr_find_getaddrinfo(void)\n  * PRHostEnt data structure and its members.\n  */\n typedef struct PRAddrInfoFB {\n-    char buf[PR_NETDB_BUF_SIZE];\n-    PRHostEnt hostent;\n-    PRBool has_cname;\n+  char buf[PR_NETDB_BUF_SIZE];\n+  PRHostEnt hostent;\n+  PRBool has_cname;\n } PRAddrInfoFB;\n \n-static PRAddrInfo*\n-pr_GetAddrInfoByNameFB(const char* hostname, PRUint16 af,\n-                       PRIntn flags)\n-{\n-    PRStatus rv;\n-    PRAddrInfoFB* ai;\n-    /* fallback on PR_GetHostByName */\n-    ai = PR_NEW(PRAddrInfoFB);\n-    if (!ai) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n-    }\n-    rv = PR_GetHostByName(hostname, ai->buf, sizeof ai->buf, &ai->hostent);\n-    if (rv == PR_FAILURE) {\n-        PR_Free(ai);\n-        return NULL;\n-    }\n-    ai->has_cname = !(flags & PR_AI_NOCANONNAME);\n-\n-    return (PRAddrInfo*)ai;\n+static PRAddrInfo* pr_GetAddrInfoByNameFB(const char* hostname, PRUint16 af,\n+                                          PRIntn flags) {\n+  PRStatus rv;\n+  PRAddrInfoFB* ai;\n+  /* fallback on PR_GetHostByName */\n+  ai = PR_NEW(PRAddrInfoFB);\n+  if (!ai) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n+  rv = PR_GetHostByName(hostname, ai->buf, sizeof ai->buf, &ai->hostent);\n+  if (rv == PR_FAILURE) {\n+    PR_Free(ai);\n+    return NULL;\n+  }\n+  ai->has_cname = !(flags & PR_AI_NOCANONNAME);\n+\n+  return (PRAddrInfo*)ai;\n }\n #endif /* !_PR_HAVE_GETADDRINFO || _PR_INET6_PROBE */\n \n PR_IMPLEMENT(PRAddrInfo*)\n-PR_GetAddrInfoByName(const char* hostname, PRUint16 af, PRIntn flags)\n-{\n-    /* restrict input to supported values */\n-    if ((af != PR_AF_INET && af != PR_AF_UNSPEC) ||\n-        (flags & ~PR_AI_NOCANONNAME) != PR_AI_ADDRCONFIG) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return NULL;\n-    }\n+PR_GetAddrInfoByName(const char* hostname, PRUint16 af, PRIntn flags) {\n+  /* restrict input to supported values */\n+  if ((af != PR_AF_INET && af != PR_AF_UNSPEC) ||\n+      (flags & ~PR_AI_NOCANONNAME) != PR_AI_ADDRCONFIG) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return NULL;\n+  }\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n #if !defined(_PR_HAVE_GETADDRINFO)\n-    return pr_GetAddrInfoByNameFB(hostname, af, flags);\n+  return pr_GetAddrInfoByNameFB(hostname, af, flags);\n #else\n-#if defined(_PR_INET6_PROBE)\n-    if (!_pr_ipv6_is_present()) {\n-        return pr_GetAddrInfoByNameFB(hostname, af, flags);\n+#  if defined(_PR_INET6_PROBE)\n+  if (!_pr_ipv6_is_present()) {\n+    return pr_GetAddrInfoByNameFB(hostname, af, flags);\n+  }\n+#  endif\n+  {\n+    PRADDRINFO *res, hints;\n+    int rv;\n+\n+    /*\n+     * we assume a RFC 2553 compliant getaddrinfo.  this may at some\n+     * point need to be customized as platforms begin to adopt the\n+     * RFC 3493.\n+     */\n+\n+    memset(&hints, 0, sizeof(hints));\n+    if (!(flags & PR_AI_NOCANONNAME)) {\n+      hints.ai_flags |= AI_CANONNAME;\n     }\n-#endif\n-    {\n-        PRADDRINFO *res, hints;\n-        int rv;\n-\n-        /*\n-         * we assume a RFC 2553 compliant getaddrinfo.  this may at some\n-         * point need to be customized as platforms begin to adopt the\n-         * RFC 3493.\n-         */\n-\n-        memset(&hints, 0, sizeof(hints));\n-        if (!(flags & PR_AI_NOCANONNAME)) {\n-            hints.ai_flags |= AI_CANONNAME;\n-        }\n-#ifdef AI_ADDRCONFIG\n-        /*\n-         * Propagate AI_ADDRCONFIG to the GETADDRINFO call if PR_AI_ADDRCONFIG\n-         * is set.\n-         *\n-         * Need a workaround for loopback host addresses:\n-         * The problem is that in glibc and Windows, AI_ADDRCONFIG applies the\n-         * existence of an outgoing network interface to IP addresses of the\n-         * loopback interface, due to a strict interpretation of the\n-         * specification.  For example, if a computer does not have any\n-         * outgoing IPv6 network interface, but its loopback network interface\n-         * supports IPv6, a getaddrinfo call on \"localhost\" with AI_ADDRCONFIG\n-         * won't return the IPv6 loopback address \"::1\", because getaddrinfo\n-         * thinks the computer cannot connect to any IPv6 destination,\n-         * ignoring the remote vs. local/loopback distinction.\n-         */\n-        if ((flags & PR_AI_ADDRCONFIG) && strcmp(hostname, \"localhost\") != 0 &&\n-            strcmp(hostname, \"localhost.localdomain\") != 0 &&\n-            strcmp(hostname, \"localhost6\") != 0 &&\n-            strcmp(hostname, \"localhost6.localdomain6\") != 0) {\n-            hints.ai_flags |= AI_ADDRCONFIG;\n-        }\n-#endif\n-        hints.ai_family = (af == PR_AF_INET) ? AF_INET : AF_UNSPEC;\n-\n-        /*\n-         * it is important to select a socket type in the hints, otherwise we\n-         * will get back repetitive entries: one for each socket type.  since\n-         * we do not expose ai_socktype through our API, it is okay to do this\n-         * here.  the application may still choose to create a socket of some\n-         * other type.\n-         */\n-        hints.ai_socktype = SOCK_STREAM;\n-\n-        rv = GETADDRINFO(hostname, NULL, &hints, &res);\n-#ifdef AI_ADDRCONFIG\n-        if (rv == EAI_BADFLAGS && (hints.ai_flags & AI_ADDRCONFIG)) {\n-            hints.ai_flags &= ~AI_ADDRCONFIG;\n-            rv = GETADDRINFO(hostname, NULL, &hints, &res);\n-        }\n-#endif\n-        if (rv == 0) {\n-            return (PRAddrInfo*)res;\n-        }\n+#  ifdef AI_ADDRCONFIG\n+    /*\n+     * Propagate AI_ADDRCONFIG to the GETADDRINFO call if PR_AI_ADDRCONFIG\n+     * is set.\n+     *\n+     * Need a workaround for loopback host addresses:\n+     * The problem is that in glibc and Windows, AI_ADDRCONFIG applies the\n+     * existence of an outgoing network interface to IP addresses of the\n+     * loopback interface, due to a strict interpretation of the\n+     * specification.  For example, if a computer does not have any\n+     * outgoing IPv6 network interface, but its loopback network interface\n+     * supports IPv6, a getaddrinfo call on \"localhost\" with AI_ADDRCONFIG\n+     * won't return the IPv6 loopback address \"::1\", because getaddrinfo\n+     * thinks the computer cannot connect to any IPv6 destination,\n+     * ignoring the remote vs. local/loopback distinction.\n+     */\n+    if ((flags & PR_AI_ADDRCONFIG) && strcmp(hostname, \"localhost\") != 0 &&\n+        strcmp(hostname, \"localhost.localdomain\") != 0 &&\n+        strcmp(hostname, \"localhost6\") != 0 &&\n+        strcmp(hostname, \"localhost6.localdomain6\") != 0) {\n+      hints.ai_flags |= AI_ADDRCONFIG;\n+    }\n+#  endif\n+    hints.ai_family = (af == PR_AF_INET) ? AF_INET : AF_UNSPEC;\n+\n+    /*\n+     * it is important to select a socket type in the hints, otherwise we\n+     * will get back repetitive entries: one for each socket type.  since\n+     * we do not expose ai_socktype through our API, it is okay to do this\n+     * here.  the application may still choose to create a socket of some\n+     * other type.\n+     */\n+    hints.ai_socktype = SOCK_STREAM;\n \n-        PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, rv);\n+    rv = GETADDRINFO(hostname, NULL, &hints, &res);\n+#  ifdef AI_ADDRCONFIG\n+    if (rv == EAI_BADFLAGS && (hints.ai_flags & AI_ADDRCONFIG)) {\n+      hints.ai_flags &= ~AI_ADDRCONFIG;\n+      rv = GETADDRINFO(hostname, NULL, &hints, &res);\n     }\n-    return NULL;\n+#  endif\n+    if (rv == 0) {\n+      return (PRAddrInfo*)res;\n+    }\n+\n+    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, rv);\n+  }\n+  return NULL;\n #endif\n }\n \n PR_IMPLEMENT(PRStatus)\n-PR_GetPrefLoopbackAddrInfo(PRNetAddr* result, PRUint16 port)\n-{\n-    char tmpBuf[40];\n-    const int tmpBufSize = sizeof(tmpBuf);\n+PR_GetPrefLoopbackAddrInfo(PRNetAddr* result, PRUint16 port) {\n+  char tmpBuf[40];\n+  const int tmpBufSize = sizeof(tmpBuf);\n \n-    if (!result) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (!result) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-    if (!_pr_initialized)\n-        _PR_ImplicitInitialization();\n+  if (!_pr_initialized) _PR_ImplicitInitialization();\n \n-    PR_snprintf(tmpBuf, tmpBufSize, \"%u\", port);\n+  PR_snprintf(tmpBuf, tmpBufSize, \"%u\", port);\n \n #if !defined(_PR_HAVE_GETADDRINFO) || !defined(AI_PASSIVE)\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n #else\n \n-    PRADDRINFO *res, hints;\n-    PRStatus rv;\n+  PRADDRINFO *res, hints;\n+  PRStatus rv;\n \n-    memset(&hints, 0, sizeof(hints));\n+  memset(&hints, 0, sizeof(hints));\n \n-    rv = GETADDRINFO(NULL, tmpBuf, &hints, &res);\n-    if (rv == 0) {\n-        PRBool result_still_empty = PR_TRUE;\n-        PRADDRINFO* ai;\n-\n-        for (ai = res; ai != NULL; ai = ai->ai_next) {\n-            PRNetAddr aNetAddr;\n-\n-            /* Skip anything that doesn't fit in a PRNetAddr. */\n-            if (ai->ai_addrlen > sizeof(PRNetAddr)) {\n-                continue;\n-            }\n-\n-            /*\n-             * Copy sockaddr to PRNetAddr, zero-filling the tail: the\n-             * sockaddr is usually much smaller than a PRNetAddr, and the\n-             * remaining bytes must not be left uninitialized.\n-             */\n-            memset(&aNetAddr, 0, sizeof(aNetAddr));\n-            memcpy(&aNetAddr, ai->ai_addr, ai->ai_addrlen);\n-            aNetAddr.raw.family = ai->ai_addr->sa_family;\n-#ifdef _PR_INET6\n-            if (AF_INET6 == aNetAddr.raw.family) {\n-                aNetAddr.raw.family = PR_AF_INET6;\n-            }\n-#endif\n+  rv = GETADDRINFO(NULL, tmpBuf, &hints, &res);\n+  if (rv == 0) {\n+    PRBool result_still_empty = PR_TRUE;\n+    PRADDRINFO* ai = res;\n+    do {\n+      PRNetAddr aNetAddr;\n \n-            /* If we obtain more than one result, prefer IPv6. */\n-            if (result_still_empty || aNetAddr.raw.family == PR_AF_INET6) {\n-                memcpy(result, &aNetAddr, sizeof(PRNetAddr));\n-                result_still_empty = PR_FALSE;\n-            }\n-        }\n+      while (ai && ai->ai_addrlen > sizeof(PRNetAddr)) ai = ai->ai_next;\n \n-        FREEADDRINFO(res);\n+      if (ai) {\n+        /* copy sockaddr to PRNetAddr */\n+        memcpy(&aNetAddr, ai->ai_addr, ai->ai_addrlen);\n+        aNetAddr.raw.family = ai->ai_addr->sa_family;\n+#  ifdef _PR_INET6\n+        if (AF_INET6 == aNetAddr.raw.family) aNetAddr.raw.family = PR_AF_INET6;\n+#  endif\n+        if (ai->ai_addrlen < sizeof(PRNetAddr))\n+          memset(((char*)result) + ai->ai_addrlen, 0,\n+                 sizeof(PRNetAddr) - ai->ai_addrlen);\n+      }\n+\n+      /* If we obtain more than one result, prefer IPv6. */\n+      if (result_still_empty || aNetAddr.raw.family == PR_AF_INET6) {\n+        memcpy(result, &aNetAddr, sizeof(PRNetAddr));\n+      }\n+      result_still_empty = PR_FALSE;\n+      ai = ai->ai_next;\n+    } while (ai);\n \n-        if (result_still_empty) {\n-            PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);\n-            return PR_FAILURE;\n-        }\n-        return PR_SUCCESS;\n-    }\n+    FREEADDRINFO(res);\n+    return PR_SUCCESS;\n+  }\n \n-    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, rv);\n-    return PR_FAILURE;\n+  PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, rv);\n+  return PR_FAILURE;\n #endif\n }\n \n-PR_IMPLEMENT(void)\n-PR_FreeAddrInfo(PRAddrInfo* ai)\n-{\n+PR_IMPLEMENT(void) PR_FreeAddrInfo(PRAddrInfo* ai) {\n #if defined(_PR_HAVE_GETADDRINFO)\n-#if defined(_PR_INET6_PROBE)\n-    if (!_pr_ipv6_is_present()) {\n-        PR_Free((PRAddrInfoFB*)ai);\n-    } else\n-#endif\n-        FREEADDRINFO((PRADDRINFO*)ai);\n-#else\n+#  if defined(_PR_INET6_PROBE)\n+  if (!_pr_ipv6_is_present()) {\n     PR_Free((PRAddrInfoFB*)ai);\n+  } else\n+#  endif\n+    FREEADDRINFO((PRADDRINFO*)ai);\n+#else\n+  PR_Free((PRAddrInfoFB*)ai);\n #endif\n }\n \n PR_IMPLEMENT(void*)\n PR_EnumerateAddrInfo(void* iterPtr, const PRAddrInfo* base, PRUint16 port,\n-                     PRNetAddr* result)\n-{\n+                     PRNetAddr* result) {\n #if defined(_PR_HAVE_GETADDRINFO)\n-    PRADDRINFO* ai;\n-#if defined(_PR_INET6_PROBE)\n-    if (!_pr_ipv6_is_present()) {\n-        /* using PRAddrInfoFB */\n-        PRIntn iter = (PRIntn)(PRPtrdiff)iterPtr;\n-        iter = PR_EnumerateHostEnt(iter, &((PRAddrInfoFB*)base)->hostent, port,\n-                                   result);\n-        if (iter < 0) {\n-            iter = 0;\n-        }\n-        return (void*)(PRPtrdiff)iter;\n-    }\n-#endif\n-\n-    if (iterPtr) {\n-        ai = ((PRADDRINFO*)iterPtr)->ai_next;\n+  PRADDRINFO* ai;\n+#  if defined(_PR_INET6_PROBE)\n+  if (!_pr_ipv6_is_present()) {\n+    /* using PRAddrInfoFB */\n+    PRIntn iter = (PRIntn)(PRPtrdiff)iterPtr;\n+    iter = PR_EnumerateHostEnt(iter, &((PRAddrInfoFB*)base)->hostent, port,\n+                               result);\n+    if (iter < 0) {\n+      iter = 0;\n+    }\n+    return (void*)(PRPtrdiff)iter;\n+  }\n+#  endif\n+\n+  if (iterPtr) {\n+    ai = ((PRADDRINFO*)iterPtr)->ai_next;\n+  } else {\n+    ai = (PRADDRINFO*)base;\n+  }\n+\n+  while (ai && ai->ai_addrlen > sizeof(PRNetAddr)) {\n+    ai = ai->ai_next;\n+  }\n+\n+  if (ai) {\n+    /* copy sockaddr to PRNetAddr */\n+    memcpy(result, ai->ai_addr, ai->ai_addrlen);\n+    result->raw.family = ai->ai_addr->sa_family;\n+#  ifdef _PR_INET6\n+    if (AF_INET6 == result->raw.family) {\n+      result->raw.family = PR_AF_INET6;\n+    }\n+#  endif\n+    if (ai->ai_addrlen < sizeof(PRNetAddr)) {\n+      memset(((char*)result) + ai->ai_addrlen, 0,\n+             sizeof(PRNetAddr) - ai->ai_addrlen);\n+    }\n+\n+    if (result->raw.family == PR_AF_INET) {\n+      result->inet.port = htons(port);\n     } else {\n-        ai = (PRADDRINFO*)base;\n+      result->ipv6.port = htons(port);\n     }\n+  }\n \n-    while (ai && ai->ai_addrlen > sizeof(PRNetAddr)) {\n-        ai = ai->ai_next;\n-    }\n-\n-    if (ai) {\n-        /* copy sockaddr to PRNetAddr */\n-        memcpy(result, ai->ai_addr, ai->ai_addrlen);\n-        result->raw.family = ai->ai_addr->sa_family;\n-#ifdef _PR_INET6\n-        if (AF_INET6 == result->raw.family) {\n-            result->raw.family = PR_AF_INET6;\n-        }\n-#endif\n-        if (ai->ai_addrlen < sizeof(PRNetAddr)) {\n-            memset(((char*)result) + ai->ai_addrlen, 0,\n-                   sizeof(PRNetAddr) - ai->ai_addrlen);\n-        }\n-\n-        if (result->raw.family == PR_AF_INET) {\n-            result->inet.port = htons(port);\n-        } else {\n-            result->ipv6.port = htons(port);\n-        }\n-    }\n-\n-    return ai;\n+  return ai;\n #else\n-    /* using PRAddrInfoFB */\n-    PRIntn iter = (PRIntn)iterPtr;\n-    iter =\n-        PR_EnumerateHostEnt(iter, &((PRAddrInfoFB*)base)->hostent, port, result);\n-    if (iter < 0) {\n-        iter = 0;\n-    }\n-    return (void*)iter;\n+  /* using PRAddrInfoFB */\n+  PRIntn iter = (PRIntn)iterPtr;\n+  iter =\n+      PR_EnumerateHostEnt(iter, &((PRAddrInfoFB*)base)->hostent, port, result);\n+  if (iter < 0) {\n+    iter = 0;\n+  }\n+  return (void*)iter;\n #endif\n }\n \n-PR_IMPLEMENT(const char*)\n-PR_GetCanonNameFromAddrInfo(const PRAddrInfo* ai)\n-{\n+PR_IMPLEMENT(const char*) PR_GetCanonNameFromAddrInfo(const PRAddrInfo* ai) {\n #if defined(_PR_HAVE_GETADDRINFO)\n-#if defined(_PR_INET6_PROBE)\n-    if (!_pr_ipv6_is_present()) {\n-        const PRAddrInfoFB* fb = (const PRAddrInfoFB*)ai;\n-        return fb->has_cname ? fb->hostent.h_name : NULL;\n-    }\n-#endif\n-    return ((const PRADDRINFO*)ai)->ai_canonname;\n-#else\n+#  if defined(_PR_INET6_PROBE)\n+  if (!_pr_ipv6_is_present()) {\n     const PRAddrInfoFB* fb = (const PRAddrInfoFB*)ai;\n     return fb->has_cname ? fb->hostent.h_name : NULL;\n+  }\n+#  endif\n+  return ((const PRADDRINFO*)ai)->ai_canonname;\n+#else\n+  const PRAddrInfoFB* fb = (const PRAddrInfoFB*)ai;\n+  return fb->has_cname ? fb->hostent.h_name : NULL;\n #endif\n }\n \n #if defined(_PR_HAVE_GETADDRINFO)\n-static PRStatus\n-pr_StringToNetAddrGAI(const char* string, PRNetAddr* addr)\n-{\n-    PRADDRINFO *res, hints;\n-    int rv; /* 0 for success, or the error code EAI_xxx */\n-    PRNetAddr laddr;\n-    PRStatus status = PR_SUCCESS;\n-\n-    memset(&hints, 0, sizeof(hints));\n-    hints.ai_flags = AI_NUMERICHOST;\n-    hints.ai_family = AF_UNSPEC;\n-    hints.ai_socktype = SOCK_STREAM;\n-\n-    rv = GETADDRINFO(string, NULL, &hints, &res);\n-    if (rv != 0) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, rv);\n-        return PR_FAILURE;\n-    }\n-\n-    /* pick up the first addr */\n-    memcpy(&laddr, res->ai_addr, res->ai_addrlen);\n-    if (AF_INET6 == res->ai_addr->sa_family) {\n-        addr->ipv6.family = PR_AF_INET6;\n-        addr->ipv6.ip = laddr.ipv6.ip;\n-        addr->ipv6.scope_id = laddr.ipv6.scope_id;\n-    } else if (AF_INET == res->ai_addr->sa_family) {\n-        addr->inet.family = PR_AF_INET;\n-        addr->inet.ip = laddr.inet.ip;\n-    } else {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        status = PR_FAILURE;\n-    }\n+static PRStatus pr_StringToNetAddrGAI(const char* string, PRNetAddr* addr) {\n+  PRADDRINFO *res, hints;\n+  int rv; /* 0 for success, or the error code EAI_xxx */\n+  PRNetAddr laddr;\n+  PRStatus status = PR_SUCCESS;\n+\n+  memset(&hints, 0, sizeof(hints));\n+  hints.ai_flags = AI_NUMERICHOST;\n+  hints.ai_family = AF_UNSPEC;\n+  hints.ai_socktype = SOCK_STREAM;\n+\n+  rv = GETADDRINFO(string, NULL, &hints, &res);\n+  if (rv != 0) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, rv);\n+    return PR_FAILURE;\n+  }\n+\n+  /* pick up the first addr */\n+  memcpy(&laddr, res->ai_addr, res->ai_addrlen);\n+  if (AF_INET6 == res->ai_addr->sa_family) {\n+    addr->ipv6.family = PR_AF_INET6;\n+    addr->ipv6.ip = laddr.ipv6.ip;\n+    addr->ipv6.scope_id = laddr.ipv6.scope_id;\n+  } else if (AF_INET == res->ai_addr->sa_family) {\n+    addr->inet.family = PR_AF_INET;\n+    addr->inet.ip = laddr.inet.ip;\n+  } else {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    status = PR_FAILURE;\n+  }\n \n-    FREEADDRINFO(res);\n-    return status;\n+  FREEADDRINFO(res);\n+  return status;\n }\n #endif /* _PR_HAVE_GETADDRINFO */\n \n-static PRStatus\n-pr_StringToNetAddrFB(const char* string, PRNetAddr* addr)\n-{\n-    PRIntn rv;\n+static PRStatus pr_StringToNetAddrFB(const char* string, PRNetAddr* addr) {\n+  PRIntn rv;\n \n-    rv = pr_inet_aton(string, &addr->inet.ip);\n-    if (1 == rv) {\n-        addr->raw.family = AF_INET;\n-        return PR_SUCCESS;\n-    }\n+  rv = pr_inet_aton(string, &addr->inet.ip);\n+  if (1 == rv) {\n+    addr->raw.family = AF_INET;\n+    return PR_SUCCESS;\n+  }\n \n-    PR_ASSERT(0 == rv);\n-    /* clean up after the failed call */\n-    memset(&addr->inet.ip, 0, sizeof(addr->inet.ip));\n+  PR_ASSERT(0 == rv);\n+  /* clean up after the failed call */\n+  memset(&addr->inet.ip, 0, sizeof(addr->inet.ip));\n \n-    rv = StringToV6Addr(string, &addr->ipv6.ip);\n-    if (1 == rv) {\n-        addr->raw.family = PR_AF_INET6;\n-        return PR_SUCCESS;\n-    }\n+  rv = StringToV6Addr(string, &addr->ipv6.ip);\n+  if (1 == rv) {\n+    addr->raw.family = PR_AF_INET6;\n+    return PR_SUCCESS;\n+  }\n \n-    PR_ASSERT(0 == rv);\n-    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-    return PR_FAILURE;\n+  PR_ASSERT(0 == rv);\n+  PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  return PR_FAILURE;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_StringToNetAddr(const char* string, PRNetAddr* addr)\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+PR_IMPLEMENT(PRStatus) PR_StringToNetAddr(const char* string, PRNetAddr* addr) {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    if (!addr || !string || !*string) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (!addr || !string || !*string) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n #if !defined(_PR_HAVE_GETADDRINFO)\n-    return pr_StringToNetAddrFB(string, addr);\n+  return pr_StringToNetAddrFB(string, addr);\n #else\n-    /*\n-     * getaddrinfo with AI_NUMERICHOST is much slower than pr_inet_aton on some\n-     * platforms, such as Mac OS X (bug 404399), Linux glibc 2.10 (bug 344809),\n-     * and most likely others. So we only use it to convert literal IP addresses\n-     * that contain IPv6 scope IDs, which pr_inet_aton cannot convert.\n-     */\n-    if (!strchr(string, '%')) {\n-        return pr_StringToNetAddrFB(string, addr);\n-    }\n+  /*\n+   * getaddrinfo with AI_NUMERICHOST is much slower than pr_inet_aton on some\n+   * platforms, such as Mac OS X (bug 404399), Linux glibc 2.10 (bug 344809),\n+   * and most likely others. So we only use it to convert literal IP addresses\n+   * that contain IPv6 scope IDs, which pr_inet_aton cannot convert.\n+   */\n+  if (!strchr(string, '%')) {\n+    return pr_StringToNetAddrFB(string, addr);\n+  }\n \n-#if defined(_PR_INET6_PROBE)\n-    if (!_pr_ipv6_is_present()) {\n-        return pr_StringToNetAddrFB(string, addr);\n-    }\n-#endif\n+#  if defined(_PR_INET6_PROBE)\n+  if (!_pr_ipv6_is_present()) {\n+    return pr_StringToNetAddrFB(string, addr);\n+  }\n+#  endif\n \n-    return pr_StringToNetAddrGAI(string, addr);\n+  return pr_StringToNetAddrGAI(string, addr);\n #endif\n }\n \n #if defined(_PR_HAVE_GETADDRINFO)\n-static PRStatus\n-pr_NetAddrToStringGNI(const PRNetAddr* addr, char* string,\n-                      PRUint32 size)\n-{\n-    int addrlen;\n-    const PRNetAddr* addrp = addr;\n-#if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)\n-    PRUint16 md_af = addr->raw.family;\n-    PRNetAddr addrcopy;\n-#endif\n-    int rv; /* 0 for success, or the error code EAI_xxx */\n-\n-#ifdef _PR_INET6\n-    if (addr->raw.family == PR_AF_INET6) {\n-        md_af = AF_INET6;\n-#ifndef _PR_HAVE_SOCKADDR_LEN\n-        addrcopy = *addr;\n-        addrcopy.raw.family = md_af;\n-        addrp = &addrcopy;\n-#endif\n-    }\n-#endif\n-\n-    addrlen = PR_NETADDR_SIZE(addr);\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n+static PRStatus pr_NetAddrToStringGNI(const PRNetAddr* addr, char* string,\n+                                      PRUint32 size) {\n+  int addrlen;\n+  const PRNetAddr* addrp = addr;\n+#  if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)\n+  PRUint16 md_af = addr->raw.family;\n+  PRNetAddr addrcopy;\n+#  endif\n+  int rv; /* 0 for success, or the error code EAI_xxx */\n+\n+#  ifdef _PR_INET6\n+  if (addr->raw.family == PR_AF_INET6) {\n+    md_af = AF_INET6;\n+#    ifndef _PR_HAVE_SOCKADDR_LEN\n     addrcopy = *addr;\n-    ((struct sockaddr*)&addrcopy)->sa_len = addrlen;\n-    ((struct sockaddr*)&addrcopy)->sa_family = md_af;\n+    addrcopy.raw.family = md_af;\n     addrp = &addrcopy;\n-#endif\n-    rv = GETNAMEINFO((const struct sockaddr*)addrp, addrlen, string, size, NULL,\n-                     0, NI_NUMERICHOST);\n-    if (rv != 0) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, rv);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+#    endif\n+  }\n+#  endif\n+\n+  addrlen = PR_NETADDR_SIZE(addr);\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  addrcopy = *addr;\n+  ((struct sockaddr*)&addrcopy)->sa_len = addrlen;\n+  ((struct sockaddr*)&addrcopy)->sa_family = md_af;\n+  addrp = &addrcopy;\n+#  endif\n+  rv = GETNAMEINFO((const struct sockaddr*)addrp, addrlen, string, size, NULL,\n+                   0, NI_NUMERICHOST);\n+  if (rv != 0) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, rv);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n #endif /* _PR_HAVE_GETADDRINFO */\n \n #if !defined(_PR_HAVE_GETADDRINFO) || defined(_PR_INET6_PROBE)\n-static PRStatus\n-pr_NetAddrToStringFB(const PRNetAddr* addr, char* string,\n-                     PRUint32 size)\n-{\n-    if (PR_AF_INET6 == addr->raw.family) {\n-#if defined(_PR_HAVE_INET_NTOP)\n-        if (NULL == inet_ntop(AF_INET6, &addr->ipv6.ip, string, size))\n-#else\n-        if (NULL == V6AddrToString(&addr->ipv6.ip, string, size))\n-#endif\n-        {\n-            /* the size of the result buffer is inadequate */\n-            PR_SetError(PR_BUFFER_OVERFLOW_ERROR, 0);\n-            return PR_FAILURE;\n-        }\n+static PRStatus pr_NetAddrToStringFB(const PRNetAddr* addr, char* string,\n+                                     PRUint32 size) {\n+  if (PR_AF_INET6 == addr->raw.family) {\n+#  if defined(_PR_HAVE_INET_NTOP)\n+    if (NULL == inet_ntop(AF_INET6, &addr->ipv6.ip, string, size))\n+#  else\n+    if (NULL == V6AddrToString(&addr->ipv6.ip, string, size))\n+#  endif\n+    {\n+      /* the size of the result buffer is inadequate */\n+      PR_SetError(PR_BUFFER_OVERFLOW_ERROR, 0);\n+      return PR_FAILURE;\n+    }\n+  } else {\n+    if (size < 16) {\n+      goto failed;\n+    }\n+    if (AF_INET != addr->raw.family) {\n+      goto failed;\n     } else {\n-        if (size < 16) {\n-            goto failed;\n-        }\n-        if (AF_INET != addr->raw.family) {\n-            goto failed;\n-        } else {\n-            unsigned char* byte = (unsigned char*)&addr->inet.ip;\n-            PR_snprintf(string, size, \"%u.%u.%u.%u\", byte[0], byte[1], byte[2],\n-                        byte[3]);\n-        }\n+      unsigned char* byte = (unsigned char*)&addr->inet.ip;\n+      PR_snprintf(string, size, \"%u.%u.%u.%u\", byte[0], byte[1], byte[2],\n+                  byte[3]);\n     }\n+  }\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n \n failed:\n-    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-    return PR_FAILURE;\n+  PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  return PR_FAILURE;\n \n } /* pr_NetAddrToStringFB */\n #endif /* !_PR_HAVE_GETADDRINFO || _PR_INET6_PROBE */\n \n PR_IMPLEMENT(PRStatus)\n-PR_NetAddrToString(const PRNetAddr* addr, char* string, PRUint32 size)\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+PR_NetAddrToString(const PRNetAddr* addr, char* string, PRUint32 size) {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n #if !defined(_PR_HAVE_GETADDRINFO)\n-    return pr_NetAddrToStringFB(addr, string, size);\n+  return pr_NetAddrToStringFB(addr, string, size);\n #else\n-#if defined(_PR_INET6_PROBE)\n-    if (!_pr_ipv6_is_present()) {\n-        return pr_NetAddrToStringFB(addr, string, size);\n-    }\n-#endif\n-    return pr_NetAddrToStringGNI(addr, string, size);\n+#  if defined(_PR_INET6_PROBE)\n+  if (!_pr_ipv6_is_present()) {\n+    return pr_NetAddrToStringFB(addr, string, size);\n+  }\n+#  endif\n+  return pr_NetAddrToStringGNI(addr, string, size);\n #endif\n } /* PR_NetAddrToString */\ndiff --git a/nspr/pr/src/misc/prolock.c b/nspr/pr/src/misc/prolock.c\nindex 6efa59c..e2646e8 100644\n--- a/nspr/pr/src/misc/prolock.c\n+++ b/nspr/pr/src/misc/prolock.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -13,31 +14,27 @@\n #include \"prerror.h\"\n \n PR_IMPLEMENT(PROrderedLock*)\n-PR_CreateOrderedLock(PRInt32 order, const char* name)\n-{\n-    PR_NOT_REACHED(\"Not implemented\"); /* Not implemented yet */\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return NULL;\n+PR_CreateOrderedLock(PRInt32 order, const char* name) {\n+  PR_NOT_REACHED(\"Not implemented\"); /* Not implemented yet */\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return NULL;\n } /*  end PR_CreateOrderedLock() */\n \n PR_IMPLEMENT(void)\n-PR_DestroyOrderedLock(PROrderedLock* lock)\n-{\n-    PR_NOT_REACHED(\"Not implemented\"); /* Not implemented yet */\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+PR_DestroyOrderedLock(PROrderedLock* lock) {\n+  PR_NOT_REACHED(\"Not implemented\"); /* Not implemented yet */\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n } /*  end PR_DestroyOrderedLock() */\n \n PR_IMPLEMENT(void)\n-PR_LockOrderedLock(PROrderedLock* lock)\n-{\n-    PR_NOT_REACHED(\"Not implemented\"); /* Not implemented yet */\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+PR_LockOrderedLock(PROrderedLock* lock) {\n+  PR_NOT_REACHED(\"Not implemented\"); /* Not implemented yet */\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n } /*  end PR_LockOrderedLock() */\n \n PR_IMPLEMENT(PRStatus)\n-PR_UnlockOrderedLock(PROrderedLock* lock)\n-{\n-    PR_NOT_REACHED(\"Not implemented\"); /* Not implemented yet */\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+PR_UnlockOrderedLock(PROrderedLock* lock) {\n+  PR_NOT_REACHED(\"Not implemented\"); /* Not implemented yet */\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n } /*  end PR_UnlockOrderedLock() */\ndiff --git a/nspr/pr/src/misc/prrng.c b/nspr/pr/src/misc/prrng.c\nindex 154c593..37812be 100644\n--- a/nspr/pr/src/misc/prrng.c\n+++ b/nspr/pr/src/misc/prrng.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -12,27 +13,23 @@\n  * include <string.h> in optimized builds for AIX.  (bug 200561)\n  */\n #if !(defined(AIX) && !defined(DEBUG))\n-#include <string.h>\n+#  include <string.h>\n #endif\n \n-PRSize\n-_pr_CopyLowBits(void* dst, PRSize dstlen, void* src, PRSize srclen)\n-{\n-    if (srclen <= dstlen) {\n-        memcpy(dst, src, srclen);\n-        return srclen;\n-    }\n+PRSize _pr_CopyLowBits(void* dst, PRSize dstlen, void* src, PRSize srclen) {\n+  if (srclen <= dstlen) {\n+    memcpy(dst, src, srclen);\n+    return srclen;\n+  }\n #if defined IS_BIG_ENDIAN\n-    memcpy(dst, (char*)src + (srclen - dstlen), dstlen);\n+  memcpy(dst, (char*)src + (srclen - dstlen), dstlen);\n #else\n-    memcpy(dst, src, dstlen);\n+  memcpy(dst, src, dstlen);\n #endif\n-    return dstlen;\n+  return dstlen;\n }\n \n-PR_IMPLEMENT(PRSize)\n-PR_GetRandomNoise(void* buf, PRSize size)\n-{\n-    return (_PR_MD_GET_RANDOM_NOISE(buf, size));\n+PR_IMPLEMENT(PRSize) PR_GetRandomNoise(void* buf, PRSize size) {\n+  return (_PR_MD_GET_RANDOM_NOISE(buf, size));\n } /* end PR_GetRandomNoise() */\n /* end prrng.c */\ndiff --git a/nspr/pr/src/misc/prsystem.c b/nspr/pr/src/misc/prsystem.c\nindex 66ed10c..863af6b 100644\n--- a/nspr/pr/src/misc/prsystem.c\n+++ b/nspr/pr/src/misc/prsystem.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,139 +11,133 @@\n /* BSD-derived systems use sysctl() to get the number of processors */\n #if defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) || \\\n     defined(DRAGONFLY) || defined(DARWIN)\n-#define _PR_HAVE_SYSCTL\n-#include <sys/param.h>\n-#include <sys/sysctl.h>\n+#  define _PR_HAVE_SYSCTL\n+#  include <sys/param.h>\n+#  include <sys/sysctl.h>\n #endif\n \n #if defined(DARWIN)\n-#include <mach/mach_init.h>\n-#include <mach/mach_host.h>\n-#include <mach/mach_port.h>\n+#  include <mach/mach_init.h>\n+#  include <mach/mach_host.h>\n+#  include <mach/mach_port.h>\n #endif\n \n+\n #if defined(XP_UNIX)\n-#include <unistd.h>\n-#include <sys/utsname.h>\n+#  include <unistd.h>\n+#  include <sys/utsname.h>\n #endif\n \n #if defined(LINUX)\n-#include <string.h>\n-#include <ctype.h>\n-#define MAX_LINE 512\n+#  include <string.h>\n+#  include <ctype.h>\n+#  define MAX_LINE 512\n #endif\n \n #if defined(AIX)\n-#include <cf.h>\n-#include <sys/cfgodm.h>\n+#  include <cf.h>\n+#  include <sys/cfgodm.h>\n #endif\n \n-PR_IMPLEMENT(char)\n-PR_GetDirectorySeparator(void)\n-{\n-    return PR_DIRECTORY_SEPARATOR;\n+PR_IMPLEMENT(char) PR_GetDirectorySeparator(void) {\n+  return PR_DIRECTORY_SEPARATOR;\n } /* PR_GetDirectorySeparator */\n \n /*\n ** OBSOLETE -- the function name is misspelled.\n */\n-PR_IMPLEMENT(char)\n-PR_GetDirectorySepartor(void)\n-{\n+PR_IMPLEMENT(char) PR_GetDirectorySepartor(void) {\n #if defined(DEBUG)\n-    static PRBool warn = PR_TRUE;\n-    if (warn) {\n-        warn =\n-            _PR_Obsolete(\"PR_GetDirectorySepartor()\", \"PR_GetDirectorySeparator()\");\n-    }\n+  static PRBool warn = PR_TRUE;\n+  if (warn) {\n+    warn =\n+        _PR_Obsolete(\"PR_GetDirectorySepartor()\", \"PR_GetDirectorySeparator()\");\n+  }\n #endif\n-    return PR_GetDirectorySeparator();\n+  return PR_GetDirectorySeparator();\n } /* PR_GetDirectorySepartor */\n \n-PR_IMPLEMENT(char)\n-PR_GetPathSeparator(void)\n-{\n-    return PR_PATH_SEPARATOR;\n+PR_IMPLEMENT(char) PR_GetPathSeparator(void) {\n+  return PR_PATH_SEPARATOR;\n } /* PR_GetPathSeparator */\n \n PR_IMPLEMENT(PRStatus)\n-PR_GetSystemInfo(PRSysInfo cmd, char* buf, PRUint32 buflen)\n-{\n-    PRUintn len = 0;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    switch (cmd) {\n-        case PR_SI_HOSTNAME:\n-        case PR_SI_HOSTNAME_UNTRUNCATED:\n-            if (PR_FAILURE == _PR_MD_GETHOSTNAME(buf, (PRUintn)buflen)) {\n-                return PR_FAILURE;\n-            }\n-\n-            if (cmd == PR_SI_HOSTNAME_UNTRUNCATED) {\n-                break;\n-            }\n-            /*\n-             * On some platforms a system does not have a hostname and\n-             * its IP address is returned instead.   The following code\n-             * should be skipped on those platforms.\n-             */\n+PR_GetSystemInfo(PRSysInfo cmd, char* buf, PRUint32 buflen) {\n+  PRUintn len = 0;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  switch (cmd) {\n+    case PR_SI_HOSTNAME:\n+    case PR_SI_HOSTNAME_UNTRUNCATED:\n+      if (PR_FAILURE == _PR_MD_GETHOSTNAME(buf, (PRUintn)buflen)) {\n+        return PR_FAILURE;\n+      }\n+\n+      if (cmd == PR_SI_HOSTNAME_UNTRUNCATED) {\n+        break;\n+      }\n+      /*\n+       * On some platforms a system does not have a hostname and\n+       * its IP address is returned instead.   The following code\n+       * should be skipped on those platforms.\n+       */\n #ifndef _PR_GET_HOST_ADDR_AS_NAME\n-            /* Return the unqualified hostname */\n-            while (buf[len] && (len < buflen)) {\n-                if (buf[len] == '.') {\n-                    buf[len] = '\\0';\n-                    break;\n-                }\n-                len += 1;\n-            }\n+      /* Return the unqualified hostname */\n+      while (buf[len] && (len < buflen)) {\n+        if (buf[len] == '.') {\n+          buf[len] = '\\0';\n+          break;\n+        }\n+        len += 1;\n+      }\n #endif\n-            break;\n+      break;\n \n-        case PR_SI_SYSNAME:\n-            /* Return the operating system name */\n+    case PR_SI_SYSNAME:\n+      /* Return the operating system name */\n #if defined(XP_UNIX) || defined(WIN32)\n-            if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen)) {\n-                return PR_FAILURE;\n-            }\n+      if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen)) {\n+        return PR_FAILURE;\n+      }\n #else\n-            (void)PR_snprintf(buf, buflen, _PR_SI_SYSNAME);\n+      (void)PR_snprintf(buf, buflen, _PR_SI_SYSNAME);\n #endif\n-            break;\n+      break;\n \n-        case PR_SI_RELEASE:\n-            /* Return the version of the operating system */\n+    case PR_SI_RELEASE:\n+      /* Return the version of the operating system */\n #if defined(XP_UNIX) || defined(WIN32)\n-            if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen)) {\n-                return PR_FAILURE;\n-            }\n+      if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen)) {\n+        return PR_FAILURE;\n+      }\n #endif\n-            break;\n+      break;\n \n-        case PR_SI_RELEASE_BUILD:\n-            /* Return the version of the operating system */\n+    case PR_SI_RELEASE_BUILD:\n+      /* Return the version of the operating system */\n #if defined(XP_UNIX) || defined(WIN32)\n-            if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen)) {\n-                return PR_FAILURE;\n-            }\n+      if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen)) {\n+        return PR_FAILURE;\n+      }\n #else\n-            if (buflen) {\n-                *buf = 0;\n-            }\n+      if (buflen) {\n+        *buf = 0;\n+      }\n #endif /* XP_UNIX || WIN32 */\n-            break;\n-\n-        case PR_SI_ARCHITECTURE:\n-            /* Return the architecture of the machine (ie. x86, mips, alpha, ...)*/\n-            (void)PR_snprintf(buf, buflen, _PR_SI_ARCHITECTURE);\n-            break;\n-        default:\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+      break;\n+\n+    case PR_SI_ARCHITECTURE:\n+      /* Return the architecture of the machine (ie. x86, mips, alpha, ...)*/\n+      (void)PR_snprintf(buf, buflen, _PR_SI_ARCHITECTURE);\n+      break;\n+    default:\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n /*\n@@ -159,72 +154,70 @@ PR_GetSystemInfo(PRSysInfo cmd, char* buf, PRUint32 buflen)\n **     specific implementations before XP_UNIX.\n **\n */\n-PR_IMPLEMENT(PRInt32)\n-PR_GetNumberOfProcessors(void)\n-{\n-    PRInt32 numCpus;\n+PR_IMPLEMENT(PRInt32) PR_GetNumberOfProcessors(void) {\n+  PRInt32 numCpus;\n #if defined(WIN32)\n-    SYSTEM_INFO info;\n+  SYSTEM_INFO info;\n \n-    GetSystemInfo(&info);\n-    numCpus = info.dwNumberOfProcessors;\n+  GetSystemInfo(&info);\n+  numCpus = info.dwNumberOfProcessors;\n #elif defined(_PR_HAVE_SYSCTL)\n-    int mib[2];\n-    int rc;\n-    size_t len = sizeof(numCpus);\n-\n-    mib[0] = CTL_HW;\n-#ifdef HW_NCPUONLINE\n-    mib[1] = HW_NCPUONLINE;\n-#else\n-    mib[1] = HW_NCPU;\n-#endif\n-    rc = sysctl(mib, 2, &numCpus, &len, NULL, 0);\n-    if (-1 == rc) {\n-        numCpus = -1; /* set to -1 for return value on error */\n-        _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO());\n-    }\n+  int mib[2];\n+  int rc;\n+  size_t len = sizeof(numCpus);\n+\n+  mib[0] = CTL_HW;\n+#  ifdef HW_NCPUONLINE\n+  mib[1] = HW_NCPUONLINE;\n+#  else\n+  mib[1] = HW_NCPU;\n+#  endif\n+  rc = sysctl(mib, 2, &numCpus, &len, NULL, 0);\n+  if (-1 == rc) {\n+    numCpus = -1; /* set to -1 for return value on error */\n+    _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO());\n+  }\n #elif defined(RISCOS)\n-    numCpus = 1;\n+  numCpus = 1;\n #elif defined(LINUX)\n-    /* for the benefit of devices with advanced power-saving, that\n-       actually hotplug their cpus in heavy load, try to figure out\n-       the real number of CPUs */\n-    char buf[MAX_LINE];\n-    FILE* fin;\n-    const char* cpu_present = \"/sys/devices/system/cpu/present\";\n-    size_t strsize;\n-    numCpus = 0;\n-    fin = fopen(cpu_present, \"r\");\n-    if (fin != NULL) {\n-        if (fgets(buf, MAX_LINE, fin) != NULL) {\n-            /* check that the format is what we expect */\n-            if (buf[0] == '0') {\n-                strsize = strlen(buf);\n-                if (strsize == 1) {\n-                    /* single core */\n-                    numCpus = 1;\n-                } else if (strsize >= 3 && strsize <= 5) {\n-                    /* should be of the form 0-999 */\n-                    /* parse the part after the 0-, note count is 0-based */\n-                    if (buf[1] == '-' && isdigit(buf[2])) {\n-                        numCpus = 1 + atoi(buf + 2);\n-                    }\n-                }\n-            }\n+  /* for the benefit of devices with advanced power-saving, that\n+     actually hotplug their cpus in heavy load, try to figure out\n+     the real number of CPUs */\n+  char buf[MAX_LINE];\n+  FILE* fin;\n+  const char* cpu_present = \"/sys/devices/system/cpu/present\";\n+  size_t strsize;\n+  numCpus = 0;\n+  fin = fopen(cpu_present, \"r\");\n+  if (fin != NULL) {\n+    if (fgets(buf, MAX_LINE, fin) != NULL) {\n+      /* check that the format is what we expect */\n+      if (buf[0] == '0') {\n+        strsize = strlen(buf);\n+        if (strsize == 1) {\n+          /* single core */\n+          numCpus = 1;\n+        } else if (strsize >= 3 && strsize <= 5) {\n+          /* should be of the form 0-999 */\n+          /* parse the part after the 0-, note count is 0-based */\n+          if (buf[1] == '-' && isdigit(buf[2])) {\n+            numCpus = 1 + atoi(buf + 2);\n+          }\n         }\n-        fclose(fin);\n-    }\n-    /* if that fails, fall back to more standard methods */\n-    if (!numCpus) {\n-        numCpus = sysconf(_SC_NPROCESSORS_CONF);\n+      }\n     }\n-#elif defined(XP_UNIX)\n+    fclose(fin);\n+  }\n+  /* if that fails, fall back to more standard methods */\n+  if (!numCpus) {\n     numCpus = sysconf(_SC_NPROCESSORS_CONF);\n+  }\n+#elif defined(XP_UNIX)\n+  numCpus = sysconf(_SC_NPROCESSORS_CONF);\n #else\n-#error \"An implementation is required\"\n+#  error \"An implementation is required\"\n #endif\n-    return (numCpus);\n+  return (numCpus);\n } /* end PR_GetNumberOfProcessors() */\n \n /*\n@@ -238,80 +231,78 @@ PR_GetNumberOfProcessors(void)\n **     do your thing, assign to bytes.\n **\n */\n-PR_IMPLEMENT(PRUint64)\n-PR_GetPhysicalMemorySize(void)\n-{\n-    PRUint64 bytes = 0;\n+PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void) {\n+  PRUint64 bytes = 0;\n \n #if defined(LINUX) || defined(SOLARIS)\n \n-    long pageSize = sysconf(_SC_PAGESIZE);\n-    long pageCount = sysconf(_SC_PHYS_PAGES);\n-    if (pageSize >= 0 && pageCount >= 0) {\n-        bytes = (PRUint64)pageSize * pageCount;\n-    }\n+  long pageSize = sysconf(_SC_PAGESIZE);\n+  long pageCount = sysconf(_SC_PHYS_PAGES);\n+  if (pageSize >= 0 && pageCount >= 0) {\n+    bytes = (PRUint64)pageSize * pageCount;\n+  }\n \n #elif defined(NETBSD) || defined(OPENBSD) || defined(FREEBSD) || \\\n     defined(DRAGONFLY)\n \n-    int mib[2];\n-    int rc;\n-#ifdef HW_PHYSMEM64\n-    uint64_t memSize;\n-#else\n-    unsigned long memSize;\n-#endif\n-    size_t len = sizeof(memSize);\n-\n-    mib[0] = CTL_HW;\n-#ifdef HW_PHYSMEM64\n-    mib[1] = HW_PHYSMEM64;\n-#else\n-    mib[1] = HW_PHYSMEM;\n-#endif\n-    rc = sysctl(mib, 2, &memSize, &len, NULL, 0);\n-    if (-1 != rc) {\n-        bytes = memSize;\n-    }\n+  int mib[2];\n+  int rc;\n+#  ifdef HW_PHYSMEM64\n+  uint64_t memSize;\n+#  else\n+  unsigned long memSize;\n+#  endif\n+  size_t len = sizeof(memSize);\n+\n+  mib[0] = CTL_HW;\n+#  ifdef HW_PHYSMEM64\n+  mib[1] = HW_PHYSMEM64;\n+#  else\n+  mib[1] = HW_PHYSMEM;\n+#  endif\n+  rc = sysctl(mib, 2, &memSize, &len, NULL, 0);\n+  if (-1 != rc) {\n+    bytes = memSize;\n+  }\n \n #elif defined(DARWIN)\n \n-    mach_port_t mach_host = mach_host_self();\n-    struct host_basic_info hInfo;\n-    mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;\n+  mach_port_t mach_host = mach_host_self();\n+  struct host_basic_info hInfo;\n+  mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;\n \n-    int result =\n-        host_info(mach_host, HOST_BASIC_INFO, (host_info_t)&hInfo, &count);\n-    mach_port_deallocate(mach_task_self(), mach_host);\n-    if (result == KERN_SUCCESS) {\n-        bytes = hInfo.max_mem;\n-    }\n+  int result =\n+      host_info(mach_host, HOST_BASIC_INFO, (host_info_t)&hInfo, &count);\n+  mach_port_deallocate(mach_task_self(), mach_host);\n+  if (result == KERN_SUCCESS) {\n+    bytes = hInfo.max_mem;\n+  }\n \n #elif defined(WIN32)\n \n-    MEMORYSTATUSEX memStat;\n-    memStat.dwLength = sizeof(memStat);\n-    if (GlobalMemoryStatusEx(&memStat)) {\n-        bytes = memStat.ullTotalPhys;\n-    }\n+  MEMORYSTATUSEX memStat;\n+  memStat.dwLength = sizeof(memStat);\n+  if (GlobalMemoryStatusEx(&memStat)) {\n+    bytes = memStat.ullTotalPhys;\n+  }\n \n #elif defined(AIX)\n \n-    if (odm_initialize() == 0) {\n-        int how_many;\n-        struct CuAt* obj = getattr(\"sys0\", \"realmem\", 0, &how_many);\n-        if (obj != NULL) {\n-            bytes = (PRUint64)atoi(obj->value) * 1024;\n-            free(obj);\n-        }\n-        odm_terminate();\n+  if (odm_initialize() == 0) {\n+    int how_many;\n+    struct CuAt* obj = getattr(\"sys0\", \"realmem\", 0, &how_many);\n+    if (obj != NULL) {\n+      bytes = (PRUint64)atoi(obj->value) * 1024;\n+      free(obj);\n     }\n+    odm_terminate();\n+  }\n \n #else\n \n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n \n #endif\n \n-    return bytes;\n+  return bytes;\n } /* end PR_GetPhysicalMemorySize() */\ndiff --git a/nspr/pr/src/misc/prthinfo.c b/nspr/pr/src/misc/prthinfo.c\nindex 102ffc1..acb0d70 100644\n--- a/nspr/pr/src/misc/prthinfo.c\n+++ b/nspr/pr/src/misc/prthinfo.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,139 +9,133 @@\n #include \"primpl.h\"\n \n PR_IMPLEMENT(PRWord*)\n-PR_GetGCRegisters(PRThread* t, int isCurrent, int* np)\n-{\n-    return _MD_HomeGCRegisters(t, isCurrent, np);\n+PR_GetGCRegisters(PRThread* t, int isCurrent, int* np) {\n+  return _MD_HomeGCRegisters(t, isCurrent, np);\n }\n \n PR_IMPLEMENT(PRStatus)\n PR_ThreadScanStackPointers(PRThread* t, PRScanStackFun scanFun,\n-                           void* scanClosure)\n-{\n-    PRThread* current = PR_GetCurrentThread();\n-    PRWord *sp, *esp, *p0;\n-    int n;\n-    void** ptd;\n-    PRStatus status;\n-    PRUint32 index;\n-    int stack_end;\n+                           void* scanClosure) {\n+  PRThread* current = PR_GetCurrentThread();\n+  PRWord *sp, *esp, *p0;\n+  int n;\n+  void** ptd;\n+  PRStatus status;\n+  PRUint32 index;\n+  int stack_end;\n \n-    /*\n-    ** Store the thread's registers in the thread structure so the GC\n-    ** can scan them. Then scan them.\n-    */\n-    p0 = _MD_HomeGCRegisters(t, t == current, &n);\n-    status = scanFun(t, (void**)p0, n, scanClosure);\n-    if (status != PR_SUCCESS) {\n-        return status;\n-    }\n+  /*\n+  ** Store the thread's registers in the thread structure so the GC\n+  ** can scan them. Then scan them.\n+  */\n+  p0 = _MD_HomeGCRegisters(t, t == current, &n);\n+  status = scanFun(t, (void**)p0, n, scanClosure);\n+  if (status != PR_SUCCESS) {\n+    return status;\n+  }\n \n-    /* Scan the C stack for pointers into the GC heap */\n+  /* Scan the C stack for pointers into the GC heap */\n #ifdef HAVE_STACK_GROWING_UP\n-    if (t == current) {\n-        esp = (PRWord*)&stack_end;\n-    } else {\n-        esp = (PRWord*)PR_GetSP(t);\n-    }\n-    sp = (PRWord*)t->stack->stackTop;\n-    if (t->stack->stackSize) {\n-        PR_ASSERT((esp > (PRWord*)t->stack->stackTop) &&\n-                  (esp < (PRWord*)t->stack->stackBottom));\n-    }\n+  if (t == current) {\n+    esp = (PRWord*)&stack_end;\n+  } else {\n+    esp = (PRWord*)PR_GetSP(t);\n+  }\n+  sp = (PRWord*)t->stack->stackTop;\n+  if (t->stack->stackSize) {\n+    PR_ASSERT((esp > (PRWord*)t->stack->stackTop) &&\n+              (esp < (PRWord*)t->stack->stackBottom));\n+  }\n #else  /* ! HAVE_STACK_GROWING_UP */\n-    if (t == current) {\n-        sp = (PRWord*)&stack_end;\n-    } else {\n-        sp = (PRWord*)PR_GetSP(t);\n-    }\n-    esp = (PRWord*)t->stack->stackTop;\n-    if (t->stack->stackSize) {\n-        PR_ASSERT((sp > (PRWord*)t->stack->stackBottom) &&\n-                  (sp < (PRWord*)t->stack->stackTop));\n-    }\n+  if (t == current) {\n+    sp = (PRWord*)&stack_end;\n+  } else {\n+    sp = (PRWord*)PR_GetSP(t);\n+  }\n+  esp = (PRWord*)t->stack->stackTop;\n+  if (t->stack->stackSize) {\n+    PR_ASSERT((sp > (PRWord*)t->stack->stackBottom) &&\n+              (sp < (PRWord*)t->stack->stackTop));\n+  }\n #endif /* ! HAVE_STACK_GROWING_UP */\n \n-    if (sp < esp) {\n-        status = scanFun(t, (void**)sp, esp - sp, scanClosure);\n-        if (status != PR_SUCCESS) {\n-            return status;\n-        }\n-    }\n-\n-    /*\n-    ** Mark all of the per-thread-data items attached to this thread\n-    **\n-    ** The execution environment better be accounted for otherwise it\n-    ** will be collected\n-    */\n-    status = scanFun(t, (void**)&t->environment, 1, scanClosure);\n+  if (sp < esp) {\n+    status = scanFun(t, (void**)sp, esp - sp, scanClosure);\n     if (status != PR_SUCCESS) {\n-        return status;\n+      return status;\n     }\n+  }\n+\n+  /*\n+  ** Mark all of the per-thread-data items attached to this thread\n+  **\n+  ** The execution environment better be accounted for otherwise it\n+  ** will be collected\n+  */\n+  status = scanFun(t, (void**)&t->environment, 1, scanClosure);\n+  if (status != PR_SUCCESS) {\n+    return status;\n+  }\n \n-    /* if thread is not allocated on stack, this is redundant. */\n-    ptd = t->privateData;\n-    for (index = 0; index < t->tpdLength; index++, ptd++) {\n-        status = scanFun(t, (void**)ptd, 1, scanClosure);\n-        if (status != PR_SUCCESS) {\n-            return status;\n-        }\n+  /* if thread is not allocated on stack, this is redundant. */\n+  ptd = t->privateData;\n+  for (index = 0; index < t->tpdLength; index++, ptd++) {\n+    status = scanFun(t, (void**)ptd, 1, scanClosure);\n+    if (status != PR_SUCCESS) {\n+      return status;\n     }\n+  }\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n }\n \n /* transducer for PR_EnumerateThreads */\n typedef struct PRScanStackData {\n-    PRScanStackFun scanFun;\n-    void* scanClosure;\n+  PRScanStackFun scanFun;\n+  void* scanClosure;\n } PRScanStackData;\n \n-static PRStatus PR_CALLBACK\n-pr_ScanStack(PRThread* t, int i, void* arg)\n-{\n-    PRScanStackData* data = (PRScanStackData*)arg;\n-    return PR_ThreadScanStackPointers(t, data->scanFun, data->scanClosure);\n+static PRStatus PR_CALLBACK pr_ScanStack(PRThread* t, int i, void* arg) {\n+  PRScanStackData* data = (PRScanStackData*)arg;\n+  return PR_ThreadScanStackPointers(t, data->scanFun, data->scanClosure);\n }\n \n PR_IMPLEMENT(PRStatus)\n-PR_ScanStackPointers(PRScanStackFun scanFun, void* scanClosure)\n-{\n-    PRScanStackData data;\n-    data.scanFun = scanFun;\n-    data.scanClosure = scanClosure;\n-    return PR_EnumerateThreads(pr_ScanStack, &data);\n+PR_ScanStackPointers(PRScanStackFun scanFun, void* scanClosure) {\n+  PRScanStackData data;\n+  data.scanFun = scanFun;\n+  data.scanClosure = scanClosure;\n+  return PR_EnumerateThreads(pr_ScanStack, &data);\n }\n \n PR_IMPLEMENT(PRUword)\n-PR_GetStackSpaceLeft(PRThread* t)\n-{\n-    PRThread* current = PR_GetCurrentThread();\n-    PRWord *sp, *esp;\n-    int stack_end;\n+PR_GetStackSpaceLeft(PRThread* t) {\n+  PRThread* current = PR_GetCurrentThread();\n+  PRWord *sp, *esp;\n+  int stack_end;\n \n #ifdef HAVE_STACK_GROWING_UP\n-    if (t == current) {\n-        esp = (PRWord*)&stack_end;\n-    } else {\n-        esp = (PRWord*)PR_GetSP(t);\n-    }\n-    sp = (PRWord*)t->stack->stackTop;\n-    if (t->stack->stackSize) {\n-        PR_ASSERT((esp > (PRWord*)t->stack->stackTop) &&\n-                  (esp < (PRWord*)t->stack->stackBottom));\n-    }\n+  if (t == current) {\n+    esp = (PRWord*)&stack_end;\n+  } else {\n+    esp = (PRWord*)PR_GetSP(t);\n+  }\n+  sp = (PRWord*)t->stack->stackTop;\n+  if (t->stack->stackSize) {\n+    PR_ASSERT((esp > (PRWord*)t->stack->stackTop) &&\n+              (esp < (PRWord*)t->stack->stackBottom));\n+  }\n #else  /* ! HAVE_STACK_GROWING_UP */\n-    if (t == current) {\n-        sp = (PRWord*)&stack_end;\n-    } else {\n-        sp = (PRWord*)PR_GetSP(t);\n-    }\n-    esp = (PRWord*)t->stack->stackTop;\n-    if (t->stack->stackSize) {\n-        PR_ASSERT((sp > (PRWord*)t->stack->stackBottom) &&\n-                  (sp < (PRWord*)t->stack->stackTop));\n-    }\n+  if (t == current) {\n+    sp = (PRWord*)&stack_end;\n+  } else {\n+    sp = (PRWord*)PR_GetSP(t);\n+  }\n+  esp = (PRWord*)t->stack->stackTop;\n+  if (t->stack->stackSize) {\n+    PR_ASSERT((sp > (PRWord*)t->stack->stackBottom) &&\n+              (sp < (PRWord*)t->stack->stackTop));\n+  }\n #endif /* ! HAVE_STACK_GROWING_UP */\n-    return (PRUword)t->stack->stackSize - ((PRWord)esp - (PRWord)sp);\n+  return (PRUword)t->stack->stackSize - ((PRWord)esp - (PRWord)sp);\n }\ndiff --git a/nspr/pr/src/misc/prtime.c b/nspr/pr/src/misc/prtime.c\nindex a1b8043..64461c6 100644\n--- a/nspr/pr/src/misc/prtime.c\n+++ b/nspr/pr/src/misc/prtime.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -48,19 +49,17 @@\n  * each month, where index 1 is January, and day 0 is January 1.\n  */\n \n-static const PRInt16 lastDayOfMonth[2][13] = {\n-    { -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364 },\n-    { -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }\n-};\n+static const int lastDayOfMonth[2][13] = {\n+    {-1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364},\n+    {-1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}};\n \n /*\n  * The number of days in a month\n  */\n \n static const PRInt8 nDays[2][12] = {\n-    { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },\n-    { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }\n-};\n+    {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},\n+    {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};\n \n /*\n  * Declarations for internal functions defined later in this file.\n@@ -81,112 +80,110 @@ static void ApplySecOffset(PRExplodedTime* time, PRInt32 secOffset);\n  *------------------------------------------------------------------------\n  */\n \n-static void\n-ComputeGMT(PRTime time, PRExplodedTime* gmt)\n-{\n-    PRInt32 tmp, rem;\n-    PRInt32 numDays;\n-    PRInt64 numDays64, rem64;\n-    int isLeap;\n-    PRInt64 sec;\n-    PRInt64 usec;\n-    PRInt64 usecPerSec;\n-    PRInt64 secPerDay;\n-\n-    /*\n-     * We first do the usec, sec, min, hour thing so that we do not\n-     * have to do LL arithmetic.\n-     */\n-\n-    LL_I2L(usecPerSec, 1000000L);\n-    LL_DIV(sec, time, usecPerSec);\n-    LL_MOD(usec, time, usecPerSec);\n-    LL_L2I(gmt->tm_usec, usec);\n-    /* Correct for weird mod semantics so the remainder is always positive */\n-    if (gmt->tm_usec < 0) {\n-        PRInt64 one;\n-\n-        LL_I2L(one, 1L);\n-        LL_SUB(sec, sec, one);\n-        gmt->tm_usec += 1000000L;\n-    }\n-\n-    LL_I2L(secPerDay, 86400L);\n-    LL_DIV(numDays64, sec, secPerDay);\n-    LL_MOD(rem64, sec, secPerDay);\n-    /* We are sure both of these numbers can fit into PRInt32 */\n-    LL_L2I(numDays, numDays64);\n-    LL_L2I(rem, rem64);\n-    if (rem < 0) {\n-        numDays--;\n-        rem += 86400L;\n-    }\n-\n-    /* Compute day of week.  Epoch started on a Thursday. */\n-\n-    gmt->tm_wday = (numDays + 4) % 7;\n-    if (gmt->tm_wday < 0) {\n-        gmt->tm_wday += 7;\n-    }\n-\n-    /* Compute the time of day. */\n-\n-    gmt->tm_hour = rem / 3600;\n-    rem %= 3600;\n-    gmt->tm_min = rem / 60;\n-    gmt->tm_sec = rem % 60;\n-\n-    /*\n-     * Compute the year by finding the 400 year period, then working\n-     * down from there.\n-     *\n-     * Since numDays is originally the number of days since January 1, 1970,\n-     * we must change it to be the number of days from January 1, 0001.\n-     */\n-\n-    numDays += 719162;      /* 719162 = days from year 1 up to 1970 */\n-    tmp = numDays / 146097; /* 146097 = days in 400 years */\n-    rem = numDays % 146097;\n-    gmt->tm_year = tmp * 400 + 1;\n-\n-    /* Compute the 100 year period. */\n-\n-    tmp = rem / 36524; /* 36524 = days in 100 years */\n-    rem %= 36524;\n-    if (tmp == 4) { /* the 400th year is a leap year */\n-        tmp = 3;\n-        rem = 36524;\n-    }\n-    gmt->tm_year += tmp * 100;\n-\n-    /* Compute the 4 year period. */\n-\n-    tmp = rem / 1461; /* 1461 = days in 4 years */\n-    rem %= 1461;\n-    gmt->tm_year += tmp * 4;\n-\n-    /* Compute which year in the 4. */\n-\n-    tmp = rem / 365;\n-    rem %= 365;\n-    if (tmp == 4) { /* the 4th year is a leap year */\n-        tmp = 3;\n-        rem = 365;\n-    }\n-\n-    gmt->tm_year += tmp;\n-    gmt->tm_yday = rem;\n-    isLeap = IsLeapYear(gmt->tm_year);\n-\n-    /* Compute the month and day of month. */\n-\n-    for (tmp = 1; lastDayOfMonth[isLeap][tmp] < gmt->tm_yday; tmp++) {\n-    }\n-    gmt->tm_month = --tmp;\n-    gmt->tm_mday = gmt->tm_yday - lastDayOfMonth[isLeap][tmp];\n-\n-    gmt->tm_params.tp_gmt_offset = 0;\n-    gmt->tm_params.tp_dst_offset = 0;\n+static void ComputeGMT(PRTime time, PRExplodedTime* gmt) {\n+  PRInt32 tmp, rem;\n+  PRInt32 numDays;\n+  PRInt64 numDays64, rem64;\n+  int isLeap;\n+  PRInt64 sec;\n+  PRInt64 usec;\n+  PRInt64 usecPerSec;\n+  PRInt64 secPerDay;\n+\n+  /*\n+   * We first do the usec, sec, min, hour thing so that we do not\n+   * have to do LL arithmetic.\n+   */\n+\n+  LL_I2L(usecPerSec, 1000000L);\n+  LL_DIV(sec, time, usecPerSec);\n+  LL_MOD(usec, time, usecPerSec);\n+  LL_L2I(gmt->tm_usec, usec);\n+  /* Correct for weird mod semantics so the remainder is always positive */\n+  if (gmt->tm_usec < 0) {\n+    PRInt64 one;\n+\n+    LL_I2L(one, 1L);\n+    LL_SUB(sec, sec, one);\n+    gmt->tm_usec += 1000000L;\n+  }\n+\n+  LL_I2L(secPerDay, 86400L);\n+  LL_DIV(numDays64, sec, secPerDay);\n+  LL_MOD(rem64, sec, secPerDay);\n+  /* We are sure both of these numbers can fit into PRInt32 */\n+  LL_L2I(numDays, numDays64);\n+  LL_L2I(rem, rem64);\n+  if (rem < 0) {\n+    numDays--;\n+    rem += 86400L;\n+  }\n+\n+  /* Compute day of week.  Epoch started on a Thursday. */\n+\n+  gmt->tm_wday = (numDays + 4) % 7;\n+  if (gmt->tm_wday < 0) {\n+    gmt->tm_wday += 7;\n+  }\n+\n+  /* Compute the time of day. */\n+\n+  gmt->tm_hour = rem / 3600;\n+  rem %= 3600;\n+  gmt->tm_min = rem / 60;\n+  gmt->tm_sec = rem % 60;\n+\n+  /*\n+   * Compute the year by finding the 400 year period, then working\n+   * down from there.\n+   *\n+   * Since numDays is originally the number of days since January 1, 1970,\n+   * we must change it to be the number of days from January 1, 0001.\n+   */\n+\n+  numDays += 719162;      /* 719162 = days from year 1 up to 1970 */\n+  tmp = numDays / 146097; /* 146097 = days in 400 years */\n+  rem = numDays % 146097;\n+  gmt->tm_year = tmp * 400 + 1;\n+\n+  /* Compute the 100 year period. */\n+\n+  tmp = rem / 36524; /* 36524 = days in 100 years */\n+  rem %= 36524;\n+  if (tmp == 4) { /* the 400th year is a leap year */\n+    tmp = 3;\n+    rem = 36524;\n+  }\n+  gmt->tm_year += tmp * 100;\n+\n+  /* Compute the 4 year period. */\n+\n+  tmp = rem / 1461; /* 1461 = days in 4 years */\n+  rem %= 1461;\n+  gmt->tm_year += tmp * 4;\n+\n+  /* Compute which year in the 4. */\n+\n+  tmp = rem / 365;\n+  rem %= 365;\n+  if (tmp == 4) { /* the 4th year is a leap year */\n+    tmp = 3;\n+    rem = 365;\n+  }\n+\n+  gmt->tm_year += tmp;\n+  gmt->tm_yday = rem;\n+  isLeap = IsLeapYear(gmt->tm_year);\n+\n+  /* Compute the month and day of month. */\n+\n+  for (tmp = 1; lastDayOfMonth[isLeap][tmp] < gmt->tm_yday; tmp++) {\n+  }\n+  gmt->tm_month = --tmp;\n+  gmt->tm_mday = gmt->tm_yday - lastDayOfMonth[isLeap][tmp];\n+\n+  gmt->tm_params.tp_gmt_offset = 0;\n+  gmt->tm_params.tp_dst_offset = 0;\n }\n \n /*\n@@ -201,12 +198,11 @@ ComputeGMT(PRTime time, PRExplodedTime* gmt)\n  */\n \n PR_IMPLEMENT(void)\n-PR_ExplodeTime(PRTime usecs, PRTimeParamFn params, PRExplodedTime* exploded)\n-{\n-    ComputeGMT(usecs, exploded);\n-    exploded->tm_params = params(exploded);\n-    ApplySecOffset(exploded, exploded->tm_params.tp_gmt_offset +\n-                                 exploded->tm_params.tp_dst_offset);\n+PR_ExplodeTime(PRTime usecs, PRTimeParamFn params, PRExplodedTime* exploded) {\n+  ComputeGMT(usecs, exploded);\n+  exploded->tm_params = params(exploded);\n+  ApplySecOffset(exploded, exploded->tm_params.tp_gmt_offset +\n+                               exploded->tm_params.tp_dst_offset);\n }\n \n /*\n@@ -220,43 +216,42 @@ PR_ExplodeTime(PRTime usecs, PRTimeParamFn params, PRExplodedTime* exploded)\n  *------------------------------------------------------------------------\n  */\n PR_IMPLEMENT(PRTime)\n-PR_ImplodeTime(const PRExplodedTime* exploded)\n-{\n-    PRExplodedTime copy;\n-    PRTime retVal;\n-    PRInt64 secPerDay, usecPerSec;\n-    PRInt64 temp;\n-    PRInt64 numSecs64;\n-    PRInt32 numDays;\n-    PRInt32 numSecs;\n-\n-    /* Normalize first.  Do this on our copy */\n-    copy = *exploded;\n-    PR_NormalizeTime(&copy, PR_GMTParameters);\n-\n-    numDays = DAYS_BETWEEN_YEARS(1970, copy.tm_year);\n-\n-    numSecs = copy.tm_yday * 86400 + copy.tm_hour * 3600 + copy.tm_min * 60 +\n-              copy.tm_sec;\n-\n-    LL_I2L(temp, numDays);\n-    LL_I2L(secPerDay, 86400);\n-    LL_MUL(temp, temp, secPerDay);\n-    LL_I2L(numSecs64, numSecs);\n-    LL_ADD(numSecs64, numSecs64, temp);\n-\n-    /* apply the GMT and DST offsets */\n-    LL_I2L(temp, copy.tm_params.tp_gmt_offset);\n-    LL_SUB(numSecs64, numSecs64, temp);\n-    LL_I2L(temp, copy.tm_params.tp_dst_offset);\n-    LL_SUB(numSecs64, numSecs64, temp);\n-\n-    LL_I2L(usecPerSec, 1000000L);\n-    LL_MUL(temp, numSecs64, usecPerSec);\n-    LL_I2L(retVal, copy.tm_usec);\n-    LL_ADD(retVal, retVal, temp);\n-\n-    return retVal;\n+PR_ImplodeTime(const PRExplodedTime* exploded) {\n+  PRExplodedTime copy;\n+  PRTime retVal;\n+  PRInt64 secPerDay, usecPerSec;\n+  PRInt64 temp;\n+  PRInt64 numSecs64;\n+  PRInt32 numDays;\n+  PRInt32 numSecs;\n+\n+  /* Normalize first.  Do this on our copy */\n+  copy = *exploded;\n+  PR_NormalizeTime(&copy, PR_GMTParameters);\n+\n+  numDays = DAYS_BETWEEN_YEARS(1970, copy.tm_year);\n+\n+  numSecs = copy.tm_yday * 86400 + copy.tm_hour * 3600 + copy.tm_min * 60 +\n+            copy.tm_sec;\n+\n+  LL_I2L(temp, numDays);\n+  LL_I2L(secPerDay, 86400);\n+  LL_MUL(temp, temp, secPerDay);\n+  LL_I2L(numSecs64, numSecs);\n+  LL_ADD(numSecs64, numSecs64, temp);\n+\n+  /* apply the GMT and DST offsets */\n+  LL_I2L(temp, copy.tm_params.tp_gmt_offset);\n+  LL_SUB(numSecs64, numSecs64, temp);\n+  LL_I2L(temp, copy.tm_params.tp_dst_offset);\n+  LL_SUB(numSecs64, numSecs64, temp);\n+\n+  LL_I2L(usecPerSec, 1000000L);\n+  LL_MUL(temp, numSecs64, usecPerSec);\n+  LL_I2L(retVal, copy.tm_usec);\n+  LL_ADD(retVal, retVal, temp);\n+\n+  return retVal;\n }\n \n /*\n@@ -269,13 +264,11 @@ PR_ImplodeTime(const PRExplodedTime* exploded)\n  *-------------------------------------------------------------------------\n  */\n \n-static int\n-IsLeapYear(PRInt16 year)\n-{\n-    if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {\n-        return 1;\n-    }\n-    return 0;\n+static int IsLeapYear(PRInt16 year) {\n+  if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {\n+    return 1;\n+  }\n+  return 0;\n }\n \n /*\n@@ -283,176 +276,173 @@ IsLeapYear(PRInt16 year)\n  * 'time' should point to a normalized PRExplodedTime.\n  */\n \n-static void\n-ApplySecOffset(PRExplodedTime* time, PRInt32 secOffset)\n-{\n-    time->tm_sec += secOffset;\n-\n-    /* Note that in this implementation we do not count leap seconds */\n-    if (time->tm_sec < 0 || time->tm_sec >= 60) {\n-        time->tm_min += time->tm_sec / 60;\n-        time->tm_sec %= 60;\n-        if (time->tm_sec < 0) {\n-            time->tm_sec += 60;\n-            time->tm_min--;\n-        }\n-    }\n+static void ApplySecOffset(PRExplodedTime* time, PRInt32 secOffset) {\n+  time->tm_sec += secOffset;\n \n-    if (time->tm_min < 0 || time->tm_min >= 60) {\n-        time->tm_hour += time->tm_min / 60;\n-        time->tm_min %= 60;\n-        if (time->tm_min < 0) {\n-            time->tm_min += 60;\n-            time->tm_hour--;\n-        }\n+  /* Note that in this implementation we do not count leap seconds */\n+  if (time->tm_sec < 0 || time->tm_sec >= 60) {\n+    time->tm_min += time->tm_sec / 60;\n+    time->tm_sec %= 60;\n+    if (time->tm_sec < 0) {\n+      time->tm_sec += 60;\n+      time->tm_min--;\n     }\n+  }\n+\n+  if (time->tm_min < 0 || time->tm_min >= 60) {\n+    time->tm_hour += time->tm_min / 60;\n+    time->tm_min %= 60;\n+    if (time->tm_min < 0) {\n+      time->tm_min += 60;\n+      time->tm_hour--;\n+    }\n+  }\n \n-    if (time->tm_hour < 0) {\n-        /* Decrement mday, yday, and wday */\n-        time->tm_hour += 24;\n-        time->tm_mday--;\n-        time->tm_yday--;\n-        if (time->tm_mday < 1) {\n-            time->tm_month--;\n-            if (time->tm_month < 0) {\n-                time->tm_month = 11;\n-                time->tm_year--;\n-                if (IsLeapYear(time->tm_year)) {\n-                    time->tm_yday = 365;\n-                } else {\n-                    time->tm_yday = 364;\n-                }\n-            }\n-            time->tm_mday = nDays[IsLeapYear(time->tm_year)][time->tm_month];\n-        }\n-        time->tm_wday--;\n-        if (time->tm_wday < 0) {\n-            time->tm_wday = 6;\n-        }\n-    } else if (time->tm_hour > 23) {\n-        /* Increment mday, yday, and wday */\n-        time->tm_hour -= 24;\n-        time->tm_mday++;\n-        time->tm_yday++;\n-        if (time->tm_mday > nDays[IsLeapYear(time->tm_year)][time->tm_month]) {\n-            time->tm_mday = 1;\n-            time->tm_month++;\n-            if (time->tm_month > 11) {\n-                time->tm_month = 0;\n-                time->tm_year++;\n-                time->tm_yday = 0;\n-            }\n-        }\n-        time->tm_wday++;\n-        if (time->tm_wday > 6) {\n-            time->tm_wday = 0;\n+  if (time->tm_hour < 0) {\n+    /* Decrement mday, yday, and wday */\n+    time->tm_hour += 24;\n+    time->tm_mday--;\n+    time->tm_yday--;\n+    if (time->tm_mday < 1) {\n+      time->tm_month--;\n+      if (time->tm_month < 0) {\n+        time->tm_month = 11;\n+        time->tm_year--;\n+        if (IsLeapYear(time->tm_year)) {\n+          time->tm_yday = 365;\n+        } else {\n+          time->tm_yday = 364;\n         }\n+      }\n+      time->tm_mday = nDays[IsLeapYear(time->tm_year)][time->tm_month];\n     }\n+    time->tm_wday--;\n+    if (time->tm_wday < 0) {\n+      time->tm_wday = 6;\n+    }\n+  } else if (time->tm_hour > 23) {\n+    /* Increment mday, yday, and wday */\n+    time->tm_hour -= 24;\n+    time->tm_mday++;\n+    time->tm_yday++;\n+    if (time->tm_mday > nDays[IsLeapYear(time->tm_year)][time->tm_month]) {\n+      time->tm_mday = 1;\n+      time->tm_month++;\n+      if (time->tm_month > 11) {\n+        time->tm_month = 0;\n+        time->tm_year++;\n+        time->tm_yday = 0;\n+      }\n+    }\n+    time->tm_wday++;\n+    if (time->tm_wday > 6) {\n+      time->tm_wday = 0;\n+    }\n+  }\n }\n \n PR_IMPLEMENT(void)\n-PR_NormalizeTime(PRExplodedTime* time, PRTimeParamFn params)\n-{\n-    int daysInMonth;\n-    PRInt32 numDays;\n-\n-    /* Get back to GMT */\n-    time->tm_sec -= time->tm_params.tp_gmt_offset + time->tm_params.tp_dst_offset;\n-    time->tm_params.tp_gmt_offset = 0;\n-    time->tm_params.tp_dst_offset = 0;\n-\n-    /* Now normalize GMT */\n-\n-    if (time->tm_usec < 0 || time->tm_usec >= 1000000) {\n-        time->tm_sec += time->tm_usec / 1000000;\n-        time->tm_usec %= 1000000;\n-        if (time->tm_usec < 0) {\n-            time->tm_usec += 1000000;\n-            time->tm_sec--;\n-        }\n+PR_NormalizeTime(PRExplodedTime* time, PRTimeParamFn params) {\n+  int daysInMonth;\n+  PRInt32 numDays;\n+\n+  /* Get back to GMT */\n+  time->tm_sec -= time->tm_params.tp_gmt_offset + time->tm_params.tp_dst_offset;\n+  time->tm_params.tp_gmt_offset = 0;\n+  time->tm_params.tp_dst_offset = 0;\n+\n+  /* Now normalize GMT */\n+\n+  if (time->tm_usec < 0 || time->tm_usec >= 1000000) {\n+    time->tm_sec += time->tm_usec / 1000000;\n+    time->tm_usec %= 1000000;\n+    if (time->tm_usec < 0) {\n+      time->tm_usec += 1000000;\n+      time->tm_sec--;\n     }\n-\n-    /* Note that we do not count leap seconds in this implementation */\n-    if (time->tm_sec < 0 || time->tm_sec >= 60) {\n-        time->tm_min += time->tm_sec / 60;\n-        time->tm_sec %= 60;\n-        if (time->tm_sec < 0) {\n-            time->tm_sec += 60;\n-            time->tm_min--;\n-        }\n+  }\n+\n+  /* Note that we do not count leap seconds in this implementation */\n+  if (time->tm_sec < 0 || time->tm_sec >= 60) {\n+    time->tm_min += time->tm_sec / 60;\n+    time->tm_sec %= 60;\n+    if (time->tm_sec < 0) {\n+      time->tm_sec += 60;\n+      time->tm_min--;\n     }\n-\n-    if (time->tm_min < 0 || time->tm_min >= 60) {\n-        time->tm_hour += time->tm_min / 60;\n-        time->tm_min %= 60;\n-        if (time->tm_min < 0) {\n-            time->tm_min += 60;\n-            time->tm_hour--;\n-        }\n+  }\n+\n+  if (time->tm_min < 0 || time->tm_min >= 60) {\n+    time->tm_hour += time->tm_min / 60;\n+    time->tm_min %= 60;\n+    if (time->tm_min < 0) {\n+      time->tm_min += 60;\n+      time->tm_hour--;\n     }\n+  }\n \n-    if (time->tm_hour < 0 || time->tm_hour >= 24) {\n-        time->tm_mday += time->tm_hour / 24;\n-        time->tm_hour %= 24;\n-        if (time->tm_hour < 0) {\n-            time->tm_hour += 24;\n-            time->tm_mday--;\n-        }\n+  if (time->tm_hour < 0 || time->tm_hour >= 24) {\n+    time->tm_mday += time->tm_hour / 24;\n+    time->tm_hour %= 24;\n+    if (time->tm_hour < 0) {\n+      time->tm_hour += 24;\n+      time->tm_mday--;\n     }\n-\n-    /* Normalize month and year before mday */\n-    if (time->tm_month < 0 || time->tm_month >= 12) {\n-        time->tm_year += time->tm_month / 12;\n-        time->tm_month %= 12;\n-        if (time->tm_month < 0) {\n-            time->tm_month += 12;\n-            time->tm_year--;\n-        }\n+  }\n+\n+  /* Normalize month and year before mday */\n+  if (time->tm_month < 0 || time->tm_month >= 12) {\n+    time->tm_year += time->tm_month / 12;\n+    time->tm_month %= 12;\n+    if (time->tm_month < 0) {\n+      time->tm_month += 12;\n+      time->tm_year--;\n     }\n-\n-    /* Now that month and year are in proper range, normalize mday */\n-\n-    if (time->tm_mday < 1) {\n-        /* mday too small */\n-        do {\n-            /* the previous month */\n-            time->tm_month--;\n-            if (time->tm_month < 0) {\n-                time->tm_month = 11;\n-                time->tm_year--;\n-            }\n-            time->tm_mday += nDays[IsLeapYear(time->tm_year)][time->tm_month];\n-        } while (time->tm_mday < 1);\n-    } else {\n-        daysInMonth = nDays[IsLeapYear(time->tm_year)][time->tm_month];\n-        while (time->tm_mday > daysInMonth) {\n-            /* mday too large */\n-            time->tm_mday -= daysInMonth;\n-            time->tm_month++;\n-            if (time->tm_month > 11) {\n-                time->tm_month = 0;\n-                time->tm_year++;\n-            }\n-            daysInMonth = nDays[IsLeapYear(time->tm_year)][time->tm_month];\n-        }\n+  }\n+\n+  /* Now that month and year are in proper range, normalize mday */\n+\n+  if (time->tm_mday < 1) {\n+    /* mday too small */\n+    do {\n+      /* the previous month */\n+      time->tm_month--;\n+      if (time->tm_month < 0) {\n+        time->tm_month = 11;\n+        time->tm_year--;\n+      }\n+      time->tm_mday += nDays[IsLeapYear(time->tm_year)][time->tm_month];\n+    } while (time->tm_mday < 1);\n+  } else {\n+    daysInMonth = nDays[IsLeapYear(time->tm_year)][time->tm_month];\n+    while (time->tm_mday > daysInMonth) {\n+      /* mday too large */\n+      time->tm_mday -= daysInMonth;\n+      time->tm_month++;\n+      if (time->tm_month > 11) {\n+        time->tm_month = 0;\n+        time->tm_year++;\n+      }\n+      daysInMonth = nDays[IsLeapYear(time->tm_year)][time->tm_month];\n     }\n+  }\n \n-    /* Recompute yday and wday */\n-    time->tm_yday = (PRInt16)time->tm_mday +\n-                    lastDayOfMonth[IsLeapYear(time->tm_year)][time->tm_month];\n+  /* Recompute yday and wday */\n+  time->tm_yday =\n+      time->tm_mday + lastDayOfMonth[IsLeapYear(time->tm_year)][time->tm_month];\n \n-    numDays = DAYS_BETWEEN_YEARS(1970, time->tm_year) + time->tm_yday;\n-    time->tm_wday = (numDays + 4) % 7;\n-    if (time->tm_wday < 0) {\n-        time->tm_wday += 7;\n-    }\n+  numDays = DAYS_BETWEEN_YEARS(1970, time->tm_year) + time->tm_yday;\n+  time->tm_wday = (numDays + 4) % 7;\n+  if (time->tm_wday < 0) {\n+    time->tm_wday += 7;\n+  }\n \n-    /* Recompute time parameters */\n+  /* Recompute time parameters */\n \n-    time->tm_params = params(time);\n+  time->tm_params = params(time);\n \n-    ApplySecOffset(time,\n-                   time->tm_params.tp_gmt_offset + time->tm_params.tp_dst_offset);\n+  ApplySecOffset(time,\n+                 time->tm_params.tp_gmt_offset + time->tm_params.tp_dst_offset);\n }\n \n /*\n@@ -483,244 +473,235 @@ PR_NormalizeTime(PRExplodedTime* time, PRTimeParamFn params)\n  * with 0.\n  */\n \n-#define MT_safe_localtime(timer, result) \\\n+#  define MT_safe_localtime(timer, result) \\\n     (localtime_r(timer, result) == -1 ? NULL : result)\n \n #elif defined(HAVE_POINTER_LOCALTIME_R)\n \n-#define MT_safe_localtime localtime_r\n+#  define MT_safe_localtime localtime_r\n \n #elif defined(_MSC_VER)\n \n /* Visual C++ has had localtime_s() since Visual C++ 2005. */\n \n-static struct tm*\n-MT_safe_localtime(const time_t* clock, struct tm* result)\n-{\n-    errno_t err = localtime_s(result, clock);\n-    if (err != 0) {\n-        errno = err;\n-        return NULL;\n-    }\n-    return result;\n+static struct tm* MT_safe_localtime(const time_t* clock, struct tm* result) {\n+  errno_t err = localtime_s(result, clock);\n+  if (err != 0) {\n+    errno = err;\n+    return NULL;\n+  }\n+  return result;\n }\n \n #else\n \n-#define HAVE_LOCALTIME_MONITOR                   \\\n+#  define HAVE_LOCALTIME_MONITOR                 \\\n     1 /* We use 'monitor' to serialize our calls \\\n        * to localtime(). */\n static PRLock* monitor = NULL;\n \n-static struct tm*\n-MT_safe_localtime(const time_t* clock, struct tm* result)\n-{\n-    struct tm* tmPtr;\n-    int needLock = PR_Initialized(); /* We need to use a lock to protect\n-                                      * against NSPR threads only when the\n-                                      * NSPR thread system is activated. */\n-\n-    if (needLock) {\n-        PR_Lock(monitor);\n-    }\n-\n-    /*\n-     * Microsoft (all flavors) localtime() returns a NULL pointer if 'clock'\n-     * represents a time before midnight January 1, 1970.  In\n-     * that case, we also return a NULL pointer and the struct tm\n-     * object pointed to by 'result' is not modified.\n-     *\n-     */\n-\n-    tmPtr = localtime(clock);\n-\n-    if (tmPtr) {\n-        *result = *tmPtr;\n-    } else {\n-        result = NULL;\n-    }\n-\n-    if (needLock) {\n-        PR_Unlock(monitor);\n-    }\n-\n-    return result;\n+static struct tm* MT_safe_localtime(const time_t* clock, struct tm* result) {\n+  struct tm* tmPtr;\n+  int needLock = PR_Initialized(); /* We need to use a lock to protect\n+                                    * against NSPR threads only when the\n+                                    * NSPR thread system is activated. */\n+\n+  if (needLock) {\n+    PR_Lock(monitor);\n+  }\n+\n+  /*\n+   * Microsoft (all flavors) localtime() returns a NULL pointer if 'clock'\n+   * represents a time before midnight January 1, 1970.  In\n+   * that case, we also return a NULL pointer and the struct tm\n+   * object pointed to by 'result' is not modified.\n+   *\n+   */\n+\n+  tmPtr = localtime(clock);\n+\n+  if (tmPtr) {\n+    *result = *tmPtr;\n+  } else {\n+    result = NULL;\n+  }\n+\n+  if (needLock) {\n+    PR_Unlock(monitor);\n+  }\n+\n+  return result;\n }\n \n #endif /* definition of MT_safe_localtime() */\n \n-void\n-_PR_InitTime(void)\n-{\n+void _PR_InitTime(void) {\n #ifdef HAVE_LOCALTIME_MONITOR\n-    monitor = PR_NewLock();\n+  monitor = PR_NewLock();\n #endif\n #ifdef WINCE\n-    _MD_InitTime();\n+  _MD_InitTime();\n #endif\n }\n \n-void\n-_PR_CleanupTime(void)\n-{\n+void _PR_CleanupTime(void) {\n #ifdef HAVE_LOCALTIME_MONITOR\n-    if (monitor) {\n-        PR_DestroyLock(monitor);\n-        monitor = NULL;\n-    }\n+  if (monitor) {\n+    PR_DestroyLock(monitor);\n+    monitor = NULL;\n+  }\n #endif\n #ifdef WINCE\n-    _MD_CleanupTime();\n+  _MD_CleanupTime();\n #endif\n }\n \n #if defined(XP_UNIX) || defined(XP_PC)\n \n PR_IMPLEMENT(PRTimeParameters)\n-PR_LocalTimeParameters(const PRExplodedTime* gmt)\n-{\n-    PRTimeParameters retVal;\n-    struct tm localTime;\n-    struct tm* localTimeResult;\n-    time_t secs;\n-    PRTime secs64;\n-    PRInt64 usecPerSec;\n-    PRInt64 usecPerSec_1;\n-    PRInt64 maxInt32;\n-    PRInt64 minInt32;\n-    PRInt32 dayOffset;\n-    PRInt32 offset2Jan1970;\n-    PRInt32 offsetNew;\n-    int isdst2Jan1970;\n-\n-    /*\n-     * Calculate the GMT offset.  First, figure out what is\n-     * 00:00:00 Jan. 2, 1970 GMT (which is exactly a day, or 86400\n-     * seconds, since the epoch) in local time.  Then we calculate\n-     * the difference between local time and GMT in seconds:\n-     *     gmt_offset = local_time - GMT\n-     *\n-     * Caveat: the validity of this calculation depends on two\n-     * assumptions:\n-     * 1. Daylight saving time was not in effect on Jan. 2, 1970.\n-     * 2. The time zone of the geographic location has not changed\n-     *    since Jan. 2, 1970.\n-     */\n-\n-    secs = 86400L;\n-    localTimeResult = MT_safe_localtime(&secs, &localTime);\n-    PR_ASSERT(localTimeResult != NULL);\n-    if (localTimeResult == NULL) {\n-        /* Shouldn't happen. Use safe fallback for optimized builds. */\n-        return PR_GMTParameters(gmt);\n-    }\n-\n-    /* GMT is 00:00:00, 2nd of Jan. */\n-\n-    offset2Jan1970 = (PRInt32)localTime.tm_sec + 60L * (PRInt32)localTime.tm_min +\n-                     3600L * (PRInt32)localTime.tm_hour +\n-                     86400L * (PRInt32)((PRInt32)localTime.tm_mday - 2L);\n-\n-    isdst2Jan1970 = localTime.tm_isdst;\n-\n-    /*\n-     * Now compute DST offset.  We calculate the overall offset\n-     * of local time from GMT, similar to above.  The overall\n-     * offset has two components: gmt offset and dst offset.\n-     * We subtract gmt offset from the overall offset to get\n-     * the dst offset.\n-     *     overall_offset = local_time - GMT\n-     *     overall_offset = gmt_offset + dst_offset\n-     * ==> dst_offset = local_time - GMT - gmt_offset\n-     */\n-\n-    secs64 = PR_ImplodeTime(gmt); /* This is still in microseconds */\n-    LL_I2L(usecPerSec, PR_USEC_PER_SEC);\n-    LL_I2L(usecPerSec_1, PR_USEC_PER_SEC - 1);\n-    /* Convert to seconds, truncating down (3.1 -> 3 and -3.1 -> -4) */\n-    if (LL_GE_ZERO(secs64)) {\n-        LL_DIV(secs64, secs64, usecPerSec);\n-    } else {\n-        LL_NEG(secs64, secs64);\n-        LL_ADD(secs64, secs64, usecPerSec_1);\n-        LL_DIV(secs64, secs64, usecPerSec);\n-        LL_NEG(secs64, secs64);\n-    }\n-    LL_I2L(maxInt32, PR_INT32_MAX);\n-    LL_I2L(minInt32, PR_INT32_MIN);\n-    if (LL_CMP(secs64, >, maxInt32) || LL_CMP(secs64, <, minInt32)) {\n-        /* secs64 is too large or too small for time_t (32-bit integer) */\n-        retVal.tp_gmt_offset = offset2Jan1970;\n-        retVal.tp_dst_offset = 0;\n-        return retVal;\n-    }\n-    LL_L2I(secs, secs64);\n-\n-    /*\n-     * On Windows, localtime() (and our MT_safe_localtime() too)\n-     * returns a NULL pointer for time before midnight January 1,\n-     * 1970 GMT.  In that case, we just use the GMT offset for\n-     * Jan 2, 1970 and assume that DST was not in effect.\n-     */\n-\n-    if (MT_safe_localtime(&secs, &localTime) == NULL) {\n-        retVal.tp_gmt_offset = offset2Jan1970;\n-        retVal.tp_dst_offset = 0;\n-        return retVal;\n-    }\n-\n-    /*\n-     * dayOffset is the offset between local time and GMT in\n-     * the day component, which can only be -1, 0, or 1.  We\n-     * use the day of the week to compute dayOffset.\n-     */\n-\n-    dayOffset = (PRInt32)localTime.tm_wday - gmt->tm_wday;\n-\n-    /*\n-     * Need to adjust for wrapping around of day of the week from\n-     * 6 back to 0.\n-     */\n-\n-    if (dayOffset == -6) {\n-        /* Local time is Sunday (0) and GMT is Saturday (6) */\n-        dayOffset = 1;\n-    } else if (dayOffset == 6) {\n-        /* Local time is Saturday (6) and GMT is Sunday (0) */\n-        dayOffset = -1;\n-    }\n-\n-    offsetNew = (PRInt32)localTime.tm_sec - gmt->tm_sec +\n-                60L * ((PRInt32)localTime.tm_min - gmt->tm_min) +\n-                3600L * ((PRInt32)localTime.tm_hour - gmt->tm_hour) +\n-                86400L * (PRInt32)dayOffset;\n-\n-    if (localTime.tm_isdst <= 0) {\n-        /* DST is not in effect */\n-        retVal.tp_gmt_offset = offsetNew;\n-        retVal.tp_dst_offset = 0;\n+PR_LocalTimeParameters(const PRExplodedTime* gmt) {\n+  PRTimeParameters retVal;\n+  struct tm localTime;\n+  struct tm* localTimeResult;\n+  time_t secs;\n+  PRTime secs64;\n+  PRInt64 usecPerSec;\n+  PRInt64 usecPerSec_1;\n+  PRInt64 maxInt32;\n+  PRInt64 minInt32;\n+  PRInt32 dayOffset;\n+  PRInt32 offset2Jan1970;\n+  PRInt32 offsetNew;\n+  int isdst2Jan1970;\n+\n+  /*\n+   * Calculate the GMT offset.  First, figure out what is\n+   * 00:00:00 Jan. 2, 1970 GMT (which is exactly a day, or 86400\n+   * seconds, since the epoch) in local time.  Then we calculate\n+   * the difference between local time and GMT in seconds:\n+   *     gmt_offset = local_time - GMT\n+   *\n+   * Caveat: the validity of this calculation depends on two\n+   * assumptions:\n+   * 1. Daylight saving time was not in effect on Jan. 2, 1970.\n+   * 2. The time zone of the geographic location has not changed\n+   *    since Jan. 2, 1970.\n+   */\n+\n+  secs = 86400L;\n+  localTimeResult = MT_safe_localtime(&secs, &localTime);\n+  PR_ASSERT(localTimeResult != NULL);\n+  if (localTimeResult == NULL) {\n+    /* Shouldn't happen. Use safe fallback for optimized builds. */\n+    return PR_GMTParameters(gmt);\n+  }\n+\n+  /* GMT is 00:00:00, 2nd of Jan. */\n+\n+  offset2Jan1970 = (PRInt32)localTime.tm_sec + 60L * (PRInt32)localTime.tm_min +\n+                   3600L * (PRInt32)localTime.tm_hour +\n+                   86400L * (PRInt32)((PRInt32)localTime.tm_mday - 2L);\n+\n+  isdst2Jan1970 = localTime.tm_isdst;\n+\n+  /*\n+   * Now compute DST offset.  We calculate the overall offset\n+   * of local time from GMT, similar to above.  The overall\n+   * offset has two components: gmt offset and dst offset.\n+   * We subtract gmt offset from the overall offset to get\n+   * the dst offset.\n+   *     overall_offset = local_time - GMT\n+   *     overall_offset = gmt_offset + dst_offset\n+   * ==> dst_offset = local_time - GMT - gmt_offset\n+   */\n+\n+  secs64 = PR_ImplodeTime(gmt); /* This is still in microseconds */\n+  LL_I2L(usecPerSec, PR_USEC_PER_SEC);\n+  LL_I2L(usecPerSec_1, PR_USEC_PER_SEC - 1);\n+  /* Convert to seconds, truncating down (3.1 -> 3 and -3.1 -> -4) */\n+  if (LL_GE_ZERO(secs64)) {\n+    LL_DIV(secs64, secs64, usecPerSec);\n+  } else {\n+    LL_NEG(secs64, secs64);\n+    LL_ADD(secs64, secs64, usecPerSec_1);\n+    LL_DIV(secs64, secs64, usecPerSec);\n+    LL_NEG(secs64, secs64);\n+  }\n+  LL_I2L(maxInt32, PR_INT32_MAX);\n+  LL_I2L(minInt32, PR_INT32_MIN);\n+  if (LL_CMP(secs64, >, maxInt32) || LL_CMP(secs64, <, minInt32)) {\n+    /* secs64 is too large or too small for time_t (32-bit integer) */\n+    retVal.tp_gmt_offset = offset2Jan1970;\n+    retVal.tp_dst_offset = 0;\n+    return retVal;\n+  }\n+  LL_L2I(secs, secs64);\n+\n+  /*\n+   * On Windows, localtime() (and our MT_safe_localtime() too)\n+   * returns a NULL pointer for time before midnight January 1,\n+   * 1970 GMT.  In that case, we just use the GMT offset for\n+   * Jan 2, 1970 and assume that DST was not in effect.\n+   */\n+\n+  if (MT_safe_localtime(&secs, &localTime) == NULL) {\n+    retVal.tp_gmt_offset = offset2Jan1970;\n+    retVal.tp_dst_offset = 0;\n+    return retVal;\n+  }\n+\n+  /*\n+   * dayOffset is the offset between local time and GMT in\n+   * the day component, which can only be -1, 0, or 1.  We\n+   * use the day of the week to compute dayOffset.\n+   */\n+\n+  dayOffset = (PRInt32)localTime.tm_wday - gmt->tm_wday;\n+\n+  /*\n+   * Need to adjust for wrapping around of day of the week from\n+   * 6 back to 0.\n+   */\n+\n+  if (dayOffset == -6) {\n+    /* Local time is Sunday (0) and GMT is Saturday (6) */\n+    dayOffset = 1;\n+  } else if (dayOffset == 6) {\n+    /* Local time is Saturday (6) and GMT is Sunday (0) */\n+    dayOffset = -1;\n+  }\n+\n+  offsetNew = (PRInt32)localTime.tm_sec - gmt->tm_sec +\n+              60L * ((PRInt32)localTime.tm_min - gmt->tm_min) +\n+              3600L * ((PRInt32)localTime.tm_hour - gmt->tm_hour) +\n+              86400L * (PRInt32)dayOffset;\n+\n+  if (localTime.tm_isdst <= 0) {\n+    /* DST is not in effect */\n+    retVal.tp_gmt_offset = offsetNew;\n+    retVal.tp_dst_offset = 0;\n+  } else {\n+    /* DST is in effect */\n+    if (isdst2Jan1970 <= 0) {\n+      /*\n+       * DST was not in effect back in 2 Jan. 1970.\n+       * Use the offset back then as the GMT offset,\n+       * assuming the time zone has not changed since then.\n+       */\n+      retVal.tp_gmt_offset = offset2Jan1970;\n+      retVal.tp_dst_offset = offsetNew - offset2Jan1970;\n     } else {\n-        /* DST is in effect */\n-        if (isdst2Jan1970 <= 0) {\n-            /*\n-             * DST was not in effect back in 2 Jan. 1970.\n-             * Use the offset back then as the GMT offset,\n-             * assuming the time zone has not changed since then.\n-             */\n-            retVal.tp_gmt_offset = offset2Jan1970;\n-            retVal.tp_dst_offset = offsetNew - offset2Jan1970;\n-        } else {\n-            /*\n-             * DST was also in effect back in 2 Jan. 1970.\n-             * Then our clever trick (or rather, ugly hack) fails.\n-             * We will just assume DST offset is an hour.\n-             */\n-            retVal.tp_gmt_offset = offsetNew - 3600;\n-            retVal.tp_dst_offset = 3600;\n-        }\n+      /*\n+       * DST was also in effect back in 2 Jan. 1970.\n+       * Then our clever trick (or rather, ugly hack) fails.\n+       * We will just assume DST offset is an hour.\n+       */\n+      retVal.tp_gmt_offset = offsetNew - 3600;\n+      retVal.tp_dst_offset = 3600;\n     }\n+  }\n \n-    return retVal;\n+  return retVal;\n }\n \n #endif /* defined(XP_UNIX) || defined(XP_PC) */\n@@ -752,114 +733,110 @@ PR_LocalTimeParameters(const PRExplodedTime* gmt)\n  * ndays is the number of days in that month, the same value as the\n  * mday of the last day of the month.\n  */\n-static PRInt32\n-NthSunday(PRInt32 mday, PRInt32 wday, PRInt32 N, PRInt32 ndays)\n-{\n-    PRInt32 firstSun = firstSunday(mday, wday);\n+static PRInt32 NthSunday(PRInt32 mday, PRInt32 wday, PRInt32 N, PRInt32 ndays) {\n+  PRInt32 firstSun = firstSunday(mday, wday);\n \n-    if (N < 0) {\n-        N = (ndays - firstSun) / 7;\n-    }\n-    return firstSun + (7 * N);\n+  if (N < 0) {\n+    N = (ndays - firstSun) / 7;\n+  }\n+  return firstSun + (7 * N);\n }\n \n typedef struct DSTParams {\n-    PRInt8 dst_start_month;       /* 0 = January */\n-    PRInt8 dst_start_Nth_Sunday;  /* N as defined above */\n-    PRInt8 dst_start_month_ndays; /* ndays as defined above */\n-    PRInt8 dst_end_month;         /* 0 = January */\n-    PRInt8 dst_end_Nth_Sunday;    /* N as defined above */\n-    PRInt8 dst_end_month_ndays;   /* ndays as defined above */\n+  PRInt8 dst_start_month;       /* 0 = January */\n+  PRInt8 dst_start_Nth_Sunday;  /* N as defined above */\n+  PRInt8 dst_start_month_ndays; /* ndays as defined above */\n+  PRInt8 dst_end_month;         /* 0 = January */\n+  PRInt8 dst_end_Nth_Sunday;    /* N as defined above */\n+  PRInt8 dst_end_month_ndays;   /* ndays as defined above */\n } DSTParams;\n \n static const DSTParams dstParams[2] = {\n     /* year < 2007:  First April Sunday - Last October Sunday */\n-    { 3, 0, 30, 9, -1, 31 },\n+    {3, 0, 30, 9, -1, 31},\n     /* year >= 2007: Second March Sunday - First November Sunday */\n-    { 2, 1, 31, 10, 0, 30 }\n-};\n+    {2, 1, 31, 10, 0, 30}};\n \n PR_IMPLEMENT(PRTimeParameters)\n-PR_USPacificTimeParameters(const PRExplodedTime* gmt)\n-{\n-    const DSTParams* dst;\n-    PRTimeParameters retVal;\n-    PRExplodedTime st;\n-\n-    /*\n-     * Based on geographic location and GMT, figure out offset of\n-     * standard time from GMT.  In this example implementation, we\n-     * assume the local time zone is US Pacific Time.\n-     */\n-\n-    retVal.tp_gmt_offset = -8L * 3600L;\n-\n-    /*\n-     * Make a copy of GMT.  Note that the tm_params field of this copy\n-     * is ignored.\n-     */\n-\n-    st.tm_usec = gmt->tm_usec;\n-    st.tm_sec = gmt->tm_sec;\n-    st.tm_min = gmt->tm_min;\n-    st.tm_hour = gmt->tm_hour;\n-    st.tm_mday = gmt->tm_mday;\n-    st.tm_month = gmt->tm_month;\n-    st.tm_year = gmt->tm_year;\n-    st.tm_wday = gmt->tm_wday;\n-    st.tm_yday = gmt->tm_yday;\n-\n-    /* Apply the offset to GMT to obtain the local standard time */\n-    ApplySecOffset(&st, retVal.tp_gmt_offset);\n-\n-    if (st.tm_year < 2007) { /* first April Sunday - Last October Sunday */\n-        dst = &dstParams[0];\n-    } else { /* Second March Sunday - First November Sunday */\n-        dst = &dstParams[1];\n-    }\n-\n-    /*\n-     * Apply the rules on standard time or GMT to obtain daylight saving\n-     * time offset.  In this implementation, we use the US DST rule.\n-     */\n-    if (st.tm_month < dst->dst_start_month) {\n+PR_USPacificTimeParameters(const PRExplodedTime* gmt) {\n+  const DSTParams* dst;\n+  PRTimeParameters retVal;\n+  PRExplodedTime st;\n+\n+  /*\n+   * Based on geographic location and GMT, figure out offset of\n+   * standard time from GMT.  In this example implementation, we\n+   * assume the local time zone is US Pacific Time.\n+   */\n+\n+  retVal.tp_gmt_offset = -8L * 3600L;\n+\n+  /*\n+   * Make a copy of GMT.  Note that the tm_params field of this copy\n+   * is ignored.\n+   */\n+\n+  st.tm_usec = gmt->tm_usec;\n+  st.tm_sec = gmt->tm_sec;\n+  st.tm_min = gmt->tm_min;\n+  st.tm_hour = gmt->tm_hour;\n+  st.tm_mday = gmt->tm_mday;\n+  st.tm_month = gmt->tm_month;\n+  st.tm_year = gmt->tm_year;\n+  st.tm_wday = gmt->tm_wday;\n+  st.tm_yday = gmt->tm_yday;\n+\n+  /* Apply the offset to GMT to obtain the local standard time */\n+  ApplySecOffset(&st, retVal.tp_gmt_offset);\n+\n+  if (st.tm_year < 2007) { /* first April Sunday - Last October Sunday */\n+    dst = &dstParams[0];\n+  } else { /* Second March Sunday - First November Sunday */\n+    dst = &dstParams[1];\n+  }\n+\n+  /*\n+   * Apply the rules on standard time or GMT to obtain daylight saving\n+   * time offset.  In this implementation, we use the US DST rule.\n+   */\n+  if (st.tm_month < dst->dst_start_month) {\n+    retVal.tp_dst_offset = 0L;\n+  } else if (st.tm_month == dst->dst_start_month) {\n+    int NthSun = NthSunday(st.tm_mday, st.tm_wday, dst->dst_start_Nth_Sunday,\n+                           dst->dst_start_month_ndays);\n+    if (st.tm_mday < NthSun) { /* Before starting Sunday */\n+      retVal.tp_dst_offset = 0L;\n+    } else if (st.tm_mday == NthSun) { /* Starting Sunday */\n+      /* 01:59:59 PST -> 03:00:00 PDT */\n+      if (st.tm_hour < 2) {\n         retVal.tp_dst_offset = 0L;\n-    } else if (st.tm_month == dst->dst_start_month) {\n-        int NthSun = NthSunday(st.tm_mday, st.tm_wday, dst->dst_start_Nth_Sunday,\n-                               dst->dst_start_month_ndays);\n-        if (st.tm_mday < NthSun) { /* Before starting Sunday */\n-            retVal.tp_dst_offset = 0L;\n-        } else if (st.tm_mday == NthSun) { /* Starting Sunday */\n-            /* 01:59:59 PST -> 03:00:00 PDT */\n-            if (st.tm_hour < 2) {\n-                retVal.tp_dst_offset = 0L;\n-            } else {\n-                retVal.tp_dst_offset = 3600L;\n-            }\n-        } else { /* After starting Sunday */\n-            retVal.tp_dst_offset = 3600L;\n-        }\n-    } else if (st.tm_month < dst->dst_end_month) {\n+      } else {\n         retVal.tp_dst_offset = 3600L;\n-    } else if (st.tm_month == dst->dst_end_month) {\n-        int NthSun = NthSunday(st.tm_mday, st.tm_wday, dst->dst_end_Nth_Sunday,\n-                               dst->dst_end_month_ndays);\n-        if (st.tm_mday < NthSun) { /* Before ending Sunday */\n-            retVal.tp_dst_offset = 3600L;\n-        } else if (st.tm_mday == NthSun) { /* Ending Sunday */\n-            /* 01:59:59 PDT -> 01:00:00 PST */\n-            if (st.tm_hour < 1) {\n-                retVal.tp_dst_offset = 3600L;\n-            } else {\n-                retVal.tp_dst_offset = 0L;\n-            }\n-        } else { /* After ending Sunday */\n-            retVal.tp_dst_offset = 0L;\n-        }\n-    } else {\n+      }\n+    } else { /* After starting Sunday */\n+      retVal.tp_dst_offset = 3600L;\n+    }\n+  } else if (st.tm_month < dst->dst_end_month) {\n+    retVal.tp_dst_offset = 3600L;\n+  } else if (st.tm_month == dst->dst_end_month) {\n+    int NthSun = NthSunday(st.tm_mday, st.tm_wday, dst->dst_end_Nth_Sunday,\n+                           dst->dst_end_month_ndays);\n+    if (st.tm_mday < NthSun) { /* Before ending Sunday */\n+      retVal.tp_dst_offset = 3600L;\n+    } else if (st.tm_mday == NthSun) { /* Ending Sunday */\n+      /* 01:59:59 PDT -> 01:00:00 PST */\n+      if (st.tm_hour < 1) {\n+        retVal.tp_dst_offset = 3600L;\n+      } else {\n         retVal.tp_dst_offset = 0L;\n+      }\n+    } else { /* After ending Sunday */\n+      retVal.tp_dst_offset = 0L;\n     }\n-    return retVal;\n+  } else {\n+    retVal.tp_dst_offset = 0L;\n+  }\n+  return retVal;\n }\n \n /*\n@@ -874,10 +851,9 @@ PR_USPacificTimeParameters(const PRExplodedTime* gmt)\n  */\n \n PR_IMPLEMENT(PRTimeParameters)\n-PR_GMTParameters(const PRExplodedTime* gmt)\n-{\n-    PRTimeParameters retVal = { 0, 0 };\n-    return retVal;\n+PR_GMTParameters(const PRExplodedTime* gmt) {\n+  PRTimeParameters retVal = {0, 0};\n+  return retVal;\n }\n \n /*\n@@ -903,44 +879,44 @@ PR_GMTParameters(const PRExplodedTime* gmt)\n  */\n \n typedef enum {\n-    TT_UNKNOWN,\n-\n-    TT_SUN,\n-    TT_MON,\n-    TT_TUE,\n-    TT_WED,\n-    TT_THU,\n-    TT_FRI,\n-    TT_SAT,\n-\n-    TT_JAN,\n-    TT_FEB,\n-    TT_MAR,\n-    TT_APR,\n-    TT_MAY,\n-    TT_JUN,\n-    TT_JUL,\n-    TT_AUG,\n-    TT_SEP,\n-    TT_OCT,\n-    TT_NOV,\n-    TT_DEC,\n-\n-    TT_PST,\n-    TT_PDT,\n-    TT_MST,\n-    TT_MDT,\n-    TT_CST,\n-    TT_CDT,\n-    TT_EST,\n-    TT_EDT,\n-    TT_AST,\n-    TT_NST,\n-    TT_GMT,\n-    TT_BST,\n-    TT_MET,\n-    TT_EET,\n-    TT_JST\n+  TT_UNKNOWN,\n+\n+  TT_SUN,\n+  TT_MON,\n+  TT_TUE,\n+  TT_WED,\n+  TT_THU,\n+  TT_FRI,\n+  TT_SAT,\n+\n+  TT_JAN,\n+  TT_FEB,\n+  TT_MAR,\n+  TT_APR,\n+  TT_MAY,\n+  TT_JUN,\n+  TT_JUL,\n+  TT_AUG,\n+  TT_SEP,\n+  TT_OCT,\n+  TT_NOV,\n+  TT_DEC,\n+\n+  TT_PST,\n+  TT_PDT,\n+  TT_MST,\n+  TT_MDT,\n+  TT_CST,\n+  TT_CDT,\n+  TT_EST,\n+  TT_EDT,\n+  TT_AST,\n+  TT_NST,\n+  TT_GMT,\n+  TT_BST,\n+  TT_MET,\n+  TT_EET,\n+  TT_JST\n } TIME_TOKEN;\n \n /*\n@@ -976,762 +952,761 @@ typedef enum {\n \n PR_IMPLEMENT(PRStatus)\n PR_ParseTimeStringToExplodedTime(const char* string, PRBool default_to_gmt,\n-                                 PRExplodedTime* result)\n-{\n-    TIME_TOKEN dotw = TT_UNKNOWN;\n-    TIME_TOKEN month = TT_UNKNOWN;\n-    TIME_TOKEN zone = TT_UNKNOWN;\n-    int zone_offset = -1;\n-    int dst_offset = 0;\n-    int date = -1;\n-    PRInt32 year = -1;\n-    int hour = -1;\n-    int min = -1;\n-    int sec = -1;\n-    struct tm* localTimeResult;\n-\n-    const char* rest = string;\n-\n-    int iterations = 0;\n-\n-    PR_ASSERT(string && result);\n-    if (!string || !result) {\n-        return PR_FAILURE;\n+                                 PRExplodedTime* result) {\n+  TIME_TOKEN dotw = TT_UNKNOWN;\n+  TIME_TOKEN month = TT_UNKNOWN;\n+  TIME_TOKEN zone = TT_UNKNOWN;\n+  int zone_offset = -1;\n+  int dst_offset = 0;\n+  int date = -1;\n+  PRInt32 year = -1;\n+  int hour = -1;\n+  int min = -1;\n+  int sec = -1;\n+  struct tm* localTimeResult;\n+\n+  const char* rest = string;\n+\n+  int iterations = 0;\n+\n+  PR_ASSERT(string && result);\n+  if (!string || !result) {\n+    return PR_FAILURE;\n+  }\n+\n+  while (*rest) {\n+    if (iterations++ > 1000) {\n+      return PR_FAILURE;\n     }\n \n-    while (*rest) {\n-        if (iterations++ > 1000) {\n-            return PR_FAILURE;\n+    switch (*rest) {\n+      case 'a':\n+      case 'A':\n+        if (month == TT_UNKNOWN && (rest[1] == 'p' || rest[1] == 'P') &&\n+            (rest[2] == 'r' || rest[2] == 'R')) {\n+          month = TT_APR;\n+        } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n+                   (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_AST;\n+        } else if (month == TT_UNKNOWN && (rest[1] == 'u' || rest[1] == 'U') &&\n+                   (rest[2] == 'g' || rest[2] == 'G')) {\n+          month = TT_AUG;\n+        }\n+        break;\n+      case 'b':\n+      case 'B':\n+        if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n+            (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_BST;\n+        }\n+        break;\n+      case 'c':\n+      case 'C':\n+        if (zone == TT_UNKNOWN && (rest[1] == 'd' || rest[1] == 'D') &&\n+            (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_CDT;\n+        } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n+                   (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_CST;\n+        }\n+        break;\n+      case 'd':\n+      case 'D':\n+        if (month == TT_UNKNOWN && (rest[1] == 'e' || rest[1] == 'E') &&\n+            (rest[2] == 'c' || rest[2] == 'C')) {\n+          month = TT_DEC;\n+        }\n+        break;\n+      case 'e':\n+      case 'E':\n+        if (zone == TT_UNKNOWN && (rest[1] == 'd' || rest[1] == 'D') &&\n+            (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_EDT;\n+        } else if (zone == TT_UNKNOWN && (rest[1] == 'e' || rest[1] == 'E') &&\n+                   (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_EET;\n+        } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n+                   (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_EST;\n+        }\n+        break;\n+      case 'f':\n+      case 'F':\n+        if (month == TT_UNKNOWN && (rest[1] == 'e' || rest[1] == 'E') &&\n+            (rest[2] == 'b' || rest[2] == 'B')) {\n+          month = TT_FEB;\n+        } else if (dotw == TT_UNKNOWN && (rest[1] == 'r' || rest[1] == 'R') &&\n+                   (rest[2] == 'i' || rest[2] == 'I')) {\n+          dotw = TT_FRI;\n+        }\n+        break;\n+      case 'g':\n+      case 'G':\n+        if (zone == TT_UNKNOWN && (rest[1] == 'm' || rest[1] == 'M') &&\n+            (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_GMT;\n+        }\n+        break;\n+      case 'j':\n+      case 'J':\n+        if (month == TT_UNKNOWN && (rest[1] == 'a' || rest[1] == 'A') &&\n+            (rest[2] == 'n' || rest[2] == 'N')) {\n+          month = TT_JAN;\n+        } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n+                   (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_JST;\n+        } else if (month == TT_UNKNOWN && (rest[1] == 'u' || rest[1] == 'U') &&\n+                   (rest[2] == 'l' || rest[2] == 'L')) {\n+          month = TT_JUL;\n+        } else if (month == TT_UNKNOWN && (rest[1] == 'u' || rest[1] == 'U') &&\n+                   (rest[2] == 'n' || rest[2] == 'N')) {\n+          month = TT_JUN;\n+        }\n+        break;\n+      case 'm':\n+      case 'M':\n+        if (month == TT_UNKNOWN && (rest[1] == 'a' || rest[1] == 'A') &&\n+            (rest[2] == 'r' || rest[2] == 'R')) {\n+          month = TT_MAR;\n+        } else if (month == TT_UNKNOWN && (rest[1] == 'a' || rest[1] == 'A') &&\n+                   (rest[2] == 'y' || rest[2] == 'Y')) {\n+          month = TT_MAY;\n+        } else if (zone == TT_UNKNOWN && (rest[1] == 'd' || rest[1] == 'D') &&\n+                   (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_MDT;\n+        } else if (zone == TT_UNKNOWN && (rest[1] == 'e' || rest[1] == 'E') &&\n+                   (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_MET;\n+        } else if (dotw == TT_UNKNOWN && (rest[1] == 'o' || rest[1] == 'O') &&\n+                   (rest[2] == 'n' || rest[2] == 'N')) {\n+          dotw = TT_MON;\n+        } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n+                   (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_MST;\n+        }\n+        break;\n+      case 'n':\n+      case 'N':\n+        if (month == TT_UNKNOWN && (rest[1] == 'o' || rest[1] == 'O') &&\n+            (rest[2] == 'v' || rest[2] == 'V')) {\n+          month = TT_NOV;\n+        } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n+                   (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_NST;\n+        }\n+        break;\n+      case 'o':\n+      case 'O':\n+        if (month == TT_UNKNOWN && (rest[1] == 'c' || rest[1] == 'C') &&\n+            (rest[2] == 't' || rest[2] == 'T')) {\n+          month = TT_OCT;\n+        }\n+        break;\n+      case 'p':\n+      case 'P':\n+        if (zone == TT_UNKNOWN && (rest[1] == 'd' || rest[1] == 'D') &&\n+            (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_PDT;\n+        } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n+                   (rest[2] == 't' || rest[2] == 'T')) {\n+          zone = TT_PST;\n+        }\n+        break;\n+      case 's':\n+      case 'S':\n+        if (dotw == TT_UNKNOWN && (rest[1] == 'a' || rest[1] == 'A') &&\n+            (rest[2] == 't' || rest[2] == 'T')) {\n+          dotw = TT_SAT;\n+        } else if (month == TT_UNKNOWN && (rest[1] == 'e' || rest[1] == 'E') &&\n+                   (rest[2] == 'p' || rest[2] == 'P')) {\n+          month = TT_SEP;\n+        } else if (dotw == TT_UNKNOWN && (rest[1] == 'u' || rest[1] == 'U') &&\n+                   (rest[2] == 'n' || rest[2] == 'N')) {\n+          dotw = TT_SUN;\n+        }\n+        break;\n+      case 't':\n+      case 'T':\n+        if (dotw == TT_UNKNOWN && (rest[1] == 'h' || rest[1] == 'H') &&\n+            (rest[2] == 'u' || rest[2] == 'U')) {\n+          dotw = TT_THU;\n+        } else if (dotw == TT_UNKNOWN && (rest[1] == 'u' || rest[1] == 'U') &&\n+                   (rest[2] == 'e' || rest[2] == 'E')) {\n+          dotw = TT_TUE;\n+        }\n+        break;\n+      case 'u':\n+      case 'U':\n+        if (zone == TT_UNKNOWN && (rest[1] == 't' || rest[1] == 'T') &&\n+            !(rest[2] >= 'A' && rest[2] <= 'Z') &&\n+            !(rest[2] >= 'a' && rest[2] <= 'z'))\n+        /* UT is the same as GMT but UTx is not. */\n+        {\n+          zone = TT_GMT;\n+        }\n+        break;\n+      case 'w':\n+      case 'W':\n+        if (dotw == TT_UNKNOWN && (rest[1] == 'e' || rest[1] == 'E') &&\n+            (rest[2] == 'd' || rest[2] == 'D')) {\n+          dotw = TT_WED;\n+        }\n+        break;\n+\n+      case '+':\n+      case '-': {\n+        const char* end;\n+        int sign;\n+        if (zone_offset != -1) {\n+          /* already got one... */\n+          rest++;\n+          break;\n+        }\n+        if (zone != TT_UNKNOWN && zone != TT_GMT) {\n+          /* GMT+0300 is legal, but PST+0300 is not. */\n+          rest++;\n+          break;\n         }\n \n-        switch (*rest) {\n-            case 'a':\n-            case 'A':\n-                if (month == TT_UNKNOWN && (rest[1] == 'p' || rest[1] == 'P') &&\n-                    (rest[2] == 'r' || rest[2] == 'R')) {\n-                    month = TT_APR;\n-                } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n-                           (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_AST;\n-                } else if (month == TT_UNKNOWN && (rest[1] == 'u' || rest[1] == 'U') &&\n-                           (rest[2] == 'g' || rest[2] == 'G')) {\n-                    month = TT_AUG;\n-                }\n-                break;\n-            case 'b':\n-            case 'B':\n-                if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n-                    (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_BST;\n-                }\n-                break;\n-            case 'c':\n-            case 'C':\n-                if (zone == TT_UNKNOWN && (rest[1] == 'd' || rest[1] == 'D') &&\n-                    (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_CDT;\n-                } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n-                           (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_CST;\n-                }\n-                break;\n-            case 'd':\n-            case 'D':\n-                if (month == TT_UNKNOWN && (rest[1] == 'e' || rest[1] == 'E') &&\n-                    (rest[2] == 'c' || rest[2] == 'C')) {\n-                    month = TT_DEC;\n-                }\n-                break;\n-            case 'e':\n-            case 'E':\n-                if (zone == TT_UNKNOWN && (rest[1] == 'd' || rest[1] == 'D') &&\n-                    (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_EDT;\n-                } else if (zone == TT_UNKNOWN && (rest[1] == 'e' || rest[1] == 'E') &&\n-                           (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_EET;\n-                } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n-                           (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_EST;\n-                }\n-                break;\n-            case 'f':\n-            case 'F':\n-                if (month == TT_UNKNOWN && (rest[1] == 'e' || rest[1] == 'E') &&\n-                    (rest[2] == 'b' || rest[2] == 'B')) {\n-                    month = TT_FEB;\n-                } else if (dotw == TT_UNKNOWN && (rest[1] == 'r' || rest[1] == 'R') &&\n-                           (rest[2] == 'i' || rest[2] == 'I')) {\n-                    dotw = TT_FRI;\n-                }\n-                break;\n-            case 'g':\n-            case 'G':\n-                if (zone == TT_UNKNOWN && (rest[1] == 'm' || rest[1] == 'M') &&\n-                    (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_GMT;\n-                }\n-                break;\n-            case 'j':\n-            case 'J':\n-                if (month == TT_UNKNOWN && (rest[1] == 'a' || rest[1] == 'A') &&\n-                    (rest[2] == 'n' || rest[2] == 'N')) {\n-                    month = TT_JAN;\n-                } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n-                           (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_JST;\n-                } else if (month == TT_UNKNOWN && (rest[1] == 'u' || rest[1] == 'U') &&\n-                           (rest[2] == 'l' || rest[2] == 'L')) {\n-                    month = TT_JUL;\n-                } else if (month == TT_UNKNOWN && (rest[1] == 'u' || rest[1] == 'U') &&\n-                           (rest[2] == 'n' || rest[2] == 'N')) {\n-                    month = TT_JUN;\n-                }\n-                break;\n-            case 'm':\n-            case 'M':\n-                if (month == TT_UNKNOWN && (rest[1] == 'a' || rest[1] == 'A') &&\n-                    (rest[2] == 'r' || rest[2] == 'R')) {\n-                    month = TT_MAR;\n-                } else if (month == TT_UNKNOWN && (rest[1] == 'a' || rest[1] == 'A') &&\n-                           (rest[2] == 'y' || rest[2] == 'Y')) {\n-                    month = TT_MAY;\n-                } else if (zone == TT_UNKNOWN && (rest[1] == 'd' || rest[1] == 'D') &&\n-                           (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_MDT;\n-                } else if (zone == TT_UNKNOWN && (rest[1] == 'e' || rest[1] == 'E') &&\n-                           (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_MET;\n-                } else if (dotw == TT_UNKNOWN && (rest[1] == 'o' || rest[1] == 'O') &&\n-                           (rest[2] == 'n' || rest[2] == 'N')) {\n-                    dotw = TT_MON;\n-                } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n-                           (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_MST;\n-                }\n-                break;\n-            case 'n':\n-            case 'N':\n-                if (month == TT_UNKNOWN && (rest[1] == 'o' || rest[1] == 'O') &&\n-                    (rest[2] == 'v' || rest[2] == 'V')) {\n-                    month = TT_NOV;\n-                } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n-                           (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_NST;\n-                }\n-                break;\n-            case 'o':\n-            case 'O':\n-                if (month == TT_UNKNOWN && (rest[1] == 'c' || rest[1] == 'C') &&\n-                    (rest[2] == 't' || rest[2] == 'T')) {\n-                    month = TT_OCT;\n-                }\n-                break;\n-            case 'p':\n-            case 'P':\n-                if (zone == TT_UNKNOWN && (rest[1] == 'd' || rest[1] == 'D') &&\n-                    (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_PDT;\n-                } else if (zone == TT_UNKNOWN && (rest[1] == 's' || rest[1] == 'S') &&\n-                           (rest[2] == 't' || rest[2] == 'T')) {\n-                    zone = TT_PST;\n-                }\n-                break;\n-            case 's':\n-            case 'S':\n-                if (dotw == TT_UNKNOWN && (rest[1] == 'a' || rest[1] == 'A') &&\n-                    (rest[2] == 't' || rest[2] == 'T')) {\n-                    dotw = TT_SAT;\n-                } else if (month == TT_UNKNOWN && (rest[1] == 'e' || rest[1] == 'E') &&\n-                           (rest[2] == 'p' || rest[2] == 'P')) {\n-                    month = TT_SEP;\n-                } else if (dotw == TT_UNKNOWN && (rest[1] == 'u' || rest[1] == 'U') &&\n-                           (rest[2] == 'n' || rest[2] == 'N')) {\n-                    dotw = TT_SUN;\n-                }\n-                break;\n-            case 't':\n-            case 'T':\n-                if (dotw == TT_UNKNOWN && (rest[1] == 'h' || rest[1] == 'H') &&\n-                    (rest[2] == 'u' || rest[2] == 'U')) {\n-                    dotw = TT_THU;\n-                } else if (dotw == TT_UNKNOWN && (rest[1] == 'u' || rest[1] == 'U') &&\n-                           (rest[2] == 'e' || rest[2] == 'E')) {\n-                    dotw = TT_TUE;\n-                }\n-                break;\n-            case 'u':\n-            case 'U':\n-                if (zone == TT_UNKNOWN && (rest[1] == 't' || rest[1] == 'T') &&\n-                    !(rest[2] >= 'A' && rest[2] <= 'Z') &&\n-                    !(rest[2] >= 'a' && rest[2] <= 'z'))\n-                /* UT is the same as GMT but UTx is not. */\n-                {\n-                    zone = TT_GMT;\n-                }\n-                break;\n-            case 'w':\n-            case 'W':\n-                if (dotw == TT_UNKNOWN && (rest[1] == 'e' || rest[1] == 'E') &&\n-                    (rest[2] == 'd' || rest[2] == 'D')) {\n-                    dotw = TT_WED;\n-                }\n-                break;\n-\n-            case '+':\n-            case '-': {\n-                const char* end;\n-                int sign;\n-                if (zone_offset != -1) {\n-                    /* already got one... */\n-                    rest++;\n-                    break;\n-                }\n-                if (zone != TT_UNKNOWN && zone != TT_GMT) {\n-                    /* GMT+0300 is legal, but PST+0300 is not. */\n-                    rest++;\n-                    break;\n-                }\n-\n-                sign = ((*rest == '+') ? 1 : -1);\n-                rest++; /* move over sign */\n-                end = rest;\n-                while (*end >= '0' && *end <= '9') {\n-                    end++;\n-                }\n-                if (rest == end) { /* no digits here */\n-                    break;\n-                }\n-\n-                if ((end - rest) == 4) /* offset in HHMM */\n-                    zone_offset = (((((rest[0] - '0') * 10) + (rest[1] - '0')) * 60) +\n-                                   (((rest[2] - '0') * 10) + (rest[3] - '0')));\n-                else if ((end - rest) == 2)\n-                /* offset in hours */\n-                {\n-                    zone_offset = (((rest[0] - '0') * 10) + (rest[1] - '0')) * 60;\n-                } else if ((end - rest) == 1)\n-                /* offset in hours */\n-                {\n-                    zone_offset = (rest[0] - '0') * 60;\n-                } else\n-                /* 3 or >4 */\n-                {\n-                    break;\n-                }\n-\n-                zone_offset *= sign;\n-                zone = TT_GMT;\n-                break;\n-            }\n-\n-            case '0':\n-            case '1':\n-            case '2':\n-            case '3':\n-            case '4':\n-            case '5':\n-            case '6':\n-            case '7':\n-            case '8':\n-            case '9': {\n-                int tmp_hour = -1;\n-                int tmp_min = -1;\n-                int tmp_sec = -1;\n-                const char* end = rest + 1;\n-                while (*end >= '0' && *end <= '9') {\n-                    end++;\n-                }\n-\n-                /* end is now the first character after a range of digits. */\n-\n-                if (*end == ':') {\n-                    if (hour >= 0 && min >= 0) { /* already got it */\n-                        break;\n-                    }\n-\n-                    /* We have seen \"[0-9]+:\", so this is probably HH:MM[:SS] */\n-                    if ((end - rest) > 2)\n-                    /* it is [0-9][0-9][0-9]+: */\n-                    {\n-                        break;\n-                    }\n-                    if ((end - rest) == 2)\n-                        tmp_hour = ((rest[0] - '0') * 10 + (rest[1] - '0'));\n-                    else {\n-                        tmp_hour = (rest[0] - '0');\n-                    }\n-\n-                    /* move over the colon, and parse minutes */\n-\n-                    rest = ++end;\n-                    while (*end >= '0' && *end <= '9') {\n-                        end++;\n-                    }\n-\n-                    if (end == rest)\n-                    /* no digits after first colon? */\n-                    {\n-                        break;\n-                    }\n-                    if ((end - rest) > 2)\n-                    /* it is [0-9][0-9][0-9]+: */\n-                    {\n-                        break;\n-                    }\n-                    if ((end - rest) == 2)\n-                        tmp_min = ((rest[0] - '0') * 10 + (rest[1] - '0'));\n-                    else {\n-                        tmp_min = (rest[0] - '0');\n-                    }\n-\n-                    /* now go for seconds */\n-                    rest = end;\n-                    if (*rest == ':') {\n-                        rest++;\n-                    }\n-                    end = rest;\n-                    while (*end >= '0' && *end <= '9') {\n-                        end++;\n-                    }\n-\n-                    if (end == rest) /* no digits after second colon - that's ok. */\n-                        ;\n-                    else if ((end - rest) > 2)\n-                    /* it is [0-9][0-9][0-9]+: */\n-                    {\n-                        break;\n-                    } else if ((end - rest) == 2)\n-                        tmp_sec = ((rest[0] - '0') * 10 + (rest[1] - '0'));\n-                    else {\n-                        tmp_sec = (rest[0] - '0');\n-                    }\n-\n-                    /* If we made it here, we've parsed hour and min,\n-                       and possibly sec, so it worked as a unit. */\n-\n-                    /* skip over whitespace and see if there's an AM or PM\n-                       directly following the time.\n-                     */\n-                    if (tmp_hour <= 12) {\n-                        const char* s = end;\n-                        while (*s && (*s == ' ' || *s == '\\t')) {\n-                            s++;\n-                        }\n-                        if ((s[0] == 'p' || s[0] == 'P') && (s[1] == 'm' || s[1] == 'M'))\n-                        /* 10:05pm == 22:05, and 12:05pm == 12:05 */\n-                        {\n-                            tmp_hour = (tmp_hour == 12 ? 12 : tmp_hour + 12);\n-                        } else if (tmp_hour == 12 && (s[0] == 'a' || s[0] == 'A') &&\n-                                   (s[1] == 'm' || s[1] == 'M'))\n-                        /* 12:05am == 00:05 */\n-                        {\n-                            tmp_hour = 0;\n-                        }\n-                    }\n-\n-                    hour = tmp_hour;\n-                    min = tmp_min;\n-                    sec = tmp_sec;\n-                    rest = end;\n-                    break;\n-                }\n-                if ((*end == '/' || *end == '-') && end[1] >= '0' && end[1] <= '9') {\n-                    /* Perhaps this is 6/16/95, 16/6/95, 6-16-95, or 16-6-95\n-                       or even 95-06-05...\n-                       #### But it doesn't handle 1995-06-22.\n-                     */\n-                    int n1, n2, n3;\n-                    const char* s;\n-\n-                    if (month != TT_UNKNOWN)\n-                    /* if we saw a month name, this can't be. */\n-                    {\n-                        break;\n-                    }\n-\n-                    s = rest;\n-\n-                    n1 = (*s++ - '0'); /* first 1 or 2 digits */\n-                    if (*s >= '0' && *s <= '9') {\n-                        n1 = n1 * 10 + (*s++ - '0');\n-                    }\n-\n-                    if (*s != '/' && *s != '-') { /* slash */\n-                        break;\n-                    }\n-                    s++;\n-\n-                    if (*s < '0' || *s > '9') { /* second 1 or 2 digits */\n-                        break;\n-                    }\n-                    n2 = (*s++ - '0');\n-                    if (*s >= '0' && *s <= '9') {\n-                        n2 = n2 * 10 + (*s++ - '0');\n-                    }\n-\n-                    if (*s != '/' && *s != '-') { /* slash */\n-                        break;\n-                    }\n-                    s++;\n-\n-                    if (*s < '0' || *s > '9') { /* third 1, 2, 4, or 5 digits */\n-                        break;\n-                    }\n-                    n3 = (*s++ - '0');\n-                    if (*s >= '0' && *s <= '9') {\n-                        n3 = n3 * 10 + (*s++ - '0');\n-                    }\n-\n-                    if (*s >= '0' && *s <= '9') /* optional digits 3, 4, and 5 */\n-                    {\n-                        n3 = n3 * 10 + (*s++ - '0');\n-                        if (*s < '0' || *s > '9') {\n-                            break;\n-                        }\n-                        n3 = n3 * 10 + (*s++ - '0');\n-                        if (*s >= '0' && *s <= '9') {\n-                            n3 = n3 * 10 + (*s++ - '0');\n-                        }\n-                    }\n-\n-                    if ((*s >= '0' && *s <= '9') || /* followed by non-alphanum */\n-                        (*s >= 'A' && *s <= 'Z') || (*s >= 'a' && *s <= 'z')) {\n-                        break;\n-                    }\n-\n-                    /* Ok, we parsed three 1-2 digit numbers, with / or -\n-                       between them.  Now decide what the hell they are\n-                       (DD/MM/YY or MM/DD/YY or YY/MM/DD.)\n-                     */\n-\n-                    if (n1 > 31 || n1 == 0) /* must be YY/MM/DD */\n-                    {\n-                        if (n2 > 12) {\n-                            break;\n-                        }\n-                        if (n3 > 31) {\n-                            break;\n-                        }\n-                        year = n1;\n-                        if (year < 70) {\n-                            year += 2000;\n-                        } else if (year < 100) {\n-                            year += 1900;\n-                        }\n-                        month = (TIME_TOKEN)(n2 + ((int)TT_JAN) - 1);\n-                        date = n3;\n-                        rest = s;\n-                        break;\n-                    }\n-\n-                    if (n1 > 12 && n2 > 12) /* illegal */\n-                    {\n-                        rest = s;\n-                        break;\n-                    }\n-\n-                    if (n3 < 70) {\n-                        n3 += 2000;\n-                    } else if (n3 < 100) {\n-                        n3 += 1900;\n-                    }\n-\n-                    if (n1 > 12) /* must be DD/MM/YY */\n-                    {\n-                        date = n1;\n-                        month = (TIME_TOKEN)(n2 + ((int)TT_JAN) - 1);\n-                        year = n3;\n-                    } else /* assume MM/DD/YY */\n-                    {\n-                        /* #### In the ambiguous case, should we consult the\n-                           locale to find out the local default? */\n-                        month = (TIME_TOKEN)(n1 + ((int)TT_JAN) - 1);\n-                        date = n2;\n-                        year = n3;\n-                    }\n-                    rest = s;\n-                } else if ((*end >= 'A' && *end <= 'Z') || (*end >= 'a' && *end <= 'z'))\n-                    /* Digits followed by non-punctuation - what's that? */\n-                    ;\n-                else if ((end - rest) == 5) /* five digits is a year */\n-                    year = (year < 0 ? ((rest[0] - '0') * 10000L +\n-                                        (rest[1] - '0') * 1000L + (rest[2] - '0') * 100L +\n-                                        (rest[3] - '0') * 10L + (rest[4] - '0'))\n-                                     : year);\n-                else if ((end - rest) == 4) /* four digits is a year */\n-                    year = (year < 0 ? ((rest[0] - '0') * 1000L + (rest[1] - '0') * 100L +\n-                                        (rest[2] - '0') * 10L + (rest[3] - '0'))\n-                                     : year);\n-                else if ((end - rest) == 2) /* two digits - date or year */\n-                {\n-                    int n = ((rest[0] - '0') * 10 + (rest[1] - '0'));\n-                    /* If we don't have a date (day of the month) and we see a number\n-                         less than 32, then assume that is the date.\n-\n-                             Otherwise, if we have a date and not a year, assume this is\n-                       the year.  If it is less than 70, then assume it refers to the 21st\n-                             century.  If it is two digits (>= 70), assume it refers to\n-                       this century.  Otherwise, assume it refers to an unambiguous year.\n-\n-                             The world will surely end soon.\n-                       */\n-                    if (date < 0 && n < 32) {\n-                        date = n;\n-                    } else if (year < 0) {\n-                        if (n < 70) {\n-                            year = 2000 + n;\n-                        } else if (n < 100) {\n-                            year = 1900 + n;\n-                        } else {\n-                            year = n;\n-                        }\n-                    }\n-                    /* else what the hell is this. */\n-                } else if ((end - rest) == 1) { /* one digit - date */\n-                    date = (date < 0 ? (rest[0] - '0') : date);\n-                }\n-                /* else, three or more than five digits - what's that? */\n-\n-                break;\n-            }\n+        sign = ((*rest == '+') ? 1 : -1);\n+        rest++; /* move over sign */\n+        end = rest;\n+        while (*end >= '0' && *end <= '9') {\n+          end++;\n+        }\n+        if (rest == end) { /* no digits here */\n+          break;\n         }\n \n-        /* Skip to the end of this token, whether we parsed it or not.\n-               Tokens are delimited by whitespace, or ,;-/\n-               But explicitly not :+-.\n-         */\n-        while (*rest && *rest != ' ' && *rest != '\\t' && *rest != ',' &&\n-               *rest != ';' && *rest != '-' && *rest != '+' && *rest != '/' &&\n-               *rest != '(' && *rest != ')' && *rest != '[' && *rest != ']') {\n-            rest++;\n+        if ((end - rest) == 4) /* offset in HHMM */\n+          zone_offset = (((((rest[0] - '0') * 10) + (rest[1] - '0')) * 60) +\n+                         (((rest[2] - '0') * 10) + (rest[3] - '0')));\n+        else if ((end - rest) == 2)\n+        /* offset in hours */\n+        {\n+          zone_offset = (((rest[0] - '0') * 10) + (rest[1] - '0')) * 60;\n+        } else if ((end - rest) == 1)\n+        /* offset in hours */\n+        {\n+          zone_offset = (rest[0] - '0') * 60;\n+        } else\n+        /* 3 or >4 */\n+        {\n+          break;\n         }\n-        /* skip over uninteresting chars. */\n-    SKIP_MORE:\n-        while (*rest && (*rest == ' ' || *rest == '\\t' || *rest == ',' ||\n-                         *rest == ';' || *rest == '/' || *rest == '(' ||\n-                         *rest == ')' || *rest == '[' || *rest == ']')) {\n-            rest++;\n+\n+        zone_offset *= sign;\n+        zone = TT_GMT;\n+        break;\n+      }\n+\n+      case '0':\n+      case '1':\n+      case '2':\n+      case '3':\n+      case '4':\n+      case '5':\n+      case '6':\n+      case '7':\n+      case '8':\n+      case '9': {\n+        int tmp_hour = -1;\n+        int tmp_min = -1;\n+        int tmp_sec = -1;\n+        const char* end = rest + 1;\n+        while (*end >= '0' && *end <= '9') {\n+          end++;\n         }\n \n-        /* \"-\" is ignored at the beginning of a token if we have not yet\n-               parsed a year (e.g., the second \"-\" in \"30-AUG-1966\"), or if\n-               the character after the dash is not a digit. */\n-        if (*rest == '-' &&\n-            ((rest > string && isalpha((unsigned char)rest[-1]) && year < 0) ||\n-             rest[1] < '0' || rest[1] > '9')) {\n+        /* end is now the first character after a range of digits. */\n+\n+        if (*end == ':') {\n+          if (hour >= 0 && min >= 0) { /* already got it */\n+            break;\n+          }\n+\n+          /* We have seen \"[0-9]+:\", so this is probably HH:MM[:SS] */\n+          if ((end - rest) > 2)\n+          /* it is [0-9][0-9][0-9]+: */\n+          {\n+            break;\n+          }\n+          if ((end - rest) == 2)\n+            tmp_hour = ((rest[0] - '0') * 10 + (rest[1] - '0'));\n+          else {\n+            tmp_hour = (rest[0] - '0');\n+          }\n+\n+          /* move over the colon, and parse minutes */\n+\n+          rest = ++end;\n+          while (*end >= '0' && *end <= '9') {\n+            end++;\n+          }\n+\n+          if (end == rest)\n+          /* no digits after first colon? */\n+          {\n+            break;\n+          }\n+          if ((end - rest) > 2)\n+          /* it is [0-9][0-9][0-9]+: */\n+          {\n+            break;\n+          }\n+          if ((end - rest) == 2)\n+            tmp_min = ((rest[0] - '0') * 10 + (rest[1] - '0'));\n+          else {\n+            tmp_min = (rest[0] - '0');\n+          }\n+\n+          /* now go for seconds */\n+          rest = end;\n+          if (*rest == ':') {\n             rest++;\n-            goto SKIP_MORE;\n-        }\n-    }\n+          }\n+          end = rest;\n+          while (*end >= '0' && *end <= '9') {\n+            end++;\n+          }\n+\n+          if (end == rest) /* no digits after second colon - that's ok. */\n+            ;\n+          else if ((end - rest) > 2)\n+          /* it is [0-9][0-9][0-9]+: */\n+          {\n+            break;\n+          }\n+          else if ((end - rest) == 2)\n+            tmp_sec = ((rest[0] - '0') * 10 + (rest[1] - '0'));\n+          else {\n+            tmp_sec = (rest[0] - '0');\n+          }\n+\n+          /* If we made it here, we've parsed hour and min,\n+             and possibly sec, so it worked as a unit. */\n+\n+          /* skip over whitespace and see if there's an AM or PM\n+             directly following the time.\n+           */\n+          if (tmp_hour <= 12) {\n+            const char* s = end;\n+            while (*s && (*s == ' ' || *s == '\\t')) {\n+              s++;\n+            }\n+            if ((s[0] == 'p' || s[0] == 'P') && (s[1] == 'm' || s[1] == 'M'))\n+            /* 10:05pm == 22:05, and 12:05pm == 12:05 */\n+            {\n+              tmp_hour = (tmp_hour == 12 ? 12 : tmp_hour + 12);\n+            } else if (tmp_hour == 12 && (s[0] == 'a' || s[0] == 'A') &&\n+                       (s[1] == 'm' || s[1] == 'M'))\n+            /* 12:05am == 00:05 */\n+            {\n+              tmp_hour = 0;\n+            }\n+          }\n \n-    if (zone != TT_UNKNOWN && zone_offset == -1) {\n-        switch (zone) {\n-            case TT_PST:\n-                zone_offset = -8 * 60;\n-                break;\n-            case TT_PDT:\n-                zone_offset = -8 * 60;\n-                dst_offset = 1 * 60;\n-                break;\n-            case TT_MST:\n-                zone_offset = -7 * 60;\n-                break;\n-            case TT_MDT:\n-                zone_offset = -7 * 60;\n-                dst_offset = 1 * 60;\n-                break;\n-            case TT_CST:\n-                zone_offset = -6 * 60;\n-                break;\n-            case TT_CDT:\n-                zone_offset = -6 * 60;\n-                dst_offset = 1 * 60;\n-                break;\n-            case TT_EST:\n-                zone_offset = -5 * 60;\n-                break;\n-            case TT_EDT:\n-                zone_offset = -5 * 60;\n-                dst_offset = 1 * 60;\n-                break;\n-            case TT_AST:\n-                zone_offset = -4 * 60;\n-                break;\n-            case TT_NST:\n-                zone_offset = -3 * 60 - 30;\n-                break;\n-            case TT_GMT:\n-                zone_offset = 0 * 60;\n-                break;\n-            case TT_BST:\n-                zone_offset = 0 * 60;\n-                dst_offset = 1 * 60;\n-                break;\n-            case TT_MET:\n-                zone_offset = 1 * 60;\n-                break;\n-            case TT_EET:\n-                zone_offset = 2 * 60;\n-                break;\n-            case TT_JST:\n-                zone_offset = 9 * 60;\n-                break;\n-            default:\n-                PR_ASSERT(0);\n-                break;\n+          hour = tmp_hour;\n+          min = tmp_min;\n+          sec = tmp_sec;\n+          rest = end;\n+          break;\n         }\n-    }\n+        if ((*end == '/' || *end == '-') && end[1] >= '0' && end[1] <= '9') {\n+          /* Perhaps this is 6/16/95, 16/6/95, 6-16-95, or 16-6-95\n+             or even 95-06-05...\n+             #### But it doesn't handle 1995-06-22.\n+           */\n+          int n1, n2, n3;\n+          const char* s;\n+\n+          if (month != TT_UNKNOWN)\n+          /* if we saw a month name, this can't be. */\n+          {\n+            break;\n+          }\n+\n+          s = rest;\n+\n+          n1 = (*s++ - '0'); /* first 1 or 2 digits */\n+          if (*s >= '0' && *s <= '9') {\n+            n1 = n1 * 10 + (*s++ - '0');\n+          }\n+\n+          if (*s != '/' && *s != '-') { /* slash */\n+            break;\n+          }\n+          s++;\n+\n+          if (*s < '0' || *s > '9') { /* second 1 or 2 digits */\n+            break;\n+          }\n+          n2 = (*s++ - '0');\n+          if (*s >= '0' && *s <= '9') {\n+            n2 = n2 * 10 + (*s++ - '0');\n+          }\n+\n+          if (*s != '/' && *s != '-') { /* slash */\n+            break;\n+          }\n+          s++;\n+\n+          if (*s < '0' || *s > '9') { /* third 1, 2, 4, or 5 digits */\n+            break;\n+          }\n+          n3 = (*s++ - '0');\n+          if (*s >= '0' && *s <= '9') {\n+            n3 = n3 * 10 + (*s++ - '0');\n+          }\n+\n+          if (*s >= '0' && *s <= '9') /* optional digits 3, 4, and 5 */\n+          {\n+            n3 = n3 * 10 + (*s++ - '0');\n+            if (*s < '0' || *s > '9') {\n+              break;\n+            }\n+            n3 = n3 * 10 + (*s++ - '0');\n+            if (*s >= '0' && *s <= '9') {\n+              n3 = n3 * 10 + (*s++ - '0');\n+            }\n+          }\n+\n+          if ((*s >= '0' && *s <= '9') || /* followed by non-alphanum */\n+              (*s >= 'A' && *s <= 'Z') || (*s >= 'a' && *s <= 'z')) {\n+            break;\n+          }\n+\n+          /* Ok, we parsed three 1-2 digit numbers, with / or -\n+             between them.  Now decide what the hell they are\n+             (DD/MM/YY or MM/DD/YY or YY/MM/DD.)\n+           */\n+\n+          if (n1 > 31 || n1 == 0) /* must be YY/MM/DD */\n+          {\n+            if (n2 > 12) {\n+              break;\n+            }\n+            if (n3 > 31) {\n+              break;\n+            }\n+            year = n1;\n+            if (year < 70) {\n+              year += 2000;\n+            } else if (year < 100) {\n+              year += 1900;\n+            }\n+            month = (TIME_TOKEN)(n2 + ((int)TT_JAN) - 1);\n+            date = n3;\n+            rest = s;\n+            break;\n+          }\n+\n+          if (n1 > 12 && n2 > 12) /* illegal */\n+          {\n+            rest = s;\n+            break;\n+          }\n+\n+          if (n3 < 70) {\n+            n3 += 2000;\n+          } else if (n3 < 100) {\n+            n3 += 1900;\n+          }\n+\n+          if (n1 > 12) /* must be DD/MM/YY */\n+          {\n+            date = n1;\n+            month = (TIME_TOKEN)(n2 + ((int)TT_JAN) - 1);\n+            year = n3;\n+          } else /* assume MM/DD/YY */\n+          {\n+            /* #### In the ambiguous case, should we consult the\n+               locale to find out the local default? */\n+            month = (TIME_TOKEN)(n1 + ((int)TT_JAN) - 1);\n+            date = n2;\n+            year = n3;\n+          }\n+          rest = s;\n+        } else if ((*end >= 'A' && *end <= 'Z') || (*end >= 'a' && *end <= 'z'))\n+          /* Digits followed by non-punctuation - what's that? */\n+          ;\n+        else if ((end - rest) == 5) /* five digits is a year */\n+          year = (year < 0 ? ((rest[0] - '0') * 10000L +\n+                              (rest[1] - '0') * 1000L + (rest[2] - '0') * 100L +\n+                              (rest[3] - '0') * 10L + (rest[4] - '0'))\n+                           : year);\n+        else if ((end - rest) == 4) /* four digits is a year */\n+          year = (year < 0 ? ((rest[0] - '0') * 1000L + (rest[1] - '0') * 100L +\n+                              (rest[2] - '0') * 10L + (rest[3] - '0'))\n+                           : year);\n+        else if ((end - rest) == 2) /* two digits - date or year */\n+        {\n+          int n = ((rest[0] - '0') * 10 + (rest[1] - '0'));\n+          /* If we don't have a date (day of the month) and we see a number\n+               less than 32, then assume that is the date.\n+\n+                   Otherwise, if we have a date and not a year, assume this is\n+             the year.  If it is less than 70, then assume it refers to the 21st\n+                   century.  If it is two digits (>= 70), assume it refers to\n+             this century.  Otherwise, assume it refers to an unambiguous year.\n+\n+                   The world will surely end soon.\n+             */\n+          if (date < 0 && n < 32) {\n+            date = n;\n+          } else if (year < 0) {\n+            if (n < 70) {\n+              year = 2000 + n;\n+            } else if (n < 100) {\n+              year = 1900 + n;\n+            } else {\n+              year = n;\n+            }\n+          }\n+          /* else what the hell is this. */\n+        } else if ((end - rest) == 1) { /* one digit - date */\n+          date = (date < 0 ? (rest[0] - '0') : date);\n+        }\n+        /* else, three or more than five digits - what's that? */\n \n-    /* If we didn't find a year, month, or day-of-the-month, we can't\n-           possibly parse this, and in fact, mktime() will do something random\n-           (I'm seeing it return \"Tue Feb  5 06:28:16 2036\", which is no doubt\n-           a numerologically significant date... */\n-    if (month == TT_UNKNOWN || date == -1 || year == -1 || year > PR_INT16_MAX) {\n-        return PR_FAILURE;\n+        break;\n+      }\n     }\n \n-    memset(result, 0, sizeof(*result));\n-    if (sec != -1) {\n-        result->tm_sec = sec;\n-    }\n-    if (min != -1) {\n-        result->tm_min = min;\n-    }\n-    if (hour != -1) {\n-        result->tm_hour = hour;\n-    }\n-    if (date != -1) {\n-        result->tm_mday = date;\n+    /* Skip to the end of this token, whether we parsed it or not.\n+           Tokens are delimited by whitespace, or ,;-/\n+           But explicitly not :+-.\n+     */\n+    while (*rest && *rest != ' ' && *rest != '\\t' && *rest != ',' &&\n+           *rest != ';' && *rest != '-' && *rest != '+' && *rest != '/' &&\n+           *rest != '(' && *rest != ')' && *rest != '[' && *rest != ']') {\n+      rest++;\n     }\n-    if (month != TT_UNKNOWN) {\n-        result->tm_month = (((int)month) - ((int)TT_JAN));\n+    /* skip over uninteresting chars. */\n+  SKIP_MORE:\n+    while (*rest && (*rest == ' ' || *rest == '\\t' || *rest == ',' ||\n+                     *rest == ';' || *rest == '/' || *rest == '(' ||\n+                     *rest == ')' || *rest == '[' || *rest == ']')) {\n+      rest++;\n     }\n-    if (year != -1) {\n-        result->tm_year = (PRInt16)year;\n+\n+    /* \"-\" is ignored at the beginning of a token if we have not yet\n+           parsed a year (e.g., the second \"-\" in \"30-AUG-1966\"), or if\n+           the character after the dash is not a digit. */\n+    if (*rest == '-' &&\n+        ((rest > string && isalpha((unsigned char)rest[-1]) && year < 0) ||\n+         rest[1] < '0' || rest[1] > '9')) {\n+      rest++;\n+      goto SKIP_MORE;\n     }\n-    if (dotw != TT_UNKNOWN) {\n-        result->tm_wday = (PRInt8)(((int)dotw) - ((int)TT_SUN));\n+  }\n+\n+  if (zone != TT_UNKNOWN && zone_offset == -1) {\n+    switch (zone) {\n+      case TT_PST:\n+        zone_offset = -8 * 60;\n+        break;\n+      case TT_PDT:\n+        zone_offset = -8 * 60;\n+        dst_offset = 1 * 60;\n+        break;\n+      case TT_MST:\n+        zone_offset = -7 * 60;\n+        break;\n+      case TT_MDT:\n+        zone_offset = -7 * 60;\n+        dst_offset = 1 * 60;\n+        break;\n+      case TT_CST:\n+        zone_offset = -6 * 60;\n+        break;\n+      case TT_CDT:\n+        zone_offset = -6 * 60;\n+        dst_offset = 1 * 60;\n+        break;\n+      case TT_EST:\n+        zone_offset = -5 * 60;\n+        break;\n+      case TT_EDT:\n+        zone_offset = -5 * 60;\n+        dst_offset = 1 * 60;\n+        break;\n+      case TT_AST:\n+        zone_offset = -4 * 60;\n+        break;\n+      case TT_NST:\n+        zone_offset = -3 * 60 - 30;\n+        break;\n+      case TT_GMT:\n+        zone_offset = 0 * 60;\n+        break;\n+      case TT_BST:\n+        zone_offset = 0 * 60;\n+        dst_offset = 1 * 60;\n+        break;\n+      case TT_MET:\n+        zone_offset = 1 * 60;\n+        break;\n+      case TT_EET:\n+        zone_offset = 2 * 60;\n+        break;\n+      case TT_JST:\n+        zone_offset = 9 * 60;\n+        break;\n+      default:\n+        PR_ASSERT(0);\n+        break;\n     }\n+  }\n+\n+  /* If we didn't find a year, month, or day-of-the-month, we can't\n+         possibly parse this, and in fact, mktime() will do something random\n+         (I'm seeing it return \"Tue Feb  5 06:28:16 2036\", which is no doubt\n+         a numerologically significant date... */\n+  if (month == TT_UNKNOWN || date == -1 || year == -1 || year > PR_INT16_MAX) {\n+    return PR_FAILURE;\n+  }\n+\n+  memset(result, 0, sizeof(*result));\n+  if (sec != -1) {\n+    result->tm_sec = sec;\n+  }\n+  if (min != -1) {\n+    result->tm_min = min;\n+  }\n+  if (hour != -1) {\n+    result->tm_hour = hour;\n+  }\n+  if (date != -1) {\n+    result->tm_mday = date;\n+  }\n+  if (month != TT_UNKNOWN) {\n+    result->tm_month = (((int)month) - ((int)TT_JAN));\n+  }\n+  if (year != -1) {\n+    result->tm_year = year;\n+  }\n+  if (dotw != TT_UNKNOWN) {\n+    result->tm_wday = (((int)dotw) - ((int)TT_SUN));\n+  }\n+  /*\n+   * Mainly to compute wday and yday, but normalized time is also required\n+   * by the check below that works around a Visual C++ 2005 mktime problem.\n+   */\n+  PR_NormalizeTime(result, PR_GMTParameters);\n+  /* The remaining work is to set the gmt and dst offsets in tm_params. */\n+\n+  if (zone == TT_UNKNOWN && default_to_gmt) {\n+    /* No zone was specified, so pretend the zone was GMT. */\n+    zone = TT_GMT;\n+    zone_offset = 0;\n+  }\n+\n+  if (zone_offset == -1) {\n+    /* no zone was specified, and we're to assume that everything\n+      is local. */\n+    struct tm localTime;\n+    time_t secs;\n+\n+    PR_ASSERT(result->tm_month > -1 && result->tm_mday > 0 &&\n+              result->tm_hour > -1 && result->tm_min > -1 &&\n+              result->tm_sec > -1);\n+\n     /*\n-     * Mainly to compute wday and yday, but normalized time is also required\n-     * by the check below that works around a Visual C++ 2005 mktime problem.\n+     * To obtain time_t from a tm structure representing the local\n+     * time, we call mktime().  However, we need to see if we are\n+     * on 1-Jan-1970 or before.  If we are, we can't call mktime()\n+     * because mktime() will crash on win16. In that case, we\n+     * calculate zone_offset based on the zone offset at\n+     * 00:00:00, 2 Jan 1970 GMT, and subtract zone_offset from the\n+     * date we are parsing to transform the date to GMT.  We also\n+     * do so if mktime() returns (time_t) -1 (time out of range).\n      */\n-    PR_NormalizeTime(result, PR_GMTParameters);\n-    /* The remaining work is to set the gmt and dst offsets in tm_params. */\n-\n-    if (zone == TT_UNKNOWN && default_to_gmt) {\n-        /* No zone was specified, so pretend the zone was GMT. */\n-        zone = TT_GMT;\n-        zone_offset = 0;\n-    }\n \n-    if (zone_offset == -1) {\n-        /* no zone was specified, and we're to assume that everything\n-          is local. */\n-        struct tm localTime;\n-        time_t secs;\n-\n-        PR_ASSERT(result->tm_month > -1 && result->tm_mday > 0 &&\n-                  result->tm_hour > -1 && result->tm_min > -1 &&\n-                  result->tm_sec > -1);\n-\n-        /*\n-         * To obtain time_t from a tm structure representing the local\n-         * time, we call mktime().  However, we need to see if we are\n-         * on 1-Jan-1970 or before.  If we are, we can't call mktime()\n-         * because mktime() will crash on win16. In that case, we\n-         * calculate zone_offset based on the zone offset at\n-         * 00:00:00, 2 Jan 1970 GMT, and subtract zone_offset from the\n-         * date we are parsing to transform the date to GMT.  We also\n-         * do so if mktime() returns (time_t) -1 (time out of range).\n-         */\n-\n-        /* month, day, hours, mins and secs are always non-negative\n-           so we dont need to worry about them. */\n-        if (result->tm_year >= 1970) {\n-            PRInt64 usec_per_sec;\n-\n-            localTime.tm_sec = result->tm_sec;\n-            localTime.tm_min = result->tm_min;\n-            localTime.tm_hour = result->tm_hour;\n-            localTime.tm_mday = result->tm_mday;\n-            localTime.tm_mon = result->tm_month;\n-            localTime.tm_year = result->tm_year - 1900;\n-            /* Set this to -1 to tell mktime \"I don't care\".  If you set\n-               it to 0 or 1, you are making assertions about whether the\n-               date you are handing it is in daylight savings mode or not;\n-               and if you're wrong, it will \"fix\" it for you. */\n-            localTime.tm_isdst = -1;\n+    /* month, day, hours, mins and secs are always non-negative\n+       so we dont need to worry about them. */\n+    if (result->tm_year >= 1970) {\n+      PRInt64 usec_per_sec;\n+\n+      localTime.tm_sec = result->tm_sec;\n+      localTime.tm_min = result->tm_min;\n+      localTime.tm_hour = result->tm_hour;\n+      localTime.tm_mday = result->tm_mday;\n+      localTime.tm_mon = result->tm_month;\n+      localTime.tm_year = result->tm_year - 1900;\n+      /* Set this to -1 to tell mktime \"I don't care\".  If you set\n+         it to 0 or 1, you are making assertions about whether the\n+         date you are handing it is in daylight savings mode or not;\n+         and if you're wrong, it will \"fix\" it for you. */\n+      localTime.tm_isdst = -1;\n \n #if _MSC_VER == 1400 /* 1400 = Visual C++ 2005 (8.0) */\n-            /*\n-             * mktime will return (time_t) -1 if the input is a date\n-             * after 23:59:59, December 31, 3000, US Pacific Time (not\n-             * UTC as documented):\n-             * http://msdn.microsoft.com/en-us/library/d1y53h2a(VS.80).aspx\n-             * But if the year is 3001, mktime also invokes the invalid\n-             * parameter handler, causing the application to crash.  This\n-             * problem has been reported in\n-             * http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=266036.\n-             * We avoid this crash by not calling mktime if the date is\n-             * out of range.  To use a simple test that works in any time\n-             * zone, we consider year 3000 out of range as well.  (See\n-             * bug 480740.)\n-             */\n-            if (result->tm_year >= 3000) {\n-                /* Emulate what mktime would have done. */\n-                errno = EINVAL;\n-                secs = (time_t)-1;\n-            } else {\n-                secs = mktime(&localTime);\n-            }\n+      /*\n+       * mktime will return (time_t) -1 if the input is a date\n+       * after 23:59:59, December 31, 3000, US Pacific Time (not\n+       * UTC as documented):\n+       * http://msdn.microsoft.com/en-us/library/d1y53h2a(VS.80).aspx\n+       * But if the year is 3001, mktime also invokes the invalid\n+       * parameter handler, causing the application to crash.  This\n+       * problem has been reported in\n+       * http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=266036.\n+       * We avoid this crash by not calling mktime if the date is\n+       * out of range.  To use a simple test that works in any time\n+       * zone, we consider year 3000 out of range as well.  (See\n+       * bug 480740.)\n+       */\n+      if (result->tm_year >= 3000) {\n+        /* Emulate what mktime would have done. */\n+        errno = EINVAL;\n+        secs = (time_t)-1;\n+      } else {\n+        secs = mktime(&localTime);\n+      }\n #else\n-            secs = mktime(&localTime);\n+      secs = mktime(&localTime);\n #endif\n-            if (secs != (time_t)-1) {\n-                PRTime usecs64;\n-                LL_I2L(usecs64, secs);\n-                LL_I2L(usec_per_sec, PR_USEC_PER_SEC);\n-                LL_MUL(usecs64, usecs64, usec_per_sec);\n-                PR_ExplodeTime(usecs64, PR_LocalTimeParameters, result);\n-                return PR_SUCCESS;\n-            }\n-        }\n+      if (secs != (time_t)-1) {\n+        PRTime usecs64;\n+        LL_I2L(usecs64, secs);\n+        LL_I2L(usec_per_sec, PR_USEC_PER_SEC);\n+        LL_MUL(usecs64, usecs64, usec_per_sec);\n+        PR_ExplodeTime(usecs64, PR_LocalTimeParameters, result);\n+        return PR_SUCCESS;\n+      }\n+    }\n \n-        /* So mktime() can't handle this case.  We assume the\n-           zone_offset for the date we are parsing is the same as\n-           the zone offset on 00:00:00 2 Jan 1970 GMT. */\n-        secs = 86400;\n-        localTimeResult = MT_safe_localtime(&secs, &localTime);\n-        PR_ASSERT(localTimeResult != NULL);\n-        if (localTimeResult == NULL) {\n-            return PR_FAILURE;\n-        }\n-        zone_offset = localTime.tm_min + 60 * localTime.tm_hour +\n-                      1440 * (localTime.tm_mday - 2);\n+    /* So mktime() can't handle this case.  We assume the\n+       zone_offset for the date we are parsing is the same as\n+       the zone offset on 00:00:00 2 Jan 1970 GMT. */\n+    secs = 86400;\n+    localTimeResult = MT_safe_localtime(&secs, &localTime);\n+    PR_ASSERT(localTimeResult != NULL);\n+    if (localTimeResult == NULL) {\n+      return PR_FAILURE;\n     }\n+    zone_offset = localTime.tm_min + 60 * localTime.tm_hour +\n+                  1440 * (localTime.tm_mday - 2);\n+  }\n \n-    result->tm_params.tp_gmt_offset = zone_offset * 60;\n-    result->tm_params.tp_dst_offset = dst_offset * 60;\n+  result->tm_params.tp_gmt_offset = zone_offset * 60;\n+  result->tm_params.tp_dst_offset = dst_offset * 60;\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n }\n \n PR_IMPLEMENT(PRStatus)\n-PR_ParseTimeString(const char* string, PRBool default_to_gmt, PRTime* result)\n-{\n-    PRExplodedTime tm;\n-    PRStatus rv;\n-\n-    rv = PR_ParseTimeStringToExplodedTime(string, default_to_gmt, &tm);\n-    if (rv != PR_SUCCESS) {\n-        return rv;\n-    }\n+PR_ParseTimeString(const char* string, PRBool default_to_gmt, PRTime* result) {\n+  PRExplodedTime tm;\n+  PRStatus rv;\n \n-    *result = PR_ImplodeTime(&tm);\n+  rv = PR_ParseTimeStringToExplodedTime(string, default_to_gmt, &tm);\n+  if (rv != PR_SUCCESS) {\n+    return rv;\n+  }\n+\n+  *result = PR_ImplodeTime(&tm);\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n }\n \n /*\n@@ -1756,99 +1731,98 @@ PR_ParseTimeString(const char* string, PRBool default_to_gmt, PRTime* result)\n \n PR_IMPLEMENT(PRUint32)\n PR_FormatTime(char* buf, int buflen, const char* fmt,\n-              const PRExplodedTime* time)\n-{\n-    size_t rv;\n-    struct tm a;\n-    struct tm* ap;\n-\n-    if (time) {\n-        ap = &a;\n-        a.tm_sec = time->tm_sec;\n-        a.tm_min = time->tm_min;\n-        a.tm_hour = time->tm_hour;\n-        a.tm_mday = time->tm_mday;\n-        a.tm_mon = time->tm_month;\n-        a.tm_wday = time->tm_wday;\n-        a.tm_year = time->tm_year - 1900;\n-        a.tm_yday = time->tm_yday;\n-        a.tm_isdst = time->tm_params.tp_dst_offset ? 1 : 0;\n-\n-        /*\n-         * On some platforms, for example SunOS 4, struct tm has two\n-         * additional fields: tm_zone and tm_gmtoff.\n-         */\n+              const PRExplodedTime* time) {\n+  size_t rv;\n+  struct tm a;\n+  struct tm* ap;\n+\n+  if (time) {\n+    ap = &a;\n+    a.tm_sec = time->tm_sec;\n+    a.tm_min = time->tm_min;\n+    a.tm_hour = time->tm_hour;\n+    a.tm_mday = time->tm_mday;\n+    a.tm_mon = time->tm_month;\n+    a.tm_wday = time->tm_wday;\n+    a.tm_year = time->tm_year - 1900;\n+    a.tm_yday = time->tm_yday;\n+    a.tm_isdst = time->tm_params.tp_dst_offset ? 1 : 0;\n+\n+    /*\n+     * On some platforms, for example SunOS 4, struct tm has two\n+     * additional fields: tm_zone and tm_gmtoff.\n+     */\n \n #if (__GLIBC__ >= 2) || defined(NETBSD) || defined(OPENBSD) || \\\n     defined(FREEBSD) || defined(DARWIN) || defined(ANDROID)\n-        a.tm_zone = NULL;\n-        a.tm_gmtoff = time->tm_params.tp_gmt_offset + time->tm_params.tp_dst_offset;\n+    a.tm_zone = NULL;\n+    a.tm_gmtoff = time->tm_params.tp_gmt_offset + time->tm_params.tp_dst_offset;\n #endif\n-    } else {\n-        ap = NULL;\n-    }\n+  } else {\n+    ap = NULL;\n+  }\n \n-    rv = strftime(buf, buflen, fmt, ap);\n-    if (!rv && buf && buflen > 0) {\n-        /*\n-         * When strftime fails, the contents of buf are indeterminate.\n-         * Some callers don't check the return value from this function,\n-         * so store an empty string in buf in case they try to print it.\n-         */\n-        buf[0] = '\\0';\n-    }\n-    return rv;\n+  rv = strftime(buf, buflen, fmt, ap);\n+  if (!rv && buf && buflen > 0) {\n+    /*\n+     * When strftime fails, the contents of buf are indeterminate.\n+     * Some callers don't check the return value from this function,\n+     * so store an empty string in buf in case they try to print it.\n+     */\n+    buf[0] = '\\0';\n+  }\n+  return rv;\n }\n \n /*\n  * The following string arrays and macros are used by PR_FormatTimeUSEnglish().\n  */\n \n-static const char* abbrevDays[] = { \"Sun\", \"Mon\", \"Tue\", \"Wed\",\n-                                    \"Thu\", \"Fri\", \"Sat\" };\n+static const char* abbrevDays[] = {\"Sun\", \"Mon\", \"Tue\", \"Wed\",\n+                                   \"Thu\", \"Fri\", \"Sat\"};\n \n-static const char* days[] = { \"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\",\n-                              \"Thursday\", \"Friday\", \"Saturday\" };\n+static const char* days[] = {\"Sunday\",   \"Monday\", \"Tuesday\", \"Wednesday\",\n+                             \"Thursday\", \"Friday\", \"Saturday\"};\n \n-static const char* abbrevMonths[] = { \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n-                                      \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\" };\n+static const char* abbrevMonths[] = {\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n+                                     \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"};\n \n-static const char* months[] = { \"January\", \"February\", \"March\", \"April\",\n-                                \"May\", \"June\", \"July\", \"August\",\n-                                \"September\", \"October\", \"November\", \"December\" };\n+static const char* months[] = {\"January\",   \"February\", \"March\",    \"April\",\n+                               \"May\",       \"June\",     \"July\",     \"August\",\n+                               \"September\", \"October\",  \"November\", \"December\"};\n \n /*\n  * Add a single character to the given buffer, incrementing the buffer pointer\n  * and decrementing the buffer size. Return 0 on error.\n  */\n #define ADDCHAR(buf, bufSize, ch) \\\n-    do {                          \\\n-        if (bufSize < 1) {        \\\n-            *(--buf) = '\\0';      \\\n-            return 0;             \\\n-        }                         \\\n-        *buf++ = ch;              \\\n-        bufSize--;                \\\n-    } while (0)\n+  do {                            \\\n+    if (bufSize < 1) {            \\\n+      *(--buf) = '\\0';            \\\n+      return 0;                   \\\n+    }                             \\\n+    *buf++ = ch;                  \\\n+    bufSize--;                    \\\n+  } while (0)\n \n /*\n  * Add a string to the given buffer, incrementing the buffer pointer\n  * and decrementing the buffer size appropriately.  Return 0 on error.\n  */\n-#define ADDSTR(buf, bufSize, str)       \\\n-    do {                                \\\n-        PRUint32 strSize = strlen(str); \\\n-        if (strSize > bufSize) {        \\\n-            if (bufSize == 0)           \\\n-                *(--buf) = '\\0';        \\\n-            else                        \\\n-                *buf = '\\0';            \\\n-            return 0;                   \\\n-        }                               \\\n-        memcpy(buf, str, strSize);      \\\n-        buf += strSize;                 \\\n-        bufSize -= strSize;             \\\n-    } while (0)\n+#define ADDSTR(buf, bufSize, str)   \\\n+  do {                              \\\n+    PRUint32 strSize = strlen(str); \\\n+    if (strSize > bufSize) {        \\\n+      if (bufSize == 0)             \\\n+        *(--buf) = '\\0';            \\\n+      else                          \\\n+        *buf = '\\0';                \\\n+      return 0;                     \\\n+    }                               \\\n+    memcpy(buf, str, strSize);      \\\n+    buf += strSize;                 \\\n+    bufSize -= strSize;             \\\n+  } while (0)\n \n /* Needed by PR_FormatTimeUSEnglish() */\n static unsigned int pr_WeekOfYear(const PRExplodedTime* time,\n@@ -1866,168 +1840,167 @@ static unsigned int pr_WeekOfYear(const PRExplodedTime* time,\n \n PR_IMPLEMENT(PRUint32)\n PR_FormatTimeUSEnglish(char* buf, PRUint32 bufSize, const char* format,\n-                       const PRExplodedTime* time)\n-{\n-    char* bufPtr = buf;\n-    const char* fmtPtr;\n-    char tmpBuf[40];\n-    const int tmpBufSize = sizeof(tmpBuf);\n-\n-    for (fmtPtr = format; *fmtPtr != '\\0'; fmtPtr++) {\n-        if (*fmtPtr != '%') {\n-            ADDCHAR(bufPtr, bufSize, *fmtPtr);\n-        } else {\n-            switch (*(++fmtPtr)) {\n-                case '%':\n-                    /* escaped '%' character */\n-                    ADDCHAR(bufPtr, bufSize, '%');\n-                    break;\n-\n-                case 'a':\n-                    /* abbreviated weekday name */\n-                    ADDSTR(bufPtr, bufSize, abbrevDays[time->tm_wday]);\n-                    break;\n-\n-                case 'A':\n-                    /* full weekday name */\n-                    ADDSTR(bufPtr, bufSize, days[time->tm_wday]);\n-                    break;\n-\n-                case 'b':\n-                    /* abbreviated month name */\n-                    ADDSTR(bufPtr, bufSize, abbrevMonths[time->tm_month]);\n-                    break;\n-\n-                case 'B':\n-                    /* full month name */\n-                    ADDSTR(bufPtr, bufSize, months[time->tm_month]);\n-                    break;\n-\n-                case 'c':\n-                    /* Date and time. */\n-                    PR_FormatTimeUSEnglish(tmpBuf, tmpBufSize, \"%a %b %d %H:%M:%S %Y\",\n-                                           time);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'd':\n-                    /* day of month ( 01 - 31 ) */\n-                    PR_snprintf(tmpBuf, tmpBufSize, \"%.2ld\", time->tm_mday);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'e':\n-                    /* day of month with space prefix for single digits ( 1 - 31 ) */\n-                    PR_snprintf(tmpBuf, tmpBufSize, \"%2ld\", time->tm_mday);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'H':\n-                    /* hour ( 00 - 23 ) */\n-                    PR_snprintf(tmpBuf, tmpBufSize, \"%.2ld\", time->tm_hour);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'I':\n-                    /* hour ( 01 - 12 ) */\n-                    PR_snprintf(tmpBuf, tmpBufSize, \"%.2ld\",\n-                                (time->tm_hour % 12) ? time->tm_hour % 12 : (PRInt32)12);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'j':\n-                    /* day number of year ( 001 - 366 ) */\n-                    PR_snprintf(tmpBuf, tmpBufSize, \"%.3d\", time->tm_yday + 1);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'm':\n-                    /* month number ( 01 - 12 ) */\n-                    PR_snprintf(tmpBuf, tmpBufSize, \"%.2ld\", time->tm_month + 1);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'M':\n-                    /* minute ( 00 - 59 ) */\n-                    PR_snprintf(tmpBuf, tmpBufSize, \"%.2ld\", time->tm_min);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'p':\n-                    /* locale's equivalent of either AM or PM */\n-                    ADDSTR(bufPtr, bufSize, (time->tm_hour < 12) ? \"AM\" : \"PM\");\n-                    break;\n-\n-                case 'S':\n-                    /* seconds ( 00 - 61 ), allows for leap seconds */\n-                    PR_snprintf(tmpBuf, tmpBufSize, \"%.2ld\", time->tm_sec);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'U':\n-                    /* week number of year ( 00 - 53  ),  Sunday  is  the first day of\n-                     * week 1 */\n-                    PR_snprintf(tmpBuf, tmpBufSize, \"%.2d\", pr_WeekOfYear(time, 0));\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'w':\n-                    /* weekday number ( 0 - 6 ), Sunday = 0 */\n-                    PR_snprintf(tmpBuf, tmpBufSize, \"%d\", time->tm_wday);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'W':\n-                    /* Week number of year ( 00 - 53  ),  Monday  is  the first day of\n-                     * week 1 */\n-                    PR_snprintf(tmpBuf, tmpBufSize, \"%.2d\", pr_WeekOfYear(time, 1));\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'x':\n-                    /* Date representation */\n-                    PR_FormatTimeUSEnglish(tmpBuf, tmpBufSize, \"%m/%d/%y\", time);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'X':\n-                    /* Time representation. */\n-                    PR_FormatTimeUSEnglish(tmpBuf, tmpBufSize, \"%H:%M:%S\", time);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'y':\n-                    /* year within century ( 00 - 99 ) */\n-                    PR_snprintf(tmpBuf, tmpBufSize, \"%.2d\", time->tm_year % 100);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'Y':\n-                    /* year as ccyy ( for example 1986 ) */\n-                    PR_snprintf(tmpBuf, tmpBufSize, \"%.4d\", time->tm_year);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                case 'Z':\n-                    /* Time zone name or no characters if  no  time  zone exists.\n-                     * Since time zone name is supposed to be independant of locale, we\n-                     * defer to PR_FormatTime() for this option.\n-                     */\n-                    PR_FormatTime(tmpBuf, tmpBufSize, \"%Z\", time);\n-                    ADDSTR(bufPtr, bufSize, tmpBuf);\n-                    break;\n-\n-                default:\n-                    /* Unknown format.  Simply copy format into output buffer. */\n-                    ADDCHAR(bufPtr, bufSize, '%');\n-                    ADDCHAR(bufPtr, bufSize, *fmtPtr);\n-                    break;\n-            }\n-        }\n+                       const PRExplodedTime* time) {\n+  char* bufPtr = buf;\n+  const char* fmtPtr;\n+  char tmpBuf[40];\n+  const int tmpBufSize = sizeof(tmpBuf);\n+\n+  for (fmtPtr = format; *fmtPtr != '\\0'; fmtPtr++) {\n+    if (*fmtPtr != '%') {\n+      ADDCHAR(bufPtr, bufSize, *fmtPtr);\n+    } else {\n+      switch (*(++fmtPtr)) {\n+        case '%':\n+          /* escaped '%' character */\n+          ADDCHAR(bufPtr, bufSize, '%');\n+          break;\n+\n+        case 'a':\n+          /* abbreviated weekday name */\n+          ADDSTR(bufPtr, bufSize, abbrevDays[time->tm_wday]);\n+          break;\n+\n+        case 'A':\n+          /* full weekday name */\n+          ADDSTR(bufPtr, bufSize, days[time->tm_wday]);\n+          break;\n+\n+        case 'b':\n+          /* abbreviated month name */\n+          ADDSTR(bufPtr, bufSize, abbrevMonths[time->tm_month]);\n+          break;\n+\n+        case 'B':\n+          /* full month name */\n+          ADDSTR(bufPtr, bufSize, months[time->tm_month]);\n+          break;\n+\n+        case 'c':\n+          /* Date and time. */\n+          PR_FormatTimeUSEnglish(tmpBuf, tmpBufSize, \"%a %b %d %H:%M:%S %Y\",\n+                                 time);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'd':\n+          /* day of month ( 01 - 31 ) */\n+          PR_snprintf(tmpBuf, tmpBufSize, \"%.2ld\", time->tm_mday);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'e':\n+          /* day of month with space prefix for single digits ( 1 - 31 ) */\n+          PR_snprintf(tmpBuf, tmpBufSize, \"%2ld\", time->tm_mday);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'H':\n+          /* hour ( 00 - 23 ) */\n+          PR_snprintf(tmpBuf, tmpBufSize, \"%.2ld\", time->tm_hour);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'I':\n+          /* hour ( 01 - 12 ) */\n+          PR_snprintf(tmpBuf, tmpBufSize, \"%.2ld\",\n+                      (time->tm_hour % 12) ? time->tm_hour % 12 : (PRInt32)12);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'j':\n+          /* day number of year ( 001 - 366 ) */\n+          PR_snprintf(tmpBuf, tmpBufSize, \"%.3d\", time->tm_yday + 1);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'm':\n+          /* month number ( 01 - 12 ) */\n+          PR_snprintf(tmpBuf, tmpBufSize, \"%.2ld\", time->tm_month + 1);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'M':\n+          /* minute ( 00 - 59 ) */\n+          PR_snprintf(tmpBuf, tmpBufSize, \"%.2ld\", time->tm_min);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'p':\n+          /* locale's equivalent of either AM or PM */\n+          ADDSTR(bufPtr, bufSize, (time->tm_hour < 12) ? \"AM\" : \"PM\");\n+          break;\n+\n+        case 'S':\n+          /* seconds ( 00 - 61 ), allows for leap seconds */\n+          PR_snprintf(tmpBuf, tmpBufSize, \"%.2ld\", time->tm_sec);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'U':\n+          /* week number of year ( 00 - 53  ),  Sunday  is  the first day of\n+           * week 1 */\n+          PR_snprintf(tmpBuf, tmpBufSize, \"%.2d\", pr_WeekOfYear(time, 0));\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'w':\n+          /* weekday number ( 0 - 6 ), Sunday = 0 */\n+          PR_snprintf(tmpBuf, tmpBufSize, \"%d\", time->tm_wday);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'W':\n+          /* Week number of year ( 00 - 53  ),  Monday  is  the first day of\n+           * week 1 */\n+          PR_snprintf(tmpBuf, tmpBufSize, \"%.2d\", pr_WeekOfYear(time, 1));\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'x':\n+          /* Date representation */\n+          PR_FormatTimeUSEnglish(tmpBuf, tmpBufSize, \"%m/%d/%y\", time);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'X':\n+          /* Time representation. */\n+          PR_FormatTimeUSEnglish(tmpBuf, tmpBufSize, \"%H:%M:%S\", time);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'y':\n+          /* year within century ( 00 - 99 ) */\n+          PR_snprintf(tmpBuf, tmpBufSize, \"%.2d\", time->tm_year % 100);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'Y':\n+          /* year as ccyy ( for example 1986 ) */\n+          PR_snprintf(tmpBuf, tmpBufSize, \"%.4d\", time->tm_year);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        case 'Z':\n+          /* Time zone name or no characters if  no  time  zone exists.\n+           * Since time zone name is supposed to be independant of locale, we\n+           * defer to PR_FormatTime() for this option.\n+           */\n+          PR_FormatTime(tmpBuf, tmpBufSize, \"%Z\", time);\n+          ADDSTR(bufPtr, bufSize, tmpBuf);\n+          break;\n+\n+        default:\n+          /* Unknown format.  Simply copy format into output buffer. */\n+          ADDCHAR(bufPtr, bufSize, '%');\n+          ADDCHAR(bufPtr, bufSize, *fmtPtr);\n+          break;\n+      }\n     }\n+  }\n \n-    ADDCHAR(bufPtr, bufSize, '\\0');\n-    return (PRUint32)(bufPtr - buf - 1);\n+  ADDCHAR(bufPtr, bufSize, '\\0');\n+  return (PRUint32)(bufPtr - buf - 1);\n }\n \n /***********************************************************************************\n@@ -2040,33 +2013,31 @@ PR_FormatTimeUSEnglish(char* buf, PRUint32 bufSize, const char* format,\n  *\n  **********************************************************************************/\n \n-static unsigned int\n-pr_WeekOfYear(const PRExplodedTime* time,\n-              unsigned int firstDayOfWeek)\n-{\n-    int dayOfWeek;\n-    int dayOfYear;\n-\n-    /* Get the day of the year for the given time then adjust it to represent the\n-     * first day of the week containing the given time.\n-     */\n-    dayOfWeek = time->tm_wday - firstDayOfWeek;\n-    if (dayOfWeek < 0) {\n-        dayOfWeek += 7;\n-    }\n-\n-    dayOfYear = time->tm_yday - dayOfWeek;\n-\n-    if (dayOfYear <= 0) {\n-        /* If dayOfYear is <= 0, it is in the first partial week of the year. */\n-        return 0;\n-    }\n-\n-    /* Count the number of full weeks ( dayOfYear / 7 ) then add a week if there\n-     * are any days left over ( dayOfYear % 7 ).  Because we are only counting to\n-     * the first day of the week containing the given time, rather than to the\n-     * actual day representing the given time, any days in week 0 will be\n-     * \"absorbed\" as extra days in the given week.\n-     */\n-    return (dayOfYear / 7) + ((dayOfYear % 7) == 0 ? 0 : 1);\n+static unsigned int pr_WeekOfYear(const PRExplodedTime* time,\n+                                  unsigned int firstDayOfWeek) {\n+  int dayOfWeek;\n+  int dayOfYear;\n+\n+  /* Get the day of the year for the given time then adjust it to represent the\n+   * first day of the week containing the given time.\n+   */\n+  dayOfWeek = time->tm_wday - firstDayOfWeek;\n+  if (dayOfWeek < 0) {\n+    dayOfWeek += 7;\n+  }\n+\n+  dayOfYear = time->tm_yday - dayOfWeek;\n+\n+  if (dayOfYear <= 0) {\n+    /* If dayOfYear is <= 0, it is in the first partial week of the year. */\n+    return 0;\n+  }\n+\n+  /* Count the number of full weeks ( dayOfYear / 7 ) then add a week if there\n+   * are any days left over ( dayOfYear % 7 ).  Because we are only counting to\n+   * the first day of the week containing the given time, rather than to the\n+   * actual day representing the given time, any days in week 0 will be\n+   * \"absorbed\" as extra days in the given week.\n+   */\n+  return (dayOfYear / 7) + ((dayOfYear % 7) == 0 ? 0 : 1);\n }\ndiff --git a/nspr/pr/src/misc/prtpool.c b/nspr/pr/src/misc/prtpool.c\nindex 3f5d689..00f07b7 100644\n--- a/nspr/pr/src/misc/prtpool.c\n+++ b/nspr/pr/src/misc/prtpool.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,39 +12,39 @@\n  *\n  */\n #ifdef OPT_WINNT\n-#include <windows.h>\n+#  include <windows.h>\n #endif\n \n /*\n  * worker thread\n  */\n typedef struct wthread {\n-    PRCList links;\n-    PRThread* thread;\n+  PRCList links;\n+  PRThread* thread;\n } wthread;\n \n /*\n  * queue of timer jobs\n  */\n typedef struct timer_jobq {\n-    PRCList list;\n-    PRLock* lock;\n-    PRCondVar* cv;\n-    PRInt32 cnt;\n-    PRCList wthreads;\n+  PRCList list;\n+  PRLock* lock;\n+  PRCondVar* cv;\n+  PRInt32 cnt;\n+  PRCList wthreads;\n } timer_jobq;\n \n /*\n  * queue of jobs\n  */\n typedef struct tp_jobq {\n-    PRCList list;\n-    PRInt32 cnt;\n-    PRLock* lock;\n-    PRCondVar* cv;\n-    PRCList wthreads;\n+  PRCList list;\n+  PRInt32 cnt;\n+  PRLock* lock;\n+  PRCondVar* cv;\n+  PRCList wthreads;\n #ifdef OPT_WINNT\n-    HANDLE nt_completion_port;\n+  HANDLE nt_completion_port;\n #endif\n } tp_jobq;\n \n@@ -51,92 +52,92 @@ typedef struct tp_jobq {\n  * queue of IO jobs\n  */\n typedef struct io_jobq {\n-    PRCList list;\n-    PRPollDesc* pollfds;\n-    PRInt32 npollfds;\n-    PRJob** polljobs;\n-    PRLock* lock;\n-    PRInt32 cnt;\n-    PRFileDesc* notify_fd;\n-    PRCList wthreads;\n+  PRCList list;\n+  PRPollDesc* pollfds;\n+  PRInt32 npollfds;\n+  PRJob** polljobs;\n+  PRLock* lock;\n+  PRInt32 cnt;\n+  PRFileDesc* notify_fd;\n+  PRCList wthreads;\n } io_jobq;\n \n /*\n  * Threadpool\n  */\n struct PRThreadPool {\n-    PRInt32 init_threads;\n-    PRInt32 max_threads;\n-    PRInt32 current_threads;\n-    PRInt32 idle_threads;\n-    PRUint32 stacksize;\n-    tp_jobq jobq;\n-    io_jobq ioq;\n-    timer_jobq timerq;\n-    PRLock* join_lock; /* used with jobp->join_cv */\n-    PRCondVar* shutdown_cv;\n-    PRBool shutdown;\n+  PRInt32 init_threads;\n+  PRInt32 max_threads;\n+  PRInt32 current_threads;\n+  PRInt32 idle_threads;\n+  PRUint32 stacksize;\n+  tp_jobq jobq;\n+  io_jobq ioq;\n+  timer_jobq timerq;\n+  PRLock* join_lock; /* used with jobp->join_cv */\n+  PRCondVar* shutdown_cv;\n+  PRBool shutdown;\n };\n \n typedef enum io_op_type {\n-    JOB_IO_READ,\n-    JOB_IO_WRITE,\n-    JOB_IO_CONNECT,\n-    JOB_IO_ACCEPT\n+  JOB_IO_READ,\n+  JOB_IO_WRITE,\n+  JOB_IO_CONNECT,\n+  JOB_IO_ACCEPT\n } io_op_type;\n \n #ifdef OPT_WINNT\n typedef struct NT_notifier {\n-    OVERLAPPED overlapped; /* must be first */\n-    PRJob* jobp;\n+  OVERLAPPED overlapped; /* must be first */\n+  PRJob* jobp;\n } NT_notifier;\n #endif\n \n struct PRJob {\n-    PRCList links;    /*  for linking jobs */\n-    PRBool on_ioq;    /* job on ioq */\n-    PRBool on_timerq; /* job on timerq */\n-    PRJobFn job_func;\n-    void* job_arg;\n-    PRCondVar* join_cv;\n-    PRBool join_wait;     /* == PR_TRUE, when waiting to join */\n-    PRCondVar* cancel_cv; /* for cancelling IO jobs */\n-    PRBool cancel_io;     /* for cancelling IO jobs */\n-    PRThreadPool* tpool;  /* back pointer to thread pool */\n-    PRJobIoDesc* iod;\n-    io_op_type io_op;\n-    PRInt16 io_poll_flags;\n-    PRNetAddr* netaddr;\n-    PRIntervalTime timeout; /* relative value */\n-    PRIntervalTime absolute;\n+  PRCList links;    /*  for linking jobs */\n+  PRBool on_ioq;    /* job on ioq */\n+  PRBool on_timerq; /* job on timerq */\n+  PRJobFn job_func;\n+  void* job_arg;\n+  PRCondVar* join_cv;\n+  PRBool join_wait;     /* == PR_TRUE, when waiting to join */\n+  PRCondVar* cancel_cv; /* for cancelling IO jobs */\n+  PRBool cancel_io;     /* for cancelling IO jobs */\n+  PRThreadPool* tpool;  /* back pointer to thread pool */\n+  PRJobIoDesc* iod;\n+  io_op_type io_op;\n+  PRInt16 io_poll_flags;\n+  PRNetAddr* netaddr;\n+  PRIntervalTime timeout; /* relative value */\n+  PRIntervalTime absolute;\n #ifdef OPT_WINNT\n-    NT_notifier nt_notifier;\n+  NT_notifier nt_notifier;\n #endif\n };\n \n #define JOB_LINKS_PTR(_qp) ((PRJob*)((char*)(_qp) - offsetof(PRJob, links)))\n \n #define WTHREAD_LINKS_PTR(_qp) \\\n-    ((wthread*)((char*)(_qp) - offsetof(wthread, links)))\n+  ((wthread*)((char*)(_qp) - offsetof(wthread, links)))\n \n #define JOINABLE_JOB(_jobp) (NULL != (_jobp)->join_cv)\n \n-#define JOIN_NOTIFY(_jobp)              \\\n-    PR_BEGIN_MACRO                      \\\n-    PR_Lock(_jobp->tpool->join_lock);   \\\n-    _jobp->join_wait = PR_FALSE;        \\\n-    PR_NotifyCondVar(_jobp->join_cv);   \\\n-    PR_Unlock(_jobp->tpool->join_lock); \\\n-    PR_END_MACRO\n-\n-#define CANCEL_IO_JOB(jobp)                \\\n-    PR_BEGIN_MACRO                         \\\n-    jobp->cancel_io = PR_FALSE;            \\\n-    jobp->on_ioq = PR_FALSE;               \\\n-    PR_REMOVE_AND_INIT_LINK(&jobp->links); \\\n-    tp->ioq.cnt--;                         \\\n-    PR_NotifyCondVar(jobp->cancel_cv);     \\\n-    PR_END_MACRO\n+#define JOIN_NOTIFY(_jobp)            \\\n+  PR_BEGIN_MACRO                      \\\n+  PR_Lock(_jobp->tpool->join_lock);   \\\n+  _jobp->join_wait = PR_FALSE;        \\\n+  PR_NotifyCondVar(_jobp->join_cv);   \\\n+  PR_Unlock(_jobp->tpool->join_lock); \\\n+  PR_END_MACRO\n+\n+#define CANCEL_IO_JOB(jobp)              \\\n+  PR_BEGIN_MACRO                         \\\n+  jobp->cancel_io = PR_FALSE;            \\\n+  jobp->on_ioq = PR_FALSE;               \\\n+  PR_REMOVE_AND_INIT_LINK(&jobp->links); \\\n+  tp->ioq.cnt--;                         \\\n+  PR_NotifyCondVar(jobp->cancel_cv);     \\\n+  PR_END_MACRO\n \n static void delete_job(PRJob* jobp);\n static PRThreadPool* alloc_threadpool(void);\n@@ -156,840 +157,811 @@ static void notify_timerq(PRThreadPool* tp);\n /*\n  * worker thread function\n  */\n-static void\n-wstart(void* arg)\n-{\n-    PRThreadPool* tp = (PRThreadPool*)arg;\n-    PRCList* head;\n-\n-    /*\n-     * execute jobs until shutdown\n-     */\n-    while (!tp->shutdown) {\n-        PRJob* jobp;\n+static void wstart(void* arg) {\n+  PRThreadPool* tp = (PRThreadPool*)arg;\n+  PRCList* head;\n+\n+  /*\n+   * execute jobs until shutdown\n+   */\n+  while (!tp->shutdown) {\n+    PRJob* jobp;\n #ifdef OPT_WINNT\n-        BOOL rv;\n-        DWORD unused, shutdown;\n-        LPOVERLAPPED olp;\n-\n-        PR_Lock(tp->jobq.lock);\n-        tp->idle_threads++;\n-        PR_Unlock(tp->jobq.lock);\n-        rv = GetQueuedCompletionStatus(tp->jobq.nt_completion_port, &unused,\n-                                       &shutdown, &olp, INFINITE);\n-\n-        PR_ASSERT(rv);\n-        if (shutdown) {\n-            break;\n-        }\n-        jobp = ((NT_notifier*)olp)->jobp;\n-        PR_Lock(tp->jobq.lock);\n-        tp->idle_threads--;\n-        tp->jobq.cnt--;\n-        PR_Unlock(tp->jobq.lock);\n-#else\n+    BOOL rv;\n+    DWORD unused, shutdown;\n+    LPOVERLAPPED olp;\n \n-        PR_Lock(tp->jobq.lock);\n-        while (PR_CLIST_IS_EMPTY(&tp->jobq.list) && (!tp->shutdown)) {\n-            tp->idle_threads++;\n-            PR_WaitCondVar(tp->jobq.cv, PR_INTERVAL_NO_TIMEOUT);\n-            tp->idle_threads--;\n-        }\n-        if (tp->shutdown) {\n-            PR_Unlock(tp->jobq.lock);\n-            break;\n-        }\n-        head = PR_LIST_HEAD(&tp->jobq.list);\n-        /*\n-         * remove job from queue\n-         */\n-        PR_REMOVE_AND_INIT_LINK(head);\n-        tp->jobq.cnt--;\n-        jobp = JOB_LINKS_PTR(head);\n-        PR_Unlock(tp->jobq.lock);\n-#endif\n+    PR_Lock(tp->jobq.lock);\n+    tp->idle_threads++;\n+    PR_Unlock(tp->jobq.lock);\n+    rv = GetQueuedCompletionStatus(tp->jobq.nt_completion_port, &unused,\n+                                   &shutdown, &olp, INFINITE);\n \n-        jobp->job_func(jobp->job_arg);\n-        if (!JOINABLE_JOB(jobp)) {\n-            delete_job(jobp);\n-        } else {\n-            JOIN_NOTIFY(jobp);\n-        }\n+    PR_ASSERT(rv);\n+    if (shutdown) {\n+      break;\n     }\n+    jobp = ((NT_notifier*)olp)->jobp;\n     PR_Lock(tp->jobq.lock);\n-    tp->current_threads--;\n+    tp->idle_threads--;\n+    tp->jobq.cnt--;\n     PR_Unlock(tp->jobq.lock);\n+#else\n+\n+    PR_Lock(tp->jobq.lock);\n+    while (PR_CLIST_IS_EMPTY(&tp->jobq.list) && (!tp->shutdown)) {\n+      tp->idle_threads++;\n+      PR_WaitCondVar(tp->jobq.cv, PR_INTERVAL_NO_TIMEOUT);\n+      tp->idle_threads--;\n+    }\n+    if (tp->shutdown) {\n+      PR_Unlock(tp->jobq.lock);\n+      break;\n+    }\n+    head = PR_LIST_HEAD(&tp->jobq.list);\n+    /*\n+     * remove job from queue\n+     */\n+    PR_REMOVE_AND_INIT_LINK(head);\n+    tp->jobq.cnt--;\n+    jobp = JOB_LINKS_PTR(head);\n+    PR_Unlock(tp->jobq.lock);\n+#endif\n+\n+    jobp->job_func(jobp->job_arg);\n+    if (!JOINABLE_JOB(jobp)) {\n+      delete_job(jobp);\n+    } else {\n+      JOIN_NOTIFY(jobp);\n+    }\n+  }\n+  PR_Lock(tp->jobq.lock);\n+  tp->current_threads--;\n+  PR_Unlock(tp->jobq.lock);\n }\n \n /*\n  * add a job to the work queue\n  */\n-static void\n-add_to_jobq(PRThreadPool* tp, PRJob* jobp)\n-{\n-    /*\n-     * add to jobq\n-     */\n+static void add_to_jobq(PRThreadPool* tp, PRJob* jobp) {\n+  /*\n+   * add to jobq\n+   */\n #ifdef OPT_WINNT\n-    PR_Lock(tp->jobq.lock);\n-    tp->jobq.cnt++;\n-    PR_Unlock(tp->jobq.lock);\n-    /*\n-     * notify worker thread(s)\n-     */\n-    PostQueuedCompletionStatus(tp->jobq.nt_completion_port, 0, FALSE,\n-                               &jobp->nt_notifier.overlapped);\n+  PR_Lock(tp->jobq.lock);\n+  tp->jobq.cnt++;\n+  PR_Unlock(tp->jobq.lock);\n+  /*\n+   * notify worker thread(s)\n+   */\n+  PostQueuedCompletionStatus(tp->jobq.nt_completion_port, 0, FALSE,\n+                             &jobp->nt_notifier.overlapped);\n #else\n-    PR_Lock(tp->jobq.lock);\n-    PR_APPEND_LINK(&jobp->links, &tp->jobq.list);\n-    tp->jobq.cnt++;\n-    if ((tp->idle_threads < tp->jobq.cnt) &&\n-        (tp->current_threads < tp->max_threads)) {\n-        wthread* wthrp;\n-        /*\n-         * increment thread count and unlock the jobq lock\n-         */\n-        tp->current_threads++;\n-        PR_Unlock(tp->jobq.lock);\n-        /* create new worker thread */\n-        wthrp = PR_NEWZAP(wthread);\n-        if (wthrp) {\n-            wthrp->thread =\n-                PR_CreateThread(PR_USER_THREAD, wstart, tp, PR_PRIORITY_NORMAL,\n-                                PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, tp->stacksize);\n-            if (NULL == wthrp->thread) {\n-                PR_DELETE(wthrp); /* this sets wthrp to NULL */\n-            }\n-        }\n-        PR_Lock(tp->jobq.lock);\n-        if (NULL == wthrp) {\n-            tp->current_threads--;\n-        } else {\n-            PR_APPEND_LINK(&wthrp->links, &tp->jobq.wthreads);\n-        }\n-    }\n+  PR_Lock(tp->jobq.lock);\n+  PR_APPEND_LINK(&jobp->links, &tp->jobq.list);\n+  tp->jobq.cnt++;\n+  if ((tp->idle_threads < tp->jobq.cnt) &&\n+      (tp->current_threads < tp->max_threads)) {\n+    wthread* wthrp;\n     /*\n-     * wakeup a worker thread\n+     * increment thread count and unlock the jobq lock\n      */\n-    PR_NotifyCondVar(tp->jobq.cv);\n+    tp->current_threads++;\n     PR_Unlock(tp->jobq.lock);\n+    /* create new worker thread */\n+    wthrp = PR_NEWZAP(wthread);\n+    if (wthrp) {\n+      wthrp->thread =\n+          PR_CreateThread(PR_USER_THREAD, wstart, tp, PR_PRIORITY_NORMAL,\n+                          PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, tp->stacksize);\n+      if (NULL == wthrp->thread) {\n+        PR_DELETE(wthrp); /* this sets wthrp to NULL */\n+      }\n+    }\n+    PR_Lock(tp->jobq.lock);\n+    if (NULL == wthrp) {\n+      tp->current_threads--;\n+    } else {\n+      PR_APPEND_LINK(&wthrp->links, &tp->jobq.wthreads);\n+    }\n+  }\n+  /*\n+   * wakeup a worker thread\n+   */\n+  PR_NotifyCondVar(tp->jobq.cv);\n+  PR_Unlock(tp->jobq.lock);\n #endif\n }\n \n /*\n  * io worker thread function\n  */\n-static void\n-io_wstart(void* arg)\n-{\n-    PRThreadPool* tp = (PRThreadPool*)arg;\n-    int pollfd_cnt, pollfds_used;\n-    int rv;\n-    PRCList *qp, *nextqp;\n-    PRPollDesc* pollfds = NULL;\n-    PRJob** polljobs = NULL;\n-    int poll_timeout;\n-    PRIntervalTime now;\n+static void io_wstart(void* arg) {\n+  PRThreadPool* tp = (PRThreadPool*)arg;\n+  int pollfd_cnt, pollfds_used;\n+  int rv;\n+  PRCList *qp, *nextqp;\n+  PRPollDesc* pollfds = NULL;\n+  PRJob** polljobs = NULL;\n+  int poll_timeout;\n+  PRIntervalTime now;\n+\n+  /*\n+   * scan io_jobq\n+   * construct poll list\n+   * call PR_Poll\n+   * for all fds, for which poll returns true, move the job to\n+   * jobq and wakeup worker thread.\n+   */\n+  while (!tp->shutdown) {\n+    PRJob* jobp;\n \n+    pollfd_cnt = tp->ioq.cnt + 10;\n+    if (pollfd_cnt > tp->ioq.npollfds) {\n+      /*\n+       * re-allocate pollfd array if the current one is not large\n+       * enough\n+       */\n+      if (NULL != tp->ioq.pollfds) {\n+        PR_Free(tp->ioq.pollfds);\n+      }\n+      tp->ioq.pollfds = (PRPollDesc*)PR_Malloc(\n+          pollfd_cnt * (sizeof(PRPollDesc) + sizeof(PRJob*)));\n+      PR_ASSERT(NULL != tp->ioq.pollfds);\n+      /*\n+       * array of pollfds\n+       */\n+      pollfds = tp->ioq.pollfds;\n+      tp->ioq.polljobs = (PRJob**)(&tp->ioq.pollfds[pollfd_cnt]);\n+      /*\n+       * parallel array of jobs\n+       */\n+      polljobs = tp->ioq.polljobs;\n+      tp->ioq.npollfds = pollfd_cnt;\n+    }\n+\n+    pollfds_used = 0;\n     /*\n-     * scan io_jobq\n-     * construct poll list\n-     * call PR_Poll\n-     * for all fds, for which poll returns true, move the job to\n-     * jobq and wakeup worker thread.\n+     * add the notify fd; used for unblocking io thread(s)\n      */\n-    while (!tp->shutdown) {\n-        PRJob* jobp;\n-\n-        pollfd_cnt = tp->ioq.cnt + 10;\n-        if (pollfd_cnt > tp->ioq.npollfds) {\n-            /*\n-             * re-allocate pollfd array if the current one is not large\n-             * enough\n-             */\n-            if (NULL != tp->ioq.pollfds) {\n-                PR_Free(tp->ioq.pollfds);\n-            }\n-            tp->ioq.pollfds = (PRPollDesc*)PR_Malloc(\n-                pollfd_cnt * (sizeof(PRPollDesc) + sizeof(PRJob*)));\n-            PR_ASSERT(NULL != tp->ioq.pollfds);\n-            /*\n-             * array of pollfds\n-             */\n-            pollfds = tp->ioq.pollfds;\n-            tp->ioq.polljobs = (PRJob**)(&tp->ioq.pollfds[pollfd_cnt]);\n-            /*\n-             * parallel array of jobs\n-             */\n-            polljobs = tp->ioq.polljobs;\n-            tp->ioq.npollfds = pollfd_cnt;\n-        }\n-\n-        pollfds_used = 0;\n-        /*\n-         * add the notify fd; used for unblocking io thread(s)\n-         */\n-        pollfds[pollfds_used].fd = tp->ioq.notify_fd;\n-        pollfds[pollfds_used].in_flags = PR_POLL_READ;\n-        pollfds[pollfds_used].out_flags = 0;\n-        polljobs[pollfds_used] = NULL;\n-        pollfds_used++;\n-        /*\n-         * fill in the pollfd array\n-         */\n-        PR_Lock(tp->ioq.lock);\n-        for (qp = tp->ioq.list.next; qp != &tp->ioq.list; qp = nextqp) {\n-            nextqp = qp->next;\n-            jobp = JOB_LINKS_PTR(qp);\n-            if (jobp->cancel_io) {\n-                CANCEL_IO_JOB(jobp);\n-                continue;\n-            }\n-            if (pollfds_used == (pollfd_cnt)) {\n-                break;\n-            }\n-            pollfds[pollfds_used].fd = jobp->iod->socket;\n-            pollfds[pollfds_used].in_flags = jobp->io_poll_flags;\n-            pollfds[pollfds_used].out_flags = 0;\n-            polljobs[pollfds_used] = jobp;\n-\n-            pollfds_used++;\n-        }\n-        if (!PR_CLIST_IS_EMPTY(&tp->ioq.list)) {\n-            qp = tp->ioq.list.next;\n-            jobp = JOB_LINKS_PTR(qp);\n-            if (PR_INTERVAL_NO_TIMEOUT == jobp->timeout) {\n-                poll_timeout = PR_INTERVAL_NO_TIMEOUT;\n-            } else if (PR_INTERVAL_NO_WAIT == jobp->timeout) {\n-                poll_timeout = PR_INTERVAL_NO_WAIT;\n-            } else {\n-                poll_timeout = jobp->absolute - PR_IntervalNow();\n-                if (poll_timeout <= 0) { /* already timed out */\n-                    poll_timeout = PR_INTERVAL_NO_WAIT;\n-                }\n-            }\n-        } else {\n-            poll_timeout = PR_INTERVAL_NO_TIMEOUT;\n+    pollfds[pollfds_used].fd = tp->ioq.notify_fd;\n+    pollfds[pollfds_used].in_flags = PR_POLL_READ;\n+    pollfds[pollfds_used].out_flags = 0;\n+    polljobs[pollfds_used] = NULL;\n+    pollfds_used++;\n+    /*\n+     * fill in the pollfd array\n+     */\n+    PR_Lock(tp->ioq.lock);\n+    for (qp = tp->ioq.list.next; qp != &tp->ioq.list; qp = nextqp) {\n+      nextqp = qp->next;\n+      jobp = JOB_LINKS_PTR(qp);\n+      if (jobp->cancel_io) {\n+        CANCEL_IO_JOB(jobp);\n+        continue;\n+      }\n+      if (pollfds_used == (pollfd_cnt)) {\n+        break;\n+      }\n+      pollfds[pollfds_used].fd = jobp->iod->socket;\n+      pollfds[pollfds_used].in_flags = jobp->io_poll_flags;\n+      pollfds[pollfds_used].out_flags = 0;\n+      polljobs[pollfds_used] = jobp;\n+\n+      pollfds_used++;\n+    }\n+    if (!PR_CLIST_IS_EMPTY(&tp->ioq.list)) {\n+      qp = tp->ioq.list.next;\n+      jobp = JOB_LINKS_PTR(qp);\n+      if (PR_INTERVAL_NO_TIMEOUT == jobp->timeout) {\n+        poll_timeout = PR_INTERVAL_NO_TIMEOUT;\n+      } else if (PR_INTERVAL_NO_WAIT == jobp->timeout) {\n+        poll_timeout = PR_INTERVAL_NO_WAIT;\n+      } else {\n+        poll_timeout = jobp->absolute - PR_IntervalNow();\n+        if (poll_timeout <= 0) { /* already timed out */\n+          poll_timeout = PR_INTERVAL_NO_WAIT;\n         }\n-        PR_Unlock(tp->ioq.lock);\n+      }\n+    } else {\n+      poll_timeout = PR_INTERVAL_NO_TIMEOUT;\n+    }\n+    PR_Unlock(tp->ioq.lock);\n \n-        /*\n-         * XXXX\n-         * should retry if more jobs have been added to the queue?\n-         *\n-         */\n-        PR_ASSERT(pollfds_used <= pollfd_cnt);\n-        rv = PR_Poll(tp->ioq.pollfds, pollfds_used, poll_timeout);\n+    /*\n+     * XXXX\n+     * should retry if more jobs have been added to the queue?\n+     *\n+     */\n+    PR_ASSERT(pollfds_used <= pollfd_cnt);\n+    rv = PR_Poll(tp->ioq.pollfds, pollfds_used, poll_timeout);\n \n-        if (tp->shutdown) {\n-            break;\n-        }\n+    if (tp->shutdown) {\n+      break;\n+    }\n \n-        if (rv > 0) {\n-            /*\n-             * at least one io event is set\n-             */\n-            PRStatus rval_status;\n-            PRInt32 index;\n-\n-            PR_ASSERT(pollfds[0].fd == tp->ioq.notify_fd);\n-            /*\n-             * reset the pollable event, if notified\n-             */\n-            if (pollfds[0].out_flags & PR_POLL_READ) {\n-                rval_status = PR_WaitForPollableEvent(tp->ioq.notify_fd);\n-                PR_ASSERT(PR_SUCCESS == rval_status);\n+    if (rv > 0) {\n+      /*\n+       * at least one io event is set\n+       */\n+      PRStatus rval_status;\n+      PRInt32 index;\n+\n+      PR_ASSERT(pollfds[0].fd == tp->ioq.notify_fd);\n+      /*\n+       * reset the pollable event, if notified\n+       */\n+      if (pollfds[0].out_flags & PR_POLL_READ) {\n+        rval_status = PR_WaitForPollableEvent(tp->ioq.notify_fd);\n+        PR_ASSERT(PR_SUCCESS == rval_status);\n+      }\n+\n+      for (index = 1; index < (pollfds_used); index++) {\n+        PRInt16 events = pollfds[index].in_flags;\n+        PRInt16 revents = pollfds[index].out_flags;\n+        jobp = polljobs[index];\n+\n+        if ((revents & PR_POLL_NVAL) || /* busted in all cases */\n+            (revents & PR_POLL_ERR) ||\n+            ((events & PR_POLL_WRITE) &&\n+             (revents & PR_POLL_HUP))) { /* write op & hup */\n+          PR_Lock(tp->ioq.lock);\n+          if (jobp->cancel_io) {\n+            CANCEL_IO_JOB(jobp);\n+            PR_Unlock(tp->ioq.lock);\n+            continue;\n+          }\n+          PR_REMOVE_AND_INIT_LINK(&jobp->links);\n+          tp->ioq.cnt--;\n+          jobp->on_ioq = PR_FALSE;\n+          PR_Unlock(tp->ioq.lock);\n+\n+          /* set error */\n+          if (PR_POLL_NVAL & revents) {\n+            jobp->iod->error = PR_BAD_DESCRIPTOR_ERROR;\n+          } else if (PR_POLL_HUP & revents) {\n+            jobp->iod->error = PR_CONNECT_RESET_ERROR;\n+          } else {\n+            jobp->iod->error = PR_IO_ERROR;\n+          }\n+\n+          /*\n+           * add to jobq\n+           */\n+          add_to_jobq(tp, jobp);\n+        } else if (revents) {\n+          /*\n+           * add to jobq\n+           */\n+          PR_Lock(tp->ioq.lock);\n+          if (jobp->cancel_io) {\n+            CANCEL_IO_JOB(jobp);\n+            PR_Unlock(tp->ioq.lock);\n+            continue;\n+          }\n+          PR_REMOVE_AND_INIT_LINK(&jobp->links);\n+          tp->ioq.cnt--;\n+          jobp->on_ioq = PR_FALSE;\n+          PR_Unlock(tp->ioq.lock);\n+\n+          if (jobp->io_op == JOB_IO_CONNECT) {\n+            if (PR_GetConnectStatus(&pollfds[index]) == PR_SUCCESS) {\n+              jobp->iod->error = 0;\n+            } else {\n+              jobp->iod->error = PR_GetError();\n             }\n+          } else {\n+            jobp->iod->error = 0;\n+          }\n \n-            for (index = 1; index < (pollfds_used); index++) {\n-                PRInt16 events = pollfds[index].in_flags;\n-                PRInt16 revents = pollfds[index].out_flags;\n-                jobp = polljobs[index];\n-\n-                if ((revents & PR_POLL_NVAL) || /* busted in all cases */\n-                    (revents & PR_POLL_ERR) ||\n-                    ((events & PR_POLL_WRITE) &&\n-                     (revents & PR_POLL_HUP))) { /* write op & hup */\n-                    PR_Lock(tp->ioq.lock);\n-                    if (jobp->cancel_io) {\n-                        CANCEL_IO_JOB(jobp);\n-                        PR_Unlock(tp->ioq.lock);\n-                        continue;\n-                    }\n-                    PR_REMOVE_AND_INIT_LINK(&jobp->links);\n-                    tp->ioq.cnt--;\n-                    jobp->on_ioq = PR_FALSE;\n-                    PR_Unlock(tp->ioq.lock);\n-\n-                    /* set error */\n-                    if (PR_POLL_NVAL & revents) {\n-                        jobp->iod->error = PR_BAD_DESCRIPTOR_ERROR;\n-                    } else if (PR_POLL_HUP & revents) {\n-                        jobp->iod->error = PR_CONNECT_RESET_ERROR;\n-                    } else {\n-                        jobp->iod->error = PR_IO_ERROR;\n-                    }\n-\n-                    /*\n-                     * add to jobq\n-                     */\n-                    add_to_jobq(tp, jobp);\n-                } else if (revents) {\n-                    /*\n-                     * add to jobq\n-                     */\n-                    PR_Lock(tp->ioq.lock);\n-                    if (jobp->cancel_io) {\n-                        CANCEL_IO_JOB(jobp);\n-                        PR_Unlock(tp->ioq.lock);\n-                        continue;\n-                    }\n-                    PR_REMOVE_AND_INIT_LINK(&jobp->links);\n-                    tp->ioq.cnt--;\n-                    jobp->on_ioq = PR_FALSE;\n-                    PR_Unlock(tp->ioq.lock);\n-\n-                    if (jobp->io_op == JOB_IO_CONNECT) {\n-                        if (PR_GetConnectStatus(&pollfds[index]) == PR_SUCCESS) {\n-                            jobp->iod->error = 0;\n-                        } else {\n-                            jobp->iod->error = PR_GetError();\n-                        }\n-                    } else {\n-                        jobp->iod->error = 0;\n-                    }\n-\n-                    add_to_jobq(tp, jobp);\n-                }\n-            }\n-        }\n-        /*\n-         * timeout processing\n-         */\n-        now = PR_IntervalNow();\n-        PR_Lock(tp->ioq.lock);\n-        for (qp = tp->ioq.list.next; qp != &tp->ioq.list; qp = nextqp) {\n-            nextqp = qp->next;\n-            jobp = JOB_LINKS_PTR(qp);\n-            if (jobp->cancel_io) {\n-                CANCEL_IO_JOB(jobp);\n-                continue;\n-            }\n-            if (PR_INTERVAL_NO_TIMEOUT == jobp->timeout) {\n-                break;\n-            }\n-            if ((PR_INTERVAL_NO_WAIT != jobp->timeout) &&\n-                ((PRInt32)(jobp->absolute - now) > 0)) {\n-                break;\n-            }\n-            PR_REMOVE_AND_INIT_LINK(&jobp->links);\n-            tp->ioq.cnt--;\n-            jobp->on_ioq = PR_FALSE;\n-            jobp->iod->error = PR_IO_TIMEOUT_ERROR;\n-            add_to_jobq(tp, jobp);\n+          add_to_jobq(tp, jobp);\n         }\n-        PR_Unlock(tp->ioq.lock);\n+      }\n+    }\n+    /*\n+     * timeout processing\n+     */\n+    now = PR_IntervalNow();\n+    PR_Lock(tp->ioq.lock);\n+    for (qp = tp->ioq.list.next; qp != &tp->ioq.list; qp = nextqp) {\n+      nextqp = qp->next;\n+      jobp = JOB_LINKS_PTR(qp);\n+      if (jobp->cancel_io) {\n+        CANCEL_IO_JOB(jobp);\n+        continue;\n+      }\n+      if (PR_INTERVAL_NO_TIMEOUT == jobp->timeout) {\n+        break;\n+      }\n+      if ((PR_INTERVAL_NO_WAIT != jobp->timeout) &&\n+          ((PRInt32)(jobp->absolute - now) > 0)) {\n+        break;\n+      }\n+      PR_REMOVE_AND_INIT_LINK(&jobp->links);\n+      tp->ioq.cnt--;\n+      jobp->on_ioq = PR_FALSE;\n+      jobp->iod->error = PR_IO_TIMEOUT_ERROR;\n+      add_to_jobq(tp, jobp);\n     }\n+    PR_Unlock(tp->ioq.lock);\n+  }\n }\n \n /*\n  * timer worker thread function\n  */\n-static void\n-timer_wstart(void* arg)\n-{\n-    PRThreadPool* tp = (PRThreadPool*)arg;\n-    PRCList* qp;\n-    PRIntervalTime timeout;\n-    PRIntervalTime now;\n-\n-    /*\n-     * call PR_WaitCondVar with minimum value of all timeouts\n-     */\n-    while (!tp->shutdown) {\n-        PRJob* jobp;\n+static void timer_wstart(void* arg) {\n+  PRThreadPool* tp = (PRThreadPool*)arg;\n+  PRCList* qp;\n+  PRIntervalTime timeout;\n+  PRIntervalTime now;\n+\n+  /*\n+   * call PR_WaitCondVar with minimum value of all timeouts\n+   */\n+  while (!tp->shutdown) {\n+    PRJob* jobp;\n \n-        PR_Lock(tp->timerq.lock);\n-        if (PR_CLIST_IS_EMPTY(&tp->timerq.list)) {\n-            timeout = PR_INTERVAL_NO_TIMEOUT;\n-        } else {\n-            PRCList* qp;\n+    PR_Lock(tp->timerq.lock);\n+    if (PR_CLIST_IS_EMPTY(&tp->timerq.list)) {\n+      timeout = PR_INTERVAL_NO_TIMEOUT;\n+    } else {\n+      PRCList* qp;\n \n-            qp = tp->timerq.list.next;\n-            jobp = JOB_LINKS_PTR(qp);\n+      qp = tp->timerq.list.next;\n+      jobp = JOB_LINKS_PTR(qp);\n \n-            timeout = jobp->absolute - PR_IntervalNow();\n-            if (timeout <= 0) {\n-                timeout = PR_INTERVAL_NO_WAIT; /* already timed out */\n-            }\n-        }\n-        if (PR_INTERVAL_NO_WAIT != timeout) {\n-            PR_WaitCondVar(tp->timerq.cv, timeout);\n-        }\n-        if (tp->shutdown) {\n-            PR_Unlock(tp->timerq.lock);\n-            break;\n-        }\n-        /*\n-         * move expired-timer jobs to jobq\n-         */\n-        now = PR_IntervalNow();\n-        while (!PR_CLIST_IS_EMPTY(&tp->timerq.list)) {\n-            qp = tp->timerq.list.next;\n-            jobp = JOB_LINKS_PTR(qp);\n-\n-            if ((PRInt32)(jobp->absolute - now) > 0) {\n-                break;\n-            }\n-            /*\n-             * job timed out\n-             */\n-            PR_REMOVE_AND_INIT_LINK(&jobp->links);\n-            tp->timerq.cnt--;\n-            jobp->on_timerq = PR_FALSE;\n-            add_to_jobq(tp, jobp);\n-        }\n-        PR_Unlock(tp->timerq.lock);\n+      timeout = jobp->absolute - PR_IntervalNow();\n+      if (timeout <= 0) {\n+        timeout = PR_INTERVAL_NO_WAIT; /* already timed out */\n+      }\n     }\n-}\n-\n-static void\n-delete_threadpool(PRThreadPool* tp)\n-{\n-    if (NULL != tp) {\n-        if (NULL != tp->shutdown_cv) {\n-            PR_DestroyCondVar(tp->shutdown_cv);\n-        }\n-        if (NULL != tp->jobq.cv) {\n-            PR_DestroyCondVar(tp->jobq.cv);\n-        }\n-        if (NULL != tp->jobq.lock) {\n-            PR_DestroyLock(tp->jobq.lock);\n-        }\n-        if (NULL != tp->join_lock) {\n-            PR_DestroyLock(tp->join_lock);\n-        }\n-#ifdef OPT_WINNT\n-        if (NULL != tp->jobq.nt_completion_port) {\n-            CloseHandle(tp->jobq.nt_completion_port);\n-        }\n-#endif\n-        /* Timer queue */\n-        if (NULL != tp->timerq.cv) {\n-            PR_DestroyCondVar(tp->timerq.cv);\n-        }\n-        if (NULL != tp->timerq.lock) {\n-            PR_DestroyLock(tp->timerq.lock);\n-        }\n-\n-        if (NULL != tp->ioq.lock) {\n-            PR_DestroyLock(tp->ioq.lock);\n-        }\n-        if (NULL != tp->ioq.pollfds) {\n-            PR_Free(tp->ioq.pollfds);\n-        }\n-        if (NULL != tp->ioq.notify_fd) {\n-            PR_DestroyPollableEvent(tp->ioq.notify_fd);\n-        }\n-        PR_Free(tp);\n+    if (PR_INTERVAL_NO_WAIT != timeout) {\n+      PR_WaitCondVar(tp->timerq.cv, timeout);\n+    }\n+    if (tp->shutdown) {\n+      PR_Unlock(tp->timerq.lock);\n+      break;\n     }\n-    return;\n+    /*\n+     * move expired-timer jobs to jobq\n+     */\n+    now = PR_IntervalNow();\n+    while (!PR_CLIST_IS_EMPTY(&tp->timerq.list)) {\n+      qp = tp->timerq.list.next;\n+      jobp = JOB_LINKS_PTR(qp);\n+\n+      if ((PRInt32)(jobp->absolute - now) > 0) {\n+        break;\n+      }\n+      /*\n+       * job timed out\n+       */\n+      PR_REMOVE_AND_INIT_LINK(&jobp->links);\n+      tp->timerq.cnt--;\n+      jobp->on_timerq = PR_FALSE;\n+      add_to_jobq(tp, jobp);\n+    }\n+    PR_Unlock(tp->timerq.lock);\n+  }\n }\n \n-static PRThreadPool*\n-alloc_threadpool(void)\n-{\n-    PRThreadPool* tp;\n-\n-    tp = (PRThreadPool*)PR_CALLOC(sizeof(*tp));\n-    if (NULL == tp) {\n-        goto failed;\n+static void delete_threadpool(PRThreadPool* tp) {\n+  if (NULL != tp) {\n+    if (NULL != tp->shutdown_cv) {\n+      PR_DestroyCondVar(tp->shutdown_cv);\n     }\n-    tp->jobq.lock = PR_NewLock();\n-    if (NULL == tp->jobq.lock) {\n-        goto failed;\n+    if (NULL != tp->jobq.cv) {\n+      PR_DestroyCondVar(tp->jobq.cv);\n     }\n-    tp->jobq.cv = PR_NewCondVar(tp->jobq.lock);\n-    if (NULL == tp->jobq.cv) {\n-        goto failed;\n+    if (NULL != tp->jobq.lock) {\n+      PR_DestroyLock(tp->jobq.lock);\n     }\n-    tp->join_lock = PR_NewLock();\n-    if (NULL == tp->join_lock) {\n-        goto failed;\n+    if (NULL != tp->join_lock) {\n+      PR_DestroyLock(tp->join_lock);\n     }\n #ifdef OPT_WINNT\n-    tp->jobq.nt_completion_port =\n-        CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);\n-    if (NULL == tp->jobq.nt_completion_port) {\n-        goto failed;\n+    if (NULL != tp->jobq.nt_completion_port) {\n+      CloseHandle(tp->jobq.nt_completion_port);\n     }\n #endif\n-\n-    tp->ioq.lock = PR_NewLock();\n-    if (NULL == tp->ioq.lock) {\n-        goto failed;\n-    }\n-\n     /* Timer queue */\n-\n-    tp->timerq.lock = PR_NewLock();\n-    if (NULL == tp->timerq.lock) {\n-        goto failed;\n+    if (NULL != tp->timerq.cv) {\n+      PR_DestroyCondVar(tp->timerq.cv);\n     }\n-    tp->timerq.cv = PR_NewCondVar(tp->timerq.lock);\n-    if (NULL == tp->timerq.cv) {\n-        goto failed;\n+    if (NULL != tp->timerq.lock) {\n+      PR_DestroyLock(tp->timerq.lock);\n     }\n \n-    tp->shutdown_cv = PR_NewCondVar(tp->jobq.lock);\n-    if (NULL == tp->shutdown_cv) {\n-        goto failed;\n+    if (NULL != tp->ioq.lock) {\n+      PR_DestroyLock(tp->ioq.lock);\n+    }\n+    if (NULL != tp->ioq.pollfds) {\n+      PR_Free(tp->ioq.pollfds);\n     }\n-    tp->ioq.notify_fd = PR_NewPollableEvent();\n-    if (NULL == tp->ioq.notify_fd) {\n-        goto failed;\n+    if (NULL != tp->ioq.notify_fd) {\n+      PR_DestroyPollableEvent(tp->ioq.notify_fd);\n     }\n-    return tp;\n+    PR_Free(tp);\n+  }\n+  return;\n+}\n+\n+static PRThreadPool* alloc_threadpool(void) {\n+  PRThreadPool* tp;\n+\n+  tp = (PRThreadPool*)PR_CALLOC(sizeof(*tp));\n+  if (NULL == tp) {\n+    goto failed;\n+  }\n+  tp->jobq.lock = PR_NewLock();\n+  if (NULL == tp->jobq.lock) {\n+    goto failed;\n+  }\n+  tp->jobq.cv = PR_NewCondVar(tp->jobq.lock);\n+  if (NULL == tp->jobq.cv) {\n+    goto failed;\n+  }\n+  tp->join_lock = PR_NewLock();\n+  if (NULL == tp->join_lock) {\n+    goto failed;\n+  }\n+#ifdef OPT_WINNT\n+  tp->jobq.nt_completion_port =\n+      CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);\n+  if (NULL == tp->jobq.nt_completion_port) {\n+    goto failed;\n+  }\n+#endif\n+\n+  tp->ioq.lock = PR_NewLock();\n+  if (NULL == tp->ioq.lock) {\n+    goto failed;\n+  }\n+\n+  /* Timer queue */\n+\n+  tp->timerq.lock = PR_NewLock();\n+  if (NULL == tp->timerq.lock) {\n+    goto failed;\n+  }\n+  tp->timerq.cv = PR_NewCondVar(tp->timerq.lock);\n+  if (NULL == tp->timerq.cv) {\n+    goto failed;\n+  }\n+\n+  tp->shutdown_cv = PR_NewCondVar(tp->jobq.lock);\n+  if (NULL == tp->shutdown_cv) {\n+    goto failed;\n+  }\n+  tp->ioq.notify_fd = PR_NewPollableEvent();\n+  if (NULL == tp->ioq.notify_fd) {\n+    goto failed;\n+  }\n+  return tp;\n failed:\n-    delete_threadpool(tp);\n-    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-    return NULL;\n+  delete_threadpool(tp);\n+  PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  return NULL;\n }\n \n /* Create thread pool */\n PR_IMPLEMENT(PRThreadPool*)\n PR_CreateThreadPool(PRInt32 initial_threads, PRInt32 max_threads,\n-                    PRUint32 stacksize)\n-{\n-    PRThreadPool* tp;\n-    PRThread* thr;\n-    int i;\n-    wthread* wthrp;\n-\n-    tp = alloc_threadpool();\n-    if (NULL == tp) {\n-        return NULL;\n-    }\n-\n-    tp->init_threads = initial_threads;\n-    tp->max_threads = max_threads;\n-    tp->stacksize = stacksize;\n-    PR_INIT_CLIST(&tp->jobq.list);\n-    PR_INIT_CLIST(&tp->ioq.list);\n-    PR_INIT_CLIST(&tp->timerq.list);\n-    PR_INIT_CLIST(&tp->jobq.wthreads);\n-    PR_INIT_CLIST(&tp->ioq.wthreads);\n-    PR_INIT_CLIST(&tp->timerq.wthreads);\n-    tp->shutdown = PR_FALSE;\n-\n-    PR_Lock(tp->jobq.lock);\n-    for (i = 0; i < initial_threads; ++i) {\n-        thr = PR_CreateThread(PR_USER_THREAD, wstart, tp, PR_PRIORITY_NORMAL,\n-                              PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, stacksize);\n-        PR_ASSERT(thr);\n-        wthrp = PR_NEWZAP(wthread);\n-        PR_ASSERT(wthrp);\n-        wthrp->thread = thr;\n-        PR_APPEND_LINK(&wthrp->links, &tp->jobq.wthreads);\n-    }\n-    tp->current_threads = initial_threads;\n-\n-    thr = PR_CreateThread(PR_USER_THREAD, io_wstart, tp, PR_PRIORITY_NORMAL,\n-                          PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, stacksize);\n-    PR_ASSERT(thr);\n-    wthrp = PR_NEWZAP(wthread);\n-    PR_ASSERT(wthrp);\n-    wthrp->thread = thr;\n-    PR_APPEND_LINK(&wthrp->links, &tp->ioq.wthreads);\n-\n-    thr = PR_CreateThread(PR_USER_THREAD, timer_wstart, tp, PR_PRIORITY_NORMAL,\n+                    PRUint32 stacksize) {\n+  PRThreadPool* tp;\n+  PRThread* thr;\n+  int i;\n+  wthread* wthrp;\n+\n+  tp = alloc_threadpool();\n+  if (NULL == tp) {\n+    return NULL;\n+  }\n+\n+  tp->init_threads = initial_threads;\n+  tp->max_threads = max_threads;\n+  tp->stacksize = stacksize;\n+  PR_INIT_CLIST(&tp->jobq.list);\n+  PR_INIT_CLIST(&tp->ioq.list);\n+  PR_INIT_CLIST(&tp->timerq.list);\n+  PR_INIT_CLIST(&tp->jobq.wthreads);\n+  PR_INIT_CLIST(&tp->ioq.wthreads);\n+  PR_INIT_CLIST(&tp->timerq.wthreads);\n+  tp->shutdown = PR_FALSE;\n+\n+  PR_Lock(tp->jobq.lock);\n+  for (i = 0; i < initial_threads; ++i) {\n+    thr = PR_CreateThread(PR_USER_THREAD, wstart, tp, PR_PRIORITY_NORMAL,\n                           PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, stacksize);\n     PR_ASSERT(thr);\n     wthrp = PR_NEWZAP(wthread);\n     PR_ASSERT(wthrp);\n     wthrp->thread = thr;\n-    PR_APPEND_LINK(&wthrp->links, &tp->timerq.wthreads);\n-\n-    PR_Unlock(tp->jobq.lock);\n-    return tp;\n+    PR_APPEND_LINK(&wthrp->links, &tp->jobq.wthreads);\n+  }\n+  tp->current_threads = initial_threads;\n+\n+  thr = PR_CreateThread(PR_USER_THREAD, io_wstart, tp, PR_PRIORITY_NORMAL,\n+                        PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, stacksize);\n+  PR_ASSERT(thr);\n+  wthrp = PR_NEWZAP(wthread);\n+  PR_ASSERT(wthrp);\n+  wthrp->thread = thr;\n+  PR_APPEND_LINK(&wthrp->links, &tp->ioq.wthreads);\n+\n+  thr = PR_CreateThread(PR_USER_THREAD, timer_wstart, tp, PR_PRIORITY_NORMAL,\n+                        PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, stacksize);\n+  PR_ASSERT(thr);\n+  wthrp = PR_NEWZAP(wthread);\n+  PR_ASSERT(wthrp);\n+  wthrp->thread = thr;\n+  PR_APPEND_LINK(&wthrp->links, &tp->timerq.wthreads);\n+\n+  PR_Unlock(tp->jobq.lock);\n+  return tp;\n }\n \n-static void\n-delete_job(PRJob* jobp)\n-{\n-    if (NULL != jobp) {\n-        if (NULL != jobp->join_cv) {\n-            PR_DestroyCondVar(jobp->join_cv);\n-            jobp->join_cv = NULL;\n-        }\n-        if (NULL != jobp->cancel_cv) {\n-            PR_DestroyCondVar(jobp->cancel_cv);\n-            jobp->cancel_cv = NULL;\n-        }\n-        PR_DELETE(jobp);\n+static void delete_job(PRJob* jobp) {\n+  if (NULL != jobp) {\n+    if (NULL != jobp->join_cv) {\n+      PR_DestroyCondVar(jobp->join_cv);\n+      jobp->join_cv = NULL;\n     }\n+    if (NULL != jobp->cancel_cv) {\n+      PR_DestroyCondVar(jobp->cancel_cv);\n+      jobp->cancel_cv = NULL;\n+    }\n+    PR_DELETE(jobp);\n+  }\n }\n \n-static PRJob*\n-alloc_job(PRBool joinable, PRThreadPool* tp)\n-{\n-    PRJob* jobp;\n-\n-    jobp = PR_NEWZAP(PRJob);\n-    if (NULL == jobp) {\n-        goto failed;\n-    }\n-    if (joinable) {\n-        jobp->join_cv = PR_NewCondVar(tp->join_lock);\n-        jobp->join_wait = PR_TRUE;\n-        if (NULL == jobp->join_cv) {\n-            goto failed;\n-        }\n-    } else {\n-        jobp->join_cv = NULL;\n+static PRJob* alloc_job(PRBool joinable, PRThreadPool* tp) {\n+  PRJob* jobp;\n+\n+  jobp = PR_NEWZAP(PRJob);\n+  if (NULL == jobp) {\n+    goto failed;\n+  }\n+  if (joinable) {\n+    jobp->join_cv = PR_NewCondVar(tp->join_lock);\n+    jobp->join_wait = PR_TRUE;\n+    if (NULL == jobp->join_cv) {\n+      goto failed;\n     }\n+  } else {\n+    jobp->join_cv = NULL;\n+  }\n #ifdef OPT_WINNT\n-    jobp->nt_notifier.jobp = jobp;\n+  jobp->nt_notifier.jobp = jobp;\n #endif\n-    return jobp;\n+  return jobp;\n failed:\n-    delete_job(jobp);\n-    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-    return NULL;\n+  delete_job(jobp);\n+  PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  return NULL;\n }\n \n /* queue a job */\n PR_IMPLEMENT(PRJob*)\n-PR_QueueJob(PRThreadPool* tpool, PRJobFn fn, void* arg, PRBool joinable)\n-{\n-    PRJob* jobp;\n+PR_QueueJob(PRThreadPool* tpool, PRJobFn fn, void* arg, PRBool joinable) {\n+  PRJob* jobp;\n \n-    jobp = alloc_job(joinable, tpool);\n-    if (NULL == jobp) {\n-        return NULL;\n-    }\n+  jobp = alloc_job(joinable, tpool);\n+  if (NULL == jobp) {\n+    return NULL;\n+  }\n \n-    jobp->job_func = fn;\n-    jobp->job_arg = arg;\n-    jobp->tpool = tpool;\n+  jobp->job_func = fn;\n+  jobp->job_arg = arg;\n+  jobp->tpool = tpool;\n \n-    add_to_jobq(tpool, jobp);\n-    return jobp;\n+  add_to_jobq(tpool, jobp);\n+  return jobp;\n }\n \n /* queue a job, when a socket is readable or writeable */\n-static PRJob*\n-queue_io_job(PRThreadPool* tpool, PRJobIoDesc* iod, PRJobFn fn,\n-             void* arg, PRBool joinable, io_op_type op)\n-{\n-    PRJob* jobp;\n-    PRIntervalTime now;\n+static PRJob* queue_io_job(PRThreadPool* tpool, PRJobIoDesc* iod, PRJobFn fn,\n+                           void* arg, PRBool joinable, io_op_type op) {\n+  PRJob* jobp;\n+  PRIntervalTime now;\n \n-    jobp = alloc_job(joinable, tpool);\n-    if (NULL == jobp) {\n-        return NULL;\n-    }\n-\n-    /*\n-     * Add a new job to io_jobq\n-     * wakeup io worker thread\n-     */\n-\n-    jobp->job_func = fn;\n-    jobp->job_arg = arg;\n-    jobp->tpool = tpool;\n-    jobp->iod = iod;\n-    if (JOB_IO_READ == op) {\n-        jobp->io_op = JOB_IO_READ;\n-        jobp->io_poll_flags = PR_POLL_READ;\n-    } else if (JOB_IO_WRITE == op) {\n-        jobp->io_op = JOB_IO_WRITE;\n-        jobp->io_poll_flags = PR_POLL_WRITE;\n-    } else if (JOB_IO_ACCEPT == op) {\n-        jobp->io_op = JOB_IO_ACCEPT;\n-        jobp->io_poll_flags = PR_POLL_READ;\n-    } else if (JOB_IO_CONNECT == op) {\n-        jobp->io_op = JOB_IO_CONNECT;\n-        jobp->io_poll_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;\n-    } else {\n-        delete_job(jobp);\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return NULL;\n-    }\n+  jobp = alloc_job(joinable, tpool);\n+  if (NULL == jobp) {\n+    return NULL;\n+  }\n+\n+  /*\n+   * Add a new job to io_jobq\n+   * wakeup io worker thread\n+   */\n+\n+  jobp->job_func = fn;\n+  jobp->job_arg = arg;\n+  jobp->tpool = tpool;\n+  jobp->iod = iod;\n+  if (JOB_IO_READ == op) {\n+    jobp->io_op = JOB_IO_READ;\n+    jobp->io_poll_flags = PR_POLL_READ;\n+  } else if (JOB_IO_WRITE == op) {\n+    jobp->io_op = JOB_IO_WRITE;\n+    jobp->io_poll_flags = PR_POLL_WRITE;\n+  } else if (JOB_IO_ACCEPT == op) {\n+    jobp->io_op = JOB_IO_ACCEPT;\n+    jobp->io_poll_flags = PR_POLL_READ;\n+  } else if (JOB_IO_CONNECT == op) {\n+    jobp->io_op = JOB_IO_CONNECT;\n+    jobp->io_poll_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;\n+  } else {\n+    delete_job(jobp);\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return NULL;\n+  }\n \n-    jobp->timeout = iod->timeout;\n-    if ((PR_INTERVAL_NO_TIMEOUT == iod->timeout) ||\n-        (PR_INTERVAL_NO_WAIT == iod->timeout)) {\n-        jobp->absolute = iod->timeout;\n-    } else {\n-        now = PR_IntervalNow();\n-        jobp->absolute = now + iod->timeout;\n-    }\n+  jobp->timeout = iod->timeout;\n+  if ((PR_INTERVAL_NO_TIMEOUT == iod->timeout) ||\n+      (PR_INTERVAL_NO_WAIT == iod->timeout)) {\n+    jobp->absolute = iod->timeout;\n+  } else {\n+    now = PR_IntervalNow();\n+    jobp->absolute = now + iod->timeout;\n+  }\n \n-    PR_Lock(tpool->ioq.lock);\n+  PR_Lock(tpool->ioq.lock);\n \n-    if (PR_CLIST_IS_EMPTY(&tpool->ioq.list) ||\n-        (PR_INTERVAL_NO_TIMEOUT == iod->timeout)) {\n-        PR_APPEND_LINK(&jobp->links, &tpool->ioq.list);\n-    } else if (PR_INTERVAL_NO_WAIT == iod->timeout) {\n-        PR_INSERT_LINK(&jobp->links, &tpool->ioq.list);\n-    } else {\n-        PRCList* qp;\n-        PRJob* tmp_jobp;\n-        /*\n-         * insert into the timeout-sorted ioq\n-         */\n-        for (qp = tpool->ioq.list.prev; qp != &tpool->ioq.list; qp = qp->prev) {\n-            tmp_jobp = JOB_LINKS_PTR(qp);\n-            if ((PRInt32)(jobp->absolute - tmp_jobp->absolute) >= 0) {\n-                break;\n-            }\n-        }\n-        PR_INSERT_AFTER(&jobp->links, qp);\n-    }\n-\n-    jobp->on_ioq = PR_TRUE;\n-    tpool->ioq.cnt++;\n+  if (PR_CLIST_IS_EMPTY(&tpool->ioq.list) ||\n+      (PR_INTERVAL_NO_TIMEOUT == iod->timeout)) {\n+    PR_APPEND_LINK(&jobp->links, &tpool->ioq.list);\n+  } else if (PR_INTERVAL_NO_WAIT == iod->timeout) {\n+    PR_INSERT_LINK(&jobp->links, &tpool->ioq.list);\n+  } else {\n+    PRCList* qp;\n+    PRJob* tmp_jobp;\n     /*\n-     * notify io worker thread(s)\n+     * insert into the timeout-sorted ioq\n      */\n-    PR_Unlock(tpool->ioq.lock);\n-    notify_ioq(tpool);\n-    return jobp;\n+    for (qp = tpool->ioq.list.prev; qp != &tpool->ioq.list; qp = qp->prev) {\n+      tmp_jobp = JOB_LINKS_PTR(qp);\n+      if ((PRInt32)(jobp->absolute - tmp_jobp->absolute) >= 0) {\n+        break;\n+      }\n+    }\n+    PR_INSERT_AFTER(&jobp->links, qp);\n+  }\n+\n+  jobp->on_ioq = PR_TRUE;\n+  tpool->ioq.cnt++;\n+  /*\n+   * notify io worker thread(s)\n+   */\n+  PR_Unlock(tpool->ioq.lock);\n+  notify_ioq(tpool);\n+  return jobp;\n }\n \n /* queue a job, when a socket is readable */\n PR_IMPLEMENT(PRJob*)\n PR_QueueJob_Read(PRThreadPool* tpool, PRJobIoDesc* iod, PRJobFn fn, void* arg,\n-                 PRBool joinable)\n-{\n-    return (queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_READ));\n+                 PRBool joinable) {\n+  return (queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_READ));\n }\n \n /* queue a job, when a socket is writeable */\n PR_IMPLEMENT(PRJob*)\n PR_QueueJob_Write(PRThreadPool* tpool, PRJobIoDesc* iod, PRJobFn fn, void* arg,\n-                  PRBool joinable)\n-{\n-    return (queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_WRITE));\n+                  PRBool joinable) {\n+  return (queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_WRITE));\n }\n \n /* queue a job, when a socket has a pending connection */\n PR_IMPLEMENT(PRJob*)\n PR_QueueJob_Accept(PRThreadPool* tpool, PRJobIoDesc* iod, PRJobFn fn, void* arg,\n-                   PRBool joinable)\n-{\n-    return (queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_ACCEPT));\n+                   PRBool joinable) {\n+  return (queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_ACCEPT));\n }\n \n /* queue a job, when a socket can be connected */\n PR_IMPLEMENT(PRJob*)\n PR_QueueJob_Connect(PRThreadPool* tpool, PRJobIoDesc* iod,\n                     const PRNetAddr* addr, PRJobFn fn, void* arg,\n-                    PRBool joinable)\n-{\n-    PRStatus rv;\n-    PRErrorCode err;\n-\n-    rv = PR_Connect(iod->socket, addr, PR_INTERVAL_NO_WAIT);\n-    if ((rv == PR_FAILURE) && ((err = PR_GetError()) == PR_IN_PROGRESS_ERROR)) {\n-        /* connection pending */\n-        return (queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_CONNECT));\n-    }\n-    /*\n-     * connection succeeded or failed; add to jobq right away\n-     */\n-    if (rv == PR_FAILURE) {\n-        iod->error = err;\n-    } else {\n-        iod->error = 0;\n-    }\n-    return (PR_QueueJob(tpool, fn, arg, joinable));\n+                    PRBool joinable) {\n+  PRStatus rv;\n+  PRErrorCode err;\n+\n+  rv = PR_Connect(iod->socket, addr, PR_INTERVAL_NO_WAIT);\n+  if ((rv == PR_FAILURE) && ((err = PR_GetError()) == PR_IN_PROGRESS_ERROR)) {\n+    /* connection pending */\n+    return (queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_CONNECT));\n+  }\n+  /*\n+   * connection succeeded or failed; add to jobq right away\n+   */\n+  if (rv == PR_FAILURE) {\n+    iod->error = err;\n+  } else {\n+    iod->error = 0;\n+  }\n+  return (PR_QueueJob(tpool, fn, arg, joinable));\n }\n \n /* queue a job, when a timer expires */\n PR_IMPLEMENT(PRJob*)\n PR_QueueJob_Timer(PRThreadPool* tpool, PRIntervalTime timeout, PRJobFn fn,\n-                  void* arg, PRBool joinable)\n-{\n-    PRIntervalTime now;\n-    PRJob* jobp;\n-\n-    if (PR_INTERVAL_NO_TIMEOUT == timeout) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return NULL;\n-    }\n-    if (PR_INTERVAL_NO_WAIT == timeout) {\n-        /*\n-         * no waiting; add to jobq right away\n-         */\n-        return (PR_QueueJob(tpool, fn, arg, joinable));\n-    }\n-    jobp = alloc_job(joinable, tpool);\n-    if (NULL == jobp) {\n-        return NULL;\n-    }\n+                  void* arg, PRBool joinable) {\n+  PRIntervalTime now;\n+  PRJob* jobp;\n \n+  if (PR_INTERVAL_NO_TIMEOUT == timeout) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return NULL;\n+  }\n+  if (PR_INTERVAL_NO_WAIT == timeout) {\n     /*\n-     * Add a new job to timer_jobq\n-     * wakeup timer worker thread\n+     * no waiting; add to jobq right away\n      */\n-\n-    jobp->job_func = fn;\n-    jobp->job_arg = arg;\n-    jobp->tpool = tpool;\n-    jobp->timeout = timeout;\n-\n-    now = PR_IntervalNow();\n-    jobp->absolute = now + timeout;\n-\n-    PR_Lock(tpool->timerq.lock);\n-    jobp->on_timerq = PR_TRUE;\n-    if (PR_CLIST_IS_EMPTY(&tpool->timerq.list)) {\n-        PR_APPEND_LINK(&jobp->links, &tpool->timerq.list);\n-    } else {\n-        PRCList* qp;\n-        PRJob* tmp_jobp;\n-        /*\n-         * insert into the sorted timer jobq\n-         */\n-        for (qp = tpool->timerq.list.prev; qp != &tpool->timerq.list;\n-             qp = qp->prev) {\n-            tmp_jobp = JOB_LINKS_PTR(qp);\n-            if ((PRInt32)(jobp->absolute - tmp_jobp->absolute) >= 0) {\n-                break;\n-            }\n-        }\n-        PR_INSERT_AFTER(&jobp->links, qp);\n-    }\n-    tpool->timerq.cnt++;\n+    return (PR_QueueJob(tpool, fn, arg, joinable));\n+  }\n+  jobp = alloc_job(joinable, tpool);\n+  if (NULL == jobp) {\n+    return NULL;\n+  }\n+\n+  /*\n+   * Add a new job to timer_jobq\n+   * wakeup timer worker thread\n+   */\n+\n+  jobp->job_func = fn;\n+  jobp->job_arg = arg;\n+  jobp->tpool = tpool;\n+  jobp->timeout = timeout;\n+\n+  now = PR_IntervalNow();\n+  jobp->absolute = now + timeout;\n+\n+  PR_Lock(tpool->timerq.lock);\n+  jobp->on_timerq = PR_TRUE;\n+  if (PR_CLIST_IS_EMPTY(&tpool->timerq.list)) {\n+    PR_APPEND_LINK(&jobp->links, &tpool->timerq.list);\n+  } else {\n+    PRCList* qp;\n+    PRJob* tmp_jobp;\n     /*\n-     * notify timer worker thread(s)\n+     * insert into the sorted timer jobq\n      */\n-    notify_timerq(tpool);\n-    PR_Unlock(tpool->timerq.lock);\n-    return jobp;\n+    for (qp = tpool->timerq.list.prev; qp != &tpool->timerq.list;\n+         qp = qp->prev) {\n+      tmp_jobp = JOB_LINKS_PTR(qp);\n+      if ((PRInt32)(jobp->absolute - tmp_jobp->absolute) >= 0) {\n+        break;\n+      }\n+    }\n+    PR_INSERT_AFTER(&jobp->links, qp);\n+  }\n+  tpool->timerq.cnt++;\n+  /*\n+   * notify timer worker thread(s)\n+   */\n+  notify_timerq(tpool);\n+  PR_Unlock(tpool->timerq.lock);\n+  return jobp;\n }\n \n-static void\n-notify_timerq(PRThreadPool* tp)\n-{\n-    /*\n-     * wakeup the timer thread(s)\n-     */\n-    PR_NotifyCondVar(tp->timerq.cv);\n+static void notify_timerq(PRThreadPool* tp) {\n+  /*\n+   * wakeup the timer thread(s)\n+   */\n+  PR_NotifyCondVar(tp->timerq.cv);\n }\n \n-static void\n-notify_ioq(PRThreadPool* tp)\n-{\n-    PRStatus rval_status;\n+static void notify_ioq(PRThreadPool* tp) {\n+  PRStatus rval_status;\n \n-    /*\n-     * wakeup the io thread(s)\n-     */\n-    rval_status = PR_SetPollableEvent(tp->ioq.notify_fd);\n-    PR_ASSERT(PR_SUCCESS == rval_status);\n+  /*\n+   * wakeup the io thread(s)\n+   */\n+  rval_status = PR_SetPollableEvent(tp->ioq.notify_fd);\n+  PR_ASSERT(PR_SUCCESS == rval_status);\n }\n \n /*\n@@ -998,105 +970,102 @@ notify_ioq(PRThreadPool* tp)\n  *  XXXX: is this needed? likely to be removed\n  */\n PR_IMPLEMENT(PRStatus)\n-PR_CancelJob(PRJob* jobp)\n-{\n-    PRStatus rval = PR_FAILURE;\n-    PRThreadPool* tp;\n+PR_CancelJob(PRJob* jobp) {\n+  PRStatus rval = PR_FAILURE;\n+  PRThreadPool* tp;\n \n+  if (jobp->on_timerq) {\n+    /*\n+     * now, check again while holding the timerq lock\n+     */\n+    tp = jobp->tpool;\n+    PR_Lock(tp->timerq.lock);\n     if (jobp->on_timerq) {\n-        /*\n-         * now, check again while holding the timerq lock\n-         */\n-        tp = jobp->tpool;\n-        PR_Lock(tp->timerq.lock);\n-        if (jobp->on_timerq) {\n-            jobp->on_timerq = PR_FALSE;\n-            PR_REMOVE_AND_INIT_LINK(&jobp->links);\n-            tp->timerq.cnt--;\n-            PR_Unlock(tp->timerq.lock);\n-            if (!JOINABLE_JOB(jobp)) {\n-                delete_job(jobp);\n-            } else {\n-                JOIN_NOTIFY(jobp);\n-            }\n-            rval = PR_SUCCESS;\n-        } else {\n-            PR_Unlock(tp->timerq.lock);\n-        }\n-    } else if (jobp->on_ioq) {\n-        /*\n-         * now, check again while holding the ioq lock\n-         */\n-        tp = jobp->tpool;\n-        PR_Lock(tp->ioq.lock);\n-        if (jobp->on_ioq) {\n-            jobp->cancel_cv = PR_NewCondVar(tp->ioq.lock);\n-            if (NULL == jobp->cancel_cv) {\n-                PR_Unlock(tp->ioq.lock);\n-                PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n-                return PR_FAILURE;\n-            }\n-            /*\n-             * mark job 'cancelled' and notify io thread(s)\n-             * XXXX:\n-             *      this assumes there is only one io thread; when there\n-             *      are multiple threads, the io thread processing this job\n-             *      must be notified.\n-             */\n-            jobp->cancel_io = PR_TRUE;\n-            PR_Unlock(tp->ioq.lock); /* release, reacquire ioq lock */\n-            notify_ioq(tp);\n-            PR_Lock(tp->ioq.lock);\n-            while (jobp->cancel_io) {\n-                PR_WaitCondVar(jobp->cancel_cv, PR_INTERVAL_NO_TIMEOUT);\n-            }\n-            PR_Unlock(tp->ioq.lock);\n-            PR_ASSERT(!jobp->on_ioq);\n-            if (!JOINABLE_JOB(jobp)) {\n-                delete_job(jobp);\n-            } else {\n-                JOIN_NOTIFY(jobp);\n-            }\n-            rval = PR_SUCCESS;\n-        } else {\n-            PR_Unlock(tp->ioq.lock);\n-        }\n+      jobp->on_timerq = PR_FALSE;\n+      PR_REMOVE_AND_INIT_LINK(&jobp->links);\n+      tp->timerq.cnt--;\n+      PR_Unlock(tp->timerq.lock);\n+      if (!JOINABLE_JOB(jobp)) {\n+        delete_job(jobp);\n+      } else {\n+        JOIN_NOTIFY(jobp);\n+      }\n+      rval = PR_SUCCESS;\n+    } else {\n+      PR_Unlock(tp->timerq.lock);\n     }\n-    if (PR_FAILURE == rval) {\n-        PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+  } else if (jobp->on_ioq) {\n+    /*\n+     * now, check again while holding the ioq lock\n+     */\n+    tp = jobp->tpool;\n+    PR_Lock(tp->ioq.lock);\n+    if (jobp->on_ioq) {\n+      jobp->cancel_cv = PR_NewCondVar(tp->ioq.lock);\n+      if (NULL == jobp->cancel_cv) {\n+        PR_Unlock(tp->ioq.lock);\n+        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n+        return PR_FAILURE;\n+      }\n+      /*\n+       * mark job 'cancelled' and notify io thread(s)\n+       * XXXX:\n+       *      this assumes there is only one io thread; when there\n+       *      are multiple threads, the io thread processing this job\n+       *      must be notified.\n+       */\n+      jobp->cancel_io = PR_TRUE;\n+      PR_Unlock(tp->ioq.lock); /* release, reacquire ioq lock */\n+      notify_ioq(tp);\n+      PR_Lock(tp->ioq.lock);\n+      while (jobp->cancel_io) {\n+        PR_WaitCondVar(jobp->cancel_cv, PR_INTERVAL_NO_TIMEOUT);\n+      }\n+      PR_Unlock(tp->ioq.lock);\n+      PR_ASSERT(!jobp->on_ioq);\n+      if (!JOINABLE_JOB(jobp)) {\n+        delete_job(jobp);\n+      } else {\n+        JOIN_NOTIFY(jobp);\n+      }\n+      rval = PR_SUCCESS;\n+    } else {\n+      PR_Unlock(tp->ioq.lock);\n     }\n-    return rval;\n+  }\n+  if (PR_FAILURE == rval) {\n+    PR_SetError(PR_INVALID_STATE_ERROR, 0);\n+  }\n+  return rval;\n }\n \n /* join a job, wait until completion */\n PR_IMPLEMENT(PRStatus)\n-PR_JoinJob(PRJob* jobp)\n-{\n-    if (!JOINABLE_JOB(jobp)) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    PR_Lock(jobp->tpool->join_lock);\n-    while (jobp->join_wait) {\n-        PR_WaitCondVar(jobp->join_cv, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_Unlock(jobp->tpool->join_lock);\n-    delete_job(jobp);\n-    return PR_SUCCESS;\n+PR_JoinJob(PRJob* jobp) {\n+  if (!JOINABLE_JOB(jobp)) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  PR_Lock(jobp->tpool->join_lock);\n+  while (jobp->join_wait) {\n+    PR_WaitCondVar(jobp->join_cv, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_Unlock(jobp->tpool->join_lock);\n+  delete_job(jobp);\n+  return PR_SUCCESS;\n }\n \n /* shutdown threadpool */\n PR_IMPLEMENT(PRStatus)\n-PR_ShutdownThreadPool(PRThreadPool* tpool)\n-{\n-    PRStatus rval = PR_SUCCESS;\n+PR_ShutdownThreadPool(PRThreadPool* tpool) {\n+  PRStatus rval = PR_SUCCESS;\n \n-    PR_Lock(tpool->jobq.lock);\n-    tpool->shutdown = PR_TRUE;\n-    PR_NotifyAllCondVar(tpool->shutdown_cv);\n-    PR_Unlock(tpool->jobq.lock);\n+  PR_Lock(tpool->jobq.lock);\n+  tpool->shutdown = PR_TRUE;\n+  PR_NotifyAllCondVar(tpool->shutdown_cv);\n+  PR_Unlock(tpool->jobq.lock);\n \n-    return rval;\n+  return rval;\n }\n \n /*\n@@ -1105,120 +1074,119 @@ PR_ShutdownThreadPool(PRThreadPool* tpool)\n  *  reclaim threadpool resources\n  */\n PR_IMPLEMENT(PRStatus)\n-PR_JoinThreadPool(PRThreadPool* tpool)\n-{\n-    PRStatus rval = PR_SUCCESS;\n-    PRCList* head;\n-    PRStatus rval_status;\n-\n-    PR_Lock(tpool->jobq.lock);\n-    while (!tpool->shutdown) {\n-        PR_WaitCondVar(tpool->shutdown_cv, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-\n-    /*\n-     * wakeup worker threads\n-     */\n+PR_JoinThreadPool(PRThreadPool* tpool) {\n+  PRStatus rval = PR_SUCCESS;\n+  PRCList* head;\n+  PRStatus rval_status;\n+\n+  PR_Lock(tpool->jobq.lock);\n+  while (!tpool->shutdown) {\n+    PR_WaitCondVar(tpool->shutdown_cv, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+\n+  /*\n+   * wakeup worker threads\n+   */\n #ifdef OPT_WINNT\n-    /*\n-     * post shutdown notification for all threads\n-     */\n-    {\n-        int i;\n-        for (i = 0; i < tpool->current_threads; i++) {\n-            PostQueuedCompletionStatus(tpool->jobq.nt_completion_port, 0, TRUE, NULL);\n-        }\n+  /*\n+   * post shutdown notification for all threads\n+   */\n+  {\n+    int i;\n+    for (i = 0; i < tpool->current_threads; i++) {\n+      PostQueuedCompletionStatus(tpool->jobq.nt_completion_port, 0, TRUE, NULL);\n     }\n+  }\n #else\n-    PR_NotifyAllCondVar(tpool->jobq.cv);\n+  PR_NotifyAllCondVar(tpool->jobq.cv);\n #endif\n \n-    /*\n-     * wakeup io thread(s)\n-     */\n-    notify_ioq(tpool);\n+  /*\n+   * wakeup io thread(s)\n+   */\n+  notify_ioq(tpool);\n \n-    /*\n-     * wakeup timer thread(s)\n-     */\n-    PR_Lock(tpool->timerq.lock);\n-    notify_timerq(tpool);\n-    PR_Unlock(tpool->timerq.lock);\n-\n-    while (!PR_CLIST_IS_EMPTY(&tpool->jobq.wthreads)) {\n-        wthread* wthrp;\n-\n-        head = PR_LIST_HEAD(&tpool->jobq.wthreads);\n-        PR_REMOVE_AND_INIT_LINK(head);\n-        PR_Unlock(tpool->jobq.lock);\n-        wthrp = WTHREAD_LINKS_PTR(head);\n-        rval_status = PR_JoinThread(wthrp->thread);\n-        PR_ASSERT(PR_SUCCESS == rval_status);\n-        PR_DELETE(wthrp);\n-        PR_Lock(tpool->jobq.lock);\n-    }\n+  /*\n+   * wakeup timer thread(s)\n+   */\n+  PR_Lock(tpool->timerq.lock);\n+  notify_timerq(tpool);\n+  PR_Unlock(tpool->timerq.lock);\n+\n+  while (!PR_CLIST_IS_EMPTY(&tpool->jobq.wthreads)) {\n+    wthread* wthrp;\n+\n+    head = PR_LIST_HEAD(&tpool->jobq.wthreads);\n+    PR_REMOVE_AND_INIT_LINK(head);\n     PR_Unlock(tpool->jobq.lock);\n-    while (!PR_CLIST_IS_EMPTY(&tpool->ioq.wthreads)) {\n-        wthread* wthrp;\n+    wthrp = WTHREAD_LINKS_PTR(head);\n+    rval_status = PR_JoinThread(wthrp->thread);\n+    PR_ASSERT(PR_SUCCESS == rval_status);\n+    PR_DELETE(wthrp);\n+    PR_Lock(tpool->jobq.lock);\n+  }\n+  PR_Unlock(tpool->jobq.lock);\n+  while (!PR_CLIST_IS_EMPTY(&tpool->ioq.wthreads)) {\n+    wthread* wthrp;\n \n-        head = PR_LIST_HEAD(&tpool->ioq.wthreads);\n-        PR_REMOVE_AND_INIT_LINK(head);\n-        wthrp = WTHREAD_LINKS_PTR(head);\n-        rval_status = PR_JoinThread(wthrp->thread);\n-        PR_ASSERT(PR_SUCCESS == rval_status);\n-        PR_DELETE(wthrp);\n-    }\n+    head = PR_LIST_HEAD(&tpool->ioq.wthreads);\n+    PR_REMOVE_AND_INIT_LINK(head);\n+    wthrp = WTHREAD_LINKS_PTR(head);\n+    rval_status = PR_JoinThread(wthrp->thread);\n+    PR_ASSERT(PR_SUCCESS == rval_status);\n+    PR_DELETE(wthrp);\n+  }\n \n-    while (!PR_CLIST_IS_EMPTY(&tpool->timerq.wthreads)) {\n-        wthread* wthrp;\n+  while (!PR_CLIST_IS_EMPTY(&tpool->timerq.wthreads)) {\n+    wthread* wthrp;\n \n-        head = PR_LIST_HEAD(&tpool->timerq.wthreads);\n-        PR_REMOVE_AND_INIT_LINK(head);\n-        wthrp = WTHREAD_LINKS_PTR(head);\n-        rval_status = PR_JoinThread(wthrp->thread);\n-        PR_ASSERT(PR_SUCCESS == rval_status);\n-        PR_DELETE(wthrp);\n-    }\n+    head = PR_LIST_HEAD(&tpool->timerq.wthreads);\n+    PR_REMOVE_AND_INIT_LINK(head);\n+    wthrp = WTHREAD_LINKS_PTR(head);\n+    rval_status = PR_JoinThread(wthrp->thread);\n+    PR_ASSERT(PR_SUCCESS == rval_status);\n+    PR_DELETE(wthrp);\n+  }\n \n-    /*\n-     * Delete queued jobs\n-     */\n-    while (!PR_CLIST_IS_EMPTY(&tpool->jobq.list)) {\n-        PRJob* jobp;\n+  /*\n+   * Delete queued jobs\n+   */\n+  while (!PR_CLIST_IS_EMPTY(&tpool->jobq.list)) {\n+    PRJob* jobp;\n \n-        head = PR_LIST_HEAD(&tpool->jobq.list);\n-        PR_REMOVE_AND_INIT_LINK(head);\n-        jobp = JOB_LINKS_PTR(head);\n-        tpool->jobq.cnt--;\n-        delete_job(jobp);\n-    }\n+    head = PR_LIST_HEAD(&tpool->jobq.list);\n+    PR_REMOVE_AND_INIT_LINK(head);\n+    jobp = JOB_LINKS_PTR(head);\n+    tpool->jobq.cnt--;\n+    delete_job(jobp);\n+  }\n \n-    /* delete io jobs */\n-    while (!PR_CLIST_IS_EMPTY(&tpool->ioq.list)) {\n-        PRJob* jobp;\n+  /* delete io jobs */\n+  while (!PR_CLIST_IS_EMPTY(&tpool->ioq.list)) {\n+    PRJob* jobp;\n \n-        head = PR_LIST_HEAD(&tpool->ioq.list);\n-        PR_REMOVE_AND_INIT_LINK(head);\n-        tpool->ioq.cnt--;\n-        jobp = JOB_LINKS_PTR(head);\n-        delete_job(jobp);\n-    }\n+    head = PR_LIST_HEAD(&tpool->ioq.list);\n+    PR_REMOVE_AND_INIT_LINK(head);\n+    tpool->ioq.cnt--;\n+    jobp = JOB_LINKS_PTR(head);\n+    delete_job(jobp);\n+  }\n \n-    /* delete timer jobs */\n-    while (!PR_CLIST_IS_EMPTY(&tpool->timerq.list)) {\n-        PRJob* jobp;\n+  /* delete timer jobs */\n+  while (!PR_CLIST_IS_EMPTY(&tpool->timerq.list)) {\n+    PRJob* jobp;\n \n-        head = PR_LIST_HEAD(&tpool->timerq.list);\n-        PR_REMOVE_AND_INIT_LINK(head);\n-        tpool->timerq.cnt--;\n-        jobp = JOB_LINKS_PTR(head);\n-        delete_job(jobp);\n-    }\n+    head = PR_LIST_HEAD(&tpool->timerq.list);\n+    PR_REMOVE_AND_INIT_LINK(head);\n+    tpool->timerq.cnt--;\n+    jobp = JOB_LINKS_PTR(head);\n+    delete_job(jobp);\n+  }\n \n-    PR_ASSERT(0 == tpool->jobq.cnt);\n-    PR_ASSERT(0 == tpool->ioq.cnt);\n-    PR_ASSERT(0 == tpool->timerq.cnt);\n+  PR_ASSERT(0 == tpool->jobq.cnt);\n+  PR_ASSERT(0 == tpool->ioq.cnt);\n+  PR_ASSERT(0 == tpool->timerq.cnt);\n \n-    delete_threadpool(tpool);\n-    return rval;\n+  delete_threadpool(tpool);\n+  return rval;\n }\ndiff --git a/nspr/pr/src/misc/prtrace.c b/nspr/pr/src/misc/prtrace.c\nindex 461cf51..718acfa 100644\n--- a/nspr/pr/src/misc/prtrace.c\n+++ b/nspr/pr/src/misc/prtrace.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -20,28 +21,27 @@\n /*\n ** Enumerate states in a RName structure\n */\n-typedef enum TraceState { Running = 1,\n-                          Suspended = 2 } TraceState;\n+typedef enum TraceState { Running = 1, Suspended = 2 } TraceState;\n \n /*\n ** Define QName structure\n */\n typedef struct QName {\n-    PRCList link;\n-    PRCList rNameList;\n-    char name[PRTRACE_NAME_MAX + 1];\n+  PRCList link;\n+  PRCList rNameList;\n+  char name[PRTRACE_NAME_MAX + 1];\n } QName;\n \n /*\n ** Define RName structure\n */\n typedef struct RName {\n-    PRCList link;\n-    PRLock* lock;\n-    QName* qName;\n-    TraceState state;\n-    char name[PRTRACE_NAME_MAX + 1];\n-    char desc[PRTRACE_DESC_MAX + 1];\n+  PRCList link;\n+  PRLock* lock;\n+  QName* qName;\n+  TraceState state;\n+  char name[PRTRACE_NAME_MAX + 1];\n+  char desc[PRTRACE_DESC_MAX + 1];\n } RName;\n \n /*\n@@ -59,7 +59,7 @@ static TraceState traceState = Running;\n */\n static PRTraceEntry* tBuf; /* pointer to buffer */\n static PRInt32\n-    bufSize;                  /* size of buffer, in bytes, rounded up to sizeof(PRTraceEntry) */\n+    bufSize; /* size of buffer, in bytes, rounded up to sizeof(PRTraceEntry) */\n static volatile PRInt32 next; /* index to next PRTraceEntry */\n static PRInt32 last;          /* index of highest numbered trace entry */\n \n@@ -84,12 +84,12 @@ static PRCondVar* logCVar; /* Sync Condidtion Variable */\n **\n */\n static enum LogState {\n-    LogNotRunning, /* Initial state */\n-    LogReset,      /* Causes logger to re-calc controls */\n-    LogActive,     /* Logging in progress, set only by log thread */\n-    LogSuspend,    /* Suspend Logging */\n-    LogResume,     /* Resume Logging => LogActive */\n-    LogStop        /* Stop the log thread */\n+  LogNotRunning, /* Initial state */\n+  LogReset,      /* Causes logger to re-calc controls */\n+  LogActive,     /* Logging in progress, set only by log thread */\n+  LogSuspend,    /* Suspend Logging */\n+  LogResume,     /* Resume Logging => LogActive */\n+  LogStop        /* Stop the log thread */\n } logOrder,\n     logState, localState;   /* controlling state variables */\n static PRInt32 logSegments; /* Number of buffer segments */\n@@ -108,70 +108,66 @@ static PRInt32 logLostData; /* number of lost log buffer segments */\n /*\n ** _PR_InitializeTrace() -- Initialize the trace facility\n */\n-static void\n-NewTraceBuffer(PRInt32 size)\n-{\n-    /*\n-    ** calculate the size of the buffer\n-    ** round down so that each segment has the same number of\n-    ** trace entries\n-    */\n-    logSegments = DEFAULT_BUFFER_SEGMENTS;\n-    logEntries = size / sizeof(PRTraceEntry);\n-    logEntriesPerSegment = logEntries / logSegments;\n-    logEntries = logSegments * logEntriesPerSegment;\n-    bufSize = logEntries * sizeof(PRTraceEntry);\n-    logSegSize = logEntriesPerSegment * sizeof(PRTraceEntry);\n-    PR_ASSERT(bufSize != 0);\n-    PR_LOG(lm, PR_LOG_ERROR,\n-           (\"NewTraceBuffer: logSegments: %ld, logEntries: %ld, \"\n-            \"logEntriesPerSegment: %ld, logSegSize: %ld\",\n-            logSegments, logEntries, logEntriesPerSegment, logSegSize));\n-\n-    tBuf = PR_Malloc(bufSize);\n-    if (tBuf == NULL) {\n-        PR_LOG(lm, PR_LOG_ERROR, (\"PRTrace: Failed to get trace buffer\"));\n-        PR_ASSERT(0);\n-    } else {\n-        PR_LOG(lm, PR_LOG_NOTICE,\n-               (\"PRTrace: Got trace buffer of size: %ld, at %p\", bufSize, tBuf));\n-    }\n-\n-    next = 0;\n-    last = logEntries - 1;\n-    logCount = 0;\n-    logLostData = PR_TRUE; /* not really on first call */\n-    logOrder = LogReset;\n+static void NewTraceBuffer(PRInt32 size) {\n+  /*\n+  ** calculate the size of the buffer\n+  ** round down so that each segment has the same number of\n+  ** trace entries\n+  */\n+  logSegments = DEFAULT_BUFFER_SEGMENTS;\n+  logEntries = size / sizeof(PRTraceEntry);\n+  logEntriesPerSegment = logEntries / logSegments;\n+  logEntries = logSegments * logEntriesPerSegment;\n+  bufSize = logEntries * sizeof(PRTraceEntry);\n+  logSegSize = logEntriesPerSegment * sizeof(PRTraceEntry);\n+  PR_ASSERT(bufSize != 0);\n+  PR_LOG(lm, PR_LOG_ERROR,\n+         (\"NewTraceBuffer: logSegments: %ld, logEntries: %ld, \"\n+          \"logEntriesPerSegment: %ld, logSegSize: %ld\",\n+          logSegments, logEntries, logEntriesPerSegment, logSegSize));\n+\n+  tBuf = PR_Malloc(bufSize);\n+  if (tBuf == NULL) {\n+    PR_LOG(lm, PR_LOG_ERROR, (\"PRTrace: Failed to get trace buffer\"));\n+    PR_ASSERT(0);\n+  } else {\n+    PR_LOG(lm, PR_LOG_NOTICE,\n+           (\"PRTrace: Got trace buffer of size: %ld, at %p\", bufSize, tBuf));\n+  }\n+\n+  next = 0;\n+  last = logEntries - 1;\n+  logCount = 0;\n+  logLostData = PR_TRUE; /* not really on first call */\n+  logOrder = LogReset;\n \n } /* end NewTraceBuffer() */\n \n /*\n ** _PR_InitializeTrace() -- Initialize the trace facility\n */\n-static void\n-_PR_InitializeTrace(void)\n-{\n-    /* The lock pointer better be null on this call */\n-    PR_ASSERT(traceLock == NULL);\n+static void _PR_InitializeTrace(void) {\n+  /* The lock pointer better be null on this call */\n+  PR_ASSERT(traceLock == NULL);\n \n-    traceLock = PR_NewLock();\n-    PR_ASSERT(traceLock != NULL);\n+  traceLock = PR_NewLock();\n+  PR_ASSERT(traceLock != NULL);\n \n-    PR_Lock(traceLock);\n+  PR_Lock(traceLock);\n \n-    PR_INIT_CLIST(&qNameList);\n+  PR_INIT_CLIST(&qNameList);\n \n-    lm = PR_NewLogModule(\"trace\");\n+  lm = PR_NewLogModule(\"trace\");\n \n-    bufSize = DEFAULT_TRACE_BUFSIZE;\n-    NewTraceBuffer(bufSize);\n+  bufSize = DEFAULT_TRACE_BUFSIZE;\n+  NewTraceBuffer(bufSize);\n \n-    /* Initialize logging controls */\n-    logLock = PR_NewLock();\n-    logCVar = PR_NewCondVar(logLock);\n+  /* Initialize logging controls */\n+  logLock = PR_NewLock();\n+  logCVar = PR_NewCondVar(logLock);\n \n-    PR_Unlock(traceLock);\n-    return;\n+  PR_Unlock(traceLock);\n+  return;\n } /* end _PR_InitializeTrace() */\n \n /*\n@@ -181,89 +177,88 @@ PR_IMPLEMENT(PRTraceHandle)\n PR_CreateTrace(const char* qName,      /* QName for this trace handle */\n                const char* rName,      /* RName for this trace handle */\n                const char* description /* description for this trace handle */\n-)\n-{\n-    QName* qnp;\n-    RName* rnp;\n-    PRBool matchQname = PR_FALSE;\n-\n-    /* Self initialize, if necessary */\n-    if (traceLock == NULL) {\n-        _PR_InitializeTrace();\n-    }\n-\n-    /* Validate input arguments */\n-    PR_ASSERT(strlen(qName) <= PRTRACE_NAME_MAX);\n-    PR_ASSERT(strlen(rName) <= PRTRACE_NAME_MAX);\n-    PR_ASSERT(strlen(description) <= PRTRACE_DESC_MAX);\n-\n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PRTRACE: CreateTrace: Qname: %s, RName: %s\", qName, rName));\n-\n-    /* Lock the Facility */\n-    PR_Lock(traceLock);\n-\n-    /* Do we already have a matching QName? */\n-    if (!PR_CLIST_IS_EMPTY(&qNameList)) {\n-        qnp = (QName*)PR_LIST_HEAD(&qNameList);\n-        do {\n-            if (strcmp(qnp->name, qName) == 0) {\n-                matchQname = PR_TRUE;\n-                break;\n-            }\n-            qnp = (QName*)PR_NEXT_LINK(&qnp->link);\n-        } while (qnp != (QName*)&qNameList);\n-    }\n-    /*\n-    ** If we did not find a matching QName,\n-    **    allocate one and initialize it.\n-    **    link it onto the qNameList.\n-    **\n-    */\n-    if (matchQname != PR_TRUE) {\n-        qnp = PR_NEWZAP(QName);\n-        PR_ASSERT(qnp != NULL);\n-        PR_INIT_CLIST(&qnp->link);\n-        PR_INIT_CLIST(&qnp->rNameList);\n-        strcpy(qnp->name, qName);\n-        PR_APPEND_LINK(&qnp->link, &qNameList);\n-    }\n-\n-    /* Do we already have a matching RName? */\n-    if (!PR_CLIST_IS_EMPTY(&qnp->rNameList)) {\n-        rnp = (RName*)PR_LIST_HEAD(&qnp->rNameList);\n-        do {\n-            /*\n-            ** No duplicate RNames are allowed within a QName\n-            **\n-            */\n-            PR_ASSERT(strcmp(rnp->name, rName));\n-            rnp = (RName*)PR_NEXT_LINK(&rnp->link);\n-        } while (rnp != (RName*)&qnp->rNameList);\n-    }\n-\n-    /* Get a new RName structure; initialize its members */\n-    rnp = PR_NEWZAP(RName);\n-    PR_ASSERT(rnp != NULL);\n-    PR_INIT_CLIST(&rnp->link);\n-    strcpy(rnp->name, rName);\n-    strcpy(rnp->desc, description);\n-    rnp->lock = PR_NewLock();\n-    rnp->state = Running;\n-    if (rnp->lock == NULL) {\n-        PR_ASSERT(0);\n-    }\n-\n-    PR_APPEND_LINK(&rnp->link, &qnp->rNameList); /* add RName to QName's rnList */\n-    rnp->qName = qnp;                            /* point the RName to the QName */\n-\n-    /* Unlock the Facility */\n-    PR_Unlock(traceLock);\n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PRTrace: Create: QName: %s %p, RName: %s %p\\n\\t\", qName, qnp, rName,\n-            rnp));\n-\n-    return ((PRTraceHandle)rnp);\n+) {\n+  QName* qnp;\n+  RName* rnp;\n+  PRBool matchQname = PR_FALSE;\n+\n+  /* Self initialize, if necessary */\n+  if (traceLock == NULL) {\n+    _PR_InitializeTrace();\n+  }\n+\n+  /* Validate input arguments */\n+  PR_ASSERT(strlen(qName) <= PRTRACE_NAME_MAX);\n+  PR_ASSERT(strlen(rName) <= PRTRACE_NAME_MAX);\n+  PR_ASSERT(strlen(description) <= PRTRACE_DESC_MAX);\n+\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PRTRACE: CreateTrace: Qname: %s, RName: %s\", qName, rName));\n+\n+  /* Lock the Facility */\n+  PR_Lock(traceLock);\n+\n+  /* Do we already have a matching QName? */\n+  if (!PR_CLIST_IS_EMPTY(&qNameList)) {\n+    qnp = (QName*)PR_LIST_HEAD(&qNameList);\n+    do {\n+      if (strcmp(qnp->name, qName) == 0) {\n+        matchQname = PR_TRUE;\n+        break;\n+      }\n+      qnp = (QName*)PR_NEXT_LINK(&qnp->link);\n+    } while (qnp != (QName*)&qNameList);\n+  }\n+  /*\n+  ** If we did not find a matching QName,\n+  **    allocate one and initialize it.\n+  **    link it onto the qNameList.\n+  **\n+  */\n+  if (matchQname != PR_TRUE) {\n+    qnp = PR_NEWZAP(QName);\n+    PR_ASSERT(qnp != NULL);\n+    PR_INIT_CLIST(&qnp->link);\n+    PR_INIT_CLIST(&qnp->rNameList);\n+    strcpy(qnp->name, qName);\n+    PR_APPEND_LINK(&qnp->link, &qNameList);\n+  }\n+\n+  /* Do we already have a matching RName? */\n+  if (!PR_CLIST_IS_EMPTY(&qnp->rNameList)) {\n+    rnp = (RName*)PR_LIST_HEAD(&qnp->rNameList);\n+    do {\n+      /*\n+      ** No duplicate RNames are allowed within a QName\n+      **\n+      */\n+      PR_ASSERT(strcmp(rnp->name, rName));\n+      rnp = (RName*)PR_NEXT_LINK(&rnp->link);\n+    } while (rnp != (RName*)&qnp->rNameList);\n+  }\n+\n+  /* Get a new RName structure; initialize its members */\n+  rnp = PR_NEWZAP(RName);\n+  PR_ASSERT(rnp != NULL);\n+  PR_INIT_CLIST(&rnp->link);\n+  strcpy(rnp->name, rName);\n+  strcpy(rnp->desc, description);\n+  rnp->lock = PR_NewLock();\n+  rnp->state = Running;\n+  if (rnp->lock == NULL) {\n+    PR_ASSERT(0);\n+  }\n+\n+  PR_APPEND_LINK(&rnp->link, &qnp->rNameList); /* add RName to QName's rnList */\n+  rnp->qName = qnp; /* point the RName to the QName */\n+\n+  /* Unlock the Facility */\n+  PR_Unlock(traceLock);\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PRTrace: Create: QName: %s %p, RName: %s %p\\n\\t\", qName, qnp, rName,\n+          rnp));\n+\n+  return ((PRTraceHandle)rnp);\n } /* end  PR_CreateTrace() */\n \n /*\n@@ -271,40 +266,39 @@ PR_CreateTrace(const char* qName,      /* QName for this trace handle */\n */\n PR_IMPLEMENT(void)\n PR_DestroyTrace(PRTraceHandle handle /* Handle to be destroyed */\n-)\n-{\n-    RName* rnp = (RName*)handle;\n-    QName* qnp = rnp->qName;\n-\n+) {\n+  RName* rnp = (RName*)handle;\n+  QName* qnp = rnp->qName;\n+\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PRTrace: Deleting: QName: %s, RName: %s\", qnp->name, rnp->name));\n+\n+  /* Lock the Facility */\n+  PR_Lock(traceLock);\n+\n+  /*\n+  ** Remove RName from the list of RNames in QName\n+  ** and free RName\n+  */\n+  PR_LOG(lm, PR_LOG_DEBUG, (\"PRTrace: Deleting RName: %s, %p\", rnp->name, rnp));\n+  PR_REMOVE_LINK(&rnp->link);\n+  PR_Free(rnp->lock);\n+  PR_DELETE(rnp);\n+\n+  /*\n+  ** If this is the last RName within QName\n+  **   remove QName from the qNameList and free it\n+  */\n+  if (PR_CLIST_IS_EMPTY(&qnp->rNameList)) {\n     PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PRTrace: Deleting: QName: %s, RName: %s\", qnp->name, rnp->name));\n-\n-    /* Lock the Facility */\n-    PR_Lock(traceLock);\n-\n-    /*\n-    ** Remove RName from the list of RNames in QName\n-    ** and free RName\n-    */\n-    PR_LOG(lm, PR_LOG_DEBUG, (\"PRTrace: Deleting RName: %s, %p\", rnp->name, rnp));\n-    PR_REMOVE_LINK(&rnp->link);\n-    PR_Free(rnp->lock);\n-    PR_DELETE(rnp);\n-\n-    /*\n-    ** If this is the last RName within QName\n-    **   remove QName from the qNameList and free it\n-    */\n-    if (PR_CLIST_IS_EMPTY(&qnp->rNameList)) {\n-        PR_LOG(lm, PR_LOG_DEBUG,\n-               (\"PRTrace: Deleting unused QName: %s, %p\", qnp->name, qnp));\n-        PR_REMOVE_LINK(&qnp->link);\n-        PR_DELETE(qnp);\n-    }\n-\n-    /* Unlock the Facility */\n-    PR_Unlock(traceLock);\n-    return;\n+           (\"PRTrace: Deleting unused QName: %s, %p\", qnp->name, qnp));\n+    PR_REMOVE_LINK(&qnp->link);\n+    PR_DELETE(qnp);\n+  }\n+\n+  /* Unlock the Facility */\n+  PR_Unlock(traceLock);\n+  return;\n } /* end PR_DestroyTrace()  */\n \n /*\n@@ -320,66 +314,65 @@ PR_Trace(PRTraceHandle handle, /* use this trace handle */\n          PRUint32 userData5,   /* User supplied data word 5 */\n          PRUint32 userData6,   /* User supplied data word 6 */\n          PRUint32 userData7    /* User supplied data word 7 */\n-)\n-{\n-    PRTraceEntry* tep;\n-    PRInt32 mark;\n-\n-    if ((traceState == Suspended) || (((RName*)handle)->state == Suspended)) {\n-        return;\n-    }\n+) {\n+  PRTraceEntry* tep;\n+  PRInt32 mark;\n \n-    /*\n-    ** Get the next trace entry slot w/ minimum delay\n-    */\n-    PR_Lock(traceLock);\n-\n-    tep = &tBuf[next++];\n-    if (next > last) {\n-        next = 0;\n-    }\n-    if (fetchLostData == PR_FALSE && next == fetchLastSeen) {\n-        fetchLostData = PR_TRUE;\n-    }\n-\n-    mark = next;\n+  if ((traceState == Suspended) || (((RName*)handle)->state == Suspended)) {\n+    return;\n+  }\n \n-    PR_Unlock(traceLock);\n+  /*\n+  ** Get the next trace entry slot w/ minimum delay\n+  */\n+  PR_Lock(traceLock);\n \n+  tep = &tBuf[next++];\n+  if (next > last) {\n+    next = 0;\n+  }\n+  if (fetchLostData == PR_FALSE && next == fetchLastSeen) {\n+    fetchLostData = PR_TRUE;\n+  }\n+\n+  mark = next;\n+\n+  PR_Unlock(traceLock);\n+\n+  /*\n+  ** We have a trace entry. Fill it in.\n+  */\n+  tep->thread = PR_GetCurrentThread();\n+  tep->handle = handle;\n+  tep->time = PR_Now();\n+  tep->userData[0] = userData0;\n+  tep->userData[1] = userData1;\n+  tep->userData[2] = userData2;\n+  tep->userData[3] = userData3;\n+  tep->userData[4] = userData4;\n+  tep->userData[5] = userData5;\n+  tep->userData[6] = userData6;\n+  tep->userData[7] = userData7;\n+\n+  /* When buffer segment is full, signal trace log thread to run */\n+  if ((mark % logEntriesPerSegment) == 0) {\n+    PR_Lock(logLock);\n+    logCount++;\n+    PR_NotifyCondVar(logCVar);\n+    PR_Unlock(logLock);\n     /*\n-    ** We have a trace entry. Fill it in.\n+    ** Gh0D! This is awful!\n+    ** Anyway, to minimize lost trace data segments,\n+    ** I inserted the PR_Sleep(0) to cause a context switch\n+    ** so that the log thread could run.\n+    ** I know, it perturbs the universe and may cause\n+    ** funny things to happen in the optimized builds.\n+    ** Take it out, lose data; leave it in risk Heisenberg.\n     */\n-    tep->thread = PR_GetCurrentThread();\n-    tep->handle = handle;\n-    tep->time = PR_Now();\n-    tep->userData[0] = userData0;\n-    tep->userData[1] = userData1;\n-    tep->userData[2] = userData2;\n-    tep->userData[3] = userData3;\n-    tep->userData[4] = userData4;\n-    tep->userData[5] = userData5;\n-    tep->userData[6] = userData6;\n-    tep->userData[7] = userData7;\n-\n-    /* When buffer segment is full, signal trace log thread to run */\n-    if ((mark % logEntriesPerSegment) == 0) {\n-        PR_Lock(logLock);\n-        logCount++;\n-        PR_NotifyCondVar(logCVar);\n-        PR_Unlock(logLock);\n-        /*\n-        ** Gh0D! This is awful!\n-        ** Anyway, to minimize lost trace data segments,\n-        ** I inserted the PR_Sleep(0) to cause a context switch\n-        ** so that the log thread could run.\n-        ** I know, it perturbs the universe and may cause\n-        ** funny things to happen in the optimized builds.\n-        ** Take it out, lose data; leave it in risk Heisenberg.\n-        */\n-        /* PR_Sleep(0); */\n-    }\n+    /* PR_Sleep(0); */\n+  }\n \n-    return;\n+  return;\n } /* end PR_Trace() */\n \n /*\n@@ -388,87 +381,86 @@ PR_Trace(PRTraceHandle handle, /* use this trace handle */\n PR_IMPLEMENT(void)\n PR_SetTraceOption(PRTraceOption command, /* One of the enumerated values */\n                   void* value            /* command value or NULL */\n-)\n-{\n-    RName* rnp;\n-\n-    switch (command) {\n-        case PRTraceBufSize:\n-            PR_Lock(traceLock);\n-            PR_Free(tBuf);\n-            bufSize = *(PRInt32*)value;\n-            NewTraceBuffer(bufSize);\n-            PR_Unlock(traceLock);\n-            PR_LOG(lm, PR_LOG_DEBUG,\n-                   (\"PRSetTraceOption: PRTraceBufSize: %ld\", bufSize));\n-            break;\n-\n-        case PRTraceEnable:\n-            rnp = *(RName**)value;\n-            rnp->state = Running;\n-            PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceEnable: %p\", rnp));\n-            break;\n-\n-        case PRTraceDisable:\n-            rnp = *(RName**)value;\n-            rnp->state = Suspended;\n-            PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceDisable: %p\", rnp));\n-            break;\n-\n-        case PRTraceSuspend:\n-            traceState = Suspended;\n-            PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceSuspend\"));\n-            break;\n-\n-        case PRTraceResume:\n-            traceState = Running;\n-            PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceResume\"));\n-            break;\n-\n-        case PRTraceSuspendRecording:\n-            PR_Lock(logLock);\n-            logOrder = LogSuspend;\n-            PR_NotifyCondVar(logCVar);\n-            PR_Unlock(logLock);\n-            PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceSuspendRecording\"));\n-            break;\n-\n-        case PRTraceResumeRecording:\n-            PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceResumeRecording\"));\n-            if (logState != LogSuspend) {\n-                break;\n-            }\n-            PR_Lock(logLock);\n-            logOrder = LogResume;\n-            PR_NotifyCondVar(logCVar);\n-            PR_Unlock(logLock);\n-            break;\n-\n-        case PRTraceStopRecording:\n-            PR_Lock(logLock);\n-            logOrder = LogStop;\n-            PR_NotifyCondVar(logCVar);\n-            PR_Unlock(logLock);\n-            PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceStopRecording\"));\n-            break;\n-\n-        case PRTraceLockHandles:\n-            PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceLockTraceHandles\"));\n-            PR_Lock(traceLock);\n-            break;\n-\n-        case PRTraceUnLockHandles:\n-            PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceUnLockHandles\"));\n-            PR_Unlock(traceLock);\n-            break;\n-\n-        default:\n-            PR_LOG(lm, PR_LOG_ERROR,\n-                   (\"PRSetTraceOption: Invalid command %ld\", command));\n-            PR_ASSERT(0);\n-            break;\n-    } /* end switch() */\n-    return;\n+) {\n+  RName* rnp;\n+\n+  switch (command) {\n+    case PRTraceBufSize:\n+      PR_Lock(traceLock);\n+      PR_Free(tBuf);\n+      bufSize = *(PRInt32*)value;\n+      NewTraceBuffer(bufSize);\n+      PR_Unlock(traceLock);\n+      PR_LOG(lm, PR_LOG_DEBUG,\n+             (\"PRSetTraceOption: PRTraceBufSize: %ld\", bufSize));\n+      break;\n+\n+    case PRTraceEnable:\n+      rnp = *(RName**)value;\n+      rnp->state = Running;\n+      PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceEnable: %p\", rnp));\n+      break;\n+\n+    case PRTraceDisable:\n+      rnp = *(RName**)value;\n+      rnp->state = Suspended;\n+      PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceDisable: %p\", rnp));\n+      break;\n+\n+    case PRTraceSuspend:\n+      traceState = Suspended;\n+      PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceSuspend\"));\n+      break;\n+\n+    case PRTraceResume:\n+      traceState = Running;\n+      PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceResume\"));\n+      break;\n+\n+    case PRTraceSuspendRecording:\n+      PR_Lock(logLock);\n+      logOrder = LogSuspend;\n+      PR_NotifyCondVar(logCVar);\n+      PR_Unlock(logLock);\n+      PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceSuspendRecording\"));\n+      break;\n+\n+    case PRTraceResumeRecording:\n+      PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceResumeRecording\"));\n+      if (logState != LogSuspend) {\n+        break;\n+      }\n+      PR_Lock(logLock);\n+      logOrder = LogResume;\n+      PR_NotifyCondVar(logCVar);\n+      PR_Unlock(logLock);\n+      break;\n+\n+    case PRTraceStopRecording:\n+      PR_Lock(logLock);\n+      logOrder = LogStop;\n+      PR_NotifyCondVar(logCVar);\n+      PR_Unlock(logLock);\n+      PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceStopRecording\"));\n+      break;\n+\n+    case PRTraceLockHandles:\n+      PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceLockTraceHandles\"));\n+      PR_Lock(traceLock);\n+      break;\n+\n+    case PRTraceUnLockHandles:\n+      PR_LOG(lm, PR_LOG_DEBUG, (\"PRSetTraceOption: PRTraceUnLockHandles\"));\n+      PR_Unlock(traceLock);\n+      break;\n+\n+    default:\n+      PR_LOG(lm, PR_LOG_ERROR,\n+             (\"PRSetTraceOption: Invalid command %ld\", command));\n+      PR_ASSERT(0);\n+      break;\n+  } /* end switch() */\n+  return;\n } /* end  PR_SetTraceOption() */\n \n /*\n@@ -477,22 +469,21 @@ PR_SetTraceOption(PRTraceOption command, /* One of the enumerated values */\n PR_IMPLEMENT(void)\n PR_GetTraceOption(PRTraceOption command, /* One of the enumerated values */\n                   void* value            /* command value or NULL */\n-)\n-{\n-    switch (command) {\n-        case PRTraceBufSize:\n-            *((PRInt32*)value) = bufSize;\n-            PR_LOG(lm, PR_LOG_DEBUG,\n-                   (\"PRGetTraceOption: PRTraceBufSize: %ld\", bufSize));\n-            break;\n-\n-        default:\n-            PR_LOG(lm, PR_LOG_ERROR,\n-                   (\"PRGetTraceOption: Invalid command %ld\", command));\n-            PR_ASSERT(0);\n-            break;\n-    } /* end switch() */\n-    return;\n+) {\n+  switch (command) {\n+    case PRTraceBufSize:\n+      *((PRInt32*)value) = bufSize;\n+      PR_LOG(lm, PR_LOG_DEBUG,\n+             (\"PRGetTraceOption: PRTraceBufSize: %ld\", bufSize));\n+      break;\n+\n+    default:\n+      PR_LOG(lm, PR_LOG_ERROR,\n+             (\"PRGetTraceOption: Invalid command %ld\", command));\n+      PR_ASSERT(0);\n+      break;\n+  } /* end switch() */\n+  return;\n } /* end PR_GetTraceOption() */\n \n /*\n@@ -501,34 +492,33 @@ PR_GetTraceOption(PRTraceOption command, /* One of the enumerated values */\n PR_IMPLEMENT(PRTraceHandle)\n PR_GetTraceHandleFromName(const char* qName, /* QName search argument */\n                           const char* rName  /* RName search argument */\n-)\n-{\n-    const char *qn, *rn, *desc;\n-    PRTraceHandle qh, rh = NULL;\n-    RName* rnp = NULL;\n-\n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PRTrace: GetTraceHandleFromName:\\n\\t\"\n-            \"QName: %s, RName: %s\",\n-            qName, rName));\n-\n-    qh = PR_FindNextTraceQname(NULL);\n-    while (qh != NULL) {\n-        rh = PR_FindNextTraceRname(NULL, qh);\n-        while (rh != NULL) {\n-            PR_GetTraceNameFromHandle(rh, &qn, &rn, &desc);\n-            if ((strcmp(qName, qn) == 0) && (strcmp(rName, rn) == 0)) {\n-                rnp = (RName*)rh;\n-                goto foundIt;\n-            }\n-            rh = PR_FindNextTraceRname(rh, qh);\n-        }\n-        qh = PR_FindNextTraceQname(NULL);\n+) {\n+  const char *qn, *rn, *desc;\n+  PRTraceHandle qh, rh = NULL;\n+  RName* rnp = NULL;\n+\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PRTrace: GetTraceHandleFromName:\\n\\t\"\n+          \"QName: %s, RName: %s\",\n+          qName, rName));\n+\n+  qh = PR_FindNextTraceQname(NULL);\n+  while (qh != NULL) {\n+    rh = PR_FindNextTraceRname(NULL, qh);\n+    while (rh != NULL) {\n+      PR_GetTraceNameFromHandle(rh, &qn, &rn, &desc);\n+      if ((strcmp(qName, qn) == 0) && (strcmp(rName, rn) == 0)) {\n+        rnp = (RName*)rh;\n+        goto foundIt;\n+      }\n+      rh = PR_FindNextTraceRname(rh, qh);\n     }\n+    qh = PR_FindNextTraceQname(NULL);\n+  }\n \n foundIt:\n-    PR_LOG(lm, PR_LOG_DEBUG, (\"PR_Counter: GetConterHandleFromName: %p\", rnp));\n-    return (rh);\n+  PR_LOG(lm, PR_LOG_DEBUG, (\"PR_Counter: GetConterHandleFromName: %p\", rnp));\n+  return (rh);\n } /* end PR_GetTraceHandleFromName() */\n \n /*\n@@ -540,243 +530,233 @@ PR_GetTraceNameFromHandle(\n     const char** qName,      /* pointer to associated QName */\n     const char** rName,      /* pointer to associated RName */\n     const char** description /* pointer to associated description */\n-)\n-{\n-    RName* rnp = (RName*)handle;\n-    QName* qnp = rnp->qName;\n+) {\n+  RName* rnp = (RName*)handle;\n+  QName* qnp = rnp->qName;\n \n-    *qName = qnp->name;\n-    *rName = rnp->name;\n-    *description = rnp->desc;\n+  *qName = qnp->name;\n+  *rName = rnp->name;\n+  *description = rnp->desc;\n \n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PRTrace: GetConterNameFromHandle: \"\n-            \"QNp: %p, RNp: %p,\\n\\tQName: %s, RName: %s, Desc: %s\",\n-            qnp, rnp, qnp->name, rnp->name, rnp->desc));\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PRTrace: GetConterNameFromHandle: \"\n+          \"QNp: %p, RNp: %p,\\n\\tQName: %s, RName: %s, Desc: %s\",\n+          qnp, rnp, qnp->name, rnp->name, rnp->desc));\n \n-    return;\n+  return;\n } /* end PR_GetTraceNameFromHandle() */\n \n /*\n **\n */\n PR_IMPLEMENT(PRTraceHandle)\n-PR_FindNextTraceQname(PRTraceHandle handle)\n-{\n-    QName* qnp = (QName*)handle;\n-\n-    if (PR_CLIST_IS_EMPTY(&qNameList)) {\n-        qnp = NULL;\n-    } else if (qnp == NULL) {\n-        qnp = (QName*)PR_LIST_HEAD(&qNameList);\n-    } else if (PR_NEXT_LINK(&qnp->link) == &qNameList) {\n-        qnp = NULL;\n-    } else {\n-        qnp = (QName*)PR_NEXT_LINK(&qnp->link);\n-    }\n-\n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PRTrace: FindNextQname: Handle: %p, Returns: %p\", handle, qnp));\n-\n-    return ((PRTraceHandle)qnp);\n+PR_FindNextTraceQname(PRTraceHandle handle) {\n+  QName* qnp = (QName*)handle;\n+\n+  if (PR_CLIST_IS_EMPTY(&qNameList)) {\n+    qnp = NULL;\n+  } else if (qnp == NULL) {\n+    qnp = (QName*)PR_LIST_HEAD(&qNameList);\n+  } else if (PR_NEXT_LINK(&qnp->link) == &qNameList) {\n+    qnp = NULL;\n+  } else {\n+    qnp = (QName*)PR_NEXT_LINK(&qnp->link);\n+  }\n+\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PRTrace: FindNextQname: Handle: %p, Returns: %p\", handle, qnp));\n+\n+  return ((PRTraceHandle)qnp);\n } /* end PR_FindNextTraceQname() */\n \n /*\n **\n */\n PR_IMPLEMENT(PRTraceHandle)\n-PR_FindNextTraceRname(PRTraceHandle rhandle, PRTraceHandle qhandle)\n-{\n-    RName* rnp = (RName*)rhandle;\n-    QName* qnp = (QName*)qhandle;\n-\n-    if (PR_CLIST_IS_EMPTY(&qnp->rNameList)) {\n-        rnp = NULL;\n-    } else if (rnp == NULL) {\n-        rnp = (RName*)PR_LIST_HEAD(&qnp->rNameList);\n-    } else if (PR_NEXT_LINK(&rnp->link) == &qnp->rNameList) {\n-        rnp = NULL;\n-    } else {\n-        rnp = (RName*)PR_NEXT_LINK(&rnp->link);\n-    }\n-\n-    PR_LOG(lm, PR_LOG_DEBUG,\n-           (\"PRTrace: FindNextRname: Rhandle: %p, QHandle: %p, Returns: %p\",\n-            rhandle, qhandle, rnp));\n-\n-    return ((PRTraceHandle)rnp);\n+PR_FindNextTraceRname(PRTraceHandle rhandle, PRTraceHandle qhandle) {\n+  RName* rnp = (RName*)rhandle;\n+  QName* qnp = (QName*)qhandle;\n+\n+  if (PR_CLIST_IS_EMPTY(&qnp->rNameList)) {\n+    rnp = NULL;\n+  } else if (rnp == NULL) {\n+    rnp = (RName*)PR_LIST_HEAD(&qnp->rNameList);\n+  } else if (PR_NEXT_LINK(&rnp->link) == &qnp->rNameList) {\n+    rnp = NULL;\n+  } else {\n+    rnp = (RName*)PR_NEXT_LINK(&rnp->link);\n+  }\n+\n+  PR_LOG(lm, PR_LOG_DEBUG,\n+         (\"PRTrace: FindNextRname: Rhandle: %p, QHandle: %p, Returns: %p\",\n+          rhandle, qhandle, rnp));\n+\n+  return ((PRTraceHandle)rnp);\n } /* end PR_FindNextTraceRname() */\n \n /*\n **\n */\n-static PRFileDesc*\n-InitializeRecording(void)\n-{\n-    char* logFileName;\n-    PRFileDesc* logFile;\n-\n-    /* Self initialize, if necessary */\n-    if (traceLock == NULL) {\n-        _PR_InitializeTrace();\n-    }\n+static PRFileDesc* InitializeRecording(void) {\n+  char* logFileName;\n+  PRFileDesc* logFile;\n \n-    PR_LOG(lm, PR_LOG_DEBUG, (\"PR_RecordTraceEntries: begins\"));\n+  /* Self initialize, if necessary */\n+  if (traceLock == NULL) {\n+    _PR_InitializeTrace();\n+  }\n \n-    logLostData = 0; /* reset at entry */\n-    logState = LogReset;\n+  PR_LOG(lm, PR_LOG_DEBUG, (\"PR_RecordTraceEntries: begins\"));\n \n-    /* Get the filename for the logfile from the environment */\n-    logFileName = PR_GetEnvSecure(\"NSPR_TRACE_LOG\");\n-    if (logFileName == NULL) {\n-        PR_LOG(lm, PR_LOG_ERROR,\n-               (\"RecordTraceEntries: Environment variable not defined. Exiting\"));\n-        return NULL;\n-    }\n+  logLostData = 0; /* reset at entry */\n+  logState = LogReset;\n \n-    /* Open the logfile */\n-    logFile = PR_Open(logFileName, PR_WRONLY | PR_CREATE_FILE, 0666);\n-    if (logFile == NULL) {\n-        PR_LOG(\n-            lm, PR_LOG_ERROR,\n-            (\"RecordTraceEntries: Cannot open %s as trace log file. OS error: %ld\",\n-             logFileName, PR_GetOSError()));\n-        return NULL;\n-    }\n-    return logFile;\n+  /* Get the filename for the logfile from the environment */\n+  logFileName = PR_GetEnvSecure(\"NSPR_TRACE_LOG\");\n+  if (logFileName == NULL) {\n+    PR_LOG(lm, PR_LOG_ERROR,\n+           (\"RecordTraceEntries: Environment variable not defined. Exiting\"));\n+    return NULL;\n+  }\n+\n+  /* Open the logfile */\n+  logFile = PR_Open(logFileName, PR_WRONLY | PR_CREATE_FILE, 0666);\n+  if (logFile == NULL) {\n+    PR_LOG(\n+        lm, PR_LOG_ERROR,\n+        (\"RecordTraceEntries: Cannot open %s as trace log file. OS error: %ld\",\n+         logFileName, PR_GetOSError()));\n+    return NULL;\n+  }\n+  return logFile;\n } /* end InitializeRecording() */\n \n /*\n **\n */\n-static void\n-ProcessOrders(void)\n-{\n-    switch (logOrder) {\n-        case LogReset:\n-            logOrder = logState = localState;\n-            PR_LOG(lm, PR_LOG_DEBUG, (\"RecordTraceEntries: LogReset\"));\n-            break;\n-\n-        case LogSuspend:\n-            localState = logOrder = logState = LogSuspend;\n-            PR_LOG(lm, PR_LOG_DEBUG, (\"RecordTraceEntries: LogSuspend\"));\n-            break;\n-\n-        case LogResume:\n-            localState = logOrder = logState = LogActive;\n-            PR_LOG(lm, PR_LOG_DEBUG, (\"RecordTraceEntries: LogResume\"));\n-            break;\n-\n-        case LogStop:\n-            logOrder = logState = LogStop;\n-            PR_LOG(lm, PR_LOG_DEBUG, (\"RecordTraceEntries: LogStop\"));\n-            break;\n-\n-        default:\n-            PR_LOG(lm, PR_LOG_ERROR,\n-                   (\"RecordTraceEntries: Invalid logOrder: %ld\", logOrder));\n-            PR_ASSERT(0);\n-            break;\n-    } /* end switch() */\n-    return;\n+static void ProcessOrders(void) {\n+  switch (logOrder) {\n+    case LogReset:\n+      logOrder = logState = localState;\n+      PR_LOG(lm, PR_LOG_DEBUG, (\"RecordTraceEntries: LogReset\"));\n+      break;\n+\n+    case LogSuspend:\n+      localState = logOrder = logState = LogSuspend;\n+      PR_LOG(lm, PR_LOG_DEBUG, (\"RecordTraceEntries: LogSuspend\"));\n+      break;\n+\n+    case LogResume:\n+      localState = logOrder = logState = LogActive;\n+      PR_LOG(lm, PR_LOG_DEBUG, (\"RecordTraceEntries: LogResume\"));\n+      break;\n+\n+    case LogStop:\n+      logOrder = logState = LogStop;\n+      PR_LOG(lm, PR_LOG_DEBUG, (\"RecordTraceEntries: LogStop\"));\n+      break;\n+\n+    default:\n+      PR_LOG(lm, PR_LOG_ERROR,\n+             (\"RecordTraceEntries: Invalid logOrder: %ld\", logOrder));\n+      PR_ASSERT(0);\n+      break;\n+  } /* end switch() */\n+  return;\n } /* end ProcessOrders() */\n \n /*\n **\n */\n-static void\n-WriteTraceSegment(PRFileDesc* logFile, void* buf, PRInt32 amount)\n-{\n-    PRInt32 rc;\n-\n+static void WriteTraceSegment(PRFileDesc* logFile, void* buf, PRInt32 amount) {\n+  PRInt32 rc;\n+\n+  PR_LOG(lm, PR_LOG_ERROR,\n+         (\"WriteTraceSegment: Buffer: %p, Amount: %ld\", buf, amount));\n+  rc = PR_Write(logFile, buf, amount);\n+  if (rc == -1)\n+    PR_LOG(\n+        lm, PR_LOG_ERROR,\n+        (\"RecordTraceEntries: PR_Write() failed. Error: %ld\", PR_GetError()));\n+  else if (rc != amount)\n     PR_LOG(lm, PR_LOG_ERROR,\n-           (\"WriteTraceSegment: Buffer: %p, Amount: %ld\", buf, amount));\n-    rc = PR_Write(logFile, buf, amount);\n-    if (rc == -1)\n-        PR_LOG(\n-            lm, PR_LOG_ERROR,\n-            (\"RecordTraceEntries: PR_Write() failed. Error: %ld\", PR_GetError()));\n-    else if (rc != amount)\n-        PR_LOG(lm, PR_LOG_ERROR,\n-               (\"RecordTraceEntries: PR_Write() Tried to write: %ld, Wrote: %ld\",\n-                amount, rc));\n-    else\n-        PR_LOG(lm, PR_LOG_DEBUG,\n-               (\"RecordTraceEntries: PR_Write(): Buffer: %p, bytes: %ld\", buf,\n-                amount));\n+           (\"RecordTraceEntries: PR_Write() Tried to write: %ld, Wrote: %ld\",\n+            amount, rc));\n+  else\n+    PR_LOG(lm, PR_LOG_DEBUG,\n+           (\"RecordTraceEntries: PR_Write(): Buffer: %p, bytes: %ld\", buf,\n+            amount));\n \n-    return;\n+  return;\n } /* end WriteTraceSegment() */\n \n /*\n **\n */\n PR_IMPLEMENT(void)\n-PR_RecordTraceEntries(void)\n-{\n-    PRFileDesc* logFile;\n-    PRInt32 lostSegments;\n-    PRInt32 currentSegment = 0;\n-    void* buf;\n-    PRBool doWrite;\n-\n-    logFile = InitializeRecording();\n-    if (logFile == NULL) {\n-        PR_LOG(lm, PR_LOG_DEBUG, (\"PR_RecordTraceEntries: Failed to initialize\"));\n-        return;\n+PR_RecordTraceEntries(void) {\n+  PRFileDesc* logFile;\n+  PRInt32 lostSegments;\n+  PRInt32 currentSegment = 0;\n+  void* buf;\n+  PRBool doWrite;\n+\n+  logFile = InitializeRecording();\n+  if (logFile == NULL) {\n+    PR_LOG(lm, PR_LOG_DEBUG, (\"PR_RecordTraceEntries: Failed to initialize\"));\n+    return;\n+  }\n+\n+  /* Do this until told to stop */\n+  while (logState != LogStop) {\n+    PR_Lock(logLock);\n+\n+    while ((logCount == 0) && (logOrder == logState)) {\n+      PR_WaitCondVar(logCVar, PR_INTERVAL_NO_TIMEOUT);\n     }\n \n-    /* Do this until told to stop */\n-    while (logState != LogStop) {\n-        PR_Lock(logLock);\n-\n-        while ((logCount == 0) && (logOrder == logState)) {\n-            PR_WaitCondVar(logCVar, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-\n-        /* Handle state transitions */\n-        if (logOrder != logState) {\n-            ProcessOrders();\n-        }\n-\n-        /* recalculate local controls */\n-        if (logCount) {\n-            lostSegments = logCount - logSegments;\n-            if (lostSegments > 0) {\n-                logLostData += (logCount - logSegments);\n-                logCount = (logCount % logSegments);\n-                currentSegment = logCount;\n-                PR_LOG(lm, PR_LOG_DEBUG,\n-                       (\"PR_RecordTraceEntries: LostData segments: %ld\", logLostData));\n-            } else {\n-                logCount--;\n-            }\n-\n-            buf = tBuf + (logEntriesPerSegment * currentSegment);\n-            if (++currentSegment >= logSegments) {\n-                currentSegment = 0;\n-            }\n-            doWrite = PR_TRUE;\n-        } else {\n-            doWrite = PR_FALSE;\n-        }\n-\n-        PR_Unlock(logLock);\n-\n-        if (doWrite == PR_TRUE) {\n-            if (localState != LogSuspend) {\n-                WriteTraceSegment(logFile, buf, logSegSize);\n-            } else\n-                PR_LOG(lm, PR_LOG_DEBUG,\n-                       (\"RecordTraceEntries: PR_Write(): is suspended\"));\n-        }\n-\n-    } /* end while(logState...) */\n-\n-    PR_Close(logFile);\n-    PR_LOG(lm, PR_LOG_DEBUG, (\"RecordTraceEntries: exiting\"));\n-    return;\n+    /* Handle state transitions */\n+    if (logOrder != logState) {\n+      ProcessOrders();\n+    }\n+\n+    /* recalculate local controls */\n+    if (logCount) {\n+      lostSegments = logCount - logSegments;\n+      if (lostSegments > 0) {\n+        logLostData += (logCount - logSegments);\n+        logCount = (logCount % logSegments);\n+        currentSegment = logCount;\n+        PR_LOG(lm, PR_LOG_DEBUG,\n+               (\"PR_RecordTraceEntries: LostData segments: %ld\", logLostData));\n+      } else {\n+        logCount--;\n+      }\n+\n+      buf = tBuf + (logEntriesPerSegment * currentSegment);\n+      if (++currentSegment >= logSegments) {\n+        currentSegment = 0;\n+      }\n+      doWrite = PR_TRUE;\n+    } else {\n+      doWrite = PR_FALSE;\n+    }\n+\n+    PR_Unlock(logLock);\n+\n+    if (doWrite == PR_TRUE) {\n+      if (localState != LogSuspend) {\n+        WriteTraceSegment(logFile, buf, logSegSize);\n+      } else\n+        PR_LOG(lm, PR_LOG_DEBUG,\n+               (\"RecordTraceEntries: PR_Write(): is suspended\"));\n+    }\n+\n+  } /* end while(logState...) */\n+\n+  PR_Close(logFile);\n+  PR_LOG(lm, PR_LOG_DEBUG, (\"RecordTraceEntries: exiting\"));\n+  return;\n } /* end  PR_RecordTraceEntries() */\n \n /*\n@@ -786,52 +766,51 @@ PR_IMPLEMENT(PRIntn)\n PR_GetTraceEntries(PRTraceEntry* buffer, /* where to write output */\n                    PRInt32 count,        /* number to get */\n                    PRInt32* found        /* number you got */\n-)\n-{\n-    PRInt32 rc;\n-    PRInt32 copied = 0;\n-\n-    PR_Lock(traceLock);\n+) {\n+  PRInt32 rc;\n+  PRInt32 copied = 0;\n+\n+  PR_Lock(traceLock);\n+\n+  /*\n+  ** Depending on where the LastSeen and Next indices are,\n+  ** copy the trace buffer in one or two pieces.\n+  */\n+  PR_LOG(lm, PR_LOG_ERROR,\n+         (\"PR_GetTraceEntries: Next: %ld, LastSeen: %ld\", next, fetchLastSeen));\n+\n+  if (fetchLastSeen <= next) {\n+    while ((count-- > 0) && (fetchLastSeen < next)) {\n+      *(buffer + copied++) = *(tBuf + fetchLastSeen++);\n+    }\n+    PR_LOG(lm, PR_LOG_ERROR,\n+           (\"PR_GetTraceEntries: Copied: %ld, LastSeen: %ld\", copied,\n+            fetchLastSeen));\n+  } else /* copy in 2 parts */\n+  {\n+    while (count-- > 0 && fetchLastSeen <= last) {\n+      *(buffer + copied++) = *(tBuf + fetchLastSeen++);\n+    }\n+    fetchLastSeen = 0;\n \n-    /*\n-    ** Depending on where the LastSeen and Next indices are,\n-    ** copy the trace buffer in one or two pieces.\n-    */\n     PR_LOG(lm, PR_LOG_ERROR,\n-           (\"PR_GetTraceEntries: Next: %ld, LastSeen: %ld\", next, fetchLastSeen));\n-\n-    if (fetchLastSeen <= next) {\n-        while ((count-- > 0) && (fetchLastSeen < next)) {\n-            *(buffer + copied++) = *(tBuf + fetchLastSeen++);\n-        }\n-        PR_LOG(lm, PR_LOG_ERROR,\n-               (\"PR_GetTraceEntries: Copied: %ld, LastSeen: %ld\", copied,\n-                fetchLastSeen));\n-    } else /* copy in 2 parts */\n-    {\n-        while (count-- > 0 && fetchLastSeen <= last) {\n-            *(buffer + copied++) = *(tBuf + fetchLastSeen++);\n-        }\n-        fetchLastSeen = 0;\n-\n-        PR_LOG(lm, PR_LOG_ERROR,\n-               (\"PR_GetTraceEntries: Copied: %ld, LastSeen: %ld\", copied,\n-                fetchLastSeen));\n-\n-        while (count-- > 0 && fetchLastSeen < next) {\n-            *(buffer + copied++) = *(tBuf + fetchLastSeen++);\n-        }\n-        PR_LOG(lm, PR_LOG_ERROR,\n-               (\"PR_GetTraceEntries: Copied: %ld, LastSeen: %ld\", copied,\n-                fetchLastSeen));\n+           (\"PR_GetTraceEntries: Copied: %ld, LastSeen: %ld\", copied,\n+            fetchLastSeen));\n+\n+    while (count-- > 0 && fetchLastSeen < next) {\n+      *(buffer + copied++) = *(tBuf + fetchLastSeen++);\n     }\n+    PR_LOG(lm, PR_LOG_ERROR,\n+           (\"PR_GetTraceEntries: Copied: %ld, LastSeen: %ld\", copied,\n+            fetchLastSeen));\n+  }\n \n-    *found = copied;\n-    rc = (fetchLostData == PR_TRUE) ? 1 : 0;\n-    fetchLostData = PR_FALSE;\n+  *found = copied;\n+  rc = (fetchLostData == PR_TRUE) ? 1 : 0;\n+  fetchLostData = PR_FALSE;\n \n-    PR_Unlock(traceLock);\n-    return rc;\n+  PR_Unlock(traceLock);\n+  return rc;\n } /* end PR_GetTraceEntries() */\n \n /* end prtrace.c */\ndiff --git a/nspr/pr/src/nspr.rc b/nspr/pr/src/nspr.rc\nindex f727c50..1f21262 100644\n--- a/nspr/pr/src/nspr.rc\n+++ b/nspr/pr/src/nspr.rc\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/pr/src/prvrsion.c b/nspr/pr/src/prvrsion.c\nindex 79114d0..82295c3 100644\n--- a/nspr/pr/src/prvrsion.c\n+++ b/nspr/pr/src/prvrsion.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,22 +11,22 @@\n /************************************************************************/\n #include \"_pr_bld.h\"\n #if !defined(_BUILD_TIME)\n-#ifdef HAVE_LONG_LONG\n-#define _BUILD_TIME 0\n-#else\n-#define _BUILD_TIME { 0, 0 }\n-#endif\n+#  ifdef HAVE_LONG_LONG\n+#    define _BUILD_TIME 0\n+#  else\n+#    define _BUILD_TIME {0, 0}\n+#  endif\n #endif\n #if !defined(_BUILD_STRING)\n-#define _BUILD_STRING \"\"\n+#  define _BUILD_STRING \"\"\n #endif\n #if !defined(_PRODUCTION)\n-#define _PRODUCTION \"\"\n+#  define _PRODUCTION \"\"\n #endif\n #if defined(DEBUG)\n-#define _DEBUG_STRING \" (debug)\"\n+#  define _DEBUG_STRING \" (debug)\"\n #else\n-#define _DEBUG_STRING \"\"\n+#  define _DEBUG_STRING \"\"\n #endif\n \n /*\n@@ -36,8 +37,8 @@\n #define VERSION_DESC_NAME CONCAT2(prVersionDescription_libnspr, PR_VMAJOR)\n \n PRVersionDescription VERSION_DESC_NAME = {\n-    /* version          */ 2,             /* this is the only one supported */\n-    /* buildTime        */ _BUILD_TIME,   /* usecs since midnight 1/1/1970 GMT */\n+    /* version          */ 2,           /* this is the only one supported */\n+    /* buildTime        */ _BUILD_TIME, /* usecs since midnight 1/1/1970 GMT */\n     /* buildTimeString  */ _BUILD_STRING, /*    ditto, but human readable */\n     /* vMajor           */ PR_VMAJOR,     /* NSPR's version number */\n     /* vMinor           */ PR_VMINOR,     /*  and minor version */\n@@ -48,8 +49,8 @@ PRVersionDescription VERSION_DESC_NAME = {\n #else\n     /* debug            */ PR_FALSE, /* an optomized build */\n #endif\n-    /* special          */ PR_FALSE,           /* they're all special, but ... */\n-    /* filename         */ _PRODUCTION,        /* the produced library name */\n+    /* special          */ PR_FALSE,    /* they're all special, but ... */\n+    /* filename         */ _PRODUCTION, /* the produced library name */\n     /* description      */ \"Portable runtime\", /* what we are */\n     /* security         */ \"N/A\",              /* not applicable here */\n                                                /* copywrite        */\n@@ -57,8 +58,7 @@ PRVersionDescription VERSION_DESC_NAME = {\n     \"License, v. 2.0. If a copy of the MPL was not distributed with this file, \"\n     \"You can obtain one at http://mozilla.org/MPL/2.0/.\",\n     /* comment          */ \"License information: http://www.mozilla.org/MPL/\",\n-    /* specialString    */ \"\"\n-};\n+    /* specialString    */ \"\"};\n \n #ifdef XP_UNIX\n \n@@ -75,26 +75,24 @@ static char sccsid[] = \"@(#)NSPR \" PR_VERSION _DEBUG_STRING \"  \" _BUILD_STRING;\n #endif /* XP_UNIX */\n \n #ifdef _PR_HAS_PRAGMA_DIAGNOSTIC\n-#pragma GCC diagnostic push\n-#pragma GCC diagnostic ignored \"-Wunused-but-set-variable\"\n+#  pragma GCC diagnostic push\n+#  pragma GCC diagnostic ignored \"-Wunused-but-set-variable\"\n #endif\n-PR_IMPLEMENT(const PRVersionDescription*)\n-libVersionPoint(void)\n-{\n+PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint(void) {\n #ifdef XP_UNIX\n-    /*\n-     * Add dummy references to rcsid and sccsid to prevent them\n-     * from being optimized away as unused variables.\n-     */\n-    const char* dummy;\n+  /*\n+   * Add dummy references to rcsid and sccsid to prevent them\n+   * from being optimized away as unused variables.\n+   */\n+  const char* dummy;\n \n-    dummy = rcsid;\n-    dummy = sccsid;\n+  dummy = rcsid;\n+  dummy = sccsid;\n #endif\n-    return &VERSION_DESC_NAME;\n+  return &VERSION_DESC_NAME;\n } /* versionEntryPointType */\n #ifdef _PR_HAS_PRAGMA_DIAGNOSTIC\n-#pragma GCC diagnostic pop\n+#  pragma GCC diagnostic pop\n #endif\n \n /* prvrsion.c */\ndiff --git a/nspr/pr/src/pthreads/.cvsignore b/nspr/pr/src/pthreads/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/src/pthreads/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/src/pthreads/ptio.c b/nspr/pr/src/pthreads/ptio.c\nindex 6d03f79..1baba7c 100644\n--- a/nspr/pr/src/pthreads/ptio.c\n+++ b/nspr/pr/src/pthreads/ptio.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,75 +10,76 @@\n \n #if defined(_PR_PTHREADS)\n \n-#include <pthread.h>\n-#include <string.h> /* for memset() */\n-#include <sys/types.h>\n-#include <dirent.h>\n-#include <fcntl.h>\n-#include <unistd.h>\n-#include <sys/socket.h>\n-#include <sys/stat.h>\n-#include <sys/uio.h>\n-#include <sys/file.h>\n-#include <sys/ioctl.h>\n-#if defined(DARWIN)\n-#include <sys/utsname.h> /* for uname */\n-#endif\n-#if defined(SOLARIS)\n-#include <sys/filio.h> /* to pick up FIONREAD */\n-#endif\n-#ifdef _PR_POLL_AVAILABLE\n-#include <poll.h>\n-#endif\n-#ifdef AIX\n+\n+#  include <pthread.h>\n+#  include <string.h> /* for memset() */\n+#  include <sys/types.h>\n+#  include <dirent.h>\n+#  include <fcntl.h>\n+#  include <unistd.h>\n+#  include <sys/socket.h>\n+#  include <sys/stat.h>\n+#  include <sys/uio.h>\n+#  include <sys/file.h>\n+#  include <sys/ioctl.h>\n+#  if defined(DARWIN)\n+#    include <sys/utsname.h> /* for uname */\n+#  endif\n+#  if defined(SOLARIS)\n+#    include <sys/filio.h> /* to pick up FIONREAD */\n+#  endif\n+#  ifdef _PR_POLL_AVAILABLE\n+#    include <poll.h>\n+#  endif\n+#  ifdef AIX\n /* To pick up sysconf() */\n-#include <unistd.h>\n-#include <dlfcn.h> /* for dlopen */\n-#else\n+#    include <unistd.h>\n+#    include <dlfcn.h> /* for dlopen */\n+#  else\n /* To pick up getrlimit() etc. */\n-#include <sys/time.h>\n-#include <sys/resource.h>\n-#endif\n+#    include <sys/time.h>\n+#    include <sys/resource.h>\n+#  endif\n \n-#ifdef SOLARIS\n+#  ifdef SOLARIS\n /*\n  * Define HAVE_SENDFILEV if the system has the sendfilev() system call.\n  * Code built this way won't run on a system without sendfilev().\n  * We can define HAVE_SENDFILEV by default when the minimum release\n  * of Solaris that NSPR supports has sendfilev().\n  */\n-#ifdef HAVE_SENDFILEV\n+#    ifdef HAVE_SENDFILEV\n \n-#include <sys/sendfile.h>\n+#      include <sys/sendfile.h>\n \n-#define SOLARIS_SENDFILEV(a, b, c, d) sendfilev((a), (b), (c), (d))\n+#      define SOLARIS_SENDFILEV(a, b, c, d) sendfilev((a), (b), (c), (d))\n \n-#else\n+#    else\n \n-#include <dlfcn.h> /* for dlopen */\n+#      include <dlfcn.h> /* for dlopen */\n \n /*\n  * Match the definitions in <sys/sendfile.h>.\n  */\n typedef struct sendfilevec {\n-    int sfv_fd;      /* input fd */\n-    uint_t sfv_flag; /* flags */\n-    off_t sfv_off;   /* offset to start reading from */\n-    size_t sfv_len;  /* amount of data */\n+  int sfv_fd;      /* input fd */\n+  uint_t sfv_flag; /* flags */\n+  off_t sfv_off;   /* offset to start reading from */\n+  size_t sfv_len;  /* amount of data */\n } sendfilevec_t;\n \n-#define SFV_FD_SELF (-2)\n+#      define SFV_FD_SELF (-2)\n \n /*\n  * extern ssize_t sendfilev(int, const struct sendfilevec *, int, size_t *);\n  */\n static ssize_t (*pt_solaris_sendfilev_fptr)() = NULL;\n \n-#define SOLARIS_SENDFILEV(a, b, c, d) \\\n-    (*pt_solaris_sendfilev_fptr)((a), (b), (c), (d))\n+#      define SOLARIS_SENDFILEV(a, b, c, d) \\\n+        (*pt_solaris_sendfilev_fptr)((a), (b), (c), (d))\n \n-#endif /* HAVE_SENDFILEV */\n-#endif /* SOLARIS */\n+#    endif /* HAVE_SENDFILEV */\n+#  endif   /* SOLARIS */\n \n /*\n  * The send_file() system call is available in AIX 4.3.2 or later.\n@@ -88,16 +90,16 @@ static ssize_t (*pt_solaris_sendfilev_fptr)() = NULL;\n  * runtime function dispatching and just use the send_file based\n  * implementation.\n  */\n-#ifdef AIX\n-#ifdef SF_CLOSE\n-#define HAVE_SEND_FILE\n-#endif\n+#  ifdef AIX\n+#    ifdef SF_CLOSE\n+#      define HAVE_SEND_FILE\n+#    endif\n \n-#ifdef HAVE_SEND_FILE\n+#    ifdef HAVE_SEND_FILE\n \n-#define AIX_SEND_FILE(a, b, c) send_file(a, b, c)\n+#      define AIX_SEND_FILE(a, b, c) send_file(a, b, c)\n \n-#else                            /* HAVE_SEND_FILE */\n+#    else                              /* HAVE_SEND_FILE */\n \n /*\n  * The following definitions match those in <sys/socket.h>\n@@ -108,97 +110,97 @@ static ssize_t (*pt_solaris_sendfilev_fptr)() = NULL;\n  * Structure for the send_file() system call\n  */\n struct sf_parms {\n-    /* --------- header parms ---------- */\n-    void* header_data;    /* Input/Output. Points to header buf */\n-    uint_t header_length; /* Input/Output. Length of the header */\n-    /* --------- file parms ------------ */\n-    int file_descriptor;            /* Input. File descriptor of the file */\n-    unsigned long long file_size;   /* Output. Size of the file */\n-    unsigned long long file_offset; /* Input/Output. Starting offset */\n-    long long file_bytes;           /* Input/Output. no. of bytes to send */\n-    /* --------- trailer parms --------- */\n-    void* trailer_data;    /* Input/Output. Points to trailer buf */\n-    uint_t trailer_length; /* Input/Output. Length of the trailer */\n-    /* --------- return info ----------- */\n-    unsigned long long bytes_sent; /* Output. no. of bytes sent */\n+  /* --------- header parms ---------- */\n+  void* header_data;    /* Input/Output. Points to header buf */\n+  uint_t header_length; /* Input/Output. Length of the header */\n+  /* --------- file parms ------------ */\n+  int file_descriptor;            /* Input. File descriptor of the file */\n+  unsigned long long file_size;   /* Output. Size of the file */\n+  unsigned long long file_offset; /* Input/Output. Starting offset */\n+  long long file_bytes;           /* Input/Output. no. of bytes to send */\n+  /* --------- trailer parms --------- */\n+  void* trailer_data;    /* Input/Output. Points to trailer buf */\n+  uint_t trailer_length; /* Input/Output. Length of the trailer */\n+  /* --------- return info ----------- */\n+  unsigned long long bytes_sent; /* Output. no. of bytes sent */\n };\n \n /*\n  * Flags for the send_file() system call\n  */\n-#define SF_CLOSE 0x00000001      /* close the socket after completion */\n-#define SF_REUSE 0x00000002      /* reuse socket. not supported */\n-#define SF_DONT_CACHE 0x00000004 /* don't apply network buffer cache */\n-#define SF_SYNC_CACHE 0x00000008 /* sync/update network buffer cache */\n+#      define SF_CLOSE 0x00000001      /* close the socket after completion */\n+#      define SF_REUSE 0x00000002      /* reuse socket. not supported */\n+#      define SF_DONT_CACHE 0x00000004 /* don't apply network buffer cache */\n+#      define SF_SYNC_CACHE 0x00000008 /* sync/update network buffer cache */\n \n /*\n  * prototype: size_t send_file(int *, struct sf_parms *, uint_t);\n  */\n static ssize_t (*pt_aix_sendfile_fptr)() = NULL;\n \n-#define AIX_SEND_FILE(a, b, c) (*pt_aix_sendfile_fptr)(a, b, c)\n+#      define AIX_SEND_FILE(a, b, c) (*pt_aix_sendfile_fptr)(a, b, c)\n \n-#endif /* HAVE_SEND_FILE */\n-#endif /* AIX */\n+#    endif /* HAVE_SEND_FILE */\n+#  endif   /* AIX */\n \n-#ifdef LINUX\n-#include <sys/sendfile.h>\n-#endif\n+#  ifdef LINUX\n+#    include <sys/sendfile.h>\n+#  endif\n \n-#include \"primpl.h\"\n+#  include \"primpl.h\"\n \n-#if defined(LINUX) || defined(ANDROID)\n-#include <netinet/in.h>\n-#endif\n+#  if defined(LINUX) || defined(ANDROID)\n+#    include <netinet/in.h>\n+#  endif\n \n-#ifdef DARWIN\n-#include <netinet/in.h>\n-#include <netinet/ip.h>\n-#endif\n+#  ifdef DARWIN\n+#    include <netinet/in.h>\n+#    include <netinet/ip.h>\n+#  endif\n \n-#ifdef HAVE_NETINET_TCP_H\n-#include <netinet/tcp.h> /* TCP_NODELAY, TCP_MAXSEG */\n-#endif\n+#  ifdef HAVE_NETINET_TCP_H\n+#    include <netinet/tcp.h> /* TCP_NODELAY, TCP_MAXSEG */\n+#  endif\n \n-#ifdef LINUX\n+#  ifdef LINUX\n /* TCP_CORK is not defined in <netinet/tcp.h> on Red Hat Linux 6.0 */\n-#ifndef TCP_CORK\n-#define TCP_CORK 3\n-#endif\n-#ifndef MSG_FASTOPEN\n-#define MSG_FASTOPEN 0x20000000\n-#endif\n-#endif\n-\n-#ifdef _PR_IPV6_V6ONLY_PROBE\n+#    ifndef TCP_CORK\n+#      define TCP_CORK 3\n+#    endif\n+#    ifndef MSG_FASTOPEN\n+#      define MSG_FASTOPEN 0x20000000\n+#    endif\n+#  endif\n+\n+#  ifdef _PR_IPV6_V6ONLY_PROBE\n static PRBool _pr_ipv6_v6only_on_by_default;\n-#endif\n-\n-#if defined(AIX4_1)\n-#define _PRSelectFdSetArg_t void*\n-#elif (defined(AIX) && !defined(AIX4_1)) || defined(SOLARIS) ||   \\\n-    defined(HPUX10_30) || defined(HPUX11) || defined(LINUX) ||    \\\n-    defined(__GNU__) || defined(__GLIBC__) || defined(FREEBSD) || \\\n-    defined(NETBSD) || defined(OPENBSD) || defined(NTO) ||        \\\n-    defined(DARWIN) || defined(RISCOS)\n-#define _PRSelectFdSetArg_t fd_set*\n-#else\n-#error \"Cannot determine architecture\"\n-#endif\n-\n-#if defined(SOLARIS)\n-#ifndef PROTO_SDP\n+#  endif\n+\n+#  if   defined(AIX4_1)\n+#    define _PRSelectFdSetArg_t void*\n+#  elif (defined(AIX) && !defined(AIX4_1)) || defined(SOLARIS) ||   \\\n+      defined(HPUX10_30) || defined(HPUX11) || defined(LINUX) ||    \\\n+      defined(__GNU__) || defined(__GLIBC__) || defined(FREEBSD) || \\\n+      defined(NETBSD) || defined(OPENBSD) || defined(NTO) ||        \\\n+      defined(DARWIN) || defined(RISCOS)\n+#    define _PRSelectFdSetArg_t fd_set*\n+#  else\n+#    error \"Cannot determine architecture\"\n+#  endif\n+\n+#  if defined(SOLARIS)\n+#    ifndef PROTO_SDP\n /* on solaris, SDP is a new type of protocol */\n-#define PROTO_SDP 257\n-#endif\n-#define _PR_HAVE_SDP\n-#elif defined(LINUX)\n-#ifndef AF_INET_SDP\n+#      define PROTO_SDP 257\n+#    endif\n+#    define _PR_HAVE_SDP\n+#  elif defined(LINUX)\n+#    ifndef AF_INET_SDP\n /* on linux, SDP is a new type of address family */\n-#define AF_INET_SDP 27\n-#endif\n-#define _PR_HAVE_SDP\n-#endif /* LINUX */\n+#      define AF_INET_SDP 27\n+#    endif\n+#    define _PR_HAVE_SDP\n+#  endif /* LINUX */\n \n static PRFileDesc* pt_SetMethods(PRIntn osfd, PRDescType type,\n                                  PRBool isAcceptedSocket, PRBool imported);\n@@ -210,45 +212,41 @@ static PRLock* _pr_rename_lock; /* For PR_Rename() */\n /**************************************************************************/\n \n /* These two functions are only used in assertions. */\n-#if defined(DEBUG)\n-\n-PRBool\n-IsValidNetAddr(const PRNetAddr* addr)\n-{\n-    if ((addr != NULL) && (addr->raw.family != AF_UNIX) &&\n-        (addr->raw.family != PR_AF_INET6) && (addr->raw.family != AF_INET)) {\n-        return PR_FALSE;\n-    }\n-    return PR_TRUE;\n+#  if defined(DEBUG)\n+\n+PRBool IsValidNetAddr(const PRNetAddr* addr) {\n+  if ((addr != NULL) && (addr->raw.family != AF_UNIX) &&\n+      (addr->raw.family != PR_AF_INET6) && (addr->raw.family != AF_INET)) {\n+    return PR_FALSE;\n+  }\n+  return PR_TRUE;\n }\n \n-static PRBool\n-IsValidNetAddrLen(const PRNetAddr* addr, PRInt32 addr_len)\n-{\n+static PRBool IsValidNetAddrLen(const PRNetAddr* addr, PRInt32 addr_len) {\n+  /*\n+   * The definition of the length of a Unix domain socket address\n+   * is not uniform, so we don't check it.\n+   */\n+  if ((addr != NULL) && (addr->raw.family != AF_UNIX) &&\n+      (PR_NETADDR_SIZE(addr) != addr_len)) {\n+#    if defined(LINUX) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 1\n     /*\n-     * The definition of the length of a Unix domain socket address\n-     * is not uniform, so we don't check it.\n+     * In glibc 2.1, struct sockaddr_in6 is 24 bytes.  In glibc 2.2\n+     * and in the 2.4 kernel, struct sockaddr_in6 has the scope_id\n+     * field and is 28 bytes.  It is possible for socket functions\n+     * to return an addr_len greater than sizeof(struct sockaddr_in6).\n+     * We need to allow that.  (Bugzilla bug #77264)\n      */\n-    if ((addr != NULL) && (addr->raw.family != AF_UNIX) &&\n-        (PR_NETADDR_SIZE(addr) != addr_len)) {\n-#if defined(LINUX) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 1\n-        /*\n-         * In glibc 2.1, struct sockaddr_in6 is 24 bytes.  In glibc 2.2\n-         * and in the 2.4 kernel, struct sockaddr_in6 has the scope_id\n-         * field and is 28 bytes.  It is possible for socket functions\n-         * to return an addr_len greater than sizeof(struct sockaddr_in6).\n-         * We need to allow that.  (Bugzilla bug #77264)\n-         */\n-        if ((PR_AF_INET6 == addr->raw.family) && (sizeof(addr->ipv6) == addr_len)) {\n-            return PR_TRUE;\n-        }\n-#endif\n-        return PR_FALSE;\n+    if ((PR_AF_INET6 == addr->raw.family) && (sizeof(addr->ipv6) == addr_len)) {\n+      return PR_TRUE;\n     }\n-    return PR_TRUE;\n+#    endif\n+    return PR_FALSE;\n+  }\n+  return PR_TRUE;\n }\n \n-#endif /* DEBUG */\n+#  endif /* DEBUG */\n \n /*****************************************************************************/\n /************************* I/O Continuation machinery ************************/\n@@ -258,7 +256,7 @@ IsValidNetAddrLen(const PRNetAddr* addr, PRInt32 addr_len)\n  * The polling interval defines the maximum amount of time that a thread\n  * might hang up before an interrupt is noticed.\n  */\n-#define PT_DEFAULT_POLL_MSEC 5000\n+#  define PT_DEFAULT_POLL_MSEC 5000\n \n /*\n  * pt_SockLen is the type for the length of a socket address\n@@ -267,1836 +265,1731 @@ IsValidNetAddrLen(const PRNetAddr* addr, PRInt32 addr_len)\n  * defines this type as socklen_t.  It is size_t or int on\n  * most current systems.\n  */\n-#if defined(HAVE_SOCKLEN_T) || (defined(__GLIBC__) && __GLIBC__ >= 2)\n+#  if defined(HAVE_SOCKLEN_T) || (defined(__GLIBC__) && __GLIBC__ >= 2)\n typedef socklen_t pt_SockLen;\n-#elif (defined(AIX) && !defined(AIX4_1))\n+#  elif (defined(AIX) && !defined(AIX4_1))\n typedef PRSize pt_SockLen;\n-#else\n+#  else\n typedef PRIntn pt_SockLen;\n-#endif\n+#  endif\n \n typedef struct pt_Continuation pt_Continuation;\n typedef PRBool (*ContinuationFn)(pt_Continuation* op, PRInt16 revents);\n \n typedef enum pr_ContuationStatus {\n-    pt_continuation_pending,\n-    pt_continuation_done\n+  pt_continuation_pending,\n+  pt_continuation_done\n } pr_ContuationStatus;\n \n struct pt_Continuation {\n-    /* The building of the continuation operation */\n-    ContinuationFn function; /* what function to continue */\n-    union {\n-        PRIntn osfd;\n-    } arg1; /* #1 - the op's fd */\n-    union {\n-        void* buffer;\n-    } arg2; /* #2 - primary transfer buffer */\n-    union {\n-        PRSize amount;        /* #3 - size of 'buffer', or */\n-        pt_SockLen* addr_len; /*    - length of address */\n-#ifdef HPUX11\n-        /*\n-         * For sendfile()\n-         */\n-        struct file_spec {\n-            off_t offset;   /* offset in file to send */\n-            size_t nbytes;  /* length of file data to send */\n-            size_t st_size; /* file size */\n-        } file_spec;\n-#endif\n-    } arg3;\n-    union {\n-        PRIntn flags;\n-    } arg4; /* #4 - read/write flags */\n-    union {\n-        PRNetAddr* addr;\n-    } arg5; /* #5 - send/recv address */\n-\n-#ifdef HPUX11\n+  /* The building of the continuation operation */\n+  ContinuationFn function; /* what function to continue */\n+  union {\n+    PRIntn osfd;\n+  } arg1; /* #1 - the op's fd */\n+  union {\n+    void* buffer;\n+  } arg2; /* #2 - primary transfer buffer */\n+  union {\n+    PRSize amount;        /* #3 - size of 'buffer', or */\n+    pt_SockLen* addr_len; /*    - length of address */\n+#  ifdef HPUX11\n     /*\n      * For sendfile()\n      */\n-    int filedesc;       /* descriptor of file to send */\n-    int nbytes_to_send; /* size of header and file */\n-#endif                  /* HPUX11 */\n+    struct file_spec {\n+      off_t offset;   /* offset in file to send */\n+      size_t nbytes;  /* length of file data to send */\n+      size_t st_size; /* file size */\n+    } file_spec;\n+#  endif\n+  } arg3;\n+  union {\n+    PRIntn flags;\n+  } arg4; /* #4 - read/write flags */\n+  union {\n+    PRNetAddr* addr;\n+  } arg5; /* #5 - send/recv address */\n+\n+#  ifdef HPUX11\n+  /*\n+   * For sendfile()\n+   */\n+  int filedesc;       /* descriptor of file to send */\n+  int nbytes_to_send; /* size of header and file */\n+#  endif              /* HPUX11 */\n+\n+#  ifdef SOLARIS\n+  /*\n+   * For sendfilev()\n+   */\n+  int nbytes_to_send; /* size of header and file */\n+#  endif              /* SOLARIS */\n+\n+#  ifdef LINUX\n+  /*\n+   * For sendfile()\n+   */\n+  int in_fd; /* descriptor of file to send */\n+  off_t offset;\n+  size_t count;\n+#  endif /* LINUX */\n+\n+  PRIntervalTime timeout; /* client (relative) timeout */\n+\n+  PRInt16 event; /* flags for poll()'s events */\n+\n+  /*\n+  ** The representation and notification of the results of the operation.\n+  ** These function can either return an int return code or a pointer to\n+  ** some object.\n+  */\n+  union {\n+    PRSize code;\n+    void* object;\n+  } result;\n+\n+  PRIntn syserrno;            /* in case it failed, why (errno) */\n+  pr_ContuationStatus status; /* the status of the operation */\n+};\n \n-#ifdef SOLARIS\n-    /*\n-     * For sendfilev()\n-     */\n-    int nbytes_to_send; /* size of header and file */\n-#endif                  /* SOLARIS */\n+#  if defined(DEBUG)\n \n-#ifdef LINUX\n-    /*\n-     * For sendfile()\n-     */\n-    int in_fd; /* descriptor of file to send */\n-    off_t offset;\n-    size_t count;\n-#endif /* LINUX */\n+PTDebug pt_debug; /* this is shared between several modules */\n \n-    PRIntervalTime timeout; /* client (relative) timeout */\n+PR_IMPLEMENT(void) PT_FPrintStats(PRFileDesc* debug_out, const char* msg) {\n+  PTDebug stats;\n+  char buffer[100];\n+  PRExplodedTime tod;\n+  PRInt64 elapsed, aMil;\n+  stats = pt_debug; /* a copy */\n+  PR_ExplodeTime(stats.timeStarted, PR_LocalTimeParameters, &tod);\n+  (void)PR_FormatTime(buffer, sizeof(buffer), \"%T\", &tod);\n+\n+  LL_SUB(elapsed, PR_Now(), stats.timeStarted);\n+  LL_I2L(aMil, 1000000);\n+  LL_DIV(elapsed, elapsed, aMil);\n+\n+  if (NULL != msg) {\n+    PR_fprintf(debug_out, \"%s\", msg);\n+  }\n+  PR_fprintf(debug_out, \"\\tstarted: %s[%lld]\\n\", buffer, elapsed);\n+  PR_fprintf(debug_out, \"\\tlocks [created: %u, destroyed: %u]\\n\",\n+             stats.locks_created, stats.locks_destroyed);\n+  PR_fprintf(debug_out, \"\\tlocks [acquired: %u, released: %u]\\n\",\n+             stats.locks_acquired, stats.locks_released);\n+  PR_fprintf(debug_out, \"\\tcvars [created: %u, destroyed: %u]\\n\",\n+             stats.cvars_created, stats.cvars_destroyed);\n+  PR_fprintf(debug_out, \"\\tcvars [notified: %u, delayed_delete: %u]\\n\",\n+             stats.cvars_notified, stats.delayed_cv_deletes);\n+} /* PT_FPrintStats */\n \n-    PRInt16 event; /* flags for poll()'s events */\n+#  else\n \n-    /*\n-    ** The representation and notification of the results of the operation.\n-    ** These function can either return an int return code or a pointer to\n-    ** some object.\n-    */\n-    union {\n-        PRSize code;\n-        void* object;\n-    } result;\n-\n-    PRIntn syserrno;            /* in case it failed, why (errno) */\n-    pr_ContuationStatus status; /* the status of the operation */\n-};\n+PR_IMPLEMENT(void) PT_FPrintStats(PRFileDesc* debug_out, const char* msg) {\n+  /* do nothing */\n+} /* PT_FPrintStats */\n \n-#if defined(DEBUG)\n+#  endif /* DEBUG */\n \n-PTDebug pt_debug; /* this is shared between several modules */\n \n-PR_IMPLEMENT(void)\n-PT_FPrintStats(PRFileDesc* debug_out, const char* msg)\n-{\n-    PTDebug stats;\n-    char buffer[100];\n-    PRExplodedTime tod;\n-    PRInt64 elapsed, aMil;\n-    stats = pt_debug; /* a copy */\n-    PR_ExplodeTime(stats.timeStarted, PR_LocalTimeParameters, &tod);\n-    (void)PR_FormatTime(buffer, sizeof(buffer), \"%T\", &tod);\n-\n-    LL_SUB(elapsed, PR_Now(), stats.timeStarted);\n-    LL_I2L(aMil, 1000000);\n-    LL_DIV(elapsed, elapsed, aMil);\n-\n-    if (NULL != msg) {\n-        PR_fprintf(debug_out, \"%s\", msg);\n-    }\n-    PR_fprintf(debug_out, \"\\tstarted: %s[%lld]\\n\", buffer, elapsed);\n-    PR_fprintf(debug_out, \"\\tlocks [created: %u, destroyed: %u]\\n\",\n-               stats.locks_created, stats.locks_destroyed);\n-    PR_fprintf(debug_out, \"\\tlocks [acquired: %u, released: %u]\\n\",\n-               stats.locks_acquired, stats.locks_released);\n-    PR_fprintf(debug_out, \"\\tcvars [created: %u, destroyed: %u]\\n\",\n-               stats.cvars_created, stats.cvars_destroyed);\n-    PR_fprintf(debug_out, \"\\tcvars [notified: %u, delayed_delete: %u]\\n\",\n-               stats.cvars_notified, stats.delayed_cv_deletes);\n-} /* PT_FPrintStats */\n+static void pt_poll_now(pt_Continuation* op) {\n+  PRInt32 msecs;\n+  PRIntervalTime epoch, now, elapsed, remaining;\n+  PRBool wait_for_remaining;\n+  PRThread* self = PR_GetCurrentThread();\n \n-#else\n+  PR_ASSERT(PR_INTERVAL_NO_WAIT != op->timeout);\n \n-PR_IMPLEMENT(void)\n-PT_FPrintStats(PRFileDesc* debug_out, const char* msg)\n-{\n-    /* do nothing */\n-} /* PT_FPrintStats */\n+  switch (op->timeout) {\n+    case PR_INTERVAL_NO_TIMEOUT:\n+      msecs = PT_DEFAULT_POLL_MSEC;\n+      do {\n+        PRIntn rv;\n+        struct pollfd tmp_pfd;\n \n-#endif /* DEBUG */\n+        tmp_pfd.revents = 0;\n+        tmp_pfd.fd = op->arg1.osfd;\n+        tmp_pfd.events = op->event;\n \n-static void\n-pt_poll_now(pt_Continuation* op)\n-{\n-    PRInt32 msecs;\n-    PRIntervalTime epoch, now, elapsed, remaining;\n-    PRBool wait_for_remaining;\n-    PRThread* self = PR_GetCurrentThread();\n+        rv = poll(&tmp_pfd, 1, msecs);\n \n-    PR_ASSERT(PR_INTERVAL_NO_WAIT != op->timeout);\n+        if (_PT_THREAD_INTERRUPTED(self)) {\n+          self->state &= ~PT_THREAD_ABORTED;\n+          op->result.code = -1;\n+          op->syserrno = EINTR;\n+          op->status = pt_continuation_done;\n+          return;\n+        }\n \n-    switch (op->timeout) {\n-        case PR_INTERVAL_NO_TIMEOUT:\n-            msecs = PT_DEFAULT_POLL_MSEC;\n-            do {\n-                PRIntn rv;\n-                struct pollfd tmp_pfd;\n-\n-                tmp_pfd.revents = 0;\n-                tmp_pfd.fd = op->arg1.osfd;\n-                tmp_pfd.events = op->event;\n-\n-                rv = poll(&tmp_pfd, 1, msecs);\n-\n-                if (_PT_THREAD_INTERRUPTED(self)) {\n-                    self->state &= ~PT_THREAD_ABORTED;\n-                    op->result.code = -1;\n-                    op->syserrno = EINTR;\n-                    op->status = pt_continuation_done;\n-                    return;\n-                }\n+        if ((-1 == rv) && ((errno == EINTR) || (errno == EAGAIN))) {\n+          continue; /* go around the loop again */\n+        }\n \n-                if ((-1 == rv) && ((errno == EINTR) || (errno == EAGAIN))) {\n-                    continue; /* go around the loop again */\n-                }\n+        if (rv > 0) {\n+          PRInt16 events = tmp_pfd.events;\n+          PRInt16 revents = tmp_pfd.revents;\n \n-                if (rv > 0) {\n-                    PRInt16 events = tmp_pfd.events;\n-                    PRInt16 revents = tmp_pfd.revents;\n-\n-                    if ((revents & POLLNVAL) /* busted in all cases */\n-                        || ((events & POLLOUT) && (revents & POLLHUP)))\n-                    /* write op & hup */\n-                    {\n-                        op->result.code = -1;\n-                        if (POLLNVAL & revents) {\n-                            op->syserrno = EBADF;\n-                        } else if (POLLHUP & revents) {\n-                            op->syserrno = EPIPE;\n-                        }\n-                        op->status = pt_continuation_done;\n-                    } else {\n-                        if (op->function(op, revents)) {\n-                            op->status = pt_continuation_done;\n-                        }\n-                    }\n-                } else if (rv == -1) {\n-                    op->result.code = -1;\n-                    op->syserrno = errno;\n-                    op->status = pt_continuation_done;\n-                }\n-                /* else, poll timed out */\n-            } while (pt_continuation_done != op->status);\n-            break;\n-        default:\n-            now = epoch = PR_IntervalNow();\n-            remaining = op->timeout;\n-            do {\n-                PRIntn rv;\n-                struct pollfd tmp_pfd;\n-\n-                tmp_pfd.revents = 0;\n-                tmp_pfd.fd = op->arg1.osfd;\n-                tmp_pfd.events = op->event;\n-\n-                wait_for_remaining = PR_TRUE;\n-                msecs = (PRInt32)PR_IntervalToMilliseconds(remaining);\n-                if (msecs > PT_DEFAULT_POLL_MSEC) {\n-                    wait_for_remaining = PR_FALSE;\n-                    msecs = PT_DEFAULT_POLL_MSEC;\n-                }\n-                rv = poll(&tmp_pfd, 1, msecs);\n-\n-                if (_PT_THREAD_INTERRUPTED(self)) {\n-                    self->state &= ~PT_THREAD_ABORTED;\n-                    op->result.code = -1;\n-                    op->syserrno = EINTR;\n-                    op->status = pt_continuation_done;\n-                    return;\n-                }\n+          if ((revents & POLLNVAL) /* busted in all cases */\n+              || ((events & POLLOUT) && (revents & POLLHUP)))\n+          /* write op & hup */\n+          {\n+            op->result.code = -1;\n+            if (POLLNVAL & revents) {\n+              op->syserrno = EBADF;\n+            } else if (POLLHUP & revents) {\n+              op->syserrno = EPIPE;\n+            }\n+            op->status = pt_continuation_done;\n+          } else {\n+            if (op->function(op, revents)) {\n+              op->status = pt_continuation_done;\n+            }\n+          }\n+        } else if (rv == -1) {\n+          op->result.code = -1;\n+          op->syserrno = errno;\n+          op->status = pt_continuation_done;\n+        }\n+        /* else, poll timed out */\n+      } while (pt_continuation_done != op->status);\n+      break;\n+    default:\n+      now = epoch = PR_IntervalNow();\n+      remaining = op->timeout;\n+      do {\n+        PRIntn rv;\n+        struct pollfd tmp_pfd;\n+\n+        tmp_pfd.revents = 0;\n+        tmp_pfd.fd = op->arg1.osfd;\n+        tmp_pfd.events = op->event;\n+\n+        wait_for_remaining = PR_TRUE;\n+        msecs = (PRInt32)PR_IntervalToMilliseconds(remaining);\n+        if (msecs > PT_DEFAULT_POLL_MSEC) {\n+          wait_for_remaining = PR_FALSE;\n+          msecs = PT_DEFAULT_POLL_MSEC;\n+        }\n+        rv = poll(&tmp_pfd, 1, msecs);\n+\n+        if (_PT_THREAD_INTERRUPTED(self)) {\n+          self->state &= ~PT_THREAD_ABORTED;\n+          op->result.code = -1;\n+          op->syserrno = EINTR;\n+          op->status = pt_continuation_done;\n+          return;\n+        }\n \n-                if (rv > 0) {\n-                    PRInt16 events = tmp_pfd.events;\n-                    PRInt16 revents = tmp_pfd.revents;\n-\n-                    if ((revents & POLLNVAL) /* busted in all cases */\n-                        || ((events & POLLOUT) && (revents & POLLHUP)))\n-                    /* write op & hup */\n-                    {\n-                        op->result.code = -1;\n-                        if (POLLNVAL & revents) {\n-                            op->syserrno = EBADF;\n-                        } else if (POLLHUP & revents) {\n-                            op->syserrno = EPIPE;\n-                        }\n-                        op->status = pt_continuation_done;\n-                    } else {\n-                        if (op->function(op, revents)) {\n-                            op->status = pt_continuation_done;\n-                        }\n-                    }\n-                } else if ((rv == 0) || ((errno == EINTR) || (errno == EAGAIN))) {\n-                    if (rv == 0) /* poll timed out */\n-                    {\n-                        if (wait_for_remaining) {\n-                            now += remaining;\n-                        } else {\n-                            now += PR_MillisecondsToInterval(msecs);\n-                        }\n-                    } else {\n-                        now = PR_IntervalNow();\n-                    }\n-                    elapsed = (PRIntervalTime)(now - epoch);\n-                    if (elapsed >= op->timeout) {\n-                        op->result.code = -1;\n-                        op->syserrno = ETIMEDOUT;\n-                        op->status = pt_continuation_done;\n-                    } else {\n-                        remaining = op->timeout - elapsed;\n-                    }\n-                } else {\n-                    op->result.code = -1;\n-                    op->syserrno = errno;\n-                    op->status = pt_continuation_done;\n-                }\n-            } while (pt_continuation_done != op->status);\n-            break;\n-    }\n+        if (rv > 0) {\n+          PRInt16 events = tmp_pfd.events;\n+          PRInt16 revents = tmp_pfd.revents;\n+\n+          if ((revents & POLLNVAL) /* busted in all cases */\n+              || ((events & POLLOUT) && (revents & POLLHUP)))\n+          /* write op & hup */\n+          {\n+            op->result.code = -1;\n+            if (POLLNVAL & revents) {\n+              op->syserrno = EBADF;\n+            } else if (POLLHUP & revents) {\n+              op->syserrno = EPIPE;\n+            }\n+            op->status = pt_continuation_done;\n+          } else {\n+            if (op->function(op, revents)) {\n+              op->status = pt_continuation_done;\n+            }\n+          }\n+        } else if ((rv == 0) || ((errno == EINTR) || (errno == EAGAIN))) {\n+          if (rv == 0) /* poll timed out */\n+          {\n+            if (wait_for_remaining) {\n+              now += remaining;\n+            } else {\n+              now += PR_MillisecondsToInterval(msecs);\n+            }\n+          } else {\n+            now = PR_IntervalNow();\n+          }\n+          elapsed = (PRIntervalTime)(now - epoch);\n+          if (elapsed >= op->timeout) {\n+            op->result.code = -1;\n+            op->syserrno = ETIMEDOUT;\n+            op->status = pt_continuation_done;\n+          } else {\n+            remaining = op->timeout - elapsed;\n+          }\n+        } else {\n+          op->result.code = -1;\n+          op->syserrno = errno;\n+          op->status = pt_continuation_done;\n+        }\n+      } while (pt_continuation_done != op->status);\n+      break;\n+  }\n \n } /* pt_poll_now */\n \n-static PRIntn\n-pt_Continue(pt_Continuation* op)\n-{\n-    op->status = pt_continuation_pending; /* set default value */\n-    /*\n-     * let each thread call poll directly\n-     */\n-    pt_poll_now(op);\n-    PR_ASSERT(pt_continuation_done == op->status);\n-    return op->result.code;\n+static PRIntn pt_Continue(pt_Continuation* op) {\n+  op->status = pt_continuation_pending; /* set default value */\n+  /*\n+   * let each thread call poll directly\n+   */\n+  pt_poll_now(op);\n+  PR_ASSERT(pt_continuation_done == op->status);\n+  return op->result.code;\n } /* pt_Continue */\n \n /*****************************************************************************/\n /*********************** specific continuation functions *********************/\n /*****************************************************************************/\n-static PRBool\n-pt_connect_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    op->syserrno = _MD_unix_get_nonblocking_connect_error(op->arg1.osfd);\n-    if (op->syserrno != 0) {\n-        op->result.code = -1;\n-    } else {\n-        op->result.code = 0;\n-    }\n-    return PR_TRUE; /* this one is cooked */\n+static PRBool pt_connect_cont(pt_Continuation* op, PRInt16 revents) {\n+  op->syserrno = _MD_unix_get_nonblocking_connect_error(op->arg1.osfd);\n+  if (op->syserrno != 0) {\n+    op->result.code = -1;\n+  } else {\n+    op->result.code = 0;\n+  }\n+  return PR_TRUE; /* this one is cooked */\n } /* pt_connect_cont */\n \n-static PRBool\n-pt_accept_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    op->syserrno = 0;\n-    op->result.code = accept(op->arg1.osfd, op->arg2.buffer, op->arg3.addr_len);\n-    if (-1 == op->result.code) {\n-        op->syserrno = errno;\n-        if (EWOULDBLOCK == errno || EAGAIN == errno || ECONNABORTED == errno) {\n-            return PR_FALSE; /* do nothing - this one ain't finished */\n-        }\n+static PRBool pt_accept_cont(pt_Continuation* op, PRInt16 revents) {\n+  op->syserrno = 0;\n+  op->result.code = accept(op->arg1.osfd, op->arg2.buffer, op->arg3.addr_len);\n+  if (-1 == op->result.code) {\n+    op->syserrno = errno;\n+    if (EWOULDBLOCK == errno || EAGAIN == errno || ECONNABORTED == errno) {\n+      return PR_FALSE; /* do nothing - this one ain't finished */\n     }\n-    return PR_TRUE;\n+  }\n+  return PR_TRUE;\n } /* pt_accept_cont */\n \n-static PRBool\n-pt_read_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    /*\n-     * Any number of bytes will complete the operation. It need\n-     * not (and probably will not) satisfy the request. The only\n-     * error we continue is EWOULDBLOCK|EAGAIN.\n-     */\n-    op->result.code = read(op->arg1.osfd, op->arg2.buffer, op->arg3.amount);\n-    op->syserrno = errno;\n-    return ((-1 == op->result.code) &&\n-            (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno))\n-               ? PR_FALSE\n-               : PR_TRUE;\n+static PRBool pt_read_cont(pt_Continuation* op, PRInt16 revents) {\n+  /*\n+   * Any number of bytes will complete the operation. It need\n+   * not (and probably will not) satisfy the request. The only\n+   * error we continue is EWOULDBLOCK|EAGAIN.\n+   */\n+  op->result.code = read(op->arg1.osfd, op->arg2.buffer, op->arg3.amount);\n+  op->syserrno = errno;\n+  return ((-1 == op->result.code) &&\n+          (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno))\n+             ? PR_FALSE\n+             : PR_TRUE;\n } /* pt_read_cont */\n \n-static PRBool\n-pt_recv_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    /*\n-     * Any number of bytes will complete the operation. It need\n-     * not (and probably will not) satisfy the request. The only\n-     * error we continue is EWOULDBLOCK|EAGAIN.\n-     */\n-#if defined(SOLARIS)\n-    if (0 == op->arg4.flags)\n-        op->result.code = read(op->arg1.osfd, op->arg2.buffer, op->arg3.amount);\n-    else\n-        op->result.code =\n-            recv(op->arg1.osfd, op->arg2.buffer, op->arg3.amount, op->arg4.flags);\n-#else\n+static PRBool pt_recv_cont(pt_Continuation* op, PRInt16 revents) {\n+  /*\n+   * Any number of bytes will complete the operation. It need\n+   * not (and probably will not) satisfy the request. The only\n+   * error we continue is EWOULDBLOCK|EAGAIN.\n+   */\n+#  if defined(SOLARIS)\n+  if (0 == op->arg4.flags)\n+    op->result.code = read(op->arg1.osfd, op->arg2.buffer, op->arg3.amount);\n+  else\n     op->result.code =\n         recv(op->arg1.osfd, op->arg2.buffer, op->arg3.amount, op->arg4.flags);\n-#endif\n-    op->syserrno = errno;\n-    return ((-1 == op->result.code) &&\n-            (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno))\n-               ? PR_FALSE\n-               : PR_TRUE;\n+#  else\n+  op->result.code =\n+      recv(op->arg1.osfd, op->arg2.buffer, op->arg3.amount, op->arg4.flags);\n+#  endif\n+  op->syserrno = errno;\n+  return ((-1 == op->result.code) &&\n+          (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno))\n+             ? PR_FALSE\n+             : PR_TRUE;\n } /* pt_recv_cont */\n \n-static PRBool\n-pt_send_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    PRIntn bytes;\n-#if defined(SOLARIS)\n-    PRInt32 tmp_amount = op->arg3.amount;\n-#endif\n-    /*\n-     * We want to write the entire amount out, no matter how many\n-     * tries it takes. Keep advancing the buffer and the decrementing\n-     * the amount until the amount goes away. Return the total bytes\n-     * (which should be the original amount) when finished (or an\n-     * error).\n-     */\n-#if defined(SOLARIS)\n+static PRBool pt_send_cont(pt_Continuation* op, PRInt16 revents) {\n+  PRIntn bytes;\n+#  if defined(SOLARIS)\n+  PRInt32 tmp_amount = op->arg3.amount;\n+#  endif\n+  /*\n+   * We want to write the entire amount out, no matter how many\n+   * tries it takes. Keep advancing the buffer and the decrementing\n+   * the amount until the amount goes away. Return the total bytes\n+   * (which should be the original amount) when finished (or an\n+   * error).\n+   */\n+#  if defined(SOLARIS)\n retry:\n-    bytes = write(op->arg1.osfd, op->arg2.buffer, tmp_amount);\n-#else\n-    bytes = send(op->arg1.osfd, op->arg2.buffer, op->arg3.amount, op->arg4.flags);\n-#endif\n-    op->syserrno = errno;\n-\n-#if defined(SOLARIS)\n-    /*\n-     * The write system call has been reported to return the ERANGE error\n-     * on occasion. Try to write in smaller chunks to workaround this bug.\n-     */\n-    if ((bytes == -1) && (op->syserrno == ERANGE)) {\n-        if (tmp_amount > 1) {\n-            tmp_amount = tmp_amount / 2; /* half the bytes */\n-            goto retry;\n-        }\n-    }\n-#endif\n-\n-    if (bytes >= 0) /* this is progress */\n-    {\n-        char* bp = (char*)op->arg2.buffer;\n-        bp += bytes; /* adjust the buffer pointer */\n-        op->arg2.buffer = bp;\n-        op->result.code += bytes; /* accumulate the number sent */\n-        op->arg3.amount -= bytes; /* and reduce the required count */\n-        return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;\n-    }\n-    if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno)) {\n-        op->result.code = -1;\n-        return PR_TRUE;\n-    } else {\n-        return PR_FALSE;\n-    }\n+  bytes = write(op->arg1.osfd, op->arg2.buffer, tmp_amount);\n+#  else\n+  bytes = send(op->arg1.osfd, op->arg2.buffer, op->arg3.amount, op->arg4.flags);\n+#  endif\n+  op->syserrno = errno;\n+\n+#  if defined(SOLARIS)\n+  /*\n+   * The write system call has been reported to return the ERANGE error\n+   * on occasion. Try to write in smaller chunks to workaround this bug.\n+   */\n+  if ((bytes == -1) && (op->syserrno == ERANGE)) {\n+    if (tmp_amount > 1) {\n+      tmp_amount = tmp_amount / 2; /* half the bytes */\n+      goto retry;\n+    }\n+  }\n+#  endif\n+\n+  if (bytes >= 0) /* this is progress */\n+  {\n+    char* bp = (char*)op->arg2.buffer;\n+    bp += bytes; /* adjust the buffer pointer */\n+    op->arg2.buffer = bp;\n+    op->result.code += bytes; /* accumulate the number sent */\n+    op->arg3.amount -= bytes; /* and reduce the required count */\n+    return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;\n+  }\n+  if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno)) {\n+    op->result.code = -1;\n+    return PR_TRUE;\n+  } else {\n+    return PR_FALSE;\n+  }\n } /* pt_send_cont */\n \n-static PRBool\n-pt_write_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    PRIntn bytes;\n-    /*\n-     * We want to write the entire amount out, no matter how many\n-     * tries it takes. Keep advancing the buffer and the decrementing\n-     * the amount until the amount goes away. Return the total bytes\n-     * (which should be the original amount) when finished (or an\n-     * error).\n-     */\n-    bytes = write(op->arg1.osfd, op->arg2.buffer, op->arg3.amount);\n-    op->syserrno = errno;\n-    if (bytes >= 0) /* this is progress */\n-    {\n-        char* bp = (char*)op->arg2.buffer;\n-        bp += bytes; /* adjust the buffer pointer */\n-        op->arg2.buffer = bp;\n-        op->result.code += bytes; /* accumulate the number sent */\n-        op->arg3.amount -= bytes; /* and reduce the required count */\n-        return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;\n-    }\n-    if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno)) {\n-        op->result.code = -1;\n-        return PR_TRUE;\n-    } else {\n-        return PR_FALSE;\n-    }\n+static PRBool pt_write_cont(pt_Continuation* op, PRInt16 revents) {\n+  PRIntn bytes;\n+  /*\n+   * We want to write the entire amount out, no matter how many\n+   * tries it takes. Keep advancing the buffer and the decrementing\n+   * the amount until the amount goes away. Return the total bytes\n+   * (which should be the original amount) when finished (or an\n+   * error).\n+   */\n+  bytes = write(op->arg1.osfd, op->arg2.buffer, op->arg3.amount);\n+  op->syserrno = errno;\n+  if (bytes >= 0) /* this is progress */\n+  {\n+    char* bp = (char*)op->arg2.buffer;\n+    bp += bytes; /* adjust the buffer pointer */\n+    op->arg2.buffer = bp;\n+    op->result.code += bytes; /* accumulate the number sent */\n+    op->arg3.amount -= bytes; /* and reduce the required count */\n+    return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;\n+  }\n+  if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno)) {\n+    op->result.code = -1;\n+    return PR_TRUE;\n+  } else {\n+    return PR_FALSE;\n+  }\n } /* pt_write_cont */\n \n-static PRBool\n-pt_writev_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    PRIntn bytes;\n-    struct iovec* iov = (struct iovec*)op->arg2.buffer;\n-    /*\n-     * Same rules as write, but continuing seems to be a bit more\n-     * complicated. As the number of bytes sent grows, we have to\n-     * redefine the vector we're pointing at. We might have to\n-     * modify an individual vector parms or we might have to eliminate\n-     * a pair altogether.\n-     */\n-    bytes = writev(op->arg1.osfd, iov, op->arg3.amount);\n-    op->syserrno = errno;\n-    if (bytes >= 0) /* this is progress */\n-    {\n-        PRIntn iov_index;\n-        op->result.code += bytes; /* accumulate the number sent */\n-        for (iov_index = 0; iov_index < op->arg3.amount; ++iov_index) {\n-            /* how much progress did we make in the i/o vector? */\n-            if (bytes < iov[iov_index].iov_len) {\n-                /* this element's not done yet */\n-                char** bp = (char**)&(iov[iov_index].iov_base);\n-                iov[iov_index].iov_len -= bytes; /* there's that much left */\n-                *bp += bytes;                    /* starting there */\n-                break;                           /* go off and do that */\n-            }\n-            bytes -= iov[iov_index].iov_len; /* that element's consumed */\n-        }\n-        op->arg2.buffer = &iov[iov_index]; /* new start of array */\n-        op->arg3.amount -= iov_index;      /* and array length */\n-        return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;\n-    }\n-    if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno)) {\n-        op->result.code = -1;\n-        return PR_TRUE;\n-    } else {\n-        return PR_FALSE;\n-    }\n+static PRBool pt_writev_cont(pt_Continuation* op, PRInt16 revents) {\n+  PRIntn bytes;\n+  struct iovec* iov = (struct iovec*)op->arg2.buffer;\n+  /*\n+   * Same rules as write, but continuing seems to be a bit more\n+   * complicated. As the number of bytes sent grows, we have to\n+   * redefine the vector we're pointing at. We might have to\n+   * modify an individual vector parms or we might have to eliminate\n+   * a pair altogether.\n+   */\n+  bytes = writev(op->arg1.osfd, iov, op->arg3.amount);\n+  op->syserrno = errno;\n+  if (bytes >= 0) /* this is progress */\n+  {\n+    PRIntn iov_index;\n+    op->result.code += bytes; /* accumulate the number sent */\n+    for (iov_index = 0; iov_index < op->arg3.amount; ++iov_index) {\n+      /* how much progress did we make in the i/o vector? */\n+      if (bytes < iov[iov_index].iov_len) {\n+        /* this element's not done yet */\n+        char** bp = (char**)&(iov[iov_index].iov_base);\n+        iov[iov_index].iov_len -= bytes; /* there's that much left */\n+        *bp += bytes;                    /* starting there */\n+        break;                           /* go off and do that */\n+      }\n+      bytes -= iov[iov_index].iov_len; /* that element's consumed */\n+    }\n+    op->arg2.buffer = &iov[iov_index]; /* new start of array */\n+    op->arg3.amount -= iov_index;      /* and array length */\n+    return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;\n+  }\n+  if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno)) {\n+    op->result.code = -1;\n+    return PR_TRUE;\n+  } else {\n+    return PR_FALSE;\n+  }\n } /* pt_writev_cont */\n \n-static PRBool\n-pt_sendto_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    PRIntn bytes =\n-        sendto(op->arg1.osfd, op->arg2.buffer, op->arg3.amount, op->arg4.flags,\n-               (struct sockaddr*)op->arg5.addr, PR_NETADDR_SIZE(op->arg5.addr));\n-    op->syserrno = errno;\n-    if (bytes >= 0) /* this is progress */\n-    {\n-        char* bp = (char*)op->arg2.buffer;\n-        bp += bytes; /* adjust the buffer pointer */\n-        op->arg2.buffer = bp;\n-        op->result.code += bytes; /* accumulate the number sent */\n-        op->arg3.amount -= bytes; /* and reduce the required count */\n-        return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;\n-    }\n-    if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno)) {\n-        op->result.code = -1;\n-        return PR_TRUE;\n-    } else {\n-        return PR_FALSE;\n-    }\n+static PRBool pt_sendto_cont(pt_Continuation* op, PRInt16 revents) {\n+  PRIntn bytes =\n+      sendto(op->arg1.osfd, op->arg2.buffer, op->arg3.amount, op->arg4.flags,\n+             (struct sockaddr*)op->arg5.addr, PR_NETADDR_SIZE(op->arg5.addr));\n+  op->syserrno = errno;\n+  if (bytes >= 0) /* this is progress */\n+  {\n+    char* bp = (char*)op->arg2.buffer;\n+    bp += bytes; /* adjust the buffer pointer */\n+    op->arg2.buffer = bp;\n+    op->result.code += bytes; /* accumulate the number sent */\n+    op->arg3.amount -= bytes; /* and reduce the required count */\n+    return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;\n+  }\n+  if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno)) {\n+    op->result.code = -1;\n+    return PR_TRUE;\n+  } else {\n+    return PR_FALSE;\n+  }\n } /* pt_sendto_cont */\n \n-static PRBool\n-pt_recvfrom_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    pt_SockLen addr_len = sizeof(PRNetAddr);\n-    op->result.code =\n-        recvfrom(op->arg1.osfd, op->arg2.buffer, op->arg3.amount, op->arg4.flags,\n-                 (struct sockaddr*)op->arg5.addr, &addr_len);\n-    op->syserrno = errno;\n-    return ((-1 == op->result.code) &&\n-            (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno))\n-               ? PR_FALSE\n-               : PR_TRUE;\n+static PRBool pt_recvfrom_cont(pt_Continuation* op, PRInt16 revents) {\n+  pt_SockLen addr_len = sizeof(PRNetAddr);\n+  op->result.code =\n+      recvfrom(op->arg1.osfd, op->arg2.buffer, op->arg3.amount, op->arg4.flags,\n+               (struct sockaddr*)op->arg5.addr, &addr_len);\n+  op->syserrno = errno;\n+  return ((-1 == op->result.code) &&\n+          (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno))\n+             ? PR_FALSE\n+             : PR_TRUE;\n } /* pt_recvfrom_cont */\n \n-#ifdef AIX\n-static PRBool\n-pt_aix_sendfile_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    struct sf_parms* sf_struct = (struct sf_parms*)op->arg2.buffer;\n-    ssize_t rv;\n-    unsigned long long saved_file_offset;\n-    long long saved_file_bytes;\n-\n-    saved_file_offset = sf_struct->file_offset;\n-    saved_file_bytes = sf_struct->file_bytes;\n-    sf_struct->bytes_sent = 0;\n-\n-    if ((sf_struct->file_bytes > 0) && (sf_struct->file_size > 0))\n-        PR_ASSERT((sf_struct->file_bytes + sf_struct->file_offset) <=\n-                  sf_struct->file_size);\n-    rv = AIX_SEND_FILE(&op->arg1.osfd, sf_struct, op->arg4.flags);\n-    op->syserrno = errno;\n-\n-    if (rv != -1) {\n-        op->result.code += sf_struct->bytes_sent;\n-        /*\n-         * A bug in AIX 4.3.2 prevents the 'file_bytes' field from\n-         * being updated. So, 'file_bytes' is maintained by NSPR to\n-         * avoid conflict when this bug is fixed in AIX, in the future.\n-         */\n-        if (saved_file_bytes != -1) {\n-            saved_file_bytes -= (sf_struct->file_offset - saved_file_offset);\n-        }\n-        sf_struct->file_bytes = saved_file_bytes;\n-    } else if (op->syserrno != EWOULDBLOCK && op->syserrno != EAGAIN) {\n-        op->result.code = -1;\n-    } else {\n-        return PR_FALSE;\n+#  ifdef AIX\n+static PRBool pt_aix_sendfile_cont(pt_Continuation* op, PRInt16 revents) {\n+  struct sf_parms* sf_struct = (struct sf_parms*)op->arg2.buffer;\n+  ssize_t rv;\n+  unsigned long long saved_file_offset;\n+  long long saved_file_bytes;\n+\n+  saved_file_offset = sf_struct->file_offset;\n+  saved_file_bytes = sf_struct->file_bytes;\n+  sf_struct->bytes_sent = 0;\n+\n+  if ((sf_struct->file_bytes > 0) && (sf_struct->file_size > 0))\n+    PR_ASSERT((sf_struct->file_bytes + sf_struct->file_offset) <=\n+              sf_struct->file_size);\n+  rv = AIX_SEND_FILE(&op->arg1.osfd, sf_struct, op->arg4.flags);\n+  op->syserrno = errno;\n+\n+  if (rv != -1) {\n+    op->result.code += sf_struct->bytes_sent;\n+    /*\n+     * A bug in AIX 4.3.2 prevents the 'file_bytes' field from\n+     * being updated. So, 'file_bytes' is maintained by NSPR to\n+     * avoid conflict when this bug is fixed in AIX, in the future.\n+     */\n+    if (saved_file_bytes != -1) {\n+      saved_file_bytes -= (sf_struct->file_offset - saved_file_offset);\n     }\n+    sf_struct->file_bytes = saved_file_bytes;\n+  } else if (op->syserrno != EWOULDBLOCK && op->syserrno != EAGAIN) {\n+    op->result.code = -1;\n+  } else {\n+    return PR_FALSE;\n+  }\n \n-    if (rv == 1) { /* more data to send */\n-        return PR_FALSE;\n-    }\n+  if (rv == 1) { /* more data to send */\n+    return PR_FALSE;\n+  }\n \n-    return PR_TRUE;\n+  return PR_TRUE;\n }\n-#endif /* AIX */\n-\n-#ifdef HPUX11\n-static PRBool\n-pt_hpux_sendfile_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    struct iovec* hdtrl = (struct iovec*)op->arg2.buffer;\n-    int count;\n-\n-    count = sendfile(op->arg1.osfd, op->filedesc, op->arg3.file_spec.offset,\n-                     op->arg3.file_spec.nbytes, hdtrl, op->arg4.flags);\n-    PR_ASSERT(count <= op->nbytes_to_send);\n-    op->syserrno = errno;\n+#  endif /* AIX */\n \n-    if (count != -1) {\n-        op->result.code += count;\n-    } else if (op->syserrno != EWOULDBLOCK && op->syserrno != EAGAIN) {\n-        op->result.code = -1;\n-    } else {\n-        return PR_FALSE;\n-    }\n-    if (count != -1 && count < op->nbytes_to_send) {\n-        if (count < hdtrl[0].iov_len) {\n-            /* header not sent */\n-\n-            hdtrl[0].iov_base = ((char*)hdtrl[0].iov_base) + count;\n-            hdtrl[0].iov_len -= count;\n-\n-        } else if (count < (hdtrl[0].iov_len + op->arg3.file_spec.nbytes)) {\n-            /* header sent, file not sent */\n-            PRUint32 file_nbytes_sent = count - hdtrl[0].iov_len;\n+#  ifdef HPUX11\n+static PRBool pt_hpux_sendfile_cont(pt_Continuation* op, PRInt16 revents) {\n+  struct iovec* hdtrl = (struct iovec*)op->arg2.buffer;\n+  int count;\n \n-            hdtrl[0].iov_base = NULL;\n-            hdtrl[0].iov_len = 0;\n-\n-            op->arg3.file_spec.offset += file_nbytes_sent;\n-            op->arg3.file_spec.nbytes -= file_nbytes_sent;\n-        } else if (count < (hdtrl[0].iov_len + op->arg3.file_spec.nbytes +\n-                            hdtrl[1].iov_len)) {\n-            PRUint32 trailer_nbytes_sent =\n-                count - (hdtrl[0].iov_len + op->arg3.file_spec.nbytes);\n-\n-            /* header sent, file sent, trailer not sent */\n-\n-            hdtrl[0].iov_base = NULL;\n-            hdtrl[0].iov_len = 0;\n-            /*\n-             * set file offset and len so that no more file data is\n-             * sent\n-             */\n-            op->arg3.file_spec.offset = op->arg3.file_spec.st_size;\n-            op->arg3.file_spec.nbytes = 0;\n+  count = sendfile(op->arg1.osfd, op->filedesc, op->arg3.file_spec.offset,\n+                   op->arg3.file_spec.nbytes, hdtrl, op->arg4.flags);\n+  PR_ASSERT(count <= op->nbytes_to_send);\n+  op->syserrno = errno;\n \n-            hdtrl[1].iov_base = ((char*)hdtrl[1].iov_base) + trailer_nbytes_sent;\n-            hdtrl[1].iov_len -= trailer_nbytes_sent;\n-        }\n-        op->nbytes_to_send -= count;\n-        return PR_FALSE;\n-    }\n+  if (count != -1) {\n+    op->result.code += count;\n+  } else if (op->syserrno != EWOULDBLOCK && op->syserrno != EAGAIN) {\n+    op->result.code = -1;\n+  } else {\n+    return PR_FALSE;\n+  }\n+  if (count != -1 && count < op->nbytes_to_send) {\n+    if (count < hdtrl[0].iov_len) {\n+      /* header not sent */\n+\n+      hdtrl[0].iov_base = ((char*)hdtrl[0].iov_base) + count;\n+      hdtrl[0].iov_len -= count;\n+\n+    } else if (count < (hdtrl[0].iov_len + op->arg3.file_spec.nbytes)) {\n+      /* header sent, file not sent */\n+      PRUint32 file_nbytes_sent = count - hdtrl[0].iov_len;\n+\n+      hdtrl[0].iov_base = NULL;\n+      hdtrl[0].iov_len = 0;\n+\n+      op->arg3.file_spec.offset += file_nbytes_sent;\n+      op->arg3.file_spec.nbytes -= file_nbytes_sent;\n+    } else if (count < (hdtrl[0].iov_len + op->arg3.file_spec.nbytes +\n+                        hdtrl[1].iov_len)) {\n+      PRUint32 trailer_nbytes_sent =\n+          count - (hdtrl[0].iov_len + op->arg3.file_spec.nbytes);\n+\n+      /* header sent, file sent, trailer not sent */\n+\n+      hdtrl[0].iov_base = NULL;\n+      hdtrl[0].iov_len = 0;\n+      /*\n+       * set file offset and len so that no more file data is\n+       * sent\n+       */\n+      op->arg3.file_spec.offset = op->arg3.file_spec.st_size;\n+      op->arg3.file_spec.nbytes = 0;\n+\n+      hdtrl[1].iov_base = ((char*)hdtrl[1].iov_base) + trailer_nbytes_sent;\n+      hdtrl[1].iov_len -= trailer_nbytes_sent;\n+    }\n+    op->nbytes_to_send -= count;\n+    return PR_FALSE;\n+  }\n \n-    return PR_TRUE;\n+  return PR_TRUE;\n }\n-#endif /* HPUX11 */\n-\n-#ifdef SOLARIS\n-static PRBool\n-pt_solaris_sendfile_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    struct sendfilevec* vec = (struct sendfilevec*)op->arg2.buffer;\n-    size_t xferred;\n-    ssize_t count;\n+#  endif /* HPUX11 */\n+\n+#  ifdef SOLARIS\n+static PRBool pt_solaris_sendfile_cont(pt_Continuation* op, PRInt16 revents) {\n+  struct sendfilevec* vec = (struct sendfilevec*)op->arg2.buffer;\n+  size_t xferred;\n+  ssize_t count;\n+\n+  count = SOLARIS_SENDFILEV(op->arg1.osfd, vec, op->arg3.amount, &xferred);\n+  op->syserrno = errno;\n+  PR_ASSERT((count == -1) || (count == xferred));\n+\n+  if (count == -1) {\n+    if (op->syserrno != EWOULDBLOCK && op->syserrno != EAGAIN &&\n+        op->syserrno != EINTR) {\n+      op->result.code = -1;\n+      return PR_TRUE;\n+    }\n+    count = xferred;\n+  } else if (count == 0) {\n+    /*\n+     * We are now at EOF. The file was truncated. Solaris sendfile is\n+     * supposed to return 0 and no error in this case, though some versions\n+     * may return -1 and EINVAL .\n+     */\n+    op->result.code = -1;\n+    op->syserrno = 0; /* will be treated as EOF */\n+    return PR_TRUE;\n+  }\n+  PR_ASSERT(count <= op->nbytes_to_send);\n \n-    count = SOLARIS_SENDFILEV(op->arg1.osfd, vec, op->arg3.amount, &xferred);\n-    op->syserrno = errno;\n-    PR_ASSERT((count == -1) || (count == xferred));\n+  op->result.code += count;\n+  if (count < op->nbytes_to_send) {\n+    op->nbytes_to_send -= count;\n \n-    if (count == -1) {\n-        if (op->syserrno != EWOULDBLOCK && op->syserrno != EAGAIN &&\n-            op->syserrno != EINTR) {\n-            op->result.code = -1;\n-            return PR_TRUE;\n-        }\n-        count = xferred;\n-    } else if (count == 0) {\n-        /*\n-         * We are now at EOF. The file was truncated. Solaris sendfile is\n-         * supposed to return 0 and no error in this case, though some versions\n-         * may return -1 and EINVAL .\n-         */\n-        op->result.code = -1;\n-        op->syserrno = 0; /* will be treated as EOF */\n-        return PR_TRUE;\n+    while (count >= vec->sfv_len) {\n+      count -= vec->sfv_len;\n+      vec++;\n+      op->arg3.amount--;\n     }\n-    PR_ASSERT(count <= op->nbytes_to_send);\n-\n-    op->result.code += count;\n-    if (count < op->nbytes_to_send) {\n-        op->nbytes_to_send -= count;\n-\n-        while (count >= vec->sfv_len) {\n-            count -= vec->sfv_len;\n-            vec++;\n-            op->arg3.amount--;\n-        }\n-        PR_ASSERT(op->arg3.amount > 0);\n+    PR_ASSERT(op->arg3.amount > 0);\n \n-        vec->sfv_off += count;\n-        vec->sfv_len -= count;\n-        PR_ASSERT(vec->sfv_len > 0);\n-        op->arg2.buffer = vec;\n+    vec->sfv_off += count;\n+    vec->sfv_len -= count;\n+    PR_ASSERT(vec->sfv_len > 0);\n+    op->arg2.buffer = vec;\n \n-        return PR_FALSE;\n-    }\n+    return PR_FALSE;\n+  }\n \n-    return PR_TRUE;\n+  return PR_TRUE;\n }\n-#endif /* SOLARIS */\n-\n-#ifdef LINUX\n-static PRBool\n-pt_linux_sendfile_cont(pt_Continuation* op, PRInt16 revents)\n-{\n-    ssize_t rv;\n-    off_t oldoffset;\n-\n-    oldoffset = op->offset;\n-    rv = sendfile(op->arg1.osfd, op->in_fd, &op->offset, op->count);\n-    op->syserrno = errno;\n-\n-    if (rv == -1) {\n-        if (op->syserrno != EWOULDBLOCK && op->syserrno != EAGAIN) {\n-            op->result.code = -1;\n-            return PR_TRUE;\n-        }\n-        rv = 0;\n-    }\n-    PR_ASSERT(rv == op->offset - oldoffset);\n-    op->result.code += rv;\n-    if (rv < op->count) {\n-        op->count -= rv;\n-        return PR_FALSE;\n-    }\n-    return PR_TRUE;\n+#  endif /* SOLARIS */\n+\n+#  ifdef LINUX\n+static PRBool pt_linux_sendfile_cont(pt_Continuation* op, PRInt16 revents) {\n+  ssize_t rv;\n+  off_t oldoffset;\n+\n+  oldoffset = op->offset;\n+  rv = sendfile(op->arg1.osfd, op->in_fd, &op->offset, op->count);\n+  op->syserrno = errno;\n+\n+  if (rv == -1) {\n+    if (op->syserrno != EWOULDBLOCK && op->syserrno != EAGAIN) {\n+      op->result.code = -1;\n+      return PR_TRUE;\n+    }\n+    rv = 0;\n+  }\n+  PR_ASSERT(rv == op->offset - oldoffset);\n+  op->result.code += rv;\n+  if (rv < op->count) {\n+    op->count -= rv;\n+    return PR_FALSE;\n+  }\n+  return PR_TRUE;\n }\n-#endif /* LINUX */\n-\n-void\n-_PR_InitIO(void)\n-{\n-#if defined(DEBUG)\n-    memset(&pt_debug, 0, sizeof(PTDebug));\n-    pt_debug.timeStarted = PR_Now();\n-#endif\n-\n-    _pr_flock_lock = PR_NewLock();\n-    PR_ASSERT(NULL != _pr_flock_lock);\n-    _pr_flock_cv = PR_NewCondVar(_pr_flock_lock);\n-    PR_ASSERT(NULL != _pr_flock_cv);\n-    _pr_rename_lock = PR_NewLock();\n-    PR_ASSERT(NULL != _pr_rename_lock);\n-\n-    _PR_InitFdCache(); /* do that */\n-\n-    _pr_stdin = pt_SetMethods(0, PR_DESC_FILE, PR_FALSE, PR_TRUE);\n-    _pr_stdout = pt_SetMethods(1, PR_DESC_FILE, PR_FALSE, PR_TRUE);\n-    _pr_stderr = pt_SetMethods(2, PR_DESC_FILE, PR_FALSE, PR_TRUE);\n-    PR_ASSERT(_pr_stdin && _pr_stdout && _pr_stderr);\n-\n-#ifdef _PR_IPV6_V6ONLY_PROBE\n-    /* In Mac OS X v10.3 Panther Beta the IPV6_V6ONLY socket option\n-     * is turned on by default, contrary to what RFC 3493, Section\n-     * 5.3 says.  So we have to turn it off.  Find out whether we\n-     * are running on such a system.\n-     */\n-    {\n-        int osfd;\n-        osfd = socket(AF_INET6, SOCK_STREAM, 0);\n-        if (osfd != -1) {\n-            int on;\n-            socklen_t optlen = sizeof(on);\n-            if (getsockopt(osfd, IPPROTO_IPV6, IPV6_V6ONLY, &on, &optlen) == 0) {\n-                _pr_ipv6_v6only_on_by_default = on;\n-            }\n-            close(osfd);\n-        }\n-    }\n-#endif\n+#  endif /* LINUX */\n+\n+void _PR_InitIO(void) {\n+#  if defined(DEBUG)\n+  memset(&pt_debug, 0, sizeof(PTDebug));\n+  pt_debug.timeStarted = PR_Now();\n+#  endif\n+\n+  _pr_flock_lock = PR_NewLock();\n+  PR_ASSERT(NULL != _pr_flock_lock);\n+  _pr_flock_cv = PR_NewCondVar(_pr_flock_lock);\n+  PR_ASSERT(NULL != _pr_flock_cv);\n+  _pr_rename_lock = PR_NewLock();\n+  PR_ASSERT(NULL != _pr_rename_lock);\n+\n+  _PR_InitFdCache(); /* do that */\n+\n+  _pr_stdin = pt_SetMethods(0, PR_DESC_FILE, PR_FALSE, PR_TRUE);\n+  _pr_stdout = pt_SetMethods(1, PR_DESC_FILE, PR_FALSE, PR_TRUE);\n+  _pr_stderr = pt_SetMethods(2, PR_DESC_FILE, PR_FALSE, PR_TRUE);\n+  PR_ASSERT(_pr_stdin && _pr_stdout && _pr_stderr);\n+\n+#  ifdef _PR_IPV6_V6ONLY_PROBE\n+  /* In Mac OS X v10.3 Panther Beta the IPV6_V6ONLY socket option\n+   * is turned on by default, contrary to what RFC 3493, Section\n+   * 5.3 says.  So we have to turn it off.  Find out whether we\n+   * are running on such a system.\n+   */\n+  {\n+    int osfd;\n+    osfd = socket(AF_INET6, SOCK_STREAM, 0);\n+    if (osfd != -1) {\n+      int on;\n+      socklen_t optlen = sizeof(on);\n+      if (getsockopt(osfd, IPPROTO_IPV6, IPV6_V6ONLY, &on, &optlen) == 0) {\n+        _pr_ipv6_v6only_on_by_default = on;\n+      }\n+      close(osfd);\n+    }\n+  }\n+#  endif\n } /* _PR_InitIO */\n \n-void\n-_PR_CleanupIO(void)\n-{\n-    _PR_Putfd(_pr_stdin);\n-    _pr_stdin = NULL;\n-    _PR_Putfd(_pr_stdout);\n-    _pr_stdout = NULL;\n-    _PR_Putfd(_pr_stderr);\n-    _pr_stderr = NULL;\n-\n-    _PR_CleanupFdCache();\n-\n-    if (_pr_flock_cv) {\n-        PR_DestroyCondVar(_pr_flock_cv);\n-        _pr_flock_cv = NULL;\n-    }\n-    if (_pr_flock_lock) {\n-        PR_DestroyLock(_pr_flock_lock);\n-        _pr_flock_lock = NULL;\n-    }\n-    if (_pr_rename_lock) {\n-        PR_DestroyLock(_pr_rename_lock);\n-        _pr_rename_lock = NULL;\n-    }\n+void _PR_CleanupIO(void) {\n+  _PR_Putfd(_pr_stdin);\n+  _pr_stdin = NULL;\n+  _PR_Putfd(_pr_stdout);\n+  _pr_stdout = NULL;\n+  _PR_Putfd(_pr_stderr);\n+  _pr_stderr = NULL;\n+\n+  _PR_CleanupFdCache();\n+\n+  if (_pr_flock_cv) {\n+    PR_DestroyCondVar(_pr_flock_cv);\n+    _pr_flock_cv = NULL;\n+  }\n+  if (_pr_flock_lock) {\n+    PR_DestroyLock(_pr_flock_lock);\n+    _pr_flock_lock = NULL;\n+  }\n+  if (_pr_rename_lock) {\n+    PR_DestroyLock(_pr_rename_lock);\n+    _pr_rename_lock = NULL;\n+  }\n } /* _PR_CleanupIO */\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_GetSpecialFD(PRSpecialFD osfd)\n-{\n-    PRFileDesc* result = NULL;\n-    PR_ASSERT(osfd >= PR_StandardInput && osfd <= PR_StandardError);\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    switch (osfd) {\n-        case PR_StandardInput:\n-            result = _pr_stdin;\n-            break;\n-        case PR_StandardOutput:\n-            result = _pr_stdout;\n-            break;\n-        case PR_StandardError:\n-            result = _pr_stderr;\n-            break;\n-        default:\n-            (void)PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-    }\n-    return result;\n+PR_IMPLEMENT(PRFileDesc*) PR_GetSpecialFD(PRSpecialFD osfd) {\n+  PRFileDesc* result = NULL;\n+  PR_ASSERT(osfd >= PR_StandardInput && osfd <= PR_StandardError);\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  switch (osfd) {\n+    case PR_StandardInput:\n+      result = _pr_stdin;\n+      break;\n+    case PR_StandardOutput:\n+      result = _pr_stdout;\n+      break;\n+    case PR_StandardError:\n+      result = _pr_stderr;\n+      break;\n+    default:\n+      (void)PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  }\n+  return result;\n } /* PR_GetSpecialFD */\n \n /*****************************************************************************/\n /***************************** I/O private methods ***************************/\n /*****************************************************************************/\n \n-static PRBool\n-pt_TestAbort(void)\n-{\n-    PRThread* me = PR_GetCurrentThread();\n-    if (_PT_THREAD_INTERRUPTED(me)) {\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        me->state &= ~PT_THREAD_ABORTED;\n-        return PR_TRUE;\n-    }\n-    return PR_FALSE;\n+static PRBool pt_TestAbort(void) {\n+  PRThread* me = PR_GetCurrentThread();\n+  if (_PT_THREAD_INTERRUPTED(me)) {\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    me->state &= ~PT_THREAD_ABORTED;\n+    return PR_TRUE;\n+  }\n+  return PR_FALSE;\n } /* pt_TestAbort */\n \n-static void\n-pt_MapError(void (*mapper)(PRIntn), PRIntn syserrno)\n-{\n-    switch (syserrno) {\n-        case EINTR:\n-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-            break;\n-        case ETIMEDOUT:\n-            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-            break;\n-        default:\n-            mapper(syserrno);\n-    }\n+static void pt_MapError(void (*mapper)(PRIntn), PRIntn syserrno) {\n+  switch (syserrno) {\n+    case EINTR:\n+      PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+      break;\n+    case ETIMEDOUT:\n+      PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+      break;\n+    default:\n+      mapper(syserrno);\n+  }\n } /* pt_MapError */\n \n-static PRStatus\n-pt_Close(PRFileDesc* fd)\n-{\n-    if ((NULL == fd) || (NULL == fd->secret) ||\n-        ((_PR_FILEDESC_OPEN != fd->secret->state) &&\n-         (_PR_FILEDESC_CLOSED != fd->secret->state))) {\n-        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+static PRStatus pt_Close(PRFileDesc* fd) {\n+  if ((NULL == fd) || (NULL == fd->secret) ||\n+      ((_PR_FILEDESC_OPEN != fd->secret->state) &&\n+       (_PR_FILEDESC_CLOSED != fd->secret->state))) {\n+    PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n \n-    if (_PR_FILEDESC_OPEN == fd->secret->state) {\n-        if (-1 == close(fd->secret->md.osfd)) {\n-            pt_MapError(_PR_MD_MAP_CLOSE_ERROR, errno);\n-            return PR_FAILURE;\n-        }\n-        fd->secret->state = _PR_FILEDESC_CLOSED;\n+  if (_PR_FILEDESC_OPEN == fd->secret->state) {\n+    if (-1 == close(fd->secret->md.osfd)) {\n+      pt_MapError(_PR_MD_MAP_CLOSE_ERROR, errno);\n+      return PR_FAILURE;\n     }\n-    _PR_Putfd(fd);\n-    return PR_SUCCESS;\n+    fd->secret->state = _PR_FILEDESC_CLOSED;\n+  }\n+  _PR_Putfd(fd);\n+  return PR_SUCCESS;\n } /* pt_Close */\n \n-static PRInt32\n-pt_Read(PRFileDesc* fd, void* buf, PRInt32 amount)\n-{\n-    PRInt32 syserrno, bytes = -1;\n-\n-    if (pt_TestAbort()) {\n-        return bytes;\n-    }\n-\n-    bytes = read(fd->secret->md.osfd, buf, amount);\n-    syserrno = errno;\n+static PRInt32 pt_Read(PRFileDesc* fd, void* buf, PRInt32 amount) {\n+  PRInt32 syserrno, bytes = -1;\n \n-    if ((bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n-        (!fd->secret->nonblocking)) {\n-        pt_Continuation op;\n-        op.arg1.osfd = fd->secret->md.osfd;\n-        op.arg2.buffer = buf;\n-        op.arg3.amount = amount;\n-        op.timeout = PR_INTERVAL_NO_TIMEOUT;\n-        op.function = pt_read_cont;\n-        op.event = POLLIN | POLLPRI;\n-        bytes = pt_Continue(&op);\n-        syserrno = op.syserrno;\n-    }\n-    if (bytes < 0) {\n-        pt_MapError(_PR_MD_MAP_READ_ERROR, syserrno);\n-    }\n+  if (pt_TestAbort()) {\n     return bytes;\n+  }\n+\n+  bytes = read(fd->secret->md.osfd, buf, amount);\n+  syserrno = errno;\n+\n+  if ((bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n+      (!fd->secret->nonblocking)) {\n+    pt_Continuation op;\n+    op.arg1.osfd = fd->secret->md.osfd;\n+    op.arg2.buffer = buf;\n+    op.arg3.amount = amount;\n+    op.timeout = PR_INTERVAL_NO_TIMEOUT;\n+    op.function = pt_read_cont;\n+    op.event = POLLIN | POLLPRI;\n+    bytes = pt_Continue(&op);\n+    syserrno = op.syserrno;\n+  }\n+  if (bytes < 0) {\n+    pt_MapError(_PR_MD_MAP_READ_ERROR, syserrno);\n+  }\n+  return bytes;\n } /* pt_Read */\n \n-static PRInt32\n-pt_Write(PRFileDesc* fd, const void* buf, PRInt32 amount)\n-{\n-    PRInt32 syserrno, bytes = -1;\n-    PRBool fNeedContinue = PR_FALSE;\n-\n-    if (pt_TestAbort()) {\n-        return bytes;\n-    }\n-\n-    bytes = write(fd->secret->md.osfd, buf, amount);\n-    syserrno = errno;\n-\n-    if ((bytes >= 0) && (bytes < amount) && (!fd->secret->nonblocking)) {\n-        buf = (char*)buf + bytes;\n-        amount -= bytes;\n-        fNeedContinue = PR_TRUE;\n-    }\n-    if ((bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n-        (!fd->secret->nonblocking)) {\n-        bytes = 0;\n-        fNeedContinue = PR_TRUE;\n-    }\n+static PRInt32 pt_Write(PRFileDesc* fd, const void* buf, PRInt32 amount) {\n+  PRInt32 syserrno, bytes = -1;\n+  PRBool fNeedContinue = PR_FALSE;\n \n-    if (fNeedContinue == PR_TRUE) {\n-        pt_Continuation op;\n-        op.arg1.osfd = fd->secret->md.osfd;\n-        op.arg2.buffer = (void*)buf;\n-        op.arg3.amount = amount;\n-        op.timeout = PR_INTERVAL_NO_TIMEOUT;\n-        op.result.code = bytes; /* initialize the number sent */\n-        op.function = pt_write_cont;\n-        op.event = POLLOUT | POLLPRI;\n-        bytes = pt_Continue(&op);\n-        syserrno = op.syserrno;\n-    }\n-    if (bytes == -1) {\n-        pt_MapError(_PR_MD_MAP_WRITE_ERROR, syserrno);\n-    }\n+  if (pt_TestAbort()) {\n     return bytes;\n+  }\n+\n+  bytes = write(fd->secret->md.osfd, buf, amount);\n+  syserrno = errno;\n+\n+  if ((bytes >= 0) && (bytes < amount) && (!fd->secret->nonblocking)) {\n+    buf = (char*)buf + bytes;\n+    amount -= bytes;\n+    fNeedContinue = PR_TRUE;\n+  }\n+  if ((bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n+      (!fd->secret->nonblocking)) {\n+    bytes = 0;\n+    fNeedContinue = PR_TRUE;\n+  }\n+\n+  if (fNeedContinue == PR_TRUE) {\n+    pt_Continuation op;\n+    op.arg1.osfd = fd->secret->md.osfd;\n+    op.arg2.buffer = (void*)buf;\n+    op.arg3.amount = amount;\n+    op.timeout = PR_INTERVAL_NO_TIMEOUT;\n+    op.result.code = bytes; /* initialize the number sent */\n+    op.function = pt_write_cont;\n+    op.event = POLLOUT | POLLPRI;\n+    bytes = pt_Continue(&op);\n+    syserrno = op.syserrno;\n+  }\n+  if (bytes == -1) {\n+    pt_MapError(_PR_MD_MAP_WRITE_ERROR, syserrno);\n+  }\n+  return bytes;\n } /* pt_Write */\n \n-static PRInt32\n-pt_Writev(PRFileDesc* fd, const PRIOVec* iov, PRInt32 iov_len,\n-          PRIntervalTime timeout)\n-{\n-    PRIntn iov_index;\n-    PRBool fNeedContinue = PR_FALSE;\n-    PRInt32 syserrno, bytes, rv = -1;\n-    struct iovec osiov_local[PR_MAX_IOVECTOR_SIZE], *osiov;\n-    int osiov_len;\n-\n-    if (pt_TestAbort()) {\n-        return rv;\n-    }\n-\n-    /* Ensured by PR_Writev */\n-    PR_ASSERT(iov_len <= PR_MAX_IOVECTOR_SIZE);\n-\n-    /*\n-     * We can't pass iov to writev because PRIOVec and struct iovec\n-     * may not be binary compatible.  Make osiov a copy of iov and\n-     * pass osiov to writev.  We can modify osiov if we need to\n-     * continue the operation.\n-     */\n-    osiov = osiov_local;\n-    osiov_len = iov_len;\n-    for (iov_index = 0; iov_index < osiov_len; iov_index++) {\n-        osiov[iov_index].iov_base = iov[iov_index].iov_base;\n-        osiov[iov_index].iov_len = iov[iov_index].iov_len;\n-    }\n-\n-    rv = bytes = writev(fd->secret->md.osfd, osiov, osiov_len);\n-    syserrno = errno;\n-\n-    if (!fd->secret->nonblocking) {\n-        if (bytes >= 0) {\n-            /*\n-             * If we moved some bytes, how does that implicate the\n-             * i/o vector list?  In other words, exactly where are\n-             * we within that array?  What are the parameters for\n-             * resumption?  Maybe we're done!\n-             */\n-            for (; osiov_len > 0; osiov++, osiov_len--) {\n-                if (bytes < osiov->iov_len) {\n-                    /* this one's not done yet */\n-                    osiov->iov_base = (char*)osiov->iov_base + bytes;\n-                    osiov->iov_len -= bytes;\n-                    break; /* go off and do that */\n-                }\n-                bytes -= osiov->iov_len; /* this one's done cooked */\n-            }\n-            PR_ASSERT(osiov_len > 0 || bytes == 0);\n-            if (osiov_len > 0) {\n-                if (PR_INTERVAL_NO_WAIT == timeout) {\n-                    rv = -1;\n-                    syserrno = ETIMEDOUT;\n-                } else {\n-                    fNeedContinue = PR_TRUE;\n-                }\n-            }\n-        } else if (syserrno == EWOULDBLOCK || syserrno == EAGAIN) {\n-            if (PR_INTERVAL_NO_WAIT == timeout) {\n-                syserrno = ETIMEDOUT;\n-            } else {\n-                rv = 0;\n-                fNeedContinue = PR_TRUE;\n-            }\n-        }\n-    }\n+static PRInt32 pt_Writev(PRFileDesc* fd, const PRIOVec* iov, PRInt32 iov_len,\n+                         PRIntervalTime timeout) {\n+  PRIntn iov_index;\n+  PRBool fNeedContinue = PR_FALSE;\n+  PRInt32 syserrno, bytes, rv = -1;\n+  struct iovec osiov_local[PR_MAX_IOVECTOR_SIZE], *osiov;\n+  int osiov_len;\n \n-    if (fNeedContinue == PR_TRUE) {\n-        pt_Continuation op;\n-\n-        op.arg1.osfd = fd->secret->md.osfd;\n-        op.arg2.buffer = (void*)osiov;\n-        op.arg3.amount = osiov_len;\n-        op.timeout = timeout;\n-        op.result.code = rv;\n-        op.function = pt_writev_cont;\n-        op.event = POLLOUT | POLLPRI;\n-        rv = pt_Continue(&op);\n-        syserrno = op.syserrno;\n-    }\n-    if (rv == -1) {\n-        pt_MapError(_PR_MD_MAP_WRITEV_ERROR, syserrno);\n-    }\n+  if (pt_TestAbort()) {\n     return rv;\n+  }\n+\n+  /* Ensured by PR_Writev */\n+  PR_ASSERT(iov_len <= PR_MAX_IOVECTOR_SIZE);\n+\n+  /*\n+   * We can't pass iov to writev because PRIOVec and struct iovec\n+   * may not be binary compatible.  Make osiov a copy of iov and\n+   * pass osiov to writev.  We can modify osiov if we need to\n+   * continue the operation.\n+   */\n+  osiov = osiov_local;\n+  osiov_len = iov_len;\n+  for (iov_index = 0; iov_index < osiov_len; iov_index++) {\n+    osiov[iov_index].iov_base = iov[iov_index].iov_base;\n+    osiov[iov_index].iov_len = iov[iov_index].iov_len;\n+  }\n+\n+  rv = bytes = writev(fd->secret->md.osfd, osiov, osiov_len);\n+  syserrno = errno;\n+\n+  if (!fd->secret->nonblocking) {\n+    if (bytes >= 0) {\n+      /*\n+       * If we moved some bytes, how does that implicate the\n+       * i/o vector list?  In other words, exactly where are\n+       * we within that array?  What are the parameters for\n+       * resumption?  Maybe we're done!\n+       */\n+      for (; osiov_len > 0; osiov++, osiov_len--) {\n+        if (bytes < osiov->iov_len) {\n+          /* this one's not done yet */\n+          osiov->iov_base = (char*)osiov->iov_base + bytes;\n+          osiov->iov_len -= bytes;\n+          break; /* go off and do that */\n+        }\n+        bytes -= osiov->iov_len; /* this one's done cooked */\n+      }\n+      PR_ASSERT(osiov_len > 0 || bytes == 0);\n+      if (osiov_len > 0) {\n+        if (PR_INTERVAL_NO_WAIT == timeout) {\n+          rv = -1;\n+          syserrno = ETIMEDOUT;\n+        } else {\n+          fNeedContinue = PR_TRUE;\n+        }\n+      }\n+    } else if (syserrno == EWOULDBLOCK || syserrno == EAGAIN) {\n+      if (PR_INTERVAL_NO_WAIT == timeout) {\n+        syserrno = ETIMEDOUT;\n+      } else {\n+        rv = 0;\n+        fNeedContinue = PR_TRUE;\n+      }\n+    }\n+  }\n+\n+  if (fNeedContinue == PR_TRUE) {\n+    pt_Continuation op;\n+\n+    op.arg1.osfd = fd->secret->md.osfd;\n+    op.arg2.buffer = (void*)osiov;\n+    op.arg3.amount = osiov_len;\n+    op.timeout = timeout;\n+    op.result.code = rv;\n+    op.function = pt_writev_cont;\n+    op.event = POLLOUT | POLLPRI;\n+    rv = pt_Continue(&op);\n+    syserrno = op.syserrno;\n+  }\n+  if (rv == -1) {\n+    pt_MapError(_PR_MD_MAP_WRITEV_ERROR, syserrno);\n+  }\n+  return rv;\n } /* pt_Writev */\n \n-static PRInt32\n-pt_Seek(PRFileDesc* fd, PRInt32 offset, PRSeekWhence whence)\n-{\n-    return _PR_MD_LSEEK(fd, offset, whence);\n+static PRInt32 pt_Seek(PRFileDesc* fd, PRInt32 offset, PRSeekWhence whence) {\n+  return _PR_MD_LSEEK(fd, offset, whence);\n } /* pt_Seek */\n \n-static PRInt64\n-pt_Seek64(PRFileDesc* fd, PRInt64 offset, PRSeekWhence whence)\n-{\n-    return _PR_MD_LSEEK64(fd, offset, whence);\n+static PRInt64 pt_Seek64(PRFileDesc* fd, PRInt64 offset, PRSeekWhence whence) {\n+  return _PR_MD_LSEEK64(fd, offset, whence);\n } /* pt_Seek64 */\n \n-static PRInt32\n-pt_Available_f(PRFileDesc* fd)\n-{\n-    PRInt32 result, cur, end;\n+static PRInt32 pt_Available_f(PRFileDesc* fd) {\n+  PRInt32 result, cur, end;\n \n-    cur = _PR_MD_LSEEK(fd, 0, PR_SEEK_CUR);\n+  cur = _PR_MD_LSEEK(fd, 0, PR_SEEK_CUR);\n \n-    if (cur >= 0) {\n-        end = _PR_MD_LSEEK(fd, 0, PR_SEEK_END);\n-    }\n+  if (cur >= 0) {\n+    end = _PR_MD_LSEEK(fd, 0, PR_SEEK_END);\n+  }\n \n-    if ((cur < 0) || (end < 0)) {\n-        return -1;\n-    }\n+  if ((cur < 0) || (end < 0)) {\n+    return -1;\n+  }\n \n-    result = end - cur;\n-    _PR_MD_LSEEK(fd, cur, PR_SEEK_SET);\n+  result = end - cur;\n+  _PR_MD_LSEEK(fd, cur, PR_SEEK_SET);\n \n-    return result;\n+  return result;\n } /* pt_Available_f */\n \n-static PRInt64\n-pt_Available64_f(PRFileDesc* fd)\n-{\n-    PRInt64 result, cur, end;\n-    PRInt64 minus_one;\n+static PRInt64 pt_Available64_f(PRFileDesc* fd) {\n+  PRInt64 result, cur, end;\n+  PRInt64 minus_one;\n \n-    LL_I2L(minus_one, -1);\n-    cur = _PR_MD_LSEEK64(fd, LL_ZERO, PR_SEEK_CUR);\n+  LL_I2L(minus_one, -1);\n+  cur = _PR_MD_LSEEK64(fd, LL_ZERO, PR_SEEK_CUR);\n \n-    if (LL_GE_ZERO(cur)) {\n-        end = _PR_MD_LSEEK64(fd, LL_ZERO, PR_SEEK_END);\n-    }\n+  if (LL_GE_ZERO(cur)) {\n+    end = _PR_MD_LSEEK64(fd, LL_ZERO, PR_SEEK_END);\n+  }\n \n-    if (!LL_GE_ZERO(cur) || !LL_GE_ZERO(end)) {\n-        return minus_one;\n-    }\n+  if (!LL_GE_ZERO(cur) || !LL_GE_ZERO(end)) {\n+    return minus_one;\n+  }\n \n-    LL_SUB(result, end, cur);\n-    (void)_PR_MD_LSEEK64(fd, cur, PR_SEEK_SET);\n+  LL_SUB(result, end, cur);\n+  (void)_PR_MD_LSEEK64(fd, cur, PR_SEEK_SET);\n \n-    return result;\n+  return result;\n } /* pt_Available64_f */\n \n-static PRInt32\n-pt_Available_s(PRFileDesc* fd)\n-{\n-    PRInt32 rv, bytes = -1;\n-    if (pt_TestAbort()) {\n-        return bytes;\n-    }\n+static PRInt32 pt_Available_s(PRFileDesc* fd) {\n+  PRInt32 rv, bytes = -1;\n+  if (pt_TestAbort()) {\n+    return bytes;\n+  }\n \n-    rv = ioctl(fd->secret->md.osfd, FIONREAD, &bytes);\n+  rv = ioctl(fd->secret->md.osfd, FIONREAD, &bytes);\n \n-    if (rv == -1) {\n-        pt_MapError(_PR_MD_MAP_SOCKETAVAILABLE_ERROR, errno);\n-    }\n-    return bytes;\n+  if (rv == -1) {\n+    pt_MapError(_PR_MD_MAP_SOCKETAVAILABLE_ERROR, errno);\n+  }\n+  return bytes;\n } /* pt_Available_s */\n \n-static PRInt64\n-pt_Available64_s(PRFileDesc* fd)\n-{\n-    PRInt64 rv;\n-    LL_I2L(rv, pt_Available_s(fd));\n-    return rv;\n+static PRInt64 pt_Available64_s(PRFileDesc* fd) {\n+  PRInt64 rv;\n+  LL_I2L(rv, pt_Available_s(fd));\n+  return rv;\n } /* pt_Available64_s */\n \n-static PRStatus\n-pt_FileInfo(PRFileDesc* fd, PRFileInfo* info)\n-{\n-    PRInt32 rv = _PR_MD_GETOPENFILEINFO(fd, info);\n-    return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;\n+static PRStatus pt_FileInfo(PRFileDesc* fd, PRFileInfo* info) {\n+  PRInt32 rv = _PR_MD_GETOPENFILEINFO(fd, info);\n+  return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;\n } /* pt_FileInfo */\n \n-static PRStatus\n-pt_FileInfo64(PRFileDesc* fd, PRFileInfo64* info)\n-{\n-    PRInt32 rv = _PR_MD_GETOPENFILEINFO64(fd, info);\n-    return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;\n+static PRStatus pt_FileInfo64(PRFileDesc* fd, PRFileInfo64* info) {\n+  PRInt32 rv = _PR_MD_GETOPENFILEINFO64(fd, info);\n+  return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;\n } /* pt_FileInfo64 */\n \n-static PRStatus\n-pt_Synch(PRFileDesc* fd)\n-{\n-    return (NULL == fd) ? PR_FAILURE : PR_SUCCESS;\n+static PRStatus pt_Synch(PRFileDesc* fd) {\n+  return (NULL == fd) ? PR_FAILURE : PR_SUCCESS;\n } /* pt_Synch */\n \n-static PRStatus\n-pt_Fsync(PRFileDesc* fd)\n-{\n-    PRIntn rv = -1;\n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+static PRStatus pt_Fsync(PRFileDesc* fd) {\n+  PRIntn rv = -1;\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n \n-    rv = fsync(fd->secret->md.osfd);\n-    if (rv < 0) {\n-        pt_MapError(_PR_MD_MAP_FSYNC_ERROR, errno);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  rv = fsync(fd->secret->md.osfd);\n+  if (rv < 0) {\n+    pt_MapError(_PR_MD_MAP_FSYNC_ERROR, errno);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n } /* pt_Fsync */\n \n-static PRStatus\n-pt_Connect(PRFileDesc* fd, const PRNetAddr* addr,\n-           PRIntervalTime timeout)\n-{\n-    PRIntn rv = -1, syserrno;\n-    pt_SockLen addr_len;\n-    const PRNetAddr* addrp = addr;\n-#if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)\n-    PRNetAddr addrCopy;\n-#endif\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    PRUint16 md_af = addr->raw.family;\n-#endif\n-\n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n-\n-    PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n-    addr_len = PR_NETADDR_SIZE(addr);\n-#ifdef _PR_INET6\n-    if (addr->raw.family == PR_AF_INET6) {\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-        md_af = AF_INET6;\n-#else\n-        addrCopy = *addr;\n-        addrCopy.raw.family = AF_INET6;\n-        addrp = &addrCopy;\n-#endif\n-    }\n-#endif\n-\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n+static PRStatus pt_Connect(PRFileDesc* fd, const PRNetAddr* addr,\n+                           PRIntervalTime timeout) {\n+  PRIntn rv = -1, syserrno;\n+  pt_SockLen addr_len;\n+  const PRNetAddr* addrp = addr;\n+#  if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)\n+  PRNetAddr addrCopy;\n+#  endif\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  PRUint16 md_af = addr->raw.family;\n+#  endif\n+\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n+\n+  PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n+  addr_len = PR_NETADDR_SIZE(addr);\n+#  ifdef _PR_INET6\n+  if (addr->raw.family == PR_AF_INET6) {\n+#    ifdef _PR_HAVE_SOCKADDR_LEN\n+    md_af = AF_INET6;\n+#    else\n     addrCopy = *addr;\n-    ((struct sockaddr*)&addrCopy)->sa_len = addr_len;\n-    ((struct sockaddr*)&addrCopy)->sa_family = md_af;\n+    addrCopy.raw.family = AF_INET6;\n     addrp = &addrCopy;\n-#endif\n-    rv = connect(fd->secret->md.osfd, (struct sockaddr*)addrp, addr_len);\n-    syserrno = errno;\n-    if ((-1 == rv) && (EINPROGRESS == syserrno) && (!fd->secret->nonblocking)) {\n-        if (PR_INTERVAL_NO_WAIT == timeout) {\n-            syserrno = ETIMEDOUT;\n-        } else {\n-            pt_Continuation op;\n-            op.arg1.osfd = fd->secret->md.osfd;\n-            op.arg2.buffer = (void*)addrp;\n-            op.arg3.amount = addr_len;\n-            op.timeout = timeout;\n-            op.function = pt_connect_cont;\n-            op.event = POLLOUT | POLLPRI;\n-            rv = pt_Continue(&op);\n-            syserrno = op.syserrno;\n-        }\n-    }\n-    if (-1 == rv) {\n-        pt_MapError(_PR_MD_MAP_CONNECT_ERROR, syserrno);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+#    endif\n+  }\n+#  endif\n+\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  addrCopy = *addr;\n+  ((struct sockaddr*)&addrCopy)->sa_len = addr_len;\n+  ((struct sockaddr*)&addrCopy)->sa_family = md_af;\n+  addrp = &addrCopy;\n+#  endif\n+  rv = connect(fd->secret->md.osfd, (struct sockaddr*)addrp, addr_len);\n+  syserrno = errno;\n+  if ((-1 == rv) && (EINPROGRESS == syserrno) && (!fd->secret->nonblocking)) {\n+    if (PR_INTERVAL_NO_WAIT == timeout) {\n+      syserrno = ETIMEDOUT;\n+    } else {\n+      pt_Continuation op;\n+      op.arg1.osfd = fd->secret->md.osfd;\n+      op.arg2.buffer = (void*)addrp;\n+      op.arg3.amount = addr_len;\n+      op.timeout = timeout;\n+      op.function = pt_connect_cont;\n+      op.event = POLLOUT | POLLPRI;\n+      rv = pt_Continue(&op);\n+      syserrno = op.syserrno;\n+    }\n+  }\n+  if (-1 == rv) {\n+    pt_MapError(_PR_MD_MAP_CONNECT_ERROR, syserrno);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n } /* pt_Connect */\n \n-static PRStatus\n-pt_ConnectContinue(PRFileDesc* fd, PRInt16 out_flags)\n-{\n-    int err;\n-    PRInt32 osfd;\n+static PRStatus pt_ConnectContinue(PRFileDesc* fd, PRInt16 out_flags) {\n+  int err;\n+  PRInt32 osfd;\n \n-    if (out_flags & PR_POLL_NVAL) {\n-        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    if ((out_flags &\n-         (PR_POLL_WRITE | PR_POLL_EXCEPT | PR_POLL_ERR | PR_POLL_HUP)) == 0) {\n-        PR_ASSERT(out_flags == 0);\n-        PR_SetError(PR_IN_PROGRESS_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (out_flags & PR_POLL_NVAL) {\n+    PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  if ((out_flags &\n+       (PR_POLL_WRITE | PR_POLL_EXCEPT | PR_POLL_ERR | PR_POLL_HUP)) == 0) {\n+    PR_ASSERT(out_flags == 0);\n+    PR_SetError(PR_IN_PROGRESS_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-    osfd = fd->secret->md.osfd;\n+  osfd = fd->secret->md.osfd;\n \n-    err = _MD_unix_get_nonblocking_connect_error(osfd);\n-    if (err != 0) {\n-        _PR_MD_MAP_CONNECT_ERROR(err);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  err = _MD_unix_get_nonblocking_connect_error(osfd);\n+  if (err != 0) {\n+    _PR_MD_MAP_CONNECT_ERROR(err);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n } /* pt_ConnectContinue */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_GetConnectStatus(const PRPollDesc* pd)\n-{\n-    /* Find the NSPR layer and invoke its connectcontinue method */\n-    PRFileDesc* bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n-\n-    if (NULL == bottom) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    return pt_ConnectContinue(bottom, pd->out_flags);\n-} /* PR_GetConnectStatus */\n+PR_IMPLEMENT(PRStatus) PR_GetConnectStatus(const PRPollDesc* pd) {\n+  /* Find the NSPR layer and invoke its connectcontinue method */\n+  PRFileDesc* bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);\n \n-static PRFileDesc*\n-pt_Accept(PRFileDesc* fd, PRNetAddr* addr,\n-          PRIntervalTime timeout)\n-{\n-    PRFileDesc* newfd = NULL;\n-    PRIntn syserrno, osfd = -1;\n-    pt_SockLen addr_len = sizeof(PRNetAddr);\n+  if (NULL == bottom) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  return pt_ConnectContinue(bottom, pd->out_flags);\n+} /* PR_GetConnectStatus */\n \n-    if (pt_TestAbort()) {\n-        return newfd;\n-    }\n+static PRFileDesc* pt_Accept(PRFileDesc* fd, PRNetAddr* addr,\n+                             PRIntervalTime timeout) {\n+  PRFileDesc* newfd = NULL;\n+  PRIntn syserrno, osfd = -1;\n+  pt_SockLen addr_len = sizeof(PRNetAddr);\n \n-#ifdef _PR_STRICT_ADDR_LEN\n-    if (addr) {\n-        /*\n-         * Set addr->raw.family just so that we can use the\n-         * PR_NETADDR_SIZE macro.\n-         */\n-        addr->raw.family = fd->secret->af;\n-        addr_len = PR_NETADDR_SIZE(addr);\n-    }\n-#endif\n+  if (pt_TestAbort()) {\n+    return newfd;\n+  }\n \n-    osfd = accept(fd->secret->md.osfd, (struct sockaddr*)addr, &addr_len);\n-    syserrno = errno;\n+#  ifdef _PR_STRICT_ADDR_LEN\n+  if (addr) {\n+    /*\n+     * Set addr->raw.family just so that we can use the\n+     * PR_NETADDR_SIZE macro.\n+     */\n+    addr->raw.family = fd->secret->af;\n+    addr_len = PR_NETADDR_SIZE(addr);\n+  }\n+#  endif\n \n-    if (osfd == -1) {\n-        if (fd->secret->nonblocking) {\n-            goto failed;\n-        }\n+  osfd = accept(fd->secret->md.osfd, (struct sockaddr*)addr, &addr_len);\n+  syserrno = errno;\n \n-        if (EWOULDBLOCK != syserrno && EAGAIN != syserrno &&\n-            ECONNABORTED != syserrno) {\n-            goto failed;\n-        } else {\n-            if (PR_INTERVAL_NO_WAIT == timeout) {\n-                syserrno = ETIMEDOUT;\n-            } else {\n-                pt_Continuation op;\n-                op.arg1.osfd = fd->secret->md.osfd;\n-                op.arg2.buffer = addr;\n-                op.arg3.addr_len = &addr_len;\n-                op.timeout = timeout;\n-                op.function = pt_accept_cont;\n-                op.event = POLLIN | POLLPRI;\n-                osfd = pt_Continue(&op);\n-                syserrno = op.syserrno;\n-            }\n-            if (osfd < 0) {\n-                goto failed;\n-            }\n-        }\n-    }\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    /* ignore the sa_len field of struct sockaddr */\n-    if (addr) {\n-        addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n-    }\n-#endif /* _PR_HAVE_SOCKADDR_LEN */\n-#ifdef _PR_INET6\n-    if (addr && (AF_INET6 == addr->raw.family)) {\n-        addr->raw.family = PR_AF_INET6;\n+  if (osfd == -1) {\n+    if (fd->secret->nonblocking) {\n+      goto failed;\n     }\n-#endif\n-    newfd = pt_SetMethods(osfd, PR_DESC_SOCKET_TCP, PR_TRUE, PR_FALSE);\n-    if (newfd == NULL) {\n-        close(osfd); /* $$$ whoops! this doesn't work $$$ */\n+\n+    if (EWOULDBLOCK != syserrno && EAGAIN != syserrno &&\n+        ECONNABORTED != syserrno) {\n+      goto failed;\n     } else {\n-        PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n-        PR_ASSERT(IsValidNetAddrLen(addr, addr_len) == PR_TRUE);\n-#ifdef LINUX\n-        /*\n-         * On Linux, experiments showed that the accepted sockets\n-         * inherit the TCP_NODELAY socket option of the listening\n-         * socket.\n-         */\n-        newfd->secret->md.tcp_nodelay = fd->secret->md.tcp_nodelay;\n-#endif\n-    }\n-    return newfd;\n+      if (PR_INTERVAL_NO_WAIT == timeout) {\n+        syserrno = ETIMEDOUT;\n+      } else {\n+        pt_Continuation op;\n+        op.arg1.osfd = fd->secret->md.osfd;\n+        op.arg2.buffer = addr;\n+        op.arg3.addr_len = &addr_len;\n+        op.timeout = timeout;\n+        op.function = pt_accept_cont;\n+        op.event = POLLIN | POLLPRI;\n+        osfd = pt_Continue(&op);\n+        syserrno = op.syserrno;\n+      }\n+      if (osfd < 0) {\n+        goto failed;\n+      }\n+    }\n+  }\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  /* ignore the sa_len field of struct sockaddr */\n+  if (addr) {\n+    addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n+  }\n+#  endif /* _PR_HAVE_SOCKADDR_LEN */\n+#  ifdef _PR_INET6\n+  if (addr && (AF_INET6 == addr->raw.family)) {\n+    addr->raw.family = PR_AF_INET6;\n+  }\n+#  endif\n+  newfd = pt_SetMethods(osfd, PR_DESC_SOCKET_TCP, PR_TRUE, PR_FALSE);\n+  if (newfd == NULL) {\n+    close(osfd); /* $$$ whoops! this doesn't work $$$ */\n+  } else {\n+    PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n+    PR_ASSERT(IsValidNetAddrLen(addr, addr_len) == PR_TRUE);\n+#  ifdef LINUX\n+    /*\n+     * On Linux, experiments showed that the accepted sockets\n+     * inherit the TCP_NODELAY socket option of the listening\n+     * socket.\n+     */\n+    newfd->secret->md.tcp_nodelay = fd->secret->md.tcp_nodelay;\n+#  endif\n+  }\n+  return newfd;\n \n failed:\n-    pt_MapError(_PR_MD_MAP_ACCEPT_ERROR, syserrno);\n-    return NULL;\n+  pt_MapError(_PR_MD_MAP_ACCEPT_ERROR, syserrno);\n+  return NULL;\n } /* pt_Accept */\n \n-static PRStatus\n-pt_Bind(PRFileDesc* fd, const PRNetAddr* addr)\n-{\n-    PRIntn rv;\n-    pt_SockLen addr_len;\n-    const PRNetAddr* addrp = addr;\n-#if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)\n-    PRNetAddr addrCopy;\n-#endif\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    PRUint16 md_af = addr->raw.family;\n-#endif\n-\n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n-\n-    PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n-    if (addr->raw.family == AF_UNIX) {\n-        /* Disallow relative pathnames */\n-        if (addr->local.path[0] != '/'\n-#if defined(LINUX)\n-            /* Linux has abstract socket address support */\n-            && addr->local.path[0] != 0\n-#endif\n-        ) {\n-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-            return PR_FAILURE;\n-        }\n-    }\n-\n-#ifdef _PR_INET6\n-    if (addr->raw.family == PR_AF_INET6) {\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-        md_af = AF_INET6;\n-#else\n-        addrCopy = *addr;\n-        addrCopy.raw.family = AF_INET6;\n-        addrp = &addrCopy;\n-#endif\n-    }\n-#endif\n-\n-    addr_len = PR_NETADDR_SIZE(addr);\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n+static PRStatus pt_Bind(PRFileDesc* fd, const PRNetAddr* addr) {\n+  PRIntn rv;\n+  pt_SockLen addr_len;\n+  const PRNetAddr* addrp = addr;\n+#  if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)\n+  PRNetAddr addrCopy;\n+#  endif\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  PRUint16 md_af = addr->raw.family;\n+#  endif\n+\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n+\n+  PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n+  if (addr->raw.family == AF_UNIX) {\n+    /* Disallow relative pathnames */\n+    if (addr->local.path[0] != '/'\n+#  if defined(LINUX)\n+        /* Linux has abstract socket address support */\n+        && addr->local.path[0] != 0\n+#  endif\n+    ) {\n+      PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+      return PR_FAILURE;\n+    }\n+  }\n+\n+#  ifdef _PR_INET6\n+  if (addr->raw.family == PR_AF_INET6) {\n+#    ifdef _PR_HAVE_SOCKADDR_LEN\n+    md_af = AF_INET6;\n+#    else\n     addrCopy = *addr;\n-    ((struct sockaddr*)&addrCopy)->sa_len = addr_len;\n-    ((struct sockaddr*)&addrCopy)->sa_family = md_af;\n+    addrCopy.raw.family = AF_INET6;\n     addrp = &addrCopy;\n-#endif\n-    rv = bind(fd->secret->md.osfd, (struct sockaddr*)addrp, addr_len);\n-\n-    if (rv == -1) {\n-        pt_MapError(_PR_MD_MAP_BIND_ERROR, errno);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+#    endif\n+  }\n+#  endif\n+\n+  addr_len = PR_NETADDR_SIZE(addr);\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  addrCopy = *addr;\n+  ((struct sockaddr*)&addrCopy)->sa_len = addr_len;\n+  ((struct sockaddr*)&addrCopy)->sa_family = md_af;\n+  addrp = &addrCopy;\n+#  endif\n+  rv = bind(fd->secret->md.osfd, (struct sockaddr*)addrp, addr_len);\n+\n+  if (rv == -1) {\n+    pt_MapError(_PR_MD_MAP_BIND_ERROR, errno);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n } /* pt_Bind */\n \n-static PRStatus\n-pt_Listen(PRFileDesc* fd, PRIntn backlog)\n-{\n-    PRIntn rv;\n+static PRStatus pt_Listen(PRFileDesc* fd, PRIntn backlog) {\n+  PRIntn rv;\n \n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n \n-    rv = listen(fd->secret->md.osfd, backlog);\n-    if (rv == -1) {\n-        pt_MapError(_PR_MD_MAP_LISTEN_ERROR, errno);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  rv = listen(fd->secret->md.osfd, backlog);\n+  if (rv == -1) {\n+    pt_MapError(_PR_MD_MAP_LISTEN_ERROR, errno);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n } /* pt_Listen */\n \n-static PRStatus\n-pt_Shutdown(PRFileDesc* fd, PRIntn how)\n-{\n-    PRIntn rv = -1;\n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+static PRStatus pt_Shutdown(PRFileDesc* fd, PRIntn how) {\n+  PRIntn rv = -1;\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n \n-    rv = shutdown(fd->secret->md.osfd, how);\n+  rv = shutdown(fd->secret->md.osfd, how);\n \n-    if (rv == -1) {\n-        pt_MapError(_PR_MD_MAP_SHUTDOWN_ERROR, errno);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  if (rv == -1) {\n+    pt_MapError(_PR_MD_MAP_SHUTDOWN_ERROR, errno);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n } /* pt_Shutdown */\n \n-static PRInt16\n-pt_Poll(PRFileDesc* fd, PRInt16 in_flags, PRInt16* out_flags)\n-{\n-    *out_flags = 0;\n-    return in_flags;\n+static PRInt16 pt_Poll(PRFileDesc* fd, PRInt16 in_flags, PRInt16* out_flags) {\n+  *out_flags = 0;\n+  return in_flags;\n } /* pt_Poll */\n \n-static PRInt32\n-pt_Recv(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n-        PRIntervalTime timeout)\n-{\n-    PRInt32 syserrno, bytes = -1;\n-    PRIntn osflags;\n-\n-    if (0 == flags) {\n-        osflags = 0;\n-    } else if (PR_MSG_PEEK == flags) {\n-        osflags = MSG_PEEK;\n-    } else {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return bytes;\n-    }\n+static PRInt32 pt_Recv(PRFileDesc* fd, void* buf, PRInt32 amount, PRIntn flags,\n+                       PRIntervalTime timeout) {\n+  PRInt32 syserrno, bytes = -1;\n+  PRIntn osflags;\n+\n+  if (0 == flags) {\n+    osflags = 0;\n+  } else if (PR_MSG_PEEK == flags) {\n+    osflags = MSG_PEEK;\n+  } else {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return bytes;\n+  }\n \n-    if (pt_TestAbort()) {\n-        return bytes;\n-    }\n+  if (pt_TestAbort()) {\n+    return bytes;\n+  }\n \n-    /* recv() is a much slower call on pre-2.6 Solaris than read(). */\n-#if defined(SOLARIS)\n-    if (0 == osflags) {\n-        bytes = read(fd->secret->md.osfd, buf, amount);\n-    } else {\n-        bytes = recv(fd->secret->md.osfd, buf, amount, osflags);\n-    }\n-#else\n+  /* recv() is a much slower call on pre-2.6 Solaris than read(). */\n+#  if defined(SOLARIS)\n+  if (0 == osflags) {\n+    bytes = read(fd->secret->md.osfd, buf, amount);\n+  } else {\n     bytes = recv(fd->secret->md.osfd, buf, amount, osflags);\n-#endif\n-    syserrno = errno;\n-\n-    if ((bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n-        (!fd->secret->nonblocking)) {\n-        if (PR_INTERVAL_NO_WAIT == timeout) {\n-            syserrno = ETIMEDOUT;\n-        } else {\n-            pt_Continuation op;\n-            op.arg1.osfd = fd->secret->md.osfd;\n-            op.arg2.buffer = buf;\n-            op.arg3.amount = amount;\n-            op.arg4.flags = osflags;\n-            op.timeout = timeout;\n-            op.function = pt_recv_cont;\n-            op.event = POLLIN | POLLPRI;\n-            bytes = pt_Continue(&op);\n-            syserrno = op.syserrno;\n-        }\n-    }\n-    if (bytes < 0) {\n-        pt_MapError(_PR_MD_MAP_RECV_ERROR, syserrno);\n-    }\n-    return bytes;\n+  }\n+#  else\n+  bytes = recv(fd->secret->md.osfd, buf, amount, osflags);\n+#  endif\n+  syserrno = errno;\n+\n+  if ((bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n+      (!fd->secret->nonblocking)) {\n+    if (PR_INTERVAL_NO_WAIT == timeout) {\n+      syserrno = ETIMEDOUT;\n+    } else {\n+      pt_Continuation op;\n+      op.arg1.osfd = fd->secret->md.osfd;\n+      op.arg2.buffer = buf;\n+      op.arg3.amount = amount;\n+      op.arg4.flags = osflags;\n+      op.timeout = timeout;\n+      op.function = pt_recv_cont;\n+      op.event = POLLIN | POLLPRI;\n+      bytes = pt_Continue(&op);\n+      syserrno = op.syserrno;\n+    }\n+  }\n+  if (bytes < 0) {\n+    pt_MapError(_PR_MD_MAP_RECV_ERROR, syserrno);\n+  }\n+  return bytes;\n } /* pt_Recv */\n \n-static PRInt32\n-pt_SocketRead(PRFileDesc* fd, void* buf, PRInt32 amount)\n-{\n-    return pt_Recv(fd, buf, amount, 0, PR_INTERVAL_NO_TIMEOUT);\n+static PRInt32 pt_SocketRead(PRFileDesc* fd, void* buf, PRInt32 amount) {\n+  return pt_Recv(fd, buf, amount, 0, PR_INTERVAL_NO_TIMEOUT);\n } /* pt_SocketRead */\n \n-static PRInt32\n-pt_Send(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-        PRIntn flags, PRIntervalTime timeout)\n-{\n-    PRInt32 syserrno, bytes = -1;\n-    PRBool fNeedContinue = PR_FALSE;\n-#if defined(SOLARIS)\n-    PRInt32 tmp_amount = amount;\n-#endif\n-\n-    if (pt_TestAbort()) {\n-        return bytes;\n-    }\n-\n-    /*\n-     * On pre-2.6 Solaris, send() is much slower than write().\n-     * On 2.6 and beyond, with in-kernel sockets, send() and\n-     * write() are fairly equivalent in performance.\n-     */\n-#if defined(SOLARIS)\n-    PR_ASSERT(0 == flags);\n-retry:\n-    bytes = write(fd->secret->md.osfd, buf, tmp_amount);\n-#else\n-    bytes = send(fd->secret->md.osfd, buf, amount, flags);\n-#endif\n-    syserrno = errno;\n-\n-#if defined(SOLARIS)\n-    /*\n-     * The write system call has been reported to return the ERANGE error\n-     * on occasion. Try to write in smaller chunks to workaround this bug.\n-     */\n-    if ((bytes == -1) && (syserrno == ERANGE)) {\n-        if (tmp_amount > 1) {\n-            tmp_amount = tmp_amount / 2; /* half the bytes */\n-            goto retry;\n-        }\n-    }\n-#endif\n+static PRInt32 pt_Send(PRFileDesc* fd, const void* buf, PRInt32 amount,\n+                       PRIntn flags, PRIntervalTime timeout) {\n+  PRInt32 syserrno, bytes = -1;\n+  PRBool fNeedContinue = PR_FALSE;\n+#  if defined(SOLARIS)\n+  PRInt32 tmp_amount = amount;\n+#  endif\n \n-    if ((bytes >= 0) && (bytes < amount) && (!fd->secret->nonblocking)) {\n-        if (PR_INTERVAL_NO_WAIT == timeout) {\n-            bytes = -1;\n-            syserrno = ETIMEDOUT;\n-        } else {\n-            buf = (char*)buf + bytes;\n-            amount -= bytes;\n-            fNeedContinue = PR_TRUE;\n-        }\n-    }\n-    if ((bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n-        (!fd->secret->nonblocking)) {\n-        if (PR_INTERVAL_NO_WAIT == timeout) {\n-            syserrno = ETIMEDOUT;\n-        } else {\n-            bytes = 0;\n-            fNeedContinue = PR_TRUE;\n-        }\n-    }\n-\n-    if (fNeedContinue == PR_TRUE) {\n-        pt_Continuation op;\n-        op.arg1.osfd = fd->secret->md.osfd;\n-        op.arg2.buffer = (void*)buf;\n-        op.arg3.amount = amount;\n-        op.arg4.flags = flags;\n-        op.timeout = timeout;\n-        op.result.code = bytes; /* initialize the number sent */\n-        op.function = pt_send_cont;\n-        op.event = POLLOUT | POLLPRI;\n-        bytes = pt_Continue(&op);\n-        syserrno = op.syserrno;\n-    }\n-    if (bytes == -1) {\n-        pt_MapError(_PR_MD_MAP_SEND_ERROR, syserrno);\n-    }\n+  if (pt_TestAbort()) {\n     return bytes;\n+  }\n+\n+  /*\n+   * On pre-2.6 Solaris, send() is much slower than write().\n+   * On 2.6 and beyond, with in-kernel sockets, send() and\n+   * write() are fairly equivalent in performance.\n+   */\n+#  if defined(SOLARIS)\n+  PR_ASSERT(0 == flags);\n+retry:\n+  bytes = write(fd->secret->md.osfd, buf, tmp_amount);\n+#  else\n+  bytes = send(fd->secret->md.osfd, buf, amount, flags);\n+#  endif\n+  syserrno = errno;\n+\n+#  if defined(SOLARIS)\n+  /*\n+   * The write system call has been reported to return the ERANGE error\n+   * on occasion. Try to write in smaller chunks to workaround this bug.\n+   */\n+  if ((bytes == -1) && (syserrno == ERANGE)) {\n+    if (tmp_amount > 1) {\n+      tmp_amount = tmp_amount / 2; /* half the bytes */\n+      goto retry;\n+    }\n+  }\n+#  endif\n+\n+  if ((bytes >= 0) && (bytes < amount) && (!fd->secret->nonblocking)) {\n+    if (PR_INTERVAL_NO_WAIT == timeout) {\n+      bytes = -1;\n+      syserrno = ETIMEDOUT;\n+    } else {\n+      buf = (char*)buf + bytes;\n+      amount -= bytes;\n+      fNeedContinue = PR_TRUE;\n+    }\n+  }\n+  if ((bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n+      (!fd->secret->nonblocking)) {\n+    if (PR_INTERVAL_NO_WAIT == timeout) {\n+      syserrno = ETIMEDOUT;\n+    } else {\n+      bytes = 0;\n+      fNeedContinue = PR_TRUE;\n+    }\n+  }\n+\n+  if (fNeedContinue == PR_TRUE) {\n+    pt_Continuation op;\n+    op.arg1.osfd = fd->secret->md.osfd;\n+    op.arg2.buffer = (void*)buf;\n+    op.arg3.amount = amount;\n+    op.arg4.flags = flags;\n+    op.timeout = timeout;\n+    op.result.code = bytes; /* initialize the number sent */\n+    op.function = pt_send_cont;\n+    op.event = POLLOUT | POLLPRI;\n+    bytes = pt_Continue(&op);\n+    syserrno = op.syserrno;\n+  }\n+  if (bytes == -1) {\n+    pt_MapError(_PR_MD_MAP_SEND_ERROR, syserrno);\n+  }\n+  return bytes;\n } /* pt_Send */\n \n-static PRInt32\n-pt_SocketWrite(PRFileDesc* fd, const void* buf, PRInt32 amount)\n-{\n-    return pt_Send(fd, buf, amount, 0, PR_INTERVAL_NO_TIMEOUT);\n+static PRInt32 pt_SocketWrite(PRFileDesc* fd, const void* buf, PRInt32 amount) {\n+  return pt_Send(fd, buf, amount, 0, PR_INTERVAL_NO_TIMEOUT);\n } /* pt_SocketWrite */\n \n-static PRInt32\n-pt_SendTo(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-          PRIntn flags, const PRNetAddr* addr,\n-          PRIntervalTime timeout)\n-{\n-    PRInt32 syserrno, bytes = -1;\n-    PRBool fNeedContinue = PR_FALSE;\n-    pt_SockLen addr_len;\n-    const PRNetAddr* addrp = addr;\n-#if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)\n-    PRNetAddr addrCopy;\n-#endif\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    PRUint16 md_af = addr->raw.family;\n-#endif\n-\n-    if (pt_TestAbort()) {\n-        return bytes;\n-    }\n-\n-    PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n-#ifdef _PR_INET6\n-    if (addr->raw.family == PR_AF_INET6) {\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-        md_af = AF_INET6;\n-#else\n-        addrCopy = *addr;\n-        addrCopy.raw.family = AF_INET6;\n-        addrp = &addrCopy;\n-#endif\n-    }\n-#endif\n-\n-    addr_len = PR_NETADDR_SIZE(addr);\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n+static PRInt32 pt_SendTo(PRFileDesc* fd, const void* buf, PRInt32 amount,\n+                         PRIntn flags, const PRNetAddr* addr,\n+                         PRIntervalTime timeout) {\n+  PRInt32 syserrno, bytes = -1;\n+  PRBool fNeedContinue = PR_FALSE;\n+  pt_SockLen addr_len;\n+  const PRNetAddr* addrp = addr;\n+#  if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)\n+  PRNetAddr addrCopy;\n+#  endif\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  PRUint16 md_af = addr->raw.family;\n+#  endif\n+\n+  if (pt_TestAbort()) {\n+    return bytes;\n+  }\n+\n+  PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n+#  ifdef _PR_INET6\n+  if (addr->raw.family == PR_AF_INET6) {\n+#    ifdef _PR_HAVE_SOCKADDR_LEN\n+    md_af = AF_INET6;\n+#    else\n     addrCopy = *addr;\n-    ((struct sockaddr*)&addrCopy)->sa_len = addr_len;\n-    ((struct sockaddr*)&addrCopy)->sa_family = md_af;\n+    addrCopy.raw.family = AF_INET6;\n     addrp = &addrCopy;\n-#endif\n-    bytes = sendto(fd->secret->md.osfd, buf, amount, flags,\n-                   (struct sockaddr*)addrp, addr_len);\n-    syserrno = errno;\n-    if ((bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n-        (!fd->secret->nonblocking)) {\n-        if (PR_INTERVAL_NO_WAIT == timeout) {\n-            syserrno = ETIMEDOUT;\n-        } else {\n-            fNeedContinue = PR_TRUE;\n-        }\n-    }\n-    if (fNeedContinue == PR_TRUE) {\n-        pt_Continuation op;\n-        op.arg1.osfd = fd->secret->md.osfd;\n-        op.arg2.buffer = (void*)buf;\n-        op.arg3.amount = amount;\n-        op.arg4.flags = flags;\n-        op.arg5.addr = (PRNetAddr*)addrp;\n-        op.timeout = timeout;\n-        op.result.code = 0; /* initialize the number sent */\n-        op.function = pt_sendto_cont;\n-        op.event = POLLOUT | POLLPRI;\n-        bytes = pt_Continue(&op);\n-        syserrno = op.syserrno;\n-    }\n-    if (bytes < 0) {\n-        pt_MapError(_PR_MD_MAP_SENDTO_ERROR, syserrno);\n-    }\n-    return bytes;\n+#    endif\n+  }\n+#  endif\n+\n+  addr_len = PR_NETADDR_SIZE(addr);\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  addrCopy = *addr;\n+  ((struct sockaddr*)&addrCopy)->sa_len = addr_len;\n+  ((struct sockaddr*)&addrCopy)->sa_family = md_af;\n+  addrp = &addrCopy;\n+#  endif\n+  bytes = sendto(fd->secret->md.osfd, buf, amount, flags,\n+                 (struct sockaddr*)addrp, addr_len);\n+  syserrno = errno;\n+  if ((bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n+      (!fd->secret->nonblocking)) {\n+    if (PR_INTERVAL_NO_WAIT == timeout) {\n+      syserrno = ETIMEDOUT;\n+    } else {\n+      fNeedContinue = PR_TRUE;\n+    }\n+  }\n+  if (fNeedContinue == PR_TRUE) {\n+    pt_Continuation op;\n+    op.arg1.osfd = fd->secret->md.osfd;\n+    op.arg2.buffer = (void*)buf;\n+    op.arg3.amount = amount;\n+    op.arg4.flags = flags;\n+    op.arg5.addr = (PRNetAddr*)addrp;\n+    op.timeout = timeout;\n+    op.result.code = 0; /* initialize the number sent */\n+    op.function = pt_sendto_cont;\n+    op.event = POLLOUT | POLLPRI;\n+    bytes = pt_Continue(&op);\n+    syserrno = op.syserrno;\n+  }\n+  if (bytes < 0) {\n+    pt_MapError(_PR_MD_MAP_SENDTO_ERROR, syserrno);\n+  }\n+  return bytes;\n } /* pt_SendTo */\n \n-#if defined(LINUX) || defined(DARWIN)\n+#  if defined(LINUX) || defined(DARWIN)\n /* Linux uses SendTo to send data during TCP Fast Open. OSX uses connectx, but\n  * we will make it imitate the Linux's interface. */\n-static PRInt32\n-pt_TCP_SendTo(PRFileDesc* fd, const void* buf, PRInt32 amount,\n-              PRIntn flags, const PRNetAddr* addr,\n-              PRIntervalTime timeout)\n-{\n-#if defined(LINUX) || HAS_CONNECTX\n-    PRInt32 syserrno;\n-    PRBool fNeedContinue = PR_FALSE;\n-    pt_SockLen addr_len;\n-    const PRNetAddr* addrp = addr;\n-#if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)\n-    PRNetAddr addrCopy;\n-#endif\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    PRUint16 md_af = addr->raw.family;\n-#endif\n-\n-    if (pt_TestAbort()) {\n-        return -1;\n-    }\n-\n-    PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n-    addr_len = PR_NETADDR_SIZE(addr);\n-#if defined(_PR_INET6)\n-    if (addr->raw.family == PR_AF_INET6) {\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-        md_af = AF_INET6;\n-#else\n-        /* If _PR_INET6 is defined and it is PR_AF_INET6 we set family\n-         * to AF_INET6. */\n-        addrCopy = *addr;\n-        addrCopy.raw.family = AF_INET6;\n-        addrp = &addrCopy;\n-#endif\n-    }\n-#endif\n-\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    /* if _PR_HAVE_SOCKADDR_LEN is defined and it is PR_AF_INET6 we set family\n-     * to AF_INET6 and we set address length. */\n+static PRInt32 pt_TCP_SendTo(PRFileDesc* fd, const void* buf, PRInt32 amount,\n+                             PRIntn flags, const PRNetAddr* addr,\n+                             PRIntervalTime timeout) {\n+#    if defined(LINUX) || HAS_CONNECTX\n+  PRInt32 syserrno;\n+  PRBool fNeedContinue = PR_FALSE;\n+  pt_SockLen addr_len;\n+  const PRNetAddr* addrp = addr;\n+#      if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)\n+  PRNetAddr addrCopy;\n+#      endif\n+#      ifdef _PR_HAVE_SOCKADDR_LEN\n+  PRUint16 md_af = addr->raw.family;\n+#      endif\n+\n+  if (pt_TestAbort()) {\n+    return -1;\n+  }\n+\n+  PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n+  addr_len = PR_NETADDR_SIZE(addr);\n+#      if defined(_PR_INET6)\n+  if (addr->raw.family == PR_AF_INET6) {\n+#        ifdef _PR_HAVE_SOCKADDR_LEN\n+    md_af = AF_INET6;\n+#        else\n+    /* If _PR_INET6 is defined and it is PR_AF_INET6 we set family\n+     * to AF_INET6. */\n     addrCopy = *addr;\n-    ((struct sockaddr*)&addrCopy)->sa_len = addr_len;\n-    ((struct sockaddr*)&addrCopy)->sa_family = md_af;\n+    addrCopy.raw.family = AF_INET6;\n     addrp = &addrCopy;\n-#endif\n-\n-    size_t bytes = 0;\n-    PRInt32 netResult = 0;\n-#ifndef HAS_CONNECTX\n-    netResult = sendto(fd->secret->md.osfd, buf, amount, MSG_FASTOPEN,\n-                       (struct sockaddr*)addrp, addr_len);\n+#        endif\n+  }\n+#      endif\n+\n+#      ifdef _PR_HAVE_SOCKADDR_LEN\n+  /* if _PR_HAVE_SOCKADDR_LEN is defined and it is PR_AF_INET6 we set family\n+   * to AF_INET6 and we set address length. */\n+  addrCopy = *addr;\n+  ((struct sockaddr*)&addrCopy)->sa_len = addr_len;\n+  ((struct sockaddr*)&addrCopy)->sa_family = md_af;\n+  addrp = &addrCopy;\n+#      endif\n+\n+  size_t bytes = 0;\n+  PRInt32 netResult = 0;\n+#      ifndef HAS_CONNECTX\n+  netResult = sendto(fd->secret->md.osfd, buf, amount, MSG_FASTOPEN,\n+                     (struct sockaddr*)addrp, addr_len);\n+  if (netResult >= 0) {\n+    bytes = netResult;\n+  }\n+#      else\n+  sa_endpoints_t endpoints;\n+  endpoints.sae_srcif = 0;\n+  endpoints.sae_srcaddr = NULL;\n+  endpoints.sae_srcaddrlen = 0;\n+  endpoints.sae_dstaddr = (struct sockaddr*)addrp;\n+  endpoints.sae_dstaddrlen = addr_len;\n+  struct iovec iov[1];\n+  iov[0].iov_base = buf;\n+  iov[0].iov_len = amount;\n+  netResult = connectx(fd->secret->md.osfd, &endpoints, SAE_ASSOCID_ANY,\n+                       CONNECT_DATA_IDEMPOTENT, iov, 1, &bytes, NULL);\n+#      endif\n+  syserrno = errno;\n+  if ((netResult < 0) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n+      (!fd->secret->nonblocking)) {\n+    if (PR_INTERVAL_NO_WAIT == timeout) {\n+      syserrno = ETIMEDOUT;\n+    } else {\n+      fNeedContinue = PR_TRUE;\n+    }\n+  }\n+  if (fNeedContinue == PR_TRUE) {\n+    pt_Continuation op;\n+    op.arg1.osfd = fd->secret->md.osfd;\n+    op.arg2.buffer = (void*)buf;\n+    op.arg3.amount = amount;\n+    op.arg4.flags = flags;\n+    op.arg5.addr = (PRNetAddr*)addrp;\n+    op.timeout = timeout;\n+    op.result.code = 0; /* initialize the number sent */\n+    op.function = pt_sendto_cont;\n+    op.event = POLLOUT | POLLPRI;\n+    netResult = pt_Continue(&op);\n     if (netResult >= 0) {\n-        bytes = netResult;\n+      bytes = netResult;\n     }\n-#else\n-    sa_endpoints_t endpoints;\n-    endpoints.sae_srcif = 0;\n-    endpoints.sae_srcaddr = NULL;\n-    endpoints.sae_srcaddrlen = 0;\n-    endpoints.sae_dstaddr = (struct sockaddr*)addrp;\n-    endpoints.sae_dstaddrlen = addr_len;\n-    struct iovec iov[1];\n-    iov[0].iov_base = buf;\n-    iov[0].iov_len = amount;\n-    netResult = connectx(fd->secret->md.osfd, &endpoints, SAE_ASSOCID_ANY,\n-                         CONNECT_DATA_IDEMPOTENT, iov, 1, &bytes, NULL);\n-#endif\n-    syserrno = errno;\n-    if ((netResult < 0) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n-        (!fd->secret->nonblocking)) {\n-        if (PR_INTERVAL_NO_WAIT == timeout) {\n-            syserrno = ETIMEDOUT;\n-        } else {\n-            fNeedContinue = PR_TRUE;\n-        }\n-    }\n-    if (fNeedContinue == PR_TRUE) {\n-        pt_Continuation op;\n-        op.arg1.osfd = fd->secret->md.osfd;\n-        op.arg2.buffer = (void*)buf;\n-        op.arg3.amount = amount;\n-        op.arg4.flags = flags;\n-        op.arg5.addr = (PRNetAddr*)addrp;\n-        op.timeout = timeout;\n-        op.result.code = 0; /* initialize the number sent */\n-        op.function = pt_sendto_cont;\n-        op.event = POLLOUT | POLLPRI;\n-        netResult = pt_Continue(&op);\n-        if (netResult >= 0) {\n-            bytes = netResult;\n-        }\n-        syserrno = op.syserrno;\n-    }\n-    if (netResult < 0) {\n-        pt_MapError(_PR_MD_MAP_SENDTO_ERROR, syserrno);\n-        return -1;\n-    }\n-    return bytes;\n-#else /* !(defined(LINUX) || HAS_CONNECTX) */\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+    syserrno = op.syserrno;\n+  }\n+  if (netResult < 0) {\n+    pt_MapError(_PR_MD_MAP_SENDTO_ERROR, syserrno);\n     return -1;\n-#endif\n+  }\n+  return bytes;\n+#    else /* !(defined(LINUX) || HAS_CONNECTX) */\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return -1;\n+#    endif\n } /* pt_TCP_SendTo */\n-#endif /* LINUX || DARWIN */\n-\n-static PRInt32\n-pt_RecvFrom(PRFileDesc* fd, void* buf, PRInt32 amount,\n-            PRIntn flags, PRNetAddr* addr,\n-            PRIntervalTime timeout)\n-{\n-    PRBool fNeedContinue = PR_FALSE;\n-    PRInt32 syserrno, bytes = -1;\n-    pt_SockLen addr_len = sizeof(PRNetAddr);\n-\n-    if (pt_TestAbort()) {\n-        return bytes;\n-    }\n+#  endif /* LINUX || DARWIN */\n \n-    bytes = recvfrom(fd->secret->md.osfd, buf, amount, flags,\n-                     (struct sockaddr*)addr, &addr_len);\n-    syserrno = errno;\n+static PRInt32 pt_RecvFrom(PRFileDesc* fd, void* buf, PRInt32 amount,\n+                           PRIntn flags, PRNetAddr* addr,\n+                           PRIntervalTime timeout) {\n+  PRBool fNeedContinue = PR_FALSE;\n+  PRInt32 syserrno, bytes = -1;\n+  pt_SockLen addr_len = sizeof(PRNetAddr);\n \n-    if ((bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n-        (!fd->secret->nonblocking)) {\n-        if (PR_INTERVAL_NO_WAIT == timeout) {\n-            syserrno = ETIMEDOUT;\n-        } else {\n-            fNeedContinue = PR_TRUE;\n-        }\n-    }\n+  if (pt_TestAbort()) {\n+    return bytes;\n+  }\n \n-    if (fNeedContinue == PR_TRUE) {\n-        pt_Continuation op;\n-        op.arg1.osfd = fd->secret->md.osfd;\n-        op.arg2.buffer = buf;\n-        op.arg3.amount = amount;\n-        op.arg4.flags = flags;\n-        op.arg5.addr = addr;\n-        op.timeout = timeout;\n-        op.function = pt_recvfrom_cont;\n-        op.event = POLLIN | POLLPRI;\n-        bytes = pt_Continue(&op);\n-        syserrno = op.syserrno;\n-    }\n-    if (bytes >= 0) {\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-        /* ignore the sa_len field of struct sockaddr */\n-        if (addr) {\n-            addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n-        }\n-#endif /* _PR_HAVE_SOCKADDR_LEN */\n-#ifdef _PR_INET6\n-        if (addr && (AF_INET6 == addr->raw.family)) {\n-            addr->raw.family = PR_AF_INET6;\n-        }\n-#endif\n+  bytes = recvfrom(fd->secret->md.osfd, buf, amount, flags,\n+                   (struct sockaddr*)addr, &addr_len);\n+  syserrno = errno;\n+\n+  if ((bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN) &&\n+      (!fd->secret->nonblocking)) {\n+    if (PR_INTERVAL_NO_WAIT == timeout) {\n+      syserrno = ETIMEDOUT;\n     } else {\n-        pt_MapError(_PR_MD_MAP_RECVFROM_ERROR, syserrno);\n+      fNeedContinue = PR_TRUE;\n+    }\n+  }\n+\n+  if (fNeedContinue == PR_TRUE) {\n+    pt_Continuation op;\n+    op.arg1.osfd = fd->secret->md.osfd;\n+    op.arg2.buffer = buf;\n+    op.arg3.amount = amount;\n+    op.arg4.flags = flags;\n+    op.arg5.addr = addr;\n+    op.timeout = timeout;\n+    op.function = pt_recvfrom_cont;\n+    op.event = POLLIN | POLLPRI;\n+    bytes = pt_Continue(&op);\n+    syserrno = op.syserrno;\n+  }\n+  if (bytes >= 0) {\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+    /* ignore the sa_len field of struct sockaddr */\n+    if (addr) {\n+      addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n     }\n-    return bytes;\n+#  endif /* _PR_HAVE_SOCKADDR_LEN */\n+#  ifdef _PR_INET6\n+    if (addr && (AF_INET6 == addr->raw.family)) {\n+      addr->raw.family = PR_AF_INET6;\n+    }\n+#  endif\n+  } else {\n+    pt_MapError(_PR_MD_MAP_RECVFROM_ERROR, syserrno);\n+  }\n+  return bytes;\n } /* pt_RecvFrom */\n \n-#ifdef AIX\n-#ifndef HAVE_SEND_FILE\n+#  ifdef AIX\n+#    ifndef HAVE_SEND_FILE\n static pthread_once_t pt_aix_sendfile_once_block = PTHREAD_ONCE_INIT;\n \n-static void\n-pt_aix_sendfile_init_routine(void)\n-{\n-    void* handle = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL);\n-    pt_aix_sendfile_fptr = (ssize_t (*)())dlsym(handle, \"send_file\");\n-    dlclose(handle);\n+static void pt_aix_sendfile_init_routine(void) {\n+  void* handle = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL);\n+  pt_aix_sendfile_fptr = (ssize_t(*)())dlsym(handle, \"send_file\");\n+  dlclose(handle);\n }\n \n /*\n  * pt_AIXDispatchSendFile\n  */\n-static PRInt32\n-pt_AIXDispatchSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n-                       PRTransmitFileFlags flags,\n-                       PRIntervalTime timeout)\n-{\n-    int rv;\n-\n-    rv = pthread_once(&pt_aix_sendfile_once_block, pt_aix_sendfile_init_routine);\n-    PR_ASSERT(0 == rv);\n-    if (pt_aix_sendfile_fptr) {\n-        return pt_AIXSendFile(sd, sfd, flags, timeout);\n-    } else {\n-        return PR_EmulateSendFile(sd, sfd, flags, timeout);\n-    }\n+static PRInt32 pt_AIXDispatchSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n+                                      PRTransmitFileFlags flags,\n+                                      PRIntervalTime timeout) {\n+  int rv;\n+\n+  rv = pthread_once(&pt_aix_sendfile_once_block, pt_aix_sendfile_init_routine);\n+  PR_ASSERT(0 == rv);\n+  if (pt_aix_sendfile_fptr) {\n+    return pt_AIXSendFile(sd, sfd, flags, timeout);\n+  } else {\n+    return PR_EmulateSendFile(sd, sfd, flags, timeout);\n+  }\n }\n-#endif /* !HAVE_SEND_FILE */\n+#    endif /* !HAVE_SEND_FILE */\n \n /*\n  * pt_AIXSendFile\n@@ -2112,93 +2005,91 @@ pt_AIXDispatchSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n  *      call available in AIX 4.3.2.\n  */\n \n-static PRInt32\n-pt_AIXSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n-               PRTransmitFileFlags flags,\n-               PRIntervalTime timeout)\n-{\n-    struct sf_parms sf_struct;\n-    uint_t send_flags;\n-    ssize_t rv;\n-    int syserrno;\n-    PRInt32 count;\n-    unsigned long long saved_file_offset;\n-    long long saved_file_bytes;\n-\n-    sf_struct.header_data = (void*)sfd->header; /* cast away the 'const' */\n-    sf_struct.header_length = sfd->hlen;\n-    sf_struct.file_descriptor = sfd->fd->secret->md.osfd;\n-    sf_struct.file_size = 0;\n-    sf_struct.file_offset = sfd->file_offset;\n-    if (sfd->file_nbytes == 0) {\n-        sf_struct.file_bytes = -1;\n+static PRInt32 pt_AIXSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n+                              PRTransmitFileFlags flags,\n+                              PRIntervalTime timeout) {\n+  struct sf_parms sf_struct;\n+  uint_t send_flags;\n+  ssize_t rv;\n+  int syserrno;\n+  PRInt32 count;\n+  unsigned long long saved_file_offset;\n+  long long saved_file_bytes;\n+\n+  sf_struct.header_data = (void*)sfd->header; /* cast away the 'const' */\n+  sf_struct.header_length = sfd->hlen;\n+  sf_struct.file_descriptor = sfd->fd->secret->md.osfd;\n+  sf_struct.file_size = 0;\n+  sf_struct.file_offset = sfd->file_offset;\n+  if (sfd->file_nbytes == 0) {\n+    sf_struct.file_bytes = -1;\n+  } else {\n+    sf_struct.file_bytes = sfd->file_nbytes;\n+  }\n+  sf_struct.trailer_data = (void*)sfd->trailer;\n+  sf_struct.trailer_length = sfd->tlen;\n+  sf_struct.bytes_sent = 0;\n+\n+  saved_file_offset = sf_struct.file_offset;\n+  saved_file_bytes = sf_struct.file_bytes;\n+\n+  send_flags = 0; /* flags processed at the end */\n+\n+  /* The first argument to send_file() is int*. */\n+  PR_ASSERT(sizeof(int) == sizeof(sd->secret->md.osfd));\n+  do {\n+    rv = AIX_SEND_FILE(&sd->secret->md.osfd, &sf_struct, send_flags);\n+  } while (rv == -1 && (syserrno = errno) == EINTR);\n+\n+  if (rv == -1) {\n+    if (syserrno == EAGAIN || syserrno == EWOULDBLOCK) {\n+      count = 0; /* Not a real error.  Need to continue. */\n     } else {\n-        sf_struct.file_bytes = sfd->file_nbytes;\n+      count = -1;\n     }\n-    sf_struct.trailer_data = (void*)sfd->trailer;\n-    sf_struct.trailer_length = sfd->tlen;\n-    sf_struct.bytes_sent = 0;\n-\n-    saved_file_offset = sf_struct.file_offset;\n-    saved_file_bytes = sf_struct.file_bytes;\n-\n-    send_flags = 0; /* flags processed at the end */\n-\n-    /* The first argument to send_file() is int*. */\n-    PR_ASSERT(sizeof(int) == sizeof(sd->secret->md.osfd));\n-    do {\n-        rv = AIX_SEND_FILE(&sd->secret->md.osfd, &sf_struct, send_flags);\n-    } while (rv == -1 && (syserrno = errno) == EINTR);\n-\n-    if (rv == -1) {\n-        if (syserrno == EAGAIN || syserrno == EWOULDBLOCK) {\n-            count = 0; /* Not a real error.  Need to continue. */\n-        } else {\n-            count = -1;\n-        }\n-    } else {\n-        count = sf_struct.bytes_sent;\n-        /*\n-         * A bug in AIX 4.3.2 prevents the 'file_bytes' field from\n-         * being updated. So, 'file_bytes' is maintained by NSPR to\n-         * avoid conflict when this bug is fixed in AIX, in the future.\n-         */\n-        if (saved_file_bytes != -1) {\n-            saved_file_bytes -= (sf_struct.file_offset - saved_file_offset);\n-        }\n-        sf_struct.file_bytes = saved_file_bytes;\n-    }\n-\n-    if ((rv == 1) || ((rv == -1) && (count == 0))) {\n-        pt_Continuation op;\n-\n-        op.arg1.osfd = sd->secret->md.osfd;\n-        op.arg2.buffer = &sf_struct;\n-        op.arg4.flags = send_flags;\n-        op.result.code = count;\n-        op.timeout = timeout;\n-        op.function = pt_aix_sendfile_cont;\n-        op.event = POLLOUT | POLLPRI;\n-        count = pt_Continue(&op);\n-        syserrno = op.syserrno;\n-    }\n-\n-    if (count == -1) {\n-        pt_MapError(_MD_aix_map_sendfile_error, syserrno);\n-        return -1;\n-    }\n-    if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) {\n-        PR_Close(sd);\n-    }\n-    PR_ASSERT(count ==\n-              (sfd->hlen + sfd->tlen +\n-               ((sfd->file_nbytes == 0) ? sf_struct.file_size - sfd->file_offset\n-                                        : sfd->file_nbytes)));\n-    return count;\n+  } else {\n+    count = sf_struct.bytes_sent;\n+    /*\n+     * A bug in AIX 4.3.2 prevents the 'file_bytes' field from\n+     * being updated. So, 'file_bytes' is maintained by NSPR to\n+     * avoid conflict when this bug is fixed in AIX, in the future.\n+     */\n+    if (saved_file_bytes != -1) {\n+      saved_file_bytes -= (sf_struct.file_offset - saved_file_offset);\n+    }\n+    sf_struct.file_bytes = saved_file_bytes;\n+  }\n+\n+  if ((rv == 1) || ((rv == -1) && (count == 0))) {\n+    pt_Continuation op;\n+\n+    op.arg1.osfd = sd->secret->md.osfd;\n+    op.arg2.buffer = &sf_struct;\n+    op.arg4.flags = send_flags;\n+    op.result.code = count;\n+    op.timeout = timeout;\n+    op.function = pt_aix_sendfile_cont;\n+    op.event = POLLOUT | POLLPRI;\n+    count = pt_Continue(&op);\n+    syserrno = op.syserrno;\n+  }\n+\n+  if (count == -1) {\n+    pt_MapError(_MD_aix_map_sendfile_error, syserrno);\n+    return -1;\n+  }\n+  if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) {\n+    PR_Close(sd);\n+  }\n+  PR_ASSERT(count ==\n+            (sfd->hlen + sfd->tlen +\n+             ((sfd->file_nbytes == 0) ? sf_struct.file_size - sfd->file_offset\n+                                      : sfd->file_nbytes)));\n+  return count;\n }\n-#endif /* AIX */\n+#  endif /* AIX */\n \n-#ifdef HPUX11\n+#  ifdef HPUX11\n /*\n  * pt_HPUXSendFile\n  *\n@@ -2213,115 +2104,113 @@ pt_AIXSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n  *      call available in HP-UX B.11.00.\n  */\n \n-static PRInt32\n-pt_HPUXSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n-                PRTransmitFileFlags flags,\n-                PRIntervalTime timeout)\n-{\n-    struct stat statbuf;\n-    size_t nbytes_to_send, file_nbytes_to_send;\n-    struct iovec hdtrl[2]; /* optional header and trailer buffers */\n-    int send_flags;\n-    PRInt32 count;\n-    int syserrno;\n-\n-    if (sfd->file_nbytes == 0) {\n-        /* Get file size */\n-        if (fstat(sfd->fd->secret->md.osfd, &statbuf) == -1) {\n-            _PR_MD_MAP_FSTAT_ERROR(errno);\n-            return -1;\n-        }\n-        file_nbytes_to_send = statbuf.st_size - sfd->file_offset;\n-    } else {\n-        file_nbytes_to_send = sfd->file_nbytes;\n-    }\n-    nbytes_to_send = sfd->hlen + sfd->tlen + file_nbytes_to_send;\n-\n-    hdtrl[0].iov_base = (void*)sfd->header; /* cast away the 'const' */\n-    hdtrl[0].iov_len = sfd->hlen;\n-    hdtrl[1].iov_base = (void*)sfd->trailer;\n-    hdtrl[1].iov_len = sfd->tlen;\n-    /*\n-     * SF_DISCONNECT seems to close the socket even if sendfile()\n-     * only does a partial send on a nonblocking socket.  This\n-     * would prevent the subsequent sendfile() calls on that socket\n-     * from working.  So we don't use the SD_DISCONNECT flag.\n-     */\n-    send_flags = 0;\n-\n-    do {\n-        count = sendfile(sd->secret->md.osfd, sfd->fd->secret->md.osfd,\n-                         sfd->file_offset, file_nbytes_to_send, hdtrl, send_flags);\n-    } while (count == -1 && (syserrno = errno) == EINTR);\n-\n-    if (count == -1 && (syserrno == EAGAIN || syserrno == EWOULDBLOCK)) {\n-        count = 0;\n-    }\n-    if (count != -1 && count < nbytes_to_send) {\n-        pt_Continuation op;\n-\n-        if (count < sfd->hlen) {\n-            /* header not sent */\n-\n-            hdtrl[0].iov_base = ((char*)sfd->header) + count;\n-            hdtrl[0].iov_len = sfd->hlen - count;\n-            op.arg3.file_spec.offset = sfd->file_offset;\n-            op.arg3.file_spec.nbytes = file_nbytes_to_send;\n-        } else if (count < (sfd->hlen + file_nbytes_to_send)) {\n-            /* header sent, file not sent */\n-\n-            hdtrl[0].iov_base = NULL;\n-            hdtrl[0].iov_len = 0;\n-\n-            op.arg3.file_spec.offset = sfd->file_offset + count - sfd->hlen;\n-            op.arg3.file_spec.nbytes = file_nbytes_to_send - (count - sfd->hlen);\n-        } else if (count < (sfd->hlen + file_nbytes_to_send + sfd->tlen)) {\n-            PRUint32 trailer_nbytes_sent;\n-\n-            /* header sent, file sent, trailer not sent */\n-\n-            hdtrl[0].iov_base = NULL;\n-            hdtrl[0].iov_len = 0;\n-            /*\n-             * set file offset and len so that no more file data is\n-             * sent\n-             */\n-            op.arg3.file_spec.offset = statbuf.st_size;\n-            op.arg3.file_spec.nbytes = 0;\n-\n-            trailer_nbytes_sent = count - sfd->hlen - file_nbytes_to_send;\n-            hdtrl[1].iov_base = ((char*)sfd->trailer) + trailer_nbytes_sent;\n-            hdtrl[1].iov_len = sfd->tlen - trailer_nbytes_sent;\n-        }\n-\n-        op.arg1.osfd = sd->secret->md.osfd;\n-        op.filedesc = sfd->fd->secret->md.osfd;\n-        op.arg2.buffer = hdtrl;\n-        op.arg3.file_spec.st_size = statbuf.st_size;\n-        op.arg4.flags = send_flags;\n-        op.nbytes_to_send = nbytes_to_send - count;\n-        op.result.code = count;\n-        op.timeout = timeout;\n-        op.function = pt_hpux_sendfile_cont;\n-        op.event = POLLOUT | POLLPRI;\n-        count = pt_Continue(&op);\n-        syserrno = op.syserrno;\n-    }\n-\n-    if (count == -1) {\n-        pt_MapError(_MD_hpux_map_sendfile_error, syserrno);\n-        return -1;\n-    }\n-    if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) {\n-        PR_Close(sd);\n-    }\n-    PR_ASSERT(count == nbytes_to_send);\n-    return count;\n+static PRInt32 pt_HPUXSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n+                               PRTransmitFileFlags flags,\n+                               PRIntervalTime timeout) {\n+  struct stat statbuf;\n+  size_t nbytes_to_send, file_nbytes_to_send;\n+  struct iovec hdtrl[2]; /* optional header and trailer buffers */\n+  int send_flags;\n+  PRInt32 count;\n+  int syserrno;\n+\n+  if (sfd->file_nbytes == 0) {\n+    /* Get file size */\n+    if (fstat(sfd->fd->secret->md.osfd, &statbuf) == -1) {\n+      _PR_MD_MAP_FSTAT_ERROR(errno);\n+      return -1;\n+    }\n+    file_nbytes_to_send = statbuf.st_size - sfd->file_offset;\n+  } else {\n+    file_nbytes_to_send = sfd->file_nbytes;\n+  }\n+  nbytes_to_send = sfd->hlen + sfd->tlen + file_nbytes_to_send;\n+\n+  hdtrl[0].iov_base = (void*)sfd->header; /* cast away the 'const' */\n+  hdtrl[0].iov_len = sfd->hlen;\n+  hdtrl[1].iov_base = (void*)sfd->trailer;\n+  hdtrl[1].iov_len = sfd->tlen;\n+  /*\n+   * SF_DISCONNECT seems to close the socket even if sendfile()\n+   * only does a partial send on a nonblocking socket.  This\n+   * would prevent the subsequent sendfile() calls on that socket\n+   * from working.  So we don't use the SD_DISCONNECT flag.\n+   */\n+  send_flags = 0;\n+\n+  do {\n+    count = sendfile(sd->secret->md.osfd, sfd->fd->secret->md.osfd,\n+                     sfd->file_offset, file_nbytes_to_send, hdtrl, send_flags);\n+  } while (count == -1 && (syserrno = errno) == EINTR);\n+\n+  if (count == -1 && (syserrno == EAGAIN || syserrno == EWOULDBLOCK)) {\n+    count = 0;\n+  }\n+  if (count != -1 && count < nbytes_to_send) {\n+    pt_Continuation op;\n+\n+    if (count < sfd->hlen) {\n+      /* header not sent */\n+\n+      hdtrl[0].iov_base = ((char*)sfd->header) + count;\n+      hdtrl[0].iov_len = sfd->hlen - count;\n+      op.arg3.file_spec.offset = sfd->file_offset;\n+      op.arg3.file_spec.nbytes = file_nbytes_to_send;\n+    } else if (count < (sfd->hlen + file_nbytes_to_send)) {\n+      /* header sent, file not sent */\n+\n+      hdtrl[0].iov_base = NULL;\n+      hdtrl[0].iov_len = 0;\n+\n+      op.arg3.file_spec.offset = sfd->file_offset + count - sfd->hlen;\n+      op.arg3.file_spec.nbytes = file_nbytes_to_send - (count - sfd->hlen);\n+    } else if (count < (sfd->hlen + file_nbytes_to_send + sfd->tlen)) {\n+      PRUint32 trailer_nbytes_sent;\n+\n+      /* header sent, file sent, trailer not sent */\n+\n+      hdtrl[0].iov_base = NULL;\n+      hdtrl[0].iov_len = 0;\n+      /*\n+       * set file offset and len so that no more file data is\n+       * sent\n+       */\n+      op.arg3.file_spec.offset = statbuf.st_size;\n+      op.arg3.file_spec.nbytes = 0;\n+\n+      trailer_nbytes_sent = count - sfd->hlen - file_nbytes_to_send;\n+      hdtrl[1].iov_base = ((char*)sfd->trailer) + trailer_nbytes_sent;\n+      hdtrl[1].iov_len = sfd->tlen - trailer_nbytes_sent;\n+    }\n+\n+    op.arg1.osfd = sd->secret->md.osfd;\n+    op.filedesc = sfd->fd->secret->md.osfd;\n+    op.arg2.buffer = hdtrl;\n+    op.arg3.file_spec.st_size = statbuf.st_size;\n+    op.arg4.flags = send_flags;\n+    op.nbytes_to_send = nbytes_to_send - count;\n+    op.result.code = count;\n+    op.timeout = timeout;\n+    op.function = pt_hpux_sendfile_cont;\n+    op.event = POLLOUT | POLLPRI;\n+    count = pt_Continue(&op);\n+    syserrno = op.syserrno;\n+  }\n+\n+  if (count == -1) {\n+    pt_MapError(_MD_hpux_map_sendfile_error, syserrno);\n+    return -1;\n+  }\n+  if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) {\n+    PR_Close(sd);\n+  }\n+  PR_ASSERT(count == nbytes_to_send);\n+  return count;\n }\n \n-#endif /* HPUX11 */\n+#  endif /* HPUX11 */\n \n-#ifdef SOLARIS\n+#  ifdef SOLARIS\n \n /*\n  *    pt_SolarisSendFile\n@@ -2337,186 +2226,180 @@ pt_HPUXSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n  *    call available in Solaris 8.\n  */\n \n-static PRInt32\n-pt_SolarisSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n-                   PRTransmitFileFlags flags,\n-                   PRIntervalTime timeout)\n-{\n-    struct stat statbuf;\n-    size_t nbytes_to_send, file_nbytes_to_send;\n-    struct sendfilevec sfv_struct[3];\n-    int sfvcnt = 0;\n-    size_t xferred;\n-    PRInt32 count;\n-    int syserrno;\n-\n-    if (sfd->file_nbytes == 0) {\n-        /* Get file size */\n-        if (fstat(sfd->fd->secret->md.osfd, &statbuf) == -1) {\n-            _PR_MD_MAP_FSTAT_ERROR(errno);\n-            return -1;\n-        }\n-        file_nbytes_to_send = statbuf.st_size - sfd->file_offset;\n-    } else {\n-        file_nbytes_to_send = sfd->file_nbytes;\n-    }\n-\n-    nbytes_to_send = sfd->hlen + sfd->tlen + file_nbytes_to_send;\n-\n-    if (sfd->hlen != 0) {\n-        sfv_struct[sfvcnt].sfv_fd = SFV_FD_SELF;\n-        sfv_struct[sfvcnt].sfv_flag = 0;\n-        sfv_struct[sfvcnt].sfv_off = (off_t)sfd->header;\n-        sfv_struct[sfvcnt].sfv_len = sfd->hlen;\n-        sfvcnt++;\n-    }\n-\n-    if (file_nbytes_to_send != 0) {\n-        sfv_struct[sfvcnt].sfv_fd = sfd->fd->secret->md.osfd;\n-        sfv_struct[sfvcnt].sfv_flag = 0;\n-        sfv_struct[sfvcnt].sfv_off = sfd->file_offset;\n-        sfv_struct[sfvcnt].sfv_len = file_nbytes_to_send;\n-        sfvcnt++;\n-    }\n-\n-    if (sfd->tlen != 0) {\n-        sfv_struct[sfvcnt].sfv_fd = SFV_FD_SELF;\n-        sfv_struct[sfvcnt].sfv_flag = 0;\n-        sfv_struct[sfvcnt].sfv_off = (off_t)sfd->trailer;\n-        sfv_struct[sfvcnt].sfv_len = sfd->tlen;\n-        sfvcnt++;\n-    }\n-\n-    if (0 == sfvcnt) {\n-        count = 0;\n-        goto done;\n+static PRInt32 pt_SolarisSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n+                                  PRTransmitFileFlags flags,\n+                                  PRIntervalTime timeout) {\n+  struct stat statbuf;\n+  size_t nbytes_to_send, file_nbytes_to_send;\n+  struct sendfilevec sfv_struct[3];\n+  int sfvcnt = 0;\n+  size_t xferred;\n+  PRInt32 count;\n+  int syserrno;\n+\n+  if (sfd->file_nbytes == 0) {\n+    /* Get file size */\n+    if (fstat(sfd->fd->secret->md.osfd, &statbuf) == -1) {\n+      _PR_MD_MAP_FSTAT_ERROR(errno);\n+      return -1;\n+    }\n+    file_nbytes_to_send = statbuf.st_size - sfd->file_offset;\n+  } else {\n+    file_nbytes_to_send = sfd->file_nbytes;\n+  }\n+\n+  nbytes_to_send = sfd->hlen + sfd->tlen + file_nbytes_to_send;\n+\n+  if (sfd->hlen != 0) {\n+    sfv_struct[sfvcnt].sfv_fd = SFV_FD_SELF;\n+    sfv_struct[sfvcnt].sfv_flag = 0;\n+    sfv_struct[sfvcnt].sfv_off = (off_t)sfd->header;\n+    sfv_struct[sfvcnt].sfv_len = sfd->hlen;\n+    sfvcnt++;\n+  }\n+\n+  if (file_nbytes_to_send != 0) {\n+    sfv_struct[sfvcnt].sfv_fd = sfd->fd->secret->md.osfd;\n+    sfv_struct[sfvcnt].sfv_flag = 0;\n+    sfv_struct[sfvcnt].sfv_off = sfd->file_offset;\n+    sfv_struct[sfvcnt].sfv_len = file_nbytes_to_send;\n+    sfvcnt++;\n+  }\n+\n+  if (sfd->tlen != 0) {\n+    sfv_struct[sfvcnt].sfv_fd = SFV_FD_SELF;\n+    sfv_struct[sfvcnt].sfv_flag = 0;\n+    sfv_struct[sfvcnt].sfv_off = (off_t)sfd->trailer;\n+    sfv_struct[sfvcnt].sfv_len = sfd->tlen;\n+    sfvcnt++;\n+  }\n+\n+  if (0 == sfvcnt) {\n+    count = 0;\n+    goto done;\n+  }\n+\n+  /*\n+   * Strictly speaking, we may have sent some bytes when the\n+   * sendfilev() is interrupted and we should retry it from an\n+   * updated offset.  We are not doing that here.\n+   */\n+  count = SOLARIS_SENDFILEV(sd->secret->md.osfd, sfv_struct, sfvcnt, &xferred);\n+\n+  PR_ASSERT((count == -1) || (count == xferred));\n+\n+  if (count == -1) {\n+    syserrno = errno;\n+    if (syserrno == EINTR || syserrno == EAGAIN || syserrno == EWOULDBLOCK) {\n+      count = xferred;\n     }\n-\n+  } else if (count == 0) {\n     /*\n-     * Strictly speaking, we may have sent some bytes when the\n-     * sendfilev() is interrupted and we should retry it from an\n-     * updated offset.  We are not doing that here.\n+     * We are now at EOF. The file was truncated. Solaris sendfile is\n+     * supposed to return 0 and no error in this case, though some versions\n+     * may return -1 and EINVAL .\n      */\n-    count = SOLARIS_SENDFILEV(sd->secret->md.osfd, sfv_struct, sfvcnt, &xferred);\n-\n-    PR_ASSERT((count == -1) || (count == xferred));\n-\n-    if (count == -1) {\n-        syserrno = errno;\n-        if (syserrno == EINTR || syserrno == EAGAIN || syserrno == EWOULDBLOCK) {\n-            count = xferred;\n-        }\n-    } else if (count == 0) {\n-        /*\n-         * We are now at EOF. The file was truncated. Solaris sendfile is\n-         * supposed to return 0 and no error in this case, though some versions\n-         * may return -1 and EINVAL .\n-         */\n-        count = -1;\n-        syserrno = 0; /* will be treated as EOF */\n-    }\n-\n-    if (count != -1 && count < nbytes_to_send) {\n-        pt_Continuation op;\n-        struct sendfilevec* vec = sfv_struct;\n-        PRInt32 rem = count;\n-\n-        while (rem >= vec->sfv_len) {\n-            rem -= vec->sfv_len;\n-            vec++;\n-            sfvcnt--;\n-        }\n-        PR_ASSERT(sfvcnt > 0);\n-\n-        vec->sfv_off += rem;\n-        vec->sfv_len -= rem;\n-        PR_ASSERT(vec->sfv_len > 0);\n-\n-        op.arg1.osfd = sd->secret->md.osfd;\n-        op.arg2.buffer = vec;\n-        op.arg3.amount = sfvcnt;\n-        op.arg4.flags = 0;\n-        op.nbytes_to_send = nbytes_to_send - count;\n-        op.result.code = count;\n-        op.timeout = timeout;\n-        op.function = pt_solaris_sendfile_cont;\n-        op.event = POLLOUT | POLLPRI;\n-        count = pt_Continue(&op);\n-        syserrno = op.syserrno;\n-    }\n+    count = -1;\n+    syserrno = 0; /* will be treated as EOF */\n+  }\n+\n+  if (count != -1 && count < nbytes_to_send) {\n+    pt_Continuation op;\n+    struct sendfilevec* vec = sfv_struct;\n+    PRInt32 rem = count;\n+\n+    while (rem >= vec->sfv_len) {\n+      rem -= vec->sfv_len;\n+      vec++;\n+      sfvcnt--;\n+    }\n+    PR_ASSERT(sfvcnt > 0);\n+\n+    vec->sfv_off += rem;\n+    vec->sfv_len -= rem;\n+    PR_ASSERT(vec->sfv_len > 0);\n+\n+    op.arg1.osfd = sd->secret->md.osfd;\n+    op.arg2.buffer = vec;\n+    op.arg3.amount = sfvcnt;\n+    op.arg4.flags = 0;\n+    op.nbytes_to_send = nbytes_to_send - count;\n+    op.result.code = count;\n+    op.timeout = timeout;\n+    op.function = pt_solaris_sendfile_cont;\n+    op.event = POLLOUT | POLLPRI;\n+    count = pt_Continue(&op);\n+    syserrno = op.syserrno;\n+  }\n \n done:\n-    if (count == -1) {\n-        pt_MapError(_MD_solaris_map_sendfile_error, syserrno);\n-        return -1;\n-    }\n-    if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) {\n-        PR_Close(sd);\n-    }\n-    PR_ASSERT(count == nbytes_to_send);\n-    return count;\n+  if (count == -1) {\n+    pt_MapError(_MD_solaris_map_sendfile_error, syserrno);\n+    return -1;\n+  }\n+  if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) {\n+    PR_Close(sd);\n+  }\n+  PR_ASSERT(count == nbytes_to_send);\n+  return count;\n }\n \n-#ifndef HAVE_SENDFILEV\n+#    ifndef HAVE_SENDFILEV\n static pthread_once_t pt_solaris_sendfilev_once_block = PTHREAD_ONCE_INIT;\n \n-static void\n-pt_solaris_sendfilev_init_routine(void)\n-{\n-    void* handle;\n-    PRBool close_it = PR_FALSE;\n+static void pt_solaris_sendfilev_init_routine(void) {\n+  void* handle;\n+  PRBool close_it = PR_FALSE;\n+\n+  /*\n+   * We do not want to unload libsendfile.so.  This handle is leaked\n+   * intentionally.\n+   */\n+  handle = dlopen(\"libsendfile.so\", RTLD_LAZY | RTLD_GLOBAL);\n+  PR_LOG(_pr_io_lm, PR_LOG_DEBUG,\n+         (\"dlopen(libsendfile.so) returns %p\", handle));\n \n+  if (NULL == handle) {\n     /*\n-     * We do not want to unload libsendfile.so.  This handle is leaked\n-     * intentionally.\n+     * The dlopen(0, mode) call is to allow for the possibility that\n+     * sendfilev() may become part of a standard system library in a\n+     * future Solaris release.\n      */\n-    handle = dlopen(\"libsendfile.so\", RTLD_LAZY | RTLD_GLOBAL);\n-    PR_LOG(_pr_io_lm, PR_LOG_DEBUG,\n-           (\"dlopen(libsendfile.so) returns %p\", handle));\n-\n-    if (NULL == handle) {\n-        /*\n-         * The dlopen(0, mode) call is to allow for the possibility that\n-         * sendfilev() may become part of a standard system library in a\n-         * future Solaris release.\n-         */\n-        handle = dlopen(0, RTLD_LAZY | RTLD_GLOBAL);\n-        PR_LOG(_pr_io_lm, PR_LOG_DEBUG, (\"dlopen(0) returns %p\", handle));\n-        close_it = PR_TRUE;\n-    }\n-    pt_solaris_sendfilev_fptr = (ssize_t (*)())dlsym(handle, \"sendfilev\");\n-    PR_LOG(_pr_io_lm, PR_LOG_DEBUG,\n-           (\"dlsym(sendfilev) returns %p\", pt_solaris_sendfilev_fptr));\n-\n-    if (close_it) {\n-        dlclose(handle);\n-    }\n+    handle = dlopen(0, RTLD_LAZY | RTLD_GLOBAL);\n+    PR_LOG(_pr_io_lm, PR_LOG_DEBUG, (\"dlopen(0) returns %p\", handle));\n+    close_it = PR_TRUE;\n+  }\n+  pt_solaris_sendfilev_fptr = (ssize_t(*)())dlsym(handle, \"sendfilev\");\n+  PR_LOG(_pr_io_lm, PR_LOG_DEBUG,\n+         (\"dlsym(sendfilev) returns %p\", pt_solaris_sendfilev_fptr));\n+\n+  if (close_it) {\n+    dlclose(handle);\n+  }\n }\n \n /*\n  * pt_SolarisDispatchSendFile\n  */\n-static PRInt32\n-pt_SolarisDispatchSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n-                           PRTransmitFileFlags flags,\n-                           PRIntervalTime timeout)\n-{\n-    int rv;\n-\n-    rv = pthread_once(&pt_solaris_sendfilev_once_block,\n-                      pt_solaris_sendfilev_init_routine);\n-    PR_ASSERT(0 == rv);\n-    if (pt_solaris_sendfilev_fptr) {\n-        return pt_SolarisSendFile(sd, sfd, flags, timeout);\n-    } else {\n-        return PR_EmulateSendFile(sd, sfd, flags, timeout);\n-    }\n+static PRInt32 pt_SolarisDispatchSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n+                                          PRTransmitFileFlags flags,\n+                                          PRIntervalTime timeout) {\n+  int rv;\n+\n+  rv = pthread_once(&pt_solaris_sendfilev_once_block,\n+                    pt_solaris_sendfilev_init_routine);\n+  PR_ASSERT(0 == rv);\n+  if (pt_solaris_sendfilev_fptr) {\n+    return pt_SolarisSendFile(sd, sfd, flags, timeout);\n+  } else {\n+    return PR_EmulateSendFile(sd, sfd, flags, timeout);\n+  }\n }\n-#endif /* !HAVE_SENDFILEV */\n+#    endif /* !HAVE_SENDFILEV */\n \n-#endif /* SOLARIS */\n+#  endif /* SOLARIS */\n \n-#ifdef LINUX\n+#  ifdef LINUX\n /*\n  * pt_LinuxSendFile\n  *\n@@ -2531,591 +2414,575 @@ pt_SolarisDispatchSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n  *      call available in Linux kernel 2.2 or higher.\n  */\n \n-static PRInt32\n-pt_LinuxSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n-                 PRTransmitFileFlags flags,\n-                 PRIntervalTime timeout)\n-{\n-    struct stat statbuf;\n-    size_t file_nbytes_to_send;\n-    PRInt32 count = 0;\n-    ssize_t rv;\n-    int syserrno;\n-    off_t offset;\n-    PRBool tcp_cork_enabled = PR_FALSE;\n-    int tcp_cork;\n-\n-    if (sfd->file_nbytes == 0) {\n-        /* Get file size */\n-        if (fstat(sfd->fd->secret->md.osfd, &statbuf) == -1) {\n-            _PR_MD_MAP_FSTAT_ERROR(errno);\n-            return -1;\n-        }\n-        file_nbytes_to_send = statbuf.st_size - sfd->file_offset;\n+static PRInt32 pt_LinuxSendFile(PRFileDesc* sd, PRSendFileData* sfd,\n+                                PRTransmitFileFlags flags,\n+                                PRIntervalTime timeout) {\n+  struct stat statbuf;\n+  size_t file_nbytes_to_send;\n+  PRInt32 count = 0;\n+  ssize_t rv;\n+  int syserrno;\n+  off_t offset;\n+  PRBool tcp_cork_enabled = PR_FALSE;\n+  int tcp_cork;\n+\n+  if (sfd->file_nbytes == 0) {\n+    /* Get file size */\n+    if (fstat(sfd->fd->secret->md.osfd, &statbuf) == -1) {\n+      _PR_MD_MAP_FSTAT_ERROR(errno);\n+      return -1;\n+    }\n+    file_nbytes_to_send = statbuf.st_size - sfd->file_offset;\n+  } else {\n+    file_nbytes_to_send = sfd->file_nbytes;\n+  }\n+\n+  if ((sfd->hlen != 0 || sfd->tlen != 0) && sd->secret->md.tcp_nodelay == 0) {\n+    tcp_cork = 1;\n+    if (setsockopt(sd->secret->md.osfd, SOL_TCP, TCP_CORK, &tcp_cork,\n+                   sizeof tcp_cork) == 0) {\n+      tcp_cork_enabled = PR_TRUE;\n     } else {\n-        file_nbytes_to_send = sfd->file_nbytes;\n-    }\n-\n-    if ((sfd->hlen != 0 || sfd->tlen != 0) && sd->secret->md.tcp_nodelay == 0) {\n-        tcp_cork = 1;\n-        if (setsockopt(sd->secret->md.osfd, SOL_TCP, TCP_CORK, &tcp_cork,\n-                       sizeof tcp_cork) == 0) {\n-            tcp_cork_enabled = PR_TRUE;\n-        } else {\n-            syserrno = errno;\n-            if (syserrno != EINVAL) {\n-                _PR_MD_MAP_SETSOCKOPT_ERROR(syserrno);\n-                return -1;\n-            }\n-            /*\n-             * The most likely reason for the EINVAL error is that\n-             * TCP_NODELAY is set (with a function other than\n-             * PR_SetSocketOption).  This is not fatal, so we keep\n-             * on going.\n-             */\n-            PR_LOG(_pr_io_lm, PR_LOG_WARNING,\n-                   (\"pt_LinuxSendFile: \"\n-                    \"setsockopt(TCP_CORK) failed with EINVAL\\n\"));\n-        }\n-    }\n-\n-    if (sfd->hlen != 0) {\n-        count = PR_Send(sd, sfd->header, sfd->hlen, 0, timeout);\n-        if (count == -1) {\n-            goto failed;\n-        }\n+      syserrno = errno;\n+      if (syserrno != EINVAL) {\n+        _PR_MD_MAP_SETSOCKOPT_ERROR(syserrno);\n+        return -1;\n+      }\n+      /*\n+       * The most likely reason for the EINVAL error is that\n+       * TCP_NODELAY is set (with a function other than\n+       * PR_SetSocketOption).  This is not fatal, so we keep\n+       * on going.\n+       */\n+      PR_LOG(_pr_io_lm, PR_LOG_WARNING,\n+             (\"pt_LinuxSendFile: \"\n+              \"setsockopt(TCP_CORK) failed with EINVAL\\n\"));\n+    }\n+  }\n+\n+  if (sfd->hlen != 0) {\n+    count = PR_Send(sd, sfd->header, sfd->hlen, 0, timeout);\n+    if (count == -1) {\n+      goto failed;\n     }\n+  }\n \n-    if (file_nbytes_to_send != 0) {\n-        offset = sfd->file_offset;\n-        do {\n-            rv = sendfile(sd->secret->md.osfd, sfd->fd->secret->md.osfd, &offset,\n-                          file_nbytes_to_send);\n-        } while (rv == -1 && (syserrno = errno) == EINTR);\n-        if (rv == -1) {\n-            if (syserrno != EAGAIN && syserrno != EWOULDBLOCK) {\n-                _MD_linux_map_sendfile_error(syserrno);\n-                count = -1;\n-                goto failed;\n-            }\n-            rv = 0;\n-        }\n-        PR_ASSERT(rv == offset - sfd->file_offset);\n-        count += rv;\n-\n-        if (rv < file_nbytes_to_send) {\n-            pt_Continuation op;\n-\n-            op.arg1.osfd = sd->secret->md.osfd;\n-            op.in_fd = sfd->fd->secret->md.osfd;\n-            op.offset = offset;\n-            op.count = file_nbytes_to_send - rv;\n-            op.result.code = count;\n-            op.timeout = timeout;\n-            op.function = pt_linux_sendfile_cont;\n-            op.event = POLLOUT | POLLPRI;\n-            count = pt_Continue(&op);\n-            syserrno = op.syserrno;\n-            if (count == -1) {\n-                pt_MapError(_MD_linux_map_sendfile_error, syserrno);\n-                goto failed;\n-            }\n-        }\n+  if (file_nbytes_to_send != 0) {\n+    offset = sfd->file_offset;\n+    do {\n+      rv = sendfile(sd->secret->md.osfd, sfd->fd->secret->md.osfd, &offset,\n+                    file_nbytes_to_send);\n+    } while (rv == -1 && (syserrno = errno) == EINTR);\n+    if (rv == -1) {\n+      if (syserrno != EAGAIN && syserrno != EWOULDBLOCK) {\n+        _MD_linux_map_sendfile_error(syserrno);\n+        count = -1;\n+        goto failed;\n+      }\n+      rv = 0;\n+    }\n+    PR_ASSERT(rv == offset - sfd->file_offset);\n+    count += rv;\n+\n+    if (rv < file_nbytes_to_send) {\n+      pt_Continuation op;\n+\n+      op.arg1.osfd = sd->secret->md.osfd;\n+      op.in_fd = sfd->fd->secret->md.osfd;\n+      op.offset = offset;\n+      op.count = file_nbytes_to_send - rv;\n+      op.result.code = count;\n+      op.timeout = timeout;\n+      op.function = pt_linux_sendfile_cont;\n+      op.event = POLLOUT | POLLPRI;\n+      count = pt_Continue(&op);\n+      syserrno = op.syserrno;\n+      if (count == -1) {\n+        pt_MapError(_MD_linux_map_sendfile_error, syserrno);\n+        goto failed;\n+      }\n     }\n+  }\n \n-    if (sfd->tlen != 0) {\n-        rv = PR_Send(sd, sfd->trailer, sfd->tlen, 0, timeout);\n-        if (rv == -1) {\n-            count = -1;\n-            goto failed;\n-        }\n-        count += rv;\n+  if (sfd->tlen != 0) {\n+    rv = PR_Send(sd, sfd->trailer, sfd->tlen, 0, timeout);\n+    if (rv == -1) {\n+      count = -1;\n+      goto failed;\n     }\n+    count += rv;\n+  }\n \n failed:\n-    if (tcp_cork_enabled) {\n-        tcp_cork = 0;\n-        if (setsockopt(sd->secret->md.osfd, SOL_TCP, TCP_CORK, &tcp_cork,\n-                       sizeof tcp_cork) == -1 &&\n-            count != -1) {\n-            _PR_MD_MAP_SETSOCKOPT_ERROR(errno);\n-            count = -1;\n-        }\n-    }\n-    if (count != -1) {\n-        if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) {\n-            PR_Close(sd);\n-        }\n-        PR_ASSERT(count == sfd->hlen + sfd->tlen + file_nbytes_to_send);\n+  if (tcp_cork_enabled) {\n+    tcp_cork = 0;\n+    if (setsockopt(sd->secret->md.osfd, SOL_TCP, TCP_CORK, &tcp_cork,\n+                   sizeof tcp_cork) == -1 &&\n+        count != -1) {\n+      _PR_MD_MAP_SETSOCKOPT_ERROR(errno);\n+      count = -1;\n+    }\n+  }\n+  if (count != -1) {\n+    if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) {\n+      PR_Close(sd);\n     }\n-    return count;\n+    PR_ASSERT(count == sfd->hlen + sfd->tlen + file_nbytes_to_send);\n+  }\n+  return count;\n }\n-#endif /* LINUX */\n-\n-#ifdef AIX\n-extern int _pr_aix_send_file_use_disabled;\n-#endif\n-\n-static PRInt32\n-pt_SendFile(PRFileDesc* sd, PRSendFileData* sfd,\n-            PRTransmitFileFlags flags, PRIntervalTime timeout)\n-{\n-    if (pt_TestAbort()) {\n-        return -1;\n-    }\n-    /* The socket must be in blocking mode. */\n-    if (sd->secret->nonblocking) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return -1;\n-    }\n-#ifdef HPUX11\n-    return (pt_HPUXSendFile(sd, sfd, flags, timeout));\n-#elif defined(AIX)\n-#ifdef HAVE_SEND_FILE\n-    /*\n-     * A bug in AIX 4.3.2 results in corruption of data transferred by\n-     * send_file(); AIX patch PTF U463956 contains the fix.  A user can\n-     * disable the use of send_file function in NSPR, when this patch is\n-     * not installed on the system, by setting the envionment variable\n-     * NSPR_AIX_SEND_FILE_USE_DISABLED to 1.\n-     */\n-    if (_pr_aix_send_file_use_disabled) {\n-        return (PR_EmulateSendFile(sd, sfd, flags, timeout));\n-    } else {\n-        return (pt_AIXSendFile(sd, sfd, flags, timeout));\n-    }\n-#else\n-    return (PR_EmulateSendFile(sd, sfd, flags, timeout));\n-    /* return(pt_AIXDispatchSendFile(sd, sfd, flags, timeout));*/\n-#endif /* HAVE_SEND_FILE */\n-#elif defined(SOLARIS)\n-#ifdef HAVE_SENDFILEV\n-    return (pt_SolarisSendFile(sd, sfd, flags, timeout));\n-#else\n-    return (pt_SolarisDispatchSendFile(sd, sfd, flags, timeout));\n-#endif /* HAVE_SENDFILEV */\n-#elif defined(LINUX)\n-    return (pt_LinuxSendFile(sd, sfd, flags, timeout));\n-#else\n+#  endif /* LINUX */\n+\n+#  ifdef AIX\n+extern int _pr_aix_send_file_use_disabled;\n+#  endif\n+\n+static PRInt32 pt_SendFile(PRFileDesc* sd, PRSendFileData* sfd,\n+                           PRTransmitFileFlags flags, PRIntervalTime timeout) {\n+  if (pt_TestAbort()) {\n+    return -1;\n+  }\n+  /* The socket must be in blocking mode. */\n+  if (sd->secret->nonblocking) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return -1;\n+  }\n+#  ifdef HPUX11\n+  return (pt_HPUXSendFile(sd, sfd, flags, timeout));\n+#  elif defined(AIX)\n+#    ifdef HAVE_SEND_FILE\n+  /*\n+   * A bug in AIX 4.3.2 results in corruption of data transferred by\n+   * send_file(); AIX patch PTF U463956 contains the fix.  A user can\n+   * disable the use of send_file function in NSPR, when this patch is\n+   * not installed on the system, by setting the envionment variable\n+   * NSPR_AIX_SEND_FILE_USE_DISABLED to 1.\n+   */\n+  if (_pr_aix_send_file_use_disabled) {\n     return (PR_EmulateSendFile(sd, sfd, flags, timeout));\n-#endif\n+  } else {\n+    return (pt_AIXSendFile(sd, sfd, flags, timeout));\n+  }\n+#    else\n+  return (PR_EmulateSendFile(sd, sfd, flags, timeout));\n+  /* return(pt_AIXDispatchSendFile(sd, sfd, flags, timeout));*/\n+#    endif /* HAVE_SEND_FILE */\n+#  elif defined(SOLARIS)\n+#    ifdef HAVE_SENDFILEV\n+  return (pt_SolarisSendFile(sd, sfd, flags, timeout));\n+#    else\n+  return (pt_SolarisDispatchSendFile(sd, sfd, flags, timeout));\n+#    endif /* HAVE_SENDFILEV */\n+#  elif defined(LINUX)\n+  return (pt_LinuxSendFile(sd, sfd, flags, timeout));\n+#  else\n+  return (PR_EmulateSendFile(sd, sfd, flags, timeout));\n+#  endif\n }\n \n-static PRInt32\n-pt_TransmitFile(PRFileDesc* sd, PRFileDesc* fd,\n-                const void* headers, PRInt32 hlen,\n-                PRTransmitFileFlags flags,\n-                PRIntervalTime timeout)\n-{\n-    PRSendFileData sfd;\n-\n-    sfd.fd = fd;\n-    sfd.file_offset = 0;\n-    sfd.file_nbytes = 0;\n-    sfd.header = headers;\n-    sfd.hlen = hlen;\n-    sfd.trailer = NULL;\n-    sfd.tlen = 0;\n-\n-    return (pt_SendFile(sd, &sfd, flags, timeout));\n+static PRInt32 pt_TransmitFile(PRFileDesc* sd, PRFileDesc* fd,\n+                               const void* headers, PRInt32 hlen,\n+                               PRTransmitFileFlags flags,\n+                               PRIntervalTime timeout) {\n+  PRSendFileData sfd;\n+\n+  sfd.fd = fd;\n+  sfd.file_offset = 0;\n+  sfd.file_nbytes = 0;\n+  sfd.header = headers;\n+  sfd.hlen = hlen;\n+  sfd.trailer = NULL;\n+  sfd.tlen = 0;\n+\n+  return (pt_SendFile(sd, &sfd, flags, timeout));\n } /* pt_TransmitFile */\n \n-static PRInt32\n-pt_AcceptRead(PRFileDesc* sd, PRFileDesc** nd, PRNetAddr** raddr,\n-              void* buf, PRInt32 amount,\n-              PRIntervalTime timeout)\n-{\n-    PRInt32 rv = -1;\n-\n-    if (pt_TestAbort()) {\n-        return rv;\n-    }\n-    /* The socket must be in blocking mode. */\n-    if (sd->secret->nonblocking) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return rv;\n-    }\n+static PRInt32 pt_AcceptRead(PRFileDesc* sd, PRFileDesc** nd, PRNetAddr** raddr,\n+                             void* buf, PRInt32 amount,\n+                             PRIntervalTime timeout) {\n+  PRInt32 rv = -1;\n \n-    rv = PR_EmulateAcceptRead(sd, nd, raddr, buf, amount, timeout);\n+  if (pt_TestAbort()) {\n     return rv;\n+  }\n+  /* The socket must be in blocking mode. */\n+  if (sd->secret->nonblocking) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return rv;\n+  }\n+\n+  rv = PR_EmulateAcceptRead(sd, nd, raddr, buf, amount, timeout);\n+  return rv;\n } /* pt_AcceptRead */\n \n-static PRStatus\n-pt_GetSockName(PRFileDesc* fd, PRNetAddr* addr)\n-{\n-    PRIntn rv = -1;\n-    pt_SockLen addr_len = sizeof(PRNetAddr);\n+static PRStatus pt_GetSockName(PRFileDesc* fd, PRNetAddr* addr) {\n+  PRIntn rv = -1;\n+  pt_SockLen addr_len = sizeof(PRNetAddr);\n \n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n \n-    rv = getsockname(fd->secret->md.osfd, (struct sockaddr*)addr, &addr_len);\n-    if (rv == -1) {\n-        pt_MapError(_PR_MD_MAP_GETSOCKNAME_ERROR, errno);\n-        return PR_FAILURE;\n-    }\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    /* ignore the sa_len field of struct sockaddr */\n-    if (addr) {\n-        addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n-    }\n-#endif /* _PR_HAVE_SOCKADDR_LEN */\n-#ifdef _PR_INET6\n-    if (AF_INET6 == addr->raw.family) {\n-        addr->raw.family = PR_AF_INET6;\n-    }\n-#endif\n-    PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n-    PR_ASSERT(IsValidNetAddrLen(addr, addr_len) == PR_TRUE);\n-    return PR_SUCCESS;\n+  rv = getsockname(fd->secret->md.osfd, (struct sockaddr*)addr, &addr_len);\n+  if (rv == -1) {\n+    pt_MapError(_PR_MD_MAP_GETSOCKNAME_ERROR, errno);\n+    return PR_FAILURE;\n+  }\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  /* ignore the sa_len field of struct sockaddr */\n+  if (addr) {\n+    addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n+  }\n+#  endif /* _PR_HAVE_SOCKADDR_LEN */\n+#  ifdef _PR_INET6\n+  if (AF_INET6 == addr->raw.family) {\n+    addr->raw.family = PR_AF_INET6;\n+  }\n+#  endif\n+  PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n+  PR_ASSERT(IsValidNetAddrLen(addr, addr_len) == PR_TRUE);\n+  return PR_SUCCESS;\n } /* pt_GetSockName */\n \n-static PRStatus\n-pt_GetPeerName(PRFileDesc* fd, PRNetAddr* addr)\n-{\n-    PRIntn rv = -1;\n-    pt_SockLen addr_len = sizeof(PRNetAddr);\n+static PRStatus pt_GetPeerName(PRFileDesc* fd, PRNetAddr* addr) {\n+  PRIntn rv = -1;\n+  pt_SockLen addr_len = sizeof(PRNetAddr);\n \n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n \n-    rv = getpeername(fd->secret->md.osfd, (struct sockaddr*)addr, &addr_len);\n+  rv = getpeername(fd->secret->md.osfd, (struct sockaddr*)addr, &addr_len);\n \n-    if (rv == -1) {\n-        pt_MapError(_PR_MD_MAP_GETPEERNAME_ERROR, errno);\n-        return PR_FAILURE;\n-    }\n-#ifdef _PR_HAVE_SOCKADDR_LEN\n-    /* ignore the sa_len field of struct sockaddr */\n-    if (addr) {\n-        addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n-    }\n-#endif /* _PR_HAVE_SOCKADDR_LEN */\n-#ifdef _PR_INET6\n-    if (AF_INET6 == addr->raw.family) {\n-        addr->raw.family = PR_AF_INET6;\n-    }\n-#endif\n-    PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n-    PR_ASSERT(IsValidNetAddrLen(addr, addr_len) == PR_TRUE);\n-    return PR_SUCCESS;\n+  if (rv == -1) {\n+    pt_MapError(_PR_MD_MAP_GETPEERNAME_ERROR, errno);\n+    return PR_FAILURE;\n+  }\n+#  ifdef _PR_HAVE_SOCKADDR_LEN\n+  /* ignore the sa_len field of struct sockaddr */\n+  if (addr) {\n+    addr->raw.family = ((struct sockaddr*)addr)->sa_family;\n+  }\n+#  endif /* _PR_HAVE_SOCKADDR_LEN */\n+#  ifdef _PR_INET6\n+  if (AF_INET6 == addr->raw.family) {\n+    addr->raw.family = PR_AF_INET6;\n+  }\n+#  endif\n+  PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);\n+  PR_ASSERT(IsValidNetAddrLen(addr, addr_len) == PR_TRUE);\n+  return PR_SUCCESS;\n } /* pt_GetPeerName */\n \n-static PRStatus\n-pt_GetSocketOption(PRFileDesc* fd, PRSocketOptionData* data)\n-{\n-    PRIntn rv;\n-    pt_SockLen length;\n-    PRInt32 level, name;\n-\n-    /*\n-     * PR_SockOpt_Nonblocking is a special case that does not\n-     * translate to a getsockopt() call\n-     */\n-    if (PR_SockOpt_Nonblocking == data->option) {\n-        data->value.non_blocking = fd->secret->nonblocking;\n-        return PR_SUCCESS;\n+static PRStatus pt_GetSocketOption(PRFileDesc* fd, PRSocketOptionData* data) {\n+  PRIntn rv;\n+  pt_SockLen length;\n+  PRInt32 level, name;\n+\n+  /*\n+   * PR_SockOpt_Nonblocking is a special case that does not\n+   * translate to a getsockopt() call\n+   */\n+  if (PR_SockOpt_Nonblocking == data->option) {\n+    data->value.non_blocking = fd->secret->nonblocking;\n+    return PR_SUCCESS;\n+  }\n+\n+  rv = _PR_MapOptionName(data->option, &level, &name);\n+  if (PR_SUCCESS == rv) {\n+    switch (data->option) {\n+      case PR_SockOpt_Linger: {\n+        struct linger linger;\n+        length = sizeof(linger);\n+        rv = getsockopt(fd->secret->md.osfd, level, name, (char*)&linger,\n+                        &length);\n+        PR_ASSERT((-1 == rv) || (sizeof(linger) == length));\n+        data->value.linger.polarity = (linger.l_onoff) ? PR_TRUE : PR_FALSE;\n+        data->value.linger.linger = PR_SecondsToInterval(linger.l_linger);\n+        break;\n+      }\n+      case PR_SockOpt_Reuseaddr:\n+      case PR_SockOpt_Keepalive:\n+      case PR_SockOpt_NoDelay:\n+      case PR_SockOpt_Broadcast:\n+      case PR_SockOpt_Reuseport: {\n+        PRIntn value;\n+        length = sizeof(PRIntn);\n+        rv = getsockopt(fd->secret->md.osfd, level, name, (char*)&value,\n+                        &length);\n+        PR_ASSERT((-1 == rv) || (sizeof(PRIntn) == length));\n+        data->value.reuse_addr = (0 == value) ? PR_FALSE : PR_TRUE;\n+        break;\n+      }\n+      case PR_SockOpt_McastLoopback: {\n+        PRUint8 xbool;\n+        length = sizeof(xbool);\n+        rv = getsockopt(fd->secret->md.osfd, level, name, (char*)&xbool,\n+                        &length);\n+        PR_ASSERT((-1 == rv) || (sizeof(xbool) == length));\n+        data->value.mcast_loopback = (0 == xbool) ? PR_FALSE : PR_TRUE;\n+        break;\n+      }\n+      case PR_SockOpt_RecvBufferSize:\n+      case PR_SockOpt_SendBufferSize:\n+      case PR_SockOpt_MaxSegment: {\n+        PRIntn value;\n+        length = sizeof(PRIntn);\n+        rv = getsockopt(fd->secret->md.osfd, level, name, (char*)&value,\n+                        &length);\n+        PR_ASSERT((-1 == rv) || (sizeof(PRIntn) == length));\n+        data->value.recv_buffer_size = value;\n+        break;\n+      }\n+      case PR_SockOpt_IpTimeToLive:\n+      case PR_SockOpt_IpTypeOfService: {\n+        length = sizeof(PRUintn);\n+        rv = getsockopt(fd->secret->md.osfd, level, name,\n+                        (char*)&data->value.ip_ttl, &length);\n+        PR_ASSERT((-1 == rv) || (sizeof(PRIntn) == length));\n+        break;\n+      }\n+      case PR_SockOpt_McastTimeToLive: {\n+        PRUint8 ttl;\n+        length = sizeof(ttl);\n+        rv = getsockopt(fd->secret->md.osfd, level, name, (char*)&ttl, &length);\n+        PR_ASSERT((-1 == rv) || (sizeof(ttl) == length));\n+        data->value.mcast_ttl = ttl;\n+        break;\n+      }\n+      case PR_SockOpt_AddMember:\n+      case PR_SockOpt_DropMember: {\n+        struct ip_mreq mreq;\n+        length = sizeof(mreq);\n+        rv =\n+            getsockopt(fd->secret->md.osfd, level, name, (char*)&mreq, &length);\n+        PR_ASSERT((-1 == rv) || (sizeof(mreq) == length));\n+        data->value.add_member.mcaddr.inet.ip = mreq.imr_multiaddr.s_addr;\n+        data->value.add_member.ifaddr.inet.ip = mreq.imr_interface.s_addr;\n+        break;\n+      }\n+      case PR_SockOpt_McastInterface: {\n+        length = sizeof(data->value.mcast_if.inet.ip);\n+        rv = getsockopt(fd->secret->md.osfd, level, name,\n+                        (char*)&data->value.mcast_if.inet.ip, &length);\n+        PR_ASSERT((-1 == rv) ||\n+                  (sizeof(data->value.mcast_if.inet.ip) == length));\n+        break;\n+      }\n+      case PR_SockOpt_DontFrag: {\n+#  if !defined(DARWIN) && !defined(LINUX) && !defined(ANDROID)\n+        PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, 0);\n+        rv = PR_FAILURE;\n+#  else\n+        PRIntn value;\n+        length = sizeof(value);\n+        rv = getsockopt(fd->secret->md.osfd, level, name, (char*)&value,\n+                        &length);\n+#    if defined(DARWIN)\n+        data->value.dont_fragment = value;\n+#    else\n+        data->value.dont_fragment = (value == IP_PMTUDISC_DO) ? 1 : 0;\n+#    endif\n+#  endif /* !(!defined(DARWIN) && !defined(LINUX) && !defined(ANDROID)) */\n+        break;\n+      }\n+      default:\n+        PR_NOT_REACHED(\"Unknown socket option\");\n+        break;\n     }\n-\n-    rv = _PR_MapOptionName(data->option, &level, &name);\n-    if (PR_SUCCESS == rv) {\n-        switch (data->option) {\n-            case PR_SockOpt_Linger: {\n-                struct linger linger;\n-                length = sizeof(linger);\n-                rv = getsockopt(fd->secret->md.osfd, level, name, (char*)&linger,\n-                                &length);\n-                PR_ASSERT((-1 == rv) || (sizeof(linger) == length));\n-                data->value.linger.polarity = (linger.l_onoff) ? PR_TRUE : PR_FALSE;\n-                data->value.linger.linger = PR_SecondsToInterval(linger.l_linger);\n-                break;\n-            }\n-            case PR_SockOpt_Reuseaddr:\n-            case PR_SockOpt_Keepalive:\n-            case PR_SockOpt_NoDelay:\n-            case PR_SockOpt_Broadcast:\n-            case PR_SockOpt_Reuseport: {\n-                PRIntn value;\n-                length = sizeof(PRIntn);\n-                rv = getsockopt(fd->secret->md.osfd, level, name, (char*)&value,\n-                                &length);\n-                PR_ASSERT((-1 == rv) || (sizeof(PRIntn) == length));\n-                data->value.reuse_addr = (0 == value) ? PR_FALSE : PR_TRUE;\n-                break;\n-            }\n-            case PR_SockOpt_McastLoopback: {\n-                PRUint8 xbool;\n-                length = sizeof(xbool);\n-                rv = getsockopt(fd->secret->md.osfd, level, name, (char*)&xbool,\n-                                &length);\n-                PR_ASSERT((-1 == rv) || (sizeof(xbool) == length));\n-                data->value.mcast_loopback = (0 == xbool) ? PR_FALSE : PR_TRUE;\n-                break;\n-            }\n-            case PR_SockOpt_RecvBufferSize:\n-            case PR_SockOpt_SendBufferSize:\n-            case PR_SockOpt_MaxSegment: {\n-                PRIntn value;\n-                length = sizeof(PRIntn);\n-                rv = getsockopt(fd->secret->md.osfd, level, name, (char*)&value,\n-                                &length);\n-                PR_ASSERT((-1 == rv) || (sizeof(PRIntn) == length));\n-                data->value.recv_buffer_size = value;\n-                break;\n-            }\n-            case PR_SockOpt_IpTimeToLive:\n-            case PR_SockOpt_IpTypeOfService: {\n-                length = sizeof(PRUintn);\n-                rv = getsockopt(fd->secret->md.osfd, level, name,\n-                                (char*)&data->value.ip_ttl, &length);\n-                PR_ASSERT((-1 == rv) || (sizeof(PRIntn) == length));\n-                break;\n-            }\n-            case PR_SockOpt_McastTimeToLive: {\n-                PRUint8 ttl;\n-                length = sizeof(ttl);\n-                rv = getsockopt(fd->secret->md.osfd, level, name, (char*)&ttl, &length);\n-                PR_ASSERT((-1 == rv) || (sizeof(ttl) == length));\n-                data->value.mcast_ttl = ttl;\n-                break;\n-            }\n-            case PR_SockOpt_AddMember:\n-            case PR_SockOpt_DropMember: {\n-                struct ip_mreq mreq;\n-                length = sizeof(mreq);\n-                rv =\n-                    getsockopt(fd->secret->md.osfd, level, name, (char*)&mreq, &length);\n-                PR_ASSERT((-1 == rv) || (sizeof(mreq) == length));\n-                data->value.add_member.mcaddr.inet.ip = mreq.imr_multiaddr.s_addr;\n-                data->value.add_member.ifaddr.inet.ip = mreq.imr_interface.s_addr;\n-                break;\n-            }\n-            case PR_SockOpt_McastInterface: {\n-                length = sizeof(data->value.mcast_if.inet.ip);\n-                rv = getsockopt(fd->secret->md.osfd, level, name,\n-                                (char*)&data->value.mcast_if.inet.ip, &length);\n-                PR_ASSERT((-1 == rv) ||\n-                          (sizeof(data->value.mcast_if.inet.ip) == length));\n-                break;\n-            }\n-            case PR_SockOpt_DontFrag: {\n-#if !defined(DARWIN) && !defined(LINUX) && !defined(ANDROID)\n-                PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, 0);\n-                rv = PR_FAILURE;\n-#else\n-                PRIntn value;\n-                length = sizeof(value);\n-                rv = getsockopt(fd->secret->md.osfd, level, name, (char*)&value,\n-                                &length);\n-#if defined(DARWIN)\n-                data->value.dont_fragment = value;\n-#else\n-                data->value.dont_fragment = (value == IP_PMTUDISC_DO) ? 1 : 0;\n-#endif\n-#endif /* !(!defined(DARWIN) && !defined(LINUX) && !defined(ANDROID)) */\n-                break;\n-            }\n-            default:\n-                PR_NOT_REACHED(\"Unknown socket option\");\n-                break;\n-        }\n-        if (-1 == rv) {\n-            _PR_MD_MAP_GETSOCKOPT_ERROR(errno);\n-        }\n+    if (-1 == rv) {\n+      _PR_MD_MAP_GETSOCKOPT_ERROR(errno);\n     }\n-    return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;\n+  }\n+  return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;\n } /* pt_GetSocketOption */\n \n-static PRStatus\n-pt_SetSocketOption(PRFileDesc* fd,\n-                   const PRSocketOptionData* data)\n-{\n-    PRIntn rv;\n-    PRInt32 level, name;\n-\n-    /*\n-     * PR_SockOpt_Nonblocking is a special case that does not\n-     * translate to a setsockopt call.\n-     */\n-    if (PR_SockOpt_Nonblocking == data->option) {\n-        fd->secret->nonblocking = data->value.non_blocking;\n-        return PR_SUCCESS;\n-    }\n-\n-    rv = _PR_MapOptionName(data->option, &level, &name);\n-    if (PR_SUCCESS == rv) {\n-        switch (data->option) {\n-            case PR_SockOpt_Linger: {\n-                struct linger linger;\n-                linger.l_onoff = data->value.linger.polarity;\n-                linger.l_linger = PR_IntervalToSeconds(data->value.linger.linger);\n-                rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&linger,\n-                                sizeof(linger));\n-                break;\n-            }\n-            case PR_SockOpt_Reuseaddr:\n-            case PR_SockOpt_Keepalive:\n-            case PR_SockOpt_NoDelay:\n-            case PR_SockOpt_Broadcast:\n-            case PR_SockOpt_Reuseport: {\n-                PRIntn value = (data->value.reuse_addr) ? 1 : 0;\n-                rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&value,\n-                                sizeof(PRIntn));\n-#ifdef LINUX\n-                /* for pt_LinuxSendFile */\n-                if (name == TCP_NODELAY && rv == 0) {\n-                    fd->secret->md.tcp_nodelay = value;\n-                }\n-#endif\n-                break;\n-            }\n-            case PR_SockOpt_McastLoopback: {\n-                PRUint8 xbool = data->value.mcast_loopback ? 1 : 0;\n-                rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&xbool,\n-                                sizeof(xbool));\n-                break;\n-            }\n-            case PR_SockOpt_RecvBufferSize:\n-            case PR_SockOpt_SendBufferSize:\n-            case PR_SockOpt_MaxSegment: {\n-                PRIntn value = data->value.recv_buffer_size;\n-                rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&value,\n-                                sizeof(PRIntn));\n-                break;\n-            }\n-            case PR_SockOpt_IpTimeToLive:\n-            case PR_SockOpt_IpTypeOfService: {\n-                rv = setsockopt(fd->secret->md.osfd, level, name,\n-                                (char*)&data->value.ip_ttl, sizeof(PRUintn));\n-                break;\n-            }\n-            case PR_SockOpt_McastTimeToLive: {\n-                PRUint8 ttl = data->value.mcast_ttl;\n-                rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&ttl,\n-                                sizeof(ttl));\n-                break;\n-            }\n-            case PR_SockOpt_AddMember:\n-            case PR_SockOpt_DropMember: {\n-                struct ip_mreq mreq;\n-                mreq.imr_multiaddr.s_addr = data->value.add_member.mcaddr.inet.ip;\n-                mreq.imr_interface.s_addr = data->value.add_member.ifaddr.inet.ip;\n-                rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&mreq,\n-                                sizeof(mreq));\n-                break;\n-            }\n-            case PR_SockOpt_McastInterface: {\n-                rv = setsockopt(fd->secret->md.osfd, level, name,\n-                                (char*)&data->value.mcast_if.inet.ip,\n-                                sizeof(data->value.mcast_if.inet.ip));\n-                break;\n-            }\n-            case PR_SockOpt_DontFrag: {\n-#if !defined(DARWIN) && !defined(LINUX) && !defined(ANDROID)\n-                PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, 0);\n-                rv = PR_FAILURE;\n-#else\n-                PRIntn value;\n-#if defined(LINUX) || defined(ANDROID)\n-                value = (data->value.dont_fragment) ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT;\n-#elif defined(DARWIN)\n-                value = data->value.dont_fragment;\n-#endif\n-                rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&value,\n-                                sizeof(value));\n-#endif /* !defined(DARWIN) && !defined(LINUX) && !defined(ANDROID)) */\n-                break;\n-            }\n-            default:\n-                PR_NOT_REACHED(\"Unknown socket option\");\n-                break;\n-        }\n-        if (-1 == rv) {\n-            _PR_MD_MAP_SETSOCKOPT_ERROR(errno);\n+static PRStatus pt_SetSocketOption(PRFileDesc* fd,\n+                                   const PRSocketOptionData* data) {\n+  PRIntn rv;\n+  PRInt32 level, name;\n+\n+  /*\n+   * PR_SockOpt_Nonblocking is a special case that does not\n+   * translate to a setsockopt call.\n+   */\n+  if (PR_SockOpt_Nonblocking == data->option) {\n+    fd->secret->nonblocking = data->value.non_blocking;\n+    return PR_SUCCESS;\n+  }\n+\n+  rv = _PR_MapOptionName(data->option, &level, &name);\n+  if (PR_SUCCESS == rv) {\n+    switch (data->option) {\n+      case PR_SockOpt_Linger: {\n+        struct linger linger;\n+        linger.l_onoff = data->value.linger.polarity;\n+        linger.l_linger = PR_IntervalToSeconds(data->value.linger.linger);\n+        rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&linger,\n+                        sizeof(linger));\n+        break;\n+      }\n+      case PR_SockOpt_Reuseaddr:\n+      case PR_SockOpt_Keepalive:\n+      case PR_SockOpt_NoDelay:\n+      case PR_SockOpt_Broadcast:\n+      case PR_SockOpt_Reuseport: {\n+        PRIntn value = (data->value.reuse_addr) ? 1 : 0;\n+        rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&value,\n+                        sizeof(PRIntn));\n+#  ifdef LINUX\n+        /* for pt_LinuxSendFile */\n+        if (name == TCP_NODELAY && rv == 0) {\n+          fd->secret->md.tcp_nodelay = value;\n         }\n+#  endif\n+        break;\n+      }\n+      case PR_SockOpt_McastLoopback: {\n+        PRUint8 xbool = data->value.mcast_loopback ? 1 : 0;\n+        rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&xbool,\n+                        sizeof(xbool));\n+        break;\n+      }\n+      case PR_SockOpt_RecvBufferSize:\n+      case PR_SockOpt_SendBufferSize:\n+      case PR_SockOpt_MaxSegment: {\n+        PRIntn value = data->value.recv_buffer_size;\n+        rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&value,\n+                        sizeof(PRIntn));\n+        break;\n+      }\n+      case PR_SockOpt_IpTimeToLive:\n+      case PR_SockOpt_IpTypeOfService: {\n+        rv = setsockopt(fd->secret->md.osfd, level, name,\n+                        (char*)&data->value.ip_ttl, sizeof(PRUintn));\n+        break;\n+      }\n+      case PR_SockOpt_McastTimeToLive: {\n+        PRUint8 ttl = data->value.mcast_ttl;\n+        rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&ttl,\n+                        sizeof(ttl));\n+        break;\n+      }\n+      case PR_SockOpt_AddMember:\n+      case PR_SockOpt_DropMember: {\n+        struct ip_mreq mreq;\n+        mreq.imr_multiaddr.s_addr = data->value.add_member.mcaddr.inet.ip;\n+        mreq.imr_interface.s_addr = data->value.add_member.ifaddr.inet.ip;\n+        rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&mreq,\n+                        sizeof(mreq));\n+        break;\n+      }\n+      case PR_SockOpt_McastInterface: {\n+        rv = setsockopt(fd->secret->md.osfd, level, name,\n+                        (char*)&data->value.mcast_if.inet.ip,\n+                        sizeof(data->value.mcast_if.inet.ip));\n+        break;\n+      }\n+      case PR_SockOpt_DontFrag: {\n+#  if !defined(DARWIN) && !defined(LINUX) && !defined(ANDROID)\n+        PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, 0);\n+        rv = PR_FAILURE;\n+#  else\n+        PRIntn value;\n+#    if defined(LINUX) || defined(ANDROID)\n+        value = (data->value.dont_fragment) ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT;\n+#    elif defined(DARWIN)\n+        value = data->value.dont_fragment;\n+#    endif\n+        rv = setsockopt(fd->secret->md.osfd, level, name, (char*)&value,\n+                        sizeof(value));\n+#  endif /* !defined(DARWIN) && !defined(LINUX) && !defined(ANDROID)) */\n+        break;\n+      }\n+      default:\n+        PR_NOT_REACHED(\"Unknown socket option\");\n+        break;\n     }\n-    return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;\n+    if (-1 == rv) {\n+      _PR_MD_MAP_SETSOCKOPT_ERROR(errno);\n+    }\n+  }\n+  return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;\n } /* pt_SetSocketOption */\n \n /*****************************************************************************/\n /****************************** I/O method objects ***************************/\n /*****************************************************************************/\n \n-static PRIOMethods _pr_file_methods = { PR_DESC_FILE,\n-                                        pt_Close,\n-                                        pt_Read,\n-                                        pt_Write,\n-                                        pt_Available_f,\n-                                        pt_Available64_f,\n-                                        pt_Fsync,\n-                                        pt_Seek,\n-                                        pt_Seek64,\n-                                        pt_FileInfo,\n-                                        pt_FileInfo64,\n-                                        (PRWritevFN)_PR_InvalidInt,\n-                                        (PRConnectFN)_PR_InvalidStatus,\n-                                        (PRAcceptFN)_PR_InvalidDesc,\n-                                        (PRBindFN)_PR_InvalidStatus,\n-                                        (PRListenFN)_PR_InvalidStatus,\n-                                        (PRShutdownFN)_PR_InvalidStatus,\n-                                        (PRRecvFN)_PR_InvalidInt,\n-                                        (PRSendFN)_PR_InvalidInt,\n-                                        (PRRecvfromFN)_PR_InvalidInt,\n-                                        (PRSendtoFN)_PR_InvalidInt,\n-                                        pt_Poll,\n-                                        (PRAcceptreadFN)_PR_InvalidInt,\n-                                        (PRTransmitfileFN)_PR_InvalidInt,\n-                                        (PRGetsocknameFN)_PR_InvalidStatus,\n-                                        (PRGetpeernameFN)_PR_InvalidStatus,\n-                                        (PRReservedFN)_PR_InvalidInt,\n-                                        (PRReservedFN)_PR_InvalidInt,\n-                                        (PRGetsocketoptionFN)_PR_InvalidStatus,\n-                                        (PRSetsocketoptionFN)_PR_InvalidStatus,\n-                                        (PRSendfileFN)_PR_InvalidInt,\n-                                        (PRConnectcontinueFN)_PR_InvalidStatus,\n-                                        (PRReservedFN)_PR_InvalidInt,\n-                                        (PRReservedFN)_PR_InvalidInt,\n-                                        (PRReservedFN)_PR_InvalidInt,\n-                                        (PRReservedFN)_PR_InvalidInt };\n-\n-static PRIOMethods _pr_pipe_methods = { PR_DESC_PIPE,\n-                                        pt_Close,\n-                                        pt_Read,\n-                                        pt_Write,\n-                                        pt_Available_s,\n-                                        pt_Available64_s,\n-                                        pt_Synch,\n-                                        (PRSeekFN)_PR_InvalidInt,\n-                                        (PRSeek64FN)_PR_InvalidInt64,\n-                                        (PRFileInfoFN)_PR_InvalidStatus,\n-                                        (PRFileInfo64FN)_PR_InvalidStatus,\n-                                        (PRWritevFN)_PR_InvalidInt,\n-                                        (PRConnectFN)_PR_InvalidStatus,\n-                                        (PRAcceptFN)_PR_InvalidDesc,\n-                                        (PRBindFN)_PR_InvalidStatus,\n-                                        (PRListenFN)_PR_InvalidStatus,\n-                                        (PRShutdownFN)_PR_InvalidStatus,\n-                                        (PRRecvFN)_PR_InvalidInt,\n-                                        (PRSendFN)_PR_InvalidInt,\n-                                        (PRRecvfromFN)_PR_InvalidInt,\n-                                        (PRSendtoFN)_PR_InvalidInt,\n-                                        pt_Poll,\n-                                        (PRAcceptreadFN)_PR_InvalidInt,\n-                                        (PRTransmitfileFN)_PR_InvalidInt,\n-                                        (PRGetsocknameFN)_PR_InvalidStatus,\n-                                        (PRGetpeernameFN)_PR_InvalidStatus,\n-                                        (PRReservedFN)_PR_InvalidInt,\n-                                        (PRReservedFN)_PR_InvalidInt,\n-                                        (PRGetsocketoptionFN)_PR_InvalidStatus,\n-                                        (PRSetsocketoptionFN)_PR_InvalidStatus,\n-                                        (PRSendfileFN)_PR_InvalidInt,\n-                                        (PRConnectcontinueFN)_PR_InvalidStatus,\n-                                        (PRReservedFN)_PR_InvalidInt,\n-                                        (PRReservedFN)_PR_InvalidInt,\n-                                        (PRReservedFN)_PR_InvalidInt,\n-                                        (PRReservedFN)_PR_InvalidInt };\n+static PRIOMethods _pr_file_methods = {PR_DESC_FILE,\n+                                       pt_Close,\n+                                       pt_Read,\n+                                       pt_Write,\n+                                       pt_Available_f,\n+                                       pt_Available64_f,\n+                                       pt_Fsync,\n+                                       pt_Seek,\n+                                       pt_Seek64,\n+                                       pt_FileInfo,\n+                                       pt_FileInfo64,\n+                                       (PRWritevFN)_PR_InvalidInt,\n+                                       (PRConnectFN)_PR_InvalidStatus,\n+                                       (PRAcceptFN)_PR_InvalidDesc,\n+                                       (PRBindFN)_PR_InvalidStatus,\n+                                       (PRListenFN)_PR_InvalidStatus,\n+                                       (PRShutdownFN)_PR_InvalidStatus,\n+                                       (PRRecvFN)_PR_InvalidInt,\n+                                       (PRSendFN)_PR_InvalidInt,\n+                                       (PRRecvfromFN)_PR_InvalidInt,\n+                                       (PRSendtoFN)_PR_InvalidInt,\n+                                       pt_Poll,\n+                                       (PRAcceptreadFN)_PR_InvalidInt,\n+                                       (PRTransmitfileFN)_PR_InvalidInt,\n+                                       (PRGetsocknameFN)_PR_InvalidStatus,\n+                                       (PRGetpeernameFN)_PR_InvalidStatus,\n+                                       (PRReservedFN)_PR_InvalidInt,\n+                                       (PRReservedFN)_PR_InvalidInt,\n+                                       (PRGetsocketoptionFN)_PR_InvalidStatus,\n+                                       (PRSetsocketoptionFN)_PR_InvalidStatus,\n+                                       (PRSendfileFN)_PR_InvalidInt,\n+                                       (PRConnectcontinueFN)_PR_InvalidStatus,\n+                                       (PRReservedFN)_PR_InvalidInt,\n+                                       (PRReservedFN)_PR_InvalidInt,\n+                                       (PRReservedFN)_PR_InvalidInt,\n+                                       (PRReservedFN)_PR_InvalidInt};\n+\n+static PRIOMethods _pr_pipe_methods = {PR_DESC_PIPE,\n+                                       pt_Close,\n+                                       pt_Read,\n+                                       pt_Write,\n+                                       pt_Available_s,\n+                                       pt_Available64_s,\n+                                       pt_Synch,\n+                                       (PRSeekFN)_PR_InvalidInt,\n+                                       (PRSeek64FN)_PR_InvalidInt64,\n+                                       (PRFileInfoFN)_PR_InvalidStatus,\n+                                       (PRFileInfo64FN)_PR_InvalidStatus,\n+                                       (PRWritevFN)_PR_InvalidInt,\n+                                       (PRConnectFN)_PR_InvalidStatus,\n+                                       (PRAcceptFN)_PR_InvalidDesc,\n+                                       (PRBindFN)_PR_InvalidStatus,\n+                                       (PRListenFN)_PR_InvalidStatus,\n+                                       (PRShutdownFN)_PR_InvalidStatus,\n+                                       (PRRecvFN)_PR_InvalidInt,\n+                                       (PRSendFN)_PR_InvalidInt,\n+                                       (PRRecvfromFN)_PR_InvalidInt,\n+                                       (PRSendtoFN)_PR_InvalidInt,\n+                                       pt_Poll,\n+                                       (PRAcceptreadFN)_PR_InvalidInt,\n+                                       (PRTransmitfileFN)_PR_InvalidInt,\n+                                       (PRGetsocknameFN)_PR_InvalidStatus,\n+                                       (PRGetpeernameFN)_PR_InvalidStatus,\n+                                       (PRReservedFN)_PR_InvalidInt,\n+                                       (PRReservedFN)_PR_InvalidInt,\n+                                       (PRGetsocketoptionFN)_PR_InvalidStatus,\n+                                       (PRSetsocketoptionFN)_PR_InvalidStatus,\n+                                       (PRSendfileFN)_PR_InvalidInt,\n+                                       (PRConnectcontinueFN)_PR_InvalidStatus,\n+                                       (PRReservedFN)_PR_InvalidInt,\n+                                       (PRReservedFN)_PR_InvalidInt,\n+                                       (PRReservedFN)_PR_InvalidInt,\n+                                       (PRReservedFN)_PR_InvalidInt};\n \n static PRIOMethods _pr_tcp_methods = {\n     PR_DESC_SOCKET_TCP,\n@@ -3138,12 +3005,12 @@ static PRIOMethods _pr_tcp_methods = {\n     pt_Recv,\n     pt_Send,\n     (PRRecvfromFN)_PR_InvalidInt,\n-#if defined(LINUX) || defined(DARWIN)\n+#  if defined(LINUX) || defined(DARWIN)\n     pt_TCP_SendTo, /* This is for TCP Fast Open. Linux uses SendTo function for\n                       this. OSX uses connectx, but we imitate Linux. */\n-#else\n+#  else\n     (PRSendtoFN)_PR_InvalidInt,\n-#endif\n+#  endif\n     pt_Poll,\n     pt_AcceptRead,\n     pt_TransmitFile,\n@@ -3158,45 +3025,44 @@ static PRIOMethods _pr_tcp_methods = {\n     (PRReservedFN)_PR_InvalidInt,\n     (PRReservedFN)_PR_InvalidInt,\n     (PRReservedFN)_PR_InvalidInt,\n-    (PRReservedFN)_PR_InvalidInt\n-};\n-\n-static PRIOMethods _pr_udp_methods = { PR_DESC_SOCKET_UDP,\n-                                       pt_Close,\n-                                       pt_SocketRead,\n-                                       pt_SocketWrite,\n-                                       pt_Available_s,\n-                                       pt_Available64_s,\n-                                       pt_Synch,\n-                                       (PRSeekFN)_PR_InvalidInt,\n-                                       (PRSeek64FN)_PR_InvalidInt64,\n-                                       (PRFileInfoFN)_PR_InvalidStatus,\n-                                       (PRFileInfo64FN)_PR_InvalidStatus,\n-                                       pt_Writev,\n-                                       pt_Connect,\n-                                       (PRAcceptFN)_PR_InvalidDesc,\n-                                       pt_Bind,\n-                                       pt_Listen,\n-                                       pt_Shutdown,\n-                                       pt_Recv,\n-                                       pt_Send,\n-                                       pt_RecvFrom,\n-                                       pt_SendTo,\n-                                       pt_Poll,\n-                                       (PRAcceptreadFN)_PR_InvalidInt,\n-                                       (PRTransmitfileFN)_PR_InvalidInt,\n-                                       pt_GetSockName,\n-                                       pt_GetPeerName,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       pt_GetSocketOption,\n-                                       pt_SetSocketOption,\n-                                       (PRSendfileFN)_PR_InvalidInt,\n-                                       (PRConnectcontinueFN)_PR_InvalidStatus,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRReservedFN)_PR_InvalidInt,\n-                                       (PRReservedFN)_PR_InvalidInt };\n+    (PRReservedFN)_PR_InvalidInt};\n+\n+static PRIOMethods _pr_udp_methods = {PR_DESC_SOCKET_UDP,\n+                                      pt_Close,\n+                                      pt_SocketRead,\n+                                      pt_SocketWrite,\n+                                      pt_Available_s,\n+                                      pt_Available64_s,\n+                                      pt_Synch,\n+                                      (PRSeekFN)_PR_InvalidInt,\n+                                      (PRSeek64FN)_PR_InvalidInt64,\n+                                      (PRFileInfoFN)_PR_InvalidStatus,\n+                                      (PRFileInfo64FN)_PR_InvalidStatus,\n+                                      pt_Writev,\n+                                      pt_Connect,\n+                                      (PRAcceptFN)_PR_InvalidDesc,\n+                                      pt_Bind,\n+                                      pt_Listen,\n+                                      pt_Shutdown,\n+                                      pt_Recv,\n+                                      pt_Send,\n+                                      pt_RecvFrom,\n+                                      pt_SendTo,\n+                                      pt_Poll,\n+                                      (PRAcceptreadFN)_PR_InvalidInt,\n+                                      (PRTransmitfileFN)_PR_InvalidInt,\n+                                      pt_GetSockName,\n+                                      pt_GetPeerName,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      pt_GetSocketOption,\n+                                      pt_SetSocketOption,\n+                                      (PRSendfileFN)_PR_InvalidInt,\n+                                      (PRConnectcontinueFN)_PR_InvalidStatus,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRReservedFN)_PR_InvalidInt,\n+                                      (PRReservedFN)_PR_InvalidInt};\n \n static PRIOMethods _pr_socketpollfd_methods = {\n     (PRDescType)0,\n@@ -3234,28 +3100,25 @@ static PRIOMethods _pr_socketpollfd_methods = {\n     (PRReservedFN)_PR_InvalidInt,\n     (PRReservedFN)_PR_InvalidInt,\n     (PRReservedFN)_PR_InvalidInt,\n-    (PRReservedFN)_PR_InvalidInt\n-};\n+    (PRReservedFN)_PR_InvalidInt};\n \n-#if defined(SOLARIS) || defined(LINUX) || defined(__GNU__) || \\\n-    defined(__GLIBC__) || defined(AIX) || defined(FREEBSD) || \\\n-    defined(NETBSD) || defined(OPENBSD) || defined(NTO) ||    \\\n-    defined(DARWIN) || defined(RISCOS)\n-#define _PR_FCNTL_FLAGS O_NONBLOCK\n-#else\n-#error \"Can't determine architecture\"\n-#endif\n+#  if defined(SOLARIS) || defined(LINUX) ||     \\\n+      defined(__GNU__) || defined(__GLIBC__) || defined(AIX) ||  \\\n+      defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) || \\\n+      defined(NTO) || defined(DARWIN) || defined(RISCOS)\n+#    define _PR_FCNTL_FLAGS O_NONBLOCK\n+#  else\n+#    error \"Can't determine architecture\"\n+#  endif\n \n /*\n  * Put a Unix file descriptor in non-blocking mode.\n  */\n-static void\n-pt_MakeFdNonblock(PRIntn osfd)\n-{\n-    PRIntn flags;\n-    flags = fcntl(osfd, F_GETFL, 0);\n-    flags |= _PR_FCNTL_FLAGS;\n-    (void)fcntl(osfd, F_SETFL, flags);\n+static void pt_MakeFdNonblock(PRIntn osfd) {\n+  PRIntn flags;\n+  flags = fcntl(osfd, F_GETFL, 0);\n+  flags |= _PR_FCNTL_FLAGS;\n+  (void)fcntl(osfd, F_SETFL, flags);\n }\n \n /*\n@@ -3272,258 +3135,241 @@ pt_MakeFdNonblock(PRIntn osfd)\n  * Other platforms just use the generic pt_MakeFdNonblock\n  * to put a socket in non-blocking mode.\n  */\n-#define pt_MakeSocketNonblock pt_MakeFdNonblock\n+#    define pt_MakeSocketNonblock pt_MakeFdNonblock\n \n-static PRFileDesc*\n-pt_SetMethods(PRIntn osfd, PRDescType type,\n-              PRBool isAcceptedSocket, PRBool imported)\n-{\n-    PRFileDesc* fd = _PR_Getfd();\n+static PRFileDesc* pt_SetMethods(PRIntn osfd, PRDescType type,\n+                                 PRBool isAcceptedSocket, PRBool imported) {\n+  PRFileDesc* fd = _PR_Getfd();\n \n-    if (fd == NULL) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  if (fd == NULL) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  } else {\n+    fd->secret->md.osfd = osfd;\n+    fd->secret->state = _PR_FILEDESC_OPEN;\n+    if (imported) {\n+      fd->secret->inheritable = _PR_TRI_UNKNOWN;\n     } else {\n-        fd->secret->md.osfd = osfd;\n-        fd->secret->state = _PR_FILEDESC_OPEN;\n-        if (imported) {\n-            fd->secret->inheritable = _PR_TRI_UNKNOWN;\n-        } else {\n-            /* By default, a Unix fd is not closed on exec. */\n-#ifdef DEBUG\n-            PRIntn flags;\n-            flags = fcntl(osfd, F_GETFD, 0);\n-            PR_ASSERT(0 == flags);\n-#endif\n-            fd->secret->inheritable = _PR_TRI_TRUE;\n-        }\n-        switch (type) {\n-            case PR_DESC_FILE:\n-                fd->methods = PR_GetFileMethods();\n-                break;\n-            case PR_DESC_SOCKET_TCP:\n-                fd->methods = PR_GetTCPMethods();\n-#ifdef _PR_ACCEPT_INHERIT_NONBLOCK\n-                if (!isAcceptedSocket) {\n-                    pt_MakeSocketNonblock(osfd);\n-                }\n-#else\n-                pt_MakeSocketNonblock(osfd);\n-#endif\n-                break;\n-            case PR_DESC_SOCKET_UDP:\n-                fd->methods = PR_GetUDPMethods();\n-                pt_MakeFdNonblock(osfd);\n-                break;\n-            case PR_DESC_PIPE:\n-                fd->methods = PR_GetPipeMethods();\n-                pt_MakeFdNonblock(osfd);\n-                break;\n-            default:\n-                break;\n+      /* By default, a Unix fd is not closed on exec. */\n+#  ifdef DEBUG\n+      PRIntn flags;\n+      flags = fcntl(osfd, F_GETFD, 0);\n+      PR_ASSERT(0 == flags);\n+#  endif\n+      fd->secret->inheritable = _PR_TRI_TRUE;\n+    }\n+    switch (type) {\n+      case PR_DESC_FILE:\n+        fd->methods = PR_GetFileMethods();\n+        break;\n+      case PR_DESC_SOCKET_TCP:\n+        fd->methods = PR_GetTCPMethods();\n+#  ifdef _PR_ACCEPT_INHERIT_NONBLOCK\n+        if (!isAcceptedSocket) {\n+          pt_MakeSocketNonblock(osfd);\n         }\n+#  else\n+        pt_MakeSocketNonblock(osfd);\n+#  endif\n+        break;\n+      case PR_DESC_SOCKET_UDP:\n+        fd->methods = PR_GetUDPMethods();\n+        pt_MakeFdNonblock(osfd);\n+        break;\n+      case PR_DESC_PIPE:\n+        fd->methods = PR_GetPipeMethods();\n+        pt_MakeFdNonblock(osfd);\n+        break;\n+      default:\n+        break;\n     }\n-    return fd;\n+  }\n+  return fd;\n } /* pt_SetMethods */\n \n-PR_IMPLEMENT(const PRIOMethods*)\n-PR_GetFileMethods(void)\n-{\n-    return &_pr_file_methods;\n+PR_IMPLEMENT(const PRIOMethods*) PR_GetFileMethods(void) {\n+  return &_pr_file_methods;\n } /* PR_GetFileMethods */\n \n-PR_IMPLEMENT(const PRIOMethods*)\n-PR_GetPipeMethods(void)\n-{\n-    return &_pr_pipe_methods;\n+PR_IMPLEMENT(const PRIOMethods*) PR_GetPipeMethods(void) {\n+  return &_pr_pipe_methods;\n } /* PR_GetPipeMethods */\n \n-PR_IMPLEMENT(const PRIOMethods*)\n-PR_GetTCPMethods(void)\n-{\n-    return &_pr_tcp_methods;\n+PR_IMPLEMENT(const PRIOMethods*) PR_GetTCPMethods(void) {\n+  return &_pr_tcp_methods;\n } /* PR_GetTCPMethods */\n \n-PR_IMPLEMENT(const PRIOMethods*)\n-PR_GetUDPMethods(void)\n-{\n-    return &_pr_udp_methods;\n+PR_IMPLEMENT(const PRIOMethods*) PR_GetUDPMethods(void) {\n+  return &_pr_udp_methods;\n } /* PR_GetUDPMethods */\n \n-static const PRIOMethods*\n-PR_GetSocketPollFdMethods(void)\n-{\n-    return &_pr_socketpollfd_methods;\n+static const PRIOMethods* PR_GetSocketPollFdMethods(void) {\n+  return &_pr_socketpollfd_methods;\n } /* PR_GetSocketPollFdMethods */\n \n PR_IMPLEMENT(PRFileDesc*)\n-PR_AllocFileDesc(PRInt32 osfd, const PRIOMethods* methods)\n-{\n-    PRFileDesc* fd = _PR_Getfd();\n-\n-    if (NULL == fd) {\n-        goto failed;\n-    }\n-\n-    fd->methods = methods;\n-    fd->secret->md.osfd = osfd;\n-    /* Make fd non-blocking */\n-    if (osfd > 2) {\n-        /* Don't mess around with stdin, stdout or stderr */\n-        if (&_pr_tcp_methods == methods) {\n-            pt_MakeSocketNonblock(osfd);\n-        } else {\n-            pt_MakeFdNonblock(osfd);\n-        }\n+PR_AllocFileDesc(PRInt32 osfd, const PRIOMethods* methods) {\n+  PRFileDesc* fd = _PR_Getfd();\n+\n+  if (NULL == fd) {\n+    goto failed;\n+  }\n+\n+  fd->methods = methods;\n+  fd->secret->md.osfd = osfd;\n+  /* Make fd non-blocking */\n+  if (osfd > 2) {\n+    /* Don't mess around with stdin, stdout or stderr */\n+    if (&_pr_tcp_methods == methods) {\n+      pt_MakeSocketNonblock(osfd);\n+    } else {\n+      pt_MakeFdNonblock(osfd);\n     }\n-    fd->secret->state = _PR_FILEDESC_OPEN;\n-    fd->secret->inheritable = _PR_TRI_UNKNOWN;\n-    return fd;\n+  }\n+  fd->secret->state = _PR_FILEDESC_OPEN;\n+  fd->secret->inheritable = _PR_TRI_UNKNOWN;\n+  return fd;\n \n failed:\n-    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-    return fd;\n+  PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  return fd;\n } /* PR_AllocFileDesc */\n \n-#if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)\n-PR_EXTERN(PRStatus)\n-_pr_push_ipv6toipv4_layer(PRFileDesc* fd);\n-#if defined(_PR_INET6_PROBE)\n+#  if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)\n+PR_EXTERN(PRStatus) _pr_push_ipv6toipv4_layer(PRFileDesc* fd);\n+#    if defined(_PR_INET6_PROBE)\n extern PRBool _pr_ipv6_is_present(void);\n-PR_IMPLEMENT(PRBool)\n-_pr_test_ipv6_socket()\n-{\n-    int osfd;\n-\n-#if defined(DARWIN)\n-    /*\n-     * Disable IPv6 if Darwin version is less than 7.0.0 (OS X 10.3).  IPv6 on\n-     * lesser versions is not ready for general use (see bug 222031).\n-     */\n-    {\n-        struct utsname u;\n-        if (uname(&u) != 0 || atoi(u.release) < 7) {\n-            return PR_FALSE;\n-        }\n-    }\n-#endif\n-\n-    /*\n-     * HP-UX only: HP-UX IPv6 Porting Guide (dated February 2001)\n-     * suggests that we call open(\"/dev/ip6\", O_RDWR) to determine\n-     * whether IPv6 APIs and the IPv6 stack are on the system.\n-     * Our portable test below seems to work fine, so I am using it.\n-     */\n-    osfd = socket(AF_INET6, SOCK_STREAM, 0);\n-    if (osfd != -1) {\n-        close(osfd);\n-        return PR_TRUE;\n-    }\n-    return PR_FALSE;\n+PR_IMPLEMENT(PRBool) _pr_test_ipv6_socket() {\n+  int osfd;\n+\n+#      if defined(DARWIN)\n+  /*\n+   * Disable IPv6 if Darwin version is less than 7.0.0 (OS X 10.3).  IPv6 on\n+   * lesser versions is not ready for general use (see bug 222031).\n+   */\n+  {\n+    struct utsname u;\n+    if (uname(&u) != 0 || atoi(u.release) < 7) {\n+      return PR_FALSE;\n+    }\n+  }\n+#      endif\n+\n+  /*\n+   * HP-UX only: HP-UX IPv6 Porting Guide (dated February 2001)\n+   * suggests that we call open(\"/dev/ip6\", O_RDWR) to determine\n+   * whether IPv6 APIs and the IPv6 stack are on the system.\n+   * Our portable test below seems to work fine, so I am using it.\n+   */\n+  osfd = socket(AF_INET6, SOCK_STREAM, 0);\n+  if (osfd != -1) {\n+    close(osfd);\n+    return PR_TRUE;\n+  }\n+  return PR_FALSE;\n }\n-#endif /* _PR_INET6_PROBE */\n-#endif\n+#    endif /* _PR_INET6_PROBE */\n+#  endif\n \n PR_IMPLEMENT(PRFileDesc*)\n-PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto)\n-{\n-    PRIntn osfd;\n-    PRDescType ftype;\n-    PRFileDesc* fd = NULL;\n-#if defined(_PR_INET6_PROBE) || !defined(_PR_INET6)\n-    PRInt32 tmp_domain = domain;\n-#endif\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    if (pt_TestAbort()) {\n-        return NULL;\n-    }\n-\n-    if (PF_INET != domain && PR_AF_INET6 != domain\n-#if defined(_PR_HAVE_SDP)\n-        && PR_AF_INET_SDP != domain\n-#if defined(SOLARIS)\n-        && PR_AF_INET6_SDP != domain\n-#endif /* SOLARIS */\n-#endif /* _PR_HAVE_SDP */\n-        && PF_UNIX != domain) {\n-        PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);\n-        return fd;\n-    }\n-    if (type == SOCK_STREAM) {\n-        ftype = PR_DESC_SOCKET_TCP;\n-    } else if (type == SOCK_DGRAM) {\n-        ftype = PR_DESC_SOCKET_UDP;\n-    } else {\n-        (void)PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);\n-        return fd;\n-    }\n-#if defined(_PR_HAVE_SDP)\n-#if defined(LINUX)\n-    if (PR_AF_INET_SDP == domain) {\n-        domain = AF_INET_SDP;\n-    }\n-#elif defined(SOLARIS)\n-    if (PR_AF_INET_SDP == domain) {\n-        domain = AF_INET;\n-        proto = PROTO_SDP;\n-    } else if (PR_AF_INET6_SDP == domain) {\n-        domain = AF_INET6;\n-        proto = PROTO_SDP;\n-    }\n-#endif /* SOLARIS */\n-#endif /* _PR_HAVE_SDP */\n-#if defined(_PR_INET6_PROBE)\n-    if (PR_AF_INET6 == domain) {\n-        domain = _pr_ipv6_is_present() ? AF_INET6 : AF_INET;\n-    }\n-#elif defined(_PR_INET6)\n-    if (PR_AF_INET6 == domain) {\n-        domain = AF_INET6;\n-    }\n-#else\n-    if (PR_AF_INET6 == domain) {\n-        domain = AF_INET;\n-    }\n-#endif\n-\n-    osfd = socket(domain, type, proto);\n-    if (osfd == -1) {\n-        pt_MapError(_PR_MD_MAP_SOCKET_ERROR, errno);\n-    } else {\n-#ifdef _PR_IPV6_V6ONLY_PROBE\n-        if ((domain == AF_INET6) && _pr_ipv6_v6only_on_by_default) {\n-            int on = 0;\n-            (void)setsockopt(osfd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));\n-        }\n-#endif\n-        fd = pt_SetMethods(osfd, ftype, PR_FALSE, PR_FALSE);\n-        if (fd == NULL) {\n-            close(osfd);\n-        }\n-    }\n-#ifdef _PR_NEED_SECRET_AF\n-    if (fd != NULL) {\n-        fd->secret->af = domain;\n-    }\n-#endif\n-#if defined(_PR_INET6_PROBE) || !defined(_PR_INET6)\n-    if (fd != NULL) {\n-        /*\n-         * For platforms with no support for IPv6\n-         * create layered socket for IPv4-mapped IPv6 addresses\n-         */\n-        if (PR_AF_INET6 == tmp_domain && PR_AF_INET == domain) {\n-            if (PR_FAILURE == _pr_push_ipv6toipv4_layer(fd)) {\n-                PR_Close(fd);\n-                fd = NULL;\n-            }\n-        }\n-    }\n-#endif\n+PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto) {\n+  PRIntn osfd;\n+  PRDescType ftype;\n+  PRFileDesc* fd = NULL;\n+#  if defined(_PR_INET6_PROBE) || !defined(_PR_INET6)\n+  PRInt32 tmp_domain = domain;\n+#  endif\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  if (pt_TestAbort()) {\n+    return NULL;\n+  }\n+\n+  if (PF_INET != domain && PR_AF_INET6 != domain\n+#  if defined(_PR_HAVE_SDP)\n+      && PR_AF_INET_SDP != domain\n+#    if defined(SOLARIS)\n+      && PR_AF_INET6_SDP != domain\n+#    endif /* SOLARIS */\n+#  endif   /* _PR_HAVE_SDP */\n+      && PF_UNIX != domain) {\n+    PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);\n     return fd;\n+  }\n+  if (type == SOCK_STREAM) {\n+    ftype = PR_DESC_SOCKET_TCP;\n+  } else if (type == SOCK_DGRAM) {\n+    ftype = PR_DESC_SOCKET_UDP;\n+  } else {\n+    (void)PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);\n+    return fd;\n+  }\n+#  if defined(_PR_HAVE_SDP)\n+#    if defined(LINUX)\n+  if (PR_AF_INET_SDP == domain) {\n+    domain = AF_INET_SDP;\n+  }\n+#    elif defined(SOLARIS)\n+  if (PR_AF_INET_SDP == domain) {\n+    domain = AF_INET;\n+    proto = PROTO_SDP;\n+  } else if (PR_AF_INET6_SDP == domain) {\n+    domain = AF_INET6;\n+    proto = PROTO_SDP;\n+  }\n+#    endif /* SOLARIS */\n+#  endif   /* _PR_HAVE_SDP */\n+#  if defined(_PR_INET6_PROBE)\n+  if (PR_AF_INET6 == domain) {\n+    domain = _pr_ipv6_is_present() ? AF_INET6 : AF_INET;\n+  }\n+#  elif defined(_PR_INET6)\n+  if (PR_AF_INET6 == domain) {\n+    domain = AF_INET6;\n+  }\n+#  else\n+  if (PR_AF_INET6 == domain) {\n+    domain = AF_INET;\n+  }\n+#  endif\n+\n+  osfd = socket(domain, type, proto);\n+  if (osfd == -1) {\n+    pt_MapError(_PR_MD_MAP_SOCKET_ERROR, errno);\n+  } else {\n+#  ifdef _PR_IPV6_V6ONLY_PROBE\n+    if ((domain == AF_INET6) && _pr_ipv6_v6only_on_by_default) {\n+      int on = 0;\n+      (void)setsockopt(osfd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));\n+    }\n+#  endif\n+    fd = pt_SetMethods(osfd, ftype, PR_FALSE, PR_FALSE);\n+    if (fd == NULL) {\n+      close(osfd);\n+    }\n+  }\n+#  ifdef _PR_NEED_SECRET_AF\n+  if (fd != NULL) {\n+    fd->secret->af = domain;\n+  }\n+#  endif\n+#  if defined(_PR_INET6_PROBE) || !defined(_PR_INET6)\n+  if (fd != NULL) {\n+    /*\n+     * For platforms with no support for IPv6\n+     * create layered socket for IPv4-mapped IPv6 addresses\n+     */\n+    if (PR_AF_INET6 == tmp_domain && PR_AF_INET == domain) {\n+      if (PR_FAILURE == _pr_push_ipv6toipv4_layer(fd)) {\n+        PR_Close(fd);\n+        fd = NULL;\n+      }\n+    }\n+  }\n+#  endif\n+  return fd;\n } /* PR_Socket */\n \n /*****************************************************************************/\n@@ -3531,829 +3377,768 @@ PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto)\n /*****************************************************************************/\n \n PR_IMPLEMENT(PRFileDesc*)\n-PR_OpenFile(const char* name, PRIntn flags, PRIntn mode)\n-{\n-    PRFileDesc* fd = NULL;\n-    PRIntn syserrno, osfd = -1, osflags = 0;\n-    ;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    if (pt_TestAbort()) {\n-        return NULL;\n-    }\n+PR_OpenFile(const char* name, PRIntn flags, PRIntn mode) {\n+  PRFileDesc* fd = NULL;\n+  PRIntn syserrno, osfd = -1, osflags = 0;\n+  ;\n \n-    if (flags & PR_RDONLY) {\n-        osflags |= O_RDONLY;\n-    }\n-    if (flags & PR_WRONLY) {\n-        osflags |= O_WRONLY;\n-    }\n-    if (flags & PR_RDWR) {\n-        osflags |= O_RDWR;\n-    }\n-    if (flags & PR_APPEND) {\n-        osflags |= O_APPEND;\n-    }\n-    if (flags & PR_TRUNCATE) {\n-        osflags |= O_TRUNC;\n-    }\n-    if (flags & PR_EXCL) {\n-        osflags |= O_EXCL;\n-    }\n-    if (flags & PR_SYNC) {\n-#if defined(O_SYNC)\n-        osflags |= O_SYNC;\n-#elif defined(O_FSYNC)\n-        osflags |= O_FSYNC;\n-#else\n-#error \"Neither O_SYNC nor O_FSYNC is defined on this platform\"\n-#endif\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    /*\n-    ** We have to hold the lock across the creation in order to\n-    ** enforce the sematics of PR_Rename(). (see the latter for\n-    ** more details)\n-    */\n-    if (flags & PR_CREATE_FILE) {\n-        osflags |= O_CREAT;\n-        if (NULL != _pr_rename_lock) {\n-            PR_Lock(_pr_rename_lock);\n-        }\n+  if (pt_TestAbort()) {\n+    return NULL;\n+  }\n+\n+  if (flags & PR_RDONLY) {\n+    osflags |= O_RDONLY;\n+  }\n+  if (flags & PR_WRONLY) {\n+    osflags |= O_WRONLY;\n+  }\n+  if (flags & PR_RDWR) {\n+    osflags |= O_RDWR;\n+  }\n+  if (flags & PR_APPEND) {\n+    osflags |= O_APPEND;\n+  }\n+  if (flags & PR_TRUNCATE) {\n+    osflags |= O_TRUNC;\n+  }\n+  if (flags & PR_EXCL) {\n+    osflags |= O_EXCL;\n+  }\n+  if (flags & PR_SYNC) {\n+#  if defined(O_SYNC)\n+    osflags |= O_SYNC;\n+#  elif defined(O_FSYNC)\n+    osflags |= O_FSYNC;\n+#  else\n+#    error \"Neither O_SYNC nor O_FSYNC is defined on this platform\"\n+#  endif\n+  }\n+\n+  /*\n+  ** We have to hold the lock across the creation in order to\n+  ** enforce the sematics of PR_Rename(). (see the latter for\n+  ** more details)\n+  */\n+  if (flags & PR_CREATE_FILE) {\n+    osflags |= O_CREAT;\n+    if (NULL != _pr_rename_lock) {\n+      PR_Lock(_pr_rename_lock);\n     }\n+  }\n \n-    osfd = _md_iovector._open64(name, osflags, mode);\n-    syserrno = errno;\n+  osfd = _md_iovector._open64(name, osflags, mode);\n+  syserrno = errno;\n \n-    if ((flags & PR_CREATE_FILE) && (NULL != _pr_rename_lock)) {\n-        PR_Unlock(_pr_rename_lock);\n-    }\n+  if ((flags & PR_CREATE_FILE) && (NULL != _pr_rename_lock)) {\n+    PR_Unlock(_pr_rename_lock);\n+  }\n \n-    if (osfd == -1) {\n-        pt_MapError(_PR_MD_MAP_OPEN_ERROR, syserrno);\n-    } else {\n-        fd = pt_SetMethods(osfd, PR_DESC_FILE, PR_FALSE, PR_FALSE);\n-        if (fd == NULL) {\n-            close(osfd); /* $$$ whoops! this is bad $$$ */\n-        }\n+  if (osfd == -1) {\n+    pt_MapError(_PR_MD_MAP_OPEN_ERROR, syserrno);\n+  } else {\n+    fd = pt_SetMethods(osfd, PR_DESC_FILE, PR_FALSE, PR_FALSE);\n+    if (fd == NULL) {\n+      close(osfd); /* $$$ whoops! this is bad $$$ */\n     }\n-    return fd;\n+  }\n+  return fd;\n } /* PR_OpenFile */\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_Open(const char* name, PRIntn flags, PRIntn mode)\n-{\n-    return PR_OpenFile(name, flags, mode);\n+PR_IMPLEMENT(PRFileDesc*) PR_Open(const char* name, PRIntn flags, PRIntn mode) {\n+  return PR_OpenFile(name, flags, mode);\n } /* PR_Open */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Delete(const char* name)\n-{\n-    PRIntn rv = -1;\n+PR_IMPLEMENT(PRStatus) PR_Delete(const char* name) {\n+  PRIntn rv = -1;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n \n-    rv = unlink(name);\n+  rv = unlink(name);\n \n-    if (rv == -1) {\n-        pt_MapError(_PR_MD_MAP_UNLINK_ERROR, errno);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  if (rv == -1) {\n+    pt_MapError(_PR_MD_MAP_UNLINK_ERROR, errno);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n } /* PR_Delete */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Access(const char* name, PRAccessHow how)\n-{\n-    PRIntn rv;\n-\n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+PR_IMPLEMENT(PRStatus) PR_Access(const char* name, PRAccessHow how) {\n+  PRIntn rv;\n \n-    switch (how) {\n-        case PR_ACCESS_READ_OK:\n-            rv = access(name, R_OK);\n-            break;\n-        case PR_ACCESS_WRITE_OK:\n-            rv = access(name, W_OK);\n-            break;\n-        case PR_ACCESS_EXISTS:\n-        default:\n-            rv = access(name, F_OK);\n-    }\n-    if (0 == rv) {\n-        return PR_SUCCESS;\n-    }\n-    pt_MapError(_PR_MD_MAP_ACCESS_ERROR, errno);\n+  if (pt_TestAbort()) {\n     return PR_FAILURE;\n+  }\n+\n+  switch (how) {\n+    case PR_ACCESS_READ_OK:\n+      rv = access(name, R_OK);\n+      break;\n+    case PR_ACCESS_WRITE_OK:\n+      rv = access(name, W_OK);\n+      break;\n+    case PR_ACCESS_EXISTS:\n+    default:\n+      rv = access(name, F_OK);\n+  }\n+  if (0 == rv) {\n+    return PR_SUCCESS;\n+  }\n+  pt_MapError(_PR_MD_MAP_ACCESS_ERROR, errno);\n+  return PR_FAILURE;\n \n } /* PR_Access */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_GetFileInfo(const char* fn, PRFileInfo* info)\n-{\n-    PRInt32 rv = _PR_MD_GETFILEINFO(fn, info);\n-    return (0 == rv) ? PR_SUCCESS : PR_FAILURE;\n+PR_IMPLEMENT(PRStatus) PR_GetFileInfo(const char* fn, PRFileInfo* info) {\n+  PRInt32 rv = _PR_MD_GETFILEINFO(fn, info);\n+  return (0 == rv) ? PR_SUCCESS : PR_FAILURE;\n } /* PR_GetFileInfo */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_GetFileInfo64(const char* fn, PRFileInfo64* info)\n-{\n-    PRInt32 rv;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    rv = _PR_MD_GETFILEINFO64(fn, info);\n-    return (0 == rv) ? PR_SUCCESS : PR_FAILURE;\n-} /* PR_GetFileInfo64 */\n-\n-PR_IMPLEMENT(PRStatus)\n-PR_Rename(const char* from, const char* to)\n-{\n-    PRIntn rv = -1;\n+PR_IMPLEMENT(PRStatus) PR_GetFileInfo64(const char* fn, PRFileInfo64* info) {\n+  PRInt32 rv;\n \n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  rv = _PR_MD_GETFILEINFO64(fn, info);\n+  return (0 == rv) ? PR_SUCCESS : PR_FAILURE;\n+} /* PR_GetFileInfo64 */\n \n-    /*\n-    ** We have to acquire a lock here to stiffle anybody trying to create\n-    ** a new file at the same time. And we have to hold that lock while we\n-    ** test to see if the file exists and do the rename. The other place\n-    ** where the lock is held is in PR_Open() when possibly creating a\n-    ** new file.\n-    */\n+PR_IMPLEMENT(PRStatus) PR_Rename(const char* from, const char* to) {\n+  PRIntn rv = -1;\n \n-    PR_Lock(_pr_rename_lock);\n-    rv = access(to, F_OK);\n-    if (0 == rv) {\n-        PR_SetError(PR_FILE_EXISTS_ERROR, 0);\n-        rv = -1;\n-    } else {\n-        rv = rename(from, to);\n-        if (rv == -1) {\n-            pt_MapError(_PR_MD_MAP_RENAME_ERROR, errno);\n-        }\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n+\n+  /*\n+  ** We have to acquire a lock here to stiffle anybody trying to create\n+  ** a new file at the same time. And we have to hold that lock while we\n+  ** test to see if the file exists and do the rename. The other place\n+  ** where the lock is held is in PR_Open() when possibly creating a\n+  ** new file.\n+  */\n+\n+  PR_Lock(_pr_rename_lock);\n+  rv = access(to, F_OK);\n+  if (0 == rv) {\n+    PR_SetError(PR_FILE_EXISTS_ERROR, 0);\n+    rv = -1;\n+  } else {\n+    rv = rename(from, to);\n+    if (rv == -1) {\n+      pt_MapError(_PR_MD_MAP_RENAME_ERROR, errno);\n     }\n-    PR_Unlock(_pr_rename_lock);\n-    return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;\n+  }\n+  PR_Unlock(_pr_rename_lock);\n+  return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;\n } /* PR_Rename */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CloseDir(PRDir* dir)\n-{\n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+PR_IMPLEMENT(PRStatus) PR_CloseDir(PRDir* dir) {\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n \n-    if (NULL != dir->md.d) {\n-        if (closedir(dir->md.d) == -1) {\n-            _PR_MD_MAP_CLOSEDIR_ERROR(errno);\n-            return PR_FAILURE;\n-        }\n-        dir->md.d = NULL;\n-        PR_DELETE(dir);\n+  if (NULL != dir->md.d) {\n+    if (closedir(dir->md.d) == -1) {\n+      _PR_MD_MAP_CLOSEDIR_ERROR(errno);\n+      return PR_FAILURE;\n     }\n-    return PR_SUCCESS;\n+    dir->md.d = NULL;\n+    PR_DELETE(dir);\n+  }\n+  return PR_SUCCESS;\n } /* PR_CloseDir */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_MakeDir(const char* name, PRIntn mode)\n-{\n-    PRInt32 rv = -1;\n+PR_IMPLEMENT(PRStatus) PR_MakeDir(const char* name, PRIntn mode) {\n+  PRInt32 rv = -1;\n \n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n \n-    /*\n-    ** This lock is used to enforce rename semantics as described\n-    ** in PR_Rename.\n-    */\n-    if (NULL != _pr_rename_lock) {\n-        PR_Lock(_pr_rename_lock);\n-    }\n-    rv = mkdir(name, mode);\n-    if (-1 == rv) {\n-        pt_MapError(_PR_MD_MAP_MKDIR_ERROR, errno);\n-    }\n-    if (NULL != _pr_rename_lock) {\n-        PR_Unlock(_pr_rename_lock);\n-    }\n+  /*\n+  ** This lock is used to enforce rename semantics as described\n+  ** in PR_Rename.\n+  */\n+  if (NULL != _pr_rename_lock) {\n+    PR_Lock(_pr_rename_lock);\n+  }\n+  rv = mkdir(name, mode);\n+  if (-1 == rv) {\n+    pt_MapError(_PR_MD_MAP_MKDIR_ERROR, errno);\n+  }\n+  if (NULL != _pr_rename_lock) {\n+    PR_Unlock(_pr_rename_lock);\n+  }\n \n-    return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;\n+  return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;\n } /* PR_Makedir */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_MkDir(const char* name, PRIntn mode)\n-{\n-    return PR_MakeDir(name, mode);\n+PR_IMPLEMENT(PRStatus) PR_MkDir(const char* name, PRIntn mode) {\n+  return PR_MakeDir(name, mode);\n } /* PR_Mkdir */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_RmDir(const char* name)\n-{\n-    PRInt32 rv;\n-\n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+PR_IMPLEMENT(PRStatus) PR_RmDir(const char* name) {\n+  PRInt32 rv;\n \n-    rv = rmdir(name);\n-    if (0 == rv) {\n-        return PR_SUCCESS;\n-    }\n-    pt_MapError(_PR_MD_MAP_RMDIR_ERROR, errno);\n+  if (pt_TestAbort()) {\n     return PR_FAILURE;\n-} /* PR_Rmdir */\n+  }\n \n-PR_IMPLEMENT(PRDir*)\n-PR_OpenDir(const char* name)\n-{\n-    DIR* osdir;\n-    PRDir* dir = NULL;\n+  rv = rmdir(name);\n+  if (0 == rv) {\n+    return PR_SUCCESS;\n+  }\n+  pt_MapError(_PR_MD_MAP_RMDIR_ERROR, errno);\n+  return PR_FAILURE;\n+} /* PR_Rmdir */\n \n-    if (pt_TestAbort()) {\n-        return dir;\n-    }\n+PR_IMPLEMENT(PRDir*) PR_OpenDir(const char* name) {\n+  DIR* osdir;\n+  PRDir* dir = NULL;\n \n-    osdir = opendir(name);\n-    if (osdir == NULL) {\n-        pt_MapError(_PR_MD_MAP_OPENDIR_ERROR, errno);\n+  if (pt_TestAbort()) {\n+    return dir;\n+  }\n+\n+  osdir = opendir(name);\n+  if (osdir == NULL) {\n+    pt_MapError(_PR_MD_MAP_OPENDIR_ERROR, errno);\n+  } else {\n+    dir = PR_NEWZAP(PRDir);\n+    if (dir) {\n+      dir->md.d = osdir;\n     } else {\n-        dir = PR_NEWZAP(PRDir);\n-        if (dir) {\n-            dir->md.d = osdir;\n-        } else {\n-            (void)closedir(osdir);\n-        }\n+      (void)closedir(osdir);\n     }\n-    return dir;\n+  }\n+  return dir;\n } /* PR_OpenDir */\n \n-static PRInt32\n-_pr_poll_with_poll(PRPollDesc* pds, PRIntn npds,\n-                   PRIntervalTime timeout)\n-{\n-    PRInt32 ready = 0;\n-    /*\n-     * For restarting poll() if it is interrupted by a signal.\n-     * We use these variables to figure out how much time has\n-     * elapsed and how much of the timeout still remains.\n-     */\n-    PRIntervalTime start = 0, elapsed, remaining;\n-\n-    if (pt_TestAbort()) {\n-        return -1;\n+static PRInt32 _pr_poll_with_poll(PRPollDesc* pds, PRIntn npds,\n+                                  PRIntervalTime timeout) {\n+  PRInt32 ready = 0;\n+  /*\n+   * For restarting poll() if it is interrupted by a signal.\n+   * We use these variables to figure out how much time has\n+   * elapsed and how much of the timeout still remains.\n+   */\n+  PRIntervalTime start = 0, elapsed, remaining;\n+\n+  if (pt_TestAbort()) {\n+    return -1;\n+  }\n+\n+  if (0 == npds) {\n+    PR_Sleep(timeout);\n+  } else {\n+#  define STACK_POLL_DESC_COUNT 64\n+    struct pollfd stack_syspoll[STACK_POLL_DESC_COUNT];\n+    struct pollfd* syspoll;\n+    PRIntn index, msecs;\n+\n+    if (npds <= STACK_POLL_DESC_COUNT) {\n+      syspoll = stack_syspoll;\n+    } else {\n+      PRThread* me = PR_GetCurrentThread();\n+      if (npds > me->syspoll_count) {\n+        PR_Free(me->syspoll_list);\n+        me->syspoll_list =\n+            (struct pollfd*)PR_MALLOC(npds * sizeof(struct pollfd));\n+        if (NULL == me->syspoll_list) {\n+          me->syspoll_count = 0;\n+          PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+          return -1;\n+        }\n+        me->syspoll_count = npds;\n+      }\n+      syspoll = me->syspoll_list;\n     }\n \n-    if (0 == npds) {\n-        PR_Sleep(timeout);\n-    } else {\n-#define STACK_POLL_DESC_COUNT 64\n-        struct pollfd stack_syspoll[STACK_POLL_DESC_COUNT];\n-        struct pollfd* syspoll;\n-        PRIntn index, msecs;\n+    for (index = 0; index < npds; ++index) {\n+      PRInt16 in_flags_read = 0, in_flags_write = 0;\n+      PRInt16 out_flags_read = 0, out_flags_write = 0;\n \n-        if (npds <= STACK_POLL_DESC_COUNT) {\n-            syspoll = stack_syspoll;\n+      if ((NULL != pds[index].fd) && (0 != pds[index].in_flags)) {\n+        if (pds[index].in_flags & PR_POLL_READ) {\n+          in_flags_read = (pds[index].fd->methods->poll)(\n+              pds[index].fd, pds[index].in_flags & ~PR_POLL_WRITE,\n+              &out_flags_read);\n+        }\n+        if (pds[index].in_flags & PR_POLL_WRITE) {\n+          in_flags_write = (pds[index].fd->methods->poll)(\n+              pds[index].fd, pds[index].in_flags & ~PR_POLL_READ,\n+              &out_flags_write);\n+        }\n+        if ((0 != (in_flags_read & out_flags_read)) ||\n+            (0 != (in_flags_write & out_flags_write))) {\n+          /* this one is ready right now */\n+          if (0 == ready) {\n+            /*\n+             * We will return without calling the system\n+             * poll function.  So zero the out_flags\n+             * fields of all the poll descriptors before\n+             * this one.\n+             */\n+            int i;\n+            for (i = 0; i < index; i++) {\n+              pds[i].out_flags = 0;\n+            }\n+          }\n+          ready += 1;\n+          pds[index].out_flags = out_flags_read | out_flags_write;\n         } else {\n-            PRThread* me = PR_GetCurrentThread();\n-            if (npds > me->syspoll_count) {\n-                PR_Free(me->syspoll_list);\n-                me->syspoll_list =\n-                    (struct pollfd*)PR_MALLOC(npds * sizeof(struct pollfd));\n-                if (NULL == me->syspoll_list) {\n-                    me->syspoll_count = 0;\n-                    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-                    return -1;\n-                }\n-                me->syspoll_count = npds;\n+          /* now locate the NSPR layer at the bottom of the stack */\n+          PRFileDesc* bottom =\n+              PR_GetIdentitiesLayer(pds[index].fd, PR_NSPR_IO_LAYER);\n+          /* ignore a socket without PR_NSPR_IO_LAYER available */\n+\n+          pds[index].out_flags = 0; /* pre-condition */\n+          if ((NULL != bottom) &&\n+              (_PR_FILEDESC_OPEN == bottom->secret->state)) {\n+            if (0 == ready) {\n+              syspoll[index].fd = bottom->secret->md.osfd;\n+              syspoll[index].events = 0;\n+              if (in_flags_read & PR_POLL_READ) {\n+                pds[index].out_flags |= _PR_POLL_READ_SYS_READ;\n+                syspoll[index].events |= POLLIN;\n+              }\n+              if (in_flags_read & PR_POLL_WRITE) {\n+                pds[index].out_flags |= _PR_POLL_READ_SYS_WRITE;\n+                syspoll[index].events |= POLLOUT;\n+              }\n+              if (in_flags_write & PR_POLL_READ) {\n+                pds[index].out_flags |= _PR_POLL_WRITE_SYS_READ;\n+                syspoll[index].events |= POLLIN;\n+              }\n+              if (in_flags_write & PR_POLL_WRITE) {\n+                pds[index].out_flags |= _PR_POLL_WRITE_SYS_WRITE;\n+                syspoll[index].events |= POLLOUT;\n+              }\n+              if (pds[index].in_flags & PR_POLL_EXCEPT) {\n+                syspoll[index].events |= POLLPRI;\n+              }\n+            }\n+          } else {\n+            if (0 == ready) {\n+              int i;\n+              for (i = 0; i < index; i++) {\n+                pds[i].out_flags = 0;\n+              }\n             }\n-            syspoll = me->syspoll_list;\n+            ready += 1; /* this will cause an abrupt return */\n+            pds[index].out_flags = PR_POLL_NVAL; /* bogii */\n+          }\n         }\n+      } else {\n+        /* make poll() ignore this entry */\n+        syspoll[index].fd = -1;\n+        syspoll[index].events = 0;\n+        pds[index].out_flags = 0;\n+      }\n+    }\n+    if (0 == ready) {\n+      switch (timeout) {\n+        case PR_INTERVAL_NO_WAIT:\n+          msecs = 0;\n+          break;\n+        case PR_INTERVAL_NO_TIMEOUT:\n+          msecs = -1;\n+          break;\n+        default:\n+          msecs = PR_IntervalToMilliseconds(timeout);\n+          start = PR_IntervalNow();\n+      }\n \n-        for (index = 0; index < npds; ++index) {\n-            PRInt16 in_flags_read = 0, in_flags_write = 0;\n-            PRInt16 out_flags_read = 0, out_flags_write = 0;\n-\n-            if ((NULL != pds[index].fd) && (0 != pds[index].in_flags)) {\n-                if (pds[index].in_flags & PR_POLL_READ) {\n-                    in_flags_read = (pds[index].fd->methods->poll)(\n-                        pds[index].fd, pds[index].in_flags & ~PR_POLL_WRITE,\n-                        &out_flags_read);\n-                }\n-                if (pds[index].in_flags & PR_POLL_WRITE) {\n-                    in_flags_write = (pds[index].fd->methods->poll)(\n-                        pds[index].fd, pds[index].in_flags & ~PR_POLL_READ,\n-                        &out_flags_write);\n-                }\n-                if ((0 != (in_flags_read & out_flags_read)) ||\n-                    (0 != (in_flags_write & out_flags_write))) {\n-                    /* this one is ready right now */\n-                    if (0 == ready) {\n-                        /*\n-                         * We will return without calling the system\n-                         * poll function.  So zero the out_flags\n-                         * fields of all the poll descriptors before\n-                         * this one.\n-                         */\n-                        int i;\n-                        for (i = 0; i < index; i++) {\n-                            pds[i].out_flags = 0;\n-                        }\n-                    }\n-                    ready += 1;\n-                    pds[index].out_flags = out_flags_read | out_flags_write;\n-                } else {\n-                    /* now locate the NSPR layer at the bottom of the stack */\n-                    PRFileDesc* bottom =\n-                        PR_GetIdentitiesLayer(pds[index].fd, PR_NSPR_IO_LAYER);\n-                    /* ignore a socket without PR_NSPR_IO_LAYER available */\n-\n-                    pds[index].out_flags = 0; /* pre-condition */\n-                    if ((NULL != bottom) &&\n-                        (_PR_FILEDESC_OPEN == bottom->secret->state)) {\n-                        if (0 == ready) {\n-                            syspoll[index].fd = bottom->secret->md.osfd;\n-                            syspoll[index].events = 0;\n-                            if (in_flags_read & PR_POLL_READ) {\n-                                pds[index].out_flags |= _PR_POLL_READ_SYS_READ;\n-                                syspoll[index].events |= POLLIN;\n-                            }\n-                            if (in_flags_read & PR_POLL_WRITE) {\n-                                pds[index].out_flags |= _PR_POLL_READ_SYS_WRITE;\n-                                syspoll[index].events |= POLLOUT;\n-                            }\n-                            if (in_flags_write & PR_POLL_READ) {\n-                                pds[index].out_flags |= _PR_POLL_WRITE_SYS_READ;\n-                                syspoll[index].events |= POLLIN;\n-                            }\n-                            if (in_flags_write & PR_POLL_WRITE) {\n-                                pds[index].out_flags |= _PR_POLL_WRITE_SYS_WRITE;\n-                                syspoll[index].events |= POLLOUT;\n-                            }\n-                            if (pds[index].in_flags & PR_POLL_EXCEPT) {\n-                                syspoll[index].events |= POLLPRI;\n-                            }\n-                        }\n-                    } else {\n-                        if (0 == ready) {\n-                            int i;\n-                            for (i = 0; i < index; i++) {\n-                                pds[i].out_flags = 0;\n-                            }\n-                        }\n-                        ready += 1;                          /* this will cause an abrupt return */\n-                        pds[index].out_flags = PR_POLL_NVAL; /* bogii */\n-                    }\n-                }\n+    retry:\n+      ready = poll(syspoll, npds, msecs);\n+      if (-1 == ready) {\n+        PRIntn oserror = errno;\n+\n+        if (EINTR == oserror) {\n+          if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+            goto retry;\n+          } else if (timeout == PR_INTERVAL_NO_WAIT) {\n+            ready = 0; /* don't retry, just time out */\n+          } else {\n+            elapsed = (PRIntervalTime)(PR_IntervalNow() - start);\n+            if (elapsed > timeout) {\n+              ready = 0; /* timed out */\n             } else {\n-                /* make poll() ignore this entry */\n-                syspoll[index].fd = -1;\n-                syspoll[index].events = 0;\n-                pds[index].out_flags = 0;\n+              remaining = timeout - elapsed;\n+              msecs = PR_IntervalToMilliseconds(remaining);\n+              goto retry;\n             }\n+          }\n+        } else {\n+          _PR_MD_MAP_POLL_ERROR(oserror);\n         }\n-        if (0 == ready) {\n-            switch (timeout) {\n-                case PR_INTERVAL_NO_WAIT:\n-                    msecs = 0;\n-                    break;\n-                case PR_INTERVAL_NO_TIMEOUT:\n-                    msecs = -1;\n-                    break;\n-                default:\n-                    msecs = PR_IntervalToMilliseconds(timeout);\n-                    start = PR_IntervalNow();\n-            }\n-\n-        retry:\n-            ready = poll(syspoll, npds, msecs);\n-            if (-1 == ready) {\n-                PRIntn oserror = errno;\n-\n-                if (EINTR == oserror) {\n-                    if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-                        goto retry;\n-                    } else if (timeout == PR_INTERVAL_NO_WAIT) {\n-                        ready = 0; /* don't retry, just time out */\n-                    } else {\n-                        elapsed = (PRIntervalTime)(PR_IntervalNow() - start);\n-                        if (elapsed > timeout) {\n-                            ready = 0; /* timed out */\n-                        } else {\n-                            remaining = timeout - elapsed;\n-                            msecs = PR_IntervalToMilliseconds(remaining);\n-                            goto retry;\n-                        }\n-                    }\n-                } else {\n-                    _PR_MD_MAP_POLL_ERROR(oserror);\n+      } else if (ready > 0) {\n+        for (index = 0; index < npds; ++index) {\n+          PRInt16 out_flags = 0;\n+          if ((NULL != pds[index].fd) && (0 != pds[index].in_flags)) {\n+            if (0 != syspoll[index].revents) {\n+              if (syspoll[index].revents & POLLIN) {\n+                if (pds[index].out_flags & _PR_POLL_READ_SYS_READ) {\n+                  out_flags |= PR_POLL_READ;\n                 }\n-            } else if (ready > 0) {\n-                for (index = 0; index < npds; ++index) {\n-                    PRInt16 out_flags = 0;\n-                    if ((NULL != pds[index].fd) && (0 != pds[index].in_flags)) {\n-                        if (0 != syspoll[index].revents) {\n-                            if (syspoll[index].revents & POLLIN) {\n-                                if (pds[index].out_flags & _PR_POLL_READ_SYS_READ) {\n-                                    out_flags |= PR_POLL_READ;\n-                                }\n-                                if (pds[index].out_flags & _PR_POLL_WRITE_SYS_READ) {\n-                                    out_flags |= PR_POLL_WRITE;\n-                                }\n-                            }\n-                            if (syspoll[index].revents & POLLOUT) {\n-                                if (pds[index].out_flags & _PR_POLL_READ_SYS_WRITE) {\n-                                    out_flags |= PR_POLL_READ;\n-                                }\n-                                if (pds[index].out_flags & _PR_POLL_WRITE_SYS_WRITE) {\n-                                    out_flags |= PR_POLL_WRITE;\n-                                }\n-                            }\n-                            if (syspoll[index].revents & POLLPRI) {\n-                                out_flags |= PR_POLL_EXCEPT;\n-                            }\n-                            if (syspoll[index].revents & POLLERR) {\n-                                out_flags |= PR_POLL_ERR;\n-                            }\n-                            if (syspoll[index].revents & POLLNVAL) {\n-                                out_flags |= PR_POLL_NVAL;\n-                            }\n-                            if (syspoll[index].revents & POLLHUP) {\n-                                out_flags |= PR_POLL_HUP;\n-                            }\n-                        }\n-                    }\n-                    pds[index].out_flags = out_flags;\n+                if (pds[index].out_flags & _PR_POLL_WRITE_SYS_READ) {\n+                  out_flags |= PR_POLL_WRITE;\n                 }\n+              }\n+              if (syspoll[index].revents & POLLOUT) {\n+                if (pds[index].out_flags & _PR_POLL_READ_SYS_WRITE) {\n+                  out_flags |= PR_POLL_READ;\n+                }\n+                if (pds[index].out_flags & _PR_POLL_WRITE_SYS_WRITE) {\n+                  out_flags |= PR_POLL_WRITE;\n+                }\n+              }\n+              if (syspoll[index].revents & POLLPRI) {\n+                out_flags |= PR_POLL_EXCEPT;\n+              }\n+              if (syspoll[index].revents & POLLERR) {\n+                out_flags |= PR_POLL_ERR;\n+              }\n+              if (syspoll[index].revents & POLLNVAL) {\n+                out_flags |= PR_POLL_NVAL;\n+              }\n+              if (syspoll[index].revents & POLLHUP) {\n+                out_flags |= PR_POLL_HUP;\n+              }\n             }\n+          }\n+          pds[index].out_flags = out_flags;\n         }\n+      }\n     }\n-    return ready;\n+  }\n+  return ready;\n \n } /* _pr_poll_with_poll */\n \n+\n PR_IMPLEMENT(PRInt32)\n-PR_Poll(PRPollDesc* pds, PRIntn npds, PRIntervalTime timeout)\n-{\n-    return (_pr_poll_with_poll(pds, npds, timeout));\n+PR_Poll(PRPollDesc* pds, PRIntn npds, PRIntervalTime timeout) {\n+  return (_pr_poll_with_poll(pds, npds, timeout));\n }\n \n-PR_IMPLEMENT(PRDirEntry*)\n-PR_ReadDir(PRDir* dir, PRDirFlags flags)\n-{\n-    struct dirent* dp;\n-\n-    if (pt_TestAbort()) {\n-        return NULL;\n-    }\n+PR_IMPLEMENT(PRDirEntry*) PR_ReadDir(PRDir* dir, PRDirFlags flags) {\n+  struct dirent* dp;\n \n-    for (;;) {\n-        errno = 0;\n-        dp = readdir(dir->md.d);\n-        if (NULL == dp) {\n-            pt_MapError(_PR_MD_MAP_READDIR_ERROR, errno);\n-            return NULL;\n-        }\n-        if ((flags & PR_SKIP_DOT) && ('.' == dp->d_name[0]) &&\n-            (0 == dp->d_name[1])) {\n-            continue;\n-        }\n-        if ((flags & PR_SKIP_DOT_DOT) && ('.' == dp->d_name[0]) &&\n-            ('.' == dp->d_name[1]) && (0 == dp->d_name[2])) {\n-            continue;\n-        }\n-        if ((flags & PR_SKIP_HIDDEN) && ('.' == dp->d_name[0])) {\n-            continue;\n-        }\n-        break;\n-    }\n-    dir->d.name = dp->d_name;\n-    return &dir->d;\n+  if (pt_TestAbort()) {\n+    return NULL;\n+  }\n+\n+  for (;;) {\n+    errno = 0;\n+    dp = readdir(dir->md.d);\n+    if (NULL == dp) {\n+      pt_MapError(_PR_MD_MAP_READDIR_ERROR, errno);\n+      return NULL;\n+    }\n+    if ((flags & PR_SKIP_DOT) && ('.' == dp->d_name[0]) &&\n+        (0 == dp->d_name[1])) {\n+      continue;\n+    }\n+    if ((flags & PR_SKIP_DOT_DOT) && ('.' == dp->d_name[0]) &&\n+        ('.' == dp->d_name[1]) && (0 == dp->d_name[2])) {\n+      continue;\n+    }\n+    if ((flags & PR_SKIP_HIDDEN) && ('.' == dp->d_name[0])) {\n+      continue;\n+    }\n+    break;\n+  }\n+  dir->d.name = dp->d_name;\n+  return &dir->d;\n } /* PR_ReadDir */\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_NewUDPSocket(void)\n-{\n-    PRIntn domain = PF_INET;\n+PR_IMPLEMENT(PRFileDesc*) PR_NewUDPSocket(void) {\n+  PRIntn domain = PF_INET;\n \n-    return PR_Socket(domain, SOCK_DGRAM, 0);\n+  return PR_Socket(domain, SOCK_DGRAM, 0);\n } /* PR_NewUDPSocket */\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_NewTCPSocket(void)\n-{\n-    PRIntn domain = PF_INET;\n+PR_IMPLEMENT(PRFileDesc*) PR_NewTCPSocket(void) {\n+  PRIntn domain = PF_INET;\n \n-    return PR_Socket(domain, SOCK_STREAM, 0);\n+  return PR_Socket(domain, SOCK_STREAM, 0);\n } /* PR_NewTCPSocket */\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_OpenUDPSocket(PRIntn af)\n-{\n-    return PR_Socket(af, SOCK_DGRAM, 0);\n+PR_IMPLEMENT(PRFileDesc*) PR_OpenUDPSocket(PRIntn af) {\n+  return PR_Socket(af, SOCK_DGRAM, 0);\n } /* PR_NewUDPSocket */\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_OpenTCPSocket(PRIntn af)\n-{\n-    return PR_Socket(af, SOCK_STREAM, 0);\n+PR_IMPLEMENT(PRFileDesc*) PR_OpenTCPSocket(PRIntn af) {\n+  return PR_Socket(af, SOCK_STREAM, 0);\n } /* PR_NewTCPSocket */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_NewTCPSocketPair(PRFileDesc* fds[2])\n-{\n-    PRInt32 osfd[2];\n+PR_IMPLEMENT(PRStatus) PR_NewTCPSocketPair(PRFileDesc* fds[2]) {\n+  PRInt32 osfd[2];\n \n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n \n-    if (socketpair(AF_UNIX, SOCK_STREAM, 0, osfd) == -1) {\n-        pt_MapError(_PR_MD_MAP_SOCKETPAIR_ERROR, errno);\n-        return PR_FAILURE;\n-    }\n+  if (socketpair(AF_UNIX, SOCK_STREAM, 0, osfd) == -1) {\n+    pt_MapError(_PR_MD_MAP_SOCKETPAIR_ERROR, errno);\n+    return PR_FAILURE;\n+  }\n \n-    fds[0] = pt_SetMethods(osfd[0], PR_DESC_SOCKET_TCP, PR_FALSE, PR_FALSE);\n-    if (fds[0] == NULL) {\n-        close(osfd[0]);\n-        close(osfd[1]);\n-        return PR_FAILURE;\n-    }\n-    fds[1] = pt_SetMethods(osfd[1], PR_DESC_SOCKET_TCP, PR_FALSE, PR_FALSE);\n-    if (fds[1] == NULL) {\n-        PR_Close(fds[0]);\n-        close(osfd[1]);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  fds[0] = pt_SetMethods(osfd[0], PR_DESC_SOCKET_TCP, PR_FALSE, PR_FALSE);\n+  if (fds[0] == NULL) {\n+    close(osfd[0]);\n+    close(osfd[1]);\n+    return PR_FAILURE;\n+  }\n+  fds[1] = pt_SetMethods(osfd[1], PR_DESC_SOCKET_TCP, PR_FALSE, PR_FALSE);\n+  if (fds[1] == NULL) {\n+    PR_Close(fds[0]);\n+    close(osfd[1]);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n } /* PR_NewTCPSocketPair */\n \n PR_IMPLEMENT(PRStatus)\n-PR_CreatePipe(PRFileDesc** readPipe, PRFileDesc** writePipe)\n-{\n-    int pipefd[2];\n+PR_CreatePipe(PRFileDesc** readPipe, PRFileDesc** writePipe) {\n+  int pipefd[2];\n \n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n \n-    if (pipe(pipefd) == -1) {\n-        /* XXX map pipe error */\n-        PR_SetError(PR_UNKNOWN_ERROR, errno);\n-        return PR_FAILURE;\n-    }\n-    *readPipe = pt_SetMethods(pipefd[0], PR_DESC_PIPE, PR_FALSE, PR_FALSE);\n-    if (NULL == *readPipe) {\n-        close(pipefd[0]);\n-        close(pipefd[1]);\n-        return PR_FAILURE;\n-    }\n-    *writePipe = pt_SetMethods(pipefd[1], PR_DESC_PIPE, PR_FALSE, PR_FALSE);\n-    if (NULL == *writePipe) {\n-        PR_Close(*readPipe);\n-        close(pipefd[1]);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  if (pipe(pipefd) == -1) {\n+    /* XXX map pipe error */\n+    PR_SetError(PR_UNKNOWN_ERROR, errno);\n+    return PR_FAILURE;\n+  }\n+  *readPipe = pt_SetMethods(pipefd[0], PR_DESC_PIPE, PR_FALSE, PR_FALSE);\n+  if (NULL == *readPipe) {\n+    close(pipefd[0]);\n+    close(pipefd[1]);\n+    return PR_FAILURE;\n+  }\n+  *writePipe = pt_SetMethods(pipefd[1], PR_DESC_PIPE, PR_FALSE, PR_FALSE);\n+  if (NULL == *writePipe) {\n+    PR_Close(*readPipe);\n+    close(pipefd[1]);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n /*\n ** Set the inheritance attribute of a file descriptor.\n */\n-PR_IMPLEMENT(PRStatus)\n-PR_SetFDInheritable(PRFileDesc* fd, PRBool inheritable)\n-{\n-    /*\n-     * Only a non-layered, NSPR file descriptor can be inherited\n-     * by a child process.\n-     */\n-    if (fd->identity != PR_NSPR_IO_LAYER) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    if (fd->secret->inheritable != inheritable) {\n-        if (fcntl(fd->secret->md.osfd, F_SETFD, inheritable ? 0 : FD_CLOEXEC) ==\n-            -1) {\n-            _PR_MD_MAP_DEFAULT_ERROR(errno);\n-            return PR_FAILURE;\n-        }\n-        fd->secret->inheritable = (_PRTriStateBool)inheritable;\n-    }\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_SetFDInheritable(PRFileDesc* fd, PRBool inheritable) {\n+  /*\n+   * Only a non-layered, NSPR file descriptor can be inherited\n+   * by a child process.\n+   */\n+  if (fd->identity != PR_NSPR_IO_LAYER) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  if (fd->secret->inheritable != inheritable) {\n+    if (fcntl(fd->secret->md.osfd, F_SETFD, inheritable ? 0 : FD_CLOEXEC) ==\n+        -1) {\n+      _PR_MD_MAP_DEFAULT_ERROR(errno);\n+      return PR_FAILURE;\n+    }\n+    fd->secret->inheritable = (_PRTriStateBool)inheritable;\n+  }\n+  return PR_SUCCESS;\n }\n \n /*****************************************************************************/\n /***************************** I/O friends methods ***************************/\n /*****************************************************************************/\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_ImportFile(PRInt32 osfd)\n-{\n-    PRFileDesc* fd;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    fd = pt_SetMethods(osfd, PR_DESC_FILE, PR_FALSE, PR_TRUE);\n-    if (NULL == fd) {\n-        close(osfd);\n-    }\n-    return fd;\n+PR_IMPLEMENT(PRFileDesc*) PR_ImportFile(PRInt32 osfd) {\n+  PRFileDesc* fd;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  fd = pt_SetMethods(osfd, PR_DESC_FILE, PR_FALSE, PR_TRUE);\n+  if (NULL == fd) {\n+    close(osfd);\n+  }\n+  return fd;\n } /* PR_ImportFile */\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_ImportPipe(PRInt32 osfd)\n-{\n-    PRFileDesc* fd;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    fd = pt_SetMethods(osfd, PR_DESC_PIPE, PR_FALSE, PR_TRUE);\n-    if (NULL == fd) {\n-        close(osfd);\n-    }\n-    return fd;\n+PR_IMPLEMENT(PRFileDesc*) PR_ImportPipe(PRInt32 osfd) {\n+  PRFileDesc* fd;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  fd = pt_SetMethods(osfd, PR_DESC_PIPE, PR_FALSE, PR_TRUE);\n+  if (NULL == fd) {\n+    close(osfd);\n+  }\n+  return fd;\n } /* PR_ImportPipe */\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_ImportTCPSocket(PRInt32 osfd)\n-{\n-    PRFileDesc* fd;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    fd = pt_SetMethods(osfd, PR_DESC_SOCKET_TCP, PR_FALSE, PR_TRUE);\n-    if (NULL == fd) {\n-        close(osfd);\n-    }\n-#ifdef _PR_NEED_SECRET_AF\n-    if (NULL != fd) {\n-        fd->secret->af = PF_INET;\n-    }\n-#endif\n-    return fd;\n+PR_IMPLEMENT(PRFileDesc*) PR_ImportTCPSocket(PRInt32 osfd) {\n+  PRFileDesc* fd;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  fd = pt_SetMethods(osfd, PR_DESC_SOCKET_TCP, PR_FALSE, PR_TRUE);\n+  if (NULL == fd) {\n+    close(osfd);\n+  }\n+#  ifdef _PR_NEED_SECRET_AF\n+  if (NULL != fd) {\n+    fd->secret->af = PF_INET;\n+  }\n+#  endif\n+  return fd;\n } /* PR_ImportTCPSocket */\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_ImportUDPSocket(PRInt32 osfd)\n-{\n-    PRFileDesc* fd;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    fd = pt_SetMethods(osfd, PR_DESC_SOCKET_UDP, PR_FALSE, PR_TRUE);\n-    if (NULL == fd) {\n-        close(osfd);\n-    }\n-    return fd;\n+PR_IMPLEMENT(PRFileDesc*) PR_ImportUDPSocket(PRInt32 osfd) {\n+  PRFileDesc* fd;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  fd = pt_SetMethods(osfd, PR_DESC_SOCKET_UDP, PR_FALSE, PR_TRUE);\n+  if (NULL == fd) {\n+    close(osfd);\n+  }\n+  return fd;\n } /* PR_ImportUDPSocket */\n \n-PR_IMPLEMENT(PRFileDesc*)\n-PR_CreateSocketPollFd(PRInt32 osfd)\n-{\n-    PRFileDesc* fd;\n+PR_IMPLEMENT(PRFileDesc*) PR_CreateSocketPollFd(PRInt32 osfd) {\n+  PRFileDesc* fd;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    fd = _PR_Getfd();\n+  fd = _PR_Getfd();\n \n-    if (fd == NULL) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-    } else {\n-        fd->secret->md.osfd = osfd;\n-        fd->secret->inheritable = _PR_TRI_FALSE;\n-        fd->secret->state = _PR_FILEDESC_OPEN;\n-        fd->methods = PR_GetSocketPollFdMethods();\n-    }\n+  if (fd == NULL) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  } else {\n+    fd->secret->md.osfd = osfd;\n+    fd->secret->inheritable = _PR_TRI_FALSE;\n+    fd->secret->state = _PR_FILEDESC_OPEN;\n+    fd->methods = PR_GetSocketPollFdMethods();\n+  }\n \n-    return fd;\n+  return fd;\n } /* PR_CreateSocketPollFD */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_DestroySocketPollFd(PRFileDesc* fd)\n-{\n-    if (NULL == fd) {\n-        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    fd->secret->state = _PR_FILEDESC_CLOSED;\n-    _PR_Putfd(fd);\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_DestroySocketPollFd(PRFileDesc* fd) {\n+  if (NULL == fd) {\n+    PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  fd->secret->state = _PR_FILEDESC_CLOSED;\n+  _PR_Putfd(fd);\n+  return PR_SUCCESS;\n } /* PR_DestroySocketPollFd */\n \n-PR_IMPLEMENT(PRInt32)\n-PR_FileDesc2NativeHandle(PRFileDesc* bottom)\n-{\n-    PRInt32 osfd = -1;\n-    bottom =\n-        (NULL == bottom) ? NULL : PR_GetIdentitiesLayer(bottom, PR_NSPR_IO_LAYER);\n-    if (NULL == bottom) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-    } else {\n-        osfd = bottom->secret->md.osfd;\n-    }\n-    return osfd;\n+PR_IMPLEMENT(PRInt32) PR_FileDesc2NativeHandle(PRFileDesc* bottom) {\n+  PRInt32 osfd = -1;\n+  bottom =\n+      (NULL == bottom) ? NULL : PR_GetIdentitiesLayer(bottom, PR_NSPR_IO_LAYER);\n+  if (NULL == bottom) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+  } else {\n+    osfd = bottom->secret->md.osfd;\n+  }\n+  return osfd;\n } /* PR_FileDesc2NativeHandle */\n \n PR_IMPLEMENT(void)\n-PR_ChangeFileDescNativeHandle(PRFileDesc* fd, PRInt32 handle)\n-{\n-    if (fd) {\n-        fd->secret->md.osfd = handle;\n-    }\n+PR_ChangeFileDescNativeHandle(PRFileDesc* fd, PRInt32 handle) {\n+  if (fd) {\n+    fd->secret->md.osfd = handle;\n+  }\n } /*  PR_ChangeFileDescNativeHandle*/\n \n-PR_IMPLEMENT(PRStatus)\n-PR_LockFile(PRFileDesc* fd)\n-{\n-    PRStatus status = PR_SUCCESS;\n-\n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+PR_IMPLEMENT(PRStatus) PR_LockFile(PRFileDesc* fd) {\n+  PRStatus status = PR_SUCCESS;\n \n-    PR_Lock(_pr_flock_lock);\n-    while (-1 == fd->secret->lockCount) {\n-        PR_WaitCondVar(_pr_flock_cv, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    if (0 == fd->secret->lockCount) {\n-        fd->secret->lockCount = -1;\n-        PR_Unlock(_pr_flock_lock);\n-        status = _PR_MD_LOCKFILE(fd->secret->md.osfd);\n-        PR_Lock(_pr_flock_lock);\n-        fd->secret->lockCount = (PR_SUCCESS == status) ? 1 : 0;\n-        PR_NotifyAllCondVar(_pr_flock_cv);\n-    } else {\n-        fd->secret->lockCount += 1;\n-    }\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n+\n+  PR_Lock(_pr_flock_lock);\n+  while (-1 == fd->secret->lockCount) {\n+    PR_WaitCondVar(_pr_flock_cv, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  if (0 == fd->secret->lockCount) {\n+    fd->secret->lockCount = -1;\n     PR_Unlock(_pr_flock_lock);\n-\n-    return status;\n+    status = _PR_MD_LOCKFILE(fd->secret->md.osfd);\n+    PR_Lock(_pr_flock_lock);\n+    fd->secret->lockCount = (PR_SUCCESS == status) ? 1 : 0;\n+    PR_NotifyAllCondVar(_pr_flock_cv);\n+  } else {\n+    fd->secret->lockCount += 1;\n+  }\n+  PR_Unlock(_pr_flock_lock);\n+\n+  return status;\n } /* PR_LockFile */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_TLockFile(PRFileDesc* fd)\n-{\n-    PRStatus status = PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_TLockFile(PRFileDesc* fd) {\n+  PRStatus status = PR_SUCCESS;\n \n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n \n-    PR_Lock(_pr_flock_lock);\n-    if (0 == fd->secret->lockCount) {\n-        status = _PR_MD_TLOCKFILE(fd->secret->md.osfd);\n-        if (PR_SUCCESS == status) {\n-            fd->secret->lockCount = 1;\n-        }\n-    } else {\n-        fd->secret->lockCount += 1;\n+  PR_Lock(_pr_flock_lock);\n+  if (0 == fd->secret->lockCount) {\n+    status = _PR_MD_TLOCKFILE(fd->secret->md.osfd);\n+    if (PR_SUCCESS == status) {\n+      fd->secret->lockCount = 1;\n     }\n-    PR_Unlock(_pr_flock_lock);\n+  } else {\n+    fd->secret->lockCount += 1;\n+  }\n+  PR_Unlock(_pr_flock_lock);\n \n-    return status;\n+  return status;\n } /* PR_TLockFile */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_UnlockFile(PRFileDesc* fd)\n-{\n-    PRStatus status = PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_UnlockFile(PRFileDesc* fd) {\n+  PRStatus status = PR_SUCCESS;\n \n-    if (pt_TestAbort()) {\n-        return PR_FAILURE;\n-    }\n+  if (pt_TestAbort()) {\n+    return PR_FAILURE;\n+  }\n \n-    PR_Lock(_pr_flock_lock);\n-    if (fd->secret->lockCount == 1) {\n-        status = _PR_MD_UNLOCKFILE(fd->secret->md.osfd);\n-        if (PR_SUCCESS == status) {\n-            fd->secret->lockCount = 0;\n-        }\n-    } else {\n-        fd->secret->lockCount -= 1;\n+  PR_Lock(_pr_flock_lock);\n+  if (fd->secret->lockCount == 1) {\n+    status = _PR_MD_UNLOCKFILE(fd->secret->md.osfd);\n+    if (PR_SUCCESS == status) {\n+      fd->secret->lockCount = 0;\n     }\n-    PR_Unlock(_pr_flock_lock);\n+  } else {\n+    fd->secret->lockCount -= 1;\n+  }\n+  PR_Unlock(_pr_flock_lock);\n \n-    return status;\n+  return status;\n }\n \n /*\n@@ -4361,49 +4146,45 @@ PR_UnlockFile(PRFileDesc* fd)\n  * defined here for historical (or hysterical) reasons.\n  */\n \n-PR_IMPLEMENT(PRInt32)\n-PR_GetSysfdTableMax(void)\n-{\n-#if defined(AIX)\n-    return sysconf(_SC_OPEN_MAX);\n-#else\n-    struct rlimit rlim;\n-\n-    if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {\n-        return -1;\n-    }\n+PR_IMPLEMENT(PRInt32) PR_GetSysfdTableMax(void) {\n+#  if defined(AIX)\n+  return sysconf(_SC_OPEN_MAX);\n+#  else\n+  struct rlimit rlim;\n+\n+  if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {\n+    return -1;\n+  }\n \n-    return rlim.rlim_max;\n-#endif\n+  return rlim.rlim_max;\n+#  endif\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_SetSysfdTableSize(PRIntn table_size)\n-{\n-#if defined(AIX)\n-    return -1;\n-#else\n-    struct rlimit rlim;\n-    PRInt32 tableMax = PR_GetSysfdTableMax();\n+PR_IMPLEMENT(PRInt32) PR_SetSysfdTableSize(PRIntn table_size) {\n+#  if defined(AIX)\n+  return -1;\n+#  else\n+  struct rlimit rlim;\n+  PRInt32 tableMax = PR_GetSysfdTableMax();\n \n-    if (tableMax < 0) {\n-        return -1;\n-    }\n-    rlim.rlim_max = tableMax;\n+  if (tableMax < 0) {\n+    return -1;\n+  }\n+  rlim.rlim_max = tableMax;\n \n-    /* Grow as much as we can; even if too big */\n-    if (rlim.rlim_max < table_size) {\n-        rlim.rlim_cur = rlim.rlim_max;\n-    } else {\n-        rlim.rlim_cur = table_size;\n-    }\n+  /* Grow as much as we can; even if too big */\n+  if (rlim.rlim_max < table_size) {\n+    rlim.rlim_cur = rlim.rlim_max;\n+  } else {\n+    rlim.rlim_cur = table_size;\n+  }\n \n-    if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) {\n-        return -1;\n-    }\n+  if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) {\n+    return -1;\n+  }\n \n-    return rlim.rlim_cur;\n-#endif\n+  return rlim.rlim_cur;\n+#  endif\n }\n \n /*\n@@ -4411,294 +4192,267 @@ PR_SetSysfdTableSize(PRIntn table_size)\n  * code uses it.  New code should use PR_GetFileInfo.\n  */\n \n-#ifndef NO_NSPR_10_SUPPORT\n-PR_IMPLEMENT(PRInt32)\n-PR_Stat(const char* name, struct stat* buf)\n-{\n-    static PRBool unwarned = PR_TRUE;\n-    if (unwarned) {\n-        unwarned = _PR_Obsolete(\"PR_Stat\", \"PR_GetFileInfo\");\n-    }\n+#  ifndef NO_NSPR_10_SUPPORT\n+PR_IMPLEMENT(PRInt32) PR_Stat(const char* name, struct stat* buf) {\n+  static PRBool unwarned = PR_TRUE;\n+  if (unwarned) {\n+    unwarned = _PR_Obsolete(\"PR_Stat\", \"PR_GetFileInfo\");\n+  }\n \n-    if (pt_TestAbort()) {\n-        return -1;\n-    }\n+  if (pt_TestAbort()) {\n+    return -1;\n+  }\n \n-    if (-1 == stat(name, buf)) {\n-        pt_MapError(_PR_MD_MAP_STAT_ERROR, errno);\n-        return -1;\n-    } else {\n-        return 0;\n-    }\n+  if (-1 == stat(name, buf)) {\n+    pt_MapError(_PR_MD_MAP_STAT_ERROR, errno);\n+    return -1;\n+  } else {\n+    return 0;\n+  }\n }\n-#endif /* ! NO_NSPR_10_SUPPORT */\n-\n-PR_IMPLEMENT(void)\n-PR_FD_ZERO(PR_fd_set* set)\n-{\n-    static PRBool unwarned = PR_TRUE;\n-    if (unwarned) {\n-        unwarned = _PR_Obsolete(\"PR_FD_ZERO (PR_Select)\", \"PR_Poll\");\n-    }\n-    memset(set, 0, sizeof(PR_fd_set));\n+#  endif /* ! NO_NSPR_10_SUPPORT */\n+\n+PR_IMPLEMENT(void) PR_FD_ZERO(PR_fd_set* set) {\n+  static PRBool unwarned = PR_TRUE;\n+  if (unwarned) {\n+    unwarned = _PR_Obsolete(\"PR_FD_ZERO (PR_Select)\", \"PR_Poll\");\n+  }\n+  memset(set, 0, sizeof(PR_fd_set));\n }\n \n-PR_IMPLEMENT(void)\n-PR_FD_SET(PRFileDesc* fh, PR_fd_set* set)\n-{\n-    static PRBool unwarned = PR_TRUE;\n-    if (unwarned) {\n-        unwarned = _PR_Obsolete(\"PR_FD_SET (PR_Select)\", \"PR_Poll\");\n-    }\n-    PR_ASSERT(set->hsize < PR_MAX_SELECT_DESC);\n+PR_IMPLEMENT(void) PR_FD_SET(PRFileDesc* fh, PR_fd_set* set) {\n+  static PRBool unwarned = PR_TRUE;\n+  if (unwarned) {\n+    unwarned = _PR_Obsolete(\"PR_FD_SET (PR_Select)\", \"PR_Poll\");\n+  }\n+  PR_ASSERT(set->hsize < PR_MAX_SELECT_DESC);\n \n-    set->harray[set->hsize++] = fh;\n+  set->harray[set->hsize++] = fh;\n }\n \n-PR_IMPLEMENT(void)\n-PR_FD_CLR(PRFileDesc* fh, PR_fd_set* set)\n-{\n-    PRUint32 index, index2;\n-    static PRBool unwarned = PR_TRUE;\n-    if (unwarned) {\n-        unwarned = _PR_Obsolete(\"PR_FD_CLR (PR_Select)\", \"PR_Poll\");\n+PR_IMPLEMENT(void) PR_FD_CLR(PRFileDesc* fh, PR_fd_set* set) {\n+  PRUint32 index, index2;\n+  static PRBool unwarned = PR_TRUE;\n+  if (unwarned) {\n+    unwarned = _PR_Obsolete(\"PR_FD_CLR (PR_Select)\", \"PR_Poll\");\n+  }\n+\n+  for (index = 0; index < set->hsize; index++)\n+    if (set->harray[index] == fh) {\n+      for (index2 = index; index2 < (set->hsize - 1); index2++) {\n+        set->harray[index2] = set->harray[index2 + 1];\n+      }\n+      set->hsize--;\n+      break;\n     }\n-\n-    for (index = 0; index < set->hsize; index++)\n-        if (set->harray[index] == fh) {\n-            for (index2 = index; index2 < (set->hsize - 1); index2++) {\n-                set->harray[index2] = set->harray[index2 + 1];\n-            }\n-            set->hsize--;\n-            break;\n-        }\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_FD_ISSET(PRFileDesc* fh, PR_fd_set* set)\n-{\n-    PRUint32 index;\n-    static PRBool unwarned = PR_TRUE;\n-    if (unwarned) {\n-        unwarned = _PR_Obsolete(\"PR_FD_ISSET (PR_Select)\", \"PR_Poll\");\n-    }\n-    for (index = 0; index < set->hsize; index++)\n-        if (set->harray[index] == fh) {\n-            return 1;\n-        }\n-    return 0;\n+PR_IMPLEMENT(PRInt32) PR_FD_ISSET(PRFileDesc* fh, PR_fd_set* set) {\n+  PRUint32 index;\n+  static PRBool unwarned = PR_TRUE;\n+  if (unwarned) {\n+    unwarned = _PR_Obsolete(\"PR_FD_ISSET (PR_Select)\", \"PR_Poll\");\n+  }\n+  for (index = 0; index < set->hsize; index++)\n+    if (set->harray[index] == fh) {\n+      return 1;\n+    }\n+  return 0;\n }\n \n-PR_IMPLEMENT(void)\n-PR_FD_NSET(PRInt32 fd, PR_fd_set* set)\n-{\n-    static PRBool unwarned = PR_TRUE;\n-    if (unwarned) {\n-        unwarned = _PR_Obsolete(\"PR_FD_NSET (PR_Select)\", \"PR_Poll\");\n-    }\n-    PR_ASSERT(set->nsize < PR_MAX_SELECT_DESC);\n+PR_IMPLEMENT(void) PR_FD_NSET(PRInt32 fd, PR_fd_set* set) {\n+  static PRBool unwarned = PR_TRUE;\n+  if (unwarned) {\n+    unwarned = _PR_Obsolete(\"PR_FD_NSET (PR_Select)\", \"PR_Poll\");\n+  }\n+  PR_ASSERT(set->nsize < PR_MAX_SELECT_DESC);\n \n-    set->narray[set->nsize++] = fd;\n+  set->narray[set->nsize++] = fd;\n }\n \n-PR_IMPLEMENT(void)\n-PR_FD_NCLR(PRInt32 fd, PR_fd_set* set)\n-{\n-    PRUint32 index, index2;\n-    static PRBool unwarned = PR_TRUE;\n-    if (unwarned) {\n-        unwarned = _PR_Obsolete(\"PR_FD_NCLR (PR_Select)\", \"PR_Poll\");\n+PR_IMPLEMENT(void) PR_FD_NCLR(PRInt32 fd, PR_fd_set* set) {\n+  PRUint32 index, index2;\n+  static PRBool unwarned = PR_TRUE;\n+  if (unwarned) {\n+    unwarned = _PR_Obsolete(\"PR_FD_NCLR (PR_Select)\", \"PR_Poll\");\n+  }\n+\n+  for (index = 0; index < set->nsize; index++)\n+    if (set->narray[index] == fd) {\n+      for (index2 = index; index2 < (set->nsize - 1); index2++) {\n+        set->narray[index2] = set->narray[index2 + 1];\n+      }\n+      set->nsize--;\n+      break;\n     }\n-\n-    for (index = 0; index < set->nsize; index++)\n-        if (set->narray[index] == fd) {\n-            for (index2 = index; index2 < (set->nsize - 1); index2++) {\n-                set->narray[index2] = set->narray[index2 + 1];\n-            }\n-            set->nsize--;\n-            break;\n-        }\n }\n \n-PR_IMPLEMENT(PRInt32)\n-PR_FD_NISSET(PRInt32 fd, PR_fd_set* set)\n-{\n-    PRUint32 index;\n-    static PRBool unwarned = PR_TRUE;\n-    if (unwarned) {\n-        unwarned = _PR_Obsolete(\"PR_FD_NISSET (PR_Select)\", \"PR_Poll\");\n-    }\n-    for (index = 0; index < set->nsize; index++)\n-        if (set->narray[index] == fd) {\n-            return 1;\n-        }\n-    return 0;\n+PR_IMPLEMENT(PRInt32) PR_FD_NISSET(PRInt32 fd, PR_fd_set* set) {\n+  PRUint32 index;\n+  static PRBool unwarned = PR_TRUE;\n+  if (unwarned) {\n+    unwarned = _PR_Obsolete(\"PR_FD_NISSET (PR_Select)\", \"PR_Poll\");\n+  }\n+  for (index = 0; index < set->nsize; index++)\n+    if (set->narray[index] == fd) {\n+      return 1;\n+    }\n+  return 0;\n }\n \n-#include <sys/types.h>\n-#include <sys/time.h>\n-#if !defined(LINUX) && !defined(__GNU__) && !defined(__GLIBC__)\n-#include <sys/select.h>\n-#endif\n+#  include <sys/types.h>\n+#  include <sys/time.h>\n+#  if !defined(LINUX) && !defined(__GNU__) && \\\n+      !defined(__GLIBC__)\n+#    include <sys/select.h>\n+#  endif\n \n-static PRInt32\n-_PR_getset(PR_fd_set* pr_set, fd_set* set)\n-{\n-    PRUint32 index;\n-    PRInt32 max = 0;\n+static PRInt32 _PR_getset(PR_fd_set* pr_set, fd_set* set) {\n+  PRUint32 index;\n+  PRInt32 max = 0;\n \n-    if (!pr_set) {\n-        return 0;\n-    }\n+  if (!pr_set) {\n+    return 0;\n+  }\n \n-    FD_ZERO(set);\n+  FD_ZERO(set);\n \n-    /* First set the pr file handle osfds */\n-    for (index = 0; index < pr_set->hsize; index++) {\n-        FD_SET(pr_set->harray[index]->secret->md.osfd, set);\n-        if (pr_set->harray[index]->secret->md.osfd > max) {\n-            max = pr_set->harray[index]->secret->md.osfd;\n-        }\n+  /* First set the pr file handle osfds */\n+  for (index = 0; index < pr_set->hsize; index++) {\n+    FD_SET(pr_set->harray[index]->secret->md.osfd, set);\n+    if (pr_set->harray[index]->secret->md.osfd > max) {\n+      max = pr_set->harray[index]->secret->md.osfd;\n     }\n-    /* Second set the native osfds */\n-    for (index = 0; index < pr_set->nsize; index++) {\n-        FD_SET(pr_set->narray[index], set);\n-        if (pr_set->narray[index] > max) {\n-            max = pr_set->narray[index];\n-        }\n+  }\n+  /* Second set the native osfds */\n+  for (index = 0; index < pr_set->nsize; index++) {\n+    FD_SET(pr_set->narray[index], set);\n+    if (pr_set->narray[index] > max) {\n+      max = pr_set->narray[index];\n     }\n-    return max;\n+  }\n+  return max;\n }\n \n-static void\n-_PR_setset(PR_fd_set* pr_set, fd_set* set)\n-{\n-    PRUint32 index, last_used;\n+static void _PR_setset(PR_fd_set* pr_set, fd_set* set) {\n+  PRUint32 index, last_used;\n \n-    if (!pr_set) {\n-        return;\n-    }\n+  if (!pr_set) {\n+    return;\n+  }\n \n-    for (last_used = 0, index = 0; index < pr_set->hsize; index++) {\n-        if (FD_ISSET(pr_set->harray[index]->secret->md.osfd, set)) {\n-            pr_set->harray[last_used++] = pr_set->harray[index];\n-        }\n+  for (last_used = 0, index = 0; index < pr_set->hsize; index++) {\n+    if (FD_ISSET(pr_set->harray[index]->secret->md.osfd, set)) {\n+      pr_set->harray[last_used++] = pr_set->harray[index];\n     }\n-    pr_set->hsize = last_used;\n+  }\n+  pr_set->hsize = last_used;\n \n-    for (last_used = 0, index = 0; index < pr_set->nsize; index++) {\n-        if (FD_ISSET(pr_set->narray[index], set)) {\n-            pr_set->narray[last_used++] = pr_set->narray[index];\n-        }\n+  for (last_used = 0, index = 0; index < pr_set->nsize; index++) {\n+    if (FD_ISSET(pr_set->narray[index], set)) {\n+      pr_set->narray[last_used++] = pr_set->narray[index];\n     }\n-    pr_set->nsize = last_used;\n+  }\n+  pr_set->nsize = last_used;\n }\n \n PR_IMPLEMENT(PRInt32)\n PR_Select(PRInt32 unused, PR_fd_set* pr_rd, PR_fd_set* pr_wr, PR_fd_set* pr_ex,\n-          PRIntervalTime timeout)\n-{\n-    fd_set rd, wr, ex;\n-    struct timeval tv, *tvp;\n-    PRInt32 max, max_fd;\n-    PRInt32 rv;\n-    /*\n-     * For restarting select() if it is interrupted by a Unix signal.\n-     * We use these variables to figure out how much time has elapsed\n-     * and how much of the timeout still remains.\n-     */\n-    PRIntervalTime start = 0, elapsed, remaining;\n-\n-    static PRBool unwarned = PR_TRUE;\n-    if (unwarned) {\n-        unwarned = _PR_Obsolete(\"PR_Select\", \"PR_Poll\");\n-    }\n-\n-    FD_ZERO(&rd);\n-    FD_ZERO(&wr);\n-    FD_ZERO(&ex);\n+          PRIntervalTime timeout) {\n+  fd_set rd, wr, ex;\n+  struct timeval tv, *tvp;\n+  PRInt32 max, max_fd;\n+  PRInt32 rv;\n+  /*\n+   * For restarting select() if it is interrupted by a Unix signal.\n+   * We use these variables to figure out how much time has elapsed\n+   * and how much of the timeout still remains.\n+   */\n+  PRIntervalTime start = 0, elapsed, remaining;\n+\n+  static PRBool unwarned = PR_TRUE;\n+  if (unwarned) {\n+    unwarned = _PR_Obsolete(\"PR_Select\", \"PR_Poll\");\n+  }\n+\n+  FD_ZERO(&rd);\n+  FD_ZERO(&wr);\n+  FD_ZERO(&ex);\n+\n+  max_fd = _PR_getset(pr_rd, &rd);\n+  max_fd = (max = _PR_getset(pr_wr, &wr)) > max_fd ? max : max_fd;\n+  max_fd = (max = _PR_getset(pr_ex, &ex)) > max_fd ? max : max_fd;\n+\n+  if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+    tvp = NULL;\n+  } else {\n+    tv.tv_sec = (PRInt32)PR_IntervalToSeconds(timeout);\n+    tv.tv_usec = (PRInt32)PR_IntervalToMicroseconds(\n+        timeout - PR_SecondsToInterval(tv.tv_sec));\n+    tvp = &tv;\n+    start = PR_IntervalNow();\n+  }\n \n-    max_fd = _PR_getset(pr_rd, &rd);\n-    max_fd = (max = _PR_getset(pr_wr, &wr)) > max_fd ? max : max_fd;\n-    max_fd = (max = _PR_getset(pr_ex, &ex)) > max_fd ? max : max_fd;\n+retry:\n+  rv = select(max_fd + 1, (_PRSelectFdSetArg_t)&rd, (_PRSelectFdSetArg_t)&wr,\n+              (_PRSelectFdSetArg_t)&ex, tvp);\n \n+  if (rv == -1 && errno == EINTR) {\n     if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-        tvp = NULL;\n+      goto retry;\n     } else {\n-        tv.tv_sec = (PRInt32)PR_IntervalToSeconds(timeout);\n+      elapsed = (PRIntervalTime)(PR_IntervalNow() - start);\n+      if (elapsed > timeout) {\n+        rv = 0; /* timed out */\n+      } else {\n+        remaining = timeout - elapsed;\n+        tv.tv_sec = (PRInt32)PR_IntervalToSeconds(remaining);\n         tv.tv_usec = (PRInt32)PR_IntervalToMicroseconds(\n-            timeout - PR_SecondsToInterval(tv.tv_sec));\n-        tvp = &tv;\n-        start = PR_IntervalNow();\n-    }\n-\n-retry:\n-    rv = select(max_fd + 1, (_PRSelectFdSetArg_t)&rd, (_PRSelectFdSetArg_t)&wr,\n-                (_PRSelectFdSetArg_t)&ex, tvp);\n-\n-    if (rv == -1 && errno == EINTR) {\n-        if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-            goto retry;\n-        } else {\n-            elapsed = (PRIntervalTime)(PR_IntervalNow() - start);\n-            if (elapsed > timeout) {\n-                rv = 0; /* timed out */\n-            } else {\n-                remaining = timeout - elapsed;\n-                tv.tv_sec = (PRInt32)PR_IntervalToSeconds(remaining);\n-                tv.tv_usec = (PRInt32)PR_IntervalToMicroseconds(\n-                    remaining - PR_SecondsToInterval(tv.tv_sec));\n-                goto retry;\n-            }\n-        }\n-    }\n-\n-    if (rv > 0) {\n-        _PR_setset(pr_rd, &rd);\n-        _PR_setset(pr_wr, &wr);\n-        _PR_setset(pr_ex, &ex);\n-    } else if (rv == -1) {\n-        pt_MapError(_PR_MD_MAP_SELECT_ERROR, errno);\n-    }\n-    return rv;\n+            remaining - PR_SecondsToInterval(tv.tv_sec));\n+        goto retry;\n+      }\n+    }\n+  }\n+\n+  if (rv > 0) {\n+    _PR_setset(pr_rd, &rd);\n+    _PR_setset(pr_wr, &wr);\n+    _PR_setset(pr_ex, &ex);\n+  } else if (rv == -1) {\n+    pt_MapError(_PR_MD_MAP_SELECT_ERROR, errno);\n+  }\n+  return rv;\n }\n #endif /* defined(_PR_PTHREADS) */\n \n #ifdef MOZ_UNICODE\n /* ================ UTF16 Interfaces ================================ */\n PR_IMPLEMENT(PRFileDesc*)\n-PR_OpenFileUTF16(const PRUnichar* name, PRIntn flags, PRIntn mode)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return NULL;\n+PR_OpenFileUTF16(const PRUnichar* name, PRIntn flags, PRIntn mode) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return NULL;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CloseDirUTF16(PRDir* dir)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+PR_IMPLEMENT(PRStatus) PR_CloseDirUTF16(PRDir* dir) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n \n-PR_IMPLEMENT(PRDirUTF16*)\n-PR_OpenDirUTF16(const PRUnichar* name)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return NULL;\n+PR_IMPLEMENT(PRDirUTF16*) PR_OpenDirUTF16(const PRUnichar* name) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return NULL;\n }\n \n PR_IMPLEMENT(PRDirEntryUTF16*)\n-PR_ReadDirUTF16(PRDirUTF16* dir, PRDirFlags flags)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return NULL;\n+PR_ReadDirUTF16(PRDirUTF16* dir, PRDirFlags flags) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return NULL;\n }\n \n PR_IMPLEMENT(PRStatus)\n-PR_GetFileInfo64UTF16(const PRUnichar* fn, PRFileInfo64* info)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+PR_GetFileInfo64UTF16(const PRUnichar* fn, PRFileInfo64* info) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n /* ================ UTF16 Interfaces ================================ */\n #endif /* MOZ_UNICODE */\ndiff --git a/nspr/pr/src/pthreads/ptmisc.c b/nspr/pr/src/pthreads/ptmisc.c\nindex 8ab29ed..c25f890 100644\n--- a/nspr/pr/src/pthreads/ptmisc.c\n+++ b/nspr/pr/src/pthreads/ptmisc.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,36 +10,28 @@\n \n #if defined(_PR_PTHREADS)\n \n-#include \"primpl.h\"\n+#  include \"primpl.h\"\n \n-#include <stdio.h>\n-#ifdef SOLARIS\n-#include <thread.h>\n-#endif\n+#  include <stdio.h>\n+#  ifdef SOLARIS\n+#    include <thread.h>\n+#  endif\n \n-#define PT_LOG(f)\n+#  define PT_LOG(f)\n \n-void\n-_PR_InitCPUs(void)\n-{\n-    PT_LOG(\"_PR_InitCPUs\")\n-}\n-void\n-_PR_InitStacks(void){ PT_LOG(\"_PR_InitStacks\") }\n-\n-PR_IMPLEMENT(void) PR_SetConcurrency(PRUintn numCPUs)\n-{\n-#ifdef SOLARIS\n-    thr_setconcurrency(numCPUs);\n-#else\n-    PT_LOG(\"PR_SetConcurrency\");\n-#endif\n+void _PR_InitCPUs(void) { PT_LOG(\"_PR_InitCPUs\") }\n+void _PR_InitStacks(void){PT_LOG(\"_PR_InitStacks\")}\n+\n+PR_IMPLEMENT(void) PR_SetConcurrency(PRUintn numCPUs) {\n+#  ifdef SOLARIS\n+  thr_setconcurrency(numCPUs);\n+#  else\n+  PT_LOG(\"PR_SetConcurrency\");\n+#  endif\n }\n \n-PR_IMPLEMENT(void)\n-PR_SetThreadRecycleMode(PRUint32 flag)\n-{\n-    PT_LOG(\"PR_SetThreadRecycleMode\")\n+PR_IMPLEMENT(void) PR_SetThreadRecycleMode(PRUint32 flag) {\n+  PT_LOG(\"PR_SetThreadRecycleMode\")\n }\n \n #endif /* defined(_PR_PTHREADS) */\ndiff --git a/nspr/pr/src/pthreads/ptsynch.c b/nspr/pr/src/pthreads/ptsynch.c\nindex 17d1ed0..9271dba 100644\n--- a/nspr/pr/src/pthreads/ptsynch.c\n+++ b/nspr/pr/src/pthreads/ptsynch.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,32 +11,30 @@\n \n #if defined(_PR_PTHREADS)\n \n-#include \"primpl.h\"\n-#include \"obsolete/prsem.h\"\n+#  include \"primpl.h\"\n+#  include \"obsolete/prsem.h\"\n \n-#include <string.h>\n-#include <pthread.h>\n-#include <sys/time.h>\n+#  include <string.h>\n+#  include <pthread.h>\n+#  include <sys/time.h>\n \n static pthread_mutexattr_t _pt_mattr;\n static pthread_condattr_t _pt_cvar_attr;\n \n-#if defined(DEBUG)\n+#  if defined(DEBUG)\n extern PTDebug pt_debug; /* this is shared between several modules */\n-#endif                   /* defined(DEBUG) */\n+#  endif                 /* defined(DEBUG) */\n \n-#if defined(FREEBSD)\n+#  if defined(FREEBSD)\n /*\n  * On older versions of FreeBSD, pthread_mutex_trylock returns EDEADLK.\n  * Newer versions return EBUSY.  We still need to support both.\n  */\n-static int\n-pt_pthread_mutex_is_locked(pthread_mutex_t* m)\n-{\n-    int rv = pthread_mutex_trylock(m);\n-    return (EBUSY == rv || EDEADLK == rv);\n+static int pt_pthread_mutex_is_locked(pthread_mutex_t* m) {\n+  int rv = pthread_mutex_trylock(m);\n+  return (EBUSY == rv || EDEADLK == rv);\n }\n-#endif\n+#  endif\n \n /**************************************************************/\n /**************************************************************/\n@@ -43,186 +42,172 @@ pt_pthread_mutex_is_locked(pthread_mutex_t* m)\n /**************************************************************/\n /**************************************************************/\n \n-void\n-_PR_InitLocks(void)\n-{\n-    int rv;\n-    rv = _PT_PTHREAD_MUTEXATTR_INIT(&_pt_mattr);\n-    PR_ASSERT(0 == rv);\n+void _PR_InitLocks(void) {\n+  int rv;\n+  rv = _PT_PTHREAD_MUTEXATTR_INIT(&_pt_mattr);\n+  PR_ASSERT(0 == rv);\n \n-#if (defined(LINUX) &&                                               \\\n-     (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))) || \\\n-    (defined(FREEBSD) && __FreeBSD_version > 700055)\n-    rv = pthread_mutexattr_settype(&_pt_mattr, PTHREAD_MUTEX_ADAPTIVE_NP);\n-    PR_ASSERT(0 == rv);\n-#endif\n+#  if (defined(LINUX) &&                                               \\\n+       (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))) || \\\n+      (defined(FREEBSD) && __FreeBSD_version > 700055)\n+  rv = pthread_mutexattr_settype(&_pt_mattr, PTHREAD_MUTEX_ADAPTIVE_NP);\n+  PR_ASSERT(0 == rv);\n+#  endif\n \n-    rv = _PT_PTHREAD_CONDATTR_INIT(&_pt_cvar_attr);\n-    PR_ASSERT(0 == rv);\n+  rv = _PT_PTHREAD_CONDATTR_INIT(&_pt_cvar_attr);\n+  PR_ASSERT(0 == rv);\n }\n \n-static void\n-pt_PostNotifies(PRLock* lock, PRBool unlock)\n-{\n-    PRIntn index, rv;\n-    _PT_Notified post;\n-    _PT_Notified *notified, *prev = NULL;\n-    /*\n-     * Time to actually notify any conditions that were affected\n-     * while the lock was held. Get a copy of the list that's in\n-     * the lock structure and then zero the original. If it's\n-     * linked to other such structures, we own that storage.\n-     */\n-    post = lock->notified; /* a safe copy; we own the lock */\n-\n-#if defined(DEBUG)\n-    memset(&lock->notified, 0, sizeof(_PT_Notified)); /* reset */\n-#else\n-    lock->notified.length = 0; /* these are really sufficient */\n-    lock->notified.link = NULL;\n-#endif\n-\n-    /* should (may) we release lock before notifying? */\n-    if (unlock) {\n-        rv = pthread_mutex_unlock(&lock->mutex);\n+static void pt_PostNotifies(PRLock* lock, PRBool unlock) {\n+  PRIntn index, rv;\n+  _PT_Notified post;\n+  _PT_Notified *notified, *prev = NULL;\n+  /*\n+   * Time to actually notify any conditions that were affected\n+   * while the lock was held. Get a copy of the list that's in\n+   * the lock structure and then zero the original. If it's\n+   * linked to other such structures, we own that storage.\n+   */\n+  post = lock->notified; /* a safe copy; we own the lock */\n+\n+#  if defined(DEBUG)\n+  memset(&lock->notified, 0, sizeof(_PT_Notified)); /* reset */\n+#  else\n+  lock->notified.length = 0; /* these are really sufficient */\n+  lock->notified.link = NULL;\n+#  endif\n+\n+  /* should (may) we release lock before notifying? */\n+  if (unlock) {\n+    rv = pthread_mutex_unlock(&lock->mutex);\n+    PR_ASSERT(0 == rv);\n+  }\n+\n+  notified = &post; /* this is where we start */\n+  do {\n+    for (index = 0; index < notified->length; ++index) {\n+      PRCondVar* cv = notified->cv[index].cv;\n+      PR_ASSERT(NULL != cv);\n+      PR_ASSERT(0 != notified->cv[index].times);\n+      if (-1 == notified->cv[index].times) {\n+        rv = pthread_cond_broadcast(&cv->cv);\n         PR_ASSERT(0 == rv);\n-    }\n-\n-    notified = &post; /* this is where we start */\n-    do {\n-        for (index = 0; index < notified->length; ++index) {\n-            PRCondVar* cv = notified->cv[index].cv;\n-            PR_ASSERT(NULL != cv);\n-            PR_ASSERT(0 != notified->cv[index].times);\n-            if (-1 == notified->cv[index].times) {\n-                rv = pthread_cond_broadcast(&cv->cv);\n-                PR_ASSERT(0 == rv);\n-            } else {\n-                while (notified->cv[index].times-- > 0) {\n-                    rv = pthread_cond_signal(&cv->cv);\n-                    PR_ASSERT(0 == rv);\n-                }\n-            }\n-#if defined(DEBUG)\n-            pt_debug.cvars_notified += 1;\n-            if (0 > PR_ATOMIC_DECREMENT(&cv->notify_pending)) {\n-                pt_debug.delayed_cv_deletes += 1;\n-                PR_DestroyCondVar(cv);\n-            }\n-#else  /* defined(DEBUG) */\n-            if (0 > PR_ATOMIC_DECREMENT(&cv->notify_pending)) {\n-                PR_DestroyCondVar(cv);\n-            }\n-#endif /* defined(DEBUG) */\n+      } else {\n+        while (notified->cv[index].times-- > 0) {\n+          rv = pthread_cond_signal(&cv->cv);\n+          PR_ASSERT(0 == rv);\n         }\n-        prev = notified;\n-        notified = notified->link;\n-        if (&post != prev) {\n-            PR_DELETE(prev);\n-        }\n-    } while (NULL != notified);\n+      }\n+#  if defined(DEBUG)\n+      pt_debug.cvars_notified += 1;\n+      if (0 > PR_ATOMIC_DECREMENT(&cv->notify_pending)) {\n+        pt_debug.delayed_cv_deletes += 1;\n+        PR_DestroyCondVar(cv);\n+      }\n+#  else  /* defined(DEBUG) */\n+      if (0 > PR_ATOMIC_DECREMENT(&cv->notify_pending)) {\n+        PR_DestroyCondVar(cv);\n+      }\n+#  endif /* defined(DEBUG) */\n+    }\n+    prev = notified;\n+    notified = notified->link;\n+    if (&post != prev) {\n+      PR_DELETE(prev);\n+    }\n+  } while (NULL != notified);\n } /* pt_PostNotifies */\n \n-PR_IMPLEMENT(PRLock*)\n-PR_NewLock(void)\n-{\n-    PRIntn rv;\n-    PRLock* lock;\n+PR_IMPLEMENT(PRLock*) PR_NewLock(void) {\n+  PRIntn rv;\n+  PRLock* lock;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    lock = PR_NEWZAP(PRLock);\n-    if (lock != NULL) {\n-        rv = _PT_PTHREAD_MUTEX_INIT(lock->mutex, _pt_mattr);\n-        PR_ASSERT(0 == rv);\n-    }\n-#if defined(DEBUG)\n-    pt_debug.locks_created += 1;\n-#endif\n-    return lock;\n+  lock = PR_NEWZAP(PRLock);\n+  if (lock != NULL) {\n+    rv = _PT_PTHREAD_MUTEX_INIT(lock->mutex, _pt_mattr);\n+    PR_ASSERT(0 == rv);\n+  }\n+#  if defined(DEBUG)\n+  pt_debug.locks_created += 1;\n+#  endif\n+  return lock;\n } /* PR_NewLock */\n \n-PR_IMPLEMENT(void)\n-PR_DestroyLock(PRLock* lock)\n-{\n-    PRIntn rv;\n-    PR_ASSERT(NULL != lock);\n-    PR_ASSERT(PR_FALSE == lock->locked);\n-    PR_ASSERT(0 == lock->notified.length);\n-    PR_ASSERT(NULL == lock->notified.link);\n-    rv = pthread_mutex_destroy(&lock->mutex);\n-    PR_ASSERT(0 == rv);\n-#if defined(DEBUG)\n-    memset(lock, 0xaf, sizeof(PRLock));\n-    pt_debug.locks_destroyed += 1;\n-#endif\n-    PR_Free(lock);\n+PR_IMPLEMENT(void) PR_DestroyLock(PRLock* lock) {\n+  PRIntn rv;\n+  PR_ASSERT(NULL != lock);\n+  PR_ASSERT(PR_FALSE == lock->locked);\n+  PR_ASSERT(0 == lock->notified.length);\n+  PR_ASSERT(NULL == lock->notified.link);\n+  rv = pthread_mutex_destroy(&lock->mutex);\n+  PR_ASSERT(0 == rv);\n+#  if defined(DEBUG)\n+  memset(lock, 0xaf, sizeof(PRLock));\n+  pt_debug.locks_destroyed += 1;\n+#  endif\n+  PR_Free(lock);\n } /* PR_DestroyLock */\n \n-PR_IMPLEMENT(void)\n-PR_Lock(PRLock* lock)\n-{\n-    /* Nb: PR_Lock must not call PR_GetCurrentThread to access the |id| or\n-     * |tid| field of the current thread's PRThread structure because\n-     * _pt_root calls PR_Lock before setting thred->id and thred->tid. */\n-    PRIntn rv;\n-    PR_ASSERT(lock != NULL);\n-    rv = pthread_mutex_lock(&lock->mutex);\n-    PR_ASSERT(0 == rv);\n-    PR_ASSERT(0 == lock->notified.length);\n-    PR_ASSERT(NULL == lock->notified.link);\n-    PR_ASSERT(PR_FALSE == lock->locked);\n-    /* Nb: the order of the next two statements is not critical to\n-     * the correctness of PR_AssertCurrentThreadOwnsLock(), but\n-     * this particular order makes the assertion more likely to\n-     * catch errors. */\n-    lock->owner = pthread_self();\n-    lock->locked = PR_TRUE;\n-#if defined(DEBUG)\n-    pt_debug.locks_acquired += 1;\n-#endif\n+PR_IMPLEMENT(void) PR_Lock(PRLock* lock) {\n+  /* Nb: PR_Lock must not call PR_GetCurrentThread to access the |id| or\n+   * |tid| field of the current thread's PRThread structure because\n+   * _pt_root calls PR_Lock before setting thred->id and thred->tid. */\n+  PRIntn rv;\n+  PR_ASSERT(lock != NULL);\n+  rv = pthread_mutex_lock(&lock->mutex);\n+  PR_ASSERT(0 == rv);\n+  PR_ASSERT(0 == lock->notified.length);\n+  PR_ASSERT(NULL == lock->notified.link);\n+  PR_ASSERT(PR_FALSE == lock->locked);\n+  /* Nb: the order of the next two statements is not critical to\n+   * the correctness of PR_AssertCurrentThreadOwnsLock(), but\n+   * this particular order makes the assertion more likely to\n+   * catch errors. */\n+  lock->owner = pthread_self();\n+  lock->locked = PR_TRUE;\n+#  if defined(DEBUG)\n+  pt_debug.locks_acquired += 1;\n+#  endif\n } /* PR_Lock */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Unlock(PRLock* lock)\n-{\n-    pthread_t self = pthread_self();\n-    PRIntn rv;\n-\n-    PR_ASSERT(lock != NULL);\n-    PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(lock->mutex));\n-    PR_ASSERT(PR_TRUE == lock->locked);\n-    PR_ASSERT(pthread_equal(lock->owner, self));\n-\n-    if (!lock->locked || !pthread_equal(lock->owner, self)) {\n-        return PR_FAILURE;\n-    }\n+PR_IMPLEMENT(PRStatus) PR_Unlock(PRLock* lock) {\n+  pthread_t self = pthread_self();\n+  PRIntn rv;\n \n-    lock->locked = PR_FALSE;\n-    if (0 == lock->notified.length) /* shortcut */\n-    {\n-        rv = pthread_mutex_unlock(&lock->mutex);\n-        PR_ASSERT(0 == rv);\n-    } else {\n-        pt_PostNotifies(lock, PR_TRUE);\n-    }\n+  PR_ASSERT(lock != NULL);\n+  PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(lock->mutex));\n+  PR_ASSERT(PR_TRUE == lock->locked);\n+  PR_ASSERT(pthread_equal(lock->owner, self));\n+\n+  if (!lock->locked || !pthread_equal(lock->owner, self)) {\n+    return PR_FAILURE;\n+  }\n \n-#if defined(DEBUG)\n-    pt_debug.locks_released += 1;\n-#endif\n-    return PR_SUCCESS;\n+  lock->locked = PR_FALSE;\n+  if (0 == lock->notified.length) /* shortcut */\n+  {\n+    rv = pthread_mutex_unlock(&lock->mutex);\n+    PR_ASSERT(0 == rv);\n+  } else {\n+    pt_PostNotifies(lock, PR_TRUE);\n+  }\n+\n+#  if defined(DEBUG)\n+  pt_debug.locks_released += 1;\n+#  endif\n+  return PR_SUCCESS;\n } /* PR_Unlock */\n \n-PR_IMPLEMENT(void)\n-PR_AssertCurrentThreadOwnsLock(PRLock* lock)\n-{\n-    /* Nb: the order of the |locked| and |owner==me| checks is not critical\n-     * to the correctness of PR_AssertCurrentThreadOwnsLock(), but\n-     * this particular order makes the assertion more likely to\n-     * catch errors. */\n-    PR_ASSERT(lock->locked && pthread_equal(lock->owner, pthread_self()));\n+PR_IMPLEMENT(void) PR_AssertCurrentThreadOwnsLock(PRLock* lock) {\n+  /* Nb: the order of the |locked| and |owner==me| checks is not critical\n+   * to the correctness of PR_AssertCurrentThreadOwnsLock(), but\n+   * this particular order makes the assertion more likely to\n+   * catch errors. */\n+  PR_ASSERT(lock->locked && pthread_equal(lock->owner, pthread_self()));\n }\n \n /**************************************************************/\n@@ -236,35 +221,33 @@ PR_AssertCurrentThreadOwnsLock(PRLock* lock)\n  * It's moderately ugly, so it's defined here and called in a\n  * couple of places.\n  */\n-#define PT_NANOPERMICRO 1000UL\n-#define PT_BILLION 1000000000UL\n-\n-static PRIntn\n-pt_TimedWait(pthread_cond_t* cv, pthread_mutex_t* ml,\n-             PRIntervalTime timeout)\n-{\n-    int rv;\n-    struct timeval now;\n-    struct timespec tmo;\n-    PRUint32 ticks = PR_TicksPerSecond();\n-\n-    tmo.tv_sec = (PRInt32)(timeout / ticks);\n-    tmo.tv_nsec = (PRInt32)(timeout - (tmo.tv_sec * ticks));\n-    tmo.tv_nsec =\n-        (PRInt32)PR_IntervalToMicroseconds(PT_NANOPERMICRO * tmo.tv_nsec);\n-\n-    /* pthreads wants this in absolute time, off we go ... */\n-    (void)GETTIMEOFDAY(&now);\n-    /* that one's usecs, this one's nsecs - grrrr! */\n-    tmo.tv_sec += now.tv_sec;\n-    tmo.tv_nsec += (PT_NANOPERMICRO * now.tv_usec);\n-    tmo.tv_sec += tmo.tv_nsec / PT_BILLION;\n-    tmo.tv_nsec %= PT_BILLION;\n-\n-    rv = pthread_cond_timedwait(cv, ml, &tmo);\n-\n-    /* NSPR doesn't report timeouts */\n-    return (rv == ETIMEDOUT) ? 0 : rv;\n+#  define PT_NANOPERMICRO 1000UL\n+#  define PT_BILLION 1000000000UL\n+\n+static PRIntn pt_TimedWait(pthread_cond_t* cv, pthread_mutex_t* ml,\n+                           PRIntervalTime timeout) {\n+  int rv;\n+  struct timeval now;\n+  struct timespec tmo;\n+  PRUint32 ticks = PR_TicksPerSecond();\n+\n+  tmo.tv_sec = (PRInt32)(timeout / ticks);\n+  tmo.tv_nsec = (PRInt32)(timeout - (tmo.tv_sec * ticks));\n+  tmo.tv_nsec =\n+      (PRInt32)PR_IntervalToMicroseconds(PT_NANOPERMICRO * tmo.tv_nsec);\n+\n+  /* pthreads wants this in absolute time, off we go ... */\n+  (void)GETTIMEOFDAY(&now);\n+  /* that one's usecs, this one's nsecs - grrrr! */\n+  tmo.tv_sec += now.tv_sec;\n+  tmo.tv_nsec += (PT_NANOPERMICRO * now.tv_usec);\n+  tmo.tv_sec += tmo.tv_nsec / PT_BILLION;\n+  tmo.tv_nsec %= PT_BILLION;\n+\n+  rv = pthread_cond_timedwait(cv, ml, &tmo);\n+\n+  /* NSPR doesn't report timeouts */\n+  return (rv == ETIMEDOUT) ? 0 : rv;\n } /* pt_TimedWait */\n \n /*\n@@ -272,165 +255,153 @@ pt_TimedWait(pthread_cond_t* cv, pthread_mutex_t* ml,\n  * actual notification is done when the lock is released so that\n  * MP systems don't contend for a lock that they can't have.\n  */\n-static void\n-pt_PostNotifyToCvar(PRCondVar* cvar, PRBool broadcast)\n-{\n-    PRIntn index = 0;\n-    _PT_Notified* notified = &cvar->lock->notified;\n-\n-    PR_ASSERT(PR_TRUE == cvar->lock->locked);\n-    PR_ASSERT(pthread_equal(cvar->lock->owner, pthread_self()));\n-    PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex));\n-\n-    while (1) {\n-        for (index = 0; index < notified->length; ++index) {\n-            if (notified->cv[index].cv == cvar) {\n-                if (broadcast) {\n-                    notified->cv[index].times = -1;\n-                } else if (-1 != notified->cv[index].times) {\n-                    notified->cv[index].times += 1;\n-                }\n-                return; /* we're finished */\n-            }\n-        }\n-        /* if not full, enter new CV in this array */\n-        if (notified->length < PT_CV_NOTIFIED_LENGTH) {\n-            break;\n+static void pt_PostNotifyToCvar(PRCondVar* cvar, PRBool broadcast) {\n+  PRIntn index = 0;\n+  _PT_Notified* notified = &cvar->lock->notified;\n+\n+  PR_ASSERT(PR_TRUE == cvar->lock->locked);\n+  PR_ASSERT(pthread_equal(cvar->lock->owner, pthread_self()));\n+  PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex));\n+\n+  while (1) {\n+    for (index = 0; index < notified->length; ++index) {\n+      if (notified->cv[index].cv == cvar) {\n+        if (broadcast) {\n+          notified->cv[index].times = -1;\n+        } else if (-1 != notified->cv[index].times) {\n+          notified->cv[index].times += 1;\n         }\n-\n-        /* if there's no link, create an empty array and link it */\n-        if (NULL == notified->link) {\n-            notified->link = PR_NEWZAP(_PT_Notified);\n-        }\n-        notified = notified->link;\n+        return; /* we're finished */\n+      }\n     }\n-\n-    /* A brand new entry in the array */\n-    (void)PR_ATOMIC_INCREMENT(&cvar->notify_pending);\n-    notified->cv[index].times = (broadcast) ? -1 : 1;\n-    notified->cv[index].cv = cvar;\n-    notified->length += 1;\n-} /* pt_PostNotifyToCvar */\n-\n-PR_IMPLEMENT(PRCondVar*)\n-PR_NewCondVar(PRLock* lock)\n-{\n-    PRCondVar* cv = PR_NEW(PRCondVar);\n-    PR_ASSERT(lock != NULL);\n-    if (cv != NULL) {\n-        int rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr);\n-        PR_ASSERT(0 == rv);\n-        if (0 == rv) {\n-            cv->lock = lock;\n-            cv->notify_pending = 0;\n-#if defined(DEBUG)\n-            pt_debug.cvars_created += 1;\n-#endif\n-        } else {\n-            PR_DELETE(cv);\n-            cv = NULL;\n-        }\n+    /* if not full, enter new CV in this array */\n+    if (notified->length < PT_CV_NOTIFIED_LENGTH) {\n+      break;\n     }\n-    return cv;\n-} /* PR_NewCondVar */\n \n-PR_IMPLEMENT(void)\n-PR_DestroyCondVar(PRCondVar* cvar)\n-{\n-    if (0 > PR_ATOMIC_DECREMENT(&cvar->notify_pending)) {\n-        PRIntn rv = pthread_cond_destroy(&cvar->cv);\n-#if defined(DEBUG)\n-        PR_ASSERT(0 == rv);\n-        memset(cvar, 0xaf, sizeof(PRCondVar));\n-        pt_debug.cvars_destroyed += 1;\n-#else\n-        (void)rv;\n-#endif\n-        PR_Free(cvar);\n-    }\n-} /* PR_DestroyCondVar */\n-\n-PR_IMPLEMENT(PRStatus)\n-PR_WaitCondVar(PRCondVar* cvar, PRIntervalTime timeout)\n-{\n-    PRIntn rv;\n-    PRThread* thred = PR_GetCurrentThread();\n-\n-    PR_ASSERT(cvar != NULL);\n-    /* We'd better be locked */\n-    PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex));\n-    PR_ASSERT(PR_TRUE == cvar->lock->locked);\n-    /* and it better be by us */\n-    PR_ASSERT(pthread_equal(cvar->lock->owner, pthread_self()));\n-\n-    if (_PT_THREAD_INTERRUPTED(thred)) {\n-        goto aborted;\n+    /* if there's no link, create an empty array and link it */\n+    if (NULL == notified->link) {\n+      notified->link = PR_NEWZAP(_PT_Notified);\n     }\n+    notified = notified->link;\n+  }\n+\n+  /* A brand new entry in the array */\n+  (void)PR_ATOMIC_INCREMENT(&cvar->notify_pending);\n+  notified->cv[index].times = (broadcast) ? -1 : 1;\n+  notified->cv[index].cv = cvar;\n+  notified->length += 1;\n+} /* pt_PostNotifyToCvar */\n \n-    /*\n-     * The thread waiting is used for PR_Interrupt\n-     */\n-    thred->waiting = cvar; /* this is where we're waiting */\n-\n-    /*\n-     * If we have pending notifies, post them now.\n-     *\n-     * This is not optimal. We're going to post these notifies\n-     * while we're holding the lock. That means on MP systems\n-     * that they are going to collide for the lock that we will\n-     * hold until we actually wait.\n-     */\n-    if (0 != cvar->lock->notified.length) {\n-        pt_PostNotifies(cvar->lock, PR_FALSE);\n-    }\n-\n-    /*\n-     * We're surrendering the lock, so clear out the locked field.\n-     */\n-    cvar->lock->locked = PR_FALSE;\n-\n-    if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-        rv = pthread_cond_wait(&cvar->cv, &cvar->lock->mutex);\n+PR_IMPLEMENT(PRCondVar*) PR_NewCondVar(PRLock* lock) {\n+  PRCondVar* cv = PR_NEW(PRCondVar);\n+  PR_ASSERT(lock != NULL);\n+  if (cv != NULL) {\n+    int rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr);\n+    PR_ASSERT(0 == rv);\n+    if (0 == rv) {\n+      cv->lock = lock;\n+      cv->notify_pending = 0;\n+#  if defined(DEBUG)\n+      pt_debug.cvars_created += 1;\n+#  endif\n     } else {\n-        rv = pt_TimedWait(&cvar->cv, &cvar->lock->mutex, timeout);\n+      PR_DELETE(cv);\n+      cv = NULL;\n     }\n+  }\n+  return cv;\n+} /* PR_NewCondVar */\n \n-    /* We just got the lock back - this better be empty */\n-    PR_ASSERT(PR_FALSE == cvar->lock->locked);\n-    cvar->lock->locked = PR_TRUE;\n-    cvar->lock->owner = pthread_self();\n+PR_IMPLEMENT(void) PR_DestroyCondVar(PRCondVar* cvar) {\n+  if (0 > PR_ATOMIC_DECREMENT(&cvar->notify_pending)) {\n+    PRIntn rv = pthread_cond_destroy(&cvar->cv);\n+#  if defined(DEBUG)\n+    PR_ASSERT(0 == rv);\n+    memset(cvar, 0xaf, sizeof(PRCondVar));\n+    pt_debug.cvars_destroyed += 1;\n+#  else\n+    (void)rv;\n+#  endif\n+    PR_Free(cvar);\n+  }\n+} /* PR_DestroyCondVar */\n \n-    PR_ASSERT(0 == cvar->lock->notified.length);\n-    thred->waiting = NULL; /* and now we're not */\n-    if (_PT_THREAD_INTERRUPTED(thred)) {\n-        goto aborted;\n-    }\n-    if (rv != 0) {\n-        _PR_MD_MAP_DEFAULT_ERROR(rv);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PRCondVar* cvar, PRIntervalTime timeout) {\n+  PRIntn rv;\n+  PRThread* thred = PR_GetCurrentThread();\n+\n+  PR_ASSERT(cvar != NULL);\n+  /* We'd better be locked */\n+  PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex));\n+  PR_ASSERT(PR_TRUE == cvar->lock->locked);\n+  /* and it better be by us */\n+  PR_ASSERT(pthread_equal(cvar->lock->owner, pthread_self()));\n+\n+  if (_PT_THREAD_INTERRUPTED(thred)) {\n+    goto aborted;\n+  }\n+\n+  /*\n+   * The thread waiting is used for PR_Interrupt\n+   */\n+  thred->waiting = cvar; /* this is where we're waiting */\n+\n+  /*\n+   * If we have pending notifies, post them now.\n+   *\n+   * This is not optimal. We're going to post these notifies\n+   * while we're holding the lock. That means on MP systems\n+   * that they are going to collide for the lock that we will\n+   * hold until we actually wait.\n+   */\n+  if (0 != cvar->lock->notified.length) {\n+    pt_PostNotifies(cvar->lock, PR_FALSE);\n+  }\n+\n+  /*\n+   * We're surrendering the lock, so clear out the locked field.\n+   */\n+  cvar->lock->locked = PR_FALSE;\n+\n+  if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+    rv = pthread_cond_wait(&cvar->cv, &cvar->lock->mutex);\n+  } else {\n+    rv = pt_TimedWait(&cvar->cv, &cvar->lock->mutex, timeout);\n+  }\n+\n+  /* We just got the lock back - this better be empty */\n+  PR_ASSERT(PR_FALSE == cvar->lock->locked);\n+  cvar->lock->locked = PR_TRUE;\n+  cvar->lock->owner = pthread_self();\n+\n+  PR_ASSERT(0 == cvar->lock->notified.length);\n+  thred->waiting = NULL; /* and now we're not */\n+  if (_PT_THREAD_INTERRUPTED(thred)) {\n+    goto aborted;\n+  }\n+  if (rv != 0) {\n+    _PR_MD_MAP_DEFAULT_ERROR(rv);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n \n aborted:\n-    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-    thred->state &= ~PT_THREAD_ABORTED;\n-    return PR_FAILURE;\n+  PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+  thred->state &= ~PT_THREAD_ABORTED;\n+  return PR_FAILURE;\n } /* PR_WaitCondVar */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_NotifyCondVar(PRCondVar* cvar)\n-{\n-    PR_ASSERT(cvar != NULL);\n-    pt_PostNotifyToCvar(cvar, PR_FALSE);\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_NotifyCondVar(PRCondVar* cvar) {\n+  PR_ASSERT(cvar != NULL);\n+  pt_PostNotifyToCvar(cvar, PR_FALSE);\n+  return PR_SUCCESS;\n } /* PR_NotifyCondVar */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_NotifyAllCondVar(PRCondVar* cvar)\n-{\n-    PR_ASSERT(cvar != NULL);\n-    pt_PostNotifyToCvar(cvar, PR_TRUE);\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_NotifyAllCondVar(PRCondVar* cvar) {\n+  PR_ASSERT(cvar != NULL);\n+  pt_PostNotifyToCvar(cvar, PR_TRUE);\n+  return PR_SUCCESS;\n } /* PR_NotifyAllCondVar */\n \n /**************************************************************/\n@@ -444,304 +415,280 @@ PR_NotifyAllCondVar(PRCondVar* cvar)\n  * when the monitor is fully exited so that MP systems don't contend for a\n  * monitor that they can't enter.\n  */\n-static void\n-pt_PostNotifyToMonitor(PRMonitor* mon, PRBool broadcast)\n-{\n-    PR_ASSERT(NULL != mon);\n-    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mon);\n-\n-    /* mon->notifyTimes is protected by the monitor, so we don't need to\n-     * acquire mon->lock.\n-     */\n-    if (broadcast) {\n-        mon->notifyTimes = -1;\n-    } else if (-1 != mon->notifyTimes) {\n-        mon->notifyTimes += 1;\n-    }\n+static void pt_PostNotifyToMonitor(PRMonitor* mon, PRBool broadcast) {\n+  PR_ASSERT(NULL != mon);\n+  PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mon);\n+\n+  /* mon->notifyTimes is protected by the monitor, so we don't need to\n+   * acquire mon->lock.\n+   */\n+  if (broadcast) {\n+    mon->notifyTimes = -1;\n+  } else if (-1 != mon->notifyTimes) {\n+    mon->notifyTimes += 1;\n+  }\n } /* pt_PostNotifyToMonitor */\n \n-static void\n-pt_PostNotifiesFromMonitor(pthread_cond_t* cv, PRIntn times)\n-{\n-    PRIntn rv;\n-\n-    /*\n-     * Time to actually notify any waits that were affected while the monitor\n-     * was entered.\n-     */\n-    PR_ASSERT(NULL != cv);\n-    PR_ASSERT(0 != times);\n-    if (-1 == times) {\n-        rv = pthread_cond_broadcast(cv);\n-        PR_ASSERT(0 == rv);\n-    } else {\n-        while (times-- > 0) {\n-            rv = pthread_cond_signal(cv);\n-            PR_ASSERT(0 == rv);\n-        }\n-    }\n-} /* pt_PostNotifiesFromMonitor */\n-\n-PR_IMPLEMENT(PRMonitor*)\n-PR_NewMonitor(void)\n-{\n-    PRMonitor* mon;\n-    int rv;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    mon = PR_NEWZAP(PRMonitor);\n-    if (mon == NULL) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n-    }\n-\n-    rv = _PT_PTHREAD_MUTEX_INIT(mon->lock, _pt_mattr);\n+static void pt_PostNotifiesFromMonitor(pthread_cond_t* cv, PRIntn times) {\n+  PRIntn rv;\n+\n+  /*\n+   * Time to actually notify any waits that were affected while the monitor\n+   * was entered.\n+   */\n+  PR_ASSERT(NULL != cv);\n+  PR_ASSERT(0 != times);\n+  if (-1 == times) {\n+    rv = pthread_cond_broadcast(cv);\n     PR_ASSERT(0 == rv);\n-    if (0 != rv) {\n-        goto error1;\n+  } else {\n+    while (times-- > 0) {\n+      rv = pthread_cond_signal(cv);\n+      PR_ASSERT(0 == rv);\n     }\n+  }\n+} /* pt_PostNotifiesFromMonitor */\n \n-    _PT_PTHREAD_INVALIDATE_THR_HANDLE(mon->owner);\n-\n-    rv = _PT_PTHREAD_COND_INIT(mon->entryCV, _pt_cvar_attr);\n-    PR_ASSERT(0 == rv);\n-    if (0 != rv) {\n-        goto error2;\n-    }\n+PR_IMPLEMENT(PRMonitor*) PR_NewMonitor(void) {\n+  PRMonitor* mon;\n+  int rv;\n \n-    rv = _PT_PTHREAD_COND_INIT(mon->waitCV, _pt_cvar_attr);\n-    PR_ASSERT(0 == rv);\n-    if (0 != rv) {\n-        goto error3;\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    mon->notifyTimes = 0;\n-    mon->entryCount = 0;\n-    mon->refCount = 1;\n-    mon->name = NULL;\n-    return mon;\n+  mon = PR_NEWZAP(PRMonitor);\n+  if (mon == NULL) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n+\n+  rv = _PT_PTHREAD_MUTEX_INIT(mon->lock, _pt_mattr);\n+  PR_ASSERT(0 == rv);\n+  if (0 != rv) {\n+    goto error1;\n+  }\n+\n+  _PT_PTHREAD_INVALIDATE_THR_HANDLE(mon->owner);\n+\n+  rv = _PT_PTHREAD_COND_INIT(mon->entryCV, _pt_cvar_attr);\n+  PR_ASSERT(0 == rv);\n+  if (0 != rv) {\n+    goto error2;\n+  }\n+\n+  rv = _PT_PTHREAD_COND_INIT(mon->waitCV, _pt_cvar_attr);\n+  PR_ASSERT(0 == rv);\n+  if (0 != rv) {\n+    goto error3;\n+  }\n+\n+  mon->notifyTimes = 0;\n+  mon->entryCount = 0;\n+  mon->refCount = 1;\n+  mon->name = NULL;\n+  return mon;\n \n error3:\n-    pthread_cond_destroy(&mon->entryCV);\n+  pthread_cond_destroy(&mon->entryCV);\n error2:\n-    pthread_mutex_destroy(&mon->lock);\n+  pthread_mutex_destroy(&mon->lock);\n error1:\n-    PR_Free(mon);\n-    _PR_MD_MAP_DEFAULT_ERROR(rv);\n-    return NULL;\n+  PR_Free(mon);\n+  _PR_MD_MAP_DEFAULT_ERROR(rv);\n+  return NULL;\n } /* PR_NewMonitor */\n \n-PR_IMPLEMENT(PRMonitor*)\n-PR_NewNamedMonitor(const char* name)\n-{\n-    PRMonitor* mon = PR_NewMonitor();\n-    if (mon) {\n-        mon->name = name;\n-    }\n-    return mon;\n+PR_IMPLEMENT(PRMonitor*) PR_NewNamedMonitor(const char* name) {\n+  PRMonitor* mon = PR_NewMonitor();\n+  if (mon) {\n+    mon->name = name;\n+  }\n+  return mon;\n }\n \n-PR_IMPLEMENT(void)\n-PR_DestroyMonitor(PRMonitor* mon)\n-{\n-    int rv;\n+PR_IMPLEMENT(void) PR_DestroyMonitor(PRMonitor* mon) {\n+  int rv;\n \n-    PR_ASSERT(mon != NULL);\n-    if (PR_ATOMIC_DECREMENT(&mon->refCount) == 0) {\n-        rv = pthread_cond_destroy(&mon->waitCV);\n-        PR_ASSERT(0 == rv);\n-        rv = pthread_cond_destroy(&mon->entryCV);\n-        PR_ASSERT(0 == rv);\n-        rv = pthread_mutex_destroy(&mon->lock);\n-        PR_ASSERT(0 == rv);\n-#if defined(DEBUG)\n-        memset(mon, 0xaf, sizeof(PRMonitor));\n-#endif\n-        PR_Free(mon);\n-    }\n+  PR_ASSERT(mon != NULL);\n+  if (PR_ATOMIC_DECREMENT(&mon->refCount) == 0) {\n+    rv = pthread_cond_destroy(&mon->waitCV);\n+    PR_ASSERT(0 == rv);\n+    rv = pthread_cond_destroy(&mon->entryCV);\n+    PR_ASSERT(0 == rv);\n+    rv = pthread_mutex_destroy(&mon->lock);\n+    PR_ASSERT(0 == rv);\n+#  if defined(DEBUG)\n+    memset(mon, 0xaf, sizeof(PRMonitor));\n+#  endif\n+    PR_Free(mon);\n+  }\n } /* PR_DestroyMonitor */\n \n /* The GC uses this; it is quite arguably a bad interface.  I'm just\n  * duplicating it for now - XXXMB\n  */\n-PR_IMPLEMENT(PRIntn)\n-PR_GetMonitorEntryCount(PRMonitor* mon)\n-{\n-    pthread_t self = pthread_self();\n-    PRIntn rv;\n-    PRIntn count = 0;\n-\n-    rv = pthread_mutex_lock(&mon->lock);\n-    PR_ASSERT(0 == rv);\n-    if (pthread_equal(mon->owner, self)) {\n-        count = mon->entryCount;\n-    }\n-    rv = pthread_mutex_unlock(&mon->lock);\n-    PR_ASSERT(0 == rv);\n-    return count;\n+PR_IMPLEMENT(PRIntn) PR_GetMonitorEntryCount(PRMonitor* mon) {\n+  pthread_t self = pthread_self();\n+  PRIntn rv;\n+  PRIntn count = 0;\n+\n+  rv = pthread_mutex_lock(&mon->lock);\n+  PR_ASSERT(0 == rv);\n+  if (pthread_equal(mon->owner, self)) {\n+    count = mon->entryCount;\n+  }\n+  rv = pthread_mutex_unlock(&mon->lock);\n+  PR_ASSERT(0 == rv);\n+  return count;\n }\n \n-PR_IMPLEMENT(void)\n-PR_AssertCurrentThreadInMonitor(PRMonitor* mon)\n-{\n-#if defined(DEBUG) || defined(FORCE_PR_ASSERT)\n-    PRIntn rv;\n+PR_IMPLEMENT(void) PR_AssertCurrentThreadInMonitor(PRMonitor* mon) {\n+#  if defined(DEBUG) || defined(FORCE_PR_ASSERT)\n+  PRIntn rv;\n \n-    rv = pthread_mutex_lock(&mon->lock);\n-    PR_ASSERT(0 == rv);\n-    PR_ASSERT(mon->entryCount != 0 && pthread_equal(mon->owner, pthread_self()));\n-    rv = pthread_mutex_unlock(&mon->lock);\n-    PR_ASSERT(0 == rv);\n-#endif\n+  rv = pthread_mutex_lock(&mon->lock);\n+  PR_ASSERT(0 == rv);\n+  PR_ASSERT(mon->entryCount != 0 && pthread_equal(mon->owner, pthread_self()));\n+  rv = pthread_mutex_unlock(&mon->lock);\n+  PR_ASSERT(0 == rv);\n+#  endif\n }\n \n-PR_IMPLEMENT(void)\n-PR_EnterMonitor(PRMonitor* mon)\n-{\n-    pthread_t self = pthread_self();\n-    PRIntn rv;\n+PR_IMPLEMENT(void) PR_EnterMonitor(PRMonitor* mon) {\n+  pthread_t self = pthread_self();\n+  PRIntn rv;\n \n-    PR_ASSERT(mon != NULL);\n-    rv = pthread_mutex_lock(&mon->lock);\n-    PR_ASSERT(0 == rv);\n-    if (mon->entryCount != 0) {\n-        if (pthread_equal(mon->owner, self)) {\n-            goto done;\n-        }\n-        while (mon->entryCount != 0) {\n-            rv = pthread_cond_wait(&mon->entryCV, &mon->lock);\n-            PR_ASSERT(0 == rv);\n-        }\n+  PR_ASSERT(mon != NULL);\n+  rv = pthread_mutex_lock(&mon->lock);\n+  PR_ASSERT(0 == rv);\n+  if (mon->entryCount != 0) {\n+    if (pthread_equal(mon->owner, self)) {\n+      goto done;\n     }\n-    /* and now I have the monitor */\n-    PR_ASSERT(0 == mon->notifyTimes);\n-    PR_ASSERT(_PT_PTHREAD_THR_HANDLE_IS_INVALID(mon->owner));\n-    _PT_PTHREAD_COPY_THR_HANDLE(self, mon->owner);\n+    while (mon->entryCount != 0) {\n+      rv = pthread_cond_wait(&mon->entryCV, &mon->lock);\n+      PR_ASSERT(0 == rv);\n+    }\n+  }\n+  /* and now I have the monitor */\n+  PR_ASSERT(0 == mon->notifyTimes);\n+  PR_ASSERT(_PT_PTHREAD_THR_HANDLE_IS_INVALID(mon->owner));\n+  _PT_PTHREAD_COPY_THR_HANDLE(self, mon->owner);\n \n done:\n-    mon->entryCount += 1;\n-    rv = pthread_mutex_unlock(&mon->lock);\n-    PR_ASSERT(0 == rv);\n+  mon->entryCount += 1;\n+  rv = pthread_mutex_unlock(&mon->lock);\n+  PR_ASSERT(0 == rv);\n } /* PR_EnterMonitor */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_ExitMonitor(PRMonitor* mon)\n-{\n-    pthread_t self = pthread_self();\n-    PRIntn rv;\n-    PRBool notifyEntryWaiter = PR_FALSE;\n-    PRIntn notifyTimes = 0;\n-\n-    PR_ASSERT(mon != NULL);\n-    rv = pthread_mutex_lock(&mon->lock);\n-    PR_ASSERT(0 == rv);\n-    /* the entries should be > 0 and we'd better be the owner */\n-    PR_ASSERT(mon->entryCount > 0);\n-    PR_ASSERT(pthread_equal(mon->owner, self));\n-    if (mon->entryCount == 0 || !pthread_equal(mon->owner, self)) {\n-        rv = pthread_mutex_unlock(&mon->lock);\n-        PR_ASSERT(0 == rv);\n-        return PR_FAILURE;\n-    }\n-\n-    mon->entryCount -= 1; /* reduce by one */\n-    if (mon->entryCount == 0) {\n-        /* and if it transitioned to zero - notify an entry waiter */\n-        /* make the owner unknown */\n-        _PT_PTHREAD_INVALIDATE_THR_HANDLE(mon->owner);\n-        notifyEntryWaiter = PR_TRUE;\n-        notifyTimes = mon->notifyTimes;\n-        mon->notifyTimes = 0;\n-        /* We will access the members of 'mon' after unlocking mon->lock.\n-         * Add a reference. */\n-        PR_ATOMIC_INCREMENT(&mon->refCount);\n-    }\n+PR_IMPLEMENT(PRStatus) PR_ExitMonitor(PRMonitor* mon) {\n+  pthread_t self = pthread_self();\n+  PRIntn rv;\n+  PRBool notifyEntryWaiter = PR_FALSE;\n+  PRIntn notifyTimes = 0;\n+\n+  PR_ASSERT(mon != NULL);\n+  rv = pthread_mutex_lock(&mon->lock);\n+  PR_ASSERT(0 == rv);\n+  /* the entries should be > 0 and we'd better be the owner */\n+  PR_ASSERT(mon->entryCount > 0);\n+  PR_ASSERT(pthread_equal(mon->owner, self));\n+  if (mon->entryCount == 0 || !pthread_equal(mon->owner, self)) {\n     rv = pthread_mutex_unlock(&mon->lock);\n     PR_ASSERT(0 == rv);\n-    if (notifyEntryWaiter) {\n-        if (notifyTimes) {\n-            pt_PostNotifiesFromMonitor(&mon->waitCV, notifyTimes);\n-        }\n-        rv = pthread_cond_signal(&mon->entryCV);\n-        PR_ASSERT(0 == rv);\n-        /* We are done accessing the members of 'mon'. Release the\n-         * reference. */\n-        PR_DestroyMonitor(mon);\n-    }\n-    return PR_SUCCESS;\n-} /* PR_ExitMonitor */\n+    return PR_FAILURE;\n+  }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Wait(PRMonitor* mon, PRIntervalTime timeout)\n-{\n-    PRStatus rv;\n-    PRUint32 saved_entries;\n-    pthread_t saved_owner;\n-\n-    PR_ASSERT(mon != NULL);\n-    rv = pthread_mutex_lock(&mon->lock);\n-    PR_ASSERT(0 == rv);\n-    /* the entries better be positive */\n-    PR_ASSERT(mon->entryCount > 0);\n-    /* and it better be owned by us */\n-    PR_ASSERT(pthread_equal(mon->owner, pthread_self()));\n-\n-    /* tuck these away 'till later */\n-    saved_entries = mon->entryCount;\n-    mon->entryCount = 0;\n-    _PT_PTHREAD_COPY_THR_HANDLE(mon->owner, saved_owner);\n+  mon->entryCount -= 1; /* reduce by one */\n+  if (mon->entryCount == 0) {\n+    /* and if it transitioned to zero - notify an entry waiter */\n+    /* make the owner unknown */\n     _PT_PTHREAD_INVALIDATE_THR_HANDLE(mon->owner);\n-    /*\n-     * If we have pending notifies, post them now.\n-     *\n-     * This is not optimal. We're going to post these notifies\n-     * while we're holding the lock. That means on MP systems\n-     * that they are going to collide for the lock that we will\n-     * hold until we actually wait.\n-     */\n-    if (0 != mon->notifyTimes) {\n-        pt_PostNotifiesFromMonitor(&mon->waitCV, mon->notifyTimes);\n-        mon->notifyTimes = 0;\n+    notifyEntryWaiter = PR_TRUE;\n+    notifyTimes = mon->notifyTimes;\n+    mon->notifyTimes = 0;\n+    /* We will access the members of 'mon' after unlocking mon->lock.\n+     * Add a reference. */\n+    PR_ATOMIC_INCREMENT(&mon->refCount);\n+  }\n+  rv = pthread_mutex_unlock(&mon->lock);\n+  PR_ASSERT(0 == rv);\n+  if (notifyEntryWaiter) {\n+    if (notifyTimes) {\n+      pt_PostNotifiesFromMonitor(&mon->waitCV, notifyTimes);\n     }\n     rv = pthread_cond_signal(&mon->entryCV);\n     PR_ASSERT(0 == rv);\n+    /* We are done accessing the members of 'mon'. Release the\n+     * reference. */\n+    PR_DestroyMonitor(mon);\n+  }\n+  return PR_SUCCESS;\n+} /* PR_ExitMonitor */\n \n-    if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-        rv = pthread_cond_wait(&mon->waitCV, &mon->lock);\n-    } else {\n-        rv = pt_TimedWait(&mon->waitCV, &mon->lock, timeout);\n-    }\n-    PR_ASSERT(0 == rv);\n-\n-    while (mon->entryCount != 0) {\n-        rv = pthread_cond_wait(&mon->entryCV, &mon->lock);\n-        PR_ASSERT(0 == rv);\n-    }\n-    PR_ASSERT(0 == mon->notifyTimes);\n-    /* reinstate the interesting information */\n-    mon->entryCount = saved_entries;\n-    _PT_PTHREAD_COPY_THR_HANDLE(saved_owner, mon->owner);\n-\n-    rv = pthread_mutex_unlock(&mon->lock);\n+PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor* mon, PRIntervalTime timeout) {\n+  PRStatus rv;\n+  PRUint32 saved_entries;\n+  pthread_t saved_owner;\n+\n+  PR_ASSERT(mon != NULL);\n+  rv = pthread_mutex_lock(&mon->lock);\n+  PR_ASSERT(0 == rv);\n+  /* the entries better be positive */\n+  PR_ASSERT(mon->entryCount > 0);\n+  /* and it better be owned by us */\n+  PR_ASSERT(pthread_equal(mon->owner, pthread_self()));\n+\n+  /* tuck these away 'till later */\n+  saved_entries = mon->entryCount;\n+  mon->entryCount = 0;\n+  _PT_PTHREAD_COPY_THR_HANDLE(mon->owner, saved_owner);\n+  _PT_PTHREAD_INVALIDATE_THR_HANDLE(mon->owner);\n+  /*\n+   * If we have pending notifies, post them now.\n+   *\n+   * This is not optimal. We're going to post these notifies\n+   * while we're holding the lock. That means on MP systems\n+   * that they are going to collide for the lock that we will\n+   * hold until we actually wait.\n+   */\n+  if (0 != mon->notifyTimes) {\n+    pt_PostNotifiesFromMonitor(&mon->waitCV, mon->notifyTimes);\n+    mon->notifyTimes = 0;\n+  }\n+  rv = pthread_cond_signal(&mon->entryCV);\n+  PR_ASSERT(0 == rv);\n+\n+  if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+    rv = pthread_cond_wait(&mon->waitCV, &mon->lock);\n+  } else {\n+    rv = pt_TimedWait(&mon->waitCV, &mon->lock, timeout);\n+  }\n+  PR_ASSERT(0 == rv);\n+\n+  while (mon->entryCount != 0) {\n+    rv = pthread_cond_wait(&mon->entryCV, &mon->lock);\n     PR_ASSERT(0 == rv);\n-    return rv;\n+  }\n+  PR_ASSERT(0 == mon->notifyTimes);\n+  /* reinstate the interesting information */\n+  mon->entryCount = saved_entries;\n+  _PT_PTHREAD_COPY_THR_HANDLE(saved_owner, mon->owner);\n+\n+  rv = pthread_mutex_unlock(&mon->lock);\n+  PR_ASSERT(0 == rv);\n+  return rv;\n } /* PR_Wait */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Notify(PRMonitor* mon)\n-{\n-    pt_PostNotifyToMonitor(mon, PR_FALSE);\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_Notify(PRMonitor* mon) {\n+  pt_PostNotifyToMonitor(mon, PR_FALSE);\n+  return PR_SUCCESS;\n } /* PR_Notify */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_NotifyAll(PRMonitor* mon)\n-{\n-    pt_PostNotifyToMonitor(mon, PR_TRUE);\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_NotifyAll(PRMonitor* mon) {\n+  pt_PostNotifyToMonitor(mon, PR_TRUE);\n+  return PR_SUCCESS;\n } /* PR_NotifyAll */\n \n /**************************************************************/\n@@ -749,73 +696,65 @@ PR_NotifyAll(PRMonitor* mon)\n /**************************SEMAPHORES**************************/\n /**************************************************************/\n /**************************************************************/\n-PR_IMPLEMENT(void)\n-PR_PostSem(PRSemaphore* semaphore)\n-{\n-    static PRBool unwarned = PR_TRUE;\n-    if (unwarned)\n-        unwarned = _PR_Obsolete(\"PR_PostSem\", \"locks & condition variables\");\n-    PR_Lock(semaphore->cvar->lock);\n-    PR_NotifyCondVar(semaphore->cvar);\n-    semaphore->count += 1;\n-    PR_Unlock(semaphore->cvar->lock);\n+PR_IMPLEMENT(void) PR_PostSem(PRSemaphore* semaphore) {\n+  static PRBool unwarned = PR_TRUE;\n+  if (unwarned)\n+    unwarned = _PR_Obsolete(\"PR_PostSem\", \"locks & condition variables\");\n+  PR_Lock(semaphore->cvar->lock);\n+  PR_NotifyCondVar(semaphore->cvar);\n+  semaphore->count += 1;\n+  PR_Unlock(semaphore->cvar->lock);\n } /* PR_PostSem */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_WaitSem(PRSemaphore* semaphore)\n-{\n-    PRStatus status = PR_SUCCESS;\n-    static PRBool unwarned = PR_TRUE;\n-    if (unwarned)\n-        unwarned = _PR_Obsolete(\"PR_WaitSem\", \"locks & condition variables\");\n-    PR_Lock(semaphore->cvar->lock);\n-    while ((semaphore->count == 0) && (PR_SUCCESS == status)) {\n-        status = PR_WaitCondVar(semaphore->cvar, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    if (PR_SUCCESS == status) {\n-        semaphore->count -= 1;\n-    }\n-    PR_Unlock(semaphore->cvar->lock);\n-    return status;\n+PR_IMPLEMENT(PRStatus) PR_WaitSem(PRSemaphore* semaphore) {\n+  PRStatus status = PR_SUCCESS;\n+  static PRBool unwarned = PR_TRUE;\n+  if (unwarned)\n+    unwarned = _PR_Obsolete(\"PR_WaitSem\", \"locks & condition variables\");\n+  PR_Lock(semaphore->cvar->lock);\n+  while ((semaphore->count == 0) && (PR_SUCCESS == status)) {\n+    status = PR_WaitCondVar(semaphore->cvar, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  if (PR_SUCCESS == status) {\n+    semaphore->count -= 1;\n+  }\n+  PR_Unlock(semaphore->cvar->lock);\n+  return status;\n } /* PR_WaitSem */\n \n-PR_IMPLEMENT(void)\n-PR_DestroySem(PRSemaphore* semaphore)\n-{\n-    static PRBool unwarned = PR_TRUE;\n-    if (unwarned)\n-        unwarned = _PR_Obsolete(\"PR_DestroySem\", \"locks & condition variables\");\n-    PR_DestroyLock(semaphore->cvar->lock);\n-    PR_DestroyCondVar(semaphore->cvar);\n-    PR_Free(semaphore);\n+PR_IMPLEMENT(void) PR_DestroySem(PRSemaphore* semaphore) {\n+  static PRBool unwarned = PR_TRUE;\n+  if (unwarned)\n+    unwarned = _PR_Obsolete(\"PR_DestroySem\", \"locks & condition variables\");\n+  PR_DestroyLock(semaphore->cvar->lock);\n+  PR_DestroyCondVar(semaphore->cvar);\n+  PR_Free(semaphore);\n } /* PR_DestroySem */\n \n-PR_IMPLEMENT(PRSemaphore*)\n-PR_NewSem(PRUintn value)\n-{\n-    PRSemaphore* semaphore;\n-    static PRBool unwarned = PR_TRUE;\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    if (unwarned)\n-        unwarned = _PR_Obsolete(\"PR_NewSem\", \"locks & condition variables\");\n-\n-    semaphore = PR_NEWZAP(PRSemaphore);\n-    if (NULL != semaphore) {\n-        PRLock* lock = PR_NewLock();\n-        if (NULL != lock) {\n-            semaphore->cvar = PR_NewCondVar(lock);\n-            if (NULL != semaphore->cvar) {\n-                semaphore->count = value;\n-                return semaphore;\n-            }\n-            PR_DestroyLock(lock);\n-        }\n-        PR_Free(semaphore);\n+PR_IMPLEMENT(PRSemaphore*) PR_NewSem(PRUintn value) {\n+  PRSemaphore* semaphore;\n+  static PRBool unwarned = PR_TRUE;\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  if (unwarned)\n+    unwarned = _PR_Obsolete(\"PR_NewSem\", \"locks & condition variables\");\n+\n+  semaphore = PR_NEWZAP(PRSemaphore);\n+  if (NULL != semaphore) {\n+    PRLock* lock = PR_NewLock();\n+    if (NULL != lock) {\n+      semaphore->cvar = PR_NewCondVar(lock);\n+      if (NULL != semaphore->cvar) {\n+        semaphore->count = value;\n+        return semaphore;\n+      }\n+      PR_DestroyLock(lock);\n     }\n-    return NULL;\n+    PR_Free(semaphore);\n+  }\n+  return NULL;\n }\n \n /*\n@@ -826,329 +765,302 @@ PR_NewSem(PRUintn value)\n  * 3. unsupported (fails with PR_NOT_IMPLEMENTED_ERROR).\n  */\n \n-#ifdef _PR_HAVE_POSIX_SEMAPHORES\n-#include <fcntl.h>\n+#  ifdef _PR_HAVE_POSIX_SEMAPHORES\n+#    include <fcntl.h>\n \n PR_IMPLEMENT(PRSem*)\n-PR_OpenSemaphore(const char* name, PRIntn flags, PRIntn mode, PRUintn value)\n-{\n-    PRSem* sem;\n-    char osname[PR_IPC_NAME_SIZE];\n+PR_OpenSemaphore(const char* name, PRIntn flags, PRIntn mode, PRUintn value) {\n+  PRSem* sem;\n+  char osname[PR_IPC_NAME_SIZE];\n \n-    if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) ==\n-        PR_FAILURE) {\n-        return NULL;\n-    }\n+  if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) ==\n+      PR_FAILURE) {\n+    return NULL;\n+  }\n \n-    sem = PR_NEW(PRSem);\n-    if (NULL == sem) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n-    }\n+  sem = PR_NEW(PRSem);\n+  if (NULL == sem) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n \n-    if (flags & PR_SEM_CREATE) {\n-        int oflag = O_CREAT;\n+  if (flags & PR_SEM_CREATE) {\n+    int oflag = O_CREAT;\n \n-        if (flags & PR_SEM_EXCL) {\n-            oflag |= O_EXCL;\n-        }\n-        sem->sem = sem_open(osname, oflag, mode, value);\n-    } else {\n-        sem->sem = sem_open(osname, 0);\n-    }\n-    if ((sem_t*)-1 == sem->sem) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        PR_Free(sem);\n-        return NULL;\n+    if (flags & PR_SEM_EXCL) {\n+      oflag |= O_EXCL;\n     }\n-    return sem;\n+    sem->sem = sem_open(osname, oflag, mode, value);\n+  } else {\n+    sem->sem = sem_open(osname, 0);\n+  }\n+  if ((sem_t*)-1 == sem->sem) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_Free(sem);\n+    return NULL;\n+  }\n+  return sem;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_WaitSemaphore(PRSem* sem)\n-{\n-    int rv;\n-    rv = sem_wait(sem->sem);\n-    if (0 != rv) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_WaitSemaphore(PRSem* sem) {\n+  int rv;\n+  rv = sem_wait(sem->sem);\n+  if (0 != rv) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_PostSemaphore(PRSem* sem)\n-{\n-    int rv;\n-    rv = sem_post(sem->sem);\n-    if (0 != rv) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_PostSemaphore(PRSem* sem) {\n+  int rv;\n+  rv = sem_post(sem->sem);\n+  if (0 != rv) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CloseSemaphore(PRSem* sem)\n-{\n-    int rv;\n-    rv = sem_close(sem->sem);\n-    if (0 != rv) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        return PR_FAILURE;\n-    }\n-    PR_Free(sem);\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_CloseSemaphore(PRSem* sem) {\n+  int rv;\n+  rv = sem_close(sem->sem);\n+  if (0 != rv) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    return PR_FAILURE;\n+  }\n+  PR_Free(sem);\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_DeleteSemaphore(const char* name)\n-{\n-    int rv;\n-    char osname[PR_IPC_NAME_SIZE];\n+PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char* name) {\n+  int rv;\n+  char osname[PR_IPC_NAME_SIZE];\n \n-    if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) ==\n-        PR_FAILURE) {\n-        return PR_FAILURE;\n-    }\n-    rv = sem_unlink(osname);\n-    if (0 != rv) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+  if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) ==\n+      PR_FAILURE) {\n+    return PR_FAILURE;\n+  }\n+  rv = sem_unlink(osname);\n+  if (0 != rv) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-#elif defined(_PR_HAVE_SYSV_SEMAPHORES)\n+#  elif defined(_PR_HAVE_SYSV_SEMAPHORES)\n \n-#include <fcntl.h>\n-#include <sys/sem.h>\n+#    include <fcntl.h>\n+#    include <sys/sem.h>\n \n /*\n  * From the semctl(2) man page in glibc 2.0\n  */\n-#if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) || \\\n-    (defined(FREEBSD) && __FreeBSD_version < 1200059) ||            \\\n-    defined(OPENBSD) || defined(DARWIN)\n+#    if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) || \\\n+        (defined(FREEBSD) && __FreeBSD_version < 1200059) ||            \\\n+        defined(OPENBSD) || defined(DARWIN)\n /* union semun is defined by including <sys/sem.h> */\n-#else\n+#    else\n /* according to X/OPEN we have to define it ourselves */\n union semun {\n-    int val;\n-    struct semid_ds* buf;\n-    unsigned short* array;\n+  int val;\n+  struct semid_ds* buf;\n+  unsigned short* array;\n };\n-#endif\n+#    endif\n \n /*\n  * 'a' (97) is the final closing price of NSCP stock.\n  */\n-#define NSPR_IPC_KEY_ID 'a' /* the id argument for ftok() */\n+#    define NSPR_IPC_KEY_ID 'a' /* the id argument for ftok() */\n \n-#define NSPR_SEM_MODE 0666\n+#    define NSPR_SEM_MODE 0666\n \n PR_IMPLEMENT(PRSem*)\n-PR_OpenSemaphore(const char* name, PRIntn flags, PRIntn mode, PRUintn value)\n-{\n-    PRSem* sem;\n-    key_t key;\n-    union semun arg;\n-    struct sembuf sop;\n-    struct semid_ds seminfo;\n-#define MAX_TRIES 60\n-    PRIntn i;\n-    char osname[PR_IPC_NAME_SIZE];\n-\n-    if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) ==\n-        PR_FAILURE) {\n-        return NULL;\n-    }\n-\n-    /* Make sure the file exists before calling ftok. */\n-    if (flags & PR_SEM_CREATE) {\n-        int osfd = open(osname, O_RDWR | O_CREAT, mode);\n-        if (-1 == osfd) {\n-            _PR_MD_MAP_OPEN_ERROR(errno);\n-            return NULL;\n-        }\n-        if (close(osfd) == -1) {\n-            _PR_MD_MAP_CLOSE_ERROR(errno);\n-            return NULL;\n-        }\n+PR_OpenSemaphore(const char* name, PRIntn flags, PRIntn mode, PRUintn value) {\n+  PRSem* sem;\n+  key_t key;\n+  union semun arg;\n+  struct sembuf sop;\n+  struct semid_ds seminfo;\n+#    define MAX_TRIES 60\n+  PRIntn i;\n+  char osname[PR_IPC_NAME_SIZE];\n+\n+  if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) ==\n+      PR_FAILURE) {\n+    return NULL;\n+  }\n+\n+  /* Make sure the file exists before calling ftok. */\n+  if (flags & PR_SEM_CREATE) {\n+    int osfd = open(osname, O_RDWR | O_CREAT, mode);\n+    if (-1 == osfd) {\n+      _PR_MD_MAP_OPEN_ERROR(errno);\n+      return NULL;\n     }\n-    key = ftok(osname, NSPR_IPC_KEY_ID);\n-    if ((key_t)-1 == key) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        return NULL;\n+    if (close(osfd) == -1) {\n+      _PR_MD_MAP_CLOSE_ERROR(errno);\n+      return NULL;\n     }\n+  }\n+  key = ftok(osname, NSPR_IPC_KEY_ID);\n+  if ((key_t)-1 == key) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    return NULL;\n+  }\n \n-    sem = PR_NEW(PRSem);\n-    if (NULL == sem) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  sem = PR_NEW(PRSem);\n+  if (NULL == sem) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n+\n+  if (flags & PR_SEM_CREATE) {\n+    sem->semid = semget(key, 1, mode | IPC_CREAT | IPC_EXCL);\n+    if (sem->semid >= 0) {\n+      /* creator of a semaphore is responsible for initializing it */\n+      arg.val = 0;\n+      if (semctl(sem->semid, 0, SETVAL, arg) == -1) {\n+        _PR_MD_MAP_DEFAULT_ERROR(errno);\n+        PR_Free(sem);\n         return NULL;\n-    }\n-\n-    if (flags & PR_SEM_CREATE) {\n-        sem->semid = semget(key, 1, mode | IPC_CREAT | IPC_EXCL);\n-        if (sem->semid >= 0) {\n-            /* creator of a semaphore is responsible for initializing it */\n-            arg.val = 0;\n-            if (semctl(sem->semid, 0, SETVAL, arg) == -1) {\n-                _PR_MD_MAP_DEFAULT_ERROR(errno);\n-                PR_Free(sem);\n-                return NULL;\n-            }\n-            /* call semop to set sem_otime to nonzero */\n-            sop.sem_num = 0;\n-            sop.sem_op = value;\n-            sop.sem_flg = 0;\n-            if (semop(sem->semid, &sop, 1) == -1) {\n-                _PR_MD_MAP_DEFAULT_ERROR(errno);\n-                PR_Free(sem);\n-                return NULL;\n-            }\n-            return sem;\n-        }\n-\n-        if (errno != EEXIST || flags & PR_SEM_EXCL) {\n-            _PR_MD_MAP_DEFAULT_ERROR(errno);\n-            PR_Free(sem);\n-            return NULL;\n-        }\n-    }\n-\n-    sem->semid = semget(key, 1, NSPR_SEM_MODE);\n-    if (sem->semid == -1) {\n+      }\n+      /* call semop to set sem_otime to nonzero */\n+      sop.sem_num = 0;\n+      sop.sem_op = value;\n+      sop.sem_flg = 0;\n+      if (semop(sem->semid, &sop, 1) == -1) {\n         _PR_MD_MAP_DEFAULT_ERROR(errno);\n         PR_Free(sem);\n         return NULL;\n+      }\n+      return sem;\n     }\n-    for (i = 0; i < MAX_TRIES; i++) {\n-        arg.buf = &seminfo;\n-        semctl(sem->semid, 0, IPC_STAT, arg);\n-        if (seminfo.sem_otime != 0) {\n-            break;\n-        }\n-        sleep(1);\n+\n+    if (errno != EEXIST || flags & PR_SEM_EXCL) {\n+      _PR_MD_MAP_DEFAULT_ERROR(errno);\n+      PR_Free(sem);\n+      return NULL;\n     }\n-    if (i == MAX_TRIES) {\n-        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n-        PR_Free(sem);\n-        return NULL;\n+  }\n+\n+  sem->semid = semget(key, 1, NSPR_SEM_MODE);\n+  if (sem->semid == -1) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    PR_Free(sem);\n+    return NULL;\n+  }\n+  for (i = 0; i < MAX_TRIES; i++) {\n+    arg.buf = &seminfo;\n+    semctl(sem->semid, 0, IPC_STAT, arg);\n+    if (seminfo.sem_otime != 0) {\n+      break;\n     }\n-    return sem;\n+    sleep(1);\n+  }\n+  if (i == MAX_TRIES) {\n+    PR_SetError(PR_IO_TIMEOUT_ERROR, 0);\n+    PR_Free(sem);\n+    return NULL;\n+  }\n+  return sem;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_WaitSemaphore(PRSem* sem)\n-{\n-    struct sembuf sop;\n-\n-    sop.sem_num = 0;\n-    sop.sem_op = -1;\n-    sop.sem_flg = 0;\n-    if (semop(sem->semid, &sop, 1) == -1) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_WaitSemaphore(PRSem* sem) {\n+  struct sembuf sop;\n+\n+  sop.sem_num = 0;\n+  sop.sem_op = -1;\n+  sop.sem_flg = 0;\n+  if (semop(sem->semid, &sop, 1) == -1) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_PostSemaphore(PRSem* sem)\n-{\n-    struct sembuf sop;\n-\n-    sop.sem_num = 0;\n-    sop.sem_op = 1;\n-    sop.sem_flg = 0;\n-    if (semop(sem->semid, &sop, 1) == -1) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_PostSemaphore(PRSem* sem) {\n+  struct sembuf sop;\n+\n+  sop.sem_num = 0;\n+  sop.sem_op = 1;\n+  sop.sem_flg = 0;\n+  if (semop(sem->semid, &sop, 1) == -1) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CloseSemaphore(PRSem* sem)\n-{\n-    PR_Free(sem);\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_CloseSemaphore(PRSem* sem) {\n+  PR_Free(sem);\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_DeleteSemaphore(const char* name)\n-{\n-    key_t key;\n-    int semid;\n-    /* On some systems (e.g., glibc 2.0) semctl requires a fourth argument */\n-    union semun unused;\n-    char osname[PR_IPC_NAME_SIZE];\n-\n-    if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) ==\n-        PR_FAILURE) {\n-        return PR_FAILURE;\n-    }\n-    key = ftok(osname, NSPR_IPC_KEY_ID);\n-    if ((key_t)-1 == key) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        return PR_FAILURE;\n-    }\n-    if (unlink(osname) == -1) {\n-        _PR_MD_MAP_UNLINK_ERROR(errno);\n-        return PR_FAILURE;\n-    }\n-    semid = semget(key, 1, NSPR_SEM_MODE);\n-    if (-1 == semid) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        return PR_FAILURE;\n-    }\n-    unused.val = 0;\n-    if (semctl(semid, 0, IPC_RMID, unused) == -1) {\n-        _PR_MD_MAP_DEFAULT_ERROR(errno);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char* name) {\n+  key_t key;\n+  int semid;\n+  /* On some systems (e.g., glibc 2.0) semctl requires a fourth argument */\n+  union semun unused;\n+  char osname[PR_IPC_NAME_SIZE];\n+\n+  if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) ==\n+      PR_FAILURE) {\n+    return PR_FAILURE;\n+  }\n+  key = ftok(osname, NSPR_IPC_KEY_ID);\n+  if ((key_t)-1 == key) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    return PR_FAILURE;\n+  }\n+  if (unlink(osname) == -1) {\n+    _PR_MD_MAP_UNLINK_ERROR(errno);\n+    return PR_FAILURE;\n+  }\n+  semid = semget(key, 1, NSPR_SEM_MODE);\n+  if (-1 == semid) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    return PR_FAILURE;\n+  }\n+  unused.val = 0;\n+  if (semctl(semid, 0, IPC_RMID, unused) == -1) {\n+    _PR_MD_MAP_DEFAULT_ERROR(errno);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-#else /* neither POSIX nor System V semaphores are available */\n+#  else /* neither POSIX nor System V semaphores are available */\n \n PR_IMPLEMENT(PRSem*)\n-PR_OpenSemaphore(const char* name, PRIntn flags, PRIntn mode, PRUintn value)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return NULL;\n+PR_OpenSemaphore(const char* name, PRIntn flags, PRIntn mode, PRUintn value) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return NULL;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_WaitSemaphore(PRSem* sem)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+PR_IMPLEMENT(PRStatus) PR_WaitSemaphore(PRSem* sem) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_PostSemaphore(PRSem* sem)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+PR_IMPLEMENT(PRStatus) PR_PostSemaphore(PRSem* sem) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CloseSemaphore(PRSem* sem)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+PR_IMPLEMENT(PRStatus) PR_CloseSemaphore(PRSem* sem) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_DeleteSemaphore(const char* name)\n-{\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return PR_FAILURE;\n+PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char* name) {\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return PR_FAILURE;\n }\n \n-#endif /* end of interprocess named semaphore functions */\n+#  endif /* end of interprocess named semaphore functions */\n \n /**************************************************************/\n /**************************************************************/\n@@ -1156,94 +1068,83 @@ PR_DeleteSemaphore(const char* name)\n /**************************************************************/\n /**************************************************************/\n \n-#include \"prpdce.h\"\n+#  include \"prpdce.h\"\n \n-PR_IMPLEMENT(PRStatus)\n-PRP_TryLock(PRLock* lock)\n-{\n-    PRIntn rv = pthread_mutex_trylock(&lock->mutex);\n-    if (rv == 0) {\n-        PR_ASSERT(PR_FALSE == lock->locked);\n-        lock->locked = PR_TRUE;\n-        lock->owner = pthread_self();\n-    }\n-    /* XXX set error code? */\n-    return (0 == rv) ? PR_SUCCESS : PR_FAILURE;\n+PR_IMPLEMENT(PRStatus) PRP_TryLock(PRLock* lock) {\n+  PRIntn rv = pthread_mutex_trylock(&lock->mutex);\n+  if (rv == 0) {\n+    PR_ASSERT(PR_FALSE == lock->locked);\n+    lock->locked = PR_TRUE;\n+    lock->owner = pthread_self();\n+  }\n+  /* XXX set error code? */\n+  return (0 == rv) ? PR_SUCCESS : PR_FAILURE;\n } /* PRP_TryLock */\n \n-PR_IMPLEMENT(PRCondVar*)\n-PRP_NewNakedCondVar(void)\n-{\n-    PRCondVar* cv;\n+PR_IMPLEMENT(PRCondVar*) PRP_NewNakedCondVar(void) {\n+  PRCondVar* cv;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    cv = PR_NEW(PRCondVar);\n-    if (cv != NULL) {\n-        int rv;\n-        rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr);\n-        PR_ASSERT(0 == rv);\n-        if (0 == rv) {\n-            cv->lock = _PR_NAKED_CV_LOCK;\n-        } else {\n-            PR_DELETE(cv);\n-            cv = NULL;\n-        }\n+  cv = PR_NEW(PRCondVar);\n+  if (cv != NULL) {\n+    int rv;\n+    rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr);\n+    PR_ASSERT(0 == rv);\n+    if (0 == rv) {\n+      cv->lock = _PR_NAKED_CV_LOCK;\n+    } else {\n+      PR_DELETE(cv);\n+      cv = NULL;\n     }\n-    return cv;\n+  }\n+  return cv;\n } /* PRP_NewNakedCondVar */\n \n-PR_IMPLEMENT(void)\n-PRP_DestroyNakedCondVar(PRCondVar* cvar)\n-{\n-    int rv;\n-    rv = pthread_cond_destroy(&cvar->cv);\n-    PR_ASSERT(0 == rv);\n-#if defined(DEBUG)\n-    memset(cvar, 0xaf, sizeof(PRCondVar));\n-#endif\n-    PR_Free(cvar);\n+PR_IMPLEMENT(void) PRP_DestroyNakedCondVar(PRCondVar* cvar) {\n+  int rv;\n+  rv = pthread_cond_destroy(&cvar->cv);\n+  PR_ASSERT(0 == rv);\n+#  if defined(DEBUG)\n+  memset(cvar, 0xaf, sizeof(PRCondVar));\n+#  endif\n+  PR_Free(cvar);\n } /* PRP_DestroyNakedCondVar */\n \n PR_IMPLEMENT(PRStatus)\n-PRP_NakedWait(PRCondVar* cvar, PRLock* ml, PRIntervalTime timeout)\n-{\n-    PRIntn rv;\n-    PR_ASSERT(cvar != NULL);\n-    /* XXX do we really want to assert this in a naked wait? */\n-    PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(ml->mutex));\n-    if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-        rv = pthread_cond_wait(&cvar->cv, &ml->mutex);\n-    } else {\n-        rv = pt_TimedWait(&cvar->cv, &ml->mutex, timeout);\n-    }\n-    if (rv != 0) {\n-        _PR_MD_MAP_DEFAULT_ERROR(rv);\n-        return PR_FAILURE;\n-    }\n-    return PR_SUCCESS;\n+PRP_NakedWait(PRCondVar* cvar, PRLock* ml, PRIntervalTime timeout) {\n+  PRIntn rv;\n+  PR_ASSERT(cvar != NULL);\n+  /* XXX do we really want to assert this in a naked wait? */\n+  PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(ml->mutex));\n+  if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+    rv = pthread_cond_wait(&cvar->cv, &ml->mutex);\n+  } else {\n+    rv = pt_TimedWait(&cvar->cv, &ml->mutex, timeout);\n+  }\n+  if (rv != 0) {\n+    _PR_MD_MAP_DEFAULT_ERROR(rv);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n } /* PRP_NakedWait */\n \n-PR_IMPLEMENT(PRStatus)\n-PRP_NakedNotify(PRCondVar* cvar)\n-{\n-    int rv;\n-    PR_ASSERT(cvar != NULL);\n-    rv = pthread_cond_signal(&cvar->cv);\n-    PR_ASSERT(0 == rv);\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PRP_NakedNotify(PRCondVar* cvar) {\n+  int rv;\n+  PR_ASSERT(cvar != NULL);\n+  rv = pthread_cond_signal(&cvar->cv);\n+  PR_ASSERT(0 == rv);\n+  return PR_SUCCESS;\n } /* PRP_NakedNotify */\n \n-PR_IMPLEMENT(PRStatus)\n-PRP_NakedBroadcast(PRCondVar* cvar)\n-{\n-    int rv;\n-    PR_ASSERT(cvar != NULL);\n-    rv = pthread_cond_broadcast(&cvar->cv);\n-    PR_ASSERT(0 == rv);\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PRP_NakedBroadcast(PRCondVar* cvar) {\n+  int rv;\n+  PR_ASSERT(cvar != NULL);\n+  rv = pthread_cond_broadcast(&cvar->cv);\n+  PR_ASSERT(0 == rv);\n+  return PR_SUCCESS;\n } /* PRP_NakedBroadcast */\n \n #endif /* defined(_PR_PTHREADS) */\ndiff --git a/nspr/pr/src/pthreads/ptthread.c b/nspr/pr/src/pthreads/ptthread.c\nindex f290623..2caa16d 100644\n--- a/nspr/pr/src/pthreads/ptthread.c\n+++ b/nspr/pr/src/pthreads/ptthread.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,31 +11,31 @@\n \n #if defined(_PR_PTHREADS)\n \n-#include \"prlog.h\"\n-#include \"primpl.h\"\n-#include \"prpdce.h\"\n+#  include \"prlog.h\"\n+#  include \"primpl.h\"\n+#  include \"prpdce.h\"\n \n-#include <pthread.h>\n-#include <unistd.h>\n-#include <string.h>\n-#include <signal.h>\n-#include <dlfcn.h>\n+#  include <pthread.h>\n+#  include <unistd.h>\n+#  include <string.h>\n+#  include <signal.h>\n+#  include <dlfcn.h>\n \n-#if defined(OPENBSD) || defined(FREEBSD) || defined(DRAGONFLY)\n-#include <pthread_np.h>\n-#endif\n+#  if defined(OPENBSD) || defined(FREEBSD) || defined(DRAGONFLY)\n+#    include <pthread_np.h>\n+#  endif\n \n-#if defined(ANDROID)\n-#include <sys/prctl.h>\n-#endif\n+#  if defined(ANDROID)\n+#    include <sys/prctl.h>\n+#  endif\n \n-#ifdef _PR_NICE_PRIORITY_SCHEDULING\n-#undef _POSIX_THREAD_PRIORITY_SCHEDULING\n-#include <sys/resource.h>\n-#ifndef HAVE_GETTID\n-#define gettid() (syscall(SYS_gettid))\n-#endif\n-#endif\n+#  ifdef _PR_NICE_PRIORITY_SCHEDULING\n+#    undef _POSIX_THREAD_PRIORITY_SCHEDULING\n+#    include <sys/resource.h>\n+#    ifndef HAVE_GETTID\n+#      define gettid() (syscall(SYS_gettid))\n+#    endif\n+#  endif\n \n /*\n  * Record whether or not we have the privilege to set the scheduling\n@@ -46,39 +47,37 @@ static PRIntn pt_schedpriv = 0;\n extern PRLock* _pr_sleeplock;\n \n static struct _PT_Bookeeping {\n-    PRLock* ml;             /* a lock to protect ourselves */\n-    PRCondVar* cv;          /* used to signal global things */\n-    PRInt32 system, user;   /* a count of the two different types */\n-    PRUintn this_many;      /* number of threads allowed for exit */\n-    pthread_key_t key;      /* thread private data key */\n-    PRBool keyCreated;      /* whether 'key' should be deleted */\n-    PRThread *first, *last; /* list of threads we know about */\n-#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n-    PRInt32 minPrio, maxPrio; /* range of scheduling priorities */\n-#endif\n-} pt_book = { 0 };\n+  PRLock* ml;             /* a lock to protect ourselves */\n+  PRCondVar* cv;          /* used to signal global things */\n+  PRInt32 system, user;   /* a count of the two different types */\n+  PRUintn this_many;      /* number of threads allowed for exit */\n+  pthread_key_t key;      /* thread private data key */\n+  PRBool keyCreated;      /* whether 'key' should be deleted */\n+  PRThread *first, *last; /* list of threads we know about */\n+#  if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n+  PRInt32 minPrio, maxPrio; /* range of scheduling priorities */\n+#  endif\n+} pt_book = {0};\n \n static void _pt_thread_death(void* arg);\n static void _pt_thread_death_internal(void* arg, PRBool callDestructors);\n static void init_pthread_gc_support(void);\n \n-#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n-static PRIntn\n-pt_PriorityMap(PRThreadPriority pri)\n-{\n-#ifdef NTO\n-    /* This priority algorithm causes lots of problems on Neutrino\n-     * for now I have just hard coded everything to run at priority 10\n-     * until I can come up with a new algorithm.\n-     *     Jerry.Kirk@Nexwarecorp.com\n-     */\n-    return 10;\n-#else\n-    return pt_book.minPrio +\n-           pri * (pt_book.maxPrio - pt_book.minPrio) / PR_PRIORITY_LAST;\n-#endif\n+#  if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n+static PRIntn pt_PriorityMap(PRThreadPriority pri) {\n+#    ifdef NTO\n+  /* This priority algorithm causes lots of problems on Neutrino\n+   * for now I have just hard coded everything to run at priority 10\n+   * until I can come up with a new algorithm.\n+   *     Jerry.Kirk@Nexwarecorp.com\n+   */\n+  return 10;\n+#    else\n+  return pt_book.minPrio +\n+         pri * (pt_book.maxPrio - pt_book.minPrio) / PR_PRIORITY_LAST;\n+#    endif\n }\n-#elif defined(_PR_NICE_PRIORITY_SCHEDULING)\n+#  elif defined(_PR_NICE_PRIORITY_SCHEDULING)\n /*\n  * This functions maps higher priorities to lower nice values relative to the\n  * nice value specified in the |nice| parameter. The corresponding relative\n@@ -89,899 +88,849 @@ pt_PriorityMap(PRThreadPriority pri)\n  * PR_PRIORITY_HIGH   -1\n  * PR_PRIORITY_URGENT -2\n  */\n-static int\n-pt_RelativePriority(int nice, PRThreadPriority pri)\n-{\n-    return nice + (1 - pri);\n+static int pt_RelativePriority(int nice, PRThreadPriority pri) {\n+  return nice + (1 - pri);\n }\n-#endif\n+#  endif\n \n /*\n ** Initialize a stack for a native pthread thread\n */\n-static void\n-_PR_InitializeStack(PRThreadStack* ts)\n-{\n-    if (ts && (ts->stackTop == 0)) {\n-        ts->allocBase = (char*)&ts;\n-        ts->allocSize = ts->stackSize;\n+static void _PR_InitializeStack(PRThreadStack* ts) {\n+  if (ts && (ts->stackTop == 0)) {\n+    ts->allocBase = (char*)&ts;\n+    ts->allocSize = ts->stackSize;\n \n-        /*\n-        ** Setup stackTop and stackBottom values.\n-        */\n-#ifdef HAVE_STACK_GROWING_UP\n-        ts->stackBottom = ts->allocBase + ts->stackSize;\n-        ts->stackTop = ts->allocBase;\n-#else\n-        ts->stackTop = ts->allocBase;\n-        ts->stackBottom = ts->allocBase - ts->stackSize;\n-#endif\n-    }\n+    /*\n+    ** Setup stackTop and stackBottom values.\n+    */\n+#  ifdef HAVE_STACK_GROWING_UP\n+    ts->stackBottom = ts->allocBase + ts->stackSize;\n+    ts->stackTop = ts->allocBase;\n+#  else\n+    ts->stackTop = ts->allocBase;\n+    ts->stackBottom = ts->allocBase - ts->stackSize;\n+#  endif\n+  }\n }\n \n-static void*\n-_pt_root(void* arg)\n-{\n-    PRIntn rv;\n-    PRThread* thred = (PRThread*)arg;\n-    PRBool detached = (thred->state & PT_THREAD_DETACHED) ? PR_TRUE : PR_FALSE;\n-    pthread_t id = pthread_self();\n-#ifdef _PR_NICE_PRIORITY_SCHEDULING\n-    pid_t tid;\n-#endif\n-\n-#ifdef _PR_NICE_PRIORITY_SCHEDULING\n-    /*\n-     * We need to know the kernel thread ID of each thread in order to\n-     * set its nice value hence we do it here instead of at creation time.\n-     */\n-    tid = gettid();\n-    errno = 0;\n-    rv = getpriority(PRIO_PROCESS, 0);\n-\n-    /* If we cannot read the main thread's nice value don't try to change the\n-     * new thread's nice value. */\n-    if (errno == 0) {\n-        setpriority(PRIO_PROCESS, tid, pt_RelativePriority(rv, thred->priority));\n+static void* _pt_root(void* arg) {\n+  PRIntn rv;\n+  PRThread* thred = (PRThread*)arg;\n+  PRBool detached = (thred->state & PT_THREAD_DETACHED) ? PR_TRUE : PR_FALSE;\n+  pthread_t id = pthread_self();\n+#  ifdef _PR_NICE_PRIORITY_SCHEDULING\n+  pid_t tid;\n+#  endif\n+\n+#  ifdef _PR_NICE_PRIORITY_SCHEDULING\n+  /*\n+   * We need to know the kernel thread ID of each thread in order to\n+   * set its nice value hence we do it here instead of at creation time.\n+   */\n+  tid = gettid();\n+  errno = 0;\n+  rv = getpriority(PRIO_PROCESS, 0);\n+\n+  /* If we cannot read the main thread's nice value don't try to change the\n+   * new thread's nice value. */\n+  if (errno == 0) {\n+    setpriority(PRIO_PROCESS, tid, pt_RelativePriority(rv, thred->priority));\n+  }\n+#  endif\n+\n+  /* Set up the thread stack information */\n+  _PR_InitializeStack(thred->stack);\n+\n+  /*\n+   * Set within the current thread the pointer to our object.\n+   * This object will be deleted when the thread termintates,\n+   * whether in a join or detached (see _PR_InitThreads()).\n+   */\n+  rv = pthread_setspecific(pt_book.key, thred);\n+  PR_ASSERT(0 == rv);\n+\n+  /* make the thread visible to the rest of the runtime */\n+  PR_Lock(pt_book.ml);\n+  /*\n+   * Both the parent thread and this new thread set thred->id.\n+   * The new thread must ensure that thred->id is set before\n+   * it executes its startFunc.  The parent thread must ensure\n+   * that thred->id is set before PR_CreateThread() returns.\n+   * Both threads set thred->id while holding pt_book.ml and\n+   * use thred->idSet to ensure thred->id is written only once.\n+   */\n+  if (!thred->idSet) {\n+    thred->id = id;\n+    thred->idSet = PR_TRUE;\n+  } else {\n+    PR_ASSERT(pthread_equal(thred->id, id));\n+  }\n+\n+#  ifdef _PR_NICE_PRIORITY_SCHEDULING\n+  thred->tid = tid;\n+  PR_NotifyAllCondVar(pt_book.cv);\n+#  endif\n+\n+  /* If this is a GCABLE thread, set its state appropriately */\n+  if (thred->suspend & PT_THREAD_SETGCABLE) {\n+    thred->state |= PT_THREAD_GCABLE;\n+  }\n+  thred->suspend = 0;\n+\n+  thred->prev = pt_book.last;\n+  if (pt_book.last) {\n+    pt_book.last->next = thred;\n+  } else {\n+    pt_book.first = thred;\n+  }\n+  thred->next = NULL;\n+  pt_book.last = thred;\n+  PR_Unlock(pt_book.ml);\n+\n+  thred->startFunc(thred->arg); /* make visible to the client */\n+\n+  /* unhook the thread from the runtime */\n+  PR_Lock(pt_book.ml);\n+  /*\n+   * At this moment, PR_CreateThread() may not have set thred->id yet.\n+   * It is safe for a detached thread to free thred only after\n+   * PR_CreateThread() has accessed thred->id and thred->idSet.\n+   */\n+  if (detached) {\n+    while (!thred->okToDelete) {\n+      PR_WaitCondVar(pt_book.cv, PR_INTERVAL_NO_TIMEOUT);\n     }\n-#endif\n+  }\n \n-    /* Set up the thread stack information */\n-    _PR_InitializeStack(thred->stack);\n+  if (thred->state & PT_THREAD_SYSTEM) {\n+    pt_book.system -= 1;\n+  } else if (--pt_book.user == pt_book.this_many) {\n+    PR_NotifyAllCondVar(pt_book.cv);\n+  }\n+  if (NULL == thred->prev) {\n+    pt_book.first = thred->next;\n+  } else {\n+    thred->prev->next = thred->next;\n+  }\n+  if (NULL == thred->next) {\n+    pt_book.last = thred->prev;\n+  } else {\n+    thred->next->prev = thred->prev;\n+  }\n+  PR_Unlock(pt_book.ml);\n+\n+  /*\n+   * Here we set the pthread's backpointer to the PRThread to NULL.\n+   * Otherwise the destructor would get called eagerly as the thread\n+   * returns to the pthread runtime. The joining thread would them be\n+   * the proud possessor of a dangling reference. However, this is the\n+   * last chance to delete the object if the thread is detached, so\n+   * just let the destructor do the work.\n+   */\n+  if (PR_FALSE == detached) {\n+    /* Call TPD destructors on this thread. */\n+    _PR_DestroyThreadPrivate(thred);\n+    rv = pthread_setspecific(pt_book.key, NULL);\n+    PR_ASSERT(0 == rv);\n+  }\n \n-    /*\n-     * Set within the current thread the pointer to our object.\n-     * This object will be deleted when the thread termintates,\n-     * whether in a join or detached (see _PR_InitThreads()).\n-     */\n+  return NULL;\n+} /* _pt_root */\n+\n+static PRThread* pt_AttachThread(void) {\n+  PRThread* thred = NULL;\n+\n+  /*\n+   * NSPR must have been initialized when PR_AttachThread is called.\n+   * We cannot have PR_AttachThread call implicit initialization\n+   * because if multiple threads call PR_AttachThread simultaneously,\n+   * NSPR may be initialized more than once.\n+   * We can't call any function that calls PR_GetCurrentThread()\n+   * either (e.g., PR_SetError()) as that will result in infinite\n+   * recursion.\n+   */\n+  if (!_pr_initialized) {\n+    return NULL;\n+  }\n+\n+  /* PR_NEWZAP must not call PR_GetCurrentThread() */\n+  thred = PR_NEWZAP(PRThread);\n+  if (NULL != thred) {\n+    int rv;\n+\n+    thred->priority = PR_PRIORITY_NORMAL;\n+    thred->id = pthread_self();\n+    thred->idSet = PR_TRUE;\n+#  ifdef _PR_NICE_PRIORITY_SCHEDULING\n+    thred->tid = gettid();\n+#  endif\n     rv = pthread_setspecific(pt_book.key, thred);\n     PR_ASSERT(0 == rv);\n \n-    /* make the thread visible to the rest of the runtime */\n+    thred->state = PT_THREAD_GLOBAL | PT_THREAD_FOREIGN;\n     PR_Lock(pt_book.ml);\n-    /*\n-     * Both the parent thread and this new thread set thred->id.\n-     * The new thread must ensure that thred->id is set before\n-     * it executes its startFunc.  The parent thread must ensure\n-     * that thred->id is set before PR_CreateThread() returns.\n-     * Both threads set thred->id while holding pt_book.ml and\n-     * use thred->idSet to ensure thred->id is written only once.\n-     */\n-    if (!thred->idSet) {\n-        thred->id = id;\n-        thred->idSet = PR_TRUE;\n-    } else {\n-        PR_ASSERT(pthread_equal(thred->id, id));\n-    }\n-\n-#ifdef _PR_NICE_PRIORITY_SCHEDULING\n-    thred->tid = tid;\n-    PR_NotifyAllCondVar(pt_book.cv);\n-#endif\n-\n-    /* If this is a GCABLE thread, set its state appropriately */\n-    if (thred->suspend & PT_THREAD_SETGCABLE) {\n-        thred->state |= PT_THREAD_GCABLE;\n-    }\n-    thred->suspend = 0;\n \n+    /* then put it into the list */\n     thred->prev = pt_book.last;\n     if (pt_book.last) {\n-        pt_book.last->next = thred;\n+      pt_book.last->next = thred;\n     } else {\n-        pt_book.first = thred;\n+      pt_book.first = thred;\n     }\n     thred->next = NULL;\n     pt_book.last = thred;\n     PR_Unlock(pt_book.ml);\n+  }\n+  return thred; /* may be NULL */\n+} /* pt_AttachThread */\n \n-    thred->startFunc(thred->arg); /* make visible to the client */\n+static PRThread* _PR_CreateThread(PRThreadType type, void (*start)(void* arg),\n+                                  void* arg, PRThreadPriority priority,\n+                                  PRThreadScope scope, PRThreadState state,\n+                                  PRUint32 stackSize, PRBool isGCAble) {\n+  int rv;\n+  PRThread* thred;\n+  pthread_attr_t tattr;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  if ((PRIntn)PR_PRIORITY_FIRST > (PRIntn)priority) {\n+    priority = PR_PRIORITY_FIRST;\n+  } else if ((PRIntn)PR_PRIORITY_LAST < (PRIntn)priority) {\n+    priority = PR_PRIORITY_LAST;\n+  }\n+\n+  rv = _PT_PTHREAD_ATTR_INIT(&tattr);\n+  PR_ASSERT(0 == rv);\n+\n+  if (EPERM != pt_schedpriv) {\n+#  if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n+    struct sched_param schedule;\n+#  endif\n+\n+#  if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n+    rv = pthread_attr_setinheritsched(&tattr, PTHREAD_EXPLICIT_SCHED);\n+    PR_ASSERT(0 == rv);\n+#  endif\n \n-    /* unhook the thread from the runtime */\n-    PR_Lock(pt_book.ml);\n-    /*\n-     * At this moment, PR_CreateThread() may not have set thred->id yet.\n-     * It is safe for a detached thread to free thred only after\n-     * PR_CreateThread() has accessed thred->id and thred->idSet.\n-     */\n-    if (detached) {\n-        while (!thred->okToDelete) {\n-            PR_WaitCondVar(pt_book.cv, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-    }\n+    /* Use the default scheduling policy */\n \n-    if (thred->state & PT_THREAD_SYSTEM) {\n-        pt_book.system -= 1;\n-    } else if (--pt_book.user == pt_book.this_many) {\n-        PR_NotifyAllCondVar(pt_book.cv);\n-    }\n-    if (NULL == thred->prev) {\n-        pt_book.first = thred->next;\n-    } else {\n-        thred->prev->next = thred->next;\n-    }\n-    if (NULL == thred->next) {\n-        pt_book.last = thred->prev;\n-    } else {\n-        thred->next->prev = thred->prev;\n-    }\n-    PR_Unlock(pt_book.ml);\n-\n-    /*\n-     * Here we set the pthread's backpointer to the PRThread to NULL.\n-     * Otherwise the destructor would get called eagerly as the thread\n-     * returns to the pthread runtime. The joining thread would them be\n-     * the proud possessor of a dangling reference. However, this is the\n-     * last chance to delete the object if the thread is detached, so\n-     * just let the destructor do the work.\n-     */\n-    if (PR_FALSE == detached) {\n-        /* Call TPD destructors on this thread. */\n-        _PR_DestroyThreadPrivate(thred);\n-        rv = pthread_setspecific(pt_book.key, NULL);\n-        PR_ASSERT(0 == rv);\n+#  if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n+    rv = pthread_attr_getschedparam(&tattr, &schedule);\n+    PR_ASSERT(0 == rv);\n+    schedule.sched_priority = pt_PriorityMap(priority);\n+    rv = pthread_attr_setschedparam(&tattr, &schedule);\n+    PR_ASSERT(0 == rv);\n+#    ifdef NTO\n+    rv = pthread_attr_setschedpolicy(&tattr, SCHED_RR); /* Round Robin */\n+    PR_ASSERT(0 == rv);\n+#    endif\n+#  endif /* _POSIX_THREAD_PRIORITY_SCHEDULING > 0 */\n+  }\n+\n+  rv = pthread_attr_setdetachstate(\n+      &tattr, ((PR_JOINABLE_THREAD == state) ? PTHREAD_CREATE_JOINABLE\n+                                             : PTHREAD_CREATE_DETACHED));\n+  PR_ASSERT(0 == rv);\n+\n+  /*\n+   * If stackSize is 0, we use the default pthread stack size.\n+   */\n+  if (stackSize) {\n+#  ifdef _MD_MINIMUM_STACK_SIZE\n+    if (stackSize < _MD_MINIMUM_STACK_SIZE) {\n+      stackSize = _MD_MINIMUM_STACK_SIZE;\n     }\n+#  endif\n+    rv = pthread_attr_setstacksize(&tattr, stackSize);\n+    PR_ASSERT(0 == rv);\n+  }\n \n-    return NULL;\n-} /* _pt_root */\n+  thred = PR_NEWZAP(PRThread);\n+  if (NULL == thred) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, errno);\n+    goto done;\n+  } else {\n+    pthread_t id;\n \n-static PRThread*\n-pt_AttachThread(void)\n-{\n-    PRThread* thred = NULL;\n+    thred->arg = arg;\n+    thred->startFunc = start;\n+    thred->priority = priority;\n+    if (PR_UNJOINABLE_THREAD == state) {\n+      thred->state |= PT_THREAD_DETACHED;\n+    }\n \n-    /*\n-     * NSPR must have been initialized when PR_AttachThread is called.\n-     * We cannot have PR_AttachThread call implicit initialization\n-     * because if multiple threads call PR_AttachThread simultaneously,\n-     * NSPR may be initialized more than once.\n-     * We can't call any function that calls PR_GetCurrentThread()\n-     * either (e.g., PR_SetError()) as that will result in infinite\n-     * recursion.\n-     */\n-    if (!_pr_initialized) {\n-        return NULL;\n+    if (PR_LOCAL_THREAD == scope) {\n+      scope = PR_GLOBAL_THREAD;\n     }\n \n-    /* PR_NEWZAP must not call PR_GetCurrentThread() */\n-    thred = PR_NEWZAP(PRThread);\n-    if (NULL != thred) {\n-        int rv;\n-\n-        thred->priority = PR_PRIORITY_NORMAL;\n-        thred->id = pthread_self();\n-        thred->idSet = PR_TRUE;\n-#ifdef _PR_NICE_PRIORITY_SCHEDULING\n-        thred->tid = gettid();\n-#endif\n-        rv = pthread_setspecific(pt_book.key, thred);\n+    if (PR_GLOBAL_BOUND_THREAD == scope) {\n+#  if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n+      rv = pthread_attr_setscope(&tattr, PTHREAD_SCOPE_SYSTEM);\n+      if (rv) {\n+        /*\n+         * system scope not supported\n+         */\n+        scope = PR_GLOBAL_THREAD;\n+        /*\n+         * reset scope\n+         */\n+        rv = pthread_attr_setscope(&tattr, PTHREAD_SCOPE_PROCESS);\n         PR_ASSERT(0 == rv);\n-\n-        thred->state = PT_THREAD_GLOBAL | PT_THREAD_FOREIGN;\n-        PR_Lock(pt_book.ml);\n-\n-        /* then put it into the list */\n-        thred->prev = pt_book.last;\n-        if (pt_book.last) {\n-            pt_book.last->next = thred;\n-        } else {\n-            pt_book.first = thred;\n-        }\n-        thred->next = NULL;\n-        pt_book.last = thred;\n-        PR_Unlock(pt_book.ml);\n+      }\n+#  endif\n     }\n-    return thred; /* may be NULL */\n-} /* pt_AttachThread */\n-\n-static PRThread*\n-_PR_CreateThread(PRThreadType type, void (*start)(void* arg),\n-                 void* arg, PRThreadPriority priority,\n-                 PRThreadScope scope, PRThreadState state,\n-                 PRUint32 stackSize, PRBool isGCAble)\n-{\n-    int rv;\n-    PRThread* thred;\n-    pthread_attr_t tattr;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n+    if (PR_GLOBAL_THREAD == scope) {\n+      thred->state |= PT_THREAD_GLOBAL;\n+    } else if (PR_GLOBAL_BOUND_THREAD == scope) {\n+      thred->state |= (PT_THREAD_GLOBAL | PT_THREAD_BOUND);\n+    } else { /* force it global */\n+      thred->state |= PT_THREAD_GLOBAL;\n     }\n-\n-    if ((PRIntn)PR_PRIORITY_FIRST > (PRIntn)priority) {\n-        priority = PR_PRIORITY_FIRST;\n-    } else if ((PRIntn)PR_PRIORITY_LAST < (PRIntn)priority) {\n-        priority = PR_PRIORITY_LAST;\n+    if (PR_SYSTEM_THREAD == type) {\n+      thred->state |= PT_THREAD_SYSTEM;\n     }\n \n-    rv = _PT_PTHREAD_ATTR_INIT(&tattr);\n-    PR_ASSERT(0 == rv);\n-\n-    if (EPERM != pt_schedpriv) {\n-#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n-        struct sched_param schedule;\n-#endif\n+    thred->suspend = (isGCAble) ? PT_THREAD_SETGCABLE : 0;\n \n-#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n-        rv = pthread_attr_setinheritsched(&tattr, PTHREAD_EXPLICIT_SCHED);\n-        PR_ASSERT(0 == rv);\n-#endif\n+    thred->stack = PR_NEWZAP(PRThreadStack);\n+    if (thred->stack == NULL) {\n+      PRIntn oserr = errno;\n+      PR_Free(thred); /* all that work ... poof! */\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, oserr);\n+      thred = NULL; /* and for what? */\n+      goto done;\n+    }\n+    thred->stack->stackSize = stackSize;\n+    thred->stack->thr = thred;\n \n-        /* Use the default scheduling policy */\n+#  ifdef PT_NO_SIGTIMEDWAIT\n+    pthread_mutex_init(&thred->suspendResumeMutex, NULL);\n+    pthread_cond_init(&thred->suspendResumeCV, NULL);\n+#  endif\n \n-#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n-        rv = pthread_attr_getschedparam(&tattr, &schedule);\n-        PR_ASSERT(0 == rv);\n-        schedule.sched_priority = pt_PriorityMap(priority);\n-        rv = pthread_attr_setschedparam(&tattr, &schedule);\n-        PR_ASSERT(0 == rv);\n-#ifdef NTO\n-        rv = pthread_attr_setschedpolicy(&tattr, SCHED_RR); /* Round Robin */\n-        PR_ASSERT(0 == rv);\n-#endif\n-#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING > 0 */\n+    /* make the thread counted to the rest of the runtime */\n+    PR_Lock(pt_book.ml);\n+    if (PR_SYSTEM_THREAD == type) {\n+      pt_book.system += 1;\n+    } else {\n+      pt_book.user += 1;\n     }\n-\n-    rv = pthread_attr_setdetachstate(\n-        &tattr, ((PR_JOINABLE_THREAD == state) ? PTHREAD_CREATE_JOINABLE\n-                                               : PTHREAD_CREATE_DETACHED));\n-    PR_ASSERT(0 == rv);\n+    PR_Unlock(pt_book.ml);\n \n     /*\n-     * If stackSize is 0, we use the default pthread stack size.\n+     * We pass a pointer to a local copy (instead of thred->id)\n+     * to pthread_create() because who knows what wacky things\n+     * pthread_create() may be doing to its argument.\n      */\n-    if (stackSize) {\n-#ifdef _MD_MINIMUM_STACK_SIZE\n-        if (stackSize < _MD_MINIMUM_STACK_SIZE) {\n-            stackSize = _MD_MINIMUM_STACK_SIZE;\n-        }\n-#endif\n-        rv = pthread_attr_setstacksize(&tattr, stackSize);\n-        PR_ASSERT(0 == rv);\n+    rv = _PT_PTHREAD_CREATE(&id, tattr, _pt_root, thred);\n+\n+    if (EPERM == rv) {\n+      /* Remember that we don't have thread scheduling privilege. */\n+      pt_schedpriv = EPERM;\n+      PR_LOG(_pr_thread_lm, PR_LOG_MIN,\n+             (\"_PR_CreateThread: no thread scheduling privilege\"));\n+      /* Try creating the thread again without setting priority. */\n+#  if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n+      rv = pthread_attr_setinheritsched(&tattr, PTHREAD_INHERIT_SCHED);\n+      PR_ASSERT(0 == rv);\n+#  endif\n+      rv = _PT_PTHREAD_CREATE(&id, tattr, _pt_root, thred);\n     }\n \n-    thred = PR_NEWZAP(PRThread);\n-    if (NULL == thred) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, errno);\n-        goto done;\n-    } else {\n-        pthread_t id;\n-\n-        thred->arg = arg;\n-        thred->startFunc = start;\n-        thred->priority = priority;\n-        if (PR_UNJOINABLE_THREAD == state) {\n-            thred->state |= PT_THREAD_DETACHED;\n-        }\n-\n-        if (PR_LOCAL_THREAD == scope) {\n-            scope = PR_GLOBAL_THREAD;\n-        }\n-\n-        if (PR_GLOBAL_BOUND_THREAD == scope) {\n-#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n-            rv = pthread_attr_setscope(&tattr, PTHREAD_SCOPE_SYSTEM);\n-            if (rv) {\n-                /*\n-                 * system scope not supported\n-                 */\n-                scope = PR_GLOBAL_THREAD;\n-                /*\n-                 * reset scope\n-                 */\n-                rv = pthread_attr_setscope(&tattr, PTHREAD_SCOPE_PROCESS);\n-                PR_ASSERT(0 == rv);\n-            }\n-#endif\n-        }\n-        if (PR_GLOBAL_THREAD == scope) {\n-            thred->state |= PT_THREAD_GLOBAL;\n-        } else if (PR_GLOBAL_BOUND_THREAD == scope) {\n-            thred->state |= (PT_THREAD_GLOBAL | PT_THREAD_BOUND);\n-        } else { /* force it global */\n-            thred->state |= PT_THREAD_GLOBAL;\n-        }\n-        if (PR_SYSTEM_THREAD == type) {\n-            thred->state |= PT_THREAD_SYSTEM;\n-        }\n-\n-        thred->suspend = (isGCAble) ? PT_THREAD_SETGCABLE : 0;\n-\n-        thred->stack = PR_NEWZAP(PRThreadStack);\n-        if (thred->stack == NULL) {\n-            PRIntn oserr = errno;\n-            PR_Free(thred); /* all that work ... poof! */\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, oserr);\n-            thred = NULL; /* and for what? */\n-            goto done;\n-        }\n-        thred->stack->stackSize = stackSize;\n-        thred->stack->thr = thred;\n-\n-#ifdef PT_NO_SIGTIMEDWAIT\n-        pthread_mutex_init(&thred->suspendResumeMutex, NULL);\n-        pthread_cond_init(&thred->suspendResumeCV, NULL);\n-#endif\n-\n-        /* make the thread counted to the rest of the runtime */\n-        PR_Lock(pt_book.ml);\n-        if (PR_SYSTEM_THREAD == type) {\n-            pt_book.system += 1;\n-        } else {\n-            pt_book.user += 1;\n-        }\n-        PR_Unlock(pt_book.ml);\n+    if (0 != rv) {\n+      PRIntn oserr = rv;\n+      PR_Lock(pt_book.ml);\n+      if (thred->state & PT_THREAD_SYSTEM) {\n+        pt_book.system -= 1;\n+      } else if (--pt_book.user == pt_book.this_many) {\n+        PR_NotifyAllCondVar(pt_book.cv);\n+      }\n+      PR_Unlock(pt_book.ml);\n+\n+      PR_Free(thred->stack);\n+      PR_Free(thred); /* all that work ... poof! */\n+      PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, oserr);\n+      thred = NULL; /* and for what? */\n+      goto done;\n+    }\n \n-        /*\n-         * We pass a pointer to a local copy (instead of thred->id)\n-         * to pthread_create() because who knows what wacky things\n-         * pthread_create() may be doing to its argument.\n-         */\n-        rv = _PT_PTHREAD_CREATE(&id, tattr, _pt_root, thred);\n-\n-        if (EPERM == rv) {\n-            /* Remember that we don't have thread scheduling privilege. */\n-            pt_schedpriv = EPERM;\n-            PR_LOG(_pr_thread_lm, PR_LOG_MIN,\n-                   (\"_PR_CreateThread: no thread scheduling privilege\"));\n-            /* Try creating the thread again without setting priority. */\n-#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n-            rv = pthread_attr_setinheritsched(&tattr, PTHREAD_INHERIT_SCHED);\n-            PR_ASSERT(0 == rv);\n-#endif\n-            rv = _PT_PTHREAD_CREATE(&id, tattr, _pt_root, thred);\n-        }\n-\n-        if (0 != rv) {\n-            PRIntn oserr = rv;\n-            PR_Lock(pt_book.ml);\n-            if (thred->state & PT_THREAD_SYSTEM) {\n-                pt_book.system -= 1;\n-            } else if (--pt_book.user == pt_book.this_many) {\n-                PR_NotifyAllCondVar(pt_book.cv);\n-            }\n-            PR_Unlock(pt_book.ml);\n-\n-            PR_Free(thred->stack);\n-            PR_Free(thred); /* all that work ... poof! */\n-            PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, oserr);\n-            thred = NULL; /* and for what? */\n-            goto done;\n-        }\n-\n-        PR_Lock(pt_book.ml);\n-        /*\n-         * Both the parent thread and this new thread set thred->id.\n-         * The parent thread must ensure that thred->id is set before\n-         * PR_CreateThread() returns.  (See comments in _pt_root().)\n-         */\n-        if (!thred->idSet) {\n-            thred->id = id;\n-            thred->idSet = PR_TRUE;\n-        } else {\n-            PR_ASSERT(pthread_equal(thred->id, id));\n-        }\n+    PR_Lock(pt_book.ml);\n+    /*\n+     * Both the parent thread and this new thread set thred->id.\n+     * The parent thread must ensure that thred->id is set before\n+     * PR_CreateThread() returns.  (See comments in _pt_root().)\n+     */\n+    if (!thred->idSet) {\n+      thred->id = id;\n+      thred->idSet = PR_TRUE;\n+    } else {\n+      PR_ASSERT(pthread_equal(thred->id, id));\n+    }\n \n-        /*\n-         * If the new thread is detached, tell it that PR_CreateThread() has\n-         * accessed thred->id and thred->idSet so it's ok to delete thred.\n-         */\n-        if (PR_UNJOINABLE_THREAD == state) {\n-            thred->okToDelete = PR_TRUE;\n-            PR_NotifyAllCondVar(pt_book.cv);\n-        }\n-        PR_Unlock(pt_book.ml);\n+    /*\n+     * If the new thread is detached, tell it that PR_CreateThread() has\n+     * accessed thred->id and thred->idSet so it's ok to delete thred.\n+     */\n+    if (PR_UNJOINABLE_THREAD == state) {\n+      thred->okToDelete = PR_TRUE;\n+      PR_NotifyAllCondVar(pt_book.cv);\n     }\n+    PR_Unlock(pt_book.ml);\n+  }\n \n done:\n-    rv = _PT_PTHREAD_ATTR_DESTROY(&tattr);\n-    PR_ASSERT(0 == rv);\n+  rv = _PT_PTHREAD_ATTR_DESTROY(&tattr);\n+  PR_ASSERT(0 == rv);\n \n-    return thred;\n+  return thred;\n } /* _PR_CreateThread */\n \n PR_IMPLEMENT(PRThread*)\n PR_CreateThread(PRThreadType type, void (*start)(void* arg), void* arg,\n                 PRThreadPriority priority, PRThreadScope scope,\n-                PRThreadState state, PRUint32 stackSize)\n-{\n-    return _PR_CreateThread(type, start, arg, priority, scope, state, stackSize,\n-                            PR_FALSE);\n+                PRThreadState state, PRUint32 stackSize) {\n+  return _PR_CreateThread(type, start, arg, priority, scope, state, stackSize,\n+                          PR_FALSE);\n } /* PR_CreateThread */\n \n PR_IMPLEMENT(PRThread*)\n PR_CreateThreadGCAble(PRThreadType type, void (*start)(void* arg), void* arg,\n                       PRThreadPriority priority, PRThreadScope scope,\n-                      PRThreadState state, PRUint32 stackSize)\n-{\n-    return _PR_CreateThread(type, start, arg, priority, scope, state, stackSize,\n-                            PR_TRUE);\n+                      PRThreadState state, PRUint32 stackSize) {\n+  return _PR_CreateThread(type, start, arg, priority, scope, state, stackSize,\n+                          PR_TRUE);\n } /* PR_CreateThreadGCAble */\n \n-PR_IMPLEMENT(void*)\n-GetExecutionEnvironment(PRThread* thred)\n-{\n-    return thred->environment;\n+PR_IMPLEMENT(void*) GetExecutionEnvironment(PRThread* thred) {\n+  return thred->environment;\n } /* GetExecutionEnvironment */\n \n-PR_IMPLEMENT(void)\n-SetExecutionEnvironment(PRThread* thred, void* env)\n-{\n-    thred->environment = env;\n+PR_IMPLEMENT(void) SetExecutionEnvironment(PRThread* thred, void* env) {\n+  thred->environment = env;\n } /* SetExecutionEnvironment */\n \n PR_IMPLEMENT(PRThread*)\n PR_AttachThread(PRThreadType type, PRThreadPriority priority,\n-                PRThreadStack* stack)\n-{\n-    return PR_GetCurrentThread();\n+                PRThreadStack* stack) {\n+  return PR_GetCurrentThread();\n } /* PR_AttachThread */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_JoinThread(PRThread* thred)\n-{\n-    int rv = -1;\n-    void* result = NULL;\n-    PR_ASSERT(thred != NULL);\n+PR_IMPLEMENT(PRStatus) PR_JoinThread(PRThread* thred) {\n+  int rv = -1;\n+  void* result = NULL;\n+  PR_ASSERT(thred != NULL);\n \n-    if ((0xafafafaf == thred->state) ||\n-        (PT_THREAD_DETACHED == (PT_THREAD_DETACHED & thred->state)) ||\n-        (PT_THREAD_FOREIGN == (PT_THREAD_FOREIGN & thred->state))) {\n-        /*\n-         * This might be a bad address, but if it isn't, the state should\n-         * either be an unjoinable thread or it's already had the object\n-         * deleted. However, the client that called join on a detached\n-         * thread deserves all the rath I can muster....\n-         */\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        PR_LogPrint(\"PR_JoinThread: %p not joinable | already smashed\\n\", thred);\n+  if ((0xafafafaf == thred->state) ||\n+      (PT_THREAD_DETACHED == (PT_THREAD_DETACHED & thred->state)) ||\n+      (PT_THREAD_FOREIGN == (PT_THREAD_FOREIGN & thred->state))) {\n+    /*\n+     * This might be a bad address, but if it isn't, the state should\n+     * either be an unjoinable thread or it's already had the object\n+     * deleted. However, the client that called join on a detached\n+     * thread deserves all the rath I can muster....\n+     */\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    PR_LogPrint(\"PR_JoinThread: %p not joinable | already smashed\\n\", thred);\n+  } else {\n+    pthread_t id = thred->id;\n+    rv = pthread_join(id, &result);\n+    PR_ASSERT(rv == 0 && result == NULL);\n+    if (0 == rv) {\n+      /*\n+       * PR_FALSE, because the thread already called the TPD\n+       * destructors before exiting _pt_root.\n+       */\n+      _pt_thread_death_internal(thred, PR_FALSE);\n     } else {\n-        pthread_t id = thred->id;\n-        rv = pthread_join(id, &result);\n-        PR_ASSERT(rv == 0 && result == NULL);\n-        if (0 == rv) {\n-            /*\n-             * PR_FALSE, because the thread already called the TPD\n-             * destructors before exiting _pt_root.\n-             */\n-            _pt_thread_death_internal(thred, PR_FALSE);\n-        } else {\n-            PRErrorCode prerror;\n-            switch (rv) {\n-                case EINVAL: /* not a joinable thread */\n-                case ESRCH:  /* no thread with given ID */\n-                    prerror = PR_INVALID_ARGUMENT_ERROR;\n-                    break;\n-                case EDEADLK: /* a thread joining with itself */\n-                    prerror = PR_DEADLOCK_ERROR;\n-                    break;\n-                default:\n-                    prerror = PR_UNKNOWN_ERROR;\n-                    break;\n-            }\n-            PR_SetError(prerror, rv);\n-        }\n+      PRErrorCode prerror;\n+      switch (rv) {\n+        case EINVAL: /* not a joinable thread */\n+        case ESRCH:  /* no thread with given ID */\n+          prerror = PR_INVALID_ARGUMENT_ERROR;\n+          break;\n+        case EDEADLK: /* a thread joining with itself */\n+          prerror = PR_DEADLOCK_ERROR;\n+          break;\n+        default:\n+          prerror = PR_UNKNOWN_ERROR;\n+          break;\n+      }\n+      PR_SetError(prerror, rv);\n     }\n-    return (0 == rv) ? PR_SUCCESS : PR_FAILURE;\n+  }\n+  return (0 == rv) ? PR_SUCCESS : PR_FAILURE;\n } /* PR_JoinThread */\n \n-PR_IMPLEMENT(void)\n-PR_DetachThread(void)\n-{\n-    void* thred;\n-    int rv;\n+PR_IMPLEMENT(void) PR_DetachThread(void) {\n+  void* thred;\n+  int rv;\n \n-    _PT_PTHREAD_GETSPECIFIC(pt_book.key, thred);\n-    if (NULL == thred) {\n-        return;\n-    }\n-    _pt_thread_death(thred);\n-    rv = pthread_setspecific(pt_book.key, NULL);\n-    PR_ASSERT(0 == rv);\n+  _PT_PTHREAD_GETSPECIFIC(pt_book.key, thred);\n+  if (NULL == thred) {\n+    return;\n+  }\n+  _pt_thread_death(thred);\n+  rv = pthread_setspecific(pt_book.key, NULL);\n+  PR_ASSERT(0 == rv);\n } /* PR_DetachThread */\n \n-PR_IMPLEMENT(PRThread*)\n-PR_GetCurrentThread(void)\n-{\n-    void* thred;\n+PR_IMPLEMENT(PRThread*) PR_GetCurrentThread(void) {\n+  void* thred;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    _PT_PTHREAD_GETSPECIFIC(pt_book.key, thred);\n-    if (NULL == thred) {\n-        thred = pt_AttachThread();\n-    }\n-    PR_ASSERT(NULL != thred);\n-    return (PRThread*)thred;\n+  _PT_PTHREAD_GETSPECIFIC(pt_book.key, thred);\n+  if (NULL == thred) {\n+    thred = pt_AttachThread();\n+  }\n+  PR_ASSERT(NULL != thred);\n+  return (PRThread*)thred;\n } /* PR_GetCurrentThread */\n \n-PR_IMPLEMENT(PRThreadScope)\n-PR_GetThreadScope(const PRThread* thred)\n-{\n-    return (thred->state & PT_THREAD_BOUND) ? PR_GLOBAL_BOUND_THREAD\n-                                            : PR_GLOBAL_THREAD;\n+PR_IMPLEMENT(PRThreadScope) PR_GetThreadScope(const PRThread* thred) {\n+  return (thred->state & PT_THREAD_BOUND) ? PR_GLOBAL_BOUND_THREAD\n+                                          : PR_GLOBAL_THREAD;\n } /* PR_GetThreadScope() */\n \n-PR_IMPLEMENT(PRThreadType)\n-PR_GetThreadType(const PRThread* thred)\n-{\n-    return (thred->state & PT_THREAD_SYSTEM) ? PR_SYSTEM_THREAD : PR_USER_THREAD;\n+PR_IMPLEMENT(PRThreadType) PR_GetThreadType(const PRThread* thred) {\n+  return (thred->state & PT_THREAD_SYSTEM) ? PR_SYSTEM_THREAD : PR_USER_THREAD;\n }\n \n-PR_IMPLEMENT(PRThreadState)\n-PR_GetThreadState(const PRThread* thred)\n-{\n-    return (thred->state & PT_THREAD_DETACHED) ? PR_UNJOINABLE_THREAD\n-                                               : PR_JOINABLE_THREAD;\n+PR_IMPLEMENT(PRThreadState) PR_GetThreadState(const PRThread* thred) {\n+  return (thred->state & PT_THREAD_DETACHED) ? PR_UNJOINABLE_THREAD\n+                                             : PR_JOINABLE_THREAD;\n } /* PR_GetThreadState */\n \n-PR_IMPLEMENT(PRThreadPriority)\n-PR_GetThreadPriority(const PRThread* thred)\n-{\n-    PR_ASSERT(thred != NULL);\n-    return thred->priority;\n+PR_IMPLEMENT(PRThreadPriority) PR_GetThreadPriority(const PRThread* thred) {\n+  PR_ASSERT(thred != NULL);\n+  return thred->priority;\n } /* PR_GetThreadPriority */\n \n PR_IMPLEMENT(void)\n-PR_SetThreadPriority(PRThread* thred, PRThreadPriority newPri)\n-{\n-    PRIntn rv;\n-\n-    PR_ASSERT(NULL != thred);\n-\n-    if ((PRIntn)PR_PRIORITY_FIRST > (PRIntn)newPri) {\n-        newPri = PR_PRIORITY_FIRST;\n-    } else if ((PRIntn)PR_PRIORITY_LAST < (PRIntn)newPri) {\n-        newPri = PR_PRIORITY_LAST;\n-    }\n-\n-#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n-    if (EPERM != pt_schedpriv) {\n-        int policy;\n-        struct sched_param schedule;\n-\n-        rv = pthread_getschedparam(thred->id, &policy, &schedule);\n-        if (0 == rv) {\n-            schedule.sched_priority = pt_PriorityMap(newPri);\n-            rv = pthread_setschedparam(thred->id, policy, &schedule);\n-            if (EPERM == rv) {\n-                pt_schedpriv = EPERM;\n-                PR_LOG(_pr_thread_lm, PR_LOG_MIN,\n-                       (\"PR_SetThreadPriority: no thread scheduling privilege\"));\n-            }\n-        }\n-        if (rv != 0) {\n-            rv = -1;\n-        }\n+PR_SetThreadPriority(PRThread* thred, PRThreadPriority newPri) {\n+  PRIntn rv;\n+\n+  PR_ASSERT(NULL != thred);\n+\n+  if ((PRIntn)PR_PRIORITY_FIRST > (PRIntn)newPri) {\n+    newPri = PR_PRIORITY_FIRST;\n+  } else if ((PRIntn)PR_PRIORITY_LAST < (PRIntn)newPri) {\n+    newPri = PR_PRIORITY_LAST;\n+  }\n+\n+#  if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n+  if (EPERM != pt_schedpriv) {\n+    int policy;\n+    struct sched_param schedule;\n+\n+    rv = pthread_getschedparam(thred->id, &policy, &schedule);\n+    if (0 == rv) {\n+      schedule.sched_priority = pt_PriorityMap(newPri);\n+      rv = pthread_setschedparam(thred->id, policy, &schedule);\n+      if (EPERM == rv) {\n+        pt_schedpriv = EPERM;\n+        PR_LOG(_pr_thread_lm, PR_LOG_MIN,\n+               (\"PR_SetThreadPriority: no thread scheduling privilege\"));\n+      }\n     }\n-#elif defined(_PR_NICE_PRIORITY_SCHEDULING)\n-    PR_Lock(pt_book.ml);\n-    while (thred->tid == 0) {\n-        PR_WaitCondVar(pt_book.cv, PR_INTERVAL_NO_TIMEOUT);\n+    if (rv != 0) {\n+      rv = -1;\n     }\n-    PR_Unlock(pt_book.ml);\n-\n-    errno = 0;\n-    rv = getpriority(PRIO_PROCESS, 0);\n-\n-    /* Do not proceed unless we know the main thread's nice value. */\n-    if (errno == 0) {\n-        rv = setpriority(PRIO_PROCESS, thred->tid, pt_RelativePriority(rv, newPri));\n-\n-        if (rv == -1) {\n-            /* We don't set pt_schedpriv to EPERM in case errno == EPERM\n-             * because adjusting the nice value might be permitted for certain\n-             * ranges but not for others. */\n-            PR_LOG(_pr_thread_lm, PR_LOG_MIN,\n-                   (\"PR_SetThreadPriority: setpriority failed with error %d\", errno));\n-        }\n+  }\n+#  elif defined(_PR_NICE_PRIORITY_SCHEDULING)\n+  PR_Lock(pt_book.ml);\n+  while (thred->tid == 0) {\n+    PR_WaitCondVar(pt_book.cv, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_Unlock(pt_book.ml);\n+\n+  errno = 0;\n+  rv = getpriority(PRIO_PROCESS, 0);\n+\n+  /* Do not proceed unless we know the main thread's nice value. */\n+  if (errno == 0) {\n+    rv = setpriority(PRIO_PROCESS, thred->tid, pt_RelativePriority(rv, newPri));\n+\n+    if (rv == -1) {\n+      /* We don't set pt_schedpriv to EPERM in case errno == EPERM\n+       * because adjusting the nice value might be permitted for certain\n+       * ranges but not for others. */\n+      PR_LOG(_pr_thread_lm, PR_LOG_MIN,\n+             (\"PR_SetThreadPriority: setpriority failed with error %d\", errno));\n     }\n-#else\n-    (void)rv; /* rv is unused */\n-#endif\n+  }\n+#  else\n+  (void)rv; /* rv is unused */\n+#  endif\n \n-    thred->priority = newPri;\n+  thred->priority = newPri;\n } /* PR_SetThreadPriority */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Interrupt(PRThread* thred)\n-{\n-    /*\n-    ** If the target thread indicates that it's waiting,\n-    ** find the condition and broadcast to it. Broadcast\n-    ** since we don't know which thread (if there are more\n-    ** than one). This sounds risky, but clients must\n-    ** test their invariants when resumed from a wait and\n-    ** I don't expect very many threads to be waiting on\n-    ** a single condition and I don't expect interrupt to\n-    ** be used very often.\n-    **\n-    ** I don't know why I thought this would work. Must have\n-    ** been one of those weaker momements after I'd been\n-    ** smelling the vapors.\n-    **\n-    ** Even with the followng changes it is possible that\n-    ** the pointer to the condition variable is pointing\n-    ** at a bogus value. Will the unerlying code detect\n-    ** that?\n-    */\n-    PRCondVar* cv;\n-    PR_ASSERT(NULL != thred);\n-    if (NULL == thred) {\n-        return PR_FAILURE;\n-    }\n+PR_IMPLEMENT(PRStatus) PR_Interrupt(PRThread* thred) {\n+  /*\n+  ** If the target thread indicates that it's waiting,\n+  ** find the condition and broadcast to it. Broadcast\n+  ** since we don't know which thread (if there are more\n+  ** than one). This sounds risky, but clients must\n+  ** test their invariants when resumed from a wait and\n+  ** I don't expect very many threads to be waiting on\n+  ** a single condition and I don't expect interrupt to\n+  ** be used very often.\n+  **\n+  ** I don't know why I thought this would work. Must have\n+  ** been one of those weaker momements after I'd been\n+  ** smelling the vapors.\n+  **\n+  ** Even with the followng changes it is possible that\n+  ** the pointer to the condition variable is pointing\n+  ** at a bogus value. Will the unerlying code detect\n+  ** that?\n+  */\n+  PRCondVar* cv;\n+  PR_ASSERT(NULL != thred);\n+  if (NULL == thred) {\n+    return PR_FAILURE;\n+  }\n \n-    thred->state |= PT_THREAD_ABORTED;\n+  thred->state |= PT_THREAD_ABORTED;\n \n-    cv = thred->waiting;\n-    if ((NULL != cv) && !thred->interrupt_blocked) {\n-        PRIntn rv;\n-        (void)PR_ATOMIC_INCREMENT(&cv->notify_pending);\n-        rv = pthread_cond_broadcast(&cv->cv);\n-        PR_ASSERT(0 == rv);\n-        if (0 > PR_ATOMIC_DECREMENT(&cv->notify_pending)) {\n-            PR_DestroyCondVar(cv);\n-        }\n+  cv = thred->waiting;\n+  if ((NULL != cv) && !thred->interrupt_blocked) {\n+    PRIntn rv;\n+    (void)PR_ATOMIC_INCREMENT(&cv->notify_pending);\n+    rv = pthread_cond_broadcast(&cv->cv);\n+    PR_ASSERT(0 == rv);\n+    if (0 > PR_ATOMIC_DECREMENT(&cv->notify_pending)) {\n+      PR_DestroyCondVar(cv);\n     }\n-    return PR_SUCCESS;\n+  }\n+  return PR_SUCCESS;\n } /* PR_Interrupt */\n \n-PR_IMPLEMENT(void)\n-PR_ClearInterrupt(void)\n-{\n-    PRThread* me = PR_GetCurrentThread();\n-    me->state &= ~PT_THREAD_ABORTED;\n+PR_IMPLEMENT(void) PR_ClearInterrupt(void) {\n+  PRThread* me = PR_GetCurrentThread();\n+  me->state &= ~PT_THREAD_ABORTED;\n } /* PR_ClearInterrupt */\n \n-PR_IMPLEMENT(void)\n-PR_BlockInterrupt(void)\n-{\n-    PRThread* me = PR_GetCurrentThread();\n-    _PT_THREAD_BLOCK_INTERRUPT(me);\n+PR_IMPLEMENT(void) PR_BlockInterrupt(void) {\n+  PRThread* me = PR_GetCurrentThread();\n+  _PT_THREAD_BLOCK_INTERRUPT(me);\n } /* PR_BlockInterrupt */\n \n-PR_IMPLEMENT(void)\n-PR_UnblockInterrupt(void)\n-{\n-    PRThread* me = PR_GetCurrentThread();\n-    _PT_THREAD_UNBLOCK_INTERRUPT(me);\n+PR_IMPLEMENT(void) PR_UnblockInterrupt(void) {\n+  PRThread* me = PR_GetCurrentThread();\n+  _PT_THREAD_UNBLOCK_INTERRUPT(me);\n } /* PR_UnblockInterrupt */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Yield(void)\n-{\n-    static PRBool warning = PR_TRUE;\n-    if (warning)\n-        warning = _PR_Obsolete(\"PR_Yield()\", \"PR_Sleep(PR_INTERVAL_NO_WAIT)\");\n-    return PR_Sleep(PR_INTERVAL_NO_WAIT);\n+PR_IMPLEMENT(PRStatus) PR_Yield(void) {\n+  static PRBool warning = PR_TRUE;\n+  if (warning)\n+    warning = _PR_Obsolete(\"PR_Yield()\", \"PR_Sleep(PR_INTERVAL_NO_WAIT)\");\n+  return PR_Sleep(PR_INTERVAL_NO_WAIT);\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Sleep(PRIntervalTime ticks)\n-{\n-    PRStatus rv = PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_Sleep(PRIntervalTime ticks) {\n+  PRStatus rv = PR_SUCCESS;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    if (PR_INTERVAL_NO_WAIT == ticks) {\n-        _PT_PTHREAD_YIELD();\n-    } else {\n-        PRCondVar* cv;\n-        PRIntervalTime timein;\n-\n-        timein = PR_IntervalNow();\n-        cv = PR_NewCondVar(_pr_sleeplock);\n-        PR_ASSERT(cv != NULL);\n-        PR_Lock(_pr_sleeplock);\n-        do {\n-            PRIntervalTime now = PR_IntervalNow();\n-            PRIntervalTime delta = now - timein;\n-            if (delta > ticks) {\n-                break;\n-            }\n-            rv = PR_WaitCondVar(cv, ticks - delta);\n-        } while (PR_SUCCESS == rv);\n-        PR_Unlock(_pr_sleeplock);\n-        PR_DestroyCondVar(cv);\n-    }\n-    return rv;\n+  if (PR_INTERVAL_NO_WAIT == ticks) {\n+    _PT_PTHREAD_YIELD();\n+  } else {\n+    PRCondVar* cv;\n+    PRIntervalTime timein;\n+\n+    timein = PR_IntervalNow();\n+    cv = PR_NewCondVar(_pr_sleeplock);\n+    PR_ASSERT(cv != NULL);\n+    PR_Lock(_pr_sleeplock);\n+    do {\n+      PRIntervalTime now = PR_IntervalNow();\n+      PRIntervalTime delta = now - timein;\n+      if (delta > ticks) {\n+        break;\n+      }\n+      rv = PR_WaitCondVar(cv, ticks - delta);\n+    } while (PR_SUCCESS == rv);\n+    PR_Unlock(_pr_sleeplock);\n+    PR_DestroyCondVar(cv);\n+  }\n+  return rv;\n } /* PR_Sleep */\n \n-static void\n-_pt_thread_death(void* arg)\n-{\n-    void* thred;\n-    int rv;\n+static void _pt_thread_death(void* arg) {\n+  void* thred;\n+  int rv;\n \n-    _PT_PTHREAD_GETSPECIFIC(pt_book.key, thred);\n-    if (NULL == thred) {\n-        /*\n-         * Have PR_GetCurrentThread return the expected value to the\n-         * destructors.\n-         */\n-        rv = pthread_setspecific(pt_book.key, arg);\n-        PR_ASSERT(0 == rv);\n-    }\n+  _PT_PTHREAD_GETSPECIFIC(pt_book.key, thred);\n+  if (NULL == thred) {\n+    /*\n+     * Have PR_GetCurrentThread return the expected value to the\n+     * destructors.\n+     */\n+    rv = pthread_setspecific(pt_book.key, arg);\n+    PR_ASSERT(0 == rv);\n+  }\n \n-    /* PR_TRUE for: call destructors */\n-    _pt_thread_death_internal(arg, PR_TRUE);\n+  /* PR_TRUE for: call destructors */\n+  _pt_thread_death_internal(arg, PR_TRUE);\n \n-    if (NULL == thred) {\n-        rv = pthread_setspecific(pt_book.key, NULL);\n-        PR_ASSERT(0 == rv);\n-    }\n+  if (NULL == thred) {\n+    rv = pthread_setspecific(pt_book.key, NULL);\n+    PR_ASSERT(0 == rv);\n+  }\n }\n \n-static void\n-_pt_thread_death_internal(void* arg, PRBool callDestructors)\n-{\n-    PRThread* thred = (PRThread*)arg;\n-\n-    if (thred->state & (PT_THREAD_FOREIGN | PT_THREAD_PRIMORD)) {\n-        PR_Lock(pt_book.ml);\n-        if (NULL == thred->prev) {\n-            pt_book.first = thred->next;\n-        } else {\n-            thred->prev->next = thred->next;\n-        }\n-        if (NULL == thred->next) {\n-            pt_book.last = thred->prev;\n-        } else {\n-            thred->next->prev = thred->prev;\n-        }\n-        PR_Unlock(pt_book.ml);\n-    }\n-    if (callDestructors) {\n-        _PR_DestroyThreadPrivate(thred);\n-    }\n-    PR_Free(thred->privateData);\n-    if (NULL != thred->errorString) {\n-        PR_Free(thred->errorString);\n-    }\n-    if (NULL != thred->name) {\n-        PR_Free(thred->name);\n-    }\n-    PR_Free(thred->stack);\n-    if (NULL != thred->syspoll_list) {\n-        PR_Free(thred->syspoll_list);\n-    }\n-#if defined(DEBUG)\n-    memset(thred, 0xaf, sizeof(PRThread));\n-#endif /* defined(DEBUG) */\n-    PR_Free(thred);\n-} /* _pt_thread_death */\n-\n-void\n-_PR_InitThreads(PRThreadType type, PRThreadPriority priority,\n-                PRUintn maxPTDs)\n-{\n-    int rv;\n-    PRThread* thred;\n+static void _pt_thread_death_internal(void* arg, PRBool callDestructors) {\n+  PRThread* thred = (PRThread*)arg;\n \n-    PR_ASSERT(priority == PR_PRIORITY_NORMAL);\n-\n-#ifdef _PR_NEED_PTHREAD_INIT\n-    /*\n-     * On BSD/OS (3.1 and 4.0), the pthread subsystem is lazily\n-     * initialized, but pthread_self() fails to initialize\n-     * pthreads and hence returns a null thread ID if invoked\n-     * by the primordial thread before any other pthread call.\n-     * So we explicitly initialize pthreads here.\n-     */\n-    pthread_init();\n-#endif\n-\n-#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n-#if defined(FREEBSD)\n-    {\n-        pthread_attr_t attr;\n-        int policy;\n-        /* get the min and max priorities of the default policy */\n-        pthread_attr_init(&attr);\n-        pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);\n-        pthread_attr_getschedpolicy(&attr, &policy);\n-        pt_book.minPrio = sched_get_priority_min(policy);\n-        PR_ASSERT(-1 != pt_book.minPrio);\n-        pt_book.maxPrio = sched_get_priority_max(policy);\n-        PR_ASSERT(-1 != pt_book.maxPrio);\n-        pthread_attr_destroy(&attr);\n+  if (thred->state & (PT_THREAD_FOREIGN | PT_THREAD_PRIMORD)) {\n+    PR_Lock(pt_book.ml);\n+    if (NULL == thred->prev) {\n+      pt_book.first = thred->next;\n+    } else {\n+      thred->prev->next = thred->next;\n     }\n-#else\n-    /*\n-    ** These might be function evaluations\n-    */\n-    pt_book.minPrio = PT_PRIO_MIN;\n-    pt_book.maxPrio = PT_PRIO_MAX;\n-#endif\n-#endif\n-\n-    PR_ASSERT(NULL == pt_book.ml);\n-    pt_book.ml = PR_NewLock();\n-    PR_ASSERT(NULL != pt_book.ml);\n-    pt_book.cv = PR_NewCondVar(pt_book.ml);\n-    PR_ASSERT(NULL != pt_book.cv);\n-    thred = PR_NEWZAP(PRThread);\n-    PR_ASSERT(NULL != thred);\n-    thred->arg = NULL;\n-    thred->startFunc = NULL;\n-    thred->priority = priority;\n-    thred->id = pthread_self();\n-    thred->idSet = PR_TRUE;\n-#ifdef _PR_NICE_PRIORITY_SCHEDULING\n-    thred->tid = gettid();\n-#endif\n-\n-    thred->state = (PT_THREAD_DETACHED | PT_THREAD_PRIMORD);\n-    if (PR_SYSTEM_THREAD == type) {\n-        thred->state |= PT_THREAD_SYSTEM;\n-        pt_book.system += 1;\n-        pt_book.this_many = 0;\n+    if (NULL == thred->next) {\n+      pt_book.last = thred->prev;\n     } else {\n-        pt_book.user += 1;\n-        pt_book.this_many = 1;\n+      thred->next->prev = thred->prev;\n     }\n-    thred->next = thred->prev = NULL;\n-    pt_book.first = pt_book.last = thred;\n-\n-    thred->stack = PR_NEWZAP(PRThreadStack);\n-    PR_ASSERT(thred->stack != NULL);\n-    thred->stack->stackSize = 0;\n-    thred->stack->thr = thred;\n-    _PR_InitializeStack(thred->stack);\n+    PR_Unlock(pt_book.ml);\n+  }\n+  if (callDestructors) {\n+    _PR_DestroyThreadPrivate(thred);\n+  }\n+  PR_Free(thred->privateData);\n+  if (NULL != thred->errorString) {\n+    PR_Free(thred->errorString);\n+  }\n+  if (NULL != thred->name) {\n+    PR_Free(thred->name);\n+  }\n+  PR_Free(thred->stack);\n+  if (NULL != thred->syspoll_list) {\n+    PR_Free(thred->syspoll_list);\n+  }\n+#  if defined(DEBUG)\n+  memset(thred, 0xaf, sizeof(PRThread));\n+#  endif /* defined(DEBUG) */\n+  PR_Free(thred);\n+} /* _pt_thread_death */\n \n-    /*\n-     * Create a key for our use to store a backpointer in the pthread\n-     * to our PRThread object. This object gets deleted when the thread\n-     * returns from its root in the case of a detached thread. Other\n-     * threads delete the objects in Join.\n-     *\n-     * NB: The destructor logic seems to have a bug so it isn't used.\n-     * NBB: Oh really? I'm going to give it a spin - AOF 19 June 1998.\n-     * More info - the problem is that pthreads calls the destructor\n-     * eagerly as the thread returns from its root, rather than lazily\n-     * after the thread is joined. Therefore, threads that are joining\n-     * and holding PRThread references are actually holding pointers to\n-     * nothing.\n-     */\n-    rv = _PT_PTHREAD_KEY_CREATE(&pt_book.key, _pt_thread_death);\n-    if (0 != rv) {\n-        PR_Assert(\"0 == rv\", __FILE__, __LINE__);\n-    }\n-    pt_book.keyCreated = PR_TRUE;\n-    rv = pthread_setspecific(pt_book.key, thred);\n-    PR_ASSERT(0 == rv);\n+void _PR_InitThreads(PRThreadType type, PRThreadPriority priority,\n+                     PRUintn maxPTDs) {\n+  int rv;\n+  PRThread* thred;\n+\n+  PR_ASSERT(priority == PR_PRIORITY_NORMAL);\n+\n+#  ifdef _PR_NEED_PTHREAD_INIT\n+  /*\n+   * On BSD/OS (3.1 and 4.0), the pthread subsystem is lazily\n+   * initialized, but pthread_self() fails to initialize\n+   * pthreads and hence returns a null thread ID if invoked\n+   * by the primordial thread before any other pthread call.\n+   * So we explicitly initialize pthreads here.\n+   */\n+  pthread_init();\n+#  endif\n+\n+#  if _POSIX_THREAD_PRIORITY_SCHEDULING > 0\n+#    if defined(FREEBSD)\n+  {\n+    pthread_attr_t attr;\n+    int policy;\n+    /* get the min and max priorities of the default policy */\n+    pthread_attr_init(&attr);\n+    pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);\n+    pthread_attr_getschedpolicy(&attr, &policy);\n+    pt_book.minPrio = sched_get_priority_min(policy);\n+    PR_ASSERT(-1 != pt_book.minPrio);\n+    pt_book.maxPrio = sched_get_priority_max(policy);\n+    PR_ASSERT(-1 != pt_book.maxPrio);\n+    pthread_attr_destroy(&attr);\n+  }\n+#    else\n+  /*\n+  ** These might be function evaluations\n+  */\n+  pt_book.minPrio = PT_PRIO_MIN;\n+  pt_book.maxPrio = PT_PRIO_MAX;\n+#    endif\n+#  endif\n+\n+  PR_ASSERT(NULL == pt_book.ml);\n+  pt_book.ml = PR_NewLock();\n+  PR_ASSERT(NULL != pt_book.ml);\n+  pt_book.cv = PR_NewCondVar(pt_book.ml);\n+  PR_ASSERT(NULL != pt_book.cv);\n+  thred = PR_NEWZAP(PRThread);\n+  PR_ASSERT(NULL != thred);\n+  thred->arg = NULL;\n+  thred->startFunc = NULL;\n+  thred->priority = priority;\n+  thred->id = pthread_self();\n+  thred->idSet = PR_TRUE;\n+#  ifdef _PR_NICE_PRIORITY_SCHEDULING\n+  thred->tid = gettid();\n+#  endif\n+\n+  thred->state = (PT_THREAD_DETACHED | PT_THREAD_PRIMORD);\n+  if (PR_SYSTEM_THREAD == type) {\n+    thred->state |= PT_THREAD_SYSTEM;\n+    pt_book.system += 1;\n+    pt_book.this_many = 0;\n+  } else {\n+    pt_book.user += 1;\n+    pt_book.this_many = 1;\n+  }\n+  thred->next = thred->prev = NULL;\n+  pt_book.first = pt_book.last = thred;\n+\n+  thred->stack = PR_NEWZAP(PRThreadStack);\n+  PR_ASSERT(thred->stack != NULL);\n+  thred->stack->stackSize = 0;\n+  thred->stack->thr = thred;\n+  _PR_InitializeStack(thred->stack);\n+\n+  /*\n+   * Create a key for our use to store a backpointer in the pthread\n+   * to our PRThread object. This object gets deleted when the thread\n+   * returns from its root in the case of a detached thread. Other\n+   * threads delete the objects in Join.\n+   *\n+   * NB: The destructor logic seems to have a bug so it isn't used.\n+   * NBB: Oh really? I'm going to give it a spin - AOF 19 June 1998.\n+   * More info - the problem is that pthreads calls the destructor\n+   * eagerly as the thread returns from its root, rather than lazily\n+   * after the thread is joined. Therefore, threads that are joining\n+   * and holding PRThread references are actually holding pointers to\n+   * nothing.\n+   */\n+  rv = _PT_PTHREAD_KEY_CREATE(&pt_book.key, _pt_thread_death);\n+  if (0 != rv) {\n+    PR_Assert(\"0 == rv\", __FILE__, __LINE__);\n+  }\n+  pt_book.keyCreated = PR_TRUE;\n+  rv = pthread_setspecific(pt_book.key, thred);\n+  PR_ASSERT(0 == rv);\n } /* _PR_InitThreads */\n \n-#ifdef __GNUC__\n+#  ifdef __GNUC__\n /*\n  * GCC supports the constructor and destructor attributes as of\n  * version 2.5.\n  */\n-#if defined(DARWIN)\n+#    if defined(DARWIN)\n /*\n  * The dynamic linker on OSX doesn't execute __attribute__((destructor))\n  * destructors in the right order wrt non-__attribute((destructor)) destructors\n@@ -990,126 +939,117 @@ _PR_InitThreads(PRThreadType type, PRThreadPriority priority,\n  */\n static void _PR_Fini(void);\n \n-__attribute__((constructor)) static void\n-_register_PR_Fini()\n-{\n-    atexit(_PR_Fini);\n+__attribute__((constructor)) static void _register_PR_Fini() {\n+  atexit(_PR_Fini);\n }\n-#else\n+#    else\n static void _PR_Fini(void) __attribute__((destructor));\n-#endif\n+#    endif\n \n-#elif defined(__SUNPRO_C)\n+#  elif defined(__SUNPRO_C)\n /*\n  * Sun Studio compiler\n  */\n-#pragma fini(_PR_Fini)\n+#    pragma fini(_PR_Fini)\n static void _PR_Fini(void);\n-#elif defined(AIX)\n+#  elif defined(AIX)\n /* Need to use the -binitfini::_PR_Fini linker option. */\n-#endif\n-\n-void\n-_PR_Fini(void)\n-{\n-    void* thred;\n-    int rv;\n-\n-    if (!_pr_initialized) {\n-        /* Either NSPR was never successfully initialized or\n-         * PR_Cleanup has been called already. */\n-        if (pt_book.keyCreated) {\n-            rv = pthread_key_delete(pt_book.key);\n-            PR_ASSERT(0 == rv);\n-            pt_book.keyCreated = PR_FALSE;\n-        }\n-        return;\n+#  endif\n+\n+void _PR_Fini(void) {\n+  void* thred;\n+  int rv;\n+\n+  if (!_pr_initialized) {\n+    /* Either NSPR was never successfully initialized or\n+     * PR_Cleanup has been called already. */\n+    if (pt_book.keyCreated) {\n+      rv = pthread_key_delete(pt_book.key);\n+      PR_ASSERT(0 == rv);\n+      pt_book.keyCreated = PR_FALSE;\n     }\n+    return;\n+  }\n \n-    _PT_PTHREAD_GETSPECIFIC(pt_book.key, thred);\n-    if (NULL != thred) {\n-        /*\n-         * PR_FALSE, because it is unsafe to call back to the\n-         * thread private data destructors at final cleanup.\n-         */\n-        _pt_thread_death_internal(thred, PR_FALSE);\n-        rv = pthread_setspecific(pt_book.key, NULL);\n-        PR_ASSERT(0 == rv);\n-    }\n-    rv = pthread_key_delete(pt_book.key);\n+  _PT_PTHREAD_GETSPECIFIC(pt_book.key, thred);\n+  if (NULL != thred) {\n+    /*\n+     * PR_FALSE, because it is unsafe to call back to the\n+     * thread private data destructors at final cleanup.\n+     */\n+    _pt_thread_death_internal(thred, PR_FALSE);\n+    rv = pthread_setspecific(pt_book.key, NULL);\n     PR_ASSERT(0 == rv);\n-    pt_book.keyCreated = PR_FALSE;\n-    /* TODO: free other resources used by NSPR */\n-    /* _pr_initialized = PR_FALSE; */\n+  }\n+  rv = pthread_key_delete(pt_book.key);\n+  PR_ASSERT(0 == rv);\n+  pt_book.keyCreated = PR_FALSE;\n+  /* TODO: free other resources used by NSPR */\n+  /* _pr_initialized = PR_FALSE; */\n } /* _PR_Fini */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Cleanup(void)\n-{\n-    PRThread* me = PR_GetCurrentThread();\n-    int rv;\n-    PR_LOG(_pr_thread_lm, PR_LOG_MIN, (\"PR_Cleanup: shutting down NSPR\"));\n-    PR_ASSERT(me->state & PT_THREAD_PRIMORD);\n-    if (me->state & PT_THREAD_PRIMORD) {\n-        PR_Lock(pt_book.ml);\n-        while (pt_book.user > pt_book.this_many) {\n-            PR_WaitCondVar(pt_book.cv, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        if (me->state & PT_THREAD_SYSTEM) {\n-            pt_book.system -= 1;\n-        } else {\n-            pt_book.user -= 1;\n-        }\n-        PR_Unlock(pt_book.ml);\n-\n-        _PR_MD_EARLY_CLEANUP();\n-\n-        _PR_CleanupMW();\n-        _PR_CleanupTime();\n-        _PR_CleanupDtoa();\n-        _PR_CleanupCallOnce();\n-        _PR_ShutdownLinker();\n-        _PR_LogCleanup();\n-        _PR_CleanupNet();\n-        /* Close all the fd's before calling _PR_CleanupIO */\n-        _PR_CleanupIO();\n-        _PR_CleanupCMon();\n-\n-        _pt_thread_death(me);\n-        rv = pthread_setspecific(pt_book.key, NULL);\n-        PR_ASSERT(0 == rv);\n-        /*\n-         * I am not sure if it's safe to delete the cv and lock here,\n-         * since there may still be \"system\" threads around. If this\n-         * call isn't immediately prior to exiting, then there's a\n-         * problem.\n-         */\n-        if (0 == pt_book.system) {\n-            PR_DestroyCondVar(pt_book.cv);\n-            pt_book.cv = NULL;\n-            PR_DestroyLock(pt_book.ml);\n-            pt_book.ml = NULL;\n-        }\n-        PR_DestroyLock(_pr_sleeplock);\n-        _pr_sleeplock = NULL;\n-        _PR_CleanupLayerCache();\n-        _PR_CleanupEnv();\n-#ifdef _PR_ZONE_ALLOCATOR\n-        _PR_DestroyZones();\n-#endif\n-        _pr_initialized = PR_FALSE;\n-        return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_Cleanup(void) {\n+  PRThread* me = PR_GetCurrentThread();\n+  int rv;\n+  PR_LOG(_pr_thread_lm, PR_LOG_MIN, (\"PR_Cleanup: shutting down NSPR\"));\n+  PR_ASSERT(me->state & PT_THREAD_PRIMORD);\n+  if (me->state & PT_THREAD_PRIMORD) {\n+    PR_Lock(pt_book.ml);\n+    while (pt_book.user > pt_book.this_many) {\n+      PR_WaitCondVar(pt_book.cv, PR_INTERVAL_NO_TIMEOUT);\n     }\n-    return PR_FAILURE;\n+    if (me->state & PT_THREAD_SYSTEM) {\n+      pt_book.system -= 1;\n+    } else {\n+      pt_book.user -= 1;\n+    }\n+    PR_Unlock(pt_book.ml);\n+\n+    _PR_MD_EARLY_CLEANUP();\n+\n+    _PR_CleanupMW();\n+    _PR_CleanupTime();\n+    _PR_CleanupDtoa();\n+    _PR_CleanupCallOnce();\n+    _PR_ShutdownLinker();\n+    _PR_LogCleanup();\n+    _PR_CleanupNet();\n+    /* Close all the fd's before calling _PR_CleanupIO */\n+    _PR_CleanupIO();\n+    _PR_CleanupCMon();\n+\n+    _pt_thread_death(me);\n+    rv = pthread_setspecific(pt_book.key, NULL);\n+    PR_ASSERT(0 == rv);\n+    /*\n+     * I am not sure if it's safe to delete the cv and lock here,\n+     * since there may still be \"system\" threads around. If this\n+     * call isn't immediately prior to exiting, then there's a\n+     * problem.\n+     */\n+    if (0 == pt_book.system) {\n+      PR_DestroyCondVar(pt_book.cv);\n+      pt_book.cv = NULL;\n+      PR_DestroyLock(pt_book.ml);\n+      pt_book.ml = NULL;\n+    }\n+    PR_DestroyLock(_pr_sleeplock);\n+    _pr_sleeplock = NULL;\n+    _PR_CleanupLayerCache();\n+    _PR_CleanupEnv();\n+#  ifdef _PR_ZONE_ALLOCATOR\n+    _PR_DestroyZones();\n+#  endif\n+    _pr_initialized = PR_FALSE;\n+    return PR_SUCCESS;\n+  }\n+  return PR_FAILURE;\n } /* PR_Cleanup */\n \n-PR_IMPLEMENT(void)\n-PR_ProcessExit(PRIntn status) { _exit(status); }\n+PR_IMPLEMENT(void) PR_ProcessExit(PRIntn status) { _exit(status); }\n \n-PR_IMPLEMENT(PRUint32)\n-PR_GetThreadID(PRThread* thred)\n-{\n-    return (PRUint32)thred->id; /* and I don't know what they will do with it */\n+PR_IMPLEMENT(PRUint32) PR_GetThreadID(PRThread* thred) {\n+  return (PRUint32)thred->id; /* and I don't know what they will do with it */\n }\n \n /*\n@@ -1121,22 +1061,19 @@ PR_GetThreadID(PRThread* thred)\n  */\n \n PR_IMPLEMENT(PRInt32)\n-PR_GetThreadAffinityMask(PRThread* thread, PRUint32* mask)\n-{\n-    return 0; /* not implemented */\n+PR_GetThreadAffinityMask(PRThread* thread, PRUint32* mask) {\n+  return 0; /* not implemented */\n }\n \n PR_IMPLEMENT(PRInt32)\n-PR_SetThreadAffinityMask(PRThread* thread, PRUint32 mask)\n-{\n-    return 0; /* not implemented */\n+PR_SetThreadAffinityMask(PRThread* thread, PRUint32 mask) {\n+  return 0; /* not implemented */\n }\n \n PR_IMPLEMENT(void)\n-PR_SetThreadDumpProc(PRThread* thread, PRThreadDumpProc dump, void* arg)\n-{\n-    thread->dump = dump;\n-    thread->dumpArg = arg;\n+PR_SetThreadDumpProc(PRThread* thread, PRThreadDumpProc dump, void* arg) {\n+  thread->dump = dump;\n+  thread->dumpArg = arg;\n }\n \n /*\n@@ -1147,128 +1084,120 @@ PR_SetThreadDumpProc(PRThread* thread, PRThreadDumpProc dump, void* arg)\n /* Not so bogus in AIX as we really do a sigwait */\n static sigset_t sigwait_set;\n \n-static struct timespec onemillisec = { 0, 1000000L };\n-#ifndef PT_NO_SIGTIMEDWAIT\n-static struct timespec hundredmillisec = { 0, 100000000L };\n-#endif\n+static struct timespec onemillisec = {0, 1000000L};\n+#  ifndef PT_NO_SIGTIMEDWAIT\n+static struct timespec hundredmillisec = {0, 100000000L};\n+#  endif\n \n static void suspend_signal_handler(PRIntn sig);\n \n-#ifdef PT_NO_SIGTIMEDWAIT\n+#  ifdef PT_NO_SIGTIMEDWAIT\n static void null_signal_handler(PRIntn sig);\n-#endif\n+#  endif\n \n /*\n  * Linux pthreads use SIGUSR1 and SIGUSR2 internally, which\n  * conflict with the use of these two signals in our GC support.\n  * So we don't know how to support GC on Linux pthreads.\n  */\n-static void\n-init_pthread_gc_support(void)\n-{\n-    PRIntn rv;\n+static void init_pthread_gc_support(void) {\n+  PRIntn rv;\n \n-    {\n-        struct sigaction sigact_usr2;\n+  {\n+    struct sigaction sigact_usr2;\n \n-        sigact_usr2.sa_handler = suspend_signal_handler;\n-        sigact_usr2.sa_flags = SA_RESTART;\n-        sigemptyset(&sigact_usr2.sa_mask);\n+    sigact_usr2.sa_handler = suspend_signal_handler;\n+    sigact_usr2.sa_flags = SA_RESTART;\n+    sigemptyset(&sigact_usr2.sa_mask);\n \n-        rv = sigaction(SIGUSR2, &sigact_usr2, NULL);\n-        PR_ASSERT(0 == rv);\n+    rv = sigaction(SIGUSR2, &sigact_usr2, NULL);\n+    PR_ASSERT(0 == rv);\n \n-        sigemptyset(&sigwait_set);\n-#if defined(PT_NO_SIGTIMEDWAIT)\n-        sigaddset(&sigwait_set, SIGUSR1);\n-#else\n-        sigaddset(&sigwait_set, SIGUSR2);\n-#endif /* defined(PT_NO_SIGTIMEDWAIT) */\n-    }\n-#if defined(PT_NO_SIGTIMEDWAIT)\n-    {\n-        struct sigaction sigact_null;\n-        sigact_null.sa_handler = null_signal_handler;\n-        sigact_null.sa_flags = SA_RESTART;\n-        sigemptyset(&sigact_null.sa_mask);\n-        rv = sigaction(SIGUSR1, &sigact_null, NULL);\n-        PR_ASSERT(0 == rv);\n-    }\n-#endif /* defined(PT_NO_SIGTIMEDWAIT) */\n+    sigemptyset(&sigwait_set);\n+#  if defined(PT_NO_SIGTIMEDWAIT)\n+    sigaddset(&sigwait_set, SIGUSR1);\n+#  else\n+    sigaddset(&sigwait_set, SIGUSR2);\n+#  endif /* defined(PT_NO_SIGTIMEDWAIT) */\n+  }\n+#  if defined(PT_NO_SIGTIMEDWAIT)\n+  {\n+    struct sigaction sigact_null;\n+    sigact_null.sa_handler = null_signal_handler;\n+    sigact_null.sa_flags = SA_RESTART;\n+    sigemptyset(&sigact_null.sa_mask);\n+    rv = sigaction(SIGUSR1, &sigact_null, NULL);\n+    PR_ASSERT(0 == rv);\n+  }\n+#  endif /* defined(PT_NO_SIGTIMEDWAIT) */\n }\n \n-PR_IMPLEMENT(void)\n-PR_SetThreadGCAble(void)\n-{\n-    PR_Lock(pt_book.ml);\n-    PR_GetCurrentThread()->state |= PT_THREAD_GCABLE;\n-    PR_Unlock(pt_book.ml);\n+PR_IMPLEMENT(void) PR_SetThreadGCAble(void) {\n+  PR_Lock(pt_book.ml);\n+  PR_GetCurrentThread()->state |= PT_THREAD_GCABLE;\n+  PR_Unlock(pt_book.ml);\n }\n \n-PR_IMPLEMENT(void)\n-PR_ClearThreadGCAble(void)\n-{\n-    PR_Lock(pt_book.ml);\n-    PR_GetCurrentThread()->state &= (~PT_THREAD_GCABLE);\n-    PR_Unlock(pt_book.ml);\n+PR_IMPLEMENT(void) PR_ClearThreadGCAble(void) {\n+  PR_Lock(pt_book.ml);\n+  PR_GetCurrentThread()->state &= (~PT_THREAD_GCABLE);\n+  PR_Unlock(pt_book.ml);\n }\n \n-#if defined(DEBUG)\n+#  if defined(DEBUG)\n static PRBool suspendAllOn = PR_FALSE;\n-#endif\n+#  endif\n \n static PRBool suspendAllSuspended = PR_FALSE;\n \n-PR_IMPLEMENT(PRStatus)\n-PR_EnumerateThreads(PREnumerator func, void* arg)\n-{\n-    PRIntn count = 0;\n-    PRStatus rv = PR_SUCCESS;\n-    PRThread* thred = pt_book.first;\n-\n-#if defined(DEBUG) || defined(FORCE_PR_ASSERT)\n-    PRThread* me = PR_GetCurrentThread();\n-#endif\n-\n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, (\"Begin PR_EnumerateThreads\\n\"));\n-    /*\n-     * $$$\n-     * Need to suspend all threads other than me before doing this.\n-     * This is really a gross and disgusting thing to do. The only\n-     * good thing is that since all other threads are suspended, holding\n-     * the lock during a callback seems like child's play.\n-     * $$$\n+PR_IMPLEMENT(PRStatus) PR_EnumerateThreads(PREnumerator func, void* arg) {\n+  PRIntn count = 0;\n+  PRStatus rv = PR_SUCCESS;\n+  PRThread* thred = pt_book.first;\n+\n+#  if defined(DEBUG) || defined(FORCE_PR_ASSERT)\n+  PRThread* me = PR_GetCurrentThread();\n+#  endif\n+\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, (\"Begin PR_EnumerateThreads\\n\"));\n+  /*\n+   * $$$\n+   * Need to suspend all threads other than me before doing this.\n+   * This is really a gross and disgusting thing to do. The only\n+   * good thing is that since all other threads are suspended, holding\n+   * the lock during a callback seems like child's play.\n+   * $$$\n+   */\n+  PR_ASSERT(suspendAllOn);\n+\n+  while (thred != NULL) {\n+    /* Steve Morse, 4-23-97: Note that we can't walk a queue by taking\n+     * qp->next after applying the function \"func\".  In particular, \"func\"\n+     * might remove the thread from the queue and put it into another one in\n+     * which case qp->next no longer points to the next entry in the original\n+     * queue.\n+     *\n+     * To get around this problem, we save qp->next in qp_next before applying\n+     * \"func\" and use that saved value as the next value after applying \"func\".\n      */\n-    PR_ASSERT(suspendAllOn);\n-\n-    while (thred != NULL) {\n-        /* Steve Morse, 4-23-97: Note that we can't walk a queue by taking\n-         * qp->next after applying the function \"func\".  In particular, \"func\"\n-         * might remove the thread from the queue and put it into another one in\n-         * which case qp->next no longer points to the next entry in the original\n-         * queue.\n-         *\n-         * To get around this problem, we save qp->next in qp_next before applying\n-         * \"func\" and use that saved value as the next value after applying \"func\".\n-         */\n-        PRThread* next = thred->next;\n-\n-        if (_PT_IS_GCABLE_THREAD(thred)) {\n-            PR_ASSERT((thred == me) || (thred->suspend & PT_THREAD_SUSPENDED));\n-            PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n-                   (\"In PR_EnumerateThreads callback thread %p thid = %X\\n\", thred,\n-                    thred->id));\n-\n-            rv = func(thred, count++, arg);\n-            if (rv != PR_SUCCESS) {\n-                return rv;\n-            }\n-        }\n-        thred = next;\n+    PRThread* next = thred->next;\n+\n+    if (_PT_IS_GCABLE_THREAD(thred)) {\n+      PR_ASSERT((thred == me) || (thred->suspend & PT_THREAD_SUSPENDED));\n+      PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n+             (\"In PR_EnumerateThreads callback thread %p thid = %X\\n\", thred,\n+              thred->id));\n+\n+      rv = func(thred, count++, arg);\n+      if (rv != PR_SUCCESS) {\n+        return rv;\n+      }\n     }\n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n-           (\"End PR_EnumerateThreads count = %d \\n\", count));\n-    return rv;\n+    thred = next;\n+  }\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n+         (\"End PR_EnumerateThreads count = %d \\n\", count));\n+  return rv;\n } /* PR_EnumerateThreads */\n \n /*\n@@ -1302,373 +1231,349 @@ PR_EnumerateThreads(PREnumerator func, void* arg)\n  * in the signal handler as all synchronization mechanisms just break down.\n  */\n \n-#if defined(PT_NO_SIGTIMEDWAIT)\n-static void\n-null_signal_handler(PRIntn sig)\n-{\n-    return;\n-}\n-#endif\n-\n-static void\n-suspend_signal_handler(PRIntn sig)\n-{\n-    PRThread* me = PR_GetCurrentThread();\n-\n-    PR_ASSERT(me != NULL);\n-    PR_ASSERT(_PT_IS_GCABLE_THREAD(me));\n-    PR_ASSERT((me->suspend & PT_THREAD_SUSPENDED) == 0);\n-\n-    PR_LOG(\n-        _pr_gc_lm, PR_LOG_ALWAYS,\n-        (\"Begin suspend_signal_handler thred %p thread id = %X\\n\", me, me->id));\n-\n-    /*\n-     * save stack pointer\n-     */\n-    me->sp = &me;\n-\n-    /*\n-       At this point, the thread's stack pointer has been saved,\n-       And it is going to enter a wait loop until it is resumed.\n-       So it is _really_ suspended\n-    */\n-\n-    me->suspend |= PT_THREAD_SUSPENDED;\n-\n-    /*\n-     * now, block current thread\n-     */\n-#if defined(PT_NO_SIGTIMEDWAIT)\n-    pthread_cond_signal(&me->suspendResumeCV);\n-    while (me->suspend & PT_THREAD_SUSPENDED) {\n-#if !defined(FREEBSD) && !defined(NETBSD) && !defined(OPENBSD) && \\\n-    !defined(DARWIN) && !defined(RISCOS)\n-        PRIntn rv;\n-        sigwait(&sigwait_set, &rv);\n-#endif\n-    }\n-    me->suspend |= PT_THREAD_RESUMED;\n-    pthread_cond_signal(&me->suspendResumeCV);\n-#else /* defined(PT_NO_SIGTIMEDWAIT) */\n-    while (me->suspend & PT_THREAD_SUSPENDED) {\n-        PRIntn rv = sigtimedwait(&sigwait_set, NULL, &hundredmillisec);\n-        PR_ASSERT(-1 == rv);\n-    }\n-    me->suspend |= PT_THREAD_RESUMED;\n-#endif\n-\n-    /*\n-     * At this point, thread has been resumed, so set a global condition.\n-     * The ResumeAll needs to know that this has really been resumed.\n-     * So the signal handler sets a flag which PR_ResumeAll will reset.\n-     * The PR_ResumeAll must reset this flag ...\n-     */\n-\n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n-           (\"End suspend_signal_handler thred = %p tid = %X\\n\", me, me->id));\n+#  if defined(PT_NO_SIGTIMEDWAIT)\n+static void null_signal_handler(PRIntn sig) { return; }\n+#  endif\n+\n+static void suspend_signal_handler(PRIntn sig) {\n+  PRThread* me = PR_GetCurrentThread();\n+\n+  PR_ASSERT(me != NULL);\n+  PR_ASSERT(_PT_IS_GCABLE_THREAD(me));\n+  PR_ASSERT((me->suspend & PT_THREAD_SUSPENDED) == 0);\n+\n+  PR_LOG(\n+      _pr_gc_lm, PR_LOG_ALWAYS,\n+      (\"Begin suspend_signal_handler thred %p thread id = %X\\n\", me, me->id));\n+\n+  /*\n+   * save stack pointer\n+   */\n+  me->sp = &me;\n+\n+  /*\n+     At this point, the thread's stack pointer has been saved,\n+     And it is going to enter a wait loop until it is resumed.\n+     So it is _really_ suspended\n+  */\n+\n+  me->suspend |= PT_THREAD_SUSPENDED;\n+\n+  /*\n+   * now, block current thread\n+   */\n+#  if defined(PT_NO_SIGTIMEDWAIT)\n+  pthread_cond_signal(&me->suspendResumeCV);\n+  while (me->suspend & PT_THREAD_SUSPENDED) {\n+#    if !defined(FREEBSD) && !defined(NETBSD) && !defined(OPENBSD) && \\\n+        !defined(DARWIN) && !defined(RISCOS)\n+    PRIntn rv;\n+    sigwait(&sigwait_set, &rv);\n+#    endif\n+  }\n+  me->suspend |= PT_THREAD_RESUMED;\n+  pthread_cond_signal(&me->suspendResumeCV);\n+#  else /* defined(PT_NO_SIGTIMEDWAIT) */\n+  while (me->suspend & PT_THREAD_SUSPENDED) {\n+    PRIntn rv = sigtimedwait(&sigwait_set, NULL, &hundredmillisec);\n+    PR_ASSERT(-1 == rv);\n+  }\n+  me->suspend |= PT_THREAD_RESUMED;\n+#  endif\n+\n+  /*\n+   * At this point, thread has been resumed, so set a global condition.\n+   * The ResumeAll needs to know that this has really been resumed.\n+   * So the signal handler sets a flag which PR_ResumeAll will reset.\n+   * The PR_ResumeAll must reset this flag ...\n+   */\n+\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n+         (\"End suspend_signal_handler thred = %p tid = %X\\n\", me, me->id));\n } /* suspend_signal_handler */\n \n-static void\n-pt_SuspendSet(PRThread* thred)\n-{\n-    PRIntn rv;\n+static void pt_SuspendSet(PRThread* thred) {\n+  PRIntn rv;\n \n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n-           (\"pt_SuspendSet thred %p thread id = %X\\n\", thred, thred->id));\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n+         (\"pt_SuspendSet thred %p thread id = %X\\n\", thred, thred->id));\n \n-    /*\n-     * Check the thread state and signal the thread to suspend\n-     */\n+  /*\n+   * Check the thread state and signal the thread to suspend\n+   */\n \n-    PR_ASSERT((thred->suspend & PT_THREAD_SUSPENDED) == 0);\n+  PR_ASSERT((thred->suspend & PT_THREAD_SUSPENDED) == 0);\n \n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n-           (\"doing pthread_kill in pt_SuspendSet thred %p tid = %X\\n\", thred,\n-            thred->id));\n-    rv = pthread_kill(thred->id, SIGUSR2);\n-    PR_ASSERT(0 == rv);\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n+         (\"doing pthread_kill in pt_SuspendSet thred %p tid = %X\\n\", thred,\n+          thred->id));\n+  rv = pthread_kill(thred->id, SIGUSR2);\n+  PR_ASSERT(0 == rv);\n }\n \n-static void\n-pt_SuspendTest(PRThread* thred)\n-{\n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n-           (\"Begin pt_SuspendTest thred %p thread id = %X\\n\", thred, thred->id));\n-\n-    /*\n-     * Wait for the thread to be really suspended. This happens when the\n-     * suspend signal handler stores the stack pointer and sets the state\n-     * to suspended.\n-     */\n-\n-#if defined(PT_NO_SIGTIMEDWAIT)\n-    pthread_mutex_lock(&thred->suspendResumeMutex);\n-    while ((thred->suspend & PT_THREAD_SUSPENDED) == 0) {\n-        pthread_cond_timedwait(&thred->suspendResumeCV, &thred->suspendResumeMutex,\n-                               &onemillisec);\n-    }\n-    pthread_mutex_unlock(&thred->suspendResumeMutex);\n-#else\n-    while ((thred->suspend & PT_THREAD_SUSPENDED) == 0) {\n-        PRIntn rv = sigtimedwait(&sigwait_set, NULL, &onemillisec);\n-        PR_ASSERT(-1 == rv);\n-    }\n-#endif\n-\n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n-           (\"End pt_SuspendTest thred %p tid %X\\n\", thred, thred->id));\n+static void pt_SuspendTest(PRThread* thred) {\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n+         (\"Begin pt_SuspendTest thred %p thread id = %X\\n\", thred, thred->id));\n+\n+  /*\n+   * Wait for the thread to be really suspended. This happens when the\n+   * suspend signal handler stores the stack pointer and sets the state\n+   * to suspended.\n+   */\n+\n+#  if defined(PT_NO_SIGTIMEDWAIT)\n+  pthread_mutex_lock(&thred->suspendResumeMutex);\n+  while ((thred->suspend & PT_THREAD_SUSPENDED) == 0) {\n+    pthread_cond_timedwait(&thred->suspendResumeCV, &thred->suspendResumeMutex,\n+                           &onemillisec);\n+  }\n+  pthread_mutex_unlock(&thred->suspendResumeMutex);\n+#  else\n+  while ((thred->suspend & PT_THREAD_SUSPENDED) == 0) {\n+    PRIntn rv = sigtimedwait(&sigwait_set, NULL, &onemillisec);\n+    PR_ASSERT(-1 == rv);\n+  }\n+#  endif\n+\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n+         (\"End pt_SuspendTest thred %p tid %X\\n\", thred, thred->id));\n } /* pt_SuspendTest */\n \n-static void\n-pt_ResumeSet(PRThread* thred)\n-{\n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n-           (\"pt_ResumeSet thred %p thread id = %X\\n\", thred, thred->id));\n+static void pt_ResumeSet(PRThread* thred) {\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n+         (\"pt_ResumeSet thred %p thread id = %X\\n\", thred, thred->id));\n \n-    /*\n-     * Clear the global state and set the thread state so that it will\n-     * continue past yield loop in the suspend signal handler\n-     */\n+  /*\n+   * Clear the global state and set the thread state so that it will\n+   * continue past yield loop in the suspend signal handler\n+   */\n \n-    PR_ASSERT(thred->suspend & PT_THREAD_SUSPENDED);\n+  PR_ASSERT(thred->suspend & PT_THREAD_SUSPENDED);\n \n-    thred->suspend &= ~PT_THREAD_SUSPENDED;\n+  thred->suspend &= ~PT_THREAD_SUSPENDED;\n \n-#if defined(PT_NO_SIGTIMEDWAIT)\n-    pthread_kill(thred->id, SIGUSR1);\n-#endif\n+#  if defined(PT_NO_SIGTIMEDWAIT)\n+  pthread_kill(thred->id, SIGUSR1);\n+#  endif\n \n } /* pt_ResumeSet */\n \n-static void\n-pt_ResumeTest(PRThread* thred)\n-{\n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n-           (\"Begin pt_ResumeTest thred %p thread id = %X\\n\", thred, thred->id));\n-\n-    /*\n-     * Wait for the threads resume state to change\n-     * to indicate it is really resumed\n-     */\n-#if defined(PT_NO_SIGTIMEDWAIT)\n-    pthread_mutex_lock(&thred->suspendResumeMutex);\n-    while ((thred->suspend & PT_THREAD_RESUMED) == 0) {\n-        pthread_cond_timedwait(&thred->suspendResumeCV, &thred->suspendResumeMutex,\n-                               &onemillisec);\n-    }\n-    pthread_mutex_unlock(&thred->suspendResumeMutex);\n-#else\n-    while ((thred->suspend & PT_THREAD_RESUMED) == 0) {\n-        PRIntn rv = sigtimedwait(&sigwait_set, NULL, &onemillisec);\n-        PR_ASSERT(-1 == rv);\n-    }\n-#endif\n-\n-    thred->suspend &= ~PT_THREAD_RESUMED;\n-\n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n-           (\"End pt_ResumeTest thred %p tid %X\\n\", thred, thred->id));\n+static void pt_ResumeTest(PRThread* thred) {\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n+         (\"Begin pt_ResumeTest thred %p thread id = %X\\n\", thred, thred->id));\n+\n+  /*\n+   * Wait for the threads resume state to change\n+   * to indicate it is really resumed\n+   */\n+#  if defined(PT_NO_SIGTIMEDWAIT)\n+  pthread_mutex_lock(&thred->suspendResumeMutex);\n+  while ((thred->suspend & PT_THREAD_RESUMED) == 0) {\n+    pthread_cond_timedwait(&thred->suspendResumeCV, &thred->suspendResumeMutex,\n+                           &onemillisec);\n+  }\n+  pthread_mutex_unlock(&thred->suspendResumeMutex);\n+#  else\n+  while ((thred->suspend & PT_THREAD_RESUMED) == 0) {\n+    PRIntn rv = sigtimedwait(&sigwait_set, NULL, &onemillisec);\n+    PR_ASSERT(-1 == rv);\n+  }\n+#  endif\n+\n+  thred->suspend &= ~PT_THREAD_RESUMED;\n+\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n+         (\"End pt_ResumeTest thred %p tid %X\\n\", thred, thred->id));\n } /* pt_ResumeTest */\n \n static pthread_once_t pt_gc_support_control = PTHREAD_ONCE_INIT;\n \n-PR_IMPLEMENT(void)\n-PR_SuspendAll(void)\n-{\n-#ifdef DEBUG\n-    PRIntervalTime stime, etime;\n-#endif\n-    PRThread* thred = pt_book.first;\n-    PRThread* me = PR_GetCurrentThread();\n-    int rv;\n-\n-    rv = pthread_once(&pt_gc_support_control, init_pthread_gc_support);\n-    PR_ASSERT(0 == rv);\n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, (\"Begin PR_SuspendAll\\n\"));\n-    /*\n-     * Stop all threads which are marked GC able.\n-     */\n-    PR_Lock(pt_book.ml);\n-#ifdef DEBUG\n-    suspendAllOn = PR_TRUE;\n-    stime = PR_IntervalNow();\n-#endif\n-    while (thred != NULL) {\n-        if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) {\n-            pt_SuspendSet(thred);\n-        }\n-        thred = thred->next;\n+PR_IMPLEMENT(void) PR_SuspendAll(void) {\n+#  ifdef DEBUG\n+  PRIntervalTime stime, etime;\n+#  endif\n+  PRThread* thred = pt_book.first;\n+  PRThread* me = PR_GetCurrentThread();\n+  int rv;\n+\n+  rv = pthread_once(&pt_gc_support_control, init_pthread_gc_support);\n+  PR_ASSERT(0 == rv);\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, (\"Begin PR_SuspendAll\\n\"));\n+  /*\n+   * Stop all threads which are marked GC able.\n+   */\n+  PR_Lock(pt_book.ml);\n+#  ifdef DEBUG\n+  suspendAllOn = PR_TRUE;\n+  stime = PR_IntervalNow();\n+#  endif\n+  while (thred != NULL) {\n+    if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) {\n+      pt_SuspendSet(thred);\n     }\n-\n-    /* Wait till they are really suspended */\n-    thred = pt_book.first;\n-    while (thred != NULL) {\n-        if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) {\n-            pt_SuspendTest(thred);\n-        }\n-        thred = thred->next;\n+    thred = thred->next;\n+  }\n+\n+  /* Wait till they are really suspended */\n+  thred = pt_book.first;\n+  while (thred != NULL) {\n+    if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) {\n+      pt_SuspendTest(thred);\n     }\n+    thred = thred->next;\n+  }\n \n-    suspendAllSuspended = PR_TRUE;\n+  suspendAllSuspended = PR_TRUE;\n \n-#ifdef DEBUG\n-    etime = PR_IntervalNow();\n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n-           (\"End PR_SuspendAll (time %dms)\\n\",\n-            PR_IntervalToMilliseconds(etime - stime)));\n-#endif\n+#  ifdef DEBUG\n+  etime = PR_IntervalNow();\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n+         (\"End PR_SuspendAll (time %dms)\\n\",\n+          PR_IntervalToMilliseconds(etime - stime)));\n+#  endif\n } /* PR_SuspendAll */\n \n-PR_IMPLEMENT(void)\n-PR_ResumeAll(void)\n-{\n-#ifdef DEBUG\n-    PRIntervalTime stime, etime;\n-#endif\n-    PRThread* thred = pt_book.first;\n-    PRThread* me = PR_GetCurrentThread();\n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, (\"Begin PR_ResumeAll\\n\"));\n-    /*\n-     * Resume all previously suspended GC able threads.\n-     */\n-    suspendAllSuspended = PR_FALSE;\n-#ifdef DEBUG\n-    stime = PR_IntervalNow();\n-#endif\n-\n-    while (thred != NULL) {\n-        if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) {\n-            pt_ResumeSet(thred);\n-        }\n-        thred = thred->next;\n+PR_IMPLEMENT(void) PR_ResumeAll(void) {\n+#  ifdef DEBUG\n+  PRIntervalTime stime, etime;\n+#  endif\n+  PRThread* thred = pt_book.first;\n+  PRThread* me = PR_GetCurrentThread();\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, (\"Begin PR_ResumeAll\\n\"));\n+  /*\n+   * Resume all previously suspended GC able threads.\n+   */\n+  suspendAllSuspended = PR_FALSE;\n+#  ifdef DEBUG\n+  stime = PR_IntervalNow();\n+#  endif\n+\n+  while (thred != NULL) {\n+    if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) {\n+      pt_ResumeSet(thred);\n     }\n+    thred = thred->next;\n+  }\n \n-    thred = pt_book.first;\n-    while (thred != NULL) {\n-        if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) {\n-            pt_ResumeTest(thred);\n-        }\n-        thred = thred->next;\n+  thred = pt_book.first;\n+  while (thred != NULL) {\n+    if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) {\n+      pt_ResumeTest(thred);\n     }\n-\n-    PR_Unlock(pt_book.ml);\n-#ifdef DEBUG\n-    suspendAllOn = PR_FALSE;\n-    etime = PR_IntervalNow();\n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n-           (\"End PR_ResumeAll (time %dms)\\n\",\n-            PR_IntervalToMilliseconds(etime - stime)));\n-#endif\n+    thred = thred->next;\n+  }\n+\n+  PR_Unlock(pt_book.ml);\n+#  ifdef DEBUG\n+  suspendAllOn = PR_FALSE;\n+  etime = PR_IntervalNow();\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n+         (\"End PR_ResumeAll (time %dms)\\n\",\n+          PR_IntervalToMilliseconds(etime - stime)));\n+#  endif\n } /* PR_ResumeAll */\n \n /* Return the stack pointer for the given thread- used by the GC */\n-PR_IMPLEMENT(void*)\n-PR_GetSP(PRThread* thred)\n-{\n-    PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n-           (\"in PR_GetSP thred %p thid = %X, sp = %p\\n\", thred, thred->id,\n-            thred->sp));\n-    return thred->sp;\n+PR_IMPLEMENT(void*) PR_GetSP(PRThread* thred) {\n+  PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,\n+         (\"in PR_GetSP thred %p thid = %X, sp = %p\\n\", thred, thred->id,\n+          thred->sp));\n+  return thred->sp;\n } /* PR_GetSP */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_SetCurrentThreadName(const char* name)\n-{\n-    PRThread* thread;\n-    size_t nameLen;\n-    int result = 0;\n+PR_IMPLEMENT(PRStatus) PR_SetCurrentThreadName(const char* name) {\n+  PRThread* thread;\n+  size_t nameLen;\n+  int result = 0;\n \n-    if (!name) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-\n-    thread = PR_GetCurrentThread();\n-    if (!thread) {\n-        return PR_FAILURE;\n-    }\n-\n-    PR_Free(thread->name);\n-    nameLen = strlen(name);\n-    thread->name = (char*)PR_Malloc(nameLen + 1);\n-    if (!thread->name) {\n-        return PR_FAILURE;\n-    }\n-    memcpy(thread->name, name, nameLen + 1);\n-\n-#if defined(OPENBSD) || defined(FREEBSD) || defined(DRAGONFLY)\n-    pthread_set_name_np(thread->id, name);\n-#elif defined(ANDROID)\n-    prctl(PR_SET_NAME, (unsigned long)(name));\n-#elif defined(NETBSD)\n-    result = pthread_setname_np(thread->id, \"%s\", (void*)name);\n-#else /* not BSD */\n-    /*\n-     * On OSX, pthread_setname_np is only available in 10.6 or later, so test\n-     * for it at runtime.  It also may not be available on all linux distros.\n-     */\n-#if defined(DARWIN)\n-    int (*dynamic_pthread_setname_np)(const char*);\n-#else\n-    int (*dynamic_pthread_setname_np)(pthread_t, const char*);\n-#endif\n-\n-    *(void**)(&dynamic_pthread_setname_np) =\n-        dlsym(RTLD_DEFAULT, \"pthread_setname_np\");\n-    if (!dynamic_pthread_setname_np) {\n-        return PR_SUCCESS;\n-    }\n-\n-#if defined(DARWIN)\n-    /* Mac OS X has a length limit of 63 characters, but there is no API\n-     * exposing it.\n-     */\n-#define SETNAME_LENGTH_CONSTRAINT 63\n-#else\n-    /*\n-     * The 15-character name length limit is an experimentally determined\n-     * length of a null-terminated string that most linux distros accept\n-     * as an argument to pthread_setname_np.  Otherwise the E2BIG\n-     * error is returned by the function.\n-     */\n-#define SETNAME_LENGTH_CONSTRAINT 15\n-#endif\n-#define SETNAME_FRAGMENT1_LENGTH (SETNAME_LENGTH_CONSTRAINT >> 1)\n-#define SETNAME_FRAGMENT2_LENGTH \\\n-    (SETNAME_LENGTH_CONSTRAINT - SETNAME_FRAGMENT1_LENGTH - 1)\n-    char name_dup[SETNAME_LENGTH_CONSTRAINT + 1];\n-    if (nameLen > SETNAME_LENGTH_CONSTRAINT) {\n-        memcpy(name_dup, name, SETNAME_FRAGMENT1_LENGTH);\n-        name_dup[SETNAME_FRAGMENT1_LENGTH] = '~';\n-        /* Note that this also copies the null terminator. */\n-        memcpy(name_dup + SETNAME_FRAGMENT1_LENGTH + 1,\n-               name + nameLen - SETNAME_FRAGMENT2_LENGTH,\n-               SETNAME_FRAGMENT2_LENGTH + 1);\n-        name = name_dup;\n-    }\n+  if (!name) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-#if defined(DARWIN)\n-    result = dynamic_pthread_setname_np(name);\n-#else\n-    result = dynamic_pthread_setname_np(thread->id, name);\n-#endif\n-#endif /* not BSD */\n+  thread = PR_GetCurrentThread();\n+  if (!thread) {\n+    return PR_FAILURE;\n+  }\n \n-    if (result) {\n-        PR_SetError(PR_UNKNOWN_ERROR, result);\n-        return PR_FAILURE;\n-    }\n+  PR_Free(thread->name);\n+  nameLen = strlen(name);\n+  thread->name = (char*)PR_Malloc(nameLen + 1);\n+  if (!thread->name) {\n+    return PR_FAILURE;\n+  }\n+  memcpy(thread->name, name, nameLen + 1);\n+\n+#  if defined(OPENBSD) || defined(FREEBSD) || defined(DRAGONFLY)\n+  pthread_set_name_np(thread->id, name);\n+#  elif defined(ANDROID)\n+  prctl(PR_SET_NAME, (unsigned long)(name));\n+#  elif defined(NETBSD)\n+  result = pthread_setname_np(thread->id, \"%s\", (void*)name);\n+#  else /* not BSD */\n+  /*\n+   * On OSX, pthread_setname_np is only available in 10.6 or later, so test\n+   * for it at runtime.  It also may not be available on all linux distros.\n+   */\n+#    if defined(DARWIN)\n+  int (*dynamic_pthread_setname_np)(const char*);\n+#    else\n+  int (*dynamic_pthread_setname_np)(pthread_t, const char*);\n+#    endif\n+\n+  *(void**)(&dynamic_pthread_setname_np) =\n+      dlsym(RTLD_DEFAULT, \"pthread_setname_np\");\n+  if (!dynamic_pthread_setname_np) {\n     return PR_SUCCESS;\n+  }\n+\n+#    if defined(DARWIN)\n+  /* Mac OS X has a length limit of 63 characters, but there is no API\n+   * exposing it.\n+   */\n+#      define SETNAME_LENGTH_CONSTRAINT 63\n+#    else\n+  /*\n+   * The 15-character name length limit is an experimentally determined\n+   * length of a null-terminated string that most linux distros accept\n+   * as an argument to pthread_setname_np.  Otherwise the E2BIG\n+   * error is returned by the function.\n+   */\n+#      define SETNAME_LENGTH_CONSTRAINT 15\n+#    endif\n+#    define SETNAME_FRAGMENT1_LENGTH (SETNAME_LENGTH_CONSTRAINT >> 1)\n+#    define SETNAME_FRAGMENT2_LENGTH \\\n+      (SETNAME_LENGTH_CONSTRAINT - SETNAME_FRAGMENT1_LENGTH - 1)\n+  char name_dup[SETNAME_LENGTH_CONSTRAINT + 1];\n+  if (nameLen > SETNAME_LENGTH_CONSTRAINT) {\n+    memcpy(name_dup, name, SETNAME_FRAGMENT1_LENGTH);\n+    name_dup[SETNAME_FRAGMENT1_LENGTH] = '~';\n+    /* Note that this also copies the null terminator. */\n+    memcpy(name_dup + SETNAME_FRAGMENT1_LENGTH + 1,\n+           name + nameLen - SETNAME_FRAGMENT2_LENGTH,\n+           SETNAME_FRAGMENT2_LENGTH + 1);\n+    name = name_dup;\n+  }\n+\n+#    if defined(DARWIN)\n+  result = dynamic_pthread_setname_np(name);\n+#    else\n+  result = dynamic_pthread_setname_np(thread->id, name);\n+#    endif\n+#  endif /* not BSD */\n+\n+  if (result) {\n+    PR_SetError(PR_UNKNOWN_ERROR, result);\n+    return PR_FAILURE;\n+  }\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(const char*)\n-PR_GetThreadName(const PRThread* thread)\n-{\n-    if (!thread) {\n-        return NULL;\n-    }\n-    return thread->name;\n+PR_IMPLEMENT(const char*) PR_GetThreadName(const PRThread* thread) {\n+  if (!thread) {\n+    return NULL;\n+  }\n+  return thread->name;\n }\n \n #endif /* defined(_PR_PTHREADS) */\ndiff --git a/nspr/pr/src/threads/.cvsignore b/nspr/pr/src/threads/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/src/threads/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/src/threads/combined/.cvsignore b/nspr/pr/src/threads/combined/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/src/threads/combined/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/src/threads/combined/prucpu.c b/nspr/pr/src/threads/combined/prucpu.c\nindex a8dfeca..9e214f9 100644\n--- a/nspr/pr/src/threads/combined/prucpu.c\n+++ b/nspr/pr/src/threads/combined/prucpu.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -15,9 +16,9 @@ PRInt32 _pr_md_idle_cpus; /* number of idle cpus */\n  * So we use a _MDLock to protect _pr_md_idle_cpus.\n  */\n #if !defined(_PR_LOCAL_THREADS_ONLY) && !defined(_PR_GLOBAL_THREADS_ONLY)\n-#ifndef _PR_HAVE_ATOMIC_OPS\n+#  ifndef _PR_HAVE_ATOMIC_OPS\n static _MDLock _pr_md_idle_cpus_lock;\n-#endif\n+#  endif\n #endif\n PRUintn _pr_numCPU;\n PRInt32 _pr_cpus_exit;\n@@ -32,59 +33,57 @@ static void PR_CALLBACK _PR_CPU_Idle(void*);\n static _PRCPU* _PR_CreateCPU(void);\n static PRStatus _PR_StartCPU(_PRCPU* cpu, PRThread* thread);\n \n-#if !defined(_PR_LOCAL_THREADS_ONLY)\n+#  if !defined(_PR_LOCAL_THREADS_ONLY)\n static void _PR_RunCPU(void* arg);\n-#endif\n+#  endif\n \n-void\n-_PR_InitCPUs()\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+void _PR_InitCPUs() {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    if (_native_threads_only) {\n-        return;\n-    }\n+  if (_native_threads_only) {\n+    return;\n+  }\n \n-    _pr_cpuID = 0;\n-    _MD_NEW_LOCK(&_pr_cpuLock);\n-#if !defined(_PR_LOCAL_THREADS_ONLY) && !defined(_PR_GLOBAL_THREADS_ONLY)\n-#ifndef _PR_HAVE_ATOMIC_OPS\n-    _MD_NEW_LOCK(&_pr_md_idle_cpus_lock);\n-#endif\n-#endif\n+  _pr_cpuID = 0;\n+  _MD_NEW_LOCK(&_pr_cpuLock);\n+#  if !defined(_PR_LOCAL_THREADS_ONLY) && !defined(_PR_GLOBAL_THREADS_ONLY)\n+#    ifndef _PR_HAVE_ATOMIC_OPS\n+  _MD_NEW_LOCK(&_pr_md_idle_cpus_lock);\n+#    endif\n+#  endif\n \n-#ifdef _PR_LOCAL_THREADS_ONLY\n+#  ifdef _PR_LOCAL_THREADS_ONLY\n \n-#ifdef HAVE_CUSTOM_USER_THREADS\n-    _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(me);\n-#endif\n+#    ifdef HAVE_CUSTOM_USER_THREADS\n+  _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(me);\n+#    endif\n \n-    /* Now start the first CPU. */\n-    _pr_primordialCPU = _PR_CreateCPU();\n-    _pr_numCPU = 1;\n-    _PR_StartCPU(_pr_primordialCPU, me);\n+  /* Now start the first CPU. */\n+  _pr_primordialCPU = _PR_CreateCPU();\n+  _pr_numCPU = 1;\n+  _PR_StartCPU(_pr_primordialCPU, me);\n \n-    _PR_MD_SET_CURRENT_CPU(_pr_primordialCPU);\n+  _PR_MD_SET_CURRENT_CPU(_pr_primordialCPU);\n \n-    /* Initialize cpu for current thread (could be different from me) */\n-    _PR_MD_CURRENT_THREAD()->cpu = _pr_primordialCPU;\n+  /* Initialize cpu for current thread (could be different from me) */\n+  _PR_MD_CURRENT_THREAD()->cpu = _pr_primordialCPU;\n \n-    _PR_MD_SET_LAST_THREAD(me);\n+  _PR_MD_SET_LAST_THREAD(me);\n \n-#else /* Combined MxN model */\n+#  else /* Combined MxN model */\n \n-    _pr_primordialCPU = _PR_CreateCPU();\n-    _pr_numCPU = 1;\n-    _PR_CreateThread(PR_SYSTEM_THREAD, _PR_RunCPU, _pr_primordialCPU,\n-                     PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD,\n-                     0, _PR_IDLE_THREAD);\n+  _pr_primordialCPU = _PR_CreateCPU();\n+  _pr_numCPU = 1;\n+  _PR_CreateThread(PR_SYSTEM_THREAD, _PR_RunCPU, _pr_primordialCPU,\n+                   PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD,\n+                   0, _PR_IDLE_THREAD);\n \n-#endif /* _PR_LOCAL_THREADS_ONLY */\n+#  endif /* _PR_LOCAL_THREADS_ONLY */\n \n-    _PR_MD_INIT_CPUS();\n+  _PR_MD_INIT_CPUS();\n }\n \n-#ifdef WINNT\n+#  ifdef WINNT\n /*\n  * Right now this function merely stops the CPUs and does\n  * not do any other cleanup.\n@@ -93,46 +92,42 @@ _PR_InitCPUs()\n  * affects the WINNT version of NSPR, but it would be nice\n  * to implement this function for other platforms too.\n  */\n-void\n-_PR_CleanupCPUs(void)\n-{\n-    PRUintn i;\n-    PRCList* qp;\n-    _PRCPU* cpu;\n-\n-    _pr_cpus_exit = 1;\n-    for (i = 0; i < _pr_numCPU; i++) {\n-        _PR_MD_WAKEUP_WAITER(NULL);\n-    }\n-    for (qp = _PR_CPUQ().next; qp != &_PR_CPUQ(); qp = qp->next) {\n-        cpu = _PR_CPU_PTR(qp);\n-        _PR_MD_JOIN_THREAD(&cpu->thread->md);\n-    }\n+void _PR_CleanupCPUs(void) {\n+  PRUintn i;\n+  PRCList* qp;\n+  _PRCPU* cpu;\n+\n+  _pr_cpus_exit = 1;\n+  for (i = 0; i < _pr_numCPU; i++) {\n+    _PR_MD_WAKEUP_WAITER(NULL);\n+  }\n+  for (qp = _PR_CPUQ().next; qp != &_PR_CPUQ(); qp = qp->next) {\n+    cpu = _PR_CPU_PTR(qp);\n+    _PR_MD_JOIN_THREAD(&cpu->thread->md);\n+  }\n }\n-#endif\n+#  endif\n \n-static _PRCPUQueue*\n-_PR_CreateCPUQueue(void)\n-{\n-    PRInt32 index;\n-    _PRCPUQueue* cpuQueue;\n-    cpuQueue = PR_NEWZAP(_PRCPUQueue);\n+static _PRCPUQueue* _PR_CreateCPUQueue(void) {\n+  PRInt32 index;\n+  _PRCPUQueue* cpuQueue;\n+  cpuQueue = PR_NEWZAP(_PRCPUQueue);\n \n-    _MD_NEW_LOCK(&cpuQueue->runQLock);\n-    _MD_NEW_LOCK(&cpuQueue->sleepQLock);\n-    _MD_NEW_LOCK(&cpuQueue->miscQLock);\n+  _MD_NEW_LOCK(&cpuQueue->runQLock);\n+  _MD_NEW_LOCK(&cpuQueue->sleepQLock);\n+  _MD_NEW_LOCK(&cpuQueue->miscQLock);\n \n-    for (index = 0; index < PR_ARRAY_SIZE(cpuQueue->runQ); index++) {\n-        PR_INIT_CLIST(&(cpuQueue->runQ[index]));\n-    }\n-    PR_INIT_CLIST(&(cpuQueue->sleepQ));\n-    PR_INIT_CLIST(&(cpuQueue->pauseQ));\n-    PR_INIT_CLIST(&(cpuQueue->suspendQ));\n-    PR_INIT_CLIST(&(cpuQueue->waitingToJoinQ));\n+  for (index = 0; index < PR_ARRAY_SIZE(cpuQueue->runQ); index++) {\n+    PR_INIT_CLIST(&(cpuQueue->runQ[index]));\n+  }\n+  PR_INIT_CLIST(&(cpuQueue->sleepQ));\n+  PR_INIT_CLIST(&(cpuQueue->pauseQ));\n+  PR_INIT_CLIST(&(cpuQueue->suspendQ));\n+  PR_INIT_CLIST(&(cpuQueue->waitingToJoinQ));\n \n-    cpuQueue->numCPUs = 1;\n+  cpuQueue->numCPUs = 1;\n \n-    return cpuQueue;\n+  return cpuQueue;\n }\n \n /*\n@@ -154,20 +149,18 @@ _PR_CreateCPUQueue(void)\n  * by DllMain, the primordial CPU thread won't run until DLL\n  * initialization is finished.\n  */\n-static _PRCPU*\n-_PR_CreateCPU(void)\n-{\n-    _PRCPU* cpu;\n-\n-    cpu = PR_NEWZAP(_PRCPU);\n-    if (cpu) {\n-        cpu->queue = _PR_CreateCPUQueue();\n-        if (!cpu->queue) {\n-            PR_DELETE(cpu);\n-            return NULL;\n-        }\n+static _PRCPU* _PR_CreateCPU(void) {\n+  _PRCPU* cpu;\n+\n+  cpu = PR_NEWZAP(_PRCPU);\n+  if (cpu) {\n+    cpu->queue = _PR_CreateCPUQueue();\n+    if (!cpu->queue) {\n+      PR_DELETE(cpu);\n+      return NULL;\n     }\n-    return cpu;\n+  }\n+  return cpu;\n }\n \n /*\n@@ -178,238 +171,228 @@ _PR_CreateCPU(void)\n  *\n  * If this function fails, 'cpu' is destroyed.\n  */\n-static PRStatus\n-_PR_StartCPU(_PRCPU* cpu, PRThread* thread)\n-{\n-    /*\n-    ** Start a new cpu. The assumption this code makes is that the\n-    ** underlying operating system creates a stack to go with the new\n-    ** native thread. That stack will be used by the cpu when pausing.\n-    */\n-\n-    PR_ASSERT(!_native_threads_only);\n-\n-    cpu->last_clock = PR_IntervalNow();\n-\n-    /* Before we create any threads on this CPU we have to\n-     * set the current CPU\n-     */\n-    _PR_MD_SET_CURRENT_CPU(cpu);\n-    _PR_MD_INIT_RUNNING_CPU(cpu);\n-    thread->cpu = cpu;\n-\n-    cpu->idle_thread = _PR_CreateThread(\n-        PR_SYSTEM_THREAD, _PR_CPU_Idle, (void*)cpu, PR_PRIORITY_NORMAL,\n-        PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0, _PR_IDLE_THREAD);\n-\n-    if (!cpu->idle_thread) {\n-        /* didn't clean up CPU queue XXXMB */\n-        PR_DELETE(cpu);\n-        return PR_FAILURE;\n-    }\n-    PR_ASSERT(cpu->idle_thread->cpu == cpu);\n-\n-    cpu->idle_thread->no_sched = 0;\n-\n-    cpu->thread = thread;\n-\n-    if (_pr_cpu_affinity_mask) {\n-        PR_SetThreadAffinityMask(thread, _pr_cpu_affinity_mask);\n-    }\n-\n-    /* Created and started a new CPU */\n-    _PR_CPU_LIST_LOCK();\n-    cpu->id = _pr_cpuID++;\n-    PR_APPEND_LINK(&cpu->links, &_PR_CPUQ());\n-    _PR_CPU_LIST_UNLOCK();\n-\n-    return PR_SUCCESS;\n+static PRStatus _PR_StartCPU(_PRCPU* cpu, PRThread* thread) {\n+  /*\n+  ** Start a new cpu. The assumption this code makes is that the\n+  ** underlying operating system creates a stack to go with the new\n+  ** native thread. That stack will be used by the cpu when pausing.\n+  */\n+\n+  PR_ASSERT(!_native_threads_only);\n+\n+  cpu->last_clock = PR_IntervalNow();\n+\n+  /* Before we create any threads on this CPU we have to\n+   * set the current CPU\n+   */\n+  _PR_MD_SET_CURRENT_CPU(cpu);\n+  _PR_MD_INIT_RUNNING_CPU(cpu);\n+  thread->cpu = cpu;\n+\n+  cpu->idle_thread = _PR_CreateThread(\n+      PR_SYSTEM_THREAD, _PR_CPU_Idle, (void*)cpu, PR_PRIORITY_NORMAL,\n+      PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0, _PR_IDLE_THREAD);\n+\n+  if (!cpu->idle_thread) {\n+    /* didn't clean up CPU queue XXXMB */\n+    PR_DELETE(cpu);\n+    return PR_FAILURE;\n+  }\n+  PR_ASSERT(cpu->idle_thread->cpu == cpu);\n+\n+  cpu->idle_thread->no_sched = 0;\n+\n+  cpu->thread = thread;\n+\n+  if (_pr_cpu_affinity_mask) {\n+    PR_SetThreadAffinityMask(thread, _pr_cpu_affinity_mask);\n+  }\n+\n+  /* Created and started a new CPU */\n+  _PR_CPU_LIST_LOCK();\n+  cpu->id = _pr_cpuID++;\n+  PR_APPEND_LINK(&cpu->links, &_PR_CPUQ());\n+  _PR_CPU_LIST_UNLOCK();\n+\n+  return PR_SUCCESS;\n }\n \n-#if !defined(_PR_GLOBAL_THREADS_ONLY) && !defined(_PR_LOCAL_THREADS_ONLY)\n+#  if !defined(_PR_GLOBAL_THREADS_ONLY) && !defined(_PR_LOCAL_THREADS_ONLY)\n /*\n ** This code is used during a cpu's initial creation.\n */\n-static void\n-_PR_RunCPU(void* arg)\n-{\n-    _PRCPU* cpu = (_PRCPU*)arg;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    PR_ASSERT(NULL != me);\n-\n-    /*\n-     * _PR_StartCPU calls _PR_CreateThread to create the\n-     * idle thread.  Because _PR_CreateThread calls PR_Lock,\n-     * the current thread has to remain a global thread\n-     * during the _PR_StartCPU call so that it can wait for\n-     * the lock if the lock is held by another thread.  If\n-     * we clear the _PR_GLOBAL_SCOPE flag in\n-     * _PR_MD_CREATE_PRIMORDIAL_THREAD, the current thread\n-     * will be treated as a local thread and have trouble\n-     * waiting for the lock because the CPU is not fully\n-     * constructed yet.\n-     *\n-     * After the CPU is started, it is safe to mark the\n-     * current thread as a local thread.\n-     */\n-\n-#ifdef HAVE_CUSTOM_USER_THREADS\n-    _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(me);\n-#endif\n-\n-    me->no_sched = 1;\n-    _PR_StartCPU(cpu, me);\n-\n-#ifdef HAVE_CUSTOM_USER_THREADS\n-    me->flags &= (~_PR_GLOBAL_SCOPE);\n-#endif\n-\n-    _PR_MD_SET_CURRENT_CPU(cpu);\n-    _PR_MD_SET_CURRENT_THREAD(cpu->thread);\n-    me->cpu = cpu;\n-\n-    while (1) {\n-        PRInt32 is;\n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_INTSOFF(is);\n-        }\n-        _PR_MD_START_INTERRUPTS();\n-        _PR_MD_SWITCH_CONTEXT(me);\n+static void _PR_RunCPU(void* arg) {\n+  _PRCPU* cpu = (_PRCPU*)arg;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  PR_ASSERT(NULL != me);\n+\n+  /*\n+   * _PR_StartCPU calls _PR_CreateThread to create the\n+   * idle thread.  Because _PR_CreateThread calls PR_Lock,\n+   * the current thread has to remain a global thread\n+   * during the _PR_StartCPU call so that it can wait for\n+   * the lock if the lock is held by another thread.  If\n+   * we clear the _PR_GLOBAL_SCOPE flag in\n+   * _PR_MD_CREATE_PRIMORDIAL_THREAD, the current thread\n+   * will be treated as a local thread and have trouble\n+   * waiting for the lock because the CPU is not fully\n+   * constructed yet.\n+   *\n+   * After the CPU is started, it is safe to mark the\n+   * current thread as a local thread.\n+   */\n+\n+#    ifdef HAVE_CUSTOM_USER_THREADS\n+  _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(me);\n+#    endif\n+\n+  me->no_sched = 1;\n+  _PR_StartCPU(cpu, me);\n+\n+#    ifdef HAVE_CUSTOM_USER_THREADS\n+  me->flags &= (~_PR_GLOBAL_SCOPE);\n+#    endif\n+\n+  _PR_MD_SET_CURRENT_CPU(cpu);\n+  _PR_MD_SET_CURRENT_THREAD(cpu->thread);\n+  me->cpu = cpu;\n+\n+  while (1) {\n+    PRInt32 is;\n+    if (!_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_INTSOFF(is);\n     }\n+    _PR_MD_START_INTERRUPTS();\n+    _PR_MD_SWITCH_CONTEXT(me);\n+  }\n }\n-#endif\n-\n-static void PR_CALLBACK\n-_PR_CPU_Idle(void* _cpu)\n-{\n-    _PRCPU* cpu = (_PRCPU*)_cpu;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    PR_ASSERT(NULL != me);\n-\n-    me->cpu = cpu;\n-    cpu->idle_thread = me;\n-    if (_MD_LAST_THREAD()) {\n-        _MD_LAST_THREAD()->no_sched = 0;\n-    }\n+#  endif\n+\n+static void PR_CALLBACK _PR_CPU_Idle(void* _cpu) {\n+  _PRCPU* cpu = (_PRCPU*)_cpu;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  PR_ASSERT(NULL != me);\n+\n+  me->cpu = cpu;\n+  cpu->idle_thread = me;\n+  if (_MD_LAST_THREAD()) {\n+    _MD_LAST_THREAD()->no_sched = 0;\n+  }\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_MD_SET_INTSOFF(0);\n+  }\n+  while (1) {\n+    PRInt32 is;\n+    PRIntervalTime timeout;\n     if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_MD_SET_INTSOFF(0);\n+      _PR_INTSOFF(is);\n     }\n-    while (1) {\n-        PRInt32 is;\n-        PRIntervalTime timeout;\n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_INTSOFF(is);\n-        }\n-\n-        _PR_RUNQ_LOCK(cpu);\n-#if !defined(_PR_LOCAL_THREADS_ONLY) && !defined(_PR_GLOBAL_THREADS_ONLY)\n-#ifdef _PR_HAVE_ATOMIC_OPS\n-        _PR_MD_ATOMIC_INCREMENT(&_pr_md_idle_cpus);\n-#else\n-        _PR_MD_LOCK(&_pr_md_idle_cpus_lock);\n-        _pr_md_idle_cpus++;\n-        _PR_MD_UNLOCK(&_pr_md_idle_cpus_lock);\n-#endif /* _PR_HAVE_ATOMIC_OPS */\n-#endif\n-        /* If someone on runq; do a nonblocking PAUSECPU */\n-        if (_PR_RUNQREADYMASK(me->cpu) != 0) {\n-            _PR_RUNQ_UNLOCK(cpu);\n-            timeout = PR_INTERVAL_NO_WAIT;\n-        } else {\n-            _PR_RUNQ_UNLOCK(cpu);\n-\n-            _PR_SLEEPQ_LOCK(cpu);\n-            if (PR_CLIST_IS_EMPTY(&_PR_SLEEPQ(me->cpu))) {\n-                timeout = PR_INTERVAL_NO_TIMEOUT;\n-            } else {\n-                PRThread* wakeThread;\n-                wakeThread = _PR_THREAD_PTR(_PR_SLEEPQ(me->cpu).next);\n-                timeout = wakeThread->sleep;\n-            }\n-            _PR_SLEEPQ_UNLOCK(cpu);\n-        }\n-\n-        /* Wait for an IO to complete */\n-        (void)_PR_MD_PAUSE_CPU(timeout);\n-\n-#ifdef WINNT\n-        if (_pr_cpus_exit) {\n-            /* _PR_CleanupCPUs tells us to exit */\n-            _PR_MD_END_THREAD();\n-        }\n-#endif\n \n-#if !defined(_PR_LOCAL_THREADS_ONLY) && !defined(_PR_GLOBAL_THREADS_ONLY)\n-#ifdef _PR_HAVE_ATOMIC_OPS\n-        _PR_MD_ATOMIC_DECREMENT(&_pr_md_idle_cpus);\n-#else\n-        _PR_MD_LOCK(&_pr_md_idle_cpus_lock);\n-        _pr_md_idle_cpus--;\n-        _PR_MD_UNLOCK(&_pr_md_idle_cpus_lock);\n-#endif /* _PR_HAVE_ATOMIC_OPS */\n-#endif\n+    _PR_RUNQ_LOCK(cpu);\n+#  if !defined(_PR_LOCAL_THREADS_ONLY) && !defined(_PR_GLOBAL_THREADS_ONLY)\n+#    ifdef _PR_HAVE_ATOMIC_OPS\n+    _PR_MD_ATOMIC_INCREMENT(&_pr_md_idle_cpus);\n+#    else\n+    _PR_MD_LOCK(&_pr_md_idle_cpus_lock);\n+    _pr_md_idle_cpus++;\n+    _PR_MD_UNLOCK(&_pr_md_idle_cpus_lock);\n+#    endif /* _PR_HAVE_ATOMIC_OPS */\n+#  endif\n+    /* If someone on runq; do a nonblocking PAUSECPU */\n+    if (_PR_RUNQREADYMASK(me->cpu) != 0) {\n+      _PR_RUNQ_UNLOCK(cpu);\n+      timeout = PR_INTERVAL_NO_WAIT;\n+    } else {\n+      _PR_RUNQ_UNLOCK(cpu);\n+\n+      _PR_SLEEPQ_LOCK(cpu);\n+      if (PR_CLIST_IS_EMPTY(&_PR_SLEEPQ(me->cpu))) {\n+        timeout = PR_INTERVAL_NO_TIMEOUT;\n+      } else {\n+        PRThread* wakeThread;\n+        wakeThread = _PR_THREAD_PTR(_PR_SLEEPQ(me->cpu).next);\n+        timeout = wakeThread->sleep;\n+      }\n+      _PR_SLEEPQ_UNLOCK(cpu);\n+    }\n \n-        _PR_ClockInterrupt();\n+    /* Wait for an IO to complete */\n+    (void)_PR_MD_PAUSE_CPU(timeout);\n \n-        /* Now schedule any thread that is on the runq\n-         * INTS must be OFF when calling PR_Schedule()\n-         */\n-        me->state = _PR_RUNNABLE;\n-        _PR_MD_SWITCH_CONTEXT(me);\n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_FAST_INTSON(is);\n-        }\n+#  ifdef WINNT\n+    if (_pr_cpus_exit) {\n+      /* _PR_CleanupCPUs tells us to exit */\n+      _PR_MD_END_THREAD();\n     }\n+#  endif\n+\n+#  if !defined(_PR_LOCAL_THREADS_ONLY) && !defined(_PR_GLOBAL_THREADS_ONLY)\n+#    ifdef _PR_HAVE_ATOMIC_OPS\n+    _PR_MD_ATOMIC_DECREMENT(&_pr_md_idle_cpus);\n+#    else\n+    _PR_MD_LOCK(&_pr_md_idle_cpus_lock);\n+    _pr_md_idle_cpus--;\n+    _PR_MD_UNLOCK(&_pr_md_idle_cpus_lock);\n+#    endif /* _PR_HAVE_ATOMIC_OPS */\n+#  endif\n+\n+    _PR_ClockInterrupt();\n+\n+    /* Now schedule any thread that is on the runq\n+     * INTS must be OFF when calling PR_Schedule()\n+     */\n+    me->state = _PR_RUNNABLE;\n+    _PR_MD_SWITCH_CONTEXT(me);\n+    if (!_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_FAST_INTSON(is);\n+    }\n+  }\n }\n #endif /* _PR_GLOBAL_THREADS_ONLY */\n \n-PR_IMPLEMENT(void)\n-PR_SetConcurrency(PRUintn numCPUs)\n-{\n+PR_IMPLEMENT(void) PR_SetConcurrency(PRUintn numCPUs) {\n #if defined(_PR_GLOBAL_THREADS_ONLY) || defined(_PR_LOCAL_THREADS_ONLY)\n \n-    /* do nothing */\n+  /* do nothing */\n \n #else /* combined, MxN thread model */\n \n-    PRUintn newCPU;\n-    _PRCPU* cpu;\n-    PRThread* thr;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    if (_native_threads_only) {\n-        return;\n-    }\n-\n-    _PR_CPU_LIST_LOCK();\n-    if (_pr_numCPU < numCPUs) {\n-        newCPU = numCPUs - _pr_numCPU;\n-        _pr_numCPU = numCPUs;\n-    } else {\n-        newCPU = 0;\n-    }\n-    _PR_CPU_LIST_UNLOCK();\n-\n-    for (; newCPU; newCPU--) {\n-        cpu = _PR_CreateCPU();\n-        thr = _PR_CreateThread(PR_SYSTEM_THREAD, _PR_RunCPU, cpu,\n-                               PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n-                               PR_UNJOINABLE_THREAD, 0, _PR_IDLE_THREAD);\n-    }\n+  PRUintn newCPU;\n+  _PRCPU* cpu;\n+  PRThread* thr;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  if (_native_threads_only) {\n+    return;\n+  }\n+\n+  _PR_CPU_LIST_LOCK();\n+  if (_pr_numCPU < numCPUs) {\n+    newCPU = numCPUs - _pr_numCPU;\n+    _pr_numCPU = numCPUs;\n+  } else {\n+    newCPU = 0;\n+  }\n+  _PR_CPU_LIST_UNLOCK();\n+\n+  for (; newCPU; newCPU--) {\n+    cpu = _PR_CreateCPU();\n+    thr = _PR_CreateThread(PR_SYSTEM_THREAD, _PR_RunCPU, cpu,\n+                           PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n+                           PR_UNJOINABLE_THREAD, 0, _PR_IDLE_THREAD);\n+  }\n #endif\n }\n \n-PR_IMPLEMENT(_PRCPU*)\n-_PR_GetPrimordialCPU(void)\n-{\n-    if (_pr_primordialCPU) {\n-        return _pr_primordialCPU;\n-    } else {\n-        return _PR_MD_CURRENT_CPU();\n-    }\n+PR_IMPLEMENT(_PRCPU*) _PR_GetPrimordialCPU(void) {\n+  if (_pr_primordialCPU) {\n+    return _pr_primordialCPU;\n+  } else {\n+    return _PR_MD_CURRENT_CPU();\n+  }\n }\ndiff --git a/nspr/pr/src/threads/combined/prucv.c b/nspr/pr/src/threads/combined/prucv.c\nindex a343d0b..7a645d7 100644\n--- a/nspr/pr/src/threads/combined/prucv.c\n+++ b/nspr/pr/src/threads/combined/prucv.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -13,282 +14,274 @@\n ** The pragma suppresses the warning.\n **\n */\n-#pragma warning(disable : 4101)\n+#  pragma warning(disable : 4101)\n #endif\n \n /*\n ** Notify one thread that it has finished waiting on a condition variable\n ** Caller must hold the _PR_CVAR_LOCK(cv)\n */\n-PRBool\n-_PR_NotifyThread(PRThread* thread, PRThread* me)\n-{\n-    PRBool rv;\n+PRBool _PR_NotifyThread(PRThread* thread, PRThread* me) {\n+  PRBool rv;\n+\n+  PR_ASSERT(_PR_IS_NATIVE_THREAD(me) || _PR_MD_GET_INTSOFF() != 0);\n+\n+  _PR_THREAD_LOCK(thread);\n+  PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n+  if (!_PR_IS_NATIVE_THREAD(thread)) {\n+    if (thread->wait.cvar != NULL) {\n+      thread->wait.cvar = NULL;\n+\n+      _PR_SLEEPQ_LOCK(thread->cpu);\n+      /* The notify and timeout can collide; in which case both may\n+       * attempt to delete from the sleepQ; only let one do it.\n+       */\n+      if (thread->flags & (_PR_ON_SLEEPQ | _PR_ON_PAUSEQ)) {\n+        _PR_DEL_SLEEPQ(thread, PR_TRUE);\n+      }\n+      _PR_SLEEPQ_UNLOCK(thread->cpu);\n+\n+      if (thread->flags & _PR_SUSPENDING) {\n+        /*\n+         * set thread state to SUSPENDED; a Resume operation\n+         * on the thread will move it to the runQ\n+         */\n+        thread->state = _PR_SUSPENDED;\n+        _PR_MISCQ_LOCK(thread->cpu);\n+        _PR_ADD_SUSPENDQ(thread, thread->cpu);\n+        _PR_MISCQ_UNLOCK(thread->cpu);\n+        _PR_THREAD_UNLOCK(thread);\n+      } else {\n+        /* Make thread runnable */\n+        thread->state = _PR_RUNNABLE;\n+        _PR_THREAD_UNLOCK(thread);\n \n-    PR_ASSERT(_PR_IS_NATIVE_THREAD(me) || _PR_MD_GET_INTSOFF() != 0);\n+        _PR_AddThreadToRunQ(me, thread);\n+        _PR_MD_WAKEUP_WAITER(thread);\n+      }\n \n-    _PR_THREAD_LOCK(thread);\n-    PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n-    if (!_PR_IS_NATIVE_THREAD(thread)) {\n-        if (thread->wait.cvar != NULL) {\n-            thread->wait.cvar = NULL;\n-\n-            _PR_SLEEPQ_LOCK(thread->cpu);\n-            /* The notify and timeout can collide; in which case both may\n-             * attempt to delete from the sleepQ; only let one do it.\n-             */\n-            if (thread->flags & (_PR_ON_SLEEPQ | _PR_ON_PAUSEQ)) {\n-                _PR_DEL_SLEEPQ(thread, PR_TRUE);\n-            }\n-            _PR_SLEEPQ_UNLOCK(thread->cpu);\n-\n-            if (thread->flags & _PR_SUSPENDING) {\n-                /*\n-                 * set thread state to SUSPENDED; a Resume operation\n-                 * on the thread will move it to the runQ\n-                 */\n-                thread->state = _PR_SUSPENDED;\n-                _PR_MISCQ_LOCK(thread->cpu);\n-                _PR_ADD_SUSPENDQ(thread, thread->cpu);\n-                _PR_MISCQ_UNLOCK(thread->cpu);\n-                _PR_THREAD_UNLOCK(thread);\n-            } else {\n-                /* Make thread runnable */\n-                thread->state = _PR_RUNNABLE;\n-                _PR_THREAD_UNLOCK(thread);\n-\n-                _PR_AddThreadToRunQ(me, thread);\n-                _PR_MD_WAKEUP_WAITER(thread);\n-            }\n-\n-            rv = PR_TRUE;\n-        } else {\n-            /* Thread has already been notified */\n-            _PR_THREAD_UNLOCK(thread);\n-            rv = PR_FALSE;\n-        }\n-    } else { /* If the thread is a native thread */\n-        if (thread->wait.cvar) {\n-            thread->wait.cvar = NULL;\n-\n-            if (thread->flags & _PR_SUSPENDING) {\n-                /*\n-                 * set thread state to SUSPENDED; a Resume operation\n-                 * on the thread will enable the thread to run\n-                 */\n-                thread->state = _PR_SUSPENDED;\n-            } else {\n-                thread->state = _PR_RUNNING;\n-            }\n-            _PR_THREAD_UNLOCK(thread);\n-            _PR_MD_WAKEUP_WAITER(thread);\n-            rv = PR_TRUE;\n-        } else {\n-            _PR_THREAD_UNLOCK(thread);\n-            rv = PR_FALSE;\n-        }\n+      rv = PR_TRUE;\n+    } else {\n+      /* Thread has already been notified */\n+      _PR_THREAD_UNLOCK(thread);\n+      rv = PR_FALSE;\n+    }\n+  } else { /* If the thread is a native thread */\n+    if (thread->wait.cvar) {\n+      thread->wait.cvar = NULL;\n+\n+      if (thread->flags & _PR_SUSPENDING) {\n+        /*\n+         * set thread state to SUSPENDED; a Resume operation\n+         * on the thread will enable the thread to run\n+         */\n+        thread->state = _PR_SUSPENDED;\n+      } else {\n+        thread->state = _PR_RUNNING;\n+      }\n+      _PR_THREAD_UNLOCK(thread);\n+      _PR_MD_WAKEUP_WAITER(thread);\n+      rv = PR_TRUE;\n+    } else {\n+      _PR_THREAD_UNLOCK(thread);\n+      rv = PR_FALSE;\n     }\n+  }\n \n-    return rv;\n+  return rv;\n }\n \n /*\n  * Notify thread waiting on cvar; called when thread is interrupted\n  *  The thread lock is held on entry and released before return\n  */\n-void\n-_PR_NotifyLockedThread(PRThread* thread)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRCondVar* cvar;\n-    PRThreadPriority pri;\n-\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        PR_ASSERT(_PR_MD_GET_INTSOFF() != 0);\n-    }\n+void _PR_NotifyLockedThread(PRThread* thread) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRCondVar* cvar;\n+  PRThreadPriority pri;\n \n-    cvar = thread->wait.cvar;\n-    thread->wait.cvar = NULL;\n-    _PR_THREAD_UNLOCK(thread);\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    PR_ASSERT(_PR_MD_GET_INTSOFF() != 0);\n+  }\n \n-    _PR_CVAR_LOCK(cvar);\n-    _PR_THREAD_LOCK(thread);\n+  cvar = thread->wait.cvar;\n+  thread->wait.cvar = NULL;\n+  _PR_THREAD_UNLOCK(thread);\n \n-    if (!_PR_IS_NATIVE_THREAD(thread)) {\n-        _PR_SLEEPQ_LOCK(thread->cpu);\n-        /* The notify and timeout can collide; in which case both may\n-         * attempt to delete from the sleepQ; only let one do it.\n-         */\n-        if (thread->flags & (_PR_ON_SLEEPQ | _PR_ON_PAUSEQ)) {\n-            _PR_DEL_SLEEPQ(thread, PR_TRUE);\n-        }\n-        _PR_SLEEPQ_UNLOCK(thread->cpu);\n+  _PR_CVAR_LOCK(cvar);\n+  _PR_THREAD_LOCK(thread);\n \n-        /* Make thread runnable */\n-        pri = thread->priority;\n-        thread->state = _PR_RUNNABLE;\n+  if (!_PR_IS_NATIVE_THREAD(thread)) {\n+    _PR_SLEEPQ_LOCK(thread->cpu);\n+    /* The notify and timeout can collide; in which case both may\n+     * attempt to delete from the sleepQ; only let one do it.\n+     */\n+    if (thread->flags & (_PR_ON_SLEEPQ | _PR_ON_PAUSEQ)) {\n+      _PR_DEL_SLEEPQ(thread, PR_TRUE);\n+    }\n+    _PR_SLEEPQ_UNLOCK(thread->cpu);\n \n-        PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n+    /* Make thread runnable */\n+    pri = thread->priority;\n+    thread->state = _PR_RUNNABLE;\n \n-        _PR_AddThreadToRunQ(me, thread);\n-        _PR_THREAD_UNLOCK(thread);\n+    PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n \n-        _PR_MD_WAKEUP_WAITER(thread);\n+    _PR_AddThreadToRunQ(me, thread);\n+    _PR_THREAD_UNLOCK(thread);\n+\n+    _PR_MD_WAKEUP_WAITER(thread);\n+  } else {\n+    if (thread->flags & _PR_SUSPENDING) {\n+      /*\n+       * set thread state to SUSPENDED; a Resume operation\n+       * on the thread will enable the thread to run\n+       */\n+      thread->state = _PR_SUSPENDED;\n     } else {\n-        if (thread->flags & _PR_SUSPENDING) {\n-            /*\n-             * set thread state to SUSPENDED; a Resume operation\n-             * on the thread will enable the thread to run\n-             */\n-            thread->state = _PR_SUSPENDED;\n-        } else {\n-            thread->state = _PR_RUNNING;\n-        }\n-        _PR_THREAD_UNLOCK(thread);\n-        _PR_MD_WAKEUP_WAITER(thread);\n+      thread->state = _PR_RUNNING;\n     }\n+    _PR_THREAD_UNLOCK(thread);\n+    _PR_MD_WAKEUP_WAITER(thread);\n+  }\n \n-    _PR_CVAR_UNLOCK(cvar);\n-    return;\n+  _PR_CVAR_UNLOCK(cvar);\n+  return;\n }\n \n /*\n ** Make the given thread wait for the given condition variable\n */\n-PRStatus\n-_PR_WaitCondVar(PRThread* thread, PRCondVar* cvar, PRLock* lock,\n-                PRIntervalTime timeout)\n-{\n-    PRIntn is;\n-    PRStatus rv = PR_SUCCESS;\n-\n-    PR_ASSERT(thread == _PR_MD_CURRENT_THREAD());\n-    PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n-\n-#ifdef _PR_GLOBAL_THREADS_ONLY\n-    if (_PR_PENDING_INTERRUPT(thread)) {\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        thread->flags &= ~_PR_INTERRUPT;\n-        return PR_FAILURE;\n-    }\n+PRStatus _PR_WaitCondVar(PRThread* thread, PRCondVar* cvar, PRLock* lock,\n+                         PRIntervalTime timeout) {\n+  PRIntn is;\n+  PRStatus rv = PR_SUCCESS;\n \n-    thread->wait.cvar = cvar;\n-    lock->owner = NULL;\n-    _PR_MD_WAIT_CV(&cvar->md, &lock->ilock, timeout);\n-    thread->wait.cvar = NULL;\n-    lock->owner = thread;\n-    if (_PR_PENDING_INTERRUPT(thread)) {\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        thread->flags &= ~_PR_INTERRUPT;\n-        return PR_FAILURE;\n-    }\n+  PR_ASSERT(thread == _PR_MD_CURRENT_THREAD());\n+  PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n \n-    return PR_SUCCESS;\n+#ifdef _PR_GLOBAL_THREADS_ONLY\n+  if (_PR_PENDING_INTERRUPT(thread)) {\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    thread->flags &= ~_PR_INTERRUPT;\n+    return PR_FAILURE;\n+  }\n+\n+  thread->wait.cvar = cvar;\n+  lock->owner = NULL;\n+  _PR_MD_WAIT_CV(&cvar->md, &lock->ilock, timeout);\n+  thread->wait.cvar = NULL;\n+  lock->owner = thread;\n+  if (_PR_PENDING_INTERRUPT(thread)) {\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    thread->flags &= ~_PR_INTERRUPT;\n+    return PR_FAILURE;\n+  }\n+\n+  return PR_SUCCESS;\n #else  /* _PR_GLOBAL_THREADS_ONLY */\n \n-    if (!_PR_IS_NATIVE_THREAD(thread)) {\n-        _PR_INTSOFF(is);\n-    }\n-\n-    _PR_CVAR_LOCK(cvar);\n-    _PR_THREAD_LOCK(thread);\n-\n-    if (_PR_PENDING_INTERRUPT(thread)) {\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        thread->flags &= ~_PR_INTERRUPT;\n-        _PR_CVAR_UNLOCK(cvar);\n-        _PR_THREAD_UNLOCK(thread);\n-        if (!_PR_IS_NATIVE_THREAD(thread)) {\n-            _PR_INTSON(is);\n-        }\n-        return PR_FAILURE;\n-    }\n-\n-    thread->state = _PR_COND_WAIT;\n-    thread->wait.cvar = cvar;\n+  if (!_PR_IS_NATIVE_THREAD(thread)) {\n+    _PR_INTSOFF(is);\n+  }\n \n-    /*\n-    ** Put the caller thread on the condition variable's wait Q\n-    */\n-    PR_APPEND_LINK(&thread->waitQLinks, &cvar->condQ);\n+  _PR_CVAR_LOCK(cvar);\n+  _PR_THREAD_LOCK(thread);\n \n-    /* Note- for global scope threads, we don't put them on the\n-     *       global sleepQ, so each global thread must put itself\n-     *       to sleep only for the time it wants to.\n-     */\n-    if (!_PR_IS_NATIVE_THREAD(thread)) {\n-        _PR_SLEEPQ_LOCK(thread->cpu);\n-        _PR_ADD_SLEEPQ(thread, timeout);\n-        _PR_SLEEPQ_UNLOCK(thread->cpu);\n-    }\n+  if (_PR_PENDING_INTERRUPT(thread)) {\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    thread->flags &= ~_PR_INTERRUPT;\n     _PR_CVAR_UNLOCK(cvar);\n     _PR_THREAD_UNLOCK(thread);\n-\n-    /*\n-    ** Release lock protecting the condition variable and thereby giving time\n-    ** to the next thread which can potentially notify on the condition variable\n-    */\n-    PR_Unlock(lock);\n-\n-    PR_LOG(_pr_cvar_lm, PR_LOG_MIN,\n-           (\"PR_Wait: cvar=%p waiting for %d\", cvar, timeout));\n-\n-    rv = _PR_MD_WAIT(thread, timeout);\n-\n-    _PR_CVAR_LOCK(cvar);\n-    PR_REMOVE_LINK(&thread->waitQLinks);\n-    _PR_CVAR_UNLOCK(cvar);\n-\n-    PR_LOG(_pr_cvar_lm, PR_LOG_MIN, (\"PR_Wait: cvar=%p done waiting\", cvar));\n-\n     if (!_PR_IS_NATIVE_THREAD(thread)) {\n-        _PR_INTSON(is);\n-    }\n-\n-    /* Acquire lock again that we had just relinquished */\n-    PR_Lock(lock);\n-\n-    if (_PR_PENDING_INTERRUPT(thread)) {\n-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n-        thread->flags &= ~_PR_INTERRUPT;\n-        return PR_FAILURE;\n+      _PR_INTSON(is);\n     }\n-\n-    return rv;\n+    return PR_FAILURE;\n+  }\n+\n+  thread->state = _PR_COND_WAIT;\n+  thread->wait.cvar = cvar;\n+\n+  /*\n+  ** Put the caller thread on the condition variable's wait Q\n+  */\n+  PR_APPEND_LINK(&thread->waitQLinks, &cvar->condQ);\n+\n+  /* Note- for global scope threads, we don't put them on the\n+   *       global sleepQ, so each global thread must put itself\n+   *       to sleep only for the time it wants to.\n+   */\n+  if (!_PR_IS_NATIVE_THREAD(thread)) {\n+    _PR_SLEEPQ_LOCK(thread->cpu);\n+    _PR_ADD_SLEEPQ(thread, timeout);\n+    _PR_SLEEPQ_UNLOCK(thread->cpu);\n+  }\n+  _PR_CVAR_UNLOCK(cvar);\n+  _PR_THREAD_UNLOCK(thread);\n+\n+  /*\n+  ** Release lock protecting the condition variable and thereby giving time\n+  ** to the next thread which can potentially notify on the condition variable\n+  */\n+  PR_Unlock(lock);\n+\n+  PR_LOG(_pr_cvar_lm, PR_LOG_MIN,\n+         (\"PR_Wait: cvar=%p waiting for %d\", cvar, timeout));\n+\n+  rv = _PR_MD_WAIT(thread, timeout);\n+\n+  _PR_CVAR_LOCK(cvar);\n+  PR_REMOVE_LINK(&thread->waitQLinks);\n+  _PR_CVAR_UNLOCK(cvar);\n+\n+  PR_LOG(_pr_cvar_lm, PR_LOG_MIN, (\"PR_Wait: cvar=%p done waiting\", cvar));\n+\n+  if (!_PR_IS_NATIVE_THREAD(thread)) {\n+    _PR_INTSON(is);\n+  }\n+\n+  /* Acquire lock again that we had just relinquished */\n+  PR_Lock(lock);\n+\n+  if (_PR_PENDING_INTERRUPT(thread)) {\n+    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);\n+    thread->flags &= ~_PR_INTERRUPT;\n+    return PR_FAILURE;\n+  }\n+\n+  return rv;\n #endif /* _PR_GLOBAL_THREADS_ONLY */\n }\n \n-void\n-_PR_NotifyCondVar(PRCondVar* cvar, PRThread* me)\n-{\n+void _PR_NotifyCondVar(PRCondVar* cvar, PRThread* me) {\n #ifdef _PR_GLOBAL_THREADS_ONLY\n-    _PR_MD_NOTIFY_CV(&cvar->md, &cvar->lock->ilock);\n+  _PR_MD_NOTIFY_CV(&cvar->md, &cvar->lock->ilock);\n #else /* _PR_GLOBAL_THREADS_ONLY */\n \n-    PRCList* q;\n-    PRIntn is;\n-\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-    PR_ASSERT(_PR_IS_NATIVE_THREAD(me) || _PR_MD_GET_INTSOFF() != 0);\n-\n-    _PR_CVAR_LOCK(cvar);\n-    q = cvar->condQ.next;\n-    while (q != &cvar->condQ) {\n-        PR_LOG(_pr_cvar_lm, PR_LOG_MIN, (\"_PR_NotifyCondVar: cvar=%p\", cvar));\n-        if (_PR_THREAD_CONDQ_PTR(q)->wait.cvar) {\n-            if (_PR_NotifyThread(_PR_THREAD_CONDQ_PTR(q), me) == PR_TRUE) {\n-                break;\n-            }\n-        }\n-        q = q->next;\n+  PRCList* q;\n+  PRIntn is;\n+\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+  PR_ASSERT(_PR_IS_NATIVE_THREAD(me) || _PR_MD_GET_INTSOFF() != 0);\n+\n+  _PR_CVAR_LOCK(cvar);\n+  q = cvar->condQ.next;\n+  while (q != &cvar->condQ) {\n+    PR_LOG(_pr_cvar_lm, PR_LOG_MIN, (\"_PR_NotifyCondVar: cvar=%p\", cvar));\n+    if (_PR_THREAD_CONDQ_PTR(q)->wait.cvar) {\n+      if (_PR_NotifyThread(_PR_THREAD_CONDQ_PTR(q), me) == PR_TRUE) {\n+        break;\n+      }\n     }\n-    _PR_CVAR_UNLOCK(cvar);\n+    q = q->next;\n+  }\n+  _PR_CVAR_UNLOCK(cvar);\n \n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n-    }\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n \n #endif /* _PR_GLOBAL_THREADS_ONLY */\n }\n@@ -296,18 +289,16 @@ _PR_NotifyCondVar(PRCondVar* cvar, PRThread* me)\n /*\n ** Cndition variable debugging log info.\n */\n-PRUint32\n-_PR_CondVarToString(PRCondVar* cvar, char* buf, PRUint32 buflen)\n-{\n-    PRUint32 nb;\n-\n-    if (cvar->lock->owner) {\n-        nb = PR_snprintf(buf, buflen, \"[%p] owner=%ld[%p]\", cvar,\n-                         cvar->lock->owner->id, cvar->lock->owner);\n-    } else {\n-        nb = PR_snprintf(buf, buflen, \"[%p]\", cvar);\n-    }\n-    return nb;\n+PRUint32 _PR_CondVarToString(PRCondVar* cvar, char* buf, PRUint32 buflen) {\n+  PRUint32 nb;\n+\n+  if (cvar->lock->owner) {\n+    nb = PR_snprintf(buf, buflen, \"[%p] owner=%ld[%p]\", cvar,\n+                     cvar->lock->owner->id, cvar->lock->owner);\n+  } else {\n+    nb = PR_snprintf(buf, buflen, \"[%p]\", cvar);\n+  }\n+  return nb;\n }\n \n /*\n@@ -315,133 +306,131 @@ _PR_CondVarToString(PRCondVar* cvar, char* buf, PRUint32 buflen)\n *current\n ** time.\n */\n-void\n-_PR_ClockInterrupt(void)\n-{\n-    PRThread *thread, *me = _PR_MD_CURRENT_THREAD();\n-    _PRCPU* cpu = me->cpu;\n-    PRIntervalTime elapsed, now;\n+void _PR_ClockInterrupt(void) {\n+  PRThread *thread, *me = _PR_MD_CURRENT_THREAD();\n+  _PRCPU* cpu = me->cpu;\n+  PRIntervalTime elapsed, now;\n+\n+  PR_ASSERT(_PR_MD_GET_INTSOFF() != 0);\n+  /* Figure out how much time elapsed since the last clock tick */\n+  now = PR_IntervalNow();\n+  elapsed = now - cpu->last_clock;\n+  cpu->last_clock = now;\n+\n+  PR_LOG(_pr_clock_lm, PR_LOG_MAX, (\"ExpireWaits: elapsed=%lld usec\", elapsed));\n+\n+  while (1) {\n+    _PR_SLEEPQ_LOCK(cpu);\n+    if (_PR_SLEEPQ(cpu).next == &_PR_SLEEPQ(cpu)) {\n+      _PR_SLEEPQ_UNLOCK(cpu);\n+      break;\n+    }\n \n-    PR_ASSERT(_PR_MD_GET_INTSOFF() != 0);\n-    /* Figure out how much time elapsed since the last clock tick */\n-    now = PR_IntervalNow();\n-    elapsed = now - cpu->last_clock;\n-    cpu->last_clock = now;\n-\n-    PR_LOG(_pr_clock_lm, PR_LOG_MAX, (\"ExpireWaits: elapsed=%lld usec\", elapsed));\n-\n-    while (1) {\n-        _PR_SLEEPQ_LOCK(cpu);\n-        if (_PR_SLEEPQ(cpu).next == &_PR_SLEEPQ(cpu)) {\n-            _PR_SLEEPQ_UNLOCK(cpu);\n-            break;\n-        }\n+    thread = _PR_THREAD_PTR(_PR_SLEEPQ(cpu).next);\n+    PR_ASSERT(thread->cpu == cpu);\n \n-        thread = _PR_THREAD_PTR(_PR_SLEEPQ(cpu).next);\n-        PR_ASSERT(thread->cpu == cpu);\n+    if (elapsed < thread->sleep) {\n+      thread->sleep -= elapsed;\n+      _PR_SLEEPQMAX(thread->cpu) -= elapsed;\n+      _PR_SLEEPQ_UNLOCK(cpu);\n+      break;\n+    }\n+    _PR_SLEEPQ_UNLOCK(cpu);\n \n-        if (elapsed < thread->sleep) {\n-            thread->sleep -= elapsed;\n-            _PR_SLEEPQMAX(thread->cpu) -= elapsed;\n-            _PR_SLEEPQ_UNLOCK(cpu);\n-            break;\n-        }\n-        _PR_SLEEPQ_UNLOCK(cpu);\n+    PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread));\n+\n+    _PR_THREAD_LOCK(thread);\n \n+    if (thread->cpu != cpu) {\n+      /*\n+      ** The thread was switched to another CPU\n+      ** between the time we unlocked the sleep\n+      ** queue and the time we acquired the thread\n+      ** lock, so it is none of our business now.\n+      */\n+      _PR_THREAD_UNLOCK(thread);\n+      continue;\n+    }\n+\n+    /*\n+    ** Consume this sleeper's amount of elapsed time from the elapsed\n+    ** time value. The next remaining piece of elapsed time will be\n+    ** available for the next sleeping thread's timer.\n+    */\n+    _PR_SLEEPQ_LOCK(cpu);\n+    PR_ASSERT(!(thread->flags & _PR_ON_PAUSEQ));\n+    if (thread->flags & _PR_ON_SLEEPQ) {\n+      _PR_DEL_SLEEPQ(thread, PR_FALSE);\n+      elapsed -= thread->sleep;\n+      _PR_SLEEPQ_UNLOCK(cpu);\n+    } else {\n+      /* Thread was already handled; Go get another one */\n+      _PR_SLEEPQ_UNLOCK(cpu);\n+      _PR_THREAD_UNLOCK(thread);\n+      continue;\n+    }\n+\n+    /* Notify the thread waiting on the condition variable */\n+    if (thread->flags & _PR_SUSPENDING) {\n+      PR_ASSERT((thread->state == _PR_IO_WAIT) ||\n+                (thread->state == _PR_COND_WAIT));\n+      /*\n+      ** Thread is suspended and its condition timeout\n+      ** expired. Transfer thread from sleepQ to suspendQ.\n+      */\n+      thread->wait.cvar = NULL;\n+      _PR_MISCQ_LOCK(cpu);\n+      thread->state = _PR_SUSPENDED;\n+      _PR_ADD_SUSPENDQ(thread, cpu);\n+      _PR_MISCQ_UNLOCK(cpu);\n+    } else {\n+      if (thread->wait.cvar) {\n+        PRThreadPriority pri;\n+\n+        /* Do work very similar to what _PR_NotifyThread does */\n         PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread));\n \n-        _PR_THREAD_LOCK(thread);\n-\n-        if (thread->cpu != cpu) {\n-            /*\n-            ** The thread was switched to another CPU\n-            ** between the time we unlocked the sleep\n-            ** queue and the time we acquired the thread\n-            ** lock, so it is none of our business now.\n-            */\n-            _PR_THREAD_UNLOCK(thread);\n-            continue;\n-        }\n+        /* Make thread runnable */\n+        pri = thread->priority;\n+        thread->state = _PR_RUNNABLE;\n+        PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n \n-        /*\n-        ** Consume this sleeper's amount of elapsed time from the elapsed\n-        ** time value. The next remaining piece of elapsed time will be\n-        ** available for the next sleeping thread's timer.\n-        */\n-        _PR_SLEEPQ_LOCK(cpu);\n-        PR_ASSERT(!(thread->flags & _PR_ON_PAUSEQ));\n-        if (thread->flags & _PR_ON_SLEEPQ) {\n-            _PR_DEL_SLEEPQ(thread, PR_FALSE);\n-            elapsed -= thread->sleep;\n-            _PR_SLEEPQ_UNLOCK(cpu);\n-        } else {\n-            /* Thread was already handled; Go get another one */\n-            _PR_SLEEPQ_UNLOCK(cpu);\n-            _PR_THREAD_UNLOCK(thread);\n-            continue;\n+        PR_ASSERT(thread->cpu == cpu);\n+        _PR_RUNQ_LOCK(cpu);\n+        _PR_ADD_RUNQ(thread, cpu, pri);\n+        _PR_RUNQ_UNLOCK(cpu);\n+\n+        if (pri > me->priority) {\n+          _PR_SET_RESCHED_FLAG();\n         }\n \n-        /* Notify the thread waiting on the condition variable */\n-        if (thread->flags & _PR_SUSPENDING) {\n-            PR_ASSERT((thread->state == _PR_IO_WAIT) ||\n-                      (thread->state == _PR_COND_WAIT));\n-            /*\n-            ** Thread is suspended and its condition timeout\n-            ** expired. Transfer thread from sleepQ to suspendQ.\n-            */\n-            thread->wait.cvar = NULL;\n-            _PR_MISCQ_LOCK(cpu);\n-            thread->state = _PR_SUSPENDED;\n-            _PR_ADD_SUSPENDQ(thread, cpu);\n-            _PR_MISCQ_UNLOCK(cpu);\n-        } else {\n-            if (thread->wait.cvar) {\n-                PRThreadPriority pri;\n-\n-                /* Do work very similar to what _PR_NotifyThread does */\n-                PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread));\n-\n-                /* Make thread runnable */\n-                pri = thread->priority;\n-                thread->state = _PR_RUNNABLE;\n-                PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n-\n-                PR_ASSERT(thread->cpu == cpu);\n-                _PR_RUNQ_LOCK(cpu);\n-                _PR_ADD_RUNQ(thread, cpu, pri);\n-                _PR_RUNQ_UNLOCK(cpu);\n-\n-                if (pri > me->priority) {\n-                    _PR_SET_RESCHED_FLAG();\n-                }\n-\n-                thread->wait.cvar = NULL;\n-\n-                _PR_MD_WAKEUP_WAITER(thread);\n-\n-            } else if (thread->io_pending == PR_TRUE) {\n-                /* Need to put IO sleeper back on runq */\n-                int pri = thread->priority;\n-\n-                thread->io_suspended = PR_TRUE;\n+        thread->wait.cvar = NULL;\n+\n+        _PR_MD_WAKEUP_WAITER(thread);\n+\n+      } else if (thread->io_pending == PR_TRUE) {\n+        /* Need to put IO sleeper back on runq */\n+        int pri = thread->priority;\n+\n+        thread->io_suspended = PR_TRUE;\n #ifdef WINNT\n-                /*\n-                 * For NT, record the cpu on which I/O was issued\n-                 * I/O cancellation is done on the same cpu\n-                 */\n-                thread->md.thr_bound_cpu = cpu;\n+        /*\n+         * For NT, record the cpu on which I/O was issued\n+         * I/O cancellation is done on the same cpu\n+         */\n+        thread->md.thr_bound_cpu = cpu;\n #endif\n \n-                PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n-                PR_ASSERT(thread->cpu == cpu);\n-                thread->state = _PR_RUNNABLE;\n-                _PR_RUNQ_LOCK(cpu);\n-                _PR_ADD_RUNQ(thread, cpu, pri);\n-                _PR_RUNQ_UNLOCK(cpu);\n-            }\n-        }\n-        _PR_THREAD_UNLOCK(thread);\n+        PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n+        PR_ASSERT(thread->cpu == cpu);\n+        thread->state = _PR_RUNNABLE;\n+        _PR_RUNQ_LOCK(cpu);\n+        _PR_ADD_RUNQ(thread, cpu, pri);\n+        _PR_RUNQ_UNLOCK(cpu);\n+      }\n     }\n+    _PR_THREAD_UNLOCK(thread);\n+  }\n }\n \n /************************************************************************/\n@@ -456,41 +445,37 @@ _PR_ClockInterrupt(void)\n ** This may fail if memory is tight or if some operating system resource\n ** is low.\n */\n-PR_IMPLEMENT(PRCondVar*)\n-PR_NewCondVar(PRLock* lock)\n-{\n-    PRCondVar* cvar;\n-\n-    cvar = PR_NEWZAP(PRCondVar);\n-    if (cvar) {\n-        if (_PR_InitCondVar(cvar, lock) != PR_SUCCESS) {\n-            PR_DELETE(cvar);\n-            return NULL;\n-        }\n-    } else {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+PR_IMPLEMENT(PRCondVar*) PR_NewCondVar(PRLock* lock) {\n+  PRCondVar* cvar;\n+\n+  cvar = PR_NEWZAP(PRCondVar);\n+  if (cvar) {\n+    if (_PR_InitCondVar(cvar, lock) != PR_SUCCESS) {\n+      PR_DELETE(cvar);\n+      return NULL;\n     }\n-    return cvar;\n+  } else {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+  }\n+  return cvar;\n }\n \n-PRStatus\n-_PR_InitCondVar(PRCondVar* cvar, PRLock* lock)\n-{\n-    PR_ASSERT(lock != NULL);\n+PRStatus _PR_InitCondVar(PRCondVar* cvar, PRLock* lock) {\n+  PR_ASSERT(lock != NULL);\n \n #ifdef _PR_GLOBAL_THREADS_ONLY\n-    if (_PR_MD_NEW_CV(&cvar->md)) {\n-        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (_PR_MD_NEW_CV(&cvar->md)) {\n+    PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n #endif\n-    if (_PR_MD_NEW_LOCK(&(cvar->ilock)) != PR_SUCCESS) {\n-        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-    cvar->lock = lock;\n-    PR_INIT_CLIST(&cvar->condQ);\n-    return PR_SUCCESS;\n+  if (_PR_MD_NEW_LOCK(&(cvar->ilock)) != PR_SUCCESS) {\n+    PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+  cvar->lock = lock;\n+  PR_INIT_CLIST(&cvar->condQ);\n+  return PR_SUCCESS;\n }\n \n /*\n@@ -499,22 +484,18 @@ _PR_InitCondVar(PRCondVar* cvar, PRLock* lock)\n ** that the condvar is no longer in use.\n **\n */\n-PR_IMPLEMENT(void)\n-PR_DestroyCondVar(PRCondVar* cvar)\n-{\n-    _PR_FreeCondVar(cvar);\n-    PR_DELETE(cvar);\n+PR_IMPLEMENT(void) PR_DestroyCondVar(PRCondVar* cvar) {\n+  _PR_FreeCondVar(cvar);\n+  PR_DELETE(cvar);\n }\n \n-void\n-_PR_FreeCondVar(PRCondVar* cvar)\n-{\n-    PR_ASSERT(cvar->condQ.next == &cvar->condQ);\n+void _PR_FreeCondVar(PRCondVar* cvar) {\n+  PR_ASSERT(cvar->condQ.next == &cvar->condQ);\n \n #ifdef _PR_GLOBAL_THREADS_ONLY\n-    _PR_MD_FREE_CV(&cvar->md);\n+  _PR_MD_FREE_CV(&cvar->md);\n #endif\n-    _PR_MD_FREE_LOCK(&(cvar->ilock));\n+  _PR_MD_FREE_LOCK(&(cvar->ilock));\n }\n \n /*\n@@ -532,18 +513,16 @@ _PR_FreeCondVar(PRCondVar* cvar)\n ** with the condition variable or the thread has been interrupted.\n */\n extern PRThread* suspendAllThread;\n-PR_IMPLEMENT(PRStatus)\n-PR_WaitCondVar(PRCondVar* cvar, PRIntervalTime timeout)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    PR_ASSERT(cvar->lock->owner == me);\n-    PR_ASSERT(me != suspendAllThread);\n-    if (cvar->lock->owner != me) {\n-        return PR_FAILURE;\n-    }\n+PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PRCondVar* cvar, PRIntervalTime timeout) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    return _PR_WaitCondVar(me, cvar, cvar->lock, timeout);\n+  PR_ASSERT(cvar->lock->owner == me);\n+  PR_ASSERT(me != suspendAllThread);\n+  if (cvar->lock->owner != me) {\n+    return PR_FAILURE;\n+  }\n+\n+  return _PR_WaitCondVar(me, cvar, cvar->lock, timeout);\n }\n \n /*\n@@ -551,19 +530,17 @@ PR_WaitCondVar(PRCondVar* cvar, PRIntervalTime timeout)\n ** variable. If a thread is waiting on the condition variable (using\n ** PR_Wait) then it is awakened and begins waiting on the lock.\n */\n-PR_IMPLEMENT(PRStatus)\n-PR_NotifyCondVar(PRCondVar* cvar)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    PR_ASSERT(cvar->lock->owner == me);\n-    PR_ASSERT(me != suspendAllThread);\n-    if (cvar->lock->owner != me) {\n-        return PR_FAILURE;\n-    }\n+PR_IMPLEMENT(PRStatus) PR_NotifyCondVar(PRCondVar* cvar) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  PR_ASSERT(cvar->lock->owner == me);\n+  PR_ASSERT(me != suspendAllThread);\n+  if (cvar->lock->owner != me) {\n+    return PR_FAILURE;\n+  }\n \n-    _PR_NotifyCondVar(cvar, me);\n-    return PR_SUCCESS;\n+  _PR_NotifyCondVar(cvar, me);\n+  return PR_SUCCESS;\n }\n \n /*\n@@ -571,38 +548,36 @@ PR_NotifyCondVar(PRCondVar* cvar)\n ** threads are notified in turn. The highest priority thread will\n ** probably acquire the lock.\n */\n-PR_IMPLEMENT(PRStatus)\n-PR_NotifyAllCondVar(PRCondVar* cvar)\n-{\n-    PRCList* q;\n-    PRIntn is;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    PR_ASSERT(cvar->lock->owner == me);\n-    if (cvar->lock->owner != me) {\n-        return PR_FAILURE;\n-    }\n+PR_IMPLEMENT(PRStatus) PR_NotifyAllCondVar(PRCondVar* cvar) {\n+  PRCList* q;\n+  PRIntn is;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  PR_ASSERT(cvar->lock->owner == me);\n+  if (cvar->lock->owner != me) {\n+    return PR_FAILURE;\n+  }\n \n #ifdef _PR_GLOBAL_THREADS_ONLY\n-    _PR_MD_NOTIFYALL_CV(&cvar->md, &cvar->lock->ilock);\n-    return PR_SUCCESS;\n+  _PR_MD_NOTIFYALL_CV(&cvar->md, &cvar->lock->ilock);\n+  return PR_SUCCESS;\n #else  /* _PR_GLOBAL_THREADS_ONLY */\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-    _PR_CVAR_LOCK(cvar);\n-    q = cvar->condQ.next;\n-    while (q != &cvar->condQ) {\n-        PR_LOG(_pr_cvar_lm, PR_LOG_MIN, (\"PR_NotifyAll: cvar=%p\", cvar));\n-        _PR_NotifyThread(_PR_THREAD_CONDQ_PTR(q), me);\n-        q = q->next;\n-    }\n-    _PR_CVAR_UNLOCK(cvar);\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n-    }\n-\n-    return PR_SUCCESS;\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+  _PR_CVAR_LOCK(cvar);\n+  q = cvar->condQ.next;\n+  while (q != &cvar->condQ) {\n+    PR_LOG(_pr_cvar_lm, PR_LOG_MIN, (\"PR_NotifyAll: cvar=%p\", cvar));\n+    _PR_NotifyThread(_PR_THREAD_CONDQ_PTR(q), me);\n+    q = q->next;\n+  }\n+  _PR_CVAR_UNLOCK(cvar);\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n+\n+  return PR_SUCCESS;\n #endif /* _PR_GLOBAL_THREADS_ONLY */\n }\n \n@@ -613,74 +588,65 @@ PR_NotifyAllCondVar(PRCondVar* cvar)\n /*********************************************************************/\n #include \"prpdce.h\"\n \n-PR_IMPLEMENT(PRCondVar*)\n-PRP_NewNakedCondVar(void)\n-{\n-    PRCondVar* cvar = PR_NEWZAP(PRCondVar);\n-    if (NULL != cvar) {\n-        if (_PR_MD_NEW_LOCK(&(cvar->ilock)) == PR_FAILURE) {\n-            PR_DELETE(cvar);\n-            cvar = NULL;\n-        } else {\n-            PR_INIT_CLIST(&cvar->condQ);\n-            cvar->lock = _PR_NAKED_CV_LOCK;\n-        }\n+PR_IMPLEMENT(PRCondVar*) PRP_NewNakedCondVar(void) {\n+  PRCondVar* cvar = PR_NEWZAP(PRCondVar);\n+  if (NULL != cvar) {\n+    if (_PR_MD_NEW_LOCK(&(cvar->ilock)) == PR_FAILURE) {\n+      PR_DELETE(cvar);\n+      cvar = NULL;\n+    } else {\n+      PR_INIT_CLIST(&cvar->condQ);\n+      cvar->lock = _PR_NAKED_CV_LOCK;\n     }\n-    return cvar;\n+  }\n+  return cvar;\n }\n \n-PR_IMPLEMENT(void)\n-PRP_DestroyNakedCondVar(PRCondVar* cvar)\n-{\n-    PR_ASSERT(cvar->condQ.next == &cvar->condQ);\n-    PR_ASSERT(_PR_NAKED_CV_LOCK == cvar->lock);\n+PR_IMPLEMENT(void) PRP_DestroyNakedCondVar(PRCondVar* cvar) {\n+  PR_ASSERT(cvar->condQ.next == &cvar->condQ);\n+  PR_ASSERT(_PR_NAKED_CV_LOCK == cvar->lock);\n \n-    _PR_MD_FREE_LOCK(&(cvar->ilock));\n+  _PR_MD_FREE_LOCK(&(cvar->ilock));\n \n-    PR_DELETE(cvar);\n+  PR_DELETE(cvar);\n }\n \n PR_IMPLEMENT(PRStatus)\n-PRP_NakedWait(PRCondVar* cvar, PRLock* lock, PRIntervalTime timeout)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PR_ASSERT(_PR_NAKED_CV_LOCK == cvar->lock);\n-    return _PR_WaitCondVar(me, cvar, lock, timeout);\n+PRP_NakedWait(PRCondVar* cvar, PRLock* lock, PRIntervalTime timeout) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PR_ASSERT(_PR_NAKED_CV_LOCK == cvar->lock);\n+  return _PR_WaitCondVar(me, cvar, lock, timeout);\n } /* PRP_NakedWait */\n \n-PR_IMPLEMENT(PRStatus)\n-PRP_NakedNotify(PRCondVar* cvar)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PR_ASSERT(_PR_NAKED_CV_LOCK == cvar->lock);\n+PR_IMPLEMENT(PRStatus) PRP_NakedNotify(PRCondVar* cvar) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PR_ASSERT(_PR_NAKED_CV_LOCK == cvar->lock);\n \n-    _PR_NotifyCondVar(cvar, me);\n+  _PR_NotifyCondVar(cvar, me);\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n } /* PRP_NakedNotify */\n \n-PR_IMPLEMENT(PRStatus)\n-PRP_NakedBroadcast(PRCondVar* cvar)\n-{\n-    PRCList* q;\n-    PRIntn is;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PR_ASSERT(_PR_NAKED_CV_LOCK == cvar->lock);\n-\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-    _PR_MD_LOCK(&(cvar->ilock));\n-    q = cvar->condQ.next;\n-    while (q != &cvar->condQ) {\n-        PR_LOG(_pr_cvar_lm, PR_LOG_MIN, (\"PR_NotifyAll: cvar=%p\", cvar));\n-        _PR_NotifyThread(_PR_THREAD_CONDQ_PTR(q), me);\n-        q = q->next;\n-    }\n-    _PR_MD_UNLOCK(&(cvar->ilock));\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n-    }\n-\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PRP_NakedBroadcast(PRCondVar* cvar) {\n+  PRCList* q;\n+  PRIntn is;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PR_ASSERT(_PR_NAKED_CV_LOCK == cvar->lock);\n+\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+  _PR_MD_LOCK(&(cvar->ilock));\n+  q = cvar->condQ.next;\n+  while (q != &cvar->condQ) {\n+    PR_LOG(_pr_cvar_lm, PR_LOG_MIN, (\"PR_NotifyAll: cvar=%p\", cvar));\n+    _PR_NotifyThread(_PR_THREAD_CONDQ_PTR(q), me);\n+    q = q->next;\n+  }\n+  _PR_MD_UNLOCK(&(cvar->ilock));\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n+\n+  return PR_SUCCESS;\n } /* PRP_NakedBroadcast */\ndiff --git a/nspr/pr/src/threads/combined/prulock.c b/nspr/pr/src/threads/combined/prulock.c\nindex b2f6d09..3fab957 100644\n--- a/nspr/pr/src/threads/combined/prulock.c\n+++ b/nspr/pr/src/threads/combined/prulock.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,74 +12,68 @@\n ** The pragma suppresses the warning.\n **\n */\n-#pragma warning(disable : 4101)\n+#  pragma warning(disable : 4101)\n #endif\n \n-void\n-_PR_InitLocks(void)\n-{\n-    _PR_MD_INIT_LOCKS();\n-}\n+void _PR_InitLocks(void) { _PR_MD_INIT_LOCKS(); }\n \n /*\n ** Deal with delayed interrupts/requested reschedule during interrupt\n ** re-enables.\n */\n-void\n-_PR_IntsOn(_PRCPU* cpu)\n-{\n-    PRUintn missed, pri, i;\n-    _PRInterruptTable* it;\n-    PRThread* me;\n-\n-    PR_ASSERT(cpu); /* Global threads don't have CPUs */\n-    PR_ASSERT(_PR_MD_GET_INTSOFF() > 0);\n-    me = _PR_MD_CURRENT_THREAD();\n-    PR_ASSERT(!(me->flags & _PR_IDLE_THREAD));\n-\n-    /*\n-    ** Process delayed interrupts. This logic is kinda scary because we\n-    ** need to avoid losing an interrupt (it's ok to delay an interrupt\n-    ** until later).\n-    **\n-    ** There are two missed state words. _pr_ints.where indicates to the\n-    ** interrupt handler which state word is currently safe for\n-    ** modification.\n-    **\n-    ** This code scans both interrupt state words, using the where flag\n-    ** to indicate to the interrupt which state word is safe for writing.\n-    ** If an interrupt comes in during a scan the other word will be\n-    ** modified. This modification will be noticed during the next\n-    ** iteration of the loop or during the next call to this routine.\n-    */\n-    for (i = 0; i < 2; i++) {\n-        cpu->where = (1 - i);\n-        missed = cpu->u.missed[i];\n-        if (missed != 0) {\n-            cpu->u.missed[i] = 0;\n-            for (it = _pr_interruptTable; it->name; it++) {\n-                if (missed & it->missed_bit) {\n-                    PR_LOG(_pr_sched_lm, PR_LOG_MIN, (\"IntsOn[0]: %s intr\", it->name));\n-                    (*it->handler)();\n-                }\n-            }\n+void _PR_IntsOn(_PRCPU* cpu) {\n+  PRUintn missed, pri, i;\n+  _PRInterruptTable* it;\n+  PRThread* me;\n+\n+  PR_ASSERT(cpu); /* Global threads don't have CPUs */\n+  PR_ASSERT(_PR_MD_GET_INTSOFF() > 0);\n+  me = _PR_MD_CURRENT_THREAD();\n+  PR_ASSERT(!(me->flags & _PR_IDLE_THREAD));\n+\n+  /*\n+  ** Process delayed interrupts. This logic is kinda scary because we\n+  ** need to avoid losing an interrupt (it's ok to delay an interrupt\n+  ** until later).\n+  **\n+  ** There are two missed state words. _pr_ints.where indicates to the\n+  ** interrupt handler which state word is currently safe for\n+  ** modification.\n+  **\n+  ** This code scans both interrupt state words, using the where flag\n+  ** to indicate to the interrupt which state word is safe for writing.\n+  ** If an interrupt comes in during a scan the other word will be\n+  ** modified. This modification will be noticed during the next\n+  ** iteration of the loop or during the next call to this routine.\n+  */\n+  for (i = 0; i < 2; i++) {\n+    cpu->where = (1 - i);\n+    missed = cpu->u.missed[i];\n+    if (missed != 0) {\n+      cpu->u.missed[i] = 0;\n+      for (it = _pr_interruptTable; it->name; it++) {\n+        if (missed & it->missed_bit) {\n+          PR_LOG(_pr_sched_lm, PR_LOG_MIN, (\"IntsOn[0]: %s intr\", it->name));\n+          (*it->handler)();\n         }\n+      }\n     }\n+  }\n \n-    if (cpu->u.missed[3] != 0) {\n-        _PRCPU* cpu;\n+  if (cpu->u.missed[3] != 0) {\n+    _PRCPU* cpu;\n \n-        _PR_THREAD_LOCK(me);\n-        me->state = _PR_RUNNABLE;\n-        pri = me->priority;\n+    _PR_THREAD_LOCK(me);\n+    me->state = _PR_RUNNABLE;\n+    pri = me->priority;\n \n-        cpu = me->cpu;\n-        _PR_RUNQ_LOCK(cpu);\n-        _PR_ADD_RUNQ(me, cpu, pri);\n-        _PR_RUNQ_UNLOCK(cpu);\n-        _PR_THREAD_UNLOCK(me);\n-        _PR_MD_SWITCH_CONTEXT(me);\n-    }\n+    cpu = me->cpu;\n+    _PR_RUNQ_LOCK(cpu);\n+    _PR_ADD_RUNQ(me, cpu, pri);\n+    _PR_RUNQ_UNLOCK(cpu);\n+    _PR_THREAD_UNLOCK(me);\n+    _PR_MD_SWITCH_CONTEXT(me);\n+  }\n }\n \n /*\n@@ -86,98 +81,92 @@ _PR_IntsOn(_PRCPU* cpu)\n ** threads that are trying to be suspended\n ** Note: Caller must hold _PR_LOCK_LOCK()\n */\n-void\n-_PR_UnblockLockWaiter(PRLock* lock)\n-{\n-    PRThread* t = NULL;\n-    PRThread* me;\n-    PRCList* q;\n-\n-    q = lock->waitQ.next;\n-    PR_ASSERT(q != &lock->waitQ);\n-    while (q != &lock->waitQ) {\n-        /* Unblock first waiter */\n-        t = _PR_THREAD_CONDQ_PTR(q);\n+void _PR_UnblockLockWaiter(PRLock* lock) {\n+  PRThread* t = NULL;\n+  PRThread* me;\n+  PRCList* q;\n \n-        /*\n-        ** We are about to change the thread's state to runnable and for local\n-        ** threads, we are going to assign a cpu to it.  So, protect thread's\n-        ** data structure.\n-        */\n-        _PR_THREAD_LOCK(t);\n+  q = lock->waitQ.next;\n+  PR_ASSERT(q != &lock->waitQ);\n+  while (q != &lock->waitQ) {\n+    /* Unblock first waiter */\n+    t = _PR_THREAD_CONDQ_PTR(q);\n \n-        if (t->flags & _PR_SUSPENDING) {\n-            q = q->next;\n-            _PR_THREAD_UNLOCK(t);\n-            continue;\n-        }\n+    /*\n+    ** We are about to change the thread's state to runnable and for local\n+    ** threads, we are going to assign a cpu to it.  So, protect thread's\n+    ** data structure.\n+    */\n+    _PR_THREAD_LOCK(t);\n \n-        /* Found a runnable thread */\n-        PR_ASSERT(t->state == _PR_LOCK_WAIT);\n-        PR_ASSERT(t->wait.lock == lock);\n-        t->wait.lock = 0;\n-        PR_REMOVE_LINK(&t->waitQLinks); /* take it off lock's waitQ */\n+    if (t->flags & _PR_SUSPENDING) {\n+      q = q->next;\n+      _PR_THREAD_UNLOCK(t);\n+      continue;\n+    }\n \n-        /*\n-        ** If this is a native thread, nothing else to do except to wake it\n-        ** up by calling the machine dependent wakeup routine.\n-        **\n-        ** If this is a local thread, we need to assign it a cpu and\n-        ** put the thread on that cpu's run queue.  There are two cases to\n-        ** take care of.  If the currently running thread is also a local\n-        ** thread, we just assign our own cpu to that thread and put it on\n-        ** the cpu's run queue.  If the the currently running thread is a\n-        ** native thread, we assign the primordial cpu to it (on NT,\n-        ** MD_WAKEUP handles the cpu assignment).\n-        */\n+    /* Found a runnable thread */\n+    PR_ASSERT(t->state == _PR_LOCK_WAIT);\n+    PR_ASSERT(t->wait.lock == lock);\n+    t->wait.lock = 0;\n+    PR_REMOVE_LINK(&t->waitQLinks); /* take it off lock's waitQ */\n \n-        if (!_PR_IS_NATIVE_THREAD(t)) {\n-            t->state = _PR_RUNNABLE;\n+    /*\n+    ** If this is a native thread, nothing else to do except to wake it\n+    ** up by calling the machine dependent wakeup routine.\n+    **\n+    ** If this is a local thread, we need to assign it a cpu and\n+    ** put the thread on that cpu's run queue.  There are two cases to\n+    ** take care of.  If the currently running thread is also a local\n+    ** thread, we just assign our own cpu to that thread and put it on\n+    ** the cpu's run queue.  If the the currently running thread is a\n+    ** native thread, we assign the primordial cpu to it (on NT,\n+    ** MD_WAKEUP handles the cpu assignment).\n+    */\n \n-            me = _PR_MD_CURRENT_THREAD();\n+    if (!_PR_IS_NATIVE_THREAD(t)) {\n+      t->state = _PR_RUNNABLE;\n \n-            _PR_AddThreadToRunQ(me, t);\n-            _PR_THREAD_UNLOCK(t);\n-        } else {\n-            t->state = _PR_RUNNING;\n-            _PR_THREAD_UNLOCK(t);\n-        }\n-        _PR_MD_WAKEUP_WAITER(t);\n-        break;\n+      me = _PR_MD_CURRENT_THREAD();\n+\n+      _PR_AddThreadToRunQ(me, t);\n+      _PR_THREAD_UNLOCK(t);\n+    } else {\n+      t->state = _PR_RUNNING;\n+      _PR_THREAD_UNLOCK(t);\n     }\n-    return;\n+    _PR_MD_WAKEUP_WAITER(t);\n+    break;\n+  }\n+  return;\n }\n \n /************************************************************************/\n \n-PR_IMPLEMENT(PRLock*)\n-PR_NewLock(void)\n-{\n-    PRLock* lock;\n+PR_IMPLEMENT(PRLock*) PR_NewLock(void) {\n+  PRLock* lock;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    lock = PR_NEWZAP(PRLock);\n-    if (lock) {\n-        if (_PR_InitLock(lock) != PR_SUCCESS) {\n-            PR_DELETE(lock);\n-            return NULL;\n-        }\n+  lock = PR_NEWZAP(PRLock);\n+  if (lock) {\n+    if (_PR_InitLock(lock) != PR_SUCCESS) {\n+      PR_DELETE(lock);\n+      return NULL;\n     }\n-    return lock;\n+  }\n+  return lock;\n }\n \n-PRStatus\n-_PR_InitLock(PRLock* lock)\n-{\n-    if (_PR_MD_NEW_LOCK(&lock->ilock) != PR_SUCCESS) {\n-        return PR_FAILURE;\n-    }\n-    PR_INIT_CLIST(&lock->links);\n-    PR_INIT_CLIST(&lock->waitQ);\n-    return PR_SUCCESS;\n+PRStatus _PR_InitLock(PRLock* lock) {\n+  if (_PR_MD_NEW_LOCK(&lock->ilock) != PR_SUCCESS) {\n+    return PR_FAILURE;\n+  }\n+  PR_INIT_CLIST(&lock->links);\n+  PR_INIT_CLIST(&lock->waitQ);\n+  return PR_SUCCESS;\n }\n \n /*\n@@ -185,76 +174,70 @@ _PR_InitLock(PRLock* lock)\n ** free because if some other thread has the pointer to this lock all\n ** bets are off.\n */\n-PR_IMPLEMENT(void)\n-PR_DestroyLock(PRLock* lock)\n-{\n-    _PR_FreeLock(lock);\n-    PR_DELETE(lock);\n+PR_IMPLEMENT(void) PR_DestroyLock(PRLock* lock) {\n+  _PR_FreeLock(lock);\n+  PR_DELETE(lock);\n }\n \n-void\n-_PR_FreeLock(PRLock* lock)\n-{\n-    PR_ASSERT(lock->owner == 0);\n-    _PR_MD_FREE_LOCK(&lock->ilock);\n+void _PR_FreeLock(PRLock* lock) {\n+  PR_ASSERT(lock->owner == 0);\n+  _PR_MD_FREE_LOCK(&lock->ilock);\n }\n \n extern PRThread* suspendAllThread;\n /*\n ** Lock the lock.\n */\n-PR_IMPLEMENT(void)\n-PR_Lock(PRLock* lock)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRIntn is;\n-    PRThread* t;\n-    PRCList* q;\n-\n-    PR_ASSERT(me != suspendAllThread);\n-    PR_ASSERT(!(me->flags & _PR_IDLE_THREAD));\n-    PR_ASSERT(lock != NULL);\n+PR_IMPLEMENT(void) PR_Lock(PRLock* lock) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRIntn is;\n+  PRThread* t;\n+  PRCList* q;\n+\n+  PR_ASSERT(me != suspendAllThread);\n+  PR_ASSERT(!(me->flags & _PR_IDLE_THREAD));\n+  PR_ASSERT(lock != NULL);\n #ifdef _PR_GLOBAL_THREADS_ONLY\n+  _PR_MD_LOCK(&lock->ilock);\n+  PR_ASSERT(lock->owner == 0);\n+  lock->owner = me;\n+  return;\n+#else /* _PR_GLOBAL_THREADS_ONLY */\n+\n+  if (_native_threads_only) {\n     _PR_MD_LOCK(&lock->ilock);\n     PR_ASSERT(lock->owner == 0);\n     lock->owner = me;\n     return;\n-#else /* _PR_GLOBAL_THREADS_ONLY */\n+  }\n \n-    if (_native_threads_only) {\n-        _PR_MD_LOCK(&lock->ilock);\n-        PR_ASSERT(lock->owner == 0);\n-        lock->owner = me;\n-        return;\n-    }\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n \n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-\n-    PR_ASSERT(_PR_IS_NATIVE_THREAD(me) || _PR_MD_GET_INTSOFF() != 0);\n+  PR_ASSERT(_PR_IS_NATIVE_THREAD(me) || _PR_MD_GET_INTSOFF() != 0);\n \n retry:\n-    _PR_LOCK_LOCK(lock);\n-    if (lock->owner == 0) {\n-        /* Just got the lock */\n-        lock->owner = me;\n-        lock->priority = me->priority;\n-        /* Add the granted lock to this owning thread's lock list */\n-        PR_APPEND_LINK(&lock->links, &me->lockList);\n-        _PR_LOCK_UNLOCK(lock);\n-        if (!_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_FAST_INTSON(is);\n-        }\n-        return;\n+  _PR_LOCK_LOCK(lock);\n+  if (lock->owner == 0) {\n+    /* Just got the lock */\n+    lock->owner = me;\n+    lock->priority = me->priority;\n+    /* Add the granted lock to this owning thread's lock list */\n+    PR_APPEND_LINK(&lock->links, &me->lockList);\n+    _PR_LOCK_UNLOCK(lock);\n+    if (!_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_FAST_INTSON(is);\n     }\n+    return;\n+  }\n \n-    /* If this thread already owns this lock, then it is a deadlock */\n-    PR_ASSERT(lock->owner != me);\n+  /* If this thread already owns this lock, then it is a deadlock */\n+  PR_ASSERT(lock->owner != me);\n \n-    PR_ASSERT(_PR_IS_NATIVE_THREAD(me) || _PR_MD_GET_INTSOFF() != 0);\n+  PR_ASSERT(_PR_IS_NATIVE_THREAD(me) || _PR_MD_GET_INTSOFF() != 0);\n \n-#if 0\n+#  if 0\n     if (me->priority > lock->owner->priority) {\n         /*\n         ** Give the lock owner a priority boost until we get the\n@@ -263,52 +246,52 @@ retry:\n         lock->boostPriority = me->priority;\n         _PR_SetThreadPriority(lock->owner, me->priority);\n     }\n-#endif\n-\n+#  endif\n+\n+  /*\n+  Add this thread to the asked for lock's list of waiting threads.  We\n+  add this thread thread in the right priority order so when the unlock\n+  occurs, the thread with the higher priority will get the lock.\n+  */\n+  q = lock->waitQ.next;\n+  if (q == &lock->waitQ ||\n+      _PR_THREAD_CONDQ_PTR(q)->priority ==\n+          _PR_THREAD_CONDQ_PTR(lock->waitQ.prev)->priority) {\n     /*\n-    Add this thread to the asked for lock's list of waiting threads.  We\n-    add this thread thread in the right priority order so when the unlock\n-    occurs, the thread with the higher priority will get the lock.\n-    */\n-    q = lock->waitQ.next;\n-    if (q == &lock->waitQ ||\n-        _PR_THREAD_CONDQ_PTR(q)->priority ==\n-            _PR_THREAD_CONDQ_PTR(lock->waitQ.prev)->priority) {\n-        /*\n-         * If all the threads in the lock waitQ have the same priority,\n-         * then avoid scanning the list:  insert the element at the end.\n-         */\n-        q = &lock->waitQ;\n-    } else {\n-        /* Sort thread into lock's waitQ at appropriate point */\n-        /* Now scan the list for where to insert this entry */\n-        while (q != &lock->waitQ) {\n-            t = _PR_THREAD_CONDQ_PTR(lock->waitQ.next);\n-            if (me->priority > t->priority) {\n-                /* Found a lower priority thread to insert in front of */\n-                break;\n-            }\n-            q = q->next;\n-        }\n+     * If all the threads in the lock waitQ have the same priority,\n+     * then avoid scanning the list:  insert the element at the end.\n+     */\n+    q = &lock->waitQ;\n+  } else {\n+    /* Sort thread into lock's waitQ at appropriate point */\n+    /* Now scan the list for where to insert this entry */\n+    while (q != &lock->waitQ) {\n+      t = _PR_THREAD_CONDQ_PTR(lock->waitQ.next);\n+      if (me->priority > t->priority) {\n+        /* Found a lower priority thread to insert in front of */\n+        break;\n+      }\n+      q = q->next;\n     }\n-    PR_INSERT_BEFORE(&me->waitQLinks, q);\n+  }\n+  PR_INSERT_BEFORE(&me->waitQLinks, q);\n \n-    /*\n-    Now grab the threadLock since we are about to change the state.  We have\n-    to do this since a PR_Suspend or PR_SetThreadPriority type call that takes\n-    a PRThread* as an argument could be changing the state of this thread from\n-    a thread running on a different cpu.\n-    */\n+  /*\n+  Now grab the threadLock since we are about to change the state.  We have\n+  to do this since a PR_Suspend or PR_SetThreadPriority type call that takes\n+  a PRThread* as an argument could be changing the state of this thread from\n+  a thread running on a different cpu.\n+  */\n \n-    _PR_THREAD_LOCK(me);\n-    me->state = _PR_LOCK_WAIT;\n-    me->wait.lock = lock;\n-    _PR_THREAD_UNLOCK(me);\n+  _PR_THREAD_LOCK(me);\n+  me->state = _PR_LOCK_WAIT;\n+  me->wait.lock = lock;\n+  _PR_THREAD_UNLOCK(me);\n \n-    _PR_LOCK_UNLOCK(lock);\n+  _PR_LOCK_UNLOCK(lock);\n \n-    _PR_MD_WAIT(me, PR_INTERVAL_NO_TIMEOUT);\n-    goto retry;\n+  _PR_MD_WAIT(me, PR_INTERVAL_NO_TIMEOUT);\n+  goto retry;\n \n #endif /* _PR_GLOBAL_THREADS_ONLY */\n }\n@@ -316,75 +299,73 @@ retry:\n /*\n ** Unlock the lock.\n */\n-PR_IMPLEMENT(PRStatus)\n-PR_Unlock(PRLock* lock)\n-{\n-    PRCList* q;\n-    PRThreadPriority pri, boost;\n-    PRIntn is;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    PR_ASSERT(lock != NULL);\n-    PR_ASSERT(lock->owner == me);\n-    PR_ASSERT(me != suspendAllThread);\n-    PR_ASSERT(!(me->flags & _PR_IDLE_THREAD));\n-    if (lock->owner != me) {\n-        return PR_FAILURE;\n-    }\n+PR_IMPLEMENT(PRStatus) PR_Unlock(PRLock* lock) {\n+  PRCList* q;\n+  PRThreadPriority pri, boost;\n+  PRIntn is;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  PR_ASSERT(lock != NULL);\n+  PR_ASSERT(lock->owner == me);\n+  PR_ASSERT(me != suspendAllThread);\n+  PR_ASSERT(!(me->flags & _PR_IDLE_THREAD));\n+  if (lock->owner != me) {\n+    return PR_FAILURE;\n+  }\n \n #ifdef _PR_GLOBAL_THREADS_ONLY\n+  lock->owner = 0;\n+  _PR_MD_UNLOCK(&lock->ilock);\n+  return PR_SUCCESS;\n+#else  /* _PR_GLOBAL_THREADS_ONLY */\n+\n+  if (_native_threads_only) {\n     lock->owner = 0;\n     _PR_MD_UNLOCK(&lock->ilock);\n     return PR_SUCCESS;\n-#else  /* _PR_GLOBAL_THREADS_ONLY */\n-\n-    if (_native_threads_only) {\n-        lock->owner = 0;\n-        _PR_MD_UNLOCK(&lock->ilock);\n-        return PR_SUCCESS;\n-    }\n-\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-    _PR_LOCK_LOCK(lock);\n-\n-    /* Remove the lock from the owning thread's lock list */\n-    PR_REMOVE_LINK(&lock->links);\n-    pri = lock->priority;\n-    boost = lock->boostPriority;\n-    if (boost > pri) {\n-        /*\n-        ** We received a priority boost during the time we held the lock.\n-        ** We need to figure out what priority to move to by scanning\n-        ** down our list of lock's that we are still holding and using\n-        ** the highest boosted priority found.\n-        */\n-        q = me->lockList.next;\n-        while (q != &me->lockList) {\n-            PRLock* ll = _PR_LOCK_PTR(q);\n-            if (ll->boostPriority > pri) {\n-                pri = ll->boostPriority;\n-            }\n-            q = q->next;\n-        }\n-        if (pri != me->priority) {\n-            _PR_SetThreadPriority(me, pri);\n-        }\n-    }\n-\n-    /* Unblock the first waiting thread */\n-    q = lock->waitQ.next;\n-    if (q != &lock->waitQ) {\n-        _PR_UnblockLockWaiter(lock);\n+  }\n+\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+  _PR_LOCK_LOCK(lock);\n+\n+  /* Remove the lock from the owning thread's lock list */\n+  PR_REMOVE_LINK(&lock->links);\n+  pri = lock->priority;\n+  boost = lock->boostPriority;\n+  if (boost > pri) {\n+    /*\n+    ** We received a priority boost during the time we held the lock.\n+    ** We need to figure out what priority to move to by scanning\n+    ** down our list of lock's that we are still holding and using\n+    ** the highest boosted priority found.\n+    */\n+    q = me->lockList.next;\n+    while (q != &me->lockList) {\n+      PRLock* ll = _PR_LOCK_PTR(q);\n+      if (ll->boostPriority > pri) {\n+        pri = ll->boostPriority;\n+      }\n+      q = q->next;\n     }\n-    lock->boostPriority = PR_PRIORITY_LOW;\n-    lock->owner = 0;\n-    _PR_LOCK_UNLOCK(lock);\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n+    if (pri != me->priority) {\n+      _PR_SetThreadPriority(me, pri);\n     }\n-    return PR_SUCCESS;\n+  }\n+\n+  /* Unblock the first waiting thread */\n+  q = lock->waitQ.next;\n+  if (q != &lock->waitQ) {\n+    _PR_UnblockLockWaiter(lock);\n+  }\n+  lock->boostPriority = PR_PRIORITY_LOW;\n+  lock->owner = 0;\n+  _PR_LOCK_UNLOCK(lock);\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n+  return PR_SUCCESS;\n #endif /* _PR_GLOBAL_THREADS_ONLY */\n }\n \n@@ -392,11 +373,9 @@ PR_Unlock(PRLock* lock)\n **  If the current thread owns |lock|, this assertion is guaranteed to\n **  succeed.  Otherwise, the behavior of this function is undefined.\n */\n-PR_IMPLEMENT(void)\n-PR_AssertCurrentThreadOwnsLock(PRLock* lock)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PR_ASSERT(lock->owner == me);\n+PR_IMPLEMENT(void) PR_AssertCurrentThreadOwnsLock(PRLock* lock) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PR_ASSERT(lock->owner == me);\n }\n \n /*\n@@ -404,52 +383,50 @@ PR_AssertCurrentThreadOwnsLock(PRLock* lock)\n ** thread. Return PR_FALSE if some other thread owned the lock at the\n ** time of the call.\n */\n-PR_IMPLEMENT(PRBool)\n-PR_TestAndLock(PRLock* lock)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRBool rv = PR_FALSE;\n-    PRIntn is;\n+PR_IMPLEMENT(PRBool) PR_TestAndLock(PRLock* lock) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRBool rv = PR_FALSE;\n+  PRIntn is;\n \n #ifdef _PR_GLOBAL_THREADS_ONLY\n+  is = _PR_MD_TEST_AND_LOCK(&lock->ilock);\n+  if (is == 0) {\n+    lock->owner = me;\n+    return PR_TRUE;\n+  }\n+  return PR_FALSE;\n+#else /* _PR_GLOBAL_THREADS_ONLY */\n+\n+#  ifndef _PR_LOCAL_THREADS_ONLY\n+  if (_native_threads_only) {\n     is = _PR_MD_TEST_AND_LOCK(&lock->ilock);\n     if (is == 0) {\n-        lock->owner = me;\n-        return PR_TRUE;\n+      lock->owner = me;\n+      return PR_TRUE;\n     }\n     return PR_FALSE;\n-#else /* _PR_GLOBAL_THREADS_ONLY */\n+  }\n+#  endif\n \n-#ifndef _PR_LOCAL_THREADS_ONLY\n-    if (_native_threads_only) {\n-        is = _PR_MD_TEST_AND_LOCK(&lock->ilock);\n-        if (is == 0) {\n-            lock->owner = me;\n-            return PR_TRUE;\n-        }\n-        return PR_FALSE;\n-    }\n-#endif\n-\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n \n-    _PR_LOCK_LOCK(lock);\n-    if (lock->owner == 0) {\n-        /* Just got the lock */\n-        lock->owner = me;\n-        lock->priority = me->priority;\n-        /* Add the granted lock to this owning thread's lock list */\n-        PR_APPEND_LINK(&lock->links, &me->lockList);\n-        rv = PR_TRUE;\n-    }\n-    _PR_LOCK_UNLOCK(lock);\n-\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n-    }\n-    return rv;\n+  _PR_LOCK_LOCK(lock);\n+  if (lock->owner == 0) {\n+    /* Just got the lock */\n+    lock->owner = me;\n+    lock->priority = me->priority;\n+    /* Add the granted lock to this owning thread's lock list */\n+    PR_APPEND_LINK(&lock->links, &me->lockList);\n+    rv = PR_TRUE;\n+  }\n+  _PR_LOCK_UNLOCK(lock);\n+\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n+  return rv;\n #endif /* _PR_GLOBAL_THREADS_ONLY */\n }\n \n@@ -458,8 +435,6 @@ PR_TestAndLock(PRLock* lock)\n /***********************ROUTINES FOR DCE EMULATION***********************/\n /************************************************************************/\n /************************************************************************/\n-PR_IMPLEMENT(PRStatus)\n-PRP_TryLock(PRLock* lock)\n-{\n-    return (PR_TestAndLock(lock)) ? PR_SUCCESS : PR_FAILURE;\n+PR_IMPLEMENT(PRStatus) PRP_TryLock(PRLock* lock) {\n+  return (PR_TestAndLock(lock)) ? PR_SUCCESS : PR_FAILURE;\n }\ndiff --git a/nspr/pr/src/threads/combined/prustack.c b/nspr/pr/src/threads/combined/prustack.c\nindex 075b1ea..5ac88b8 100644\n--- a/nspr/pr/src/threads/combined/prustack.c\n+++ b/nspr/pr/src/threads/combined/prustack.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -21,157 +22,147 @@ PRBool _pr_debugStacks = PR_FALSE;\n #define REDZONE (2 << _pr_pageShift)\n \n #define _PR_THREAD_STACK_PTR(_qp) \\\n-    ((PRThreadStack*)((char*)(_qp) - offsetof(PRThreadStack, links)))\n+  ((PRThreadStack*)((char*)(_qp) - offsetof(PRThreadStack, links)))\n \n-void\n-_PR_InitStacks(void)\n-{\n-    _pr_stackLock = PR_NewLock();\n-}\n+void _PR_InitStacks(void) { _pr_stackLock = PR_NewLock(); }\n \n-void\n-_PR_CleanupStacks(void)\n-{\n-    if (_pr_stackLock) {\n-        PR_DestroyLock(_pr_stackLock);\n-        _pr_stackLock = NULL;\n-    }\n+void _PR_CleanupStacks(void) {\n+  if (_pr_stackLock) {\n+    PR_DestroyLock(_pr_stackLock);\n+    _pr_stackLock = NULL;\n+  }\n }\n \n /*\n ** Allocate a stack for a thread.\n */\n-PRThreadStack*\n-_PR_NewStack(PRUint32 stackSize)\n-{\n-    PRCList* qp;\n-    PRThreadStack* ts;\n-    PRThread* thr;\n-\n+PRThreadStack* _PR_NewStack(PRUint32 stackSize) {\n+  PRCList* qp;\n+  PRThreadStack* ts;\n+  PRThread* thr;\n+\n+  /*\n+  ** Trim the list of free stacks. Trim it backwards, tossing out the\n+  ** oldest stack found first (this way more recent stacks have a\n+  ** chance of being present in the data cache).\n+  */\n+  PR_Lock(_pr_stackLock);\n+  qp = _pr_freeStacks.prev;\n+  while ((_pr_numFreeStacks > _pr_maxFreeStacks) && (qp != &_pr_freeStacks)) {\n+    ts = _PR_THREAD_STACK_PTR(qp);\n+    thr = _PR_THREAD_STACK_TO_PTR(ts);\n+    qp = qp->prev;\n     /*\n-    ** Trim the list of free stacks. Trim it backwards, tossing out the\n-    ** oldest stack found first (this way more recent stacks have a\n-    ** chance of being present in the data cache).\n-    */\n-    PR_Lock(_pr_stackLock);\n-    qp = _pr_freeStacks.prev;\n-    while ((_pr_numFreeStacks > _pr_maxFreeStacks) && (qp != &_pr_freeStacks)) {\n-        ts = _PR_THREAD_STACK_PTR(qp);\n-        thr = _PR_THREAD_STACK_TO_PTR(ts);\n-        qp = qp->prev;\n-        /*\n-         * skip stacks which are still being used\n-         */\n-        if (thr->no_sched) {\n-            continue;\n-        }\n-        PR_REMOVE_LINK(&ts->links);\n-\n-        /* Give platform OS to clear out the stack for debugging */\n-        _PR_MD_CLEAR_STACK(ts);\n-\n-        _pr_numFreeStacks--;\n-        _PR_DestroySegment(ts->seg);\n-        PR_DELETE(ts);\n+     * skip stacks which are still being used\n+     */\n+    if (thr->no_sched) {\n+      continue;\n     }\n-\n+    PR_REMOVE_LINK(&ts->links);\n+\n+    /* Give platform OS to clear out the stack for debugging */\n+    _PR_MD_CLEAR_STACK(ts);\n+\n+    _pr_numFreeStacks--;\n+    _PR_DestroySegment(ts->seg);\n+    PR_DELETE(ts);\n+  }\n+\n+  /*\n+  ** Find a free thread stack. This searches the list of free'd up\n+  ** virtually mapped thread stacks.\n+  */\n+  qp = _pr_freeStacks.next;\n+  ts = 0;\n+  while (qp != &_pr_freeStacks) {\n+    ts = _PR_THREAD_STACK_PTR(qp);\n+    thr = _PR_THREAD_STACK_TO_PTR(ts);\n+    qp = qp->next;\n     /*\n-    ** Find a free thread stack. This searches the list of free'd up\n-    ** virtually mapped thread stacks.\n-    */\n-    qp = _pr_freeStacks.next;\n-    ts = 0;\n-    while (qp != &_pr_freeStacks) {\n-        ts = _PR_THREAD_STACK_PTR(qp);\n-        thr = _PR_THREAD_STACK_TO_PTR(ts);\n-        qp = qp->next;\n-        /*\n-         * skip stacks which are still being used\n-         */\n-        if ((!(thr->no_sched)) && ((ts->allocSize - 2 * REDZONE) >= stackSize)) {\n-            /*\n-            ** Found a stack that is not in use and is big enough. Change\n-            ** stackSize to fit it.\n-            */\n-            stackSize = ts->allocSize - 2 * REDZONE;\n-            PR_REMOVE_LINK(&ts->links);\n-            _pr_numFreeStacks--;\n-            ts->links.next = 0;\n-            ts->links.prev = 0;\n-            PR_Unlock(_pr_stackLock);\n-            goto done;\n-        }\n-        ts = 0;\n+     * skip stacks which are still being used\n+     */\n+    if ((!(thr->no_sched)) && ((ts->allocSize - 2 * REDZONE) >= stackSize)) {\n+      /*\n+      ** Found a stack that is not in use and is big enough. Change\n+      ** stackSize to fit it.\n+      */\n+      stackSize = ts->allocSize - 2 * REDZONE;\n+      PR_REMOVE_LINK(&ts->links);\n+      _pr_numFreeStacks--;\n+      ts->links.next = 0;\n+      ts->links.prev = 0;\n+      PR_Unlock(_pr_stackLock);\n+      goto done;\n     }\n-    PR_Unlock(_pr_stackLock);\n+    ts = 0;\n+  }\n+  PR_Unlock(_pr_stackLock);\n \n+  if (!ts) {\n+    /* Make a new thread stack object. */\n+    ts = PR_NEWZAP(PRThreadStack);\n     if (!ts) {\n-        /* Make a new thread stack object. */\n-        ts = PR_NEWZAP(PRThreadStack);\n-        if (!ts) {\n-            return NULL;\n-        }\n-\n-        /*\n-        ** Assign some of the virtual space to the new stack object. We\n-        ** may not get that piece of VM, but if nothing else we will\n-        ** advance the pointer so we don't collide (unless the OS screws\n-        ** up).\n-        */\n-        ts->allocSize = stackSize + 2 * REDZONE;\n-        ts->seg = _PR_NewSegment(ts->allocSize, 0);\n-        if (!ts->seg) {\n-            PR_DELETE(ts);\n-            return NULL;\n-        }\n+      return NULL;\n+    }\n+\n+    /*\n+    ** Assign some of the virtual space to the new stack object. We\n+    ** may not get that piece of VM, but if nothing else we will\n+    ** advance the pointer so we don't collide (unless the OS screws\n+    ** up).\n+    */\n+    ts->allocSize = stackSize + 2 * REDZONE;\n+    ts->seg = _PR_NewSegment(ts->allocSize, 0);\n+    if (!ts->seg) {\n+      PR_DELETE(ts);\n+      return NULL;\n     }\n+  }\n \n done:\n-    ts->allocBase = (char*)ts->seg->vaddr;\n-    ts->flags = _PR_STACK_MAPPED;\n-    ts->stackSize = stackSize;\n+  ts->allocBase = (char*)ts->seg->vaddr;\n+  ts->flags = _PR_STACK_MAPPED;\n+  ts->stackSize = stackSize;\n \n #ifdef HAVE_STACK_GROWING_UP\n-    ts->stackTop = ts->allocBase + REDZONE;\n-    ts->stackBottom = ts->stackTop + stackSize;\n+  ts->stackTop = ts->allocBase + REDZONE;\n+  ts->stackBottom = ts->stackTop + stackSize;\n #else\n-    ts->stackBottom = ts->allocBase + REDZONE;\n-    ts->stackTop = ts->stackBottom + stackSize;\n+  ts->stackBottom = ts->allocBase + REDZONE;\n+  ts->stackTop = ts->stackBottom + stackSize;\n #endif\n \n-    PR_LOG(_pr_thread_lm, PR_LOG_NOTICE,\n-           (\"thread stack: base=0x%x limit=0x%x bottom=0x%x top=0x%x\\n\",\n-            ts->allocBase, ts->allocBase + ts->allocSize - 1,\n-            ts->allocBase + REDZONE, ts->allocBase + REDZONE + stackSize - 1));\n+  PR_LOG(_pr_thread_lm, PR_LOG_NOTICE,\n+         (\"thread stack: base=0x%x limit=0x%x bottom=0x%x top=0x%x\\n\",\n+          ts->allocBase, ts->allocBase + ts->allocSize - 1,\n+          ts->allocBase + REDZONE, ts->allocBase + REDZONE + stackSize - 1));\n \n-    _PR_MD_INIT_STACK(ts, REDZONE);\n+  _PR_MD_INIT_STACK(ts, REDZONE);\n \n-    return ts;\n+  return ts;\n }\n \n /*\n ** Free the stack for the current thread\n */\n-void\n-_PR_FreeStack(PRThreadStack* ts)\n-{\n-    if (!ts) {\n-        return;\n-    }\n-    if (ts->flags & _PR_STACK_PRIMORDIAL) {\n-        PR_DELETE(ts);\n-        return;\n-    }\n-\n-    /*\n-    ** Put the stack on the free list. This is done because we are still\n-    ** using the stack. Next time a thread is created we will trim the\n-    ** list down; it's safe to do it then because we will have had to\n-    ** context switch to a live stack before another thread can be\n-    ** created.\n-    */\n-    PR_Lock(_pr_stackLock);\n-    PR_APPEND_LINK(&ts->links, _pr_freeStacks.prev);\n-    _pr_numFreeStacks++;\n-    PR_Unlock(_pr_stackLock);\n+void _PR_FreeStack(PRThreadStack* ts) {\n+  if (!ts) {\n+    return;\n+  }\n+  if (ts->flags & _PR_STACK_PRIMORDIAL) {\n+    PR_DELETE(ts);\n+    return;\n+  }\n+\n+  /*\n+  ** Put the stack on the free list. This is done because we are still\n+  ** using the stack. Next time a thread is created we will trim the\n+  ** list down; it's safe to do it then because we will have had to\n+  ** context switch to a live stack before another thread can be\n+  ** created.\n+  */\n+  PR_Lock(_pr_stackLock);\n+  PR_APPEND_LINK(&ts->links, _pr_freeStacks.prev);\n+  _pr_numFreeStacks++;\n+  PR_Unlock(_pr_stackLock);\n }\ndiff --git a/nspr/pr/src/threads/combined/pruthr.c b/nspr/pr/src/threads/combined/pruthr.c\nindex 747d52a..d27e2a1 100644\n--- a/nspr/pr/src/threads/combined/pruthr.c\n+++ b/nspr/pr/src/threads/combined/pruthr.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -13,7 +14,7 @@\n ** The pragma suppresses the warning.\n **\n */\n-#pragma warning(disable : 4101)\n+#  pragma warning(disable : 4101)\n #endif\n \n /* _pr_activeLock protects the following global variables */\n@@ -59,165 +60,157 @@ static void _PR_InitializeNativeStack(PRThreadStack* ts);\n static void _PR_InitializeRecycledThread(PRThread* thread);\n static void _PR_UserRunThread(void);\n \n-void\n-_PR_InitThreads(PRThreadType type, PRThreadPriority priority,\n-                PRUintn maxPTDs)\n-{\n-    PRThread* thread;\n-    PRThreadStack* stack;\n+void _PR_InitThreads(PRThreadType type, PRThreadPriority priority,\n+                     PRUintn maxPTDs) {\n+  PRThread* thread;\n+  PRThreadStack* stack;\n \n-    PR_ASSERT(priority == PR_PRIORITY_NORMAL);\n+  PR_ASSERT(priority == PR_PRIORITY_NORMAL);\n \n-    _pr_terminationCVLock = PR_NewLock();\n-    _pr_activeLock = PR_NewLock();\n+  _pr_terminationCVLock = PR_NewLock();\n+  _pr_activeLock = PR_NewLock();\n \n #ifndef HAVE_CUSTOM_USER_THREADS\n-    stack = PR_NEWZAP(PRThreadStack);\n-#ifdef HAVE_STACK_GROWING_UP\n-    stack->stackTop =\n-        (char*)((((PRWord)&type) >> _pr_pageShift) << _pr_pageShift);\n-#else\n-#if defined(SOLARIS)\n-    stack->stackTop = (char*)&thread;\n-#else\n-    stack->stackTop =\n-        (char*)((((PRWord)&type + _pr_pageSize - 1) >> _pr_pageShift)\n-                << _pr_pageShift);\n-#endif\n-#endif\n+  stack = PR_NEWZAP(PRThreadStack);\n+#  ifdef HAVE_STACK_GROWING_UP\n+  stack->stackTop =\n+      (char*)((((PRWord)&type) >> _pr_pageShift) << _pr_pageShift);\n+#  else\n+#    if defined(SOLARIS)\n+  stack->stackTop = (char*)&thread;\n+#    else\n+  stack->stackTop =\n+      (char*)((((PRWord)&type + _pr_pageSize - 1) >> _pr_pageShift)\n+              << _pr_pageShift);\n+#    endif\n+#  endif\n #else\n-    /* If stack is NULL, we're using custom user threads like NT fibers. */\n-    stack = PR_NEWZAP(PRThreadStack);\n-    if (stack) {\n-        stack->stackSize = 0;\n-        _PR_InitializeNativeStack(stack);\n-    }\n+  /* If stack is NULL, we're using custom user threads like NT fibers. */\n+  stack = PR_NEWZAP(PRThreadStack);\n+  if (stack) {\n+    stack->stackSize = 0;\n+    _PR_InitializeNativeStack(stack);\n+  }\n #endif /* HAVE_CUSTOM_USER_THREADS */\n \n-    thread = _PR_AttachThread(type, priority, stack);\n-    if (thread) {\n-        _PR_MD_SET_CURRENT_THREAD(thread);\n+  thread = _PR_AttachThread(type, priority, stack);\n+  if (thread) {\n+    _PR_MD_SET_CURRENT_THREAD(thread);\n \n-        if (type == PR_SYSTEM_THREAD) {\n-            thread->flags = _PR_SYSTEM;\n-            _pr_systemActive++;\n-            _pr_primordialExitCount = 0;\n-        } else {\n-            _pr_userActive++;\n-            _pr_primordialExitCount = 1;\n-        }\n-        thread->no_sched = 1;\n-        _pr_primordialExitCVar = PR_NewCondVar(_pr_activeLock);\n+    if (type == PR_SYSTEM_THREAD) {\n+      thread->flags = _PR_SYSTEM;\n+      _pr_systemActive++;\n+      _pr_primordialExitCount = 0;\n+    } else {\n+      _pr_userActive++;\n+      _pr_primordialExitCount = 1;\n     }\n+    thread->no_sched = 1;\n+    _pr_primordialExitCVar = PR_NewCondVar(_pr_activeLock);\n+  }\n \n-    if (!thread) {\n-        PR_Abort();\n-    }\n+  if (!thread) {\n+    PR_Abort();\n+  }\n #ifdef _PR_LOCAL_THREADS_ONLY\n-    thread->flags |= _PR_PRIMORDIAL;\n+  thread->flags |= _PR_PRIMORDIAL;\n #else\n-    thread->flags |= _PR_PRIMORDIAL | _PR_GLOBAL_SCOPE;\n+  thread->flags |= _PR_PRIMORDIAL | _PR_GLOBAL_SCOPE;\n #endif\n \n+  /*\n+   * Needs _PR_PRIMORDIAL flag set before calling\n+   * _PR_MD_INIT_THREAD()\n+   */\n+  if (_PR_MD_INIT_THREAD(thread) == PR_FAILURE) {\n     /*\n-     * Needs _PR_PRIMORDIAL flag set before calling\n-     * _PR_MD_INIT_THREAD()\n+     * XXX do what?\n      */\n-    if (_PR_MD_INIT_THREAD(thread) == PR_FAILURE) {\n-        /*\n-         * XXX do what?\n-         */\n-    }\n-\n-    if (_PR_IS_NATIVE_THREAD(thread)) {\n-        PR_APPEND_LINK(&thread->active, &_PR_ACTIVE_GLOBAL_THREADQ());\n-        _pr_global_threads++;\n-    } else {\n-        PR_APPEND_LINK(&thread->active, &_PR_ACTIVE_LOCAL_THREADQ());\n-        _pr_local_threads++;\n-    }\n-\n-    _pr_recycleThreads = 0;\n-    _pr_deadQLock = PR_NewLock();\n-    _pr_numNativeDead = 0;\n-    _pr_numUserDead = 0;\n-    PR_INIT_CLIST(&_pr_deadNativeQ);\n-    PR_INIT_CLIST(&_pr_deadUserQ);\n+  }\n+\n+  if (_PR_IS_NATIVE_THREAD(thread)) {\n+    PR_APPEND_LINK(&thread->active, &_PR_ACTIVE_GLOBAL_THREADQ());\n+    _pr_global_threads++;\n+  } else {\n+    PR_APPEND_LINK(&thread->active, &_PR_ACTIVE_LOCAL_THREADQ());\n+    _pr_local_threads++;\n+  }\n+\n+  _pr_recycleThreads = 0;\n+  _pr_deadQLock = PR_NewLock();\n+  _pr_numNativeDead = 0;\n+  _pr_numUserDead = 0;\n+  PR_INIT_CLIST(&_pr_deadNativeQ);\n+  PR_INIT_CLIST(&_pr_deadUserQ);\n }\n \n-void\n-_PR_CleanupThreads(void)\n-{\n-    if (_pr_terminationCVLock) {\n-        PR_DestroyLock(_pr_terminationCVLock);\n-        _pr_terminationCVLock = NULL;\n-    }\n-    if (_pr_activeLock) {\n-        PR_DestroyLock(_pr_activeLock);\n-        _pr_activeLock = NULL;\n-    }\n-    if (_pr_primordialExitCVar) {\n-        PR_DestroyCondVar(_pr_primordialExitCVar);\n-        _pr_primordialExitCVar = NULL;\n-    }\n-    /* TODO _pr_dead{Native,User}Q need to be deleted */\n-    if (_pr_deadQLock) {\n-        PR_DestroyLock(_pr_deadQLock);\n-        _pr_deadQLock = NULL;\n-    }\n+void _PR_CleanupThreads(void) {\n+  if (_pr_terminationCVLock) {\n+    PR_DestroyLock(_pr_terminationCVLock);\n+    _pr_terminationCVLock = NULL;\n+  }\n+  if (_pr_activeLock) {\n+    PR_DestroyLock(_pr_activeLock);\n+    _pr_activeLock = NULL;\n+  }\n+  if (_pr_primordialExitCVar) {\n+    PR_DestroyCondVar(_pr_primordialExitCVar);\n+    _pr_primordialExitCVar = NULL;\n+  }\n+  /* TODO _pr_dead{Native,User}Q need to be deleted */\n+  if (_pr_deadQLock) {\n+    PR_DestroyLock(_pr_deadQLock);\n+    _pr_deadQLock = NULL;\n+  }\n }\n \n /*\n ** Initialize a stack for a native thread\n */\n-static void\n-_PR_InitializeNativeStack(PRThreadStack* ts)\n-{\n-    if (ts && (ts->stackTop == 0)) {\n-        ts->allocSize = ts->stackSize;\n+static void _PR_InitializeNativeStack(PRThreadStack* ts) {\n+  if (ts && (ts->stackTop == 0)) {\n+    ts->allocSize = ts->stackSize;\n \n-        /*\n-        ** Setup stackTop and stackBottom values.\n-        */\n+    /*\n+    ** Setup stackTop and stackBottom values.\n+    */\n #ifdef HAVE_STACK_GROWING_UP\n-        ts->allocBase = (char*)((((PRWord)&ts) >> _pr_pageShift) << _pr_pageShift);\n-        ts->stackBottom = ts->allocBase + ts->stackSize;\n-        ts->stackTop = ts->allocBase;\n+    ts->allocBase = (char*)((((PRWord)&ts) >> _pr_pageShift) << _pr_pageShift);\n+    ts->stackBottom = ts->allocBase + ts->stackSize;\n+    ts->stackTop = ts->allocBase;\n #else\n-        ts->allocBase = (char*)((((PRWord)&ts + _pr_pageSize - 1) >> _pr_pageShift)\n-                                << _pr_pageShift);\n-        ts->stackTop = ts->allocBase;\n-        ts->stackBottom = ts->allocBase - ts->stackSize;\n+    ts->allocBase = (char*)((((PRWord)&ts + _pr_pageSize - 1) >> _pr_pageShift)\n+                            << _pr_pageShift);\n+    ts->stackTop = ts->allocBase;\n+    ts->stackBottom = ts->allocBase - ts->stackSize;\n #endif\n-    }\n+  }\n }\n \n-void\n-_PR_NotifyJoinWaiters(PRThread* thread)\n-{\n-    /*\n-    ** Handle joinable threads.  Change the state to waiting for join.\n-    ** Remove from our run Q and put it on global waiting to join Q.\n-    ** Notify on our \"termination\" condition variable so that joining\n-    ** thread will know about our termination.  Switch our context and\n-    ** come back later on to continue the cleanup.\n-    */\n-    PR_ASSERT(thread == _PR_MD_CURRENT_THREAD());\n-    if (thread->term != NULL) {\n-        PR_Lock(_pr_terminationCVLock);\n-        _PR_THREAD_LOCK(thread);\n-        thread->state = _PR_JOIN_WAIT;\n-        if (!_PR_IS_NATIVE_THREAD(thread)) {\n-            _PR_MISCQ_LOCK(thread->cpu);\n-            _PR_ADD_JOINQ(thread, thread->cpu);\n-            _PR_MISCQ_UNLOCK(thread->cpu);\n-        }\n-        _PR_THREAD_UNLOCK(thread);\n-        PR_NotifyCondVar(thread->term);\n-        PR_Unlock(_pr_terminationCVLock);\n-        _PR_MD_WAIT(thread, PR_INTERVAL_NO_TIMEOUT);\n-        PR_ASSERT(thread->state != _PR_JOIN_WAIT);\n+void _PR_NotifyJoinWaiters(PRThread* thread) {\n+  /*\n+  ** Handle joinable threads.  Change the state to waiting for join.\n+  ** Remove from our run Q and put it on global waiting to join Q.\n+  ** Notify on our \"termination\" condition variable so that joining\n+  ** thread will know about our termination.  Switch our context and\n+  ** come back later on to continue the cleanup.\n+  */\n+  PR_ASSERT(thread == _PR_MD_CURRENT_THREAD());\n+  if (thread->term != NULL) {\n+    PR_Lock(_pr_terminationCVLock);\n+    _PR_THREAD_LOCK(thread);\n+    thread->state = _PR_JOIN_WAIT;\n+    if (!_PR_IS_NATIVE_THREAD(thread)) {\n+      _PR_MISCQ_LOCK(thread->cpu);\n+      _PR_ADD_JOINQ(thread, thread->cpu);\n+      _PR_MISCQ_UNLOCK(thread->cpu);\n     }\n+    _PR_THREAD_UNLOCK(thread);\n+    PR_NotifyCondVar(thread->term);\n+    PR_Unlock(_pr_terminationCVLock);\n+    _PR_MD_WAIT(thread, PR_INTERVAL_NO_TIMEOUT);\n+    PR_ASSERT(thread->state != _PR_JOIN_WAIT);\n+  }\n }\n \n /*\n@@ -227,51 +220,47 @@ _PR_NotifyJoinWaiters(PRThread* thread)\n  * the dead thread queue or when it is reused.  Here, we are doing\n  * this lazily, when the thread is reused in _PR_CreateThread().\n  */\n-static void\n-_PR_InitializeRecycledThread(PRThread* thread)\n-{\n-    /*\n-     * Assert that the following data members are already zeroed\n-     * by _PR_CleanupThread().\n-     */\n+static void _PR_InitializeRecycledThread(PRThread* thread) {\n+  /*\n+   * Assert that the following data members are already zeroed\n+   * by _PR_CleanupThread().\n+   */\n #ifdef DEBUG\n-    if (thread->privateData) {\n-        unsigned int i;\n-        for (i = 0; i < thread->tpdLength; i++) {\n-            PR_ASSERT(thread->privateData[i] == NULL);\n-        }\n+  if (thread->privateData) {\n+    unsigned int i;\n+    for (i = 0; i < thread->tpdLength; i++) {\n+      PR_ASSERT(thread->privateData[i] == NULL);\n     }\n+  }\n #endif\n-    PR_ASSERT(thread->dumpArg == 0 && thread->dump == 0);\n-    PR_ASSERT(thread->errorString == 0 && thread->errorStringSize == 0);\n-    PR_ASSERT(thread->errorStringLength == 0);\n-    PR_ASSERT(thread->name == 0);\n-\n-    /* Reset data members in thread structure */\n-    thread->errorCode = thread->osErrorCode = 0;\n-    thread->io_pending = thread->io_suspended = PR_FALSE;\n-    thread->environment = 0;\n-    PR_INIT_CLIST(&thread->lockList);\n+  PR_ASSERT(thread->dumpArg == 0 && thread->dump == 0);\n+  PR_ASSERT(thread->errorString == 0 && thread->errorStringSize == 0);\n+  PR_ASSERT(thread->errorStringLength == 0);\n+  PR_ASSERT(thread->name == 0);\n+\n+  /* Reset data members in thread structure */\n+  thread->errorCode = thread->osErrorCode = 0;\n+  thread->io_pending = thread->io_suspended = PR_FALSE;\n+  thread->environment = 0;\n+  PR_INIT_CLIST(&thread->lockList);\n }\n \n-PRStatus\n-_PR_RecycleThread(PRThread* thread)\n-{\n-    if (_PR_IS_NATIVE_THREAD(thread) && _PR_NUM_DEADNATIVE < _pr_recycleThreads) {\n-        _PR_DEADQ_LOCK;\n-        PR_APPEND_LINK(&thread->links, &_PR_DEADNATIVEQ);\n-        _PR_INC_DEADNATIVE;\n-        _PR_DEADQ_UNLOCK;\n-        return (PR_SUCCESS);\n-    } else if (!_PR_IS_NATIVE_THREAD(thread) &&\n-               _PR_NUM_DEADUSER < _pr_recycleThreads) {\n-        _PR_DEADQ_LOCK;\n-        PR_APPEND_LINK(&thread->links, &_PR_DEADUSERQ);\n-        _PR_INC_DEADUSER;\n-        _PR_DEADQ_UNLOCK;\n-        return (PR_SUCCESS);\n-    }\n-    return (PR_FAILURE);\n+PRStatus _PR_RecycleThread(PRThread* thread) {\n+  if (_PR_IS_NATIVE_THREAD(thread) && _PR_NUM_DEADNATIVE < _pr_recycleThreads) {\n+    _PR_DEADQ_LOCK;\n+    PR_APPEND_LINK(&thread->links, &_PR_DEADNATIVEQ);\n+    _PR_INC_DEADNATIVE;\n+    _PR_DEADQ_UNLOCK;\n+    return (PR_SUCCESS);\n+  } else if (!_PR_IS_NATIVE_THREAD(thread) &&\n+             _PR_NUM_DEADUSER < _pr_recycleThreads) {\n+    _PR_DEADQ_LOCK;\n+    PR_APPEND_LINK(&thread->links, &_PR_DEADUSERQ);\n+    _PR_INC_DEADUSER;\n+    _PR_DEADQ_UNLOCK;\n+    return (PR_SUCCESS);\n+  }\n+  return (PR_FAILURE);\n }\n \n /*\n@@ -286,81 +275,73 @@ _PR_RecycleThread(PRThread* thread)\n  * in a deadlock.\n  */\n \n-static void\n-_PR_DecrActiveThreadCount(PRThread* thread)\n-{\n-    PR_Lock(_pr_activeLock);\n-    if (thread->flags & _PR_SYSTEM) {\n-        _pr_systemActive--;\n-    } else {\n-        _pr_userActive--;\n-        if (_pr_userActive == _pr_primordialExitCount) {\n-            PR_NotifyCondVar(_pr_primordialExitCVar);\n-        }\n-    }\n-    PR_Unlock(_pr_activeLock);\n+static void _PR_DecrActiveThreadCount(PRThread* thread) {\n+  PR_Lock(_pr_activeLock);\n+  if (thread->flags & _PR_SYSTEM) {\n+    _pr_systemActive--;\n+  } else {\n+    _pr_userActive--;\n+    if (_pr_userActive == _pr_primordialExitCount) {\n+      PR_NotifyCondVar(_pr_primordialExitCVar);\n+    }\n+  }\n+  PR_Unlock(_pr_activeLock);\n }\n \n /*\n ** Detach thread structure\n */\n-static void\n-_PR_DestroyThread(PRThread* thread)\n-{\n-    _PR_MD_FREE_LOCK(&thread->threadLock);\n-    PR_DELETE(thread);\n+static void _PR_DestroyThread(PRThread* thread) {\n+  _PR_MD_FREE_LOCK(&thread->threadLock);\n+  PR_DELETE(thread);\n }\n \n-void\n-_PR_NativeDestroyThread(PRThread* thread)\n-{\n-    if (thread->term) {\n-        PR_DestroyCondVar(thread->term);\n-        thread->term = 0;\n-    }\n-    if (NULL != thread->privateData) {\n-        PR_ASSERT(0 != thread->tpdLength);\n-        PR_DELETE(thread->privateData);\n-        thread->tpdLength = 0;\n-    }\n-    PR_DELETE(thread->stack);\n-    _PR_DestroyThread(thread);\n+void _PR_NativeDestroyThread(PRThread* thread) {\n+  if (thread->term) {\n+    PR_DestroyCondVar(thread->term);\n+    thread->term = 0;\n+  }\n+  if (NULL != thread->privateData) {\n+    PR_ASSERT(0 != thread->tpdLength);\n+    PR_DELETE(thread->privateData);\n+    thread->tpdLength = 0;\n+  }\n+  PR_DELETE(thread->stack);\n+  _PR_DestroyThread(thread);\n }\n \n-void\n-_PR_UserDestroyThread(PRThread* thread)\n-{\n-    if (thread->term) {\n-        PR_DestroyCondVar(thread->term);\n-        thread->term = 0;\n-    }\n-    if (NULL != thread->privateData) {\n-        PR_ASSERT(0 != thread->tpdLength);\n-        PR_DELETE(thread->privateData);\n-        thread->tpdLength = 0;\n-    }\n-    _PR_MD_FREE_LOCK(&thread->threadLock);\n-    if (thread->threadAllocatedOnStack == 1) {\n-        _PR_MD_CLEAN_THREAD(thread);\n-        /*\n-         *  Because the no_sched field is set, this thread/stack will\n-         *  will not be re-used until the flag is cleared by the thread\n-         *  we will context switch to.\n-         */\n-        _PR_FreeStack(thread->stack);\n-    } else {\n+void _PR_UserDestroyThread(PRThread* thread) {\n+  if (thread->term) {\n+    PR_DestroyCondVar(thread->term);\n+    thread->term = 0;\n+  }\n+  if (NULL != thread->privateData) {\n+    PR_ASSERT(0 != thread->tpdLength);\n+    PR_DELETE(thread->privateData);\n+    thread->tpdLength = 0;\n+  }\n+  _PR_MD_FREE_LOCK(&thread->threadLock);\n+  if (thread->threadAllocatedOnStack == 1) {\n+    _PR_MD_CLEAN_THREAD(thread);\n+    /*\n+     *  Because the no_sched field is set, this thread/stack will\n+     *  will not be re-used until the flag is cleared by the thread\n+     *  we will context switch to.\n+     */\n+    _PR_FreeStack(thread->stack);\n+  } else {\n #ifdef WINNT\n-        _PR_MD_CLEAN_THREAD(thread);\n+    _PR_MD_CLEAN_THREAD(thread);\n #else\n-        /*\n-         * This assertion does not apply to NT.  On NT, every fiber\n-         * has its threadAllocatedOnStack equal to 0.  Elsewhere,\n-         * only the primordial thread has its threadAllocatedOnStack\n-         * equal to 0.\n-         */\n-        PR_ASSERT(thread->flags & _PR_PRIMORDIAL);\n+    /*\n+     * This assertion does not apply to NT.  On NT, every fiber\n+     * has its threadAllocatedOnStack equal to 0.  Elsewhere,\n+     * only the primordial thread has its threadAllocatedOnStack\n+     * equal to 0.\n+     */\n+    PR_ASSERT(thread->flags & _PR_PRIMORDIAL);\n #endif\n-    }\n+  }\n }\n \n /*\n@@ -368,464 +349,452 @@ _PR_UserDestroyThread(PRThread* thread)\n ** thread is done executing and no longer needs the CPU. If there are no\n ** more user threads running then we can exit the program.\n */\n-void\n-_PR_NativeRunThread(void* arg)\n-{\n-    PRThread* thread = (PRThread*)arg;\n+void _PR_NativeRunThread(void* arg) {\n+  PRThread* thread = (PRThread*)arg;\n \n-    _PR_MD_SET_CURRENT_THREAD(thread);\n+  _PR_MD_SET_CURRENT_THREAD(thread);\n \n-    _PR_MD_SET_CURRENT_CPU(NULL);\n+  _PR_MD_SET_CURRENT_CPU(NULL);\n \n-    /* Set up the thread stack information */\n-    _PR_InitializeNativeStack(thread->stack);\n+  /* Set up the thread stack information */\n+  _PR_InitializeNativeStack(thread->stack);\n \n-    /* Set up the thread md information */\n-    if (_PR_MD_INIT_THREAD(thread) == PR_FAILURE) {\n-        /*\n-         * thread failed to initialize itself, possibly due to\n-         * failure to allocate per-thread resources\n-         */\n-        return;\n-    }\n+  /* Set up the thread md information */\n+  if (_PR_MD_INIT_THREAD(thread) == PR_FAILURE) {\n+    /*\n+     * thread failed to initialize itself, possibly due to\n+     * failure to allocate per-thread resources\n+     */\n+    return;\n+  }\n \n-    while (1) {\n-        thread->state = _PR_RUNNING;\n+  while (1) {\n+    thread->state = _PR_RUNNING;\n \n-        /*\n-         * Add to list of active threads\n-         */\n-        PR_Lock(_pr_activeLock);\n-        PR_APPEND_LINK(&thread->active, &_PR_ACTIVE_GLOBAL_THREADQ());\n-        _pr_global_threads++;\n-        PR_Unlock(_pr_activeLock);\n+    /*\n+     * Add to list of active threads\n+     */\n+    PR_Lock(_pr_activeLock);\n+    PR_APPEND_LINK(&thread->active, &_PR_ACTIVE_GLOBAL_THREADQ());\n+    _pr_global_threads++;\n+    PR_Unlock(_pr_activeLock);\n \n-        (*thread->startFunc)(thread->arg);\n+    (*thread->startFunc)(thread->arg);\n \n-        /*\n-         * The following two assertions are meant for NT asynch io.\n-         *\n-         * The thread should have no asynch io in progress when it\n-         * exits, otherwise the overlapped buffer, which is part of\n-         * the thread structure, would become invalid.\n-         */\n-        PR_ASSERT(thread->io_pending == PR_FALSE);\n-        /*\n-         * This assertion enforces the programming guideline that\n-         * if an io function times out or is interrupted, the thread\n-         * should close the fd to force the asynch io to abort\n-         * before it exits.  Right now, closing the fd is the only\n-         * way to clear the io_suspended flag.\n-         */\n-        PR_ASSERT(thread->io_suspended == PR_FALSE);\n+    /*\n+     * The following two assertions are meant for NT asynch io.\n+     *\n+     * The thread should have no asynch io in progress when it\n+     * exits, otherwise the overlapped buffer, which is part of\n+     * the thread structure, would become invalid.\n+     */\n+    PR_ASSERT(thread->io_pending == PR_FALSE);\n+    /*\n+     * This assertion enforces the programming guideline that\n+     * if an io function times out or is interrupted, the thread\n+     * should close the fd to force the asynch io to abort\n+     * before it exits.  Right now, closing the fd is the only\n+     * way to clear the io_suspended flag.\n+     */\n+    PR_ASSERT(thread->io_suspended == PR_FALSE);\n \n-        /*\n-         * remove thread from list of active threads\n-         */\n-        PR_Lock(_pr_activeLock);\n-        PR_REMOVE_LINK(&thread->active);\n-        _pr_global_threads--;\n-        PR_Unlock(_pr_activeLock);\n-\n-        PR_LOG(_pr_thread_lm, PR_LOG_MIN, (\"thread exiting\"));\n-\n-        /* All done, time to go away */\n-        _PR_CleanupThread(thread);\n-\n-        _PR_NotifyJoinWaiters(thread);\n-\n-        _PR_DecrActiveThreadCount(thread);\n-\n-        thread->state = _PR_DEAD_STATE;\n-\n-        if (!_pr_recycleThreads || (_PR_RecycleThread(thread) == PR_FAILURE)) {\n-            /*\n-             * thread not recycled\n-             * platform-specific thread exit processing\n-             *        - for stuff like releasing native-thread resources, etc.\n-             */\n-            _PR_MD_EXIT_THREAD(thread);\n-            /*\n-             * Free memory allocated for the thread\n-             */\n-            _PR_NativeDestroyThread(thread);\n-            /*\n-             * thread gone, cannot de-reference thread now\n-             */\n-            return;\n-        }\n+    /*\n+     * remove thread from list of active threads\n+     */\n+    PR_Lock(_pr_activeLock);\n+    PR_REMOVE_LINK(&thread->active);\n+    _pr_global_threads--;\n+    PR_Unlock(_pr_activeLock);\n+\n+    PR_LOG(_pr_thread_lm, PR_LOG_MIN, (\"thread exiting\"));\n+\n+    /* All done, time to go away */\n+    _PR_CleanupThread(thread);\n+\n+    _PR_NotifyJoinWaiters(thread);\n+\n+    _PR_DecrActiveThreadCount(thread);\n \n-        /* Now wait for someone to activate us again... */\n-        _PR_MD_WAIT(thread, PR_INTERVAL_NO_TIMEOUT);\n+    thread->state = _PR_DEAD_STATE;\n+\n+    if (!_pr_recycleThreads || (_PR_RecycleThread(thread) == PR_FAILURE)) {\n+      /*\n+       * thread not recycled\n+       * platform-specific thread exit processing\n+       *        - for stuff like releasing native-thread resources, etc.\n+       */\n+      _PR_MD_EXIT_THREAD(thread);\n+      /*\n+       * Free memory allocated for the thread\n+       */\n+      _PR_NativeDestroyThread(thread);\n+      /*\n+       * thread gone, cannot de-reference thread now\n+       */\n+      return;\n     }\n+\n+    /* Now wait for someone to activate us again... */\n+    _PR_MD_WAIT(thread, PR_INTERVAL_NO_TIMEOUT);\n+  }\n }\n \n-static void\n-_PR_UserRunThread(void)\n-{\n-    PRThread* thread = _PR_MD_CURRENT_THREAD();\n-    PRIntn is;\n+static void _PR_UserRunThread(void) {\n+  PRThread* thread = _PR_MD_CURRENT_THREAD();\n+  PRIntn is;\n \n-    if (_MD_LAST_THREAD()) {\n-        _MD_LAST_THREAD()->no_sched = 0;\n-    }\n+  if (_MD_LAST_THREAD()) {\n+    _MD_LAST_THREAD()->no_sched = 0;\n+  }\n \n #ifdef HAVE_CUSTOM_USER_THREADS\n-    if (thread->stack == NULL) {\n-        thread->stack = PR_NEWZAP(PRThreadStack);\n-        _PR_InitializeNativeStack(thread->stack);\n-    }\n+  if (thread->stack == NULL) {\n+    thread->stack = PR_NEWZAP(PRThreadStack);\n+    _PR_InitializeNativeStack(thread->stack);\n+  }\n #endif /* HAVE_CUSTOM_USER_THREADS */\n \n-    while (1) {\n-        /* Run thread main */\n-        if (!_PR_IS_NATIVE_THREAD(thread)) {\n-            _PR_MD_SET_INTSOFF(0);\n-        }\n+  while (1) {\n+    /* Run thread main */\n+    if (!_PR_IS_NATIVE_THREAD(thread)) {\n+      _PR_MD_SET_INTSOFF(0);\n+    }\n \n-        /*\n-         * Add to list of active threads\n-         */\n-        if (!(thread->flags & _PR_IDLE_THREAD)) {\n-            PR_Lock(_pr_activeLock);\n-            PR_APPEND_LINK(&thread->active, &_PR_ACTIVE_LOCAL_THREADQ());\n-            _pr_local_threads++;\n-            PR_Unlock(_pr_activeLock);\n-        }\n+    /*\n+     * Add to list of active threads\n+     */\n+    if (!(thread->flags & _PR_IDLE_THREAD)) {\n+      PR_Lock(_pr_activeLock);\n+      PR_APPEND_LINK(&thread->active, &_PR_ACTIVE_LOCAL_THREADQ());\n+      _pr_local_threads++;\n+      PR_Unlock(_pr_activeLock);\n+    }\n \n-        (*thread->startFunc)(thread->arg);\n+    (*thread->startFunc)(thread->arg);\n \n-        /*\n-         * The following two assertions are meant for NT asynch io.\n-         *\n-         * The thread should have no asynch io in progress when it\n-         * exits, otherwise the overlapped buffer, which is part of\n-         * the thread structure, would become invalid.\n-         */\n-        PR_ASSERT(thread->io_pending == PR_FALSE);\n-        /*\n-         * This assertion enforces the programming guideline that\n-         * if an io function times out or is interrupted, the thread\n-         * should close the fd to force the asynch io to abort\n-         * before it exits.  Right now, closing the fd is the only\n-         * way to clear the io_suspended flag.\n-         */\n-        PR_ASSERT(thread->io_suspended == PR_FALSE);\n-\n-        PR_Lock(_pr_activeLock);\n-        /*\n-         * remove thread from list of active threads\n-         */\n-        if (!(thread->flags & _PR_IDLE_THREAD)) {\n-            PR_REMOVE_LINK(&thread->active);\n-            _pr_local_threads--;\n-        }\n-        PR_Unlock(_pr_activeLock);\n-        PR_LOG(_pr_thread_lm, PR_LOG_MIN, (\"thread exiting\"));\n+    /*\n+     * The following two assertions are meant for NT asynch io.\n+     *\n+     * The thread should have no asynch io in progress when it\n+     * exits, otherwise the overlapped buffer, which is part of\n+     * the thread structure, would become invalid.\n+     */\n+    PR_ASSERT(thread->io_pending == PR_FALSE);\n+    /*\n+     * This assertion enforces the programming guideline that\n+     * if an io function times out or is interrupted, the thread\n+     * should close the fd to force the asynch io to abort\n+     * before it exits.  Right now, closing the fd is the only\n+     * way to clear the io_suspended flag.\n+     */\n+    PR_ASSERT(thread->io_suspended == PR_FALSE);\n \n-        /* All done, time to go away */\n-        _PR_CleanupThread(thread);\n+    PR_Lock(_pr_activeLock);\n+    /*\n+     * remove thread from list of active threads\n+     */\n+    if (!(thread->flags & _PR_IDLE_THREAD)) {\n+      PR_REMOVE_LINK(&thread->active);\n+      _pr_local_threads--;\n+    }\n+    PR_Unlock(_pr_activeLock);\n+    PR_LOG(_pr_thread_lm, PR_LOG_MIN, (\"thread exiting\"));\n \n-        _PR_INTSOFF(is);\n+    /* All done, time to go away */\n+    _PR_CleanupThread(thread);\n \n-        _PR_NotifyJoinWaiters(thread);\n+    _PR_INTSOFF(is);\n \n-        _PR_DecrActiveThreadCount(thread);\n+    _PR_NotifyJoinWaiters(thread);\n \n-        thread->state = _PR_DEAD_STATE;\n+    _PR_DecrActiveThreadCount(thread);\n \n-        if (!_pr_recycleThreads || (_PR_RecycleThread(thread) == PR_FAILURE)) {\n-            /*\n-            ** Destroy the thread resources\n-            */\n-            _PR_UserDestroyThread(thread);\n-        }\n+    thread->state = _PR_DEAD_STATE;\n \n-        /*\n-        ** Find another user thread to run. This cpu has finished the\n-        ** previous threads main and is now ready to run another thread.\n-        */\n-        {\n-            PRInt32 is;\n-            _PR_INTSOFF(is);\n-            _PR_MD_SWITCH_CONTEXT(thread);\n-        }\n+    if (!_pr_recycleThreads || (_PR_RecycleThread(thread) == PR_FAILURE)) {\n+      /*\n+      ** Destroy the thread resources\n+      */\n+      _PR_UserDestroyThread(thread);\n+    }\n \n-        /* Will land here when we get scheduled again if we are recycling... */\n+    /*\n+    ** Find another user thread to run. This cpu has finished the\n+    ** previous threads main and is now ready to run another thread.\n+    */\n+    {\n+      PRInt32 is;\n+      _PR_INTSOFF(is);\n+      _PR_MD_SWITCH_CONTEXT(thread);\n     }\n+\n+    /* Will land here when we get scheduled again if we are recycling... */\n+  }\n }\n \n-void\n-_PR_SetThreadPriority(PRThread* thread, PRThreadPriority newPri)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRIntn is;\n+void _PR_SetThreadPriority(PRThread* thread, PRThreadPriority newPri) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRIntn is;\n \n-    if (_PR_IS_NATIVE_THREAD(thread)) {\n-        _PR_MD_SET_PRIORITY(&(thread->md), newPri);\n-        return;\n-    }\n+  if (_PR_IS_NATIVE_THREAD(thread)) {\n+    _PR_MD_SET_PRIORITY(&(thread->md), newPri);\n+    return;\n+  }\n \n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-    _PR_THREAD_LOCK(thread);\n-    if (newPri != thread->priority) {\n-        _PRCPU* cpu = thread->cpu;\n-\n-        switch (thread->state) {\n-            case _PR_RUNNING:\n-                /* Change my priority */\n-\n-                _PR_RUNQ_LOCK(cpu);\n-                thread->priority = newPri;\n-                if (_PR_RUNQREADYMASK(cpu) >> (newPri + 1)) {\n-                    if (!_PR_IS_NATIVE_THREAD(me)) {\n-                        _PR_SET_RESCHED_FLAG();\n-                    }\n-                }\n-                _PR_RUNQ_UNLOCK(cpu);\n-                break;\n-\n-            case _PR_RUNNABLE:\n-\n-                _PR_RUNQ_LOCK(cpu);\n-                /* Move to different runQ */\n-                _PR_DEL_RUNQ(thread);\n-                thread->priority = newPri;\n-                PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n-                _PR_ADD_RUNQ(thread, cpu, newPri);\n-                _PR_RUNQ_UNLOCK(cpu);\n-\n-                if (newPri > me->priority) {\n-                    if (!_PR_IS_NATIVE_THREAD(me)) {\n-                        _PR_SET_RESCHED_FLAG();\n-                    }\n-                }\n-\n-                break;\n-\n-            case _PR_LOCK_WAIT:\n-            case _PR_COND_WAIT:\n-            case _PR_IO_WAIT:\n-            case _PR_SUSPENDED:\n-\n-                thread->priority = newPri;\n-                break;\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+  _PR_THREAD_LOCK(thread);\n+  if (newPri != thread->priority) {\n+    _PRCPU* cpu = thread->cpu;\n+\n+    switch (thread->state) {\n+      case _PR_RUNNING:\n+        /* Change my priority */\n+\n+        _PR_RUNQ_LOCK(cpu);\n+        thread->priority = newPri;\n+        if (_PR_RUNQREADYMASK(cpu) >> (newPri + 1)) {\n+          if (!_PR_IS_NATIVE_THREAD(me)) {\n+            _PR_SET_RESCHED_FLAG();\n+          }\n         }\n-    }\n-    _PR_THREAD_UNLOCK(thread);\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n-    }\n-}\n+        _PR_RUNQ_UNLOCK(cpu);\n+        break;\n \n-/*\n-** Suspend the named thread and copy its gc registers into regBuf\n-*/\n-static void\n-_PR_Suspend(PRThread* thread)\n-{\n-    PRIntn is;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+      case _PR_RUNNABLE:\n \n-    PR_ASSERT(thread != me);\n-    PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread) || (!thread->cpu));\n+        _PR_RUNQ_LOCK(cpu);\n+        /* Move to different runQ */\n+        _PR_DEL_RUNQ(thread);\n+        thread->priority = newPri;\n+        PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n+        _PR_ADD_RUNQ(thread, cpu, newPri);\n+        _PR_RUNQ_UNLOCK(cpu);\n \n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-    _PR_THREAD_LOCK(thread);\n-    switch (thread->state) {\n-        case _PR_RUNNABLE:\n-            if (!_PR_IS_NATIVE_THREAD(thread)) {\n-                _PR_RUNQ_LOCK(thread->cpu);\n-                _PR_DEL_RUNQ(thread);\n-                _PR_RUNQ_UNLOCK(thread->cpu);\n-\n-                _PR_MISCQ_LOCK(thread->cpu);\n-                _PR_ADD_SUSPENDQ(thread, thread->cpu);\n-                _PR_MISCQ_UNLOCK(thread->cpu);\n-            } else {\n-                /*\n-                 * Only LOCAL threads are suspended by _PR_Suspend\n-                 */\n-                PR_ASSERT(0);\n-            }\n-            thread->state = _PR_SUSPENDED;\n-            break;\n+        if (newPri > me->priority) {\n+          if (!_PR_IS_NATIVE_THREAD(me)) {\n+            _PR_SET_RESCHED_FLAG();\n+          }\n+        }\n \n-        case _PR_RUNNING:\n-            /*\n-             * The thread being suspended should be a LOCAL thread with\n-             * _pr_numCPUs == 1. Hence, the thread cannot be in RUNNING state\n-             */\n-            PR_ASSERT(0);\n-            break;\n+        break;\n \n-        case _PR_LOCK_WAIT:\n-        case _PR_IO_WAIT:\n-        case _PR_COND_WAIT:\n-            if (_PR_IS_NATIVE_THREAD(thread)) {\n-                _PR_MD_SUSPEND_THREAD(thread);\n-            }\n-            thread->flags |= _PR_SUSPENDING;\n-            break;\n+      case _PR_LOCK_WAIT:\n+      case _PR_COND_WAIT:\n+      case _PR_IO_WAIT:\n+      case _PR_SUSPENDED:\n \n-        default:\n-            PR_Abort();\n-    }\n-    _PR_THREAD_UNLOCK(thread);\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n+        thread->priority = newPri;\n+        break;\n     }\n+  }\n+  _PR_THREAD_UNLOCK(thread);\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n }\n \n-static void\n-_PR_Resume(PRThread* thread)\n-{\n-    PRThreadPriority pri;\n-    PRIntn is;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+/*\n+** Suspend the named thread and copy its gc registers into regBuf\n+*/\n+static void _PR_Suspend(PRThread* thread) {\n+  PRIntn is;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  PR_ASSERT(thread != me);\n+  PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread) || (!thread->cpu));\n+\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+  _PR_THREAD_LOCK(thread);\n+  switch (thread->state) {\n+    case _PR_RUNNABLE:\n+      if (!_PR_IS_NATIVE_THREAD(thread)) {\n+        _PR_RUNQ_LOCK(thread->cpu);\n+        _PR_DEL_RUNQ(thread);\n+        _PR_RUNQ_UNLOCK(thread->cpu);\n \n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-    _PR_THREAD_LOCK(thread);\n-    switch (thread->state) {\n-        case _PR_SUSPENDED:\n-            thread->state = _PR_RUNNABLE;\n-            thread->flags &= ~_PR_SUSPENDING;\n-            if (!_PR_IS_NATIVE_THREAD(thread)) {\n-                _PR_MISCQ_LOCK(thread->cpu);\n-                _PR_DEL_SUSPENDQ(thread);\n-                _PR_MISCQ_UNLOCK(thread->cpu);\n-\n-                pri = thread->priority;\n-\n-                _PR_RUNQ_LOCK(thread->cpu);\n-                _PR_ADD_RUNQ(thread, thread->cpu, pri);\n-                _PR_RUNQ_UNLOCK(thread->cpu);\n-\n-                if (pri > _PR_MD_CURRENT_THREAD()->priority) {\n-                    if (!_PR_IS_NATIVE_THREAD(me)) {\n-                        _PR_SET_RESCHED_FLAG();\n-                    }\n-                }\n-            } else {\n-                PR_ASSERT(0);\n-            }\n-            break;\n+        _PR_MISCQ_LOCK(thread->cpu);\n+        _PR_ADD_SUSPENDQ(thread, thread->cpu);\n+        _PR_MISCQ_UNLOCK(thread->cpu);\n+      } else {\n+        /*\n+         * Only LOCAL threads are suspended by _PR_Suspend\n+         */\n+        PR_ASSERT(0);\n+      }\n+      thread->state = _PR_SUSPENDED;\n+      break;\n+\n+    case _PR_RUNNING:\n+      /*\n+       * The thread being suspended should be a LOCAL thread with\n+       * _pr_numCPUs == 1. Hence, the thread cannot be in RUNNING state\n+       */\n+      PR_ASSERT(0);\n+      break;\n+\n+    case _PR_LOCK_WAIT:\n+    case _PR_IO_WAIT:\n+    case _PR_COND_WAIT:\n+      if (_PR_IS_NATIVE_THREAD(thread)) {\n+        _PR_MD_SUSPEND_THREAD(thread);\n+      }\n+      thread->flags |= _PR_SUSPENDING;\n+      break;\n+\n+    default:\n+      PR_Abort();\n+  }\n+  _PR_THREAD_UNLOCK(thread);\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n+}\n \n-        case _PR_IO_WAIT:\n-        case _PR_COND_WAIT:\n-            thread->flags &= ~_PR_SUSPENDING;\n-            /*      PR_ASSERT(thread->wait.monitor->stickyCount == 0); */\n-            break;\n+static void _PR_Resume(PRThread* thread) {\n+  PRThreadPriority pri;\n+  PRIntn is;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+  _PR_THREAD_LOCK(thread);\n+  switch (thread->state) {\n+    case _PR_SUSPENDED:\n+      thread->state = _PR_RUNNABLE;\n+      thread->flags &= ~_PR_SUSPENDING;\n+      if (!_PR_IS_NATIVE_THREAD(thread)) {\n+        _PR_MISCQ_LOCK(thread->cpu);\n+        _PR_DEL_SUSPENDQ(thread);\n+        _PR_MISCQ_UNLOCK(thread->cpu);\n \n-        case _PR_LOCK_WAIT: {\n-            PRLock* wLock = thread->wait.lock;\n+        pri = thread->priority;\n \n-            thread->flags &= ~_PR_SUSPENDING;\n+        _PR_RUNQ_LOCK(thread->cpu);\n+        _PR_ADD_RUNQ(thread, thread->cpu, pri);\n+        _PR_RUNQ_UNLOCK(thread->cpu);\n \n-            _PR_LOCK_LOCK(wLock);\n-            if (thread->wait.lock->owner == 0) {\n-                _PR_UnblockLockWaiter(thread->wait.lock);\n-            }\n-            _PR_LOCK_UNLOCK(wLock);\n-            break;\n+        if (pri > _PR_MD_CURRENT_THREAD()->priority) {\n+          if (!_PR_IS_NATIVE_THREAD(me)) {\n+            _PR_SET_RESCHED_FLAG();\n+          }\n         }\n-        case _PR_RUNNABLE:\n-            break;\n-        case _PR_RUNNING:\n-            /*\n-             * The thread being suspended should be a LOCAL thread with\n-             * _pr_numCPUs == 1. Hence, the thread cannot be in RUNNING state\n-             */\n-            PR_ASSERT(0);\n-            break;\n-\n-        default:\n-            /*\n-             * thread should have been in one of the above-listed blocked states\n-             * (_PR_JOIN_WAIT, _PR_IO_WAIT, _PR_UNBORN, _PR_DEAD_STATE)\n-             */\n-            PR_Abort();\n-    }\n-    _PR_THREAD_UNLOCK(thread);\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n-    }\n+      } else {\n+        PR_ASSERT(0);\n+      }\n+      break;\n+\n+    case _PR_IO_WAIT:\n+    case _PR_COND_WAIT:\n+      thread->flags &= ~_PR_SUSPENDING;\n+      /*      PR_ASSERT(thread->wait.monitor->stickyCount == 0); */\n+      break;\n+\n+    case _PR_LOCK_WAIT: {\n+      PRLock* wLock = thread->wait.lock;\n+\n+      thread->flags &= ~_PR_SUSPENDING;\n+\n+      _PR_LOCK_LOCK(wLock);\n+      if (thread->wait.lock->owner == 0) {\n+        _PR_UnblockLockWaiter(thread->wait.lock);\n+      }\n+      _PR_LOCK_UNLOCK(wLock);\n+      break;\n+    }\n+    case _PR_RUNNABLE:\n+      break;\n+    case _PR_RUNNING:\n+      /*\n+       * The thread being suspended should be a LOCAL thread with\n+       * _pr_numCPUs == 1. Hence, the thread cannot be in RUNNING state\n+       */\n+      PR_ASSERT(0);\n+      break;\n+\n+    default:\n+      /*\n+       * thread should have been in one of the above-listed blocked states\n+       * (_PR_JOIN_WAIT, _PR_IO_WAIT, _PR_UNBORN, _PR_DEAD_STATE)\n+       */\n+      PR_Abort();\n+  }\n+  _PR_THREAD_UNLOCK(thread);\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n }\n \n #if !defined(_PR_LOCAL_THREADS_ONLY) && defined(XP_UNIX)\n-static PRThread*\n-get_thread(_PRCPU* cpu, PRBool* wakeup_cpus)\n-{\n-    PRThread* thread;\n-    PRIntn pri;\n-    PRUint32 r;\n-    PRCList* qp;\n-    PRIntn priMin, priMax;\n-\n-    _PR_RUNQ_LOCK(cpu);\n-    r = _PR_RUNQREADYMASK(cpu);\n-    if (r == 0) {\n-        priMin = priMax = PR_PRIORITY_FIRST;\n-    } else if (r == (1 << PR_PRIORITY_NORMAL)) {\n-        priMin = priMax = PR_PRIORITY_NORMAL;\n-    } else {\n-        priMin = PR_PRIORITY_FIRST;\n-        priMax = PR_PRIORITY_LAST;\n-    }\n-    thread = NULL;\n-    for (pri = priMax; pri >= priMin; pri--) {\n-        if (r & (1 << pri)) {\n-            for (qp = _PR_RUNQ(cpu)[pri].next; qp != &_PR_RUNQ(cpu)[pri];\n-                 qp = qp->next) {\n-                thread = _PR_THREAD_PTR(qp);\n-                /*\n-                 * skip non-schedulable threads\n-                 */\n-                PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n-                if (thread->no_sched) {\n-                    thread = NULL;\n-                    /*\n-                     * Need to wakeup cpus to avoid missing a\n-                     * runnable thread\n-                     * Waking up all CPU's need happen only once.\n-                     */\n-\n-                    *wakeup_cpus = PR_TRUE;\n-                    continue;\n-                } else if (thread->flags & _PR_BOUND_THREAD) {\n-                    /*\n-                     * Thread bound to cpu 0\n-                     */\n-\n-                    thread = NULL;\n-                    continue;\n-                } else if (thread->io_pending == PR_TRUE) {\n-                    /*\n-                     * A thread that is blocked for I/O needs to run\n-                     * on the same cpu on which it was blocked. This is because\n-                     * the cpu's ioq is accessed without lock protection and scheduling\n-                     * the thread on a different cpu would preclude this optimization.\n-                     */\n-                    thread = NULL;\n-                    continue;\n-                } else {\n-                    /* Pull thread off of its run queue */\n-                    _PR_DEL_RUNQ(thread);\n-                    _PR_RUNQ_UNLOCK(cpu);\n-                    return (thread);\n-                }\n-            }\n+static PRThread* get_thread(_PRCPU* cpu, PRBool* wakeup_cpus) {\n+  PRThread* thread;\n+  PRIntn pri;\n+  PRUint32 r;\n+  PRCList* qp;\n+  PRIntn priMin, priMax;\n+\n+  _PR_RUNQ_LOCK(cpu);\n+  r = _PR_RUNQREADYMASK(cpu);\n+  if (r == 0) {\n+    priMin = priMax = PR_PRIORITY_FIRST;\n+  } else if (r == (1 << PR_PRIORITY_NORMAL)) {\n+    priMin = priMax = PR_PRIORITY_NORMAL;\n+  } else {\n+    priMin = PR_PRIORITY_FIRST;\n+    priMax = PR_PRIORITY_LAST;\n+  }\n+  thread = NULL;\n+  for (pri = priMax; pri >= priMin; pri--) {\n+    if (r & (1 << pri)) {\n+      for (qp = _PR_RUNQ(cpu)[pri].next; qp != &_PR_RUNQ(cpu)[pri];\n+           qp = qp->next) {\n+        thread = _PR_THREAD_PTR(qp);\n+        /*\n+         * skip non-schedulable threads\n+         */\n+        PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n+        if (thread->no_sched) {\n+          thread = NULL;\n+          /*\n+           * Need to wakeup cpus to avoid missing a\n+           * runnable thread\n+           * Waking up all CPU's need happen only once.\n+           */\n+\n+          *wakeup_cpus = PR_TRUE;\n+          continue;\n+        } else if (thread->flags & _PR_BOUND_THREAD) {\n+          /*\n+           * Thread bound to cpu 0\n+           */\n+\n+          thread = NULL;\n+          continue;\n+        } else if (thread->io_pending == PR_TRUE) {\n+          /*\n+           * A thread that is blocked for I/O needs to run\n+           * on the same cpu on which it was blocked. This is because\n+           * the cpu's ioq is accessed without lock protection and scheduling\n+           * the thread on a different cpu would preclude this optimization.\n+           */\n+          thread = NULL;\n+          continue;\n+        } else {\n+          /* Pull thread off of its run queue */\n+          _PR_DEL_RUNQ(thread);\n+          _PR_RUNQ_UNLOCK(cpu);\n+          return (thread);\n         }\n-        thread = NULL;\n+      }\n     }\n-    _PR_RUNQ_UNLOCK(cpu);\n-    return (thread);\n+    thread = NULL;\n+  }\n+  _PR_RUNQ_UNLOCK(cpu);\n+  return (thread);\n }\n #endif /* !defined(_PR_LOCAL_THREADS_ONLY) && defined(XP_UNIX) */\n \n@@ -838,130 +807,128 @@ get_thread(_PRCPU* cpu, PRBool* wakeup_cpus)\n **       is initialization required for switching from SWITCH_CONTEXT,\n **       it will not get done!\n */\n-void\n-_PR_Schedule(void)\n-{\n-    PRThread *thread, *me = _PR_MD_CURRENT_THREAD();\n-    _PRCPU* cpu = _PR_MD_CURRENT_CPU();\n-    PRIntn pri;\n-    PRUint32 r;\n-    PRCList* qp;\n-    PRIntn priMin, priMax;\n+void _PR_Schedule(void) {\n+  PRThread *thread, *me = _PR_MD_CURRENT_THREAD();\n+  _PRCPU* cpu = _PR_MD_CURRENT_CPU();\n+  PRIntn pri;\n+  PRUint32 r;\n+  PRCList* qp;\n+  PRIntn priMin, priMax;\n #if !defined(_PR_LOCAL_THREADS_ONLY) && defined(XP_UNIX)\n-    PRBool wakeup_cpus;\n+  PRBool wakeup_cpus;\n #endif\n \n-    /* Interrupts must be disabled */\n-    PR_ASSERT(_PR_IS_NATIVE_THREAD(me) || _PR_MD_GET_INTSOFF() != 0);\n-\n-    /* Since we are rescheduling, we no longer want to */\n-    _PR_CLEAR_RESCHED_FLAG();\n-\n-    /*\n-    ** Find highest priority thread to run. Bigger priority numbers are\n-    ** higher priority threads\n-    */\n-    _PR_RUNQ_LOCK(cpu);\n-    /*\n-     *  if we are in SuspendAll mode, can schedule only the thread\n-     *    that called PR_SuspendAll\n-     *\n-     *  The thread may be ready to run now, after completing an I/O\n-     *  operation, for example\n-     */\n-    if ((thread = suspendAllThread) != 0) {\n-        if ((!(thread->no_sched)) && (thread->state == _PR_RUNNABLE)) {\n-            /* Pull thread off of its run queue */\n-            _PR_DEL_RUNQ(thread);\n-            _PR_RUNQ_UNLOCK(cpu);\n-            goto found_thread;\n+  /* Interrupts must be disabled */\n+  PR_ASSERT(_PR_IS_NATIVE_THREAD(me) || _PR_MD_GET_INTSOFF() != 0);\n+\n+  /* Since we are rescheduling, we no longer want to */\n+  _PR_CLEAR_RESCHED_FLAG();\n+\n+  /*\n+  ** Find highest priority thread to run. Bigger priority numbers are\n+  ** higher priority threads\n+  */\n+  _PR_RUNQ_LOCK(cpu);\n+  /*\n+   *  if we are in SuspendAll mode, can schedule only the thread\n+   *    that called PR_SuspendAll\n+   *\n+   *  The thread may be ready to run now, after completing an I/O\n+   *  operation, for example\n+   */\n+  if ((thread = suspendAllThread) != 0) {\n+    if ((!(thread->no_sched)) && (thread->state == _PR_RUNNABLE)) {\n+      /* Pull thread off of its run queue */\n+      _PR_DEL_RUNQ(thread);\n+      _PR_RUNQ_UNLOCK(cpu);\n+      goto found_thread;\n+    } else {\n+      thread = NULL;\n+      _PR_RUNQ_UNLOCK(cpu);\n+      goto idle_thread;\n+    }\n+  }\n+  r = _PR_RUNQREADYMASK(cpu);\n+  if (r == 0) {\n+    priMin = priMax = PR_PRIORITY_FIRST;\n+  } else if (r == (1 << PR_PRIORITY_NORMAL)) {\n+    priMin = priMax = PR_PRIORITY_NORMAL;\n+  } else {\n+    priMin = PR_PRIORITY_FIRST;\n+    priMax = PR_PRIORITY_LAST;\n+  }\n+  thread = NULL;\n+  for (pri = priMax; pri >= priMin; pri--) {\n+    if (r & (1 << pri)) {\n+      for (qp = _PR_RUNQ(cpu)[pri].next; qp != &_PR_RUNQ(cpu)[pri];\n+           qp = qp->next) {\n+        thread = _PR_THREAD_PTR(qp);\n+        /*\n+         * skip non-schedulable threads\n+         */\n+        PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n+        if ((thread->no_sched) && (me != thread)) {\n+          thread = NULL;\n+          continue;\n         } else {\n-            thread = NULL;\n-            _PR_RUNQ_UNLOCK(cpu);\n-            goto idle_thread;\n+          /* Pull thread off of its run queue */\n+          _PR_DEL_RUNQ(thread);\n+          _PR_RUNQ_UNLOCK(cpu);\n+          goto found_thread;\n         }\n-    }\n-    r = _PR_RUNQREADYMASK(cpu);\n-    if (r == 0) {\n-        priMin = priMax = PR_PRIORITY_FIRST;\n-    } else if (r == (1 << PR_PRIORITY_NORMAL)) {\n-        priMin = priMax = PR_PRIORITY_NORMAL;\n-    } else {\n-        priMin = PR_PRIORITY_FIRST;\n-        priMax = PR_PRIORITY_LAST;\n+      }\n     }\n     thread = NULL;\n-    for (pri = priMax; pri >= priMin; pri--) {\n-        if (r & (1 << pri)) {\n-            for (qp = _PR_RUNQ(cpu)[pri].next; qp != &_PR_RUNQ(cpu)[pri];\n-                 qp = qp->next) {\n-                thread = _PR_THREAD_PTR(qp);\n-                /*\n-                 * skip non-schedulable threads\n-                 */\n-                PR_ASSERT(!(thread->flags & _PR_IDLE_THREAD));\n-                if ((thread->no_sched) && (me != thread)) {\n-                    thread = NULL;\n-                    continue;\n-                } else {\n-                    /* Pull thread off of its run queue */\n-                    _PR_DEL_RUNQ(thread);\n-                    _PR_RUNQ_UNLOCK(cpu);\n-                    goto found_thread;\n-                }\n-            }\n-        }\n-        thread = NULL;\n-    }\n-    _PR_RUNQ_UNLOCK(cpu);\n+  }\n+  _PR_RUNQ_UNLOCK(cpu);\n \n #if !defined(_PR_LOCAL_THREADS_ONLY) && defined(XP_UNIX)\n \n-    wakeup_cpus = PR_FALSE;\n-    _PR_CPU_LIST_LOCK();\n-    for (qp = _PR_CPUQ().next; qp != &_PR_CPUQ(); qp = qp->next) {\n-        if (cpu != _PR_CPU_PTR(qp)) {\n-            if ((thread = get_thread(_PR_CPU_PTR(qp), &wakeup_cpus)) != NULL) {\n-                thread->cpu = cpu;\n-                _PR_CPU_LIST_UNLOCK();\n-                if (wakeup_cpus == PR_TRUE) {\n-                    _PR_MD_WAKEUP_CPUS();\n-                }\n-                goto found_thread;\n-            }\n+  wakeup_cpus = PR_FALSE;\n+  _PR_CPU_LIST_LOCK();\n+  for (qp = _PR_CPUQ().next; qp != &_PR_CPUQ(); qp = qp->next) {\n+    if (cpu != _PR_CPU_PTR(qp)) {\n+      if ((thread = get_thread(_PR_CPU_PTR(qp), &wakeup_cpus)) != NULL) {\n+        thread->cpu = cpu;\n+        _PR_CPU_LIST_UNLOCK();\n+        if (wakeup_cpus == PR_TRUE) {\n+          _PR_MD_WAKEUP_CPUS();\n         }\n+        goto found_thread;\n+      }\n     }\n-    _PR_CPU_LIST_UNLOCK();\n-    if (wakeup_cpus == PR_TRUE) {\n-        _PR_MD_WAKEUP_CPUS();\n-    }\n+  }\n+  _PR_CPU_LIST_UNLOCK();\n+  if (wakeup_cpus == PR_TRUE) {\n+    _PR_MD_WAKEUP_CPUS();\n+  }\n \n #endif /* _PR_LOCAL_THREADS_ONLY */\n \n idle_thread:\n-    /*\n-     ** There are no threads to run. Switch to the idle thread\n-     */\n-    PR_LOG(_pr_sched_lm, PR_LOG_MAX, (\"pausing\"));\n-    thread = _PR_MD_CURRENT_CPU()->idle_thread;\n+  /*\n+   ** There are no threads to run. Switch to the idle thread\n+   */\n+  PR_LOG(_pr_sched_lm, PR_LOG_MAX, (\"pausing\"));\n+  thread = _PR_MD_CURRENT_CPU()->idle_thread;\n \n found_thread:\n-    PR_ASSERT((me == thread) ||\n-              ((thread->state == _PR_RUNNABLE) && (!(thread->no_sched))));\n-\n-    /* Resume the thread */\n-    PR_LOG(_pr_sched_lm, PR_LOG_MAX, (\"switching to %d[%p]\", thread->id, thread));\n-    PR_ASSERT(thread->state != _PR_RUNNING);\n-    thread->state = _PR_RUNNING;\n-\n-    /* If we are on the runq, it just means that we went to sleep on some\n-     * resource, and by the time we got here another real native thread had\n-     * already given us the resource and put us back on the runqueue\n-     */\n-    PR_ASSERT(thread->cpu == _PR_MD_CURRENT_CPU());\n-    if (thread != me) {\n-        _PR_MD_RESTORE_CONTEXT(thread);\n-    }\n+  PR_ASSERT((me == thread) ||\n+            ((thread->state == _PR_RUNNABLE) && (!(thread->no_sched))));\n+\n+  /* Resume the thread */\n+  PR_LOG(_pr_sched_lm, PR_LOG_MAX, (\"switching to %d[%p]\", thread->id, thread));\n+  PR_ASSERT(thread->state != _PR_RUNNING);\n+  thread->state = _PR_RUNNING;\n+\n+  /* If we are on the runq, it just means that we went to sleep on some\n+   * resource, and by the time we got here another real native thread had\n+   * already given us the resource and put us back on the runqueue\n+   */\n+  PR_ASSERT(thread->cpu == _PR_MD_CURRENT_CPU());\n+  if (thread != me) {\n+    _PR_MD_RESTORE_CONTEXT(thread);\n+  }\n #if 0\n     /* XXXMB; with setjmp/longjmp it is impossible to land here, but\n      * it is not with fibers... Is this a bad thing?  I believe it is\n@@ -976,98 +943,95 @@ found_thread:\n ** Does not set the _PR_MD_CURRENT_THREAD.\n ** Does not specify the scope of the thread.\n */\n-static PRThread*\n-_PR_AttachThread(PRThreadType type, PRThreadPriority priority,\n-                 PRThreadStack* stack)\n-{\n-    PRThread* thread;\n-    char* mem;\n-\n-    if (priority > PR_PRIORITY_LAST) {\n-        priority = PR_PRIORITY_LAST;\n-    } else if (priority < PR_PRIORITY_FIRST) {\n-        priority = PR_PRIORITY_FIRST;\n+static PRThread* _PR_AttachThread(PRThreadType type, PRThreadPriority priority,\n+                                  PRThreadStack* stack) {\n+  PRThread* thread;\n+  char* mem;\n+\n+  if (priority > PR_PRIORITY_LAST) {\n+    priority = PR_PRIORITY_LAST;\n+  } else if (priority < PR_PRIORITY_FIRST) {\n+    priority = PR_PRIORITY_FIRST;\n+  }\n+\n+  mem = (char*)PR_CALLOC(sizeof(PRThread));\n+  if (mem) {\n+    thread = (PRThread*)mem;\n+    thread->priority = priority;\n+    thread->stack = stack;\n+    thread->state = _PR_RUNNING;\n+    PR_INIT_CLIST(&thread->lockList);\n+    if (_PR_MD_NEW_LOCK(&thread->threadLock) == PR_FAILURE) {\n+      PR_DELETE(thread);\n+      return 0;\n     }\n \n-    mem = (char*)PR_CALLOC(sizeof(PRThread));\n-    if (mem) {\n-        thread = (PRThread*)mem;\n-        thread->priority = priority;\n-        thread->stack = stack;\n-        thread->state = _PR_RUNNING;\n-        PR_INIT_CLIST(&thread->lockList);\n-        if (_PR_MD_NEW_LOCK(&thread->threadLock) == PR_FAILURE) {\n-            PR_DELETE(thread);\n-            return 0;\n-        }\n-\n-        return thread;\n-    }\n-    return 0;\n+    return thread;\n+  }\n+  return 0;\n }\n \n PR_IMPLEMENT(PRThread*)\n _PR_NativeCreateThread(PRThreadType type, void (*start)(void* arg), void* arg,\n                        PRThreadPriority priority, PRThreadScope scope,\n                        PRThreadState state, PRUint32 stackSize,\n-                       PRUint32 flags)\n-{\n-    PRThread* thread;\n-\n-    thread = _PR_AttachThread(type, priority, NULL);\n-\n-    if (thread) {\n-        PR_Lock(_pr_activeLock);\n-        thread->flags = (flags | _PR_GLOBAL_SCOPE);\n-        thread->id = ++_pr_utid;\n-        if (type == PR_SYSTEM_THREAD) {\n-            thread->flags |= _PR_SYSTEM;\n-            _pr_systemActive++;\n-        } else {\n-            _pr_userActive++;\n-        }\n-        PR_Unlock(_pr_activeLock);\n+                       PRUint32 flags) {\n+  PRThread* thread;\n \n-        thread->stack = PR_NEWZAP(PRThreadStack);\n-        if (!thread->stack) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            goto done;\n-        }\n-        thread->stack->stackSize = stackSize ? stackSize : _MD_DEFAULT_STACK_SIZE;\n-        thread->stack->thr = thread;\n-        thread->startFunc = start;\n-        thread->arg = arg;\n+  thread = _PR_AttachThread(type, priority, NULL);\n \n-        /*\n-          Set thread flags related to scope and joinable state. If joinable\n-          thread, allocate a \"termination\" conidition variable.\n-         */\n-        if (state == PR_JOINABLE_THREAD) {\n-            thread->term = PR_NewCondVar(_pr_terminationCVLock);\n-            if (thread->term == NULL) {\n-                PR_DELETE(thread->stack);\n-                goto done;\n-            }\n-        }\n+  if (thread) {\n+    PR_Lock(_pr_activeLock);\n+    thread->flags = (flags | _PR_GLOBAL_SCOPE);\n+    thread->id = ++_pr_utid;\n+    if (type == PR_SYSTEM_THREAD) {\n+      thread->flags |= _PR_SYSTEM;\n+      _pr_systemActive++;\n+    } else {\n+      _pr_userActive++;\n+    }\n+    PR_Unlock(_pr_activeLock);\n \n-        thread->state = _PR_RUNNING;\n-        if (_PR_MD_CREATE_THREAD(thread, _PR_NativeRunThread, priority, scope,\n-                                 state, stackSize) == PR_SUCCESS) {\n-            return thread;\n-        }\n-        if (thread->term) {\n-            PR_DestroyCondVar(thread->term);\n-            thread->term = NULL;\n-        }\n+    thread->stack = PR_NEWZAP(PRThreadStack);\n+    if (!thread->stack) {\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      goto done;\n+    }\n+    thread->stack->stackSize = stackSize ? stackSize : _MD_DEFAULT_STACK_SIZE;\n+    thread->stack->thr = thread;\n+    thread->startFunc = start;\n+    thread->arg = arg;\n+\n+    /*\n+      Set thread flags related to scope and joinable state. If joinable\n+      thread, allocate a \"termination\" conidition variable.\n+     */\n+    if (state == PR_JOINABLE_THREAD) {\n+      thread->term = PR_NewCondVar(_pr_terminationCVLock);\n+      if (thread->term == NULL) {\n         PR_DELETE(thread->stack);\n+        goto done;\n+      }\n     }\n \n-done:\n-    if (thread) {\n-        _PR_DecrActiveThreadCount(thread);\n-        _PR_DestroyThread(thread);\n+    thread->state = _PR_RUNNING;\n+    if (_PR_MD_CREATE_THREAD(thread, _PR_NativeRunThread, priority, scope,\n+                             state, stackSize) == PR_SUCCESS) {\n+      return thread;\n     }\n-    return NULL;\n+    if (thread->term) {\n+      PR_DestroyCondVar(thread->term);\n+      thread->term = NULL;\n+    }\n+    PR_DELETE(thread->stack);\n+  }\n+\n+done:\n+  if (thread) {\n+    _PR_DecrActiveThreadCount(thread);\n+    _PR_DestroyThread(thread);\n+  }\n+  return NULL;\n }\n \n /************************************************************************/\n@@ -1075,314 +1039,312 @@ done:\n PR_IMPLEMENT(PRThread*)\n _PR_CreateThread(PRThreadType type, void (*start)(void* arg), void* arg,\n                  PRThreadPriority priority, PRThreadScope scope,\n-                 PRThreadState state, PRUint32 stackSize, PRUint32 flags)\n-{\n-    PRThread* me;\n-    PRThread* thread = NULL;\n-    PRThreadStack* stack;\n-    char* top;\n-    PRIntn is;\n-    PRIntn native = 0;\n-    PRIntn useRecycled = 0;\n-    PRBool status;\n+                 PRThreadState state, PRUint32 stackSize, PRUint32 flags) {\n+  PRThread* me;\n+  PRThread* thread = NULL;\n+  PRThreadStack* stack;\n+  char* top;\n+  PRIntn is;\n+  PRIntn native = 0;\n+  PRIntn useRecycled = 0;\n+  PRBool status;\n+\n+  /*\n+  First, pin down the priority.  Not all compilers catch passing out of\n+  range enum here.  If we let bad values thru, priority queues won't work.\n+  */\n+  if (priority > PR_PRIORITY_LAST) {\n+    priority = PR_PRIORITY_LAST;\n+  } else if (priority < PR_PRIORITY_FIRST) {\n+    priority = PR_PRIORITY_FIRST;\n+  }\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  if (!(flags & _PR_IDLE_THREAD)) {\n+    me = _PR_MD_CURRENT_THREAD();\n+  }\n \n-    /*\n-    First, pin down the priority.  Not all compilers catch passing out of\n-    range enum here.  If we let bad values thru, priority queues won't work.\n-    */\n-    if (priority > PR_PRIORITY_LAST) {\n-        priority = PR_PRIORITY_LAST;\n-    } else if (priority < PR_PRIORITY_FIRST) {\n-        priority = PR_PRIORITY_FIRST;\n-    }\n+#if defined(_PR_GLOBAL_THREADS_ONLY)\n+  /*\n+   * can create global threads only\n+   */\n+  if (scope == PR_LOCAL_THREAD) {\n+    scope = PR_GLOBAL_THREAD;\n+  }\n+#endif\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (_native_threads_only) {\n+    scope = PR_GLOBAL_THREAD;\n+  }\n \n-    if (!(flags & _PR_IDLE_THREAD)) {\n-        me = _PR_MD_CURRENT_THREAD();\n-    }\n+  native =\n+      (((scope == PR_GLOBAL_THREAD) || (scope == PR_GLOBAL_BOUND_THREAD)) &&\n+       _PR_IS_NATIVE_THREAD_SUPPORTED());\n \n-#if defined(_PR_GLOBAL_THREADS_ONLY)\n+  _PR_ADJUST_STACKSIZE(stackSize);\n+\n+  if (native) {\n     /*\n-     * can create global threads only\n+     * clear the IDLE_THREAD flag which applies to LOCAL\n+     * threads only\n      */\n-    if (scope == PR_LOCAL_THREAD) {\n-        scope = PR_GLOBAL_THREAD;\n-    }\n-#endif\n+    flags &= ~_PR_IDLE_THREAD;\n+    flags |= _PR_GLOBAL_SCOPE;\n+    if (_PR_NUM_DEADNATIVE > 0) {\n+      _PR_DEADQ_LOCK;\n \n-    if (_native_threads_only) {\n-        scope = PR_GLOBAL_THREAD;\n-    }\n+      if (_PR_NUM_DEADNATIVE == 0) { /* Thread safe check */\n+        _PR_DEADQ_UNLOCK;\n+      } else {\n+        thread = _PR_THREAD_PTR(_PR_DEADNATIVEQ.next);\n+        PR_REMOVE_LINK(&thread->links);\n+        _PR_DEC_DEADNATIVE;\n+        _PR_DEADQ_UNLOCK;\n+\n+        _PR_InitializeRecycledThread(thread);\n+        thread->startFunc = start;\n+        thread->arg = arg;\n+        thread->flags = (flags | _PR_GLOBAL_SCOPE);\n+        if (type == PR_SYSTEM_THREAD) {\n+          thread->flags |= _PR_SYSTEM;\n+          PR_ATOMIC_INCREMENT(&_pr_systemActive);\n+        } else {\n+          PR_ATOMIC_INCREMENT(&_pr_userActive);\n+        }\n \n-    native =\n-        (((scope == PR_GLOBAL_THREAD) || (scope == PR_GLOBAL_BOUND_THREAD)) &&\n-         _PR_IS_NATIVE_THREAD_SUPPORTED());\n+        if (state == PR_JOINABLE_THREAD) {\n+          if (!thread->term) {\n+            thread->term = PR_NewCondVar(_pr_terminationCVLock);\n+          }\n+        } else {\n+          if (thread->term) {\n+            PR_DestroyCondVar(thread->term);\n+            thread->term = 0;\n+          }\n+        }\n \n-    _PR_ADJUST_STACKSIZE(stackSize);\n+        thread->priority = priority;\n+        _PR_MD_SET_PRIORITY(&(thread->md), priority);\n+        /* XXX what about stackSize? */\n+        thread->state = _PR_RUNNING;\n+        _PR_MD_WAKEUP_WAITER(thread);\n+        return thread;\n+      }\n+    }\n+    thread = _PR_NativeCreateThread(type, start, arg, priority, scope, state,\n+                                    stackSize, flags);\n+  } else {\n+    if (_PR_NUM_DEADUSER > 0) {\n+      _PR_DEADQ_LOCK;\n \n-    if (native) {\n-        /*\n-         * clear the IDLE_THREAD flag which applies to LOCAL\n-         * threads only\n+      if (_PR_NUM_DEADUSER == 0) { /* thread safe check */\n+        _PR_DEADQ_UNLOCK;\n+      } else {\n+        PRCList* ptr;\n+\n+        /* Go down list checking for a recycled thread with a\n+         * large enough stack.  XXXMB - this has a bad degenerate case.\n          */\n-        flags &= ~_PR_IDLE_THREAD;\n-        flags |= _PR_GLOBAL_SCOPE;\n-        if (_PR_NUM_DEADNATIVE > 0) {\n-            _PR_DEADQ_LOCK;\n-\n-            if (_PR_NUM_DEADNATIVE == 0) { /* Thread safe check */\n-                _PR_DEADQ_UNLOCK;\n-            } else {\n-                thread = _PR_THREAD_PTR(_PR_DEADNATIVEQ.next);\n-                PR_REMOVE_LINK(&thread->links);\n-                _PR_DEC_DEADNATIVE;\n-                _PR_DEADQ_UNLOCK;\n-\n-                _PR_InitializeRecycledThread(thread);\n-                thread->startFunc = start;\n-                thread->arg = arg;\n-                thread->flags = (flags | _PR_GLOBAL_SCOPE);\n-                if (type == PR_SYSTEM_THREAD) {\n-                    thread->flags |= _PR_SYSTEM;\n-                    PR_ATOMIC_INCREMENT(&_pr_systemActive);\n-                } else {\n-                    PR_ATOMIC_INCREMENT(&_pr_userActive);\n-                }\n-\n-                if (state == PR_JOINABLE_THREAD) {\n-                    if (!thread->term) {\n-                        thread->term = PR_NewCondVar(_pr_terminationCVLock);\n-                    }\n-                } else {\n-                    if (thread->term) {\n-                        PR_DestroyCondVar(thread->term);\n-                        thread->term = 0;\n-                    }\n-                }\n-\n-                thread->priority = priority;\n-                _PR_MD_SET_PRIORITY(&(thread->md), priority);\n-                /* XXX what about stackSize? */\n-                thread->state = _PR_RUNNING;\n-                _PR_MD_WAKEUP_WAITER(thread);\n-                return thread;\n-            }\n-        }\n-        thread = _PR_NativeCreateThread(type, start, arg, priority, scope, state,\n-                                        stackSize, flags);\n-    } else {\n-        if (_PR_NUM_DEADUSER > 0) {\n-            _PR_DEADQ_LOCK;\n-\n-            if (_PR_NUM_DEADUSER == 0) { /* thread safe check */\n-                _PR_DEADQ_UNLOCK;\n-            } else {\n-                PRCList* ptr;\n-\n-                /* Go down list checking for a recycled thread with a\n-                 * large enough stack.  XXXMB - this has a bad degenerate case.\n-                 */\n-                ptr = _PR_DEADUSERQ.next;\n-                while (ptr != &_PR_DEADUSERQ) {\n-                    thread = _PR_THREAD_PTR(ptr);\n-                    if ((thread->stack->stackSize >= stackSize) && (!thread->no_sched)) {\n-                        PR_REMOVE_LINK(&thread->links);\n-                        _PR_DEC_DEADUSER;\n-                        break;\n-                    } else {\n-                        ptr = ptr->next;\n-                        thread = NULL;\n-                    }\n-                }\n-\n-                _PR_DEADQ_UNLOCK;\n-\n-                if (thread) {\n-                    _PR_InitializeRecycledThread(thread);\n-                    thread->startFunc = start;\n-                    thread->arg = arg;\n-                    thread->priority = priority;\n-                    if (state == PR_JOINABLE_THREAD) {\n-                        if (!thread->term) {\n-                            thread->term = PR_NewCondVar(_pr_terminationCVLock);\n-                        }\n-                    } else {\n-                        if (thread->term) {\n-                            PR_DestroyCondVar(thread->term);\n-                            thread->term = 0;\n-                        }\n-                    }\n-                    useRecycled++;\n-                }\n-            }\n+        ptr = _PR_DEADUSERQ.next;\n+        while (ptr != &_PR_DEADUSERQ) {\n+          thread = _PR_THREAD_PTR(ptr);\n+          if ((thread->stack->stackSize >= stackSize) && (!thread->no_sched)) {\n+            PR_REMOVE_LINK(&thread->links);\n+            _PR_DEC_DEADUSER;\n+            break;\n+          } else {\n+            ptr = ptr->next;\n+            thread = NULL;\n+          }\n         }\n-        if (thread == NULL) {\n-#ifndef HAVE_CUSTOM_USER_THREADS\n-            stack = _PR_NewStack(stackSize);\n-            if (!stack) {\n-                PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-                return NULL;\n-            }\n \n-            /* Allocate thread object and per-thread data off the top of the stack*/\n-            top = stack->stackTop;\n-#ifdef HAVE_STACK_GROWING_UP\n-            thread = (PRThread*)top;\n-            top = top + sizeof(PRThread);\n-            /*\n-             * Make stack 64-byte aligned\n-             */\n-            if ((PRUptrdiff)top & 0x3f) {\n-                top = (char*)(((PRUptrdiff)top + 0x40) & ~0x3f);\n+        _PR_DEADQ_UNLOCK;\n+\n+        if (thread) {\n+          _PR_InitializeRecycledThread(thread);\n+          thread->startFunc = start;\n+          thread->arg = arg;\n+          thread->priority = priority;\n+          if (state == PR_JOINABLE_THREAD) {\n+            if (!thread->term) {\n+              thread->term = PR_NewCondVar(_pr_terminationCVLock);\n             }\n-#else\n-            top = top - sizeof(PRThread);\n-            thread = (PRThread*)top;\n-            /*\n-             * Make stack 64-byte aligned\n-             */\n-            if ((PRUptrdiff)top & 0x3f) {\n-                top = (char*)((PRUptrdiff)top & ~0x3f);\n+          } else {\n+            if (thread->term) {\n+              PR_DestroyCondVar(thread->term);\n+              thread->term = 0;\n             }\n-#endif\n-            stack->thr = thread;\n-            memset(thread, 0, sizeof(PRThread));\n-            thread->threadAllocatedOnStack = 1;\n+          }\n+          useRecycled++;\n+        }\n+      }\n+    }\n+    if (thread == NULL) {\n+#ifndef HAVE_CUSTOM_USER_THREADS\n+      stack = _PR_NewStack(stackSize);\n+      if (!stack) {\n+        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+        return NULL;\n+      }\n+\n+      /* Allocate thread object and per-thread data off the top of the stack*/\n+      top = stack->stackTop;\n+#  ifdef HAVE_STACK_GROWING_UP\n+      thread = (PRThread*)top;\n+      top = top + sizeof(PRThread);\n+      /*\n+       * Make stack 64-byte aligned\n+       */\n+      if ((PRUptrdiff)top & 0x3f) {\n+        top = (char*)(((PRUptrdiff)top + 0x40) & ~0x3f);\n+      }\n+#  else\n+      top = top - sizeof(PRThread);\n+      thread = (PRThread*)top;\n+      /*\n+       * Make stack 64-byte aligned\n+       */\n+      if ((PRUptrdiff)top & 0x3f) {\n+        top = (char*)((PRUptrdiff)top & ~0x3f);\n+      }\n+#  endif\n+      stack->thr = thread;\n+      memset(thread, 0, sizeof(PRThread));\n+      thread->threadAllocatedOnStack = 1;\n #else\n-            thread = _PR_MD_CREATE_USER_THREAD(stackSize, start, arg);\n-            if (!thread) {\n-                PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-                return NULL;\n-            }\n-            thread->threadAllocatedOnStack = 0;\n-            stack = NULL;\n-            top = NULL;\n+      thread = _PR_MD_CREATE_USER_THREAD(stackSize, start, arg);\n+      if (!thread) {\n+        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+        return NULL;\n+      }\n+      thread->threadAllocatedOnStack = 0;\n+      stack = NULL;\n+      top = NULL;\n #endif\n \n-            /* Initialize thread */\n-            thread->tpdLength = 0;\n-            thread->privateData = NULL;\n-            thread->stack = stack;\n-            thread->priority = priority;\n-            thread->startFunc = start;\n-            thread->arg = arg;\n-            PR_INIT_CLIST(&thread->lockList);\n-\n-            if (_PR_MD_INIT_THREAD(thread) == PR_FAILURE) {\n-                if (thread->threadAllocatedOnStack == 1) {\n-                    _PR_FreeStack(thread->stack);\n-                } else {\n-                    PR_DELETE(thread);\n-                }\n-                PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n-                return NULL;\n-            }\n-\n-            if (_PR_MD_NEW_LOCK(&thread->threadLock) == PR_FAILURE) {\n-                if (thread->threadAllocatedOnStack == 1) {\n-                    _PR_FreeStack(thread->stack);\n-                } else {\n-                    PR_DELETE(thread->privateData);\n-                    PR_DELETE(thread);\n-                }\n-                PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n-                return NULL;\n-            }\n-\n-            _PR_MD_INIT_CONTEXT(thread, top, _PR_UserRunThread, &status);\n-\n-            if (status == PR_FALSE) {\n-                _PR_MD_FREE_LOCK(&thread->threadLock);\n-                if (thread->threadAllocatedOnStack == 1) {\n-                    _PR_FreeStack(thread->stack);\n-                } else {\n-                    PR_DELETE(thread->privateData);\n-                    PR_DELETE(thread);\n-                }\n-                return NULL;\n-            }\n-\n-            /*\n-              Set thread flags related to scope and joinable state. If joinable\n-              thread, allocate a \"termination\" condition variable.\n-            */\n-            if (state == PR_JOINABLE_THREAD) {\n-                thread->term = PR_NewCondVar(_pr_terminationCVLock);\n-                if (thread->term == NULL) {\n-                    _PR_MD_FREE_LOCK(&thread->threadLock);\n-                    if (thread->threadAllocatedOnStack == 1) {\n-                        _PR_FreeStack(thread->stack);\n-                    } else {\n-                        PR_DELETE(thread->privateData);\n-                        PR_DELETE(thread);\n-                    }\n-                    return NULL;\n-                }\n-            }\n+      /* Initialize thread */\n+      thread->tpdLength = 0;\n+      thread->privateData = NULL;\n+      thread->stack = stack;\n+      thread->priority = priority;\n+      thread->startFunc = start;\n+      thread->arg = arg;\n+      PR_INIT_CLIST(&thread->lockList);\n+\n+      if (_PR_MD_INIT_THREAD(thread) == PR_FAILURE) {\n+        if (thread->threadAllocatedOnStack == 1) {\n+          _PR_FreeStack(thread->stack);\n+        } else {\n+          PR_DELETE(thread);\n         }\n+        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n+        return NULL;\n+      }\n \n-        /* Update thread type counter */\n-        PR_Lock(_pr_activeLock);\n-        thread->flags = flags;\n-        thread->id = ++_pr_utid;\n-        if (type == PR_SYSTEM_THREAD) {\n-            thread->flags |= _PR_SYSTEM;\n-            _pr_systemActive++;\n+      if (_PR_MD_NEW_LOCK(&thread->threadLock) == PR_FAILURE) {\n+        if (thread->threadAllocatedOnStack == 1) {\n+          _PR_FreeStack(thread->stack);\n         } else {\n-            _pr_userActive++;\n+          PR_DELETE(thread->privateData);\n+          PR_DELETE(thread);\n         }\n+        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);\n+        return NULL;\n+      }\n \n-        /* Make thread runnable */\n-        thread->state = _PR_RUNNABLE;\n-        /*\n-         * Add to list of active threads\n-         */\n-        PR_Unlock(_pr_activeLock);\n+      _PR_MD_INIT_CONTEXT(thread, top, _PR_UserRunThread, &status);\n \n-        if ((!(thread->flags & _PR_IDLE_THREAD)) && _PR_IS_NATIVE_THREAD(me)) {\n-            thread->cpu = _PR_GetPrimordialCPU();\n+      if (status == PR_FALSE) {\n+        _PR_MD_FREE_LOCK(&thread->threadLock);\n+        if (thread->threadAllocatedOnStack == 1) {\n+          _PR_FreeStack(thread->stack);\n         } else {\n-            thread->cpu = _PR_MD_CURRENT_CPU();\n+          PR_DELETE(thread->privateData);\n+          PR_DELETE(thread);\n+        }\n+        return NULL;\n+      }\n+\n+      /*\n+        Set thread flags related to scope and joinable state. If joinable\n+        thread, allocate a \"termination\" condition variable.\n+      */\n+      if (state == PR_JOINABLE_THREAD) {\n+        thread->term = PR_NewCondVar(_pr_terminationCVLock);\n+        if (thread->term == NULL) {\n+          _PR_MD_FREE_LOCK(&thread->threadLock);\n+          if (thread->threadAllocatedOnStack == 1) {\n+            _PR_FreeStack(thread->stack);\n+          } else {\n+            PR_DELETE(thread->privateData);\n+            PR_DELETE(thread);\n+          }\n+          return NULL;\n         }\n+      }\n+    }\n \n-        PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread));\n+    /* Update thread type counter */\n+    PR_Lock(_pr_activeLock);\n+    thread->flags = flags;\n+    thread->id = ++_pr_utid;\n+    if (type == PR_SYSTEM_THREAD) {\n+      thread->flags |= _PR_SYSTEM;\n+      _pr_systemActive++;\n+    } else {\n+      _pr_userActive++;\n+    }\n \n-        if ((!(thread->flags & _PR_IDLE_THREAD)) && !_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_INTSOFF(is);\n-            _PR_RUNQ_LOCK(thread->cpu);\n-            _PR_ADD_RUNQ(thread, thread->cpu, priority);\n-            _PR_RUNQ_UNLOCK(thread->cpu);\n-        }\n+    /* Make thread runnable */\n+    thread->state = _PR_RUNNABLE;\n+    /*\n+     * Add to list of active threads\n+     */\n+    PR_Unlock(_pr_activeLock);\n \n-        if (thread->flags & _PR_IDLE_THREAD) {\n-            /*\n-            ** If the creating thread is a kernel thread, we need to\n-            ** awaken the user thread idle thread somehow; potentially\n-            ** it could be sleeping in its idle loop, and we need to poke\n-            ** it.  To do so, wake the idle thread...\n-            */\n-            _PR_MD_WAKEUP_WAITER(NULL);\n-        } else if (_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_MD_WAKEUP_WAITER(thread);\n-        }\n-        if ((!(thread->flags & _PR_IDLE_THREAD)) && !_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_INTSON(is);\n-        }\n+    if ((!(thread->flags & _PR_IDLE_THREAD)) && _PR_IS_NATIVE_THREAD(me)) {\n+      thread->cpu = _PR_GetPrimordialCPU();\n+    } else {\n+      thread->cpu = _PR_MD_CURRENT_CPU();\n     }\n \n-    return thread;\n+    PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread));\n+\n+    if ((!(thread->flags & _PR_IDLE_THREAD)) && !_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_INTSOFF(is);\n+      _PR_RUNQ_LOCK(thread->cpu);\n+      _PR_ADD_RUNQ(thread, thread->cpu, priority);\n+      _PR_RUNQ_UNLOCK(thread->cpu);\n+    }\n+\n+    if (thread->flags & _PR_IDLE_THREAD) {\n+      /*\n+      ** If the creating thread is a kernel thread, we need to\n+      ** awaken the user thread idle thread somehow; potentially\n+      ** it could be sleeping in its idle loop, and we need to poke\n+      ** it.  To do so, wake the idle thread...\n+      */\n+      _PR_MD_WAKEUP_WAITER(NULL);\n+    } else if (_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_MD_WAKEUP_WAITER(thread);\n+    }\n+    if ((!(thread->flags & _PR_IDLE_THREAD)) && !_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_INTSON(is);\n+    }\n+  }\n+\n+  return thread;\n }\n \n PR_IMPLEMENT(PRThread*)\n PR_CreateThread(PRThreadType type, void (*start)(void* arg), void* arg,\n                 PRThreadPriority priority, PRThreadScope scope,\n-                PRThreadState state, PRUint32 stackSize)\n-{\n-    return _PR_CreateThread(type, start, arg, priority, scope, state, stackSize,\n-                            0);\n+                PRThreadState state, PRUint32 stackSize) {\n+  return _PR_CreateThread(type, start, arg, priority, scope, state, stackSize,\n+                          0);\n }\n \n /*\n@@ -1397,114 +1359,107 @@ PR_CreateThread(PRThreadType type, void (*start)(void* arg), void* arg,\n ** This call is not normally needed unless you create your own native\n ** thread. PR_Init does this automatically for the primordial thread.\n */\n-PRThread*\n-_PRI_AttachThread(PRThreadType type, PRThreadPriority priority,\n-                  PRThreadStack* stack, PRUint32 flags)\n-{\n-    PRThread* thread;\n+PRThread* _PRI_AttachThread(PRThreadType type, PRThreadPriority priority,\n+                            PRThreadStack* stack, PRUint32 flags) {\n+  PRThread* thread;\n \n-    if ((thread = _PR_MD_GET_ATTACHED_THREAD()) != NULL) {\n-        return thread;\n-    }\n-    _PR_MD_SET_CURRENT_THREAD(NULL);\n+  if ((thread = _PR_MD_GET_ATTACHED_THREAD()) != NULL) {\n+    return thread;\n+  }\n+  _PR_MD_SET_CURRENT_THREAD(NULL);\n \n-    /* Clear out any state if this thread was attached before */\n-    _PR_MD_SET_CURRENT_CPU(NULL);\n+  /* Clear out any state if this thread was attached before */\n+  _PR_MD_SET_CURRENT_CPU(NULL);\n \n-    thread = _PR_AttachThread(type, priority, stack);\n-    if (thread) {\n-        PRIntn is;\n+  thread = _PR_AttachThread(type, priority, stack);\n+  if (thread) {\n+    PRIntn is;\n \n-        _PR_MD_SET_CURRENT_THREAD(thread);\n+    _PR_MD_SET_CURRENT_THREAD(thread);\n \n-        thread->flags = flags | _PR_GLOBAL_SCOPE | _PR_ATTACHED;\n+    thread->flags = flags | _PR_GLOBAL_SCOPE | _PR_ATTACHED;\n \n-        if (!stack) {\n-            thread->stack = PR_NEWZAP(PRThreadStack);\n-            if (!thread->stack) {\n-                _PR_DestroyThread(thread);\n-                return NULL;\n-            }\n-            thread->stack->stackSize = _MD_DEFAULT_STACK_SIZE;\n-        }\n-        PR_INIT_CLIST(&thread->links);\n+    if (!stack) {\n+      thread->stack = PR_NEWZAP(PRThreadStack);\n+      if (!thread->stack) {\n+        _PR_DestroyThread(thread);\n+        return NULL;\n+      }\n+      thread->stack->stackSize = _MD_DEFAULT_STACK_SIZE;\n+    }\n+    PR_INIT_CLIST(&thread->links);\n \n-        if (_PR_MD_INIT_ATTACHED_THREAD(thread) == PR_FAILURE) {\n-            PR_DELETE(thread->stack);\n-            _PR_DestroyThread(thread);\n-            return NULL;\n-        }\n+    if (_PR_MD_INIT_ATTACHED_THREAD(thread) == PR_FAILURE) {\n+      PR_DELETE(thread->stack);\n+      _PR_DestroyThread(thread);\n+      return NULL;\n+    }\n \n-        _PR_MD_SET_CURRENT_CPU(NULL);\n+    _PR_MD_SET_CURRENT_CPU(NULL);\n \n-        if (_PR_MD_CURRENT_CPU()) {\n-            _PR_INTSOFF(is);\n-            PR_Lock(_pr_activeLock);\n-        }\n-        if (type == PR_SYSTEM_THREAD) {\n-            thread->flags |= _PR_SYSTEM;\n-            _pr_systemActive++;\n-        } else {\n-            _pr_userActive++;\n-        }\n-        if (_PR_MD_CURRENT_CPU()) {\n-            PR_Unlock(_pr_activeLock);\n-            _PR_INTSON(is);\n-        }\n+    if (_PR_MD_CURRENT_CPU()) {\n+      _PR_INTSOFF(is);\n+      PR_Lock(_pr_activeLock);\n     }\n-    return thread;\n+    if (type == PR_SYSTEM_THREAD) {\n+      thread->flags |= _PR_SYSTEM;\n+      _pr_systemActive++;\n+    } else {\n+      _pr_userActive++;\n+    }\n+    if (_PR_MD_CURRENT_CPU()) {\n+      PR_Unlock(_pr_activeLock);\n+      _PR_INTSON(is);\n+    }\n+  }\n+  return thread;\n }\n \n PR_IMPLEMENT(PRThread*)\n PR_AttachThread(PRThreadType type, PRThreadPriority priority,\n-                PRThreadStack* stack)\n-{\n-    return PR_GetCurrentThread();\n+                PRThreadStack* stack) {\n+  return PR_GetCurrentThread();\n }\n \n-PR_IMPLEMENT(void)\n-PR_DetachThread(void)\n-{\n-    /*\n-     * On Solaris, and Windows, foreign threads are detached when\n-     * they terminate.\n-     */\n+PR_IMPLEMENT(void) PR_DetachThread(void) {\n+  /*\n+   * On Solaris, and Windows, foreign threads are detached when\n+   * they terminate.\n+   */\n #if !defined(WIN32) && !(defined(SOLARIS) && defined(_PR_GLOBAL_THREADS_ONLY))\n-    PRThread* me;\n-    if (_pr_initialized) {\n-        me = _PR_MD_GET_ATTACHED_THREAD();\n-        if ((me != NULL) && (me->flags & _PR_ATTACHED)) {\n-            _PRI_DetachThread();\n-        }\n+  PRThread* me;\n+  if (_pr_initialized) {\n+    me = _PR_MD_GET_ATTACHED_THREAD();\n+    if ((me != NULL) && (me->flags & _PR_ATTACHED)) {\n+      _PRI_DetachThread();\n     }\n+  }\n #endif\n }\n \n-void\n-_PRI_DetachThread(void)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (me->flags & _PR_PRIMORDIAL) {\n-        /*\n-         * ignore, if primordial thread\n-         */\n-        return;\n-    }\n-    PR_ASSERT(me->flags & _PR_ATTACHED);\n-    PR_ASSERT(_PR_IS_NATIVE_THREAD(me));\n-    _PR_CleanupThread(me);\n-    PR_DELETE(me->privateData);\n-\n-    _PR_DecrActiveThreadCount(me);\n+void _PRI_DetachThread(void) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n \n-    _PR_MD_CLEAN_THREAD(me);\n-    _PR_MD_SET_CURRENT_THREAD(NULL);\n-    if (!me->threadAllocatedOnStack) {\n-        PR_DELETE(me->stack);\n-    }\n-    _PR_MD_FREE_LOCK(&me->threadLock);\n-    PR_DELETE(me);\n+  if (me->flags & _PR_PRIMORDIAL) {\n+    /*\n+     * ignore, if primordial thread\n+     */\n+    return;\n+  }\n+  PR_ASSERT(me->flags & _PR_ATTACHED);\n+  PR_ASSERT(_PR_IS_NATIVE_THREAD(me));\n+  _PR_CleanupThread(me);\n+  PR_DELETE(me->privateData);\n+\n+  _PR_DecrActiveThreadCount(me);\n+\n+  _PR_MD_CLEAN_THREAD(me);\n+  _PR_MD_SET_CURRENT_THREAD(NULL);\n+  if (!me->threadAllocatedOnStack) {\n+    PR_DELETE(me->stack);\n+  }\n+  _PR_MD_FREE_LOCK(&me->threadLock);\n+  PR_DELETE(me);\n }\n \n /*\n@@ -1521,252 +1476,239 @@ _PRI_DetachThread(void)\n ** The calling thread will not be blocked if the target thread has already\n ** terminated.\n */\n-PR_IMPLEMENT(PRStatus)\n-PR_JoinThread(PRThread* thread)\n-{\n-    PRIntn is;\n-    PRCondVar* term;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-    term = thread->term;\n-    /* can't join a non-joinable thread */\n-    if (term == NULL) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        goto ErrorExit;\n-    }\n-\n-    /* multiple threads can't wait on the same joinable thread */\n-    if (term->condQ.next != &term->condQ) {\n-        goto ErrorExit;\n-    }\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n-    }\n-\n-    /* wait for the target thread's termination cv invariant */\n-    PR_Lock(_pr_terminationCVLock);\n-    while (thread->state != _PR_JOIN_WAIT) {\n-        (void)PR_WaitCondVar(term, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    (void)PR_Unlock(_pr_terminationCVLock);\n-\n-    /*\n-     Remove target thread from global waiting to join Q; make it runnable\n-     again and put it back on its run Q.  When it gets scheduled later in\n-     _PR_RunThread code, it will clean up its stack.\n-    */\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-    thread->state = _PR_RUNNABLE;\n-    if (!_PR_IS_NATIVE_THREAD(thread)) {\n-        _PR_THREAD_LOCK(thread);\n+PR_IMPLEMENT(PRStatus) PR_JoinThread(PRThread* thread) {\n+  PRIntn is;\n+  PRCondVar* term;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+  term = thread->term;\n+  /* can't join a non-joinable thread */\n+  if (term == NULL) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    goto ErrorExit;\n+  }\n+\n+  /* multiple threads can't wait on the same joinable thread */\n+  if (term->condQ.next != &term->condQ) {\n+    goto ErrorExit;\n+  }\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n+\n+  /* wait for the target thread's termination cv invariant */\n+  PR_Lock(_pr_terminationCVLock);\n+  while (thread->state != _PR_JOIN_WAIT) {\n+    (void)PR_WaitCondVar(term, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  (void)PR_Unlock(_pr_terminationCVLock);\n+\n+  /*\n+   Remove target thread from global waiting to join Q; make it runnable\n+   again and put it back on its run Q.  When it gets scheduled later in\n+   _PR_RunThread code, it will clean up its stack.\n+  */\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+  thread->state = _PR_RUNNABLE;\n+  if (!_PR_IS_NATIVE_THREAD(thread)) {\n+    _PR_THREAD_LOCK(thread);\n \n-        _PR_MISCQ_LOCK(thread->cpu);\n-        _PR_DEL_JOINQ(thread);\n-        _PR_MISCQ_UNLOCK(thread->cpu);\n+    _PR_MISCQ_LOCK(thread->cpu);\n+    _PR_DEL_JOINQ(thread);\n+    _PR_MISCQ_UNLOCK(thread->cpu);\n \n-        _PR_AddThreadToRunQ(me, thread);\n-        _PR_THREAD_UNLOCK(thread);\n-    }\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n-    }\n+    _PR_AddThreadToRunQ(me, thread);\n+    _PR_THREAD_UNLOCK(thread);\n+  }\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n \n-    _PR_MD_WAKEUP_WAITER(thread);\n+  _PR_MD_WAKEUP_WAITER(thread);\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n \n ErrorExit:\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n-    }\n-    return PR_FAILURE;\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n+  return PR_FAILURE;\n }\n \n PR_IMPLEMENT(void)\n-PR_SetThreadPriority(PRThread* thread, PRThreadPriority newPri)\n-{\n-    /*\n-    First, pin down the priority.  Not all compilers catch passing out of\n-    range enum here.  If we let bad values thru, priority queues won't work.\n-    */\n-    if ((PRIntn)newPri > (PRIntn)PR_PRIORITY_LAST) {\n-        newPri = PR_PRIORITY_LAST;\n-    } else if ((PRIntn)newPri < (PRIntn)PR_PRIORITY_FIRST) {\n-        newPri = PR_PRIORITY_FIRST;\n-    }\n-\n-    if (_PR_IS_NATIVE_THREAD(thread)) {\n-        thread->priority = newPri;\n-        _PR_MD_SET_PRIORITY(&(thread->md), newPri);\n-    } else {\n-        _PR_SetThreadPriority(thread, newPri);\n-    }\n+PR_SetThreadPriority(PRThread* thread, PRThreadPriority newPri) {\n+  /*\n+  First, pin down the priority.  Not all compilers catch passing out of\n+  range enum here.  If we let bad values thru, priority queues won't work.\n+  */\n+  if ((PRIntn)newPri > (PRIntn)PR_PRIORITY_LAST) {\n+    newPri = PR_PRIORITY_LAST;\n+  } else if ((PRIntn)newPri < (PRIntn)PR_PRIORITY_FIRST) {\n+    newPri = PR_PRIORITY_FIRST;\n+  }\n+\n+  if (_PR_IS_NATIVE_THREAD(thread)) {\n+    thread->priority = newPri;\n+    _PR_MD_SET_PRIORITY(&(thread->md), newPri);\n+  } else {\n+    _PR_SetThreadPriority(thread, newPri);\n+  }\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_SetCurrentThreadName(const char* name)\n-{\n-    PRThread* thread;\n-    size_t nameLen;\n+PR_IMPLEMENT(PRStatus) PR_SetCurrentThreadName(const char* name) {\n+  PRThread* thread;\n+  size_t nameLen;\n \n-    if (!name) {\n-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n+  if (!name) {\n+    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n \n-    thread = PR_GetCurrentThread();\n-    if (!thread) {\n-        return PR_FAILURE;\n-    }\n+  thread = PR_GetCurrentThread();\n+  if (!thread) {\n+    return PR_FAILURE;\n+  }\n \n-    PR_Free(thread->name);\n-    nameLen = strlen(name);\n-    thread->name = (char*)PR_Malloc(nameLen + 1);\n-    if (!thread->name) {\n-        return PR_FAILURE;\n-    }\n-    memcpy(thread->name, name, nameLen + 1);\n-    _PR_MD_SET_CURRENT_THREAD_NAME(thread->name);\n-    return PR_SUCCESS;\n+  PR_Free(thread->name);\n+  nameLen = strlen(name);\n+  thread->name = (char*)PR_Malloc(nameLen + 1);\n+  if (!thread->name) {\n+    return PR_FAILURE;\n+  }\n+  memcpy(thread->name, name, nameLen + 1);\n+  _PR_MD_SET_CURRENT_THREAD_NAME(thread->name);\n+  return PR_SUCCESS;\n }\n \n-PR_IMPLEMENT(const char*)\n-PR_GetThreadName(const PRThread* thread)\n-{\n-    if (!thread) {\n-        return NULL;\n-    }\n-    return thread->name;\n+PR_IMPLEMENT(const char*) PR_GetThreadName(const PRThread* thread) {\n+  if (!thread) {\n+    return NULL;\n+  }\n+  return thread->name;\n }\n \n /*\n ** This routine prevents all other threads from running. This call is needed by\n ** the garbage collector.\n */\n-PR_IMPLEMENT(void)\n-PR_SuspendAll(void)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRCList* qp;\n-\n-    /*\n-     * Stop all user and native threads which are marked GC able.\n-     */\n-    PR_Lock(_pr_activeLock);\n-    suspendAllOn = PR_TRUE;\n-    suspendAllThread = _PR_MD_CURRENT_THREAD();\n-    _PR_MD_BEGIN_SUSPEND_ALL();\n-    for (qp = _PR_ACTIVE_LOCAL_THREADQ().next; qp != &_PR_ACTIVE_LOCAL_THREADQ();\n-         qp = qp->next) {\n-        if ((me != _PR_ACTIVE_THREAD_PTR(qp)) &&\n-            _PR_IS_GCABLE_THREAD(_PR_ACTIVE_THREAD_PTR(qp))) {\n-            _PR_Suspend(_PR_ACTIVE_THREAD_PTR(qp));\n-            PR_ASSERT((_PR_ACTIVE_THREAD_PTR(qp))->state != _PR_RUNNING);\n-        }\n-    }\n-    for (qp = _PR_ACTIVE_GLOBAL_THREADQ().next;\n-         qp != &_PR_ACTIVE_GLOBAL_THREADQ(); qp = qp->next) {\n-        if ((me != _PR_ACTIVE_THREAD_PTR(qp)) &&\n-            _PR_IS_GCABLE_THREAD(_PR_ACTIVE_THREAD_PTR(qp)))\n-        /* PR_Suspend(_PR_ACTIVE_THREAD_PTR(qp)); */\n-        {\n-            _PR_MD_SUSPEND_THREAD(_PR_ACTIVE_THREAD_PTR(qp));\n-        }\n-    }\n-    _PR_MD_END_SUSPEND_ALL();\n+PR_IMPLEMENT(void) PR_SuspendAll(void) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRCList* qp;\n+\n+  /*\n+   * Stop all user and native threads which are marked GC able.\n+   */\n+  PR_Lock(_pr_activeLock);\n+  suspendAllOn = PR_TRUE;\n+  suspendAllThread = _PR_MD_CURRENT_THREAD();\n+  _PR_MD_BEGIN_SUSPEND_ALL();\n+  for (qp = _PR_ACTIVE_LOCAL_THREADQ().next; qp != &_PR_ACTIVE_LOCAL_THREADQ();\n+       qp = qp->next) {\n+    if ((me != _PR_ACTIVE_THREAD_PTR(qp)) &&\n+        _PR_IS_GCABLE_THREAD(_PR_ACTIVE_THREAD_PTR(qp))) {\n+      _PR_Suspend(_PR_ACTIVE_THREAD_PTR(qp));\n+      PR_ASSERT((_PR_ACTIVE_THREAD_PTR(qp))->state != _PR_RUNNING);\n+    }\n+  }\n+  for (qp = _PR_ACTIVE_GLOBAL_THREADQ().next;\n+       qp != &_PR_ACTIVE_GLOBAL_THREADQ(); qp = qp->next) {\n+    if ((me != _PR_ACTIVE_THREAD_PTR(qp)) &&\n+        _PR_IS_GCABLE_THREAD(_PR_ACTIVE_THREAD_PTR(qp)))\n+    /* PR_Suspend(_PR_ACTIVE_THREAD_PTR(qp)); */\n+    {\n+      _PR_MD_SUSPEND_THREAD(_PR_ACTIVE_THREAD_PTR(qp));\n+    }\n+  }\n+  _PR_MD_END_SUSPEND_ALL();\n }\n \n /*\n ** This routine unblocks all other threads that were suspended from running by\n ** PR_SuspendAll(). This call is needed by the garbage collector.\n */\n-PR_IMPLEMENT(void)\n-PR_ResumeAll(void)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRCList* qp;\n-\n-    /*\n-     * Resume all user and native threads which are marked GC able.\n-     */\n-    _PR_MD_BEGIN_RESUME_ALL();\n-    for (qp = _PR_ACTIVE_LOCAL_THREADQ().next; qp != &_PR_ACTIVE_LOCAL_THREADQ();\n-         qp = qp->next) {\n-        if ((me != _PR_ACTIVE_THREAD_PTR(qp)) &&\n-            _PR_IS_GCABLE_THREAD(_PR_ACTIVE_THREAD_PTR(qp))) {\n-            _PR_Resume(_PR_ACTIVE_THREAD_PTR(qp));\n-        }\n-    }\n-    for (qp = _PR_ACTIVE_GLOBAL_THREADQ().next;\n-         qp != &_PR_ACTIVE_GLOBAL_THREADQ(); qp = qp->next) {\n-        if ((me != _PR_ACTIVE_THREAD_PTR(qp)) &&\n-            _PR_IS_GCABLE_THREAD(_PR_ACTIVE_THREAD_PTR(qp))) {\n-            _PR_MD_RESUME_THREAD(_PR_ACTIVE_THREAD_PTR(qp));\n-        }\n-    }\n-    _PR_MD_END_RESUME_ALL();\n-    suspendAllThread = NULL;\n-    suspendAllOn = PR_FALSE;\n-    PR_Unlock(_pr_activeLock);\n+PR_IMPLEMENT(void) PR_ResumeAll(void) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRCList* qp;\n+\n+  /*\n+   * Resume all user and native threads which are marked GC able.\n+   */\n+  _PR_MD_BEGIN_RESUME_ALL();\n+  for (qp = _PR_ACTIVE_LOCAL_THREADQ().next; qp != &_PR_ACTIVE_LOCAL_THREADQ();\n+       qp = qp->next) {\n+    if ((me != _PR_ACTIVE_THREAD_PTR(qp)) &&\n+        _PR_IS_GCABLE_THREAD(_PR_ACTIVE_THREAD_PTR(qp))) {\n+      _PR_Resume(_PR_ACTIVE_THREAD_PTR(qp));\n+    }\n+  }\n+  for (qp = _PR_ACTIVE_GLOBAL_THREADQ().next;\n+       qp != &_PR_ACTIVE_GLOBAL_THREADQ(); qp = qp->next) {\n+    if ((me != _PR_ACTIVE_THREAD_PTR(qp)) &&\n+        _PR_IS_GCABLE_THREAD(_PR_ACTIVE_THREAD_PTR(qp))) {\n+      _PR_MD_RESUME_THREAD(_PR_ACTIVE_THREAD_PTR(qp));\n+    }\n+  }\n+  _PR_MD_END_RESUME_ALL();\n+  suspendAllThread = NULL;\n+  suspendAllOn = PR_FALSE;\n+  PR_Unlock(_pr_activeLock);\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_EnumerateThreads(PREnumerator func, void* arg)\n-{\n-    PRCList *qp, *qp_next;\n-    PRIntn i = 0;\n-    PRStatus rv = PR_SUCCESS;\n-    PRThread* t;\n-\n-    /*\n-    ** Currently Enumerate threads happen only with suspension and\n-    ** pr_activeLock held\n-    */\n-    PR_ASSERT(suspendAllOn);\n-\n-    /* Steve Morse, 4-23-97: Note that we can't walk a queue by taking\n-     * qp->next after applying the function \"func\".  In particular, \"func\"\n-     * might remove the thread from the queue and put it into another one in\n-     * which case qp->next no longer points to the next entry in the original\n-     * queue.\n-     *\n-     * To get around this problem, we save qp->next in qp_next before applying\n-     * \"func\" and use that saved value as the next value after applying \"func\".\n-     */\n-\n-    /*\n-     * Traverse the list of local and global threads\n-     */\n-    for (qp = _PR_ACTIVE_LOCAL_THREADQ().next; qp != &_PR_ACTIVE_LOCAL_THREADQ();\n-         qp = qp_next) {\n-        qp_next = qp->next;\n-        t = _PR_ACTIVE_THREAD_PTR(qp);\n-        if (_PR_IS_GCABLE_THREAD(t)) {\n-            rv = (*func)(t, i, arg);\n-            if (rv != PR_SUCCESS) {\n-                return rv;\n-            }\n-            i++;\n-        }\n-    }\n-    for (qp = _PR_ACTIVE_GLOBAL_THREADQ().next;\n-         qp != &_PR_ACTIVE_GLOBAL_THREADQ(); qp = qp_next) {\n-        qp_next = qp->next;\n-        t = _PR_ACTIVE_THREAD_PTR(qp);\n-        if (_PR_IS_GCABLE_THREAD(t)) {\n-            rv = (*func)(t, i, arg);\n-            if (rv != PR_SUCCESS) {\n-                return rv;\n-            }\n-            i++;\n-        }\n-    }\n-    return rv;\n+PR_IMPLEMENT(PRStatus) PR_EnumerateThreads(PREnumerator func, void* arg) {\n+  PRCList *qp, *qp_next;\n+  PRIntn i = 0;\n+  PRStatus rv = PR_SUCCESS;\n+  PRThread* t;\n+\n+  /*\n+  ** Currently Enumerate threads happen only with suspension and\n+  ** pr_activeLock held\n+  */\n+  PR_ASSERT(suspendAllOn);\n+\n+  /* Steve Morse, 4-23-97: Note that we can't walk a queue by taking\n+   * qp->next after applying the function \"func\".  In particular, \"func\"\n+   * might remove the thread from the queue and put it into another one in\n+   * which case qp->next no longer points to the next entry in the original\n+   * queue.\n+   *\n+   * To get around this problem, we save qp->next in qp_next before applying\n+   * \"func\" and use that saved value as the next value after applying \"func\".\n+   */\n+\n+  /*\n+   * Traverse the list of local and global threads\n+   */\n+  for (qp = _PR_ACTIVE_LOCAL_THREADQ().next; qp != &_PR_ACTIVE_LOCAL_THREADQ();\n+       qp = qp_next) {\n+    qp_next = qp->next;\n+    t = _PR_ACTIVE_THREAD_PTR(qp);\n+    if (_PR_IS_GCABLE_THREAD(t)) {\n+      rv = (*func)(t, i, arg);\n+      if (rv != PR_SUCCESS) {\n+        return rv;\n+      }\n+      i++;\n+    }\n+  }\n+  for (qp = _PR_ACTIVE_GLOBAL_THREADQ().next;\n+       qp != &_PR_ACTIVE_GLOBAL_THREADQ(); qp = qp_next) {\n+    qp_next = qp->next;\n+    t = _PR_ACTIVE_THREAD_PTR(qp);\n+    if (_PR_IS_GCABLE_THREAD(t)) {\n+      rv = (*func)(t, i, arg);\n+      if (rv != PR_SUCCESS) {\n+        return rv;\n+      }\n+      i++;\n+    }\n+  }\n+  return rv;\n }\n \n /* FUNCTION: _PR_AddSleepQ\n@@ -1777,57 +1719,56 @@ PR_EnumerateThreads(PREnumerator func, void* arg)\n **    Caller must be a user level thread\n */\n PR_IMPLEMENT(void)\n-_PR_AddSleepQ(PRThread* thread, PRIntervalTime timeout)\n-{\n-    _PRCPU* cpu = thread->cpu;\n+_PR_AddSleepQ(PRThread* thread, PRIntervalTime timeout) {\n+  _PRCPU* cpu = thread->cpu;\n+\n+  if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n+    /* append the thread to the global pause Q */\n+    PR_APPEND_LINK(&thread->links, &_PR_PAUSEQ(thread->cpu));\n+    thread->flags |= _PR_ON_PAUSEQ;\n+  } else {\n+    PRIntervalTime sleep;\n+    PRCList* q;\n+    PRThread* t;\n+\n+    /* sort onto global sleepQ */\n+    sleep = timeout;\n \n-    if (timeout == PR_INTERVAL_NO_TIMEOUT) {\n-        /* append the thread to the global pause Q */\n-        PR_APPEND_LINK(&thread->links, &_PR_PAUSEQ(thread->cpu));\n-        thread->flags |= _PR_ON_PAUSEQ;\n+    /* Check if we are longest timeout */\n+    if (timeout >= _PR_SLEEPQMAX(cpu)) {\n+      PR_INSERT_BEFORE(&thread->links, &_PR_SLEEPQ(cpu));\n+      thread->sleep = timeout - _PR_SLEEPQMAX(cpu);\n+      _PR_SLEEPQMAX(cpu) = timeout;\n     } else {\n-        PRIntervalTime sleep;\n-        PRCList* q;\n-        PRThread* t;\n-\n-        /* sort onto global sleepQ */\n-        sleep = timeout;\n-\n-        /* Check if we are longest timeout */\n-        if (timeout >= _PR_SLEEPQMAX(cpu)) {\n-            PR_INSERT_BEFORE(&thread->links, &_PR_SLEEPQ(cpu));\n-            thread->sleep = timeout - _PR_SLEEPQMAX(cpu);\n-            _PR_SLEEPQMAX(cpu) = timeout;\n-        } else {\n-            /* Sort thread into global sleepQ at appropriate point */\n-            q = _PR_SLEEPQ(cpu).next;\n-\n-            /* Now scan the list for where to insert this entry */\n-            while (q != &_PR_SLEEPQ(cpu)) {\n-                t = _PR_THREAD_PTR(q);\n-                if (sleep < t->sleep) {\n-                    /* Found sleeper to insert in front of */\n-                    break;\n-                }\n-                sleep -= t->sleep;\n-                q = q->next;\n-            }\n-            thread->sleep = sleep;\n-            PR_INSERT_BEFORE(&thread->links, q);\n-\n-            /*\n-            ** Subtract our sleep time from the sleeper that follows us (there\n-            ** must be one) so that they remain relative to us.\n-            */\n-            PR_ASSERT(thread->links.next != &_PR_SLEEPQ(cpu));\n-\n-            t = _PR_THREAD_PTR(thread->links.next);\n-            PR_ASSERT(_PR_THREAD_PTR(t->links.prev) == thread);\n-            t->sleep -= sleep;\n+      /* Sort thread into global sleepQ at appropriate point */\n+      q = _PR_SLEEPQ(cpu).next;\n+\n+      /* Now scan the list for where to insert this entry */\n+      while (q != &_PR_SLEEPQ(cpu)) {\n+        t = _PR_THREAD_PTR(q);\n+        if (sleep < t->sleep) {\n+          /* Found sleeper to insert in front of */\n+          break;\n         }\n+        sleep -= t->sleep;\n+        q = q->next;\n+      }\n+      thread->sleep = sleep;\n+      PR_INSERT_BEFORE(&thread->links, q);\n \n-        thread->flags |= _PR_ON_SLEEPQ;\n+      /*\n+      ** Subtract our sleep time from the sleeper that follows us (there\n+      ** must be one) so that they remain relative to us.\n+      */\n+      PR_ASSERT(thread->links.next != &_PR_SLEEPQ(cpu));\n+\n+      t = _PR_THREAD_PTR(thread->links.next);\n+      PR_ASSERT(_PR_THREAD_PTR(t->links.prev) == thread);\n+      t->sleep -= sleep;\n     }\n+\n+    thread->flags |= _PR_ON_SLEEPQ;\n+  }\n }\n \n /* FUNCTION: _PR_DelSleepQ\n@@ -1842,83 +1783,81 @@ _PR_AddSleepQ(PRThread* thread, PRIntervalTime timeout)\n **    Caller must be a user level thread\n */\n PR_IMPLEMENT(void)\n-_PR_DelSleepQ(PRThread* thread, PRBool propogate_time)\n-{\n-    _PRCPU* cpu = thread->cpu;\n-\n-    /* Remove from pauseQ/sleepQ */\n-    if (thread->flags & (_PR_ON_PAUSEQ | _PR_ON_SLEEPQ)) {\n-        if (thread->flags & _PR_ON_SLEEPQ) {\n-            PRCList* q = thread->links.next;\n-            if (q != &_PR_SLEEPQ(cpu)) {\n-                if (propogate_time == PR_TRUE) {\n-                    PRThread* after = _PR_THREAD_PTR(q);\n-                    after->sleep += thread->sleep;\n-                } else {\n-                    _PR_SLEEPQMAX(cpu) -= thread->sleep;\n-                }\n-            } else {\n-                /* Check if prev is the beggining of the list; if so,\n-                 * we are the only element on the list.\n-                 */\n-                if (thread->links.prev != &_PR_SLEEPQ(cpu)) {\n-                    _PR_SLEEPQMAX(cpu) -= thread->sleep;\n-                } else {\n-                    _PR_SLEEPQMAX(cpu) = 0;\n-                }\n-            }\n-            thread->flags &= ~_PR_ON_SLEEPQ;\n+_PR_DelSleepQ(PRThread* thread, PRBool propogate_time) {\n+  _PRCPU* cpu = thread->cpu;\n+\n+  /* Remove from pauseQ/sleepQ */\n+  if (thread->flags & (_PR_ON_PAUSEQ | _PR_ON_SLEEPQ)) {\n+    if (thread->flags & _PR_ON_SLEEPQ) {\n+      PRCList* q = thread->links.next;\n+      if (q != &_PR_SLEEPQ(cpu)) {\n+        if (propogate_time == PR_TRUE) {\n+          PRThread* after = _PR_THREAD_PTR(q);\n+          after->sleep += thread->sleep;\n         } else {\n-            thread->flags &= ~_PR_ON_PAUSEQ;\n+          _PR_SLEEPQMAX(cpu) -= thread->sleep;\n         }\n-        PR_REMOVE_LINK(&thread->links);\n+      } else {\n+        /* Check if prev is the beggining of the list; if so,\n+         * we are the only element on the list.\n+         */\n+        if (thread->links.prev != &_PR_SLEEPQ(cpu)) {\n+          _PR_SLEEPQMAX(cpu) -= thread->sleep;\n+        } else {\n+          _PR_SLEEPQMAX(cpu) = 0;\n+        }\n+      }\n+      thread->flags &= ~_PR_ON_SLEEPQ;\n     } else {\n-        PR_ASSERT(0);\n+      thread->flags &= ~_PR_ON_PAUSEQ;\n     }\n+    PR_REMOVE_LINK(&thread->links);\n+  } else {\n+    PR_ASSERT(0);\n+  }\n }\n \n-void\n-_PR_AddThreadToRunQ(\n+void _PR_AddThreadToRunQ(\n     PRThread* me,     /* the current thread */\n     PRThread* thread) /* the local thread to be added to a run queue */\n {\n-    PRThreadPriority pri = thread->priority;\n-    _PRCPU* cpu = thread->cpu;\n+  PRThreadPriority pri = thread->priority;\n+  _PRCPU* cpu = thread->cpu;\n \n-    PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread));\n+  PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread));\n \n #if defined(WINNT)\n-    /*\n-     * On NT, we can only reliably know that the current CPU\n-     * is not idle.  We add the awakened thread to the run\n-     * queue of its CPU if its CPU is the current CPU.\n-     * For any other CPU, we don't really know whether it\n-     * is busy or idle.  So in all other cases, we just\n-     * \"post\" the awakened thread to the IO completion port\n-     * for the next idle CPU to execute (this is done in\n-     * _PR_MD_WAKEUP_WAITER).\n-     * Threads with a suspended I/O operation remain bound to\n-     * the same cpu until I/O is cancelled\n-     *\n-     * NOTE: the boolean expression below must be the exact\n-     * opposite of the corresponding boolean expression in\n-     * _PR_MD_WAKEUP_WAITER.\n-     */\n-    if ((!_PR_IS_NATIVE_THREAD(me) && (cpu == me->cpu)) ||\n-        (thread->md.thr_bound_cpu)) {\n-        PR_ASSERT(!thread->md.thr_bound_cpu || (thread->md.thr_bound_cpu == cpu));\n-        _PR_RUNQ_LOCK(cpu);\n-        _PR_ADD_RUNQ(thread, cpu, pri);\n-        _PR_RUNQ_UNLOCK(cpu);\n-    }\n-#else\n+  /*\n+   * On NT, we can only reliably know that the current CPU\n+   * is not idle.  We add the awakened thread to the run\n+   * queue of its CPU if its CPU is the current CPU.\n+   * For any other CPU, we don't really know whether it\n+   * is busy or idle.  So in all other cases, we just\n+   * \"post\" the awakened thread to the IO completion port\n+   * for the next idle CPU to execute (this is done in\n+   * _PR_MD_WAKEUP_WAITER).\n+   * Threads with a suspended I/O operation remain bound to\n+   * the same cpu until I/O is cancelled\n+   *\n+   * NOTE: the boolean expression below must be the exact\n+   * opposite of the corresponding boolean expression in\n+   * _PR_MD_WAKEUP_WAITER.\n+   */\n+  if ((!_PR_IS_NATIVE_THREAD(me) && (cpu == me->cpu)) ||\n+      (thread->md.thr_bound_cpu)) {\n+    PR_ASSERT(!thread->md.thr_bound_cpu || (thread->md.thr_bound_cpu == cpu));\n     _PR_RUNQ_LOCK(cpu);\n     _PR_ADD_RUNQ(thread, cpu, pri);\n     _PR_RUNQ_UNLOCK(cpu);\n-    if (!_PR_IS_NATIVE_THREAD(me) && (cpu == me->cpu)) {\n-        if (pri > me->priority) {\n-            _PR_SET_RESCHED_FLAG();\n-        }\n-    }\n+  }\n+#else\n+  _PR_RUNQ_LOCK(cpu);\n+  _PR_ADD_RUNQ(thread, cpu, pri);\n+  _PR_RUNQ_UNLOCK(cpu);\n+  if (!_PR_IS_NATIVE_THREAD(me) && (cpu == me->cpu)) {\n+    if (pri > me->priority) {\n+      _PR_SET_RESCHED_FLAG();\n+    }\n+  }\n #endif\n }\ndiff --git a/nspr/pr/src/threads/prcmon.c b/nspr/pr/src/threads/prcmon.c\nindex 14e212e..32479a7 100644\n--- a/nspr/pr/src/threads/prcmon.c\n+++ b/nspr/pr/src/threads/prcmon.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,34 +10,34 @@\n \n /* Lock used to lock the monitor cache */\n #ifdef _PR_NO_PREEMPT\n-#define _PR_NEW_LOCK_MCACHE()\n-#define _PR_DESTROY_LOCK_MCACHE()\n-#define _PR_LOCK_MCACHE()\n-#define _PR_UNLOCK_MCACHE()\n+#  define _PR_NEW_LOCK_MCACHE()\n+#  define _PR_DESTROY_LOCK_MCACHE()\n+#  define _PR_LOCK_MCACHE()\n+#  define _PR_UNLOCK_MCACHE()\n #else\n-#ifdef _PR_LOCAL_THREADS_ONLY\n-#define _PR_NEW_LOCK_MCACHE()\n-#define _PR_DESTROY_LOCK_MCACHE()\n-#define _PR_LOCK_MCACHE() \\\n-    {                     \\\n-        PRIntn _is;       \\\n+#  ifdef _PR_LOCAL_THREADS_ONLY\n+#    define _PR_NEW_LOCK_MCACHE()\n+#    define _PR_DESTROY_LOCK_MCACHE()\n+#    define _PR_LOCK_MCACHE() \\\n+      {                       \\\n+        PRIntn _is;           \\\n         _PR_INTSOFF(_is)\n-#define _PR_UNLOCK_MCACHE() \\\n-    _PR_INTSON(_is);        \\\n-    }\n-#else\n+#    define _PR_UNLOCK_MCACHE() \\\n+      _PR_INTSON(_is);          \\\n+      }\n+#  else\n PRLock* _pr_mcacheLock;\n-#define _PR_NEW_LOCK_MCACHE() (_pr_mcacheLock = PR_NewLock())\n-#define _PR_DESTROY_LOCK_MCACHE()       \\\n-    PR_BEGIN_MACRO                      \\\n-    if (_pr_mcacheLock) {               \\\n+#    define _PR_NEW_LOCK_MCACHE() (_pr_mcacheLock = PR_NewLock())\n+#    define _PR_DESTROY_LOCK_MCACHE()   \\\n+      PR_BEGIN_MACRO                    \\\n+      if (_pr_mcacheLock) {             \\\n         PR_DestroyLock(_pr_mcacheLock); \\\n         _pr_mcacheLock = NULL;          \\\n-    }                                   \\\n-    PR_END_MACRO\n-#define _PR_LOCK_MCACHE() PR_Lock(_pr_mcacheLock)\n-#define _PR_UNLOCK_MCACHE() PR_Unlock(_pr_mcacheLock)\n-#endif\n+      }                                 \\\n+      PR_END_MACRO\n+#    define _PR_LOCK_MCACHE() PR_Lock(_pr_mcacheLock)\n+#    define _PR_UNLOCK_MCACHE() PR_Unlock(_pr_mcacheLock)\n+#  endif\n #endif\n \n /************************************************************************/\n@@ -44,10 +45,10 @@ PRLock* _pr_mcacheLock;\n typedef struct MonitorCacheEntryStr MonitorCacheEntry;\n \n struct MonitorCacheEntryStr {\n-    MonitorCacheEntry* next;\n-    void* address;\n-    PRMonitor* mon;\n-    long cacheEntryCount;\n+  MonitorCacheEntry* next;\n+  void* address;\n+  PRMonitor* mon;\n+  long cacheEntryCount;\n };\n \n /*\n@@ -58,8 +59,8 @@ struct MonitorCacheEntryStr {\n typedef struct MonitorCacheEntryBlockStr MonitorCacheEntryBlock;\n \n struct MonitorCacheEntryBlockStr {\n-    MonitorCacheEntryBlock* next;\n-    MonitorCacheEntry entries[1];\n+  MonitorCacheEntryBlock* next;\n+  MonitorCacheEntry entries[1];\n };\n \n static PRUint32 hash_mask;\n@@ -73,9 +74,9 @@ static MonitorCacheEntryBlock* mcache_blocks;\n \n static void (*OnMonitorRecycle)(void* address);\n \n-#define HASH(address)                                                           \\\n-    ((PRUint32)(((PRUptrdiff)(address) >> 2) ^ ((PRUptrdiff)(address) >> 10)) & \\\n-     hash_mask)\n+#define HASH(address)                                                         \\\n+  ((PRUint32)(((PRUptrdiff)(address) >> 2) ^ ((PRUptrdiff)(address) >> 10)) & \\\n+   hash_mask)\n \n /*\n ** Expand the monitor cache. This grows the hash buckets and allocates a\n@@ -90,154 +91,150 @@ static void (*OnMonitorRecycle)(void* address);\n \n #define FREE_THRESHOLD 5\n \n-static PRStatus\n-ExpandMonitorCache(PRUintn new_size_log2)\n-{\n-    MonitorCacheEntry **old_hash_buckets, *p;\n-    PRUintn i, entries, old_num_hash_buckets, added;\n-    MonitorCacheEntry** new_hash_buckets;\n-    MonitorCacheEntryBlock* new_block;\n-\n-    entries = 1L << new_size_log2;\n-\n-    /*\n-    ** Expand the monitor-cache-entry free list\n-    */\n-    new_block = (MonitorCacheEntryBlock*)PR_CALLOC(\n-        sizeof(MonitorCacheEntryBlock) +\n-        (entries - 1) * sizeof(MonitorCacheEntry));\n-    if (NULL == new_block) {\n-        return PR_FAILURE;\n-    }\n-\n-    /*\n-    ** Allocate system monitors for the new monitor cache entries. If we\n-    ** run out of system monitors, break out of the loop.\n-    */\n-    for (i = 0, p = new_block->entries; i < entries; i++, p++) {\n-        p->mon = PR_NewMonitor();\n-        if (!p->mon) {\n-            break;\n-        }\n+static PRStatus ExpandMonitorCache(PRUintn new_size_log2) {\n+  MonitorCacheEntry **old_hash_buckets, *p;\n+  PRUintn i, entries, old_num_hash_buckets, added;\n+  MonitorCacheEntry** new_hash_buckets;\n+  MonitorCacheEntryBlock* new_block;\n+\n+  entries = 1L << new_size_log2;\n+\n+  /*\n+  ** Expand the monitor-cache-entry free list\n+  */\n+  new_block = (MonitorCacheEntryBlock*)PR_CALLOC(\n+      sizeof(MonitorCacheEntryBlock) +\n+      (entries - 1) * sizeof(MonitorCacheEntry));\n+  if (NULL == new_block) {\n+    return PR_FAILURE;\n+  }\n+\n+  /*\n+  ** Allocate system monitors for the new monitor cache entries. If we\n+  ** run out of system monitors, break out of the loop.\n+  */\n+  for (i = 0, p = new_block->entries; i < entries; i++, p++) {\n+    p->mon = PR_NewMonitor();\n+    if (!p->mon) {\n+      break;\n     }\n-    added = i;\n-    if (added != entries) {\n-        MonitorCacheEntryBlock* realloc_block;\n-\n-        if (added == 0) {\n-            /* Totally out of system monitors. Lossage abounds */\n-            PR_DELETE(new_block);\n-            return PR_FAILURE;\n-        }\n-\n-        /*\n-        ** We were able to allocate some of the system monitors. Use\n-        ** realloc to shrink down the new_block memory. If that fails,\n-        ** carry on with the too-large new_block.\n-        */\n-        realloc_block = (MonitorCacheEntryBlock*)PR_REALLOC(\n-            new_block, sizeof(MonitorCacheEntryBlock) +\n-                           (added - 1) * sizeof(MonitorCacheEntry));\n-        if (realloc_block) {\n-            new_block = realloc_block;\n-        }\n+  }\n+  added = i;\n+  if (added != entries) {\n+    MonitorCacheEntryBlock* realloc_block;\n+\n+    if (added == 0) {\n+      /* Totally out of system monitors. Lossage abounds */\n+      PR_DELETE(new_block);\n+      return PR_FAILURE;\n     }\n \n     /*\n-    ** Now that we have allocated all of the system monitors, build up\n-    ** the new free list. We can just update the free_list because we own\n-    ** the mcache-lock and we aren't calling anyone who might want to use\n-    ** it.\n+    ** We were able to allocate some of the system monitors. Use\n+    ** realloc to shrink down the new_block memory. If that fails,\n+    ** carry on with the too-large new_block.\n     */\n-    for (i = 0, p = new_block->entries; i < added - 1; i++, p++) {\n-        p->next = p + 1;\n-    }\n-    p->next = free_entries;\n-    free_entries = new_block->entries;\n-    num_free_entries += added;\n-    new_block->next = mcache_blocks;\n-    mcache_blocks = new_block;\n-\n-    /* Try to expand the hash table */\n-    new_hash_buckets =\n-        (MonitorCacheEntry**)PR_CALLOC(entries * sizeof(MonitorCacheEntry*));\n-    if (NULL == new_hash_buckets) {\n-        /*\n-        ** Partial lossage. In this situation we don't get any more hash\n-        ** buckets, which just means that the table lookups will take\n-        ** longer. This is bad, but not fatal\n-        */\n-        PR_LOG(_pr_cmon_lm, PR_LOG_WARNING,\n-               (\"unable to grow monitor cache hash buckets\"));\n-        return PR_SUCCESS;\n+    realloc_block = (MonitorCacheEntryBlock*)PR_REALLOC(\n+        new_block, sizeof(MonitorCacheEntryBlock) +\n+                       (added - 1) * sizeof(MonitorCacheEntry));\n+    if (realloc_block) {\n+      new_block = realloc_block;\n     }\n-\n-    /*\n-    ** Compute new hash mask value. This value is used to mask an address\n-    ** until it's bits are in the right spot for indexing into the hash\n-    ** table.\n-    */\n-    hash_mask = entries - 1;\n-\n+  }\n+\n+  /*\n+  ** Now that we have allocated all of the system monitors, build up\n+  ** the new free list. We can just update the free_list because we own\n+  ** the mcache-lock and we aren't calling anyone who might want to use\n+  ** it.\n+  */\n+  for (i = 0, p = new_block->entries; i < added - 1; i++, p++) {\n+    p->next = p + 1;\n+  }\n+  p->next = free_entries;\n+  free_entries = new_block->entries;\n+  num_free_entries += added;\n+  new_block->next = mcache_blocks;\n+  mcache_blocks = new_block;\n+\n+  /* Try to expand the hash table */\n+  new_hash_buckets =\n+      (MonitorCacheEntry**)PR_CALLOC(entries * sizeof(MonitorCacheEntry*));\n+  if (NULL == new_hash_buckets) {\n     /*\n-    ** Expand the hash table. We have to rehash everything in the old\n-    ** table into the new table.\n+    ** Partial lossage. In this situation we don't get any more hash\n+    ** buckets, which just means that the table lookups will take\n+    ** longer. This is bad, but not fatal\n     */\n-    old_hash_buckets = hash_buckets;\n-    old_num_hash_buckets = num_hash_buckets;\n-    for (i = 0; i < old_num_hash_buckets; i++) {\n-        p = old_hash_buckets[i];\n-        while (p) {\n-            MonitorCacheEntry* next = p->next;\n-\n-            /* Hash based on new table size, and then put p in the new table */\n-            PRUintn hash = HASH(p->address);\n-            p->next = new_hash_buckets[hash];\n-            new_hash_buckets[hash] = p;\n-\n-            p = next;\n-        }\n-    }\n-\n-    /*\n-    ** Switch over to new hash table and THEN call free of the old\n-    ** table. Since free might re-enter _pr_mcache_lock, things would\n-    ** break terribly if it used the old hash table.\n-    */\n-    hash_buckets = new_hash_buckets;\n-    num_hash_buckets = entries;\n-    num_hash_buckets_log2 = new_size_log2;\n-    PR_DELETE(old_hash_buckets);\n-\n-    PR_LOG(\n-        _pr_cmon_lm, PR_LOG_NOTICE,\n-        (\"expanded monitor cache to %d (buckets %d)\", num_free_entries, entries));\n-\n+    PR_LOG(_pr_cmon_lm, PR_LOG_WARNING,\n+           (\"unable to grow monitor cache hash buckets\"));\n     return PR_SUCCESS;\n+  }\n+\n+  /*\n+  ** Compute new hash mask value. This value is used to mask an address\n+  ** until it's bits are in the right spot for indexing into the hash\n+  ** table.\n+  */\n+  hash_mask = entries - 1;\n+\n+  /*\n+  ** Expand the hash table. We have to rehash everything in the old\n+  ** table into the new table.\n+  */\n+  old_hash_buckets = hash_buckets;\n+  old_num_hash_buckets = num_hash_buckets;\n+  for (i = 0; i < old_num_hash_buckets; i++) {\n+    p = old_hash_buckets[i];\n+    while (p) {\n+      MonitorCacheEntry* next = p->next;\n+\n+      /* Hash based on new table size, and then put p in the new table */\n+      PRUintn hash = HASH(p->address);\n+      p->next = new_hash_buckets[hash];\n+      new_hash_buckets[hash] = p;\n+\n+      p = next;\n+    }\n+  }\n+\n+  /*\n+  ** Switch over to new hash table and THEN call free of the old\n+  ** table. Since free might re-enter _pr_mcache_lock, things would\n+  ** break terribly if it used the old hash table.\n+  */\n+  hash_buckets = new_hash_buckets;\n+  num_hash_buckets = entries;\n+  num_hash_buckets_log2 = new_size_log2;\n+  PR_DELETE(old_hash_buckets);\n+\n+  PR_LOG(\n+      _pr_cmon_lm, PR_LOG_NOTICE,\n+      (\"expanded monitor cache to %d (buckets %d)\", num_free_entries, entries));\n+\n+  return PR_SUCCESS;\n } /* ExpandMonitorCache */\n \n /*\n ** Lookup a monitor cache entry by address. Return a pointer to the\n ** pointer to the monitor cache entry on success, null on failure.\n */\n-static MonitorCacheEntry**\n-LookupMonitorCacheEntry(void* address)\n-{\n-    PRUintn hash;\n-    MonitorCacheEntry **pp, *p;\n-\n-    hash = HASH(address);\n-    pp = hash_buckets + hash;\n-    while ((p = *pp) != 0) {\n-        if (p->address == address) {\n-            if (p->cacheEntryCount > 0) {\n-                return pp;\n-            }\n-            return NULL;\n-        }\n-        pp = &p->next;\n+static MonitorCacheEntry** LookupMonitorCacheEntry(void* address) {\n+  PRUintn hash;\n+  MonitorCacheEntry **pp, *p;\n+\n+  hash = HASH(address);\n+  pp = hash_buckets + hash;\n+  while ((p = *pp) != 0) {\n+    if (p->address == address) {\n+      if (p->cacheEntryCount > 0) {\n+        return pp;\n+      }\n+      return NULL;\n     }\n-    return NULL;\n+    pp = &p->next;\n+  }\n+  return NULL;\n }\n \n /*\n@@ -245,218 +242,201 @@ LookupMonitorCacheEntry(void* address)\n ** great - return it. Otherwise get a new free cache entry and set it\n ** up. If the cache free space is getting low, expand the cache.\n */\n-static PRMonitor*\n-CreateMonitor(void* address)\n-{\n-    PRUintn hash;\n-    MonitorCacheEntry **pp, *p;\n-\n-    hash = HASH(address);\n-    pp = hash_buckets + hash;\n-    while ((p = *pp) != 0) {\n-        if (p->address == address) {\n-            goto gotit;\n-        }\n-\n-        pp = &p->next;\n+static PRMonitor* CreateMonitor(void* address) {\n+  PRUintn hash;\n+  MonitorCacheEntry **pp, *p;\n+\n+  hash = HASH(address);\n+  pp = hash_buckets + hash;\n+  while ((p = *pp) != 0) {\n+    if (p->address == address) {\n+      goto gotit;\n     }\n \n-    /* Expand the monitor cache if we have run out of free slots in the table */\n-    if (num_free_entries < FREE_THRESHOLD) {\n-        /* Expand monitor cache */\n-\n-        /*\n-        ** This function is called with the lock held. So what's the 'expanding'\n-        ** boolean all about? Seems a bit redundant.\n-        */\n-        if (!expanding) {\n-            PRStatus rv;\n-\n-            expanding = PR_TRUE;\n-            rv = ExpandMonitorCache(num_hash_buckets_log2 + 1);\n-            expanding = PR_FALSE;\n-            if (PR_FAILURE == rv) {\n-                return NULL;\n-            }\n-\n-            /* redo the hash because it'll be different now */\n-            hash = HASH(address);\n-        } else {\n-            /*\n-            ** We are in process of expanding and we need a cache\n-            ** monitor.  Make sure we have enough!\n-            */\n-            PR_ASSERT(num_free_entries > 0);\n-        }\n-    }\n+    pp = &p->next;\n+  }\n+\n+  /* Expand the monitor cache if we have run out of free slots in the table */\n+  if (num_free_entries < FREE_THRESHOLD) {\n+    /* Expand monitor cache */\n+\n+    /*\n+    ** This function is called with the lock held. So what's the 'expanding'\n+    ** boolean all about? Seems a bit redundant.\n+    */\n+    if (!expanding) {\n+      PRStatus rv;\n \n-    /* Make a new monitor */\n-    p = free_entries;\n-    free_entries = p->next;\n-    num_free_entries--;\n-    if (OnMonitorRecycle && p->address) {\n-        OnMonitorRecycle(p->address);\n+      expanding = PR_TRUE;\n+      rv = ExpandMonitorCache(num_hash_buckets_log2 + 1);\n+      expanding = PR_FALSE;\n+      if (PR_FAILURE == rv) {\n+        return NULL;\n+      }\n+\n+      /* redo the hash because it'll be different now */\n+      hash = HASH(address);\n+    } else {\n+      /*\n+      ** We are in process of expanding and we need a cache\n+      ** monitor.  Make sure we have enough!\n+      */\n+      PR_ASSERT(num_free_entries > 0);\n     }\n-    p->address = address;\n-    p->next = hash_buckets[hash];\n-    hash_buckets[hash] = p;\n-    PR_ASSERT(p->cacheEntryCount == 0);\n+  }\n+\n+  /* Make a new monitor */\n+  p = free_entries;\n+  free_entries = p->next;\n+  num_free_entries--;\n+  if (OnMonitorRecycle && p->address) {\n+    OnMonitorRecycle(p->address);\n+  }\n+  p->address = address;\n+  p->next = hash_buckets[hash];\n+  hash_buckets[hash] = p;\n+  PR_ASSERT(p->cacheEntryCount == 0);\n \n gotit:\n-    p->cacheEntryCount++;\n-    return p->mon;\n+  p->cacheEntryCount++;\n+  return p->mon;\n }\n \n /*\n ** Initialize the monitor cache\n */\n-void\n-_PR_InitCMon(void)\n-{\n-    _PR_NEW_LOCK_MCACHE();\n-    ExpandMonitorCache(3);\n+void _PR_InitCMon(void) {\n+  _PR_NEW_LOCK_MCACHE();\n+  ExpandMonitorCache(3);\n }\n \n /*\n ** Destroy the monitor cache\n */\n-void\n-_PR_CleanupCMon(void)\n-{\n-    _PR_DESTROY_LOCK_MCACHE();\n-\n-    while (free_entries) {\n-        PR_DestroyMonitor(free_entries->mon);\n-        free_entries = free_entries->next;\n-    }\n-    num_free_entries = 0;\n-\n-    while (mcache_blocks) {\n-        MonitorCacheEntryBlock* block;\n-\n-        block = mcache_blocks;\n-        mcache_blocks = block->next;\n-        PR_DELETE(block);\n-    }\n-\n-    PR_DELETE(hash_buckets);\n-    hash_mask = 0;\n-    num_hash_buckets = 0;\n-    num_hash_buckets_log2 = 0;\n-\n-    expanding = PR_FALSE;\n-    OnMonitorRecycle = NULL;\n+void _PR_CleanupCMon(void) {\n+  _PR_DESTROY_LOCK_MCACHE();\n+\n+  while (free_entries) {\n+    PR_DestroyMonitor(free_entries->mon);\n+    free_entries = free_entries->next;\n+  }\n+  num_free_entries = 0;\n+\n+  while (mcache_blocks) {\n+    MonitorCacheEntryBlock* block;\n+\n+    block = mcache_blocks;\n+    mcache_blocks = block->next;\n+    PR_DELETE(block);\n+  }\n+\n+  PR_DELETE(hash_buckets);\n+  hash_mask = 0;\n+  num_hash_buckets = 0;\n+  num_hash_buckets_log2 = 0;\n+\n+  expanding = PR_FALSE;\n+  OnMonitorRecycle = NULL;\n }\n \n /*\n ** Create monitor for address. Don't enter the monitor while we have the\n ** mcache locked because we might block!\n */\n-PR_IMPLEMENT(PRMonitor*)\n-PR_CEnterMonitor(void* address)\n-{\n-    PRMonitor* mon;\n+PR_IMPLEMENT(PRMonitor*) PR_CEnterMonitor(void* address) {\n+  PRMonitor* mon;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    _PR_LOCK_MCACHE();\n-    mon = CreateMonitor(address);\n-    _PR_UNLOCK_MCACHE();\n+  _PR_LOCK_MCACHE();\n+  mon = CreateMonitor(address);\n+  _PR_UNLOCK_MCACHE();\n \n-    if (!mon) {\n-        return NULL;\n-    }\n+  if (!mon) {\n+    return NULL;\n+  }\n \n-    PR_EnterMonitor(mon);\n-    return mon;\n+  PR_EnterMonitor(mon);\n+  return mon;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CExitMonitor(void* address)\n-{\n-    MonitorCacheEntry **pp, *p;\n-    PRStatus status = PR_SUCCESS;\n-\n-    _PR_LOCK_MCACHE();\n-    pp = LookupMonitorCacheEntry(address);\n-    if (pp != NULL) {\n-        p = *pp;\n-        if (--p->cacheEntryCount == 0) {\n-            /*\n-            ** Nobody is using the system monitor. Put it on the cached free\n-            ** list. We are safe from somebody trying to use it because we\n-            ** have the mcache locked.\n-            */\n-            p->address = 0;         /* defensive move */\n-            *pp = p->next;          /* unlink from hash_buckets */\n-            p->next = free_entries; /* link into free list */\n-            free_entries = p;\n-            num_free_entries++; /* count it as free */\n-        }\n-        status = PR_ExitMonitor(p->mon);\n-    } else {\n-        status = PR_FAILURE;\n+PR_IMPLEMENT(PRStatus) PR_CExitMonitor(void* address) {\n+  MonitorCacheEntry **pp, *p;\n+  PRStatus status = PR_SUCCESS;\n+\n+  _PR_LOCK_MCACHE();\n+  pp = LookupMonitorCacheEntry(address);\n+  if (pp != NULL) {\n+    p = *pp;\n+    if (--p->cacheEntryCount == 0) {\n+      /*\n+      ** Nobody is using the system monitor. Put it on the cached free\n+      ** list. We are safe from somebody trying to use it because we\n+      ** have the mcache locked.\n+      */\n+      p->address = 0;         /* defensive move */\n+      *pp = p->next;          /* unlink from hash_buckets */\n+      p->next = free_entries; /* link into free list */\n+      free_entries = p;\n+      num_free_entries++; /* count it as free */\n     }\n-    _PR_UNLOCK_MCACHE();\n+    status = PR_ExitMonitor(p->mon);\n+  } else {\n+    status = PR_FAILURE;\n+  }\n+  _PR_UNLOCK_MCACHE();\n \n-    return status;\n+  return status;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CWait(void* address, PRIntervalTime ticks)\n-{\n-    MonitorCacheEntry** pp;\n-    PRMonitor* mon;\n+PR_IMPLEMENT(PRStatus) PR_CWait(void* address, PRIntervalTime ticks) {\n+  MonitorCacheEntry** pp;\n+  PRMonitor* mon;\n \n-    _PR_LOCK_MCACHE();\n-    pp = LookupMonitorCacheEntry(address);\n-    mon = pp ? ((*pp)->mon) : NULL;\n-    _PR_UNLOCK_MCACHE();\n+  _PR_LOCK_MCACHE();\n+  pp = LookupMonitorCacheEntry(address);\n+  mon = pp ? ((*pp)->mon) : NULL;\n+  _PR_UNLOCK_MCACHE();\n \n-    if (mon == NULL) {\n-        return PR_FAILURE;\n-    }\n-    return PR_Wait(mon, ticks);\n+  if (mon == NULL) {\n+    return PR_FAILURE;\n+  }\n+  return PR_Wait(mon, ticks);\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CNotify(void* address)\n-{\n-    MonitorCacheEntry** pp;\n-    PRMonitor* mon;\n+PR_IMPLEMENT(PRStatus) PR_CNotify(void* address) {\n+  MonitorCacheEntry** pp;\n+  PRMonitor* mon;\n \n-    _PR_LOCK_MCACHE();\n-    pp = LookupMonitorCacheEntry(address);\n-    mon = pp ? ((*pp)->mon) : NULL;\n-    _PR_UNLOCK_MCACHE();\n+  _PR_LOCK_MCACHE();\n+  pp = LookupMonitorCacheEntry(address);\n+  mon = pp ? ((*pp)->mon) : NULL;\n+  _PR_UNLOCK_MCACHE();\n \n-    if (mon == NULL) {\n-        return PR_FAILURE;\n-    }\n-    return PR_Notify(mon);\n+  if (mon == NULL) {\n+    return PR_FAILURE;\n+  }\n+  return PR_Notify(mon);\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_CNotifyAll(void* address)\n-{\n-    MonitorCacheEntry** pp;\n-    PRMonitor* mon;\n+PR_IMPLEMENT(PRStatus) PR_CNotifyAll(void* address) {\n+  MonitorCacheEntry** pp;\n+  PRMonitor* mon;\n \n-    _PR_LOCK_MCACHE();\n-    pp = LookupMonitorCacheEntry(address);\n-    mon = pp ? ((*pp)->mon) : NULL;\n-    _PR_UNLOCK_MCACHE();\n+  _PR_LOCK_MCACHE();\n+  pp = LookupMonitorCacheEntry(address);\n+  mon = pp ? ((*pp)->mon) : NULL;\n+  _PR_UNLOCK_MCACHE();\n \n-    if (mon == NULL) {\n-        return PR_FAILURE;\n-    }\n-    return PR_NotifyAll(mon);\n+  if (mon == NULL) {\n+    return PR_FAILURE;\n+  }\n+  return PR_NotifyAll(mon);\n }\n \n PR_IMPLEMENT(void)\n-PR_CSetOnMonitorRecycle(void (*callback)(void* address))\n-{\n-    OnMonitorRecycle = callback;\n+PR_CSetOnMonitorRecycle(void (*callback)(void* address)) {\n+  OnMonitorRecycle = callback;\n }\ndiff --git a/nspr/pr/src/threads/prcthr.c b/nspr/pr/src/threads/prcthr.c\nindex c09a9d2..03586b6 100644\n--- a/nspr/pr/src/threads/prcthr.c\n+++ b/nspr/pr/src/threads/prcthr.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,7 +12,7 @@\n ** The pragma suppresses the warning.\n **\n */\n-#pragma warning(disable : 4101)\n+#  pragma warning(disable : 4101)\n #endif\n \n extern PRLock* _pr_sleeplock; /* allocated and initialized in prinit */\n@@ -22,32 +23,28 @@ extern PRLock* _pr_sleeplock; /* allocated and initialized in prinit */\n ** Clean up a thread object, releasing all of the attached data. Do not\n ** free the object itself (it may not have been malloc'd)\n */\n-void\n-_PR_CleanupThread(PRThread* thread)\n-{\n-    /* Free up per-thread-data */\n-    _PR_DestroyThreadPrivate(thread);\n-\n-    /* Free any thread dump procs */\n-    if (thread->dumpArg) {\n-        PR_DELETE(thread->dumpArg);\n-    }\n-    thread->dump = 0;\n-\n-    PR_DELETE(thread->name);\n-    PR_DELETE(thread->errorString);\n-    thread->errorStringSize = 0;\n-    thread->errorStringLength = 0;\n-    thread->environment = NULL;\n+void _PR_CleanupThread(PRThread* thread) {\n+  /* Free up per-thread-data */\n+  _PR_DestroyThreadPrivate(thread);\n+\n+  /* Free any thread dump procs */\n+  if (thread->dumpArg) {\n+    PR_DELETE(thread->dumpArg);\n+  }\n+  thread->dump = 0;\n+\n+  PR_DELETE(thread->name);\n+  PR_DELETE(thread->errorString);\n+  thread->errorStringSize = 0;\n+  thread->errorStringLength = 0;\n+  thread->environment = NULL;\n }\n \n-PR_IMPLEMENT(PRStatus)\n-PR_Yield()\n-{\n-    static PRBool warning = PR_TRUE;\n-    if (warning)\n-        warning = _PR_Obsolete(\"PR_Yield()\", \"PR_Sleep(PR_INTERVAL_NO_WAIT)\");\n-    return (PR_Sleep(PR_INTERVAL_NO_WAIT));\n+PR_IMPLEMENT(PRStatus) PR_Yield() {\n+  static PRBool warning = PR_TRUE;\n+  if (warning)\n+    warning = _PR_Obsolete(\"PR_Yield()\", \"PR_Sleep(PR_INTERVAL_NO_WAIT)\");\n+  return (PR_Sleep(PR_INTERVAL_NO_WAIT));\n }\n \n /*\n@@ -60,88 +57,81 @@ PR_Yield()\n ** does get its own condition variable since each is expected to have\n ** a unique 'timeout'.\n */\n-PR_IMPLEMENT(PRStatus)\n-PR_Sleep(PRIntervalTime timeout)\n-{\n-    PRStatus rv = PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_Sleep(PRIntervalTime timeout) {\n+  PRStatus rv = PR_SUCCESS;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  if (PR_INTERVAL_NO_WAIT == timeout) {\n+    /*\n+    ** This is a simple yield, nothing more, nothing less.\n+    */\n+    PRIntn is;\n+    PRThread* me = PR_GetCurrentThread();\n+    PRUintn pri = me->priority;\n+    _PRCPU* cpu = _PR_MD_CURRENT_CPU();\n \n-    if (PR_INTERVAL_NO_WAIT == timeout) {\n-        /*\n-        ** This is a simple yield, nothing more, nothing less.\n-        */\n-        PRIntn is;\n-        PRThread* me = PR_GetCurrentThread();\n-        PRUintn pri = me->priority;\n-        _PRCPU* cpu = _PR_MD_CURRENT_CPU();\n-\n-        if (_PR_IS_NATIVE_THREAD(me)) {\n-            _PR_MD_YIELD();\n-        } else {\n-            _PR_INTSOFF(is);\n-            _PR_RUNQ_LOCK(cpu);\n-            if (_PR_RUNQREADYMASK(cpu) >> pri) {\n-                me->cpu = cpu;\n-                me->state = _PR_RUNNABLE;\n-                _PR_ADD_RUNQ(me, cpu, pri);\n-                _PR_RUNQ_UNLOCK(cpu);\n-\n-                PR_LOG(_pr_sched_lm, PR_LOG_MIN, (\"PR_Yield: yielding\"));\n-                _PR_MD_SWITCH_CONTEXT(me);\n-                PR_LOG(_pr_sched_lm, PR_LOG_MIN, (\"PR_Yield: done\"));\n-\n-                _PR_FAST_INTSON(is);\n-            } else {\n-                _PR_RUNQ_UNLOCK(cpu);\n-                _PR_INTSON(is);\n-            }\n-        }\n+    if (_PR_IS_NATIVE_THREAD(me)) {\n+      _PR_MD_YIELD();\n     } else {\n-        /*\n-        ** This is waiting for some finite period of time.\n-        ** A thread in this state is interruptible (PR_Interrupt()),\n-        ** but the lock and cvar used are local to the implementation\n-        ** and not visible to the caller, therefore not notifiable.\n-        */\n-        PRCondVar* cv;\n-        PRIntervalTime timein;\n-\n-        timein = PR_IntervalNow();\n-        cv = PR_NewCondVar(_pr_sleeplock);\n-        PR_ASSERT(cv != NULL);\n-        PR_Lock(_pr_sleeplock);\n-        do {\n-            PRIntervalTime delta = PR_IntervalNow() - timein;\n-            if (delta > timeout) {\n-                break;\n-            }\n-            rv = PR_WaitCondVar(cv, timeout - delta);\n-        } while (rv == PR_SUCCESS);\n-        PR_Unlock(_pr_sleeplock);\n-        PR_DestroyCondVar(cv);\n+      _PR_INTSOFF(is);\n+      _PR_RUNQ_LOCK(cpu);\n+      if (_PR_RUNQREADYMASK(cpu) >> pri) {\n+        me->cpu = cpu;\n+        me->state = _PR_RUNNABLE;\n+        _PR_ADD_RUNQ(me, cpu, pri);\n+        _PR_RUNQ_UNLOCK(cpu);\n+\n+        PR_LOG(_pr_sched_lm, PR_LOG_MIN, (\"PR_Yield: yielding\"));\n+        _PR_MD_SWITCH_CONTEXT(me);\n+        PR_LOG(_pr_sched_lm, PR_LOG_MIN, (\"PR_Yield: done\"));\n+\n+        _PR_FAST_INTSON(is);\n+      } else {\n+        _PR_RUNQ_UNLOCK(cpu);\n+        _PR_INTSON(is);\n+      }\n     }\n-    return rv;\n+  } else {\n+    /*\n+    ** This is waiting for some finite period of time.\n+    ** A thread in this state is interruptible (PR_Interrupt()),\n+    ** but the lock and cvar used are local to the implementation\n+    ** and not visible to the caller, therefore not notifiable.\n+    */\n+    PRCondVar* cv;\n+    PRIntervalTime timein;\n+\n+    timein = PR_IntervalNow();\n+    cv = PR_NewCondVar(_pr_sleeplock);\n+    PR_ASSERT(cv != NULL);\n+    PR_Lock(_pr_sleeplock);\n+    do {\n+      PRIntervalTime delta = PR_IntervalNow() - timein;\n+      if (delta > timeout) {\n+        break;\n+      }\n+      rv = PR_WaitCondVar(cv, timeout - delta);\n+    } while (rv == PR_SUCCESS);\n+    PR_Unlock(_pr_sleeplock);\n+    PR_DestroyCondVar(cv);\n+  }\n+  return rv;\n }\n \n-PR_IMPLEMENT(PRUint32)\n-PR_GetThreadID(PRThread* thread) { return thread->id; }\n+PR_IMPLEMENT(PRUint32) PR_GetThreadID(PRThread* thread) { return thread->id; }\n \n-PR_IMPLEMENT(PRThreadPriority)\n-PR_GetThreadPriority(const PRThread* thread)\n-{\n-    return (PRThreadPriority)thread->priority;\n+PR_IMPLEMENT(PRThreadPriority) PR_GetThreadPriority(const PRThread* thread) {\n+  return (PRThreadPriority)thread->priority;\n }\n \n-PR_IMPLEMENT(PRThread*)\n-PR_GetCurrentThread()\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    return _PR_MD_CURRENT_THREAD();\n+PR_IMPLEMENT(PRThread*) PR_GetCurrentThread() {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  return _PR_MD_CURRENT_THREAD();\n }\n \n /*\n@@ -150,281 +140,248 @@ PR_GetCurrentThread()\n ** progress will be undone. The interrupt remains in force until\n ** PR_ClearInterrupt is called.\n */\n-PR_IMPLEMENT(PRStatus)\n-PR_Interrupt(PRThread* thread)\n-{\n+PR_IMPLEMENT(PRStatus) PR_Interrupt(PRThread* thread) {\n #ifdef _PR_GLOBAL_THREADS_ONLY\n-    PRCondVar* victim;\n-\n-    _PR_THREAD_LOCK(thread);\n-    thread->flags |= _PR_INTERRUPT;\n-    victim = thread->wait.cvar;\n-    _PR_THREAD_UNLOCK(thread);\n-    if ((NULL != victim) && (!(thread->flags & _PR_INTERRUPT_BLOCKED))) {\n-        int haveLock = (victim->lock->owner == _PR_MD_CURRENT_THREAD());\n-\n-        if (!haveLock) {\n-            PR_Lock(victim->lock);\n-        }\n-        PR_NotifyAllCondVar(victim);\n-        if (!haveLock) {\n-            PR_Unlock(victim->lock);\n-        }\n-    }\n-    return PR_SUCCESS;\n-#else /* ! _PR_GLOBAL_THREADS_ONLY */\n-    PRIntn is;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRCondVar* victim;\n \n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n+  _PR_THREAD_LOCK(thread);\n+  thread->flags |= _PR_INTERRUPT;\n+  victim = thread->wait.cvar;\n+  _PR_THREAD_UNLOCK(thread);\n+  if ((NULL != victim) && (!(thread->flags & _PR_INTERRUPT_BLOCKED))) {\n+    int haveLock = (victim->lock->owner == _PR_MD_CURRENT_THREAD());\n \n-    _PR_THREAD_LOCK(thread);\n-    thread->flags |= _PR_INTERRUPT;\n-    switch (thread->state) {\n-        case _PR_COND_WAIT:\n-            /*\n-             * call is made with thread locked;\n-             * on return lock is released\n-             */\n-            if (!(thread->flags & _PR_INTERRUPT_BLOCKED)) {\n-                _PR_NotifyLockedThread(thread);\n-            }\n-            break;\n-        case _PR_IO_WAIT:\n-            /*\n-             * Need to hold the thread lock when calling\n-             * _PR_Unblock_IO_Wait().  On return lock is\n-             * released.\n-             */\n-#if defined(XP_UNIX) || defined(WINNT)\n-            if (!(thread->flags & _PR_INTERRUPT_BLOCKED)) {\n-                _PR_Unblock_IO_Wait(thread);\n-            }\n-#else\n-            _PR_THREAD_UNLOCK(thread);\n-#endif\n-            break;\n-        case _PR_RUNNING:\n-        case _PR_RUNNABLE:\n-        case _PR_LOCK_WAIT:\n-        default:\n-            _PR_THREAD_UNLOCK(thread);\n-            break;\n+    if (!haveLock) {\n+      PR_Lock(victim->lock);\n     }\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n+    PR_NotifyAllCondVar(victim);\n+    if (!haveLock) {\n+      PR_Unlock(victim->lock);\n     }\n-    return PR_SUCCESS;\n+  }\n+  return PR_SUCCESS;\n+#else /* ! _PR_GLOBAL_THREADS_ONLY */\n+  PRIntn is;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+\n+  _PR_THREAD_LOCK(thread);\n+  thread->flags |= _PR_INTERRUPT;\n+  switch (thread->state) {\n+    case _PR_COND_WAIT:\n+      /*\n+       * call is made with thread locked;\n+       * on return lock is released\n+       */\n+      if (!(thread->flags & _PR_INTERRUPT_BLOCKED)) {\n+        _PR_NotifyLockedThread(thread);\n+      }\n+      break;\n+    case _PR_IO_WAIT:\n+      /*\n+       * Need to hold the thread lock when calling\n+       * _PR_Unblock_IO_Wait().  On return lock is\n+       * released.\n+       */\n+#  if defined(XP_UNIX) || defined(WINNT)\n+      if (!(thread->flags & _PR_INTERRUPT_BLOCKED)) {\n+        _PR_Unblock_IO_Wait(thread);\n+      }\n+#  else\n+      _PR_THREAD_UNLOCK(thread);\n+#  endif\n+      break;\n+    case _PR_RUNNING:\n+    case _PR_RUNNABLE:\n+    case _PR_LOCK_WAIT:\n+    default:\n+      _PR_THREAD_UNLOCK(thread);\n+      break;\n+  }\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n+  return PR_SUCCESS;\n #endif /* _PR_GLOBAL_THREADS_ONLY */\n }\n \n /*\n ** Clear the interrupt flag for self.\n */\n-PR_IMPLEMENT(void)\n-PR_ClearInterrupt()\n-{\n-    PRIntn is;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-    _PR_THREAD_LOCK(me);\n-    me->flags &= ~_PR_INTERRUPT;\n-    _PR_THREAD_UNLOCK(me);\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n-    }\n+PR_IMPLEMENT(void) PR_ClearInterrupt() {\n+  PRIntn is;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+  _PR_THREAD_LOCK(me);\n+  me->flags &= ~_PR_INTERRUPT;\n+  _PR_THREAD_UNLOCK(me);\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n }\n \n-PR_IMPLEMENT(void)\n-PR_BlockInterrupt()\n-{\n-    PRIntn is;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-    _PR_THREAD_LOCK(me);\n-    _PR_THREAD_BLOCK_INTERRUPT(me);\n-    _PR_THREAD_UNLOCK(me);\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n-    }\n+PR_IMPLEMENT(void) PR_BlockInterrupt() {\n+  PRIntn is;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+  _PR_THREAD_LOCK(me);\n+  _PR_THREAD_BLOCK_INTERRUPT(me);\n+  _PR_THREAD_UNLOCK(me);\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n } /* PR_BlockInterrupt */\n \n-PR_IMPLEMENT(void)\n-PR_UnblockInterrupt()\n-{\n-    PRIntn is;\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSOFF(is);\n-    }\n-    _PR_THREAD_LOCK(me);\n-    _PR_THREAD_UNBLOCK_INTERRUPT(me);\n-    _PR_THREAD_UNLOCK(me);\n-    if (!_PR_IS_NATIVE_THREAD(me)) {\n-        _PR_INTSON(is);\n-    }\n+PR_IMPLEMENT(void) PR_UnblockInterrupt() {\n+  PRIntn is;\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSOFF(is);\n+  }\n+  _PR_THREAD_LOCK(me);\n+  _PR_THREAD_UNBLOCK_INTERRUPT(me);\n+  _PR_THREAD_UNLOCK(me);\n+  if (!_PR_IS_NATIVE_THREAD(me)) {\n+    _PR_INTSON(is);\n+  }\n } /* PR_UnblockInterrupt */\n \n /*\n ** Return the thread stack pointer of the given thread.\n */\n-PR_IMPLEMENT(void*)\n-PR_GetSP(PRThread* thread)\n-{\n-    return (void*)_PR_MD_GET_SP(thread);\n+PR_IMPLEMENT(void*) PR_GetSP(PRThread* thread) {\n+  return (void*)_PR_MD_GET_SP(thread);\n }\n \n-PR_IMPLEMENT(void*)\n-GetExecutionEnvironment(PRThread* thread)\n-{\n-    return thread->environment;\n+PR_IMPLEMENT(void*) GetExecutionEnvironment(PRThread* thread) {\n+  return thread->environment;\n }\n \n-PR_IMPLEMENT(void)\n-SetExecutionEnvironment(PRThread* thread, void* env)\n-{\n-    thread->environment = env;\n+PR_IMPLEMENT(void) SetExecutionEnvironment(PRThread* thread, void* env) {\n+  thread->environment = env;\n }\n \n PR_IMPLEMENT(PRInt32)\n-PR_GetThreadAffinityMask(PRThread* thread, PRUint32* mask)\n-{\n+PR_GetThreadAffinityMask(PRThread* thread, PRUint32* mask) {\n #ifdef HAVE_THREAD_AFFINITY\n-    return _PR_MD_GETTHREADAFFINITYMASK(thread, mask);\n+  return _PR_MD_GETTHREADAFFINITYMASK(thread, mask);\n #else\n-    return 0;\n+  return 0;\n #endif\n }\n \n PR_IMPLEMENT(PRInt32)\n-PR_SetThreadAffinityMask(PRThread* thread, PRUint32 mask)\n-{\n+PR_SetThreadAffinityMask(PRThread* thread, PRUint32 mask) {\n #ifdef HAVE_THREAD_AFFINITY\n-    return _PR_MD_SETTHREADAFFINITYMASK(thread, mask);\n+  return _PR_MD_SETTHREADAFFINITYMASK(thread, mask);\n #else\n-    return 0;\n+  return 0;\n #endif\n }\n \n /* This call is thread unsafe if another thread is calling SetConcurrency()\n  */\n-PR_IMPLEMENT(PRInt32)\n-PR_SetCPUAffinityMask(PRUint32 mask)\n-{\n+PR_IMPLEMENT(PRInt32) PR_SetCPUAffinityMask(PRUint32 mask) {\n #ifdef HAVE_THREAD_AFFINITY\n-    PRCList* qp;\n-    extern PRUint32 _pr_cpu_affinity_mask;\n+  PRCList* qp;\n+  extern PRUint32 _pr_cpu_affinity_mask;\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    _pr_cpu_affinity_mask = mask;\n+  _pr_cpu_affinity_mask = mask;\n \n-    qp = _PR_CPUQ().next;\n-    while (qp != &_PR_CPUQ()) {\n-        _PRCPU* cpu;\n+  qp = _PR_CPUQ().next;\n+  while (qp != &_PR_CPUQ()) {\n+    _PRCPU* cpu;\n \n-        cpu = _PR_CPU_PTR(qp);\n-        PR_SetThreadAffinityMask(cpu->thread, mask);\n+    cpu = _PR_CPU_PTR(qp);\n+    PR_SetThreadAffinityMask(cpu->thread, mask);\n \n-        qp = qp->next;\n-    }\n+    qp = qp->next;\n+  }\n #endif\n \n-    return 0;\n+  return 0;\n }\n \n PRUint32 _pr_recycleThreads = 0;\n-PR_IMPLEMENT(void)\n-PR_SetThreadRecycleMode(PRUint32 count)\n-{\n-    _pr_recycleThreads = count;\n+PR_IMPLEMENT(void) PR_SetThreadRecycleMode(PRUint32 count) {\n+  _pr_recycleThreads = count;\n }\n \n PR_IMPLEMENT(PRThread*)\n PR_CreateThreadGCAble(PRThreadType type, void (*start)(void* arg), void* arg,\n                       PRThreadPriority priority, PRThreadScope scope,\n-                      PRThreadState state, PRUint32 stackSize)\n-{\n-    return _PR_CreateThread(type, start, arg, priority, scope, state, stackSize,\n-                            _PR_GCABLE_THREAD);\n+                      PRThreadState state, PRUint32 stackSize) {\n+  return _PR_CreateThread(type, start, arg, priority, scope, state, stackSize,\n+                          _PR_GCABLE_THREAD);\n }\n \n #ifdef SOLARIS\n PR_IMPLEMENT(PRThread*)\n PR_CreateThreadBound(PRThreadType type, void (*start)(void* arg), void* arg,\n                      PRUintn priority, PRThreadScope scope, PRThreadState state,\n-                     PRUint32 stackSize)\n-{\n-    return _PR_CreateThread(type, start, arg, priority, scope, state, stackSize,\n-                            _PR_BOUND_THREAD);\n+                     PRUint32 stackSize) {\n+  return _PR_CreateThread(type, start, arg, priority, scope, state, stackSize,\n+                          _PR_BOUND_THREAD);\n }\n #endif\n \n PR_IMPLEMENT(PRThread*)\n PR_AttachThreadGCAble(PRThreadType type, PRThreadPriority priority,\n-                      PRThreadStack* stack)\n-{\n-    /* $$$$ not sure how to finese this one */\n-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-    return NULL;\n+                      PRThreadStack* stack) {\n+  /* $$$$ not sure how to finese this one */\n+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+  return NULL;\n }\n \n-PR_IMPLEMENT(void)\n-PR_SetThreadGCAble()\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    PR_Lock(_pr_activeLock);\n-    _PR_MD_CURRENT_THREAD()->flags |= _PR_GCABLE_THREAD;\n-    PR_Unlock(_pr_activeLock);\n+PR_IMPLEMENT(void) PR_SetThreadGCAble() {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  PR_Lock(_pr_activeLock);\n+  _PR_MD_CURRENT_THREAD()->flags |= _PR_GCABLE_THREAD;\n+  PR_Unlock(_pr_activeLock);\n }\n \n-PR_IMPLEMENT(void)\n-PR_ClearThreadGCAble()\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-    PR_Lock(_pr_activeLock);\n-    _PR_MD_CURRENT_THREAD()->flags &= (~_PR_GCABLE_THREAD);\n-    PR_Unlock(_pr_activeLock);\n+PR_IMPLEMENT(void) PR_ClearThreadGCAble() {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+  PR_Lock(_pr_activeLock);\n+  _PR_MD_CURRENT_THREAD()->flags &= (~_PR_GCABLE_THREAD);\n+  PR_Unlock(_pr_activeLock);\n }\n \n-PR_IMPLEMENT(PRThreadScope)\n-PR_GetThreadScope(const PRThread* thread)\n-{\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    if (_PR_IS_NATIVE_THREAD(thread)) {\n-        return (thread->flags & _PR_BOUND_THREAD) ? PR_GLOBAL_BOUND_THREAD\n-                                                  : PR_GLOBAL_THREAD;\n-    } else {\n-        return PR_LOCAL_THREAD;\n-    }\n+PR_IMPLEMENT(PRThreadScope) PR_GetThreadScope(const PRThread* thread) {\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  if (_PR_IS_NATIVE_THREAD(thread)) {\n+    return (thread->flags & _PR_BOUND_THREAD) ? PR_GLOBAL_BOUND_THREAD\n+                                              : PR_GLOBAL_THREAD;\n+  } else {\n+    return PR_LOCAL_THREAD;\n+  }\n }\n \n-PR_IMPLEMENT(PRThreadType)\n-PR_GetThreadType(const PRThread* thread)\n-{\n-    return (thread->flags & _PR_SYSTEM) ? PR_SYSTEM_THREAD : PR_USER_THREAD;\n+PR_IMPLEMENT(PRThreadType) PR_GetThreadType(const PRThread* thread) {\n+  return (thread->flags & _PR_SYSTEM) ? PR_SYSTEM_THREAD : PR_USER_THREAD;\n }\n \n-PR_IMPLEMENT(PRThreadState)\n-PR_GetThreadState(const PRThread* thread)\n-{\n-    return (NULL == thread->term) ? PR_UNJOINABLE_THREAD : PR_JOINABLE_THREAD;\n+PR_IMPLEMENT(PRThreadState) PR_GetThreadState(const PRThread* thread) {\n+  return (NULL == thread->term) ? PR_UNJOINABLE_THREAD : PR_JOINABLE_THREAD;\n } /* PR_GetThreadState */\ndiff --git a/nspr/pr/src/threads/prdump.c b/nspr/pr/src/threads/prdump.c\nindex d79f301..8e63336 100644\n--- a/nspr/pr/src/threads/prdump.c\n+++ b/nspr/pr/src/threads/prdump.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,118 +12,107 @@\n ** The pragma suppresses the warning.\n **\n */\n-#pragma warning(disable : 4101)\n+#  pragma warning(disable : 4101)\n #endif\n \n /* XXX use unbuffered nspr stdio */\n \n PRFileDesc* _pr_dumpOut;\n \n-PRUint32\n-_PR_DumpPrintf(PRFileDesc* fd, const char* fmt, ...)\n-{\n-    char buf[100];\n-    PRUint32 nb;\n-    va_list ap;\n+PRUint32 _PR_DumpPrintf(PRFileDesc* fd, const char* fmt, ...) {\n+  char buf[100];\n+  PRUint32 nb;\n+  va_list ap;\n \n-    va_start(ap, fmt);\n-    nb = PR_vsnprintf(buf, sizeof(buf), fmt, ap);\n-    va_end(ap);\n-    PR_Write(fd, buf, nb);\n+  va_start(ap, fmt);\n+  nb = PR_vsnprintf(buf, sizeof(buf), fmt, ap);\n+  va_end(ap);\n+  PR_Write(fd, buf, nb);\n \n-    return nb;\n+  return nb;\n }\n \n-void\n-_PR_DumpThread(PRFileDesc* fd, PRThread* thread)\n-{\n+void _PR_DumpThread(PRFileDesc* fd, PRThread* thread) {\n #ifndef _PR_GLOBAL_THREADS_ONLY\n-    _PR_DumpPrintf(fd, \"%05d[%08p] pri=%2d flags=0x%02x\", thread->id, thread,\n-                   thread->priority, thread->flags);\n-    switch (thread->state) {\n-        case _PR_RUNNABLE:\n-        case _PR_RUNNING:\n-            break;\n-        case _PR_LOCK_WAIT:\n-            _PR_DumpPrintf(fd, \" lock=%p\", thread->wait.lock);\n-            break;\n-        case _PR_COND_WAIT:\n-            _PR_DumpPrintf(fd, \" condvar=%p sleep=%lldms\", thread->wait.cvar,\n-                           thread->sleep);\n-            break;\n-        case _PR_SUSPENDED:\n-            _PR_DumpPrintf(fd, \" suspended\");\n-            break;\n-    }\n-    PR_Write(fd, \"\\n\", 1);\n+  _PR_DumpPrintf(fd, \"%05d[%08p] pri=%2d flags=0x%02x\", thread->id, thread,\n+                 thread->priority, thread->flags);\n+  switch (thread->state) {\n+    case _PR_RUNNABLE:\n+    case _PR_RUNNING:\n+      break;\n+    case _PR_LOCK_WAIT:\n+      _PR_DumpPrintf(fd, \" lock=%p\", thread->wait.lock);\n+      break;\n+    case _PR_COND_WAIT:\n+      _PR_DumpPrintf(fd, \" condvar=%p sleep=%lldms\", thread->wait.cvar,\n+                     thread->sleep);\n+      break;\n+    case _PR_SUSPENDED:\n+      _PR_DumpPrintf(fd, \" suspended\");\n+      break;\n+  }\n+  PR_Write(fd, \"\\n\", 1);\n #endif\n \n-    /* Now call dump routine */\n-    if (thread->dump) {\n-        thread->dump(fd, thread, thread->dumpArg);\n-    }\n+  /* Now call dump routine */\n+  if (thread->dump) {\n+    thread->dump(fd, thread, thread->dumpArg);\n+  }\n }\n \n-static void\n-DumpThreadQueue(PRFileDesc* fd, PRCList* list)\n-{\n+static void DumpThreadQueue(PRFileDesc* fd, PRCList* list) {\n #ifndef _PR_GLOBAL_THREADS_ONLY\n-    PRCList* q;\n-\n-    q = list->next;\n-    while (q != list) {\n-        PRThread* t = _PR_THREAD_PTR(q);\n-        _PR_DumpThread(fd, t);\n-        q = q->next;\n-    }\n+  PRCList* q;\n+\n+  q = list->next;\n+  while (q != list) {\n+    PRThread* t = _PR_THREAD_PTR(q);\n+    _PR_DumpThread(fd, t);\n+    q = q->next;\n+  }\n #endif\n }\n \n-void\n-_PR_DumpThreads(PRFileDesc* fd)\n-{\n-    PRThread* t;\n-    PRIntn i;\n+void _PR_DumpThreads(PRFileDesc* fd) {\n+  PRThread* t;\n+  PRIntn i;\n \n-    _PR_DumpPrintf(fd, \"Current Thread:\\n\");\n-    t = _PR_MD_CURRENT_THREAD();\n-    _PR_DumpThread(fd, t);\n+  _PR_DumpPrintf(fd, \"Current Thread:\\n\");\n+  t = _PR_MD_CURRENT_THREAD();\n+  _PR_DumpThread(fd, t);\n \n-    _PR_DumpPrintf(fd, \"Runnable Threads:\\n\");\n-    for (i = 0; i < PR_ARRAY_SIZE(_PR_RUNQ(t->cpu)); i++) {\n-        DumpThreadQueue(fd, &_PR_RUNQ(t->cpu)[i]);\n-    }\n+  _PR_DumpPrintf(fd, \"Runnable Threads:\\n\");\n+  for (i = 0; i < PR_ARRAY_SIZE(_PR_RUNQ(t->cpu)); i++) {\n+    DumpThreadQueue(fd, &_PR_RUNQ(t->cpu)[i]);\n+  }\n \n-    _PR_DumpPrintf(fd, \"CondVar timed wait Threads:\\n\");\n-    DumpThreadQueue(fd, &_PR_SLEEPQ(t->cpu));\n+  _PR_DumpPrintf(fd, \"CondVar timed wait Threads:\\n\");\n+  DumpThreadQueue(fd, &_PR_SLEEPQ(t->cpu));\n \n-    _PR_DumpPrintf(fd, \"CondVar wait Threads:\\n\");\n-    DumpThreadQueue(fd, &_PR_PAUSEQ(t->cpu));\n+  _PR_DumpPrintf(fd, \"CondVar wait Threads:\\n\");\n+  DumpThreadQueue(fd, &_PR_PAUSEQ(t->cpu));\n \n-    _PR_DumpPrintf(fd, \"Suspended Threads:\\n\");\n-    DumpThreadQueue(fd, &_PR_SUSPENDQ(t->cpu));\n+  _PR_DumpPrintf(fd, \"Suspended Threads:\\n\");\n+  DumpThreadQueue(fd, &_PR_SUSPENDQ(t->cpu));\n }\n \n-PR_IMPLEMENT(void)\n-PR_ShowStatus(void)\n-{\n-    PRIntn is;\n-\n-    if (_PR_MD_CURRENT_THREAD() &&\n-        !_PR_IS_NATIVE_THREAD(_PR_MD_CURRENT_THREAD())) {\n-        _PR_INTSOFF(is);\n-    }\n-    _pr_dumpOut = _pr_stderr;\n-    _PR_DumpThreads(_pr_dumpOut);\n-    if (_PR_MD_CURRENT_THREAD() &&\n-        !_PR_IS_NATIVE_THREAD(_PR_MD_CURRENT_THREAD())) {\n-        _PR_FAST_INTSON(is);\n-    }\n+PR_IMPLEMENT(void) PR_ShowStatus(void) {\n+  PRIntn is;\n+\n+  if (_PR_MD_CURRENT_THREAD() &&\n+      !_PR_IS_NATIVE_THREAD(_PR_MD_CURRENT_THREAD())) {\n+    _PR_INTSOFF(is);\n+  }\n+  _pr_dumpOut = _pr_stderr;\n+  _PR_DumpThreads(_pr_dumpOut);\n+  if (_PR_MD_CURRENT_THREAD() &&\n+      !_PR_IS_NATIVE_THREAD(_PR_MD_CURRENT_THREAD())) {\n+    _PR_FAST_INTSON(is);\n+  }\n }\n \n PR_IMPLEMENT(void)\n-PR_SetThreadDumpProc(PRThread* thread, PRThreadDumpProc dump, void* arg)\n-{\n-    thread->dump = dump;\n-    thread->dumpArg = arg;\n+PR_SetThreadDumpProc(PRThread* thread, PRThreadDumpProc dump, void* arg) {\n+  thread->dump = dump;\n+  thread->dumpArg = arg;\n }\ndiff --git a/nspr/pr/src/threads/prmon.c b/nspr/pr/src/threads/prmon.c\nindex d2c345e..a067c2f 100644\n--- a/nspr/pr/src/threads/prmon.c\n+++ b/nspr/pr/src/threads/prmon.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,105 +12,97 @@\n  * when the monitor is fully exited so that MP systems don't contend for a\n  * monitor that they can't enter.\n  */\n-static void\n-_PR_PostNotifyToMonitor(PRMonitor* mon, PRBool broadcast)\n-{\n-    PR_ASSERT(mon != NULL);\n-    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mon);\n-\n-    /* mon->notifyTimes is protected by the monitor, so we don't need to\n-     * acquire mon->lock.\n-     */\n-    if (broadcast) {\n-        mon->notifyTimes = -1;\n-    } else if (mon->notifyTimes != -1) {\n-        mon->notifyTimes += 1;\n-    }\n+static void _PR_PostNotifyToMonitor(PRMonitor* mon, PRBool broadcast) {\n+  PR_ASSERT(mon != NULL);\n+  PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mon);\n+\n+  /* mon->notifyTimes is protected by the monitor, so we don't need to\n+   * acquire mon->lock.\n+   */\n+  if (broadcast) {\n+    mon->notifyTimes = -1;\n+  } else if (mon->notifyTimes != -1) {\n+    mon->notifyTimes += 1;\n+  }\n }\n \n-static void\n-_PR_PostNotifiesFromMonitor(PRCondVar* cv, PRIntn times)\n-{\n-    PRStatus rv;\n-\n-    /*\n-     * Time to actually notify any waits that were affected while the monitor\n-     * was entered.\n-     */\n-    PR_ASSERT(cv != NULL);\n-    PR_ASSERT(times != 0);\n-    if (times == -1) {\n-        rv = PR_NotifyAllCondVar(cv);\n-        PR_ASSERT(rv == PR_SUCCESS);\n-    } else {\n-        while (times-- > 0) {\n-            rv = PR_NotifyCondVar(cv);\n-            PR_ASSERT(rv == PR_SUCCESS);\n-        }\n+static void _PR_PostNotifiesFromMonitor(PRCondVar* cv, PRIntn times) {\n+  PRStatus rv;\n+\n+  /*\n+   * Time to actually notify any waits that were affected while the monitor\n+   * was entered.\n+   */\n+  PR_ASSERT(cv != NULL);\n+  PR_ASSERT(times != 0);\n+  if (times == -1) {\n+    rv = PR_NotifyAllCondVar(cv);\n+    PR_ASSERT(rv == PR_SUCCESS);\n+  } else {\n+    while (times-- > 0) {\n+      rv = PR_NotifyCondVar(cv);\n+      PR_ASSERT(rv == PR_SUCCESS);\n     }\n+  }\n }\n \n /*\n ** Create a new monitor.\n */\n-PR_IMPLEMENT(PRMonitor*)\n-PR_NewMonitor()\n-{\n-    PRMonitor* mon;\n-    PRStatus rv;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n+PR_IMPLEMENT(PRMonitor*) PR_NewMonitor() {\n+  PRMonitor* mon;\n+  PRStatus rv;\n \n-    mon = PR_NEWZAP(PRMonitor);\n-    if (mon == NULL) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    rv = _PR_InitLock(&mon->lock);\n-    PR_ASSERT(rv == PR_SUCCESS);\n-    if (rv != PR_SUCCESS) {\n-        goto error1;\n-    }\n+  mon = PR_NEWZAP(PRMonitor);\n+  if (mon == NULL) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n \n-    mon->owner = NULL;\n+  rv = _PR_InitLock(&mon->lock);\n+  PR_ASSERT(rv == PR_SUCCESS);\n+  if (rv != PR_SUCCESS) {\n+    goto error1;\n+  }\n \n-    rv = _PR_InitCondVar(&mon->entryCV, &mon->lock);\n-    PR_ASSERT(rv == PR_SUCCESS);\n-    if (rv != PR_SUCCESS) {\n-        goto error2;\n-    }\n+  mon->owner = NULL;\n \n-    rv = _PR_InitCondVar(&mon->waitCV, &mon->lock);\n-    PR_ASSERT(rv == PR_SUCCESS);\n-    if (rv != PR_SUCCESS) {\n-        goto error3;\n-    }\n+  rv = _PR_InitCondVar(&mon->entryCV, &mon->lock);\n+  PR_ASSERT(rv == PR_SUCCESS);\n+  if (rv != PR_SUCCESS) {\n+    goto error2;\n+  }\n \n-    mon->notifyTimes = 0;\n-    mon->entryCount = 0;\n-    mon->name = NULL;\n-    return mon;\n+  rv = _PR_InitCondVar(&mon->waitCV, &mon->lock);\n+  PR_ASSERT(rv == PR_SUCCESS);\n+  if (rv != PR_SUCCESS) {\n+    goto error3;\n+  }\n+\n+  mon->notifyTimes = 0;\n+  mon->entryCount = 0;\n+  mon->name = NULL;\n+  return mon;\n \n error3:\n-    _PR_FreeCondVar(&mon->entryCV);\n+  _PR_FreeCondVar(&mon->entryCV);\n error2:\n-    _PR_FreeLock(&mon->lock);\n+  _PR_FreeLock(&mon->lock);\n error1:\n-    PR_Free(mon);\n-    return NULL;\n+  PR_Free(mon);\n+  return NULL;\n }\n \n-PR_IMPLEMENT(PRMonitor*)\n-PR_NewNamedMonitor(const char* name)\n-{\n-    PRMonitor* mon = PR_NewMonitor();\n-    if (mon) {\n-        mon->name = name;\n-    }\n-    return mon;\n+PR_IMPLEMENT(PRMonitor*) PR_NewNamedMonitor(const char* name) {\n+  PRMonitor* mon = PR_NewMonitor();\n+  if (mon) {\n+    mon->name = name;\n+  }\n+  return mon;\n }\n \n /*\n@@ -117,48 +110,44 @@ PR_NewNamedMonitor(const char* name)\n ** condition variable. The caller is responsible for guaranteeing that the\n ** monitor is no longer in use.\n */\n-PR_IMPLEMENT(void)\n-PR_DestroyMonitor(PRMonitor* mon)\n-{\n-    PR_ASSERT(mon != NULL);\n-    _PR_FreeCondVar(&mon->waitCV);\n-    _PR_FreeCondVar(&mon->entryCV);\n-    _PR_FreeLock(&mon->lock);\n+PR_IMPLEMENT(void) PR_DestroyMonitor(PRMonitor* mon) {\n+  PR_ASSERT(mon != NULL);\n+  _PR_FreeCondVar(&mon->waitCV);\n+  _PR_FreeCondVar(&mon->entryCV);\n+  _PR_FreeLock(&mon->lock);\n #if defined(DEBUG)\n-    memset(mon, 0xaf, sizeof(PRMonitor));\n+  memset(mon, 0xaf, sizeof(PRMonitor));\n #endif\n-    PR_Free(mon);\n+  PR_Free(mon);\n }\n \n /*\n ** Enter the lock associated with the monitor.\n */\n-PR_IMPLEMENT(void)\n-PR_EnterMonitor(PRMonitor* mon)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRStatus rv;\n-\n-    PR_ASSERT(mon != NULL);\n-    PR_Lock(&mon->lock);\n-    if (mon->entryCount != 0) {\n-        if (mon->owner == me) {\n-            goto done;\n-        }\n-        while (mon->entryCount != 0) {\n-            rv = PR_WaitCondVar(&mon->entryCV, PR_INTERVAL_NO_TIMEOUT);\n-            PR_ASSERT(rv == PR_SUCCESS);\n-        }\n+PR_IMPLEMENT(void) PR_EnterMonitor(PRMonitor* mon) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRStatus rv;\n+\n+  PR_ASSERT(mon != NULL);\n+  PR_Lock(&mon->lock);\n+  if (mon->entryCount != 0) {\n+    if (mon->owner == me) {\n+      goto done;\n     }\n-    /* and now I have the monitor */\n-    PR_ASSERT(mon->notifyTimes == 0);\n-    PR_ASSERT(mon->owner == NULL);\n-    mon->owner = me;\n+    while (mon->entryCount != 0) {\n+      rv = PR_WaitCondVar(&mon->entryCV, PR_INTERVAL_NO_TIMEOUT);\n+      PR_ASSERT(rv == PR_SUCCESS);\n+    }\n+  }\n+  /* and now I have the monitor */\n+  PR_ASSERT(mon->notifyTimes == 0);\n+  PR_ASSERT(mon->owner == NULL);\n+  mon->owner = me;\n \n done:\n-    mon->entryCount += 1;\n-    rv = PR_Unlock(&mon->lock);\n-    PR_ASSERT(rv == PR_SUCCESS);\n+  mon->entryCount += 1;\n+  rv = PR_Unlock(&mon->lock);\n+  PR_ASSERT(rv == PR_SUCCESS);\n }\n \n /*\n@@ -166,101 +155,93 @@ done:\n ** already entered by some other thread. Return PR_FALSE if some other\n ** thread owned the lock at the time of the call.\n */\n-PR_IMPLEMENT(PRBool)\n-PR_TestAndEnterMonitor(PRMonitor* mon)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRStatus rv;\n-\n-    PR_ASSERT(mon != NULL);\n-    PR_Lock(&mon->lock);\n-    if (mon->entryCount != 0) {\n-        if (mon->owner == me) {\n-            goto done;\n-        }\n-        rv = PR_Unlock(&mon->lock);\n-        PR_ASSERT(rv == PR_SUCCESS);\n-        return PR_FALSE;\n-    }\n-    /* and now I have the monitor */\n-    PR_ASSERT(mon->notifyTimes == 0);\n-    PR_ASSERT(mon->owner == NULL);\n-    mon->owner = me;\n+PR_IMPLEMENT(PRBool) PR_TestAndEnterMonitor(PRMonitor* mon) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRStatus rv;\n \n-done:\n-    mon->entryCount += 1;\n+  PR_ASSERT(mon != NULL);\n+  PR_Lock(&mon->lock);\n+  if (mon->entryCount != 0) {\n+    if (mon->owner == me) {\n+      goto done;\n+    }\n     rv = PR_Unlock(&mon->lock);\n     PR_ASSERT(rv == PR_SUCCESS);\n-    return PR_TRUE;\n+    return PR_FALSE;\n+  }\n+  /* and now I have the monitor */\n+  PR_ASSERT(mon->notifyTimes == 0);\n+  PR_ASSERT(mon->owner == NULL);\n+  mon->owner = me;\n+\n+done:\n+  mon->entryCount += 1;\n+  rv = PR_Unlock(&mon->lock);\n+  PR_ASSERT(rv == PR_SUCCESS);\n+  return PR_TRUE;\n }\n \n /*\n ** Exit the lock associated with the monitor once.\n */\n-PR_IMPLEMENT(PRStatus)\n-PR_ExitMonitor(PRMonitor* mon)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRStatus rv;\n-\n-    PR_ASSERT(mon != NULL);\n-    PR_Lock(&mon->lock);\n-    /* the entries should be > 0 and we'd better be the owner */\n-    PR_ASSERT(mon->entryCount > 0);\n-    PR_ASSERT(mon->owner == me);\n-    if (mon->entryCount == 0 || mon->owner != me) {\n-        rv = PR_Unlock(&mon->lock);\n-        PR_ASSERT(rv == PR_SUCCESS);\n-        return PR_FAILURE;\n-    }\n+PR_IMPLEMENT(PRStatus) PR_ExitMonitor(PRMonitor* mon) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRStatus rv;\n+\n+  PR_ASSERT(mon != NULL);\n+  PR_Lock(&mon->lock);\n+  /* the entries should be > 0 and we'd better be the owner */\n+  PR_ASSERT(mon->entryCount > 0);\n+  PR_ASSERT(mon->owner == me);\n+  if (mon->entryCount == 0 || mon->owner != me) {\n+    rv = PR_Unlock(&mon->lock);\n+    PR_ASSERT(rv == PR_SUCCESS);\n+    return PR_FAILURE;\n+  }\n \n-    mon->entryCount -= 1; /* reduce by one */\n-    if (mon->entryCount == 0) {\n-        /* and if it transitioned to zero - notify an entry waiter */\n-        /* make the owner unknown */\n-        mon->owner = NULL;\n-        if (mon->notifyTimes != 0) {\n-            _PR_PostNotifiesFromMonitor(&mon->waitCV, mon->notifyTimes);\n-            mon->notifyTimes = 0;\n-        }\n-        rv = PR_NotifyCondVar(&mon->entryCV);\n-        PR_ASSERT(rv == PR_SUCCESS);\n+  mon->entryCount -= 1; /* reduce by one */\n+  if (mon->entryCount == 0) {\n+    /* and if it transitioned to zero - notify an entry waiter */\n+    /* make the owner unknown */\n+    mon->owner = NULL;\n+    if (mon->notifyTimes != 0) {\n+      _PR_PostNotifiesFromMonitor(&mon->waitCV, mon->notifyTimes);\n+      mon->notifyTimes = 0;\n     }\n-    rv = PR_Unlock(&mon->lock);\n+    rv = PR_NotifyCondVar(&mon->entryCV);\n     PR_ASSERT(rv == PR_SUCCESS);\n-    return PR_SUCCESS;\n+  }\n+  rv = PR_Unlock(&mon->lock);\n+  PR_ASSERT(rv == PR_SUCCESS);\n+  return PR_SUCCESS;\n }\n \n /*\n ** Return the number of times that the current thread has entered the\n ** lock. Returns zero if the current thread has not entered the lock.\n */\n-PR_IMPLEMENT(PRIntn)\n-PR_GetMonitorEntryCount(PRMonitor* mon)\n-{\n-    PRThread* me = _PR_MD_CURRENT_THREAD();\n-    PRStatus rv;\n-    PRIntn count = 0;\n-\n-    PR_Lock(&mon->lock);\n-    if (mon->owner == me) {\n-        count = mon->entryCount;\n-    }\n-    rv = PR_Unlock(&mon->lock);\n-    PR_ASSERT(rv == PR_SUCCESS);\n-    return count;\n+PR_IMPLEMENT(PRIntn) PR_GetMonitorEntryCount(PRMonitor* mon) {\n+  PRThread* me = _PR_MD_CURRENT_THREAD();\n+  PRStatus rv;\n+  PRIntn count = 0;\n+\n+  PR_Lock(&mon->lock);\n+  if (mon->owner == me) {\n+    count = mon->entryCount;\n+  }\n+  rv = PR_Unlock(&mon->lock);\n+  PR_ASSERT(rv == PR_SUCCESS);\n+  return count;\n }\n \n-PR_IMPLEMENT(void)\n-PR_AssertCurrentThreadInMonitor(PRMonitor* mon)\n-{\n+PR_IMPLEMENT(void) PR_AssertCurrentThreadInMonitor(PRMonitor* mon) {\n #if defined(DEBUG) || defined(FORCE_PR_ASSERT)\n-    PRStatus rv;\n+  PRStatus rv;\n \n-    PR_Lock(&mon->lock);\n-    PR_ASSERT(mon->entryCount != 0 && mon->owner == _PR_MD_CURRENT_THREAD());\n-    rv = PR_Unlock(&mon->lock);\n-    PR_ASSERT(rv == PR_SUCCESS);\n+  PR_Lock(&mon->lock);\n+  PR_ASSERT(mon->entryCount != 0 && mon->owner == _PR_MD_CURRENT_THREAD());\n+  rv = PR_Unlock(&mon->lock);\n+  PR_ASSERT(rv == PR_SUCCESS);\n #endif\n }\n \n@@ -281,48 +262,46 @@ PR_AssertCurrentThreadInMonitor(PRMonitor* mon)\n ** This routine can return PR_PENDING_INTERRUPT_ERROR if the waiting thread\n ** has been interrupted.\n */\n-PR_IMPLEMENT(PRStatus)\n-PR_Wait(PRMonitor* mon, PRIntervalTime ticks)\n-{\n-    PRStatus rv;\n-    PRUint32 saved_entries;\n-    PRThread* saved_owner;\n-\n-    PR_ASSERT(mon != NULL);\n-    PR_Lock(&mon->lock);\n-    /* the entries better be positive */\n-    PR_ASSERT(mon->entryCount > 0);\n-    /* and it better be owned by us */\n-    PR_ASSERT(mon->owner == _PR_MD_CURRENT_THREAD()); /* XXX return failure */\n-\n-    /* tuck these away 'till later */\n-    saved_entries = mon->entryCount;\n-    mon->entryCount = 0;\n-    saved_owner = mon->owner;\n-    mon->owner = NULL;\n-    /* If we have pending notifies, post them now. */\n-    if (mon->notifyTimes != 0) {\n-        _PR_PostNotifiesFromMonitor(&mon->waitCV, mon->notifyTimes);\n-        mon->notifyTimes = 0;\n-    }\n-    rv = PR_NotifyCondVar(&mon->entryCV);\n-    PR_ASSERT(rv == PR_SUCCESS);\n-\n-    rv = PR_WaitCondVar(&mon->waitCV, ticks);\n-    PR_ASSERT(rv == PR_SUCCESS);\n+PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor* mon, PRIntervalTime ticks) {\n+  PRStatus rv;\n+  PRUint32 saved_entries;\n+  PRThread* saved_owner;\n+\n+  PR_ASSERT(mon != NULL);\n+  PR_Lock(&mon->lock);\n+  /* the entries better be positive */\n+  PR_ASSERT(mon->entryCount > 0);\n+  /* and it better be owned by us */\n+  PR_ASSERT(mon->owner == _PR_MD_CURRENT_THREAD()); /* XXX return failure */\n+\n+  /* tuck these away 'till later */\n+  saved_entries = mon->entryCount;\n+  mon->entryCount = 0;\n+  saved_owner = mon->owner;\n+  mon->owner = NULL;\n+  /* If we have pending notifies, post them now. */\n+  if (mon->notifyTimes != 0) {\n+    _PR_PostNotifiesFromMonitor(&mon->waitCV, mon->notifyTimes);\n+    mon->notifyTimes = 0;\n+  }\n+  rv = PR_NotifyCondVar(&mon->entryCV);\n+  PR_ASSERT(rv == PR_SUCCESS);\n \n-    while (mon->entryCount != 0) {\n-        rv = PR_WaitCondVar(&mon->entryCV, PR_INTERVAL_NO_TIMEOUT);\n-        PR_ASSERT(rv == PR_SUCCESS);\n-    }\n-    PR_ASSERT(mon->notifyTimes == 0);\n-    /* reinstate the interesting information */\n-    mon->entryCount = saved_entries;\n-    mon->owner = saved_owner;\n+  rv = PR_WaitCondVar(&mon->waitCV, ticks);\n+  PR_ASSERT(rv == PR_SUCCESS);\n \n-    rv = PR_Unlock(&mon->lock);\n+  while (mon->entryCount != 0) {\n+    rv = PR_WaitCondVar(&mon->entryCV, PR_INTERVAL_NO_TIMEOUT);\n     PR_ASSERT(rv == PR_SUCCESS);\n-    return rv;\n+  }\n+  PR_ASSERT(mon->notifyTimes == 0);\n+  /* reinstate the interesting information */\n+  mon->entryCount = saved_entries;\n+  mon->owner = saved_owner;\n+\n+  rv = PR_Unlock(&mon->lock);\n+  PR_ASSERT(rv == PR_SUCCESS);\n+  return rv;\n }\n \n /*\n@@ -330,11 +309,9 @@ PR_Wait(PRMonitor* mon, PRIntervalTime ticks)\n ** variable. If a thread is waiting on the condition variable (using\n ** PR_Wait) then it is awakened and begins waiting on the monitor's lock.\n */\n-PR_IMPLEMENT(PRStatus)\n-PR_Notify(PRMonitor* mon)\n-{\n-    _PR_PostNotifyToMonitor(mon, PR_FALSE);\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_Notify(PRMonitor* mon) {\n+  _PR_PostNotifyToMonitor(mon, PR_FALSE);\n+  return PR_SUCCESS;\n }\n \n /*\n@@ -342,25 +319,21 @@ PR_Notify(PRMonitor* mon)\n ** threads are notified in turn. The highest priority thread will\n ** probably acquire the monitor first when the monitor is exited.\n */\n-PR_IMPLEMENT(PRStatus)\n-PR_NotifyAll(PRMonitor* mon)\n-{\n-    _PR_PostNotifyToMonitor(mon, PR_TRUE);\n-    return PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_NotifyAll(PRMonitor* mon) {\n+  _PR_PostNotifyToMonitor(mon, PR_TRUE);\n+  return PR_SUCCESS;\n }\n \n /************************************************************************/\n \n-PRUint32\n-_PR_MonitorToString(PRMonitor* mon, char* buf, PRUint32 buflen)\n-{\n-    PRUint32 nb;\n+PRUint32 _PR_MonitorToString(PRMonitor* mon, char* buf, PRUint32 buflen) {\n+  PRUint32 nb;\n \n-    if (mon->owner) {\n-        nb = PR_snprintf(buf, buflen, \"[%p] owner=%d[%p] count=%ld\", mon,\n-                         mon->owner->id, mon->owner, mon->entryCount);\n-    } else {\n-        nb = PR_snprintf(buf, buflen, \"[%p]\", mon);\n-    }\n-    return nb;\n+  if (mon->owner) {\n+    nb = PR_snprintf(buf, buflen, \"[%p] owner=%d[%p] count=%ld\", mon,\n+                     mon->owner->id, mon->owner, mon->entryCount);\n+  } else {\n+    nb = PR_snprintf(buf, buflen, \"[%p]\", mon);\n+  }\n+  return nb;\n }\ndiff --git a/nspr/pr/src/threads/prrwlock.c b/nspr/pr/src/threads/prrwlock.c\nindex a8f3fb8..bb61cc3 100644\n--- a/nspr/pr/src/threads/prrwlock.c\n+++ b/nspr/pr/src/threads/prrwlock.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,14 +10,14 @@\n #if defined(SOLARIS) && \\\n     (defined(_PR_PTHREADS) || defined(_PR_GLOBAL_THREADS_ONLY))\n \n-#include <synch.h>\n-#define HAVE_UI_RWLOCK\n-#define RWLOCK_T rwlock_t\n-#define RWLOCK_INIT(lock) rwlock_init(lock, USYNC_THREAD, NULL)\n-#define RWLOCK_DESTROY(lock) rwlock_destroy(lock)\n-#define RWLOCK_RDLOCK(lock) rw_rdlock(lock)\n-#define RWLOCK_WRLOCK(lock) rw_wrlock(lock)\n-#define RWLOCK_UNLOCK(lock) rw_unlock(lock)\n+#  include <synch.h>\n+#  define HAVE_UI_RWLOCK\n+#  define RWLOCK_T rwlock_t\n+#  define RWLOCK_INIT(lock) rwlock_init(lock, USYNC_THREAD, NULL)\n+#  define RWLOCK_DESTROY(lock) rwlock_destroy(lock)\n+#  define RWLOCK_RDLOCK(lock) rw_rdlock(lock)\n+#  define RWLOCK_WRLOCK(lock) rw_wrlock(lock)\n+#  define RWLOCK_UNLOCK(lock) rw_unlock(lock)\n \n #endif\n \n@@ -24,30 +25,30 @@\n  * Reader-writer lock\n  */\n struct PRRWLock {\n-    char* rw_name;    /* lock name                    */\n-    PRUint32 rw_rank; /* rank of the lock             */\n+  char* rw_name;    /* lock name                    */\n+  PRUint32 rw_rank; /* rank of the lock             */\n \n #if defined(HAVE_UNIX98_RWLOCK) || defined(HAVE_UI_RWLOCK)\n-    RWLOCK_T rw_lock;\n+  RWLOCK_T rw_lock;\n #else\n-    PRLock* rw_lock;\n-    PRInt32 rw_lock_cnt; /* ==  0, if unlocked           */\n-    /* == -1, if write-locked       */\n-    /* > 0  , # of read locks       */\n-    PRUint32 rw_reader_cnt;     /* number of waiting readers    */\n-    PRUint32 rw_writer_cnt;     /* number of waiting writers    */\n-    PRCondVar* rw_reader_waitq; /* cvar for readers             */\n-    PRCondVar* rw_writer_waitq; /* cvar for writers             */\n-#ifdef DEBUG\n-    PRThread* rw_owner; /* lock owner for write-lock    */\n-#endif\n+  PRLock* rw_lock;\n+  PRInt32 rw_lock_cnt; /* ==  0, if unlocked           */\n+  /* == -1, if write-locked       */\n+  /* > 0  , # of read locks       */\n+  PRUint32 rw_reader_cnt;     /* number of waiting readers    */\n+  PRUint32 rw_writer_cnt;     /* number of waiting writers    */\n+  PRCondVar* rw_reader_waitq; /* cvar for readers             */\n+  PRCondVar* rw_writer_waitq; /* cvar for writers             */\n+#  ifdef DEBUG\n+  PRThread* rw_owner; /* lock owner for write-lock    */\n+#  endif\n #endif\n };\n \n #ifdef DEBUG\n-#define _PR_RWLOCK_RANK_ORDER_DEBUG /* enable deadlock detection using \\\n-                                       rank-order for locks            \\\n-                                    */\n+#  define _PR_RWLOCK_RANK_ORDER_DEBUG /* enable deadlock detection using \\\n+                                         rank-order for locks            \\\n+                                      */\n #endif\n \n #ifdef _PR_RWLOCK_RANK_ORDER_DEBUG\n@@ -55,12 +56,12 @@ struct PRRWLock {\n static PRUintn pr_thread_rwlock_key; /* TPD key for lock stack */\n static PRUintn pr_thread_rwlock_alloc_failed;\n \n-#define _PR_RWLOCK_RANK_ORDER_LIMIT 10\n+#  define _PR_RWLOCK_RANK_ORDER_LIMIT 10\n \n typedef struct thread_rwlock_stack {\n-    PRInt32 trs_index;                                /* top of stack */\n-    PRRWLock* trs_stack[_PR_RWLOCK_RANK_ORDER_LIMIT]; /* stack of lock\n-                                                         pointers */\n+  PRInt32 trs_index;                                /* top of stack */\n+  PRRWLock* trs_stack[_PR_RWLOCK_RANK_ORDER_LIMIT]; /* stack of lock\n+                                                       pointers */\n \n } thread_rwlock_stack;\n \n@@ -82,71 +83,70 @@ static void _PR_RELEASE_LOCK_STACK(void* lock_stack);\n  */\n \n PR_IMPLEMENT(PRRWLock*)\n-PR_NewRWLock(PRUint32 lock_rank, const char* lock_name)\n-{\n-    PRRWLock* rwlock;\n+PR_NewRWLock(PRUint32 lock_rank, const char* lock_name) {\n+  PRRWLock* rwlock;\n #if defined(HAVE_UNIX98_RWLOCK) || defined(HAVE_UI_RWLOCK)\n-    int err;\n+  int err;\n #endif\n \n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    rwlock = PR_NEWZAP(PRRWLock);\n-    if (rwlock == NULL) {\n-        return NULL;\n-    }\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n \n-    rwlock->rw_rank = lock_rank;\n-    if (lock_name != NULL) {\n-        rwlock->rw_name = (char*)PR_Malloc(strlen(lock_name) + 1);\n-        if (rwlock->rw_name == NULL) {\n-            PR_DELETE(rwlock);\n-            return (NULL);\n-        }\n-        strcpy(rwlock->rw_name, lock_name);\n-    } else {\n-        rwlock->rw_name = NULL;\n+  rwlock = PR_NEWZAP(PRRWLock);\n+  if (rwlock == NULL) {\n+    return NULL;\n+  }\n+\n+  rwlock->rw_rank = lock_rank;\n+  if (lock_name != NULL) {\n+    rwlock->rw_name = (char*)PR_Malloc(strlen(lock_name) + 1);\n+    if (rwlock->rw_name == NULL) {\n+      PR_DELETE(rwlock);\n+      return (NULL);\n     }\n+    strcpy(rwlock->rw_name, lock_name);\n+  } else {\n+    rwlock->rw_name = NULL;\n+  }\n \n #if defined(HAVE_UNIX98_RWLOCK) || defined(HAVE_UI_RWLOCK)\n-    err = RWLOCK_INIT(&rwlock->rw_lock);\n-    if (err != 0) {\n-        PR_SetError(PR_UNKNOWN_ERROR, err);\n-        PR_Free(rwlock->rw_name);\n-        PR_DELETE(rwlock);\n-        return NULL;\n-    }\n-    return rwlock;\n-#else\n-    rwlock->rw_lock = PR_NewLock();\n-    if (rwlock->rw_lock == NULL) {\n-        goto failed;\n-    }\n-    rwlock->rw_reader_waitq = PR_NewCondVar(rwlock->rw_lock);\n-    if (rwlock->rw_reader_waitq == NULL) {\n-        goto failed;\n-    }\n-    rwlock->rw_writer_waitq = PR_NewCondVar(rwlock->rw_lock);\n-    if (rwlock->rw_writer_waitq == NULL) {\n-        goto failed;\n-    }\n-    rwlock->rw_reader_cnt = 0;\n-    rwlock->rw_writer_cnt = 0;\n-    rwlock->rw_lock_cnt = 0;\n-    return rwlock;\n-\n-failed:\n-    if (rwlock->rw_reader_waitq != NULL) {\n-        PR_DestroyCondVar(rwlock->rw_reader_waitq);\n-    }\n-    if (rwlock->rw_lock != NULL) {\n-        PR_DestroyLock(rwlock->rw_lock);\n-    }\n+  err = RWLOCK_INIT(&rwlock->rw_lock);\n+  if (err != 0) {\n+    PR_SetError(PR_UNKNOWN_ERROR, err);\n     PR_Free(rwlock->rw_name);\n     PR_DELETE(rwlock);\n     return NULL;\n+  }\n+  return rwlock;\n+#else\n+  rwlock->rw_lock = PR_NewLock();\n+  if (rwlock->rw_lock == NULL) {\n+    goto failed;\n+  }\n+  rwlock->rw_reader_waitq = PR_NewCondVar(rwlock->rw_lock);\n+  if (rwlock->rw_reader_waitq == NULL) {\n+    goto failed;\n+  }\n+  rwlock->rw_writer_waitq = PR_NewCondVar(rwlock->rw_lock);\n+  if (rwlock->rw_writer_waitq == NULL) {\n+    goto failed;\n+  }\n+  rwlock->rw_reader_cnt = 0;\n+  rwlock->rw_writer_cnt = 0;\n+  rwlock->rw_lock_cnt = 0;\n+  return rwlock;\n+\n+failed:\n+  if (rwlock->rw_reader_waitq != NULL) {\n+    PR_DestroyCondVar(rwlock->rw_reader_waitq);\n+  }\n+  if (rwlock->rw_lock != NULL) {\n+    PR_DestroyLock(rwlock->rw_lock);\n+  }\n+  PR_Free(rwlock->rw_name);\n+  PR_DELETE(rwlock);\n+  return NULL;\n #endif\n }\n \n@@ -154,72 +154,70 @@ failed:\n ** Destroy the given RWLock \"lock\".\n */\n PR_IMPLEMENT(void)\n-PR_DestroyRWLock(PRRWLock* rwlock)\n-{\n+PR_DestroyRWLock(PRRWLock* rwlock) {\n #if defined(HAVE_UNIX98_RWLOCK) || defined(HAVE_UI_RWLOCK)\n-    int err;\n-    err = RWLOCK_DESTROY(&rwlock->rw_lock);\n-    PR_ASSERT(err == 0);\n+  int err;\n+  err = RWLOCK_DESTROY(&rwlock->rw_lock);\n+  PR_ASSERT(err == 0);\n #else\n-    PR_ASSERT(rwlock->rw_reader_cnt == 0);\n-    PR_DestroyCondVar(rwlock->rw_reader_waitq);\n-    PR_DestroyCondVar(rwlock->rw_writer_waitq);\n-    PR_DestroyLock(rwlock->rw_lock);\n+  PR_ASSERT(rwlock->rw_reader_cnt == 0);\n+  PR_DestroyCondVar(rwlock->rw_reader_waitq);\n+  PR_DestroyCondVar(rwlock->rw_writer_waitq);\n+  PR_DestroyLock(rwlock->rw_lock);\n #endif\n-    if (rwlock->rw_name != NULL) {\n-        PR_Free(rwlock->rw_name);\n-    }\n-    PR_DELETE(rwlock);\n+  if (rwlock->rw_name != NULL) {\n+    PR_Free(rwlock->rw_name);\n+  }\n+  PR_DELETE(rwlock);\n }\n \n /*\n ** Read-lock the RWLock.\n */\n PR_IMPLEMENT(void)\n-PR_RWLock_Rlock(PRRWLock* rwlock)\n-{\n+PR_RWLock_Rlock(PRRWLock* rwlock) {\n #if defined(HAVE_UNIX98_RWLOCK) || defined(HAVE_UI_RWLOCK)\n-    int err;\n+  int err;\n #endif\n \n #ifdef _PR_RWLOCK_RANK_ORDER_DEBUG\n-    /*\n-     * assert that rank ordering is not violated; the rank of 'rwlock' should\n-     * be equal to or greater than the highest rank of all the locks held by\n-     * the thread.\n-     */\n-    PR_ASSERT((rwlock->rw_rank == PR_RWLOCK_RANK_NONE) ||\n-              (rwlock->rw_rank >= _PR_GET_THREAD_RWLOCK_RANK()));\n+  /*\n+   * assert that rank ordering is not violated; the rank of 'rwlock' should\n+   * be equal to or greater than the highest rank of all the locks held by\n+   * the thread.\n+   */\n+  PR_ASSERT((rwlock->rw_rank == PR_RWLOCK_RANK_NONE) ||\n+            (rwlock->rw_rank >= _PR_GET_THREAD_RWLOCK_RANK()));\n #endif\n \n #if defined(HAVE_UNIX98_RWLOCK) || defined(HAVE_UI_RWLOCK)\n-    err = RWLOCK_RDLOCK(&rwlock->rw_lock);\n-    PR_ASSERT(err == 0);\n+  err = RWLOCK_RDLOCK(&rwlock->rw_lock);\n+  PR_ASSERT(err == 0);\n #else\n-    PR_Lock(rwlock->rw_lock);\n-    /*\n-     * wait if write-locked or if a writer is waiting; preference for writers\n-     */\n-    while ((rwlock->rw_lock_cnt < 0) || (rwlock->rw_writer_cnt > 0)) {\n-        rwlock->rw_reader_cnt++;\n-        PR_WaitCondVar(rwlock->rw_reader_waitq, PR_INTERVAL_NO_TIMEOUT);\n-        rwlock->rw_reader_cnt--;\n-    }\n-    /*\n-     * Increment read-lock count\n-     */\n-    rwlock->rw_lock_cnt++;\n-\n-    PR_Unlock(rwlock->rw_lock);\n+  PR_Lock(rwlock->rw_lock);\n+  /*\n+   * wait if write-locked or if a writer is waiting; preference for writers\n+   */\n+  while ((rwlock->rw_lock_cnt < 0) || (rwlock->rw_writer_cnt > 0)) {\n+    rwlock->rw_reader_cnt++;\n+    PR_WaitCondVar(rwlock->rw_reader_waitq, PR_INTERVAL_NO_TIMEOUT);\n+    rwlock->rw_reader_cnt--;\n+  }\n+  /*\n+   * Increment read-lock count\n+   */\n+  rwlock->rw_lock_cnt++;\n+\n+  PR_Unlock(rwlock->rw_lock);\n #endif\n \n #ifdef _PR_RWLOCK_RANK_ORDER_DEBUG\n-    /*\n-     * update thread's lock rank\n-     */\n-    if (rwlock->rw_rank != PR_RWLOCK_RANK_NONE) {\n-        _PR_SET_THREAD_RWLOCK_RANK(rwlock);\n-    }\n+  /*\n+   * update thread's lock rank\n+   */\n+  if (rwlock->rw_rank != PR_RWLOCK_RANK_NONE) {\n+    _PR_SET_THREAD_RWLOCK_RANK(rwlock);\n+  }\n #endif\n }\n \n@@ -227,57 +225,56 @@ PR_RWLock_Rlock(PRRWLock* rwlock)\n ** Write-lock the RWLock.\n */\n PR_IMPLEMENT(void)\n-PR_RWLock_Wlock(PRRWLock* rwlock)\n-{\n+PR_RWLock_Wlock(PRRWLock* rwlock) {\n #if defined(DEBUG)\n-    PRThread* me = PR_GetCurrentThread();\n+  PRThread* me = PR_GetCurrentThread();\n #endif\n #if defined(HAVE_UNIX98_RWLOCK) || defined(HAVE_UI_RWLOCK)\n-    int err;\n+  int err;\n #endif\n \n #ifdef _PR_RWLOCK_RANK_ORDER_DEBUG\n-    /*\n-     * assert that rank ordering is not violated; the rank of 'rwlock' should\n-     * be equal to or greater than the highest rank of all the locks held by\n-     * the thread.\n-     */\n-    PR_ASSERT((rwlock->rw_rank == PR_RWLOCK_RANK_NONE) ||\n-              (rwlock->rw_rank >= _PR_GET_THREAD_RWLOCK_RANK()));\n+  /*\n+   * assert that rank ordering is not violated; the rank of 'rwlock' should\n+   * be equal to or greater than the highest rank of all the locks held by\n+   * the thread.\n+   */\n+  PR_ASSERT((rwlock->rw_rank == PR_RWLOCK_RANK_NONE) ||\n+            (rwlock->rw_rank >= _PR_GET_THREAD_RWLOCK_RANK()));\n #endif\n \n #if defined(HAVE_UNIX98_RWLOCK) || defined(HAVE_UI_RWLOCK)\n-    err = RWLOCK_WRLOCK(&rwlock->rw_lock);\n-    PR_ASSERT(err == 0);\n+  err = RWLOCK_WRLOCK(&rwlock->rw_lock);\n+  PR_ASSERT(err == 0);\n #else\n-    PR_Lock(rwlock->rw_lock);\n-    /*\n-     * wait if read locked\n-     */\n-    while (rwlock->rw_lock_cnt != 0) {\n-        rwlock->rw_writer_cnt++;\n-        PR_WaitCondVar(rwlock->rw_writer_waitq, PR_INTERVAL_NO_TIMEOUT);\n-        rwlock->rw_writer_cnt--;\n-    }\n-    /*\n-     * apply write lock\n-     */\n-    rwlock->rw_lock_cnt--;\n-    PR_ASSERT(rwlock->rw_lock_cnt == -1);\n-#ifdef DEBUG\n-    PR_ASSERT(me != NULL);\n-    rwlock->rw_owner = me;\n-#endif\n-    PR_Unlock(rwlock->rw_lock);\n+  PR_Lock(rwlock->rw_lock);\n+  /*\n+   * wait if read locked\n+   */\n+  while (rwlock->rw_lock_cnt != 0) {\n+    rwlock->rw_writer_cnt++;\n+    PR_WaitCondVar(rwlock->rw_writer_waitq, PR_INTERVAL_NO_TIMEOUT);\n+    rwlock->rw_writer_cnt--;\n+  }\n+  /*\n+   * apply write lock\n+   */\n+  rwlock->rw_lock_cnt--;\n+  PR_ASSERT(rwlock->rw_lock_cnt == -1);\n+#  ifdef DEBUG\n+  PR_ASSERT(me != NULL);\n+  rwlock->rw_owner = me;\n+#  endif\n+  PR_Unlock(rwlock->rw_lock);\n #endif\n \n #ifdef _PR_RWLOCK_RANK_ORDER_DEBUG\n-    /*\n-     * update thread's lock rank\n-     */\n-    if (rwlock->rw_rank != PR_RWLOCK_RANK_NONE) {\n-        _PR_SET_THREAD_RWLOCK_RANK(rwlock);\n-    }\n+  /*\n+   * update thread's lock rank\n+   */\n+  if (rwlock->rw_rank != PR_RWLOCK_RANK_NONE) {\n+    _PR_SET_THREAD_RWLOCK_RANK(rwlock);\n+  }\n #endif\n }\n \n@@ -285,92 +282,86 @@ PR_RWLock_Wlock(PRRWLock* rwlock)\n ** Unlock the RW lock.\n */\n PR_IMPLEMENT(void)\n-PR_RWLock_Unlock(PRRWLock* rwlock)\n-{\n+PR_RWLock_Unlock(PRRWLock* rwlock) {\n #if defined(DEBUG)\n-    PRThread* me = PR_GetCurrentThread();\n+  PRThread* me = PR_GetCurrentThread();\n #endif\n #if defined(HAVE_UNIX98_RWLOCK) || defined(HAVE_UI_RWLOCK)\n-    int err;\n+  int err;\n #endif\n \n #if defined(HAVE_UNIX98_RWLOCK) || defined(HAVE_UI_RWLOCK)\n-    err = RWLOCK_UNLOCK(&rwlock->rw_lock);\n-    PR_ASSERT(err == 0);\n+  err = RWLOCK_UNLOCK(&rwlock->rw_lock);\n+  PR_ASSERT(err == 0);\n #else\n-    PR_Lock(rwlock->rw_lock);\n+  PR_Lock(rwlock->rw_lock);\n+  /*\n+   * lock must be read or write-locked\n+   */\n+  PR_ASSERT(rwlock->rw_lock_cnt != 0);\n+  if (rwlock->rw_lock_cnt > 0) {\n     /*\n-     * lock must be read or write-locked\n+     * decrement read-lock count\n      */\n-    PR_ASSERT(rwlock->rw_lock_cnt != 0);\n-    if (rwlock->rw_lock_cnt > 0) {\n-        /*\n-         * decrement read-lock count\n-         */\n-        rwlock->rw_lock_cnt--;\n-        if (rwlock->rw_lock_cnt == 0) {\n-            /*\n-             * lock is not read-locked anymore; wakeup a waiting writer\n-             */\n-            if (rwlock->rw_writer_cnt > 0) {\n-                PR_NotifyCondVar(rwlock->rw_writer_waitq);\n-            }\n-        }\n-    } else {\n-        PR_ASSERT(rwlock->rw_lock_cnt == -1);\n-\n-        rwlock->rw_lock_cnt = 0;\n-#ifdef DEBUG\n-        PR_ASSERT(rwlock->rw_owner == me);\n-        rwlock->rw_owner = NULL;\n-#endif\n-        /*\n-         * wakeup a writer, if present; preference for writers\n-         */\n-        if (rwlock->rw_writer_cnt > 0) {\n-            PR_NotifyCondVar(rwlock->rw_writer_waitq);\n-        }\n-        /*\n-         * else, wakeup all readers, if any\n-         */\n-        else if (rwlock->rw_reader_cnt > 0) {\n-            PR_NotifyAllCondVar(rwlock->rw_reader_waitq);\n-        }\n+    rwlock->rw_lock_cnt--;\n+    if (rwlock->rw_lock_cnt == 0) {\n+      /*\n+       * lock is not read-locked anymore; wakeup a waiting writer\n+       */\n+      if (rwlock->rw_writer_cnt > 0) {\n+        PR_NotifyCondVar(rwlock->rw_writer_waitq);\n+      }\n     }\n-    PR_Unlock(rwlock->rw_lock);\n-#endif\n+  } else {\n+    PR_ASSERT(rwlock->rw_lock_cnt == -1);\n \n-#ifdef _PR_RWLOCK_RANK_ORDER_DEBUG\n+    rwlock->rw_lock_cnt = 0;\n+#  ifdef DEBUG\n+    PR_ASSERT(rwlock->rw_owner == me);\n+    rwlock->rw_owner = NULL;\n+#  endif\n+    /*\n+     * wakeup a writer, if present; preference for writers\n+     */\n+    if (rwlock->rw_writer_cnt > 0) {\n+      PR_NotifyCondVar(rwlock->rw_writer_waitq);\n+    }\n     /*\n-     * update thread's lock rank\n+     * else, wakeup all readers, if any\n      */\n-    if (rwlock->rw_rank != PR_RWLOCK_RANK_NONE) {\n-        _PR_UNSET_THREAD_RWLOCK_RANK(rwlock);\n+    else if (rwlock->rw_reader_cnt > 0) {\n+      PR_NotifyAllCondVar(rwlock->rw_reader_waitq);\n     }\n+  }\n+  PR_Unlock(rwlock->rw_lock);\n #endif\n-    return;\n+\n+#ifdef _PR_RWLOCK_RANK_ORDER_DEBUG\n+  /*\n+   * update thread's lock rank\n+   */\n+  if (rwlock->rw_rank != PR_RWLOCK_RANK_NONE) {\n+    _PR_UNSET_THREAD_RWLOCK_RANK(rwlock);\n+  }\n+#endif\n+  return;\n }\n \n #ifndef _PR_RWLOCK_RANK_ORDER_DEBUG\n \n-void\n-_PR_InitRWLocks(void)\n-{\n-}\n+void _PR_InitRWLocks(void) {}\n \n #else\n \n-void\n-_PR_InitRWLocks(void)\n-{\n-    /*\n-     * allocated thread-private-data index for rwlock list\n-     */\n-    if (PR_NewThreadPrivateIndex(&pr_thread_rwlock_key, _PR_RELEASE_LOCK_STACK) ==\n-        PR_FAILURE) {\n-        pr_thread_rwlock_alloc_failed = 1;\n-        return;\n-    }\n+void _PR_InitRWLocks(void) {\n+  /*\n+   * allocated thread-private-data index for rwlock list\n+   */\n+  if (PR_NewThreadPrivateIndex(&pr_thread_rwlock_key, _PR_RELEASE_LOCK_STACK) ==\n+      PR_FAILURE) {\n+    pr_thread_rwlock_alloc_failed = 1;\n+    return;\n+  }\n }\n \n /*\n@@ -380,45 +371,41 @@ _PR_InitRWLocks(void)\n  *      per-thread list, which is anchored off a thread-private data key.\n  */\n \n-static void\n-_PR_SET_THREAD_RWLOCK_RANK(PRRWLock* rwlock)\n-{\n-    thread_rwlock_stack* lock_stack;\n-    PRStatus rv;\n+static void _PR_SET_THREAD_RWLOCK_RANK(PRRWLock* rwlock) {\n+  thread_rwlock_stack* lock_stack;\n+  PRStatus rv;\n \n-    /*\n-     * allocate a lock stack\n-     */\n-    if ((lock_stack = PR_GetThreadPrivate(pr_thread_rwlock_key)) == NULL) {\n-        lock_stack =\n-            (thread_rwlock_stack*)PR_CALLOC(1 * sizeof(thread_rwlock_stack));\n-        if (lock_stack) {\n-            rv = PR_SetThreadPrivate(pr_thread_rwlock_key, lock_stack);\n-            if (rv == PR_FAILURE) {\n-                PR_DELETE(lock_stack);\n-                pr_thread_rwlock_alloc_failed = 1;\n-                return;\n-            }\n-        } else {\n-            pr_thread_rwlock_alloc_failed = 1;\n-            return;\n-        }\n-    }\n-    /*\n-     * add rwlock to lock stack, if limit is not exceeded\n-     */\n+  /*\n+   * allocate a lock stack\n+   */\n+  if ((lock_stack = PR_GetThreadPrivate(pr_thread_rwlock_key)) == NULL) {\n+    lock_stack =\n+        (thread_rwlock_stack*)PR_CALLOC(1 * sizeof(thread_rwlock_stack));\n     if (lock_stack) {\n-        if (lock_stack->trs_index < _PR_RWLOCK_RANK_ORDER_LIMIT) {\n-            lock_stack->trs_stack[lock_stack->trs_index++] = rwlock;\n-        }\n+      rv = PR_SetThreadPrivate(pr_thread_rwlock_key, lock_stack);\n+      if (rv == PR_FAILURE) {\n+        PR_DELETE(lock_stack);\n+        pr_thread_rwlock_alloc_failed = 1;\n+        return;\n+      }\n+    } else {\n+      pr_thread_rwlock_alloc_failed = 1;\n+      return;\n     }\n+  }\n+  /*\n+   * add rwlock to lock stack, if limit is not exceeded\n+   */\n+  if (lock_stack) {\n+    if (lock_stack->trs_index < _PR_RWLOCK_RANK_ORDER_LIMIT) {\n+      lock_stack->trs_stack[lock_stack->trs_index++] = rwlock;\n+    }\n+  }\n }\n \n-static void\n-_PR_RELEASE_LOCK_STACK(void* lock_stack)\n-{\n-    PR_ASSERT(lock_stack);\n-    PR_DELETE(lock_stack);\n+static void _PR_RELEASE_LOCK_STACK(void* lock_stack) {\n+  PR_ASSERT(lock_stack);\n+  PR_DELETE(lock_stack);\n }\n \n /*\n@@ -428,17 +415,15 @@ _PR_RELEASE_LOCK_STACK(void* lock_stack)\n  *      stack is not allocated, return PR_RWLOCK_RANK_NONE.\n  */\n \n-static PRUint32\n-_PR_GET_THREAD_RWLOCK_RANK(void)\n-{\n-    thread_rwlock_stack* lock_stack;\n+static PRUint32 _PR_GET_THREAD_RWLOCK_RANK(void) {\n+  thread_rwlock_stack* lock_stack;\n \n-    lock_stack = PR_GetThreadPrivate(pr_thread_rwlock_key);\n-    if (lock_stack == NULL || lock_stack->trs_index == 0) {\n-        return (PR_RWLOCK_RANK_NONE);\n-    } else {\n-        return (lock_stack->trs_stack[lock_stack->trs_index - 1]->rw_rank);\n-    }\n+  lock_stack = PR_GetThreadPrivate(pr_thread_rwlock_key);\n+  if (lock_stack == NULL || lock_stack->trs_index == 0) {\n+    return (PR_RWLOCK_RANK_NONE);\n+  } else {\n+    return (lock_stack->trs_stack[lock_stack->trs_index - 1]->rw_rank);\n+  }\n }\n \n /*\n@@ -448,39 +433,37 @@ _PR_GET_THREAD_RWLOCK_RANK(void)\n  *      unlocked in a FIFO order, the entire lock stack is searched.\n  */\n \n-static void\n-_PR_UNSET_THREAD_RWLOCK_RANK(PRRWLock* rwlock)\n-{\n-    thread_rwlock_stack* lock_stack;\n-    int new_index = 0, index, done = 0;\n-\n-    lock_stack = PR_GetThreadPrivate(pr_thread_rwlock_key);\n-\n-    PR_ASSERT(lock_stack != NULL);\n-\n-    for (index = lock_stack->trs_index - 1; index >= 0; index--) {\n-        if (!done && (lock_stack->trs_stack[index] == rwlock)) {\n-            /*\n-             * reset the slot for rwlock\n-             */\n-            lock_stack->trs_stack[index] = NULL;\n-            done = 1;\n-        }\n-        /*\n-         * search for the lowest-numbered empty slot, above which there are\n-         * no non-empty slots\n-         */\n-        if (!new_index && (lock_stack->trs_stack[index] != NULL)) {\n-            new_index = index + 1;\n-        }\n-        if (done && new_index) {\n-            break;\n-        }\n+static void _PR_UNSET_THREAD_RWLOCK_RANK(PRRWLock* rwlock) {\n+  thread_rwlock_stack* lock_stack;\n+  int new_index = 0, index, done = 0;\n+\n+  lock_stack = PR_GetThreadPrivate(pr_thread_rwlock_key);\n+\n+  PR_ASSERT(lock_stack != NULL);\n+\n+  for (index = lock_stack->trs_index - 1; index >= 0; index--) {\n+    if (!done && (lock_stack->trs_stack[index] == rwlock)) {\n+      /*\n+       * reset the slot for rwlock\n+       */\n+      lock_stack->trs_stack[index] = NULL;\n+      done = 1;\n     }\n     /*\n-     * set top of stack to highest numbered empty slot\n+     * search for the lowest-numbered empty slot, above which there are\n+     * no non-empty slots\n      */\n-    lock_stack->trs_index = new_index;\n+    if (!new_index && (lock_stack->trs_stack[index] != NULL)) {\n+      new_index = index + 1;\n+    }\n+    if (done && new_index) {\n+      break;\n+    }\n+  }\n+  /*\n+   * set top of stack to highest numbered empty slot\n+   */\n+  lock_stack->trs_index = new_index;\n }\n \n #endif /* _PR_RWLOCK_RANK_ORDER_DEBUG */\ndiff --git a/nspr/pr/src/threads/prsem.c b/nspr/pr/src/threads/prsem.c\nindex 8e896e7..7d7b769 100644\n--- a/nspr/pr/src/threads/prsem.c\n+++ b/nspr/pr/src/threads/prsem.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,35 +11,33 @@\n /*\n ** Create a new semaphore.\n */\n-PR_IMPLEMENT(PRSemaphore*)\n-PR_NewSem(PRUintn value)\n-{\n-    PRSemaphore* sem;\n-    PRCondVar* cvar;\n-    PRLock* lock;\n+PR_IMPLEMENT(PRSemaphore*) PR_NewSem(PRUintn value) {\n+  PRSemaphore* sem;\n+  PRCondVar* cvar;\n+  PRLock* lock;\n \n-    sem = PR_NEWZAP(PRSemaphore);\n-    if (sem) {\n+  sem = PR_NEWZAP(PRSemaphore);\n+  if (sem) {\n #ifdef HAVE_CVAR_BUILT_ON_SEM\n-        _PR_MD_NEW_SEM(&sem->md, value);\n+    _PR_MD_NEW_SEM(&sem->md, value);\n #else\n-        lock = PR_NewLock();\n-        if (!lock) {\n-            PR_DELETE(sem);\n-            return NULL;\n-        }\n+    lock = PR_NewLock();\n+    if (!lock) {\n+      PR_DELETE(sem);\n+      return NULL;\n+    }\n \n-        cvar = PR_NewCondVar(lock);\n-        if (!cvar) {\n-            PR_DestroyLock(lock);\n-            PR_DELETE(sem);\n-            return NULL;\n-        }\n-        sem->cvar = cvar;\n-        sem->count = value;\n-#endif\n+    cvar = PR_NewCondVar(lock);\n+    if (!cvar) {\n+      PR_DestroyLock(lock);\n+      PR_DELETE(sem);\n+      return NULL;\n     }\n-    return sem;\n+    sem->cvar = cvar;\n+    sem->count = value;\n+#endif\n+  }\n+  return sem;\n }\n \n /*\n@@ -46,18 +45,16 @@ PR_NewSem(PRUintn value)\n ** The caller is responsible for guaranteeing that the semaphore is\n ** no longer in use.\n */\n-PR_IMPLEMENT(void)\n-PR_DestroySem(PRSemaphore* sem)\n-{\n+PR_IMPLEMENT(void) PR_DestroySem(PRSemaphore* sem) {\n #ifdef HAVE_CVAR_BUILT_ON_SEM\n-    _PR_MD_DESTROY_SEM(&sem->md);\n+  _PR_MD_DESTROY_SEM(&sem->md);\n #else\n-    PR_ASSERT(sem->waiters == 0);\n+  PR_ASSERT(sem->waiters == 0);\n \n-    PR_DestroyLock(sem->cvar->lock);\n-    PR_DestroyCondVar(sem->cvar);\n+  PR_DestroyLock(sem->cvar->lock);\n+  PR_DestroyCondVar(sem->cvar);\n #endif\n-    PR_DELETE(sem);\n+  PR_DELETE(sem);\n }\n \n /*\n@@ -74,30 +71,28 @@ PR_DestroySem(PRSemaphore* sem)\n ** This routine can return PR_PENDING_INTERRUPT if the waiting thread\n ** has been interrupted.\n */\n-PR_IMPLEMENT(PRStatus)\n-PR_WaitSem(PRSemaphore* sem)\n-{\n-    PRStatus status = PR_SUCCESS;\n+PR_IMPLEMENT(PRStatus) PR_WaitSem(PRSemaphore* sem) {\n+  PRStatus status = PR_SUCCESS;\n \n #ifdef HAVE_CVAR_BUILT_ON_SEM\n-    return _PR_MD_WAIT_SEM(&sem->md);\n+  return _PR_MD_WAIT_SEM(&sem->md);\n #else\n-    PR_Lock(sem->cvar->lock);\n-    while (sem->count == 0) {\n-        sem->waiters++;\n-        status = PR_WaitCondVar(sem->cvar, PR_INTERVAL_NO_TIMEOUT);\n-        sem->waiters--;\n-        if (status != PR_SUCCESS) {\n-            break;\n-        }\n-    }\n-    if (status == PR_SUCCESS) {\n-        sem->count--;\n+  PR_Lock(sem->cvar->lock);\n+  while (sem->count == 0) {\n+    sem->waiters++;\n+    status = PR_WaitCondVar(sem->cvar, PR_INTERVAL_NO_TIMEOUT);\n+    sem->waiters--;\n+    if (status != PR_SUCCESS) {\n+      break;\n     }\n-    PR_Unlock(sem->cvar->lock);\n+  }\n+  if (status == PR_SUCCESS) {\n+    sem->count--;\n+  }\n+  PR_Unlock(sem->cvar->lock);\n #endif\n \n-    return (status);\n+  return (status);\n }\n \n /*\n@@ -105,18 +100,16 @@ PR_WaitSem(PRSemaphore* sem)\n ** are blocked for the semaphore, then the scheduler will determine which ONE\n ** thread will be unblocked.\n */\n-PR_IMPLEMENT(void)\n-PR_PostSem(PRSemaphore* sem)\n-{\n+PR_IMPLEMENT(void) PR_PostSem(PRSemaphore* sem) {\n #ifdef HAVE_CVAR_BUILT_ON_SEM\n-    _PR_MD_POST_SEM(&sem->md);\n+  _PR_MD_POST_SEM(&sem->md);\n #else\n-    PR_Lock(sem->cvar->lock);\n-    if (sem->waiters) {\n-        PR_NotifyCondVar(sem->cvar);\n-    }\n-    sem->count++;\n-    PR_Unlock(sem->cvar->lock);\n+  PR_Lock(sem->cvar->lock);\n+  if (sem->waiters) {\n+    PR_NotifyCondVar(sem->cvar);\n+  }\n+  sem->count++;\n+  PR_Unlock(sem->cvar->lock);\n #endif\n }\n \n@@ -127,19 +120,17 @@ PR_PostSem(PRSemaphore* sem)\n ** at the time of the call, but may not be the actual value when the\n ** caller inspects it. (FOR DEBUGGING ONLY)\n */\n-PR_IMPLEMENT(PRUintn)\n-PR_GetValueSem(PRSemaphore* sem)\n-{\n-    PRUintn rv;\n+PR_IMPLEMENT(PRUintn) PR_GetValueSem(PRSemaphore* sem) {\n+  PRUintn rv;\n \n-#ifdef HAVE_CVAR_BUILT_ON_SEM\n-    rv = _PR_MD_GET_VALUE_SEM(&sem->md);\n-#else\n-    PR_Lock(sem->cvar->lock);\n-    rv = sem->count;\n-    PR_Unlock(sem->cvar->lock);\n-#endif\n+#  ifdef HAVE_CVAR_BUILT_ON_SEM\n+  rv = _PR_MD_GET_VALUE_SEM(&sem->md);\n+#  else\n+  PR_Lock(sem->cvar->lock);\n+  rv = sem->count;\n+  PR_Unlock(sem->cvar->lock);\n+#  endif\n \n-    return rv;\n+  return rv;\n }\n #endif\ndiff --git a/nspr/pr/src/threads/prtpd.c b/nspr/pr/src/threads/prtpd.c\nindex d1df0df..2b37142 100644\n--- a/nspr/pr/src/threads/prtpd.c\n+++ b/nspr/pr/src/threads/prtpd.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -42,7 +43,7 @@\n ** The pragma suppresses the warning.\n **\n */\n-#pragma warning(disable : 4101)\n+#  pragma warning(disable : 4101)\n #endif\n \n #define _PR_TPD_LIMIT 128             /* arbitary limit on the TPD slots */\n@@ -56,22 +57,17 @@ static PRThreadPrivateDTOR* _pr_tpd_destructors = NULL;\n /*\n ** Initialize the thread private data manipulation\n */\n-void\n-_PR_InitTPD(void)\n-{\n-    _pr_tpd_destructors = (PRThreadPrivateDTOR*)PR_CALLOC(\n-        _PR_TPD_LIMIT * sizeof(PRThreadPrivateDTOR*));\n-    PR_ASSERT(NULL != _pr_tpd_destructors);\n-    _pr_tpd_length = _PR_TPD_LIMIT;\n+void _PR_InitTPD(void) {\n+  _pr_tpd_destructors = (PRThreadPrivateDTOR*)PR_CALLOC(\n+      _PR_TPD_LIMIT * sizeof(PRThreadPrivateDTOR*));\n+  PR_ASSERT(NULL != _pr_tpd_destructors);\n+  _pr_tpd_length = _PR_TPD_LIMIT;\n }\n \n /*\n ** Clean up the thread private data manipulation\n */\n-void\n-_PR_CleanupTPD(void)\n-{\n-} /* _PR_CleanupTPD */\n+void _PR_CleanupTPD(void) {} /* _PR_CleanupTPD */\n \n /*\n ** This routine returns a new index for per-thread-private data table.\n@@ -94,29 +90,28 @@ _PR_CleanupTPD(void)\n */\n \n PR_IMPLEMENT(PRStatus)\n-PR_NewThreadPrivateIndex(PRUintn* newIndex, PRThreadPrivateDTOR dtor)\n-{\n-    PRStatus rv;\n-    PRInt32 index;\n-\n-    if (!_pr_initialized) {\n-        _PR_ImplicitInitialization();\n-    }\n-\n-    PR_ASSERT(NULL != newIndex);\n-    PR_ASSERT(NULL != _pr_tpd_destructors);\n-\n-    index = PR_ATOMIC_INCREMENT(&_pr_tpd_highwater) - 1; /* allocate index */\n-    if (_PR_TPD_LIMIT <= index) {\n-        PR_SetError(PR_TPD_RANGE_ERROR, 0);\n-        rv = PR_FAILURE; /* that's just wrong */\n-    } else {\n-        _pr_tpd_destructors[index] = dtor; /* record destructor @index */\n-        *newIndex = (PRUintn)index;        /* copy into client's location */\n-        rv = PR_SUCCESS;                   /* that's okay */\n-    }\n-\n-    return rv;\n+PR_NewThreadPrivateIndex(PRUintn* newIndex, PRThreadPrivateDTOR dtor) {\n+  PRStatus rv;\n+  PRInt32 index;\n+\n+  if (!_pr_initialized) {\n+    _PR_ImplicitInitialization();\n+  }\n+\n+  PR_ASSERT(NULL != newIndex);\n+  PR_ASSERT(NULL != _pr_tpd_destructors);\n+\n+  index = PR_ATOMIC_INCREMENT(&_pr_tpd_highwater) - 1; /* allocate index */\n+  if (_PR_TPD_LIMIT <= index) {\n+    PR_SetError(PR_TPD_RANGE_ERROR, 0);\n+    rv = PR_FAILURE; /* that's just wrong */\n+  } else {\n+    _pr_tpd_destructors[index] = dtor; /* record destructor @index */\n+    *newIndex = (PRUintn)index;        /* copy into client's location */\n+    rv = PR_SUCCESS;                   /* that's okay */\n+  }\n+\n+  return rv;\n }\n \n /*\n@@ -133,55 +128,53 @@ PR_NewThreadPrivateIndex(PRUintn* newIndex, PRThreadPrivateDTOR dtor)\n ** vector.\n */\n \n-PR_IMPLEMENT(PRStatus)\n-PR_SetThreadPrivate(PRUintn index, void* priv)\n-{\n-    PRThread* self = PR_GetCurrentThread();\n-\n-    /*\n-    ** To improve performance, we don't check if the index has been\n-    ** allocated.\n-    */\n-    if (index >= _PR_TPD_LIMIT) {\n-        PR_SetError(PR_TPD_RANGE_ERROR, 0);\n-        return PR_FAILURE;\n-    }\n-\n-    PR_ASSERT(((NULL == self->privateData) && (0 == self->tpdLength)) ||\n-              ((NULL != self->privateData) && (0 != self->tpdLength)));\n-\n-    /*\n-    ** If this thread does not have a sufficient vector for the index\n-    ** being set, go ahead and extend this vector now.\n-    */\n-    if ((NULL == self->privateData) || (self->tpdLength <= index)) {\n-        void* extension = PR_CALLOC(_pr_tpd_length * sizeof(void*));\n-        if (NULL == extension) {\n-            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-            return PR_FAILURE;\n-        }\n-        if (self->privateData) {\n-            (void)memcpy(extension, self->privateData,\n-                         self->tpdLength * sizeof(void*));\n-            PR_DELETE(self->privateData);\n-        }\n-        self->tpdLength = _pr_tpd_length;\n-        self->privateData = (void**)extension;\n+PR_IMPLEMENT(PRStatus) PR_SetThreadPrivate(PRUintn index, void* priv) {\n+  PRThread* self = PR_GetCurrentThread();\n+\n+  /*\n+  ** To improve performance, we don't check if the index has been\n+  ** allocated.\n+  */\n+  if (index >= _PR_TPD_LIMIT) {\n+    PR_SetError(PR_TPD_RANGE_ERROR, 0);\n+    return PR_FAILURE;\n+  }\n+\n+  PR_ASSERT(((NULL == self->privateData) && (0 == self->tpdLength)) ||\n+            ((NULL != self->privateData) && (0 != self->tpdLength)));\n+\n+  /*\n+  ** If this thread does not have a sufficient vector for the index\n+  ** being set, go ahead and extend this vector now.\n+  */\n+  if ((NULL == self->privateData) || (self->tpdLength <= index)) {\n+    void* extension = PR_CALLOC(_pr_tpd_length * sizeof(void*));\n+    if (NULL == extension) {\n+      PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+      return PR_FAILURE;\n     }\n-    /*\n-    ** There wasn't much chance of having to call the destructor\n-    ** unless the slot already existed.\n-    */\n-    else if (self->privateData[index] && _pr_tpd_destructors[index]) {\n-        void* data = self->privateData[index];\n-        self->privateData[index] = NULL;\n-        (*_pr_tpd_destructors[index])(data);\n+    if (self->privateData) {\n+      (void)memcpy(extension, self->privateData,\n+                   self->tpdLength * sizeof(void*));\n+      PR_DELETE(self->privateData);\n     }\n-\n-    PR_ASSERT(index < self->tpdLength);\n-    self->privateData[index] = priv;\n-\n-    return PR_SUCCESS;\n+    self->tpdLength = _pr_tpd_length;\n+    self->privateData = (void**)extension;\n+  }\n+  /*\n+  ** There wasn't much chance of having to call the destructor\n+  ** unless the slot already existed.\n+  */\n+  else if (self->privateData[index] && _pr_tpd_destructors[index]) {\n+    void* data = self->privateData[index];\n+    self->privateData[index] = NULL;\n+    (*_pr_tpd_destructors[index])(data);\n+  }\n+\n+  PR_ASSERT(index < self->tpdLength);\n+  self->privateData[index] = priv;\n+\n+  return PR_SUCCESS;\n }\n \n /*\n@@ -193,15 +186,13 @@ PR_SetThreadPrivate(PRUintn index, void* priv)\n **\n */\n \n-PR_IMPLEMENT(void*)\n-PR_GetThreadPrivate(PRUintn index)\n-{\n-    PRThread* self = PR_GetCurrentThread();\n-    void* tpd = ((NULL == self->privateData) || (index >= self->tpdLength))\n-                    ? NULL\n-                    : self->privateData[index];\n+PR_IMPLEMENT(void*) PR_GetThreadPrivate(PRUintn index) {\n+  PRThread* self = PR_GetCurrentThread();\n+  void* tpd = ((NULL == self->privateData) || (index >= self->tpdLength))\n+                  ? NULL\n+                  : self->privateData[index];\n \n-    return tpd;\n+  return tpd;\n }\n \n /*\n@@ -209,36 +200,34 @@ PR_GetThreadPrivate(PRUintn index)\n ** thread termination time only. There should be no threading issues\n ** since this is being called by the thread itself.\n */\n-void\n-_PR_DestroyThreadPrivate(PRThread* self)\n-{\n+void _PR_DestroyThreadPrivate(PRThread* self) {\n #define _PR_TPD_DESTRUCTOR_ITERATIONS 4\n \n-    if (NULL != self->privateData) /* we have some */\n-    {\n-        PRBool clean;\n-        PRUint32 index;\n-        PRInt32 passes = _PR_TPD_DESTRUCTOR_ITERATIONS;\n-        PR_ASSERT(0 != self->tpdLength);\n-        do {\n-            clean = PR_TRUE;\n-            for (index = 0; index < self->tpdLength; ++index) {\n-                void* priv = self->privateData[index]; /* extract */\n-                if (NULL != priv)                      /* we have data at this index */\n-                {\n-                    if (NULL != _pr_tpd_destructors[index]) {\n-                        self->privateData[index] = NULL;     /* precondition */\n-                        (*_pr_tpd_destructors[index])(priv); /* destroy */\n-                        clean = PR_FALSE;                    /* unknown side effects */\n-                    }\n-                }\n-            }\n-        } while ((--passes > 0) && !clean); /* limit # of passes */\n-        /*\n-        ** We give up after a fixed number of passes. Any non-NULL\n-        ** thread-private data value with a registered destructor\n-        ** function is not destroyed.\n-        */\n-        memset(self->privateData, 0, self->tpdLength * sizeof(void*));\n-    }\n+  if (NULL != self->privateData) /* we have some */\n+  {\n+    PRBool clean;\n+    PRUint32 index;\n+    PRInt32 passes = _PR_TPD_DESTRUCTOR_ITERATIONS;\n+    PR_ASSERT(0 != self->tpdLength);\n+    do {\n+      clean = PR_TRUE;\n+      for (index = 0; index < self->tpdLength; ++index) {\n+        void* priv = self->privateData[index]; /* extract */\n+        if (NULL != priv)                      /* we have data at this index */\n+        {\n+          if (NULL != _pr_tpd_destructors[index]) {\n+            self->privateData[index] = NULL;     /* precondition */\n+            (*_pr_tpd_destructors[index])(priv); /* destroy */\n+            clean = PR_FALSE;                    /* unknown side effects */\n+          }\n+        }\n+      }\n+    } while ((--passes > 0) && !clean); /* limit # of passes */\n+    /*\n+    ** We give up after a fixed number of passes. Any non-NULL\n+    ** thread-private data value with a registered destructor\n+    ** function is not destroyed.\n+    */\n+    memset(self->privateData, 0, self->tpdLength * sizeof(void*));\n+  }\n } /* _PR_DestroyThreadPrivate */\ndiff --git a/nspr/pr/tests/.cvsignore b/nspr/pr/tests/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/tests/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/tests/Makefile.in b/nspr/pr/tests/Makefile.in\nindex d2434d6..20e2f99 100644\n--- a/nspr/pr/tests/Makefile.in\n+++ b/nspr/pr/tests/Makefile.in\n@@ -108,7 +108,6 @@ CSRCS =             \\\n \tpoll_nm.c\t\t\\\n \tpoll_to.c\t\t\\\n \tpollable.c\t\t\\\n-\tprefloop.c\t\t\\\n \tprfdbl.c\t\t\\\n \tprftest.c\t\t\\\n \tprftest1.c\t\t\\\n@@ -249,6 +248,9 @@ ifeq ($(OS_ARCH), SunOS)\n     ifdef NS_USE_GCC\n         LDOPTS += -Xlinker -R -Xlinker $(ABSOLUTE_LIB_DIR)\n     else\n+        ifeq ($(USE_CPLUS), 1)\n+            CC = CC\n+        endif\n         LDOPTS += -R $(ABSOLUTE_LIB_DIR)\n     endif\n \n@@ -368,7 +370,7 @@ ifdef MT\n \tfi\n endif\n else\n-\t$(PURE) $(CC) $(XCFLAGS) $(LDFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(EXTRA_LIBS) -o $@\n+\t$(PURE) $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(EXTRA_LIBS) -o $@\n endif # WINNT\n endif # AIX_PRE_4_2\n \n@@ -381,23 +383,23 @@ clean::\n ifeq ($(OS_ARCH),SunOS)\n ifeq ($(USE_IPV6),1)\n $(OBJDIR)/gethost: $(OBJDIR)/gethost.o\n-\t$(PURE) $(CC) $(XCFLAGS) $(LDFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) -lsocket $(EXTRA_LIBS) -o $@\n+\t$(PURE) $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) -lsocket $(EXTRA_LIBS) -o $@\n endif\n $(OBJDIR)/prpoll: $(OBJDIR)/prpoll.o\n-\t$(PURE) $(CC) $(XCFLAGS) $(LDFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) -lsocket $(EXTRA_LIBS) -o $@\n+\t$(PURE) $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) -lsocket $(EXTRA_LIBS) -o $@\n endif\n \n ifeq ($(USE_PTHREADS), 1)\n $(OBJDIR)/attach: $(OBJDIR)/attach.o\n-\t$(PURE) $(CC) $(XCFLAGS) $(LDFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(LIBPTHREAD) $(EXTRA_LIBS) -o $@\n+\t$(PURE) $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(LIBPTHREAD) $(EXTRA_LIBS) -o $@\n $(OBJDIR)/foreign: $(OBJDIR)/foreign.o\n-\t$(PURE) $(CC) $(XCFLAGS) $(LDFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(LIBPTHREAD) $(EXTRA_LIBS) -o $@\n+\t$(PURE) $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(LIBPTHREAD) $(EXTRA_LIBS) -o $@\n $(OBJDIR)/provider: $(OBJDIR)/provider.o\n-\t$(PURE) $(CC) $(XCFLAGS) $(LDFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(LIBPTHREAD) $(EXTRA_LIBS) -o $@\n+\t$(PURE) $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(LIBPTHREAD) $(EXTRA_LIBS) -o $@\n $(OBJDIR)/socket: $(OBJDIR)/socket.o\n-\t$(PURE) $(CC) $(XCFLAGS) $(LDFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(LIBPTHREAD) $(EXTRA_LIBS) -o $@\n+\t$(PURE) $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(LIBPTHREAD) $(EXTRA_LIBS) -o $@\n $(OBJDIR)/testfile: $(OBJDIR)/testfile.o\n-\t$(PURE) $(CC) $(XCFLAGS) $(LDFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(LIBPTHREAD) $(EXTRA_LIBS) -o $@\n+\t$(PURE) $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(LIBPTHREAD) $(EXTRA_LIBS) -o $@\n endif\n \n #\ndiff --git a/nspr/pr/tests/abstract.c b/nspr/pr/tests/abstract.c\nindex 24ae64d..382e07b 100644\n--- a/nspr/pr/tests/abstract.c\n+++ b/nspr/pr/tests/abstract.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,151 +7,145 @@\n \n #if defined(LINUX)\n \n-#include <string.h>\n-#include \"nspr.h\"\n+#  include <string.h>\n+#  include \"nspr.h\"\n \n static const char abstractSocketName[] = \"\\0testsocket\";\n \n-static void\n-ClientThread(void* aArg)\n-{\n-    PRFileDesc* socket;\n-    PRNetAddr addr;\n-    PRUint8 buf[1024];\n-    PRInt32 len;\n-    PRInt32 total;\n-\n-    addr.local.family = PR_AF_LOCAL;\n-    memcpy(addr.local.path, abstractSocketName, sizeof(abstractSocketName));\n-\n-    socket = PR_OpenTCPSocket(addr.raw.family);\n-    if (!socket) {\n-        fprintf(stderr, \"PR_OpenTCPSokcet failed\\n\");\n-        exit(1);\n+static void ClientThread(void* aArg) {\n+  PRFileDesc* socket;\n+  PRNetAddr addr;\n+  PRUint8 buf[1024];\n+  PRInt32 len;\n+  PRInt32 total;\n+\n+  addr.local.family = PR_AF_LOCAL;\n+  memcpy(addr.local.path, abstractSocketName, sizeof(abstractSocketName));\n+\n+  socket = PR_OpenTCPSocket(addr.raw.family);\n+  if (!socket) {\n+    fprintf(stderr, \"PR_OpenTCPSokcet failed\\n\");\n+    exit(1);\n+  }\n+\n+  if (PR_Connect(socket, &addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Connect failed\\n\");\n+    exit(1);\n+  }\n+\n+  total = 0;\n+  while (total < sizeof(buf)) {\n+    len = PR_Recv(socket, buf + total, sizeof(buf) - total, 0,\n+                  PR_INTERVAL_NO_TIMEOUT);\n+    if (len < 1) {\n+      fprintf(stderr, \"PR_Recv failed\\n\");\n+      exit(1);\n     }\n-\n-    if (PR_Connect(socket, &addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Connect failed\\n\");\n-        exit(1);\n-    }\n-\n-    total = 0;\n-    while (total < sizeof(buf)) {\n-        len = PR_Recv(socket, buf + total, sizeof(buf) - total, 0,\n-                      PR_INTERVAL_NO_TIMEOUT);\n-        if (len < 1) {\n-            fprintf(stderr, \"PR_Recv failed\\n\");\n-            exit(1);\n-        }\n-        total += len;\n+    total += len;\n+  }\n+\n+  total = 0;\n+  while (total < sizeof(buf)) {\n+    len = PR_Send(socket, buf + total, sizeof(buf) - total, 0,\n+                  PR_INTERVAL_NO_TIMEOUT);\n+    if (len < 1) {\n+      fprintf(stderr, \"PR_Send failed\\n\");\n+      exit(1);\n     }\n+    total += len;\n+  }\n \n-    total = 0;\n-    while (total < sizeof(buf)) {\n-        len = PR_Send(socket, buf + total, sizeof(buf) - total, 0,\n-                      PR_INTERVAL_NO_TIMEOUT);\n-        if (len < 1) {\n-            fprintf(stderr, \"PR_Send failed\\n\");\n-            exit(1);\n-        }\n-        total += len;\n-    }\n-\n-    if (PR_Close(socket) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n+  if (PR_Close(socket) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n }\n \n-int\n-main()\n-{\n-    PRFileDesc* socket;\n-    PRFileDesc* acceptSocket;\n-    PRThread* thread;\n-    PRNetAddr addr;\n-    PRUint8 buf[1024];\n-    PRInt32 len;\n-    PRInt32 total;\n-\n-    addr.local.family = PR_AF_LOCAL;\n-    memcpy(addr.local.path, abstractSocketName, sizeof(abstractSocketName));\n-\n-    socket = PR_OpenTCPSocket(addr.raw.family);\n-    if (!socket) {\n-        fprintf(stderr, \"PR_OpenTCPSocket failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Bind(socket, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Bind failed\\n\");\n-        exit(1);\n-    }\n-\n-    if (PR_Listen(socket, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Listen failed\\n\");\n-        exit(1);\n-    }\n-\n-    thread = PR_CreateThread(PR_USER_THREAD, ClientThread, 0, PR_PRIORITY_NORMAL,\n-                             PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (!thread) {\n-        fprintf(stderr, \"PR_CreateThread failed\");\n-        exit(1);\n+int main() {\n+  PRFileDesc* socket;\n+  PRFileDesc* acceptSocket;\n+  PRThread* thread;\n+  PRNetAddr addr;\n+  PRUint8 buf[1024];\n+  PRInt32 len;\n+  PRInt32 total;\n+\n+  addr.local.family = PR_AF_LOCAL;\n+  memcpy(addr.local.path, abstractSocketName, sizeof(abstractSocketName));\n+\n+  socket = PR_OpenTCPSocket(addr.raw.family);\n+  if (!socket) {\n+    fprintf(stderr, \"PR_OpenTCPSocket failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Bind(socket, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Bind failed\\n\");\n+    exit(1);\n+  }\n+\n+  if (PR_Listen(socket, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Listen failed\\n\");\n+    exit(1);\n+  }\n+\n+  thread = PR_CreateThread(PR_USER_THREAD, ClientThread, 0, PR_PRIORITY_NORMAL,\n+                           PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (!thread) {\n+    fprintf(stderr, \"PR_CreateThread failed\");\n+    exit(1);\n+  }\n+\n+  acceptSocket = PR_Accept(socket, NULL, PR_INTERVAL_NO_TIMEOUT);\n+  if (!acceptSocket) {\n+    fprintf(stderr, \"PR_Accept failed\\n\");\n+    exit(1);\n+  }\n+\n+  memset(buf, 'A', sizeof(buf));\n+\n+  total = 0;\n+  while (total < sizeof(buf)) {\n+    len = PR_Send(acceptSocket, buf + total, sizeof(buf) - total, 0,\n+                  PR_INTERVAL_NO_TIMEOUT);\n+    if (len < 1) {\n+      fprintf(stderr, \"PR_Send failed\\n\");\n+      exit(1);\n     }\n-\n-    acceptSocket = PR_Accept(socket, NULL, PR_INTERVAL_NO_TIMEOUT);\n-    if (!acceptSocket) {\n-        fprintf(stderr, \"PR_Accept failed\\n\");\n-        exit(1);\n-    }\n-\n-    memset(buf, 'A', sizeof(buf));\n-\n-    total = 0;\n-    while (total < sizeof(buf)) {\n-        len = PR_Send(acceptSocket, buf + total, sizeof(buf) - total, 0,\n-                      PR_INTERVAL_NO_TIMEOUT);\n-        if (len < 1) {\n-            fprintf(stderr, \"PR_Send failed\\n\");\n-            exit(1);\n-        }\n-        total += len;\n-    }\n-\n-    total = 0;\n-    while (total < sizeof(buf)) {\n-        len = PR_Recv(acceptSocket, buf + total, sizeof(buf) - total, 0,\n-                      PR_INTERVAL_NO_TIMEOUT);\n-        if (len < 1) {\n-            fprintf(stderr, \"PR_Recv failed\\n\");\n-            exit(1);\n-        }\n-        total += len;\n-    }\n-\n-    if (PR_Close(acceptSocket) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-\n-    if (PR_JoinThread(thread) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n-    }\n-\n-    if (PR_Close(socket) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n+    total += len;\n+  }\n+\n+  total = 0;\n+  while (total < sizeof(buf)) {\n+    len = PR_Recv(acceptSocket, buf + total, sizeof(buf) - total, 0,\n+                  PR_INTERVAL_NO_TIMEOUT);\n+    if (len < 1) {\n+      fprintf(stderr, \"PR_Recv failed\\n\");\n+      exit(1);\n     }\n-    printf(\"PASS\\n\");\n-    return 0;\n+    total += len;\n+  }\n+\n+  if (PR_Close(acceptSocket) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+\n+  if (PR_JoinThread(thread) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+\n+  if (PR_Close(socket) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  printf(\"PASS\\n\");\n+  return 0;\n }\n \n #else\n-int\n-main()\n-{\n-    printf(\"PASS\\n\");\n-    return 0;\n+int main() {\n+  printf(\"PASS\\n\");\n+  return 0;\n }\n #endif\ndiff --git a/nspr/pr/tests/accept.c b/nspr/pr/tests/accept.c\nindex 5180603..971e48b 100644\n--- a/nspr/pr/tests/accept.c\n+++ b/nspr/pr/tests/accept.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -78,431 +79,384 @@ static PRInt32 bytesRead;\n PRIntn failed_already = 0;\n PRIntn debug_mode;\n \n-void\n-Test_Assert(const char* msg, const char* file, PRIntn line)\n-{\n-    failed_already = 1;\n-    if (debug_mode) {\n-        PR_fprintf(output, \"@%s:%d \", file, line);\n-        PR_fprintf(output, msg);\n-    }\n+void Test_Assert(const char* msg, const char* file, PRIntn line) {\n+  failed_already = 1;\n+  if (debug_mode) {\n+    PR_fprintf(output, \"@%s:%d \", file, line);\n+    PR_fprintf(output, msg);\n+  }\n } /* Test_Assert */\n \n #define TEST_ASSERT(expr) \\\n-    if (!(expr))          \\\n-    Test_Assert(#expr, __FILE__, __LINE__)\n+  if (!(expr)) Test_Assert(#expr, __FILE__, __LINE__)\n \n #ifdef WINNT\n-#define CALLBACK_MAGIC 0x12345678\n+#  define CALLBACK_MAGIC 0x12345678\n \n-void\n-timeout_callback(void* magic)\n-{\n-    TEST_ASSERT(magic == (void*)CALLBACK_MAGIC);\n-    if (debug_mode) {\n-        PR_fprintf(output, \"timeout callback called okay\\n\");\n-    }\n+void timeout_callback(void* magic) {\n+  TEST_ASSERT(magic == (void*)CALLBACK_MAGIC);\n+  if (debug_mode) {\n+    PR_fprintf(output, \"timeout callback called okay\\n\");\n+  }\n }\n #endif\n \n-static void PR_CALLBACK\n-ClientThread(void* _action)\n-{\n-    PRInt32 action = *(PRInt32*)_action;\n-    PRInt32 iterations = count;\n-    PRFileDesc* sock = NULL;\n-\n-    serverAddr.inet.family = PR_AF_INET;\n-    serverAddr.inet.port = listenAddr.inet.port;\n-    serverAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n-\n-    for (; iterations--;) {\n-        PRInt32 rv;\n-        char buf[CLIENT_DATA];\n-\n-        memset(buf, 0xaf, sizeof(buf)); /* initialize with arbitrary data */\n-        sock = PR_NewTCPSocket();\n-        if (!sock) {\n-            if (!debug_mode) {\n-                failed_already = 1;\n-            } else {\n-                PR_fprintf(output, \"client: unable to create socket\\n\");\n-            }\n-            return;\n-        }\n+static void PR_CALLBACK ClientThread(void* _action) {\n+  PRInt32 action = *(PRInt32*)_action;\n+  PRInt32 iterations = count;\n+  PRFileDesc* sock = NULL;\n \n-        if (action != CLIENT_TIMEOUT_ACCEPT) {\n-            if ((rv = PR_Connect(sock, &serverAddr, timeoutTime)) < 0) {\n-                if (!debug_mode) {\n-                    failed_already = 1;\n-                } else\n-                    PR_fprintf(\n-                        output,\n-                        \"client: unable to connect to server (%ld, %ld, %ld, %ld)\\n\",\n-                        iterations, rv, PR_GetError(), PR_GetOSError());\n-                goto ErrorExit;\n-            }\n+  serverAddr.inet.family = PR_AF_INET;\n+  serverAddr.inet.port = listenAddr.inet.port;\n+  serverAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n \n-            if (action != CLIENT_TIMEOUT_SEND) {\n-                if ((rv = PR_Send(sock, buf, CLIENT_DATA, 0, timeoutTime)) < 0) {\n-                    if (!debug_mode) {\n-                        failed_already = 1;\n-                    } else {\n-                        PR_fprintf(output,\n-                                   \"client: unable to send to server (%d, %ld, %ld)\\n\",\n-                                   CLIENT_DATA, rv, PR_GetError());\n-                    }\n-                    goto ErrorExit;\n-                }\n-            } else {\n-                PR_Sleep(PR_SecondsToInterval(TIMEOUTSECS + 1));\n-            }\n-        } else {\n-            PR_Sleep(PR_SecondsToInterval(TIMEOUTSECS + 1));\n-        }\n-        if (debug_mode) {\n-            PR_fprintf(output, \".\");\n+  for (; iterations--;) {\n+    PRInt32 rv;\n+    char buf[CLIENT_DATA];\n+\n+    memset(buf, 0xaf, sizeof(buf)); /* initialize with arbitrary data */\n+    sock = PR_NewTCPSocket();\n+    if (!sock) {\n+      if (!debug_mode) {\n+        failed_already = 1;\n+      } else {\n+        PR_fprintf(output, \"client: unable to create socket\\n\");\n+      }\n+      return;\n+    }\n+\n+    if (action != CLIENT_TIMEOUT_ACCEPT) {\n+      if ((rv = PR_Connect(sock, &serverAddr, timeoutTime)) < 0) {\n+        if (!debug_mode) {\n+          failed_already = 1;\n+        } else\n+          PR_fprintf(\n+              output,\n+              \"client: unable to connect to server (%ld, %ld, %ld, %ld)\\n\",\n+              iterations, rv, PR_GetError(), PR_GetOSError());\n+        goto ErrorExit;\n+      }\n+\n+      if (action != CLIENT_TIMEOUT_SEND) {\n+        if ((rv = PR_Send(sock, buf, CLIENT_DATA, 0, timeoutTime)) < 0) {\n+          if (!debug_mode) {\n+            failed_already = 1;\n+          } else {\n+            PR_fprintf(output,\n+                       \"client: unable to send to server (%d, %ld, %ld)\\n\",\n+                       CLIENT_DATA, rv, PR_GetError());\n+          }\n+          goto ErrorExit;\n         }\n-        PR_Close(sock);\n-        sock = NULL;\n+      } else {\n+        PR_Sleep(PR_SecondsToInterval(TIMEOUTSECS + 1));\n+      }\n+    } else {\n+      PR_Sleep(PR_SecondsToInterval(TIMEOUTSECS + 1));\n     }\n     if (debug_mode) {\n-        PR_fprintf(output, \"\\n\");\n+      PR_fprintf(output, \".\");\n     }\n+    PR_Close(sock);\n+    sock = NULL;\n+  }\n+  if (debug_mode) {\n+    PR_fprintf(output, \"\\n\");\n+  }\n \n ErrorExit:\n-    if (sock != NULL) {\n-        PR_Close(sock);\n-    }\n+  if (sock != NULL) {\n+    PR_Close(sock);\n+  }\n }\n \n-static void\n-RunTest(PRInt32 acceptType, PRInt32 clientAction)\n-{\n-    int i;\n+static void RunTest(PRInt32 acceptType, PRInt32 clientAction) {\n+  int i;\n \n-    /* First bind to the socket */\n-    listenSock = PR_NewTCPSocket();\n-    if (!listenSock) {\n-        failed_already = 1;\n-        if (debug_mode) {\n-            PR_fprintf(output, \"unable to create listen socket\\n\");\n-        }\n-        return;\n+  /* First bind to the socket */\n+  listenSock = PR_NewTCPSocket();\n+  if (!listenSock) {\n+    failed_already = 1;\n+    if (debug_mode) {\n+      PR_fprintf(output, \"unable to create listen socket\\n\");\n     }\n-    memset(&listenAddr, 0, sizeof(listenAddr));\n-    listenAddr.inet.family = PR_AF_INET;\n-    listenAddr.inet.port = PR_htons(BASE_PORT);\n-    listenAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    /*\n-     * try a few times to bind server's address, if addresses are in\n-     * use\n-     */\n-    i = 0;\n-    while (PR_Bind(listenSock, &listenAddr) == PR_FAILURE) {\n-        if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n-            listenAddr.inet.port += 2;\n-            if (i++ < SERVER_MAX_BIND_COUNT) {\n-                continue;\n-            }\n-        }\n-        failed_already = 1;\n-        if (debug_mode) {\n-            PR_fprintf(output, \"accept: ERROR - PR_Bind failed\\n\");\n-        }\n-        return;\n+    return;\n+  }\n+  memset(&listenAddr, 0, sizeof(listenAddr));\n+  listenAddr.inet.family = PR_AF_INET;\n+  listenAddr.inet.port = PR_htons(BASE_PORT);\n+  listenAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  /*\n+   * try a few times to bind server's address, if addresses are in\n+   * use\n+   */\n+  i = 0;\n+  while (PR_Bind(listenSock, &listenAddr) == PR_FAILURE) {\n+    if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n+      listenAddr.inet.port += 2;\n+      if (i++ < SERVER_MAX_BIND_COUNT) {\n+        continue;\n+      }\n     }\n-\n-    rv = PR_Listen(listenSock, 100);\n-    if (rv == PR_FAILURE) {\n-        failed_already = 1;\n-        if (debug_mode) {\n-            PR_fprintf(output, \"unable to listen\\n\");\n-        }\n-        return;\n+    failed_already = 1;\n+    if (debug_mode) {\n+      PR_fprintf(output, \"accept: ERROR - PR_Bind failed\\n\");\n     }\n+    return;\n+  }\n \n-    clientCommand = clientAction;\n-    clientThread =\n-        PR_CreateThread(PR_USER_THREAD, ClientThread, (void*)&clientCommand,\n-                        PR_PRIORITY_NORMAL, thread_scope, PR_JOINABLE_THREAD, 0);\n-    if (!clientThread) {\n-        failed_already = 1;\n-        if (debug_mode) {\n-            PR_fprintf(output, \"error creating client thread\\n\");\n-        }\n-        return;\n+  rv = PR_Listen(listenSock, 100);\n+  if (rv == PR_FAILURE) {\n+    failed_already = 1;\n+    if (debug_mode) {\n+      PR_fprintf(output, \"unable to listen\\n\");\n     }\n-\n-    iterations = count;\n-    for (; iterations--;) {\n-        switch (acceptType) {\n-            case ACCEPT_NORMAL:\n-                clientSock = PR_Accept(listenSock, &clientAddr, timeoutTime);\n-                switch (clientAction) {\n-                    case CLIENT_TIMEOUT_ACCEPT:\n-                        TEST_ASSERT(clientSock == 0);\n-                        TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n-                        break;\n-                    case CLIENT_NORMAL:\n-                        TEST_ASSERT(clientSock);\n-                        bytesRead = PR_Recv(clientSock, buf, CLIENT_DATA, 0, timeoutTime);\n-                        TEST_ASSERT(bytesRead == CLIENT_DATA);\n-                        break;\n-                    case CLIENT_TIMEOUT_SEND:\n-                        TEST_ASSERT(clientSock);\n-                        bytesRead = PR_Recv(clientSock, buf, CLIENT_DATA, 0, timeoutTime);\n-                        TEST_ASSERT(bytesRead == -1);\n-                        TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n-                        break;\n-                }\n-                break;\n-            case ACCEPT_READ:\n-                status = PR_AcceptRead(listenSock, &clientSock, &raddr, buf,\n-                                       CLIENT_DATA, timeoutTime);\n-                switch (clientAction) {\n-                    case CLIENT_TIMEOUT_ACCEPT:\n-                        /* Invalid test case */\n-                        TEST_ASSERT(0);\n-                        break;\n-                    case CLIENT_NORMAL:\n-                        TEST_ASSERT(clientSock);\n-                        TEST_ASSERT(status == CLIENT_DATA);\n-                        break;\n-                    case CLIENT_TIMEOUT_SEND:\n-                        TEST_ASSERT(status == -1);\n-                        TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n-                        break;\n-                }\n-                break;\n+    return;\n+  }\n+\n+  clientCommand = clientAction;\n+  clientThread =\n+      PR_CreateThread(PR_USER_THREAD, ClientThread, (void*)&clientCommand,\n+                      PR_PRIORITY_NORMAL, thread_scope, PR_JOINABLE_THREAD, 0);\n+  if (!clientThread) {\n+    failed_already = 1;\n+    if (debug_mode) {\n+      PR_fprintf(output, \"error creating client thread\\n\");\n+    }\n+    return;\n+  }\n+\n+  iterations = count;\n+  for (; iterations--;) {\n+    switch (acceptType) {\n+      case ACCEPT_NORMAL:\n+        clientSock = PR_Accept(listenSock, &clientAddr, timeoutTime);\n+        switch (clientAction) {\n+          case CLIENT_TIMEOUT_ACCEPT:\n+            TEST_ASSERT(clientSock == 0);\n+            TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n+            break;\n+          case CLIENT_NORMAL:\n+            TEST_ASSERT(clientSock);\n+            bytesRead = PR_Recv(clientSock, buf, CLIENT_DATA, 0, timeoutTime);\n+            TEST_ASSERT(bytesRead == CLIENT_DATA);\n+            break;\n+          case CLIENT_TIMEOUT_SEND:\n+            TEST_ASSERT(clientSock);\n+            bytesRead = PR_Recv(clientSock, buf, CLIENT_DATA, 0, timeoutTime);\n+            TEST_ASSERT(bytesRead == -1);\n+            TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n+            break;\n+        }\n+        break;\n+      case ACCEPT_READ:\n+        status = PR_AcceptRead(listenSock, &clientSock, &raddr, buf,\n+                               CLIENT_DATA, timeoutTime);\n+        switch (clientAction) {\n+          case CLIENT_TIMEOUT_ACCEPT:\n+            /* Invalid test case */\n+            TEST_ASSERT(0);\n+            break;\n+          case CLIENT_NORMAL:\n+            TEST_ASSERT(clientSock);\n+            TEST_ASSERT(status == CLIENT_DATA);\n+            break;\n+          case CLIENT_TIMEOUT_SEND:\n+            TEST_ASSERT(status == -1);\n+            TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n+            break;\n+        }\n+        break;\n #ifdef WINNT\n-            case ACCEPT_FAST:\n-                clientSock = PR_NTFast_Accept(listenSock, &clientAddr, timeoutTime);\n-                switch (clientAction) {\n-                    case CLIENT_TIMEOUT_ACCEPT:\n-                        TEST_ASSERT(clientSock == 0);\n-                        if (debug_mode) {\n-                            PR_fprintf(output, \"PR_GetError is %ld\\n\", PR_GetError());\n-                        }\n-                        TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n-                        break;\n-                    case CLIENT_NORMAL:\n-                        TEST_ASSERT(clientSock);\n-                        bytesRead = PR_Recv(clientSock, buf, CLIENT_DATA, 0, timeoutTime);\n-                        TEST_ASSERT(bytesRead == CLIENT_DATA);\n-                        break;\n-                    case CLIENT_TIMEOUT_SEND:\n-                        TEST_ASSERT(clientSock);\n-                        bytesRead = PR_Recv(clientSock, buf, CLIENT_DATA, 0, timeoutTime);\n-                        TEST_ASSERT(bytesRead == -1);\n-                        TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n-                        break;\n-                }\n-                break;\n-                break;\n-            case ACCEPT_READ_FAST:\n-                status = PR_NTFast_AcceptRead(listenSock, &clientSock, &raddr, buf,\n-                                              4096, timeoutTime);\n-                switch (clientAction) {\n-                    case CLIENT_TIMEOUT_ACCEPT:\n-                        /* Invalid test case */\n-                        TEST_ASSERT(0);\n-                        break;\n-                    case CLIENT_NORMAL:\n-                        TEST_ASSERT(clientSock);\n-                        TEST_ASSERT(status == CLIENT_DATA);\n-                        break;\n-                    case CLIENT_TIMEOUT_SEND:\n-                        TEST_ASSERT(clientSock == NULL);\n-                        TEST_ASSERT(status == -1);\n-                        TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n-                        break;\n-                }\n-                break;\n-            case ACCEPT_READ_FAST_CB:\n-                status = PR_NTFast_AcceptRead_WithTimeoutCallback(\n-                    listenSock, &clientSock, &raddr, buf, 4096, timeoutTime,\n-                    timeout_callback, (void*)CALLBACK_MAGIC);\n-                switch (clientAction) {\n-                    case CLIENT_TIMEOUT_ACCEPT:\n-                        /* Invalid test case */\n-                        TEST_ASSERT(0);\n-                        break;\n-                    case CLIENT_NORMAL:\n-                        TEST_ASSERT(clientSock);\n-                        TEST_ASSERT(status == CLIENT_DATA);\n-                        break;\n-                    case CLIENT_TIMEOUT_SEND:\n-                        if (debug_mode) {\n-                            PR_fprintf(output, \"clientSock = 0x%8.8lx\\n\", clientSock);\n-                        }\n-                        TEST_ASSERT(clientSock == NULL);\n-                        TEST_ASSERT(status == -1);\n-                        TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n-                        break;\n-                }\n-                break;\n-#endif\n+      case ACCEPT_FAST:\n+        clientSock = PR_NTFast_Accept(listenSock, &clientAddr, timeoutTime);\n+        switch (clientAction) {\n+          case CLIENT_TIMEOUT_ACCEPT:\n+            TEST_ASSERT(clientSock == 0);\n+            if (debug_mode) {\n+              PR_fprintf(output, \"PR_GetError is %ld\\n\", PR_GetError());\n+            }\n+            TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n+            break;\n+          case CLIENT_NORMAL:\n+            TEST_ASSERT(clientSock);\n+            bytesRead = PR_Recv(clientSock, buf, CLIENT_DATA, 0, timeoutTime);\n+            TEST_ASSERT(bytesRead == CLIENT_DATA);\n+            break;\n+          case CLIENT_TIMEOUT_SEND:\n+            TEST_ASSERT(clientSock);\n+            bytesRead = PR_Recv(clientSock, buf, CLIENT_DATA, 0, timeoutTime);\n+            TEST_ASSERT(bytesRead == -1);\n+            TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n+            break;\n         }\n-        if (clientSock != NULL) {\n-            PR_Close(clientSock);\n-            clientSock = NULL;\n+        break;\n+        break;\n+      case ACCEPT_READ_FAST:\n+        status = PR_NTFast_AcceptRead(listenSock, &clientSock, &raddr, buf,\n+                                      4096, timeoutTime);\n+        switch (clientAction) {\n+          case CLIENT_TIMEOUT_ACCEPT:\n+            /* Invalid test case */\n+            TEST_ASSERT(0);\n+            break;\n+          case CLIENT_NORMAL:\n+            TEST_ASSERT(clientSock);\n+            TEST_ASSERT(status == CLIENT_DATA);\n+            break;\n+          case CLIENT_TIMEOUT_SEND:\n+            TEST_ASSERT(clientSock == NULL);\n+            TEST_ASSERT(status == -1);\n+            TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n+            break;\n+        }\n+        break;\n+      case ACCEPT_READ_FAST_CB:\n+        status = PR_NTFast_AcceptRead_WithTimeoutCallback(\n+            listenSock, &clientSock, &raddr, buf, 4096, timeoutTime,\n+            timeout_callback, (void*)CALLBACK_MAGIC);\n+        switch (clientAction) {\n+          case CLIENT_TIMEOUT_ACCEPT:\n+            /* Invalid test case */\n+            TEST_ASSERT(0);\n+            break;\n+          case CLIENT_NORMAL:\n+            TEST_ASSERT(clientSock);\n+            TEST_ASSERT(status == CLIENT_DATA);\n+            break;\n+          case CLIENT_TIMEOUT_SEND:\n+            if (debug_mode) {\n+              PR_fprintf(output, \"clientSock = 0x%8.8lx\\n\", clientSock);\n+            }\n+            TEST_ASSERT(clientSock == NULL);\n+            TEST_ASSERT(status == -1);\n+            TEST_ASSERT(PR_GetError() == PR_IO_TIMEOUT_ERROR);\n+            break;\n         }\n+        break;\n+#endif\n+    }\n+    if (clientSock != NULL) {\n+      PR_Close(clientSock);\n+      clientSock = NULL;\n     }\n-    PR_Close(listenSock);\n+  }\n+  PR_Close(listenSock);\n \n-    PR_JoinThread(clientThread);\n+  PR_JoinThread(clientThread);\n }\n \n-void\n-AcceptUpdatedTest(void)\n-{\n-    RunTest(ACCEPT_NORMAL, CLIENT_NORMAL);\n-}\n-void\n-AcceptNotUpdatedTest(void)\n-{\n-    RunTest(ACCEPT_FAST, CLIENT_NORMAL);\n+void AcceptUpdatedTest(void) { RunTest(ACCEPT_NORMAL, CLIENT_NORMAL); }\n+void AcceptNotUpdatedTest(void) { RunTest(ACCEPT_FAST, CLIENT_NORMAL); }\n+void AcceptReadTest(void) { RunTest(ACCEPT_READ, CLIENT_NORMAL); }\n+void AcceptReadNotUpdatedTest(void) {\n+  RunTest(ACCEPT_READ_FAST, CLIENT_NORMAL);\n }\n-void\n-AcceptReadTest(void)\n-{\n-    RunTest(ACCEPT_READ, CLIENT_NORMAL);\n-}\n-void\n-AcceptReadNotUpdatedTest(void)\n-{\n-    RunTest(ACCEPT_READ_FAST, CLIENT_NORMAL);\n-}\n-void\n-AcceptReadCallbackTest(void)\n-{\n-    RunTest(ACCEPT_READ_FAST_CB, CLIENT_NORMAL);\n+void AcceptReadCallbackTest(void) {\n+  RunTest(ACCEPT_READ_FAST_CB, CLIENT_NORMAL);\n }\n \n-void\n-TimeoutAcceptUpdatedTest(void)\n-{\n-    RunTest(ACCEPT_NORMAL, CLIENT_TIMEOUT_ACCEPT);\n+void TimeoutAcceptUpdatedTest(void) {\n+  RunTest(ACCEPT_NORMAL, CLIENT_TIMEOUT_ACCEPT);\n }\n-void\n-TimeoutAcceptNotUpdatedTest(void)\n-{\n-    RunTest(ACCEPT_FAST, CLIENT_TIMEOUT_ACCEPT);\n+void TimeoutAcceptNotUpdatedTest(void) {\n+  RunTest(ACCEPT_FAST, CLIENT_TIMEOUT_ACCEPT);\n }\n-void\n-TimeoutAcceptReadCallbackTest(void)\n-{\n-    RunTest(ACCEPT_READ_FAST_CB, CLIENT_TIMEOUT_ACCEPT);\n+void TimeoutAcceptReadCallbackTest(void) {\n+  RunTest(ACCEPT_READ_FAST_CB, CLIENT_TIMEOUT_ACCEPT);\n }\n \n-void\n-TimeoutReadUpdatedTest(void)\n-{\n-    RunTest(ACCEPT_NORMAL, CLIENT_TIMEOUT_SEND);\n+void TimeoutReadUpdatedTest(void) {\n+  RunTest(ACCEPT_NORMAL, CLIENT_TIMEOUT_SEND);\n }\n-void\n-TimeoutReadNotUpdatedTest(void)\n-{\n-    RunTest(ACCEPT_FAST, CLIENT_TIMEOUT_SEND);\n+void TimeoutReadNotUpdatedTest(void) {\n+  RunTest(ACCEPT_FAST, CLIENT_TIMEOUT_SEND);\n }\n-void\n-TimeoutReadReadTest(void)\n-{\n-    RunTest(ACCEPT_READ, CLIENT_TIMEOUT_SEND);\n+void TimeoutReadReadTest(void) { RunTest(ACCEPT_READ, CLIENT_TIMEOUT_SEND); }\n+void TimeoutReadReadNotUpdatedTest(void) {\n+  RunTest(ACCEPT_READ_FAST, CLIENT_TIMEOUT_SEND);\n }\n-void\n-TimeoutReadReadNotUpdatedTest(void)\n-{\n-    RunTest(ACCEPT_READ_FAST, CLIENT_TIMEOUT_SEND);\n-}\n-void\n-TimeoutReadReadCallbackTest(void)\n-{\n-    RunTest(ACCEPT_READ_FAST_CB, CLIENT_TIMEOUT_SEND);\n+void TimeoutReadReadCallbackTest(void) {\n+  RunTest(ACCEPT_READ_FAST_CB, CLIENT_TIMEOUT_SEND);\n }\n \n /************************************************************************/\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow();\n \n-    d = (double)PR_IntervalToMicroseconds(stop - start);\n-    if (debug_mode) {\n-        PR_fprintf(output, \"%40s: %6.2f usec\\n\", msg, d / count);\n-    }\n+  d = (double)PR_IntervalToMicroseconds(stop - start);\n+  if (debug_mode) {\n+    PR_fprintf(output, \"%40s: %6.2f usec\\n\", msg, d / count);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name [-d] [-c n]\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"Gdc:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'G': /* global threads */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            case 'c': /* loop counter */\n-                count = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name [-d] [-c n]\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"Gdc:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n+    switch (opt->option) {\n+      case 'G': /* global threads */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      case 'c': /* loop counter */\n+        count = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-    output = PR_STDERR;\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  output = PR_STDERR;\n \n-    timeoutTime = PR_SecondsToInterval(TIMEOUTSECS);\n-    if (debug_mode) {\n-        PR_fprintf(output, \"\\nRun accept() sucessful connection tests\\n\");\n-    }\n+  timeoutTime = PR_SecondsToInterval(TIMEOUTSECS);\n+  if (debug_mode) {\n+    PR_fprintf(output, \"\\nRun accept() sucessful connection tests\\n\");\n+  }\n \n-    Measure(AcceptUpdatedTest, \"PR_Accept()\");\n-    Measure(AcceptReadTest, \"PR_AcceptRead()\");\n+  Measure(AcceptUpdatedTest, \"PR_Accept()\");\n+  Measure(AcceptReadTest, \"PR_AcceptRead()\");\n #ifdef WINNT\n-    Measure(AcceptNotUpdatedTest, \"PR_NTFast_Accept()\");\n-    Measure(AcceptReadNotUpdatedTest, \"PR_NTFast_AcceptRead()\");\n-    Measure(AcceptReadCallbackTest, \"PR_NTFast_AcceptRead_WithTimeoutCallback()\");\n+  Measure(AcceptNotUpdatedTest, \"PR_NTFast_Accept()\");\n+  Measure(AcceptReadNotUpdatedTest, \"PR_NTFast_AcceptRead()\");\n+  Measure(AcceptReadCallbackTest, \"PR_NTFast_AcceptRead_WithTimeoutCallback()\");\n #endif\n-    if (debug_mode) {\n-        PR_fprintf(output, \"\\nRun accept() timeout in the accept tests\\n\");\n-    }\n+  if (debug_mode) {\n+    PR_fprintf(output, \"\\nRun accept() timeout in the accept tests\\n\");\n+  }\n #ifdef WINNT\n-    Measure(TimeoutReadReadCallbackTest,\n-            \"PR_NTFast_AcceptRead_WithTimeoutCallback()\");\n+  Measure(TimeoutReadReadCallbackTest,\n+          \"PR_NTFast_AcceptRead_WithTimeoutCallback()\");\n #endif\n-    Measure(TimeoutReadUpdatedTest, \"PR_Accept()\");\n-    if (debug_mode) {\n-        PR_fprintf(output, \"\\nRun accept() timeout in the read tests\\n\");\n-    }\n-    Measure(TimeoutReadReadTest, \"PR_AcceptRead()\");\n+  Measure(TimeoutReadUpdatedTest, \"PR_Accept()\");\n+  if (debug_mode) {\n+    PR_fprintf(output, \"\\nRun accept() timeout in the read tests\\n\");\n+  }\n+  Measure(TimeoutReadReadTest, \"PR_AcceptRead()\");\n #ifdef WINNT\n-    Measure(TimeoutReadNotUpdatedTest, \"PR_NTFast_Accept()\");\n-    Measure(TimeoutReadReadNotUpdatedTest, \"PR_NTFast_AcceptRead()\");\n-    Measure(TimeoutReadReadCallbackTest,\n-            \"PR_NTFast_AcceptRead_WithTimeoutCallback()\");\n+  Measure(TimeoutReadNotUpdatedTest, \"PR_NTFast_Accept()\");\n+  Measure(TimeoutReadReadNotUpdatedTest, \"PR_NTFast_AcceptRead()\");\n+  Measure(TimeoutReadReadCallbackTest,\n+          \"PR_NTFast_AcceptRead_WithTimeoutCallback()\");\n #endif\n-    PR_fprintf(output, \"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n-    return failed_already;\n+  PR_fprintf(output, \"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n+  return failed_already;\n }\ndiff --git a/nspr/pr/tests/acceptread.c b/nspr/pr/tests/acceptread.c\nindex a151c39..036f4bb 100644\n--- a/nspr/pr/tests/acceptread.c\n+++ b/nspr/pr/tests/acceptread.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -14,14 +15,14 @@\n #include <stdlib.h>\n \n #ifdef DEBUG\n-#define PORT_INC_DO +100\n+#  define PORT_INC_DO +100\n #else\n-#define PORT_INC_DO\n+#  define PORT_INC_DO\n #endif\n #ifdef IS_64\n-#define PORT_INC_3264 +200\n+#  define PORT_INC_3264 +200\n #else\n-#define PORT_INC_3264\n+#  define PORT_INC_3264\n #endif\n \n #define DEFAULT_PORT 12273 PORT_INC_DO PORT_INC_3264\n@@ -29,215 +30,207 @@\n static PRFileDesc *std_out, *err_out;\n static PRIntervalTime write_dally, accept_timeout;\n \n-static PRStatus\n-PrintAddress(const PRNetAddr* address)\n-{\n-    char buffer[100];\n-    PRStatus rv = PR_NetAddrToString(address, buffer, sizeof(buffer));\n-    if (PR_FAILURE == rv) {\n-        PL_FPrintError(err_out, \"PR_NetAddrToString\");\n-    } else\n-        PR_fprintf(std_out, \"Accepted connection from (0x%p)%s:%d\\n\", address,\n-                   buffer, address->inet.port);\n-    return rv;\n+static PRStatus PrintAddress(const PRNetAddr* address) {\n+  char buffer[100];\n+  PRStatus rv = PR_NetAddrToString(address, buffer, sizeof(buffer));\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err_out, \"PR_NetAddrToString\");\n+  } else\n+    PR_fprintf(std_out, \"Accepted connection from (0x%p)%s:%d\\n\", address,\n+               buffer, address->inet.port);\n+  return rv;\n } /* PrintAddress */\n \n-static void\n-ConnectingThread(void* arg)\n-{\n-    PRInt32 nbytes;\n-    char buf[1024];\n-    PRFileDesc* sock;\n-    PRNetAddr peer_addr, *addr;\n-\n-    addr = (PRNetAddr*)arg;\n-\n-    sock = PR_NewTCPSocket();\n-    if (sock == NULL) {\n-        PL_FPrintError(err_out, \"PR_NewTCPSocket (client) failed\");\n-        PR_ProcessExit(1);\n-    }\n-\n-    if (PR_Connect(sock, addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n-        PL_FPrintError(err_out, \"PR_Connect (client) failed\");\n-        PR_ProcessExit(1);\n-    }\n-    if (PR_GetPeerName(sock, &peer_addr) == PR_FAILURE) {\n-        PL_FPrintError(err_out, \"PR_GetPeerName (client) failed\");\n-        PR_ProcessExit(1);\n-    }\n-\n-    /*\n-    ** Then wait between the connection coming up and sending the expected\n-    ** data. At some point in time, the server should fail due to a timeou\n-    ** on the AcceptRead() operation, which according to the document is\n-    ** only due to the read() portion.\n-    */\n-    PR_Sleep(write_dally);\n-\n-    nbytes = PR_Send(sock, GET, sizeof(GET), 0, PR_INTERVAL_NO_TIMEOUT);\n-    if (nbytes == -1) {\n-        PL_FPrintError(err_out, \"PR_Send (client) failed\");\n-    }\n-\n-    nbytes = PR_Recv(sock, buf, sizeof(buf), 0, PR_INTERVAL_NO_TIMEOUT);\n-    if (nbytes == -1) {\n-        PL_FPrintError(err_out, \"PR_Recv (client) failed\");\n-    } else {\n-        PR_fprintf(std_out, \"PR_Recv (client) succeeded: %d bytes\\n\", nbytes);\n-        buf[sizeof(buf) - 1] = '\\0';\n-        PR_fprintf(std_out, \"%s\\n\", buf);\n-    }\n-\n-    if (PR_FAILURE == PR_Shutdown(sock, PR_SHUTDOWN_BOTH)) {\n-        PL_FPrintError(err_out, \"PR_Shutdown (client) failed\");\n-    }\n-\n-    if (PR_FAILURE == PR_Close(sock)) {\n-        PL_FPrintError(err_out, \"PR_Close (client) failed\");\n-    }\n-\n-    return;\n+static void ConnectingThread(void* arg) {\n+  PRInt32 nbytes;\n+  char buf[1024];\n+  PRFileDesc* sock;\n+  PRNetAddr peer_addr, *addr;\n+\n+  addr = (PRNetAddr*)arg;\n+\n+  sock = PR_NewTCPSocket();\n+  if (sock == NULL) {\n+    PL_FPrintError(err_out, \"PR_NewTCPSocket (client) failed\");\n+    PR_ProcessExit(1);\n+  }\n+\n+  if (PR_Connect(sock, addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n+    PL_FPrintError(err_out, \"PR_Connect (client) failed\");\n+    PR_ProcessExit(1);\n+  }\n+  if (PR_GetPeerName(sock, &peer_addr) == PR_FAILURE) {\n+    PL_FPrintError(err_out, \"PR_GetPeerName (client) failed\");\n+    PR_ProcessExit(1);\n+  }\n+\n+  /*\n+  ** Then wait between the connection coming up and sending the expected\n+  ** data. At some point in time, the server should fail due to a timeou\n+  ** on the AcceptRead() operation, which according to the document is\n+  ** only due to the read() portion.\n+  */\n+  PR_Sleep(write_dally);\n+\n+  nbytes = PR_Send(sock, GET, sizeof(GET), 0, PR_INTERVAL_NO_TIMEOUT);\n+  if (nbytes == -1) {\n+    PL_FPrintError(err_out, \"PR_Send (client) failed\");\n+  }\n+\n+  nbytes = PR_Recv(sock, buf, sizeof(buf), 0, PR_INTERVAL_NO_TIMEOUT);\n+  if (nbytes == -1) {\n+    PL_FPrintError(err_out, \"PR_Recv (client) failed\");\n+  } else {\n+    PR_fprintf(std_out, \"PR_Recv (client) succeeded: %d bytes\\n\", nbytes);\n+    buf[sizeof(buf) - 1] = '\\0';\n+    PR_fprintf(std_out, \"%s\\n\", buf);\n+  }\n+\n+  if (PR_FAILURE == PR_Shutdown(sock, PR_SHUTDOWN_BOTH)) {\n+    PL_FPrintError(err_out, \"PR_Shutdown (client) failed\");\n+  }\n+\n+  if (PR_FAILURE == PR_Close(sock)) {\n+    PL_FPrintError(err_out, \"PR_Close (client) failed\");\n+  }\n+\n+  return;\n } /* ConnectingThread */\n \n #define BUF_SIZE 117\n-static void\n-AcceptingThread(void* arg)\n-{\n-    PRStatus rv;\n-    PRInt32 bytes;\n-    PRSize buf_size = BUF_SIZE;\n-    PRUint8 buf[BUF_SIZE + (2 * sizeof(PRNetAddr)) + 32];\n-    PRNetAddr *accept_addr, *listen_addr = (PRNetAddr*)arg;\n-    PRFileDesc *accept_sock, *listen_sock = PR_NewTCPSocket();\n-    PRSocketOptionData sock_opt;\n-\n-    if (NULL == listen_sock) {\n-        PL_FPrintError(err_out, \"PR_NewTCPSocket (server) failed\");\n-        PR_ProcessExit(1);\n-    }\n-    sock_opt.option = PR_SockOpt_Reuseaddr;\n-    sock_opt.value.reuse_addr = PR_TRUE;\n-    rv = PR_SetSocketOption(listen_sock, &sock_opt);\n+static void AcceptingThread(void* arg) {\n+  PRStatus rv;\n+  PRInt32 bytes;\n+  PRSize buf_size = BUF_SIZE;\n+  PRUint8 buf[BUF_SIZE + (2 * sizeof(PRNetAddr)) + 32];\n+  PRNetAddr *accept_addr, *listen_addr = (PRNetAddr*)arg;\n+  PRFileDesc *accept_sock, *listen_sock = PR_NewTCPSocket();\n+  PRSocketOptionData sock_opt;\n+\n+  if (NULL == listen_sock) {\n+    PL_FPrintError(err_out, \"PR_NewTCPSocket (server) failed\");\n+    PR_ProcessExit(1);\n+  }\n+  sock_opt.option = PR_SockOpt_Reuseaddr;\n+  sock_opt.value.reuse_addr = PR_TRUE;\n+  rv = PR_SetSocketOption(listen_sock, &sock_opt);\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err_out, \"PR_SetSocketOption (server) failed\");\n+    PR_ProcessExit(1);\n+  }\n+  rv = PR_Bind(listen_sock, listen_addr);\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err_out, \"PR_Bind (server) failed\");\n+    PR_ProcessExit(1);\n+  }\n+  rv = PR_Listen(listen_sock, 10);\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err_out, \"PR_Listen (server) failed\");\n+    PR_ProcessExit(1);\n+  }\n+  bytes = PR_AcceptRead(listen_sock, &accept_sock, &accept_addr, buf, buf_size,\n+                        accept_timeout);\n+\n+  if (-1 == bytes) {\n+    PL_FPrintError(err_out, \"PR_AcceptRead (server) failed\");\n+  } else {\n+    PrintAddress(accept_addr);\n+    PR_fprintf(std_out, \"(Server) read [0x%p..0x%p) %s\\n\", buf, &buf[BUF_SIZE],\n+               buf);\n+    bytes = PR_Write(accept_sock, buf, bytes);\n+    rv = PR_Shutdown(accept_sock, PR_SHUTDOWN_BOTH);\n     if (PR_FAILURE == rv) {\n-        PL_FPrintError(err_out, \"PR_SetSocketOption (server) failed\");\n-        PR_ProcessExit(1);\n+      PL_FPrintError(err_out, \"PR_Shutdown (server) failed\");\n     }\n-    rv = PR_Bind(listen_sock, listen_addr);\n+  }\n+\n+  if (-1 != bytes) {\n+    rv = PR_Close(accept_sock);\n     if (PR_FAILURE == rv) {\n-        PL_FPrintError(err_out, \"PR_Bind (server) failed\");\n-        PR_ProcessExit(1);\n+      PL_FPrintError(err_out, \"PR_Close (server) failed\");\n     }\n-    rv = PR_Listen(listen_sock, 10);\n-    if (PR_FAILURE == rv) {\n-        PL_FPrintError(err_out, \"PR_Listen (server) failed\");\n-        PR_ProcessExit(1);\n+  }\n+\n+  rv = PR_Close(listen_sock);\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err_out, \"PR_Close (server) failed\");\n+  }\n+} /* AcceptingThread */\n+\n+int main(int argc, char** argv) {\n+  PRHostEnt he;\n+  PRStatus status;\n+  PRIntn next_index;\n+  PRUint16 port_number;\n+  char netdb_buf[PR_NETDB_BUF_SIZE];\n+  PRNetAddr client_addr, server_addr;\n+  PRThread *client_thread, *server_thread;\n+  PRIntervalTime delta = PR_MillisecondsToInterval(500);\n+\n+  err_out = PR_STDERR;\n+  std_out = PR_STDOUT;\n+  accept_timeout = PR_SecondsToInterval(2);\n+\n+  if (argc != 2 && argc != 3) {\n+    port_number = DEFAULT_PORT;\n+  } else {\n+    port_number = (PRUint16)atoi(argv[(argc == 2) ? 1 : 2]);\n+  }\n+\n+  status = PR_InitializeNetAddr(PR_IpAddrAny, port_number, &server_addr);\n+  if (PR_SUCCESS != status) {\n+    PL_FPrintError(err_out, \"PR_InitializeNetAddr failed\");\n+    PR_ProcessExit(1);\n+  }\n+  if (argc < 3) {\n+    status = PR_InitializeNetAddr(PR_IpAddrLoopback, port_number, &client_addr);\n+    if (PR_SUCCESS != status) {\n+      PL_FPrintError(err_out, \"PR_InitializeNetAddr failed\");\n+      PR_ProcessExit(1);\n     }\n-    bytes = PR_AcceptRead(listen_sock, &accept_sock, &accept_addr, buf, buf_size,\n-                          accept_timeout);\n-\n-    if (-1 == bytes) {\n-        PL_FPrintError(err_out, \"PR_AcceptRead (server) failed\");\n-    } else {\n-        PrintAddress(accept_addr);\n-        PR_fprintf(std_out, \"(Server) read [0x%p..0x%p) %s\\n\", buf, &buf[BUF_SIZE],\n-                   buf);\n-        bytes = PR_Write(accept_sock, buf, bytes);\n-        rv = PR_Shutdown(accept_sock, PR_SHUTDOWN_BOTH);\n-        if (PR_FAILURE == rv) {\n-            PL_FPrintError(err_out, \"PR_Shutdown (server) failed\");\n-        }\n+  } else {\n+    status = PR_GetHostByName(argv[1], netdb_buf, sizeof(netdb_buf), &he);\n+    if (status == PR_FAILURE) {\n+      PL_FPrintError(err_out, \"PR_GetHostByName failed\");\n+      PR_ProcessExit(1);\n     }\n-\n-    if (-1 != bytes) {\n-        rv = PR_Close(accept_sock);\n-        if (PR_FAILURE == rv) {\n-            PL_FPrintError(err_out, \"PR_Close (server) failed\");\n-        }\n+    next_index = PR_EnumerateHostEnt(0, &he, port_number, &client_addr);\n+    if (next_index == -1) {\n+      PL_FPrintError(err_out, \"PR_EnumerateHostEnt failed\");\n+      PR_ProcessExit(1);\n     }\n+  }\n \n-    rv = PR_Close(listen_sock);\n-    if (PR_FAILURE == rv) {\n-        PL_FPrintError(err_out, \"PR_Close (server) failed\");\n+  for (write_dally = 0; write_dally < accept_timeout + (2 * delta);\n+       write_dally += delta) {\n+    PR_fprintf(std_out, \"Testing w/ write_dally = %d msec\\n\",\n+               PR_IntervalToMilliseconds(write_dally));\n+    server_thread = PR_CreateThread(PR_USER_THREAD, AcceptingThread,\n+                                    &server_addr, PR_PRIORITY_NORMAL,\n+                                    PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+    if (server_thread == NULL) {\n+      PL_FPrintError(err_out, \"PR_CreateThread (server) failed\");\n+      PR_ProcessExit(1);\n     }\n-} /* AcceptingThread */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRHostEnt he;\n-    PRStatus status;\n-    PRIntn next_index;\n-    PRUint16 port_number;\n-    char netdb_buf[PR_NETDB_BUF_SIZE];\n-    PRNetAddr client_addr, server_addr;\n-    PRThread *client_thread, *server_thread;\n-    PRIntervalTime delta = PR_MillisecondsToInterval(500);\n-\n-    err_out = PR_STDERR;\n-    std_out = PR_STDOUT;\n-    accept_timeout = PR_SecondsToInterval(2);\n-\n-    if (argc != 2 && argc != 3) {\n-        port_number = DEFAULT_PORT;\n-    } else {\n-        port_number = (PRUint16)atoi(argv[(argc == 2) ? 1 : 2]);\n-    }\n+    PR_Sleep(delta); /* let the server pot thicken */\n \n-    status = PR_InitializeNetAddr(PR_IpAddrAny, port_number, &server_addr);\n-    if (PR_SUCCESS != status) {\n-        PL_FPrintError(err_out, \"PR_InitializeNetAddr failed\");\n-        PR_ProcessExit(1);\n+    client_thread = PR_CreateThread(PR_USER_THREAD, ConnectingThread,\n+                                    &client_addr, PR_PRIORITY_NORMAL,\n+                                    PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+    if (client_thread == NULL) {\n+      PL_FPrintError(err_out, \"PR_CreateThread (client) failed\");\n+      PR_ProcessExit(1);\n     }\n-    if (argc < 3) {\n-        status = PR_InitializeNetAddr(PR_IpAddrLoopback, port_number, &client_addr);\n-        if (PR_SUCCESS != status) {\n-            PL_FPrintError(err_out, \"PR_InitializeNetAddr failed\");\n-            PR_ProcessExit(1);\n-        }\n-    } else {\n-        status = PR_GetHostByName(argv[1], netdb_buf, sizeof(netdb_buf), &he);\n-        if (status == PR_FAILURE) {\n-            PL_FPrintError(err_out, \"PR_GetHostByName failed\");\n-            PR_ProcessExit(1);\n-        }\n-        next_index = PR_EnumerateHostEnt(0, &he, port_number, &client_addr);\n-        if (next_index == -1) {\n-            PL_FPrintError(err_out, \"PR_EnumerateHostEnt failed\");\n-            PR_ProcessExit(1);\n-        }\n+\n+    if (PR_JoinThread(client_thread) == PR_FAILURE) {\n+      PL_FPrintError(err_out, \"PR_JoinThread (client) failed\");\n     }\n \n-    for (write_dally = 0; write_dally < accept_timeout + (2 * delta);\n-         write_dally += delta) {\n-        PR_fprintf(std_out, \"Testing w/ write_dally = %d msec\\n\",\n-                   PR_IntervalToMilliseconds(write_dally));\n-        server_thread = PR_CreateThread(PR_USER_THREAD, AcceptingThread,\n-                                        &server_addr, PR_PRIORITY_NORMAL,\n-                                        PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-        if (server_thread == NULL) {\n-            PL_FPrintError(err_out, \"PR_CreateThread (server) failed\");\n-            PR_ProcessExit(1);\n-        }\n-\n-        PR_Sleep(delta); /* let the server pot thicken */\n-\n-        client_thread = PR_CreateThread(PR_USER_THREAD, ConnectingThread,\n-                                        &client_addr, PR_PRIORITY_NORMAL,\n-                                        PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-        if (client_thread == NULL) {\n-            PL_FPrintError(err_out, \"PR_CreateThread (client) failed\");\n-            PR_ProcessExit(1);\n-        }\n-\n-        if (PR_JoinThread(client_thread) == PR_FAILURE) {\n-            PL_FPrintError(err_out, \"PR_JoinThread (client) failed\");\n-        }\n-\n-        if (PR_JoinThread(server_thread) == PR_FAILURE) {\n-            PL_FPrintError(err_out, \"PR_JoinThread (server) failed\");\n-        }\n+    if (PR_JoinThread(server_thread) == PR_FAILURE) {\n+      PL_FPrintError(err_out, \"PR_JoinThread (server) failed\");\n     }\n+  }\n \n-    return 0;\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/acceptreademu.c b/nspr/pr/tests/acceptreademu.c\nindex 616f233..f489ca9 100644\n--- a/nspr/pr/tests/acceptreademu.c\n+++ b/nspr/pr/tests/acceptreademu.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -20,14 +21,14 @@\n #include <stdlib.h>\n \n #ifdef DEBUG\n-#define PORT_INC_DO +100\n+#  define PORT_INC_DO +100\n #else\n-#define PORT_INC_DO\n+#  define PORT_INC_DO\n #endif\n #ifdef IS_64\n-#define PORT_INC_3264 +200\n+#  define PORT_INC_3264 +200\n #else\n-#define PORT_INC_3264\n+#  define PORT_INC_3264\n #endif\n \n #define DEFAULT_PORT 12273 PORT_INC_DO PORT_INC_3264\n@@ -38,237 +39,227 @@ static PRDescIdentity emu_layer_ident;\n static PRIOMethods emu_layer_methods;\n \n /* the acceptread method in emu_layer_methods */\n-static PRInt32 PR_CALLBACK\n-emu_AcceptRead(PRFileDesc* sd, PRFileDesc** nd,\n-               PRNetAddr** raddr, void* buf,\n-               PRInt32 amount,\n-               PRIntervalTime timeout)\n-{\n-    return PR_EmulateAcceptRead(sd, nd, raddr, buf, amount, timeout);\n+static PRInt32 PR_CALLBACK emu_AcceptRead(PRFileDesc* sd, PRFileDesc** nd,\n+                                          PRNetAddr** raddr, void* buf,\n+                                          PRInt32 amount,\n+                                          PRIntervalTime timeout) {\n+  return PR_EmulateAcceptRead(sd, nd, raddr, buf, amount, timeout);\n }\n \n-static PRStatus\n-PrintAddress(const PRNetAddr* address)\n-{\n-    char buffer[100];\n-    PRStatus rv = PR_NetAddrToString(address, buffer, sizeof(buffer));\n-    if (PR_FAILURE == rv) {\n-        PL_FPrintError(err_out, \"PR_NetAddrToString\");\n-    } else\n-        PR_fprintf(std_out, \"Accepted connection from (0x%p)%s:%d\\n\", address,\n-                   buffer, address->inet.port);\n-    return rv;\n+static PRStatus PrintAddress(const PRNetAddr* address) {\n+  char buffer[100];\n+  PRStatus rv = PR_NetAddrToString(address, buffer, sizeof(buffer));\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err_out, \"PR_NetAddrToString\");\n+  } else\n+    PR_fprintf(std_out, \"Accepted connection from (0x%p)%s:%d\\n\", address,\n+               buffer, address->inet.port);\n+  return rv;\n } /* PrintAddress */\n \n-static void\n-ConnectingThread(void* arg)\n-{\n-    PRInt32 nbytes;\n-    char buf[1024];\n-    PRFileDesc* sock;\n-    PRNetAddr peer_addr, *addr;\n-\n-    addr = (PRNetAddr*)arg;\n-\n-    sock = PR_NewTCPSocket();\n-    if (sock == NULL) {\n-        PL_FPrintError(err_out, \"PR_NewTCPSocket (client) failed\");\n-        PR_ProcessExit(1);\n-    }\n-\n-    if (PR_Connect(sock, addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n-        PL_FPrintError(err_out, \"PR_Connect (client) failed\");\n-        PR_ProcessExit(1);\n-    }\n-    if (PR_GetPeerName(sock, &peer_addr) == PR_FAILURE) {\n-        PL_FPrintError(err_out, \"PR_GetPeerName (client) failed\");\n-        PR_ProcessExit(1);\n-    }\n-\n-    /*\n-    ** Then wait between the connection coming up and sending the expected\n-    ** data. At some point in time, the server should fail due to a timeou\n-    ** on the AcceptRead() operation, which according to the document is\n-    ** only due to the read() portion.\n-    */\n-    PR_Sleep(write_dally);\n-\n-    nbytes = PR_Send(sock, GET, sizeof(GET), 0, PR_INTERVAL_NO_TIMEOUT);\n-    if (nbytes == -1) {\n-        PL_FPrintError(err_out, \"PR_Send (client) failed\");\n-    }\n-\n-    nbytes = PR_Recv(sock, buf, sizeof(buf), 0, PR_INTERVAL_NO_TIMEOUT);\n-    if (nbytes == -1) {\n-        PL_FPrintError(err_out, \"PR_Recv (client) failed\");\n-    } else {\n-        PR_fprintf(std_out, \"PR_Recv (client) succeeded: %d bytes\\n\", nbytes);\n-        buf[sizeof(buf) - 1] = '\\0';\n-        PR_fprintf(std_out, \"%s\\n\", buf);\n-    }\n-\n-    if (PR_FAILURE == PR_Shutdown(sock, PR_SHUTDOWN_BOTH)) {\n-        PL_FPrintError(err_out, \"PR_Shutdown (client) failed\");\n-    }\n-\n-    if (PR_FAILURE == PR_Close(sock)) {\n-        PL_FPrintError(err_out, \"PR_Close (client) failed\");\n-    }\n-\n-    return;\n+static void ConnectingThread(void* arg) {\n+  PRInt32 nbytes;\n+  char buf[1024];\n+  PRFileDesc* sock;\n+  PRNetAddr peer_addr, *addr;\n+\n+  addr = (PRNetAddr*)arg;\n+\n+  sock = PR_NewTCPSocket();\n+  if (sock == NULL) {\n+    PL_FPrintError(err_out, \"PR_NewTCPSocket (client) failed\");\n+    PR_ProcessExit(1);\n+  }\n+\n+  if (PR_Connect(sock, addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n+    PL_FPrintError(err_out, \"PR_Connect (client) failed\");\n+    PR_ProcessExit(1);\n+  }\n+  if (PR_GetPeerName(sock, &peer_addr) == PR_FAILURE) {\n+    PL_FPrintError(err_out, \"PR_GetPeerName (client) failed\");\n+    PR_ProcessExit(1);\n+  }\n+\n+  /*\n+  ** Then wait between the connection coming up and sending the expected\n+  ** data. At some point in time, the server should fail due to a timeou\n+  ** on the AcceptRead() operation, which according to the document is\n+  ** only due to the read() portion.\n+  */\n+  PR_Sleep(write_dally);\n+\n+  nbytes = PR_Send(sock, GET, sizeof(GET), 0, PR_INTERVAL_NO_TIMEOUT);\n+  if (nbytes == -1) {\n+    PL_FPrintError(err_out, \"PR_Send (client) failed\");\n+  }\n+\n+  nbytes = PR_Recv(sock, buf, sizeof(buf), 0, PR_INTERVAL_NO_TIMEOUT);\n+  if (nbytes == -1) {\n+    PL_FPrintError(err_out, \"PR_Recv (client) failed\");\n+  } else {\n+    PR_fprintf(std_out, \"PR_Recv (client) succeeded: %d bytes\\n\", nbytes);\n+    buf[sizeof(buf) - 1] = '\\0';\n+    PR_fprintf(std_out, \"%s\\n\", buf);\n+  }\n+\n+  if (PR_FAILURE == PR_Shutdown(sock, PR_SHUTDOWN_BOTH)) {\n+    PL_FPrintError(err_out, \"PR_Shutdown (client) failed\");\n+  }\n+\n+  if (PR_FAILURE == PR_Close(sock)) {\n+    PL_FPrintError(err_out, \"PR_Close (client) failed\");\n+  }\n+\n+  return;\n } /* ConnectingThread */\n \n #define BUF_SIZE 117\n-static void\n-AcceptingThread(void* arg)\n-{\n-    PRStatus rv;\n-    PRInt32 bytes;\n-    PRSize buf_size = BUF_SIZE;\n-    PRUint8 buf[BUF_SIZE + (2 * sizeof(PRNetAddr)) + 32];\n-    PRNetAddr *accept_addr, *listen_addr = (PRNetAddr*)arg;\n-    PRFileDesc *accept_sock, *listen_sock = PR_NewTCPSocket();\n-    PRFileDesc* layer;\n-    PRSocketOptionData sock_opt;\n-\n-    if (NULL == listen_sock) {\n-        PL_FPrintError(err_out, \"PR_NewTCPSocket (server) failed\");\n-        PR_ProcessExit(1);\n-    }\n-    layer = PR_CreateIOLayerStub(emu_layer_ident, &emu_layer_methods);\n-    if (NULL == layer) {\n-        PL_FPrintError(err_out, \"PR_CreateIOLayerStub (server) failed\");\n-        PR_ProcessExit(1);\n-    }\n-    if (PR_PushIOLayer(listen_sock, PR_TOP_IO_LAYER, layer) == PR_FAILURE) {\n-        PL_FPrintError(err_out, \"PR_PushIOLayer (server) failed\");\n-        PR_ProcessExit(1);\n-    }\n-    sock_opt.option = PR_SockOpt_Reuseaddr;\n-    sock_opt.value.reuse_addr = PR_TRUE;\n-    rv = PR_SetSocketOption(listen_sock, &sock_opt);\n+static void AcceptingThread(void* arg) {\n+  PRStatus rv;\n+  PRInt32 bytes;\n+  PRSize buf_size = BUF_SIZE;\n+  PRUint8 buf[BUF_SIZE + (2 * sizeof(PRNetAddr)) + 32];\n+  PRNetAddr *accept_addr, *listen_addr = (PRNetAddr*)arg;\n+  PRFileDesc *accept_sock, *listen_sock = PR_NewTCPSocket();\n+  PRFileDesc* layer;\n+  PRSocketOptionData sock_opt;\n+\n+  if (NULL == listen_sock) {\n+    PL_FPrintError(err_out, \"PR_NewTCPSocket (server) failed\");\n+    PR_ProcessExit(1);\n+  }\n+  layer = PR_CreateIOLayerStub(emu_layer_ident, &emu_layer_methods);\n+  if (NULL == layer) {\n+    PL_FPrintError(err_out, \"PR_CreateIOLayerStub (server) failed\");\n+    PR_ProcessExit(1);\n+  }\n+  if (PR_PushIOLayer(listen_sock, PR_TOP_IO_LAYER, layer) == PR_FAILURE) {\n+    PL_FPrintError(err_out, \"PR_PushIOLayer (server) failed\");\n+    PR_ProcessExit(1);\n+  }\n+  sock_opt.option = PR_SockOpt_Reuseaddr;\n+  sock_opt.value.reuse_addr = PR_TRUE;\n+  rv = PR_SetSocketOption(listen_sock, &sock_opt);\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err_out, \"PR_SetSocketOption (server) failed\");\n+    PR_ProcessExit(1);\n+  }\n+  rv = PR_Bind(listen_sock, listen_addr);\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err_out, \"PR_Bind (server) failed\");\n+    PR_ProcessExit(1);\n+  }\n+  rv = PR_Listen(listen_sock, 10);\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err_out, \"PR_Listen (server) failed\");\n+    PR_ProcessExit(1);\n+  }\n+  bytes = PR_AcceptRead(listen_sock, &accept_sock, &accept_addr, buf, buf_size,\n+                        accept_timeout);\n+\n+  if (-1 == bytes) {\n+    PL_FPrintError(err_out, \"PR_AcceptRead (server) failed\");\n+  } else {\n+    PrintAddress(accept_addr);\n+    PR_fprintf(std_out, \"(Server) read [0x%p..0x%p) %s\\n\", buf, &buf[BUF_SIZE],\n+               buf);\n+    bytes = PR_Write(accept_sock, buf, bytes);\n+    rv = PR_Shutdown(accept_sock, PR_SHUTDOWN_BOTH);\n     if (PR_FAILURE == rv) {\n-        PL_FPrintError(err_out, \"PR_SetSocketOption (server) failed\");\n-        PR_ProcessExit(1);\n+      PL_FPrintError(err_out, \"PR_Shutdown (server) failed\");\n     }\n-    rv = PR_Bind(listen_sock, listen_addr);\n+  }\n+\n+  if (-1 != bytes) {\n+    rv = PR_Close(accept_sock);\n     if (PR_FAILURE == rv) {\n-        PL_FPrintError(err_out, \"PR_Bind (server) failed\");\n-        PR_ProcessExit(1);\n+      PL_FPrintError(err_out, \"PR_Close (server) failed\");\n     }\n-    rv = PR_Listen(listen_sock, 10);\n-    if (PR_FAILURE == rv) {\n-        PL_FPrintError(err_out, \"PR_Listen (server) failed\");\n-        PR_ProcessExit(1);\n+  }\n+\n+  rv = PR_Close(listen_sock);\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err_out, \"PR_Close (server) failed\");\n+  }\n+} /* AcceptingThread */\n+\n+int main(int argc, char** argv) {\n+  PRHostEnt he;\n+  PRStatus status;\n+  PRIntn next_index;\n+  PRUint16 port_number;\n+  char netdb_buf[PR_NETDB_BUF_SIZE];\n+  PRNetAddr client_addr, server_addr;\n+  PRThread *client_thread, *server_thread;\n+  PRIntervalTime delta = PR_MillisecondsToInterval(500);\n+\n+  err_out = PR_STDERR;\n+  std_out = PR_STDOUT;\n+  accept_timeout = PR_SecondsToInterval(2);\n+  emu_layer_ident = PR_GetUniqueIdentity(\"Emulated AcceptRead\");\n+  emu_layer_methods = *PR_GetDefaultIOMethods();\n+  emu_layer_methods.acceptread = emu_AcceptRead;\n+\n+  if (argc != 2 && argc != 3) {\n+    port_number = DEFAULT_PORT;\n+  } else {\n+    port_number = (PRUint16)atoi(argv[(argc == 2) ? 1 : 2]);\n+  }\n+\n+  status = PR_InitializeNetAddr(PR_IpAddrAny, port_number, &server_addr);\n+  if (PR_SUCCESS != status) {\n+    PL_FPrintError(err_out, \"PR_InitializeNetAddr failed\");\n+    PR_ProcessExit(1);\n+  }\n+  if (argc < 3) {\n+    status = PR_InitializeNetAddr(PR_IpAddrLoopback, port_number, &client_addr);\n+    if (PR_SUCCESS != status) {\n+      PL_FPrintError(err_out, \"PR_InitializeNetAddr failed\");\n+      PR_ProcessExit(1);\n     }\n-    bytes = PR_AcceptRead(listen_sock, &accept_sock, &accept_addr, buf, buf_size,\n-                          accept_timeout);\n-\n-    if (-1 == bytes) {\n-        PL_FPrintError(err_out, \"PR_AcceptRead (server) failed\");\n-    } else {\n-        PrintAddress(accept_addr);\n-        PR_fprintf(std_out, \"(Server) read [0x%p..0x%p) %s\\n\", buf, &buf[BUF_SIZE],\n-                   buf);\n-        bytes = PR_Write(accept_sock, buf, bytes);\n-        rv = PR_Shutdown(accept_sock, PR_SHUTDOWN_BOTH);\n-        if (PR_FAILURE == rv) {\n-            PL_FPrintError(err_out, \"PR_Shutdown (server) failed\");\n-        }\n+  } else {\n+    status = PR_GetHostByName(argv[1], netdb_buf, sizeof(netdb_buf), &he);\n+    if (status == PR_FAILURE) {\n+      PL_FPrintError(err_out, \"PR_GetHostByName failed\");\n+      PR_ProcessExit(1);\n     }\n-\n-    if (-1 != bytes) {\n-        rv = PR_Close(accept_sock);\n-        if (PR_FAILURE == rv) {\n-            PL_FPrintError(err_out, \"PR_Close (server) failed\");\n-        }\n+    next_index = PR_EnumerateHostEnt(0, &he, port_number, &client_addr);\n+    if (next_index == -1) {\n+      PL_FPrintError(err_out, \"PR_EnumerateHostEnt failed\");\n+      PR_ProcessExit(1);\n     }\n-\n-    rv = PR_Close(listen_sock);\n-    if (PR_FAILURE == rv) {\n-        PL_FPrintError(err_out, \"PR_Close (server) failed\");\n+  }\n+\n+  for (write_dally = 0; write_dally < accept_timeout + (2 * delta);\n+       write_dally += delta) {\n+    PR_fprintf(std_out, \"Testing w/ write_dally = %d msec\\n\",\n+               PR_IntervalToMilliseconds(write_dally));\n+    server_thread = PR_CreateThread(PR_USER_THREAD, AcceptingThread,\n+                                    &server_addr, PR_PRIORITY_NORMAL,\n+                                    PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+    if (server_thread == NULL) {\n+      PL_FPrintError(err_out, \"PR_CreateThread (server) failed\");\n+      PR_ProcessExit(1);\n     }\n-} /* AcceptingThread */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRHostEnt he;\n-    PRStatus status;\n-    PRIntn next_index;\n-    PRUint16 port_number;\n-    char netdb_buf[PR_NETDB_BUF_SIZE];\n-    PRNetAddr client_addr, server_addr;\n-    PRThread *client_thread, *server_thread;\n-    PRIntervalTime delta = PR_MillisecondsToInterval(500);\n-\n-    err_out = PR_STDERR;\n-    std_out = PR_STDOUT;\n-    accept_timeout = PR_SecondsToInterval(2);\n-    emu_layer_ident = PR_GetUniqueIdentity(\"Emulated AcceptRead\");\n-    emu_layer_methods = *PR_GetDefaultIOMethods();\n-    emu_layer_methods.acceptread = emu_AcceptRead;\n-\n-    if (argc != 2 && argc != 3) {\n-        port_number = DEFAULT_PORT;\n-    } else {\n-        port_number = (PRUint16)atoi(argv[(argc == 2) ? 1 : 2]);\n-    }\n+    PR_Sleep(delta); /* let the server pot thicken */\n \n-    status = PR_InitializeNetAddr(PR_IpAddrAny, port_number, &server_addr);\n-    if (PR_SUCCESS != status) {\n-        PL_FPrintError(err_out, \"PR_InitializeNetAddr failed\");\n-        PR_ProcessExit(1);\n+    client_thread = PR_CreateThread(PR_USER_THREAD, ConnectingThread,\n+                                    &client_addr, PR_PRIORITY_NORMAL,\n+                                    PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+    if (client_thread == NULL) {\n+      PL_FPrintError(err_out, \"PR_CreateThread (client) failed\");\n+      PR_ProcessExit(1);\n     }\n-    if (argc < 3) {\n-        status = PR_InitializeNetAddr(PR_IpAddrLoopback, port_number, &client_addr);\n-        if (PR_SUCCESS != status) {\n-            PL_FPrintError(err_out, \"PR_InitializeNetAddr failed\");\n-            PR_ProcessExit(1);\n-        }\n-    } else {\n-        status = PR_GetHostByName(argv[1], netdb_buf, sizeof(netdb_buf), &he);\n-        if (status == PR_FAILURE) {\n-            PL_FPrintError(err_out, \"PR_GetHostByName failed\");\n-            PR_ProcessExit(1);\n-        }\n-        next_index = PR_EnumerateHostEnt(0, &he, port_number, &client_addr);\n-        if (next_index == -1) {\n-            PL_FPrintError(err_out, \"PR_EnumerateHostEnt failed\");\n-            PR_ProcessExit(1);\n-        }\n+\n+    if (PR_JoinThread(client_thread) == PR_FAILURE) {\n+      PL_FPrintError(err_out, \"PR_JoinThread (client) failed\");\n     }\n \n-    for (write_dally = 0; write_dally < accept_timeout + (2 * delta);\n-         write_dally += delta) {\n-        PR_fprintf(std_out, \"Testing w/ write_dally = %d msec\\n\",\n-                   PR_IntervalToMilliseconds(write_dally));\n-        server_thread = PR_CreateThread(PR_USER_THREAD, AcceptingThread,\n-                                        &server_addr, PR_PRIORITY_NORMAL,\n-                                        PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-        if (server_thread == NULL) {\n-            PL_FPrintError(err_out, \"PR_CreateThread (server) failed\");\n-            PR_ProcessExit(1);\n-        }\n-\n-        PR_Sleep(delta); /* let the server pot thicken */\n-\n-        client_thread = PR_CreateThread(PR_USER_THREAD, ConnectingThread,\n-                                        &client_addr, PR_PRIORITY_NORMAL,\n-                                        PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-        if (client_thread == NULL) {\n-            PL_FPrintError(err_out, \"PR_CreateThread (client) failed\");\n-            PR_ProcessExit(1);\n-        }\n-\n-        if (PR_JoinThread(client_thread) == PR_FAILURE) {\n-            PL_FPrintError(err_out, \"PR_JoinThread (client) failed\");\n-        }\n-\n-        if (PR_JoinThread(server_thread) == PR_FAILURE) {\n-            PL_FPrintError(err_out, \"PR_JoinThread (server) failed\");\n-        }\n+    if (PR_JoinThread(server_thread) == PR_FAILURE) {\n+      PL_FPrintError(err_out, \"PR_JoinThread (server) failed\");\n     }\n+  }\n \n-    return 0;\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/addrstr.c b/nspr/pr/tests/addrstr.c\nindex 5b2f897..4e17380 100644\n--- a/nspr/pr/tests/addrstr.c\n+++ b/nspr/pr/tests/addrstr.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,83 +9,81 @@\n #include <string.h>\n #include <stdlib.h>\n \n-const char* testaddrs[] = { \"::\",\n-                            \"::\",\n-                            \"::1\",\n-                            \"::1\",\n-                            \"::ffff\",\n-                            \"::ffff\",\n-                            \"::1:0\",\n-                            \"::0.1.0.0\",\n-                            \"::127.0.0.1\",\n-                            \"::127.0.0.1\",\n-                            \"::FFFF:127.0.0.1\",\n-                            \"::ffff:127.0.0.1\",\n-                            \"::FFFE:9504:3501\",\n-                            \"::fffe:9504:3501\",\n-                            \"0:0:1:0:35c:0:0:0\",\n-                            \"0:0:1:0:35c::\",\n-                            \"0:0:3f4c:0:0:4552:0:0\",\n-                            \"::3f4c:0:0:4552:0:0\",\n-                            \"0:0:1245:0:0:0:0567:0\",\n-                            \"0:0:1245::567:0\",\n-                            \"0:1:2:3:4:5:6:7\",\n-                            \"0:1:2:3:4:5:6:7\",\n-                            \"1:2:3:0:4:5:6:7\",\n-                            \"1:2:3:0:4:5:6:7\",\n-                            \"1:2:3:4:5:6:7:0\",\n-                            \"1:2:3:4:5:6:7:0\",\n-                            \"1:2:3:4:5:6:7:8\",\n-                            \"1:2:3:4:5:6:7:8\",\n-                            \"1:2:3:4:5:6::7\",\n-                            \"1:2:3:4:5:6:0:7\",\n-                            0 };\n+const char* testaddrs[] = {\"::\",\n+                           \"::\",\n+                           \"::1\",\n+                           \"::1\",\n+                           \"::ffff\",\n+                           \"::ffff\",\n+                           \"::1:0\",\n+                           \"::0.1.0.0\",\n+                           \"::127.0.0.1\",\n+                           \"::127.0.0.1\",\n+                           \"::FFFF:127.0.0.1\",\n+                           \"::ffff:127.0.0.1\",\n+                           \"::FFFE:9504:3501\",\n+                           \"::fffe:9504:3501\",\n+                           \"0:0:1:0:35c:0:0:0\",\n+                           \"0:0:1:0:35c::\",\n+                           \"0:0:3f4c:0:0:4552:0:0\",\n+                           \"::3f4c:0:0:4552:0:0\",\n+                           \"0:0:1245:0:0:0:0567:0\",\n+                           \"0:0:1245::567:0\",\n+                           \"0:1:2:3:4:5:6:7\",\n+                           \"0:1:2:3:4:5:6:7\",\n+                           \"1:2:3:0:4:5:6:7\",\n+                           \"1:2:3:0:4:5:6:7\",\n+                           \"1:2:3:4:5:6:7:0\",\n+                           \"1:2:3:4:5:6:7:0\",\n+                           \"1:2:3:4:5:6:7:8\",\n+                           \"1:2:3:4:5:6:7:8\",\n+                           \"1:2:3:4:5:6::7\",\n+                           \"1:2:3:4:5:6:0:7\",\n+                           0};\n \n-const char* badaddrs[] = { \"::.1.2.3\", \"ffff::.1.2.3\",\n-                           \"1:2:3:4:5:6:7::8\", \"1:2:3:4:5:6::7:8\",\n-                           \"::ff99.2.3.4\", 0 };\n+const char* badaddrs[] = {\"::.1.2.3\",         \"ffff::.1.2.3\",\n+                          \"1:2:3:4:5:6:7::8\", \"1:2:3:4:5:6::7:8\",\n+                          \"::ff99.2.3.4\",     0};\n \n int failed_already = 0;\n \n-int\n-main(int argc, char** argv)\n-{\n-    const char** nexttestaddr = testaddrs;\n-    const char** nextbadaddr = badaddrs;\n-    const char *in, *expected_out;\n-    PRNetAddr addr;\n-    char buf[256];\n-    PRStatus rv;\n+int main(int argc, char** argv) {\n+  const char** nexttestaddr = testaddrs;\n+  const char** nextbadaddr = badaddrs;\n+  const char *in, *expected_out;\n+  PRNetAddr addr;\n+  char buf[256];\n+  PRStatus rv;\n \n-    while ((in = *nexttestaddr++) != 0) {\n-        expected_out = *nexttestaddr++;\n-        rv = PR_StringToNetAddr(in, &addr);\n-        if (rv) {\n-            printf(\"cannot convert %s to addr: %d\\n\", in, rv);\n-            failed_already = 1;\n-            continue;\n-        }\n-        rv = PR_NetAddrToString(&addr, buf, sizeof(buf));\n-        if (rv) {\n-            printf(\"cannot convert %s back to string: %d\\n\", in, rv);\n-            failed_already = 1;\n-            continue;\n-        }\n-        if (strcmp(buf, expected_out)) {\n-            /* This is not necessarily an error */\n-            printf(\"%s expected %s got %s\\n\", in, expected_out, buf);\n-        }\n+  while ((in = *nexttestaddr++) != 0) {\n+    expected_out = *nexttestaddr++;\n+    rv = PR_StringToNetAddr(in, &addr);\n+    if (rv) {\n+      printf(\"cannot convert %s to addr: %d\\n\", in, rv);\n+      failed_already = 1;\n+      continue;\n     }\n-    while ((in = *nextbadaddr++) != 0) {\n-        if (PR_StringToNetAddr(in, &addr) == PR_SUCCESS) {\n-            printf(\"converted bad addr %s\\n\", in);\n-            failed_already = 1;\n-        }\n+    rv = PR_NetAddrToString(&addr, buf, sizeof(buf));\n+    if (rv) {\n+      printf(\"cannot convert %s back to string: %d\\n\", in, rv);\n+      failed_already = 1;\n+      continue;\n     }\n-    if (failed_already) {\n-        printf(\"FAIL\\n\");\n-        return 1;\n+    if (strcmp(buf, expected_out)) {\n+      /* This is not necessarily an error */\n+      printf(\"%s expected %s got %s\\n\", in, expected_out, buf);\n     }\n-    printf(\"PASS\\n\");\n-    return 0;\n+  }\n+  while ((in = *nextbadaddr++) != 0) {\n+    if (PR_StringToNetAddr(in, &addr) == PR_SUCCESS) {\n+      printf(\"converted bad addr %s\\n\", in);\n+      failed_already = 1;\n+    }\n+  }\n+  if (failed_already) {\n+    printf(\"FAIL\\n\");\n+    return 1;\n+  }\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/affinity.c b/nspr/pr/tests/affinity.c\nindex bf121ad..772268c 100644\n--- a/nspr/pr/tests/affinity.c\n+++ b/nspr/pr/tests/affinity.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -15,56 +16,52 @@\n  *      The function is called by each of local, global and global bound threads\n  *      The test should be run on both single and multi-cpu systems\n  */\n-static void PR_CALLBACK\n-thread_start(void* arg)\n-{\n-    PRUint32 mask = 0;\n-\n-    if (PR_GetThreadAffinityMask(PR_GetCurrentThread(), &mask)) {\n-        printf(\"\\tthread_start: PR_GetCurrentThreadAffinityMask failed\\n\");\n-    } else {\n-        printf(\"\\tthread_start: AffinityMask = 0x%x\\n\", mask);\n-    }\n+static void PR_CALLBACK thread_start(void* arg) {\n+  PRUint32 mask = 0;\n+\n+  if (PR_GetThreadAffinityMask(PR_GetCurrentThread(), &mask)) {\n+    printf(\"\\tthread_start: PR_GetCurrentThreadAffinityMask failed\\n\");\n+  } else {\n+    printf(\"\\tthread_start: AffinityMask = 0x%x\\n\", mask);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRThread* t;\n+int main(int argc, char** argv) {\n+  PRThread* t;\n \n-    printf(\"main: creating local thread\\n\");\n+  printf(\"main: creating local thread\\n\");\n \n-    t = PR_CreateThread(PR_USER_THREAD, thread_start, 0, PR_PRIORITY_NORMAL,\n-                        PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  t = PR_CreateThread(PR_USER_THREAD, thread_start, 0, PR_PRIORITY_NORMAL,\n+                      PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n \n-    if (NULL == t) {\n-        printf(\"main: cannot create local thread\\n\");\n-        exit(1);\n-    }\n+  if (NULL == t) {\n+    printf(\"main: cannot create local thread\\n\");\n+    exit(1);\n+  }\n \n-    PR_JoinThread(t);\n+  PR_JoinThread(t);\n \n-    printf(\"main: creating global thread\\n\");\n-    t = PR_CreateThread(PR_USER_THREAD, thread_start, 0, PR_PRIORITY_NORMAL,\n-                        PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  printf(\"main: creating global thread\\n\");\n+  t = PR_CreateThread(PR_USER_THREAD, thread_start, 0, PR_PRIORITY_NORMAL,\n+                      PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n \n-    if (NULL == t) {\n-        printf(\"main: cannot create global thread\\n\");\n-        exit(1);\n-    }\n+  if (NULL == t) {\n+    printf(\"main: cannot create global thread\\n\");\n+    exit(1);\n+  }\n \n-    PR_JoinThread(t);\n+  PR_JoinThread(t);\n \n-    printf(\"main: creating global bound thread\\n\");\n-    t = PR_CreateThread(PR_USER_THREAD, thread_start, 0, PR_PRIORITY_NORMAL,\n-                        PR_GLOBAL_BOUND_THREAD, PR_JOINABLE_THREAD, 0);\n+  printf(\"main: creating global bound thread\\n\");\n+  t = PR_CreateThread(PR_USER_THREAD, thread_start, 0, PR_PRIORITY_NORMAL,\n+                      PR_GLOBAL_BOUND_THREAD, PR_JOINABLE_THREAD, 0);\n \n-    if (NULL == t) {\n-        printf(\"main: cannot create global bound thread\\n\");\n-        exit(1);\n-    }\n+  if (NULL == t) {\n+    printf(\"main: cannot create global bound thread\\n\");\n+    exit(1);\n+  }\n \n-    PR_JoinThread(t);\n+  PR_JoinThread(t);\n \n-    return 0;\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/alarm.c b/nspr/pr/tests/alarm.c\nindex 6b4bed8..f7a8fa7 100644\n--- a/nspr/pr/tests/alarm.c\n+++ b/nspr/pr/tests/alarm.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -42,7 +43,7 @@\n #include <stdlib.h>\n \n #if defined(XP_UNIX)\n-#include <sys/time.h>\n+#  include <sys/time.h>\n #endif\n \n static PRIntn debug_mode;\n@@ -50,27 +51,25 @@ static PRIntn failed_already = 0;\n static PRThreadScope thread_scope = PR_LOCAL_THREAD;\n \n typedef struct notifyData {\n-    PRLock* ml;\n-    PRCondVar* child;\n-    PRCondVar* parent;\n-    PRBool pending;\n-    PRUint32 counter;\n+  PRLock* ml;\n+  PRCondVar* child;\n+  PRCondVar* parent;\n+  PRBool pending;\n+  PRUint32 counter;\n } NotifyData;\n \n-static void\n-Notifier(void* arg)\n-{\n-    NotifyData* notifyData = (NotifyData*)arg;\n-    PR_Lock(notifyData->ml);\n-    while (notifyData->counter > 0) {\n-        while (!notifyData->pending) {\n-            PR_WaitCondVar(notifyData->child, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        notifyData->counter -= 1;\n-        notifyData->pending = PR_FALSE;\n-        PR_NotifyCondVar(notifyData->parent);\n+static void Notifier(void* arg) {\n+  NotifyData* notifyData = (NotifyData*)arg;\n+  PR_Lock(notifyData->ml);\n+  while (notifyData->counter > 0) {\n+    while (!notifyData->pending) {\n+      PR_WaitCondVar(notifyData->child, PR_INTERVAL_NO_TIMEOUT);\n     }\n-    PR_Unlock(notifyData->ml);\n+    notifyData->counter -= 1;\n+    notifyData->pending = PR_FALSE;\n+    PR_NotifyCondVar(notifyData->parent);\n+  }\n+  PR_Unlock(notifyData->ml);\n } /* Notifier */\n /***********************************************************************\n ** PRIVATE FUNCTION:    ConditionNotify\n@@ -88,438 +87,418 @@ Notifier(void* arg)\n **\n ***********************************************************************/\n \n-static PRIntervalTime\n-ConditionNotify(PRUint32 loops)\n-{\n-    PRThread* thread;\n-    NotifyData notifyData;\n-    PRIntervalTime timein, overhead;\n-\n-    timein = PR_IntervalNow();\n-\n-    notifyData.counter = loops;\n-    notifyData.ml = PR_NewLock();\n-    notifyData.child = PR_NewCondVar(notifyData.ml);\n-    notifyData.parent = PR_NewCondVar(notifyData.ml);\n-    thread = PR_CreateThread(PR_USER_THREAD, Notifier, &notifyData,\n-                             PR_GetThreadPriority(PR_GetCurrentThread()),\n-                             thread_scope, PR_JOINABLE_THREAD, 0);\n-\n-    overhead = PR_IntervalNow() - timein; /* elapsed so far */\n-\n-    PR_Lock(notifyData.ml);\n-    while (notifyData.counter > 0) {\n-        notifyData.pending = PR_TRUE;\n-        PR_NotifyCondVar(notifyData.child);\n-        while (notifyData.pending) {\n-            PR_WaitCondVar(notifyData.parent, PR_INTERVAL_NO_TIMEOUT);\n-        }\n+static PRIntervalTime ConditionNotify(PRUint32 loops) {\n+  PRThread* thread;\n+  NotifyData notifyData;\n+  PRIntervalTime timein, overhead;\n+\n+  timein = PR_IntervalNow();\n+\n+  notifyData.counter = loops;\n+  notifyData.ml = PR_NewLock();\n+  notifyData.child = PR_NewCondVar(notifyData.ml);\n+  notifyData.parent = PR_NewCondVar(notifyData.ml);\n+  thread = PR_CreateThread(PR_USER_THREAD, Notifier, &notifyData,\n+                           PR_GetThreadPriority(PR_GetCurrentThread()),\n+                           thread_scope, PR_JOINABLE_THREAD, 0);\n+\n+  overhead = PR_IntervalNow() - timein; /* elapsed so far */\n+\n+  PR_Lock(notifyData.ml);\n+  while (notifyData.counter > 0) {\n+    notifyData.pending = PR_TRUE;\n+    PR_NotifyCondVar(notifyData.child);\n+    while (notifyData.pending) {\n+      PR_WaitCondVar(notifyData.parent, PR_INTERVAL_NO_TIMEOUT);\n     }\n-    PR_Unlock(notifyData.ml);\n+  }\n+  PR_Unlock(notifyData.ml);\n \n-    timein = PR_IntervalNow();\n+  timein = PR_IntervalNow();\n \n-    (void)PR_JoinThread(thread);\n-    PR_DestroyCondVar(notifyData.child);\n-    PR_DestroyCondVar(notifyData.parent);\n-    PR_DestroyLock(notifyData.ml);\n+  (void)PR_JoinThread(thread);\n+  PR_DestroyCondVar(notifyData.child);\n+  PR_DestroyCondVar(notifyData.parent);\n+  PR_DestroyLock(notifyData.ml);\n \n-    overhead += (PR_IntervalNow() - timein); /* more overhead */\n+  overhead += (PR_IntervalNow() - timein); /* more overhead */\n \n-    return overhead;\n+  return overhead;\n } /* ConditionNotify */\n \n-static PRIntervalTime\n-ConditionTimeout(PRUint32 loops)\n-{\n-    PRUintn count;\n-    PRIntervalTime overhead, timein = PR_IntervalNow();\n+static PRIntervalTime ConditionTimeout(PRUint32 loops) {\n+  PRUintn count;\n+  PRIntervalTime overhead, timein = PR_IntervalNow();\n \n-    PRLock* ml = PR_NewLock();\n-    PRCondVar* cv = PR_NewCondVar(ml);\n-    PRIntervalTime interval = PR_MillisecondsToInterval(50);\n+  PRLock* ml = PR_NewLock();\n+  PRCondVar* cv = PR_NewCondVar(ml);\n+  PRIntervalTime interval = PR_MillisecondsToInterval(50);\n \n-    overhead = PR_IntervalNow() - timein;\n+  overhead = PR_IntervalNow() - timein;\n \n-    PR_Lock(ml);\n-    for (count = 0; count < loops; ++count) {\n-        overhead += interval;\n-        PR_ASSERT(PR_WaitCondVar(cv, interval) == PR_SUCCESS);\n-    }\n-    PR_Unlock(ml);\n+  PR_Lock(ml);\n+  for (count = 0; count < loops; ++count) {\n+    overhead += interval;\n+    PR_ASSERT(PR_WaitCondVar(cv, interval) == PR_SUCCESS);\n+  }\n+  PR_Unlock(ml);\n \n-    timein = PR_IntervalNow();\n-    PR_DestroyCondVar(cv);\n-    PR_DestroyLock(ml);\n-    overhead += (PR_IntervalNow() - timein);\n+  timein = PR_IntervalNow();\n+  PR_DestroyCondVar(cv);\n+  PR_DestroyLock(ml);\n+  overhead += (PR_IntervalNow() - timein);\n \n-    return overhead;\n+  return overhead;\n } /* ConditionTimeout */\n \n typedef struct AlarmData {\n-    PRLock* ml;\n-    PRCondVar* cv;\n-    PRUint32 rate, late, times;\n-    PRIntervalTime duration, timein, period;\n+  PRLock* ml;\n+  PRCondVar* cv;\n+  PRUint32 rate, late, times;\n+  PRIntervalTime duration, timein, period;\n } AlarmData;\n \n-static PRBool\n-AlarmFn1(PRAlarmID* id, void* clientData, PRUint32 late)\n-{\n-    PRStatus rv = PR_SUCCESS;\n-    PRBool keepGoing, resetAlarm;\n-    PRIntervalTime interval, now = PR_IntervalNow();\n-    AlarmData* ad = (AlarmData*)clientData;\n-\n-    PR_Lock(ad->ml);\n-    ad->late += late;\n-    ad->times += 1;\n-    keepGoing =\n-        ((PRIntervalTime)(now - ad->timein) < ad->duration) ? PR_TRUE : PR_FALSE;\n-    if (!keepGoing) {\n-        rv = PR_NotifyCondVar(ad->cv);\n-    }\n-    resetAlarm = ((ad->times % 31) == 0) ? PR_TRUE : PR_FALSE;\n-\n-    interval = (ad->period + ad->rate - 1) / ad->rate;\n-    if (!late && (interval > 10)) {\n-        interval &= (now & 0x03) + 1;\n-        PR_WaitCondVar(ad->cv, interval);\n+static PRBool AlarmFn1(PRAlarmID* id, void* clientData, PRUint32 late) {\n+  PRStatus rv = PR_SUCCESS;\n+  PRBool keepGoing, resetAlarm;\n+  PRIntervalTime interval, now = PR_IntervalNow();\n+  AlarmData* ad = (AlarmData*)clientData;\n+\n+  PR_Lock(ad->ml);\n+  ad->late += late;\n+  ad->times += 1;\n+  keepGoing =\n+      ((PRIntervalTime)(now - ad->timein) < ad->duration) ? PR_TRUE : PR_FALSE;\n+  if (!keepGoing) {\n+    rv = PR_NotifyCondVar(ad->cv);\n+  }\n+  resetAlarm = ((ad->times % 31) == 0) ? PR_TRUE : PR_FALSE;\n+\n+  interval = (ad->period + ad->rate - 1) / ad->rate;\n+  if (!late && (interval > 10)) {\n+    interval &= (now & 0x03) + 1;\n+    PR_WaitCondVar(ad->cv, interval);\n+  }\n+\n+  PR_Unlock(ad->ml);\n+\n+  if (rv != PR_SUCCESS) {\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    } else {\n+      printf(\"AlarmFn: notify status: FAIL\\n\");\n     }\n+  }\n \n-    PR_Unlock(ad->ml);\n-\n-    if (rv != PR_SUCCESS) {\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        } else {\n-            printf(\"AlarmFn: notify status: FAIL\\n\");\n-        }\n-    }\n+  if (resetAlarm) {\n+    ad->rate += 3;\n+    ad->late = ad->times = 0;\n+    if (PR_ResetAlarm(id, ad->period, ad->rate) != PR_SUCCESS) {\n+      if (!debug_mode) {\n+        failed_already = 1;\n+      } else {\n+        printf(\"AlarmFn: Resetting alarm status: FAIL\\n\");\n+      }\n \n-    if (resetAlarm) {\n-        ad->rate += 3;\n-        ad->late = ad->times = 0;\n-        if (PR_ResetAlarm(id, ad->period, ad->rate) != PR_SUCCESS) {\n-            if (!debug_mode) {\n-                failed_already = 1;\n-            } else {\n-                printf(\"AlarmFn: Resetting alarm status: FAIL\\n\");\n-            }\n-\n-            keepGoing = PR_FALSE;\n-        }\n+      keepGoing = PR_FALSE;\n     }\n+  }\n \n-    return keepGoing;\n+  return keepGoing;\n } /* AlarmFn1 */\n \n-static PRIntervalTime\n-Alarms1(PRUint32 loops)\n-{\n-    PRAlarm* alarm;\n-    AlarmData ad;\n-    PRIntervalTime overhead, timein = PR_IntervalNow();\n-    PRIntervalTime duration = PR_SecondsToInterval(3);\n+static PRIntervalTime Alarms1(PRUint32 loops) {\n+  PRAlarm* alarm;\n+  AlarmData ad;\n+  PRIntervalTime overhead, timein = PR_IntervalNow();\n+  PRIntervalTime duration = PR_SecondsToInterval(3);\n \n-    PRLock* ml = PR_NewLock();\n-    PRCondVar* cv = PR_NewCondVar(ml);\n+  PRLock* ml = PR_NewLock();\n+  PRCondVar* cv = PR_NewCondVar(ml);\n \n-    ad.ml = ml;\n-    ad.cv = cv;\n-    ad.rate = 1;\n-    ad.times = loops;\n-    ad.late = ad.times = 0;\n-    ad.duration = duration;\n-    ad.timein = PR_IntervalNow();\n-    ad.period = PR_SecondsToInterval(1);\n+  ad.ml = ml;\n+  ad.cv = cv;\n+  ad.rate = 1;\n+  ad.times = loops;\n+  ad.late = ad.times = 0;\n+  ad.duration = duration;\n+  ad.timein = PR_IntervalNow();\n+  ad.period = PR_SecondsToInterval(1);\n \n-    alarm = PR_CreateAlarm();\n+  alarm = PR_CreateAlarm();\n \n-    (void)PR_SetAlarm(alarm, ad.period, ad.rate, AlarmFn1, &ad);\n+  (void)PR_SetAlarm(alarm, ad.period, ad.rate, AlarmFn1, &ad);\n \n-    overhead = PR_IntervalNow() - timein;\n+  overhead = PR_IntervalNow() - timein;\n \n-    PR_Lock(ml);\n-    while ((PRIntervalTime)(PR_IntervalNow() - ad.timein) < duration) {\n-        PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_Unlock(ml);\n+  PR_Lock(ml);\n+  while ((PRIntervalTime)(PR_IntervalNow() - ad.timein) < duration) {\n+    PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_Unlock(ml);\n \n-    timein = PR_IntervalNow();\n-    (void)PR_DestroyAlarm(alarm);\n-    PR_DestroyCondVar(cv);\n-    PR_DestroyLock(ml);\n-    overhead += (PR_IntervalNow() - timein);\n+  timein = PR_IntervalNow();\n+  (void)PR_DestroyAlarm(alarm);\n+  PR_DestroyCondVar(cv);\n+  PR_DestroyLock(ml);\n+  overhead += (PR_IntervalNow() - timein);\n \n-    return duration + overhead;\n+  return duration + overhead;\n } /* Alarms1 */\n \n-static PRBool\n-AlarmFn2(PRAlarmID* id, void* clientData, PRUint32 late)\n-{\n-    PRBool keepGoing;\n-    PRStatus rv = PR_SUCCESS;\n-    AlarmData* ad = (AlarmData*)clientData;\n-    PRIntervalTime interval, now = PR_IntervalNow();\n-\n-    PR_Lock(ad->ml);\n-    ad->times += 1;\n-    keepGoing =\n-        ((PRIntervalTime)(now - ad->timein) < ad->duration) ? PR_TRUE : PR_FALSE;\n-    interval = (ad->period + ad->rate - 1) / ad->rate;\n-\n-    if (!late && (interval > 10)) {\n-        interval &= (now & 0x03) + 1;\n-        PR_WaitCondVar(ad->cv, interval);\n-    }\n+static PRBool AlarmFn2(PRAlarmID* id, void* clientData, PRUint32 late) {\n+  PRBool keepGoing;\n+  PRStatus rv = PR_SUCCESS;\n+  AlarmData* ad = (AlarmData*)clientData;\n+  PRIntervalTime interval, now = PR_IntervalNow();\n \n-    if (!keepGoing) {\n-        rv = PR_NotifyCondVar(ad->cv);\n-    }\n+  PR_Lock(ad->ml);\n+  ad->times += 1;\n+  keepGoing =\n+      ((PRIntervalTime)(now - ad->timein) < ad->duration) ? PR_TRUE : PR_FALSE;\n+  interval = (ad->period + ad->rate - 1) / ad->rate;\n \n-    PR_Unlock(ad->ml);\n+  if (!late && (interval > 10)) {\n+    interval &= (now & 0x03) + 1;\n+    PR_WaitCondVar(ad->cv, interval);\n+  }\n \n-    if (rv != PR_SUCCESS) {\n-        failed_already = 1;\n-    };\n+  if (!keepGoing) {\n+    rv = PR_NotifyCondVar(ad->cv);\n+  }\n \n-    return keepGoing;\n+  PR_Unlock(ad->ml);\n+\n+  if (rv != PR_SUCCESS) {\n+    failed_already = 1;\n+  };\n+\n+  return keepGoing;\n } /* AlarmFn2 */\n \n-static PRIntervalTime\n-Alarms2(PRUint32 loops)\n-{\n-    PRStatus rv;\n-    PRAlarm* alarm;\n-    PRIntervalTime overhead, timein = PR_IntervalNow();\n-    AlarmData ad;\n-    PRIntervalTime duration = PR_SecondsToInterval(30);\n+static PRIntervalTime Alarms2(PRUint32 loops) {\n+  PRStatus rv;\n+  PRAlarm* alarm;\n+  PRIntervalTime overhead, timein = PR_IntervalNow();\n+  AlarmData ad;\n+  PRIntervalTime duration = PR_SecondsToInterval(30);\n \n-    PRLock* ml = PR_NewLock();\n-    PRCondVar* cv = PR_NewCondVar(ml);\n+  PRLock* ml = PR_NewLock();\n+  PRCondVar* cv = PR_NewCondVar(ml);\n \n-    ad.ml = ml;\n-    ad.cv = cv;\n-    ad.rate = 1;\n-    ad.times = loops;\n-    ad.late = ad.times = 0;\n-    ad.duration = duration;\n-    ad.timein = PR_IntervalNow();\n-    ad.period = PR_SecondsToInterval(1);\n+  ad.ml = ml;\n+  ad.cv = cv;\n+  ad.rate = 1;\n+  ad.times = loops;\n+  ad.late = ad.times = 0;\n+  ad.duration = duration;\n+  ad.timein = PR_IntervalNow();\n+  ad.period = PR_SecondsToInterval(1);\n \n-    alarm = PR_CreateAlarm();\n+  alarm = PR_CreateAlarm();\n \n-    (void)PR_SetAlarm(alarm, ad.period, ad.rate, AlarmFn2, &ad);\n+  (void)PR_SetAlarm(alarm, ad.period, ad.rate, AlarmFn2, &ad);\n \n-    overhead = PR_IntervalNow() - timein;\n+  overhead = PR_IntervalNow() - timein;\n \n-    PR_Lock(ml);\n-    while ((PRIntervalTime)(PR_IntervalNow() - ad.timein) < duration) {\n-        PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_Unlock(ml);\n+  PR_Lock(ml);\n+  while ((PRIntervalTime)(PR_IntervalNow() - ad.timein) < duration) {\n+    PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_Unlock(ml);\n \n-    timein = PR_IntervalNow();\n+  timein = PR_IntervalNow();\n \n-    rv = PR_DestroyAlarm(alarm);\n-    if (rv != PR_SUCCESS) {\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        } else {\n-            printf(\"***Destroying alarm status: FAIL\\n\");\n-        }\n+  rv = PR_DestroyAlarm(alarm);\n+  if (rv != PR_SUCCESS) {\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    } else {\n+      printf(\"***Destroying alarm status: FAIL\\n\");\n     }\n+  }\n \n-    PR_DestroyCondVar(cv);\n-    PR_DestroyLock(ml);\n+  PR_DestroyCondVar(cv);\n+  PR_DestroyLock(ml);\n \n-    overhead += (PR_IntervalNow() - timein);\n+  overhead += (PR_IntervalNow() - timein);\n \n-    return duration + overhead;\n+  return duration + overhead;\n } /* Alarms2 */\n \n-static PRIntervalTime\n-Alarms3(PRUint32 loops)\n-{\n-    PRIntn i;\n-    PRStatus rv;\n-    PRAlarm* alarm;\n-    AlarmData ad[3];\n-    PRIntervalTime duration = PR_SecondsToInterval(30);\n-    PRIntervalTime overhead, timein = PR_IntervalNow();\n-\n-    PRLock* ml = PR_NewLock();\n-    PRCondVar* cv = PR_NewCondVar(ml);\n-\n-    for (i = 0; i < 3; ++i) {\n-        ad[i].ml = ml;\n-        ad[i].cv = cv;\n-        ad[i].rate = 1;\n-        ad[i].times = loops;\n-        ad[i].duration = duration;\n-        ad[i].late = ad[i].times = 0;\n-        ad[i].timein = PR_IntervalNow();\n-        ad[i].period = PR_SecondsToInterval(1);\n-\n-        /* more loops, faster rate => same elapsed time */\n-        ad[i].times = (i + 1) * loops;\n-        ad[i].rate = (i + 1) * 10;\n-    }\n-\n-    alarm = PR_CreateAlarm();\n-\n-    for (i = 0; i < 3; ++i) {\n-        (void)PR_SetAlarm(alarm, ad[i].period, ad[i].rate, AlarmFn2, &ad[i]);\n+static PRIntervalTime Alarms3(PRUint32 loops) {\n+  PRIntn i;\n+  PRStatus rv;\n+  PRAlarm* alarm;\n+  AlarmData ad[3];\n+  PRIntervalTime duration = PR_SecondsToInterval(30);\n+  PRIntervalTime overhead, timein = PR_IntervalNow();\n+\n+  PRLock* ml = PR_NewLock();\n+  PRCondVar* cv = PR_NewCondVar(ml);\n+\n+  for (i = 0; i < 3; ++i) {\n+    ad[i].ml = ml;\n+    ad[i].cv = cv;\n+    ad[i].rate = 1;\n+    ad[i].times = loops;\n+    ad[i].duration = duration;\n+    ad[i].late = ad[i].times = 0;\n+    ad[i].timein = PR_IntervalNow();\n+    ad[i].period = PR_SecondsToInterval(1);\n+\n+    /* more loops, faster rate => same elapsed time */\n+    ad[i].times = (i + 1) * loops;\n+    ad[i].rate = (i + 1) * 10;\n+  }\n+\n+  alarm = PR_CreateAlarm();\n+\n+  for (i = 0; i < 3; ++i) {\n+    (void)PR_SetAlarm(alarm, ad[i].period, ad[i].rate, AlarmFn2, &ad[i]);\n+  }\n+\n+  overhead = PR_IntervalNow() - timein;\n+\n+  PR_Lock(ml);\n+  for (i = 0; i < 3; ++i) {\n+    while ((PRIntervalTime)(PR_IntervalNow() - ad[i].timein) < duration) {\n+      PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n     }\n+  }\n+  PR_Unlock(ml);\n \n-    overhead = PR_IntervalNow() - timein;\n+  timein = PR_IntervalNow();\n \n-    PR_Lock(ml);\n-    for (i = 0; i < 3; ++i) {\n-        while ((PRIntervalTime)(PR_IntervalNow() - ad[i].timein) < duration) {\n-            PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-    }\n-    PR_Unlock(ml);\n+  if (debug_mode)\n+    printf(\"Alarms3 finished at %u, %u, %u\\n\", ad[0].timein, ad[1].timein,\n+           ad[2].timein);\n \n-    timein = PR_IntervalNow();\n-\n-    if (debug_mode)\n-        printf(\"Alarms3 finished at %u, %u, %u\\n\", ad[0].timein, ad[1].timein,\n-               ad[2].timein);\n-\n-    rv = PR_DestroyAlarm(alarm);\n-    if (rv != PR_SUCCESS) {\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        } else {\n-            printf(\"***Destroying alarm status: FAIL\\n\");\n-        }\n+  rv = PR_DestroyAlarm(alarm);\n+  if (rv != PR_SUCCESS) {\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    } else {\n+      printf(\"***Destroying alarm status: FAIL\\n\");\n     }\n-    PR_DestroyCondVar(cv);\n-    PR_DestroyLock(ml);\n+  }\n+  PR_DestroyCondVar(cv);\n+  PR_DestroyLock(ml);\n \n-    overhead += (duration / 3);\n-    overhead += (PR_IntervalNow() - timein);\n+  overhead += (duration / 3);\n+  overhead += (PR_IntervalNow() - timein);\n \n-    return overhead;\n+  return overhead;\n } /* Alarms3 */\n \n-static PRUint32\n-TimeThis(const char* msg, PRUint32 (*func)(PRUint32 loops),\n-         PRUint32 loops)\n-{\n-    PRUint32 overhead, usecs;\n-    PRIntervalTime predicted, timein, timeout, ticks;\n+static PRUint32 TimeThis(const char* msg, PRUint32 (*func)(PRUint32 loops),\n+                         PRUint32 loops) {\n+  PRUint32 overhead, usecs;\n+  PRIntervalTime predicted, timein, timeout, ticks;\n \n-    if (debug_mode) {\n-        printf(\"Testing %s ...\", msg);\n-    }\n+  if (debug_mode) {\n+    printf(\"Testing %s ...\", msg);\n+  }\n \n-    timein = PR_IntervalNow();\n-    predicted = func(loops);\n-    timeout = PR_IntervalNow();\n+  timein = PR_IntervalNow();\n+  predicted = func(loops);\n+  timeout = PR_IntervalNow();\n \n-    if (debug_mode) {\n-        printf(\" done\\n\");\n-    }\n+  if (debug_mode) {\n+    printf(\" done\\n\");\n+  }\n \n-    ticks = timeout - timein;\n-    usecs = PR_IntervalToMicroseconds(ticks);\n-    overhead = PR_IntervalToMicroseconds(predicted);\n+  ticks = timeout - timein;\n+  usecs = PR_IntervalToMicroseconds(ticks);\n+  overhead = PR_IntervalToMicroseconds(predicted);\n \n-    if (ticks < predicted) {\n-        if (debug_mode) {\n-            printf(\"\\tFinished in negative time\\n\");\n-            printf(\"\\tpredicted overhead was %d usecs\\n\", overhead);\n-            printf(\"\\ttest completed in %d usecs\\n\\n\", usecs);\n-        }\n-    } else {\n-        if (debug_mode)\n-            printf(\"\\ttotal: %d usecs\\n\\toverhead: %d usecs\\n\\tcost: %6.3f usecs\\n\\n\",\n-                   usecs, overhead, ((double)(usecs - overhead) / (double)loops));\n+  if (ticks < predicted) {\n+    if (debug_mode) {\n+      printf(\"\\tFinished in negative time\\n\");\n+      printf(\"\\tpredicted overhead was %d usecs\\n\", overhead);\n+      printf(\"\\ttest completed in %d usecs\\n\\n\", usecs);\n     }\n+  } else {\n+    if (debug_mode)\n+      printf(\"\\ttotal: %d usecs\\n\\toverhead: %d usecs\\n\\tcost: %6.3f usecs\\n\\n\",\n+             usecs, overhead, ((double)(usecs - overhead) / (double)loops));\n+  }\n \n-    return overhead;\n+  return overhead;\n } /* TimeThis */\n \n-int\n-prmain(int argc, char** argv)\n-{\n-    PRUint32 cpu, cpus = 0, loops = 0;\n-\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name [-d]\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"Gdl:c:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'G': /* GLOBAL threads */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            case 'l': /* loop count */\n-                loops = atoi(opt->value);\n-                break;\n-            case 'c': /* concurrency limit */\n-                cpus = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    if (cpus == 0) {\n-        cpus = 1;\n+int prmain(int argc, char** argv) {\n+  PRUint32 cpu, cpus = 0, loops = 0;\n+\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name [-d]\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"Gdl:c:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    if (loops == 0) {\n-        loops = 4;\n+    switch (opt->option) {\n+      case 'G': /* GLOBAL threads */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      case 'l': /* loop count */\n+        loops = atoi(opt->value);\n+        break;\n+      case 'c': /* concurrency limit */\n+        cpus = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    if (debug_mode) {\n-        printf(\"Alarm: Using %d loops\\n\", loops);\n-    }\n+  if (cpus == 0) {\n+    cpus = 1;\n+  }\n+  if (loops == 0) {\n+    loops = 4;\n+  }\n+\n+  if (debug_mode) {\n+    printf(\"Alarm: Using %d loops\\n\", loops);\n+  }\n \n+  if (debug_mode) {\n+    printf(\"Alarm: Using %d cpu(s)\\n\", cpus);\n+  }\n+\n+  for (cpu = 1; cpu <= cpus; ++cpu) {\n     if (debug_mode) {\n-        printf(\"Alarm: Using %d cpu(s)\\n\", cpus);\n+      printf(\"\\nAlarm: Using %d CPU(s)\\n\", cpu);\n     }\n \n-    for (cpu = 1; cpu <= cpus; ++cpu) {\n-        if (debug_mode) {\n-            printf(\"\\nAlarm: Using %d CPU(s)\\n\", cpu);\n-        }\n-\n-        PR_SetConcurrency(cpu);\n+    PR_SetConcurrency(cpu);\n \n-        /* some basic time test */\n-        (void)TimeThis(\"ConditionNotify\", ConditionNotify, loops);\n-        (void)TimeThis(\"ConditionTimeout\", ConditionTimeout, loops);\n-        (void)TimeThis(\"Alarms1\", Alarms1, loops);\n-        (void)TimeThis(\"Alarms2\", Alarms2, loops);\n-        (void)TimeThis(\"Alarms3\", Alarms3, loops);\n-    }\n-    return 0;\n+    /* some basic time test */\n+    (void)TimeThis(\"ConditionNotify\", ConditionNotify, loops);\n+    (void)TimeThis(\"ConditionTimeout\", ConditionTimeout, loops);\n+    (void)TimeThis(\"Alarms1\", Alarms1, loops);\n+    (void)TimeThis(\"Alarms2\", Alarms2, loops);\n+    (void)TimeThis(\"Alarms3\", Alarms3, loops);\n+  }\n+  return 0;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PR_Initialize(prmain, argc, argv, 0);\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+int main(int argc, char** argv) {\n+  PR_Initialize(prmain, argc, argv, 0);\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n \n } /* main */\n \ndiff --git a/nspr/pr/tests/anonfm.c b/nspr/pr/tests/anonfm.c\nindex fc77426..14eaf90 100644\n--- a/nspr/pr/tests/anonfm.c\n+++ b/nspr/pr/tests/anonfm.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -52,248 +53,234 @@ const char* fmEnvName = \"nsprFileMapEnvVariable\";\n /*\n ** Emit help text for this test\n */\n-static void\n-Help(void)\n-{\n-    printf(\"anonfm [options] [dirName]\\n\");\n-    printf(\"-d -- enable debug mode\\n\");\n-    printf(\n-        \"dirName is alternate directory name. Default: . (current directory)\\n\");\n-    exit(1);\n+static void Help(void) {\n+  printf(\"anonfm [options] [dirName]\\n\");\n+  printf(\"-d -- enable debug mode\\n\");\n+  printf(\n+      \"dirName is alternate directory name. Default: . (current directory)\\n\");\n+  exit(1);\n } /* end Help() */\n \n /*\n ** ClientOne() --\n */\n-static void\n-ClientOne(void)\n-{\n-    PRFileMap* fm;\n-    char* fmString;\n-    char* addr;\n-    PRStatus rc;\n-\n-    PR_LOG(lm, msgLevel, (\"ClientOne() starting\"));\n-\n-    fmString = PR_GetEnv(fmEnvName);\n-    if (NULL == fmString) {\n-        failed_already = 1;\n-        PR_LOG(lm, msgLevel, (\"ClientOne(): PR_Getenv() failed\"));\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"ClientOne(): PR_Getenv(): found: %s\", fmString));\n+static void ClientOne(void) {\n+  PRFileMap* fm;\n+  char* fmString;\n+  char* addr;\n+  PRStatus rc;\n \n-    fm = PR_ImportFileMapFromString(fmString);\n-    if (NULL == fm) {\n-        failed_already = 1;\n-        PR_LOG(lm, msgLevel, (\"ClientOne(): PR_ImportFileMapFromString() failed\"));\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel,\n-           (\"ClientOne(): PR_ImportFileMapFromString(): fm: %p\", fm));\n-\n-    addr = PR_MemMap(fm, LL_ZERO, fmSize);\n-    if (NULL == addr) {\n-        failed_already = 1;\n-        PR_LOG(lm, msgLevel,\n-               (\"ClientOne(): PR_MemMap() failed, OSError: %d\", PR_GetOSError()));\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"ClientOne(): PR_MemMap(): addr: %p\", addr));\n+  PR_LOG(lm, msgLevel, (\"ClientOne() starting\"));\n+\n+  fmString = PR_GetEnv(fmEnvName);\n+  if (NULL == fmString) {\n+    failed_already = 1;\n+    PR_LOG(lm, msgLevel, (\"ClientOne(): PR_Getenv() failed\"));\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"ClientOne(): PR_Getenv(): found: %s\", fmString));\n \n-    /* write to memory map to release server */\n-    *addr = 1;\n+  fm = PR_ImportFileMapFromString(fmString);\n+  if (NULL == fm) {\n+    failed_already = 1;\n+    PR_LOG(lm, msgLevel, (\"ClientOne(): PR_ImportFileMapFromString() failed\"));\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel,\n+         (\"ClientOne(): PR_ImportFileMapFromString(): fm: %p\", fm));\n \n-    rc = PR_MemUnmap(addr, fmSize);\n-    PR_ASSERT(rc == PR_SUCCESS);\n-    PR_LOG(lm, msgLevel, (\"ClientOne(): PR_MemUnap(): success\"));\n+  addr = PR_MemMap(fm, LL_ZERO, fmSize);\n+  if (NULL == addr) {\n+    failed_already = 1;\n+    PR_LOG(lm, msgLevel,\n+           (\"ClientOne(): PR_MemMap() failed, OSError: %d\", PR_GetOSError()));\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"ClientOne(): PR_MemMap(): addr: %p\", addr));\n \n-    rc = PR_CloseFileMap(fm);\n-    if (PR_FAILURE == rc) {\n-        failed_already = 1;\n-        PR_LOG(lm, msgLevel,\n-               (\"ClientOne(): PR_MemUnap() failed, OSError: %d\", PR_GetOSError()));\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"ClientOne(): PR_CloseFileMap(): success\"));\n+  /* write to memory map to release server */\n+  *addr = 1;\n+\n+  rc = PR_MemUnmap(addr, fmSize);\n+  PR_ASSERT(rc == PR_SUCCESS);\n+  PR_LOG(lm, msgLevel, (\"ClientOne(): PR_MemUnap(): success\"));\n \n+  rc = PR_CloseFileMap(fm);\n+  if (PR_FAILURE == rc) {\n+    failed_already = 1;\n+    PR_LOG(lm, msgLevel,\n+           (\"ClientOne(): PR_MemUnap() failed, OSError: %d\", PR_GetOSError()));\n     return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"ClientOne(): PR_CloseFileMap(): success\"));\n+\n+  return;\n } /* end ClientOne() */\n \n /*\n ** ClientTwo() --\n */\n-static void\n-ClientTwo(void)\n-{\n-    failed_already = 1;\n-} /* end ClientTwo() */\n+static void ClientTwo(void) { failed_already = 1; } /* end ClientTwo() */\n \n /*\n ** ServerOne() --\n */\n-static void\n-ServerOne(void)\n-{\n-    PRFileMap* fm;\n-    PRStatus rc;\n-    PRIntn i;\n-    char* addr;\n-    char fmString[256];\n-    char envBuf[256];\n-    char* child_argv[8];\n-    PRProcess* proc;\n-    PRInt32 exit_status;\n-\n-    PR_LOG(lm, msgLevel, (\"ServerOne() starting\"));\n-\n-    fm = PR_OpenAnonFileMap(dirName, fmSize, fmProt);\n-    if (NULL == fm) {\n-        failed_already = 1;\n-        PR_LOG(lm, msgLevel, (\"PR_OpenAnonFileMap() failed\"));\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"ServerOne(): FileMap: %p\", fm));\n-\n-    rc = PR_ExportFileMapAsString(fm, sizeof(fmString), fmString);\n-    if (PR_FAILURE == rc) {\n-        failed_already = 1;\n-        PR_LOG(lm, msgLevel, (\"PR_ExportFileMap() failed\"));\n-        return;\n-    }\n-\n-    /*\n-    ** put the string into the environment\n-    */\n-    PR_snprintf(envBuf, sizeof(envBuf), \"%s=%s\", fmEnvName, fmString);\n-    putenv(envBuf);\n-\n-    addr = PR_MemMap(fm, LL_ZERO, fmSize);\n-    if (NULL == addr) {\n-        failed_already = 1;\n-        PR_LOG(lm, msgLevel, (\"PR_MemMap() failed\"));\n-        return;\n-    }\n-\n-    /* set initial value for client */\n-    for (i = 0; i < (PRIntn)fmSize; i++) {\n-        *(addr + i) = 0x00;\n-    }\n-\n-    PR_LOG(lm, msgLevel, (\"ServerOne(): PR_MemMap(): addr: %p\", addr));\n+static void ServerOne(void) {\n+  PRFileMap* fm;\n+  PRStatus rc;\n+  PRIntn i;\n+  char* addr;\n+  char fmString[256];\n+  char envBuf[256];\n+  char* child_argv[8];\n+  PRProcess* proc;\n+  PRInt32 exit_status;\n+\n+  PR_LOG(lm, msgLevel, (\"ServerOne() starting\"));\n+\n+  fm = PR_OpenAnonFileMap(dirName, fmSize, fmProt);\n+  if (NULL == fm) {\n+    failed_already = 1;\n+    PR_LOG(lm, msgLevel, (\"PR_OpenAnonFileMap() failed\"));\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"ServerOne(): FileMap: %p\", fm));\n \n-    /*\n-    ** set arguments for child process\n-    */\n-    child_argv[0] = \"anonfm\";\n-    child_argv[1] = \"-C\";\n-    child_argv[2] = \"1\";\n-    child_argv[3] = NULL;\n+  rc = PR_ExportFileMapAsString(fm, sizeof(fmString), fmString);\n+  if (PR_FAILURE == rc) {\n+    failed_already = 1;\n+    PR_LOG(lm, msgLevel, (\"PR_ExportFileMap() failed\"));\n+    return;\n+  }\n \n-    proc = PR_CreateProcess(child_argv[0], child_argv, NULL, NULL);\n-    PR_ASSERT(proc);\n-    PR_LOG(lm, msgLevel, (\"ServerOne(): PR_CreateProcess(): proc: %x\", proc));\n+  /*\n+  ** put the string into the environment\n+  */\n+  PR_snprintf(envBuf, sizeof(envBuf), \"%s=%s\", fmEnvName, fmString);\n+  putenv(envBuf);\n \n-    /*\n-    ** ClientOne() will set the memory to 1\n-    */\n-    PR_LOG(lm, msgLevel, (\"ServerOne(): waiting on Client, *addr: %x\", *addr));\n-    while (*addr == 0x00) {\n-        if (debug) {\n-            fprintf(stderr, \".\");\n-        }\n-        PR_Sleep(PR_MillisecondsToInterval(300));\n-    }\n+  addr = PR_MemMap(fm, LL_ZERO, fmSize);\n+  if (NULL == addr) {\n+    failed_already = 1;\n+    PR_LOG(lm, msgLevel, (\"PR_MemMap() failed\"));\n+    return;\n+  }\n+\n+  /* set initial value for client */\n+  for (i = 0; i < (PRIntn)fmSize; i++) {\n+    *(addr + i) = 0x00;\n+  }\n+\n+  PR_LOG(lm, msgLevel, (\"ServerOne(): PR_MemMap(): addr: %p\", addr));\n+\n+  /*\n+  ** set arguments for child process\n+  */\n+  child_argv[0] = \"anonfm\";\n+  child_argv[1] = \"-C\";\n+  child_argv[2] = \"1\";\n+  child_argv[3] = NULL;\n+\n+  proc = PR_CreateProcess(child_argv[0], child_argv, NULL, NULL);\n+  PR_ASSERT(proc);\n+  PR_LOG(lm, msgLevel, (\"ServerOne(): PR_CreateProcess(): proc: %x\", proc));\n+\n+  /*\n+  ** ClientOne() will set the memory to 1\n+  */\n+  PR_LOG(lm, msgLevel, (\"ServerOne(): waiting on Client, *addr: %x\", *addr));\n+  while (*addr == 0x00) {\n     if (debug) {\n-        fprintf(stderr, \"\\n\");\n-    }\n-    PR_LOG(lm, msgLevel, (\"ServerOne(): Client responded\"));\n-\n-    rc = PR_WaitProcess(proc, &exit_status);\n-    PR_ASSERT(PR_FAILURE != rc);\n-\n-    rc = PR_MemUnmap(addr, fmSize);\n-    if (PR_FAILURE == rc) {\n-        failed_already = 1;\n-        PR_LOG(lm, msgLevel, (\"PR_MemUnmap() failed\"));\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"ServerOne(): PR_MemUnmap(): success\"));\n-\n-    rc = PR_CloseFileMap(fm);\n-    if (PR_FAILURE == rc) {\n-        failed_already = 1;\n-        PR_LOG(lm, msgLevel, (\"PR_CloseFileMap() failed\"));\n-        return;\n+      fprintf(stderr, \".\");\n     }\n-    PR_LOG(lm, msgLevel, (\"ServerOne(): PR_CloseFileMap() success\"));\n+    PR_Sleep(PR_MillisecondsToInterval(300));\n+  }\n+  if (debug) {\n+    fprintf(stderr, \"\\n\");\n+  }\n+  PR_LOG(lm, msgLevel, (\"ServerOne(): Client responded\"));\n+\n+  rc = PR_WaitProcess(proc, &exit_status);\n+  PR_ASSERT(PR_FAILURE != rc);\n+\n+  rc = PR_MemUnmap(addr, fmSize);\n+  if (PR_FAILURE == rc) {\n+    failed_already = 1;\n+    PR_LOG(lm, msgLevel, (\"PR_MemUnmap() failed\"));\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"ServerOne(): PR_MemUnmap(): success\"));\n \n+  rc = PR_CloseFileMap(fm);\n+  if (PR_FAILURE == rc) {\n+    failed_already = 1;\n+    PR_LOG(lm, msgLevel, (\"PR_CloseFileMap() failed\"));\n     return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"ServerOne(): PR_CloseFileMap() success\"));\n+\n+  return;\n } /* end ServerOne() */\n \n /*\n ** ServerTwo() --\n */\n-static void\n-ServerTwo(void)\n-{\n-    PR_LOG(lm, msgLevel, (\"ServerTwo(): Not implemented yet\"));\n+static void ServerTwo(void) {\n+  PR_LOG(lm, msgLevel, (\"ServerTwo(): Not implemented yet\"));\n } /* end ServerTwo() */\n \n-int\n-main(int argc, char** argv)\n-{\n-    {\n-        /*\n-        ** Get command line options\n-        */\n-        PLOptStatus os;\n-        PLOptState* opt = PL_CreateOptState(argc, argv, \"hdC:\");\n-\n-        while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-            if (PL_OPT_BAD == os) {\n-                continue;\n-            }\n-            switch (opt->option) {\n-                case 'C': /* Client style */\n-                    client = atol(opt->value);\n-                    break;\n-                case 's': /* file size */\n-                    fmSize = atol(opt->value) * 1024;\n-                    break;\n-                case 'd': /* debug */\n-                    debug = 1;\n-                    msgLevel = PR_LOG_DEBUG;\n-                    break;\n-                case 'h': /* help message */\n-                    Help();\n-                    break;\n-                default:\n-                    strcpy(dirName, opt->value);\n-                    break;\n-            }\n-        }\n-        PL_DestroyOptState(opt);\n+int main(int argc, char** argv) {\n+  {\n+    /*\n+    ** Get command line options\n+    */\n+    PLOptStatus os;\n+    PLOptState* opt = PL_CreateOptState(argc, argv, \"hdC:\");\n+\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+      if (PL_OPT_BAD == os) {\n+        continue;\n+      }\n+      switch (opt->option) {\n+        case 'C': /* Client style */\n+          client = atol(opt->value);\n+          break;\n+        case 's': /* file size */\n+          fmSize = atol(opt->value) * 1024;\n+          break;\n+        case 'd': /* debug */\n+          debug = 1;\n+          msgLevel = PR_LOG_DEBUG;\n+          break;\n+        case 'h': /* help message */\n+          Help();\n+          break;\n+        default:\n+          strcpy(dirName, opt->value);\n+          break;\n+      }\n     }\n-\n-    lm = PR_NewLogModule(\"Test\"); /* Initialize logging */\n-\n-    if (client == 1) {\n-        ClientOne();\n-    } else if (client == 2) {\n-        ClientTwo();\n-    } else {\n-        ServerOne();\n-        if (failed_already) {\n-            goto Finished;\n-        }\n-        ServerTwo();\n+    PL_DestroyOptState(opt);\n+  }\n+\n+  lm = PR_NewLogModule(\"Test\"); /* Initialize logging */\n+\n+  if (client == 1) {\n+    ClientOne();\n+  } else if (client == 2) {\n+    ClientTwo();\n+  } else {\n+    ServerOne();\n+    if (failed_already) {\n+      goto Finished;\n     }\n+    ServerTwo();\n+  }\n \n Finished:\n-    if (debug) {\n-        printf(\"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n-    }\n-    return ((failed_already == PR_TRUE) ? 1 : 0);\n+  if (debug) {\n+    printf(\"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n+  }\n+  return ((failed_already == PR_TRUE) ? 1 : 0);\n } /* main() */\n /* end anonfm.c */\ndiff --git a/nspr/pr/tests/append.c b/nspr/pr/tests/append.c\nindex a2c6119..c8c5c35 100644\n--- a/nspr/pr/tests/append.c\n+++ b/nspr/pr/tests/append.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -29,117 +30,115 @@ const PRInt32 addedBytes = 1000;\n const PRInt32 buf = 1; /* constant written to fd, addedBytes times */\n PRInt32 inBuf;         /* read it back into here */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRStatus rc;\n-    PRInt32 rv;\n-    PRFileDesc* fd;\n-    PRIntn i;\n-    PRInt32 sum = 0;\n+int main(int argc, char** argv) {\n+  PRStatus rc;\n+  PRInt32 rv;\n+  PRFileDesc* fd;\n+  PRIntn i;\n+  PRInt32 sum = 0;\n \n-    { /* Get command line options */\n-        PLOptStatus os;\n-        PLOptState* opt = PL_CreateOptState(argc, argv, \"vd\");\n+  { /* Get command line options */\n+    PLOptStatus os;\n+    PLOptState* opt = PL_CreateOptState(argc, argv, \"vd\");\n \n-        while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-            if (PL_OPT_BAD == os) {\n-                continue;\n-            }\n-            switch (opt->option) {\n-                case 'd': /* debug */\n-                    debug = 1;\n-                    break;\n-                case 'v': /* verbose */\n-                    verbose = 1;\n-                    break;\n-                default:\n-                    break;\n-            }\n-        }\n-        PL_DestroyOptState(opt);\n-    } /* end block \"Get command line options\" */\n-    /* ---------------------------------------------------------------------- */\n-    fd = PR_Open(\"./tmp-nsprAppend\",\n-                 (PR_APPEND | PR_CREATE_FILE | PR_TRUNCATE | PR_WRONLY), 0666);\n-    if (NULL == fd) {\n-        if (debug) {\n-            printf(\"PR_Open() failed for writing: %d\\n\", PR_GetError());\n-        }\n-        failedAlready = PR_TRUE;\n-        goto Finished;\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+      if (PL_OPT_BAD == os) {\n+        continue;\n+      }\n+      switch (opt->option) {\n+        case 'd': /* debug */\n+          debug = 1;\n+          break;\n+        case 'v': /* verbose */\n+          verbose = 1;\n+          break;\n+        default:\n+          break;\n+      }\n     }\n+    PL_DestroyOptState(opt);\n+  } /* end block \"Get command line options\" */\n+  /* ---------------------------------------------------------------------- */\n+  fd = PR_Open(\"./tmp-nsprAppend\",\n+               (PR_APPEND | PR_CREATE_FILE | PR_TRUNCATE | PR_WRONLY), 0666);\n+  if (NULL == fd) {\n+    if (debug) {\n+      printf(\"PR_Open() failed for writing: %d\\n\", PR_GetError());\n+    }\n+    failedAlready = PR_TRUE;\n+    goto Finished;\n+  }\n \n-    for (i = 0; i < addedBytes; i++) {\n-        rv = PR_Write(fd, &buf, sizeof(buf));\n-        if (sizeof(buf) != rv) {\n-            if (debug) {\n-                printf(\"PR_Write() failed: %d\\n\", PR_GetError());\n-            }\n-            failedAlready = PR_TRUE;\n-            goto Finished;\n-        }\n-        rv = PR_Seek(fd, 0, PR_SEEK_SET);\n-        if (-1 == rv) {\n-            if (debug) {\n-                printf(\"PR_Seek() failed: %d\\n\", PR_GetError());\n-            }\n-            failedAlready = PR_TRUE;\n-            goto Finished;\n-        }\n+  for (i = 0; i < addedBytes; i++) {\n+    rv = PR_Write(fd, &buf, sizeof(buf));\n+    if (sizeof(buf) != rv) {\n+      if (debug) {\n+        printf(\"PR_Write() failed: %d\\n\", PR_GetError());\n+      }\n+      failedAlready = PR_TRUE;\n+      goto Finished;\n+    }\n+    rv = PR_Seek(fd, 0, PR_SEEK_SET);\n+    if (-1 == rv) {\n+      if (debug) {\n+        printf(\"PR_Seek() failed: %d\\n\", PR_GetError());\n+      }\n+      failedAlready = PR_TRUE;\n+      goto Finished;\n     }\n-    rc = PR_Close(fd);\n-    if (PR_FAILURE == rc) {\n-        if (debug) {\n-            printf(\"PR_Close() failed after writing: %d\\n\", PR_GetError());\n-        }\n-        failedAlready = PR_TRUE;\n-        goto Finished;\n+  }\n+  rc = PR_Close(fd);\n+  if (PR_FAILURE == rc) {\n+    if (debug) {\n+      printf(\"PR_Close() failed after writing: %d\\n\", PR_GetError());\n     }\n-    /* ---------------------------------------------------------------------- */\n-    fd = PR_Open(\"./tmp-nsprAppend\", PR_RDONLY, 0);\n-    if (NULL == fd) {\n-        if (debug) {\n-            printf(\"PR_Open() failed for reading: %d\\n\", PR_GetError());\n-        }\n-        failedAlready = PR_TRUE;\n-        goto Finished;\n+    failedAlready = PR_TRUE;\n+    goto Finished;\n+  }\n+  /* ---------------------------------------------------------------------- */\n+  fd = PR_Open(\"./tmp-nsprAppend\", PR_RDONLY, 0);\n+  if (NULL == fd) {\n+    if (debug) {\n+      printf(\"PR_Open() failed for reading: %d\\n\", PR_GetError());\n     }\n+    failedAlready = PR_TRUE;\n+    goto Finished;\n+  }\n \n-    for (i = 0; i < addedBytes; i++) {\n-        rv = PR_Read(fd, &inBuf, sizeof(inBuf));\n-        if (sizeof(inBuf) != rv) {\n-            if (debug) {\n-                printf(\"PR_Write() failed: %d\\n\", PR_GetError());\n-            }\n-            failedAlready = PR_TRUE;\n-            goto Finished;\n-        }\n-        sum += inBuf;\n+  for (i = 0; i < addedBytes; i++) {\n+    rv = PR_Read(fd, &inBuf, sizeof(inBuf));\n+    if (sizeof(inBuf) != rv) {\n+      if (debug) {\n+        printf(\"PR_Write() failed: %d\\n\", PR_GetError());\n+      }\n+      failedAlready = PR_TRUE;\n+      goto Finished;\n     }\n+    sum += inBuf;\n+  }\n \n-    rc = PR_Close(fd);\n-    if (PR_FAILURE == rc) {\n-        if (debug) {\n-            printf(\"PR_Close() failed after reading: %d\\n\", PR_GetError());\n-        }\n-        failedAlready = PR_TRUE;\n-        goto Finished;\n+  rc = PR_Close(fd);\n+  if (PR_FAILURE == rc) {\n+    if (debug) {\n+      printf(\"PR_Close() failed after reading: %d\\n\", PR_GetError());\n     }\n-    if (sum != addedBytes) {\n-        if (debug) {\n-            printf(\"Uh Oh! addedBytes: %d. Sum: %d\\n\", addedBytes, sum);\n-        }\n-        failedAlready = PR_TRUE;\n-        goto Finished;\n+    failedAlready = PR_TRUE;\n+    goto Finished;\n+  }\n+  if (sum != addedBytes) {\n+    if (debug) {\n+      printf(\"Uh Oh! addedBytes: %d. Sum: %d\\n\", addedBytes, sum);\n     }\n+    failedAlready = PR_TRUE;\n+    goto Finished;\n+  }\n \n-    /* ---------------------------------------------------------------------- */\n+  /* ---------------------------------------------------------------------- */\n Finished:\n-    if (debug || verbose) {\n-        printf(\"%s\\n\", (failedAlready) ? \"FAILED\" : \"PASSED\");\n-    }\n-    return ((failedAlready) ? 1 : 0);\n+  if (debug || verbose) {\n+    printf(\"%s\\n\", (failedAlready) ? \"FAILED\" : \"PASSED\");\n+  }\n+  return ((failedAlready) ? 1 : 0);\n } /* main() */\n \n /* append.c */\ndiff --git a/nspr/pr/tests/atomic.c b/nspr/pr/tests/atomic.c\nindex d89448e..ba7d338 100644\n--- a/nspr/pr/tests/atomic.c\n+++ b/nspr/pr/tests/atomic.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -14,147 +15,145 @@\n  *     result |= !(EXPRESSION);\n  */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRInt32 rv, oldval, test, result = 0;\n-    PRFileDesc* output = PR_GetSpecialFD(PR_StandardOutput);\n-\n-    /***********************/\n-    /* Test the functions. */\n-    /***********************/\n-\n-    oldval = test = -2;\n-    rv = PR_AtomicIncrement(&test);\n-    result = result | ((rv == -1) ? 0 : 1);\n-    PR_fprintf(output, \"PR_AtomicIncrement(%d) == %d: %s\\n\", oldval, rv,\n-               (rv == -1) ? \"PASSED\" : \"FAILED\");\n-    oldval = test;\n-    rv = PR_AtomicIncrement(&test);\n-    result = result | ((rv == 0) ? 0 : 1);\n-    PR_fprintf(output, \"PR_AtomicIncrement(%d) == %d: %s\\n\", oldval, rv,\n-               (rv == 0) ? \"PASSED\" : \"FAILED\");\n-    oldval = test;\n-    rv = PR_AtomicIncrement(&test);\n-    result = result | ((rv == 1) ? 0 : 1);\n-    PR_fprintf(output, \"PR_AtomicIncrement(%d) == %d: %s\\n\", oldval, rv,\n-               (rv == 1) ? \"PASSED\" : \"FAILED\");\n-\n-    oldval = test = -2;\n-    rv = PR_AtomicAdd(&test, 1);\n-    result = result | ((rv == -1) ? 0 : 1);\n-    PR_fprintf(output, \"PR_AtomicAdd(%d,%d) == %d: %s\\n\", oldval, 1, rv,\n-               (rv == -1) ? \"PASSED\" : \"FAILED\");\n-    oldval = test;\n-    rv = PR_AtomicAdd(&test, 4);\n-    result = result | ((rv == 3) ? 0 : 1);\n-    PR_fprintf(output, \"PR_AtomicAdd(%d,%d) == %d: %s\\n\", oldval, 4, rv,\n-               (rv == 3) ? \"PASSED\" : \"FAILED\");\n-    oldval = test;\n-    rv = PR_AtomicAdd(&test, -6);\n-    result = result | ((rv == -3) ? 0 : 1);\n-    PR_fprintf(output, \"PR_AtomicAdd(%d,%d) == %d: %s\\n\", oldval, -6, rv,\n-               (rv == -3) ? \"PASSED\" : \"FAILED\");\n-\n-    oldval = test = 2;\n-    rv = PR_AtomicDecrement(&test);\n-    result = result | ((rv == 1) ? 0 : 1);\n-    PR_fprintf(output, \"PR_AtomicDecrement(%d) == %d: %s\\n\", oldval, rv,\n-               (rv == 1) ? \"PASSED\" : \"FAILED\");\n-    oldval = test;\n-    rv = PR_AtomicDecrement(&test);\n-    result = result | ((rv == 0) ? 0 : 1);\n-    PR_fprintf(output, \"PR_AtomicDecrement(%d) == %d: %s\\n\", oldval, rv,\n-               (rv == 0) ? \"PASSED\" : \"FAILED\");\n-    oldval = test;\n-    rv = PR_AtomicDecrement(&test);\n-    result = result | ((rv == -1) ? 0 : 1);\n-    PR_fprintf(output, \"PR_AtomicDecrement(%d) == %d: %s\\n\", oldval, rv,\n-               (rv == -1) ? \"PASSED\" : \"FAILED\");\n-\n-    /* set to a different value */\n-    oldval = test = -2;\n-    rv = PR_AtomicSet(&test, 2);\n-    result = result | (((rv == -2) && (test == 2)) ? 0 : 1);\n-    PR_fprintf(output, \"PR_AtomicSet(%d, %d) == %d: %s\\n\", oldval, 2, rv,\n-               ((rv == -2) && (test == 2)) ? \"PASSED\" : \"FAILED\");\n-\n-    /* set to the same value */\n-    oldval = test = -2;\n-    rv = PR_AtomicSet(&test, -2);\n-    result = result | (((rv == -2) && (test == -2)) ? 0 : 1);\n-    PR_fprintf(output, \"PR_AtomicSet(%d, %d) == %d: %s\\n\", oldval, -2, rv,\n-               ((rv == -2) && (test == -2)) ? \"PASSED\" : \"FAILED\");\n-\n-    /***********************/\n-    /* Test the macros.    */\n-    /***********************/\n-\n-    oldval = test = -2;\n-    rv = PR_ATOMIC_INCREMENT(&test);\n-    result = result | ((rv == -1) ? 0 : 1);\n-    PR_fprintf(output, \"PR_ATOMIC_INCREMENT(%d) == %d: %s\\n\", oldval, rv,\n-               (rv == -1) ? \"PASSED\" : \"FAILED\");\n-    oldval = test;\n-    rv = PR_ATOMIC_INCREMENT(&test);\n-    result = result | ((rv == 0) ? 0 : 1);\n-    PR_fprintf(output, \"PR_ATOMIC_INCREMENT(%d) == %d: %s\\n\", oldval, rv,\n-               (rv == 0) ? \"PASSED\" : \"FAILED\");\n-    oldval = test;\n-    rv = PR_ATOMIC_INCREMENT(&test);\n-    result = result | ((rv == 1) ? 0 : 1);\n-    PR_fprintf(output, \"PR_ATOMIC_INCREMENT(%d) == %d: %s\\n\", oldval, rv,\n-               (rv == 1) ? \"PASSED\" : \"FAILED\");\n-\n-    oldval = test = -2;\n-    rv = PR_ATOMIC_ADD(&test, 1);\n-    result = result | ((rv == -1) ? 0 : 1);\n-    PR_fprintf(output, \"PR_ATOMIC_ADD(%d,%d) == %d: %s\\n\", oldval, 1, rv,\n-               (rv == -1) ? \"PASSED\" : \"FAILED\");\n-    oldval = test;\n-    rv = PR_ATOMIC_ADD(&test, 4);\n-    result = result | ((rv == 3) ? 0 : 1);\n-    PR_fprintf(output, \"PR_ATOMIC_ADD(%d,%d) == %d: %s\\n\", oldval, 4, rv,\n-               (rv == 3) ? \"PASSED\" : \"FAILED\");\n-    oldval = test;\n-    rv = PR_ATOMIC_ADD(&test, -6);\n-    result = result | ((rv == -3) ? 0 : 1);\n-    PR_fprintf(output, \"PR_ATOMIC_ADD(%d,%d) == %d: %s\\n\", oldval, -6, rv,\n-               (rv == -3) ? \"PASSED\" : \"FAILED\");\n-\n-    oldval = test = 2;\n-    rv = PR_ATOMIC_DECREMENT(&test);\n-    result = result | ((rv == 1) ? 0 : 1);\n-    PR_fprintf(output, \"PR_ATOMIC_DECREMENT(%d) == %d: %s\\n\", oldval, rv,\n-               (rv == 1) ? \"PASSED\" : \"FAILED\");\n-    oldval = test;\n-    rv = PR_ATOMIC_DECREMENT(&test);\n-    result = result | ((rv == 0) ? 0 : 1);\n-    PR_fprintf(output, \"PR_ATOMIC_DECREMENT(%d) == %d: %s\\n\", oldval, rv,\n-               (rv == 0) ? \"PASSED\" : \"FAILED\");\n-    oldval = test;\n-    rv = PR_ATOMIC_DECREMENT(&test);\n-    result = result | ((rv == -1) ? 0 : 1);\n-    PR_fprintf(output, \"PR_ATOMIC_DECREMENT(%d) == %d: %s\\n\", oldval, rv,\n-               (rv == -1) ? \"PASSED\" : \"FAILED\");\n-\n-    /* set to a different value */\n-    oldval = test = -2;\n-    rv = PR_ATOMIC_SET(&test, 2);\n-    result = result | (((rv == -2) && (test == 2)) ? 0 : 1);\n-    PR_fprintf(output, \"PR_ATOMIC_SET(%d, %d) == %d: %s\\n\", oldval, 2, rv,\n-               ((rv == -2) && (test == 2)) ? \"PASSED\" : \"FAILED\");\n-\n-    /* set to the same value */\n-    oldval = test = -2;\n-    rv = PR_ATOMIC_SET(&test, -2);\n-    result = result | (((rv == -2) && (test == -2)) ? 0 : 1);\n-    PR_fprintf(output, \"PR_ATOMIC_SET(%d, %d) == %d: %s\\n\", oldval, -2, rv,\n-               ((rv == -2) && (test == -2)) ? \"PASSED\" : \"FAILED\");\n-\n-    PR_fprintf(output, \"Atomic operations test %s\\n\",\n-               (result == 0) ? \"PASSED\" : \"FAILED\");\n-    return result;\n+int main(int argc, char** argv) {\n+  PRInt32 rv, oldval, test, result = 0;\n+  PRFileDesc* output = PR_GetSpecialFD(PR_StandardOutput);\n+\n+  /***********************/\n+  /* Test the functions. */\n+  /***********************/\n+\n+  oldval = test = -2;\n+  rv = PR_AtomicIncrement(&test);\n+  result = result | ((rv == -1) ? 0 : 1);\n+  PR_fprintf(output, \"PR_AtomicIncrement(%d) == %d: %s\\n\", oldval, rv,\n+             (rv == -1) ? \"PASSED\" : \"FAILED\");\n+  oldval = test;\n+  rv = PR_AtomicIncrement(&test);\n+  result = result | ((rv == 0) ? 0 : 1);\n+  PR_fprintf(output, \"PR_AtomicIncrement(%d) == %d: %s\\n\", oldval, rv,\n+             (rv == 0) ? \"PASSED\" : \"FAILED\");\n+  oldval = test;\n+  rv = PR_AtomicIncrement(&test);\n+  result = result | ((rv == 1) ? 0 : 1);\n+  PR_fprintf(output, \"PR_AtomicIncrement(%d) == %d: %s\\n\", oldval, rv,\n+             (rv == 1) ? \"PASSED\" : \"FAILED\");\n+\n+  oldval = test = -2;\n+  rv = PR_AtomicAdd(&test, 1);\n+  result = result | ((rv == -1) ? 0 : 1);\n+  PR_fprintf(output, \"PR_AtomicAdd(%d,%d) == %d: %s\\n\", oldval, 1, rv,\n+             (rv == -1) ? \"PASSED\" : \"FAILED\");\n+  oldval = test;\n+  rv = PR_AtomicAdd(&test, 4);\n+  result = result | ((rv == 3) ? 0 : 1);\n+  PR_fprintf(output, \"PR_AtomicAdd(%d,%d) == %d: %s\\n\", oldval, 4, rv,\n+             (rv == 3) ? \"PASSED\" : \"FAILED\");\n+  oldval = test;\n+  rv = PR_AtomicAdd(&test, -6);\n+  result = result | ((rv == -3) ? 0 : 1);\n+  PR_fprintf(output, \"PR_AtomicAdd(%d,%d) == %d: %s\\n\", oldval, -6, rv,\n+             (rv == -3) ? \"PASSED\" : \"FAILED\");\n+\n+  oldval = test = 2;\n+  rv = PR_AtomicDecrement(&test);\n+  result = result | ((rv == 1) ? 0 : 1);\n+  PR_fprintf(output, \"PR_AtomicDecrement(%d) == %d: %s\\n\", oldval, rv,\n+             (rv == 1) ? \"PASSED\" : \"FAILED\");\n+  oldval = test;\n+  rv = PR_AtomicDecrement(&test);\n+  result = result | ((rv == 0) ? 0 : 1);\n+  PR_fprintf(output, \"PR_AtomicDecrement(%d) == %d: %s\\n\", oldval, rv,\n+             (rv == 0) ? \"PASSED\" : \"FAILED\");\n+  oldval = test;\n+  rv = PR_AtomicDecrement(&test);\n+  result = result | ((rv == -1) ? 0 : 1);\n+  PR_fprintf(output, \"PR_AtomicDecrement(%d) == %d: %s\\n\", oldval, rv,\n+             (rv == -1) ? \"PASSED\" : \"FAILED\");\n+\n+  /* set to a different value */\n+  oldval = test = -2;\n+  rv = PR_AtomicSet(&test, 2);\n+  result = result | (((rv == -2) && (test == 2)) ? 0 : 1);\n+  PR_fprintf(output, \"PR_AtomicSet(%d, %d) == %d: %s\\n\", oldval, 2, rv,\n+             ((rv == -2) && (test == 2)) ? \"PASSED\" : \"FAILED\");\n+\n+  /* set to the same value */\n+  oldval = test = -2;\n+  rv = PR_AtomicSet(&test, -2);\n+  result = result | (((rv == -2) && (test == -2)) ? 0 : 1);\n+  PR_fprintf(output, \"PR_AtomicSet(%d, %d) == %d: %s\\n\", oldval, -2, rv,\n+             ((rv == -2) && (test == -2)) ? \"PASSED\" : \"FAILED\");\n+\n+  /***********************/\n+  /* Test the macros.    */\n+  /***********************/\n+\n+  oldval = test = -2;\n+  rv = PR_ATOMIC_INCREMENT(&test);\n+  result = result | ((rv == -1) ? 0 : 1);\n+  PR_fprintf(output, \"PR_ATOMIC_INCREMENT(%d) == %d: %s\\n\", oldval, rv,\n+             (rv == -1) ? \"PASSED\" : \"FAILED\");\n+  oldval = test;\n+  rv = PR_ATOMIC_INCREMENT(&test);\n+  result = result | ((rv == 0) ? 0 : 1);\n+  PR_fprintf(output, \"PR_ATOMIC_INCREMENT(%d) == %d: %s\\n\", oldval, rv,\n+             (rv == 0) ? \"PASSED\" : \"FAILED\");\n+  oldval = test;\n+  rv = PR_ATOMIC_INCREMENT(&test);\n+  result = result | ((rv == 1) ? 0 : 1);\n+  PR_fprintf(output, \"PR_ATOMIC_INCREMENT(%d) == %d: %s\\n\", oldval, rv,\n+             (rv == 1) ? \"PASSED\" : \"FAILED\");\n+\n+  oldval = test = -2;\n+  rv = PR_ATOMIC_ADD(&test, 1);\n+  result = result | ((rv == -1) ? 0 : 1);\n+  PR_fprintf(output, \"PR_ATOMIC_ADD(%d,%d) == %d: %s\\n\", oldval, 1, rv,\n+             (rv == -1) ? \"PASSED\" : \"FAILED\");\n+  oldval = test;\n+  rv = PR_ATOMIC_ADD(&test, 4);\n+  result = result | ((rv == 3) ? 0 : 1);\n+  PR_fprintf(output, \"PR_ATOMIC_ADD(%d,%d) == %d: %s\\n\", oldval, 4, rv,\n+             (rv == 3) ? \"PASSED\" : \"FAILED\");\n+  oldval = test;\n+  rv = PR_ATOMIC_ADD(&test, -6);\n+  result = result | ((rv == -3) ? 0 : 1);\n+  PR_fprintf(output, \"PR_ATOMIC_ADD(%d,%d) == %d: %s\\n\", oldval, -6, rv,\n+             (rv == -3) ? \"PASSED\" : \"FAILED\");\n+\n+  oldval = test = 2;\n+  rv = PR_ATOMIC_DECREMENT(&test);\n+  result = result | ((rv == 1) ? 0 : 1);\n+  PR_fprintf(output, \"PR_ATOMIC_DECREMENT(%d) == %d: %s\\n\", oldval, rv,\n+             (rv == 1) ? \"PASSED\" : \"FAILED\");\n+  oldval = test;\n+  rv = PR_ATOMIC_DECREMENT(&test);\n+  result = result | ((rv == 0) ? 0 : 1);\n+  PR_fprintf(output, \"PR_ATOMIC_DECREMENT(%d) == %d: %s\\n\", oldval, rv,\n+             (rv == 0) ? \"PASSED\" : \"FAILED\");\n+  oldval = test;\n+  rv = PR_ATOMIC_DECREMENT(&test);\n+  result = result | ((rv == -1) ? 0 : 1);\n+  PR_fprintf(output, \"PR_ATOMIC_DECREMENT(%d) == %d: %s\\n\", oldval, rv,\n+             (rv == -1) ? \"PASSED\" : \"FAILED\");\n+\n+  /* set to a different value */\n+  oldval = test = -2;\n+  rv = PR_ATOMIC_SET(&test, 2);\n+  result = result | (((rv == -2) && (test == 2)) ? 0 : 1);\n+  PR_fprintf(output, \"PR_ATOMIC_SET(%d, %d) == %d: %s\\n\", oldval, 2, rv,\n+             ((rv == -2) && (test == 2)) ? \"PASSED\" : \"FAILED\");\n+\n+  /* set to the same value */\n+  oldval = test = -2;\n+  rv = PR_ATOMIC_SET(&test, -2);\n+  result = result | (((rv == -2) && (test == -2)) ? 0 : 1);\n+  PR_fprintf(output, \"PR_ATOMIC_SET(%d, %d) == %d: %s\\n\", oldval, -2, rv,\n+             ((rv == -2) && (test == -2)) ? \"PASSED\" : \"FAILED\");\n+\n+  PR_fprintf(output, \"Atomic operations test %s\\n\",\n+             (result == 0) ? \"PASSED\" : \"FAILED\");\n+  return result;\n } /* main */\n \n /* atomic.c */\ndiff --git a/nspr/pr/tests/attach.c b/nspr/pr/tests/attach.c\nindex 9983b88..fc22f78 100644\n--- a/nspr/pr/tests/attach.c\n+++ b/nspr/pr/tests/attach.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -41,13 +42,13 @@\n #include <stdio.h>\n \n #ifdef WIN32\n-#include <windows.h>\n-#include <process.h>\n+#  include <windows.h>\n+#  include <process.h>\n #elif defined(_PR_PTHREADS)\n-#include <pthread.h>\n-#include \"md/_pth.h\"\n+#  include <pthread.h>\n+#  include \"md/_pth.h\"\n #elif defined(SOLARIS)\n-#include <thread.h>\n+#  include <thread.h>\n #endif\n \n #define DEFAULT_COUNT 1000\n@@ -56,205 +57,197 @@ PRIntn debug_mode;\n \n int count;\n \n-static void\n-AttachDetach(void)\n-{\n-    PRThread* me;\n-    PRInt32 index;\n+static void AttachDetach(void) {\n+  PRThread* me;\n+  PRInt32 index;\n \n-    for (index = 0; index < count; index++) {\n-        me = PR_AttachThread(PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL);\n+  for (index = 0; index < count; index++) {\n+    me = PR_AttachThread(PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL);\n \n-        if (!me) {\n-            fprintf(stderr, \"Error attaching thread %d: PR_AttachThread failed\\n\",\n-                    count);\n-            failed_already = 1;\n-            return;\n-        }\n-        PR_DetachThread();\n+    if (!me) {\n+      fprintf(stderr, \"Error attaching thread %d: PR_AttachThread failed\\n\",\n+              count);\n+      failed_already = 1;\n+      return;\n     }\n+    PR_DetachThread();\n+  }\n }\n \n /************************************************************************/\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow();\n \n-    d = (double)PR_IntervalToMicroseconds(stop - start);\n-    if (debug_mode) {\n-        printf(\"%40s: %6.2f usec\\n\", msg, d / count);\n-    }\n+  d = (double)PR_IntervalToMicroseconds(stop - start);\n+  if (debug_mode) {\n+    printf(\"%40s: %6.2f usec\\n\", msg, d / count);\n+  }\n }\n \n #ifdef WIN32\n-static unsigned __stdcall\n-threadStartFunc(void* arg)\n+static unsigned __stdcall threadStartFunc(void* arg)\n #else\n-static void*\n-threadStartFunc(void* arg)\n+static void* threadStartFunc(void* arg)\n #endif\n {\n-    Measure(AttachDetach, \"Attach/Detach\");\n+  Measure(AttachDetach, \"Attach/Detach\");\n \n-    return 0;\n+  return 0;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n+int main(int argc, char** argv) {\n #ifdef _PR_PTHREADS\n-    int rv;\n-    pthread_t threadID;\n-    pthread_attr_t attr;\n+  int rv;\n+  pthread_t threadID;\n+  pthread_attr_t attr;\n #elif defined(SOLARIS)\n-    int rv;\n-    thread_t threadID;\n+  int rv;\n+  thread_t threadID;\n #elif defined(WIN32)\n-    DWORD rv;\n-    unsigned threadID;\n-    HANDLE hThread;\n+  DWORD rv;\n+  unsigned threadID;\n+  HANDLE hThread;\n #endif\n \n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name [-d] [-c n]\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            case 'c': /* loop count */\n-                count = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name [-d] [-c n]\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    if (0 == count) {\n-        count = DEFAULT_COUNT;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      case 'c': /* loop count */\n+        count = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    /*\n-     * To force the implicit initialization of nspr20\n-     */\n-    PR_SetError(0, 0);\n+  if (0 == count) {\n+    count = DEFAULT_COUNT;\n+  }\n \n-    /*\n-     * Platform-specific code to create a native thread.  The native\n-     * thread will repeatedly call PR_AttachThread and PR_DetachThread.\n-     * The primordial thread waits for this new thread to finish.\n-     */\n+  /*\n+   * To force the implicit initialization of nspr20\n+   */\n+  PR_SetError(0, 0);\n+\n+  /*\n+   * Platform-specific code to create a native thread.  The native\n+   * thread will repeatedly call PR_AttachThread and PR_DetachThread.\n+   * The primordial thread waits for this new thread to finish.\n+   */\n \n #ifdef _PR_PTHREADS\n \n-    rv = _PT_PTHREAD_ATTR_INIT(&attr);\n-    if (debug_mode) {\n-        PR_ASSERT(0 == rv);\n-    } else if (0 != rv) {\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n+  rv = _PT_PTHREAD_ATTR_INIT(&attr);\n+  if (debug_mode) {\n+    PR_ASSERT(0 == rv);\n+  } else if (0 != rv) {\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n \n-    rv = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);\n-    if (debug_mode) {\n-        PR_ASSERT(0 == rv);\n-    } else if (0 != rv) {\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    rv = _PT_PTHREAD_CREATE(&threadID, attr, threadStartFunc, NULL);\n-    if (rv != 0) {\n-        fprintf(stderr, \"thread creation failed: error code %d\\n\", rv);\n-        failed_already = 1;\n-        goto exit_now;\n-    } else {\n-        if (debug_mode) {\n-            printf(\"thread creation succeeded \\n\");\n-        }\n-    }\n-    rv = _PT_PTHREAD_ATTR_DESTROY(&attr);\n-    if (debug_mode) {\n-        PR_ASSERT(0 == rv);\n-    } else if (0 != rv) {\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    rv = pthread_join(threadID, NULL);\n+  rv = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);\n+  if (debug_mode) {\n+    PR_ASSERT(0 == rv);\n+  } else if (0 != rv) {\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  rv = _PT_PTHREAD_CREATE(&threadID, attr, threadStartFunc, NULL);\n+  if (rv != 0) {\n+    fprintf(stderr, \"thread creation failed: error code %d\\n\", rv);\n+    failed_already = 1;\n+    goto exit_now;\n+  } else {\n     if (debug_mode) {\n-        PR_ASSERT(0 == rv);\n-    } else if (0 != rv) {\n-        failed_already = 1;\n-        goto exit_now;\n+      printf(\"thread creation succeeded \\n\");\n     }\n+  }\n+  rv = _PT_PTHREAD_ATTR_DESTROY(&attr);\n+  if (debug_mode) {\n+    PR_ASSERT(0 == rv);\n+  } else if (0 != rv) {\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  rv = pthread_join(threadID, NULL);\n+  if (debug_mode) {\n+    PR_ASSERT(0 == rv);\n+  } else if (0 != rv) {\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n \n #elif defined(SOLARIS)\n \n-    rv = thr_create(NULL, 0, threadStartFunc, NULL, 0, &threadID);\n-    if (rv != 0) {\n-        if (!debug_mode) {\n-            failed_already = 1;\n-            goto exit_now;\n-        } else {\n-            fprintf(stderr, \"thread creation failed: error code %d\\n\", rv);\n-        }\n-    }\n-    rv = thr_join(threadID, NULL, NULL);\n-    if (debug_mode) {\n-        PR_ASSERT(0 == rv);\n-    } else if (0 != rv) {\n-        failed_already = 1;\n-        goto exit_now;\n+  rv = thr_create(NULL, 0, threadStartFunc, NULL, 0, &threadID);\n+  if (rv != 0) {\n+    if (!debug_mode) {\n+      failed_already = 1;\n+      goto exit_now;\n+    } else {\n+      fprintf(stderr, \"thread creation failed: error code %d\\n\", rv);\n     }\n+  }\n+  rv = thr_join(threadID, NULL, NULL);\n+  if (debug_mode) {\n+    PR_ASSERT(0 == rv);\n+  } else if (0 != rv) {\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n \n #elif defined(WIN32)\n \n-    hThread =\n-        (HANDLE)_beginthreadex(NULL, 0, threadStartFunc, NULL,\n-                               STACK_SIZE_PARAM_IS_A_RESERVATION, &threadID);\n-    if (hThread == 0) {\n-        fprintf(stderr, \"thread creation failed: error code %d\\n\", GetLastError());\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    rv = WaitForSingleObject(hThread, INFINITE);\n-    if (debug_mode) {\n-        PR_ASSERT(rv != WAIT_FAILED);\n-    } else if (rv == WAIT_FAILED) {\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n+  hThread =\n+      (HANDLE)_beginthreadex(NULL, 0, threadStartFunc, NULL,\n+                             STACK_SIZE_PARAM_IS_A_RESERVATION, &threadID);\n+  if (hThread == 0) {\n+    fprintf(stderr, \"thread creation failed: error code %d\\n\", GetLastError());\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  rv = WaitForSingleObject(hThread, INFINITE);\n+  if (debug_mode) {\n+    PR_ASSERT(rv != WAIT_FAILED);\n+  } else if (rv == WAIT_FAILED) {\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n \n #else\n-    if (!debug_mode) {\n-        failed_already = 1;\n-    } else\n-        printf(\n-            \"The attach test does not apply to this platform because\\n\"\n-            \"either this platform does not have native threads or the\\n\"\n-            \"test needs to be written for this platform.\\n\");\n-    goto exit_now;\n+  if (!debug_mode) {\n+    failed_already = 1;\n+  } else\n+    printf(\n+        \"The attach test does not apply to this platform because\\n\"\n+        \"either this platform does not have native threads or the\\n\"\n+        \"test needs to be written for this platform.\\n\");\n+  goto exit_now;\n #endif\n \n exit_now:\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/bigfile.c b/nspr/pr/tests/bigfile.c\nindex 3f7b3fd..5d055cc 100644\n--- a/nspr/pr/tests/bigfile.c\n+++ b/nspr/pr/tests/bigfile.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -16,9 +17,7 @@\n #define DEFAULT_FILESIZE 1\n #define BUFFER_SIZE 1000000\n \n-typedef enum { v_silent,\n-               v_whisper,\n-               v_shout } Verbosity;\n+typedef enum { v_silent, v_whisper, v_shout } Verbosity;\n static void Verbose(Verbosity, const char*, const char*, PRIntn);\n \n #define VERBOSE(_l, _m) Verbose(_l, _m, __FILE__, __LINE__)\n@@ -28,321 +27,309 @@ static PRFileDesc* output = NULL;\n static PRIntn verbose = v_silent;\n static PRIntn filesize = DEFAULT_FILESIZE;\n \n-static PRIntn\n-Usage(void)\n-{\n-    PR_fprintf(output, \"Bigfile test usage:\\n\");\n-    PR_fprintf(output, \">bigfile [-G] [-d] [-v[*v]] [-s <n>] <filename>\\n\");\n-    PR_fprintf(output, \"\\td\\tdebug mode (equivalent to -vvv)\\t(false)\\n\");\n-    PR_fprintf(output, \"\\tv\\tAdditional levels of output\\t(none)\\n\");\n-    PR_fprintf(output, \"\\tk\\tKeep data file after exit\\t(false)\\n\");\n-    PR_fprintf(output, \"\\ts <n>\\tFile size in megabytes\\t\\t(1 megabyte)\\n\");\n-    PR_fprintf(output, \"\\t<filename>\\tName of test file\\t(none)\\n\");\n-    return 2; /* nothing happened */\n+static PRIntn Usage(void) {\n+  PR_fprintf(output, \"Bigfile test usage:\\n\");\n+  PR_fprintf(output, \">bigfile [-G] [-d] [-v[*v]] [-s <n>] <filename>\\n\");\n+  PR_fprintf(output, \"\\td\\tdebug mode (equivalent to -vvv)\\t(false)\\n\");\n+  PR_fprintf(output, \"\\tv\\tAdditional levels of output\\t(none)\\n\");\n+  PR_fprintf(output, \"\\tk\\tKeep data file after exit\\t(false)\\n\");\n+  PR_fprintf(output, \"\\ts <n>\\tFile size in megabytes\\t\\t(1 megabyte)\\n\");\n+  PR_fprintf(output, \"\\t<filename>\\tName of test file\\t(none)\\n\");\n+  return 2; /* nothing happened */\n } /* Usage */\n \n-static PRStatus\n-DeleteIfFound(const char* filename)\n-{\n-    PRStatus rv;\n-    VERBOSE(v_shout, \"Checking for existing file\");\n-    rv = PR_Access(filename, PR_ACCESS_WRITE_OK);\n-    if (PR_SUCCESS == rv) {\n-        VERBOSE(v_shout, \"Deleting existing file\");\n-        rv = PR_Delete(filename);\n-        if (PR_FAILURE == rv) {\n-            VERBOSE(v_shout, \"Cannot delete big file\");\n-        }\n-    } else if (PR_FILE_NOT_FOUND_ERROR != PR_GetError()) {\n-        VERBOSE(v_shout, \"Cannot access big file\");\n-    } else {\n-        rv = PR_SUCCESS;\n-    }\n-    return rv;\n+static PRStatus DeleteIfFound(const char* filename) {\n+  PRStatus rv;\n+  VERBOSE(v_shout, \"Checking for existing file\");\n+  rv = PR_Access(filename, PR_ACCESS_WRITE_OK);\n+  if (PR_SUCCESS == rv) {\n+    VERBOSE(v_shout, \"Deleting existing file\");\n+    rv = PR_Delete(filename);\n+    if (PR_FAILURE == rv) {\n+      VERBOSE(v_shout, \"Cannot delete big file\");\n+    }\n+  } else if (PR_FILE_NOT_FOUND_ERROR != PR_GetError()) {\n+    VERBOSE(v_shout, \"Cannot access big file\");\n+  } else {\n+    rv = PR_SUCCESS;\n+  }\n+  return rv;\n } /* DeleteIfFound */\n \n-static PRIntn\n-Error(const char* msg, const char* filename)\n-{\n-    PRInt32 error = PR_GetError();\n-    if (NULL != msg) {\n-        if (0 == error) {\n-            PR_fprintf(output, msg);\n-        } else {\n-            PL_FPrintError(output, msg);\n-        }\n-    }\n-    (void)DeleteIfFound(filename);\n-    if (v_shout == verbose) {\n-        PR_Abort();\n-    }\n-    return 1;\n+static PRIntn Error(const char* msg, const char* filename) {\n+  PRInt32 error = PR_GetError();\n+  if (NULL != msg) {\n+    if (0 == error) {\n+      PR_fprintf(output, msg);\n+    } else {\n+      PL_FPrintError(output, msg);\n+    }\n+  }\n+  (void)DeleteIfFound(filename);\n+  if (v_shout == verbose) {\n+    PR_Abort();\n+  }\n+  return 1;\n } /* Error */\n \n-static void\n-Verbose(Verbosity level, const char* msg, const char* file,\n-        PRIntn line)\n-{\n-    if (level <= verbose) {\n-        PR_fprintf(output, \"[%s : %d]: %s\\n\", file, line, msg);\n-    }\n+static void Verbose(Verbosity level, const char* msg, const char* file,\n+                    PRIntn line) {\n+  if (level <= verbose) {\n+    PR_fprintf(output, \"[%s : %d]: %s\\n\", file, line, msg);\n+  }\n } /* Verbose */\n \n-static void\n-PrintInfo(PRFileInfo64* info, const char* filename)\n-{\n-    PRExplodedTime tm;\n-    char ctime[40], mtime[40];\n-    static const char* types[] = { \"FILE\", \"DIRECTORY\", \"OTHER\" };\n-    PR_fprintf(output, \"[%s : %d]: File info for %s\\n\", __FILE__, __LINE__,\n-               filename);\n-    PR_fprintf(output, \"    type: %s, size: %llu bytes,\\n\", types[info->type - 1],\n-               info->size);\n-\n-    PR_ExplodeTime(info->creationTime, PR_GMTParameters, &tm);\n-    (void)PR_FormatTime(ctime, sizeof(ctime), \"%c GMT\", &tm);\n-    PR_ExplodeTime(info->modifyTime, PR_GMTParameters, &tm);\n-    (void)PR_FormatTime(mtime, sizeof(mtime), \"%c GMT\", &tm);\n-\n-    PR_fprintf(output, \"    creation: %s,\\n    modify: %s\\n\", ctime, mtime);\n+static void PrintInfo(PRFileInfo64* info, const char* filename) {\n+  PRExplodedTime tm;\n+  char ctime[40], mtime[40];\n+  static const char* types[] = {\"FILE\", \"DIRECTORY\", \"OTHER\"};\n+  PR_fprintf(output, \"[%s : %d]: File info for %s\\n\", __FILE__, __LINE__,\n+             filename);\n+  PR_fprintf(output, \"    type: %s, size: %llu bytes,\\n\", types[info->type - 1],\n+             info->size);\n+\n+  PR_ExplodeTime(info->creationTime, PR_GMTParameters, &tm);\n+  (void)PR_FormatTime(ctime, sizeof(ctime), \"%c GMT\", &tm);\n+  PR_ExplodeTime(info->modifyTime, PR_GMTParameters, &tm);\n+  (void)PR_FormatTime(mtime, sizeof(mtime), \"%c GMT\", &tm);\n+\n+  PR_fprintf(output, \"    creation: %s,\\n    modify: %s\\n\", ctime, mtime);\n } /* PrintInfo */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRStatus rv;\n-    char* buffer;\n-    PLOptStatus os;\n-    PRInt32 loop, bytes;\n-    PRFileInfo small_info;\n-    PRFileInfo64 big_info;\n-    PRBool keep = PR_FALSE;\n-    PRFileDesc* file = NULL;\n-    const char* filename = NULL;\n-    PRIntn count = DEFAULT_COUNT;\n-    PRInt64 filesize64, big_answer, big_size, one_meg, zero_meg, big_fragment;\n-    PRInt64 sevenFox = LL_INIT(0, 0x7fffffff);\n-\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dtvhs:\");\n-\n-    output = PR_GetSpecialFD(PR_StandardError);\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 0:\n-                filename = opt->value;\n-                break;\n-            case 'd': /* debug mode */\n-                verbose = v_shout;\n-                break;\n-            case 'k': /* keep file */\n-                keep = PR_TRUE;\n-                break;\n-            case 'v': /* verbosity */\n-                if (v_shout > verbose) {\n-                    verbose += 1;\n-                }\n-                break;\n-            case 'c': /* loop counter */\n-                count = atoi(opt->value);\n-                break;\n-            case 's': /* filesize */\n-                filesize = atoi(opt->value);\n-                break;\n-            case 'h': /* confused */\n-            default:\n-                return Usage();\n+int main(int argc, char** argv) {\n+  PRStatus rv;\n+  char* buffer;\n+  PLOptStatus os;\n+  PRInt32 loop, bytes;\n+  PRFileInfo small_info;\n+  PRFileInfo64 big_info;\n+  PRBool keep = PR_FALSE;\n+  PRFileDesc* file = NULL;\n+  const char* filename = NULL;\n+  PRIntn count = DEFAULT_COUNT;\n+  PRInt64 filesize64, big_answer, big_size, one_meg, zero_meg, big_fragment;\n+  PRInt64 sevenFox = LL_INIT(0, 0x7fffffff);\n+\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dtvhs:\");\n+\n+  output = PR_GetSpecialFD(PR_StandardError);\n+\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 0:\n+        filename = opt->value;\n+        break;\n+      case 'd': /* debug mode */\n+        verbose = v_shout;\n+        break;\n+      case 'k': /* keep file */\n+        keep = PR_TRUE;\n+        break;\n+      case 'v': /* verbosity */\n+        if (v_shout > verbose) {\n+          verbose += 1;\n         }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    if (0 == count) {\n-        count = DEFAULT_COUNT;\n-    }\n-    if (0 == filesize) {\n-        filesize = DEFAULT_FILESIZE;\n-    }\n-    if (NULL == filename) {\n+        break;\n+      case 'c': /* loop counter */\n+        count = atoi(opt->value);\n+        break;\n+      case 's': /* filesize */\n+        filesize = atoi(opt->value);\n+        break;\n+      case 'h': /* confused */\n+      default:\n+        return Usage();\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  if (0 == count) {\n+    count = DEFAULT_COUNT;\n+  }\n+  if (0 == filesize) {\n+    filesize = DEFAULT_FILESIZE;\n+  }\n+  if (NULL == filename) {\n #define FILE_NAME \"bigfile.dat\"\n-        if (DEFAULT_FILESIZE != filesize) {\n-            return Usage();\n-        } else {\n-            filename = FILE_NAME;\n-        }\n-    }\n-\n-    if (PR_FAILURE == DeleteIfFound(filename)) {\n-        return 1;\n-    }\n-\n-    test_result = 0;\n-\n-    LL_I2L(zero_meg, 0);\n-    LL_I2L(one_meg, 1000000);\n-    LL_I2L(filesize64, filesize);\n-    buffer = (char*)PR_MALLOC(BUFFER_SIZE);\n-    LL_I2L(big_fragment, BUFFER_SIZE);\n-    LL_MUL(filesize64, filesize64, one_meg);\n-\n-    for (loop = 0; loop < BUFFER_SIZE; ++loop) {\n-        buffer[loop] = (char)loop;\n-    }\n-\n-    VERBOSE(v_whisper, \"Creating big file\");\n-    file = PR_Open(filename, PR_CREATE_FILE | PR_WRONLY, 0666);\n-    if (NULL == file) {\n-        return Error(\"PR_Open()\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Testing available space in empty file\");\n-    big_answer = file->methods->available64(file);\n-    if (!LL_IS_ZERO(big_answer)) {\n-        return Error(\"empty available64()\", filename);\n-    }\n-\n-    LL_SUB(big_size, filesize64, one_meg);\n-    VERBOSE(v_whisper, \"Creating sparse big file by seeking to end\");\n-    big_answer = file->methods->seek64(file, big_size, PR_SEEK_SET);\n-    if (!LL_EQ(big_answer, big_size)) {\n-        return Error(\"seek\", filename);\n+    if (DEFAULT_FILESIZE != filesize) {\n+      return Usage();\n+    } else {\n+      filename = FILE_NAME;\n     }\n+  }\n \n-    VERBOSE(v_whisper, \"Writing block at end of sparse file\");\n+  if (PR_FAILURE == DeleteIfFound(filename)) {\n+    return 1;\n+  }\n+\n+  test_result = 0;\n+\n+  LL_I2L(zero_meg, 0);\n+  LL_I2L(one_meg, 1000000);\n+  LL_I2L(filesize64, filesize);\n+  buffer = (char*)PR_MALLOC(BUFFER_SIZE);\n+  LL_I2L(big_fragment, BUFFER_SIZE);\n+  LL_MUL(filesize64, filesize64, one_meg);\n+\n+  for (loop = 0; loop < BUFFER_SIZE; ++loop) {\n+    buffer[loop] = (char)loop;\n+  }\n+\n+  VERBOSE(v_whisper, \"Creating big file\");\n+  file = PR_Open(filename, PR_CREATE_FILE | PR_WRONLY, 0666);\n+  if (NULL == file) {\n+    return Error(\"PR_Open()\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Testing available space in empty file\");\n+  big_answer = file->methods->available64(file);\n+  if (!LL_IS_ZERO(big_answer)) {\n+    return Error(\"empty available64()\", filename);\n+  }\n+\n+  LL_SUB(big_size, filesize64, one_meg);\n+  VERBOSE(v_whisper, \"Creating sparse big file by seeking to end\");\n+  big_answer = file->methods->seek64(file, big_size, PR_SEEK_SET);\n+  if (!LL_EQ(big_answer, big_size)) {\n+    return Error(\"seek\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Writing block at end of sparse file\");\n+  bytes = file->methods->write(file, buffer, BUFFER_SIZE);\n+  if (bytes != BUFFER_SIZE) {\n+    return Error(\"write\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Testing available space at end of sparse file\");\n+  big_answer = file->methods->available64(file);\n+  if (!LL_IS_ZERO(big_answer)) {\n+    return Error(\"eof available64()\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Getting big info on sparse big file\");\n+  rv = file->methods->fileInfo64(file, &big_info);\n+  if (PR_FAILURE == rv) {\n+    return Error(\"fileInfo64()\", filename);\n+  }\n+  if (v_shout <= verbose) {\n+    PrintInfo(&big_info, filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Getting small info on sparse big file\");\n+  rv = file->methods->fileInfo(file, &small_info);\n+  if (LL_CMP(sevenFox, <, filesize64) && (PR_SUCCESS == rv)) {\n+    VERBOSE(v_whisper, \"Should have failed and didn't\");\n+    return Error(\"fileInfo()\", filename);\n+  } else if (LL_CMP(sevenFox, >, filesize64) && (PR_FAILURE == rv)) {\n+    VERBOSE(v_whisper, \"Should have succeeded and didn't\");\n+    return Error(\"fileInfo()\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Rewinding big file\");\n+  big_answer = file->methods->seek64(file, zero_meg, PR_SEEK_SET);\n+  if (!LL_IS_ZERO(big_answer)) {\n+    return Error(\"rewind seek64()\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Establishing available space in rewound file\");\n+  big_answer = file->methods->available64(file);\n+  if (LL_NE(filesize64, big_answer)) {\n+    return Error(\"bof available64()\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Closing big file\");\n+  rv = file->methods->close(file);\n+  if (PR_FAILURE == rv) {\n+    return Error(\"close()\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Reopening big file\");\n+  file = PR_Open(filename, PR_RDWR, 0666);\n+  if (NULL == file) {\n+    return Error(\"open failed\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Checking available data in reopened file\");\n+  big_answer = file->methods->available64(file);\n+  if (LL_NE(filesize64, big_answer)) {\n+    return Error(\"reopened available64()\", filename);\n+  }\n+\n+  big_answer = zero_meg;\n+  VERBOSE(v_whisper, \"Rewriting every byte of big file data\");\n+  do {\n     bytes = file->methods->write(file, buffer, BUFFER_SIZE);\n     if (bytes != BUFFER_SIZE) {\n-        return Error(\"write\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Testing available space at end of sparse file\");\n-    big_answer = file->methods->available64(file);\n-    if (!LL_IS_ZERO(big_answer)) {\n-        return Error(\"eof available64()\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Getting big info on sparse big file\");\n-    rv = file->methods->fileInfo64(file, &big_info);\n-    if (PR_FAILURE == rv) {\n-        return Error(\"fileInfo64()\", filename);\n-    }\n-    if (v_shout <= verbose) {\n-        PrintInfo(&big_info, filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Getting small info on sparse big file\");\n-    rv = file->methods->fileInfo(file, &small_info);\n-    if (LL_CMP(sevenFox, <, filesize64) && (PR_SUCCESS == rv)) {\n-        VERBOSE(v_whisper, \"Should have failed and didn't\");\n-        return Error(\"fileInfo()\", filename);\n-    } else if (LL_CMP(sevenFox, >, filesize64) && (PR_FAILURE == rv)) {\n-        VERBOSE(v_whisper, \"Should have succeeded and didn't\");\n-        return Error(\"fileInfo()\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Rewinding big file\");\n-    big_answer = file->methods->seek64(file, zero_meg, PR_SEEK_SET);\n-    if (!LL_IS_ZERO(big_answer)) {\n-        return Error(\"rewind seek64()\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Establishing available space in rewound file\");\n-    big_answer = file->methods->available64(file);\n-    if (LL_NE(filesize64, big_answer)) {\n-        return Error(\"bof available64()\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Closing big file\");\n-    rv = file->methods->close(file);\n-    if (PR_FAILURE == rv) {\n-        return Error(\"close()\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Reopening big file\");\n-    file = PR_Open(filename, PR_RDWR, 0666);\n-    if (NULL == file) {\n-        return Error(\"open failed\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Checking available data in reopened file\");\n-    big_answer = file->methods->available64(file);\n-    if (LL_NE(filesize64, big_answer)) {\n-        return Error(\"reopened available64()\", filename);\n-    }\n-\n-    big_answer = zero_meg;\n-    VERBOSE(v_whisper, \"Rewriting every byte of big file data\");\n-    do {\n-        bytes = file->methods->write(file, buffer, BUFFER_SIZE);\n-        if (bytes != BUFFER_SIZE) {\n-            return Error(\"write\", filename);\n-        }\n-        LL_ADD(big_answer, big_answer, big_fragment);\n-    } while (LL_CMP(big_answer, <, filesize64));\n-\n-    VERBOSE(v_whisper, \"Checking position at eof\");\n-    big_answer = file->methods->seek64(file, zero_meg, PR_SEEK_CUR);\n-    if (LL_NE(big_answer, filesize64)) {\n-        return Error(\"file size error\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Testing available space at eof\");\n-    big_answer = file->methods->available64(file);\n-    if (!LL_IS_ZERO(big_answer)) {\n-        return Error(\"eof available64()\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Rewinding full file\");\n-    big_answer = file->methods->seek64(file, zero_meg, PR_SEEK_SET);\n-    if (!LL_IS_ZERO(big_answer)) {\n-        return Error(\"bof seek64()\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Testing available space in rewound file\");\n-    big_answer = file->methods->available64(file);\n-    if (LL_NE(big_answer, filesize64)) {\n-        return Error(\"bof available64()\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Seeking to end of big file\");\n-    big_answer = file->methods->seek64(file, filesize64, PR_SEEK_SET);\n-    if (LL_NE(big_answer, filesize64)) {\n-        return Error(\"eof seek64()\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Getting info on big file while it's open\");\n-    rv = file->methods->fileInfo64(file, &big_info);\n-    if (PR_FAILURE == rv) {\n-        return Error(\"fileInfo64()\", filename);\n-    }\n-    if (v_shout <= verbose) {\n-        PrintInfo(&big_info, filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Closing big file\");\n-    rv = file->methods->close(file);\n-    if (PR_FAILURE == rv) {\n-        return Error(\"close()\", filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Getting info on big file after it's closed\");\n-    rv = PR_GetFileInfo64(filename, &big_info);\n-    if (PR_FAILURE == rv) {\n-        return Error(\"fileInfo64()\", filename);\n-    }\n-    if (v_shout <= verbose) {\n-        PrintInfo(&big_info, filename);\n-    }\n-\n-    VERBOSE(v_whisper, \"Deleting big file\");\n-    rv = PR_Delete(filename);\n-    if (PR_FAILURE == rv) {\n-        return Error(\"PR_Delete()\", filename);\n-    }\n-\n-    PR_DELETE(buffer);\n-    return test_result;\n+      return Error(\"write\", filename);\n+    }\n+    LL_ADD(big_answer, big_answer, big_fragment);\n+  } while (LL_CMP(big_answer, <, filesize64));\n+\n+  VERBOSE(v_whisper, \"Checking position at eof\");\n+  big_answer = file->methods->seek64(file, zero_meg, PR_SEEK_CUR);\n+  if (LL_NE(big_answer, filesize64)) {\n+    return Error(\"file size error\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Testing available space at eof\");\n+  big_answer = file->methods->available64(file);\n+  if (!LL_IS_ZERO(big_answer)) {\n+    return Error(\"eof available64()\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Rewinding full file\");\n+  big_answer = file->methods->seek64(file, zero_meg, PR_SEEK_SET);\n+  if (!LL_IS_ZERO(big_answer)) {\n+    return Error(\"bof seek64()\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Testing available space in rewound file\");\n+  big_answer = file->methods->available64(file);\n+  if (LL_NE(big_answer, filesize64)) {\n+    return Error(\"bof available64()\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Seeking to end of big file\");\n+  big_answer = file->methods->seek64(file, filesize64, PR_SEEK_SET);\n+  if (LL_NE(big_answer, filesize64)) {\n+    return Error(\"eof seek64()\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Getting info on big file while it's open\");\n+  rv = file->methods->fileInfo64(file, &big_info);\n+  if (PR_FAILURE == rv) {\n+    return Error(\"fileInfo64()\", filename);\n+  }\n+  if (v_shout <= verbose) {\n+    PrintInfo(&big_info, filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Closing big file\");\n+  rv = file->methods->close(file);\n+  if (PR_FAILURE == rv) {\n+    return Error(\"close()\", filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Getting info on big file after it's closed\");\n+  rv = PR_GetFileInfo64(filename, &big_info);\n+  if (PR_FAILURE == rv) {\n+    return Error(\"fileInfo64()\", filename);\n+  }\n+  if (v_shout <= verbose) {\n+    PrintInfo(&big_info, filename);\n+  }\n+\n+  VERBOSE(v_whisper, \"Deleting big file\");\n+  rv = PR_Delete(filename);\n+  if (PR_FAILURE == rv) {\n+    return Error(\"PR_Delete()\", filename);\n+  }\n+\n+  PR_DELETE(buffer);\n+  return test_result;\n } /* main */\n \n /* bigfile.c */\ndiff --git a/nspr/pr/tests/bigfile2.c b/nspr/pr/tests/bigfile2.c\nindex b1b8157..43bcd55 100644\n--- a/nspr/pr/tests/bigfile2.c\n+++ b/nspr/pr/tests/bigfile2.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,92 +9,90 @@\n #include <stdlib.h>\n #include <string.h>\n #ifdef _WIN32\n-#include <windows.h>\n+#  include <windows.h>\n #endif\n \n #define TEST_FILE_NAME \"bigfile2.txt\"\n #ifdef WINCE\n-#define TEST_FILE_NAME_FOR_CREATEFILE L\"bigfile2.txt\"\n+#  define TEST_FILE_NAME_FOR_CREATEFILE L\"bigfile2.txt\"\n #else\n-#define TEST_FILE_NAME_FOR_CREATEFILE TEST_FILE_NAME\n+#  define TEST_FILE_NAME_FOR_CREATEFILE TEST_FILE_NAME\n #endif\n \n #define MESSAGE \"Hello world!\"\n #define MESSAGE_SIZE 13\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc* fd;\n-    PRInt64 offset, position;\n-    PRInt32 nbytes;\n-    char buf[MESSAGE_SIZE];\n+int main(int argc, char** argv) {\n+  PRFileDesc* fd;\n+  PRInt64 offset, position;\n+  PRInt32 nbytes;\n+  char buf[MESSAGE_SIZE];\n #ifdef _WIN32\n-    HANDLE hFile;\n-    LARGE_INTEGER li;\n+  HANDLE hFile;\n+  LARGE_INTEGER li;\n #endif /* _WIN32 */\n \n-    LL_I2L(offset, 1);\n-    LL_SHL(offset, offset, 32);\n+  LL_I2L(offset, 1);\n+  LL_SHL(offset, offset, 32);\n \n-    fd = PR_Open(TEST_FILE_NAME, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 0666);\n-    if (fd == NULL) {\n-        fprintf(stderr, \"PR_Open failed\\n\");\n-        exit(1);\n-    }\n-    position = PR_Seek64(fd, offset, PR_SEEK_SET);\n-    if (!LL_GE_ZERO(position)) {\n-        fprintf(stderr, \"PR_Seek64 failed\\n\");\n-        exit(1);\n-    }\n-    PR_ASSERT(LL_EQ(position, offset));\n-    strcpy(buf, MESSAGE);\n-    nbytes = PR_Write(fd, buf, sizeof(buf));\n-    if (nbytes != sizeof(buf)) {\n-        fprintf(stderr, \"PR_Write failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Close(fd) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n+  fd = PR_Open(TEST_FILE_NAME, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 0666);\n+  if (fd == NULL) {\n+    fprintf(stderr, \"PR_Open failed\\n\");\n+    exit(1);\n+  }\n+  position = PR_Seek64(fd, offset, PR_SEEK_SET);\n+  if (!LL_GE_ZERO(position)) {\n+    fprintf(stderr, \"PR_Seek64 failed\\n\");\n+    exit(1);\n+  }\n+  PR_ASSERT(LL_EQ(position, offset));\n+  strcpy(buf, MESSAGE);\n+  nbytes = PR_Write(fd, buf, sizeof(buf));\n+  if (nbytes != sizeof(buf)) {\n+    fprintf(stderr, \"PR_Write failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Close(fd) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n \n-    memset(buf, 0, sizeof(buf));\n+  memset(buf, 0, sizeof(buf));\n \n #ifdef _WIN32\n-    hFile = CreateFile(TEST_FILE_NAME_FOR_CREATEFILE, GENERIC_READ, 0, NULL,\n-                       OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);\n-    if (hFile == INVALID_HANDLE_VALUE) {\n-        fprintf(stderr, \"CreateFile failed\\n\");\n-        exit(1);\n-    }\n-    li.QuadPart = offset;\n-    li.LowPart = SetFilePointer(hFile, li.LowPart, &li.HighPart, FILE_BEGIN);\n-    if (li.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR) {\n-        fprintf(stderr, \"SetFilePointer failed\\n\");\n-        exit(1);\n-    }\n-    PR_ASSERT(li.QuadPart == offset);\n-    if (ReadFile(hFile, buf, sizeof(buf), &nbytes, NULL) == 0) {\n-        fprintf(stderr, \"ReadFile failed\\n\");\n-        exit(1);\n-    }\n-    PR_ASSERT(nbytes == sizeof(buf));\n-    if (strcmp(buf, MESSAGE)) {\n-        fprintf(stderr, \"corrupt data:$%s$\\n\", buf);\n-        exit(1);\n-    }\n-    if (CloseHandle(hFile) == 0) {\n-        fprintf(stderr, \"CloseHandle failed\\n\");\n-        exit(1);\n-    }\n+  hFile = CreateFile(TEST_FILE_NAME_FOR_CREATEFILE, GENERIC_READ, 0, NULL,\n+                     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);\n+  if (hFile == INVALID_HANDLE_VALUE) {\n+    fprintf(stderr, \"CreateFile failed\\n\");\n+    exit(1);\n+  }\n+  li.QuadPart = offset;\n+  li.LowPart = SetFilePointer(hFile, li.LowPart, &li.HighPart, FILE_BEGIN);\n+  if (li.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR) {\n+    fprintf(stderr, \"SetFilePointer failed\\n\");\n+    exit(1);\n+  }\n+  PR_ASSERT(li.QuadPart == offset);\n+  if (ReadFile(hFile, buf, sizeof(buf), &nbytes, NULL) == 0) {\n+    fprintf(stderr, \"ReadFile failed\\n\");\n+    exit(1);\n+  }\n+  PR_ASSERT(nbytes == sizeof(buf));\n+  if (strcmp(buf, MESSAGE)) {\n+    fprintf(stderr, \"corrupt data:$%s$\\n\", buf);\n+    exit(1);\n+  }\n+  if (CloseHandle(hFile) == 0) {\n+    fprintf(stderr, \"CloseHandle failed\\n\");\n+    exit(1);\n+  }\n #endif /* _WIN32 */\n \n-    if (PR_Delete(TEST_FILE_NAME) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Delete failed\\n\");\n-        exit(1);\n-    }\n+  if (PR_Delete(TEST_FILE_NAME) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Delete failed\\n\");\n+    exit(1);\n+  }\n \n-    printf(\"PASS\\n\");\n-    return 0;\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/bigfile3.c b/nspr/pr/tests/bigfile3.c\nindex 56c8c74..2bd1e03 100644\n--- a/nspr/pr/tests/bigfile3.c\n+++ b/nspr/pr/tests/bigfile3.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,92 +9,90 @@\n #include <stdlib.h>\n #include <string.h>\n #ifdef _WIN32\n-#include <windows.h>\n+#  include <windows.h>\n #endif\n \n #define TEST_FILE_NAME \"bigfile3.txt\"\n #ifdef WINCE\n-#define TEST_FILE_NAME_FOR_CREATEFILE L\"bigfile3.txt\"\n+#  define TEST_FILE_NAME_FOR_CREATEFILE L\"bigfile3.txt\"\n #else\n-#define TEST_FILE_NAME_FOR_CREATEFILE TEST_FILE_NAME\n+#  define TEST_FILE_NAME_FOR_CREATEFILE TEST_FILE_NAME\n #endif\n \n #define MESSAGE \"Hello world!\"\n #define MESSAGE_SIZE 13\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc* fd;\n-    PRInt64 offset, position;\n-    PRInt32 nbytes;\n-    char buf[MESSAGE_SIZE];\n+int main(int argc, char** argv) {\n+  PRFileDesc* fd;\n+  PRInt64 offset, position;\n+  PRInt32 nbytes;\n+  char buf[MESSAGE_SIZE];\n #ifdef _WIN32\n-    HANDLE hFile;\n-    LARGE_INTEGER li;\n+  HANDLE hFile;\n+  LARGE_INTEGER li;\n #endif /* _WIN32 */\n \n-    LL_I2L(offset, 1);\n-    LL_SHL(offset, offset, 32);\n+  LL_I2L(offset, 1);\n+  LL_SHL(offset, offset, 32);\n \n #ifdef _WIN32\n-    hFile = CreateFile(TEST_FILE_NAME_FOR_CREATEFILE, GENERIC_WRITE, 0, NULL,\n-                       CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);\n-    if (hFile == INVALID_HANDLE_VALUE) {\n-        fprintf(stderr, \"CreateFile failed\\n\");\n-        exit(1);\n-    }\n-    li.QuadPart = offset;\n-    li.LowPart = SetFilePointer(hFile, li.LowPart, &li.HighPart, FILE_BEGIN);\n-    if (li.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR) {\n-        fprintf(stderr, \"SetFilePointer failed\\n\");\n-        exit(1);\n-    }\n-    PR_ASSERT(li.QuadPart == offset);\n-    strcpy(buf, MESSAGE);\n-    if (WriteFile(hFile, buf, sizeof(buf), &nbytes, NULL) == 0) {\n-        fprintf(stderr, \"WriteFile failed\\n\");\n-        exit(1);\n-    }\n-    PR_ASSERT(nbytes == sizeof(buf));\n-    if (CloseHandle(hFile) == 0) {\n-        fprintf(stderr, \"CloseHandle failed\\n\");\n-        exit(1);\n-    }\n+  hFile = CreateFile(TEST_FILE_NAME_FOR_CREATEFILE, GENERIC_WRITE, 0, NULL,\n+                     CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);\n+  if (hFile == INVALID_HANDLE_VALUE) {\n+    fprintf(stderr, \"CreateFile failed\\n\");\n+    exit(1);\n+  }\n+  li.QuadPart = offset;\n+  li.LowPart = SetFilePointer(hFile, li.LowPart, &li.HighPart, FILE_BEGIN);\n+  if (li.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR) {\n+    fprintf(stderr, \"SetFilePointer failed\\n\");\n+    exit(1);\n+  }\n+  PR_ASSERT(li.QuadPart == offset);\n+  strcpy(buf, MESSAGE);\n+  if (WriteFile(hFile, buf, sizeof(buf), &nbytes, NULL) == 0) {\n+    fprintf(stderr, \"WriteFile failed\\n\");\n+    exit(1);\n+  }\n+  PR_ASSERT(nbytes == sizeof(buf));\n+  if (CloseHandle(hFile) == 0) {\n+    fprintf(stderr, \"CloseHandle failed\\n\");\n+    exit(1);\n+  }\n #endif /* _WIN32 */\n \n-    memset(buf, 0, sizeof(buf));\n+  memset(buf, 0, sizeof(buf));\n \n-    fd = PR_Open(TEST_FILE_NAME, PR_RDONLY, 0666);\n-    if (fd == NULL) {\n-        fprintf(stderr, \"PR_Open failed\\n\");\n-        exit(1);\n-    }\n-    position = PR_Seek64(fd, offset, PR_SEEK_SET);\n-    if (!LL_GE_ZERO(position)) {\n-        fprintf(stderr, \"PR_Seek64 failed\\n\");\n-        exit(1);\n-    }\n-    PR_ASSERT(LL_EQ(position, offset));\n-    nbytes = PR_Read(fd, buf, sizeof(buf));\n-    if (nbytes != sizeof(buf)) {\n-        fprintf(stderr, \"PR_Read failed\\n\");\n-        exit(1);\n-    }\n-    if (strcmp(buf, MESSAGE)) {\n-        fprintf(stderr, \"corrupt data:$%s$\\n\", buf);\n-        exit(1);\n-    }\n-    if (PR_Close(fd) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n+  fd = PR_Open(TEST_FILE_NAME, PR_RDONLY, 0666);\n+  if (fd == NULL) {\n+    fprintf(stderr, \"PR_Open failed\\n\");\n+    exit(1);\n+  }\n+  position = PR_Seek64(fd, offset, PR_SEEK_SET);\n+  if (!LL_GE_ZERO(position)) {\n+    fprintf(stderr, \"PR_Seek64 failed\\n\");\n+    exit(1);\n+  }\n+  PR_ASSERT(LL_EQ(position, offset));\n+  nbytes = PR_Read(fd, buf, sizeof(buf));\n+  if (nbytes != sizeof(buf)) {\n+    fprintf(stderr, \"PR_Read failed\\n\");\n+    exit(1);\n+  }\n+  if (strcmp(buf, MESSAGE)) {\n+    fprintf(stderr, \"corrupt data:$%s$\\n\", buf);\n+    exit(1);\n+  }\n+  if (PR_Close(fd) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n \n-    if (PR_Delete(TEST_FILE_NAME) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Delete failed\\n\");\n-        exit(1);\n-    }\n+  if (PR_Delete(TEST_FILE_NAME) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Delete failed\\n\");\n+    exit(1);\n+  }\n \n-    printf(\"PASS\\n\");\n-    return 0;\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/bug1test.c b/nspr/pr/tests/bug1test.c\nindex 94622ef..d8188a4 100644\n--- a/nspr/pr/tests/bug1test.c\n+++ b/nspr/pr/tests/bug1test.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -15,213 +16,199 @@ before leaving the critical section in _PR_CondWait in hwmon.c).\n #include \"prlog.h\"\n \n typedef struct Arg_s {\n-    PRInt32 a, b;\n+  PRInt32 a, b;\n } Arg_t;\n \n-PRMonitor* gMonitor;   // the monitor\n-PRInt32 gReading;      // number of read locks\n-PRInt32 gWriteWaiting; // number of threads waiting for write lock\n-PRInt32 gReadWaiting;  // number of threads waiting for read lock\n+PRMonitor* gMonitor;    // the monitor\n+PRInt32 gReading;       // number of read locks\n+PRInt32 gWriteWaiting;  // number of threads waiting for write lock\n+PRInt32 gReadWaiting;   // number of threads waiting for read lock\n \n-PRInt32 gCounter; // a counter\n+PRInt32 gCounter;  // a counter\n \n // stats\n-PRInt32 gReads;         // number of successful reads\n-PRInt32 gMaxReads;      // max number of simultaneous reads\n-PRInt32 gMaxWriteWaits; // max number of writes that waited for read\n-PRInt32 gMaxReadWaits;  // max number of reads that waited for write wait\n-\n-void\n-spin(PRInt32 aDelay)\n-{\n-    PRInt32 index;\n-    PRInt32 delay = aDelay * 1000;\n-\n-    PR_Sleep(0);\n-\n-    // randomize delay a bit\n-    delay =\n-        (delay / 2) + (PRInt32)((float)delay * ((float)rand() / (float)RAND_MAX));\n-\n-    for (index = 0; index < delay * 10; index++)\n-        // consume a bunch of cpu cycles\n-        ;\n-    PR_Sleep(0);\n+PRInt32 gReads;          // number of successful reads\n+PRInt32 gMaxReads;       // max number of simultaneous reads\n+PRInt32 gMaxWriteWaits;  // max number of writes that waited for read\n+PRInt32 gMaxReadWaits;   // max number of reads that waited for write wait\n+\n+void spin(PRInt32 aDelay) {\n+  PRInt32 index;\n+  PRInt32 delay = aDelay * 1000;\n+\n+  PR_Sleep(0);\n+\n+  // randomize delay a bit\n+  delay =\n+      (delay / 2) + (PRInt32)((float)delay * ((float)rand() / (float)RAND_MAX));\n+\n+  for (index = 0; index < delay * 10; index++)\n+    // consume a bunch of cpu cycles\n+    ;\n+  PR_Sleep(0);\n }\n \n-void\n-doWriteThread(void* arg)\n-{\n-    PRInt32 last;\n-    Arg_t* args = (Arg_t*)arg;\n-    PRInt32 aWorkDelay = args->a, aWaitDelay = args->b;\n-    PR_Sleep(0);\n-\n-    while (1) {\n-        // -- enter write lock\n-        PR_EnterMonitor(gMonitor);\n-\n-        if (0 < gReading) // wait for read locks to go away\n-        {\n-            PRIntervalTime fiveSecs = PR_SecondsToInterval(5);\n-\n-            gWriteWaiting++;\n-            if (gWriteWaiting > gMaxWriteWaits) { // stats\n-                gMaxWriteWaits = gWriteWaiting;\n-            }\n-            while (0 < gReading) {\n-                PR_Wait(gMonitor, fiveSecs);\n-            }\n-            gWriteWaiting--;\n-        }\n-        // -- write lock entered\n-\n-        last = gCounter;\n-        gCounter++;\n-\n-        spin(aWorkDelay);\n-\n-        PR_ASSERT(gCounter == (last + 1)); // test invariance\n-\n-        // -- exit write lock\n-        //    if (0 < gReadWaiting)   // notify waiting reads (do it anyway to show\n-        //    off the CondWait bug)\n-        PR_NotifyAll(gMonitor);\n-\n-        PR_ExitMonitor(gMonitor);\n-        // -- write lock exited\n-\n-        spin(aWaitDelay);\n+void doWriteThread(void* arg) {\n+  PRInt32 last;\n+  Arg_t* args = (Arg_t*)arg;\n+  PRInt32 aWorkDelay = args->a, aWaitDelay = args->b;\n+  PR_Sleep(0);\n+\n+  while (1) {\n+    // -- enter write lock\n+    PR_EnterMonitor(gMonitor);\n+\n+    if (0 < gReading)  // wait for read locks to go away\n+    {\n+      PRIntervalTime fiveSecs = PR_SecondsToInterval(5);\n+\n+      gWriteWaiting++;\n+      if (gWriteWaiting > gMaxWriteWaits) {  // stats\n+        gMaxWriteWaits = gWriteWaiting;\n+      }\n+      while (0 < gReading) {\n+        PR_Wait(gMonitor, fiveSecs);\n+      }\n+      gWriteWaiting--;\n     }\n-}\n+    // -- write lock entered\n \n-void\n-doReadThread(void* arg)\n-{\n-    PRInt32 last;\n-    Arg_t* args = (Arg_t*)arg;\n-    PRInt32 aWorkDelay = args->a, aWaitDelay = args->b;\n-    PR_Sleep(0);\n+    last = gCounter;\n+    gCounter++;\n \n-    while (1) {\n-        // -- enter read lock\n-        PR_EnterMonitor(gMonitor);\n+    spin(aWorkDelay);\n \n-        if (0 < gWriteWaiting) // give up the monitor to waiting writes\n-        {\n-            PRIntervalTime fiveSecs = PR_SecondsToInterval(5);\n+    PR_ASSERT(gCounter == (last + 1));  // test invariance\n \n-            gReadWaiting++;\n-            if (gReadWaiting > gMaxReadWaits) { // stats\n-                gMaxReadWaits = gReadWaiting;\n-            }\n-            while (0 < gWriteWaiting) {\n-                PR_Wait(gMonitor, fiveSecs);\n-            }\n-            gReadWaiting--;\n-        }\n+    // -- exit write lock\n+    //    if (0 < gReadWaiting)   // notify waiting reads (do it anyway to show\n+    //    off the CondWait bug)\n+    PR_NotifyAll(gMonitor);\n \n-        gReading++;\n+    PR_ExitMonitor(gMonitor);\n+    // -- write lock exited\n \n-        gReads++;                   // stats\n-        if (gReading > gMaxReads) { // stats\n-            gMaxReads = gReading;\n-        }\n+    spin(aWaitDelay);\n+  }\n+}\n \n-        PR_ExitMonitor(gMonitor);\n-        // -- read lock entered\n+void doReadThread(void* arg) {\n+  PRInt32 last;\n+  Arg_t* args = (Arg_t*)arg;\n+  PRInt32 aWorkDelay = args->a, aWaitDelay = args->b;\n+  PR_Sleep(0);\n+\n+  while (1) {\n+    // -- enter read lock\n+    PR_EnterMonitor(gMonitor);\n+\n+    if (0 < gWriteWaiting)  // give up the monitor to waiting writes\n+    {\n+      PRIntervalTime fiveSecs = PR_SecondsToInterval(5);\n+\n+      gReadWaiting++;\n+      if (gReadWaiting > gMaxReadWaits) {  // stats\n+        gMaxReadWaits = gReadWaiting;\n+      }\n+      while (0 < gWriteWaiting) {\n+        PR_Wait(gMonitor, fiveSecs);\n+      }\n+      gReadWaiting--;\n+    }\n \n-        last = gCounter;\n+    gReading++;\n \n-        spin(aWorkDelay);\n+    gReads++;                    // stats\n+    if (gReading > gMaxReads) {  // stats\n+      gMaxReads = gReading;\n+    }\n \n-        PR_ASSERT(gCounter == last); // test invariance\n+    PR_ExitMonitor(gMonitor);\n+    // -- read lock entered\n \n-        // -- exit read lock\n-        PR_EnterMonitor(gMonitor); // read unlock\n-        gReading--;\n+    last = gCounter;\n \n-        //    if ((0 == gReading) && (0 < gWriteWaiting))  // notify waiting writes\n-        //    (do it anyway to show off the CondWait bug)\n-        PR_NotifyAll(gMonitor);\n-        PR_ExitMonitor(gMonitor);\n-        // -- read lock exited\n+    spin(aWorkDelay);\n \n-        spin(aWaitDelay);\n-    }\n+    PR_ASSERT(gCounter == last);  // test invariance\n+\n+    // -- exit read lock\n+    PR_EnterMonitor(gMonitor);  // read unlock\n+    gReading--;\n+\n+    //    if ((0 == gReading) && (0 < gWriteWaiting))  // notify waiting writes\n+    //    (do it anyway to show off the CondWait bug)\n+    PR_NotifyAll(gMonitor);\n+    PR_ExitMonitor(gMonitor);\n+    // -- read lock exited\n+\n+    spin(aWaitDelay);\n+  }\n }\n \n-void\n-fireThread(char* aName, void (*aProc)(void* arg), Arg_t* aArg)\n-{\n-    PRThread* thread =\n-        PR_CreateThread(PR_USER_THREAD, aProc, aArg, PR_PRIORITY_NORMAL,\n-                        PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+void fireThread(char* aName, void (*aProc)(void* arg), Arg_t* aArg) {\n+  PRThread* thread =\n+      PR_CreateThread(PR_USER_THREAD, aProc, aArg, PR_PRIORITY_NORMAL,\n+                      PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n }\n \n-int\n-pseudoMain(int argc, char** argv, char* pad)\n-{\n-    PRInt32 lastWriteCount = gCounter;\n-    PRInt32 lastReadCount = gReads;\n-    Arg_t a1 = { 500, 250 };\n-    Arg_t a2 = { 500, 500 };\n-    Arg_t a3 = { 250, 500 };\n-    Arg_t a4 = { 750, 250 };\n-    Arg_t a5 = { 100, 750 };\n-    Arg_t a6 = { 100, 500 };\n-    Arg_t a7 = { 100, 750 };\n-\n-    gMonitor = PR_NewMonitor();\n-\n-    fireThread(\"R1\", doReadThread, &a1);\n-    fireThread(\"R2\", doReadThread, &a2);\n-    fireThread(\"R3\", doReadThread, &a3);\n-    fireThread(\"R4\", doReadThread, &a4);\n-\n-    fireThread(\"W1\", doWriteThread, &a5);\n-    fireThread(\"W2\", doWriteThread, &a6);\n-    fireThread(\"W3\", doWriteThread, &a7);\n-\n-    fireThread(\"R5\", doReadThread, &a1);\n-    fireThread(\"R6\", doReadThread, &a2);\n-    fireThread(\"R7\", doReadThread, &a3);\n-    fireThread(\"R8\", doReadThread, &a4);\n-\n-    fireThread(\"W4\", doWriteThread, &a5);\n-    fireThread(\"W5\", doWriteThread, &a6);\n-    fireThread(\"W6\", doWriteThread, &a7);\n-\n-    while (1) {\n-        PRInt32 writeCount, readCount;\n-        PRIntervalTime fiveSecs = PR_SecondsToInterval(5);\n-        PR_Sleep(fiveSecs); // get out of the way\n-\n-        // print some stats, not threadsafe, informative only\n-        writeCount = gCounter;\n-        readCount = gReads;\n-        printf(\"\\ntick %d writes (+%d), %d reads (+%d) [max %d, %d, %d]\",\n-               writeCount, writeCount - lastWriteCount, readCount,\n-               readCount - lastReadCount, gMaxReads, gMaxWriteWaits, gMaxReadWaits);\n-        lastWriteCount = writeCount;\n-        lastReadCount = readCount;\n-        gMaxReads = gMaxWriteWaits = gMaxReadWaits = 0;\n-    }\n-    return 0;\n+int pseudoMain(int argc, char** argv, char* pad) {\n+  PRInt32 lastWriteCount = gCounter;\n+  PRInt32 lastReadCount = gReads;\n+  Arg_t a1 = {500, 250};\n+  Arg_t a2 = {500, 500};\n+  Arg_t a3 = {250, 500};\n+  Arg_t a4 = {750, 250};\n+  Arg_t a5 = {100, 750};\n+  Arg_t a6 = {100, 500};\n+  Arg_t a7 = {100, 750};\n+\n+  gMonitor = PR_NewMonitor();\n+\n+  fireThread(\"R1\", doReadThread, &a1);\n+  fireThread(\"R2\", doReadThread, &a2);\n+  fireThread(\"R3\", doReadThread, &a3);\n+  fireThread(\"R4\", doReadThread, &a4);\n+\n+  fireThread(\"W1\", doWriteThread, &a5);\n+  fireThread(\"W2\", doWriteThread, &a6);\n+  fireThread(\"W3\", doWriteThread, &a7);\n+\n+  fireThread(\"R5\", doReadThread, &a1);\n+  fireThread(\"R6\", doReadThread, &a2);\n+  fireThread(\"R7\", doReadThread, &a3);\n+  fireThread(\"R8\", doReadThread, &a4);\n+\n+  fireThread(\"W4\", doWriteThread, &a5);\n+  fireThread(\"W5\", doWriteThread, &a6);\n+  fireThread(\"W6\", doWriteThread, &a7);\n+\n+  while (1) {\n+    PRInt32 writeCount, readCount;\n+    PRIntervalTime fiveSecs = PR_SecondsToInterval(5);\n+    PR_Sleep(fiveSecs);  // get out of the way\n+\n+    // print some stats, not threadsafe, informative only\n+    writeCount = gCounter;\n+    readCount = gReads;\n+    printf(\"\\ntick %d writes (+%d), %d reads (+%d) [max %d, %d, %d]\",\n+           writeCount, writeCount - lastWriteCount, readCount,\n+           readCount - lastReadCount, gMaxReads, gMaxWriteWaits, gMaxReadWaits);\n+    lastWriteCount = writeCount;\n+    lastReadCount = readCount;\n+    gMaxReads = gMaxWriteWaits = gMaxReadWaits = 0;\n+  }\n+  return 0;\n }\n \n-static void\n-padStack(int argc, char** argv)\n-{\n-    char pad[512]; /* Work around bug in nspr on windoze */\n-    pseudoMain(argc, argv, pad);\n+static void padStack(int argc, char** argv) {\n+  char pad[512]; /* Work around bug in nspr on windoze */\n+  pseudoMain(argc, argv, pad);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-    padStack(argc, argv);\n+int main(int argc, char** argv) {\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  padStack(argc, argv);\n }\n \n /* bug1test.c */\ndiff --git a/nspr/pr/tests/cleanup.c b/nspr/pr/tests/cleanup.c\nindex d1a5ba2..e978c29 100644\n--- a/nspr/pr/tests/cleanup.c\n+++ b/nspr/pr/tests/cleanup.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -12,90 +13,84 @@\n \n #include <stdlib.h>\n \n-static void PR_CALLBACK\n-Thread(void* sleep)\n-{\n-    PR_Sleep(PR_SecondsToInterval((PRUint32)sleep));\n-    printf(\"Thread exiting\\n\");\n+static void PR_CALLBACK Thread(void* sleep) {\n+  PR_Sleep(PR_SecondsToInterval((PRUint32)sleep));\n+  printf(\"Thread exiting\\n\");\n }\n \n-static void\n-Help(void)\n-{\n-    PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n-    PR_fprintf(err, \"Cleanup usage: [-g] [-s n] [-t n] [-c n] [-h]\\n\");\n-    PR_fprintf(err, \"\\t-c   Call cleanup before exiting     (default: false)\\n\");\n-    PR_fprintf(err, \"\\t-G   Use global threads only         (default: local)\\n\");\n-    PR_fprintf(err, \"\\t-t n Number of threads involved      (default: 1)\\n\");\n-    PR_fprintf(err, \"\\t-s n Seconds thread(s) should dally  (defaut: 10)\\n\");\n-    PR_fprintf(err, \"\\t-S n Seconds main() should dally     (defaut: 5)\\n\");\n-    PR_fprintf(err, \"\\t-C n Value to set concurrency        (default 1)\\n\");\n-    PR_fprintf(err, \"\\t-h   This message and nothing else\\n\");\n+static void Help(void) {\n+  PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n+  PR_fprintf(err, \"Cleanup usage: [-g] [-s n] [-t n] [-c n] [-h]\\n\");\n+  PR_fprintf(err, \"\\t-c   Call cleanup before exiting     (default: false)\\n\");\n+  PR_fprintf(err, \"\\t-G   Use global threads only         (default: local)\\n\");\n+  PR_fprintf(err, \"\\t-t n Number of threads involved      (default: 1)\\n\");\n+  PR_fprintf(err, \"\\t-s n Seconds thread(s) should dally  (defaut: 10)\\n\");\n+  PR_fprintf(err, \"\\t-S n Seconds main() should dally     (defaut: 5)\\n\");\n+  PR_fprintf(err, \"\\t-C n Value to set concurrency        (default 1)\\n\");\n+  PR_fprintf(err, \"\\t-h   This message and nothing else\\n\");\n } /* Help */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PLOptStatus os;\n-    PRBool cleanup = PR_FALSE;\n-    PRThreadScope type = PR_LOCAL_THREAD;\n-    PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"Ghs:S:t:cC:\");\n-    PRIntn concurrency = 1, child_sleep = 10, main_sleep = 5, threads = 1;\n+int main(int argc, char** argv) {\n+  PLOptStatus os;\n+  PRBool cleanup = PR_FALSE;\n+  PRThreadScope type = PR_LOCAL_THREAD;\n+  PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"Ghs:S:t:cC:\");\n+  PRIntn concurrency = 1, child_sleep = 10, main_sleep = 5, threads = 1;\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'c': /* call PR_Cleanup() before exiting */\n-                cleanup = PR_TRUE;\n-                break;\n-            case 'G': /* local vs global threads */\n-                type = PR_GLOBAL_THREAD;\n-                break;\n-            case 's': /* time to sleep */\n-                child_sleep = atoi(opt->value);\n-                break;\n-            case 'S': /* time to sleep */\n-                main_sleep = atoi(opt->value);\n-                break;\n-            case 'C': /* number of cpus to create */\n-                concurrency = atoi(opt->value);\n-                break;\n-            case 't': /* number of threads to create */\n-                threads = atoi(opt->value);\n-                break;\n-            case 'h':     /* user wants some guidance */\n-                Help();   /* so give him an earful */\n-                return 2; /* but not a lot else */\n-                break;\n-            default:\n-                break;\n-        }\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n+    switch (opt->option) {\n+      case 'c': /* call PR_Cleanup() before exiting */\n+        cleanup = PR_TRUE;\n+        break;\n+      case 'G': /* local vs global threads */\n+        type = PR_GLOBAL_THREAD;\n+        break;\n+      case 's': /* time to sleep */\n+        child_sleep = atoi(opt->value);\n+        break;\n+      case 'S': /* time to sleep */\n+        main_sleep = atoi(opt->value);\n+        break;\n+      case 'C': /* number of cpus to create */\n+        concurrency = atoi(opt->value);\n+        break;\n+      case 't': /* number of threads to create */\n+        threads = atoi(opt->value);\n+        break;\n+      case 'h':   /* user wants some guidance */\n+        Help();   /* so give him an earful */\n+        return 2; /* but not a lot else */\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    PR_fprintf(err, \"Cleanup settings\\n\");\n-    PR_fprintf(err, \"\\tThread type: %s\\n\",\n-               (PR_LOCAL_THREAD == type) ? \"LOCAL\" : \"GLOBAL\");\n-    PR_fprintf(err, \"\\tConcurrency: %d\\n\", concurrency);\n-    PR_fprintf(err, \"\\tNumber of threads: %d\\n\", threads);\n-    PR_fprintf(err, \"\\tThread sleep: %d\\n\", child_sleep);\n-    PR_fprintf(err, \"\\tMain sleep: %d\\n\", main_sleep);\n-    PR_fprintf(err, \"\\tCleanup will %sbe called\\n\\n\", (cleanup) ? \"\" : \"NOT \");\n+  PR_fprintf(err, \"Cleanup settings\\n\");\n+  PR_fprintf(err, \"\\tThread type: %s\\n\",\n+             (PR_LOCAL_THREAD == type) ? \"LOCAL\" : \"GLOBAL\");\n+  PR_fprintf(err, \"\\tConcurrency: %d\\n\", concurrency);\n+  PR_fprintf(err, \"\\tNumber of threads: %d\\n\", threads);\n+  PR_fprintf(err, \"\\tThread sleep: %d\\n\", child_sleep);\n+  PR_fprintf(err, \"\\tMain sleep: %d\\n\", main_sleep);\n+  PR_fprintf(err, \"\\tCleanup will %sbe called\\n\\n\", (cleanup) ? \"\" : \"NOT \");\n \n-    PR_SetConcurrency(concurrency);\n+  PR_SetConcurrency(concurrency);\n \n-    while (threads-- > 0)\n-        (void)PR_CreateThread(PR_USER_THREAD, Thread, (void*)child_sleep,\n-                              PR_PRIORITY_NORMAL, type, PR_UNJOINABLE_THREAD, 0);\n-    PR_Sleep(PR_SecondsToInterval(main_sleep));\n+  while (threads-- > 0)\n+    (void)PR_CreateThread(PR_USER_THREAD, Thread, (void*)child_sleep,\n+                          PR_PRIORITY_NORMAL, type, PR_UNJOINABLE_THREAD, 0);\n+  PR_Sleep(PR_SecondsToInterval(main_sleep));\n \n-    if (cleanup) {\n-        PR_Cleanup();\n-    }\n+  if (cleanup) {\n+    PR_Cleanup();\n+  }\n \n-    PR_fprintf(err, \"main() exiting\\n\");\n-    return 0;\n+  PR_fprintf(err, \"main() exiting\\n\");\n+  return 0;\n } /* main */\ndiff --git a/nspr/pr/tests/cltsrv.c b/nspr/pr/tests/cltsrv.c\nindex 7c2671e..3290500 100644\n--- a/nspr/pr/tests/cltsrv.c\n+++ b/nspr/pr/tests/cltsrv.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -50,7 +51,7 @@\n #include <string.h>\n \n #if defined(XP_UNIX)\n-#include <math.h>\n+#  include <math.h>\n #endif\n \n /*\n@@ -65,14 +66,14 @@\n #define DEFAULT_BACKLOG 5\n \n #ifdef DEBUG\n-#define PORT_INC_DO +100\n+#  define PORT_INC_DO +100\n #else\n-#define PORT_INC_DO\n+#  define PORT_INC_DO\n #endif\n #ifdef IS_64\n-#define PORT_INC_3264 +200\n+#  define PORT_INC_3264 +200\n #else\n-#define PORT_INC_3264\n+#  define PORT_INC_3264\n #endif\n \n #define DEFAULT_PORT 12849 PORT_INC_DO PORT_INC_3264\n@@ -88,23 +89,20 @@\n #define DEFAULT_SERVER_TIMEOUT 4000\n #define DEFAULT_SERVER_PRIORITY PR_PRIORITY_HIGH\n \n-typedef enum CSState_e { cs_init,\n-                         cs_run,\n-                         cs_stop,\n-                         cs_exit } CSState_t;\n+typedef enum CSState_e { cs_init, cs_run, cs_stop, cs_exit } CSState_t;\n \n static void PR_CALLBACK Worker(void* arg);\n typedef struct CSPool_s CSPool_t;\n typedef struct CSWorker_s CSWorker_t;\n typedef struct CSServer_s CSServer_t;\n typedef enum Verbosity {\n-    TEST_LOG_ALWAYS,\n-    TEST_LOG_ERROR,\n-    TEST_LOG_WARNING,\n-    TEST_LOG_NOTICE,\n-    TEST_LOG_INFO,\n-    TEST_LOG_STATUS,\n-    TEST_LOG_VERBOSE\n+  TEST_LOG_ALWAYS,\n+  TEST_LOG_ERROR,\n+  TEST_LOG_WARNING,\n+  TEST_LOG_NOTICE,\n+  TEST_LOG_INFO,\n+  TEST_LOG_STATUS,\n+  TEST_LOG_VERBOSE\n } Verbosity;\n \n static PRInt32 domain = AF_INET;\n@@ -116,1068 +114,1043 @@ static Verbosity verbosity = TEST_LOG_ALWAYS;\n static PRThreadScope thread_scope = PR_LOCAL_THREAD;\n \n struct CSWorker_s {\n-    PRCList element; /* list of the server's workers */\n+  PRCList element; /* list of the server's workers */\n \n-    PRThread* thread;   /* this worker objects thread */\n-    CSServer_t* server; /* back pointer to server structure */\n+  PRThread* thread;   /* this worker objects thread */\n+  CSServer_t* server; /* back pointer to server structure */\n };\n \n struct CSPool_s {\n-    PRCondVar* exiting;\n-    PRCondVar* acceptComplete;\n-    PRUint32 accepting, active, workers;\n+  PRCondVar* exiting;\n+  PRCondVar* acceptComplete;\n+  PRUint32 accepting, active, workers;\n };\n \n struct CSServer_s {\n-    PRCList list; /* head of worker list */\n-\n-    PRLock* ml;\n-    PRThread* thread; /* the main server thread */\n-    PRCondVar* stateChange;\n-\n-    PRUint16 port;        /* port we're listening on */\n-    PRUint32 backlog;     /* size of our listener backlog */\n-    PRFileDesc* listener; /* the fd accepting connections */\n-\n-    CSPool_t pool;   /* statistics on worker threads */\n-    CSState_t state; /* the server's state */\n-    struct           /* controlling worker counts */\n-    {\n-        PRUint32 minimum, maximum, accepting;\n-    } workers;\n-\n-    /* statistics */\n-    PRIntervalTime started, stopped;\n-    PRUint32 operations, bytesTransferred;\n+  PRCList list; /* head of worker list */\n+\n+  PRLock* ml;\n+  PRThread* thread; /* the main server thread */\n+  PRCondVar* stateChange;\n+\n+  PRUint16 port;        /* port we're listening on */\n+  PRUint32 backlog;     /* size of our listener backlog */\n+  PRFileDesc* listener; /* the fd accepting connections */\n+\n+  CSPool_t pool;   /* statistics on worker threads */\n+  CSState_t state; /* the server's state */\n+  struct           /* controlling worker counts */\n+  {\n+    PRUint32 minimum, maximum, accepting;\n+  } workers;\n+\n+  /* statistics */\n+  PRIntervalTime started, stopped;\n+  PRUint32 operations, bytesTransferred;\n };\n \n typedef struct CSDescriptor_s {\n-    PRInt32 size;      /* size of transfer */\n-    char filename[60]; /* filename, null padded */\n+  PRInt32 size;      /* size of transfer */\n+  char filename[60]; /* filename, null padded */\n } CSDescriptor_t;\n \n typedef struct CSClient_s {\n-    PRLock* ml;\n-    PRThread* thread;\n-    PRCondVar* stateChange;\n-    PRNetAddr serverAddress;\n+  PRLock* ml;\n+  PRThread* thread;\n+  PRCondVar* stateChange;\n+  PRNetAddr serverAddress;\n \n-    CSState_t state;\n+  CSState_t state;\n \n-    /* statistics */\n-    PRIntervalTime started, stopped;\n-    PRUint32 operations, bytesTransferred;\n+  /* statistics */\n+  PRIntervalTime started, stopped;\n+  PRUint32 operations, bytesTransferred;\n } CSClient_t;\n \n-#define TEST_LOG(l, p, a)                   \\\n-    do {                                    \\\n-        if (debug_mode || (p <= verbosity)) \\\n-            printf a;                       \\\n-    } while (0)\n+#define TEST_LOG(l, p, a)                         \\\n+  do {                                            \\\n+    if (debug_mode || (p <= verbosity)) printf a; \\\n+  } while (0)\n \n PRLogModuleInfo* cltsrv_log_file = NULL;\n \n #define MY_ASSERT(_expr) \\\n-    ((_expr) ? ((void)0) : _MY_Assert(#_expr, __FILE__, __LINE__))\n+  ((_expr) ? ((void)0) : _MY_Assert(#_expr, __FILE__, __LINE__))\n \n #define TEST_ASSERT(_expr) \\\n-    ((_expr) ? ((void)0) : _MY_Assert(#_expr, __FILE__, __LINE__))\n+  ((_expr) ? ((void)0) : _MY_Assert(#_expr, __FILE__, __LINE__))\n \n-static void\n-_MY_Assert(const char* s, const char* file, PRIntn ln)\n-{\n-    PL_PrintError(NULL);\n-    PR_Assert(s, file, ln);\n+static void _MY_Assert(const char* s, const char* file, PRIntn ln) {\n+  PL_PrintError(NULL);\n+  PR_Assert(s, file, ln);\n } /* _MY_Assert */\n \n-static PRBool\n-Aborted(PRStatus rv)\n-{\n-    return ((PR_FAILURE == rv) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError()))\n-               ? PR_TRUE\n-               : PR_FALSE;\n+static PRBool Aborted(PRStatus rv) {\n+  return ((PR_FAILURE == rv) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError()))\n+             ? PR_TRUE\n+             : PR_FALSE;\n }\n \n-static void\n-TimeOfDayMessage(const char* msg, PRThread* me)\n-{\n-    char buffer[100];\n-    PRExplodedTime tod;\n-    PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &tod);\n-    (void)PR_FormatTime(buffer, sizeof(buffer), \"%H:%M:%S\", &tod);\n+static void TimeOfDayMessage(const char* msg, PRThread* me) {\n+  char buffer[100];\n+  PRExplodedTime tod;\n+  PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &tod);\n+  (void)PR_FormatTime(buffer, sizeof(buffer), \"%H:%M:%S\", &tod);\n \n-    TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n-             (\"%s(0x%p): %s\\n\", msg, me, buffer));\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n+           (\"%s(0x%p): %s\\n\", msg, me, buffer));\n } /* TimeOfDayMessage */\n \n-static void PR_CALLBACK\n-Client(void* arg)\n-{\n-    PRStatus rv;\n-    PRIntn index;\n-    char buffer[1024];\n-    PRFileDesc* fd = NULL;\n-    PRUintn clipping = DEFAULT_CLIPPING;\n-    PRThread* me = PR_GetCurrentThread();\n-    CSClient_t* client = (CSClient_t*)arg;\n-    CSDescriptor_t* descriptor = PR_NEW(CSDescriptor_t);\n-    PRIntervalTime timeout = PR_MillisecondsToInterval(DEFAULT_CLIENT_TIMEOUT);\n-\n-    for (index = 0; index < sizeof(buffer); ++index) {\n-        buffer[index] = (char)index;\n-    }\n+static void PR_CALLBACK Client(void* arg) {\n+  PRStatus rv;\n+  PRIntn index;\n+  char buffer[1024];\n+  PRFileDesc* fd = NULL;\n+  PRUintn clipping = DEFAULT_CLIPPING;\n+  PRThread* me = PR_GetCurrentThread();\n+  CSClient_t* client = (CSClient_t*)arg;\n+  CSDescriptor_t* descriptor = PR_NEW(CSDescriptor_t);\n+  PRIntervalTime timeout = PR_MillisecondsToInterval(DEFAULT_CLIENT_TIMEOUT);\n \n-    client->started = PR_IntervalNow();\n+  for (index = 0; index < sizeof(buffer); ++index) {\n+    buffer[index] = (char)index;\n+  }\n \n-    PR_Lock(client->ml);\n-    client->state = cs_run;\n-    PR_NotifyCondVar(client->stateChange);\n-    PR_Unlock(client->ml);\n+  client->started = PR_IntervalNow();\n \n-    TimeOfDayMessage(\"Client started at\", me);\n+  PR_Lock(client->ml);\n+  client->state = cs_run;\n+  PR_NotifyCondVar(client->stateChange);\n+  PR_Unlock(client->ml);\n \n-    while (cs_run == client->state) {\n-        PRInt32 bytes, descbytes, filebytes, netbytes;\n+  TimeOfDayMessage(\"Client started at\", me);\n \n-        (void)PR_NetAddrToString(&client->serverAddress, buffer, sizeof(buffer));\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n-                 (\"\\tClient(0x%p): connecting to server at %s\\n\", me, buffer));\n+  while (cs_run == client->state) {\n+    PRInt32 bytes, descbytes, filebytes, netbytes;\n \n-        fd = PR_Socket(domain, SOCK_STREAM, protocol);\n-        TEST_ASSERT(NULL != fd);\n-        rv = PR_Connect(fd, &client->serverAddress, timeout);\n-        if (PR_FAILURE == rv) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                     (\"\\tClient(0x%p): conection failed (%d, %d)\\n\", me,\n-                      PR_GetError(), PR_GetOSError()));\n-            goto aborted;\n-        }\n+    (void)PR_NetAddrToString(&client->serverAddress, buffer, sizeof(buffer));\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n+             (\"\\tClient(0x%p): connecting to server at %s\\n\", me, buffer));\n+\n+    fd = PR_Socket(domain, SOCK_STREAM, protocol);\n+    TEST_ASSERT(NULL != fd);\n+    rv = PR_Connect(fd, &client->serverAddress, timeout);\n+    if (PR_FAILURE == rv) {\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+               (\"\\tClient(0x%p): conection failed (%d, %d)\\n\", me,\n+                PR_GetError(), PR_GetOSError()));\n+      goto aborted;\n+    }\n \n-        memset(descriptor, 0, sizeof(*descriptor));\n-        descriptor->size = PR_htonl(descbytes = rand() % clipping);\n-        PR_snprintf(descriptor->filename, sizeof(descriptor->filename),\n-                    \"CS%p%p-%p.dat\", client->started, me, client->operations);\n-        TEST_LOG(\n-            cltsrv_log_file, TEST_LOG_VERBOSE,\n-            (\"\\tClient(0x%p): sending descriptor for %u bytes\\n\", me, descbytes));\n-        bytes = PR_Send(fd, descriptor, sizeof(*descriptor), SEND_FLAGS, timeout);\n-        if (sizeof(CSDescriptor_t) != bytes) {\n-            if (Aborted(PR_FAILURE)) {\n-                goto aborted;\n-            }\n-            if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\tClient(0x%p): send descriptor timeout\\n\", me));\n-                goto retry;\n-            }\n-        }\n-        TEST_ASSERT(sizeof(*descriptor) == bytes);\n-\n-        netbytes = 0;\n-        while (netbytes < descbytes) {\n-            filebytes = sizeof(buffer);\n-            if ((descbytes - netbytes) < filebytes) {\n-                filebytes = descbytes - netbytes;\n-            }\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                     (\"\\tClient(0x%p): sending %d bytes\\n\", me, filebytes));\n-            bytes = PR_Send(fd, buffer, filebytes, SEND_FLAGS, timeout);\n-            if (filebytes != bytes) {\n-                if (Aborted(PR_FAILURE)) {\n-                    goto aborted;\n-                }\n-                if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-                    TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                             (\"\\tClient(0x%p): send data timeout\\n\", me));\n-                    goto retry;\n-                }\n-            }\n-            TEST_ASSERT(bytes == filebytes);\n-            netbytes += bytes;\n-        }\n-        filebytes = 0;\n-        while (filebytes < descbytes) {\n-            netbytes = sizeof(buffer);\n-            if ((descbytes - filebytes) < netbytes) {\n-                netbytes = descbytes - filebytes;\n-            }\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                     (\"\\tClient(0x%p): receiving %d bytes\\n\", me, netbytes));\n-            bytes = PR_Recv(fd, buffer, netbytes, RECV_FLAGS, timeout);\n-            if (-1 == bytes) {\n-                if (Aborted(PR_FAILURE)) {\n-                    TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                             (\"\\tClient(0x%p): receive data aborted\\n\", me));\n-                    goto aborted;\n-                } else if (PR_IO_TIMEOUT_ERROR == PR_GetError())\n-                    TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                             (\"\\tClient(0x%p): receive data timeout\\n\", me));\n-                else\n-                    TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                             (\"\\tClient(0x%p): receive error (%d, %d)\\n\", me,\n-                              PR_GetError(), PR_GetOSError()));\n-                goto retry;\n-            }\n-            if (0 == bytes) {\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tClient(0x%p): unexpected end of stream\\n\",\n-                          PR_GetCurrentThread()));\n-                break;\n-            }\n-            filebytes += bytes;\n-        }\n+    memset(descriptor, 0, sizeof(*descriptor));\n+    descriptor->size = PR_htonl(descbytes = rand() % clipping);\n+    PR_snprintf(descriptor->filename, sizeof(descriptor->filename),\n+                \"CS%p%p-%p.dat\", client->started, me, client->operations);\n+    TEST_LOG(\n+        cltsrv_log_file, TEST_LOG_VERBOSE,\n+        (\"\\tClient(0x%p): sending descriptor for %u bytes\\n\", me, descbytes));\n+    bytes = PR_Send(fd, descriptor, sizeof(*descriptor), SEND_FLAGS, timeout);\n+    if (sizeof(CSDescriptor_t) != bytes) {\n+      if (Aborted(PR_FAILURE)) {\n+        goto aborted;\n+      }\n+      if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                 (\"\\tClient(0x%p): send descriptor timeout\\n\", me));\n+        goto retry;\n+      }\n+    }\n+    TEST_ASSERT(sizeof(*descriptor) == bytes);\n \n-        rv = PR_Shutdown(fd, PR_SHUTDOWN_BOTH);\n-        if (Aborted(rv)) {\n-            goto aborted;\n+    netbytes = 0;\n+    while (netbytes < descbytes) {\n+      filebytes = sizeof(buffer);\n+      if ((descbytes - netbytes) < filebytes) {\n+        filebytes = descbytes - netbytes;\n+      }\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+               (\"\\tClient(0x%p): sending %d bytes\\n\", me, filebytes));\n+      bytes = PR_Send(fd, buffer, filebytes, SEND_FLAGS, timeout);\n+      if (filebytes != bytes) {\n+        if (Aborted(PR_FAILURE)) {\n+          goto aborted;\n         }\n-        TEST_ASSERT(PR_SUCCESS == rv);\n-    retry:\n-        (void)PR_Close(fd);\n-        fd = NULL;\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n-                 (\"\\tClient(0x%p): disconnected from server\\n\", me));\n-\n-        PR_Lock(client->ml);\n-        client->operations += 1;\n-        client->bytesTransferred += 2 * descbytes;\n-        rv = PR_WaitCondVar(client->stateChange, rand() % clipping);\n-        PR_Unlock(client->ml);\n-        if (Aborted(rv)) {\n-            break;\n+        if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+          TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                   (\"\\tClient(0x%p): send data timeout\\n\", me));\n+          goto retry;\n         }\n+      }\n+      TEST_ASSERT(bytes == filebytes);\n+      netbytes += bytes;\n+    }\n+    filebytes = 0;\n+    while (filebytes < descbytes) {\n+      netbytes = sizeof(buffer);\n+      if ((descbytes - filebytes) < netbytes) {\n+        netbytes = descbytes - filebytes;\n+      }\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+               (\"\\tClient(0x%p): receiving %d bytes\\n\", me, netbytes));\n+      bytes = PR_Recv(fd, buffer, netbytes, RECV_FLAGS, timeout);\n+      if (-1 == bytes) {\n+        if (Aborted(PR_FAILURE)) {\n+          TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                   (\"\\tClient(0x%p): receive data aborted\\n\", me));\n+          goto aborted;\n+        } else if (PR_IO_TIMEOUT_ERROR == PR_GetError())\n+          TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                   (\"\\tClient(0x%p): receive data timeout\\n\", me));\n+        else\n+          TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                   (\"\\tClient(0x%p): receive error (%d, %d)\\n\", me,\n+                    PR_GetError(), PR_GetOSError()));\n+        goto retry;\n+      }\n+      if (0 == bytes) {\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                 (\"\\t\\tClient(0x%p): unexpected end of stream\\n\",\n+                  PR_GetCurrentThread()));\n+        break;\n+      }\n+      filebytes += bytes;\n     }\n \n-aborted:\n-    client->stopped = PR_IntervalNow();\n-\n-    PR_ClearInterrupt();\n-    if (NULL != fd) {\n-        rv = PR_Close(fd);\n+    rv = PR_Shutdown(fd, PR_SHUTDOWN_BOTH);\n+    if (Aborted(rv)) {\n+      goto aborted;\n     }\n+    TEST_ASSERT(PR_SUCCESS == rv);\n+  retry:\n+    (void)PR_Close(fd);\n+    fd = NULL;\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n+             (\"\\tClient(0x%p): disconnected from server\\n\", me));\n \n     PR_Lock(client->ml);\n-    client->state = cs_exit;\n-    PR_NotifyCondVar(client->stateChange);\n+    client->operations += 1;\n+    client->bytesTransferred += 2 * descbytes;\n+    rv = PR_WaitCondVar(client->stateChange, rand() % clipping);\n     PR_Unlock(client->ml);\n-    PR_DELETE(descriptor);\n-    TEST_LOG(\n-        cltsrv_log_file, TEST_LOG_ALWAYS,\n-        (\"\\tClient(0x%p): stopped after %u operations and %u bytes\\n\",\n-         PR_GetCurrentThread(), client->operations, client->bytesTransferred));\n+    if (Aborted(rv)) {\n+      break;\n+    }\n+  }\n \n-} /* Client */\n+aborted:\n+  client->stopped = PR_IntervalNow();\n+\n+  PR_ClearInterrupt();\n+  if (NULL != fd) {\n+    rv = PR_Close(fd);\n+  }\n+\n+  PR_Lock(client->ml);\n+  client->state = cs_exit;\n+  PR_NotifyCondVar(client->stateChange);\n+  PR_Unlock(client->ml);\n+  PR_DELETE(descriptor);\n+  TEST_LOG(\n+      cltsrv_log_file, TEST_LOG_ALWAYS,\n+      (\"\\tClient(0x%p): stopped after %u operations and %u bytes\\n\",\n+       PR_GetCurrentThread(), client->operations, client->bytesTransferred));\n \n-static PRStatus\n-ProcessRequest(PRFileDesc* fd, CSServer_t* server)\n-{\n-    PRStatus drv, rv;\n-    char buffer[1024];\n-    PRFileDesc* file = NULL;\n-    PRThread* me = PR_GetCurrentThread();\n-    PRInt32 bytes, descbytes, netbytes, filebytes = 0;\n-    CSDescriptor_t* descriptor = PR_NEW(CSDescriptor_t);\n-    PRIntervalTime timeout = PR_MillisecondsToInterval(DEFAULT_SERVER_TIMEOUT);\n+} /* Client */\n \n+static PRStatus ProcessRequest(PRFileDesc* fd, CSServer_t* server) {\n+  PRStatus drv, rv;\n+  char buffer[1024];\n+  PRFileDesc* file = NULL;\n+  PRThread* me = PR_GetCurrentThread();\n+  PRInt32 bytes, descbytes, netbytes, filebytes = 0;\n+  CSDescriptor_t* descriptor = PR_NEW(CSDescriptor_t);\n+  PRIntervalTime timeout = PR_MillisecondsToInterval(DEFAULT_SERVER_TIMEOUT);\n+\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+           (\"\\tProcessRequest(0x%p): receiving desciptor\\n\", me));\n+  bytes = PR_Recv(fd, descriptor, sizeof(*descriptor), RECV_FLAGS, timeout);\n+  if (-1 == bytes) {\n+    rv = PR_FAILURE;\n+    if (Aborted(rv)) {\n+      goto exit;\n+    }\n+    if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+               (\"\\tProcessRequest(0x%p): receive timeout\\n\", me));\n+    }\n+    goto exit;\n+  }\n+  if (0 == bytes) {\n+    rv = PR_FAILURE;\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+             (\"\\tProcessRequest(0x%p): unexpected end of file\\n\", me));\n+    goto exit;\n+  }\n+  descbytes = PR_ntohl(descriptor->size);\n+  TEST_ASSERT(sizeof(*descriptor) == bytes);\n+\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+           (\"\\t\\tProcessRequest(0x%p): read descriptor {%d, %s}\\n\", me,\n+            descbytes, descriptor->filename));\n+\n+  file = PR_Open(descriptor->filename, (PR_CREATE_FILE | PR_WRONLY), 0666);\n+  if (NULL == file) {\n+    rv = PR_FAILURE;\n+    if (Aborted(rv)) {\n+      goto aborted;\n+    }\n+    if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+               (\"\\tProcessRequest(0x%p): open file timeout\\n\", me));\n+      goto aborted;\n+    }\n+  }\n+  TEST_ASSERT(NULL != file);\n+\n+  filebytes = 0;\n+  while (filebytes < descbytes) {\n+    netbytes = sizeof(buffer);\n+    if ((descbytes - filebytes) < netbytes) {\n+      netbytes = descbytes - filebytes;\n+    }\n     TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-             (\"\\tProcessRequest(0x%p): receiving desciptor\\n\", me));\n-    bytes = PR_Recv(fd, descriptor, sizeof(*descriptor), RECV_FLAGS, timeout);\n+             (\"\\tProcessRequest(0x%p): receive %d bytes\\n\", me, netbytes));\n+    bytes = PR_Recv(fd, buffer, netbytes, RECV_FLAGS, timeout);\n     if (-1 == bytes) {\n-        rv = PR_FAILURE;\n-        if (Aborted(rv)) {\n-            goto exit;\n-        }\n-        if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                     (\"\\tProcessRequest(0x%p): receive timeout\\n\", me));\n-        }\n-        goto exit;\n+      rv = PR_FAILURE;\n+      if (Aborted(rv)) {\n+        goto aborted;\n+      }\n+      if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                 (\"\\t\\tProcessRequest(0x%p): receive data timeout\\n\", me));\n+        goto aborted;\n+      }\n+      /*\n+       * XXX: I got (PR_CONNECT_RESET_ERROR, ERROR_NETNAME_DELETED)\n+       * on NT here.  This is equivalent to ECONNRESET on Unix.\n+       *     -wtc\n+       */\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_WARNING,\n+               (\"\\t\\tProcessRequest(0x%p): unexpected error (%d, %d)\\n\", me,\n+                PR_GetError(), PR_GetOSError()));\n+      goto aborted;\n     }\n     if (0 == bytes) {\n-        rv = PR_FAILURE;\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_WARNING,\n+               (\"\\t\\tProcessRequest(0x%p): unexpected end of stream\\n\", me));\n+      rv = PR_FAILURE;\n+      goto aborted;\n+    }\n+    filebytes += bytes;\n+    netbytes = bytes;\n+    /* The byte count for PR_Write should be positive */\n+    MY_ASSERT(netbytes > 0);\n+    TEST_LOG(\n+        cltsrv_log_file, TEST_LOG_VERBOSE,\n+        (\"\\tProcessRequest(0x%p): write %d bytes to file\\n\", me, netbytes));\n+    bytes = PR_Write(file, buffer, netbytes);\n+    if (netbytes != bytes) {\n+      rv = PR_FAILURE;\n+      if (Aborted(rv)) {\n+        goto aborted;\n+      }\n+      if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n         TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                 (\"\\tProcessRequest(0x%p): unexpected end of file\\n\", me));\n-        goto exit;\n+                 (\"\\t\\tProcessRequest(0x%p): write file timeout\\n\", me));\n+        goto aborted;\n+      }\n     }\n-    descbytes = PR_ntohl(descriptor->size);\n-    TEST_ASSERT(sizeof(*descriptor) == bytes);\n-\n-    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-             (\"\\t\\tProcessRequest(0x%p): read descriptor {%d, %s}\\n\", me,\n-              descbytes, descriptor->filename));\n-\n-    file = PR_Open(descriptor->filename, (PR_CREATE_FILE | PR_WRONLY), 0666);\n-    if (NULL == file) {\n-        rv = PR_FAILURE;\n-        if (Aborted(rv)) {\n-            goto aborted;\n-        }\n-        if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                     (\"\\tProcessRequest(0x%p): open file timeout\\n\", me));\n-            goto aborted;\n-        }\n+    TEST_ASSERT(bytes > 0);\n+  }\n+\n+  PR_Lock(server->ml);\n+  server->operations += 1;\n+  server->bytesTransferred += filebytes;\n+  PR_Unlock(server->ml);\n+\n+  rv = PR_Close(file);\n+  if (Aborted(rv)) {\n+    goto aborted;\n+  }\n+  TEST_ASSERT(PR_SUCCESS == rv);\n+  file = NULL;\n+\n+  TEST_LOG(\n+      cltsrv_log_file, TEST_LOG_VERBOSE,\n+      (\"\\t\\tProcessRequest(0x%p): opening %s\\n\", me, descriptor->filename));\n+  file = PR_Open(descriptor->filename, PR_RDONLY, 0);\n+  if (NULL == file) {\n+    rv = PR_FAILURE;\n+    if (Aborted(rv)) {\n+      goto aborted;\n     }\n-    TEST_ASSERT(NULL != file);\n-\n-    filebytes = 0;\n-    while (filebytes < descbytes) {\n-        netbytes = sizeof(buffer);\n-        if ((descbytes - filebytes) < netbytes) {\n-            netbytes = descbytes - filebytes;\n-        }\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"\\tProcessRequest(0x%p): receive %d bytes\\n\", me, netbytes));\n-        bytes = PR_Recv(fd, buffer, netbytes, RECV_FLAGS, timeout);\n-        if (-1 == bytes) {\n-            rv = PR_FAILURE;\n-            if (Aborted(rv)) {\n-                goto aborted;\n-            }\n-            if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tProcessRequest(0x%p): receive data timeout\\n\", me));\n-                goto aborted;\n-            }\n-            /*\n-             * XXX: I got (PR_CONNECT_RESET_ERROR, ERROR_NETNAME_DELETED)\n-             * on NT here.  This is equivalent to ECONNRESET on Unix.\n-             *     -wtc\n-             */\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_WARNING,\n-                     (\"\\t\\tProcessRequest(0x%p): unexpected error (%d, %d)\\n\", me,\n-                      PR_GetError(), PR_GetOSError()));\n-            goto aborted;\n-        }\n-        if (0 == bytes) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_WARNING,\n-                     (\"\\t\\tProcessRequest(0x%p): unexpected end of stream\\n\", me));\n-            rv = PR_FAILURE;\n-            goto aborted;\n-        }\n-        filebytes += bytes;\n-        netbytes = bytes;\n-        /* The byte count for PR_Write should be positive */\n-        MY_ASSERT(netbytes > 0);\n-        TEST_LOG(\n-            cltsrv_log_file, TEST_LOG_VERBOSE,\n-            (\"\\tProcessRequest(0x%p): write %d bytes to file\\n\", me, netbytes));\n-        bytes = PR_Write(file, buffer, netbytes);\n-        if (netbytes != bytes) {\n-            rv = PR_FAILURE;\n-            if (Aborted(rv)) {\n-                goto aborted;\n-            }\n-            if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tProcessRequest(0x%p): write file timeout\\n\", me));\n-                goto aborted;\n-            }\n-        }\n-        TEST_ASSERT(bytes > 0);\n+    if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+               (\"\\t\\tProcessRequest(0x%p): open file timeout\\n\",\n+                PR_GetCurrentThread()));\n+      goto aborted;\n     }\n-\n-    PR_Lock(server->ml);\n-    server->operations += 1;\n-    server->bytesTransferred += filebytes;\n-    PR_Unlock(server->ml);\n-\n-    rv = PR_Close(file);\n-    if (Aborted(rv)) {\n-        goto aborted;\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+             (\"\\t\\tProcessRequest(0x%p): other file open error (%u, %u)\\n\", me,\n+              PR_GetError(), PR_GetOSError()));\n+    goto aborted;\n+  }\n+  TEST_ASSERT(NULL != file);\n+\n+  netbytes = 0;\n+  while (netbytes < descbytes) {\n+    filebytes = sizeof(buffer);\n+    if ((descbytes - netbytes) < filebytes) {\n+      filebytes = descbytes - netbytes;\n     }\n-    TEST_ASSERT(PR_SUCCESS == rv);\n-    file = NULL;\n-\n     TEST_LOG(\n         cltsrv_log_file, TEST_LOG_VERBOSE,\n-        (\"\\t\\tProcessRequest(0x%p): opening %s\\n\", me, descriptor->filename));\n-    file = PR_Open(descriptor->filename, PR_RDONLY, 0);\n-    if (NULL == file) {\n-        rv = PR_FAILURE;\n-        if (Aborted(rv)) {\n-            goto aborted;\n-        }\n-        if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                     (\"\\t\\tProcessRequest(0x%p): open file timeout\\n\",\n-                      PR_GetCurrentThread()));\n-            goto aborted;\n-        }\n+        (\"\\tProcessRequest(0x%p): read %d bytes from file\\n\", me, filebytes));\n+    bytes = PR_Read(file, buffer, filebytes);\n+    if (filebytes != bytes) {\n+      rv = PR_FAILURE;\n+      if (Aborted(rv)) {\n+        goto aborted;\n+      }\n+      if (PR_IO_TIMEOUT_ERROR == PR_GetError())\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                 (\"\\t\\tProcessRequest(0x%p): read file timeout\\n\", me));\n+      else\n         TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                 (\"\\t\\tProcessRequest(0x%p): other file open error (%u, %u)\\n\", me,\n+                 (\"\\t\\tProcessRequest(0x%p): other file error (%d, %d)\\n\", me,\n                   PR_GetError(), PR_GetOSError()));\n-        goto aborted;\n+      goto aborted;\n     }\n-    TEST_ASSERT(NULL != file);\n-\n-    netbytes = 0;\n-    while (netbytes < descbytes) {\n-        filebytes = sizeof(buffer);\n-        if ((descbytes - netbytes) < filebytes) {\n-            filebytes = descbytes - netbytes;\n-        }\n-        TEST_LOG(\n-            cltsrv_log_file, TEST_LOG_VERBOSE,\n-            (\"\\tProcessRequest(0x%p): read %d bytes from file\\n\", me, filebytes));\n-        bytes = PR_Read(file, buffer, filebytes);\n-        if (filebytes != bytes) {\n-            rv = PR_FAILURE;\n-            if (Aborted(rv)) {\n-                goto aborted;\n-            }\n-            if (PR_IO_TIMEOUT_ERROR == PR_GetError())\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tProcessRequest(0x%p): read file timeout\\n\", me));\n-            else\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tProcessRequest(0x%p): other file error (%d, %d)\\n\", me,\n-                          PR_GetError(), PR_GetOSError()));\n-            goto aborted;\n-        }\n-        TEST_ASSERT(bytes > 0);\n-        netbytes += bytes;\n-        filebytes = bytes;\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"\\t\\tProcessRequest(0x%p): sending %d bytes\\n\", me, filebytes));\n-        bytes = PR_Send(fd, buffer, filebytes, SEND_FLAGS, timeout);\n-        if (filebytes != bytes) {\n-            rv = PR_FAILURE;\n-            if (Aborted(rv)) {\n-                goto aborted;\n-            }\n-            if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tProcessRequest(0x%p): send data timeout\\n\", me));\n-                goto aborted;\n-            }\n-            break;\n-        }\n-        TEST_ASSERT(bytes > 0);\n+    TEST_ASSERT(bytes > 0);\n+    netbytes += bytes;\n+    filebytes = bytes;\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+             (\"\\t\\tProcessRequest(0x%p): sending %d bytes\\n\", me, filebytes));\n+    bytes = PR_Send(fd, buffer, filebytes, SEND_FLAGS, timeout);\n+    if (filebytes != bytes) {\n+      rv = PR_FAILURE;\n+      if (Aborted(rv)) {\n+        goto aborted;\n+      }\n+      if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                 (\"\\t\\tProcessRequest(0x%p): send data timeout\\n\", me));\n+        goto aborted;\n+      }\n+      break;\n     }\n+    TEST_ASSERT(bytes > 0);\n+  }\n \n-    PR_Lock(server->ml);\n-    server->bytesTransferred += filebytes;\n-    PR_Unlock(server->ml);\n+  PR_Lock(server->ml);\n+  server->bytesTransferred += filebytes;\n+  PR_Unlock(server->ml);\n \n-    rv = PR_Shutdown(fd, PR_SHUTDOWN_BOTH);\n-    if (Aborted(rv)) {\n-        goto aborted;\n-    }\n+  rv = PR_Shutdown(fd, PR_SHUTDOWN_BOTH);\n+  if (Aborted(rv)) {\n+    goto aborted;\n+  }\n \n-    rv = PR_Close(file);\n-    if (Aborted(rv)) {\n-        goto aborted;\n-    }\n-    TEST_ASSERT(PR_SUCCESS == rv);\n-    file = NULL;\n+  rv = PR_Close(file);\n+  if (Aborted(rv)) {\n+    goto aborted;\n+  }\n+  TEST_ASSERT(PR_SUCCESS == rv);\n+  file = NULL;\n \n aborted:\n-    PR_ClearInterrupt();\n-    if (NULL != file) {\n-        PR_Close(file);\n-    }\n-    drv = PR_Delete(descriptor->filename);\n-    TEST_ASSERT(PR_SUCCESS == drv);\n+  PR_ClearInterrupt();\n+  if (NULL != file) {\n+    PR_Close(file);\n+  }\n+  drv = PR_Delete(descriptor->filename);\n+  TEST_ASSERT(PR_SUCCESS == drv);\n exit:\n-    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-             (\"\\t\\tProcessRequest(0x%p): Finished\\n\", me));\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+           (\"\\t\\tProcessRequest(0x%p): Finished\\n\", me));\n \n-    PR_DELETE(descriptor);\n+  PR_DELETE(descriptor);\n \n #if defined(WIN95)\n-    PR_Sleep(PR_MillisecondsToInterval(200)); /* lth. see note [1] */\n+  PR_Sleep(PR_MillisecondsToInterval(200)); /* lth. see note [1] */\n #endif\n-    return rv;\n+  return rv;\n } /* ProcessRequest */\n \n-static PRStatus\n-CreateWorker(CSServer_t* server, CSPool_t* pool)\n-{\n-    CSWorker_t* worker = PR_NEWZAP(CSWorker_t);\n-    worker->server = server;\n-    PR_INIT_CLIST(&worker->element);\n-    worker->thread =\n-        PR_CreateThread(PR_USER_THREAD, Worker, worker, DEFAULT_SERVER_PRIORITY,\n-                        thread_scope, PR_UNJOINABLE_THREAD, 0);\n-    if (NULL == worker->thread) {\n-        PR_DELETE(worker);\n-        return PR_FAILURE;\n-    }\n-\n-    TEST_LOG(cltsrv_log_file, TEST_LOG_STATUS,\n-             (\"\\tCreateWorker(0x%p): create new worker (0x%p)\\n\",\n-              PR_GetCurrentThread(), worker->thread));\n-\n-    return PR_SUCCESS;\n+static PRStatus CreateWorker(CSServer_t* server, CSPool_t* pool) {\n+  CSWorker_t* worker = PR_NEWZAP(CSWorker_t);\n+  worker->server = server;\n+  PR_INIT_CLIST(&worker->element);\n+  worker->thread =\n+      PR_CreateThread(PR_USER_THREAD, Worker, worker, DEFAULT_SERVER_PRIORITY,\n+                      thread_scope, PR_UNJOINABLE_THREAD, 0);\n+  if (NULL == worker->thread) {\n+    PR_DELETE(worker);\n+    return PR_FAILURE;\n+  }\n+\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_STATUS,\n+           (\"\\tCreateWorker(0x%p): create new worker (0x%p)\\n\",\n+            PR_GetCurrentThread(), worker->thread));\n+\n+  return PR_SUCCESS;\n } /* CreateWorker */\n \n-static void PR_CALLBACK\n-Worker(void* arg)\n-{\n-    PRStatus rv;\n-    PRNetAddr from;\n-    PRFileDesc* fd = NULL;\n-    PRThread* me = PR_GetCurrentThread();\n-    CSWorker_t* worker = (CSWorker_t*)arg;\n-    CSServer_t* server = worker->server;\n-    CSPool_t* pool = &server->pool;\n+static void PR_CALLBACK Worker(void* arg) {\n+  PRStatus rv;\n+  PRNetAddr from;\n+  PRFileDesc* fd = NULL;\n+  PRThread* me = PR_GetCurrentThread();\n+  CSWorker_t* worker = (CSWorker_t*)arg;\n+  CSServer_t* server = worker->server;\n+  CSPool_t* pool = &server->pool;\n+\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+           (\"\\t\\tWorker(0x%p): started [%u]\\n\", me, pool->workers + 1));\n+\n+  PR_Lock(server->ml);\n+  PR_APPEND_LINK(&worker->element, &server->list);\n+  pool->workers += 1; /* define our existance */\n+\n+  while (cs_run == server->state) {\n+    while (pool->accepting >= server->workers.accepting) {\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+               (\"\\t\\tWorker(0x%p): waiting for accept slot[%d]\\n\", me,\n+                pool->accepting));\n+      rv = PR_WaitCondVar(pool->acceptComplete, PR_INTERVAL_NO_TIMEOUT);\n+      if (Aborted(rv) || (cs_run != server->state)) {\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+                 (\"\\tWorker(0x%p): has been %s\\n\", me,\n+                  (Aborted(rv) ? \"interrupted\" : \"stopped\")));\n+        goto exit;\n+      }\n+    }\n+    pool->accepting += 1; /* how many are really in accept */\n+    PR_Unlock(server->ml);\n \n-    TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-             (\"\\t\\tWorker(0x%p): started [%u]\\n\", me, pool->workers + 1));\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+             (\"\\t\\tWorker(0x%p): calling accept\\n\", me));\n+    fd = PR_Accept(server->listener, &from, PR_INTERVAL_NO_TIMEOUT);\n \n     PR_Lock(server->ml);\n-    PR_APPEND_LINK(&worker->element, &server->list);\n-    pool->workers += 1; /* define our existance */\n-\n-    while (cs_run == server->state) {\n-        while (pool->accepting >= server->workers.accepting) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                     (\"\\t\\tWorker(0x%p): waiting for accept slot[%d]\\n\", me,\n-                      pool->accepting));\n-            rv = PR_WaitCondVar(pool->acceptComplete, PR_INTERVAL_NO_TIMEOUT);\n-            if (Aborted(rv) || (cs_run != server->state)) {\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-                         (\"\\tWorker(0x%p): has been %s\\n\", me,\n-                          (Aborted(rv) ? \"interrupted\" : \"stopped\")));\n-                goto exit;\n-            }\n-        }\n-        pool->accepting += 1; /* how many are really in accept */\n-        PR_Unlock(server->ml);\n-\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"\\t\\tWorker(0x%p): calling accept\\n\", me));\n-        fd = PR_Accept(server->listener, &from, PR_INTERVAL_NO_TIMEOUT);\n-\n-        PR_Lock(server->ml);\n-        pool->accepting -= 1;\n-        PR_NotifyCondVar(pool->acceptComplete);\n-\n-        if ((NULL == fd) && Aborted(PR_FAILURE)) {\n-            if (NULL != server->listener) {\n-                PR_Close(server->listener);\n-                server->listener = NULL;\n-            }\n-            goto exit;\n-        }\n+    pool->accepting -= 1;\n+    PR_NotifyCondVar(pool->acceptComplete);\n \n-        if (NULL != fd) {\n-            /*\n-            ** Create another worker of the total number of workers is\n-            ** less than the minimum specified or we have none left in\n-            ** accept() AND we're not over the maximum.\n-            ** This sort of presumes that the number allowed in accept\n-            ** is at least as many as the minimum. Otherwise we'll keep\n-            ** creating new threads and deleting them soon after.\n-            */\n-            PRBool another = ((pool->workers < server->workers.minimum) ||\n-                              ((0 == pool->accepting) &&\n-                               (pool->workers < server->workers.maximum)))\n-                                 ? PR_TRUE\n-                                 : PR_FALSE;\n-            pool->active += 1;\n-            PR_Unlock(server->ml);\n-\n-            if (another) {\n-                (void)CreateWorker(server, pool);\n-            }\n-\n-            rv = ProcessRequest(fd, server);\n-            if (PR_SUCCESS != rv)\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tWorker(0x%p): server process ended abnormally\\n\", me));\n-            (void)PR_Close(fd);\n-            fd = NULL;\n-\n-            PR_Lock(server->ml);\n-            pool->active -= 1;\n-        }\n+    if ((NULL == fd) && Aborted(PR_FAILURE)) {\n+      if (NULL != server->listener) {\n+        PR_Close(server->listener);\n+        server->listener = NULL;\n+      }\n+      goto exit;\n     }\n \n-exit:\n-    PR_ClearInterrupt();\n-    PR_Unlock(server->ml);\n-\n     if (NULL != fd) {\n-        (void)PR_Shutdown(fd, PR_SHUTDOWN_BOTH);\n-        (void)PR_Close(fd);\n-    }\n-\n-    TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-             (\"\\t\\tWorker(0x%p): exiting [%u]\\n\", PR_GetCurrentThread(),\n-              pool->workers));\n-\n-    PR_Lock(server->ml);\n-    pool->workers -= 1; /* undefine our existance */\n-    PR_REMOVE_AND_INIT_LINK(&worker->element);\n-    PR_NotifyCondVar(pool->exiting);\n-    PR_Unlock(server->ml);\n+      /*\n+      ** Create another worker of the total number of workers is\n+      ** less than the minimum specified or we have none left in\n+      ** accept() AND we're not over the maximum.\n+      ** This sort of presumes that the number allowed in accept\n+      ** is at least as many as the minimum. Otherwise we'll keep\n+      ** creating new threads and deleting them soon after.\n+      */\n+      PRBool another = ((pool->workers < server->workers.minimum) ||\n+                        ((0 == pool->accepting) &&\n+                         (pool->workers < server->workers.maximum)))\n+                           ? PR_TRUE\n+                           : PR_FALSE;\n+      pool->active += 1;\n+      PR_Unlock(server->ml);\n+\n+      if (another) {\n+        (void)CreateWorker(server, pool);\n+      }\n+\n+      rv = ProcessRequest(fd, server);\n+      if (PR_SUCCESS != rv)\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                 (\"\\t\\tWorker(0x%p): server process ended abnormally\\n\", me));\n+      (void)PR_Close(fd);\n+      fd = NULL;\n \n-    PR_DELETE(worker); /* destruction of the \"worker\" object */\n+      PR_Lock(server->ml);\n+      pool->active -= 1;\n+    }\n+  }\n \n-} /* Worker */\n+exit:\n+  PR_ClearInterrupt();\n+  PR_Unlock(server->ml);\n \n-static void PR_CALLBACK\n-Server(void* arg)\n-{\n-    PRStatus rv;\n-    PRNetAddr serverAddress;\n-    PRThread* me = PR_GetCurrentThread();\n-    CSServer_t* server = (CSServer_t*)arg;\n-    PRSocketOptionData sockOpt;\n+  if (NULL != fd) {\n+    (void)PR_Shutdown(fd, PR_SHUTDOWN_BOTH);\n+    (void)PR_Close(fd);\n+  }\n \n-    server->listener = PR_Socket(domain, SOCK_STREAM, protocol);\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+           (\"\\t\\tWorker(0x%p): exiting [%u]\\n\", PR_GetCurrentThread(),\n+            pool->workers));\n \n-    sockOpt.option = PR_SockOpt_Reuseaddr;\n-    sockOpt.value.reuse_addr = PR_TRUE;\n-    rv = PR_SetSocketOption(server->listener, &sockOpt);\n-    TEST_ASSERT(PR_SUCCESS == rv);\n+  PR_Lock(server->ml);\n+  pool->workers -= 1; /* undefine our existance */\n+  PR_REMOVE_AND_INIT_LINK(&worker->element);\n+  PR_NotifyCondVar(pool->exiting);\n+  PR_Unlock(server->ml);\n \n-    memset(&serverAddress, 0, sizeof(serverAddress));\n-    if (PR_AF_INET6 != domain) {\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n-                 (\"server binding to ip port %s\\n\", DEFAULT_PORT));\n-        rv = PR_InitializeNetAddr(PR_IpAddrAny, DEFAULT_PORT, &serverAddress);\n-    } else {\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n-                 (\"server binding to ipv6 port %s\\n\", DEFAULT_PORT));\n-        rv = PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, DEFAULT_PORT, &serverAddress);\n-    }\n-    rv = PR_Bind(server->listener, &serverAddress);\n-    TEST_ASSERT(PR_SUCCESS == rv);\n+  PR_DELETE(worker); /* destruction of the \"worker\" object */\n \n-    rv = PR_Listen(server->listener, server->backlog);\n-    TEST_ASSERT(PR_SUCCESS == rv);\n+} /* Worker */\n \n-    server->started = PR_IntervalNow();\n-    TimeOfDayMessage(\"Server started at\", me);\n+static void PR_CALLBACK Server(void* arg) {\n+  PRStatus rv;\n+  PRNetAddr serverAddress;\n+  PRThread* me = PR_GetCurrentThread();\n+  CSServer_t* server = (CSServer_t*)arg;\n+  PRSocketOptionData sockOpt;\n \n-    PR_Lock(server->ml);\n-    server->state = cs_run;\n-    PR_NotifyCondVar(server->stateChange);\n-    PR_Unlock(server->ml);\n+  server->listener = PR_Socket(domain, SOCK_STREAM, protocol);\n \n-    /*\n-    ** Create the first worker (actually, a thread that accepts\n-    ** connections and then processes the work load as needed).\n-    ** From this point on, additional worker threads are created\n-    ** as they are needed by existing worker threads.\n-    */\n-    rv = CreateWorker(server, &server->pool);\n-    TEST_ASSERT(PR_SUCCESS == rv);\n+  sockOpt.option = PR_SockOpt_Reuseaddr;\n+  sockOpt.value.reuse_addr = PR_TRUE;\n+  rv = PR_SetSocketOption(server->listener, &sockOpt);\n+  TEST_ASSERT(PR_SUCCESS == rv);\n \n-    /*\n-    ** From here on this thread is merely hanging around as the contact\n-    ** point for the main test driver. It's just waiting for the driver\n-    ** to declare the test complete.\n-    */\n+  memset(&serverAddress, 0, sizeof(serverAddress));\n+  if (PR_AF_INET6 != domain) {\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n+             (\"server binding to ip port %s\\n\", DEFAULT_PORT));\n+    rv = PR_InitializeNetAddr(PR_IpAddrAny, DEFAULT_PORT, &serverAddress);\n+  } else {\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n+             (\"server binding to ipv6 port %s\\n\", DEFAULT_PORT));\n+    rv = PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, DEFAULT_PORT, &serverAddress);\n+  }\n+  rv = PR_Bind(server->listener, &serverAddress);\n+  TEST_ASSERT(PR_SUCCESS == rv);\n+\n+  rv = PR_Listen(server->listener, server->backlog);\n+  TEST_ASSERT(PR_SUCCESS == rv);\n+\n+  server->started = PR_IntervalNow();\n+  TimeOfDayMessage(\"Server started at\", me);\n+\n+  PR_Lock(server->ml);\n+  server->state = cs_run;\n+  PR_NotifyCondVar(server->stateChange);\n+  PR_Unlock(server->ml);\n+\n+  /*\n+  ** Create the first worker (actually, a thread that accepts\n+  ** connections and then processes the work load as needed).\n+  ** From this point on, additional worker threads are created\n+  ** as they are needed by existing worker threads.\n+  */\n+  rv = CreateWorker(server, &server->pool);\n+  TEST_ASSERT(PR_SUCCESS == rv);\n+\n+  /*\n+  ** From here on this thread is merely hanging around as the contact\n+  ** point for the main test driver. It's just waiting for the driver\n+  ** to declare the test complete.\n+  */\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+           (\"\\tServer(0x%p): waiting for state change\\n\", me));\n+\n+  PR_Lock(server->ml);\n+  while ((cs_run == server->state) && !Aborted(rv)) {\n+    rv = PR_WaitCondVar(server->stateChange, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_Unlock(server->ml);\n+  PR_ClearInterrupt();\n+\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n+           (\"\\tServer(0x%p): shutting down workers\\n\", me));\n+\n+  /*\n+  ** Get all the worker threads to exit. They know how to\n+  ** clean up after themselves, so this is just a matter of\n+  ** waiting for clorine in the pool to take effect. During\n+  ** this stage we're ignoring interrupts.\n+  */\n+  server->workers.minimum = server->workers.maximum = 0;\n+\n+  PR_Lock(server->ml);\n+  while (!PR_CLIST_IS_EMPTY(&server->list)) {\n+    PRCList* head = PR_LIST_HEAD(&server->list);\n+    CSWorker_t* worker = (CSWorker_t*)head;\n     TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-             (\"\\tServer(0x%p): waiting for state change\\n\", me));\n-\n-    PR_Lock(server->ml);\n-    while ((cs_run == server->state) && !Aborted(rv)) {\n-        rv = PR_WaitCondVar(server->stateChange, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_Unlock(server->ml);\n-    PR_ClearInterrupt();\n-\n-    TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n-             (\"\\tServer(0x%p): shutting down workers\\n\", me));\n-\n-    /*\n-    ** Get all the worker threads to exit. They know how to\n-    ** clean up after themselves, so this is just a matter of\n-    ** waiting for clorine in the pool to take effect. During\n-    ** this stage we're ignoring interrupts.\n-    */\n-    server->workers.minimum = server->workers.maximum = 0;\n-\n-    PR_Lock(server->ml);\n-    while (!PR_CLIST_IS_EMPTY(&server->list)) {\n-        PRCList* head = PR_LIST_HEAD(&server->list);\n-        CSWorker_t* worker = (CSWorker_t*)head;\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"\\tServer(0x%p): interrupting worker(0x%p)\\n\", me, worker));\n-        rv = PR_Interrupt(worker->thread);\n-        TEST_ASSERT(PR_SUCCESS == rv);\n-        PR_REMOVE_AND_INIT_LINK(head);\n-    }\n+             (\"\\tServer(0x%p): interrupting worker(0x%p)\\n\", me, worker));\n+    rv = PR_Interrupt(worker->thread);\n+    TEST_ASSERT(PR_SUCCESS == rv);\n+    PR_REMOVE_AND_INIT_LINK(head);\n+  }\n \n-    while (server->pool.workers > 0) {\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-                 (\"\\tServer(0x%p): waiting for %u workers to exit\\n\", me,\n-                  server->pool.workers));\n-        (void)PR_WaitCondVar(server->pool.exiting, PR_INTERVAL_NO_TIMEOUT);\n-    }\n+  while (server->pool.workers > 0) {\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+             (\"\\tServer(0x%p): waiting for %u workers to exit\\n\", me,\n+              server->pool.workers));\n+    (void)PR_WaitCondVar(server->pool.exiting, PR_INTERVAL_NO_TIMEOUT);\n+  }\n \n-    server->state = cs_exit;\n-    PR_NotifyCondVar(server->stateChange);\n-    PR_Unlock(server->ml);\n+  server->state = cs_exit;\n+  PR_NotifyCondVar(server->stateChange);\n+  PR_Unlock(server->ml);\n \n-    TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n-             (\"\\tServer(0x%p): stopped after %u operations and %u bytes\\n\", me,\n-              server->operations, server->bytesTransferred));\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n+           (\"\\tServer(0x%p): stopped after %u operations and %u bytes\\n\", me,\n+            server->operations, server->bytesTransferred));\n \n-    if (NULL != server->listener) {\n-        PR_Close(server->listener);\n-    }\n-    server->stopped = PR_IntervalNow();\n+  if (NULL != server->listener) {\n+    PR_Close(server->listener);\n+  }\n+  server->stopped = PR_IntervalNow();\n \n } /* Server */\n \n-static void\n-WaitForCompletion(PRIntn execution)\n-{\n-    while (execution > 0) {\n-        PRIntn dally = (execution > 30) ? 30 : execution;\n-        PR_Sleep(PR_SecondsToInterval(dally));\n-        if (pthread_stats) {\n-            PT_FPrintStats(debug_out, \"\\nPThread Statistics\\n\");\n-        }\n-        execution -= dally;\n+static void WaitForCompletion(PRIntn execution) {\n+  while (execution > 0) {\n+    PRIntn dally = (execution > 30) ? 30 : execution;\n+    PR_Sleep(PR_SecondsToInterval(dally));\n+    if (pthread_stats) {\n+      PT_FPrintStats(debug_out, \"\\nPThread Statistics\\n\");\n     }\n+    execution -= dally;\n+  }\n } /* WaitForCompletion */\n \n-static void\n-Help(void)\n-{\n-    PR_fprintf(debug_out, \"cltsrv test program usage:\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-a <n>       threads allowed in accept        (5)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-b <n>       backlock for listen              (5)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-c <threads> number of clients to create      (1)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-f <low>     low water mark for fd caching    (0)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-F <high>    high water mark for fd caching   (0)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-w <threads> minimal number of server threads (1)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-W <threads> maximum number of server threads (1)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-e <seconds> duration of the test in seconds  (10)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-s <string>  dsn name of server               (localhost)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-G           use GLOBAL threads               (LOCAL)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-X           use XTP as transport             (TCP)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-6           Use IPv6                         (IPv4)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-v           verbosity (accumulative)         (0)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-p           pthread statistics               (FALSE)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-d           debug mode                       (FALSE)\\n\");\n-    PR_fprintf(debug_out, \"\\t-h           this message\\n\");\n+static void Help(void) {\n+  PR_fprintf(debug_out, \"cltsrv test program usage:\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-a <n>       threads allowed in accept        (5)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-b <n>       backlock for listen              (5)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-c <threads> number of clients to create      (1)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-f <low>     low water mark for fd caching    (0)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-F <high>    high water mark for fd caching   (0)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-w <threads> minimal number of server threads (1)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-W <threads> maximum number of server threads (1)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-e <seconds> duration of the test in seconds  (10)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-s <string>  dsn name of server               (localhost)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-G           use GLOBAL threads               (LOCAL)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-X           use XTP as transport             (TCP)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-6           Use IPv6                         (IPv4)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-v           verbosity (accumulative)         (0)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-p           pthread statistics               (FALSE)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-d           debug mode                       (FALSE)\\n\");\n+  PR_fprintf(debug_out, \"\\t-h           this message\\n\");\n } /* Help */\n \n-static Verbosity\n-IncrementVerbosity(void)\n-{\n-    PRIntn verboge = (PRIntn)verbosity + 1;\n-    return (Verbosity)verboge;\n+static Verbosity IncrementVerbosity(void) {\n+  PRIntn verboge = (PRIntn)verbosity + 1;\n+  return (Verbosity)verboge;\n } /* IncrementVerbosity */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRUintn index;\n-    PRBool boolean;\n-    CSClient_t* client;\n-    PRStatus rv, joinStatus;\n-    CSServer_t* server = NULL;\n-\n-    PRUintn backlog = DEFAULT_BACKLOG;\n-    PRUintn clients = DEFAULT_CLIENTS;\n-    const char* serverName = DEFAULT_SERVER;\n-    PRBool serverIsLocal = PR_TRUE;\n-    PRUintn accepting = ALLOWED_IN_ACCEPT;\n-    PRUintn workersMin = DEFAULT_WORKERS_MIN;\n-    PRUintn workersMax = DEFAULT_WORKERS_MAX;\n-    PRIntn execution = DEFAULT_EXECUTION_TIME;\n-    PRIntn low = DEFAULT_LOW, high = DEFAULT_HIGH;\n-\n-    /*\n-     * -G           use global threads\n-     * -a <n>       threads allowed in accept\n-     * -b <n>       backlock for listen\n-     * -c <threads> number of clients to create\n-     * -f <low>     low water mark for caching FDs\n-     * -F <high>    high water mark for caching FDs\n-     * -w <threads> minimal number of server threads\n-     * -W <threads> maximum number of server threads\n-     * -e <seconds> duration of the test in seconds\n-     * -s <string>  dsn name of server (implies no server here)\n-     * -v           verbosity\n-     */\n-\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"GX6b:a:c:f:F:w:W:e:s:vdhp\");\n-\n-    debug_out = PR_GetSpecialFD(PR_StandardError);\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'G': /* use global threads */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'X': /* use XTP as transport */\n-                protocol = 36;\n-                break;\n-            case '6': /* Use IPv6 */\n-                domain = PR_AF_INET6;\n-                break;\n-            case 'a': /* the value for accepting */\n-                accepting = atoi(opt->value);\n-                break;\n-            case 'b': /* the value for backlock */\n-                backlog = atoi(opt->value);\n-                break;\n-            case 'c': /* number of client threads */\n-                clients = atoi(opt->value);\n-                break;\n-            case 'f': /* low water fd cache */\n-                low = atoi(opt->value);\n-                break;\n-            case 'F': /* low water fd cache */\n-                high = atoi(opt->value);\n-                break;\n-            case 'w': /* minimum server worker threads */\n-                workersMin = atoi(opt->value);\n-                break;\n-            case 'W': /* maximum server worker threads */\n-                workersMax = atoi(opt->value);\n-                break;\n-            case 'e': /* program execution time in seconds */\n-                execution = atoi(opt->value);\n-                break;\n-            case 's': /* server's address */\n-                serverName = opt->value;\n-                break;\n-            case 'v': /* verbosity */\n-                verbosity = IncrementVerbosity();\n-                break;\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            case 'p': /* pthread mode */\n-                pthread_stats = PR_TRUE;\n-                break;\n-            case 'h':\n-            default:\n-                Help();\n-                return 2;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    if (0 != PL_strcmp(serverName, DEFAULT_SERVER)) {\n-        serverIsLocal = PR_FALSE;\n-    }\n-    if (0 == execution) {\n-        execution = DEFAULT_EXECUTION_TIME;\n+int main(int argc, char** argv) {\n+  PRUintn index;\n+  PRBool boolean;\n+  CSClient_t* client;\n+  PRStatus rv, joinStatus;\n+  CSServer_t* server = NULL;\n+\n+  PRUintn backlog = DEFAULT_BACKLOG;\n+  PRUintn clients = DEFAULT_CLIENTS;\n+  const char* serverName = DEFAULT_SERVER;\n+  PRBool serverIsLocal = PR_TRUE;\n+  PRUintn accepting = ALLOWED_IN_ACCEPT;\n+  PRUintn workersMin = DEFAULT_WORKERS_MIN;\n+  PRUintn workersMax = DEFAULT_WORKERS_MAX;\n+  PRIntn execution = DEFAULT_EXECUTION_TIME;\n+  PRIntn low = DEFAULT_LOW, high = DEFAULT_HIGH;\n+\n+  /*\n+   * -G           use global threads\n+   * -a <n>       threads allowed in accept\n+   * -b <n>       backlock for listen\n+   * -c <threads> number of clients to create\n+   * -f <low>     low water mark for caching FDs\n+   * -F <high>    high water mark for caching FDs\n+   * -w <threads> minimal number of server threads\n+   * -W <threads> maximum number of server threads\n+   * -e <seconds> duration of the test in seconds\n+   * -s <string>  dsn name of server (implies no server here)\n+   * -v           verbosity\n+   */\n+\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"GX6b:a:c:f:F:w:W:e:s:vdhp\");\n+\n+  debug_out = PR_GetSpecialFD(PR_StandardError);\n+\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    if (0 == workersMax) {\n-        workersMax = DEFAULT_WORKERS_MAX;\n-    }\n-    if (0 == workersMin) {\n-        workersMin = DEFAULT_WORKERS_MIN;\n-    }\n-    if (0 == accepting) {\n-        accepting = ALLOWED_IN_ACCEPT;\n-    }\n-    if (0 == backlog) {\n-        backlog = DEFAULT_BACKLOG;\n+    switch (opt->option) {\n+      case 'G': /* use global threads */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'X': /* use XTP as transport */\n+        protocol = 36;\n+        break;\n+      case '6': /* Use IPv6 */\n+        domain = PR_AF_INET6;\n+        break;\n+      case 'a': /* the value for accepting */\n+        accepting = atoi(opt->value);\n+        break;\n+      case 'b': /* the value for backlock */\n+        backlog = atoi(opt->value);\n+        break;\n+      case 'c': /* number of client threads */\n+        clients = atoi(opt->value);\n+        break;\n+      case 'f': /* low water fd cache */\n+        low = atoi(opt->value);\n+        break;\n+      case 'F': /* low water fd cache */\n+        high = atoi(opt->value);\n+        break;\n+      case 'w': /* minimum server worker threads */\n+        workersMin = atoi(opt->value);\n+        break;\n+      case 'W': /* maximum server worker threads */\n+        workersMax = atoi(opt->value);\n+        break;\n+      case 'e': /* program execution time in seconds */\n+        execution = atoi(opt->value);\n+        break;\n+      case 's': /* server's address */\n+        serverName = opt->value;\n+        break;\n+      case 'v': /* verbosity */\n+        verbosity = IncrementVerbosity();\n+        break;\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      case 'p': /* pthread mode */\n+        pthread_stats = PR_TRUE;\n+        break;\n+      case 'h':\n+      default:\n+        Help();\n+        return 2;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  if (0 != PL_strcmp(serverName, DEFAULT_SERVER)) {\n+    serverIsLocal = PR_FALSE;\n+  }\n+  if (0 == execution) {\n+    execution = DEFAULT_EXECUTION_TIME;\n+  }\n+  if (0 == workersMax) {\n+    workersMax = DEFAULT_WORKERS_MAX;\n+  }\n+  if (0 == workersMin) {\n+    workersMin = DEFAULT_WORKERS_MIN;\n+  }\n+  if (0 == accepting) {\n+    accepting = ALLOWED_IN_ACCEPT;\n+  }\n+  if (0 == backlog) {\n+    backlog = DEFAULT_BACKLOG;\n+  }\n+\n+  if (workersMin > accepting) {\n+    accepting = workersMin;\n+  }\n+\n+  TimeOfDayMessage(\"Client/Server started at\", PR_GetCurrentThread());\n+\n+  cltsrv_log_file = PR_NewLogModule(\"cltsrv_log\");\n+  MY_ASSERT(NULL != cltsrv_log_file);\n+  boolean = PR_SetLogFile(\"cltsrv.log\");\n+  MY_ASSERT(boolean);\n+\n+  rv = PR_SetFDCacheSize(low, high);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+\n+  if (serverIsLocal) {\n+    /* Establish the server */\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n+             (\"main(0x%p): starting server\\n\", PR_GetCurrentThread()));\n+\n+    server = PR_NEWZAP(CSServer_t);\n+    PR_INIT_CLIST(&server->list);\n+    server->state = cs_init;\n+    server->ml = PR_NewLock();\n+    server->backlog = backlog;\n+    server->port = DEFAULT_PORT;\n+    server->workers.minimum = workersMin;\n+    server->workers.maximum = workersMax;\n+    server->workers.accepting = accepting;\n+    server->stateChange = PR_NewCondVar(server->ml);\n+    server->pool.exiting = PR_NewCondVar(server->ml);\n+    server->pool.acceptComplete = PR_NewCondVar(server->ml);\n \n-    if (workersMin > accepting) {\n-        accepting = workersMin;\n-    }\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+             (\"main(0x%p): creating server thread\\n\", PR_GetCurrentThread()));\n \n-    TimeOfDayMessage(\"Client/Server started at\", PR_GetCurrentThread());\n-\n-    cltsrv_log_file = PR_NewLogModule(\"cltsrv_log\");\n-    MY_ASSERT(NULL != cltsrv_log_file);\n-    boolean = PR_SetLogFile(\"cltsrv.log\");\n-    MY_ASSERT(boolean);\n-\n-    rv = PR_SetFDCacheSize(low, high);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-\n-    if (serverIsLocal) {\n-        /* Establish the server */\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n-                 (\"main(0x%p): starting server\\n\", PR_GetCurrentThread()));\n-\n-        server = PR_NEWZAP(CSServer_t);\n-        PR_INIT_CLIST(&server->list);\n-        server->state = cs_init;\n-        server->ml = PR_NewLock();\n-        server->backlog = backlog;\n-        server->port = DEFAULT_PORT;\n-        server->workers.minimum = workersMin;\n-        server->workers.maximum = workersMax;\n-        server->workers.accepting = accepting;\n-        server->stateChange = PR_NewCondVar(server->ml);\n-        server->pool.exiting = PR_NewCondVar(server->ml);\n-        server->pool.acceptComplete = PR_NewCondVar(server->ml);\n+    server->thread =\n+        PR_CreateThread(PR_USER_THREAD, Server, server, PR_PRIORITY_HIGH,\n+                        thread_scope, PR_JOINABLE_THREAD, 0);\n+    TEST_ASSERT(NULL != server->thread);\n \n-        TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-                 (\"main(0x%p): creating server thread\\n\", PR_GetCurrentThread()));\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+             (\"main(0x%p): waiting for server init\\n\", PR_GetCurrentThread()));\n \n-        server->thread =\n-            PR_CreateThread(PR_USER_THREAD, Server, server, PR_PRIORITY_HIGH,\n-                            thread_scope, PR_JOINABLE_THREAD, 0);\n-        TEST_ASSERT(NULL != server->thread);\n+    PR_Lock(server->ml);\n+    while (server->state == cs_init) {\n+      PR_WaitCondVar(server->stateChange, PR_INTERVAL_NO_TIMEOUT);\n+    }\n+    PR_Unlock(server->ml);\n \n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"main(0x%p): waiting for server init\\n\", PR_GetCurrentThread()));\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+             (\"main(0x%p): server init complete (port #%d)\\n\",\n+              PR_GetCurrentThread(), server->port));\n+  }\n \n-        PR_Lock(server->ml);\n-        while (server->state == cs_init) {\n-            PR_WaitCondVar(server->stateChange, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        PR_Unlock(server->ml);\n+  if (clients != 0) {\n+    /* Create all of the clients */\n+    PRHostEnt host;\n+    char buffer[BUFFER_SIZE];\n+    client = (CSClient_t*)PR_CALLOC(clients * sizeof(CSClient_t));\n \n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"main(0x%p): server init complete (port #%d)\\n\",\n-                  PR_GetCurrentThread(), server->port));\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+             (\"main(0x%p): creating %d client threads\\n\", PR_GetCurrentThread(),\n+              clients));\n+\n+    if (!serverIsLocal) {\n+      rv = PR_GetHostByName(serverName, buffer, BUFFER_SIZE, &host);\n+      if (PR_SUCCESS != rv) {\n+        PL_FPrintError(PR_STDERR, \"PR_GetHostByName\");\n+        return 2;\n+      }\n     }\n \n-    if (clients != 0) {\n-        /* Create all of the clients */\n-        PRHostEnt host;\n-        char buffer[BUFFER_SIZE];\n-        client = (CSClient_t*)PR_CALLOC(clients * sizeof(CSClient_t));\n-\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"main(0x%p): creating %d client threads\\n\", PR_GetCurrentThread(),\n-                  clients));\n-\n-        if (!serverIsLocal) {\n-            rv = PR_GetHostByName(serverName, buffer, BUFFER_SIZE, &host);\n-            if (PR_SUCCESS != rv) {\n-                PL_FPrintError(PR_STDERR, \"PR_GetHostByName\");\n-                return 2;\n-            }\n-        }\n-\n-        for (index = 0; index < clients; ++index) {\n-            client[index].state = cs_init;\n-            client[index].ml = PR_NewLock();\n-            if (serverIsLocal) {\n-                if (PR_AF_INET6 != domain) {\n-                    TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n-                             (\"loopback client ip port %s\\n\", DEFAULT_PORT));\n-                    (void)PR_InitializeNetAddr(PR_IpAddrLoopback, DEFAULT_PORT,\n-                                               &client[index].serverAddress);\n-                } else {\n-                    TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n-                             (\"loopback client ipv6 port %s\\n\", DEFAULT_PORT));\n-                    rv = PR_SetNetAddr(PR_IpAddrLoopback, PR_AF_INET6, DEFAULT_PORT,\n-                                       &client[index].serverAddress);\n-                }\n-            } else {\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n-                         (\"client enumerate port %s\\n\", DEFAULT_PORT));\n-                (void)PR_EnumerateHostEnt(0, &host, DEFAULT_PORT,\n-                                          &client[index].serverAddress);\n-            }\n-            client[index].stateChange = PR_NewCondVar(client[index].ml);\n-            TEST_LOG(\n-                cltsrv_log_file, TEST_LOG_INFO,\n-                (\"main(0x%p): creating client threads\\n\", PR_GetCurrentThread()));\n-            client[index].thread = PR_CreateThread(\n-                PR_USER_THREAD, Client, &client[index], PR_PRIORITY_NORMAL,\n-                thread_scope, PR_JOINABLE_THREAD, 0);\n-            TEST_ASSERT(NULL != client[index].thread);\n-            PR_Lock(client[index].ml);\n-            while (cs_init == client[index].state) {\n-                PR_WaitCondVar(client[index].stateChange, PR_INTERVAL_NO_TIMEOUT);\n-            }\n-            PR_Unlock(client[index].ml);\n+    for (index = 0; index < clients; ++index) {\n+      client[index].state = cs_init;\n+      client[index].ml = PR_NewLock();\n+      if (serverIsLocal) {\n+        if (PR_AF_INET6 != domain) {\n+          TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n+                   (\"loopback client ip port %s\\n\", DEFAULT_PORT));\n+          (void)PR_InitializeNetAddr(PR_IpAddrLoopback, DEFAULT_PORT,\n+                                     &client[index].serverAddress);\n+        } else {\n+          TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n+                   (\"loopback client ipv6 port %s\\n\", DEFAULT_PORT));\n+          rv = PR_SetNetAddr(PR_IpAddrLoopback, PR_AF_INET6, DEFAULT_PORT,\n+                             &client[index].serverAddress);\n         }\n+      } else {\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n+                 (\"client enumerate port %s\\n\", DEFAULT_PORT));\n+        (void)PR_EnumerateHostEnt(0, &host, DEFAULT_PORT,\n+                                  &client[index].serverAddress);\n+      }\n+      client[index].stateChange = PR_NewCondVar(client[index].ml);\n+      TEST_LOG(\n+          cltsrv_log_file, TEST_LOG_INFO,\n+          (\"main(0x%p): creating client threads\\n\", PR_GetCurrentThread()));\n+      client[index].thread = PR_CreateThread(\n+          PR_USER_THREAD, Client, &client[index], PR_PRIORITY_NORMAL,\n+          thread_scope, PR_JOINABLE_THREAD, 0);\n+      TEST_ASSERT(NULL != client[index].thread);\n+      PR_Lock(client[index].ml);\n+      while (cs_init == client[index].state) {\n+        PR_WaitCondVar(client[index].stateChange, PR_INTERVAL_NO_TIMEOUT);\n+      }\n+      PR_Unlock(client[index].ml);\n     }\n-\n-    /* Then just let them go at it for a bit */\n-    TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n-             (\"main(0x%p): waiting for execution interval (%d seconds)\\n\",\n-              PR_GetCurrentThread(), execution));\n-\n-    WaitForCompletion(execution);\n-\n-    TimeOfDayMessage(\"Shutting down\", PR_GetCurrentThread());\n-\n-    if (clients != 0) {\n-        for (index = 0; index < clients; ++index) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_STATUS,\n-                     (\"main(0x%p): notifying client(0x%p) to stop\\n\",\n-                      PR_GetCurrentThread(), client[index].thread));\n-\n-            PR_Lock(client[index].ml);\n-            if (cs_run == client[index].state) {\n-                client[index].state = cs_stop;\n-                PR_Interrupt(client[index].thread);\n-                while (cs_stop == client[index].state)\n-                    PR_WaitCondVar(client[index].stateChange, PR_INTERVAL_NO_TIMEOUT);\n-            }\n-            PR_Unlock(client[index].ml);\n-\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                     (\"main(0x%p): joining client(0x%p)\\n\", PR_GetCurrentThread(),\n-                      client[index].thread));\n-\n-            joinStatus = PR_JoinThread(client[index].thread);\n-            TEST_ASSERT(PR_SUCCESS == joinStatus);\n-            PR_DestroyCondVar(client[index].stateChange);\n-            PR_DestroyLock(client[index].ml);\n-        }\n-        PR_DELETE(client);\n+  }\n+\n+  /* Then just let them go at it for a bit */\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n+           (\"main(0x%p): waiting for execution interval (%d seconds)\\n\",\n+            PR_GetCurrentThread(), execution));\n+\n+  WaitForCompletion(execution);\n+\n+  TimeOfDayMessage(\"Shutting down\", PR_GetCurrentThread());\n+\n+  if (clients != 0) {\n+    for (index = 0; index < clients; ++index) {\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_STATUS,\n+               (\"main(0x%p): notifying client(0x%p) to stop\\n\",\n+                PR_GetCurrentThread(), client[index].thread));\n+\n+      PR_Lock(client[index].ml);\n+      if (cs_run == client[index].state) {\n+        client[index].state = cs_stop;\n+        PR_Interrupt(client[index].thread);\n+        while (cs_stop == client[index].state)\n+          PR_WaitCondVar(client[index].stateChange, PR_INTERVAL_NO_TIMEOUT);\n+      }\n+      PR_Unlock(client[index].ml);\n+\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+               (\"main(0x%p): joining client(0x%p)\\n\", PR_GetCurrentThread(),\n+                client[index].thread));\n+\n+      joinStatus = PR_JoinThread(client[index].thread);\n+      TEST_ASSERT(PR_SUCCESS == joinStatus);\n+      PR_DestroyCondVar(client[index].stateChange);\n+      PR_DestroyLock(client[index].ml);\n     }\n+    PR_DELETE(client);\n+  }\n \n-    if (NULL != server) {\n-        /* All clients joined - retrieve the server */\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-                 (\"main(0x%p): notifying server(0x%p) to stop\\n\",\n-                  PR_GetCurrentThread(), server->thread));\n-\n-        PR_Lock(server->ml);\n-        server->state = cs_stop;\n-        PR_Interrupt(server->thread);\n-        while (cs_exit != server->state) {\n-            PR_WaitCondVar(server->stateChange, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        PR_Unlock(server->ml);\n+  if (NULL != server) {\n+    /* All clients joined - retrieve the server */\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+             (\"main(0x%p): notifying server(0x%p) to stop\\n\",\n+              PR_GetCurrentThread(), server->thread));\n \n-        TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-                 (\"main(0x%p): joining server(0x%p)\\n\", PR_GetCurrentThread(),\n-                  server->thread));\n-        joinStatus = PR_JoinThread(server->thread);\n-        TEST_ASSERT(PR_SUCCESS == joinStatus);\n-\n-        PR_DestroyCondVar(server->stateChange);\n-        PR_DestroyCondVar(server->pool.exiting);\n-        PR_DestroyCondVar(server->pool.acceptComplete);\n-        PR_DestroyLock(server->ml);\n-        PR_DELETE(server);\n+    PR_Lock(server->ml);\n+    server->state = cs_stop;\n+    PR_Interrupt(server->thread);\n+    while (cs_exit != server->state) {\n+      PR_WaitCondVar(server->stateChange, PR_INTERVAL_NO_TIMEOUT);\n     }\n+    PR_Unlock(server->ml);\n \n-    TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n-             (\"main(0x%p): test complete\\n\", PR_GetCurrentThread()));\n-\n-    PT_FPrintStats(debug_out, \"\\nPThread Statistics\\n\");\n-\n-    TimeOfDayMessage(\"Test exiting at\", PR_GetCurrentThread());\n-    PR_Cleanup();\n-    return 0;\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+             (\"main(0x%p): joining server(0x%p)\\n\", PR_GetCurrentThread(),\n+              server->thread));\n+    joinStatus = PR_JoinThread(server->thread);\n+    TEST_ASSERT(PR_SUCCESS == joinStatus);\n+\n+    PR_DestroyCondVar(server->stateChange);\n+    PR_DestroyCondVar(server->pool.exiting);\n+    PR_DestroyCondVar(server->pool.acceptComplete);\n+    PR_DestroyLock(server->ml);\n+    PR_DELETE(server);\n+  }\n+\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n+           (\"main(0x%p): test complete\\n\", PR_GetCurrentThread()));\n+\n+  PT_FPrintStats(debug_out, \"\\nPThread Statistics\\n\");\n+\n+  TimeOfDayMessage(\"Test exiting at\", PR_GetCurrentThread());\n+  PR_Cleanup();\n+  return 0;\n } /* main */\n \n /* cltsrv.c */\ndiff --git a/nspr/pr/tests/concur.c b/nspr/pr/tests/concur.c\nindex 7cc4afc..8256829 100644\n--- a/nspr/pr/tests/concur.c\n+++ b/nspr/pr/tests/concur.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -27,131 +28,125 @@\n static PRThreadScope thread_scope = PR_LOCAL_THREAD;\n \n typedef struct Context {\n-    PRLock* ml;\n-    PRCondVar* cv;\n-    PRIntn want, have;\n+  PRLock* ml;\n+  PRCondVar* cv;\n+  PRIntn want, have;\n } Context;\n \n /*\n ** Make the instance of 'context' static (not on the stack)\n ** for Win16 threads\n */\n-static Context context = { NULL, NULL, 0, 0 };\n-\n-static void PR_CALLBACK\n-Dull(void* arg)\n-{\n-    Context* context = (Context*)arg;\n-    PR_Lock(context->ml);\n-    context->have += 1;\n-    while (context->want >= context->have) {\n-        PR_WaitCondVar(context->cv, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    context->have -= 1;\n-    PR_Unlock(context->ml);\n+static Context context = {NULL, NULL, 0, 0};\n+\n+static void PR_CALLBACK Dull(void* arg) {\n+  Context* context = (Context*)arg;\n+  PR_Lock(context->ml);\n+  context->have += 1;\n+  while (context->want >= context->have) {\n+    PR_WaitCondVar(context->cv, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  context->have -= 1;\n+  PR_Unlock(context->ml);\n } /* Dull */\n \n-PRIntn PR_CALLBACK\n-Concur(PRIntn argc, char** argv)\n-{\n-    PRUintn cpus;\n-    PLOptStatus os;\n-    PRThread** threads;\n-    PRBool debug = PR_FALSE;\n-    PRUintn range = DEFAULT_RANGE;\n-    PRStatus rc;\n-    PRUintn cnt;\n-    PRUintn loops = DEFAULT_LOOPS;\n-    PRIntervalTime hundredMills = PR_MillisecondsToInterval(100);\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"Gdl:r:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'G': /* GLOBAL threads */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'd': /* debug mode */\n-                debug = PR_TRUE;\n-                break;\n-            case 'r': /* range limit */\n-                range = atoi(opt->value);\n-                break;\n-            case 'l': /* loop counter */\n-                loops = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n+PRIntn PR_CALLBACK Concur(PRIntn argc, char** argv) {\n+  PRUintn cpus;\n+  PLOptStatus os;\n+  PRThread** threads;\n+  PRBool debug = PR_FALSE;\n+  PRUintn range = DEFAULT_RANGE;\n+  PRStatus rc;\n+  PRUintn cnt;\n+  PRUintn loops = DEFAULT_LOOPS;\n+  PRIntervalTime hundredMills = PR_MillisecondsToInterval(100);\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"Gdl:r:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    if (0 == range) {\n-        range = DEFAULT_RANGE;\n+    switch (opt->option) {\n+      case 'G': /* GLOBAL threads */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'd': /* debug mode */\n+        debug = PR_TRUE;\n+        break;\n+      case 'r': /* range limit */\n+        range = atoi(opt->value);\n+        break;\n+      case 'l': /* loop counter */\n+        loops = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n-    if (0 == loops) {\n-        loops = DEFAULT_LOOPS;\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  if (0 == range) {\n+    range = DEFAULT_RANGE;\n+  }\n+  if (0 == loops) {\n+    loops = DEFAULT_LOOPS;\n+  }\n+\n+  context.ml = PR_NewLock();\n+  context.cv = PR_NewCondVar(context.ml);\n+\n+  if (debug)\n+    PR_fprintf(PR_STDERR, \"Testing with %d CPUs and %d interations\\n\", range,\n+               loops);\n+\n+  threads = (PRThread**)PR_CALLOC(sizeof(PRThread*) * range);\n+  while (--loops > 0) {\n+    for (cpus = 1; cpus <= range; ++cpus) {\n+      PR_SetConcurrency(cpus);\n+      context.want = cpus;\n+\n+      threads[cpus - 1] =\n+          PR_CreateThread(PR_USER_THREAD, Dull, &context, PR_PRIORITY_NORMAL,\n+                          thread_scope, PR_JOINABLE_THREAD, 0);\n     }\n \n-    context.ml = PR_NewLock();\n-    context.cv = PR_NewCondVar(context.ml);\n-\n-    if (debug)\n-        PR_fprintf(PR_STDERR, \"Testing with %d CPUs and %d interations\\n\", range,\n-                   loops);\n-\n-    threads = (PRThread**)PR_CALLOC(sizeof(PRThread*) * range);\n-    while (--loops > 0) {\n-        for (cpus = 1; cpus <= range; ++cpus) {\n-            PR_SetConcurrency(cpus);\n-            context.want = cpus;\n-\n-            threads[cpus - 1] =\n-                PR_CreateThread(PR_USER_THREAD, Dull, &context, PR_PRIORITY_NORMAL,\n-                                thread_scope, PR_JOINABLE_THREAD, 0);\n-        }\n-\n-        PR_Sleep(hundredMills);\n-\n-        for (cpus = range; cpus > 0; cpus--) {\n-            PR_SetConcurrency(cpus);\n-            context.want = cpus - 1;\n-\n-            PR_Lock(context.ml);\n-            PR_NotifyCondVar(context.cv);\n-            PR_Unlock(context.ml);\n-        }\n-        for (cnt = 0; cnt < range; cnt++) {\n-            rc = PR_JoinThread(threads[cnt]);\n-            PR_ASSERT(rc == PR_SUCCESS);\n-        }\n-    }\n+    PR_Sleep(hundredMills);\n \n-    if (debug)\n-        PR_fprintf(PR_STDERR, \"Waiting for %d thread(s) to exit\\n\", context.have);\n+    for (cpus = range; cpus > 0; cpus--) {\n+      PR_SetConcurrency(cpus);\n+      context.want = cpus - 1;\n \n-    while (context.have > 0) {\n-        PR_Sleep(hundredMills);\n+      PR_Lock(context.ml);\n+      PR_NotifyCondVar(context.cv);\n+      PR_Unlock(context.ml);\n     }\n+    for (cnt = 0; cnt < range; cnt++) {\n+      rc = PR_JoinThread(threads[cnt]);\n+      PR_ASSERT(rc == PR_SUCCESS);\n+    }\n+  }\n+\n+  if (debug)\n+    PR_fprintf(PR_STDERR, \"Waiting for %d thread(s) to exit\\n\", context.have);\n+\n+  while (context.have > 0) {\n+    PR_Sleep(hundredMills);\n+  }\n \n-    if (debug)\n-        PR_fprintf(PR_STDERR, \"Finished [want: %d, have: %d]\\n\", context.want,\n-                   context.have);\n+  if (debug)\n+    PR_fprintf(PR_STDERR, \"Finished [want: %d, have: %d]\\n\", context.want,\n+               context.have);\n \n-    PR_DestroyLock(context.ml);\n-    PR_DestroyCondVar(context.cv);\n-    PR_DELETE(threads);\n+  PR_DestroyLock(context.ml);\n+  PR_DestroyCondVar(context.cv);\n+  PR_DELETE(threads);\n \n-    PR_fprintf(PR_STDERR, \"PASSED\\n\");\n+  PR_fprintf(PR_STDERR, \"PASSED\\n\");\n \n-    return 0;\n+  return 0;\n } /* Concur */\n \n-int\n-main(int argc, char** argv)\n-{\n-    return PR_Initialize(Concur, argc, argv, 0);\n+int main(int argc, char** argv) {\n+  return PR_Initialize(Concur, argc, argv, 0);\n } /* main */\n \n /* concur.c */\ndiff --git a/nspr/pr/tests/cvar.c b/nspr/pr/tests/cvar.c\nindex bedbd5b..f22f089 100644\n--- a/nspr/pr/tests/cvar.c\n+++ b/nspr/pr/tests/cvar.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -45,12 +46,12 @@ PRIntn debug_mode;\n #define kQSIZE 1\n \n typedef struct {\n-    PRLock* bufLock;\n-    int startIdx;\n-    int numFull;\n-    PRCondVar* notFull;\n-    PRCondVar* notEmpty;\n-    void* data[kQSIZE];\n+  PRLock* bufLock;\n+  int startIdx;\n+  int numFull;\n+  PRCondVar* notFull;\n+  PRCondVar* notEmpty;\n+  void* data[kQSIZE];\n } CircBuf;\n \n static PRBool failed = PR_FALSE;\n@@ -58,251 +59,225 @@ static PRBool failed = PR_FALSE;\n /*\n ** NewCB creates and initializes a new circular buffer.\n */\n-static CircBuf*\n-NewCB(void)\n-{\n-    CircBuf* cbp;\n-\n-    cbp = PR_NEW(CircBuf);\n-    if (cbp == NULL) {\n-        return (NULL);\n-    }\n+static CircBuf* NewCB(void) {\n+  CircBuf* cbp;\n+\n+  cbp = PR_NEW(CircBuf);\n+  if (cbp == NULL) {\n+    return (NULL);\n+  }\n \n-    cbp->bufLock = PR_NewLock();\n-    cbp->startIdx = 0;\n-    cbp->numFull = 0;\n-    cbp->notFull = PR_NewCondVar(cbp->bufLock);\n-    cbp->notEmpty = PR_NewCondVar(cbp->bufLock);\n+  cbp->bufLock = PR_NewLock();\n+  cbp->startIdx = 0;\n+  cbp->numFull = 0;\n+  cbp->notFull = PR_NewCondVar(cbp->bufLock);\n+  cbp->notEmpty = PR_NewCondVar(cbp->bufLock);\n \n-    return (cbp);\n+  return (cbp);\n }\n \n /*\n ** DeleteCB frees a circular buffer.\n */\n-static void\n-DeleteCB(CircBuf* cbp)\n-{\n-    PR_DestroyLock(cbp->bufLock);\n-    PR_DestroyCondVar(cbp->notFull);\n-    PR_DestroyCondVar(cbp->notEmpty);\n-    PR_DELETE(cbp);\n+static void DeleteCB(CircBuf* cbp) {\n+  PR_DestroyLock(cbp->bufLock);\n+  PR_DestroyCondVar(cbp->notFull);\n+  PR_DestroyCondVar(cbp->notEmpty);\n+  PR_DELETE(cbp);\n }\n \n /*\n ** PutCBData puts new data on the queue.  If the queue is full, it waits\n ** until there is room.\n */\n-static void\n-PutCBData(CircBuf* cbp, void* data)\n-{\n-    PR_Lock(cbp->bufLock);\n-    /* wait while the buffer is full */\n-    while (cbp->numFull == kQSIZE) {\n-        PR_WaitCondVar(cbp->notFull, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    cbp->data[(cbp->startIdx + cbp->numFull) % kQSIZE] = data;\n-    cbp->numFull += 1;\n-\n-    /* let a waiting reader know that there is data */\n-    PR_NotifyCondVar(cbp->notEmpty);\n-    PR_Unlock(cbp->bufLock);\n+static void PutCBData(CircBuf* cbp, void* data) {\n+  PR_Lock(cbp->bufLock);\n+  /* wait while the buffer is full */\n+  while (cbp->numFull == kQSIZE) {\n+    PR_WaitCondVar(cbp->notFull, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  cbp->data[(cbp->startIdx + cbp->numFull) % kQSIZE] = data;\n+  cbp->numFull += 1;\n+\n+  /* let a waiting reader know that there is data */\n+  PR_NotifyCondVar(cbp->notEmpty);\n+  PR_Unlock(cbp->bufLock);\n }\n \n /*\n ** GetCBData gets the oldest data on the queue.  If the queue is empty, it waits\n ** until new data appears.\n */\n-static void*\n-GetCBData(CircBuf* cbp)\n-{\n-    void* data;\n-\n-    PR_Lock(cbp->bufLock);\n-    /* wait while the buffer is empty */\n-    while (cbp->numFull == 0) {\n-        PR_WaitCondVar(cbp->notEmpty, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    data = cbp->data[cbp->startIdx];\n-    cbp->startIdx = (cbp->startIdx + 1) % kQSIZE;\n-    cbp->numFull -= 1;\n-\n-    /* let a waiting writer know that there is room */\n-    PR_NotifyCondVar(cbp->notFull);\n-    PR_Unlock(cbp->bufLock);\n-\n-    return (data);\n+static void* GetCBData(CircBuf* cbp) {\n+  void* data;\n+\n+  PR_Lock(cbp->bufLock);\n+  /* wait while the buffer is empty */\n+  while (cbp->numFull == 0) {\n+    PR_WaitCondVar(cbp->notEmpty, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  data = cbp->data[cbp->startIdx];\n+  cbp->startIdx = (cbp->startIdx + 1) % kQSIZE;\n+  cbp->numFull -= 1;\n+\n+  /* let a waiting writer know that there is room */\n+  PR_NotifyCondVar(cbp->notFull);\n+  PR_Unlock(cbp->bufLock);\n+\n+  return (data);\n }\n \n /************************************************************************/\n \n static int alive;\n \n-static void PR_CALLBACK\n-CXReader(void* arg)\n-{\n-    CircBuf* cbp = (CircBuf*)arg;\n-    PRInt32 i, n;\n-    void* data;\n-\n-    n = count / 2;\n-    for (i = 0; i < n; i++) {\n-        data = GetCBData(cbp);\n-        if ((int)data != i)\n-            if (debug_mode) {\n-                printf(\"data mismatch at for i = %d usec\\n\", i);\n-            }\n-    }\n-\n-    PR_EnterMonitor(mon);\n-    --alive;\n-    PR_Notify(mon);\n-    PR_ExitMonitor(mon);\n+static void PR_CALLBACK CXReader(void* arg) {\n+  CircBuf* cbp = (CircBuf*)arg;\n+  PRInt32 i, n;\n+  void* data;\n+\n+  n = count / 2;\n+  for (i = 0; i < n; i++) {\n+    data = GetCBData(cbp);\n+    if ((int)data != i)\n+      if (debug_mode) {\n+        printf(\"data mismatch at for i = %d usec\\n\", i);\n+      }\n+  }\n+\n+  PR_EnterMonitor(mon);\n+  --alive;\n+  PR_Notify(mon);\n+  PR_ExitMonitor(mon);\n }\n \n-static void PR_CALLBACK\n-CXWriter(void* arg)\n-{\n-    CircBuf* cbp = (CircBuf*)arg;\n-    PRInt32 i, n;\n+static void PR_CALLBACK CXWriter(void* arg) {\n+  CircBuf* cbp = (CircBuf*)arg;\n+  PRInt32 i, n;\n \n-    n = count / 2;\n-    for (i = 0; i < n; i++) {\n-        PutCBData(cbp, (void*)i);\n-    }\n+  n = count / 2;\n+  for (i = 0; i < n; i++) {\n+    PutCBData(cbp, (void*)i);\n+  }\n \n-    PR_EnterMonitor(mon);\n-    --alive;\n-    PR_Notify(mon);\n-    PR_ExitMonitor(mon);\n+  PR_EnterMonitor(mon);\n+  --alive;\n+  PR_Notify(mon);\n+  PR_ExitMonitor(mon);\n }\n \n-static void\n-CondWaitContextSwitch(PRThreadScope scope1, PRThreadScope scope2)\n-{\n-    PRThread *t1, *t2;\n-    CircBuf* cbp;\n+static void CondWaitContextSwitch(PRThreadScope scope1, PRThreadScope scope2) {\n+  PRThread *t1, *t2;\n+  CircBuf* cbp;\n \n-    PR_EnterMonitor(mon);\n+  PR_EnterMonitor(mon);\n \n-    alive = 2;\n+  alive = 2;\n \n-    cbp = NewCB();\n+  cbp = NewCB();\n \n-    t1 = PR_CreateThread(PR_USER_THREAD, CXReader, cbp, PR_PRIORITY_NORMAL,\n-                         scope1, PR_UNJOINABLE_THREAD, 0);\n-    PR_ASSERT(t1);\n-    t2 = PR_CreateThread(PR_USER_THREAD, CXWriter, cbp, PR_PRIORITY_NORMAL,\n-                         scope2, PR_UNJOINABLE_THREAD, 0);\n-    PR_ASSERT(t2);\n+  t1 = PR_CreateThread(PR_USER_THREAD, CXReader, cbp, PR_PRIORITY_NORMAL,\n+                       scope1, PR_UNJOINABLE_THREAD, 0);\n+  PR_ASSERT(t1);\n+  t2 = PR_CreateThread(PR_USER_THREAD, CXWriter, cbp, PR_PRIORITY_NORMAL,\n+                       scope2, PR_UNJOINABLE_THREAD, 0);\n+  PR_ASSERT(t2);\n \n-    /* Wait for both of the threads to exit */\n-    while (alive) {\n-        PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n-    }\n+  /* Wait for both of the threads to exit */\n+  while (alive) {\n+    PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n+  }\n \n-    DeleteCB(cbp);\n+  DeleteCB(cbp);\n \n-    PR_ExitMonitor(mon);\n+  PR_ExitMonitor(mon);\n }\n \n-static void\n-CondWaitContextSwitchUU(void)\n-{\n-    CondWaitContextSwitch(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n+static void CondWaitContextSwitchUU(void) {\n+  CondWaitContextSwitch(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n }\n \n-static void\n-CondWaitContextSwitchUK(void)\n-{\n-    CondWaitContextSwitch(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n+static void CondWaitContextSwitchUK(void) {\n+  CondWaitContextSwitch(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n }\n \n-static void\n-CondWaitContextSwitchKK(void)\n-{\n-    CondWaitContextSwitch(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n+static void CondWaitContextSwitchKK(void) {\n+  CondWaitContextSwitch(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n }\n \n /************************************************************************/\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow();\n \n-    d = (double)PR_IntervalToMicroseconds(stop - start);\n+  d = (double)PR_IntervalToMicroseconds(stop - start);\n \n-    if (debug_mode) {\n-        printf(\"%40s: %6.2f usec\\n\", msg, d / count);\n-    }\n+  if (debug_mode) {\n+    printf(\"%40s: %6.2f usec\\n\", msg, d / count);\n+  }\n \n-    if (0 == d) {\n-        failed = PR_TRUE;\n-    }\n+  if (0 == d) {\n+    failed = PR_TRUE;\n+  }\n }\n \n-static PRIntn PR_CALLBACK\n-RealMain(int argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name [-d] [-c n]\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            case 'c': /* loop count */\n-                count = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n+static PRIntn PR_CALLBACK RealMain(int argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name [-d] [-c n]\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    if (0 == count) {\n-        count = DEFAULT_COUNT;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      case 'c': /* loop count */\n+        count = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    mon = PR_NewMonitor();\n+  if (0 == count) {\n+    count = DEFAULT_COUNT;\n+  }\n \n-    Measure(CondWaitContextSwitchUU, \"cond var wait context switch- user/user\");\n-    Measure(CondWaitContextSwitchUK, \"cond var wait context switch- user/kernel\");\n-    Measure(CondWaitContextSwitchKK,\n-            \"cond var wait context switch- kernel/kernel\");\n+  mon = PR_NewMonitor();\n \n-    PR_DestroyMonitor(mon);\n+  Measure(CondWaitContextSwitchUU, \"cond var wait context switch- user/user\");\n+  Measure(CondWaitContextSwitchUK, \"cond var wait context switch- user/kernel\");\n+  Measure(CondWaitContextSwitchKK,\n+          \"cond var wait context switch- kernel/kernel\");\n \n-    if (debug_mode) {\n-        printf(\"%s\\n\", (failed) ? \"FAILED\" : \"PASSED\");\n-    }\n+  PR_DestroyMonitor(mon);\n \n-    if (failed) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (debug_mode) {\n+    printf(\"%s\\n\", (failed) ? \"FAILED\" : \"PASSED\");\n+  }\n+\n+  if (failed) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\n \n-int\n-main(int argc, char* argv[])\n-{\n-    PRIntn rv;\n+int main(int argc, char* argv[]) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\ndiff --git a/nspr/pr/tests/cvar2.c b/nspr/pr/tests/cvar2.c\nindex 7c584a8..a4c0cda 100644\n--- a/nspr/pr/tests/cvar2.c\n+++ b/nspr/pr/tests/cvar2.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -33,26 +34,25 @@\n \n int _debug_on = 0;\n #define DPRINTF(arg) \\\n-    if (_debug_on)   \\\n-    printf arg\n+  if (_debug_on) printf arg\n \n #define DEFAULT_COUNT 100\n #define DEFAULT_THREADS 5\n PRInt32 count = DEFAULT_COUNT;\n \n typedef struct threadinfo {\n-    PRThread* thread;\n-    PRInt32 id;\n-    PRBool internal;\n-    PRInt32* tcount;\n-    PRLock* lock;\n-    PRCondVar* cvar;\n-    PRIntervalTime timeout;\n-    PRInt32 loops;\n-\n-    PRLock* exitlock;\n-    PRCondVar* exitcvar;\n-    PRInt32* exitcount;\n+  PRThread* thread;\n+  PRInt32 id;\n+  PRBool internal;\n+  PRInt32* tcount;\n+  PRLock* lock;\n+  PRCondVar* cvar;\n+  PRIntervalTime timeout;\n+  PRInt32 loops;\n+\n+  PRLock* exitlock;\n+  PRCondVar* exitcvar;\n+  PRInt32* exitcount;\n } threadinfo;\n \n /*\n@@ -62,698 +62,672 @@ static PRInt32 exitcount = 0;\n static PRInt32 tcount = 0;\n \n /* Thread that gets notified; many threads share the same condvar */\n-void PR_CALLBACK\n-SharedCondVarThread(void* _info)\n-{\n-    threadinfo* info = (threadinfo*)_info;\n-    PRInt32 index;\n-\n-    for (index = 0; index < info->loops; index++) {\n-        PR_Lock(info->lock);\n-        if (*info->tcount == 0) {\n-            PR_WaitCondVar(info->cvar, info->timeout);\n-        }\n+void PR_CALLBACK SharedCondVarThread(void* _info) {\n+  threadinfo* info = (threadinfo*)_info;\n+  PRInt32 index;\n+\n+  for (index = 0; index < info->loops; index++) {\n+    PR_Lock(info->lock);\n+    if (*info->tcount == 0) {\n+      PR_WaitCondVar(info->cvar, info->timeout);\n+    }\n #if 0\n         printf(\"shared thread %ld notified in loop %ld\\n\", info->id, index);\n #endif\n-        (*info->tcount)--;\n-        PR_Unlock(info->lock);\n-\n-        PR_Lock(info->exitlock);\n-        (*info->exitcount)++;\n-        PR_NotifyCondVar(info->exitcvar);\n-        PR_Unlock(info->exitlock);\n-    }\n+    (*info->tcount)--;\n+    PR_Unlock(info->lock);\n+\n+    PR_Lock(info->exitlock);\n+    (*info->exitcount)++;\n+    PR_NotifyCondVar(info->exitcvar);\n+    PR_Unlock(info->exitlock);\n+  }\n #if 0\n     printf(\"shared thread %ld terminating\\n\", info->id);\n #endif\n }\n \n /* Thread that gets notified; no other threads use the same condvar */\n-void PR_CALLBACK\n-PrivateCondVarThread(void* _info)\n-{\n-    threadinfo* info = (threadinfo*)_info;\n-    PRInt32 index;\n-\n-    for (index = 0; index < info->loops; index++) {\n-        PR_Lock(info->lock);\n-        if (*info->tcount == 0) {\n-            DPRINTF((\"PrivateCondVarThread: thread 0x%lx waiting on cvar = 0x%lx\\n\",\n-                     PR_GetCurrentThread(), info->cvar));\n-            PR_WaitCondVar(info->cvar, info->timeout);\n-        }\n+void PR_CALLBACK PrivateCondVarThread(void* _info) {\n+  threadinfo* info = (threadinfo*)_info;\n+  PRInt32 index;\n+\n+  for (index = 0; index < info->loops; index++) {\n+    PR_Lock(info->lock);\n+    if (*info->tcount == 0) {\n+      DPRINTF((\"PrivateCondVarThread: thread 0x%lx waiting on cvar = 0x%lx\\n\",\n+               PR_GetCurrentThread(), info->cvar));\n+      PR_WaitCondVar(info->cvar, info->timeout);\n+    }\n #if 0\n         printf(\"solo   thread %ld notified in loop %ld\\n\", info->id, index);\n #endif\n-        (*info->tcount)--;\n-        PR_Unlock(info->lock);\n-\n-        PR_Lock(info->exitlock);\n-        (*info->exitcount)++;\n-        PR_NotifyCondVar(info->exitcvar);\n-        DPRINTF(\n-            (\"PrivateCondVarThread: thread 0x%lx notified exitcvar = 0x%lx cnt = \"\n-             \"%ld\\n\",\n-             PR_GetCurrentThread(), info->exitcvar, (*info->exitcount)));\n-        PR_Unlock(info->exitlock);\n-    }\n+    (*info->tcount)--;\n+    PR_Unlock(info->lock);\n+\n+    PR_Lock(info->exitlock);\n+    (*info->exitcount)++;\n+    PR_NotifyCondVar(info->exitcvar);\n+    DPRINTF(\n+        (\"PrivateCondVarThread: thread 0x%lx notified exitcvar = 0x%lx cnt = \"\n+         \"%ld\\n\",\n+         PR_GetCurrentThread(), info->exitcvar, (*info->exitcount)));\n+    PR_Unlock(info->exitlock);\n+  }\n #if 0\n     printf(\"solo   thread %ld terminating\\n\", info->id);\n #endif\n }\n \n-void\n-CreateTestThread(threadinfo* info, PRInt32 id, PRLock* lock,\n-                 PRCondVar* cvar, PRInt32 loops, PRIntervalTime timeout,\n-                 PRInt32* tcount, PRLock* exitlock, PRCondVar* exitcvar,\n-                 PRInt32* exitcount, PRBool shared, PRThreadScope scope)\n-{\n-    info->id = id;\n-    info->internal = (shared) ? PR_FALSE : PR_TRUE;\n-    info->lock = lock;\n-    info->cvar = cvar;\n-    info->loops = loops;\n-    info->timeout = timeout;\n-    info->tcount = tcount;\n-    info->exitlock = exitlock;\n-    info->exitcvar = exitcvar;\n-    info->exitcount = exitcount;\n-    info->thread = PR_CreateThread(\n-        PR_USER_THREAD, shared ? SharedCondVarThread : PrivateCondVarThread, info,\n-        PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n-    if (!info->thread) {\n-        PL_PrintError(\"error creating thread\\n\");\n-    }\n+void CreateTestThread(threadinfo* info, PRInt32 id, PRLock* lock,\n+                      PRCondVar* cvar, PRInt32 loops, PRIntervalTime timeout,\n+                      PRInt32* tcount, PRLock* exitlock, PRCondVar* exitcvar,\n+                      PRInt32* exitcount, PRBool shared, PRThreadScope scope) {\n+  info->id = id;\n+  info->internal = (shared) ? PR_FALSE : PR_TRUE;\n+  info->lock = lock;\n+  info->cvar = cvar;\n+  info->loops = loops;\n+  info->timeout = timeout;\n+  info->tcount = tcount;\n+  info->exitlock = exitlock;\n+  info->exitcvar = exitcvar;\n+  info->exitcount = exitcount;\n+  info->thread = PR_CreateThread(\n+      PR_USER_THREAD, shared ? SharedCondVarThread : PrivateCondVarThread, info,\n+      PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n+  if (!info->thread) {\n+    PL_PrintError(\"error creating thread\\n\");\n+  }\n }\n \n-void\n-CondVarTestSUU(void* _arg)\n-{\n-    PRInt32 arg = (PRInt32)_arg;\n-    PRInt32 index, loops;\n-    threadinfo* list;\n-    PRLock* sharedlock;\n-    PRCondVar* sharedcvar;\n-    PRLock* exitlock;\n-    PRCondVar* exitcvar;\n-\n-    exitcount = 0;\n-    tcount = 0;\n-    list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n-\n-    sharedlock = PR_NewLock();\n-    sharedcvar = PR_NewCondVar(sharedlock);\n-    exitlock = PR_NewLock();\n-    exitcvar = PR_NewCondVar(exitlock);\n-\n-    /* Create the threads */\n-    for (index = 0; index < arg;) {\n-        CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n-                         PR_INTERVAL_NO_TIMEOUT, &tcount, exitlock, exitcvar,\n-                         &exitcount, PR_TRUE, PR_LOCAL_THREAD);\n-        index++;\n-        DPRINTF((\"CondVarTestSUU: created thread 0x%lx\\n\", list[index].thread));\n-    }\n-\n-    for (loops = 0; loops < count; loops++) {\n-        /* Notify the threads */\n-        for (index = 0; index < (arg); index++) {\n-            PR_Lock(list[index].lock);\n-            (*list[index].tcount)++;\n-            PR_NotifyCondVar(list[index].cvar);\n-            PR_Unlock(list[index].lock);\n-            DPRINTF((\"PrivateCondVarThread: thread 0x%lx notified cvar = 0x%lx\\n\",\n-                     PR_GetCurrentThread(), list[index].cvar));\n-        }\n-\n-        /* Wait for threads to finish */\n-        PR_Lock(exitlock);\n-        while (exitcount < arg) {\n-            PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n-        }\n-        PR_ASSERT(exitcount >= arg);\n-        exitcount -= arg;\n-        PR_Unlock(exitlock);\n-    }\n-\n-    /* Join all the threads */\n+void CondVarTestSUU(void* _arg) {\n+  PRInt32 arg = (PRInt32)_arg;\n+  PRInt32 index, loops;\n+  threadinfo* list;\n+  PRLock* sharedlock;\n+  PRCondVar* sharedcvar;\n+  PRLock* exitlock;\n+  PRCondVar* exitcvar;\n+\n+  exitcount = 0;\n+  tcount = 0;\n+  list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n+\n+  sharedlock = PR_NewLock();\n+  sharedcvar = PR_NewCondVar(sharedlock);\n+  exitlock = PR_NewLock();\n+  exitcvar = PR_NewCondVar(exitlock);\n+\n+  /* Create the threads */\n+  for (index = 0; index < arg;) {\n+    CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n+                     PR_INTERVAL_NO_TIMEOUT, &tcount, exitlock, exitcvar,\n+                     &exitcount, PR_TRUE, PR_LOCAL_THREAD);\n+    index++;\n+    DPRINTF((\"CondVarTestSUU: created thread 0x%lx\\n\", list[index].thread));\n+  }\n+\n+  for (loops = 0; loops < count; loops++) {\n+    /* Notify the threads */\n     for (index = 0; index < (arg); index++) {\n-        PR_JoinThread(list[index].thread);\n+      PR_Lock(list[index].lock);\n+      (*list[index].tcount)++;\n+      PR_NotifyCondVar(list[index].cvar);\n+      PR_Unlock(list[index].lock);\n+      DPRINTF((\"PrivateCondVarThread: thread 0x%lx notified cvar = 0x%lx\\n\",\n+               PR_GetCurrentThread(), list[index].cvar));\n     }\n \n-    PR_DestroyCondVar(sharedcvar);\n-    PR_DestroyLock(sharedlock);\n-    PR_DestroyCondVar(exitcvar);\n-    PR_DestroyLock(exitlock);\n-\n-    PR_DELETE(list);\n+    /* Wait for threads to finish */\n+    PR_Lock(exitlock);\n+    while (exitcount < arg) {\n+      PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n+    }\n+    PR_ASSERT(exitcount >= arg);\n+    exitcount -= arg;\n+    PR_Unlock(exitlock);\n+  }\n+\n+  /* Join all the threads */\n+  for (index = 0; index < (arg); index++) {\n+    PR_JoinThread(list[index].thread);\n+  }\n+\n+  PR_DestroyCondVar(sharedcvar);\n+  PR_DestroyLock(sharedlock);\n+  PR_DestroyCondVar(exitcvar);\n+  PR_DestroyLock(exitlock);\n+\n+  PR_DELETE(list);\n }\n \n-void\n-CondVarTestSUK(void* _arg)\n-{\n-    PRInt32 arg = (PRInt32)_arg;\n-    PRInt32 index, loops;\n-    threadinfo* list;\n-    PRLock* sharedlock;\n-    PRCondVar* sharedcvar;\n-    PRLock* exitlock;\n-    PRCondVar* exitcvar;\n-    exitcount = 0;\n-    tcount = 0;\n-\n-    list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n-\n-    sharedlock = PR_NewLock();\n-    sharedcvar = PR_NewCondVar(sharedlock);\n-    exitlock = PR_NewLock();\n-    exitcvar = PR_NewCondVar(exitlock);\n-\n-    /* Create the threads */\n-    for (index = 0; index < arg;) {\n-        CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n-                         PR_INTERVAL_NO_TIMEOUT, &tcount, exitlock, exitcvar,\n-                         &exitcount, PR_TRUE, PR_GLOBAL_THREAD);\n-        index++;\n+void CondVarTestSUK(void* _arg) {\n+  PRInt32 arg = (PRInt32)_arg;\n+  PRInt32 index, loops;\n+  threadinfo* list;\n+  PRLock* sharedlock;\n+  PRCondVar* sharedcvar;\n+  PRLock* exitlock;\n+  PRCondVar* exitcvar;\n+  exitcount = 0;\n+  tcount = 0;\n+\n+  list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n+\n+  sharedlock = PR_NewLock();\n+  sharedcvar = PR_NewCondVar(sharedlock);\n+  exitlock = PR_NewLock();\n+  exitcvar = PR_NewCondVar(exitlock);\n+\n+  /* Create the threads */\n+  for (index = 0; index < arg;) {\n+    CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n+                     PR_INTERVAL_NO_TIMEOUT, &tcount, exitlock, exitcvar,\n+                     &exitcount, PR_TRUE, PR_GLOBAL_THREAD);\n+    index++;\n+  }\n+\n+  for (loops = 0; loops < count; loops++) {\n+    /* Notify the threads */\n+    for (index = 0; index < (arg); index++) {\n+      PR_Lock(list[index].lock);\n+      (*list[index].tcount)++;\n+      PR_NotifyCondVar(list[index].cvar);\n+      PR_Unlock(list[index].lock);\n     }\n \n-    for (loops = 0; loops < count; loops++) {\n-        /* Notify the threads */\n-        for (index = 0; index < (arg); index++) {\n-            PR_Lock(list[index].lock);\n-            (*list[index].tcount)++;\n-            PR_NotifyCondVar(list[index].cvar);\n-            PR_Unlock(list[index].lock);\n-        }\n-\n #if 0\n         printf(\"wait for threads to be done\\n\");\n #endif\n-        /* Wait for threads to finish */\n-        PR_Lock(exitlock);\n-        while (exitcount < arg) {\n-            PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n-        }\n-        PR_ASSERT(exitcount >= arg);\n-        exitcount -= arg;\n-        PR_Unlock(exitlock);\n+    /* Wait for threads to finish */\n+    PR_Lock(exitlock);\n+    while (exitcount < arg) {\n+      PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n+    }\n+    PR_ASSERT(exitcount >= arg);\n+    exitcount -= arg;\n+    PR_Unlock(exitlock);\n #if 0\n         printf(\"threads ready\\n\");\n #endif\n-    }\n+  }\n \n-    /* Join all the threads */\n-    for (index = 0; index < (arg); index++) {\n-        PR_JoinThread(list[index].thread);\n-    }\n+  /* Join all the threads */\n+  for (index = 0; index < (arg); index++) {\n+    PR_JoinThread(list[index].thread);\n+  }\n \n-    PR_DestroyCondVar(sharedcvar);\n-    PR_DestroyLock(sharedlock);\n-    PR_DestroyCondVar(exitcvar);\n-    PR_DestroyLock(exitlock);\n+  PR_DestroyCondVar(sharedcvar);\n+  PR_DestroyLock(sharedlock);\n+  PR_DestroyCondVar(exitcvar);\n+  PR_DestroyLock(exitlock);\n \n-    PR_DELETE(list);\n+  PR_DELETE(list);\n }\n \n-void\n-CondVarTestPUU(void* _arg)\n-{\n-    PRInt32 arg = (PRInt32)_arg;\n-    PRInt32 index, loops;\n-    threadinfo* list;\n-    PRLock* sharedlock;\n-    PRCondVar* sharedcvar;\n-    PRLock* exitlock;\n-    PRCondVar* exitcvar;\n-    PRInt32 *tcount, *saved_tcount;\n-\n-    exitcount = 0;\n-    list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n-    saved_tcount = tcount = (PRInt32*)PR_CALLOC(sizeof(*tcount) * (arg * 4));\n-\n-    sharedlock = PR_NewLock();\n-    sharedcvar = PR_NewCondVar(sharedlock);\n-    exitlock = PR_NewLock();\n-    exitcvar = PR_NewCondVar(exitlock);\n-\n-    /* Create the threads */\n-    for (index = 0; index < arg;) {\n-        list[index].lock = PR_NewLock();\n-        list[index].cvar = PR_NewCondVar(list[index].lock);\n-        CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n-                         count, PR_INTERVAL_NO_TIMEOUT, tcount, exitlock, exitcvar,\n-                         &exitcount, PR_FALSE, PR_LOCAL_THREAD);\n-\n-        DPRINTF((\"CondVarTestPUU: created thread 0x%lx\\n\", list[index].thread));\n-        index++;\n-        tcount++;\n+void CondVarTestPUU(void* _arg) {\n+  PRInt32 arg = (PRInt32)_arg;\n+  PRInt32 index, loops;\n+  threadinfo* list;\n+  PRLock* sharedlock;\n+  PRCondVar* sharedcvar;\n+  PRLock* exitlock;\n+  PRCondVar* exitcvar;\n+  PRInt32 *tcount, *saved_tcount;\n+\n+  exitcount = 0;\n+  list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n+  saved_tcount = tcount = (PRInt32*)PR_CALLOC(sizeof(*tcount) * (arg * 4));\n+\n+  sharedlock = PR_NewLock();\n+  sharedcvar = PR_NewCondVar(sharedlock);\n+  exitlock = PR_NewLock();\n+  exitcvar = PR_NewCondVar(exitlock);\n+\n+  /* Create the threads */\n+  for (index = 0; index < arg;) {\n+    list[index].lock = PR_NewLock();\n+    list[index].cvar = PR_NewCondVar(list[index].lock);\n+    CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n+                     count, PR_INTERVAL_NO_TIMEOUT, tcount, exitlock, exitcvar,\n+                     &exitcount, PR_FALSE, PR_LOCAL_THREAD);\n+\n+    DPRINTF((\"CondVarTestPUU: created thread 0x%lx\\n\", list[index].thread));\n+    index++;\n+    tcount++;\n+  }\n+\n+  for (loops = 0; loops < count; loops++) {\n+    /* Notify the threads */\n+    for (index = 0; index < (arg); index++) {\n+      PR_Lock(list[index].lock);\n+      (*list[index].tcount)++;\n+      PR_NotifyCondVar(list[index].cvar);\n+      PR_Unlock(list[index].lock);\n     }\n \n-    for (loops = 0; loops < count; loops++) {\n-        /* Notify the threads */\n-        for (index = 0; index < (arg); index++) {\n-            PR_Lock(list[index].lock);\n-            (*list[index].tcount)++;\n-            PR_NotifyCondVar(list[index].cvar);\n-            PR_Unlock(list[index].lock);\n-        }\n-\n-        PR_Lock(exitlock);\n-        /* Wait for threads to finish */\n-        while (exitcount < arg) {\n-            DPRINTF(\n-                (\"CondVarTestPUU: thread 0x%lx waiting on exitcvar = 0x%lx cnt = \"\n-                 \"%ld\\n\",\n-                 PR_GetCurrentThread(), exitcvar, exitcount));\n-            PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n-        }\n-        PR_ASSERT(exitcount >= arg);\n-        exitcount -= arg;\n-        PR_Unlock(exitlock);\n+    PR_Lock(exitlock);\n+    /* Wait for threads to finish */\n+    while (exitcount < arg) {\n+      DPRINTF(\n+          (\"CondVarTestPUU: thread 0x%lx waiting on exitcvar = 0x%lx cnt = \"\n+           \"%ld\\n\",\n+           PR_GetCurrentThread(), exitcvar, exitcount));\n+      PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n     }\n-\n-    /* Join all the threads */\n-    for (index = 0; index < (arg); index++) {\n-        DPRINTF((\"CondVarTestPUU: joining thread 0x%lx\\n\", list[index].thread));\n-        PR_JoinThread(list[index].thread);\n-        if (list[index].internal) {\n-            PR_Lock(list[index].lock);\n-            PR_DestroyCondVar(list[index].cvar);\n-            PR_Unlock(list[index].lock);\n-            PR_DestroyLock(list[index].lock);\n-        }\n+    PR_ASSERT(exitcount >= arg);\n+    exitcount -= arg;\n+    PR_Unlock(exitlock);\n+  }\n+\n+  /* Join all the threads */\n+  for (index = 0; index < (arg); index++) {\n+    DPRINTF((\"CondVarTestPUU: joining thread 0x%lx\\n\", list[index].thread));\n+    PR_JoinThread(list[index].thread);\n+    if (list[index].internal) {\n+      PR_Lock(list[index].lock);\n+      PR_DestroyCondVar(list[index].cvar);\n+      PR_Unlock(list[index].lock);\n+      PR_DestroyLock(list[index].lock);\n     }\n+  }\n \n-    PR_DestroyCondVar(sharedcvar);\n-    PR_DestroyLock(sharedlock);\n-    PR_DestroyCondVar(exitcvar);\n-    PR_DestroyLock(exitlock);\n+  PR_DestroyCondVar(sharedcvar);\n+  PR_DestroyLock(sharedlock);\n+  PR_DestroyCondVar(exitcvar);\n+  PR_DestroyLock(exitlock);\n \n-    PR_DELETE(list);\n-    PR_DELETE(saved_tcount);\n+  PR_DELETE(list);\n+  PR_DELETE(saved_tcount);\n }\n \n-void\n-CondVarTestPUK(void* _arg)\n-{\n-    PRInt32 arg = (PRInt32)_arg;\n-    PRInt32 index, loops;\n-    threadinfo* list;\n-    PRLock* sharedlock;\n-    PRCondVar* sharedcvar;\n-    PRLock* exitlock;\n-    PRCondVar* exitcvar;\n-    PRInt32 *tcount, *saved_tcount;\n-\n-    exitcount = 0;\n-    list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n-    saved_tcount = tcount = (PRInt32*)PR_CALLOC(sizeof(*tcount) * (arg * 4));\n-\n-    sharedlock = PR_NewLock();\n-    sharedcvar = PR_NewCondVar(sharedlock);\n-    exitlock = PR_NewLock();\n-    exitcvar = PR_NewCondVar(exitlock);\n-\n-    /* Create the threads */\n-    for (index = 0; index < arg;) {\n-        list[index].lock = PR_NewLock();\n-        list[index].cvar = PR_NewCondVar(list[index].lock);\n-        CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n-                         count, PR_INTERVAL_NO_TIMEOUT, tcount, exitlock, exitcvar,\n-                         &exitcount, PR_FALSE, PR_GLOBAL_THREAD);\n-\n-        index++;\n-        tcount++;\n+void CondVarTestPUK(void* _arg) {\n+  PRInt32 arg = (PRInt32)_arg;\n+  PRInt32 index, loops;\n+  threadinfo* list;\n+  PRLock* sharedlock;\n+  PRCondVar* sharedcvar;\n+  PRLock* exitlock;\n+  PRCondVar* exitcvar;\n+  PRInt32 *tcount, *saved_tcount;\n+\n+  exitcount = 0;\n+  list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n+  saved_tcount = tcount = (PRInt32*)PR_CALLOC(sizeof(*tcount) * (arg * 4));\n+\n+  sharedlock = PR_NewLock();\n+  sharedcvar = PR_NewCondVar(sharedlock);\n+  exitlock = PR_NewLock();\n+  exitcvar = PR_NewCondVar(exitlock);\n+\n+  /* Create the threads */\n+  for (index = 0; index < arg;) {\n+    list[index].lock = PR_NewLock();\n+    list[index].cvar = PR_NewCondVar(list[index].lock);\n+    CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n+                     count, PR_INTERVAL_NO_TIMEOUT, tcount, exitlock, exitcvar,\n+                     &exitcount, PR_FALSE, PR_GLOBAL_THREAD);\n+\n+    index++;\n+    tcount++;\n+  }\n+\n+  for (loops = 0; loops < count; loops++) {\n+    /* Notify the threads */\n+    for (index = 0; index < (arg); index++) {\n+      PR_Lock(list[index].lock);\n+      (*list[index].tcount)++;\n+      PR_NotifyCondVar(list[index].cvar);\n+      PR_Unlock(list[index].lock);\n     }\n \n-    for (loops = 0; loops < count; loops++) {\n-        /* Notify the threads */\n-        for (index = 0; index < (arg); index++) {\n-            PR_Lock(list[index].lock);\n-            (*list[index].tcount)++;\n-            PR_NotifyCondVar(list[index].cvar);\n-            PR_Unlock(list[index].lock);\n-        }\n-\n-        /* Wait for threads to finish */\n-        PR_Lock(exitlock);\n-        while (exitcount < arg) {\n-            PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n-        }\n-        PR_ASSERT(exitcount >= arg);\n-        exitcount -= arg;\n-        PR_Unlock(exitlock);\n+    /* Wait for threads to finish */\n+    PR_Lock(exitlock);\n+    while (exitcount < arg) {\n+      PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n     }\n-\n-    /* Join all the threads */\n-    for (index = 0; index < (arg); index++) {\n-        PR_JoinThread(list[index].thread);\n-        if (list[index].internal) {\n-            PR_Lock(list[index].lock);\n-            PR_DestroyCondVar(list[index].cvar);\n-            PR_Unlock(list[index].lock);\n-            PR_DestroyLock(list[index].lock);\n-        }\n+    PR_ASSERT(exitcount >= arg);\n+    exitcount -= arg;\n+    PR_Unlock(exitlock);\n+  }\n+\n+  /* Join all the threads */\n+  for (index = 0; index < (arg); index++) {\n+    PR_JoinThread(list[index].thread);\n+    if (list[index].internal) {\n+      PR_Lock(list[index].lock);\n+      PR_DestroyCondVar(list[index].cvar);\n+      PR_Unlock(list[index].lock);\n+      PR_DestroyLock(list[index].lock);\n     }\n+  }\n \n-    PR_DestroyCondVar(sharedcvar);\n-    PR_DestroyLock(sharedlock);\n-    PR_DestroyCondVar(exitcvar);\n-    PR_DestroyLock(exitlock);\n+  PR_DestroyCondVar(sharedcvar);\n+  PR_DestroyLock(sharedlock);\n+  PR_DestroyCondVar(exitcvar);\n+  PR_DestroyLock(exitlock);\n \n-    PR_DELETE(list);\n-    PR_DELETE(saved_tcount);\n+  PR_DELETE(list);\n+  PR_DELETE(saved_tcount);\n }\n \n-void\n-CondVarTest(void* _arg)\n-{\n-    PRInt32 arg = (PRInt32)_arg;\n-    PRInt32 index, loops;\n-    threadinfo* list;\n-    PRLock* sharedlock;\n-    PRCondVar* sharedcvar;\n-    PRLock* exitlock;\n-    PRCondVar* exitcvar;\n-    PRInt32 *ptcount, *saved_ptcount;\n-\n-    exitcount = 0;\n-    tcount = 0;\n-    list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n-    saved_ptcount = ptcount = (PRInt32*)PR_CALLOC(sizeof(*ptcount) * (arg * 4));\n-\n-    sharedlock = PR_NewLock();\n-    sharedcvar = PR_NewCondVar(sharedlock);\n-    exitlock = PR_NewLock();\n-    exitcvar = PR_NewCondVar(exitlock);\n-\n-    /* Create the threads */\n-    for (index = 0; index < arg * 4;) {\n-        CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n-                         PR_INTERVAL_NO_TIMEOUT, &tcount, exitlock, exitcvar,\n-                         &exitcount, PR_TRUE, PR_LOCAL_THREAD);\n-\n-        index++;\n-        CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n-                         PR_INTERVAL_NO_TIMEOUT, &tcount, exitlock, exitcvar,\n-                         &exitcount, PR_TRUE, PR_GLOBAL_THREAD);\n-\n-        index++;\n-        list[index].lock = PR_NewLock();\n-        list[index].cvar = PR_NewCondVar(list[index].lock);\n-        CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n-                         count, PR_INTERVAL_NO_TIMEOUT, ptcount, exitlock, exitcvar,\n-                         &exitcount, PR_FALSE, PR_LOCAL_THREAD);\n-        index++;\n-        ptcount++;\n-        list[index].lock = PR_NewLock();\n-        list[index].cvar = PR_NewCondVar(list[index].lock);\n-        CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n-                         count, PR_INTERVAL_NO_TIMEOUT, ptcount, exitlock, exitcvar,\n-                         &exitcount, PR_FALSE, PR_GLOBAL_THREAD);\n-\n-        index++;\n-        ptcount++;\n+void CondVarTest(void* _arg) {\n+  PRInt32 arg = (PRInt32)_arg;\n+  PRInt32 index, loops;\n+  threadinfo* list;\n+  PRLock* sharedlock;\n+  PRCondVar* sharedcvar;\n+  PRLock* exitlock;\n+  PRCondVar* exitcvar;\n+  PRInt32 *ptcount, *saved_ptcount;\n+\n+  exitcount = 0;\n+  tcount = 0;\n+  list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n+  saved_ptcount = ptcount = (PRInt32*)PR_CALLOC(sizeof(*ptcount) * (arg * 4));\n+\n+  sharedlock = PR_NewLock();\n+  sharedcvar = PR_NewCondVar(sharedlock);\n+  exitlock = PR_NewLock();\n+  exitcvar = PR_NewCondVar(exitlock);\n+\n+  /* Create the threads */\n+  for (index = 0; index < arg * 4;) {\n+    CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n+                     PR_INTERVAL_NO_TIMEOUT, &tcount, exitlock, exitcvar,\n+                     &exitcount, PR_TRUE, PR_LOCAL_THREAD);\n+\n+    index++;\n+    CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n+                     PR_INTERVAL_NO_TIMEOUT, &tcount, exitlock, exitcvar,\n+                     &exitcount, PR_TRUE, PR_GLOBAL_THREAD);\n+\n+    index++;\n+    list[index].lock = PR_NewLock();\n+    list[index].cvar = PR_NewCondVar(list[index].lock);\n+    CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n+                     count, PR_INTERVAL_NO_TIMEOUT, ptcount, exitlock, exitcvar,\n+                     &exitcount, PR_FALSE, PR_LOCAL_THREAD);\n+    index++;\n+    ptcount++;\n+    list[index].lock = PR_NewLock();\n+    list[index].cvar = PR_NewCondVar(list[index].lock);\n+    CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n+                     count, PR_INTERVAL_NO_TIMEOUT, ptcount, exitlock, exitcvar,\n+                     &exitcount, PR_FALSE, PR_GLOBAL_THREAD);\n+\n+    index++;\n+    ptcount++;\n+  }\n+\n+  for (loops = 0; loops < count; loops++) {\n+    /* Notify the threads */\n+    for (index = 0; index < (arg * 4); index++) {\n+      PR_Lock(list[index].lock);\n+      (*list[index].tcount)++;\n+      PR_NotifyCondVar(list[index].cvar);\n+      PR_Unlock(list[index].lock);\n     }\n \n-    for (loops = 0; loops < count; loops++) {\n-        /* Notify the threads */\n-        for (index = 0; index < (arg * 4); index++) {\n-            PR_Lock(list[index].lock);\n-            (*list[index].tcount)++;\n-            PR_NotifyCondVar(list[index].cvar);\n-            PR_Unlock(list[index].lock);\n-        }\n-\n #if 0\n         printf(\"wait for threads done\\n\");\n #endif\n \n-        /* Wait for threads to finish */\n-        PR_Lock(exitlock);\n-        while (exitcount < arg * 4) {\n-            PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n-        }\n-        PR_ASSERT(exitcount >= arg * 4);\n-        exitcount -= arg * 4;\n-        PR_Unlock(exitlock);\n+    /* Wait for threads to finish */\n+    PR_Lock(exitlock);\n+    while (exitcount < arg * 4) {\n+      PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n+    }\n+    PR_ASSERT(exitcount >= arg * 4);\n+    exitcount -= arg * 4;\n+    PR_Unlock(exitlock);\n #if 0\n         printf(\"threads ready\\n\");\n #endif\n+  }\n+\n+  /* Join all the threads */\n+  for (index = 0; index < (arg * 4); index++) {\n+    PR_JoinThread(list[index].thread);\n+    if (list[index].internal) {\n+      PR_Lock(list[index].lock);\n+      PR_DestroyCondVar(list[index].cvar);\n+      PR_Unlock(list[index].lock);\n+      PR_DestroyLock(list[index].lock);\n     }\n+  }\n \n-    /* Join all the threads */\n-    for (index = 0; index < (arg * 4); index++) {\n-        PR_JoinThread(list[index].thread);\n-        if (list[index].internal) {\n-            PR_Lock(list[index].lock);\n-            PR_DestroyCondVar(list[index].cvar);\n-            PR_Unlock(list[index].lock);\n-            PR_DestroyLock(list[index].lock);\n-        }\n-    }\n+  PR_DestroyCondVar(sharedcvar);\n+  PR_DestroyLock(sharedlock);\n+  PR_DestroyCondVar(exitcvar);\n+  PR_DestroyLock(exitlock);\n \n-    PR_DestroyCondVar(sharedcvar);\n-    PR_DestroyLock(sharedlock);\n-    PR_DestroyCondVar(exitcvar);\n-    PR_DestroyLock(exitlock);\n-\n-    PR_DELETE(list);\n-    PR_DELETE(saved_ptcount);\n+  PR_DELETE(list);\n+  PR_DELETE(saved_ptcount);\n }\n \n-void\n-CondVarTimeoutTest(void* _arg)\n-{\n-    PRInt32 arg = (PRInt32)_arg;\n-    PRInt32 index, loops;\n-    threadinfo* list;\n-    PRLock* sharedlock;\n-    PRCondVar* sharedcvar;\n-    PRLock* exitlock;\n-    PRCondVar* exitcvar;\n-\n-    list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n-\n-    sharedlock = PR_NewLock();\n-    sharedcvar = PR_NewCondVar(sharedlock);\n-    exitlock = PR_NewLock();\n-    exitcvar = PR_NewCondVar(exitlock);\n-\n-    /* Create the threads */\n-    for (index = 0; index < arg * 4;) {\n-        CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n-                         PR_MillisecondsToInterval(50), &tcount, exitlock, exitcvar,\n-                         &exitcount, PR_TRUE, PR_LOCAL_THREAD);\n-        index++;\n-        CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n-                         PR_MillisecondsToInterval(50), &tcount, exitlock, exitcvar,\n-                         &exitcount, PR_TRUE, PR_GLOBAL_THREAD);\n-        index++;\n-        list[index].lock = PR_NewLock();\n-        list[index].cvar = PR_NewCondVar(list[index].lock);\n-        CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n-                         count, PR_MillisecondsToInterval(50), &tcount, exitlock,\n-                         exitcvar, &exitcount, PR_FALSE, PR_LOCAL_THREAD);\n-        index++;\n-\n-        list[index].lock = PR_NewLock();\n-        list[index].cvar = PR_NewCondVar(list[index].lock);\n-        CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n-                         count, PR_MillisecondsToInterval(50), &tcount, exitlock,\n-                         exitcvar, &exitcount, PR_FALSE, PR_GLOBAL_THREAD);\n-\n-        index++;\n-    }\n-\n-    for (loops = 0; loops < count; loops++) {\n-        /* Wait for threads to finish */\n-        PR_Lock(exitlock);\n-        while (exitcount < arg * 4) {\n-            PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n-        }\n-        PR_ASSERT(exitcount >= arg * 4);\n-        exitcount -= arg * 4;\n-        PR_Unlock(exitlock);\n+void CondVarTimeoutTest(void* _arg) {\n+  PRInt32 arg = (PRInt32)_arg;\n+  PRInt32 index, loops;\n+  threadinfo* list;\n+  PRLock* sharedlock;\n+  PRCondVar* sharedcvar;\n+  PRLock* exitlock;\n+  PRCondVar* exitcvar;\n+\n+  list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n+\n+  sharedlock = PR_NewLock();\n+  sharedcvar = PR_NewCondVar(sharedlock);\n+  exitlock = PR_NewLock();\n+  exitcvar = PR_NewCondVar(exitlock);\n+\n+  /* Create the threads */\n+  for (index = 0; index < arg * 4;) {\n+    CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n+                     PR_MillisecondsToInterval(50), &tcount, exitlock, exitcvar,\n+                     &exitcount, PR_TRUE, PR_LOCAL_THREAD);\n+    index++;\n+    CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n+                     PR_MillisecondsToInterval(50), &tcount, exitlock, exitcvar,\n+                     &exitcount, PR_TRUE, PR_GLOBAL_THREAD);\n+    index++;\n+    list[index].lock = PR_NewLock();\n+    list[index].cvar = PR_NewCondVar(list[index].lock);\n+    CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n+                     count, PR_MillisecondsToInterval(50), &tcount, exitlock,\n+                     exitcvar, &exitcount, PR_FALSE, PR_LOCAL_THREAD);\n+    index++;\n+\n+    list[index].lock = PR_NewLock();\n+    list[index].cvar = PR_NewCondVar(list[index].lock);\n+    CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n+                     count, PR_MillisecondsToInterval(50), &tcount, exitlock,\n+                     exitcvar, &exitcount, PR_FALSE, PR_GLOBAL_THREAD);\n+\n+    index++;\n+  }\n+\n+  for (loops = 0; loops < count; loops++) {\n+    /* Wait for threads to finish */\n+    PR_Lock(exitlock);\n+    while (exitcount < arg * 4) {\n+      PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n     }\n-\n-    /* Join all the threads */\n-    for (index = 0; index < (arg * 4); index++) {\n-        PR_JoinThread(list[index].thread);\n-        if (list[index].internal) {\n-            PR_Lock(list[index].lock);\n-            PR_DestroyCondVar(list[index].cvar);\n-            PR_Unlock(list[index].lock);\n-            PR_DestroyLock(list[index].lock);\n-        }\n+    PR_ASSERT(exitcount >= arg * 4);\n+    exitcount -= arg * 4;\n+    PR_Unlock(exitlock);\n+  }\n+\n+  /* Join all the threads */\n+  for (index = 0; index < (arg * 4); index++) {\n+    PR_JoinThread(list[index].thread);\n+    if (list[index].internal) {\n+      PR_Lock(list[index].lock);\n+      PR_DestroyCondVar(list[index].cvar);\n+      PR_Unlock(list[index].lock);\n+      PR_DestroyLock(list[index].lock);\n     }\n+  }\n \n-    PR_DestroyCondVar(sharedcvar);\n-    PR_DestroyLock(sharedlock);\n-    PR_DestroyCondVar(exitcvar);\n-    PR_DestroyLock(exitlock);\n+  PR_DestroyCondVar(sharedcvar);\n+  PR_DestroyLock(sharedlock);\n+  PR_DestroyCondVar(exitcvar);\n+  PR_DestroyLock(exitlock);\n \n-    PR_DELETE(list);\n+  PR_DELETE(list);\n }\n \n-void\n-CondVarMixedTest(void* _arg)\n-{\n-    PRInt32 arg = (PRInt32)_arg;\n-    PRInt32 index, loops;\n-    threadinfo* list;\n-    PRLock* sharedlock;\n-    PRCondVar* sharedcvar;\n-    PRLock* exitlock;\n-    PRCondVar* exitcvar;\n-    PRInt32* ptcount;\n-\n-    exitcount = 0;\n-    tcount = 0;\n-    list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n-    ptcount = (PRInt32*)PR_CALLOC(sizeof(*ptcount) * (arg * 4));\n-\n-    sharedlock = PR_NewLock();\n-    sharedcvar = PR_NewCondVar(sharedlock);\n-    exitlock = PR_NewLock();\n-    exitcvar = PR_NewCondVar(exitlock);\n-\n-    /* Create the threads */\n-    for (index = 0; index < arg * 4;) {\n-        CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n-                         PR_MillisecondsToInterval(50), &tcount, exitlock, exitcvar,\n-                         &exitcount, PR_TRUE, PR_LOCAL_THREAD);\n-        index++;\n-        CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n-                         PR_MillisecondsToInterval(50), &tcount, exitlock, exitcvar,\n-                         &exitcount, PR_TRUE, PR_GLOBAL_THREAD);\n-        index++;\n-        list[index].lock = PR_NewLock();\n-        list[index].cvar = PR_NewCondVar(list[index].lock);\n-        CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n-                         count, PR_MillisecondsToInterval(50), ptcount, exitlock,\n-                         exitcvar, &exitcount, PR_FALSE, PR_LOCAL_THREAD);\n-        index++;\n-        ptcount++;\n-\n-        list[index].lock = PR_NewLock();\n-        list[index].cvar = PR_NewCondVar(list[index].lock);\n-        CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n-                         count, PR_MillisecondsToInterval(50), ptcount, exitlock,\n-                         exitcvar, &exitcount, PR_FALSE, PR_GLOBAL_THREAD);\n-        index++;\n-        ptcount++;\n+void CondVarMixedTest(void* _arg) {\n+  PRInt32 arg = (PRInt32)_arg;\n+  PRInt32 index, loops;\n+  threadinfo* list;\n+  PRLock* sharedlock;\n+  PRCondVar* sharedcvar;\n+  PRLock* exitlock;\n+  PRCondVar* exitcvar;\n+  PRInt32* ptcount;\n+\n+  exitcount = 0;\n+  tcount = 0;\n+  list = (threadinfo*)PR_MALLOC(sizeof(threadinfo) * (arg * 4));\n+  ptcount = (PRInt32*)PR_CALLOC(sizeof(*ptcount) * (arg * 4));\n+\n+  sharedlock = PR_NewLock();\n+  sharedcvar = PR_NewCondVar(sharedlock);\n+  exitlock = PR_NewLock();\n+  exitcvar = PR_NewCondVar(exitlock);\n+\n+  /* Create the threads */\n+  for (index = 0; index < arg * 4;) {\n+    CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n+                     PR_MillisecondsToInterval(50), &tcount, exitlock, exitcvar,\n+                     &exitcount, PR_TRUE, PR_LOCAL_THREAD);\n+    index++;\n+    CreateTestThread(&list[index], index, sharedlock, sharedcvar, count,\n+                     PR_MillisecondsToInterval(50), &tcount, exitlock, exitcvar,\n+                     &exitcount, PR_TRUE, PR_GLOBAL_THREAD);\n+    index++;\n+    list[index].lock = PR_NewLock();\n+    list[index].cvar = PR_NewCondVar(list[index].lock);\n+    CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n+                     count, PR_MillisecondsToInterval(50), ptcount, exitlock,\n+                     exitcvar, &exitcount, PR_FALSE, PR_LOCAL_THREAD);\n+    index++;\n+    ptcount++;\n+\n+    list[index].lock = PR_NewLock();\n+    list[index].cvar = PR_NewCondVar(list[index].lock);\n+    CreateTestThread(&list[index], index, list[index].lock, list[index].cvar,\n+                     count, PR_MillisecondsToInterval(50), ptcount, exitlock,\n+                     exitcvar, &exitcount, PR_FALSE, PR_GLOBAL_THREAD);\n+    index++;\n+    ptcount++;\n+  }\n+\n+  /* Notify every 3rd thread */\n+  for (loops = 0; loops < count; loops++) {\n+    /* Notify the threads */\n+    for (index = 0; index < (arg * 4); index += 3) {\n+      PR_Lock(list[index].lock);\n+      *list[index].tcount++;\n+      PR_NotifyCondVar(list[index].cvar);\n+      PR_Unlock(list[index].lock);\n     }\n-\n-    /* Notify every 3rd thread */\n-    for (loops = 0; loops < count; loops++) {\n-        /* Notify the threads */\n-        for (index = 0; index < (arg * 4); index += 3) {\n-            PR_Lock(list[index].lock);\n-            *list[index].tcount++;\n-            PR_NotifyCondVar(list[index].cvar);\n-            PR_Unlock(list[index].lock);\n-        }\n-        /* Wait for threads to finish */\n-        PR_Lock(exitlock);\n-        while (exitcount < arg * 4) {\n-            PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n-        }\n-        PR_ASSERT(exitcount >= arg * 4);\n-        exitcount -= arg * 4;\n-        PR_Unlock(exitlock);\n+    /* Wait for threads to finish */\n+    PR_Lock(exitlock);\n+    while (exitcount < arg * 4) {\n+      PR_WaitCondVar(exitcvar, PR_SecondsToInterval(60));\n     }\n-\n-    /* Join all the threads */\n-    for (index = 0; index < (arg * 4); index++) {\n-        PR_JoinThread(list[index].thread);\n-        if (list[index].internal) {\n-            PR_Lock(list[index].lock);\n-            PR_DestroyCondVar(list[index].cvar);\n-            PR_Unlock(list[index].lock);\n-            PR_DestroyLock(list[index].lock);\n-        }\n+    PR_ASSERT(exitcount >= arg * 4);\n+    exitcount -= arg * 4;\n+    PR_Unlock(exitlock);\n+  }\n+\n+  /* Join all the threads */\n+  for (index = 0; index < (arg * 4); index++) {\n+    PR_JoinThread(list[index].thread);\n+    if (list[index].internal) {\n+      PR_Lock(list[index].lock);\n+      PR_DestroyCondVar(list[index].cvar);\n+      PR_Unlock(list[index].lock);\n+      PR_DestroyLock(list[index].lock);\n     }\n+  }\n \n-    PR_DestroyCondVar(sharedcvar);\n-    PR_DestroyLock(sharedlock);\n+  PR_DestroyCondVar(sharedcvar);\n+  PR_DestroyLock(sharedlock);\n \n-    PR_DELETE(list);\n+  PR_DELETE(list);\n }\n \n-void\n-CondVarCombinedTest(void* arg)\n-{\n-    PRThread* threads[3];\n-\n-    threads[0] = PR_CreateThread(PR_USER_THREAD, CondVarTest, (void*)arg,\n-                                 PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n-                                 PR_JOINABLE_THREAD, 0);\n-    threads[1] = PR_CreateThread(PR_USER_THREAD, CondVarTimeoutTest, (void*)arg,\n-                                 PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n-                                 PR_JOINABLE_THREAD, 0);\n-    threads[2] = PR_CreateThread(PR_USER_THREAD, CondVarMixedTest, (void*)arg,\n-                                 PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n-                                 PR_JOINABLE_THREAD, 0);\n-\n-    PR_JoinThread(threads[0]);\n-    PR_JoinThread(threads[1]);\n-    PR_JoinThread(threads[2]);\n+void CondVarCombinedTest(void* arg) {\n+  PRThread* threads[3];\n+\n+  threads[0] = PR_CreateThread(PR_USER_THREAD, CondVarTest, (void*)arg,\n+                               PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n+                               PR_JOINABLE_THREAD, 0);\n+  threads[1] = PR_CreateThread(PR_USER_THREAD, CondVarTimeoutTest, (void*)arg,\n+                               PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n+                               PR_JOINABLE_THREAD, 0);\n+  threads[2] = PR_CreateThread(PR_USER_THREAD, CondVarMixedTest, (void*)arg,\n+                               PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n+                               PR_JOINABLE_THREAD, 0);\n+\n+  PR_JoinThread(threads[0]);\n+  PR_JoinThread(threads[1]);\n+  PR_JoinThread(threads[2]);\n }\n \n /************************************************************************/\n \n-static void\n-Measure(void (*func)(void*), PRInt32 arg, const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n+static void Measure(void (*func)(void*), PRInt32 arg, const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n \n-    start = PR_IntervalNow();\n-    (*func)((void*)arg);\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)((void*)arg);\n+  stop = PR_IntervalNow();\n \n-    d = (double)PR_IntervalToMicroseconds(stop - start);\n+  d = (double)PR_IntervalToMicroseconds(stop - start);\n \n-    printf(\"%40s: %6.2f usec\\n\", msg, d / count);\n+  printf(\"%40s: %6.2f usec\\n\", msg, d / count);\n }\n \n-static PRIntn PR_CALLBACK\n-RealMain(int argc, char** argv)\n-{\n-    PRInt32 threads, default_threads = DEFAULT_THREADS;\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"vc:t:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'v': /* debug mode */\n-                _debug_on = 1;\n-                break;\n-            case 'c': /* loop counter */\n-                count = atoi(opt->value);\n-                break;\n-            case 't': /* number of threads involved */\n-                default_threads = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    if (0 == count) {\n-        count = DEFAULT_COUNT;\n+static PRIntn PR_CALLBACK RealMain(int argc, char** argv) {\n+  PRInt32 threads, default_threads = DEFAULT_THREADS;\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"vc:t:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    if (0 == default_threads) {\n-        default_threads = DEFAULT_THREADS;\n+    switch (opt->option) {\n+      case 'v': /* debug mode */\n+        _debug_on = 1;\n+        break;\n+      case 'c': /* loop counter */\n+        count = atoi(opt->value);\n+        break;\n+      case 't': /* number of threads involved */\n+        default_threads = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n-\n-    printf(\n-        \"\\n\\\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  if (0 == count) {\n+    count = DEFAULT_COUNT;\n+  }\n+  if (0 == default_threads) {\n+    default_threads = DEFAULT_THREADS;\n+  }\n+\n+  printf(\n+      \"\\n\\\n CondVar Test:                                                           \\n\\\n                                                                         \\n\\\n Simple test creates several local and global threads; half use a single,\\n\\\n@@ -771,36 +745,34 @@ Lastly, the combined test creates a thread for each of the above three  \\n\\\n cases and they all run simultaneously.                                  \\n\\\n                                                                         \\n\\\n This test is run with %d, %d, %d, and %d threads of each type.\\n\\n\",\n-        default_threads, default_threads * 2, default_threads * 3,\n-        default_threads * 4);\n-\n-    PR_SetConcurrency(2);\n-\n-    for (threads = default_threads; threads < default_threads * 5;\n-         threads += default_threads) {\n-        printf(\"\\n%ld Thread tests\\n\", threads);\n-        Measure(CondVarTestSUU, threads, \"Condvar simple test shared UU\");\n-        Measure(CondVarTestSUK, threads, \"Condvar simple test shared UK\");\n-        Measure(CondVarTestPUU, threads, \"Condvar simple test priv UU\");\n-        Measure(CondVarTestPUK, threads, \"Condvar simple test priv UK\");\n-        Measure(CondVarTest, threads, \"Condvar simple test All\");\n-        Measure(CondVarTimeoutTest, threads, \"Condvar timeout test\");\n+      default_threads, default_threads * 2, default_threads * 3,\n+      default_threads * 4);\n+\n+  PR_SetConcurrency(2);\n+\n+  for (threads = default_threads; threads < default_threads * 5;\n+       threads += default_threads) {\n+    printf(\"\\n%ld Thread tests\\n\", threads);\n+    Measure(CondVarTestSUU, threads, \"Condvar simple test shared UU\");\n+    Measure(CondVarTestSUK, threads, \"Condvar simple test shared UK\");\n+    Measure(CondVarTestPUU, threads, \"Condvar simple test priv UU\");\n+    Measure(CondVarTestPUK, threads, \"Condvar simple test priv UK\");\n+    Measure(CondVarTest, threads, \"Condvar simple test All\");\n+    Measure(CondVarTimeoutTest, threads, \"Condvar timeout test\");\n #if 0\n         Measure(CondVarMixedTest, threads,  \"Condvar mixed timeout test\");\n         Measure(CondVarCombinedTest, threads, \"Combined condvar test\");\n #endif\n-    }\n+  }\n \n-    printf(\"PASS\\n\");\n+  printf(\"PASS\\n\");\n \n-    return 0;\n+  return 0;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv;\n+int main(int argc, char** argv) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\ndiff --git a/nspr/pr/tests/dbmalloc.c b/nspr/pr/tests/dbmalloc.c\nindex 29765c7..b9ddda4 100644\n--- a/nspr/pr/tests/dbmalloc.c\n+++ b/nspr/pr/tests/dbmalloc.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -24,271 +25,256 @@\n #include <string.h>\n #include \"nspr.h\"\n \n-void\n-usage(void)\n-{\n-    fprintf(stderr,\n-            \"Usage: dbmalloc ('-m'|'-s') '-f' num_fails ('-d'|'-n') filename \"\n-            \"[...]\\n\");\n-    exit(0);\n+void usage(void) {\n+  fprintf(stderr,\n+          \"Usage: dbmalloc ('-m'|'-s') '-f' num_fails ('-d'|'-n') filename \"\n+          \"[...]\\n\");\n+  exit(0);\n }\n \n typedef struct node_struct {\n-    struct node_struct *next, *prev;\n-    int line;\n-    char value[4];\n+  struct node_struct *next, *prev;\n+  int line;\n+  char value[4];\n } node_t, *node_pt;\n \n-node_pt\n-get_node(const char* line)\n-{\n-    node_pt rv;\n-    int l = strlen(line);\n-    rv = (node_pt)PR_MALLOC(sizeof(node_t) + l + 1 - 4);\n-    if ((node_pt)0 == rv) {\n-        return (node_pt)0;\n-    }\n-    memcpy(&rv->value[0], line, l + 1);\n-    rv->next = rv->prev = (node_pt)0;\n-    return rv;\n+node_pt get_node(const char* line) {\n+  node_pt rv;\n+  int l = strlen(line);\n+  rv = (node_pt)PR_MALLOC(sizeof(node_t) + l + 1 - 4);\n+  if ((node_pt)0 == rv) {\n+    return (node_pt)0;\n+  }\n+  memcpy(&rv->value[0], line, l + 1);\n+  rv->next = rv->prev = (node_pt)0;\n+  return rv;\n }\n \n-void\n-dump(const char* name, node_pt node, int mf, int debug)\n-{\n-    if ((node_pt)0 != node->prev) {\n-        dump(name, node->prev, mf, debug);\n-    }\n-    if (0 != debug) {\n-        printf(\"[%s]: %6d: %s\", name, node->line, node->value);\n-    }\n-    if (node->line == mf) {\n-        fprintf(stderr, \"[%s]: Line %d was allocated!\\n\", name, node->line);\n-    }\n-    if ((node_pt)0 != node->next) {\n-        dump(name, node->next, mf, debug);\n-    }\n-    return;\n+void dump(const char* name, node_pt node, int mf, int debug) {\n+  if ((node_pt)0 != node->prev) {\n+    dump(name, node->prev, mf, debug);\n+  }\n+  if (0 != debug) {\n+    printf(\"[%s]: %6d: %s\", name, node->line, node->value);\n+  }\n+  if (node->line == mf) {\n+    fprintf(stderr, \"[%s]: Line %d was allocated!\\n\", name, node->line);\n+  }\n+  if ((node_pt)0 != node->next) {\n+    dump(name, node->next, mf, debug);\n+  }\n+  return;\n }\n \n-void\n-release(node_pt node)\n-{\n-    if ((node_pt)0 != node->prev) {\n-        release(node->prev);\n-    }\n-    if ((node_pt)0 != node->next) {\n-        release(node->next);\n-    }\n-    PR_DELETE(node);\n+void release(node_pt node) {\n+  if ((node_pt)0 != node->prev) {\n+    release(node->prev);\n+  }\n+  if ((node_pt)0 != node->next) {\n+    release(node->next);\n+  }\n+  PR_DELETE(node);\n }\n \n-int\n-t2(const char* name, int mf, int debug)\n-{\n-    int rv;\n-    FILE* fp;\n-    int l = 0;\n-    node_pt head = (node_pt)0;\n-    char buffer[BUFSIZ];\n-\n-    fp = fopen(name, \"r\");\n-    if ((FILE*)0 == fp) {\n-        fprintf(stderr, \"[%s]: Cannot open \\\"%s.\\\"\\n\", name, name);\n-        return -1;\n-    }\n-\n-    /* fgets mallocs a buffer, first time through. */\n-    if ((char*)0 == fgets(buffer, BUFSIZ, fp)) {\n-        fprintf(stderr, \"[%s]: \\\"%s\\\" is empty.\\n\", name, name);\n-        (void)fclose(fp);\n-        return -1;\n-    }\n+int t2(const char* name, int mf, int debug) {\n+  int rv;\n+  FILE* fp;\n+  int l = 0;\n+  node_pt head = (node_pt)0;\n+  char buffer[BUFSIZ];\n+\n+  fp = fopen(name, \"r\");\n+  if ((FILE*)0 == fp) {\n+    fprintf(stderr, \"[%s]: Cannot open \\\"%s.\\\"\\n\", name, name);\n+    return -1;\n+  }\n+\n+  /* fgets mallocs a buffer, first time through. */\n+  if ((char*)0 == fgets(buffer, BUFSIZ, fp)) {\n+    fprintf(stderr, \"[%s]: \\\"%s\\\" is empty.\\n\", name, name);\n+    (void)fclose(fp);\n+    return -1;\n+  }\n \n-    rewind(fp);\n+  rewind(fp);\n \n-    if (PR_SUCCESS != PR_ClearMallocCount()) {\n-        fprintf(stderr, \"[%s]: Cannot clear malloc count.\\n\", name);\n-        (void)fclose(fp);\n-        return -1;\n-    }\n+  if (PR_SUCCESS != PR_ClearMallocCount()) {\n+    fprintf(stderr, \"[%s]: Cannot clear malloc count.\\n\", name);\n+    (void)fclose(fp);\n+    return -1;\n+  }\n \n-    if (PR_SUCCESS != PR_SetMallocCountdown(mf)) {\n-        fprintf(stderr, \"[%s]: Cannot set malloc countdown to %d\\n\", name, mf);\n-        (void)fclose(fp);\n-        return -1;\n-    }\n+  if (PR_SUCCESS != PR_SetMallocCountdown(mf)) {\n+    fprintf(stderr, \"[%s]: Cannot set malloc countdown to %d\\n\", name, mf);\n+    (void)fclose(fp);\n+    return -1;\n+  }\n \n-    while (fgets(buffer, BUFSIZ, fp)) {\n-        node_pt n;\n-        node_pt* w = &head;\n+  while (fgets(buffer, BUFSIZ, fp)) {\n+    node_pt n;\n+    node_pt* w = &head;\n \n-        if ((strlen(buffer) == (BUFSIZ - 1)) && (buffer[BUFSIZ - 2] != '\\n')) {\n-            buffer[BUFSIZ - 2] == '\\n';\n-        }\n+    if ((strlen(buffer) == (BUFSIZ - 1)) && (buffer[BUFSIZ - 2] != '\\n')) {\n+      buffer[BUFSIZ - 2] == '\\n';\n+    }\n \n-        l++;\n+    l++;\n \n-        n = get_node(buffer);\n-        if ((node_pt)0 == n) {\n-            printf(\"[%s]: Line %d: malloc failure!\\n\", name, l);\n-            continue;\n-        }\n+    n = get_node(buffer);\n+    if ((node_pt)0 == n) {\n+      printf(\"[%s]: Line %d: malloc failure!\\n\", name, l);\n+      continue;\n+    }\n \n-        n->line = l;\n+    n->line = l;\n \n-        while (1) {\n-            int comp;\n+    while (1) {\n+      int comp;\n \n-            if ((node_pt)0 == *w) {\n-                *w = n;\n-                break;\n-            }\n+      if ((node_pt)0 == *w) {\n+        *w = n;\n+        break;\n+      }\n \n-            comp = strcmp((*w)->value, n->value);\n-            if (comp < 0) {\n-                w = &(*w)->next;\n-            } else {\n-                w = &(*w)->prev;\n-            }\n-        }\n+      comp = strcmp((*w)->value, n->value);\n+      if (comp < 0) {\n+        w = &(*w)->next;\n+      } else {\n+        w = &(*w)->prev;\n+      }\n     }\n+  }\n \n-    (void)fclose(fp);\n+  (void)fclose(fp);\n \n-    dump(name, head, mf, debug);\n+  dump(name, head, mf, debug);\n \n-    rv = PR_GetMallocCount();\n-    PR_ClearMallocCountdown();\n+  rv = PR_GetMallocCount();\n+  PR_ClearMallocCountdown();\n \n-    release(head);\n+  release(head);\n \n-    return rv;\n+  return rv;\n }\n \n int nf = 0;\n int debug = 0;\n \n-void\n-test(const char* name)\n-{\n-    int n, i;\n+void test(const char* name) {\n+  int n, i;\n \n-    extern int nf, debug;\n+  extern int nf, debug;\n \n-    printf(\"[%s]: starting test 0\\n\", name);\n-    n = t2(name, 0, debug);\n-    if (-1 == n) {\n-        return;\n-    }\n-    printf(\"[%s]: test 0 had %ld allocations.\\n\", name, n);\n-\n-    if (0 >= n) {\n-        return;\n-    }\n+  printf(\"[%s]: starting test 0\\n\", name);\n+  n = t2(name, 0, debug);\n+  if (-1 == n) {\n+    return;\n+  }\n+  printf(\"[%s]: test 0 had %ld allocations.\\n\", name, n);\n \n-    for (i = 0; i < nf; i++) {\n-        int which = rand() % n;\n-        if (0 == which) {\n-            printf(\"[%s]: starting test %d -- no allocation should fail\\n\", name,\n-                   i + 1);\n-        } else {\n-            printf(\"[%s]: starting test %d -- allocation %d should fail\\n\", name,\n-                   i + 1, which);\n-        }\n-        (void)t2(name, which, debug);\n-        printf(\"[%s]: test %d done.\\n\", name, i + 1);\n+  if (0 >= n) {\n+    return;\n+  }\n+\n+  for (i = 0; i < nf; i++) {\n+    int which = rand() % n;\n+    if (0 == which) {\n+      printf(\"[%s]: starting test %d -- no allocation should fail\\n\", name,\n+             i + 1);\n+    } else {\n+      printf(\"[%s]: starting test %d -- allocation %d should fail\\n\", name,\n+             i + 1, which);\n     }\n+    (void)t2(name, which, debug);\n+    printf(\"[%s]: test %d done.\\n\", name, i + 1);\n+  }\n \n-    return;\n+  return;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    int okay = 0;\n-    int multithread = 0;\n-\n-    struct threadlist {\n-        struct threadlist* next;\n-        PRThread* thread;\n-    }* threadhead = (struct threadlist*)0;\n-\n-    extern int nf, debug;\n-\n-    srand(time(0));\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    printf(\"[main]: We %s using the debugging malloc.\\n\",\n-           PR_IsDebuggingMalloc() ? \"ARE\" : \"ARE NOT\");\n-\n-    while (argv++, --argc) {\n-        if ('-' == argv[0][0]) {\n-            switch (argv[0][1]) {\n-                case 'f':\n-                    nf = atoi(argv[0][2] ? &argv[0][2] : --argc ? *++argv\n-                                                                : \"0\");\n-                    break;\n-                case 'd':\n-                    debug = 1;\n-                    break;\n-                case 'n':\n-                    debug = 0;\n-                    break;\n-                case 'm':\n-                    multithread = 1;\n-                    break;\n-                case 's':\n-                    multithread = 0;\n-                    break;\n-                default:\n-                    usage();\n-                    break;\n-            }\n-        } else {\n-            FILE* fp = fopen(*argv, \"r\");\n-            if ((FILE*)0 == fp) {\n-                fprintf(stderr, \"Cannot open \\\"%s.\\\"\\n\", *argv);\n-                continue;\n-            }\n-\n-            okay++;\n-            (void)fclose(fp);\n-            if (multithread) {\n-                struct threadlist* n;\n-\n-                n = (struct threadlist*)malloc(sizeof(struct threadlist));\n-                if ((struct threadlist*)0 == n) {\n-                    fprintf(stderr, \"This is getting tedious. \\\"%s\\\"\\n\", *argv);\n-                    continue;\n-                }\n-\n-                n->next = threadhead;\n-                n->thread = PR_CreateThread(PR_USER_THREAD, (void (*)(void*))test,\n-                                            *argv, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n-                                            PR_JOINABLE_THREAD, 0);\n-                if ((PRThread*)0 == n->thread) {\n-                    fprintf(stderr, \"Can't create thread for \\\"%s.\\\"\\n\", *argv);\n-                    continue;\n-                } else {\n-                    threadhead = n;\n-                }\n-            } else {\n-                test(*argv);\n-            }\n+int main(int argc, char** argv) {\n+  int okay = 0;\n+  int multithread = 0;\n+\n+  struct threadlist {\n+    struct threadlist* next;\n+    PRThread* thread;\n+  }* threadhead = (struct threadlist*)0;\n+\n+  extern int nf, debug;\n+\n+  srand(time(0));\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  printf(\"[main]: We %s using the debugging malloc.\\n\",\n+         PR_IsDebuggingMalloc() ? \"ARE\" : \"ARE NOT\");\n+\n+  while (argv++, --argc) {\n+    if ('-' == argv[0][0]) {\n+      switch (argv[0][1]) {\n+        case 'f':\n+          nf = atoi(argv[0][2] ? &argv[0][2] : --argc ? *++argv : \"0\");\n+          break;\n+        case 'd':\n+          debug = 1;\n+          break;\n+        case 'n':\n+          debug = 0;\n+          break;\n+        case 'm':\n+          multithread = 1;\n+          break;\n+        case 's':\n+          multithread = 0;\n+          break;\n+        default:\n+          usage();\n+          break;\n+      }\n+    } else {\n+      FILE* fp = fopen(*argv, \"r\");\n+      if ((FILE*)0 == fp) {\n+        fprintf(stderr, \"Cannot open \\\"%s.\\\"\\n\", *argv);\n+        continue;\n+      }\n+\n+      okay++;\n+      (void)fclose(fp);\n+      if (multithread) {\n+        struct threadlist* n;\n+\n+        n = (struct threadlist*)malloc(sizeof(struct threadlist));\n+        if ((struct threadlist*)0 == n) {\n+          fprintf(stderr, \"This is getting tedious. \\\"%s\\\"\\n\", *argv);\n+          continue;\n         }\n-    }\n \n-    if (okay == 0) {\n-        usage();\n-    } else\n-        while ((struct threadlist*)0 != threadhead) {\n-            struct threadlist* x = threadhead->next;\n-            (void)PR_JoinThread(threadhead->thread);\n-            PR_DELETE(threadhead);\n-            threadhead = x;\n+        n->next = threadhead;\n+        n->thread = PR_CreateThread(PR_USER_THREAD, (void (*)(void*))test,\n+                                    *argv, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n+                                    PR_JOINABLE_THREAD, 0);\n+        if ((PRThread*)0 == n->thread) {\n+          fprintf(stderr, \"Can't create thread for \\\"%s.\\\"\\n\", *argv);\n+          continue;\n+        } else {\n+          threadhead = n;\n         }\n+      } else {\n+        test(*argv);\n+      }\n+    }\n+  }\n+\n+  if (okay == 0) {\n+    usage();\n+  } else\n+    while ((struct threadlist*)0 != threadhead) {\n+      struct threadlist* x = threadhead->next;\n+      (void)PR_JoinThread(threadhead->thread);\n+      PR_DELETE(threadhead);\n+      threadhead = x;\n+    }\n \n-    return 0;\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/dbmalloc1.c b/nspr/pr/tests/dbmalloc1.c\nindex af729a6..3180af6 100644\n--- a/nspr/pr/tests/dbmalloc1.c\n+++ b/nspr/pr/tests/dbmalloc1.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -39,63 +40,57 @@ PRIntn debug_mode;\n int should_fail = 0;\n int actually_failed = 0;\n \n-void\n-r1(void)\n-{\n-    int i;\n-    actually_failed = 0;\n-    for (i = 0; i < 5; i++) {\n-        void* x = PR_MALLOC(128);\n-        if ((void*)0 == x) {\n-            if (debug_mode) {\n-                printf(\"\\tMalloc %d failed.\\n\", i + 1);\n-            }\n-            actually_failed = 1;\n-        }\n-        PR_DELETE(x);\n+void r1(void) {\n+  int i;\n+  actually_failed = 0;\n+  for (i = 0; i < 5; i++) {\n+    void* x = PR_MALLOC(128);\n+    if ((void*)0 == x) {\n+      if (debug_mode) {\n+        printf(\"\\tMalloc %d failed.\\n\", i + 1);\n+      }\n+      actually_failed = 1;\n     }\n+    PR_DELETE(x);\n+  }\n \n-    if (((should_fail != actually_failed) & (!debug_mode))) {\n-        failed_already = 1;\n-    }\n+  if (((should_fail != actually_failed) & (!debug_mode))) {\n+    failed_already = 1;\n+  }\n \n-    return;\n+  return;\n }\n \n-void\n-r2(void)\n-{\n-    int i;\n+void r2(void) {\n+  int i;\n \n-    for (i = 0; i <= 5; i++) {\n-        should_fail = 0;\n-        if (0 == i) {\n-            if (debug_mode) {\n-                printf(\"No malloc should fail:\\n\");\n-            }\n-        } else {\n-            if (debug_mode) {\n-                printf(\"Malloc %d should fail:\\n\", i);\n-            }\n-            should_fail = 1;\n-        }\n-        PR_SetMallocCountdown(i);\n-        r1();\n-        PR_ClearMallocCountdown();\n+  for (i = 0; i <= 5; i++) {\n+    should_fail = 0;\n+    if (0 == i) {\n+      if (debug_mode) {\n+        printf(\"No malloc should fail:\\n\");\n+      }\n+    } else {\n+      if (debug_mode) {\n+        printf(\"Malloc %d should fail:\\n\", i);\n+      }\n+      should_fail = 1;\n     }\n+    PR_SetMallocCountdown(i);\n+    r1();\n+    PR_ClearMallocCountdown();\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    /* main test */\n+int main(int argc, char** argv) {\n+  /* main test */\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-    r2();\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  r2();\n \n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/dceemu.c b/nspr/pr/tests/dceemu.c\nindex 2bef059..d59b2f7 100644\n--- a/nspr/pr/tests/dceemu.c\n+++ b/nspr/pr/tests/dceemu.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -35,78 +36,74 @@\n PRIntn failed_already = 0;\n PRIntn debug_mode = 0;\n \n-static PRIntn\n-prmain(PRIntn argc, char** argv)\n-{\n-    PRStatus rv;\n-    PRLock* ml = PR_NewLock();\n-    PRCondVar* cv = PRP_NewNakedCondVar();\n-    PRIntervalTime tenmsecs = PR_MillisecondsToInterval(10);\n-\n-    rv = PRP_TryLock(ml);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    if ((rv != PR_SUCCESS) & (!debug_mode)) {\n-        failed_already = 1;\n-    }\n-\n-    rv = PRP_TryLock(ml);\n-    PR_ASSERT(PR_FAILURE == rv);\n-    if ((rv != PR_FAILURE) & (!debug_mode)) {\n-        failed_already = 1;\n-    }\n-\n-    rv = PRP_NakedNotify(cv);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    if ((rv != PR_SUCCESS) & (!debug_mode)) {\n-        failed_already = 1;\n-    }\n-\n-    rv = PRP_NakedBroadcast(cv);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    if ((rv != PR_SUCCESS) & (!debug_mode)) {\n-        failed_already = 1;\n-    }\n-\n-    rv = PRP_NakedWait(cv, ml, tenmsecs);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    if ((rv != PR_SUCCESS) & (!debug_mode)) {\n-        failed_already = 1;\n-    }\n-\n-    PR_Unlock(ml);\n-\n-    rv = PRP_NakedNotify(cv);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    if ((rv != PR_SUCCESS) & (!debug_mode)) {\n-        failed_already = 1;\n-    }\n-\n-    rv = PRP_NakedBroadcast(cv);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    if ((rv != PR_SUCCESS) & (!debug_mode)) {\n-        failed_already = 1;\n-    }\n-\n-    PRP_DestroyNakedCondVar(cv);\n-    PR_DestroyLock(ml);\n-\n-    if (debug_mode) {\n-        printf(\"Test succeeded\\n\");\n-    }\n-\n-    return 0;\n+static PRIntn prmain(PRIntn argc, char** argv) {\n+  PRStatus rv;\n+  PRLock* ml = PR_NewLock();\n+  PRCondVar* cv = PRP_NewNakedCondVar();\n+  PRIntervalTime tenmsecs = PR_MillisecondsToInterval(10);\n+\n+  rv = PRP_TryLock(ml);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  if ((rv != PR_SUCCESS) & (!debug_mode)) {\n+    failed_already = 1;\n+  }\n+\n+  rv = PRP_TryLock(ml);\n+  PR_ASSERT(PR_FAILURE == rv);\n+  if ((rv != PR_FAILURE) & (!debug_mode)) {\n+    failed_already = 1;\n+  }\n+\n+  rv = PRP_NakedNotify(cv);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  if ((rv != PR_SUCCESS) & (!debug_mode)) {\n+    failed_already = 1;\n+  }\n+\n+  rv = PRP_NakedBroadcast(cv);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  if ((rv != PR_SUCCESS) & (!debug_mode)) {\n+    failed_already = 1;\n+  }\n+\n+  rv = PRP_NakedWait(cv, ml, tenmsecs);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  if ((rv != PR_SUCCESS) & (!debug_mode)) {\n+    failed_already = 1;\n+  }\n+\n+  PR_Unlock(ml);\n+\n+  rv = PRP_NakedNotify(cv);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  if ((rv != PR_SUCCESS) & (!debug_mode)) {\n+    failed_already = 1;\n+  }\n+\n+  rv = PRP_NakedBroadcast(cv);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  if ((rv != PR_SUCCESS) & (!debug_mode)) {\n+    failed_already = 1;\n+  }\n+\n+  PRP_DestroyNakedCondVar(cv);\n+  PR_DestroyLock(ml);\n+\n+  if (debug_mode) {\n+    printf(\"Test succeeded\\n\");\n+  }\n+\n+  return 0;\n \n } /* prmain */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PR_Initialize(prmain, argc, argv, 0);\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+int main(int argc, char** argv) {\n+  PR_Initialize(prmain, argc, argv, 0);\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n } /* main */\n \n /* decemu.c */\ndiff --git a/nspr/pr/tests/depend.c b/nspr/pr/tests/depend.c\nindex d579afe..eee9ce9 100644\n--- a/nspr/pr/tests/depend.c\n+++ b/nspr/pr/tests/depend.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -30,105 +31,93 @@\n #include <stdio.h>\n #include <stdlib.h>\n \n-static void\n-PrintVersion(const char* msg, const PRVersion* info, PRIntn tab)\n-{\n-    static const len = 20;\n-    static const char* tabs = { \"                    \" };\n-\n-    tab *= 2;\n-    if (tab > len) {\n-        tab = len;\n-    }\n-    printf(\"%s\", &tabs[len - tab]);\n-    printf(\"%s \", msg);\n-    printf(\"%s \", info->id);\n-    printf(\"%d.%d\", info->major, info->minor);\n-    if (0 != info->patch) {\n-        printf(\".p%d\", info->patch);\n-    }\n-    printf(\"\\n\");\n+static void PrintVersion(const char* msg, const PRVersion* info, PRIntn tab) {\n+  static const len = 20;\n+  static const char* tabs = {\"                    \"};\n+\n+  tab *= 2;\n+  if (tab > len) {\n+    tab = len;\n+  }\n+  printf(\"%s\", &tabs[len - tab]);\n+  printf(\"%s \", msg);\n+  printf(\"%s \", info->id);\n+  printf(\"%d.%d\", info->major, info->minor);\n+  if (0 != info->patch) {\n+    printf(\".p%d\", info->patch);\n+  }\n+  printf(\"\\n\");\n } /* PrintDependency */\n \n-static void\n-ChaseDependents(const PRVersionInfo* info, PRIntn tab)\n-{\n-    PrintVersion(\"exports\", &info->selfExport, tab);\n-    if (NULL != info->importEnumerator) {\n-        const PRDependencyInfo* dependent = NULL;\n-        while (NULL != (dependent = info->importEnumerator(dependent))) {\n-            const PRVersionInfo* import = dependent->exportInfoFn();\n-            PrintVersion(\"imports\", &dependent->importNeeded, tab);\n-            ChaseDependents(import, tab + 1);\n-        }\n+static void ChaseDependents(const PRVersionInfo* info, PRIntn tab) {\n+  PrintVersion(\"exports\", &info->selfExport, tab);\n+  if (NULL != info->importEnumerator) {\n+    const PRDependencyInfo* dependent = NULL;\n+    while (NULL != (dependent = info->importEnumerator(dependent))) {\n+      const PRVersionInfo* import = dependent->exportInfoFn();\n+      PrintVersion(\"imports\", &dependent->importNeeded, tab);\n+      ChaseDependents(import, tab + 1);\n     }\n+  }\n } /* ChaseDependents */\n \n static PRVersionInfo hack_export;\n static PRVersionInfo dummy_export;\n static PRDependencyInfo dummy_imports[2];\n \n-static const PRVersionInfo*\n-HackExportInfo(void)\n-{\n-    hack_export.selfExport.major = 11;\n-    hack_export.selfExport.minor = 10;\n-    hack_export.selfExport.patch = 200;\n-    hack_export.selfExport.id = \"Hack\";\n-    hack_export.importEnumerator = NULL;\n-    return &hack_export;\n+static const PRVersionInfo* HackExportInfo(void) {\n+  hack_export.selfExport.major = 11;\n+  hack_export.selfExport.minor = 10;\n+  hack_export.selfExport.patch = 200;\n+  hack_export.selfExport.id = \"Hack\";\n+  hack_export.importEnumerator = NULL;\n+  return &hack_export;\n }\n \n-static const PRDependencyInfo*\n-DummyImports(const PRDependencyInfo* previous)\n-{\n-    if (NULL == previous) {\n-        return &dummy_imports[0];\n-    } else if (&dummy_imports[0] == previous) {\n-        return &dummy_imports[1];\n-    } else if (&dummy_imports[1] == previous) {\n-        return NULL;\n-    }\n+static const PRDependencyInfo* DummyImports(const PRDependencyInfo* previous) {\n+  if (NULL == previous) {\n+    return &dummy_imports[0];\n+  } else if (&dummy_imports[0] == previous) {\n+    return &dummy_imports[1];\n+  } else if (&dummy_imports[1] == previous) {\n+    return NULL;\n+  }\n } /* DummyImports */\n \n-static const PRVersionInfo*\n-DummyLibVersion(void)\n-{\n-    dummy_export.selfExport.major = 1;\n-    dummy_export.selfExport.minor = 0;\n-    dummy_export.selfExport.patch = 0;\n-    dummy_export.selfExport.id = \"Dumbass application\";\n-    dummy_export.importEnumerator = DummyImports;\n-\n-    dummy_imports[0].importNeeded.major = 2;\n-    dummy_imports[0].importNeeded.minor = 0;\n-    dummy_imports[0].importNeeded.patch = 0;\n-    dummy_imports[0].importNeeded.id = \"Netscape Portable Runtime\";\n-    dummy_imports[0].exportInfoFn = PR_ExportInfo;\n-\n-    dummy_imports[1].importNeeded.major = 5;\n-    dummy_imports[1].importNeeded.minor = 1;\n-    dummy_imports[1].importNeeded.patch = 2;\n-    dummy_imports[1].importNeeded.id = \"Hack Library\";\n-    dummy_imports[1].exportInfoFn = HackExportInfo;\n-\n-    return &dummy_export;\n+static const PRVersionInfo* DummyLibVersion(void) {\n+  dummy_export.selfExport.major = 1;\n+  dummy_export.selfExport.minor = 0;\n+  dummy_export.selfExport.patch = 0;\n+  dummy_export.selfExport.id = \"Dumbass application\";\n+  dummy_export.importEnumerator = DummyImports;\n+\n+  dummy_imports[0].importNeeded.major = 2;\n+  dummy_imports[0].importNeeded.minor = 0;\n+  dummy_imports[0].importNeeded.patch = 0;\n+  dummy_imports[0].importNeeded.id = \"Netscape Portable Runtime\";\n+  dummy_imports[0].exportInfoFn = PR_ExportInfo;\n+\n+  dummy_imports[1].importNeeded.major = 5;\n+  dummy_imports[1].importNeeded.minor = 1;\n+  dummy_imports[1].importNeeded.patch = 2;\n+  dummy_imports[1].importNeeded.id = \"Hack Library\";\n+  dummy_imports[1].exportInfoFn = HackExportInfo;\n+\n+  return &dummy_export;\n } /* DummyLibVersion */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn tab = 0;\n-    const PRVersionInfo* info = DummyLibVersion();\n-    const char *buildDate = __DATE__, *buildTime = __TIME__;\n+int main(int argc, char** argv) {\n+  PRIntn tab = 0;\n+  const PRVersionInfo* info = DummyLibVersion();\n+  const char *buildDate = __DATE__, *buildTime = __TIME__;\n \n-    printf(\"Depend.c build time is %s %s\\n\", buildDate, buildTime);\n+  printf(\"Depend.c build time is %s %s\\n\", buildDate, buildTime);\n \n-    if (NULL != info) {\n-        ChaseDependents(info, tab);\n-    }\n+  if (NULL != info) {\n+    ChaseDependents(info, tab);\n+  }\n \n-    return 0;\n+  return 0;\n } /* main */\n \n /* depend.c */\ndiff --git a/nspr/pr/tests/dll/.cvsignore b/nspr/pr/tests/dll/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/pr/tests/dll/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/pr/tests/dll/mygetval.c b/nspr/pr/tests/dll/mygetval.c\nindex 540b3b4..1f5c8e5 100644\n--- a/nspr/pr/tests/dll/mygetval.c\n+++ b/nspr/pr/tests/dll/mygetval.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,5 +7,4 @@\n \n extern PRIntn my_global;\n \n-PR_IMPLEMENT(PRIntn)\n-My_GetValue(void) { return my_global; }\n+PR_IMPLEMENT(PRIntn) My_GetValue() { return my_global; }\ndiff --git a/nspr/pr/tests/dll/mysetval.c b/nspr/pr/tests/dll/mysetval.c\nindex ce9270b..fce6b8a 100644\n--- a/nspr/pr/tests/dll/mysetval.c\n+++ b/nspr/pr/tests/dll/mysetval.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -6,5 +7,4 @@\n \n PRIntn my_global = 0;\n \n-PR_IMPLEMENT(void)\n-My_SetValue(PRIntn val) { my_global = val; }\n+PR_IMPLEMENT(void) My_SetValue(PRIntn val) { my_global = val; }\ndiff --git a/nspr/pr/tests/dlltest.c b/nspr/pr/tests/dlltest.c\nindex 10a2d6e..4fa0a3f 100644\n--- a/nspr/pr/tests/dlltest.c\n+++ b/nspr/pr/tests/dlltest.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -42,177 +43,175 @@ typedef void(PR_CALLBACK* SetFcnType)(PRIntn);\n PRIntn failed_already = 0;\n PRIntn debug_mode;\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRLibrary *lib, *lib2; /* two handles to the same library */\n-    GetFcnType getFcn;\n-    SetFcnType setFcn;\n-    PRIntn value;\n-    PRStatus status;\n-    char* libName;\n-\n-    if (argc >= 2 && PL_strcmp(argv[1], \"-d\") == 0) {\n-        debug_mode = 1;\n+int main(int argc, char** argv) {\n+  PRLibrary *lib, *lib2; /* two handles to the same library */\n+  GetFcnType getFcn;\n+  SetFcnType setFcn;\n+  PRIntn value;\n+  PRStatus status;\n+  char* libName;\n+\n+  if (argc >= 2 && PL_strcmp(argv[1], \"-d\") == 0) {\n+    debug_mode = 1;\n+  }\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  /*\n+   * Test 1: load the library, look up the symbols, call the functions,\n+   * and check the results.\n+   */\n+\n+  libName = PR_GetLibraryName(\"dll\", \"my\");\n+  if (debug_mode) {\n+    printf(\"Loading library %s\\n\", libName);\n+  }\n+  lib = PR_LoadLibrary(libName);\n+  PR_FreeLibraryName(libName);\n+  if (lib == NULL) {\n+    PRInt32 textLength = PR_GetErrorTextLength();\n+    char* text = (char*)PR_MALLOC(textLength + 1);\n+    text[0] = '\\0';\n+    (void)PR_GetErrorText(text);\n+    fprintf(stderr, \"PR_LoadLibrary failed (%d, %d, %s)\\n\", PR_GetError(),\n+            PR_GetOSError(), text);\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    }\n+  }\n+  getFcn = (GetFcnType)PR_FindSymbol(lib, \"My_GetValue\");\n+  setFcn = (SetFcnType)PR_FindFunctionSymbol(lib, \"My_SetValue\");\n+  (*setFcn)(888);\n+  value = (*getFcn)();\n+  if (value != 888) {\n+    fprintf(stderr, \"Test 1 failed: set value to 888, but got %d\\n\", value);\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    }\n+  }\n+  if (debug_mode) {\n+    printf(\"Test 1 passed\\n\");\n+  }\n+\n+  /*\n+   * Test 2: get a second handle to the same library (this should increment\n+   * the reference count), look up the symbols, call the functions, and\n+   * check the results.\n+   */\n+\n+  getFcn = (GetFcnType)PR_FindSymbolAndLibrary(\"My_GetValue\", &lib2);\n+  if (NULL == getFcn || lib != lib2) {\n+    fprintf(stderr,\n+            \"Test 2 failed: handles for the same library are not \"\n+            \"equal: handle 1: %p, handle 2: %p\\n\",\n+            lib, lib2);\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    }\n+  }\n+  setFcn = (SetFcnType)PR_FindSymbol(lib2, \"My_SetValue\");\n+  value = (*getFcn)();\n+  if (value != 888) {\n+    fprintf(stderr, \"Test 2 failed: value should be 888, but got %d\\n\", value);\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    }\n+  }\n+  (*setFcn)(777);\n+  value = (*getFcn)();\n+  if (value != 777) {\n+    fprintf(stderr, \"Test 2 failed: set value to 777, but got %d\\n\", value);\n+    if (!debug_mode) {\n+      failed_already = 1;\n     }\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    /*\n-     * Test 1: load the library, look up the symbols, call the functions,\n-     * and check the results.\n-     */\n-\n-    libName = PR_GetLibraryName(\"dll\", \"my\");\n-    if (debug_mode) {\n-        printf(\"Loading library %s\\n\", libName);\n-    }\n-    lib = PR_LoadLibrary(libName);\n-    PR_FreeLibraryName(libName);\n-    if (lib == NULL) {\n-        PRInt32 textLength = PR_GetErrorTextLength();\n-        char* text = (char*)PR_MALLOC(textLength + 1);\n-        text[0] = '\\0';\n-        (void)PR_GetErrorText(text);\n-        fprintf(stderr, \"PR_LoadLibrary failed (%d, %d, %s)\\n\", PR_GetError(),\n-                PR_GetOSError(), text);\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-    }\n-    getFcn = (GetFcnType)PR_FindSymbol(lib, \"My_GetValue\");\n-    setFcn = (SetFcnType)PR_FindFunctionSymbol(lib, \"My_SetValue\");\n-    (*setFcn)(888);\n-    value = (*getFcn)();\n-    if (value != 888) {\n-        fprintf(stderr, \"Test 1 failed: set value to 888, but got %d\\n\", value);\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-    }\n-    if (debug_mode) {\n-        printf(\"Test 1 passed\\n\");\n-    }\n-\n-    /*\n-     * Test 2: get a second handle to the same library (this should increment\n-     * the reference count), look up the symbols, call the functions, and\n-     * check the results.\n-     */\n-\n-    getFcn = (GetFcnType)PR_FindSymbolAndLibrary(\"My_GetValue\", &lib2);\n-    if (NULL == getFcn || lib != lib2) {\n-        fprintf(stderr,\n-                \"Test 2 failed: handles for the same library are not \"\n-                \"equal: handle 1: %p, handle 2: %p\\n\",\n-                lib, lib2);\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-    }\n-    setFcn = (SetFcnType)PR_FindSymbol(lib2, \"My_SetValue\");\n-    value = (*getFcn)();\n-    if (value != 888) {\n-        fprintf(stderr, \"Test 2 failed: value should be 888, but got %d\\n\", value);\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-    }\n-    (*setFcn)(777);\n-    value = (*getFcn)();\n-    if (value != 777) {\n-        fprintf(stderr, \"Test 2 failed: set value to 777, but got %d\\n\", value);\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n-    }\n-    if (debug_mode) {\n-        printf(\"Test 2 passed\\n\");\n-    }\n-\n-    /*\n-     * Test 3: unload the library.  The library should still be accessible\n-     * via the second handle.  do the same things as above.\n-     */\n-\n-    status = PR_UnloadLibrary(lib);\n-    if (PR_FAILURE == status) {\n-        fprintf(stderr, \"Test 3 failed: cannot unload library: (%d, %d)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n+    goto exit_now;\n+  }\n+  if (debug_mode) {\n+    printf(\"Test 2 passed\\n\");\n+  }\n+\n+  /*\n+   * Test 3: unload the library.  The library should still be accessible\n+   * via the second handle.  do the same things as above.\n+   */\n+\n+  status = PR_UnloadLibrary(lib);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"Test 3 failed: cannot unload library: (%d, %d)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    if (!debug_mode) {\n+      failed_already = 1;\n     }\n-    getFcn = (GetFcnType)PR_FindFunctionSymbol(lib2, \"My_GetValue\");\n-    setFcn = (SetFcnType)PR_FindSymbol(lib2, \"My_SetValue\");\n-    (*setFcn)(666);\n-    value = (*getFcn)();\n-    if (value != 666) {\n-        fprintf(stderr, \"Test 3 failed: set value to 666, but got %d\\n\", value);\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n+    goto exit_now;\n+  }\n+  getFcn = (GetFcnType)PR_FindFunctionSymbol(lib2, \"My_GetValue\");\n+  setFcn = (SetFcnType)PR_FindSymbol(lib2, \"My_SetValue\");\n+  (*setFcn)(666);\n+  value = (*getFcn)();\n+  if (value != 666) {\n+    fprintf(stderr, \"Test 3 failed: set value to 666, but got %d\\n\", value);\n+    if (!debug_mode) {\n+      failed_already = 1;\n     }\n-    if (debug_mode) {\n-        printf(\"Test 3 passed\\n\");\n+    goto exit_now;\n+  }\n+  if (debug_mode) {\n+    printf(\"Test 3 passed\\n\");\n+  }\n+\n+  /*\n+   * Test 4: unload the library, testing the reference count mechanism.\n+   */\n+\n+  status = PR_UnloadLibrary(lib2);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"Test 4 failed: cannot unload library: (%d, %d)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    if (!debug_mode) {\n+      failed_already = 1;\n     }\n-\n-    /*\n-     * Test 4: unload the library, testing the reference count mechanism.\n-     */\n-\n-    status = PR_UnloadLibrary(lib2);\n-    if (PR_FAILURE == status) {\n-        fprintf(stderr, \"Test 4 failed: cannot unload library: (%d, %d)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n+    goto exit_now;\n+  }\n+  getFcn = (GetFcnType)PR_FindFunctionSymbolAndLibrary(\"My_GetValue\", &lib2);\n+  if (NULL != getFcn) {\n+    fprintf(stderr,\n+            \"Test 4 failed: how can we find a symbol \"\n+            \"in an already unloaded library?\\n\");\n+    if (!debug_mode) {\n+      failed_already = 1;\n     }\n-    getFcn = (GetFcnType)PR_FindFunctionSymbolAndLibrary(\"My_GetValue\", &lib2);\n-    if (NULL != getFcn) {\n-        fprintf(stderr,\n-                \"Test 4 failed: how can we find a symbol \"\n-                \"in an already unloaded library?\\n\");\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n+    goto exit_now;\n+  }\n+  if (debug_mode) {\n+    printf(\"Test 4 passed\\n\");\n+  }\n+\n+  /*\n+  ** Test 5: LoadStaticLibrary()\n+  */\n+  {\n+    PRStaticLinkTable slt[10];\n+    PRLibrary* lib;\n+\n+    lib = PR_LoadStaticLibrary(\"my.dll\", slt);\n+    if (lib == NULL) {\n+      fprintf(stderr, \"Test 5: LoadStatiLibrary() failed\\n\");\n+      goto exit_now;\n     }\n     if (debug_mode) {\n-        printf(\"Test 4 passed\\n\");\n+      printf(\"Test 5 passed\\n\");\n     }\n+  }\n \n-    /*\n-    ** Test 5: LoadStaticLibrary()\n-    */\n-    {\n-        PRStaticLinkTable slt[10];\n-        PRLibrary* lib;\n-\n-        lib = PR_LoadStaticLibrary(\"my.dll\", slt);\n-        if (lib == NULL) {\n-            fprintf(stderr, \"Test 5: LoadStatiLibrary() failed\\n\");\n-            goto exit_now;\n-        }\n-        if (debug_mode) {\n-            printf(\"Test 5 passed\\n\");\n-        }\n-    }\n-\n-    goto exit_now;\n+  goto exit_now;\n exit_now:\n-    PR_Cleanup();\n-\n-    if (failed_already) {\n-        printf(\"FAILED\\n\");\n-        return 1;\n-    } else {\n-        printf(\"PASSED\\n\");\n-        return 0;\n-    }\n+  PR_Cleanup();\n+\n+  if (failed_already) {\n+    printf(\"FAILED\\n\");\n+    return 1;\n+  } else {\n+    printf(\"PASSED\\n\");\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/dtoa.c b/nspr/pr/tests/dtoa.c\nindex 1063f24..eb76cc6 100644\n--- a/nspr/pr/tests/dtoa.c\n+++ b/nspr/pr/tests/dtoa.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -23,189 +24,187 @@\n \n static int failed_already = 0;\n \n-int\n-main(int argc, char** argv)\n-{\n-    double num;\n-    double num1;\n-    double zero = 0.0;\n-    char cnvt[50];\n-    char* thousands;\n-\n-    num = 1e24;\n-    num1 = PR_strtod(\"1e24\", NULL);\n-    if (num1 != num) {\n-        fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"1e24\");\n-        failed_already = 1;\n-    }\n-\n-    PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n-    if (strcmp(\"1e+24\", cnvt) != 0) {\n-        fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n-        failed_already = 1;\n-    }\n-\n-    num = 0.001e7;\n-    num1 = PR_strtod(\"0.001e7\", NULL);\n-    if (num1 != num) {\n-        fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"0.001e7\");\n-        failed_already = 1;\n-    }\n-    PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n-    if (strcmp(\"10000\", cnvt) != 0) {\n-        fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n-        failed_already = 1;\n-    }\n-\n-    num = 0.0000000000000753;\n-    num1 = PR_strtod(\"0.0000000000000753\", NULL);\n-    if (num1 != num) {\n-        fprintf(stderr, \"Failed to convert numeric value %s\\n\",\n-                \"0.0000000000000753\");\n-        failed_already = 1;\n-    }\n-    PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n-    if (strcmp(\"7.53e-14\", cnvt) != 0) {\n-        fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n-        failed_already = 1;\n-    }\n-\n-    num = 1.867e73;\n-    num1 = PR_strtod(\"1.867e73\", NULL);\n-    if (num1 != num) {\n-        fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"1.867e73\");\n-        failed_already = 1;\n-    }\n-    PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n-    if (strcmp(\"1.867e+73\", cnvt) != 0) {\n-        fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n-        failed_already = 1;\n-    }\n-\n-    num = -1.867e73;\n-    num1 = PR_strtod(\"-1.867e73\", NULL);\n-    if (num1 != num) {\n-        fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"-1.867e73\");\n-        failed_already = 1;\n-    }\n-    PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n-    if (strcmp(\"-1.867e+73\", cnvt) != 0) {\n-        fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n-        failed_already = 1;\n-    }\n-\n-    num = -1.867e-73;\n-    num1 = PR_strtod(\"-1.867e-73\", NULL);\n-    if (num1 != num) {\n-        fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"-1.867e-73\");\n-        failed_already = 1;\n-    }\n-\n-    PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n-    if (strcmp(\"-1.867e-73\", cnvt) != 0) {\n-        fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n-        failed_already = 1;\n-    }\n-\n-    /* Testing for infinity */\n-    num = 1.0 / zero;\n-    num1 = PR_strtod(\"1.867e765\", NULL);\n-    if (num1 != num) {\n-        fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"1.867e765\");\n-        failed_already = 1;\n-    }\n-\n-    PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n-    if (strcmp(\"Infinity\", cnvt) != 0) {\n-        fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n-        failed_already = 1;\n-    }\n-\n-    num = -1.0 / zero;\n-    num1 = PR_strtod(\"-1.867e765\", NULL);\n-    if (num1 != num) {\n-        fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"-1.867e765\");\n-        failed_already = 1;\n-    }\n-\n-    PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n-    if (strcmp(\"-Infinity\", cnvt) != 0) {\n-        fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n-        failed_already = 1;\n-    }\n-\n-    /* Testing for NaN. PR_strtod can't parse \"NaN\" and \"Infinity\" */\n-    num = zero / zero;\n-\n-    PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n-    if (strcmp(\"NaN\", cnvt) != 0) {\n-        fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n-        failed_already = 1;\n-    }\n-\n-    num = -zero / zero;\n-    PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n-    if (strcmp(\"NaN\", cnvt) != 0) {\n-        fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n-        failed_already = 1;\n-    }\n-\n-    num = 1.0000000001e21;\n-    num1 = PR_strtod(\"1.0000000001e21\", NULL);\n-    if (num1 != num) {\n-        fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"1.0000000001e21\");\n-        failed_already = 1;\n-    }\n-\n-    PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n-    if (strcmp(\"1.0000000001e+21\", cnvt) != 0) {\n-        fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n-        failed_already = 1;\n-    }\n-\n-    num = -1.0000000001e-21;\n-    num1 = PR_strtod(\"-1.0000000001e-21\", NULL);\n-    if (num1 != num) {\n-        fprintf(stderr, \"Failed to convert numeric value %s\\n\",\n-                \"-1.0000000001e-21\");\n-        failed_already = 1;\n-    }\n-    PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n-    if (strcmp(\"-1.0000000001e-21\", cnvt) != 0) {\n-        fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n-        failed_already = 1;\n-    }\n-\n-    /*\n-     * Bug 414772: should not exit with \"Zero passed to d2b\" in debug\n-     * build.\n-     */\n-    num1 = PR_strtod(\"4e-356\", NULL);\n-\n-    /*\n-     * A very long input with ~384K digits.\n-     * Bug 516396: Should not crash.\n-     * Bug 521306: Should return 0 without converting the input.\n-     */\n+int main(int argc, char** argv) {\n+  double num;\n+  double num1;\n+  double zero = 0.0;\n+  char cnvt[50];\n+  char* thousands;\n+\n+  num = 1e24;\n+  num1 = PR_strtod(\"1e24\", NULL);\n+  if (num1 != num) {\n+    fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"1e24\");\n+    failed_already = 1;\n+  }\n+\n+  PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n+  if (strcmp(\"1e+24\", cnvt) != 0) {\n+    fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n+    failed_already = 1;\n+  }\n+\n+  num = 0.001e7;\n+  num1 = PR_strtod(\"0.001e7\", NULL);\n+  if (num1 != num) {\n+    fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"0.001e7\");\n+    failed_already = 1;\n+  }\n+  PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n+  if (strcmp(\"10000\", cnvt) != 0) {\n+    fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n+    failed_already = 1;\n+  }\n+\n+  num = 0.0000000000000753;\n+  num1 = PR_strtod(\"0.0000000000000753\", NULL);\n+  if (num1 != num) {\n+    fprintf(stderr, \"Failed to convert numeric value %s\\n\",\n+            \"0.0000000000000753\");\n+    failed_already = 1;\n+  }\n+  PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n+  if (strcmp(\"7.53e-14\", cnvt) != 0) {\n+    fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n+    failed_already = 1;\n+  }\n+\n+  num = 1.867e73;\n+  num1 = PR_strtod(\"1.867e73\", NULL);\n+  if (num1 != num) {\n+    fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"1.867e73\");\n+    failed_already = 1;\n+  }\n+  PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n+  if (strcmp(\"1.867e+73\", cnvt) != 0) {\n+    fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n+    failed_already = 1;\n+  }\n+\n+  num = -1.867e73;\n+  num1 = PR_strtod(\"-1.867e73\", NULL);\n+  if (num1 != num) {\n+    fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"-1.867e73\");\n+    failed_already = 1;\n+  }\n+  PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n+  if (strcmp(\"-1.867e+73\", cnvt) != 0) {\n+    fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n+    failed_already = 1;\n+  }\n+\n+  num = -1.867e-73;\n+  num1 = PR_strtod(\"-1.867e-73\", NULL);\n+  if (num1 != num) {\n+    fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"-1.867e-73\");\n+    failed_already = 1;\n+  }\n+\n+  PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n+  if (strcmp(\"-1.867e-73\", cnvt) != 0) {\n+    fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n+    failed_already = 1;\n+  }\n+\n+  /* Testing for infinity */\n+  num = 1.0 / zero;\n+  num1 = PR_strtod(\"1.867e765\", NULL);\n+  if (num1 != num) {\n+    fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"1.867e765\");\n+    failed_already = 1;\n+  }\n+\n+  PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n+  if (strcmp(\"Infinity\", cnvt) != 0) {\n+    fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n+    failed_already = 1;\n+  }\n+\n+  num = -1.0 / zero;\n+  num1 = PR_strtod(\"-1.867e765\", NULL);\n+  if (num1 != num) {\n+    fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"-1.867e765\");\n+    failed_already = 1;\n+  }\n+\n+  PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n+  if (strcmp(\"-Infinity\", cnvt) != 0) {\n+    fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n+    failed_already = 1;\n+  }\n+\n+  /* Testing for NaN. PR_strtod can't parse \"NaN\" and \"Infinity\" */\n+  num = zero / zero;\n+\n+  PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n+  if (strcmp(\"NaN\", cnvt) != 0) {\n+    fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n+    failed_already = 1;\n+  }\n+\n+  num = -zero / zero;\n+  PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n+  if (strcmp(\"NaN\", cnvt) != 0) {\n+    fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n+    failed_already = 1;\n+  }\n+\n+  num = 1.0000000001e21;\n+  num1 = PR_strtod(\"1.0000000001e21\", NULL);\n+  if (num1 != num) {\n+    fprintf(stderr, \"Failed to convert numeric value %s\\n\", \"1.0000000001e21\");\n+    failed_already = 1;\n+  }\n+\n+  PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n+  if (strcmp(\"1.0000000001e+21\", cnvt) != 0) {\n+    fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n+    failed_already = 1;\n+  }\n+\n+  num = -1.0000000001e-21;\n+  num1 = PR_strtod(\"-1.0000000001e-21\", NULL);\n+  if (num1 != num) {\n+    fprintf(stderr, \"Failed to convert numeric value %s\\n\",\n+            \"-1.0000000001e-21\");\n+    failed_already = 1;\n+  }\n+  PR_cnvtf(cnvt, sizeof(cnvt), 20, num);\n+  if (strcmp(\"-1.0000000001e-21\", cnvt) != 0) {\n+    fprintf(stderr, \"Failed to convert numeric value %lf %s\\n\", num, cnvt);\n+    failed_already = 1;\n+  }\n+\n+  /*\n+   * Bug 414772: should not exit with \"Zero passed to d2b\" in debug\n+   * build.\n+   */\n+  num1 = PR_strtod(\"4e-356\", NULL);\n+\n+  /*\n+   * A very long input with ~384K digits.\n+   * Bug 516396: Should not crash.\n+   * Bug 521306: Should return 0 without converting the input.\n+   */\n #define LENGTH (384 * 1024)\n-    thousands = (char*)malloc(LENGTH);\n-    thousands[0] = '0';\n-    thousands[1] = '.';\n-    memset(&thousands[2], '1', LENGTH - 3);\n-    thousands[LENGTH - 1] = '\\0';\n-    num = 0;\n-    num1 = PR_strtod(thousands, NULL);\n-    free(thousands);\n-    if (num1 != num) {\n-        fprintf(stderr, \"Failed to convert numeric value %s\\n\",\n-                \"0.1111111111111111...\");\n-        failed_already = 1;\n-    }\n-\n-    if (failed_already) {\n-        printf(\"FAILED\\n\");\n-    } else {\n-        printf(\"PASSED\\n\");\n-    }\n-    return failed_already;\n+  thousands = (char*)malloc(LENGTH);\n+  thousands[0] = '0';\n+  thousands[1] = '.';\n+  memset(&thousands[2], '1', LENGTH - 3);\n+  thousands[LENGTH - 1] = '\\0';\n+  num = 0;\n+  num1 = PR_strtod(thousands, NULL);\n+  free(thousands);\n+  if (num1 != num) {\n+    fprintf(stderr, \"Failed to convert numeric value %s\\n\",\n+            \"0.1111111111111111...\");\n+    failed_already = 1;\n+  }\n+\n+  if (failed_already) {\n+    printf(\"FAILED\\n\");\n+  } else {\n+    printf(\"PASSED\\n\");\n+  }\n+  return failed_already;\n }\ndiff --git a/nspr/pr/tests/env.c b/nspr/pr/tests/env.c\nindex a7eb7ef..1afe0c0 100644\n--- a/nspr/pr/tests/env.c\n+++ b/nspr/pr/tests/env.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -26,53 +27,49 @@ PRBool failedAlready = PR_FALSE;\n \n char* envBuf; /* buffer pointer. We leak memory here on purpose! */\n \n-static char*\n-NewBuffer(size_t size)\n-{\n-    char* buf = malloc(size);\n-    if (NULL == buf) {\n-        printf(\"env: NewBuffer() failed\\n\");\n-        exit(1);\n-    }\n-    return (buf);\n+static char* NewBuffer(size_t size) {\n+  char* buf = malloc(size);\n+  if (NULL == buf) {\n+    printf(\"env: NewBuffer() failed\\n\");\n+    exit(1);\n+  }\n+  return (buf);\n } /* end NewBuffer() */\n \n-int\n-main(int argc, char** argv)\n-{\n-    char* value;\n-    PRStatus rc;\n+int main(int argc, char** argv) {\n+  char* value;\n+  PRStatus rc;\n \n-    { /* Get command line options */\n-        PLOptStatus os;\n-        PLOptState* opt = PL_CreateOptState(argc, argv, \"vds\");\n+  { /* Get command line options */\n+    PLOptStatus os;\n+    PLOptState* opt = PL_CreateOptState(argc, argv, \"vds\");\n \n-        while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-            if (PL_OPT_BAD == os) {\n-                continue;\n-            }\n-            switch (opt->option) {\n-                case 'd': /* debug */\n-                    debug = 1;\n-                    break;\n-                case 'v': /* verbose */\n-                    verbose = 1;\n-                    break;\n-                case 's': /* secure / set[ug]id */\n-                    /*\n-                    ** To test PR_GetEnvSecure, make this executable (or a\n-                    ** copy of it) setuid / setgid / otherwise inherently\n-                    ** privileged (e.g., file capabilities) and run it\n-                    ** with this flag.\n-                    */\n-                    secure = 1;\n-                    break;\n-                default:\n-                    break;\n-            }\n-        }\n-        PL_DestroyOptState(opt);\n-    } /* end block \"Get command line options\" */\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+      if (PL_OPT_BAD == os) {\n+        continue;\n+      }\n+      switch (opt->option) {\n+        case 'd': /* debug */\n+          debug = 1;\n+          break;\n+        case 'v': /* verbose */\n+          verbose = 1;\n+          break;\n+        case 's': /* secure / set[ug]id */\n+          /*\n+          ** To test PR_GetEnvSecure, make this executable (or a\n+          ** copy of it) setuid / setgid / otherwise inherently\n+          ** privileged (e.g., file capabilities) and run it\n+          ** with this flag.\n+          */\n+          secure = 1;\n+          break;\n+        default:\n+          break;\n+      }\n+    }\n+    PL_DestroyOptState(opt);\n+  } /* end block \"Get command line options\" */\n \n #if 0\n     {\n@@ -117,275 +114,275 @@ main(int argc, char** argv)\n     }\n #endif\n \n-    /* set an environment variable, read it back */\n-    envBuf = NewBuffer(ENVBUFSIZE);\n-    sprintf(envBuf, ENVNAME \"=\" ENVVALUE);\n-    rc = PR_SetEnv(envBuf);\n-    if (PR_FAILURE == rc) {\n-        if (debug) {\n-            printf(\"env: PR_SetEnv() failed setting\\n\");\n-        }\n-        failedAlready = PR_TRUE;\n-    } else {\n-        if (verbose) {\n-            printf(\"env: PR_SetEnv() worked.\\n\");\n-        }\n+  /* set an environment variable, read it back */\n+  envBuf = NewBuffer(ENVBUFSIZE);\n+  sprintf(envBuf, ENVNAME \"=\" ENVVALUE);\n+  rc = PR_SetEnv(envBuf);\n+  if (PR_FAILURE == rc) {\n+    if (debug) {\n+      printf(\"env: PR_SetEnv() failed setting\\n\");\n     }\n+    failedAlready = PR_TRUE;\n+  } else {\n+    if (verbose) {\n+      printf(\"env: PR_SetEnv() worked.\\n\");\n+    }\n+  }\n \n-    value = PR_GetEnv(ENVNAME);\n-    if ((NULL == value) || (strcmp(value, ENVVALUE))) {\n-        if (debug) {\n-            printf(\"env: PR_GetEnv() Failed after setting\\n\");\n-        }\n-        failedAlready = PR_TRUE;\n-    } else {\n-        if (verbose) {\n-            printf(\"env: PR_GetEnv() worked after setting it. Found: %s\\n\", value);\n-        }\n+  value = PR_GetEnv(ENVNAME);\n+  if ((NULL == value) || (strcmp(value, ENVVALUE))) {\n+    if (debug) {\n+      printf(\"env: PR_GetEnv() Failed after setting\\n\");\n+    }\n+    failedAlready = PR_TRUE;\n+  } else {\n+    if (verbose) {\n+      printf(\"env: PR_GetEnv() worked after setting it. Found: %s\\n\", value);\n     }\n+  }\n \n-    if (secure) {\n-        /*\n-        ** In this case we've been run with elevated privileges, so\n-        ** test that PR_GetEnvSecure *doesn't* find that env var.\n-        */\n-        value = PR_GetEnvSecure(ENVNAME);\n-        if (NULL != value) {\n-            if (debug) {\n-                printf(\"env: PR_GetEnvSecure() failed; expected NULL, found \\\"%s\\\"\\n\",\n-                       value);\n-            }\n-            failedAlready = PR_TRUE;\n-        } else {\n-            if (verbose) {\n-                printf(\"env: PR_GetEnvSecure() worked\\n\");\n-            }\n-        }\n+  if (secure) {\n+    /*\n+    ** In this case we've been run with elevated privileges, so\n+    ** test that PR_GetEnvSecure *doesn't* find that env var.\n+    */\n+    value = PR_GetEnvSecure(ENVNAME);\n+    if (NULL != value) {\n+      if (debug) {\n+        printf(\"env: PR_GetEnvSecure() failed; expected NULL, found \\\"%s\\\"\\n\",\n+               value);\n+      }\n+      failedAlready = PR_TRUE;\n     } else {\n-        /*\n-        ** In this case the program is being run normally, so do the\n-        ** same check for PR_GetEnvSecure as for PR_GetEnv.\n-        */\n-        value = PR_GetEnvSecure(ENVNAME);\n-        if ((NULL == value) || (strcmp(value, ENVVALUE))) {\n-            if (debug) {\n-                printf(\"env: PR_GetEnvSecure() Failed after setting\\n\");\n-            }\n-            failedAlready = PR_TRUE;\n-        } else {\n-            if (verbose) {\n-                printf(\"env: PR_GetEnvSecure() worked after setting it. Found: %s\\n\",\n-                       value);\n-            }\n-        }\n+      if (verbose) {\n+        printf(\"env: PR_GetEnvSecure() worked\\n\");\n+      }\n+    }\n+  } else {\n+    /*\n+    ** In this case the program is being run normally, so do the\n+    ** same check for PR_GetEnvSecure as for PR_GetEnv.\n+    */\n+    value = PR_GetEnvSecure(ENVNAME);\n+    if ((NULL == value) || (strcmp(value, ENVVALUE))) {\n+      if (debug) {\n+        printf(\"env: PR_GetEnvSecure() Failed after setting\\n\");\n+      }\n+      failedAlready = PR_TRUE;\n+    } else {\n+      if (verbose) {\n+        printf(\"env: PR_GetEnvSecure() worked after setting it. Found: %s\\n\",\n+               value);\n+      }\n     }\n+  }\n \n-    /* ---------------------------------------------------------------------- */\n-    /* check that PR_DuplicateEnvironment() agrees with PR_GetEnv() */\n-    {\n+  /* ---------------------------------------------------------------------- */\n+  /* check that PR_DuplicateEnvironment() agrees with PR_GetEnv() */\n+  {\n #if defined(XP_UNIX) && (!defined(DARWIN) || defined(HAVE_CRT_EXTERNS_H))\n-        static const PRBool expect_failure = PR_FALSE;\n+    static const PRBool expect_failure = PR_FALSE;\n #else\n-        static const PRBool expect_failure = PR_TRUE;\n+    static const PRBool expect_failure = PR_TRUE;\n #endif\n-        char **i, **dupenv = PR_DuplicateEnvironment();\n-\n-        if (NULL == dupenv) {\n-            if (expect_failure) {\n-                if (verbose)\n-                    printf(\n-                        \"env: PR_DuplicateEnvironment failed, \"\n-                        \"as expected on this platform.\\n\");\n-            } else {\n-                if (debug) {\n-                    printf(\"env: PR_DuplicateEnvironment() failed.\\n\");\n-                }\n-                failedAlready = PR_TRUE;\n-            }\n-        } else {\n-            unsigned found = 0;\n-\n-            if (expect_failure) {\n-                if (debug)\n-                    printf(\n-                        \"env: PR_DuplicateEnvironment() succeeded, \"\n-                        \"but failure is expected on this platform.\\n\");\n-                failedAlready = PR_TRUE;\n-            } else {\n-                if (verbose) {\n-                    printf(\"env: PR_DuplicateEnvironment() succeeded.\\n\");\n-                }\n-            }\n-            for (i = dupenv; *i; i++) {\n-                char* equals = strchr(*i, '=');\n-\n-                if (equals == NULL) {\n-                    if (debug)\n-                        printf(\n-                            \"env: PR_DuplicateEnvironment() returned a string\"\n-                            \" with no '=': %s\\n\",\n-                            *i);\n-                    failedAlready = PR_TRUE;\n-                } else {\n-                    /* We own this string, so we can temporarily alter it */\n-                    /* *i is the null-terminated name; equals + 1 is the value */\n-                    *equals = '\\0';\n-\n-                    if (strcmp(*i, ENVNAME) == 0) {\n-                        found++;\n-                        if (verbose)\n-                            printf(\"env: PR_DuplicateEnvironment() found \" ENVNAME\n-                                   \" (%u so far).\\n\",\n-                                   found);\n-                    }\n-\n-                    /* Multiple values for the same name can't happen, according to POSIX.\n-                     */\n-                    value = PR_GetEnv(*i);\n-                    if (value == NULL) {\n-                        if (debug)\n-                            printf(\n-                                \"env: PR_DuplicateEnvironment() returned a name\"\n-                                \" which PR_GetEnv() failed to find: %s\\n\",\n-                                *i);\n-                        failedAlready = PR_TRUE;\n-                    } else if (strcmp(equals + 1, value) != 0) {\n-                        if (debug)\n-                            printf(\n-                                \"env: PR_DuplicateEnvironment() returned the wrong\"\n-                                \" value for %s: expected %s; found %s\\n\",\n-                                *i, value, equals + 1);\n-                        failedAlready = PR_TRUE;\n-                    } else {\n-                        if (verbose)\n-                            printf(\n-                                \"env: PR_DuplicateEnvironment() agreed with\"\n-                                \" PR_GetEnv() about %s\\n\",\n-                                *i);\n-                    }\n-                }\n-                PR_Free(*i);\n-            }\n-            PR_Free(dupenv);\n-\n-            if (found != 1) {\n-                if (debug)\n-                    printf(\"env: PR_DuplicateEnvironment() found %u entries for \" ENVNAME\n-                           \" (expected 1)\\n\",\n-                           found);\n-                failedAlready = PR_TRUE;\n-            } else {\n-                if (verbose) {\n-                    printf(\"env: PR_DuplicateEnvironment() found 1 entry for \" ENVNAME\n-                           \"\\n\");\n-                }\n-            }\n-        }\n-    }\n+    char **i, **dupenv = PR_DuplicateEnvironment();\n \n-    /* ---------------------------------------------------------------------- */\n-    /* un-set the variable, using RAW name... should not work */\n-    envBuf = NewBuffer(ENVBUFSIZE);\n-    sprintf(envBuf, ENVNAME);\n-    rc = PR_SetEnv(envBuf);\n-    if (PR_FAILURE == rc) {\n-        if (verbose) {\n-            printf(\"env: PR_SetEnv() not un-set using RAW name. Good!\\n\");\n-        }\n-    } else {\n+    if (NULL == dupenv) {\n+      if (expect_failure) {\n+        if (verbose)\n+          printf(\n+              \"env: PR_DuplicateEnvironment failed, \"\n+              \"as expected on this platform.\\n\");\n+      } else {\n         if (debug) {\n-            printf(\"env: PR_SetEnv() un-set using RAW name. Bad!\\n\");\n+          printf(\"env: PR_DuplicateEnvironment() failed.\\n\");\n         }\n         failedAlready = PR_TRUE;\n-    }\n+      }\n+    } else {\n+      unsigned found = 0;\n \n-    value = PR_GetEnv(ENVNAME);\n-    if (NULL == value) {\n-        if (debug) {\n-            printf(\"env: PR_GetEnv() after un-set using RAW name. Bad!\\n\");\n-        }\n+      if (expect_failure) {\n+        if (debug)\n+          printf(\n+              \"env: PR_DuplicateEnvironment() succeeded, \"\n+              \"but failure is expected on this platform.\\n\");\n         failedAlready = PR_TRUE;\n-    } else {\n+      } else {\n         if (verbose) {\n-            printf(\"env: PR_GetEnv() after RAW un-set found: %s\\n\", value);\n+          printf(\"env: PR_DuplicateEnvironment() succeeded.\\n\");\n         }\n-    }\n+      }\n+      for (i = dupenv; *i; i++) {\n+        char* equals = strchr(*i, '=');\n \n-    /* ---------------------------------------------------------------------- */\n-    /* set it again ... */\n-    envBuf = NewBuffer(ENVBUFSIZE);\n-    sprintf(envBuf, ENVNAME \"=\" ENVVALUE);\n-    rc = PR_SetEnv(envBuf);\n-    if (PR_FAILURE == rc) {\n-        if (debug) {\n-            printf(\"env: PR_SetEnv() failed setting the second time.\\n\");\n+        if (equals == NULL) {\n+          if (debug)\n+            printf(\n+                \"env: PR_DuplicateEnvironment() returned a string\"\n+                \" with no '=': %s\\n\",\n+                *i);\n+          failedAlready = PR_TRUE;\n+        } else {\n+          /* We own this string, so we can temporarily alter it */\n+          /* *i is the null-terminated name; equals + 1 is the value */\n+          *equals = '\\0';\n+\n+          if (strcmp(*i, ENVNAME) == 0) {\n+            found++;\n+            if (verbose)\n+              printf(\"env: PR_DuplicateEnvironment() found \" ENVNAME\n+                     \" (%u so far).\\n\",\n+                     found);\n+          }\n+\n+          /* Multiple values for the same name can't happen, according to POSIX.\n+           */\n+          value = PR_GetEnv(*i);\n+          if (value == NULL) {\n+            if (debug)\n+              printf(\n+                  \"env: PR_DuplicateEnvironment() returned a name\"\n+                  \" which PR_GetEnv() failed to find: %s\\n\",\n+                  *i);\n+            failedAlready = PR_TRUE;\n+          } else if (strcmp(equals + 1, value) != 0) {\n+            if (debug)\n+              printf(\n+                  \"env: PR_DuplicateEnvironment() returned the wrong\"\n+                  \" value for %s: expected %s; found %s\\n\",\n+                  *i, value, equals + 1);\n+            failedAlready = PR_TRUE;\n+          } else {\n+            if (verbose)\n+              printf(\n+                  \"env: PR_DuplicateEnvironment() agreed with\"\n+                  \" PR_GetEnv() about %s\\n\",\n+                  *i);\n+          }\n         }\n+        PR_Free(*i);\n+      }\n+      PR_Free(dupenv);\n+\n+      if (found != 1) {\n+        if (debug)\n+          printf(\"env: PR_DuplicateEnvironment() found %u entries for \" ENVNAME\n+                 \" (expected 1)\\n\",\n+                 found);\n         failedAlready = PR_TRUE;\n-    } else {\n+      } else {\n         if (verbose) {\n-            printf(\"env: PR_SetEnv() worked.\\n\");\n+          printf(\"env: PR_DuplicateEnvironment() found 1 entry for \" ENVNAME\n+                 \"\\n\");\n         }\n+      }\n     }\n+  }\n \n-    /* un-set the variable using the form name= */\n-    envBuf = NewBuffer(ENVBUFSIZE);\n-    sprintf(envBuf, ENVNAME \"=\");\n-    rc = PR_SetEnv(envBuf);\n-    if (PR_FAILURE == rc) {\n-        if (debug) {\n-            printf(\"env: PR_SetEnv() failed un-setting using name=\\n\");\n-        }\n-        failedAlready = PR_TRUE;\n-    } else {\n-        if (verbose) {\n-            printf(\"env: PR_SetEnv() un-set using name= worked\\n\");\n-        }\n+  /* ---------------------------------------------------------------------- */\n+  /* un-set the variable, using RAW name... should not work */\n+  envBuf = NewBuffer(ENVBUFSIZE);\n+  sprintf(envBuf, ENVNAME);\n+  rc = PR_SetEnv(envBuf);\n+  if (PR_FAILURE == rc) {\n+    if (verbose) {\n+      printf(\"env: PR_SetEnv() not un-set using RAW name. Good!\\n\");\n+    }\n+  } else {\n+    if (debug) {\n+      printf(\"env: PR_SetEnv() un-set using RAW name. Bad!\\n\");\n     }\n+    failedAlready = PR_TRUE;\n+  }\n \n-    value = PR_GetEnv(ENVNAME);\n-    if ((NULL == value) || (0x00 == *value)) {\n-        if (verbose) {\n-            printf(\"env: PR_GetEnv() after un-set using name= worked\\n\");\n-        }\n-    } else {\n-        if (debug) {\n-            printf(\"env: PR_GetEnv() after un-set using name=. Found: %s\\n\", value);\n-        }\n-        failedAlready = PR_TRUE;\n+  value = PR_GetEnv(ENVNAME);\n+  if (NULL == value) {\n+    if (debug) {\n+      printf(\"env: PR_GetEnv() after un-set using RAW name. Bad!\\n\");\n     }\n-    /* ---------------------------------------------------------------------- */\n-    /* un-set the variable using the form name= */\n-    envBuf = NewBuffer(ENVBUFSIZE);\n-    sprintf(envBuf, ENVNAME \"999=\");\n-    rc = PR_SetEnv(envBuf);\n-    if (PR_FAILURE == rc) {\n-        if (debug) {\n-            printf(\"env: PR_SetEnv() failed un-setting using name=\\n\");\n-        }\n-        failedAlready = PR_TRUE;\n-    } else {\n-        if (verbose) {\n-            printf(\"env: PR_SetEnv() un-set using name= worked\\n\");\n-        }\n+    failedAlready = PR_TRUE;\n+  } else {\n+    if (verbose) {\n+      printf(\"env: PR_GetEnv() after RAW un-set found: %s\\n\", value);\n     }\n+  }\n \n-    value = PR_GetEnv(ENVNAME \"999\");\n-    if ((NULL == value) || (0x00 == *value)) {\n-        if (verbose) {\n-            printf(\"env: PR_GetEnv() after un-set using name= worked\\n\");\n-        }\n-    } else {\n-        if (debug) {\n-            printf(\"env: PR_GetEnv() after un-set using name=. Found: %s\\n\", value);\n-        }\n-        failedAlready = PR_TRUE;\n+  /* ---------------------------------------------------------------------- */\n+  /* set it again ... */\n+  envBuf = NewBuffer(ENVBUFSIZE);\n+  sprintf(envBuf, ENVNAME \"=\" ENVVALUE);\n+  rc = PR_SetEnv(envBuf);\n+  if (PR_FAILURE == rc) {\n+    if (debug) {\n+      printf(\"env: PR_SetEnv() failed setting the second time.\\n\");\n     }\n+    failedAlready = PR_TRUE;\n+  } else {\n+    if (verbose) {\n+      printf(\"env: PR_SetEnv() worked.\\n\");\n+    }\n+  }\n \n-    /* ---------------------------------------------------------------------- */\n-    if (debug || verbose) {\n-        printf(\"\\n%s\\n\", (failedAlready) ? \"FAILED\" : \"PASSED\");\n+  /* un-set the variable using the form name= */\n+  envBuf = NewBuffer(ENVBUFSIZE);\n+  sprintf(envBuf, ENVNAME \"=\");\n+  rc = PR_SetEnv(envBuf);\n+  if (PR_FAILURE == rc) {\n+    if (debug) {\n+      printf(\"env: PR_SetEnv() failed un-setting using name=\\n\");\n+    }\n+    failedAlready = PR_TRUE;\n+  } else {\n+    if (verbose) {\n+      printf(\"env: PR_SetEnv() un-set using name= worked\\n\");\n+    }\n+  }\n+\n+  value = PR_GetEnv(ENVNAME);\n+  if ((NULL == value) || (0x00 == *value)) {\n+    if (verbose) {\n+      printf(\"env: PR_GetEnv() after un-set using name= worked\\n\");\n+    }\n+  } else {\n+    if (debug) {\n+      printf(\"env: PR_GetEnv() after un-set using name=. Found: %s\\n\", value);\n     }\n-    return ((failedAlready) ? 1 : 0);\n+    failedAlready = PR_TRUE;\n+  }\n+  /* ---------------------------------------------------------------------- */\n+  /* un-set the variable using the form name= */\n+  envBuf = NewBuffer(ENVBUFSIZE);\n+  sprintf(envBuf, ENVNAME \"999=\");\n+  rc = PR_SetEnv(envBuf);\n+  if (PR_FAILURE == rc) {\n+    if (debug) {\n+      printf(\"env: PR_SetEnv() failed un-setting using name=\\n\");\n+    }\n+    failedAlready = PR_TRUE;\n+  } else {\n+    if (verbose) {\n+      printf(\"env: PR_SetEnv() un-set using name= worked\\n\");\n+    }\n+  }\n+\n+  value = PR_GetEnv(ENVNAME \"999\");\n+  if ((NULL == value) || (0x00 == *value)) {\n+    if (verbose) {\n+      printf(\"env: PR_GetEnv() after un-set using name= worked\\n\");\n+    }\n+  } else {\n+    if (debug) {\n+      printf(\"env: PR_GetEnv() after un-set using name=. Found: %s\\n\", value);\n+    }\n+    failedAlready = PR_TRUE;\n+  }\n+\n+  /* ---------------------------------------------------------------------- */\n+  if (debug || verbose) {\n+    printf(\"\\n%s\\n\", (failedAlready) ? \"FAILED\" : \"PASSED\");\n+  }\n+  return ((failedAlready) ? 1 : 0);\n } /* main() */\n \n /* env.c */\ndiff --git a/nspr/pr/tests/errcodes.c b/nspr/pr/tests/errcodes.c\nindex fa12066..b5bce93 100644\n--- a/nspr/pr/tests/errcodes.c\n+++ b/nspr/pr/tests/errcodes.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -17,116 +18,113 @@\n static int _debug_on = 0;\n \n struct errinfo {\n-    PRErrorCode errcode;\n-    char* errname;\n+  PRErrorCode errcode;\n+  char* errname;\n };\n \n struct errinfo errcodes[] = {\n-    { PR_OUT_OF_MEMORY_ERROR, \"PR_OUT_OF_MEMORY_ERROR\" },\n-    { PR_BAD_DESCRIPTOR_ERROR, \"PR_BAD_DESCRIPTOR_ERROR\" },\n-    { PR_WOULD_BLOCK_ERROR, \"PR_WOULD_BLOCK_ERROR\" },\n-    { PR_ACCESS_FAULT_ERROR, \"PR_ACCESS_FAULT_ERROR\" },\n-    { PR_INVALID_METHOD_ERROR, \"PR_INVALID_METHOD_ERROR\" },\n-    { PR_ILLEGAL_ACCESS_ERROR, \"PR_ILLEGAL_ACCESS_ERROR\" },\n-    { PR_UNKNOWN_ERROR, \"PR_UNKNOWN_ERROR\" },\n-    { PR_PENDING_INTERRUPT_ERROR, \"PR_PENDING_INTERRUPT_ERROR\" },\n-    { PR_NOT_IMPLEMENTED_ERROR, \"PR_NOT_IMPLEMENTED_ERROR\" },\n-    { PR_IO_ERROR, \"PR_IO_ERROR\" },\n-    { PR_IO_TIMEOUT_ERROR, \"PR_IO_TIMEOUT_ERROR\" },\n-    { PR_IO_PENDING_ERROR, \"PR_IO_PENDING_ERROR\" },\n-    { PR_DIRECTORY_OPEN_ERROR, \"PR_DIRECTORY_OPEN_ERROR\" },\n-    { PR_INVALID_ARGUMENT_ERROR, \"PR_INVALID_ARGUMENT_ERROR\" },\n-    { PR_ADDRESS_NOT_AVAILABLE_ERROR, \"PR_ADDRESS_NOT_AVAILABLE_ERROR\" },\n-    { PR_ADDRESS_NOT_SUPPORTED_ERROR, \"PR_ADDRESS_NOT_SUPPORTED_ERROR\" },\n-    { PR_IS_CONNECTED_ERROR, \"PR_IS_CONNECTED_ERROR\" },\n-    { PR_BAD_ADDRESS_ERROR, \"PR_BAD_ADDRESS_ERROR\" },\n-    { PR_ADDRESS_IN_USE_ERROR, \"PR_ADDRESS_IN_USE_ERROR\" },\n-    { PR_CONNECT_REFUSED_ERROR, \"PR_CONNECT_REFUSED_ERROR\" },\n-    { PR_NETWORK_UNREACHABLE_ERROR, \"PR_NETWORK_UNREACHABLE_ERROR\" },\n-    { PR_CONNECT_TIMEOUT_ERROR, \"PR_CONNECT_TIMEOUT_ERROR\" },\n-    { PR_NOT_CONNECTED_ERROR, \"PR_NOT_CONNECTED_ERROR\" },\n-    { PR_LOAD_LIBRARY_ERROR, \"PR_LOAD_LIBRARY_ERROR\" },\n-    { PR_UNLOAD_LIBRARY_ERROR, \"PR_UNLOAD_LIBRARY_ERROR\" },\n-    { PR_FIND_SYMBOL_ERROR, \"PR_FIND_SYMBOL_ERROR\" },\n-    { PR_INSUFFICIENT_RESOURCES_ERROR, \"PR_INSUFFICIENT_RESOURCES_ERROR\" },\n-    { PR_DIRECTORY_LOOKUP_ERROR, \"PR_DIRECTORY_LOOKUP_ERROR\" },\n-    { PR_TPD_RANGE_ERROR, \"PR_TPD_RANGE_ERROR\" },\n-    { PR_PROC_DESC_TABLE_FULL_ERROR, \"PR_PROC_DESC_TABLE_FULL_ERROR\" },\n-    { PR_SYS_DESC_TABLE_FULL_ERROR, \"PR_SYS_DESC_TABLE_FULL_ERROR\" },\n-    { PR_NOT_SOCKET_ERROR, \"PR_NOT_SOCKET_ERROR\" },\n-    { PR_NOT_TCP_SOCKET_ERROR, \"PR_NOT_TCP_SOCKET_ERROR\" },\n-    { PR_SOCKET_ADDRESS_IS_BOUND_ERROR, \"PR_SOCKET_ADDRESS_IS_BOUND_ERROR\" },\n-    { PR_NO_ACCESS_RIGHTS_ERROR, \"PR_NO_ACCESS_RIGHTS_ERROR\" },\n-    { PR_OPERATION_NOT_SUPPORTED_ERROR, \"PR_OPERATION_NOT_SUPPORTED_ERROR\" },\n-    { PR_PROTOCOL_NOT_SUPPORTED_ERROR, \"PR_PROTOCOL_NOT_SUPPORTED_ERROR\" },\n-    { PR_REMOTE_FILE_ERROR, \"PR_REMOTE_FILE_ERROR\" },\n-    { PR_BUFFER_OVERFLOW_ERROR, \"PR_BUFFER_OVERFLOW_ERROR\" },\n-    { PR_CONNECT_RESET_ERROR, \"PR_CONNECT_RESET_ERROR\" },\n-    { PR_RANGE_ERROR, \"PR_RANGE_ERROR\" },\n-    { PR_DEADLOCK_ERROR, \"PR_DEADLOCK_ERROR\" },\n-    { PR_FILE_IS_LOCKED_ERROR, \"PR_FILE_IS_LOCKED_ERROR\" },\n-    { PR_FILE_TOO_BIG_ERROR, \"PR_FILE_TOO_BIG_ERROR\" },\n-    { PR_NO_DEVICE_SPACE_ERROR, \"PR_NO_DEVICE_SPACE_ERROR\" },\n-    { PR_PIPE_ERROR, \"PR_PIPE_ERROR\" },\n-    { PR_NO_SEEK_DEVICE_ERROR, \"PR_NO_SEEK_DEVICE_ERROR\" },\n-    { PR_IS_DIRECTORY_ERROR, \"PR_IS_DIRECTORY_ERROR\" },\n-    { PR_LOOP_ERROR, \"PR_LOOP_ERROR\" },\n-    { PR_NAME_TOO_LONG_ERROR, \"PR_NAME_TOO_LONG_ERROR\" },\n-    { PR_FILE_NOT_FOUND_ERROR, \"PR_FILE_NOT_FOUND_ERROR\" },\n-    { PR_NOT_DIRECTORY_ERROR, \"PR_NOT_DIRECTORY_ERROR\" },\n-    { PR_READ_ONLY_FILESYSTEM_ERROR, \"PR_READ_ONLY_FILESYSTEM_ERROR\" },\n-    { PR_DIRECTORY_NOT_EMPTY_ERROR, \"PR_DIRECTORY_NOT_EMPTY_ERROR\" },\n-    { PR_FILESYSTEM_MOUNTED_ERROR, \"PR_FILESYSTEM_MOUNTED_ERROR\" },\n-    { PR_NOT_SAME_DEVICE_ERROR, \"PR_NOT_SAME_DEVICE_ERROR\" },\n-    { PR_DIRECTORY_CORRUPTED_ERROR, \"PR_DIRECTORY_CORRUPTED_ERROR\" },\n-    { PR_FILE_EXISTS_ERROR, \"PR_FILE_EXISTS_ERROR\" },\n-    { PR_MAX_DIRECTORY_ENTRIES_ERROR, \"PR_MAX_DIRECTORY_ENTRIES_ERROR\" },\n-    { PR_INVALID_DEVICE_STATE_ERROR, \"PR_INVALID_DEVICE_STATE_ERROR\" },\n-    { PR_DEVICE_IS_LOCKED_ERROR, \"PR_DEVICE_IS_LOCKED_ERROR\" },\n-    { PR_NO_MORE_FILES_ERROR, \"PR_NO_MORE_FILES_ERROR\" },\n-    { PR_END_OF_FILE_ERROR, \"PR_END_OF_FILE_ERROR\" },\n-    { PR_FILE_SEEK_ERROR, \"PR_FILE_SEEK_ERROR\" },\n-    { PR_FILE_IS_BUSY_ERROR, \"PR_FILE_IS_BUSY_ERROR\" },\n-    { PR_IN_PROGRESS_ERROR, \"PR_IN_PROGRESS_ERROR\" },\n-    { PR_ALREADY_INITIATED_ERROR, \"PR_ALREADY_INITIATED_ERROR\" },\n-    { PR_GROUP_EMPTY_ERROR, \"PR_GROUP_EMPTY_ERROR\" },\n-    { PR_INVALID_STATE_ERROR, \"PR_INVALID_STATE_ERROR\" },\n-    { PR_NETWORK_DOWN_ERROR, \"PR_NETWORK_DOWN_ERROR\" },\n-    { PR_SOCKET_SHUTDOWN_ERROR, \"PR_SOCKET_SHUTDOWN_ERROR\" },\n-    { PR_CONNECT_ABORTED_ERROR, \"PR_CONNECT_ABORTED_ERROR\" },\n-    { PR_HOST_UNREACHABLE_ERROR, \"PR_HOST_UNREACHABLE_ERROR\" }\n-};\n+    {PR_OUT_OF_MEMORY_ERROR, \"PR_OUT_OF_MEMORY_ERROR\"},\n+    {PR_BAD_DESCRIPTOR_ERROR, \"PR_BAD_DESCRIPTOR_ERROR\"},\n+    {PR_WOULD_BLOCK_ERROR, \"PR_WOULD_BLOCK_ERROR\"},\n+    {PR_ACCESS_FAULT_ERROR, \"PR_ACCESS_FAULT_ERROR\"},\n+    {PR_INVALID_METHOD_ERROR, \"PR_INVALID_METHOD_ERROR\"},\n+    {PR_ILLEGAL_ACCESS_ERROR, \"PR_ILLEGAL_ACCESS_ERROR\"},\n+    {PR_UNKNOWN_ERROR, \"PR_UNKNOWN_ERROR\"},\n+    {PR_PENDING_INTERRUPT_ERROR, \"PR_PENDING_INTERRUPT_ERROR\"},\n+    {PR_NOT_IMPLEMENTED_ERROR, \"PR_NOT_IMPLEMENTED_ERROR\"},\n+    {PR_IO_ERROR, \"PR_IO_ERROR\"},\n+    {PR_IO_TIMEOUT_ERROR, \"PR_IO_TIMEOUT_ERROR\"},\n+    {PR_IO_PENDING_ERROR, \"PR_IO_PENDING_ERROR\"},\n+    {PR_DIRECTORY_OPEN_ERROR, \"PR_DIRECTORY_OPEN_ERROR\"},\n+    {PR_INVALID_ARGUMENT_ERROR, \"PR_INVALID_ARGUMENT_ERROR\"},\n+    {PR_ADDRESS_NOT_AVAILABLE_ERROR, \"PR_ADDRESS_NOT_AVAILABLE_ERROR\"},\n+    {PR_ADDRESS_NOT_SUPPORTED_ERROR, \"PR_ADDRESS_NOT_SUPPORTED_ERROR\"},\n+    {PR_IS_CONNECTED_ERROR, \"PR_IS_CONNECTED_ERROR\"},\n+    {PR_BAD_ADDRESS_ERROR, \"PR_BAD_ADDRESS_ERROR\"},\n+    {PR_ADDRESS_IN_USE_ERROR, \"PR_ADDRESS_IN_USE_ERROR\"},\n+    {PR_CONNECT_REFUSED_ERROR, \"PR_CONNECT_REFUSED_ERROR\"},\n+    {PR_NETWORK_UNREACHABLE_ERROR, \"PR_NETWORK_UNREACHABLE_ERROR\"},\n+    {PR_CONNECT_TIMEOUT_ERROR, \"PR_CONNECT_TIMEOUT_ERROR\"},\n+    {PR_NOT_CONNECTED_ERROR, \"PR_NOT_CONNECTED_ERROR\"},\n+    {PR_LOAD_LIBRARY_ERROR, \"PR_LOAD_LIBRARY_ERROR\"},\n+    {PR_UNLOAD_LIBRARY_ERROR, \"PR_UNLOAD_LIBRARY_ERROR\"},\n+    {PR_FIND_SYMBOL_ERROR, \"PR_FIND_SYMBOL_ERROR\"},\n+    {PR_INSUFFICIENT_RESOURCES_ERROR, \"PR_INSUFFICIENT_RESOURCES_ERROR\"},\n+    {PR_DIRECTORY_LOOKUP_ERROR, \"PR_DIRECTORY_LOOKUP_ERROR\"},\n+    {PR_TPD_RANGE_ERROR, \"PR_TPD_RANGE_ERROR\"},\n+    {PR_PROC_DESC_TABLE_FULL_ERROR, \"PR_PROC_DESC_TABLE_FULL_ERROR\"},\n+    {PR_SYS_DESC_TABLE_FULL_ERROR, \"PR_SYS_DESC_TABLE_FULL_ERROR\"},\n+    {PR_NOT_SOCKET_ERROR, \"PR_NOT_SOCKET_ERROR\"},\n+    {PR_NOT_TCP_SOCKET_ERROR, \"PR_NOT_TCP_SOCKET_ERROR\"},\n+    {PR_SOCKET_ADDRESS_IS_BOUND_ERROR, \"PR_SOCKET_ADDRESS_IS_BOUND_ERROR\"},\n+    {PR_NO_ACCESS_RIGHTS_ERROR, \"PR_NO_ACCESS_RIGHTS_ERROR\"},\n+    {PR_OPERATION_NOT_SUPPORTED_ERROR, \"PR_OPERATION_NOT_SUPPORTED_ERROR\"},\n+    {PR_PROTOCOL_NOT_SUPPORTED_ERROR, \"PR_PROTOCOL_NOT_SUPPORTED_ERROR\"},\n+    {PR_REMOTE_FILE_ERROR, \"PR_REMOTE_FILE_ERROR\"},\n+    {PR_BUFFER_OVERFLOW_ERROR, \"PR_BUFFER_OVERFLOW_ERROR\"},\n+    {PR_CONNECT_RESET_ERROR, \"PR_CONNECT_RESET_ERROR\"},\n+    {PR_RANGE_ERROR, \"PR_RANGE_ERROR\"},\n+    {PR_DEADLOCK_ERROR, \"PR_DEADLOCK_ERROR\"},\n+    {PR_FILE_IS_LOCKED_ERROR, \"PR_FILE_IS_LOCKED_ERROR\"},\n+    {PR_FILE_TOO_BIG_ERROR, \"PR_FILE_TOO_BIG_ERROR\"},\n+    {PR_NO_DEVICE_SPACE_ERROR, \"PR_NO_DEVICE_SPACE_ERROR\"},\n+    {PR_PIPE_ERROR, \"PR_PIPE_ERROR\"},\n+    {PR_NO_SEEK_DEVICE_ERROR, \"PR_NO_SEEK_DEVICE_ERROR\"},\n+    {PR_IS_DIRECTORY_ERROR, \"PR_IS_DIRECTORY_ERROR\"},\n+    {PR_LOOP_ERROR, \"PR_LOOP_ERROR\"},\n+    {PR_NAME_TOO_LONG_ERROR, \"PR_NAME_TOO_LONG_ERROR\"},\n+    {PR_FILE_NOT_FOUND_ERROR, \"PR_FILE_NOT_FOUND_ERROR\"},\n+    {PR_NOT_DIRECTORY_ERROR, \"PR_NOT_DIRECTORY_ERROR\"},\n+    {PR_READ_ONLY_FILESYSTEM_ERROR, \"PR_READ_ONLY_FILESYSTEM_ERROR\"},\n+    {PR_DIRECTORY_NOT_EMPTY_ERROR, \"PR_DIRECTORY_NOT_EMPTY_ERROR\"},\n+    {PR_FILESYSTEM_MOUNTED_ERROR, \"PR_FILESYSTEM_MOUNTED_ERROR\"},\n+    {PR_NOT_SAME_DEVICE_ERROR, \"PR_NOT_SAME_DEVICE_ERROR\"},\n+    {PR_DIRECTORY_CORRUPTED_ERROR, \"PR_DIRECTORY_CORRUPTED_ERROR\"},\n+    {PR_FILE_EXISTS_ERROR, \"PR_FILE_EXISTS_ERROR\"},\n+    {PR_MAX_DIRECTORY_ENTRIES_ERROR, \"PR_MAX_DIRECTORY_ENTRIES_ERROR\"},\n+    {PR_INVALID_DEVICE_STATE_ERROR, \"PR_INVALID_DEVICE_STATE_ERROR\"},\n+    {PR_DEVICE_IS_LOCKED_ERROR, \"PR_DEVICE_IS_LOCKED_ERROR\"},\n+    {PR_NO_MORE_FILES_ERROR, \"PR_NO_MORE_FILES_ERROR\"},\n+    {PR_END_OF_FILE_ERROR, \"PR_END_OF_FILE_ERROR\"},\n+    {PR_FILE_SEEK_ERROR, \"PR_FILE_SEEK_ERROR\"},\n+    {PR_FILE_IS_BUSY_ERROR, \"PR_FILE_IS_BUSY_ERROR\"},\n+    {PR_IN_PROGRESS_ERROR, \"PR_IN_PROGRESS_ERROR\"},\n+    {PR_ALREADY_INITIATED_ERROR, \"PR_ALREADY_INITIATED_ERROR\"},\n+    {PR_GROUP_EMPTY_ERROR, \"PR_GROUP_EMPTY_ERROR\"},\n+    {PR_INVALID_STATE_ERROR, \"PR_INVALID_STATE_ERROR\"},\n+    {PR_NETWORK_DOWN_ERROR, \"PR_NETWORK_DOWN_ERROR\"},\n+    {PR_SOCKET_SHUTDOWN_ERROR, \"PR_SOCKET_SHUTDOWN_ERROR\"},\n+    {PR_CONNECT_ABORTED_ERROR, \"PR_CONNECT_ABORTED_ERROR\"},\n+    {PR_HOST_UNREACHABLE_ERROR, \"PR_HOST_UNREACHABLE_ERROR\"}};\n \n-int\n-main(int argc, char** argv)\n-{\n-    int count, errnum;\n+int main(int argc, char** argv) {\n+  int count, errnum;\n \n-    /*\n-     * -d           debug mode\n-     */\n+  /*\n+   * -d           debug mode\n+   */\n \n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                _debug_on = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    count = sizeof(errcodes) / sizeof(errcodes[0]);\n-    printf(\"\\nNumber of error codes = %d\\n\\n\", count);\n-    for (errnum = 0; errnum < count; errnum++) {\n-        printf(\"%-40s = %d\\n\", errcodes[errnum].errname, errcodes[errnum].errcode);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        _debug_on = 1;\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  count = sizeof(errcodes) / sizeof(errcodes[0]);\n+  printf(\"\\nNumber of error codes = %d\\n\\n\", count);\n+  for (errnum = 0; errnum < count; errnum++) {\n+    printf(\"%-40s = %d\\n\", errcodes[errnum].errname, errcodes[errnum].errcode);\n+  }\n \n-    return 0;\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/errset.c b/nspr/pr/tests/errset.c\nindex fe7c1dc..adf2fc2 100644\n--- a/nspr/pr/tests/errset.c\n+++ b/nspr/pr/tests/errset.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -24,131 +25,128 @@\n static int _debug_on = 0;\n \n struct errinfo {\n-    PRErrorCode errcode;\n-    char* errname;\n+  PRErrorCode errcode;\n+  char* errname;\n };\n \n struct errinfo errcodes[] = {\n-    { PR_OUT_OF_MEMORY_ERROR, \"PR_OUT_OF_MEMORY_ERROR\" },\n-    { PR_UNKNOWN_ERROR,\n-      \"An intentionally long error message text intended to force a delete of \"\n-      \"the current errorString buffer and get another one.\" },\n-    { PR_BAD_DESCRIPTOR_ERROR, \"PR_BAD_DESCRIPTOR_ERROR\" },\n-    { PR_WOULD_BLOCK_ERROR, \"PR_WOULD_BLOCK_ERROR\" },\n-    { PR_ACCESS_FAULT_ERROR, \"PR_ACCESS_FAULT_ERROR\" },\n-    { PR_INVALID_METHOD_ERROR, \"PR_INVALID_METHOD_ERROR\" },\n-    { PR_ILLEGAL_ACCESS_ERROR, \"PR_ILLEGAL_ACCESS_ERROR\" },\n-    { PR_UNKNOWN_ERROR, \"PR_UNKNOWN_ERROR\" },\n-    { PR_PENDING_INTERRUPT_ERROR, \"PR_PENDING_INTERRUPT_ERROR\" },\n-    { PR_NOT_IMPLEMENTED_ERROR, \"PR_NOT_IMPLEMENTED_ERROR\" },\n-    { PR_IO_ERROR, \"PR_IO_ERROR\" },\n-    { PR_IO_TIMEOUT_ERROR, \"PR_IO_TIMEOUT_ERROR\" },\n-    { PR_IO_PENDING_ERROR, \"PR_IO_PENDING_ERROR\" },\n-    { PR_DIRECTORY_OPEN_ERROR, \"PR_DIRECTORY_OPEN_ERROR\" },\n-    { PR_INVALID_ARGUMENT_ERROR, \"PR_INVALID_ARGUMENT_ERROR\" },\n-    { PR_ADDRESS_NOT_AVAILABLE_ERROR, \"PR_ADDRESS_NOT_AVAILABLE_ERROR\" },\n-    { PR_ADDRESS_NOT_SUPPORTED_ERROR, \"PR_ADDRESS_NOT_SUPPORTED_ERROR\" },\n-    { PR_IS_CONNECTED_ERROR, \"PR_IS_CONNECTED_ERROR\" },\n-    { PR_BAD_ADDRESS_ERROR, \"PR_BAD_ADDRESS_ERROR\" },\n-    { PR_ADDRESS_IN_USE_ERROR, \"PR_ADDRESS_IN_USE_ERROR\" },\n-    { PR_CONNECT_REFUSED_ERROR, \"PR_CONNECT_REFUSED_ERROR\" },\n-    { PR_NETWORK_UNREACHABLE_ERROR, \"PR_NETWORK_UNREACHABLE_ERROR\" },\n-    { PR_CONNECT_TIMEOUT_ERROR, \"PR_CONNECT_TIMEOUT_ERROR\" },\n-    { PR_NOT_CONNECTED_ERROR, \"PR_NOT_CONNECTED_ERROR\" },\n-    { PR_LOAD_LIBRARY_ERROR, \"PR_LOAD_LIBRARY_ERROR\" },\n-    { PR_UNLOAD_LIBRARY_ERROR, \"PR_UNLOAD_LIBRARY_ERROR\" },\n-    { PR_FIND_SYMBOL_ERROR, \"PR_FIND_SYMBOL_ERROR\" },\n-    { PR_INSUFFICIENT_RESOURCES_ERROR, \"PR_INSUFFICIENT_RESOURCES_ERROR\" },\n-    { PR_DIRECTORY_LOOKUP_ERROR, \"PR_DIRECTORY_LOOKUP_ERROR\" },\n-    { PR_TPD_RANGE_ERROR, \"PR_TPD_RANGE_ERROR\" },\n-    { PR_PROC_DESC_TABLE_FULL_ERROR, \"PR_PROC_DESC_TABLE_FULL_ERROR\" },\n-    { PR_SYS_DESC_TABLE_FULL_ERROR, \"PR_SYS_DESC_TABLE_FULL_ERROR\" },\n-    { PR_NOT_SOCKET_ERROR, \"PR_NOT_SOCKET_ERROR\" },\n-    { PR_NOT_TCP_SOCKET_ERROR, \"PR_NOT_TCP_SOCKET_ERROR\" },\n-    { PR_SOCKET_ADDRESS_IS_BOUND_ERROR, \"PR_SOCKET_ADDRESS_IS_BOUND_ERROR\" },\n-    { PR_NO_ACCESS_RIGHTS_ERROR, \"PR_NO_ACCESS_RIGHTS_ERROR\" },\n-    { PR_OPERATION_NOT_SUPPORTED_ERROR, \"PR_OPERATION_NOT_SUPPORTED_ERROR\" },\n-    { PR_PROTOCOL_NOT_SUPPORTED_ERROR, \"PR_PROTOCOL_NOT_SUPPORTED_ERROR\" },\n-    { PR_REMOTE_FILE_ERROR, \"PR_REMOTE_FILE_ERROR\" },\n-    { PR_BUFFER_OVERFLOW_ERROR, \"PR_BUFFER_OVERFLOW_ERROR\" },\n-    { PR_CONNECT_RESET_ERROR, \"PR_CONNECT_RESET_ERROR\" },\n-    { PR_RANGE_ERROR, \"PR_RANGE_ERROR\" },\n-    { PR_DEADLOCK_ERROR, \"PR_DEADLOCK_ERROR\" },\n-    { PR_FILE_IS_LOCKED_ERROR, \"PR_FILE_IS_LOCKED_ERROR\" },\n-    { PR_FILE_TOO_BIG_ERROR, \"PR_FILE_TOO_BIG_ERROR\" },\n-    { PR_NO_DEVICE_SPACE_ERROR, \"PR_NO_DEVICE_SPACE_ERROR\" },\n-    { PR_PIPE_ERROR, \"PR_PIPE_ERROR\" },\n-    { PR_NO_SEEK_DEVICE_ERROR, \"PR_NO_SEEK_DEVICE_ERROR\" },\n-    { PR_IS_DIRECTORY_ERROR, \"PR_IS_DIRECTORY_ERROR\" },\n-    { PR_LOOP_ERROR, \"PR_LOOP_ERROR\" },\n-    { PR_NAME_TOO_LONG_ERROR, \"PR_NAME_TOO_LONG_ERROR\" },\n-    { PR_FILE_NOT_FOUND_ERROR, \"PR_FILE_NOT_FOUND_ERROR\" },\n-    { PR_NOT_DIRECTORY_ERROR, \"PR_NOT_DIRECTORY_ERROR\" },\n-    { PR_READ_ONLY_FILESYSTEM_ERROR, \"PR_READ_ONLY_FILESYSTEM_ERROR\" },\n-    { PR_DIRECTORY_NOT_EMPTY_ERROR, \"PR_DIRECTORY_NOT_EMPTY_ERROR\" },\n-    { PR_FILESYSTEM_MOUNTED_ERROR, \"PR_FILESYSTEM_MOUNTED_ERROR\" },\n-    { PR_NOT_SAME_DEVICE_ERROR, \"PR_NOT_SAME_DEVICE_ERROR\" },\n-    { PR_DIRECTORY_CORRUPTED_ERROR, \"PR_DIRECTORY_CORRUPTED_ERROR\" },\n-    { PR_FILE_EXISTS_ERROR, \"PR_FILE_EXISTS_ERROR\" },\n-    { PR_MAX_DIRECTORY_ENTRIES_ERROR, \"PR_MAX_DIRECTORY_ENTRIES_ERROR\" },\n-    { PR_INVALID_DEVICE_STATE_ERROR, \"PR_INVALID_DEVICE_STATE_ERROR\" },\n-    { PR_DEVICE_IS_LOCKED_ERROR, \"PR_DEVICE_IS_LOCKED_ERROR\" },\n-    { PR_NO_MORE_FILES_ERROR, \"PR_NO_MORE_FILES_ERROR\" },\n-    { PR_END_OF_FILE_ERROR, \"PR_END_OF_FILE_ERROR\" },\n-    { PR_FILE_SEEK_ERROR, \"PR_FILE_SEEK_ERROR\" },\n-    { PR_FILE_IS_BUSY_ERROR, \"PR_FILE_IS_BUSY_ERROR\" },\n-    { PR_IN_PROGRESS_ERROR, \"PR_IN_PROGRESS_ERROR\" },\n-    { PR_ALREADY_INITIATED_ERROR, \"PR_ALREADY_INITIATED_ERROR\" },\n-    { PR_GROUP_EMPTY_ERROR, \"PR_GROUP_EMPTY_ERROR\" },\n-    { PR_INVALID_STATE_ERROR, \"PR_INVALID_STATE_ERROR\" },\n-    { PR_NETWORK_DOWN_ERROR, \"PR_NETWORK_DOWN_ERROR\" },\n-    { PR_SOCKET_SHUTDOWN_ERROR, \"PR_SOCKET_SHUTDOWN_ERROR\" },\n-    { PR_CONNECT_ABORTED_ERROR, \"PR_CONNECT_ABORTED_ERROR\" },\n-    { PR_HOST_UNREACHABLE_ERROR, \"PR_HOST_UNREACHABLE_ERROR\" }\n-};\n+    {PR_OUT_OF_MEMORY_ERROR, \"PR_OUT_OF_MEMORY_ERROR\"},\n+    {PR_UNKNOWN_ERROR,\n+     \"An intentionally long error message text intended to force a delete of \"\n+     \"the current errorString buffer and get another one.\"},\n+    {PR_BAD_DESCRIPTOR_ERROR, \"PR_BAD_DESCRIPTOR_ERROR\"},\n+    {PR_WOULD_BLOCK_ERROR, \"PR_WOULD_BLOCK_ERROR\"},\n+    {PR_ACCESS_FAULT_ERROR, \"PR_ACCESS_FAULT_ERROR\"},\n+    {PR_INVALID_METHOD_ERROR, \"PR_INVALID_METHOD_ERROR\"},\n+    {PR_ILLEGAL_ACCESS_ERROR, \"PR_ILLEGAL_ACCESS_ERROR\"},\n+    {PR_UNKNOWN_ERROR, \"PR_UNKNOWN_ERROR\"},\n+    {PR_PENDING_INTERRUPT_ERROR, \"PR_PENDING_INTERRUPT_ERROR\"},\n+    {PR_NOT_IMPLEMENTED_ERROR, \"PR_NOT_IMPLEMENTED_ERROR\"},\n+    {PR_IO_ERROR, \"PR_IO_ERROR\"},\n+    {PR_IO_TIMEOUT_ERROR, \"PR_IO_TIMEOUT_ERROR\"},\n+    {PR_IO_PENDING_ERROR, \"PR_IO_PENDING_ERROR\"},\n+    {PR_DIRECTORY_OPEN_ERROR, \"PR_DIRECTORY_OPEN_ERROR\"},\n+    {PR_INVALID_ARGUMENT_ERROR, \"PR_INVALID_ARGUMENT_ERROR\"},\n+    {PR_ADDRESS_NOT_AVAILABLE_ERROR, \"PR_ADDRESS_NOT_AVAILABLE_ERROR\"},\n+    {PR_ADDRESS_NOT_SUPPORTED_ERROR, \"PR_ADDRESS_NOT_SUPPORTED_ERROR\"},\n+    {PR_IS_CONNECTED_ERROR, \"PR_IS_CONNECTED_ERROR\"},\n+    {PR_BAD_ADDRESS_ERROR, \"PR_BAD_ADDRESS_ERROR\"},\n+    {PR_ADDRESS_IN_USE_ERROR, \"PR_ADDRESS_IN_USE_ERROR\"},\n+    {PR_CONNECT_REFUSED_ERROR, \"PR_CONNECT_REFUSED_ERROR\"},\n+    {PR_NETWORK_UNREACHABLE_ERROR, \"PR_NETWORK_UNREACHABLE_ERROR\"},\n+    {PR_CONNECT_TIMEOUT_ERROR, \"PR_CONNECT_TIMEOUT_ERROR\"},\n+    {PR_NOT_CONNECTED_ERROR, \"PR_NOT_CONNECTED_ERROR\"},\n+    {PR_LOAD_LIBRARY_ERROR, \"PR_LOAD_LIBRARY_ERROR\"},\n+    {PR_UNLOAD_LIBRARY_ERROR, \"PR_UNLOAD_LIBRARY_ERROR\"},\n+    {PR_FIND_SYMBOL_ERROR, \"PR_FIND_SYMBOL_ERROR\"},\n+    {PR_INSUFFICIENT_RESOURCES_ERROR, \"PR_INSUFFICIENT_RESOURCES_ERROR\"},\n+    {PR_DIRECTORY_LOOKUP_ERROR, \"PR_DIRECTORY_LOOKUP_ERROR\"},\n+    {PR_TPD_RANGE_ERROR, \"PR_TPD_RANGE_ERROR\"},\n+    {PR_PROC_DESC_TABLE_FULL_ERROR, \"PR_PROC_DESC_TABLE_FULL_ERROR\"},\n+    {PR_SYS_DESC_TABLE_FULL_ERROR, \"PR_SYS_DESC_TABLE_FULL_ERROR\"},\n+    {PR_NOT_SOCKET_ERROR, \"PR_NOT_SOCKET_ERROR\"},\n+    {PR_NOT_TCP_SOCKET_ERROR, \"PR_NOT_TCP_SOCKET_ERROR\"},\n+    {PR_SOCKET_ADDRESS_IS_BOUND_ERROR, \"PR_SOCKET_ADDRESS_IS_BOUND_ERROR\"},\n+    {PR_NO_ACCESS_RIGHTS_ERROR, \"PR_NO_ACCESS_RIGHTS_ERROR\"},\n+    {PR_OPERATION_NOT_SUPPORTED_ERROR, \"PR_OPERATION_NOT_SUPPORTED_ERROR\"},\n+    {PR_PROTOCOL_NOT_SUPPORTED_ERROR, \"PR_PROTOCOL_NOT_SUPPORTED_ERROR\"},\n+    {PR_REMOTE_FILE_ERROR, \"PR_REMOTE_FILE_ERROR\"},\n+    {PR_BUFFER_OVERFLOW_ERROR, \"PR_BUFFER_OVERFLOW_ERROR\"},\n+    {PR_CONNECT_RESET_ERROR, \"PR_CONNECT_RESET_ERROR\"},\n+    {PR_RANGE_ERROR, \"PR_RANGE_ERROR\"},\n+    {PR_DEADLOCK_ERROR, \"PR_DEADLOCK_ERROR\"},\n+    {PR_FILE_IS_LOCKED_ERROR, \"PR_FILE_IS_LOCKED_ERROR\"},\n+    {PR_FILE_TOO_BIG_ERROR, \"PR_FILE_TOO_BIG_ERROR\"},\n+    {PR_NO_DEVICE_SPACE_ERROR, \"PR_NO_DEVICE_SPACE_ERROR\"},\n+    {PR_PIPE_ERROR, \"PR_PIPE_ERROR\"},\n+    {PR_NO_SEEK_DEVICE_ERROR, \"PR_NO_SEEK_DEVICE_ERROR\"},\n+    {PR_IS_DIRECTORY_ERROR, \"PR_IS_DIRECTORY_ERROR\"},\n+    {PR_LOOP_ERROR, \"PR_LOOP_ERROR\"},\n+    {PR_NAME_TOO_LONG_ERROR, \"PR_NAME_TOO_LONG_ERROR\"},\n+    {PR_FILE_NOT_FOUND_ERROR, \"PR_FILE_NOT_FOUND_ERROR\"},\n+    {PR_NOT_DIRECTORY_ERROR, \"PR_NOT_DIRECTORY_ERROR\"},\n+    {PR_READ_ONLY_FILESYSTEM_ERROR, \"PR_READ_ONLY_FILESYSTEM_ERROR\"},\n+    {PR_DIRECTORY_NOT_EMPTY_ERROR, \"PR_DIRECTORY_NOT_EMPTY_ERROR\"},\n+    {PR_FILESYSTEM_MOUNTED_ERROR, \"PR_FILESYSTEM_MOUNTED_ERROR\"},\n+    {PR_NOT_SAME_DEVICE_ERROR, \"PR_NOT_SAME_DEVICE_ERROR\"},\n+    {PR_DIRECTORY_CORRUPTED_ERROR, \"PR_DIRECTORY_CORRUPTED_ERROR\"},\n+    {PR_FILE_EXISTS_ERROR, \"PR_FILE_EXISTS_ERROR\"},\n+    {PR_MAX_DIRECTORY_ENTRIES_ERROR, \"PR_MAX_DIRECTORY_ENTRIES_ERROR\"},\n+    {PR_INVALID_DEVICE_STATE_ERROR, \"PR_INVALID_DEVICE_STATE_ERROR\"},\n+    {PR_DEVICE_IS_LOCKED_ERROR, \"PR_DEVICE_IS_LOCKED_ERROR\"},\n+    {PR_NO_MORE_FILES_ERROR, \"PR_NO_MORE_FILES_ERROR\"},\n+    {PR_END_OF_FILE_ERROR, \"PR_END_OF_FILE_ERROR\"},\n+    {PR_FILE_SEEK_ERROR, \"PR_FILE_SEEK_ERROR\"},\n+    {PR_FILE_IS_BUSY_ERROR, \"PR_FILE_IS_BUSY_ERROR\"},\n+    {PR_IN_PROGRESS_ERROR, \"PR_IN_PROGRESS_ERROR\"},\n+    {PR_ALREADY_INITIATED_ERROR, \"PR_ALREADY_INITIATED_ERROR\"},\n+    {PR_GROUP_EMPTY_ERROR, \"PR_GROUP_EMPTY_ERROR\"},\n+    {PR_INVALID_STATE_ERROR, \"PR_INVALID_STATE_ERROR\"},\n+    {PR_NETWORK_DOWN_ERROR, \"PR_NETWORK_DOWN_ERROR\"},\n+    {PR_SOCKET_SHUTDOWN_ERROR, \"PR_SOCKET_SHUTDOWN_ERROR\"},\n+    {PR_CONNECT_ABORTED_ERROR, \"PR_CONNECT_ABORTED_ERROR\"},\n+    {PR_HOST_UNREACHABLE_ERROR, \"PR_HOST_UNREACHABLE_ERROR\"}};\n \n-int\n-main(int argc, char** argv)\n-{\n-    int count, errnum;\n+int main(int argc, char** argv) {\n+  int count, errnum;\n \n-    /*\n-     * -d           debug mode\n-     */\n+  /*\n+   * -d           debug mode\n+   */\n \n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                _debug_on = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        _debug_on = 1;\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n+  }\n+  PL_DestroyOptState(opt);\n \n-    count = sizeof(errcodes) / sizeof(errcodes[0]);\n-    printf(\"\\nNumber of error codes = %d\\n\\n\", count);\n-    for (errnum = 0; errnum < count; errnum++) {\n-        PRInt32 len1, len2, err;\n-        char msg[256];\n+  count = sizeof(errcodes) / sizeof(errcodes[0]);\n+  printf(\"\\nNumber of error codes = %d\\n\\n\", count);\n+  for (errnum = 0; errnum < count; errnum++) {\n+    PRInt32 len1, len2, err;\n+    char msg[256];\n \n-        PR_SetError(errnum, -5);\n-        err = PR_GetError();\n-        PR_ASSERT(err == errnum);\n-        err = PR_GetOSError();\n-        PR_ASSERT(err == -5);\n-        PR_SetErrorText(strlen(errcodes[errnum].errname), errcodes[errnum].errname);\n-        len1 = PR_GetErrorTextLength();\n-        len2 = PR_GetErrorText(msg);\n-        PR_ASSERT(len1 == len2);\n-        printf(\"%5.5d -- %s\\n\", errnum, msg);\n-    }\n+    PR_SetError(errnum, -5);\n+    err = PR_GetError();\n+    PR_ASSERT(err == errnum);\n+    err = PR_GetOSError();\n+    PR_ASSERT(err == -5);\n+    PR_SetErrorText(strlen(errcodes[errnum].errname), errcodes[errnum].errname);\n+    len1 = PR_GetErrorTextLength();\n+    len2 = PR_GetErrorText(msg);\n+    PR_ASSERT(len1 == len2);\n+    printf(\"%5.5d -- %s\\n\", errnum, msg);\n+  }\n \n-    return 0;\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/exit.c b/nspr/pr/tests/exit.c\nindex 9d132bc..7ea310c 100644\n--- a/nspr/pr/tests/exit.c\n+++ b/nspr/pr/tests/exit.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -17,87 +18,79 @@ static PRInt32 dally = 0;\n static PRFileDesc* err = NULL;\n static PRBool verbose = PR_FALSE, force = PR_FALSE;\n \n-static void\n-Help(void)\n-{\n-    PR_fprintf(err, \"Usage: [-t s] [-h]\\n\");\n-    PR_fprintf(err, \"\\t-d   Verbose output              (default: FALSE)\\n\");\n-    PR_fprintf(err, \"\\t-x   Forced termination          (default: FALSE)\\n\");\n-    PR_fprintf(err, \"\\t-t   Time for thread to block    (default: 10 seconds)\\n\");\n-    PR_fprintf(err, \"\\t-h   This message and nothing else\\n\");\n+static void Help(void) {\n+  PR_fprintf(err, \"Usage: [-t s] [-h]\\n\");\n+  PR_fprintf(err, \"\\t-d   Verbose output              (default: FALSE)\\n\");\n+  PR_fprintf(err, \"\\t-x   Forced termination          (default: FALSE)\\n\");\n+  PR_fprintf(err, \"\\t-t   Time for thread to block    (default: 10 seconds)\\n\");\n+  PR_fprintf(err, \"\\t-h   This message and nothing else\\n\");\n } /* Help */\n \n-static void\n-Dull(void* arg)\n-{\n-    PR_Sleep(PR_SecondsToInterval(dally));\n-    if (verbose && force) {\n-        PR_fprintf(err, \"If you see this, the test failed\\n\");\n-    }\n+static void Dull(void* arg) {\n+  PR_Sleep(PR_SecondsToInterval(dally));\n+  if (verbose && force) {\n+    PR_fprintf(err, \"If you see this, the test failed\\n\");\n+  }\n } /* Dull */\n \n-static PRIntn PR_CALLBACK\n-RealMain(PRIntn argc, char** argv)\n-{\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"ht:dx\");\n-\n-    err = PR_GetSpecialFD(PR_StandardError);\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* verbosity */\n-                verbose = PR_TRUE;\n-                break;\n-            case 'x': /* force exit */\n-                force = PR_TRUE;\n-                break;\n-            case 't': /* seconds to dally in child */\n-                dally = atoi(opt->value);\n-                break;\n-            case 'h': /* user wants some guidance */\n-            default:\n-                Help();   /* so give him an earful */\n-                return 2; /* but not a lot else */\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n+static PRIntn PR_CALLBACK RealMain(PRIntn argc, char** argv) {\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"ht:dx\");\n \n-    if (0 == dally) {\n-        dally = 10;\n-    }\n+  err = PR_GetSpecialFD(PR_StandardError);\n \n-    /*\n-     * Create LOCAL and GLOBAL threads\n-     */\n-    (void)PR_CreateThread(PR_USER_THREAD, Dull, NULL, PR_PRIORITY_NORMAL,\n-                          PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-\n-    (void)PR_CreateThread(PR_USER_THREAD, Dull, NULL, PR_PRIORITY_NORMAL,\n-                          PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-\n-    if (verbose)\n-        PR_fprintf(err, \"Main is exiting now. Program should exit %s.\\n\",\n-                   (force) ? \"immediately\" : \"after child dally time\");\n-\n-    if (force) {\n-        PR_ProcessExit(0);\n-        if (verbose) {\n-            PR_fprintf(err, \"You should not have gotten here.\\n\");\n-            return 1;\n-        }\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* verbosity */\n+        verbose = PR_TRUE;\n+        break;\n+      case 'x': /* force exit */\n+        force = PR_TRUE;\n+        break;\n+      case 't': /* seconds to dally in child */\n+        dally = atoi(opt->value);\n+        break;\n+      case 'h': /* user wants some guidance */\n+      default:\n+        Help();   /* so give him an earful */\n+        return 2; /* but not a lot else */\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  if (0 == dally) {\n+    dally = 10;\n+  }\n+\n+  /*\n+   * Create LOCAL and GLOBAL threads\n+   */\n+  (void)PR_CreateThread(PR_USER_THREAD, Dull, NULL, PR_PRIORITY_NORMAL,\n+                        PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+\n+  (void)PR_CreateThread(PR_USER_THREAD, Dull, NULL, PR_PRIORITY_NORMAL,\n+                        PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+\n+  if (verbose)\n+    PR_fprintf(err, \"Main is exiting now. Program should exit %s.\\n\",\n+               (force) ? \"immediately\" : \"after child dally time\");\n+\n+  if (force) {\n+    PR_ProcessExit(0);\n+    if (verbose) {\n+      PR_fprintf(err, \"You should not have gotten here.\\n\");\n+      return 1;\n     }\n-    return 0;\n+  }\n+  return 0;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv;\n+int main(int argc, char** argv) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\ndiff --git a/nspr/pr/tests/fdcach.c b/nspr/pr/tests/fdcach.c\nindex 1d29ed5..e03fcb0 100644\n--- a/nspr/pr/tests/fdcach.c\n+++ b/nspr/pr/tests/fdcach.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -27,99 +28,97 @@\n #define FD_CACHE_SIZE 1024\n #define NUM_FDS 20\n \n-int\n-main(int argc, char** argv)\n-{\n-    int i;\n-    PRFileDesc* fds[NUM_FDS];\n-    PRFileDesc* savefds[NUM_FDS];\n-    int numfds = sizeof(fds) / sizeof(fds[0]);\n+int main(int argc, char** argv) {\n+  int i;\n+  PRFileDesc* fds[NUM_FDS];\n+  PRFileDesc* savefds[NUM_FDS];\n+  int numfds = sizeof(fds) / sizeof(fds[0]);\n \n-    PR_SetFDCacheSize(0, FD_CACHE_SIZE);\n+  PR_SetFDCacheSize(0, FD_CACHE_SIZE);\n \n-    /* Add some fd's to the fd cache. */\n-    for (i = 0; i < numfds; i++) {\n-        savefds[i] = PR_NewTCPSocket();\n-        if (NULL == savefds[i]) {\n-            fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-            exit(1);\n-        }\n+  /* Add some fd's to the fd cache. */\n+  for (i = 0; i < numfds; i++) {\n+    savefds[i] = PR_NewTCPSocket();\n+    if (NULL == savefds[i]) {\n+      fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+      exit(1);\n     }\n-    for (i = 0; i < numfds; i++) {\n-        if (PR_Close(savefds[i]) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_Close failed\\n\");\n-            exit(1);\n-        }\n+  }\n+  for (i = 0; i < numfds; i++) {\n+    if (PR_Close(savefds[i]) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_Close failed\\n\");\n+      exit(1);\n     }\n+  }\n \n-    /*\n-     * Create some fd's.  These fd's should come from\n-     * the fd cache.  Verify the FIFO ordering of the fd\n-     * cache.\n-     */\n-    for (i = 0; i < numfds; i++) {\n-        fds[i] = PR_NewTCPSocket();\n-        if (NULL == fds[i]) {\n-            fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-            exit(1);\n-        }\n-        if (fds[i] != savefds[i]) {\n-            fprintf(stderr, \"fd cache malfunctioned\\n\");\n-            exit(1);\n-        }\n+  /*\n+   * Create some fd's.  These fd's should come from\n+   * the fd cache.  Verify the FIFO ordering of the fd\n+   * cache.\n+   */\n+  for (i = 0; i < numfds; i++) {\n+    fds[i] = PR_NewTCPSocket();\n+    if (NULL == fds[i]) {\n+      fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+      exit(1);\n     }\n-    /* Put the fd's back to the fd cache. */\n-    for (i = 0; i < numfds; i++) {\n-        if (PR_Close(savefds[i]) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_Close failed\\n\");\n-            exit(1);\n-        }\n+    if (fds[i] != savefds[i]) {\n+      fprintf(stderr, \"fd cache malfunctioned\\n\");\n+      exit(1);\n     }\n+  }\n+  /* Put the fd's back to the fd cache. */\n+  for (i = 0; i < numfds; i++) {\n+    if (PR_Close(savefds[i]) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_Close failed\\n\");\n+      exit(1);\n+    }\n+  }\n \n-    /* Switch to the fd cache. */\n-    PR_SetFDCacheSize(0, FD_CACHE_SIZE);\n+  /* Switch to the fd cache. */\n+  PR_SetFDCacheSize(0, FD_CACHE_SIZE);\n \n-    for (i = 0; i < numfds; i++) {\n-        fds[i] = PR_NewTCPSocket();\n-        if (NULL == fds[i]) {\n-            fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-            exit(1);\n-        }\n+  for (i = 0; i < numfds; i++) {\n+    fds[i] = PR_NewTCPSocket();\n+    if (NULL == fds[i]) {\n+      fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+      exit(1);\n+    }\n #ifdef ORDER_PRESERVED\n-        if (fds[i] != savefds[i]) {\n-            fprintf(stderr, \"fd cache malfunctioned\\n\");\n-            exit(1);\n-        }\n+    if (fds[i] != savefds[i]) {\n+      fprintf(stderr, \"fd cache malfunctioned\\n\");\n+      exit(1);\n+    }\n #else\n-        savefds[i] = fds[i];\n+    savefds[i] = fds[i];\n #endif\n+  }\n+  for (i = 0; i < numfds; i++) {\n+    if (PR_Close(savefds[i]) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_Close failed\\n\");\n+      exit(1);\n     }\n-    for (i = 0; i < numfds; i++) {\n-        if (PR_Close(savefds[i]) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_Close failed\\n\");\n-            exit(1);\n-        }\n-    }\n+  }\n \n-    for (i = 0; i < numfds; i++) {\n-        fds[i] = PR_NewTCPSocket();\n-        if (NULL == fds[i]) {\n-            fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-            exit(1);\n-        }\n-        if (fds[i] != savefds[i]) {\n-            fprintf(stderr, \"fd cache malfunctioned\\n\");\n-            exit(1);\n-        }\n+  for (i = 0; i < numfds; i++) {\n+    fds[i] = PR_NewTCPSocket();\n+    if (NULL == fds[i]) {\n+      fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+      exit(1);\n+    }\n+    if (fds[i] != savefds[i]) {\n+      fprintf(stderr, \"fd cache malfunctioned\\n\");\n+      exit(1);\n     }\n-    for (i = 0; i < numfds; i++) {\n-        if (PR_Close(savefds[i]) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_Close failed\\n\");\n-            exit(1);\n-        }\n+  }\n+  for (i = 0; i < numfds; i++) {\n+    if (PR_Close(savefds[i]) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_Close failed\\n\");\n+      exit(1);\n     }\n+  }\n \n-    PR_Cleanup();\n-    printf(\"PASS\\n\");\n-    return 0;\n+  PR_Cleanup();\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/fileio.c b/nspr/pr/tests/fileio.c\nindex e16d72c..dac051b 100644\n--- a/nspr/pr/tests/fileio.c\n+++ b/nspr/pr/tests/fileio.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -47,62 +48,58 @@ static PRFileDesc *t1, *t2;\n \n PRIntn failed_already = 0;\n PRIntn debug_mode;\n-static void\n-InitialSetup(void)\n-{\n-    PRUintn i;\n-    PRInt32 nWritten, rv;\n+static void InitialSetup(void) {\n+  PRUintn i;\n+  PRInt32 nWritten, rv;\n \n-    t1 = PR_Open(\"t1.tmp\", PR_CREATE_FILE | PR_RDWR, 0);\n-    PR_ASSERT(t1 != NULL);\n+  t1 = PR_Open(\"t1.tmp\", PR_CREATE_FILE | PR_RDWR, 0);\n+  PR_ASSERT(t1 != NULL);\n \n-    for (i = 0; i < TBSIZE; i++) {\n-        tbuf[i] = i;\n-    }\n+  for (i = 0; i < TBSIZE; i++) {\n+    tbuf[i] = i;\n+  }\n \n-    nWritten = PR_Write((PRFileDesc*)t1, tbuf, TBSIZE);\n-    PR_ASSERT(nWritten == TBSIZE);\n+  nWritten = PR_Write((PRFileDesc*)t1, tbuf, TBSIZE);\n+  PR_ASSERT(nWritten == TBSIZE);\n \n-    rv = PR_Seek(t1, 0, PR_SEEK_SET);\n-    PR_ASSERT(rv == 0);\n+  rv = PR_Seek(t1, 0, PR_SEEK_SET);\n+  PR_ASSERT(rv == 0);\n \n-    t2 = PR_Open(\"t2.tmp\", PR_CREATE_FILE | PR_RDWR, 0);\n-    PR_ASSERT(t2 != NULL);\n+  t2 = PR_Open(\"t2.tmp\", PR_CREATE_FILE | PR_RDWR, 0);\n+  PR_ASSERT(t2 != NULL);\n }\n \n-static void\n-VerifyAndCleanup(void)\n-{\n-    PRUintn i;\n-    PRInt32 nRead, rv;\n+static void VerifyAndCleanup(void) {\n+  PRUintn i;\n+  PRInt32 nRead, rv;\n \n-    for (i = 0; i < TBSIZE; i++) {\n-        tbuf[i] = 0;\n-    }\n+  for (i = 0; i < TBSIZE; i++) {\n+    tbuf[i] = 0;\n+  }\n \n-    rv = PR_Seek(t2, 0, PR_SEEK_SET);\n-    PR_ASSERT(rv == 0);\n+  rv = PR_Seek(t2, 0, PR_SEEK_SET);\n+  PR_ASSERT(rv == 0);\n \n-    nRead = PR_Read((PRFileDesc*)t2, tbuf, TBSIZE);\n-    PR_ASSERT(nRead == TBSIZE);\n+  nRead = PR_Read((PRFileDesc*)t2, tbuf, TBSIZE);\n+  PR_ASSERT(nRead == TBSIZE);\n \n-    for (i = 0; i < TBSIZE; i++)\n-        if (tbuf[i] != (PRUint8)i) {\n-            if (debug_mode) {\n-                printf(\"data mismatch for index= %d \\n\", i);\n-            } else {\n-                failed_already = 1;\n-            }\n-        }\n-    PR_Close(t1);\n-    PR_Close(t2);\n+  for (i = 0; i < TBSIZE; i++)\n+    if (tbuf[i] != (PRUint8)i) {\n+      if (debug_mode) {\n+        printf(\"data mismatch for index= %d \\n\", i);\n+      } else {\n+        failed_already = 1;\n+      }\n+    }\n+  PR_Close(t1);\n+  PR_Close(t2);\n \n-    PR_Delete(\"t1.tmp\");\n-    PR_Delete(\"t2.tmp\");\n+  PR_Delete(\"t1.tmp\");\n+  PR_Delete(\"t2.tmp\");\n \n-    if (debug_mode) {\n-        printf(\"fileio test passed\\n\");\n-    }\n+  if (debug_mode) {\n+    printf(\"fileio test passed\\n\");\n+  }\n }\n \n /*------------------ Following is the real test program ---------*/\n@@ -121,83 +118,77 @@ PRSemaphore* fullBufs;  /* number of buffers that are full */\n #define BSIZE 100\n \n struct {\n-    char data[BSIZE];\n-    PRUintn nbytes; /* number of bytes in this buffer */\n+  char data[BSIZE];\n+  PRUintn nbytes; /* number of bytes in this buffer */\n } buf[2];\n \n-static void PR_CALLBACK\n-reader(void* arg)\n-{\n-    PRUintn i = 0;\n-    PRInt32 nbytes;\n-\n-    do {\n-        (void)PR_WaitSem(emptyBufs);\n-        nbytes = PR_Read((PRFileDesc*)arg, buf[i].data, BSIZE);\n-        if (nbytes >= 0) {\n-            buf[i].nbytes = nbytes;\n-            PR_PostSem(fullBufs);\n-            i = (i + 1) % 2;\n-        }\n-    } while (nbytes > 0);\n+static void PR_CALLBACK reader(void* arg) {\n+  PRUintn i = 0;\n+  PRInt32 nbytes;\n+\n+  do {\n+    (void)PR_WaitSem(emptyBufs);\n+    nbytes = PR_Read((PRFileDesc*)arg, buf[i].data, BSIZE);\n+    if (nbytes >= 0) {\n+      buf[i].nbytes = nbytes;\n+      PR_PostSem(fullBufs);\n+      i = (i + 1) % 2;\n+    }\n+  } while (nbytes > 0);\n }\n \n-static void PR_CALLBACK\n-writer(void* arg)\n-{\n-    PRUintn i = 0;\n-    PRInt32 nbytes;\n-\n-    do {\n-        (void)PR_WaitSem(fullBufs);\n-        nbytes = buf[i].nbytes;\n-        if (nbytes > 0) {\n-            nbytes = PR_Write((PRFileDesc*)arg, buf[i].data, nbytes);\n-            PR_PostSem(emptyBufs);\n-            i = (i + 1) % 2;\n-        }\n-    } while (nbytes > 0);\n+static void PR_CALLBACK writer(void* arg) {\n+  PRUintn i = 0;\n+  PRInt32 nbytes;\n+\n+  do {\n+    (void)PR_WaitSem(fullBufs);\n+    nbytes = buf[i].nbytes;\n+    if (nbytes > 0) {\n+      nbytes = PR_Write((PRFileDesc*)arg, buf[i].data, nbytes);\n+      PR_PostSem(emptyBufs);\n+      i = (i + 1) % 2;\n+    }\n+  } while (nbytes > 0);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRThread *r, *w;\n+int main(int argc, char** argv) {\n+  PRThread *r, *w;\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    emptyBufs = PR_NewSem(2); /* two empty buffers */\n+  emptyBufs = PR_NewSem(2); /* two empty buffers */\n \n-    fullBufs = PR_NewSem(0); /* zero full buffers */\n+  fullBufs = PR_NewSem(0); /* zero full buffers */\n \n-    /* Create initial temp file setup */\n-    InitialSetup();\n+  /* Create initial temp file setup */\n+  InitialSetup();\n \n-    /* create the reader thread */\n+  /* create the reader thread */\n \n-    r = PR_CreateThread(PR_USER_THREAD, reader, t1, PR_PRIORITY_NORMAL,\n-                        PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  r = PR_CreateThread(PR_USER_THREAD, reader, t1, PR_PRIORITY_NORMAL,\n+                      PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n \n-    w = PR_CreateThread(PR_USER_THREAD, writer, t2, PR_PRIORITY_NORMAL,\n-                        PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  w = PR_CreateThread(PR_USER_THREAD, writer, t2, PR_PRIORITY_NORMAL,\n+                      PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n \n-    /* Do the joining for both threads */\n-    (void)PR_JoinThread(r);\n-    (void)PR_JoinThread(w);\n+  /* Do the joining for both threads */\n+  (void)PR_JoinThread(r);\n+  (void)PR_JoinThread(w);\n \n-    /* Do the verification and clean up */\n-    VerifyAndCleanup();\n+  /* Do the verification and clean up */\n+  VerifyAndCleanup();\n \n-    PR_DestroySem(emptyBufs);\n-    PR_DestroySem(fullBufs);\n+  PR_DestroySem(emptyBufs);\n+  PR_DestroySem(fullBufs);\n \n-    PR_Cleanup();\n+  PR_Cleanup();\n \n-    if (failed_already) {\n-        printf(\"Fail\\n\");\n-        return 1;\n-    } else {\n-        printf(\"PASS\\n\");\n-        return 0;\n-    }\n+  if (failed_already) {\n+    printf(\"Fail\\n\");\n+    return 1;\n+  } else {\n+    printf(\"PASS\\n\");\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/foreign.c b/nspr/pr/tests/foreign.c\nindex a44f79b..8ad7dd0 100644\n--- a/nspr/pr/tests/foreign.c\n+++ b/nspr/pr/tests/foreign.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -33,16 +34,16 @@\n #include <stdlib.h>\n \n static enum {\n-    thread_nspr,\n-    thread_pthread,\n-    thread_sproc,\n-    thread_win32\n+  thread_nspr,\n+  thread_pthread,\n+  thread_sproc,\n+  thread_win32\n } thread_provider;\n \n typedef void (*StartFn)(void*);\n typedef struct StartObject {\n-    StartFn start;\n-    void* arg;\n+  StartFn start;\n+  void* arg;\n } StartObject;\n \n static PRFileDesc* output;\n@@ -52,281 +53,259 @@ static int _debug_on = 0;\n #define DEFAULT_THREAD_COUNT 10\n \n #define DPRINTF(arg) \\\n-    if (_debug_on)   \\\n-    PR_fprintf arg\n+  if (_debug_on) PR_fprintf arg\n \n #if defined(_PR_PTHREADS)\n-#include <pthread.h>\n-#include \"md/_pth.h\"\n-static void*\n-pthread_start(void* arg)\n-{\n-    StartFn start = ((StartObject*)arg)->start;\n-    void* data = ((StartObject*)arg)->arg;\n-    PR_Free(arg);\n-    start(data);\n-    return NULL;\n+#  include <pthread.h>\n+#  include \"md/_pth.h\"\n+static void* pthread_start(void* arg) {\n+  StartFn start = ((StartObject*)arg)->start;\n+  void* data = ((StartObject*)arg)->arg;\n+  PR_Free(arg);\n+  start(data);\n+  return NULL;\n } /* pthread_start */\n #endif /* defined(_PR_PTHREADS) */\n \n #if defined(WIN32)\n-#include <windows.h>\n-#include <process.h> /* for _beginthreadex() */\n-\n-static PRUintn __stdcall\n-windows_start(void* arg)\n-{\n-    StartObject* so = (StartObject*)arg;\n-    StartFn start = so->start;\n-    void* data = so->arg;\n-    PR_Free(so);\n-    start(data);\n-    return 0;\n+#  include <windows.h>\n+#  include <process.h> /* for _beginthreadex() */\n+\n+static PRUintn __stdcall windows_start(void* arg) {\n+  StartObject* so = (StartObject*)arg;\n+  StartFn start = so->start;\n+  void* data = so->arg;\n+  PR_Free(so);\n+  start(data);\n+  return 0;\n } /* windows_start */\n #endif /* defined(WIN32) */\n \n-static PRStatus\n-NSPRPUB_TESTS_CreateThread(StartFn start, void* arg)\n-{\n-    PRStatus rv;\n-\n-    switch (thread_provider) {\n-        case thread_nspr: {\n-            PRThread* thread =\n-                PR_CreateThread(PR_USER_THREAD, start, arg, PR_PRIORITY_NORMAL,\n-                                PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-            rv = (NULL == thread) ? PR_FAILURE : PR_SUCCESS;\n-        } break;\n-        case thread_pthread:\n+static PRStatus NSPRPUB_TESTS_CreateThread(StartFn start, void* arg) {\n+  PRStatus rv;\n+\n+  switch (thread_provider) {\n+    case thread_nspr: {\n+      PRThread* thread =\n+          PR_CreateThread(PR_USER_THREAD, start, arg, PR_PRIORITY_NORMAL,\n+                          PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+      rv = (NULL == thread) ? PR_FAILURE : PR_SUCCESS;\n+    } break;\n+    case thread_pthread:\n #if defined(_PR_PTHREADS)\n-        {\n-            int rv;\n-            pthread_t id;\n-            pthread_attr_t tattr;\n-            size_t stacksize = 64 * 1024;\n-            StartObject* start_object;\n-            start_object = PR_NEW(StartObject);\n-            PR_ASSERT(NULL != start_object);\n-            start_object->start = start;\n-            start_object->arg = arg;\n-\n-            rv = _PT_PTHREAD_ATTR_INIT(&tattr);\n-            PR_ASSERT(0 == rv);\n-\n-            rv = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);\n-            PR_ASSERT(0 == rv);\n-\n-            /* Some platforms (e.g. aarch64 glibc) have a PTHREAD_STACK_MIN that\n-             * exceeds our default, which makes pthread_attr_setstacksize fail with\n-             * EINVAL.  Never request less than the platform minimum. */\n-#ifdef PTHREAD_STACK_MIN\n-            if (stacksize < (size_t)PTHREAD_STACK_MIN) {\n-                stacksize = (size_t)PTHREAD_STACK_MIN;\n-            }\n-#endif\n-            rv = pthread_attr_setstacksize(&tattr, stacksize);\n-            PR_ASSERT(0 == rv);\n-\n-            rv = _PT_PTHREAD_CREATE(&id, tattr, pthread_start, start_object);\n-            (void)_PT_PTHREAD_ATTR_DESTROY(&tattr);\n-            return (0 == rv) ? PR_SUCCESS : PR_FAILURE;\n-        }\n+    {\n+      int rv;\n+      pthread_t id;\n+      pthread_attr_t tattr;\n+      StartObject* start_object;\n+      start_object = PR_NEW(StartObject);\n+      PR_ASSERT(NULL != start_object);\n+      start_object->start = start;\n+      start_object->arg = arg;\n+\n+      rv = _PT_PTHREAD_ATTR_INIT(&tattr);\n+      PR_ASSERT(0 == rv);\n+\n+      rv = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);\n+      PR_ASSERT(0 == rv);\n+\n+      rv = pthread_attr_setstacksize(&tattr, 64 * 1024);\n+      PR_ASSERT(0 == rv);\n+\n+      rv = _PT_PTHREAD_CREATE(&id, tattr, pthread_start, start_object);\n+      (void)_PT_PTHREAD_ATTR_DESTROY(&tattr);\n+      return (0 == rv) ? PR_SUCCESS : PR_FAILURE;\n+    }\n #else\n-            PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-            rv = PR_FAILURE;\n-            break;\n+      PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+      rv = PR_FAILURE;\n+      break;\n #endif /* defined(_PR_PTHREADS) */\n \n-        case thread_sproc:\n-            PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-            rv = PR_FAILURE;\n-            break;\n-        case thread_win32:\n+    case thread_sproc:\n+      PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+      rv = PR_FAILURE;\n+      break;\n+    case thread_win32:\n #if defined(WIN32)\n-        {\n-            void* th;\n-            PRUintn id;\n-            StartObject* start_object;\n-            start_object = PR_NEW(StartObject);\n-            PR_ASSERT(NULL != start_object);\n-            start_object->start = start;\n-            start_object->arg = arg;\n-            th = (void*)_beginthreadex(\n-                NULL,                              /* LPSECURITY_ATTRIBUTES - pointer to thread security attributes\n-                                                    */\n-                0U,                                /* DWORD - initial thread stack size, in bytes */\n-                windows_start,                     /* LPTHREAD_START_ROUTINE - pointer to thread function\n-                                                    */\n-                start_object,                      /* LPVOID - argument for new thread */\n-                STACK_SIZE_PARAM_IS_A_RESERVATION, /*DWORD dwCreationFlags - creation\n-                                                      flags */\n-                &id /* LPDWORD - pointer to returned thread identifier */);\n-\n-            rv = (NULL == th) ? PR_FAILURE : PR_SUCCESS;\n-        }\n+    {\n+      void* th;\n+      PRUintn id;\n+      StartObject* start_object;\n+      start_object = PR_NEW(StartObject);\n+      PR_ASSERT(NULL != start_object);\n+      start_object->start = start;\n+      start_object->arg = arg;\n+      th = (void*)_beginthreadex(\n+          NULL, /* LPSECURITY_ATTRIBUTES - pointer to thread security attributes\n+                 */\n+          0U,   /* DWORD - initial thread stack size, in bytes */\n+          windows_start, /* LPTHREAD_START_ROUTINE - pointer to thread function\n+                          */\n+          start_object,  /* LPVOID - argument for new thread */\n+          STACK_SIZE_PARAM_IS_A_RESERVATION, /*DWORD dwCreationFlags - creation\n+                                                flags */\n+          &id /* LPDWORD - pointer to returned thread identifier */);\n+\n+      rv = (NULL == th) ? PR_FAILURE : PR_SUCCESS;\n+    }\n #else\n-            PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-            rv = PR_FAILURE;\n+      PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+      rv = PR_FAILURE;\n #endif\n-        break;\n-        default:\n-            PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-            rv = PR_FAILURE;\n-    }\n-    return rv;\n+    break;\n+    default:\n+      PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+      rv = PR_FAILURE;\n+  }\n+  return rv;\n } /* NSPRPUB_TESTS_CreateThread */\n \n-static void PR_CALLBACK\n-lazyEntry(void* arg)\n-{\n-    PR_ASSERT(NULL == arg);\n+static void PR_CALLBACK lazyEntry(void* arg) {\n+  PR_ASSERT(NULL == arg);\n } /* lazyEntry */\n \n-static void\n-OneShot(void* arg)\n-{\n-    PRUintn pdkey;\n-    PRLock* lock;\n-    PRFileDesc* fd;\n-    PRDir* dir;\n-    PRFileDesc* pair[2];\n-    PRIntn test = (PRIntn)arg;\n-\n-    for (test = 0; test < 12; ++test) {\n-        switch (test) {\n-            case 0:\n-                lock = PR_NewLock();\n-                DPRINTF((output, \"Thread[0x%x] called PR_NewLock\\n\",\n-                         PR_GetCurrentThread()));\n-                PR_DestroyLock(lock);\n-                break;\n-\n-            case 1:\n-                (void)PR_SecondsToInterval(1);\n-                DPRINTF((output, \"Thread[0x%x] called PR_SecondsToInterval\\n\",\n-                         PR_GetCurrentThread()));\n-                break;\n-\n-            case 2:\n-                (void)PR_CreateThread(PR_USER_THREAD, lazyEntry, NULL,\n-                                      PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n-                                      PR_UNJOINABLE_THREAD, 0);\n-                DPRINTF((output, \"Thread[0x%x] called PR_CreateThread\\n\",\n-                         PR_GetCurrentThread()));\n-                break;\n-\n-            case 3:\n-                fd = PR_Open(\"foreign.tmp\", PR_CREATE_FILE | PR_RDWR, 0666);\n-                DPRINTF(\n-                    (output, \"Thread[0x%x] called PR_Open\\n\", PR_GetCurrentThread()));\n-                PR_Close(fd);\n-                break;\n-\n-            case 4:\n-                fd = PR_NewUDPSocket();\n-                DPRINTF((output, \"Thread[0x%x] called PR_NewUDPSocket\\n\",\n-                         PR_GetCurrentThread()));\n-                PR_Close(fd);\n-                break;\n-\n-            case 5:\n-                fd = PR_NewTCPSocket();\n-                DPRINTF((output, \"Thread[0x%x] called PR_NewTCPSocket\\n\",\n-                         PR_GetCurrentThread()));\n-                PR_Close(fd);\n-                break;\n-\n-            case 6:\n+static void OneShot(void* arg) {\n+  PRUintn pdkey;\n+  PRLock* lock;\n+  PRFileDesc* fd;\n+  PRDir* dir;\n+  PRFileDesc* pair[2];\n+  PRIntn test = (PRIntn)arg;\n+\n+  for (test = 0; test < 12; ++test) {\n+    switch (test) {\n+      case 0:\n+        lock = PR_NewLock();\n+        DPRINTF((output, \"Thread[0x%x] called PR_NewLock\\n\",\n+                 PR_GetCurrentThread()));\n+        PR_DestroyLock(lock);\n+        break;\n+\n+      case 1:\n+        (void)PR_SecondsToInterval(1);\n+        DPRINTF((output, \"Thread[0x%x] called PR_SecondsToInterval\\n\",\n+                 PR_GetCurrentThread()));\n+        break;\n+\n+      case 2:\n+        (void)PR_CreateThread(PR_USER_THREAD, lazyEntry, NULL,\n+                              PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n+                              PR_UNJOINABLE_THREAD, 0);\n+        DPRINTF((output, \"Thread[0x%x] called PR_CreateThread\\n\",\n+                 PR_GetCurrentThread()));\n+        break;\n+\n+      case 3:\n+        fd = PR_Open(\"foreign.tmp\", PR_CREATE_FILE | PR_RDWR, 0666);\n+        DPRINTF(\n+            (output, \"Thread[0x%x] called PR_Open\\n\", PR_GetCurrentThread()));\n+        PR_Close(fd);\n+        break;\n+\n+      case 4:\n+        fd = PR_NewUDPSocket();\n+        DPRINTF((output, \"Thread[0x%x] called PR_NewUDPSocket\\n\",\n+                 PR_GetCurrentThread()));\n+        PR_Close(fd);\n+        break;\n+\n+      case 5:\n+        fd = PR_NewTCPSocket();\n+        DPRINTF((output, \"Thread[0x%x] called PR_NewTCPSocket\\n\",\n+                 PR_GetCurrentThread()));\n+        PR_Close(fd);\n+        break;\n+\n+      case 6:\n #define TEMP_DIR \"./tmp\"\n-                PR_MkDir(TEMP_DIR, 0700);\n-                dir = PR_OpenDir(TEMP_DIR);\n-                DPRINTF((output, \"Thread[0x%x] called PR_OpenDir\\n\",\n-                         PR_GetCurrentThread()));\n-                PR_CloseDir(dir);\n-                break;\n-\n-            case 7:\n-                (void)PR_NewThreadPrivateIndex(&pdkey, NULL);\n-                DPRINTF((output, \"Thread[0x%x] called PR_NewThreadPrivateIndex\\n\",\n-                         PR_GetCurrentThread()));\n-                break;\n-\n-            case 8:\n-                (void)PR_GetEnv(\"PATH\");\n-                DPRINTF(\n-                    (output, \"Thread[0x%x] called PR_GetEnv\\n\", PR_GetCurrentThread()));\n-                break;\n-\n-            case 9:\n-                (void)PR_NewTCPSocketPair(pair);\n-                DPRINTF((output, \"Thread[0x%x] called PR_NewTCPSocketPair\\n\",\n-                         PR_GetCurrentThread()));\n-                PR_Close(pair[0]);\n-                PR_Close(pair[1]);\n-                break;\n-\n-            case 10:\n-                PR_SetConcurrency(2);\n-                DPRINTF((output, \"Thread[0x%x] called PR_SetConcurrency\\n\",\n-                         PR_GetCurrentThread()));\n-                break;\n-\n-            case 11:\n-                PR_SetThreadPriority(PR_GetCurrentThread(), PR_PRIORITY_HIGH);\n-                DPRINTF((output, \"Thread[0x%x] called PR_SetThreadPriority\\n\",\n-                         PR_GetCurrentThread()));\n-                break;\n-\n-            default:\n-                break;\n-        } /* switch() */\n-    }\n+        PR_MkDir(TEMP_DIR, 0700);\n+        dir = PR_OpenDir(TEMP_DIR);\n+        DPRINTF((output, \"Thread[0x%x] called PR_OpenDir\\n\",\n+                 PR_GetCurrentThread()));\n+        PR_CloseDir(dir);\n+        break;\n+\n+      case 7:\n+        (void)PR_NewThreadPrivateIndex(&pdkey, NULL);\n+        DPRINTF((output, \"Thread[0x%x] called PR_NewThreadPrivateIndex\\n\",\n+                 PR_GetCurrentThread()));\n+        break;\n+\n+      case 8:\n+        (void)PR_GetEnv(\"PATH\");\n+        DPRINTF(\n+            (output, \"Thread[0x%x] called PR_GetEnv\\n\", PR_GetCurrentThread()));\n+        break;\n+\n+      case 9:\n+        (void)PR_NewTCPSocketPair(pair);\n+        DPRINTF((output, \"Thread[0x%x] called PR_NewTCPSocketPair\\n\",\n+                 PR_GetCurrentThread()));\n+        PR_Close(pair[0]);\n+        PR_Close(pair[1]);\n+        break;\n+\n+      case 10:\n+        PR_SetConcurrency(2);\n+        DPRINTF((output, \"Thread[0x%x] called PR_SetConcurrency\\n\",\n+                 PR_GetCurrentThread()));\n+        break;\n+\n+      case 11:\n+        PR_SetThreadPriority(PR_GetCurrentThread(), PR_PRIORITY_HIGH);\n+        DPRINTF((output, \"Thread[0x%x] called PR_SetThreadPriority\\n\",\n+                 PR_GetCurrentThread()));\n+        break;\n+\n+      default:\n+        break;\n+    } /* switch() */\n+  }\n } /* OneShot */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRStatus rv;\n-    PRInt32 thread_cnt = DEFAULT_THREAD_COUNT;\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dt:\");\n+int main(int argc, char** argv) {\n+  PRStatus rv;\n+  PRInt32 thread_cnt = DEFAULT_THREAD_COUNT;\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dt:\");\n \n #if defined(WIN32)\n-    thread_provider = thread_win32;\n+  thread_provider = thread_win32;\n #elif defined(_PR_PTHREADS)\n-    thread_provider = thread_pthread;\n+  thread_provider = thread_pthread;\n #else\n-    thread_provider = thread_nspr;\n+  thread_provider = thread_nspr;\n #endif\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                _debug_on = 1;\n-                break;\n-            case 't': /* thread count */\n-                thread_cnt = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        _debug_on = 1;\n+        break;\n+      case 't': /* thread count */\n+        thread_cnt = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    PR_SetConcurrency(2);\n+  PR_SetConcurrency(2);\n \n-    output = PR_GetSpecialFD(PR_StandardOutput);\n+  output = PR_GetSpecialFD(PR_StandardOutput);\n \n-    while (thread_cnt-- > 0) {\n-        rv = NSPRPUB_TESTS_CreateThread(OneShot, (void*)thread_cnt);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        PR_Sleep(PR_MillisecondsToInterval(5));\n-    }\n-    PR_Sleep(PR_SecondsToInterval(3));\n-    return (PR_SUCCESS == PR_Cleanup()) ? 0 : 1;\n+  while (thread_cnt-- > 0) {\n+    rv = NSPRPUB_TESTS_CreateThread(OneShot, (void*)thread_cnt);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    PR_Sleep(PR_MillisecondsToInterval(5));\n+  }\n+  PR_Sleep(PR_SecondsToInterval(3));\n+  return (PR_SUCCESS == PR_Cleanup()) ? 0 : 1;\n } /* main */\n \n /* foreign.c */\ndiff --git a/nspr/pr/tests/forktest.c b/nspr/pr/tests/forktest.c\nindex 615bc7c..ccd99f6 100644\n--- a/nspr/pr/tests/forktest.c\n+++ b/nspr/pr/tests/forktest.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -39,64 +40,62 @@ PRIntn failed_already = 0;\n \n #ifdef XP_UNIX\n \n-#include <sys/types.h>\n-#include <sys/wait.h>\n-#include <unistd.h>\n-#include <errno.h>\n+#  include <sys/types.h>\n+#  include <sys/wait.h>\n+#  include <unistd.h>\n+#  include <errno.h>\n \n static char* message = \"Hello world!\";\n \n-static void\n-ClientThreadFunc(void* arg)\n-{\n-    PRNetAddr addr;\n-    PRFileDesc* sock = NULL;\n-    PRInt32 tmp = (PRInt32)arg;\n-\n-    /*\n-     * Make sure the PR_Accept call will block\n-     */\n-\n-    printf(\"Wait one second before connect\\n\");\n-    fflush(stdout);\n-    PR_Sleep(PR_SecondsToInterval(1));\n-\n-    addr.inet.family = AF_INET;\n-    addr.inet.ip = PR_htonl(INADDR_ANY);\n-    addr.inet.port = 0;\n-    if ((sock = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"failed to create TCP socket: error code %d\\n\",\n-                PR_GetError());\n-        failed_already = 1;\n-        goto finish;\n-    }\n-    if (PR_Bind(sock, &addr) != PR_SUCCESS) {\n-        fprintf(stderr, \"PR_Bind failed: error code %d\\n\", PR_GetError());\n-        failed_already = 1;\n-        goto finish;\n-    }\n-    addr.inet.ip = PR_htonl(INADDR_LOOPBACK);\n-    addr.inet.port = PR_htons((PRInt16)tmp);\n-    printf(\"Connecting to port %hu\\n\", PR_ntohs(addr.inet.port));\n-    fflush(stdout);\n-    if (PR_Connect(sock, &addr, PR_SecondsToInterval(5)) != PR_SUCCESS) {\n-        fprintf(stderr, \"PR_Connect failed: error code %d\\n\", PR_GetError());\n-        failed_already = 1;\n-        goto finish;\n-    }\n-    printf(\"Writing message \\\"%s\\\"\\n\", message);\n-    fflush(stdout);\n-    if (PR_Send(sock, message, strlen(message) + 1, 0, PR_INTERVAL_NO_TIMEOUT) ==\n-        -1) {\n-        fprintf(stderr, \"PR_Send failed: error code %d\\n\", PR_GetError());\n-        failed_already = 1;\n-        goto finish;\n-    }\n+static void ClientThreadFunc(void* arg) {\n+  PRNetAddr addr;\n+  PRFileDesc* sock = NULL;\n+  PRInt32 tmp = (PRInt32)arg;\n+\n+  /*\n+   * Make sure the PR_Accept call will block\n+   */\n+\n+  printf(\"Wait one second before connect\\n\");\n+  fflush(stdout);\n+  PR_Sleep(PR_SecondsToInterval(1));\n+\n+  addr.inet.family = AF_INET;\n+  addr.inet.ip = PR_htonl(INADDR_ANY);\n+  addr.inet.port = 0;\n+  if ((sock = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"failed to create TCP socket: error code %d\\n\",\n+            PR_GetError());\n+    failed_already = 1;\n+    goto finish;\n+  }\n+  if (PR_Bind(sock, &addr) != PR_SUCCESS) {\n+    fprintf(stderr, \"PR_Bind failed: error code %d\\n\", PR_GetError());\n+    failed_already = 1;\n+    goto finish;\n+  }\n+  addr.inet.ip = PR_htonl(INADDR_LOOPBACK);\n+  addr.inet.port = PR_htons((PRInt16)tmp);\n+  printf(\"Connecting to port %hu\\n\", PR_ntohs(addr.inet.port));\n+  fflush(stdout);\n+  if (PR_Connect(sock, &addr, PR_SecondsToInterval(5)) != PR_SUCCESS) {\n+    fprintf(stderr, \"PR_Connect failed: error code %d\\n\", PR_GetError());\n+    failed_already = 1;\n+    goto finish;\n+  }\n+  printf(\"Writing message \\\"%s\\\"\\n\", message);\n+  fflush(stdout);\n+  if (PR_Send(sock, message, strlen(message) + 1, 0, PR_INTERVAL_NO_TIMEOUT) ==\n+      -1) {\n+    fprintf(stderr, \"PR_Send failed: error code %d\\n\", PR_GetError());\n+    failed_already = 1;\n+    goto finish;\n+  }\n finish:\n-    if (sock) {\n-        PR_Close(sock);\n-    }\n-    return;\n+  if (sock) {\n+    PR_Close(sock);\n+  }\n+  return;\n }\n \n /*\n@@ -104,143 +103,137 @@ finish:\n  *     This function creates a thread that acts as a client and itself.\n  *     acts as a server.  Then it joins the client thread.\n  */\n-static void\n-DoIO(void)\n-{\n-    PRThread* clientThread;\n-    PRFileDesc* listenSock = NULL;\n-    PRFileDesc* sock = NULL;\n-    PRNetAddr addr;\n-    PRInt32 nBytes;\n-    char buf[128];\n-\n-    listenSock = PR_NewTCPSocket();\n-    if (!listenSock) {\n-        fprintf(stderr, \"failed to create a TCP socket: error code %d\\n\",\n-                PR_GetError());\n-        failed_already = 1;\n-        goto finish;\n-    }\n-    addr.inet.family = AF_INET;\n-    addr.inet.ip = PR_htonl(INADDR_ANY);\n-    addr.inet.port = 0;\n-    if (PR_Bind(listenSock, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"failed to bind socket: error code %d\\n\", PR_GetError());\n-        failed_already = 1;\n-        goto finish;\n-    }\n-    if (PR_GetSockName(listenSock, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"failed to get socket port number: error code %d\\n\",\n-                PR_GetError());\n-        failed_already = 1;\n-        goto finish;\n-    }\n-    if (PR_Listen(listenSock, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Listen failed: error code %d\\n\", PR_GetError());\n-        failed_already = 1;\n-        goto finish;\n-    }\n-    clientThread = PR_CreateThread(\n-        PR_USER_THREAD, ClientThreadFunc, (void*)PR_ntohs(addr.inet.port),\n-        PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (clientThread == NULL) {\n-        fprintf(stderr, \"Cannot create client thread: (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        failed_already = 1;\n-        goto finish;\n-    }\n-    printf(\"Accepting connection at port %hu\\n\", PR_ntohs(addr.inet.port));\n+static void DoIO(void) {\n+  PRThread* clientThread;\n+  PRFileDesc* listenSock = NULL;\n+  PRFileDesc* sock = NULL;\n+  PRNetAddr addr;\n+  PRInt32 nBytes;\n+  char buf[128];\n+\n+  listenSock = PR_NewTCPSocket();\n+  if (!listenSock) {\n+    fprintf(stderr, \"failed to create a TCP socket: error code %d\\n\",\n+            PR_GetError());\n+    failed_already = 1;\n+    goto finish;\n+  }\n+  addr.inet.family = AF_INET;\n+  addr.inet.ip = PR_htonl(INADDR_ANY);\n+  addr.inet.port = 0;\n+  if (PR_Bind(listenSock, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"failed to bind socket: error code %d\\n\", PR_GetError());\n+    failed_already = 1;\n+    goto finish;\n+  }\n+  if (PR_GetSockName(listenSock, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"failed to get socket port number: error code %d\\n\",\n+            PR_GetError());\n+    failed_already = 1;\n+    goto finish;\n+  }\n+  if (PR_Listen(listenSock, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Listen failed: error code %d\\n\", PR_GetError());\n+    failed_already = 1;\n+    goto finish;\n+  }\n+  clientThread = PR_CreateThread(\n+      PR_USER_THREAD, ClientThreadFunc, (void*)PR_ntohs(addr.inet.port),\n+      PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (clientThread == NULL) {\n+    fprintf(stderr, \"Cannot create client thread: (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    failed_already = 1;\n+    goto finish;\n+  }\n+  printf(\"Accepting connection at port %hu\\n\", PR_ntohs(addr.inet.port));\n+  fflush(stdout);\n+  sock = PR_Accept(listenSock, &addr, PR_SecondsToInterval(5));\n+  if (!sock) {\n+    fprintf(stderr, \"PR_Accept failed: error code %d\\n\", PR_GetError());\n+    failed_already = 1;\n+    goto finish;\n+  }\n+  nBytes = PR_Recv(sock, buf, sizeof(buf), 0, PR_INTERVAL_NO_TIMEOUT);\n+  if (nBytes == -1) {\n+    fprintf(stderr, \"PR_Recv failed: error code %d\\n\", PR_GetError());\n+    failed_already = 1;\n+    goto finish;\n+  }\n+\n+  /*\n+   * Make sure it has proper null byte to mark end of string\n+   */\n+\n+  buf[sizeof(buf) - 1] = '\\0';\n+  printf(\"Received \\\"%s\\\" from the client\\n\", buf);\n+  fflush(stdout);\n+  if (!strcmp(buf, message)) {\n+    PR_JoinThread(clientThread);\n+\n+    printf(\"The message is received correctly\\n\");\n     fflush(stdout);\n-    sock = PR_Accept(listenSock, &addr, PR_SecondsToInterval(5));\n-    if (!sock) {\n-        fprintf(stderr, \"PR_Accept failed: error code %d\\n\", PR_GetError());\n-        failed_already = 1;\n-        goto finish;\n-    }\n-    nBytes = PR_Recv(sock, buf, sizeof(buf), 0, PR_INTERVAL_NO_TIMEOUT);\n-    if (nBytes == -1) {\n-        fprintf(stderr, \"PR_Recv failed: error code %d\\n\", PR_GetError());\n-        failed_already = 1;\n-        goto finish;\n-    }\n-\n-    /*\n-     * Make sure it has proper null byte to mark end of string\n-     */\n-\n-    buf[sizeof(buf) - 1] = '\\0';\n-    printf(\"Received \\\"%s\\\" from the client\\n\", buf);\n-    fflush(stdout);\n-    if (!strcmp(buf, message)) {\n-        PR_JoinThread(clientThread);\n-\n-        printf(\"The message is received correctly\\n\");\n-        fflush(stdout);\n-    } else {\n-        fprintf(stderr, \"The message should be \\\"%s\\\"\\n\", message);\n-        failed_already = 1;\n-    }\n+  } else {\n+    fprintf(stderr, \"The message should be \\\"%s\\\"\\n\", message);\n+    failed_already = 1;\n+  }\n \n finish:\n-    if (listenSock) {\n-        PR_Close(listenSock);\n-    }\n-    if (sock) {\n-        PR_Close(sock);\n-    }\n-    return;\n+  if (listenSock) {\n+    PR_Close(listenSock);\n+  }\n+  if (sock) {\n+    PR_Close(sock);\n+  }\n+  return;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    pid_t pid;\n+int main(int argc, char** argv) {\n+  pid_t pid;\n \n-    /* main test program */\n+  /* main test program */\n \n-    DoIO();\n+  DoIO();\n+\n+  pid = fork();\n \n-    pid = fork();\n+  if (pid == (pid_t)-1) {\n+    fprintf(stderr, \"Fork failed: errno %d\\n\", errno);\n+    failed_already = 1;\n+    return 1;\n+  } else if (pid > 0) {\n+    int childStatus;\n \n-    if (pid == (pid_t)-1) {\n-        fprintf(stderr, \"Fork failed: errno %d\\n\", errno);\n+    printf(\"Fork succeeded.  Parent process continues.\\n\");\n+    DoIO();\n+    if (waitpid(pid, &childStatus, 0) != pid) {\n+      {\n+        fprintf(stderr, \"waitpid failed: %d\\n\", errno);\n         failed_already = 1;\n-        return 1;\n-    } else if (pid > 0) {\n-        int childStatus;\n-\n-        printf(\"Fork succeeded.  Parent process continues.\\n\");\n-        DoIO();\n-        if (waitpid(pid, &childStatus, 0) != pid) {\n-            {\n-                fprintf(stderr, \"waitpid failed: %d\\n\", errno);\n-                failed_already = 1;\n-            }\n-        } else if (!WIFEXITED(childStatus) || WEXITSTATUS(childStatus) != 0) {\n-            failed_already = 1;\n-        }\n-        printf(\"Parent process exits.\\n\");\n-        if (!failed_already) {\n-            printf(\"PASSED\\n\");\n-        } else {\n-            printf(\"FAILED\\n\");\n-        }\n-        return failed_already;\n+      }\n+    } else if (!WIFEXITED(childStatus) || WEXITSTATUS(childStatus) != 0) {\n+      failed_already = 1;\n+    }\n+    printf(\"Parent process exits.\\n\");\n+    if (!failed_already) {\n+      printf(\"PASSED\\n\");\n     } else {\n-        printf(\"Fork succeeded.  Child process continues.\\n\");\n-        DoIO();\n-        printf(\"Child process exits.\\n\");\n-        return failed_already;\n+      printf(\"FAILED\\n\");\n     }\n+    return failed_already;\n+  } else {\n+    printf(\"Fork succeeded.  Child process continues.\\n\");\n+    DoIO();\n+    printf(\"Child process exits.\\n\");\n+    return failed_already;\n+  }\n }\n \n #else /* XP_UNIX */\n \n-int\n-main(int argc, char* argv[])\n-{\n-    printf(\"The fork test is applicable to Unix only.\\n\");\n-    return 0;\n+int main(int argc, char* argv[]) {\n+  printf(\"The fork test is applicable to Unix only.\\n\");\n+  return 0;\n }\n \n #endif /* XP_UNIX */\ndiff --git a/nspr/pr/tests/formattm.c b/nspr/pr/tests/formattm.c\nindex 963c9bc..205ae1c 100644\n--- a/nspr/pr/tests/formattm.c\n+++ b/nspr/pr/tests/formattm.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,45 +9,43 @@\n \n #include <stdio.h>\n \n-int\n-main(int argc, char** argv)\n-{\n-    char buffer[256];\n-    char small_buffer[8];\n-    PRTime now;\n-    PRExplodedTime tod;\n-\n-    now = PR_Now();\n-    PR_ExplodeTime(now, PR_LocalTimeParameters, &tod);\n-\n-    if (PR_FormatTime(buffer, sizeof(buffer), \"%a %b %d %H:%M:%S %Z %Y\", &tod) !=\n-        0) {\n-        printf(\"%s\\n\", buffer);\n-    } else {\n-        fprintf(stderr, \"PR_FormatTime(buffer) failed\\n\");\n-        return 1;\n-    }\n+int main(int argc, char** argv) {\n+  char buffer[256];\n+  char small_buffer[8];\n+  PRTime now;\n+  PRExplodedTime tod;\n \n-    small_buffer[0] = '?';\n-    if (PR_FormatTime(small_buffer, sizeof(small_buffer),\n-                      \"%a %b %d %H:%M:%S %Z %Y\", &tod) == 0) {\n-        if (small_buffer[0] != '\\0') {\n-            fprintf(stderr,\n-                    \"PR_FormatTime(small_buffer) did not output \"\n-                    \"an empty string on failure\\n\");\n-            return 1;\n-        }\n-        printf(\"%s\\n\", small_buffer);\n-    } else {\n-        fprintf(stderr,\n-                \"PR_FormatTime(small_buffer) succeeded \"\n-                \"unexpectedly\\n\");\n-        return 1;\n-    }\n+  now = PR_Now();\n+  PR_ExplodeTime(now, PR_LocalTimeParameters, &tod);\n \n-    (void)PR_FormatTimeUSEnglish(buffer, sizeof(buffer),\n-                                 \"%a %b %d %H:%M:%S %Z %Y\", &tod);\n+  if (PR_FormatTime(buffer, sizeof(buffer), \"%a %b %d %H:%M:%S %Z %Y\", &tod) !=\n+      0) {\n     printf(\"%s\\n\", buffer);\n-\n-    return 0;\n+  } else {\n+    fprintf(stderr, \"PR_FormatTime(buffer) failed\\n\");\n+    return 1;\n+  }\n+\n+  small_buffer[0] = '?';\n+  if (PR_FormatTime(small_buffer, sizeof(small_buffer),\n+                    \"%a %b %d %H:%M:%S %Z %Y\", &tod) == 0) {\n+    if (small_buffer[0] != '\\0') {\n+      fprintf(stderr,\n+              \"PR_FormatTime(small_buffer) did not output \"\n+              \"an empty string on failure\\n\");\n+      return 1;\n+    }\n+    printf(\"%s\\n\", small_buffer);\n+  } else {\n+    fprintf(stderr,\n+            \"PR_FormatTime(small_buffer) succeeded \"\n+            \"unexpectedly\\n\");\n+    return 1;\n+  }\n+\n+  (void)PR_FormatTimeUSEnglish(buffer, sizeof(buffer),\n+                               \"%a %b %d %H:%M:%S %Z %Y\", &tod);\n+  printf(\"%s\\n\", buffer);\n+\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/freeif.c b/nspr/pr/tests/freeif.c\nindex 91b38a3..3db3159 100644\n--- a/nspr/pr/tests/freeif.c\n+++ b/nspr/pr/tests/freeif.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -12,38 +13,31 @@\n #include <stdio.h>\n #include <stdlib.h>\n \n-static void\n-Noop(void)\n-{\n-}\n+static void Noop(void) {}\n \n-static void\n-Fail(void)\n-{\n-    printf(\"FAIL\\n\");\n-    exit(1);\n+static void Fail(void) {\n+  printf(\"FAIL\\n\");\n+  exit(1);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    int foo = 1;\n-    char* ptr = NULL;\n-\n-    /* this fails to compile with the old definition of PR_DELETE */\n-    if (foo) {\n-        PR_DELETE(ptr);\n-    } else {\n-        Noop();\n-    }\n-\n-    /* this nests incorrectly with the old definition of PR_FREEIF */\n-    if (foo) {\n-        PR_FREEIF(ptr);\n-    } else {\n-        Fail();\n-    }\n-\n-    printf(\"PASS\\n\");\n-    return 0;\n+int main(int argc, char** argv) {\n+  int foo = 1;\n+  char* ptr = NULL;\n+\n+  /* this fails to compile with the old definition of PR_DELETE */\n+  if (foo) {\n+    PR_DELETE(ptr);\n+  } else {\n+    Noop();\n+  }\n+\n+  /* this nests incorrectly with the old definition of PR_FREEIF */\n+  if (foo) {\n+    PR_FREEIF(ptr);\n+  } else {\n+    Fail();\n+  }\n+\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/fsync.c b/nspr/pr/tests/fsync.c\nindex 608a755..60986d7 100644\n--- a/nspr/pr/tests/fsync.c\n+++ b/nspr/pr/tests/fsync.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -12,109 +13,105 @@\n \n static PRFileDesc* err = NULL;\n \n-static void\n-Help(void)\n-{\n-    PR_fprintf(err, \"Usage: [-S] [-K <n>] [-h] <filename>\\n\");\n-    PR_fprintf(err, \"\\t-c   Nuber of iterations     (default: 10)\\n\");\n-    PR_fprintf(err, \"\\t-S   Sync the file           (default: FALSE)\\n\");\n-    PR_fprintf(err, \"\\t-K   Size of file (K bytes)  (default: 10)\\n\");\n-    PR_fprintf(err, \"\\t     Name of file to write   (default: ./tmp-sync.dat)\\n\");\n-    PR_fprintf(err, \"\\t-h   This message and nothing else\\n\");\n+static void Help(void) {\n+  PR_fprintf(err, \"Usage: [-S] [-K <n>] [-h] <filename>\\n\");\n+  PR_fprintf(err, \"\\t-c   Nuber of iterations     (default: 10)\\n\");\n+  PR_fprintf(err, \"\\t-S   Sync the file           (default: FALSE)\\n\");\n+  PR_fprintf(err, \"\\t-K   Size of file (K bytes)  (default: 10)\\n\");\n+  PR_fprintf(err, \"\\t     Name of file to write   (default: ./tmp-sync.dat)\\n\");\n+  PR_fprintf(err, \"\\t-h   This message and nothing else\\n\");\n } /* Help */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRStatus rv;\n-    PLOptStatus os;\n-    PRUint8* buffer;\n-    PRFileDesc* file = NULL;\n-    const char* filename = \"sync.dat\";\n-    PRUint32 index, loops, iterations = 10, filesize = 10;\n-    PRIntn flags = PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"hSK:c:\");\n-    PRIntervalTime time, total = 0, shortest = 0x7fffffff, longest = 0;\n+int main(int argc, char** argv) {\n+  PRStatus rv;\n+  PLOptStatus os;\n+  PRUint8* buffer;\n+  PRFileDesc* file = NULL;\n+  const char* filename = \"sync.dat\";\n+  PRUint32 index, loops, iterations = 10, filesize = 10;\n+  PRIntn flags = PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"hSK:c:\");\n+  PRIntervalTime time, total = 0, shortest = 0x7fffffff, longest = 0;\n \n-    err = PR_GetSpecialFD(PR_StandardError);\n+  err = PR_GetSpecialFD(PR_StandardError);\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 0: /* Name of file to create */\n-                filename = opt->value;\n-                break;\n-            case 'S': /* Use sych option on file */\n-                flags |= PR_SYNC;\n-                break;\n-            case 'K': /* Size of file to write */\n-                filesize = atoi(opt->value);\n-                break;\n-            case 'c': /* Number of iterations */\n-                iterations = atoi(opt->value);\n-                break;\n-            case 'h':     /* user wants some guidance */\n-            default:      /* user needs some guidance */\n-                Help();   /* so give him an earful */\n-                return 2; /* but not a lot else */\n-        }\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    file = PR_Open(filename, flags, 0666);\n-    if (NULL == file) {\n-        PL_FPrintError(err, \"Failed to open file\");\n-        return 1;\n+    switch (opt->option) {\n+      case 0: /* Name of file to create */\n+        filename = opt->value;\n+        break;\n+      case 'S': /* Use sych option on file */\n+        flags |= PR_SYNC;\n+        break;\n+      case 'K': /* Size of file to write */\n+        filesize = atoi(opt->value);\n+        break;\n+      case 'c': /* Number of iterations */\n+        iterations = atoi(opt->value);\n+        break;\n+      case 'h':   /* user wants some guidance */\n+      default:    /* user needs some guidance */\n+        Help();   /* so give him an earful */\n+        return 2; /* but not a lot else */\n     }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    buffer = (PRUint8*)PR_CALLOC(1024);\n-    if (NULL == buffer) {\n-        PL_FPrintError(err, \"Cannot allocate buffer\");\n-        return 1;\n-    }\n+  file = PR_Open(filename, flags, 0666);\n+  if (NULL == file) {\n+    PL_FPrintError(err, \"Failed to open file\");\n+    return 1;\n+  }\n \n-    for (index = 0; index < sizeof(buffer); ++index) {\n-        buffer[index] = (PRUint8)index;\n-    }\n+  buffer = (PRUint8*)PR_CALLOC(1024);\n+  if (NULL == buffer) {\n+    PL_FPrintError(err, \"Cannot allocate buffer\");\n+    return 1;\n+  }\n \n-    for (loops = 0; loops < iterations; ++loops) {\n-        time = PR_IntervalNow();\n-        for (index = 0; index < filesize; ++index) {\n-            PR_Write(file, buffer, 1024);\n-        }\n-        time = (PR_IntervalNow() - time);\n+  for (index = 0; index < sizeof(buffer); ++index) {\n+    buffer[index] = (PRUint8)index;\n+  }\n \n-        total += time;\n-        if (time < shortest) {\n-            shortest = time;\n-        } else if (time > longest) {\n-            longest = time;\n-        }\n-        if (0 != PR_Seek(file, 0, PR_SEEK_SET)) {\n-            PL_FPrintError(err, \"Rewinding file\");\n-            return 1;\n-        }\n+  for (loops = 0; loops < iterations; ++loops) {\n+    time = PR_IntervalNow();\n+    for (index = 0; index < filesize; ++index) {\n+      PR_Write(file, buffer, 1024);\n     }\n+    time = (PR_IntervalNow() - time);\n \n-    total = total / iterations;\n-    PR_fprintf(err, \"%u iterations over a %u kbyte %sfile: %u [%u] %u\\n\",\n-               iterations, filesize, ((flags & PR_SYNC) ? \"SYNCH'd \" : \"\"),\n-               PR_IntervalToMicroseconds(shortest),\n-               PR_IntervalToMicroseconds(total),\n-               PR_IntervalToMicroseconds(longest));\n-\n-    PR_DELETE(buffer);\n-    rv = PR_Close(file);\n-    if (PR_SUCCESS != rv) {\n-        PL_FPrintError(err, \"Closing file failed\");\n-        return 1;\n+    total += time;\n+    if (time < shortest) {\n+      shortest = time;\n+    } else if (time > longest) {\n+      longest = time;\n     }\n-    rv = PR_Delete(filename);\n-    if (PR_SUCCESS != rv) {\n-        PL_FPrintError(err, \"Deleting file failed\");\n-        return 1;\n+    if (0 != PR_Seek(file, 0, PR_SEEK_SET)) {\n+      PL_FPrintError(err, \"Rewinding file\");\n+      return 1;\n     }\n-    return 0;\n+  }\n+\n+  total = total / iterations;\n+  PR_fprintf(err, \"%u iterations over a %u kbyte %sfile: %u [%u] %u\\n\",\n+             iterations, filesize, ((flags & PR_SYNC) ? \"SYNCH'd \" : \"\"),\n+             PR_IntervalToMicroseconds(shortest),\n+             PR_IntervalToMicroseconds(total),\n+             PR_IntervalToMicroseconds(longest));\n+\n+  PR_DELETE(buffer);\n+  rv = PR_Close(file);\n+  if (PR_SUCCESS != rv) {\n+    PL_FPrintError(err, \"Closing file failed\");\n+    return 1;\n+  }\n+  rv = PR_Delete(filename);\n+  if (PR_SUCCESS != rv) {\n+    PL_FPrintError(err, \"Deleting file failed\");\n+    return 1;\n+  }\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/getai.c b/nspr/pr/tests/getai.c\nindex 5365fd6..edd8e27 100644\n--- a/nspr/pr/tests/getai.c\n+++ b/nspr/pr/tests/getai.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,26 +8,24 @@\n #include <stdio.h>\n #include <stdlib.h>\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRAddrInfo* ai;\n-    void* iter;\n-    PRNetAddr addr;\n+int main(int argc, char** argv) {\n+  PRAddrInfo* ai;\n+  void* iter;\n+  PRNetAddr addr;\n \n-    ai = PR_GetAddrInfoByName(argv[1], PR_AF_UNSPEC, PR_AI_ADDRCONFIG);\n-    if (ai == NULL) {\n-        fprintf(stderr, \"PR_GetAddrInfoByName failed: (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    printf(\"%s\\n\", PR_GetCanonNameFromAddrInfo(ai));\n-    iter = NULL;\n-    while ((iter = PR_EnumerateAddrInfo(iter, ai, 0, &addr)) != NULL) {\n-        char buf[128];\n-        PR_NetAddrToString(&addr, buf, sizeof buf);\n-        printf(\"%s\\n\", buf);\n-    }\n-    PR_FreeAddrInfo(ai);\n-    return 0;\n+  ai = PR_GetAddrInfoByName(argv[1], PR_AF_UNSPEC, PR_AI_ADDRCONFIG);\n+  if (ai == NULL) {\n+    fprintf(stderr, \"PR_GetAddrInfoByName failed: (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  printf(\"%s\\n\", PR_GetCanonNameFromAddrInfo(ai));\n+  iter = NULL;\n+  while ((iter = PR_EnumerateAddrInfo(iter, ai, 0, &addr)) != NULL) {\n+    char buf[128];\n+    PR_NetAddrToString(&addr, buf, sizeof buf);\n+    printf(\"%s\\n\", buf);\n+  }\n+  PR_FreeAddrInfo(ai);\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/gethost.c b/nspr/pr/tests/gethost.c\nindex b3cae5e..ef48d32 100644\n--- a/nspr/pr/tests/gethost.c\n+++ b/nspr/pr/tests/gethost.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -19,251 +20,245 @@\n \n #define DEFAULT_HOST_NAME \"mozilla.org\"\n \n-static void\n-Help(void)\n-{\n-    fprintf(stderr, \"Usage: gethost [-h] [hostname]\\n\");\n-    fprintf(stderr, \"\\t-h          help\\n\");\n-    fprintf(stderr, \"\\thostname    Name of host    (default: %s)\\n\",\n-            DEFAULT_HOST_NAME);\n+static void Help(void) {\n+  fprintf(stderr, \"Usage: gethost [-h] [hostname]\\n\");\n+  fprintf(stderr, \"\\t-h          help\\n\");\n+  fprintf(stderr, \"\\thostname    Name of host    (default: %s)\\n\",\n+          DEFAULT_HOST_NAME);\n } /* Help */\n \n /*\n  * Prints the contents of a PRHostEnt structure\n  */\n-void\n-PrintHostent(const PRHostEnt* he)\n-{\n-    int i;\n-    int j;\n+void PrintHostent(const PRHostEnt* he) {\n+  int i;\n+  int j;\n \n-    printf(\"h_name: %s\\n\", he->h_name);\n-    for (i = 0; he->h_aliases[i]; i++) {\n-        printf(\"h_aliases[%d]: %s\\n\", i, he->h_aliases[i]);\n-    }\n-    printf(\"h_addrtype: %d\\n\", he->h_addrtype);\n-    printf(\"h_length: %d\\n\", he->h_length);\n-    for (i = 0; he->h_addr_list[i]; i++) {\n-        printf(\"h_addr_list[%d]: \", i);\n-        for (j = 0; j < he->h_length; j++) {\n-            if (j != 0) {\n-                printf(\".\");\n-            }\n-            printf(\"%u\", (unsigned char)he->h_addr_list[i][j]);\n-        }\n-        printf(\"\\n\");\n-    }\n+  printf(\"h_name: %s\\n\", he->h_name);\n+  for (i = 0; he->h_aliases[i]; i++) {\n+    printf(\"h_aliases[%d]: %s\\n\", i, he->h_aliases[i]);\n+  }\n+  printf(\"h_addrtype: %d\\n\", he->h_addrtype);\n+  printf(\"h_length: %d\\n\", he->h_length);\n+  for (i = 0; he->h_addr_list[i]; i++) {\n+    printf(\"h_addr_list[%d]: \", i);\n+    for (j = 0; j < he->h_length; j++) {\n+      if (j != 0) {\n+        printf(\".\");\n+      }\n+      printf(\"%u\", (unsigned char)he->h_addr_list[i][j]);\n+    }\n+    printf(\"\\n\");\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    const char* hostName = DEFAULT_HOST_NAME;\n-    PRHostEnt he, reversehe;\n-    char buf[PR_NETDB_BUF_SIZE];\n-    char reversebuf[PR_NETDB_BUF_SIZE];\n-    PRIntn idx;\n-    PRNetAddr addr;\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"h\");\n+int main(int argc, char** argv) {\n+  const char* hostName = DEFAULT_HOST_NAME;\n+  PRHostEnt he, reversehe;\n+  char buf[PR_NETDB_BUF_SIZE];\n+  char reversebuf[PR_NETDB_BUF_SIZE];\n+  PRIntn idx;\n+  PRNetAddr addr;\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"h\");\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 0: /* naked */\n-                hostName = opt->value;\n-                break;\n-            case 'h': /* Help message */\n-            default:\n-                Help();\n-                return 2;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 0: /* naked */\n+        hostName = opt->value;\n+        break;\n+      case 'h': /* Help message */\n+      default:\n+        Help();\n+        return 2;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    if (PR_GetHostByName(hostName, buf, sizeof(buf), &he) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetHostByName failed\\n\");\n-        exit(1);\n-    }\n-    PrintHostent(&he);\n-    idx = 0;\n-    while (1) {\n-        idx = PR_EnumerateHostEnt(idx, &he, 0, &addr);\n-        if (idx == -1) {\n-            fprintf(stderr, \"PR_EnumerateHostEnt failed\\n\");\n-            exit(1);\n-        }\n-        if (idx == 0) {\n-            break; /* normal loop termination */\n-        }\n-        printf(\"reverse lookup\\n\");\n-        if (PR_GetHostByAddr(&addr, reversebuf, sizeof(reversebuf), &reversehe) ==\n-            PR_FAILURE) {\n-            fprintf(stderr, \"PR_GetHostByAddr failed\\n\");\n-            exit(1);\n-        }\n-        PrintHostent(&reversehe);\n-    }\n+  if (PR_GetHostByName(hostName, buf, sizeof(buf), &he) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetHostByName failed\\n\");\n+    exit(1);\n+  }\n+  PrintHostent(&he);\n+  idx = 0;\n+  while (1) {\n+    idx = PR_EnumerateHostEnt(idx, &he, 0, &addr);\n+    if (idx == -1) {\n+      fprintf(stderr, \"PR_EnumerateHostEnt failed\\n\");\n+      exit(1);\n+    }\n+    if (idx == 0) {\n+      break; /* normal loop termination */\n+    }\n+    printf(\"reverse lookup\\n\");\n+    if (PR_GetHostByAddr(&addr, reversebuf, sizeof(reversebuf), &reversehe) ==\n+        PR_FAILURE) {\n+      fprintf(stderr, \"PR_GetHostByAddr failed\\n\");\n+      exit(1);\n+    }\n+    PrintHostent(&reversehe);\n+  }\n \n-    printf(\"PR_GetIPNodeByName with PR_AF_INET\\n\");\n-    if (PR_GetIPNodeByName(hostName, PR_AF_INET, PR_AI_DEFAULT, buf, sizeof(buf),\n-                           &he) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetIPNodeByName failed\\n\");\n-        exit(1);\n-    }\n-    PrintHostent(&he);\n-    printf(\"PR_GetIPNodeByName with PR_AF_INET6\\n\");\n-    if (PR_GetIPNodeByName(hostName, PR_AF_INET6, PR_AI_DEFAULT, buf, sizeof(buf),\n-                           &he) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetIPNodeByName failed\\n\");\n-        exit(1);\n-    }\n-    PrintHostent(&he);\n-    idx = 0;\n-    printf(\"PR_GetHostByAddr with PR_AF_INET6\\n\");\n-    while (1) {\n-        idx = PR_EnumerateHostEnt(idx, &he, 0, &addr);\n-        if (idx == -1) {\n-            fprintf(stderr, \"PR_EnumerateHostEnt failed\\n\");\n-            exit(1);\n-        }\n-        if (idx == 0) {\n-            break; /* normal loop termination */\n-        }\n-        printf(\"reverse lookup\\n\");\n-        if (PR_GetHostByAddr(&addr, reversebuf, sizeof(reversebuf), &reversehe) ==\n-            PR_FAILURE) {\n-            fprintf(stderr, \"PR_GetHostByAddr failed\\n\");\n-            exit(1);\n-        }\n-        PrintHostent(&reversehe);\n-    }\n-    printf(\"PR_GetHostByAddr with PR_AF_INET6 done\\n\");\n+  printf(\"PR_GetIPNodeByName with PR_AF_INET\\n\");\n+  if (PR_GetIPNodeByName(hostName, PR_AF_INET, PR_AI_DEFAULT, buf, sizeof(buf),\n+                         &he) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetIPNodeByName failed\\n\");\n+    exit(1);\n+  }\n+  PrintHostent(&he);\n+  printf(\"PR_GetIPNodeByName with PR_AF_INET6\\n\");\n+  if (PR_GetIPNodeByName(hostName, PR_AF_INET6, PR_AI_DEFAULT, buf, sizeof(buf),\n+                         &he) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetIPNodeByName failed\\n\");\n+    exit(1);\n+  }\n+  PrintHostent(&he);\n+  idx = 0;\n+  printf(\"PR_GetHostByAddr with PR_AF_INET6\\n\");\n+  while (1) {\n+    idx = PR_EnumerateHostEnt(idx, &he, 0, &addr);\n+    if (idx == -1) {\n+      fprintf(stderr, \"PR_EnumerateHostEnt failed\\n\");\n+      exit(1);\n+    }\n+    if (idx == 0) {\n+      break; /* normal loop termination */\n+    }\n+    printf(\"reverse lookup\\n\");\n+    if (PR_GetHostByAddr(&addr, reversebuf, sizeof(reversebuf), &reversehe) ==\n+        PR_FAILURE) {\n+      fprintf(stderr, \"PR_GetHostByAddr failed\\n\");\n+      exit(1);\n+    }\n+    PrintHostent(&reversehe);\n+  }\n+  printf(\"PR_GetHostByAddr with PR_AF_INET6 done\\n\");\n \n-    PR_StringToNetAddr(\"::1\", &addr);\n-    if (PR_IsNetAddrType(&addr, PR_IpAddrV4Mapped) == PR_TRUE) {\n-        fprintf(stderr, \"addr should not be ipv4 mapped address\\n\");\n-        exit(1);\n-    }\n-    if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n-        fprintf(stderr, \"addr should be loopback address\\n\");\n-        exit(1);\n-    }\n+  PR_StringToNetAddr(\"::1\", &addr);\n+  if (PR_IsNetAddrType(&addr, PR_IpAddrV4Mapped) == PR_TRUE) {\n+    fprintf(stderr, \"addr should not be ipv4 mapped address\\n\");\n+    exit(1);\n+  }\n+  if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n+    fprintf(stderr, \"addr should be loopback address\\n\");\n+    exit(1);\n+  }\n \n-    PR_StringToNetAddr(\"127.0.0.1\", &addr);\n-    if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n-        fprintf(stderr, \"addr should be loopback address\\n\");\n-        exit(1);\n-    }\n-    PR_StringToNetAddr(\"::FFFF:127.0.0.1\", &addr);\n-    if (PR_IsNetAddrType(&addr, PR_IpAddrV4Mapped) == PR_FALSE) {\n-        fprintf(stderr, \"addr should be ipv4 mapped address\\n\");\n-        exit(1);\n-    }\n-    if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n-        fprintf(stderr, \"addr should be loopback address\\n\");\n-        exit(1);\n-    }\n+  PR_StringToNetAddr(\"127.0.0.1\", &addr);\n+  if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n+    fprintf(stderr, \"addr should be loopback address\\n\");\n+    exit(1);\n+  }\n+  PR_StringToNetAddr(\"::FFFF:127.0.0.1\", &addr);\n+  if (PR_IsNetAddrType(&addr, PR_IpAddrV4Mapped) == PR_FALSE) {\n+    fprintf(stderr, \"addr should be ipv4 mapped address\\n\");\n+    exit(1);\n+  }\n+  if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n+    fprintf(stderr, \"addr should be loopback address\\n\");\n+    exit(1);\n+  }\n \n-    if (PR_InitializeNetAddr(PR_IpAddrAny, 0, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_IsNetAddrType(&addr, PR_IpAddrAny) == PR_FALSE) {\n-        fprintf(stderr, \"addr should be unspecified address\\n\");\n-        exit(1);\n-    }\n-    if (PR_InitializeNetAddr(PR_IpAddrLoopback, 0, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n-        fprintf(stderr, \"addr should be loopback address\\n\");\n-        exit(1);\n-    }\n+  if (PR_InitializeNetAddr(PR_IpAddrAny, 0, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_IsNetAddrType(&addr, PR_IpAddrAny) == PR_FALSE) {\n+    fprintf(stderr, \"addr should be unspecified address\\n\");\n+    exit(1);\n+  }\n+  if (PR_InitializeNetAddr(PR_IpAddrLoopback, 0, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n+    fprintf(stderr, \"addr should be loopback address\\n\");\n+    exit(1);\n+  }\n \n-    if (PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET, 0, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_IsNetAddrType(&addr, PR_IpAddrAny) == PR_FALSE) {\n-        fprintf(stderr, \"addr should be unspecified address\\n\");\n-        exit(1);\n-    }\n-    if (PR_SetNetAddr(PR_IpAddrLoopback, PR_AF_INET, 0, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n-        fprintf(stderr, \"addr should be loopback address\\n\");\n-        exit(1);\n-    }\n+  if (PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET, 0, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_IsNetAddrType(&addr, PR_IpAddrAny) == PR_FALSE) {\n+    fprintf(stderr, \"addr should be unspecified address\\n\");\n+    exit(1);\n+  }\n+  if (PR_SetNetAddr(PR_IpAddrLoopback, PR_AF_INET, 0, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n+    fprintf(stderr, \"addr should be loopback address\\n\");\n+    exit(1);\n+  }\n \n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.port = 0;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    if (PR_IsNetAddrType(&addr, PR_IpAddrAny) == PR_FALSE) {\n-        fprintf(stderr, \"addr should be unspecified address\\n\");\n-        exit(1);\n-    }\n-    {\n-        char buf[256];\n-        PR_NetAddrToString(&addr, buf, 256);\n-        printf(\"IPv4 INADDRANY: %s\\n\", buf);\n-    }\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.port = 0;\n-    addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n-    if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n-        fprintf(stderr, \"addr should be loopback address\\n\");\n-        exit(1);\n-    }\n-    {\n-        char buf[256];\n-        PR_NetAddrToString(&addr, buf, 256);\n-        printf(\"IPv4 LOOPBACK: %s\\n\", buf);\n-    }\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.port = 0;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  if (PR_IsNetAddrType(&addr, PR_IpAddrAny) == PR_FALSE) {\n+    fprintf(stderr, \"addr should be unspecified address\\n\");\n+    exit(1);\n+  }\n+  {\n+    char buf[256];\n+    PR_NetAddrToString(&addr, buf, 256);\n+    printf(\"IPv4 INADDRANY: %s\\n\", buf);\n+  }\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.port = 0;\n+  addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n+  if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n+    fprintf(stderr, \"addr should be loopback address\\n\");\n+    exit(1);\n+  }\n+  {\n+    char buf[256];\n+    PR_NetAddrToString(&addr, buf, 256);\n+    printf(\"IPv4 LOOPBACK: %s\\n\", buf);\n+  }\n \n-    if (PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, 0, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_IsNetAddrType(&addr, PR_IpAddrAny) == PR_FALSE) {\n-        fprintf(stderr, \"addr should be unspecified address\\n\");\n-        exit(1);\n-    }\n-    {\n-        char buf[256];\n-        PR_NetAddrToString(&addr, buf, 256);\n-        printf(\"IPv6 INADDRANY: %s\\n\", buf);\n-    }\n-    if (PR_SetNetAddr(PR_IpAddrLoopback, PR_AF_INET6, 0, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n-        fprintf(stderr, \"addr should be loopback address\\n\");\n-        exit(1);\n-    }\n-    {\n-        char buf[256];\n-        PR_NetAddrToString(&addr, buf, 256);\n-        printf(\"IPv6 LOOPBACK: %s\\n\", buf);\n-    }\n-    {\n-        PRIPv6Addr v6addr;\n-        char tmp_buf[256];\n+  if (PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, 0, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_IsNetAddrType(&addr, PR_IpAddrAny) == PR_FALSE) {\n+    fprintf(stderr, \"addr should be unspecified address\\n\");\n+    exit(1);\n+  }\n+  {\n+    char buf[256];\n+    PR_NetAddrToString(&addr, buf, 256);\n+    printf(\"IPv6 INADDRANY: %s\\n\", buf);\n+  }\n+  if (PR_SetNetAddr(PR_IpAddrLoopback, PR_AF_INET6, 0, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_IsNetAddrType(&addr, PR_IpAddrLoopback) == PR_FALSE) {\n+    fprintf(stderr, \"addr should be loopback address\\n\");\n+    exit(1);\n+  }\n+  {\n+    char buf[256];\n+    PR_NetAddrToString(&addr, buf, 256);\n+    printf(\"IPv6 LOOPBACK: %s\\n\", buf);\n+  }\n+  {\n+    PRIPv6Addr v6addr;\n+    char tmp_buf[256];\n \n-        PR_SetNetAddr(PR_IpAddrLoopback, PR_AF_INET, 0, &addr);\n+    PR_SetNetAddr(PR_IpAddrLoopback, PR_AF_INET, 0, &addr);\n \n-        PR_ConvertIPv4AddrToIPv6(addr.inet.ip, &v6addr);\n-        PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, 0, &addr);\n-        addr.ipv6.ip = v6addr;\n-        PR_NetAddrToString(&addr, tmp_buf, 256);\n-        printf(\"IPv4-mapped IPv6 LOOPBACK: %s\\n\", tmp_buf);\n-    }\n-    printf(\"PASS\\n\");\n-    return 0;\n+    PR_ConvertIPv4AddrToIPv6(addr.inet.ip, &v6addr);\n+    PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, 0, &addr);\n+    addr.ipv6.ip = v6addr;\n+    PR_NetAddrToString(&addr, tmp_buf, 256);\n+    printf(\"IPv4-mapped IPv6 LOOPBACK: %s\\n\", tmp_buf);\n+  }\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/getproto.c b/nspr/pr/tests/getproto.c\nindex 480d5d0..0318799 100644\n--- a/nspr/pr/tests/getproto.c\n+++ b/nspr/pr/tests/getproto.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -19,63 +20,61 @@\n #include \"prnetdb.h\"\n #include \"prerror.h\"\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc* prstderr = PR_GetSpecialFD(PR_StandardError);\n-    PRBool failed = PR_FALSE;\n-    PRProtoEnt proto;\n-    char buf[2048];\n-    PRStatus rv;\n+int main(int argc, char** argv) {\n+  PRFileDesc* prstderr = PR_GetSpecialFD(PR_StandardError);\n+  PRBool failed = PR_FALSE;\n+  PRProtoEnt proto;\n+  char buf[2048];\n+  PRStatus rv;\n \n-    rv = PR_GetProtoByName(\"tcp\", buf, sizeof(buf), &proto);\n-    if (PR_FAILURE == rv) {\n-        failed = PR_TRUE;\n-        PL_FPrintError(prstderr, \"PR_GetProtoByName failed\");\n-    } else if (6 != proto.p_num) {\n-        PR_fprintf(prstderr, \"tcp is usually 6, but is %d on this machine\\n\",\n-                   proto.p_num);\n-    } else {\n-        PR_fprintf(prstderr, \"tcp is protocol number %d\\n\", proto.p_num);\n-    }\n+  rv = PR_GetProtoByName(\"tcp\", buf, sizeof(buf), &proto);\n+  if (PR_FAILURE == rv) {\n+    failed = PR_TRUE;\n+    PL_FPrintError(prstderr, \"PR_GetProtoByName failed\");\n+  } else if (6 != proto.p_num) {\n+    PR_fprintf(prstderr, \"tcp is usually 6, but is %d on this machine\\n\",\n+               proto.p_num);\n+  } else {\n+    PR_fprintf(prstderr, \"tcp is protocol number %d\\n\", proto.p_num);\n+  }\n \n-    rv = PR_GetProtoByName(\"udp\", buf, sizeof(buf), &proto);\n-    if (PR_FAILURE == rv) {\n-        failed = PR_TRUE;\n-        PL_FPrintError(prstderr, \"PR_GetProtoByName failed\");\n-    } else if (17 != proto.p_num) {\n-        PR_fprintf(prstderr, \"udp is usually 17, but is %d on this machine\\n\",\n-                   proto.p_num);\n-    } else {\n-        PR_fprintf(prstderr, \"udp is protocol number %d\\n\", proto.p_num);\n-    }\n+  rv = PR_GetProtoByName(\"udp\", buf, sizeof(buf), &proto);\n+  if (PR_FAILURE == rv) {\n+    failed = PR_TRUE;\n+    PL_FPrintError(prstderr, \"PR_GetProtoByName failed\");\n+  } else if (17 != proto.p_num) {\n+    PR_fprintf(prstderr, \"udp is usually 17, but is %d on this machine\\n\",\n+               proto.p_num);\n+  } else {\n+    PR_fprintf(prstderr, \"udp is protocol number %d\\n\", proto.p_num);\n+  }\n \n-    rv = PR_GetProtoByNumber(6, buf, sizeof(buf), &proto);\n-    if (PR_FAILURE == rv) {\n-        failed = PR_TRUE;\n-        PL_FPrintError(prstderr, \"PR_GetProtoByNumber failed\");\n-    } else if (PL_strcmp(\"tcp\", proto.p_name)) {\n-        PR_fprintf(prstderr,\n-                   \"Protocol number 6 is usually tcp, but is %s\"\n-                   \" on this platform\\n\",\n-                   proto.p_name);\n-    } else {\n-        PR_fprintf(prstderr, \"Protocol number 6 is %s\\n\", proto.p_name);\n-    }\n+  rv = PR_GetProtoByNumber(6, buf, sizeof(buf), &proto);\n+  if (PR_FAILURE == rv) {\n+    failed = PR_TRUE;\n+    PL_FPrintError(prstderr, \"PR_GetProtoByNumber failed\");\n+  } else if (PL_strcmp(\"tcp\", proto.p_name)) {\n+    PR_fprintf(prstderr,\n+               \"Protocol number 6 is usually tcp, but is %s\"\n+               \" on this platform\\n\",\n+               proto.p_name);\n+  } else {\n+    PR_fprintf(prstderr, \"Protocol number 6 is %s\\n\", proto.p_name);\n+  }\n \n-    rv = PR_GetProtoByNumber(17, buf, sizeof(buf), &proto);\n-    if (PR_FAILURE == rv) {\n-        failed = PR_TRUE;\n-        PL_FPrintError(prstderr, \"PR_GetProtoByNumber failed\");\n-    } else if (PL_strcmp(\"udp\", proto.p_name)) {\n-        PR_fprintf(prstderr,\n-                   \"Protocol number 17 is usually udp, but is %s\"\n-                   \" on this platform\\n\",\n-                   proto.p_name);\n-    } else {\n-        PR_fprintf(prstderr, \"Protocol number 17 is %s\\n\", proto.p_name);\n-    }\n+  rv = PR_GetProtoByNumber(17, buf, sizeof(buf), &proto);\n+  if (PR_FAILURE == rv) {\n+    failed = PR_TRUE;\n+    PL_FPrintError(prstderr, \"PR_GetProtoByNumber failed\");\n+  } else if (PL_strcmp(\"udp\", proto.p_name)) {\n+    PR_fprintf(prstderr,\n+               \"Protocol number 17 is usually udp, but is %s\"\n+               \" on this platform\\n\",\n+               proto.p_name);\n+  } else {\n+    PR_fprintf(prstderr, \"Protocol number 17 is %s\\n\", proto.p_name);\n+  }\n \n-    PR_fprintf(prstderr, (failed) ? \"FAILED\\n\" : \"PASSED\\n\");\n-    return (failed) ? 1 : 0;\n+  PR_fprintf(prstderr, (failed) ? \"FAILED\\n\" : \"PASSED\\n\");\n+  return (failed) ? 1 : 0;\n }\ndiff --git a/nspr/pr/tests/i2l.c b/nspr/pr/tests/i2l.c\nindex 204f81c..dbc1b90 100644\n--- a/nspr/pr/tests/i2l.c\n+++ b/nspr/pr/tests/i2l.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -13,85 +14,79 @@\n #include \"plgetopt.h\"\n \n typedef union Overlay_i {\n-    PRInt32 i;\n-    PRInt64 l;\n+  PRInt32 i;\n+  PRInt64 l;\n } Overlay_i;\n \n typedef union Overlay_u {\n-    PRUint32 i;\n-    PRUint64 l;\n+  PRUint32 i;\n+  PRUint64 l;\n } Overlay_u;\n \n static PRFileDesc* err = NULL;\n \n-static void\n-Help(void)\n-{\n-    PR_fprintf(err, \"Usage: -i n | -u n | -h\\n\");\n-    PR_fprintf(err, \"\\t-i n treat following number as signed integer\\n\");\n-    PR_fprintf(err, \"\\t-u n treat following number as unsigned integer\\n\");\n-    PR_fprintf(err, \"\\t-h   This message and nothing else\\n\");\n+static void Help(void) {\n+  PR_fprintf(err, \"Usage: -i n | -u n | -h\\n\");\n+  PR_fprintf(err, \"\\t-i n treat following number as signed integer\\n\");\n+  PR_fprintf(err, \"\\t-u n treat following number as unsigned integer\\n\");\n+  PR_fprintf(err, \"\\t-h   This message and nothing else\\n\");\n } /* Help */\n \n-static PRIntn PR_CALLBACK\n-RealMain(PRIntn argc, char** argv)\n-{\n-    Overlay_i si;\n-    Overlay_u ui;\n-    PLOptStatus os;\n-    PRBool bsi = PR_FALSE, bui = PR_FALSE;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"hi:u:\");\n-    err = PR_GetSpecialFD(PR_StandardError);\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'i': /* signed integer */\n-                si.i = (PRInt32)atoi(opt->value);\n-                bsi = PR_TRUE;\n-                break;\n-            case 'u': /* unsigned */\n-                ui.i = (PRUint32)atoi(opt->value);\n-                bui = PR_TRUE;\n-                break;\n-            case 'h': /* user wants some guidance */\n-            default:\n-                Help();   /* so give him an earful */\n-                return 2; /* but not a lot else */\n-        }\n+static PRIntn PR_CALLBACK RealMain(PRIntn argc, char** argv) {\n+  Overlay_i si;\n+  Overlay_u ui;\n+  PLOptStatus os;\n+  PRBool bsi = PR_FALSE, bui = PR_FALSE;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"hi:u:\");\n+  err = PR_GetSpecialFD(PR_StandardError);\n+\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n+    switch (opt->option) {\n+      case 'i': /* signed integer */\n+        si.i = (PRInt32)atoi(opt->value);\n+        bsi = PR_TRUE;\n+        break;\n+      case 'u': /* unsigned */\n+        ui.i = (PRUint32)atoi(opt->value);\n+        bui = PR_TRUE;\n+        break;\n+      case 'h': /* user wants some guidance */\n+      default:\n+        Help();   /* so give him an earful */\n+        return 2; /* but not a lot else */\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n #if defined(HAVE_LONG_LONG)\n-    PR_fprintf(err, \"We have long long\\n\");\n+  PR_fprintf(err, \"We have long long\\n\");\n #else\n-    PR_fprintf(err, \"We don't have long long\\n\");\n+  PR_fprintf(err, \"We don't have long long\\n\");\n #endif\n \n-    if (bsi) {\n-        PR_fprintf(err, \"Converting %ld: \", si.i);\n-        LL_I2L(si.l, si.i);\n-        PR_fprintf(err, \"%lld\\n\", si.l);\n-    }\n+  if (bsi) {\n+    PR_fprintf(err, \"Converting %ld: \", si.i);\n+    LL_I2L(si.l, si.i);\n+    PR_fprintf(err, \"%lld\\n\", si.l);\n+  }\n \n-    if (bui) {\n-        PR_fprintf(err, \"Converting %lu: \", ui.i);\n-        LL_I2L(ui.l, ui.i);\n-        PR_fprintf(err, \"%llu\\n\", ui.l);\n-    }\n-    return 0;\n+  if (bui) {\n+    PR_fprintf(err, \"Converting %lu: \", ui.i);\n+    LL_I2L(ui.l, ui.i);\n+    PR_fprintf(err, \"%llu\\n\", ui.l);\n+  }\n+  return 0;\n \n } /* main */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv;\n+int main(int argc, char** argv) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\n \n /* i2l.c */\ndiff --git a/nspr/pr/tests/initclk.c b/nspr/pr/tests/initclk.c\nindex cb27020..6ab49f7 100644\n--- a/nspr/pr/tests/initclk.c\n+++ b/nspr/pr/tests/initclk.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -25,48 +26,44 @@\n PRLock *lock1, *lock2;\n PRCondVar *cv1, *cv2;\n \n-void\n-ThreadFunc(void* arg)\n-{\n-    PR_Lock(lock1);\n-    PR_WaitCondVar(cv1, PR_MillisecondsToInterval(SHORT_TIMEOUT));\n-    PR_Unlock(lock1);\n+void ThreadFunc(void* arg) {\n+  PR_Lock(lock1);\n+  PR_WaitCondVar(cv1, PR_MillisecondsToInterval(SHORT_TIMEOUT));\n+  PR_Unlock(lock1);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRThread* thread;\n-    PRIntervalTime start, end;\n-    PRUint32 elapsed_ms;\n+int main(int argc, char** argv) {\n+  PRThread* thread;\n+  PRIntervalTime start, end;\n+  PRUint32 elapsed_ms;\n \n-    lock1 = PR_NewLock();\n-    PR_ASSERT(NULL != lock1);\n-    cv1 = PR_NewCondVar(lock1);\n-    PR_ASSERT(NULL != cv1);\n-    lock2 = PR_NewLock();\n-    PR_ASSERT(NULL != lock2);\n-    cv2 = PR_NewCondVar(lock2);\n-    PR_ASSERT(NULL != cv2);\n-    start = PR_IntervalNow();\n-    thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, NULL, PR_PRIORITY_NORMAL,\n-                             PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    PR_ASSERT(NULL != thread);\n-    PR_Lock(lock2);\n-    PR_WaitCondVar(cv2, PR_MillisecondsToInterval(LONG_TIMEOUT));\n-    PR_Unlock(lock2);\n-    PR_JoinThread(thread);\n-    end = PR_IntervalNow();\n-    elapsed_ms = PR_IntervalToMilliseconds((PRIntervalTime)(end - start));\n-    /* Allow -100ms/+200ms imprecision */\n-    if (elapsed_ms < LONG_TIMEOUT - 100 || elapsed_ms > LONG_TIMEOUT + 200) {\n-        printf(\"Elapsed time should be %u ms but is %u ms\\n\", LONG_TIMEOUT,\n-               elapsed_ms);\n-        printf(\"FAIL\\n\");\n-        exit(1);\n-    }\n-    printf(\"Elapsed time: %u ms, expected time: %u ms\\n\", LONG_TIMEOUT,\n+  lock1 = PR_NewLock();\n+  PR_ASSERT(NULL != lock1);\n+  cv1 = PR_NewCondVar(lock1);\n+  PR_ASSERT(NULL != cv1);\n+  lock2 = PR_NewLock();\n+  PR_ASSERT(NULL != lock2);\n+  cv2 = PR_NewCondVar(lock2);\n+  PR_ASSERT(NULL != cv2);\n+  start = PR_IntervalNow();\n+  thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, NULL, PR_PRIORITY_NORMAL,\n+                           PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  PR_ASSERT(NULL != thread);\n+  PR_Lock(lock2);\n+  PR_WaitCondVar(cv2, PR_MillisecondsToInterval(LONG_TIMEOUT));\n+  PR_Unlock(lock2);\n+  PR_JoinThread(thread);\n+  end = PR_IntervalNow();\n+  elapsed_ms = PR_IntervalToMilliseconds((PRIntervalTime)(end - start));\n+  /* Allow -100ms/+200ms imprecision */\n+  if (elapsed_ms < LONG_TIMEOUT - 100 || elapsed_ms > LONG_TIMEOUT + 200) {\n+    printf(\"Elapsed time should be %u ms but is %u ms\\n\", LONG_TIMEOUT,\n            elapsed_ms);\n-    printf(\"PASS\\n\");\n-    return 0;\n+    printf(\"FAIL\\n\");\n+    exit(1);\n+  }\n+  printf(\"Elapsed time: %u ms, expected time: %u ms\\n\", LONG_TIMEOUT,\n+         elapsed_ms);\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/inrval.c b/nspr/pr/tests/inrval.c\nindex cb020c8..66ad188 100644\n--- a/nspr/pr/tests/inrval.c\n+++ b/nspr/pr/tests/inrval.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -43,186 +44,174 @@\n static PRIntn debug_mode;\n static PRFileDesc* output;\n \n-static void\n-TestConversions(void)\n-{\n-    PRIntervalTime ticks = PR_TicksPerSecond();\n-\n-    if (debug_mode) {\n-        PR_fprintf(output, \"PR_TicksPerSecond: %ld\\n\\n\", ticks);\n-        PR_fprintf(output, \"PR_SecondsToInterval(1): %ld\\n\",\n-                   PR_SecondsToInterval(1));\n-        PR_fprintf(output, \"PR_MillisecondsToInterval(1000): %ld\\n\",\n-                   PR_MillisecondsToInterval(1000));\n-        PR_fprintf(output, \"PR_MicrosecondsToInterval(1000000): %ld\\n\\n\",\n-                   PR_MicrosecondsToInterval(1000000));\n-\n-        PR_fprintf(output, \"PR_SecondsToInterval(3): %ld\\n\",\n-                   PR_SecondsToInterval(3));\n-        PR_fprintf(output, \"PR_MillisecondsToInterval(3000): %ld\\n\",\n-                   PR_MillisecondsToInterval(3000));\n-        PR_fprintf(output, \"PR_MicrosecondsToInterval(3000000): %ld\\n\\n\",\n-                   PR_MicrosecondsToInterval(3000000));\n-\n-        PR_fprintf(output, \"PR_IntervalToSeconds(%ld): %ld\\n\", ticks,\n-                   PR_IntervalToSeconds(ticks));\n-        PR_fprintf(output, \"PR_IntervalToMilliseconds(%ld): %ld\\n\", ticks,\n-                   PR_IntervalToMilliseconds(ticks));\n-        PR_fprintf(output, \"PR_IntervalToMicroseconds(%ld): %ld\\n\\n\", ticks,\n-                   PR_IntervalToMicroseconds(ticks));\n-\n-        ticks *= 3;\n-        PR_fprintf(output, \"PR_IntervalToSeconds(%ld): %ld\\n\", ticks,\n-                   PR_IntervalToSeconds(ticks));\n-        PR_fprintf(output, \"PR_IntervalToMilliseconds(%ld): %ld\\n\", ticks,\n-                   PR_IntervalToMilliseconds(ticks));\n-        PR_fprintf(output, \"PR_IntervalToMicroseconds(%ld): %ld\\n\\n\", ticks,\n-                   PR_IntervalToMicroseconds(ticks));\n-    } /*end debug mode */\n+static void TestConversions(void) {\n+  PRIntervalTime ticks = PR_TicksPerSecond();\n+\n+  if (debug_mode) {\n+    PR_fprintf(output, \"PR_TicksPerSecond: %ld\\n\\n\", ticks);\n+    PR_fprintf(output, \"PR_SecondsToInterval(1): %ld\\n\",\n+               PR_SecondsToInterval(1));\n+    PR_fprintf(output, \"PR_MillisecondsToInterval(1000): %ld\\n\",\n+               PR_MillisecondsToInterval(1000));\n+    PR_fprintf(output, \"PR_MicrosecondsToInterval(1000000): %ld\\n\\n\",\n+               PR_MicrosecondsToInterval(1000000));\n+\n+    PR_fprintf(output, \"PR_SecondsToInterval(3): %ld\\n\",\n+               PR_SecondsToInterval(3));\n+    PR_fprintf(output, \"PR_MillisecondsToInterval(3000): %ld\\n\",\n+               PR_MillisecondsToInterval(3000));\n+    PR_fprintf(output, \"PR_MicrosecondsToInterval(3000000): %ld\\n\\n\",\n+               PR_MicrosecondsToInterval(3000000));\n+\n+    PR_fprintf(output, \"PR_IntervalToSeconds(%ld): %ld\\n\", ticks,\n+               PR_IntervalToSeconds(ticks));\n+    PR_fprintf(output, \"PR_IntervalToMilliseconds(%ld): %ld\\n\", ticks,\n+               PR_IntervalToMilliseconds(ticks));\n+    PR_fprintf(output, \"PR_IntervalToMicroseconds(%ld): %ld\\n\\n\", ticks,\n+               PR_IntervalToMicroseconds(ticks));\n+\n+    ticks *= 3;\n+    PR_fprintf(output, \"PR_IntervalToSeconds(%ld): %ld\\n\", ticks,\n+               PR_IntervalToSeconds(ticks));\n+    PR_fprintf(output, \"PR_IntervalToMilliseconds(%ld): %ld\\n\", ticks,\n+               PR_IntervalToMilliseconds(ticks));\n+    PR_fprintf(output, \"PR_IntervalToMicroseconds(%ld): %ld\\n\\n\", ticks,\n+               PR_IntervalToMicroseconds(ticks));\n+  } /*end debug mode */\n } /* TestConversions */\n \n-static void\n-TestIntervalOverhead(void)\n-{\n-    /* Hopefully the optimizer won't delete this function */\n-    PRUint32 elapsed, per_call, loops = 1000000;\n+static void TestIntervalOverhead(void) {\n+  /* Hopefully the optimizer won't delete this function */\n+  PRUint32 elapsed, per_call, loops = 1000000;\n \n-    PRIntervalTime timeout, timein = PR_IntervalNow();\n-    while (--loops > 0) {\n-        timeout = PR_IntervalNow();\n-    }\n+  PRIntervalTime timeout, timein = PR_IntervalNow();\n+  while (--loops > 0) {\n+    timeout = PR_IntervalNow();\n+  }\n \n-    elapsed = 1000U * PR_IntervalToMicroseconds(timeout - timein);\n-    per_call = elapsed / 1000000U;\n-    PR_fprintf(output, \"Overhead of 'PR_IntervalNow()' is %u nsecs\\n\\n\",\n-               per_call);\n+  elapsed = 1000U * PR_IntervalToMicroseconds(timeout - timein);\n+  per_call = elapsed / 1000000U;\n+  PR_fprintf(output, \"Overhead of 'PR_IntervalNow()' is %u nsecs\\n\\n\",\n+             per_call);\n } /* TestIntervalOverhead */\n \n-static void\n-TestNowOverhead(void)\n-{\n-    PRTime timeout, timein;\n-    PRInt32 overhead, loops = 1000000;\n-    PRInt64 elapsed, per_call, ten23rd, ten26th;\n+static void TestNowOverhead(void) {\n+  PRTime timeout, timein;\n+  PRInt32 overhead, loops = 1000000;\n+  PRInt64 elapsed, per_call, ten23rd, ten26th;\n \n-    LL_I2L(ten23rd, 1000);\n-    LL_I2L(ten26th, 1000000);\n+  LL_I2L(ten23rd, 1000);\n+  LL_I2L(ten26th, 1000000);\n \n-    timein = PR_Now();\n-    while (--loops > 0) {\n-        timeout = PR_Now();\n-    }\n+  timein = PR_Now();\n+  while (--loops > 0) {\n+    timeout = PR_Now();\n+  }\n \n-    LL_SUB(elapsed, timeout, timein);\n-    LL_MUL(elapsed, elapsed, ten23rd);\n-    LL_DIV(per_call, elapsed, ten26th);\n-    LL_L2I(overhead, per_call);\n-    PR_fprintf(output, \"Overhead of 'PR_Now()' is %u nsecs\\n\\n\", overhead);\n+  LL_SUB(elapsed, timeout, timein);\n+  LL_MUL(elapsed, elapsed, ten23rd);\n+  LL_DIV(per_call, elapsed, ten26th);\n+  LL_L2I(overhead, per_call);\n+  PR_fprintf(output, \"Overhead of 'PR_Now()' is %u nsecs\\n\\n\", overhead);\n } /* TestNowOverhead */\n \n-static void\n-TestIntervals(void)\n-{\n-    PRStatus rv;\n-    PRUint32 delta;\n-    PRInt32 seconds;\n-    PRUint64 elapsed, thousand;\n-    PRTime timein, timeout;\n-    PRLock* ml = PR_NewLock();\n-    PRCondVar* cv = PR_NewCondVar(ml);\n-    for (seconds = 0; seconds < 10; ++seconds) {\n-        PRIntervalTime ticks = PR_SecondsToInterval(seconds);\n-        PR_Lock(ml);\n-        timein = PR_Now();\n-        rv = PR_WaitCondVar(cv, ticks);\n-        timeout = PR_Now();\n-        PR_Unlock(ml);\n-        LL_SUB(elapsed, timeout, timein);\n-        LL_I2L(thousand, 1000);\n-        LL_DIV(elapsed, elapsed, thousand);\n-        LL_L2UI(delta, elapsed);\n-        if (debug_mode)\n-            PR_fprintf(output,\n-                       \"TestIntervals: %swaiting %ld seconds took %ld msecs\\n\",\n-                       ((rv == PR_SUCCESS) ? \"\" : \"FAILED \"), seconds, delta);\n-    }\n-    PR_DestroyCondVar(cv);\n-    PR_DestroyLock(ml);\n-    if (debug_mode) {\n-        PR_fprintf(output, \"\\n\");\n-    }\n+static void TestIntervals(void) {\n+  PRStatus rv;\n+  PRUint32 delta;\n+  PRInt32 seconds;\n+  PRUint64 elapsed, thousand;\n+  PRTime timein, timeout;\n+  PRLock* ml = PR_NewLock();\n+  PRCondVar* cv = PR_NewCondVar(ml);\n+  for (seconds = 0; seconds < 10; ++seconds) {\n+    PRIntervalTime ticks = PR_SecondsToInterval(seconds);\n+    PR_Lock(ml);\n+    timein = PR_Now();\n+    rv = PR_WaitCondVar(cv, ticks);\n+    timeout = PR_Now();\n+    PR_Unlock(ml);\n+    LL_SUB(elapsed, timeout, timein);\n+    LL_I2L(thousand, 1000);\n+    LL_DIV(elapsed, elapsed, thousand);\n+    LL_L2UI(delta, elapsed);\n+    if (debug_mode)\n+      PR_fprintf(output,\n+                 \"TestIntervals: %swaiting %ld seconds took %ld msecs\\n\",\n+                 ((rv == PR_SUCCESS) ? \"\" : \"FAILED \"), seconds, delta);\n+  }\n+  PR_DestroyCondVar(cv);\n+  PR_DestroyLock(ml);\n+  if (debug_mode) {\n+    PR_fprintf(output, \"\\n\");\n+  }\n } /* TestIntervals */\n \n-static PRIntn PR_CALLBACK\n-RealMain(int argc, char** argv)\n-{\n-    PRUint32 vcpu, cpus = 0, loops = 1000;\n-\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-\n-    /* main test */\n-\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dl:c:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            case 'c': /* concurrency counter */\n-                cpus = atoi(opt->value);\n-                break;\n-            case 'l': /* loop counter */\n-                loops = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n+static PRIntn PR_CALLBACK RealMain(int argc, char** argv) {\n+  PRUint32 vcpu, cpus = 0, loops = 1000;\n+\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n \n-    output = PR_GetSpecialFD(PR_StandardOutput);\n-    PR_fprintf(output, \"inrval: Examine stdout to determine results.\\n\");\n+  /* main test */\n \n-    if (cpus == 0) {\n-        cpus = 8;\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dl:c:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    if (loops == 0) {\n-        loops = 1000;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      case 'c': /* concurrency counter */\n+        cpus = atoi(opt->value);\n+        break;\n+      case 'l': /* loop counter */\n+        loops = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    if (debug_mode > 0) {\n-        PR_fprintf(output, \"Inrval: Using %d loops\\n\", loops);\n-        PR_fprintf(output, \"Inrval: Using 1 and %d cpu(s)\\n\", cpus);\n-    }\n+  output = PR_GetSpecialFD(PR_StandardOutput);\n+  PR_fprintf(output, \"inrval: Examine stdout to determine results.\\n\");\n+\n+  if (cpus == 0) {\n+    cpus = 8;\n+  }\n+  if (loops == 0) {\n+    loops = 1000;\n+  }\n \n-    for (vcpu = 1; vcpu <= cpus; vcpu += cpus - 1) {\n-        if (debug_mode) {\n-            PR_fprintf(output, \"\\nInrval: Using %d CPU(s)\\n\\n\", vcpu);\n-        }\n-        PR_SetConcurrency(vcpu);\n+  if (debug_mode > 0) {\n+    PR_fprintf(output, \"Inrval: Using %d loops\\n\", loops);\n+    PR_fprintf(output, \"Inrval: Using 1 and %d cpu(s)\\n\", cpus);\n+  }\n \n-        TestNowOverhead();\n-        TestIntervalOverhead();\n-        TestConversions();\n-        TestIntervals();\n+  for (vcpu = 1; vcpu <= cpus; vcpu += cpus - 1) {\n+    if (debug_mode) {\n+      PR_fprintf(output, \"\\nInrval: Using %d CPU(s)\\n\\n\", vcpu);\n     }\n+    PR_SetConcurrency(vcpu);\n+\n+    TestNowOverhead();\n+    TestIntervalOverhead();\n+    TestConversions();\n+    TestIntervals();\n+  }\n \n-    return 0;\n+  return 0;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv;\n+int main(int argc, char** argv) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\ndiff --git a/nspr/pr/tests/instrumt.c b/nspr/pr/tests/instrumt.c\nindex 25e5f8f..9eba784 100644\n--- a/nspr/pr/tests/instrumt.c\n+++ b/nspr/pr/tests/instrumt.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -50,9 +51,7 @@\n \n #define SMALL_TRACE_BUFSIZE (60 * 1024)\n \n-typedef enum { CountLoop = 1,\n-               TraceLoop = 2,\n-               TraceFlow = 3 } TraceTypes;\n+typedef enum { CountLoop = 1, TraceLoop = 2, TraceFlow = 3 } TraceTypes;\n \n PRLogModuleLevel msgLevel = PR_LOG_ALWAYS;\n \n@@ -65,60 +64,52 @@ PRInt32 activeThreads = 0;\n PR_DEFINE_COUNTER(hCounter);\n PR_DEFINE_TRACE(hTrace);\n \n-static void\n-Help(void)\n-{\n-    printf(\"Help? ... Ha!\\n\");\n-}\n-\n-static void\n-ListCounters(void)\n-{\n-    PR_DEFINE_COUNTER(qh);\n-    PR_DEFINE_COUNTER(rh);\n-    const char *qn, *rn, *dn;\n-    const char **qname = &qn, **rname = &rn, **desc = &dn;\n-    PRUint32 tCtr;\n-\n-    PR_INIT_COUNTER_HANDLE(qh, NULL);\n-    PR_FIND_NEXT_COUNTER_QNAME(qh, qh);\n-    while (qh != NULL) {\n-        PR_INIT_COUNTER_HANDLE(rh, NULL);\n-        PR_FIND_NEXT_COUNTER_RNAME(rh, rh, qh);\n-        while (rh != NULL) {\n-            PR_GET_COUNTER_NAME_FROM_HANDLE(rh, qname, rname, desc);\n-            PR_GET_COUNTER(tCtr, rh);\n-            PR_LOG(\n-                lm, msgLevel,\n-                (\"QName: %s  RName: %s  Desc: %s  Value: %ld\\n\", qn, rn, dn, tCtr));\n-            PR_FIND_NEXT_COUNTER_RNAME(rh, rh, qh);\n-        }\n-        PR_FIND_NEXT_COUNTER_QNAME(qh, qh);\n+static void Help(void) { printf(\"Help? ... Ha!\\n\"); }\n+\n+static void ListCounters(void) {\n+  PR_DEFINE_COUNTER(qh);\n+  PR_DEFINE_COUNTER(rh);\n+  const char *qn, *rn, *dn;\n+  const char **qname = &qn, **rname = &rn, **desc = &dn;\n+  PRUint32 tCtr;\n+\n+  PR_INIT_COUNTER_HANDLE(qh, NULL);\n+  PR_FIND_NEXT_COUNTER_QNAME(qh, qh);\n+  while (qh != NULL) {\n+    PR_INIT_COUNTER_HANDLE(rh, NULL);\n+    PR_FIND_NEXT_COUNTER_RNAME(rh, rh, qh);\n+    while (rh != NULL) {\n+      PR_GET_COUNTER_NAME_FROM_HANDLE(rh, qname, rname, desc);\n+      PR_GET_COUNTER(tCtr, rh);\n+      PR_LOG(\n+          lm, msgLevel,\n+          (\"QName: %s  RName: %s  Desc: %s  Value: %ld\\n\", qn, rn, dn, tCtr));\n+      PR_FIND_NEXT_COUNTER_RNAME(rh, rh, qh);\n     }\n-    return;\n+    PR_FIND_NEXT_COUNTER_QNAME(qh, qh);\n+  }\n+  return;\n } /* end ListCounters() */\n \n-static void\n-ListTraces(void)\n-{\n-    PR_DEFINE_TRACE(qh);\n-    PR_DEFINE_TRACE(rh);\n-    const char *qn, *rn, *dn;\n-    const char **qname = &qn, **rname = &rn, **desc = &dn;\n-\n-    PR_INIT_TRACE_HANDLE(qh, NULL);\n-    PR_FIND_NEXT_TRACE_QNAME(qh, qh);\n-    while (qh != NULL) {\n-        PR_INIT_TRACE_HANDLE(rh, NULL);\n-        PR_FIND_NEXT_TRACE_RNAME(rh, rh, qh);\n-        while (rh != NULL) {\n-            PR_GET_TRACE_NAME_FROM_HANDLE(rh, qname, rname, desc);\n-            PR_LOG(lm, msgLevel, (\"QName: %s  RName: %s  Desc: %s\", qn, rn, dn));\n-            PR_FIND_NEXT_TRACE_RNAME(rh, rh, qh);\n-        }\n-        PR_FIND_NEXT_TRACE_QNAME(qh, qh);\n+static void ListTraces(void) {\n+  PR_DEFINE_TRACE(qh);\n+  PR_DEFINE_TRACE(rh);\n+  const char *qn, *rn, *dn;\n+  const char **qname = &qn, **rname = &rn, **desc = &dn;\n+\n+  PR_INIT_TRACE_HANDLE(qh, NULL);\n+  PR_FIND_NEXT_TRACE_QNAME(qh, qh);\n+  while (qh != NULL) {\n+    PR_INIT_TRACE_HANDLE(rh, NULL);\n+    PR_FIND_NEXT_TRACE_RNAME(rh, rh, qh);\n+    while (rh != NULL) {\n+      PR_GET_TRACE_NAME_FROM_HANDLE(rh, qname, rname, desc);\n+      PR_LOG(lm, msgLevel, (\"QName: %s  RName: %s  Desc: %s\", qn, rn, dn));\n+      PR_FIND_NEXT_TRACE_RNAME(rh, rh, qh);\n     }\n-    return;\n+    PR_FIND_NEXT_TRACE_QNAME(qh, qh);\n+  }\n+  return;\n } /* end ListCounters() */\n \n static PRInt32 one = 1;\n@@ -129,308 +120,294 @@ static PRInt32 four = 4;\n /*\n ** Thread to iteratively count something.\n */\n-static void PR_CALLBACK\n-CountSomething(void* arg)\n-{\n-    PRInt32 switchVar = *((PRInt32*)arg);\n-    PRInt32 i;\n-\n-    PR_LOG(lm, msgLevel, (\"CountSomething: begin thread %ld\", switchVar));\n-\n-    for (i = 0; i < COUNT_LIMIT; i++) {\n-        switch (switchVar) {\n-            case 1:\n-                PR_INCREMENT_COUNTER(hCounter);\n-                break;\n-            case 2:\n-                PR_DECREMENT_COUNTER(hCounter);\n-                break;\n-            case 3:\n-                PR_ADD_TO_COUNTER(hCounter, 1);\n-                break;\n-            case 4:\n-                PR_SUBTRACT_FROM_COUNTER(hCounter, 1);\n-                break;\n-            default:\n-                PR_ASSERT(0);\n-                break;\n-        }\n-        PR_TRACE(hTrace, CountLoop, switchVar, i, 0, 0, 0, 0, 0);\n-    } /* end for() */\n-\n-    PR_LOG(lm, msgLevel, (\"CounterSomething: end thread %ld\", switchVar));\n-\n-    PR_EnterMonitor(mon);\n-    --activeThreads;\n-    PR_Notify(mon);\n-    PR_ExitMonitor(mon);\n-\n-    return;\n-} /* end CountSomething() */\n-\n-/*\n-** Create the counter threads.\n-*/\n-static void\n-CounterTest(void)\n-{\n-    PRThread *t1, *t2, *t3, *t4;\n-    PRIntn i = 0;\n-    PR_DEFINE_COUNTER(tc);\n-    PR_DEFINE_COUNTER(zCounter);\n-\n-    PR_LOG(lm, msgLevel, (\"Begin CounterTest\"));\n-\n-    /*\n-    ** Test Get and Set of a counter.\n-    **\n-    */\n-    PR_CREATE_COUNTER(zCounter, \"Atomic\", \"get/set test\",\n-                      \"test get and set of counter\");\n-    PR_SET_COUNTER(zCounter, 9);\n-    PR_GET_COUNTER(i, zCounter);\n-    if (i != 9) {\n-        failed = PR_TRUE;\n-        PR_LOG(lm, msgLevel, (\"Counter set/get failed\"));\n+static void PR_CALLBACK CountSomething(void* arg) {\n+  PRInt32 switchVar = *((PRInt32*)arg);\n+  PRInt32 i;\n+\n+  PR_LOG(lm, msgLevel, (\"CountSomething: begin thread %ld\", switchVar));\n+\n+  for (i = 0; i < COUNT_LIMIT; i++) {\n+    switch (switchVar) {\n+      case 1:\n+        PR_INCREMENT_COUNTER(hCounter);\n+        break;\n+      case 2:\n+        PR_DECREMENT_COUNTER(hCounter);\n+        break;\n+      case 3:\n+        PR_ADD_TO_COUNTER(hCounter, 1);\n+        break;\n+      case 4:\n+        PR_SUBTRACT_FROM_COUNTER(hCounter, 1);\n+        break;\n+      default:\n+        PR_ASSERT(0);\n+        break;\n     }\n+    PR_TRACE(hTrace, CountLoop, switchVar, i, 0, 0, 0, 0, 0);\n+  } /* end for() */\n \n-    activeThreads += 4;\n-    PR_CREATE_COUNTER(hCounter, \"Atomic\", \"SMP Tests\",\n-                      \"test atomic nature of counter\");\n-\n-    PR_GET_COUNTER_HANDLE_FROM_NAME(tc, \"Atomic\", \"SMP Tests\");\n-    PR_ASSERT(tc == hCounter);\n-\n-    t1 = PR_CreateThread(PR_USER_THREAD, CountSomething, &one, PR_PRIORITY_NORMAL,\n-                         PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    PR_ASSERT(t1);\n-\n-    t2 = PR_CreateThread(PR_USER_THREAD, CountSomething, &two, PR_PRIORITY_NORMAL,\n-                         PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    PR_ASSERT(t2);\n-\n-    t3 = PR_CreateThread(PR_USER_THREAD, CountSomething, &three,\n-                         PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n-                         PR_UNJOINABLE_THREAD, 0);\n-    PR_ASSERT(t3);\n+  PR_LOG(lm, msgLevel, (\"CounterSomething: end thread %ld\", switchVar));\n \n-    t4 =\n-        PR_CreateThread(PR_USER_THREAD, CountSomething, &four, PR_PRIORITY_NORMAL,\n-                        PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    PR_ASSERT(t4);\n+  PR_EnterMonitor(mon);\n+  --activeThreads;\n+  PR_Notify(mon);\n+  PR_ExitMonitor(mon);\n \n-    PR_LOG(lm, msgLevel, (\"Counter Threads started\"));\n+  return;\n+} /* end CountSomething() */\n \n-    ListCounters();\n-    return;\n+/*\n+** Create the counter threads.\n+*/\n+static void CounterTest(void) {\n+  PRThread *t1, *t2, *t3, *t4;\n+  PRIntn i = 0;\n+  PR_DEFINE_COUNTER(tc);\n+  PR_DEFINE_COUNTER(zCounter);\n+\n+  PR_LOG(lm, msgLevel, (\"Begin CounterTest\"));\n+\n+  /*\n+  ** Test Get and Set of a counter.\n+  **\n+  */\n+  PR_CREATE_COUNTER(zCounter, \"Atomic\", \"get/set test\",\n+                    \"test get and set of counter\");\n+  PR_SET_COUNTER(zCounter, 9);\n+  PR_GET_COUNTER(i, zCounter);\n+  if (i != 9) {\n+    failed = PR_TRUE;\n+    PR_LOG(lm, msgLevel, (\"Counter set/get failed\"));\n+  }\n+\n+  activeThreads += 4;\n+  PR_CREATE_COUNTER(hCounter, \"Atomic\", \"SMP Tests\",\n+                    \"test atomic nature of counter\");\n+\n+  PR_GET_COUNTER_HANDLE_FROM_NAME(tc, \"Atomic\", \"SMP Tests\");\n+  PR_ASSERT(tc == hCounter);\n+\n+  t1 = PR_CreateThread(PR_USER_THREAD, CountSomething, &one, PR_PRIORITY_NORMAL,\n+                       PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  PR_ASSERT(t1);\n+\n+  t2 = PR_CreateThread(PR_USER_THREAD, CountSomething, &two, PR_PRIORITY_NORMAL,\n+                       PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  PR_ASSERT(t2);\n+\n+  t3 = PR_CreateThread(PR_USER_THREAD, CountSomething, &three,\n+                       PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n+                       PR_UNJOINABLE_THREAD, 0);\n+  PR_ASSERT(t3);\n+\n+  t4 =\n+      PR_CreateThread(PR_USER_THREAD, CountSomething, &four, PR_PRIORITY_NORMAL,\n+                      PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  PR_ASSERT(t4);\n+\n+  PR_LOG(lm, msgLevel, (\"Counter Threads started\"));\n+\n+  ListCounters();\n+  return;\n } /* end CounterTest() */\n \n /*\n ** Thread to dump trace buffer to a file.\n */\n-static void PR_CALLBACK\n-RecordTrace(void* arg)\n-{\n-    PR_RECORD_TRACE_ENTRIES();\n+static void PR_CALLBACK RecordTrace(void* arg) {\n+  PR_RECORD_TRACE_ENTRIES();\n \n-    PR_EnterMonitor(mon);\n-    --activeThreads;\n-    PR_Notify(mon);\n-    PR_ExitMonitor(mon);\n+  PR_EnterMonitor(mon);\n+  --activeThreads;\n+  PR_Notify(mon);\n+  PR_ExitMonitor(mon);\n \n-    return;\n+  return;\n } /* end RecordTrace() */\n \n #define NUM_TRACE_RECORDS (10000)\n /*\n ** Thread to extract and print trace entries from the buffer.\n */\n-static void PR_CALLBACK\n-SampleTrace(void* arg)\n-{\n+static void PR_CALLBACK SampleTrace(void* arg) {\n #if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-    PRInt32 found, rc;\n-    PRTraceEntry* foundEntries;\n-    PRInt32 i;\n-\n-    foundEntries =\n-        (PRTraceEntry*)PR_Malloc(NUM_TRACE_RECORDS * sizeof(PRTraceEntry));\n-    PR_ASSERT(foundEntries != NULL);\n-\n-    do {\n-        rc = PR_GetTraceEntries(foundEntries, NUM_TRACE_RECORDS, &found);\n-        PR_LOG(lm, msgLevel, (\"SampleTrace: Lost Data: %ld found: %ld\", rc, found));\n-\n-        if (found != 0) {\n-            for (i = 0; i < found; i++) {\n-                PR_LOG(\n-                    lm, msgLevel,\n-                    (\"SampleTrace, detail: Thread: %p, Time: %llX, UD0: %ld, UD1: %ld, \"\n-                     \"UD2: %8.8ld\",\n-                     (foundEntries + i)->thread, (foundEntries + i)->time,\n-                     (foundEntries + i)->userData[0], (foundEntries + i)->userData[1],\n-                     (foundEntries + i)->userData[2]));\n-            }\n-        }\n-        PR_Sleep(PR_MillisecondsToInterval(50));\n-    } while (found != 0 && activeThreads >= 1);\n-\n-    PR_Free(foundEntries);\n-\n-    PR_EnterMonitor(mon);\n-    --activeThreads;\n-    PR_Notify(mon);\n-    PR_ExitMonitor(mon);\n-\n-    PR_LOG(lm, msgLevel, (\"SampleTrace(): exiting\"));\n+  PRInt32 found, rc;\n+  PRTraceEntry* foundEntries;\n+  PRInt32 i;\n+\n+  foundEntries =\n+      (PRTraceEntry*)PR_Malloc(NUM_TRACE_RECORDS * sizeof(PRTraceEntry));\n+  PR_ASSERT(foundEntries != NULL);\n+\n+  do {\n+    rc = PR_GetTraceEntries(foundEntries, NUM_TRACE_RECORDS, &found);\n+    PR_LOG(lm, msgLevel, (\"SampleTrace: Lost Data: %ld found: %ld\", rc, found));\n+\n+    if (found != 0) {\n+      for (i = 0; i < found; i++) {\n+        PR_LOG(\n+            lm, msgLevel,\n+            (\"SampleTrace, detail: Thread: %p, Time: %llX, UD0: %ld, UD1: %ld, \"\n+             \"UD2: %8.8ld\",\n+             (foundEntries + i)->thread, (foundEntries + i)->time,\n+             (foundEntries + i)->userData[0], (foundEntries + i)->userData[1],\n+             (foundEntries + i)->userData[2]));\n+      }\n+    }\n+    PR_Sleep(PR_MillisecondsToInterval(50));\n+  } while (found != 0 && activeThreads >= 1);\n+\n+  PR_Free(foundEntries);\n+\n+  PR_EnterMonitor(mon);\n+  --activeThreads;\n+  PR_Notify(mon);\n+  PR_ExitMonitor(mon);\n+\n+  PR_LOG(lm, msgLevel, (\"SampleTrace(): exiting\"));\n \n #endif\n-    return;\n+  return;\n } /* end RecordTrace() */\n \n /*\n ** Basic trace test.\n */\n-static void\n-TraceTest(void)\n-{\n-    PRInt32 i;\n-    PRInt32 size;\n-    PR_DEFINE_TRACE(th);\n-    PRThread *t1, *t2;\n-\n-    PR_LOG(lm, msgLevel, (\"Begin TraceTest\"));\n-\n-    size = SMALL_TRACE_BUFSIZE;\n-    PR_SET_TRACE_OPTION(PRTraceBufSize, &size);\n-    PR_GET_TRACE_OPTION(PRTraceBufSize, &i);\n-\n-    PR_CREATE_TRACE(th, \"TraceTest\", \"tt2\", \"A description for the trace test\");\n-    PR_CREATE_TRACE(th, \"TraceTest\", \"tt3\", \"A description for the trace test\");\n-    PR_CREATE_TRACE(th, \"TraceTest\", \"tt4\", \"A description for the trace test\");\n-    PR_CREATE_TRACE(th, \"TraceTest\", \"tt5\", \"A description for the trace test\");\n-    PR_CREATE_TRACE(th, \"TraceTest\", \"tt6\", \"A description for the trace test\");\n-    PR_CREATE_TRACE(th, \"TraceTest\", \"tt7\", \"A description for the trace test\");\n-    PR_CREATE_TRACE(th, \"TraceTest\", \"tt8\", \"A description for the trace test\");\n-\n-    PR_CREATE_TRACE(th, \"Trace Test\", \"tt0\",\n-                    \"QName is Trace Test, not TraceTest\");\n-    PR_CREATE_TRACE(th, \"Trace Test\", \"tt1\",\n-                    \"QName is Trace Test, not TraceTest\");\n-    PR_CREATE_TRACE(th, \"Trace Test\", \"tt2\",\n-                    \"QName is Trace Test, not TraceTest\");\n-    PR_CREATE_TRACE(th, \"Trace Test\", \"tt3\",\n-                    \"QName is Trace Test, not TraceTest\");\n-    PR_CREATE_TRACE(th, \"Trace Test\", \"tt4\",\n-                    \"QName is Trace Test, not TraceTest\");\n-    PR_CREATE_TRACE(th, \"Trace Test\", \"tt5\",\n-                    \"QName is Trace Test, not TraceTest\");\n-    PR_CREATE_TRACE(th, \"Trace Test\", \"tt6\",\n-                    \"QName is Trace Test, not TraceTest\");\n-    PR_CREATE_TRACE(th, \"Trace Test\", \"tt7\",\n-                    \"QName is Trace Test, not TraceTest\");\n-    PR_CREATE_TRACE(th, \"Trace Test\", \"tt8\",\n-                    \"QName is Trace Test, not TraceTest\");\n-    PR_CREATE_TRACE(th, \"Trace Test\", \"tt9\",\n-                    \"QName is Trace Test, not TraceTest\");\n-    PR_CREATE_TRACE(th, \"Trace Test\", \"tt10\",\n-                    \"QName is Trace Test, not TraceTest\");\n-\n-    activeThreads += 2;\n-    t1 = PR_CreateThread(PR_USER_THREAD, RecordTrace, NULL, PR_PRIORITY_NORMAL,\n-                         PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    PR_ASSERT(t1);\n-\n-    t2 = PR_CreateThread(PR_USER_THREAD, SampleTrace, 0, PR_PRIORITY_NORMAL,\n-                         PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    PR_ASSERT(t2);\n-\n-    ListTraces();\n-\n-    PR_GET_TRACE_HANDLE_FROM_NAME(th, \"TraceTest\", \"tt1\");\n-    PR_ASSERT(th == hTrace);\n-\n-    PR_LOG(lm, msgLevel, (\"End TraceTest\"));\n-    return;\n+static void TraceTest(void) {\n+  PRInt32 i;\n+  PRInt32 size;\n+  PR_DEFINE_TRACE(th);\n+  PRThread *t1, *t2;\n+\n+  PR_LOG(lm, msgLevel, (\"Begin TraceTest\"));\n+\n+  size = SMALL_TRACE_BUFSIZE;\n+  PR_SET_TRACE_OPTION(PRTraceBufSize, &size);\n+  PR_GET_TRACE_OPTION(PRTraceBufSize, &i);\n+\n+  PR_CREATE_TRACE(th, \"TraceTest\", \"tt2\", \"A description for the trace test\");\n+  PR_CREATE_TRACE(th, \"TraceTest\", \"tt3\", \"A description for the trace test\");\n+  PR_CREATE_TRACE(th, \"TraceTest\", \"tt4\", \"A description for the trace test\");\n+  PR_CREATE_TRACE(th, \"TraceTest\", \"tt5\", \"A description for the trace test\");\n+  PR_CREATE_TRACE(th, \"TraceTest\", \"tt6\", \"A description for the trace test\");\n+  PR_CREATE_TRACE(th, \"TraceTest\", \"tt7\", \"A description for the trace test\");\n+  PR_CREATE_TRACE(th, \"TraceTest\", \"tt8\", \"A description for the trace test\");\n+\n+  PR_CREATE_TRACE(th, \"Trace Test\", \"tt0\",\n+                  \"QName is Trace Test, not TraceTest\");\n+  PR_CREATE_TRACE(th, \"Trace Test\", \"tt1\",\n+                  \"QName is Trace Test, not TraceTest\");\n+  PR_CREATE_TRACE(th, \"Trace Test\", \"tt2\",\n+                  \"QName is Trace Test, not TraceTest\");\n+  PR_CREATE_TRACE(th, \"Trace Test\", \"tt3\",\n+                  \"QName is Trace Test, not TraceTest\");\n+  PR_CREATE_TRACE(th, \"Trace Test\", \"tt4\",\n+                  \"QName is Trace Test, not TraceTest\");\n+  PR_CREATE_TRACE(th, \"Trace Test\", \"tt5\",\n+                  \"QName is Trace Test, not TraceTest\");\n+  PR_CREATE_TRACE(th, \"Trace Test\", \"tt6\",\n+                  \"QName is Trace Test, not TraceTest\");\n+  PR_CREATE_TRACE(th, \"Trace Test\", \"tt7\",\n+                  \"QName is Trace Test, not TraceTest\");\n+  PR_CREATE_TRACE(th, \"Trace Test\", \"tt8\",\n+                  \"QName is Trace Test, not TraceTest\");\n+  PR_CREATE_TRACE(th, \"Trace Test\", \"tt9\",\n+                  \"QName is Trace Test, not TraceTest\");\n+  PR_CREATE_TRACE(th, \"Trace Test\", \"tt10\",\n+                  \"QName is Trace Test, not TraceTest\");\n+\n+  activeThreads += 2;\n+  t1 = PR_CreateThread(PR_USER_THREAD, RecordTrace, NULL, PR_PRIORITY_NORMAL,\n+                       PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  PR_ASSERT(t1);\n+\n+  t2 = PR_CreateThread(PR_USER_THREAD, SampleTrace, 0, PR_PRIORITY_NORMAL,\n+                       PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  PR_ASSERT(t2);\n+\n+  ListTraces();\n+\n+  PR_GET_TRACE_HANDLE_FROM_NAME(th, \"TraceTest\", \"tt1\");\n+  PR_ASSERT(th == hTrace);\n+\n+  PR_LOG(lm, msgLevel, (\"End TraceTest\"));\n+  return;\n } /* end TraceTest() */\n \n /*\n ** Ordered lock test.\n */\n-static void\n-OrderedLockTest(void)\n-{\n-    PR_LOG(lm, msgLevel, (\"Begin OrderedLockTest\"));\n+static void OrderedLockTest(void) {\n+  PR_LOG(lm, msgLevel, (\"Begin OrderedLockTest\"));\n \n } /* end OrderedLockTest() */\n \n-int\n-main(int argc, char** argv)\n-{\n+int main(int argc, char** argv) {\n #if defined(DEBUG) || defined(FORCE_NSPR_TRACE)\n-    PRUint32 counter;\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"hdv:\");\n-    lm = PR_NewLogModule(\"Test\");\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'v': /* verbose mode */\n-                msgLevel = (PRLogModuleLevel)atol(opt->value);\n-                break;\n-            case 'h': /* help message */\n-                Help();\n-                help = PR_TRUE;\n-                break;\n-            default:\n-                break;\n-        }\n+  PRUint32 counter;\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"hdv:\");\n+  lm = PR_NewLogModule(\"Test\");\n+\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    PR_CREATE_TRACE(hTrace, \"TraceTest\", \"tt1\",\n-                    \"A description for the trace test\");\n-    mon = PR_NewMonitor();\n-    PR_EnterMonitor(mon);\n-\n-    TraceTest();\n-    CounterTest();\n-    OrderedLockTest();\n-\n-    /* Wait for all threads to exit */\n-    while (activeThreads > 0) {\n-        if (activeThreads == 1) {\n-            PR_SET_TRACE_OPTION(PRTraceStopRecording, NULL);\n-        }\n-        PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n-        PR_GET_COUNTER(counter, hCounter);\n+    switch (opt->option) {\n+      case 'v': /* verbose mode */\n+        msgLevel = (PRLogModuleLevel)atol(opt->value);\n+        break;\n+      case 'h': /* help message */\n+        Help();\n+        help = PR_TRUE;\n+        break;\n+      default:\n+        break;\n     }\n-    PR_ExitMonitor(mon);\n-\n-    /*\n-    ** Evaluate results\n-    */\n-    PR_GET_COUNTER(counter, hCounter);\n-    if (counter != 0) {\n-        failed = PR_TRUE;\n-        PR_LOG(lm, msgLevel, (\"Expected counter == 0, found: %ld\", counter));\n-        printf(\"FAIL\\n\");\n-    } else {\n-        printf(\"PASS\\n\");\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  PR_CREATE_TRACE(hTrace, \"TraceTest\", \"tt1\",\n+                  \"A description for the trace test\");\n+  mon = PR_NewMonitor();\n+  PR_EnterMonitor(mon);\n+\n+  TraceTest();\n+  CounterTest();\n+  OrderedLockTest();\n+\n+  /* Wait for all threads to exit */\n+  while (activeThreads > 0) {\n+    if (activeThreads == 1) {\n+      PR_SET_TRACE_OPTION(PRTraceStopRecording, NULL);\n     }\n-\n-    PR_DESTROY_COUNTER(hCounter);\n-\n-    PR_DestroyMonitor(mon);\n-\n-    PR_TRACE(hTrace, TraceFlow, 0xfff, 0, 0, 0, 0, 0, 0);\n-    PR_DESTROY_TRACE(hTrace);\n+    PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n+    PR_GET_COUNTER(counter, hCounter);\n+  }\n+  PR_ExitMonitor(mon);\n+\n+  /*\n+  ** Evaluate results\n+  */\n+  PR_GET_COUNTER(counter, hCounter);\n+  if (counter != 0) {\n+    failed = PR_TRUE;\n+    PR_LOG(lm, msgLevel, (\"Expected counter == 0, found: %ld\", counter));\n+    printf(\"FAIL\\n\");\n+  } else {\n+    printf(\"PASS\\n\");\n+  }\n+\n+  PR_DESTROY_COUNTER(hCounter);\n+\n+  PR_DestroyMonitor(mon);\n+\n+  PR_TRACE(hTrace, TraceFlow, 0xfff, 0, 0, 0, 0, 0, 0);\n+  PR_DESTROY_TRACE(hTrace);\n #else\n-    printf(\"Test not defined\\n\");\n+  printf(\"Test not defined\\n\");\n #endif\n-    return 0;\n+  return 0;\n } /* main() */\n /* end instrumt.c */\ndiff --git a/nspr/pr/tests/intrio.c b/nspr/pr/tests/intrio.c\nindex ecc83b2..493a3a6 100644\n--- a/nspr/pr/tests/intrio.c\n+++ b/nspr/pr/tests/intrio.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -18,115 +19,107 @@ static PRLock* lock;\n static PRCondVar* cvar;\n static PRBool iothread_ready;\n \n-static void PR_CALLBACK\n-AbortIO(void* arg)\n-{\n-    PRStatus rv;\n-    PR_Sleep(PR_SecondsToInterval(2));\n-    rv = PR_Interrupt((PRThread*)arg);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+static void PR_CALLBACK AbortIO(void* arg) {\n+  PRStatus rv;\n+  PR_Sleep(PR_SecondsToInterval(2));\n+  rv = PR_Interrupt((PRThread*)arg);\n+  PR_ASSERT(PR_SUCCESS == rv);\n } /* AbortIO */\n \n-static void PR_CALLBACK\n-IOThread(void* arg)\n-{\n-    PRFileDesc *sock, *newsock;\n-    PRNetAddr addr;\n+static void PR_CALLBACK IOThread(void* arg) {\n+  PRFileDesc *sock, *newsock;\n+  PRNetAddr addr;\n \n-    sock = PR_OpenTCPSocket(PR_AF_INET6);\n-    if (sock == NULL) {\n-        fprintf(stderr, \"PR_OpenTCPSocket failed\\n\");\n-        exit(1);\n-    }\n-    memset(&addr, 0, sizeof(addr));\n-    if (PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, 0, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Bind(sock, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Bind failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Listen(sock, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Listen failed\\n\");\n-        exit(1);\n-    }\n-    /* tell the main thread that we are ready */\n-    PR_Lock(lock);\n-    iothread_ready = PR_TRUE;\n-    PR_NotifyCondVar(cvar);\n-    PR_Unlock(lock);\n-    newsock = PR_Accept(sock, NULL, PR_INTERVAL_NO_TIMEOUT);\n-    if (newsock != NULL) {\n-        fprintf(stderr, \"PR_Accept shouldn't have succeeded\\n\");\n-        exit(1);\n-    }\n-    if (PR_GetError() != PR_PENDING_INTERRUPT_ERROR) {\n-        fprintf(stderr, \"PR_Accept failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    printf(\"PR_Accept() is interrupted as expected\\n\");\n-    if (PR_Close(sock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n+  sock = PR_OpenTCPSocket(PR_AF_INET6);\n+  if (sock == NULL) {\n+    fprintf(stderr, \"PR_OpenTCPSocket failed\\n\");\n+    exit(1);\n+  }\n+  memset(&addr, 0, sizeof(addr));\n+  if (PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, 0, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Bind(sock, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Bind failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Listen(sock, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Listen failed\\n\");\n+    exit(1);\n+  }\n+  /* tell the main thread that we are ready */\n+  PR_Lock(lock);\n+  iothread_ready = PR_TRUE;\n+  PR_NotifyCondVar(cvar);\n+  PR_Unlock(lock);\n+  newsock = PR_Accept(sock, NULL, PR_INTERVAL_NO_TIMEOUT);\n+  if (newsock != NULL) {\n+    fprintf(stderr, \"PR_Accept shouldn't have succeeded\\n\");\n+    exit(1);\n+  }\n+  if (PR_GetError() != PR_PENDING_INTERRUPT_ERROR) {\n+    fprintf(stderr, \"PR_Accept failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  printf(\"PR_Accept() is interrupted as expected\\n\");\n+  if (PR_Close(sock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n }\n \n-static void\n-Test(PRThreadScope scope1, PRThreadScope scope2)\n-{\n-    PRThread *iothread, *abortio;\n+static void Test(PRThreadScope scope1, PRThreadScope scope2) {\n+  PRThread *iothread, *abortio;\n \n-    printf(\"A %s thread will be interrupted by a %s thread\\n\",\n-           (scope1 == PR_LOCAL_THREAD ? \"local\" : \"global\"),\n-           (scope2 == PR_LOCAL_THREAD ? \"local\" : \"global\"));\n-    iothread_ready = PR_FALSE;\n-    iothread = PR_CreateThread(PR_USER_THREAD, IOThread, NULL, PR_PRIORITY_NORMAL,\n-                               scope1, PR_JOINABLE_THREAD, 0);\n-    if (iothread == NULL) {\n-        fprintf(stderr, \"cannot create thread\\n\");\n-        exit(1);\n-    }\n-    PR_Lock(lock);\n-    while (!iothread_ready) {\n-        PR_WaitCondVar(cvar, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_Unlock(lock);\n-    abortio = PR_CreateThread(PR_USER_THREAD, AbortIO, iothread,\n-                              PR_PRIORITY_NORMAL, scope2, PR_JOINABLE_THREAD, 0);\n-    if (abortio == NULL) {\n-        fprintf(stderr, \"cannot create thread\\n\");\n-        exit(1);\n-    }\n-    if (PR_JoinThread(iothread) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_JoinThread(abortio) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n-    }\n+  printf(\"A %s thread will be interrupted by a %s thread\\n\",\n+         (scope1 == PR_LOCAL_THREAD ? \"local\" : \"global\"),\n+         (scope2 == PR_LOCAL_THREAD ? \"local\" : \"global\"));\n+  iothread_ready = PR_FALSE;\n+  iothread = PR_CreateThread(PR_USER_THREAD, IOThread, NULL, PR_PRIORITY_NORMAL,\n+                             scope1, PR_JOINABLE_THREAD, 0);\n+  if (iothread == NULL) {\n+    fprintf(stderr, \"cannot create thread\\n\");\n+    exit(1);\n+  }\n+  PR_Lock(lock);\n+  while (!iothread_ready) {\n+    PR_WaitCondVar(cvar, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_Unlock(lock);\n+  abortio = PR_CreateThread(PR_USER_THREAD, AbortIO, iothread,\n+                            PR_PRIORITY_NORMAL, scope2, PR_JOINABLE_THREAD, 0);\n+  if (abortio == NULL) {\n+    fprintf(stderr, \"cannot create thread\\n\");\n+    exit(1);\n+  }\n+  if (PR_JoinThread(iothread) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_JoinThread(abortio) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    lock = PR_NewLock();\n-    if (lock == NULL) {\n-        fprintf(stderr, \"PR_NewLock failed\\n\");\n-        exit(1);\n-    }\n-    cvar = PR_NewCondVar(lock);\n-    if (cvar == NULL) {\n-        fprintf(stderr, \"PR_NewCondVar failed\\n\");\n-        exit(1);\n-    }\n-    /* test all four combinations */\n-    Test(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n-    Test(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n-    Test(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n-    Test(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n-    printf(\"PASSED\\n\");\n-    return 0;\n+int main(int argc, char** argv) {\n+  lock = PR_NewLock();\n+  if (lock == NULL) {\n+    fprintf(stderr, \"PR_NewLock failed\\n\");\n+    exit(1);\n+  }\n+  cvar = PR_NewCondVar(lock);\n+  if (cvar == NULL) {\n+    fprintf(stderr, \"PR_NewCondVar failed\\n\");\n+    exit(1);\n+  }\n+  /* test all four combinations */\n+  Test(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n+  Test(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n+  Test(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n+  Test(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n+  printf(\"PASSED\\n\");\n+  return 0;\n } /* main */\ndiff --git a/nspr/pr/tests/intrupt.c b/nspr/pr/tests/intrupt.c\nindex 541019b..c46fc2e 100644\n--- a/nspr/pr/tests/intrupt.c\n+++ b/nspr/pr/tests/intrupt.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -31,316 +32,301 @@ static PRBool passed = PR_TRUE;\n static PRBool debug_mode = PR_FALSE;\n static PRThreadScope thread_scope = PR_LOCAL_THREAD;\n \n-static void PR_CALLBACK\n-AbortCV(void* arg)\n-{\n-    PRStatus rv;\n-    PRThread* me = PR_GetCurrentThread();\n-\n-    /* some other thread (main) is doing the interrupt */\n-    PR_Lock(ml);\n-    rv = PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n-    if (debug_mode) {\n-        printf(\"Expected interrupt on wait CV and \");\n-    }\n-    if (PR_FAILURE == rv) {\n-        if (PR_PENDING_INTERRUPT_ERROR == PR_GetError()) {\n-            if (debug_mode) {\n-                printf(\"got it\\n\");\n-            }\n-        } else {\n-            if (debug_mode) {\n-                printf(\"got random error\\n\");\n-            }\n-            passed = PR_FALSE;\n-        }\n+static void PR_CALLBACK AbortCV(void* arg) {\n+  PRStatus rv;\n+  PRThread* me = PR_GetCurrentThread();\n+\n+  /* some other thread (main) is doing the interrupt */\n+  PR_Lock(ml);\n+  rv = PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n+  if (debug_mode) {\n+    printf(\"Expected interrupt on wait CV and \");\n+  }\n+  if (PR_FAILURE == rv) {\n+    if (PR_PENDING_INTERRUPT_ERROR == PR_GetError()) {\n+      if (debug_mode) {\n+        printf(\"got it\\n\");\n+      }\n     } else {\n-        if (debug_mode) {\n-            printf(\"got a successful completion\\n\");\n-        }\n-        passed = PR_FALSE;\n+      if (debug_mode) {\n+        printf(\"got random error\\n\");\n+      }\n+      passed = PR_FALSE;\n     }\n-\n-    rv = PR_WaitCondVar(cv, 10);\n+  } else {\n     if (debug_mode) {\n-        printf(\"Expected success on wait CV and %s\\n\",\n-               (PR_SUCCESS == rv) ? \"got it\" : \"failed\");\n-    }\n-    passed = ((PR_TRUE == passed) && (PR_SUCCESS == rv)) ? PR_TRUE : PR_FALSE;\n-\n-    /* interrupt myself, then clear */\n-    PR_Interrupt(me);\n-    PR_ClearInterrupt();\n-    rv = PR_WaitCondVar(cv, 10);\n-    if (debug_mode) {\n-        printf(\"Expected success on wait CV and \");\n-        if (PR_FAILURE == rv) {\n-            printf(\"%s\\n\", (PR_PENDING_INTERRUPT_ERROR == PR_GetError())\n-                               ? \"got interrupted\"\n-                               : \"a random failure\");\n-        }\n-        printf(\"got it\\n\");\n-    }\n-    passed = ((PR_TRUE == passed) && (PR_SUCCESS == rv)) ? PR_TRUE : PR_FALSE;\n-\n-    /* set, then wait - interrupt - then wait again */\n-    PR_Interrupt(me);\n-    rv = PR_WaitCondVar(cv, 10);\n-    if (debug_mode) {\n-        printf(\"Expected interrupt on wait CV and \");\n+      printf(\"got a successful completion\\n\");\n     }\n+    passed = PR_FALSE;\n+  }\n+\n+  rv = PR_WaitCondVar(cv, 10);\n+  if (debug_mode) {\n+    printf(\"Expected success on wait CV and %s\\n\",\n+           (PR_SUCCESS == rv) ? \"got it\" : \"failed\");\n+  }\n+  passed = ((PR_TRUE == passed) && (PR_SUCCESS == rv)) ? PR_TRUE : PR_FALSE;\n+\n+  /* interrupt myself, then clear */\n+  PR_Interrupt(me);\n+  PR_ClearInterrupt();\n+  rv = PR_WaitCondVar(cv, 10);\n+  if (debug_mode) {\n+    printf(\"Expected success on wait CV and \");\n     if (PR_FAILURE == rv) {\n-        if (PR_PENDING_INTERRUPT_ERROR == PR_GetError()) {\n-            if (debug_mode) {\n-                printf(\"got it\\n\");\n-            }\n-        } else {\n-            if (debug_mode) {\n-                printf(\"failed\\n\");\n-            }\n-            passed = PR_FALSE;\n-        }\n+      printf(\"%s\\n\", (PR_PENDING_INTERRUPT_ERROR == PR_GetError())\n+                         ? \"got interrupted\"\n+                         : \"a random failure\");\n+    }\n+    printf(\"got it\\n\");\n+  }\n+  passed = ((PR_TRUE == passed) && (PR_SUCCESS == rv)) ? PR_TRUE : PR_FALSE;\n+\n+  /* set, then wait - interrupt - then wait again */\n+  PR_Interrupt(me);\n+  rv = PR_WaitCondVar(cv, 10);\n+  if (debug_mode) {\n+    printf(\"Expected interrupt on wait CV and \");\n+  }\n+  if (PR_FAILURE == rv) {\n+    if (PR_PENDING_INTERRUPT_ERROR == PR_GetError()) {\n+      if (debug_mode) {\n+        printf(\"got it\\n\");\n+      }\n     } else {\n-        if (debug_mode) {\n-            printf(\"got a successful completion\\n\");\n-        }\n-        passed = PR_FALSE;\n+      if (debug_mode) {\n+        printf(\"failed\\n\");\n+      }\n+      passed = PR_FALSE;\n     }\n-\n-    rv = PR_WaitCondVar(cv, 10);\n+  } else {\n     if (debug_mode) {\n-        printf(\"Expected success on wait CV and %s\\n\",\n-               (PR_SUCCESS == rv) ? \"got it\" : \"failed\");\n+      printf(\"got a successful completion\\n\");\n     }\n-    passed = ((PR_TRUE == passed) && (PR_SUCCESS == rv)) ? PR_TRUE : PR_FALSE;\n+    passed = PR_FALSE;\n+  }\n+\n+  rv = PR_WaitCondVar(cv, 10);\n+  if (debug_mode) {\n+    printf(\"Expected success on wait CV and %s\\n\",\n+           (PR_SUCCESS == rv) ? \"got it\" : \"failed\");\n+  }\n+  passed = ((PR_TRUE == passed) && (PR_SUCCESS == rv)) ? PR_TRUE : PR_FALSE;\n \n-    PR_Unlock(ml);\n+  PR_Unlock(ml);\n \n } /* AbortCV */\n \n-static void PR_CALLBACK\n-AbortIO(void* arg)\n-{\n-    PRStatus rv;\n-    PR_Sleep(PR_SecondsToInterval(2));\n-    rv = PR_Interrupt((PRThread*)arg);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+static void PR_CALLBACK AbortIO(void* arg) {\n+  PRStatus rv;\n+  PR_Sleep(PR_SecondsToInterval(2));\n+  rv = PR_Interrupt((PRThread*)arg);\n+  PR_ASSERT(PR_SUCCESS == rv);\n } /* AbortIO */\n \n-static void PR_CALLBACK\n-AbortJoin(void* arg)\n-{\n-} /* AbortJoin */\n+static void PR_CALLBACK AbortJoin(void* arg) {} /* AbortJoin */\n \n-static void\n-setup_listen_socket(PRFileDesc** listner, PRNetAddr* netaddr)\n-{\n-    PRStatus rv;\n-    PRInt16 port = DEFAULT_TCP_PORT;\n-\n-    *listner = PR_NewTCPSocket();\n-    PR_ASSERT(*listner != NULL);\n-    memset(netaddr, 0, sizeof(*netaddr));\n-    (*netaddr).inet.ip = PR_htonl(PR_INADDR_ANY);\n-    (*netaddr).inet.family = PR_AF_INET;\n-    do {\n-        (*netaddr).inet.port = PR_htons(port);\n-        rv = PR_Bind(*listner, netaddr);\n-        port += 1;\n-        PR_ASSERT(port < (DEFAULT_TCP_PORT + 10));\n-    } while (PR_FAILURE == rv);\n-\n-    rv = PR_Listen(*listner, 5);\n-\n-    if (PR_GetSockName(*listner, netaddr) < 0) {\n-        if (debug_mode) {\n-            printf(\"intrupt: ERROR - PR_GetSockName failed\\n\");\n-        }\n-        passed = PR_FALSE;\n-        return;\n-    }\n-}\n+static void setup_listen_socket(PRFileDesc** listner, PRNetAddr* netaddr) {\n+  PRStatus rv;\n+  PRInt16 port = DEFAULT_TCP_PORT;\n \n-static void PR_CALLBACK\n-IntrBlock(void* arg)\n-{\n-    PRStatus rv;\n-    PRNetAddr netaddr;\n-    PRFileDesc* listner;\n-\n-    /* some other thread (main) is doing the interrupt */\n-    /* block the interrupt */\n-    PR_BlockInterrupt();\n-    PR_Lock(ml);\n-    rv = PR_WaitCondVar(cv, PR_SecondsToInterval(4));\n-    PR_Unlock(ml);\n-    if (debug_mode) {\n-        printf(\"Expected success on wait CV and \");\n-        if (PR_FAILURE == rv) {\n-            printf(\"%s\\n\", (PR_PENDING_INTERRUPT_ERROR == PR_GetError())\n-                               ? \"got interrupted\"\n-                               : \"got a random failure\");\n-        } else {\n-            printf(\"got it\\n\");\n-        }\n-    }\n-    passed = ((PR_TRUE == passed) && (PR_SUCCESS == rv)) ? PR_TRUE : PR_FALSE;\n-\n-    setup_listen_socket(&listner, &netaddr);\n-    PR_UnblockInterrupt();\n-    if (PR_Accept(listner, &netaddr, PR_INTERVAL_NO_TIMEOUT) == NULL) {\n-        PRInt32 error = PR_GetError();\n-        if (debug_mode) {\n-            printf(\"Expected interrupt on PR_Accept() and \");\n-        }\n-        if (PR_PENDING_INTERRUPT_ERROR == error) {\n-            if (debug_mode) {\n-                printf(\"got it\\n\");\n-            }\n-        } else {\n-            if (debug_mode) {\n-                printf(\"failed\\n\");\n-            }\n-            passed = PR_FALSE;\n-        }\n-    } else {\n-        if (debug_mode) {\n-            printf(\"Failed to interrupt PR_Accept()\\n\");\n-        }\n-        passed = PR_FALSE;\n-    }\n-\n-    (void)PR_Close(listner);\n-    listner = NULL;\n-} /* TestIntrBlock */\n-\n-void PR_CALLBACK\n-Intrupt(void* arg)\n-{\n-    PRStatus rv;\n-    PRNetAddr netaddr;\n-    PRFileDesc* listner;\n-    PRThread *abortCV, *abortIO, *abortJoin, *intrBlock;\n+  *listner = PR_NewTCPSocket();\n+  PR_ASSERT(*listner != NULL);\n+  memset(netaddr, 0, sizeof(*netaddr));\n+  (*netaddr).inet.ip = PR_htonl(PR_INADDR_ANY);\n+  (*netaddr).inet.family = PR_AF_INET;\n+  do {\n+    (*netaddr).inet.port = PR_htons(port);\n+    rv = PR_Bind(*listner, netaddr);\n+    port += 1;\n+    PR_ASSERT(port < (DEFAULT_TCP_PORT + 10));\n+  } while (PR_FAILURE == rv);\n \n-    ml = PR_NewLock();\n-    cv = PR_NewCondVar(ml);\n+  rv = PR_Listen(*listner, 5);\n \n-    /* Part I */\n+  if (PR_GetSockName(*listner, netaddr) < 0) {\n     if (debug_mode) {\n-        printf(\"Part I\\n\");\n+      printf(\"intrupt: ERROR - PR_GetSockName failed\\n\");\n     }\n-    abortCV = PR_CreateThread(PR_USER_THREAD, AbortCV, 0, PR_PRIORITY_NORMAL,\n-                              thread_scope, PR_JOINABLE_THREAD, 0);\n+    passed = PR_FALSE;\n+    return;\n+  }\n+}\n \n-    PR_Sleep(PR_SecondsToInterval(2));\n-    rv = PR_Interrupt(abortCV);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    rv = PR_JoinThread(abortCV);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+static void PR_CALLBACK IntrBlock(void* arg) {\n+  PRStatus rv;\n+  PRNetAddr netaddr;\n+  PRFileDesc* listner;\n+\n+  /* some other thread (main) is doing the interrupt */\n+  /* block the interrupt */\n+  PR_BlockInterrupt();\n+  PR_Lock(ml);\n+  rv = PR_WaitCondVar(cv, PR_SecondsToInterval(4));\n+  PR_Unlock(ml);\n+  if (debug_mode) {\n+    printf(\"Expected success on wait CV and \");\n+    if (PR_FAILURE == rv) {\n+      printf(\"%s\\n\", (PR_PENDING_INTERRUPT_ERROR == PR_GetError())\n+                         ? \"got interrupted\"\n+                         : \"got a random failure\");\n+    } else {\n+      printf(\"got it\\n\");\n+    }\n+  }\n+  passed = ((PR_TRUE == passed) && (PR_SUCCESS == rv)) ? PR_TRUE : PR_FALSE;\n \n-    /* Part II */\n+  setup_listen_socket(&listner, &netaddr);\n+  PR_UnblockInterrupt();\n+  if (PR_Accept(listner, &netaddr, PR_INTERVAL_NO_TIMEOUT) == NULL) {\n+    PRInt32 error = PR_GetError();\n     if (debug_mode) {\n-        printf(\"Part II\\n\");\n+      printf(\"Expected interrupt on PR_Accept() and \");\n     }\n-    abortJoin = PR_CreateThread(PR_USER_THREAD, AbortJoin, 0, PR_PRIORITY_NORMAL,\n-                                thread_scope, PR_JOINABLE_THREAD, 0);\n-    PR_Sleep(PR_SecondsToInterval(2));\n-    if (debug_mode) {\n-        printf(\"Expecting to interrupt an exited thread \");\n+    if (PR_PENDING_INTERRUPT_ERROR == error) {\n+      if (debug_mode) {\n+        printf(\"got it\\n\");\n+      }\n+    } else {\n+      if (debug_mode) {\n+        printf(\"failed\\n\");\n+      }\n+      passed = PR_FALSE;\n     }\n-    rv = PR_Interrupt(abortJoin);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    rv = PR_JoinThread(abortJoin);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+  } else {\n     if (debug_mode) {\n-        printf(\"and succeeded\\n\");\n+      printf(\"Failed to interrupt PR_Accept()\\n\");\n     }\n+    passed = PR_FALSE;\n+  }\n+\n+  (void)PR_Close(listner);\n+  listner = NULL;\n+} /* TestIntrBlock */\n \n-    /* Part III */\n+void PR_CALLBACK Intrupt(void* arg) {\n+  PRStatus rv;\n+  PRNetAddr netaddr;\n+  PRFileDesc* listner;\n+  PRThread *abortCV, *abortIO, *abortJoin, *intrBlock;\n+\n+  ml = PR_NewLock();\n+  cv = PR_NewCondVar(ml);\n+\n+  /* Part I */\n+  if (debug_mode) {\n+    printf(\"Part I\\n\");\n+  }\n+  abortCV = PR_CreateThread(PR_USER_THREAD, AbortCV, 0, PR_PRIORITY_NORMAL,\n+                            thread_scope, PR_JOINABLE_THREAD, 0);\n+\n+  PR_Sleep(PR_SecondsToInterval(2));\n+  rv = PR_Interrupt(abortCV);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  rv = PR_JoinThread(abortCV);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+\n+  /* Part II */\n+  if (debug_mode) {\n+    printf(\"Part II\\n\");\n+  }\n+  abortJoin = PR_CreateThread(PR_USER_THREAD, AbortJoin, 0, PR_PRIORITY_NORMAL,\n+                              thread_scope, PR_JOINABLE_THREAD, 0);\n+  PR_Sleep(PR_SecondsToInterval(2));\n+  if (debug_mode) {\n+    printf(\"Expecting to interrupt an exited thread \");\n+  }\n+  rv = PR_Interrupt(abortJoin);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  rv = PR_JoinThread(abortJoin);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  if (debug_mode) {\n+    printf(\"and succeeded\\n\");\n+  }\n+\n+  /* Part III */\n+  if (debug_mode) {\n+    printf(\"Part III\\n\");\n+  }\n+  setup_listen_socket(&listner, &netaddr);\n+  abortIO =\n+      PR_CreateThread(PR_USER_THREAD, AbortIO, PR_GetCurrentThread(),\n+                      PR_PRIORITY_NORMAL, thread_scope, PR_JOINABLE_THREAD, 0);\n+\n+  if (PR_Accept(listner, &netaddr, PR_INTERVAL_NO_TIMEOUT) == NULL) {\n+    PRInt32 error = PR_GetError();\n     if (debug_mode) {\n-        printf(\"Part III\\n\");\n+      printf(\"Expected interrupt on PR_Accept() and \");\n     }\n-    setup_listen_socket(&listner, &netaddr);\n-    abortIO =\n-        PR_CreateThread(PR_USER_THREAD, AbortIO, PR_GetCurrentThread(),\n-                        PR_PRIORITY_NORMAL, thread_scope, PR_JOINABLE_THREAD, 0);\n-\n-    if (PR_Accept(listner, &netaddr, PR_INTERVAL_NO_TIMEOUT) == NULL) {\n-        PRInt32 error = PR_GetError();\n-        if (debug_mode) {\n-            printf(\"Expected interrupt on PR_Accept() and \");\n-        }\n-        if (PR_PENDING_INTERRUPT_ERROR == error) {\n-            if (debug_mode) {\n-                printf(\"got it\\n\");\n-            }\n-        } else {\n-            if (debug_mode) {\n-                printf(\"failed\\n\");\n-            }\n-            passed = PR_FALSE;\n-        }\n+    if (PR_PENDING_INTERRUPT_ERROR == error) {\n+      if (debug_mode) {\n+        printf(\"got it\\n\");\n+      }\n     } else {\n-        if (debug_mode) {\n-            printf(\"Failed to interrupt PR_Accept()\\n\");\n-        }\n-        passed = PR_FALSE;\n+      if (debug_mode) {\n+        printf(\"failed\\n\");\n+      }\n+      passed = PR_FALSE;\n     }\n-\n-    (void)PR_Close(listner);\n-    listner = NULL;\n-\n-    rv = PR_JoinThread(abortIO);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    /* Part VI */\n+  } else {\n     if (debug_mode) {\n-        printf(\"Part VI\\n\");\n+      printf(\"Failed to interrupt PR_Accept()\\n\");\n     }\n-    intrBlock = PR_CreateThread(PR_USER_THREAD, IntrBlock, 0, PR_PRIORITY_NORMAL,\n-                                thread_scope, PR_JOINABLE_THREAD, 0);\n+    passed = PR_FALSE;\n+  }\n+\n+  (void)PR_Close(listner);\n+  listner = NULL;\n+\n+  rv = PR_JoinThread(abortIO);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  /* Part VI */\n+  if (debug_mode) {\n+    printf(\"Part VI\\n\");\n+  }\n+  intrBlock = PR_CreateThread(PR_USER_THREAD, IntrBlock, 0, PR_PRIORITY_NORMAL,\n+                              thread_scope, PR_JOINABLE_THREAD, 0);\n \n-    PR_Sleep(PR_SecondsToInterval(2));\n-    rv = PR_Interrupt(intrBlock);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    rv = PR_JoinThread(intrBlock);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+  PR_Sleep(PR_SecondsToInterval(2));\n+  rv = PR_Interrupt(intrBlock);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  rv = PR_JoinThread(intrBlock);\n+  PR_ASSERT(PR_SUCCESS == rv);\n \n-    PR_DestroyCondVar(cv);\n-    PR_DestroyLock(ml);\n+  PR_DestroyCondVar(cv);\n+  PR_DestroyLock(ml);\n } /* Intrupt */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRThread* intrupt;\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dG\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            case 'G': /* use global threads */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  PRThread* intrupt;\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dG\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-    intrupt = PR_CreateThread(PR_USER_THREAD, Intrupt, NULL, PR_PRIORITY_NORMAL,\n-                              thread_scope, PR_JOINABLE_THREAD, 0);\n-    if (intrupt == NULL) {\n-        fprintf(stderr, \"cannot create thread\\n\");\n-        passed = PR_FALSE;\n-    } else {\n-        PRStatus rv;\n-        rv = PR_JoinThread(intrupt);\n-        PR_ASSERT(rv == PR_SUCCESS);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      case 'G': /* use global threads */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n     }\n-    printf(\"%s\\n\", ((passed) ? \"PASSED\" : \"FAILED\"));\n-    return ((passed) ? 0 : 1);\n+  }\n+  PL_DestroyOptState(opt);\n+  intrupt = PR_CreateThread(PR_USER_THREAD, Intrupt, NULL, PR_PRIORITY_NORMAL,\n+                            thread_scope, PR_JOINABLE_THREAD, 0);\n+  if (intrupt == NULL) {\n+    fprintf(stderr, \"cannot create thread\\n\");\n+    passed = PR_FALSE;\n+  } else {\n+    PRStatus rv;\n+    rv = PR_JoinThread(intrupt);\n+    PR_ASSERT(rv == PR_SUCCESS);\n+  }\n+  printf(\"%s\\n\", ((passed) ? \"PASSED\" : \"FAILED\"));\n+  return ((passed) ? 0 : 1);\n } /* main */\n \n /* intrupt.c */\ndiff --git a/nspr/pr/tests/io_timeout.c b/nspr/pr/tests/io_timeout.c\nindex 805ee7f..14dcb58 100644\n--- a/nspr/pr/tests/io_timeout.c\n+++ b/nspr/pr/tests/io_timeout.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -32,11 +33,11 @@\n #define DEFAULT_ACCEPT_TIMEOUT 2\n \n typedef struct threadInfo {\n-    PRInt16 id;\n-    PRInt16 accept_timeout;\n-    PRLock* dead_lock;\n-    PRCondVar* dead_cv;\n-    PRInt32* alive;\n+  PRInt16 id;\n+  PRInt16 accept_timeout;\n+  PRLock* dead_lock;\n+  PRCondVar* dead_cv;\n+  PRInt32* alive;\n } threadInfo;\n \n PRIntn failed_already = 0;\n@@ -46,216 +47,210 @@ PRIntn debug_mode = 0;\n #define GLOBAL_SCOPE_STRING \"GLOBAL scope\"\n #define GLOBAL_BOUND_SCOPE_STRING \"GLOBAL_BOUND scope\"\n \n-void\n-thread_main(void* _info)\n-{\n-    threadInfo* info = (threadInfo*)_info;\n-    PRNetAddr listenAddr;\n-    PRNetAddr clientAddr;\n-    PRFileDesc* listenSock = NULL;\n-    PRFileDesc* clientSock;\n-    PRStatus rv;\n-    PRThreadScope tscope;\n-    char* scope_str;\n-\n+void thread_main(void* _info) {\n+  threadInfo* info = (threadInfo*)_info;\n+  PRNetAddr listenAddr;\n+  PRNetAddr clientAddr;\n+  PRFileDesc* listenSock = NULL;\n+  PRFileDesc* clientSock;\n+  PRStatus rv;\n+  PRThreadScope tscope;\n+  char* scope_str;\n+\n+  if (debug_mode) {\n+    printf(\"thread %d is alive\\n\", info->id);\n+  }\n+  tscope = PR_GetThreadScope(PR_GetCurrentThread());\n+\n+  switch (tscope) {\n+    case PR_LOCAL_THREAD:\n+      scope_str = LOCAL_SCOPE_STRING;\n+      break;\n+    case PR_GLOBAL_THREAD:\n+      scope_str = GLOBAL_SCOPE_STRING;\n+      break;\n+    case PR_GLOBAL_BOUND_THREAD:\n+      scope_str = GLOBAL_BOUND_SCOPE_STRING;\n+      break;\n+    default:\n+      PR_NOT_REACHED(\"Invalid thread scope\");\n+      break;\n+  }\n+  printf(\"thread id %d, scope %s\\n\", info->id, scope_str);\n+\n+  listenSock = PR_NewTCPSocket();\n+  if (!listenSock) {\n     if (debug_mode) {\n-        printf(\"thread %d is alive\\n\", info->id);\n-    }\n-    tscope = PR_GetThreadScope(PR_GetCurrentThread());\n-\n-    switch (tscope) {\n-        case PR_LOCAL_THREAD:\n-            scope_str = LOCAL_SCOPE_STRING;\n-            break;\n-        case PR_GLOBAL_THREAD:\n-            scope_str = GLOBAL_SCOPE_STRING;\n-            break;\n-        case PR_GLOBAL_BOUND_THREAD:\n-            scope_str = GLOBAL_BOUND_SCOPE_STRING;\n-            break;\n-        default:\n-            PR_NOT_REACHED(\"Invalid thread scope\");\n-            break;\n+      printf(\"unable to create listen socket\\n\");\n     }\n-    printf(\"thread id %d, scope %s\\n\", info->id, scope_str);\n-\n-    listenSock = PR_NewTCPSocket();\n-    if (!listenSock) {\n-        if (debug_mode) {\n-            printf(\"unable to create listen socket\\n\");\n-        }\n-        failed_already = 1;\n-        goto dead;\n-    }\n-\n-    listenAddr.inet.family = PR_AF_INET;\n-    listenAddr.inet.port = PR_htons(BASE_PORT + info->id);\n-    listenAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    rv = PR_Bind(listenSock, &listenAddr);\n-    if (rv == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"unable to bind\\n\");\n-        }\n-        failed_already = 1;\n-        goto dead;\n+    failed_already = 1;\n+    goto dead;\n+  }\n+\n+  listenAddr.inet.family = PR_AF_INET;\n+  listenAddr.inet.port = PR_htons(BASE_PORT + info->id);\n+  listenAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  rv = PR_Bind(listenSock, &listenAddr);\n+  if (rv == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"unable to bind\\n\");\n     }\n+    failed_already = 1;\n+    goto dead;\n+  }\n \n-    rv = PR_Listen(listenSock, 4);\n-    if (rv == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"unable to listen\\n\");\n-        }\n-        failed_already = 1;\n-        goto dead;\n+  rv = PR_Listen(listenSock, 4);\n+  if (rv == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"unable to listen\\n\");\n     }\n-\n-    if (debug_mode)\n-        printf(\"thread %d going into accept for %d seconds\\n\", info->id,\n-               info->accept_timeout + info->id);\n-\n-    clientSock = PR_Accept(listenSock, &clientAddr,\n-                           PR_SecondsToInterval(info->accept_timeout + info->id));\n-\n-    if (clientSock == NULL) {\n-        if (PR_GetError() == PR_IO_TIMEOUT_ERROR) {\n-            if (debug_mode) {\n-                printf(\"PR_Accept() timeout worked!\\n\");\n-                printf(\"TEST PASSED! PR_Accept() returned error %d\\n\",\n-                       PR_IO_TIMEOUT_ERROR);\n-            }\n-        } else {\n-            if (debug_mode)\n-                printf(\"TEST FAILED! PR_Accept() returned error %d\\n\", PR_GetError());\n-            failed_already = 1;\n-        }\n+    failed_already = 1;\n+    goto dead;\n+  }\n+\n+  if (debug_mode)\n+    printf(\"thread %d going into accept for %d seconds\\n\", info->id,\n+           info->accept_timeout + info->id);\n+\n+  clientSock = PR_Accept(listenSock, &clientAddr,\n+                         PR_SecondsToInterval(info->accept_timeout + info->id));\n+\n+  if (clientSock == NULL) {\n+    if (PR_GetError() == PR_IO_TIMEOUT_ERROR) {\n+      if (debug_mode) {\n+        printf(\"PR_Accept() timeout worked!\\n\");\n+        printf(\"TEST PASSED! PR_Accept() returned error %d\\n\",\n+               PR_IO_TIMEOUT_ERROR);\n+      }\n     } else {\n-        if (debug_mode) {\n-            printf(\"TEST FAILED! PR_Accept() succeeded?\\n\");\n-        }\n-        failed_already = 1;\n-        PR_Close(clientSock);\n+      if (debug_mode)\n+        printf(\"TEST FAILED! PR_Accept() returned error %d\\n\", PR_GetError());\n+      failed_already = 1;\n     }\n-\n-dead:\n-    if (listenSock) {\n-        PR_Close(listenSock);\n-    }\n-    PR_Lock(info->dead_lock);\n-    (*info->alive)--;\n-    PR_NotifyCondVar(info->dead_cv);\n-    PR_Unlock(info->dead_lock);\n-\n+  } else {\n     if (debug_mode) {\n-        printf(\"thread %d is dead\\n\", info->id);\n+      printf(\"TEST FAILED! PR_Accept() succeeded?\\n\");\n     }\n+    failed_already = 1;\n+    PR_Close(clientSock);\n+  }\n \n-    PR_Free(info);\n+dead:\n+  if (listenSock) {\n+    PR_Close(listenSock);\n+  }\n+  PR_Lock(info->dead_lock);\n+  (*info->alive)--;\n+  PR_NotifyCondVar(info->dead_cv);\n+  PR_Unlock(info->dead_lock);\n+\n+  if (debug_mode) {\n+    printf(\"thread %d is dead\\n\", info->id);\n+  }\n+\n+  PR_Free(info);\n }\n \n-void\n-thread_test(PRThreadScope scope, PRInt32 num_threads)\n-{\n-    PRInt32 index;\n-    PRThread* thr;\n-    PRLock* dead_lock;\n-    PRCondVar* dead_cv;\n-    PRInt32 alive;\n-\n-    if (debug_mode) {\n-        printf(\"IO Timeout test started with %d threads\\n\", num_threads);\n+void thread_test(PRThreadScope scope, PRInt32 num_threads) {\n+  PRInt32 index;\n+  PRThread* thr;\n+  PRLock* dead_lock;\n+  PRCondVar* dead_cv;\n+  PRInt32 alive;\n+\n+  if (debug_mode) {\n+    printf(\"IO Timeout test started with %d threads\\n\", num_threads);\n+  }\n+\n+  dead_lock = PR_NewLock();\n+  dead_cv = PR_NewCondVar(dead_lock);\n+  alive = num_threads;\n+\n+  for (index = 0; index < num_threads; index++) {\n+    threadInfo* info = (threadInfo*)PR_Malloc(sizeof(threadInfo));\n+\n+    info->id = index;\n+    info->dead_lock = dead_lock;\n+    info->dead_cv = dead_cv;\n+    info->alive = &alive;\n+    info->accept_timeout = DEFAULT_ACCEPT_TIMEOUT;\n+\n+    thr = PR_CreateThread(PR_USER_THREAD, thread_main, (void*)info,\n+                          PR_PRIORITY_NORMAL, scope, PR_UNJOINABLE_THREAD, 0);\n+\n+    if (!thr) {\n+      printf(\"Failed to create thread, error = %d(%d)\\n\", PR_GetError(),\n+             PR_GetOSError());\n+      failed_already = 1;\n+\n+      PR_Lock(dead_lock);\n+      alive--;\n+      PR_Unlock(dead_lock);\n     }\n+  }\n \n-    dead_lock = PR_NewLock();\n-    dead_cv = PR_NewCondVar(dead_lock);\n-    alive = num_threads;\n-\n-    for (index = 0; index < num_threads; index++) {\n-        threadInfo* info = (threadInfo*)PR_Malloc(sizeof(threadInfo));\n-\n-        info->id = index;\n-        info->dead_lock = dead_lock;\n-        info->dead_cv = dead_cv;\n-        info->alive = &alive;\n-        info->accept_timeout = DEFAULT_ACCEPT_TIMEOUT;\n-\n-        thr = PR_CreateThread(PR_USER_THREAD, thread_main, (void*)info,\n-                              PR_PRIORITY_NORMAL, scope, PR_UNJOINABLE_THREAD, 0);\n-\n-        if (!thr) {\n-            printf(\"Failed to create thread, error = %d(%d)\\n\", PR_GetError(),\n-                   PR_GetOSError());\n-            failed_already = 1;\n-\n-            PR_Lock(dead_lock);\n-            alive--;\n-            PR_Unlock(dead_lock);\n-        }\n-    }\n-\n-    PR_Lock(dead_lock);\n-    while (alive) {\n-        if (debug_mode) {\n-            printf(\"main loop awake; alive = %d\\n\", alive);\n-        }\n-        PR_WaitCondVar(dead_cv, PR_INTERVAL_NO_TIMEOUT);\n+  PR_Lock(dead_lock);\n+  while (alive) {\n+    if (debug_mode) {\n+      printf(\"main loop awake; alive = %d\\n\", alive);\n     }\n-    PR_Unlock(dead_lock);\n+    PR_WaitCondVar(dead_cv, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_Unlock(dead_lock);\n \n-    PR_DestroyCondVar(dead_cv);\n-    PR_DestroyLock(dead_lock);\n+  PR_DestroyCondVar(dead_cv);\n+  PR_DestroyLock(dead_lock);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRInt32 num_threads = 0;\n-\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name [-d] [-t <threads>]\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dt:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            case 't': /* threads to involve */\n-                num_threads = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  PRInt32 num_threads = 0;\n+\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name [-d] [-t <threads>]\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dt:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      case 't': /* threads to involve */\n+        num_threads = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n+  }\n+  PL_DestroyOptState(opt);\n \n-    /* main test */\n+  /* main test */\n \n-    if (0 == num_threads) {\n-        num_threads = NUM_THREADS;\n-    }\n+  if (0 == num_threads) {\n+    num_threads = NUM_THREADS;\n+  }\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_LOW, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_LOW, 0);\n \n-    printf(\"test with global bound thread\\n\");\n-    thread_test(PR_GLOBAL_BOUND_THREAD, num_threads);\n+  printf(\"test with global bound thread\\n\");\n+  thread_test(PR_GLOBAL_BOUND_THREAD, num_threads);\n \n-    printf(\"test with local thread\\n\");\n-    thread_test(PR_LOCAL_THREAD, num_threads);\n+  printf(\"test with local thread\\n\");\n+  thread_test(PR_LOCAL_THREAD, num_threads);\n \n-    printf(\"test with global thread\\n\");\n-    thread_test(PR_GLOBAL_THREAD, num_threads);\n+  printf(\"test with global thread\\n\");\n+  thread_test(PR_GLOBAL_THREAD, num_threads);\n \n-    PR_Cleanup();\n+  PR_Cleanup();\n \n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/io_timeoutk.c b/nspr/pr/tests/io_timeoutk.c\nindex a309f68..041e1ab 100644\n--- a/nspr/pr/tests/io_timeoutk.c\n+++ b/nspr/pr/tests/io_timeoutk.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -33,187 +34,181 @@\n #define DEFAULT_ACCEPT_TIMEOUT 2\n \n typedef struct threadInfo {\n-    PRInt16 id;\n-    PRInt16 accept_timeout;\n-    PRLock* dead_lock;\n-    PRCondVar* dead_cv;\n-    PRInt32* alive;\n+  PRInt16 id;\n+  PRInt16 accept_timeout;\n+  PRLock* dead_lock;\n+  PRCondVar* dead_cv;\n+  PRInt32* alive;\n } threadInfo;\n \n PRIntn failed_already = 0;\n PRIntn debug_mode;\n \n-void\n-thread_main(void* _info)\n-{\n-    threadInfo* info = (threadInfo*)_info;\n-    PRNetAddr listenAddr;\n-    PRNetAddr clientAddr;\n-    PRFileDesc* listenSock = NULL;\n-    PRFileDesc* clientSock;\n-    PRStatus rv;\n+void thread_main(void* _info) {\n+  threadInfo* info = (threadInfo*)_info;\n+  PRNetAddr listenAddr;\n+  PRNetAddr clientAddr;\n+  PRFileDesc* listenSock = NULL;\n+  PRFileDesc* clientSock;\n+  PRStatus rv;\n \n-    if (debug_mode) {\n-        printf(\"thread %d is alive\\n\", info->id);\n-    }\n+  if (debug_mode) {\n+    printf(\"thread %d is alive\\n\", info->id);\n+  }\n \n-    listenSock = PR_NewTCPSocket();\n-    if (!listenSock) {\n-        if (debug_mode) {\n-            printf(\"unable to create listen socket\\n\");\n-        }\n-        goto dead;\n+  listenSock = PR_NewTCPSocket();\n+  if (!listenSock) {\n+    if (debug_mode) {\n+      printf(\"unable to create listen socket\\n\");\n     }\n-\n-    listenAddr.inet.family = AF_INET;\n-    listenAddr.inet.port = PR_htons(BASE_PORT + info->id);\n-    listenAddr.inet.ip = PR_htonl(INADDR_ANY);\n-    rv = PR_Bind(listenSock, &listenAddr);\n-    if (rv == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"unable to bind\\n\");\n-        }\n-        goto dead;\n+    goto dead;\n+  }\n+\n+  listenAddr.inet.family = AF_INET;\n+  listenAddr.inet.port = PR_htons(BASE_PORT + info->id);\n+  listenAddr.inet.ip = PR_htonl(INADDR_ANY);\n+  rv = PR_Bind(listenSock, &listenAddr);\n+  if (rv == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"unable to bind\\n\");\n     }\n+    goto dead;\n+  }\n \n-    rv = PR_Listen(listenSock, 4);\n-    if (rv == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"unable to listen\\n\");\n-        }\n-        goto dead;\n+  rv = PR_Listen(listenSock, 4);\n+  if (rv == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"unable to listen\\n\");\n     }\n-\n-    if (debug_mode)\n-        printf(\"thread %d going into accept for %d seconds\\n\", info->id,\n-               info->accept_timeout + info->id);\n-\n-    clientSock = PR_Accept(listenSock, &clientAddr,\n-                           PR_SecondsToInterval(info->accept_timeout + info->id));\n-\n-    if (clientSock == NULL) {\n-        if (PR_GetError() == PR_IO_TIMEOUT_ERROR)\n-            if (debug_mode) {\n-                printf(\"PR_Accept() timeout worked!\\n\");\n-                printf(\"TEST FAILED! PR_Accept() returned error %d\\n\", PR_GetError());\n-            } else {\n-                failed_already = 1;\n-            }\n+    goto dead;\n+  }\n+\n+  if (debug_mode)\n+    printf(\"thread %d going into accept for %d seconds\\n\", info->id,\n+           info->accept_timeout + info->id);\n+\n+  clientSock = PR_Accept(listenSock, &clientAddr,\n+                         PR_SecondsToInterval(info->accept_timeout + info->id));\n+\n+  if (clientSock == NULL) {\n+    if (PR_GetError() == PR_IO_TIMEOUT_ERROR)\n+      if (debug_mode) {\n+        printf(\"PR_Accept() timeout worked!\\n\");\n+        printf(\"TEST FAILED! PR_Accept() returned error %d\\n\", PR_GetError());\n+      } else {\n+        failed_already = 1;\n+      }\n+  } else {\n+    if (debug_mode) {\n+      printf(\"TEST FAILED! PR_Accept() succeeded?\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"TEST FAILED! PR_Accept() succeeded?\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        PR_Close(clientSock);\n+      failed_already = 1;\n     }\n+    PR_Close(clientSock);\n+  }\n \n dead:\n-    if (listenSock) {\n-        PR_Close(listenSock);\n-    }\n-    PR_Lock(info->dead_lock);\n-    (*info->alive)--;\n-    PR_NotifyCondVar(info->dead_cv);\n-    PR_Unlock(info->dead_lock);\n-\n-    if (debug_mode) {\n-        printf(\"thread %d is dead\\n\", info->id);\n-    }\n+  if (listenSock) {\n+    PR_Close(listenSock);\n+  }\n+  PR_Lock(info->dead_lock);\n+  (*info->alive)--;\n+  PR_NotifyCondVar(info->dead_cv);\n+  PR_Unlock(info->dead_lock);\n+\n+  if (debug_mode) {\n+    printf(\"thread %d is dead\\n\", info->id);\n+  }\n }\n \n-void\n-thread_test(PRInt32 scope, PRInt32 num_threads)\n-{\n-    PRInt32 index;\n-    PRThread* thr;\n-    PRLock* dead_lock;\n-    PRCondVar* dead_cv;\n-    PRInt32 alive;\n-\n-    if (debug_mode) {\n-        printf(\"IO Timeout test started with %d threads\\n\", num_threads);\n-    }\n-\n-    dead_lock = PR_NewLock();\n-    dead_cv = PR_NewCondVar(dead_lock);\n-    alive = num_threads;\n-\n-    for (index = 0; index < num_threads; index++) {\n-        threadInfo* info = (threadInfo*)malloc(sizeof(threadInfo));\n-\n-        info->id = index;\n-        info->dead_lock = dead_lock;\n-        info->dead_cv = dead_cv;\n-        info->alive = &alive;\n-        info->accept_timeout = DEFAULT_ACCEPT_TIMEOUT;\n-\n-        thr = PR_CreateThread(PR_USER_THREAD, thread_main, (void*)info,\n-                              PR_PRIORITY_NORMAL, scope, PR_UNJOINABLE_THREAD, 0);\n-\n-        if (!thr) {\n-            PR_Lock(dead_lock);\n-            alive--;\n-            PR_Unlock(dead_lock);\n-        }\n+void thread_test(PRInt32 scope, PRInt32 num_threads) {\n+  PRInt32 index;\n+  PRThread* thr;\n+  PRLock* dead_lock;\n+  PRCondVar* dead_cv;\n+  PRInt32 alive;\n+\n+  if (debug_mode) {\n+    printf(\"IO Timeout test started with %d threads\\n\", num_threads);\n+  }\n+\n+  dead_lock = PR_NewLock();\n+  dead_cv = PR_NewCondVar(dead_lock);\n+  alive = num_threads;\n+\n+  for (index = 0; index < num_threads; index++) {\n+    threadInfo* info = (threadInfo*)malloc(sizeof(threadInfo));\n+\n+    info->id = index;\n+    info->dead_lock = dead_lock;\n+    info->dead_cv = dead_cv;\n+    info->alive = &alive;\n+    info->accept_timeout = DEFAULT_ACCEPT_TIMEOUT;\n+\n+    thr = PR_CreateThread(PR_USER_THREAD, thread_main, (void*)info,\n+                          PR_PRIORITY_NORMAL, scope, PR_UNJOINABLE_THREAD, 0);\n+\n+    if (!thr) {\n+      PR_Lock(dead_lock);\n+      alive--;\n+      PR_Unlock(dead_lock);\n     }\n+  }\n \n-    PR_Lock(dead_lock);\n-    while (alive) {\n-        if (debug_mode) {\n-            printf(\"main loop awake; alive = %d\\n\", alive);\n-        }\n-        PR_WaitCondVar(dead_cv, PR_INTERVAL_NO_TIMEOUT);\n+  PR_Lock(dead_lock);\n+  while (alive) {\n+    if (debug_mode) {\n+      printf(\"main loop awake; alive = %d\\n\", alive);\n     }\n-    PR_Unlock(dead_lock);\n+    PR_WaitCondVar(dead_cv, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_Unlock(dead_lock);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRInt32 num_threads;\n-\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  PRInt32 num_threads;\n+\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    /* main test */\n+  /* main test */\n \n-    if (argc > 2) {\n-        num_threads = atoi(argv[2]);\n-    } else {\n-        num_threads = NUM_THREADS;\n-    }\n+  if (argc > 2) {\n+    num_threads = atoi(argv[2]);\n+  } else {\n+    num_threads = NUM_THREADS;\n+  }\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_LOW, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_LOW, 0);\n \n-    if (debug_mode) {\n-        printf(\"kernel level test\\n\");\n-    }\n-    thread_test(PR_GLOBAL_THREAD, num_threads);\n+  if (debug_mode) {\n+    printf(\"kernel level test\\n\");\n+  }\n+  thread_test(PR_GLOBAL_THREAD, num_threads);\n \n-    PR_Cleanup();\n+  PR_Cleanup();\n \n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/io_timeoutu.c b/nspr/pr/tests/io_timeoutu.c\nindex 89bffdf..03fd12a 100644\n--- a/nspr/pr/tests/io_timeoutu.c\n+++ b/nspr/pr/tests/io_timeoutu.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -33,188 +34,181 @@\n #define DEFAULT_ACCEPT_TIMEOUT 2\n \n typedef struct threadInfo {\n-    PRInt16 id;\n-    PRInt16 accept_timeout;\n-    PRLock* dead_lock;\n-    PRCondVar* dead_cv;\n-    PRInt32* alive;\n+  PRInt16 id;\n+  PRInt16 accept_timeout;\n+  PRLock* dead_lock;\n+  PRCondVar* dead_cv;\n+  PRInt32* alive;\n } threadInfo;\n PRIntn failed_already = 0;\n PRIntn debug_mode;\n \n-void\n-thread_main(void* _info)\n-{\n-    threadInfo* info = (threadInfo*)_info;\n-    PRNetAddr listenAddr;\n-    PRNetAddr clientAddr;\n-    PRFileDesc* listenSock = NULL;\n-    PRFileDesc* clientSock;\n-    PRStatus rv;\n+void thread_main(void* _info) {\n+  threadInfo* info = (threadInfo*)_info;\n+  PRNetAddr listenAddr;\n+  PRNetAddr clientAddr;\n+  PRFileDesc* listenSock = NULL;\n+  PRFileDesc* clientSock;\n+  PRStatus rv;\n \n-    if (debug_mode) {\n-        printf(\"thread %d is alive\\n\", info->id);\n-    }\n+  if (debug_mode) {\n+    printf(\"thread %d is alive\\n\", info->id);\n+  }\n \n-    listenSock = PR_NewTCPSocket();\n-    if (!listenSock) {\n-        if (debug_mode) {\n-            printf(\"unable to create listen socket\\n\");\n-        }\n-        goto dead;\n+  listenSock = PR_NewTCPSocket();\n+  if (!listenSock) {\n+    if (debug_mode) {\n+      printf(\"unable to create listen socket\\n\");\n     }\n-\n-    listenAddr.inet.family = AF_INET;\n-    listenAddr.inet.port = PR_htons(BASE_PORT + info->id);\n-    listenAddr.inet.ip = PR_htonl(INADDR_ANY);\n-    rv = PR_Bind(listenSock, &listenAddr);\n-    if (rv == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"unable to bind\\n\");\n-        }\n-        goto dead;\n+    goto dead;\n+  }\n+\n+  listenAddr.inet.family = AF_INET;\n+  listenAddr.inet.port = PR_htons(BASE_PORT + info->id);\n+  listenAddr.inet.ip = PR_htonl(INADDR_ANY);\n+  rv = PR_Bind(listenSock, &listenAddr);\n+  if (rv == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"unable to bind\\n\");\n     }\n+    goto dead;\n+  }\n \n-    rv = PR_Listen(listenSock, 4);\n-    if (rv == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"unable to listen\\n\");\n-        }\n-        goto dead;\n+  rv = PR_Listen(listenSock, 4);\n+  if (rv == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"unable to listen\\n\");\n     }\n+    goto dead;\n+  }\n \n-    if (debug_mode)\n-        printf(\"thread %d going into accept for %d seconds\\n\", info->id,\n-               info->accept_timeout + info->id);\n+  if (debug_mode)\n+    printf(\"thread %d going into accept for %d seconds\\n\", info->id,\n+           info->accept_timeout + info->id);\n \n-    clientSock = PR_Accept(listenSock, &clientAddr,\n-                           PR_SecondsToInterval(info->accept_timeout + info->id));\n+  clientSock = PR_Accept(listenSock, &clientAddr,\n+                         PR_SecondsToInterval(info->accept_timeout + info->id));\n \n-    if (clientSock == NULL) {\n-        if (PR_GetError() == PR_IO_TIMEOUT_ERROR)\n-            if (debug_mode) {\n-                printf(\"PR_Accept() timeout worked!\\n\");\n+  if (clientSock == NULL) {\n+    if (PR_GetError() == PR_IO_TIMEOUT_ERROR)\n+      if (debug_mode) {\n+        printf(\"PR_Accept() timeout worked!\\n\");\n                 printf(\"TEST FAILED! PR_Accept() returned error %d\\n\",\n-            }\n+      }\n         PR_GetError());\n-        else\n-        {\n-            failed_already = 1;\n+        else {\n+          failed_already = 1;\n         }\n+  } else {\n+    if (debug_mode) {\n+      printf(\"TEST FAILED! PR_Accept() succeeded?\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"TEST FAILED! PR_Accept() succeeded?\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        PR_Close(clientSock);\n+      failed_already = 1;\n     }\n+    PR_Close(clientSock);\n+  }\n \n dead:\n-    if (listenSock) {\n-        PR_Close(listenSock);\n-    }\n-    PR_Lock(info->dead_lock);\n-    (*info->alive)--;\n-    PR_NotifyCondVar(info->dead_cv);\n-    PR_Unlock(info->dead_lock);\n-\n-    if (debug_mode) {\n-        printf(\"thread %d is dead\\n\", info->id);\n-    }\n+  if (listenSock) {\n+    PR_Close(listenSock);\n+  }\n+  PR_Lock(info->dead_lock);\n+  (*info->alive)--;\n+  PR_NotifyCondVar(info->dead_cv);\n+  PR_Unlock(info->dead_lock);\n+\n+  if (debug_mode) {\n+    printf(\"thread %d is dead\\n\", info->id);\n+  }\n }\n \n-void\n-thread_test(PRInt32 scope, PRInt32 num_threads)\n-{\n-    PRInt32 index;\n-    PRThread* thr;\n-    PRLock* dead_lock;\n-    PRCondVar* dead_cv;\n-    PRInt32 alive;\n-\n-    if (debug_mode) {\n-        printf(\"IO Timeout test started with %d threads\\n\", num_threads);\n-    }\n-\n-    dead_lock = PR_NewLock();\n-    dead_cv = PR_NewCondVar(dead_lock);\n-    alive = num_threads;\n-\n-    for (index = 0; index < num_threads; index++) {\n-        threadInfo* info = (threadInfo*)malloc(sizeof(threadInfo));\n-\n-        info->id = index;\n-        info->dead_lock = dead_lock;\n-        info->dead_cv = dead_cv;\n-        info->alive = &alive;\n-        info->accept_timeout = DEFAULT_ACCEPT_TIMEOUT;\n-\n-        thr = PR_CreateThread(PR_USER_THREAD, thread_main, (void*)info,\n-                              PR_PRIORITY_NORMAL, scope, PR_UNJOINABLE_THREAD, 0);\n-\n-        if (!thr) {\n-            PR_Lock(dead_lock);\n-            alive--;\n-            PR_Unlock(dead_lock);\n-        }\n+void thread_test(PRInt32 scope, PRInt32 num_threads) {\n+  PRInt32 index;\n+  PRThread* thr;\n+  PRLock* dead_lock;\n+  PRCondVar* dead_cv;\n+  PRInt32 alive;\n+\n+  if (debug_mode) {\n+    printf(\"IO Timeout test started with %d threads\\n\", num_threads);\n+  }\n+\n+  dead_lock = PR_NewLock();\n+  dead_cv = PR_NewCondVar(dead_lock);\n+  alive = num_threads;\n+\n+  for (index = 0; index < num_threads; index++) {\n+    threadInfo* info = (threadInfo*)malloc(sizeof(threadInfo));\n+\n+    info->id = index;\n+    info->dead_lock = dead_lock;\n+    info->dead_cv = dead_cv;\n+    info->alive = &alive;\n+    info->accept_timeout = DEFAULT_ACCEPT_TIMEOUT;\n+\n+    thr = PR_CreateThread(PR_USER_THREAD, thread_main, (void*)info,\n+                          PR_PRIORITY_NORMAL, scope, PR_UNJOINABLE_THREAD, 0);\n+\n+    if (!thr) {\n+      PR_Lock(dead_lock);\n+      alive--;\n+      PR_Unlock(dead_lock);\n     }\n+  }\n \n-    PR_Lock(dead_lock);\n-    while (alive) {\n-        if (debug_mode) {\n-            printf(\"main loop awake; alive = %d\\n\", alive);\n-        }\n-        PR_WaitCondVar(dead_cv, PR_INTERVAL_NO_TIMEOUT);\n+  PR_Lock(dead_lock);\n+  while (alive) {\n+    if (debug_mode) {\n+      printf(\"main loop awake; alive = %d\\n\", alive);\n     }\n-    PR_Unlock(dead_lock);\n+    PR_WaitCondVar(dead_cv, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_Unlock(dead_lock);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRInt32 num_threads;\n-\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  PRInt32 num_threads;\n+\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-\n-    if (argc > 2) {\n-        num_threads = atoi(argv[2]);\n-    } else {\n-        num_threads = NUM_THREADS;\n-    }\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_LOW, 0);\n-\n-    if (debug_mode) {\n-        printf(\"user level test\\n\");\n-    }\n-    thread_test(PR_LOCAL_THREAD, num_threads);\n-\n-    PR_Cleanup();\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+\n+  if (argc > 2) {\n+    num_threads = atoi(argv[2]);\n+  } else {\n+    num_threads = NUM_THREADS;\n+  }\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_LOW, 0);\n+\n+  if (debug_mode) {\n+    printf(\"user level test\\n\");\n+  }\n+  thread_test(PR_LOCAL_THREAD, num_threads);\n+\n+  PR_Cleanup();\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/ioconthr.c b/nspr/pr/tests/ioconthr.c\nindex 6710b06..0a69a21 100644\n--- a/nspr/pr/tests/ioconthr.c\n+++ b/nspr/pr/tests/ioconthr.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -13,102 +14,98 @@\n int num_threads = 10; /* must be an even number */\n PRThreadScope thread_scope = PR_GLOBAL_THREAD;\n \n-void\n-ThreadFunc(void* arg)\n-{\n-    PRFileDesc* fd = (PRFileDesc*)arg;\n-    char buf[1024];\n-    PRInt32 nbytes;\n-    PRErrorCode err;\n+void ThreadFunc(void* arg) {\n+  PRFileDesc* fd = (PRFileDesc*)arg;\n+  char buf[1024];\n+  PRInt32 nbytes;\n+  PRErrorCode err;\n \n-    nbytes = PR_Recv(fd, buf, sizeof(buf), 0, PR_SecondsToInterval(20));\n-    if (nbytes == -1) {\n-        err = PR_GetError();\n-        if (err != PR_PENDING_INTERRUPT_ERROR) {\n-            fprintf(stderr, \"PR_Recv failed: (%d, %d)\\n\", err, PR_GetOSError());\n-            PR_ProcessExit(1);\n-        }\n-        /*\n-         * After getting an I/O interrupt, this thread must\n-         * close the fd before it exits due to a limitation\n-         * of our NT implementation.\n-         */\n-        if (PR_Close(fd) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_Close failed\\n\");\n-            PR_ProcessExit(1);\n-        }\n-    } else {\n-        fprintf(stderr, \"PR_Recv received %d bytes!?\\n\", nbytes);\n-        PR_ProcessExit(1);\n+  nbytes = PR_Recv(fd, buf, sizeof(buf), 0, PR_SecondsToInterval(20));\n+  if (nbytes == -1) {\n+    err = PR_GetError();\n+    if (err != PR_PENDING_INTERRUPT_ERROR) {\n+      fprintf(stderr, \"PR_Recv failed: (%d, %d)\\n\", err, PR_GetOSError());\n+      PR_ProcessExit(1);\n     }\n+    /*\n+     * After getting an I/O interrupt, this thread must\n+     * close the fd before it exits due to a limitation\n+     * of our NT implementation.\n+     */\n+    if (PR_Close(fd) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_Close failed\\n\");\n+      PR_ProcessExit(1);\n+    }\n+  } else {\n+    fprintf(stderr, \"PR_Recv received %d bytes!?\\n\", nbytes);\n+    PR_ProcessExit(1);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc** fds;\n-    PRThread** threads;\n-    PRIntervalTime start, elapsed;\n-    int index;\n+int main(int argc, char** argv) {\n+  PRFileDesc** fds;\n+  PRThread** threads;\n+  PRIntervalTime start, elapsed;\n+  int index;\n \n-    fds = (PRFileDesc**)PR_MALLOC(2 * num_threads * sizeof(PRFileDesc*));\n-    PR_ASSERT(fds != NULL);\n-    threads = (PRThread**)PR_MALLOC(num_threads * sizeof(PRThread*));\n-    PR_ASSERT(threads != NULL);\n+  fds = (PRFileDesc**)PR_MALLOC(2 * num_threads * sizeof(PRFileDesc*));\n+  PR_ASSERT(fds != NULL);\n+  threads = (PRThread**)PR_MALLOC(num_threads * sizeof(PRThread*));\n+  PR_ASSERT(threads != NULL);\n \n-    for (index = 0; index < num_threads; index++) {\n-        if (PR_NewTCPSocketPair(&fds[2 * index]) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-            PR_ProcessExit(1);\n-        }\n-        threads[index] = PR_CreateThread(PR_USER_THREAD, ThreadFunc, fds[2 * index],\n-                                         PR_PRIORITY_NORMAL, thread_scope,\n-                                         PR_JOINABLE_THREAD, 0);\n-        if (NULL == threads[index]) {\n-            fprintf(stderr, \"PR_CreateThread failed\\n\");\n-            PR_ProcessExit(1);\n-        }\n+  for (index = 0; index < num_threads; index++) {\n+    if (PR_NewTCPSocketPair(&fds[2 * index]) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+      PR_ProcessExit(1);\n+    }\n+    threads[index] = PR_CreateThread(PR_USER_THREAD, ThreadFunc, fds[2 * index],\n+                                     PR_PRIORITY_NORMAL, thread_scope,\n+                                     PR_JOINABLE_THREAD, 0);\n+    if (NULL == threads[index]) {\n+      fprintf(stderr, \"PR_CreateThread failed\\n\");\n+      PR_ProcessExit(1);\n     }\n+  }\n \n-    /* Let the threads block in PR_Recv */\n-    PR_Sleep(PR_SecondsToInterval(2));\n+  /* Let the threads block in PR_Recv */\n+  PR_Sleep(PR_SecondsToInterval(2));\n \n-    printf(\"Interrupting the threads\\n\");\n-    fflush(stdout);\n-    start = PR_IntervalNow();\n-    for (index = 0; index < num_threads; index++) {\n-        if (PR_Interrupt(threads[index]) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_Interrupt failed\\n\");\n-            PR_ProcessExit(1);\n-        }\n+  printf(\"Interrupting the threads\\n\");\n+  fflush(stdout);\n+  start = PR_IntervalNow();\n+  for (index = 0; index < num_threads; index++) {\n+    if (PR_Interrupt(threads[index]) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_Interrupt failed\\n\");\n+      PR_ProcessExit(1);\n     }\n-    for (index = 0; index < num_threads; index++) {\n-        if (PR_JoinThread(threads[index]) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_JoinThread failed\\n\");\n-            PR_ProcessExit(1);\n-        }\n+  }\n+  for (index = 0; index < num_threads; index++) {\n+    if (PR_JoinThread(threads[index]) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_JoinThread failed\\n\");\n+      PR_ProcessExit(1);\n     }\n-    elapsed = (PRIntervalTime)(PR_IntervalNow() - start);\n-    printf(\"Threads terminated in %d milliseconds\\n\",\n-           PR_IntervalToMilliseconds(elapsed));\n-    fflush(stdout);\n+  }\n+  elapsed = (PRIntervalTime)(PR_IntervalNow() - start);\n+  printf(\"Threads terminated in %d milliseconds\\n\",\n+         PR_IntervalToMilliseconds(elapsed));\n+  fflush(stdout);\n \n-    /* We are being very generous and allow 10 seconds. */\n-    if (elapsed >= PR_SecondsToInterval(10)) {\n-        fprintf(stderr, \"Interrupting threads took longer than 10 seconds!!\\n\");\n-        PR_ProcessExit(1);\n-    }\n+  /* We are being very generous and allow 10 seconds. */\n+  if (elapsed >= PR_SecondsToInterval(10)) {\n+    fprintf(stderr, \"Interrupting threads took longer than 10 seconds!!\\n\");\n+    PR_ProcessExit(1);\n+  }\n \n-    for (index = 0; index < num_threads; index++) {\n-        /* fds[2 * index] was passed to and closed by threads[index]. */\n-        if (PR_Close(fds[2 * index + 1]) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_Close failed\\n\");\n-            PR_ProcessExit(1);\n-        }\n+  for (index = 0; index < num_threads; index++) {\n+    /* fds[2 * index] was passed to and closed by threads[index]. */\n+    if (PR_Close(fds[2 * index + 1]) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_Close failed\\n\");\n+      PR_ProcessExit(1);\n     }\n-    PR_DELETE(threads);\n-    PR_DELETE(fds);\n-    printf(\"PASS\\n\");\n-    PR_Cleanup();\n-    return 0;\n+  }\n+  PR_DELETE(threads);\n+  PR_DELETE(fds);\n+  printf(\"PASS\\n\");\n+  PR_Cleanup();\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/ipv6.c b/nspr/pr/tests/ipv6.c\nindex b0c1d99..78b0809 100644\n--- a/nspr/pr/tests/ipv6.c\n+++ b/nspr/pr/tests/ipv6.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -22,186 +23,178 @@\n #define HOST_BUFFER 1024\n #define PROTO_BUFFER 1500\n \n-#define NETADDR_SIZE(addr)                                   \\\n-    (PR_AF_INET == (addr)->raw.family ? sizeof((addr)->inet) \\\n-                                      : sizeof((addr)->ipv6))\n+#define NETADDR_SIZE(addr)                                 \\\n+  (PR_AF_INET == (addr)->raw.family ? sizeof((addr)->inet) \\\n+                                    : sizeof((addr)->ipv6))\n \n static PRFileDesc* err = NULL;\n \n-static void\n-Help(void)\n-{\n-    PR_fprintf(err, \"Usage: [-V] [-h]\\n\");\n-    PR_fprintf(err,\n-               \"\\t<nul>    Name of host to lookup          (default: self)\\n\");\n-    PR_fprintf(err,\n-               \"\\t-V       Display runtime version info    (default: FALSE)\\n\");\n-    PR_fprintf(err, \"\\t-h       This message and nothing else\\n\");\n+static void Help(void) {\n+  PR_fprintf(err, \"Usage: [-V] [-h]\\n\");\n+  PR_fprintf(err,\n+             \"\\t<nul>    Name of host to lookup          (default: self)\\n\");\n+  PR_fprintf(err,\n+             \"\\t-V       Display runtime version info    (default: FALSE)\\n\");\n+  PR_fprintf(err, \"\\t-h       This message and nothing else\\n\");\n } /* Help */\n \n-static void\n-DumpAddr(const PRNetAddr* address, const char* msg)\n-{\n-    PRUint32* word = (PRUint32*)address;\n-    PRUint32 addr_len = sizeof(PRNetAddr);\n-    PR_fprintf(err, \"%s[%d]\\t\", msg, NETADDR_SIZE(address));\n-    while (addr_len > 0) {\n-        PR_fprintf(err, \" %08x\", *word++);\n-        addr_len -= sizeof(PRUint32);\n-    }\n-    PR_fprintf(err, \"\\n\");\n+static void DumpAddr(const PRNetAddr* address, const char* msg) {\n+  PRUint32* word = (PRUint32*)address;\n+  PRUint32 addr_len = sizeof(PRNetAddr);\n+  PR_fprintf(err, \"%s[%d]\\t\", msg, NETADDR_SIZE(address));\n+  while (addr_len > 0) {\n+    PR_fprintf(err, \" %08x\", *word++);\n+    addr_len -= sizeof(PRUint32);\n+  }\n+  PR_fprintf(err, \"\\n\");\n } /* DumpAddr */\n \n-static PRStatus\n-PrintAddress(const PRNetAddr* address)\n-{\n-    PRNetAddr translation;\n-    char buffer[ADDR_BUFFER];\n-    PRStatus rv = PR_NetAddrToString(address, buffer, sizeof(buffer));\n+static PRStatus PrintAddress(const PRNetAddr* address) {\n+  PRNetAddr translation;\n+  char buffer[ADDR_BUFFER];\n+  PRStatus rv = PR_NetAddrToString(address, buffer, sizeof(buffer));\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err, \"PR_NetAddrToString\");\n+  } else {\n+    PR_fprintf(err, \"\\t%s\\n\", buffer);\n+    memset(&translation, 0, sizeof(translation));\n+    rv = PR_StringToNetAddr(buffer, &translation);\n     if (PR_FAILURE == rv) {\n-        PL_FPrintError(err, \"PR_NetAddrToString\");\n+      PL_FPrintError(err, \"PR_StringToNetAddr\");\n     } else {\n-        PR_fprintf(err, \"\\t%s\\n\", buffer);\n-        memset(&translation, 0, sizeof(translation));\n-        rv = PR_StringToNetAddr(buffer, &translation);\n-        if (PR_FAILURE == rv) {\n-            PL_FPrintError(err, \"PR_StringToNetAddr\");\n-        } else {\n-            PRSize addr_len = NETADDR_SIZE(address);\n-            if (0 != memcmp(address, &translation, addr_len)) {\n-                PR_fprintf(err, \"Address translations do not match\\n\");\n-                DumpAddr(address, \"original\");\n-                DumpAddr(&translation, \"translate\");\n-                rv = PR_FAILURE;\n-            }\n-        }\n+      PRSize addr_len = NETADDR_SIZE(address);\n+      if (0 != memcmp(address, &translation, addr_len)) {\n+        PR_fprintf(err, \"Address translations do not match\\n\");\n+        DumpAddr(address, \"original\");\n+        DumpAddr(&translation, \"translate\");\n+        rv = PR_FAILURE;\n+      }\n     }\n-    return rv;\n+  }\n+  return rv;\n } /* PrintAddress */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRStatus rv;\n-    PLOptStatus os;\n-    PRHostEnt host;\n-    PRProtoEnt proto;\n-    const char* name = NULL;\n-    PRBool failed = PR_FALSE, version = PR_FALSE;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"Vh\");\n-\n-    err = PR_GetSpecialFD(PR_StandardError);\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 0: /* Name of host to lookup */\n-                name = opt->value;\n-                break;\n-            case 'V': /* Do version discovery */\n-                version = PR_TRUE;\n-                break;\n-            case 'h': /* user wants some guidance */\n-            default:\n-                Help();   /* so give him an earful */\n-                return 2; /* but not a lot else */\n-        }\n+int main(int argc, char** argv) {\n+  PRStatus rv;\n+  PLOptStatus os;\n+  PRHostEnt host;\n+  PRProtoEnt proto;\n+  const char* name = NULL;\n+  PRBool failed = PR_FALSE, version = PR_FALSE;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"Vh\");\n+\n+  err = PR_GetSpecialFD(PR_StandardError);\n+\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 0: /* Name of host to lookup */\n+        name = opt->value;\n+        break;\n+      case 'V': /* Do version discovery */\n+        version = PR_TRUE;\n+        break;\n+      case 'h': /* user wants some guidance */\n+      default:\n+        Help();   /* so give him an earful */\n+        return 2; /* but not a lot else */\n     }\n-    PL_DestroyOptState(opt);\n+  }\n+  PL_DestroyOptState(opt);\n \n-    if (version) {\n+  if (version) {\n #if defined(WINNT)\n-#define NSPR_LIB \"libnspr4\"\n+#  define NSPR_LIB \"libnspr4\"\n #else\n-#define NSPR_LIB \"nspr4\"\n+#  define NSPR_LIB \"nspr4\"\n #endif\n-        const PRVersionDescription* version_info;\n-        char* nspr_path = PR_GetEnv(\"LD_LIBRARY_PATH\");\n-        char* nspr_name = PR_GetLibraryName(nspr_path, NSPR_LIB);\n-        PRLibrary* runtime = PR_LoadLibrary(nspr_name);\n-        if (NULL == runtime) {\n-            PL_FPrintError(err, \"PR_LoadLibrary\");\n-        } else {\n-            versionEntryPointType versionPoint =\n-                (versionEntryPointType)PR_FindSymbol(runtime, \"libVersionPoint\");\n-            if (NULL == versionPoint) {\n-                PL_FPrintError(err, \"PR_FindSymbol\");\n-            } else {\n-                char buffer[100];\n-                PRExplodedTime exploded;\n-                version_info = versionPoint();\n-                (void)PR_fprintf(err, \"Runtime library version information\\n\");\n-                PR_ExplodeTime(version_info->buildTime, PR_GMTParameters, &exploded);\n-                (void)PR_FormatTime(buffer, sizeof(buffer), \"%d %b %Y %H:%M:%S\",\n-                                    &exploded);\n-                (void)PR_fprintf(err, \"  Build time: %s GMT\\n\", buffer);\n-                (void)PR_fprintf(err, \"  Build time: %s\\n\",\n-                                 version_info->buildTimeString);\n-                (void)PR_fprintf(err, \"  %s V%u.%u.%u (%s%s%s)\\n\",\n-                                 version_info->description, version_info->vMajor,\n-                                 version_info->vMinor, version_info->vPatch,\n-                                 (version_info->beta ? \" beta \" : \"\"),\n-                                 (version_info->debug ? \" debug \" : \"\"),\n-                                 (version_info->special ? \" special\" : \"\"));\n-                (void)PR_fprintf(err, \"  filename: %s\\n\", version_info->filename);\n-                (void)PR_fprintf(err, \"  security: %s\\n\", version_info->security);\n-                (void)PR_fprintf(err, \"  copyright: %s\\n\", version_info->copyright);\n-                (void)PR_fprintf(err, \"  comment: %s\\n\", version_info->comment);\n-            }\n-        }\n-        if (NULL != nspr_name) {\n-            PR_FreeLibraryName(nspr_name);\n-        }\n+    const PRVersionDescription* version_info;\n+    char* nspr_path = PR_GetEnv(\"LD_LIBRARY_PATH\");\n+    char* nspr_name = PR_GetLibraryName(nspr_path, NSPR_LIB);\n+    PRLibrary* runtime = PR_LoadLibrary(nspr_name);\n+    if (NULL == runtime) {\n+      PL_FPrintError(err, \"PR_LoadLibrary\");\n+    } else {\n+      versionEntryPointType versionPoint =\n+          (versionEntryPointType)PR_FindSymbol(runtime, \"libVersionPoint\");\n+      if (NULL == versionPoint) {\n+        PL_FPrintError(err, \"PR_FindSymbol\");\n+      } else {\n+        char buffer[100];\n+        PRExplodedTime exploded;\n+        version_info = versionPoint();\n+        (void)PR_fprintf(err, \"Runtime library version information\\n\");\n+        PR_ExplodeTime(version_info->buildTime, PR_GMTParameters, &exploded);\n+        (void)PR_FormatTime(buffer, sizeof(buffer), \"%d %b %Y %H:%M:%S\",\n+                            &exploded);\n+        (void)PR_fprintf(err, \"  Build time: %s GMT\\n\", buffer);\n+        (void)PR_fprintf(err, \"  Build time: %s\\n\",\n+                         version_info->buildTimeString);\n+        (void)PR_fprintf(err, \"  %s V%u.%u.%u (%s%s%s)\\n\",\n+                         version_info->description, version_info->vMajor,\n+                         version_info->vMinor, version_info->vPatch,\n+                         (version_info->beta ? \" beta \" : \"\"),\n+                         (version_info->debug ? \" debug \" : \"\"),\n+                         (version_info->special ? \" special\" : \"\"));\n+        (void)PR_fprintf(err, \"  filename: %s\\n\", version_info->filename);\n+        (void)PR_fprintf(err, \"  security: %s\\n\", version_info->security);\n+        (void)PR_fprintf(err, \"  copyright: %s\\n\", version_info->copyright);\n+        (void)PR_fprintf(err, \"  comment: %s\\n\", version_info->comment);\n+      }\n     }\n-\n-    {\n-        if (NULL == name) {\n-            char* me = (char*)PR_MALLOC(DNS_BUFFER);\n-            rv = PR_GetSystemInfo(PR_SI_HOSTNAME, me, DNS_BUFFER);\n-            if (PR_FAILURE == rv) {\n-                failed = PR_TRUE;\n-                PL_FPrintError(err, \"PR_GetSystemInfo\");\n-                return 2;\n-            }\n-            name = me; /* just leak the storage */\n-        }\n+    if (NULL != nspr_name) {\n+      PR_FreeLibraryName(nspr_name);\n     }\n-\n-    {\n-        char buffer[HOST_BUFFER];\n-        PR_fprintf(err, \"Translating the name %s ...\", name);\n-\n-        rv = PR_GetHostByName(name, buffer, sizeof(buffer), &host);\n-        if (PR_FAILURE == rv) {\n-            failed = PR_TRUE;\n-            PL_FPrintError(err, \"PR_GetHostByName\");\n-        } else {\n-            PRIntn index = 0;\n-            PRNetAddr address;\n-            memset(&address, 0, sizeof(PRNetAddr));\n-            PR_fprintf(err, \"success .. enumerating results\\n\");\n-            do {\n-                index = PR_EnumerateHostEnt(index, &host, 0, &address);\n-                if (index > 0) {\n-                    PrintAddress(&address);\n-                } else if (-1 == index) {\n-                    failed = PR_TRUE;\n-                    PL_FPrintError(err, \"PR_EnumerateHostEnt\");\n-                }\n-            } while (index > 0);\n-        }\n+  }\n+\n+  {\n+    if (NULL == name) {\n+      char* me = (char*)PR_MALLOC(DNS_BUFFER);\n+      rv = PR_GetSystemInfo(PR_SI_HOSTNAME, me, DNS_BUFFER);\n+      if (PR_FAILURE == rv) {\n+        failed = PR_TRUE;\n+        PL_FPrintError(err, \"PR_GetSystemInfo\");\n+        return 2;\n+      }\n+      name = me; /* just leak the storage */\n     }\n+  }\n \n-    {\n-        char buffer[PROTO_BUFFER];\n-        /*\n-        ** Get Proto by name/number\n-        */\n-        rv = PR_GetProtoByName(\"tcp\", &buffer[1], sizeof(buffer) - 1, &proto);\n-        rv = PR_GetProtoByNumber(6, &buffer[3], sizeof(buffer) - 3, &proto);\n-    }\n+  {\n+    char buffer[HOST_BUFFER];\n+    PR_fprintf(err, \"Translating the name %s ...\", name);\n \n-    return (failed) ? 1 : 0;\n+    rv = PR_GetHostByName(name, buffer, sizeof(buffer), &host);\n+    if (PR_FAILURE == rv) {\n+      failed = PR_TRUE;\n+      PL_FPrintError(err, \"PR_GetHostByName\");\n+    } else {\n+      PRIntn index = 0;\n+      PRNetAddr address;\n+      memset(&address, 0, sizeof(PRNetAddr));\n+      PR_fprintf(err, \"success .. enumerating results\\n\");\n+      do {\n+        index = PR_EnumerateHostEnt(index, &host, 0, &address);\n+        if (index > 0) {\n+          PrintAddress(&address);\n+        } else if (-1 == index) {\n+          failed = PR_TRUE;\n+          PL_FPrintError(err, \"PR_EnumerateHostEnt\");\n+        }\n+      } while (index > 0);\n+    }\n+  }\n+\n+  {\n+    char buffer[PROTO_BUFFER];\n+    /*\n+    ** Get Proto by name/number\n+    */\n+    rv = PR_GetProtoByName(\"tcp\", &buffer[1], sizeof(buffer) - 1, &proto);\n+    rv = PR_GetProtoByNumber(6, &buffer[3], sizeof(buffer) - 3, &proto);\n+  }\n+\n+  return (failed) ? 1 : 0;\n }\ndiff --git a/nspr/pr/tests/join.c b/nspr/pr/tests/join.c\nindex 4552915..d2d2fd6 100644\n--- a/nspr/pr/tests/join.c\n+++ b/nspr/pr/tests/join.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -51,15 +52,13 @@\n **\n ***********************************************************************/\n \n-static void\n-Test_Result(int result)\n-{\n-    if (result == PASS) {\n-        printf(\"PASS\\n\");\n-    } else {\n-        printf(\"FAIL\\n\");\n-    }\n-    exit(1);\n+static void Test_Result(int result) {\n+  if (result == PASS) {\n+    printf(\"PASS\\n\");\n+  } else {\n+    printf(\"FAIL\\n\");\n+  }\n+  exit(1);\n }\n \n /*\n@@ -68,177 +67,161 @@ Test_Result(int result)\n     completed.\n */\n \n-static void PR_CALLBACK\n-lowPriority(void* arg)\n-{\n-}\n+static void PR_CALLBACK lowPriority(void* arg) {}\n \n-static void PR_CALLBACK\n-highPriority(void* arg)\n-{\n-}\n+static void PR_CALLBACK highPriority(void* arg) {}\n \n-static void PR_CALLBACK\n-unjoinable(void* arg)\n-{\n-    PR_Sleep(PR_INTERVAL_NO_TIMEOUT);\n+static void PR_CALLBACK unjoinable(void* arg) {\n+  PR_Sleep(PR_INTERVAL_NO_TIMEOUT);\n }\n \n-void\n-runTest(PRThreadScope scope1, PRThreadScope scope2)\n-{\n-    PRThread *low, *high;\n-\n-    /* create the low and high priority threads */\n-\n-    low = PR_CreateThread(PR_USER_THREAD, lowPriority, 0, PR_PRIORITY_LOW, scope1,\n-                          PR_JOINABLE_THREAD, 0);\n-    if (!low) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot create low priority thread\\n\");\n-        } else {\n-            Test_Result(FAIL);\n-        }\n-        return;\n-    }\n+void runTest(PRThreadScope scope1, PRThreadScope scope2) {\n+  PRThread *low, *high;\n \n-    high = PR_CreateThread(PR_USER_THREAD, highPriority, 0, PR_PRIORITY_HIGH,\n-                           scope2, PR_JOINABLE_THREAD, 0);\n-    if (!high) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot create high priority thread\\n\");\n-        } else {\n-            Test_Result(FAIL);\n-        }\n-        return;\n+  /* create the low and high priority threads */\n+\n+  low = PR_CreateThread(PR_USER_THREAD, lowPriority, 0, PR_PRIORITY_LOW, scope1,\n+                        PR_JOINABLE_THREAD, 0);\n+  if (!low) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot create low priority thread\\n\");\n+    } else {\n+      Test_Result(FAIL);\n+    }\n+    return;\n+  }\n+\n+  high = PR_CreateThread(PR_USER_THREAD, highPriority, 0, PR_PRIORITY_HIGH,\n+                         scope2, PR_JOINABLE_THREAD, 0);\n+  if (!high) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot create high priority thread\\n\");\n+    } else {\n+      Test_Result(FAIL);\n     }\n+    return;\n+  }\n \n-    /* Do the joining for both threads */\n-    if (PR_JoinThread(low) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot join low priority thread\\n\");\n-        } else {\n-            Test_Result(FAIL);\n-        }\n-        return;\n+  /* Do the joining for both threads */\n+  if (PR_JoinThread(low) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot join low priority thread\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"\\tjoined low priority thread\\n\");\n-        }\n+      Test_Result(FAIL);\n     }\n-    if (PR_JoinThread(high) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot join high priority thread\\n\");\n-        } else {\n-            Test_Result(FAIL);\n-        }\n-        return;\n+    return;\n+  } else {\n+    if (debug_mode) {\n+      printf(\"\\tjoined low priority thread\\n\");\n+    }\n+  }\n+  if (PR_JoinThread(high) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot join high priority thread\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"\\tjoined high priority thread\\n\");\n-        }\n+      Test_Result(FAIL);\n+    }\n+    return;\n+  } else {\n+    if (debug_mode) {\n+      printf(\"\\tjoined high priority thread\\n\");\n     }\n+  }\n }\n \n-void\n-joinWithUnjoinable(void)\n-{\n-    PRThread* thread;\n-\n-    /* create the unjoinable thread */\n-\n-    thread = PR_CreateThread(PR_USER_THREAD, unjoinable, 0, PR_PRIORITY_NORMAL,\n-                             PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    if (!thread) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot create unjoinable thread\\n\");\n-        } else {\n-            Test_Result(FAIL);\n-        }\n-        return;\n+void joinWithUnjoinable(void) {\n+  PRThread* thread;\n+\n+  /* create the unjoinable thread */\n+\n+  thread = PR_CreateThread(PR_USER_THREAD, unjoinable, 0, PR_PRIORITY_NORMAL,\n+                           PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  if (!thread) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot create unjoinable thread\\n\");\n+    } else {\n+      Test_Result(FAIL);\n     }\n+    return;\n+  }\n \n-    if (PR_JoinThread(thread) == PR_SUCCESS) {\n-        if (debug_mode) {\n-            printf(\"\\tsuccessfully joined with unjoinable thread?!\\n\");\n-        } else {\n-            Test_Result(FAIL);\n-        }\n-        return;\n+  if (PR_JoinThread(thread) == PR_SUCCESS) {\n+    if (debug_mode) {\n+      printf(\"\\tsuccessfully joined with unjoinable thread?!\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"\\tcannot join with unjoinable thread, as expected\\n\");\n-        }\n-        if (PR_GetError() != PR_INVALID_ARGUMENT_ERROR) {\n-            if (debug_mode) {\n-                printf(\"\\tWrong error code\\n\");\n-            } else {\n-                Test_Result(FAIL);\n-            }\n-            return;\n-        }\n+      Test_Result(FAIL);\n     }\n-    if (PR_Interrupt(thread) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot interrupt unjoinable thread\\n\");\n-        } else {\n-            Test_Result(FAIL);\n-        }\n-        return;\n+    return;\n+  } else {\n+    if (debug_mode) {\n+      printf(\"\\tcannot join with unjoinable thread, as expected\\n\");\n+    }\n+    if (PR_GetError() != PR_INVALID_ARGUMENT_ERROR) {\n+      if (debug_mode) {\n+        printf(\"\\tWrong error code\\n\");\n+      } else {\n+        Test_Result(FAIL);\n+      }\n+      return;\n+    }\n+  }\n+  if (PR_Interrupt(thread) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot interrupt unjoinable thread\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"\\tinterrupted unjoinable thread\\n\");\n-        }\n+      Test_Result(FAIL);\n     }\n+    return;\n+  } else {\n+    if (debug_mode) {\n+      printf(\"\\tinterrupted unjoinable thread\\n\");\n+    }\n+  }\n }\n \n-static PRIntn PR_CALLBACK\n-RealMain(int argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+static PRIntn PR_CALLBACK RealMain(int argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-    printf(\"User-User test\\n\");\n-    runTest(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n-    printf(\"User-Kernel test\\n\");\n-    runTest(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n-    printf(\"Kernel-User test\\n\");\n-    runTest(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n-    printf(\"Kernel-Kernel test\\n\");\n-    runTest(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n-    printf(\"Join with unjoinable thread\\n\");\n-    joinWithUnjoinable();\n-\n-    printf(\"PASSED\\n\");\n-\n-    return 0;\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+  printf(\"User-User test\\n\");\n+  runTest(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n+  printf(\"User-Kernel test\\n\");\n+  runTest(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n+  printf(\"Kernel-User test\\n\");\n+  runTest(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n+  printf(\"Kernel-Kernel test\\n\");\n+  runTest(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n+  printf(\"Join with unjoinable thread\\n\");\n+  joinWithUnjoinable();\n+\n+  printf(\"PASSED\\n\");\n+\n+  return 0;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv;\n+int main(int argc, char** argv) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\ndiff --git a/nspr/pr/tests/joinkk.c b/nspr/pr/tests/joinkk.c\nindex 40b62c6..d848ef0 100644\n--- a/nspr/pr/tests/joinkk.c\n+++ b/nspr/pr/tests/joinkk.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -45,118 +46,106 @@ PRIntn debug_mode;\n     completed.\n */\n \n-static void\n-lowPriority(void* arg)\n-{\n-}\n+static void lowPriority(void* arg) {}\n \n-static void\n-highPriority(void* arg)\n-{\n-}\n+static void highPriority(void* arg) {}\n \n-void\n-runTest(PRThreadScope scope1, PRThreadScope scope2)\n-{\n-    PRThread *low, *high;\n-\n-    /* create the low and high priority threads */\n-\n-    low = PR_CreateThread(PR_USER_THREAD, lowPriority, 0, PR_PRIORITY_LOW, scope1,\n-                          PR_JOINABLE_THREAD, 0);\n-    if (!low) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot create low priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n-    }\n+void runTest(PRThreadScope scope1, PRThreadScope scope2) {\n+  PRThread *low, *high;\n \n-    high = PR_CreateThread(PR_USER_THREAD, highPriority, 0, PR_PRIORITY_HIGH,\n-                           scope2, PR_JOINABLE_THREAD, 0);\n-    if (!high) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot create high priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n-    }\n+  /* create the low and high priority threads */\n \n-    /* Do the joining for both threads */\n-    if (PR_JoinThread(low) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot join low priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n+  low = PR_CreateThread(PR_USER_THREAD, lowPriority, 0, PR_PRIORITY_LOW, scope1,\n+                        PR_JOINABLE_THREAD, 0);\n+  if (!low) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot create low priority thread\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"\\tjoined low priority thread\\n\");\n-        }\n+      failed_already = 1;\n     }\n-    if (PR_JoinThread(high) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot join high priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n+    return;\n+  }\n+\n+  high = PR_CreateThread(PR_USER_THREAD, highPriority, 0, PR_PRIORITY_HIGH,\n+                         scope2, PR_JOINABLE_THREAD, 0);\n+  if (!high) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot create high priority thread\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"\\tjoined high priority thread\\n\");\n-        }\n+      failed_already = 1;\n     }\n-}\n+    return;\n+  }\n \n-static PRIntn PR_CALLBACK\n-RealMain(PRIntn argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+  /* Do the joining for both threads */\n+  if (PR_JoinThread(low) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot join low priority thread\\n\");\n+    } else {\n+      failed_already = 1;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-\n+    return;\n+  } else {\n     if (debug_mode) {\n-        printf(\"Kernel-Kernel test\\n\");\n+      printf(\"\\tjoined low priority thread\\n\");\n     }\n-    runTest(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n-\n-    if (failed_already) {\n-        printf(\"FAIL\\n\");\n-        return 1;\n+  }\n+  if (PR_JoinThread(high) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot join high priority thread\\n\");\n     } else {\n-        printf(\"PASS\\n\");\n-        return 0;\n+      failed_already = 1;\n+    }\n+    return;\n+  } else {\n+    if (debug_mode) {\n+      printf(\"\\tjoined high priority thread\\n\");\n+    }\n+  }\n+}\n+\n+static PRIntn PR_CALLBACK RealMain(PRIntn argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+\n+  if (debug_mode) {\n+    printf(\"Kernel-Kernel test\\n\");\n+  }\n+  runTest(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n+\n+  if (failed_already) {\n+    printf(\"FAIL\\n\");\n+    return 1;\n+  } else {\n+    printf(\"PASS\\n\");\n+    return 0;\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv;\n+int main(int argc, char** argv) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\ndiff --git a/nspr/pr/tests/joinku.c b/nspr/pr/tests/joinku.c\nindex 49ae220..013634c 100644\n--- a/nspr/pr/tests/joinku.c\n+++ b/nspr/pr/tests/joinku.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -46,120 +47,108 @@ PRIntn debug_mode;\n     completed.\n */\n \n-static void\n-lowPriority(void* arg)\n-{\n-}\n+static void lowPriority(void* arg) {}\n \n-static void\n-highPriority(void* arg)\n-{\n-}\n+static void highPriority(void* arg) {}\n+\n+void runTest(PRThreadScope scope1, PRThreadScope scope2) {\n+  PRThread *low, *high;\n \n-void\n-runTest(PRThreadScope scope1, PRThreadScope scope2)\n-{\n-    PRThread *low, *high;\n-\n-    /* create the low and high priority threads */\n-\n-    low = PR_CreateThread(PR_USER_THREAD, lowPriority, 0, PR_PRIORITY_LOW, scope1,\n-                          PR_JOINABLE_THREAD, 0);\n-    if (!low) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot create low priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n+  /* create the low and high priority threads */\n+\n+  low = PR_CreateThread(PR_USER_THREAD, lowPriority, 0, PR_PRIORITY_LOW, scope1,\n+                        PR_JOINABLE_THREAD, 0);\n+  if (!low) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot create low priority thread\\n\");\n+    } else {\n+      failed_already = 1;\n     }\n+    return;\n+  }\n \n-    high = PR_CreateThread(PR_USER_THREAD, highPriority, 0, PR_PRIORITY_HIGH,\n-                           scope2, PR_JOINABLE_THREAD, 0);\n-    if (!high) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot create high priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n+  high = PR_CreateThread(PR_USER_THREAD, highPriority, 0, PR_PRIORITY_HIGH,\n+                         scope2, PR_JOINABLE_THREAD, 0);\n+  if (!high) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot create high priority thread\\n\");\n+    } else {\n+      failed_already = 1;\n     }\n+    return;\n+  }\n \n-    /* Do the joining for both threads */\n-    if (PR_JoinThread(low) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot join low priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n+  /* Do the joining for both threads */\n+  if (PR_JoinThread(low) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot join low priority thread\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"\\tjoined low priority thread\\n\");\n-        }\n+      failed_already = 1;\n     }\n-    if (PR_JoinThread(high) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot join high priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n+    return;\n+  } else {\n+    if (debug_mode) {\n+      printf(\"\\tjoined low priority thread\\n\");\n+    }\n+  }\n+  if (PR_JoinThread(high) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot join high priority thread\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"\\tjoined high priority thread\\n\");\n-        }\n+      failed_already = 1;\n     }\n+    return;\n+  } else {\n+    if (debug_mode) {\n+      printf(\"\\tjoined high priority thread\\n\");\n+    }\n+  }\n }\n \n-static PRIntn PR_CALLBACK\n-RealMain(PRIntn argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+static PRIntn PR_CALLBACK RealMain(PRIntn argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n+  }\n+  PL_DestroyOptState(opt);\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    /* main test */\n+  /* main test */\n \n-    if (debug_mode) {\n-        printf(\"Kernel-User test\\n\");\n-    }\n-    runTest(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n+  if (debug_mode) {\n+    printf(\"Kernel-User test\\n\");\n+  }\n+  runTest(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n \n-    if (failed_already) {\n-        printf(\"FAIL\\n\");\n-        return 1;\n-    } else {\n-        printf(\"PASS\\n\");\n-        return 0;\n-    }\n+  if (failed_already) {\n+    printf(\"FAIL\\n\");\n+    return 1;\n+  } else {\n+    printf(\"PASS\\n\");\n+    return 0;\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv;\n+int main(int argc, char** argv) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\ndiff --git a/nspr/pr/tests/joinuk.c b/nspr/pr/tests/joinuk.c\nindex 8b33e47..32304e8 100644\n--- a/nspr/pr/tests/joinuk.c\n+++ b/nspr/pr/tests/joinuk.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -45,120 +46,108 @@ PRIntn debug_mode;\n     completed.\n */\n \n-static void\n-lowPriority(void* arg)\n-{\n-}\n+static void lowPriority(void* arg) {}\n \n-static void\n-highPriority(void* arg)\n-{\n-}\n+static void highPriority(void* arg) {}\n+\n+void runTest(PRThreadScope scope1, PRThreadScope scope2) {\n+  PRThread *low, *high;\n \n-void\n-runTest(PRThreadScope scope1, PRThreadScope scope2)\n-{\n-    PRThread *low, *high;\n-\n-    /* create the low and high priority threads */\n-\n-    low = PR_CreateThread(PR_USER_THREAD, lowPriority, 0, PR_PRIORITY_LOW, scope1,\n-                          PR_JOINABLE_THREAD, 0);\n-    if (!low) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot create low priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n+  /* create the low and high priority threads */\n+\n+  low = PR_CreateThread(PR_USER_THREAD, lowPriority, 0, PR_PRIORITY_LOW, scope1,\n+                        PR_JOINABLE_THREAD, 0);\n+  if (!low) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot create low priority thread\\n\");\n+    } else {\n+      failed_already = 1;\n     }\n+    return;\n+  }\n \n-    high = PR_CreateThread(PR_USER_THREAD, highPriority, 0, PR_PRIORITY_HIGH,\n-                           scope2, PR_JOINABLE_THREAD, 0);\n-    if (!high) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot create high priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n+  high = PR_CreateThread(PR_USER_THREAD, highPriority, 0, PR_PRIORITY_HIGH,\n+                         scope2, PR_JOINABLE_THREAD, 0);\n+  if (!high) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot create high priority thread\\n\");\n+    } else {\n+      failed_already = 1;\n     }\n+    return;\n+  }\n \n-    /* Do the joining for both threads */\n-    if (PR_JoinThread(low) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot join low priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n+  /* Do the joining for both threads */\n+  if (PR_JoinThread(low) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot join low priority thread\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"\\tjoined low priority thread\\n\");\n-        }\n+      failed_already = 1;\n     }\n-    if (PR_JoinThread(high) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot join high priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n+    return;\n+  } else {\n+    if (debug_mode) {\n+      printf(\"\\tjoined low priority thread\\n\");\n+    }\n+  }\n+  if (PR_JoinThread(high) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot join high priority thread\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"\\tjoined high priority thread\\n\");\n-        }\n+      failed_already = 1;\n     }\n+    return;\n+  } else {\n+    if (debug_mode) {\n+      printf(\"\\tjoined high priority thread\\n\");\n+    }\n+  }\n }\n \n-static PRIntn PR_CALLBACK\n-RealMain(PRIntn argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+static PRIntn PR_CALLBACK RealMain(PRIntn argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n+  }\n+  PL_DestroyOptState(opt);\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    /* main test */\n+  /* main test */\n \n-    if (debug_mode) {\n-        printf(\"User-Kernel test\\n\");\n-    }\n-    runTest(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n+  if (debug_mode) {\n+    printf(\"User-Kernel test\\n\");\n+  }\n+  runTest(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n \n-    if (failed_already) {\n-        printf(\"FAIL\\n\");\n-        return 1;\n-    } else {\n-        printf(\"PASS\\n\");\n-        return 0;\n-    }\n+  if (failed_already) {\n+    printf(\"FAIL\\n\");\n+    return 1;\n+  } else {\n+    printf(\"PASS\\n\");\n+    return 0;\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv;\n+int main(int argc, char** argv) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\ndiff --git a/nspr/pr/tests/joinuu.c b/nspr/pr/tests/joinuu.c\nindex 259094c..cd3f5b3 100644\n--- a/nspr/pr/tests/joinuu.c\n+++ b/nspr/pr/tests/joinuu.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -46,119 +47,107 @@ PRIntn debug_mode;\n     completed.\n */\n \n-static void\n-lowPriority(void* arg)\n-{\n-}\n+static void lowPriority(void* arg) {}\n \n-static void\n-highPriority(void* arg)\n-{\n-}\n+static void highPriority(void* arg) {}\n \n-void\n-runTest(PRThreadScope scope1, PRThreadScope scope2)\n-{\n-    PRThread *low, *high;\n-\n-    /* create the low and high priority threads */\n-\n-    low = PR_CreateThread(PR_USER_THREAD, lowPriority, 0, PR_PRIORITY_LOW, scope1,\n-                          PR_JOINABLE_THREAD, 0);\n-    if (!low) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot create low priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n-    }\n+void runTest(PRThreadScope scope1, PRThreadScope scope2) {\n+  PRThread *low, *high;\n \n-    high = PR_CreateThread(PR_USER_THREAD, highPriority, 0, PR_PRIORITY_HIGH,\n-                           scope2, PR_JOINABLE_THREAD, 0);\n-    if (!high) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot create high priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n-    }\n+  /* create the low and high priority threads */\n \n-    /* Do the joining for both threads */\n-    if (PR_JoinThread(low) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot join low priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n+  low = PR_CreateThread(PR_USER_THREAD, lowPriority, 0, PR_PRIORITY_LOW, scope1,\n+                        PR_JOINABLE_THREAD, 0);\n+  if (!low) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot create low priority thread\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"\\tjoined low priority thread\\n\");\n-        }\n+      failed_already = 1;\n     }\n-    if (PR_JoinThread(high) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tcannot join high priority thread\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        return;\n+    return;\n+  }\n+\n+  high = PR_CreateThread(PR_USER_THREAD, highPriority, 0, PR_PRIORITY_HIGH,\n+                         scope2, PR_JOINABLE_THREAD, 0);\n+  if (!high) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot create high priority thread\\n\");\n     } else {\n-        if (debug_mode) {\n-            printf(\"\\tjoined high priority thread\\n\");\n-        }\n+      failed_already = 1;\n     }\n-}\n+    return;\n+  }\n \n-static PRIntn PR_CALLBACK\n-RealMain(PRIntn argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+  /* Do the joining for both threads */\n+  if (PR_JoinThread(low) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot join low priority thread\\n\");\n+    } else {\n+      failed_already = 1;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    /* main test */\n+    return;\n+  } else {\n     if (debug_mode) {\n-        printf(\"User-User test\\n\");\n+      printf(\"\\tjoined low priority thread\\n\");\n     }\n-    runTest(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n-\n-    if (failed_already) {\n-        printf(\"FAIL\\n\");\n-        return 1;\n+  }\n+  if (PR_JoinThread(high) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tcannot join high priority thread\\n\");\n     } else {\n-        printf(\"PASS\\n\");\n-        return 0;\n+      failed_already = 1;\n+    }\n+    return;\n+  } else {\n+    if (debug_mode) {\n+      printf(\"\\tjoined high priority thread\\n\");\n+    }\n+  }\n+}\n+\n+static PRIntn PR_CALLBACK RealMain(PRIntn argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  /* main test */\n+  if (debug_mode) {\n+    printf(\"User-User test\\n\");\n+  }\n+  runTest(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n+\n+  if (failed_already) {\n+    printf(\"FAIL\\n\");\n+    return 1;\n+  } else {\n+    printf(\"PASS\\n\");\n+    return 0;\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv;\n+int main(int argc, char** argv) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\ndiff --git a/nspr/pr/tests/layer.c b/nspr/pr/tests/layer.c\nindex 002dc4a..5325689 100644\n--- a/nspr/pr/tests/layer.c\n+++ b/nspr/pr/tests/layer.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -33,70 +34,63 @@ static PRNetAddr server_address;\n \n static PRIOMethods myMethods;\n \n-typedef enum Verbosity { silent,\n-                         quiet,\n-                         chatty,\n-                         noisy } Verbosity;\n+typedef enum Verbosity { silent, quiet, chatty, noisy } Verbosity;\n \n static PRIntn minor_iterations = 5;\n static PRIntn major_iterations = 1;\n static Verbosity verbosity = quiet;\n \n #ifdef DEBUG\n-#define PORT_INC_DO +100\n+#  define PORT_INC_DO +100\n #else\n-#define PORT_INC_DO\n+#  define PORT_INC_DO\n #endif\n #ifdef IS_64\n-#define PORT_INC_3264 +200\n+#  define PORT_INC_3264 +200\n #else\n-#define PORT_INC_3264\n+#  define PORT_INC_3264\n #endif\n \n static PRUint16 default_port = 12273 PORT_INC_DO PORT_INC_3264;\n \n-static PRFileDesc*\n-PushLayer(PRFileDesc* stack)\n-{\n-    PRFileDesc* layer = PR_CreateIOLayerStub(identity, &myMethods);\n-    PRStatus rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), layer);\n-    if (verbosity > quiet) {\n-        PR_fprintf(logFile, \"Pushed layer(0x%x) onto stack(0x%x)\\n\", layer, stack);\n-    }\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    return stack;\n+static PRFileDesc* PushLayer(PRFileDesc* stack) {\n+  PRFileDesc* layer = PR_CreateIOLayerStub(identity, &myMethods);\n+  PRStatus rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), layer);\n+  if (verbosity > quiet) {\n+    PR_fprintf(logFile, \"Pushed layer(0x%x) onto stack(0x%x)\\n\", layer, stack);\n+  }\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  return stack;\n } /* PushLayer */\n \n-static PRFileDesc*\n-PushNewLayers(PRFileDesc* stack)\n-{\n-    PRDescIdentity tmp_identity;\n-    PRFileDesc* layer;\n-    PRStatus rv;\n-\n-    /* push a dummy layer */\n-    tmp_identity = PR_GetUniqueIdentity(\"Dummy 1\");\n-    layer = PR_CreateIOLayerStub(tmp_identity, PR_GetDefaultIOMethods());\n-    rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), layer);\n-    if (verbosity > quiet)\n-        PR_fprintf(logFile, \"Pushed layer(0x%x) onto stack(0x%x)\\n\", layer, stack);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-\n-    /* push a data processing layer */\n-    layer = PR_CreateIOLayerStub(identity, &myMethods);\n-    rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), layer);\n-    if (verbosity > quiet)\n-        PR_fprintf(logFile, \"Pushed layer(0x%x) onto stack(0x%x)\\n\", layer, stack);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-\n-    /* push another dummy layer */\n-    tmp_identity = PR_GetUniqueIdentity(\"Dummy 2\");\n-    layer = PR_CreateIOLayerStub(tmp_identity, PR_GetDefaultIOMethods());\n-    rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), layer);\n-    if (verbosity > quiet)\n-        PR_fprintf(logFile, \"Pushed layer(0x%x) onto stack(0x%x)\\n\", layer, stack);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    return stack;\n+static PRFileDesc* PushNewLayers(PRFileDesc* stack) {\n+  PRDescIdentity tmp_identity;\n+  PRFileDesc* layer;\n+  PRStatus rv;\n+\n+  /* push a dummy layer */\n+  tmp_identity = PR_GetUniqueIdentity(\"Dummy 1\");\n+  layer = PR_CreateIOLayerStub(tmp_identity, PR_GetDefaultIOMethods());\n+  rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), layer);\n+  if (verbosity > quiet)\n+    PR_fprintf(logFile, \"Pushed layer(0x%x) onto stack(0x%x)\\n\", layer, stack);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+\n+  /* push a data processing layer */\n+  layer = PR_CreateIOLayerStub(identity, &myMethods);\n+  rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), layer);\n+  if (verbosity > quiet)\n+    PR_fprintf(logFile, \"Pushed layer(0x%x) onto stack(0x%x)\\n\", layer, stack);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+\n+  /* push another dummy layer */\n+  tmp_identity = PR_GetUniqueIdentity(\"Dummy 2\");\n+  layer = PR_CreateIOLayerStub(tmp_identity, PR_GetDefaultIOMethods());\n+  rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), layer);\n+  if (verbosity > quiet)\n+    PR_fprintf(logFile, \"Pushed layer(0x%x) onto stack(0x%x)\\n\", layer, stack);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  return stack;\n } /* PushLayer */\n \n #if 0\n@@ -112,362 +106,350 @@ static PRFileDesc *PopLayer(PRFileDesc *stack)\n }  /* PopLayer */\n #endif\n \n-static void PR_CALLBACK\n-Client(void* arg)\n-{\n-    PRStatus rv;\n-    PRUint8 buffer[100];\n-    PRIntn empty_flags = 0;\n-    PRIntn bytes_read, bytes_sent;\n-    PRFileDesc* stack = (PRFileDesc*)arg;\n-\n-    /* Initialize the buffer so that Purify won't complain */\n-    memset(buffer, 0, sizeof(buffer));\n-\n-    rv = PR_Connect(stack, &server_address, PR_INTERVAL_NO_TIMEOUT);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    while (minor_iterations-- > 0) {\n-        bytes_sent = PR_Send(stack, buffer, sizeof(buffer), empty_flags,\n-                             PR_INTERVAL_NO_TIMEOUT);\n-        PR_ASSERT(sizeof(buffer) == bytes_sent);\n-        if (verbosity > chatty) {\n-            PR_fprintf(logFile, \"Client sending %d bytes\\n\", bytes_sent);\n-        }\n-        bytes_read =\n-            PR_Recv(stack, buffer, bytes_sent, empty_flags, PR_INTERVAL_NO_TIMEOUT);\n-        if (verbosity > chatty) {\n-            PR_fprintf(logFile, \"Client receiving %d bytes\\n\", bytes_read);\n-        }\n-        PR_ASSERT(bytes_read == bytes_sent);\n+static void PR_CALLBACK Client(void* arg) {\n+  PRStatus rv;\n+  PRUint8 buffer[100];\n+  PRIntn empty_flags = 0;\n+  PRIntn bytes_read, bytes_sent;\n+  PRFileDesc* stack = (PRFileDesc*)arg;\n+\n+  /* Initialize the buffer so that Purify won't complain */\n+  memset(buffer, 0, sizeof(buffer));\n+\n+  rv = PR_Connect(stack, &server_address, PR_INTERVAL_NO_TIMEOUT);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  while (minor_iterations-- > 0) {\n+    bytes_sent = PR_Send(stack, buffer, sizeof(buffer), empty_flags,\n+                         PR_INTERVAL_NO_TIMEOUT);\n+    PR_ASSERT(sizeof(buffer) == bytes_sent);\n+    if (verbosity > chatty) {\n+      PR_fprintf(logFile, \"Client sending %d bytes\\n\", bytes_sent);\n     }\n-\n-    if (verbosity > quiet) {\n-        PR_fprintf(logFile, \"Client shutting down stack\\n\");\n+    bytes_read =\n+        PR_Recv(stack, buffer, bytes_sent, empty_flags, PR_INTERVAL_NO_TIMEOUT);\n+    if (verbosity > chatty) {\n+      PR_fprintf(logFile, \"Client receiving %d bytes\\n\", bytes_read);\n     }\n+    PR_ASSERT(bytes_read == bytes_sent);\n+  }\n \n-    rv = PR_Shutdown(stack, PR_SHUTDOWN_BOTH);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+  if (verbosity > quiet) {\n+    PR_fprintf(logFile, \"Client shutting down stack\\n\");\n+  }\n+\n+  rv = PR_Shutdown(stack, PR_SHUTDOWN_BOTH);\n+  PR_ASSERT(PR_SUCCESS == rv);\n } /* Client */\n \n-static void PR_CALLBACK\n-Server(void* arg)\n-{\n-    PRStatus rv;\n-    PRUint8 buffer[100];\n-    PRFileDesc* service;\n-    PRUintn empty_flags = 0;\n-    PRIntn bytes_read, bytes_sent;\n-    PRFileDesc* stack = (PRFileDesc*)arg;\n-    PRNetAddr client_address;\n-\n-    service = PR_Accept(stack, &client_address, PR_INTERVAL_NO_TIMEOUT);\n-    if (verbosity > quiet) {\n-        PR_fprintf(logFile, \"Server accepting connection\\n\");\n+static void PR_CALLBACK Server(void* arg) {\n+  PRStatus rv;\n+  PRUint8 buffer[100];\n+  PRFileDesc* service;\n+  PRUintn empty_flags = 0;\n+  PRIntn bytes_read, bytes_sent;\n+  PRFileDesc* stack = (PRFileDesc*)arg;\n+  PRNetAddr client_address;\n+\n+  service = PR_Accept(stack, &client_address, PR_INTERVAL_NO_TIMEOUT);\n+  if (verbosity > quiet) {\n+    PR_fprintf(logFile, \"Server accepting connection\\n\");\n+  }\n+\n+  do {\n+    bytes_read = PR_Recv(service, buffer, sizeof(buffer), empty_flags,\n+                         PR_INTERVAL_NO_TIMEOUT);\n+    if (0 != bytes_read) {\n+      if (verbosity > chatty) {\n+        PR_fprintf(logFile, \"Server receiving %d bytes\\n\", bytes_read);\n+      }\n+      PR_ASSERT(bytes_read > 0);\n+      bytes_sent = PR_Send(service, buffer, bytes_read, empty_flags,\n+                           PR_INTERVAL_NO_TIMEOUT);\n+      if (verbosity > chatty) {\n+        PR_fprintf(logFile, \"Server sending %d bytes\\n\", bytes_sent);\n+      }\n+      PR_ASSERT(bytes_read == bytes_sent);\n     }\n \n-    do {\n-        bytes_read = PR_Recv(service, buffer, sizeof(buffer), empty_flags,\n-                             PR_INTERVAL_NO_TIMEOUT);\n-        if (0 != bytes_read) {\n-            if (verbosity > chatty) {\n-                PR_fprintf(logFile, \"Server receiving %d bytes\\n\", bytes_read);\n-            }\n-            PR_ASSERT(bytes_read > 0);\n-            bytes_sent = PR_Send(service, buffer, bytes_read, empty_flags,\n-                                 PR_INTERVAL_NO_TIMEOUT);\n-            if (verbosity > chatty) {\n-                PR_fprintf(logFile, \"Server sending %d bytes\\n\", bytes_sent);\n-            }\n-            PR_ASSERT(bytes_read == bytes_sent);\n-        }\n+  } while (0 != bytes_read);\n \n-    } while (0 != bytes_read);\n-\n-    if (verbosity > quiet) {\n-        PR_fprintf(logFile, \"Server shutting down and closing stack\\n\");\n-    }\n-    rv = PR_Shutdown(service, PR_SHUTDOWN_BOTH);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    rv = PR_Close(service);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+  if (verbosity > quiet) {\n+    PR_fprintf(logFile, \"Server shutting down and closing stack\\n\");\n+  }\n+  rv = PR_Shutdown(service, PR_SHUTDOWN_BOTH);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  rv = PR_Close(service);\n+  PR_ASSERT(PR_SUCCESS == rv);\n \n } /* Server */\n \n-static PRInt32 PR_CALLBACK\n-MyRecv(PRFileDesc* fd, void* buf, PRInt32 amount,\n-       PRIntn flags, PRIntervalTime timeout)\n-{\n-    char* b = (char*)buf;\n-    PRFileDesc* lo = fd->lower;\n-    PRInt32 rv, readin = 0, request = 0;\n-    rv = lo->methods->recv(lo, &request, sizeof(request), flags, timeout);\n+static PRInt32 PR_CALLBACK MyRecv(PRFileDesc* fd, void* buf, PRInt32 amount,\n+                                  PRIntn flags, PRIntervalTime timeout) {\n+  char* b = (char*)buf;\n+  PRFileDesc* lo = fd->lower;\n+  PRInt32 rv, readin = 0, request = 0;\n+  rv = lo->methods->recv(lo, &request, sizeof(request), flags, timeout);\n+  if (verbosity > chatty)\n+    PR_fprintf(logFile, \"MyRecv sending permission for %d bytes\\n\", request);\n+  if (0 < rv) {\n     if (verbosity > chatty)\n-        PR_fprintf(logFile, \"MyRecv sending permission for %d bytes\\n\", request);\n+      PR_fprintf(logFile, \"MyRecv received permission request for %d bytes\\n\",\n+                 request);\n+    rv = lo->methods->send(lo, &request, sizeof(request), flags, timeout);\n     if (0 < rv) {\n-        if (verbosity > chatty)\n-            PR_fprintf(logFile, \"MyRecv received permission request for %d bytes\\n\",\n-                       request);\n-        rv = lo->methods->send(lo, &request, sizeof(request), flags, timeout);\n-        if (0 < rv) {\n-            if (verbosity > chatty)\n-                PR_fprintf(logFile, \"MyRecv sending permission for %d bytes\\n\",\n-                           request);\n-            while (readin < request) {\n-                rv = lo->methods->recv(lo, b + readin, amount - readin, flags, timeout);\n-                if (rv <= 0) {\n-                    break;\n-                }\n-                if (verbosity > chatty)\n-                    PR_fprintf(logFile, \"MyRecv received %d bytes\\n\", rv);\n-                readin += rv;\n-            }\n-            rv = readin;\n+      if (verbosity > chatty)\n+        PR_fprintf(logFile, \"MyRecv sending permission for %d bytes\\n\",\n+                   request);\n+      while (readin < request) {\n+        rv = lo->methods->recv(lo, b + readin, amount - readin, flags, timeout);\n+        if (rv <= 0) {\n+          break;\n         }\n+        if (verbosity > chatty)\n+          PR_fprintf(logFile, \"MyRecv received %d bytes\\n\", rv);\n+        readin += rv;\n+      }\n+      rv = readin;\n     }\n-    return rv;\n+  }\n+  return rv;\n } /* MyRecv */\n \n-static PRInt32 PR_CALLBACK\n-MySend(PRFileDesc* fd, const void* buf,\n-       PRInt32 amount, PRIntn flags,\n-       PRIntervalTime timeout)\n-{\n-    PRFileDesc* lo = fd->lower;\n-    const char* b = (const char*)buf;\n-    PRInt32 rv, wroteout = 0, request;\n-    if (verbosity > chatty)\n-        PR_fprintf(logFile, \"MySend asking permission to send %d bytes\\n\", amount);\n-    rv = lo->methods->send(lo, &amount, sizeof(amount), flags, timeout);\n+static PRInt32 PR_CALLBACK MySend(PRFileDesc* fd, const void* buf,\n+                                  PRInt32 amount, PRIntn flags,\n+                                  PRIntervalTime timeout) {\n+  PRFileDesc* lo = fd->lower;\n+  const char* b = (const char*)buf;\n+  PRInt32 rv, wroteout = 0, request;\n+  if (verbosity > chatty)\n+    PR_fprintf(logFile, \"MySend asking permission to send %d bytes\\n\", amount);\n+  rv = lo->methods->send(lo, &amount, sizeof(amount), flags, timeout);\n+  if (0 < rv) {\n+    rv = lo->methods->recv(lo, &request, sizeof(request), flags, timeout);\n     if (0 < rv) {\n-        rv = lo->methods->recv(lo, &request, sizeof(request), flags, timeout);\n-        if (0 < rv) {\n-            PR_ASSERT(request == amount);\n-            if (verbosity > chatty)\n-                PR_fprintf(logFile, \"MySend got permission to send %d bytes\\n\",\n-                           request);\n-            while (wroteout < request) {\n-                rv = lo->methods->send(lo, b + wroteout, request - wroteout, flags,\n-                                       timeout);\n-                if (rv <= 0) {\n-                    break;\n-                }\n-                if (verbosity > chatty)\n-                    PR_fprintf(logFile, \"MySend wrote %d bytes\\n\", rv);\n-                wroteout += rv;\n-            }\n-            rv = amount;\n+      PR_ASSERT(request == amount);\n+      if (verbosity > chatty)\n+        PR_fprintf(logFile, \"MySend got permission to send %d bytes\\n\",\n+                   request);\n+      while (wroteout < request) {\n+        rv = lo->methods->send(lo, b + wroteout, request - wroteout, flags,\n+                               timeout);\n+        if (rv <= 0) {\n+          break;\n         }\n+        if (verbosity > chatty)\n+          PR_fprintf(logFile, \"MySend wrote %d bytes\\n\", rv);\n+        wroteout += rv;\n+      }\n+      rv = amount;\n     }\n-    return rv;\n+  }\n+  return rv;\n } /* MySend */\n \n-static Verbosity\n-ChangeVerbosity(Verbosity verbosity, PRIntn delta)\n-{\n-    PRIntn verbage = (PRIntn)verbosity + delta;\n-    if (verbage < (PRIntn)silent) {\n-        verbage = (PRIntn)silent;\n-    } else if (verbage > (PRIntn)noisy) {\n-        verbage = (PRIntn)noisy;\n-    }\n-    return (Verbosity)verbage;\n+static Verbosity ChangeVerbosity(Verbosity verbosity, PRIntn delta) {\n+  PRIntn verbage = (PRIntn)verbosity + delta;\n+  if (verbage < (PRIntn)silent) {\n+    verbage = (PRIntn)silent;\n+  } else if (verbage > (PRIntn)noisy) {\n+    verbage = (PRIntn)noisy;\n+  }\n+  return (Verbosity)verbage;\n } /* ChangeVerbosity */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRStatus rv;\n-    PRIntn mits;\n-    PLOptStatus os;\n-    PRFileDesc *client, *service;\n-    PRFileDesc *client_stack, *service_stack;\n-    PRNetAddr any_address;\n-    const char* server_name = NULL;\n-    const PRIOMethods* stubMethods;\n-    PRThread *client_thread, *server_thread;\n-    PRThreadScope thread_scope = PR_LOCAL_THREAD;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dqGC:c:p:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n+int main(int argc, char** argv) {\n+  PRStatus rv;\n+  PRIntn mits;\n+  PLOptStatus os;\n+  PRFileDesc *client, *service;\n+  PRFileDesc *client_stack, *service_stack;\n+  PRNetAddr any_address;\n+  const char* server_name = NULL;\n+  const PRIOMethods* stubMethods;\n+  PRThread *client_thread, *server_thread;\n+  PRThreadScope thread_scope = PR_LOCAL_THREAD;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dqGC:c:p:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 0:\n+        server_name = opt->value;\n+        break;\n+      case 'd': /* debug mode */\n+        if (verbosity < noisy) {\n+          verbosity = ChangeVerbosity(verbosity, 1);\n         }\n-        switch (opt->option) {\n-            case 0:\n-                server_name = opt->value;\n-                break;\n-            case 'd': /* debug mode */\n-                if (verbosity < noisy) {\n-                    verbosity = ChangeVerbosity(verbosity, 1);\n-                }\n-                break;\n-            case 'q': /* debug mode */\n-                if (verbosity > silent) {\n-                    verbosity = ChangeVerbosity(verbosity, -1);\n-                }\n-                break;\n-            case 'G': /* use global threads */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'C': /* number of threads waiting */\n-                major_iterations = atoi(opt->value);\n-                break;\n-            case 'c': /* number of client threads */\n-                minor_iterations = atoi(opt->value);\n-                break;\n-            case 'p': /* default port */\n-                default_port = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n+        break;\n+      case 'q': /* debug mode */\n+        if (verbosity > silent) {\n+          verbosity = ChangeVerbosity(verbosity, -1);\n         }\n+        break;\n+      case 'G': /* use global threads */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'C': /* number of threads waiting */\n+        major_iterations = atoi(opt->value);\n+        break;\n+      case 'c': /* number of client threads */\n+        minor_iterations = atoi(opt->value);\n+        break;\n+      case 'p': /* default port */\n+        default_port = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    logFile = PR_GetSpecialFD(PR_StandardError);\n-\n-    identity = PR_GetUniqueIdentity(\"Dummy\");\n-    stubMethods = PR_GetDefaultIOMethods();\n-\n-    /*\n-    ** The protocol we're going to implement is one where in order to initiate\n-    ** a send, the sender must first solicit permission. Therefore, every\n-    ** send is really a send - receive - send sequence.\n-    */\n-    myMethods = *stubMethods; /* first get the entire batch */\n-    myMethods.recv = MyRecv;  /* then override the ones we care about */\n-    myMethods.send = MySend;  /* then override the ones we care about */\n-\n-    if (NULL == server_name)\n-        rv = PR_InitializeNetAddr(PR_IpAddrLoopback, default_port, &server_address);\n-    else {\n-        rv = PR_StringToNetAddr(server_name, &server_address);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_InitializeNetAddr(PR_IpAddrNull, default_port, &server_address);\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  logFile = PR_GetSpecialFD(PR_StandardError);\n+\n+  identity = PR_GetUniqueIdentity(\"Dummy\");\n+  stubMethods = PR_GetDefaultIOMethods();\n+\n+  /*\n+  ** The protocol we're going to implement is one where in order to initiate\n+  ** a send, the sender must first solicit permission. Therefore, every\n+  ** send is really a send - receive - send sequence.\n+  */\n+  myMethods = *stubMethods; /* first get the entire batch */\n+  myMethods.recv = MyRecv;  /* then override the ones we care about */\n+  myMethods.send = MySend;  /* then override the ones we care about */\n+\n+  if (NULL == server_name)\n+    rv = PR_InitializeNetAddr(PR_IpAddrLoopback, default_port, &server_address);\n+  else {\n+    rv = PR_StringToNetAddr(server_name, &server_address);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_InitializeNetAddr(PR_IpAddrNull, default_port, &server_address);\n+  }\n+  PR_ASSERT(PR_SUCCESS == rv);\n+\n+  /* one type w/o layering */\n+\n+  mits = minor_iterations;\n+  while (major_iterations-- > 0) {\n+    if (verbosity > silent) {\n+      PR_fprintf(logFile, \"Beginning non-layered test\\n\");\n     }\n+    client = PR_NewTCPSocket();\n+    PR_ASSERT(NULL != client);\n+    service = PR_NewTCPSocket();\n+    PR_ASSERT(NULL != service);\n+    rv = PR_InitializeNetAddr(PR_IpAddrAny, default_port, &any_address);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Bind(service, &any_address);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Listen(service, 10);\n     PR_ASSERT(PR_SUCCESS == rv);\n \n-    /* one type w/o layering */\n+    minor_iterations = mits;\n+    server_thread =\n+        PR_CreateThread(PR_USER_THREAD, Server, service, PR_PRIORITY_HIGH,\n+                        thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n+    PR_ASSERT(NULL != server_thread);\n \n-    mits = minor_iterations;\n-    while (major_iterations-- > 0) {\n-        if (verbosity > silent) {\n-            PR_fprintf(logFile, \"Beginning non-layered test\\n\");\n-        }\n-        client = PR_NewTCPSocket();\n-        PR_ASSERT(NULL != client);\n-        service = PR_NewTCPSocket();\n-        PR_ASSERT(NULL != service);\n-        rv = PR_InitializeNetAddr(PR_IpAddrAny, default_port, &any_address);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Bind(service, &any_address);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Listen(service, 10);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-\n-        minor_iterations = mits;\n-        server_thread =\n-            PR_CreateThread(PR_USER_THREAD, Server, service, PR_PRIORITY_HIGH,\n-                            thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n-        PR_ASSERT(NULL != server_thread);\n-\n-        client_thread =\n-            PR_CreateThread(PR_USER_THREAD, Client, client, PR_PRIORITY_NORMAL,\n-                            thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n-        PR_ASSERT(NULL != client_thread);\n-\n-        rv = PR_JoinThread(client_thread);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_JoinThread(server_thread);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-\n-        rv = PR_Close(client);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Close(service);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        if (verbosity > silent) {\n-            PR_fprintf(logFile, \"Ending non-layered test\\n\");\n-        }\n+    client_thread =\n+        PR_CreateThread(PR_USER_THREAD, Client, client, PR_PRIORITY_NORMAL,\n+                        thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n+    PR_ASSERT(NULL != client_thread);\n \n-        /* with layering */\n-        if (verbosity > silent) {\n-            PR_fprintf(logFile, \"Beginning layered test\\n\");\n-        }\n-        client = PR_NewTCPSocket();\n-        PR_ASSERT(NULL != client);\n-        PushLayer(client);\n-        service = PR_NewTCPSocket();\n-        PR_ASSERT(NULL != service);\n-        PushLayer(service);\n-        rv = PR_InitializeNetAddr(PR_IpAddrAny, default_port, &any_address);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Bind(service, &any_address);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Listen(service, 10);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-\n-        minor_iterations = mits;\n-        server_thread =\n-            PR_CreateThread(PR_USER_THREAD, Server, service, PR_PRIORITY_HIGH,\n-                            thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n-        PR_ASSERT(NULL != server_thread);\n-\n-        client_thread =\n-            PR_CreateThread(PR_USER_THREAD, Client, client, PR_PRIORITY_NORMAL,\n-                            thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n-        PR_ASSERT(NULL != client_thread);\n-\n-        rv = PR_JoinThread(client_thread);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_JoinThread(server_thread);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-\n-        rv = PR_Close(client);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Close(service);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        /* with layering, using new style stack */\n-        if (verbosity > silent)\n-            PR_fprintf(logFile, \"Beginning layered test with new style stack\\n\");\n-        client = PR_NewTCPSocket();\n-        PR_ASSERT(NULL != client);\n-        client_stack = PR_CreateIOLayer(client);\n-        PushNewLayers(client_stack);\n-        service = PR_NewTCPSocket();\n-        PR_ASSERT(NULL != service);\n-        service_stack = PR_CreateIOLayer(service);\n-        PushNewLayers(service_stack);\n-        rv = PR_InitializeNetAddr(PR_IpAddrAny, default_port, &any_address);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Bind(service, &any_address);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Listen(service, 10);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-\n-        minor_iterations = mits;\n-        server_thread =\n-            PR_CreateThread(PR_USER_THREAD, Server, service_stack, PR_PRIORITY_HIGH,\n-                            thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n-        PR_ASSERT(NULL != server_thread);\n-\n-        client_thread = PR_CreateThread(PR_USER_THREAD, Client, client_stack,\n-                                        PR_PRIORITY_NORMAL, thread_scope,\n-                                        PR_JOINABLE_THREAD, 16 * 1024);\n-        PR_ASSERT(NULL != client_thread);\n-\n-        rv = PR_JoinThread(client_thread);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_JoinThread(server_thread);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-\n-        rv = PR_Close(client_stack);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Close(service_stack);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        if (verbosity > silent) {\n-            PR_fprintf(logFile, \"Ending layered test\\n\");\n-        }\n+    rv = PR_JoinThread(client_thread);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_JoinThread(server_thread);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+\n+    rv = PR_Close(client);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Close(service);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    if (verbosity > silent) {\n+      PR_fprintf(logFile, \"Ending non-layered test\\n\");\n+    }\n+\n+    /* with layering */\n+    if (verbosity > silent) {\n+      PR_fprintf(logFile, \"Beginning layered test\\n\");\n+    }\n+    client = PR_NewTCPSocket();\n+    PR_ASSERT(NULL != client);\n+    PushLayer(client);\n+    service = PR_NewTCPSocket();\n+    PR_ASSERT(NULL != service);\n+    PushLayer(service);\n+    rv = PR_InitializeNetAddr(PR_IpAddrAny, default_port, &any_address);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Bind(service, &any_address);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Listen(service, 10);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+\n+    minor_iterations = mits;\n+    server_thread =\n+        PR_CreateThread(PR_USER_THREAD, Server, service, PR_PRIORITY_HIGH,\n+                        thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n+    PR_ASSERT(NULL != server_thread);\n+\n+    client_thread =\n+        PR_CreateThread(PR_USER_THREAD, Client, client, PR_PRIORITY_NORMAL,\n+                        thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n+    PR_ASSERT(NULL != client_thread);\n+\n+    rv = PR_JoinThread(client_thread);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_JoinThread(server_thread);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+\n+    rv = PR_Close(client);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Close(service);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    /* with layering, using new style stack */\n+    if (verbosity > silent)\n+      PR_fprintf(logFile, \"Beginning layered test with new style stack\\n\");\n+    client = PR_NewTCPSocket();\n+    PR_ASSERT(NULL != client);\n+    client_stack = PR_CreateIOLayer(client);\n+    PushNewLayers(client_stack);\n+    service = PR_NewTCPSocket();\n+    PR_ASSERT(NULL != service);\n+    service_stack = PR_CreateIOLayer(service);\n+    PushNewLayers(service_stack);\n+    rv = PR_InitializeNetAddr(PR_IpAddrAny, default_port, &any_address);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Bind(service, &any_address);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Listen(service, 10);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+\n+    minor_iterations = mits;\n+    server_thread =\n+        PR_CreateThread(PR_USER_THREAD, Server, service_stack, PR_PRIORITY_HIGH,\n+                        thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n+    PR_ASSERT(NULL != server_thread);\n+\n+    client_thread = PR_CreateThread(PR_USER_THREAD, Client, client_stack,\n+                                    PR_PRIORITY_NORMAL, thread_scope,\n+                                    PR_JOINABLE_THREAD, 16 * 1024);\n+    PR_ASSERT(NULL != client_thread);\n+\n+    rv = PR_JoinThread(client_thread);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_JoinThread(server_thread);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+\n+    rv = PR_Close(client_stack);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Close(service_stack);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    if (verbosity > silent) {\n+      PR_fprintf(logFile, \"Ending layered test\\n\");\n     }\n-    return 0;\n+  }\n+  return 0;\n } /* main */\n \n /* layer.c */\ndiff --git a/nspr/pr/tests/lazyinit.c b/nspr/pr/tests/lazyinit.c\nindex 1d28a27..bd1229d 100644\n--- a/nspr/pr/tests/lazyinit.c\n+++ b/nspr/pr/tests/lazyinit.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -29,111 +30,82 @@\n #include <stdio.h>\n #include <stdlib.h>\n \n-static void PR_CALLBACK\n-lazyEntry(void* arg)\n-{\n-    PR_ASSERT(NULL == arg);\n+static void PR_CALLBACK lazyEntry(void* arg) {\n+  PR_ASSERT(NULL == arg);\n } /* lazyEntry */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRUintn pdkey;\n-    PRStatus status;\n-    char* path = NULL;\n-    PRDir* dir = NULL;\n-    PRLock* ml = NULL;\n-    PRCondVar* cv = NULL;\n-    PRThread* thread = NULL;\n-    PRIntervalTime interval = 0;\n-    PRFileDesc *file, *udp, *tcp, *pair[2];\n-    PRIntn test;\n-\n-    if (argc < 2) {\n-        test = 0;\n-    } else {\n-        test = atoi(argv[1]);\n-    }\n-\n-    switch (test) {\n-        case 0:\n-            ml = PR_NewLock();\n-            /* The lazy initialization has already happened; releasing the lock\n-             * afterwards keeps the test leak-free without defeating its purpose.\n-             */\n-            if (ml != NULL) {\n-                PR_DestroyLock(ml);\n-            }\n-            break;\n-\n-        case 1:\n-            interval = PR_SecondsToInterval(1);\n-            break;\n-\n-        case 2:\n-            thread =\n-                PR_CreateThread(PR_USER_THREAD, lazyEntry, NULL, PR_PRIORITY_NORMAL,\n-                                PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-            if (thread != NULL) {\n-                (void)PR_JoinThread(thread);\n-            }\n-            break;\n-\n-        case 3:\n-            file = PR_Open(\"./tmp-\", PR_RDONLY, 0);\n-            if (file != NULL) {\n-                PR_Close(file);\n-            }\n-            break;\n-\n-        case 4:\n-            udp = PR_NewUDPSocket();\n-            if (udp != NULL) {\n-                PR_Close(udp);\n-            }\n-            break;\n-\n-        case 5:\n-            tcp = PR_NewTCPSocket();\n-            if (tcp != NULL) {\n-                PR_Close(tcp);\n-            }\n-            break;\n-\n-        case 6:\n-            dir = PR_OpenDir(\"./tmp-\");\n-            if (dir != NULL) {\n-                PR_CloseDir(dir);\n-            }\n-            break;\n-\n-        case 7:\n-            (void)PR_NewThreadPrivateIndex(&pdkey, NULL);\n-            break;\n-\n-        case 8:\n-            path = PR_GetEnv(\"PATH\");\n-            break;\n-\n-        case 9:\n-            status = PR_NewTCPSocketPair(pair);\n-            if (status == PR_SUCCESS) {\n-                PR_Close(pair[0]);\n-                PR_Close(pair[1]);\n-            }\n-            break;\n-\n-        case 10:\n-            PR_SetConcurrency(2);\n-            break;\n-\n-        default:\n-            printf(\"lazyinit: unrecognized command line argument: %s\\n\", argv[1]);\n-            printf(\"FAIL\\n\");\n-            exit(1);\n-            break;\n-    } /* switch() */\n-    return 0;\n+int main(int argc, char** argv) {\n+  PRUintn pdkey;\n+  PRStatus status;\n+  char* path = NULL;\n+  PRDir* dir = NULL;\n+  PRLock* ml = NULL;\n+  PRCondVar* cv = NULL;\n+  PRThread* thread = NULL;\n+  PRIntervalTime interval = 0;\n+  PRFileDesc *file, *udp, *tcp, *pair[2];\n+  PRIntn test;\n+\n+  if (argc < 2) {\n+    test = 0;\n+  } else {\n+    test = atoi(argv[1]);\n+  }\n+\n+  switch (test) {\n+    case 0:\n+      ml = PR_NewLock();\n+      break;\n+\n+    case 1:\n+      interval = PR_SecondsToInterval(1);\n+      break;\n+\n+    case 2:\n+      thread =\n+          PR_CreateThread(PR_USER_THREAD, lazyEntry, NULL, PR_PRIORITY_NORMAL,\n+                          PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+      break;\n+\n+    case 3:\n+      file = PR_Open(\"./tmp-\", PR_RDONLY, 0);\n+      break;\n+\n+    case 4:\n+      udp = PR_NewUDPSocket();\n+      break;\n+\n+    case 5:\n+      tcp = PR_NewTCPSocket();\n+      break;\n+\n+    case 6:\n+      dir = PR_OpenDir(\"./tmp-\");\n+      break;\n+\n+    case 7:\n+      (void)PR_NewThreadPrivateIndex(&pdkey, NULL);\n+      break;\n+\n+    case 8:\n+      path = PR_GetEnv(\"PATH\");\n+      break;\n+\n+    case 9:\n+      status = PR_NewTCPSocketPair(pair);\n+      break;\n+\n+    case 10:\n+      PR_SetConcurrency(2);\n+      break;\n+\n+    default:\n+      printf(\"lazyinit: unrecognized command line argument: %s\\n\", argv[1]);\n+      printf(\"FAIL\\n\");\n+      exit(1);\n+      break;\n+  } /* switch() */\n+  return 0;\n } /* Lazy */\n \n /* lazyinit.c */\ndiff --git a/nspr/pr/tests/libfilename.c b/nspr/pr/tests/libfilename.c\nindex b40c55b..590abd0 100644\n--- a/nspr/pr/tests/libfilename.c\n+++ b/nspr/pr/tests/libfilename.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -18,85 +19,81 @@\n \n PRBool debug_mode = PR_FALSE;\n \n-static PRStatus\n-RunTest(const char* name, PRFuncPtr addr)\n-{\n-    char* pathname;\n-    PRFileDesc* fd;\n+static PRStatus RunTest(const char* name, PRFuncPtr addr) {\n+  char* pathname;\n+  PRFileDesc* fd;\n \n-    pathname = PR_GetLibraryFilePathname(name, addr);\n-    if (pathname == NULL) {\n-        fprintf(stderr, \"PR_GetLibraryFilePathname failed\\n\");\n-        /* we let this test pass if this function is not implemented */\n-        if (PR_GetError() == PR_NOT_IMPLEMENTED_ERROR) {\n-            return PR_SUCCESS;\n-        }\n-        return PR_FAILURE;\n+  pathname = PR_GetLibraryFilePathname(name, addr);\n+  if (pathname == NULL) {\n+    fprintf(stderr, \"PR_GetLibraryFilePathname failed\\n\");\n+    /* we let this test pass if this function is not implemented */\n+    if (PR_GetError() == PR_NOT_IMPLEMENTED_ERROR) {\n+      return PR_SUCCESS;\n     }\n+    return PR_FAILURE;\n+  }\n \n-    if (debug_mode) {\n-        printf(\"Pathname is %s\\n\", pathname);\n-    }\n-    fd = PR_OpenFile(pathname, PR_RDONLY, 0);\n-    if (fd == NULL) {\n-        fprintf(stderr, \"PR_Open failed: %d\\n\", (int)PR_GetError());\n-        return PR_FAILURE;\n-    }\n-    if (PR_Close(fd) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed: %d\\n\", (int)PR_GetError());\n-        return PR_FAILURE;\n-    }\n-    PR_Free(pathname);\n-    return PR_SUCCESS;\n+  if (debug_mode) {\n+    printf(\"Pathname is %s\\n\", pathname);\n+  }\n+  fd = PR_OpenFile(pathname, PR_RDONLY, 0);\n+  if (fd == NULL) {\n+    fprintf(stderr, \"PR_Open failed: %d\\n\", (int)PR_GetError());\n+    return PR_FAILURE;\n+  }\n+  if (PR_Close(fd) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed: %d\\n\", (int)PR_GetError());\n+    return PR_FAILURE;\n+  }\n+  PR_Free(pathname);\n+  return PR_SUCCESS;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    char* name;\n-    PRFuncPtr addr;\n-    PRLibrary* lib;\n-    PRBool failed = PR_FALSE;\n+int main(int argc, char** argv) {\n+  char* name;\n+  PRFuncPtr addr;\n+  PRLibrary* lib;\n+  PRBool failed = PR_FALSE;\n \n-    if (argc >= 2 && strcmp(argv[1], \"-d\") == 0) {\n-        debug_mode = PR_TRUE;\n-    }\n+  if (argc >= 2 && strcmp(argv[1], \"-d\") == 0) {\n+    debug_mode = PR_TRUE;\n+  }\n \n-    /* First test a library that is implicitly linked. */\n+  /* First test a library that is implicitly linked. */\n #ifdef WINNT\n-    name = PR_Malloc(strlen(\"libnspr4.dll\") + 1);\n-    strcpy(name, \"libnspr4.dll\");\n+  name = PR_Malloc(strlen(\"libnspr4.dll\") + 1);\n+  strcpy(name, \"libnspr4.dll\");\n #else\n-    name = PR_GetLibraryName(NULL, \"nspr4\");\n+  name = PR_GetLibraryName(NULL, \"nspr4\");\n #endif\n-    addr = (PRFuncPtr)PR_GetTCPMethods()->close;\n-    if (RunTest(name, addr) == PR_FAILURE) {\n-        failed = PR_TRUE;\n-    }\n-    PR_FreeLibraryName(name);\n+  addr = (PRFuncPtr)PR_GetTCPMethods()->close;\n+  if (RunTest(name, addr) == PR_FAILURE) {\n+    failed = PR_TRUE;\n+  }\n+  PR_FreeLibraryName(name);\n \n-    /* Next test a library that is dynamically loaded. */\n-    name = PR_GetLibraryName(\"dll\", \"my\");\n-    if (debug_mode) {\n-        printf(\"Loading library %s\\n\", name);\n-    }\n-    lib = PR_LoadLibrary(name);\n-    if (!lib) {\n-        fprintf(stderr, \"PR_LoadLibrary failed\\n\");\n-        exit(1);\n-    }\n-    PR_FreeLibraryName(name);\n-    name = PR_GetLibraryName(NULL, \"my\");\n-    addr = PR_FindFunctionSymbol(lib, \"My_GetValue\");\n-    if (RunTest(name, addr) == PR_FAILURE) {\n-        failed = PR_TRUE;\n-    }\n-    PR_FreeLibraryName(name);\n-    PR_UnloadLibrary(lib);\n-    if (failed) {\n-        printf(\"FAIL\\n\");\n-        return 1;\n-    }\n-    printf(\"PASS\\n\");\n-    return 0;\n+  /* Next test a library that is dynamically loaded. */\n+  name = PR_GetLibraryName(\"dll\", \"my\");\n+  if (debug_mode) {\n+    printf(\"Loading library %s\\n\", name);\n+  }\n+  lib = PR_LoadLibrary(name);\n+  if (!lib) {\n+    fprintf(stderr, \"PR_LoadLibrary failed\\n\");\n+    exit(1);\n+  }\n+  PR_FreeLibraryName(name);\n+  name = PR_GetLibraryName(NULL, \"my\");\n+  addr = PR_FindFunctionSymbol(lib, \"My_GetValue\");\n+  if (RunTest(name, addr) == PR_FAILURE) {\n+    failed = PR_TRUE;\n+  }\n+  PR_FreeLibraryName(name);\n+  PR_UnloadLibrary(lib);\n+  if (failed) {\n+    printf(\"FAIL\\n\");\n+    return 1;\n+  }\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/lltest.c b/nspr/pr/tests/lltest.c\nindex d25417a..fd8079c 100644\n--- a/nspr/pr/tests/lltest.c\n+++ b/nspr/pr/tests/lltest.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -39,8 +40,7 @@\n \n /* --- Local Definitions --- */\n #define ReportProgress(m) \\\n-    if (verboseMode)      \\\n-        PR_fprintf(output, (m));\n+  if (verboseMode) PR_fprintf(output, (m));\n \n /* --- Global variables --- */\n static PRIntn failedAlready = 0;\n@@ -89,580 +89,566 @@ const PRInt32 sixtyThree = 63l;\n ** SetFailed() -- Report individual test failure\n **\n */\n-static void\n-SetFailed(char* what, char* how)\n-{\n-    failedAlready = 1;\n-    if (debugMode) {\n-        PR_fprintf(output, \"%s: failed: %s\\n\", what, how);\n-    }\n-    return;\n+static void SetFailed(char* what, char* how) {\n+  failedAlready = 1;\n+  if (debugMode) {\n+    PR_fprintf(output, \"%s: failed: %s\\n\", what, how);\n+  }\n+  return;\n }\n \n-static void\n-ResultFailed(char* what, char* how, PRInt64 expected, PRInt64 got)\n-{\n-    if (debugMode) {\n-        SetFailed(what, how);\n-        PR_fprintf(output, \"Expected: 0x%llx   Got: 0x%llx\\n\", expected, got);\n-    }\n-    return;\n+static void ResultFailed(char* what, char* how, PRInt64 expected, PRInt64 got) {\n+  if (debugMode) {\n+    SetFailed(what, how);\n+    PR_fprintf(output, \"Expected: 0x%llx   Got: 0x%llx\\n\", expected, got);\n+  }\n+  return;\n }\n \n /*\n ** TestAssignment() -- Test the assignment\n */\n-static void\n-TestAssignment(void)\n-{\n-    PRInt64 zero = LL_Zero();\n-    PRInt64 min = LL_MinInt();\n-    PRInt64 max = LL_MaxInt();\n-    if (!LL_EQ(zero, bigZero)) {\n-        SetFailed(\"LL_EQ(zero, bigZero)\", \"!=\");\n-    }\n-    if (!LL_CMP(max, >, min)) {\n-        SetFailed(\"LL_CMP(max, >, min)\", \"!>\");\n-    }\n+static void TestAssignment(void) {\n+  PRInt64 zero = LL_Zero();\n+  PRInt64 min = LL_MinInt();\n+  PRInt64 max = LL_MaxInt();\n+  if (!LL_EQ(zero, bigZero)) {\n+    SetFailed(\"LL_EQ(zero, bigZero)\", \"!=\");\n+  }\n+  if (!LL_CMP(max, >, min)) {\n+    SetFailed(\"LL_CMP(max, >, min)\", \"!>\");\n+  }\n }\n \n /*\n ** TestComparisons() -- Test the longlong comparison operations\n */\n-static void\n-TestComparisons(void)\n-{\n-    ReportProgress(\"Testing Comparisons Operations\\n\");\n-\n-    /* test for zero */\n-    if (!LL_IS_ZERO(bigZero)) {\n-        SetFailed(\"LL_IS_ZERO\", \"Zero is not zero\");\n-    }\n-\n-    if (LL_IS_ZERO(bigOne)) {\n-        SetFailed(\"LL_IS_ZERO\", \"One tests as zero\");\n-    }\n-\n-    if (LL_IS_ZERO(bigMinusOne)) {\n-        SetFailed(\"LL_IS_ZERO\", \"Minus One tests as zero\");\n-    }\n-\n-    /* test equal */\n-    if (!LL_EQ(bigZero, bigZero)) {\n-        SetFailed(\"LL_EQ\", \"zero EQ zero\");\n-    }\n-\n-    if (!LL_EQ(bigOne, bigOne)) {\n-        SetFailed(\"LL_EQ\", \"one EQ one\");\n-    }\n-\n-    if (!LL_EQ(bigNumber, bigNumber)) {\n-        SetFailed(\"LL_EQ\", \"bigNumber EQ bigNumber\");\n-    }\n-\n-    if (!LL_EQ(bigMinusOne, bigMinusOne)) {\n-        SetFailed(\"LL_EQ\", \"minus one EQ minus one\");\n-    }\n-\n-    if (LL_EQ(bigZero, bigOne)) {\n-        SetFailed(\"LL_EQ\", \"zero EQ one\");\n-    }\n-\n-    if (LL_EQ(bigOne, bigZero)) {\n-        SetFailed(\"LL_EQ\", \"one EQ zero\");\n-    }\n-\n-    if (LL_EQ(bigMinusOne, bigOne)) {\n-        SetFailed(\"LL_EQ\", \"minus one EQ one\");\n-    }\n-\n-    if (LL_EQ(bigNumber, bigOne)) {\n-        SetFailed(\"LL_EQ\", \"bigNumber EQ one\");\n-    }\n-\n-    /* test not equal */\n-    if (LL_NE(bigZero, bigZero)) {\n-        SetFailed(\"LL_NE\", \"0 NE 0\");\n-    }\n-\n-    if (LL_NE(bigOne, bigOne)) {\n-        SetFailed(\"LL_NE\", \"1 NE 1\");\n-    }\n-\n-    if (LL_NE(bigMinusOne, bigMinusOne)) {\n-        SetFailed(\"LL_NE\", \"-1 NE -1\");\n-    }\n-\n-    if (LL_NE(bigNumber, bigNumber)) {\n-        SetFailed(\"LL_NE\", \"n NE n\");\n-    }\n-\n-    if (LL_NE(bigMinusNumber, bigMinusNumber)) {\n-        SetFailed(\"LL_NE\", \"-n NE -n\");\n-    }\n+static void TestComparisons(void) {\n+  ReportProgress(\"Testing Comparisons Operations\\n\");\n+\n+  /* test for zero */\n+  if (!LL_IS_ZERO(bigZero)) {\n+    SetFailed(\"LL_IS_ZERO\", \"Zero is not zero\");\n+  }\n+\n+  if (LL_IS_ZERO(bigOne)) {\n+    SetFailed(\"LL_IS_ZERO\", \"One tests as zero\");\n+  }\n+\n+  if (LL_IS_ZERO(bigMinusOne)) {\n+    SetFailed(\"LL_IS_ZERO\", \"Minus One tests as zero\");\n+  }\n+\n+  /* test equal */\n+  if (!LL_EQ(bigZero, bigZero)) {\n+    SetFailed(\"LL_EQ\", \"zero EQ zero\");\n+  }\n+\n+  if (!LL_EQ(bigOne, bigOne)) {\n+    SetFailed(\"LL_EQ\", \"one EQ one\");\n+  }\n+\n+  if (!LL_EQ(bigNumber, bigNumber)) {\n+    SetFailed(\"LL_EQ\", \"bigNumber EQ bigNumber\");\n+  }\n+\n+  if (!LL_EQ(bigMinusOne, bigMinusOne)) {\n+    SetFailed(\"LL_EQ\", \"minus one EQ minus one\");\n+  }\n+\n+  if (LL_EQ(bigZero, bigOne)) {\n+    SetFailed(\"LL_EQ\", \"zero EQ one\");\n+  }\n+\n+  if (LL_EQ(bigOne, bigZero)) {\n+    SetFailed(\"LL_EQ\", \"one EQ zero\");\n+  }\n+\n+  if (LL_EQ(bigMinusOne, bigOne)) {\n+    SetFailed(\"LL_EQ\", \"minus one EQ one\");\n+  }\n+\n+  if (LL_EQ(bigNumber, bigOne)) {\n+    SetFailed(\"LL_EQ\", \"bigNumber EQ one\");\n+  }\n+\n+  /* test not equal */\n+  if (LL_NE(bigZero, bigZero)) {\n+    SetFailed(\"LL_NE\", \"0 NE 0\");\n+  }\n+\n+  if (LL_NE(bigOne, bigOne)) {\n+    SetFailed(\"LL_NE\", \"1 NE 1\");\n+  }\n+\n+  if (LL_NE(bigMinusOne, bigMinusOne)) {\n+    SetFailed(\"LL_NE\", \"-1 NE -1\");\n+  }\n+\n+  if (LL_NE(bigNumber, bigNumber)) {\n+    SetFailed(\"LL_NE\", \"n NE n\");\n+  }\n+\n+  if (LL_NE(bigMinusNumber, bigMinusNumber)) {\n+    SetFailed(\"LL_NE\", \"-n NE -n\");\n+  }\n+\n+  if (!LL_NE(bigZero, bigOne)) {\n+    SetFailed(\"LL_NE\", \"0 NE 1\");\n+  }\n+\n+  if (!LL_NE(bigOne, bigMinusNumber)) {\n+    SetFailed(\"LL_NE\", \"1 NE -n\");\n+  }\n+\n+  /* Greater than or equal to zero */\n+  if (!LL_GE_ZERO(bigZero)) {\n+    SetFailed(\"LL_GE_ZERO\", \"0\");\n+  }\n+\n+  if (!LL_GE_ZERO(bigOne)) {\n+    SetFailed(\"LL_GE_ZERO\", \"1\");\n+  }\n+\n+  if (!LL_GE_ZERO(bigNumber)) {\n+    SetFailed(\"LL_GE_ZERO\", \"n\");\n+  }\n+\n+  if (LL_GE_ZERO(bigMinusOne)) {\n+    SetFailed(\"LL_GE_ZERO\", \"-1\");\n+  }\n+\n+  if (LL_GE_ZERO(bigMinusNumber)) {\n+    SetFailed(\"LL_GE_ZERO\", \"-n\");\n+  }\n+\n+  /* Algebraic Compare two values */\n+  if (!LL_CMP(bigZero, ==, bigZero)) {\n+    SetFailed(\"LL_CMP\", \"0 == 0\");\n+  }\n+\n+  if (LL_CMP(bigZero, >, bigZero)) {\n+    SetFailed(\"LL_CMP\", \"0 > 0\");\n+  }\n+\n+  if (LL_CMP(bigZero, <, bigZero)) {\n+    SetFailed(\"LL_CMP\", \"0 < 0\");\n+  }\n+\n+  if (LL_CMP(bigNumber, <, bigOne)) {\n+    SetFailed(\"LL_CMP\", \"n < 1\");\n+  }\n+\n+  if (!LL_CMP(bigNumber, >, bigOne)) {\n+    SetFailed(\"LL_CMP\", \"n <= 1\");\n+  }\n+\n+  if (LL_CMP(bigOne, >, bigNumber)) {\n+    SetFailed(\"LL_CMP\", \"1 > n\");\n+  }\n+\n+  if (LL_CMP(bigMinusNumber, >, bigNumber)) {\n+    SetFailed(\"LL_CMP\", \"-n > n\");\n+  }\n+\n+  if (LL_CMP(bigNumber, !=, bigNumber)) {\n+    SetFailed(\"LL_CMP\", \"n != n\");\n+  }\n+\n+  if (!LL_CMP(bigMinusOne, >, bigMinusTwo)) {\n+    SetFailed(\"LL_CMP\", \"-1 <= -2\");\n+  }\n+\n+  if (!LL_CMP(bigMaxInt32, <, big2To31)) {\n+    SetFailed(\"LL_CMP\", \"Max 32-bit signed int >= 2^31\");\n+  }\n+\n+  /* Two positive numbers */\n+  if (!LL_CMP(bigInt0, <=, bigInt0)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  if (!LL_CMP(bigInt0, <=, bigInt1)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  if (LL_CMP(bigInt0, <=, bigInt2)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  if (!LL_CMP(bigInt0, <=, bigInt3)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  if (!LL_CMP(bigInt0, <=, bigInt4)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  if (!LL_CMP(bigInt0, <=, bigInt5)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  /* Two negative numbers */\n+  if (!LL_CMP(bigInt6, <=, bigInt6)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  if (!LL_CMP(bigInt6, <=, bigInt7)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  if (LL_CMP(bigInt6, <=, bigInt8)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  if (!LL_CMP(bigInt6, <=, bigInt9)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  if (!LL_CMP(bigInt6, <=, bigInt10)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  if (!LL_CMP(bigInt6, <=, bigInt11)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  /* One positive, one negative */\n+  if (LL_CMP(bigInt0, <=, bigInt6)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  if (LL_CMP(bigInt0, <=, bigInt7)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  if (LL_CMP(bigInt0, <=, bigInt8)) {\n+    SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n+  }\n+\n+  /* Bitwise Compare two numbers */\n+  if (!LL_UCMP(bigZero, ==, bigZero)) {\n+    SetFailed(\"LL_UCMP\", \"0 == 0\");\n+  }\n+\n+  if (LL_UCMP(bigZero, >, bigZero)) {\n+    SetFailed(\"LL_UCMP\", \"0 > 0\");\n+  }\n+\n+  if (LL_UCMP(bigZero, <, bigZero)) {\n+    SetFailed(\"LL_UCMP\", \"0 < 0\");\n+  }\n+\n+  if (LL_UCMP(bigNumber, <, bigOne)) {\n+    SetFailed(\"LL_UCMP\", \"n < 1\");\n+  }\n+\n+  if (!LL_UCMP(bigNumber, >, bigOne)) {\n+    SetFailed(\"LL_UCMP\", \"n < 1\");\n+  }\n+\n+  if (LL_UCMP(bigOne, >, bigNumber)) {\n+    SetFailed(\"LL_UCMP\", \"1 > n\");\n+  }\n+\n+  if (LL_UCMP(bigMinusNumber, <, bigNumber)) {\n+    SetFailed(\"LL_UCMP\", \"-n < n\");\n+  }\n+\n+  /* Two positive numbers */\n+  if (!LL_UCMP(bigInt0, <=, bigInt0)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n+\n+  if (!LL_UCMP(bigInt0, <=, bigInt1)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n+\n+  if (LL_UCMP(bigInt0, <=, bigInt2)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n+\n+  if (!LL_UCMP(bigInt0, <=, bigInt3)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n+\n+  if (!LL_UCMP(bigInt0, <=, bigInt4)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n+\n+  if (!LL_UCMP(bigInt0, <=, bigInt5)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n+\n+  /* Two negative numbers */\n+  if (!LL_UCMP(bigInt6, <=, bigInt6)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n+\n+  if (!LL_UCMP(bigInt6, <=, bigInt7)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n+\n+  if (LL_UCMP(bigInt6, <=, bigInt8)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n \n-    if (!LL_NE(bigZero, bigOne)) {\n-        SetFailed(\"LL_NE\", \"0 NE 1\");\n-    }\n-\n-    if (!LL_NE(bigOne, bigMinusNumber)) {\n-        SetFailed(\"LL_NE\", \"1 NE -n\");\n-    }\n-\n-    /* Greater than or equal to zero */\n-    if (!LL_GE_ZERO(bigZero)) {\n-        SetFailed(\"LL_GE_ZERO\", \"0\");\n-    }\n-\n-    if (!LL_GE_ZERO(bigOne)) {\n-        SetFailed(\"LL_GE_ZERO\", \"1\");\n-    }\n-\n-    if (!LL_GE_ZERO(bigNumber)) {\n-        SetFailed(\"LL_GE_ZERO\", \"n\");\n-    }\n+  if (!LL_UCMP(bigInt6, <=, bigInt9)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n \n-    if (LL_GE_ZERO(bigMinusOne)) {\n-        SetFailed(\"LL_GE_ZERO\", \"-1\");\n-    }\n-\n-    if (LL_GE_ZERO(bigMinusNumber)) {\n-        SetFailed(\"LL_GE_ZERO\", \"-n\");\n-    }\n-\n-    /* Algebraic Compare two values */\n-    if (!LL_CMP(bigZero, ==, bigZero)) {\n-        SetFailed(\"LL_CMP\", \"0 == 0\");\n-    }\n-\n-    if (LL_CMP(bigZero, >, bigZero)) {\n-        SetFailed(\"LL_CMP\", \"0 > 0\");\n-    }\n-\n-    if (LL_CMP(bigZero, <, bigZero)) {\n-        SetFailed(\"LL_CMP\", \"0 < 0\");\n-    }\n+  if (!LL_UCMP(bigInt6, <=, bigInt10)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n \n-    if (LL_CMP(bigNumber, <, bigOne)) {\n-        SetFailed(\"LL_CMP\", \"n < 1\");\n-    }\n-\n-    if (!LL_CMP(bigNumber, >, bigOne)) {\n-        SetFailed(\"LL_CMP\", \"n <= 1\");\n-    }\n-\n-    if (LL_CMP(bigOne, >, bigNumber)) {\n-        SetFailed(\"LL_CMP\", \"1 > n\");\n-    }\n-\n-    if (LL_CMP(bigMinusNumber, >, bigNumber)) {\n-        SetFailed(\"LL_CMP\", \"-n > n\");\n-    }\n-\n-    if (LL_CMP(bigNumber, !=, bigNumber)) {\n-        SetFailed(\"LL_CMP\", \"n != n\");\n-    }\n-\n-    if (!LL_CMP(bigMinusOne, >, bigMinusTwo)) {\n-        SetFailed(\"LL_CMP\", \"-1 <= -2\");\n-    }\n-\n-    if (!LL_CMP(bigMaxInt32, <, big2To31)) {\n-        SetFailed(\"LL_CMP\", \"Max 32-bit signed int >= 2^31\");\n-    }\n-\n-    /* Two positive numbers */\n-    if (!LL_CMP(bigInt0, <=, bigInt0)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    if (!LL_CMP(bigInt0, <=, bigInt1)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n+  if (!LL_UCMP(bigInt6, <=, bigInt11)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n \n-    if (LL_CMP(bigInt0, <=, bigInt2)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    if (!LL_CMP(bigInt0, <=, bigInt3)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    if (!LL_CMP(bigInt0, <=, bigInt4)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    if (!LL_CMP(bigInt0, <=, bigInt5)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    /* Two negative numbers */\n-    if (!LL_CMP(bigInt6, <=, bigInt6)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    if (!LL_CMP(bigInt6, <=, bigInt7)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    if (LL_CMP(bigInt6, <=, bigInt8)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    if (!LL_CMP(bigInt6, <=, bigInt9)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    if (!LL_CMP(bigInt6, <=, bigInt10)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    if (!LL_CMP(bigInt6, <=, bigInt11)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    /* One positive, one negative */\n-    if (LL_CMP(bigInt0, <=, bigInt6)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    if (LL_CMP(bigInt0, <=, bigInt7)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    if (LL_CMP(bigInt0, <=, bigInt8)) {\n-        SetFailed(\"LL_CMP\", \"LL_CMP(<=) failed\");\n-    }\n-\n-    /* Bitwise Compare two numbers */\n-    if (!LL_UCMP(bigZero, ==, bigZero)) {\n-        SetFailed(\"LL_UCMP\", \"0 == 0\");\n-    }\n-\n-    if (LL_UCMP(bigZero, >, bigZero)) {\n-        SetFailed(\"LL_UCMP\", \"0 > 0\");\n-    }\n-\n-    if (LL_UCMP(bigZero, <, bigZero)) {\n-        SetFailed(\"LL_UCMP\", \"0 < 0\");\n-    }\n-\n-    if (LL_UCMP(bigNumber, <, bigOne)) {\n-        SetFailed(\"LL_UCMP\", \"n < 1\");\n-    }\n-\n-    if (!LL_UCMP(bigNumber, >, bigOne)) {\n-        SetFailed(\"LL_UCMP\", \"n < 1\");\n-    }\n-\n-    if (LL_UCMP(bigOne, >, bigNumber)) {\n-        SetFailed(\"LL_UCMP\", \"1 > n\");\n-    }\n-\n-    if (LL_UCMP(bigMinusNumber, <, bigNumber)) {\n-        SetFailed(\"LL_UCMP\", \"-n < n\");\n-    }\n-\n-    /* Two positive numbers */\n-    if (!LL_UCMP(bigInt0, <=, bigInt0)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    if (!LL_UCMP(bigInt0, <=, bigInt1)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    if (LL_UCMP(bigInt0, <=, bigInt2)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    if (!LL_UCMP(bigInt0, <=, bigInt3)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    if (!LL_UCMP(bigInt0, <=, bigInt4)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    if (!LL_UCMP(bigInt0, <=, bigInt5)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    /* Two negative numbers */\n-    if (!LL_UCMP(bigInt6, <=, bigInt6)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    if (!LL_UCMP(bigInt6, <=, bigInt7)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    if (LL_UCMP(bigInt6, <=, bigInt8)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    if (!LL_UCMP(bigInt6, <=, bigInt9)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    if (!LL_UCMP(bigInt6, <=, bigInt10)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    if (!LL_UCMP(bigInt6, <=, bigInt11)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    /* One positive, one negative */\n-    if (!LL_UCMP(bigInt0, <=, bigInt6)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    if (!LL_UCMP(bigInt0, <=, bigInt7)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n-\n-    if (!LL_UCMP(bigInt0, <=, bigInt8)) {\n-        SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n-    }\n+  /* One positive, one negative */\n+  if (!LL_UCMP(bigInt0, <=, bigInt6)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n+\n+  if (!LL_UCMP(bigInt0, <=, bigInt7)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n+\n+  if (!LL_UCMP(bigInt0, <=, bigInt8)) {\n+    SetFailed(\"LL_UCMP\", \"LL_UCMP(<=) failed\");\n+  }\n \n-    return;\n+  return;\n }\n \n /*\n **  TestLogicalOperations() -- Tests for AND, OR, ...\n **\n */\n-static void\n-TestLogicalOperations(void)\n-{\n-    PRUint64 result, result2;\n-\n-    ReportProgress(\"Testing Logical Operations\\n\");\n-\n-    /* Test AND */\n-    LL_AND(result, bigZero, bigZero);\n-    if (!LL_IS_ZERO(result)) {\n-        ResultFailed(\"LL_AND\", \"0 & 0\", bigZero, result);\n-    }\n-\n-    LL_AND(result, bigOne, bigOne);\n-    if (LL_IS_ZERO(result)) {\n-        ResultFailed(\"LL_AND\", \"1 & 1\", bigOne, result);\n-    }\n-\n-    LL_AND(result, bigZero, bigOne);\n-    if (!LL_IS_ZERO(result)) {\n-        ResultFailed(\"LL_AND\", \"1 & 1\", bigZero, result);\n-    }\n-\n-    LL_AND(result, bigMinusOne, bigMinusOne);\n-    if (!LL_UCMP(result, ==, bigMinusOne)) {\n-        ResultFailed(\"LL_AND\", \"-1 & -1\", bigMinusOne, result);\n-    }\n-\n-    /* test OR */\n-    LL_OR(result, bigZero, bigZero);\n-    if (!LL_IS_ZERO(result)) {\n-        ResultFailed(\"LL_OR\", \"0 | 1\", bigZero, result);\n-    }\n-\n-    LL_OR(result, bigZero, bigOne);\n-    if (LL_IS_ZERO(result)) {\n-        ResultFailed(\"LL_OR\", \"0 | 1\", bigOne, result);\n-    }\n-\n-    LL_OR(result, bigZero, bigMinusNumber);\n-    if (!LL_UCMP(result, ==, bigMinusNumber)) {\n-        ResultFailed(\"LL_OR\", \"0 | -n\", bigMinusNumber, result);\n-    }\n-\n-    LL_OR(result, bigMinusNumber, bigZero);\n-    if (!LL_UCMP(result, ==, bigMinusNumber)) {\n-        ResultFailed(\"LL_OR\", \"-n | 0\", bigMinusNumber, result);\n-    }\n-\n-    /* test XOR */\n-    LL_XOR(result, bigZero, bigZero);\n-    if (LL_UCMP(result, !=, bigZero)) {\n-        ResultFailed(\"LL_XOR\", \"0 ^ 0\", bigZero, result);\n-    }\n-\n-    LL_XOR(result, bigOne, bigZero);\n-    if (LL_UCMP(result, !=, bigOne)) {\n-        ResultFailed(\"LL_XOR\", \"1 ^ 0\", bigZero, result);\n-    }\n-\n-    LL_XOR(result, bigMinusNumber, bigZero);\n-    if (LL_UCMP(result, !=, bigMinusNumber)) {\n-        ResultFailed(\"LL_XOR\", \"-n ^ 0\", bigMinusNumber, result);\n-    }\n-\n-    LL_XOR(result, bigMinusNumber, bigMinusNumber);\n-    if (LL_UCMP(result, !=, bigZero)) {\n-        ResultFailed(\"LL_XOR\", \"-n ^ -n\", bigMinusNumber, result);\n-    }\n-\n-    /* test OR2.  */\n-    result = bigZero;\n-    LL_OR2(result, bigOne);\n-    if (LL_UCMP(result, !=, bigOne)) {\n-        ResultFailed(\"LL_OR2\", \"(r=0) |= 1\", bigOne, result);\n-    }\n-\n-    result = bigOne;\n-    LL_OR2(result, bigNumber);\n-    if (LL_UCMP(result, !=, bigNumber)) {\n-        ResultFailed(\"LL_OR2\", \"(r=1) |= n\", bigNumber, result);\n-    }\n-\n-    result = bigMinusNumber;\n-    LL_OR2(result, bigMinusNumber);\n-    if (LL_UCMP(result, !=, bigMinusNumber)) {\n-        ResultFailed(\"LL_OR2\", \"(r=-n) |= -n\", bigMinusNumber, result);\n-    }\n-\n-    /* test NOT */\n-    LL_NOT(result, bigMinusNumber);\n-    LL_NOT(result2, result);\n-    if (LL_UCMP(result2, !=, bigMinusNumber)) {\n-        ResultFailed(\"LL_NOT\", \"r != ~(~-n)\", bigMinusNumber, result);\n-    }\n-\n-    /* test Negation */\n-    LL_NEG(result, bigMinusNumber);\n-    LL_NEG(result2, result);\n-    if (LL_CMP(result2, !=, bigMinusNumber)) {\n-        ResultFailed(\"LL_NEG\", \"r != -(-(-n))\", bigMinusNumber, result);\n-    }\n-\n-    return;\n+static void TestLogicalOperations(void) {\n+  PRUint64 result, result2;\n+\n+  ReportProgress(\"Testing Logical Operations\\n\");\n+\n+  /* Test AND */\n+  LL_AND(result, bigZero, bigZero);\n+  if (!LL_IS_ZERO(result)) {\n+    ResultFailed(\"LL_AND\", \"0 & 0\", bigZero, result);\n+  }\n+\n+  LL_AND(result, bigOne, bigOne);\n+  if (LL_IS_ZERO(result)) {\n+    ResultFailed(\"LL_AND\", \"1 & 1\", bigOne, result);\n+  }\n+\n+  LL_AND(result, bigZero, bigOne);\n+  if (!LL_IS_ZERO(result)) {\n+    ResultFailed(\"LL_AND\", \"1 & 1\", bigZero, result);\n+  }\n+\n+  LL_AND(result, bigMinusOne, bigMinusOne);\n+  if (!LL_UCMP(result, ==, bigMinusOne)) {\n+    ResultFailed(\"LL_AND\", \"-1 & -1\", bigMinusOne, result);\n+  }\n+\n+  /* test OR */\n+  LL_OR(result, bigZero, bigZero);\n+  if (!LL_IS_ZERO(result)) {\n+    ResultFailed(\"LL_OR\", \"0 | 1\", bigZero, result);\n+  }\n+\n+  LL_OR(result, bigZero, bigOne);\n+  if (LL_IS_ZERO(result)) {\n+    ResultFailed(\"LL_OR\", \"0 | 1\", bigOne, result);\n+  }\n+\n+  LL_OR(result, bigZero, bigMinusNumber);\n+  if (!LL_UCMP(result, ==, bigMinusNumber)) {\n+    ResultFailed(\"LL_OR\", \"0 | -n\", bigMinusNumber, result);\n+  }\n+\n+  LL_OR(result, bigMinusNumber, bigZero);\n+  if (!LL_UCMP(result, ==, bigMinusNumber)) {\n+    ResultFailed(\"LL_OR\", \"-n | 0\", bigMinusNumber, result);\n+  }\n+\n+  /* test XOR */\n+  LL_XOR(result, bigZero, bigZero);\n+  if (LL_UCMP(result, !=, bigZero)) {\n+    ResultFailed(\"LL_XOR\", \"0 ^ 0\", bigZero, result);\n+  }\n+\n+  LL_XOR(result, bigOne, bigZero);\n+  if (LL_UCMP(result, !=, bigOne)) {\n+    ResultFailed(\"LL_XOR\", \"1 ^ 0\", bigZero, result);\n+  }\n+\n+  LL_XOR(result, bigMinusNumber, bigZero);\n+  if (LL_UCMP(result, !=, bigMinusNumber)) {\n+    ResultFailed(\"LL_XOR\", \"-n ^ 0\", bigMinusNumber, result);\n+  }\n+\n+  LL_XOR(result, bigMinusNumber, bigMinusNumber);\n+  if (LL_UCMP(result, !=, bigZero)) {\n+    ResultFailed(\"LL_XOR\", \"-n ^ -n\", bigMinusNumber, result);\n+  }\n+\n+  /* test OR2.  */\n+  result = bigZero;\n+  LL_OR2(result, bigOne);\n+  if (LL_UCMP(result, !=, bigOne)) {\n+    ResultFailed(\"LL_OR2\", \"(r=0) |= 1\", bigOne, result);\n+  }\n+\n+  result = bigOne;\n+  LL_OR2(result, bigNumber);\n+  if (LL_UCMP(result, !=, bigNumber)) {\n+    ResultFailed(\"LL_OR2\", \"(r=1) |= n\", bigNumber, result);\n+  }\n+\n+  result = bigMinusNumber;\n+  LL_OR2(result, bigMinusNumber);\n+  if (LL_UCMP(result, !=, bigMinusNumber)) {\n+    ResultFailed(\"LL_OR2\", \"(r=-n) |= -n\", bigMinusNumber, result);\n+  }\n+\n+  /* test NOT */\n+  LL_NOT(result, bigMinusNumber);\n+  LL_NOT(result2, result);\n+  if (LL_UCMP(result2, !=, bigMinusNumber)) {\n+    ResultFailed(\"LL_NOT\", \"r != ~(~-n)\", bigMinusNumber, result);\n+  }\n+\n+  /* test Negation */\n+  LL_NEG(result, bigMinusNumber);\n+  LL_NEG(result2, result);\n+  if (LL_CMP(result2, !=, bigMinusNumber)) {\n+    ResultFailed(\"LL_NEG\", \"r != -(-(-n))\", bigMinusNumber, result);\n+  }\n+\n+  return;\n }\n \n /*\n **  TestConversion() -- Test Conversion Operations\n **\n */\n-static void\n-TestConversion(void)\n-{\n-    PRInt64 result;\n-    PRInt64 resultU;\n-    PRInt32 result32;\n-    PRUint32 resultU32;\n-    float resultF;\n-    PRFloat64 resultD;\n-\n-    ReportProgress(\"Testing Conversion Operations\\n\");\n-\n-    /* LL_L2I  -- Convert to signed 32bit */\n-    LL_L2I(result32, bigOne);\n-    if (result32 != one) {\n-        SetFailed(\"LL_L2I\", \"r != 1\");\n-    }\n-\n-    LL_L2I(result32, bigMinusOne);\n-    if (result32 != minusOne) {\n-        SetFailed(\"LL_L2I\", \"r != -1\");\n-    }\n-\n-    /* LL_L2UI -- Convert 64bit to unsigned 32bit */\n-    LL_L2UI(resultU32, bigMinusOne);\n-    if (resultU32 != (PRUint32)minusOne) {\n-        SetFailed(\"LL_L2UI\", \"r != -1\");\n-    }\n-\n-    LL_L2UI(resultU32, bigOne);\n-    if (resultU32 != (PRUint32)one) {\n-        SetFailed(\"LL_L2UI\", \"r != 1\");\n-    }\n-\n-    /* LL_L2F  -- Convert to 32bit floating point */\n-    LL_L2F(resultF, bigOne);\n-    if (resultF != 1.0) {\n-        SetFailed(\"LL_L2F\", \"r != 1.0\");\n-    }\n-\n-    LL_L2F(resultF, bigMinusOne);\n-    if (resultF != -1.0) {\n-        SetFailed(\"LL_L2F\", \"r != 1.0\");\n-    }\n-\n-    /* LL_L2D  -- Convert to 64bit floating point */\n-    LL_L2D(resultD, bigOne);\n-    if (resultD != 1.0L) {\n-        SetFailed(\"LL_L2D\", \"r != 1.0\");\n-    }\n-\n-    LL_L2D(resultD, bigMinusOne);\n-    if (resultD != -1.0L) {\n-        SetFailed(\"LL_L2D\", \"r != -1.0\");\n-    }\n-\n-    /* LL_I2L  -- Convert 32bit signed to 64bit signed */\n-    LL_I2L(result, one);\n-    if (LL_CMP(result, !=, bigOne)) {\n-        SetFailed(\"LL_I2L\", \"r != 1\");\n-    }\n-\n-    LL_I2L(result, minusOne);\n-    if (LL_CMP(result, !=, bigMinusOne)) {\n-        SetFailed(\"LL_I2L\", \"r != -1\");\n-    }\n-\n-    /* LL_UI2L -- Convert 32bit unsigned to 64bit unsigned */\n-    LL_UI2L(resultU, (PRUint32)one);\n-    if (LL_CMP(resultU, !=, bigOne)) {\n-        SetFailed(\"LL_UI2L\", \"r != 1\");\n-    }\n-\n-    /* [lth.] This did not behave as expected, but it is correct\n-     */\n-    LL_UI2L(resultU, (PRUint32)minusOne);\n-    if (LL_CMP(resultU, !=, bigZeroFox)) {\n-        ResultFailed(\"LL_UI2L\", \"r != -1\", bigZeroFox, resultU);\n-    }\n-\n-    /* LL_F2L  -- Convert 32bit float to 64bit signed */\n-    LL_F2L(result, 1.0);\n-    if (LL_CMP(result, !=, bigOne)) {\n-        SetFailed(\"LL_F2L\", \"r != 1\");\n-    }\n-\n-    LL_F2L(result, -1.0);\n-    if (LL_CMP(result, !=, bigMinusOne)) {\n-        SetFailed(\"LL_F2L\", \"r != -1\");\n-    }\n-\n-    /* LL_D2L  -- Convert 64bit Float to 64bit signed */\n-    LL_D2L(result, 1.0L);\n-    if (LL_CMP(result, !=, bigOne)) {\n-        SetFailed(\"LL_D2L\", \"r != 1\");\n-    }\n-\n-    LL_D2L(result, -1.0L);\n-    if (LL_CMP(result, !=, bigMinusOne)) {\n-        SetFailed(\"LL_D2L\", \"r != -1\");\n-    }\n-\n-    return;\n+static void TestConversion(void) {\n+  PRInt64 result;\n+  PRInt64 resultU;\n+  PRInt32 result32;\n+  PRUint32 resultU32;\n+  float resultF;\n+  PRFloat64 resultD;\n+\n+  ReportProgress(\"Testing Conversion Operations\\n\");\n+\n+  /* LL_L2I  -- Convert to signed 32bit */\n+  LL_L2I(result32, bigOne);\n+  if (result32 != one) {\n+    SetFailed(\"LL_L2I\", \"r != 1\");\n+  }\n+\n+  LL_L2I(result32, bigMinusOne);\n+  if (result32 != minusOne) {\n+    SetFailed(\"LL_L2I\", \"r != -1\");\n+  }\n+\n+  /* LL_L2UI -- Convert 64bit to unsigned 32bit */\n+  LL_L2UI(resultU32, bigMinusOne);\n+  if (resultU32 != (PRUint32)minusOne) {\n+    SetFailed(\"LL_L2UI\", \"r != -1\");\n+  }\n+\n+  LL_L2UI(resultU32, bigOne);\n+  if (resultU32 != (PRUint32)one) {\n+    SetFailed(\"LL_L2UI\", \"r != 1\");\n+  }\n+\n+  /* LL_L2F  -- Convert to 32bit floating point */\n+  LL_L2F(resultF, bigOne);\n+  if (resultF != 1.0) {\n+    SetFailed(\"LL_L2F\", \"r != 1.0\");\n+  }\n+\n+  LL_L2F(resultF, bigMinusOne);\n+  if (resultF != -1.0) {\n+    SetFailed(\"LL_L2F\", \"r != 1.0\");\n+  }\n+\n+  /* LL_L2D  -- Convert to 64bit floating point */\n+  LL_L2D(resultD, bigOne);\n+  if (resultD != 1.0L) {\n+    SetFailed(\"LL_L2D\", \"r != 1.0\");\n+  }\n+\n+  LL_L2D(resultD, bigMinusOne);\n+  if (resultD != -1.0L) {\n+    SetFailed(\"LL_L2D\", \"r != -1.0\");\n+  }\n+\n+  /* LL_I2L  -- Convert 32bit signed to 64bit signed */\n+  LL_I2L(result, one);\n+  if (LL_CMP(result, !=, bigOne)) {\n+    SetFailed(\"LL_I2L\", \"r != 1\");\n+  }\n+\n+  LL_I2L(result, minusOne);\n+  if (LL_CMP(result, !=, bigMinusOne)) {\n+    SetFailed(\"LL_I2L\", \"r != -1\");\n+  }\n+\n+  /* LL_UI2L -- Convert 32bit unsigned to 64bit unsigned */\n+  LL_UI2L(resultU, (PRUint32)one);\n+  if (LL_CMP(resultU, !=, bigOne)) {\n+    SetFailed(\"LL_UI2L\", \"r != 1\");\n+  }\n+\n+  /* [lth.] This did not behave as expected, but it is correct\n+   */\n+  LL_UI2L(resultU, (PRUint32)minusOne);\n+  if (LL_CMP(resultU, !=, bigZeroFox)) {\n+    ResultFailed(\"LL_UI2L\", \"r != -1\", bigZeroFox, resultU);\n+  }\n+\n+  /* LL_F2L  -- Convert 32bit float to 64bit signed */\n+  LL_F2L(result, 1.0);\n+  if (LL_CMP(result, !=, bigOne)) {\n+    SetFailed(\"LL_F2L\", \"r != 1\");\n+  }\n+\n+  LL_F2L(result, -1.0);\n+  if (LL_CMP(result, !=, bigMinusOne)) {\n+    SetFailed(\"LL_F2L\", \"r != -1\");\n+  }\n+\n+  /* LL_D2L  -- Convert 64bit Float to 64bit signed */\n+  LL_D2L(result, 1.0L);\n+  if (LL_CMP(result, !=, bigOne)) {\n+    SetFailed(\"LL_D2L\", \"r != 1\");\n+  }\n+\n+  LL_D2L(result, -1.0L);\n+  if (LL_CMP(result, !=, bigMinusOne)) {\n+    SetFailed(\"LL_D2L\", \"r != -1\");\n+  }\n+\n+  return;\n }\n \n-static void\n-ShiftCompileOnly()\n-{\n-    /*\n-    ** This function is only compiled, never called.\n-    ** The real test is to see if it compiles w/o\n-    ** warnings. This is no small feat, by the way.\n-    */\n-    PRInt64 ia, ib;\n-    PRUint64 ua, ub;\n-    LL_SHR(ia, ib, 32);\n-    LL_SHL(ia, ib, 32);\n-\n-    LL_USHR(ua, ub, 32);\n-    LL_ISHL(ia, 49, 32);\n+static void ShiftCompileOnly() {\n+  /*\n+  ** This function is only compiled, never called.\n+  ** The real test is to see if it compiles w/o\n+  ** warnings. This is no small feat, by the way.\n+  */\n+  PRInt64 ia, ib;\n+  PRUint64 ua, ub;\n+  LL_SHR(ia, ib, 32);\n+  LL_SHL(ia, ib, 32);\n+\n+  LL_USHR(ua, ub, 32);\n+  LL_ISHL(ia, 49, 32);\n \n } /* ShiftCompileOnly */\n \n@@ -670,221 +656,215 @@ ShiftCompileOnly()\n **  TestShift() -- Test Shifting Operations\n **\n */\n-static void\n-TestShift(void)\n-{\n-    static const PRInt64 largeTwoZero = LL_INIT(0x00000002, 0x00000000);\n-    PRInt64 result;\n-    PRUint64 resultU;\n-\n-    ReportProgress(\"Testing Shifting Operations\\n\");\n-\n-    /* LL_SHL  -- Shift left algebraic */\n-    LL_SHL(result, bigOne, one);\n-    if (LL_CMP(result, !=, bigTwo)) {\n-        ResultFailed(\"LL_SHL\", \"r != 2\", bigOne, result);\n-    }\n-\n-    LL_SHL(result, bigTwo, thirtyTwo);\n-    if (LL_CMP(result, !=, largeTwoZero)) {\n-        ResultFailed(\"LL_SHL\", \"r != twoZero\", largeTwoZero, result);\n-    }\n-\n-    /* LL_SHR  -- Shift right algebraic */\n-    LL_SHR(result, bigFoxZero, thirtyTwo);\n-    if (LL_CMP(result, !=, bigMinusOne)) {\n-        ResultFailed(\"LL_SHR\", \"r != -1\", bigMinusOne, result);\n-    }\n-\n-    LL_SHR(result, bigTwo, one);\n-    if (LL_CMP(result, !=, bigOne)) {\n-        ResultFailed(\"LL_SHR\", \"r != 1\", bigOne, result);\n-    }\n-\n-    LL_SHR(result, bigFoxFox, thirtyTwo);\n-    if (LL_CMP(result, !=, bigMinusOne)) {\n-        ResultFailed(\"LL_SHR\", \"r != -1 (was ff,ff)\", bigMinusOne, result);\n-    }\n-\n-    /* LL_USHR -- Logical shift right */\n-    LL_USHR(resultU, bigZeroFox, thirtyTwo);\n-    if (LL_UCMP(resultU, !=, bigZero)) {\n-        ResultFailed(\"LL_USHR\", \"r != 0 \", bigZero, result);\n-    }\n-\n-    LL_USHR(resultU, bigFoxFox, thirtyTwo);\n-    if (LL_UCMP(resultU, !=, bigZeroFox)) {\n-        ResultFailed(\"LL_USHR\", \"r != 0 \", bigZeroFox, result);\n-    }\n-\n-    /* LL_ISHL -- Shift a 32bit integer into a 64bit result */\n-    LL_ISHL(resultU, minusOne, thirtyTwo);\n-    if (LL_UCMP(resultU, !=, bigFoxZero)) {\n-        ResultFailed(\"LL_ISHL\", \"r != ff,00 \", bigFoxZero, result);\n-    }\n-\n-    LL_ISHL(resultU, one, sixtyThree);\n-    if (LL_UCMP(resultU, !=, bigEightZero)) {\n-        ResultFailed(\"LL_ISHL\", \"r != 80,00 \", bigEightZero, result);\n-    }\n-\n-    LL_ISHL(resultU, one, sixteen);\n-    if (LL_UCMP(resultU, !=, big64K)) {\n-        ResultFailed(\"LL_ISHL\", \"r != 64K \", big64K, resultU);\n-    }\n-\n-    return;\n+static void TestShift(void) {\n+  static const PRInt64 largeTwoZero = LL_INIT(0x00000002, 0x00000000);\n+  PRInt64 result;\n+  PRUint64 resultU;\n+\n+  ReportProgress(\"Testing Shifting Operations\\n\");\n+\n+  /* LL_SHL  -- Shift left algebraic */\n+  LL_SHL(result, bigOne, one);\n+  if (LL_CMP(result, !=, bigTwo)) {\n+    ResultFailed(\"LL_SHL\", \"r != 2\", bigOne, result);\n+  }\n+\n+  LL_SHL(result, bigTwo, thirtyTwo);\n+  if (LL_CMP(result, !=, largeTwoZero)) {\n+    ResultFailed(\"LL_SHL\", \"r != twoZero\", largeTwoZero, result);\n+  }\n+\n+  /* LL_SHR  -- Shift right algebraic */\n+  LL_SHR(result, bigFoxZero, thirtyTwo);\n+  if (LL_CMP(result, !=, bigMinusOne)) {\n+    ResultFailed(\"LL_SHR\", \"r != -1\", bigMinusOne, result);\n+  }\n+\n+  LL_SHR(result, bigTwo, one);\n+  if (LL_CMP(result, !=, bigOne)) {\n+    ResultFailed(\"LL_SHR\", \"r != 1\", bigOne, result);\n+  }\n+\n+  LL_SHR(result, bigFoxFox, thirtyTwo);\n+  if (LL_CMP(result, !=, bigMinusOne)) {\n+    ResultFailed(\"LL_SHR\", \"r != -1 (was ff,ff)\", bigMinusOne, result);\n+  }\n+\n+  /* LL_USHR -- Logical shift right */\n+  LL_USHR(resultU, bigZeroFox, thirtyTwo);\n+  if (LL_UCMP(resultU, !=, bigZero)) {\n+    ResultFailed(\"LL_USHR\", \"r != 0 \", bigZero, result);\n+  }\n+\n+  LL_USHR(resultU, bigFoxFox, thirtyTwo);\n+  if (LL_UCMP(resultU, !=, bigZeroFox)) {\n+    ResultFailed(\"LL_USHR\", \"r != 0 \", bigZeroFox, result);\n+  }\n+\n+  /* LL_ISHL -- Shift a 32bit integer into a 64bit result */\n+  LL_ISHL(resultU, minusOne, thirtyTwo);\n+  if (LL_UCMP(resultU, !=, bigFoxZero)) {\n+    ResultFailed(\"LL_ISHL\", \"r != ff,00 \", bigFoxZero, result);\n+  }\n+\n+  LL_ISHL(resultU, one, sixtyThree);\n+  if (LL_UCMP(resultU, !=, bigEightZero)) {\n+    ResultFailed(\"LL_ISHL\", \"r != 80,00 \", bigEightZero, result);\n+  }\n+\n+  LL_ISHL(resultU, one, sixteen);\n+  if (LL_UCMP(resultU, !=, big64K)) {\n+    ResultFailed(\"LL_ISHL\", \"r != 64K \", big64K, resultU);\n+  }\n+\n+  return;\n }\n \n /*\n **  TestArithmetic() -- Test arithmetic operations.\n **\n */\n-static void\n-TestArithmetic(void)\n-{\n-    PRInt64 largeVal = LL_INIT(0x00000001, 0xffffffff);\n-    PRInt64 largeValPlusOne = LL_INIT(0x00000002, 0x00000000);\n-    PRInt64 largeValTimesTwo = LL_INIT(0x00000003, 0xfffffffe);\n-    PRInt64 largeMultCand = LL_INIT(0x00000000, 0x7fffffff);\n-    PRInt64 largeMinusMultCand = LL_INIT(0xffffffff, 0x10000001);\n-    PRInt64 largeMultCandx64K = LL_INIT(0x00007fff, 0xffff0000);\n-    PRInt64 largeNumSHL5 = LL_INIT(0x0000001f, 0xffffffe0);\n-    PRInt64 result, result2;\n-\n-    /* Addition */\n-    LL_ADD(result, bigOne, bigOne);\n-    if (LL_CMP(result, !=, bigTwo)) {\n-        ResultFailed(\"LL_ADD\", \"r != 1 + 1\", bigTwo, result);\n-    }\n-\n-    LL_ADD(result, bigMinusOne, bigOne);\n-    if (LL_CMP(result, !=, bigZero)) {\n-        ResultFailed(\"LL_ADD\", \"r != -1 + 1\", bigOne, result);\n-    }\n-\n-    LL_ADD(result, largeVal, bigOne);\n-    if (LL_CMP(result, !=, largeValPlusOne)) {\n-        ResultFailed(\"LL_ADD\", \"lVP1 != lV + 1\", largeValPlusOne, result);\n-    }\n-\n-    /* Subtraction */\n-    LL_SUB(result, bigOne, bigOne);\n-    if (LL_CMP(result, !=, bigZero)) {\n-        ResultFailed(\"LL_SUB\", \"r != 1 - 1\", bigZero, result);\n-    }\n-\n-    LL_SUB(result, bigTwo, bigOne);\n-    if (LL_CMP(result, !=, bigOne)) {\n-        ResultFailed(\"LL_SUB\", \"r != 2 - 1\", bigOne, result);\n-    }\n-\n-    LL_SUB(result, largeValPlusOne, bigOne);\n-    if (LL_CMP(result, !=, largeVal)) {\n-        ResultFailed(\"LL_SUB\", \"r != lVP1 - 1\", largeVal, result);\n-    }\n-\n-    /* Multiply */\n-    LL_MUL(result, largeVal, bigTwo);\n-    if (LL_CMP(result, !=, largeValTimesTwo)) {\n-        ResultFailed(\"LL_MUL\", \"r != lV*2\", largeValTimesTwo, result);\n-    }\n-\n-    LL_MUL(result, largeMultCand, big64K);\n-    if (LL_CMP(result, !=, largeMultCandx64K)) {\n-        ResultFailed(\"LL_MUL\", \"r != lV*64K\", largeMultCandx64K, result);\n-    }\n-\n-    LL_NEG(result2, largeMultCand);\n-    LL_MUL(result, largeMultCand, bigMinusOne);\n-    if (LL_CMP(result, !=, result2)) {\n-        ResultFailed(\"LL_MUL\", \"r != -lMC\", result2, result);\n-    }\n-\n-    LL_SHL(result2, bigZeroFox, 5);\n-    LL_MUL(result, bigZeroFox, bigThirtyTwo);\n-    if (LL_CMP(result, !=, largeNumSHL5)) {\n-        ResultFailed(\"LL_MUL\", \"r != 0f<<5\", largeNumSHL5, result);\n-    }\n-\n-    /* LL_DIV() Division */\n-    LL_DIV(result, bigOne, bigOne);\n-    if (LL_CMP(result, !=, bigOne)) {\n-        ResultFailed(\"LL_DIV\", \"1 != 1\", bigOne, result);\n-    }\n-\n-    LL_DIV(result, bigNumber, bigOne);\n-    if (LL_CMP(result, !=, bigNumber)) {\n-        ResultFailed(\"LL_DIV\", \"r != n / 1\", bigNumber, result);\n-    }\n-\n-    LL_DIV(result, bigNumber, bigMinusOne);\n-    if (LL_CMP(result, !=, bigMinusNumber)) {\n-        ResultFailed(\"LL_DIV\", \"r != n / -1\", bigMinusNumber, result);\n-    }\n-\n-    LL_DIV(result, bigMinusNumber, bigMinusOne);\n-    if (LL_CMP(result, !=, bigNumber)) {\n-        ResultFailed(\"LL_DIV\", \"r != -n / -1\", bigNumber, result);\n-    }\n-\n-    LL_SHL(result2, bigZeroFox, 5);\n-    LL_DIV(result, result2, bigOne);\n-    if (LL_CMP(result, !=, result2)) {\n-        ResultFailed(\"LL_DIV\", \"0f<<5 != 0f<<5\", result2, result);\n-    }\n-\n-    LL_SHL(result2, bigZeroFox, 5);\n-    LL_NEG(result2, result2);\n-    LL_DIV(result, result2, bigOne);\n-    if (LL_CMP(result, !=, result2)) {\n-        ResultFailed(\"LL_DIV\", \"-0f<<5 != -0f<<5\", result2, result);\n-    }\n-\n-    LL_SHL(result2, bigZeroFox, 17);\n-    LL_DIV(result, result2, bigMinusOne);\n-    LL_NEG(result2, result2);\n-    if (LL_CMP(result, !=, result2)) {\n-        ResultFailed(\"LL_DIV\", \"-0f<<17 != -0f<<17\", result2, result);\n-    }\n-\n-    /* LL_MOD() Modulo Division */\n-    LL_ADD(result2, bigThirtyTwo, bigOne);\n-    LL_MOD(result, result2, bigSixTeen);\n-    if (LL_CMP(result, !=, bigOne)) {\n-        ResultFailed(\"LL_MOD\", \"r != 1\", bigSixTeen, result);\n-    }\n-\n-    LL_MUL(result2, bigZeroFox, bigThirtyTwo);\n-    LL_ADD(result2, result2, bigSixTeen);\n-    LL_MOD(result, result2, bigThirtyTwo);\n-    if (LL_CMP(result, !=, bigSixTeen)) {\n-        ResultFailed(\"LL_MOD\", \"r != 16\", bigSixTeen, result);\n-    }\n-\n-    /* LL_UDIVMOD */\n-    LL_DIV(result, bigOne, bigOne);\n-    if (LL_CMP(result, !=, bigOne)) {\n-        ResultFailed(\"LL_DIV\", \"r != 16\", bigSixTeen, result);\n-    }\n-\n-    return;\n+static void TestArithmetic(void) {\n+  PRInt64 largeVal = LL_INIT(0x00000001, 0xffffffff);\n+  PRInt64 largeValPlusOne = LL_INIT(0x00000002, 0x00000000);\n+  PRInt64 largeValTimesTwo = LL_INIT(0x00000003, 0xfffffffe);\n+  PRInt64 largeMultCand = LL_INIT(0x00000000, 0x7fffffff);\n+  PRInt64 largeMinusMultCand = LL_INIT(0xffffffff, 0x10000001);\n+  PRInt64 largeMultCandx64K = LL_INIT(0x00007fff, 0xffff0000);\n+  PRInt64 largeNumSHL5 = LL_INIT(0x0000001f, 0xffffffe0);\n+  PRInt64 result, result2;\n+\n+  /* Addition */\n+  LL_ADD(result, bigOne, bigOne);\n+  if (LL_CMP(result, !=, bigTwo)) {\n+    ResultFailed(\"LL_ADD\", \"r != 1 + 1\", bigTwo, result);\n+  }\n+\n+  LL_ADD(result, bigMinusOne, bigOne);\n+  if (LL_CMP(result, !=, bigZero)) {\n+    ResultFailed(\"LL_ADD\", \"r != -1 + 1\", bigOne, result);\n+  }\n+\n+  LL_ADD(result, largeVal, bigOne);\n+  if (LL_CMP(result, !=, largeValPlusOne)) {\n+    ResultFailed(\"LL_ADD\", \"lVP1 != lV + 1\", largeValPlusOne, result);\n+  }\n+\n+  /* Subtraction */\n+  LL_SUB(result, bigOne, bigOne);\n+  if (LL_CMP(result, !=, bigZero)) {\n+    ResultFailed(\"LL_SUB\", \"r != 1 - 1\", bigZero, result);\n+  }\n+\n+  LL_SUB(result, bigTwo, bigOne);\n+  if (LL_CMP(result, !=, bigOne)) {\n+    ResultFailed(\"LL_SUB\", \"r != 2 - 1\", bigOne, result);\n+  }\n+\n+  LL_SUB(result, largeValPlusOne, bigOne);\n+  if (LL_CMP(result, !=, largeVal)) {\n+    ResultFailed(\"LL_SUB\", \"r != lVP1 - 1\", largeVal, result);\n+  }\n+\n+  /* Multiply */\n+  LL_MUL(result, largeVal, bigTwo);\n+  if (LL_CMP(result, !=, largeValTimesTwo)) {\n+    ResultFailed(\"LL_MUL\", \"r != lV*2\", largeValTimesTwo, result);\n+  }\n+\n+  LL_MUL(result, largeMultCand, big64K);\n+  if (LL_CMP(result, !=, largeMultCandx64K)) {\n+    ResultFailed(\"LL_MUL\", \"r != lV*64K\", largeMultCandx64K, result);\n+  }\n+\n+  LL_NEG(result2, largeMultCand);\n+  LL_MUL(result, largeMultCand, bigMinusOne);\n+  if (LL_CMP(result, !=, result2)) {\n+    ResultFailed(\"LL_MUL\", \"r != -lMC\", result2, result);\n+  }\n+\n+  LL_SHL(result2, bigZeroFox, 5);\n+  LL_MUL(result, bigZeroFox, bigThirtyTwo);\n+  if (LL_CMP(result, !=, largeNumSHL5)) {\n+    ResultFailed(\"LL_MUL\", \"r != 0f<<5\", largeNumSHL5, result);\n+  }\n+\n+  /* LL_DIV() Division */\n+  LL_DIV(result, bigOne, bigOne);\n+  if (LL_CMP(result, !=, bigOne)) {\n+    ResultFailed(\"LL_DIV\", \"1 != 1\", bigOne, result);\n+  }\n+\n+  LL_DIV(result, bigNumber, bigOne);\n+  if (LL_CMP(result, !=, bigNumber)) {\n+    ResultFailed(\"LL_DIV\", \"r != n / 1\", bigNumber, result);\n+  }\n+\n+  LL_DIV(result, bigNumber, bigMinusOne);\n+  if (LL_CMP(result, !=, bigMinusNumber)) {\n+    ResultFailed(\"LL_DIV\", \"r != n / -1\", bigMinusNumber, result);\n+  }\n+\n+  LL_DIV(result, bigMinusNumber, bigMinusOne);\n+  if (LL_CMP(result, !=, bigNumber)) {\n+    ResultFailed(\"LL_DIV\", \"r != -n / -1\", bigNumber, result);\n+  }\n+\n+  LL_SHL(result2, bigZeroFox, 5);\n+  LL_DIV(result, result2, bigOne);\n+  if (LL_CMP(result, !=, result2)) {\n+    ResultFailed(\"LL_DIV\", \"0f<<5 != 0f<<5\", result2, result);\n+  }\n+\n+  LL_SHL(result2, bigZeroFox, 5);\n+  LL_NEG(result2, result2);\n+  LL_DIV(result, result2, bigOne);\n+  if (LL_CMP(result, !=, result2)) {\n+    ResultFailed(\"LL_DIV\", \"-0f<<5 != -0f<<5\", result2, result);\n+  }\n+\n+  LL_SHL(result2, bigZeroFox, 17);\n+  LL_DIV(result, result2, bigMinusOne);\n+  LL_NEG(result2, result2);\n+  if (LL_CMP(result, !=, result2)) {\n+    ResultFailed(\"LL_DIV\", \"-0f<<17 != -0f<<17\", result2, result);\n+  }\n+\n+  /* LL_MOD() Modulo Division */\n+  LL_ADD(result2, bigThirtyTwo, bigOne);\n+  LL_MOD(result, result2, bigSixTeen);\n+  if (LL_CMP(result, !=, bigOne)) {\n+    ResultFailed(\"LL_MOD\", \"r != 1\", bigSixTeen, result);\n+  }\n+\n+  LL_MUL(result2, bigZeroFox, bigThirtyTwo);\n+  LL_ADD(result2, result2, bigSixTeen);\n+  LL_MOD(result, result2, bigThirtyTwo);\n+  if (LL_CMP(result, !=, bigSixTeen)) {\n+    ResultFailed(\"LL_MOD\", \"r != 16\", bigSixTeen, result);\n+  }\n+\n+  /* LL_UDIVMOD */\n+  LL_DIV(result, bigOne, bigOne);\n+  if (LL_CMP(result, !=, bigOne)) {\n+    ResultFailed(\"LL_DIV\", \"r != 16\", bigSixTeen, result);\n+  }\n+\n+  return;\n }\n \n-static void\n-TestWellknowns(void)\n-{\n-    PRInt64 max = LL_MAXINT, min = LL_MININT, zero = LL_ZERO;\n-    PRInt64 mmax = LL_MaxInt(), mmin = LL_MinInt(), mzero = LL_Zero();\n-    if (LL_NE(max, mmax)) {\n-        ResultFailed(\"max, mmax\", \"max != mmax\", max, mmax);\n-    }\n-    if (LL_NE(min, mmin)) {\n-        ResultFailed(\"min, mmin\", \"min != mmin\", max, mmin);\n-    }\n-    if (LL_NE(zero, mzero)) {\n-        ResultFailed(\"zero, mzero\", \"zero != mzero\", zero, mzero);\n-    }\n+static void TestWellknowns(void) {\n+  PRInt64 max = LL_MAXINT, min = LL_MININT, zero = LL_ZERO;\n+  PRInt64 mmax = LL_MaxInt(), mmin = LL_MinInt(), mzero = LL_Zero();\n+  if (LL_NE(max, mmax)) {\n+    ResultFailed(\"max, mmax\", \"max != mmax\", max, mmax);\n+  }\n+  if (LL_NE(min, mmin)) {\n+    ResultFailed(\"min, mmin\", \"min != mmin\", max, mmin);\n+  }\n+  if (LL_NE(zero, mzero)) {\n+    ResultFailed(\"zero, mzero\", \"zero != mzero\", zero, mzero);\n+  }\n } /* TestWellknowns */\n \n /*\n@@ -893,63 +873,59 @@ TestWellknowns(void)\n ** Parse command line options\n **\n */\n-static PRIntn\n-Initialize(PRIntn argc, char** argv)\n-{\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dvh\");\n-    PLOptStatus os;\n-\n-    /*\n-    ** Parse command line options\n-    */\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* set debug mode */\n-                debugMode = PR_TRUE;\n-                break;\n-\n-            case 'v': /* set verbose mode */\n-                verboseMode = PR_TRUE;\n-                debugMode = PR_TRUE;\n-                break;\n-\n-            case 'h': /* user wants some guidance */\n-            default:\n-                PR_fprintf(output, \"You get help.\\n\");\n-                return (1);\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-    return (0);\n-}\n-\n-int\n-main(int argc, char** argv)\n-{\n-    output = PR_GetSpecialFD(PR_StandardError);\n-\n-    if (Initialize(argc, argv)) {\n+static PRIntn Initialize(PRIntn argc, char** argv) {\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dvh\");\n+  PLOptStatus os;\n+\n+  /*\n+  ** Parse command line options\n+  */\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* set debug mode */\n+        debugMode = PR_TRUE;\n+        break;\n+\n+      case 'v': /* set verbose mode */\n+        verboseMode = PR_TRUE;\n+        debugMode = PR_TRUE;\n+        break;\n+\n+      case 'h': /* user wants some guidance */\n+      default:\n+        PR_fprintf(output, \"You get help.\\n\");\n         return (1);\n     }\n+  }\n+  PL_DestroyOptState(opt);\n+  return (0);\n+}\n \n-    TestAssignment();\n-    TestComparisons();\n-    TestLogicalOperations();\n-    TestConversion();\n-    TestShift();\n-    TestArithmetic();\n-    TestWellknowns();\n-\n-    /*\n-    ** That's all folks!\n-    */\n-    if (failedAlready) {\n-        PR_fprintf(output, \"FAIL\\n\");\n-    } else {\n-        PR_fprintf(output, \"PASS\\n\");\n-    }\n-    return failedAlready;\n+int main(int argc, char** argv) {\n+  output = PR_GetSpecialFD(PR_StandardError);\n+\n+  if (Initialize(argc, argv)) {\n+    return (1);\n+  }\n+\n+  TestAssignment();\n+  TestComparisons();\n+  TestLogicalOperations();\n+  TestConversion();\n+  TestShift();\n+  TestArithmetic();\n+  TestWellknowns();\n+\n+  /*\n+  ** That's all folks!\n+  */\n+  if (failedAlready) {\n+    PR_fprintf(output, \"FAIL\\n\");\n+  } else {\n+    PR_fprintf(output, \"PASS\\n\");\n+  }\n+  return failedAlready;\n } /* end main() */\ndiff --git a/nspr/pr/tests/lock.c b/nspr/pr/tests/lock.c\nindex ede9804..f235855 100644\n--- a/nspr/pr/tests/lock.c\n+++ b/nspr/pr/tests/lock.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -55,7 +56,7 @@\n #include <stdlib.h>\n \n #if defined(XP_UNIX)\n-#include <string.h>\n+#  include <string.h>\n #endif\n \n static PRIntn failed_already = 0;\n@@ -66,476 +67,444 @@ static PRBool debug_mode = PR_FALSE;\n const static PRIntervalTime contention_interval = 50;\n \n typedef struct LockContentious_s {\n-    PRLock* ml;\n-    PRInt32 loops;\n-    PRUint32 contender;\n-    PRUint32 contentious;\n-    PRIntervalTime overhead;\n-    PRIntervalTime interval;\n+  PRLock* ml;\n+  PRInt32 loops;\n+  PRUint32 contender;\n+  PRUint32 contentious;\n+  PRIntervalTime overhead;\n+  PRIntervalTime interval;\n } LockContentious_t;\n \n typedef struct MonitorContentious_s {\n-    PRMonitor* ml;\n-    PRInt32 loops;\n-    PRUint32 contender;\n-    PRUint32 contentious;\n-    PRIntervalTime overhead;\n-    PRIntervalTime interval;\n+  PRMonitor* ml;\n+  PRInt32 loops;\n+  PRUint32 contender;\n+  PRUint32 contentious;\n+  PRIntervalTime overhead;\n+  PRIntervalTime interval;\n } MonitorContentious_t;\n \n-static PRIntervalTime\n-Sleeper(PRUint32 loops)\n-{\n-    PRIntervalTime predicted = 0;\n-    while (loops-- > 0) {\n-        predicted += contention_interval;\n-        (void)PR_Sleep(contention_interval);\n-    }\n-    return predicted;\n+static PRIntervalTime Sleeper(PRUint32 loops) {\n+  PRIntervalTime predicted = 0;\n+  while (loops-- > 0) {\n+    predicted += contention_interval;\n+    (void)PR_Sleep(contention_interval);\n+  }\n+  return predicted;\n } /* Sleeper */\n \n /*\n ** BASIC LOCKS\n */\n-static PRIntervalTime\n-MakeLock(PRUint32 loops)\n-{\n-    PRLock* ml = NULL;\n-    while (loops-- > 0) {\n-        ml = PR_NewLock();\n-        PR_DestroyLock(ml);\n-        ml = NULL;\n-    }\n-    return 0;\n-} /* MakeLock */\n-\n-static PRIntervalTime\n-NonContentiousLock(PRUint32 loops)\n-{\n-    PRLock* ml = NULL;\n+static PRIntervalTime MakeLock(PRUint32 loops) {\n+  PRLock* ml = NULL;\n+  while (loops-- > 0) {\n     ml = PR_NewLock();\n-    while (loops-- > 0) {\n-        PR_Lock(ml);\n-        PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(ml);\n-        PR_Unlock(ml);\n-    }\n     PR_DestroyLock(ml);\n-    return 0;\n+    ml = NULL;\n+  }\n+  return 0;\n+} /* MakeLock */\n+\n+static PRIntervalTime NonContentiousLock(PRUint32 loops) {\n+  PRLock* ml = NULL;\n+  ml = PR_NewLock();\n+  while (loops-- > 0) {\n+    PR_Lock(ml);\n+    PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(ml);\n+    PR_Unlock(ml);\n+  }\n+  PR_DestroyLock(ml);\n+  return 0;\n } /* NonContentiousLock */\n \n-static void PR_CALLBACK\n-LockContender(void* arg)\n-{\n-    LockContentious_t* contention = (LockContentious_t*)arg;\n-    while (contention->loops-- > 0) {\n-        PR_Lock(contention->ml);\n-        PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(contention->ml);\n-        contention->contender += 1;\n-        contention->overhead += contention->interval;\n-        PR_Sleep(contention->interval);\n-        PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(contention->ml);\n-        PR_Unlock(contention->ml);\n-    }\n+static void PR_CALLBACK LockContender(void* arg) {\n+  LockContentious_t* contention = (LockContentious_t*)arg;\n+  while (contention->loops-- > 0) {\n+    PR_Lock(contention->ml);\n+    PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(contention->ml);\n+    contention->contender += 1;\n+    contention->overhead += contention->interval;\n+    PR_Sleep(contention->interval);\n+    PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(contention->ml);\n+    PR_Unlock(contention->ml);\n+  }\n } /* LockContender */\n \n-static PRIntervalTime\n-ContentiousLock(PRUint32 loops)\n-{\n-    PRStatus status;\n-    PRThread* thread = NULL;\n-    LockContentious_t* contention;\n-    PRIntervalTime rv, overhead, timein = PR_IntervalNow();\n-\n-    contention = PR_NEWZAP(LockContentious_t);\n-    contention->loops = loops;\n-    contention->overhead = 0;\n-    contention->ml = PR_NewLock();\n-    contention->interval = contention_interval;\n-    thread =\n-        PR_CreateThread(PR_USER_THREAD, LockContender, contention,\n-                        PR_PRIORITY_LOW, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    PR_ASSERT(thread != NULL);\n-\n-    overhead = PR_IntervalNow() - timein;\n-\n-    while (contention->loops-- > 0) {\n-        PR_Lock(contention->ml);\n-        PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(contention->ml);\n-        contention->contentious += 1;\n-        contention->overhead += contention->interval;\n-        PR_Sleep(contention->interval);\n-        PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(contention->ml);\n-        PR_Unlock(contention->ml);\n-    }\n-\n-    timein = PR_IntervalNow();\n-    status = PR_JoinThread(thread);\n-    PR_DestroyLock(contention->ml);\n-    overhead += (PR_IntervalNow() - timein);\n-    rv = overhead + contention->overhead;\n-    if (verbosity)\n-        PR_fprintf(std_err, \"Access ratio: %u to %u\\n\", contention->contentious,\n-                   contention->contender);\n-    PR_Free(contention);\n-    return rv;\n+static PRIntervalTime ContentiousLock(PRUint32 loops) {\n+  PRStatus status;\n+  PRThread* thread = NULL;\n+  LockContentious_t* contention;\n+  PRIntervalTime rv, overhead, timein = PR_IntervalNow();\n+\n+  contention = PR_NEWZAP(LockContentious_t);\n+  contention->loops = loops;\n+  contention->overhead = 0;\n+  contention->ml = PR_NewLock();\n+  contention->interval = contention_interval;\n+  thread =\n+      PR_CreateThread(PR_USER_THREAD, LockContender, contention,\n+                      PR_PRIORITY_LOW, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  PR_ASSERT(thread != NULL);\n+\n+  overhead = PR_IntervalNow() - timein;\n+\n+  while (contention->loops-- > 0) {\n+    PR_Lock(contention->ml);\n+    PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(contention->ml);\n+    contention->contentious += 1;\n+    contention->overhead += contention->interval;\n+    PR_Sleep(contention->interval);\n+    PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(contention->ml);\n+    PR_Unlock(contention->ml);\n+  }\n+\n+  timein = PR_IntervalNow();\n+  status = PR_JoinThread(thread);\n+  PR_DestroyLock(contention->ml);\n+  overhead += (PR_IntervalNow() - timein);\n+  rv = overhead + contention->overhead;\n+  if (verbosity)\n+    PR_fprintf(std_err, \"Access ratio: %u to %u\\n\", contention->contentious,\n+               contention->contender);\n+  PR_Free(contention);\n+  return rv;\n } /* ContentiousLock */\n \n /*\n ** MONITORS\n */\n-static PRIntervalTime\n-MakeMonitor(PRUint32 loops)\n-{\n-    PRMonitor* ml = NULL;\n-    while (loops-- > 0) {\n-        ml = PR_NewMonitor();\n-        PR_DestroyMonitor(ml);\n-        ml = NULL;\n-    }\n-    return 0;\n-} /* MakeMonitor */\n-\n-static PRIntervalTime\n-NonContentiousMonitor(PRUint32 loops)\n-{\n-    PRMonitor* ml = NULL;\n+static PRIntervalTime MakeMonitor(PRUint32 loops) {\n+  PRMonitor* ml = NULL;\n+  while (loops-- > 0) {\n     ml = PR_NewMonitor();\n-    while (loops-- > 0) {\n-        PR_EnterMonitor(ml);\n-        PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);\n-        PR_ExitMonitor(ml);\n-    }\n     PR_DestroyMonitor(ml);\n-    return 0;\n-} /* NonContentiousMonitor */\n+    ml = NULL;\n+  }\n+  return 0;\n+} /* MakeMonitor */\n \n-static void PR_CALLBACK\n-TryEntry(void* arg)\n-{\n-    PRMonitor* ml = (PRMonitor*)arg;\n-    if (debug_mode) {\n-        PR_fprintf(std_err, \"Reentrant thread created\\n\");\n-    }\n+static PRIntervalTime NonContentiousMonitor(PRUint32 loops) {\n+  PRMonitor* ml = NULL;\n+  ml = PR_NewMonitor();\n+  while (loops-- > 0) {\n     PR_EnterMonitor(ml);\n     PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);\n-    if (debug_mode) {\n-        PR_fprintf(std_err, \"Reentrant thread acquired monitor\\n\");\n-    }\n     PR_ExitMonitor(ml);\n-    if (debug_mode) {\n-        PR_fprintf(std_err, \"Reentrant thread released monitor\\n\");\n-    }\n-} /* TryEntry */\n-\n-static PRIntervalTime\n-ReentrantMonitor(PRUint32 loops)\n-{\n-    PRStatus status;\n-    PRThread* thread;\n-    PRMonitor* ml = PR_NewMonitor();\n-    if (debug_mode) {\n-        PR_fprintf(std_err, \"\\nMonitor created for reentrant test\\n\");\n-    }\n-\n-    PR_EnterMonitor(ml);\n-    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);\n-    PR_EnterMonitor(ml);\n-    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);\n-    if (debug_mode) {\n-        PR_fprintf(std_err, \"Monitor acquired twice\\n\");\n-    }\n-\n-    thread = PR_CreateThread(PR_USER_THREAD, TryEntry, ml, PR_PRIORITY_LOW,\n-                             PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    PR_ASSERT(thread != NULL);\n-    PR_Sleep(PR_SecondsToInterval(1));\n-    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);\n-\n-    PR_ExitMonitor(ml);\n-    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);\n-    if (debug_mode) {\n-        PR_fprintf(std_err, \"Monitor released first time\\n\");\n-    }\n-\n-    PR_ExitMonitor(ml);\n-    if (debug_mode) {\n-        PR_fprintf(std_err, \"Monitor released second time\\n\");\n-    }\n+  }\n+  PR_DestroyMonitor(ml);\n+  return 0;\n+} /* NonContentiousMonitor */\n \n-    status = PR_JoinThread(thread);\n-    if (debug_mode)\n-        PR_fprintf(std_err, \"Reentrant thread joined %s\\n\",\n-                   (status == PR_SUCCESS) ? \"successfully\" : \"in error\");\n+static void PR_CALLBACK TryEntry(void* arg) {\n+  PRMonitor* ml = (PRMonitor*)arg;\n+  if (debug_mode) {\n+    PR_fprintf(std_err, \"Reentrant thread created\\n\");\n+  }\n+  PR_EnterMonitor(ml);\n+  PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);\n+  if (debug_mode) {\n+    PR_fprintf(std_err, \"Reentrant thread acquired monitor\\n\");\n+  }\n+  PR_ExitMonitor(ml);\n+  if (debug_mode) {\n+    PR_fprintf(std_err, \"Reentrant thread released monitor\\n\");\n+  }\n+} /* TryEntry */\n \n-    PR_DestroyMonitor(ml);\n-    return 0;\n+static PRIntervalTime ReentrantMonitor(PRUint32 loops) {\n+  PRStatus status;\n+  PRThread* thread;\n+  PRMonitor* ml = PR_NewMonitor();\n+  if (debug_mode) {\n+    PR_fprintf(std_err, \"\\nMonitor created for reentrant test\\n\");\n+  }\n+\n+  PR_EnterMonitor(ml);\n+  PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);\n+  PR_EnterMonitor(ml);\n+  PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);\n+  if (debug_mode) {\n+    PR_fprintf(std_err, \"Monitor acquired twice\\n\");\n+  }\n+\n+  thread = PR_CreateThread(PR_USER_THREAD, TryEntry, ml, PR_PRIORITY_LOW,\n+                           PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  PR_ASSERT(thread != NULL);\n+  PR_Sleep(PR_SecondsToInterval(1));\n+  PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);\n+\n+  PR_ExitMonitor(ml);\n+  PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);\n+  if (debug_mode) {\n+    PR_fprintf(std_err, \"Monitor released first time\\n\");\n+  }\n+\n+  PR_ExitMonitor(ml);\n+  if (debug_mode) {\n+    PR_fprintf(std_err, \"Monitor released second time\\n\");\n+  }\n+\n+  status = PR_JoinThread(thread);\n+  if (debug_mode)\n+    PR_fprintf(std_err, \"Reentrant thread joined %s\\n\",\n+               (status == PR_SUCCESS) ? \"successfully\" : \"in error\");\n+\n+  PR_DestroyMonitor(ml);\n+  return 0;\n } /* ReentrantMonitor */\n \n-static void PR_CALLBACK\n-MonitorContender(void* arg)\n-{\n-    MonitorContentious_t* contention = (MonitorContentious_t*)arg;\n-    while (contention->loops-- > 0) {\n-        PR_EnterMonitor(contention->ml);\n-        PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);\n-        contention->contender += 1;\n-        contention->overhead += contention->interval;\n-        PR_Sleep(contention->interval);\n-        PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);\n-        PR_ExitMonitor(contention->ml);\n-    }\n+static void PR_CALLBACK MonitorContender(void* arg) {\n+  MonitorContentious_t* contention = (MonitorContentious_t*)arg;\n+  while (contention->loops-- > 0) {\n+    PR_EnterMonitor(contention->ml);\n+    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);\n+    contention->contender += 1;\n+    contention->overhead += contention->interval;\n+    PR_Sleep(contention->interval);\n+    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);\n+    PR_ExitMonitor(contention->ml);\n+  }\n } /* MonitorContender */\n \n-static PRUint32\n-ContentiousMonitor(PRUint32 loops)\n-{\n-    PRStatus status;\n-    PRThread* thread = NULL;\n-    MonitorContentious_t* contention;\n-    PRIntervalTime rv, overhead, timein = PR_IntervalNow();\n-\n-    contention = PR_NEWZAP(MonitorContentious_t);\n-    contention->loops = loops;\n-    contention->overhead = 0;\n-    contention->ml = PR_NewMonitor();\n-    contention->interval = contention_interval;\n-    thread =\n-        PR_CreateThread(PR_USER_THREAD, MonitorContender, contention,\n-                        PR_PRIORITY_LOW, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    PR_ASSERT(thread != NULL);\n-\n-    overhead = PR_IntervalNow() - timein;\n-\n-    while (contention->loops-- > 0) {\n-        PR_EnterMonitor(contention->ml);\n-        PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);\n-        contention->contentious += 1;\n-        contention->overhead += contention->interval;\n-        PR_Sleep(contention->interval);\n-        PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);\n-        PR_ExitMonitor(contention->ml);\n-    }\n-\n-    timein = PR_IntervalNow();\n-    status = PR_JoinThread(thread);\n-    PR_DestroyMonitor(contention->ml);\n-    overhead += (PR_IntervalNow() - timein);\n-    rv = overhead + contention->overhead;\n-    if (verbosity)\n-        PR_fprintf(std_err, \"Access ratio: %u to %u\\n\", contention->contentious,\n-                   contention->contender);\n-    PR_Free(contention);\n-    return rv;\n+static PRUint32 ContentiousMonitor(PRUint32 loops) {\n+  PRStatus status;\n+  PRThread* thread = NULL;\n+  MonitorContentious_t* contention;\n+  PRIntervalTime rv, overhead, timein = PR_IntervalNow();\n+\n+  contention = PR_NEWZAP(MonitorContentious_t);\n+  contention->loops = loops;\n+  contention->overhead = 0;\n+  contention->ml = PR_NewMonitor();\n+  contention->interval = contention_interval;\n+  thread =\n+      PR_CreateThread(PR_USER_THREAD, MonitorContender, contention,\n+                      PR_PRIORITY_LOW, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  PR_ASSERT(thread != NULL);\n+\n+  overhead = PR_IntervalNow() - timein;\n+\n+  while (contention->loops-- > 0) {\n+    PR_EnterMonitor(contention->ml);\n+    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);\n+    contention->contentious += 1;\n+    contention->overhead += contention->interval;\n+    PR_Sleep(contention->interval);\n+    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);\n+    PR_ExitMonitor(contention->ml);\n+  }\n+\n+  timein = PR_IntervalNow();\n+  status = PR_JoinThread(thread);\n+  PR_DestroyMonitor(contention->ml);\n+  overhead += (PR_IntervalNow() - timein);\n+  rv = overhead + contention->overhead;\n+  if (verbosity)\n+    PR_fprintf(std_err, \"Access ratio: %u to %u\\n\", contention->contentious,\n+               contention->contender);\n+  PR_Free(contention);\n+  return rv;\n } /* ContentiousMonitor */\n \n /*\n ** CACHED MONITORS\n */\n-static PRIntervalTime\n-NonContentiousCMonitor(PRUint32 loops)\n-{\n-    MonitorContentious_t contention;\n-    while (loops-- > 0) {\n-        PR_CEnterMonitor(&contention);\n-        PR_CExitMonitor(&contention);\n-    }\n-    return 0;\n+static PRIntervalTime NonContentiousCMonitor(PRUint32 loops) {\n+  MonitorContentious_t contention;\n+  while (loops-- > 0) {\n+    PR_CEnterMonitor(&contention);\n+    PR_CExitMonitor(&contention);\n+  }\n+  return 0;\n } /* NonContentiousCMonitor */\n \n-static void PR_CALLBACK\n-Contender(void* arg)\n-{\n-    MonitorContentious_t* contention = (MonitorContentious_t*)arg;\n-    while (contention->loops-- > 0) {\n-        PR_CEnterMonitor(contention);\n-        contention->contender += 1;\n-        contention->overhead += contention->interval;\n-        PR_Sleep(contention->interval);\n-        PR_CExitMonitor(contention);\n-    }\n+static void PR_CALLBACK Contender(void* arg) {\n+  MonitorContentious_t* contention = (MonitorContentious_t*)arg;\n+  while (contention->loops-- > 0) {\n+    PR_CEnterMonitor(contention);\n+    contention->contender += 1;\n+    contention->overhead += contention->interval;\n+    PR_Sleep(contention->interval);\n+    PR_CExitMonitor(contention);\n+  }\n } /* Contender */\n \n-static PRIntervalTime\n-ContentiousCMonitor(PRUint32 loops)\n-{\n-    PRStatus status;\n-    PRThread* thread = NULL;\n-    MonitorContentious_t* contention;\n-    PRIntervalTime overhead, timein = PR_IntervalNow();\n-\n-    contention = PR_NEWZAP(MonitorContentious_t);\n-    contention->ml = NULL;\n-    contention->loops = loops;\n-    contention->interval = contention_interval;\n-    thread =\n-        PR_CreateThread(PR_USER_THREAD, Contender, contention, PR_PRIORITY_LOW,\n-                        PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    PR_ASSERT(thread != NULL);\n-\n-    overhead = PR_IntervalNow() - timein;\n-\n-    while (contention->loops-- > 0) {\n-        PR_CEnterMonitor(contention);\n-        contention->contentious += 1;\n-        contention->overhead += contention->interval;\n-        PR_Sleep(contention->interval);\n-        PR_CExitMonitor(contention);\n-    }\n-\n-    timein = PR_IntervalNow();\n-    status = PR_JoinThread(thread);\n-    overhead += (PR_IntervalNow() - timein);\n-    overhead += overhead + contention->overhead;\n-    if (verbosity)\n-        PR_fprintf(std_err, \"Access ratio: %u to %u\\n\", contention->contentious,\n-                   contention->contender);\n-    PR_Free(contention);\n-    return overhead;\n+static PRIntervalTime ContentiousCMonitor(PRUint32 loops) {\n+  PRStatus status;\n+  PRThread* thread = NULL;\n+  MonitorContentious_t* contention;\n+  PRIntervalTime overhead, timein = PR_IntervalNow();\n+\n+  contention = PR_NEWZAP(MonitorContentious_t);\n+  contention->ml = NULL;\n+  contention->loops = loops;\n+  contention->interval = contention_interval;\n+  thread =\n+      PR_CreateThread(PR_USER_THREAD, Contender, contention, PR_PRIORITY_LOW,\n+                      PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  PR_ASSERT(thread != NULL);\n+\n+  overhead = PR_IntervalNow() - timein;\n+\n+  while (contention->loops-- > 0) {\n+    PR_CEnterMonitor(contention);\n+    contention->contentious += 1;\n+    contention->overhead += contention->interval;\n+    PR_Sleep(contention->interval);\n+    PR_CExitMonitor(contention);\n+  }\n+\n+  timein = PR_IntervalNow();\n+  status = PR_JoinThread(thread);\n+  overhead += (PR_IntervalNow() - timein);\n+  overhead += overhead + contention->overhead;\n+  if (verbosity)\n+    PR_fprintf(std_err, \"Access ratio: %u to %u\\n\", contention->contentious,\n+               contention->contender);\n+  PR_Free(contention);\n+  return overhead;\n } /* ContentiousCMonitor */\n \n-static PRIntervalTime\n-Test(const char* msg, PRUint32 (*test)(PRUint32 loops),\n-     PRUint32 loops, PRIntervalTime overhead)\n-{\n-    /*\n-     * overhead - overhead not measured by the test.\n-     * duration - wall clock time it took to perform test.\n-     * predicted - extra time test says should not be counted\n-     *\n-     * Time accountable to the test is duration - overhead - predicted\n-     * All times are Intervals and accumulated for all iterations.\n-     */\n-    PRFloat64 elapsed;\n-    PRIntervalTime accountable, duration;\n-    PRUintn spaces = PL_strlen(msg);\n-    PRIntervalTime timeout, timein = PR_IntervalNow();\n-    PRIntervalTime predicted = test(loops);\n-    timeout = PR_IntervalNow();\n-    duration = timeout - timein;\n-\n-    if (debug_mode) {\n-        accountable = duration - predicted;\n-        accountable -= overhead;\n-        elapsed = (PRFloat64)PR_IntervalToMicroseconds(accountable);\n-        PR_fprintf(PR_STDOUT, \"%s:\", msg);\n-        while (spaces++ < 50) {\n-            PR_fprintf(PR_STDOUT, \" \");\n-        }\n-        if ((PRInt32)accountable < 0) {\n-            PR_fprintf(PR_STDOUT, \"*****.** usecs/iteration\\n\");\n-        } else {\n-            PR_fprintf(PR_STDOUT, \"%8.2f usecs/iteration\\n\", elapsed / loops);\n-        }\n-    }\n-    return duration;\n-} /* Test */\n-\n-int\n-main(int argc, char** argv)\n-{\n-    PRBool rv = PR_TRUE;\n-    PRIntervalTime duration;\n-    PRUint32 cpu, cpus = 2, loops = 100;\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-    {\n-        /* The command line argument: -d is used to determine if the test is being\n-        run in debug mode. The regress tool requires only one line output:PASS or\n-        FAIL. All of the printfs associated with this test has been handled with a\n-        if (debug_mode) test. Command line argument -l <num> sets the number of\n-        loops. Command line argument -c <num> sets the number of cpus. Usage: lock\n-        [-d] [-l <num>] [-c <num>]\n-        */\n-        PLOptStatus os;\n-        PLOptState* opt = PL_CreateOptState(argc, argv, \"dvl:c:\");\n-        while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-            if (PL_OPT_BAD == os) {\n-                continue;\n-            }\n-            switch (opt->option) {\n-                case 'd': /* debug mode */\n-                    debug_mode = PR_TRUE;\n-                    break;\n-                case 'v': /* debug mode */\n-                    verbosity = PR_TRUE;\n-                    break;\n-                case 'l': /* number of loops */\n-                    loops = atoi(opt->value);\n-                    break;\n-                case 'c': /* number of cpus */\n-                    cpus = atoi(opt->value);\n-                    break;\n-                default:\n-                    break;\n-            }\n-        }\n-        PL_DestroyOptState(opt);\n-    }\n-\n-    /* main test */\n-    PR_SetConcurrency(8);\n-\n-    if (loops == 0) {\n-        loops = 100;\n+static PRIntervalTime Test(const char* msg, PRUint32 (*test)(PRUint32 loops),\n+                           PRUint32 loops, PRIntervalTime overhead) {\n+  /*\n+   * overhead - overhead not measured by the test.\n+   * duration - wall clock time it took to perform test.\n+   * predicted - extra time test says should not be counted\n+   *\n+   * Time accountable to the test is duration - overhead - predicted\n+   * All times are Intervals and accumulated for all iterations.\n+   */\n+  PRFloat64 elapsed;\n+  PRIntervalTime accountable, duration;\n+  PRUintn spaces = PL_strlen(msg);\n+  PRIntervalTime timeout, timein = PR_IntervalNow();\n+  PRIntervalTime predicted = test(loops);\n+  timeout = PR_IntervalNow();\n+  duration = timeout - timein;\n+\n+  if (debug_mode) {\n+    accountable = duration - predicted;\n+    accountable -= overhead;\n+    elapsed = (PRFloat64)PR_IntervalToMicroseconds(accountable);\n+    PR_fprintf(PR_STDOUT, \"%s:\", msg);\n+    while (spaces++ < 50) {\n+      PR_fprintf(PR_STDOUT, \" \");\n     }\n-    if (debug_mode) {\n-        std_err = PR_STDERR;\n-        PR_fprintf(std_err, \"Lock: Using %d loops\\n\", loops);\n+    if ((PRInt32)accountable < 0) {\n+      PR_fprintf(PR_STDOUT, \"*****.** usecs/iteration\\n\");\n+    } else {\n+      PR_fprintf(PR_STDOUT, \"%8.2f usecs/iteration\\n\", elapsed / loops);\n     }\n+  }\n+  return duration;\n+} /* Test */\n \n-    if (cpus == 0) {\n-        cpus = 2;\n+int main(int argc, char** argv) {\n+  PRBool rv = PR_TRUE;\n+  PRIntervalTime duration;\n+  PRUint32 cpu, cpus = 2, loops = 100;\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  {\n+    /* The command line argument: -d is used to determine if the test is being\n+    run in debug mode. The regress tool requires only one line output:PASS or\n+    FAIL. All of the printfs associated with this test has been handled with a\n+    if (debug_mode) test. Command line argument -l <num> sets the number of\n+    loops. Command line argument -c <num> sets the number of cpus. Usage: lock\n+    [-d] [-l <num>] [-c <num>]\n+    */\n+    PLOptStatus os;\n+    PLOptState* opt = PL_CreateOptState(argc, argv, \"dvl:c:\");\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+      if (PL_OPT_BAD == os) {\n+        continue;\n+      }\n+      switch (opt->option) {\n+        case 'd': /* debug mode */\n+          debug_mode = PR_TRUE;\n+          break;\n+        case 'v': /* debug mode */\n+          verbosity = PR_TRUE;\n+          break;\n+        case 'l': /* number of loops */\n+          loops = atoi(opt->value);\n+          break;\n+        case 'c': /* number of cpus */\n+          cpus = atoi(opt->value);\n+          break;\n+        default:\n+          break;\n+      }\n     }\n+    PL_DestroyOptState(opt);\n+  }\n+\n+  /* main test */\n+  PR_SetConcurrency(8);\n+\n+  if (loops == 0) {\n+    loops = 100;\n+  }\n+  if (debug_mode) {\n+    std_err = PR_STDERR;\n+    PR_fprintf(std_err, \"Lock: Using %d loops\\n\", loops);\n+  }\n+\n+  if (cpus == 0) {\n+    cpus = 2;\n+  }\n+  if (debug_mode) {\n+    PR_fprintf(std_err, \"Lock: Using %d cpu(s)\\n\", cpus);\n+  }\n+\n+  (void)Sleeper(10); /* try filling in the caches */\n+\n+  for (cpu = 1; cpu <= cpus; ++cpu) {\n     if (debug_mode) {\n-        PR_fprintf(std_err, \"Lock: Using %d cpu(s)\\n\", cpus);\n+      PR_fprintf(std_err, \"\\nLock: Using %d CPU(s)\\n\", cpu);\n     }\n-\n-    (void)Sleeper(10); /* try filling in the caches */\n-\n-    for (cpu = 1; cpu <= cpus; ++cpu) {\n-        if (debug_mode) {\n-            PR_fprintf(std_err, \"\\nLock: Using %d CPU(s)\\n\", cpu);\n-        }\n-        PR_SetConcurrency(cpu);\n-\n-        duration = Test(\"Overhead of PR_Sleep\", Sleeper, loops, 0);\n-        duration = 0;\n-\n-        (void)Test(\"Lock creation/deletion\", MakeLock, loops, 0);\n-        (void)Test(\"Lock non-contentious locking/unlocking\", NonContentiousLock,\n-                   loops, 0);\n-        (void)Test(\"Lock contentious locking/unlocking\", ContentiousLock, loops,\n-                   duration);\n-        (void)Test(\"Monitor creation/deletion\", MakeMonitor, loops, 0);\n-        (void)Test(\"Monitor non-contentious locking/unlocking\",\n-                   NonContentiousMonitor, loops, 0);\n-        (void)Test(\"Monitor contentious locking/unlocking\", ContentiousMonitor,\n-                   loops, duration);\n-\n-        (void)Test(\"Cached monitor non-contentious locking/unlocking\",\n-                   NonContentiousCMonitor, loops, 0);\n-        (void)Test(\"Cached monitor contentious locking/unlocking\",\n-                   ContentiousCMonitor, loops, duration);\n-\n-        (void)ReentrantMonitor(loops);\n+    PR_SetConcurrency(cpu);\n+\n+    duration = Test(\"Overhead of PR_Sleep\", Sleeper, loops, 0);\n+    duration = 0;\n+\n+    (void)Test(\"Lock creation/deletion\", MakeLock, loops, 0);\n+    (void)Test(\"Lock non-contentious locking/unlocking\", NonContentiousLock,\n+               loops, 0);\n+    (void)Test(\"Lock contentious locking/unlocking\", ContentiousLock, loops,\n+               duration);\n+    (void)Test(\"Monitor creation/deletion\", MakeMonitor, loops, 0);\n+    (void)Test(\"Monitor non-contentious locking/unlocking\",\n+               NonContentiousMonitor, loops, 0);\n+    (void)Test(\"Monitor contentious locking/unlocking\", ContentiousMonitor,\n+               loops, duration);\n+\n+    (void)Test(\"Cached monitor non-contentious locking/unlocking\",\n+               NonContentiousCMonitor, loops, 0);\n+    (void)Test(\"Cached monitor contentious locking/unlocking\",\n+               ContentiousCMonitor, loops, duration);\n+\n+    (void)ReentrantMonitor(loops);\n+  }\n+\n+  if (debug_mode)\n+    PR_fprintf(std_err, \"%s: test %s\\n\", \"Lock(mutex) test\",\n+               ((rv) ? \"passed\" : \"failed\"));\n+  else {\n+    if (!rv) {\n+      failed_already = 1;\n     }\n+  }\n \n-    if (debug_mode)\n-        PR_fprintf(std_err, \"%s: test %s\\n\", \"Lock(mutex) test\",\n-                   ((rv) ? \"passed\" : \"failed\"));\n-    else {\n-        if (!rv) {\n-            failed_already = 1;\n-        }\n-    }\n-\n-    if (failed_already) {\n-        PR_fprintf(PR_STDOUT, \"FAIL\\n\");\n-        return 1;\n-    } else {\n-        PR_fprintf(PR_STDOUT, \"PASS\\n\");\n-        return 0;\n-    }\n+  if (failed_already) {\n+    PR_fprintf(PR_STDOUT, \"FAIL\\n\");\n+    return 1;\n+  } else {\n+    PR_fprintf(PR_STDOUT, \"PASS\\n\");\n+    return 0;\n+  }\n \n } /* main */\n \ndiff --git a/nspr/pr/tests/lockfile.c b/nspr/pr/tests/lockfile.c\nindex 11c2787..244958e 100644\n--- a/nspr/pr/tests/lockfile.c\n+++ b/nspr/pr/tests/lockfile.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -49,51 +50,47 @@ PRIntn debug_mode;\n const static PRIntervalTime contention_interval = 50;\n \n typedef struct LockContentious_s {\n-    PRLock* ml;\n-    PRInt32 loops;\n-    PRIntervalTime overhead;\n-    PRIntervalTime interval;\n+  PRLock* ml;\n+  PRInt32 loops;\n+  PRIntervalTime overhead;\n+  PRIntervalTime interval;\n } LockContentious_t;\n \n #define LOCKFILE \"prlock.fil\"\n \n-static PRIntervalTime\n-NonContentiousLock(PRInt32 loops)\n-{\n-    PRFileDesc* _lockfile;\n-    while (loops-- > 0) {\n-        _lockfile = PR_Open(LOCKFILE, PR_CREATE_FILE | PR_RDWR, 0666);\n-        if (!_lockfile) {\n-            if (debug_mode)\n-                printf(\"could not create lockfile: %d [%d]\\n\", PR_GetError(),\n-                       PR_GetOSError());\n-            return PR_INTERVAL_NO_TIMEOUT;\n-        }\n-        PR_LockFile(_lockfile);\n-        PR_UnlockFile(_lockfile);\n-        PR_Close(_lockfile);\n+static PRIntervalTime NonContentiousLock(PRInt32 loops) {\n+  PRFileDesc* _lockfile;\n+  while (loops-- > 0) {\n+    _lockfile = PR_Open(LOCKFILE, PR_CREATE_FILE | PR_RDWR, 0666);\n+    if (!_lockfile) {\n+      if (debug_mode)\n+        printf(\"could not create lockfile: %d [%d]\\n\", PR_GetError(),\n+               PR_GetOSError());\n+      return PR_INTERVAL_NO_TIMEOUT;\n     }\n-    return 0;\n+    PR_LockFile(_lockfile);\n+    PR_UnlockFile(_lockfile);\n+    PR_Close(_lockfile);\n+  }\n+  return 0;\n } /* NonContentiousLock */\n \n-static void PR_CALLBACK\n-LockContender(void* arg)\n-{\n-    LockContentious_t* contention = (LockContentious_t*)arg;\n-    PRFileDesc* _lockfile;\n-    while (contention->loops-- > 0) {\n-        _lockfile = PR_Open(LOCKFILE, PR_CREATE_FILE | PR_RDWR, 0666);\n-        if (!_lockfile) {\n-            if (debug_mode)\n-                printf(\"could not create lockfile: %d [%d]\\n\", PR_GetError(),\n-                       PR_GetOSError());\n-            break;\n-        }\n-        PR_LockFile(_lockfile);\n-        PR_Sleep(contention->interval);\n-        PR_UnlockFile(_lockfile);\n-        PR_Close(_lockfile);\n+static void PR_CALLBACK LockContender(void* arg) {\n+  LockContentious_t* contention = (LockContentious_t*)arg;\n+  PRFileDesc* _lockfile;\n+  while (contention->loops-- > 0) {\n+    _lockfile = PR_Open(LOCKFILE, PR_CREATE_FILE | PR_RDWR, 0666);\n+    if (!_lockfile) {\n+      if (debug_mode)\n+        printf(\"could not create lockfile: %d [%d]\\n\", PR_GetError(),\n+               PR_GetOSError());\n+      break;\n     }\n+    PR_LockFile(_lockfile);\n+    PR_Sleep(contention->interval);\n+    PR_UnlockFile(_lockfile);\n+    PR_Close(_lockfile);\n+  }\n \n } /* LockContender */\n \n@@ -102,153 +99,147 @@ LockContender(void* arg)\n */\n static LockContentious_t contention;\n \n-static PRIntervalTime\n-ContentiousLock(PRInt32 loops)\n-{\n-    PRStatus status;\n-    PRThread* thread = NULL;\n-    PRIntervalTime overhead, timein = PR_IntervalNow();\n-\n-    contention.loops = loops;\n-    contention.overhead = 0;\n-    contention.ml = PR_NewLock();\n-    contention.interval = contention_interval;\n-    thread =\n-        PR_CreateThread(PR_USER_THREAD, LockContender, &contention,\n-                        PR_PRIORITY_LOW, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    PR_ASSERT(thread != NULL);\n-\n-    overhead = PR_IntervalNow() - timein;\n-\n-    while (contention.loops > 0) {\n-        PR_Lock(contention.ml);\n-        contention.overhead += contention.interval;\n-        PR_Sleep(contention.interval);\n-        PR_Unlock(contention.ml);\n-    }\n-\n-    timein = PR_IntervalNow();\n-    status = PR_JoinThread(thread);\n-    PR_DestroyLock(contention.ml);\n-    overhead += (PR_IntervalNow() - timein);\n-    return overhead + contention.overhead;\n+static PRIntervalTime ContentiousLock(PRInt32 loops) {\n+  PRStatus status;\n+  PRThread* thread = NULL;\n+  PRIntervalTime overhead, timein = PR_IntervalNow();\n+\n+  contention.loops = loops;\n+  contention.overhead = 0;\n+  contention.ml = PR_NewLock();\n+  contention.interval = contention_interval;\n+  thread =\n+      PR_CreateThread(PR_USER_THREAD, LockContender, &contention,\n+                      PR_PRIORITY_LOW, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  PR_ASSERT(thread != NULL);\n+\n+  overhead = PR_IntervalNow() - timein;\n+\n+  while (contention.loops > 0) {\n+    PR_Lock(contention.ml);\n+    contention.overhead += contention.interval;\n+    PR_Sleep(contention.interval);\n+    PR_Unlock(contention.ml);\n+  }\n+\n+  timein = PR_IntervalNow();\n+  status = PR_JoinThread(thread);\n+  PR_DestroyLock(contention.ml);\n+  overhead += (PR_IntervalNow() - timein);\n+  return overhead + contention.overhead;\n } /* ContentiousLock */\n \n-static PRIntervalTime\n-Test(const char* msg,\n-     PRIntervalTime (*test)(PRInt32 loops), PRInt32 loops,\n-     PRIntervalTime overhead)\n-{\n-    /*\n-     * overhead - overhead not measured by the test.\n-     * duration - wall clock time it took to perform test.\n-     * predicted - extra time test says should not be counted\n-     *\n-     * Time accountable to the test is duration - overhead - predicted\n-     * All times are Intervals and accumulated for all iterations.\n-     */\n-    PRFloat64 elapsed;\n-    PRIntervalTime accountable, duration;\n-    PRUintn spaces = strlen(msg);\n-    PRIntervalTime timeout, timein = PR_IntervalNow();\n-    PRIntervalTime predicted = test(loops);\n-    timeout = PR_IntervalNow();\n-    duration = timeout - timein;\n-    accountable = duration - predicted;\n-    accountable -= overhead;\n-    elapsed = (PRFloat64)PR_IntervalToMicroseconds(accountable);\n+static PRIntervalTime Test(const char* msg,\n+                           PRIntervalTime (*test)(PRInt32 loops), PRInt32 loops,\n+                           PRIntervalTime overhead) {\n+  /*\n+   * overhead - overhead not measured by the test.\n+   * duration - wall clock time it took to perform test.\n+   * predicted - extra time test says should not be counted\n+   *\n+   * Time accountable to the test is duration - overhead - predicted\n+   * All times are Intervals and accumulated for all iterations.\n+   */\n+  PRFloat64 elapsed;\n+  PRIntervalTime accountable, duration;\n+  PRUintn spaces = strlen(msg);\n+  PRIntervalTime timeout, timein = PR_IntervalNow();\n+  PRIntervalTime predicted = test(loops);\n+  timeout = PR_IntervalNow();\n+  duration = timeout - timein;\n+  accountable = duration - predicted;\n+  accountable -= overhead;\n+  elapsed = (PRFloat64)PR_IntervalToMicroseconds(accountable);\n+  if (debug_mode) {\n+    printf(\"%s:\", msg);\n+  }\n+  while (spaces++ < 50)\n     if (debug_mode) {\n-        printf(\"%s:\", msg);\n-    }\n-    while (spaces++ < 50)\n-        if (debug_mode) {\n-            printf(\" \");\n-        }\n-    if ((PRInt32)accountable < 0) {\n-        if (debug_mode) {\n-            printf(\"*****.** usecs/iteration\\n\");\n-        }\n-    } else {\n-        if (debug_mode) {\n-            printf(\"%8.2f usecs/iteration\\n\", elapsed / loops);\n-        }\n-    }\n-    return duration;\n-} /* Test */\n-\n-int\n-main(int argc, char** argv)\n-{\n-    PRIntervalTime duration;\n-    PRUint32 cpu, cpus = 2;\n-    PRInt32 loops = 100;\n-\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    if (argc > 1) {\n-        loops = atoi(argv[1]);\n-    }\n-    if (loops == 0) {\n-        loops = 100;\n+      printf(\" \");\n     }\n+  if ((PRInt32)accountable < 0) {\n     if (debug_mode) {\n-        printf(\"Lock: Using %d loops\\n\", loops);\n-    }\n-\n-    cpus = (argc < 3) ? 2 : atoi(argv[2]);\n-    if (cpus == 0) {\n-        cpus = 2;\n+      printf(\"*****.** usecs/iteration\\n\");\n     }\n+  } else {\n     if (debug_mode) {\n-        printf(\"Lock: Using %d cpu(s)\\n\", cpus);\n+      printf(\"%8.2f usecs/iteration\\n\", elapsed / loops);\n     }\n+  }\n+  return duration;\n+} /* Test */\n \n-    for (cpu = 1; cpu <= cpus; ++cpu) {\n-        if (debug_mode) {\n-            printf(\"\\nLockFile: Using %d CPU(s)\\n\", cpu);\n-        }\n-        PR_SetConcurrency(cpu);\n-\n-        duration = Test(\"LockFile non-contentious locking/unlocking\",\n-                        NonContentiousLock, loops, 0);\n-        (void)Test(\"LockFile contentious locking/unlocking\", ContentiousLock, loops,\n-                   duration);\n+int main(int argc, char** argv) {\n+  PRIntervalTime duration;\n+  PRUint32 cpu, cpus = 2;\n+  PRInt32 loops = 100;\n+\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-\n-    PR_Delete(LOCKFILE); /* try to get rid of evidence */\n-\n-    if (debug_mode) {\n-        printf(\"%s: test %s\\n\", \"Lock(mutex) test\",\n-               ((failed_already) ? \"failed\" : \"passed\"));\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  if (argc > 1) {\n+    loops = atoi(argv[1]);\n+  }\n+  if (loops == 0) {\n+    loops = 100;\n+  }\n+  if (debug_mode) {\n+    printf(\"Lock: Using %d loops\\n\", loops);\n+  }\n+\n+  cpus = (argc < 3) ? 2 : atoi(argv[2]);\n+  if (cpus == 0) {\n+    cpus = 2;\n+  }\n+  if (debug_mode) {\n+    printf(\"Lock: Using %d cpu(s)\\n\", cpus);\n+  }\n+\n+  for (cpu = 1; cpu <= cpus; ++cpu) {\n+    if (debug_mode) {\n+      printf(\"\\nLockFile: Using %d CPU(s)\\n\", cpu);\n     }\n+    PR_SetConcurrency(cpu);\n+\n+    duration = Test(\"LockFile non-contentious locking/unlocking\",\n+                    NonContentiousLock, loops, 0);\n+    (void)Test(\"LockFile contentious locking/unlocking\", ContentiousLock, loops,\n+               duration);\n+  }\n+\n+  PR_Delete(LOCKFILE); /* try to get rid of evidence */\n+\n+  if (debug_mode) {\n+    printf(\"%s: test %s\\n\", \"Lock(mutex) test\",\n+           ((failed_already) ? \"failed\" : \"passed\"));\n+  }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n } /* main */\n \n /* testlock.c */\ndiff --git a/nspr/pr/tests/logfile.c b/nspr/pr/tests/logfile.c\nindex e944995..aa3ef4a 100644\n--- a/nspr/pr/tests/logfile.c\n+++ b/nspr/pr/tests/logfile.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -16,23 +17,21 @@\n #include <stdio.h>\n #include <stdlib.h>\n \n-int\n-main()\n-{\n-    PRLogModuleInfo* test_lm;\n+int main() {\n+  PRLogModuleInfo* test_lm;\n \n-    if (putenv(\"NSPR_LOG_MODULES=all:5\") != 0) {\n-        fprintf(stderr, \"putenv failed\\n\");\n-        exit(1);\n-    }\n-    if (putenv(\"NSPR_LOG_FILE=logfile.log\") != 0) {\n-        fprintf(stderr, \"putenv failed\\n\");\n-        exit(1);\n-    }\n+  if (putenv(\"NSPR_LOG_MODULES=all:5\") != 0) {\n+    fprintf(stderr, \"putenv failed\\n\");\n+    exit(1);\n+  }\n+  if (putenv(\"NSPR_LOG_FILE=logfile.log\") != 0) {\n+    fprintf(stderr, \"putenv failed\\n\");\n+    exit(1);\n+  }\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-    test_lm = PR_NewLogModule(\"test\");\n-    PR_LOG(test_lm, PR_LOG_MIN, (\"logfile: test log message\"));\n-    PR_Cleanup();\n-    return 0;\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  test_lm = PR_NewLogModule(\"test\");\n+  PR_LOG(test_lm, PR_LOG_MIN, (\"logfile: test log message\"));\n+  PR_Cleanup();\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/logger.c b/nspr/pr/tests/logger.c\nindex 7fa36dc..e1cab96 100644\n--- a/nspr/pr/tests/logger.c\n+++ b/nspr/pr/tests/logger.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -18,106 +19,95 @@\n \n /* lth. re-define PR_LOG() */\n #if 0\n-#undef PR_LOG_TEST\n-#undef PR_LOG\n-#define PR_LOG_TEST(_module, _level) ((_module)->level <= (_level))\n-#define PR_LOG(_module, _level, _args)    \\\n-    {                                     \\\n-        if (PR_LOG_TEST(_module, _level)) \\\n-            PR_LogPrint _args;            \\\n+#  undef PR_LOG_TEST\n+#  undef PR_LOG\n+#  define PR_LOG_TEST(_module, _level) ((_module)->level <= (_level))\n+#  define PR_LOG(_module, _level, _args)                   \\\n+    {                                                      \\\n+      if (PR_LOG_TEST(_module, _level)) PR_LogPrint _args; \\\n     }\n #endif\n \n-static void\n-Error(const char* msg)\n-{\n-    printf(\"\\t%s\\n\", msg);\n-} /* Error */\n-\n-static void PR_CALLBACK\n-forked(void* arg)\n-{\n-    PRIntn i;\n-    PRLock* ml;\n-    PRCondVar* cv;\n-\n-    PR_LogPrint(\"%s logging creating mutex\\n\", (const char*)arg);\n-    ml = PR_NewLock();\n-    PR_LogPrint(\"%s logging creating condition variable\\n\", (const char*)arg);\n-    cv = PR_NewCondVar(ml);\n-\n-    PR_LogPrint(\"%s waiting on condition timeout 10 times\\n\", (const char*)arg);\n-    for (i = 0; i < 10; ++i) {\n-        PR_Lock(ml);\n-        PR_WaitCondVar(cv, PR_SecondsToInterval(1));\n-        PR_Unlock(ml);\n-    }\n-\n-    PR_LogPrint(\"%s logging destroying condition variable\\n\", (const char*)arg);\n-    PR_DestroyCondVar(cv);\n-    PR_LogPrint(\"%s logging destroying mutex\\n\", (const char*)arg);\n-    PR_DestroyLock(ml);\n-    PR_LogPrint(\"%s forked thread exiting\\n\", (const char*)arg);\n+static void Error(const char* msg) { printf(\"\\t%s\\n\", msg); } /* Error */\n+\n+static void PR_CALLBACK forked(void* arg) {\n+  PRIntn i;\n+  PRLock* ml;\n+  PRCondVar* cv;\n+\n+  PR_LogPrint(\"%s logging creating mutex\\n\", (const char*)arg);\n+  ml = PR_NewLock();\n+  PR_LogPrint(\"%s logging creating condition variable\\n\", (const char*)arg);\n+  cv = PR_NewCondVar(ml);\n+\n+  PR_LogPrint(\"%s waiting on condition timeout 10 times\\n\", (const char*)arg);\n+  for (i = 0; i < 10; ++i) {\n+    PR_Lock(ml);\n+    PR_WaitCondVar(cv, PR_SecondsToInterval(1));\n+    PR_Unlock(ml);\n+  }\n+\n+  PR_LogPrint(\"%s logging destroying condition variable\\n\", (const char*)arg);\n+  PR_DestroyCondVar(cv);\n+  PR_LogPrint(\"%s logging destroying mutex\\n\", (const char*)arg);\n+  PR_DestroyLock(ml);\n+  PR_LogPrint(\"%s forked thread exiting\\n\", (const char*)arg);\n }\n \n-static void\n-UserLogStuff(void)\n-{\n-    PRLogModuleInfo* myLM;\n-    PRIntn i;\n+static void UserLogStuff(void) {\n+  PRLogModuleInfo* myLM;\n+  PRIntn i;\n \n-    myLM = PR_NewLogModule(\"userStuff\");\n-    if (!myLM) {\n-        printf(\"UserLogStuff(): can't create new log module\\n\");\n-        return;\n-    }\n+  myLM = PR_NewLogModule(\"userStuff\");\n+  if (!myLM) {\n+    printf(\"UserLogStuff(): can't create new log module\\n\");\n+    return;\n+  }\n \n-    PR_LOG(myLM, PR_LOG_NOTICE, (\"Log a Notice %d\\n\", 1));\n+  PR_LOG(myLM, PR_LOG_NOTICE, (\"Log a Notice %d\\n\", 1));\n \n-    for (i = 0; i < 10; i++) {\n-        PR_LOG(myLM, PR_LOG_DEBUG, (\"Log Debug number: %d\\n\", i));\n-        PR_Sleep(300);\n-    }\n+  for (i = 0; i < 10; i++) {\n+    PR_LOG(myLM, PR_LOG_DEBUG, (\"Log Debug number: %d\\n\", i));\n+    PR_Sleep(300);\n+  }\n \n } /* end UserLogStuff() */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRThread* thread;\n+int main(int argc, char** argv) {\n+  PRThread* thread;\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    if (argc > 1) {\n-        if (!PR_SetLogFile(argv[1])) {\n-            Error(\"Access: Cannot create log file\");\n-            goto exit;\n-        }\n+  if (argc > 1) {\n+    if (!PR_SetLogFile(argv[1])) {\n+      Error(\"Access: Cannot create log file\");\n+      goto exit;\n     }\n+  }\n \n-    /* Start logging something here */\n-    PR_LogPrint(\"%s logging into %s\\n\", argv[0], argv[1]);\n+  /* Start logging something here */\n+  PR_LogPrint(\"%s logging into %s\\n\", argv[0], argv[1]);\n \n-    PR_LogPrint(\"%s creating new thread\\n\", argv[0]);\n+  PR_LogPrint(\"%s creating new thread\\n\", argv[0]);\n \n-    /*\n-    ** Now change buffering.\n-    */\n-    PR_SetLogBuffering(65500);\n-    thread = PR_CreateThread(PR_USER_THREAD, forked, (void*)argv[0],\n-                             PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n-                             PR_JOINABLE_THREAD, 0);\n-    PR_LogPrint(\"%s joining thread\\n\", argv[0]);\n+  /*\n+  ** Now change buffering.\n+  */\n+  PR_SetLogBuffering(65500);\n+  thread = PR_CreateThread(PR_USER_THREAD, forked, (void*)argv[0],\n+                           PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n+                           PR_JOINABLE_THREAD, 0);\n+  PR_LogPrint(\"%s joining thread\\n\", argv[0]);\n \n-    UserLogStuff();\n+  UserLogStuff();\n \n-    PR_JoinThread(thread);\n+  PR_JoinThread(thread);\n \n-    PR_LogFlush();\n-    return 0;\n+  PR_LogFlush();\n+  return 0;\n \n exit:\n-    return -1;\n+  return -1;\n }\n \n /* logger.c */\ndiff --git a/nspr/pr/tests/makedir.c b/nspr/pr/tests/makedir.c\nindex f262117..b98c161 100644\n--- a/nspr/pr/tests/makedir.c\n+++ b/nspr/pr/tests/makedir.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -12,56 +13,54 @@\n #include <stdio.h>\n #include <stdlib.h>\n \n-int\n-main(int argc, char** argv)\n-{\n-    if (PR_MakeDir(\"tdir0400\", 0400) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_MakeDir failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_MakeDir(\"tdir0200\", 0200) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_MakeDir failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_MakeDir(\"tdir0100\", 0100) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_MakeDir failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_MakeDir(\"tdir0500\", 0500) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_MakeDir failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_MakeDir(\"tdir0600\", 0600) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_MakeDir failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_MakeDir(\"tdir0300\", 0300) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_MakeDir failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_MakeDir(\"tdir0700\", 0700) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_MakeDir failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_MakeDir(\"tdir0640\", 0640) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_MakeDir failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_MakeDir(\"tdir0660\", 0660) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_MakeDir failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_MakeDir(\"tdir0644\", 0644) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_MakeDir failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_MakeDir(\"tdir0664\", 0664) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_MakeDir failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_MakeDir(\"tdir0666\", 0666) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_MakeDir failed\\n\");\n-        exit(1);\n-    }\n-    return 0;\n+int main(int argc, char** argv) {\n+  if (PR_MakeDir(\"tdir0400\", 0400) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_MakeDir failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_MakeDir(\"tdir0200\", 0200) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_MakeDir failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_MakeDir(\"tdir0100\", 0100) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_MakeDir failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_MakeDir(\"tdir0500\", 0500) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_MakeDir failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_MakeDir(\"tdir0600\", 0600) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_MakeDir failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_MakeDir(\"tdir0300\", 0300) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_MakeDir failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_MakeDir(\"tdir0700\", 0700) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_MakeDir failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_MakeDir(\"tdir0640\", 0640) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_MakeDir failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_MakeDir(\"tdir0660\", 0660) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_MakeDir failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_MakeDir(\"tdir0644\", 0644) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_MakeDir failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_MakeDir(\"tdir0664\", 0664) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_MakeDir failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_MakeDir(\"tdir0666\", 0666) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_MakeDir failed\\n\");\n+    exit(1);\n+  }\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/many_cv.c b/nspr/pr/tests/many_cv.c\nindex d1cea9d..314af8c 100644\n--- a/nspr/pr/tests/many_cv.c\n+++ b/nspr/pr/tests/many_cv.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -16,105 +17,97 @@\n \n #include <stdlib.h>\n \n-static PRInt32\n-RandomNum(void)\n-{\n-    PRInt32 ran = rand() >> 16;\n-    return ran;\n+static PRInt32 RandomNum(void) {\n+  PRInt32 ran = rand() >> 16;\n+  return ran;\n } /* RandomNum */\n \n-static void\n-Help(void)\n-{\n-    PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n-    PR_fprintf(err, \"many_cv usage: [-c n] [-l n] [-h]\\n\");\n-    PR_fprintf(err, \"\\t-c n Number of conditions per lock       (default: 10)\\n\");\n-    PR_fprintf(err, \"\\t-l n Number of times to loop the test    (default:  1)\\n\");\n-    PR_fprintf(err, \"\\t-h   This message and nothing else\\n\");\n+static void Help(void) {\n+  PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n+  PR_fprintf(err, \"many_cv usage: [-c n] [-l n] [-h]\\n\");\n+  PR_fprintf(err, \"\\t-c n Number of conditions per lock       (default: 10)\\n\");\n+  PR_fprintf(err, \"\\t-l n Number of times to loop the test    (default:  1)\\n\");\n+  PR_fprintf(err, \"\\t-h   This message and nothing else\\n\");\n } /* Help */\n \n-static PRIntn PR_CALLBACK\n-RealMain(PRIntn argc, char** argv)\n-{\n-    PLOptStatus os;\n-    PRIntn index, nl;\n-    PRLock* ml = NULL;\n-    PRCondVar** cv = NULL;\n-    PRBool stats = PR_FALSE;\n-    PRIntn nc, loops = 1, cvs = 10;\n-    PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"hsc:l:\");\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 's': /* number of CVs to association with lock */\n-                stats = PR_TRUE;\n-                break;\n-            case 'c': /* number of CVs to association with lock */\n-                cvs = atoi(opt->value);\n-                break;\n-            case 'l': /* number of times to run the tests */\n-                loops = atoi(opt->value);\n-                break;\n-            case 'h': /* user wants some guidance */\n-            default:\n-                Help();   /* so give him an earful */\n-                return 2; /* but not a lot else */\n-        }\n+static PRIntn PR_CALLBACK RealMain(PRIntn argc, char** argv) {\n+  PLOptStatus os;\n+  PRIntn index, nl;\n+  PRLock* ml = NULL;\n+  PRCondVar** cv = NULL;\n+  PRBool stats = PR_FALSE;\n+  PRIntn nc, loops = 1, cvs = 10;\n+  PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"hsc:l:\");\n+\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    PR_fprintf(err, \"Settings\\n\");\n-    PR_fprintf(err, \"\\tConditions / lock: %d\\n\", cvs);\n-    PR_fprintf(err, \"\\tLoops to run test: %d\\n\", loops);\n-\n-    ml = PR_NewLock();\n-    PR_ASSERT(NULL != ml);\n-\n-    cv = (PRCondVar**)PR_CALLOC(sizeof(PRCondVar*) * cvs);\n-    PR_ASSERT(NULL != cv);\n-\n-    for (index = 0; index < cvs; ++index) {\n-        cv[index] = PR_NewCondVar(ml);\n-        PR_ASSERT(NULL != cv[index]);\n+    switch (opt->option) {\n+      case 's': /* number of CVs to association with lock */\n+        stats = PR_TRUE;\n+        break;\n+      case 'c': /* number of CVs to association with lock */\n+        cvs = atoi(opt->value);\n+        break;\n+      case 'l': /* number of times to run the tests */\n+        loops = atoi(opt->value);\n+        break;\n+      case 'h': /* user wants some guidance */\n+      default:\n+        Help();   /* so give him an earful */\n+        return 2; /* but not a lot else */\n     }\n-\n-    for (index = 0; index < loops; ++index) {\n-        PR_Lock(ml);\n-        for (nl = 0; nl < cvs; ++nl) {\n-            PRInt32 ran = RandomNum() % 8;\n-            if (0 == ran) {\n-                PR_NotifyAllCondVar(cv[nl]);\n-            } else\n-                for (nc = 0; nc < ran; ++nc) {\n-                    PR_NotifyCondVar(cv[nl]);\n-                }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  PR_fprintf(err, \"Settings\\n\");\n+  PR_fprintf(err, \"\\tConditions / lock: %d\\n\", cvs);\n+  PR_fprintf(err, \"\\tLoops to run test: %d\\n\", loops);\n+\n+  ml = PR_NewLock();\n+  PR_ASSERT(NULL != ml);\n+\n+  cv = (PRCondVar**)PR_CALLOC(sizeof(PRCondVar*) * cvs);\n+  PR_ASSERT(NULL != cv);\n+\n+  for (index = 0; index < cvs; ++index) {\n+    cv[index] = PR_NewCondVar(ml);\n+    PR_ASSERT(NULL != cv[index]);\n+  }\n+\n+  for (index = 0; index < loops; ++index) {\n+    PR_Lock(ml);\n+    for (nl = 0; nl < cvs; ++nl) {\n+      PRInt32 ran = RandomNum() % 8;\n+      if (0 == ran) {\n+        PR_NotifyAllCondVar(cv[nl]);\n+      } else\n+        for (nc = 0; nc < ran; ++nc) {\n+          PR_NotifyCondVar(cv[nl]);\n         }\n-        PR_Unlock(ml);\n     }\n+    PR_Unlock(ml);\n+  }\n \n-    for (index = 0; index < cvs; ++index) {\n-        PR_DestroyCondVar(cv[index]);\n-    }\n+  for (index = 0; index < cvs; ++index) {\n+    PR_DestroyCondVar(cv[index]);\n+  }\n \n-    PR_DELETE(cv);\n+  PR_DELETE(cv);\n \n-    PR_DestroyLock(ml);\n+  PR_DestroyLock(ml);\n \n-    printf(\"PASS\\n\");\n+  printf(\"PASS\\n\");\n \n-    PT_FPrintStats(err, \"\\nPThread Statistics\\n\");\n-    return 0;\n+  PT_FPrintStats(err, \"\\nPThread Statistics\\n\");\n+  return 0;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv;\n+int main(int argc, char** argv) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\ndiff --git a/nspr/pr/tests/mbcs.c b/nspr/pr/tests/mbcs.c\nindex b91f701..4e78244 100644\n--- a/nspr/pr/tests/mbcs.c\n+++ b/nspr/pr/tests/mbcs.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -53,105 +54,101 @@ char* dirName = NULL; /* directory name to traverse */\n /*\n ** Traverse directory\n */\n-static void\n-TraverseDirectory(unsigned char* dir)\n-{\n-    PRDir* cwd;\n-    PRDirEntry* dirEntry;\n-    PRFileInfo info;\n-    PRStatus rc;\n-    PRInt32 err;\n-    PRFileDesc* fd;\n-    char nextDir[256];\n-    char file[256];\n+static void TraverseDirectory(unsigned char* dir) {\n+  PRDir* cwd;\n+  PRDirEntry* dirEntry;\n+  PRFileInfo info;\n+  PRStatus rc;\n+  PRInt32 err;\n+  PRFileDesc* fd;\n+  char nextDir[256];\n+  char file[256];\n \n-    printf(\"Directory: %s\\n\", dir);\n-    cwd = PR_OpenDir(dir);\n-    if (NULL == cwd) {\n-        printf(\"PR_OpenDir() failed on directory: %s, with error: %d, %d\\n\", dir,\n-               PR_GetError(), PR_GetOSError());\n-        exit(1);\n+  printf(\"Directory: %s\\n\", dir);\n+  cwd = PR_OpenDir(dir);\n+  if (NULL == cwd) {\n+    printf(\"PR_OpenDir() failed on directory: %s, with error: %d, %d\\n\", dir,\n+           PR_GetError(), PR_GetOSError());\n+    exit(1);\n+  }\n+  while (NULL != (dirEntry = PR_ReadDir(cwd, PR_SKIP_BOTH | PR_SKIP_HIDDEN))) {\n+    sprintf(file, \"%s/%s\", dir, dirEntry->name);\n+    rc = PR_GetFileInfo(file, &info);\n+    if (PR_FAILURE == rc) {\n+      printf(\"PR_GetFileInfo() failed on file: %s, with error: %d, %d\\n\",\n+             dirEntry->name, PR_GetError(), PR_GetOSError());\n+      exit(1);\n     }\n-    while (NULL != (dirEntry = PR_ReadDir(cwd, PR_SKIP_BOTH | PR_SKIP_HIDDEN))) {\n-        sprintf(file, \"%s/%s\", dir, dirEntry->name);\n-        rc = PR_GetFileInfo(file, &info);\n-        if (PR_FAILURE == rc) {\n-            printf(\"PR_GetFileInfo() failed on file: %s, with error: %d, %d\\n\",\n-                   dirEntry->name, PR_GetError(), PR_GetOSError());\n-            exit(1);\n-        }\n-        if (PR_FILE_FILE == info.type) {\n-            printf(\"File: %s \\tsize: %ld\\n\", dirEntry->name, info.size);\n-            fd = PR_Open(file, PR_RDONLY, 0);\n-            if (NULL == fd) {\n-                printf(\"PR_Open() failed. Error: %ld, OSError: %ld\\n\", PR_GetError(),\n-                       PR_GetOSError());\n-            }\n-            rc = PR_Close(fd);\n-            if (PR_FAILURE == rc) {\n-                printf(\"PR_Close() failed. Error: %ld, OSError: %ld\\n\", PR_GetError(),\n-                       PR_GetOSError());\n-            }\n-        } else if (PR_FILE_DIRECTORY == info.type) {\n-            sprintf(nextDir, \"%s/%s\", dir, dirEntry->name);\n-            TraverseDirectory(nextDir);\n-        } else {\n-            printf(\"type is not interesting for file: %s\\n\", dirEntry->name);\n-            /* keep going */\n-        }\n+    if (PR_FILE_FILE == info.type) {\n+      printf(\"File: %s \\tsize: %ld\\n\", dirEntry->name, info.size);\n+      fd = PR_Open(file, PR_RDONLY, 0);\n+      if (NULL == fd) {\n+        printf(\"PR_Open() failed. Error: %ld, OSError: %ld\\n\", PR_GetError(),\n+               PR_GetOSError());\n+      }\n+      rc = PR_Close(fd);\n+      if (PR_FAILURE == rc) {\n+        printf(\"PR_Close() failed. Error: %ld, OSError: %ld\\n\", PR_GetError(),\n+               PR_GetOSError());\n+      }\n+    } else if (PR_FILE_DIRECTORY == info.type) {\n+      sprintf(nextDir, \"%s/%s\", dir, dirEntry->name);\n+      TraverseDirectory(nextDir);\n+    } else {\n+      printf(\"type is not interesting for file: %s\\n\", dirEntry->name);\n+      /* keep going */\n     }\n-    /* assume end-of-file, actually could be error */\n+  }\n+  /* assume end-of-file, actually could be error */\n \n-    rc = PR_CloseDir(cwd);\n-    if (PR_FAILURE == rc) {\n-        printf(\"PR_CloseDir() failed on directory: %s, with error: %d, %d\\n\", dir,\n-               PR_GetError(), PR_GetOSError());\n-    }\n+  rc = PR_CloseDir(cwd);\n+  if (PR_FAILURE == rc) {\n+    printf(\"PR_CloseDir() failed on directory: %s, with error: %d, %d\\n\", dir,\n+           PR_GetError(), PR_GetOSError());\n+  }\n \n } /* end TraverseDirectory() */\n \n-int\n-main(int argc, char** argv)\n-{\n-    { /* get command line options */\n-        /*\n-        ** Get command line options\n-        */\n-        PLOptStatus os;\n-        PLOptState* opt = PL_CreateOptState(argc, argv, \"dv\");\n+int main(int argc, char** argv) {\n+  { /* get command line options */\n+    /*\n+    ** Get command line options\n+    */\n+    PLOptStatus os;\n+    PLOptState* opt = PL_CreateOptState(argc, argv, \"dv\");\n \n-        while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-            if (PL_OPT_BAD == os) {\n-                continue;\n-            }\n-            switch (opt->option) {\n-                case 'd': /* debug */\n-                    debug = 1;\n-                    msgLevel = PR_LOG_ERROR;\n-                    break;\n-                case 'v': /* verbose mode */\n-                    msgLevel = PR_LOG_DEBUG;\n-                    break;\n-                default:\n-                    dirName = strdup(opt->value);\n-                    break;\n-            }\n-        }\n-        PL_DestroyOptState(opt);\n-    } /* end get command line options */\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+      if (PL_OPT_BAD == os) {\n+        continue;\n+      }\n+      switch (opt->option) {\n+        case 'd': /* debug */\n+          debug = 1;\n+          msgLevel = PR_LOG_ERROR;\n+          break;\n+        case 'v': /* verbose mode */\n+          msgLevel = PR_LOG_DEBUG;\n+          break;\n+        default:\n+          dirName = strdup(opt->value);\n+          break;\n+      }\n+    }\n+    PL_DestroyOptState(opt);\n+  } /* end get command line options */\n \n-    lm = PR_NewLogModule(\"Test\"); /* Initialize logging */\n+  lm = PR_NewLogModule(\"Test\"); /* Initialize logging */\n \n-    if (dirName == NULL) {\n-        printf(\"you gotta specify a directory as an operand!\\n\");\n-        exit(1);\n-    }\n+  if (dirName == NULL) {\n+    printf(\"you gotta specify a directory as an operand!\\n\");\n+    exit(1);\n+  }\n \n-    TraverseDirectory(dirName);\n+  TraverseDirectory(dirName);\n \n-    if (debug) {\n-        printf(\"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n-    }\n-    return ((failed_already == PR_TRUE) ? 1 : 0);\n+  if (debug) {\n+    printf(\"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n+  }\n+  return ((failed_already == PR_TRUE) ? 1 : 0);\n } /* main() */\n /* end template.c */\ndiff --git a/nspr/pr/tests/monref.c b/nspr/pr/tests/monref.c\nindex c4a80c8..cd63475 100644\n--- a/nspr/pr/tests/monref.c\n+++ b/nspr/pr/tests/monref.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -18,57 +19,53 @@\n /* Protected by the PRMonitor 'mon' in the main function. */\n static PRBool done = PR_FALSE;\n \n-static void\n-ThreadFunc(void* arg)\n-{\n-    PRMonitor* mon = (PRMonitor*)arg;\n-    PRStatus rv;\n+static void ThreadFunc(void* arg) {\n+  PRMonitor* mon = (PRMonitor*)arg;\n+  PRStatus rv;\n \n-    PR_EnterMonitor(mon);\n-    done = PR_TRUE;\n-    rv = PR_Notify(mon);\n-    PR_ASSERT(rv == PR_SUCCESS);\n-    rv = PR_ExitMonitor(mon);\n-    PR_ASSERT(rv == PR_SUCCESS);\n+  PR_EnterMonitor(mon);\n+  done = PR_TRUE;\n+  rv = PR_Notify(mon);\n+  PR_ASSERT(rv == PR_SUCCESS);\n+  rv = PR_ExitMonitor(mon);\n+  PR_ASSERT(rv == PR_SUCCESS);\n }\n \n-int\n-main()\n-{\n-    PRMonitor* mon;\n-    PRThread* thread;\n-    PRStatus rv;\n+int main() {\n+  PRMonitor* mon;\n+  PRThread* thread;\n+  PRStatus rv;\n \n-    mon = PR_NewMonitor();\n-    if (!mon) {\n-        fprintf(stderr, \"PR_NewMonitor failed\\n\");\n-        exit(1);\n-    }\n+  mon = PR_NewMonitor();\n+  if (!mon) {\n+    fprintf(stderr, \"PR_NewMonitor failed\\n\");\n+    exit(1);\n+  }\n \n-    thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, mon, PR_PRIORITY_NORMAL,\n-                             PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (!thread) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n-    }\n+  thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, mon, PR_PRIORITY_NORMAL,\n+                           PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (!thread) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n \n-    PR_EnterMonitor(mon);\n-    while (!done) {\n-        rv = PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n-        PR_ASSERT(rv == PR_SUCCESS);\n-    }\n-    rv = PR_ExitMonitor(mon);\n+  PR_EnterMonitor(mon);\n+  while (!done) {\n+    rv = PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n     PR_ASSERT(rv == PR_SUCCESS);\n+  }\n+  rv = PR_ExitMonitor(mon);\n+  PR_ASSERT(rv == PR_SUCCESS);\n \n-    /*\n-     * Do you agree it should be safe to destroy 'mon' now?\n-     * See bug 844784 comment 27.\n-     */\n-    PR_DestroyMonitor(mon);\n+  /*\n+   * Do you agree it should be safe to destroy 'mon' now?\n+   * See bug 844784 comment 27.\n+   */\n+  PR_DestroyMonitor(mon);\n \n-    rv = PR_JoinThread(thread);\n-    PR_ASSERT(rv == PR_SUCCESS);\n+  rv = PR_JoinThread(thread);\n+  PR_ASSERT(rv == PR_SUCCESS);\n \n-    printf(\"PASS\\n\");\n-    return 0;\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/multiacc.c b/nspr/pr/tests/multiacc.c\nindex 96ebf9c..0a0d746 100644\n--- a/nspr/pr/tests/multiacc.c\n+++ b/nspr/pr/tests/multiacc.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -22,199 +23,195 @@ static int num_server_threads = NUM_SERVER_THREADS;\n static PRThreadScope thread_scope = PR_GLOBAL_THREAD;\n static PRBool exit_flag = PR_FALSE;\n \n-static void\n-ServerThreadFunc(void* arg)\n-{\n-    PRFileDesc* listenSock = (PRFileDesc*)arg;\n-    PRFileDesc* acceptSock;\n-    PRErrorCode err;\n-    PRStatus status;\n+static void ServerThreadFunc(void* arg) {\n+  PRFileDesc* listenSock = (PRFileDesc*)arg;\n+  PRFileDesc* acceptSock;\n+  PRErrorCode err;\n+  PRStatus status;\n \n-    while (!exit_flag) {\n-        acceptSock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n-        if (NULL == acceptSock) {\n-            err = PR_GetError();\n-            if (PR_PENDING_INTERRUPT_ERROR == err) {\n-                printf(\"server thread is interrupted\\n\");\n-                fflush(stdout);\n-                continue;\n-            }\n-            fprintf(stderr, \"PR_Accept failed: %d\\n\", err);\n-            exit(1);\n-        }\n-        status = PR_Close(acceptSock);\n-        if (PR_FAILURE == status) {\n-            fprintf(stderr, \"PR_Close failed\\n\");\n-            exit(1);\n-        }\n+  while (!exit_flag) {\n+    acceptSock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n+    if (NULL == acceptSock) {\n+      err = PR_GetError();\n+      if (PR_PENDING_INTERRUPT_ERROR == err) {\n+        printf(\"server thread is interrupted\\n\");\n+        fflush(stdout);\n+        continue;\n+      }\n+      fprintf(stderr, \"PR_Accept failed: %d\\n\", err);\n+      exit(1);\n+    }\n+    status = PR_Close(acceptSock);\n+    if (PR_FAILURE == status) {\n+      fprintf(stderr, \"PR_Close failed\\n\");\n+      exit(1);\n     }\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRNetAddr serverAddr;\n-    PRFileDesc* dummySock;\n-    PRFileDesc* listenSock;\n-    PRFileDesc* clientSock;\n-    PRThread* dummyThread;\n-    PRThread** serverThreads;\n-    PRStatus status;\n-    PRUint16 port;\n-    int idx;\n-    PRInt32 nbytes;\n-    char buf[1024];\n+int main(int argc, char** argv) {\n+  PRNetAddr serverAddr;\n+  PRFileDesc* dummySock;\n+  PRFileDesc* listenSock;\n+  PRFileDesc* clientSock;\n+  PRThread* dummyThread;\n+  PRThread** serverThreads;\n+  PRStatus status;\n+  PRUint16 port;\n+  int idx;\n+  PRInt32 nbytes;\n+  char buf[1024];\n \n-    serverThreads = (PRThread**)PR_Malloc(num_server_threads * sizeof(PRThread*));\n-    if (NULL == serverThreads) {\n-        fprintf(stderr, \"PR_Malloc failed\\n\");\n-        exit(1);\n-    }\n+  serverThreads = (PRThread**)PR_Malloc(num_server_threads * sizeof(PRThread*));\n+  if (NULL == serverThreads) {\n+    fprintf(stderr, \"PR_Malloc failed\\n\");\n+    exit(1);\n+  }\n \n-    /*\n-     * Create a dummy listening socket and have the first\n-     * (dummy) thread listen on it.  This is to ensure that\n-     * the first thread becomes the I/O continuation thread\n-     * in the pthreads implementation (see ptio.c) and remains\n-     * so throughout the test, so that we never have to\n-     * recycle the I/O continuation thread.\n-     */\n-    dummySock = PR_NewTCPSocket();\n-    if (NULL == dummySock) {\n-        fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-        exit(1);\n-    }\n-    memset(&serverAddr, 0, sizeof(serverAddr));\n-    status = PR_InitializeNetAddr(PR_IpAddrAny, 0, &serverAddr);\n-    if (PR_FAILURE == status) {\n-        fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_Bind(dummySock, &serverAddr);\n-    if (PR_FAILURE == status) {\n-        fprintf(stderr, \"PR_Bind failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_Listen(dummySock, 5);\n-    if (PR_FAILURE == status) {\n-        fprintf(stderr, \"PR_Listen failed\\n\");\n-        exit(1);\n-    }\n+  /*\n+   * Create a dummy listening socket and have the first\n+   * (dummy) thread listen on it.  This is to ensure that\n+   * the first thread becomes the I/O continuation thread\n+   * in the pthreads implementation (see ptio.c) and remains\n+   * so throughout the test, so that we never have to\n+   * recycle the I/O continuation thread.\n+   */\n+  dummySock = PR_NewTCPSocket();\n+  if (NULL == dummySock) {\n+    fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+    exit(1);\n+  }\n+  memset(&serverAddr, 0, sizeof(serverAddr));\n+  status = PR_InitializeNetAddr(PR_IpAddrAny, 0, &serverAddr);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_Bind(dummySock, &serverAddr);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"PR_Bind failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_Listen(dummySock, 5);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"PR_Listen failed\\n\");\n+    exit(1);\n+  }\n \n-    listenSock = PR_NewTCPSocket();\n-    if (NULL == listenSock) {\n-        fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-        exit(1);\n-    }\n-    memset(&serverAddr, 0, sizeof(serverAddr));\n-    status = PR_InitializeNetAddr(PR_IpAddrAny, 0, &serverAddr);\n-    if (PR_FAILURE == status) {\n-        fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_Bind(listenSock, &serverAddr);\n-    if (PR_FAILURE == status) {\n-        fprintf(stderr, \"PR_Bind failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_GetSockName(listenSock, &serverAddr);\n-    if (PR_FAILURE == status) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        exit(1);\n-    }\n-    port = PR_ntohs(serverAddr.inet.port);\n-    status = PR_Listen(listenSock, 5);\n-    if (PR_FAILURE == status) {\n-        fprintf(stderr, \"PR_Listen failed\\n\");\n-        exit(1);\n-    }\n+  listenSock = PR_NewTCPSocket();\n+  if (NULL == listenSock) {\n+    fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+    exit(1);\n+  }\n+  memset(&serverAddr, 0, sizeof(serverAddr));\n+  status = PR_InitializeNetAddr(PR_IpAddrAny, 0, &serverAddr);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_Bind(listenSock, &serverAddr);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"PR_Bind failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_GetSockName(listenSock, &serverAddr);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    exit(1);\n+  }\n+  port = PR_ntohs(serverAddr.inet.port);\n+  status = PR_Listen(listenSock, 5);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"PR_Listen failed\\n\");\n+    exit(1);\n+  }\n \n-    printf(\"creating dummy thread\\n\");\n-    fflush(stdout);\n-    dummyThread =\n-        PR_CreateThread(PR_USER_THREAD, ServerThreadFunc, dummySock,\n-                        PR_PRIORITY_NORMAL, thread_scope, PR_JOINABLE_THREAD, 0);\n-    if (NULL == dummyThread) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n-    }\n-    printf(\"sleeping one second before creating server threads\\n\");\n-    fflush(stdout);\n-    PR_Sleep(PR_SecondsToInterval(1));\n-    for (idx = 0; idx < num_server_threads; idx++) {\n-        serverThreads[idx] = PR_CreateThread(PR_USER_THREAD, ServerThreadFunc,\n-                                             listenSock, PR_PRIORITY_NORMAL,\n-                                             thread_scope, PR_JOINABLE_THREAD, 0);\n-        if (NULL == serverThreads[idx]) {\n-            fprintf(stderr, \"PR_CreateThread failed\\n\");\n-            exit(1);\n-        }\n-    }\n+  printf(\"creating dummy thread\\n\");\n+  fflush(stdout);\n+  dummyThread =\n+      PR_CreateThread(PR_USER_THREAD, ServerThreadFunc, dummySock,\n+                      PR_PRIORITY_NORMAL, thread_scope, PR_JOINABLE_THREAD, 0);\n+  if (NULL == dummyThread) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n+  printf(\"sleeping one second before creating server threads\\n\");\n+  fflush(stdout);\n+  PR_Sleep(PR_SecondsToInterval(1));\n+  for (idx = 0; idx < num_server_threads; idx++) {\n+    serverThreads[idx] = PR_CreateThread(PR_USER_THREAD, ServerThreadFunc,\n+                                         listenSock, PR_PRIORITY_NORMAL,\n+                                         thread_scope, PR_JOINABLE_THREAD, 0);\n+    if (NULL == serverThreads[idx]) {\n+      fprintf(stderr, \"PR_CreateThread failed\\n\");\n+      exit(1);\n+    }\n+  }\n \n-    memset(&serverAddr, 0, sizeof(serverAddr));\n-    PR_InitializeNetAddr(PR_IpAddrLoopback, port, &serverAddr);\n-    clientSock = PR_NewTCPSocket();\n-    if (NULL == clientSock) {\n-        fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-        exit(1);\n-    }\n-    printf(\"sleeping one second before connecting\\n\");\n-    fflush(stdout);\n-    PR_Sleep(PR_SecondsToInterval(1));\n-    status = PR_Connect(clientSock, &serverAddr, PR_INTERVAL_NO_TIMEOUT);\n-    if (PR_FAILURE == status) {\n-        fprintf(stderr, \"PR_Connect failed\\n\");\n-        exit(1);\n-    }\n-    nbytes = PR_Read(clientSock, buf, sizeof(buf));\n-    if (nbytes != 0) {\n-        fprintf(stderr, \"expected 0 bytes but got %d bytes\\n\", nbytes);\n-        exit(1);\n-    }\n-    status = PR_Close(clientSock);\n-    if (PR_FAILURE == status) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    printf(\"sleeping one second before shutting down server threads\\n\");\n-    fflush(stdout);\n-    PR_Sleep(PR_SecondsToInterval(1));\n+  memset(&serverAddr, 0, sizeof(serverAddr));\n+  PR_InitializeNetAddr(PR_IpAddrLoopback, port, &serverAddr);\n+  clientSock = PR_NewTCPSocket();\n+  if (NULL == clientSock) {\n+    fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+    exit(1);\n+  }\n+  printf(\"sleeping one second before connecting\\n\");\n+  fflush(stdout);\n+  PR_Sleep(PR_SecondsToInterval(1));\n+  status = PR_Connect(clientSock, &serverAddr, PR_INTERVAL_NO_TIMEOUT);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"PR_Connect failed\\n\");\n+    exit(1);\n+  }\n+  nbytes = PR_Read(clientSock, buf, sizeof(buf));\n+  if (nbytes != 0) {\n+    fprintf(stderr, \"expected 0 bytes but got %d bytes\\n\", nbytes);\n+    exit(1);\n+  }\n+  status = PR_Close(clientSock);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  printf(\"sleeping one second before shutting down server threads\\n\");\n+  fflush(stdout);\n+  PR_Sleep(PR_SecondsToInterval(1));\n \n-    exit_flag = PR_TRUE;\n-    status = PR_Interrupt(dummyThread);\n-    if (PR_FAILURE == status) {\n-        fprintf(stderr, \"PR_Interrupt failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_JoinThread(dummyThread);\n+  exit_flag = PR_TRUE;\n+  status = PR_Interrupt(dummyThread);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"PR_Interrupt failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_JoinThread(dummyThread);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+  for (idx = 0; idx < num_server_threads; idx++) {\n+    status = PR_Interrupt(serverThreads[idx]);\n     if (PR_FAILURE == status) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n+      fprintf(stderr, \"PR_Interrupt failed\\n\");\n+      exit(1);\n     }\n-    for (idx = 0; idx < num_server_threads; idx++) {\n-        status = PR_Interrupt(serverThreads[idx]);\n-        if (PR_FAILURE == status) {\n-            fprintf(stderr, \"PR_Interrupt failed\\n\");\n-            exit(1);\n-        }\n-        status = PR_JoinThread(serverThreads[idx]);\n-        if (PR_FAILURE == status) {\n-            fprintf(stderr, \"PR_JoinThread failed\\n\");\n-            exit(1);\n-        }\n-    }\n-    PR_Free(serverThreads);\n-    status = PR_Close(dummySock);\n-    if (PR_FAILURE == status) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_Close(listenSock);\n+    status = PR_JoinThread(serverThreads[idx]);\n     if (PR_FAILURE == status) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n+      fprintf(stderr, \"PR_JoinThread failed\\n\");\n+      exit(1);\n+    }\n+  }\n+  PR_Free(serverThreads);\n+  status = PR_Close(dummySock);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_Close(listenSock);\n+  if (PR_FAILURE == status) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n \n-    printf(\"PASS\\n\");\n-    return 0;\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/multiwait.c b/nspr/pr/tests/multiwait.c\nindex 3308048..e674ee1 100644\n--- a/nspr/pr/tests/multiwait.c\n+++ b/nspr/pr/tests/multiwait.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -22,26 +23,23 @@\n #include <string.h>\n \n typedef struct Shared {\n-    const char* title;\n-    PRLock* list_lock;\n-    PRWaitGroup* group;\n-    PRIntervalTime timeout;\n+  const char* title;\n+  PRLock* list_lock;\n+  PRWaitGroup* group;\n+  PRIntervalTime timeout;\n } Shared;\n \n-typedef enum Verbosity { silent,\n-                         quiet,\n-                         chatty,\n-                         noisy } Verbosity;\n+typedef enum Verbosity { silent, quiet, chatty, noisy } Verbosity;\n \n #ifdef DEBUG\n-#define PORT_INC_DO +100\n+#  define PORT_INC_DO +100\n #else\n-#define PORT_INC_DO\n+#  define PORT_INC_DO\n #endif\n #ifdef IS_64\n-#define PORT_INC_3264 +200\n+#  define PORT_INC_3264 +200\n #else\n-#define PORT_INC_3264\n+#  define PORT_INC_3264\n #endif\n \n static PRFileDesc* debug = NULL;\n@@ -53,718 +51,676 @@ static PRThreadScope thread_scope = PR_LOCAL_THREAD;\n static PRIntn client_threads = 20, worker_threads = 2, wait_objects = 50;\n \n #if defined(DEBUG)\n-#define MW_ASSERT(_expr) \\\n+#  define MW_ASSERT(_expr) \\\n     ((_expr) ? ((void)0) : _MW_Assert(#_expr, __FILE__, __LINE__))\n-static void\n-_MW_Assert(const char* s, const char* file, PRIntn ln)\n-{\n-    if (NULL != debug) {\n-        PL_FPrintError(debug, NULL);\n-    }\n-    PR_Assert(s, file, ln);\n+static void _MW_Assert(const char* s, const char* file, PRIntn ln) {\n+  if (NULL != debug) {\n+    PL_FPrintError(debug, NULL);\n+  }\n+  PR_Assert(s, file, ln);\n } /* _MW_Assert */\n #else\n-#define MW_ASSERT(_expr)\n+#  define MW_ASSERT(_expr)\n #endif\n \n-static void\n-PrintRecvDesc(PRRecvWait* desc, const char* msg)\n-{\n-    const char* tag[] = { \"PR_MW_INTERRUPT\", \"PR_MW_TIMEOUT\", \"PR_MW_FAILURE\",\n-                          \"PR_MW_SUCCESS\", \"PR_MW_PENDING\" };\n-    PR_fprintf(debug, \"%s: PRRecvWait(@0x%x): {fd: 0x%x, outcome: %s, tmo: %u}\\n\",\n-               msg, desc, desc->fd, tag[desc->outcome + 3], desc->timeout);\n+static void PrintRecvDesc(PRRecvWait* desc, const char* msg) {\n+  const char* tag[] = {\"PR_MW_INTERRUPT\", \"PR_MW_TIMEOUT\", \"PR_MW_FAILURE\",\n+                       \"PR_MW_SUCCESS\", \"PR_MW_PENDING\"};\n+  PR_fprintf(debug, \"%s: PRRecvWait(@0x%x): {fd: 0x%x, outcome: %s, tmo: %u}\\n\",\n+             msg, desc, desc->fd, tag[desc->outcome + 3], desc->timeout);\n } /* PrintRecvDesc */\n \n-static Shared*\n-MakeShared(const char* title)\n-{\n-    Shared* shared = PR_NEWZAP(Shared);\n-    shared->group = PR_CreateWaitGroup(1);\n-    shared->timeout = PR_SecondsToInterval(1);\n-    shared->list_lock = PR_NewLock();\n-    shared->title = title;\n-    return shared;\n+static Shared* MakeShared(const char* title) {\n+  Shared* shared = PR_NEWZAP(Shared);\n+  shared->group = PR_CreateWaitGroup(1);\n+  shared->timeout = PR_SecondsToInterval(1);\n+  shared->list_lock = PR_NewLock();\n+  shared->title = title;\n+  return shared;\n } /* MakeShared */\n \n-static void\n-DestroyShared(Shared* shared)\n-{\n-    PRStatus rv;\n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: destroying group\\n\", shared->title);\n-    }\n-    rv = PR_DestroyWaitGroup(shared->group);\n-    MW_ASSERT(PR_SUCCESS == rv);\n-    PR_DestroyLock(shared->list_lock);\n-    PR_DELETE(shared);\n+static void DestroyShared(Shared* shared) {\n+  PRStatus rv;\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: destroying group\\n\", shared->title);\n+  }\n+  rv = PR_DestroyWaitGroup(shared->group);\n+  MW_ASSERT(PR_SUCCESS == rv);\n+  PR_DestroyLock(shared->list_lock);\n+  PR_DELETE(shared);\n } /* DestroyShared */\n \n-static PRRecvWait*\n-CreateRecvWait(PRFileDesc* fd, PRIntervalTime timeout)\n-{\n-    PRRecvWait* desc_out = PR_NEWZAP(PRRecvWait);\n-    MW_ASSERT(NULL != desc_out);\n+static PRRecvWait* CreateRecvWait(PRFileDesc* fd, PRIntervalTime timeout) {\n+  PRRecvWait* desc_out = PR_NEWZAP(PRRecvWait);\n+  MW_ASSERT(NULL != desc_out);\n \n-    MW_ASSERT(NULL != fd);\n-    desc_out->fd = fd;\n-    desc_out->timeout = timeout;\n-    desc_out->buffer.length = 120;\n-    desc_out->buffer.start = PR_CALLOC(120);\n+  MW_ASSERT(NULL != fd);\n+  desc_out->fd = fd;\n+  desc_out->timeout = timeout;\n+  desc_out->buffer.length = 120;\n+  desc_out->buffer.start = PR_CALLOC(120);\n \n-    PR_AtomicIncrement(&desc_allocated);\n+  PR_AtomicIncrement(&desc_allocated);\n \n-    if (verbosity > chatty) {\n-        PrintRecvDesc(desc_out, \"Allocated\");\n-    }\n-    return desc_out;\n+  if (verbosity > chatty) {\n+    PrintRecvDesc(desc_out, \"Allocated\");\n+  }\n+  return desc_out;\n } /* CreateRecvWait */\n \n-static void\n-DestroyRecvWait(PRRecvWait* desc_out)\n-{\n-    if (verbosity > chatty) {\n-        PrintRecvDesc(desc_out, \"Destroying\");\n-    }\n-    PR_Close(desc_out->fd);\n-    if (NULL != desc_out->buffer.start) {\n-        PR_DELETE(desc_out->buffer.start);\n-    }\n-    PR_Free(desc_out);\n-    (void)PR_AtomicDecrement(&desc_allocated);\n+static void DestroyRecvWait(PRRecvWait* desc_out) {\n+  if (verbosity > chatty) {\n+    PrintRecvDesc(desc_out, \"Destroying\");\n+  }\n+  PR_Close(desc_out->fd);\n+  if (NULL != desc_out->buffer.start) {\n+    PR_DELETE(desc_out->buffer.start);\n+  }\n+  PR_Free(desc_out);\n+  (void)PR_AtomicDecrement(&desc_allocated);\n } /* DestroyRecvWait */\n \n-static void\n-CancelGroup(Shared* shared)\n-{\n-    PRRecvWait* desc_out;\n+static void CancelGroup(Shared* shared) {\n+  PRRecvWait* desc_out;\n \n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s Reclaiming wait descriptors\\n\", shared->title);\n-    }\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s Reclaiming wait descriptors\\n\", shared->title);\n+  }\n \n-    do {\n-        desc_out = PR_CancelWaitGroup(shared->group);\n-        if (NULL != desc_out) {\n-            DestroyRecvWait(desc_out);\n-        }\n-    } while (NULL != desc_out);\n+  do {\n+    desc_out = PR_CancelWaitGroup(shared->group);\n+    if (NULL != desc_out) {\n+      DestroyRecvWait(desc_out);\n+    }\n+  } while (NULL != desc_out);\n \n-    MW_ASSERT(0 == desc_allocated);\n-    MW_ASSERT(PR_GROUP_EMPTY_ERROR == PR_GetError());\n+  MW_ASSERT(0 == desc_allocated);\n+  MW_ASSERT(PR_GROUP_EMPTY_ERROR == PR_GetError());\n } /* CancelGroup */\n \n-static void PR_CALLBACK\n-ClientThread(void* arg)\n-{\n-    PRStatus rv;\n-    PRInt32 bytes;\n-    PRIntn empty_flags = 0;\n-    PRNetAddr server_address;\n-    unsigned char buffer[100];\n-    Shared* shared = (Shared*)arg;\n-    PRFileDesc* server = PR_NewTCPSocket();\n-    if ((NULL == server) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n-        return;\n+static void PR_CALLBACK ClientThread(void* arg) {\n+  PRStatus rv;\n+  PRInt32 bytes;\n+  PRIntn empty_flags = 0;\n+  PRNetAddr server_address;\n+  unsigned char buffer[100];\n+  Shared* shared = (Shared*)arg;\n+  PRFileDesc* server = PR_NewTCPSocket();\n+  if ((NULL == server) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n+    return;\n+  }\n+  MW_ASSERT(NULL != server);\n+\n+  if (verbosity > chatty) {\n+    PR_fprintf(debug, \"%s: Server socket @0x%x\\n\", shared->title, server);\n+  }\n+\n+  /* Initialize the buffer so that Purify won't complain */\n+  memset(buffer, 0, sizeof(buffer));\n+\n+  rv = PR_InitializeNetAddr(PR_IpAddrLoopback, default_port, &server_address);\n+  MW_ASSERT(PR_SUCCESS == rv);\n+\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: Client opening connection\\n\", shared->title);\n+  }\n+  rv = PR_Connect(server, &server_address, PR_INTERVAL_NO_TIMEOUT);\n+\n+  if (PR_FAILURE == rv) {\n+    if (verbosity > silent) {\n+      PL_FPrintError(debug, \"Client connect failed\");\n+    }\n+    return;\n+  }\n+\n+  while (ops_done < ops_required) {\n+    bytes = PR_Send(server, buffer, sizeof(buffer), empty_flags,\n+                    PR_INTERVAL_NO_TIMEOUT);\n+    if ((-1 == bytes) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n+      break;\n+    }\n+    MW_ASSERT(sizeof(buffer) == bytes);\n+    if (verbosity > chatty)\n+      PR_fprintf(debug, \"%s: Client sent %d bytes\\n\", shared->title,\n+                 sizeof(buffer));\n+    bytes = PR_Recv(server, buffer, sizeof(buffer), empty_flags,\n+                    PR_INTERVAL_NO_TIMEOUT);\n+    if (verbosity > chatty)\n+      PR_fprintf(debug, \"%s: Client received %d bytes\\n\", shared->title,\n+                 sizeof(buffer));\n+    if ((-1 == bytes) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n+      break;\n     }\n-    MW_ASSERT(NULL != server);\n+    MW_ASSERT(sizeof(buffer) == bytes);\n+    PR_Sleep(shared->timeout);\n+  }\n+  rv = PR_Close(server);\n+  MW_ASSERT(PR_SUCCESS == rv);\n \n-    if (verbosity > chatty) {\n-        PR_fprintf(debug, \"%s: Server socket @0x%x\\n\", shared->title, server);\n-    }\n+} /* ClientThread */\n \n-    /* Initialize the buffer so that Purify won't complain */\n-    memset(buffer, 0, sizeof(buffer));\n+static void OneInThenCancelled(Shared* shared) {\n+  PRStatus rv;\n+  PRRecvWait *desc_out, *desc_in = PR_NEWZAP(PRRecvWait);\n \n-    rv = PR_InitializeNetAddr(PR_IpAddrLoopback, default_port, &server_address);\n-    MW_ASSERT(PR_SUCCESS == rv);\n+  shared->timeout = PR_INTERVAL_NO_TIMEOUT;\n \n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: Client opening connection\\n\", shared->title);\n-    }\n-    rv = PR_Connect(server, &server_address, PR_INTERVAL_NO_TIMEOUT);\n+  desc_in->fd = PR_NewTCPSocket();\n+  desc_in->timeout = shared->timeout;\n \n-    if (PR_FAILURE == rv) {\n-        if (verbosity > silent) {\n-            PL_FPrintError(debug, \"Client connect failed\");\n-        }\n-        return;\n-    }\n+  if (verbosity > chatty) {\n+    PrintRecvDesc(desc_in, \"Adding desc\");\n+  }\n \n-    while (ops_done < ops_required) {\n-        bytes = PR_Send(server, buffer, sizeof(buffer), empty_flags,\n-                        PR_INTERVAL_NO_TIMEOUT);\n-        if ((-1 == bytes) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n-            break;\n-        }\n-        MW_ASSERT(sizeof(buffer) == bytes);\n-        if (verbosity > chatty)\n-            PR_fprintf(debug, \"%s: Client sent %d bytes\\n\", shared->title,\n-                       sizeof(buffer));\n-        bytes = PR_Recv(server, buffer, sizeof(buffer), empty_flags,\n-                        PR_INTERVAL_NO_TIMEOUT);\n-        if (verbosity > chatty)\n-            PR_fprintf(debug, \"%s: Client received %d bytes\\n\", shared->title,\n-                       sizeof(buffer));\n-        if ((-1 == bytes) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n-            break;\n-        }\n-        MW_ASSERT(sizeof(buffer) == bytes);\n-        PR_Sleep(shared->timeout);\n-    }\n-    rv = PR_Close(server);\n-    MW_ASSERT(PR_SUCCESS == rv);\n+  rv = PR_AddWaitFileDesc(shared->group, desc_in);\n+  MW_ASSERT(PR_SUCCESS == rv);\n \n-} /* ClientThread */\n+  if (verbosity > chatty) {\n+    PrintRecvDesc(desc_in, \"Cancelling\");\n+  }\n+  rv = PR_CancelWaitFileDesc(shared->group, desc_in);\n+  MW_ASSERT(PR_SUCCESS == rv);\n \n-static void\n-OneInThenCancelled(Shared* shared)\n-{\n-    PRStatus rv;\n-    PRRecvWait *desc_out, *desc_in = PR_NEWZAP(PRRecvWait);\n+  desc_out = PR_WaitRecvReady(shared->group);\n+  MW_ASSERT(desc_out == desc_in);\n+  MW_ASSERT(PR_MW_INTERRUPT == desc_out->outcome);\n+  MW_ASSERT(PR_PENDING_INTERRUPT_ERROR == PR_GetError());\n+  if (verbosity > chatty) {\n+    PrintRecvDesc(desc_out, \"Ready\");\n+  }\n \n-    shared->timeout = PR_INTERVAL_NO_TIMEOUT;\n+  rv = PR_Close(desc_in->fd);\n+  MW_ASSERT(PR_SUCCESS == rv);\n \n-    desc_in->fd = PR_NewTCPSocket();\n-    desc_in->timeout = shared->timeout;\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: destroying group\\n\", shared->title);\n+  }\n \n-    if (verbosity > chatty) {\n-        PrintRecvDesc(desc_in, \"Adding desc\");\n-    }\n+  PR_DELETE(desc_in);\n+} /* OneInThenCancelled */\n \n-    rv = PR_AddWaitFileDesc(shared->group, desc_in);\n-    MW_ASSERT(PR_SUCCESS == rv);\n+static void OneOpOneThread(Shared* shared) {\n+  PRStatus rv;\n+  PRRecvWait *desc_out, *desc_in = PR_NEWZAP(PRRecvWait);\n \n-    if (verbosity > chatty) {\n-        PrintRecvDesc(desc_in, \"Cancelling\");\n-    }\n-    rv = PR_CancelWaitFileDesc(shared->group, desc_in);\n-    MW_ASSERT(PR_SUCCESS == rv);\n+  desc_in->fd = PR_NewTCPSocket();\n+  desc_in->timeout = shared->timeout;\n \n-    desc_out = PR_WaitRecvReady(shared->group);\n-    MW_ASSERT(desc_out == desc_in);\n-    MW_ASSERT(PR_MW_INTERRUPT == desc_out->outcome);\n-    MW_ASSERT(PR_PENDING_INTERRUPT_ERROR == PR_GetError());\n-    if (verbosity > chatty) {\n-        PrintRecvDesc(desc_out, \"Ready\");\n-    }\n+  if (verbosity > chatty) {\n+    PrintRecvDesc(desc_in, \"Adding desc\");\n+  }\n \n-    rv = PR_Close(desc_in->fd);\n-    MW_ASSERT(PR_SUCCESS == rv);\n+  rv = PR_AddWaitFileDesc(shared->group, desc_in);\n+  MW_ASSERT(PR_SUCCESS == rv);\n+  desc_out = PR_WaitRecvReady(shared->group);\n+  MW_ASSERT(desc_out == desc_in);\n+  MW_ASSERT(PR_MW_TIMEOUT == desc_out->outcome);\n+  MW_ASSERT(PR_IO_TIMEOUT_ERROR == PR_GetError());\n+  if (verbosity > chatty) {\n+    PrintRecvDesc(desc_out, \"Ready\");\n+  }\n \n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: destroying group\\n\", shared->title);\n-    }\n+  rv = PR_Close(desc_in->fd);\n+  MW_ASSERT(PR_SUCCESS == rv);\n \n-    PR_DELETE(desc_in);\n-} /* OneInThenCancelled */\n+  PR_DELETE(desc_in);\n+} /* OneOpOneThread */\n \n-static void\n-OneOpOneThread(Shared* shared)\n-{\n-    PRStatus rv;\n-    PRRecvWait *desc_out, *desc_in = PR_NEWZAP(PRRecvWait);\n+static void ManyOpOneThread(Shared* shared) {\n+  PRStatus rv;\n+  PRIntn index;\n+  PRRecvWait* desc_in;\n+  PRRecvWait* desc_out;\n \n-    desc_in->fd = PR_NewTCPSocket();\n-    desc_in->timeout = shared->timeout;\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: adding %d descs\\n\", shared->title, wait_objects);\n+  }\n \n-    if (verbosity > chatty) {\n-        PrintRecvDesc(desc_in, \"Adding desc\");\n-    }\n+  for (index = 0; index < wait_objects; ++index) {\n+    desc_in = CreateRecvWait(PR_NewTCPSocket(), shared->timeout);\n \n     rv = PR_AddWaitFileDesc(shared->group, desc_in);\n     MW_ASSERT(PR_SUCCESS == rv);\n+  }\n+\n+  while (ops_done < ops_required) {\n     desc_out = PR_WaitRecvReady(shared->group);\n-    MW_ASSERT(desc_out == desc_in);\n     MW_ASSERT(PR_MW_TIMEOUT == desc_out->outcome);\n     MW_ASSERT(PR_IO_TIMEOUT_ERROR == PR_GetError());\n     if (verbosity > chatty) {\n-        PrintRecvDesc(desc_out, \"Ready\");\n+      PrintRecvDesc(desc_out, \"Ready/readding\");\n     }\n-\n-    rv = PR_Close(desc_in->fd);\n+    rv = PR_AddWaitFileDesc(shared->group, desc_out);\n     MW_ASSERT(PR_SUCCESS == rv);\n+    (void)PR_AtomicIncrement(&ops_done);\n+  }\n \n-    PR_DELETE(desc_in);\n-} /* OneOpOneThread */\n-\n-static void\n-ManyOpOneThread(Shared* shared)\n-{\n-    PRStatus rv;\n-    PRIntn index;\n-    PRRecvWait* desc_in;\n-    PRRecvWait* desc_out;\n+  CancelGroup(shared);\n+} /* ManyOpOneThread */\n \n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: adding %d descs\\n\", shared->title, wait_objects);\n+static void PR_CALLBACK SomeOpsThread(void* arg) {\n+  PRRecvWait* desc_out;\n+  PRStatus rv = PR_SUCCESS;\n+  Shared* shared = (Shared*)arg;\n+  do /* until interrupted */\n+  {\n+    desc_out = PR_WaitRecvReady(shared->group);\n+    if (NULL == desc_out) {\n+      MW_ASSERT(PR_PENDING_INTERRUPT_ERROR == PR_GetError());\n+      if (verbosity > quiet) {\n+        PR_fprintf(debug, \"Aborted\\n\");\n+      }\n+      break;\n     }\n-\n-    for (index = 0; index < wait_objects; ++index) {\n-        desc_in = CreateRecvWait(PR_NewTCPSocket(), shared->timeout);\n-\n-        rv = PR_AddWaitFileDesc(shared->group, desc_in);\n-        MW_ASSERT(PR_SUCCESS == rv);\n+    MW_ASSERT(PR_MW_TIMEOUT == desc_out->outcome);\n+    MW_ASSERT(PR_IO_TIMEOUT_ERROR == PR_GetError());\n+    if (verbosity > chatty) {\n+      PrintRecvDesc(desc_out, \"Ready\");\n     }\n \n-    while (ops_done < ops_required) {\n-        desc_out = PR_WaitRecvReady(shared->group);\n-        MW_ASSERT(PR_MW_TIMEOUT == desc_out->outcome);\n-        MW_ASSERT(PR_IO_TIMEOUT_ERROR == PR_GetError());\n-        if (verbosity > chatty) {\n-            PrintRecvDesc(desc_out, \"Ready/readding\");\n-        }\n-        rv = PR_AddWaitFileDesc(shared->group, desc_out);\n-        MW_ASSERT(PR_SUCCESS == rv);\n-        (void)PR_AtomicIncrement(&ops_done);\n+    if (verbosity > chatty) {\n+      PrintRecvDesc(desc_out, \"Re-Adding\");\n     }\n-\n-    CancelGroup(shared);\n-} /* ManyOpOneThread */\n-\n-static void PR_CALLBACK\n-SomeOpsThread(void* arg)\n-{\n-    PRRecvWait* desc_out;\n-    PRStatus rv = PR_SUCCESS;\n-    Shared* shared = (Shared*)arg;\n-    do /* until interrupted */\n-    {\n-        desc_out = PR_WaitRecvReady(shared->group);\n-        if (NULL == desc_out) {\n-            MW_ASSERT(PR_PENDING_INTERRUPT_ERROR == PR_GetError());\n-            if (verbosity > quiet) {\n-                PR_fprintf(debug, \"Aborted\\n\");\n-            }\n-            break;\n-        }\n-        MW_ASSERT(PR_MW_TIMEOUT == desc_out->outcome);\n-        MW_ASSERT(PR_IO_TIMEOUT_ERROR == PR_GetError());\n-        if (verbosity > chatty) {\n-            PrintRecvDesc(desc_out, \"Ready\");\n-        }\n-\n-        if (verbosity > chatty) {\n-            PrintRecvDesc(desc_out, \"Re-Adding\");\n-        }\n-        desc_out->timeout = shared->timeout;\n-        rv = PR_AddWaitFileDesc(shared->group, desc_out);\n-        PR_AtomicIncrement(&ops_done);\n-        if (ops_done > ops_required) {\n-            break;\n-        }\n-    } while (PR_SUCCESS == rv);\n-    MW_ASSERT(PR_SUCCESS == rv);\n+    desc_out->timeout = shared->timeout;\n+    rv = PR_AddWaitFileDesc(shared->group, desc_out);\n+    PR_AtomicIncrement(&ops_done);\n+    if (ops_done > ops_required) {\n+      break;\n+    }\n+  } while (PR_SUCCESS == rv);\n+  MW_ASSERT(PR_SUCCESS == rv);\n } /* SomeOpsThread */\n \n-static void\n-SomeOpsSomeThreads(Shared* shared)\n-{\n-    PRStatus rv;\n-    PRThread** thread;\n-    PRIntn index;\n-    PRRecvWait* desc_in;\n-\n-    thread = (PRThread**)PR_CALLOC(sizeof(PRThread*) * worker_threads);\n-\n-    /* Create some threads */\n-\n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: creating threads\\n\", shared->title);\n-    }\n-    for (index = 0; index < worker_threads; ++index) {\n-        thread[index] =\n-            PR_CreateThread(PR_USER_THREAD, SomeOpsThread, shared, PR_PRIORITY_HIGH,\n-                            thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n-    }\n+static void SomeOpsSomeThreads(Shared* shared) {\n+  PRStatus rv;\n+  PRThread** thread;\n+  PRIntn index;\n+  PRRecvWait* desc_in;\n \n-    /* then create some operations */\n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: creating desc\\n\", shared->title);\n-    }\n-    for (index = 0; index < wait_objects; ++index) {\n-        desc_in = CreateRecvWait(PR_NewTCPSocket(), shared->timeout);\n-        rv = PR_AddWaitFileDesc(shared->group, desc_in);\n-        MW_ASSERT(PR_SUCCESS == rv);\n-    }\n+  thread = (PRThread**)PR_CALLOC(sizeof(PRThread*) * worker_threads);\n \n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: sleeping\\n\", shared->title);\n-    }\n-    while (ops_done < ops_required) {\n-        PR_Sleep(shared->timeout);\n-    }\n+  /* Create some threads */\n \n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: interrupting/joining threads\\n\", shared->title);\n-    }\n-    for (index = 0; index < worker_threads; ++index) {\n-        rv = PR_Interrupt(thread[index]);\n-        MW_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_JoinThread(thread[index]);\n-        MW_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PR_DELETE(thread);\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: creating threads\\n\", shared->title);\n+  }\n+  for (index = 0; index < worker_threads; ++index) {\n+    thread[index] =\n+        PR_CreateThread(PR_USER_THREAD, SomeOpsThread, shared, PR_PRIORITY_HIGH,\n+                        thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n+  }\n+\n+  /* then create some operations */\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: creating desc\\n\", shared->title);\n+  }\n+  for (index = 0; index < wait_objects; ++index) {\n+    desc_in = CreateRecvWait(PR_NewTCPSocket(), shared->timeout);\n+    rv = PR_AddWaitFileDesc(shared->group, desc_in);\n+    MW_ASSERT(PR_SUCCESS == rv);\n+  }\n+\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: sleeping\\n\", shared->title);\n+  }\n+  while (ops_done < ops_required) {\n+    PR_Sleep(shared->timeout);\n+  }\n+\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: interrupting/joining threads\\n\", shared->title);\n+  }\n+  for (index = 0; index < worker_threads; ++index) {\n+    rv = PR_Interrupt(thread[index]);\n+    MW_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_JoinThread(thread[index]);\n+    MW_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PR_DELETE(thread);\n \n-    CancelGroup(shared);\n+  CancelGroup(shared);\n } /* SomeOpsSomeThreads */\n \n-static PRStatus\n-ServiceRequest(Shared* shared, PRRecvWait* desc)\n-{\n-    PRInt32 bytes_out;\n+static PRStatus ServiceRequest(Shared* shared, PRRecvWait* desc) {\n+  PRInt32 bytes_out;\n \n-    if (verbosity > chatty)\n-        PR_fprintf(debug, \"%s: Service received %d bytes\\n\", shared->title,\n-                   desc->bytesRecv);\n+  if (verbosity > chatty)\n+    PR_fprintf(debug, \"%s: Service received %d bytes\\n\", shared->title,\n+               desc->bytesRecv);\n \n-    if (0 == desc->bytesRecv) {\n-        goto quitting;\n-    }\n-    if ((-1 == desc->bytesRecv) &&\n-        (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n-        goto aborted;\n-    }\n+  if (0 == desc->bytesRecv) {\n+    goto quitting;\n+  }\n+  if ((-1 == desc->bytesRecv) &&\n+      (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n+    goto aborted;\n+  }\n \n-    bytes_out = PR_Send(desc->fd, desc->buffer.start, desc->bytesRecv, 0,\n-                        shared->timeout);\n-    if (verbosity > chatty)\n-        PR_fprintf(debug, \"%s: Service sent %d bytes\\n\", shared->title, bytes_out);\n+  bytes_out = PR_Send(desc->fd, desc->buffer.start, desc->bytesRecv, 0,\n+                      shared->timeout);\n+  if (verbosity > chatty)\n+    PR_fprintf(debug, \"%s: Service sent %d bytes\\n\", shared->title, bytes_out);\n \n-    if ((-1 == bytes_out) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n-        goto aborted;\n-    }\n-    MW_ASSERT(bytes_out == desc->bytesRecv);\n+  if ((-1 == bytes_out) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError())) {\n+    goto aborted;\n+  }\n+  MW_ASSERT(bytes_out == desc->bytesRecv);\n \n-    return PR_SUCCESS;\n+  return PR_SUCCESS;\n \n aborted:\n quitting:\n-    return PR_FAILURE;\n+  return PR_FAILURE;\n } /* ServiceRequest */\n \n-static void PR_CALLBACK\n-ServiceThread(void* arg)\n-{\n-    PRStatus rv = PR_SUCCESS;\n-    PRRecvWait* desc_out = NULL;\n-    Shared* shared = (Shared*)arg;\n-    do /* until interrupted */\n-    {\n-        if (NULL != desc_out) {\n-            desc_out->timeout = PR_INTERVAL_NO_TIMEOUT;\n-            if (verbosity > chatty) {\n-                PrintRecvDesc(desc_out, \"Service re-adding\");\n-            }\n-            rv = PR_AddWaitFileDesc(shared->group, desc_out);\n-            MW_ASSERT(PR_SUCCESS == rv);\n-        }\n-\n-        desc_out = PR_WaitRecvReady(shared->group);\n-        if (NULL == desc_out) {\n-            MW_ASSERT(PR_PENDING_INTERRUPT_ERROR == PR_GetError());\n-            break;\n-        }\n-\n-        switch (desc_out->outcome) {\n-            case PR_MW_SUCCESS: {\n-                PR_AtomicIncrement(&ops_done);\n-                if (verbosity > chatty) {\n-                    PrintRecvDesc(desc_out, \"Service ready\");\n-                }\n-                rv = ServiceRequest(shared, desc_out);\n-                break;\n-            }\n-            case PR_MW_INTERRUPT:\n-                MW_ASSERT(PR_PENDING_INTERRUPT_ERROR == PR_GetError());\n-                rv = PR_FAILURE; /* if interrupted, then exit */\n-                break;\n-            case PR_MW_TIMEOUT:\n-                MW_ASSERT(PR_IO_TIMEOUT_ERROR == PR_GetError());\n-            case PR_MW_FAILURE:\n-                if (verbosity > silent) {\n-                    PL_FPrintError(debug, \"RecvReady failure\");\n-                }\n-                break;\n-            default:\n-                break;\n-        }\n-    } while (PR_SUCCESS == rv);\n-\n+static void PR_CALLBACK ServiceThread(void* arg) {\n+  PRStatus rv = PR_SUCCESS;\n+  PRRecvWait* desc_out = NULL;\n+  Shared* shared = (Shared*)arg;\n+  do /* until interrupted */\n+  {\n     if (NULL != desc_out) {\n-        DestroyRecvWait(desc_out);\n-    }\n-\n-} /* ServiceThread */\n-\n-static void PR_CALLBACK\n-EnumerationThread(void* arg)\n-{\n-    PRStatus rv;\n-    PRIntn count;\n-    PRRecvWait* desc;\n-    Shared* shared = (Shared*)arg;\n-    PRIntervalTime five_seconds = PR_SecondsToInterval(5);\n-    PRMWaitEnumerator* enumerator = PR_CreateMWaitEnumerator(shared->group);\n-    MW_ASSERT(NULL != enumerator);\n-\n-    while (PR_SUCCESS == PR_Sleep(five_seconds)) {\n-        count = 0;\n-        desc = NULL;\n-        while (NULL != (desc = PR_EnumerateWaitGroup(enumerator, desc))) {\n-            if (verbosity > chatty) {\n-                PrintRecvDesc(desc, shared->title);\n-            }\n-            count += 1;\n-        }\n-        if (verbosity > silent)\n-            PR_fprintf(debug, \"%s Enumerated %d objects\\n\", shared->title, count);\n+      desc_out->timeout = PR_INTERVAL_NO_TIMEOUT;\n+      if (verbosity > chatty) {\n+        PrintRecvDesc(desc_out, \"Service re-adding\");\n+      }\n+      rv = PR_AddWaitFileDesc(shared->group, desc_out);\n+      MW_ASSERT(PR_SUCCESS == rv);\n     }\n \n-    MW_ASSERT(PR_PENDING_INTERRUPT_ERROR == PR_GetError());\n-\n-    rv = PR_DestroyMWaitEnumerator(enumerator);\n-    MW_ASSERT(PR_SUCCESS == rv);\n-} /* EnumerationThread */\n-\n-static void PR_CALLBACK\n-ServerThread(void* arg)\n-{\n-    PRStatus rv;\n-    PRIntn index;\n-    PRRecvWait* desc_in;\n-    PRThread** worker_thread;\n-    Shared* shared = (Shared*)arg;\n-    PRFileDesc *listener, *service;\n-    PRNetAddr server_address, client_address;\n-\n-    worker_thread = (PRThread**)PR_CALLOC(sizeof(PRThread*) * worker_threads);\n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: Server creating worker_threads\\n\", shared->title);\n-    }\n-    for (index = 0; index < worker_threads; ++index) {\n-        worker_thread[index] =\n-            PR_CreateThread(PR_USER_THREAD, ServiceThread, shared, PR_PRIORITY_HIGH,\n-                            thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n+    desc_out = PR_WaitRecvReady(shared->group);\n+    if (NULL == desc_out) {\n+      MW_ASSERT(PR_PENDING_INTERRUPT_ERROR == PR_GetError());\n+      break;\n     }\n \n-    rv = PR_InitializeNetAddr(PR_IpAddrAny, default_port, &server_address);\n-    MW_ASSERT(PR_SUCCESS == rv);\n-\n-    listener = PR_NewTCPSocket();\n-    MW_ASSERT(NULL != listener);\n-    if (verbosity > chatty)\n-        PR_fprintf(debug, \"%s: Server listener socket @0x%x\\n\", shared->title,\n-                   listener);\n-    rv = PR_Bind(listener, &server_address);\n-    MW_ASSERT(PR_SUCCESS == rv);\n-    rv = PR_Listen(listener, 10);\n-    MW_ASSERT(PR_SUCCESS == rv);\n-    while (ops_done < ops_required) {\n-        if (verbosity > quiet) {\n-            PR_fprintf(debug, \"%s: Server accepting connection\\n\", shared->title);\n+    switch (desc_out->outcome) {\n+      case PR_MW_SUCCESS: {\n+        PR_AtomicIncrement(&ops_done);\n+        if (verbosity > chatty) {\n+          PrintRecvDesc(desc_out, \"Service ready\");\n         }\n-        service = PR_Accept(listener, &client_address, PR_INTERVAL_NO_TIMEOUT);\n-        if (NULL == service) {\n-            if (PR_PENDING_INTERRUPT_ERROR == PR_GetError()) {\n-                break;\n-            }\n-            PL_PrintError(\"Accept failed\");\n-            MW_ASSERT(PR_FALSE && \"Accept failed\");\n-        } else {\n-            desc_in = CreateRecvWait(service, shared->timeout);\n-            desc_in->timeout = PR_INTERVAL_NO_TIMEOUT;\n-            if (verbosity > chatty) {\n-                PrintRecvDesc(desc_in, \"Service adding\");\n-            }\n-            rv = PR_AddWaitFileDesc(shared->group, desc_in);\n-            MW_ASSERT(PR_SUCCESS == rv);\n+        rv = ServiceRequest(shared, desc_out);\n+        break;\n+      }\n+      case PR_MW_INTERRUPT:\n+        MW_ASSERT(PR_PENDING_INTERRUPT_ERROR == PR_GetError());\n+        rv = PR_FAILURE; /* if interrupted, then exit */\n+        break;\n+      case PR_MW_TIMEOUT:\n+        MW_ASSERT(PR_IO_TIMEOUT_ERROR == PR_GetError());\n+      case PR_MW_FAILURE:\n+        if (verbosity > silent) {\n+          PL_FPrintError(debug, \"RecvReady failure\");\n         }\n+        break;\n+      default:\n+        break;\n     }\n+  } while (PR_SUCCESS == rv);\n \n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: Server interrupting worker_threads\\n\",\n-                   shared->title);\n-    }\n-    for (index = 0; index < worker_threads; ++index) {\n-        rv = PR_Interrupt(worker_thread[index]);\n-        MW_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_JoinThread(worker_thread[index]);\n-        MW_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PR_DELETE(worker_thread);\n+  if (NULL != desc_out) {\n+    DestroyRecvWait(desc_out);\n+  }\n \n-    PR_Close(listener);\n-\n-    CancelGroup(shared);\n-\n-} /* ServerThread */\n-\n-static void\n-RealOneGroupIO(Shared* shared)\n-{\n-    /*\n-    ** Create a server that listens for connections and then services\n-    ** requests that come in over those connections. The server never\n-    ** deletes a connection and assumes a basic RPC model of operation.\n-    **\n-    ** Use worker_threads threads to service how every many open ports\n-    ** there might be.\n-    **\n-    ** Oh, ya. Almost forget. Create (some) clients as well.\n-    */\n-    PRStatus rv;\n-    PRIntn index;\n-    PRThread *server_thread, *enumeration_thread, **client_thread;\n+} /* ServiceThread */\n \n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: creating server_thread\\n\", shared->title);\n-    }\n+static void PR_CALLBACK EnumerationThread(void* arg) {\n+  PRStatus rv;\n+  PRIntn count;\n+  PRRecvWait* desc;\n+  Shared* shared = (Shared*)arg;\n+  PRIntervalTime five_seconds = PR_SecondsToInterval(5);\n+  PRMWaitEnumerator* enumerator = PR_CreateMWaitEnumerator(shared->group);\n+  MW_ASSERT(NULL != enumerator);\n+\n+  while (PR_SUCCESS == PR_Sleep(five_seconds)) {\n+    count = 0;\n+    desc = NULL;\n+    while (NULL != (desc = PR_EnumerateWaitGroup(enumerator, desc))) {\n+      if (verbosity > chatty) {\n+        PrintRecvDesc(desc, shared->title);\n+      }\n+      count += 1;\n+    }\n+    if (verbosity > silent)\n+      PR_fprintf(debug, \"%s Enumerated %d objects\\n\", shared->title, count);\n+  }\n+\n+  MW_ASSERT(PR_PENDING_INTERRUPT_ERROR == PR_GetError());\n+\n+  rv = PR_DestroyMWaitEnumerator(enumerator);\n+  MW_ASSERT(PR_SUCCESS == rv);\n+} /* EnumerationThread */\n \n-    server_thread =\n-        PR_CreateThread(PR_USER_THREAD, ServerThread, shared, PR_PRIORITY_HIGH,\n+static void PR_CALLBACK ServerThread(void* arg) {\n+  PRStatus rv;\n+  PRIntn index;\n+  PRRecvWait* desc_in;\n+  PRThread** worker_thread;\n+  Shared* shared = (Shared*)arg;\n+  PRFileDesc *listener, *service;\n+  PRNetAddr server_address, client_address;\n+\n+  worker_thread = (PRThread**)PR_CALLOC(sizeof(PRThread*) * worker_threads);\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: Server creating worker_threads\\n\", shared->title);\n+  }\n+  for (index = 0; index < worker_threads; ++index) {\n+    worker_thread[index] =\n+        PR_CreateThread(PR_USER_THREAD, ServiceThread, shared, PR_PRIORITY_HIGH,\n                         thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n-\n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: creating enumeration_thread\\n\", shared->title);\n-    }\n-\n-    enumeration_thread = PR_CreateThread(PR_USER_THREAD, EnumerationThread,\n-                                         shared, PR_PRIORITY_HIGH, thread_scope,\n-                                         PR_JOINABLE_THREAD, 16 * 1024);\n-\n+  }\n+\n+  rv = PR_InitializeNetAddr(PR_IpAddrAny, default_port, &server_address);\n+  MW_ASSERT(PR_SUCCESS == rv);\n+\n+  listener = PR_NewTCPSocket();\n+  MW_ASSERT(NULL != listener);\n+  if (verbosity > chatty)\n+    PR_fprintf(debug, \"%s: Server listener socket @0x%x\\n\", shared->title,\n+               listener);\n+  rv = PR_Bind(listener, &server_address);\n+  MW_ASSERT(PR_SUCCESS == rv);\n+  rv = PR_Listen(listener, 10);\n+  MW_ASSERT(PR_SUCCESS == rv);\n+  while (ops_done < ops_required) {\n     if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: snoozing before creating clients\\n\", shared->title);\n-    }\n-    PR_Sleep(5 * shared->timeout);\n-\n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: creating client_threads\\n\", shared->title);\n-    }\n-    client_thread = (PRThread**)PR_CALLOC(sizeof(PRThread*) * client_threads);\n-    for (index = 0; index < client_threads; ++index) {\n-        client_thread[index] = PR_CreateThread(PR_USER_THREAD, ClientThread, shared,\n-                                               PR_PRIORITY_NORMAL, thread_scope,\n-                                               PR_JOINABLE_THREAD, 16 * 1024);\n-    }\n+      PR_fprintf(debug, \"%s: Server accepting connection\\n\", shared->title);\n+    }\n+    service = PR_Accept(listener, &client_address, PR_INTERVAL_NO_TIMEOUT);\n+    if (NULL == service) {\n+      if (PR_PENDING_INTERRUPT_ERROR == PR_GetError()) {\n+        break;\n+      }\n+      PL_PrintError(\"Accept failed\");\n+      MW_ASSERT(PR_FALSE && \"Accept failed\");\n+    } else {\n+      desc_in = CreateRecvWait(service, shared->timeout);\n+      desc_in->timeout = PR_INTERVAL_NO_TIMEOUT;\n+      if (verbosity > chatty) {\n+        PrintRecvDesc(desc_in, \"Service adding\");\n+      }\n+      rv = PR_AddWaitFileDesc(shared->group, desc_in);\n+      MW_ASSERT(PR_SUCCESS == rv);\n+    }\n+  }\n+\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: Server interrupting worker_threads\\n\",\n+               shared->title);\n+  }\n+  for (index = 0; index < worker_threads; ++index) {\n+    rv = PR_Interrupt(worker_thread[index]);\n+    MW_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_JoinThread(worker_thread[index]);\n+    MW_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PR_DELETE(worker_thread);\n \n-    while (ops_done < ops_required) {\n-        PR_Sleep(shared->timeout);\n-    }\n+  PR_Close(listener);\n \n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: interrupting/joining client_threads\\n\",\n-                   shared->title);\n-    }\n-    for (index = 0; index < client_threads; ++index) {\n-        rv = PR_Interrupt(client_thread[index]);\n-        MW_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_JoinThread(client_thread[index]);\n-        MW_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PR_DELETE(client_thread);\n+  CancelGroup(shared);\n \n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: interrupting/joining enumeration_thread\\n\",\n-                   shared->title);\n-    }\n-    rv = PR_Interrupt(enumeration_thread);\n-    MW_ASSERT(PR_SUCCESS == rv);\n-    rv = PR_JoinThread(enumeration_thread);\n-    MW_ASSERT(PR_SUCCESS == rv);\n+} /* ServerThread */\n \n-    if (verbosity > quiet) {\n-        PR_fprintf(debug, \"%s: interrupting/joining server_thread\\n\",\n-                   shared->title);\n-    }\n-    rv = PR_Interrupt(server_thread);\n+static void RealOneGroupIO(Shared* shared) {\n+  /*\n+  ** Create a server that listens for connections and then services\n+  ** requests that come in over those connections. The server never\n+  ** deletes a connection and assumes a basic RPC model of operation.\n+  **\n+  ** Use worker_threads threads to service how every many open ports\n+  ** there might be.\n+  **\n+  ** Oh, ya. Almost forget. Create (some) clients as well.\n+  */\n+  PRStatus rv;\n+  PRIntn index;\n+  PRThread *server_thread, *enumeration_thread, **client_thread;\n+\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: creating server_thread\\n\", shared->title);\n+  }\n+\n+  server_thread =\n+      PR_CreateThread(PR_USER_THREAD, ServerThread, shared, PR_PRIORITY_HIGH,\n+                      thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n+\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: creating enumeration_thread\\n\", shared->title);\n+  }\n+\n+  enumeration_thread = PR_CreateThread(PR_USER_THREAD, EnumerationThread,\n+                                       shared, PR_PRIORITY_HIGH, thread_scope,\n+                                       PR_JOINABLE_THREAD, 16 * 1024);\n+\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: snoozing before creating clients\\n\", shared->title);\n+  }\n+  PR_Sleep(5 * shared->timeout);\n+\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: creating client_threads\\n\", shared->title);\n+  }\n+  client_thread = (PRThread**)PR_CALLOC(sizeof(PRThread*) * client_threads);\n+  for (index = 0; index < client_threads; ++index) {\n+    client_thread[index] = PR_CreateThread(PR_USER_THREAD, ClientThread, shared,\n+                                           PR_PRIORITY_NORMAL, thread_scope,\n+                                           PR_JOINABLE_THREAD, 16 * 1024);\n+  }\n+\n+  while (ops_done < ops_required) {\n+    PR_Sleep(shared->timeout);\n+  }\n+\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: interrupting/joining client_threads\\n\",\n+               shared->title);\n+  }\n+  for (index = 0; index < client_threads; ++index) {\n+    rv = PR_Interrupt(client_thread[index]);\n     MW_ASSERT(PR_SUCCESS == rv);\n-    rv = PR_JoinThread(server_thread);\n+    rv = PR_JoinThread(client_thread[index]);\n     MW_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PR_DELETE(client_thread);\n+\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: interrupting/joining enumeration_thread\\n\",\n+               shared->title);\n+  }\n+  rv = PR_Interrupt(enumeration_thread);\n+  MW_ASSERT(PR_SUCCESS == rv);\n+  rv = PR_JoinThread(enumeration_thread);\n+  MW_ASSERT(PR_SUCCESS == rv);\n+\n+  if (verbosity > quiet) {\n+    PR_fprintf(debug, \"%s: interrupting/joining server_thread\\n\",\n+               shared->title);\n+  }\n+  rv = PR_Interrupt(server_thread);\n+  MW_ASSERT(PR_SUCCESS == rv);\n+  rv = PR_JoinThread(server_thread);\n+  MW_ASSERT(PR_SUCCESS == rv);\n } /* RealOneGroupIO */\n \n-static void\n-RunThisOne(void (*func)(Shared*), const char* name,\n-           const char* test_name)\n-{\n-    Shared* shared;\n-    if ((NULL == test_name) || (0 == PL_strcmp(name, test_name))) {\n-        if (verbosity > silent) {\n-            PR_fprintf(debug, \"%s()\\n\", name);\n-        }\n-        shared = MakeShared(name);\n-        ops_done = 0;\n-        func(shared); /* run the test */\n-        MW_ASSERT(0 == desc_allocated);\n-        DestroyShared(shared);\n+static void RunThisOne(void (*func)(Shared*), const char* name,\n+                       const char* test_name) {\n+  Shared* shared;\n+  if ((NULL == test_name) || (0 == PL_strcmp(name, test_name))) {\n+    if (verbosity > silent) {\n+      PR_fprintf(debug, \"%s()\\n\", name);\n     }\n+    shared = MakeShared(name);\n+    ops_done = 0;\n+    func(shared); /* run the test */\n+    MW_ASSERT(0 == desc_allocated);\n+    DestroyShared(shared);\n+  }\n } /* RunThisOne */\n \n-static Verbosity\n-ChangeVerbosity(Verbosity verbosity, PRIntn delta)\n-{\n-    return (Verbosity)(((PRIntn)verbosity) + delta);\n+static Verbosity ChangeVerbosity(Verbosity verbosity, PRIntn delta) {\n+  return (Verbosity)(((PRIntn)verbosity) + delta);\n } /* ChangeVerbosity */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PLOptStatus os;\n-    const char* test_name = NULL;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dqGc:o:p:t:w:\");\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n+int main(int argc, char** argv) {\n+  PLOptStatus os;\n+  const char* test_name = NULL;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dqGc:o:p:t:w:\");\n+\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 0:\n+        test_name = opt->value;\n+        break;\n+      case 'd': /* debug mode */\n+        if (verbosity < noisy) {\n+          verbosity = ChangeVerbosity(verbosity, 1);\n         }\n-        switch (opt->option) {\n-            case 0:\n-                test_name = opt->value;\n-                break;\n-            case 'd': /* debug mode */\n-                if (verbosity < noisy) {\n-                    verbosity = ChangeVerbosity(verbosity, 1);\n-                }\n-                break;\n-            case 'q': /* debug mode */\n-                if (verbosity > silent) {\n-                    verbosity = ChangeVerbosity(verbosity, -1);\n-                }\n-                break;\n-            case 'G': /* use global threads */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'c': /* number of client threads */\n-                client_threads = atoi(opt->value);\n-                break;\n-            case 'o': /* operations to compelete */\n-                ops_required = atoi(opt->value);\n-                break;\n-            case 'p': /* default port */\n-                default_port = atoi(opt->value);\n-                break;\n-            case 't': /* number of threads waiting */\n-                worker_threads = atoi(opt->value);\n-                break;\n-            case 'w': /* number of wait objects */\n-                wait_objects = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n+        break;\n+      case 'q': /* debug mode */\n+        if (verbosity > silent) {\n+          verbosity = ChangeVerbosity(verbosity, -1);\n         }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    if (verbosity > 0) {\n-        debug = PR_GetSpecialFD(PR_StandardError);\n-    }\n-\n-    RunThisOne(OneInThenCancelled, \"OneInThenCancelled\", test_name);\n-    RunThisOne(OneOpOneThread, \"OneOpOneThread\", test_name);\n-    RunThisOne(ManyOpOneThread, \"ManyOpOneThread\", test_name);\n-    RunThisOne(SomeOpsSomeThreads, \"SomeOpsSomeThreads\", test_name);\n-    RunThisOne(RealOneGroupIO, \"RealOneGroupIO\", test_name);\n-    return 0;\n+        break;\n+      case 'G': /* use global threads */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'c': /* number of client threads */\n+        client_threads = atoi(opt->value);\n+        break;\n+      case 'o': /* operations to compelete */\n+        ops_required = atoi(opt->value);\n+        break;\n+      case 'p': /* default port */\n+        default_port = atoi(opt->value);\n+        break;\n+      case 't': /* number of threads waiting */\n+        worker_threads = atoi(opt->value);\n+        break;\n+      case 'w': /* number of wait objects */\n+        wait_objects = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  if (verbosity > 0) {\n+    debug = PR_GetSpecialFD(PR_StandardError);\n+  }\n+\n+  RunThisOne(OneInThenCancelled, \"OneInThenCancelled\", test_name);\n+  RunThisOne(OneOpOneThread, \"OneOpOneThread\", test_name);\n+  RunThisOne(ManyOpOneThread, \"ManyOpOneThread\", test_name);\n+  RunThisOne(SomeOpsSomeThreads, \"SomeOpsSomeThreads\", test_name);\n+  RunThisOne(RealOneGroupIO, \"RealOneGroupIO\", test_name);\n+  return 0;\n } /* main */\n \n /* multwait.c */\ndiff --git a/nspr/pr/tests/nameshm1.c b/nspr/pr/tests/nameshm1.c\nindex 153d6ba..da5e122 100644\n--- a/nspr/pr/tests/nameshm1.c\n+++ b/nspr/pr/tests/nameshm1.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -72,14 +73,14 @@\n #include <private/primpl.h>\n \n #ifdef DEBUG\n-#define SEM_D \"D\"\n+#  define SEM_D \"D\"\n #else\n-#define SEM_D\n+#  define SEM_D\n #endif\n #ifdef IS_64\n-#define SEM_64 \"64\"\n+#  define SEM_64 \"64\"\n #else\n-#define SEM_64\n+#  define SEM_64\n #endif\n \n #define SEM_NAME1 \"/tmp/nameshmSEM1\" SEM_D SEM_64\n@@ -113,429 +114,419 @@ char optName[NameSize] = OPT_NAME;\n \n char buf[1024] = \"\";\n \n-static void\n-BasicTest(void)\n-{\n-    PRSharedMemory* shm;\n-    char* addr; /* address of shared memory segment */\n-    PRUint32 i;\n-    PRInt32 rc;\n-\n-    PR_LOG(lm, msgLevel, (\"nameshm1: Begin BasicTest\"));\n-\n-    if (PR_FAILURE == PR_DeleteSharedMemory(optName)) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: Initial PR_DeleteSharedMemory() failed. No problem\"));\n-    } else\n-        PR_LOG(lm, msgLevel, (\"nameshm1: Initial PR_DeleteSharedMemory() success\"));\n-\n-    shm = PR_OpenSharedMemory(optName, optSize, (PR_SHM_CREATE | PR_SHM_EXCL),\n-                              SHM_MODE);\n-    if (NULL == shm) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: RW Create: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: RW Create: success: %p\", shm));\n-\n-    addr = PR_AttachSharedMemory(shm, 0);\n-    if (NULL == addr) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: RW Attach: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: RW Attach: success: %p\", addr));\n-\n-    /* fill memory with i */\n-    for (i = 0; i < optSize; i++) {\n-        *(addr + i) = i;\n-    }\n-\n-    rc = PR_DetachSharedMemory(shm, addr);\n-    if (PR_FAILURE == rc) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: RW Detach: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: RW Detach: success: \"));\n-\n-    rc = PR_CloseSharedMemory(shm);\n-    if (PR_FAILURE == rc) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: RW Close: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: RW Close: success: \"));\n-\n-    rc = PR_DeleteSharedMemory(optName);\n-    if (PR_FAILURE == rc) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: RW Delete: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: RW Delete: success: \"));\n+static void BasicTest(void) {\n+  PRSharedMemory* shm;\n+  char* addr; /* address of shared memory segment */\n+  PRUint32 i;\n+  PRInt32 rc;\n+\n+  PR_LOG(lm, msgLevel, (\"nameshm1: Begin BasicTest\"));\n+\n+  if (PR_FAILURE == PR_DeleteSharedMemory(optName)) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: Initial PR_DeleteSharedMemory() failed. No problem\"));\n+  } else\n+    PR_LOG(lm, msgLevel, (\"nameshm1: Initial PR_DeleteSharedMemory() success\"));\n+\n+  shm = PR_OpenSharedMemory(optName, optSize, (PR_SHM_CREATE | PR_SHM_EXCL),\n+                            SHM_MODE);\n+  if (NULL == shm) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: RW Create: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: RW Create: success: %p\", shm));\n+\n+  addr = PR_AttachSharedMemory(shm, 0);\n+  if (NULL == addr) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: RW Attach: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: RW Attach: success: %p\", addr));\n+\n+  /* fill memory with i */\n+  for (i = 0; i < optSize; i++) {\n+    *(addr + i) = i;\n+  }\n+\n+  rc = PR_DetachSharedMemory(shm, addr);\n+  if (PR_FAILURE == rc) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: RW Detach: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: RW Detach: success: \"));\n+\n+  rc = PR_CloseSharedMemory(shm);\n+  if (PR_FAILURE == rc) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: RW Close: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: RW Close: success: \"));\n+\n+  rc = PR_DeleteSharedMemory(optName);\n+  if (PR_FAILURE == rc) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: RW Delete: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: RW Delete: success: \"));\n \n-    PR_LOG(lm, msgLevel, (\"nameshm1: BasicTest(): Passed\"));\n+  PR_LOG(lm, msgLevel, (\"nameshm1: BasicTest(): Passed\"));\n \n-    return;\n+  return;\n } /* end BasicTest() */\n \n-static void\n-ReadOnlyTest(void)\n-{\n-    PRSharedMemory* shm;\n-    char* roAddr; /* read-only address of shared memory segment */\n-    PRInt32 rc;\n-\n-    PR_LOG(lm, msgLevel, (\"nameshm1: Begin ReadOnlyTest\"));\n-\n-    shm = PR_OpenSharedMemory(optName, optSize, (PR_SHM_CREATE | PR_SHM_EXCL),\n-                              SHM_MODE);\n-    if (NULL == shm) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: RO Create: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: RO Create: success: %p\", shm));\n-\n-    roAddr = PR_AttachSharedMemory(shm, PR_SHM_READONLY);\n-    if (NULL == roAddr) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: RO Attach: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: RO Attach: success: %p\", roAddr));\n+static void ReadOnlyTest(void) {\n+  PRSharedMemory* shm;\n+  char* roAddr; /* read-only address of shared memory segment */\n+  PRInt32 rc;\n \n-    if (optWriteRO) {\n-        *roAddr = 0x00; /* write to read-only memory */\n-        failed_already = 1;\n-        PR_LOG(lm, msgLevel, (\"nameshm1: Wrote to read-only memory segment!\"));\n-        return;\n-    }\n-\n-    rc = PR_DetachSharedMemory(shm, roAddr);\n-    if (PR_FAILURE == rc) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: RO Detach: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: RO Detach: success: \"));\n-\n-    rc = PR_CloseSharedMemory(shm);\n-    if (PR_FAILURE == rc) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: RO Close: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: RO Close: success: \"));\n-\n-    rc = PR_DeleteSharedMemory(optName);\n-    if (PR_FAILURE == rc) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: RO Destroy: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: RO Destroy: success: \"));\n+  PR_LOG(lm, msgLevel, (\"nameshm1: Begin ReadOnlyTest\"));\n \n-    PR_LOG(lm, msgLevel, (\"nameshm1: ReadOnlyTest(): Passed\"));\n+  shm = PR_OpenSharedMemory(optName, optSize, (PR_SHM_CREATE | PR_SHM_EXCL),\n+                            SHM_MODE);\n+  if (NULL == shm) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: RO Create: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: RO Create: success: %p\", shm));\n+\n+  roAddr = PR_AttachSharedMemory(shm, PR_SHM_READONLY);\n+  if (NULL == roAddr) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: RO Attach: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: RO Attach: success: %p\", roAddr));\n \n+  if (optWriteRO) {\n+    *roAddr = 0x00; /* write to read-only memory */\n+    failed_already = 1;\n+    PR_LOG(lm, msgLevel, (\"nameshm1: Wrote to read-only memory segment!\"));\n+    return;\n+  }\n+\n+  rc = PR_DetachSharedMemory(shm, roAddr);\n+  if (PR_FAILURE == rc) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: RO Detach: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n     return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: RO Detach: success: \"));\n+\n+  rc = PR_CloseSharedMemory(shm);\n+  if (PR_FAILURE == rc) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: RO Close: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: RO Close: success: \"));\n+\n+  rc = PR_DeleteSharedMemory(optName);\n+  if (PR_FAILURE == rc) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: RO Destroy: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: RO Destroy: success: \"));\n+\n+  PR_LOG(lm, msgLevel, (\"nameshm1: ReadOnlyTest(): Passed\"));\n+\n+  return;\n } /* end ReadOnlyTest() */\n \n-static void\n-DoClient(void)\n-{\n-    PRStatus rc;\n-    PRSem *sem1, *sem2;\n-    PRSharedMemory* shm;\n-    PRUint32* addr;\n-    PRInt32 i;\n-\n-    PR_LOG(lm, msgLevel, (\"nameshm1: DoClient(): Starting\"));\n-\n-    sem1 = PR_OpenSemaphore(SEM_NAME1, 0, 0, 0);\n-    PR_ASSERT(sem1);\n-\n-    sem2 = PR_OpenSemaphore(SEM_NAME2, 0, 0, 0);\n-    PR_ASSERT(sem1);\n-\n-    shm = PR_OpenSharedMemory(optName, optSize, 0, SHM_MODE);\n-    if (NULL == shm) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: DoClient(): Create: Error: %ld. OSError: %ld\",\n-                PR_GetError(), PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: DoClient(): Create: success: %p\", shm));\n-\n-    addr = PR_AttachSharedMemory(shm, 0);\n-    if (NULL == addr) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: DoClient(): Attach: Error: %ld. OSError: %ld\",\n-                PR_GetError(), PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: DoClient(): Attach: success: %p\", addr));\n+static void DoClient(void) {\n+  PRStatus rc;\n+  PRSem *sem1, *sem2;\n+  PRSharedMemory* shm;\n+  PRUint32* addr;\n+  PRInt32 i;\n \n-    PR_LOG(lm, msgLevel, (\"Client found: %s\", addr));\n+  PR_LOG(lm, msgLevel, (\"nameshm1: DoClient(): Starting\"));\n \n-    PR_Sleep(PR_SecondsToInterval(4));\n-    for (i = 0; i < optPing; i++) {\n-        rc = PR_WaitSemaphore(sem2);\n-        PR_ASSERT(PR_FAILURE != rc);\n+  sem1 = PR_OpenSemaphore(SEM_NAME1, 0, 0, 0);\n+  PR_ASSERT(sem1);\n \n-        (*addr)++;\n-        PR_ASSERT((*addr % 2) == 0);\n-        if (optVerbose)\n-            PR_LOG(lm, msgLevel, (\"nameshm1: Client ping: %d, i: %d\", *addr, i));\n+  sem2 = PR_OpenSemaphore(SEM_NAME2, 0, 0, 0);\n+  PR_ASSERT(sem1);\n \n-        rc = PR_PostSemaphore(sem1);\n-        PR_ASSERT(PR_FAILURE != rc);\n-    }\n+  shm = PR_OpenSharedMemory(optName, optSize, 0, SHM_MODE);\n+  if (NULL == shm) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: DoClient(): Create: Error: %ld. OSError: %ld\",\n+            PR_GetError(), PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: DoClient(): Create: success: %p\", shm));\n+\n+  addr = PR_AttachSharedMemory(shm, 0);\n+  if (NULL == addr) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: DoClient(): Attach: Error: %ld. OSError: %ld\",\n+            PR_GetError(), PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: DoClient(): Attach: success: %p\", addr));\n \n-    rc = PR_CloseSemaphore(sem1);\n+  PR_LOG(lm, msgLevel, (\"Client found: %s\", addr));\n+\n+  PR_Sleep(PR_SecondsToInterval(4));\n+  for (i = 0; i < optPing; i++) {\n+    rc = PR_WaitSemaphore(sem2);\n     PR_ASSERT(PR_FAILURE != rc);\n \n-    rc = PR_CloseSemaphore(sem2);\n+    (*addr)++;\n+    PR_ASSERT((*addr % 2) == 0);\n+    if (optVerbose)\n+      PR_LOG(lm, msgLevel, (\"nameshm1: Client ping: %d, i: %d\", *addr, i));\n+\n+    rc = PR_PostSemaphore(sem1);\n     PR_ASSERT(PR_FAILURE != rc);\n+  }\n \n-    rc = PR_DetachSharedMemory(shm, addr);\n-    if (PR_FAILURE == rc) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: DoClient(): Detach: Error: %ld. OSError: %ld\",\n-                PR_GetError(), PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: DoClient(): Detach: success: \"));\n-\n-    rc = PR_CloseSharedMemory(shm);\n-    if (PR_FAILURE == rc) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: DoClient(): Close: Error: %ld. OSError: %ld\",\n-                PR_GetError(), PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: DoClient(): Close: success: \"));\n+  rc = PR_CloseSemaphore(sem1);\n+  PR_ASSERT(PR_FAILURE != rc);\n \n+  rc = PR_CloseSemaphore(sem2);\n+  PR_ASSERT(PR_FAILURE != rc);\n+\n+  rc = PR_DetachSharedMemory(shm, addr);\n+  if (PR_FAILURE == rc) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: DoClient(): Detach: Error: %ld. OSError: %ld\",\n+            PR_GetError(), PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: DoClient(): Detach: success: \"));\n+\n+  rc = PR_CloseSharedMemory(shm);\n+  if (PR_FAILURE == rc) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: DoClient(): Close: Error: %ld. OSError: %ld\",\n+            PR_GetError(), PR_GetOSError()));\n+    failed_already = 1;\n     return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: DoClient(): Close: success: \"));\n+\n+  return;\n } /* end DoClient() */\n \n-static void\n-ClientServerTest(void)\n-{\n-    PRStatus rc;\n-    PRSem *sem1, *sem2;\n-    PRProcess* proc;\n-    PRInt32 exit_status;\n-    PRSharedMemory* shm;\n-    PRUint32* addr;\n-    PRInt32 i;\n-    char* child_argv[8];\n-    char buf[24];\n-\n-    PR_LOG(lm, msgLevel, (\"nameshm1: Begin ClientServerTest\"));\n-\n-    rc = PR_DeleteSharedMemory(optName);\n-    if (PR_FAILURE == rc) {\n-        PR_LOG(lm, msgLevel, (\"nameshm1: Server: Destroy: failed. No problem\"));\n-    } else\n-        PR_LOG(lm, msgLevel, (\"nameshm1: Server: Destroy: success\"));\n-\n-    shm = PR_OpenSharedMemory(optName, optSize, (PR_SHM_CREATE | PR_SHM_EXCL),\n-                              SHM_MODE);\n-    if (NULL == shm) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: Server: Create: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: Server: Create: success: %p\", shm));\n-\n-    addr = PR_AttachSharedMemory(shm, 0);\n-    if (NULL == addr) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: Server: Attach: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: Server: Attach: success: %p\", addr));\n+static void ClientServerTest(void) {\n+  PRStatus rc;\n+  PRSem *sem1, *sem2;\n+  PRProcess* proc;\n+  PRInt32 exit_status;\n+  PRSharedMemory* shm;\n+  PRUint32* addr;\n+  PRInt32 i;\n+  char* child_argv[8];\n+  char buf[24];\n+\n+  PR_LOG(lm, msgLevel, (\"nameshm1: Begin ClientServerTest\"));\n+\n+  rc = PR_DeleteSharedMemory(optName);\n+  if (PR_FAILURE == rc) {\n+    PR_LOG(lm, msgLevel, (\"nameshm1: Server: Destroy: failed. No problem\"));\n+  } else\n+    PR_LOG(lm, msgLevel, (\"nameshm1: Server: Destroy: success\"));\n \n-    sem1 = PR_OpenSemaphore(SEM_NAME1, PR_SEM_CREATE, SEM_MODE, 0);\n-    PR_ASSERT(sem1);\n+  shm = PR_OpenSharedMemory(optName, optSize, (PR_SHM_CREATE | PR_SHM_EXCL),\n+                            SHM_MODE);\n+  if (NULL == shm) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: Server: Create: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: Server: Create: success: %p\", shm));\n+\n+  addr = PR_AttachSharedMemory(shm, 0);\n+  if (NULL == addr) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: Server: Attach: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: Server: Attach: success: %p\", addr));\n \n-    sem2 = PR_OpenSemaphore(SEM_NAME2, PR_SEM_CREATE, SEM_MODE, 1);\n-    PR_ASSERT(sem1);\n+  sem1 = PR_OpenSemaphore(SEM_NAME1, PR_SEM_CREATE, SEM_MODE, 0);\n+  PR_ASSERT(sem1);\n \n-    strcpy((char*)addr, \"FooBar\");\n+  sem2 = PR_OpenSemaphore(SEM_NAME2, PR_SEM_CREATE, SEM_MODE, 1);\n+  PR_ASSERT(sem1);\n \n-    child_argv[0] = EXE_NAME;\n-    child_argv[1] = \"-C\";\n-    child_argv[2] = \"-p\";\n-    sprintf(buf, \"%d\", optPing);\n-    child_argv[3] = buf;\n-    child_argv[4] = optName;\n-    child_argv[5] = NULL;\n+  strcpy((char*)addr, \"FooBar\");\n \n-    proc = PR_CreateProcess(child_argv[0], child_argv, NULL, NULL);\n-    PR_ASSERT(proc);\n+  child_argv[0] = EXE_NAME;\n+  child_argv[1] = \"-C\";\n+  child_argv[2] = \"-p\";\n+  sprintf(buf, \"%d\", optPing);\n+  child_argv[3] = buf;\n+  child_argv[4] = optName;\n+  child_argv[5] = NULL;\n \n-    PR_Sleep(PR_SecondsToInterval(4));\n+  proc = PR_CreateProcess(child_argv[0], child_argv, NULL, NULL);\n+  PR_ASSERT(proc);\n \n-    *addr = 1;\n-    for (i = 0; i < optPing; i++) {\n-        rc = PR_WaitSemaphore(sem1);\n-        PR_ASSERT(PR_FAILURE != rc);\n+  PR_Sleep(PR_SecondsToInterval(4));\n \n-        (*addr)++;\n-        PR_ASSERT((*addr % 2) == 1);\n-        if (optVerbose)\n-            PR_LOG(lm, msgLevel, (\"nameshm1: Server pong: %d, i: %d\", *addr, i));\n+  *addr = 1;\n+  for (i = 0; i < optPing; i++) {\n+    rc = PR_WaitSemaphore(sem1);\n+    PR_ASSERT(PR_FAILURE != rc);\n \n-        rc = PR_PostSemaphore(sem2);\n-        PR_ASSERT(PR_FAILURE != rc);\n-    }\n+    (*addr)++;\n+    PR_ASSERT((*addr % 2) == 1);\n+    if (optVerbose)\n+      PR_LOG(lm, msgLevel, (\"nameshm1: Server pong: %d, i: %d\", *addr, i));\n \n-    rc = PR_WaitProcess(proc, &exit_status);\n+    rc = PR_PostSemaphore(sem2);\n     PR_ASSERT(PR_FAILURE != rc);\n+  }\n \n-    rc = PR_CloseSemaphore(sem1);\n-    PR_ASSERT(PR_FAILURE != rc);\n+  rc = PR_WaitProcess(proc, &exit_status);\n+  PR_ASSERT(PR_FAILURE != rc);\n \n-    rc = PR_CloseSemaphore(sem2);\n-    PR_ASSERT(PR_FAILURE != rc);\n+  rc = PR_CloseSemaphore(sem1);\n+  PR_ASSERT(PR_FAILURE != rc);\n \n-    rc = PR_DeleteSemaphore(SEM_NAME1);\n-    PR_ASSERT(PR_FAILURE != rc);\n+  rc = PR_CloseSemaphore(sem2);\n+  PR_ASSERT(PR_FAILURE != rc);\n \n-    rc = PR_DeleteSemaphore(SEM_NAME2);\n-    PR_ASSERT(PR_FAILURE != rc);\n+  rc = PR_DeleteSemaphore(SEM_NAME1);\n+  PR_ASSERT(PR_FAILURE != rc);\n \n-    rc = PR_DetachSharedMemory(shm, addr);\n-    if (PR_FAILURE == rc) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: Server: Detach: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: Server: Detach: success: \"));\n-\n-    rc = PR_CloseSharedMemory(shm);\n-    if (PR_FAILURE == rc) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: Server: Close: Error: %ld. OSError: %ld\", PR_GetError(),\n-                PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: Server: Close: success: \"));\n-\n-    rc = PR_DeleteSharedMemory(optName);\n-    if (PR_FAILURE == rc) {\n-        PR_LOG(lm, msgLevel,\n-               (\"nameshm1: Server: Destroy: Error: %ld. OSError: %ld\",\n-                PR_GetError(), PR_GetOSError()));\n-        failed_already = 1;\n-        return;\n-    }\n-    PR_LOG(lm, msgLevel, (\"nameshm1: Server: Destroy: success\"));\n+  rc = PR_DeleteSemaphore(SEM_NAME2);\n+  PR_ASSERT(PR_FAILURE != rc);\n \n+  rc = PR_DetachSharedMemory(shm, addr);\n+  if (PR_FAILURE == rc) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: Server: Detach: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n     return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: Server: Detach: success: \"));\n+\n+  rc = PR_CloseSharedMemory(shm);\n+  if (PR_FAILURE == rc) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: Server: Close: Error: %ld. OSError: %ld\", PR_GetError(),\n+            PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: Server: Close: success: \"));\n+\n+  rc = PR_DeleteSharedMemory(optName);\n+  if (PR_FAILURE == rc) {\n+    PR_LOG(lm, msgLevel,\n+           (\"nameshm1: Server: Destroy: Error: %ld. OSError: %ld\",\n+            PR_GetError(), PR_GetOSError()));\n+    failed_already = 1;\n+    return;\n+  }\n+  PR_LOG(lm, msgLevel, (\"nameshm1: Server: Destroy: success\"));\n+\n+  return;\n } /* end ClientServerTest() */\n \n-int\n-main(int argc, char** argv)\n-{\n-    {\n-        /*\n-        ** Get command line options\n-        */\n-        PLOptStatus os;\n-        PLOptState* opt = PL_CreateOptState(argc, argv, \"Cdvw:s:p:i:\");\n-\n-        while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-            if (PL_OPT_BAD == os) {\n-                continue;\n-            }\n-            switch (opt->option) {\n-                case 'v': /* debug mode */\n-                    optVerbose = 1;\n-                /* no break! fall into debug option */\n-                case 'd': /* debug mode */\n-                    debug = 1;\n-                    msgLevel = PR_LOG_DEBUG;\n-                    break;\n-                case 'w': /* try writing to memory mapped read-only */\n-                    optWriteRO = 1;\n-                    break;\n-                case 'C':\n-                    optClient = 1;\n-                    break;\n-                case 's':\n-                    optSize = atol(opt->value) * 1024;\n-                    break;\n-                case 'p':\n-                    optPing = atol(opt->value);\n-                    break;\n-                case 'i':\n-                    optClientIterations = atol(opt->value);\n-                    break;\n-                default:\n-                    strcpy(optName, opt->value);\n-                    break;\n-            }\n-        }\n-        PL_DestroyOptState(opt);\n+int main(int argc, char** argv) {\n+  {\n+    /*\n+    ** Get command line options\n+    */\n+    PLOptStatus os;\n+    PLOptState* opt = PL_CreateOptState(argc, argv, \"Cdvw:s:p:i:\");\n+\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+      if (PL_OPT_BAD == os) {\n+        continue;\n+      }\n+      switch (opt->option) {\n+        case 'v': /* debug mode */\n+          optVerbose = 1;\n+        /* no break! fall into debug option */\n+        case 'd': /* debug mode */\n+          debug = 1;\n+          msgLevel = PR_LOG_DEBUG;\n+          break;\n+        case 'w': /* try writing to memory mapped read-only */\n+          optWriteRO = 1;\n+          break;\n+        case 'C':\n+          optClient = 1;\n+          break;\n+        case 's':\n+          optSize = atol(opt->value) * 1024;\n+          break;\n+        case 'p':\n+          optPing = atol(opt->value);\n+          break;\n+        case 'i':\n+          optClientIterations = atol(opt->value);\n+          break;\n+        default:\n+          strcpy(optName, opt->value);\n+          break;\n+      }\n     }\n+    PL_DestroyOptState(opt);\n+  }\n+\n+  lm = PR_NewLogModule(\"Test\"); /* Initialize logging */\n \n-    lm = PR_NewLogModule(\"Test\"); /* Initialize logging */\n-\n-    PR_LOG(lm, msgLevel, (\"nameshm1: Starting\"));\n-\n-    if (optClient) {\n-        DoClient();\n-    } else {\n-        BasicTest();\n-        if (failed_already != 0) {\n-            goto Finished;\n-        }\n-        ReadOnlyTest();\n-        if (failed_already != 0) {\n-            goto Finished;\n-        }\n-        ClientServerTest();\n+  PR_LOG(lm, msgLevel, (\"nameshm1: Starting\"));\n+\n+  if (optClient) {\n+    DoClient();\n+  } else {\n+    BasicTest();\n+    if (failed_already != 0) {\n+      goto Finished;\n+    }\n+    ReadOnlyTest();\n+    if (failed_already != 0) {\n+      goto Finished;\n     }\n+    ClientServerTest();\n+  }\n \n Finished:\n-    if (debug) {\n-        printf(\"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n-    }\n-    return ((failed_already) ? 1 : 0);\n+  if (debug) {\n+    printf(\"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n+  }\n+  return ((failed_already) ? 1 : 0);\n } /* main() */\n /* end instrumt.c */\ndiff --git a/nspr/pr/tests/nbconn.c b/nspr/pr/tests/nbconn.c\nindex f12ce44..6c96c02 100644\n--- a/nspr/pr/tests/nbconn.c\n+++ b/nspr/pr/tests/nbconn.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -34,144 +35,141 @@\n #define TCP_UNUSED_PORT 211\n \n typedef struct Server_Param {\n-    PRFileDesc* sp_fd; /* server port */\n+  PRFileDesc* sp_fd; /* server port */\n } Server_Param;\n static void PR_CALLBACK TCP_Server(void* arg);\n \n int _debug_on;\n #define DPRINTF(arg) \\\n-    if (_debug_on)   \\\n-    printf arg\n+  if (_debug_on) printf arg\n \n static PRIntn connection_success_test();\n static PRIntn connection_failure_test();\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRHostEnt he;\n-    char buf[1024];\n-    PRNetAddr addr;\n-    PRPollDesc pd;\n-    PRStatus rv;\n-    PRSocketOptionData optData;\n-    const char* hostname = NULL;\n-    PRIntn default_case, n, bytes_read, bytes_sent;\n-    PRInt32 failed_already = 0;\n+int main(int argc, char** argv) {\n+  PRHostEnt he;\n+  char buf[1024];\n+  PRNetAddr addr;\n+  PRPollDesc pd;\n+  PRStatus rv;\n+  PRSocketOptionData optData;\n+  const char* hostname = NULL;\n+  PRIntn default_case, n, bytes_read, bytes_sent;\n+  PRInt32 failed_already = 0;\n \n-    /*\n-     * -d           debug mode\n-     */\n+  /*\n+   * -d           debug mode\n+   */\n \n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 0: /* debug mode */\n-                hostname = opt->value;\n-                break;\n-            case 'd': /* debug mode */\n-                _debug_on = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 0: /* debug mode */\n+        hostname = opt->value;\n+        break;\n+      case 'd': /* debug mode */\n+        _debug_on = 1;\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n+  }\n+  PL_DestroyOptState(opt);\n \n-    if (hostname) {\n-        default_case = 0;\n-    } else {\n-        default_case = 1;\n+  if (hostname) {\n+    default_case = 0;\n+  } else {\n+    default_case = 1;\n+  }\n+\n+  if (default_case) {\n+    /*\n+     * In the default case the following tests are executed:\n+     *  1. successful connection: a server thread accepts a connection\n+     *     from the main thread\n+     *  2. unsuccessful connection: the main thread tries to connect to a\n+     *     nonexistent port and expects to get an error\n+     */\n+    rv = connection_success_test();\n+    if (rv == 0) {\n+      rv = connection_failure_test();\n     }\n+    return rv;\n+  } else {\n+    PRFileDesc* sock;\n \n-    if (default_case) {\n-        /*\n-         * In the default case the following tests are executed:\n-         *  1. successful connection: a server thread accepts a connection\n-         *     from the main thread\n-         *  2. unsuccessful connection: the main thread tries to connect to a\n-         *     nonexistent port and expects to get an error\n-         */\n-        rv = connection_success_test();\n-        if (rv == 0) {\n-            rv = connection_failure_test();\n-        }\n-        return rv;\n+    if (PR_GetHostByName(argv[1], buf, sizeof(buf), &he) == PR_FAILURE) {\n+      printf(\"Unknown host: %s\\n\", argv[1]);\n+      exit(1);\n     } else {\n-        PRFileDesc* sock;\n+      printf(\"host: %s\\n\", buf);\n+    }\n+    PR_EnumerateHostEnt(0, &he, 80, &addr);\n \n-        if (PR_GetHostByName(argv[1], buf, sizeof(buf), &he) == PR_FAILURE) {\n-            printf(\"Unknown host: %s\\n\", argv[1]);\n-            exit(1);\n-        } else {\n-            printf(\"host: %s\\n\", buf);\n-        }\n-        PR_EnumerateHostEnt(0, &he, 80, &addr);\n+    sock = PR_NewTCPSocket();\n+    optData.option = PR_SockOpt_Nonblocking;\n+    optData.value.non_blocking = PR_TRUE;\n+    PR_SetSocketOption(sock, &optData);\n+    rv = PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT);\n+    if (rv == PR_FAILURE && PR_GetError() == PR_IN_PROGRESS_ERROR) {\n+      printf(\"Connect in progress\\n\");\n+    }\n \n-        sock = PR_NewTCPSocket();\n-        optData.option = PR_SockOpt_Nonblocking;\n-        optData.value.non_blocking = PR_TRUE;\n-        PR_SetSocketOption(sock, &optData);\n-        rv = PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT);\n-        if (rv == PR_FAILURE && PR_GetError() == PR_IN_PROGRESS_ERROR) {\n-            printf(\"Connect in progress\\n\");\n-        }\n+    pd.fd = sock;\n+    pd.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;\n+    n = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n+    if (n == -1) {\n+      printf(\"PR_Poll failed\\n\");\n+      exit(1);\n+    }\n+    printf(\"PR_Poll returns %d\\n\", n);\n+    if (pd.out_flags & PR_POLL_READ) {\n+      printf(\"PR_POLL_READ\\n\");\n+    }\n+    if (pd.out_flags & PR_POLL_WRITE) {\n+      printf(\"PR_POLL_WRITE\\n\");\n+    }\n+    if (pd.out_flags & PR_POLL_EXCEPT) {\n+      printf(\"PR_POLL_EXCEPT\\n\");\n+    }\n+    if (pd.out_flags & PR_POLL_ERR) {\n+      printf(\"PR_POLL_ERR\\n\");\n+    }\n+    if (pd.out_flags & PR_POLL_NVAL) {\n+      printf(\"PR_POLL_NVAL\\n\");\n+    }\n \n-        pd.fd = sock;\n-        pd.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;\n+    if (PR_GetConnectStatus(&pd) == PR_SUCCESS) {\n+      printf(\"PR_GetConnectStatus: connect succeeded\\n\");\n+      PR_Write(sock, \"GET /\\r\\n\\r\\n\", 9);\n+      PR_Shutdown(sock, PR_SHUTDOWN_SEND);\n+      pd.in_flags = PR_POLL_READ;\n+      while (1) {\n         n = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n-        if (n == -1) {\n-            printf(\"PR_Poll failed\\n\");\n-            exit(1);\n+        printf(\"poll returns %d\\n\", n);\n+        n = PR_Read(sock, buf, sizeof(buf));\n+        printf(\"read returns %d\\n\", n);\n+        if (n <= 0) {\n+          break;\n         }\n-        printf(\"PR_Poll returns %d\\n\", n);\n-        if (pd.out_flags & PR_POLL_READ) {\n-            printf(\"PR_POLL_READ\\n\");\n-        }\n-        if (pd.out_flags & PR_POLL_WRITE) {\n-            printf(\"PR_POLL_WRITE\\n\");\n-        }\n-        if (pd.out_flags & PR_POLL_EXCEPT) {\n-            printf(\"PR_POLL_EXCEPT\\n\");\n-        }\n-        if (pd.out_flags & PR_POLL_ERR) {\n-            printf(\"PR_POLL_ERR\\n\");\n-        }\n-        if (pd.out_flags & PR_POLL_NVAL) {\n-            printf(\"PR_POLL_NVAL\\n\");\n-        }\n-\n-        if (PR_GetConnectStatus(&pd) == PR_SUCCESS) {\n-            printf(\"PR_GetConnectStatus: connect succeeded\\n\");\n-            PR_Write(sock, \"GET /\\r\\n\\r\\n\", 9);\n-            PR_Shutdown(sock, PR_SHUTDOWN_SEND);\n-            pd.in_flags = PR_POLL_READ;\n-            while (1) {\n-                n = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n-                printf(\"poll returns %d\\n\", n);\n-                n = PR_Read(sock, buf, sizeof(buf));\n-                printf(\"read returns %d\\n\", n);\n-                if (n <= 0) {\n-                    break;\n-                }\n-                PR_Write(PR_STDOUT, buf, n);\n-            }\n-        } else {\n-            if (PR_GetError() == PR_IN_PROGRESS_ERROR) {\n-                printf(\"PR_GetConnectStatus: connect still in progress\\n\");\n-                exit(1);\n-            }\n-            printf(\"PR_GetConnectStatus: connect failed: (%ld, %ld)\\n\", PR_GetError(),\n-                   PR_GetOSError());\n-        }\n-        PR_Close(sock);\n-        printf(\"PASS\\n\");\n-        return 0;\n+        PR_Write(PR_STDOUT, buf, n);\n+      }\n+    } else {\n+      if (PR_GetError() == PR_IN_PROGRESS_ERROR) {\n+        printf(\"PR_GetConnectStatus: connect still in progress\\n\");\n+        exit(1);\n+      }\n+      printf(\"PR_GetConnectStatus: connect failed: (%ld, %ld)\\n\", PR_GetError(),\n+             PR_GetOSError());\n     }\n+    PR_Close(sock);\n+    printf(\"PASS\\n\");\n+    return 0;\n+  }\n }\n \n /*\n@@ -179,340 +177,334 @@ main(int argc, char** argv)\n  *    Server Thread\n  *    Accept a connection from the client and write some data\n  */\n-static void PR_CALLBACK\n-TCP_Server(void* arg)\n-{\n-    Server_Param* sp = (Server_Param*)arg;\n-    PRFileDesc *sockfd, *newsockfd;\n-    char data_buf[DATA_BUF_SIZE];\n-    PRIntn rv, bytes_read;\n+static void PR_CALLBACK TCP_Server(void* arg) {\n+  Server_Param* sp = (Server_Param*)arg;\n+  PRFileDesc *sockfd, *newsockfd;\n+  char data_buf[DATA_BUF_SIZE];\n+  PRIntn rv, bytes_read;\n \n-    sockfd = sp->sp_fd;\n-    if ((newsockfd = PR_Accept(sockfd, NULL, PR_INTERVAL_NO_TIMEOUT)) == NULL) {\n-        fprintf(stderr, \"ERROR - PR_Accept failed: (%d,%d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        return;\n-    }\n-    bytes_read = 0;\n-    while (bytes_read != DATA_BUF_SIZE) {\n-        rv = PR_Read(newsockfd, data_buf + bytes_read, DATA_BUF_SIZE - bytes_read);\n-        if (rv < 0) {\n-            fprintf(stderr, \"Error - PR_Read failed: (%d, %d)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            PR_Close(newsockfd);\n-            return;\n-        }\n-        PR_ASSERT(rv != 0);\n-        bytes_read += rv;\n-    }\n-    DPRINTF((\"Bytes read from client - %d\\n\", bytes_read));\n-    rv = PR_Write(newsockfd, data_buf, DATA_BUF_SIZE);\n+  sockfd = sp->sp_fd;\n+  if ((newsockfd = PR_Accept(sockfd, NULL, PR_INTERVAL_NO_TIMEOUT)) == NULL) {\n+    fprintf(stderr, \"ERROR - PR_Accept failed: (%d,%d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    return;\n+  }\n+  bytes_read = 0;\n+  while (bytes_read != DATA_BUF_SIZE) {\n+    rv = PR_Read(newsockfd, data_buf + bytes_read, DATA_BUF_SIZE - bytes_read);\n     if (rv < 0) {\n-        fprintf(stderr, \"Error - PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        PR_Close(newsockfd);\n-        return;\n+      fprintf(stderr, \"Error - PR_Read failed: (%d, %d)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      PR_Close(newsockfd);\n+      return;\n     }\n-    PR_ASSERT(rv == DATA_BUF_SIZE);\n-    DPRINTF((\"Bytes written to client - %d\\n\", rv));\n+    PR_ASSERT(rv != 0);\n+    bytes_read += rv;\n+  }\n+  DPRINTF((\"Bytes read from client - %d\\n\", bytes_read));\n+  rv = PR_Write(newsockfd, data_buf, DATA_BUF_SIZE);\n+  if (rv < 0) {\n+    fprintf(stderr, \"Error - PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n     PR_Close(newsockfd);\n+    return;\n+  }\n+  PR_ASSERT(rv == DATA_BUF_SIZE);\n+  DPRINTF((\"Bytes written to client - %d\\n\", rv));\n+  PR_Close(newsockfd);\n }\n \n /*\n  * test for successful connection using a non-blocking socket\n  */\n-static PRIntn\n-connection_success_test()\n-{\n-    PRFileDesc *sockfd = NULL, *conn_fd = NULL;\n-    PRNetAddr netaddr;\n-    PRInt32 i, rv;\n-    PRPollDesc pd;\n-    PRSocketOptionData optData;\n-    PRThread* thr = NULL;\n-    Server_Param sp;\n-    char send_buf[DATA_BUF_SIZE], recv_buf[DATA_BUF_SIZE];\n-    PRIntn default_case, n, bytes_read, bytes_sent;\n-    PRIntn failed_already = 0;\n+static PRIntn connection_success_test() {\n+  PRFileDesc *sockfd = NULL, *conn_fd = NULL;\n+  PRNetAddr netaddr;\n+  PRInt32 i, rv;\n+  PRPollDesc pd;\n+  PRSocketOptionData optData;\n+  PRThread* thr = NULL;\n+  Server_Param sp;\n+  char send_buf[DATA_BUF_SIZE], recv_buf[DATA_BUF_SIZE];\n+  PRIntn default_case, n, bytes_read, bytes_sent;\n+  PRIntn failed_already = 0;\n \n-    /*\n-     * Create a tcp socket\n-     */\n-    if ((sockfd = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Error - PR_NewTCPSocket failed\\n\");\n-        failed_already = 1;\n-        goto def_exit;\n+  /*\n+   * Create a tcp socket\n+   */\n+  if ((sockfd = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Error - PR_NewTCPSocket failed\\n\");\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n+  memset(&netaddr, 0, sizeof(netaddr));\n+  netaddr.inet.family = PR_AF_INET;\n+  netaddr.inet.port = PR_htons(TCP_SERVER_PORT);\n+  netaddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  /*\n+   * try a few times to bind server's address, if addresses are in\n+   * use\n+   */\n+  i = 0;\n+  while (PR_Bind(sockfd, &netaddr) < 0) {\n+    if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n+      netaddr.inet.port += 2;\n+      if (i++ < SERVER_MAX_BIND_COUNT) {\n+        continue;\n+      }\n+    }\n+    fprintf(stderr, \"ERROR - PR_Bind failed: (%d,%d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n+\n+  if (PR_Listen(sockfd, 32) < 0) {\n+    fprintf(stderr, \"ERROR - PR_Listen failed: (%d,%d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n+\n+  if (PR_GetSockName(sockfd, &netaddr) < 0) {\n+    fprintf(stderr, \"ERROR - PR_GetSockName failed: (%d,%d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n+  if ((conn_fd = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Error - PR_NewTCPSocket failed\\n\");\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n+  optData.option = PR_SockOpt_Nonblocking;\n+  optData.value.non_blocking = PR_TRUE;\n+  PR_SetSocketOption(conn_fd, &optData);\n+  rv = PR_Connect(conn_fd, &netaddr, PR_INTERVAL_NO_TIMEOUT);\n+  if (rv == PR_FAILURE) {\n+    if (PR_GetError() == PR_IN_PROGRESS_ERROR) {\n+      DPRINTF((\"Connect in progress\\n\"));\n+    } else {\n+      fprintf(stderr, \"Error - PR_Connect failed: (%d, %d)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      failed_already = 1;\n+      goto def_exit;\n     }\n-    memset(&netaddr, 0, sizeof(netaddr));\n-    netaddr.inet.family = PR_AF_INET;\n-    netaddr.inet.port = PR_htons(TCP_SERVER_PORT);\n-    netaddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  }\n+  /*\n+   * Now create a thread to accept a connection\n+   */\n+  sp.sp_fd = sockfd;\n+  thr = PR_CreateThread(PR_USER_THREAD, TCP_Server, (void*)&sp,\n+                        PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_JOINABLE_THREAD,\n+                        0);\n+  if (thr == NULL) {\n+    fprintf(stderr, \"Error - PR_CreateThread failed: (%d,%d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n+  DPRINTF((\"Created TCP_Server thread [0x%x]\\n\", thr));\n+  pd.fd = conn_fd;\n+  pd.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;\n+  n = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n+  if (n == -1) {\n+    fprintf(stderr, \"Error - PR_Poll failed: (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n+  if (PR_GetConnectStatus(&pd) == PR_SUCCESS) {\n+    PRInt32 rv;\n+\n+    DPRINTF((\"Connection successful\\n\"));\n+\n     /*\n-     * try a few times to bind server's address, if addresses are in\n-     * use\n+     * Write some data, read it back and check data integrity to\n+     * make sure the connection is good\n      */\n-    i = 0;\n-    while (PR_Bind(sockfd, &netaddr) < 0) {\n-        if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n-            netaddr.inet.port += 2;\n-            if (i++ < SERVER_MAX_BIND_COUNT) {\n-                continue;\n-            }\n-        }\n-        fprintf(stderr, \"ERROR - PR_Bind failed: (%d,%d)\\n\", PR_GetError(),\n+    pd.in_flags = PR_POLL_WRITE;\n+    bytes_sent = 0;\n+    memset(send_buf, 'a', DATA_BUF_SIZE);\n+    while (bytes_sent != DATA_BUF_SIZE) {\n+      rv = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n+      if (rv < 0) {\n+        fprintf(stderr, \"Error - PR_Poll failed: (%d, %d)\\n\", PR_GetError(),\n                 PR_GetOSError());\n         failed_already = 1;\n         goto def_exit;\n-    }\n-\n-    if (PR_Listen(sockfd, 32) < 0) {\n-        fprintf(stderr, \"ERROR - PR_Listen failed: (%d,%d)\\n\", PR_GetError(),\n+      }\n+      PR_ASSERT((rv == 1) && (pd.out_flags == PR_POLL_WRITE));\n+      rv = PR_Write(conn_fd, send_buf + bytes_sent, DATA_BUF_SIZE - bytes_sent);\n+      if (rv < 0) {\n+        fprintf(stderr, \"Error - PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n                 PR_GetOSError());\n         failed_already = 1;\n         goto def_exit;\n+      }\n+      PR_ASSERT(rv > 0);\n+      bytes_sent += rv;\n     }\n-\n-    if (PR_GetSockName(sockfd, &netaddr) < 0) {\n-        fprintf(stderr, \"ERROR - PR_GetSockName failed: (%d,%d)\\n\", PR_GetError(),\n+    DPRINTF((\"Bytes written to server - %d\\n\", bytes_sent));\n+    PR_Shutdown(conn_fd, PR_SHUTDOWN_SEND);\n+    pd.in_flags = PR_POLL_READ;\n+    bytes_read = 0;\n+    memset(recv_buf, 0, DATA_BUF_SIZE);\n+    while (bytes_read != DATA_BUF_SIZE) {\n+      rv = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n+      if (rv < 0) {\n+        fprintf(stderr, \"Error - PR_Poll failed: (%d, %d)\\n\", PR_GetError(),\n                 PR_GetOSError());\n         failed_already = 1;\n         goto def_exit;\n-    }\n-    if ((conn_fd = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Error - PR_NewTCPSocket failed\\n\");\n+      }\n+      PR_ASSERT((rv == 1) && (pd.out_flags == PR_POLL_READ));\n+      rv = PR_Read(conn_fd, recv_buf + bytes_read, DATA_BUF_SIZE - bytes_read);\n+      if (rv < 0) {\n+        fprintf(stderr, \"Error - PR_Read failed: (%d, %d)\\n\", PR_GetError(),\n+                PR_GetOSError());\n         failed_already = 1;\n         goto def_exit;\n+      }\n+      PR_ASSERT(rv != 0);\n+      bytes_read += rv;\n     }\n-    optData.option = PR_SockOpt_Nonblocking;\n-    optData.value.non_blocking = PR_TRUE;\n-    PR_SetSocketOption(conn_fd, &optData);\n-    rv = PR_Connect(conn_fd, &netaddr, PR_INTERVAL_NO_TIMEOUT);\n-    if (rv == PR_FAILURE) {\n-        if (PR_GetError() == PR_IN_PROGRESS_ERROR) {\n-            DPRINTF((\"Connect in progress\\n\"));\n-        } else {\n-            fprintf(stderr, \"Error - PR_Connect failed: (%d, %d)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            failed_already = 1;\n-            goto def_exit;\n-        }\n-    }\n+    DPRINTF((\"Bytes read from server - %d\\n\", bytes_read));\n     /*\n-     * Now create a thread to accept a connection\n+     * verify the data read\n      */\n-    sp.sp_fd = sockfd;\n-    thr = PR_CreateThread(PR_USER_THREAD, TCP_Server, (void*)&sp,\n-                          PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_JOINABLE_THREAD,\n-                          0);\n-    if (thr == NULL) {\n-        fprintf(stderr, \"Error - PR_CreateThread failed: (%d,%d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        failed_already = 1;\n-        goto def_exit;\n-    }\n-    DPRINTF((\"Created TCP_Server thread [0x%x]\\n\", thr));\n-    pd.fd = conn_fd;\n-    pd.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;\n-    n = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n-    if (n == -1) {\n-        fprintf(stderr, \"Error - PR_Poll failed: (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        failed_already = 1;\n-        goto def_exit;\n-    }\n-    if (PR_GetConnectStatus(&pd) == PR_SUCCESS) {\n-        PRInt32 rv;\n-\n-        DPRINTF((\"Connection successful\\n\"));\n-\n-        /*\n-         * Write some data, read it back and check data integrity to\n-         * make sure the connection is good\n-         */\n-        pd.in_flags = PR_POLL_WRITE;\n-        bytes_sent = 0;\n-        memset(send_buf, 'a', DATA_BUF_SIZE);\n-        while (bytes_sent != DATA_BUF_SIZE) {\n-            rv = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n-            if (rv < 0) {\n-                fprintf(stderr, \"Error - PR_Poll failed: (%d, %d)\\n\", PR_GetError(),\n-                        PR_GetOSError());\n-                failed_already = 1;\n-                goto def_exit;\n-            }\n-            PR_ASSERT((rv == 1) && (pd.out_flags == PR_POLL_WRITE));\n-            rv = PR_Write(conn_fd, send_buf + bytes_sent, DATA_BUF_SIZE - bytes_sent);\n-            if (rv < 0) {\n-                fprintf(stderr, \"Error - PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n-                        PR_GetOSError());\n-                failed_already = 1;\n-                goto def_exit;\n-            }\n-            PR_ASSERT(rv > 0);\n-            bytes_sent += rv;\n-        }\n-        DPRINTF((\"Bytes written to server - %d\\n\", bytes_sent));\n-        PR_Shutdown(conn_fd, PR_SHUTDOWN_SEND);\n-        pd.in_flags = PR_POLL_READ;\n-        bytes_read = 0;\n-        memset(recv_buf, 0, DATA_BUF_SIZE);\n-        while (bytes_read != DATA_BUF_SIZE) {\n-            rv = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n-            if (rv < 0) {\n-                fprintf(stderr, \"Error - PR_Poll failed: (%d, %d)\\n\", PR_GetError(),\n-                        PR_GetOSError());\n-                failed_already = 1;\n-                goto def_exit;\n-            }\n-            PR_ASSERT((rv == 1) && (pd.out_flags == PR_POLL_READ));\n-            rv = PR_Read(conn_fd, recv_buf + bytes_read, DATA_BUF_SIZE - bytes_read);\n-            if (rv < 0) {\n-                fprintf(stderr, \"Error - PR_Read failed: (%d, %d)\\n\", PR_GetError(),\n-                        PR_GetOSError());\n-                failed_already = 1;\n-                goto def_exit;\n-            }\n-            PR_ASSERT(rv != 0);\n-            bytes_read += rv;\n-        }\n-        DPRINTF((\"Bytes read from server - %d\\n\", bytes_read));\n-        /*\n-         * verify the data read\n-         */\n-        if (memcmp(send_buf, recv_buf, DATA_BUF_SIZE) != 0) {\n-            fprintf(stderr, \"ERROR - data corruption\\n\");\n-            failed_already = 1;\n-            goto def_exit;\n-        }\n-        DPRINTF((\"Data integrity verified\\n\"));\n-    } else {\n-        fprintf(stderr, \"PR_GetConnectStatus: connect failed: (%ld, %ld)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        failed_already = 1;\n-        goto def_exit;\n+    if (memcmp(send_buf, recv_buf, DATA_BUF_SIZE) != 0) {\n+      fprintf(stderr, \"ERROR - data corruption\\n\");\n+      failed_already = 1;\n+      goto def_exit;\n     }\n+    DPRINTF((\"Data integrity verified\\n\"));\n+  } else {\n+    fprintf(stderr, \"PR_GetConnectStatus: connect failed: (%ld, %ld)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n def_exit:\n-    if (thr) {\n-        PR_JoinThread(thr);\n-        thr = NULL;\n-    }\n-    if (sockfd) {\n-        PR_Close(sockfd);\n-        sockfd = NULL;\n-    }\n-    if (conn_fd) {\n-        PR_Close(conn_fd);\n-        conn_fd = NULL;\n-    }\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (thr) {\n+    PR_JoinThread(thr);\n+    thr = NULL;\n+  }\n+  if (sockfd) {\n+    PR_Close(sockfd);\n+    sockfd = NULL;\n+  }\n+  if (conn_fd) {\n+    PR_Close(conn_fd);\n+    conn_fd = NULL;\n+  }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\n \n /*\n  * test for connection to a nonexistent port using a non-blocking socket\n  */\n-static PRIntn\n-connection_failure_test()\n-{\n-    PRFileDesc *sockfd = NULL, *conn_fd = NULL;\n-    PRNetAddr netaddr;\n-    PRInt32 i, rv;\n-    PRPollDesc pd;\n-    PRSocketOptionData optData;\n-    PRIntn n, failed_already = 0;\n+static PRIntn connection_failure_test() {\n+  PRFileDesc *sockfd = NULL, *conn_fd = NULL;\n+  PRNetAddr netaddr;\n+  PRInt32 i, rv;\n+  PRPollDesc pd;\n+  PRSocketOptionData optData;\n+  PRIntn n, failed_already = 0;\n \n-    /*\n-     * Create a tcp socket\n-     */\n-    if ((sockfd = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Error - PR_NewTCPSocket failed\\n\");\n-        failed_already = 1;\n-        goto def_exit;\n-    }\n-    memset(&netaddr, 0, sizeof(netaddr));\n-    netaddr.inet.family = PR_AF_INET;\n-    netaddr.inet.port = PR_htons(TCP_SERVER_PORT);\n-    netaddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    /*\n-     * try a few times to bind server's address, if addresses are in\n-     * use\n-     */\n-    i = 0;\n-    while (PR_Bind(sockfd, &netaddr) < 0) {\n-        if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n-            netaddr.inet.port += 2;\n-            if (i++ < SERVER_MAX_BIND_COUNT) {\n-                continue;\n-            }\n-        }\n-        fprintf(stderr, \"ERROR - PR_Bind failed: (%d,%d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        failed_already = 1;\n-        goto def_exit;\n+  /*\n+   * Create a tcp socket\n+   */\n+  if ((sockfd = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Error - PR_NewTCPSocket failed\\n\");\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n+  memset(&netaddr, 0, sizeof(netaddr));\n+  netaddr.inet.family = PR_AF_INET;\n+  netaddr.inet.port = PR_htons(TCP_SERVER_PORT);\n+  netaddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  /*\n+   * try a few times to bind server's address, if addresses are in\n+   * use\n+   */\n+  i = 0;\n+  while (PR_Bind(sockfd, &netaddr) < 0) {\n+    if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n+      netaddr.inet.port += 2;\n+      if (i++ < SERVER_MAX_BIND_COUNT) {\n+        continue;\n+      }\n     }\n+    fprintf(stderr, \"ERROR - PR_Bind failed: (%d,%d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n \n-    if (PR_GetSockName(sockfd, &netaddr) < 0) {\n-        fprintf(stderr, \"ERROR - PR_GetSockName failed: (%d,%d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        failed_already = 1;\n-        goto def_exit;\n-    }\n+  if (PR_GetSockName(sockfd, &netaddr) < 0) {\n+    fprintf(stderr, \"ERROR - PR_GetSockName failed: (%d,%d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n #ifdef AIX\n-    /*\n-     * On AIX, set to unused/reserved port\n-     */\n-    netaddr.inet.port = PR_htons(TCP_UNUSED_PORT);\n+  /*\n+   * On AIX, set to unused/reserved port\n+   */\n+  netaddr.inet.port = PR_htons(TCP_UNUSED_PORT);\n #endif\n-    if ((conn_fd = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Error - PR_NewTCPSocket failed\\n\");\n-        failed_already = 1;\n-        goto def_exit;\n-    }\n-    optData.option = PR_SockOpt_Nonblocking;\n-    optData.value.non_blocking = PR_TRUE;\n-    PR_SetSocketOption(conn_fd, &optData);\n-    rv = PR_Connect(conn_fd, &netaddr, PR_INTERVAL_NO_TIMEOUT);\n-    if (rv == PR_FAILURE) {\n-        DPRINTF((\"PR_Connect to a non-listen port failed: (%d, %d)\\n\",\n-                 PR_GetError(), PR_GetOSError()));\n-    } else {\n-        PR_ASSERT(rv == PR_SUCCESS);\n-        fprintf(stderr, \"Error - PR_Connect succeeded, expected to fail\\n\");\n-        failed_already = 1;\n-        goto def_exit;\n-    }\n-    pd.fd = conn_fd;\n-    pd.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;\n-    n = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n-    if (n == -1) {\n-        fprintf(stderr, \"Error - PR_Poll failed: (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        failed_already = 1;\n-        goto def_exit;\n-    }\n-    if (PR_GetConnectStatus(&pd) == PR_SUCCESS) {\n-        PRInt32 rv;\n-        fprintf(stderr, \"PR_GetConnectStatus succeeded, expected to fail\\n\");\n-        failed_already = 1;\n-        goto def_exit;\n-    }\n-    rv = PR_GetError();\n-    DPRINTF((\"Connection failed, successfully with PR_Error %d\\n\", rv));\n+  if ((conn_fd = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Error - PR_NewTCPSocket failed\\n\");\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n+  optData.option = PR_SockOpt_Nonblocking;\n+  optData.value.non_blocking = PR_TRUE;\n+  PR_SetSocketOption(conn_fd, &optData);\n+  rv = PR_Connect(conn_fd, &netaddr, PR_INTERVAL_NO_TIMEOUT);\n+  if (rv == PR_FAILURE) {\n+    DPRINTF((\"PR_Connect to a non-listen port failed: (%d, %d)\\n\",\n+             PR_GetError(), PR_GetOSError()));\n+  } else {\n+    PR_ASSERT(rv == PR_SUCCESS);\n+    fprintf(stderr, \"Error - PR_Connect succeeded, expected to fail\\n\");\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n+  pd.fd = conn_fd;\n+  pd.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;\n+  n = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n+  if (n == -1) {\n+    fprintf(stderr, \"Error - PR_Poll failed: (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n+  if (PR_GetConnectStatus(&pd) == PR_SUCCESS) {\n+    PRInt32 rv;\n+    fprintf(stderr, \"PR_GetConnectStatus succeeded, expected to fail\\n\");\n+    failed_already = 1;\n+    goto def_exit;\n+  }\n+  rv = PR_GetError();\n+  DPRINTF((\"Connection failed, successfully with PR_Error %d\\n\", rv));\n def_exit:\n-    if (sockfd) {\n-        PR_Close(sockfd);\n-        sockfd = NULL;\n-    }\n-    if (conn_fd) {\n-        PR_Close(conn_fd);\n-        conn_fd = NULL;\n-    }\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (sockfd) {\n+    PR_Close(sockfd);\n+    sockfd = NULL;\n+  }\n+  if (conn_fd) {\n+    PR_Close(conn_fd);\n+    conn_fd = NULL;\n+  }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/nblayer.c b/nspr/pr/tests/nblayer.c\nindex 2ae9f7b..ab26b0b 100644\n--- a/nspr/pr/tests/nblayer.c\n+++ b/nspr/pr/tests/nblayer.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -35,709 +36,680 @@ static PRNetAddr server_address;\n \n static PRIOMethods myMethods;\n \n-typedef enum { rcv_get_debit,\n-               rcv_send_credit,\n-               rcv_data } RcvState;\n-typedef enum { xmt_send_debit,\n-               xmt_recv_credit,\n-               xmt_data } XmtState;\n+typedef enum { rcv_get_debit, rcv_send_credit, rcv_data } RcvState;\n+typedef enum { xmt_send_debit, xmt_recv_credit, xmt_data } XmtState;\n \n struct PRFilePrivate {\n-    RcvState rcvstate;\n-    XmtState xmtstate;\n-    PRInt32 rcvreq, rcvinprogress;\n-    PRInt32 xmtreq, xmtinprogress;\n+  RcvState rcvstate;\n+  XmtState xmtstate;\n+  PRInt32 rcvreq, rcvinprogress;\n+  PRInt32 xmtreq, xmtinprogress;\n };\n \n-typedef enum Verbosity { silent,\n-                         quiet,\n-                         chatty,\n-                         noisy } Verbosity;\n+typedef enum Verbosity { silent, quiet, chatty, noisy } Verbosity;\n \n static PRIntn minor_iterations = 5;\n static PRIntn major_iterations = 1;\n static Verbosity verbosity = quiet;\n \n #ifdef DEBUG\n-#define PORT_INC_DO +100\n+#  define PORT_INC_DO +100\n #else\n-#define PORT_INC_DO\n+#  define PORT_INC_DO\n #endif\n #ifdef IS_64\n-#define PORT_INC_3264 +200\n+#  define PORT_INC_3264 +200\n #else\n-#define PORT_INC_3264\n+#  define PORT_INC_3264\n #endif\n \n static PRUint16 default_port = 12273 PORT_INC_DO PORT_INC_3264;\n \n-static PRFileDesc*\n-PushLayer(PRFileDesc* stack)\n-{\n-    PRStatus rv;\n-    PRFileDesc* layer = PR_CreateIOLayerStub(identity, &myMethods);\n-    layer->secret = PR_NEWZAP(PRFilePrivate);\n-    rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), layer);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    if (verbosity > quiet) {\n-        PR_fprintf(logFile, \"Pushed layer(0x%x) onto stack(0x%x)\\n\", layer, stack);\n-    }\n-    return stack;\n+static PRFileDesc* PushLayer(PRFileDesc* stack) {\n+  PRStatus rv;\n+  PRFileDesc* layer = PR_CreateIOLayerStub(identity, &myMethods);\n+  layer->secret = PR_NEWZAP(PRFilePrivate);\n+  rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), layer);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  if (verbosity > quiet) {\n+    PR_fprintf(logFile, \"Pushed layer(0x%x) onto stack(0x%x)\\n\", layer, stack);\n+  }\n+  return stack;\n } /* PushLayer */\n \n-static PRFileDesc*\n-PopLayer(PRFileDesc* stack)\n-{\n-    PRFileDesc* popped = PR_PopIOLayer(stack, identity);\n-    if (verbosity > quiet) {\n-        PR_fprintf(logFile, \"Popped layer(0x%x) from stack(0x%x)\\n\", popped, stack);\n-    }\n-    PR_DELETE(popped->secret);\n-    popped->dtor(popped);\n-    return stack;\n+static PRFileDesc* PopLayer(PRFileDesc* stack) {\n+  PRFileDesc* popped = PR_PopIOLayer(stack, identity);\n+  if (verbosity > quiet) {\n+    PR_fprintf(logFile, \"Popped layer(0x%x) from stack(0x%x)\\n\", popped, stack);\n+  }\n+  PR_DELETE(popped->secret);\n+  popped->dtor(popped);\n+  return stack;\n } /* PopLayer */\n \n-static void PR_CALLBACK\n-Client(void* arg)\n-{\n-    PRStatus rv;\n-    PRIntn mits;\n-    PRInt32 ready;\n-    PRUint8 buffer[100];\n-    PRPollDesc polldesc;\n-    PRIntn empty_flags = 0;\n-    PRIntn bytes_read, bytes_sent;\n-    PRFileDesc* stack = (PRFileDesc*)arg;\n-\n-    /* Initialize the buffer so that Purify won't complain */\n-    memset(buffer, 0, sizeof(buffer));\n-\n-    rv = PR_Connect(stack, &server_address, PR_INTERVAL_NO_TIMEOUT);\n-    if ((PR_FAILURE == rv) && (PR_IN_PROGRESS_ERROR == PR_GetError())) {\n-        if (verbosity > quiet) {\n-            PR_fprintf(logFile, \"Client connect 'in progress'\\n\");\n-        }\n-        do {\n-            polldesc.fd = stack;\n-            polldesc.out_flags = 0;\n-            polldesc.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;\n-            ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);\n-            if ((1 != ready) /* if not 1, then we're dead */\n-                || (0 == (polldesc.in_flags & polldesc.out_flags))) {\n-                PR_NOT_REACHED(\"Whoa!\");\n-                break;\n-            }\n-            if (verbosity > quiet)\n-                PR_fprintf(logFile, \"Client connect 'in progress' [0x%x]\\n\",\n-                           polldesc.out_flags);\n-            rv = PR_GetConnectStatus(&polldesc);\n-            if ((PR_FAILURE == rv) && (PR_IN_PROGRESS_ERROR != PR_GetError())) {\n-                break;\n-            }\n-        } while (PR_FAILURE == rv);\n+static void PR_CALLBACK Client(void* arg) {\n+  PRStatus rv;\n+  PRIntn mits;\n+  PRInt32 ready;\n+  PRUint8 buffer[100];\n+  PRPollDesc polldesc;\n+  PRIntn empty_flags = 0;\n+  PRIntn bytes_read, bytes_sent;\n+  PRFileDesc* stack = (PRFileDesc*)arg;\n+\n+  /* Initialize the buffer so that Purify won't complain */\n+  memset(buffer, 0, sizeof(buffer));\n+\n+  rv = PR_Connect(stack, &server_address, PR_INTERVAL_NO_TIMEOUT);\n+  if ((PR_FAILURE == rv) && (PR_IN_PROGRESS_ERROR == PR_GetError())) {\n+    if (verbosity > quiet) {\n+      PR_fprintf(logFile, \"Client connect 'in progress'\\n\");\n     }\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    if (verbosity > chatty) {\n-        PR_fprintf(logFile, \"Client created connection\\n\");\n+    do {\n+      polldesc.fd = stack;\n+      polldesc.out_flags = 0;\n+      polldesc.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;\n+      ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);\n+      if ((1 != ready) /* if not 1, then we're dead */\n+          || (0 == (polldesc.in_flags & polldesc.out_flags))) {\n+        PR_NOT_REACHED(\"Whoa!\");\n+        break;\n+      }\n+      if (verbosity > quiet)\n+        PR_fprintf(logFile, \"Client connect 'in progress' [0x%x]\\n\",\n+                   polldesc.out_flags);\n+      rv = PR_GetConnectStatus(&polldesc);\n+      if ((PR_FAILURE == rv) && (PR_IN_PROGRESS_ERROR != PR_GetError())) {\n+        break;\n+      }\n+    } while (PR_FAILURE == rv);\n+  }\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  if (verbosity > chatty) {\n+    PR_fprintf(logFile, \"Client created connection\\n\");\n+  }\n+\n+  for (mits = 0; mits < minor_iterations; ++mits) {\n+    bytes_sent = 0;\n+    if (verbosity > quiet) {\n+      PR_fprintf(logFile, \"Client sending %d bytes\\n\", sizeof(buffer));\n     }\n-\n-    for (mits = 0; mits < minor_iterations; ++mits) {\n-        bytes_sent = 0;\n-        if (verbosity > quiet) {\n-            PR_fprintf(logFile, \"Client sending %d bytes\\n\", sizeof(buffer));\n+    do {\n+      if (verbosity > chatty)\n+        PR_fprintf(logFile, \"Client sending %d bytes\\n\",\n+                   sizeof(buffer) - bytes_sent);\n+      ready = PR_Send(stack, buffer + bytes_sent, sizeof(buffer) - bytes_sent,\n+                      empty_flags, PR_INTERVAL_NO_TIMEOUT);\n+      if (verbosity > chatty) {\n+        PR_fprintf(logFile, \"Client send status [%d]\\n\", ready);\n+      }\n+      if (0 < ready) {\n+        bytes_sent += ready;\n+      } else if ((-1 == ready) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n+        polldesc.fd = stack;\n+        polldesc.out_flags = 0;\n+        polldesc.in_flags = PR_POLL_WRITE;\n+        ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);\n+        if ((1 != ready) /* if not 1, then we're dead */\n+            || (0 == (polldesc.in_flags & polldesc.out_flags))) {\n+          PR_NOT_REACHED(\"Whoa!\");\n+          break;\n         }\n-        do {\n-            if (verbosity > chatty)\n-                PR_fprintf(logFile, \"Client sending %d bytes\\n\",\n-                           sizeof(buffer) - bytes_sent);\n-            ready = PR_Send(stack, buffer + bytes_sent, sizeof(buffer) - bytes_sent,\n-                            empty_flags, PR_INTERVAL_NO_TIMEOUT);\n-            if (verbosity > chatty) {\n-                PR_fprintf(logFile, \"Client send status [%d]\\n\", ready);\n-            }\n-            if (0 < ready) {\n-                bytes_sent += ready;\n-            } else if ((-1 == ready) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n-                polldesc.fd = stack;\n-                polldesc.out_flags = 0;\n-                polldesc.in_flags = PR_POLL_WRITE;\n-                ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);\n-                if ((1 != ready) /* if not 1, then we're dead */\n-                    || (0 == (polldesc.in_flags & polldesc.out_flags))) {\n-                    PR_NOT_REACHED(\"Whoa!\");\n-                    break;\n-                }\n-            } else {\n-                break;\n-            }\n-        } while (bytes_sent < sizeof(buffer));\n-        PR_ASSERT(sizeof(buffer) == bytes_sent);\n-\n-        bytes_read = 0;\n-        do {\n-            if (verbosity > chatty)\n-                PR_fprintf(logFile, \"Client receiving %d bytes\\n\",\n-                           bytes_sent - bytes_read);\n-            ready = PR_Recv(stack, buffer + bytes_read, bytes_sent - bytes_read,\n-                            empty_flags, PR_INTERVAL_NO_TIMEOUT);\n-            if (verbosity > chatty)\n-                PR_fprintf(logFile, \"Client receive status [%d]\\n\", ready);\n-            if (0 < ready) {\n-                bytes_read += ready;\n-            } else if ((-1 == ready) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n-                polldesc.fd = stack;\n-                polldesc.out_flags = 0;\n-                polldesc.in_flags = PR_POLL_READ;\n-                ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);\n-                if ((1 != ready) /* if not 1, then we're dead */\n-                    || (0 == (polldesc.in_flags & polldesc.out_flags))) {\n-                    PR_NOT_REACHED(\"Whoa!\");\n-                    break;\n-                }\n-            } else {\n-                break;\n-            }\n-        } while (bytes_read < bytes_sent);\n-        if (verbosity > chatty) {\n-            PR_fprintf(logFile, \"Client received %d bytes\\n\", bytes_read);\n+      } else {\n+        break;\n+      }\n+    } while (bytes_sent < sizeof(buffer));\n+    PR_ASSERT(sizeof(buffer) == bytes_sent);\n+\n+    bytes_read = 0;\n+    do {\n+      if (verbosity > chatty)\n+        PR_fprintf(logFile, \"Client receiving %d bytes\\n\",\n+                   bytes_sent - bytes_read);\n+      ready = PR_Recv(stack, buffer + bytes_read, bytes_sent - bytes_read,\n+                      empty_flags, PR_INTERVAL_NO_TIMEOUT);\n+      if (verbosity > chatty)\n+        PR_fprintf(logFile, \"Client receive status [%d]\\n\", ready);\n+      if (0 < ready) {\n+        bytes_read += ready;\n+      } else if ((-1 == ready) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n+        polldesc.fd = stack;\n+        polldesc.out_flags = 0;\n+        polldesc.in_flags = PR_POLL_READ;\n+        ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);\n+        if ((1 != ready) /* if not 1, then we're dead */\n+            || (0 == (polldesc.in_flags & polldesc.out_flags))) {\n+          PR_NOT_REACHED(\"Whoa!\");\n+          break;\n         }\n-        PR_ASSERT(bytes_read == bytes_sent);\n+      } else {\n+        break;\n+      }\n+    } while (bytes_read < bytes_sent);\n+    if (verbosity > chatty) {\n+      PR_fprintf(logFile, \"Client received %d bytes\\n\", bytes_read);\n     }\n+    PR_ASSERT(bytes_read == bytes_sent);\n+  }\n \n-    if (verbosity > quiet) {\n-        PR_fprintf(logFile, \"Client shutting down stack\\n\");\n-    }\n+  if (verbosity > quiet) {\n+    PR_fprintf(logFile, \"Client shutting down stack\\n\");\n+  }\n \n-    rv = PR_Shutdown(stack, PR_SHUTDOWN_BOTH);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+  rv = PR_Shutdown(stack, PR_SHUTDOWN_BOTH);\n+  PR_ASSERT(PR_SUCCESS == rv);\n } /* Client */\n \n-static void PR_CALLBACK\n-Server(void* arg)\n-{\n-    PRStatus rv;\n-    PRInt32 ready;\n-    PRUint8 buffer[100];\n-    PRFileDesc* service;\n-    PRUintn empty_flags = 0;\n-    struct PRPollDesc polldesc;\n-    PRIntn bytes_read, bytes_sent;\n-    PRFileDesc* stack = (PRFileDesc*)arg;\n-    PRNetAddr client_address;\n+static void PR_CALLBACK Server(void* arg) {\n+  PRStatus rv;\n+  PRInt32 ready;\n+  PRUint8 buffer[100];\n+  PRFileDesc* service;\n+  PRUintn empty_flags = 0;\n+  struct PRPollDesc polldesc;\n+  PRIntn bytes_read, bytes_sent;\n+  PRFileDesc* stack = (PRFileDesc*)arg;\n+  PRNetAddr client_address;\n+\n+  do {\n+    if (verbosity > chatty) {\n+      PR_fprintf(logFile, \"Server accepting connection\\n\");\n+    }\n+    service = PR_Accept(stack, &client_address, PR_INTERVAL_NO_TIMEOUT);\n+    if (verbosity > chatty) {\n+      PR_fprintf(logFile, \"Server accept status [0x%p]\\n\", service);\n+    }\n+    if ((NULL == service) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n+      polldesc.fd = stack;\n+      polldesc.out_flags = 0;\n+      polldesc.in_flags = PR_POLL_READ | PR_POLL_EXCEPT;\n+      ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);\n+      if ((1 != ready) /* if not 1, then we're dead */\n+          || (0 == (polldesc.in_flags & polldesc.out_flags))) {\n+        PR_NOT_REACHED(\"Whoa!\");\n+        break;\n+      }\n+    }\n+  } while (NULL == service);\n+  PR_ASSERT(NULL != service);\n+\n+  if (verbosity > quiet) {\n+    PR_fprintf(logFile, \"Server accepting connection\\n\");\n+  }\n \n+  do {\n+    bytes_read = 0;\n     do {\n-        if (verbosity > chatty) {\n-            PR_fprintf(logFile, \"Server accepting connection\\n\");\n-        }\n-        service = PR_Accept(stack, &client_address, PR_INTERVAL_NO_TIMEOUT);\n-        if (verbosity > chatty) {\n-            PR_fprintf(logFile, \"Server accept status [0x%p]\\n\", service);\n+      if (verbosity > chatty)\n+        PR_fprintf(logFile, \"Server receiving %d bytes\\n\",\n+                   sizeof(buffer) - bytes_read);\n+      ready = PR_Recv(service, buffer + bytes_read, sizeof(buffer) - bytes_read,\n+                      empty_flags, PR_INTERVAL_NO_TIMEOUT);\n+      if (verbosity > chatty) {\n+        PR_fprintf(logFile, \"Server receive status [%d]\\n\", ready);\n+      }\n+      if (0 < ready) {\n+        bytes_read += ready;\n+      } else if ((-1 == ready) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n+        polldesc.fd = service;\n+        polldesc.out_flags = 0;\n+        polldesc.in_flags = PR_POLL_READ;\n+        ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);\n+        if ((1 != ready) /* if not 1, then we're dead */\n+            || (0 == (polldesc.in_flags & polldesc.out_flags))) {\n+          PR_NOT_REACHED(\"Whoa!\");\n+          break;\n         }\n-        if ((NULL == service) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n-            polldesc.fd = stack;\n-            polldesc.out_flags = 0;\n-            polldesc.in_flags = PR_POLL_READ | PR_POLL_EXCEPT;\n-            ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);\n-            if ((1 != ready) /* if not 1, then we're dead */\n-                || (0 == (polldesc.in_flags & polldesc.out_flags))) {\n-                PR_NOT_REACHED(\"Whoa!\");\n-                break;\n-            }\n+      } else {\n+        break;\n+      }\n+    } while (bytes_read < sizeof(buffer));\n+\n+    if (0 != bytes_read) {\n+      if (verbosity > chatty) {\n+        PR_fprintf(logFile, \"Server received %d bytes\\n\", bytes_read);\n+      }\n+      PR_ASSERT(bytes_read > 0);\n+\n+      bytes_sent = 0;\n+      do {\n+        ready = PR_Send(service, buffer + bytes_sent, bytes_read - bytes_sent,\n+                        empty_flags, PR_INTERVAL_NO_TIMEOUT);\n+        if (0 < ready) {\n+          bytes_sent += ready;\n+        } else if ((-1 == ready) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n+          polldesc.fd = service;\n+          polldesc.out_flags = 0;\n+          polldesc.in_flags = PR_POLL_WRITE;\n+          ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);\n+          if ((1 != ready) /* if not 1, then we're dead */\n+              || (0 == (polldesc.in_flags & polldesc.out_flags))) {\n+            PR_NOT_REACHED(\"Whoa!\");\n+            break;\n+          }\n+        } else {\n+          break;\n         }\n-    } while (NULL == service);\n-    PR_ASSERT(NULL != service);\n-\n-    if (verbosity > quiet) {\n-        PR_fprintf(logFile, \"Server accepting connection\\n\");\n+      } while (bytes_sent < bytes_read);\n+      PR_ASSERT(bytes_read == bytes_sent);\n+      if (verbosity > chatty) {\n+        PR_fprintf(logFile, \"Server sent %d bytes\\n\", bytes_sent);\n+      }\n     }\n+  } while (0 != bytes_read);\n \n-    do {\n-        bytes_read = 0;\n-        do {\n-            if (verbosity > chatty)\n-                PR_fprintf(logFile, \"Server receiving %d bytes\\n\",\n-                           sizeof(buffer) - bytes_read);\n-            ready = PR_Recv(service, buffer + bytes_read, sizeof(buffer) - bytes_read,\n-                            empty_flags, PR_INTERVAL_NO_TIMEOUT);\n-            if (verbosity > chatty) {\n-                PR_fprintf(logFile, \"Server receive status [%d]\\n\", ready);\n-            }\n-            if (0 < ready) {\n-                bytes_read += ready;\n-            } else if ((-1 == ready) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n-                polldesc.fd = service;\n-                polldesc.out_flags = 0;\n-                polldesc.in_flags = PR_POLL_READ;\n-                ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);\n-                if ((1 != ready) /* if not 1, then we're dead */\n-                    || (0 == (polldesc.in_flags & polldesc.out_flags))) {\n-                    PR_NOT_REACHED(\"Whoa!\");\n-                    break;\n-                }\n-            } else {\n-                break;\n-            }\n-        } while (bytes_read < sizeof(buffer));\n-\n-        if (0 != bytes_read) {\n-            if (verbosity > chatty) {\n-                PR_fprintf(logFile, \"Server received %d bytes\\n\", bytes_read);\n-            }\n-            PR_ASSERT(bytes_read > 0);\n-\n-            bytes_sent = 0;\n-            do {\n-                ready = PR_Send(service, buffer + bytes_sent, bytes_read - bytes_sent,\n-                                empty_flags, PR_INTERVAL_NO_TIMEOUT);\n-                if (0 < ready) {\n-                    bytes_sent += ready;\n-                } else if ((-1 == ready) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n-                    polldesc.fd = service;\n-                    polldesc.out_flags = 0;\n-                    polldesc.in_flags = PR_POLL_WRITE;\n-                    ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);\n-                    if ((1 != ready) /* if not 1, then we're dead */\n-                        || (0 == (polldesc.in_flags & polldesc.out_flags))) {\n-                        PR_NOT_REACHED(\"Whoa!\");\n-                        break;\n-                    }\n-                } else {\n-                    break;\n-                }\n-            } while (bytes_sent < bytes_read);\n-            PR_ASSERT(bytes_read == bytes_sent);\n-            if (verbosity > chatty) {\n-                PR_fprintf(logFile, \"Server sent %d bytes\\n\", bytes_sent);\n-            }\n-        }\n-    } while (0 != bytes_read);\n-\n-    if (verbosity > quiet) {\n-        PR_fprintf(logFile, \"Server shutting down stack\\n\");\n-    }\n-    rv = PR_Shutdown(service, PR_SHUTDOWN_BOTH);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    rv = PR_Close(service);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+  if (verbosity > quiet) {\n+    PR_fprintf(logFile, \"Server shutting down stack\\n\");\n+  }\n+  rv = PR_Shutdown(service, PR_SHUTDOWN_BOTH);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  rv = PR_Close(service);\n+  PR_ASSERT(PR_SUCCESS == rv);\n \n } /* Server */\n \n-static PRStatus PR_CALLBACK\n-MyClose(PRFileDesc* fd)\n-{\n-    PR_DELETE(fd->secret);                        /* manage my secret file object */\n-    return (PR_GetDefaultIOMethods())->close(fd); /* let him do all the work */\n+static PRStatus PR_CALLBACK MyClose(PRFileDesc* fd) {\n+  PR_DELETE(fd->secret); /* manage my secret file object */\n+  return (PR_GetDefaultIOMethods())->close(fd); /* let him do all the work */\n } /* MyClose */\n \n-static PRInt16 PR_CALLBACK\n-MyPoll(PRFileDesc* fd, PRInt16 in_flags,\n-       PRInt16* out_flags)\n-{\n-    PRInt16 my_flags, new_flags;\n-    PRFilePrivate* mine = (PRFilePrivate*)fd->secret;\n-    if (0 != (PR_POLL_READ & in_flags)) {\n-        /* client thinks he's reading */\n-        switch (mine->rcvstate) {\n-            case rcv_send_credit:\n-                my_flags = (in_flags & ~PR_POLL_READ) | PR_POLL_WRITE;\n-                break;\n-            case rcv_data:\n-            case rcv_get_debit:\n-                my_flags = in_flags;\n-            default:\n-                break;\n-        }\n-    } else if (0 != (PR_POLL_WRITE & in_flags)) {\n-        /* client thinks he's writing */\n-        switch (mine->xmtstate) {\n-            case xmt_recv_credit:\n-                my_flags = (in_flags & ~PR_POLL_WRITE) | PR_POLL_READ;\n-                break;\n-            case xmt_send_debit:\n-            case xmt_data:\n-                my_flags = in_flags;\n-            default:\n-                break;\n-        }\n-    } else {\n-        PR_NOT_REACHED(\"How'd I get here?\");\n-    }\n-    new_flags = (fd->lower->methods->poll)(fd->lower, my_flags, out_flags);\n-    if (verbosity > chatty)\n-        PR_fprintf(logFile, \"Poll [i: 0x%x, m: 0x%x, o: 0x%x, n: 0x%x]\\n\", in_flags,\n-                   my_flags, *out_flags, new_flags);\n-    return new_flags;\n-} /* MyPoll */\n-\n-static PRFileDesc* PR_CALLBACK\n-MyAccept(PRFileDesc* fd, PRNetAddr* addr,\n-         PRIntervalTime timeout)\n-{\n-    PRStatus rv;\n-    PRFileDesc *newfd, *layer = fd;\n-    PRFileDesc* newstack;\n-    PRFilePrivate* newsecret;\n-\n-    PR_ASSERT(fd != NULL);\n-    PR_ASSERT(fd->lower != NULL);\n-\n-    newstack = PR_NEW(PRFileDesc);\n-    if (NULL == newstack) {\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n-    }\n-    newsecret = PR_NEW(PRFilePrivate);\n-    if (NULL == newsecret) {\n-        PR_DELETE(newstack);\n-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n-        return NULL;\n+static PRInt16 PR_CALLBACK MyPoll(PRFileDesc* fd, PRInt16 in_flags,\n+                                  PRInt16* out_flags) {\n+  PRInt16 my_flags, new_flags;\n+  PRFilePrivate* mine = (PRFilePrivate*)fd->secret;\n+  if (0 != (PR_POLL_READ & in_flags)) {\n+    /* client thinks he's reading */\n+    switch (mine->rcvstate) {\n+      case rcv_send_credit:\n+        my_flags = (in_flags & ~PR_POLL_READ) | PR_POLL_WRITE;\n+        break;\n+      case rcv_data:\n+      case rcv_get_debit:\n+        my_flags = in_flags;\n+      default:\n+        break;\n     }\n-    *newstack = *fd; /* make a copy of the accepting layer */\n-    *newsecret = *fd->secret;\n-    newstack->secret = newsecret;\n-\n-    newfd = (fd->lower->methods->accept)(fd->lower, addr, timeout);\n-    if (NULL == newfd) {\n-        PR_DELETE(newsecret);\n-        PR_DELETE(newstack);\n-        return NULL;\n+  } else if (0 != (PR_POLL_WRITE & in_flags)) {\n+    /* client thinks he's writing */\n+    switch (mine->xmtstate) {\n+      case xmt_recv_credit:\n+        my_flags = (in_flags & ~PR_POLL_WRITE) | PR_POLL_READ;\n+        break;\n+      case xmt_send_debit:\n+      case xmt_data:\n+        my_flags = in_flags;\n+      default:\n+        break;\n     }\n+  } else {\n+    PR_NOT_REACHED(\"How'd I get here?\");\n+  }\n+  new_flags = (fd->lower->methods->poll)(fd->lower, my_flags, out_flags);\n+  if (verbosity > chatty)\n+    PR_fprintf(logFile, \"Poll [i: 0x%x, m: 0x%x, o: 0x%x, n: 0x%x]\\n\", in_flags,\n+               my_flags, *out_flags, new_flags);\n+  return new_flags;\n+} /* MyPoll */\n \n-    /* this PR_PushIOLayer call cannot fail */\n-    rv = PR_PushIOLayer(newfd, PR_TOP_IO_LAYER, newstack);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    return newfd; /* that's it */\n+static PRFileDesc* PR_CALLBACK MyAccept(PRFileDesc* fd, PRNetAddr* addr,\n+                                        PRIntervalTime timeout) {\n+  PRStatus rv;\n+  PRFileDesc *newfd, *layer = fd;\n+  PRFileDesc* newstack;\n+  PRFilePrivate* newsecret;\n+\n+  PR_ASSERT(fd != NULL);\n+  PR_ASSERT(fd->lower != NULL);\n+\n+  newstack = PR_NEW(PRFileDesc);\n+  if (NULL == newstack) {\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n+  newsecret = PR_NEW(PRFilePrivate);\n+  if (NULL == newsecret) {\n+    PR_DELETE(newstack);\n+    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);\n+    return NULL;\n+  }\n+  *newstack = *fd; /* make a copy of the accepting layer */\n+  *newsecret = *fd->secret;\n+  newstack->secret = newsecret;\n+\n+  newfd = (fd->lower->methods->accept)(fd->lower, addr, timeout);\n+  if (NULL == newfd) {\n+    PR_DELETE(newsecret);\n+    PR_DELETE(newstack);\n+    return NULL;\n+  }\n+\n+  /* this PR_PushIOLayer call cannot fail */\n+  rv = PR_PushIOLayer(newfd, PR_TOP_IO_LAYER, newstack);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  return newfd; /* that's it */\n }\n \n-static PRInt32 PR_CALLBACK\n-MyRecv(PRFileDesc* fd, void* buf, PRInt32 amount,\n-       PRIntn flags, PRIntervalTime timeout)\n-{\n-    char* b;\n-    PRInt32 rv;\n-    PRFileDesc* lo = fd->lower;\n-    PRFilePrivate* mine = (PRFilePrivate*)fd->secret;\n-\n-    do {\n-        switch (mine->rcvstate) {\n-            case rcv_get_debit:\n-                b = (char*)&mine->rcvreq;\n-                mine->rcvreq = amount;\n-                rv = lo->methods->recv(lo, b + mine->rcvinprogress,\n-                                       sizeof(mine->rcvreq) - mine->rcvinprogress,\n-                                       flags, timeout);\n-                if (0 == rv) {\n-                    goto closed;\n-                }\n-                if ((-1 == rv) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n-                    break;\n-                }\n-                mine->rcvinprogress += rv; /* accumulate the read */\n-                if (mine->rcvinprogress < sizeof(mine->rcvreq)) {\n-                    break; /* loop */\n-                }\n-                mine->rcvstate = rcv_send_credit;\n-                mine->rcvinprogress = 0;\n-            case rcv_send_credit:\n-                b = (char*)&mine->rcvreq;\n-                rv = lo->methods->send(lo, b + mine->rcvinprogress,\n-                                       sizeof(mine->rcvreq) - mine->rcvinprogress,\n-                                       flags, timeout);\n-                if ((-1 == rv) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n-                    break;\n-                }\n-                mine->rcvinprogress += rv; /* accumulate the read */\n-                if (mine->rcvinprogress < sizeof(mine->rcvreq)) {\n-                    break; /* loop */\n-                }\n-                mine->rcvstate = rcv_data;\n-                mine->rcvinprogress = 0;\n-            case rcv_data:\n-                b = (char*)buf;\n-                rv = lo->methods->recv(lo, b + mine->rcvinprogress,\n-                                       mine->rcvreq - mine->rcvinprogress, flags,\n-                                       timeout);\n-                if (0 == rv) {\n-                    goto closed;\n-                }\n-                if ((-1 == rv) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n-                    break;\n-                }\n-                mine->rcvinprogress += rv; /* accumulate the read */\n-                if (mine->rcvinprogress < amount) {\n-                    break; /* loop */\n-                }\n-                mine->rcvstate = rcv_get_debit;\n-                mine->rcvinprogress = 0;\n-                return mine->rcvreq; /* << -- that's it! */\n-            default:\n-                break;\n+static PRInt32 PR_CALLBACK MyRecv(PRFileDesc* fd, void* buf, PRInt32 amount,\n+                                  PRIntn flags, PRIntervalTime timeout) {\n+  char* b;\n+  PRInt32 rv;\n+  PRFileDesc* lo = fd->lower;\n+  PRFilePrivate* mine = (PRFilePrivate*)fd->secret;\n+\n+  do {\n+    switch (mine->rcvstate) {\n+      case rcv_get_debit:\n+        b = (char*)&mine->rcvreq;\n+        mine->rcvreq = amount;\n+        rv = lo->methods->recv(lo, b + mine->rcvinprogress,\n+                               sizeof(mine->rcvreq) - mine->rcvinprogress,\n+                               flags, timeout);\n+        if (0 == rv) {\n+          goto closed;\n+        }\n+        if ((-1 == rv) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n+          break;\n+        }\n+        mine->rcvinprogress += rv; /* accumulate the read */\n+        if (mine->rcvinprogress < sizeof(mine->rcvreq)) {\n+          break; /* loop */\n+        }\n+        mine->rcvstate = rcv_send_credit;\n+        mine->rcvinprogress = 0;\n+      case rcv_send_credit:\n+        b = (char*)&mine->rcvreq;\n+        rv = lo->methods->send(lo, b + mine->rcvinprogress,\n+                               sizeof(mine->rcvreq) - mine->rcvinprogress,\n+                               flags, timeout);\n+        if ((-1 == rv) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n+          break;\n         }\n-    } while (-1 != rv);\n-    return rv;\n+        mine->rcvinprogress += rv; /* accumulate the read */\n+        if (mine->rcvinprogress < sizeof(mine->rcvreq)) {\n+          break; /* loop */\n+        }\n+        mine->rcvstate = rcv_data;\n+        mine->rcvinprogress = 0;\n+      case rcv_data:\n+        b = (char*)buf;\n+        rv = lo->methods->recv(lo, b + mine->rcvinprogress,\n+                               mine->rcvreq - mine->rcvinprogress, flags,\n+                               timeout);\n+        if (0 == rv) {\n+          goto closed;\n+        }\n+        if ((-1 == rv) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n+          break;\n+        }\n+        mine->rcvinprogress += rv; /* accumulate the read */\n+        if (mine->rcvinprogress < amount) {\n+          break; /* loop */\n+        }\n+        mine->rcvstate = rcv_get_debit;\n+        mine->rcvinprogress = 0;\n+        return mine->rcvreq; /* << -- that's it! */\n+      default:\n+        break;\n+    }\n+  } while (-1 != rv);\n+  return rv;\n closed:\n-    mine->rcvinprogress = 0;\n-    mine->rcvstate = rcv_get_debit;\n-    return 0;\n+  mine->rcvinprogress = 0;\n+  mine->rcvstate = rcv_get_debit;\n+  return 0;\n } /* MyRecv */\n \n-static PRInt32 PR_CALLBACK\n-MySend(PRFileDesc* fd, const void* buf,\n-       PRInt32 amount, PRIntn flags,\n-       PRIntervalTime timeout)\n-{\n-    char* b;\n-    PRInt32 rv;\n-    PRFileDesc* lo = fd->lower;\n-    PRFilePrivate* mine = (PRFilePrivate*)fd->secret;\n-\n-    do {\n-        switch (mine->xmtstate) {\n-            case xmt_send_debit:\n-                b = (char*)&mine->xmtreq;\n-                mine->xmtreq = amount;\n-                rv = lo->methods->send(lo, b - mine->xmtinprogress,\n-                                       sizeof(mine->xmtreq) - mine->xmtinprogress,\n-                                       flags, timeout);\n-                if ((-1 == rv) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n-                    break;\n-                }\n-                mine->xmtinprogress += rv;\n-                if (mine->xmtinprogress < sizeof(mine->xmtreq)) {\n-                    break;\n-                }\n-                mine->xmtstate = xmt_recv_credit;\n-                mine->xmtinprogress = 0;\n-            case xmt_recv_credit:\n-                b = (char*)&mine->xmtreq;\n-                rv = lo->methods->recv(lo, b + mine->xmtinprogress,\n-                                       sizeof(mine->xmtreq) - mine->xmtinprogress,\n-                                       flags, timeout);\n-                if ((-1 == rv) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n-                    break;\n-                }\n-                mine->xmtinprogress += rv;\n-                if (mine->xmtinprogress < sizeof(mine->xmtreq)) {\n-                    break;\n-                }\n-                mine->xmtstate = xmt_data;\n-                mine->xmtinprogress = 0;\n-            case xmt_data:\n-                b = (char*)buf;\n-                rv = lo->methods->send(lo, b + mine->xmtinprogress,\n-                                       mine->xmtreq - mine->xmtinprogress, flags,\n-                                       timeout);\n-                if ((-1 == rv) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n-                    break;\n-                }\n-                mine->xmtinprogress += rv;\n-                if (mine->xmtinprogress < amount) {\n-                    break;\n-                }\n-                mine->xmtstate = xmt_send_debit;\n-                mine->xmtinprogress = 0;\n-                return mine->xmtreq; /* <<-- That's the one! */\n-            default:\n-                break;\n+static PRInt32 PR_CALLBACK MySend(PRFileDesc* fd, const void* buf,\n+                                  PRInt32 amount, PRIntn flags,\n+                                  PRIntervalTime timeout) {\n+  char* b;\n+  PRInt32 rv;\n+  PRFileDesc* lo = fd->lower;\n+  PRFilePrivate* mine = (PRFilePrivate*)fd->secret;\n+\n+  do {\n+    switch (mine->xmtstate) {\n+      case xmt_send_debit:\n+        b = (char*)&mine->xmtreq;\n+        mine->xmtreq = amount;\n+        rv = lo->methods->send(lo, b - mine->xmtinprogress,\n+                               sizeof(mine->xmtreq) - mine->xmtinprogress,\n+                               flags, timeout);\n+        if ((-1 == rv) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n+          break;\n         }\n-    } while (-1 != rv);\n-    return rv;\n+        mine->xmtinprogress += rv;\n+        if (mine->xmtinprogress < sizeof(mine->xmtreq)) {\n+          break;\n+        }\n+        mine->xmtstate = xmt_recv_credit;\n+        mine->xmtinprogress = 0;\n+      case xmt_recv_credit:\n+        b = (char*)&mine->xmtreq;\n+        rv = lo->methods->recv(lo, b + mine->xmtinprogress,\n+                               sizeof(mine->xmtreq) - mine->xmtinprogress,\n+                               flags, timeout);\n+        if ((-1 == rv) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n+          break;\n+        }\n+        mine->xmtinprogress += rv;\n+        if (mine->xmtinprogress < sizeof(mine->xmtreq)) {\n+          break;\n+        }\n+        mine->xmtstate = xmt_data;\n+        mine->xmtinprogress = 0;\n+      case xmt_data:\n+        b = (char*)buf;\n+        rv = lo->methods->send(lo, b + mine->xmtinprogress,\n+                               mine->xmtreq - mine->xmtinprogress, flags,\n+                               timeout);\n+        if ((-1 == rv) && (PR_WOULD_BLOCK_ERROR == PR_GetError())) {\n+          break;\n+        }\n+        mine->xmtinprogress += rv;\n+        if (mine->xmtinprogress < amount) {\n+          break;\n+        }\n+        mine->xmtstate = xmt_send_debit;\n+        mine->xmtinprogress = 0;\n+        return mine->xmtreq; /* <<-- That's the one! */\n+      default:\n+        break;\n+    }\n+  } while (-1 != rv);\n+  return rv;\n } /* MySend */\n \n-static Verbosity\n-ChangeVerbosity(Verbosity verbosity, PRIntn delta)\n-{\n-    PRIntn verbage = (PRIntn)verbosity + delta;\n-    if (verbage < (PRIntn)silent) {\n-        verbage = (PRIntn)silent;\n-    } else if (verbage > (PRIntn)noisy) {\n-        verbage = (PRIntn)noisy;\n-    }\n-    return (Verbosity)verbage;\n+static Verbosity ChangeVerbosity(Verbosity verbosity, PRIntn delta) {\n+  PRIntn verbage = (PRIntn)verbosity + delta;\n+  if (verbage < (PRIntn)silent) {\n+    verbage = (PRIntn)silent;\n+  } else if (verbage > (PRIntn)noisy) {\n+    verbage = (PRIntn)noisy;\n+  }\n+  return (Verbosity)verbage;\n } /* ChangeVerbosity */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRStatus rv;\n-    PLOptStatus os;\n-    PRFileDesc *client, *service;\n-    PRNetAddr any_address;\n-    const char* server_name = NULL;\n-    const PRIOMethods* stubMethods;\n-    PRThread *client_thread, *server_thread;\n-    PRThreadScope thread_scope = PR_LOCAL_THREAD;\n-    PRSocketOptionData socket_noblock, socket_nodelay;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dqGC:c:p:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n+int main(int argc, char** argv) {\n+  PRStatus rv;\n+  PLOptStatus os;\n+  PRFileDesc *client, *service;\n+  PRNetAddr any_address;\n+  const char* server_name = NULL;\n+  const PRIOMethods* stubMethods;\n+  PRThread *client_thread, *server_thread;\n+  PRThreadScope thread_scope = PR_LOCAL_THREAD;\n+  PRSocketOptionData socket_noblock, socket_nodelay;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dqGC:c:p:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 0:\n+        server_name = opt->value;\n+        break;\n+      case 'd': /* debug mode */\n+        if (verbosity < noisy) {\n+          verbosity = ChangeVerbosity(verbosity, 1);\n         }\n-        switch (opt->option) {\n-            case 0:\n-                server_name = opt->value;\n-                break;\n-            case 'd': /* debug mode */\n-                if (verbosity < noisy) {\n-                    verbosity = ChangeVerbosity(verbosity, 1);\n-                }\n-                break;\n-            case 'q': /* debug mode */\n-                if (verbosity > silent) {\n-                    verbosity = ChangeVerbosity(verbosity, -1);\n-                }\n-                break;\n-            case 'G': /* use global threads */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'C': /* number of threads waiting */\n-                major_iterations = atoi(opt->value);\n-                break;\n-            case 'c': /* number of client threads */\n-                minor_iterations = atoi(opt->value);\n-                break;\n-            case 'p': /* default port */\n-                default_port = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n+        break;\n+      case 'q': /* debug mode */\n+        if (verbosity > silent) {\n+          verbosity = ChangeVerbosity(verbosity, -1);\n         }\n+        break;\n+      case 'G': /* use global threads */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'C': /* number of threads waiting */\n+        major_iterations = atoi(opt->value);\n+        break;\n+      case 'c': /* number of client threads */\n+        minor_iterations = atoi(opt->value);\n+        break;\n+      case 'p': /* default port */\n+        default_port = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    logFile = PR_GetSpecialFD(PR_StandardError);\n-    identity = PR_GetUniqueIdentity(\"Dummy\");\n-    stubMethods = PR_GetDefaultIOMethods();\n-\n-    /*\n-    ** The protocol we're going to implement is one where in order to initiate\n-    ** a send, the sender must first solicit permission. Therefore, every\n-    ** send is really a send - receive - send sequence.\n-    */\n-    myMethods = *stubMethods;    /* first get the entire batch */\n-    myMethods.accept = MyAccept; /* then override the ones we care about */\n-    myMethods.recv = MyRecv;     /* then override the ones we care about */\n-    myMethods.send = MySend;     /* then override the ones we care about */\n-    myMethods.close = MyClose;   /* then override the ones we care about */\n-    myMethods.poll = MyPoll;     /* then override the ones we care about */\n-\n-    if (NULL == server_name)\n-        rv = PR_InitializeNetAddr(PR_IpAddrLoopback, default_port, &server_address);\n-    else {\n-        rv = PR_StringToNetAddr(server_name, &server_address);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_InitializeNetAddr(PR_IpAddrNull, default_port, &server_address);\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  logFile = PR_GetSpecialFD(PR_StandardError);\n+  identity = PR_GetUniqueIdentity(\"Dummy\");\n+  stubMethods = PR_GetDefaultIOMethods();\n+\n+  /*\n+  ** The protocol we're going to implement is one where in order to initiate\n+  ** a send, the sender must first solicit permission. Therefore, every\n+  ** send is really a send - receive - send sequence.\n+  */\n+  myMethods = *stubMethods;    /* first get the entire batch */\n+  myMethods.accept = MyAccept; /* then override the ones we care about */\n+  myMethods.recv = MyRecv;     /* then override the ones we care about */\n+  myMethods.send = MySend;     /* then override the ones we care about */\n+  myMethods.close = MyClose;   /* then override the ones we care about */\n+  myMethods.poll = MyPoll;     /* then override the ones we care about */\n+\n+  if (NULL == server_name)\n+    rv = PR_InitializeNetAddr(PR_IpAddrLoopback, default_port, &server_address);\n+  else {\n+    rv = PR_StringToNetAddr(server_name, &server_address);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_InitializeNetAddr(PR_IpAddrNull, default_port, &server_address);\n+  }\n+  PR_ASSERT(PR_SUCCESS == rv);\n+\n+  socket_noblock.value.non_blocking = PR_TRUE;\n+  socket_noblock.option = PR_SockOpt_Nonblocking;\n+  socket_nodelay.value.no_delay = PR_TRUE;\n+  socket_nodelay.option = PR_SockOpt_NoDelay;\n+\n+  /* one type w/o layering */\n+\n+  while (major_iterations-- > 0) {\n+    if (verbosity > silent) {\n+      PR_fprintf(logFile, \"Beginning non-layered test\\n\");\n     }\n+\n+    client = PR_NewTCPSocket();\n+    PR_ASSERT(NULL != client);\n+    service = PR_NewTCPSocket();\n+    PR_ASSERT(NULL != service);\n+\n+    rv = PR_SetSocketOption(client, &socket_noblock);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_SetSocketOption(service, &socket_noblock);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_SetSocketOption(client, &socket_nodelay);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_SetSocketOption(service, &socket_nodelay);\n     PR_ASSERT(PR_SUCCESS == rv);\n \n-    socket_noblock.value.non_blocking = PR_TRUE;\n-    socket_noblock.option = PR_SockOpt_Nonblocking;\n-    socket_nodelay.value.no_delay = PR_TRUE;\n-    socket_nodelay.option = PR_SockOpt_NoDelay;\n+    rv = PR_InitializeNetAddr(PR_IpAddrAny, default_port, &any_address);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Bind(service, &any_address);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Listen(service, 10);\n+    PR_ASSERT(PR_SUCCESS == rv);\n \n-    /* one type w/o layering */\n+    server_thread =\n+        PR_CreateThread(PR_USER_THREAD, Server, service, PR_PRIORITY_HIGH,\n+                        thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n+    PR_ASSERT(NULL != server_thread);\n \n-    while (major_iterations-- > 0) {\n-        if (verbosity > silent) {\n-            PR_fprintf(logFile, \"Beginning non-layered test\\n\");\n-        }\n+    client_thread =\n+        PR_CreateThread(PR_USER_THREAD, Client, client, PR_PRIORITY_NORMAL,\n+                        thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n+    PR_ASSERT(NULL != client_thread);\n \n-        client = PR_NewTCPSocket();\n-        PR_ASSERT(NULL != client);\n-        service = PR_NewTCPSocket();\n-        PR_ASSERT(NULL != service);\n-\n-        rv = PR_SetSocketOption(client, &socket_noblock);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_SetSocketOption(service, &socket_noblock);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_SetSocketOption(client, &socket_nodelay);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_SetSocketOption(service, &socket_nodelay);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-\n-        rv = PR_InitializeNetAddr(PR_IpAddrAny, default_port, &any_address);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Bind(service, &any_address);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Listen(service, 10);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-\n-        server_thread =\n-            PR_CreateThread(PR_USER_THREAD, Server, service, PR_PRIORITY_HIGH,\n-                            thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n-        PR_ASSERT(NULL != server_thread);\n-\n-        client_thread =\n-            PR_CreateThread(PR_USER_THREAD, Client, client, PR_PRIORITY_NORMAL,\n-                            thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n-        PR_ASSERT(NULL != client_thread);\n-\n-        rv = PR_JoinThread(client_thread);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_JoinThread(server_thread);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-\n-        rv = PR_Close(client);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Close(service);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        if (verbosity > silent) {\n-            PR_fprintf(logFile, \"Ending non-layered test\\n\");\n-        }\n+    rv = PR_JoinThread(client_thread);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_JoinThread(server_thread);\n+    PR_ASSERT(PR_SUCCESS == rv);\n \n-        /* with layering */\n-        if (verbosity > silent) {\n-            PR_fprintf(logFile, \"Beginning layered test\\n\");\n-        }\n-        client = PR_NewTCPSocket();\n-        PR_ASSERT(NULL != client);\n-        service = PR_NewTCPSocket();\n-        PR_ASSERT(NULL != service);\n-\n-        rv = PR_SetSocketOption(client, &socket_noblock);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_SetSocketOption(service, &socket_noblock);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_SetSocketOption(client, &socket_nodelay);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_SetSocketOption(service, &socket_nodelay);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-\n-        PushLayer(client);\n-        PushLayer(service);\n-\n-        rv = PR_InitializeNetAddr(PR_IpAddrAny, default_port, &any_address);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Bind(service, &any_address);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Listen(service, 10);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-\n-        server_thread =\n-            PR_CreateThread(PR_USER_THREAD, Server, service, PR_PRIORITY_HIGH,\n-                            thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n-        PR_ASSERT(NULL != server_thread);\n-\n-        client_thread =\n-            PR_CreateThread(PR_USER_THREAD, Client, client, PR_PRIORITY_NORMAL,\n-                            thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n-        PR_ASSERT(NULL != client_thread);\n-\n-        rv = PR_JoinThread(client_thread);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_JoinThread(server_thread);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-\n-        rv = PR_Close(PopLayer(client));\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Close(PopLayer(service));\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        if (verbosity > silent) {\n-            PR_fprintf(logFile, \"Ending layered test\\n\");\n-        }\n+    rv = PR_Close(client);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Close(service);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    if (verbosity > silent) {\n+      PR_fprintf(logFile, \"Ending non-layered test\\n\");\n+    }\n+\n+    /* with layering */\n+    if (verbosity > silent) {\n+      PR_fprintf(logFile, \"Beginning layered test\\n\");\n+    }\n+    client = PR_NewTCPSocket();\n+    PR_ASSERT(NULL != client);\n+    service = PR_NewTCPSocket();\n+    PR_ASSERT(NULL != service);\n+\n+    rv = PR_SetSocketOption(client, &socket_noblock);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_SetSocketOption(service, &socket_noblock);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_SetSocketOption(client, &socket_nodelay);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_SetSocketOption(service, &socket_nodelay);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+\n+    PushLayer(client);\n+    PushLayer(service);\n+\n+    rv = PR_InitializeNetAddr(PR_IpAddrAny, default_port, &any_address);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Bind(service, &any_address);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Listen(service, 10);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+\n+    server_thread =\n+        PR_CreateThread(PR_USER_THREAD, Server, service, PR_PRIORITY_HIGH,\n+                        thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n+    PR_ASSERT(NULL != server_thread);\n+\n+    client_thread =\n+        PR_CreateThread(PR_USER_THREAD, Client, client, PR_PRIORITY_NORMAL,\n+                        thread_scope, PR_JOINABLE_THREAD, 16 * 1024);\n+    PR_ASSERT(NULL != client_thread);\n+\n+    rv = PR_JoinThread(client_thread);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_JoinThread(server_thread);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+\n+    rv = PR_Close(PopLayer(client));\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Close(PopLayer(service));\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    if (verbosity > silent) {\n+      PR_fprintf(logFile, \"Ending layered test\\n\");\n     }\n-    return 0;\n+  }\n+  return 0;\n } /* main */\n \n /* nblayer.c */\ndiff --git a/nspr/pr/tests/nonblock.c b/nspr/pr/tests/nonblock.c\nindex a7c6b64..5d12947 100644\n--- a/nspr/pr/tests/nonblock.c\n+++ b/nspr/pr/tests/nonblock.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -23,191 +24,185 @@\n                       * If not defined, use PR_Poll instead. */\n \n #if defined(USE_PR_SELECT)\n-#include \"pprio.h\"\n+#  include \"pprio.h\"\n #endif\n \n-static void PR_CALLBACK\n-clientThreadFunc(void* arg)\n-{\n-    PRUintn port = (PRUintn)arg;\n-    PRFileDesc* sock;\n-    PRNetAddr addr;\n-    char buf[CHUNK_SIZE];\n-    int i;\n-    PRIntervalTime unitTime = PR_MillisecondsToInterval(UNIT_TIME);\n-    PRSocketOptionData optval;\n-    PRStatus retVal;\n-    PRInt32 nBytes;\n-\n-    /* Initialize the buffer so that Purify won't complain */\n-    memset(buf, 0, sizeof(buf));\n-\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.port = PR_htons((PRUint16)port);\n-    addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n-    PR_snprintf(buf, sizeof(buf), \"%hu\", addr.inet.ip);\n-\n-    /* time 1 */\n-    PR_Sleep(unitTime);\n-    sock = PR_NewTCPSocket();\n-    optval.option = PR_SockOpt_Nonblocking;\n-    optval.value.non_blocking = PR_TRUE;\n-    PR_SetSocketOption(sock, &optval);\n-    retVal = PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT);\n-    if (retVal == PR_FAILURE && PR_GetError() == PR_IN_PROGRESS_ERROR) {\n+static void PR_CALLBACK clientThreadFunc(void* arg) {\n+  PRUintn port = (PRUintn)arg;\n+  PRFileDesc* sock;\n+  PRNetAddr addr;\n+  char buf[CHUNK_SIZE];\n+  int i;\n+  PRIntervalTime unitTime = PR_MillisecondsToInterval(UNIT_TIME);\n+  PRSocketOptionData optval;\n+  PRStatus retVal;\n+  PRInt32 nBytes;\n+\n+  /* Initialize the buffer so that Purify won't complain */\n+  memset(buf, 0, sizeof(buf));\n+\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.port = PR_htons((PRUint16)port);\n+  addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n+  PR_snprintf(buf, sizeof(buf), \"%hu\", addr.inet.ip);\n+\n+  /* time 1 */\n+  PR_Sleep(unitTime);\n+  sock = PR_NewTCPSocket();\n+  optval.option = PR_SockOpt_Nonblocking;\n+  optval.value.non_blocking = PR_TRUE;\n+  PR_SetSocketOption(sock, &optval);\n+  retVal = PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT);\n+  if (retVal == PR_FAILURE && PR_GetError() == PR_IN_PROGRESS_ERROR) {\n #if !defined(USE_PR_SELECT)\n-        PRPollDesc pd;\n-        PRInt32 n;\n-        fprintf(stderr, \"connect: EWOULDBLOCK, good\\n\");\n-        pd.fd = sock;\n-        pd.in_flags = PR_POLL_WRITE;\n-        n = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n-        PR_ASSERT(n == 1);\n-        PR_ASSERT(pd.out_flags == PR_POLL_WRITE);\n+    PRPollDesc pd;\n+    PRInt32 n;\n+    fprintf(stderr, \"connect: EWOULDBLOCK, good\\n\");\n+    pd.fd = sock;\n+    pd.in_flags = PR_POLL_WRITE;\n+    n = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n+    PR_ASSERT(n == 1);\n+    PR_ASSERT(pd.out_flags == PR_POLL_WRITE);\n #else\n-        PR_fd_set writeSet;\n-        PRInt32 n;\n-        fprintf(stderr, \"connect: EWOULDBLOCK, good\\n\");\n-        PR_FD_ZERO(&writeSet);\n-        PR_FD_SET(sock, &writeSet);\n-        n = PR_Select(0, NULL, &writeSet, NULL, PR_INTERVAL_NO_TIMEOUT);\n-        PR_ASSERT(n == 1);\n-        PR_ASSERT(PR_FD_ISSET(sock, &writeSet));\n+    PR_fd_set writeSet;\n+    PRInt32 n;\n+    fprintf(stderr, \"connect: EWOULDBLOCK, good\\n\");\n+    PR_FD_ZERO(&writeSet);\n+    PR_FD_SET(sock, &writeSet);\n+    n = PR_Select(0, NULL, &writeSet, NULL, PR_INTERVAL_NO_TIMEOUT);\n+    PR_ASSERT(n == 1);\n+    PR_ASSERT(PR_FD_ISSET(sock, &writeSet));\n #endif\n+  }\n+  printf(\"client connected\\n\");\n+  fflush(stdout);\n+\n+  /* time 4, 7, 11, etc. */\n+  for (i = 0; i < NUMBER_ROUNDS; i++) {\n+    PR_Sleep(3 * unitTime);\n+    nBytes = PR_Write(sock, buf, sizeof(buf));\n+    if (nBytes == -1) {\n+      if (PR_GetError() == PR_WOULD_BLOCK_ERROR) {\n+        fprintf(stderr, \"write: EWOULDBLOCK\\n\");\n+        exit(1);\n+      } else {\n+        fprintf(stderr, \"write: failed\\n\");\n+      }\n     }\n-    printf(\"client connected\\n\");\n+    printf(\"client sent %d bytes\\n\", nBytes);\n     fflush(stdout);\n+  }\n \n-    /* time 4, 7, 11, etc. */\n-    for (i = 0; i < NUMBER_ROUNDS; i++) {\n-        PR_Sleep(3 * unitTime);\n-        nBytes = PR_Write(sock, buf, sizeof(buf));\n-        if (nBytes == -1) {\n-            if (PR_GetError() == PR_WOULD_BLOCK_ERROR) {\n-                fprintf(stderr, \"write: EWOULDBLOCK\\n\");\n-                exit(1);\n-            } else {\n-                fprintf(stderr, \"write: failed\\n\");\n-            }\n-        }\n-        printf(\"client sent %d bytes\\n\", nBytes);\n-        fflush(stdout);\n-    }\n-\n-    PR_Close(sock);\n+  PR_Close(sock);\n }\n \n-static PRIntn PR_CALLBACK\n-RealMain(PRIntn argc, char** argv)\n-{\n-    PRFileDesc *listenSock, *sock;\n-    PRUint16 listenPort;\n-    PRNetAddr addr;\n-    char buf[CHUNK_SIZE];\n-    PRThread* clientThread;\n-    PRInt32 retVal;\n-    PRSocketOptionData optval;\n-    PRIntn i;\n-    PRIntervalTime unitTime = PR_MillisecondsToInterval(UNIT_TIME);\n-\n-    /* Create a listening socket */\n-    if ((listenSock = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        exit(1);\n-    }\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        exit(1);\n-    }\n-    if (PR_GetSockName(listenSock, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        exit(1);\n-    }\n-    listenPort = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        exit(1);\n-    }\n-\n-    PR_snprintf(buf, sizeof(buf),\n-                \"The server thread is listening on port %hu\\n\\n\", listenPort);\n-    printf(\"%s\", buf);\n-\n-    clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n-                                   (void*)listenPort, PR_PRIORITY_NORMAL,\n-                                   PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    if (clientThread == NULL) {\n-        fprintf(stderr, \"can't create thread\\n\");\n-        exit(1);\n-    }\n-\n-    printf(\"client thread created.\\n\");\n-\n-    optval.option = PR_SockOpt_Nonblocking;\n-    optval.value.non_blocking = PR_TRUE;\n-    PR_SetSocketOption(listenSock, &optval);\n-    /* time 0 */\n-    sock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n-    if (sock != NULL || PR_GetError() != PR_WOULD_BLOCK_ERROR) {\n-        PL_PrintError(\"First Accept\\n\");\n-        fprintf(stderr, \"First PR_Accept() xxx\\n\");\n-        exit(1);\n+static PRIntn PR_CALLBACK RealMain(PRIntn argc, char** argv) {\n+  PRFileDesc *listenSock, *sock;\n+  PRUint16 listenPort;\n+  PRNetAddr addr;\n+  char buf[CHUNK_SIZE];\n+  PRThread* clientThread;\n+  PRInt32 retVal;\n+  PRSocketOptionData optval;\n+  PRIntn i;\n+  PRIntervalTime unitTime = PR_MillisecondsToInterval(UNIT_TIME);\n+\n+  /* Create a listening socket */\n+  if ((listenSock = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    exit(1);\n+  }\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    exit(1);\n+  }\n+  if (PR_GetSockName(listenSock, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    exit(1);\n+  }\n+  listenPort = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    exit(1);\n+  }\n+\n+  PR_snprintf(buf, sizeof(buf),\n+              \"The server thread is listening on port %hu\\n\\n\", listenPort);\n+  printf(\"%s\", buf);\n+\n+  clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n+                                 (void*)listenPort, PR_PRIORITY_NORMAL,\n+                                 PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  if (clientThread == NULL) {\n+    fprintf(stderr, \"can't create thread\\n\");\n+    exit(1);\n+  }\n+\n+  printf(\"client thread created.\\n\");\n+\n+  optval.option = PR_SockOpt_Nonblocking;\n+  optval.value.non_blocking = PR_TRUE;\n+  PR_SetSocketOption(listenSock, &optval);\n+  /* time 0 */\n+  sock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n+  if (sock != NULL || PR_GetError() != PR_WOULD_BLOCK_ERROR) {\n+    PL_PrintError(\"First Accept\\n\");\n+    fprintf(stderr, \"First PR_Accept() xxx\\n\");\n+    exit(1);\n+  }\n+  printf(\"accept: EWOULDBLOCK, good\\n\");\n+  fflush(stdout);\n+  /* time 2 */\n+  PR_Sleep(2 * unitTime);\n+  sock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n+  if (sock == NULL) {\n+    PL_PrintError(\"Second Accept\\n\");\n+    fprintf(stderr, \"Second PR_Accept() failed: (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  printf(\"accept: succeeded, good\\n\");\n+  fflush(stdout);\n+  PR_Close(listenSock);\n+\n+  PR_SetSocketOption(sock, &optval);\n+\n+  /* time 3, 5, 6, 8, etc. */\n+  for (i = 0; i < NUMBER_ROUNDS; i++) {\n+    PR_Sleep(unitTime);\n+    retVal = PR_Recv(sock, buf, sizeof(buf), 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (retVal != -1 || PR_GetError() != PR_WOULD_BLOCK_ERROR) {\n+      PL_PrintError(\"First Receive:\\n\");\n+      fprintf(stderr, \"First PR_Recv: retVal: %ld, Error: %ld\\n\", retVal,\n+              PR_GetError());\n+      exit(1);\n     }\n-    printf(\"accept: EWOULDBLOCK, good\\n\");\n+    printf(\"read: EWOULDBLOCK, good\\n\");\n     fflush(stdout);\n-    /* time 2 */\n     PR_Sleep(2 * unitTime);\n-    sock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n-    if (sock == NULL) {\n-        PL_PrintError(\"Second Accept\\n\");\n-        fprintf(stderr, \"Second PR_Accept() failed: (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n+    retVal = PR_Recv(sock, buf, sizeof(buf), 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (retVal != CHUNK_SIZE) {\n+      PL_PrintError(\"Second Receive:\\n\");\n+      fprintf(stderr, \"Second PR_Recv: retVal: %ld, Error: %ld\\n\", retVal,\n+              PR_GetError());\n+      exit(1);\n     }\n-    printf(\"accept: succeeded, good\\n\");\n+    printf(\"read: %d bytes, good\\n\", retVal);\n     fflush(stdout);\n-    PR_Close(listenSock);\n-\n-    PR_SetSocketOption(sock, &optval);\n-\n-    /* time 3, 5, 6, 8, etc. */\n-    for (i = 0; i < NUMBER_ROUNDS; i++) {\n-        PR_Sleep(unitTime);\n-        retVal = PR_Recv(sock, buf, sizeof(buf), 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (retVal != -1 || PR_GetError() != PR_WOULD_BLOCK_ERROR) {\n-            PL_PrintError(\"First Receive:\\n\");\n-            fprintf(stderr, \"First PR_Recv: retVal: %ld, Error: %ld\\n\", retVal,\n-                    PR_GetError());\n-            exit(1);\n-        }\n-        printf(\"read: EWOULDBLOCK, good\\n\");\n-        fflush(stdout);\n-        PR_Sleep(2 * unitTime);\n-        retVal = PR_Recv(sock, buf, sizeof(buf), 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (retVal != CHUNK_SIZE) {\n-            PL_PrintError(\"Second Receive:\\n\");\n-            fprintf(stderr, \"Second PR_Recv: retVal: %ld, Error: %ld\\n\", retVal,\n-                    PR_GetError());\n-            exit(1);\n-        }\n-        printf(\"read: %d bytes, good\\n\", retVal);\n-        fflush(stdout);\n-    }\n-    PR_Close(sock);\n+  }\n+  PR_Close(sock);\n \n-    printf(\"All tests finished\\n\");\n-    printf(\"PASS\\n\");\n-    return 0;\n+  printf(\"All tests finished\\n\");\n+  printf(\"PASS\\n\");\n+  return 0;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv;\n+int main(int argc, char** argv) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\ndiff --git a/nspr/pr/tests/ntioto.c b/nspr/pr/tests/ntioto.c\nindex 64cd279..16f9566 100644\n--- a/nspr/pr/tests/ntioto.c\n+++ b/nspr/pr/tests/ntioto.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -59,14 +60,14 @@ PRUint32 failed_already = 0;\n #define JITTER_DEFAULT 100000\n \n #ifdef DEBUG\n-#define PORT_INC_DO +100\n+#  define PORT_INC_DO +100\n #else\n-#define PORT_INC_DO\n+#  define PORT_INC_DO\n #endif\n #ifdef IS_64\n-#define PORT_INC_3264 +200\n+#  define PORT_INC_3264 +200\n #else\n-#define PORT_INC_3264\n+#  define PORT_INC_3264\n #endif\n \n #define BASE_PORT 9867 PORT_INC_DO PORT_INC_3264\n@@ -76,9 +77,7 @@ PRNetAddr listenAddr;\n PRFileDesc* listenSock;\n PRLock* ml;\n PRCondVar* cv;\n-volatile enum { RunJitter,\n-                RunAcceptRead,\n-                AllDone } state = RunAcceptRead;\n+volatile enum { RunJitter, RunAcceptRead, AllDone } state = RunAcceptRead;\n PRFileDesc* file1;\n PRIntn iCounter = 0;\n PRIntn jitter = JITTER_DEFAULT;\n@@ -87,11 +86,9 @@ PRBool resume = PR_FALSE;\n /*\n ** Emit help text for this test\n */\n-static void\n-Help(void)\n-{\n-    printf(\"Template: Help(): display your help message(s) here\");\n-    exit(1);\n+static void Help(void) {\n+  printf(\"Template: Help(): display your help message(s) here\");\n+  exit(1);\n } /* end Help() */\n \n /*\n@@ -100,209 +97,201 @@ Help(void)\n #define ACCEPT_READ_DATASIZE 10\n #define ACCEPT_READ_BUFSIZE (PR_ACCEPT_READ_BUF_OVERHEAD + ACCEPT_READ_DATASIZE)\n \n-static void\n-AcceptThread(void* arg)\n-{\n-    PRIntn bytesRead;\n-    char dataBuf[ACCEPT_READ_BUFSIZE];\n-    PRFileDesc* arSock;\n-    PRNetAddr* arAddr;\n-\n-    bytesRead = PR_AcceptRead(listenSock, &arSock, &arAddr, dataBuf,\n-                              ACCEPT_READ_DATASIZE, PR_SecondsToInterval(1));\n-\n-    if (bytesRead == -1 && PR_GetError() == PR_IO_TIMEOUT_ERROR) {\n-        if (debug) {\n-            printf(\"AcceptRead timed out\\n\");\n-        }\n-    } else {\n-        if (debug) {\n-            printf(\"Oops! read: %d, error: %d\\n\", bytesRead, PR_GetError());\n-        }\n+static void AcceptThread(void* arg) {\n+  PRIntn bytesRead;\n+  char dataBuf[ACCEPT_READ_BUFSIZE];\n+  PRFileDesc* arSock;\n+  PRNetAddr* arAddr;\n+\n+  bytesRead = PR_AcceptRead(listenSock, &arSock, &arAddr, dataBuf,\n+                            ACCEPT_READ_DATASIZE, PR_SecondsToInterval(1));\n+\n+  if (bytesRead == -1 && PR_GetError() == PR_IO_TIMEOUT_ERROR) {\n+    if (debug) {\n+      printf(\"AcceptRead timed out\\n\");\n     }\n+  } else {\n+    if (debug) {\n+      printf(\"Oops! read: %d, error: %d\\n\", bytesRead, PR_GetError());\n+    }\n+  }\n \n-    while (state != AllDone) {\n-        PR_Lock(ml);\n-        while (state != RunAcceptRead) {\n-            PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        if (++iCounter >= jitter) {\n-            state = AllDone;\n-        } else {\n-            state = RunJitter;\n-        }\n-        if (verbose) {\n-            printf(\".\");\n-        }\n-        PR_NotifyCondVar(cv);\n-        PR_Unlock(ml);\n-        PR_Write(file1, \".\", 1);\n+  while (state != AllDone) {\n+    PR_Lock(ml);\n+    while (state != RunAcceptRead) {\n+      PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n+    }\n+    if (++iCounter >= jitter) {\n+      state = AllDone;\n+    } else {\n+      state = RunJitter;\n     }\n+    if (verbose) {\n+      printf(\".\");\n+    }\n+    PR_NotifyCondVar(cv);\n+    PR_Unlock(ml);\n+    PR_Write(file1, \".\", 1);\n+  }\n \n-    return;\n+  return;\n } /* end AcceptThread() */\n \n-static void\n-JitterThread(void* arg)\n-{\n-    while (state != AllDone) {\n-        PR_Lock(ml);\n-        while (state != RunJitter && state != AllDone) {\n-            PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        if (state != AllDone) {\n-            state = RunAcceptRead;\n-        }\n-        if (verbose) {\n-            printf(\"+\");\n-        }\n-        PR_NotifyCondVar(cv);\n-        PR_Unlock(ml);\n-        PR_Write(file1, \"+\", 1);\n+static void JitterThread(void* arg) {\n+  while (state != AllDone) {\n+    PR_Lock(ml);\n+    while (state != RunJitter && state != AllDone) {\n+      PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n+    }\n+    if (state != AllDone) {\n+      state = RunAcceptRead;\n     }\n-    return;\n+    if (verbose) {\n+      printf(\"+\");\n+    }\n+    PR_NotifyCondVar(cv);\n+    PR_Unlock(ml);\n+    PR_Write(file1, \"+\", 1);\n+  }\n+  return;\n } /* end Goofy() */\n \n-static void\n-ConnectThread(void* arg)\n-{\n-    PRStatus rv;\n-    PRFileDesc* clientSock;\n-    PRNetAddr serverAddress;\n-    clientSock = PR_NewTCPSocket();\n-\n-    PR_ASSERT(clientSock);\n-\n-    if (resume) {\n-        if (debug) {\n-            printf(\"pausing 3 seconds before connect\\n\");\n-        }\n-        PR_Sleep(PR_SecondsToInterval(3));\n-    }\n+static void ConnectThread(void* arg) {\n+  PRStatus rv;\n+  PRFileDesc* clientSock;\n+  PRNetAddr serverAddress;\n+  clientSock = PR_NewTCPSocket();\n \n-    memset(&serverAddress, 0, sizeof(serverAddress));\n-    rv = PR_InitializeNetAddr(PR_IpAddrLoopback, BASE_PORT, &serverAddress);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    rv = PR_Connect(clientSock, &serverAddress, PR_SecondsToInterval(1));\n-    PR_ASSERT(PR_SUCCESS == rv);\n+  PR_ASSERT(clientSock);\n \n-    /* that's all we do. ... Wait for the acceptread() to timeout */\n-    while (state != AllDone) {\n-        PR_Sleep(PR_SecondsToInterval(1));\n+  if (resume) {\n+    if (debug) {\n+      printf(\"pausing 3 seconds before connect\\n\");\n     }\n-    return;\n+    PR_Sleep(PR_SecondsToInterval(3));\n+  }\n+\n+  memset(&serverAddress, 0, sizeof(serverAddress));\n+  rv = PR_InitializeNetAddr(PR_IpAddrLoopback, BASE_PORT, &serverAddress);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  rv = PR_Connect(clientSock, &serverAddress, PR_SecondsToInterval(1));\n+  PR_ASSERT(PR_SUCCESS == rv);\n+\n+  /* that's all we do. ... Wait for the acceptread() to timeout */\n+  while (state != AllDone) {\n+    PR_Sleep(PR_SecondsToInterval(1));\n+  }\n+  return;\n } /* end ConnectThread() */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRThread* tJitter;\n-    PRThread* tAccept;\n-    PRThread* tConnect;\n-    PRStatus rv;\n-    /* This test if valid for WinNT only! */\n+int main(int argc, char** argv) {\n+  PRThread* tJitter;\n+  PRThread* tAccept;\n+  PRThread* tConnect;\n+  PRStatus rv;\n+  /* This test if valid for WinNT only! */\n \n #if !defined(WINNT)\n-    return 0;\n+  return 0;\n #endif\n \n-    {\n-        /*\n-        ** Get command line options\n-        */\n-        PLOptStatus os;\n-        PLOptState* opt = PL_CreateOptState(argc, argv, \"hdrvj:\");\n-\n-        while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-            if (PL_OPT_BAD == os) {\n-                continue;\n-            }\n-            switch (opt->option) {\n-                case 'd': /* debug */\n-                    debug = 1;\n-                    msgLevel = PR_LOG_ERROR;\n-                    break;\n-                case 'v': /* verbose mode */\n-                    verbose = 1;\n-                    msgLevel = PR_LOG_DEBUG;\n-                    break;\n-                case 'j':\n-                    jitter = atoi(opt->value);\n-                    if (jitter == 0) {\n-                        jitter = JITTER_DEFAULT;\n-                    }\n-                    break;\n-                case 'r':\n-                    resume = PR_TRUE;\n-                    break;\n-                case 'h': /* help message */\n-                    Help();\n-                    break;\n-                default:\n-                    break;\n-            }\n-        }\n-        PL_DestroyOptState(opt);\n-    }\n-\n-    lm = PR_NewLogModule(\"Test\"); /* Initialize logging */\n-\n-    /* set concurrency */\n-    PR_SetConcurrency(4);\n-\n-    /* setup thread synchronization mechanics */\n-    ml = PR_NewLock();\n-    cv = PR_NewCondVar(ml);\n-\n-    /* setup a tcp socket */\n-    memset(&listenAddr, 0, sizeof(listenAddr));\n-    rv = PR_InitializeNetAddr(PR_IpAddrAny, BASE_PORT, &listenAddr);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-\n-    listenSock = PR_NewTCPSocket();\n-    PR_ASSERT(listenSock);\n-\n-    rv = PR_Bind(listenSock, &listenAddr);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-\n-    rv = PR_Listen(listenSock, 5);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-\n-    /* open a file for writing, provoke bug */\n-    file1 = PR_Open(\"xxxTestFile\", PR_CREATE_FILE | PR_RDWR, 666);\n-\n-    /* create Connect thread */\n-    tConnect =\n-        PR_CreateThread(PR_USER_THREAD, ConnectThread, NULL, PR_PRIORITY_NORMAL,\n-                        PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    PR_ASSERT(tConnect);\n-\n-    /* create jitter off thread */\n-    tJitter =\n-        PR_CreateThread(PR_USER_THREAD, JitterThread, NULL, PR_PRIORITY_NORMAL,\n-                        PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    PR_ASSERT(tJitter);\n-\n-    /* create acceptread thread */\n-    tAccept =\n-        PR_CreateThread(PR_USER_THREAD, AcceptThread, NULL, PR_PRIORITY_NORMAL,\n-                        PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    PR_ASSERT(tAccept);\n-\n-    /* wait for all threads to quit, then terminate gracefully */\n-    PR_JoinThread(tConnect);\n-    PR_JoinThread(tAccept);\n-    PR_JoinThread(tJitter);\n-    PR_Close(listenSock);\n-    PR_DestroyCondVar(cv);\n-    PR_DestroyLock(ml);\n-    PR_Close(file1);\n-    PR_Delete(\"xxxTestFile\");\n-\n-    /* test return and exit */\n-    if (debug) {\n-        printf(\"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n+  {\n+    /*\n+    ** Get command line options\n+    */\n+    PLOptStatus os;\n+    PLOptState* opt = PL_CreateOptState(argc, argv, \"hdrvj:\");\n+\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+      if (PL_OPT_BAD == os) {\n+        continue;\n+      }\n+      switch (opt->option) {\n+        case 'd': /* debug */\n+          debug = 1;\n+          msgLevel = PR_LOG_ERROR;\n+          break;\n+        case 'v': /* verbose mode */\n+          verbose = 1;\n+          msgLevel = PR_LOG_DEBUG;\n+          break;\n+        case 'j':\n+          jitter = atoi(opt->value);\n+          if (jitter == 0) {\n+            jitter = JITTER_DEFAULT;\n+          }\n+          break;\n+        case 'r':\n+          resume = PR_TRUE;\n+          break;\n+        case 'h': /* help message */\n+          Help();\n+          break;\n+        default:\n+          break;\n+      }\n     }\n-    return ((failed_already == PR_TRUE) ? 1 : 0);\n+    PL_DestroyOptState(opt);\n+  }\n+\n+  lm = PR_NewLogModule(\"Test\"); /* Initialize logging */\n+\n+  /* set concurrency */\n+  PR_SetConcurrency(4);\n+\n+  /* setup thread synchronization mechanics */\n+  ml = PR_NewLock();\n+  cv = PR_NewCondVar(ml);\n+\n+  /* setup a tcp socket */\n+  memset(&listenAddr, 0, sizeof(listenAddr));\n+  rv = PR_InitializeNetAddr(PR_IpAddrAny, BASE_PORT, &listenAddr);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+\n+  listenSock = PR_NewTCPSocket();\n+  PR_ASSERT(listenSock);\n+\n+  rv = PR_Bind(listenSock, &listenAddr);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+\n+  rv = PR_Listen(listenSock, 5);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+\n+  /* open a file for writing, provoke bug */\n+  file1 = PR_Open(\"xxxTestFile\", PR_CREATE_FILE | PR_RDWR, 666);\n+\n+  /* create Connect thread */\n+  tConnect =\n+      PR_CreateThread(PR_USER_THREAD, ConnectThread, NULL, PR_PRIORITY_NORMAL,\n+                      PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  PR_ASSERT(tConnect);\n+\n+  /* create jitter off thread */\n+  tJitter =\n+      PR_CreateThread(PR_USER_THREAD, JitterThread, NULL, PR_PRIORITY_NORMAL,\n+                      PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  PR_ASSERT(tJitter);\n+\n+  /* create acceptread thread */\n+  tAccept =\n+      PR_CreateThread(PR_USER_THREAD, AcceptThread, NULL, PR_PRIORITY_NORMAL,\n+                      PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  PR_ASSERT(tAccept);\n+\n+  /* wait for all threads to quit, then terminate gracefully */\n+  PR_JoinThread(tConnect);\n+  PR_JoinThread(tAccept);\n+  PR_JoinThread(tJitter);\n+  PR_Close(listenSock);\n+  PR_DestroyCondVar(cv);\n+  PR_DestroyLock(ml);\n+  PR_Close(file1);\n+  PR_Delete(\"xxxTestFile\");\n+\n+  /* test return and exit */\n+  if (debug) {\n+    printf(\"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n+  }\n+  return ((failed_already == PR_TRUE) ? 1 : 0);\n } /* main() */\n /* end ntioto.c */\ndiff --git a/nspr/pr/tests/ntoh.c b/nspr/pr/tests/ntoh.c\nindex 702affd..ea2ca48 100644\n--- a/nspr/pr/tests/ntoh.c\n+++ b/nspr/pr/tests/ntoh.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -14,71 +15,69 @@\n #include <stdlib.h>\n \n /* Byte sequence in network byte order */\n-static unsigned char bytes_n[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };\n+static unsigned char bytes_n[8] = {1, 2, 3, 4, 5, 6, 7, 8};\n \n /* Integers in host byte order */\n static PRUint16 s_h = 0x0102;\n static PRUint32 l_h = 0x01020304;\n static PRUint64 ll_h = LL_INIT(0x01020304, 0x05060708);\n \n-int\n-main(int argc, char** argv)\n-{\n-    union {\n-        PRUint16 s;\n-        PRUint32 l;\n-        PRUint64 ll;\n-        unsigned char bytes[8];\n-    } un;\n+int main(int argc, char** argv) {\n+  union {\n+    PRUint16 s;\n+    PRUint32 l;\n+    PRUint64 ll;\n+    unsigned char bytes[8];\n+  } un;\n \n-    un.s = s_h;\n-    printf(\"%u %u\\n\", un.bytes[0], un.bytes[1]);\n-    un.s = PR_htons(un.s);\n-    printf(\"%u %u\\n\", un.bytes[0], un.bytes[1]);\n-    if (memcmp(un.bytes, bytes_n, 2)) {\n-        fprintf(stderr, \"PR_htons failed\\n\");\n-        exit(1);\n-    }\n-    un.s = PR_ntohs(un.s);\n-    printf(\"%u %u\\n\", un.bytes[0], un.bytes[1]);\n-    if (un.s != s_h) {\n-        fprintf(stderr, \"PR_ntohs failed\\n\");\n-        exit(1);\n-    }\n+  un.s = s_h;\n+  printf(\"%u %u\\n\", un.bytes[0], un.bytes[1]);\n+  un.s = PR_htons(un.s);\n+  printf(\"%u %u\\n\", un.bytes[0], un.bytes[1]);\n+  if (memcmp(un.bytes, bytes_n, 2)) {\n+    fprintf(stderr, \"PR_htons failed\\n\");\n+    exit(1);\n+  }\n+  un.s = PR_ntohs(un.s);\n+  printf(\"%u %u\\n\", un.bytes[0], un.bytes[1]);\n+  if (un.s != s_h) {\n+    fprintf(stderr, \"PR_ntohs failed\\n\");\n+    exit(1);\n+  }\n \n-    un.l = l_h;\n-    printf(\"%u %u %u %u\\n\", un.bytes[0], un.bytes[1], un.bytes[2], un.bytes[3]);\n-    un.l = PR_htonl(un.l);\n-    printf(\"%u %u %u %u\\n\", un.bytes[0], un.bytes[1], un.bytes[2], un.bytes[3]);\n-    if (memcmp(un.bytes, bytes_n, 4)) {\n-        fprintf(stderr, \"PR_htonl failed\\n\");\n-        exit(1);\n-    }\n-    un.l = PR_ntohl(un.l);\n-    printf(\"%u %u %u %u\\n\", un.bytes[0], un.bytes[1], un.bytes[2], un.bytes[3]);\n-    if (un.l != l_h) {\n-        fprintf(stderr, \"PR_ntohl failed\\n\");\n-        exit(1);\n-    }\n+  un.l = l_h;\n+  printf(\"%u %u %u %u\\n\", un.bytes[0], un.bytes[1], un.bytes[2], un.bytes[3]);\n+  un.l = PR_htonl(un.l);\n+  printf(\"%u %u %u %u\\n\", un.bytes[0], un.bytes[1], un.bytes[2], un.bytes[3]);\n+  if (memcmp(un.bytes, bytes_n, 4)) {\n+    fprintf(stderr, \"PR_htonl failed\\n\");\n+    exit(1);\n+  }\n+  un.l = PR_ntohl(un.l);\n+  printf(\"%u %u %u %u\\n\", un.bytes[0], un.bytes[1], un.bytes[2], un.bytes[3]);\n+  if (un.l != l_h) {\n+    fprintf(stderr, \"PR_ntohl failed\\n\");\n+    exit(1);\n+  }\n \n-    un.ll = ll_h;\n-    printf(\"%u %u %u %u %u %u %u %u\\n\", un.bytes[0], un.bytes[1], un.bytes[2],\n-           un.bytes[3], un.bytes[4], un.bytes[5], un.bytes[6], un.bytes[7]);\n-    un.ll = PR_htonll(un.ll);\n-    printf(\"%u %u %u %u %u %u %u %u\\n\", un.bytes[0], un.bytes[1], un.bytes[2],\n-           un.bytes[3], un.bytes[4], un.bytes[5], un.bytes[6], un.bytes[7]);\n-    if (memcmp(un.bytes, bytes_n, 8)) {\n-        fprintf(stderr, \"PR_htonll failed\\n\");\n-        exit(1);\n-    }\n-    un.ll = PR_ntohll(un.ll);\n-    printf(\"%u %u %u %u %u %u %u %u\\n\", un.bytes[0], un.bytes[1], un.bytes[2],\n-           un.bytes[3], un.bytes[4], un.bytes[5], un.bytes[6], un.bytes[7]);\n-    if (LL_NE(un.ll, ll_h)) {\n-        fprintf(stderr, \"PR_ntohll failed\\n\");\n-        exit(1);\n-    }\n+  un.ll = ll_h;\n+  printf(\"%u %u %u %u %u %u %u %u\\n\", un.bytes[0], un.bytes[1], un.bytes[2],\n+         un.bytes[3], un.bytes[4], un.bytes[5], un.bytes[6], un.bytes[7]);\n+  un.ll = PR_htonll(un.ll);\n+  printf(\"%u %u %u %u %u %u %u %u\\n\", un.bytes[0], un.bytes[1], un.bytes[2],\n+         un.bytes[3], un.bytes[4], un.bytes[5], un.bytes[6], un.bytes[7]);\n+  if (memcmp(un.bytes, bytes_n, 8)) {\n+    fprintf(stderr, \"PR_htonll failed\\n\");\n+    exit(1);\n+  }\n+  un.ll = PR_ntohll(un.ll);\n+  printf(\"%u %u %u %u %u %u %u %u\\n\", un.bytes[0], un.bytes[1], un.bytes[2],\n+         un.bytes[3], un.bytes[4], un.bytes[5], un.bytes[6], un.bytes[7]);\n+  if (LL_NE(un.ll, ll_h)) {\n+    fprintf(stderr, \"PR_ntohll failed\\n\");\n+    exit(1);\n+  }\n \n-    printf(\"PASS\\n\");\n-    return 0;\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/obsints.c b/nspr/pr/tests/obsints.c\nindex 78b68d3..7f2bb25 100644\n--- a/nspr/pr/tests/obsints.c\n+++ b/nspr/pr/tests/obsints.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -15,38 +16,34 @@\n #ifdef NO_NSPR_10_SUPPORT\n \n /* nothing to do */\n-int\n-main(int argc, char** argv)\n-{\n-    printf(\"PASS\\n\");\n-    return 0;\n+int main(int argc, char** argv) {\n+  printf(\"PASS\\n\");\n+  return 0;\n }\n \n #else /* NO_NSPR_10_SUPPORT */\n \n-#include \"prtypes.h\" /* which includes protypes.h */\n-\n-int\n-main(int argc, char** argv)\n-{\n-    /*\n-     * Compilation fails if any of these integer types are not\n-     * defined by protypes.h.\n-     */\n-    intn in;\n-    uintn uin;\n-    uint ui;\n-    int8 i8;\n-    uint8 ui8;\n-    int16 i16;\n-    uint16 ui16;\n-    int32 i32;\n-    uint32 ui32;\n-    int64 i64;\n-    uint64 ui64;\n-\n-    printf(\"PASS\\n\");\n-    return 0;\n+#  include \"prtypes.h\" /* which includes protypes.h */\n+\n+int main(int argc, char** argv) {\n+  /*\n+   * Compilation fails if any of these integer types are not\n+   * defined by protypes.h.\n+   */\n+  intn in;\n+  uintn uin;\n+  uint ui;\n+  int8 i8;\n+  uint8 ui8;\n+  int16 i16;\n+  uint16 ui16;\n+  int32 i32;\n+  uint32 ui32;\n+  int64 i64;\n+  uint64 ui64;\n+\n+  printf(\"PASS\\n\");\n+  return 0;\n }\n \n #endif /* NO_NSPR_10_SUPPORT */\ndiff --git a/nspr/pr/tests/op_2long.c b/nspr/pr/tests/op_2long.c\nindex 3b509da..e18dba3 100644\n--- a/nspr/pr/tests/op_2long.c\n+++ b/nspr/pr/tests/op_2long.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -34,37 +35,35 @@ PRIntn error_code;\n  */\n #define TOO_LONG 5000\n \n-int\n-main(int argc, char** argv)\n-{\n-    char nameTooLong[TOO_LONG];\n-    int i;\n+int main(int argc, char** argv) {\n+  char nameTooLong[TOO_LONG];\n+  int i;\n \n-    /* Generate a really long pathname */\n-    for (i = 0; i < TOO_LONG - 1; i++) {\n-        if (i % 10 == 0) {\n-            nameTooLong[i] = '/';\n-        } else {\n-            nameTooLong[i] = 'a';\n-        }\n+  /* Generate a really long pathname */\n+  for (i = 0; i < TOO_LONG - 1; i++) {\n+    if (i % 10 == 0) {\n+      nameTooLong[i] = '/';\n+    } else {\n+      nameTooLong[i] = 'a';\n     }\n-    nameTooLong[TOO_LONG - 1] = 0;\n+  }\n+  nameTooLong[TOO_LONG - 1] = 0;\n \n-    t1 = PR_Open(nameTooLong, PR_RDWR, 0666);\n-    if (t1 == NULL) {\n-        if (PR_GetError() == PR_NAME_TOO_LONG_ERROR) {\n-            PL_PrintError(\"error code is\");\n-            printf(\"PASS\\n\");\n-            return 0;\n-        } else {\n-            PL_PrintError(\"error code is\");\n-            printf(\"FAIL\\n\");\n-            return 1;\n-        }\n+  t1 = PR_Open(nameTooLong, PR_RDWR, 0666);\n+  if (t1 == NULL) {\n+    if (PR_GetError() == PR_NAME_TOO_LONG_ERROR) {\n+      PL_PrintError(\"error code is\");\n+      printf(\"PASS\\n\");\n+      return 0;\n+    } else {\n+      PL_PrintError(\"error code is\");\n+      printf(\"FAIL\\n\");\n+      return 1;\n     }\n+  }\n \n-    else {\n-        printf(\"Test passed\\n\");\n-        return 0;\n-    }\n+  else {\n+    printf(\"Test passed\\n\");\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/op_excl.c b/nspr/pr/tests/op_excl.c\nindex 152ccf2..0552a39 100644\n--- a/nspr/pr/tests/op_excl.c\n+++ b/nspr/pr/tests/op_excl.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -28,107 +29,103 @@ PRUint32 failed_already = 0;\n /*\n ** Emit help text for this test\n */\n-static void\n-Help(void)\n-{\n-    printf(\"op_excl: Help\");\n-    printf(\"op_excl [-d]\");\n-    printf(\"-d enables debug messages\");\n-    exit(1);\n+static void Help(void) {\n+  printf(\"op_excl: Help\");\n+  printf(\"op_excl [-d]\");\n+  printf(\"-d enables debug messages\");\n+  exit(1);\n } /* end Help() */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc* fd;\n-    PRStatus rv;\n-    PRInt32 written;\n-    char outBuf[] = \"op_excl.c test file\";\n+int main(int argc, char** argv) {\n+  PRFileDesc* fd;\n+  PRStatus rv;\n+  PRInt32 written;\n+  char outBuf[] = \"op_excl.c test file\";\n #define OUT_SIZE sizeof(outBuf)\n #define NEW_FILENAME \"xxxExclNewFile\"\n \n-    {\n-        /*\n-        ** Get command line options\n-        */\n-        PLOptStatus os;\n-        PLOptState* opt = PL_CreateOptState(argc, argv, \"hd\");\n+  {\n+    /*\n+    ** Get command line options\n+    */\n+    PLOptStatus os;\n+    PLOptState* opt = PL_CreateOptState(argc, argv, \"hd\");\n \n-        while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-            if (PL_OPT_BAD == os) {\n-                continue;\n-            }\n-            switch (opt->option) {\n-                case 'd': /* debug */\n-                    debug = 1;\n-                    msgLevel = PR_LOG_ERROR;\n-                    break;\n-                case 'h': /* help message */\n-                    Help();\n-                    break;\n-                default:\n-                    break;\n-            }\n-        }\n-        PL_DestroyOptState(opt);\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+      if (PL_OPT_BAD == os) {\n+        continue;\n+      }\n+      switch (opt->option) {\n+        case 'd': /* debug */\n+          debug = 1;\n+          msgLevel = PR_LOG_ERROR;\n+          break;\n+        case 'h': /* help message */\n+          Help();\n+          break;\n+        default:\n+          break;\n+      }\n     }\n+    PL_DestroyOptState(opt);\n+  }\n \n-    lm = PR_NewLogModule(\"Test\"); /* Initialize logging */\n+  lm = PR_NewLogModule(\"Test\"); /* Initialize logging */\n \n-    /*\n-    ** First, open a file, PR_EXCL, we believe not to exist\n-    */\n-    fd = PR_Open(NEW_FILENAME, PR_CREATE_FILE | PR_EXCL | PR_WRONLY, 0666);\n-    if (NULL == fd) {\n-        if (debug) {\n-            fprintf(stderr, \"Open exclusive. Expected success, got failure\\n\");\n-        }\n-        failed_already = 1;\n-        goto Finished;\n+  /*\n+  ** First, open a file, PR_EXCL, we believe not to exist\n+  */\n+  fd = PR_Open(NEW_FILENAME, PR_CREATE_FILE | PR_EXCL | PR_WRONLY, 0666);\n+  if (NULL == fd) {\n+    if (debug) {\n+      fprintf(stderr, \"Open exclusive. Expected success, got failure\\n\");\n     }\n+    failed_already = 1;\n+    goto Finished;\n+  }\n \n-    written = PR_Write(fd, outBuf, OUT_SIZE);\n-    if (OUT_SIZE != written) {\n-        if (debug) {\n-            fprintf(stderr, \"Write after open exclusive failed\\n\");\n-        }\n-        failed_already = 1;\n-        goto Finished;\n+  written = PR_Write(fd, outBuf, OUT_SIZE);\n+  if (OUT_SIZE != written) {\n+    if (debug) {\n+      fprintf(stderr, \"Write after open exclusive failed\\n\");\n     }\n+    failed_already = 1;\n+    goto Finished;\n+  }\n \n-    rv = PR_Close(fd);\n-    if (PR_FAILURE == rv) {\n-        if (debug) {\n-            fprintf(stderr, \"Close after open exclusive failed\\n\");\n-        }\n-        failed_already = 1;\n-        goto Finished;\n+  rv = PR_Close(fd);\n+  if (PR_FAILURE == rv) {\n+    if (debug) {\n+      fprintf(stderr, \"Close after open exclusive failed\\n\");\n     }\n+    failed_already = 1;\n+    goto Finished;\n+  }\n \n-    /*\n-    ** Second, open the same file, PR_EXCL, expect it to fail\n-    */\n-    fd = PR_Open(NEW_FILENAME, PR_CREATE_FILE | PR_EXCL | PR_WRONLY, 0666);\n-    if (NULL != fd) {\n-        if (debug) {\n-            fprintf(stderr, \"Open exclusive. Expected failure, got success\\n\");\n-        }\n-        failed_already = 1;\n-        PR_Close(fd);\n+  /*\n+  ** Second, open the same file, PR_EXCL, expect it to fail\n+  */\n+  fd = PR_Open(NEW_FILENAME, PR_CREATE_FILE | PR_EXCL | PR_WRONLY, 0666);\n+  if (NULL != fd) {\n+    if (debug) {\n+      fprintf(stderr, \"Open exclusive. Expected failure, got success\\n\");\n     }\n+    failed_already = 1;\n+    PR_Close(fd);\n+  }\n \n-    rv = PR_Delete(NEW_FILENAME);\n-    if (PR_FAILURE == rv) {\n-        if (debug) {\n-            fprintf(stderr, \"PR_Delete() failed\\n\");\n-        }\n-        failed_already = 1;\n+  rv = PR_Delete(NEW_FILENAME);\n+  if (PR_FAILURE == rv) {\n+    if (debug) {\n+      fprintf(stderr, \"PR_Delete() failed\\n\");\n     }\n+    failed_already = 1;\n+  }\n \n Finished:\n-    if (debug) {\n-        printf(\"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n-    }\n-    return ((failed_already == PR_TRUE) ? 1 : 0);\n+  if (debug) {\n+    printf(\"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n+  }\n+  return ((failed_already == PR_TRUE) ? 1 : 0);\n } /* main() */\n /* end op_excl.c */\ndiff --git a/nspr/pr/tests/op_filnf.c b/nspr/pr/tests/op_filnf.c\nindex 7ca1ec9..64c51ce 100644\n--- a/nspr/pr/tests/op_filnf.c\n+++ b/nspr/pr/tests/op_filnf.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -27,23 +28,21 @@\n static PRFileDesc* t1;\n PRIntn error_code;\n \n-int\n-main(int argc, char** argv)\n-{\n-    t1 = PR_Open(\"./tmp-ttools/err03.tmp\", PR_TRUNCATE | PR_RDWR, 0666);\n-    if (t1 == NULL) {\n-        if (PR_GetError() == PR_FILE_NOT_FOUND_ERROR) {\n-            printf(\"error code is %d \\n\", PR_GetError());\n-            printf(\"PASS\\n\");\n-            return 0;\n-        } else {\n-            printf(\"error code is %d \\n\", PR_GetError());\n-            printf(\"FAIL\\n\");\n-            return 1;\n-        }\n+int main(int argc, char** argv) {\n+  t1 = PR_Open(\"./tmp-ttools/err03.tmp\", PR_TRUNCATE | PR_RDWR, 0666);\n+  if (t1 == NULL) {\n+    if (PR_GetError() == PR_FILE_NOT_FOUND_ERROR) {\n+      printf(\"error code is %d \\n\", PR_GetError());\n+      printf(\"PASS\\n\");\n+      return 0;\n+    } else {\n+      printf(\"error code is %d \\n\", PR_GetError());\n+      printf(\"FAIL\\n\");\n+      return 1;\n     }\n-    PR_Close(t1);\n-    printf(\"opened a file that should not exist\\n\");\n-    printf(\"FAIL\\n\");\n-    return 1;\n+  }\n+  PR_Close(t1);\n+  printf(\"opened a file that should not exist\\n\");\n+  printf(\"FAIL\\n\");\n+  return 1;\n }\ndiff --git a/nspr/pr/tests/op_filok.c b/nspr/pr/tests/op_filok.c\nindex 0c314bd..382e685 100644\n--- a/nspr/pr/tests/op_filok.c\n+++ b/nspr/pr/tests/op_filok.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -24,23 +25,22 @@\n \n static PRFileDesc* t1;\n \n-int\n-main(int argc, char** argv)\n-{\n-    t1 = PR_Open(argv[0], PR_RDONLY, 0666);\n+int main(int argc, char** argv) {\n \n-    if (t1 == NULL) {\n-        printf(\"error code is %d \\n\", PR_GetError());\n-        printf(\"File %s should be found\\n\", argv[0]);\n-        return 1;\n+  t1 = PR_Open(argv[0], PR_RDONLY, 0666);\n+\n+  if (t1 == NULL) {\n+    printf(\"error code is %d \\n\", PR_GetError());\n+    printf(\"File %s should be found\\n\", argv[0]);\n+    return 1;\n+  } else {\n+    if (PR_Close(t1) == PR_SUCCESS) {\n+      printf(\"Test passed \\n\");\n+      return 0;\n     } else {\n-        if (PR_Close(t1) == PR_SUCCESS) {\n-            printf(\"Test passed \\n\");\n-            return 0;\n-        } else {\n-            printf(\"cannot close file\\n\");\n-            printf(\"error code is %d\\n\", PR_GetError());\n-            return 1;\n-        }\n+      printf(\"cannot close file\\n\");\n+      printf(\"error code is %d\\n\", PR_GetError());\n+      return 1;\n     }\n+  }\n }\ndiff --git a/nspr/pr/tests/op_noacc.c b/nspr/pr/tests/op_noacc.c\nindex bf4a2bb..270c06e 100644\n--- a/nspr/pr/tests/op_noacc.c\n+++ b/nspr/pr/tests/op_noacc.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -26,25 +27,23 @@\n static PRFileDesc* err01;\n PRIntn error_code;\n \n-int\n-main(int argc, char** argv)\n-{\n+int main(int argc, char** argv) {\n #ifdef XP_PC\n-    printf(\n-        \"op_noacc: Test not valid on MS-Windows.\\n\\tNo concept of 'mode' on \"\n-        \"Open() call\\n\");\n-    return (0);\n+  printf(\n+      \"op_noacc: Test not valid on MS-Windows.\\n\\tNo concept of 'mode' on \"\n+      \"Open() call\\n\");\n+  return (0);\n #endif\n \n-    err01 = PR_Open(\"err01.tmp\", PR_CREATE_FILE | PR_RDWR, 0);\n-    if (err01 == NULL) {\n-        int error = PR_GetError();\n-        printf(\"error code is %d\\n\", error);\n-        if (error == PR_NO_ACCESS_RIGHTS_ERROR) {\n-            printf(\"PASS\\n\");\n-            return 0;\n-        }\n+  err01 = PR_Open(\"err01.tmp\", PR_CREATE_FILE | PR_RDWR, 0);\n+  if (err01 == NULL) {\n+    int error = PR_GetError();\n+    printf(\"error code is %d\\n\", error);\n+    if (error == PR_NO_ACCESS_RIGHTS_ERROR) {\n+      printf(\"PASS\\n\");\n+      return 0;\n     }\n-    printf(\"FAIL\\n\");\n-    return 1;\n+  }\n+  printf(\"FAIL\\n\");\n+  return 1;\n }\ndiff --git a/nspr/pr/tests/op_nofil.c b/nspr/pr/tests/op_nofil.c\nindex 6225e27..9e76d88 100644\n--- a/nspr/pr/tests/op_nofil.c\n+++ b/nspr/pr/tests/op_nofil.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -30,26 +31,24 @@\n \n static PRFileDesc* t1;\n \n-int\n-main(int argc, char** argv)\n-{\n-    t1 = PR_Open(NO_SUCH_FILE, PR_RDONLY, 0666);\n-    if (t1 == NULL) {\n-        if (PR_GetError() == PR_FILE_NOT_FOUND_ERROR) {\n-            printf(\"error code is PR_FILE_NOT_FOUND_ERROR, as expected\\n\");\n-            printf(\"PASS\\n\");\n-            return 0;\n-        } else {\n-            printf(\"error code is %d \\n\", PR_GetError());\n-            printf(\"FAIL\\n\");\n-            return 1;\n-        }\n+int main(int argc, char** argv) {\n+  t1 = PR_Open(NO_SUCH_FILE, PR_RDONLY, 0666);\n+  if (t1 == NULL) {\n+    if (PR_GetError() == PR_FILE_NOT_FOUND_ERROR) {\n+      printf(\"error code is PR_FILE_NOT_FOUND_ERROR, as expected\\n\");\n+      printf(\"PASS\\n\");\n+      return 0;\n+    } else {\n+      printf(\"error code is %d \\n\", PR_GetError());\n+      printf(\"FAIL\\n\");\n+      return 1;\n     }\n-    printf(\"File %s exists on this machine!?\\n\", NO_SUCH_FILE);\n-    if (PR_Close(t1) == PR_FAILURE) {\n-        printf(\"cannot close file\\n\");\n-        printf(\"error code is %d \\n\", PR_GetError());\n-    }\n-    printf(\"FAIL\\n\");\n-    return 1;\n+  }\n+  printf(\"File %s exists on this machine!?\\n\", NO_SUCH_FILE);\n+  if (PR_Close(t1) == PR_FAILURE) {\n+    printf(\"cannot close file\\n\");\n+    printf(\"error code is %d \\n\", PR_GetError());\n+  }\n+  printf(\"FAIL\\n\");\n+  return 1;\n }\ndiff --git a/nspr/pr/tests/openfile.c b/nspr/pr/tests/openfile.c\nindex b8ca2be..6e6965c 100644\n--- a/nspr/pr/tests/openfile.c\n+++ b/nspr/pr/tests/openfile.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -16,97 +17,95 @@\n \n #define TEMPLATE_FILE_NAME \"template.txt\"\n \n-int\n-main(int argc, char** argv)\n-{\n-    FILE* template;\n-    char buf[32];\n-    PRInt32 nbytes;\n-    PRFileDesc* fd;\n-\n-    /* Write in text mode.  Let stdio deal with line endings. */\n-    template = fopen(TEMPLATE_FILE_NAME, \"w\");\n-    fputs(\"line 1\\nline 2\\n\", template);\n-    fclose(template);\n-\n-    /* Read in binary mode */\n-    fd = PR_OpenFile(TEMPLATE_FILE_NAME, PR_RDONLY, 0666);\n-    nbytes = PR_Read(fd, buf, sizeof(buf));\n-    PR_Close(fd);\n-    PR_Delete(TEMPLATE_FILE_NAME);\n-\n-    fd = PR_OpenFile(\"tfil0700.txt\", PR_RDWR | PR_CREATE_FILE, 0700);\n-    if (NULL == fd) {\n-        fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    PR_Write(fd, buf, nbytes);\n-    PR_Close(fd);\n-\n-    fd = PR_OpenFile(\"tfil0500.txt\", PR_RDWR | PR_CREATE_FILE, 0500);\n-    if (NULL == fd) {\n-        fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    PR_Write(fd, buf, nbytes);\n-    PR_Close(fd);\n-\n-    fd = PR_OpenFile(\"tfil0400.txt\", PR_RDWR | PR_CREATE_FILE, 0400);\n-    if (NULL == fd) {\n-        fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    PR_Write(fd, buf, nbytes);\n-    PR_Close(fd);\n-\n-    fd = PR_OpenFile(\"tfil0644.txt\", PR_RDWR | PR_CREATE_FILE, 0644);\n-    if (NULL == fd) {\n-        fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    PR_Write(fd, buf, nbytes);\n-    PR_Close(fd);\n-\n-    fd = PR_OpenFile(\"tfil0664.txt\", PR_RDWR | PR_CREATE_FILE, 0664);\n-    if (NULL == fd) {\n-        fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    PR_Write(fd, buf, nbytes);\n-    PR_Close(fd);\n-\n-    fd = PR_OpenFile(\"tfil0660.txt\", PR_RDWR | PR_CREATE_FILE, 0660);\n-    if (NULL == fd) {\n-        fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    PR_Write(fd, buf, nbytes);\n-    PR_Close(fd);\n-\n-    fd = PR_OpenFile(\"tfil0666.txt\", PR_RDWR | PR_CREATE_FILE, 0666);\n-    if (NULL == fd) {\n-        fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    PR_Write(fd, buf, nbytes);\n-    PR_Close(fd);\n-\n-    fd = PR_OpenFile(\"tfil0640.txt\", PR_RDWR | PR_CREATE_FILE, 0640);\n-    if (NULL == fd) {\n-        fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    PR_Write(fd, buf, nbytes);\n-    PR_Close(fd);\n-\n-    PR_Cleanup();\n-    return 0;\n+int main(int argc, char** argv) {\n+  FILE* template;\n+  char buf[32];\n+  PRInt32 nbytes;\n+  PRFileDesc* fd;\n+\n+  /* Write in text mode.  Let stdio deal with line endings. */\n+  template = fopen(TEMPLATE_FILE_NAME, \"w\");\n+  fputs(\"line 1\\nline 2\\n\", template);\n+  fclose(template);\n+\n+  /* Read in binary mode */\n+  fd = PR_OpenFile(TEMPLATE_FILE_NAME, PR_RDONLY, 0666);\n+  nbytes = PR_Read(fd, buf, sizeof(buf));\n+  PR_Close(fd);\n+  PR_Delete(TEMPLATE_FILE_NAME);\n+\n+  fd = PR_OpenFile(\"tfil0700.txt\", PR_RDWR | PR_CREATE_FILE, 0700);\n+  if (NULL == fd) {\n+    fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  PR_Write(fd, buf, nbytes);\n+  PR_Close(fd);\n+\n+  fd = PR_OpenFile(\"tfil0500.txt\", PR_RDWR | PR_CREATE_FILE, 0500);\n+  if (NULL == fd) {\n+    fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  PR_Write(fd, buf, nbytes);\n+  PR_Close(fd);\n+\n+  fd = PR_OpenFile(\"tfil0400.txt\", PR_RDWR | PR_CREATE_FILE, 0400);\n+  if (NULL == fd) {\n+    fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  PR_Write(fd, buf, nbytes);\n+  PR_Close(fd);\n+\n+  fd = PR_OpenFile(\"tfil0644.txt\", PR_RDWR | PR_CREATE_FILE, 0644);\n+  if (NULL == fd) {\n+    fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  PR_Write(fd, buf, nbytes);\n+  PR_Close(fd);\n+\n+  fd = PR_OpenFile(\"tfil0664.txt\", PR_RDWR | PR_CREATE_FILE, 0664);\n+  if (NULL == fd) {\n+    fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  PR_Write(fd, buf, nbytes);\n+  PR_Close(fd);\n+\n+  fd = PR_OpenFile(\"tfil0660.txt\", PR_RDWR | PR_CREATE_FILE, 0660);\n+  if (NULL == fd) {\n+    fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  PR_Write(fd, buf, nbytes);\n+  PR_Close(fd);\n+\n+  fd = PR_OpenFile(\"tfil0666.txt\", PR_RDWR | PR_CREATE_FILE, 0666);\n+  if (NULL == fd) {\n+    fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  PR_Write(fd, buf, nbytes);\n+  PR_Close(fd);\n+\n+  fd = PR_OpenFile(\"tfil0640.txt\", PR_RDWR | PR_CREATE_FILE, 0640);\n+  if (NULL == fd) {\n+    fprintf(stderr, \"PR_OpenFile failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  PR_Write(fd, buf, nbytes);\n+  PR_Close(fd);\n+\n+  PR_Cleanup();\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/parent.c b/nspr/pr/tests/parent.c\nindex 52f6bc3..085b707 100644\n--- a/nspr/pr/tests/parent.c\n+++ b/nspr/pr/tests/parent.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -14,98 +15,94 @@\n #include \"prinrval.h\"\n \n typedef struct Child {\n-    const char* name;\n-    char** argv;\n-    PRProcess* process;\n-    PRProcessAttr* attr;\n+  const char* name;\n+  char** argv;\n+  PRProcess* process;\n+  PRProcessAttr* attr;\n } Child;\n \n /* for the default test 'cvar -c 2000' */\n-static char* default_argv[] = { \"cvar\", \"-c\", \"2000\", NULL };\n+static char* default_argv[] = {\"cvar\", \"-c\", \"2000\", NULL};\n \n-static void\n-PrintUsage(void)\n-{\n-    PR_fprintf(PR_GetSpecialFD(PR_StandardError),\n-               \"Usage: parent [-d] child [options]\\n\");\n+static void PrintUsage(void) {\n+  PR_fprintf(PR_GetSpecialFD(PR_StandardError),\n+             \"Usage: parent [-d] child [options]\\n\");\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRStatus rv;\n-    PRInt32 test_status = 1;\n-    PRIntervalTime t_start, t_elapsed;\n-    PRFileDesc* debug = NULL;\n-    Child* child = PR_NEWZAP(Child);\n-\n-    if (1 == argc) {\n-        /* no command-line arguments: run the default test */\n-        child->argv = default_argv;\n-    } else {\n-        argv += 1; /* don't care about our program name */\n-        while (*argv != NULL && argv[0][0] == '-') {\n-            if (argv[0][1] == 'd') {\n-                debug = PR_GetSpecialFD(PR_StandardError);\n-            } else {\n-                PrintUsage();\n-                return 2; /* not sufficient */\n-            }\n-            argv += 1;\n-        }\n-        child->argv = argv;\n-    }\n-\n-    if (NULL == *child->argv) {\n+int main(int argc, char** argv) {\n+  PRStatus rv;\n+  PRInt32 test_status = 1;\n+  PRIntervalTime t_start, t_elapsed;\n+  PRFileDesc* debug = NULL;\n+  Child* child = PR_NEWZAP(Child);\n+\n+  if (1 == argc) {\n+    /* no command-line arguments: run the default test */\n+    child->argv = default_argv;\n+  } else {\n+    argv += 1; /* don't care about our program name */\n+    while (*argv != NULL && argv[0][0] == '-') {\n+      if (argv[0][1] == 'd') {\n+        debug = PR_GetSpecialFD(PR_StandardError);\n+      } else {\n         PrintUsage();\n-        return 2;\n-    }\n-\n-    child->name = *child->argv;\n-    if (NULL != debug) {\n-        PR_fprintf(debug, \"Forking %s\\n\", child->name);\n+        return 2; /* not sufficient */\n+      }\n+      argv += 1;\n     }\n-\n-    child->attr = PR_NewProcessAttr();\n-    PR_ProcessAttrSetStdioRedirect(child->attr, PR_StandardOutput,\n-                                   PR_GetSpecialFD(PR_StandardOutput));\n-    PR_ProcessAttrSetStdioRedirect(child->attr, PR_StandardError,\n-                                   PR_GetSpecialFD(PR_StandardError));\n-\n-    t_start = PR_IntervalNow();\n-    child->process =\n-        PR_CreateProcess(child->name, child->argv, NULL, child->attr);\n-    t_elapsed = (PRIntervalTime)(PR_IntervalNow() - t_start);\n-\n-    PR_DestroyProcessAttr(child->attr);\n-\n-    test_status = (NULL == child->process) ? 1 : 0;\n+    child->argv = argv;\n+  }\n+\n+  if (NULL == *child->argv) {\n+    PrintUsage();\n+    return 2;\n+  }\n+\n+  child->name = *child->argv;\n+  if (NULL != debug) {\n+    PR_fprintf(debug, \"Forking %s\\n\", child->name);\n+  }\n+\n+  child->attr = PR_NewProcessAttr();\n+  PR_ProcessAttrSetStdioRedirect(child->attr, PR_StandardOutput,\n+                                 PR_GetSpecialFD(PR_StandardOutput));\n+  PR_ProcessAttrSetStdioRedirect(child->attr, PR_StandardError,\n+                                 PR_GetSpecialFD(PR_StandardError));\n+\n+  t_start = PR_IntervalNow();\n+  child->process =\n+      PR_CreateProcess(child->name, child->argv, NULL, child->attr);\n+  t_elapsed = (PRIntervalTime)(PR_IntervalNow() - t_start);\n+\n+  PR_DestroyProcessAttr(child->attr);\n+\n+  test_status = (NULL == child->process) ? 1 : 0;\n+  if (NULL != debug) {\n+    PR_fprintf(debug, \"Child was %sforked\\n\", (0 == test_status) ? \"\" : \"NOT \");\n+    if (0 == test_status)\n+      PR_fprintf(debug, \"PR_CreateProcess took %lu microseconds\\n\",\n+                 PR_IntervalToMicroseconds(t_elapsed));\n+  }\n+\n+  if (0 == test_status) {\n     if (NULL != debug) {\n-        PR_fprintf(debug, \"Child was %sforked\\n\", (0 == test_status) ? \"\" : \"NOT \");\n-        if (0 == test_status)\n-            PR_fprintf(debug, \"PR_CreateProcess took %lu microseconds\\n\",\n-                       PR_IntervalToMicroseconds(t_elapsed));\n+      PR_fprintf(debug, \"Waiting for child to exit\\n\");\n     }\n-\n-    if (0 == test_status) {\n-        if (NULL != debug) {\n-            PR_fprintf(debug, \"Waiting for child to exit\\n\");\n-        }\n-        rv = PR_WaitProcess(child->process, &test_status);\n-        if (PR_SUCCESS == rv) {\n-            if (NULL != debug)\n-                PR_fprintf(debug, \"Child exited %s\\n\",\n-                           (0 == test_status) ? \"successfully\" : \"with error\");\n-        } else {\n-            test_status = 1;\n-            if (NULL != debug) {\n-                PR_fprintf(debug, \"PR_WaitProcess failed\\n\");\n-            }\n-        }\n+    rv = PR_WaitProcess(child->process, &test_status);\n+    if (PR_SUCCESS == rv) {\n+      if (NULL != debug)\n+        PR_fprintf(debug, \"Child exited %s\\n\",\n+                   (0 == test_status) ? \"successfully\" : \"with error\");\n+    } else {\n+      test_status = 1;\n+      if (NULL != debug) {\n+        PR_fprintf(debug, \"PR_WaitProcess failed\\n\");\n+      }\n     }\n-    PR_DELETE(child);\n-    PR_Cleanup();\n-    return test_status;\n+  }\n+  PR_DELETE(child);\n+  PR_Cleanup();\n+  return test_status;\n \n } /* main */\n \ndiff --git a/nspr/pr/tests/parsetm.c b/nspr/pr/tests/parsetm.c\nindex ce2f8e8..54fa271 100644\n--- a/nspr/pr/tests/parsetm.c\n+++ b/nspr/pr/tests/parsetm.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,129 +12,123 @@\n \n PRBool debug_mode = PR_TRUE;\n \n-static char* dayOfWeek[] = { \"Sun\", \"Mon\", \"Tue\", \"Wed\",\n-                             \"Thu\", \"Fri\", \"Sat\", \"???\" };\n-static char* month[] = { \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\",\n-                         \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\", \"???\" };\n-\n-static void\n-PrintExplodedTime(const PRExplodedTime* et)\n-{\n-    PRInt32 totalOffset;\n-    PRInt32 hourOffset, minOffset;\n-    const char* sign;\n-\n-    /* Print day of the week, month, day, hour, minute, and second */\n-    if (debug_mode)\n-        printf(\"%s %s %ld %02ld:%02ld:%02ld \", dayOfWeek[et->tm_wday],\n-               month[et->tm_month], et->tm_mday, et->tm_hour, et->tm_min,\n-               et->tm_sec);\n-\n-    /* Print time zone */\n-    totalOffset = et->tm_params.tp_gmt_offset + et->tm_params.tp_dst_offset;\n-    if (totalOffset == 0) {\n-        if (debug_mode) {\n-            printf(\"UTC \");\n-        }\n-    } else {\n-        sign = \"+\";\n-        if (totalOffset < 0) {\n-            totalOffset = -totalOffset;\n-            sign = \"-\";\n-        }\n-        hourOffset = totalOffset / 3600;\n-        minOffset = (totalOffset % 3600) / 60;\n-        if (debug_mode) {\n-            printf(\"%s%02ld%02ld \", sign, hourOffset, minOffset);\n-        }\n+static char* dayOfWeek[] = {\"Sun\", \"Mon\", \"Tue\", \"Wed\",\n+                            \"Thu\", \"Fri\", \"Sat\", \"???\"};\n+static char* month[] = {\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\",\n+                        \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\", \"???\"};\n+\n+static void PrintExplodedTime(const PRExplodedTime* et) {\n+  PRInt32 totalOffset;\n+  PRInt32 hourOffset, minOffset;\n+  const char* sign;\n+\n+  /* Print day of the week, month, day, hour, minute, and second */\n+  if (debug_mode)\n+    printf(\"%s %s %ld %02ld:%02ld:%02ld \", dayOfWeek[et->tm_wday],\n+           month[et->tm_month], et->tm_mday, et->tm_hour, et->tm_min,\n+           et->tm_sec);\n+\n+  /* Print time zone */\n+  totalOffset = et->tm_params.tp_gmt_offset + et->tm_params.tp_dst_offset;\n+  if (totalOffset == 0) {\n+    if (debug_mode) {\n+      printf(\"UTC \");\n     }\n-\n-    /* Print year */\n+  } else {\n+    sign = \"+\";\n+    if (totalOffset < 0) {\n+      totalOffset = -totalOffset;\n+      sign = \"-\";\n+    }\n+    hourOffset = totalOffset / 3600;\n+    minOffset = (totalOffset % 3600) / 60;\n     if (debug_mode) {\n-        printf(\"%hd\", et->tm_year);\n+      printf(\"%s%02ld%02ld \", sign, hourOffset, minOffset);\n     }\n+  }\n+\n+  /* Print year */\n+  if (debug_mode) {\n+    printf(\"%hd\", et->tm_year);\n+  }\n }\n \n-static PRStatus\n-KnownAnswerTest(void)\n-{\n-    static const struct {\n-        const char* string;\n-        PRBool default_to_gmt;\n-        PRTime expected;\n-    } tests[] = {\n-        { \"Mon, 15 Oct 2007 19:45:00 GMT\", PR_FALSE, PR_INT64(1192477500000000) },\n-        { \"15 Oct 07 19:45 GMT\", PR_FALSE, PR_INT64(1192477500000000) },\n-        { \"Mon Oct 15 12:45 PDT 2007\", PR_FALSE, PR_INT64(1192477500000000) },\n-        { \"16 Oct 2007 4:45-JST (Tuesday)\", PR_FALSE, PR_INT64(1192477500000000) },\n-        // Not normalized.\n-        { \"Mon Oct 15 12:44:60 PDT 2007\", PR_FALSE, PR_INT64(1192477500000000) },\n-        // Not normalized.\n-        { \"Sun Oct 14 36:45 PDT 2007\", PR_FALSE, PR_INT64(1192477500000000) },\n-        { \"Mon, 15 Oct 2007 19:45:23 GMT\", PR_FALSE, PR_INT64(1192477523000000) },\n-    };\n-\n-    PRBool failed = PR_FALSE;\n-\n-    for (int i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {\n-        PRTime result = 0;\n-        if (PR_ParseTimeString(tests[i].string, tests[i].default_to_gmt, &result) !=\n-            PR_SUCCESS) {\n-            printf(\"PR_ParseTimeString(\\\"%s\\\", %s, &result) failed\\n\",\n-                   tests[i].string, tests[i].default_to_gmt ? \"PR_TRUE\" : \"PR_FALSE\");\n-            failed = PR_TRUE;\n-            continue;\n-        }\n-        if (result != tests[i].expected) {\n-            printf(\n-                \"PR_ParseTimeString(\\\"%s\\\", %s, &result) returns %lld, expected \"\n-                \"%lld\\n\",\n-                tests[i].string, tests[i].default_to_gmt ? \"PR_TRUE\" : \"PR_FALSE\",\n-                (long long)result, (long long)tests[i].expected);\n-            failed = PR_TRUE;\n-        }\n+static PRStatus KnownAnswerTest(void) {\n+  static const struct {\n+    const char* string;\n+    PRBool default_to_gmt;\n+    PRTime expected;\n+  } tests[] = {\n+      {\"Mon, 15 Oct 2007 19:45:00 GMT\", PR_FALSE, PR_INT64(1192477500000000)},\n+      {\"15 Oct 07 19:45 GMT\", PR_FALSE, PR_INT64(1192477500000000)},\n+      {\"Mon Oct 15 12:45 PDT 2007\", PR_FALSE, PR_INT64(1192477500000000)},\n+      {\"16 Oct 2007 4:45-JST (Tuesday)\", PR_FALSE, PR_INT64(1192477500000000)},\n+      // Not normalized.\n+      {\"Mon Oct 15 12:44:60 PDT 2007\", PR_FALSE, PR_INT64(1192477500000000)},\n+      // Not normalized.\n+      {\"Sun Oct 14 36:45 PDT 2007\", PR_FALSE, PR_INT64(1192477500000000)},\n+      {\"Mon, 15 Oct 2007 19:45:23 GMT\", PR_FALSE, PR_INT64(1192477523000000)},\n+  };\n+\n+  PRBool failed = PR_FALSE;\n+\n+  for (int i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {\n+    PRTime result = 0;\n+    if (PR_ParseTimeString(tests[i].string, tests[i].default_to_gmt, &result) !=\n+        PR_SUCCESS) {\n+      printf(\"PR_ParseTimeString(\\\"%s\\\", %s, &result) failed\\n\",\n+             tests[i].string, tests[i].default_to_gmt ? \"PR_TRUE\" : \"PR_FALSE\");\n+      failed = PR_TRUE;\n+      continue;\n     }\n+    if (result != tests[i].expected) {\n+      printf(\n+          \"PR_ParseTimeString(\\\"%s\\\", %s, &result) returns %lld, expected \"\n+          \"%lld\\n\",\n+          tests[i].string, tests[i].default_to_gmt ? \"PR_TRUE\" : \"PR_FALSE\",\n+          (long long)result, (long long)tests[i].expected);\n+      failed = PR_TRUE;\n+    }\n+  }\n \n-    return failed ? PR_FAILURE : PR_SUCCESS;\n+  return failed ? PR_FAILURE : PR_SUCCESS;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    /*\n-     * 1. Verify that PR_ParseTimeString doesn't crash on an out-of-range time\n-     * string (bug 480740).\n-     */\n-    PRTime ct;\n-    PRExplodedTime et;\n-    PRStatus rv;\n-    char* sp1 = \"Sat, 1 Jan 3001 00:00:00\";  /* no time zone */\n-    char* sp2 = \"Fri, 31 Dec 3000 23:59:60\"; /* no time zone, not normalized */\n+int main(int argc, char** argv) {\n+  /*\n+   * 1. Verify that PR_ParseTimeString doesn't crash on an out-of-range time\n+   * string (bug 480740).\n+   */\n+  PRTime ct;\n+  PRExplodedTime et;\n+  PRStatus rv;\n+  char* sp1 = \"Sat, 1 Jan 3001 00:00:00\";  /* no time zone */\n+  char* sp2 = \"Fri, 31 Dec 3000 23:59:60\"; /* no time zone, not normalized */\n \n #if _MSC_VER >= 1400 && !defined(WINCE)\n-    /* Run this test in the US Pacific Time timezone. */\n-    _putenv_s(\"TZ\", \"PST8PDT\");\n-    _tzset();\n+  /* Run this test in the US Pacific Time timezone. */\n+  _putenv_s(\"TZ\", \"PST8PDT\");\n+  _tzset();\n #endif\n \n-    rv = PR_ParseTimeString(sp1, PR_FALSE, &ct);\n-    printf(\"rv = %d\\n\", rv);\n-    PR_ExplodeTime(ct, PR_GMTParameters, &et);\n-    PrintExplodedTime(&et);\n-    printf(\"\\n\");\n-\n-    rv = PR_ParseTimeString(sp2, PR_FALSE, &ct);\n-    printf(\"rv = %d\\n\", rv);\n-    PR_ExplodeTime(ct, PR_GMTParameters, &et);\n-    PrintExplodedTime(&et);\n-    printf(\"\\n\");\n-\n-    /* 2. Run a full-blown test for PR_ParseTimeString. */\n-    if (KnownAnswerTest() != PR_SUCCESS) {\n-        printf(\"FAIL\\n\");\n-        return 1;\n-    }\n-\n-    printf(\"PASS\\n\");\n-    return 0;\n+  rv = PR_ParseTimeString(sp1, PR_FALSE, &ct);\n+  printf(\"rv = %d\\n\", rv);\n+  PR_ExplodeTime(ct, PR_GMTParameters, &et);\n+  PrintExplodedTime(&et);\n+  printf(\"\\n\");\n+\n+  rv = PR_ParseTimeString(sp2, PR_FALSE, &ct);\n+  printf(\"rv = %d\\n\", rv);\n+  PR_ExplodeTime(ct, PR_GMTParameters, &et);\n+  PrintExplodedTime(&et);\n+  printf(\"\\n\");\n+\n+  /* 2. Run a full-blown test for PR_ParseTimeString. */\n+  if (KnownAnswerTest() != PR_SUCCESS) {\n+    printf(\"FAIL\\n\");\n+    return 1;\n+  }\n+\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/peek.c b/nspr/pr/tests/peek.c\nindex 1b2a527..468bfa9 100644\n--- a/nspr/pr/tests/peek.c\n+++ b/nspr/pr/tests/peek.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -28,328 +29,320 @@ static int iterations = 10;\n  *     send_amount[i] <= BUFFER_SIZE,\n  *     send_amount[i] <= recv_amount[i].\n  */\n-static PRInt32 recv_amount[10] = { 16, 128, 256, 1024, 512,\n-                                   512, 128, 256, 32, 32 };\n-static PRInt32 send_amount[10] = { 16, 64, 128, 1024, 512, 256, 128, 64, 16, 32 };\n+static PRInt32 recv_amount[10] = {16,  128, 256, 1024, 512,\n+                                  512, 128, 256, 32,   32};\n+static PRInt32 send_amount[10] = {16, 64, 128, 1024, 512, 256, 128, 64, 16, 32};\n \n /* Blocking I/O */\n-static void\n-ServerB(void* arg)\n-{\n-    PRFileDesc* listenSock = (PRFileDesc*)arg;\n-    PRFileDesc* sock;\n-    char buf[BUFFER_SIZE];\n-    PRInt32 nbytes;\n-    int i;\n-    int j;\n+static void ServerB(void* arg) {\n+  PRFileDesc* listenSock = (PRFileDesc*)arg;\n+  PRFileDesc* sock;\n+  char buf[BUFFER_SIZE];\n+  PRInt32 nbytes;\n+  int i;\n+  int j;\n \n-    sock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n-    if (NULL == sock) {\n-        fprintf(stderr, \"PR_Accept failed\\n\");\n+  sock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n+  if (NULL == sock) {\n+    fprintf(stderr, \"PR_Accept failed\\n\");\n+    exit(1);\n+  }\n+\n+  for (i = 0; i < iterations; i++) {\n+    memset(buf, 0, sizeof(buf));\n+    nbytes =\n+        PR_Recv(sock, buf, recv_amount[i], PR_MSG_PEEK, PR_INTERVAL_NO_TIMEOUT);\n+    if (-1 == nbytes) {\n+      fprintf(stderr, \"PR_Recv failed\\n\");\n+      exit(1);\n+    }\n+    if (send_amount[i] != nbytes) {\n+      fprintf(stderr, \"PR_Recv returned %d, absurd!\\n\", nbytes);\n+      exit(1);\n+    }\n+    for (j = 0; j < nbytes; j++) {\n+      if (buf[j] != 2 * i) {\n+        fprintf(stderr, \"byte %d should be %d but is %d\\n\", j, 2 * i, buf[j]);\n         exit(1);\n+      }\n     }\n+    fprintf(stderr, \"server: peeked expected data\\n\");\n \n-    for (i = 0; i < iterations; i++) {\n-        memset(buf, 0, sizeof(buf));\n-        nbytes =\n-            PR_Recv(sock, buf, recv_amount[i], PR_MSG_PEEK, PR_INTERVAL_NO_TIMEOUT);\n-        if (-1 == nbytes) {\n-            fprintf(stderr, \"PR_Recv failed\\n\");\n-            exit(1);\n-        }\n-        if (send_amount[i] != nbytes) {\n-            fprintf(stderr, \"PR_Recv returned %d, absurd!\\n\", nbytes);\n-            exit(1);\n-        }\n-        for (j = 0; j < nbytes; j++) {\n-            if (buf[j] != 2 * i) {\n-                fprintf(stderr, \"byte %d should be %d but is %d\\n\", j, 2 * i, buf[j]);\n-                exit(1);\n-            }\n-        }\n-        fprintf(stderr, \"server: peeked expected data\\n\");\n-\n-        memset(buf, 0, sizeof(buf));\n-        nbytes =\n-            PR_Recv(sock, buf, recv_amount[i], PR_MSG_PEEK, PR_INTERVAL_NO_TIMEOUT);\n-        if (-1 == nbytes) {\n-            fprintf(stderr, \"PR_Recv failed\\n\");\n-            exit(1);\n-        }\n-        if (send_amount[i] != nbytes) {\n-            fprintf(stderr, \"PR_Recv returned %d, absurd!\\n\", nbytes);\n-            exit(1);\n-        }\n-        for (j = 0; j < nbytes; j++) {\n-            if (buf[j] != 2 * i) {\n-                fprintf(stderr, \"byte %d should be %d but is %d\\n\", j, 2 * i, buf[j]);\n-                exit(1);\n-            }\n-        }\n-        fprintf(stderr, \"server: peeked expected data\\n\");\n-\n-        memset(buf, 0, sizeof(buf));\n-        nbytes = PR_Recv(sock, buf, recv_amount[i], 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (-1 == nbytes) {\n-            fprintf(stderr, \"PR_Recv failed\\n\");\n-            exit(1);\n-        }\n-        if (send_amount[i] != nbytes) {\n-            fprintf(stderr, \"PR_Recv returned %d, absurd!\\n\", nbytes);\n-            exit(1);\n-        }\n-        for (j = 0; j < nbytes; j++) {\n-            if (buf[j] != 2 * i) {\n-                fprintf(stderr, \"byte %d should be %d but is %d\\n\", j, 2 * i, buf[j]);\n-                exit(1);\n-            }\n-        }\n-        fprintf(stderr, \"server: received expected data\\n\");\n-\n-        PR_Sleep(PR_SecondsToInterval(1));\n-        memset(buf, 2 * i + 1, send_amount[i]);\n-        nbytes = PR_Send(sock, buf, send_amount[i], 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (-1 == nbytes) {\n-            fprintf(stderr, \"PR_Send failed\\n\");\n-            exit(1);\n-        }\n-        if (send_amount[i] != nbytes) {\n-            fprintf(stderr, \"PR_Send returned %d, absurd!\\n\", nbytes);\n-            exit(1);\n-        }\n+    memset(buf, 0, sizeof(buf));\n+    nbytes =\n+        PR_Recv(sock, buf, recv_amount[i], PR_MSG_PEEK, PR_INTERVAL_NO_TIMEOUT);\n+    if (-1 == nbytes) {\n+      fprintf(stderr, \"PR_Recv failed\\n\");\n+      exit(1);\n     }\n-    if (PR_Close(sock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n+    if (send_amount[i] != nbytes) {\n+      fprintf(stderr, \"PR_Recv returned %d, absurd!\\n\", nbytes);\n+      exit(1);\n+    }\n+    for (j = 0; j < nbytes; j++) {\n+      if (buf[j] != 2 * i) {\n+        fprintf(stderr, \"byte %d should be %d but is %d\\n\", j, 2 * i, buf[j]);\n         exit(1);\n+      }\n     }\n-}\n-\n-/* Non-blocking I/O */\n-static void\n-ClientNB(void* arg)\n-{\n-    PRFileDesc* sock;\n-    PRSocketOptionData opt;\n-    PRUint16 port = (PRUint16)arg;\n-    PRNetAddr addr;\n-    char buf[BUFFER_SIZE];\n-    PRPollDesc pd;\n-    PRInt32 npds;\n-    PRInt32 nbytes;\n-    int i;\n-    int j;\n+    fprintf(stderr, \"server: peeked expected data\\n\");\n \n-    sock = PR_OpenTCPSocket(PR_AF_INET6);\n-    if (NULL == sock) {\n-        fprintf(stderr, \"PR_OpenTCPSocket failed\\n\");\n-        exit(1);\n+    memset(buf, 0, sizeof(buf));\n+    nbytes = PR_Recv(sock, buf, recv_amount[i], 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (-1 == nbytes) {\n+      fprintf(stderr, \"PR_Recv failed\\n\");\n+      exit(1);\n     }\n-    opt.option = PR_SockOpt_Nonblocking;\n-    opt.value.non_blocking = PR_TRUE;\n-    if (PR_SetSocketOption(sock, &opt) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetSocketOption failed\\n\");\n-        exit(1);\n+    if (send_amount[i] != nbytes) {\n+      fprintf(stderr, \"PR_Recv returned %d, absurd!\\n\", nbytes);\n+      exit(1);\n     }\n-    memset(&addr, 0, sizeof(addr));\n-    if (PR_SetNetAddr(PR_IpAddrLoopback, PR_AF_INET6, port, &addr) ==\n-        PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n+    for (j = 0; j < nbytes; j++) {\n+      if (buf[j] != 2 * i) {\n+        fprintf(stderr, \"byte %d should be %d but is %d\\n\", j, 2 * i, buf[j]);\n         exit(1);\n+      }\n     }\n-    if (PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n-        if (PR_GetError() != PR_IN_PROGRESS_ERROR) {\n-            fprintf(stderr, \"PR_Connect failed\\n\");\n-            exit(1);\n-        }\n-        pd.fd = sock;\n-        pd.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;\n-        npds = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n-        if (-1 == npds) {\n-            fprintf(stderr, \"PR_Poll failed\\n\");\n-            exit(1);\n-        }\n-        if (1 != npds) {\n-            fprintf(stderr, \"PR_Poll returned %d, absurd!\\n\", npds);\n-            exit(1);\n-        }\n-        if (PR_GetConnectStatus(&pd) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_GetConnectStatus failed\\n\");\n-            exit(1);\n-        }\n-    }\n-\n-    for (i = 0; i < iterations; i++) {\n-        PR_Sleep(PR_SecondsToInterval(1));\n-        memset(buf, 2 * i, send_amount[i]);\n-        while ((nbytes = PR_Send(sock, buf, send_amount[i], 0,\n-                                 PR_INTERVAL_NO_TIMEOUT)) == -1) {\n-            if (PR_GetError() != PR_WOULD_BLOCK_ERROR) {\n-                fprintf(stderr, \"PR_Send failed\\n\");\n-                exit(1);\n-            }\n-            pd.fd = sock;\n-            pd.in_flags = PR_POLL_WRITE;\n-            npds = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n-            if (-1 == npds) {\n-                fprintf(stderr, \"PR_Poll failed\\n\");\n-                exit(1);\n-            }\n-            if (1 != npds) {\n-                fprintf(stderr, \"PR_Poll returned %d, absurd!\\n\", npds);\n-                exit(1);\n-            }\n-        }\n-        if (send_amount[i] != nbytes) {\n-            fprintf(stderr, \"PR_Send returned %d, absurd!\\n\", nbytes);\n-            exit(1);\n-        }\n-\n-        memset(buf, 0, sizeof(buf));\n-        while ((nbytes = PR_Recv(sock, buf, recv_amount[i], PR_MSG_PEEK,\n-                                 PR_INTERVAL_NO_TIMEOUT)) == -1) {\n-            if (PR_GetError() != PR_WOULD_BLOCK_ERROR) {\n-                fprintf(stderr, \"PR_Recv failed\\n\");\n-                exit(1);\n-            }\n-            pd.fd = sock;\n-            pd.in_flags = PR_POLL_READ;\n-            npds = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n-            if (-1 == npds) {\n-                fprintf(stderr, \"PR_Poll failed\\n\");\n-                exit(1);\n-            }\n-            if (1 != npds) {\n-                fprintf(stderr, \"PR_Poll returned %d, absurd!\\n\", npds);\n-                exit(1);\n-            }\n-        }\n-        if (send_amount[i] != nbytes) {\n-            fprintf(stderr, \"PR_Recv returned %d, absurd!\\n\", nbytes);\n-            exit(1);\n-        }\n-        for (j = 0; j < nbytes; j++) {\n-            if (buf[j] != 2 * i + 1) {\n-                fprintf(stderr, \"byte %d should be %d but is %d\\n\", j, 2 * i + 1,\n-                        buf[j]);\n-                exit(1);\n-            }\n-        }\n-        fprintf(stderr, \"client: peeked expected data\\n\");\n+    fprintf(stderr, \"server: received expected data\\n\");\n \n-        memset(buf, 0, sizeof(buf));\n-        nbytes =\n-            PR_Recv(sock, buf, recv_amount[i], PR_MSG_PEEK, PR_INTERVAL_NO_TIMEOUT);\n-        if (-1 == nbytes) {\n-            fprintf(stderr, \"PR_Recv failed\\n\");\n-            exit(1);\n-        }\n-        if (send_amount[i] != nbytes) {\n-            fprintf(stderr, \"PR_Recv returned %d, absurd!\\n\", nbytes);\n-            exit(1);\n-        }\n-        for (j = 0; j < nbytes; j++) {\n-            if (buf[j] != 2 * i + 1) {\n-                fprintf(stderr, \"byte %d should be %d but is %d\\n\", j, 2 * i + 1,\n-                        buf[j]);\n-                exit(1);\n-            }\n-        }\n-        fprintf(stderr, \"client: peeked expected data\\n\");\n-\n-        memset(buf, 0, sizeof(buf));\n-        nbytes = PR_Recv(sock, buf, recv_amount[i], 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (-1 == nbytes) {\n-            fprintf(stderr, \"PR_Recv failed\\n\");\n-            exit(1);\n-        }\n-        if (send_amount[i] != nbytes) {\n-            fprintf(stderr, \"PR_Recv returned %d, absurd!\\n\", nbytes);\n-            exit(1);\n-        }\n-        for (j = 0; j < nbytes; j++) {\n-            if (buf[j] != 2 * i + 1) {\n-                fprintf(stderr, \"byte %d should be %d but is %d\\n\", j, 2 * i + 1,\n-                        buf[j]);\n-                exit(1);\n-            }\n-        }\n-        fprintf(stderr, \"client: received expected data\\n\");\n+    PR_Sleep(PR_SecondsToInterval(1));\n+    memset(buf, 2 * i + 1, send_amount[i]);\n+    nbytes = PR_Send(sock, buf, send_amount[i], 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (-1 == nbytes) {\n+      fprintf(stderr, \"PR_Send failed\\n\");\n+      exit(1);\n     }\n-    if (PR_Close(sock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n+    if (send_amount[i] != nbytes) {\n+      fprintf(stderr, \"PR_Send returned %d, absurd!\\n\", nbytes);\n+      exit(1);\n     }\n+  }\n+  if (PR_Close(sock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n }\n \n-static void\n-RunTest(PRThreadScope scope, PRFileDesc* listenSock,\n-        PRUint16 port)\n-{\n-    PRThread *server, *client;\n+/* Non-blocking I/O */\n+static void ClientNB(void* arg) {\n+  PRFileDesc* sock;\n+  PRSocketOptionData opt;\n+  PRUint16 port = (PRUint16)arg;\n+  PRNetAddr addr;\n+  char buf[BUFFER_SIZE];\n+  PRPollDesc pd;\n+  PRInt32 npds;\n+  PRInt32 nbytes;\n+  int i;\n+  int j;\n \n-    server = PR_CreateThread(PR_USER_THREAD, ServerB, listenSock,\n-                             PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n-    if (NULL == server) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n+  sock = PR_OpenTCPSocket(PR_AF_INET6);\n+  if (NULL == sock) {\n+    fprintf(stderr, \"PR_OpenTCPSocket failed\\n\");\n+    exit(1);\n+  }\n+  opt.option = PR_SockOpt_Nonblocking;\n+  opt.value.non_blocking = PR_TRUE;\n+  if (PR_SetSocketOption(sock, &opt) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetSocketOption failed\\n\");\n+    exit(1);\n+  }\n+  memset(&addr, 0, sizeof(addr));\n+  if (PR_SetNetAddr(PR_IpAddrLoopback, PR_AF_INET6, port, &addr) ==\n+      PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n+    if (PR_GetError() != PR_IN_PROGRESS_ERROR) {\n+      fprintf(stderr, \"PR_Connect failed\\n\");\n+      exit(1);\n     }\n-    client = PR_CreateThread(PR_USER_THREAD, ClientNB, (void*)port,\n-                             PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n-    if (NULL == client) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n+    pd.fd = sock;\n+    pd.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;\n+    npds = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n+    if (-1 == npds) {\n+      fprintf(stderr, \"PR_Poll failed\\n\");\n+      exit(1);\n+    }\n+    if (1 != npds) {\n+      fprintf(stderr, \"PR_Poll returned %d, absurd!\\n\", npds);\n+      exit(1);\n     }\n+    if (PR_GetConnectStatus(&pd) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_GetConnectStatus failed\\n\");\n+      exit(1);\n+    }\n+  }\n \n-    if (PR_JoinThread(server) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n+  for (i = 0; i < iterations; i++) {\n+    PR_Sleep(PR_SecondsToInterval(1));\n+    memset(buf, 2 * i, send_amount[i]);\n+    while ((nbytes = PR_Send(sock, buf, send_amount[i], 0,\n+                             PR_INTERVAL_NO_TIMEOUT)) == -1) {\n+      if (PR_GetError() != PR_WOULD_BLOCK_ERROR) {\n+        fprintf(stderr, \"PR_Send failed\\n\");\n         exit(1);\n-    }\n-    if (PR_JoinThread(client) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n+      }\n+      pd.fd = sock;\n+      pd.in_flags = PR_POLL_WRITE;\n+      npds = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n+      if (-1 == npds) {\n+        fprintf(stderr, \"PR_Poll failed\\n\");\n         exit(1);\n+      }\n+      if (1 != npds) {\n+        fprintf(stderr, \"PR_Poll returned %d, absurd!\\n\", npds);\n+        exit(1);\n+      }\n+    }\n+    if (send_amount[i] != nbytes) {\n+      fprintf(stderr, \"PR_Send returned %d, absurd!\\n\", nbytes);\n+      exit(1);\n     }\n-}\n-\n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc* listenSock;\n-    PRNetAddr addr;\n-    PRUint16 port;\n \n-    listenSock = PR_OpenTCPSocket(PR_AF_INET6);\n-    if (NULL == listenSock) {\n-        fprintf(stderr, \"PR_OpenTCPSocket failed\\n\");\n+    memset(buf, 0, sizeof(buf));\n+    while ((nbytes = PR_Recv(sock, buf, recv_amount[i], PR_MSG_PEEK,\n+                             PR_INTERVAL_NO_TIMEOUT)) == -1) {\n+      if (PR_GetError() != PR_WOULD_BLOCK_ERROR) {\n+        fprintf(stderr, \"PR_Recv failed\\n\");\n         exit(1);\n-    }\n-    memset(&addr, 0, sizeof(addr));\n-    if (PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, 0, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n+      }\n+      pd.fd = sock;\n+      pd.in_flags = PR_POLL_READ;\n+      npds = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n+      if (-1 == npds) {\n+        fprintf(stderr, \"PR_Poll failed\\n\");\n         exit(1);\n-    }\n-    if (PR_Bind(listenSock, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Bind failed\\n\");\n+      }\n+      if (1 != npds) {\n+        fprintf(stderr, \"PR_Poll returned %d, absurd!\\n\", npds);\n         exit(1);\n+      }\n     }\n-    if (PR_GetSockName(listenSock, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        exit(1);\n+    if (send_amount[i] != nbytes) {\n+      fprintf(stderr, \"PR_Recv returned %d, absurd!\\n\", nbytes);\n+      exit(1);\n     }\n-    port = PR_ntohs(addr.ipv6.port);\n-    if (PR_Listen(listenSock, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Listen failed\\n\");\n+    for (j = 0; j < nbytes; j++) {\n+      if (buf[j] != 2 * i + 1) {\n+        fprintf(stderr, \"byte %d should be %d but is %d\\n\", j, 2 * i + 1,\n+                buf[j]);\n         exit(1);\n+      }\n     }\n+    fprintf(stderr, \"client: peeked expected data\\n\");\n \n-    fprintf(stderr, \"Running the test with local threads\\n\");\n-    RunTest(PR_LOCAL_THREAD, listenSock, port);\n-    fprintf(stderr, \"Running the test with global threads\\n\");\n-    RunTest(PR_GLOBAL_THREAD, listenSock, port);\n+    memset(buf, 0, sizeof(buf));\n+    nbytes =\n+        PR_Recv(sock, buf, recv_amount[i], PR_MSG_PEEK, PR_INTERVAL_NO_TIMEOUT);\n+    if (-1 == nbytes) {\n+      fprintf(stderr, \"PR_Recv failed\\n\");\n+      exit(1);\n+    }\n+    if (send_amount[i] != nbytes) {\n+      fprintf(stderr, \"PR_Recv returned %d, absurd!\\n\", nbytes);\n+      exit(1);\n+    }\n+    for (j = 0; j < nbytes; j++) {\n+      if (buf[j] != 2 * i + 1) {\n+        fprintf(stderr, \"byte %d should be %d but is %d\\n\", j, 2 * i + 1,\n+                buf[j]);\n+        exit(1);\n+      }\n+    }\n+    fprintf(stderr, \"client: peeked expected data\\n\");\n \n-    if (PR_Close(listenSock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n+    memset(buf, 0, sizeof(buf));\n+    nbytes = PR_Recv(sock, buf, recv_amount[i], 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (-1 == nbytes) {\n+      fprintf(stderr, \"PR_Recv failed\\n\");\n+      exit(1);\n+    }\n+    if (send_amount[i] != nbytes) {\n+      fprintf(stderr, \"PR_Recv returned %d, absurd!\\n\", nbytes);\n+      exit(1);\n+    }\n+    for (j = 0; j < nbytes; j++) {\n+      if (buf[j] != 2 * i + 1) {\n+        fprintf(stderr, \"byte %d should be %d but is %d\\n\", j, 2 * i + 1,\n+                buf[j]);\n         exit(1);\n+      }\n     }\n-    printf(\"PASS\\n\");\n-    return 0;\n+    fprintf(stderr, \"client: received expected data\\n\");\n+  }\n+  if (PR_Close(sock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+}\n+\n+static void RunTest(PRThreadScope scope, PRFileDesc* listenSock,\n+                    PRUint16 port) {\n+  PRThread *server, *client;\n+\n+  server = PR_CreateThread(PR_USER_THREAD, ServerB, listenSock,\n+                           PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n+  if (NULL == server) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n+  client = PR_CreateThread(PR_USER_THREAD, ClientNB, (void*)port,\n+                           PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n+  if (NULL == client) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n+\n+  if (PR_JoinThread(server) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_JoinThread(client) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+}\n+\n+int main(int argc, char** argv) {\n+  PRFileDesc* listenSock;\n+  PRNetAddr addr;\n+  PRUint16 port;\n+\n+  listenSock = PR_OpenTCPSocket(PR_AF_INET6);\n+  if (NULL == listenSock) {\n+    fprintf(stderr, \"PR_OpenTCPSocket failed\\n\");\n+    exit(1);\n+  }\n+  memset(&addr, 0, sizeof(addr));\n+  if (PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, 0, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Bind(listenSock, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Bind failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_GetSockName(listenSock, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    exit(1);\n+  }\n+  port = PR_ntohs(addr.ipv6.port);\n+  if (PR_Listen(listenSock, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Listen failed\\n\");\n+    exit(1);\n+  }\n+\n+  fprintf(stderr, \"Running the test with local threads\\n\");\n+  RunTest(PR_LOCAL_THREAD, listenSock, port);\n+  fprintf(stderr, \"Running the test with global threads\\n\");\n+  RunTest(PR_GLOBAL_THREAD, listenSock, port);\n+\n+  if (PR_Close(listenSock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/perf.c b/nspr/pr/tests/perf.c\nindex bf289ed..e3e4a39 100644\n--- a/nspr/pr/tests/perf.c\n+++ b/nspr/pr/tests/perf.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,8 +12,7 @@\n \n int _debug_on = 0;\n #define DPRINTF(arg) \\\n-    if (_debug_on)   \\\n-    printf arg\n+  if (_debug_on) printf arg\n \n #include \"obsolete/prsem.h\"\n \n@@ -24,422 +24,370 @@ PRMonitor* mon2;\n \n PRInt32 count;\n \n-static void\n-nop(int a, int b, int c)\n-{\n-}\n+static void nop(int a, int b, int c) {}\n \n-static void\n-LocalProcedureCall(void)\n-{\n-    PRInt32 i;\n+static void LocalProcedureCall(void) {\n+  PRInt32 i;\n \n-    for (i = 0; i < count; i++) {\n-        nop(i, i, 5);\n-    }\n+  for (i = 0; i < count; i++) {\n+    nop(i, i, 5);\n+  }\n }\n \n-static void\n-DLLProcedureCall(void)\n-{\n-    PRInt32 i;\n-    PRThreadState state;\n-    PRThread* self = PR_GetCurrentThread();\n+static void DLLProcedureCall(void) {\n+  PRInt32 i;\n+  PRThreadState state;\n+  PRThread* self = PR_GetCurrentThread();\n \n-    for (i = 0; i < count; i++) {\n-        state = PR_GetThreadState(self);\n-    }\n+  for (i = 0; i < count; i++) {\n+    state = PR_GetThreadState(self);\n+  }\n }\n \n-static void\n-Now(void)\n-{\n-    PRInt32 i;\n-    PRTime time;\n+static void Now(void) {\n+  PRInt32 i;\n+  PRTime time;\n \n-    for (i = 0; i < count; i++) {\n-        time = PR_Now();\n-    }\n+  for (i = 0; i < count; i++) {\n+    time = PR_Now();\n+  }\n }\n \n-static void\n-Interval(void)\n-{\n-    PRInt32 i;\n-    PRIntervalTime time;\n+static void Interval(void) {\n+  PRInt32 i;\n+  PRIntervalTime time;\n \n-    for (i = 0; i < count; i++) {\n-        time = PR_IntervalNow();\n-    }\n+  for (i = 0; i < count; i++) {\n+    time = PR_IntervalNow();\n+  }\n }\n \n-static void\n-IdleLock(void)\n-{\n-    PRInt32 i;\n+static void IdleLock(void) {\n+  PRInt32 i;\n \n-    for (i = 0; i < count; i++) {\n-        PR_Lock(lock);\n-        PR_Unlock(lock);\n-    }\n+  for (i = 0; i < count; i++) {\n+    PR_Lock(lock);\n+    PR_Unlock(lock);\n+  }\n }\n \n-static void\n-IdleMonitor(void)\n-{\n-    PRInt32 i;\n+static void IdleMonitor(void) {\n+  PRInt32 i;\n \n-    for (i = 0; i < count; i++) {\n-        PR_EnterMonitor(mon);\n-        PR_ExitMonitor(mon);\n-    }\n+  for (i = 0; i < count; i++) {\n+    PR_EnterMonitor(mon);\n+    PR_ExitMonitor(mon);\n+  }\n }\n \n-static void\n-IdleCMonitor(void)\n-{\n-    PRInt32 i;\n+static void IdleCMonitor(void) {\n+  PRInt32 i;\n \n-    for (i = 0; i < count; i++) {\n-        PR_CEnterMonitor((void*)7);\n-        PR_CExitMonitor((void*)7);\n-    }\n+  for (i = 0; i < count; i++) {\n+    PR_CEnterMonitor((void*)7);\n+    PR_CExitMonitor((void*)7);\n+  }\n }\n \n /************************************************************************/\n \n-static void PR_CALLBACK\n-dull(void* arg)\n-{\n-}\n+static void PR_CALLBACK dull(void* arg) {}\n \n-static void\n-CDThread(void)\n-{\n-    PRInt32 i;\n-    int num_threads = count;\n-\n-    /*\n-     * Cannot create too many threads\n-     */\n-    if (num_threads > 1000) {\n-        num_threads = 1000;\n-    }\n+static void CDThread(void) {\n+  PRInt32 i;\n+  int num_threads = count;\n+\n+  /*\n+   * Cannot create too many threads\n+   */\n+  if (num_threads > 1000) {\n+    num_threads = 1000;\n+  }\n \n-    for (i = 0; i < num_threads; i++) {\n-        PRThread* t = PR_CreateThread(PR_USER_THREAD, dull, 0, PR_PRIORITY_NORMAL,\n-                                      PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-        if (NULL == t) {\n-            fprintf(stderr, \"CDThread: cannot create thread %3d\\n\", i);\n-        } else {\n-            DPRINTF((\"CDThread: created thread %3d \\n\", i));\n-        }\n-        PR_Sleep(0);\n+  for (i = 0; i < num_threads; i++) {\n+    PRThread* t = PR_CreateThread(PR_USER_THREAD, dull, 0, PR_PRIORITY_NORMAL,\n+                                  PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+    if (NULL == t) {\n+      fprintf(stderr, \"CDThread: cannot create thread %3d\\n\", i);\n+    } else {\n+      DPRINTF((\"CDThread: created thread %3d \\n\", i));\n     }\n+    PR_Sleep(0);\n+  }\n }\n \n static int alive;\n static int cxq;\n \n-static void PR_CALLBACK\n-CXReader(void* arg)\n-{\n-    PRInt32 i, n;\n+static void PR_CALLBACK CXReader(void* arg) {\n+  PRInt32 i, n;\n \n-    PR_EnterMonitor(mon);\n-    n = count / 2;\n-    for (i = 0; i < n; i++) {\n-        while (cxq == 0) {\n-            DPRINTF((\"CXReader: thread = 0x%lx waiting\\n\", PR_GetCurrentThread()));\n-            PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        --cxq;\n-        PR_Notify(mon);\n+  PR_EnterMonitor(mon);\n+  n = count / 2;\n+  for (i = 0; i < n; i++) {\n+    while (cxq == 0) {\n+      DPRINTF((\"CXReader: thread = 0x%lx waiting\\n\", PR_GetCurrentThread()));\n+      PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n     }\n-    PR_ExitMonitor(mon);\n-\n-    PR_EnterMonitor(mon2);\n-    --alive;\n-    PR_Notify(mon2);\n-    PR_ExitMonitor(mon2);\n-    DPRINTF((\"CXReader: thread = 0x%lx exiting\\n\", PR_GetCurrentThread()));\n+    --cxq;\n+    PR_Notify(mon);\n+  }\n+  PR_ExitMonitor(mon);\n+\n+  PR_EnterMonitor(mon2);\n+  --alive;\n+  PR_Notify(mon2);\n+  PR_ExitMonitor(mon2);\n+  DPRINTF((\"CXReader: thread = 0x%lx exiting\\n\", PR_GetCurrentThread()));\n }\n \n-static void PR_CALLBACK\n-CXWriter(void* arg)\n-{\n-    PRInt32 i, n;\n+static void PR_CALLBACK CXWriter(void* arg) {\n+  PRInt32 i, n;\n \n-    PR_EnterMonitor(mon);\n-    n = count / 2;\n-    for (i = 0; i < n; i++) {\n-        while (cxq == 1) {\n-            DPRINTF((\"CXWriter: thread = 0x%lx waiting\\n\", PR_GetCurrentThread()));\n-            PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        ++cxq;\n-        PR_Notify(mon);\n+  PR_EnterMonitor(mon);\n+  n = count / 2;\n+  for (i = 0; i < n; i++) {\n+    while (cxq == 1) {\n+      DPRINTF((\"CXWriter: thread = 0x%lx waiting\\n\", PR_GetCurrentThread()));\n+      PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n     }\n-    PR_ExitMonitor(mon);\n-\n-    PR_EnterMonitor(mon2);\n-    --alive;\n-    PR_Notify(mon2);\n-    PR_ExitMonitor(mon2);\n-    DPRINTF((\"CXWriter: thread = 0x%lx exiting\\n\", PR_GetCurrentThread()));\n+    ++cxq;\n+    PR_Notify(mon);\n+  }\n+  PR_ExitMonitor(mon);\n+\n+  PR_EnterMonitor(mon2);\n+  --alive;\n+  PR_Notify(mon2);\n+  PR_ExitMonitor(mon2);\n+  DPRINTF((\"CXWriter: thread = 0x%lx exiting\\n\", PR_GetCurrentThread()));\n }\n \n-static void\n-ContextSwitch(PRThreadScope scope1, PRThreadScope scope2)\n-{\n-    PRThread *t1, *t2;\n-\n-    PR_EnterMonitor(mon2);\n-    alive = 2;\n-    cxq = 0;\n-\n-    t1 = PR_CreateThread(PR_USER_THREAD, CXReader, 0, PR_PRIORITY_NORMAL, scope1,\n-                         PR_UNJOINABLE_THREAD, 0);\n-    if (NULL == t1) {\n-        fprintf(stderr, \"ContextSwitch: cannot create thread\\n\");\n-    } else {\n-        DPRINTF(\n-            (\"ContextSwitch: created %s thread = 0x%lx\\n\",\n-             (scope1 == PR_GLOBAL_THREAD ? \"PR_GLOBAL_THREAD\" : \"PR_LOCAL_THREAD\"),\n-             t1));\n-    }\n-    t2 = PR_CreateThread(PR_USER_THREAD, CXWriter, 0, PR_PRIORITY_NORMAL, scope2,\n-                         PR_UNJOINABLE_THREAD, 0);\n-    if (NULL == t2) {\n-        fprintf(stderr, \"ContextSwitch: cannot create thread\\n\");\n-    } else {\n-        DPRINTF(\n-            (\"ContextSwitch: created %s thread = 0x%lx\\n\",\n-             (scope2 == PR_GLOBAL_THREAD ? \"PR_GLOBAL_THREAD\" : \"PR_LOCAL_THREAD\"),\n-             t2));\n-    }\n-\n-    /* Wait for both of the threads to exit */\n-    while (alive) {\n-        PR_Wait(mon2, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_ExitMonitor(mon2);\n+static void ContextSwitch(PRThreadScope scope1, PRThreadScope scope2) {\n+  PRThread *t1, *t2;\n+\n+  PR_EnterMonitor(mon2);\n+  alive = 2;\n+  cxq = 0;\n+\n+  t1 = PR_CreateThread(PR_USER_THREAD, CXReader, 0, PR_PRIORITY_NORMAL, scope1,\n+                       PR_UNJOINABLE_THREAD, 0);\n+  if (NULL == t1) {\n+    fprintf(stderr, \"ContextSwitch: cannot create thread\\n\");\n+  } else {\n+    DPRINTF(\n+        (\"ContextSwitch: created %s thread = 0x%lx\\n\",\n+         (scope1 == PR_GLOBAL_THREAD ? \"PR_GLOBAL_THREAD\" : \"PR_LOCAL_THREAD\"),\n+         t1));\n+  }\n+  t2 = PR_CreateThread(PR_USER_THREAD, CXWriter, 0, PR_PRIORITY_NORMAL, scope2,\n+                       PR_UNJOINABLE_THREAD, 0);\n+  if (NULL == t2) {\n+    fprintf(stderr, \"ContextSwitch: cannot create thread\\n\");\n+  } else {\n+    DPRINTF(\n+        (\"ContextSwitch: created %s thread = 0x%lx\\n\",\n+         (scope2 == PR_GLOBAL_THREAD ? \"PR_GLOBAL_THREAD\" : \"PR_LOCAL_THREAD\"),\n+         t2));\n+  }\n+\n+  /* Wait for both of the threads to exit */\n+  while (alive) {\n+    PR_Wait(mon2, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_ExitMonitor(mon2);\n }\n \n-static void\n-ContextSwitchUU(void)\n-{\n-    ContextSwitch(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n+static void ContextSwitchUU(void) {\n+  ContextSwitch(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n }\n \n-static void\n-ContextSwitchUK(void)\n-{\n-    ContextSwitch(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n+static void ContextSwitchUK(void) {\n+  ContextSwitch(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n }\n \n-static void\n-ContextSwitchKU(void)\n-{\n-    ContextSwitch(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n+static void ContextSwitchKU(void) {\n+  ContextSwitch(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n }\n \n-static void\n-ContextSwitchKK(void)\n-{\n-    ContextSwitch(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n+static void ContextSwitchKK(void) {\n+  ContextSwitch(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n }\n \n /************************************************************************/\n \n-static void PR_CALLBACK\n-SemaThread(void* argSema)\n-{\n-    PRSemaphore** sem = (PRSemaphore**)argSema;\n-    PRInt32 i, n;\n-\n-    n = count / 2;\n-    for (i = 0; i < n; i++) {\n-        DPRINTF((\"SemaThread: thread = 0x%lx waiting on sem = 0x%lx\\n\",\n-                 PR_GetCurrentThread(), sem[0]));\n-        PR_WaitSem(sem[0]);\n-        DPRINTF((\"SemaThread: thread = 0x%lx posting on sem = 0x%lx\\n\",\n-                 PR_GetCurrentThread(), sem[1]));\n-        PR_PostSem(sem[1]);\n-    }\n-\n-    PR_EnterMonitor(mon2);\n-    --alive;\n-    PR_Notify(mon2);\n-    PR_ExitMonitor(mon2);\n-    DPRINTF((\"SemaThread: thread = 0x%lx exiting\\n\", PR_GetCurrentThread()));\n+static void PR_CALLBACK SemaThread(void* argSema) {\n+  PRSemaphore** sem = (PRSemaphore**)argSema;\n+  PRInt32 i, n;\n+\n+  n = count / 2;\n+  for (i = 0; i < n; i++) {\n+    DPRINTF((\"SemaThread: thread = 0x%lx waiting on sem = 0x%lx\\n\",\n+             PR_GetCurrentThread(), sem[0]));\n+    PR_WaitSem(sem[0]);\n+    DPRINTF((\"SemaThread: thread = 0x%lx posting on sem = 0x%lx\\n\",\n+             PR_GetCurrentThread(), sem[1]));\n+    PR_PostSem(sem[1]);\n+  }\n+\n+  PR_EnterMonitor(mon2);\n+  --alive;\n+  PR_Notify(mon2);\n+  PR_ExitMonitor(mon2);\n+  DPRINTF((\"SemaThread: thread = 0x%lx exiting\\n\", PR_GetCurrentThread()));\n }\n \n static PRSemaphore* sem_set1[2];\n static PRSemaphore* sem_set2[2];\n \n-static void\n-SemaContextSwitch(PRThreadScope scope1, PRThreadScope scope2)\n-{\n-    PRThread *t1, *t2;\n-    sem_set1[0] = PR_NewSem(1);\n-    sem_set1[1] = PR_NewSem(0);\n-    sem_set2[0] = sem_set1[1];\n-    sem_set2[1] = sem_set1[0];\n-\n-    PR_EnterMonitor(mon2);\n-    alive = 2;\n-    cxq = 0;\n-\n-    t1 = PR_CreateThread(PR_USER_THREAD, SemaThread, sem_set1, PR_PRIORITY_NORMAL,\n-                         scope1, PR_UNJOINABLE_THREAD, 0);\n-    if (NULL == t1) {\n-        fprintf(stderr, \"SemaContextSwitch: cannot create thread\\n\");\n-    } else {\n-        DPRINTF(\n-            (\"SemaContextSwitch: created %s thread = 0x%lx\\n\",\n-             (scope1 == PR_GLOBAL_THREAD ? \"PR_GLOBAL_THREAD\" : \"PR_LOCAL_THREAD\"),\n-             t1));\n-    }\n-    t2 = PR_CreateThread(PR_USER_THREAD, SemaThread, sem_set2, PR_PRIORITY_NORMAL,\n-                         scope2, PR_UNJOINABLE_THREAD, 0);\n-    if (NULL == t2) {\n-        fprintf(stderr, \"SemaContextSwitch: cannot create thread\\n\");\n-    } else {\n-        DPRINTF(\n-            (\"SemaContextSwitch: created %s thread = 0x%lx\\n\",\n-             (scope2 == PR_GLOBAL_THREAD ? \"PR_GLOBAL_THREAD\" : \"PR_LOCAL_THREAD\"),\n-             t2));\n-    }\n-\n-    /* Wait for both of the threads to exit */\n-    while (alive) {\n-        PR_Wait(mon2, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_ExitMonitor(mon2);\n-\n-    PR_DestroySem(sem_set1[0]);\n-    PR_DestroySem(sem_set1[1]);\n+static void SemaContextSwitch(PRThreadScope scope1, PRThreadScope scope2) {\n+  PRThread *t1, *t2;\n+  sem_set1[0] = PR_NewSem(1);\n+  sem_set1[1] = PR_NewSem(0);\n+  sem_set2[0] = sem_set1[1];\n+  sem_set2[1] = sem_set1[0];\n+\n+  PR_EnterMonitor(mon2);\n+  alive = 2;\n+  cxq = 0;\n+\n+  t1 = PR_CreateThread(PR_USER_THREAD, SemaThread, sem_set1, PR_PRIORITY_NORMAL,\n+                       scope1, PR_UNJOINABLE_THREAD, 0);\n+  if (NULL == t1) {\n+    fprintf(stderr, \"SemaContextSwitch: cannot create thread\\n\");\n+  } else {\n+    DPRINTF(\n+        (\"SemaContextSwitch: created %s thread = 0x%lx\\n\",\n+         (scope1 == PR_GLOBAL_THREAD ? \"PR_GLOBAL_THREAD\" : \"PR_LOCAL_THREAD\"),\n+         t1));\n+  }\n+  t2 = PR_CreateThread(PR_USER_THREAD, SemaThread, sem_set2, PR_PRIORITY_NORMAL,\n+                       scope2, PR_UNJOINABLE_THREAD, 0);\n+  if (NULL == t2) {\n+    fprintf(stderr, \"SemaContextSwitch: cannot create thread\\n\");\n+  } else {\n+    DPRINTF(\n+        (\"SemaContextSwitch: created %s thread = 0x%lx\\n\",\n+         (scope2 == PR_GLOBAL_THREAD ? \"PR_GLOBAL_THREAD\" : \"PR_LOCAL_THREAD\"),\n+         t2));\n+  }\n+\n+  /* Wait for both of the threads to exit */\n+  while (alive) {\n+    PR_Wait(mon2, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_ExitMonitor(mon2);\n+\n+  PR_DestroySem(sem_set1[0]);\n+  PR_DestroySem(sem_set1[1]);\n }\n \n-static void\n-SemaContextSwitchUU(void)\n-{\n-    SemaContextSwitch(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n+static void SemaContextSwitchUU(void) {\n+  SemaContextSwitch(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n }\n \n-static void\n-SemaContextSwitchUK(void)\n-{\n-    SemaContextSwitch(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n+static void SemaContextSwitchUK(void) {\n+  SemaContextSwitch(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n }\n \n-static void\n-SemaContextSwitchKU(void)\n-{\n-    SemaContextSwitch(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n+static void SemaContextSwitchKU(void) {\n+  SemaContextSwitch(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n }\n \n-static void\n-SemaContextSwitchKK(void)\n-{\n-    SemaContextSwitch(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n+static void SemaContextSwitchKK(void) {\n+  SemaContextSwitch(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n }\n \n /************************************************************************/\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow() - start;\n-    d = (double)PR_IntervalToMicroseconds(stop);\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow() - start;\n+  d = (double)PR_IntervalToMicroseconds(stop);\n \n-    printf(\"%40s: %6.2f usec\\n\", msg, d / count);\n+  printf(\"%40s: %6.2f usec\\n\", msg, d / count);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                _debug_on = 1;\n-                break;\n-            case 'c': /* loop count */\n-                count = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    if (0 == count) {\n-        count = DEFAULT_COUNT;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        _debug_on = 1;\n+        break;\n+      case 'c': /* loop count */\n+        count = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-    PR_BlockClockInterrupts();\n-    PR_UnblockClockInterrupts();\n-\n-    lock = PR_NewLock();\n-    mon = PR_NewMonitor();\n-    mon2 = PR_NewMonitor();\n-\n-    Measure(LocalProcedureCall, \"local procedure call overhead\");\n-    Measure(DLLProcedureCall, \"DLL procedure call overhead\");\n-    Measure(Now, \"current calendar time\");\n-    Measure(Interval, \"interval time\");\n-    Measure(IdleLock, \"idle lock lock/unlock pair\");\n-    Measure(IdleMonitor, \"idle monitor entry/exit pair\");\n-    Measure(IdleCMonitor, \"idle cache monitor entry/exit pair\");\n-    Measure(CDThread, \"create/destroy thread pair\");\n-    Measure(ContextSwitchUU, \"context switch - user/user\");\n-    Measure(ContextSwitchUK, \"context switch - user/kernel\");\n-    Measure(ContextSwitchKU, \"context switch - kernel/user\");\n-    Measure(ContextSwitchKK, \"context switch - kernel/kernel\");\n-    Measure(SemaContextSwitchUU, \"sema context switch - user/user\");\n-    Measure(SemaContextSwitchUK, \"sema context switch - user/kernel\");\n-    Measure(SemaContextSwitchKU, \"sema context switch - kernel/user\");\n-    Measure(SemaContextSwitchKK, \"sema context switch - kernel/kernel\");\n-\n-    printf(\"--------------\\n\");\n-    printf(\"Adding 7 additional CPUs\\n\");\n-\n-    PR_SetConcurrency(8);\n-    printf(\"--------------\\n\");\n-\n-    Measure(LocalProcedureCall, \"local procedure call overhead\");\n-    Measure(DLLProcedureCall, \"DLL procedure call overhead\");\n-    Measure(Now, \"current calendar time\");\n-    Measure(Interval, \"interval time\");\n-    Measure(IdleLock, \"idle lock lock/unlock pair\");\n-    Measure(IdleMonitor, \"idle monitor entry/exit pair\");\n-    Measure(IdleCMonitor, \"idle cache monitor entry/exit pair\");\n-    Measure(CDThread, \"create/destroy thread pair\");\n-    Measure(ContextSwitchUU, \"context switch - user/user\");\n-    Measure(ContextSwitchUK, \"context switch - user/kernel\");\n-    Measure(ContextSwitchKU, \"context switch - kernel/user\");\n-    Measure(ContextSwitchKK, \"context switch - kernel/kernel\");\n-    Measure(SemaContextSwitchUU, \"sema context switch - user/user\");\n-    Measure(SemaContextSwitchUK, \"sema context switch - user/kernel\");\n-    Measure(SemaContextSwitchKU, \"sema context switch - kernel/user\");\n-    Measure(SemaContextSwitchKK, \"sema context switch - kernel/kernel\");\n-\n-    PR_DestroyLock(lock);\n-    PR_DestroyMonitor(mon);\n-    PR_DestroyMonitor(mon2);\n-\n-    PR_Cleanup();\n-    return 0;\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  if (0 == count) {\n+    count = DEFAULT_COUNT;\n+  }\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  PR_BlockClockInterrupts();\n+  PR_UnblockClockInterrupts();\n+\n+  lock = PR_NewLock();\n+  mon = PR_NewMonitor();\n+  mon2 = PR_NewMonitor();\n+\n+  Measure(LocalProcedureCall, \"local procedure call overhead\");\n+  Measure(DLLProcedureCall, \"DLL procedure call overhead\");\n+  Measure(Now, \"current calendar time\");\n+  Measure(Interval, \"interval time\");\n+  Measure(IdleLock, \"idle lock lock/unlock pair\");\n+  Measure(IdleMonitor, \"idle monitor entry/exit pair\");\n+  Measure(IdleCMonitor, \"idle cache monitor entry/exit pair\");\n+  Measure(CDThread, \"create/destroy thread pair\");\n+  Measure(ContextSwitchUU, \"context switch - user/user\");\n+  Measure(ContextSwitchUK, \"context switch - user/kernel\");\n+  Measure(ContextSwitchKU, \"context switch - kernel/user\");\n+  Measure(ContextSwitchKK, \"context switch - kernel/kernel\");\n+  Measure(SemaContextSwitchUU, \"sema context switch - user/user\");\n+  Measure(SemaContextSwitchUK, \"sema context switch - user/kernel\");\n+  Measure(SemaContextSwitchKU, \"sema context switch - kernel/user\");\n+  Measure(SemaContextSwitchKK, \"sema context switch - kernel/kernel\");\n+\n+  printf(\"--------------\\n\");\n+  printf(\"Adding 7 additional CPUs\\n\");\n+\n+  PR_SetConcurrency(8);\n+  printf(\"--------------\\n\");\n+\n+  Measure(LocalProcedureCall, \"local procedure call overhead\");\n+  Measure(DLLProcedureCall, \"DLL procedure call overhead\");\n+  Measure(Now, \"current calendar time\");\n+  Measure(Interval, \"interval time\");\n+  Measure(IdleLock, \"idle lock lock/unlock pair\");\n+  Measure(IdleMonitor, \"idle monitor entry/exit pair\");\n+  Measure(IdleCMonitor, \"idle cache monitor entry/exit pair\");\n+  Measure(CDThread, \"create/destroy thread pair\");\n+  Measure(ContextSwitchUU, \"context switch - user/user\");\n+  Measure(ContextSwitchUK, \"context switch - user/kernel\");\n+  Measure(ContextSwitchKU, \"context switch - kernel/user\");\n+  Measure(ContextSwitchKK, \"context switch - kernel/kernel\");\n+  Measure(SemaContextSwitchUU, \"sema context switch - user/user\");\n+  Measure(SemaContextSwitchUK, \"sema context switch - user/kernel\");\n+  Measure(SemaContextSwitchKU, \"sema context switch - kernel/user\");\n+  Measure(SemaContextSwitchKK, \"sema context switch - kernel/kernel\");\n+\n+  PR_DestroyLock(lock);\n+  PR_DestroyMonitor(mon);\n+  PR_DestroyMonitor(mon2);\n+\n+  PR_Cleanup();\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/pipeping.c b/nspr/pr/tests/pipeping.c\nindex b098e79..d0b990c 100644\n--- a/nspr/pr/tests/pipeping.c\n+++ b/nspr/pr/tests/pipeping.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -25,129 +26,127 @@\n #include <stdlib.h>\n #include <string.h>\n \n-static char* child_argv[] = { \"pipepong\", NULL };\n+static char* child_argv[] = {\"pipepong\", NULL};\n \n #define NUM_ITERATIONS 10\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc* in_pipe[2];\n-    PRFileDesc* out_pipe[2];\n-    PRStatus status;\n-    PRProcess* process;\n-    PRProcessAttr* attr;\n-    char buf[1024];\n-    PRInt32 nBytes;\n-    PRInt32 exitCode;\n-    int idx;\n+int main(int argc, char** argv) {\n+  PRFileDesc* in_pipe[2];\n+  PRFileDesc* out_pipe[2];\n+  PRStatus status;\n+  PRProcess* process;\n+  PRProcessAttr* attr;\n+  char buf[1024];\n+  PRInt32 nBytes;\n+  PRInt32 exitCode;\n+  int idx;\n \n-    status = PR_CreatePipe(&in_pipe[0], &in_pipe[1]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CreatePipe failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_CreatePipe(&out_pipe[0], &out_pipe[1]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CreatePipe failed\\n\");\n-        exit(1);\n-    }\n+  status = PR_CreatePipe(&in_pipe[0], &in_pipe[1]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CreatePipe failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_CreatePipe(&out_pipe[0], &out_pipe[1]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CreatePipe failed\\n\");\n+    exit(1);\n+  }\n \n-    status = PR_SetFDInheritable(in_pipe[0], PR_FALSE);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_SetFDInheritable(in_pipe[1], PR_TRUE);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_SetFDInheritable(out_pipe[0], PR_TRUE);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_SetFDInheritable(out_pipe[1], PR_FALSE);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n-        exit(1);\n-    }\n+  status = PR_SetFDInheritable(in_pipe[0], PR_FALSE);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_SetFDInheritable(in_pipe[1], PR_TRUE);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_SetFDInheritable(out_pipe[0], PR_TRUE);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_SetFDInheritable(out_pipe[1], PR_FALSE);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n+    exit(1);\n+  }\n \n-    attr = PR_NewProcessAttr();\n-    if (attr == NULL) {\n-        fprintf(stderr, \"PR_NewProcessAttr failed\\n\");\n-        exit(1);\n-    }\n+  attr = PR_NewProcessAttr();\n+  if (attr == NULL) {\n+    fprintf(stderr, \"PR_NewProcessAttr failed\\n\");\n+    exit(1);\n+  }\n \n-    PR_ProcessAttrSetStdioRedirect(attr, PR_StandardInput, out_pipe[0]);\n-    PR_ProcessAttrSetStdioRedirect(attr, PR_StandardOutput, in_pipe[1]);\n+  PR_ProcessAttrSetStdioRedirect(attr, PR_StandardInput, out_pipe[0]);\n+  PR_ProcessAttrSetStdioRedirect(attr, PR_StandardOutput, in_pipe[1]);\n \n-    process = PR_CreateProcess(child_argv[0], child_argv, NULL, attr);\n-    if (process == NULL) {\n-        fprintf(stderr, \"PR_CreateProcess failed\\n\");\n-        exit(1);\n-    }\n-    PR_DestroyProcessAttr(attr);\n-    status = PR_Close(out_pipe[0]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_Close(in_pipe[1]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n+  process = PR_CreateProcess(child_argv[0], child_argv, NULL, attr);\n+  if (process == NULL) {\n+    fprintf(stderr, \"PR_CreateProcess failed\\n\");\n+    exit(1);\n+  }\n+  PR_DestroyProcessAttr(attr);\n+  status = PR_Close(out_pipe[0]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_Close(in_pipe[1]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n \n-    for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n-        strcpy(buf, \"ping\");\n-        printf(\"ping process: sending \\\"%s\\\"\\n\", buf);\n-        nBytes = PR_Write(out_pipe[1], buf, 5);\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            exit(1);\n-        }\n-        memset(buf, 0, sizeof(buf));\n-        nBytes = PR_Read(in_pipe[0], buf, sizeof(buf));\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Read failed: (%d, %d)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            exit(1);\n-        }\n-        printf(\"ping process: received \\\"%s\\\"\\n\", buf);\n-        if (nBytes != 5) {\n-            fprintf(stderr, \"ping process: expected 5 bytes but got %d bytes\\n\",\n-                    nBytes);\n-            exit(1);\n-        }\n-        if (strcmp(buf, \"pong\") != 0) {\n-            fprintf(stderr, \"ping process: expected \\\"pong\\\" but got \\\"%s\\\"\\n\", buf);\n-            exit(1);\n-        }\n+  for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n+    strcpy(buf, \"ping\");\n+    printf(\"ping process: sending \\\"%s\\\"\\n\", buf);\n+    nBytes = PR_Write(out_pipe[1], buf, 5);\n+    if (nBytes == -1) {\n+      fprintf(stderr, \"PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      exit(1);\n     }\n-\n-    status = PR_Close(in_pipe[0]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_Close(out_pipe[1]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n+    memset(buf, 0, sizeof(buf));\n+    nBytes = PR_Read(in_pipe[0], buf, sizeof(buf));\n+    if (nBytes == -1) {\n+      fprintf(stderr, \"PR_Read failed: (%d, %d)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      exit(1);\n     }\n-    status = PR_WaitProcess(process, &exitCode);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_WaitProcess failed\\n\");\n-        exit(1);\n+    printf(\"ping process: received \\\"%s\\\"\\n\", buf);\n+    if (nBytes != 5) {\n+      fprintf(stderr, \"ping process: expected 5 bytes but got %d bytes\\n\",\n+              nBytes);\n+      exit(1);\n     }\n-    if (exitCode == 0) {\n-        printf(\"PASS\\n\");\n-        return 0;\n-    } else {\n-        printf(\"FAIL\\n\");\n-        return 1;\n+    if (strcmp(buf, \"pong\") != 0) {\n+      fprintf(stderr, \"ping process: expected \\\"pong\\\" but got \\\"%s\\\"\\n\", buf);\n+      exit(1);\n     }\n+  }\n+\n+  status = PR_Close(in_pipe[0]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_Close(out_pipe[1]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_WaitProcess(process, &exitCode);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_WaitProcess failed\\n\");\n+    exit(1);\n+  }\n+  if (exitCode == 0) {\n+    printf(\"PASS\\n\");\n+    return 0;\n+  } else {\n+    printf(\"FAIL\\n\");\n+    return 1;\n+  }\n }\ndiff --git a/nspr/pr/tests/pipeping2.c b/nspr/pr/tests/pipeping2.c\nindex 1dc6391..2fc9589 100644\n--- a/nspr/pr/tests/pipeping2.c\n+++ b/nspr/pr/tests/pipeping2.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -26,134 +27,132 @@\n \n #define NUM_ITERATIONS 10\n \n-static char* child_argv[] = { \"pipepong2\", NULL };\n+static char* child_argv[] = {\"pipepong2\", NULL};\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc* in_pipe[2];\n-    PRFileDesc* out_pipe[2];\n-    PRStatus status;\n-    PRProcess* process;\n-    PRProcessAttr* attr;\n-    char buf[1024];\n-    PRInt32 nBytes;\n-    PRInt32 exitCode;\n-    int idx;\n+int main(int argc, char** argv) {\n+  PRFileDesc* in_pipe[2];\n+  PRFileDesc* out_pipe[2];\n+  PRStatus status;\n+  PRProcess* process;\n+  PRProcessAttr* attr;\n+  char buf[1024];\n+  PRInt32 nBytes;\n+  PRInt32 exitCode;\n+  int idx;\n \n-    status = PR_CreatePipe(&in_pipe[0], &in_pipe[1]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CreatePipe failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_CreatePipe(&out_pipe[0], &out_pipe[1]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CreatePipe failed\\n\");\n-        exit(1);\n-    }\n+  status = PR_CreatePipe(&in_pipe[0], &in_pipe[1]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CreatePipe failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_CreatePipe(&out_pipe[0], &out_pipe[1]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CreatePipe failed\\n\");\n+    exit(1);\n+  }\n \n-    status = PR_SetFDInheritable(in_pipe[0], PR_FALSE);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_SetFDInheritable(in_pipe[1], PR_TRUE);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_SetFDInheritable(out_pipe[0], PR_TRUE);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_SetFDInheritable(out_pipe[1], PR_FALSE);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n-        exit(1);\n-    }\n+  status = PR_SetFDInheritable(in_pipe[0], PR_FALSE);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_SetFDInheritable(in_pipe[1], PR_TRUE);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_SetFDInheritable(out_pipe[0], PR_TRUE);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_SetFDInheritable(out_pipe[1], PR_FALSE);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n+    exit(1);\n+  }\n \n-    attr = PR_NewProcessAttr();\n-    if (attr == NULL) {\n-        fprintf(stderr, \"PR_NewProcessAttr failed\\n\");\n-        exit(1);\n-    }\n+  attr = PR_NewProcessAttr();\n+  if (attr == NULL) {\n+    fprintf(stderr, \"PR_NewProcessAttr failed\\n\");\n+    exit(1);\n+  }\n \n-    status = PR_ProcessAttrSetInheritableFD(attr, out_pipe[0], \"PIPE_READ\");\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_ProcessAttrSetInheritableFD failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_ProcessAttrSetInheritableFD(attr, in_pipe[1], \"PIPE_WRITE\");\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_ProcessAttrSetInheritableFD failed\\n\");\n-        exit(1);\n-    }\n+  status = PR_ProcessAttrSetInheritableFD(attr, out_pipe[0], \"PIPE_READ\");\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_ProcessAttrSetInheritableFD failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_ProcessAttrSetInheritableFD(attr, in_pipe[1], \"PIPE_WRITE\");\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_ProcessAttrSetInheritableFD failed\\n\");\n+    exit(1);\n+  }\n \n-    process = PR_CreateProcess(child_argv[0], child_argv, NULL, attr);\n-    if (process == NULL) {\n-        fprintf(stderr, \"PR_CreateProcess failed\\n\");\n-        exit(1);\n-    }\n-    PR_DestroyProcessAttr(attr);\n-    status = PR_Close(out_pipe[0]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_Close(in_pipe[1]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n+  process = PR_CreateProcess(child_argv[0], child_argv, NULL, attr);\n+  if (process == NULL) {\n+    fprintf(stderr, \"PR_CreateProcess failed\\n\");\n+    exit(1);\n+  }\n+  PR_DestroyProcessAttr(attr);\n+  status = PR_Close(out_pipe[0]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_Close(in_pipe[1]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n \n-    for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n-        strcpy(buf, \"ping\");\n-        printf(\"ping process: sending \\\"%s\\\"\\n\", buf);\n-        nBytes = PR_Write(out_pipe[1], buf, 5);\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            exit(1);\n-        }\n-        memset(buf, 0, sizeof(buf));\n-        nBytes = PR_Read(in_pipe[0], buf, sizeof(buf));\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Read failed\\n\");\n-            exit(1);\n-        }\n-        printf(\"ping process: received \\\"%s\\\"\\n\", buf);\n-        if (nBytes != 5) {\n-            fprintf(stderr, \"ping process: expected 5 bytes but got %d bytes\\n\",\n-                    nBytes);\n-            exit(1);\n-        }\n-        if (strcmp(buf, \"pong\") != 0) {\n-            fprintf(stderr, \"ping process: expected \\\"pong\\\" but got \\\"%s\\\"\\n\", buf);\n-            exit(1);\n-        }\n-    }\n+  for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n+    strcpy(buf, \"ping\");\n+    printf(\"ping process: sending \\\"%s\\\"\\n\", buf);\n+    nBytes = PR_Write(out_pipe[1], buf, 5);\n+    if (nBytes == -1) {\n+      fprintf(stderr, \"PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      exit(1);\n+    }\n+    memset(buf, 0, sizeof(buf));\n+    nBytes = PR_Read(in_pipe[0], buf, sizeof(buf));\n+    if (nBytes == -1) {\n+      fprintf(stderr, \"PR_Read failed\\n\");\n+      exit(1);\n+    }\n+    printf(\"ping process: received \\\"%s\\\"\\n\", buf);\n+    if (nBytes != 5) {\n+      fprintf(stderr, \"ping process: expected 5 bytes but got %d bytes\\n\",\n+              nBytes);\n+      exit(1);\n+    }\n+    if (strcmp(buf, \"pong\") != 0) {\n+      fprintf(stderr, \"ping process: expected \\\"pong\\\" but got \\\"%s\\\"\\n\", buf);\n+      exit(1);\n+    }\n+  }\n \n-    status = PR_Close(in_pipe[0]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_Close(out_pipe[1]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_WaitProcess(process, &exitCode);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_WaitProcess failed\\n\");\n-        exit(1);\n-    }\n-    if (exitCode == 0) {\n-        printf(\"PASS\\n\");\n-        return 0;\n-    } else {\n-        printf(\"FAIL\\n\");\n-        return 1;\n-    }\n+  status = PR_Close(in_pipe[0]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_Close(out_pipe[1]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_WaitProcess(process, &exitCode);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_WaitProcess failed\\n\");\n+    exit(1);\n+  }\n+  if (exitCode == 0) {\n+    printf(\"PASS\\n\");\n+    return 0;\n+  } else {\n+    printf(\"FAIL\\n\");\n+    return 1;\n+  }\n }\ndiff --git a/nspr/pr/tests/pipepong.c b/nspr/pr/tests/pipepong.c\nindex cb099d1..56afc14 100644\n--- a/nspr/pr/tests/pipepong.c\n+++ b/nspr/pr/tests/pipepong.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -24,36 +25,34 @@\n \n #define NUM_ITERATIONS 10\n \n-int\n-main(int argc, char** argv)\n-{\n-    char buf[1024];\n-    size_t nBytes;\n-    int idx;\n+int main(int argc, char** argv) {\n+  char buf[1024];\n+  size_t nBytes;\n+  int idx;\n \n-    for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n-        memset(buf, 0, sizeof(buf));\n-        nBytes = fread(buf, 1, 5, stdin);\n-        fprintf(stderr, \"pong process: received \\\"%s\\\"\\n\", buf);\n-        if (nBytes != 5) {\n-            fprintf(stderr, \"pong process: expected 5 bytes but got %d bytes\\n\",\n-                    nBytes);\n-            exit(1);\n-        }\n-        if (strcmp(buf, \"ping\") != 0) {\n-            fprintf(stderr, \"pong process: expected \\\"ping\\\" but got \\\"%s\\\"\\n\", buf);\n-            exit(1);\n-        }\n+  for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n+    memset(buf, 0, sizeof(buf));\n+    nBytes = fread(buf, 1, 5, stdin);\n+    fprintf(stderr, \"pong process: received \\\"%s\\\"\\n\", buf);\n+    if (nBytes != 5) {\n+      fprintf(stderr, \"pong process: expected 5 bytes but got %d bytes\\n\",\n+              nBytes);\n+      exit(1);\n+    }\n+    if (strcmp(buf, \"ping\") != 0) {\n+      fprintf(stderr, \"pong process: expected \\\"ping\\\" but got \\\"%s\\\"\\n\", buf);\n+      exit(1);\n+    }\n \n-        strcpy(buf, \"pong\");\n-        fprintf(stderr, \"pong process: sending \\\"%s\\\"\\n\", buf);\n-        nBytes = fwrite(buf, 1, 5, stdout);\n-        if (nBytes != 5) {\n-            fprintf(stderr, \"pong process: fwrite failed\\n\");\n-            exit(1);\n-        }\n-        fflush(stdout);\n+    strcpy(buf, \"pong\");\n+    fprintf(stderr, \"pong process: sending \\\"%s\\\"\\n\", buf);\n+    nBytes = fwrite(buf, 1, 5, stdout);\n+    if (nBytes != 5) {\n+      fprintf(stderr, \"pong process: fwrite failed\\n\");\n+      exit(1);\n     }\n+    fflush(stdout);\n+  }\n \n-    return 0;\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/pipepong2.c b/nspr/pr/tests/pipepong2.c\nindex ee291e2..1d647e8 100644\n--- a/nspr/pr/tests/pipepong2.c\n+++ b/nspr/pr/tests/pipepong2.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -25,73 +26,71 @@\n \n #define NUM_ITERATIONS 10\n \n-int\n-main(int argc, char **argv)\n-{\n-    PRFileDesc *pipe_read, *pipe_write;\n-    PRStatus status;\n-    char buf[1024];\n-    PRInt32 nBytes;\n-    int idx;\n+int main(int argc, char** argv) {\n+  PRFileDesc *pipe_read, *pipe_write;\n+  PRStatus status;\n+  char buf[1024];\n+  PRInt32 nBytes;\n+  int idx;\n \n-    pipe_read = PR_GetInheritedFD(\"PIPE_READ\");\n-    if (pipe_read == NULL) {\n-        fprintf(stderr, \"PR_GetInheritedFD failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_SetFDInheritable(pipe_read, PR_FALSE);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n-        exit(1);\n+  pipe_read = PR_GetInheritedFD(\"PIPE_READ\");\n+  if (pipe_read == NULL) {\n+    fprintf(stderr, \"PR_GetInheritedFD failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_SetFDInheritable(pipe_read, PR_FALSE);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n+    exit(1);\n+  }\n+  pipe_write = PR_GetInheritedFD(\"PIPE_WRITE\");\n+  if (pipe_write == NULL) {\n+    fprintf(stderr, \"PR_GetInheritedFD failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_SetFDInheritable(pipe_write, PR_FALSE);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n+    exit(1);\n+  }\n+\n+  for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n+    memset(buf, 0, sizeof(buf));\n+    nBytes = PR_Read(pipe_read, buf, sizeof(buf));\n+    if (nBytes == -1) {\n+      fprintf(stderr, \"PR_Read failed: (%d, %d)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      exit(1);\n     }\n-    pipe_write = PR_GetInheritedFD(\"PIPE_WRITE\");\n-    if (pipe_write == NULL) {\n-        fprintf(stderr, \"PR_GetInheritedFD failed\\n\");\n-        exit(1);\n+    printf(\"pong process: received \\\"%s\\\"\\n\", buf);\n+    if (nBytes != 5) {\n+      fprintf(stderr, \"pong process: expected 5 bytes but got %d bytes\\n\",\n+              nBytes);\n+      exit(1);\n     }\n-    status = PR_SetFDInheritable(pipe_write, PR_FALSE);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n-        exit(1);\n+    if (strcmp(buf, \"ping\") != 0) {\n+      fprintf(stderr, \"pong process: expected \\\"ping\\\" but got \\\"%s\\\"\\n\", buf);\n+      exit(1);\n     }\n \n-    for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n-        memset(buf, 0, sizeof(buf));\n-        nBytes = PR_Read(pipe_read, buf, sizeof(buf));\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Read failed: (%d, %d)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            exit(1);\n-        }\n-        printf(\"pong process: received \\\"%s\\\"\\n\", buf);\n-        if (nBytes != 5) {\n-            fprintf(stderr, \"pong process: expected 5 bytes but got %d bytes\\n\",\n-                    nBytes);\n-            exit(1);\n-        }\n-        if (strcmp(buf, \"ping\") != 0) {\n-            fprintf(stderr, \"pong process: expected \\\"ping\\\" but got \\\"%s\\\"\\n\", buf);\n-            exit(1);\n-        }\n-\n-        strcpy(buf, \"pong\");\n-        printf(\"pong process: sending \\\"%s\\\"\\n\", buf);\n-        nBytes = PR_Write(pipe_write, buf, 5);\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Write failed\\n\");\n-            exit(1);\n-        }\n+    strcpy(buf, \"pong\");\n+    printf(\"pong process: sending \\\"%s\\\"\\n\", buf);\n+    nBytes = PR_Write(pipe_write, buf, 5);\n+    if (nBytes == -1) {\n+      fprintf(stderr, \"PR_Write failed\\n\");\n+      exit(1);\n     }\n+  }\n \n-    status = PR_Close(pipe_read);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_Close(pipe_write);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    return 0;\n+  status = PR_Close(pipe_read);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_Close(pipe_write);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/pipeself.c b/nspr/pr/tests/pipeself.c\nindex 362bcc6..d7328c7 100644\n--- a/nspr/pr/tests/pipeself.c\n+++ b/nspr/pr/tests/pipeself.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -26,202 +27,198 @@\n static PRFileDesc *ping_in, *ping_out;\n static PRFileDesc *pong_in, *pong_out;\n \n-static void\n-PongThreadFunc(void* arg)\n-{\n-    char buf[1024];\n-    int idx;\n-    PRInt32 nBytes;\n-    PRStatus status;\n-\n-    for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n-        memset(buf, 0, sizeof(buf));\n-        nBytes = PR_Read(pong_in, buf, sizeof(buf));\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Read failed\\n\");\n-            exit(1);\n-        }\n-        printf(\"pong thread: received \\\"%s\\\"\\n\", buf);\n-        if (nBytes != 5) {\n-            fprintf(stderr, \"pong thread: expected 5 bytes but got %d bytes\\n\",\n-                    nBytes);\n-            exit(1);\n-        }\n-        if (strcmp(buf, \"ping\") != 0) {\n-            fprintf(stderr, \"pong thread: expected \\\"ping\\\" but got \\\"%s\\\"\\n\", buf);\n-            exit(1);\n-        }\n-        strcpy(buf, \"pong\");\n-        printf(\"pong thread: sending \\\"%s\\\"\\n\", buf);\n-        nBytes = PR_Write(pong_out, buf, 5);\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            exit(1);\n-        }\n-    }\n+static void PongThreadFunc(void* arg) {\n+  char buf[1024];\n+  int idx;\n+  PRInt32 nBytes;\n+  PRStatus status;\n \n-    status = PR_Close(pong_in);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_Close(pong_out);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n+  for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n+    memset(buf, 0, sizeof(buf));\n+    nBytes = PR_Read(pong_in, buf, sizeof(buf));\n+    if (nBytes == -1) {\n+      fprintf(stderr, \"PR_Read failed\\n\");\n+      exit(1);\n+    }\n+    printf(\"pong thread: received \\\"%s\\\"\\n\", buf);\n+    if (nBytes != 5) {\n+      fprintf(stderr, \"pong thread: expected 5 bytes but got %d bytes\\n\",\n+              nBytes);\n+      exit(1);\n+    }\n+    if (strcmp(buf, \"ping\") != 0) {\n+      fprintf(stderr, \"pong thread: expected \\\"ping\\\" but got \\\"%s\\\"\\n\", buf);\n+      exit(1);\n+    }\n+    strcpy(buf, \"pong\");\n+    printf(\"pong thread: sending \\\"%s\\\"\\n\", buf);\n+    nBytes = PR_Write(pong_out, buf, 5);\n+    if (nBytes == -1) {\n+      fprintf(stderr, \"PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      exit(1);\n+    }\n+  }\n+\n+  status = PR_Close(pong_in);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_Close(pong_out);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRStatus status;\n-    PRThread* pongThread;\n-    char buf[1024];\n-    PRInt32 nBytes;\n-    int idx;\n-\n-    status = PR_CreatePipe(&ping_in, &pong_out);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CreatePipe failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_CreatePipe(&pong_in, &ping_out);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CreatePipe failed\\n\");\n-        exit(1);\n-    }\n-\n-    pongThread =\n-        PR_CreateThread(PR_USER_THREAD, PongThreadFunc, NULL, PR_PRIORITY_NORMAL,\n-                        PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (pongThread == NULL) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n-    }\n-\n-    for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n-        strcpy(buf, \"ping\");\n-        printf(\"ping thread: sending \\\"%s\\\"\\n\", buf);\n-        nBytes = PR_Write(ping_out, buf, 5);\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            exit(1);\n-        }\n-        memset(buf, 0, sizeof(buf));\n-        nBytes = PR_Read(ping_in, buf, sizeof(buf));\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Read failed\\n\");\n-            exit(1);\n-        }\n-        printf(\"ping thread: received \\\"%s\\\"\\n\", buf);\n-        if (nBytes != 5) {\n-            fprintf(stderr, \"ping thread: expected 5 bytes but got %d bytes\\n\",\n-                    nBytes);\n-            exit(1);\n-        }\n-        if (strcmp(buf, \"pong\") != 0) {\n-            fprintf(stderr, \"ping thread: expected \\\"pong\\\" but got \\\"%s\\\"\\n\", buf);\n-            exit(1);\n-        }\n-    }\n-\n-    status = PR_Close(ping_in);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_Close(ping_out);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_JoinThread(pongThread);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n-    }\n-\n-#if defined(XP_UNIX)\n-    /*\n-     * Test PR_Available for pipes\n-     */\n-    status = PR_CreatePipe(&ping_in, &ping_out);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CreatePipe failed\\n\");\n-        exit(1);\n-    }\n-    nBytes = PR_Write(ping_out, buf, 250);\n-    if (nBytes == -1) {\n-        fprintf(stderr, \"PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    nBytes = PR_Available(ping_in);\n-    if (nBytes < 0) {\n-        fprintf(stderr, \"PR_Available failed: (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    } else if (nBytes != 250) {\n-        fprintf(stderr, \"PR_Available: expected 250 bytes but got %d bytes\\n\",\n-                nBytes);\n-        exit(1);\n-    }\n-    printf(\"PR_Available: expected %d, got %d bytes\\n\", 250, nBytes);\n-    /* read some data */\n-    nBytes = PR_Read(ping_in, buf, 7);\n+int main(int argc, char** argv) {\n+  PRStatus status;\n+  PRThread* pongThread;\n+  char buf[1024];\n+  PRInt32 nBytes;\n+  int idx;\n+\n+  status = PR_CreatePipe(&ping_in, &pong_out);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CreatePipe failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_CreatePipe(&pong_in, &ping_out);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CreatePipe failed\\n\");\n+    exit(1);\n+  }\n+\n+  pongThread =\n+      PR_CreateThread(PR_USER_THREAD, PongThreadFunc, NULL, PR_PRIORITY_NORMAL,\n+                      PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (pongThread == NULL) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n+\n+  for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n+    strcpy(buf, \"ping\");\n+    printf(\"ping thread: sending \\\"%s\\\"\\n\", buf);\n+    nBytes = PR_Write(ping_out, buf, 5);\n     if (nBytes == -1) {\n-        fprintf(stderr, \"PR_Read failed\\n\");\n-        exit(1);\n+      fprintf(stderr, \"PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      exit(1);\n     }\n-    /* check available data */\n-    nBytes = PR_Available(ping_in);\n-    if (nBytes < 0) {\n-        fprintf(stderr, \"PR_Available failed: (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    } else if (nBytes != (250 - 7)) {\n-        fprintf(stderr, \"PR_Available: expected 243 bytes but got %d bytes\\n\",\n-                nBytes);\n-        exit(1);\n-    }\n-    printf(\"PR_Available: expected %d, got %d bytes\\n\", 243, nBytes);\n-    /* read all data */\n+    memset(buf, 0, sizeof(buf));\n     nBytes = PR_Read(ping_in, buf, sizeof(buf));\n     if (nBytes == -1) {\n-        fprintf(stderr, \"PR_Read failed\\n\");\n-        exit(1);\n-    } else if (nBytes != 243) {\n-        fprintf(stderr, \"PR_Read failed: expected %d, got %d bytes\\n\", 243, nBytes);\n-        exit(1);\n-    }\n-    /* check available data */\n-    nBytes = PR_Available(ping_in);\n-    if (nBytes < 0) {\n-        fprintf(stderr, \"PR_Available failed: (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    } else if (nBytes != 0) {\n-        fprintf(stderr, \"PR_Available: expected 0 bytes but got %d bytes\\n\",\n-                nBytes);\n-        exit(1);\n-    }\n-    printf(\"PR_Available: expected %d, got %d bytes\\n\", 0, nBytes);\n+      fprintf(stderr, \"PR_Read failed\\n\");\n+      exit(1);\n+    }\n+    printf(\"ping thread: received \\\"%s\\\"\\n\", buf);\n+    if (nBytes != 5) {\n+      fprintf(stderr, \"ping thread: expected 5 bytes but got %d bytes\\n\",\n+              nBytes);\n+      exit(1);\n+    }\n+    if (strcmp(buf, \"pong\") != 0) {\n+      fprintf(stderr, \"ping thread: expected \\\"pong\\\" but got \\\"%s\\\"\\n\", buf);\n+      exit(1);\n+    }\n+  }\n+\n+  status = PR_Close(ping_in);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_Close(ping_out);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_JoinThread(pongThread);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n \n-    status = PR_Close(ping_in);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    status = PR_Close(ping_out);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n+#if defined(XP_UNIX)\n+  /*\n+   * Test PR_Available for pipes\n+   */\n+  status = PR_CreatePipe(&ping_in, &ping_out);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CreatePipe failed\\n\");\n+    exit(1);\n+  }\n+  nBytes = PR_Write(ping_out, buf, 250);\n+  if (nBytes == -1) {\n+    fprintf(stderr, \"PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  nBytes = PR_Available(ping_in);\n+  if (nBytes < 0) {\n+    fprintf(stderr, \"PR_Available failed: (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  } else if (nBytes != 250) {\n+    fprintf(stderr, \"PR_Available: expected 250 bytes but got %d bytes\\n\",\n+            nBytes);\n+    exit(1);\n+  }\n+  printf(\"PR_Available: expected %d, got %d bytes\\n\", 250, nBytes);\n+  /* read some data */\n+  nBytes = PR_Read(ping_in, buf, 7);\n+  if (nBytes == -1) {\n+    fprintf(stderr, \"PR_Read failed\\n\");\n+    exit(1);\n+  }\n+  /* check available data */\n+  nBytes = PR_Available(ping_in);\n+  if (nBytes < 0) {\n+    fprintf(stderr, \"PR_Available failed: (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  } else if (nBytes != (250 - 7)) {\n+    fprintf(stderr, \"PR_Available: expected 243 bytes but got %d bytes\\n\",\n+            nBytes);\n+    exit(1);\n+  }\n+  printf(\"PR_Available: expected %d, got %d bytes\\n\", 243, nBytes);\n+  /* read all data */\n+  nBytes = PR_Read(ping_in, buf, sizeof(buf));\n+  if (nBytes == -1) {\n+    fprintf(stderr, \"PR_Read failed\\n\");\n+    exit(1);\n+  } else if (nBytes != 243) {\n+    fprintf(stderr, \"PR_Read failed: expected %d, got %d bytes\\n\", 243, nBytes);\n+    exit(1);\n+  }\n+  /* check available data */\n+  nBytes = PR_Available(ping_in);\n+  if (nBytes < 0) {\n+    fprintf(stderr, \"PR_Available failed: (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  } else if (nBytes != 0) {\n+    fprintf(stderr, \"PR_Available: expected 0 bytes but got %d bytes\\n\",\n+            nBytes);\n+    exit(1);\n+  }\n+  printf(\"PR_Available: expected %d, got %d bytes\\n\", 0, nBytes);\n+\n+  status = PR_Close(ping_in);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_Close(ping_out);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n #endif /* XP_UNIX */\n \n-    printf(\"PASS\\n\");\n-    return 0;\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/poll_er.c b/nspr/pr/tests/poll_er.c\nindex d88b43f..3ae62e2 100644\n--- a/nspr/pr/tests/poll_er.c\n+++ b/nspr/pr/tests/poll_er.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -38,169 +39,165 @@\n PRIntn failed_already = 0;\n PRIntn debug_mode;\n \n-static void\n-ClientThreadFunc(void* arg)\n-{\n-    PRFileDesc* badFD = (PRFileDesc*)arg;\n-    /*\n-     * Make the fd invalid\n-     */\n+static void ClientThreadFunc(void* arg) {\n+  PRFileDesc* badFD = (PRFileDesc*)arg;\n+  /*\n+   * Make the fd invalid\n+   */\n #if defined(XP_UNIX)\n-    close(PR_FileDesc2NativeHandle(badFD));\n+  close(PR_FileDesc2NativeHandle(badFD));\n #elif defined(WIN32)\n-    closesocket(PR_FileDesc2NativeHandle(badFD));\n+  closesocket(PR_FileDesc2NativeHandle(badFD));\n #else\n-#error \"Unknown architecture\"\n+#  error \"Unknown architecture\"\n #endif\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc *listenSock1, *listenSock2;\n-    PRFileDesc* badFD;\n-    PRUint16 listenPort1, listenPort2;\n-    PRNetAddr addr;\n-    char buf[128];\n-    PRPollDesc pds0[10], pds1[10], *pds, *other_pds;\n-    PRIntn npds;\n-    PRInt32 retVal;\n-\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    if (debug_mode) {\n-        printf(\"This program tests PR_Poll with sockets.\\n\");\n-        printf(\"error reporting is  tested.\\n\\n\");\n-    }\n-\n-    /* Create two listening sockets */\n-    if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    addr.inet.family = AF_INET;\n-    addr.inet.ip = PR_htonl(INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    listenPort1 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-\n-    if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    addr.inet.family = AF_INET;\n-    addr.inet.ip = PR_htonl(INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    listenPort2 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    PR_snprintf(buf, sizeof(buf),\n-                \"The server thread is listening on ports %hu and %hu\\n\\n\",\n-                listenPort1, listenPort2);\n-    if (debug_mode) {\n-        printf(\"%s\", buf);\n-    }\n-\n-    /* Set up the poll descriptor array */\n-    pds = pds0;\n-    other_pds = pds1;\n-    memset(pds, 0, sizeof(pds));\n-    pds[0].fd = listenSock1;\n-    pds[0].in_flags = PR_POLL_READ;\n-    pds[1].fd = listenSock2;\n-    pds[1].in_flags = PR_POLL_READ;\n-    npds = 2;\n-\n-    /* Testing bad fd */\n-    if (debug_mode) {\n-        printf(\"PR_Poll should detect a bad file descriptor\\n\");\n-    }\n-    if ((badFD = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a TCP socket\\n\");\n-        goto exit_now;\n-    }\n-\n-    pds[2].fd = badFD;\n-    pds[2].in_flags = PR_POLL_READ;\n-    npds = 3;\n-\n-    if (PR_CreateThread(PR_USER_THREAD, ClientThreadFunc, badFD,\n-                        PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD,\n-                        0) == NULL) {\n-        fprintf(stderr, \"cannot create thread\\n\");\n-        exit(1);\n-    }\n+int main(int argc, char** argv) {\n+  PRFileDesc *listenSock1, *listenSock2;\n+  PRFileDesc* badFD;\n+  PRUint16 listenPort1, listenPort2;\n+  PRNetAddr addr;\n+  char buf[128];\n+  PRPollDesc pds0[10], pds1[10], *pds, *other_pds;\n+  PRIntn npds;\n+  PRInt32 retVal;\n+\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  if (debug_mode) {\n+    printf(\"This program tests PR_Poll with sockets.\\n\");\n+    printf(\"error reporting is  tested.\\n\\n\");\n+  }\n+\n+  /* Create two listening sockets */\n+  if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  addr.inet.family = AF_INET;\n+  addr.inet.ip = PR_htonl(INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  listenPort1 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n \n-    retVal = PR_Poll(pds, npds, PR_INTERVAL_NO_TIMEOUT);\n-    if (retVal != 1 || (unsigned short)pds[2].out_flags != PR_POLL_NVAL) {\n-        fprintf(stderr,\n-                \"Failed to detect the bad fd: \"\n-                \"PR_Poll returns %d, out_flags is 0x%hx\\n\",\n-                retVal, pds[2].out_flags);\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    if (debug_mode) {\n-        printf(\"PR_Poll detected the bad fd.  Test passed.\\n\\n\");\n-    }\n-    PR_Cleanup();\n+  if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  addr.inet.family = AF_INET;\n+  addr.inet.ip = PR_htonl(INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    failed_already = 1;\n     goto exit_now;\n+  }\n+  listenPort2 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  PR_snprintf(buf, sizeof(buf),\n+              \"The server thread is listening on ports %hu and %hu\\n\\n\",\n+              listenPort1, listenPort2);\n+  if (debug_mode) {\n+    printf(\"%s\", buf);\n+  }\n+\n+  /* Set up the poll descriptor array */\n+  pds = pds0;\n+  other_pds = pds1;\n+  memset(pds, 0, sizeof(pds));\n+  pds[0].fd = listenSock1;\n+  pds[0].in_flags = PR_POLL_READ;\n+  pds[1].fd = listenSock2;\n+  pds[1].in_flags = PR_POLL_READ;\n+  npds = 2;\n+\n+  /* Testing bad fd */\n+  if (debug_mode) {\n+    printf(\"PR_Poll should detect a bad file descriptor\\n\");\n+  }\n+  if ((badFD = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a TCP socket\\n\");\n+    goto exit_now;\n+  }\n+\n+  pds[2].fd = badFD;\n+  pds[2].in_flags = PR_POLL_READ;\n+  npds = 3;\n+\n+  if (PR_CreateThread(PR_USER_THREAD, ClientThreadFunc, badFD,\n+                      PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD,\n+                      0) == NULL) {\n+    fprintf(stderr, \"cannot create thread\\n\");\n+    exit(1);\n+  }\n+\n+  retVal = PR_Poll(pds, npds, PR_INTERVAL_NO_TIMEOUT);\n+  if (retVal != 1 || (unsigned short)pds[2].out_flags != PR_POLL_NVAL) {\n+    fprintf(stderr,\n+            \"Failed to detect the bad fd: \"\n+            \"PR_Poll returns %d, out_flags is 0x%hx\\n\",\n+            retVal, pds[2].out_flags);\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  if (debug_mode) {\n+    printf(\"PR_Poll detected the bad fd.  Test passed.\\n\\n\");\n+  }\n+  PR_Cleanup();\n+  goto exit_now;\n exit_now:\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/poll_nm.c b/nspr/pr/tests/poll_nm.c\nindex 53c60bc..9ae4be4 100644\n--- a/nspr/pr/tests/poll_nm.c\n+++ b/nspr/pr/tests/poll_nm.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -47,305 +48,301 @@ PRIntn debug_mode;\n \n #define NUM_ITERATIONS 5\n \n-static void PR_CALLBACK\n-clientThreadFunc(void* arg)\n-{\n-    PRUintn port = (PRUintn)arg;\n-    PRFileDesc* sock;\n-    PRNetAddr addr;\n-    char buf[128];\n-    int i;\n-    PRStatus sts;\n-    PRInt32 n;\n-\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.port = PR_htons((PRUint16)port);\n-    addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n-    memset(buf, 0, sizeof(buf));\n-    PR_snprintf(buf, sizeof(buf), \"%hu\", port);\n-\n-    for (i = 0; i < NUM_ITERATIONS; i++) {\n-        sock = PR_NewTCPSocket();\n-        PR_ASSERT(sock != NULL);\n-\n-        sts = PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT);\n-        PR_ASSERT(sts == PR_SUCCESS);\n-\n-        n = PR_Write(sock, buf, sizeof(buf));\n-        PR_ASSERT(n >= 0);\n-\n-        sts = PR_Close(sock);\n-        PR_ASSERT(sts == PR_SUCCESS);\n-    }\n+static void PR_CALLBACK clientThreadFunc(void* arg) {\n+  PRUintn port = (PRUintn)arg;\n+  PRFileDesc* sock;\n+  PRNetAddr addr;\n+  char buf[128];\n+  int i;\n+  PRStatus sts;\n+  PRInt32 n;\n+\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.port = PR_htons((PRUint16)port);\n+  addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n+  memset(buf, 0, sizeof(buf));\n+  PR_snprintf(buf, sizeof(buf), \"%hu\", port);\n+\n+  for (i = 0; i < NUM_ITERATIONS; i++) {\n+    sock = PR_NewTCPSocket();\n+    PR_ASSERT(sock != NULL);\n+\n+    sts = PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT);\n+    PR_ASSERT(sts == PR_SUCCESS);\n+\n+    n = PR_Write(sock, buf, sizeof(buf));\n+    PR_ASSERT(n >= 0);\n+\n+    sts = PR_Close(sock);\n+    PR_ASSERT(sts == PR_SUCCESS);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc *listenSock1 = NULL, *listenSock2 = NULL;\n-    PRUint16 listenPort1, listenPort2;\n-    PRNetAddr addr;\n-    char buf[128];\n-    PRThread* clientThread;\n-    PRPollDesc pds0[20], pds1[20], *pds, *other_pds;\n-    PRIntn npds;\n-    PRInt32 retVal;\n-    PRIntn i, j;\n-    PRSocketOptionData optval;\n-\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    if (debug_mode) {\n-        printf(\"This program tests PR_Poll with sockets.\\n\");\n-        printf(\"Normal operation are tested.\\n\\n\");\n-    }\n-\n-    /* Create two listening sockets */\n-    if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n+int main(int argc, char** argv) {\n+  PRFileDesc *listenSock1 = NULL, *listenSock2 = NULL;\n+  PRUint16 listenPort1, listenPort2;\n+  PRNetAddr addr;\n+  char buf[128];\n+  PRThread* clientThread;\n+  PRPollDesc pds0[20], pds1[20], *pds, *other_pds;\n+  PRIntn npds;\n+  PRInt32 retVal;\n+  PRIntn i, j;\n+  PRSocketOptionData optval;\n+\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    memset(&addr, 0, sizeof(addr));\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n-    if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    listenPort1 = PR_ntohs(addr.inet.port);\n-    optval.option = PR_SockOpt_Nonblocking;\n-    optval.value.non_blocking = PR_TRUE;\n-    PR_SetSocketOption(listenSock1, &optval);\n-    if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  if (debug_mode) {\n+    printf(\"This program tests PR_Poll with sockets.\\n\");\n+    printf(\"Normal operation are tested.\\n\\n\");\n+  }\n+\n+  /* Create two listening sockets */\n+  if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  memset(&addr, 0, sizeof(addr));\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  listenPort1 = PR_ntohs(addr.inet.port);\n+  optval.option = PR_SockOpt_Nonblocking;\n+  optval.value.non_blocking = PR_TRUE;\n+  PR_SetSocketOption(listenSock1, &optval);\n+  if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+\n+  if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  listenPort2 = PR_ntohs(addr.inet.port);\n+  PR_SetSocketOption(listenSock2, &optval);\n+  if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  PR_snprintf(buf, sizeof(buf),\n+              \"The server thread is listening on ports %hu and %hu\\n\\n\",\n+              listenPort1, listenPort2);\n+  if (debug_mode) {\n+    printf(\"%s\", buf);\n+  }\n+\n+  /* Set up the poll descriptor array */\n+  pds = pds0;\n+  other_pds = pds1;\n+  memset(pds, 0, sizeof(pds));\n+  pds[0].fd = listenSock1;\n+  pds[0].in_flags = PR_POLL_READ;\n+  pds[1].fd = listenSock2;\n+  pds[1].in_flags = PR_POLL_READ;\n+  /* Add some unused entries to test if they are ignored by PR_Poll() */\n+  memset(&pds[2], 0, sizeof(pds[2]));\n+  memset(&pds[3], 0, sizeof(pds[3]));\n+  memset(&pds[4], 0, sizeof(pds[4]));\n+  npds = 5;\n+\n+  clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n+                                 (void*)listenPort1, PR_PRIORITY_NORMAL,\n+                                 PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  if (clientThread == NULL) {\n+    fprintf(stderr, \"can't create thread\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+\n+  clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n+                                 (void*)listenPort2, PR_PRIORITY_NORMAL,\n+                                 PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  if (clientThread == NULL) {\n+    fprintf(stderr, \"can't create thread\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+\n+  if (debug_mode) {\n+    printf(\"Two client threads are created.  Each of them will\\n\");\n+    printf(\"send data to one of the two ports the server is listening on.\\n\");\n+    printf(\"The data they send is the port number.  Each of them send\\n\");\n+    printf(\"the data five times, so you should see ten lines below,\\n\");\n+    printf(\"interleaved in an arbitrary order.\\n\");\n+  }\n+\n+  /* two clients, three events per iteration: accept, read, close */\n+  i = 0;\n+  while (i < 2 * 3 * NUM_ITERATIONS) {\n+    PRPollDesc* tmp;\n+    int nextIndex;\n+    int nEvents = 0;\n+\n+    retVal = PR_Poll(pds, npds, PR_INTERVAL_NO_TIMEOUT);\n+    PR_ASSERT(retVal != 0); /* no timeout */\n+    if (retVal == -1) {\n+      fprintf(stderr, \"PR_Poll failed\\n\");\n+      failed_already = 1;\n+      goto exit_now;\n     }\n \n-    if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    nextIndex = 2;\n+    /* the two listening sockets */\n+    for (j = 0; j < 2; j++) {\n+      other_pds[j] = pds[j];\n+      PR_ASSERT((pds[j].out_flags & PR_POLL_WRITE) == 0 &&\n+                (pds[j].out_flags & PR_POLL_EXCEPT) == 0);\n+      if (pds[j].out_flags & PR_POLL_READ) {\n+        PRFileDesc* sock;\n+\n+        nEvents++;\n+        sock = PR_Accept(pds[j].fd, NULL, PR_INTERVAL_NO_TIMEOUT);\n+        if (sock == NULL) {\n+          fprintf(stderr, \"PR_Accept() failed\\n\");\n+          failed_already = 1;\n+          goto exit_now;\n+        }\n+        other_pds[nextIndex].fd = sock;\n+        other_pds[nextIndex].in_flags = PR_POLL_READ;\n+        nextIndex++;\n+      } else if (pds[j].out_flags & PR_POLL_ERR) {\n+        fprintf(stderr, \"PR_Poll() indicates that an fd has error\\n\");\n         failed_already = 1;\n         goto exit_now;\n-    }\n-    listenPort2 = PR_ntohs(addr.inet.port);\n-    PR_SetSocketOption(listenSock2, &optval);\n-    if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n+      } else if (pds[j].out_flags & PR_POLL_NVAL) {\n+        fprintf(stderr, \"PR_Poll() indicates that fd %d is invalid\\n\",\n+                PR_FileDesc2NativeHandle(pds[j].fd));\n         failed_already = 1;\n         goto exit_now;\n-    }\n-    PR_snprintf(buf, sizeof(buf),\n-                \"The server thread is listening on ports %hu and %hu\\n\\n\",\n-                listenPort1, listenPort2);\n-    if (debug_mode) {\n-        printf(\"%s\", buf);\n+      }\n     }\n \n-    /* Set up the poll descriptor array */\n-    pds = pds0;\n-    other_pds = pds1;\n-    memset(pds, 0, sizeof(pds));\n-    pds[0].fd = listenSock1;\n-    pds[0].in_flags = PR_POLL_READ;\n-    pds[1].fd = listenSock2;\n-    pds[1].in_flags = PR_POLL_READ;\n-    /* Add some unused entries to test if they are ignored by PR_Poll() */\n-    memset(&pds[2], 0, sizeof(pds[2]));\n-    memset(&pds[3], 0, sizeof(pds[3]));\n-    memset(&pds[4], 0, sizeof(pds[4]));\n-    npds = 5;\n-\n-    clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n-                                   (void*)listenPort1, PR_PRIORITY_NORMAL,\n-                                   PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    if (clientThread == NULL) {\n-        fprintf(stderr, \"can't create thread\\n\");\n+    for (j = 2; j < npds; j++) {\n+      if (NULL == pds[j].fd) {\n+        /*\n+         * Keep the unused entries in the poll descriptor array\n+         * for testing purposes.\n+         */\n+        other_pds[nextIndex] = pds[j];\n+        nextIndex++;\n+        continue;\n+      }\n+\n+      PR_ASSERT((pds[j].out_flags & PR_POLL_WRITE) == 0 &&\n+                (pds[j].out_flags & PR_POLL_EXCEPT) == 0);\n+      if (pds[j].out_flags & PR_POLL_READ) {\n+        PRInt32 nAvail;\n+        PRInt32 nRead;\n+\n+        nEvents++;\n+        nAvail = PR_Available(pds[j].fd);\n+        nRead = PR_Read(pds[j].fd, buf, sizeof(buf));\n+        PR_ASSERT(nAvail == nRead);\n+        if (nRead == -1) {\n+          fprintf(stderr, \"PR_Read() failed\\n\");\n+          failed_already = 1;\n+          goto exit_now;\n+        } else if (nRead == 0) {\n+          PR_Close(pds[j].fd);\n+          continue;\n+        } else {\n+          /* Just to be safe */\n+          buf[127] = '\\0';\n+          if (debug_mode) {\n+            printf(\"The server received \\\"%s\\\" from a client\\n\", buf);\n+          }\n+        }\n+      } else if (pds[j].out_flags & PR_POLL_ERR) {\n+        fprintf(stderr, \"PR_Poll() indicates that an fd has error\\n\");\n         failed_already = 1;\n         goto exit_now;\n-    }\n-\n-    clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n-                                   (void*)listenPort2, PR_PRIORITY_NORMAL,\n-                                   PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    if (clientThread == NULL) {\n-        fprintf(stderr, \"can't create thread\\n\");\n+      } else if (pds[j].out_flags & PR_POLL_NVAL) {\n+        fprintf(stderr, \"PR_Poll() indicates that an fd is invalid\\n\");\n         failed_already = 1;\n         goto exit_now;\n+      }\n+      other_pds[nextIndex] = pds[j];\n+      nextIndex++;\n     }\n \n-    if (debug_mode) {\n-        printf(\"Two client threads are created.  Each of them will\\n\");\n-        printf(\"send data to one of the two ports the server is listening on.\\n\");\n-        printf(\"The data they send is the port number.  Each of them send\\n\");\n-        printf(\"the data five times, so you should see ten lines below,\\n\");\n-        printf(\"interleaved in an arbitrary order.\\n\");\n-    }\n+    PR_ASSERT(retVal == nEvents);\n+    /* swap */\n+    tmp = pds;\n+    pds = other_pds;\n+    other_pds = tmp;\n+    npds = nextIndex;\n+    i += nEvents;\n+  }\n \n-    /* two clients, three events per iteration: accept, read, close */\n-    i = 0;\n-    while (i < 2 * 3 * NUM_ITERATIONS) {\n-        PRPollDesc* tmp;\n-        int nextIndex;\n-        int nEvents = 0;\n-\n-        retVal = PR_Poll(pds, npds, PR_INTERVAL_NO_TIMEOUT);\n-        PR_ASSERT(retVal != 0); /* no timeout */\n-        if (retVal == -1) {\n-            fprintf(stderr, \"PR_Poll failed\\n\");\n-            failed_already = 1;\n-            goto exit_now;\n-        }\n-\n-        nextIndex = 2;\n-        /* the two listening sockets */\n-        for (j = 0; j < 2; j++) {\n-            other_pds[j] = pds[j];\n-            PR_ASSERT((pds[j].out_flags & PR_POLL_WRITE) == 0 &&\n-                      (pds[j].out_flags & PR_POLL_EXCEPT) == 0);\n-            if (pds[j].out_flags & PR_POLL_READ) {\n-                PRFileDesc* sock;\n-\n-                nEvents++;\n-                sock = PR_Accept(pds[j].fd, NULL, PR_INTERVAL_NO_TIMEOUT);\n-                if (sock == NULL) {\n-                    fprintf(stderr, \"PR_Accept() failed\\n\");\n-                    failed_already = 1;\n-                    goto exit_now;\n-                }\n-                other_pds[nextIndex].fd = sock;\n-                other_pds[nextIndex].in_flags = PR_POLL_READ;\n-                nextIndex++;\n-            } else if (pds[j].out_flags & PR_POLL_ERR) {\n-                fprintf(stderr, \"PR_Poll() indicates that an fd has error\\n\");\n-                failed_already = 1;\n-                goto exit_now;\n-            } else if (pds[j].out_flags & PR_POLL_NVAL) {\n-                fprintf(stderr, \"PR_Poll() indicates that fd %d is invalid\\n\",\n-                        PR_FileDesc2NativeHandle(pds[j].fd));\n-                failed_already = 1;\n-                goto exit_now;\n-            }\n-        }\n-\n-        for (j = 2; j < npds; j++) {\n-            if (NULL == pds[j].fd) {\n-                /*\n-                 * Keep the unused entries in the poll descriptor array\n-                 * for testing purposes.\n-                 */\n-                other_pds[nextIndex] = pds[j];\n-                nextIndex++;\n-                continue;\n-            }\n-\n-            PR_ASSERT((pds[j].out_flags & PR_POLL_WRITE) == 0 &&\n-                      (pds[j].out_flags & PR_POLL_EXCEPT) == 0);\n-            if (pds[j].out_flags & PR_POLL_READ) {\n-                PRInt32 nAvail;\n-                PRInt32 nRead;\n-\n-                nEvents++;\n-                nAvail = PR_Available(pds[j].fd);\n-                nRead = PR_Read(pds[j].fd, buf, sizeof(buf));\n-                PR_ASSERT(nAvail == nRead);\n-                if (nRead == -1) {\n-                    fprintf(stderr, \"PR_Read() failed\\n\");\n-                    failed_already = 1;\n-                    goto exit_now;\n-                } else if (nRead == 0) {\n-                    PR_Close(pds[j].fd);\n-                    continue;\n-                } else {\n-                    /* Just to be safe */\n-                    buf[127] = '\\0';\n-                    if (debug_mode) {\n-                        printf(\"The server received \\\"%s\\\" from a client\\n\", buf);\n-                    }\n-                }\n-            } else if (pds[j].out_flags & PR_POLL_ERR) {\n-                fprintf(stderr, \"PR_Poll() indicates that an fd has error\\n\");\n-                failed_already = 1;\n-                goto exit_now;\n-            } else if (pds[j].out_flags & PR_POLL_NVAL) {\n-                fprintf(stderr, \"PR_Poll() indicates that an fd is invalid\\n\");\n-                failed_already = 1;\n-                goto exit_now;\n-            }\n-            other_pds[nextIndex] = pds[j];\n-            nextIndex++;\n-        }\n-\n-        PR_ASSERT(retVal == nEvents);\n-        /* swap */\n-        tmp = pds;\n-        pds = other_pds;\n-        other_pds = tmp;\n-        npds = nextIndex;\n-        i += nEvents;\n-    }\n-\n-    if (debug_mode) {\n-        printf(\"Tests passed\\n\");\n-    }\n+  if (debug_mode) {\n+    printf(\"Tests passed\\n\");\n+  }\n \n exit_now:\n \n-    if (listenSock1) {\n-        PR_Close(listenSock1);\n-    }\n-    if (listenSock2) {\n-        PR_Close(listenSock2);\n-    }\n+  if (listenSock1) {\n+    PR_Close(listenSock1);\n+  }\n+  if (listenSock2) {\n+    PR_Close(listenSock2);\n+  }\n \n-    PR_Cleanup();\n+  PR_Cleanup();\n \n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/poll_to.c b/nspr/pr/tests/poll_to.c\nindex 8fd3815..9aeae5e 100644\n--- a/nspr/pr/tests/poll_to.c\n+++ b/nspr/pr/tests/poll_to.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -44,164 +45,162 @@\n PRIntn failed_already = 0;\n PRIntn debug_mode;\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc *listenSock1 = NULL, *listenSock2 = NULL;\n-    PRUint16 listenPort1, listenPort2;\n-    PRNetAddr addr;\n-    char buf[128];\n-    PRPollDesc pds0[10], pds1[10], *pds, *other_pds;\n-    PRIntn npds;\n-    PRInt32 retVal;\n-\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    if (debug_mode) {\n-        printf(\"This program tests PR_Poll with sockets.\\n\");\n-        printf(\"Timeout is tested.\\n\\n\");\n-    }\n-\n-    /* Create two listening sockets */\n-    if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n-    }\n-    memset(&addr, 0, sizeof(addr));\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n-    }\n-    if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n-    }\n-    listenPort1 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n-    }\n-\n-    if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n-    }\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n-    }\n-    if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n-    }\n-    listenPort2 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n-    }\n+int main(int argc, char** argv) {\n+  PRFileDesc *listenSock1 = NULL, *listenSock2 = NULL;\n+  PRUint16 listenPort1, listenPort2;\n+  PRNetAddr addr;\n+  char buf[128];\n+  PRPollDesc pds0[10], pds1[10], *pds, *other_pds;\n+  PRIntn npds;\n+  PRInt32 retVal;\n+\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  if (debug_mode) {\n+    printf(\"This program tests PR_Poll with sockets.\\n\");\n+    printf(\"Timeout is tested.\\n\\n\");\n+  }\n+\n+  /* Create two listening sockets */\n+  if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    }\n+    goto exit_now;\n+  }\n+  memset(&addr, 0, sizeof(addr));\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    }\n+    goto exit_now;\n+  }\n+  if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    }\n+    goto exit_now;\n+  }\n+  listenPort1 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    }\n+    goto exit_now;\n+  }\n+\n+  if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    }\n+    goto exit_now;\n+  }\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    }\n+    goto exit_now;\n+  }\n+  if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    }\n+    goto exit_now;\n+  }\n+  listenPort2 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    }\n+    goto exit_now;\n+  }\n+  PR_snprintf(buf, sizeof(buf),\n+              \"The server thread is listening on ports %hu and %hu\\n\\n\",\n+              listenPort1, listenPort2);\n+  if (debug_mode) {\n+    printf(\"%s\", buf);\n+  }\n+\n+  /* Set up the poll descriptor array */\n+  pds = pds0;\n+  other_pds = pds1;\n+  memset(pds, 0, sizeof(pds));\n+  pds[0].fd = listenSock1;\n+  pds[0].in_flags = PR_POLL_READ;\n+  pds[1].fd = listenSock2;\n+  pds[1].in_flags = PR_POLL_READ;\n+  npds = 2;\n+\n+  /* Testing timeout */\n+  if (debug_mode) {\n+    printf(\"PR_Poll should time out in 5 seconds\\n\");\n+  }\n+  retVal = PR_Poll(pds, npds, PR_SecondsToInterval(5));\n+  if (retVal != 0) {\n     PR_snprintf(buf, sizeof(buf),\n-                \"The server thread is listening on ports %hu and %hu\\n\\n\",\n-                listenPort1, listenPort2);\n-    if (debug_mode) {\n-        printf(\"%s\", buf);\n-    }\n-\n-    /* Set up the poll descriptor array */\n-    pds = pds0;\n-    other_pds = pds1;\n-    memset(pds, 0, sizeof(pds));\n-    pds[0].fd = listenSock1;\n-    pds[0].in_flags = PR_POLL_READ;\n-    pds[1].fd = listenSock2;\n-    pds[1].in_flags = PR_POLL_READ;\n-    npds = 2;\n-\n-    /* Testing timeout */\n-    if (debug_mode) {\n-        printf(\"PR_Poll should time out in 5 seconds\\n\");\n-    }\n-    retVal = PR_Poll(pds, npds, PR_SecondsToInterval(5));\n-    if (retVal != 0) {\n-        PR_snprintf(buf, sizeof(buf),\n-                    \"PR_Poll should time out and return 0, but it returns %ld\\n\",\n-                    retVal);\n-        fprintf(stderr, \"%s\", buf);\n-        if (!debug_mode) {\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n-    }\n-    if (debug_mode) {\n-        printf(\"PR_Poll timed out.  Test passed.\\n\\n\");\n-    }\n+                \"PR_Poll should time out and return 0, but it returns %ld\\n\",\n+                retVal);\n+    fprintf(stderr, \"%s\", buf);\n+    if (!debug_mode) {\n+      failed_already = 1;\n+    }\n+    goto exit_now;\n+  }\n+  if (debug_mode) {\n+    printf(\"PR_Poll timed out.  Test passed.\\n\\n\");\n+  }\n \n exit_now:\n \n-    if (listenSock1) {\n-        PR_Close(listenSock1);\n-    }\n-    if (listenSock2) {\n-        PR_Close(listenSock2);\n-    }\n+  if (listenSock1) {\n+    PR_Close(listenSock1);\n+  }\n+  if (listenSock2) {\n+    PR_Close(listenSock2);\n+  }\n \n-    PR_Cleanup();\n+  PR_Cleanup();\n \n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/pollable.c b/nspr/pr/tests/pollable.c\nindex 1ab1aff..742b42a 100644\n--- a/nspr/pr/tests/pollable.c\n+++ b/nspr/pr/tests/pollable.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -32,230 +33,225 @@ PRBool debug_mode = PR_FALSE;\n PRBool verbosity = PR_FALSE;\n \n typedef struct ThreadData {\n-    PRFileDesc* event;\n-    int index;\n-    struct ThreadData* next;\n+  PRFileDesc* event;\n+  int index;\n+  struct ThreadData* next;\n } ThreadData;\n \n-void\n-ThreadRoutine(void* arg)\n-{\n-    ThreadData* data = (ThreadData*)arg;\n-    PRIntn i;\n-    PRPollDesc pd;\n-    PRInt32 rv;\n+void ThreadRoutine(void* arg) {\n+  ThreadData* data = (ThreadData*)arg;\n+  PRIntn i;\n+  PRPollDesc pd;\n+  PRInt32 rv;\n \n-    pd.fd = data->event;\n-    pd.in_flags = PR_POLL_READ;\n+  pd.fd = data->event;\n+  pd.in_flags = PR_POLL_READ;\n \n-    for (i = 0; i < numIterations; i++) {\n-        rv = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n-        if (rv == -1) {\n-            PR_fprintf(PR_STDERR, \"PR_Poll failed\\n\");\n-            exit(1);\n-        }\n-        if (verbosity) {\n-            PR_fprintf(debug_out, \"thread %d awakened\\n\", data->index);\n-        }\n-        PR_ASSERT(rv != 0);\n-        PR_ASSERT(pd.out_flags & PR_POLL_READ);\n-        if (PR_WaitForPollableEvent(data->event) == PR_FAILURE) {\n-            PR_fprintf(PR_STDERR, \"consume event failed\\n\");\n-            exit(1);\n-        }\n-        if (dally != PR_INTERVAL_NO_WAIT) {\n-            PR_Sleep(dally);\n-        }\n-        if (verbosity) {\n-            PR_fprintf(debug_out, \"thread %d posting event\\n\", data->index);\n-        }\n-        if (PR_SetPollableEvent(data->next->event) == PR_FAILURE) {\n-            PR_fprintf(PR_STDERR, \"post event failed\\n\");\n-            exit(1);\n-        }\n+  for (i = 0; i < numIterations; i++) {\n+    rv = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n+    if (rv == -1) {\n+      PR_fprintf(PR_STDERR, \"PR_Poll failed\\n\");\n+      exit(1);\n     }\n+    if (verbosity) {\n+      PR_fprintf(debug_out, \"thread %d awakened\\n\", data->index);\n+    }\n+    PR_ASSERT(rv != 0);\n+    PR_ASSERT(pd.out_flags & PR_POLL_READ);\n+    if (PR_WaitForPollableEvent(data->event) == PR_FAILURE) {\n+      PR_fprintf(PR_STDERR, \"consume event failed\\n\");\n+      exit(1);\n+    }\n+    if (dally != PR_INTERVAL_NO_WAIT) {\n+      PR_Sleep(dally);\n+    }\n+    if (verbosity) {\n+      PR_fprintf(debug_out, \"thread %d posting event\\n\", data->index);\n+    }\n+    if (PR_SetPollableEvent(data->next->event) == PR_FAILURE) {\n+      PR_fprintf(PR_STDERR, \"post event failed\\n\");\n+      exit(1);\n+    }\n+  }\n }\n \n-static void\n-Help(void)\n-{\n-    debug_out = PR_STDOUT;\n+static void Help(void) {\n+  debug_out = PR_STDOUT;\n \n-    PR_fprintf(debug_out,\n-               \"Usage: pollable [-c n] [-t n] [-d] [-v] [-G] [-C n] [-D n]\\n\");\n-    PR_fprintf(debug_out, \"-c n\\tloops at thread level (default: %d)\\n\",\n-               DEFAULT_LOOPS);\n-    PR_fprintf(debug_out, \"-t n\\tnumber of threads (default: %d)\\n\",\n-               DEFAULT_THREADS);\n-    PR_fprintf(debug_out, \"-d\\tturn on debugging output (default: FALSE)\\n\");\n-    PR_fprintf(debug_out, \"-v\\tturn on verbose output (default: FALSE)\\n\");\n-    PR_fprintf(debug_out, \"-G\\tglobal threads only (default: FALSE)\\n\");\n-    PR_fprintf(debug_out, \"-C n\\tconcurrency setting (default: 1)\\n\");\n-    PR_fprintf(debug_out, \"-D n\\tdally setting (msecs) (default: 0)\\n\");\n+  PR_fprintf(debug_out,\n+             \"Usage: pollable [-c n] [-t n] [-d] [-v] [-G] [-C n] [-D n]\\n\");\n+  PR_fprintf(debug_out, \"-c n\\tloops at thread level (default: %d)\\n\",\n+             DEFAULT_LOOPS);\n+  PR_fprintf(debug_out, \"-t n\\tnumber of threads (default: %d)\\n\",\n+             DEFAULT_THREADS);\n+  PR_fprintf(debug_out, \"-d\\tturn on debugging output (default: FALSE)\\n\");\n+  PR_fprintf(debug_out, \"-v\\tturn on verbose output (default: FALSE)\\n\");\n+  PR_fprintf(debug_out, \"-G\\tglobal threads only (default: FALSE)\\n\");\n+  PR_fprintf(debug_out, \"-C n\\tconcurrency setting (default: 1)\\n\");\n+  PR_fprintf(debug_out, \"-D n\\tdally setting (msecs) (default: 0)\\n\");\n } /* Help */\n \n-int\n-main(int argc, char** argv)\n-{\n-    ThreadData selfData;\n-    ThreadData* data;\n-    PRThread** thread;\n-    void* block;\n-    PRIntn i;\n-    PRIntervalTime timeStart, timeEnd;\n-    PRPollDesc pd;\n-    PRInt32 rv;\n-    PRThreadScope thread_scope = PR_LOCAL_THREAD;\n-    PRBool help = PR_FALSE;\n-    PRUintn concurrency = 1;\n-    PRUintn average;\n-    PLOptStatus os;\n-    PLOptState* opt;\n+int main(int argc, char** argv) {\n+  ThreadData selfData;\n+  ThreadData* data;\n+  PRThread** thread;\n+  void* block;\n+  PRIntn i;\n+  PRIntervalTime timeStart, timeEnd;\n+  PRPollDesc pd;\n+  PRInt32 rv;\n+  PRThreadScope thread_scope = PR_LOCAL_THREAD;\n+  PRBool help = PR_FALSE;\n+  PRUintn concurrency = 1;\n+  PRUintn average;\n+  PLOptStatus os;\n+  PLOptState* opt;\n \n-    opt = PL_CreateOptState(argc, argv, \"hdvc:t:C:GD:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'v': /* verbose mode */\n-                verbosity = PR_TRUE;\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            case 'c': /* loop counter */\n-                numIterations = atoi(opt->value);\n-                break;\n-            case 't': /* thread limit */\n-                numThreads = atoi(opt->value);\n-                break;\n-            case 'C': /* Concurrency limit */\n-                concurrency = atoi(opt->value);\n-                break;\n-            case 'G': /* global threads only */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'D': /* dally */\n-                dally = PR_MillisecondsToInterval(atoi(opt->value));\n-                break;\n-            case 'h': /* help message */\n-                Help();\n-                help = PR_TRUE;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n \n-    if (help) {\n-        return 1;\n+  opt = PL_CreateOptState(argc, argv, \"hdvc:t:C:GD:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-\n-    if (concurrency > 1) {\n-        PR_SetConcurrency(concurrency);\n+    switch (opt->option) {\n+      case 'v': /* verbose mode */\n+        verbosity = PR_TRUE;\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      case 'c': /* loop counter */\n+        numIterations = atoi(opt->value);\n+        break;\n+      case 't': /* thread limit */\n+        numThreads = atoi(opt->value);\n+        break;\n+      case 'C': /* Concurrency limit */\n+        concurrency = atoi(opt->value);\n+        break;\n+      case 'G': /* global threads only */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'D': /* dally */\n+        dally = PR_MillisecondsToInterval(atoi(opt->value));\n+        break;\n+      case 'h': /* help message */\n+        Help();\n+        help = PR_TRUE;\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    if (PR_TRUE == debug_mode) {\n-        debug_out = PR_STDOUT;\n-        PR_fprintf(debug_out, \"Test parameters\\n\");\n-        PR_fprintf(debug_out, \"\\tThreads involved: %d\\n\", numThreads);\n-        PR_fprintf(debug_out, \"\\tIteration limit: %d\\n\", numIterations);\n-        PR_fprintf(debug_out, \"\\tConcurrency: %d\\n\", concurrency);\n-        PR_fprintf(debug_out, \"\\tThread type: %s\\n\",\n-                   (PR_GLOBAL_THREAD == thread_scope) ? \"GLOBAL\" : \"LOCAL\");\n-    }\n+  if (help) {\n+    return 1;\n+  }\n \n-    /*\n-     * Malloc a block of memory and divide it into data and thread.\n-     */\n-    block = PR_MALLOC(numThreads * (sizeof(ThreadData) + sizeof(PRThread*)));\n-    if (block == NULL) {\n-        PR_fprintf(PR_STDERR, \"cannot malloc, failed\\n\");\n-        exit(1);\n-    }\n-    data = (ThreadData*)block;\n-    thread = (PRThread**)&data[numThreads];\n+  if (concurrency > 1) {\n+    PR_SetConcurrency(concurrency);\n+  }\n \n-    /* Pollable event */\n-    selfData.event = PR_NewPollableEvent();\n-    if (selfData.event == NULL) {\n-        PR_fprintf(PR_STDERR, \"cannot create event: (%ld, %ld)\\n\", PR_GetError(),\n-                   PR_GetOSError());\n-        exit(1);\n-    }\n-    selfData.next = &data[0];\n-    for (i = 0; i < numThreads; i++) {\n-        data[i].event = PR_NewPollableEvent();\n-        if (data[i].event == NULL) {\n-            PR_fprintf(PR_STDERR, \"cannot create event: (%ld, %ld)\\n\", PR_GetError(),\n-                       PR_GetOSError());\n-            exit(1);\n-        }\n-        data[i].index = i;\n-        if (i != numThreads - 1) {\n-            data[i].next = &data[i + 1];\n-        } else {\n-            data[i].next = &selfData;\n-        }\n+  if (PR_TRUE == debug_mode) {\n+    debug_out = PR_STDOUT;\n+    PR_fprintf(debug_out, \"Test parameters\\n\");\n+    PR_fprintf(debug_out, \"\\tThreads involved: %d\\n\", numThreads);\n+    PR_fprintf(debug_out, \"\\tIteration limit: %d\\n\", numIterations);\n+    PR_fprintf(debug_out, \"\\tConcurrency: %d\\n\", concurrency);\n+    PR_fprintf(debug_out, \"\\tThread type: %s\\n\",\n+               (PR_GLOBAL_THREAD == thread_scope) ? \"GLOBAL\" : \"LOCAL\");\n+  }\n+\n+  /*\n+   * Malloc a block of memory and divide it into data and thread.\n+   */\n+  block = PR_MALLOC(numThreads * (sizeof(ThreadData) + sizeof(PRThread*)));\n+  if (block == NULL) {\n+    PR_fprintf(PR_STDERR, \"cannot malloc, failed\\n\");\n+    exit(1);\n+  }\n+  data = (ThreadData*)block;\n+  thread = (PRThread**)&data[numThreads];\n \n-        thread[i] = PR_CreateThread(PR_USER_THREAD, ThreadRoutine, &data[i],\n-                                    PR_PRIORITY_NORMAL, thread_scope,\n-                                    PR_JOINABLE_THREAD, 0);\n-        if (thread[i] == NULL) {\n-            PR_fprintf(PR_STDERR, \"cannot create thread\\n\");\n-            exit(1);\n-        }\n+  /* Pollable event */\n+  selfData.event = PR_NewPollableEvent();\n+  if (selfData.event == NULL) {\n+    PR_fprintf(PR_STDERR, \"cannot create event: (%ld, %ld)\\n\", PR_GetError(),\n+               PR_GetOSError());\n+    exit(1);\n+  }\n+  selfData.next = &data[0];\n+  for (i = 0; i < numThreads; i++) {\n+    data[i].event = PR_NewPollableEvent();\n+    if (data[i].event == NULL) {\n+      PR_fprintf(PR_STDERR, \"cannot create event: (%ld, %ld)\\n\", PR_GetError(),\n+                 PR_GetOSError());\n+      exit(1);\n+    }\n+    data[i].index = i;\n+    if (i != numThreads - 1) {\n+      data[i].next = &data[i + 1];\n+    } else {\n+      data[i].next = &selfData;\n     }\n \n-    timeStart = PR_IntervalNow();\n-    pd.fd = selfData.event;\n-    pd.in_flags = PR_POLL_READ;\n-    for (i = 0; i < numIterations; i++) {\n-        if (dally != PR_INTERVAL_NO_WAIT) {\n-            PR_Sleep(dally);\n-        }\n-        if (verbosity) {\n-            PR_fprintf(debug_out, \"main thread posting event\\n\");\n-        }\n-        if (PR_SetPollableEvent(selfData.next->event) == PR_FAILURE) {\n-            PR_fprintf(PR_STDERR, \"set event failed\\n\");\n-            exit(1);\n-        }\n-        rv = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n-        if (rv == -1) {\n-            PR_fprintf(PR_STDERR, \"wait failed\\n\");\n-            exit(1);\n-        }\n-        PR_ASSERT(rv != 0);\n-        PR_ASSERT(pd.out_flags & PR_POLL_READ);\n-        if (verbosity) {\n-            PR_fprintf(debug_out, \"main thread awakened\\n\");\n-        }\n-        if (PR_WaitForPollableEvent(selfData.event) == PR_FAILURE) {\n-            PR_fprintf(PR_STDERR, \"consume event failed\\n\");\n-            exit(1);\n-        }\n+    thread[i] = PR_CreateThread(PR_USER_THREAD, ThreadRoutine, &data[i],\n+                                PR_PRIORITY_NORMAL, thread_scope,\n+                                PR_JOINABLE_THREAD, 0);\n+    if (thread[i] == NULL) {\n+      PR_fprintf(PR_STDERR, \"cannot create thread\\n\");\n+      exit(1);\n     }\n-    timeEnd = PR_IntervalNow();\n+  }\n \n-    if (debug_mode) {\n-        average = PR_IntervalToMicroseconds(timeEnd - timeStart) /\n-                  (numIterations * numThreads);\n-        PR_fprintf(debug_out, \"Average switch times %d usecs for %d threads\\n\",\n-                   average, numThreads);\n+  timeStart = PR_IntervalNow();\n+  pd.fd = selfData.event;\n+  pd.in_flags = PR_POLL_READ;\n+  for (i = 0; i < numIterations; i++) {\n+    if (dally != PR_INTERVAL_NO_WAIT) {\n+      PR_Sleep(dally);\n+    }\n+    if (verbosity) {\n+      PR_fprintf(debug_out, \"main thread posting event\\n\");\n     }\n+    if (PR_SetPollableEvent(selfData.next->event) == PR_FAILURE) {\n+      PR_fprintf(PR_STDERR, \"set event failed\\n\");\n+      exit(1);\n+    }\n+    rv = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);\n+    if (rv == -1) {\n+      PR_fprintf(PR_STDERR, \"wait failed\\n\");\n+      exit(1);\n+    }\n+    PR_ASSERT(rv != 0);\n+    PR_ASSERT(pd.out_flags & PR_POLL_READ);\n+    if (verbosity) {\n+      PR_fprintf(debug_out, \"main thread awakened\\n\");\n+    }\n+    if (PR_WaitForPollableEvent(selfData.event) == PR_FAILURE) {\n+      PR_fprintf(PR_STDERR, \"consume event failed\\n\");\n+      exit(1);\n+    }\n+  }\n+  timeEnd = PR_IntervalNow();\n+\n+  if (debug_mode) {\n+    average = PR_IntervalToMicroseconds(timeEnd - timeStart) /\n+              (numIterations * numThreads);\n+    PR_fprintf(debug_out, \"Average switch times %d usecs for %d threads\\n\",\n+               average, numThreads);\n+  }\n \n-    for (i = 0; i < numThreads; i++) {\n-        if (PR_JoinThread(thread[i]) == PR_FAILURE) {\n-            PR_fprintf(PR_STDERR, \"join thread failed\\n\");\n-            exit(1);\n-        }\n-        PR_DestroyPollableEvent(data[i].event);\n+  for (i = 0; i < numThreads; i++) {\n+    if (PR_JoinThread(thread[i]) == PR_FAILURE) {\n+      PR_fprintf(PR_STDERR, \"join thread failed\\n\");\n+      exit(1);\n     }\n-    PR_DELETE(block);\n-    PR_DestroyPollableEvent(selfData.event);\n+    PR_DestroyPollableEvent(data[i].event);\n+  }\n+  PR_DELETE(block);\n+  PR_DestroyPollableEvent(selfData.event);\n \n-    PR_fprintf(PR_STDOUT, \"PASSED\\n\");\n-    return 0;\n+  PR_fprintf(PR_STDOUT, \"PASSED\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/prefloop.c b/nspr/pr/tests/prefloop.c\ndeleted file mode 100644\nindex 8378ec1..0000000\n--- a/nspr/pr/tests/prefloop.c\n+++ /dev/null\n@@ -1,90 +0,0 @@\n-/* This Source Code Form is subject to the terms of the Mozilla Public\n- * License, v. 2.0. If a copy of the MPL was not distributed with this\n- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n-\n-/*\n- * Test PR_GetPrefLoopbackAddrInfo().\n- *\n- * The returned PRNetAddr must describe the loopback address with the\n- * requested port, and every byte past the address family's sockaddr must\n- * be zeroed -- callers compare and hash whole PRNetAddr structures, so\n- * leftover bytes there are a bug.\n- */\n-\n-#include \"nspr.h\"\n-\n-#include <stdio.h>\n-#include <string.h>\n-\n-#define TEST_PORT 4242\n-\n-int\n-main(int argc, char** argv)\n-{\n-    PRNetAddr addr;\n-    char buf[128];\n-    PRUint32 i, addrlen, junk = 0;\n-    PRUint16 port;\n-\n-    /*\n-     * Poison the buffer first: anything the callee fails to write or zero\n-     * stays visible as 0xAB.\n-     */\n-    memset(&addr, 0xAB, sizeof(addr));\n-\n-    if (PR_GetPrefLoopbackAddrInfo(&addr, TEST_PORT) != PR_SUCCESS) {\n-        /*\n-         * PR_GetPrefLoopbackAddrInfo is a stub on platforms built without\n-         * getaddrinfo() or AI_PASSIVE -- Windows, where the md headers only\n-         * pull in Winsock 1's <winsock.h>. Nothing to test there.\n-         */\n-        if (PR_GetError() == PR_NOT_IMPLEMENTED_ERROR) {\n-            printf(\"PR_GetPrefLoopbackAddrInfo not implemented, skipping\\n\");\n-            return 0;\n-        }\n-        fprintf(stderr, \"PR_GetPrefLoopbackAddrInfo failed: (%d, %d)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        return 1;\n-    }\n-\n-    if (addr.raw.family != PR_AF_INET && addr.raw.family != PR_AF_INET6) {\n-        fprintf(stderr, \"unexpected address family %d\\n\", addr.raw.family);\n-        return 1;\n-    }\n-\n-    if (PR_NetAddrToString(&addr, buf, sizeof(buf)) != PR_SUCCESS) {\n-        fprintf(stderr, \"PR_NetAddrToString failed: (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        return 1;\n-    }\n-\n-    port = (addr.raw.family == PR_AF_INET6) ? addr.ipv6.port : addr.inet.port;\n-    printf(\"family = %d, addr = %s, port = %u\\n\", addr.raw.family, buf,\n-           PR_ntohs(port));\n-\n-    if (!PR_IsNetAddrType(&addr, PR_IpAddrLoopback)) {\n-        fprintf(stderr, \"%s is not the loopback address\\n\", buf);\n-        return 1;\n-    }\n-\n-    if (PR_ntohs(port) != TEST_PORT) {\n-        fprintf(stderr, \"expected port %d, got %u\\n\", TEST_PORT, PR_ntohs(port));\n-        return 1;\n-    }\n-\n-    addrlen = (addr.raw.family == PR_AF_INET6) ? sizeof(addr.ipv6)\n-                                               : sizeof(addr.inet);\n-    for (i = addrlen; i < sizeof(addr); i++) {\n-        if (((unsigned char*)&addr)[i] != 0) {\n-            junk++;\n-        }\n-    }\n-    if (junk != 0) {\n-        fprintf(stderr, \"%u non-zero byte(s) past offset %u of %u\\n\", junk,\n-                addrlen, (PRUint32)sizeof(addr));\n-        return 1;\n-    }\n-\n-    printf(\"PASS\\n\");\n-    return 0;\n-}\ndiff --git a/nspr/pr/tests/prfdbl.c b/nspr/pr/tests/prfdbl.c\nindex 456dd8f..19a1553 100644\n--- a/nspr/pr/tests/prfdbl.c\n+++ b/nspr/pr/tests/prfdbl.c\n@@ -8,23 +8,21 @@\n \n #include \"prprf.h\"\n \n-int\n-main()\n-{\n-    double pi = 3.1415926;\n-    double e = 2.71828;\n-    double root2 = 1.414;\n-    double zero = 0.0;\n-    double nan = zero / zero;\n+int main() {\n+  double pi = 3.1415926;\n+  double e = 2.71828;\n+  double root2 = 1.414;\n+  double zero = 0.0;\n+  double nan = zero / zero;\n \n-    PR_fprintf(PR_STDOUT, \"pi is %f.\\n\", pi);\n-    PR_fprintf(PR_STDOUT, \"e is %f.\\n\", e);\n-    PR_fprintf(PR_STDOUT, \"The square root of 2 is %f.\\n\", root2);\n-    PR_fprintf(PR_STDOUT, \"NaN is %f.\\n\", nan);\n+  PR_fprintf(PR_STDOUT, \"pi is %f.\\n\", pi);\n+  PR_fprintf(PR_STDOUT, \"e is %f.\\n\", e);\n+  PR_fprintf(PR_STDOUT, \"The square root of 2 is %f.\\n\", root2);\n+  PR_fprintf(PR_STDOUT, \"NaN is %f.\\n\", nan);\n \n-    PR_fprintf(PR_STDOUT, \"pi is %301f.\\n\", pi);\n-    PR_fprintf(PR_STDOUT, \"e is %65416.123f.\\n\", e);\n-    PR_fprintf(PR_STDOUT, \"e is %0000000000000000000065416.123f.\\n\", e);\n-    PR_fprintf(PR_STDOUT, \"NaN is %1024.1f.\\n\", nan);\n-    return 0;\n+  PR_fprintf(PR_STDOUT, \"pi is %301f.\\n\", pi);\n+  PR_fprintf(PR_STDOUT, \"e is %65416.123f.\\n\", e);\n+  PR_fprintf(PR_STDOUT, \"e is %0000000000000000000065416.123f.\\n\", e);\n+  PR_fprintf(PR_STDOUT, \"NaN is %1024.1f.\\n\", nan);\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/prftest.c b/nspr/pr/tests/prftest.c\nindex 3872a66..0b5a851 100644\n--- a/nspr/pr/tests/prftest.c\n+++ b/nspr/pr/tests/prftest.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -16,51 +17,49 @@\n \n #define BUF_SIZE 128\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRInt16 i16;\n-    PRIntn n;\n-    PRInt32 i32;\n-    PRInt64 i64;\n-    char buf[BUF_SIZE];\n-    char answer[BUF_SIZE];\n-    int i, rv = 0;\n+int main(int argc, char** argv) {\n+  PRInt16 i16;\n+  PRIntn n;\n+  PRInt32 i32;\n+  PRInt64 i64;\n+  char buf[BUF_SIZE];\n+  char answer[BUF_SIZE];\n+  int i, rv = 0;\n \n-    i16 = -1;\n-    n = -1;\n-    i32 = -1;\n-    LL_I2L(i64, i32);\n+  i16 = -1;\n+  n = -1;\n+  i32 = -1;\n+  LL_I2L(i64, i32);\n \n-    PR_snprintf(buf, BUF_SIZE, \"%hx %x %lx %llx\", i16, n, i32, i64);\n-    strcpy(answer, \"ffff \");\n-    for (i = PR_BYTES_PER_INT * 2; i; i--) {\n-        strcat(answer, \"f\");\n-    }\n-    strcat(answer, \" ffffffff ffffffffffffffff\");\n+  PR_snprintf(buf, BUF_SIZE, \"%hx %x %lx %llx\", i16, n, i32, i64);\n+  strcpy(answer, \"ffff \");\n+  for (i = PR_BYTES_PER_INT * 2; i; i--) {\n+    strcat(answer, \"f\");\n+  }\n+  strcat(answer, \" ffffffff ffffffffffffffff\");\n \n-    if (!strcmp(buf, answer)) {\n-        printf(\"PR_snprintf test 1 passed\\n\");\n-    } else {\n-        printf(\"PR_snprintf test 1 failed\\n\");\n-        printf(\"Converted string is %s\\n\", buf);\n-        printf(\"Should be %s\\n\", answer);\n-        rv = 1;\n-    }\n+  if (!strcmp(buf, answer)) {\n+    printf(\"PR_snprintf test 1 passed\\n\");\n+  } else {\n+    printf(\"PR_snprintf test 1 failed\\n\");\n+    printf(\"Converted string is %s\\n\", buf);\n+    printf(\"Should be %s\\n\", answer);\n+    rv = 1;\n+  }\n \n-    i16 = -32;\n-    n = 30;\n-    i32 = 64;\n-    LL_I2L(i64, 333);\n-    PR_snprintf(buf, BUF_SIZE, \"%d %hd %lld %ld\", n, i16, i64, i32);\n-    if (!strcmp(buf, \"30 -32 333 64\")) {\n-        printf(\"PR_snprintf test 2 passed\\n\");\n-    } else {\n-        printf(\"PR_snprintf test 2 failed\\n\");\n-        printf(\"Converted string is %s\\n\", buf);\n-        printf(\"Should be 30 -32 333 64\\n\");\n-        rv = 1;\n-    }\n+  i16 = -32;\n+  n = 30;\n+  i32 = 64;\n+  LL_I2L(i64, 333);\n+  PR_snprintf(buf, BUF_SIZE, \"%d %hd %lld %ld\", n, i16, i64, i32);\n+  if (!strcmp(buf, \"30 -32 333 64\")) {\n+    printf(\"PR_snprintf test 2 passed\\n\");\n+  } else {\n+    printf(\"PR_snprintf test 2 failed\\n\");\n+    printf(\"Converted string is %s\\n\", buf);\n+    printf(\"Should be 30 -32 333 64\\n\");\n+    rv = 1;\n+  }\n \n-    return rv;\n+  return rv;\n }\ndiff --git a/nspr/pr/tests/prftest1.c b/nspr/pr/tests/prftest1.c\nindex 9f08625..8bec086 100644\n--- a/nspr/pr/tests/prftest1.c\n+++ b/nspr/pr/tests/prftest1.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -49,77 +50,73 @@\n **\n ***********************************************************************/\n \n-static void\n-Test_Result(int result)\n-{\n-    if (result == PASS) {\n-        printf(\"PASS\\n\");\n-    } else {\n-        printf(\"FAIL\\n\");\n-    }\n+static void Test_Result(int result) {\n+  if (result == PASS) {\n+    printf(\"PASS\\n\");\n+  } else {\n+    printf(\"FAIL\\n\");\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRInt16 i16;\n-    PRIntn n;\n-    PRInt32 i32;\n-    PRInt64 i64;\n-    char buf[BUF_SIZE];\n-    char answer[BUF_SIZE];\n-    int i;\n+int main(int argc, char** argv) {\n+  PRInt16 i16;\n+  PRIntn n;\n+  PRInt32 i32;\n+  PRInt64 i64;\n+  char buf[BUF_SIZE];\n+  char answer[BUF_SIZE];\n+  int i;\n \n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n+  }\n+  PL_DestroyOptState(opt);\n \n-    /* main test */\n+  /* main test */\n \n-    i16 = -1;\n-    n = -1;\n-    i32 = -1;\n-    LL_I2L(i64, i32);\n+  i16 = -1;\n+  n = -1;\n+  i32 = -1;\n+  LL_I2L(i64, i32);\n \n-    PR_snprintf(buf, BUF_SIZE, \"%hx %x %lx %llx\", i16, n, i32, i64);\n-    strcpy(answer, \"ffff \");\n-    for (i = PR_BYTES_PER_INT * 2; i; i--) {\n-        strcat(answer, \"f\");\n-    }\n-    strcat(answer, \" ffffffff ffffffffffffffff\");\n+  PR_snprintf(buf, BUF_SIZE, \"%hx %x %lx %llx\", i16, n, i32, i64);\n+  strcpy(answer, \"ffff \");\n+  for (i = PR_BYTES_PER_INT * 2; i; i--) {\n+    strcat(answer, \"f\");\n+  }\n+  strcat(answer, \" ffffffff ffffffffffffffff\");\n \n-    if (!strcmp(buf, answer)) {\n-        if (debug_mode) {\n-            printf(\"PR_snprintf test 1 passed\\n\");\n-        } else {\n-            Test_Result(PASS);\n-        }\n+  if (!strcmp(buf, answer)) {\n+    if (debug_mode) {\n+      printf(\"PR_snprintf test 1 passed\\n\");\n+    } else {\n+      Test_Result(PASS);\n+    }\n+  } else {\n+    if (debug_mode) {\n+      printf(\"PR_snprintf test 1 failed\\n\");\n+      printf(\"Converted string is %s\\n\", buf);\n+      printf(\"Should be %s\\n\", answer);\n     } else {\n-        if (debug_mode) {\n-            printf(\"PR_snprintf test 1 failed\\n\");\n-            printf(\"Converted string is %s\\n\", buf);\n-            printf(\"Should be %s\\n\", answer);\n-        } else {\n-            Test_Result(FAIL);\n-        }\n+      Test_Result(FAIL);\n     }\n+  }\n \n-    return 0;\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/prftest2.c b/nspr/pr/tests/prftest2.c\nindex efe7443..f84de3f 100644\n--- a/nspr/pr/tests/prftest2.c\n+++ b/nspr/pr/tests/prftest2.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -38,61 +39,59 @@\n PRIntn failed_already = 0;\n PRIntn debug_mode;\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRInt16 i16;\n-    PRIntn n;\n-    PRInt32 i32;\n-    PRInt64 i64;\n-    char buf[BUF_SIZE];\n+int main(int argc, char** argv) {\n+  PRInt16 i16;\n+  PRIntn n;\n+  PRInt32 i32;\n+  PRInt64 i64;\n+  char buf[BUF_SIZE];\n \n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    /* main test */\n+  /* main test */\n \n-    i16 = -32;\n-    n = 30;\n-    i32 = 64;\n-    LL_I2L(i64, 333);\n-    PR_snprintf(buf, BUF_SIZE, \"%d %hd %lld %ld\", n, i16, i64, i32);\n-    if (!strcmp(buf, \"30 -32 333 64\")) {\n-        if (debug_mode) {\n-            printf(\"PR_snprintf test 2 passed\\n\");\n-        }\n-    } else {\n-        if (debug_mode) {\n-            printf(\"PR_snprintf test 2 failed\\n\");\n-            printf(\"Converted string is %s\\n\", buf);\n-            printf(\"Should be 30 -32 333 64\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n+  i16 = -32;\n+  n = 30;\n+  i32 = 64;\n+  LL_I2L(i64, 333);\n+  PR_snprintf(buf, BUF_SIZE, \"%d %hd %lld %ld\", n, i16, i64, i32);\n+  if (!strcmp(buf, \"30 -32 333 64\")) {\n+    if (debug_mode) {\n+      printf(\"PR_snprintf test 2 passed\\n\");\n     }\n-    if (failed_already) {\n-        printf(\"FAILED\\n\");\n-        return 1;\n+  } else {\n+    if (debug_mode) {\n+      printf(\"PR_snprintf test 2 failed\\n\");\n+      printf(\"Converted string is %s\\n\", buf);\n+      printf(\"Should be 30 -32 333 64\\n\");\n     } else {\n-        printf(\"PASSED\\n\");\n-        return 0;\n+      failed_already = 1;\n     }\n+  }\n+  if (failed_already) {\n+    printf(\"FAILED\\n\");\n+    return 1;\n+  } else {\n+    printf(\"PASSED\\n\");\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/prfz.c b/nspr/pr/tests/prfz.c\nindex 538e195..a841066 100644\n--- a/nspr/pr/tests/prfz.c\n+++ b/nspr/pr/tests/prfz.c\n@@ -12,73 +12,71 @@\n #include <string.h>\n #include <stdint.h>\n \n-int\n-main(int argc, char** argv)\n-{\n-    char buffer[128];\n+int main(int argc, char** argv) {\n+  char buffer[128];\n \n-    size_t unsigned_small = 266;\n+  size_t unsigned_small = 266;\n #ifdef XP_UNIX\n-    ssize_t signed_small_p = 943;\n-    ssize_t signed_small_n = -1;\n+  ssize_t signed_small_p = 943;\n+  ssize_t signed_small_n = -1;\n #endif\n-    size_t unsigned_max = SIZE_MAX;\n-    size_t unsigned_min = 0;\n+  size_t unsigned_max = SIZE_MAX;\n+  size_t unsigned_min = 0;\n #ifdef XP_UNIX\n-    ssize_t signed_max = SSIZE_MAX;\n+  ssize_t signed_max = SSIZE_MAX;\n #endif\n \n-    printf(\"Test: unsigned small '%%zu' : \");\n-    PR_snprintf(buffer, sizeof(buffer), \"%zu\", unsigned_small);\n-    if (strncmp(buffer, \"266\", sizeof(buffer)) != 0) {\n-        printf(\"Failed, got '%s'\\n\", buffer);\n-        return -1;\n-    }\n-    printf(\"OK\\n\");\n+  printf(\"Test: unsigned small '%%zu' : \");\n+  PR_snprintf(buffer, sizeof(buffer), \"%zu\", unsigned_small);\n+  if (strncmp(buffer, \"266\", sizeof(buffer)) != 0) {\n+    printf(\"Failed, got '%s'\\n\", buffer);\n+    return -1;\n+  }\n+  printf(\"OK\\n\");\n \n #ifdef XP_UNIX\n-    printf(\"Test: signed small positive '%%zd' : \");\n-    PR_snprintf(buffer, sizeof(buffer), \"%zd\", signed_small_p);\n-    if (strncmp(buffer, \"943\", sizeof(buffer)) != 0) {\n-        printf(\"Failed, got '%s'\\n\", buffer);\n-        return -1;\n-    }\n-    printf(\"OK\\n\");\n+  printf(\"Test: signed small positive '%%zd' : \");\n+  PR_snprintf(buffer, sizeof(buffer), \"%zd\", signed_small_p);\n+  if (strncmp(buffer, \"943\", sizeof(buffer)) != 0) {\n+    printf(\"Failed, got '%s'\\n\", buffer);\n+    return -1;\n+  }\n+  printf(\"OK\\n\");\n \n-    printf(\"Test: signed small negative '%%zd' : \");\n-    PR_snprintf(buffer, sizeof(buffer), \"%zd\", signed_small_n);\n-    if (strncmp(buffer, \"-1\", sizeof(buffer)) != 0) {\n-        printf(\"Failed, got '%s'\\n\", buffer);\n-        return -1;\n-    }\n-    printf(\"OK\\n\");\n+  printf(\"Test: signed small negative '%%zd' : \");\n+  PR_snprintf(buffer, sizeof(buffer), \"%zd\", signed_small_n);\n+  if (strncmp(buffer, \"-1\", sizeof(buffer)) != 0) {\n+    printf(\"Failed, got '%s'\\n\", buffer);\n+    return -1;\n+  }\n+  printf(\"OK\\n\");\n #endif\n \n-    printf(\"Test: 0 '%%zu' : \");\n-    PR_snprintf(buffer, sizeof(buffer), \"%zu\", unsigned_min);\n-    if (strncmp(buffer, \"0\", sizeof(buffer)) != 0) {\n-        printf(\"Failed, got '%s'\\n\", buffer);\n-        return -1;\n-    }\n-    printf(\"OK\\n\");\n+  printf(\"Test: 0 '%%zu' : \");\n+  PR_snprintf(buffer, sizeof(buffer), \"%zu\", unsigned_min);\n+  if (strncmp(buffer, \"0\", sizeof(buffer)) != 0) {\n+    printf(\"Failed, got '%s'\\n\", buffer);\n+    return -1;\n+  }\n+  printf(\"OK\\n\");\n \n-    printf(\"Test: SIZE_MAX '%%zx' : \");\n-    PR_snprintf(buffer, sizeof(buffer), \"%zx\", unsigned_max);\n-    if (strspn(buffer, \"f\") != sizeof(size_t) * 2) {\n-        printf(\"Failed, got '%s'\\n\", buffer);\n-        return -1;\n-    }\n-    printf(\"OK\\n\");\n+  printf(\"Test: SIZE_MAX '%%zx' : \");\n+  PR_snprintf(buffer, sizeof(buffer), \"%zx\", unsigned_max);\n+  if (strspn(buffer, \"f\") != sizeof(size_t) * 2) {\n+    printf(\"Failed, got '%s'\\n\", buffer);\n+    return -1;\n+  }\n+  printf(\"OK\\n\");\n \n #ifdef XP_UNIX\n-    printf(\"Test: SSIZE_MAX '%%zx' : \");\n-    PR_snprintf(buffer, sizeof(buffer), \"%zx\", signed_max);\n-    if (*buffer != '7' || strspn(buffer + 1, \"f\") != sizeof(ssize_t) * 2 - 1) {\n-        printf(\"Failed, got '%s'\\n\", buffer);\n-        return -1;\n-    }\n-    printf(\"OK\\n\");\n+  printf(\"Test: SSIZE_MAX '%%zx' : \");\n+  PR_snprintf(buffer, sizeof(buffer), \"%zx\", signed_max);\n+  if (*buffer != '7' || strspn(buffer + 1, \"f\") != sizeof(ssize_t) * 2 - 1) {\n+    printf(\"Failed, got '%s'\\n\", buffer);\n+    return -1;\n+  }\n+  printf(\"OK\\n\");\n #endif\n \n-    return 0;\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/primblok.c b/nspr/pr/tests/primblok.c\nindex f9c5d6a..228ace6 100644\n--- a/nspr/pr/tests/primblok.c\n+++ b/nspr/pr/tests/primblok.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,107 +12,101 @@\n \n #if !defined(WINNT)\n \n-#include <stdio.h>\n+#  include <stdio.h>\n \n-int\n-main(int argc, char** argv)\n-{\n-    printf(\"This test is not relevant on this platform\\n\");\n-    return 0;\n+int main(int argc, char** argv) {\n+  printf(\"This test is not relevant on this platform\\n\");\n+  return 0;\n }\n \n #else /* WINNT */\n \n-#include \"nspr.h\"\n+#  include \"nspr.h\"\n \n-#include <windows.h>\n-#include <stdio.h>\n-#include <stdlib.h>\n-#include <string.h>\n+#  include <windows.h>\n+#  include <stdio.h>\n+#  include <stdlib.h>\n+#  include <string.h>\n \n-#define TEST_FILE_NAME \"primblok.dat\"\n+#  define TEST_FILE_NAME \"primblok.dat\"\n \n /* use InterlockedExchange to update this variable */\n static LONG iothread_done;\n \n-static void PR_CALLBACK\n-IOThread(void* arg)\n-{\n-    PRFileDesc* fd;\n-    char buf[32];\n-    PRInt32 nbytes;\n-\n-    /* Give the primordial thread one second to block */\n-    Sleep(1000);\n-\n-    /*\n-     * See if our PR_Write call will hang when the primordial\n-     * thread is blocking in a native blocking function.\n-     */\n-    fd = PR_Open(TEST_FILE_NAME, PR_WRONLY | PR_CREATE_FILE, 0666);\n-    if (NULL == fd) {\n-        fprintf(stderr, \"PR_Open failed\\n\");\n-        exit(1);\n-    }\n-    memset(buf, 0xaf, sizeof(buf));\n-    fprintf(stderr, \"iothread: calling PR_Write\\n\");\n-    nbytes = PR_Write(fd, buf, sizeof(buf));\n-    fprintf(stderr, \"iothread: PR_Write returned\\n\");\n-    if (nbytes != sizeof(buf)) {\n-        fprintf(stderr, \"PR_Write returned %d\\n\", nbytes);\n-        exit(1);\n-    }\n-    if (PR_Close(fd) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Delete(TEST_FILE_NAME) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Delete failed\\n\");\n-        exit(1);\n-    }\n-\n-    /* Tell the main thread that we are done */\n-    InterlockedExchange(&iothread_done, 1);\n+static void PR_CALLBACK IOThread(void* arg) {\n+  PRFileDesc* fd;\n+  char buf[32];\n+  PRInt32 nbytes;\n+\n+  /* Give the primordial thread one second to block */\n+  Sleep(1000);\n+\n+  /*\n+   * See if our PR_Write call will hang when the primordial\n+   * thread is blocking in a native blocking function.\n+   */\n+  fd = PR_Open(TEST_FILE_NAME, PR_WRONLY | PR_CREATE_FILE, 0666);\n+  if (NULL == fd) {\n+    fprintf(stderr, \"PR_Open failed\\n\");\n+    exit(1);\n+  }\n+  memset(buf, 0xaf, sizeof(buf));\n+  fprintf(stderr, \"iothread: calling PR_Write\\n\");\n+  nbytes = PR_Write(fd, buf, sizeof(buf));\n+  fprintf(stderr, \"iothread: PR_Write returned\\n\");\n+  if (nbytes != sizeof(buf)) {\n+    fprintf(stderr, \"PR_Write returned %d\\n\", nbytes);\n+    exit(1);\n+  }\n+  if (PR_Close(fd) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Delete(TEST_FILE_NAME) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Delete failed\\n\");\n+    exit(1);\n+  }\n+\n+  /* Tell the main thread that we are done */\n+  InterlockedExchange(&iothread_done, 1);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRThread* iothread;\n-\n-    /* Must be a global thread */\n-    iothread = PR_CreateThread(PR_USER_THREAD, IOThread, NULL, PR_PRIORITY_NORMAL,\n-                               PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (iothread == NULL) {\n-        fprintf(stderr, \"cannot create thread\\n\");\n-        exit(1);\n-    }\n-\n-    /*\n-     * Block in a native blocking function.\n-     * Give iothread 5 seconds to finish its task.\n-     */\n-    Sleep(5000);\n-\n-    /*\n-     * Is iothread done or is it hung?\n-     *\n-     * I'm actually only interested in reading the value\n-     * of iothread_done.  I'm using InterlockedExchange as\n-     * a thread-safe way to read iothread_done.\n-     */\n-    if (InterlockedExchange(&iothread_done, 1) == 0) {\n-        fprintf(stderr, \"iothread is hung\\n\");\n-        fprintf(stderr, \"FAILED\\n\");\n-        exit(1);\n-    }\n-\n-    if (PR_JoinThread(iothread) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n-    }\n-    printf(\"PASSED\\n\");\n-    return 0;\n+int main(int argc, char** argv) {\n+  PRThread* iothread;\n+\n+  /* Must be a global thread */\n+  iothread = PR_CreateThread(PR_USER_THREAD, IOThread, NULL, PR_PRIORITY_NORMAL,\n+                             PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (iothread == NULL) {\n+    fprintf(stderr, \"cannot create thread\\n\");\n+    exit(1);\n+  }\n+\n+  /*\n+   * Block in a native blocking function.\n+   * Give iothread 5 seconds to finish its task.\n+   */\n+  Sleep(5000);\n+\n+  /*\n+   * Is iothread done or is it hung?\n+   *\n+   * I'm actually only interested in reading the value\n+   * of iothread_done.  I'm using InterlockedExchange as\n+   * a thread-safe way to read iothread_done.\n+   */\n+  if (InterlockedExchange(&iothread_done, 1) == 0) {\n+    fprintf(stderr, \"iothread is hung\\n\");\n+    fprintf(stderr, \"FAILED\\n\");\n+    exit(1);\n+  }\n+\n+  if (PR_JoinThread(iothread) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+  printf(\"PASSED\\n\");\n+  return 0;\n } /* main */\n \n #endif /* WINNT */\ndiff --git a/nspr/pr/tests/priotest.c b/nspr/pr/tests/priotest.c\nindex c02887a..b9158fb 100644\n--- a/nspr/pr/tests/priotest.c\n+++ b/nspr/pr/tests/priotest.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -30,166 +31,152 @@ static PRIntervalTime oneSecond;\n static PRFileDesc* debug_out = NULL;\n static PRBool debug_mode = PR_FALSE;\n \n-static PRUint32\n-PerSecond(PRIntervalTime timein)\n-{\n-    PRUint32 loop = 0;\n-    while (((PRIntervalTime)(PR_IntervalNow()) - timein) < oneSecond) {\n-        loop += 1;\n-    }\n-    return loop;\n+static PRUint32 PerSecond(PRIntervalTime timein) {\n+  PRUint32 loop = 0;\n+  while (((PRIntervalTime)(PR_IntervalNow()) - timein) < oneSecond) {\n+    loop += 1;\n+  }\n+  return loop;\n } /* PerSecond */\n \n-static void PR_CALLBACK\n-Low(void* arg)\n-{\n-    PRUint32 t3 = 0, t2 = 0, t1 = 0, t0, *tn = (PRUint32*)arg;\n-    while (1) {\n-        t0 = PerSecond(PR_IntervalNow());\n-        *tn = (t3 + 3 * t2 + 3 * t1 + t0) / 8;\n-        t3 = t2;\n-        t2 = t1;\n-        t1 = t0;\n-    }\n+static void PR_CALLBACK Low(void* arg) {\n+  PRUint32 t3 = 0, t2 = 0, t1 = 0, t0, *tn = (PRUint32*)arg;\n+  while (1) {\n+    t0 = PerSecond(PR_IntervalNow());\n+    *tn = (t3 + 3 * t2 + 3 * t1 + t0) / 8;\n+    t3 = t2;\n+    t2 = t1;\n+    t1 = t0;\n+  }\n } /* Low */\n \n-static void PR_CALLBACK\n-High(void* arg)\n-{\n-    PRUint32 t3 = 0, t2 = 0, t1 = 0, t0, *tn = (PRUint32*)arg;\n-    while (1) {\n-        PRIntervalTime timein = PR_IntervalNow();\n-        PR_Sleep(oneSecond >> 2); /* 0.25 seconds */\n-        t0 = PerSecond(timein);\n-        *tn = (t3 + 3 * t2 + 3 * t1 + t0) / 8;\n-        t3 = t2;\n-        t2 = t1;\n-        t1 = t0;\n-    }\n+static void PR_CALLBACK High(void* arg) {\n+  PRUint32 t3 = 0, t2 = 0, t1 = 0, t0, *tn = (PRUint32*)arg;\n+  while (1) {\n+    PRIntervalTime timein = PR_IntervalNow();\n+    PR_Sleep(oneSecond >> 2); /* 0.25 seconds */\n+    t0 = PerSecond(timein);\n+    *tn = (t3 + 3 * t2 + 3 * t1 + t0) / 8;\n+    t3 = t2;\n+    t2 = t1;\n+    t1 = t0;\n+  }\n } /* High */\n \n-static void\n-Help(void)\n-{\n-    PR_fprintf(debug_out, \"Usage: priotest [-d] [-c n]\\n\");\n-    PR_fprintf(debug_out, \"-c n\\tduration of test in seconds (default: %d)\\n\",\n-               DEFAULT_DURATION);\n-    PR_fprintf(debug_out, \"-d\\tturn on debugging output (default: FALSE)\\n\");\n+static void Help(void) {\n+  PR_fprintf(debug_out, \"Usage: priotest [-d] [-c n]\\n\");\n+  PR_fprintf(debug_out, \"-c n\\tduration of test in seconds (default: %d)\\n\",\n+             DEFAULT_DURATION);\n+  PR_fprintf(debug_out, \"-d\\tturn on debugging output (default: FALSE)\\n\");\n } /* Help */\n \n-static void\n-RudimentaryTests(void)\n-{\n-    /*\n-    ** Try some rudimentary tests like setting valid priority and\n-    ** getting it back, or setting invalid priorities and getting\n-    ** back a valid answer.\n-    */\n-    PRThreadPriority priority;\n-    PR_SetThreadPriority(PR_GetCurrentThread(), PR_PRIORITY_URGENT);\n-    priority = PR_GetThreadPriority(PR_GetCurrentThread());\n-    failed = ((PR_TRUE == failed) || (PR_PRIORITY_URGENT != priority)) ? PR_TRUE\n-                                                                       : PR_FALSE;\n-    if (debug_mode && (PR_PRIORITY_URGENT != priority)) {\n-        PR_fprintf(debug_out, \"PR_[S/G]etThreadPriority() failed\\n\");\n-    }\n-\n-    PR_SetThreadPriority(PR_GetCurrentThread(),\n-                         (PRThreadPriority)(PR_PRIORITY_FIRST - 1));\n-    priority = PR_GetThreadPriority(PR_GetCurrentThread());\n-    failed = ((PR_TRUE == failed) || (PR_PRIORITY_FIRST != priority)) ? PR_TRUE\n-                                                                      : PR_FALSE;\n-    if (debug_mode && (PR_PRIORITY_FIRST != priority)) {\n-        PR_fprintf(debug_out, \"PR_SetThreadPriority(-1) failed\\n\");\n-    }\n-\n-    PR_SetThreadPriority(PR_GetCurrentThread(),\n-                         (PRThreadPriority)(PR_PRIORITY_LAST + 1));\n-    priority = PR_GetThreadPriority(PR_GetCurrentThread());\n-    failed = ((PR_TRUE == failed) || (PR_PRIORITY_LAST != priority)) ? PR_TRUE\n+static void RudimentaryTests(void) {\n+  /*\n+  ** Try some rudimentary tests like setting valid priority and\n+  ** getting it back, or setting invalid priorities and getting\n+  ** back a valid answer.\n+  */\n+  PRThreadPriority priority;\n+  PR_SetThreadPriority(PR_GetCurrentThread(), PR_PRIORITY_URGENT);\n+  priority = PR_GetThreadPriority(PR_GetCurrentThread());\n+  failed = ((PR_TRUE == failed) || (PR_PRIORITY_URGENT != priority)) ? PR_TRUE\n                                                                      : PR_FALSE;\n-    if (debug_mode && (PR_PRIORITY_LAST != priority)) {\n-        PR_fprintf(debug_out, \"PR_SetThreadPriority(+1) failed\\n\");\n-    }\n+  if (debug_mode && (PR_PRIORITY_URGENT != priority)) {\n+    PR_fprintf(debug_out, \"PR_[S/G]etThreadPriority() failed\\n\");\n+  }\n+\n+  PR_SetThreadPriority(PR_GetCurrentThread(),\n+                       (PRThreadPriority)(PR_PRIORITY_FIRST - 1));\n+  priority = PR_GetThreadPriority(PR_GetCurrentThread());\n+  failed = ((PR_TRUE == failed) || (PR_PRIORITY_FIRST != priority)) ? PR_TRUE\n+                                                                    : PR_FALSE;\n+  if (debug_mode && (PR_PRIORITY_FIRST != priority)) {\n+    PR_fprintf(debug_out, \"PR_SetThreadPriority(-1) failed\\n\");\n+  }\n+\n+  PR_SetThreadPriority(PR_GetCurrentThread(),\n+                       (PRThreadPriority)(PR_PRIORITY_LAST + 1));\n+  priority = PR_GetThreadPriority(PR_GetCurrentThread());\n+  failed = ((PR_TRUE == failed) || (PR_PRIORITY_LAST != priority)) ? PR_TRUE\n+                                                                   : PR_FALSE;\n+  if (debug_mode && (PR_PRIORITY_LAST != priority)) {\n+    PR_fprintf(debug_out, \"PR_SetThreadPriority(+1) failed\\n\");\n+  }\n \n } /* RudimentataryTests */\n \n-static void\n-CreateThreads(PRUint32* lowCount, PRUint32* highCount)\n-{\n-    (void)PR_CreateThread(PR_USER_THREAD, Low, lowCount, PR_PRIORITY_LOW,\n-                          PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    (void)PR_CreateThread(PR_USER_THREAD, High, highCount, PR_PRIORITY_HIGH,\n-                          PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+static void CreateThreads(PRUint32* lowCount, PRUint32* highCount) {\n+  (void)PR_CreateThread(PR_USER_THREAD, Low, lowCount, PR_PRIORITY_LOW,\n+                        PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  (void)PR_CreateThread(PR_USER_THREAD, High, highCount, PR_PRIORITY_HIGH,\n+                        PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n } /* CreateThreads */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PLOptStatus os;\n-    PRIntn duration = DEFAULT_DURATION;\n-    PRUint32 totalCount, highCount = 0, lowCount = 0;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"hdc:\");\n-\n-    debug_out = PR_STDOUT;\n-    oneSecond = PR_SecondsToInterval(1);\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            case 'c': /* test duration */\n-                duration = atoi(opt->value);\n-                break;\n-            case 'h': /* help message */\n-            default:\n-                Help();\n-                return 2;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n+int main(int argc, char** argv) {\n+  PLOptStatus os;\n+  PRIntn duration = DEFAULT_DURATION;\n+  PRUint32 totalCount, highCount = 0, lowCount = 0;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"hdc:\");\n+\n+  debug_out = PR_STDOUT;\n+  oneSecond = PR_SecondsToInterval(1);\n \n-    if (duration == 0) {\n-        duration = DEFAULT_DURATION;\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      case 'c': /* test duration */\n+        duration = atoi(opt->value);\n+        break;\n+      case 'h': /* help message */\n+      default:\n+        Help();\n+        return 2;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    RudimentaryTests();\n+  if (duration == 0) {\n+    duration = DEFAULT_DURATION;\n+  }\n \n-    printf(\"Priority test: running for %d seconds\\n\\n\", duration);\n+  RudimentaryTests();\n \n-    (void)PerSecond(PR_IntervalNow());\n-    totalCount = PerSecond(PR_IntervalNow());\n+  printf(\"Priority test: running for %d seconds\\n\\n\", duration);\n \n-    PR_SetThreadPriority(PR_GetCurrentThread(), PR_PRIORITY_URGENT);\n+  (void)PerSecond(PR_IntervalNow());\n+  totalCount = PerSecond(PR_IntervalNow());\n \n-    if (debug_mode) {\n-        PR_fprintf(debug_out,\n-                   \"The high priority thread should get approximately three\\n\");\n-        PR_fprintf(debug_out,\n-                   \"times what the low priority thread manages. A maximum of \\n\");\n-        PR_fprintf(debug_out, \"%d cycles are available.\\n\\n\", totalCount);\n-    }\n+  PR_SetThreadPriority(PR_GetCurrentThread(), PR_PRIORITY_URGENT);\n+\n+  if (debug_mode) {\n+    PR_fprintf(debug_out,\n+               \"The high priority thread should get approximately three\\n\");\n+    PR_fprintf(debug_out,\n+               \"times what the low priority thread manages. A maximum of \\n\");\n+    PR_fprintf(debug_out, \"%d cycles are available.\\n\\n\", totalCount);\n+  }\n \n-    duration = (duration + 4) / 5;\n-    CreateThreads(&lowCount, &highCount);\n-    while (duration--) {\n-        PRIntn loop = 5;\n-        while (loop--) {\n-            PR_Sleep(oneSecond);\n-        }\n-        if (debug_mode) {\n-            PR_fprintf(debug_out, \"high : low :: %d : %d\\n\", highCount, lowCount);\n-        }\n+  duration = (duration + 4) / 5;\n+  CreateThreads(&lowCount, &highCount);\n+  while (duration--) {\n+    PRIntn loop = 5;\n+    while (loop--) {\n+      PR_Sleep(oneSecond);\n+    }\n+    if (debug_mode) {\n+      PR_fprintf(debug_out, \"high : low :: %d : %d\\n\", highCount, lowCount);\n     }\n+  }\n \n-    PR_ProcessExit((failed) ? 1 : 0);\n+  PR_ProcessExit((failed) ? 1 : 0);\n \n-    PR_NOT_REACHED(\"You can't get here -- but you did!\");\n-    return 1; /* or here */\n+  PR_NOT_REACHED(\"You can't get here -- but you did!\");\n+  return 1; /* or here */\n \n } /* main */\n \ndiff --git a/nspr/pr/tests/provider.c b/nspr/pr/tests/provider.c\nindex f415dd7..350338e 100644\n--- a/nspr/pr/tests/provider.c\n+++ b/nspr/pr/tests/provider.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -50,7 +51,7 @@\n #include <string.h>\n \n #if defined(XP_UNIX)\n-#include <math.h>\n+#  include <math.h>\n #endif\n \n /*\n@@ -58,14 +59,14 @@\n */\n \n #ifdef DEBUG\n-#define PORT_INC_DO +100\n+#  define PORT_INC_DO +100\n #else\n-#define PORT_INC_DO\n+#  define PORT_INC_DO\n #endif\n #ifdef IS_64\n-#define PORT_INC_3264 +200\n+#  define PORT_INC_3264 +200\n #else\n-#define PORT_INC_3264\n+#  define PORT_INC_3264\n #endif\n \n #define RECV_FLAGS 0\n@@ -84,30 +85,27 @@\n #define DEFAULT_SERVER_TIMEOUT 4000\n #define DEFAULT_SERVER_PRIORITY PR_PRIORITY_HIGH\n \n-typedef enum CSState_e { cs_init,\n-                         cs_run,\n-                         cs_stop,\n-                         cs_exit } CSState_t;\n+typedef enum CSState_e { cs_init, cs_run, cs_stop, cs_exit } CSState_t;\n \n static void PR_CALLBACK Worker(void* arg);\n typedef struct CSPool_s CSPool_t;\n typedef struct CSWorker_s CSWorker_t;\n typedef struct CSServer_s CSServer_t;\n typedef enum Verbosity {\n-    TEST_LOG_ALWAYS,\n-    TEST_LOG_ERROR,\n-    TEST_LOG_WARNING,\n-    TEST_LOG_NOTICE,\n-    TEST_LOG_INFO,\n-    TEST_LOG_STATUS,\n-    TEST_LOG_VERBOSE\n+  TEST_LOG_ALWAYS,\n+  TEST_LOG_ERROR,\n+  TEST_LOG_WARNING,\n+  TEST_LOG_NOTICE,\n+  TEST_LOG_INFO,\n+  TEST_LOG_STATUS,\n+  TEST_LOG_VERBOSE\n } Verbosity;\n \n static enum {\n-    thread_nspr,\n-    thread_pthread,\n-    thread_sproc,\n-    thread_win32\n+  thread_nspr,\n+  thread_pthread,\n+  thread_sproc,\n+  thread_win32\n } thread_provider;\n \n static PRInt32 domain = AF_INET;\n@@ -119,1208 +117,1175 @@ static Verbosity verbosity = TEST_LOG_ALWAYS;\n static PRThreadScope thread_scope = PR_LOCAL_THREAD;\n \n struct CSWorker_s {\n-    PRCList element; /* list of the server's workers */\n+  PRCList element; /* list of the server's workers */\n \n-    PRThread* thread;   /* this worker objects thread */\n-    CSServer_t* server; /* back pointer to server structure */\n+  PRThread* thread;   /* this worker objects thread */\n+  CSServer_t* server; /* back pointer to server structure */\n };\n \n struct CSPool_s {\n-    PRCondVar* exiting;\n-    PRCondVar* acceptComplete;\n-    PRUint32 accepting, active, workers;\n+  PRCondVar* exiting;\n+  PRCondVar* acceptComplete;\n+  PRUint32 accepting, active, workers;\n };\n \n struct CSServer_s {\n-    PRCList list; /* head of worker list */\n-\n-    PRLock* ml;\n-    PRThread* thread; /* the main server thread */\n-    PRCondVar* stateChange;\n-\n-    PRUint16 port;        /* port we're listening on */\n-    PRUint32 backlog;     /* size of our listener backlog */\n-    PRFileDesc* listener; /* the fd accepting connections */\n-\n-    CSPool_t pool;   /* statistics on worker threads */\n-    CSState_t state; /* the server's state */\n-    struct           /* controlling worker counts */\n-    {\n-        PRUint32 minimum, maximum, accepting;\n-    } workers;\n-\n-    /* statistics */\n-    PRIntervalTime started, stopped;\n-    PRUint32 operations, bytesTransferred;\n+  PRCList list; /* head of worker list */\n+\n+  PRLock* ml;\n+  PRThread* thread; /* the main server thread */\n+  PRCondVar* stateChange;\n+\n+  PRUint16 port;        /* port we're listening on */\n+  PRUint32 backlog;     /* size of our listener backlog */\n+  PRFileDesc* listener; /* the fd accepting connections */\n+\n+  CSPool_t pool;   /* statistics on worker threads */\n+  CSState_t state; /* the server's state */\n+  struct           /* controlling worker counts */\n+  {\n+    PRUint32 minimum, maximum, accepting;\n+  } workers;\n+\n+  /* statistics */\n+  PRIntervalTime started, stopped;\n+  PRUint32 operations, bytesTransferred;\n };\n \n typedef struct CSDescriptor_s {\n-    PRInt32 size;      /* size of transfer */\n-    char filename[60]; /* filename, null padded */\n+  PRInt32 size;      /* size of transfer */\n+  char filename[60]; /* filename, null padded */\n } CSDescriptor_t;\n \n typedef struct CSClient_s {\n-    PRLock* ml;\n-    PRThread* thread;\n-    PRCondVar* stateChange;\n-    PRNetAddr serverAddress;\n+  PRLock* ml;\n+  PRThread* thread;\n+  PRCondVar* stateChange;\n+  PRNetAddr serverAddress;\n \n-    CSState_t state;\n+  CSState_t state;\n \n-    /* statistics */\n-    PRIntervalTime started, stopped;\n-    PRUint32 operations, bytesTransferred;\n+  /* statistics */\n+  PRIntervalTime started, stopped;\n+  PRUint32 operations, bytesTransferred;\n } CSClient_t;\n \n-#define TEST_LOG(l, p, a)                   \\\n-    do {                                    \\\n-        if (debug_mode || (p <= verbosity)) \\\n-            printf a;                       \\\n-    } while (0)\n+#define TEST_LOG(l, p, a)                         \\\n+  do {                                            \\\n+    if (debug_mode || (p <= verbosity)) printf a; \\\n+  } while (0)\n \n PRLogModuleInfo* cltsrv_log_file = NULL;\n \n #define MY_ASSERT(_expr) \\\n-    ((_expr) ? ((void)0) : _MY_Assert(#_expr, __FILE__, __LINE__))\n+  ((_expr) ? ((void)0) : _MY_Assert(#_expr, __FILE__, __LINE__))\n \n #define TEST_ASSERT(_expr) \\\n-    ((_expr) ? ((void)0) : _MY_Assert(#_expr, __FILE__, __LINE__))\n+  ((_expr) ? ((void)0) : _MY_Assert(#_expr, __FILE__, __LINE__))\n \n-static void\n-_MY_Assert(const char* s, const char* file, PRIntn ln)\n-{\n-    PL_PrintError(NULL);\n-    PR_Assert(s, file, ln);\n+static void _MY_Assert(const char* s, const char* file, PRIntn ln) {\n+  PL_PrintError(NULL);\n+  PR_Assert(s, file, ln);\n } /* _MY_Assert */\n \n-static PRBool\n-Aborted(PRStatus rv)\n-{\n-    return ((PR_FAILURE == rv) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError()))\n-               ? PR_TRUE\n-               : PR_FALSE;\n+static PRBool Aborted(PRStatus rv) {\n+  return ((PR_FAILURE == rv) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError()))\n+             ? PR_TRUE\n+             : PR_FALSE;\n }\n \n-static void\n-TimeOfDayMessage(const char* msg, PRThread* me)\n-{\n-    char buffer[100];\n-    PRExplodedTime tod;\n-    PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &tod);\n-    (void)PR_FormatTime(buffer, sizeof(buffer), \"%H:%M:%S\", &tod);\n+static void TimeOfDayMessage(const char* msg, PRThread* me) {\n+  char buffer[100];\n+  PRExplodedTime tod;\n+  PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &tod);\n+  (void)PR_FormatTime(buffer, sizeof(buffer), \"%H:%M:%S\", &tod);\n \n-    TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n-             (\"%s(0x%p): %s\\n\", msg, me, buffer));\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n+           (\"%s(0x%p): %s\\n\", msg, me, buffer));\n } /* TimeOfDayMessage */\n \n-static void PR_CALLBACK\n-Client(void* arg)\n-{\n-    PRStatus rv;\n-    PRIntn index;\n-    char buffer[1024];\n-    PRFileDesc* fd = NULL;\n-    PRUintn clipping = DEFAULT_CLIPPING;\n-    CSClient_t* client = (CSClient_t*)arg;\n-    PRThread* me = client->thread = PR_GetCurrentThread();\n-    CSDescriptor_t* descriptor = PR_NEW(CSDescriptor_t);\n-    PRIntervalTime timeout = PR_MillisecondsToInterval(DEFAULT_CLIENT_TIMEOUT);\n-\n-    for (index = 0; index < sizeof(buffer); ++index) {\n-        buffer[index] = (char)index;\n-    }\n+static void PR_CALLBACK Client(void* arg) {\n+  PRStatus rv;\n+  PRIntn index;\n+  char buffer[1024];\n+  PRFileDesc* fd = NULL;\n+  PRUintn clipping = DEFAULT_CLIPPING;\n+  CSClient_t* client = (CSClient_t*)arg;\n+  PRThread* me = client->thread = PR_GetCurrentThread();\n+  CSDescriptor_t* descriptor = PR_NEW(CSDescriptor_t);\n+  PRIntervalTime timeout = PR_MillisecondsToInterval(DEFAULT_CLIENT_TIMEOUT);\n \n-    client->started = PR_IntervalNow();\n+  for (index = 0; index < sizeof(buffer); ++index) {\n+    buffer[index] = (char)index;\n+  }\n \n-    PR_Lock(client->ml);\n-    client->state = cs_run;\n-    PR_NotifyCondVar(client->stateChange);\n-    PR_Unlock(client->ml);\n+  client->started = PR_IntervalNow();\n \n-    TimeOfDayMessage(\"Client started at\", me);\n+  PR_Lock(client->ml);\n+  client->state = cs_run;\n+  PR_NotifyCondVar(client->stateChange);\n+  PR_Unlock(client->ml);\n \n-    while (cs_run == client->state) {\n-        PRInt32 bytes, descbytes, filebytes, netbytes;\n+  TimeOfDayMessage(\"Client started at\", me);\n \n-        (void)PR_NetAddrToString(&client->serverAddress, buffer, sizeof(buffer));\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n-                 (\"\\tClient(0x%p): connecting to server at %s\\n\", me, buffer));\n+  while (cs_run == client->state) {\n+    PRInt32 bytes, descbytes, filebytes, netbytes;\n \n-        fd = PR_Socket(domain, SOCK_STREAM, protocol);\n-        TEST_ASSERT(NULL != fd);\n-        rv = PR_Connect(fd, &client->serverAddress, timeout);\n-        if (PR_FAILURE == rv) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                     (\"\\tClient(0x%p): conection failed\\n\", me));\n-            goto aborted;\n-        }\n+    (void)PR_NetAddrToString(&client->serverAddress, buffer, sizeof(buffer));\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n+             (\"\\tClient(0x%p): connecting to server at %s\\n\", me, buffer));\n \n-        memset(descriptor, 0, sizeof(*descriptor));\n-        descriptor->size = PR_htonl(descbytes = rand() % clipping);\n-        PR_snprintf(descriptor->filename, sizeof(descriptor->filename),\n-                    \"CS%p%p-%p.dat\", client->started, me, client->operations);\n-        TEST_LOG(\n-            cltsrv_log_file, TEST_LOG_VERBOSE,\n-            (\"\\tClient(0x%p): sending descriptor for %u bytes\\n\", me, descbytes));\n-        bytes = PR_Send(fd, descriptor, sizeof(*descriptor), SEND_FLAGS, timeout);\n-        if (sizeof(CSDescriptor_t) != bytes) {\n-            if (Aborted(PR_FAILURE)) {\n-                goto aborted;\n-            }\n-            if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\tClient(0x%p): send descriptor timeout\\n\", me));\n-                goto retry;\n-            }\n-        }\n-        TEST_ASSERT(sizeof(*descriptor) == bytes);\n-\n-        netbytes = 0;\n-        while (netbytes < descbytes) {\n-            filebytes = sizeof(buffer);\n-            if ((descbytes - netbytes) < filebytes) {\n-                filebytes = descbytes - netbytes;\n-            }\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                     (\"\\tClient(0x%p): sending %d bytes\\n\", me, filebytes));\n-            bytes = PR_Send(fd, buffer, filebytes, SEND_FLAGS, timeout);\n-            if (filebytes != bytes) {\n-                if (Aborted(PR_FAILURE)) {\n-                    goto aborted;\n-                }\n-                if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-                    TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                             (\"\\tClient(0x%p): send data timeout\\n\", me));\n-                    goto retry;\n-                }\n-            }\n-            TEST_ASSERT(bytes == filebytes);\n-            netbytes += bytes;\n-        }\n-        filebytes = 0;\n-        while (filebytes < descbytes) {\n-            netbytes = sizeof(buffer);\n-            if ((descbytes - filebytes) < netbytes) {\n-                netbytes = descbytes - filebytes;\n-            }\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                     (\"\\tClient(0x%p): receiving %d bytes\\n\", me, netbytes));\n-            bytes = PR_Recv(fd, buffer, netbytes, RECV_FLAGS, timeout);\n-            if (-1 == bytes) {\n-                if (Aborted(PR_FAILURE)) {\n-                    TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                             (\"\\tClient(0x%p): receive data aborted\\n\", me));\n-                    goto aborted;\n-                } else if (PR_IO_TIMEOUT_ERROR == PR_GetError())\n-                    TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                             (\"\\tClient(0x%p): receive data timeout\\n\", me));\n-                else\n-                    TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                             (\"\\tClient(0x%p): receive error (%d, %d)\\n\", me,\n-                              PR_GetError(), PR_GetOSError()));\n-                goto retry;\n-            }\n-            if (0 == bytes) {\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tClient(0x%p): unexpected end of stream\\n\",\n-                          PR_GetCurrentThread()));\n-                break;\n-            }\n-            filebytes += bytes;\n-        }\n+    fd = PR_Socket(domain, SOCK_STREAM, protocol);\n+    TEST_ASSERT(NULL != fd);\n+    rv = PR_Connect(fd, &client->serverAddress, timeout);\n+    if (PR_FAILURE == rv) {\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+               (\"\\tClient(0x%p): conection failed\\n\", me));\n+      goto aborted;\n+    }\n \n-        rv = PR_Shutdown(fd, PR_SHUTDOWN_BOTH);\n-        if (Aborted(rv)) {\n-            goto aborted;\n+    memset(descriptor, 0, sizeof(*descriptor));\n+    descriptor->size = PR_htonl(descbytes = rand() % clipping);\n+    PR_snprintf(descriptor->filename, sizeof(descriptor->filename),\n+                \"CS%p%p-%p.dat\", client->started, me, client->operations);\n+    TEST_LOG(\n+        cltsrv_log_file, TEST_LOG_VERBOSE,\n+        (\"\\tClient(0x%p): sending descriptor for %u bytes\\n\", me, descbytes));\n+    bytes = PR_Send(fd, descriptor, sizeof(*descriptor), SEND_FLAGS, timeout);\n+    if (sizeof(CSDescriptor_t) != bytes) {\n+      if (Aborted(PR_FAILURE)) {\n+        goto aborted;\n+      }\n+      if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                 (\"\\tClient(0x%p): send descriptor timeout\\n\", me));\n+        goto retry;\n+      }\n+    }\n+    TEST_ASSERT(sizeof(*descriptor) == bytes);\n+\n+    netbytes = 0;\n+    while (netbytes < descbytes) {\n+      filebytes = sizeof(buffer);\n+      if ((descbytes - netbytes) < filebytes) {\n+        filebytes = descbytes - netbytes;\n+      }\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+               (\"\\tClient(0x%p): sending %d bytes\\n\", me, filebytes));\n+      bytes = PR_Send(fd, buffer, filebytes, SEND_FLAGS, timeout);\n+      if (filebytes != bytes) {\n+        if (Aborted(PR_FAILURE)) {\n+          goto aborted;\n         }\n-        TEST_ASSERT(PR_SUCCESS == rv);\n-    retry:\n-        (void)PR_Close(fd);\n-        fd = NULL;\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n-                 (\"\\tClient(0x%p): disconnected from server\\n\", me));\n-\n-        PR_Lock(client->ml);\n-        client->operations += 1;\n-        client->bytesTransferred += 2 * descbytes;\n-        rv = PR_WaitCondVar(client->stateChange, rand() % clipping);\n-        PR_Unlock(client->ml);\n-        if (Aborted(rv)) {\n-            break;\n+        if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+          TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                   (\"\\tClient(0x%p): send data timeout\\n\", me));\n+          goto retry;\n         }\n+      }\n+      TEST_ASSERT(bytes == filebytes);\n+      netbytes += bytes;\n+    }\n+    filebytes = 0;\n+    while (filebytes < descbytes) {\n+      netbytes = sizeof(buffer);\n+      if ((descbytes - filebytes) < netbytes) {\n+        netbytes = descbytes - filebytes;\n+      }\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+               (\"\\tClient(0x%p): receiving %d bytes\\n\", me, netbytes));\n+      bytes = PR_Recv(fd, buffer, netbytes, RECV_FLAGS, timeout);\n+      if (-1 == bytes) {\n+        if (Aborted(PR_FAILURE)) {\n+          TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                   (\"\\tClient(0x%p): receive data aborted\\n\", me));\n+          goto aborted;\n+        } else if (PR_IO_TIMEOUT_ERROR == PR_GetError())\n+          TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                   (\"\\tClient(0x%p): receive data timeout\\n\", me));\n+        else\n+          TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                   (\"\\tClient(0x%p): receive error (%d, %d)\\n\", me,\n+                    PR_GetError(), PR_GetOSError()));\n+        goto retry;\n+      }\n+      if (0 == bytes) {\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                 (\"\\t\\tClient(0x%p): unexpected end of stream\\n\",\n+                  PR_GetCurrentThread()));\n+        break;\n+      }\n+      filebytes += bytes;\n     }\n \n-aborted:\n-    client->stopped = PR_IntervalNow();\n-\n-    PR_ClearInterrupt();\n-    if (NULL != fd) {\n-        rv = PR_Close(fd);\n+    rv = PR_Shutdown(fd, PR_SHUTDOWN_BOTH);\n+    if (Aborted(rv)) {\n+      goto aborted;\n     }\n+    TEST_ASSERT(PR_SUCCESS == rv);\n+  retry:\n+    (void)PR_Close(fd);\n+    fd = NULL;\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n+             (\"\\tClient(0x%p): disconnected from server\\n\", me));\n \n     PR_Lock(client->ml);\n-    client->state = cs_exit;\n-    PR_NotifyCondVar(client->stateChange);\n+    client->operations += 1;\n+    client->bytesTransferred += 2 * descbytes;\n+    rv = PR_WaitCondVar(client->stateChange, rand() % clipping);\n     PR_Unlock(client->ml);\n-    PR_DELETE(descriptor);\n-    TEST_LOG(\n-        cltsrv_log_file, TEST_LOG_ALWAYS,\n-        (\"\\tClient(0x%p): stopped after %u operations and %u bytes\\n\",\n-         PR_GetCurrentThread(), client->operations, client->bytesTransferred));\n+    if (Aborted(rv)) {\n+      break;\n+    }\n+  }\n \n-} /* Client */\n+aborted:\n+  client->stopped = PR_IntervalNow();\n+\n+  PR_ClearInterrupt();\n+  if (NULL != fd) {\n+    rv = PR_Close(fd);\n+  }\n+\n+  PR_Lock(client->ml);\n+  client->state = cs_exit;\n+  PR_NotifyCondVar(client->stateChange);\n+  PR_Unlock(client->ml);\n+  PR_DELETE(descriptor);\n+  TEST_LOG(\n+      cltsrv_log_file, TEST_LOG_ALWAYS,\n+      (\"\\tClient(0x%p): stopped after %u operations and %u bytes\\n\",\n+       PR_GetCurrentThread(), client->operations, client->bytesTransferred));\n \n-static PRStatus\n-ProcessRequest(PRFileDesc* fd, CSServer_t* server)\n-{\n-    PRStatus drv, rv;\n-    char buffer[1024];\n-    PRFileDesc* file = NULL;\n-    PRThread* me = PR_GetCurrentThread();\n-    PRInt32 bytes, descbytes, netbytes, filebytes = 0;\n-    CSDescriptor_t* descriptor = PR_NEW(CSDescriptor_t);\n-    PRIntervalTime timeout = PR_MillisecondsToInterval(DEFAULT_SERVER_TIMEOUT);\n+} /* Client */\n \n+static PRStatus ProcessRequest(PRFileDesc* fd, CSServer_t* server) {\n+  PRStatus drv, rv;\n+  char buffer[1024];\n+  PRFileDesc* file = NULL;\n+  PRThread* me = PR_GetCurrentThread();\n+  PRInt32 bytes, descbytes, netbytes, filebytes = 0;\n+  CSDescriptor_t* descriptor = PR_NEW(CSDescriptor_t);\n+  PRIntervalTime timeout = PR_MillisecondsToInterval(DEFAULT_SERVER_TIMEOUT);\n+\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+           (\"\\tProcessRequest(0x%p): receiving desciptor\\n\", me));\n+  bytes = PR_Recv(fd, descriptor, sizeof(*descriptor), RECV_FLAGS, timeout);\n+  if (-1 == bytes) {\n+    rv = PR_FAILURE;\n+    if (Aborted(rv)) {\n+      goto exit;\n+    }\n+    if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+               (\"\\tProcessRequest(0x%p): receive timeout\\n\", me));\n+    }\n+    goto exit;\n+  }\n+  if (0 == bytes) {\n+    rv = PR_FAILURE;\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+             (\"\\tProcessRequest(0x%p): unexpected end of file\\n\", me));\n+    goto exit;\n+  }\n+  descbytes = PR_ntohl(descriptor->size);\n+  TEST_ASSERT(sizeof(*descriptor) == bytes);\n+\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+           (\"\\t\\tProcessRequest(0x%p): read descriptor {%d, %s}\\n\", me,\n+            descbytes, descriptor->filename));\n+\n+  file = PR_Open(descriptor->filename, (PR_CREATE_FILE | PR_WRONLY), 0666);\n+  if (NULL == file) {\n+    rv = PR_FAILURE;\n+    if (Aborted(rv)) {\n+      goto aborted;\n+    }\n+    if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+               (\"\\tProcessRequest(0x%p): open file timeout\\n\", me));\n+      goto aborted;\n+    }\n+  }\n+  TEST_ASSERT(NULL != file);\n+\n+  filebytes = 0;\n+  while (filebytes < descbytes) {\n+    netbytes = sizeof(buffer);\n+    if ((descbytes - filebytes) < netbytes) {\n+      netbytes = descbytes - filebytes;\n+    }\n     TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-             (\"\\tProcessRequest(0x%p): receiving desciptor\\n\", me));\n-    bytes = PR_Recv(fd, descriptor, sizeof(*descriptor), RECV_FLAGS, timeout);\n+             (\"\\tProcessRequest(0x%p): receive %d bytes\\n\", me, netbytes));\n+    bytes = PR_Recv(fd, buffer, netbytes, RECV_FLAGS, timeout);\n     if (-1 == bytes) {\n-        rv = PR_FAILURE;\n-        if (Aborted(rv)) {\n-            goto exit;\n-        }\n-        if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                     (\"\\tProcessRequest(0x%p): receive timeout\\n\", me));\n-        }\n-        goto exit;\n+      rv = PR_FAILURE;\n+      if (Aborted(rv)) {\n+        goto aborted;\n+      }\n+      if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                 (\"\\t\\tProcessRequest(0x%p): receive data timeout\\n\", me));\n+        goto aborted;\n+      }\n+      /*\n+       * XXX: I got (PR_CONNECT_RESET_ERROR, ERROR_NETNAME_DELETED)\n+       * on NT here.  This is equivalent to ECONNRESET on Unix.\n+       *     -wtc\n+       */\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_WARNING,\n+               (\"\\t\\tProcessRequest(0x%p): unexpected error (%d, %d)\\n\", me,\n+                PR_GetError(), PR_GetOSError()));\n+      goto aborted;\n     }\n     if (0 == bytes) {\n-        rv = PR_FAILURE;\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_WARNING,\n+               (\"\\t\\tProcessRequest(0x%p): unexpected end of stream\\n\", me));\n+      rv = PR_FAILURE;\n+      goto aborted;\n+    }\n+    filebytes += bytes;\n+    netbytes = bytes;\n+    /* The byte count for PR_Write should be positive */\n+    MY_ASSERT(netbytes > 0);\n+    TEST_LOG(\n+        cltsrv_log_file, TEST_LOG_VERBOSE,\n+        (\"\\tProcessRequest(0x%p): write %d bytes to file\\n\", me, netbytes));\n+    bytes = PR_Write(file, buffer, netbytes);\n+    if (netbytes != bytes) {\n+      rv = PR_FAILURE;\n+      if (Aborted(rv)) {\n+        goto aborted;\n+      }\n+      if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n         TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                 (\"\\tProcessRequest(0x%p): unexpected end of file\\n\", me));\n-        goto exit;\n+                 (\"\\t\\tProcessRequest(0x%p): write file timeout\\n\", me));\n+        goto aborted;\n+      }\n     }\n-    descbytes = PR_ntohl(descriptor->size);\n-    TEST_ASSERT(sizeof(*descriptor) == bytes);\n-\n-    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-             (\"\\t\\tProcessRequest(0x%p): read descriptor {%d, %s}\\n\", me,\n-              descbytes, descriptor->filename));\n-\n-    file = PR_Open(descriptor->filename, (PR_CREATE_FILE | PR_WRONLY), 0666);\n-    if (NULL == file) {\n-        rv = PR_FAILURE;\n-        if (Aborted(rv)) {\n-            goto aborted;\n-        }\n-        if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                     (\"\\tProcessRequest(0x%p): open file timeout\\n\", me));\n-            goto aborted;\n-        }\n+    TEST_ASSERT(bytes > 0);\n+  }\n+\n+  PR_Lock(server->ml);\n+  server->operations += 1;\n+  server->bytesTransferred += filebytes;\n+  PR_Unlock(server->ml);\n+\n+  rv = PR_Close(file);\n+  file = NULL;\n+  if (Aborted(rv)) {\n+    goto aborted;\n+  }\n+  TEST_ASSERT(PR_SUCCESS == rv);\n+\n+  TEST_LOG(\n+      cltsrv_log_file, TEST_LOG_VERBOSE,\n+      (\"\\t\\tProcessRequest(0x%p): opening %s\\n\", me, descriptor->filename));\n+  file = PR_Open(descriptor->filename, PR_RDONLY, 0);\n+  if (NULL == file) {\n+    rv = PR_FAILURE;\n+    if (Aborted(rv)) {\n+      goto aborted;\n     }\n-    TEST_ASSERT(NULL != file);\n-\n-    filebytes = 0;\n-    while (filebytes < descbytes) {\n-        netbytes = sizeof(buffer);\n-        if ((descbytes - filebytes) < netbytes) {\n-            netbytes = descbytes - filebytes;\n-        }\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"\\tProcessRequest(0x%p): receive %d bytes\\n\", me, netbytes));\n-        bytes = PR_Recv(fd, buffer, netbytes, RECV_FLAGS, timeout);\n-        if (-1 == bytes) {\n-            rv = PR_FAILURE;\n-            if (Aborted(rv)) {\n-                goto aborted;\n-            }\n-            if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tProcessRequest(0x%p): receive data timeout\\n\", me));\n-                goto aborted;\n-            }\n-            /*\n-             * XXX: I got (PR_CONNECT_RESET_ERROR, ERROR_NETNAME_DELETED)\n-             * on NT here.  This is equivalent to ECONNRESET on Unix.\n-             *     -wtc\n-             */\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_WARNING,\n-                     (\"\\t\\tProcessRequest(0x%p): unexpected error (%d, %d)\\n\", me,\n-                      PR_GetError(), PR_GetOSError()));\n-            goto aborted;\n-        }\n-        if (0 == bytes) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_WARNING,\n-                     (\"\\t\\tProcessRequest(0x%p): unexpected end of stream\\n\", me));\n-            rv = PR_FAILURE;\n-            goto aborted;\n-        }\n-        filebytes += bytes;\n-        netbytes = bytes;\n-        /* The byte count for PR_Write should be positive */\n-        MY_ASSERT(netbytes > 0);\n-        TEST_LOG(\n-            cltsrv_log_file, TEST_LOG_VERBOSE,\n-            (\"\\tProcessRequest(0x%p): write %d bytes to file\\n\", me, netbytes));\n-        bytes = PR_Write(file, buffer, netbytes);\n-        if (netbytes != bytes) {\n-            rv = PR_FAILURE;\n-            if (Aborted(rv)) {\n-                goto aborted;\n-            }\n-            if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tProcessRequest(0x%p): write file timeout\\n\", me));\n-                goto aborted;\n-            }\n-        }\n-        TEST_ASSERT(bytes > 0);\n+    if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+               (\"\\t\\tProcessRequest(0x%p): open file timeout\\n\",\n+                PR_GetCurrentThread()));\n+      goto aborted;\n     }\n-\n-    PR_Lock(server->ml);\n-    server->operations += 1;\n-    server->bytesTransferred += filebytes;\n-    PR_Unlock(server->ml);\n-\n-    rv = PR_Close(file);\n-    file = NULL;\n-    if (Aborted(rv)) {\n-        goto aborted;\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+             (\"\\t\\tProcessRequest(0x%p): other file open error (%u, %u)\\n\", me,\n+              PR_GetError(), PR_GetOSError()));\n+    goto aborted;\n+  }\n+  TEST_ASSERT(NULL != file);\n+\n+  netbytes = 0;\n+  while (netbytes < descbytes) {\n+    filebytes = sizeof(buffer);\n+    if ((descbytes - netbytes) < filebytes) {\n+      filebytes = descbytes - netbytes;\n     }\n-    TEST_ASSERT(PR_SUCCESS == rv);\n-\n     TEST_LOG(\n         cltsrv_log_file, TEST_LOG_VERBOSE,\n-        (\"\\t\\tProcessRequest(0x%p): opening %s\\n\", me, descriptor->filename));\n-    file = PR_Open(descriptor->filename, PR_RDONLY, 0);\n-    if (NULL == file) {\n-        rv = PR_FAILURE;\n-        if (Aborted(rv)) {\n-            goto aborted;\n-        }\n-        if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                     (\"\\t\\tProcessRequest(0x%p): open file timeout\\n\",\n-                      PR_GetCurrentThread()));\n-            goto aborted;\n-        }\n+        (\"\\tProcessRequest(0x%p): read %d bytes from file\\n\", me, filebytes));\n+    bytes = PR_Read(file, buffer, filebytes);\n+    if (filebytes != bytes) {\n+      rv = PR_FAILURE;\n+      if (Aborted(rv)) {\n+        goto aborted;\n+      }\n+      if (PR_IO_TIMEOUT_ERROR == PR_GetError())\n         TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                 (\"\\t\\tProcessRequest(0x%p): other file open error (%u, %u)\\n\", me,\n+                 (\"\\t\\tProcessRequest(0x%p): read file timeout\\n\", me));\n+      else\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                 (\"\\t\\tProcessRequest(0x%p): other file error (%d, %d)\\n\", me,\n                   PR_GetError(), PR_GetOSError()));\n-        goto aborted;\n+      goto aborted;\n     }\n-    TEST_ASSERT(NULL != file);\n-\n-    netbytes = 0;\n-    while (netbytes < descbytes) {\n-        filebytes = sizeof(buffer);\n-        if ((descbytes - netbytes) < filebytes) {\n-            filebytes = descbytes - netbytes;\n-        }\n-        TEST_LOG(\n-            cltsrv_log_file, TEST_LOG_VERBOSE,\n-            (\"\\tProcessRequest(0x%p): read %d bytes from file\\n\", me, filebytes));\n-        bytes = PR_Read(file, buffer, filebytes);\n-        if (filebytes != bytes) {\n-            rv = PR_FAILURE;\n-            if (Aborted(rv)) {\n-                goto aborted;\n-            }\n-            if (PR_IO_TIMEOUT_ERROR == PR_GetError())\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tProcessRequest(0x%p): read file timeout\\n\", me));\n-            else\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tProcessRequest(0x%p): other file error (%d, %d)\\n\", me,\n-                          PR_GetError(), PR_GetOSError()));\n-            goto aborted;\n-        }\n-        TEST_ASSERT(bytes > 0);\n-        netbytes += bytes;\n-        filebytes = bytes;\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"\\t\\tProcessRequest(0x%p): sending %d bytes\\n\", me, filebytes));\n-        bytes = PR_Send(fd, buffer, filebytes, SEND_FLAGS, timeout);\n-        if (filebytes != bytes) {\n-            rv = PR_FAILURE;\n-            if (Aborted(rv)) {\n-                goto aborted;\n-            }\n-            if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tProcessRequest(0x%p): send data timeout\\n\", me));\n-                goto aborted;\n-            }\n-            break;\n-        }\n-        TEST_ASSERT(bytes > 0);\n+    TEST_ASSERT(bytes > 0);\n+    netbytes += bytes;\n+    filebytes = bytes;\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+             (\"\\t\\tProcessRequest(0x%p): sending %d bytes\\n\", me, filebytes));\n+    bytes = PR_Send(fd, buffer, filebytes, SEND_FLAGS, timeout);\n+    if (filebytes != bytes) {\n+      rv = PR_FAILURE;\n+      if (Aborted(rv)) {\n+        goto aborted;\n+      }\n+      if (PR_IO_TIMEOUT_ERROR == PR_GetError()) {\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                 (\"\\t\\tProcessRequest(0x%p): send data timeout\\n\", me));\n+        goto aborted;\n+      }\n+      break;\n     }\n+    TEST_ASSERT(bytes > 0);\n+  }\n \n-    PR_Lock(server->ml);\n-    server->bytesTransferred += filebytes;\n-    PR_Unlock(server->ml);\n+  PR_Lock(server->ml);\n+  server->bytesTransferred += filebytes;\n+  PR_Unlock(server->ml);\n \n-    rv = PR_Shutdown(fd, PR_SHUTDOWN_BOTH);\n-    if (Aborted(rv)) {\n-        goto aborted;\n-    }\n+  rv = PR_Shutdown(fd, PR_SHUTDOWN_BOTH);\n+  if (Aborted(rv)) {\n+    goto aborted;\n+  }\n \n-    rv = PR_Close(file);\n-    file = NULL;\n-    if (Aborted(rv)) {\n-        goto aborted;\n-    }\n-    TEST_ASSERT(PR_SUCCESS == rv);\n+  rv = PR_Close(file);\n+  file = NULL;\n+  if (Aborted(rv)) {\n+    goto aborted;\n+  }\n+  TEST_ASSERT(PR_SUCCESS == rv);\n \n aborted:\n-    PR_ClearInterrupt();\n-    if (NULL != file) {\n-        PR_Close(file);\n-    }\n-    drv = PR_Delete(descriptor->filename);\n-    TEST_ASSERT(PR_SUCCESS == drv);\n+  PR_ClearInterrupt();\n+  if (NULL != file) {\n+    PR_Close(file);\n+  }\n+  drv = PR_Delete(descriptor->filename);\n+  TEST_ASSERT(PR_SUCCESS == drv);\n exit:\n-    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-             (\"\\t\\tProcessRequest(0x%p): Finished\\n\", me));\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+           (\"\\t\\tProcessRequest(0x%p): Finished\\n\", me));\n \n-    PR_DELETE(descriptor);\n+  PR_DELETE(descriptor);\n \n #if defined(WIN95)\n-    PR_Sleep(PR_MillisecondsToInterval(200)); /* lth. see note [1] */\n+  PR_Sleep(PR_MillisecondsToInterval(200)); /* lth. see note [1] */\n #endif\n-    return rv;\n+  return rv;\n } /* ProcessRequest */\n \n typedef void (*StartFn)(void*);\n typedef struct StartObject {\n-    StartFn start;\n-    void* arg;\n+  StartFn start;\n+  void* arg;\n } StartObject;\n \n #if defined(_PR_PTHREADS)\n-#include \"md/_pth.h\"\n-#include <pthread.h>\n-\n-static void*\n-pthread_start(void* arg)\n-{\n-    StartObject* so = (StartObject*)arg;\n-    StartFn start = so->start;\n-    void* data = so->arg;\n-    PR_Free(so);\n-    start(data);\n-    return NULL;\n+#  include \"md/_pth.h\"\n+#  include <pthread.h>\n+\n+static void* pthread_start(void* arg) {\n+  StartObject* so = (StartObject*)arg;\n+  StartFn start = so->start;\n+  void* data = so->arg;\n+  PR_Free(so);\n+  start(data);\n+  return NULL;\n } /* pthread_start */\n #endif /* defined(_PR_PTHREADS) */\n \n #if defined(WIN32)\n-#include <process.h> /* for _beginthreadex() */\n-\n-static PRUintn __stdcall\n-windows_start(void* arg)\n-{\n-    StartObject* so = (StartObject*)arg;\n-    StartFn start = so->start;\n-    void* data = so->arg;\n-    PR_Free(so);\n-    start(data);\n-    return 0;\n+#  include <process.h> /* for _beginthreadex() */\n+\n+static PRUintn __stdcall windows_start(void* arg) {\n+  StartObject* so = (StartObject*)arg;\n+  StartFn start = so->start;\n+  void* data = so->arg;\n+  PR_Free(so);\n+  start(data);\n+  return 0;\n } /* windows_start */\n #endif /* defined(WIN32) */\n \n-static PRStatus\n-JoinThread(PRThread* thread)\n-{\n-    PRStatus rv;\n-    switch (thread_provider) {\n-        case thread_nspr:\n-            rv = PR_JoinThread(thread);\n-            break;\n-        case thread_pthread:\n+static PRStatus JoinThread(PRThread* thread) {\n+  PRStatus rv;\n+  switch (thread_provider) {\n+    case thread_nspr:\n+      rv = PR_JoinThread(thread);\n+      break;\n+    case thread_pthread:\n #if defined(_PR_PTHREADS)\n-            rv = PR_SUCCESS;\n-            break;\n+      rv = PR_SUCCESS;\n+      break;\n #endif /* defined(_PR_PTHREADS) */\n-        case thread_win32:\n+    case thread_win32:\n #if defined(WIN32)\n-            rv = PR_SUCCESS;\n-            break;\n+      rv = PR_SUCCESS;\n+      break;\n #endif\n-        default:\n-            rv = PR_FAILURE;\n-            break;\n-    }\n-    return rv;\n+    default:\n+      rv = PR_FAILURE;\n+      break;\n+  }\n+  return rv;\n } /* JoinThread */\n \n-static PRStatus\n-NewThread(StartFn start, void* arg, PRThreadPriority prio,\n-          PRThreadState state)\n-{\n-    PRStatus rv;\n-\n-    switch (thread_provider) {\n-        case thread_nspr: {\n-            PRThread* thread =\n-                PR_CreateThread(PR_USER_THREAD, start, arg, PR_PRIORITY_NORMAL,\n-                                PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-            rv = (NULL == thread) ? PR_FAILURE : PR_SUCCESS;\n-        } break;\n-        case thread_pthread:\n+static PRStatus NewThread(StartFn start, void* arg, PRThreadPriority prio,\n+                          PRThreadState state) {\n+  PRStatus rv;\n+\n+  switch (thread_provider) {\n+    case thread_nspr: {\n+      PRThread* thread =\n+          PR_CreateThread(PR_USER_THREAD, start, arg, PR_PRIORITY_NORMAL,\n+                          PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+      rv = (NULL == thread) ? PR_FAILURE : PR_SUCCESS;\n+    } break;\n+    case thread_pthread:\n #if defined(_PR_PTHREADS)\n-        {\n-            int rv;\n-            pthread_t id;\n-            pthread_attr_t tattr;\n-            StartObject* start_object;\n-            start_object = PR_NEW(StartObject);\n-            PR_ASSERT(NULL != start_object);\n-            start_object->start = start;\n-            start_object->arg = arg;\n-\n-            rv = _PT_PTHREAD_ATTR_INIT(&tattr);\n-            PR_ASSERT(0 == rv);\n-\n-            rv = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);\n-            PR_ASSERT(0 == rv);\n-\n-            rv = pthread_attr_setstacksize(&tattr, 64 * 1024);\n-            PR_ASSERT(0 == rv);\n-\n-            rv = _PT_PTHREAD_CREATE(&id, tattr, pthread_start, start_object);\n-            (void)_PT_PTHREAD_ATTR_DESTROY(&tattr);\n-            return (0 == rv) ? PR_SUCCESS : PR_FAILURE;\n-        }\n+    {\n+      int rv;\n+      pthread_t id;\n+      pthread_attr_t tattr;\n+      StartObject* start_object;\n+      start_object = PR_NEW(StartObject);\n+      PR_ASSERT(NULL != start_object);\n+      start_object->start = start;\n+      start_object->arg = arg;\n+\n+      rv = _PT_PTHREAD_ATTR_INIT(&tattr);\n+      PR_ASSERT(0 == rv);\n+\n+      rv = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);\n+      PR_ASSERT(0 == rv);\n+\n+      rv = pthread_attr_setstacksize(&tattr, 64 * 1024);\n+      PR_ASSERT(0 == rv);\n+\n+      rv = _PT_PTHREAD_CREATE(&id, tattr, pthread_start, start_object);\n+      (void)_PT_PTHREAD_ATTR_DESTROY(&tattr);\n+      return (0 == rv) ? PR_SUCCESS : PR_FAILURE;\n+    }\n #else\n-            PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-            rv = PR_FAILURE;\n+      PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+      rv = PR_FAILURE;\n #endif /* defined(_PR_PTHREADS) */\n-        break;\n+    break;\n \n-        case thread_sproc:\n-            PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-            rv = PR_FAILURE;\n-            break;\n-        case thread_win32:\n+    case thread_sproc:\n+      PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+      rv = PR_FAILURE;\n+      break;\n+    case thread_win32:\n #if defined(WIN32)\n-        {\n-            void* th;\n-            PRUintn id;\n-            StartObject* start_object;\n-            start_object = PR_NEW(StartObject);\n-            PR_ASSERT(NULL != start_object);\n-            start_object->start = start;\n-            start_object->arg = arg;\n-            th = (void*)_beginthreadex(\n-                NULL,                              /* LPSECURITY_ATTRIBUTES - pointer to thread security attributes\n-                                                    */\n-                0U,                                /* DWORD - initial thread stack size, in bytes */\n-                windows_start,                     /* LPTHREAD_START_ROUTINE - pointer to thread function\n-                                                    */\n-                start_object,                      /* LPVOID - argument for new thread */\n-                STACK_SIZE_PARAM_IS_A_RESERVATION, /*DWORD dwCreationFlags - creation\n-                                                      flags */\n-                &id /* LPDWORD - pointer to returned thread identifier */);\n-\n-            rv = (NULL == th) ? PR_FAILURE : PR_SUCCESS;\n-        }\n+    {\n+      void* th;\n+      PRUintn id;\n+      StartObject* start_object;\n+      start_object = PR_NEW(StartObject);\n+      PR_ASSERT(NULL != start_object);\n+      start_object->start = start;\n+      start_object->arg = arg;\n+      th = (void*)_beginthreadex(\n+          NULL, /* LPSECURITY_ATTRIBUTES - pointer to thread security attributes\n+                 */\n+          0U,   /* DWORD - initial thread stack size, in bytes */\n+          windows_start, /* LPTHREAD_START_ROUTINE - pointer to thread function\n+                          */\n+          start_object,  /* LPVOID - argument for new thread */\n+          STACK_SIZE_PARAM_IS_A_RESERVATION, /*DWORD dwCreationFlags - creation\n+                                                flags */\n+          &id /* LPDWORD - pointer to returned thread identifier */);\n+\n+      rv = (NULL == th) ? PR_FAILURE : PR_SUCCESS;\n+    }\n #else\n-            PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-            rv = PR_FAILURE;\n+      PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+      rv = PR_FAILURE;\n #endif\n-        break;\n-        default:\n-            PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n-            rv = PR_FAILURE;\n-    }\n-    return rv;\n+    break;\n+    default:\n+      PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);\n+      rv = PR_FAILURE;\n+  }\n+  return rv;\n } /* NewThread */\n \n-static PRStatus\n-CreateWorker(CSServer_t* server, CSPool_t* pool)\n-{\n-    PRStatus rv;\n-    CSWorker_t* worker = PR_NEWZAP(CSWorker_t);\n-    worker->server = server;\n-    PR_INIT_CLIST(&worker->element);\n-    rv = NewThread(Worker, worker, DEFAULT_SERVER_PRIORITY, PR_UNJOINABLE_THREAD);\n-    if (PR_FAILURE == rv) {\n-        PR_DELETE(worker);\n-    }\n-\n-    TEST_LOG(cltsrv_log_file, TEST_LOG_STATUS,\n-             (\"\\tCreateWorker(0x%p): create new worker (0x%p)\\n\",\n-              PR_GetCurrentThread(), worker->thread));\n-\n-    return rv;\n+static PRStatus CreateWorker(CSServer_t* server, CSPool_t* pool) {\n+  PRStatus rv;\n+  CSWorker_t* worker = PR_NEWZAP(CSWorker_t);\n+  worker->server = server;\n+  PR_INIT_CLIST(&worker->element);\n+  rv = NewThread(Worker, worker, DEFAULT_SERVER_PRIORITY, PR_UNJOINABLE_THREAD);\n+  if (PR_FAILURE == rv) {\n+    PR_DELETE(worker);\n+  }\n+\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_STATUS,\n+           (\"\\tCreateWorker(0x%p): create new worker (0x%p)\\n\",\n+            PR_GetCurrentThread(), worker->thread));\n+\n+  return rv;\n } /* CreateWorker */\n \n-static void PR_CALLBACK\n-Worker(void* arg)\n-{\n-    PRStatus rv;\n-    PRNetAddr from;\n-    PRFileDesc* fd = NULL;\n-    CSWorker_t* worker = (CSWorker_t*)arg;\n-    CSServer_t* server = worker->server;\n-    CSPool_t* pool = &server->pool;\n-\n-    PRThread* me = worker->thread = PR_GetCurrentThread();\n-\n-    TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-             (\"\\t\\tWorker(0x%p): started [%u]\\n\", me, pool->workers + 1));\n-\n-    PR_Lock(server->ml);\n-    PR_APPEND_LINK(&worker->element, &server->list);\n-    pool->workers += 1; /* define our existance */\n-\n-    while (cs_run == server->state) {\n-        while (pool->accepting >= server->workers.accepting) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                     (\"\\t\\tWorker(0x%p): waiting for accept slot[%d]\\n\", me,\n-                      pool->accepting));\n-            rv = PR_WaitCondVar(pool->acceptComplete, PR_INTERVAL_NO_TIMEOUT);\n-            if (Aborted(rv) || (cs_run != server->state)) {\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-                         (\"\\tWorker(0x%p): has been %s\\n\", me,\n-                          (Aborted(rv) ? \"interrupted\" : \"stopped\")));\n-                goto exit;\n-            }\n-        }\n-        pool->accepting += 1; /* how many are really in accept */\n-        PR_Unlock(server->ml);\n-\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"\\t\\tWorker(0x%p): calling accept\\n\", me));\n-        fd = PR_Accept(server->listener, &from, PR_INTERVAL_NO_TIMEOUT);\n-\n-        PR_Lock(server->ml);\n-        pool->accepting -= 1;\n-        PR_NotifyCondVar(pool->acceptComplete);\n-\n-        if ((NULL == fd) && Aborted(PR_FAILURE)) {\n-            if (NULL != server->listener) {\n-                PR_Close(server->listener);\n-                server->listener = NULL;\n-            }\n-            goto exit;\n-        }\n-\n-        if (NULL != fd) {\n-            /*\n-            ** Create another worker of the total number of workers is\n-            ** less than the minimum specified or we have none left in\n-            ** accept() AND we're not over the maximum.\n-            ** This sort of presumes that the number allowed in accept\n-            ** is at least as many as the minimum. Otherwise we'll keep\n-            ** creating new threads and deleting them soon after.\n-            */\n-            PRBool another = ((pool->workers < server->workers.minimum) ||\n-                              ((0 == pool->accepting) &&\n-                               (pool->workers < server->workers.maximum)))\n-                                 ? PR_TRUE\n-                                 : PR_FALSE;\n-            pool->active += 1;\n-            PR_Unlock(server->ml);\n-\n-            if (another) {\n-                (void)CreateWorker(server, pool);\n-            }\n-\n-            rv = ProcessRequest(fd, server);\n-            if (PR_SUCCESS != rv)\n-                TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n-                         (\"\\t\\tWorker(0x%p): server process ended abnormally\\n\", me));\n-            (void)PR_Close(fd);\n-            fd = NULL;\n-\n-            PR_Lock(server->ml);\n-            pool->active -= 1;\n-        }\n+static void PR_CALLBACK Worker(void* arg) {\n+  PRStatus rv;\n+  PRNetAddr from;\n+  PRFileDesc* fd = NULL;\n+  CSWorker_t* worker = (CSWorker_t*)arg;\n+  CSServer_t* server = worker->server;\n+  CSPool_t* pool = &server->pool;\n+\n+  PRThread* me = worker->thread = PR_GetCurrentThread();\n+\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+           (\"\\t\\tWorker(0x%p): started [%u]\\n\", me, pool->workers + 1));\n+\n+  PR_Lock(server->ml);\n+  PR_APPEND_LINK(&worker->element, &server->list);\n+  pool->workers += 1; /* define our existance */\n+\n+  while (cs_run == server->state) {\n+    while (pool->accepting >= server->workers.accepting) {\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+               (\"\\t\\tWorker(0x%p): waiting for accept slot[%d]\\n\", me,\n+                pool->accepting));\n+      rv = PR_WaitCondVar(pool->acceptComplete, PR_INTERVAL_NO_TIMEOUT);\n+      if (Aborted(rv) || (cs_run != server->state)) {\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+                 (\"\\tWorker(0x%p): has been %s\\n\", me,\n+                  (Aborted(rv) ? \"interrupted\" : \"stopped\")));\n+        goto exit;\n+      }\n     }\n-\n-exit:\n-    PR_ClearInterrupt();\n+    pool->accepting += 1; /* how many are really in accept */\n     PR_Unlock(server->ml);\n \n-    if (NULL != fd) {\n-        (void)PR_Shutdown(fd, PR_SHUTDOWN_BOTH);\n-        (void)PR_Close(fd);\n-    }\n-\n-    TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-             (\"\\t\\tWorker(0x%p): exiting [%u]\\n\", PR_GetCurrentThread(),\n-              pool->workers));\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+             (\"\\t\\tWorker(0x%p): calling accept\\n\", me));\n+    fd = PR_Accept(server->listener, &from, PR_INTERVAL_NO_TIMEOUT);\n \n     PR_Lock(server->ml);\n-    pool->workers -= 1; /* undefine our existance */\n-    PR_REMOVE_AND_INIT_LINK(&worker->element);\n-    PR_NotifyCondVar(pool->exiting);\n-    PR_Unlock(server->ml);\n+    pool->accepting -= 1;\n+    PR_NotifyCondVar(pool->acceptComplete);\n \n-    PR_DELETE(worker); /* destruction of the \"worker\" object */\n-\n-} /* Worker */\n+    if ((NULL == fd) && Aborted(PR_FAILURE)) {\n+      if (NULL != server->listener) {\n+        PR_Close(server->listener);\n+        server->listener = NULL;\n+      }\n+      goto exit;\n+    }\n \n-static void PR_CALLBACK\n-Server(void* arg)\n-{\n-    PRStatus rv;\n-    PRNetAddr serverAddress;\n-    CSServer_t* server = (CSServer_t*)arg;\n-    PRThread* me = server->thread = PR_GetCurrentThread();\n-    PRSocketOptionData sockOpt;\n+    if (NULL != fd) {\n+      /*\n+      ** Create another worker of the total number of workers is\n+      ** less than the minimum specified or we have none left in\n+      ** accept() AND we're not over the maximum.\n+      ** This sort of presumes that the number allowed in accept\n+      ** is at least as many as the minimum. Otherwise we'll keep\n+      ** creating new threads and deleting them soon after.\n+      */\n+      PRBool another = ((pool->workers < server->workers.minimum) ||\n+                        ((0 == pool->accepting) &&\n+                         (pool->workers < server->workers.maximum)))\n+                           ? PR_TRUE\n+                           : PR_FALSE;\n+      pool->active += 1;\n+      PR_Unlock(server->ml);\n+\n+      if (another) {\n+        (void)CreateWorker(server, pool);\n+      }\n+\n+      rv = ProcessRequest(fd, server);\n+      if (PR_SUCCESS != rv)\n+        TEST_LOG(cltsrv_log_file, TEST_LOG_ERROR,\n+                 (\"\\t\\tWorker(0x%p): server process ended abnormally\\n\", me));\n+      (void)PR_Close(fd);\n+      fd = NULL;\n \n-    server->listener = PR_Socket(domain, SOCK_STREAM, protocol);\n+      PR_Lock(server->ml);\n+      pool->active -= 1;\n+    }\n+  }\n \n-    sockOpt.option = PR_SockOpt_Reuseaddr;\n-    sockOpt.value.reuse_addr = PR_TRUE;\n-    rv = PR_SetSocketOption(server->listener, &sockOpt);\n-    TEST_ASSERT(PR_SUCCESS == rv);\n+exit:\n+  PR_ClearInterrupt();\n+  PR_Unlock(server->ml);\n \n-    memset(&serverAddress, 0, sizeof(serverAddress));\n-    rv = PR_InitializeNetAddr(PR_IpAddrAny, DEFAULT_PORT, &serverAddress);\n+  if (NULL != fd) {\n+    (void)PR_Shutdown(fd, PR_SHUTDOWN_BOTH);\n+    (void)PR_Close(fd);\n+  }\n \n-    rv = PR_Bind(server->listener, &serverAddress);\n-    TEST_ASSERT(PR_SUCCESS == rv);\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+           (\"\\t\\tWorker(0x%p): exiting [%u]\\n\", PR_GetCurrentThread(),\n+            pool->workers));\n \n-    rv = PR_Listen(server->listener, server->backlog);\n-    TEST_ASSERT(PR_SUCCESS == rv);\n+  PR_Lock(server->ml);\n+  pool->workers -= 1; /* undefine our existance */\n+  PR_REMOVE_AND_INIT_LINK(&worker->element);\n+  PR_NotifyCondVar(pool->exiting);\n+  PR_Unlock(server->ml);\n \n-    server->started = PR_IntervalNow();\n-    TimeOfDayMessage(\"Server started at\", me);\n+  PR_DELETE(worker); /* destruction of the \"worker\" object */\n \n-    PR_Lock(server->ml);\n-    server->state = cs_run;\n-    PR_NotifyCondVar(server->stateChange);\n-    PR_Unlock(server->ml);\n-\n-    /*\n-    ** Create the first worker (actually, a thread that accepts\n-    ** connections and then processes the work load as needed).\n-    ** From this point on, additional worker threads are created\n-    ** as they are needed by existing worker threads.\n-    */\n-    rv = CreateWorker(server, &server->pool);\n-    TEST_ASSERT(PR_SUCCESS == rv);\n+} /* Worker */\n \n-    /*\n-    ** From here on this thread is merely hanging around as the contact\n-    ** point for the main test driver. It's just waiting for the driver\n-    ** to declare the test complete.\n-    */\n+static void PR_CALLBACK Server(void* arg) {\n+  PRStatus rv;\n+  PRNetAddr serverAddress;\n+  CSServer_t* server = (CSServer_t*)arg;\n+  PRThread* me = server->thread = PR_GetCurrentThread();\n+  PRSocketOptionData sockOpt;\n+\n+  server->listener = PR_Socket(domain, SOCK_STREAM, protocol);\n+\n+  sockOpt.option = PR_SockOpt_Reuseaddr;\n+  sockOpt.value.reuse_addr = PR_TRUE;\n+  rv = PR_SetSocketOption(server->listener, &sockOpt);\n+  TEST_ASSERT(PR_SUCCESS == rv);\n+\n+  memset(&serverAddress, 0, sizeof(serverAddress));\n+  rv = PR_InitializeNetAddr(PR_IpAddrAny, DEFAULT_PORT, &serverAddress);\n+\n+  rv = PR_Bind(server->listener, &serverAddress);\n+  TEST_ASSERT(PR_SUCCESS == rv);\n+\n+  rv = PR_Listen(server->listener, server->backlog);\n+  TEST_ASSERT(PR_SUCCESS == rv);\n+\n+  server->started = PR_IntervalNow();\n+  TimeOfDayMessage(\"Server started at\", me);\n+\n+  PR_Lock(server->ml);\n+  server->state = cs_run;\n+  PR_NotifyCondVar(server->stateChange);\n+  PR_Unlock(server->ml);\n+\n+  /*\n+  ** Create the first worker (actually, a thread that accepts\n+  ** connections and then processes the work load as needed).\n+  ** From this point on, additional worker threads are created\n+  ** as they are needed by existing worker threads.\n+  */\n+  rv = CreateWorker(server, &server->pool);\n+  TEST_ASSERT(PR_SUCCESS == rv);\n+\n+  /*\n+  ** From here on this thread is merely hanging around as the contact\n+  ** point for the main test driver. It's just waiting for the driver\n+  ** to declare the test complete.\n+  */\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+           (\"\\tServer(0x%p): waiting for state change\\n\", me));\n+\n+  PR_Lock(server->ml);\n+  while ((cs_run == server->state) && !Aborted(rv)) {\n+    rv = PR_WaitCondVar(server->stateChange, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_Unlock(server->ml);\n+  PR_ClearInterrupt();\n+\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n+           (\"\\tServer(0x%p): shutting down workers\\n\", me));\n+\n+  /*\n+  ** Get all the worker threads to exit. They know how to\n+  ** clean up after themselves, so this is just a matter of\n+  ** waiting for clorine in the pool to take effect. During\n+  ** this stage we're ignoring interrupts.\n+  */\n+  server->workers.minimum = server->workers.maximum = 0;\n+\n+  PR_Lock(server->ml);\n+  while (!PR_CLIST_IS_EMPTY(&server->list)) {\n+    PRCList* head = PR_LIST_HEAD(&server->list);\n+    CSWorker_t* worker = (CSWorker_t*)head;\n     TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-             (\"\\tServer(0x%p): waiting for state change\\n\", me));\n-\n-    PR_Lock(server->ml);\n-    while ((cs_run == server->state) && !Aborted(rv)) {\n-        rv = PR_WaitCondVar(server->stateChange, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_Unlock(server->ml);\n-    PR_ClearInterrupt();\n-\n-    TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n-             (\"\\tServer(0x%p): shutting down workers\\n\", me));\n-\n-    /*\n-    ** Get all the worker threads to exit. They know how to\n-    ** clean up after themselves, so this is just a matter of\n-    ** waiting for clorine in the pool to take effect. During\n-    ** this stage we're ignoring interrupts.\n-    */\n-    server->workers.minimum = server->workers.maximum = 0;\n-\n-    PR_Lock(server->ml);\n-    while (!PR_CLIST_IS_EMPTY(&server->list)) {\n-        PRCList* head = PR_LIST_HEAD(&server->list);\n-        CSWorker_t* worker = (CSWorker_t*)head;\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"\\tServer(0x%p): interrupting worker(0x%p)\\n\", me, worker));\n-        rv = PR_Interrupt(worker->thread);\n-        TEST_ASSERT(PR_SUCCESS == rv);\n-        PR_REMOVE_AND_INIT_LINK(head);\n-    }\n+             (\"\\tServer(0x%p): interrupting worker(0x%p)\\n\", me, worker));\n+    rv = PR_Interrupt(worker->thread);\n+    TEST_ASSERT(PR_SUCCESS == rv);\n+    PR_REMOVE_AND_INIT_LINK(head);\n+  }\n \n-    while (server->pool.workers > 0) {\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-                 (\"\\tServer(0x%p): waiting for %u workers to exit\\n\", me,\n-                  server->pool.workers));\n-        (void)PR_WaitCondVar(server->pool.exiting, PR_INTERVAL_NO_TIMEOUT);\n-    }\n+  while (server->pool.workers > 0) {\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+             (\"\\tServer(0x%p): waiting for %u workers to exit\\n\", me,\n+              server->pool.workers));\n+    (void)PR_WaitCondVar(server->pool.exiting, PR_INTERVAL_NO_TIMEOUT);\n+  }\n \n-    server->state = cs_exit;\n-    PR_NotifyCondVar(server->stateChange);\n-    PR_Unlock(server->ml);\n+  server->state = cs_exit;\n+  PR_NotifyCondVar(server->stateChange);\n+  PR_Unlock(server->ml);\n \n-    TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n-             (\"\\tServer(0x%p): stopped after %u operations and %u bytes\\n\", me,\n-              server->operations, server->bytesTransferred));\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n+           (\"\\tServer(0x%p): stopped after %u operations and %u bytes\\n\", me,\n+            server->operations, server->bytesTransferred));\n \n-    if (NULL != server->listener) {\n-        PR_Close(server->listener);\n-    }\n-    server->stopped = PR_IntervalNow();\n+  if (NULL != server->listener) {\n+    PR_Close(server->listener);\n+  }\n+  server->stopped = PR_IntervalNow();\n \n } /* Server */\n \n-static void\n-WaitForCompletion(PRIntn execution)\n-{\n-    while (execution > 0) {\n-        PRIntn dally = (execution > 30) ? 30 : execution;\n-        PR_Sleep(PR_SecondsToInterval(dally));\n-        if (pthread_stats) {\n-            PT_FPrintStats(debug_out, \"\\nPThread Statistics\\n\");\n-        }\n-        execution -= dally;\n+static void WaitForCompletion(PRIntn execution) {\n+  while (execution > 0) {\n+    PRIntn dally = (execution > 30) ? 30 : execution;\n+    PR_Sleep(PR_SecondsToInterval(dally));\n+    if (pthread_stats) {\n+      PT_FPrintStats(debug_out, \"\\nPThread Statistics\\n\");\n     }\n+    execution -= dally;\n+  }\n } /* WaitForCompletion */\n \n-static void\n-Help(void)\n-{\n-    PR_fprintf(debug_out, \"cltsrv test program usage:\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-a <n>       threads allowed in accept        (5)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-b <n>       backlock for listen              (5)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-c <threads> number of clients to create      (1)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-w <threads> minimal number of server threads (1)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-W <threads> maximum number of server threads (1)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-e <seconds> duration of the test in seconds  (10)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-s <string>  dsn name of server               (localhost)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-G           use GLOBAL threads               (LOCAL)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-T <string>  thread provider ('n' | 'p' | 'w')(n)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-X           use XTP as transport             (TCP)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-6           Use IPv6                         (IPv4)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-v           verbosity (accumulative)         (0)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-p           pthread statistics               (FALSE)\\n\");\n-    PR_fprintf(debug_out,\n-               \"\\t-d           debug mode                       (FALSE)\\n\");\n-    PR_fprintf(debug_out, \"\\t-h           this message\\n\");\n+static void Help(void) {\n+  PR_fprintf(debug_out, \"cltsrv test program usage:\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-a <n>       threads allowed in accept        (5)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-b <n>       backlock for listen              (5)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-c <threads> number of clients to create      (1)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-w <threads> minimal number of server threads (1)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-W <threads> maximum number of server threads (1)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-e <seconds> duration of the test in seconds  (10)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-s <string>  dsn name of server               (localhost)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-G           use GLOBAL threads               (LOCAL)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-T <string>  thread provider ('n' | 'p' | 'w')(n)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-X           use XTP as transport             (TCP)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-6           Use IPv6                         (IPv4)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-v           verbosity (accumulative)         (0)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-p           pthread statistics               (FALSE)\\n\");\n+  PR_fprintf(debug_out,\n+             \"\\t-d           debug mode                       (FALSE)\\n\");\n+  PR_fprintf(debug_out, \"\\t-h           this message\\n\");\n } /* Help */\n \n-static Verbosity\n-IncrementVerbosity(void)\n-{\n-    PRIntn verboge = (PRIntn)verbosity + 1;\n-    return (Verbosity)verboge;\n+static Verbosity IncrementVerbosity(void) {\n+  PRIntn verboge = (PRIntn)verbosity + 1;\n+  return (Verbosity)verboge;\n } /* IncrementVerbosity */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRUintn index;\n-    PRBool boolean;\n-    CSClient_t* client;\n-    PRStatus rv, joinStatus;\n-    CSServer_t* server = NULL;\n-    char* thread_type;\n-\n-    PRUintn backlog = DEFAULT_BACKLOG;\n-    PRUintn clients = DEFAULT_CLIENTS;\n-    const char* serverName = DEFAULT_SERVER;\n-    PRBool serverIsLocal = PR_TRUE;\n-    PRUintn accepting = ALLOWED_IN_ACCEPT;\n-    PRUintn workersMin = DEFAULT_WORKERS_MIN;\n-    PRUintn workersMax = DEFAULT_WORKERS_MAX;\n-    PRIntn execution = DEFAULT_EXECUTION_TIME;\n-\n-    /*\n-     * -G           use global threads\n-     * -a <n>       threads allowed in accept\n-     * -b <n>       backlock for listen\n-     * -c <threads> number of clients to create\n-     * -w <threads> minimal number of server threads\n-     * -W <threads> maximum number of server threads\n-     * -e <seconds> duration of the test in seconds\n-     * -s <string>  dsn name of server (implies no server here)\n-     * -v           verbosity\n-     */\n-\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"GX6b:a:c:w:W:e:s:T:vdhp\");\n+int main(int argc, char** argv) {\n+  PRUintn index;\n+  PRBool boolean;\n+  CSClient_t* client;\n+  PRStatus rv, joinStatus;\n+  CSServer_t* server = NULL;\n+  char* thread_type;\n+\n+  PRUintn backlog = DEFAULT_BACKLOG;\n+  PRUintn clients = DEFAULT_CLIENTS;\n+  const char* serverName = DEFAULT_SERVER;\n+  PRBool serverIsLocal = PR_TRUE;\n+  PRUintn accepting = ALLOWED_IN_ACCEPT;\n+  PRUintn workersMin = DEFAULT_WORKERS_MIN;\n+  PRUintn workersMax = DEFAULT_WORKERS_MAX;\n+  PRIntn execution = DEFAULT_EXECUTION_TIME;\n+\n+  /*\n+   * -G           use global threads\n+   * -a <n>       threads allowed in accept\n+   * -b <n>       backlock for listen\n+   * -c <threads> number of clients to create\n+   * -w <threads> minimal number of server threads\n+   * -W <threads> maximum number of server threads\n+   * -e <seconds> duration of the test in seconds\n+   * -s <string>  dsn name of server (implies no server here)\n+   * -v           verbosity\n+   */\n+\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"GX6b:a:c:w:W:e:s:T:vdhp\");\n \n #if defined(WIN32)\n-    thread_provider = thread_win32;\n+  thread_provider = thread_win32;\n #elif defined(_PR_PTHREADS)\n-    thread_provider = thread_pthread;\n+  thread_provider = thread_pthread;\n #else\n-    thread_provider = thread_nspr;\n+  thread_provider = thread_nspr;\n #endif\n \n-    debug_out = PR_GetSpecialFD(PR_StandardError);\n+  debug_out = PR_GetSpecialFD(PR_StandardError);\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'G': /* use global threads */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'X': /* use XTP as transport */\n-                protocol = 36;\n-                break;\n-            case '6': /* Use IPv6 */\n-                domain = PR_AF_INET6;\n-                break;\n-            case 'a': /* the value for accepting */\n-                accepting = atoi(opt->value);\n-                break;\n-            case 'b': /* the value for backlock */\n-                backlog = atoi(opt->value);\n-                break;\n-            case 'T': /* the thread provider */\n-                if ('n' == *opt->value) {\n-                    thread_provider = thread_nspr;\n-                } else if ('p' == *opt->value) {\n-                    thread_provider = thread_pthread;\n-                } else if ('w' == *opt->value) {\n-                    thread_provider = thread_win32;\n-                } else {\n-                    Help();\n-                    return 2;\n-                }\n-                break;\n-            case 'c': /* number of client threads */\n-                clients = atoi(opt->value);\n-                break;\n-            case 'w': /* minimum server worker threads */\n-                workersMin = atoi(opt->value);\n-                break;\n-            case 'W': /* maximum server worker threads */\n-                workersMax = atoi(opt->value);\n-                break;\n-            case 'e': /* program execution time in seconds */\n-                execution = atoi(opt->value);\n-                break;\n-            case 's': /* server's address */\n-                serverName = opt->value;\n-                break;\n-            case 'v': /* verbosity */\n-                verbosity = IncrementVerbosity();\n-                break;\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            case 'p': /* pthread mode */\n-                pthread_stats = PR_TRUE;\n-                break;\n-            case 'h':\n-            default:\n-                Help();\n-                return 2;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    if (0 != PL_strcmp(serverName, DEFAULT_SERVER)) {\n-        serverIsLocal = PR_FALSE;\n-    }\n-    if (0 == execution) {\n-        execution = DEFAULT_EXECUTION_TIME;\n-    }\n-    if (0 == workersMax) {\n-        workersMax = DEFAULT_WORKERS_MAX;\n-    }\n-    if (0 == workersMin) {\n-        workersMin = DEFAULT_WORKERS_MIN;\n-    }\n-    if (0 == accepting) {\n-        accepting = ALLOWED_IN_ACCEPT;\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    if (0 == backlog) {\n-        backlog = DEFAULT_BACKLOG;\n+    switch (opt->option) {\n+      case 'G': /* use global threads */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'X': /* use XTP as transport */\n+        protocol = 36;\n+        break;\n+      case '6': /* Use IPv6 */\n+        domain = PR_AF_INET6;\n+        break;\n+      case 'a': /* the value for accepting */\n+        accepting = atoi(opt->value);\n+        break;\n+      case 'b': /* the value for backlock */\n+        backlog = atoi(opt->value);\n+        break;\n+      case 'T': /* the thread provider */\n+        if ('n' == *opt->value) {\n+          thread_provider = thread_nspr;\n+        } else if ('p' == *opt->value) {\n+          thread_provider = thread_pthread;\n+        } else if ('w' == *opt->value) {\n+          thread_provider = thread_win32;\n+        } else {\n+          Help();\n+          return 2;\n+        }\n+        break;\n+      case 'c': /* number of client threads */\n+        clients = atoi(opt->value);\n+        break;\n+      case 'w': /* minimum server worker threads */\n+        workersMin = atoi(opt->value);\n+        break;\n+      case 'W': /* maximum server worker threads */\n+        workersMax = atoi(opt->value);\n+        break;\n+      case 'e': /* program execution time in seconds */\n+        execution = atoi(opt->value);\n+        break;\n+      case 's': /* server's address */\n+        serverName = opt->value;\n+        break;\n+      case 'v': /* verbosity */\n+        verbosity = IncrementVerbosity();\n+        break;\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      case 'p': /* pthread mode */\n+        pthread_stats = PR_TRUE;\n+        break;\n+      case 'h':\n+      default:\n+        Help();\n+        return 2;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  if (0 != PL_strcmp(serverName, DEFAULT_SERVER)) {\n+    serverIsLocal = PR_FALSE;\n+  }\n+  if (0 == execution) {\n+    execution = DEFAULT_EXECUTION_TIME;\n+  }\n+  if (0 == workersMax) {\n+    workersMax = DEFAULT_WORKERS_MAX;\n+  }\n+  if (0 == workersMin) {\n+    workersMin = DEFAULT_WORKERS_MIN;\n+  }\n+  if (0 == accepting) {\n+    accepting = ALLOWED_IN_ACCEPT;\n+  }\n+  if (0 == backlog) {\n+    backlog = DEFAULT_BACKLOG;\n+  }\n+\n+  if (workersMin > accepting) {\n+    accepting = workersMin;\n+  }\n+\n+  TimeOfDayMessage(\"Client/Server started at\", PR_GetCurrentThread());\n+\n+  cltsrv_log_file = PR_NewLogModule(\"cltsrv_log\");\n+  MY_ASSERT(NULL != cltsrv_log_file);\n+  boolean = PR_SetLogFile(\"cltsrv.log\");\n+  MY_ASSERT(boolean);\n+\n+  if (serverIsLocal) {\n+    /* Establish the server */\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n+             (\"main(0x%p): starting server\\n\", PR_GetCurrentThread()));\n+\n+    server = PR_NEWZAP(CSServer_t);\n+    PR_INIT_CLIST(&server->list);\n+    server->state = cs_init;\n+    server->ml = PR_NewLock();\n+    server->backlog = backlog;\n+    server->port = DEFAULT_PORT;\n+    server->workers.minimum = workersMin;\n+    server->workers.maximum = workersMax;\n+    server->workers.accepting = accepting;\n+    server->stateChange = PR_NewCondVar(server->ml);\n+    server->pool.exiting = PR_NewCondVar(server->ml);\n+    server->pool.acceptComplete = PR_NewCondVar(server->ml);\n \n-    if (workersMin > accepting) {\n-        accepting = workersMin;\n-    }\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+             (\"main(0x%p): creating server thread\\n\", PR_GetCurrentThread()));\n \n-    TimeOfDayMessage(\"Client/Server started at\", PR_GetCurrentThread());\n-\n-    cltsrv_log_file = PR_NewLogModule(\"cltsrv_log\");\n-    MY_ASSERT(NULL != cltsrv_log_file);\n-    boolean = PR_SetLogFile(\"cltsrv.log\");\n-    MY_ASSERT(boolean);\n-\n-    if (serverIsLocal) {\n-        /* Establish the server */\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_INFO,\n-                 (\"main(0x%p): starting server\\n\", PR_GetCurrentThread()));\n-\n-        server = PR_NEWZAP(CSServer_t);\n-        PR_INIT_CLIST(&server->list);\n-        server->state = cs_init;\n-        server->ml = PR_NewLock();\n-        server->backlog = backlog;\n-        server->port = DEFAULT_PORT;\n-        server->workers.minimum = workersMin;\n-        server->workers.maximum = workersMax;\n-        server->workers.accepting = accepting;\n-        server->stateChange = PR_NewCondVar(server->ml);\n-        server->pool.exiting = PR_NewCondVar(server->ml);\n-        server->pool.acceptComplete = PR_NewCondVar(server->ml);\n+    rv = NewThread(Server, server, PR_PRIORITY_HIGH, PR_JOINABLE_THREAD);\n+    TEST_ASSERT(PR_SUCCESS == rv);\n \n-        TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-                 (\"main(0x%p): creating server thread\\n\", PR_GetCurrentThread()));\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+             (\"main(0x%p): waiting for server init\\n\", PR_GetCurrentThread()));\n \n-        rv = NewThread(Server, server, PR_PRIORITY_HIGH, PR_JOINABLE_THREAD);\n-        TEST_ASSERT(PR_SUCCESS == rv);\n+    PR_Lock(server->ml);\n+    while (server->state == cs_init) {\n+      PR_WaitCondVar(server->stateChange, PR_INTERVAL_NO_TIMEOUT);\n+    }\n+    PR_Unlock(server->ml);\n \n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"main(0x%p): waiting for server init\\n\", PR_GetCurrentThread()));\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+             (\"main(0x%p): server init complete (port #%d)\\n\",\n+              PR_GetCurrentThread(), server->port));\n+  }\n \n-        PR_Lock(server->ml);\n-        while (server->state == cs_init) {\n-            PR_WaitCondVar(server->stateChange, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        PR_Unlock(server->ml);\n+  if (clients != 0) {\n+    /* Create all of the clients */\n+    PRHostEnt host;\n+    char buffer[BUFFER_SIZE];\n+    client = (CSClient_t*)PR_CALLOC(clients * sizeof(CSClient_t));\n \n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"main(0x%p): server init complete (port #%d)\\n\",\n-                  PR_GetCurrentThread(), server->port));\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+             (\"main(0x%p): creating %d client threads\\n\", PR_GetCurrentThread(),\n+              clients));\n+\n+    if (!serverIsLocal) {\n+      rv = PR_GetHostByName(serverName, buffer, BUFFER_SIZE, &host);\n+      if (PR_SUCCESS != rv) {\n+        PL_FPrintError(PR_STDERR, \"PR_GetHostByName\");\n+        return 2;\n+      }\n     }\n \n-    if (clients != 0) {\n-        /* Create all of the clients */\n-        PRHostEnt host;\n-        char buffer[BUFFER_SIZE];\n-        client = (CSClient_t*)PR_CALLOC(clients * sizeof(CSClient_t));\n-\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                 (\"main(0x%p): creating %d client threads\\n\", PR_GetCurrentThread(),\n-                  clients));\n-\n-        if (!serverIsLocal) {\n-            rv = PR_GetHostByName(serverName, buffer, BUFFER_SIZE, &host);\n-            if (PR_SUCCESS != rv) {\n-                PL_FPrintError(PR_STDERR, \"PR_GetHostByName\");\n-                return 2;\n-            }\n-        }\n-\n-        for (index = 0; index < clients; ++index) {\n-            client[index].state = cs_init;\n-            client[index].ml = PR_NewLock();\n-            if (serverIsLocal) {\n-                (void)PR_InitializeNetAddr(PR_IpAddrLoopback, DEFAULT_PORT,\n-                                           &client[index].serverAddress);\n-            } else {\n-                (void)PR_EnumerateHostEnt(0, &host, DEFAULT_PORT,\n-                                          &client[index].serverAddress);\n-            }\n-            client[index].stateChange = PR_NewCondVar(client[index].ml);\n-            TEST_LOG(\n-                cltsrv_log_file, TEST_LOG_INFO,\n-                (\"main(0x%p): creating client threads\\n\", PR_GetCurrentThread()));\n-            rv = NewThread(Client, &client[index], PR_PRIORITY_NORMAL,\n-                           PR_JOINABLE_THREAD);\n-            TEST_ASSERT(PR_SUCCESS == rv);\n-            PR_Lock(client[index].ml);\n-            while (cs_init == client[index].state) {\n-                PR_WaitCondVar(client[index].stateChange, PR_INTERVAL_NO_TIMEOUT);\n-            }\n-            PR_Unlock(client[index].ml);\n-        }\n+    for (index = 0; index < clients; ++index) {\n+      client[index].state = cs_init;\n+      client[index].ml = PR_NewLock();\n+      if (serverIsLocal) {\n+        (void)PR_InitializeNetAddr(PR_IpAddrLoopback, DEFAULT_PORT,\n+                                   &client[index].serverAddress);\n+      } else {\n+        (void)PR_EnumerateHostEnt(0, &host, DEFAULT_PORT,\n+                                  &client[index].serverAddress);\n+      }\n+      client[index].stateChange = PR_NewCondVar(client[index].ml);\n+      TEST_LOG(\n+          cltsrv_log_file, TEST_LOG_INFO,\n+          (\"main(0x%p): creating client threads\\n\", PR_GetCurrentThread()));\n+      rv = NewThread(Client, &client[index], PR_PRIORITY_NORMAL,\n+                     PR_JOINABLE_THREAD);\n+      TEST_ASSERT(PR_SUCCESS == rv);\n+      PR_Lock(client[index].ml);\n+      while (cs_init == client[index].state) {\n+        PR_WaitCondVar(client[index].stateChange, PR_INTERVAL_NO_TIMEOUT);\n+      }\n+      PR_Unlock(client[index].ml);\n     }\n-\n-    /* Then just let them go at it for a bit */\n-    TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n-             (\"main(0x%p): waiting for execution interval (%d seconds)\\n\",\n-              PR_GetCurrentThread(), execution));\n-\n-    WaitForCompletion(execution);\n-\n-    TimeOfDayMessage(\"Shutting down\", PR_GetCurrentThread());\n-\n-    if (clients != 0) {\n-        for (index = 0; index < clients; ++index) {\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_STATUS,\n-                     (\"main(0x%p): notifying client(0x%p) to stop\\n\",\n-                      PR_GetCurrentThread(), client[index].thread));\n-\n-            PR_Lock(client[index].ml);\n-            if (cs_run == client[index].state) {\n-                client[index].state = cs_stop;\n-                PR_Interrupt(client[index].thread);\n-                while (cs_stop == client[index].state)\n-                    PR_WaitCondVar(client[index].stateChange, PR_INTERVAL_NO_TIMEOUT);\n-            }\n-            PR_Unlock(client[index].ml);\n-\n-            TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n-                     (\"main(0x%p): joining client(0x%p)\\n\", PR_GetCurrentThread(),\n-                      client[index].thread));\n-\n-            joinStatus = JoinThread(client[index].thread);\n-            TEST_ASSERT(PR_SUCCESS == joinStatus);\n-            PR_DestroyCondVar(client[index].stateChange);\n-            PR_DestroyLock(client[index].ml);\n-        }\n-        PR_DELETE(client);\n+  }\n+\n+  /* Then just let them go at it for a bit */\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n+           (\"main(0x%p): waiting for execution interval (%d seconds)\\n\",\n+            PR_GetCurrentThread(), execution));\n+\n+  WaitForCompletion(execution);\n+\n+  TimeOfDayMessage(\"Shutting down\", PR_GetCurrentThread());\n+\n+  if (clients != 0) {\n+    for (index = 0; index < clients; ++index) {\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_STATUS,\n+               (\"main(0x%p): notifying client(0x%p) to stop\\n\",\n+                PR_GetCurrentThread(), client[index].thread));\n+\n+      PR_Lock(client[index].ml);\n+      if (cs_run == client[index].state) {\n+        client[index].state = cs_stop;\n+        PR_Interrupt(client[index].thread);\n+        while (cs_stop == client[index].state)\n+          PR_WaitCondVar(client[index].stateChange, PR_INTERVAL_NO_TIMEOUT);\n+      }\n+      PR_Unlock(client[index].ml);\n+\n+      TEST_LOG(cltsrv_log_file, TEST_LOG_VERBOSE,\n+               (\"main(0x%p): joining client(0x%p)\\n\", PR_GetCurrentThread(),\n+                client[index].thread));\n+\n+      joinStatus = JoinThread(client[index].thread);\n+      TEST_ASSERT(PR_SUCCESS == joinStatus);\n+      PR_DestroyCondVar(client[index].stateChange);\n+      PR_DestroyLock(client[index].ml);\n     }\n+    PR_DELETE(client);\n+  }\n \n-    if (NULL != server) {\n-        /* All clients joined - retrieve the server */\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-                 (\"main(0x%p): notifying server(0x%p) to stop\\n\",\n-                  PR_GetCurrentThread(), server->thread));\n-\n-        PR_Lock(server->ml);\n-        server->state = cs_stop;\n-        PR_Interrupt(server->thread);\n-        while (cs_exit != server->state) {\n-            PR_WaitCondVar(server->stateChange, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        PR_Unlock(server->ml);\n-\n-        TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n-                 (\"main(0x%p): joining server(0x%p)\\n\", PR_GetCurrentThread(),\n-                  server->thread));\n-        joinStatus = JoinThread(server->thread);\n-        TEST_ASSERT(PR_SUCCESS == joinStatus);\n-\n-        PR_DestroyCondVar(server->stateChange);\n-        PR_DestroyCondVar(server->pool.exiting);\n-        PR_DestroyCondVar(server->pool.acceptComplete);\n-        PR_DestroyLock(server->ml);\n-        PR_DELETE(server);\n-    }\n+  if (NULL != server) {\n+    /* All clients joined - retrieve the server */\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+             (\"main(0x%p): notifying server(0x%p) to stop\\n\",\n+              PR_GetCurrentThread(), server->thread));\n \n-    TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n-             (\"main(0x%p): test complete\\n\", PR_GetCurrentThread()));\n-\n-    if (thread_provider == thread_win32) {\n-        thread_type = \"\\nWin32 Thread Statistics\\n\";\n-    } else if (thread_provider == thread_pthread) {\n-        thread_type = \"\\npthread Statistics\\n\";\n-    } else if (thread_provider == thread_sproc) {\n-        thread_type = \"\\nsproc Statistics\\n\";\n-    } else {\n-        PR_ASSERT(thread_provider == thread_nspr);\n-        thread_type = \"\\nPRThread Statistics\\nn\";\n+    PR_Lock(server->ml);\n+    server->state = cs_stop;\n+    PR_Interrupt(server->thread);\n+    while (cs_exit != server->state) {\n+      PR_WaitCondVar(server->stateChange, PR_INTERVAL_NO_TIMEOUT);\n     }\n+    PR_Unlock(server->ml);\n \n-    PT_FPrintStats(debug_out, thread_type);\n-\n-    TimeOfDayMessage(\"Test exiting at\", PR_GetCurrentThread());\n-    PR_Cleanup();\n-    return 0;\n+    TEST_LOG(cltsrv_log_file, TEST_LOG_NOTICE,\n+             (\"main(0x%p): joining server(0x%p)\\n\", PR_GetCurrentThread(),\n+              server->thread));\n+    joinStatus = JoinThread(server->thread);\n+    TEST_ASSERT(PR_SUCCESS == joinStatus);\n+\n+    PR_DestroyCondVar(server->stateChange);\n+    PR_DestroyCondVar(server->pool.exiting);\n+    PR_DestroyCondVar(server->pool.acceptComplete);\n+    PR_DestroyLock(server->ml);\n+    PR_DELETE(server);\n+  }\n+\n+  TEST_LOG(cltsrv_log_file, TEST_LOG_ALWAYS,\n+           (\"main(0x%p): test complete\\n\", PR_GetCurrentThread()));\n+\n+  if (thread_provider == thread_win32) {\n+    thread_type = \"\\nWin32 Thread Statistics\\n\";\n+  } else if (thread_provider == thread_pthread) {\n+    thread_type = \"\\npthread Statistics\\n\";\n+  } else if (thread_provider == thread_sproc) {\n+    thread_type = \"\\nsproc Statistics\\n\";\n+  } else {\n+    PR_ASSERT(thread_provider == thread_nspr);\n+    thread_type = \"\\nPRThread Statistics\\nn\";\n+  }\n+\n+  PT_FPrintStats(debug_out, thread_type);\n+\n+  TimeOfDayMessage(\"Test exiting at\", PR_GetCurrentThread());\n+  PR_Cleanup();\n+  return 0;\n } /* main */\n \n /* cltsrv.c */\ndiff --git a/nspr/pr/tests/prpoll.c b/nspr/pr/tests/prpoll.c\nindex 6203e28..db3878f 100644\n--- a/nspr/pr/tests/prpoll.c\n+++ b/nspr/pr/tests/prpoll.c\n@@ -1,13 +1,14 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n \n #ifdef WIN32\n-#include <windows.h>\n+#  include <windows.h>\n #endif\n \n #ifdef XP_UNIX\n-#include <unistd.h> /* for close() */\n+#  include <unistd.h> /* for close() */\n #endif\n \n #include \"prinit.h\"\n@@ -27,166 +28,160 @@\n \n #ifdef WINCE\n \n-int\n-main(int argc, char** argv)\n-{\n-    fprintf(stderr, \"Invalid/Broken Test for WinCE/WinMobile\\n\");\n-    exit(1);\n+int main(int argc, char** argv) {\n+  fprintf(stderr, \"Invalid/Broken Test for WinCE/WinMobile\\n\");\n+  exit(1);\n }\n \n #else\n \n-static void\n-clientThreadFunc(void* arg)\n-{\n-    PRUint16 port = (PRUint16)arg;\n-    PRFileDesc* sock;\n-    PRNetAddr addr;\n-    char buf[BUF_SIZE];\n-    int i;\n-\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.port = PR_htons(port);\n-    addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n-    PR_snprintf(buf, sizeof(buf), \"%hu\", port);\n-\n-    for (i = 0; i < 5; i++) {\n-        sock = PR_NewTCPSocket();\n-        PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT);\n-\n-        PR_Write(sock, buf, sizeof(buf));\n-        PR_Close(sock);\n-    }\n+static void clientThreadFunc(void* arg) {\n+  PRUint16 port = (PRUint16)arg;\n+  PRFileDesc* sock;\n+  PRNetAddr addr;\n+  char buf[BUF_SIZE];\n+  int i;\n+\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.port = PR_htons(port);\n+  addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n+  PR_snprintf(buf, sizeof(buf), \"%hu\", port);\n+\n+  for (i = 0; i < 5; i++) {\n+    sock = PR_NewTCPSocket();\n+    PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT);\n+\n+    PR_Write(sock, buf, sizeof(buf));\n+    PR_Close(sock);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc *listenSock1, *listenSock2;\n-    PRFileDesc* badFD;\n-    PRUint16 listenPort1, listenPort2;\n-    PRNetAddr addr;\n-    char buf[BUF_SIZE];\n-    PRThread* clientThread;\n-    PRPollDesc pds0[10], pds1[10], *pds, *other_pds;\n-    PRIntn npds;\n-    PRInt32 retVal;\n-    PRInt32 rv;\n-    PROsfd sd;\n-    struct sockaddr_in saddr;\n-    PRIntn saddr_len;\n-    PRUint16 listenPort3;\n-    PRFileDesc* socket_poll_fd;\n-    PRIntn i, j;\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    printf(\"This program tests PR_Poll with sockets.\\n\");\n-    printf(\"Timeout, error reporting, and normal operation are tested.\\n\\n\");\n-\n-    /* Create two listening sockets */\n-    if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        exit(1);\n-    }\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        exit(1);\n-    }\n-    if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        exit(1);\n-    }\n-    listenPort1 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        exit(1);\n-    }\n+int main(int argc, char** argv) {\n+  PRFileDesc *listenSock1, *listenSock2;\n+  PRFileDesc* badFD;\n+  PRUint16 listenPort1, listenPort2;\n+  PRNetAddr addr;\n+  char buf[BUF_SIZE];\n+  PRThread* clientThread;\n+  PRPollDesc pds0[10], pds1[10], *pds, *other_pds;\n+  PRIntn npds;\n+  PRInt32 retVal;\n+  PRInt32 rv;\n+  PROsfd sd;\n+  struct sockaddr_in saddr;\n+  PRIntn saddr_len;\n+  PRUint16 listenPort3;\n+  PRFileDesc* socket_poll_fd;\n+  PRIntn i, j;\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  printf(\"This program tests PR_Poll with sockets.\\n\");\n+  printf(\"Timeout, error reporting, and normal operation are tested.\\n\\n\");\n+\n+  /* Create two listening sockets */\n+  if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    exit(1);\n+  }\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    exit(1);\n+  }\n+  if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    exit(1);\n+  }\n+  listenPort1 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    exit(1);\n+  }\n \n-    if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        exit(1);\n-    }\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        exit(1);\n-    }\n-    if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        exit(1);\n-    }\n-    listenPort2 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        exit(1);\n-    }\n-    /* Set up the poll descriptor array */\n-    pds = pds0;\n-    other_pds = pds1;\n-    memset(pds, 0, sizeof(pds));\n-    npds = 0;\n-    pds[npds].fd = listenSock1;\n-    pds[npds].in_flags = PR_POLL_READ;\n-    npds++;\n-    pds[npds].fd = listenSock2;\n-    pds[npds].in_flags = PR_POLL_READ;\n-    npds++;\n-\n-    sd = socket(AF_INET, SOCK_STREAM, 0);\n-    PR_ASSERT(sd >= 0);\n-    memset((char*)&saddr, 0, sizeof(saddr));\n-    saddr.sin_family = AF_INET;\n-    saddr.sin_addr.s_addr = htonl(INADDR_ANY);\n-    saddr.sin_port = htons(0);\n-\n-    rv = bind(sd, (struct sockaddr*)&saddr, sizeof(saddr));\n-    PR_ASSERT(rv == 0);\n-    saddr_len = sizeof(saddr);\n-    rv = getsockname(sd, (struct sockaddr*)&saddr, &saddr_len);\n-    PR_ASSERT(rv == 0);\n-    listenPort3 = ntohs(saddr.sin_port);\n-\n-    rv = listen(sd, 5);\n-    PR_ASSERT(rv == 0);\n-    pds[npds].fd = socket_poll_fd = PR_CreateSocketPollFd(sd);\n-    PR_ASSERT(pds[npds].fd);\n-    pds[npds].in_flags = PR_POLL_READ;\n-    npds++;\n+  if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    exit(1);\n+  }\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    exit(1);\n+  }\n+  if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    exit(1);\n+  }\n+  listenPort2 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    exit(1);\n+  }\n+  /* Set up the poll descriptor array */\n+  pds = pds0;\n+  other_pds = pds1;\n+  memset(pds, 0, sizeof(pds));\n+  npds = 0;\n+  pds[npds].fd = listenSock1;\n+  pds[npds].in_flags = PR_POLL_READ;\n+  npds++;\n+  pds[npds].fd = listenSock2;\n+  pds[npds].in_flags = PR_POLL_READ;\n+  npds++;\n+\n+  sd = socket(AF_INET, SOCK_STREAM, 0);\n+  PR_ASSERT(sd >= 0);\n+  memset((char*)&saddr, 0, sizeof(saddr));\n+  saddr.sin_family = AF_INET;\n+  saddr.sin_addr.s_addr = htonl(INADDR_ANY);\n+  saddr.sin_port = htons(0);\n+\n+  rv = bind(sd, (struct sockaddr*)&saddr, sizeof(saddr));\n+  PR_ASSERT(rv == 0);\n+  saddr_len = sizeof(saddr);\n+  rv = getsockname(sd, (struct sockaddr*)&saddr, &saddr_len);\n+  PR_ASSERT(rv == 0);\n+  listenPort3 = ntohs(saddr.sin_port);\n+\n+  rv = listen(sd, 5);\n+  PR_ASSERT(rv == 0);\n+  pds[npds].fd = socket_poll_fd = PR_CreateSocketPollFd(sd);\n+  PR_ASSERT(pds[npds].fd);\n+  pds[npds].in_flags = PR_POLL_READ;\n+  npds++;\n+  PR_snprintf(buf, sizeof(buf),\n+              \"The server thread is listening on ports %hu, %hu and %hu\\n\\n\",\n+              listenPort1, listenPort2, listenPort3);\n+  printf(\"%s\", buf);\n+\n+  /* Testing timeout */\n+  printf(\"PR_Poll should time out in 5 seconds\\n\");\n+  retVal = PR_Poll(pds, npds, PR_SecondsToInterval(5));\n+  if (retVal != 0) {\n     PR_snprintf(buf, sizeof(buf),\n-                \"The server thread is listening on ports %hu, %hu and %hu\\n\\n\",\n-                listenPort1, listenPort2, listenPort3);\n-    printf(\"%s\", buf);\n-\n-    /* Testing timeout */\n-    printf(\"PR_Poll should time out in 5 seconds\\n\");\n-    retVal = PR_Poll(pds, npds, PR_SecondsToInterval(5));\n-    if (retVal != 0) {\n-        PR_snprintf(buf, sizeof(buf),\n-                    \"PR_Poll should time out and return 0, but it returns %ld\\n\",\n-                    retVal);\n-        fprintf(stderr, \"%s\", buf);\n-        exit(1);\n-    }\n-    printf(\"PR_Poll timed out.  Test passed.\\n\\n\");\n+                \"PR_Poll should time out and return 0, but it returns %ld\\n\",\n+                retVal);\n+    fprintf(stderr, \"%s\", buf);\n+    exit(1);\n+  }\n+  printf(\"PR_Poll timed out.  Test passed.\\n\\n\");\n \n-    /* Testing bad fd */\n-    printf(\"PR_Poll should detect a bad file descriptor\\n\");\n-    if ((badFD = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a TCP socket\\n\");\n-        exit(1);\n-    }\n+  /* Testing bad fd */\n+  printf(\"PR_Poll should detect a bad file descriptor\\n\");\n+  if ((badFD = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a TCP socket\\n\");\n+    exit(1);\n+  }\n \n-    pds[npds].fd = badFD;\n-    pds[npds].in_flags = PR_POLL_READ;\n-    npds++;\n-    PR_Close(badFD); /* make the fd bad */\n-#if 0\n+  pds[npds].fd = badFD;\n+  pds[npds].in_flags = PR_POLL_READ;\n+  npds++;\n+  PR_Close(badFD); /* make the fd bad */\n+#  if 0\n     retVal = PR_Poll(pds, npds, PR_INTERVAL_NO_TIMEOUT);\n     if (retVal != 1 || (unsigned short) pds[2].out_flags != PR_POLL_NVAL) {\n         fprintf(stderr, \"Failed to detect the bad fd: \"\n@@ -195,152 +190,152 @@ main(int argc, char** argv)\n         exit(1);\n     }\n     printf(\"PR_Poll detected the bad fd.  Test passed.\\n\\n\");\n-#endif\n-    npds--;\n+#  endif\n+  npds--;\n+\n+  clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n+                                 (void*)listenPort1, PR_PRIORITY_NORMAL,\n+                                 PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  if (clientThread == NULL) {\n+    fprintf(stderr, \"can't create thread\\n\");\n+    exit(1);\n+  }\n \n-    clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n-                                   (void*)listenPort1, PR_PRIORITY_NORMAL,\n-                                   PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    if (clientThread == NULL) {\n-        fprintf(stderr, \"can't create thread\\n\");\n-        exit(1);\n-    }\n+  clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n+                                 (void*)listenPort2, PR_PRIORITY_NORMAL,\n+                                 PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  if (clientThread == NULL) {\n+    fprintf(stderr, \"can't create thread\\n\");\n+    exit(1);\n+  }\n \n-    clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n-                                   (void*)listenPort2, PR_PRIORITY_NORMAL,\n-                                   PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    if (clientThread == NULL) {\n-        fprintf(stderr, \"can't create thread\\n\");\n-        exit(1);\n-    }\n+  clientThread = PR_CreateThread(\n+      PR_USER_THREAD, clientThreadFunc, (void*)listenPort3, PR_PRIORITY_NORMAL,\n+      PR_GLOBAL_BOUND_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  if (clientThread == NULL) {\n+    fprintf(stderr, \"can't create thread\\n\");\n+    exit(1);\n+  }\n \n-    clientThread = PR_CreateThread(\n-        PR_USER_THREAD, clientThreadFunc, (void*)listenPort3, PR_PRIORITY_NORMAL,\n-        PR_GLOBAL_BOUND_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    if (clientThread == NULL) {\n-        fprintf(stderr, \"can't create thread\\n\");\n-        exit(1);\n+  printf(\"Three client threads are created.  Each of them will\\n\");\n+  printf(\"send data to one of the three ports the server is listening on.\\n\");\n+  printf(\"The data they send is the port number.  Each of them send\\n\");\n+  printf(\"the data five times, so you should see ten lines below,\\n\");\n+  printf(\"interleaved in an arbitrary order.\\n\");\n+\n+  /* 30 events total */\n+  i = 0;\n+  while (i < 30) {\n+    PRPollDesc* tmp;\n+    int nextIndex;\n+    int nEvents = 0;\n+\n+    retVal = PR_Poll(pds, npds, PR_INTERVAL_NO_TIMEOUT);\n+    PR_ASSERT(retVal != 0); /* no timeout */\n+    if (retVal == -1) {\n+      fprintf(stderr, \"PR_Poll failed\\n\");\n+      exit(1);\n     }\n \n-    printf(\"Three client threads are created.  Each of them will\\n\");\n-    printf(\"send data to one of the three ports the server is listening on.\\n\");\n-    printf(\"The data they send is the port number.  Each of them send\\n\");\n-    printf(\"the data five times, so you should see ten lines below,\\n\");\n-    printf(\"interleaved in an arbitrary order.\\n\");\n-\n-    /* 30 events total */\n-    i = 0;\n-    while (i < 30) {\n-        PRPollDesc* tmp;\n-        int nextIndex;\n-        int nEvents = 0;\n-\n-        retVal = PR_Poll(pds, npds, PR_INTERVAL_NO_TIMEOUT);\n-        PR_ASSERT(retVal != 0); /* no timeout */\n-        if (retVal == -1) {\n-            fprintf(stderr, \"PR_Poll failed\\n\");\n+    nextIndex = 3;\n+    /* the three listening sockets */\n+    for (j = 0; j < 3; j++) {\n+      other_pds[j] = pds[j];\n+      PR_ASSERT((pds[j].out_flags & PR_POLL_WRITE) == 0 &&\n+                (pds[j].out_flags & PR_POLL_EXCEPT) == 0);\n+      if (pds[j].out_flags & PR_POLL_READ) {\n+        PRFileDesc* sock;\n+\n+        nEvents++;\n+        if (j == 2) {\n+          PROsfd newsd;\n+          newsd = accept(PR_FileDesc2NativeHandle(pds[j].fd), NULL, 0);\n+          if (newsd == -1) {\n+            fprintf(stderr, \"accept() failed\\n\");\n             exit(1);\n+          }\n+          other_pds[nextIndex].fd = PR_CreateSocketPollFd(newsd);\n+          PR_ASSERT(other_pds[nextIndex].fd);\n+          other_pds[nextIndex].in_flags = PR_POLL_READ;\n+        } else {\n+          sock = PR_Accept(pds[j].fd, NULL, PR_INTERVAL_NO_TIMEOUT);\n+          if (sock == NULL) {\n+            fprintf(stderr, \"PR_Accept() failed\\n\");\n+            exit(1);\n+          }\n+          other_pds[nextIndex].fd = sock;\n+          other_pds[nextIndex].in_flags = PR_POLL_READ;\n         }\n+        nextIndex++;\n+      } else if (pds[j].out_flags & PR_POLL_ERR) {\n+        fprintf(stderr, \"PR_Poll() indicates that an fd has error\\n\");\n+        exit(1);\n+      } else if (pds[j].out_flags & PR_POLL_NVAL) {\n+        fprintf(stderr, \"PR_Poll() indicates that fd %d is invalid\\n\",\n+                PR_FileDesc2NativeHandle(pds[j].fd));\n+        exit(1);\n+      }\n+    }\n \n-        nextIndex = 3;\n-        /* the three listening sockets */\n-        for (j = 0; j < 3; j++) {\n-            other_pds[j] = pds[j];\n-            PR_ASSERT((pds[j].out_flags & PR_POLL_WRITE) == 0 &&\n-                      (pds[j].out_flags & PR_POLL_EXCEPT) == 0);\n-            if (pds[j].out_flags & PR_POLL_READ) {\n-                PRFileDesc* sock;\n-\n-                nEvents++;\n-                if (j == 2) {\n-                    PROsfd newsd;\n-                    newsd = accept(PR_FileDesc2NativeHandle(pds[j].fd), NULL, 0);\n-                    if (newsd == -1) {\n-                        fprintf(stderr, \"accept() failed\\n\");\n-                        exit(1);\n-                    }\n-                    other_pds[nextIndex].fd = PR_CreateSocketPollFd(newsd);\n-                    PR_ASSERT(other_pds[nextIndex].fd);\n-                    other_pds[nextIndex].in_flags = PR_POLL_READ;\n-                } else {\n-                    sock = PR_Accept(pds[j].fd, NULL, PR_INTERVAL_NO_TIMEOUT);\n-                    if (sock == NULL) {\n-                        fprintf(stderr, \"PR_Accept() failed\\n\");\n-                        exit(1);\n-                    }\n-                    other_pds[nextIndex].fd = sock;\n-                    other_pds[nextIndex].in_flags = PR_POLL_READ;\n-                }\n-                nextIndex++;\n-            } else if (pds[j].out_flags & PR_POLL_ERR) {\n-                fprintf(stderr, \"PR_Poll() indicates that an fd has error\\n\");\n-                exit(1);\n-            } else if (pds[j].out_flags & PR_POLL_NVAL) {\n-                fprintf(stderr, \"PR_Poll() indicates that fd %d is invalid\\n\",\n-                        PR_FileDesc2NativeHandle(pds[j].fd));\n-                exit(1);\n-            }\n-        }\n-\n-        for (j = 3; j < npds; j++) {\n-            PR_ASSERT((pds[j].out_flags & PR_POLL_WRITE) == 0 &&\n-                      (pds[j].out_flags & PR_POLL_EXCEPT) == 0);\n-            if (pds[j].out_flags & PR_POLL_READ) {\n-                PRInt32 nBytes;\n-\n-                nEvents++;\n-                /* XXX: This call is a hack and should be fixed */\n-                if (PR_GetDescType(pds[j].fd) == (PRDescType)0) {\n-                    nBytes =\n-                        recv(PR_FileDesc2NativeHandle(pds[j].fd), buf, sizeof(buf), 0);\n-                    if (nBytes == -1) {\n-                        fprintf(stderr, \"recv() failed\\n\");\n-                        exit(1);\n-                    }\n-                    printf(\"Server read %d bytes from native fd %d\\n\", nBytes,\n-                           PR_FileDesc2NativeHandle(pds[j].fd));\n-#ifdef WIN32\n-                    closesocket((SOCKET)PR_FileDesc2NativeHandle(pds[j].fd));\n-#else\n-                    close(PR_FileDesc2NativeHandle(pds[j].fd));\n-#endif\n-                    PR_DestroySocketPollFd(pds[j].fd);\n-                } else {\n-                    nBytes = PR_Read(pds[j].fd, buf, sizeof(buf));\n-                    if (nBytes == -1) {\n-                        fprintf(stderr, \"PR_Read() failed\\n\");\n-                        exit(1);\n-                    }\n-                    PR_Close(pds[j].fd);\n-                }\n-                /* Just to be safe */\n-                buf[BUF_SIZE - 1] = '\\0';\n-                printf(\"The server received \\\"%s\\\" from a client\\n\", buf);\n-            } else if (pds[j].out_flags & PR_POLL_ERR) {\n-                fprintf(stderr, \"PR_Poll() indicates that an fd has error\\n\");\n-                exit(1);\n-            } else if (pds[j].out_flags & PR_POLL_NVAL) {\n-                fprintf(stderr, \"PR_Poll() indicates that an fd is invalid\\n\");\n-                exit(1);\n-            } else {\n-                other_pds[nextIndex] = pds[j];\n-                nextIndex++;\n-            }\n+    for (j = 3; j < npds; j++) {\n+      PR_ASSERT((pds[j].out_flags & PR_POLL_WRITE) == 0 &&\n+                (pds[j].out_flags & PR_POLL_EXCEPT) == 0);\n+      if (pds[j].out_flags & PR_POLL_READ) {\n+        PRInt32 nBytes;\n+\n+        nEvents++;\n+        /* XXX: This call is a hack and should be fixed */\n+        if (PR_GetDescType(pds[j].fd) == (PRDescType)0) {\n+          nBytes =\n+              recv(PR_FileDesc2NativeHandle(pds[j].fd), buf, sizeof(buf), 0);\n+          if (nBytes == -1) {\n+            fprintf(stderr, \"recv() failed\\n\");\n+            exit(1);\n+          }\n+          printf(\"Server read %d bytes from native fd %d\\n\", nBytes,\n+                 PR_FileDesc2NativeHandle(pds[j].fd));\n+#  ifdef WIN32\n+          closesocket((SOCKET)PR_FileDesc2NativeHandle(pds[j].fd));\n+#  else\n+          close(PR_FileDesc2NativeHandle(pds[j].fd));\n+#  endif\n+          PR_DestroySocketPollFd(pds[j].fd);\n+        } else {\n+          nBytes = PR_Read(pds[j].fd, buf, sizeof(buf));\n+          if (nBytes == -1) {\n+            fprintf(stderr, \"PR_Read() failed\\n\");\n+            exit(1);\n+          }\n+          PR_Close(pds[j].fd);\n         }\n-\n-        PR_ASSERT(retVal == nEvents);\n-        /* swap */\n-        tmp = pds;\n-        pds = other_pds;\n-        other_pds = tmp;\n-        npds = nextIndex;\n-        i += nEvents;\n+        /* Just to be safe */\n+        buf[BUF_SIZE - 1] = '\\0';\n+        printf(\"The server received \\\"%s\\\" from a client\\n\", buf);\n+      } else if (pds[j].out_flags & PR_POLL_ERR) {\n+        fprintf(stderr, \"PR_Poll() indicates that an fd has error\\n\");\n+        exit(1);\n+      } else if (pds[j].out_flags & PR_POLL_NVAL) {\n+        fprintf(stderr, \"PR_Poll() indicates that an fd is invalid\\n\");\n+        exit(1);\n+      } else {\n+        other_pds[nextIndex] = pds[j];\n+        nextIndex++;\n+      }\n     }\n-    PR_DestroySocketPollFd(socket_poll_fd);\n \n-    printf(\"All tests finished\\n\");\n-    PR_Cleanup();\n-    return 0;\n+    PR_ASSERT(retVal == nEvents);\n+    /* swap */\n+    tmp = pds;\n+    pds = other_pds;\n+    other_pds = tmp;\n+    npds = nextIndex;\n+    i += nEvents;\n+  }\n+  PR_DestroySocketPollFd(socket_poll_fd);\n+\n+  printf(\"All tests finished\\n\");\n+  PR_Cleanup();\n+  return 0;\n }\n \n #endif /* ifdef WINCE */\ndiff --git a/nspr/pr/tests/prpollml.c b/nspr/pr/tests/prpollml.c\nindex 531aa5f..621e250 100644\n--- a/nspr/pr/tests/prpollml.c\n+++ b/nspr/pr/tests/prpollml.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -14,126 +15,118 @@\n #include <stdlib.h>\n #include <string.h>\n \n-#define POLL_DESC_COUNT                    \\\n-    256 /* This should be greater than the \\\n-         * STACK_POLL_DESC_COUNT macro in  \\\n-         * ptio.c to cause syspoll_list to \\\n-         * be created. */\n+#define POLL_DESC_COUNT                  \\\n+  256 /* This should be greater than the \\\n+       * STACK_POLL_DESC_COUNT macro in  \\\n+       * ptio.c to cause syspoll_list to \\\n+       * be created. */\n \n static PRPollDesc pd[POLL_DESC_COUNT];\n \n-static void\n-Test(void)\n-{\n-    int i;\n-    PRInt32 rv;\n-    PRIntervalTime timeout;\n+static void Test(void) {\n+  int i;\n+  PRInt32 rv;\n+  PRIntervalTime timeout;\n \n-    timeout = PR_MillisecondsToInterval(10);\n-    /* cause syspoll_list to grow */\n-    for (i = 1; i <= POLL_DESC_COUNT; i++) {\n-        rv = PR_Poll(pd, i, timeout);\n-        if (rv != 0) {\n-            fprintf(stderr, \"PR_Poll should time out but returns %d (%d, %d)\\n\",\n-                    (int)rv, (int)PR_GetError(), (int)PR_GetOSError());\n-            exit(1);\n-        }\n+  timeout = PR_MillisecondsToInterval(10);\n+  /* cause syspoll_list to grow */\n+  for (i = 1; i <= POLL_DESC_COUNT; i++) {\n+    rv = PR_Poll(pd, i, timeout);\n+    if (rv != 0) {\n+      fprintf(stderr, \"PR_Poll should time out but returns %d (%d, %d)\\n\",\n+              (int)rv, (int)PR_GetError(), (int)PR_GetOSError());\n+      exit(1);\n     }\n-    /* syspoll_list should be large enough for all these */\n-    for (i = POLL_DESC_COUNT; i >= 1; i--) {\n-        rv = PR_Poll(pd, i, timeout);\n-        if (rv != 0) {\n-            fprintf(stderr, \"PR_Poll should time out but returns %d\\n\", (int)rv);\n-            exit(1);\n-        }\n+  }\n+  /* syspoll_list should be large enough for all these */\n+  for (i = POLL_DESC_COUNT; i >= 1; i--) {\n+    rv = PR_Poll(pd, i, timeout);\n+    if (rv != 0) {\n+      fprintf(stderr, \"PR_Poll should time out but returns %d\\n\", (int)rv);\n+      exit(1);\n     }\n+  }\n }\n \n-static void\n-ThreadFunc(void* arg)\n-{\n-    Test();\n-}\n-\n-int\n-main(int argc, char** argv)\n-{\n-    int i;\n-    PRThread* thread;\n-    PRFileDesc* sock;\n-    PRNetAddr addr;\n-\n-    memset(&addr, 0, sizeof(addr));\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.port = PR_htons(0);\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    for (i = 0; i < POLL_DESC_COUNT; i++) {\n-        sock = PR_NewTCPSocket();\n-        if (sock == NULL) {\n-            fprintf(stderr, \"PR_NewTCPSocket failed (%d, %d)\\n\", (int)PR_GetError(),\n-                    (int)PR_GetOSError());\n-            fprintf(stderr,\n-                    \"Ensure the per process file descriptor limit \"\n-                    \"is greater than %d.\",\n-                    POLL_DESC_COUNT);\n-            exit(1);\n-        }\n-        if (PR_Bind(sock, &addr) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_Bind failed (%d, %d)\\n\", (int)PR_GetError(),\n-                    (int)PR_GetOSError());\n-            exit(1);\n-        }\n-        if (PR_Listen(sock, 5) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_Listen failed (%d, %d)\\n\", (int)PR_GetError(),\n-                    (int)PR_GetOSError());\n-            exit(1);\n-        }\n+static void ThreadFunc(void* arg) { Test(); }\n \n-        pd[i].fd = sock;\n-        pd[i].in_flags = PR_POLL_READ;\n-    }\n-\n-    /* first run the test on the primordial thread */\n-    Test();\n+int main(int argc, char** argv) {\n+  int i;\n+  PRThread* thread;\n+  PRFileDesc* sock;\n+  PRNetAddr addr;\n \n-    /* then run the test on all three kinds of threads */\n-    thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, NULL, PR_PRIORITY_NORMAL,\n-                             PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (NULL == thread) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_JoinThread(thread) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n+  memset(&addr, 0, sizeof(addr));\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.port = PR_htons(0);\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  for (i = 0; i < POLL_DESC_COUNT; i++) {\n+    sock = PR_NewTCPSocket();\n+    if (sock == NULL) {\n+      fprintf(stderr, \"PR_NewTCPSocket failed (%d, %d)\\n\", (int)PR_GetError(),\n+              (int)PR_GetOSError());\n+      fprintf(stderr,\n+              \"Ensure the per process file descriptor limit \"\n+              \"is greater than %d.\",\n+              POLL_DESC_COUNT);\n+      exit(1);\n     }\n-    thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, NULL, PR_PRIORITY_NORMAL,\n-                             PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (NULL == thread) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n+    if (PR_Bind(sock, &addr) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_Bind failed (%d, %d)\\n\", (int)PR_GetError(),\n+              (int)PR_GetOSError());\n+      exit(1);\n     }\n-    if (PR_JoinThread(thread) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n+    if (PR_Listen(sock, 5) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_Listen failed (%d, %d)\\n\", (int)PR_GetError(),\n+              (int)PR_GetOSError());\n+      exit(1);\n     }\n-    thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, NULL, PR_PRIORITY_NORMAL,\n-                             PR_GLOBAL_BOUND_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (NULL == thread) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_JoinThread(thread) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n-    }\n-    for (i = 0; i < POLL_DESC_COUNT; i++) {\n-        if (PR_Close(pd[i].fd) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_Close failed\\n\");\n-            exit(1);\n-        }\n+\n+    pd[i].fd = sock;\n+    pd[i].in_flags = PR_POLL_READ;\n+  }\n+\n+  /* first run the test on the primordial thread */\n+  Test();\n+\n+  /* then run the test on all three kinds of threads */\n+  thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, NULL, PR_PRIORITY_NORMAL,\n+                           PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (NULL == thread) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_JoinThread(thread) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+  thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, NULL, PR_PRIORITY_NORMAL,\n+                           PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (NULL == thread) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_JoinThread(thread) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+  thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, NULL, PR_PRIORITY_NORMAL,\n+                           PR_GLOBAL_BOUND_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (NULL == thread) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_JoinThread(thread) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+  for (i = 0; i < POLL_DESC_COUNT; i++) {\n+    if (PR_Close(pd[i].fd) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_Close failed\\n\");\n+      exit(1);\n     }\n-    PR_Cleanup();\n-    printf(\"PASS\\n\");\n-    return 0;\n+  }\n+  PR_Cleanup();\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/prselect.c b/nspr/pr/tests/prselect.c\nindex cf0c199..835eaed 100644\n--- a/nspr/pr/tests/prselect.c\n+++ b/nspr/pr/tests/prselect.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -54,308 +55,303 @@\n **\n ***********************************************************************/\n \n-static Test_Result(int result)\n-{\n-    if (result == PASS) {\n-        printf(\"PASS\\n\");\n-    } else {\n-        printf(\"FAIL\\n\");\n-    }\n+static Test_Result(int result) {\n+  if (result == PASS) {\n+    printf(\"PASS\\n\");\n+  } else {\n+    printf(\"FAIL\\n\");\n+  }\n }\n \n-static void\n-clientThreadFunc(void* arg)\n-{\n-    PRUint16 port = (PRUint16)arg;\n-    PRFileDesc* sock;\n-    PRNetAddr addr;\n-    char buf[128];\n-    int i;\n-\n-    addr.inet.family = AF_INET;\n-    addr.inet.port = PR_htons(port);\n-    addr.inet.ip = PR_htonl(INADDR_LOOPBACK);\n-    PR_snprintf(buf, sizeof(buf), \"%hu\", port);\n-\n-    for (i = 0; i < 5; i++) {\n-        sock = PR_NewTCPSocket();\n-        PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT);\n-        PR_Write(sock, buf, sizeof(buf));\n-        PR_Close(sock);\n-    }\n+static void clientThreadFunc(void* arg) {\n+  PRUint16 port = (PRUint16)arg;\n+  PRFileDesc* sock;\n+  PRNetAddr addr;\n+  char buf[128];\n+  int i;\n+\n+  addr.inet.family = AF_INET;\n+  addr.inet.port = PR_htons(port);\n+  addr.inet.ip = PR_htonl(INADDR_LOOPBACK);\n+  PR_snprintf(buf, sizeof(buf), \"%hu\", port);\n+\n+  for (i = 0; i < 5; i++) {\n+    sock = PR_NewTCPSocket();\n+    PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT);\n+    PR_Write(sock, buf, sizeof(buf));\n+    PR_Close(sock);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc *listenSock1, *listenSock2;\n-    PRFileDesc* badFD;\n-    PRFileDesc *fds0[10], *fds1[10], **fds, **other_fds;\n-    PRIntn nfds;\n-    PRUint16 listenPort1, listenPort2;\n-    PRNetAddr addr;\n-    PR_fd_set readFdSet;\n-    char buf[128];\n-    PRThread* clientThread;\n-    PRInt32 retVal;\n-    PRIntn i, j;\n-\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  PRFileDesc *listenSock1, *listenSock2;\n+  PRFileDesc* badFD;\n+  PRFileDesc *fds0[10], *fds1[10], **fds, **other_fds;\n+  PRIntn nfds;\n+  PRUint16 listenPort1, listenPort2;\n+  PRNetAddr addr;\n+  PR_fd_set readFdSet;\n+  char buf[128];\n+  PRThread* clientThread;\n+  PRInt32 retVal;\n+  PRIntn i, j;\n+\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    /* main test */\n+  /* main test */\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    if (debug_mode) {\n-        printf(\"This program tests PR_Select with sockets.  Timeout, error\\n\");\n-        printf(\"reporting, and normal operation are tested.\\n\\n\");\n-    }\n+  if (debug_mode) {\n+    printf(\"This program tests PR_Select with sockets.  Timeout, error\\n\");\n+    printf(\"reporting, and normal operation are tested.\\n\\n\");\n+  }\n \n-    /* Create two listening sockets */\n-    if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        if (!debug_mode) {\n-            Test_Result(FAIL);\n-        }\n-        exit(1);\n+  /* Create two listening sockets */\n+  if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    if (!debug_mode) {\n+      Test_Result(FAIL);\n     }\n-    addr.inet.family = AF_INET;\n-    addr.inet.ip = PR_htonl(INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        if (!debug_mode) {\n-            Test_Result(FAIL);\n-        }\n-        exit(1);\n+    exit(1);\n+  }\n+  addr.inet.family = AF_INET;\n+  addr.inet.ip = PR_htonl(INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    if (!debug_mode) {\n+      Test_Result(FAIL);\n     }\n-    if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        if (!debug_mode) {\n-            Test_Result(FAIL);\n-        }\n-        exit(1);\n+    exit(1);\n+  }\n+  if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    if (!debug_mode) {\n+      Test_Result(FAIL);\n     }\n-    listenPort1 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        if (!debug_mode) {\n-            Test_Result(FAIL);\n-        }\n-        exit(1);\n+    exit(1);\n+  }\n+  listenPort1 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    if (!debug_mode) {\n+      Test_Result(FAIL);\n     }\n+    exit(1);\n+  }\n \n-    if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        if (!debug_mode) {\n-            Test_Result(FAIL);\n-        }\n-        exit(1);\n+  if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    if (!debug_mode) {\n+      Test_Result(FAIL);\n     }\n-    addr.inet.family = AF_INET;\n-    addr.inet.ip = PR_htonl(INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        if (!debug_mode) {\n-            Test_Result(FAIL);\n-        }\n-        exit(1);\n+    exit(1);\n+  }\n+  addr.inet.family = AF_INET;\n+  addr.inet.ip = PR_htonl(INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    if (!debug_mode) {\n+      Test_Result(FAIL);\n     }\n-    if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        if (!debug_mode) {\n-            Test_Result(FAIL);\n-        }\n-        exit(1);\n+    exit(1);\n+  }\n+  if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    if (!debug_mode) {\n+      Test_Result(FAIL);\n     }\n-    listenPort2 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        if (!debug_mode) {\n-            Test_Result(FAIL);\n-        }\n-        exit(1);\n+    exit(1);\n+  }\n+  listenPort2 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    if (!debug_mode) {\n+      Test_Result(FAIL);\n     }\n+    exit(1);\n+  }\n+  PR_snprintf(buf, sizeof(buf),\n+              \"The server thread is listening on ports %hu and %hu\\n\\n\",\n+              listenPort1, listenPort2);\n+  printf(\"%s\", buf);\n+\n+  /* Set up the fd set */\n+  PR_FD_ZERO(&readFdSet);\n+  PR_FD_SET(listenSock1, &readFdSet);\n+  PR_FD_SET(listenSock2, &readFdSet);\n+\n+  /* Testing timeout */\n+  if (debug_mode) {\n+    printf(\"PR_Select should time out in 5 seconds\\n\");\n+  }\n+  retVal = PR_Select(0 /* unused */, &readFdSet, NULL, NULL,\n+                     PR_SecondsToInterval(5));\n+  if (retVal != 0) {\n     PR_snprintf(buf, sizeof(buf),\n-                \"The server thread is listening on ports %hu and %hu\\n\\n\",\n-                listenPort1, listenPort2);\n-    printf(\"%s\", buf);\n-\n-    /* Set up the fd set */\n-    PR_FD_ZERO(&readFdSet);\n-    PR_FD_SET(listenSock1, &readFdSet);\n-    PR_FD_SET(listenSock2, &readFdSet);\n-\n-    /* Testing timeout */\n-    if (debug_mode) {\n-        printf(\"PR_Select should time out in 5 seconds\\n\");\n-    }\n-    retVal = PR_Select(0 /* unused */, &readFdSet, NULL, NULL,\n-                       PR_SecondsToInterval(5));\n-    if (retVal != 0) {\n-        PR_snprintf(buf, sizeof(buf),\n-                    \"PR_Select should time out and return 0, but it returns %ld\\n\",\n-                    retVal);\n-        fprintf(stderr, \"%s\", buf);\n-        if (retVal == -1) {\n-            fprintf(stderr, \"Error %d, oserror %d\\n\", PR_GetError(), PR_GetOSError());\n-            if (!debug_mode) {\n-                Test_Result(FAIL);\n-            }\n-        }\n-        exit(1);\n-    }\n-    if (debug_mode) {\n-        printf(\"PR_Select timed out.  Test passed.\\n\\n\");\n-    } else {\n-        Test_Result(PASS);\n-    }\n-\n-    /* Testing bad fd */\n-    printf(\"PR_Select should detect a bad file descriptor\\n\");\n-    if ((badFD = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a TCP socket\\n\");\n-        exit(1);\n-    }\n-\n-    PR_FD_SET(listenSock1, &readFdSet);\n-    PR_FD_SET(listenSock2, &readFdSet);\n-    PR_FD_SET(badFD, &readFdSet);\n-    PR_Close(badFD); /* make the fd bad */\n-    retVal =\n-        PR_Select(0 /* unused */, &readFdSet, NULL, NULL, PR_INTERVAL_NO_TIMEOUT);\n-    if (retVal != -1 || PR_GetError() != PR_BAD_DESCRIPTOR_ERROR) {\n-        fprintf(stderr,\n-                \"Failed to detect the bad fd: \"\n-                \"PR_Select returns %d\\n\",\n+                \"PR_Select should time out and return 0, but it returns %ld\\n\",\n                 retVal);\n-        if (retVal == -1) {\n-            fprintf(stderr, \"Error %d, oserror %d\\n\", PR_GetError(), PR_GetOSError());\n-        }\n-        exit(1);\n+    fprintf(stderr, \"%s\", buf);\n+    if (retVal == -1) {\n+      fprintf(stderr, \"Error %d, oserror %d\\n\", PR_GetError(), PR_GetOSError());\n+      if (!debug_mode) {\n+        Test_Result(FAIL);\n+      }\n     }\n-    printf(\"PR_Select detected a bad fd.  Test passed.\\n\\n\");\n-    PR_FD_CLR(badFD, &readFdSet);\n-\n-    clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n-                                   (void*)listenPort1, PR_PRIORITY_NORMAL,\n-                                   PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    if (clientThread == NULL) {\n-        fprintf(stderr, \"can't create thread\\n\");\n-        exit(1);\n+    exit(1);\n+  }\n+  if (debug_mode) {\n+    printf(\"PR_Select timed out.  Test passed.\\n\\n\");\n+  } else {\n+    Test_Result(PASS);\n+  }\n+\n+  /* Testing bad fd */\n+  printf(\"PR_Select should detect a bad file descriptor\\n\");\n+  if ((badFD = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a TCP socket\\n\");\n+    exit(1);\n+  }\n+\n+  PR_FD_SET(listenSock1, &readFdSet);\n+  PR_FD_SET(listenSock2, &readFdSet);\n+  PR_FD_SET(badFD, &readFdSet);\n+  PR_Close(badFD); /* make the fd bad */\n+  retVal =\n+      PR_Select(0 /* unused */, &readFdSet, NULL, NULL, PR_INTERVAL_NO_TIMEOUT);\n+  if (retVal != -1 || PR_GetError() != PR_BAD_DESCRIPTOR_ERROR) {\n+    fprintf(stderr,\n+            \"Failed to detect the bad fd: \"\n+            \"PR_Select returns %d\\n\",\n+            retVal);\n+    if (retVal == -1) {\n+      fprintf(stderr, \"Error %d, oserror %d\\n\", PR_GetError(), PR_GetOSError());\n     }\n+    exit(1);\n+  }\n+  printf(\"PR_Select detected a bad fd.  Test passed.\\n\\n\");\n+  PR_FD_CLR(badFD, &readFdSet);\n+\n+  clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n+                                 (void*)listenPort1, PR_PRIORITY_NORMAL,\n+                                 PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  if (clientThread == NULL) {\n+    fprintf(stderr, \"can't create thread\\n\");\n+    exit(1);\n+  }\n+\n+  clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n+                                 (void*)listenPort2, PR_PRIORITY_NORMAL,\n+                                 PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  if (clientThread == NULL) {\n+    fprintf(stderr, \"can't create thread\\n\");\n+    exit(1);\n+  }\n+\n+  printf(\"Two client threads are created.  Each of them will\\n\");\n+  printf(\"send data to one of the two ports the server is listening on.\\n\");\n+  printf(\"The data they send is the port number.  Each of them send\\n\");\n+  printf(\"the data five times, so you should see ten lines below,\\n\");\n+  printf(\"interleaved in an arbitrary order.\\n\");\n+\n+  /* set up the fd array */\n+  fds = fds0;\n+  other_fds = fds1;\n+  fds[0] = listenSock1;\n+  fds[1] = listenSock2;\n+  nfds = 2;\n+  PR_FD_SET(listenSock1, &readFdSet);\n+  PR_FD_SET(listenSock2, &readFdSet);\n+\n+  /* 20 events total */\n+  i = 0;\n+  while (i < 20) {\n+    PRFileDesc** tmp;\n+    int nextIndex;\n+    int nEvents = 0;\n \n-    clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n-                                   (void*)listenPort2, PR_PRIORITY_NORMAL,\n-                                   PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    if (clientThread == NULL) {\n-        fprintf(stderr, \"can't create thread\\n\");\n-        exit(1);\n+    retVal = PR_Select(0 /* unused */, &readFdSet, NULL, NULL,\n+                       PR_INTERVAL_NO_TIMEOUT);\n+    PR_ASSERT(retVal != 0); /* no timeout */\n+    if (retVal == -1) {\n+      fprintf(stderr, \"PR_Select failed (%d, %d)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      exit(1);\n     }\n \n-    printf(\"Two client threads are created.  Each of them will\\n\");\n-    printf(\"send data to one of the two ports the server is listening on.\\n\");\n-    printf(\"The data they send is the port number.  Each of them send\\n\");\n-    printf(\"the data five times, so you should see ten lines below,\\n\");\n-    printf(\"interleaved in an arbitrary order.\\n\");\n-\n-    /* set up the fd array */\n-    fds = fds0;\n-    other_fds = fds1;\n-    fds[0] = listenSock1;\n-    fds[1] = listenSock2;\n-    nfds = 2;\n-    PR_FD_SET(listenSock1, &readFdSet);\n-    PR_FD_SET(listenSock2, &readFdSet);\n-\n-    /* 20 events total */\n-    i = 0;\n-    while (i < 20) {\n-        PRFileDesc** tmp;\n-        int nextIndex;\n-        int nEvents = 0;\n-\n-        retVal = PR_Select(0 /* unused */, &readFdSet, NULL, NULL,\n-                           PR_INTERVAL_NO_TIMEOUT);\n-        PR_ASSERT(retVal != 0); /* no timeout */\n-        if (retVal == -1) {\n-            fprintf(stderr, \"PR_Select failed (%d, %d)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            exit(1);\n+    nextIndex = 2;\n+    /* the two listening sockets */\n+    for (j = 0; j < 2; j++) {\n+      other_fds[j] = fds[j];\n+      if (PR_FD_ISSET(fds[j], &readFdSet)) {\n+        PRFileDesc* sock;\n+\n+        nEvents++;\n+        sock = PR_Accept(fds[j], NULL, PR_INTERVAL_NO_TIMEOUT);\n+        if (sock == NULL) {\n+          fprintf(stderr, \"PR_Accept() failed\\n\");\n+          exit(1);\n         }\n+        other_fds[nextIndex] = sock;\n+        PR_FD_SET(sock, &readFdSet);\n+        nextIndex++;\n+      }\n+      PR_FD_SET(fds[j], &readFdSet);\n+    }\n \n-        nextIndex = 2;\n-        /* the two listening sockets */\n-        for (j = 0; j < 2; j++) {\n-            other_fds[j] = fds[j];\n-            if (PR_FD_ISSET(fds[j], &readFdSet)) {\n-                PRFileDesc* sock;\n-\n-                nEvents++;\n-                sock = PR_Accept(fds[j], NULL, PR_INTERVAL_NO_TIMEOUT);\n-                if (sock == NULL) {\n-                    fprintf(stderr, \"PR_Accept() failed\\n\");\n-                    exit(1);\n-                }\n-                other_fds[nextIndex] = sock;\n-                PR_FD_SET(sock, &readFdSet);\n-                nextIndex++;\n-            }\n-            PR_FD_SET(fds[j], &readFdSet);\n-        }\n+    for (j = 2; j < nfds; j++) {\n+      if (PR_FD_ISSET(fds[j], &readFdSet)) {\n+        PRInt32 nBytes;\n \n-        for (j = 2; j < nfds; j++) {\n-            if (PR_FD_ISSET(fds[j], &readFdSet)) {\n-                PRInt32 nBytes;\n-\n-                PR_FD_CLR(fds[j], &readFdSet);\n-                nEvents++;\n-                nBytes = PR_Read(fds[j], buf, sizeof(buf));\n-                if (nBytes == -1) {\n-                    fprintf(stderr, \"PR_Read() failed\\n\");\n-                    exit(1);\n-                }\n-                /* Just to be safe */\n-                buf[127] = '\\0';\n-                PR_Close(fds[j]);\n-                printf(\"The server received \\\"%s\\\" from a client\\n\", buf);\n-            } else {\n-                PR_FD_SET(fds[j], &readFdSet);\n-                other_fds[nextIndex] = fds[j];\n-                nextIndex++;\n-            }\n+        PR_FD_CLR(fds[j], &readFdSet);\n+        nEvents++;\n+        nBytes = PR_Read(fds[j], buf, sizeof(buf));\n+        if (nBytes == -1) {\n+          fprintf(stderr, \"PR_Read() failed\\n\");\n+          exit(1);\n         }\n-\n-        PR_ASSERT(retVal == nEvents);\n-        /* swap */\n-        tmp = fds;\n-        fds = other_fds;\n-        other_fds = tmp;\n-        nfds = nextIndex;\n-        i += nEvents;\n+        /* Just to be safe */\n+        buf[127] = '\\0';\n+        PR_Close(fds[j]);\n+        printf(\"The server received \\\"%s\\\" from a client\\n\", buf);\n+      } else {\n+        PR_FD_SET(fds[j], &readFdSet);\n+        other_fds[nextIndex] = fds[j];\n+        nextIndex++;\n+      }\n     }\n \n-    printf(\"All tests finished\\n\");\n-    PR_Cleanup();\n-    return 0;\n+    PR_ASSERT(retVal == nEvents);\n+    /* swap */\n+    tmp = fds;\n+    fds = other_fds;\n+    other_fds = tmp;\n+    nfds = nextIndex;\n+    i += nEvents;\n+  }\n+\n+  printf(\"All tests finished\\n\");\n+  PR_Cleanup();\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/prttools.h b/nspr/pr/tests/prttools.h\nindex 92d329e..e3cac5d 100644\n--- a/nspr/pr/tests/prttools.h\n+++ b/nspr/pr/tests/prttools.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,4 +8,4 @@\n #define PASS 1\n #define FAIL 0\n \n-PRIntn debug_mode = 0;\n+PRIntn debug_mode=0;\ndiff --git a/nspr/pr/tests/pushtop.c b/nspr/pr/tests/pushtop.c\nindex 2bc7811..56ae48c 100644\n--- a/nspr/pr/tests/pushtop.c\n+++ b/nspr/pr/tests/pushtop.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,63 +12,61 @@\n \n static PRIOMethods dummyMethods;\n \n-int\n-main()\n-{\n-    PRDescIdentity topId, middleId, bottomId;\n-    PRFileDesc *top, *middle, *bottom;\n-    PRFileDesc *fd;\n+int main() {\n+  PRDescIdentity topId, middleId, bottomId;\n+  PRFileDesc *top, *middle, *bottom;\n+  PRFileDesc* fd;\n \n-    topId = PR_GetUniqueIdentity(\"top\");\n-    middleId = PR_GetUniqueIdentity(\"middle\");\n-    bottomId = PR_GetUniqueIdentity(\"bottom\");\n+  topId = PR_GetUniqueIdentity(\"top\");\n+  middleId = PR_GetUniqueIdentity(\"middle\");\n+  bottomId = PR_GetUniqueIdentity(\"bottom\");\n \n-    top = PR_CreateIOLayerStub(topId, &dummyMethods);\n-    middle = PR_CreateIOLayerStub(middleId, &dummyMethods);\n-    bottom = PR_CreateIOLayerStub(bottomId, &dummyMethods);\n+  top = PR_CreateIOLayerStub(topId, &dummyMethods);\n+  middle = PR_CreateIOLayerStub(middleId, &dummyMethods);\n+  bottom = PR_CreateIOLayerStub(bottomId, &dummyMethods);\n \n-    fd = bottom;\n-    PR_PushIOLayer(fd, PR_TOP_IO_LAYER, middle);\n-    PR_PushIOLayer(fd, PR_TOP_IO_LAYER, top);\n+  fd = bottom;\n+  PR_PushIOLayer(fd, PR_TOP_IO_LAYER, middle);\n+  PR_PushIOLayer(fd, PR_TOP_IO_LAYER, top);\n \n-    top = fd;\n-    middle = top->lower;\n-    bottom = middle->lower;\n+  top = fd;\n+  middle = top->lower;\n+  bottom = middle->lower;\n \n-    /* Verify that the higher pointers are correct. */\n-    if (middle->higher != top) {\n-        fprintf(stderr, \"middle->higher is wrong\\n\");\n-        fprintf(stderr, \"FAILED\\n\");\n-        exit(1);\n-    }\n-    if (bottom->higher != middle) {\n-        fprintf(stderr, \"bottom->higher is wrong\\n\");\n-        fprintf(stderr, \"FAILED\\n\");\n-        exit(1);\n-    }\n+  /* Verify that the higher pointers are correct. */\n+  if (middle->higher != top) {\n+    fprintf(stderr, \"middle->higher is wrong\\n\");\n+    fprintf(stderr, \"FAILED\\n\");\n+    exit(1);\n+  }\n+  if (bottom->higher != middle) {\n+    fprintf(stderr, \"bottom->higher is wrong\\n\");\n+    fprintf(stderr, \"FAILED\\n\");\n+    exit(1);\n+  }\n \n-    top = PR_PopIOLayer(fd, topId);\n-    top->dtor(top);\n+  top = PR_PopIOLayer(fd, topId);\n+  top->dtor(top);\n \n-    middle = fd;\n-    bottom = middle->lower;\n+  middle = fd;\n+  bottom = middle->lower;\n \n-    /* Verify that the higher pointer is correct. */\n-    if (bottom->higher != middle) {\n-        fprintf(stderr, \"bottom->higher is wrong\\n\");\n-        fprintf(stderr, \"FAILED\\n\");\n-        exit(1);\n-    }\n+  /* Verify that the higher pointer is correct. */\n+  if (bottom->higher != middle) {\n+    fprintf(stderr, \"bottom->higher is wrong\\n\");\n+    fprintf(stderr, \"FAILED\\n\");\n+    exit(1);\n+  }\n \n-    middle = PR_PopIOLayer(fd, middleId);\n-    middle->dtor(middle);\n-    if (fd->identity != bottomId) {\n-        fprintf(stderr, \"The bottom layer has the wrong identity\\n\");\n-        fprintf(stderr, \"FAILED\\n\");\n-        exit(1);\n-    }\n-    fd->dtor(fd);\n+  middle = PR_PopIOLayer(fd, middleId);\n+  middle->dtor(middle);\n+  if (fd->identity != bottomId) {\n+    fprintf(stderr, \"The bottom layer has the wrong identity\\n\");\n+    fprintf(stderr, \"FAILED\\n\");\n+    exit(1);\n+  }\n+  fd->dtor(fd);\n \n-    printf(\"PASS\\n\");\n-    return 0;\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/randseed.c b/nspr/pr/tests/randseed.c\nindex 0b9a62a..32b4f47 100644\n--- a/nspr/pr/tests/randseed.c\n+++ b/nspr/pr/tests/randseed.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -38,98 +39,92 @@ PRIntn i;\n /*\n ** Emit help text for this test\n */\n-static void\n-Help(void)\n-{\n-    printf(\"Template: Help(): display your help message(s) here\");\n-    exit(1);\n+static void Help(void) {\n+  printf(\"Template: Help(): display your help message(s) here\");\n+  exit(1);\n } /* end Help() */\n \n-static void\n-PrintRand(void* buf, PRIntn size)\n-{\n-    PRUint32* rp = buf;\n-    PRIntn i;\n+static void PrintRand(void* buf, PRIntn size) {\n+  PRUint32* rp = buf;\n+  PRIntn i;\n \n-    printf(\"%4.4d--\\n\", size);\n-    while (size > 0) {\n-        switch (size) {\n-            case 1:\n-                printf(\"%2.2X\\n\", *(rp++));\n-                size -= 4;\n-                break;\n-            case 2:\n-                printf(\"%4.4X\\n\", *(rp++));\n-                size -= 4;\n-                break;\n-            case 3:\n-                printf(\"%6.6X\\n\", *(rp++));\n-                size -= 4;\n-                break;\n-            default:\n-                while (size >= 4) {\n-                    PRIntn i = 3;\n-                    do {\n-                        printf(\"%8.8X \", *(rp++));\n-                        size -= 4;\n-                    } while (i--);\n-                    i = 3;\n-                    printf(\"\\n\");\n-                }\n-                break;\n-        } /* end switch() */\n-    } /* end while() */\n+  printf(\"%4.4d--\\n\", size);\n+  while (size > 0) {\n+    switch (size) {\n+      case 1:\n+        printf(\"%2.2X\\n\", *(rp++));\n+        size -= 4;\n+        break;\n+      case 2:\n+        printf(\"%4.4X\\n\", *(rp++));\n+        size -= 4;\n+        break;\n+      case 3:\n+        printf(\"%6.6X\\n\", *(rp++));\n+        size -= 4;\n+        break;\n+      default:\n+        while (size >= 4) {\n+          PRIntn i = 3;\n+          do {\n+            printf(\"%8.8X \", *(rp++));\n+            size -= 4;\n+          } while (i--);\n+          i = 3;\n+          printf(\"\\n\");\n+        }\n+        break;\n+    } /* end switch() */\n+  } /* end while() */\n } /* end PrintRand() */\n \n-int\n-main(int argc, char** argv)\n-{\n-    {\n-        /*\n-        ** Get command line options\n-        */\n-        PLOptStatus os;\n-        PLOptState* opt = PL_CreateOptState(argc, argv, \"hdv\");\n+int main(int argc, char** argv) {\n+  {\n+    /*\n+    ** Get command line options\n+    */\n+    PLOptStatus os;\n+    PLOptState* opt = PL_CreateOptState(argc, argv, \"hdv\");\n \n-        while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-            if (PL_OPT_BAD == os) {\n-                continue;\n-            }\n-            switch (opt->option) {\n-                case 'd': /* debug */\n-                    debug = 1;\n-                    msgLevel = PR_LOG_ERROR;\n-                    break;\n-                case 'v': /* verbose mode */\n-                    msgLevel = PR_LOG_DEBUG;\n-                    break;\n-                case 'h': /* help message */\n-                    Help();\n-                    break;\n-                default:\n-                    break;\n-            }\n-        }\n-        PL_DestroyOptState(opt);\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+      if (PL_OPT_BAD == os) {\n+        continue;\n+      }\n+      switch (opt->option) {\n+        case 'd': /* debug */\n+          debug = 1;\n+          msgLevel = PR_LOG_ERROR;\n+          break;\n+        case 'v': /* verbose mode */\n+          msgLevel = PR_LOG_DEBUG;\n+          break;\n+        case 'h': /* help message */\n+          Help();\n+          break;\n+        default:\n+          break;\n+      }\n     }\n+    PL_DestroyOptState(opt);\n+  }\n \n-    lm = PR_NewLogModule(\"Test\"); /* Initialize logging */\n-    for (i = 0; i < optRandCount; i++) {\n-        memset(buf, 0, bufSize);\n-        rSize = PR_GetRandomNoise(buf, bufSize);\n-        if (!rSize) {\n-            fprintf(stderr, \"Not implemented\\n\");\n-            failed_already = PR_TRUE;\n-            break;\n-        }\n-        if (debug) {\n-            PrintRand(buf, rSize);\n-        }\n+  lm = PR_NewLogModule(\"Test\"); /* Initialize logging */\n+  for (i = 0; i < optRandCount; i++) {\n+    memset(buf, 0, bufSize);\n+    rSize = PR_GetRandomNoise(buf, bufSize);\n+    if (!rSize) {\n+      fprintf(stderr, \"Not implemented\\n\");\n+      failed_already = PR_TRUE;\n+      break;\n     }\n-\n     if (debug) {\n-        printf(\"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n+      PrintRand(buf, rSize);\n     }\n-    return ((failed_already == PR_TRUE) ? 1 : 0);\n+  }\n+\n+  if (debug) {\n+    printf(\"%s\\n\", (failed_already) ? \"FAIL\" : \"PASS\");\n+  }\n+  return ((failed_already == PR_TRUE) ? 1 : 0);\n } /* main() */\n /* end template.c */\ndiff --git a/nspr/pr/tests/ranfile.c b/nspr/pr/tests/ranfile.c\nindex 93c89e7..bf2abfe 100644\n--- a/nspr/pr/tests/ranfile.c\n+++ b/nspr/pr/tests/ranfile.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -44,28 +45,26 @@ static PRIntn debug_mode = 0;\n static PRIntn failed_already = 0;\n static PRThreadScope thread_scope = PR_LOCAL_THREAD;\n \n-typedef enum { sg_go,\n-               sg_stop,\n-               sg_done } Action;\n+typedef enum { sg_go, sg_stop, sg_done } Action;\n typedef enum {\n-    sg_okay,\n-    sg_open,\n-    sg_close,\n-    sg_delete,\n-    sg_write,\n-    sg_seek\n+  sg_okay,\n+  sg_open,\n+  sg_close,\n+  sg_delete,\n+  sg_write,\n+  sg_seek\n } Problem;\n \n typedef struct Hammer_s {\n-    PRLock* ml;\n-    PRCondVar* cv;\n-    PRUint32 id;\n-    PRUint32 limit;\n-    PRUint32 writes;\n-    PRThread* thread;\n-    PRIntervalTime timein;\n-    Action action;\n-    Problem problem;\n+  PRLock* ml;\n+  PRCondVar* cv;\n+  PRUint32 id;\n+  PRUint32 limit;\n+  PRUint32 writes;\n+  PRThread* thread;\n+  PRIntervalTime timein;\n+  Action action;\n+  Problem problem;\n } Hammer_t;\n \n #define DEFAULT_LIMIT 10\n@@ -95,17 +94,15 @@ static const char* programName = \"Random File\";\n **      of the product. Seed is then updated with the return value\n **      promoted to a float-64.\n ***********************************************************************/\n-static PRUint32\n-RandomNum(void)\n-{\n-    PRUint32 rv;\n-    PRUint64 shift;\n-    static PRFloat64 seed = 0x58a9382; /* Just make sure it isn't 0! */\n-    PRFloat64 random = seed * (PRFloat64)PR_IntervalNow();\n-    LL_USHR(shift, *((PRUint64*)&random), 16);\n-    LL_L2UI(rv, shift);\n-    seed = (PRFloat64)rv;\n-    return rv;\n+static PRUint32 RandomNum(void) {\n+  PRUint32 rv;\n+  PRUint64 shift;\n+  static PRFloat64 seed = 0x58a9382; /* Just make sure it isn't 0! */\n+  PRFloat64 random = seed * (PRFloat64)PR_IntervalNow();\n+  LL_USHR(shift, *((PRUint64*)&random), 16);\n+  LL_L2UI(rv, shift);\n+  seed = (PRFloat64)rv;\n+  return rv;\n } /* RandomNum */\n \n /***********************************************************************\n@@ -133,113 +130,111 @@ RandomNum(void)\n **      9) Repeat steps [1..8] until told to stop\n **     10) Notify complete and return\n ***********************************************************************/\n-static void PR_CALLBACK\n-Thread(void* arg)\n-{\n-    PRUint32 index;\n-    char filename[30];\n-    const char zero = 0;\n-    PRFileDesc* file = NULL;\n-    PRStatus rv = PR_SUCCESS;\n-    Hammer_t* cd = (Hammer_t*)arg;\n-\n-    (void)sprintf(filename, \"%ssg%04ld.dat\", baseName, cd->id);\n-\n-    if (debug_mode) {\n-        printf(\"Starting work on %s\\n\", filename);\n-    }\n-\n-    while (PR_TRUE) {\n-        PRUint32 bytes;\n-        PRUint32 minor = (RandomNum() % cd->limit) + 1;\n-        PRUint32 random = (RandomNum() % cd->limit) + 1;\n-        PRUint32 pages = (RandomNum() % cd->limit) + 10;\n-        while (minor-- > 0) {\n-            cd->problem = sg_okay;\n-            if (cd->action != sg_go) {\n-                goto finished;\n-            }\n-            cd->problem = sg_open;\n-            file = PR_Open(filename, PR_RDWR | PR_CREATE_FILE, 0666);\n-            if (file == NULL) {\n-                goto finished;\n-            }\n-            for (index = 0; index < pages; index++) {\n-                cd->problem = sg_okay;\n-                if (cd->action != sg_go) {\n-                    goto close;\n-                }\n-                cd->problem = sg_seek;\n-                bytes = PR_Seek(file, pageSize * index, PR_SEEK_SET);\n-                if (bytes != pageSize * index) {\n-                    goto close;\n-                }\n-                cd->problem = sg_write;\n-                bytes = PR_Write(file, &zero, sizeof(zero));\n-                if (bytes <= 0) {\n-                    goto close;\n-                }\n-                cd->writes += 1;\n-            }\n-            cd->problem = sg_close;\n-            rv = PR_Close(file);\n-            if (rv != PR_SUCCESS) {\n-                goto purge;\n-            }\n-\n-            cd->problem = sg_okay;\n-            if (cd->action != sg_go) {\n-                goto purge;\n-            }\n-\n-            cd->problem = sg_open;\n-            file = PR_Open(filename, PR_RDWR, 0666);\n-            for (index = 0; index < pages; index++) {\n-                cd->problem = sg_okay;\n-                if (cd->action != sg_go) {\n-                    goto close;\n-                }\n-                cd->problem = sg_seek;\n-                bytes = PR_Seek(file, pageSize * index, PR_SEEK_SET);\n-                if (bytes != pageSize * index) {\n-                    goto close;\n-                }\n-                cd->problem = sg_write;\n-                bytes = PR_Write(file, &zero, sizeof(zero));\n-                if (bytes <= 0) {\n-                    goto close;\n-                }\n-                cd->writes += 1;\n-                random = (random + 511) % pages;\n-            }\n-            cd->problem = sg_close;\n-            rv = PR_Close(file);\n-            if (rv != PR_SUCCESS) {\n-                goto purge;\n-            }\n-            cd->problem = sg_delete;\n-            rv = PR_Delete(filename);\n-            if (rv != PR_SUCCESS) {\n-                goto finished;\n-            }\n+static void PR_CALLBACK Thread(void* arg) {\n+  PRUint32 index;\n+  char filename[30];\n+  const char zero = 0;\n+  PRFileDesc* file = NULL;\n+  PRStatus rv = PR_SUCCESS;\n+  Hammer_t* cd = (Hammer_t*)arg;\n+\n+  (void)sprintf(filename, \"%ssg%04ld.dat\", baseName, cd->id);\n+\n+  if (debug_mode) {\n+    printf(\"Starting work on %s\\n\", filename);\n+  }\n+\n+  while (PR_TRUE) {\n+    PRUint32 bytes;\n+    PRUint32 minor = (RandomNum() % cd->limit) + 1;\n+    PRUint32 random = (RandomNum() % cd->limit) + 1;\n+    PRUint32 pages = (RandomNum() % cd->limit) + 10;\n+    while (minor-- > 0) {\n+      cd->problem = sg_okay;\n+      if (cd->action != sg_go) {\n+        goto finished;\n+      }\n+      cd->problem = sg_open;\n+      file = PR_Open(filename, PR_RDWR | PR_CREATE_FILE, 0666);\n+      if (file == NULL) {\n+        goto finished;\n+      }\n+      for (index = 0; index < pages; index++) {\n+        cd->problem = sg_okay;\n+        if (cd->action != sg_go) {\n+          goto close;\n+        }\n+        cd->problem = sg_seek;\n+        bytes = PR_Seek(file, pageSize * index, PR_SEEK_SET);\n+        if (bytes != pageSize * index) {\n+          goto close;\n+        }\n+        cd->problem = sg_write;\n+        bytes = PR_Write(file, &zero, sizeof(zero));\n+        if (bytes <= 0) {\n+          goto close;\n         }\n+        cd->writes += 1;\n+      }\n+      cd->problem = sg_close;\n+      rv = PR_Close(file);\n+      if (rv != PR_SUCCESS) {\n+        goto purge;\n+      }\n+\n+      cd->problem = sg_okay;\n+      if (cd->action != sg_go) {\n+        goto purge;\n+      }\n+\n+      cd->problem = sg_open;\n+      file = PR_Open(filename, PR_RDWR, 0666);\n+      for (index = 0; index < pages; index++) {\n+        cd->problem = sg_okay;\n+        if (cd->action != sg_go) {\n+          goto close;\n+        }\n+        cd->problem = sg_seek;\n+        bytes = PR_Seek(file, pageSize * index, PR_SEEK_SET);\n+        if (bytes != pageSize * index) {\n+          goto close;\n+        }\n+        cd->problem = sg_write;\n+        bytes = PR_Write(file, &zero, sizeof(zero));\n+        if (bytes <= 0) {\n+          goto close;\n+        }\n+        cd->writes += 1;\n+        random = (random + 511) % pages;\n+      }\n+      cd->problem = sg_close;\n+      rv = PR_Close(file);\n+      if (rv != PR_SUCCESS) {\n+        goto purge;\n+      }\n+      cd->problem = sg_delete;\n+      rv = PR_Delete(filename);\n+      if (rv != PR_SUCCESS) {\n+        goto finished;\n+      }\n     }\n+  }\n \n close:\n-    (void)PR_Close(file);\n+  (void)PR_Close(file);\n purge:\n-    (void)PR_Delete(filename);\n+  (void)PR_Delete(filename);\n finished:\n-    PR_Lock(cd->ml);\n-    cd->action = sg_done;\n-    PR_NotifyCondVar(cd->cv);\n-    PR_Unlock(cd->ml);\n+  PR_Lock(cd->ml);\n+  cd->action = sg_done;\n+  PR_NotifyCondVar(cd->cv);\n+  PR_Unlock(cd->ml);\n \n-    if (debug_mode) {\n-        printf(\"Ending work on %s\\n\", filename);\n-    }\n+  if (debug_mode) {\n+    printf(\"Ending work on %s\\n\", filename);\n+  }\n \n-    return;\n+  return;\n } /* Thread */\n \n static Hammer_t hammer[100];\n@@ -274,157 +269,155 @@ static PRCondVar* cv;\n **          Random File: Using loops = 2, threads = 10, limit = 57\n **          Random File: [min [avg] max] writes/sec average\n ***********************************************************************/\n-int\n-main(int argc, char** argv)\n-{\n-    PRLock* ml;\n-    PRUint32 id = 0;\n-    int active, poll;\n-    PRIntervalTime interleave;\n-    PRIntervalTime duration = 0;\n-    int limit = 0, loops = 0, threads = 0, times;\n-    PRUint32 writes, writesMin = 0x7fffffff, writesTot = 0, durationTot = 0,\n-                     writesMax = 0;\n-\n-    const char* where[] = { \"okay\", \"open\", \"close\", \"delete\", \"write\", \"seek\" };\n-\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"Gdl:t:i:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'G': /* global threads */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            case 'l': /* limiting number */\n-                limit = atoi(opt->value);\n-                break;\n-            case 't': /* number of threads */\n-                threads = atoi(opt->value);\n-                break;\n-            case 'i': /* iteration counter */\n-                loops = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  PRLock* ml;\n+  PRUint32 id = 0;\n+  int active, poll;\n+  PRIntervalTime interleave;\n+  PRIntervalTime duration = 0;\n+  int limit = 0, loops = 0, threads = 0, times;\n+  PRUint32 writes, writesMin = 0x7fffffff, writesTot = 0, durationTot = 0,\n+                   writesMax = 0;\n+\n+  const char* where[] = {\"okay\", \"open\", \"close\", \"delete\", \"write\", \"seek\"};\n+\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"Gdl:t:i:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'G': /* global threads */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      case 'l': /* limiting number */\n+        limit = atoi(opt->value);\n+        break;\n+      case 't': /* number of threads */\n+        threads = atoi(opt->value);\n+        break;\n+      case 'i': /* iteration counter */\n+        loops = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n+  }\n+  PL_DestroyOptState(opt);\n \n-    /* main test */\n+  /* main test */\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    interleave = PR_SecondsToInterval(10);\n+  interleave = PR_SecondsToInterval(10);\n \n-    ml = PR_NewLock();\n-    cv = PR_NewCondVar(ml);\n+  ml = PR_NewLock();\n+  cv = PR_NewCondVar(ml);\n \n-    if (loops == 0) {\n-        loops = DEFAULT_LOOPS;\n-    }\n-    if (limit == 0) {\n-        limit = DEFAULT_LIMIT;\n+  if (loops == 0) {\n+    loops = DEFAULT_LOOPS;\n+  }\n+  if (limit == 0) {\n+    limit = DEFAULT_LIMIT;\n+  }\n+  if (threads == 0) {\n+    threads = DEFAULT_THREADS;\n+  }\n+\n+  if (debug_mode)\n+    printf(\"%s: Using loops = %d, threads = %d, limit = %d and %s threads\\n\",\n+           programName, loops, threads, limit,\n+           (thread_scope == PR_LOCAL_THREAD) ? \"LOCAL\" : \"GLOBAL\");\n+\n+  for (times = 0; times < loops; ++times) {\n+    if (debug_mode) {\n+      printf(\"%s: Setting concurrency level to %d\\n\", programName, times + 1);\n     }\n-    if (threads == 0) {\n-        threads = DEFAULT_THREADS;\n+    PR_SetConcurrency(times + 1);\n+    for (active = 0; active < threads; active++) {\n+      hammer[active].ml = ml;\n+      hammer[active].cv = cv;\n+      hammer[active].id = id++;\n+      hammer[active].writes = 0;\n+      hammer[active].action = sg_go;\n+      hammer[active].problem = sg_okay;\n+      hammer[active].limit = (RandomNum() % limit) + 1;\n+      hammer[active].timein = PR_IntervalNow();\n+      hammer[active].thread =\n+          PR_CreateThread(PR_USER_THREAD, Thread, &hammer[active],\n+                          PR_GetThreadPriority(PR_GetCurrentThread()),\n+                          thread_scope, PR_JOINABLE_THREAD, 0);\n+\n+      PR_Lock(ml);\n+      PR_WaitCondVar(cv, interleave); /* start new ones slowly */\n+      PR_Unlock(ml);\n     }\n \n-    if (debug_mode)\n-        printf(\"%s: Using loops = %d, threads = %d, limit = %d and %s threads\\n\",\n-               programName, loops, threads, limit,\n-               (thread_scope == PR_LOCAL_THREAD) ? \"LOCAL\" : \"GLOBAL\");\n-\n-    for (times = 0; times < loops; ++times) {\n-        if (debug_mode) {\n-            printf(\"%s: Setting concurrency level to %d\\n\", programName, times + 1);\n-        }\n-        PR_SetConcurrency(times + 1);\n-        for (active = 0; active < threads; active++) {\n-            hammer[active].ml = ml;\n-            hammer[active].cv = cv;\n-            hammer[active].id = id++;\n-            hammer[active].writes = 0;\n-            hammer[active].action = sg_go;\n-            hammer[active].problem = sg_okay;\n-            hammer[active].limit = (RandomNum() % limit) + 1;\n-            hammer[active].timein = PR_IntervalNow();\n-            hammer[active].thread =\n-                PR_CreateThread(PR_USER_THREAD, Thread, &hammer[active],\n-                                PR_GetThreadPriority(PR_GetCurrentThread()),\n-                                thread_scope, PR_JOINABLE_THREAD, 0);\n-\n-            PR_Lock(ml);\n-            PR_WaitCondVar(cv, interleave); /* start new ones slowly */\n-            PR_Unlock(ml);\n-        }\n+    /*\n+     * The last thread started has had the opportunity to run for\n+     * 'interleave' seconds. Now gather them all back in.\n+     */\n+    PR_Lock(ml);\n+    for (poll = 0; poll < threads; poll++) {\n+      if (hammer[poll].action == sg_go) { /* don't overwrite done */\n+        hammer[poll].action = sg_stop;    /* ask him to stop */\n+      }\n+    }\n+    PR_Unlock(ml);\n \n-        /*\n-         * The last thread started has had the opportunity to run for\n-         * 'interleave' seconds. Now gather them all back in.\n-         */\n+    while (active > 0) {\n+      for (poll = 0; poll < threads; poll++) {\n         PR_Lock(ml);\n-        for (poll = 0; poll < threads; poll++) {\n-            if (hammer[poll].action == sg_go) { /* don't overwrite done */\n-                hammer[poll].action = sg_stop;  /* ask him to stop */\n-            }\n+        while (hammer[poll].action < sg_done) {\n+          PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n         }\n         PR_Unlock(ml);\n \n-        while (active > 0) {\n-            for (poll = 0; poll < threads; poll++) {\n-                PR_Lock(ml);\n-                while (hammer[poll].action < sg_done) {\n-                    PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT);\n-                }\n-                PR_Unlock(ml);\n-\n-                active -= 1; /* this is another one down */\n-                (void)PR_JoinThread(hammer[poll].thread);\n-                hammer[poll].thread = NULL;\n-                if (hammer[poll].problem == sg_okay) {\n-                    duration =\n-                        PR_IntervalToMilliseconds(PR_IntervalNow() - hammer[poll].timein);\n-                    writes = hammer[poll].writes * 1000 / duration;\n-                    if (writes < writesMin) {\n-                        writesMin = writes;\n-                    }\n-                    if (writes > writesMax) {\n-                        writesMax = writes;\n-                    }\n-                    writesTot += hammer[poll].writes;\n-                    durationTot += duration;\n-                } else if (debug_mode)\n-                    printf(\"%s: test failed %s after %ld seconds\\n\", programName,\n-                           where[hammer[poll].problem], duration);\n-                else {\n-                    failed_already = 1;\n-                }\n-            }\n+        active -= 1; /* this is another one down */\n+        (void)PR_JoinThread(hammer[poll].thread);\n+        hammer[poll].thread = NULL;\n+        if (hammer[poll].problem == sg_okay) {\n+          duration =\n+              PR_IntervalToMilliseconds(PR_IntervalNow() - hammer[poll].timein);\n+          writes = hammer[poll].writes * 1000 / duration;\n+          if (writes < writesMin) {\n+            writesMin = writes;\n+          }\n+          if (writes > writesMax) {\n+            writesMax = writes;\n+          }\n+          writesTot += hammer[poll].writes;\n+          durationTot += duration;\n+        } else if (debug_mode)\n+          printf(\"%s: test failed %s after %ld seconds\\n\", programName,\n+                 where[hammer[poll].problem], duration);\n+        else {\n+          failed_already = 1;\n         }\n+      }\n     }\n-    if (debug_mode)\n-        printf(\"%s: [%ld [%ld] %ld] writes/sec average\\n\", programName, writesMin,\n-               writesTot * 1000 / durationTot, writesMax);\n-\n-    PR_DestroyCondVar(cv);\n-    PR_DestroyLock(ml);\n-\n-    if (failed_already) {\n-        printf(\"FAIL\\n\");\n-        return 1;\n-    } else {\n-        printf(\"PASS\\n\");\n-        return 0;\n-    }\n+  }\n+  if (debug_mode)\n+    printf(\"%s: [%ld [%ld] %ld] writes/sec average\\n\", programName, writesMin,\n+           writesTot * 1000 / durationTot, writesMax);\n+\n+  PR_DestroyCondVar(cv);\n+  PR_DestroyLock(ml);\n+\n+  if (failed_already) {\n+    printf(\"FAIL\\n\");\n+    return 1;\n+  } else {\n+    printf(\"PASS\\n\");\n+    return 0;\n+  }\n } /* main */\ndiff --git a/nspr/pr/tests/reinit.c b/nspr/pr/tests/reinit.c\nindex 1920365..6fa61b1 100644\n--- a/nspr/pr/tests/reinit.c\n+++ b/nspr/pr/tests/reinit.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,29 +8,27 @@\n #include \"nspr.h\"\n #include <stdio.h>\n \n-int\n-main()\n-{\n-    PRStatus rv;\n+int main() {\n+  PRStatus rv;\n \n-    fprintf(stderr, \"Init 1\\n\");\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-    fprintf(stderr, \"Cleanup 1\\n\");\n-    rv = PR_Cleanup();\n-    if (rv != PR_SUCCESS) {\n-        fprintf(stderr, \"FAIL\\n\");\n-        return 1;\n-    }\n+  fprintf(stderr, \"Init 1\\n\");\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  fprintf(stderr, \"Cleanup 1\\n\");\n+  rv = PR_Cleanup();\n+  if (rv != PR_SUCCESS) {\n+    fprintf(stderr, \"FAIL\\n\");\n+    return 1;\n+  }\n \n-    fprintf(stderr, \"Init 2\\n\");\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-    fprintf(stderr, \"Cleanup 2\\n\");\n-    rv = PR_Cleanup();\n-    if (rv != PR_SUCCESS) {\n-        fprintf(stderr, \"FAIL\\n\");\n-        return 1;\n-    }\n+  fprintf(stderr, \"Init 2\\n\");\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  fprintf(stderr, \"Cleanup 2\\n\");\n+  rv = PR_Cleanup();\n+  if (rv != PR_SUCCESS) {\n+    fprintf(stderr, \"FAIL\\n\");\n+    return 1;\n+  }\n \n-    fprintf(stderr, \"PASS\\n\");\n-    return 0;\n+  fprintf(stderr, \"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/rmdir.c b/nspr/pr/tests/rmdir.c\nindex c9efacd..7e54c16 100644\n--- a/nspr/pr/tests/rmdir.c\n+++ b/nspr/pr/tests/rmdir.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -30,72 +31,68 @@ PRLogModuleInfo* lm;\n /*\n ** Help() -- print Usage information\n */\n-static void\n-Help(void)\n-{\n-    fprintf(stderr,\n-            \"template usage:\\n\"\n-            \"\\t-d     debug mode\\n\");\n+static void Help(void) {\n+  fprintf(stderr,\n+          \"template usage:\\n\"\n+          \"\\t-d     debug mode\\n\");\n } /* --- end Help() */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dh\");\n-    PRFileDesc* fd;\n-    PRErrorCode err;\n-\n-    /* parse command line options */\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            case 'h':\n-            default:\n-                Help();\n-                return 2;\n-        }\n+int main(int argc, char** argv) {\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dh\");\n+  PRFileDesc* fd;\n+  PRErrorCode err;\n+\n+  /* parse command line options */\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    lm = PR_NewLogModule(\"testcase\");\n-\n-    (void)PR_MkDir(DIRNAME, 0777);\n-    fd = PR_Open(DIRNAME FILENAME, PR_CREATE_FILE | PR_RDWR, 0666);\n-    if (fd == 0) {\n-        PRErrorCode err = PR_GetError();\n-        fprintf(stderr, \"create file fails: %d: %s\\n\", err,\n-                PR_ErrorToString(err, PR_LANGUAGE_I_DEFAULT));\n-        failed_already = PR_TRUE;\n-        goto Finished;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      case 'h':\n+      default:\n+        Help();\n+        return 2;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    PR_Close(fd);\n-\n-    if (PR_RmDir(DIRNAME) == PR_SUCCESS) {\n-        fprintf(stderr, \"remove directory succeeds\\n\");\n-        failed_already = PR_TRUE;\n-        goto Finished;\n-    }\n+  lm = PR_NewLogModule(\"testcase\");\n \n-    err = PR_GetError();\n-    fprintf(stderr, \"remove directory fails with: %d: %s\\n\", err,\n+  (void)PR_MkDir(DIRNAME, 0777);\n+  fd = PR_Open(DIRNAME FILENAME, PR_CREATE_FILE | PR_RDWR, 0666);\n+  if (fd == 0) {\n+    PRErrorCode err = PR_GetError();\n+    fprintf(stderr, \"create file fails: %d: %s\\n\", err,\n             PR_ErrorToString(err, PR_LANGUAGE_I_DEFAULT));\n+    failed_already = PR_TRUE;\n+    goto Finished;\n+  }\n+\n+  PR_Close(fd);\n \n-    (void)PR_Delete(DIRNAME FILENAME);\n-    (void)PR_RmDir(DIRNAME);\n+  if (PR_RmDir(DIRNAME) == PR_SUCCESS) {\n+    fprintf(stderr, \"remove directory succeeds\\n\");\n+    failed_already = PR_TRUE;\n+    goto Finished;\n+  }\n \n-    return 0;\n+  err = PR_GetError();\n+  fprintf(stderr, \"remove directory fails with: %d: %s\\n\", err,\n+          PR_ErrorToString(err, PR_LANGUAGE_I_DEFAULT));\n+\n+  (void)PR_Delete(DIRNAME FILENAME);\n+  (void)PR_RmDir(DIRNAME);\n+\n+  return 0;\n \n Finished:\n-    if (debug_mode) {\n-        printf(\"%s\\n\", (failed_already) ? \"FAILED\" : \"PASS\");\n-    }\n-    return ((failed_already) ? 1 : 0);\n+  if (debug_mode) {\n+    printf(\"%s\\n\", (failed_already) ? \"FAILED\" : \"PASS\");\n+  }\n+  return ((failed_already) ? 1 : 0);\n } /* --- end main() */\n /* --- end template.c */\ndiff --git a/nspr/pr/tests/runtests.sh b/nspr/pr/tests/runtests.sh\nindex 6718fc0..37b231f 100755\n--- a/nspr/pr/tests/runtests.sh\n+++ b/nspr/pr/tests/runtests.sh\n@@ -159,7 +159,6 @@ pipeself\n poll_nm\n poll_to\n pollable\n-prefloop\n prftest\n prfz\n primblok\n@@ -205,13 +204,6 @@ writev\n xnotify\n zerolen\"\n \n-# reinit is known to fail on Windows; exclude it there.\n-case `uname` in\n-    CYGWIN*|MINGW*|MSYS*|Windows_NT|Windows_95|Windows_98)\n-        TESTS=`echo \"$TESTS\" | grep -v '^reinit$'`\n-        ;;\n-esac\n-\n rval=0\n \n \ndiff --git a/nspr/pr/tests/rwlockrank.c b/nspr/pr/tests/rwlockrank.c\nindex 6584162..13bfee7 100644\n--- a/nspr/pr/tests/rwlockrank.c\n+++ b/nspr/pr/tests/rwlockrank.c\n@@ -14,32 +14,30 @@ static PRRWLock* rwlock0;\n static PRRWLock* rwlock1;\n static PRRWLock* rwlock2;\n \n-static void\n-rwtest(void* args)\n-{\n-    PR_RWLock_Rlock(rwlock1);\n-    PR_RWLock_Unlock(rwlock1);\n-\n-    PR_RWLock_Rlock(rwlock1);\n-    PR_RWLock_Unlock(rwlock1);\n-\n-    /* Test correct lock rank. */\n-    PR_RWLock_Rlock(rwlock1);\n-    PR_RWLock_Rlock(rwlock2);\n-    PR_RWLock_Unlock(rwlock2);\n-    PR_RWLock_Unlock(rwlock1);\n-\n-    PR_RWLock_Rlock(rwlock1);\n-    PR_RWLock_Rlock(rwlock2);\n-    PR_RWLock_Unlock(rwlock1);\n-    PR_RWLock_Unlock(rwlock2);\n-\n-    PR_RWLock_Rlock(rwlock1);\n-    PR_RWLock_Rlock(rwlock0);\n-    PR_RWLock_Rlock(rwlock2);\n-    PR_RWLock_Unlock(rwlock2);\n-    PR_RWLock_Unlock(rwlock0);\n-    PR_RWLock_Unlock(rwlock1);\n+static void rwtest(void* args) {\n+  PR_RWLock_Rlock(rwlock1);\n+  PR_RWLock_Unlock(rwlock1);\n+\n+  PR_RWLock_Rlock(rwlock1);\n+  PR_RWLock_Unlock(rwlock1);\n+\n+  /* Test correct lock rank. */\n+  PR_RWLock_Rlock(rwlock1);\n+  PR_RWLock_Rlock(rwlock2);\n+  PR_RWLock_Unlock(rwlock2);\n+  PR_RWLock_Unlock(rwlock1);\n+\n+  PR_RWLock_Rlock(rwlock1);\n+  PR_RWLock_Rlock(rwlock2);\n+  PR_RWLock_Unlock(rwlock1);\n+  PR_RWLock_Unlock(rwlock2);\n+\n+  PR_RWLock_Rlock(rwlock1);\n+  PR_RWLock_Rlock(rwlock0);\n+  PR_RWLock_Rlock(rwlock2);\n+  PR_RWLock_Unlock(rwlock2);\n+  PR_RWLock_Unlock(rwlock0);\n+  PR_RWLock_Unlock(rwlock1);\n \n #if 0\n     /* Test incorrect lock rank. */\n@@ -57,64 +55,62 @@ rwtest(void* args)\n #endif\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRStatus rc;\n-    PRThread* thread;\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                _debug_on = 1;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n+int main(int argc, char** argv) {\n+  PRStatus rc;\n+  PRThread* thread;\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n \n-    rwlock0 = PR_NewRWLock(PR_RWLOCK_RANK_NONE, \"Lock 0\");\n-    if (rwlock0 == NULL) {\n-        fprintf(stderr, \"PR_NewRWLock failed - error %d\\n\", (int)PR_GetError());\n-        return 1;\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    rwlock1 = PR_NewRWLock(1, \"Lock 1\");\n-    if (rwlock1 == NULL) {\n-        fprintf(stderr, \"PR_NewRWLock failed - error %d\\n\", (int)PR_GetError());\n-        return 1;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        _debug_on = 1;\n+        break;\n+      default:\n+        break;\n     }\n-    rwlock2 = PR_NewRWLock(2, \"Lock 2\");\n-    if (rwlock2 == NULL) {\n-        fprintf(stderr, \"PR_NewRWLock failed - error %d\\n\", (int)PR_GetError());\n-        return 1;\n-    }\n-\n-    thread = PR_CreateThread(PR_USER_THREAD, rwtest, NULL, PR_PRIORITY_NORMAL,\n-                             PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (thread == NULL) {\n-        fprintf(stderr, \"PR_CreateThread failed - error %d\\n\", (int)PR_GetError());\n-        PR_ProcessExit(2);\n-    }\n-    if (_debug_on) {\n-        printf(\"%s: created thread = %p\\n\", argv[0], thread);\n-    }\n-\n-    rc = PR_JoinThread(thread);\n-    PR_ASSERT(rc == PR_SUCCESS);\n-\n-    PR_DestroyRWLock(rwlock0);\n-    rwlock0 = NULL;\n-    PR_DestroyRWLock(rwlock1);\n-    rwlock1 = NULL;\n-    PR_DestroyRWLock(rwlock2);\n-    rwlock2 = NULL;\n-\n-    printf(\"PASS\\n\");\n-    return 0;\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  rwlock0 = PR_NewRWLock(PR_RWLOCK_RANK_NONE, \"Lock 0\");\n+  if (rwlock0 == NULL) {\n+    fprintf(stderr, \"PR_NewRWLock failed - error %d\\n\", (int)PR_GetError());\n+    return 1;\n+  }\n+  rwlock1 = PR_NewRWLock(1, \"Lock 1\");\n+  if (rwlock1 == NULL) {\n+    fprintf(stderr, \"PR_NewRWLock failed - error %d\\n\", (int)PR_GetError());\n+    return 1;\n+  }\n+  rwlock2 = PR_NewRWLock(2, \"Lock 2\");\n+  if (rwlock2 == NULL) {\n+    fprintf(stderr, \"PR_NewRWLock failed - error %d\\n\", (int)PR_GetError());\n+    return 1;\n+  }\n+\n+  thread = PR_CreateThread(PR_USER_THREAD, rwtest, NULL, PR_PRIORITY_NORMAL,\n+                           PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (thread == NULL) {\n+    fprintf(stderr, \"PR_CreateThread failed - error %d\\n\", (int)PR_GetError());\n+    PR_ProcessExit(2);\n+  }\n+  if (_debug_on) {\n+    printf(\"%s: created thread = %p\\n\", argv[0], thread);\n+  }\n+\n+  rc = PR_JoinThread(thread);\n+  PR_ASSERT(rc == PR_SUCCESS);\n+\n+  PR_DestroyRWLock(rwlock0);\n+  rwlock0 = NULL;\n+  PR_DestroyRWLock(rwlock1);\n+  rwlock1 = NULL;\n+  PR_DestroyRWLock(rwlock2);\n+  rwlock2 = NULL;\n+\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/rwlocktest.c b/nspr/pr/tests/rwlocktest.c\nindex 056d843..bcb95f4 100644\n--- a/nspr/pr/tests/rwlocktest.c\n+++ b/nspr/pr/tests/rwlocktest.c\n@@ -28,8 +28,8 @@ static void update_array(void);\n static void check_array(void);\n \n typedef struct thread_args {\n-    PRRWLock* rwlock;\n-    PRInt32 loop_cnt;\n+  PRRWLock* rwlock;\n+  PRInt32 loop_cnt;\n } thread_args;\n \n PRFileDesc* output;\n@@ -39,164 +39,156 @@ PRFileDesc* errhandle;\n #define DEFAULT_LOOP_CNT 100\n #define TEST_ARRAY_SIZE 100\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRInt32 cnt;\n-    PRStatus rc;\n-    PRInt32 i;\n-\n-    PRInt32 thread_cnt = DEFAULT_THREAD_CNT;\n-    PRInt32 loop_cnt = DEFAULT_LOOP_CNT;\n-    PRThread** threads;\n-    thread_args* params;\n-    PRRWLock* rwlock1;\n-\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dt:c:\");\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                _debug_on = 1;\n-                break;\n-            case 't': /* thread count */\n-                thread_cnt = atoi(opt->value);\n-                break;\n-            case 'c': /* loop count */\n-                loop_cnt = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n+int main(int argc, char** argv) {\n+  PRInt32 cnt;\n+  PRStatus rc;\n+  PRInt32 i;\n \n-    PR_SetConcurrency(4);\n+  PRInt32 thread_cnt = DEFAULT_THREAD_CNT;\n+  PRInt32 loop_cnt = DEFAULT_LOOP_CNT;\n+  PRThread** threads;\n+  thread_args* params;\n+  PRRWLock* rwlock1;\n \n-    output = PR_GetSpecialFD(PR_StandardOutput);\n-    errhandle = PR_GetSpecialFD(PR_StandardError);\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dt:c:\");\n \n-    rwlock1 = PR_NewRWLock(0, \"Lock 1\");\n-    if (rwlock1 == NULL) {\n-        PR_fprintf(errhandle, \"PR_NewRWLock failed - error %d\\n\", PR_GetError());\n-        return 1;\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-\n-    threads = (PRThread**)PR_CALLOC(sizeof(PRThread*) * thread_cnt);\n-    params = (thread_args*)PR_CALLOC(sizeof(thread_args) * thread_cnt);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        _debug_on = 1;\n+        break;\n+      case 't': /* thread count */\n+        thread_cnt = atoi(opt->value);\n+        break;\n+      case 'c': /* loop count */\n+        loop_cnt = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  PR_SetConcurrency(4);\n+\n+  output = PR_GetSpecialFD(PR_StandardOutput);\n+  errhandle = PR_GetSpecialFD(PR_StandardError);\n+\n+  rwlock1 = PR_NewRWLock(0, \"Lock 1\");\n+  if (rwlock1 == NULL) {\n+    PR_fprintf(errhandle, \"PR_NewRWLock failed - error %d\\n\", PR_GetError());\n+    return 1;\n+  }\n+\n+  threads = (PRThread**)PR_CALLOC(sizeof(PRThread*) * thread_cnt);\n+  params = (thread_args*)PR_CALLOC(sizeof(thread_args) * thread_cnt);\n+\n+  /*\n+   * allocate and initialize data arrays\n+   */\n+  array_A = (PRInt32*)PR_MALLOC(sizeof(PRInt32) * TEST_ARRAY_SIZE);\n+  array_B = (PRInt32*)PR_MALLOC(sizeof(PRInt32) * TEST_ARRAY_SIZE);\n+  array_C = (PRInt32*)PR_MALLOC(sizeof(PRInt32) * TEST_ARRAY_SIZE);\n+  cnt = 0;\n+  for (i = 0; i < TEST_ARRAY_SIZE; i++) {\n+    array_A[i] = cnt++;\n+    array_B[i] = cnt++;\n+    array_C[i] = array_A[i] + array_B[i];\n+  }\n+\n+  if (_debug_on)\n+    PR_fprintf(output, \"%s: thread_cnt = %d loop_cnt = %d\\n\", argv[0],\n+               thread_cnt, loop_cnt);\n+  for (cnt = 0; cnt < thread_cnt; cnt++) {\n+    PRThreadScope scope;\n+\n+    params[cnt].rwlock = rwlock1;\n+    params[cnt].loop_cnt = loop_cnt;\n \n     /*\n-     * allocate and initialize data arrays\n+     * create LOCAL and GLOBAL threads alternately\n      */\n-    array_A = (PRInt32*)PR_MALLOC(sizeof(PRInt32) * TEST_ARRAY_SIZE);\n-    array_B = (PRInt32*)PR_MALLOC(sizeof(PRInt32) * TEST_ARRAY_SIZE);\n-    array_C = (PRInt32*)PR_MALLOC(sizeof(PRInt32) * TEST_ARRAY_SIZE);\n-    cnt = 0;\n-    for (i = 0; i < TEST_ARRAY_SIZE; i++) {\n-        array_A[i] = cnt++;\n-        array_B[i] = cnt++;\n-        array_C[i] = array_A[i] + array_B[i];\n+    if (cnt & 1) {\n+      scope = PR_LOCAL_THREAD;\n+    } else {\n+      scope = PR_GLOBAL_THREAD;\n     }\n \n-    if (_debug_on)\n-        PR_fprintf(output, \"%s: thread_cnt = %d loop_cnt = %d\\n\", argv[0],\n-                   thread_cnt, loop_cnt);\n-    for (cnt = 0; cnt < thread_cnt; cnt++) {\n-        PRThreadScope scope;\n-\n-        params[cnt].rwlock = rwlock1;\n-        params[cnt].loop_cnt = loop_cnt;\n-\n-        /*\n-         * create LOCAL and GLOBAL threads alternately\n-         */\n-        if (cnt & 1) {\n-            scope = PR_LOCAL_THREAD;\n-        } else {\n-            scope = PR_GLOBAL_THREAD;\n-        }\n-\n-        threads[cnt] =\n-            PR_CreateThread(PR_USER_THREAD, rwtest, &params[cnt],\n-                            PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n-        if (threads[cnt] == NULL) {\n-            PR_fprintf(errhandle, \"PR_CreateThread failed - error %d\\n\",\n-                       PR_GetError());\n-            PR_ProcessExit(2);\n-        }\n-        if (_debug_on)\n-            PR_fprintf(output, \"%s: created thread = %p\\n\", argv[0], threads[cnt]);\n+    threads[cnt] =\n+        PR_CreateThread(PR_USER_THREAD, rwtest, &params[cnt],\n+                        PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n+    if (threads[cnt] == NULL) {\n+      PR_fprintf(errhandle, \"PR_CreateThread failed - error %d\\n\",\n+                 PR_GetError());\n+      PR_ProcessExit(2);\n     }\n+    if (_debug_on)\n+      PR_fprintf(output, \"%s: created thread = %p\\n\", argv[0], threads[cnt]);\n+  }\n \n-    for (cnt = 0; cnt < thread_cnt; cnt++) {\n-        rc = PR_JoinThread(threads[cnt]);\n-        PR_ASSERT(rc == PR_SUCCESS);\n-    }\n+  for (cnt = 0; cnt < thread_cnt; cnt++) {\n+    rc = PR_JoinThread(threads[cnt]);\n+    PR_ASSERT(rc == PR_SUCCESS);\n+  }\n \n-    PR_DELETE(threads);\n-    PR_DELETE(params);\n+  PR_DELETE(threads);\n+  PR_DELETE(params);\n \n-    PR_DELETE(array_A);\n-    PR_DELETE(array_B);\n-    PR_DELETE(array_C);\n+  PR_DELETE(array_A);\n+  PR_DELETE(array_B);\n+  PR_DELETE(array_C);\n \n-    PR_DestroyRWLock(rwlock1);\n+  PR_DestroyRWLock(rwlock1);\n \n-    printf(\"PASS\\n\");\n-    return 0;\n+  printf(\"PASS\\n\");\n+  return 0;\n }\n \n-static void\n-rwtest(void* args)\n-{\n-    PRInt32 index;\n-    thread_args* arg = (thread_args*)args;\n-\n-    for (index = 0; index < arg->loop_cnt; index++) {\n-        /*\n-         * verify sum, update arrays and verify sum again\n-         */\n+static void rwtest(void* args) {\n+  PRInt32 index;\n+  thread_args* arg = (thread_args*)args;\n \n-        PR_RWLock_Rlock(arg->rwlock);\n-        check_array();\n-        PR_RWLock_Unlock(arg->rwlock);\n-\n-        PR_RWLock_Wlock(arg->rwlock);\n-        update_array();\n-        PR_RWLock_Unlock(arg->rwlock);\n+  for (index = 0; index < arg->loop_cnt; index++) {\n+    /*\n+     * verify sum, update arrays and verify sum again\n+     */\n \n-        PR_RWLock_Rlock(arg->rwlock);\n-        check_array();\n-        PR_RWLock_Unlock(arg->rwlock);\n-    }\n-    if (_debug_on)\n-        PR_fprintf(output, \"Thread[0x%x] lock = 0x%x exiting\\n\",\n-                   PR_GetCurrentThread(), arg->rwlock);\n+    PR_RWLock_Rlock(arg->rwlock);\n+    check_array();\n+    PR_RWLock_Unlock(arg->rwlock);\n+\n+    PR_RWLock_Wlock(arg->rwlock);\n+    update_array();\n+    PR_RWLock_Unlock(arg->rwlock);\n+\n+    PR_RWLock_Rlock(arg->rwlock);\n+    check_array();\n+    PR_RWLock_Unlock(arg->rwlock);\n+  }\n+  if (_debug_on)\n+    PR_fprintf(output, \"Thread[0x%x] lock = 0x%x exiting\\n\",\n+               PR_GetCurrentThread(), arg->rwlock);\n }\n \n-static void\n-check_array(void)\n-{\n-    PRInt32 i;\n+static void check_array(void) {\n+  PRInt32 i;\n \n-    for (i = 0; i < TEST_ARRAY_SIZE; i++)\n-        if (array_C[i] != (array_A[i] + array_B[i])) {\n-            PR_fprintf(output, \"Error - data check failed\\n\");\n-            PR_ProcessExit(1);\n-        }\n+  for (i = 0; i < TEST_ARRAY_SIZE; i++)\n+    if (array_C[i] != (array_A[i] + array_B[i])) {\n+      PR_fprintf(output, \"Error - data check failed\\n\");\n+      PR_ProcessExit(1);\n+    }\n }\n \n-static void\n-update_array(void)\n-{\n-    PRInt32 i;\n+static void update_array(void) {\n+  PRInt32 i;\n \n-    for (i = 0; i < TEST_ARRAY_SIZE; i++) {\n-        array_A[i] += i;\n-        array_B[i] -= i;\n-    }\n+  for (i = 0; i < TEST_ARRAY_SIZE; i++) {\n+    array_A[i] += i;\n+    array_B[i] -= i;\n+  }\n }\ndiff --git a/nspr/pr/tests/sel_spd.c b/nspr/pr/tests/sel_spd.c\nindex b9fbb90..1e96529 100644\n--- a/nspr/pr/tests/sel_spd.c\n+++ b/nspr/pr/tests/sel_spd.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -16,29 +17,29 @@\n #include <string.h>\n \n #if defined(XP_UNIX)\n-#include <unistd.h>\n+#  include <unistd.h>\n #endif\n \n #ifdef DEBUG\n-#define PORT_INC_DO +100\n+#  define PORT_INC_DO +100\n #else\n-#define PORT_INC_DO\n+#  define PORT_INC_DO\n #endif\n #ifdef IS_64\n-#define PORT_INC_3264 +200\n+#  define PORT_INC_3264 +200\n #else\n-#define PORT_INC_3264\n+#  define PORT_INC_3264\n #endif\n \n #define PORT_BASE 19000 PORT_INC_DO PORT_INC_3264\n \n typedef struct timer_slot_t {\n-    unsigned long d_connect;\n-    unsigned long d_cl_data;\n-    unsigned long d_sv_data;\n-    unsigned long d_close;\n-    unsigned long d_total;\n-    unsigned long requests;\n+  unsigned long d_connect;\n+  unsigned long d_cl_data;\n+  unsigned long d_sv_data;\n+  unsigned long d_close;\n+  unsigned long d_total;\n+  unsigned long requests;\n } timer_slot_t;\n \n static long _iterations = 5;\n@@ -56,482 +57,445 @@ static PRThreadScope scope1, scope2;\n void tally_results(int);\n \n /* return the diff in microseconds */\n-unsigned long\n-_delta(PRIntervalTime* start, PRIntervalTime* stop)\n-{\n-    /*\n-     * Will C do the right thing with unsigned arithemtic?\n-     */\n-    return PR_IntervalToMicroseconds(*stop - *start);\n+unsigned long _delta(PRIntervalTime* start, PRIntervalTime* stop) {\n+  /*\n+   * Will C do the right thing with unsigned arithemtic?\n+   */\n+  return PR_IntervalToMicroseconds(*stop - *start);\n }\n \n-int\n-_readn(PRFileDesc* sock, char* buf, int len)\n-{\n-    int rem;\n-    int bytes;\n-\n-    for (rem = len; rem; rem -= bytes) {\n-        bytes = PR_Recv(sock, buf + len - rem, rem, 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (bytes <= 0) {\n-            return -1;\n-        }\n+int _readn(PRFileDesc* sock, char* buf, int len) {\n+  int rem;\n+  int bytes;\n+\n+  for (rem = len; rem; rem -= bytes) {\n+    bytes = PR_Recv(sock, buf + len - rem, rem, 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (bytes <= 0) {\n+      return -1;\n     }\n-    return len;\n+  }\n+  return len;\n }\n \n-void\n-_thread_exit(int id)\n-{\n-    PR_EnterMonitor(exit_cv);\n+void _thread_exit(int id) {\n+  PR_EnterMonitor(exit_cv);\n #ifdef DEBUG\n-    fprintf(stdout, \"Thread %d EXIT\\n\", id);\n+  fprintf(stdout, \"Thread %d EXIT\\n\", id);\n #endif\n \n-    _thread_exit_count--;\n-    if (_thread_exit_count == 0) {\n+  _thread_exit_count--;\n+  if (_thread_exit_count == 0) {\n #ifdef DEBUG\n-        fprintf(stdout, \"Thread %d EXIT triggered notify\\n\", id);\n+    fprintf(stdout, \"Thread %d EXIT triggered notify\\n\", id);\n #endif\n-        PR_Notify(exit_cv);\n-    }\n-    PR_ExitMonitor(exit_cv);\n+    PR_Notify(exit_cv);\n+  }\n+  PR_ExitMonitor(exit_cv);\n }\n \n-void\n-_server_thread(void* arg_id)\n-{\n-    void _client_thread(void*);\n-    int* id = (int*)arg_id;\n-    PRFileDesc* sock;\n-    PRSocketOptionData sockopt;\n-    PRNetAddr sa;\n-    PRFileDesc* newsock;\n-    char* data_buffer = NULL;\n-    int data_buffer_size;\n-    int index;\n-    PRIntervalTime start, connect_done, read_done, write_done, close_done;\n+void _server_thread(void* arg_id) {\n+  void _client_thread(void*);\n+  int* id = (int*)arg_id;\n+  PRFileDesc* sock;\n+  PRSocketOptionData sockopt;\n+  PRNetAddr sa;\n+  PRFileDesc* newsock;\n+  char* data_buffer = NULL;\n+  int data_buffer_size;\n+  int index;\n+  PRIntervalTime start, connect_done, read_done, write_done, close_done;\n \n #ifdef DEBUG\n-    fprintf(stdout, \"server thread %d alive\\n\", *id);\n+  fprintf(stdout, \"server thread %d alive\\n\", *id);\n #endif\n \n-    data_buffer_size =\n-        (_client_data > _server_data ? _client_data : _server_data);\n-\n-    if ((data_buffer = (char*)PR_Malloc(data_buffer_size * sizeof(char))) ==\n-        NULL) {\n-        fprintf(stderr, \"Error creating buffer in server thread %d\\n\", *id);\n-        goto done;\n-    }\n-\n-    if ((sock = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Error creating socket in server thread %d\\n\", *id);\n-        goto done;\n-    }\n-\n-    sockopt.option = PR_SockOpt_Reuseaddr;\n-    sockopt.value.reuse_addr = PR_TRUE;\n-    if (PR_SetSocketOption(sock, &sockopt) == PR_FAILURE) {\n-        fprintf(stderr, \"Error setting socket option in server thread %d\\n\", *id);\n-        goto done;\n-    }\n-\n-    memset(&sa, 0, sizeof(sa));\n-    sa.inet.family = PR_AF_INET;\n-    sa.inet.port = PR_htons(PORT_BASE + *id);\n-    sa.inet.ip = PR_htonl(PR_INADDR_ANY);\n-\n-    if (PR_Bind(sock, &sa) < 0) {\n-        fprintf(stderr, \"Error binding socket in server thread %d errno = %d\\n\",\n-                *id, errno);\n-        goto done;\n-    }\n-\n-    if (PR_Listen(sock, 32) < 0) {\n-        fprintf(stderr, \"Error listening to socket in server thread %d\\n\", *id);\n-        goto done;\n-    }\n-\n-    /* Tell the client to start. Give it its own copy of the id so that the\n-     * server and client threads can each free their own without racing. */\n-    {\n-        int* client_id = (int*)PR_Malloc(sizeof(int));\n-        *client_id = *id;\n-        if (PR_CreateThread(PR_USER_THREAD, _client_thread, client_id,\n-                            PR_PRIORITY_NORMAL, scope2, PR_UNJOINABLE_THREAD,\n-                            0) == NULL) {\n-            fprintf(stderr, \"Error creating client thread %d\\n\", *id);\n-            PR_Free(client_id);\n-        }\n-    }\n-\n-    for (index = 0; index < _iterations; index++) {\n+  data_buffer_size =\n+      (_client_data > _server_data ? _client_data : _server_data);\n+\n+  if ((data_buffer = (char*)PR_Malloc(data_buffer_size * sizeof(char))) ==\n+      NULL) {\n+    fprintf(stderr, \"Error creating buffer in server thread %d\\n\", *id);\n+    goto done;\n+  }\n+\n+  if ((sock = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Error creating socket in server thread %d\\n\", *id);\n+    goto done;\n+  }\n+\n+  sockopt.option = PR_SockOpt_Reuseaddr;\n+  sockopt.value.reuse_addr = PR_TRUE;\n+  if (PR_SetSocketOption(sock, &sockopt) == PR_FAILURE) {\n+    fprintf(stderr, \"Error setting socket option in server thread %d\\n\", *id);\n+    goto done;\n+  }\n+\n+  memset(&sa, 0, sizeof(sa));\n+  sa.inet.family = PR_AF_INET;\n+  sa.inet.port = PR_htons(PORT_BASE + *id);\n+  sa.inet.ip = PR_htonl(PR_INADDR_ANY);\n+\n+  if (PR_Bind(sock, &sa) < 0) {\n+    fprintf(stderr, \"Error binding socket in server thread %d errno = %d\\n\",\n+            *id, errno);\n+    goto done;\n+  }\n+\n+  if (PR_Listen(sock, 32) < 0) {\n+    fprintf(stderr, \"Error listening to socket in server thread %d\\n\", *id);\n+    goto done;\n+  }\n+\n+  /* Tell the client to start */\n+  if (PR_CreateThread(PR_USER_THREAD, _client_thread, id, PR_PRIORITY_NORMAL,\n+                      scope2, PR_UNJOINABLE_THREAD, 0) == NULL) {\n+    fprintf(stderr, \"Error creating client thread %d\\n\", *id);\n+  }\n+\n+  for (index = 0; index < _iterations; index++) {\n #ifdef DEBUG\n-        fprintf(stdout, \"server thread %d loop %d\\n\", *id, index);\n+    fprintf(stdout, \"server thread %d loop %d\\n\", *id, index);\n #endif\n \n-        start = PR_IntervalNow();\n+    start = PR_IntervalNow();\n \n-        if ((newsock = PR_Accept(sock, &sa, PR_INTERVAL_NO_TIMEOUT)) == NULL) {\n-            fprintf(stderr, \"Error accepting connection %d in server thread %d\\n\",\n-                    index, *id);\n-            goto done;\n-        }\n+    if ((newsock = PR_Accept(sock, &sa, PR_INTERVAL_NO_TIMEOUT)) == NULL) {\n+      fprintf(stderr, \"Error accepting connection %d in server thread %d\\n\",\n+              index, *id);\n+      goto done;\n+    }\n #ifdef DEBUG\n-        fprintf(stdout, \"server thread %d got connection %d\\n\", *id, newsock);\n+    fprintf(stdout, \"server thread %d got connection %d\\n\", *id, newsock);\n #endif\n \n-        connect_done = PR_IntervalNow();\n+    connect_done = PR_IntervalNow();\n \n-        if (_readn(newsock, data_buffer, _client_data) < _client_data) {\n-            fprintf(\n-                stderr,\n-                \"Error reading client data for iteration %d in server thread %d\\n\",\n-                index, *id);\n-            goto done;\n-        }\n+    if (_readn(newsock, data_buffer, _client_data) < _client_data) {\n+      fprintf(\n+          stderr,\n+          \"Error reading client data for iteration %d in server thread %d\\n\",\n+          index, *id);\n+      goto done;\n+    }\n \n #ifdef DEBUG\n-        fprintf(stdout, \"server thread %d read %d bytes\\n\", *id, _client_data);\n+    fprintf(stdout, \"server thread %d read %d bytes\\n\", *id, _client_data);\n #endif\n-        read_done = PR_IntervalNow();\n-\n-        if (PR_Send(newsock, data_buffer, _server_data, 0, PR_INTERVAL_NO_TIMEOUT) <\n-            _server_data) {\n-            fprintf(\n-                stderr,\n-                \"Error sending client data for iteration %d in server thread %d\\n\",\n-                index, *id);\n-            goto done;\n-        }\n+    read_done = PR_IntervalNow();\n+\n+    if (PR_Send(newsock, data_buffer, _server_data, 0, PR_INTERVAL_NO_TIMEOUT) <\n+        _server_data) {\n+      fprintf(\n+          stderr,\n+          \"Error sending client data for iteration %d in server thread %d\\n\",\n+          index, *id);\n+      goto done;\n+    }\n \n #ifdef DEBUG\n-        fprintf(stdout, \"server thread %d write %d bytes\\n\", *id, _server_data);\n+    fprintf(stdout, \"server thread %d write %d bytes\\n\", *id, _server_data);\n #endif\n \n-        write_done = PR_IntervalNow();\n+    write_done = PR_IntervalNow();\n \n-        PR_Close(newsock);\n+    PR_Close(newsock);\n \n-        close_done = PR_IntervalNow();\n+    close_done = PR_IntervalNow();\n \n-        timer_data[2 * (*id)].d_connect += _delta(&start, &connect_done);\n-        timer_data[2 * (*id)].d_cl_data += _delta(&connect_done, &read_done);\n-        timer_data[2 * (*id)].d_sv_data += _delta(&read_done, &write_done);\n-        timer_data[2 * (*id)].d_close += _delta(&write_done, &close_done);\n-        timer_data[2 * (*id)].d_total += _delta(&start, &close_done);\n-        timer_data[2 * (*id)].requests++;\n+    timer_data[2 * (*id)].d_connect += _delta(&start, &connect_done);\n+    timer_data[2 * (*id)].d_cl_data += _delta(&connect_done, &read_done);\n+    timer_data[2 * (*id)].d_sv_data += _delta(&read_done, &write_done);\n+    timer_data[2 * (*id)].d_close += _delta(&write_done, &close_done);\n+    timer_data[2 * (*id)].d_total += _delta(&start, &close_done);\n+    timer_data[2 * (*id)].requests++;\n \n #ifdef DEBUG\n-        fprintf(stdout, \"server: %d %d %d %d %d\\n\", _delta(&start, &connect_done),\n-                _delta(&connect_done, &read_done), _delta(&read_done, &write_done),\n-                _delta(&write_done, &close_done), _delta(&start, &close_done));\n+    fprintf(stdout, \"server: %d %d %d %d %d\\n\", _delta(&start, &connect_done),\n+            _delta(&connect_done, &read_done), _delta(&read_done, &write_done),\n+            _delta(&write_done, &close_done), _delta(&start, &close_done));\n #endif\n-    }\n+  }\n \n done:\n-    if (data_buffer != NULL) {\n-        PR_Free(data_buffer);\n-    }\n-    if (sock) {\n-        PR_Close(sock);\n-    }\n-    _thread_exit(*id);\n-    PR_Free(id);\n-    return;\n+  if (data_buffer != NULL) {\n+    PR_Free(data_buffer);\n+  }\n+  if (sock) {\n+    PR_Close(sock);\n+  }\n+  _thread_exit(*id);\n+  return;\n }\n \n-void\n-_client_thread(void* arg_id)\n-{\n-    int* id = (int*)arg_id;\n-    int index;\n-    PRNetAddr sa;\n-    PRFileDesc* sock_h;\n-    char* data_buffer = NULL;\n-    int data_buffer_size;\n-    int bytes;\n-    PRIntervalTime start, connect_done, read_done, write_done, close_done;\n-    PRStatus rv;\n+void _client_thread(void* arg_id) {\n+  int* id = (int*)arg_id;\n+  int index;\n+  PRNetAddr sa;\n+  PRFileDesc* sock_h;\n+  char* data_buffer = NULL;\n+  int data_buffer_size;\n+  int bytes;\n+  PRIntervalTime start, connect_done, read_done, write_done, close_done;\n+  PRStatus rv;\n \n #ifdef DEBUG\n-    fprintf(stdout, \"client thread %d alive\\n\", *id);\n+  fprintf(stdout, \"client thread %d alive\\n\", *id);\n #endif\n \n-    data_buffer_size =\n-        (_client_data > _server_data ? _client_data : _server_data);\n+  data_buffer_size =\n+      (_client_data > _server_data ? _client_data : _server_data);\n \n-    if ((data_buffer = (char*)PR_Malloc(data_buffer_size * sizeof(char))) ==\n-        NULL) {\n-        fprintf(stderr, \"Error creating buffer in server thread %d\\n\", *id);\n-        goto done;\n-    }\n+  if ((data_buffer = (char*)PR_Malloc(data_buffer_size * sizeof(char))) ==\n+      NULL) {\n+    fprintf(stderr, \"Error creating buffer in server thread %d\\n\", *id);\n+    goto done;\n+  }\n \n-    memset(&sa, 0, sizeof(sa));\n-    rv = PR_InitializeNetAddr(PR_IpAddrLoopback, PORT_BASE + *id, &sa);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+  memset(&sa, 0, sizeof(sa));\n+  rv = PR_InitializeNetAddr(PR_IpAddrLoopback, PORT_BASE + *id, &sa);\n+  PR_ASSERT(PR_SUCCESS == rv);\n \n-    for (index = 0; index < _iterations; index++) {\n+  for (index = 0; index < _iterations; index++) {\n #ifdef DEBUG\n-        fprintf(stdout, \"client thread %d loop %d\\n\", *id, index);\n+    fprintf(stdout, \"client thread %d loop %d\\n\", *id, index);\n #endif\n \n-        start = PR_IntervalNow();\n-        if ((sock_h = PR_NewTCPSocket()) == NULL) {\n-            fprintf(stderr, \"Error creating socket %d in client thread %d\\n\", index,\n-                    *id);\n-            goto done;\n-        }\n+    start = PR_IntervalNow();\n+    if ((sock_h = PR_NewTCPSocket()) == NULL) {\n+      fprintf(stderr, \"Error creating socket %d in client thread %d\\n\", index,\n+              *id);\n+      goto done;\n+    }\n \n #ifdef DEBUG\n-        fprintf(stdout, \"client thread %d socket created %d\\n\", *id, sock_h);\n+    fprintf(stdout, \"client thread %d socket created %d\\n\", *id, sock_h);\n #endif\n \n-        if (PR_Connect(sock_h, &sa, PR_INTERVAL_NO_TIMEOUT) < 0) {\n-            fprintf(stderr, \"Error accepting connection %d in client thread %d\\n\",\n-                    index, *id);\n-            goto done;\n-        }\n+    if (PR_Connect(sock_h, &sa, PR_INTERVAL_NO_TIMEOUT) < 0) {\n+      fprintf(stderr, \"Error accepting connection %d in client thread %d\\n\",\n+              index, *id);\n+      goto done;\n+    }\n \n #ifdef DEBUG\n-        fprintf(stdout, \"client thread %d socket connected %d\\n\", *id, sock_h);\n+    fprintf(stdout, \"client thread %d socket connected %d\\n\", *id, sock_h);\n #endif\n \n-        connect_done = PR_IntervalNow();\n-        if (PR_Send(sock_h, data_buffer, _client_data, 0, PR_INTERVAL_NO_TIMEOUT) <\n-            _client_data) {\n-            fprintf(\n-                stderr,\n-                \"Error sending client data for iteration %d in client thread %d\\n\",\n-                index, *id);\n-            goto done;\n-        }\n+    connect_done = PR_IntervalNow();\n+    if (PR_Send(sock_h, data_buffer, _client_data, 0, PR_INTERVAL_NO_TIMEOUT) <\n+        _client_data) {\n+      fprintf(\n+          stderr,\n+          \"Error sending client data for iteration %d in client thread %d\\n\",\n+          index, *id);\n+      goto done;\n+    }\n \n #ifdef DEBUG\n-        fprintf(stdout, \"client thread %d socket wrote %d\\n\", *id, _client_data);\n+    fprintf(stdout, \"client thread %d socket wrote %d\\n\", *id, _client_data);\n #endif\n \n-        write_done = PR_IntervalNow();\n-        if ((bytes = _readn(sock_h, data_buffer, _server_data)) < _server_data) {\n-            fprintf(stderr,\n-                    \"Error reading server data for iteration %d in client thread %d \"\n-                    \"(read %d bytes)\\n\",\n-                    index, *id, bytes);\n-            goto done;\n-        }\n+    write_done = PR_IntervalNow();\n+    if ((bytes = _readn(sock_h, data_buffer, _server_data)) < _server_data) {\n+      fprintf(stderr,\n+              \"Error reading server data for iteration %d in client thread %d \"\n+              \"(read %d bytes)\\n\",\n+              index, *id, bytes);\n+      goto done;\n+    }\n \n #ifdef DEBUG\n-        fprintf(stdout, \"client thread %d socket read %d\\n\", *id, _server_data);\n+    fprintf(stdout, \"client thread %d socket read %d\\n\", *id, _server_data);\n #endif\n \n-        read_done = PR_IntervalNow();\n-        PR_Close(sock_h);\n-        close_done = PR_IntervalNow();\n-\n-        timer_data[2 * (*id) + 1].d_connect += _delta(&start, &connect_done);\n-        timer_data[2 * (*id) + 1].d_cl_data += _delta(&connect_done, &write_done);\n-        timer_data[2 * (*id) + 1].d_sv_data += _delta(&write_done, &read_done);\n-        timer_data[2 * (*id) + 1].d_close += _delta(&read_done, &close_done);\n-        timer_data[2 * (*id) + 1].d_total += _delta(&start, &close_done);\n-        timer_data[2 * (*id) + 1].requests++;\n-    }\n+    read_done = PR_IntervalNow();\n+    PR_Close(sock_h);\n+    close_done = PR_IntervalNow();\n+\n+    timer_data[2 * (*id) + 1].d_connect += _delta(&start, &connect_done);\n+    timer_data[2 * (*id) + 1].d_cl_data += _delta(&connect_done, &write_done);\n+    timer_data[2 * (*id) + 1].d_sv_data += _delta(&write_done, &read_done);\n+    timer_data[2 * (*id) + 1].d_close += _delta(&read_done, &close_done);\n+    timer_data[2 * (*id) + 1].d_total += _delta(&start, &close_done);\n+    timer_data[2 * (*id) + 1].requests++;\n+  }\n done:\n-    if (data_buffer != NULL) {\n-        PR_Free(data_buffer);\n-    }\n-    _thread_exit(*id);\n-    PR_Free(id);\n+  if (data_buffer != NULL) {\n+    PR_Free(data_buffer);\n+  }\n+  _thread_exit(*id);\n \n-    return;\n+  return;\n }\n \n-static void\n-do_work(void)\n-{\n-    int index;\n+static void do_work(void) {\n+  int index;\n \n-    _thread_exit_count = _threads * 2;\n-    for (index = 0; index < _threads; index++) {\n-        int* id = (int*)PR_Malloc(sizeof(int));\n+  _thread_exit_count = _threads * 2;\n+  for (index = 0; index < _threads; index++) {\n+    int* id = (int*)PR_Malloc(sizeof(int));\n \n-        *id = index;\n+    *id = index;\n \n-        if (PR_CreateThread(PR_USER_THREAD, _server_thread, id, PR_PRIORITY_NORMAL,\n-                            scope1, PR_UNJOINABLE_THREAD, 0) == NULL) {\n-            fprintf(stderr, \"Error creating server thread %d\\n\", index);\n-            PR_Free(id);\n-        }\n+    if (PR_CreateThread(PR_USER_THREAD, _server_thread, id, PR_PRIORITY_NORMAL,\n+                        scope1, PR_UNJOINABLE_THREAD, 0) == NULL) {\n+      fprintf(stderr, \"Error creating server thread %d\\n\", index);\n     }\n+  }\n \n-    PR_EnterMonitor(exit_cv);\n-    while (_thread_exit_count > 0) {\n-        PR_Wait(exit_cv, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_ExitMonitor(exit_cv);\n+  PR_EnterMonitor(exit_cv);\n+  while (_thread_exit_count > 0) {\n+    PR_Wait(exit_cv, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_ExitMonitor(exit_cv);\n \n-    fprintf(stdout, \"TEST COMPLETE!\\n\");\n+  fprintf(stdout, \"TEST COMPLETE!\\n\");\n \n-    tally_results(verbose);\n+  tally_results(verbose);\n }\n \n-static void\n-do_workUU(void)\n-{\n-    scope1 = PR_LOCAL_THREAD;\n-    scope2 = PR_LOCAL_THREAD;\n-    do_work();\n+static void do_workUU(void) {\n+  scope1 = PR_LOCAL_THREAD;\n+  scope2 = PR_LOCAL_THREAD;\n+  do_work();\n }\n \n-static void\n-do_workUK(void)\n-{\n-    scope1 = PR_LOCAL_THREAD;\n-    scope2 = PR_GLOBAL_THREAD;\n-    do_work();\n+static void do_workUK(void) {\n+  scope1 = PR_LOCAL_THREAD;\n+  scope2 = PR_GLOBAL_THREAD;\n+  do_work();\n }\n \n-static void\n-do_workKU(void)\n-{\n-    scope1 = PR_GLOBAL_THREAD;\n-    scope2 = PR_LOCAL_THREAD;\n-    do_work();\n+static void do_workKU(void) {\n+  scope1 = PR_GLOBAL_THREAD;\n+  scope2 = PR_LOCAL_THREAD;\n+  do_work();\n }\n \n-static void\n-do_workKK(void)\n-{\n-    scope1 = PR_GLOBAL_THREAD;\n-    scope2 = PR_GLOBAL_THREAD;\n-    do_work();\n+static void do_workKK(void) {\n+  scope1 = PR_GLOBAL_THREAD;\n+  scope2 = PR_GLOBAL_THREAD;\n+  do_work();\n }\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow();\n \n-    d = (double)PR_IntervalToMicroseconds(stop - start);\n+  d = (double)PR_IntervalToMicroseconds(stop - start);\n \n-    printf(\"%40s: %6.2f usec\\n\", msg, d / _iterations);\n+  printf(\"%40s: %6.2f usec\\n\", msg, d / _iterations);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n+int main(int argc, char** argv) {\n #if defined(XP_UNIX)\n-    int opt;\n-    PR_IMPORT_DATA(char*)\n-    optarg;\n+  int opt;\n+  PR_IMPORT_DATA(char*) optarg;\n #endif\n \n #if defined(XP_UNIX)\n-    while ((opt = getopt(argc, argv, \"c:s:i:t:v\")) != EOF) {\n-        switch (opt) {\n-            case 'i':\n-                _iterations = atoi(optarg);\n-                break;\n-            case 't':\n-                _threads_max = _threads = atoi(optarg);\n-                break;\n-            case 'c':\n-                _client_data = atoi(optarg);\n-                break;\n-            case 's':\n-                _server_data = atoi(optarg);\n-                break;\n-            case 'v':\n-                verbose = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+  while ((opt = getopt(argc, argv, \"c:s:i:t:v\")) != EOF) {\n+    switch (opt) {\n+      case 'i':\n+        _iterations = atoi(optarg);\n+        break;\n+      case 't':\n+        _threads_max = _threads = atoi(optarg);\n+        break;\n+      case 'c':\n+        _client_data = atoi(optarg);\n+        break;\n+      case 's':\n+        _server_data = atoi(optarg);\n+        break;\n+      case 'v':\n+        verbose = 1;\n+        break;\n+      default:\n+        break;\n     }\n+  }\n #endif\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    fprintf(stdout,\n-            \"Running test for %d iterations with %d simultaneous threads.\\n\",\n-            _iterations, _threads);\n-    fprintf(stdout,\n-            \"\\tWill send %d bytes of client data and %d bytes of server data\\n\",\n-            _client_data, _server_data);\n-\n-    if ((exit_cv = PR_NewMonitor()) == NULL) {\n-        fprintf(stderr, \"Error creating monitor for exit cv\\n\");\n-    }\n-    if ((timer_data = (timer_slot_t*)PR_Malloc(2 * _threads *\n-                                               sizeof(timer_slot_t))) == NULL) {\n-        fprintf(stderr, \"error allocating thread time results array\\n\");\n-    }\n-    memset(timer_data, 0, 2 * _threads * sizeof(timer_slot_t));\n-\n-    Measure(do_workUU, \"select loop user/user\");\n-    Measure(do_workUK, \"select loop user/kernel\");\n-    Measure(do_workKU, \"select loop kernel/user\");\n-    Measure(do_workKK, \"select loop kernel/kernel\");\n-\n-    return 0;\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  fprintf(stdout,\n+          \"Running test for %d iterations with %d simultaneous threads.\\n\",\n+          _iterations, _threads);\n+  fprintf(stdout,\n+          \"\\tWill send %d bytes of client data and %d bytes of server data\\n\",\n+          _client_data, _server_data);\n+\n+  if ((exit_cv = PR_NewMonitor()) == NULL) {\n+    fprintf(stderr, \"Error creating monitor for exit cv\\n\");\n+  }\n+  if ((timer_data = (timer_slot_t*)PR_Malloc(2 * _threads *\n+                                             sizeof(timer_slot_t))) == NULL) {\n+    fprintf(stderr, \"error allocating thread time results array\\n\");\n+  }\n+  memset(timer_data, 0, 2 * _threads * sizeof(timer_slot_t));\n+\n+  Measure(do_workUU, \"select loop user/user\");\n+  Measure(do_workUK, \"select loop user/kernel\");\n+  Measure(do_workKU, \"select loop kernel/user\");\n+  Measure(do_workKK, \"select loop kernel/kernel\");\n+\n+  return 0;\n }\n \n-void\n-tally_results(int verbose)\n-{\n-    int index;\n-    unsigned long tot_connect = 0;\n-    unsigned long tot_cl_data = 0;\n-    unsigned long tot_sv_data = 0;\n-    unsigned long tot_close = 0;\n-    unsigned long tot_all = 0;\n-    unsigned long tot_requests = 0;\n-\n-    fprintf(stdout, \"Server results:\\n\\n\");\n-    for (index = 0; index < _threads_max * 2; index += 2) {\n-        if (verbose)\n-            fprintf(stdout, \"server thread %u\\t%u\\t%u\\t%u\\t%u\\t%u\\t%u\\n\", index,\n-                    timer_data[index].requests, timer_data[index].d_connect,\n-                    timer_data[index].d_cl_data, timer_data[index].d_sv_data,\n-                    timer_data[index].d_close, timer_data[index].d_total);\n-\n-        tot_connect += timer_data[index].d_connect / _threads;\n-        tot_cl_data += timer_data[index].d_cl_data / _threads;\n-        tot_sv_data += timer_data[index].d_sv_data / _threads;\n-        tot_close += timer_data[index].d_close / _threads;\n-        tot_all += timer_data[index].d_total / _threads;\n-        tot_requests += timer_data[index].requests / _threads;\n-    }\n-    fprintf(stdout, \"----------\\n\");\n-    fprintf(stdout, \"server per thread totals %u\\t%u\\t%u\\t%u\\t%u\\n\", tot_requests,\n-            tot_connect, tot_cl_data, tot_sv_data, tot_close);\n-    fprintf(stdout, \"server per thread elapsed time %u\\n\", tot_all);\n-    fprintf(stdout, \"----------\\n\");\n-\n-    tot_connect = tot_cl_data = tot_sv_data = tot_close = tot_all = tot_requests =\n-        0;\n-    fprintf(stdout, \"Client results:\\n\\n\");\n-    for (index = 1; index < _threads_max * 2; index += 2) {\n-        if (verbose)\n-            fprintf(stdout, \"client thread %u\\t%u\\t%u\\t%u\\t%u\\t%u\\t%u\\n\", index,\n-                    timer_data[index].requests, timer_data[index].d_connect,\n-                    timer_data[index].d_cl_data, timer_data[index].d_sv_data,\n-                    timer_data[index].d_close, timer_data[index].d_total);\n-\n-        tot_connect += timer_data[index].d_connect / _threads;\n-        tot_cl_data += timer_data[index].d_cl_data / _threads;\n-        tot_sv_data += timer_data[index].d_sv_data / _threads;\n-        tot_close += timer_data[index].d_close / _threads;\n-        tot_all += timer_data[index].d_total / _threads;\n-        tot_requests += timer_data[index].requests / _threads;\n-    }\n-    fprintf(stdout, \"----------\\n\");\n-    fprintf(stdout, \"client per thread totals %u\\t%u\\t%u\\t%u\\t%u\\n\", tot_requests,\n-            tot_connect, tot_cl_data, tot_sv_data, tot_close);\n-    fprintf(stdout, \"client per thread elapsed time %u\\n\", tot_all);\n+void tally_results(int verbose) {\n+  int index;\n+  unsigned long tot_connect = 0;\n+  unsigned long tot_cl_data = 0;\n+  unsigned long tot_sv_data = 0;\n+  unsigned long tot_close = 0;\n+  unsigned long tot_all = 0;\n+  unsigned long tot_requests = 0;\n+\n+  fprintf(stdout, \"Server results:\\n\\n\");\n+  for (index = 0; index < _threads_max * 2; index += 2) {\n+    if (verbose)\n+      fprintf(stdout, \"server thread %u\\t%u\\t%u\\t%u\\t%u\\t%u\\t%u\\n\", index,\n+              timer_data[index].requests, timer_data[index].d_connect,\n+              timer_data[index].d_cl_data, timer_data[index].d_sv_data,\n+              timer_data[index].d_close, timer_data[index].d_total);\n+\n+    tot_connect += timer_data[index].d_connect / _threads;\n+    tot_cl_data += timer_data[index].d_cl_data / _threads;\n+    tot_sv_data += timer_data[index].d_sv_data / _threads;\n+    tot_close += timer_data[index].d_close / _threads;\n+    tot_all += timer_data[index].d_total / _threads;\n+    tot_requests += timer_data[index].requests / _threads;\n+  }\n+  fprintf(stdout, \"----------\\n\");\n+  fprintf(stdout, \"server per thread totals %u\\t%u\\t%u\\t%u\\t%u\\n\", tot_requests,\n+          tot_connect, tot_cl_data, tot_sv_data, tot_close);\n+  fprintf(stdout, \"server per thread elapsed time %u\\n\", tot_all);\n+  fprintf(stdout, \"----------\\n\");\n+\n+  tot_connect = tot_cl_data = tot_sv_data = tot_close = tot_all = tot_requests =\n+      0;\n+  fprintf(stdout, \"Client results:\\n\\n\");\n+  for (index = 1; index < _threads_max * 2; index += 2) {\n+    if (verbose)\n+      fprintf(stdout, \"client thread %u\\t%u\\t%u\\t%u\\t%u\\t%u\\t%u\\n\", index,\n+              timer_data[index].requests, timer_data[index].d_connect,\n+              timer_data[index].d_cl_data, timer_data[index].d_sv_data,\n+              timer_data[index].d_close, timer_data[index].d_total);\n+\n+    tot_connect += timer_data[index].d_connect / _threads;\n+    tot_cl_data += timer_data[index].d_cl_data / _threads;\n+    tot_sv_data += timer_data[index].d_sv_data / _threads;\n+    tot_close += timer_data[index].d_close / _threads;\n+    tot_all += timer_data[index].d_total / _threads;\n+    tot_requests += timer_data[index].requests / _threads;\n+  }\n+  fprintf(stdout, \"----------\\n\");\n+  fprintf(stdout, \"client per thread totals %u\\t%u\\t%u\\t%u\\t%u\\n\", tot_requests,\n+          tot_connect, tot_cl_data, tot_sv_data, tot_close);\n+  fprintf(stdout, \"client per thread elapsed time %u\\n\", tot_all);\n }\ndiff --git a/nspr/pr/tests/selct_er.c b/nspr/pr/tests/selct_er.c\nindex b3d567b..5d5d498 100644\n--- a/nspr/pr/tests/selct_er.c\n+++ b/nspr/pr/tests/selct_er.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -40,155 +41,153 @@\n PRIntn failed_already = 0;\n PRIntn debug_mode;\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc *listenSock1, *listenSock2;\n-    PRFileDesc* badFD;\n-    PRUint16 listenPort1, listenPort2;\n-    PRNetAddr addr;\n-    PR_fd_set readFdSet;\n-    char buf[128];\n-    PRInt32 retVal;\n-\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    if (debug_mode) {\n-        printf(\"This program tests PR_Select with sockets.  Error\\n\");\n-        printf(\"reporting operations are tested.\\n\\n\");\n-    }\n-\n-    /* Create two listening sockets */\n-    if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    addr.inet.family = AF_INET;\n-    addr.inet.ip = PR_htonl(INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    listenPort1 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-\n-    if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    addr.inet.family = AF_INET;\n-    addr.inet.ip = PR_htonl(INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    listenPort2 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    PR_snprintf(buf, sizeof(buf),\n-                \"The server thread is listening on ports %hu and %hu\\n\\n\",\n-                listenPort1, listenPort2);\n-    if (debug_mode) {\n-        printf(\"%s\", buf);\n-    }\n-\n-    /* Set up the fd set */\n-    PR_FD_ZERO(&readFdSet);\n-    PR_FD_SET(listenSock1, &readFdSet);\n-    PR_FD_SET(listenSock2, &readFdSet);\n+int main(int argc, char** argv) {\n+  PRFileDesc *listenSock1, *listenSock2;\n+  PRFileDesc* badFD;\n+  PRUint16 listenPort1, listenPort2;\n+  PRNetAddr addr;\n+  PR_fd_set readFdSet;\n+  char buf[128];\n+  PRInt32 retVal;\n+\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  if (debug_mode) {\n+    printf(\"This program tests PR_Select with sockets.  Error\\n\");\n+    printf(\"reporting operations are tested.\\n\\n\");\n+  }\n+\n+  /* Create two listening sockets */\n+  if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  addr.inet.family = AF_INET;\n+  addr.inet.ip = PR_htonl(INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  listenPort1 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n \n-    /* Testing bad fd */\n-    if (debug_mode) {\n-        printf(\"PR_Select should detect a bad file descriptor\\n\");\n-    }\n-    if ((badFD = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a TCP socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n+  if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  addr.inet.family = AF_INET;\n+  addr.inet.ip = PR_htonl(INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  listenPort2 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  PR_snprintf(buf, sizeof(buf),\n+              \"The server thread is listening on ports %hu and %hu\\n\\n\",\n+              listenPort1, listenPort2);\n+  if (debug_mode) {\n+    printf(\"%s\", buf);\n+  }\n+\n+  /* Set up the fd set */\n+  PR_FD_ZERO(&readFdSet);\n+  PR_FD_SET(listenSock1, &readFdSet);\n+  PR_FD_SET(listenSock2, &readFdSet);\n+\n+  /* Testing bad fd */\n+  if (debug_mode) {\n+    printf(\"PR_Select should detect a bad file descriptor\\n\");\n+  }\n+  if ((badFD = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a TCP socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n \n-    PR_FD_SET(badFD, &readFdSet);\n-    /*\n-     * Make the fd invalid\n-     */\n+  PR_FD_SET(badFD, &readFdSet);\n+  /*\n+   * Make the fd invalid\n+   */\n #if defined(XP_UNIX)\n-    close(PR_FileDesc2NativeHandle(badFD));\n+  close(PR_FileDesc2NativeHandle(badFD));\n #elif defined(WIN32)\n-    closesocket(PR_FileDesc2NativeHandle(badFD));\n+  closesocket(PR_FileDesc2NativeHandle(badFD));\n #else\n-#error \"Unknown architecture\"\n+#  error \"Unknown architecture\"\n #endif\n \n-    retVal =\n-        PR_Select(0 /* unused */, &readFdSet, NULL, NULL, PR_INTERVAL_NO_TIMEOUT);\n-    if (retVal != -1 || PR_GetError() != PR_BAD_DESCRIPTOR_ERROR) {\n-        fprintf(stderr,\n-                \"Failed to detect the bad fd: \"\n-                \"PR_Select returns %d\\n\",\n-                retVal);\n-        if (retVal == -1) {\n-            fprintf(stderr, \"Error %d, oserror %d\\n\", PR_GetError(), PR_GetOSError());\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n+  retVal =\n+      PR_Select(0 /* unused */, &readFdSet, NULL, NULL, PR_INTERVAL_NO_TIMEOUT);\n+  if (retVal != -1 || PR_GetError() != PR_BAD_DESCRIPTOR_ERROR) {\n+    fprintf(stderr,\n+            \"Failed to detect the bad fd: \"\n+            \"PR_Select returns %d\\n\",\n+            retVal);\n+    if (retVal == -1) {\n+      fprintf(stderr, \"Error %d, oserror %d\\n\", PR_GetError(), PR_GetOSError());\n+      failed_already = 1;\n     }\n-    if (debug_mode) {\n-        printf(\"PR_Select detected a bad fd.  Test passed.\\n\\n\");\n-    }\n-    PR_FD_CLR(badFD, &readFdSet);\n-\n-    PR_Cleanup();\n     goto exit_now;\n+  }\n+  if (debug_mode) {\n+    printf(\"PR_Select detected a bad fd.  Test passed.\\n\\n\");\n+  }\n+  PR_FD_CLR(badFD, &readFdSet);\n+\n+  PR_Cleanup();\n+  goto exit_now;\n exit_now:\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/selct_nm.c b/nspr/pr/tests/selct_nm.c\nindex 733197d..70a60b8 100644\n--- a/nspr/pr/tests/selct_nm.c\n+++ b/nspr/pr/tests/selct_nm.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -45,247 +46,243 @@\n PRIntn failed_already = 0;\n PRIntn debug_mode;\n \n-static void\n-clientThreadFunc(void* arg)\n-{\n-    PRUintn port = (PRUintn)arg;\n-    PRFileDesc* sock;\n-    PRNetAddr addr;\n-    char buf[128];\n-    int i;\n+static void clientThreadFunc(void* arg) {\n+  PRUintn port = (PRUintn)arg;\n+  PRFileDesc* sock;\n+  PRNetAddr addr;\n+  char buf[128];\n+  int i;\n \n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.port = PR_htons((PRUint16)port);\n-    addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n-    PR_snprintf(buf, sizeof(buf), \"%hu\", addr.inet.port);\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.port = PR_htons((PRUint16)port);\n+  addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n+  PR_snprintf(buf, sizeof(buf), \"%hu\", addr.inet.port);\n \n-    for (i = 0; i < 5; i++) {\n-        sock = PR_NewTCPSocket();\n-        PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT);\n-        PR_Write(sock, buf, sizeof(buf));\n-        PR_Close(sock);\n-    }\n+  for (i = 0; i < 5; i++) {\n+    sock = PR_NewTCPSocket();\n+    PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT);\n+    PR_Write(sock, buf, sizeof(buf));\n+    PR_Close(sock);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc *listenSock1, *listenSock2;\n-    PRFileDesc *fds0[10], *fds1[10], **fds, **other_fds;\n-    PRIntn nfds;\n-    PRUint16 listenPort1, listenPort2;\n-    PRNetAddr addr;\n-    PR_fd_set readFdSet;\n-    char buf[128];\n-    PRThread* clientThread;\n-    PRInt32 retVal;\n-    PRIntn i, j;\n+int main(int argc, char** argv) {\n+  PRFileDesc *listenSock1, *listenSock2;\n+  PRFileDesc *fds0[10], *fds1[10], **fds, **other_fds;\n+  PRIntn nfds;\n+  PRUint16 listenPort1, listenPort2;\n+  PRNetAddr addr;\n+  PR_fd_set readFdSet;\n+  char buf[128];\n+  PRThread* clientThread;\n+  PRInt32 retVal;\n+  PRIntn i, j;\n \n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    /* main test */\n+  /* main test */\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    if (debug_mode) {\n-        printf(\"This program tests PR_Select with sockets.  \\n\");\n-        printf(\" Normal operation are tested.\\n\\n\");\n-    }\n+  if (debug_mode) {\n+    printf(\"This program tests PR_Select with sockets.  \\n\");\n+    printf(\" Normal operation are tested.\\n\\n\");\n+  }\n \n-    /* Create two listening sockets */\n-    if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    listenPort1 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n+  /* Create two listening sockets */\n+  if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  listenPort1 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n \n-    if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    listenPort2 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    PR_snprintf(buf, sizeof(buf),\n-                \"The server thread is listening on ports %hu and %hu\\n\\n\",\n-                listenPort1, listenPort2);\n-    if (debug_mode) {\n-        printf(\"%s\", buf);\n-    }\n+  if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  listenPort2 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  PR_snprintf(buf, sizeof(buf),\n+              \"The server thread is listening on ports %hu and %hu\\n\\n\",\n+              listenPort1, listenPort2);\n+  if (debug_mode) {\n+    printf(\"%s\", buf);\n+  }\n \n-    clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n-                                   (void*)listenPort1, PR_PRIORITY_NORMAL,\n-                                   PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    if (clientThread == NULL) {\n-        fprintf(stderr, \"can't create thread\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n+  clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n+                                 (void*)listenPort1, PR_PRIORITY_NORMAL,\n+                                 PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  if (clientThread == NULL) {\n+    fprintf(stderr, \"can't create thread\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n \n-    clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n-                                   (void*)listenPort2, PR_PRIORITY_NORMAL,\n-                                   PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n-    if (clientThread == NULL) {\n-        fprintf(stderr, \"can't create thread\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n+  clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,\n+                                 (void*)listenPort2, PR_PRIORITY_NORMAL,\n+                                 PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  if (clientThread == NULL) {\n+    fprintf(stderr, \"can't create thread\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n \n-    if (debug_mode) {\n-        printf(\"Two client threads are created.  Each of them will\\n\");\n-        printf(\"send data to one of the two ports the server is listening on.\\n\");\n-        printf(\"The data they send is the port number.  Each of them send\\n\");\n-        printf(\"the data five times, so you should see ten lines below,\\n\");\n-        printf(\"interleaved in an arbitrary order.\\n\");\n-    }\n-    /* set up the fd array */\n-    fds = fds0;\n-    other_fds = fds1;\n-    fds[0] = listenSock1;\n-    fds[1] = listenSock2;\n-    nfds = 2;\n-    /* Set up the fd set */\n-    PR_FD_ZERO(&readFdSet);\n-    PR_FD_SET(listenSock1, &readFdSet);\n-    PR_FD_SET(listenSock2, &readFdSet);\n+  if (debug_mode) {\n+    printf(\"Two client threads are created.  Each of them will\\n\");\n+    printf(\"send data to one of the two ports the server is listening on.\\n\");\n+    printf(\"The data they send is the port number.  Each of them send\\n\");\n+    printf(\"the data five times, so you should see ten lines below,\\n\");\n+    printf(\"interleaved in an arbitrary order.\\n\");\n+  }\n+  /* set up the fd array */\n+  fds = fds0;\n+  other_fds = fds1;\n+  fds[0] = listenSock1;\n+  fds[1] = listenSock2;\n+  nfds = 2;\n+  /* Set up the fd set */\n+  PR_FD_ZERO(&readFdSet);\n+  PR_FD_SET(listenSock1, &readFdSet);\n+  PR_FD_SET(listenSock2, &readFdSet);\n \n-    /* 20 events total */\n-    i = 0;\n-    while (i < 20) {\n-        PRFileDesc** tmp;\n-        int nextIndex;\n-        int nEvents = 0;\n+  /* 20 events total */\n+  i = 0;\n+  while (i < 20) {\n+    PRFileDesc** tmp;\n+    int nextIndex;\n+    int nEvents = 0;\n \n-        retVal = PR_Select(0 /* unused */, &readFdSet, NULL, NULL,\n-                           PR_INTERVAL_NO_TIMEOUT);\n-        PR_ASSERT(retVal != 0); /* no timeout */\n-        if (retVal == -1) {\n-            fprintf(stderr, \"PR_Select failed (%d, %d)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            failed_already = 1;\n-            goto exit_now;\n-        }\n+    retVal = PR_Select(0 /* unused */, &readFdSet, NULL, NULL,\n+                       PR_INTERVAL_NO_TIMEOUT);\n+    PR_ASSERT(retVal != 0); /* no timeout */\n+    if (retVal == -1) {\n+      fprintf(stderr, \"PR_Select failed (%d, %d)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      failed_already = 1;\n+      goto exit_now;\n+    }\n \n-        nextIndex = 2;\n-        /* the two listening sockets */\n-        for (j = 0; j < 2; j++) {\n-            other_fds[j] = fds[j];\n-            if (PR_FD_ISSET(fds[j], &readFdSet)) {\n-                PRFileDesc* sock;\n+    nextIndex = 2;\n+    /* the two listening sockets */\n+    for (j = 0; j < 2; j++) {\n+      other_fds[j] = fds[j];\n+      if (PR_FD_ISSET(fds[j], &readFdSet)) {\n+        PRFileDesc* sock;\n \n-                nEvents++;\n-                sock = PR_Accept(fds[j], NULL, PR_INTERVAL_NO_TIMEOUT);\n-                if (sock == NULL) {\n-                    fprintf(stderr, \"PR_Accept() failed\\n\");\n-                    failed_already = 1;\n-                    goto exit_now;\n-                }\n-                other_fds[nextIndex] = sock;\n-                PR_FD_SET(sock, &readFdSet);\n-                nextIndex++;\n-            }\n-            PR_FD_SET(fds[j], &readFdSet);\n+        nEvents++;\n+        sock = PR_Accept(fds[j], NULL, PR_INTERVAL_NO_TIMEOUT);\n+        if (sock == NULL) {\n+          fprintf(stderr, \"PR_Accept() failed\\n\");\n+          failed_already = 1;\n+          goto exit_now;\n         }\n+        other_fds[nextIndex] = sock;\n+        PR_FD_SET(sock, &readFdSet);\n+        nextIndex++;\n+      }\n+      PR_FD_SET(fds[j], &readFdSet);\n+    }\n \n-        for (j = 2; j < nfds; j++) {\n-            if (PR_FD_ISSET(fds[j], &readFdSet)) {\n-                PRInt32 nBytes;\n+    for (j = 2; j < nfds; j++) {\n+      if (PR_FD_ISSET(fds[j], &readFdSet)) {\n+        PRInt32 nBytes;\n \n-                PR_FD_CLR(fds[j], &readFdSet);\n-                nEvents++;\n-                nBytes = PR_Read(fds[j], buf, sizeof(buf));\n-                if (nBytes == -1) {\n-                    fprintf(stderr, \"PR_Read() failed\\n\");\n-                    failed_already = 1;\n-                    goto exit_now;\n-                }\n-                /* Just to be safe */\n-                buf[127] = '\\0';\n-                PR_Close(fds[j]);\n-                if (debug_mode) {\n-                    printf(\"The server received \\\"%s\\\" from a client\\n\", buf);\n-                }\n-            } else {\n-                PR_FD_SET(fds[j], &readFdSet);\n-                other_fds[nextIndex] = fds[j];\n-                nextIndex++;\n-            }\n+        PR_FD_CLR(fds[j], &readFdSet);\n+        nEvents++;\n+        nBytes = PR_Read(fds[j], buf, sizeof(buf));\n+        if (nBytes == -1) {\n+          fprintf(stderr, \"PR_Read() failed\\n\");\n+          failed_already = 1;\n+          goto exit_now;\n         }\n-\n-        PR_ASSERT(retVal == nEvents);\n-        /* swap */\n-        tmp = fds;\n-        fds = other_fds;\n-        other_fds = tmp;\n-        nfds = nextIndex;\n-        i += nEvents;\n+        /* Just to be safe */\n+        buf[127] = '\\0';\n+        PR_Close(fds[j]);\n+        if (debug_mode) {\n+          printf(\"The server received \\\"%s\\\" from a client\\n\", buf);\n+        }\n+      } else {\n+        PR_FD_SET(fds[j], &readFdSet);\n+        other_fds[nextIndex] = fds[j];\n+        nextIndex++;\n+      }\n     }\n \n-    if (debug_mode) {\n-        printf(\"Test passed\\n\");\n-    }\n+    PR_ASSERT(retVal == nEvents);\n+    /* swap */\n+    tmp = fds;\n+    fds = other_fds;\n+    other_fds = tmp;\n+    nfds = nextIndex;\n+    i += nEvents;\n+  }\n \n-    PR_Cleanup();\n-    goto exit_now;\n+  if (debug_mode) {\n+    printf(\"Test passed\\n\");\n+  }\n+\n+  PR_Cleanup();\n+  goto exit_now;\n exit_now:\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/selct_to.c b/nspr/pr/tests/selct_to.c\nindex 9c31cf2..7e6b944 100644\n--- a/nspr/pr/tests/selct_to.c\n+++ b/nspr/pr/tests/selct_to.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -46,135 +47,133 @@\n PRIntn failed_already = 0;\n PRIntn debug_mode;\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc *listenSock1, *listenSock2;\n-    PRUint16 listenPort1, listenPort2;\n-    PRNetAddr addr;\n-    PR_fd_set readFdSet;\n-    char buf[128];\n-    PRInt32 retVal;\n-\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  PRFileDesc *listenSock1, *listenSock2;\n+  PRUint16 listenPort1, listenPort2;\n+  PRNetAddr addr;\n+  PR_fd_set readFdSet;\n+  char buf[128];\n+  PRInt32 retVal;\n+\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    if (debug_mode) {\n-        printf(\"This program tests PR_Select with sockets.  Timeout \\n\");\n-        printf(\"operations are tested.\\n\\n\");\n-    }\n-\n-    /* Create two listening sockets */\n-    if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    listenPort1 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-\n-    if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"Can't create a new TCP socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    addr.inet.port = PR_htons(0);\n-    if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't bind socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n-    }\n-    listenPort2 = PR_ntohs(addr.inet.port);\n-    if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"Can't listen on a socket\\n\");\n-        failed_already = 1;\n-        goto exit_now;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  if (debug_mode) {\n+    printf(\"This program tests PR_Select with sockets.  Timeout \\n\");\n+    printf(\"operations are tested.\\n\\n\");\n+  }\n+\n+  /* Create two listening sockets */\n+  if ((listenSock1 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  if (PR_GetSockName(listenSock1, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  listenPort1 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock1, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+\n+  if ((listenSock2 = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"Can't create a new TCP socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  addr.inet.port = PR_htons(0);\n+  if (PR_Bind(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't bind socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  if (PR_GetSockName(listenSock2, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  listenPort2 = PR_ntohs(addr.inet.port);\n+  if (PR_Listen(listenSock2, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"Can't listen on a socket\\n\");\n+    failed_already = 1;\n+    goto exit_now;\n+  }\n+  PR_snprintf(buf, sizeof(buf),\n+              \"The server thread is listening on ports %hu and %hu\\n\\n\",\n+              listenPort1, listenPort2);\n+  if (debug_mode) {\n+    printf(\"%s\", buf);\n+  }\n+\n+  /* Set up the fd set */\n+  PR_FD_ZERO(&readFdSet);\n+  PR_FD_SET(listenSock1, &readFdSet);\n+  PR_FD_SET(listenSock2, &readFdSet);\n+\n+  /* Testing timeout */\n+  if (debug_mode) {\n+    printf(\"PR_Select should time out in 5 seconds\\n\");\n+  }\n+  retVal = PR_Select(0 /* unused */, &readFdSet, NULL, NULL,\n+                     PR_SecondsToInterval(5));\n+  if (retVal != 0) {\n     PR_snprintf(buf, sizeof(buf),\n-                \"The server thread is listening on ports %hu and %hu\\n\\n\",\n-                listenPort1, listenPort2);\n-    if (debug_mode) {\n-        printf(\"%s\", buf);\n+                \"PR_Select should time out and return 0, but it returns %ld\\n\",\n+                retVal);\n+    fprintf(stderr, \"%s\", buf);\n+    if (retVal == -1) {\n+      fprintf(stderr, \"Error %d, oserror %d\\n\", PR_GetError(), PR_GetOSError());\n+      failed_already = 1;\n     }\n+    goto exit_now;\n+  }\n+  if (debug_mode) {\n+    printf(\"PR_Select timed out.  Test passed.\\n\\n\");\n+  }\n \n-    /* Set up the fd set */\n-    PR_FD_ZERO(&readFdSet);\n-    PR_FD_SET(listenSock1, &readFdSet);\n-    PR_FD_SET(listenSock2, &readFdSet);\n-\n-    /* Testing timeout */\n-    if (debug_mode) {\n-        printf(\"PR_Select should time out in 5 seconds\\n\");\n-    }\n-    retVal = PR_Select(0 /* unused */, &readFdSet, NULL, NULL,\n-                       PR_SecondsToInterval(5));\n-    if (retVal != 0) {\n-        PR_snprintf(buf, sizeof(buf),\n-                    \"PR_Select should time out and return 0, but it returns %ld\\n\",\n-                    retVal);\n-        fprintf(stderr, \"%s\", buf);\n-        if (retVal == -1) {\n-            fprintf(stderr, \"Error %d, oserror %d\\n\", PR_GetError(), PR_GetOSError());\n-            failed_already = 1;\n-        }\n-        goto exit_now;\n-    }\n-    if (debug_mode) {\n-        printf(\"PR_Select timed out.  Test passed.\\n\\n\");\n-    }\n-\n-    PR_Cleanup();\n+  PR_Cleanup();\n \n exit_now:\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/select2.c b/nspr/pr/tests/select2.c\nindex 46ea74d..55c97a8 100644\n--- a/nspr/pr/tests/select2.c\n+++ b/nspr/pr/tests/select2.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -51,324 +52,310 @@ PRInt32 count;\n **\n ***********************************************************************/\n \n-static void\n-Test_Result(int result)\n-{\n-    switch (result) {\n-        case PASS:\n-            printf(\"PASS\\n\");\n-            break;\n-        case FAIL:\n-            printf(\"FAIL\\n\");\n-            break;\n-        default:\n-            printf(\"NOSTATUS\\n\");\n-            break;\n-    }\n+static void Test_Result(int result) {\n+  switch (result) {\n+    case PASS:\n+      printf(\"PASS\\n\");\n+      break;\n+    case FAIL:\n+      printf(\"FAIL\\n\");\n+      break;\n+    default:\n+      printf(\"NOSTATUS\\n\");\n+      break;\n+  }\n }\n \n-static void\n-EmptyPRSelect(void)\n-{\n-    PRInt32 index = count;\n-    PRInt32 rv;\n+static void EmptyPRSelect(void) {\n+  PRInt32 index = count;\n+  PRInt32 rv;\n \n-    for (; index--;) {\n-        rv = PR_Select(0, NULL, NULL, NULL, PR_INTERVAL_NO_WAIT);\n-    }\n+  for (; index--;) {\n+    rv = PR_Select(0, NULL, NULL, NULL, PR_INTERVAL_NO_WAIT);\n+  }\n }\n \n-static void\n-EmptyNativeSelect(void)\n-{\n-    PRInt32 rv;\n-    PRInt32 index = count;\n-    struct timeval timeout;\n+static void EmptyNativeSelect(void) {\n+  PRInt32 rv;\n+  PRInt32 index = count;\n+  struct timeval timeout;\n \n-    timeout.tv_sec = timeout.tv_usec = 0;\n-    for (; index--;) {\n-        rv = select(0, NULL, NULL, NULL, &timeout);\n-    }\n+  timeout.tv_sec = timeout.tv_usec = 0;\n+  for (; index--;) {\n+    rv = select(0, NULL, NULL, NULL, &timeout);\n+  }\n }\n \n-static void\n-PRSelectTest(void)\n-{\n-    PRFileDesc* listenSocket;\n-    PRNetAddr serverAddr;\n-\n-    if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n-        if (debug_mode) {\n-            printf(\"\\tServer error creating listen socket\\n\");\n-        }\n-        return;\n+static void PRSelectTest(void) {\n+  PRFileDesc* listenSocket;\n+  PRNetAddr serverAddr;\n+\n+  if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error creating listen socket\\n\");\n     }\n+    return;\n+  }\n+\n+  memset(&serverAddr, 0, sizeof(PRNetAddr));\n+  serverAddr.inet.family = AF_INET;\n+  serverAddr.inet.port = PR_htons(PORT);\n+  serverAddr.inet.ip = PR_htonl(INADDR_ANY);\n \n-    memset(&serverAddr, 0, sizeof(PRNetAddr));\n-    serverAddr.inet.family = AF_INET;\n-    serverAddr.inet.port = PR_htons(PORT);\n-    serverAddr.inet.ip = PR_htonl(INADDR_ANY);\n-\n-    if (PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tServer error binding to server address\\n\");\n-        }\n-        PR_Close(listenSocket);\n-        return;\n+  if (PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error binding to server address\\n\");\n     }\n+    PR_Close(listenSocket);\n+    return;\n+  }\n \n-    if (PR_Listen(listenSocket, 128) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tServer error listening to server socket\\n\");\n-        }\n-        PR_Close(listenSocket);\n-        return;\n+  if (PR_Listen(listenSocket, 128) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error listening to server socket\\n\");\n     }\n+    PR_Close(listenSocket);\n+    return;\n+  }\n+  if (debug_mode) {\n+    printf(\"Listening on port %d\\n\", PORT);\n+  }\n+\n+  {\n+    PRFileDesc* newSock;\n+    PRNetAddr rAddr;\n+    PRInt32 loops = 0;\n+    PR_fd_set rdset;\n+    PRInt32 rv;\n+    PRInt32 bytesRead;\n+    char buf[11];\n+\n+    loops++;\n+\n     if (debug_mode) {\n-        printf(\"Listening on port %d\\n\", PORT);\n+      printf(\"Going into accept\\n\");\n     }\n \n-    {\n-        PRFileDesc* newSock;\n-        PRNetAddr rAddr;\n-        PRInt32 loops = 0;\n-        PR_fd_set rdset;\n-        PRInt32 rv;\n-        PRInt32 bytesRead;\n-        char buf[11];\n-\n-        loops++;\n-\n-        if (debug_mode) {\n-            printf(\"Going into accept\\n\");\n-        }\n-\n-        newSock = PR_Accept(listenSocket, &rAddr, PR_INTERVAL_NO_TIMEOUT);\n-\n-        if (newSock) {\n-            if (debug_mode) {\n-                printf(\"Got connection!\\n\");\n-            }\n-        } else {\n-            if (debug_mode) {\n-                printf(\"PR_Accept failed: error code %d\\n\", PR_GetError());\n-            } else {\n-                Test_Result(FAIL);\n-            }\n-        }\n-\n-        PR_FD_ZERO(&rdset);\n-        PR_FD_SET(newSock, &rdset);\n-\n-        if (debug_mode) {\n-            printf(\"Going into select \\n\");\n-        }\n-\n-        rv = PR_Select(0, &rdset, 0, 0, PR_INTERVAL_NO_TIMEOUT);\n-\n-        if (debug_mode) {\n-            printf(\"return from select is %d\\n\", rv);\n-        }\n-\n-        if (PR_FD_ISSET(newSock, &rdset)) {\n-            if (debug_mode) {\n-                printf(\"I can't believe it- the socket is ready okay!\\n\");\n-            }\n-        } else {\n-            if (debug_mode) {\n-                printf(\"Damn; the select test failed...\\n\");\n-            } else {\n-                Test_Result(FAIL);\n-            }\n-        }\n-\n-        strcpy(buf, \"XXXXXXXXXX\");\n-        bytesRead = PR_Recv(newSock, buf, 10, 0, PR_INTERVAL_NO_TIMEOUT);\n-        buf[10] = '\\0';\n-\n-        if (debug_mode) {\n-            printf(\"Recv completed with %d bytes, %s\\n\", bytesRead, buf);\n-        }\n-\n-        PR_Close(newSock);\n+    newSock = PR_Accept(listenSocket, &rAddr, PR_INTERVAL_NO_TIMEOUT);\n+\n+    if (newSock) {\n+      if (debug_mode) {\n+        printf(\"Got connection!\\n\");\n+      }\n+    } else {\n+      if (debug_mode) {\n+        printf(\"PR_Accept failed: error code %d\\n\", PR_GetError());\n+      } else {\n+        Test_Result(FAIL);\n+      }\n     }\n+\n+    PR_FD_ZERO(&rdset);\n+    PR_FD_SET(newSock, &rdset);\n+\n+    if (debug_mode) {\n+      printf(\"Going into select \\n\");\n+    }\n+\n+    rv = PR_Select(0, &rdset, 0, 0, PR_INTERVAL_NO_TIMEOUT);\n+\n+    if (debug_mode) {\n+      printf(\"return from select is %d\\n\", rv);\n+    }\n+\n+    if (PR_FD_ISSET(newSock, &rdset)) {\n+      if (debug_mode) {\n+        printf(\"I can't believe it- the socket is ready okay!\\n\");\n+      }\n+    } else {\n+      if (debug_mode) {\n+        printf(\"Damn; the select test failed...\\n\");\n+      } else {\n+        Test_Result(FAIL);\n+      }\n+    }\n+\n+    strcpy(buf, \"XXXXXXXXXX\");\n+    bytesRead = PR_Recv(newSock, buf, 10, 0, PR_INTERVAL_NO_TIMEOUT);\n+    buf[10] = '\\0';\n+\n+    if (debug_mode) {\n+      printf(\"Recv completed with %d bytes, %s\\n\", bytesRead, buf);\n+    }\n+\n+    PR_Close(newSock);\n+  }\n }\n \n #if defined(XP_UNIX)\n \n-static void\n-NativeSelectTest(void)\n-{\n-    PRFileDesc* listenSocket;\n-    PRNetAddr serverAddr;\n-\n-    if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n-        if (debug_mode) {\n-            printf(\"\\tServer error creating listen socket\\n\");\n-        }\n-        return;\n+static void NativeSelectTest(void) {\n+  PRFileDesc* listenSocket;\n+  PRNetAddr serverAddr;\n+\n+  if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error creating listen socket\\n\");\n+    }\n+    return;\n+  }\n+\n+  memset(&serverAddr, 0, sizeof(PRNetAddr));\n+  serverAddr.inet.family = AF_INET;\n+  serverAddr.inet.port = PR_htons(PORT);\n+  serverAddr.inet.ip = PR_htonl(INADDR_ANY);\n+\n+  if (PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error binding to server address\\n\");\n+    }\n+    PR_Close(listenSocket);\n+    return;\n+  }\n+\n+  if (PR_Listen(listenSocket, 128) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error listening to server socket\\n\");\n     }\n+    PR_Close(listenSocket);\n+    return;\n+  }\n+  if (debug_mode) {\n+    printf(\"Listening on port %d\\n\", PORT);\n+  }\n+\n+  {\n+    PRIntn osfd;\n+    char buf[11];\n+    fd_set rdset;\n+    PRNetAddr rAddr;\n+    PRFileDesc* newSock;\n+    struct timeval timeout;\n+    PRInt32 bytesRead, rv, loops = 0;\n+\n+    loops++;\n+\n+    if (debug_mode) {\n+      printf(\"Going into accept\\n\");\n+    }\n+\n+    newSock = PR_Accept(listenSocket, &rAddr, PR_INTERVAL_NO_TIMEOUT);\n \n-    memset(&serverAddr, 0, sizeof(PRNetAddr));\n-    serverAddr.inet.family = AF_INET;\n-    serverAddr.inet.port = PR_htons(PORT);\n-    serverAddr.inet.ip = PR_htonl(INADDR_ANY);\n-\n-    if (PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tServer error binding to server address\\n\");\n-        }\n-        PR_Close(listenSocket);\n-        return;\n+    if (newSock) {\n+      if (debug_mode) {\n+        printf(\"Got connection!\\n\");\n+      }\n+    } else {\n+      if (debug_mode) {\n+        printf(\"PR_Accept failed: error code %d\\n\", PR_GetError());\n+      } else {\n+        Test_Result(FAIL);\n+      }\n     }\n \n-    if (PR_Listen(listenSocket, 128) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tServer error listening to server socket\\n\");\n-        }\n-        PR_Close(listenSocket);\n-        return;\n+    osfd = PR_FileDesc2NativeHandle(newSock);\n+    FD_ZERO(&rdset);\n+    FD_SET(osfd, &rdset);\n+\n+    if (debug_mode) {\n+      printf(\"Going into select \\n\");\n     }\n+\n+    timeout.tv_sec = 2;\n+    timeout.tv_usec = 0;\n+    rv = select(osfd + 1, &rdset, NULL, NULL, &timeout);\n+\n     if (debug_mode) {\n-        printf(\"Listening on port %d\\n\", PORT);\n+      printf(\"return from select is %d\\n\", rv);\n+    }\n+\n+    if (FD_ISSET(osfd, &rdset)) {\n+      if (debug_mode) {\n+        printf(\"I can't believe it- the socket is ready okay!\\n\");\n+      }\n+    } else {\n+      if (debug_mode) {\n+        printf(\"Damn; the select test failed...\\n\");\n+      } else {\n+        Test_Result(FAIL);\n+      }\n     }\n \n-    {\n-        PRIntn osfd;\n-        char buf[11];\n-        fd_set rdset;\n-        PRNetAddr rAddr;\n-        PRFileDesc* newSock;\n-        struct timeval timeout;\n-        PRInt32 bytesRead, rv, loops = 0;\n-\n-        loops++;\n-\n-        if (debug_mode) {\n-            printf(\"Going into accept\\n\");\n-        }\n-\n-        newSock = PR_Accept(listenSocket, &rAddr, PR_INTERVAL_NO_TIMEOUT);\n-\n-        if (newSock) {\n-            if (debug_mode) {\n-                printf(\"Got connection!\\n\");\n-            }\n-        } else {\n-            if (debug_mode) {\n-                printf(\"PR_Accept failed: error code %d\\n\", PR_GetError());\n-            } else {\n-                Test_Result(FAIL);\n-            }\n-        }\n-\n-        osfd = PR_FileDesc2NativeHandle(newSock);\n-        FD_ZERO(&rdset);\n-        FD_SET(osfd, &rdset);\n-\n-        if (debug_mode) {\n-            printf(\"Going into select \\n\");\n-        }\n-\n-        timeout.tv_sec = 2;\n-        timeout.tv_usec = 0;\n-        rv = select(osfd + 1, &rdset, NULL, NULL, &timeout);\n-\n-        if (debug_mode) {\n-            printf(\"return from select is %d\\n\", rv);\n-        }\n-\n-        if (FD_ISSET(osfd, &rdset)) {\n-            if (debug_mode) {\n-                printf(\"I can't believe it- the socket is ready okay!\\n\");\n-            }\n-        } else {\n-            if (debug_mode) {\n-                printf(\"Damn; the select test failed...\\n\");\n-            } else {\n-                Test_Result(FAIL);\n-            }\n-        }\n-\n-        strcpy(buf, \"XXXXXXXXXX\");\n-        bytesRead = PR_Recv(newSock, buf, 10, 0, PR_INTERVAL_NO_TIMEOUT);\n-        buf[10] = '\\0';\n-\n-        if (debug_mode) {\n-            printf(\"Recv completed with %d bytes, %s\\n\", bytesRead, buf);\n-        }\n-\n-        PR_Close(newSock);\n+    strcpy(buf, \"XXXXXXXXXX\");\n+    bytesRead = PR_Recv(newSock, buf, 10, 0, PR_INTERVAL_NO_TIMEOUT);\n+    buf[10] = '\\0';\n+\n+    if (debug_mode) {\n+      printf(\"Recv completed with %d bytes, %s\\n\", bytesRead, buf);\n     }\n \n+    PR_Close(newSock);\n+  }\n+\n } /* NativeSelectTest */\n \n #endif /* defined(XP_UNIX) */\n \n /************************************************************************/\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n-    PRInt32 tot;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n+  PRInt32 tot;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow();\n \n-    d = (double)PR_IntervalToMicroseconds(stop - start);\n-    tot = PR_IntervalToMilliseconds(stop - start);\n+  d = (double)PR_IntervalToMicroseconds(stop - start);\n+  tot = PR_IntervalToMilliseconds(stop - start);\n \n-    if (debug_mode) {\n-        printf(\"%40s: %6.2f usec avg, %d msec total\\n\", msg, d / count, tot);\n-    }\n+  if (debug_mode) {\n+    printf(\"%40s: %6.2f usec avg, %d msec total\\n\", msg, d / count, tot);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n+  }\n+  PL_DestroyOptState(opt);\n \n-    /* main test */\n+  /* main test */\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    if (argc > 2) {\n-        count = atoi(argv[2]);\n-    } else {\n-        count = DEFAULT_COUNT;\n-    }\n+  if (argc > 2) {\n+    count = atoi(argv[2]);\n+  } else {\n+    count = DEFAULT_COUNT;\n+  }\n \n #if defined(XP_UNIX)\n-    Measure(NativeSelectTest, \"time to call 1 element select()\");\n+  Measure(NativeSelectTest, \"time to call 1 element select()\");\n #endif\n-    Measure(EmptyPRSelect, \"time to call Empty PR_select()\");\n-    Measure(EmptyNativeSelect, \"time to call Empty select()\");\n-    Measure(PRSelectTest, \"time to call 1 element PR_select()\");\n-\n-    if (!debug_mode) {\n-        Test_Result(NOSTATUS);\n-    }\n-    PR_Cleanup();\n+  Measure(EmptyPRSelect, \"time to call Empty PR_select()\");\n+  Measure(EmptyNativeSelect, \"time to call Empty select()\");\n+  Measure(PRSelectTest, \"time to call 1 element PR_select()\");\n+\n+  if (!debug_mode) {\n+    Test_Result(NOSTATUS);\n+  }\n+  PR_Cleanup();\n }\ndiff --git a/nspr/pr/tests/selintr.c b/nspr/pr/tests/selintr.c\nindex 4191835..951e5e6 100644\n--- a/nspr/pr/tests/selintr.c\n+++ b/nspr/pr/tests/selintr.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -17,34 +18,28 @@\n  * This test is applicable to Unix only.\n  */\n \n-int\n-main()\n-{\n-    return 0;\n-}\n+int main() { return 0; }\n \n #else /* XP_UNIX */\n \n-#include \"nspr.h\"\n+#  include \"nspr.h\"\n \n-#include <sys/time.h>\n-#include <stdio.h>\n+#  include <sys/time.h>\n+#  include <stdio.h>\n \n-int\n-main(int argc, char** argv)\n-{\n-    struct timeval timeout;\n-    int rv;\n+int main(int argc, char** argv) {\n+  struct timeval timeout;\n+  int rv;\n \n-    PR_SetError(0, 0); /* force NSPR to initialize */\n-    PR_EnableClockInterrupts();\n+  PR_SetError(0, 0); /* force NSPR to initialize */\n+  PR_EnableClockInterrupts();\n \n-    /* 2 seconds timeout */\n-    timeout.tv_sec = 2;\n-    timeout.tv_usec = 0;\n-    rv = select(1, NULL, NULL, NULL, &timeout);\n-    printf(\"select returned %d\\n\", rv);\n-    return 0;\n+  /* 2 seconds timeout */\n+  timeout.tv_sec = 2;\n+  timeout.tv_usec = 0;\n+  rv = select(1, NULL, NULL, NULL, &timeout);\n+  printf(\"select returned %d\\n\", rv);\n+  return 0;\n }\n \n #endif /* XP_UNIX */\ndiff --git a/nspr/pr/tests/sem.c b/nspr/pr/tests/sem.c\nindex de61552..bf224fd 100644\n--- a/nspr/pr/tests/sem.c\n+++ b/nspr/pr/tests/sem.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -54,53 +55,49 @@ static PRUintn stdinBufIdx = 0;\n static PRUintn stdoutBufIdx = 0;\n static PRStatus finalResult = PR_SUCCESS;\n \n-static size_t\n-dread(PRUintn device, char* buf, size_t bufSize)\n-{\n-    PRUintn i;\n+static size_t dread(PRUintn device, char* buf, size_t bufSize) {\n+  PRUintn i;\n \n-    /* during first read call, initialize the stdinBuf buffer*/\n-    if (stdinBufIdx == 0) {\n-        for (i = 0; i < SBSIZE; i++) {\n-            stdinBuf[i] = i;\n-        }\n+  /* during first read call, initialize the stdinBuf buffer*/\n+  if (stdinBufIdx == 0) {\n+    for (i = 0; i < SBSIZE; i++) {\n+      stdinBuf[i] = i;\n     }\n+  }\n \n-    /* now copy data from stdinBuf to the given buffer upto bufSize */\n-    for (i = 0; i < bufSize; i++) {\n-        if (stdinBufIdx == SBSIZE) {\n-            break;\n-        }\n-        buf[i] = stdinBuf[stdinBufIdx++];\n+  /* now copy data from stdinBuf to the given buffer upto bufSize */\n+  for (i = 0; i < bufSize; i++) {\n+    if (stdinBufIdx == SBSIZE) {\n+      break;\n     }\n+    buf[i] = stdinBuf[stdinBufIdx++];\n+  }\n \n-    return i;\n+  return i;\n }\n \n-static size_t\n-dwrite(PRUintn device, char* buf, size_t bufSize)\n-{\n-    PRUintn i, j;\n+static size_t dwrite(PRUintn device, char* buf, size_t bufSize) {\n+  PRUintn i, j;\n \n-    /* copy data from the given buffer upto bufSize to stdoutBuf */\n-    for (i = 0; i < bufSize; i++) {\n-        if (stdoutBufIdx == SBSIZE) {\n-            break;\n-        }\n-        stdoutBuf[stdoutBufIdx++] = buf[i];\n+  /* copy data from the given buffer upto bufSize to stdoutBuf */\n+  for (i = 0; i < bufSize; i++) {\n+    if (stdoutBufIdx == SBSIZE) {\n+      break;\n     }\n+    stdoutBuf[stdoutBufIdx++] = buf[i];\n+  }\n \n-    /* during last write call, compare the two buffers */\n-    if (stdoutBufIdx == SBSIZE)\n-        for (j = 0; j < SBSIZE; j++)\n-            if (stdinBuf[j] != stdoutBuf[j]) {\n-                if (debug_mode) {\n-                    printf(\"data mismatch for index= %d \\n\", j);\n-                }\n-                finalResult = PR_FAILURE;\n-            }\n-\n-    return i;\n+  /* during last write call, compare the two buffers */\n+  if (stdoutBufIdx == SBSIZE)\n+    for (j = 0; j < SBSIZE; j++)\n+      if (stdinBuf[j] != stdoutBuf[j]) {\n+        if (debug_mode) {\n+          printf(\"data mismatch for index= %d \\n\", j);\n+        }\n+        finalResult = PR_FAILURE;\n+      }\n+\n+  return i;\n }\n \n /*------------------ Following is the real test program ---------*/\n@@ -117,103 +114,97 @@ PRSemaphore* fullBufs;  /* number of buffers that are full */\n #define BSIZE 100\n \n struct {\n-    char data[BSIZE];\n-    PRUintn nbytes; /* number of bytes in this buffer */\n+  char data[BSIZE];\n+  PRUintn nbytes; /* number of bytes in this buffer */\n } buf[2];\n \n-static void PR_CALLBACK\n-reader(void* arg)\n-{\n-    PRUintn i = 0;\n-    size_t nbytes;\n-\n-    do {\n-        (void)PR_WaitSem(emptyBufs);\n-        nbytes = dread(0, buf[i].data, BSIZE);\n-        buf[i].nbytes = nbytes;\n-        PR_PostSem(fullBufs);\n-        i = (i + 1) % 2;\n-    } while (nbytes > 0);\n+static void PR_CALLBACK reader(void* arg) {\n+  PRUintn i = 0;\n+  size_t nbytes;\n+\n+  do {\n+    (void)PR_WaitSem(emptyBufs);\n+    nbytes = dread(0, buf[i].data, BSIZE);\n+    buf[i].nbytes = nbytes;\n+    PR_PostSem(fullBufs);\n+    i = (i + 1) % 2;\n+  } while (nbytes > 0);\n }\n \n-static void\n-writer(void)\n-{\n-    PRUintn i = 0;\n-    size_t nbytes;\n-\n-    do {\n-        (void)PR_WaitSem(fullBufs);\n-        nbytes = buf[i].nbytes;\n-        if (nbytes > 0) {\n-            nbytes = dwrite(1, buf[i].data, nbytes);\n-            PR_PostSem(emptyBufs);\n-            i = (i + 1) % 2;\n-        }\n-    } while (nbytes > 0);\n+static void writer(void) {\n+  PRUintn i = 0;\n+  size_t nbytes;\n+\n+  do {\n+    (void)PR_WaitSem(fullBufs);\n+    nbytes = buf[i].nbytes;\n+    if (nbytes > 0) {\n+      nbytes = dwrite(1, buf[i].data, nbytes);\n+      PR_PostSem(emptyBufs);\n+      i = (i + 1) % 2;\n+    }\n+  } while (nbytes > 0);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRThread* r;\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    {\n-        /* The command line argument: -d is used to determine if the test is being\n-        run in debug mode. The regress tool requires only one line output:PASS or\n-        FAIL. All of the printfs associated with this test has been handled with a\n-        if (debug_mode) test. Usage: test_name -d\n-        */\n-        PLOptStatus os;\n-        PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-        while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-            if (PL_OPT_BAD == os) {\n-                continue;\n-            }\n-            switch (opt->option) {\n-                case 'd': /* debug mode */\n-                    debug_mode = 1;\n-                    break;\n-                default:\n-                    break;\n-            }\n-        }\n-        PL_DestroyOptState(opt);\n+int main(int argc, char** argv) {\n+  PRThread* r;\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  {\n+    /* The command line argument: -d is used to determine if the test is being\n+    run in debug mode. The regress tool requires only one line output:PASS or\n+    FAIL. All of the printfs associated with this test has been handled with a\n+    if (debug_mode) test. Usage: test_name -d\n+    */\n+    PLOptStatus os;\n+    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+      if (PL_OPT_BAD == os) {\n+        continue;\n+      }\n+      switch (opt->option) {\n+        case 'd': /* debug mode */\n+          debug_mode = 1;\n+          break;\n+        default:\n+          break;\n+      }\n     }\n+    PL_DestroyOptState(opt);\n+  }\n \n-    /* main test */\n+  /* main test */\n \n-    emptyBufs = PR_NewSem(2); /* two empty buffers */\n+  emptyBufs = PR_NewSem(2); /* two empty buffers */\n \n-    fullBufs = PR_NewSem(0); /* zero full buffers */\n+  fullBufs = PR_NewSem(0); /* zero full buffers */\n \n-    /* create the reader thread */\n+  /* create the reader thread */\n \n-    r = PR_CreateThread(PR_USER_THREAD, reader, 0, PR_PRIORITY_NORMAL,\n-                        PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n+  r = PR_CreateThread(PR_USER_THREAD, reader, 0, PR_PRIORITY_NORMAL,\n+                      PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);\n \n-    /* Do the writer operation in this thread */\n-    writer();\n+  /* Do the writer operation in this thread */\n+  writer();\n \n-    PR_DestroySem(emptyBufs);\n-    PR_DestroySem(fullBufs);\n+  PR_DestroySem(emptyBufs);\n+  PR_DestroySem(fullBufs);\n \n-    if (finalResult == PR_SUCCESS) {\n-        if (debug_mode) {\n-            printf(\"sem Test Passed.\\n\");\n-        }\n-    } else {\n-        if (debug_mode) {\n-            printf(\"sem Test Failed.\\n\");\n-        }\n-        failed_already = 1;\n+  if (finalResult == PR_SUCCESS) {\n+    if (debug_mode) {\n+      printf(\"sem Test Passed.\\n\");\n     }\n-    PR_Cleanup();\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n+  } else {\n+    if (debug_mode) {\n+      printf(\"sem Test Failed.\\n\");\n     }\n+    failed_already = 1;\n+  }\n+  PR_Cleanup();\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/sema.c b/nspr/pr/tests/sema.c\nindex fc179ac..35f1b2c 100644\n--- a/nspr/pr/tests/sema.c\n+++ b/nspr/pr/tests/sema.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,14 +9,14 @@\n #include <stdio.h>\n \n #ifdef DEBUG\n-#define SEM_D \"D\"\n+#  define SEM_D \"D\"\n #else\n-#define SEM_D\n+#  define SEM_D\n #endif\n #ifdef IS_64\n-#define SEM_64 \"64\"\n+#  define SEM_64 \"64\"\n #else\n-#define SEM_64\n+#  define SEM_64\n #endif\n \n #define SEM_NAME1 \"/tmp/foo.sem\" SEM_D SEM_64\n@@ -31,141 +32,135 @@ static PRSem *sem1, *sem2;\n /*\n  * Thread 2 waits on semaphore 2 and posts to semaphore 1.\n  */\n-void\n-ThreadFunc(void* arg)\n-{\n-    PRIntn i;\n+void ThreadFunc(void* arg) {\n+  PRIntn i;\n \n-    for (i = 0; i < iterations; i++) {\n-        if (PR_WaitSemaphore(sem2) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_WaitSemaphore failed\\n\");\n-            exit(1);\n-        }\n-        if (counter == 2 * i + 1) {\n-            if (debug_mode) {\n-                printf(\"thread 2: counter = %d\\n\", counter);\n-            }\n-        } else {\n-            fprintf(stderr, \"thread 2: counter should be %d but is %d\\n\", 2 * i + 1,\n-                    counter);\n-            exit(1);\n-        }\n-        counter++;\n-        if (PR_PostSemaphore(sem1) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_PostSemaphore failed\\n\");\n-            exit(1);\n-        }\n+  for (i = 0; i < iterations; i++) {\n+    if (PR_WaitSemaphore(sem2) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_WaitSemaphore failed\\n\");\n+      exit(1);\n     }\n+    if (counter == 2 * i + 1) {\n+      if (debug_mode) {\n+        printf(\"thread 2: counter = %d\\n\", counter);\n+      }\n+    } else {\n+      fprintf(stderr, \"thread 2: counter should be %d but is %d\\n\", 2 * i + 1,\n+              counter);\n+      exit(1);\n+    }\n+    counter++;\n+    if (PR_PostSemaphore(sem1) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_PostSemaphore failed\\n\");\n+      exit(1);\n+    }\n+  }\n }\n \n-static void\n-Help(void)\n-{\n-    fprintf(stderr, \"sema test program usage:\\n\");\n-    fprintf(stderr, \"\\t-d           debug mode         (FALSE)\\n\");\n-    fprintf(stderr, \"\\t-c <count>   loop count         (%d)\\n\", ITERATIONS);\n-    fprintf(stderr, \"\\t-h           this message\\n\");\n+static void Help(void) {\n+  fprintf(stderr, \"sema test program usage:\\n\");\n+  fprintf(stderr, \"\\t-d           debug mode         (FALSE)\\n\");\n+  fprintf(stderr, \"\\t-c <count>   loop count         (%d)\\n\", ITERATIONS);\n+  fprintf(stderr, \"\\t-h           this message\\n\");\n } /* Help */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRThread* thred;\n-    PRIntn i;\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:h\");\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            case 'c': /* loop count */\n-                iterations = atoi(opt->value);\n-                break;\n-            case 'h':\n-            default:\n-                Help();\n-                return 2;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n+int main(int argc, char** argv) {\n+  PRThread* thred;\n+  PRIntn i;\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:h\");\n \n-    if (PR_DeleteSemaphore(SEM_NAME1) == PR_SUCCESS) {\n-        fprintf(stderr,\n-                \"warning: removed semaphore %s left over \"\n-                \"from previous run\\n\",\n-                SEM_NAME1);\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    if (PR_DeleteSemaphore(SEM_NAME2) == PR_SUCCESS) {\n-        fprintf(stderr,\n-                \"warning: removed semaphore %s left over \"\n-                \"from previous run\\n\",\n-                SEM_NAME2);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      case 'c': /* loop count */\n+        iterations = atoi(opt->value);\n+        break;\n+      case 'h':\n+      default:\n+        Help();\n+        return 2;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    sem1 = PR_OpenSemaphore(SEM_NAME1, PR_SEM_CREATE, SEM_MODE, 1);\n-    if (NULL == sem1) {\n-        fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    sem2 = PR_OpenSemaphore(SEM_NAME2, PR_SEM_CREATE, SEM_MODE, 0);\n-    if (NULL == sem2) {\n-        fprintf(stderr, \"PR_OpenSemaphore failed\\n\");\n-        exit(1);\n-    }\n-    thred = PR_CreateThread(PR_USER_THREAD, ThreadFunc, NULL, PR_PRIORITY_NORMAL,\n-                            PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (NULL == thred) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n-    }\n+  if (PR_DeleteSemaphore(SEM_NAME1) == PR_SUCCESS) {\n+    fprintf(stderr,\n+            \"warning: removed semaphore %s left over \"\n+            \"from previous run\\n\",\n+            SEM_NAME1);\n+  }\n+  if (PR_DeleteSemaphore(SEM_NAME2) == PR_SUCCESS) {\n+    fprintf(stderr,\n+            \"warning: removed semaphore %s left over \"\n+            \"from previous run\\n\",\n+            SEM_NAME2);\n+  }\n \n-    /*\n-     * Thread 1 waits on semaphore 1 and posts to semaphore 2.\n-     */\n-    for (i = 0; i < iterations; i++) {\n-        if (PR_WaitSemaphore(sem1) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_WaitSemaphore failed\\n\");\n-            exit(1);\n-        }\n-        if (counter == 2 * i) {\n-            if (debug_mode) {\n-                printf(\"thread 1: counter = %d\\n\", counter);\n-            }\n-        } else {\n-            fprintf(stderr, \"thread 1: counter should be %d but is %d\\n\", 2 * i,\n-                    counter);\n-            exit(1);\n-        }\n-        counter++;\n-        if (PR_PostSemaphore(sem2) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_PostSemaphore failed\\n\");\n-            exit(1);\n-        }\n-    }\n-\n-    if (PR_JoinThread(thred) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n-    }\n+  sem1 = PR_OpenSemaphore(SEM_NAME1, PR_SEM_CREATE, SEM_MODE, 1);\n+  if (NULL == sem1) {\n+    fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  sem2 = PR_OpenSemaphore(SEM_NAME2, PR_SEM_CREATE, SEM_MODE, 0);\n+  if (NULL == sem2) {\n+    fprintf(stderr, \"PR_OpenSemaphore failed\\n\");\n+    exit(1);\n+  }\n+  thred = PR_CreateThread(PR_USER_THREAD, ThreadFunc, NULL, PR_PRIORITY_NORMAL,\n+                          PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (NULL == thred) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n \n-    if (PR_CloseSemaphore(sem1) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+  /*\n+   * Thread 1 waits on semaphore 1 and posts to semaphore 2.\n+   */\n+  for (i = 0; i < iterations; i++) {\n+    if (PR_WaitSemaphore(sem1) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_WaitSemaphore failed\\n\");\n+      exit(1);\n     }\n-    if (PR_CloseSemaphore(sem2) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+    if (counter == 2 * i) {\n+      if (debug_mode) {\n+        printf(\"thread 1: counter = %d\\n\", counter);\n+      }\n+    } else {\n+      fprintf(stderr, \"thread 1: counter should be %d but is %d\\n\", 2 * i,\n+              counter);\n+      exit(1);\n     }\n-    if (PR_DeleteSemaphore(SEM_NAME1) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_DeleteSemaphore failed\\n\");\n+    counter++;\n+    if (PR_PostSemaphore(sem2) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_PostSemaphore failed\\n\");\n+      exit(1);\n     }\n-    if (PR_DeleteSemaphore(SEM_NAME2) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_DeleteSemaphore failed\\n\");\n-    }\n-    printf(\"PASS\\n\");\n-    return 0;\n+  }\n+\n+  if (PR_JoinThread(thred) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+\n+  if (PR_CloseSemaphore(sem1) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+  }\n+  if (PR_CloseSemaphore(sem2) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+  }\n+  if (PR_DeleteSemaphore(SEM_NAME1) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_DeleteSemaphore failed\\n\");\n+  }\n+  if (PR_DeleteSemaphore(SEM_NAME2) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_DeleteSemaphore failed\\n\");\n+  }\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/semaerr.c b/nspr/pr/tests/semaerr.c\nindex 6275d12..6dabed0 100644\n--- a/nspr/pr/tests/semaerr.c\n+++ b/nspr/pr/tests/semaerr.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,14 +9,14 @@\n #include <stdio.h>\n \n #ifdef DEBUG\n-#define SEM_D \"D\"\n+#  define SEM_D \"D\"\n #else\n-#define SEM_D\n+#  define SEM_D\n #endif\n #ifdef IS_64\n-#define SEM_64 \"64\"\n+#  define SEM_64 \"64\"\n #else\n-#define SEM_64\n+#  define SEM_64\n #endif\n \n #define NO_SUCH_SEM_NAME \"/tmp/nosuchsem.sem\" SEM_D SEM_64\n@@ -25,105 +26,101 @@\n \n static PRBool debug_mode = PR_FALSE;\n \n-static void\n-Help(void)\n-{\n-    fprintf(stderr, \"semaerr test program usage:\\n\");\n-    fprintf(stderr, \"\\t-d           debug mode         (FALSE)\\n\");\n-    fprintf(stderr, \"\\t-h           this message\\n\");\n+static void Help(void) {\n+  fprintf(stderr, \"semaerr test program usage:\\n\");\n+  fprintf(stderr, \"\\t-d           debug mode         (FALSE)\\n\");\n+  fprintf(stderr, \"\\t-h           this message\\n\");\n } /* Help */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dh\");\n-    PRSem* sem;\n-    char* child_argv[32];\n-    char** child_arg;\n-    PRProcess* proc;\n-    PRInt32 exit_code;\n+int main(int argc, char** argv) {\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dh\");\n+  PRSem* sem;\n+  char* child_argv[32];\n+  char** child_arg;\n+  PRProcess* proc;\n+  PRInt32 exit_code;\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            case 'h':\n-            default:\n-                Help();\n-                return 2;\n-        }\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    /*\n-     * Open a nonexistent semaphore without the PR_SEM_CREATE\n-     * flag should fail with PR_FILE_NOT_FOUND_ERROR.\n-     */\n-    (void)PR_DeleteSemaphore(NO_SUCH_SEM_NAME);\n-    sem = PR_OpenSemaphore(NO_SUCH_SEM_NAME, 0, 0, 0);\n-    if (NULL != sem) {\n-        fprintf(stderr,\n-                \"Opening nonexistent semaphore %s \"\n-                \"without the PR_SEM_CREATE flag should fail \"\n-                \"but succeeded\\n\",\n-                NO_SUCH_SEM_NAME);\n-        exit(1);\n-    }\n-    if (PR_GetError() != PR_FILE_NOT_FOUND_ERROR) {\n-        fprintf(stderr, \"Expected error is %d but got (%d, %d)\\n\",\n-                PR_FILE_NOT_FOUND_ERROR, PR_GetError(), PR_GetOSError());\n-        exit(1);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      case 'h':\n+      default:\n+        Help();\n+        return 2;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    /*\n-     * Create a semaphore and let the another process\n-     * try PR_SEM_CREATE and PR_SEM_CREATE|PR_SEM_EXCL.\n-     */\n-    if (PR_DeleteSemaphore(SEM_NAME1) == PR_SUCCESS) {\n-        fprintf(stderr,\n-                \"warning: deleted semaphore %s from previous \"\n-                \"run of the test\\n\",\n-                SEM_NAME1);\n-    }\n-    sem = PR_OpenSemaphore(SEM_NAME1, PR_SEM_CREATE, SEM_MODE, 0);\n-    if (sem == NULL) {\n-        fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    child_arg = child_argv;\n-    *child_arg++ = EXE_NAME;\n-    if (debug_mode) {\n-        *child_arg++ = \"-d\";\n-    }\n-    *child_arg = NULL;\n-    proc = PR_CreateProcess(child_argv[0], child_argv, NULL, NULL);\n-    if (proc == NULL) {\n-        fprintf(stderr, \"PR_CreateProcess failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_WaitProcess(proc, &exit_code) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_WaitProcess failed\\n\");\n-        exit(1);\n-    }\n-    if (exit_code != 0) {\n-        fprintf(stderr, \"process semaerr1 failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_CloseSemaphore(sem) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_DeleteSemaphore(SEM_NAME1) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_DeleteSemaphore failed\\n\");\n-        exit(1);\n-    }\n+  /*\n+   * Open a nonexistent semaphore without the PR_SEM_CREATE\n+   * flag should fail with PR_FILE_NOT_FOUND_ERROR.\n+   */\n+  (void)PR_DeleteSemaphore(NO_SUCH_SEM_NAME);\n+  sem = PR_OpenSemaphore(NO_SUCH_SEM_NAME, 0, 0, 0);\n+  if (NULL != sem) {\n+    fprintf(stderr,\n+            \"Opening nonexistent semaphore %s \"\n+            \"without the PR_SEM_CREATE flag should fail \"\n+            \"but succeeded\\n\",\n+            NO_SUCH_SEM_NAME);\n+    exit(1);\n+  }\n+  if (PR_GetError() != PR_FILE_NOT_FOUND_ERROR) {\n+    fprintf(stderr, \"Expected error is %d but got (%d, %d)\\n\",\n+            PR_FILE_NOT_FOUND_ERROR, PR_GetError(), PR_GetOSError());\n+    exit(1);\n+  }\n+\n+  /*\n+   * Create a semaphore and let the another process\n+   * try PR_SEM_CREATE and PR_SEM_CREATE|PR_SEM_EXCL.\n+   */\n+  if (PR_DeleteSemaphore(SEM_NAME1) == PR_SUCCESS) {\n+    fprintf(stderr,\n+            \"warning: deleted semaphore %s from previous \"\n+            \"run of the test\\n\",\n+            SEM_NAME1);\n+  }\n+  sem = PR_OpenSemaphore(SEM_NAME1, PR_SEM_CREATE, SEM_MODE, 0);\n+  if (sem == NULL) {\n+    fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  child_arg = child_argv;\n+  *child_arg++ = EXE_NAME;\n+  if (debug_mode) {\n+    *child_arg++ = \"-d\";\n+  }\n+  *child_arg = NULL;\n+  proc = PR_CreateProcess(child_argv[0], child_argv, NULL, NULL);\n+  if (proc == NULL) {\n+    fprintf(stderr, \"PR_CreateProcess failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_WaitProcess(proc, &exit_code) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_WaitProcess failed\\n\");\n+    exit(1);\n+  }\n+  if (exit_code != 0) {\n+    fprintf(stderr, \"process semaerr1 failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_CloseSemaphore(sem) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_DeleteSemaphore(SEM_NAME1) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_DeleteSemaphore failed\\n\");\n+    exit(1);\n+  }\n \n-    printf(\"PASS\\n\");\n-    return 0;\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/semaerr1.c b/nspr/pr/tests/semaerr1.c\nindex 47ecb45..6ad682a 100644\n--- a/nspr/pr/tests/semaerr1.c\n+++ b/nspr/pr/tests/semaerr1.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,14 +9,14 @@\n #include <stdio.h>\n \n #ifdef DEBUG\n-#define SEM_D \"D\"\n+#  define SEM_D \"D\"\n #else\n-#define SEM_D\n+#  define SEM_D\n #endif\n #ifdef IS_64\n-#define SEM_64 \"64\"\n+#  define SEM_64 \"64\"\n #else\n-#define SEM_64\n+#  define SEM_64\n #endif\n \n #define SEM_NAME1 \"/tmp/foo.sem\" SEM_D SEM_64\n@@ -24,96 +25,92 @@\n \n static PRBool debug_mode = PR_FALSE;\n \n-static void\n-Help(void)\n-{\n-    fprintf(stderr, \"semaerr1 test program usage:\\n\");\n-    fprintf(stderr, \"\\t-d           debug mode         (FALSE)\\n\");\n-    fprintf(stderr, \"\\t-h           this message\\n\");\n+static void Help(void) {\n+  fprintf(stderr, \"semaerr1 test program usage:\\n\");\n+  fprintf(stderr, \"\\t-d           debug mode         (FALSE)\\n\");\n+  fprintf(stderr, \"\\t-h           this message\\n\");\n } /* Help */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dh\");\n-    PRSem* sem;\n+int main(int argc, char** argv) {\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dh\");\n+  PRSem* sem;\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            case 'h':\n-            default:\n-                Help();\n-                return 2;\n-        }\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    /*\n-     * PR_SEM_CREATE|PR_SEM_EXCL should be able to\n-     * create a nonexistent semaphore.\n-     */\n-    (void)PR_DeleteSemaphore(SEM_NAME2);\n-    sem = PR_OpenSemaphore(SEM_NAME2, PR_SEM_CREATE | PR_SEM_EXCL, SEM_MODE, 0);\n-    if (sem == NULL) {\n-        fprintf(stderr, \"PR_OpenSemaphore failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_CloseSemaphore(sem) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_DeleteSemaphore(SEM_NAME2) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_DeleteSemaphore failed\\n\");\n-        exit(1);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      case 'h':\n+      default:\n+        Help();\n+        return 2;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    /*\n-     * Opening an existing semaphore with PR_SEM_CREATE|PR_SEM_EXCL.\n-     * should fail with PR_FILE_EXISTS_ERROR.\n-     */\n-    sem = PR_OpenSemaphore(SEM_NAME1, PR_SEM_CREATE | PR_SEM_EXCL, SEM_MODE, 0);\n-    if (sem != NULL) {\n-        fprintf(stderr, \"PR_OpenSemaphore should fail but succeeded\\n\");\n-        exit(1);\n-    }\n-    if (PR_GetError() != PR_FILE_EXISTS_ERROR) {\n-        fprintf(stderr, \"Expect %d but got %d\\n\", PR_FILE_EXISTS_ERROR,\n-                PR_GetError());\n-        exit(1);\n-    }\n+  /*\n+   * PR_SEM_CREATE|PR_SEM_EXCL should be able to\n+   * create a nonexistent semaphore.\n+   */\n+  (void)PR_DeleteSemaphore(SEM_NAME2);\n+  sem = PR_OpenSemaphore(SEM_NAME2, PR_SEM_CREATE | PR_SEM_EXCL, SEM_MODE, 0);\n+  if (sem == NULL) {\n+    fprintf(stderr, \"PR_OpenSemaphore failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_CloseSemaphore(sem) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_DeleteSemaphore(SEM_NAME2) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_DeleteSemaphore failed\\n\");\n+    exit(1);\n+  }\n \n-    /*\n-     * Try again, with just PR_SEM_CREATE.  This should succeed.\n-     */\n-    sem = PR_OpenSemaphore(SEM_NAME1, PR_SEM_CREATE, SEM_MODE, 0);\n-    if (sem == NULL) {\n-        fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    if (PR_CloseSemaphore(sem) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n-        exit(1);\n-    }\n+  /*\n+   * Opening an existing semaphore with PR_SEM_CREATE|PR_SEM_EXCL.\n+   * should fail with PR_FILE_EXISTS_ERROR.\n+   */\n+  sem = PR_OpenSemaphore(SEM_NAME1, PR_SEM_CREATE | PR_SEM_EXCL, SEM_MODE, 0);\n+  if (sem != NULL) {\n+    fprintf(stderr, \"PR_OpenSemaphore should fail but succeeded\\n\");\n+    exit(1);\n+  }\n+  if (PR_GetError() != PR_FILE_EXISTS_ERROR) {\n+    fprintf(stderr, \"Expect %d but got %d\\n\", PR_FILE_EXISTS_ERROR,\n+            PR_GetError());\n+    exit(1);\n+  }\n \n-    sem = PR_OpenSemaphore(SEM_NAME2, PR_SEM_CREATE | PR_SEM_EXCL, SEM_MODE, 0);\n-    if (sem == NULL) {\n-        fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    if (PR_CloseSemaphore(sem) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n-        exit(1);\n-    }\n+  /*\n+   * Try again, with just PR_SEM_CREATE.  This should succeed.\n+   */\n+  sem = PR_OpenSemaphore(SEM_NAME1, PR_SEM_CREATE, SEM_MODE, 0);\n+  if (sem == NULL) {\n+    fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  if (PR_CloseSemaphore(sem) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+    exit(1);\n+  }\n+\n+  sem = PR_OpenSemaphore(SEM_NAME2, PR_SEM_CREATE | PR_SEM_EXCL, SEM_MODE, 0);\n+  if (sem == NULL) {\n+    fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  if (PR_CloseSemaphore(sem) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+    exit(1);\n+  }\n \n-    printf(\"PASS\\n\");\n-    return 0;\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/semaping.c b/nspr/pr/tests/semaping.c\nindex 13334b2..f1c5fa1 100644\n--- a/nspr/pr/tests/semaping.c\n+++ b/nspr/pr/tests/semaping.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,14 +9,14 @@\n #include <stdio.h>\n \n #ifdef DEBUG\n-#define SEM_D \"D\"\n+#  define SEM_D \"D\"\n #else\n-#define SEM_D\n+#  define SEM_D\n #endif\n #ifdef IS_64\n-#define SEM_64 \"64\"\n+#  define SEM_64 \"64\"\n #else\n-#define SEM_64\n+#  define SEM_64\n #endif\n \n #define SHM_NAME \"/tmp/counter\" SEM_D SEM_64\n@@ -30,166 +31,162 @@ static PRBool debug_mode = PR_FALSE;\n static PRIntn iterations = ITERATIONS;\n static PRSem *sem1, *sem2;\n \n-static void\n-Help(void)\n-{\n-    fprintf(stderr, \"semaping test program usage:\\n\");\n-    fprintf(stderr, \"\\t-d           debug mode         (FALSE)\\n\");\n-    fprintf(stderr, \"\\t-c <count>   loop count         (%d)\\n\", ITERATIONS);\n-    fprintf(stderr, \"\\t-h           this message\\n\");\n+static void Help(void) {\n+  fprintf(stderr, \"semaping test program usage:\\n\");\n+  fprintf(stderr, \"\\t-d           debug mode         (FALSE)\\n\");\n+  fprintf(stderr, \"\\t-c <count>   loop count         (%d)\\n\", ITERATIONS);\n+  fprintf(stderr, \"\\t-h           this message\\n\");\n } /* Help */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRProcess* proc;\n-    PRIntn i;\n-    char* child_argv[32];\n-    char** child_arg;\n-    char iterations_buf[32];\n-    PRSharedMemory* shm;\n-    PRIntn* counter_addr;\n-    PRInt32 exit_code;\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:h\");\n+int main(int argc, char** argv) {\n+  PRProcess* proc;\n+  PRIntn i;\n+  char* child_argv[32];\n+  char** child_arg;\n+  char iterations_buf[32];\n+  PRSharedMemory* shm;\n+  PRIntn* counter_addr;\n+  PRInt32 exit_code;\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:h\");\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            case 'c': /* loop count */\n-                iterations = atoi(opt->value);\n-                break;\n-            case 'h':\n-            default:\n-                Help();\n-                return 2;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      case 'c': /* loop count */\n+        iterations = atoi(opt->value);\n+        break;\n+      case 'h':\n+      default:\n+        Help();\n+        return 2;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    if (PR_DeleteSharedMemory(SHM_NAME) == PR_SUCCESS) {\n-        fprintf(stderr,\n-                \"warning: removed shared memory %s left over \"\n-                \"from previous run\\n\",\n-                SHM_NAME);\n-    }\n-    if (PR_DeleteSemaphore(SEM_NAME1) == PR_SUCCESS) {\n-        fprintf(stderr,\n-                \"warning: removed semaphore %s left over \"\n-                \"from previous run\\n\",\n-                SEM_NAME1);\n-    }\n-    if (PR_DeleteSemaphore(SEM_NAME2) == PR_SUCCESS) {\n-        fprintf(stderr,\n-                \"warning: removed semaphore %s left over \"\n-                \"from previous run\\n\",\n-                SEM_NAME2);\n-    }\n+  if (PR_DeleteSharedMemory(SHM_NAME) == PR_SUCCESS) {\n+    fprintf(stderr,\n+            \"warning: removed shared memory %s left over \"\n+            \"from previous run\\n\",\n+            SHM_NAME);\n+  }\n+  if (PR_DeleteSemaphore(SEM_NAME1) == PR_SUCCESS) {\n+    fprintf(stderr,\n+            \"warning: removed semaphore %s left over \"\n+            \"from previous run\\n\",\n+            SEM_NAME1);\n+  }\n+  if (PR_DeleteSemaphore(SEM_NAME2) == PR_SUCCESS) {\n+    fprintf(stderr,\n+            \"warning: removed semaphore %s left over \"\n+            \"from previous run\\n\",\n+            SEM_NAME2);\n+  }\n \n-    shm = PR_OpenSharedMemory(SHM_NAME, sizeof(*counter_addr), PR_SHM_CREATE,\n-                              SHM_MODE);\n-    if (NULL == shm) {\n-        fprintf(stderr, \"PR_OpenSharedMemory failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    counter_addr = PR_AttachSharedMemory(shm, 0);\n-    if (NULL == counter_addr) {\n-        fprintf(stderr, \"PR_AttachSharedMemory failed\\n\");\n-        exit(1);\n-    }\n-    *counter_addr = 0;\n-    sem1 = PR_OpenSemaphore(SEM_NAME1, PR_SEM_CREATE, SEM_MODE, 1);\n-    if (NULL == sem1) {\n-        fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    sem2 = PR_OpenSemaphore(SEM_NAME2, PR_SEM_CREATE, SEM_MODE, 0);\n-    if (NULL == sem2) {\n-        fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n+  shm = PR_OpenSharedMemory(SHM_NAME, sizeof(*counter_addr), PR_SHM_CREATE,\n+                            SHM_MODE);\n+  if (NULL == shm) {\n+    fprintf(stderr, \"PR_OpenSharedMemory failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  counter_addr = PR_AttachSharedMemory(shm, 0);\n+  if (NULL == counter_addr) {\n+    fprintf(stderr, \"PR_AttachSharedMemory failed\\n\");\n+    exit(1);\n+  }\n+  *counter_addr = 0;\n+  sem1 = PR_OpenSemaphore(SEM_NAME1, PR_SEM_CREATE, SEM_MODE, 1);\n+  if (NULL == sem1) {\n+    fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  sem2 = PR_OpenSemaphore(SEM_NAME2, PR_SEM_CREATE, SEM_MODE, 0);\n+  if (NULL == sem2) {\n+    fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n \n-    child_arg = &child_argv[0];\n-    *child_arg++ = EXE_NAME;\n-    if (debug_mode != PR_FALSE) {\n-        *child_arg++ = \"-d\";\n-    }\n-    if (iterations != ITERATIONS) {\n-        *child_arg++ = \"-c\";\n-        PR_snprintf(iterations_buf, sizeof(iterations_buf), \"%d\", iterations);\n-        *child_arg++ = iterations_buf;\n-    }\n-    *child_arg = NULL;\n-    proc = PR_CreateProcess(child_argv[0], child_argv, NULL, NULL);\n-    if (NULL == proc) {\n-        fprintf(stderr, \"PR_CreateProcess failed\\n\");\n-        exit(1);\n-    }\n+  child_arg = &child_argv[0];\n+  *child_arg++ = EXE_NAME;\n+  if (debug_mode != PR_FALSE) {\n+    *child_arg++ = \"-d\";\n+  }\n+  if (iterations != ITERATIONS) {\n+    *child_arg++ = \"-c\";\n+    PR_snprintf(iterations_buf, sizeof(iterations_buf), \"%d\", iterations);\n+    *child_arg++ = iterations_buf;\n+  }\n+  *child_arg = NULL;\n+  proc = PR_CreateProcess(child_argv[0], child_argv, NULL, NULL);\n+  if (NULL == proc) {\n+    fprintf(stderr, \"PR_CreateProcess failed\\n\");\n+    exit(1);\n+  }\n \n-    /*\n-     * Process 1 waits on semaphore 1 and posts to semaphore 2.\n-     */\n-    for (i = 0; i < iterations; i++) {\n-        if (PR_WaitSemaphore(sem1) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_WaitSemaphore failed\\n\");\n-            exit(1);\n-        }\n-        if (*counter_addr == 2 * i) {\n-            if (debug_mode) {\n-                printf(\"process 1: counter = %d\\n\", *counter_addr);\n-            }\n-        } else {\n-            fprintf(stderr, \"process 1: counter should be %d but is %d\\n\", 2 * i,\n-                    *counter_addr);\n-            exit(1);\n-        }\n-        (*counter_addr)++;\n-        if (PR_PostSemaphore(sem2) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_PostSemaphore failed\\n\");\n-            exit(1);\n-        }\n-    }\n-    if (PR_DetachSharedMemory(shm, counter_addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_DetachSharedMemory failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_CloseSharedMemory(shm) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CloseSharedMemory failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_CloseSemaphore(sem1) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n-    }\n-    if (PR_CloseSemaphore(sem2) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n-    }\n+  /*\n+   * Process 1 waits on semaphore 1 and posts to semaphore 2.\n+   */\n+  for (i = 0; i < iterations; i++) {\n+    if (PR_WaitSemaphore(sem1) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_WaitSemaphore failed\\n\");\n+      exit(1);\n+    }\n+    if (*counter_addr == 2 * i) {\n+      if (debug_mode) {\n+        printf(\"process 1: counter = %d\\n\", *counter_addr);\n+      }\n+    } else {\n+      fprintf(stderr, \"process 1: counter should be %d but is %d\\n\", 2 * i,\n+              *counter_addr);\n+      exit(1);\n+    }\n+    (*counter_addr)++;\n+    if (PR_PostSemaphore(sem2) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_PostSemaphore failed\\n\");\n+      exit(1);\n+    }\n+  }\n+  if (PR_DetachSharedMemory(shm, counter_addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_DetachSharedMemory failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_CloseSharedMemory(shm) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CloseSharedMemory failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_CloseSemaphore(sem1) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+  }\n+  if (PR_CloseSemaphore(sem2) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+  }\n \n-    if (PR_WaitProcess(proc, &exit_code) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_WaitProcess failed\\n\");\n-        exit(1);\n-    }\n-    if (exit_code != 0) {\n-        fprintf(stderr, \"process 2 failed with exit code %d\\n\", exit_code);\n-        exit(1);\n-    }\n+  if (PR_WaitProcess(proc, &exit_code) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_WaitProcess failed\\n\");\n+    exit(1);\n+  }\n+  if (exit_code != 0) {\n+    fprintf(stderr, \"process 2 failed with exit code %d\\n\", exit_code);\n+    exit(1);\n+  }\n \n-    if (PR_DeleteSharedMemory(SHM_NAME) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_DeleteSharedMemory failed\\n\");\n-    }\n-    if (PR_DeleteSemaphore(SEM_NAME1) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_DeleteSemaphore failed\\n\");\n-    }\n-    if (PR_DeleteSemaphore(SEM_NAME2) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_DeleteSemaphore failed\\n\");\n-    }\n-    printf(\"PASS\\n\");\n-    return 0;\n+  if (PR_DeleteSharedMemory(SHM_NAME) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_DeleteSharedMemory failed\\n\");\n+  }\n+  if (PR_DeleteSemaphore(SEM_NAME1) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_DeleteSemaphore failed\\n\");\n+  }\n+  if (PR_DeleteSemaphore(SEM_NAME2) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_DeleteSemaphore failed\\n\");\n+  }\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/semapong.c b/nspr/pr/tests/semapong.c\nindex 6c9adca..fdaa2c8 100644\n--- a/nspr/pr/tests/semapong.c\n+++ b/nspr/pr/tests/semapong.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -8,14 +9,14 @@\n #include <stdio.h>\n \n #ifdef DEBUG\n-#define SEM_D \"D\"\n+#  define SEM_D \"D\"\n #else\n-#define SEM_D\n+#  define SEM_D\n #endif\n #ifdef IS_64\n-#define SEM_64 \"64\"\n+#  define SEM_64 \"64\"\n #else\n-#define SEM_64\n+#  define SEM_64\n #endif\n \n #define SHM_NAME \"/tmp/counter\" SEM_D SEM_64\n@@ -27,105 +28,101 @@ static PRBool debug_mode = PR_FALSE;\n static PRIntn iterations = ITERATIONS;\n static PRSem *sem1, *sem2;\n \n-static void\n-Help(void)\n-{\n-    fprintf(stderr, \"semapong test program usage:\\n\");\n-    fprintf(stderr, \"\\t-d           debug mode         (FALSE)\\n\");\n-    fprintf(stderr, \"\\t-c <count>   loop count         (%d)\\n\", ITERATIONS);\n-    fprintf(stderr, \"\\t-h           this message\\n\");\n+static void Help(void) {\n+  fprintf(stderr, \"semapong test program usage:\\n\");\n+  fprintf(stderr, \"\\t-d           debug mode         (FALSE)\\n\");\n+  fprintf(stderr, \"\\t-c <count>   loop count         (%d)\\n\", ITERATIONS);\n+  fprintf(stderr, \"\\t-h           this message\\n\");\n } /* Help */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn i;\n-    PRSharedMemory* shm;\n-    PRIntn* counter_addr;\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:h\");\n+int main(int argc, char** argv) {\n+  PRIntn i;\n+  PRSharedMemory* shm;\n+  PRIntn* counter_addr;\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:h\");\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            case 'c': /* loop count */\n-                iterations = atoi(opt->value);\n-                break;\n-            case 'h':\n-            default:\n-                Help();\n-                return 2;\n-        }\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    shm = PR_OpenSharedMemory(SHM_NAME, sizeof(*counter_addr), 0, 0666);\n-    if (NULL == shm) {\n-        fprintf(stderr, \"PR_OpenSharedMemory failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    sem1 = PR_OpenSemaphore(SEM_NAME1, 0, 0, 0);\n-    if (NULL == sem1) {\n-        fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    sem2 = PR_OpenSemaphore(SEM_NAME2, 0, 0, 0);\n-    if (NULL == sem2) {\n-        fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      case 'c': /* loop count */\n+        iterations = atoi(opt->value);\n+        break;\n+      case 'h':\n+      default:\n+        Help();\n+        return 2;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    counter_addr = PR_AttachSharedMemory(shm, 0);\n-    if (NULL == counter_addr) {\n-        fprintf(stderr, \"PR_AttachSharedMemory failed\\n\");\n-        exit(1);\n-    }\n+  shm = PR_OpenSharedMemory(SHM_NAME, sizeof(*counter_addr), 0, 0666);\n+  if (NULL == shm) {\n+    fprintf(stderr, \"PR_OpenSharedMemory failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  sem1 = PR_OpenSemaphore(SEM_NAME1, 0, 0, 0);\n+  if (NULL == sem1) {\n+    fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  sem2 = PR_OpenSemaphore(SEM_NAME2, 0, 0, 0);\n+  if (NULL == sem2) {\n+    fprintf(stderr, \"PR_OpenSemaphore failed (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n \n-    /*\n-     * Process 2 waits on semaphore 2 and posts to semaphore 1.\n-     */\n-    for (i = 0; i < iterations; i++) {\n-        if (PR_WaitSemaphore(sem2) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_WaitSemaphore failed\\n\");\n-            exit(1);\n-        }\n-        if (*counter_addr == 2 * i + 1) {\n-            if (debug_mode) {\n-                printf(\"process 2: counter = %d\\n\", *counter_addr);\n-            }\n-        } else {\n-            fprintf(stderr, \"process 2: counter should be %d but is %d\\n\", 2 * i + 1,\n-                    *counter_addr);\n-            exit(1);\n-        }\n-        (*counter_addr)++;\n-        if (PR_PostSemaphore(sem1) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_PostSemaphore failed\\n\");\n-            exit(1);\n-        }\n-    }\n-    if (PR_DetachSharedMemory(shm, counter_addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_DetachSharedMemory failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_CloseSharedMemory(shm) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CloseSharedMemory failed\\n\");\n-        exit(1);\n+  counter_addr = PR_AttachSharedMemory(shm, 0);\n+  if (NULL == counter_addr) {\n+    fprintf(stderr, \"PR_AttachSharedMemory failed\\n\");\n+    exit(1);\n+  }\n+\n+  /*\n+   * Process 2 waits on semaphore 2 and posts to semaphore 1.\n+   */\n+  for (i = 0; i < iterations; i++) {\n+    if (PR_WaitSemaphore(sem2) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_WaitSemaphore failed\\n\");\n+      exit(1);\n     }\n-    if (PR_CloseSemaphore(sem1) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+    if (*counter_addr == 2 * i + 1) {\n+      if (debug_mode) {\n+        printf(\"process 2: counter = %d\\n\", *counter_addr);\n+      }\n+    } else {\n+      fprintf(stderr, \"process 2: counter should be %d but is %d\\n\", 2 * i + 1,\n+              *counter_addr);\n+      exit(1);\n     }\n-    if (PR_CloseSemaphore(sem2) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+    (*counter_addr)++;\n+    if (PR_PostSemaphore(sem1) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_PostSemaphore failed\\n\");\n+      exit(1);\n     }\n-    printf(\"PASS\\n\");\n-    return 0;\n+  }\n+  if (PR_DetachSharedMemory(shm, counter_addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_DetachSharedMemory failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_CloseSharedMemory(shm) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CloseSharedMemory failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_CloseSemaphore(sem1) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+  }\n+  if (PR_CloseSemaphore(sem2) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_CloseSemaphore failed\\n\");\n+  }\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/sendzlf.c b/nspr/pr/tests/sendzlf.c\nindex 104e8d9..c033fb4 100644\n--- a/nspr/pr/tests/sendzlf.c\n+++ b/nspr/pr/tests/sendzlf.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -21,196 +22,190 @@\n #include <stdlib.h>\n #include <string.h>\n \n-static void\n-ClientThread(void* arg)\n-{\n-    PRFileDesc* sock;\n-    PRNetAddr addr;\n-    PRUint16 port = (PRUint16)arg;\n-    char buf[1024];\n-    char* bufPtr;\n-    PRInt32 nbytes;\n-    PRInt32 ntotal;\n-    PRInt32 nexpected;\n+static void ClientThread(void* arg) {\n+  PRFileDesc* sock;\n+  PRNetAddr addr;\n+  PRUint16 port = (PRUint16)arg;\n+  char buf[1024];\n+  char* bufPtr;\n+  PRInt32 nbytes;\n+  PRInt32 ntotal;\n+  PRInt32 nexpected;\n \n-    sock = PR_NewTCPSocket();\n-    if (NULL == sock) {\n-        fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_InitializeNetAddr(PR_IpAddrLoopback, port, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Connect failed\\n\");\n-        exit(1);\n-    }\n-    ntotal = 0;\n-    bufPtr = buf;\n-    while ((nbytes = PR_Read(sock, bufPtr, sizeof(buf) - ntotal)) > 0) {\n-        ntotal += nbytes;\n-        bufPtr += nbytes;\n-    }\n-    if (-1 == nbytes) {\n-        fprintf(stderr, \"PR_Read failed\\n\");\n-        exit(1);\n-    }\n-    nexpected = HEADER_LEN + TRAILER_LEN + TRAILER_LEN + HEADER_LEN + HEADER_LEN;\n-    if (ntotal != nexpected) {\n-        fprintf(stderr, \"total bytes read should be %d but is %d\\n\", nexpected,\n-                ntotal);\n-        exit(1);\n-    }\n-    if (memcmp(buf, HEADER_STR TRAILER_STR TRAILER_STR HEADER_STR HEADER_STR,\n-               nexpected) != 0) {\n-        fprintf(stderr, \"wrong data is received\\n\");\n-        exit(1);\n-    }\n-    if (PR_Close(sock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n+  sock = PR_NewTCPSocket();\n+  if (NULL == sock) {\n+    fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_InitializeNetAddr(PR_IpAddrLoopback, port, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Connect failed\\n\");\n+    exit(1);\n+  }\n+  ntotal = 0;\n+  bufPtr = buf;\n+  while ((nbytes = PR_Read(sock, bufPtr, sizeof(buf) - ntotal)) > 0) {\n+    ntotal += nbytes;\n+    bufPtr += nbytes;\n+  }\n+  if (-1 == nbytes) {\n+    fprintf(stderr, \"PR_Read failed\\n\");\n+    exit(1);\n+  }\n+  nexpected = HEADER_LEN + TRAILER_LEN + TRAILER_LEN + HEADER_LEN + HEADER_LEN;\n+  if (ntotal != nexpected) {\n+    fprintf(stderr, \"total bytes read should be %d but is %d\\n\", nexpected,\n+            ntotal);\n+    exit(1);\n+  }\n+  if (memcmp(buf, HEADER_STR TRAILER_STR TRAILER_STR HEADER_STR HEADER_STR,\n+             nexpected) != 0) {\n+    fprintf(stderr, \"wrong data is received\\n\");\n+    exit(1);\n+  }\n+  if (PR_Close(sock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n }\n \n-static void\n-ServerThread(void* arg)\n-{\n-    PRFileDesc* listenSock = (PRFileDesc*)arg;\n-    PRFileDesc* acceptSock;\n-    PRFileDesc* file;\n-    PRSendFileData sfd;\n-    char header[1024], trailer[1024];\n-    PRInt32 nbytes;\n+static void ServerThread(void* arg) {\n+  PRFileDesc* listenSock = (PRFileDesc*)arg;\n+  PRFileDesc* acceptSock;\n+  PRFileDesc* file;\n+  PRSendFileData sfd;\n+  char header[1024], trailer[1024];\n+  PRInt32 nbytes;\n \n-    /* Create a zero-length file */\n-    file =\n-        PR_Open(ZERO_LEN_FILE_NAME, PR_CREATE_FILE | PR_TRUNCATE | PR_RDWR, 0666);\n-    if (NULL == file) {\n-        fprintf(stderr, \"PR_Open failed\\n\");\n-        exit(1);\n-    }\n-    sfd.fd = file;\n-    sfd.file_offset = 0;\n-    sfd.file_nbytes = 0;\n-    memcpy(header, HEADER_STR, HEADER_LEN);\n-    memcpy(trailer, TRAILER_STR, TRAILER_LEN);\n-    sfd.header = header;\n-    sfd.hlen = HEADER_LEN;\n-    sfd.trailer = trailer;\n-    sfd.tlen = TRAILER_LEN;\n-    acceptSock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n-    if (NULL == acceptSock) {\n-        fprintf(stderr, \"PR_Accept failed\\n\");\n-        exit(1);\n-    }\n-    /* Send both header and trailer */\n-    nbytes = PR_SendFile(acceptSock, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n-                         PR_INTERVAL_NO_TIMEOUT);\n-    if (HEADER_LEN + TRAILER_LEN != nbytes) {\n-        fprintf(stderr, \"PR_SendFile should return %d but returned %d\\n\",\n-                HEADER_LEN + TRAILER_LEN, nbytes);\n-        exit(1);\n-    }\n-    /* Trailer only, no header */\n-    sfd.hlen = 0;\n-    nbytes = PR_SendFile(acceptSock, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n-                         PR_INTERVAL_NO_TIMEOUT);\n-    if (TRAILER_LEN != nbytes) {\n-        fprintf(stderr, \"PR_SendFile should return %d but returned %d\\n\",\n-                TRAILER_LEN, nbytes);\n-        exit(1);\n-    }\n-    /* Header only, no trailer */\n-    sfd.hlen = HEADER_LEN;\n-    sfd.tlen = 0;\n-    nbytes = PR_SendFile(acceptSock, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n-                         PR_INTERVAL_NO_TIMEOUT);\n-    if (HEADER_LEN != nbytes) {\n-        fprintf(stderr, \"PR_SendFile should return %d but returned %d\\n\",\n-                HEADER_LEN, nbytes);\n-        exit(1);\n-    }\n-    /* Try PR_TransmitFile */\n-    nbytes = PR_TransmitFile(acceptSock, file, header, HEADER_LEN,\n-                             PR_TRANSMITFILE_KEEP_OPEN, PR_INTERVAL_NO_TIMEOUT);\n-    if (HEADER_LEN != nbytes) {\n-        fprintf(stderr, \"PR_TransmitFile should return %d but returned %d\\n\",\n-                HEADER_LEN, nbytes);\n-        exit(1);\n-    }\n-    if (PR_Close(acceptSock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Close(file) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Delete(ZERO_LEN_FILE_NAME) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Delete failed\\n\");\n-        exit(1);\n-    }\n+  /* Create a zero-length file */\n+  file =\n+      PR_Open(ZERO_LEN_FILE_NAME, PR_CREATE_FILE | PR_TRUNCATE | PR_RDWR, 0666);\n+  if (NULL == file) {\n+    fprintf(stderr, \"PR_Open failed\\n\");\n+    exit(1);\n+  }\n+  sfd.fd = file;\n+  sfd.file_offset = 0;\n+  sfd.file_nbytes = 0;\n+  memcpy(header, HEADER_STR, HEADER_LEN);\n+  memcpy(trailer, TRAILER_STR, TRAILER_LEN);\n+  sfd.header = header;\n+  sfd.hlen = HEADER_LEN;\n+  sfd.trailer = trailer;\n+  sfd.tlen = TRAILER_LEN;\n+  acceptSock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n+  if (NULL == acceptSock) {\n+    fprintf(stderr, \"PR_Accept failed\\n\");\n+    exit(1);\n+  }\n+  /* Send both header and trailer */\n+  nbytes = PR_SendFile(acceptSock, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n+                       PR_INTERVAL_NO_TIMEOUT);\n+  if (HEADER_LEN + TRAILER_LEN != nbytes) {\n+    fprintf(stderr, \"PR_SendFile should return %d but returned %d\\n\",\n+            HEADER_LEN + TRAILER_LEN, nbytes);\n+    exit(1);\n+  }\n+  /* Trailer only, no header */\n+  sfd.hlen = 0;\n+  nbytes = PR_SendFile(acceptSock, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n+                       PR_INTERVAL_NO_TIMEOUT);\n+  if (TRAILER_LEN != nbytes) {\n+    fprintf(stderr, \"PR_SendFile should return %d but returned %d\\n\",\n+            TRAILER_LEN, nbytes);\n+    exit(1);\n+  }\n+  /* Header only, no trailer */\n+  sfd.hlen = HEADER_LEN;\n+  sfd.tlen = 0;\n+  nbytes = PR_SendFile(acceptSock, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n+                       PR_INTERVAL_NO_TIMEOUT);\n+  if (HEADER_LEN != nbytes) {\n+    fprintf(stderr, \"PR_SendFile should return %d but returned %d\\n\",\n+            HEADER_LEN, nbytes);\n+    exit(1);\n+  }\n+  /* Try PR_TransmitFile */\n+  nbytes = PR_TransmitFile(acceptSock, file, header, HEADER_LEN,\n+                           PR_TRANSMITFILE_KEEP_OPEN, PR_INTERVAL_NO_TIMEOUT);\n+  if (HEADER_LEN != nbytes) {\n+    fprintf(stderr, \"PR_TransmitFile should return %d but returned %d\\n\",\n+            HEADER_LEN, nbytes);\n+    exit(1);\n+  }\n+  if (PR_Close(acceptSock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Close(file) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Delete(ZERO_LEN_FILE_NAME) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Delete failed\\n\");\n+    exit(1);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc* listenSock;\n-    PRThread* clientThread;\n-    PRThread* serverThread;\n-    PRNetAddr addr;\n-    PRThreadScope scope = PR_GLOBAL_THREAD;\n+int main(int argc, char** argv) {\n+  PRFileDesc* listenSock;\n+  PRThread* clientThread;\n+  PRThread* serverThread;\n+  PRNetAddr addr;\n+  PRThreadScope scope = PR_GLOBAL_THREAD;\n \n-    listenSock = PR_NewTCPSocket();\n-    if (NULL == listenSock) {\n-        fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_InitializeNetAddr(PR_IpAddrAny, 0, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Bind(listenSock, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Bind failed\\n\");\n-        exit(1);\n-    }\n-    /* Find out what port number we are bound to. */\n-    if (PR_GetSockName(listenSock, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Listen(listenSock, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Listen failed\\n\");\n-        exit(1);\n-    }\n+  listenSock = PR_NewTCPSocket();\n+  if (NULL == listenSock) {\n+    fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_InitializeNetAddr(PR_IpAddrAny, 0, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Bind(listenSock, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Bind failed\\n\");\n+    exit(1);\n+  }\n+  /* Find out what port number we are bound to. */\n+  if (PR_GetSockName(listenSock, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Listen(listenSock, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Listen failed\\n\");\n+    exit(1);\n+  }\n \n-    clientThread = PR_CreateThread(\n-        PR_USER_THREAD, ClientThread, (void*)PR_ntohs(PR_NetAddrInetPort(&addr)),\n-        PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n-    if (NULL == clientThread) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n-    }\n-    serverThread =\n-        PR_CreateThread(PR_USER_THREAD, ServerThread, listenSock,\n-                        PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n-    if (NULL == serverThread) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_JoinThread(clientThread) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_JoinThread(serverThread) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Close(listenSock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    printf(\"PASS\\n\");\n-    return 0;\n+  clientThread = PR_CreateThread(\n+      PR_USER_THREAD, ClientThread, (void*)PR_ntohs(PR_NetAddrInetPort(&addr)),\n+      PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n+  if (NULL == clientThread) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n+  serverThread =\n+      PR_CreateThread(PR_USER_THREAD, ServerThread, listenSock,\n+                      PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n+  if (NULL == serverThread) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_JoinThread(clientThread) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_JoinThread(serverThread) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Close(listenSock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/server_test.c b/nspr/pr/tests/server_test.c\nindex a004fe5..a9add05 100644\n--- a/nspr/pr/tests/server_test.c\n+++ b/nspr/pr/tests/server_test.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -61,9 +62,9 @@ PRCondVar* ServerStateCV;\n \n #undef DEBUGPRINTS\n #ifdef DEBUGPRINTS\n-#define DPRINTF printf\n+#  define DPRINTF printf\n #else\n-#define DPRINTF\n+#  define DPRINTF\n #endif\n \n /***********************************************************************\n@@ -82,61 +83,55 @@ PRCondVar* ServerStateCV;\n **\n ***********************************************************************/\n \n-static void\n-Test_Result(int result)\n-{\n-    switch (result) {\n-        case PASS:\n-            printf(\"PASS\\n\");\n-            break;\n-        case FAIL:\n-            printf(\"FAIL\\n\");\n-            failed_already = 1;\n-            break;\n-        default:\n-            break;\n-    }\n+static void Test_Result(int result) {\n+  switch (result) {\n+    case PASS:\n+      printf(\"PASS\\n\");\n+      break;\n+    case FAIL:\n+      printf(\"FAIL\\n\");\n+      failed_already = 1;\n+      break;\n+    default:\n+      break;\n+  }\n }\n \n static void do_work(void);\n \n /* --- Server state functions --------------------------------------------- */\n-void\n-SetServerState(char* waiter, PRInt32 state)\n-{\n-    PR_Lock(ServerStateCVLock);\n-    ServerState = state;\n-    PR_NotifyCondVar(ServerStateCV);\n+void SetServerState(char* waiter, PRInt32 state) {\n+  PR_Lock(ServerStateCVLock);\n+  ServerState = state;\n+  PR_NotifyCondVar(ServerStateCV);\n \n-    if (debug_mode) {\n-        DPRINTF(\"\\t%s changed state to %d\\n\", waiter, state);\n-    }\n+  if (debug_mode) {\n+    DPRINTF(\"\\t%s changed state to %d\\n\", waiter, state);\n+  }\n \n-    PR_Unlock(ServerStateCVLock);\n+  PR_Unlock(ServerStateCVLock);\n }\n \n-int\n-WaitServerState(char* waiter, PRInt32 state)\n-{\n-    PRInt32 rv;\n+int WaitServerState(char* waiter, PRInt32 state) {\n+  PRInt32 rv;\n \n-    PR_Lock(ServerStateCVLock);\n+  PR_Lock(ServerStateCVLock);\n \n-    if (debug_mode) {\n-        DPRINTF(\"\\t%s waiting for state %d\\n\", waiter, state);\n-    }\n+  if (debug_mode) {\n+    DPRINTF(\"\\t%s waiting for state %d\\n\", waiter, state);\n+  }\n \n-    while (!(ServerState & state)) {\n-        PR_WaitCondVar(ServerStateCV, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    rv = ServerState;\n+  while (!(ServerState & state)) {\n+    PR_WaitCondVar(ServerStateCV, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  rv = ServerState;\n \n-    if (debug_mode)\n-        DPRINTF(\"\\t%s resuming from wait for state %d; state now %d\\n\", waiter,\n-                state, ServerState);\n-    PR_Unlock(ServerStateCVLock);\n+  if (debug_mode)\n+    DPRINTF(\"\\t%s resuming from wait for state %d; state now %d\\n\", waiter,\n+            state, ServerState);\n+  PR_Unlock(ServerStateCVLock);\n \n-    return rv;\n+  return rv;\n }\n \n /* --- Server Functions ------------------------------------------- */\n@@ -145,224 +140,218 @@ PRLock* workerThreadsLock;\n PRInt32 workerThreads;\n PRInt32 workerThreadsBusy;\n \n-void\n-WorkerThreadFunc(void* _listenSock)\n-{\n-    PRFileDesc* listenSock = (PRFileDesc*)_listenSock;\n-    PRInt32 bytesRead;\n-    PRInt32 bytesWritten;\n-    char* dataBuf;\n-    char* sendBuf;\n-\n-    if (debug_mode)\n-        DPRINTF(\"\\tServer buffer is %d bytes; %d data, %d netaddrs\\n\",\n-                _client_data + (2 * sizeof(PRNetAddr)) + 32, _client_data,\n-                (2 * sizeof(PRNetAddr)) + 32);\n-    dataBuf = (char*)PR_MALLOC(_client_data + 2 * sizeof(PRNetAddr) + 32);\n-    if (!dataBuf)\n-        if (debug_mode) {\n-            printf(\"\\tServer could not malloc space!?\\n\");\n-        }\n-    sendBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n-    if (!sendBuf)\n-        if (debug_mode) {\n-            printf(\"\\tServer could not malloc space!?\\n\");\n-        }\n-\n+void WorkerThreadFunc(void* _listenSock) {\n+  PRFileDesc* listenSock = (PRFileDesc*)_listenSock;\n+  PRInt32 bytesRead;\n+  PRInt32 bytesWritten;\n+  char* dataBuf;\n+  char* sendBuf;\n+\n+  if (debug_mode)\n+    DPRINTF(\"\\tServer buffer is %d bytes; %d data, %d netaddrs\\n\",\n+            _client_data + (2 * sizeof(PRNetAddr)) + 32, _client_data,\n+            (2 * sizeof(PRNetAddr)) + 32);\n+  dataBuf = (char*)PR_MALLOC(_client_data + 2 * sizeof(PRNetAddr) + 32);\n+  if (!dataBuf)\n+    if (debug_mode) {\n+      printf(\"\\tServer could not malloc space!?\\n\");\n+    }\n+  sendBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n+  if (!sendBuf)\n     if (debug_mode) {\n-        DPRINTF(\"\\tServer worker thread running\\n\");\n+      printf(\"\\tServer could not malloc space!?\\n\");\n     }\n \n-    while (1) {\n-        PRInt32 bytesToRead = _client_data;\n-        PRInt32 bytesToWrite = _server_data;\n-        PRFileDesc* newSock;\n-        PRNetAddr* rAddr;\n-        PRInt32 loops = 0;\n+  if (debug_mode) {\n+    DPRINTF(\"\\tServer worker thread running\\n\");\n+  }\n \n-        loops++;\n+  while (1) {\n+    PRInt32 bytesToRead = _client_data;\n+    PRInt32 bytesToWrite = _server_data;\n+    PRFileDesc* newSock;\n+    PRNetAddr* rAddr;\n+    PRInt32 loops = 0;\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer thread going into accept\\n\");\n-        }\n+    loops++;\n \n-        bytesRead = PR_AcceptRead(listenSock, &newSock, &rAddr, dataBuf,\n-                                  bytesToRead, PR_INTERVAL_NO_TIMEOUT);\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer thread going into accept\\n\");\n+    }\n \n-        if (bytesRead < 0) {\n-            if (debug_mode) {\n-                printf(\"\\tServer error in accept (%d)\\n\", bytesRead);\n-            }\n-            continue;\n-        }\n+    bytesRead = PR_AcceptRead(listenSock, &newSock, &rAddr, dataBuf,\n+                              bytesToRead, PR_INTERVAL_NO_TIMEOUT);\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer accepted connection (%d bytes)\\n\", bytesRead);\n-        }\n+    if (bytesRead < 0) {\n+      if (debug_mode) {\n+        printf(\"\\tServer error in accept (%d)\\n\", bytesRead);\n+      }\n+      continue;\n+    }\n \n-        PR_AtomicIncrement(&workerThreadsBusy);\n-        if (workerThreadsBusy == workerThreads) {\n-            PR_Lock(workerThreadsLock);\n-            if (workerThreadsBusy == workerThreads) {\n-                PRThread* WorkerThread;\n-\n-                WorkerThread = PR_CreateThread(\n-                    PR_SYSTEM_THREAD, WorkerThreadFunc, listenSock, PR_PRIORITY_NORMAL,\n-                    ServerScope, PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n-\n-                if (!WorkerThread) {\n-                    if (debug_mode) {\n-                        printf(\"Error creating client thread %d\\n\", workerThreads);\n-                    }\n-                } else {\n-                    PR_AtomicIncrement(&workerThreads);\n-                    if (debug_mode) {\n-                        DPRINTF(\"\\tServer creates worker (%d)\\n\", workerThreads);\n-                    }\n-                }\n-            }\n-            PR_Unlock(workerThreadsLock);\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer accepted connection (%d bytes)\\n\", bytesRead);\n+    }\n \n-        bytesToRead -= bytesRead;\n-        while (bytesToRead) {\n-            bytesRead =\n-                PR_Recv(newSock, dataBuf, bytesToRead, 0, PR_INTERVAL_NO_TIMEOUT);\n-            if (bytesRead < 0) {\n-                if (debug_mode) {\n-                    printf(\"\\tServer error receiving data (%d)\\n\", bytesRead);\n-                }\n-                continue;\n-            }\n-            if (debug_mode) {\n-                DPRINTF(\"\\tServer received %d bytes\\n\", bytesRead);\n-            }\n-        }\n+    PR_AtomicIncrement(&workerThreadsBusy);\n+    if (workerThreadsBusy == workerThreads) {\n+      PR_Lock(workerThreadsLock);\n+      if (workerThreadsBusy == workerThreads) {\n+        PRThread* WorkerThread;\n+\n+        WorkerThread = PR_CreateThread(\n+            PR_SYSTEM_THREAD, WorkerThreadFunc, listenSock, PR_PRIORITY_NORMAL,\n+            ServerScope, PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n \n-        bytesWritten =\n-            PR_Send(newSock, sendBuf, bytesToWrite, 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (bytesWritten != _server_data) {\n-            if (debug_mode)\n-                printf(\"\\tError sending data to client (%d, %d)\\n\", bytesWritten,\n-                       PR_GetOSError());\n+        if (!WorkerThread) {\n+          if (debug_mode) {\n+            printf(\"Error creating client thread %d\\n\", workerThreads);\n+          }\n         } else {\n-            if (debug_mode) {\n-                DPRINTF(\"\\tServer sent %d bytes\\n\", bytesWritten);\n-            }\n+          PR_AtomicIncrement(&workerThreads);\n+          if (debug_mode) {\n+            DPRINTF(\"\\tServer creates worker (%d)\\n\", workerThreads);\n+          }\n         }\n-\n-        PR_Close(newSock);\n-        PR_AtomicDecrement(&workerThreadsBusy);\n+      }\n+      PR_Unlock(workerThreadsLock);\n     }\n-}\n-\n-PRFileDesc*\n-ServerSetup(void)\n-{\n-    PRFileDesc* listenSocket;\n-    PRSocketOptionData sockOpt;\n-    PRNetAddr serverAddr;\n-    PRThread* WorkerThread;\n \n-    if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n+    bytesToRead -= bytesRead;\n+    while (bytesToRead) {\n+      bytesRead =\n+          PR_Recv(newSock, dataBuf, bytesToRead, 0, PR_INTERVAL_NO_TIMEOUT);\n+      if (bytesRead < 0) {\n         if (debug_mode) {\n-            printf(\"\\tServer error creating listen socket\\n\");\n-        } else {\n-            Test_Result(FAIL);\n+          printf(\"\\tServer error receiving data (%d)\\n\", bytesRead);\n         }\n-        return NULL;\n+        continue;\n+      }\n+      if (debug_mode) {\n+        DPRINTF(\"\\tServer received %d bytes\\n\", bytesRead);\n+      }\n     }\n \n-    sockOpt.option = PR_SockOpt_Reuseaddr;\n-    sockOpt.value.reuse_addr = PR_TRUE;\n-    if (PR_SetSocketOption(listenSocket, &sockOpt) != PR_SUCCESS) {\n-        if (debug_mode)\n-            printf(\"\\tServer error setting socket option: OS error %d\\n\",\n-                   PR_GetOSError());\n-        else {\n-            Test_Result(FAIL);\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n+    bytesWritten =\n+        PR_Send(newSock, sendBuf, bytesToWrite, 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (bytesWritten != _server_data) {\n+      if (debug_mode)\n+        printf(\"\\tError sending data to client (%d, %d)\\n\", bytesWritten,\n+               PR_GetOSError());\n+    } else {\n+      if (debug_mode) {\n+        DPRINTF(\"\\tServer sent %d bytes\\n\", bytesWritten);\n+      }\n     }\n \n-    memset(&serverAddr, 0, sizeof(PRNetAddr));\n-    serverAddr.inet.family = PR_AF_INET;\n-    serverAddr.inet.port = PR_htons(PORT);\n-    serverAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+    PR_Close(newSock);\n+    PR_AtomicDecrement(&workerThreadsBusy);\n+  }\n+}\n \n-    if (PR_Bind(listenSocket, &serverAddr) != PR_SUCCESS) {\n-        if (debug_mode)\n-            printf(\"\\tServer error binding to server address: OS error %d\\n\",\n-                   PR_GetOSError());\n-        else {\n-            Test_Result(FAIL);\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n+PRFileDesc* ServerSetup(void) {\n+  PRFileDesc* listenSocket;\n+  PRSocketOptionData sockOpt;\n+  PRNetAddr serverAddr;\n+  PRThread* WorkerThread;\n+\n+  if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error creating listen socket\\n\");\n+    } else {\n+      Test_Result(FAIL);\n     }\n+    return NULL;\n+  }\n \n-    if (PR_Listen(listenSocket, 128) != PR_SUCCESS) {\n-        if (debug_mode) {\n-            printf(\"\\tServer error listening to server socket\\n\");\n-        } else {\n-            Test_Result(FAIL);\n-        }\n-        PR_Close(listenSocket);\n+  sockOpt.option = PR_SockOpt_Reuseaddr;\n+  sockOpt.value.reuse_addr = PR_TRUE;\n+  if (PR_SetSocketOption(listenSocket, &sockOpt) != PR_SUCCESS) {\n+    if (debug_mode)\n+      printf(\"\\tServer error setting socket option: OS error %d\\n\",\n+             PR_GetOSError());\n+    else {\n+      Test_Result(FAIL);\n+    }\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n \n-        return NULL;\n+  memset(&serverAddr, 0, sizeof(PRNetAddr));\n+  serverAddr.inet.family = PR_AF_INET;\n+  serverAddr.inet.port = PR_htons(PORT);\n+  serverAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+\n+  if (PR_Bind(listenSocket, &serverAddr) != PR_SUCCESS) {\n+    if (debug_mode)\n+      printf(\"\\tServer error binding to server address: OS error %d\\n\",\n+             PR_GetOSError());\n+    else {\n+      Test_Result(FAIL);\n     }\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n \n-    /* Create Clients */\n-    workerThreads = 0;\n-    workerThreadsBusy = 0;\n+  if (PR_Listen(listenSocket, 128) != PR_SUCCESS) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error listening to server socket\\n\");\n+    } else {\n+      Test_Result(FAIL);\n+    }\n+    PR_Close(listenSocket);\n \n-    workerThreadsLock = PR_NewLock();\n+    return NULL;\n+  }\n \n-    WorkerThread = PR_CreateThread(PR_SYSTEM_THREAD, WorkerThreadFunc,\n-                                   listenSocket, PR_PRIORITY_NORMAL, ServerScope,\n-                                   PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+  /* Create Clients */\n+  workerThreads = 0;\n+  workerThreadsBusy = 0;\n \n-    if (!WorkerThread) {\n-        if (debug_mode) {\n-            printf(\"error creating working thread\\n\");\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n-    }\n-    PR_AtomicIncrement(&workerThreads);\n+  workerThreadsLock = PR_NewLock();\n+\n+  WorkerThread = PR_CreateThread(PR_SYSTEM_THREAD, WorkerThreadFunc,\n+                                 listenSocket, PR_PRIORITY_NORMAL, ServerScope,\n+                                 PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+\n+  if (!WorkerThread) {\n     if (debug_mode) {\n-        DPRINTF(\"\\tServer created primordial worker thread\\n\");\n+      printf(\"error creating working thread\\n\");\n     }\n-\n-    return listenSocket;\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n+  PR_AtomicIncrement(&workerThreads);\n+  if (debug_mode) {\n+    DPRINTF(\"\\tServer created primordial worker thread\\n\");\n+  }\n+\n+  return listenSocket;\n }\n \n /* The main server loop */\n-void\n-ServerThreadFunc(void* unused)\n-{\n-    PRFileDesc* listenSocket;\n+void ServerThreadFunc(void* unused) {\n+  PRFileDesc* listenSocket;\n \n-    /* Do setup */\n-    listenSocket = ServerSetup();\n+  /* Do setup */\n+  listenSocket = ServerSetup();\n \n-    if (!listenSocket) {\n-        SetServerState(SERVER, SERVER_STATE_DEAD);\n-    } else {\n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer up\\n\");\n-        }\n+  if (!listenSocket) {\n+    SetServerState(SERVER, SERVER_STATE_DEAD);\n+  } else {\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer up\\n\");\n+    }\n \n-        /* Tell clients they can start now. */\n-        SetServerState(SERVER, SERVER_STATE_READY);\n+    /* Tell clients they can start now. */\n+    SetServerState(SERVER, SERVER_STATE_READY);\n \n-        /* Now wait for server death signal */\n-        WaitServerState(SERVER, SERVER_STATE_DYING);\n+    /* Now wait for server death signal */\n+    WaitServerState(SERVER, SERVER_STATE_DYING);\n \n-        /* Cleanup */\n-        SetServerState(SERVER, SERVER_STATE_DEAD);\n-    }\n+    /* Cleanup */\n+    SetServerState(SERVER, SERVER_STATE_DEAD);\n+  }\n }\n \n /* --- Client Functions ------------------------------------------- */\n@@ -371,283 +360,265 @@ PRInt32 numRequests;\n PRInt32 numClients;\n PRMonitor* clientMonitor;\n \n-void\n-ClientThreadFunc(void* unused)\n-{\n-    PRNetAddr serverAddr;\n-    PRFileDesc* clientSocket;\n-    char* sendBuf;\n-    char* recvBuf;\n-    PRInt32 rv;\n-    PRInt32 bytesNeeded;\n-\n-    sendBuf = (char*)PR_MALLOC(_client_data * sizeof(char));\n-    if (!sendBuf)\n-        if (debug_mode) {\n-            printf(\"\\tClient could not malloc space!?\\n\");\n-        }\n-    recvBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n-    if (!recvBuf)\n-        if (debug_mode) {\n-            printf(\"\\tClient could not malloc space!?\\n\");\n-        }\n-\n-    memset(&serverAddr, 0, sizeof(PRNetAddr));\n-    serverAddr.inet.family = PR_AF_INET;\n-    serverAddr.inet.port = PR_htons(PORT);\n-    serverAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n+void ClientThreadFunc(void* unused) {\n+  PRNetAddr serverAddr;\n+  PRFileDesc* clientSocket;\n+  char* sendBuf;\n+  char* recvBuf;\n+  PRInt32 rv;\n+  PRInt32 bytesNeeded;\n \n-    while (numRequests > 0) {\n-        if ((numRequests % 10) == 0)\n-            if (debug_mode) {\n-                printf(\".\");\n-            }\n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient starting request %d\\n\", numRequests);\n-        }\n+  sendBuf = (char*)PR_MALLOC(_client_data * sizeof(char));\n+  if (!sendBuf)\n+    if (debug_mode) {\n+      printf(\"\\tClient could not malloc space!?\\n\");\n+    }\n+  recvBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n+  if (!recvBuf)\n+    if (debug_mode) {\n+      printf(\"\\tClient could not malloc space!?\\n\");\n+    }\n \n-        clientSocket = PR_NewTCPSocket();\n-        if (!clientSocket) {\n-            if (debug_mode)\n-                printf(\"Client error creating socket: OS error %d\\n\", PR_GetOSError());\n-            continue;\n-        }\n+  memset(&serverAddr, 0, sizeof(PRNetAddr));\n+  serverAddr.inet.family = PR_AF_INET;\n+  serverAddr.inet.port = PR_htons(PORT);\n+  serverAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient connecting\\n\");\n-        }\n+  while (numRequests > 0) {\n+    if ((numRequests % 10) == 0)\n+      if (debug_mode) {\n+        printf(\".\");\n+      }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient starting request %d\\n\", numRequests);\n+    }\n \n-        rv = PR_Connect(clientSocket, &serverAddr, PR_INTERVAL_NO_TIMEOUT);\n-        if (!clientSocket) {\n-            if (debug_mode) {\n-                printf(\"\\tClient error connecting\\n\");\n-            }\n-            continue;\n-        }\n+    clientSocket = PR_NewTCPSocket();\n+    if (!clientSocket) {\n+      if (debug_mode)\n+        printf(\"Client error creating socket: OS error %d\\n\", PR_GetOSError());\n+      continue;\n+    }\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient connected\\n\");\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient connecting\\n\");\n+    }\n \n-        rv =\n-            PR_Send(clientSocket, sendBuf, _client_data, 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (rv != _client_data) {\n-            if (debug_mode) {\n-                printf(\"Client error sending data (%d)\\n\", rv);\n-            }\n-            PR_Close(clientSocket);\n-            continue;\n-        }\n+    rv = PR_Connect(clientSocket, &serverAddr, PR_INTERVAL_NO_TIMEOUT);\n+    if (!clientSocket) {\n+      if (debug_mode) {\n+        printf(\"\\tClient error connecting\\n\");\n+      }\n+      continue;\n+    }\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient sent %d bytes\\n\", rv);\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient connected\\n\");\n+    }\n \n-        bytesNeeded = _server_data;\n-        while (bytesNeeded) {\n-            rv = PR_Recv(clientSocket, recvBuf, bytesNeeded, 0,\n-                         PR_INTERVAL_NO_TIMEOUT);\n-            if (rv <= 0) {\n-                if (debug_mode)\n-                    printf(\"Client error receiving data (%d) (%d/%d)\\n\", rv,\n-                           (_server_data - bytesNeeded), _server_data);\n-                break;\n-            }\n-            if (debug_mode) {\n-                DPRINTF(\"\\tClient received %d bytes; need %d more\\n\", rv,\n-                        bytesNeeded - rv);\n-            }\n-            bytesNeeded -= rv;\n-        }\n+    rv =\n+        PR_Send(clientSocket, sendBuf, _client_data, 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (rv != _client_data) {\n+      if (debug_mode) {\n+        printf(\"Client error sending data (%d)\\n\", rv);\n+      }\n+      PR_Close(clientSocket);\n+      continue;\n+    }\n \n-        PR_Close(clientSocket);\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient sent %d bytes\\n\", rv);\n+    }\n \n-        PR_AtomicDecrement(&numRequests);\n+    bytesNeeded = _server_data;\n+    while (bytesNeeded) {\n+      rv = PR_Recv(clientSocket, recvBuf, bytesNeeded, 0,\n+                   PR_INTERVAL_NO_TIMEOUT);\n+      if (rv <= 0) {\n+        if (debug_mode)\n+          printf(\"Client error receiving data (%d) (%d/%d)\\n\", rv,\n+                 (_server_data - bytesNeeded), _server_data);\n+        break;\n+      }\n+      if (debug_mode) {\n+        DPRINTF(\"\\tClient received %d bytes; need %d more\\n\", rv,\n+                bytesNeeded - rv);\n+      }\n+      bytesNeeded -= rv;\n     }\n \n-    PR_EnterMonitor(clientMonitor);\n-    --numClients;\n-    PR_Notify(clientMonitor);\n-    PR_ExitMonitor(clientMonitor);\n+    PR_Close(clientSocket);\n \n-    PR_DELETE(sendBuf);\n-    PR_DELETE(recvBuf);\n+    PR_AtomicDecrement(&numRequests);\n+  }\n+\n+  PR_EnterMonitor(clientMonitor);\n+  --numClients;\n+  PR_Notify(clientMonitor);\n+  PR_ExitMonitor(clientMonitor);\n+\n+  PR_DELETE(sendBuf);\n+  PR_DELETE(recvBuf);\n }\n \n-void\n-RunClients(void)\n-{\n-    PRInt32 index;\n+void RunClients(void) {\n+  PRInt32 index;\n \n-    numRequests = _iterations;\n-    numClients = _clients;\n-    clientMonitor = PR_NewMonitor();\n+  numRequests = _iterations;\n+  numClients = _clients;\n+  clientMonitor = PR_NewMonitor();\n \n-    for (index = 0; index < _clients; index++) {\n-        PRThread* clientThread;\n+  for (index = 0; index < _clients; index++) {\n+    PRThread* clientThread;\n \n-        clientThread = PR_CreateThread(PR_USER_THREAD, ClientThreadFunc, NULL,\n-                                       PR_PRIORITY_NORMAL, ClientScope,\n-                                       PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+    clientThread = PR_CreateThread(PR_USER_THREAD, ClientThreadFunc, NULL,\n+                                   PR_PRIORITY_NORMAL, ClientScope,\n+                                   PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n \n-        if (!clientThread) {\n-            if (debug_mode) {\n-                printf(\"\\terror creating client thread %d\\n\", index);\n-            }\n-        } else if (debug_mode) {\n-            DPRINTF(\"\\tMain created client %d/%d\\n\", index + 1, _clients);\n-        }\n+    if (!clientThread) {\n+      if (debug_mode) {\n+        printf(\"\\terror creating client thread %d\\n\", index);\n+      }\n+    } else if (debug_mode) {\n+      DPRINTF(\"\\tMain created client %d/%d\\n\", index + 1, _clients);\n     }\n+  }\n \n-    PR_EnterMonitor(clientMonitor);\n-    while (numClients) {\n-        PR_Wait(clientMonitor, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_ExitMonitor(clientMonitor);\n+  PR_EnterMonitor(clientMonitor);\n+  while (numClients) {\n+    PR_Wait(clientMonitor, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_ExitMonitor(clientMonitor);\n }\n \n /* --- Main Function ---------------------------------------------- */\n \n-static void\n-do_work()\n-{\n-    PRThread* ServerThread;\n-    PRInt32 state;\n-\n-    SetServerState(MAIN, SERVER_STATE_STARTUP);\n-    ServerThread = PR_CreateThread(PR_USER_THREAD, ServerThreadFunc, NULL,\n-                                   PR_PRIORITY_NORMAL, ServerScope,\n-                                   PR_JOINABLE_THREAD, THREAD_STACKSIZE);\n-    if (!ServerThread) {\n-        if (debug_mode) {\n-            printf(\"error creating main server thread\\n\");\n-        }\n-        return;\n+static void do_work() {\n+  PRThread* ServerThread;\n+  PRInt32 state;\n+\n+  SetServerState(MAIN, SERVER_STATE_STARTUP);\n+  ServerThread = PR_CreateThread(PR_USER_THREAD, ServerThreadFunc, NULL,\n+                                 PR_PRIORITY_NORMAL, ServerScope,\n+                                 PR_JOINABLE_THREAD, THREAD_STACKSIZE);\n+  if (!ServerThread) {\n+    if (debug_mode) {\n+      printf(\"error creating main server thread\\n\");\n     }\n+    return;\n+  }\n \n-    /* Wait for server to be ready */\n-    state = WaitServerState(MAIN, SERVER_STATE_READY | SERVER_STATE_DEAD);\n+  /* Wait for server to be ready */\n+  state = WaitServerState(MAIN, SERVER_STATE_READY | SERVER_STATE_DEAD);\n \n-    if (!(state & SERVER_STATE_DEAD)) {\n-        /* Run Test Clients */\n-        RunClients();\n+  if (!(state & SERVER_STATE_DEAD)) {\n+    /* Run Test Clients */\n+    RunClients();\n \n-        /* Send death signal to server */\n-        SetServerState(MAIN, SERVER_STATE_DYING);\n-    }\n+    /* Send death signal to server */\n+    SetServerState(MAIN, SERVER_STATE_DYING);\n+  }\n \n-    PR_JoinThread(ServerThread);\n+  PR_JoinThread(ServerThread);\n }\n \n-static void\n-do_workUU(void)\n-{\n-    ServerScope = PR_LOCAL_THREAD;\n-    ClientScope = PR_LOCAL_THREAD;\n-    do_work();\n+static void do_workUU(void) {\n+  ServerScope = PR_LOCAL_THREAD;\n+  ClientScope = PR_LOCAL_THREAD;\n+  do_work();\n }\n \n-static void\n-do_workUK(void)\n-{\n-    ServerScope = PR_LOCAL_THREAD;\n-    ClientScope = PR_GLOBAL_THREAD;\n-    do_work();\n+static void do_workUK(void) {\n+  ServerScope = PR_LOCAL_THREAD;\n+  ClientScope = PR_GLOBAL_THREAD;\n+  do_work();\n }\n \n-static void\n-do_workKU(void)\n-{\n-    ServerScope = PR_GLOBAL_THREAD;\n-    ClientScope = PR_LOCAL_THREAD;\n-    do_work();\n+static void do_workKU(void) {\n+  ServerScope = PR_GLOBAL_THREAD;\n+  ClientScope = PR_LOCAL_THREAD;\n+  do_work();\n }\n \n-static void\n-do_workKK(void)\n-{\n-    ServerScope = PR_GLOBAL_THREAD;\n-    ClientScope = PR_GLOBAL_THREAD;\n-    do_work();\n+static void do_workKK(void) {\n+  ServerScope = PR_GLOBAL_THREAD;\n+  ClientScope = PR_GLOBAL_THREAD;\n+  do_work();\n }\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow();\n \n-    d = (double)PR_IntervalToMicroseconds(stop - start);\n+  d = (double)PR_IntervalToMicroseconds(stop - start);\n \n-    if (debug_mode) {\n-        printf(\"\\n%40s: %6.2f usec\\n\", msg, d / _iterations);\n-    }\n+  if (debug_mode) {\n+    printf(\"\\n%40s: %6.2f usec\\n\", msg, d / _iterations);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-    if (debug_mode) {\n-        printf(\"Enter number of iterations: \\n\");\n-        scanf(\"%d\", &_iterations);\n-        printf(\"Enter number of clients   : \\n\");\n-        scanf(\"%d\", &_clients);\n-        printf(\"Enter size of client data : \\n\");\n-        scanf(\"%d\", &_client_data);\n-        printf(\"Enter size of server data : \\n\");\n-        scanf(\"%d\", &_server_data);\n-    } else {\n-        _iterations = 10;\n-        _clients = 1;\n-        _client_data = 10;\n-        _server_data = 10;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n-\n-    if (debug_mode) {\n-        printf(\"\\n\\n%d iterations with %d client threads.\\n\", _iterations,\n-               _clients);\n-        printf(\"Sending %d bytes of client data and %d bytes of server data\\n\",\n-               _client_data, _server_data);\n-    }\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    ServerStateCVLock = PR_NewLock();\n-    ServerStateCV = PR_NewCondVar(ServerStateCVLock);\n-\n-    Measure(do_workUU, \"server loop user/user\");\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+  if (debug_mode) {\n+    printf(\"Enter number of iterations: \\n\");\n+    scanf(\"%d\", &_iterations);\n+    printf(\"Enter number of clients   : \\n\");\n+    scanf(\"%d\", &_clients);\n+    printf(\"Enter size of client data : \\n\");\n+    scanf(\"%d\", &_client_data);\n+    printf(\"Enter size of server data : \\n\");\n+    scanf(\"%d\", &_server_data);\n+  } else {\n+    _iterations = 10;\n+    _clients = 1;\n+    _client_data = 10;\n+    _server_data = 10;\n+  }\n+\n+  if (debug_mode) {\n+    printf(\"\\n\\n%d iterations with %d client threads.\\n\", _iterations,\n+           _clients);\n+    printf(\"Sending %d bytes of client data and %d bytes of server data\\n\",\n+           _client_data, _server_data);\n+  }\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  ServerStateCVLock = PR_NewLock();\n+  ServerStateCV = PR_NewCondVar(ServerStateCVLock);\n+\n+  Measure(do_workUU, \"server loop user/user\");\n #if 0\n     Measure(do_workUK, \"server loop user/kernel\");\n     Measure(do_workKU, \"server loop kernel/user\");\n     Measure(do_workKK, \"server loop kernel/kernel\");\n #endif\n \n-    PR_Cleanup();\n+  PR_Cleanup();\n \n-    return failed_already;\n+  return failed_already;\n }\ndiff --git a/nspr/pr/tests/servr_kk.c b/nspr/pr/tests/servr_kk.c\nindex 3c5c524..9d9b2fa 100644\n--- a/nspr/pr/tests/servr_kk.c\n+++ b/nspr/pr/tests/servr_kk.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -58,9 +59,9 @@ PRLock* ServerStateCVLock;\n PRCondVar* ServerStateCV;\n \n #ifdef DEBUGPRINTS\n-#define DPRINTF printf\n+#  define DPRINTF printf\n #else\n-#define DPRINTF\n+#  define DPRINTF\n #endif\n \n PRIntn failed_already = 0;\n@@ -68,42 +69,38 @@ PRIntn debug_mode;\n static void do_work(void);\n \n /* --- Server state functions --------------------------------------------- */\n-void\n-SetServerState(char* waiter, PRInt32 state)\n-{\n-    PR_Lock(ServerStateCVLock);\n-    ServerState = state;\n-    PR_NotifyCondVar(ServerStateCV);\n+void SetServerState(char* waiter, PRInt32 state) {\n+  PR_Lock(ServerStateCVLock);\n+  ServerState = state;\n+  PR_NotifyCondVar(ServerStateCV);\n \n-    if (debug_mode) {\n-        DPRINTF(\"\\t%s changed state to %d\\n\", waiter, state);\n-    }\n+  if (debug_mode) {\n+    DPRINTF(\"\\t%s changed state to %d\\n\", waiter, state);\n+  }\n \n-    PR_Unlock(ServerStateCVLock);\n+  PR_Unlock(ServerStateCVLock);\n }\n \n-int\n-WaitServerState(char* waiter, PRInt32 state)\n-{\n-    PRInt32 rv;\n+int WaitServerState(char* waiter, PRInt32 state) {\n+  PRInt32 rv;\n \n-    PR_Lock(ServerStateCVLock);\n+  PR_Lock(ServerStateCVLock);\n \n-    if (debug_mode) {\n-        DPRINTF(\"\\t%s waiting for state %d\\n\", waiter, state);\n-    }\n+  if (debug_mode) {\n+    DPRINTF(\"\\t%s waiting for state %d\\n\", waiter, state);\n+  }\n \n-    while (!(ServerState & state)) {\n-        PR_WaitCondVar(ServerStateCV, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    rv = ServerState;\n+  while (!(ServerState & state)) {\n+    PR_WaitCondVar(ServerStateCV, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  rv = ServerState;\n \n-    if (debug_mode)\n-        DPRINTF(\"\\t%s resuming from wait for state %d; state now %d\\n\", waiter,\n-                state, ServerState);\n-    PR_Unlock(ServerStateCVLock);\n+  if (debug_mode)\n+    DPRINTF(\"\\t%s resuming from wait for state %d; state now %d\\n\", waiter,\n+            state, ServerState);\n+  PR_Unlock(ServerStateCVLock);\n \n-    return rv;\n+  return rv;\n }\n \n /* --- Server Functions ------------------------------------------- */\n@@ -112,224 +109,218 @@ PRLock* workerThreadsLock;\n PRInt32 workerThreads;\n PRInt32 workerThreadsBusy;\n \n-void\n-WorkerThreadFunc(void* _listenSock)\n-{\n-    PRFileDesc* listenSock = (PRFileDesc*)_listenSock;\n-    PRInt32 bytesRead;\n-    PRInt32 bytesWritten;\n-    char* dataBuf;\n-    char* sendBuf;\n-\n-    if (debug_mode)\n-        DPRINTF(\"\\tServer buffer is %d bytes; %d data, %d netaddrs\\n\",\n-                _client_data + (2 * sizeof(PRNetAddr)) + 32, _client_data,\n-                (2 * sizeof(PRNetAddr)) + 32);\n-    dataBuf = (char*)PR_MALLOC(_client_data + 2 * sizeof(PRNetAddr) + 32);\n-    if (!dataBuf)\n-        if (debug_mode) {\n-            printf(\"\\tServer could not malloc space!?\\n\");\n-        }\n-    sendBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n-    if (!sendBuf)\n-        if (debug_mode) {\n-            printf(\"\\tServer could not malloc space!?\\n\");\n-        }\n-\n+void WorkerThreadFunc(void* _listenSock) {\n+  PRFileDesc* listenSock = (PRFileDesc*)_listenSock;\n+  PRInt32 bytesRead;\n+  PRInt32 bytesWritten;\n+  char* dataBuf;\n+  char* sendBuf;\n+\n+  if (debug_mode)\n+    DPRINTF(\"\\tServer buffer is %d bytes; %d data, %d netaddrs\\n\",\n+            _client_data + (2 * sizeof(PRNetAddr)) + 32, _client_data,\n+            (2 * sizeof(PRNetAddr)) + 32);\n+  dataBuf = (char*)PR_MALLOC(_client_data + 2 * sizeof(PRNetAddr) + 32);\n+  if (!dataBuf)\n+    if (debug_mode) {\n+      printf(\"\\tServer could not malloc space!?\\n\");\n+    }\n+  sendBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n+  if (!sendBuf)\n     if (debug_mode) {\n-        DPRINTF(\"\\tServer worker thread running\\n\");\n+      printf(\"\\tServer could not malloc space!?\\n\");\n     }\n \n-    while (1) {\n-        PRInt32 bytesToRead = _client_data;\n-        PRInt32 bytesToWrite = _server_data;\n-        PRFileDesc* newSock;\n-        PRNetAddr* rAddr;\n-        PRInt32 loops = 0;\n+  if (debug_mode) {\n+    DPRINTF(\"\\tServer worker thread running\\n\");\n+  }\n \n-        loops++;\n+  while (1) {\n+    PRInt32 bytesToRead = _client_data;\n+    PRInt32 bytesToWrite = _server_data;\n+    PRFileDesc* newSock;\n+    PRNetAddr* rAddr;\n+    PRInt32 loops = 0;\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer thread going into accept\\n\");\n-        }\n+    loops++;\n \n-        bytesRead = PR_AcceptRead(listenSock, &newSock, &rAddr, dataBuf,\n-                                  bytesToRead, PR_INTERVAL_NO_TIMEOUT);\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer thread going into accept\\n\");\n+    }\n \n-        if (bytesRead < 0) {\n-            if (debug_mode) {\n-                printf(\"\\tServer error in accept (%d)\\n\", bytesRead);\n-            }\n-            continue;\n-        }\n+    bytesRead = PR_AcceptRead(listenSock, &newSock, &rAddr, dataBuf,\n+                              bytesToRead, PR_INTERVAL_NO_TIMEOUT);\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer accepted connection (%d bytes)\\n\", bytesRead);\n-        }\n+    if (bytesRead < 0) {\n+      if (debug_mode) {\n+        printf(\"\\tServer error in accept (%d)\\n\", bytesRead);\n+      }\n+      continue;\n+    }\n \n-        PR_AtomicIncrement(&workerThreadsBusy);\n-        if (workerThreadsBusy == workerThreads) {\n-            PR_Lock(workerThreadsLock);\n-            if (workerThreadsBusy == workerThreads) {\n-                PRThread* WorkerThread;\n-\n-                WorkerThread = PR_CreateThread(\n-                    PR_SYSTEM_THREAD, WorkerThreadFunc, listenSock, PR_PRIORITY_NORMAL,\n-                    ServerScope, PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n-\n-                if (!WorkerThread) {\n-                    if (debug_mode) {\n-                        printf(\"Error creating client thread %d\\n\", workerThreads);\n-                    }\n-                } else {\n-                    PR_AtomicIncrement(&workerThreads);\n-                    if (debug_mode) {\n-                        DPRINTF(\"\\tServer creates worker (%d)\\n\", workerThreads);\n-                    }\n-                }\n-            }\n-            PR_Unlock(workerThreadsLock);\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer accepted connection (%d bytes)\\n\", bytesRead);\n+    }\n \n-        bytesToRead -= bytesRead;\n-        while (bytesToRead) {\n-            bytesRead =\n-                PR_Recv(newSock, dataBuf, bytesToRead, 0, PR_INTERVAL_NO_TIMEOUT);\n-            if (bytesRead < 0) {\n-                if (debug_mode) {\n-                    printf(\"\\tServer error receiving data (%d)\\n\", bytesRead);\n-                }\n-                continue;\n-            }\n-            if (debug_mode) {\n-                DPRINTF(\"\\tServer received %d bytes\\n\", bytesRead);\n-            }\n-        }\n+    PR_AtomicIncrement(&workerThreadsBusy);\n+    if (workerThreadsBusy == workerThreads) {\n+      PR_Lock(workerThreadsLock);\n+      if (workerThreadsBusy == workerThreads) {\n+        PRThread* WorkerThread;\n+\n+        WorkerThread = PR_CreateThread(\n+            PR_SYSTEM_THREAD, WorkerThreadFunc, listenSock, PR_PRIORITY_NORMAL,\n+            ServerScope, PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n \n-        bytesWritten =\n-            PR_Send(newSock, sendBuf, bytesToWrite, 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (bytesWritten != _server_data) {\n-            if (debug_mode)\n-                printf(\"\\tError sending data to client (%d, %d)\\n\", bytesWritten,\n-                       PR_GetOSError());\n+        if (!WorkerThread) {\n+          if (debug_mode) {\n+            printf(\"Error creating client thread %d\\n\", workerThreads);\n+          }\n         } else {\n-            if (debug_mode) {\n-                DPRINTF(\"\\tServer sent %d bytes\\n\", bytesWritten);\n-            }\n+          PR_AtomicIncrement(&workerThreads);\n+          if (debug_mode) {\n+            DPRINTF(\"\\tServer creates worker (%d)\\n\", workerThreads);\n+          }\n         }\n-\n-        PR_Close(newSock);\n-        PR_AtomicDecrement(&workerThreadsBusy);\n+      }\n+      PR_Unlock(workerThreadsLock);\n     }\n-}\n-\n-PRFileDesc*\n-ServerSetup(void)\n-{\n-    PRFileDesc* listenSocket;\n-    PRSocketOptionData sockOpt;\n-    PRNetAddr serverAddr;\n-    PRThread* WorkerThread;\n \n-    if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n+    bytesToRead -= bytesRead;\n+    while (bytesToRead) {\n+      bytesRead =\n+          PR_Recv(newSock, dataBuf, bytesToRead, 0, PR_INTERVAL_NO_TIMEOUT);\n+      if (bytesRead < 0) {\n         if (debug_mode) {\n-            printf(\"\\tServer error creating listen socket\\n\");\n-        } else {\n-            failed_already = 1;\n+          printf(\"\\tServer error receiving data (%d)\\n\", bytesRead);\n         }\n-        return NULL;\n+        continue;\n+      }\n+      if (debug_mode) {\n+        DPRINTF(\"\\tServer received %d bytes\\n\", bytesRead);\n+      }\n     }\n \n-    sockOpt.option = PR_SockOpt_Reuseaddr;\n-    sockOpt.value.reuse_addr = PR_TRUE;\n-    if (PR_SetSocketOption(listenSocket, &sockOpt) == PR_FAILURE) {\n-        if (debug_mode)\n-            printf(\"\\tServer error setting socket option: OS error %d\\n\",\n-                   PR_GetOSError());\n-        else {\n-            failed_already = 1;\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n+    bytesWritten =\n+        PR_Send(newSock, sendBuf, bytesToWrite, 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (bytesWritten != _server_data) {\n+      if (debug_mode)\n+        printf(\"\\tError sending data to client (%d, %d)\\n\", bytesWritten,\n+               PR_GetOSError());\n+    } else {\n+      if (debug_mode) {\n+        DPRINTF(\"\\tServer sent %d bytes\\n\", bytesWritten);\n+      }\n     }\n \n-    memset(&serverAddr, 0, sizeof(PRNetAddr));\n-    serverAddr.inet.family = PR_AF_INET;\n-    serverAddr.inet.port = PR_htons(PORT);\n-    serverAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+    PR_Close(newSock);\n+    PR_AtomicDecrement(&workerThreadsBusy);\n+  }\n+}\n \n-    if (PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {\n-        if (debug_mode)\n-            printf(\"\\tServer error binding to server address: OS error %d\\n\",\n-                   PR_GetOSError());\n-        else {\n-            failed_already = 1;\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n+PRFileDesc* ServerSetup(void) {\n+  PRFileDesc* listenSocket;\n+  PRSocketOptionData sockOpt;\n+  PRNetAddr serverAddr;\n+  PRThread* WorkerThread;\n+\n+  if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error creating listen socket\\n\");\n+    } else {\n+      failed_already = 1;\n     }\n+    return NULL;\n+  }\n \n-    if (PR_Listen(listenSocket, 128) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tServer error listening to server socket\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        PR_Close(listenSocket);\n+  sockOpt.option = PR_SockOpt_Reuseaddr;\n+  sockOpt.value.reuse_addr = PR_TRUE;\n+  if (PR_SetSocketOption(listenSocket, &sockOpt) == PR_FAILURE) {\n+    if (debug_mode)\n+      printf(\"\\tServer error setting socket option: OS error %d\\n\",\n+             PR_GetOSError());\n+    else {\n+      failed_already = 1;\n+    }\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n+\n+  memset(&serverAddr, 0, sizeof(PRNetAddr));\n+  serverAddr.inet.family = PR_AF_INET;\n+  serverAddr.inet.port = PR_htons(PORT);\n+  serverAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n \n-        return NULL;\n+  if (PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {\n+    if (debug_mode)\n+      printf(\"\\tServer error binding to server address: OS error %d\\n\",\n+             PR_GetOSError());\n+    else {\n+      failed_already = 1;\n     }\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n \n-    /* Create Clients */\n-    workerThreads = 0;\n-    workerThreadsBusy = 0;\n+  if (PR_Listen(listenSocket, 128) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error listening to server socket\\n\");\n+    } else {\n+      failed_already = 1;\n+    }\n+    PR_Close(listenSocket);\n \n-    workerThreadsLock = PR_NewLock();\n+    return NULL;\n+  }\n \n-    WorkerThread = PR_CreateThread(PR_SYSTEM_THREAD, WorkerThreadFunc,\n-                                   listenSocket, PR_PRIORITY_NORMAL, ServerScope,\n-                                   PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+  /* Create Clients */\n+  workerThreads = 0;\n+  workerThreadsBusy = 0;\n \n-    if (!WorkerThread) {\n-        if (debug_mode) {\n-            printf(\"error creating working thread\\n\");\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n-    }\n-    PR_AtomicIncrement(&workerThreads);\n+  workerThreadsLock = PR_NewLock();\n+\n+  WorkerThread = PR_CreateThread(PR_SYSTEM_THREAD, WorkerThreadFunc,\n+                                 listenSocket, PR_PRIORITY_NORMAL, ServerScope,\n+                                 PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+\n+  if (!WorkerThread) {\n     if (debug_mode) {\n-        DPRINTF(\"\\tServer created primordial worker thread\\n\");\n+      printf(\"error creating working thread\\n\");\n     }\n-\n-    return listenSocket;\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n+  PR_AtomicIncrement(&workerThreads);\n+  if (debug_mode) {\n+    DPRINTF(\"\\tServer created primordial worker thread\\n\");\n+  }\n+\n+  return listenSocket;\n }\n \n /* The main server loop */\n-void\n-ServerThreadFunc(void* unused)\n-{\n-    PRFileDesc* listenSocket;\n+void ServerThreadFunc(void* unused) {\n+  PRFileDesc* listenSocket;\n \n-    /* Do setup */\n-    listenSocket = ServerSetup();\n+  /* Do setup */\n+  listenSocket = ServerSetup();\n \n-    if (!listenSocket) {\n-        SetServerState(SERVER, SERVER_STATE_DEAD);\n-    } else {\n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer up\\n\");\n-        }\n+  if (!listenSocket) {\n+    SetServerState(SERVER, SERVER_STATE_DEAD);\n+  } else {\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer up\\n\");\n+    }\n \n-        /* Tell clients they can start now. */\n-        SetServerState(SERVER, SERVER_STATE_READY);\n+    /* Tell clients they can start now. */\n+    SetServerState(SERVER, SERVER_STATE_READY);\n \n-        /* Now wait for server death signal */\n-        WaitServerState(SERVER, SERVER_STATE_DYING);\n+    /* Now wait for server death signal */\n+    WaitServerState(SERVER, SERVER_STATE_DYING);\n \n-        /* Cleanup */\n-        SetServerState(SERVER, SERVER_STATE_DEAD);\n-    }\n+    /* Cleanup */\n+    SetServerState(SERVER, SERVER_STATE_DEAD);\n+  }\n }\n \n /* --- Client Functions ------------------------------------------- */\n@@ -338,284 +329,266 @@ PRInt32 numRequests;\n PRInt32 numClients;\n PRMonitor* clientMonitor;\n \n-void\n-ClientThreadFunc(void* unused)\n-{\n-    PRNetAddr serverAddr;\n-    PRFileDesc* clientSocket;\n-    char* sendBuf;\n-    char* recvBuf;\n-    PRInt32 rv;\n-    PRInt32 bytesNeeded;\n-\n-    sendBuf = (char*)PR_MALLOC(_client_data * sizeof(char));\n-    if (!sendBuf)\n-        if (debug_mode) {\n-            printf(\"\\tClient could not malloc space!?\\n\");\n-        }\n-    recvBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n-    if (!recvBuf)\n-        if (debug_mode) {\n-            printf(\"\\tClient could not malloc space!?\\n\");\n-        }\n-\n-    memset(&serverAddr, 0, sizeof(PRNetAddr));\n-    serverAddr.inet.family = PR_AF_INET;\n-    serverAddr.inet.port = PR_htons(PORT);\n-    serverAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n+void ClientThreadFunc(void* unused) {\n+  PRNetAddr serverAddr;\n+  PRFileDesc* clientSocket;\n+  char* sendBuf;\n+  char* recvBuf;\n+  PRInt32 rv;\n+  PRInt32 bytesNeeded;\n \n-    while (numRequests > 0) {\n-        if ((numRequests % 10) == 0)\n-            if (debug_mode) {\n-                printf(\".\");\n-            }\n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient starting request %d\\n\", numRequests);\n-        }\n+  sendBuf = (char*)PR_MALLOC(_client_data * sizeof(char));\n+  if (!sendBuf)\n+    if (debug_mode) {\n+      printf(\"\\tClient could not malloc space!?\\n\");\n+    }\n+  recvBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n+  if (!recvBuf)\n+    if (debug_mode) {\n+      printf(\"\\tClient could not malloc space!?\\n\");\n+    }\n \n-        clientSocket = PR_NewTCPSocket();\n-        if (!clientSocket) {\n-            if (debug_mode)\n-                printf(\"Client error creating socket: OS error %d\\n\", PR_GetOSError());\n-            continue;\n-        }\n+  memset(&serverAddr, 0, sizeof(PRNetAddr));\n+  serverAddr.inet.family = PR_AF_INET;\n+  serverAddr.inet.port = PR_htons(PORT);\n+  serverAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient connecting\\n\");\n-        }\n+  while (numRequests > 0) {\n+    if ((numRequests % 10) == 0)\n+      if (debug_mode) {\n+        printf(\".\");\n+      }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient starting request %d\\n\", numRequests);\n+    }\n \n-        rv = PR_Connect(clientSocket, &serverAddr, PR_INTERVAL_NO_TIMEOUT);\n-        if (!clientSocket) {\n-            if (debug_mode) {\n-                printf(\"\\tClient error connecting\\n\");\n-            }\n-            continue;\n-        }\n+    clientSocket = PR_NewTCPSocket();\n+    if (!clientSocket) {\n+      if (debug_mode)\n+        printf(\"Client error creating socket: OS error %d\\n\", PR_GetOSError());\n+      continue;\n+    }\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient connected\\n\");\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient connecting\\n\");\n+    }\n \n-        rv =\n-            PR_Send(clientSocket, sendBuf, _client_data, 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (rv != _client_data) {\n-            if (debug_mode) {\n-                printf(\"Client error sending data (%d)\\n\", rv);\n-            }\n-            PR_Close(clientSocket);\n-            continue;\n-        }\n+    rv = PR_Connect(clientSocket, &serverAddr, PR_INTERVAL_NO_TIMEOUT);\n+    if (!clientSocket) {\n+      if (debug_mode) {\n+        printf(\"\\tClient error connecting\\n\");\n+      }\n+      continue;\n+    }\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient sent %d bytes\\n\", rv);\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient connected\\n\");\n+    }\n \n-        bytesNeeded = _server_data;\n-        while (bytesNeeded) {\n-            rv = PR_Recv(clientSocket, recvBuf, bytesNeeded, 0,\n-                         PR_INTERVAL_NO_TIMEOUT);\n-            if (rv <= 0) {\n-                if (debug_mode)\n-                    printf(\"Client error receiving data (%d) (%d/%d)\\n\", rv,\n-                           (_server_data - bytesNeeded), _server_data);\n-                break;\n-            }\n-            if (debug_mode) {\n-                DPRINTF(\"\\tClient received %d bytes; need %d more\\n\", rv,\n-                        bytesNeeded - rv);\n-            }\n-            bytesNeeded -= rv;\n-        }\n+    rv =\n+        PR_Send(clientSocket, sendBuf, _client_data, 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (rv != _client_data) {\n+      if (debug_mode) {\n+        printf(\"Client error sending data (%d)\\n\", rv);\n+      }\n+      PR_Close(clientSocket);\n+      continue;\n+    }\n \n-        PR_Close(clientSocket);\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient sent %d bytes\\n\", rv);\n+    }\n \n-        PR_AtomicDecrement(&numRequests);\n+    bytesNeeded = _server_data;\n+    while (bytesNeeded) {\n+      rv = PR_Recv(clientSocket, recvBuf, bytesNeeded, 0,\n+                   PR_INTERVAL_NO_TIMEOUT);\n+      if (rv <= 0) {\n+        if (debug_mode)\n+          printf(\"Client error receiving data (%d) (%d/%d)\\n\", rv,\n+                 (_server_data - bytesNeeded), _server_data);\n+        break;\n+      }\n+      if (debug_mode) {\n+        DPRINTF(\"\\tClient received %d bytes; need %d more\\n\", rv,\n+                bytesNeeded - rv);\n+      }\n+      bytesNeeded -= rv;\n     }\n \n-    PR_EnterMonitor(clientMonitor);\n-    --numClients;\n-    PR_Notify(clientMonitor);\n-    PR_ExitMonitor(clientMonitor);\n+    PR_Close(clientSocket);\n \n-    PR_DELETE(sendBuf);\n-    PR_DELETE(recvBuf);\n+    PR_AtomicDecrement(&numRequests);\n+  }\n+\n+  PR_EnterMonitor(clientMonitor);\n+  --numClients;\n+  PR_Notify(clientMonitor);\n+  PR_ExitMonitor(clientMonitor);\n+\n+  PR_DELETE(sendBuf);\n+  PR_DELETE(recvBuf);\n }\n \n-void\n-RunClients(void)\n-{\n-    PRInt32 index;\n+void RunClients(void) {\n+  PRInt32 index;\n \n-    numRequests = _iterations;\n-    numClients = _clients;\n-    clientMonitor = PR_NewMonitor();\n+  numRequests = _iterations;\n+  numClients = _clients;\n+  clientMonitor = PR_NewMonitor();\n \n-    for (index = 0; index < _clients; index++) {\n-        PRThread* clientThread;\n+  for (index = 0; index < _clients; index++) {\n+    PRThread* clientThread;\n \n-        clientThread = PR_CreateThread(PR_USER_THREAD, ClientThreadFunc, NULL,\n-                                       PR_PRIORITY_NORMAL, ClientScope,\n-                                       PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+    clientThread = PR_CreateThread(PR_USER_THREAD, ClientThreadFunc, NULL,\n+                                   PR_PRIORITY_NORMAL, ClientScope,\n+                                   PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n \n-        if (!clientThread) {\n-            if (debug_mode) {\n-                printf(\"\\terror creating client thread %d\\n\", index);\n-            }\n-        } else if (debug_mode) {\n-            DPRINTF(\"\\tMain created client %d/%d\\n\", index + 1, _clients);\n-        }\n+    if (!clientThread) {\n+      if (debug_mode) {\n+        printf(\"\\terror creating client thread %d\\n\", index);\n+      }\n+    } else if (debug_mode) {\n+      DPRINTF(\"\\tMain created client %d/%d\\n\", index + 1, _clients);\n     }\n+  }\n \n-    PR_EnterMonitor(clientMonitor);\n-    while (numClients) {\n-        PR_Wait(clientMonitor, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_ExitMonitor(clientMonitor);\n+  PR_EnterMonitor(clientMonitor);\n+  while (numClients) {\n+    PR_Wait(clientMonitor, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_ExitMonitor(clientMonitor);\n }\n \n /* --- Main Function ---------------------------------------------- */\n \n-static void\n-do_work()\n-{\n-    PRThread* ServerThread;\n-    PRInt32 state;\n-\n-    SetServerState(MAIN, SERVER_STATE_STARTUP);\n-    ServerThread = PR_CreateThread(PR_USER_THREAD, ServerThreadFunc, NULL,\n-                                   PR_PRIORITY_NORMAL, ServerScope,\n-                                   PR_JOINABLE_THREAD, THREAD_STACKSIZE);\n-    if (!ServerThread) {\n-        if (debug_mode) {\n-            printf(\"error creating main server thread\\n\");\n-        }\n-        return;\n+static void do_work() {\n+  PRThread* ServerThread;\n+  PRInt32 state;\n+\n+  SetServerState(MAIN, SERVER_STATE_STARTUP);\n+  ServerThread = PR_CreateThread(PR_USER_THREAD, ServerThreadFunc, NULL,\n+                                 PR_PRIORITY_NORMAL, ServerScope,\n+                                 PR_JOINABLE_THREAD, THREAD_STACKSIZE);\n+  if (!ServerThread) {\n+    if (debug_mode) {\n+      printf(\"error creating main server thread\\n\");\n     }\n+    return;\n+  }\n \n-    /* Wait for server to be ready */\n-    state = WaitServerState(MAIN, SERVER_STATE_READY | SERVER_STATE_DEAD);\n+  /* Wait for server to be ready */\n+  state = WaitServerState(MAIN, SERVER_STATE_READY | SERVER_STATE_DEAD);\n \n-    if (!(state & SERVER_STATE_DEAD)) {\n-        /* Run Test Clients */\n-        RunClients();\n+  if (!(state & SERVER_STATE_DEAD)) {\n+    /* Run Test Clients */\n+    RunClients();\n \n-        /* Send death signal to server */\n-        SetServerState(MAIN, SERVER_STATE_DYING);\n-    }\n+    /* Send death signal to server */\n+    SetServerState(MAIN, SERVER_STATE_DYING);\n+  }\n \n-    PR_JoinThread(ServerThread);\n+  PR_JoinThread(ServerThread);\n }\n \n-static void\n-do_workUU(void)\n-{\n-    ServerScope = PR_LOCAL_THREAD;\n-    ClientScope = PR_LOCAL_THREAD;\n-    do_work();\n+static void do_workUU(void) {\n+  ServerScope = PR_LOCAL_THREAD;\n+  ClientScope = PR_LOCAL_THREAD;\n+  do_work();\n }\n \n-static void\n-do_workUK(void)\n-{\n-    ServerScope = PR_LOCAL_THREAD;\n-    ClientScope = PR_GLOBAL_THREAD;\n-    do_work();\n+static void do_workUK(void) {\n+  ServerScope = PR_LOCAL_THREAD;\n+  ClientScope = PR_GLOBAL_THREAD;\n+  do_work();\n }\n \n-static void\n-do_workKU(void)\n-{\n-    ServerScope = PR_GLOBAL_THREAD;\n-    ClientScope = PR_LOCAL_THREAD;\n-    do_work();\n+static void do_workKU(void) {\n+  ServerScope = PR_GLOBAL_THREAD;\n+  ClientScope = PR_LOCAL_THREAD;\n+  do_work();\n }\n \n-static void\n-do_workKK(void)\n-{\n-    ServerScope = PR_GLOBAL_THREAD;\n-    ClientScope = PR_GLOBAL_THREAD;\n-    do_work();\n+static void do_workKK(void) {\n+  ServerScope = PR_GLOBAL_THREAD;\n+  ClientScope = PR_GLOBAL_THREAD;\n+  do_work();\n }\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow();\n \n-    d = (double)PR_IntervalToMicroseconds(stop - start);\n+  d = (double)PR_IntervalToMicroseconds(stop - start);\n \n-    if (debug_mode) {\n-        printf(\"\\n%40s: %6.2f usec\\n\", msg, d / _iterations);\n-    }\n+  if (debug_mode) {\n+    printf(\"\\n%40s: %6.2f usec\\n\", msg, d / _iterations);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-    if (debug_mode) {\n-        printf(\"Enter number of iterations: \\n\");\n-        scanf(\"%d\", &_iterations);\n-        printf(\"Enter number of clients   : \\n\");\n-        scanf(\"%d\", &_clients);\n-        printf(\"Enter size of client data : \\n\");\n-        scanf(\"%d\", &_client_data);\n-        printf(\"Enter size of server data : \\n\");\n-        scanf(\"%d\", &_server_data);\n-    } else {\n-        _iterations = 7;\n-        _clients = 7;\n-        _client_data = 100;\n-        _server_data = 100;\n+int main(int argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-\n-    if (debug_mode) {\n-        printf(\"\\n\\n%d iterations with %d client threads.\\n\", _iterations,\n-               _clients);\n-        printf(\"Sending %d bytes of client data and %d bytes of server data\\n\",\n-               _client_data, _server_data);\n-    }\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    PR_SetThreadRecycleMode(64);\n-\n-    ServerStateCVLock = PR_NewLock();\n-    ServerStateCV = PR_NewCondVar(ServerStateCVLock);\n-\n-    Measure(do_workKK, \"server loop kernel/kernel\");\n-\n-    PR_Cleanup();\n-\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+  if (debug_mode) {\n+    printf(\"Enter number of iterations: \\n\");\n+    scanf(\"%d\", &_iterations);\n+    printf(\"Enter number of clients   : \\n\");\n+    scanf(\"%d\", &_clients);\n+    printf(\"Enter size of client data : \\n\");\n+    scanf(\"%d\", &_client_data);\n+    printf(\"Enter size of server data : \\n\");\n+    scanf(\"%d\", &_server_data);\n+  } else {\n+    _iterations = 7;\n+    _clients = 7;\n+    _client_data = 100;\n+    _server_data = 100;\n+  }\n+\n+  if (debug_mode) {\n+    printf(\"\\n\\n%d iterations with %d client threads.\\n\", _iterations,\n+           _clients);\n+    printf(\"Sending %d bytes of client data and %d bytes of server data\\n\",\n+           _client_data, _server_data);\n+  }\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  PR_SetThreadRecycleMode(64);\n+\n+  ServerStateCVLock = PR_NewLock();\n+  ServerStateCV = PR_NewCondVar(ServerStateCVLock);\n+\n+  Measure(do_workKK, \"server loop kernel/kernel\");\n+\n+  PR_Cleanup();\n+\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/servr_ku.c b/nspr/pr/tests/servr_ku.c\nindex f33a86e..7694438 100644\n--- a/nspr/pr/tests/servr_ku.c\n+++ b/nspr/pr/tests/servr_ku.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -58,9 +59,9 @@ PRLock* ServerStateCVLock;\n PRCondVar* ServerStateCV;\n \n #ifdef DEBUGPRINTS\n-#define DPRINTF printf\n+#  define DPRINTF printf\n #else\n-#define DPRINTF\n+#  define DPRINTF\n #endif\n \n PRIntn failed_already = 0;\n@@ -69,42 +70,38 @@ PRIntn debug_mode;\n static void do_work(void);\n \n /* --- Server state functions --------------------------------------------- */\n-void\n-SetServerState(char* waiter, PRInt32 state)\n-{\n-    PR_Lock(ServerStateCVLock);\n-    ServerState = state;\n-    PR_NotifyCondVar(ServerStateCV);\n+void SetServerState(char* waiter, PRInt32 state) {\n+  PR_Lock(ServerStateCVLock);\n+  ServerState = state;\n+  PR_NotifyCondVar(ServerStateCV);\n \n-    if (debug_mode) {\n-        DPRINTF(\"\\t%s changed state to %d\\n\", waiter, state);\n-    }\n+  if (debug_mode) {\n+    DPRINTF(\"\\t%s changed state to %d\\n\", waiter, state);\n+  }\n \n-    PR_Unlock(ServerStateCVLock);\n+  PR_Unlock(ServerStateCVLock);\n }\n \n-int\n-WaitServerState(char* waiter, PRInt32 state)\n-{\n-    PRInt32 rv;\n+int WaitServerState(char* waiter, PRInt32 state) {\n+  PRInt32 rv;\n \n-    PR_Lock(ServerStateCVLock);\n+  PR_Lock(ServerStateCVLock);\n \n-    if (debug_mode) {\n-        DPRINTF(\"\\t%s waiting for state %d\\n\", waiter, state);\n-    }\n+  if (debug_mode) {\n+    DPRINTF(\"\\t%s waiting for state %d\\n\", waiter, state);\n+  }\n \n-    while (!(ServerState & state)) {\n-        PR_WaitCondVar(ServerStateCV, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    rv = ServerState;\n+  while (!(ServerState & state)) {\n+    PR_WaitCondVar(ServerStateCV, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  rv = ServerState;\n \n-    if (debug_mode)\n-        DPRINTF(\"\\t%s resuming from wait for state %d; state now %d\\n\", waiter,\n-                state, ServerState);\n-    PR_Unlock(ServerStateCVLock);\n+  if (debug_mode)\n+    DPRINTF(\"\\t%s resuming from wait for state %d; state now %d\\n\", waiter,\n+            state, ServerState);\n+  PR_Unlock(ServerStateCVLock);\n \n-    return rv;\n+  return rv;\n }\n \n /* --- Server Functions ------------------------------------------- */\n@@ -113,224 +110,218 @@ PRLock* workerThreadsLock;\n PRInt32 workerThreads;\n PRInt32 workerThreadsBusy;\n \n-void\n-WorkerThreadFunc(void* _listenSock)\n-{\n-    PRFileDesc* listenSock = (PRFileDesc*)_listenSock;\n-    PRInt32 bytesRead;\n-    PRInt32 bytesWritten;\n-    char* dataBuf;\n-    char* sendBuf;\n-\n-    if (debug_mode)\n-        DPRINTF(\"\\tServer buffer is %d bytes; %d data, %d netaddrs\\n\",\n-                _client_data + (2 * sizeof(PRNetAddr)) + 32, _client_data,\n-                (2 * sizeof(PRNetAddr)) + 32);\n-    dataBuf = (char*)PR_MALLOC(_client_data + 2 * sizeof(PRNetAddr) + 32);\n-    if (!dataBuf)\n-        if (debug_mode) {\n-            printf(\"\\tServer could not malloc space!?\\n\");\n-        }\n-    sendBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n-    if (!sendBuf)\n-        if (debug_mode) {\n-            printf(\"\\tServer could not malloc space!?\\n\");\n-        }\n-\n+void WorkerThreadFunc(void* _listenSock) {\n+  PRFileDesc* listenSock = (PRFileDesc*)_listenSock;\n+  PRInt32 bytesRead;\n+  PRInt32 bytesWritten;\n+  char* dataBuf;\n+  char* sendBuf;\n+\n+  if (debug_mode)\n+    DPRINTF(\"\\tServer buffer is %d bytes; %d data, %d netaddrs\\n\",\n+            _client_data + (2 * sizeof(PRNetAddr)) + 32, _client_data,\n+            (2 * sizeof(PRNetAddr)) + 32);\n+  dataBuf = (char*)PR_MALLOC(_client_data + 2 * sizeof(PRNetAddr) + 32);\n+  if (!dataBuf)\n+    if (debug_mode) {\n+      printf(\"\\tServer could not malloc space!?\\n\");\n+    }\n+  sendBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n+  if (!sendBuf)\n     if (debug_mode) {\n-        DPRINTF(\"\\tServer worker thread running\\n\");\n+      printf(\"\\tServer could not malloc space!?\\n\");\n     }\n \n-    while (1) {\n-        PRInt32 bytesToRead = _client_data;\n-        PRInt32 bytesToWrite = _server_data;\n-        PRFileDesc* newSock;\n-        PRNetAddr* rAddr;\n-        PRInt32 loops = 0;\n+  if (debug_mode) {\n+    DPRINTF(\"\\tServer worker thread running\\n\");\n+  }\n \n-        loops++;\n+  while (1) {\n+    PRInt32 bytesToRead = _client_data;\n+    PRInt32 bytesToWrite = _server_data;\n+    PRFileDesc* newSock;\n+    PRNetAddr* rAddr;\n+    PRInt32 loops = 0;\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer thread going into accept\\n\");\n-        }\n+    loops++;\n \n-        bytesRead = PR_AcceptRead(listenSock, &newSock, &rAddr, dataBuf,\n-                                  bytesToRead, PR_INTERVAL_NO_TIMEOUT);\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer thread going into accept\\n\");\n+    }\n \n-        if (bytesRead < 0) {\n-            if (debug_mode) {\n-                printf(\"\\tServer error in accept (%d)\\n\", bytesRead);\n-            }\n-            continue;\n-        }\n+    bytesRead = PR_AcceptRead(listenSock, &newSock, &rAddr, dataBuf,\n+                              bytesToRead, PR_INTERVAL_NO_TIMEOUT);\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer accepted connection (%d bytes)\\n\", bytesRead);\n-        }\n+    if (bytesRead < 0) {\n+      if (debug_mode) {\n+        printf(\"\\tServer error in accept (%d)\\n\", bytesRead);\n+      }\n+      continue;\n+    }\n \n-        PR_AtomicIncrement(&workerThreadsBusy);\n-        if (workerThreadsBusy == workerThreads) {\n-            PR_Lock(workerThreadsLock);\n-            if (workerThreadsBusy == workerThreads) {\n-                PRThread* WorkerThread;\n-\n-                WorkerThread = PR_CreateThread(\n-                    PR_SYSTEM_THREAD, WorkerThreadFunc, listenSock, PR_PRIORITY_NORMAL,\n-                    ServerScope, PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n-\n-                if (!WorkerThread) {\n-                    if (debug_mode) {\n-                        printf(\"Error creating client thread %d\\n\", workerThreads);\n-                    }\n-                } else {\n-                    PR_AtomicIncrement(&workerThreads);\n-                    if (debug_mode) {\n-                        DPRINTF(\"\\tServer creates worker (%d)\\n\", workerThreads);\n-                    }\n-                }\n-            }\n-            PR_Unlock(workerThreadsLock);\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer accepted connection (%d bytes)\\n\", bytesRead);\n+    }\n \n-        bytesToRead -= bytesRead;\n-        while (bytesToRead) {\n-            bytesRead =\n-                PR_Recv(newSock, dataBuf, bytesToRead, 0, PR_INTERVAL_NO_TIMEOUT);\n-            if (bytesRead < 0) {\n-                if (debug_mode) {\n-                    printf(\"\\tServer error receiving data (%d)\\n\", bytesRead);\n-                }\n-                continue;\n-            }\n-            if (debug_mode) {\n-                DPRINTF(\"\\tServer received %d bytes\\n\", bytesRead);\n-            }\n-        }\n+    PR_AtomicIncrement(&workerThreadsBusy);\n+    if (workerThreadsBusy == workerThreads) {\n+      PR_Lock(workerThreadsLock);\n+      if (workerThreadsBusy == workerThreads) {\n+        PRThread* WorkerThread;\n+\n+        WorkerThread = PR_CreateThread(\n+            PR_SYSTEM_THREAD, WorkerThreadFunc, listenSock, PR_PRIORITY_NORMAL,\n+            ServerScope, PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n \n-        bytesWritten =\n-            PR_Send(newSock, sendBuf, bytesToWrite, 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (bytesWritten != _server_data) {\n-            if (debug_mode)\n-                printf(\"\\tError sending data to client (%d, %d)\\n\", bytesWritten,\n-                       PR_GetOSError());\n+        if (!WorkerThread) {\n+          if (debug_mode) {\n+            printf(\"Error creating client thread %d\\n\", workerThreads);\n+          }\n         } else {\n-            if (debug_mode) {\n-                DPRINTF(\"\\tServer sent %d bytes\\n\", bytesWritten);\n-            }\n+          PR_AtomicIncrement(&workerThreads);\n+          if (debug_mode) {\n+            DPRINTF(\"\\tServer creates worker (%d)\\n\", workerThreads);\n+          }\n         }\n-\n-        PR_Close(newSock);\n-        PR_AtomicDecrement(&workerThreadsBusy);\n+      }\n+      PR_Unlock(workerThreadsLock);\n     }\n-}\n-\n-PRFileDesc*\n-ServerSetup(void)\n-{\n-    PRFileDesc* listenSocket;\n-    PRSocketOptionData sockOpt;\n-    PRNetAddr serverAddr;\n-    PRThread* WorkerThread;\n \n-    if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n+    bytesToRead -= bytesRead;\n+    while (bytesToRead) {\n+      bytesRead =\n+          PR_Recv(newSock, dataBuf, bytesToRead, 0, PR_INTERVAL_NO_TIMEOUT);\n+      if (bytesRead < 0) {\n         if (debug_mode) {\n-            printf(\"\\tServer error creating listen socket\\n\");\n-        } else {\n-            failed_already = 1;\n+          printf(\"\\tServer error receiving data (%d)\\n\", bytesRead);\n         }\n-        return NULL;\n+        continue;\n+      }\n+      if (debug_mode) {\n+        DPRINTF(\"\\tServer received %d bytes\\n\", bytesRead);\n+      }\n     }\n \n-    sockOpt.option = PR_SockOpt_Reuseaddr;\n-    sockOpt.value.reuse_addr = PR_TRUE;\n-    if (PR_SetSocketOption(listenSocket, &sockOpt) == PR_FAILURE) {\n-        if (debug_mode)\n-            printf(\"\\tServer error setting socket option: OS error %d\\n\",\n-                   PR_GetOSError());\n-        else {\n-            failed_already = 1;\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n+    bytesWritten =\n+        PR_Send(newSock, sendBuf, bytesToWrite, 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (bytesWritten != _server_data) {\n+      if (debug_mode)\n+        printf(\"\\tError sending data to client (%d, %d)\\n\", bytesWritten,\n+               PR_GetOSError());\n+    } else {\n+      if (debug_mode) {\n+        DPRINTF(\"\\tServer sent %d bytes\\n\", bytesWritten);\n+      }\n     }\n \n-    memset(&serverAddr, 0, sizeof(PRNetAddr));\n-    serverAddr.inet.family = PR_AF_INET;\n-    serverAddr.inet.port = PR_htons(PORT);\n-    serverAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+    PR_Close(newSock);\n+    PR_AtomicDecrement(&workerThreadsBusy);\n+  }\n+}\n \n-    if (PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {\n-        if (debug_mode)\n-            printf(\"\\tServer error binding to server address: OS error %d\\n\",\n-                   PR_GetOSError());\n-        else {\n-            failed_already = 1;\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n+PRFileDesc* ServerSetup(void) {\n+  PRFileDesc* listenSocket;\n+  PRSocketOptionData sockOpt;\n+  PRNetAddr serverAddr;\n+  PRThread* WorkerThread;\n+\n+  if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error creating listen socket\\n\");\n+    } else {\n+      failed_already = 1;\n     }\n+    return NULL;\n+  }\n \n-    if (PR_Listen(listenSocket, 128) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tServer error listening to server socket\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        PR_Close(listenSocket);\n+  sockOpt.option = PR_SockOpt_Reuseaddr;\n+  sockOpt.value.reuse_addr = PR_TRUE;\n+  if (PR_SetSocketOption(listenSocket, &sockOpt) == PR_FAILURE) {\n+    if (debug_mode)\n+      printf(\"\\tServer error setting socket option: OS error %d\\n\",\n+             PR_GetOSError());\n+    else {\n+      failed_already = 1;\n+    }\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n+\n+  memset(&serverAddr, 0, sizeof(PRNetAddr));\n+  serverAddr.inet.family = PR_AF_INET;\n+  serverAddr.inet.port = PR_htons(PORT);\n+  serverAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n \n-        return NULL;\n+  if (PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {\n+    if (debug_mode)\n+      printf(\"\\tServer error binding to server address: OS error %d\\n\",\n+             PR_GetOSError());\n+    else {\n+      failed_already = 1;\n     }\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n \n-    /* Create Clients */\n-    workerThreads = 0;\n-    workerThreadsBusy = 0;\n+  if (PR_Listen(listenSocket, 128) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error listening to server socket\\n\");\n+    } else {\n+      failed_already = 1;\n+    }\n+    PR_Close(listenSocket);\n \n-    workerThreadsLock = PR_NewLock();\n+    return NULL;\n+  }\n \n-    WorkerThread = PR_CreateThread(PR_SYSTEM_THREAD, WorkerThreadFunc,\n-                                   listenSocket, PR_PRIORITY_NORMAL, ServerScope,\n-                                   PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+  /* Create Clients */\n+  workerThreads = 0;\n+  workerThreadsBusy = 0;\n \n-    if (!WorkerThread) {\n-        if (debug_mode) {\n-            printf(\"error creating working thread\\n\");\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n-    }\n-    PR_AtomicIncrement(&workerThreads);\n+  workerThreadsLock = PR_NewLock();\n+\n+  WorkerThread = PR_CreateThread(PR_SYSTEM_THREAD, WorkerThreadFunc,\n+                                 listenSocket, PR_PRIORITY_NORMAL, ServerScope,\n+                                 PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+\n+  if (!WorkerThread) {\n     if (debug_mode) {\n-        DPRINTF(\"\\tServer created primordial worker thread\\n\");\n+      printf(\"error creating working thread\\n\");\n     }\n-\n-    return listenSocket;\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n+  PR_AtomicIncrement(&workerThreads);\n+  if (debug_mode) {\n+    DPRINTF(\"\\tServer created primordial worker thread\\n\");\n+  }\n+\n+  return listenSocket;\n }\n \n /* The main server loop */\n-void\n-ServerThreadFunc(void* unused)\n-{\n-    PRFileDesc* listenSocket;\n+void ServerThreadFunc(void* unused) {\n+  PRFileDesc* listenSocket;\n \n-    /* Do setup */\n-    listenSocket = ServerSetup();\n+  /* Do setup */\n+  listenSocket = ServerSetup();\n \n-    if (!listenSocket) {\n-        SetServerState(SERVER, SERVER_STATE_DEAD);\n-    } else {\n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer up\\n\");\n-        }\n+  if (!listenSocket) {\n+    SetServerState(SERVER, SERVER_STATE_DEAD);\n+  } else {\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer up\\n\");\n+    }\n \n-        /* Tell clients they can start now. */\n-        SetServerState(SERVER, SERVER_STATE_READY);\n+    /* Tell clients they can start now. */\n+    SetServerState(SERVER, SERVER_STATE_READY);\n \n-        /* Now wait for server death signal */\n-        WaitServerState(SERVER, SERVER_STATE_DYING);\n+    /* Now wait for server death signal */\n+    WaitServerState(SERVER, SERVER_STATE_DYING);\n \n-        /* Cleanup */\n-        SetServerState(SERVER, SERVER_STATE_DEAD);\n-    }\n+    /* Cleanup */\n+    SetServerState(SERVER, SERVER_STATE_DEAD);\n+  }\n }\n \n /* --- Client Functions ------------------------------------------- */\n@@ -339,259 +330,247 @@ PRInt32 numRequests;\n PRInt32 numClients;\n PRMonitor* clientMonitor;\n \n-void\n-ClientThreadFunc(void* unused)\n-{\n-    PRNetAddr serverAddr;\n-    PRFileDesc* clientSocket;\n-    char* sendBuf;\n-    char* recvBuf;\n-    PRInt32 rv;\n-    PRInt32 bytesNeeded;\n-\n-    sendBuf = (char*)PR_MALLOC(_client_data * sizeof(char));\n-    if (!sendBuf)\n-        if (debug_mode) {\n-            printf(\"\\tClient could not malloc space!?\\n\");\n-        }\n-    recvBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n-    if (!recvBuf)\n-        if (debug_mode) {\n-            printf(\"\\tClient could not malloc space!?\\n\");\n-        }\n-\n-    memset(&serverAddr, 0, sizeof(PRNetAddr));\n-    serverAddr.inet.family = PR_AF_INET;\n-    serverAddr.inet.port = PR_htons(PORT);\n-    serverAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n+void ClientThreadFunc(void* unused) {\n+  PRNetAddr serverAddr;\n+  PRFileDesc* clientSocket;\n+  char* sendBuf;\n+  char* recvBuf;\n+  PRInt32 rv;\n+  PRInt32 bytesNeeded;\n \n-    while (numRequests > 0) {\n-        if ((numRequests % 10) == 0)\n-            if (debug_mode) {\n-                printf(\".\");\n-            }\n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient starting request %d\\n\", numRequests);\n-        }\n+  sendBuf = (char*)PR_MALLOC(_client_data * sizeof(char));\n+  if (!sendBuf)\n+    if (debug_mode) {\n+      printf(\"\\tClient could not malloc space!?\\n\");\n+    }\n+  recvBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n+  if (!recvBuf)\n+    if (debug_mode) {\n+      printf(\"\\tClient could not malloc space!?\\n\");\n+    }\n \n-        clientSocket = PR_NewTCPSocket();\n-        if (!clientSocket) {\n-            if (debug_mode)\n-                printf(\"Client error creating socket: OS error %d\\n\", PR_GetOSError());\n-            continue;\n-        }\n+  memset(&serverAddr, 0, sizeof(PRNetAddr));\n+  serverAddr.inet.family = PR_AF_INET;\n+  serverAddr.inet.port = PR_htons(PORT);\n+  serverAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient connecting\\n\");\n-        }\n+  while (numRequests > 0) {\n+    if ((numRequests % 10) == 0)\n+      if (debug_mode) {\n+        printf(\".\");\n+      }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient starting request %d\\n\", numRequests);\n+    }\n \n-        rv = PR_Connect(clientSocket, &serverAddr, PR_INTERVAL_NO_TIMEOUT);\n-        if (!clientSocket) {\n-            if (debug_mode) {\n-                printf(\"\\tClient error connecting\\n\");\n-            }\n-            continue;\n-        }\n+    clientSocket = PR_NewTCPSocket();\n+    if (!clientSocket) {\n+      if (debug_mode)\n+        printf(\"Client error creating socket: OS error %d\\n\", PR_GetOSError());\n+      continue;\n+    }\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient connected\\n\");\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient connecting\\n\");\n+    }\n \n-        rv =\n-            PR_Send(clientSocket, sendBuf, _client_data, 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (rv != _client_data) {\n-            if (debug_mode) {\n-                printf(\"Client error sending data (%d)\\n\", rv);\n-            }\n-            PR_Close(clientSocket);\n-            continue;\n-        }\n+    rv = PR_Connect(clientSocket, &serverAddr, PR_INTERVAL_NO_TIMEOUT);\n+    if (!clientSocket) {\n+      if (debug_mode) {\n+        printf(\"\\tClient error connecting\\n\");\n+      }\n+      continue;\n+    }\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient sent %d bytes\\n\", rv);\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient connected\\n\");\n+    }\n \n-        bytesNeeded = _server_data;\n-        while (bytesNeeded) {\n-            rv = PR_Recv(clientSocket, recvBuf, bytesNeeded, 0,\n-                         PR_INTERVAL_NO_TIMEOUT);\n-            if (rv <= 0) {\n-                if (debug_mode)\n-                    printf(\"Client error receiving data (%d) (%d/%d)\\n\", rv,\n-                           (_server_data - bytesNeeded), _server_data);\n-                break;\n-            }\n-            if (debug_mode) {\n-                DPRINTF(\"\\tClient received %d bytes; need %d more\\n\", rv,\n-                        bytesNeeded - rv);\n-            }\n-            bytesNeeded -= rv;\n-        }\n+    rv =\n+        PR_Send(clientSocket, sendBuf, _client_data, 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (rv != _client_data) {\n+      if (debug_mode) {\n+        printf(\"Client error sending data (%d)\\n\", rv);\n+      }\n+      PR_Close(clientSocket);\n+      continue;\n+    }\n \n-        PR_Close(clientSocket);\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient sent %d bytes\\n\", rv);\n+    }\n \n-        PR_AtomicDecrement(&numRequests);\n+    bytesNeeded = _server_data;\n+    while (bytesNeeded) {\n+      rv = PR_Recv(clientSocket, recvBuf, bytesNeeded, 0,\n+                   PR_INTERVAL_NO_TIMEOUT);\n+      if (rv <= 0) {\n+        if (debug_mode)\n+          printf(\"Client error receiving data (%d) (%d/%d)\\n\", rv,\n+                 (_server_data - bytesNeeded), _server_data);\n+        break;\n+      }\n+      if (debug_mode) {\n+        DPRINTF(\"\\tClient received %d bytes; need %d more\\n\", rv,\n+                bytesNeeded - rv);\n+      }\n+      bytesNeeded -= rv;\n     }\n \n-    PR_EnterMonitor(clientMonitor);\n-    --numClients;\n-    PR_Notify(clientMonitor);\n-    PR_ExitMonitor(clientMonitor);\n+    PR_Close(clientSocket);\n \n-    PR_DELETE(sendBuf);\n-    PR_DELETE(recvBuf);\n+    PR_AtomicDecrement(&numRequests);\n+  }\n+\n+  PR_EnterMonitor(clientMonitor);\n+  --numClients;\n+  PR_Notify(clientMonitor);\n+  PR_ExitMonitor(clientMonitor);\n+\n+  PR_DELETE(sendBuf);\n+  PR_DELETE(recvBuf);\n }\n \n-void\n-RunClients(void)\n-{\n-    PRInt32 index;\n+void RunClients(void) {\n+  PRInt32 index;\n \n-    numRequests = _iterations;\n-    numClients = _clients;\n-    clientMonitor = PR_NewMonitor();\n+  numRequests = _iterations;\n+  numClients = _clients;\n+  clientMonitor = PR_NewMonitor();\n \n-    for (index = 0; index < _clients; index++) {\n-        PRThread* clientThread;\n+  for (index = 0; index < _clients; index++) {\n+    PRThread* clientThread;\n \n-        clientThread = PR_CreateThread(PR_USER_THREAD, ClientThreadFunc, NULL,\n-                                       PR_PRIORITY_NORMAL, ClientScope,\n-                                       PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+    clientThread = PR_CreateThread(PR_USER_THREAD, ClientThreadFunc, NULL,\n+                                   PR_PRIORITY_NORMAL, ClientScope,\n+                                   PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n \n-        if (!clientThread) {\n-            if (debug_mode) {\n-                printf(\"\\terror creating client thread %d\\n\", index);\n-            }\n-        } else if (debug_mode) {\n-            DPRINTF(\"\\tMain created client %d/%d\\n\", index + 1, _clients);\n-        }\n+    if (!clientThread) {\n+      if (debug_mode) {\n+        printf(\"\\terror creating client thread %d\\n\", index);\n+      }\n+    } else if (debug_mode) {\n+      DPRINTF(\"\\tMain created client %d/%d\\n\", index + 1, _clients);\n     }\n+  }\n \n-    PR_EnterMonitor(clientMonitor);\n-    while (numClients) {\n-        PR_Wait(clientMonitor, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_ExitMonitor(clientMonitor);\n+  PR_EnterMonitor(clientMonitor);\n+  while (numClients) {\n+    PR_Wait(clientMonitor, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_ExitMonitor(clientMonitor);\n }\n \n /* --- Main Function ---------------------------------------------- */\n \n-static void\n-do_work()\n-{\n-    PRThread* ServerThread;\n-    PRInt32 state;\n-\n-    SetServerState(MAIN, SERVER_STATE_STARTUP);\n-    ServerThread = PR_CreateThread(PR_USER_THREAD, ServerThreadFunc, NULL,\n-                                   PR_PRIORITY_NORMAL, ServerScope,\n-                                   PR_JOINABLE_THREAD, THREAD_STACKSIZE);\n-    if (!ServerThread) {\n-        if (debug_mode) {\n-            printf(\"error creating main server thread\\n\");\n-        }\n-        return;\n+static void do_work() {\n+  PRThread* ServerThread;\n+  PRInt32 state;\n+\n+  SetServerState(MAIN, SERVER_STATE_STARTUP);\n+  ServerThread = PR_CreateThread(PR_USER_THREAD, ServerThreadFunc, NULL,\n+                                 PR_PRIORITY_NORMAL, ServerScope,\n+                                 PR_JOINABLE_THREAD, THREAD_STACKSIZE);\n+  if (!ServerThread) {\n+    if (debug_mode) {\n+      printf(\"error creating main server thread\\n\");\n     }\n+    return;\n+  }\n \n-    /* Wait for server to be ready */\n-    state = WaitServerState(MAIN, SERVER_STATE_READY | SERVER_STATE_DEAD);\n+  /* Wait for server to be ready */\n+  state = WaitServerState(MAIN, SERVER_STATE_READY | SERVER_STATE_DEAD);\n \n-    if (!(state & SERVER_STATE_DEAD)) {\n-        /* Run Test Clients */\n-        RunClients();\n+  if (!(state & SERVER_STATE_DEAD)) {\n+    /* Run Test Clients */\n+    RunClients();\n \n-        /* Send death signal to server */\n-        SetServerState(MAIN, SERVER_STATE_DYING);\n-    }\n+    /* Send death signal to server */\n+    SetServerState(MAIN, SERVER_STATE_DYING);\n+  }\n \n-    PR_JoinThread(ServerThread);\n+  PR_JoinThread(ServerThread);\n }\n \n-static void\n-do_workKU(void)\n-{\n-    ServerScope = PR_GLOBAL_THREAD;\n-    ClientScope = PR_LOCAL_THREAD;\n-    do_work();\n+static void do_workKU(void) {\n+  ServerScope = PR_GLOBAL_THREAD;\n+  ClientScope = PR_LOCAL_THREAD;\n+  do_work();\n }\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow();\n \n-    d = (double)PR_IntervalToMicroseconds(stop - start);\n+  d = (double)PR_IntervalToMicroseconds(stop - start);\n \n-    if (debug_mode) {\n-        printf(\"\\n%40s: %6.2f usec\\n\", msg, d / _iterations);\n-    }\n+  if (debug_mode) {\n+    printf(\"\\n%40s: %6.2f usec\\n\", msg, d / _iterations);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-    if (debug_mode) {\n-        printf(\"Enter number of iterations: \\n\");\n-        scanf(\"%d\", &_iterations);\n-        printf(\"Enter number of clients   : \\n\");\n-        scanf(\"%d\", &_clients);\n-        printf(\"Enter size of client data : \\n\");\n-        scanf(\"%d\", &_client_data);\n-        printf(\"Enter size of server data : \\n\");\n-        scanf(\"%d\", &_server_data);\n-    } else {\n-        _iterations = 7;\n-        _clients = 7;\n-        _client_data = 100;\n-        _server_data = 100;\n+int main(int argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-\n-    if (debug_mode) {\n-        printf(\"\\n\\n%d iterations with %d client threads.\\n\", _iterations,\n-               _clients);\n-        printf(\"Sending %d bytes of client data and %d bytes of server data\\n\",\n-               _client_data, _server_data);\n-    }\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    PR_SetThreadRecycleMode(64);\n-\n-    ServerStateCVLock = PR_NewLock();\n-    ServerStateCV = PR_NewCondVar(ServerStateCVLock);\n-\n-    Measure(do_workKU, \"server loop kernel/user\");\n-\n-    PR_Cleanup();\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+  if (debug_mode) {\n+    printf(\"Enter number of iterations: \\n\");\n+    scanf(\"%d\", &_iterations);\n+    printf(\"Enter number of clients   : \\n\");\n+    scanf(\"%d\", &_clients);\n+    printf(\"Enter size of client data : \\n\");\n+    scanf(\"%d\", &_client_data);\n+    printf(\"Enter size of server data : \\n\");\n+    scanf(\"%d\", &_server_data);\n+  } else {\n+    _iterations = 7;\n+    _clients = 7;\n+    _client_data = 100;\n+    _server_data = 100;\n+  }\n+\n+  if (debug_mode) {\n+    printf(\"\\n\\n%d iterations with %d client threads.\\n\", _iterations,\n+           _clients);\n+    printf(\"Sending %d bytes of client data and %d bytes of server data\\n\",\n+           _client_data, _server_data);\n+  }\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  PR_SetThreadRecycleMode(64);\n+\n+  ServerStateCVLock = PR_NewLock();\n+  ServerStateCV = PR_NewCondVar(ServerStateCVLock);\n+\n+  Measure(do_workKU, \"server loop kernel/user\");\n+\n+  PR_Cleanup();\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/servr_uk.c b/nspr/pr/tests/servr_uk.c\nindex 54219e7..beebd1f 100644\n--- a/nspr/pr/tests/servr_uk.c\n+++ b/nspr/pr/tests/servr_uk.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -58,9 +59,9 @@ PRLock* ServerStateCVLock;\n PRCondVar* ServerStateCV;\n \n #ifdef DEBUGPRINTS\n-#define DPRINTF printf\n+#  define DPRINTF printf\n #else\n-#define DPRINTF\n+#  define DPRINTF\n #endif\n \n PRIntn failed_already = 0;\n@@ -69,42 +70,38 @@ PRIntn debug_mode;\n static void do_work(void);\n \n /* --- Server state functions --------------------------------------------- */\n-void\n-SetServerState(char* waiter, PRInt32 state)\n-{\n-    PR_Lock(ServerStateCVLock);\n-    ServerState = state;\n-    PR_NotifyCondVar(ServerStateCV);\n+void SetServerState(char* waiter, PRInt32 state) {\n+  PR_Lock(ServerStateCVLock);\n+  ServerState = state;\n+  PR_NotifyCondVar(ServerStateCV);\n \n-    if (debug_mode) {\n-        DPRINTF(\"\\t%s changed state to %d\\n\", waiter, state);\n-    }\n+  if (debug_mode) {\n+    DPRINTF(\"\\t%s changed state to %d\\n\", waiter, state);\n+  }\n \n-    PR_Unlock(ServerStateCVLock);\n+  PR_Unlock(ServerStateCVLock);\n }\n \n-int\n-WaitServerState(char* waiter, PRInt32 state)\n-{\n-    PRInt32 rv;\n+int WaitServerState(char* waiter, PRInt32 state) {\n+  PRInt32 rv;\n \n-    PR_Lock(ServerStateCVLock);\n+  PR_Lock(ServerStateCVLock);\n \n-    if (debug_mode) {\n-        DPRINTF(\"\\t%s waiting for state %d\\n\", waiter, state);\n-    }\n+  if (debug_mode) {\n+    DPRINTF(\"\\t%s waiting for state %d\\n\", waiter, state);\n+  }\n \n-    while (!(ServerState & state)) {\n-        PR_WaitCondVar(ServerStateCV, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    rv = ServerState;\n+  while (!(ServerState & state)) {\n+    PR_WaitCondVar(ServerStateCV, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  rv = ServerState;\n \n-    if (debug_mode)\n-        DPRINTF(\"\\t%s resuming from wait for state %d; state now %d\\n\", waiter,\n-                state, ServerState);\n-    PR_Unlock(ServerStateCVLock);\n+  if (debug_mode)\n+    DPRINTF(\"\\t%s resuming from wait for state %d; state now %d\\n\", waiter,\n+            state, ServerState);\n+  PR_Unlock(ServerStateCVLock);\n \n-    return rv;\n+  return rv;\n }\n \n /* --- Server Functions ------------------------------------------- */\n@@ -113,223 +110,217 @@ PRLock* workerThreadsLock;\n PRInt32 workerThreads;\n PRInt32 workerThreadsBusy;\n \n-void\n-WorkerThreadFunc(void* _listenSock)\n-{\n-    PRFileDesc* listenSock = (PRFileDesc*)_listenSock;\n-    PRInt32 bytesRead;\n-    PRInt32 bytesWritten;\n-    char* dataBuf;\n-    char* sendBuf;\n-\n-    if (debug_mode)\n-        DPRINTF(\"\\tServer buffer is %d bytes; %d data, %d netaddrs\\n\",\n-                _client_data + (2 * sizeof(PRNetAddr)) + 32, _client_data,\n-                (2 * sizeof(PRNetAddr)) + 32);\n-    dataBuf = (char*)PR_MALLOC(_client_data + 2 * sizeof(PRNetAddr) + 32);\n-    if (!dataBuf)\n-        if (debug_mode) {\n-            printf(\"\\tServer could not malloc space!?\\n\");\n-        }\n-    sendBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n-    if (!sendBuf)\n-        if (debug_mode) {\n-            printf(\"\\tServer could not malloc space!?\\n\");\n-        }\n-\n+void WorkerThreadFunc(void* _listenSock) {\n+  PRFileDesc* listenSock = (PRFileDesc*)_listenSock;\n+  PRInt32 bytesRead;\n+  PRInt32 bytesWritten;\n+  char* dataBuf;\n+  char* sendBuf;\n+\n+  if (debug_mode)\n+    DPRINTF(\"\\tServer buffer is %d bytes; %d data, %d netaddrs\\n\",\n+            _client_data + (2 * sizeof(PRNetAddr)) + 32, _client_data,\n+            (2 * sizeof(PRNetAddr)) + 32);\n+  dataBuf = (char*)PR_MALLOC(_client_data + 2 * sizeof(PRNetAddr) + 32);\n+  if (!dataBuf)\n+    if (debug_mode) {\n+      printf(\"\\tServer could not malloc space!?\\n\");\n+    }\n+  sendBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n+  if (!sendBuf)\n     if (debug_mode) {\n-        DPRINTF(\"\\tServer worker thread running\\n\");\n+      printf(\"\\tServer could not malloc space!?\\n\");\n     }\n \n-    while (1) {\n-        PRInt32 bytesToRead = _client_data;\n-        PRInt32 bytesToWrite = _server_data;\n-        PRFileDesc* newSock;\n-        PRNetAddr* rAddr;\n-        PRInt32 loops = 0;\n+  if (debug_mode) {\n+    DPRINTF(\"\\tServer worker thread running\\n\");\n+  }\n \n-        loops++;\n+  while (1) {\n+    PRInt32 bytesToRead = _client_data;\n+    PRInt32 bytesToWrite = _server_data;\n+    PRFileDesc* newSock;\n+    PRNetAddr* rAddr;\n+    PRInt32 loops = 0;\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer thread going into accept\\n\");\n-        }\n+    loops++;\n \n-        bytesRead = PR_AcceptRead(listenSock, &newSock, &rAddr, dataBuf,\n-                                  bytesToRead, PR_INTERVAL_NO_TIMEOUT);\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer thread going into accept\\n\");\n+    }\n \n-        if (bytesRead < 0) {\n-            if (debug_mode) {\n-                printf(\"\\tServer error in accept (%d)\\n\", bytesRead);\n-            }\n-            continue;\n-        }\n+    bytesRead = PR_AcceptRead(listenSock, &newSock, &rAddr, dataBuf,\n+                              bytesToRead, PR_INTERVAL_NO_TIMEOUT);\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer accepted connection (%d bytes)\\n\", bytesRead);\n-        }\n+    if (bytesRead < 0) {\n+      if (debug_mode) {\n+        printf(\"\\tServer error in accept (%d)\\n\", bytesRead);\n+      }\n+      continue;\n+    }\n \n-        PR_AtomicIncrement(&workerThreadsBusy);\n-        if (workerThreadsBusy == workerThreads) {\n-            PR_Lock(workerThreadsLock);\n-            if (workerThreadsBusy == workerThreads) {\n-                PRThread* WorkerThread;\n-\n-                WorkerThread = PR_CreateThread(\n-                    PR_SYSTEM_THREAD, WorkerThreadFunc, listenSock, PR_PRIORITY_NORMAL,\n-                    ServerScope, PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n-\n-                if (!WorkerThread) {\n-                    if (debug_mode) {\n-                        printf(\"Error creating client thread %d\\n\", workerThreads);\n-                    }\n-                } else {\n-                    PR_AtomicIncrement(&workerThreads);\n-                    if (debug_mode) {\n-                        DPRINTF(\"\\tServer creates worker (%d)\\n\", workerThreads);\n-                    }\n-                }\n-            }\n-            PR_Unlock(workerThreadsLock);\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer accepted connection (%d bytes)\\n\", bytesRead);\n+    }\n \n-        bytesToRead -= bytesRead;\n-        while (bytesToRead) {\n-            bytesRead =\n-                PR_Recv(newSock, dataBuf, bytesToRead, 0, PR_INTERVAL_NO_TIMEOUT);\n-            if (bytesRead < 0) {\n-                if (debug_mode) {\n-                    printf(\"\\tServer error receiving data (%d)\\n\", bytesRead);\n-                }\n-                continue;\n-            }\n-            if (debug_mode) {\n-                DPRINTF(\"\\tServer received %d bytes\\n\", bytesRead);\n-            }\n-        }\n+    PR_AtomicIncrement(&workerThreadsBusy);\n+    if (workerThreadsBusy == workerThreads) {\n+      PR_Lock(workerThreadsLock);\n+      if (workerThreadsBusy == workerThreads) {\n+        PRThread* WorkerThread;\n+\n+        WorkerThread = PR_CreateThread(\n+            PR_SYSTEM_THREAD, WorkerThreadFunc, listenSock, PR_PRIORITY_NORMAL,\n+            ServerScope, PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n \n-        bytesWritten =\n-            PR_Send(newSock, sendBuf, bytesToWrite, 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (bytesWritten != _server_data) {\n-            if (debug_mode)\n-                printf(\"\\tError sending data to client (%d, %d)\\n\", bytesWritten,\n-                       PR_GetOSError());\n+        if (!WorkerThread) {\n+          if (debug_mode) {\n+            printf(\"Error creating client thread %d\\n\", workerThreads);\n+          }\n         } else {\n-            if (debug_mode) {\n-                DPRINTF(\"\\tServer sent %d bytes\\n\", bytesWritten);\n-            }\n+          PR_AtomicIncrement(&workerThreads);\n+          if (debug_mode) {\n+            DPRINTF(\"\\tServer creates worker (%d)\\n\", workerThreads);\n+          }\n         }\n-\n-        PR_Close(newSock);\n-        PR_AtomicDecrement(&workerThreadsBusy);\n+      }\n+      PR_Unlock(workerThreadsLock);\n     }\n-}\n-\n-PRFileDesc*\n-ServerSetup(void)\n-{\n-    PRFileDesc* listenSocket;\n-    PRSocketOptionData sockOpt;\n-    PRNetAddr serverAddr;\n-    PRThread* WorkerThread;\n \n-    if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n+    bytesToRead -= bytesRead;\n+    while (bytesToRead) {\n+      bytesRead =\n+          PR_Recv(newSock, dataBuf, bytesToRead, 0, PR_INTERVAL_NO_TIMEOUT);\n+      if (bytesRead < 0) {\n         if (debug_mode) {\n-            printf(\"\\tServer error creating listen socket\\n\");\n-        } else {\n-            return NULL;\n+          printf(\"\\tServer error receiving data (%d)\\n\", bytesRead);\n         }\n+        continue;\n+      }\n+      if (debug_mode) {\n+        DPRINTF(\"\\tServer received %d bytes\\n\", bytesRead);\n+      }\n     }\n \n-    sockOpt.option = PR_SockOpt_Reuseaddr;\n-    sockOpt.value.reuse_addr = PR_TRUE;\n-    if (PR_SetSocketOption(listenSocket, &sockOpt) == PR_FAILURE) {\n-        if (debug_mode)\n-            printf(\"\\tServer error setting socket option: OS error %d\\n\",\n-                   PR_GetOSError());\n-        else {\n-            failed_already = 1;\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n+    bytesWritten =\n+        PR_Send(newSock, sendBuf, bytesToWrite, 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (bytesWritten != _server_data) {\n+      if (debug_mode)\n+        printf(\"\\tError sending data to client (%d, %d)\\n\", bytesWritten,\n+               PR_GetOSError());\n+    } else {\n+      if (debug_mode) {\n+        DPRINTF(\"\\tServer sent %d bytes\\n\", bytesWritten);\n+      }\n     }\n \n-    memset(&serverAddr, 0, sizeof(PRNetAddr));\n-    serverAddr.inet.family = PR_AF_INET;\n-    serverAddr.inet.port = PR_htons(PORT);\n-    serverAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+    PR_Close(newSock);\n+    PR_AtomicDecrement(&workerThreadsBusy);\n+  }\n+}\n \n-    if (PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {\n-        if (debug_mode)\n-            printf(\"\\tServer error binding to server address: OS error %d\\n\",\n-                   PR_GetOSError());\n-        else {\n-            failed_already = 1;\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n+PRFileDesc* ServerSetup(void) {\n+  PRFileDesc* listenSocket;\n+  PRSocketOptionData sockOpt;\n+  PRNetAddr serverAddr;\n+  PRThread* WorkerThread;\n+\n+  if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error creating listen socket\\n\");\n+    } else {\n+      return NULL;\n     }\n+  }\n \n-    if (PR_Listen(listenSocket, 128) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tServer error listening to server socket\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        PR_Close(listenSocket);\n+  sockOpt.option = PR_SockOpt_Reuseaddr;\n+  sockOpt.value.reuse_addr = PR_TRUE;\n+  if (PR_SetSocketOption(listenSocket, &sockOpt) == PR_FAILURE) {\n+    if (debug_mode)\n+      printf(\"\\tServer error setting socket option: OS error %d\\n\",\n+             PR_GetOSError());\n+    else {\n+      failed_already = 1;\n+    }\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n+\n+  memset(&serverAddr, 0, sizeof(PRNetAddr));\n+  serverAddr.inet.family = PR_AF_INET;\n+  serverAddr.inet.port = PR_htons(PORT);\n+  serverAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n \n-        return NULL;\n+  if (PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {\n+    if (debug_mode)\n+      printf(\"\\tServer error binding to server address: OS error %d\\n\",\n+             PR_GetOSError());\n+    else {\n+      failed_already = 1;\n     }\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n \n-    /* Create Clients */\n-    workerThreads = 0;\n-    workerThreadsBusy = 0;\n+  if (PR_Listen(listenSocket, 128) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error listening to server socket\\n\");\n+    } else {\n+      failed_already = 1;\n+    }\n+    PR_Close(listenSocket);\n \n-    workerThreadsLock = PR_NewLock();\n+    return NULL;\n+  }\n \n-    WorkerThread = PR_CreateThread(PR_SYSTEM_THREAD, WorkerThreadFunc,\n-                                   listenSocket, PR_PRIORITY_NORMAL, ServerScope,\n-                                   PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+  /* Create Clients */\n+  workerThreads = 0;\n+  workerThreadsBusy = 0;\n \n-    if (!WorkerThread) {\n-        if (debug_mode) {\n-            printf(\"error creating working thread\\n\");\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n-    }\n-    PR_AtomicIncrement(&workerThreads);\n+  workerThreadsLock = PR_NewLock();\n+\n+  WorkerThread = PR_CreateThread(PR_SYSTEM_THREAD, WorkerThreadFunc,\n+                                 listenSocket, PR_PRIORITY_NORMAL, ServerScope,\n+                                 PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+\n+  if (!WorkerThread) {\n     if (debug_mode) {\n-        DPRINTF(\"\\tServer created primordial worker thread\\n\");\n+      printf(\"error creating working thread\\n\");\n     }\n-\n-    return listenSocket;\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n+  PR_AtomicIncrement(&workerThreads);\n+  if (debug_mode) {\n+    DPRINTF(\"\\tServer created primordial worker thread\\n\");\n+  }\n+\n+  return listenSocket;\n }\n \n /* The main server loop */\n-void\n-ServerThreadFunc(void* unused)\n-{\n-    PRFileDesc* listenSocket;\n+void ServerThreadFunc(void* unused) {\n+  PRFileDesc* listenSocket;\n \n-    /* Do setup */\n-    listenSocket = ServerSetup();\n+  /* Do setup */\n+  listenSocket = ServerSetup();\n \n-    if (!listenSocket) {\n-        SetServerState(SERVER, SERVER_STATE_DEAD);\n-    } else {\n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer up\\n\");\n-        }\n+  if (!listenSocket) {\n+    SetServerState(SERVER, SERVER_STATE_DEAD);\n+  } else {\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer up\\n\");\n+    }\n \n-        /* Tell clients they can start now. */\n-        SetServerState(SERVER, SERVER_STATE_READY);\n+    /* Tell clients they can start now. */\n+    SetServerState(SERVER, SERVER_STATE_READY);\n \n-        /* Now wait for server death signal */\n-        WaitServerState(SERVER, SERVER_STATE_DYING);\n+    /* Now wait for server death signal */\n+    WaitServerState(SERVER, SERVER_STATE_DYING);\n \n-        /* Cleanup */\n-        SetServerState(SERVER, SERVER_STATE_DEAD);\n-    }\n+    /* Cleanup */\n+    SetServerState(SERVER, SERVER_STATE_DEAD);\n+  }\n }\n \n /* --- Client Functions ------------------------------------------- */\n@@ -338,260 +329,248 @@ PRInt32 numRequests;\n PRInt32 numClients;\n PRMonitor* clientMonitor;\n \n-void\n-ClientThreadFunc(void* unused)\n-{\n-    PRNetAddr serverAddr;\n-    PRFileDesc* clientSocket;\n-    char* sendBuf;\n-    char* recvBuf;\n-    PRInt32 rv;\n-    PRInt32 bytesNeeded;\n-\n-    sendBuf = (char*)PR_MALLOC(_client_data * sizeof(char));\n-    if (!sendBuf)\n-        if (debug_mode) {\n-            printf(\"\\tClient could not malloc space!?\\n\");\n-        }\n-    recvBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n-    if (!recvBuf)\n-        if (debug_mode) {\n-            printf(\"\\tClient could not malloc space!?\\n\");\n-        }\n-\n-    memset(&serverAddr, 0, sizeof(PRNetAddr));\n-    serverAddr.inet.family = PR_AF_INET;\n-    serverAddr.inet.port = PR_htons(PORT);\n-    serverAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n+void ClientThreadFunc(void* unused) {\n+  PRNetAddr serverAddr;\n+  PRFileDesc* clientSocket;\n+  char* sendBuf;\n+  char* recvBuf;\n+  PRInt32 rv;\n+  PRInt32 bytesNeeded;\n \n-    while (numRequests > 0) {\n-        if ((numRequests % 10) == 0)\n-            if (debug_mode) {\n-                printf(\".\");\n-            }\n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient starting request %d\\n\", numRequests);\n-        }\n+  sendBuf = (char*)PR_MALLOC(_client_data * sizeof(char));\n+  if (!sendBuf)\n+    if (debug_mode) {\n+      printf(\"\\tClient could not malloc space!?\\n\");\n+    }\n+  recvBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n+  if (!recvBuf)\n+    if (debug_mode) {\n+      printf(\"\\tClient could not malloc space!?\\n\");\n+    }\n \n-        clientSocket = PR_NewTCPSocket();\n-        if (!clientSocket) {\n-            if (debug_mode)\n-                printf(\"Client error creating socket: OS error %d\\n\", PR_GetOSError());\n-            continue;\n-        }\n+  memset(&serverAddr, 0, sizeof(PRNetAddr));\n+  serverAddr.inet.family = PR_AF_INET;\n+  serverAddr.inet.port = PR_htons(PORT);\n+  serverAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient connecting\\n\");\n-        }\n+  while (numRequests > 0) {\n+    if ((numRequests % 10) == 0)\n+      if (debug_mode) {\n+        printf(\".\");\n+      }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient starting request %d\\n\", numRequests);\n+    }\n \n-        rv = PR_Connect(clientSocket, &serverAddr, PR_INTERVAL_NO_TIMEOUT);\n-        if (!clientSocket) {\n-            if (debug_mode) {\n-                printf(\"\\tClient error connecting\\n\");\n-            }\n-            continue;\n-        }\n+    clientSocket = PR_NewTCPSocket();\n+    if (!clientSocket) {\n+      if (debug_mode)\n+        printf(\"Client error creating socket: OS error %d\\n\", PR_GetOSError());\n+      continue;\n+    }\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient connected\\n\");\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient connecting\\n\");\n+    }\n \n-        rv =\n-            PR_Send(clientSocket, sendBuf, _client_data, 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (rv != _client_data) {\n-            if (debug_mode) {\n-                printf(\"Client error sending data (%d)\\n\", rv);\n-            }\n-            PR_Close(clientSocket);\n-            continue;\n-        }\n+    rv = PR_Connect(clientSocket, &serverAddr, PR_INTERVAL_NO_TIMEOUT);\n+    if (!clientSocket) {\n+      if (debug_mode) {\n+        printf(\"\\tClient error connecting\\n\");\n+      }\n+      continue;\n+    }\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient sent %d bytes\\n\", rv);\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient connected\\n\");\n+    }\n \n-        bytesNeeded = _server_data;\n-        while (bytesNeeded) {\n-            rv = PR_Recv(clientSocket, recvBuf, bytesNeeded, 0,\n-                         PR_INTERVAL_NO_TIMEOUT);\n-            if (rv <= 0) {\n-                if (debug_mode)\n-                    printf(\"Client error receiving data (%d) (%d/%d)\\n\", rv,\n-                           (_server_data - bytesNeeded), _server_data);\n-                break;\n-            }\n-            if (debug_mode) {\n-                DPRINTF(\"\\tClient received %d bytes; need %d more\\n\", rv,\n-                        bytesNeeded - rv);\n-            }\n-            bytesNeeded -= rv;\n-        }\n+    rv =\n+        PR_Send(clientSocket, sendBuf, _client_data, 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (rv != _client_data) {\n+      if (debug_mode) {\n+        printf(\"Client error sending data (%d)\\n\", rv);\n+      }\n+      PR_Close(clientSocket);\n+      continue;\n+    }\n \n-        PR_Close(clientSocket);\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient sent %d bytes\\n\", rv);\n+    }\n \n-        PR_AtomicDecrement(&numRequests);\n+    bytesNeeded = _server_data;\n+    while (bytesNeeded) {\n+      rv = PR_Recv(clientSocket, recvBuf, bytesNeeded, 0,\n+                   PR_INTERVAL_NO_TIMEOUT);\n+      if (rv <= 0) {\n+        if (debug_mode)\n+          printf(\"Client error receiving data (%d) (%d/%d)\\n\", rv,\n+                 (_server_data - bytesNeeded), _server_data);\n+        break;\n+      }\n+      if (debug_mode) {\n+        DPRINTF(\"\\tClient received %d bytes; need %d more\\n\", rv,\n+                bytesNeeded - rv);\n+      }\n+      bytesNeeded -= rv;\n     }\n \n-    PR_EnterMonitor(clientMonitor);\n-    --numClients;\n-    PR_Notify(clientMonitor);\n-    PR_ExitMonitor(clientMonitor);\n+    PR_Close(clientSocket);\n \n-    PR_DELETE(sendBuf);\n-    PR_DELETE(recvBuf);\n+    PR_AtomicDecrement(&numRequests);\n+  }\n+\n+  PR_EnterMonitor(clientMonitor);\n+  --numClients;\n+  PR_Notify(clientMonitor);\n+  PR_ExitMonitor(clientMonitor);\n+\n+  PR_DELETE(sendBuf);\n+  PR_DELETE(recvBuf);\n }\n \n-void\n-RunClients(void)\n-{\n-    PRInt32 index;\n+void RunClients(void) {\n+  PRInt32 index;\n \n-    numRequests = _iterations;\n-    numClients = _clients;\n-    clientMonitor = PR_NewMonitor();\n+  numRequests = _iterations;\n+  numClients = _clients;\n+  clientMonitor = PR_NewMonitor();\n \n-    for (index = 0; index < _clients; index++) {\n-        PRThread* clientThread;\n+  for (index = 0; index < _clients; index++) {\n+    PRThread* clientThread;\n \n-        clientThread = PR_CreateThread(PR_USER_THREAD, ClientThreadFunc, NULL,\n-                                       PR_PRIORITY_NORMAL, ClientScope,\n-                                       PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+    clientThread = PR_CreateThread(PR_USER_THREAD, ClientThreadFunc, NULL,\n+                                   PR_PRIORITY_NORMAL, ClientScope,\n+                                   PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n \n-        if (!clientThread) {\n-            if (debug_mode) {\n-                printf(\"\\terror creating client thread %d\\n\", index);\n-            }\n-        } else if (debug_mode) {\n-            DPRINTF(\"\\tMain created client %d/%d\\n\", index + 1, _clients);\n-        }\n+    if (!clientThread) {\n+      if (debug_mode) {\n+        printf(\"\\terror creating client thread %d\\n\", index);\n+      }\n+    } else if (debug_mode) {\n+      DPRINTF(\"\\tMain created client %d/%d\\n\", index + 1, _clients);\n     }\n+  }\n \n-    PR_EnterMonitor(clientMonitor);\n-    while (numClients) {\n-        PR_Wait(clientMonitor, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_ExitMonitor(clientMonitor);\n+  PR_EnterMonitor(clientMonitor);\n+  while (numClients) {\n+    PR_Wait(clientMonitor, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_ExitMonitor(clientMonitor);\n }\n \n /* --- Main Function ---------------------------------------------- */\n \n-static void\n-do_work()\n-{\n-    PRThread* ServerThread;\n-    PRInt32 state;\n-\n-    SetServerState(MAIN, SERVER_STATE_STARTUP);\n-    ServerThread = PR_CreateThread(PR_USER_THREAD, ServerThreadFunc, NULL,\n-                                   PR_PRIORITY_NORMAL, ServerScope,\n-                                   PR_JOINABLE_THREAD, THREAD_STACKSIZE);\n-    if (!ServerThread) {\n-        if (debug_mode) {\n-            printf(\"error creating main server thread\\n\");\n-        }\n-        return;\n+static void do_work() {\n+  PRThread* ServerThread;\n+  PRInt32 state;\n+\n+  SetServerState(MAIN, SERVER_STATE_STARTUP);\n+  ServerThread = PR_CreateThread(PR_USER_THREAD, ServerThreadFunc, NULL,\n+                                 PR_PRIORITY_NORMAL, ServerScope,\n+                                 PR_JOINABLE_THREAD, THREAD_STACKSIZE);\n+  if (!ServerThread) {\n+    if (debug_mode) {\n+      printf(\"error creating main server thread\\n\");\n     }\n+    return;\n+  }\n \n-    /* Wait for server to be ready */\n-    state = WaitServerState(MAIN, SERVER_STATE_READY | SERVER_STATE_DEAD);\n+  /* Wait for server to be ready */\n+  state = WaitServerState(MAIN, SERVER_STATE_READY | SERVER_STATE_DEAD);\n \n-    if (!(state & SERVER_STATE_DEAD)) {\n-        /* Run Test Clients */\n-        RunClients();\n+  if (!(state & SERVER_STATE_DEAD)) {\n+    /* Run Test Clients */\n+    RunClients();\n \n-        /* Send death signal to server */\n-        SetServerState(MAIN, SERVER_STATE_DYING);\n-    }\n+    /* Send death signal to server */\n+    SetServerState(MAIN, SERVER_STATE_DYING);\n+  }\n \n-    PR_JoinThread(ServerThread);\n+  PR_JoinThread(ServerThread);\n }\n \n-static void\n-do_workUK(void)\n-{\n-    ServerScope = PR_LOCAL_THREAD;\n-    ClientScope = PR_GLOBAL_THREAD;\n-    do_work();\n+static void do_workUK(void) {\n+  ServerScope = PR_LOCAL_THREAD;\n+  ClientScope = PR_GLOBAL_THREAD;\n+  do_work();\n }\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow();\n \n-    d = (double)PR_IntervalToMicroseconds(stop - start);\n+  d = (double)PR_IntervalToMicroseconds(stop - start);\n \n-    if (debug_mode) {\n-        printf(\"\\n%40s: %6.2f usec\\n\", msg, d / _iterations);\n-    }\n+  if (debug_mode) {\n+    printf(\"\\n%40s: %6.2f usec\\n\", msg, d / _iterations);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-    if (debug_mode) {\n-        printf(\"Enter number of iterations: \\n\");\n-        scanf(\"%d\", &_iterations);\n-        printf(\"Enter number of clients   : \\n\");\n-        scanf(\"%d\", &_clients);\n-        printf(\"Enter size of client data : \\n\");\n-        scanf(\"%d\", &_client_data);\n-        printf(\"Enter size of server data : \\n\");\n-        scanf(\"%d\", &_server_data);\n-    } else {\n-        _iterations = 7;\n-        _clients = 7;\n-        _client_data = 100;\n-        _server_data = 100;\n+int main(int argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-\n-    if (debug_mode) {\n-        printf(\"\\n\\n%d iterations with %d client threads.\\n\", _iterations,\n-               _clients);\n-        printf(\"Sending %d bytes of client data and %d bytes of server data\\n\",\n-               _client_data, _server_data);\n-    }\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    PR_SetThreadRecycleMode(64);\n-\n-    ServerStateCVLock = PR_NewLock();\n-    ServerStateCV = PR_NewCondVar(ServerStateCVLock);\n-\n-    Measure(do_workUK, \"server loop user/kernel\");\n-\n-    PR_Cleanup();\n-\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+  if (debug_mode) {\n+    printf(\"Enter number of iterations: \\n\");\n+    scanf(\"%d\", &_iterations);\n+    printf(\"Enter number of clients   : \\n\");\n+    scanf(\"%d\", &_clients);\n+    printf(\"Enter size of client data : \\n\");\n+    scanf(\"%d\", &_client_data);\n+    printf(\"Enter size of server data : \\n\");\n+    scanf(\"%d\", &_server_data);\n+  } else {\n+    _iterations = 7;\n+    _clients = 7;\n+    _client_data = 100;\n+    _server_data = 100;\n+  }\n+\n+  if (debug_mode) {\n+    printf(\"\\n\\n%d iterations with %d client threads.\\n\", _iterations,\n+           _clients);\n+    printf(\"Sending %d bytes of client data and %d bytes of server data\\n\",\n+           _client_data, _server_data);\n+  }\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  PR_SetThreadRecycleMode(64);\n+\n+  ServerStateCVLock = PR_NewLock();\n+  ServerStateCV = PR_NewCondVar(ServerStateCVLock);\n+\n+  Measure(do_workUK, \"server loop user/kernel\");\n+\n+  PR_Cleanup();\n+\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/servr_uu.c b/nspr/pr/tests/servr_uu.c\nindex 966738e..40111b4 100644\n--- a/nspr/pr/tests/servr_uu.c\n+++ b/nspr/pr/tests/servr_uu.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -58,9 +59,9 @@ PRLock* ServerStateCVLock;\n PRCondVar* ServerStateCV;\n \n #ifdef DEBUGPRINTS\n-#define DPRINTF printf\n+#  define DPRINTF printf\n #else\n-#define DPRINTF\n+#  define DPRINTF\n #endif\n \n PRIntn failed_already = 0;\n@@ -69,42 +70,38 @@ PRIntn debug_mode;\n static void do_work(void);\n \n /* --- Server state functions --------------------------------------------- */\n-void\n-SetServerState(char* waiter, PRInt32 state)\n-{\n-    PR_Lock(ServerStateCVLock);\n-    ServerState = state;\n-    PR_NotifyCondVar(ServerStateCV);\n+void SetServerState(char* waiter, PRInt32 state) {\n+  PR_Lock(ServerStateCVLock);\n+  ServerState = state;\n+  PR_NotifyCondVar(ServerStateCV);\n \n-    if (debug_mode) {\n-        DPRINTF(\"\\t%s changed state to %d\\n\", waiter, state);\n-    }\n+  if (debug_mode) {\n+    DPRINTF(\"\\t%s changed state to %d\\n\", waiter, state);\n+  }\n \n-    PR_Unlock(ServerStateCVLock);\n+  PR_Unlock(ServerStateCVLock);\n }\n \n-int\n-WaitServerState(char* waiter, PRInt32 state)\n-{\n-    PRInt32 rv;\n+int WaitServerState(char* waiter, PRInt32 state) {\n+  PRInt32 rv;\n \n-    PR_Lock(ServerStateCVLock);\n+  PR_Lock(ServerStateCVLock);\n \n-    if (debug_mode) {\n-        DPRINTF(\"\\t%s waiting for state %d\\n\", waiter, state);\n-    }\n+  if (debug_mode) {\n+    DPRINTF(\"\\t%s waiting for state %d\\n\", waiter, state);\n+  }\n \n-    while (!(ServerState & state)) {\n-        PR_WaitCondVar(ServerStateCV, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    rv = ServerState;\n+  while (!(ServerState & state)) {\n+    PR_WaitCondVar(ServerStateCV, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  rv = ServerState;\n \n-    if (debug_mode)\n-        DPRINTF(\"\\t%s resuming from wait for state %d; state now %d\\n\", waiter,\n-                state, ServerState);\n-    PR_Unlock(ServerStateCVLock);\n+  if (debug_mode)\n+    DPRINTF(\"\\t%s resuming from wait for state %d; state now %d\\n\", waiter,\n+            state, ServerState);\n+  PR_Unlock(ServerStateCVLock);\n \n-    return rv;\n+  return rv;\n }\n \n /* --- Server Functions ------------------------------------------- */\n@@ -113,224 +110,218 @@ PRLock* workerThreadsLock;\n PRInt32 workerThreads;\n PRInt32 workerThreadsBusy;\n \n-void\n-WorkerThreadFunc(void* _listenSock)\n-{\n-    PRFileDesc* listenSock = (PRFileDesc*)_listenSock;\n-    PRInt32 bytesRead;\n-    PRInt32 bytesWritten;\n-    char* dataBuf;\n-    char* sendBuf;\n-\n-    if (debug_mode)\n-        DPRINTF(\"\\tServer buffer is %d bytes; %d data, %d netaddrs\\n\",\n-                _client_data + (2 * sizeof(PRNetAddr)) + 32, _client_data,\n-                (2 * sizeof(PRNetAddr)) + 32);\n-    dataBuf = (char*)PR_MALLOC(_client_data + 2 * sizeof(PRNetAddr) + 32);\n-    if (!dataBuf)\n-        if (debug_mode) {\n-            printf(\"\\tServer could not malloc space!?\\n\");\n-        }\n-    sendBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n-    if (!sendBuf)\n-        if (debug_mode) {\n-            printf(\"\\tServer could not malloc space!?\\n\");\n-        }\n-\n+void WorkerThreadFunc(void* _listenSock) {\n+  PRFileDesc* listenSock = (PRFileDesc*)_listenSock;\n+  PRInt32 bytesRead;\n+  PRInt32 bytesWritten;\n+  char* dataBuf;\n+  char* sendBuf;\n+\n+  if (debug_mode)\n+    DPRINTF(\"\\tServer buffer is %d bytes; %d data, %d netaddrs\\n\",\n+            _client_data + (2 * sizeof(PRNetAddr)) + 32, _client_data,\n+            (2 * sizeof(PRNetAddr)) + 32);\n+  dataBuf = (char*)PR_MALLOC(_client_data + 2 * sizeof(PRNetAddr) + 32);\n+  if (!dataBuf)\n+    if (debug_mode) {\n+      printf(\"\\tServer could not malloc space!?\\n\");\n+    }\n+  sendBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n+  if (!sendBuf)\n     if (debug_mode) {\n-        DPRINTF(\"\\tServer worker thread running\\n\");\n+      printf(\"\\tServer could not malloc space!?\\n\");\n     }\n \n-    while (1) {\n-        PRInt32 bytesToRead = _client_data;\n-        PRInt32 bytesToWrite = _server_data;\n-        PRFileDesc* newSock;\n-        PRNetAddr* rAddr;\n-        PRInt32 loops = 0;\n+  if (debug_mode) {\n+    DPRINTF(\"\\tServer worker thread running\\n\");\n+  }\n \n-        loops++;\n+  while (1) {\n+    PRInt32 bytesToRead = _client_data;\n+    PRInt32 bytesToWrite = _server_data;\n+    PRFileDesc* newSock;\n+    PRNetAddr* rAddr;\n+    PRInt32 loops = 0;\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer thread going into accept\\n\");\n-        }\n+    loops++;\n \n-        bytesRead = PR_AcceptRead(listenSock, &newSock, &rAddr, dataBuf,\n-                                  bytesToRead, PR_INTERVAL_NO_TIMEOUT);\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer thread going into accept\\n\");\n+    }\n \n-        if (bytesRead < 0) {\n-            if (debug_mode) {\n-                printf(\"\\tServer error in accept (%d)\\n\", bytesRead);\n-            }\n-            continue;\n-        }\n+    bytesRead = PR_AcceptRead(listenSock, &newSock, &rAddr, dataBuf,\n+                              bytesToRead, PR_INTERVAL_NO_TIMEOUT);\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer accepted connection (%d bytes)\\n\", bytesRead);\n-        }\n+    if (bytesRead < 0) {\n+      if (debug_mode) {\n+        printf(\"\\tServer error in accept (%d)\\n\", bytesRead);\n+      }\n+      continue;\n+    }\n \n-        PR_AtomicIncrement(&workerThreadsBusy);\n-        if (workerThreadsBusy == workerThreads) {\n-            PR_Lock(workerThreadsLock);\n-            if (workerThreadsBusy == workerThreads) {\n-                PRThread* WorkerThread;\n-\n-                WorkerThread = PR_CreateThread(\n-                    PR_SYSTEM_THREAD, WorkerThreadFunc, listenSock, PR_PRIORITY_NORMAL,\n-                    ServerScope, PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n-\n-                if (!WorkerThread) {\n-                    if (debug_mode) {\n-                        printf(\"Error creating client thread %d\\n\", workerThreads);\n-                    }\n-                } else {\n-                    PR_AtomicIncrement(&workerThreads);\n-                    if (debug_mode) {\n-                        DPRINTF(\"\\tServer creates worker (%d)\\n\", workerThreads);\n-                    }\n-                }\n-            }\n-            PR_Unlock(workerThreadsLock);\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer accepted connection (%d bytes)\\n\", bytesRead);\n+    }\n \n-        bytesToRead -= bytesRead;\n-        while (bytesToRead) {\n-            bytesRead =\n-                PR_Recv(newSock, dataBuf, bytesToRead, 0, PR_INTERVAL_NO_TIMEOUT);\n-            if (bytesRead < 0) {\n-                if (debug_mode) {\n-                    printf(\"\\tServer error receiving data (%d)\\n\", bytesRead);\n-                }\n-                continue;\n-            }\n-            if (debug_mode) {\n-                DPRINTF(\"\\tServer received %d bytes\\n\", bytesRead);\n-            }\n-        }\n+    PR_AtomicIncrement(&workerThreadsBusy);\n+    if (workerThreadsBusy == workerThreads) {\n+      PR_Lock(workerThreadsLock);\n+      if (workerThreadsBusy == workerThreads) {\n+        PRThread* WorkerThread;\n+\n+        WorkerThread = PR_CreateThread(\n+            PR_SYSTEM_THREAD, WorkerThreadFunc, listenSock, PR_PRIORITY_NORMAL,\n+            ServerScope, PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n \n-        bytesWritten =\n-            PR_Send(newSock, sendBuf, bytesToWrite, 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (bytesWritten != _server_data) {\n-            if (debug_mode)\n-                printf(\"\\tError sending data to client (%d, %d)\\n\", bytesWritten,\n-                       PR_GetOSError());\n+        if (!WorkerThread) {\n+          if (debug_mode) {\n+            printf(\"Error creating client thread %d\\n\", workerThreads);\n+          }\n         } else {\n-            if (debug_mode) {\n-                DPRINTF(\"\\tServer sent %d bytes\\n\", bytesWritten);\n-            }\n+          PR_AtomicIncrement(&workerThreads);\n+          if (debug_mode) {\n+            DPRINTF(\"\\tServer creates worker (%d)\\n\", workerThreads);\n+          }\n         }\n-\n-        PR_Close(newSock);\n-        PR_AtomicDecrement(&workerThreadsBusy);\n+      }\n+      PR_Unlock(workerThreadsLock);\n     }\n-}\n-\n-PRFileDesc*\n-ServerSetup(void)\n-{\n-    PRFileDesc* listenSocket;\n-    PRSocketOptionData sockOpt;\n-    PRNetAddr serverAddr;\n-    PRThread* WorkerThread;\n \n-    if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n+    bytesToRead -= bytesRead;\n+    while (bytesToRead) {\n+      bytesRead =\n+          PR_Recv(newSock, dataBuf, bytesToRead, 0, PR_INTERVAL_NO_TIMEOUT);\n+      if (bytesRead < 0) {\n         if (debug_mode) {\n-            printf(\"\\tServer error creating listen socket\\n\");\n-        } else {\n-            failed_already = 1;\n+          printf(\"\\tServer error receiving data (%d)\\n\", bytesRead);\n         }\n-        return NULL;\n+        continue;\n+      }\n+      if (debug_mode) {\n+        DPRINTF(\"\\tServer received %d bytes\\n\", bytesRead);\n+      }\n     }\n \n-    sockOpt.option = PR_SockOpt_Reuseaddr;\n-    sockOpt.value.reuse_addr = PR_TRUE;\n-    if (PR_SetSocketOption(listenSocket, &sockOpt) == PR_FAILURE) {\n-        if (debug_mode)\n-            printf(\"\\tServer error setting socket option: OS error %d\\n\",\n-                   PR_GetOSError());\n-        else {\n-            failed_already = 1;\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n+    bytesWritten =\n+        PR_Send(newSock, sendBuf, bytesToWrite, 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (bytesWritten != _server_data) {\n+      if (debug_mode)\n+        printf(\"\\tError sending data to client (%d, %d)\\n\", bytesWritten,\n+               PR_GetOSError());\n+    } else {\n+      if (debug_mode) {\n+        DPRINTF(\"\\tServer sent %d bytes\\n\", bytesWritten);\n+      }\n     }\n \n-    memset(&serverAddr, 0, sizeof(PRNetAddr));\n-    serverAddr.inet.family = PR_AF_INET;\n-    serverAddr.inet.port = PR_htons(PORT);\n-    serverAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+    PR_Close(newSock);\n+    PR_AtomicDecrement(&workerThreadsBusy);\n+  }\n+}\n \n-    if (PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {\n-        if (debug_mode)\n-            printf(\"\\tServer error binding to server address: OS error %d\\n\",\n-                   PR_GetOSError());\n-        else {\n-            failed_already = 1;\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n+PRFileDesc* ServerSetup(void) {\n+  PRFileDesc* listenSocket;\n+  PRSocketOptionData sockOpt;\n+  PRNetAddr serverAddr;\n+  PRThread* WorkerThread;\n+\n+  if ((listenSocket = PR_NewTCPSocket()) == NULL) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error creating listen socket\\n\");\n+    } else {\n+      failed_already = 1;\n     }\n+    return NULL;\n+  }\n \n-    if (PR_Listen(listenSocket, 128) == PR_FAILURE) {\n-        if (debug_mode) {\n-            printf(\"\\tServer error listening to server socket\\n\");\n-        } else {\n-            failed_already = 1;\n-        }\n-        PR_Close(listenSocket);\n+  sockOpt.option = PR_SockOpt_Reuseaddr;\n+  sockOpt.value.reuse_addr = PR_TRUE;\n+  if (PR_SetSocketOption(listenSocket, &sockOpt) == PR_FAILURE) {\n+    if (debug_mode)\n+      printf(\"\\tServer error setting socket option: OS error %d\\n\",\n+             PR_GetOSError());\n+    else {\n+      failed_already = 1;\n+    }\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n+\n+  memset(&serverAddr, 0, sizeof(PRNetAddr));\n+  serverAddr.inet.family = PR_AF_INET;\n+  serverAddr.inet.port = PR_htons(PORT);\n+  serverAddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n \n-        return NULL;\n+  if (PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {\n+    if (debug_mode)\n+      printf(\"\\tServer error binding to server address: OS error %d\\n\",\n+             PR_GetOSError());\n+    else {\n+      failed_already = 1;\n     }\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n \n-    /* Create Clients */\n-    workerThreads = 0;\n-    workerThreadsBusy = 0;\n+  if (PR_Listen(listenSocket, 128) == PR_FAILURE) {\n+    if (debug_mode) {\n+      printf(\"\\tServer error listening to server socket\\n\");\n+    } else {\n+      failed_already = 1;\n+    }\n+    PR_Close(listenSocket);\n \n-    workerThreadsLock = PR_NewLock();\n+    return NULL;\n+  }\n \n-    WorkerThread = PR_CreateThread(PR_SYSTEM_THREAD, WorkerThreadFunc,\n-                                   listenSocket, PR_PRIORITY_NORMAL, ServerScope,\n-                                   PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+  /* Create Clients */\n+  workerThreads = 0;\n+  workerThreadsBusy = 0;\n \n-    if (!WorkerThread) {\n-        if (debug_mode) {\n-            printf(\"error creating working thread\\n\");\n-        }\n-        PR_Close(listenSocket);\n-        return NULL;\n-    }\n-    PR_AtomicIncrement(&workerThreads);\n+  workerThreadsLock = PR_NewLock();\n+\n+  WorkerThread = PR_CreateThread(PR_SYSTEM_THREAD, WorkerThreadFunc,\n+                                 listenSocket, PR_PRIORITY_NORMAL, ServerScope,\n+                                 PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+\n+  if (!WorkerThread) {\n     if (debug_mode) {\n-        DPRINTF(\"\\tServer created primordial worker thread\\n\");\n+      printf(\"error creating working thread\\n\");\n     }\n-\n-    return listenSocket;\n+    PR_Close(listenSocket);\n+    return NULL;\n+  }\n+  PR_AtomicIncrement(&workerThreads);\n+  if (debug_mode) {\n+    DPRINTF(\"\\tServer created primordial worker thread\\n\");\n+  }\n+\n+  return listenSocket;\n }\n \n /* The main server loop */\n-void\n-ServerThreadFunc(void* unused)\n-{\n-    PRFileDesc* listenSocket;\n+void ServerThreadFunc(void* unused) {\n+  PRFileDesc* listenSocket;\n \n-    /* Do setup */\n-    listenSocket = ServerSetup();\n+  /* Do setup */\n+  listenSocket = ServerSetup();\n \n-    if (!listenSocket) {\n-        SetServerState(SERVER, SERVER_STATE_DEAD);\n-    } else {\n-        if (debug_mode) {\n-            DPRINTF(\"\\tServer up\\n\");\n-        }\n+  if (!listenSocket) {\n+    SetServerState(SERVER, SERVER_STATE_DEAD);\n+  } else {\n+    if (debug_mode) {\n+      DPRINTF(\"\\tServer up\\n\");\n+    }\n \n-        /* Tell clients they can start now. */\n-        SetServerState(SERVER, SERVER_STATE_READY);\n+    /* Tell clients they can start now. */\n+    SetServerState(SERVER, SERVER_STATE_READY);\n \n-        /* Now wait for server death signal */\n-        WaitServerState(SERVER, SERVER_STATE_DYING);\n+    /* Now wait for server death signal */\n+    WaitServerState(SERVER, SERVER_STATE_DYING);\n \n-        /* Cleanup */\n-        SetServerState(SERVER, SERVER_STATE_DEAD);\n-    }\n+    /* Cleanup */\n+    SetServerState(SERVER, SERVER_STATE_DEAD);\n+  }\n }\n \n /* --- Client Functions ------------------------------------------- */\n@@ -339,260 +330,248 @@ PRInt32 numRequests;\n PRInt32 numClients;\n PRMonitor* clientMonitor;\n \n-void\n-ClientThreadFunc(void* unused)\n-{\n-    PRNetAddr serverAddr;\n-    PRFileDesc* clientSocket;\n-    char* sendBuf;\n-    char* recvBuf;\n-    PRInt32 rv;\n-    PRInt32 bytesNeeded;\n-\n-    sendBuf = (char*)PR_MALLOC(_client_data * sizeof(char));\n-    if (!sendBuf)\n-        if (debug_mode) {\n-            printf(\"\\tClient could not malloc space!?\\n\");\n-        }\n-    recvBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n-    if (!recvBuf)\n-        if (debug_mode) {\n-            printf(\"\\tClient could not malloc space!?\\n\");\n-        }\n-\n-    memset(&serverAddr, 0, sizeof(PRNetAddr));\n-    serverAddr.inet.family = PR_AF_INET;\n-    serverAddr.inet.port = PR_htons(PORT);\n-    serverAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n+void ClientThreadFunc(void* unused) {\n+  PRNetAddr serverAddr;\n+  PRFileDesc* clientSocket;\n+  char* sendBuf;\n+  char* recvBuf;\n+  PRInt32 rv;\n+  PRInt32 bytesNeeded;\n \n-    while (numRequests > 0) {\n-        if ((numRequests % 10) == 0)\n-            if (debug_mode) {\n-                printf(\".\");\n-            }\n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient starting request %d\\n\", numRequests);\n-        }\n+  sendBuf = (char*)PR_MALLOC(_client_data * sizeof(char));\n+  if (!sendBuf)\n+    if (debug_mode) {\n+      printf(\"\\tClient could not malloc space!?\\n\");\n+    }\n+  recvBuf = (char*)PR_MALLOC(_server_data * sizeof(char));\n+  if (!recvBuf)\n+    if (debug_mode) {\n+      printf(\"\\tClient could not malloc space!?\\n\");\n+    }\n \n-        clientSocket = PR_NewTCPSocket();\n-        if (!clientSocket) {\n-            if (debug_mode)\n-                printf(\"Client error creating socket: OS error %d\\n\", PR_GetOSError());\n-            continue;\n-        }\n+  memset(&serverAddr, 0, sizeof(PRNetAddr));\n+  serverAddr.inet.family = PR_AF_INET;\n+  serverAddr.inet.port = PR_htons(PORT);\n+  serverAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient connecting\\n\");\n-        }\n+  while (numRequests > 0) {\n+    if ((numRequests % 10) == 0)\n+      if (debug_mode) {\n+        printf(\".\");\n+      }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient starting request %d\\n\", numRequests);\n+    }\n \n-        rv = PR_Connect(clientSocket, &serverAddr, PR_INTERVAL_NO_TIMEOUT);\n-        if (!clientSocket) {\n-            if (debug_mode) {\n-                printf(\"\\tClient error connecting\\n\");\n-            }\n-            continue;\n-        }\n+    clientSocket = PR_NewTCPSocket();\n+    if (!clientSocket) {\n+      if (debug_mode)\n+        printf(\"Client error creating socket: OS error %d\\n\", PR_GetOSError());\n+      continue;\n+    }\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient connected\\n\");\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient connecting\\n\");\n+    }\n \n-        rv =\n-            PR_Send(clientSocket, sendBuf, _client_data, 0, PR_INTERVAL_NO_TIMEOUT);\n-        if (rv != _client_data) {\n-            if (debug_mode) {\n-                printf(\"Client error sending data (%d)\\n\", rv);\n-            }\n-            PR_Close(clientSocket);\n-            continue;\n-        }\n+    rv = PR_Connect(clientSocket, &serverAddr, PR_INTERVAL_NO_TIMEOUT);\n+    if (!clientSocket) {\n+      if (debug_mode) {\n+        printf(\"\\tClient error connecting\\n\");\n+      }\n+      continue;\n+    }\n \n-        if (debug_mode) {\n-            DPRINTF(\"\\tClient sent %d bytes\\n\", rv);\n-        }\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient connected\\n\");\n+    }\n \n-        bytesNeeded = _server_data;\n-        while (bytesNeeded) {\n-            rv = PR_Recv(clientSocket, recvBuf, bytesNeeded, 0,\n-                         PR_INTERVAL_NO_TIMEOUT);\n-            if (rv <= 0) {\n-                if (debug_mode)\n-                    printf(\"Client error receiving data (%d) (%d/%d)\\n\", rv,\n-                           (_server_data - bytesNeeded), _server_data);\n-                break;\n-            }\n-            if (debug_mode) {\n-                DPRINTF(\"\\tClient received %d bytes; need %d more\\n\", rv,\n-                        bytesNeeded - rv);\n-            }\n-            bytesNeeded -= rv;\n-        }\n+    rv =\n+        PR_Send(clientSocket, sendBuf, _client_data, 0, PR_INTERVAL_NO_TIMEOUT);\n+    if (rv != _client_data) {\n+      if (debug_mode) {\n+        printf(\"Client error sending data (%d)\\n\", rv);\n+      }\n+      PR_Close(clientSocket);\n+      continue;\n+    }\n \n-        PR_Close(clientSocket);\n+    if (debug_mode) {\n+      DPRINTF(\"\\tClient sent %d bytes\\n\", rv);\n+    }\n \n-        PR_AtomicDecrement(&numRequests);\n+    bytesNeeded = _server_data;\n+    while (bytesNeeded) {\n+      rv = PR_Recv(clientSocket, recvBuf, bytesNeeded, 0,\n+                   PR_INTERVAL_NO_TIMEOUT);\n+      if (rv <= 0) {\n+        if (debug_mode)\n+          printf(\"Client error receiving data (%d) (%d/%d)\\n\", rv,\n+                 (_server_data - bytesNeeded), _server_data);\n+        break;\n+      }\n+      if (debug_mode) {\n+        DPRINTF(\"\\tClient received %d bytes; need %d more\\n\", rv,\n+                bytesNeeded - rv);\n+      }\n+      bytesNeeded -= rv;\n     }\n \n-    PR_EnterMonitor(clientMonitor);\n-    --numClients;\n-    PR_Notify(clientMonitor);\n-    PR_ExitMonitor(clientMonitor);\n+    PR_Close(clientSocket);\n \n-    PR_DELETE(sendBuf);\n-    PR_DELETE(recvBuf);\n+    PR_AtomicDecrement(&numRequests);\n+  }\n+\n+  PR_EnterMonitor(clientMonitor);\n+  --numClients;\n+  PR_Notify(clientMonitor);\n+  PR_ExitMonitor(clientMonitor);\n+\n+  PR_DELETE(sendBuf);\n+  PR_DELETE(recvBuf);\n }\n \n-void\n-RunClients(void)\n-{\n-    PRInt32 index;\n+void RunClients(void) {\n+  PRInt32 index;\n \n-    numRequests = _iterations;\n-    numClients = _clients;\n-    clientMonitor = PR_NewMonitor();\n+  numRequests = _iterations;\n+  numClients = _clients;\n+  clientMonitor = PR_NewMonitor();\n \n-    for (index = 0; index < _clients; index++) {\n-        PRThread* clientThread;\n+  for (index = 0; index < _clients; index++) {\n+    PRThread* clientThread;\n \n-        clientThread = PR_CreateThread(PR_USER_THREAD, ClientThreadFunc, NULL,\n-                                       PR_PRIORITY_NORMAL, ClientScope,\n-                                       PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n+    clientThread = PR_CreateThread(PR_USER_THREAD, ClientThreadFunc, NULL,\n+                                   PR_PRIORITY_NORMAL, ClientScope,\n+                                   PR_UNJOINABLE_THREAD, THREAD_STACKSIZE);\n \n-        if (!clientThread) {\n-            if (debug_mode) {\n-                printf(\"\\terror creating client thread %d\\n\", index);\n-            }\n-        } else if (debug_mode) {\n-            DPRINTF(\"\\tMain created client %d/%d\\n\", index + 1, _clients);\n-        }\n+    if (!clientThread) {\n+      if (debug_mode) {\n+        printf(\"\\terror creating client thread %d\\n\", index);\n+      }\n+    } else if (debug_mode) {\n+      DPRINTF(\"\\tMain created client %d/%d\\n\", index + 1, _clients);\n     }\n+  }\n \n-    PR_EnterMonitor(clientMonitor);\n-    while (numClients) {\n-        PR_Wait(clientMonitor, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_ExitMonitor(clientMonitor);\n+  PR_EnterMonitor(clientMonitor);\n+  while (numClients) {\n+    PR_Wait(clientMonitor, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_ExitMonitor(clientMonitor);\n }\n \n /* --- Main Function ---------------------------------------------- */\n \n-static void\n-do_work()\n-{\n-    PRThread* ServerThread;\n-    PRInt32 state;\n-\n-    SetServerState(MAIN, SERVER_STATE_STARTUP);\n-    ServerThread = PR_CreateThread(PR_USER_THREAD, ServerThreadFunc, NULL,\n-                                   PR_PRIORITY_NORMAL, ServerScope,\n-                                   PR_JOINABLE_THREAD, THREAD_STACKSIZE);\n-    if (!ServerThread) {\n-        if (debug_mode) {\n-            printf(\"error creating main server thread\\n\");\n-        }\n-        return;\n+static void do_work() {\n+  PRThread* ServerThread;\n+  PRInt32 state;\n+\n+  SetServerState(MAIN, SERVER_STATE_STARTUP);\n+  ServerThread = PR_CreateThread(PR_USER_THREAD, ServerThreadFunc, NULL,\n+                                 PR_PRIORITY_NORMAL, ServerScope,\n+                                 PR_JOINABLE_THREAD, THREAD_STACKSIZE);\n+  if (!ServerThread) {\n+    if (debug_mode) {\n+      printf(\"error creating main server thread\\n\");\n     }\n+    return;\n+  }\n \n-    /* Wait for server to be ready */\n-    state = WaitServerState(MAIN, SERVER_STATE_READY | SERVER_STATE_DEAD);\n+  /* Wait for server to be ready */\n+  state = WaitServerState(MAIN, SERVER_STATE_READY | SERVER_STATE_DEAD);\n \n-    if (!(state & SERVER_STATE_DEAD)) {\n-        /* Run Test Clients */\n-        RunClients();\n+  if (!(state & SERVER_STATE_DEAD)) {\n+    /* Run Test Clients */\n+    RunClients();\n \n-        /* Send death signal to server */\n-        SetServerState(MAIN, SERVER_STATE_DYING);\n-    }\n+    /* Send death signal to server */\n+    SetServerState(MAIN, SERVER_STATE_DYING);\n+  }\n \n-    PR_JoinThread(ServerThread);\n+  PR_JoinThread(ServerThread);\n }\n \n-static void\n-do_workUU(void)\n-{\n-    ServerScope = PR_LOCAL_THREAD;\n-    ClientScope = PR_LOCAL_THREAD;\n-    do_work();\n+static void do_workUU(void) {\n+  ServerScope = PR_LOCAL_THREAD;\n+  ClientScope = PR_LOCAL_THREAD;\n+  do_work();\n }\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow();\n \n-    d = (double)PR_IntervalToMicroseconds(stop - start);\n+  d = (double)PR_IntervalToMicroseconds(stop - start);\n \n-    if (debug_mode) {\n-        printf(\"\\n%40s: %6.2f usec\\n\", msg, d / _iterations);\n-    }\n+  if (debug_mode) {\n+    printf(\"\\n%40s: %6.2f usec\\n\", msg, d / _iterations);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n-    if (debug_mode) {\n-        printf(\"Enter number of iterations: \\n\");\n-        scanf(\"%d\", &_iterations);\n-        printf(\"Enter number of clients   : \\n\");\n-        scanf(\"%d\", &_clients);\n-        printf(\"Enter size of client data : \\n\");\n-        scanf(\"%d\", &_client_data);\n-        printf(\"Enter size of server data : \\n\");\n-        scanf(\"%d\", &_server_data);\n-    } else {\n-        _iterations = 7;\n-        _clients = 7;\n-        _client_data = 100;\n-        _server_data = 100;\n+int main(int argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-\n-    if (debug_mode) {\n-        printf(\"\\n\\n%d iterations with %d client threads.\\n\", _iterations,\n-               _clients);\n-        printf(\"Sending %d bytes of client data and %d bytes of server data\\n\",\n-               _client_data, _server_data);\n-    }\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    PR_SetThreadRecycleMode(64);\n-\n-    ServerStateCVLock = PR_NewLock();\n-    ServerStateCV = PR_NewCondVar(ServerStateCVLock);\n-\n-    Measure(do_workUU, \"server loop user/user\");\n-\n-    PR_Cleanup();\n-\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+  if (debug_mode) {\n+    printf(\"Enter number of iterations: \\n\");\n+    scanf(\"%d\", &_iterations);\n+    printf(\"Enter number of clients   : \\n\");\n+    scanf(\"%d\", &_clients);\n+    printf(\"Enter size of client data : \\n\");\n+    scanf(\"%d\", &_client_data);\n+    printf(\"Enter size of server data : \\n\");\n+    scanf(\"%d\", &_server_data);\n+  } else {\n+    _iterations = 7;\n+    _clients = 7;\n+    _client_data = 100;\n+    _server_data = 100;\n+  }\n+\n+  if (debug_mode) {\n+    printf(\"\\n\\n%d iterations with %d client threads.\\n\", _iterations,\n+           _clients);\n+    printf(\"Sending %d bytes of client data and %d bytes of server data\\n\",\n+           _client_data, _server_data);\n+  }\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  PR_SetThreadRecycleMode(64);\n+\n+  ServerStateCVLock = PR_NewLock();\n+  ServerStateCV = PR_NewCondVar(ServerStateCVLock);\n+\n+  Measure(do_workUU, \"server loop user/user\");\n+\n+  PR_Cleanup();\n+\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/short_thread.c b/nspr/pr/tests/short_thread.c\nindex 19717d0..dde1099 100644\n--- a/nspr/pr/tests/short_thread.c\n+++ b/nspr/pr/tests/short_thread.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -13,47 +14,42 @@\n \n int _debug_on = 0;\n #define DPRINTF(arg) \\\n-    if (_debug_on)   \\\n-    printf arg\n+  if (_debug_on) printf arg\n \n static void housecleaning(void* cur_time);\n \n-int\n-main(int argc, char** argv)\n-{\n-    static PRIntervalTime thread_start_time;\n-    static PRThread* housekeeping_tid = NULL;\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                _debug_on = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  static PRIntervalTime thread_start_time;\n+  static PRThread* housekeeping_tid = NULL;\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n+\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    if ((housekeeping_tid = PR_CreateThread(\n-             PR_USER_THREAD, housecleaning, (void*)&thread_start_time,\n-             PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0)) ==\n-        NULL) {\n-        fprintf(stderr, \"simple_test: Error - PR_CreateThread failed: (%ld, %ld)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        exit(1);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        _debug_on = 1;\n+        break;\n+      default:\n+        break;\n     }\n-    PR_Cleanup();\n-    return (0);\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  if ((housekeeping_tid = PR_CreateThread(\n+           PR_USER_THREAD, housecleaning, (void*)&thread_start_time,\n+           PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0)) ==\n+      NULL) {\n+    fprintf(stderr, \"simple_test: Error - PR_CreateThread failed: (%ld, %ld)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    exit(1);\n+  }\n+  PR_Cleanup();\n+  return (0);\n }\n \n-static void\n-housecleaning(void* cur_time)\n-{\n-    DPRINTF((\"Child Thread exiting\\n\"));\n+static void housecleaning(void* cur_time) {\n+  DPRINTF((\"Child Thread exiting\\n\"));\n }\ndiff --git a/nspr/pr/tests/sigpipe.c b/nspr/pr/tests/sigpipe.c\nindex 4efda6b..42f4a20 100644\n--- a/nspr/pr/tests/sigpipe.c\n+++ b/nspr/pr/tests/sigpipe.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -14,73 +15,67 @@\n \n #if !defined(XP_UNIX)\n \n-int\n-main(void)\n-{\n-    /* This test applies to Unix and OS/2. */\n-    return 0;\n+int main(void) {\n+  /* This test applies to Unix and OS/2. */\n+  return 0;\n }\n \n #else /* XP_UNIX && OS/2 */\n \n-#include \"nspr.h\"\n+#  include \"nspr.h\"\n \n-#include <stdio.h>\n-#include <unistd.h>\n-#include <errno.h>\n+#  include <stdio.h>\n+#  include <unistd.h>\n+#  include <errno.h>\n \n-static void\n-Test(void* arg)\n-{\n-    int pipefd[2];\n-    int rv;\n-    char c = '\\0';\n+static void Test(void* arg) {\n+  int pipefd[2];\n+  int rv;\n+  char c = '\\0';\n \n-    if (pipe(pipefd) == -1) {\n-        fprintf(stderr, \"cannot create pipe: %d\\n\", errno);\n-        exit(1);\n-    }\n-    close(pipefd[0]);\n+  if (pipe(pipefd) == -1) {\n+    fprintf(stderr, \"cannot create pipe: %d\\n\", errno);\n+    exit(1);\n+  }\n+  close(pipefd[0]);\n \n-    rv = write(pipefd[1], &c, 1);\n-    if (rv != -1) {\n-        fprintf(\n-            stderr,\n-            \"write to broken pipe should have failed with EPIPE but returned %d\\n\",\n-            rv);\n-        exit(1);\n-    }\n-    if (errno != EPIPE) {\n-        fprintf(stderr, \"write to broken pipe failed but with wrong errno: %d\\n\",\n-                errno);\n-        exit(1);\n-    }\n-    close(pipefd[1]);\n-    printf(\"write to broken pipe failed with EPIPE, as expected\\n\");\n+  rv = write(pipefd[1], &c, 1);\n+  if (rv != -1) {\n+    fprintf(\n+        stderr,\n+        \"write to broken pipe should have failed with EPIPE but returned %d\\n\",\n+        rv);\n+    exit(1);\n+  }\n+  if (errno != EPIPE) {\n+    fprintf(stderr, \"write to broken pipe failed but with wrong errno: %d\\n\",\n+            errno);\n+    exit(1);\n+  }\n+  close(pipefd[1]);\n+  printf(\"write to broken pipe failed with EPIPE, as expected\\n\");\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRThread* thread;\n+int main(int argc, char** argv) {\n+  PRThread* thread;\n \n-    /* This initializes NSPR. */\n-    PR_SetError(0, 0);\n+  /* This initializes NSPR. */\n+  PR_SetError(0, 0);\n \n-    thread = PR_CreateThread(PR_USER_THREAD, Test, NULL, PR_PRIORITY_NORMAL,\n-                             PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (thread == NULL) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_JoinThread(thread) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n-    }\n-    Test(NULL);\n+  thread = PR_CreateThread(PR_USER_THREAD, Test, NULL, PR_PRIORITY_NORMAL,\n+                           PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (thread == NULL) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_JoinThread(thread) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+  Test(NULL);\n \n-    printf(\"PASSED\\n\");\n-    return 0;\n+  printf(\"PASSED\\n\");\n+  return 0;\n }\n \n #endif /* XP_UNIX */\ndiff --git a/nspr/pr/tests/socket.c b/nspr/pr/tests/socket.c\nindex 5068053..280c2e0 100644\n--- a/nspr/pr/tests/socket.c\n+++ b/nspr/pr/tests/socket.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -18,14 +19,14 @@\n #include <string.h>\n #include <errno.h>\n #ifdef XP_UNIX\n-#include <sys/mman.h>\n+#  include <sys/mman.h>\n #endif\n #if defined(_PR_PTHREADS)\n-#include <pthread.h>\n+#  include <pthread.h>\n #endif\n \n #ifdef WIN32\n-#include <process.h>\n+#  include <process.h>\n #endif\n \n static int _debug_on = 0;\n@@ -34,12 +35,11 @@ static int test_cancelio = 0;\n #include \"obsolete/prsem.h\"\n \n #ifdef XP_PC\n-#define mode_t int\n+#  define mode_t int\n #endif\n \n #define DPRINTF(arg) \\\n-    if (_debug_on)   \\\n-    printf arg\n+  if (_debug_on) printf arg\n \n #ifdef XP_PC\n char* TEST_DIR = \"prdir\";\n@@ -92,7 +92,7 @@ char* LARGE_FILE_NAME = \"./tmp-prsocket_test_dir/large_file\";\n #define SERVER_MAX_BIND_COUNT 100\n \n #ifdef WINCE\n-#define perror(s)\n+#  define perror(s)\n #endif\n \n static PRInt32 num_tcp_clients = NUM_TCP_CLIENTS;\n@@ -113,123 +113,115 @@ static PRIOMethods emuSendFileMethods;\n \n int failed_already = 0;\n typedef struct buffer {\n-    char data[BUF_DATA_SIZE];\n+  char data[BUF_DATA_SIZE];\n } buffer;\n \n PRNetAddr tcp_server_addr, udp_server_addr;\n \n typedef struct Serve_Client_Param {\n-    PRFileDesc* sockfd; /* socket to read from/write to    */\n-    PRInt32 datalen;    /* bytes of data transfered in each read/write */\n+  PRFileDesc* sockfd; /* socket to read from/write to    */\n+  PRInt32 datalen;    /* bytes of data transfered in each read/write */\n } Serve_Client_Param;\n \n typedef struct Server_Param {\n-    PRSemaphore* addr_sem; /* sem to post on, after setting up the address */\n-    PRMonitor* exit_mon;   /* monitor to signal on exit            */\n-    PRInt32* exit_counter; /* counter to decrement, before exit        */\n-    PRInt32 datalen;       /* bytes of data transfered in each read/write    */\n+  PRSemaphore* addr_sem; /* sem to post on, after setting up the address */\n+  PRMonitor* exit_mon;   /* monitor to signal on exit            */\n+  PRInt32* exit_counter; /* counter to decrement, before exit        */\n+  PRInt32 datalen;       /* bytes of data transfered in each read/write    */\n } Server_Param;\n \n typedef struct Client_Param {\n-    PRNetAddr server_addr;\n-    PRMonitor* exit_mon;   /* monitor to signal on exit */\n-    PRInt32* exit_counter; /* counter to decrement, before exit */\n-    PRInt32 datalen;\n-    PRInt32 udp_connect; /* if set clients connect udp sockets */\n+  PRNetAddr server_addr;\n+  PRMonitor* exit_mon;   /* monitor to signal on exit */\n+  PRInt32* exit_counter; /* counter to decrement, before exit */\n+  PRInt32 datalen;\n+  PRInt32 udp_connect; /* if set clients connect udp sockets */\n } Client_Param;\n \n /* the sendfile method in emuSendFileMethods */\n-static PRInt32 PR_CALLBACK\n-emu_SendFile(PRFileDesc* sd, PRSendFileData* sfd,\n-             PRTransmitFileFlags flags,\n-             PRIntervalTime timeout)\n-{\n-    return PR_EmulateSendFile(sd, sfd, flags, timeout);\n+static PRInt32 PR_CALLBACK emu_SendFile(PRFileDesc* sd, PRSendFileData* sfd,\n+                                        PRTransmitFileFlags flags,\n+                                        PRIntervalTime timeout) {\n+  return PR_EmulateSendFile(sd, sfd, flags, timeout);\n }\n \n /* the transmitfile method in emuSendFileMethods */\n-static PRInt32 PR_CALLBACK\n-emu_TransmitFile(PRFileDesc* sd, PRFileDesc* fd,\n-                 const void* headers, PRInt32 hlen,\n-                 PRTransmitFileFlags flags,\n-                 PRIntervalTime timeout)\n-{\n-    PRSendFileData sfd;\n-\n-    sfd.fd = fd;\n-    sfd.file_offset = 0;\n-    sfd.file_nbytes = 0;\n-    sfd.header = headers;\n-    sfd.hlen = hlen;\n-    sfd.trailer = NULL;\n-    sfd.tlen = 0;\n-    return emu_SendFile(sd, &sfd, flags, timeout);\n+static PRInt32 PR_CALLBACK emu_TransmitFile(PRFileDesc* sd, PRFileDesc* fd,\n+                                            const void* headers, PRInt32 hlen,\n+                                            PRTransmitFileFlags flags,\n+                                            PRIntervalTime timeout) {\n+  PRSendFileData sfd;\n+\n+  sfd.fd = fd;\n+  sfd.file_offset = 0;\n+  sfd.file_nbytes = 0;\n+  sfd.header = headers;\n+  sfd.hlen = hlen;\n+  sfd.trailer = NULL;\n+  sfd.tlen = 0;\n+  return emu_SendFile(sd, &sfd, flags, timeout);\n }\n \n /*\n  * readn\n  *    read data from sockfd into buf\n  */\n-static PRInt32\n-readn(PRFileDesc* sockfd, char* buf, int len)\n-{\n-    int rem;\n-    int bytes;\n-    int offset = 0;\n-    int err;\n-    PRIntervalTime timeout = PR_INTERVAL_NO_TIMEOUT;\n-\n-    if (test_cancelio) {\n-        timeout = PR_SecondsToInterval(2);\n-    }\n-\n-    for (rem = len; rem; offset += bytes, rem -= bytes) {\n-        DPRINTF((\"thread = 0x%lx: calling PR_Recv, bytes = %d\\n\",\n-                 PR_GetCurrentThread(), rem));\n-    retry:\n-        bytes = PR_Recv(sockfd, buf + offset, rem, 0, timeout);\n-        DPRINTF((\"thread = 0x%lx: returning from PR_Recv, bytes = %d\\n\",\n-                 PR_GetCurrentThread(), bytes));\n-        if (bytes < 0) {\n+static PRInt32 readn(PRFileDesc* sockfd, char* buf, int len) {\n+  int rem;\n+  int bytes;\n+  int offset = 0;\n+  int err;\n+  PRIntervalTime timeout = PR_INTERVAL_NO_TIMEOUT;\n+\n+  if (test_cancelio) {\n+    timeout = PR_SecondsToInterval(2);\n+  }\n+\n+  for (rem = len; rem; offset += bytes, rem -= bytes) {\n+    DPRINTF((\"thread = 0x%lx: calling PR_Recv, bytes = %d\\n\",\n+             PR_GetCurrentThread(), rem));\n+  retry:\n+    bytes = PR_Recv(sockfd, buf + offset, rem, 0, timeout);\n+    DPRINTF((\"thread = 0x%lx: returning from PR_Recv, bytes = %d\\n\",\n+             PR_GetCurrentThread(), bytes));\n+    if (bytes < 0) {\n #ifdef WINNT\n-            printf(\"PR_Recv: error = %d oserr = %d\\n\", (err = PR_GetError()),\n-                   PR_GetOSError());\n-            if ((test_cancelio) && (err == PR_IO_TIMEOUT_ERROR)) {\n-                if (PR_NT_CancelIo(sockfd) != PR_SUCCESS) {\n-                    printf(\"PR_NT_CancelIO: error = %d\\n\", PR_GetError());\n-                }\n-                timeout = PR_INTERVAL_NO_TIMEOUT;\n-                goto retry;\n-            }\n-#endif\n-            return -1;\n+      printf(\"PR_Recv: error = %d oserr = %d\\n\", (err = PR_GetError()),\n+             PR_GetOSError());\n+      if ((test_cancelio) && (err == PR_IO_TIMEOUT_ERROR)) {\n+        if (PR_NT_CancelIo(sockfd) != PR_SUCCESS) {\n+          printf(\"PR_NT_CancelIO: error = %d\\n\", PR_GetError());\n         }\n+        timeout = PR_INTERVAL_NO_TIMEOUT;\n+        goto retry;\n+      }\n+#endif\n+      return -1;\n     }\n-    return len;\n+  }\n+  return len;\n }\n \n /*\n  * writen\n  *    write data from buf to sockfd\n  */\n-static PRInt32\n-writen(PRFileDesc* sockfd, char* buf, int len)\n-{\n-    int rem;\n-    int bytes;\n-    int offset = 0;\n-\n-    for (rem = len; rem; offset += bytes, rem -= bytes) {\n-        DPRINTF((\"thread = 0x%lx: calling PR_Send, bytes = %d\\n\",\n-                 PR_GetCurrentThread(), rem));\n-        bytes = PR_Send(sockfd, buf + offset, rem, 0, PR_INTERVAL_NO_TIMEOUT);\n-        DPRINTF((\"thread = 0x%lx: returning from PR_Send, bytes = %d\\n\",\n-                 PR_GetCurrentThread(), bytes));\n-        if (bytes <= 0) {\n-            return -1;\n-        }\n-    }\n-    return len;\n+static PRInt32 writen(PRFileDesc* sockfd, char* buf, int len) {\n+  int rem;\n+  int bytes;\n+  int offset = 0;\n+\n+  for (rem = len; rem; offset += bytes, rem -= bytes) {\n+    DPRINTF((\"thread = 0x%lx: calling PR_Send, bytes = %d\\n\",\n+             PR_GetCurrentThread(), rem));\n+    bytes = PR_Send(sockfd, buf + offset, rem, 0, PR_INTERVAL_NO_TIMEOUT);\n+    DPRINTF((\"thread = 0x%lx: returning from PR_Send, bytes = %d\\n\",\n+             PR_GetCurrentThread(), bytes));\n+    if (bytes <= 0) {\n+      return -1;\n+    }\n+  }\n+  return len;\n }\n \n /*\n@@ -238,113 +230,109 @@ writen(PRFileDesc* sockfd, char* buf, int len)\n  *    Reads data from socket and writes it back, unmodified, and\n  *    closes the socket\n  */\n-static void PR_CALLBACK\n-Serve_Client(void* arg)\n-{\n-    Serve_Client_Param* scp = (Serve_Client_Param*)arg;\n-    PRFileDesc* sockfd;\n-    buffer* in_buf;\n-    PRInt32 bytes, j;\n-\n-    sockfd = scp->sockfd;\n-    bytes = scp->datalen;\n-    in_buf = PR_NEW(buffer);\n-    if (in_buf == NULL) {\n-        fprintf(stderr, \"prsocket_test: failed to alloc buffer struct\\n\");\n-        failed_already = 1;\n-        goto exit;\n-    }\n+static void PR_CALLBACK Serve_Client(void* arg) {\n+  Serve_Client_Param* scp = (Serve_Client_Param*)arg;\n+  PRFileDesc* sockfd;\n+  buffer* in_buf;\n+  PRInt32 bytes, j;\n \n-    for (j = 0; j < num_tcp_mesgs_per_connection; j++) {\n-        /*\n-         * Read data from client and send it back to the client unmodified\n-         */\n-        if (readn(sockfd, in_buf->data, bytes) < bytes) {\n-            fprintf(stderr, \"prsocket_test: ERROR - Serve_Client:readn\\n\");\n-            failed_already = 1;\n-            goto exit;\n-        }\n-        /* Shutdown only RCV will cause error on Symbian OS */\n-        /*\n-         * shutdown reads, after the last read\n-         */\n-        if (j == num_tcp_mesgs_per_connection - 1)\n-            if (PR_Shutdown(sockfd, PR_SHUTDOWN_RCV) < 0) {\n-                fprintf(stderr, \"prsocket_test: ERROR - PR_Shutdown\\n\");\n-            }\n-        DPRINTF((\"Serve_Client [0x%lx]: inbuf[0] = 0x%lx\\n\", PR_GetCurrentThread(),\n-                 (*((int*)in_buf->data))));\n-        if (writen(sockfd, in_buf->data, bytes) < bytes) {\n-            fprintf(stderr, \"prsocket_test: ERROR - Serve_Client:writen\\n\");\n-            failed_already = 1;\n-            goto exit;\n-        }\n+  sockfd = scp->sockfd;\n+  bytes = scp->datalen;\n+  in_buf = PR_NEW(buffer);\n+  if (in_buf == NULL) {\n+    fprintf(stderr, \"prsocket_test: failed to alloc buffer struct\\n\");\n+    failed_already = 1;\n+    goto exit;\n+  }\n+\n+  for (j = 0; j < num_tcp_mesgs_per_connection; j++) {\n+    /*\n+     * Read data from client and send it back to the client unmodified\n+     */\n+    if (readn(sockfd, in_buf->data, bytes) < bytes) {\n+      fprintf(stderr, \"prsocket_test: ERROR - Serve_Client:readn\\n\");\n+      failed_already = 1;\n+      goto exit;\n     }\n+    /* Shutdown only RCV will cause error on Symbian OS */\n     /*\n-     * shutdown reads and writes\n+     * shutdown reads, after the last read\n      */\n-    if (PR_Shutdown(sockfd, PR_SHUTDOWN_BOTH) < 0) {\n+    if (j == num_tcp_mesgs_per_connection - 1)\n+      if (PR_Shutdown(sockfd, PR_SHUTDOWN_RCV) < 0) {\n         fprintf(stderr, \"prsocket_test: ERROR - PR_Shutdown\\n\");\n-        failed_already = 1;\n-    }\n+      }\n+    DPRINTF((\"Serve_Client [0x%lx]: inbuf[0] = 0x%lx\\n\", PR_GetCurrentThread(),\n+             (*((int*)in_buf->data))));\n+    if (writen(sockfd, in_buf->data, bytes) < bytes) {\n+      fprintf(stderr, \"prsocket_test: ERROR - Serve_Client:writen\\n\");\n+      failed_already = 1;\n+      goto exit;\n+    }\n+  }\n+  /*\n+   * shutdown reads and writes\n+   */\n+  if (PR_Shutdown(sockfd, PR_SHUTDOWN_BOTH) < 0) {\n+    fprintf(stderr, \"prsocket_test: ERROR - PR_Shutdown\\n\");\n+    failed_already = 1;\n+  }\n \n exit:\n-    PR_Close(sockfd);\n-    if (in_buf) {\n-        PR_DELETE(in_buf);\n-    }\n+  PR_Close(sockfd);\n+  if (in_buf) {\n+    PR_DELETE(in_buf);\n+  }\n }\n \n-PRThread*\n-create_new_thread(PRThreadType type, void (*start)(void* arg),\n-                  void* arg, PRThreadPriority priority,\n-                  PRThreadScope scope, PRThreadState state,\n-                  PRUint32 stackSize, PRInt32 index)\n-{\n-    PRInt32 native_thread = 0;\n+PRThread* create_new_thread(PRThreadType type, void (*start)(void* arg),\n+                            void* arg, PRThreadPriority priority,\n+                            PRThreadScope scope, PRThreadState state,\n+                            PRUint32 stackSize, PRInt32 index) {\n+  PRInt32 native_thread = 0;\n \n-    PR_ASSERT(state == PR_UNJOINABLE_THREAD);\n+  PR_ASSERT(state == PR_UNJOINABLE_THREAD);\n #if defined(_PR_PTHREADS) || defined(WIN32)\n-    switch (index % 4) {\n-        case 0:\n-            scope = (PR_LOCAL_THREAD);\n-            break;\n-        case 1:\n-            scope = (PR_GLOBAL_THREAD);\n-            break;\n-        case 2:\n-            scope = (PR_GLOBAL_BOUND_THREAD);\n-            break;\n-        case 3:\n-            native_thread = 1;\n-            break;\n-        default:\n-            PR_NOT_REACHED(\"Invalid scope\");\n-            break;\n-    }\n-    if (native_thread) {\n-#if defined(_PR_PTHREADS)\n-        pthread_t tid;\n-        if (!pthread_create(&tid, NULL, (void* (*)(void*))start, arg)) {\n-            return ((PRThread*)tid);\n-        } else {\n-            return (NULL);\n-        }\n-#else\n-        HANDLE thandle;\n-        unsigned tid;\n-\n-        thandle = (HANDLE)_beginthreadex(NULL, stackSize,\n-                                         (unsigned(__stdcall*)(void*))start, arg,\n-                                         STACK_SIZE_PARAM_IS_A_RESERVATION, &tid);\n-        return ((PRThread*)thandle);\n-#endif\n+  switch (index % 4) {\n+    case 0:\n+      scope = (PR_LOCAL_THREAD);\n+      break;\n+    case 1:\n+      scope = (PR_GLOBAL_THREAD);\n+      break;\n+    case 2:\n+      scope = (PR_GLOBAL_BOUND_THREAD);\n+      break;\n+    case 3:\n+      native_thread = 1;\n+      break;\n+    default:\n+      PR_NOT_REACHED(\"Invalid scope\");\n+      break;\n+  }\n+  if (native_thread) {\n+#  if defined(_PR_PTHREADS)\n+    pthread_t tid;\n+    if (!pthread_create(&tid, NULL, (void* (*)(void*))start, arg)) {\n+      return ((PRThread*)tid);\n     } else {\n-        return (\n-            PR_CreateThread(type, start, arg, priority, scope, state, stackSize));\n-    }\n+      return (NULL);\n+    }\n+#  else\n+    HANDLE thandle;\n+    unsigned tid;\n+\n+    thandle = (HANDLE)_beginthreadex(NULL, stackSize,\n+                                     (unsigned(__stdcall*)(void*))start, arg,\n+                                     STACK_SIZE_PARAM_IS_A_RESERVATION, &tid);\n+    return ((PRThread*)thandle);\n+#  endif\n+  } else {\n+    return (\n+        PR_CreateThread(type, start, arg, priority, scope, state, stackSize));\n+  }\n #else\n-    return (PR_CreateThread(type, start, arg, priority, scope, state, stackSize));\n+  return (PR_CreateThread(type, start, arg, priority, scope, state, stackSize));\n #endif\n }\n \n@@ -354,127 +342,125 @@ create_new_thread(PRThreadType type, void (*start)(void* arg),\n  *    Bind an address to a socket and listen for incoming connections\n  *    Start a Serve_Client thread for each incoming connection.\n  */\n-static void PR_CALLBACK\n-TCP_Server(void* arg)\n-{\n-    PRThread* t;\n-    Server_Param* sp = (Server_Param*)arg;\n-    Serve_Client_Param* scp;\n-    PRFileDesc *sockfd, *newsockfd;\n-    PRNetAddr netaddr;\n-    PRInt32 i;\n-    /*\n-     * Create a tcp socket\n-     */\n-    if ((sockfd = PR_OpenTCPSocket(server_domain)) == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NewTCPSocket failed\\n\");\n-        goto exit;\n-    }\n-    memset(&netaddr, 0, sizeof(netaddr));\n-\n-    if (PR_SetNetAddr(PR_IpAddrAny, server_domain, TCP_SERVER_PORT, &netaddr) ==\n-        PR_FAILURE) {\n-        fprintf(stderr, \"prsocket_test: PR_SetNetAddr failed\\n\");\n-        goto exit;\n-    }\n-    /*\n-     * try a few times to bind server's address, if addresses are in\n-     * use\n-     */\n-    i = 0;\n-\n-    while (PR_Bind(sockfd, &netaddr) < 0) {\n-        if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n-            netaddr.inet.port += 2;\n-            if (i++ < SERVER_MAX_BIND_COUNT) {\n-                continue;\n-            }\n-        }\n-        fprintf(stderr, \"prsocket_test: ERROR - PR_Bind failed\\n\");\n-        perror(\"PR_Bind\");\n-        failed_already = 1;\n-        goto exit;\n-    }\n-\n-    if (PR_Listen(sockfd, 32) < 0) {\n-        fprintf(stderr, \"prsocket_test: ERROR - PR_Listen failed\\n\");\n-        failed_already = 1;\n-        goto exit;\n-    }\n-\n-    if (PR_GetSockName(sockfd, &netaddr) < 0) {\n-        fprintf(stderr, \"prsocket_test: ERROR - PR_GetSockName failed\\n\");\n-        failed_already = 1;\n-        goto exit;\n-    }\n-\n-    DPRINTF(\n-        (\"TCP_Server: PR_BIND netaddr.inet.ip = 0x%lx, netaddr.inet.port = %d\\n\",\n-         netaddr.inet.ip, netaddr.inet.port));\n-    if (PR_SetNetAddr(PR_IpAddrLoopback, client_domain,\n-                      PR_ntohs(PR_NetAddrInetPort(&netaddr)),\n-                      &tcp_server_addr) == PR_FAILURE) {\n-        fprintf(stderr, \"prsocket_test: PR_SetNetAddr failed\\n\");\n-        goto exit;\n-    }\n-    if ((client_domain == PR_AF_INET6) && (server_domain == PR_AF_INET))\n-        PR_ConvertIPv4AddrToIPv6(PR_htonl(INADDR_LOOPBACK),\n-                                 &tcp_server_addr.ipv6.ip);\n-\n-    /*\n-     * Wake up parent thread because server address is bound and made\n-     * available in the global variable 'tcp_server_addr'\n-     */\n-    PR_PostSem(sp->addr_sem);\n-\n-    for (i = 0; i < (num_tcp_clients * num_tcp_connections_per_client); i++) {\n-        /* test both null and non-null 'addr' argument to PR_Accept */\n-        PRNetAddr* addrp = (i % 2 ? &netaddr : NULL);\n-\n-        DPRINTF((\"TCP_Server: Accepting connection\\n\"));\n-        if ((newsockfd = PR_Accept(sockfd, addrp, PR_INTERVAL_NO_TIMEOUT)) ==\n-            NULL) {\n-            fprintf(stderr, \"prsocket_test: ERROR - PR_Accept failed\\n\");\n-            goto exit;\n-        }\n-        DPRINTF((\"TCP_Server: Accepted connection\\n\"));\n-        scp = PR_NEW(Serve_Client_Param);\n-        if (scp == NULL) {\n-            fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n-            goto exit;\n-        }\n-\n-        /*\n-         * Start a Serve_Client thread for each incoming connection\n-         */\n-        scp->sockfd = newsockfd;\n-        scp->datalen = sp->datalen;\n-\n-        t = create_new_thread(PR_USER_THREAD, Serve_Client, (void*)scp,\n-                              PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n-                              PR_UNJOINABLE_THREAD, 0, i);\n-        if (t == NULL) {\n-            fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n-            failed_already = 1;\n-            goto exit;\n-        }\n-        DPRINTF((\"TCP_Server: Created Serve_Client = 0x%lx\\n\", t));\n+static void PR_CALLBACK TCP_Server(void* arg) {\n+  PRThread* t;\n+  Server_Param* sp = (Server_Param*)arg;\n+  Serve_Client_Param* scp;\n+  PRFileDesc *sockfd, *newsockfd;\n+  PRNetAddr netaddr;\n+  PRInt32 i;\n+  /*\n+   * Create a tcp socket\n+   */\n+  if ((sockfd = PR_OpenTCPSocket(server_domain)) == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NewTCPSocket failed\\n\");\n+    goto exit;\n+  }\n+  memset(&netaddr, 0, sizeof(netaddr));\n+\n+  if (PR_SetNetAddr(PR_IpAddrAny, server_domain, TCP_SERVER_PORT, &netaddr) ==\n+      PR_FAILURE) {\n+    fprintf(stderr, \"prsocket_test: PR_SetNetAddr failed\\n\");\n+    goto exit;\n+  }\n+  /*\n+   * try a few times to bind server's address, if addresses are in\n+   * use\n+   */\n+  i = 0;\n+\n+  while (PR_Bind(sockfd, &netaddr) < 0) {\n+    if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n+      netaddr.inet.port += 2;\n+      if (i++ < SERVER_MAX_BIND_COUNT) {\n+        continue;\n+      }\n+    }\n+    fprintf(stderr, \"prsocket_test: ERROR - PR_Bind failed\\n\");\n+    perror(\"PR_Bind\");\n+    failed_already = 1;\n+    goto exit;\n+  }\n+\n+  if (PR_Listen(sockfd, 32) < 0) {\n+    fprintf(stderr, \"prsocket_test: ERROR - PR_Listen failed\\n\");\n+    failed_already = 1;\n+    goto exit;\n+  }\n+\n+  if (PR_GetSockName(sockfd, &netaddr) < 0) {\n+    fprintf(stderr, \"prsocket_test: ERROR - PR_GetSockName failed\\n\");\n+    failed_already = 1;\n+    goto exit;\n+  }\n+\n+  DPRINTF(\n+      (\"TCP_Server: PR_BIND netaddr.inet.ip = 0x%lx, netaddr.inet.port = %d\\n\",\n+       netaddr.inet.ip, netaddr.inet.port));\n+  if (PR_SetNetAddr(PR_IpAddrLoopback, client_domain,\n+                    PR_ntohs(PR_NetAddrInetPort(&netaddr)),\n+                    &tcp_server_addr) == PR_FAILURE) {\n+    fprintf(stderr, \"prsocket_test: PR_SetNetAddr failed\\n\");\n+    goto exit;\n+  }\n+  if ((client_domain == PR_AF_INET6) && (server_domain == PR_AF_INET))\n+    PR_ConvertIPv4AddrToIPv6(PR_htonl(INADDR_LOOPBACK),\n+                             &tcp_server_addr.ipv6.ip);\n+\n+  /*\n+   * Wake up parent thread because server address is bound and made\n+   * available in the global variable 'tcp_server_addr'\n+   */\n+  PR_PostSem(sp->addr_sem);\n+\n+  for (i = 0; i < (num_tcp_clients * num_tcp_connections_per_client); i++) {\n+    /* test both null and non-null 'addr' argument to PR_Accept */\n+    PRNetAddr* addrp = (i % 2 ? &netaddr : NULL);\n+\n+    DPRINTF((\"TCP_Server: Accepting connection\\n\"));\n+    if ((newsockfd = PR_Accept(sockfd, addrp, PR_INTERVAL_NO_TIMEOUT)) ==\n+        NULL) {\n+      fprintf(stderr, \"prsocket_test: ERROR - PR_Accept failed\\n\");\n+      goto exit;\n+    }\n+    DPRINTF((\"TCP_Server: Accepted connection\\n\"));\n+    scp = PR_NEW(Serve_Client_Param);\n+    if (scp == NULL) {\n+      fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n+      goto exit;\n+    }\n+\n+    /*\n+     * Start a Serve_Client thread for each incoming connection\n+     */\n+    scp->sockfd = newsockfd;\n+    scp->datalen = sp->datalen;\n+\n+    t = create_new_thread(PR_USER_THREAD, Serve_Client, (void*)scp,\n+                          PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n+                          PR_UNJOINABLE_THREAD, 0, i);\n+    if (t == NULL) {\n+      fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n+      failed_already = 1;\n+      goto exit;\n     }\n+    DPRINTF((\"TCP_Server: Created Serve_Client = 0x%lx\\n\", t));\n+  }\n \n exit:\n-    if (sockfd) {\n-        PR_Close(sockfd);\n-    }\n+  if (sockfd) {\n+    PR_Close(sockfd);\n+  }\n \n-    /*\n-     * Decrement exit_counter and notify parent thread\n-     */\n+  /*\n+   * Decrement exit_counter and notify parent thread\n+   */\n \n-    PR_EnterMonitor(sp->exit_mon);\n-    --(*sp->exit_counter);\n-    PR_Notify(sp->exit_mon);\n-    PR_ExitMonitor(sp->exit_mon);\n-    DPRINTF((\"TCP_Server [0x%lx] exiting\\n\", PR_GetCurrentThread()));\n+  PR_EnterMonitor(sp->exit_mon);\n+  --(*sp->exit_counter);\n+  PR_Notify(sp->exit_mon);\n+  PR_ExitMonitor(sp->exit_mon);\n+  DPRINTF((\"TCP_Server [0x%lx] exiting\\n\", PR_GetCurrentThread()));\n }\n \n /*\n@@ -483,127 +469,125 @@ exit:\n  *    Bind an address to a socket, read data from clients and send data\n  *    back to clients\n  */\n-static void PR_CALLBACK\n-UDP_Server(void* arg)\n-{\n-    Server_Param* sp = (Server_Param*)arg;\n-    PRFileDesc* sockfd;\n-    buffer* in_buf;\n-    PRNetAddr netaddr;\n-    PRInt32 bytes, i, rv = 0;\n-\n-    bytes = sp->datalen;\n-    /*\n-     * Create a udp socket\n-     */\n-    if ((sockfd = PR_OpenUDPSocket(server_domain)) == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NewUDPSocket failed\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    memset(&netaddr, 0, sizeof(netaddr));\n-    if (PR_SetNetAddr(PR_IpAddrAny, server_domain, UDP_SERVER_PORT, &netaddr) ==\n-        PR_FAILURE) {\n-        fprintf(stderr, \"prsocket_test: PR_SetNetAddr failed\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    /*\n-     * try a few times to bind server's address, if addresses are in\n-     * use\n-     */\n-    i = 0;\n-    while (PR_Bind(sockfd, &netaddr) < 0) {\n-        if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n-            netaddr.inet.port += 2;\n-            if (i++ < SERVER_MAX_BIND_COUNT) {\n-                continue;\n-            }\n-        }\n-        fprintf(stderr, \"prsocket_test: ERROR - PR_Bind failed\\n\");\n-        perror(\"PR_Bind\");\n-        failed_already = 1;\n-        return;\n-    }\n-\n-    if (PR_GetSockName(sockfd, &netaddr) < 0) {\n-        fprintf(stderr, \"prsocket_test: ERROR - PR_GetSockName failed\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-\n+static void PR_CALLBACK UDP_Server(void* arg) {\n+  Server_Param* sp = (Server_Param*)arg;\n+  PRFileDesc* sockfd;\n+  buffer* in_buf;\n+  PRNetAddr netaddr;\n+  PRInt32 bytes, i, rv = 0;\n+\n+  bytes = sp->datalen;\n+  /*\n+   * Create a udp socket\n+   */\n+  if ((sockfd = PR_OpenUDPSocket(server_domain)) == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NewUDPSocket failed\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  memset(&netaddr, 0, sizeof(netaddr));\n+  if (PR_SetNetAddr(PR_IpAddrAny, server_domain, UDP_SERVER_PORT, &netaddr) ==\n+      PR_FAILURE) {\n+    fprintf(stderr, \"prsocket_test: PR_SetNetAddr failed\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  /*\n+   * try a few times to bind server's address, if addresses are in\n+   * use\n+   */\n+  i = 0;\n+  while (PR_Bind(sockfd, &netaddr) < 0) {\n+    if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n+      netaddr.inet.port += 2;\n+      if (i++ < SERVER_MAX_BIND_COUNT) {\n+        continue;\n+      }\n+    }\n+    fprintf(stderr, \"prsocket_test: ERROR - PR_Bind failed\\n\");\n+    perror(\"PR_Bind\");\n+    failed_already = 1;\n+    return;\n+  }\n+\n+  if (PR_GetSockName(sockfd, &netaddr) < 0) {\n+    fprintf(stderr, \"prsocket_test: ERROR - PR_GetSockName failed\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+\n+  DPRINTF(\n+      (\"PR_Bind: UDP Server netaddr.inet.ip = 0x%lx, netaddr.inet.port = %d\\n\",\n+       netaddr.inet.ip, netaddr.inet.port));\n+  /*\n+   * We can't use the IP address returned by PR_GetSockName in\n+   * netaddr.inet.ip because netaddr.inet.ip is returned\n+   * as 0 (= PR_INADDR_ANY).\n+   */\n+\n+  if (PR_SetNetAddr(PR_IpAddrLoopback, client_domain,\n+                    PR_ntohs(PR_NetAddrInetPort(&netaddr)),\n+                    &udp_server_addr) == PR_FAILURE) {\n+    fprintf(stderr, \"prsocket_test: PR_SetNetAddr failed\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if ((client_domain == PR_AF_INET6) && (server_domain == PR_AF_INET))\n+    PR_ConvertIPv4AddrToIPv6(PR_htonl(INADDR_LOOPBACK),\n+                             &udp_server_addr.ipv6.ip);\n+\n+  /*\n+   * Wake up parent thread because server address is bound and made\n+   * available in the global variable 'udp_server_addr'\n+   */\n+  PR_PostSem(sp->addr_sem);\n+\n+  bytes = sp->datalen;\n+  in_buf = PR_NEW(buffer);\n+  if (in_buf == NULL) {\n+    fprintf(stderr, \"prsocket_test: failed to alloc buffer struct\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  /*\n+   * Receive datagrams from clients and send them back, unmodified, to the\n+   * clients\n+   */\n+  memset(&netaddr, 0, sizeof(netaddr));\n+  for (i = 0; i < (num_udp_clients * num_udp_datagrams_per_client); i++) {\n     DPRINTF(\n-        (\"PR_Bind: UDP Server netaddr.inet.ip = 0x%lx, netaddr.inet.port = %d\\n\",\n-         netaddr.inet.ip, netaddr.inet.port));\n-    /*\n-     * We can't use the IP address returned by PR_GetSockName in\n-     * netaddr.inet.ip because netaddr.inet.ip is returned\n-     * as 0 (= PR_INADDR_ANY).\n-     */\n-\n-    if (PR_SetNetAddr(PR_IpAddrLoopback, client_domain,\n-                      PR_ntohs(PR_NetAddrInetPort(&netaddr)),\n-                      &udp_server_addr) == PR_FAILURE) {\n-        fprintf(stderr, \"prsocket_test: PR_SetNetAddr failed\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if ((client_domain == PR_AF_INET6) && (server_domain == PR_AF_INET))\n-        PR_ConvertIPv4AddrToIPv6(PR_htonl(INADDR_LOOPBACK),\n-                                 &udp_server_addr.ipv6.ip);\n-\n-    /*\n-     * Wake up parent thread because server address is bound and made\n-     * available in the global variable 'udp_server_addr'\n-     */\n-    PR_PostSem(sp->addr_sem);\n-\n-    bytes = sp->datalen;\n-    in_buf = PR_NEW(buffer);\n-    if (in_buf == NULL) {\n-        fprintf(stderr, \"prsocket_test: failed to alloc buffer struct\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    /*\n-     * Receive datagrams from clients and send them back, unmodified, to the\n-     * clients\n-     */\n-    memset(&netaddr, 0, sizeof(netaddr));\n-    for (i = 0; i < (num_udp_clients * num_udp_datagrams_per_client); i++) {\n-        DPRINTF(\n-            (\"UDP_Server: calling PR_RecvFrom client  - ip = 0x%lx, port = %d \"\n-             \"bytes = %d inbuf = 0x%lx, inbuf[0] = 0x%lx\\n\",\n-             netaddr.inet.ip, netaddr.inet.port, bytes, in_buf->data,\n-             in_buf->data[0]));\n-\n-        rv = PR_RecvFrom(sockfd, in_buf->data, bytes, 0, &netaddr,\n-                         PR_INTERVAL_NO_TIMEOUT);\n-        DPRINTF((\n-            \"UDP_Server: PR_RecvFrom client  - ip = 0x%lx, port = %d bytes = %d \"\n-            \"inbuf = 0x%lx, inbuf[0] = 0x%lx\\n\",\n-            netaddr.inet.ip, netaddr.inet.port, rv, in_buf->data, in_buf->data[0]));\n-        if (rv != bytes) {\n-            return;\n-        }\n-        rv = PR_SendTo(sockfd, in_buf->data, bytes, 0, &netaddr,\n-                       PR_INTERVAL_NO_TIMEOUT);\n-        if (rv != bytes) {\n-            return;\n-        }\n-    }\n-\n-    PR_DELETE(in_buf);\n-    PR_Close(sockfd);\n-\n-    /*\n-     * Decrement exit_counter and notify parent thread\n-     */\n-    PR_EnterMonitor(sp->exit_mon);\n-    --(*sp->exit_counter);\n-    PR_Notify(sp->exit_mon);\n-    PR_ExitMonitor(sp->exit_mon);\n-    DPRINTF((\"UDP_Server [0x%x] exiting\\n\", PR_GetCurrentThread()));\n+        (\"UDP_Server: calling PR_RecvFrom client  - ip = 0x%lx, port = %d \"\n+         \"bytes = %d inbuf = 0x%lx, inbuf[0] = 0x%lx\\n\",\n+         netaddr.inet.ip, netaddr.inet.port, bytes, in_buf->data,\n+         in_buf->data[0]));\n+\n+    rv = PR_RecvFrom(sockfd, in_buf->data, bytes, 0, &netaddr,\n+                     PR_INTERVAL_NO_TIMEOUT);\n+    DPRINTF((\n+        \"UDP_Server: PR_RecvFrom client  - ip = 0x%lx, port = %d bytes = %d \"\n+        \"inbuf = 0x%lx, inbuf[0] = 0x%lx\\n\",\n+        netaddr.inet.ip, netaddr.inet.port, rv, in_buf->data, in_buf->data[0]));\n+    if (rv != bytes) {\n+      return;\n+    }\n+    rv = PR_SendTo(sockfd, in_buf->data, bytes, 0, &netaddr,\n+                   PR_INTERVAL_NO_TIMEOUT);\n+    if (rv != bytes) {\n+      return;\n+    }\n+  }\n+\n+  PR_DELETE(in_buf);\n+  PR_Close(sockfd);\n+\n+  /*\n+   * Decrement exit_counter and notify parent thread\n+   */\n+  PR_EnterMonitor(sp->exit_mon);\n+  --(*sp->exit_counter);\n+  PR_Notify(sp->exit_mon);\n+  PR_ExitMonitor(sp->exit_mon);\n+  DPRINTF((\"UDP_Server [0x%x] exiting\\n\", PR_GetCurrentThread()));\n }\n \n /*\n@@ -614,98 +598,96 @@ UDP_Server(void* arg)\n  *    for data corruption.\n  *    Close the socket for server connection\n  */\n-static void PR_CALLBACK\n-TCP_Client(void* arg)\n-{\n-    Client_Param* cp = (Client_Param*)arg;\n-    PRFileDesc* sockfd;\n-    buffer *in_buf, *out_buf;\n-    union PRNetAddr netaddr;\n-    PRInt32 bytes, i, j;\n-\n-    bytes = cp->datalen;\n-    out_buf = PR_NEW(buffer);\n-    if (out_buf == NULL) {\n-        fprintf(stderr, \"prsocket_test: failed to alloc buffer struct\\n\");\n+static void PR_CALLBACK TCP_Client(void* arg) {\n+  Client_Param* cp = (Client_Param*)arg;\n+  PRFileDesc* sockfd;\n+  buffer *in_buf, *out_buf;\n+  union PRNetAddr netaddr;\n+  PRInt32 bytes, i, j;\n+\n+  bytes = cp->datalen;\n+  out_buf = PR_NEW(buffer);\n+  if (out_buf == NULL) {\n+    fprintf(stderr, \"prsocket_test: failed to alloc buffer struct\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  in_buf = PR_NEW(buffer);\n+  if (in_buf == NULL) {\n+    fprintf(stderr, \"prsocket_test: failed to alloc buffer struct\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  netaddr = cp->server_addr;\n+\n+  for (i = 0; i < num_tcp_connections_per_client; i++) {\n+    if ((sockfd = PR_OpenTCPSocket(client_domain)) == NULL) {\n+      fprintf(stderr, \"prsocket_test: PR_OpenTCPSocket failed\\n\");\n+      failed_already = 1;\n+      return;\n+    }\n+    if (PR_Connect(sockfd, &netaddr, PR_INTERVAL_NO_TIMEOUT) < 0) {\n+      fprintf(stderr, \"PR_Connect failed: (%ld, %ld)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      failed_already = 1;\n+      return;\n+    }\n+    for (j = 0; j < num_tcp_mesgs_per_connection; j++) {\n+      /*\n+       * fill in random data\n+       */\n+      memset(out_buf->data, ((PRInt32)(&netaddr)) + i + j, bytes);\n+      /*\n+       * write to server\n+       */\n+#ifdef WINNT\n+      if (test_cancelio && (j == 0)) {\n+        PR_Sleep(PR_SecondsToInterval(12));\n+      }\n+#endif\n+      if (writen(sockfd, out_buf->data, bytes) < bytes) {\n+        fprintf(stderr, \"prsocket_test: ERROR - TCP_Client:writen\\n\");\n         failed_already = 1;\n         return;\n-    }\n-    in_buf = PR_NEW(buffer);\n-    if (in_buf == NULL) {\n-        fprintf(stderr, \"prsocket_test: failed to alloc buffer struct\\n\");\n+      }\n+      DPRINTF((\"TCP Client [0x%lx]: out_buf = 0x%lx out_buf[0] = 0x%lx\\n\",\n+               PR_GetCurrentThread(), out_buf, (*((int*)out_buf->data))));\n+      if (readn(sockfd, in_buf->data, bytes) < bytes) {\n+        fprintf(stderr, \"prsocket_test: ERROR - TCP_Client:readn\\n\");\n+        failed_already = 1;\n+        return;\n+      }\n+      /*\n+       * verify the data read\n+       */\n+      if (memcmp(in_buf->data, out_buf->data, bytes) != 0) {\n+        fprintf(stderr, \"prsocket_test: ERROR - data corruption\\n\");\n         failed_already = 1;\n         return;\n+      }\n     }\n-    netaddr = cp->server_addr;\n-\n-    for (i = 0; i < num_tcp_connections_per_client; i++) {\n-        if ((sockfd = PR_OpenTCPSocket(client_domain)) == NULL) {\n-            fprintf(stderr, \"prsocket_test: PR_OpenTCPSocket failed\\n\");\n-            failed_already = 1;\n-            return;\n-        }\n-        if (PR_Connect(sockfd, &netaddr, PR_INTERVAL_NO_TIMEOUT) < 0) {\n-            fprintf(stderr, \"PR_Connect failed: (%ld, %ld)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            failed_already = 1;\n-            return;\n-        }\n-        for (j = 0; j < num_tcp_mesgs_per_connection; j++) {\n-            /*\n-             * fill in random data\n-             */\n-            memset(out_buf->data, ((PRInt32)(&netaddr)) + i + j, bytes);\n-            /*\n-             * write to server\n-             */\n-#ifdef WINNT\n-            if (test_cancelio && (j == 0)) {\n-                PR_Sleep(PR_SecondsToInterval(12));\n-            }\n-#endif\n-            if (writen(sockfd, out_buf->data, bytes) < bytes) {\n-                fprintf(stderr, \"prsocket_test: ERROR - TCP_Client:writen\\n\");\n-                failed_already = 1;\n-                return;\n-            }\n-            DPRINTF((\"TCP Client [0x%lx]: out_buf = 0x%lx out_buf[0] = 0x%lx\\n\",\n-                     PR_GetCurrentThread(), out_buf, (*((int*)out_buf->data))));\n-            if (readn(sockfd, in_buf->data, bytes) < bytes) {\n-                fprintf(stderr, \"prsocket_test: ERROR - TCP_Client:readn\\n\");\n-                failed_already = 1;\n-                return;\n-            }\n-            /*\n-             * verify the data read\n-             */\n-            if (memcmp(in_buf->data, out_buf->data, bytes) != 0) {\n-                fprintf(stderr, \"prsocket_test: ERROR - data corruption\\n\");\n-                failed_already = 1;\n-                return;\n-            }\n-        }\n-        /*\n-         * shutdown reads and writes\n-         */\n-        if (PR_Shutdown(sockfd, PR_SHUTDOWN_BOTH) < 0) {\n-            fprintf(stderr, \"prsocket_test: ERROR - PR_Shutdown\\n\");\n-            failed_already = 1;\n-        }\n-        PR_Close(sockfd);\n+    /*\n+     * shutdown reads and writes\n+     */\n+    if (PR_Shutdown(sockfd, PR_SHUTDOWN_BOTH) < 0) {\n+      fprintf(stderr, \"prsocket_test: ERROR - PR_Shutdown\\n\");\n+      failed_already = 1;\n     }\n+    PR_Close(sockfd);\n+  }\n \n-    PR_DELETE(out_buf);\n-    PR_DELETE(in_buf);\n+  PR_DELETE(out_buf);\n+  PR_DELETE(in_buf);\n \n-    /*\n-     * Decrement exit_counter and notify parent thread\n-     */\n+  /*\n+   * Decrement exit_counter and notify parent thread\n+   */\n \n-    PR_EnterMonitor(cp->exit_mon);\n-    --(*cp->exit_counter);\n-    PR_Notify(cp->exit_mon);\n-    PR_ExitMonitor(cp->exit_mon);\n-    DPRINTF((\"TCP_Client [0x%x] exiting\\n\", PR_GetCurrentThread()));\n+  PR_EnterMonitor(cp->exit_mon);\n+  --(*cp->exit_counter);\n+  PR_Notify(cp->exit_mon);\n+  PR_ExitMonitor(cp->exit_mon);\n+  DPRINTF((\"TCP_Client [0x%x] exiting\\n\", PR_GetCurrentThread()));\n }\n \n /*\n@@ -717,124 +699,122 @@ TCP_Client(void* arg)\n  *    for data corruption.\n  *    Close the socket\n  */\n-static void PR_CALLBACK\n-UDP_Client(void* arg)\n-{\n-    Client_Param* cp = (Client_Param*)arg;\n-    PRFileDesc* sockfd;\n-    buffer *in_buf, *out_buf;\n-    union PRNetAddr netaddr;\n-    PRInt32 bytes, i, rv;\n-\n-    bytes = cp->datalen;\n-    out_buf = PR_NEW(buffer);\n-    if (out_buf == NULL) {\n-        fprintf(stderr, \"prsocket_test: failed to alloc buffer struct\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    in_buf = PR_NEW(buffer);\n-    if (in_buf == NULL) {\n-        fprintf(stderr, \"prsocket_test: failed to alloc buffer struct\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if ((sockfd = PR_OpenUDPSocket(client_domain)) == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_OpenUDPSocket failed\\n\");\n-        failed_already = 1;\n-        return;\n+static void PR_CALLBACK UDP_Client(void* arg) {\n+  Client_Param* cp = (Client_Param*)arg;\n+  PRFileDesc* sockfd;\n+  buffer *in_buf, *out_buf;\n+  union PRNetAddr netaddr;\n+  PRInt32 bytes, i, rv;\n+\n+  bytes = cp->datalen;\n+  out_buf = PR_NEW(buffer);\n+  if (out_buf == NULL) {\n+    fprintf(stderr, \"prsocket_test: failed to alloc buffer struct\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  in_buf = PR_NEW(buffer);\n+  if (in_buf == NULL) {\n+    fprintf(stderr, \"prsocket_test: failed to alloc buffer struct\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if ((sockfd = PR_OpenUDPSocket(client_domain)) == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_OpenUDPSocket failed\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+\n+  /*\n+   * bind an address for the client, let the system chose the port\n+   * number\n+   */\n+  memset(&netaddr, 0, sizeof(netaddr));\n+  if (PR_SetNetAddr(PR_IpAddrAny, client_domain, 0, &netaddr) == PR_FAILURE) {\n+    fprintf(stderr, \"prsocket_test: PR_SetNetAddr failed\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if (PR_Bind(sockfd, &netaddr) < 0) {\n+    fprintf(stderr, \"prsocket_test: ERROR - PR_Bind failed\\n\");\n+    perror(\"PR_Bind\");\n+    return;\n+  }\n+\n+  if (PR_GetSockName(sockfd, &netaddr) < 0) {\n+    fprintf(stderr, \"prsocket_test: ERROR - PR_GetSockName failed\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+\n+  DPRINTF(\n+      (\"PR_Bind: UDP Client netaddr.inet.ip = 0x%lx, netaddr.inet.port = %d\\n\",\n+       netaddr.inet.ip, netaddr.inet.port));\n+\n+  netaddr = cp->server_addr;\n+\n+  if (cp->udp_connect) {\n+    if (PR_Connect(sockfd, &netaddr, PR_INTERVAL_NO_TIMEOUT) < 0) {\n+      fprintf(stderr, \"prsocket_test: PR_Connect failed\\n\");\n+      failed_already = 1;\n+      return;\n     }\n+  }\n \n+  for (i = 0; i < num_udp_datagrams_per_client; i++) {\n     /*\n-     * bind an address for the client, let the system chose the port\n-     * number\n+     * fill in random data\n      */\n-    memset(&netaddr, 0, sizeof(netaddr));\n-    if (PR_SetNetAddr(PR_IpAddrAny, client_domain, 0, &netaddr) == PR_FAILURE) {\n-        fprintf(stderr, \"prsocket_test: PR_SetNetAddr failed\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if (PR_Bind(sockfd, &netaddr) < 0) {\n-        fprintf(stderr, \"prsocket_test: ERROR - PR_Bind failed\\n\");\n-        perror(\"PR_Bind\");\n-        return;\n-    }\n-\n-    if (PR_GetSockName(sockfd, &netaddr) < 0) {\n-        fprintf(stderr, \"prsocket_test: ERROR - PR_GetSockName failed\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-\n-    DPRINTF(\n-        (\"PR_Bind: UDP Client netaddr.inet.ip = 0x%lx, netaddr.inet.port = %d\\n\",\n-         netaddr.inet.ip, netaddr.inet.port));\n-\n-    netaddr = cp->server_addr;\n-\n-    if (cp->udp_connect) {\n-        if (PR_Connect(sockfd, &netaddr, PR_INTERVAL_NO_TIMEOUT) < 0) {\n-            fprintf(stderr, \"prsocket_test: PR_Connect failed\\n\");\n-            failed_already = 1;\n-            return;\n-        }\n+    DPRINTF((\"UDP_Client [0x%lx]: out_buf = 0x%lx bytes = 0x%lx\\n\",\n+             PR_GetCurrentThread(), out_buf->data, bytes));\n+    memset(out_buf->data, ((PRInt32)(&netaddr)) + i, bytes);\n+    /*\n+     * write to server\n+     */\n+    if (cp->udp_connect)\n+      rv = PR_Send(sockfd, out_buf->data, bytes, 0, PR_INTERVAL_NO_TIMEOUT);\n+    else\n+      rv = PR_SendTo(sockfd, out_buf->data, bytes, 0, &netaddr,\n+                     PR_INTERVAL_NO_TIMEOUT);\n+    if (rv != bytes) {\n+      return;\n+    }\n+    DPRINTF((\"UDP_Client [0x%lx]: out_buf = 0x%lx out_buf[0] = 0x%lx\\n\",\n+             PR_GetCurrentThread(), out_buf, (*((int*)out_buf->data))));\n+    if (cp->udp_connect)\n+      rv = PR_Recv(sockfd, in_buf->data, bytes, 0, PR_INTERVAL_NO_TIMEOUT);\n+    else\n+      rv = PR_RecvFrom(sockfd, in_buf->data, bytes, 0, &netaddr,\n+                       PR_INTERVAL_NO_TIMEOUT);\n+    if (rv != bytes) {\n+      return;\n     }\n-\n-    for (i = 0; i < num_udp_datagrams_per_client; i++) {\n-        /*\n-         * fill in random data\n-         */\n-        DPRINTF((\"UDP_Client [0x%lx]: out_buf = 0x%lx bytes = 0x%lx\\n\",\n-                 PR_GetCurrentThread(), out_buf->data, bytes));\n-        memset(out_buf->data, ((PRInt32)(&netaddr)) + i, bytes);\n-        /*\n-         * write to server\n-         */\n-        if (cp->udp_connect)\n-            rv = PR_Send(sockfd, out_buf->data, bytes, 0, PR_INTERVAL_NO_TIMEOUT);\n-        else\n-            rv = PR_SendTo(sockfd, out_buf->data, bytes, 0, &netaddr,\n-                           PR_INTERVAL_NO_TIMEOUT);\n-        if (rv != bytes) {\n-            return;\n-        }\n-        DPRINTF((\"UDP_Client [0x%lx]: out_buf = 0x%lx out_buf[0] = 0x%lx\\n\",\n-                 PR_GetCurrentThread(), out_buf, (*((int*)out_buf->data))));\n-        if (cp->udp_connect)\n-            rv = PR_Recv(sockfd, in_buf->data, bytes, 0, PR_INTERVAL_NO_TIMEOUT);\n-        else\n-            rv = PR_RecvFrom(sockfd, in_buf->data, bytes, 0, &netaddr,\n-                             PR_INTERVAL_NO_TIMEOUT);\n-        if (rv != bytes) {\n-            return;\n-        }\n-        DPRINTF((\"UDP_Client [0x%lx]: in_buf = 0x%lx in_buf[0] = 0x%lx\\n\",\n-                 PR_GetCurrentThread(), in_buf, (*((int*)in_buf->data))));\n-        /*\n-         * verify the data read\n-         */\n-        if (memcmp(in_buf->data, out_buf->data, bytes) != 0) {\n-            fprintf(stderr, \"prsocket_test: ERROR - UDP data corruption\\n\");\n-            failed_already = 1;\n-            return;\n-        }\n+    DPRINTF((\"UDP_Client [0x%lx]: in_buf = 0x%lx in_buf[0] = 0x%lx\\n\",\n+             PR_GetCurrentThread(), in_buf, (*((int*)in_buf->data))));\n+    /*\n+     * verify the data read\n+     */\n+    if (memcmp(in_buf->data, out_buf->data, bytes) != 0) {\n+      fprintf(stderr, \"prsocket_test: ERROR - UDP data corruption\\n\");\n+      failed_already = 1;\n+      return;\n     }\n-    PR_Close(sockfd);\n+  }\n+  PR_Close(sockfd);\n \n-    PR_DELETE(in_buf);\n-    PR_DELETE(out_buf);\n+  PR_DELETE(in_buf);\n+  PR_DELETE(out_buf);\n \n-    /*\n-     * Decrement exit_counter and notify parent thread\n-     */\n+  /*\n+   * Decrement exit_counter and notify parent thread\n+   */\n \n-    PR_EnterMonitor(cp->exit_mon);\n-    --(*cp->exit_counter);\n-    PR_Notify(cp->exit_mon);\n-    PR_ExitMonitor(cp->exit_mon);\n-    PR_DELETE(cp);\n-    DPRINTF((\"UDP_Client [0x%x] exiting\\n\", PR_GetCurrentThread()));\n+  PR_EnterMonitor(cp->exit_mon);\n+  --(*cp->exit_counter);\n+  PR_Notify(cp->exit_mon);\n+  PR_ExitMonitor(cp->exit_mon);\n+  PR_DELETE(cp);\n+  DPRINTF((\"UDP_Client [0x%x] exiting\\n\", PR_GetCurrentThread()));\n }\n \n /*\n@@ -849,101 +829,99 @@ UDP_Client(void* arg)\n  *\n  */\n \n-static PRInt32\n-TCP_Socket_Client_Server_Test(void)\n-{\n-    int i;\n-    PRThread* t;\n-    PRSemaphore* server_sem;\n-    Server_Param* sparamp;\n-    Client_Param* cparamp;\n-    PRMonitor* mon2;\n-    PRInt32 datalen;\n-\n-    datalen = tcp_mesg_size;\n-    thread_count = 0;\n-    /*\n-     * start the server thread\n-     */\n-    sparamp = PR_NEW(Server_Param);\n-    if (sparamp == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n-        failed_already = 1;\n-        return -1;\n-    }\n-    server_sem = PR_NewSem(0);\n-    if (server_sem == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NewSem failed\\n\");\n-        failed_already = 1;\n-        return -1;\n-    }\n-    mon2 = PR_NewMonitor();\n-    if (mon2 == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NewMonitor failed\\n\");\n-        failed_already = 1;\n-        return -1;\n-    }\n-    PR_EnterMonitor(mon2);\n-\n-    sparamp->addr_sem = server_sem;\n-    sparamp->exit_mon = mon2;\n-    sparamp->exit_counter = &thread_count;\n-    sparamp->datalen = datalen;\n-    t = PR_CreateThread(PR_USER_THREAD, TCP_Server, (void*)sparamp,\n-                        PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD,\n-                        0);\n+static PRInt32 TCP_Socket_Client_Server_Test(void) {\n+  int i;\n+  PRThread* t;\n+  PRSemaphore* server_sem;\n+  Server_Param* sparamp;\n+  Client_Param* cparamp;\n+  PRMonitor* mon2;\n+  PRInt32 datalen;\n+\n+  datalen = tcp_mesg_size;\n+  thread_count = 0;\n+  /*\n+   * start the server thread\n+   */\n+  sparamp = PR_NEW(Server_Param);\n+  if (sparamp == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n+    failed_already = 1;\n+    return -1;\n+  }\n+  server_sem = PR_NewSem(0);\n+  if (server_sem == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NewSem failed\\n\");\n+    failed_already = 1;\n+    return -1;\n+  }\n+  mon2 = PR_NewMonitor();\n+  if (mon2 == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NewMonitor failed\\n\");\n+    failed_already = 1;\n+    return -1;\n+  }\n+  PR_EnterMonitor(mon2);\n+\n+  sparamp->addr_sem = server_sem;\n+  sparamp->exit_mon = mon2;\n+  sparamp->exit_counter = &thread_count;\n+  sparamp->datalen = datalen;\n+  t = PR_CreateThread(PR_USER_THREAD, TCP_Server, (void*)sparamp,\n+                      PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD,\n+                      0);\n+  if (t == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n+    failed_already = 1;\n+    return -1;\n+  }\n+  DPRINTF((\"Created TCP server = 0x%lx\\n\", t));\n+  thread_count++;\n+\n+  /*\n+   * wait till the server address is setup\n+   */\n+  PR_WaitSem(server_sem);\n+\n+  /*\n+   * Now start a bunch of client threads\n+   */\n+\n+  cparamp = PR_NEW(Client_Param);\n+  if (cparamp == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n+    failed_already = 1;\n+    return -1;\n+  }\n+  cparamp->server_addr = tcp_server_addr;\n+  cparamp->exit_mon = mon2;\n+  cparamp->exit_counter = &thread_count;\n+  cparamp->datalen = datalen;\n+  for (i = 0; i < num_tcp_clients; i++) {\n+    t = create_new_thread(PR_USER_THREAD, TCP_Client, (void*)cparamp,\n+                          PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n+                          PR_UNJOINABLE_THREAD, 0, i);\n     if (t == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n-        failed_already = 1;\n-        return -1;\n+      fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n+      failed_already = 1;\n+      return -1;\n     }\n-    DPRINTF((\"Created TCP server = 0x%lx\\n\", t));\n+    DPRINTF((\"Created TCP client = 0x%lx\\n\", t));\n     thread_count++;\n-\n-    /*\n-     * wait till the server address is setup\n-     */\n-    PR_WaitSem(server_sem);\n-\n-    /*\n-     * Now start a bunch of client threads\n-     */\n-\n-    cparamp = PR_NEW(Client_Param);\n-    if (cparamp == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n-        failed_already = 1;\n-        return -1;\n-    }\n-    cparamp->server_addr = tcp_server_addr;\n-    cparamp->exit_mon = mon2;\n-    cparamp->exit_counter = &thread_count;\n-    cparamp->datalen = datalen;\n-    for (i = 0; i < num_tcp_clients; i++) {\n-        t = create_new_thread(PR_USER_THREAD, TCP_Client, (void*)cparamp,\n-                              PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n-                              PR_UNJOINABLE_THREAD, 0, i);\n-        if (t == NULL) {\n-            fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n-            failed_already = 1;\n-            return -1;\n-        }\n-        DPRINTF((\"Created TCP client = 0x%lx\\n\", t));\n-        thread_count++;\n-    }\n-    /* Wait for server and client threads to exit */\n-    while (thread_count) {\n-        PR_Wait(mon2, PR_INTERVAL_NO_TIMEOUT);\n-        DPRINTF((\"TCP Server - thread_count  = %d\\n\", thread_count));\n-    }\n-    PR_ExitMonitor(mon2);\n-    printf(\"%30s\", \"TCP_Socket_Client_Server_Test:\");\n-    printf(\"%2ld Server %2ld Clients %2ld connections_per_client\\n\", 1l,\n-           num_tcp_clients, num_tcp_connections_per_client);\n-    printf(\"%30s %2ld messages_per_connection %4ld bytes_per_message\\n\", \":\",\n-           num_tcp_mesgs_per_connection, tcp_mesg_size);\n-\n-    return 0;\n+  }\n+  /* Wait for server and client threads to exit */\n+  while (thread_count) {\n+    PR_Wait(mon2, PR_INTERVAL_NO_TIMEOUT);\n+    DPRINTF((\"TCP Server - thread_count  = %d\\n\", thread_count));\n+  }\n+  PR_ExitMonitor(mon2);\n+  printf(\"%30s\", \"TCP_Socket_Client_Server_Test:\");\n+  printf(\"%2ld Server %2ld Clients %2ld connections_per_client\\n\", 1l,\n+         num_tcp_clients, num_tcp_connections_per_client);\n+  printf(\"%30s %2ld messages_per_connection %4ld bytes_per_message\\n\", \":\",\n+         num_tcp_mesgs_per_connection, tcp_mesg_size);\n+\n+  return 0;\n }\n \n /*\n@@ -958,110 +936,108 @@ TCP_Socket_Client_Server_Test(void)\n  *\n  */\n \n-static PRInt32\n-UDP_Socket_Client_Server_Test(void)\n-{\n-    int i;\n-    PRThread* t;\n-    PRSemaphore* server_sem;\n-    Server_Param* sparamp;\n-    Client_Param* cparamp;\n-    PRMonitor* mon2;\n-    PRInt32 datalen;\n-    PRInt32 udp_connect = 1;\n-\n-    datalen = udp_datagram_size;\n-    thread_count = 0;\n+static PRInt32 UDP_Socket_Client_Server_Test(void) {\n+  int i;\n+  PRThread* t;\n+  PRSemaphore* server_sem;\n+  Server_Param* sparamp;\n+  Client_Param* cparamp;\n+  PRMonitor* mon2;\n+  PRInt32 datalen;\n+  PRInt32 udp_connect = 1;\n+\n+  datalen = udp_datagram_size;\n+  thread_count = 0;\n+  /*\n+   * start the server thread\n+   */\n+  sparamp = PR_NEW(Server_Param);\n+  if (sparamp == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n+    failed_already = 1;\n+    return -1;\n+  }\n+  server_sem = PR_NewSem(0);\n+  if (server_sem == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NewSem failed\\n\");\n+    failed_already = 1;\n+    return -1;\n+  }\n+  mon2 = PR_NewMonitor();\n+  if (mon2 == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NewMonitor failed\\n\");\n+    failed_already = 1;\n+    return -1;\n+  }\n+  PR_EnterMonitor(mon2);\n+\n+  sparamp->addr_sem = server_sem;\n+  sparamp->exit_mon = mon2;\n+  sparamp->exit_counter = &thread_count;\n+  sparamp->datalen = datalen;\n+  DPRINTF((\"Creating UDP server\"));\n+  t = PR_CreateThread(PR_USER_THREAD, UDP_Server, (void*)sparamp,\n+                      PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD,\n+                      0);\n+  if (t == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n+    failed_already = 1;\n+    return -1;\n+  }\n+  thread_count++;\n+\n+  /*\n+   * wait till the server address is setup\n+   */\n+  PR_WaitSem(server_sem);\n+\n+  /*\n+   * Now start a bunch of client threads\n+   */\n+\n+  for (i = 0; i < num_udp_clients; i++) {\n+    cparamp = PR_NEW(Client_Param);\n+    if (cparamp == NULL) {\n+      fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n+      failed_already = 1;\n+      return -1;\n+    }\n+    cparamp->server_addr = udp_server_addr;\n+    cparamp->exit_mon = mon2;\n+    cparamp->exit_counter = &thread_count;\n+    cparamp->datalen = datalen;\n     /*\n-     * start the server thread\n+     * Cause every other client thread to connect udp sockets\n      */\n-    sparamp = PR_NEW(Server_Param);\n-    if (sparamp == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n-        failed_already = 1;\n-        return -1;\n-    }\n-    server_sem = PR_NewSem(0);\n-    if (server_sem == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NewSem failed\\n\");\n-        failed_already = 1;\n-        return -1;\n-    }\n-    mon2 = PR_NewMonitor();\n-    if (mon2 == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NewMonitor failed\\n\");\n-        failed_already = 1;\n-        return -1;\n+    cparamp->udp_connect = udp_connect;\n+    if (udp_connect) {\n+      udp_connect = 0;\n+    } else {\n+      udp_connect = 1;\n     }\n-    PR_EnterMonitor(mon2);\n-\n-    sparamp->addr_sem = server_sem;\n-    sparamp->exit_mon = mon2;\n-    sparamp->exit_counter = &thread_count;\n-    sparamp->datalen = datalen;\n-    DPRINTF((\"Creating UDP server\"));\n-    t = PR_CreateThread(PR_USER_THREAD, UDP_Server, (void*)sparamp,\n-                        PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD,\n-                        0);\n+    DPRINTF((\"Creating UDP client %d\\n\", i));\n+    t = PR_CreateThread(PR_USER_THREAD, UDP_Client, (void*)cparamp,\n+                        PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n+                        PR_UNJOINABLE_THREAD, 0);\n     if (t == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n-        failed_already = 1;\n-        return -1;\n+      fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n+      failed_already = 1;\n+      return -1;\n     }\n     thread_count++;\n-\n-    /*\n-     * wait till the server address is setup\n-     */\n-    PR_WaitSem(server_sem);\n-\n-    /*\n-     * Now start a bunch of client threads\n-     */\n-\n-    for (i = 0; i < num_udp_clients; i++) {\n-        cparamp = PR_NEW(Client_Param);\n-        if (cparamp == NULL) {\n-            fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n-            failed_already = 1;\n-            return -1;\n-        }\n-        cparamp->server_addr = udp_server_addr;\n-        cparamp->exit_mon = mon2;\n-        cparamp->exit_counter = &thread_count;\n-        cparamp->datalen = datalen;\n-        /*\n-         * Cause every other client thread to connect udp sockets\n-         */\n-        cparamp->udp_connect = udp_connect;\n-        if (udp_connect) {\n-            udp_connect = 0;\n-        } else {\n-            udp_connect = 1;\n-        }\n-        DPRINTF((\"Creating UDP client %d\\n\", i));\n-        t = PR_CreateThread(PR_USER_THREAD, UDP_Client, (void*)cparamp,\n-                            PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n-                            PR_UNJOINABLE_THREAD, 0);\n-        if (t == NULL) {\n-            fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n-            failed_already = 1;\n-            return -1;\n-        }\n-        thread_count++;\n-    }\n-    /* Wait for server and client threads to exit */\n-    while (thread_count) {\n-        PR_Wait(mon2, PR_INTERVAL_NO_TIMEOUT);\n-        DPRINTF((\"UDP Server - thread_count  = %d\\n\", thread_count));\n-    }\n-    PR_ExitMonitor(mon2);\n-    printf(\"%30s\", \"UDP_Socket_Client_Server_Test: \");\n-    printf(\"%2ld Server %2ld Clients\\n\", 1l, num_udp_clients);\n-    printf(\"%30s %2ld datagrams_per_client %4ld bytes_per_datagram\\n\", \":\",\n-           num_udp_datagrams_per_client, udp_datagram_size);\n-\n-    return 0;\n+  }\n+  /* Wait for server and client threads to exit */\n+  while (thread_count) {\n+    PR_Wait(mon2, PR_INTERVAL_NO_TIMEOUT);\n+    DPRINTF((\"UDP Server - thread_count  = %d\\n\", thread_count));\n+  }\n+  PR_ExitMonitor(mon2);\n+  printf(\"%30s\", \"UDP_Socket_Client_Server_Test: \");\n+  printf(\"%2ld Server %2ld Clients\\n\", 1l, num_udp_clients);\n+  printf(\"%30s %2ld datagrams_per_client %4ld bytes_per_datagram\\n\", \":\",\n+         num_udp_datagrams_per_client, udp_datagram_size);\n+\n+  return 0;\n }\n \n static PRFileDesc *small_file_fd, *large_file_fd;\n@@ -1071,235 +1047,233 @@ static void *small_file_trailer, *large_file_header, *large_file_trailer;\n  * TransmitFile_Client\n  *    Client Thread\n  */\n-static void\n-TransmitFile_Client(void* arg)\n-{\n-    PRFileDesc* sockfd;\n-    union PRNetAddr netaddr;\n-    char *small_buf, *large_buf;\n-    Client_Param* cp = (Client_Param*)arg;\n-    PRInt32 rlen;\n-\n-    small_buf = (char*)PR_Malloc(SMALL_FILE_SIZE + SMALL_FILE_HEADER_SIZE +\n-                                 SMALL_FILE_TRAILER_SIZE);\n-    if (small_buf == NULL) {\n-        fprintf(stderr, \"prsocket_test: failed to alloc buffer\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    large_buf = (char*)PR_Malloc(LARGE_FILE_SIZE + LARGE_FILE_HEADER_SIZE +\n-                                 LARGE_FILE_TRAILER_SIZE);\n-    if (large_buf == NULL) {\n-        fprintf(stderr, \"prsocket_test: failed to alloc buffer\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    netaddr.inet.family = cp->server_addr.inet.family;\n-    netaddr.inet.port = cp->server_addr.inet.port;\n-    netaddr.inet.ip = cp->server_addr.inet.ip;\n-\n-    if ((sockfd = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NewTCPSocket failed\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+static void TransmitFile_Client(void* arg) {\n+  PRFileDesc* sockfd;\n+  union PRNetAddr netaddr;\n+  char *small_buf, *large_buf;\n+  Client_Param* cp = (Client_Param*)arg;\n+  PRInt32 rlen;\n+\n+  small_buf = (char*)PR_Malloc(SMALL_FILE_SIZE + SMALL_FILE_HEADER_SIZE +\n+                               SMALL_FILE_TRAILER_SIZE);\n+  if (small_buf == NULL) {\n+    fprintf(stderr, \"prsocket_test: failed to alloc buffer\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  large_buf = (char*)PR_Malloc(LARGE_FILE_SIZE + LARGE_FILE_HEADER_SIZE +\n+                               LARGE_FILE_TRAILER_SIZE);\n+  if (large_buf == NULL) {\n+    fprintf(stderr, \"prsocket_test: failed to alloc buffer\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  netaddr.inet.family = cp->server_addr.inet.family;\n+  netaddr.inet.port = cp->server_addr.inet.port;\n+  netaddr.inet.ip = cp->server_addr.inet.ip;\n+\n+  if ((sockfd = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NewTCPSocket failed\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+\n+  if (PR_Connect(sockfd, &netaddr, PR_INTERVAL_NO_TIMEOUT) < 0) {\n+    fprintf(stderr, \"prsocket_test: PR_Connect failed\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  /*\n+   * read the small file and verify the data\n+   */\n+  if (readn(sockfd, small_buf, SMALL_FILE_SIZE + SMALL_FILE_HEADER_SIZE) !=\n+      (SMALL_FILE_SIZE + SMALL_FILE_HEADER_SIZE)) {\n+    fprintf(stderr,\n+            \"prsocket_test: TransmitFile_Client failed to receive file\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+#if defined(XP_UNIX)\n+  /* File transmission test can not be done because of large file's size */\n+  if (memcmp(small_file_header, small_buf, SMALL_FILE_HEADER_SIZE) != 0) {\n+    fprintf(stderr,\n+            \"prsocket_test: TransmitFile_Client ERROR - small file header data \"\n+            \"corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if (memcmp(small_file_addr, small_buf + SMALL_FILE_HEADER_SIZE,\n+             SMALL_FILE_SIZE) != 0) {\n+    fprintf(stderr,\n+            \"prsocket_test: TransmitFile_Client ERROR - small file data \"\n+            \"corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+#endif\n+  /*\n+   * read the large file and verify the data\n+   */\n+  if (readn(sockfd, large_buf, LARGE_FILE_SIZE) != LARGE_FILE_SIZE) {\n+    fprintf(stderr,\n+            \"prsocket_test: TransmitFile_Client failed to receive file\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+#if defined(XP_UNIX)\n+  if (memcmp(large_file_addr, large_buf, LARGE_FILE_SIZE) != 0) {\n+    fprintf(stderr,\n+            \"prsocket_test: TransmitFile_Client ERROR - large file data \"\n+            \"corruption\\n\");\n+    failed_already = 1;\n+  }\n+#endif\n \n-    if (PR_Connect(sockfd, &netaddr, PR_INTERVAL_NO_TIMEOUT) < 0) {\n-        fprintf(stderr, \"prsocket_test: PR_Connect failed\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    /*\n-     * read the small file and verify the data\n-     */\n-    if (readn(sockfd, small_buf, SMALL_FILE_SIZE + SMALL_FILE_HEADER_SIZE) !=\n-        (SMALL_FILE_SIZE + SMALL_FILE_HEADER_SIZE)) {\n-        fprintf(stderr,\n-                \"prsocket_test: TransmitFile_Client failed to receive file\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  /*\n+   * receive data from PR_SendFile\n+   */\n+  /*\n+   * case 1: small file with header and trailer\n+   */\n+  rlen = SMALL_FILE_SIZE + SMALL_FILE_HEADER_SIZE + SMALL_FILE_TRAILER_SIZE;\n+  if (readn(sockfd, small_buf, rlen) != rlen) {\n+    fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #if defined(XP_UNIX)\n-    /* File transmission test can not be done because of large file's size */\n-    if (memcmp(small_file_header, small_buf, SMALL_FILE_HEADER_SIZE) != 0) {\n-        fprintf(stderr,\n-                \"prsocket_test: TransmitFile_Client ERROR - small file header data \"\n-                \"corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if (memcmp(small_file_addr, small_buf + SMALL_FILE_HEADER_SIZE,\n-               SMALL_FILE_SIZE) != 0) {\n-        fprintf(stderr,\n-                \"prsocket_test: TransmitFile_Client ERROR - small file data \"\n-                \"corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  if (memcmp(small_file_header, small_buf, SMALL_FILE_HEADER_SIZE) != 0) {\n+    fprintf(stderr, \"SendFile 1. ERROR - small file header corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if (memcmp(small_file_addr, small_buf + SMALL_FILE_HEADER_SIZE,\n+             SMALL_FILE_SIZE) != 0) {\n+    fprintf(stderr, \"SendFile 1. ERROR - small file data corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if (memcmp(small_file_trailer,\n+             small_buf + SMALL_FILE_HEADER_SIZE + SMALL_FILE_SIZE,\n+             SMALL_FILE_TRAILER_SIZE) != 0) {\n+    fprintf(stderr, \"SendFile 1. ERROR - small file trailer corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #endif\n-    /*\n-     * read the large file and verify the data\n-     */\n-    if (readn(sockfd, large_buf, LARGE_FILE_SIZE) != LARGE_FILE_SIZE) {\n-        fprintf(stderr,\n-                \"prsocket_test: TransmitFile_Client failed to receive file\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  /*\n+   * case 2: partial large file at zero offset, file with header and trailer\n+   */\n+  rlen = LARGE_FILE_LEN_1 + LARGE_FILE_HEADER_SIZE + LARGE_FILE_TRAILER_SIZE;\n+  if (readn(sockfd, large_buf, rlen) != rlen) {\n+    fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #if defined(XP_UNIX)\n-    if (memcmp(large_file_addr, large_buf, LARGE_FILE_SIZE) != 0) {\n-        fprintf(stderr,\n-                \"prsocket_test: TransmitFile_Client ERROR - large file data \"\n-                \"corruption\\n\");\n-        failed_already = 1;\n-    }\n-#endif\n-\n-    /*\n-     * receive data from PR_SendFile\n-     */\n-    /*\n-     * case 1: small file with header and trailer\n-     */\n-    rlen = SMALL_FILE_SIZE + SMALL_FILE_HEADER_SIZE + SMALL_FILE_TRAILER_SIZE;\n-    if (readn(sockfd, small_buf, rlen) != rlen) {\n-        fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-#if defined(XP_UNIX)\n-    if (memcmp(small_file_header, small_buf, SMALL_FILE_HEADER_SIZE) != 0) {\n-        fprintf(stderr, \"SendFile 1. ERROR - small file header corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if (memcmp(small_file_addr, small_buf + SMALL_FILE_HEADER_SIZE,\n-               SMALL_FILE_SIZE) != 0) {\n-        fprintf(stderr, \"SendFile 1. ERROR - small file data corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if (memcmp(small_file_trailer,\n-               small_buf + SMALL_FILE_HEADER_SIZE + SMALL_FILE_SIZE,\n-               SMALL_FILE_TRAILER_SIZE) != 0) {\n-        fprintf(stderr, \"SendFile 1. ERROR - small file trailer corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-#endif\n-    /*\n-     * case 2: partial large file at zero offset, file with header and trailer\n-     */\n-    rlen = LARGE_FILE_LEN_1 + LARGE_FILE_HEADER_SIZE + LARGE_FILE_TRAILER_SIZE;\n-    if (readn(sockfd, large_buf, rlen) != rlen) {\n-        fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-#if defined(XP_UNIX)\n-    if (memcmp(large_file_header, large_buf, LARGE_FILE_HEADER_SIZE) != 0) {\n-        fprintf(stderr, \"SendFile 2. ERROR - large file header corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if (memcmp(large_file_addr, large_buf + LARGE_FILE_HEADER_SIZE,\n-               LARGE_FILE_LEN_1) != 0) {\n-        fprintf(stderr, \"SendFile 2. ERROR - large file data corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if (memcmp(large_file_trailer,\n-               large_buf + LARGE_FILE_HEADER_SIZE + LARGE_FILE_LEN_1,\n-               LARGE_FILE_TRAILER_SIZE) != 0) {\n-        fprintf(stderr, \"SendFile 2. ERROR - large file trailer corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  if (memcmp(large_file_header, large_buf, LARGE_FILE_HEADER_SIZE) != 0) {\n+    fprintf(stderr, \"SendFile 2. ERROR - large file header corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if (memcmp(large_file_addr, large_buf + LARGE_FILE_HEADER_SIZE,\n+             LARGE_FILE_LEN_1) != 0) {\n+    fprintf(stderr, \"SendFile 2. ERROR - large file data corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if (memcmp(large_file_trailer,\n+             large_buf + LARGE_FILE_HEADER_SIZE + LARGE_FILE_LEN_1,\n+             LARGE_FILE_TRAILER_SIZE) != 0) {\n+    fprintf(stderr, \"SendFile 2. ERROR - large file trailer corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #endif\n-    /*\n-     * case 3: partial small file at non-zero offset, with header\n-     */\n-    rlen = SMALL_FILE_LEN_1 + SMALL_FILE_HEADER_SIZE;\n-    if (readn(sockfd, small_buf, rlen) != rlen) {\n-        fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  /*\n+   * case 3: partial small file at non-zero offset, with header\n+   */\n+  rlen = SMALL_FILE_LEN_1 + SMALL_FILE_HEADER_SIZE;\n+  if (readn(sockfd, small_buf, rlen) != rlen) {\n+    fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #if defined(XP_UNIX)\n-    if (memcmp(small_file_header, small_buf, SMALL_FILE_HEADER_SIZE) != 0) {\n-        fprintf(stderr, \"SendFile 3. ERROR - small file header corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if (memcmp((char*)small_file_addr + SMALL_FILE_OFFSET_1,\n-               small_buf + SMALL_FILE_HEADER_SIZE, SMALL_FILE_LEN_1) != 0) {\n-        fprintf(stderr, \"SendFile 3. ERROR - small file data corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  if (memcmp(small_file_header, small_buf, SMALL_FILE_HEADER_SIZE) != 0) {\n+    fprintf(stderr, \"SendFile 3. ERROR - small file header corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if (memcmp((char*)small_file_addr + SMALL_FILE_OFFSET_1,\n+             small_buf + SMALL_FILE_HEADER_SIZE, SMALL_FILE_LEN_1) != 0) {\n+    fprintf(stderr, \"SendFile 3. ERROR - small file data corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #endif\n-    /*\n-     * case 4: partial small file at non-zero offset, with trailer\n-     */\n-    rlen = SMALL_FILE_LEN_2 + SMALL_FILE_TRAILER_SIZE;\n-    if (readn(sockfd, small_buf, rlen) != rlen) {\n-        fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  /*\n+   * case 4: partial small file at non-zero offset, with trailer\n+   */\n+  rlen = SMALL_FILE_LEN_2 + SMALL_FILE_TRAILER_SIZE;\n+  if (readn(sockfd, small_buf, rlen) != rlen) {\n+    fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #if defined(XP_UNIX)\n-    if (memcmp((char*)small_file_addr + SMALL_FILE_OFFSET_2, small_buf,\n-               SMALL_FILE_LEN_2) != 0) {\n-        fprintf(stderr, \"SendFile 4. ERROR - small file data corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if (memcmp(small_file_trailer, small_buf + SMALL_FILE_LEN_2,\n-               SMALL_FILE_TRAILER_SIZE) != 0) {\n-        fprintf(stderr, \"SendFile 4. ERROR - small file trailer corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  if (memcmp((char*)small_file_addr + SMALL_FILE_OFFSET_2, small_buf,\n+             SMALL_FILE_LEN_2) != 0) {\n+    fprintf(stderr, \"SendFile 4. ERROR - small file data corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if (memcmp(small_file_trailer, small_buf + SMALL_FILE_LEN_2,\n+             SMALL_FILE_TRAILER_SIZE) != 0) {\n+    fprintf(stderr, \"SendFile 4. ERROR - small file trailer corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #endif\n-    /*\n-     * case 5: partial large file at non-zero offset, file with header\n-     */\n-    rlen = LARGE_FILE_LEN_2 + LARGE_FILE_HEADER_SIZE;\n-    if (readn(sockfd, large_buf, rlen) != rlen) {\n-        fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  /*\n+   * case 5: partial large file at non-zero offset, file with header\n+   */\n+  rlen = LARGE_FILE_LEN_2 + LARGE_FILE_HEADER_SIZE;\n+  if (readn(sockfd, large_buf, rlen) != rlen) {\n+    fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #if defined(XP_UNIX)\n-    if (memcmp(large_file_header, large_buf, LARGE_FILE_HEADER_SIZE) != 0) {\n-        fprintf(stderr, \"SendFile 5. ERROR - large file header corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if (memcmp((char*)large_file_addr + LARGE_FILE_OFFSET_2,\n-               large_buf + LARGE_FILE_HEADER_SIZE, LARGE_FILE_LEN_2) != 0) {\n-        fprintf(stderr, \"SendFile 5. ERROR - large file data corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  if (memcmp(large_file_header, large_buf, LARGE_FILE_HEADER_SIZE) != 0) {\n+    fprintf(stderr, \"SendFile 5. ERROR - large file header corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if (memcmp((char*)large_file_addr + LARGE_FILE_OFFSET_2,\n+             large_buf + LARGE_FILE_HEADER_SIZE, LARGE_FILE_LEN_2) != 0) {\n+    fprintf(stderr, \"SendFile 5. ERROR - large file data corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #endif\n-    /*\n-     * case 6: partial small file at non-zero offset, with header\n-     */\n-    rlen = SMALL_FILE_LEN_3 + SMALL_FILE_HEADER_SIZE;\n-    if (readn(sockfd, small_buf, rlen) != rlen) {\n-        fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  /*\n+   * case 6: partial small file at non-zero offset, with header\n+   */\n+  rlen = SMALL_FILE_LEN_3 + SMALL_FILE_HEADER_SIZE;\n+  if (readn(sockfd, small_buf, rlen) != rlen) {\n+    fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #if defined(XP_UNIX)\n-    if (memcmp(small_file_header, small_buf, SMALL_FILE_HEADER_SIZE) != 0) {\n-        fprintf(stderr, \"SendFile 6. ERROR - small file header corruption\\n\");\n-        return;\n-    }\n-    if (memcmp((char*)small_file_addr + SMALL_FILE_OFFSET_3,\n-               small_buf + SMALL_FILE_HEADER_SIZE, SMALL_FILE_LEN_3) != 0) {\n-#if 0\n+  if (memcmp(small_file_header, small_buf, SMALL_FILE_HEADER_SIZE) != 0) {\n+    fprintf(stderr, \"SendFile 6. ERROR - small file header corruption\\n\");\n+    return;\n+  }\n+  if (memcmp((char*)small_file_addr + SMALL_FILE_OFFSET_3,\n+             small_buf + SMALL_FILE_HEADER_SIZE, SMALL_FILE_LEN_3) != 0) {\n+#  if 0\n         char *i, *j;\n         int k;\n \n@@ -1312,77 +1286,77 @@ TransmitFile_Client(void* arg)\n                        (int) (i - ((char *) small_file_addr + SMALL_FILE_OFFSET_3)),\n                        (int) (j - (small_buf + SMALL_FILE_HEADER_SIZE)));\n         }\n+#  endif\n+    fprintf(stderr, \"SendFile 6. ERROR - small file data corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #endif\n-        fprintf(stderr, \"SendFile 6. ERROR - small file data corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-#endif\n-    /*\n-     * case 7: partial large file at non-zero offset, with header\n-     */\n-    rlen = LARGE_FILE_LEN_3 + LARGE_FILE_HEADER_SIZE;\n-    if (readn(sockfd, large_buf, rlen) != rlen) {\n-        fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  /*\n+   * case 7: partial large file at non-zero offset, with header\n+   */\n+  rlen = LARGE_FILE_LEN_3 + LARGE_FILE_HEADER_SIZE;\n+  if (readn(sockfd, large_buf, rlen) != rlen) {\n+    fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #if defined(XP_UNIX)\n-    if (memcmp(large_file_header, large_buf, LARGE_FILE_HEADER_SIZE) != 0) {\n-        fprintf(stderr, \"SendFile 7. ERROR - large file header corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if (memcmp((char*)large_file_addr + LARGE_FILE_OFFSET_3,\n-               large_buf + LARGE_FILE_HEADER_SIZE, LARGE_FILE_LEN_3) != 0) {\n-        fprintf(stderr, \"SendFile 7. ERROR - large file data corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  if (memcmp(large_file_header, large_buf, LARGE_FILE_HEADER_SIZE) != 0) {\n+    fprintf(stderr, \"SendFile 7. ERROR - large file header corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if (memcmp((char*)large_file_addr + LARGE_FILE_OFFSET_3,\n+             large_buf + LARGE_FILE_HEADER_SIZE, LARGE_FILE_LEN_3) != 0) {\n+    fprintf(stderr, \"SendFile 7. ERROR - large file data corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #endif\n-    /*\n-     * case 8: partial large file at non-zero, page-aligned offset, with\n-     * header and trailer\n-     */\n-    rlen = LARGE_FILE_LEN_4 + LARGE_FILE_HEADER_SIZE + LARGE_FILE_TRAILER_SIZE;\n-    if (readn(sockfd, large_buf, rlen) != rlen) {\n-        fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  /*\n+   * case 8: partial large file at non-zero, page-aligned offset, with\n+   * header and trailer\n+   */\n+  rlen = LARGE_FILE_LEN_4 + LARGE_FILE_HEADER_SIZE + LARGE_FILE_TRAILER_SIZE;\n+  if (readn(sockfd, large_buf, rlen) != rlen) {\n+    fprintf(stderr, \"prsocket_test: SendFile_Client failed to receive file\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #if defined(XP_UNIX)\n-    if (memcmp(large_file_header, large_buf, LARGE_FILE_HEADER_SIZE) != 0) {\n-        fprintf(stderr, \"SendFile 2. ERROR - large file header corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if (memcmp((char*)large_file_addr + LARGE_FILE_OFFSET_4,\n-               large_buf + LARGE_FILE_HEADER_SIZE, LARGE_FILE_LEN_4) != 0) {\n-        fprintf(stderr, \"SendFile 2. ERROR - large file data corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n-    if (memcmp(large_file_trailer,\n-               large_buf + LARGE_FILE_HEADER_SIZE + LARGE_FILE_LEN_4,\n-               LARGE_FILE_TRAILER_SIZE) != 0) {\n-        fprintf(stderr, \"SendFile 2. ERROR - large file trailer corruption\\n\");\n-        failed_already = 1;\n-        return;\n-    }\n+  if (memcmp(large_file_header, large_buf, LARGE_FILE_HEADER_SIZE) != 0) {\n+    fprintf(stderr, \"SendFile 2. ERROR - large file header corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if (memcmp((char*)large_file_addr + LARGE_FILE_OFFSET_4,\n+             large_buf + LARGE_FILE_HEADER_SIZE, LARGE_FILE_LEN_4) != 0) {\n+    fprintf(stderr, \"SendFile 2. ERROR - large file data corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n+  if (memcmp(large_file_trailer,\n+             large_buf + LARGE_FILE_HEADER_SIZE + LARGE_FILE_LEN_4,\n+             LARGE_FILE_TRAILER_SIZE) != 0) {\n+    fprintf(stderr, \"SendFile 2. ERROR - large file trailer corruption\\n\");\n+    failed_already = 1;\n+    return;\n+  }\n #endif\n-    PR_DELETE(small_buf);\n-    PR_DELETE(large_buf);\n-    PR_Close(sockfd);\n-\n-    /*\n-     * Decrement exit_counter and notify parent thread\n-     */\n-\n-    PR_EnterMonitor(cp->exit_mon);\n-    --(*cp->exit_counter);\n-    PR_Notify(cp->exit_mon);\n-    PR_ExitMonitor(cp->exit_mon);\n-    DPRINTF((\"TransmitFile_Client [0x%lx] exiting\\n\", PR_GetCurrentThread()));\n+  PR_DELETE(small_buf);\n+  PR_DELETE(large_buf);\n+  PR_Close(sockfd);\n+\n+  /*\n+   * Decrement exit_counter and notify parent thread\n+   */\n+\n+  PR_EnterMonitor(cp->exit_mon);\n+  --(*cp->exit_counter);\n+  PR_Notify(cp->exit_mon);\n+  PR_ExitMonitor(cp->exit_mon);\n+  DPRINTF((\"TransmitFile_Client [0x%lx] exiting\\n\", PR_GetCurrentThread()));\n }\n \n /*\n@@ -1391,232 +1365,230 @@ TransmitFile_Client(void* arg)\n  *    Trasmits a small file, with a header, and a large file, without\n  *    a header\n  */\n-static void\n-Serve_TransmitFile_Client(void* arg)\n-{\n-    Serve_Client_Param* scp = (Serve_Client_Param*)arg;\n-    PRFileDesc* sockfd;\n-    PRInt32 bytes;\n-    PRFileDesc* local_small_file_fd = NULL;\n-    PRFileDesc* local_large_file_fd = NULL;\n-    PRSendFileData sfd;\n-    PRInt32 slen;\n-\n-    sockfd = scp->sockfd;\n-    local_small_file_fd = PR_Open(SMALL_FILE_NAME, PR_RDONLY, 0);\n-\n-    if (local_small_file_fd == NULL) {\n-        fprintf(stderr, \"prsocket_test failed to open file for transmitting %s\\n\",\n-                SMALL_FILE_NAME);\n-        failed_already = 1;\n-        goto done;\n-    }\n-    local_large_file_fd = PR_Open(LARGE_FILE_NAME, PR_RDONLY, 0);\n-\n-    if (local_large_file_fd == NULL) {\n-        fprintf(stderr, \"prsocket_test failed to open file for transmitting %s\\n\",\n-                LARGE_FILE_NAME);\n-        failed_already = 1;\n-        goto done;\n-    }\n-    bytes = PR_TransmitFile(sockfd, local_small_file_fd, small_file_header,\n-                            SMALL_FILE_HEADER_SIZE, PR_TRANSMITFILE_KEEP_OPEN,\n-                            PR_INTERVAL_NO_TIMEOUT);\n-    if (bytes != (SMALL_FILE_SIZE + SMALL_FILE_HEADER_SIZE)) {\n-        fprintf(stderr, \"prsocet_test: PR_TransmitFile failed: (%ld, %ld)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        failed_already = 1;\n-    }\n-    bytes = PR_TransmitFile(sockfd, local_large_file_fd, NULL, 0,\n-                            PR_TRANSMITFILE_KEEP_OPEN, PR_INTERVAL_NO_TIMEOUT);\n-    if (bytes != LARGE_FILE_SIZE) {\n-        fprintf(stderr, \"prsocket_test: PR_TransmitFile failed: (%ld, %ld)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        failed_already = 1;\n-    }\n-\n-    /*\n-     * PR_SendFile test cases\n-     */\n-\n-    /*\n-     * case 1: small file with header and trailer\n-     */\n-    sfd.fd = local_small_file_fd;\n-    sfd.file_offset = 0;\n-    sfd.file_nbytes = 0;\n-    sfd.header = small_file_header;\n-    sfd.hlen = SMALL_FILE_HEADER_SIZE;\n-    sfd.trailer = small_file_trailer;\n-    sfd.tlen = SMALL_FILE_TRAILER_SIZE;\n-    bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n-                        PR_INTERVAL_NO_TIMEOUT);\n-    slen = SMALL_FILE_SIZE + SMALL_FILE_HEADER_SIZE + SMALL_FILE_TRAILER_SIZE;\n-    if (bytes != slen) {\n-        fprintf(stderr,\n-                \"socket: Error - 1. PR_SendFile  send_size = %d, bytes sent = %d\\n\",\n-                slen, bytes);\n-        fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        failed_already = 1;\n-    }\n-\n-    /*\n-     * case 2: partial large file at zero offset, file with header and trailer\n-     */\n-    sfd.fd = local_large_file_fd;\n-    sfd.file_offset = 0;\n-    sfd.file_nbytes = LARGE_FILE_LEN_1;\n-    sfd.header = large_file_header;\n-    sfd.hlen = LARGE_FILE_HEADER_SIZE;\n-    sfd.trailer = large_file_trailer;\n-    sfd.tlen = LARGE_FILE_TRAILER_SIZE;\n-    bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n-                        PR_INTERVAL_NO_TIMEOUT);\n-    slen = LARGE_FILE_LEN_1 + LARGE_FILE_HEADER_SIZE + LARGE_FILE_TRAILER_SIZE;\n-    if (bytes != slen) {\n-        fprintf(stderr,\n-                \"socket: Error - 2. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n-                slen, bytes);\n-        fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        failed_already = 1;\n-    }\n-    /*\n-     * case 3: partial small file at non-zero offset, with header\n-     */\n-    sfd.fd = local_small_file_fd;\n-    sfd.file_offset = SMALL_FILE_OFFSET_1;\n-    sfd.file_nbytes = SMALL_FILE_LEN_1;\n-    sfd.header = small_file_header;\n-    sfd.hlen = SMALL_FILE_HEADER_SIZE;\n-    sfd.trailer = NULL;\n-    sfd.tlen = 0;\n-    bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n-                        PR_INTERVAL_NO_TIMEOUT);\n-    slen = SMALL_FILE_LEN_1 + SMALL_FILE_HEADER_SIZE;\n-    if (bytes != slen) {\n-        fprintf(stderr,\n-                \"socket: Error - 3. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n-                slen, bytes);\n-        fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        failed_already = 1;\n-    }\n-    /*\n-     * case 4: partial small file at non-zero offset, with trailer\n-     */\n-    sfd.fd = local_small_file_fd;\n-    sfd.file_offset = SMALL_FILE_OFFSET_2;\n-    sfd.file_nbytes = SMALL_FILE_LEN_2;\n-    sfd.header = NULL;\n-    sfd.hlen = 0;\n-    sfd.trailer = small_file_trailer;\n-    sfd.tlen = SMALL_FILE_TRAILER_SIZE;\n-    bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n-                        PR_INTERVAL_NO_TIMEOUT);\n-    slen = SMALL_FILE_LEN_2 + SMALL_FILE_TRAILER_SIZE;\n-    if (bytes != slen) {\n-        fprintf(stderr,\n-                \"socket: Error - 4. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n-                slen, bytes);\n-        fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        failed_already = 1;\n-    }\n-    /*\n-     * case 5: partial large file at non-zero offset, file with header\n-     */\n-    sfd.fd = local_large_file_fd;\n-    sfd.file_offset = LARGE_FILE_OFFSET_2;\n-    sfd.file_nbytes = LARGE_FILE_LEN_2;\n-    sfd.header = large_file_header;\n-    sfd.hlen = LARGE_FILE_HEADER_SIZE;\n-    sfd.trailer = NULL;\n-    sfd.tlen = 0;\n-    bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n-                        PR_INTERVAL_NO_TIMEOUT);\n-    slen = LARGE_FILE_LEN_2 + LARGE_FILE_HEADER_SIZE;\n-    if (bytes != slen) {\n-        fprintf(stderr,\n-                \"socket: Error - 5. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n-                slen, bytes);\n-        fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        failed_already = 1;\n-    }\n-    /*\n-     * case 6: partial small file from non-zero offset till end of file, with\n-     * header\n-     */\n-    sfd.fd = local_small_file_fd;\n-    sfd.file_offset = SMALL_FILE_OFFSET_3;\n-    sfd.file_nbytes = 0; /* data from offset to end-of-file */\n-    sfd.header = small_file_header;\n-    sfd.hlen = SMALL_FILE_HEADER_SIZE;\n-    sfd.trailer = NULL;\n-    sfd.tlen = 0;\n-    bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n-                        PR_INTERVAL_NO_TIMEOUT);\n-    slen = SMALL_FILE_LEN_3 + SMALL_FILE_HEADER_SIZE;\n-    if (bytes != slen) {\n-        fprintf(stderr,\n-                \"socket: Error - 6. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n-                slen, bytes);\n-        fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        failed_already = 1;\n-    }\n-    /*\n-     * case 7: partial large file at non-zero offset till end-of-file, with header\n-     */\n-    sfd.fd = local_large_file_fd;\n-    sfd.file_offset = LARGE_FILE_OFFSET_3;\n-    sfd.file_nbytes = 0; /* data until end-of-file */\n-    sfd.header = large_file_header;\n-    sfd.hlen = LARGE_FILE_HEADER_SIZE;\n-    sfd.trailer = NULL;\n-    sfd.tlen = 0;\n-    bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n-                        PR_INTERVAL_NO_TIMEOUT);\n-    slen = LARGE_FILE_LEN_3 + LARGE_FILE_HEADER_SIZE;\n-    if (bytes != slen) {\n-        fprintf(stderr,\n-                \"socket: Error - 7. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n-                slen, bytes);\n-        fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        failed_already = 1;\n-    }\n-    /*\n-     * case 8: partial large file at non-zero page-aligned offset,\n-     * with header and trailer\n-     */\n-    sfd.fd = local_large_file_fd;\n-    sfd.file_offset = LARGE_FILE_OFFSET_4;\n-    sfd.file_nbytes = LARGE_FILE_LEN_4;\n-    sfd.header = large_file_header;\n-    sfd.hlen = LARGE_FILE_HEADER_SIZE;\n-    sfd.trailer = large_file_trailer;\n-    sfd.tlen = LARGE_FILE_TRAILER_SIZE;\n-    bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_CLOSE_SOCKET,\n-                        PR_INTERVAL_NO_TIMEOUT);\n-    slen = LARGE_FILE_LEN_4 + LARGE_FILE_HEADER_SIZE + LARGE_FILE_TRAILER_SIZE;\n-    if (bytes != slen) {\n-        fprintf(stderr,\n-                \"socket: Error - 2. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n-                slen, bytes);\n-        fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n-                PR_GetError(), PR_GetOSError());\n-        failed_already = 1;\n-    }\n+static void Serve_TransmitFile_Client(void* arg) {\n+  Serve_Client_Param* scp = (Serve_Client_Param*)arg;\n+  PRFileDesc* sockfd;\n+  PRInt32 bytes;\n+  PRFileDesc* local_small_file_fd = NULL;\n+  PRFileDesc* local_large_file_fd = NULL;\n+  PRSendFileData sfd;\n+  PRInt32 slen;\n+\n+  sockfd = scp->sockfd;\n+  local_small_file_fd = PR_Open(SMALL_FILE_NAME, PR_RDONLY, 0);\n+\n+  if (local_small_file_fd == NULL) {\n+    fprintf(stderr, \"prsocket_test failed to open file for transmitting %s\\n\",\n+            SMALL_FILE_NAME);\n+    failed_already = 1;\n+    goto done;\n+  }\n+  local_large_file_fd = PR_Open(LARGE_FILE_NAME, PR_RDONLY, 0);\n+\n+  if (local_large_file_fd == NULL) {\n+    fprintf(stderr, \"prsocket_test failed to open file for transmitting %s\\n\",\n+            LARGE_FILE_NAME);\n+    failed_already = 1;\n+    goto done;\n+  }\n+  bytes = PR_TransmitFile(sockfd, local_small_file_fd, small_file_header,\n+                          SMALL_FILE_HEADER_SIZE, PR_TRANSMITFILE_KEEP_OPEN,\n+                          PR_INTERVAL_NO_TIMEOUT);\n+  if (bytes != (SMALL_FILE_SIZE + SMALL_FILE_HEADER_SIZE)) {\n+    fprintf(stderr, \"prsocet_test: PR_TransmitFile failed: (%ld, %ld)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    failed_already = 1;\n+  }\n+  bytes = PR_TransmitFile(sockfd, local_large_file_fd, NULL, 0,\n+                          PR_TRANSMITFILE_KEEP_OPEN, PR_INTERVAL_NO_TIMEOUT);\n+  if (bytes != LARGE_FILE_SIZE) {\n+    fprintf(stderr, \"prsocket_test: PR_TransmitFile failed: (%ld, %ld)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    failed_already = 1;\n+  }\n+\n+  /*\n+   * PR_SendFile test cases\n+   */\n+\n+  /*\n+   * case 1: small file with header and trailer\n+   */\n+  sfd.fd = local_small_file_fd;\n+  sfd.file_offset = 0;\n+  sfd.file_nbytes = 0;\n+  sfd.header = small_file_header;\n+  sfd.hlen = SMALL_FILE_HEADER_SIZE;\n+  sfd.trailer = small_file_trailer;\n+  sfd.tlen = SMALL_FILE_TRAILER_SIZE;\n+  bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n+                      PR_INTERVAL_NO_TIMEOUT);\n+  slen = SMALL_FILE_SIZE + SMALL_FILE_HEADER_SIZE + SMALL_FILE_TRAILER_SIZE;\n+  if (bytes != slen) {\n+    fprintf(stderr,\n+            \"socket: Error - 1. PR_SendFile  send_size = %d, bytes sent = %d\\n\",\n+            slen, bytes);\n+    fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    failed_already = 1;\n+  }\n+\n+  /*\n+   * case 2: partial large file at zero offset, file with header and trailer\n+   */\n+  sfd.fd = local_large_file_fd;\n+  sfd.file_offset = 0;\n+  sfd.file_nbytes = LARGE_FILE_LEN_1;\n+  sfd.header = large_file_header;\n+  sfd.hlen = LARGE_FILE_HEADER_SIZE;\n+  sfd.trailer = large_file_trailer;\n+  sfd.tlen = LARGE_FILE_TRAILER_SIZE;\n+  bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n+                      PR_INTERVAL_NO_TIMEOUT);\n+  slen = LARGE_FILE_LEN_1 + LARGE_FILE_HEADER_SIZE + LARGE_FILE_TRAILER_SIZE;\n+  if (bytes != slen) {\n+    fprintf(stderr,\n+            \"socket: Error - 2. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n+            slen, bytes);\n+    fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    failed_already = 1;\n+  }\n+  /*\n+   * case 3: partial small file at non-zero offset, with header\n+   */\n+  sfd.fd = local_small_file_fd;\n+  sfd.file_offset = SMALL_FILE_OFFSET_1;\n+  sfd.file_nbytes = SMALL_FILE_LEN_1;\n+  sfd.header = small_file_header;\n+  sfd.hlen = SMALL_FILE_HEADER_SIZE;\n+  sfd.trailer = NULL;\n+  sfd.tlen = 0;\n+  bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n+                      PR_INTERVAL_NO_TIMEOUT);\n+  slen = SMALL_FILE_LEN_1 + SMALL_FILE_HEADER_SIZE;\n+  if (bytes != slen) {\n+    fprintf(stderr,\n+            \"socket: Error - 3. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n+            slen, bytes);\n+    fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    failed_already = 1;\n+  }\n+  /*\n+   * case 4: partial small file at non-zero offset, with trailer\n+   */\n+  sfd.fd = local_small_file_fd;\n+  sfd.file_offset = SMALL_FILE_OFFSET_2;\n+  sfd.file_nbytes = SMALL_FILE_LEN_2;\n+  sfd.header = NULL;\n+  sfd.hlen = 0;\n+  sfd.trailer = small_file_trailer;\n+  sfd.tlen = SMALL_FILE_TRAILER_SIZE;\n+  bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n+                      PR_INTERVAL_NO_TIMEOUT);\n+  slen = SMALL_FILE_LEN_2 + SMALL_FILE_TRAILER_SIZE;\n+  if (bytes != slen) {\n+    fprintf(stderr,\n+            \"socket: Error - 4. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n+            slen, bytes);\n+    fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    failed_already = 1;\n+  }\n+  /*\n+   * case 5: partial large file at non-zero offset, file with header\n+   */\n+  sfd.fd = local_large_file_fd;\n+  sfd.file_offset = LARGE_FILE_OFFSET_2;\n+  sfd.file_nbytes = LARGE_FILE_LEN_2;\n+  sfd.header = large_file_header;\n+  sfd.hlen = LARGE_FILE_HEADER_SIZE;\n+  sfd.trailer = NULL;\n+  sfd.tlen = 0;\n+  bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n+                      PR_INTERVAL_NO_TIMEOUT);\n+  slen = LARGE_FILE_LEN_2 + LARGE_FILE_HEADER_SIZE;\n+  if (bytes != slen) {\n+    fprintf(stderr,\n+            \"socket: Error - 5. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n+            slen, bytes);\n+    fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    failed_already = 1;\n+  }\n+  /*\n+   * case 6: partial small file from non-zero offset till end of file, with\n+   * header\n+   */\n+  sfd.fd = local_small_file_fd;\n+  sfd.file_offset = SMALL_FILE_OFFSET_3;\n+  sfd.file_nbytes = 0; /* data from offset to end-of-file */\n+  sfd.header = small_file_header;\n+  sfd.hlen = SMALL_FILE_HEADER_SIZE;\n+  sfd.trailer = NULL;\n+  sfd.tlen = 0;\n+  bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n+                      PR_INTERVAL_NO_TIMEOUT);\n+  slen = SMALL_FILE_LEN_3 + SMALL_FILE_HEADER_SIZE;\n+  if (bytes != slen) {\n+    fprintf(stderr,\n+            \"socket: Error - 6. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n+            slen, bytes);\n+    fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    failed_already = 1;\n+  }\n+  /*\n+   * case 7: partial large file at non-zero offset till end-of-file, with header\n+   */\n+  sfd.fd = local_large_file_fd;\n+  sfd.file_offset = LARGE_FILE_OFFSET_3;\n+  sfd.file_nbytes = 0; /* data until end-of-file */\n+  sfd.header = large_file_header;\n+  sfd.hlen = LARGE_FILE_HEADER_SIZE;\n+  sfd.trailer = NULL;\n+  sfd.tlen = 0;\n+  bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_KEEP_OPEN,\n+                      PR_INTERVAL_NO_TIMEOUT);\n+  slen = LARGE_FILE_LEN_3 + LARGE_FILE_HEADER_SIZE;\n+  if (bytes != slen) {\n+    fprintf(stderr,\n+            \"socket: Error - 7. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n+            slen, bytes);\n+    fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    failed_already = 1;\n+  }\n+  /*\n+   * case 8: partial large file at non-zero page-aligned offset,\n+   * with header and trailer\n+   */\n+  sfd.fd = local_large_file_fd;\n+  sfd.file_offset = LARGE_FILE_OFFSET_4;\n+  sfd.file_nbytes = LARGE_FILE_LEN_4;\n+  sfd.header = large_file_header;\n+  sfd.hlen = LARGE_FILE_HEADER_SIZE;\n+  sfd.trailer = large_file_trailer;\n+  sfd.tlen = LARGE_FILE_TRAILER_SIZE;\n+  bytes = PR_SendFile(sockfd, &sfd, PR_TRANSMITFILE_CLOSE_SOCKET,\n+                      PR_INTERVAL_NO_TIMEOUT);\n+  slen = LARGE_FILE_LEN_4 + LARGE_FILE_HEADER_SIZE + LARGE_FILE_TRAILER_SIZE;\n+  if (bytes != slen) {\n+    fprintf(stderr,\n+            \"socket: Error - 2. PR_SendFile send_size = %d, bytes sent = %d\\n\",\n+            slen, bytes);\n+    fprintf(stderr, \"prsocket_test: PR_SendFile failed: (%ld, %ld)\\n\",\n+            PR_GetError(), PR_GetOSError());\n+    failed_already = 1;\n+  }\n done:\n-    if (local_small_file_fd != NULL) {\n-        PR_Close(local_small_file_fd);\n-    }\n-    if (local_large_file_fd != NULL) {\n-        PR_Close(local_large_file_fd);\n-    }\n+  if (local_small_file_fd != NULL) {\n+    PR_Close(local_small_file_fd);\n+  }\n+  if (local_large_file_fd != NULL) {\n+    PR_Close(local_large_file_fd);\n+  }\n }\n \n /*\n@@ -1625,447 +1597,443 @@ done:\n  *    Bind an address to a socket and listen for incoming connections\n  *    Create worker threads to service clients\n  */\n-static void\n-TransmitFile_Server(void* arg)\n-{\n-    PRThread** t = NULL; /* an array of PRThread pointers */\n-    Server_Param* sp = (Server_Param*)arg;\n-    Serve_Client_Param* scp;\n-    PRFileDesc *sockfd = NULL, *newsockfd;\n-    PRNetAddr netaddr;\n-    PRInt32 i;\n-\n-    t = (PRThread**)PR_MALLOC(num_transmitfile_clients * sizeof(PRThread*));\n-    if (t == NULL) {\n-        fprintf(stderr, \"prsocket_test: run out of memory\\n\");\n+static void TransmitFile_Server(void* arg) {\n+  PRThread** t = NULL; /* an array of PRThread pointers */\n+  Server_Param* sp = (Server_Param*)arg;\n+  Serve_Client_Param* scp;\n+  PRFileDesc *sockfd = NULL, *newsockfd;\n+  PRNetAddr netaddr;\n+  PRInt32 i;\n+\n+  t = (PRThread**)PR_MALLOC(num_transmitfile_clients * sizeof(PRThread*));\n+  if (t == NULL) {\n+    fprintf(stderr, \"prsocket_test: run out of memory\\n\");\n+    failed_already = 1;\n+    goto exit;\n+  }\n+  /*\n+   * Create a tcp socket\n+   */\n+  if ((sockfd = PR_OpenTCPSocket(PR_AF_INET)) == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_OpenTCPSocket failed\\n\");\n+    failed_already = 1;\n+    goto exit;\n+  }\n+  memset(&netaddr, 0, sizeof(netaddr));\n+  netaddr.inet.family = PR_AF_INET;\n+  netaddr.inet.port = PR_htons(TCP_SERVER_PORT);\n+  netaddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  /*\n+   * try a few times to bind server's address, if addresses are in\n+   * use\n+   */\n+  i = 0;\n+  while (PR_Bind(sockfd, &netaddr) < 0) {\n+    if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n+      netaddr.inet.port += 2;\n+      if (i++ < SERVER_MAX_BIND_COUNT) {\n+        continue;\n+      }\n+    }\n+    fprintf(stderr, \"prsocket_test: ERROR - PR_Bind failed\\n\");\n+    failed_already = 1;\n+    perror(\"PR_Bind\");\n+    goto exit;\n+  }\n+\n+  if (PR_Listen(sockfd, 32) < 0) {\n+    fprintf(stderr, \"prsocket_test: ERROR - PR_Listen failed\\n\");\n+    failed_already = 1;\n+    goto exit;\n+  }\n+\n+  if (PR_GetSockName(sockfd, &netaddr) < 0) {\n+    fprintf(stderr, \"prsocket_test: ERROR - PR_GetSockName failed\\n\");\n+    failed_already = 1;\n+    goto exit;\n+  }\n+\n+  DPRINTF(\n+      (\"TCP_Server: PR_BIND netaddr.inet.ip = 0x%lx, netaddr.inet.port = %d\\n\",\n+       netaddr.inet.ip, netaddr.inet.port));\n+  tcp_server_addr.inet.family = netaddr.inet.family;\n+  tcp_server_addr.inet.port = netaddr.inet.port;\n+  tcp_server_addr.inet.ip = netaddr.inet.ip;\n+\n+  /*\n+   * Wake up parent thread because server address is bound and made\n+   * available in the global variable 'tcp_server_addr'\n+   */\n+  PR_PostSem(sp->addr_sem);\n+\n+  for (i = 0; i < num_transmitfile_clients; i++) {\n+    /* test both null and non-null 'addr' argument to PR_Accept */\n+    PRNetAddr* addrp = (i % 2 ? &netaddr : NULL);\n+\n+    if ((newsockfd = PR_Accept(sockfd, addrp, PR_INTERVAL_NO_TIMEOUT)) ==\n+        NULL) {\n+      fprintf(stderr, \"prsocket_test: ERROR - PR_Accept failed\\n\");\n+      failed_already = 1;\n+      goto exit;\n+    }\n+    /* test both regular and emulated PR_SendFile */\n+    if (i % 2) {\n+      PRFileDesc* layer =\n+          PR_CreateIOLayerStub(emuSendFileIdentity, &emuSendFileMethods);\n+      if (layer == NULL) {\n+        fprintf(stderr, \"prsocket_test: ERROR - PR_CreateIOLayerStub failed\\n\");\n         failed_already = 1;\n         goto exit;\n-    }\n-    /*\n-     * Create a tcp socket\n-     */\n-    if ((sockfd = PR_OpenTCPSocket(PR_AF_INET)) == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_OpenTCPSocket failed\\n\");\n+      }\n+      if (PR_PushIOLayer(newsockfd, PR_TOP_IO_LAYER, layer) == PR_FAILURE) {\n+        fprintf(stderr, \"prsocket_test: ERROR - PR_PushIOLayer failed\\n\");\n         failed_already = 1;\n         goto exit;\n+      }\n     }\n-    memset(&netaddr, 0, sizeof(netaddr));\n-    netaddr.inet.family = PR_AF_INET;\n-    netaddr.inet.port = PR_htons(TCP_SERVER_PORT);\n-    netaddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    /*\n-     * try a few times to bind server's address, if addresses are in\n-     * use\n-     */\n-    i = 0;\n-    while (PR_Bind(sockfd, &netaddr) < 0) {\n-        if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n-            netaddr.inet.port += 2;\n-            if (i++ < SERVER_MAX_BIND_COUNT) {\n-                continue;\n-            }\n-        }\n-        fprintf(stderr, \"prsocket_test: ERROR - PR_Bind failed\\n\");\n-        failed_already = 1;\n-        perror(\"PR_Bind\");\n-        goto exit;\n+    scp = PR_NEW(Serve_Client_Param);\n+    if (scp == NULL) {\n+      fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n+      failed_already = 1;\n+      goto exit;\n     }\n \n-    if (PR_Listen(sockfd, 32) < 0) {\n-        fprintf(stderr, \"prsocket_test: ERROR - PR_Listen failed\\n\");\n-        failed_already = 1;\n-        goto exit;\n-    }\n-\n-    if (PR_GetSockName(sockfd, &netaddr) < 0) {\n-        fprintf(stderr, \"prsocket_test: ERROR - PR_GetSockName failed\\n\");\n-        failed_already = 1;\n-        goto exit;\n-    }\n-\n-    DPRINTF(\n-        (\"TCP_Server: PR_BIND netaddr.inet.ip = 0x%lx, netaddr.inet.port = %d\\n\",\n-         netaddr.inet.ip, netaddr.inet.port));\n-    tcp_server_addr.inet.family = netaddr.inet.family;\n-    tcp_server_addr.inet.port = netaddr.inet.port;\n-    tcp_server_addr.inet.ip = netaddr.inet.ip;\n-\n     /*\n-     * Wake up parent thread because server address is bound and made\n-     * available in the global variable 'tcp_server_addr'\n+     * Start a Serve_Client thread for each incoming connection\n      */\n-    PR_PostSem(sp->addr_sem);\n-\n-    for (i = 0; i < num_transmitfile_clients; i++) {\n-        /* test both null and non-null 'addr' argument to PR_Accept */\n-        PRNetAddr* addrp = (i % 2 ? &netaddr : NULL);\n+    scp->sockfd = newsockfd;\n+    scp->datalen = sp->datalen;\n \n-        if ((newsockfd = PR_Accept(sockfd, addrp, PR_INTERVAL_NO_TIMEOUT)) ==\n-            NULL) {\n-            fprintf(stderr, \"prsocket_test: ERROR - PR_Accept failed\\n\");\n-            failed_already = 1;\n-            goto exit;\n-        }\n-        /* test both regular and emulated PR_SendFile */\n-        if (i % 2) {\n-            PRFileDesc* layer =\n-                PR_CreateIOLayerStub(emuSendFileIdentity, &emuSendFileMethods);\n-            if (layer == NULL) {\n-                fprintf(stderr, \"prsocket_test: ERROR - PR_CreateIOLayerStub failed\\n\");\n-                failed_already = 1;\n-                goto exit;\n-            }\n-            if (PR_PushIOLayer(newsockfd, PR_TOP_IO_LAYER, layer) == PR_FAILURE) {\n-                fprintf(stderr, \"prsocket_test: ERROR - PR_PushIOLayer failed\\n\");\n-                failed_already = 1;\n-                goto exit;\n-            }\n-        }\n-        scp = PR_NEW(Serve_Client_Param);\n-        if (scp == NULL) {\n-            fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n-            failed_already = 1;\n-            goto exit;\n-        }\n-\n-        /*\n-         * Start a Serve_Client thread for each incoming connection\n-         */\n-        scp->sockfd = newsockfd;\n-        scp->datalen = sp->datalen;\n-\n-        t[i] = PR_CreateThread(PR_USER_THREAD, Serve_TransmitFile_Client,\n-                               (void*)scp, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n-                               PR_JOINABLE_THREAD, 0);\n-        if (t[i] == NULL) {\n-            fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n-            failed_already = 1;\n-            goto exit;\n-        }\n-        DPRINTF((\"TransmitFile_Server: Created Serve_TransmitFile_Client = 0x%lx\\n\",\n-                 t));\n+    t[i] = PR_CreateThread(PR_USER_THREAD, Serve_TransmitFile_Client,\n+                           (void*)scp, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n+                           PR_JOINABLE_THREAD, 0);\n+    if (t[i] == NULL) {\n+      fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n+      failed_already = 1;\n+      goto exit;\n     }\n+    DPRINTF((\"TransmitFile_Server: Created Serve_TransmitFile_Client = 0x%lx\\n\",\n+             t));\n+  }\n \n-    /*\n-     * Wait for all the worker threads to end, so that we know\n-     * they are no longer using the small and large file fd's.\n-     */\n+  /*\n+   * Wait for all the worker threads to end, so that we know\n+   * they are no longer using the small and large file fd's.\n+   */\n \n-    for (i = 0; i < num_transmitfile_clients; i++) {\n-        PR_JoinThread(t[i]);\n-    }\n+  for (i = 0; i < num_transmitfile_clients; i++) {\n+    PR_JoinThread(t[i]);\n+  }\n \n exit:\n-    if (t) {\n-        PR_DELETE(t);\n-    }\n-    if (sockfd) {\n-        PR_Close(sockfd);\n-    }\n+  if (t) {\n+    PR_DELETE(t);\n+  }\n+  if (sockfd) {\n+    PR_Close(sockfd);\n+  }\n \n-    /*\n-     * Decrement exit_counter and notify parent thread\n-     */\n+  /*\n+   * Decrement exit_counter and notify parent thread\n+   */\n \n-    PR_EnterMonitor(sp->exit_mon);\n-    --(*sp->exit_counter);\n-    PR_Notify(sp->exit_mon);\n-    PR_ExitMonitor(sp->exit_mon);\n-    DPRINTF((\"TransmitFile_Server [0x%lx] exiting\\n\", PR_GetCurrentThread()));\n+  PR_EnterMonitor(sp->exit_mon);\n+  --(*sp->exit_counter);\n+  PR_Notify(sp->exit_mon);\n+  PR_ExitMonitor(sp->exit_mon);\n+  DPRINTF((\"TransmitFile_Server [0x%lx] exiting\\n\", PR_GetCurrentThread()));\n }\n \n /*\n  * Socket_Misc_Test    - test miscellaneous functions\n  *\n  */\n-static PRInt32\n-Socket_Misc_Test(void)\n-{\n-    PRIntn i, rv = 0, bytes, count, len;\n-    PRThread* t;\n-    PRSemaphore* server_sem;\n-    Server_Param* sparamp;\n-    Client_Param* cparamp;\n-    PRMonitor* mon2;\n-    PRInt32 datalen;\n-\n-    /*\n-     * We deliberately pick a buffer size that is not a nice multiple\n-     * of 1024.\n-     */\n+static PRInt32 Socket_Misc_Test(void) {\n+  PRIntn i, rv = 0, bytes, count, len;\n+  PRThread* t;\n+  PRSemaphore* server_sem;\n+  Server_Param* sparamp;\n+  Client_Param* cparamp;\n+  PRMonitor* mon2;\n+  PRInt32 datalen;\n+\n+  /*\n+   * We deliberately pick a buffer size that is not a nice multiple\n+   * of 1024.\n+   */\n #define TRANSMITFILE_BUF_SIZE (4 * 1024 - 11)\n \n-    typedef struct {\n-        char data[TRANSMITFILE_BUF_SIZE];\n-    } file_buf;\n-    file_buf* buf = NULL;\n-\n-    /*\n-     * create file(s) to be transmitted\n-     */\n-    if ((PR_MkDir(TEST_DIR, 0777)) < 0) {\n-        printf(\"prsocket_test failed to create dir %s\\n\", TEST_DIR);\n-        failed_already = 1;\n-        return -1;\n-    }\n-\n-    small_file_fd = PR_Open(SMALL_FILE_NAME, PR_RDWR | PR_CREATE_FILE, 0777);\n-\n-    if (small_file_fd == NULL) {\n-        fprintf(stderr, \"prsocket_test failed to create/open file %s\\n\",\n-                SMALL_FILE_NAME);\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n-    }\n-    buf = PR_NEW(file_buf);\n-    if (buf == NULL) {\n-        fprintf(stderr, \"prsocket_test failed to allocate buffer\\n\");\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n-    }\n-    /*\n-     * fill in random data\n-     */\n-    for (i = 0; i < TRANSMITFILE_BUF_SIZE; i++) {\n-        buf->data[i] = i;\n-    }\n-    count = 0;\n-    do {\n-        len = (SMALL_FILE_SIZE - count) > TRANSMITFILE_BUF_SIZE\n-                  ? TRANSMITFILE_BUF_SIZE\n-                  : (SMALL_FILE_SIZE - count);\n-        bytes = PR_Write(small_file_fd, buf->data, len);\n-        if (bytes <= 0) {\n-            fprintf(stderr, \"prsocket_test failed to write to file %s\\n\",\n-                    SMALL_FILE_NAME);\n-            failed_already = 1;\n-            rv = -1;\n-            goto done;\n-        }\n-        count += bytes;\n-    } while (count < SMALL_FILE_SIZE);\n+  typedef struct {\n+    char data[TRANSMITFILE_BUF_SIZE];\n+  } file_buf;\n+  file_buf* buf = NULL;\n+\n+  /*\n+   * create file(s) to be transmitted\n+   */\n+  if ((PR_MkDir(TEST_DIR, 0777)) < 0) {\n+    printf(\"prsocket_test failed to create dir %s\\n\", TEST_DIR);\n+    failed_already = 1;\n+    return -1;\n+  }\n+\n+  small_file_fd = PR_Open(SMALL_FILE_NAME, PR_RDWR | PR_CREATE_FILE, 0777);\n+\n+  if (small_file_fd == NULL) {\n+    fprintf(stderr, \"prsocket_test failed to create/open file %s\\n\",\n+            SMALL_FILE_NAME);\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n+  buf = PR_NEW(file_buf);\n+  if (buf == NULL) {\n+    fprintf(stderr, \"prsocket_test failed to allocate buffer\\n\");\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n+  /*\n+   * fill in random data\n+   */\n+  for (i = 0; i < TRANSMITFILE_BUF_SIZE; i++) {\n+    buf->data[i] = i;\n+  }\n+  count = 0;\n+  do {\n+    len = (SMALL_FILE_SIZE - count) > TRANSMITFILE_BUF_SIZE\n+              ? TRANSMITFILE_BUF_SIZE\n+              : (SMALL_FILE_SIZE - count);\n+    bytes = PR_Write(small_file_fd, buf->data, len);\n+    if (bytes <= 0) {\n+      fprintf(stderr, \"prsocket_test failed to write to file %s\\n\",\n+              SMALL_FILE_NAME);\n+      failed_already = 1;\n+      rv = -1;\n+      goto done;\n+    }\n+    count += bytes;\n+  } while (count < SMALL_FILE_SIZE);\n #ifdef XP_UNIX\n-    /*\n-     * map the small file; used in checking for data corruption\n-     */\n-    small_file_addr = mmap(0, SMALL_FILE_SIZE, PROT_READ, MAP_SHARED,\n-                           small_file_fd->secret->md.osfd, 0);\n-    if (small_file_addr == (void*)-1) {\n-        fprintf(stderr, \"prsocket_test failed to mmap file %s\\n\", SMALL_FILE_NAME);\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n-    }\n+  /*\n+   * map the small file; used in checking for data corruption\n+   */\n+  small_file_addr = mmap(0, SMALL_FILE_SIZE, PROT_READ, MAP_SHARED,\n+                         small_file_fd->secret->md.osfd, 0);\n+  if (small_file_addr == (void*)-1) {\n+    fprintf(stderr, \"prsocket_test failed to mmap file %s\\n\", SMALL_FILE_NAME);\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n #endif\n-    /*\n-     * header for small file\n-     */\n-    small_file_header = PR_MALLOC(SMALL_FILE_HEADER_SIZE);\n-    if (small_file_header == NULL) {\n-        fprintf(stderr, \"prsocket_test failed to malloc header file\\n\");\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n-    }\n-    memset(small_file_header, (int)PR_IntervalNow(), SMALL_FILE_HEADER_SIZE);\n-    /*\n-     * trailer for small file\n-     */\n-    small_file_trailer = PR_MALLOC(SMALL_FILE_TRAILER_SIZE);\n-    if (small_file_trailer == NULL) {\n-        fprintf(stderr, \"prsocket_test failed to malloc header trailer\\n\");\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n-    }\n-    memset(small_file_trailer, (int)PR_IntervalNow(), SMALL_FILE_TRAILER_SIZE);\n-    /*\n-     * setup large file\n-     */\n-    large_file_fd = PR_Open(LARGE_FILE_NAME, PR_RDWR | PR_CREATE_FILE, 0777);\n-\n-    if (large_file_fd == NULL) {\n-        fprintf(stderr, \"prsocket_test failed to create/open file %s\\n\",\n-                LARGE_FILE_NAME);\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n-    }\n-    /*\n-     * fill in random data\n-     */\n-    for (i = 0; i < TRANSMITFILE_BUF_SIZE; i++) {\n-        buf->data[i] = i;\n-    }\n-    count = 0;\n-    do {\n-        len = (LARGE_FILE_SIZE - count) > TRANSMITFILE_BUF_SIZE\n-                  ? TRANSMITFILE_BUF_SIZE\n-                  : (LARGE_FILE_SIZE - count);\n-        bytes = PR_Write(large_file_fd, buf->data, len);\n-        if (bytes <= 0) {\n-            fprintf(stderr, \"prsocket_test failed to write to file %s: (%ld, %ld)\\n\",\n-                    LARGE_FILE_NAME, PR_GetError(), PR_GetOSError());\n-            failed_already = 1;\n-            rv = -1;\n-            goto done;\n-        }\n-        count += bytes;\n-    } while (count < LARGE_FILE_SIZE);\n+  /*\n+   * header for small file\n+   */\n+  small_file_header = PR_MALLOC(SMALL_FILE_HEADER_SIZE);\n+  if (small_file_header == NULL) {\n+    fprintf(stderr, \"prsocket_test failed to malloc header file\\n\");\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n+  memset(small_file_header, (int)PR_IntervalNow(), SMALL_FILE_HEADER_SIZE);\n+  /*\n+   * trailer for small file\n+   */\n+  small_file_trailer = PR_MALLOC(SMALL_FILE_TRAILER_SIZE);\n+  if (small_file_trailer == NULL) {\n+    fprintf(stderr, \"prsocket_test failed to malloc header trailer\\n\");\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n+  memset(small_file_trailer, (int)PR_IntervalNow(), SMALL_FILE_TRAILER_SIZE);\n+  /*\n+   * setup large file\n+   */\n+  large_file_fd = PR_Open(LARGE_FILE_NAME, PR_RDWR | PR_CREATE_FILE, 0777);\n+\n+  if (large_file_fd == NULL) {\n+    fprintf(stderr, \"prsocket_test failed to create/open file %s\\n\",\n+            LARGE_FILE_NAME);\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n+  /*\n+   * fill in random data\n+   */\n+  for (i = 0; i < TRANSMITFILE_BUF_SIZE; i++) {\n+    buf->data[i] = i;\n+  }\n+  count = 0;\n+  do {\n+    len = (LARGE_FILE_SIZE - count) > TRANSMITFILE_BUF_SIZE\n+              ? TRANSMITFILE_BUF_SIZE\n+              : (LARGE_FILE_SIZE - count);\n+    bytes = PR_Write(large_file_fd, buf->data, len);\n+    if (bytes <= 0) {\n+      fprintf(stderr, \"prsocket_test failed to write to file %s: (%ld, %ld)\\n\",\n+              LARGE_FILE_NAME, PR_GetError(), PR_GetOSError());\n+      failed_already = 1;\n+      rv = -1;\n+      goto done;\n+    }\n+    count += bytes;\n+  } while (count < LARGE_FILE_SIZE);\n #if defined(XP_UNIX)\n-    /*\n-     * map the large file; used in checking for data corruption\n-     */\n-    large_file_addr = mmap(0, LARGE_FILE_SIZE, PROT_READ, MAP_SHARED,\n-                           large_file_fd->secret->md.osfd, 0);\n-    if (large_file_addr == (void*)-1) {\n-        fprintf(stderr, \"prsocket_test failed to mmap file %s\\n\", LARGE_FILE_NAME);\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n-    }\n+  /*\n+   * map the large file; used in checking for data corruption\n+   */\n+  large_file_addr = mmap(0, LARGE_FILE_SIZE, PROT_READ, MAP_SHARED,\n+                         large_file_fd->secret->md.osfd, 0);\n+  if (large_file_addr == (void*)-1) {\n+    fprintf(stderr, \"prsocket_test failed to mmap file %s\\n\", LARGE_FILE_NAME);\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n #endif\n-    /*\n-     * header for large file\n-     */\n-    large_file_header = PR_MALLOC(LARGE_FILE_HEADER_SIZE);\n-    if (large_file_header == NULL) {\n-        fprintf(stderr, \"prsocket_test failed to malloc header file\\n\");\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n-    }\n-    memset(large_file_header, (int)PR_IntervalNow(), LARGE_FILE_HEADER_SIZE);\n-    /*\n-     * trailer for large file\n-     */\n-    large_file_trailer = PR_MALLOC(LARGE_FILE_TRAILER_SIZE);\n-    if (large_file_trailer == NULL) {\n-        fprintf(stderr, \"prsocket_test failed to malloc header trailer\\n\");\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n-    }\n-    memset(large_file_trailer, (int)PR_IntervalNow(), LARGE_FILE_TRAILER_SIZE);\n-\n-    datalen = tcp_mesg_size;\n-    thread_count = 0;\n-    /*\n-     * start the server thread\n-     */\n-    sparamp = PR_NEW(Server_Param);\n-    if (sparamp == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n-    }\n-    server_sem = PR_NewSem(0);\n-    if (server_sem == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NewSem failed\\n\");\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n-    }\n-    mon2 = PR_NewMonitor();\n-    if (mon2 == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NewMonitor failed\\n\");\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n-    }\n-    PR_EnterMonitor(mon2);\n-\n-    sparamp->addr_sem = server_sem;\n-    sparamp->exit_mon = mon2;\n-    sparamp->exit_counter = &thread_count;\n-    sparamp->datalen = datalen;\n-    t = PR_CreateThread(PR_USER_THREAD, TransmitFile_Server, (void*)sparamp,\n-                        PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD,\n-                        0);\n+  /*\n+   * header for large file\n+   */\n+  large_file_header = PR_MALLOC(LARGE_FILE_HEADER_SIZE);\n+  if (large_file_header == NULL) {\n+    fprintf(stderr, \"prsocket_test failed to malloc header file\\n\");\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n+  memset(large_file_header, (int)PR_IntervalNow(), LARGE_FILE_HEADER_SIZE);\n+  /*\n+   * trailer for large file\n+   */\n+  large_file_trailer = PR_MALLOC(LARGE_FILE_TRAILER_SIZE);\n+  if (large_file_trailer == NULL) {\n+    fprintf(stderr, \"prsocket_test failed to malloc header trailer\\n\");\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n+  memset(large_file_trailer, (int)PR_IntervalNow(), LARGE_FILE_TRAILER_SIZE);\n+\n+  datalen = tcp_mesg_size;\n+  thread_count = 0;\n+  /*\n+   * start the server thread\n+   */\n+  sparamp = PR_NEW(Server_Param);\n+  if (sparamp == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n+  server_sem = PR_NewSem(0);\n+  if (server_sem == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NewSem failed\\n\");\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n+  mon2 = PR_NewMonitor();\n+  if (mon2 == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NewMonitor failed\\n\");\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n+  PR_EnterMonitor(mon2);\n+\n+  sparamp->addr_sem = server_sem;\n+  sparamp->exit_mon = mon2;\n+  sparamp->exit_counter = &thread_count;\n+  sparamp->datalen = datalen;\n+  t = PR_CreateThread(PR_USER_THREAD, TransmitFile_Server, (void*)sparamp,\n+                      PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD,\n+                      0);\n+  if (t == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n+  DPRINTF((\"Created TCP server = 0x%x\\n\", t));\n+  thread_count++;\n+\n+  /*\n+   * wait till the server address is setup\n+   */\n+  PR_WaitSem(server_sem);\n+\n+  /*\n+   * Now start a bunch of client threads\n+   */\n+\n+  cparamp = PR_NEW(Client_Param);\n+  if (cparamp == NULL) {\n+    fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n+    failed_already = 1;\n+    rv = -1;\n+    goto done;\n+  }\n+  cparamp->server_addr = tcp_server_addr;\n+  cparamp->server_addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n+  cparamp->exit_mon = mon2;\n+  cparamp->exit_counter = &thread_count;\n+  cparamp->datalen = datalen;\n+  for (i = 0; i < num_transmitfile_clients; i++) {\n+    t = create_new_thread(PR_USER_THREAD, TransmitFile_Client, (void*)cparamp,\n+                          PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n+                          PR_UNJOINABLE_THREAD, 0, i);\n     if (t == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n+      fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n+      rv = -1;\n+      failed_already = 1;\n+      goto done;\n     }\n-    DPRINTF((\"Created TCP server = 0x%x\\n\", t));\n+    DPRINTF((\"Created TransmitFile client = 0x%lx\\n\", t));\n     thread_count++;\n-\n-    /*\n-     * wait till the server address is setup\n-     */\n-    PR_WaitSem(server_sem);\n-\n-    /*\n-     * Now start a bunch of client threads\n-     */\n-\n-    cparamp = PR_NEW(Client_Param);\n-    if (cparamp == NULL) {\n-        fprintf(stderr, \"prsocket_test: PR_NEW failed\\n\");\n-        failed_already = 1;\n-        rv = -1;\n-        goto done;\n-    }\n-    cparamp->server_addr = tcp_server_addr;\n-    cparamp->server_addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n-    cparamp->exit_mon = mon2;\n-    cparamp->exit_counter = &thread_count;\n-    cparamp->datalen = datalen;\n-    for (i = 0; i < num_transmitfile_clients; i++) {\n-        t = create_new_thread(PR_USER_THREAD, TransmitFile_Client, (void*)cparamp,\n-                              PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n-                              PR_UNJOINABLE_THREAD, 0, i);\n-        if (t == NULL) {\n-            fprintf(stderr, \"prsocket_test: PR_CreateThread failed\\n\");\n-            rv = -1;\n-            failed_already = 1;\n-            goto done;\n-        }\n-        DPRINTF((\"Created TransmitFile client = 0x%lx\\n\", t));\n-        thread_count++;\n-    }\n-    /* Wait for server and client threads to exit */\n-    while (thread_count) {\n-        PR_Wait(mon2, PR_INTERVAL_NO_TIMEOUT);\n-        DPRINTF((\"Socket_Misc_Test - thread_count  = %d\\n\", thread_count));\n-    }\n-    PR_ExitMonitor(mon2);\n+  }\n+  /* Wait for server and client threads to exit */\n+  while (thread_count) {\n+    PR_Wait(mon2, PR_INTERVAL_NO_TIMEOUT);\n+    DPRINTF((\"Socket_Misc_Test - thread_count  = %d\\n\", thread_count));\n+  }\n+  PR_ExitMonitor(mon2);\n done:\n-    if (buf) {\n-        PR_DELETE(buf);\n-    }\n+  if (buf) {\n+    PR_DELETE(buf);\n+  }\n #if defined(XP_UNIX)\n-    munmap((char*)small_file_addr, SMALL_FILE_SIZE);\n-    munmap((char*)large_file_addr, LARGE_FILE_SIZE);\n+  munmap((char*)small_file_addr, SMALL_FILE_SIZE);\n+  munmap((char*)large_file_addr, LARGE_FILE_SIZE);\n #endif\n-    PR_Close(small_file_fd);\n-    PR_Close(large_file_fd);\n-    if ((PR_Delete(SMALL_FILE_NAME)) == PR_FAILURE) {\n-        fprintf(stderr, \"prsocket_test: failed to unlink file %s\\n\",\n-                SMALL_FILE_NAME);\n-        failed_already = 1;\n-    }\n-    if ((PR_Delete(LARGE_FILE_NAME)) == PR_FAILURE) {\n-        fprintf(stderr, \"prsocket_test: failed to unlink file %s\\n\",\n-                LARGE_FILE_NAME);\n-        failed_already = 1;\n-    }\n-    if ((PR_RmDir(TEST_DIR)) == PR_FAILURE) {\n-        fprintf(stderr, \"prsocket_test failed to rmdir %s: (%ld, %ld)\\n\", TEST_DIR,\n-                PR_GetError(), PR_GetOSError());\n-        failed_already = 1;\n-    }\n-\n-    printf(\"%-29s%s\", \"Socket_Misc_Test\", \":\");\n-    printf(\"%2d Server %2d Clients\\n\", 1, num_transmitfile_clients);\n-    printf(\"%30s Sizes of Transmitted Files  - %4d KB, %2d MB \\n\", \":\",\n-           SMALL_FILE_SIZE / 1024, LARGE_FILE_SIZE / (1024 * 1024));\n-\n-    return rv;\n+  PR_Close(small_file_fd);\n+  PR_Close(large_file_fd);\n+  if ((PR_Delete(SMALL_FILE_NAME)) == PR_FAILURE) {\n+    fprintf(stderr, \"prsocket_test: failed to unlink file %s\\n\",\n+            SMALL_FILE_NAME);\n+    failed_already = 1;\n+  }\n+  if ((PR_Delete(LARGE_FILE_NAME)) == PR_FAILURE) {\n+    fprintf(stderr, \"prsocket_test: failed to unlink file %s\\n\",\n+            LARGE_FILE_NAME);\n+    failed_already = 1;\n+  }\n+  if ((PR_RmDir(TEST_DIR)) == PR_FAILURE) {\n+    fprintf(stderr, \"prsocket_test failed to rmdir %s: (%ld, %ld)\\n\", TEST_DIR,\n+            PR_GetError(), PR_GetOSError());\n+    failed_already = 1;\n+  }\n+\n+  printf(\"%-29s%s\", \"Socket_Misc_Test\", \":\");\n+  printf(\"%2d Server %2d Clients\\n\", 1, num_transmitfile_clients);\n+  printf(\"%30s Sizes of Transmitted Files  - %4d KB, %2d MB \\n\", \":\",\n+         SMALL_FILE_SIZE / 1024, LARGE_FILE_SIZE / (1024 * 1024));\n+\n+  return rv;\n }\n /************************************************************************/\n \n@@ -2073,120 +2041,118 @@ done:\n  * Test Socket NSPR APIs\n  */\n \n-int\n-main(int argc, char** argv)\n-{\n-    /*\n-     * -d           debug mode\n-     */\n-\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                _debug_on = 1;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    PR_SetConcurrency(4);\n-\n-    emuSendFileIdentity = PR_GetUniqueIdentity(\"Emulated SendFile\");\n-    emuSendFileMethods = *PR_GetDefaultIOMethods();\n-    emuSendFileMethods.transmitfile = emu_TransmitFile;\n-    emuSendFileMethods.sendfile = emu_SendFile;\n-\n-    /*\n-     * run client-server test with TCP, Ipv4-Ipv4\n-     */\n-    printf(\"TCP Client/Server Test - IPv4/Ipv4\\n\");\n-    if (TCP_Socket_Client_Server_Test() < 0) {\n-        printf(\"TCP_Socket_Client_Server_Test failed\\n\");\n-        goto done;\n-    } else {\n-        printf(\"TCP_Socket_Client_Server_Test Passed\\n\");\n-    }\n-    /*\n-     * client-server test, Ipv6-Ipv4\n-     */\n-    client_domain = PR_AF_INET6;\n-    printf(\"TCP Client/Server Test - IPv6/Ipv4\\n\");\n-    if (TCP_Socket_Client_Server_Test() < 0) {\n-        printf(\"TCP_Socket_Client_Server_Test failed\\n\");\n-        goto done;\n-    } else {\n-        printf(\"TCP_Socket_Client_Server_Test Passed\\n\");\n-    }\n-    /*\n-     * client-server test, Ipv4-Ipv6\n-     */\n-    client_domain = PR_AF_INET;\n-    server_domain = PR_AF_INET6;\n-    printf(\"TCP Client/Server Test - IPv4/Ipv6\\n\");\n-    if (TCP_Socket_Client_Server_Test() < 0) {\n-        printf(\"TCP_Socket_Client_Server_Test failed\\n\");\n-        goto done;\n-    } else {\n-        printf(\"TCP_Socket_Client_Server_Test Passed\\n\");\n-    }\n-    /*\n-     * client-server test, Ipv6-Ipv6\n-     */\n-    client_domain = PR_AF_INET6;\n-    server_domain = PR_AF_INET6;\n-    printf(\"TCP Client/Server Test - IPv6/Ipv6\\n\");\n-    if (TCP_Socket_Client_Server_Test() < 0) {\n-        printf(\"TCP_Socket_Client_Server_Test failed\\n\");\n-        goto done;\n-    } else {\n-        printf(\"TCP_Socket_Client_Server_Test Passed\\n\");\n-    }\n-    test_cancelio = 0;\n-\n-    /*\n-     * Misc socket tests - including transmitfile, etc.\n-     */\n-\n-    /* File transmission test can not be done in Symbian OS because of\n-     * large file's size and the incomplete mmap() implementation. */\n-    /*\n-    ** The 'transmit file' test does not run because\n-    ** transmit file is not implemented in NSPR yet.\n-    **\n-    */\n-    if (Socket_Misc_Test() < 0) {\n-        printf(\"Socket_Misc_Test failed\\n\");\n-        failed_already = 1;\n-        goto done;\n-    } else {\n-        printf(\"Socket_Misc_Test passed\\n\");\n-    }\n-\n-    /*\n-     * run client-server test with TCP again to test\n-     * recycling used sockets from PR_TransmitFile().\n-     */\n-    if (TCP_Socket_Client_Server_Test() < 0) {\n-        printf(\"TCP_Socket_Client_Server_Test failed\\n\");\n-        goto done;\n-    } else {\n-        printf(\"TCP_Socket_Client_Server_Test Passed\\n\");\n-    }\n+int main(int argc, char** argv) {\n+  /*\n+   * -d           debug mode\n+   */\n+\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        _debug_on = 1;\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  PR_SetConcurrency(4);\n+\n+  emuSendFileIdentity = PR_GetUniqueIdentity(\"Emulated SendFile\");\n+  emuSendFileMethods = *PR_GetDefaultIOMethods();\n+  emuSendFileMethods.transmitfile = emu_TransmitFile;\n+  emuSendFileMethods.sendfile = emu_SendFile;\n+\n+  /*\n+   * run client-server test with TCP, Ipv4-Ipv4\n+   */\n+  printf(\"TCP Client/Server Test - IPv4/Ipv4\\n\");\n+  if (TCP_Socket_Client_Server_Test() < 0) {\n+    printf(\"TCP_Socket_Client_Server_Test failed\\n\");\n+    goto done;\n+  } else {\n+    printf(\"TCP_Socket_Client_Server_Test Passed\\n\");\n+  }\n+  /*\n+   * client-server test, Ipv6-Ipv4\n+   */\n+  client_domain = PR_AF_INET6;\n+  printf(\"TCP Client/Server Test - IPv6/Ipv4\\n\");\n+  if (TCP_Socket_Client_Server_Test() < 0) {\n+    printf(\"TCP_Socket_Client_Server_Test failed\\n\");\n+    goto done;\n+  } else {\n+    printf(\"TCP_Socket_Client_Server_Test Passed\\n\");\n+  }\n+  /*\n+   * client-server test, Ipv4-Ipv6\n+   */\n+  client_domain = PR_AF_INET;\n+  server_domain = PR_AF_INET6;\n+  printf(\"TCP Client/Server Test - IPv4/Ipv6\\n\");\n+  if (TCP_Socket_Client_Server_Test() < 0) {\n+    printf(\"TCP_Socket_Client_Server_Test failed\\n\");\n+    goto done;\n+  } else {\n+    printf(\"TCP_Socket_Client_Server_Test Passed\\n\");\n+  }\n+  /*\n+   * client-server test, Ipv6-Ipv6\n+   */\n+  client_domain = PR_AF_INET6;\n+  server_domain = PR_AF_INET6;\n+  printf(\"TCP Client/Server Test - IPv6/Ipv6\\n\");\n+  if (TCP_Socket_Client_Server_Test() < 0) {\n+    printf(\"TCP_Socket_Client_Server_Test failed\\n\");\n+    goto done;\n+  } else {\n+    printf(\"TCP_Socket_Client_Server_Test Passed\\n\");\n+  }\n+  test_cancelio = 0;\n+\n+  /*\n+   * Misc socket tests - including transmitfile, etc.\n+   */\n+\n+  /* File transmission test can not be done in Symbian OS because of\n+   * large file's size and the incomplete mmap() implementation. */\n+  /*\n+  ** The 'transmit file' test does not run because\n+  ** transmit file is not implemented in NSPR yet.\n+  **\n+  */\n+  if (Socket_Misc_Test() < 0) {\n+    printf(\"Socket_Misc_Test failed\\n\");\n+    failed_already = 1;\n+    goto done;\n+  } else {\n+    printf(\"Socket_Misc_Test passed\\n\");\n+  }\n+\n+  /*\n+   * run client-server test with TCP again to test\n+   * recycling used sockets from PR_TransmitFile().\n+   */\n+  if (TCP_Socket_Client_Server_Test() < 0) {\n+    printf(\"TCP_Socket_Client_Server_Test failed\\n\");\n+    goto done;\n+  } else {\n+    printf(\"TCP_Socket_Client_Server_Test Passed\\n\");\n+  }\n \n done:\n-    PR_Cleanup();\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  PR_Cleanup();\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/sockopt.c b/nspr/pr/tests/sockopt.c\nindex 77a799e..da7e060 100644\n--- a/nspr/pr/tests/sockopt.c\n+++ b/nspr/pr/tests/sockopt.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,168 +12,161 @@\n #include \"plerror.h\"\n \n #ifdef XP_UNIX\n-#include <sys/socket.h> /* SO_REUSEPORT */\n+#  include <sys/socket.h> /* SO_REUSEPORT */\n #endif\n \n static PRFileDesc* err = NULL;\n static PRBool failed = PR_FALSE;\n \n-static void\n-Failed(const char* msg1, const char* msg2)\n-{\n-    if (NULL != msg1) {\n-        PR_fprintf(err, \"%s \", msg1);\n-    }\n-    PL_FPrintError(err, msg2);\n-    failed = PR_TRUE;\n+static void Failed(const char* msg1, const char* msg2) {\n+  if (NULL != msg1) {\n+    PR_fprintf(err, \"%s \", msg1);\n+  }\n+  PL_FPrintError(err, msg2);\n+  failed = PR_TRUE;\n } /* Failed */\n \n-static PRSockOption\n-Incr(PRSockOption* option)\n-{\n-    PRIntn val = ((PRIntn)*option) + 1;\n-    *option = (PRSockOption)val;\n-    return (PRSockOption)val;\n+static PRSockOption Incr(PRSockOption* option) {\n+  PRIntn val = ((PRIntn)*option) + 1;\n+  *option = (PRSockOption)val;\n+  return (PRSockOption)val;\n } /* Incr */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRStatus rv;\n-    PRFileDesc* udp = PR_NewUDPSocket();\n-    PRFileDesc* tcp = PR_NewTCPSocket();\n-    const char* tag[] = {\n-        \"PR_SockOpt_Nonblocking\",    /* nonblocking io */\n-        \"PR_SockOpt_Linger\",         /* linger on close if data present */\n-        \"PR_SockOpt_Reuseaddr\",      /* allow local address reuse */\n-        \"PR_SockOpt_Keepalive\",      /* keep connections alive */\n-        \"PR_SockOpt_RecvBufferSize\", /* receive buffer size */\n-        \"PR_SockOpt_SendBufferSize\", /* send buffer size */\n-\n-        \"PR_SockOpt_IpTimeToLive\",    /* time to live */\n-        \"PR_SockOpt_IpTypeOfService\", /* type of service and precedence */\n-\n-        \"PR_SockOpt_AddMember\",       /* add an IP group membership */\n-        \"PR_SockOpt_DropMember\",      /* drop an IP group membership */\n-        \"PR_SockOpt_McastInterface\",  /* multicast interface address */\n-        \"PR_SockOpt_McastTimeToLive\", /* multicast timetolive */\n-        \"PR_SockOpt_McastLoopback\",   /* multicast loopback */\n-\n-        \"PR_SockOpt_NoDelay\",    /* don't delay send to coalesce packets */\n-        \"PR_SockOpt_MaxSegment\", /* maximum segment size */\n-        \"PR_SockOpt_Broadcast\",  /* Enable broadcast */\n-        \"PR_SockOpt_Reuseport\",  /* allow local address & port reuse */\n-        \"PR_SockOpt_DontFrag\",   /* do not fragment */\n-        \"PR_SockOpt_Last\"\n-    };\n-\n-    err = PR_GetSpecialFD(PR_StandardError);\n-\n-    if (NULL == udp) {\n-        Failed(\"PR_NewUDPSocket()\", NULL);\n-    } else if (NULL == tcp) {\n-        Failed(\"PR_NewTCPSocket()\", NULL);\n-    } else {\n-        PRSockOption option;\n-        PRUint32 segment = 1024;\n-        PRNetAddr addr;\n-\n-        rv = PR_InitializeNetAddr(PR_IpAddrAny, 0, &addr);\n-        if (PR_FAILURE == rv) {\n-            Failed(\"PR_InitializeNetAddr()\", NULL);\n-        }\n-        rv = PR_Bind(udp, &addr);\n-        if (PR_FAILURE == rv) {\n-            Failed(\"PR_Bind()\", NULL);\n-        }\n-        for (option = PR_SockOpt_Linger; option < PR_SockOpt_Last; Incr(&option)) {\n-            PRSocketOptionData data;\n-            PRFileDesc* fd = tcp;\n-            data.option = option;\n-            switch (option) {\n-                case PR_SockOpt_Nonblocking:\n-                    data.value.non_blocking = PR_TRUE;\n-                    break;\n-                case PR_SockOpt_Linger:\n-                    data.value.linger.polarity = PR_TRUE;\n-                    data.value.linger.linger = PR_SecondsToInterval(2);\n-                    break;\n-                case PR_SockOpt_Reuseaddr:\n-                    data.value.reuse_addr = PR_TRUE;\n-                    break;\n-                case PR_SockOpt_Keepalive:\n-                    data.value.keep_alive = PR_TRUE;\n-                    break;\n-                case PR_SockOpt_RecvBufferSize:\n-                    data.value.recv_buffer_size = segment;\n-                    break;\n-                case PR_SockOpt_SendBufferSize:\n-                    data.value.send_buffer_size = segment;\n-                    break;\n-                case PR_SockOpt_IpTimeToLive:\n-                    data.value.ip_ttl = 64;\n-                    break;\n-                case PR_SockOpt_IpTypeOfService:\n-                    data.value.tos = 0;\n-                    break;\n-                case PR_SockOpt_McastTimeToLive:\n-                    fd = udp;\n-                    data.value.mcast_ttl = 4;\n-                    break;\n-                case PR_SockOpt_McastLoopback:\n-                    fd = udp;\n-                    data.value.mcast_loopback = PR_TRUE;\n-                    break;\n-                case PR_SockOpt_NoDelay:\n-                    data.value.no_delay = PR_TRUE;\n-                    break;\n+int main(int argc, char** argv) {\n+  PRStatus rv;\n+  PRFileDesc* udp = PR_NewUDPSocket();\n+  PRFileDesc* tcp = PR_NewTCPSocket();\n+  const char* tag[] = {\n+      \"PR_SockOpt_Nonblocking\",    /* nonblocking io */\n+      \"PR_SockOpt_Linger\",         /* linger on close if data present */\n+      \"PR_SockOpt_Reuseaddr\",      /* allow local address reuse */\n+      \"PR_SockOpt_Keepalive\",      /* keep connections alive */\n+      \"PR_SockOpt_RecvBufferSize\", /* receive buffer size */\n+      \"PR_SockOpt_SendBufferSize\", /* send buffer size */\n+\n+      \"PR_SockOpt_IpTimeToLive\",    /* time to live */\n+      \"PR_SockOpt_IpTypeOfService\", /* type of service and precedence */\n+\n+      \"PR_SockOpt_AddMember\",       /* add an IP group membership */\n+      \"PR_SockOpt_DropMember\",      /* drop an IP group membership */\n+      \"PR_SockOpt_McastInterface\",  /* multicast interface address */\n+      \"PR_SockOpt_McastTimeToLive\", /* multicast timetolive */\n+      \"PR_SockOpt_McastLoopback\",   /* multicast loopback */\n+\n+      \"PR_SockOpt_NoDelay\",    /* don't delay send to coalesce packets */\n+      \"PR_SockOpt_MaxSegment\", /* maximum segment size */\n+      \"PR_SockOpt_Broadcast\",  /* Enable broadcast */\n+      \"PR_SockOpt_Reuseport\",  /* allow local address & port reuse */\n+      \"PR_SockOpt_DontFrag\",   /* do not fragment */\n+      \"PR_SockOpt_Last\"};\n+\n+  err = PR_GetSpecialFD(PR_StandardError);\n+\n+  if (NULL == udp) {\n+    Failed(\"PR_NewUDPSocket()\", NULL);\n+  } else if (NULL == tcp) {\n+    Failed(\"PR_NewTCPSocket()\", NULL);\n+  } else {\n+    PRSockOption option;\n+    PRUint32 segment = 1024;\n+    PRNetAddr addr;\n+\n+    rv = PR_InitializeNetAddr(PR_IpAddrAny, 0, &addr);\n+    if (PR_FAILURE == rv) {\n+      Failed(\"PR_InitializeNetAddr()\", NULL);\n+    }\n+    rv = PR_Bind(udp, &addr);\n+    if (PR_FAILURE == rv) {\n+      Failed(\"PR_Bind()\", NULL);\n+    }\n+    for (option = PR_SockOpt_Linger; option < PR_SockOpt_Last; Incr(&option)) {\n+      PRSocketOptionData data;\n+      PRFileDesc* fd = tcp;\n+      data.option = option;\n+      switch (option) {\n+        case PR_SockOpt_Nonblocking:\n+          data.value.non_blocking = PR_TRUE;\n+          break;\n+        case PR_SockOpt_Linger:\n+          data.value.linger.polarity = PR_TRUE;\n+          data.value.linger.linger = PR_SecondsToInterval(2);\n+          break;\n+        case PR_SockOpt_Reuseaddr:\n+          data.value.reuse_addr = PR_TRUE;\n+          break;\n+        case PR_SockOpt_Keepalive:\n+          data.value.keep_alive = PR_TRUE;\n+          break;\n+        case PR_SockOpt_RecvBufferSize:\n+          data.value.recv_buffer_size = segment;\n+          break;\n+        case PR_SockOpt_SendBufferSize:\n+          data.value.send_buffer_size = segment;\n+          break;\n+        case PR_SockOpt_IpTimeToLive:\n+          data.value.ip_ttl = 64;\n+          break;\n+        case PR_SockOpt_IpTypeOfService:\n+          data.value.tos = 0;\n+          break;\n+        case PR_SockOpt_McastTimeToLive:\n+          fd = udp;\n+          data.value.mcast_ttl = 4;\n+          break;\n+        case PR_SockOpt_McastLoopback:\n+          fd = udp;\n+          data.value.mcast_loopback = PR_TRUE;\n+          break;\n+        case PR_SockOpt_NoDelay:\n+          data.value.no_delay = PR_TRUE;\n+          break;\n #ifndef WIN32\n-                case PR_SockOpt_MaxSegment:\n-                    data.value.max_segment = segment;\n-                    break;\n+        case PR_SockOpt_MaxSegment:\n+          data.value.max_segment = segment;\n+          break;\n #endif\n-                case PR_SockOpt_Broadcast:\n-                    fd = udp;\n-                    data.value.broadcast = PR_TRUE;\n-                    break;\n+        case PR_SockOpt_Broadcast:\n+          fd = udp;\n+          data.value.broadcast = PR_TRUE;\n+          break;\n #ifdef SO_REUSEPORT\n-                case PR_SockOpt_Reuseport:\n-                    data.value.reuse_port = PR_TRUE;\n-                    break;\n+        case PR_SockOpt_Reuseport:\n+          data.value.reuse_port = PR_TRUE;\n+          break;\n #endif\n-                case PR_SockOpt_DontFrag:\n-                    data.value.dont_fragment = PR_TRUE;\n-                    break;\n-\n-                default:\n-                    continue;\n-            }\n-\n-            /*\n-             * TCP_MAXSEG can only be read, not set\n-             */\n-            if (option != PR_SockOpt_MaxSegment) {\n+        case PR_SockOpt_DontFrag:\n+          data.value.dont_fragment = PR_TRUE;\n+          break;\n+\n+        default:\n+          continue;\n+      }\n+\n+      /*\n+       * TCP_MAXSEG can only be read, not set\n+       */\n+      if (option != PR_SockOpt_MaxSegment) {\n #ifdef WIN32\n-                if (option != PR_SockOpt_McastLoopback)\n+        if (option != PR_SockOpt_McastLoopback)\n #endif\n-                {\n-                    rv = PR_SetSocketOption(fd, &data);\n-                    if (PR_FAILURE == rv) {\n-                        Failed(\"PR_SetSocketOption()\", tag[option]);\n-                    }\n-                }\n-            }\n-\n-            rv = PR_GetSocketOption(fd, &data);\n-            if (PR_FAILURE == rv) {\n-                Failed(\"PR_GetSocketOption()\", tag[option]);\n-            }\n+        {\n+          rv = PR_SetSocketOption(fd, &data);\n+          if (PR_FAILURE == rv) {\n+            Failed(\"PR_SetSocketOption()\", tag[option]);\n+          }\n         }\n-        PR_Close(udp);\n-        PR_Close(tcp);\n+      }\n+\n+      rv = PR_GetSocketOption(fd, &data);\n+      if (PR_FAILURE == rv) {\n+        Failed(\"PR_GetSocketOption()\", tag[option]);\n+      }\n     }\n-    PR_fprintf(err, \"%s\\n\", (failed) ? \"FAILED\" : \"PASSED\");\n-    return (failed) ? 1 : 0;\n+    PR_Close(udp);\n+    PR_Close(tcp);\n+  }\n+  PR_fprintf(err, \"%s\\n\", (failed) ? \"FAILED\" : \"PASSED\");\n+  return (failed) ? 1 : 0;\n } /* main */\n \n /* sockopt.c */\ndiff --git a/nspr/pr/tests/sockping.c b/nspr/pr/tests/sockping.c\nindex 85c7caf..fbd9fc2 100644\n--- a/nspr/pr/tests/sockping.c\n+++ b/nspr/pr/tests/sockping.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -26,106 +27,104 @@\n \n #define NUM_ITERATIONS 10\n \n-static char* child_argv[] = { \"sockpong\", NULL };\n+static char* child_argv[] = {\"sockpong\", NULL};\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc* sock[2];\n-    PRStatus status;\n-    PRProcess* process;\n-    PRProcessAttr* attr;\n-    char buf[1024];\n-    PRInt32 nBytes;\n-    PRInt32 exitCode;\n-    int idx;\n+int main(int argc, char** argv) {\n+  PRFileDesc* sock[2];\n+  PRStatus status;\n+  PRProcess* process;\n+  PRProcessAttr* attr;\n+  char buf[1024];\n+  PRInt32 nBytes;\n+  PRInt32 exitCode;\n+  int idx;\n \n-    status = PR_NewTCPSocketPair(sock);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_NewTCPSocketPair failed\\n\");\n-        exit(1);\n-    }\n+  status = PR_NewTCPSocketPair(sock);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_NewTCPSocketPair failed\\n\");\n+    exit(1);\n+  }\n \n-    status = PR_SetFDInheritable(sock[0], PR_FALSE);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetFDInheritable failed: (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n-    status = PR_SetFDInheritable(sock[1], PR_TRUE);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetFDInheritable failed: (%d, %d)\\n\", PR_GetError(),\n-                PR_GetOSError());\n-        exit(1);\n-    }\n+  status = PR_SetFDInheritable(sock[0], PR_FALSE);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetFDInheritable failed: (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n+  status = PR_SetFDInheritable(sock[1], PR_TRUE);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetFDInheritable failed: (%d, %d)\\n\", PR_GetError(),\n+            PR_GetOSError());\n+    exit(1);\n+  }\n \n-    attr = PR_NewProcessAttr();\n-    if (attr == NULL) {\n-        fprintf(stderr, \"PR_NewProcessAttr failed\\n\");\n-        exit(1);\n-    }\n+  attr = PR_NewProcessAttr();\n+  if (attr == NULL) {\n+    fprintf(stderr, \"PR_NewProcessAttr failed\\n\");\n+    exit(1);\n+  }\n \n-    status = PR_ProcessAttrSetInheritableFD(attr, sock[1], \"SOCKET\");\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_ProcessAttrSetInheritableFD failed\\n\");\n-        exit(1);\n-    }\n+  status = PR_ProcessAttrSetInheritableFD(attr, sock[1], \"SOCKET\");\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_ProcessAttrSetInheritableFD failed\\n\");\n+    exit(1);\n+  }\n \n-    process = PR_CreateProcess(child_argv[0], child_argv, NULL, attr);\n-    if (process == NULL) {\n-        fprintf(stderr, \"PR_CreateProcess failed\\n\");\n-        exit(1);\n-    }\n-    PR_DestroyProcessAttr(attr);\n-    status = PR_Close(sock[1]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n+  process = PR_CreateProcess(child_argv[0], child_argv, NULL, attr);\n+  if (process == NULL) {\n+    fprintf(stderr, \"PR_CreateProcess failed\\n\");\n+    exit(1);\n+  }\n+  PR_DestroyProcessAttr(attr);\n+  status = PR_Close(sock[1]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n \n-    for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n-        strcpy(buf, \"ping\");\n-        printf(\"ping process: sending \\\"%s\\\"\\n\", buf);\n-        nBytes = PR_Write(sock[0], buf, 5);\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            exit(1);\n-        }\n-        memset(buf, 0, sizeof(buf));\n-        nBytes = PR_Read(sock[0], buf, sizeof(buf));\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Read failed: (%d, %d)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            exit(1);\n-        }\n-        printf(\"ping process: received \\\"%s\\\"\\n\", buf);\n-        if (nBytes != 5) {\n-            fprintf(stderr, \"ping process: expected 5 bytes but got %d bytes\\n\",\n-                    nBytes);\n-            exit(1);\n-        }\n-        if (strcmp(buf, \"pong\") != 0) {\n-            fprintf(stderr, \"ping process: expected \\\"pong\\\" but got \\\"%s\\\"\\n\", buf);\n-            exit(1);\n-        }\n+  for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n+    strcpy(buf, \"ping\");\n+    printf(\"ping process: sending \\\"%s\\\"\\n\", buf);\n+    nBytes = PR_Write(sock[0], buf, 5);\n+    if (nBytes == -1) {\n+      fprintf(stderr, \"PR_Write failed: (%d, %d)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      exit(1);\n     }\n-\n-    status = PR_Close(sock[0]);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n+    memset(buf, 0, sizeof(buf));\n+    nBytes = PR_Read(sock[0], buf, sizeof(buf));\n+    if (nBytes == -1) {\n+      fprintf(stderr, \"PR_Read failed: (%d, %d)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      exit(1);\n     }\n-    status = PR_WaitProcess(process, &exitCode);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_WaitProcess failed\\n\");\n-        exit(1);\n+    printf(\"ping process: received \\\"%s\\\"\\n\", buf);\n+    if (nBytes != 5) {\n+      fprintf(stderr, \"ping process: expected 5 bytes but got %d bytes\\n\",\n+              nBytes);\n+      exit(1);\n     }\n-    if (exitCode == 0) {\n-        printf(\"PASS\\n\");\n-        return 0;\n-    } else {\n-        printf(\"FAIL\\n\");\n-        return 1;\n+    if (strcmp(buf, \"pong\") != 0) {\n+      fprintf(stderr, \"ping process: expected \\\"pong\\\" but got \\\"%s\\\"\\n\", buf);\n+      exit(1);\n     }\n+  }\n+\n+  status = PR_Close(sock[0]);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_WaitProcess(process, &exitCode);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_WaitProcess failed\\n\");\n+    exit(1);\n+  }\n+  if (exitCode == 0) {\n+    printf(\"PASS\\n\");\n+    return 0;\n+  } else {\n+    printf(\"FAIL\\n\");\n+    return 1;\n+  }\n }\ndiff --git a/nspr/pr/tests/sockpong.c b/nspr/pr/tests/sockpong.c\nindex 7968d99..24e7646 100644\n--- a/nspr/pr/tests/sockpong.c\n+++ b/nspr/pr/tests/sockpong.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -25,58 +26,56 @@\n \n #define NUM_ITERATIONS 10\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRFileDesc* sock;\n-    PRStatus status;\n-    char buf[1024];\n-    PRInt32 nBytes;\n-    int idx;\n+int main(int argc, char** argv) {\n+  PRFileDesc* sock;\n+  PRStatus status;\n+  char buf[1024];\n+  PRInt32 nBytes;\n+  int idx;\n \n-    sock = PR_GetInheritedFD(\"SOCKET\");\n-    if (sock == NULL) {\n-        fprintf(stderr, \"PR_GetInheritedFD failed\\n\");\n-        exit(1);\n+  sock = PR_GetInheritedFD(\"SOCKET\");\n+  if (sock == NULL) {\n+    fprintf(stderr, \"PR_GetInheritedFD failed\\n\");\n+    exit(1);\n+  }\n+  status = PR_SetFDInheritable(sock, PR_FALSE);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n+    exit(1);\n+  }\n+\n+  for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n+    memset(buf, 0, sizeof(buf));\n+    nBytes = PR_Read(sock, buf, sizeof(buf));\n+    if (nBytes == -1) {\n+      fprintf(stderr, \"PR_Read failed: (%d, %d)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      exit(1);\n     }\n-    status = PR_SetFDInheritable(sock, PR_FALSE);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_SetFDInheritable failed\\n\");\n-        exit(1);\n+    printf(\"pong process: received \\\"%s\\\"\\n\", buf);\n+    if (nBytes != 5) {\n+      fprintf(stderr, \"pong process: expected 5 bytes but got %d bytes\\n\",\n+              nBytes);\n+      exit(1);\n     }\n-\n-    for (idx = 0; idx < NUM_ITERATIONS; idx++) {\n-        memset(buf, 0, sizeof(buf));\n-        nBytes = PR_Read(sock, buf, sizeof(buf));\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Read failed: (%d, %d)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            exit(1);\n-        }\n-        printf(\"pong process: received \\\"%s\\\"\\n\", buf);\n-        if (nBytes != 5) {\n-            fprintf(stderr, \"pong process: expected 5 bytes but got %d bytes\\n\",\n-                    nBytes);\n-            exit(1);\n-        }\n-        if (strcmp(buf, \"ping\") != 0) {\n-            fprintf(stderr, \"pong process: expected \\\"ping\\\" but got \\\"%s\\\"\\n\", buf);\n-            exit(1);\n-        }\n-\n-        strcpy(buf, \"pong\");\n-        printf(\"pong process: sending \\\"%s\\\"\\n\", buf);\n-        nBytes = PR_Write(sock, buf, 5);\n-        if (nBytes == -1) {\n-            fprintf(stderr, \"PR_Write failed\\n\");\n-            exit(1);\n-        }\n+    if (strcmp(buf, \"ping\") != 0) {\n+      fprintf(stderr, \"pong process: expected \\\"ping\\\" but got \\\"%s\\\"\\n\", buf);\n+      exit(1);\n     }\n \n-    status = PR_Close(sock);\n-    if (status == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n+    strcpy(buf, \"pong\");\n+    printf(\"pong process: sending \\\"%s\\\"\\n\", buf);\n+    nBytes = PR_Write(sock, buf, 5);\n+    if (nBytes == -1) {\n+      fprintf(stderr, \"PR_Write failed\\n\");\n+      exit(1);\n     }\n-    return 0;\n+  }\n+\n+  status = PR_Close(sock);\n+  if (status == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/sprintf.c b/nspr/pr/tests/sprintf.c\nindex 421356c..9f6dcdd 100644\n--- a/nspr/pr/tests/sprintf.c\n+++ b/nspr/pr/tests/sprintf.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -29,146 +30,72 @@ static char sbuf[20000];\n ** Perform a three way test against PR_smprintf, PR_snprintf, and sprintf.\n ** Make sure the results are identical\n */\n-static void\n-test_i(char* pattern, int i)\n-{\n-    char* s;\n-    char buf[200];\n-    int n;\n-\n-    /* try all three routines */\n-    s = PR_smprintf(pattern, i);\n-    PR_ASSERT(s != 0);\n-    n = PR_snprintf(buf, sizeof(buf), pattern, i);\n-    PR_ASSERT(n <= sizeof(buf));\n-    sprintf(sbuf, pattern, i);\n-\n-    /* compare results */\n-    if ((strncmp(s, buf, sizeof(buf)) != 0) ||\n-        (strncmp(s, sbuf, sizeof(sbuf)) != 0)) {\n-        fprintf(stderr,\n-                \"pattern='%s' i=%d\\nPR_smprintf='%s'\\nPR_snprintf='%s'\\n    \"\n-                \"sprintf='%s'\\n\",\n-                pattern, i, s, buf, sbuf);\n-        PR_smprintf_free(s);\n-        exit(-1);\n-    }\n+static void test_i(char* pattern, int i) {\n+  char* s;\n+  char buf[200];\n+  int n;\n+\n+  /* try all three routines */\n+  s = PR_smprintf(pattern, i);\n+  PR_ASSERT(s != 0);\n+  n = PR_snprintf(buf, sizeof(buf), pattern, i);\n+  PR_ASSERT(n <= sizeof(buf));\n+  sprintf(sbuf, pattern, i);\n+\n+  /* compare results */\n+  if ((strncmp(s, buf, sizeof(buf)) != 0) ||\n+      (strncmp(s, sbuf, sizeof(sbuf)) != 0)) {\n+    fprintf(stderr,\n+            \"pattern='%s' i=%d\\nPR_smprintf='%s'\\nPR_snprintf='%s'\\n    \"\n+            \"sprintf='%s'\\n\",\n+            pattern, i, s, buf, sbuf);\n     PR_smprintf_free(s);\n+    exit(-1);\n+  }\n+  PR_smprintf_free(s);\n }\n \n-static void\n-TestI(void)\n-{\n-    static int nums[] = {\n-        0,\n-        1,\n-        -1,\n-        10,\n-        -10,\n-        32767,\n-        -32768,\n-    };\n-    static char* signs[] = {\n-        \"\",\n-        \"0\",\n-        \"-\",\n-        \"+\",\n-        \" \",\n-        \"0-\",\n-        \"0+\",\n-        \"0 \",\n-        \"-0\",\n-        \"-+\",\n-        \"- \",\n-        \"+0\",\n-        \"+-\",\n-        \"+ \",\n-        \" 0\",\n-        \" -\",\n-        \" +\",\n-        \"0-+\",\n-        \"0- \",\n-        \"0+-\",\n-        \"0+ \",\n-        \"0 -\",\n-        \"0 +\",\n-        \"-0+\",\n-        \"-0 \",\n-        \"-+0\",\n-        \"-+ \",\n-        \"- 0\",\n-        \"- +\",\n-        \"+0-\",\n-        \"+0 \",\n-        \"+-0\",\n-        \"+- \",\n-        \"+ 0\",\n-        \"+ -\",\n-        \" 0-\",\n-        \" 0+\",\n-        \" -0\",\n-        \" -+\",\n-        \" +0\",\n-        \" +-\",\n-        \"0-+ \",\n-        \"0- +\",\n-        \"0+- \",\n-        \"0+ -\",\n-        \"0 -+\",\n-        \"0 +-\",\n-        \"-0+ \",\n-        \"-0 +\",\n-        \"-+0 \",\n-        \"-+ 0\",\n-        \"- 0+\",\n-        \"- +0\",\n-        \"+0- \",\n-        \"+0 -\",\n-        \"+-0 \",\n-        \"+- 0\",\n-        \"+ 0-\",\n-        \"+ -0\",\n-        \" 0-+\",\n-        \" 0+-\",\n-        \" -0+\",\n-        \" -+0\",\n-        \" +0-\",\n-        \" +-0\",\n-    };\n-    static char* precs[] = {\n-        \"\",\n-        \"3\",\n-        \"5\",\n-        \"43\",\n-        \"7.3\",\n-        \"7.5\",\n-        \"7.11\",\n-        \"7.43\",\n-    };\n-    static char* formats[] = { \"d\", \"o\", \"x\", \"u\", \"hd\", \"ho\", \"hx\", \"hu\" };\n-    int f, s, n, p;\n-    char fmt[20];\n-\n-    for (f = 0; f < PR_ARRAY_SIZE(formats); f++) {\n-        for (s = 0; s < PR_ARRAY_SIZE(signs); s++) {\n-            for (p = 0; p < PR_ARRAY_SIZE(precs); p++) {\n-                fmt[0] = '%';\n-                fmt[1] = 0;\n-                if (signs[s]) {\n-                    strcat(fmt, signs[s]);\n-                }\n-                if (precs[p]) {\n-                    strcat(fmt, precs[p]);\n-                }\n-                if (formats[f]) {\n-                    strcat(fmt, formats[f]);\n-                }\n-                for (n = 0; n < PR_ARRAY_SIZE(nums); n++) {\n-                    test_i(fmt, nums[n]);\n-                }\n-            }\n+static void TestI(void) {\n+  static int nums[] = {\n+      0, 1, -1, 10, -10, 32767, -32768,\n+  };\n+  static char* signs[] = {\n+      \"\",     \"0\",    \"-\",    \"+\",    \" \",    \"0-\",   \"0+\",   \"0 \",   \"-0\",\n+      \"-+\",   \"- \",   \"+0\",   \"+-\",   \"+ \",   \" 0\",   \" -\",   \" +\",   \"0-+\",\n+      \"0- \",  \"0+-\",  \"0+ \",  \"0 -\",  \"0 +\",  \"-0+\",  \"-0 \",  \"-+0\",  \"-+ \",\n+      \"- 0\",  \"- +\",  \"+0-\",  \"+0 \",  \"+-0\",  \"+- \",  \"+ 0\",  \"+ -\",  \" 0-\",\n+      \" 0+\",  \" -0\",  \" -+\",  \" +0\",  \" +-\",  \"0-+ \", \"0- +\", \"0+- \", \"0+ -\",\n+      \"0 -+\", \"0 +-\", \"-0+ \", \"-0 +\", \"-+0 \", \"-+ 0\", \"- 0+\", \"- +0\", \"+0- \",\n+      \"+0 -\", \"+-0 \", \"+- 0\", \"+ 0-\", \"+ -0\", \" 0-+\", \" 0+-\", \" -0+\", \" -+0\",\n+      \" +0-\", \" +-0\",\n+  };\n+  static char* precs[] = {\n+      \"\", \"3\", \"5\", \"43\", \"7.3\", \"7.5\", \"7.11\", \"7.43\",\n+  };\n+  static char* formats[] = {\"d\", \"o\", \"x\", \"u\", \"hd\", \"ho\", \"hx\", \"hu\"};\n+  int f, s, n, p;\n+  char fmt[20];\n+\n+  for (f = 0; f < PR_ARRAY_SIZE(formats); f++) {\n+    for (s = 0; s < PR_ARRAY_SIZE(signs); s++) {\n+      for (p = 0; p < PR_ARRAY_SIZE(precs); p++) {\n+        fmt[0] = '%';\n+        fmt[1] = 0;\n+        if (signs[s]) {\n+          strcat(fmt, signs[s]);\n+        }\n+        if (precs[p]) {\n+          strcat(fmt, precs[p]);\n+        }\n+        if (formats[f]) {\n+          strcat(fmt, formats[f]);\n+        }\n+        for (n = 0; n < PR_ARRAY_SIZE(nums); n++) {\n+          test_i(fmt, nums[n]);\n         }\n+      }\n     }\n+  }\n }\n \n /************************************************************************/\n@@ -177,163 +104,93 @@ TestI(void)\n ** Perform a three way test against PR_smprintf, PR_snprintf, and sprintf.\n ** Make sure the results are identical\n */\n-static void\n-test_l(char* pattern, char* spattern, PRInt32 l)\n-{\n-    char* s;\n-    char buf[200];\n-    int n;\n-\n-    /* try all three routines */\n-    s = PR_smprintf(pattern, l);\n-    PR_ASSERT(s != 0);\n-    n = PR_snprintf(buf, sizeof(buf), pattern, l);\n-    PR_ASSERT(n <= sizeof(buf));\n-    sprintf(sbuf, spattern, l);\n-\n-    /* compare results */\n-    if ((strncmp(s, buf, sizeof(buf)) != 0) ||\n-        (strncmp(s, sbuf, sizeof(sbuf)) != 0)) {\n-        fprintf(stderr,\n-                \"pattern='%s' l=%ld\\nPR_smprintf='%s'\\nPR_snprintf='%s'\\n    \"\n-                \"sprintf='%s'\\n\",\n-                pattern, l, s, buf, sbuf);\n-        PR_smprintf_free(s);\n-        exit(-1);\n-    }\n+static void test_l(char* pattern, char* spattern, PRInt32 l) {\n+  char* s;\n+  char buf[200];\n+  int n;\n+\n+  /* try all three routines */\n+  s = PR_smprintf(pattern, l);\n+  PR_ASSERT(s != 0);\n+  n = PR_snprintf(buf, sizeof(buf), pattern, l);\n+  PR_ASSERT(n <= sizeof(buf));\n+  sprintf(sbuf, spattern, l);\n+\n+  /* compare results */\n+  if ((strncmp(s, buf, sizeof(buf)) != 0) ||\n+      (strncmp(s, sbuf, sizeof(sbuf)) != 0)) {\n+    fprintf(stderr,\n+            \"pattern='%s' l=%ld\\nPR_smprintf='%s'\\nPR_snprintf='%s'\\n    \"\n+            \"sprintf='%s'\\n\",\n+            pattern, l, s, buf, sbuf);\n     PR_smprintf_free(s);\n+    exit(-1);\n+  }\n+  PR_smprintf_free(s);\n }\n \n-static void\n-TestL(void)\n-{\n-    static PRInt32 nums[] = {\n-        0,\n-        1,\n-        -1,\n-        10,\n-        -10,\n-        32767,\n-        -32768,\n-        PR_INT32(0x7fffffff),     /* 2147483647L */\n-        -1 - PR_INT32(0x7fffffff) /* -2147483648L */\n-    };\n-    static char* signs[] = {\n-        \"\",\n-        \"0\",\n-        \"-\",\n-        \"+\",\n-        \" \",\n-        \"0-\",\n-        \"0+\",\n-        \"0 \",\n-        \"-0\",\n-        \"-+\",\n-        \"- \",\n-        \"+0\",\n-        \"+-\",\n-        \"+ \",\n-        \" 0\",\n-        \" -\",\n-        \" +\",\n-        \"0-+\",\n-        \"0- \",\n-        \"0+-\",\n-        \"0+ \",\n-        \"0 -\",\n-        \"0 +\",\n-        \"-0+\",\n-        \"-0 \",\n-        \"-+0\",\n-        \"-+ \",\n-        \"- 0\",\n-        \"- +\",\n-        \"+0-\",\n-        \"+0 \",\n-        \"+-0\",\n-        \"+- \",\n-        \"+ 0\",\n-        \"+ -\",\n-        \" 0-\",\n-        \" 0+\",\n-        \" -0\",\n-        \" -+\",\n-        \" +0\",\n-        \" +-\",\n-        \"0-+ \",\n-        \"0- +\",\n-        \"0+- \",\n-        \"0+ -\",\n-        \"0 -+\",\n-        \"0 +-\",\n-        \"-0+ \",\n-        \"-0 +\",\n-        \"-+0 \",\n-        \"-+ 0\",\n-        \"- 0+\",\n-        \"- +0\",\n-        \"+0- \",\n-        \"+0 -\",\n-        \"+-0 \",\n-        \"+- 0\",\n-        \"+ 0-\",\n-        \"+ -0\",\n-        \" 0-+\",\n-        \" 0+-\",\n-        \" -0+\",\n-        \" -+0\",\n-        \" +0-\",\n-        \" +-0\",\n-    };\n-    static char* precs[] = {\n-        \"\",\n-        \"3\",\n-        \"5\",\n-        \"43\",\n-        \".3\",\n-        \".43\",\n-        \"7.3\",\n-        \"7.5\",\n-        \"7.11\",\n-        \"7.43\",\n-    };\n-    static char* formats[] = { \"ld\", \"lo\", \"lx\", \"lu\" };\n+static void TestL(void) {\n+  static PRInt32 nums[] = {\n+      0,\n+      1,\n+      -1,\n+      10,\n+      -10,\n+      32767,\n+      -32768,\n+      PR_INT32(0x7fffffff),     /* 2147483647L */\n+      -1 - PR_INT32(0x7fffffff) /* -2147483648L */\n+  };\n+  static char* signs[] = {\n+      \"\",     \"0\",    \"-\",    \"+\",    \" \",    \"0-\",   \"0+\",   \"0 \",   \"-0\",\n+      \"-+\",   \"- \",   \"+0\",   \"+-\",   \"+ \",   \" 0\",   \" -\",   \" +\",   \"0-+\",\n+      \"0- \",  \"0+-\",  \"0+ \",  \"0 -\",  \"0 +\",  \"-0+\",  \"-0 \",  \"-+0\",  \"-+ \",\n+      \"- 0\",  \"- +\",  \"+0-\",  \"+0 \",  \"+-0\",  \"+- \",  \"+ 0\",  \"+ -\",  \" 0-\",\n+      \" 0+\",  \" -0\",  \" -+\",  \" +0\",  \" +-\",  \"0-+ \", \"0- +\", \"0+- \", \"0+ -\",\n+      \"0 -+\", \"0 +-\", \"-0+ \", \"-0 +\", \"-+0 \", \"-+ 0\", \"- 0+\", \"- +0\", \"+0- \",\n+      \"+0 -\", \"+-0 \", \"+- 0\", \"+ 0-\", \"+ -0\", \" 0-+\", \" 0+-\", \" -0+\", \" -+0\",\n+      \" +0-\", \" +-0\",\n+  };\n+  static char* precs[] = {\n+      \"\", \"3\", \"5\", \"43\", \".3\", \".43\", \"7.3\", \"7.5\", \"7.11\", \"7.43\",\n+  };\n+  static char* formats[] = {\"ld\", \"lo\", \"lx\", \"lu\"};\n \n #if PR_BYTES_PER_INT == 4\n-    static char* sformats[] = { \"d\", \"o\", \"x\", \"u\" };\n+  static char* sformats[] = {\"d\", \"o\", \"x\", \"u\"};\n #elif PR_BYTES_PER_LONG == 4\n-    static char* sformats[] = { \"ld\", \"lo\", \"lx\", \"lu\" };\n+  static char* sformats[] = {\"ld\", \"lo\", \"lx\", \"lu\"};\n #else\n-#error Neither int nor long is 4 bytes on this platform\n+#  error Neither int nor long is 4 bytes on this platform\n #endif\n \n-    int f, s, n, p;\n-    char fmt[40], sfmt[40];\n-\n-    for (f = 0; f < PR_ARRAY_SIZE(formats); f++) {\n-        for (s = 0; s < PR_ARRAY_SIZE(signs); s++) {\n-            for (p = 0; p < PR_ARRAY_SIZE(precs); p++) {\n-                fmt[0] = '%';\n-                fmt[1] = 0;\n-                if (signs[s]) {\n-                    strcat(fmt, signs[s]);\n-                }\n-                if (precs[p]) {\n-                    strcat(fmt, precs[p]);\n-                }\n-                strcpy(sfmt, fmt);\n-                if (formats[f]) {\n-                    strcat(fmt, formats[f]);\n-                }\n-                if (sformats[f]) {\n-                    strcat(sfmt, sformats[f]);\n-                }\n-                for (n = 0; n < PR_ARRAY_SIZE(nums); n++) {\n-                    test_l(fmt, sfmt, nums[n]);\n-                }\n-            }\n+  int f, s, n, p;\n+  char fmt[40], sfmt[40];\n+\n+  for (f = 0; f < PR_ARRAY_SIZE(formats); f++) {\n+    for (s = 0; s < PR_ARRAY_SIZE(signs); s++) {\n+      for (p = 0; p < PR_ARRAY_SIZE(precs); p++) {\n+        fmt[0] = '%';\n+        fmt[1] = 0;\n+        if (signs[s]) {\n+          strcat(fmt, signs[s]);\n+        }\n+        if (precs[p]) {\n+          strcat(fmt, precs[p]);\n         }\n+        strcpy(sfmt, fmt);\n+        if (formats[f]) {\n+          strcat(fmt, formats[f]);\n+        }\n+        if (sformats[f]) {\n+          strcat(sfmt, sformats[f]);\n+        }\n+        for (n = 0; n < PR_ARRAY_SIZE(nums); n++) {\n+          test_l(fmt, sfmt, nums[n]);\n+        }\n+      }\n     }\n+  }\n }\n \n /************************************************************************/\n@@ -342,199 +199,128 @@ TestL(void)\n ** Perform a three way test against PR_smprintf, PR_snprintf, and sprintf.\n ** Make sure the results are identical\n */\n-static void\n-test_ll(char* pattern, char* spattern, PRInt64 l)\n-{\n-    char* s;\n-    char buf[200];\n-    int n;\n-\n-    /* try all three routines */\n-    s = PR_smprintf(pattern, l);\n-    PR_ASSERT(s != 0);\n-    n = PR_snprintf(buf, sizeof(buf), pattern, l);\n-    PR_ASSERT(n <= sizeof(buf));\n+static void test_ll(char* pattern, char* spattern, PRInt64 l) {\n+  char* s;\n+  char buf[200];\n+  int n;\n+\n+  /* try all three routines */\n+  s = PR_smprintf(pattern, l);\n+  PR_ASSERT(s != 0);\n+  n = PR_snprintf(buf, sizeof(buf), pattern, l);\n+  PR_ASSERT(n <= sizeof(buf));\n #if defined(HAVE_LONG_LONG)\n-    sprintf(sbuf, spattern, l);\n-\n-    /* compare results */\n-    if ((strncmp(s, buf, sizeof(buf)) != 0) ||\n-        (strncmp(s, sbuf, sizeof(sbuf)) != 0)) {\n-#if PR_BYTES_PER_LONG == 8\n-#define FORMAT_SPEC \"%ld\"\n-#elif defined(WIN32)\n-#define FORMAT_SPEC \"%I64d\"\n-#else\n-#define FORMAT_SPEC \"%lld\"\n-#endif\n-        fprintf(stderr,\n-                \"pattern='%s' ll=\" FORMAT_SPEC\n-                \"\\nPR_smprintf='%s'\\nPR_snprintf='%s'\\n    sprintf='%s'\\n\",\n-                pattern, l, s, buf, sbuf);\n-        printf(\"FAIL\\n\");\n-        PR_smprintf_free(s);\n-        exit(-1);\n-    }\n+  sprintf(sbuf, spattern, l);\n+\n+  /* compare results */\n+  if ((strncmp(s, buf, sizeof(buf)) != 0) ||\n+      (strncmp(s, sbuf, sizeof(sbuf)) != 0)) {\n+#  if PR_BYTES_PER_LONG == 8\n+#    define FORMAT_SPEC \"%ld\"\n+#  elif defined(WIN32)\n+#    define FORMAT_SPEC \"%I64d\"\n+#  else\n+#    define FORMAT_SPEC \"%lld\"\n+#  endif\n+    fprintf(stderr,\n+            \"pattern='%s' ll=\" FORMAT_SPEC\n+            \"\\nPR_smprintf='%s'\\nPR_snprintf='%s'\\n    sprintf='%s'\\n\",\n+            pattern, l, s, buf, sbuf);\n+    printf(\"FAIL\\n\");\n     PR_smprintf_free(s);\n+    exit(-1);\n+  }\n+  PR_smprintf_free(s);\n #else\n-    /* compare results */\n-    if ((strncmp(s, buf, sizeof(buf)) != 0)) {\n-        fprintf(\n-            stderr,\n-            \"pattern='%s'\\nPR_smprintf='%s'\\nPR_snprintf='%s'\\n    sprintf='%s'\\n\",\n-            pattern, s, buf, sbuf);\n-        printf(\"FAIL\\n\");\n-        PR_smprintf_free(s);\n-        exit(-1);\n-    }\n+  /* compare results */\n+  if ((strncmp(s, buf, sizeof(buf)) != 0)) {\n+    fprintf(\n+        stderr,\n+        \"pattern='%s'\\nPR_smprintf='%s'\\nPR_snprintf='%s'\\n    sprintf='%s'\\n\",\n+        pattern, s, buf, sbuf);\n+    printf(\"FAIL\\n\");\n     PR_smprintf_free(s);\n+    exit(-1);\n+  }\n+  PR_smprintf_free(s);\n #endif\n }\n \n-static void\n-TestLL(void)\n-{\n-    static PRInt64 nums[] = {\n-        LL_INIT(0, 0),\n-        LL_INIT(0, 1),\n-        LL_INIT(0xffffffff, 0xffffffff), /* -1 */\n-        LL_INIT(0, 10),\n-        LL_INIT(0xffffffff, 0xfffffff6), /* -10 */\n-        LL_INIT(0, 32767),\n-        LL_INIT(0xffffffff, 0xffff8000), /* -32768 */\n-        LL_INIT(0, 0x7fffffff),          /* 2147483647 */\n-        LL_INIT(0xffffffff, 0x80000000), /* -2147483648 */\n-        LL_INIT(0x7fffffff, 0xffffffff), /* 9223372036854775807 */\n-        LL_INIT(0x80000000, 0),          /* -9223372036854775808 */\n-        PR_INT64(0),\n-        PR_INT64(1),\n-        PR_INT64(-1),\n-        PR_INT64(10),\n-        PR_INT64(-10),\n-        PR_INT64(32767),\n-        PR_INT64(-32768),\n-        PR_INT64(2147483647),\n-        PR_INT64(-2147483648),\n-        PR_INT64(9223372036854775807),\n-        PR_INT64(-9223372036854775808)\n-    };\n-\n-    static char* signs[] = {\n-        \"\",\n-        \"0\",\n-        \"-\",\n-        \"+\",\n-        \" \",\n-        \"0-\",\n-        \"0+\",\n-        \"0 \",\n-        \"-0\",\n-        \"-+\",\n-        \"- \",\n-        \"+0\",\n-        \"+-\",\n-        \"+ \",\n-        \" 0\",\n-        \" -\",\n-        \" +\",\n-        \"0-+\",\n-        \"0- \",\n-        \"0+-\",\n-        \"0+ \",\n-        \"0 -\",\n-        \"0 +\",\n-        \"-0+\",\n-        \"-0 \",\n-        \"-+0\",\n-        \"-+ \",\n-        \"- 0\",\n-        \"- +\",\n-        \"+0-\",\n-        \"+0 \",\n-        \"+-0\",\n-        \"+- \",\n-        \"+ 0\",\n-        \"+ -\",\n-        \" 0-\",\n-        \" 0+\",\n-        \" -0\",\n-        \" -+\",\n-        \" +0\",\n-        \" +-\",\n-        \"0-+ \",\n-        \"0- +\",\n-        \"0+- \",\n-        \"0+ -\",\n-        \"0 -+\",\n-        \"0 +-\",\n-        \"-0+ \",\n-        \"-0 +\",\n-        \"-+0 \",\n-        \"-+ 0\",\n-        \"- 0+\",\n-        \"- +0\",\n-        \"+0- \",\n-        \"+0 -\",\n-        \"+-0 \",\n-        \"+- 0\",\n-        \"+ 0-\",\n-        \"+ -0\",\n-        \" 0-+\",\n-        \" 0+-\",\n-        \" -0+\",\n-        \" -+0\",\n-        \" +0-\",\n-        \" +-0\",\n-    };\n-    static char* precs[] = {\n-        \"\",\n-        \"3\",\n-        \"5\",\n-        \"43\",\n-        \".3\",\n-        \".43\",\n-        \"7.3\",\n-        \"7.5\",\n-        \"7.11\",\n-        \"7.43\",\n-    };\n-    static char* formats[] = { \"lld\", \"llo\", \"llx\", \"llu\" };\n+static void TestLL(void) {\n+  static PRInt64 nums[] = {\n+      LL_INIT(0, 0),\n+      LL_INIT(0, 1),\n+      LL_INIT(0xffffffff, 0xffffffff), /* -1 */\n+      LL_INIT(0, 10),\n+      LL_INIT(0xffffffff, 0xfffffff6), /* -10 */\n+      LL_INIT(0, 32767),\n+      LL_INIT(0xffffffff, 0xffff8000), /* -32768 */\n+      LL_INIT(0, 0x7fffffff),          /* 2147483647 */\n+      LL_INIT(0xffffffff, 0x80000000), /* -2147483648 */\n+      LL_INIT(0x7fffffff, 0xffffffff), /* 9223372036854775807 */\n+      LL_INIT(0x80000000, 0),          /* -9223372036854775808 */\n+      PR_INT64(0),\n+      PR_INT64(1),\n+      PR_INT64(-1),\n+      PR_INT64(10),\n+      PR_INT64(-10),\n+      PR_INT64(32767),\n+      PR_INT64(-32768),\n+      PR_INT64(2147483647),\n+      PR_INT64(-2147483648),\n+      PR_INT64(9223372036854775807),\n+      PR_INT64(-9223372036854775808)};\n+\n+  static char* signs[] = {\n+      \"\",     \"0\",    \"-\",    \"+\",    \" \",    \"0-\",   \"0+\",   \"0 \",   \"-0\",\n+      \"-+\",   \"- \",   \"+0\",   \"+-\",   \"+ \",   \" 0\",   \" -\",   \" +\",   \"0-+\",\n+      \"0- \",  \"0+-\",  \"0+ \",  \"0 -\",  \"0 +\",  \"-0+\",  \"-0 \",  \"-+0\",  \"-+ \",\n+      \"- 0\",  \"- +\",  \"+0-\",  \"+0 \",  \"+-0\",  \"+- \",  \"+ 0\",  \"+ -\",  \" 0-\",\n+      \" 0+\",  \" -0\",  \" -+\",  \" +0\",  \" +-\",  \"0-+ \", \"0- +\", \"0+- \", \"0+ -\",\n+      \"0 -+\", \"0 +-\", \"-0+ \", \"-0 +\", \"-+0 \", \"-+ 0\", \"- 0+\", \"- +0\", \"+0- \",\n+      \"+0 -\", \"+-0 \", \"+- 0\", \"+ 0-\", \"+ -0\", \" 0-+\", \" 0+-\", \" -0+\", \" -+0\",\n+      \" +0-\", \" +-0\",\n+  };\n+  static char* precs[] = {\n+      \"\", \"3\", \"5\", \"43\", \".3\", \".43\", \"7.3\", \"7.5\", \"7.11\", \"7.43\",\n+  };\n+  static char* formats[] = {\"lld\", \"llo\", \"llx\", \"llu\"};\n \n #if PR_BYTES_PER_LONG == 8\n-    static char* sformats[] = { \"ld\", \"lo\", \"lx\", \"lu\" };\n+  static char* sformats[] = {\"ld\", \"lo\", \"lx\", \"lu\"};\n #elif defined(WIN32)\n-    static char* sformats[] = { \"I64d\", \"I64o\", \"I64x\", \"I64u\" };\n+  static char* sformats[] = {\"I64d\", \"I64o\", \"I64x\", \"I64u\"};\n #else\n-    static char* sformats[] = { \"lld\", \"llo\", \"llx\", \"llu\" };\n+  static char* sformats[] = {\"lld\", \"llo\", \"llx\", \"llu\"};\n #endif\n \n-    int f, s, n, p;\n-    char fmt[40], sfmt[40];\n-\n-    for (f = 0; f < PR_ARRAY_SIZE(formats); f++) {\n-        for (s = 0; s < PR_ARRAY_SIZE(signs); s++) {\n-            for (p = 0; p < PR_ARRAY_SIZE(precs); p++) {\n-                fmt[0] = '%';\n-                fmt[1] = 0;\n-                if (signs[s]) {\n-                    strcat(fmt, signs[s]);\n-                }\n-                if (precs[p]) {\n-                    strcat(fmt, precs[p]);\n-                }\n-                strcpy(sfmt, fmt);\n-                if (formats[f]) {\n-                    strcat(fmt, formats[f]);\n-                }\n-                if (sformats[f]) {\n-                    strcat(sfmt, sformats[f]);\n-                }\n-                for (n = 0; n < PR_ARRAY_SIZE(nums); n++) {\n-                    test_ll(fmt, sfmt, nums[n]);\n-                }\n-            }\n+  int f, s, n, p;\n+  char fmt[40], sfmt[40];\n+\n+  for (f = 0; f < PR_ARRAY_SIZE(formats); f++) {\n+    for (s = 0; s < PR_ARRAY_SIZE(signs); s++) {\n+      for (p = 0; p < PR_ARRAY_SIZE(precs); p++) {\n+        fmt[0] = '%';\n+        fmt[1] = 0;\n+        if (signs[s]) {\n+          strcat(fmt, signs[s]);\n+        }\n+        if (precs[p]) {\n+          strcat(fmt, precs[p]);\n+        }\n+        strcpy(sfmt, fmt);\n+        if (formats[f]) {\n+          strcat(fmt, formats[f]);\n+        }\n+        if (sformats[f]) {\n+          strcat(sfmt, sformats[f]);\n         }\n+        for (n = 0; n < PR_ARRAY_SIZE(nums); n++) {\n+          test_ll(fmt, sfmt, nums[n]);\n+        }\n+      }\n     }\n+  }\n }\n \n /************************************************************************/\n@@ -543,123 +329,94 @@ TestLL(void)\n ** Perform a three way test against PR_smprintf, PR_snprintf, and sprintf.\n ** Make sure the results are identical\n */\n-static void\n-test_s(char* pattern, char* ss)\n-{\n-    char* s;\n-    unsigned char before[8];\n-    char buf[200];\n-    unsigned char after[8];\n-    int n;\n-\n-    memset(before, 0xBB, 8);\n-    memset(after, 0xAA, 8);\n-\n-    /* try all three routines */\n-    s = PR_smprintf(pattern, ss);\n-    PR_ASSERT(s != 0);\n-    n = PR_snprintf(buf, sizeof(buf), pattern, ss);\n-    PR_ASSERT(n <= sizeof(buf));\n-    sprintf(sbuf, pattern, ss);\n-\n-    for (n = 0; n < 8; n++) {\n-        PR_ASSERT(before[n] == 0xBB);\n-        PR_ASSERT(after[n] == 0xAA);\n-    }\n-\n-    /* compare results */\n-    if ((strncmp(s, buf, sizeof(buf)) != 0) ||\n-        (strncmp(s, sbuf, sizeof(sbuf)) != 0)) {\n-        fprintf(stderr,\n-                \"pattern='%s' ss=%.20s\\nPR_smprintf='%s'\\nPR_snprintf='%s'\\n    \"\n-                \"sprintf='%s'\\n\",\n-                pattern, ss, s, buf, sbuf);\n-        printf(\"FAIL\\n\");\n-        PR_smprintf_free(s);\n-        exit(-1);\n-    }\n+static void test_s(char* pattern, char* ss) {\n+  char* s;\n+  unsigned char before[8];\n+  char buf[200];\n+  unsigned char after[8];\n+  int n;\n+\n+  memset(before, 0xBB, 8);\n+  memset(after, 0xAA, 8);\n+\n+  /* try all three routines */\n+  s = PR_smprintf(pattern, ss);\n+  PR_ASSERT(s != 0);\n+  n = PR_snprintf(buf, sizeof(buf), pattern, ss);\n+  PR_ASSERT(n <= sizeof(buf));\n+  sprintf(sbuf, pattern, ss);\n+\n+  for (n = 0; n < 8; n++) {\n+    PR_ASSERT(before[n] == 0xBB);\n+    PR_ASSERT(after[n] == 0xAA);\n+  }\n+\n+  /* compare results */\n+  if ((strncmp(s, buf, sizeof(buf)) != 0) ||\n+      (strncmp(s, sbuf, sizeof(sbuf)) != 0)) {\n+    fprintf(stderr,\n+            \"pattern='%s' ss=%.20s\\nPR_smprintf='%s'\\nPR_snprintf='%s'\\n    \"\n+            \"sprintf='%s'\\n\",\n+            pattern, ss, s, buf, sbuf);\n+    printf(\"FAIL\\n\");\n     PR_smprintf_free(s);\n+    exit(-1);\n+  }\n+  PR_smprintf_free(s);\n }\n \n-static void\n-TestS(void)\n-{\n-    static char* strs[] = {\n-        \"\",\n-        \"a\",\n-        \"abc\",\n-        \"abcde\",\n-        \"abcdefABCDEF\",\n-        \"abcdefghijklmnopqrstuvwxyz0123456789!@#$\"\n-        \"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$\"\n-        \"abcdefghijklmnopqrstuvwxyz0123456789!@#$\",\n-    };\n-    /* '0' is not relevant to printing strings */\n-    static char* signs[] = {\n-        \"\",\n-        \"-\",\n-        \"+\",\n-        \" \",\n-        \"-+\",\n-        \"- \",\n-        \"+-\",\n-        \"+ \",\n-        \" -\",\n-        \" +\",\n-        \"-+ \",\n-        \"- +\",\n-        \"+- \",\n-        \"+ -\",\n-        \" -+\",\n-        \" +-\",\n-    };\n-    static char* precs[] = {\n-        \"\",\n-        \"3\",\n-        \"5\",\n-        \"43\",\n-        \".3\",\n-        \".43\",\n-        \"7.3\",\n-        \"7.5\",\n-        \"7.11\",\n-        \"7.43\",\n-    };\n-    static char* formats[] = { \"s\" };\n-    int f, s, n, p;\n-    char fmt[40];\n-\n-    for (f = 0; f < PR_ARRAY_SIZE(formats); f++) {\n-        for (s = 0; s < PR_ARRAY_SIZE(signs); s++) {\n-            for (p = 0; p < PR_ARRAY_SIZE(precs); p++) {\n-                fmt[0] = '%';\n-                fmt[1] = 0;\n-                if (signs[s]) {\n-                    strcat(fmt + strlen(fmt), signs[s]);\n-                }\n-                if (precs[p]) {\n-                    strcat(fmt + strlen(fmt), precs[p]);\n-                }\n-                if (formats[f]) {\n-                    strcat(fmt + strlen(fmt), formats[f]);\n-                }\n-                for (n = 0; n < PR_ARRAY_SIZE(strs); n++) {\n-                    test_s(fmt, strs[n]);\n-                }\n-            }\n+static void TestS(void) {\n+  static char* strs[] = {\n+      \"\",\n+      \"a\",\n+      \"abc\",\n+      \"abcde\",\n+      \"abcdefABCDEF\",\n+      \"abcdefghijklmnopqrstuvwxyz0123456789!@#$\"\n+      \"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$\"\n+      \"abcdefghijklmnopqrstuvwxyz0123456789!@#$\",\n+  };\n+  /* '0' is not relevant to printing strings */\n+  static char* signs[] = {\n+      \"\",   \"-\",  \"+\",   \" \",   \"-+\",  \"- \",  \"+-\",  \"+ \",\n+      \" -\", \" +\", \"-+ \", \"- +\", \"+- \", \"+ -\", \" -+\", \" +-\",\n+  };\n+  static char* precs[] = {\n+      \"\", \"3\", \"5\", \"43\", \".3\", \".43\", \"7.3\", \"7.5\", \"7.11\", \"7.43\",\n+  };\n+  static char* formats[] = {\"s\"};\n+  int f, s, n, p;\n+  char fmt[40];\n+\n+  for (f = 0; f < PR_ARRAY_SIZE(formats); f++) {\n+    for (s = 0; s < PR_ARRAY_SIZE(signs); s++) {\n+      for (p = 0; p < PR_ARRAY_SIZE(precs); p++) {\n+        fmt[0] = '%';\n+        fmt[1] = 0;\n+        if (signs[s]) {\n+          strcat(fmt + strlen(fmt), signs[s]);\n+        }\n+        if (precs[p]) {\n+          strcat(fmt + strlen(fmt), precs[p]);\n+        }\n+        if (formats[f]) {\n+          strcat(fmt + strlen(fmt), formats[f]);\n+        }\n+        for (n = 0; n < PR_ARRAY_SIZE(strs); n++) {\n+          test_s(fmt, strs[n]);\n         }\n+      }\n     }\n+  }\n }\n \n /************************************************************************/\n \n-int\n-main(int argc, char** argv)\n-{\n-    TestI();\n-    TestL();\n-    TestLL();\n-    TestS();\n-    printf(\"PASS\\n\");\n-    return 0;\n+int main(int argc, char** argv) {\n+  TestI();\n+  TestL();\n+  TestLL();\n+  TestS();\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/stack.c b/nspr/pr/tests/stack.c\nindex d84eaa6..80e8af8 100644\n--- a/nspr/pr/tests/stack.c\n+++ b/nspr/pr/tests/stack.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -18,12 +19,12 @@\n #include \"plgetopt.h\"\n \n typedef struct _DataRecord {\n-    PRInt32 data;\n-    PRStackElem link;\n+  PRInt32 data;\n+  PRStackElem link;\n } DataRecord;\n \n #define RECORD_LINK_PTR(lp) \\\n-    ((DataRecord*)((char*)(lp) - offsetof(DataRecord, link)))\n+  ((DataRecord*)((char*)(lp) - offsetof(DataRecord, link)))\n \n #define MAX_THREAD_CNT 100\n #define DEFAULT_THREAD_CNT 4\n@@ -36,12 +37,11 @@ typedef struct _DataRecord {\n #define SUM_OF_NUMBERS(n) ((n & 1) ? (((n + 1) / 2) * n) : ((n / 2) * (n + 1)))\n \n typedef struct stack_data {\n-    PRStack* list1;\n-    PRStack* list2;\n-    PRInt32 initial_data_value;\n-    PRInt32 data_cnt;\n-    PRInt32 loops;\n-    void* items; /* backing array allocated by the worker, freed by main */\n+  PRStack* list1;\n+  PRStack* list2;\n+  PRInt32 initial_data_value;\n+  PRInt32 data_cnt;\n+  PRInt32 loops;\n } stack_data;\n \n static void stackop(void* arg);\n@@ -51,229 +51,215 @@ static int _debug_on;\n PRFileDesc* output;\n PRFileDesc* errhandle;\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRInt32 rv, cnt, sum;\n-    DataRecord* Item;\n-    PRStack *list1, *list2;\n-    PRStackElem* node;\n-    PRStatus rc;\n-\n-    PRInt32 thread_cnt = DEFAULT_THREAD_CNT;\n-    PRInt32 data_cnt = DEFAULT_DATA_CNT;\n-    PRInt32 loops = DEFAULT_LOOP_CNT;\n-    PRThread** threads;\n-    stack_data* thread_args;\n-\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dt:c:l:\");\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                _debug_on = 1;\n-                break;\n-            case 't': /* thread count */\n-                thread_cnt = atoi(opt->value);\n-                break;\n-            case 'c': /* data count */\n-                data_cnt = atoi(opt->value);\n-                break;\n-            case 'l': /* loop count */\n-                loops = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  PRInt32 rv, cnt, sum;\n+  DataRecord* Item;\n+  PRStack *list1, *list2;\n+  PRStackElem* node;\n+  PRStatus rc;\n+\n+  PRInt32 thread_cnt = DEFAULT_THREAD_CNT;\n+  PRInt32 data_cnt = DEFAULT_DATA_CNT;\n+  PRInt32 loops = DEFAULT_LOOP_CNT;\n+  PRThread** threads;\n+  stack_data* thread_args;\n+\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dt:c:l:\");\n+\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    PR_SetConcurrency(4);\n-\n-    output = PR_GetSpecialFD(PR_StandardOutput);\n-    errhandle = PR_GetSpecialFD(PR_StandardError);\n-    list1 = PR_CreateStack(\"Stack_1\");\n-    if (list1 == NULL) {\n-        PR_fprintf(errhandle, \"PR_CreateStack failed - error %d\\n\", PR_GetError());\n-        return 1;\n-    }\n-\n-    list2 = PR_CreateStack(\"Stack_2\");\n-    if (list2 == NULL) {\n-        PR_fprintf(errhandle, \"PR_CreateStack failed - error %d\\n\", PR_GetError());\n-        return 1;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        _debug_on = 1;\n+        break;\n+      case 't': /* thread count */\n+        thread_cnt = atoi(opt->value);\n+        break;\n+      case 'c': /* data count */\n+        data_cnt = atoi(opt->value);\n+        break;\n+      case 'l': /* loop count */\n+        loops = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n-\n-    threads = (PRThread**)PR_CALLOC(sizeof(PRThread*) * thread_cnt);\n-    thread_args = (stack_data*)PR_CALLOC(sizeof(stack_data) * thread_cnt);\n-\n-    if (_debug_on)\n-        PR_fprintf(output, \"%s: thread_cnt = %d data_cnt = %d\\n\", argv[0],\n-                   thread_cnt, data_cnt);\n-    for (cnt = 0; cnt < thread_cnt; cnt++) {\n-        PRThreadScope scope;\n-\n-        thread_args[cnt].list1 = list1;\n-        thread_args[cnt].list2 = list2;\n-        thread_args[cnt].loops = loops;\n-        thread_args[cnt].data_cnt = data_cnt;\n-        thread_args[cnt].initial_data_value = 1 + cnt * data_cnt;\n-\n-        if (cnt & 1) {\n-            scope = PR_GLOBAL_THREAD;\n-        } else {\n-            scope = PR_LOCAL_THREAD;\n-        }\n-\n-        threads[cnt] =\n-            PR_CreateThread(PR_USER_THREAD, stackop, &thread_args[cnt],\n-                            PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n-        if (threads[cnt] == NULL) {\n-            PR_fprintf(errhandle, \"PR_CreateThread failed - error %d\\n\",\n-                       PR_GetError());\n-            PR_ProcessExit(2);\n-        }\n-        if (_debug_on)\n-            PR_fprintf(output, \"%s: created thread = 0x%x\\n\", argv[0], threads[cnt]);\n-    }\n-\n-    for (cnt = 0; cnt < thread_cnt; cnt++) {\n-        rc = PR_JoinThread(threads[cnt]);\n-        PR_ASSERT(rc == PR_SUCCESS);\n-    }\n-\n-    node = PR_StackPop(list1);\n-    /*\n-     * list1 should be empty\n-     */\n-    if (node != NULL) {\n-        PR_fprintf(errhandle, \"Error - Stack 1 not empty\\n\");\n-        PR_ASSERT(node == NULL);\n-        PR_ProcessExit(4);\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  PR_SetConcurrency(4);\n+\n+  output = PR_GetSpecialFD(PR_StandardOutput);\n+  errhandle = PR_GetSpecialFD(PR_StandardError);\n+  list1 = PR_CreateStack(\"Stack_1\");\n+  if (list1 == NULL) {\n+    PR_fprintf(errhandle, \"PR_CreateStack failed - error %d\\n\", PR_GetError());\n+    return 1;\n+  }\n+\n+  list2 = PR_CreateStack(\"Stack_2\");\n+  if (list2 == NULL) {\n+    PR_fprintf(errhandle, \"PR_CreateStack failed - error %d\\n\", PR_GetError());\n+    return 1;\n+  }\n+\n+  threads = (PRThread**)PR_CALLOC(sizeof(PRThread*) * thread_cnt);\n+  thread_args = (stack_data*)PR_CALLOC(sizeof(stack_data) * thread_cnt);\n+\n+  if (_debug_on)\n+    PR_fprintf(output, \"%s: thread_cnt = %d data_cnt = %d\\n\", argv[0],\n+               thread_cnt, data_cnt);\n+  for (cnt = 0; cnt < thread_cnt; cnt++) {\n+    PRThreadScope scope;\n+\n+    thread_args[cnt].list1 = list1;\n+    thread_args[cnt].list2 = list2;\n+    thread_args[cnt].loops = loops;\n+    thread_args[cnt].data_cnt = data_cnt;\n+    thread_args[cnt].initial_data_value = 1 + cnt * data_cnt;\n+\n+    if (cnt & 1) {\n+      scope = PR_GLOBAL_THREAD;\n+    } else {\n+      scope = PR_LOCAL_THREAD;\n     }\n \n-    cnt = data_cnt * thread_cnt;\n-    sum = 0;\n-    while (cnt-- > 0) {\n-        node = PR_StackPop(list2);\n-        /*\n-         * There should be at least 'cnt' number of records\n-         */\n-        if (node == NULL) {\n-            PR_fprintf(errhandle, \"Error - PR_StackPop returned NULL\\n\");\n-            PR_ProcessExit(3);\n-        }\n-        Item = RECORD_LINK_PTR(node);\n-        sum += Item->data;\n+    threads[cnt] =\n+        PR_CreateThread(PR_USER_THREAD, stackop, &thread_args[cnt],\n+                        PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n+    if (threads[cnt] == NULL) {\n+      PR_fprintf(errhandle, \"PR_CreateThread failed - error %d\\n\",\n+                 PR_GetError());\n+      PR_ProcessExit(2);\n     }\n+    if (_debug_on)\n+      PR_fprintf(output, \"%s: created thread = 0x%x\\n\", argv[0], threads[cnt]);\n+  }\n+\n+  for (cnt = 0; cnt < thread_cnt; cnt++) {\n+    rc = PR_JoinThread(threads[cnt]);\n+    PR_ASSERT(rc == PR_SUCCESS);\n+  }\n+\n+  node = PR_StackPop(list1);\n+  /*\n+   * list1 should be empty\n+   */\n+  if (node != NULL) {\n+    PR_fprintf(errhandle, \"Error - Stack 1 not empty\\n\");\n+    PR_ASSERT(node == NULL);\n+    PR_ProcessExit(4);\n+  }\n+\n+  cnt = data_cnt * thread_cnt;\n+  sum = 0;\n+  while (cnt-- > 0) {\n     node = PR_StackPop(list2);\n     /*\n-     * there should be exactly 'cnt' number of records\n+     * There should be at least 'cnt' number of records\n      */\n-    if (node != NULL) {\n-        PR_fprintf(errhandle, \"Error - Stack 2 not empty\\n\");\n-        PR_ASSERT(node == NULL);\n-        PR_ProcessExit(4);\n-    }\n-    /*\n-     * All records have been popped and summed above, so the per-thread\n-     * backing arrays are no longer referenced and can be freed.\n-     */\n-    for (cnt = 0; cnt < thread_cnt; cnt++) {\n-        if (thread_args[cnt].items != NULL) {\n-            PR_Free(thread_args[cnt].items);\n-        }\n-    }\n-    PR_DELETE(threads);\n-    PR_DELETE(thread_args);\n-\n-    PR_DestroyStack(list1);\n-    PR_DestroyStack(list2);\n-\n-    if (sum == SUM_OF_NUMBERS(data_cnt * thread_cnt)) {\n-        PR_fprintf(output, \"%s successful\\n\", argv[0]);\n-        PR_fprintf(output, \"\\t\\tsum = 0x%x, expected = 0x%x\\n\", sum,\n-                   SUM_OF_NUMBERS(thread_cnt * data_cnt));\n-        return 0;\n-    } else {\n-        PR_fprintf(output, \"%s failed: sum = 0x%x, expected = 0x%x\\n\", argv[0], sum,\n-                   SUM_OF_NUMBERS(data_cnt * thread_cnt));\n-        return 2;\n+    if (node == NULL) {\n+      PR_fprintf(errhandle, \"Error - PR_StackPop returned NULL\\n\");\n+      PR_ProcessExit(3);\n     }\n+    Item = RECORD_LINK_PTR(node);\n+    sum += Item->data;\n+  }\n+  node = PR_StackPop(list2);\n+  /*\n+   * there should be exactly 'cnt' number of records\n+   */\n+  if (node != NULL) {\n+    PR_fprintf(errhandle, \"Error - Stack 2 not empty\\n\");\n+    PR_ASSERT(node == NULL);\n+    PR_ProcessExit(4);\n+  }\n+  PR_DELETE(threads);\n+  PR_DELETE(thread_args);\n+\n+  PR_DestroyStack(list1);\n+  PR_DestroyStack(list2);\n+\n+  if (sum == SUM_OF_NUMBERS(data_cnt * thread_cnt)) {\n+    PR_fprintf(output, \"%s successful\\n\", argv[0]);\n+    PR_fprintf(output, \"\\t\\tsum = 0x%x, expected = 0x%x\\n\", sum,\n+               SUM_OF_NUMBERS(thread_cnt * data_cnt));\n+    return 0;\n+  } else {\n+    PR_fprintf(output, \"%s failed: sum = 0x%x, expected = 0x%x\\n\", argv[0], sum,\n+               SUM_OF_NUMBERS(data_cnt * thread_cnt));\n+    return 2;\n+  }\n }\n \n-static void\n-stackop(void* thread_arg)\n-{\n-    PRInt32 val, cnt, index, loops;\n-    DataRecord *Items, *Item;\n-    PRStack *list1, *list2;\n-    PRStackElem* node;\n-    stack_data* arg = (stack_data*)thread_arg;\n-\n-    val = arg->initial_data_value;\n+static void stackop(void* thread_arg) {\n+  PRInt32 val, cnt, index, loops;\n+  DataRecord *Items, *Item;\n+  PRStack *list1, *list2;\n+  PRStackElem* node;\n+  stack_data* arg = (stack_data*)thread_arg;\n+\n+  val = arg->initial_data_value;\n+  cnt = arg->data_cnt;\n+  loops = arg->loops;\n+  list1 = arg->list1;\n+  list2 = arg->list2;\n+\n+  /*\n+   * allocate memory for the data records\n+   */\n+  Items = (DataRecord*)PR_CALLOC(sizeof(DataRecord) * cnt);\n+  PR_ASSERT(Items != NULL);\n+  index = 0;\n+\n+  if (_debug_on)\n+    PR_fprintf(\n+        output,\n+        \"Thread[0x%x] init_val = %d cnt = %d data1 = 0x%x datan = 0x%x\\n\",\n+        PR_GetCurrentThread(), val, cnt, &Items[0], &Items[cnt - 1]);\n+\n+  /*\n+   * add the data records to list1\n+   */\n+  while (cnt-- > 0) {\n+    Items[index].data = val++;\n+    PR_StackPush(list1, &Items[index].link);\n+    index++;\n+  }\n+\n+  /*\n+   * pop data records from list1 and add them back to list1\n+   * generates contention for the stack accesses\n+   */\n+  while (loops-- > 0) {\n     cnt = arg->data_cnt;\n-    loops = arg->loops;\n-    list1 = arg->list1;\n-    list2 = arg->list2;\n-\n-    /*\n-     * allocate memory for the data records\n-     */\n-    Items = (DataRecord*)PR_CALLOC(sizeof(DataRecord) * cnt);\n-    PR_ASSERT(Items != NULL);\n-    arg->items = Items; /* hand ownership to main for cleanup after the join */\n-    index = 0;\n-\n-    if (_debug_on)\n-        PR_fprintf(\n-            output,\n-            \"Thread[0x%x] init_val = %d cnt = %d data1 = 0x%x datan = 0x%x\\n\",\n-            PR_GetCurrentThread(), val, cnt, &Items[0], &Items[cnt - 1]);\n-\n-    /*\n-     * add the data records to list1\n-     */\n     while (cnt-- > 0) {\n-        Items[index].data = val++;\n-        PR_StackPush(list1, &Items[index].link);\n-        index++;\n+      node = PR_StackPop(list1);\n+      if (node == NULL) {\n+        PR_fprintf(errhandle, \"Error - PR_StackPop returned NULL\\n\");\n+        PR_ASSERT(node != NULL);\n+        PR_ProcessExit(3);\n+      }\n+      PR_StackPush(list1, node);\n     }\n-\n-    /*\n-     * pop data records from list1 and add them back to list1\n-     * generates contention for the stack accesses\n-     */\n-    while (loops-- > 0) {\n-        cnt = arg->data_cnt;\n-        while (cnt-- > 0) {\n-            node = PR_StackPop(list1);\n-            if (node == NULL) {\n-                PR_fprintf(errhandle, \"Error - PR_StackPop returned NULL\\n\");\n-                PR_ASSERT(node != NULL);\n-                PR_ProcessExit(3);\n-            }\n-            PR_StackPush(list1, node);\n-        }\n-    }\n-    /*\n-     * remove the data records from list1 and add them to list2\n-     */\n-    cnt = arg->data_cnt;\n-    while (cnt-- > 0) {\n-        node = PR_StackPop(list1);\n-        if (node == NULL) {\n-            PR_fprintf(errhandle, \"Error - PR_StackPop returned NULL\\n\");\n-            PR_ASSERT(node != NULL);\n-            PR_ProcessExit(3);\n-        }\n-        PR_StackPush(list2, node);\n+  }\n+  /*\n+   * remove the data records from list1 and add them to list2\n+   */\n+  cnt = arg->data_cnt;\n+  while (cnt-- > 0) {\n+    node = PR_StackPop(list1);\n+    if (node == NULL) {\n+      PR_fprintf(errhandle, \"Error - PR_StackPop returned NULL\\n\");\n+      PR_ASSERT(node != NULL);\n+      PR_ProcessExit(3);\n     }\n-    if (_debug_on)\n-        PR_fprintf(output, \"Thread[0x%x] init_val = %d cnt = %d exiting\\n\",\n-                   PR_GetCurrentThread(), val, cnt);\n+    PR_StackPush(list2, node);\n+  }\n+  if (_debug_on)\n+    PR_fprintf(output, \"Thread[0x%x] init_val = %d cnt = %d exiting\\n\",\n+               PR_GetCurrentThread(), val, cnt);\n }\ndiff --git a/nspr/pr/tests/stat.c b/nspr/pr/tests/stat.c\nindex 62c3e4f..fdf0078 100644\n--- a/nspr/pr/tests/stat.c\n+++ b/nspr/pr/tests/stat.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -25,60 +26,52 @@ char* filename = \"/etc/passwd\";\n char* filename = \"..\\\\stat.c\";\n #endif\n \n-static void\n-statPRStat(void)\n-{\n-    PRFileInfo finfo;\n-    PRInt32 index = count;\n+static void statPRStat(void) {\n+  PRFileInfo finfo;\n+  PRInt32 index = count;\n \n-    for (; index--;) {\n-        PR_GetFileInfo(filename, &finfo);\n-    }\n+  for (; index--;) {\n+    PR_GetFileInfo(filename, &finfo);\n+  }\n }\n \n-static void\n-statStat(void)\n-{\n-    struct stat finfo;\n-    PRInt32 index = count;\n+static void statStat(void) {\n+  struct stat finfo;\n+  PRInt32 index = count;\n \n-    for (; index--;) {\n-        stat(filename, &finfo);\n-    }\n+  for (; index--;) {\n+    stat(filename, &finfo);\n+  }\n }\n \n /************************************************************************/\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n-    PRInt32 tot;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n+  PRInt32 tot;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow();\n \n-    d = (double)PR_IntervalToMicroseconds(stop - start);\n-    tot = PR_IntervalToMilliseconds(stop - start);\n+  d = (double)PR_IntervalToMicroseconds(stop - start);\n+  tot = PR_IntervalToMilliseconds(stop - start);\n \n-    printf(\"%40s: %6.2f usec avg, %d msec total\\n\", msg, d / count, tot);\n+  printf(\"%40s: %6.2f usec avg, %d msec total\\n\", msg, d / count, tot);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+int main(int argc, char** argv) {\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    if (argc > 1) {\n-        count = atoi(argv[1]);\n-    } else {\n-        count = DEFAULT_COUNT;\n-    }\n+  if (argc > 1) {\n+    count = atoi(argv[1]);\n+  } else {\n+    count = DEFAULT_COUNT;\n+  }\n \n-    Measure(statPRStat, \"time to call PR_GetFileInfo()\");\n-    Measure(statStat, \"time to call stat()\");\n+  Measure(statPRStat, \"time to call PR_GetFileInfo()\");\n+  Measure(statStat, \"time to call stat()\");\n \n-    PR_Cleanup();\n+  PR_Cleanup();\n }\ndiff --git a/nspr/pr/tests/stdio.c b/nspr/pr/tests/stdio.c\nindex fd38793..4277ea0 100644\n--- a/nspr/pr/tests/stdio.c\n+++ b/nspr/pr/tests/stdio.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -20,29 +21,25 @@\n #include <stdio.h>\n #include <string.h>\n \n-static PRIntn PR_CALLBACK\n-stdio(PRIntn argc, char** argv)\n-{\n-    PRInt32 rv;\n+static PRIntn PR_CALLBACK stdio(PRIntn argc, char** argv) {\n+  PRInt32 rv;\n \n-    PRFileDesc* out = PR_GetSpecialFD(PR_StandardOutput);\n-    PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n+  PRFileDesc* out = PR_GetSpecialFD(PR_StandardOutput);\n+  PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n \n-    rv =\n-        PR_Write(out, \"This to standard out\\n\", strlen(\"This to standard out\\n\"));\n-    PR_ASSERT((PRInt32)strlen(\"This to standard out\\n\") == rv);\n-    rv =\n-        PR_Write(err, \"This to standard err\\n\", strlen(\"This to standard err\\n\"));\n-    PR_ASSERT((PRInt32)strlen(\"This to standard err\\n\") == rv);\n+  rv =\n+      PR_Write(out, \"This to standard out\\n\", strlen(\"This to standard out\\n\"));\n+  PR_ASSERT((PRInt32)strlen(\"This to standard out\\n\") == rv);\n+  rv =\n+      PR_Write(err, \"This to standard err\\n\", strlen(\"This to standard err\\n\"));\n+  PR_ASSERT((PRInt32)strlen(\"This to standard err\\n\") == rv);\n \n-    return 0;\n+  return 0;\n \n } /* stdio */\n \n-int\n-main(int argc, char** argv)\n-{\n-    return PR_Initialize(stdio, argc, argv, 0);\n+int main(int argc, char** argv) {\n+  return PR_Initialize(stdio, argc, argv, 0);\n } /* main */\n \n /* stdio.c */\ndiff --git a/nspr/pr/tests/str2addr.c b/nspr/pr/tests/str2addr.c\nindex 5795057..62cf752 100644\n--- a/nspr/pr/tests/str2addr.c\n+++ b/nspr/pr/tests/str2addr.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -16,35 +17,33 @@\n #define DEFAULT_IPV4_ADDR_STR \"207.200.73.41\"\n \n /* Expected conversion result, in network byte order */\n-static unsigned char default_ipv4_addr[] = { 207, 200, 73, 41 };\n-\n-int\n-main(int argc, char** argv)\n-{\n-    PRNetAddr addr;\n-    const char* addrStr;\n-    unsigned char* bytes;\n-    int idx;\n-\n-    addrStr = DEFAULT_IPV4_ADDR_STR;\n-    if (PR_StringToNetAddr(addrStr, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_StringToNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    if (addr.inet.family != PR_AF_INET) {\n-        fprintf(stderr, \"addr.inet.family should be %d but is %d\\n\", PR_AF_INET,\n-                addr.inet.family);\n-        exit(1);\n-    }\n-    bytes = (unsigned char*)&addr.inet.ip;\n-    for (idx = 0; idx < 4; idx++) {\n-        if (bytes[idx] != default_ipv4_addr[idx]) {\n-            fprintf(stderr, \"byte %d of IPv4 addr should be %d but is %d\\n\", idx,\n-                    default_ipv4_addr[idx], bytes[idx]);\n-            exit(1);\n-        }\n+static unsigned char default_ipv4_addr[] = {207, 200, 73, 41};\n+\n+int main(int argc, char** argv) {\n+  PRNetAddr addr;\n+  const char* addrStr;\n+  unsigned char* bytes;\n+  int idx;\n+\n+  addrStr = DEFAULT_IPV4_ADDR_STR;\n+  if (PR_StringToNetAddr(addrStr, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_StringToNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (addr.inet.family != PR_AF_INET) {\n+    fprintf(stderr, \"addr.inet.family should be %d but is %d\\n\", PR_AF_INET,\n+            addr.inet.family);\n+    exit(1);\n+  }\n+  bytes = (unsigned char*)&addr.inet.ip;\n+  for (idx = 0; idx < 4; idx++) {\n+    if (bytes[idx] != default_ipv4_addr[idx]) {\n+      fprintf(stderr, \"byte %d of IPv4 addr should be %d but is %d\\n\", idx,\n+              default_ipv4_addr[idx], bytes[idx]);\n+      exit(1);\n     }\n+  }\n \n-    printf(\"PASS\\n\");\n-    return 0;\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/strod.c b/nspr/pr/tests/strod.c\nindex a65f1df..2c0cb33 100644\n--- a/nspr/pr/tests/strod.c\n+++ b/nspr/pr/tests/strod.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,64 +11,58 @@\n \n #include <stdlib.h>\n \n-static void\n-Help(void)\n-{\n-    PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n-    PR_fprintf(err, \"Usage: /.strod [-n n] [-l n] [-h]\\n\");\n-    PR_fprintf(err,\n-               \"\\t-n n Number to translate    (default: 1234567890123456789)\\n\");\n-    PR_fprintf(err, \"\\t-l n Times to loop the test (default: 1)\\n\");\n-    PR_fprintf(err, \"\\t-h   This message and nothing else\\n\");\n+static void Help(void) {\n+  PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n+  PR_fprintf(err, \"Usage: /.strod [-n n] [-l n] [-h]\\n\");\n+  PR_fprintf(err,\n+             \"\\t-n n Number to translate    (default: 1234567890123456789)\\n\");\n+  PR_fprintf(err, \"\\t-l n Times to loop the test (default: 1)\\n\");\n+  PR_fprintf(err, \"\\t-h   This message and nothing else\\n\");\n } /* Help */\n \n-static PRIntn PR_CALLBACK\n-RealMain(PRIntn argc, char** argv)\n-{\n-    PLOptStatus os;\n-    PRIntn loops = 1;\n-    PRFloat64 answer;\n-    const char* number = \"1234567890123456789\";\n-    PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"hc:l:\");\n+static PRIntn PR_CALLBACK RealMain(PRIntn argc, char** argv) {\n+  PLOptStatus os;\n+  PRIntn loops = 1;\n+  PRFloat64 answer;\n+  const char* number = \"1234567890123456789\";\n+  PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"hc:l:\");\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'n': /* number to translate */\n-                number = opt->value;\n-                break;\n-            case 'l': /* number of times to run the tests */\n-                loops = atoi(opt->value);\n-                break;\n-            case 'h':     /* user wants some guidance */\n-                Help();   /* so give him an earful */\n-                return 2; /* but not a lot else */\n-                break;\n-            default:\n-                break;\n-        }\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n+    switch (opt->option) {\n+      case 'n': /* number to translate */\n+        number = opt->value;\n+        break;\n+      case 'l': /* number of times to run the tests */\n+        loops = atoi(opt->value);\n+        break;\n+      case 'h':   /* user wants some guidance */\n+        Help();   /* so give him an earful */\n+        return 2; /* but not a lot else */\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    PR_fprintf(err, \"Settings\\n\");\n-    PR_fprintf(err, \"\\tNumber to translate %s\\n\", number);\n-    PR_fprintf(err, \"\\tLoops to run test: %d\\n\", loops);\n+  PR_fprintf(err, \"Settings\\n\");\n+  PR_fprintf(err, \"\\tNumber to translate %s\\n\", number);\n+  PR_fprintf(err, \"\\tLoops to run test: %d\\n\", loops);\n \n-    while (loops--) {\n-        answer = PR_strtod(number, NULL);\n-        PR_fprintf(err, \"Translation = %20.0f\\n\", answer);\n-    }\n-    return 0;\n+  while (loops--) {\n+    answer = PR_strtod(number, NULL);\n+    PR_fprintf(err, \"Translation = %20.0f\\n\", answer);\n+  }\n+  return 0;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv;\n+int main(int argc, char** argv) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\ndiff --git a/nspr/pr/tests/suspend.c b/nspr/pr/tests/suspend.c\nindex 7e78061..b9cf3b3 100644\n--- a/nspr/pr/tests/suspend.c\n+++ b/nspr/pr/tests/suspend.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -16,155 +17,137 @@ PRInt32 alive;\n \n #define SLEEP_TIME 4 /* secs */\n \n-void PR_CALLBACK\n-Level_2_Thread(void* arg)\n-{\n-    PR_Sleep(PR_MillisecondsToInterval(4 * 1000));\n-    printf(\"Level_2_Thread[0x%lx] exiting\\n\", PR_GetCurrentThread());\n-    return;\n+void PR_CALLBACK Level_2_Thread(void* arg) {\n+  PR_Sleep(PR_MillisecondsToInterval(4 * 1000));\n+  printf(\"Level_2_Thread[0x%lx] exiting\\n\", PR_GetCurrentThread());\n+  return;\n }\n \n-void PR_CALLBACK\n-Level_1_Thread(void* arg)\n-{\n-    PRUint32 tmp = (PRUint32)arg;\n-    PRThreadScope scope = (PRThreadScope)tmp;\n-    PRThread* thr;\n-\n-    thr = PR_CreateThreadGCAble(PR_USER_THREAD, Level_2_Thread, NULL,\n-                                PR_PRIORITY_HIGH, scope, PR_JOINABLE_THREAD, 0);\n-\n-    if (!thr) {\n-        printf(\"Could not create thread!\\n\");\n-    } else {\n-        printf(\"Level_1_Thread[0x%lx] created %15s thread 0x%lx\\n\",\n-               PR_GetCurrentThread(),\n-               (scope == PR_GLOBAL_THREAD) ? \"PR_GLOBAL_THREAD\" : \"PR_LOCAL_THREAD\",\n-               thr);\n-        PR_JoinThread(thr);\n-    }\n-    PR_EnterMonitor(mon);\n-    alive--;\n-    PR_Notify(mon);\n-    PR_ExitMonitor(mon);\n-    printf(\"Thread[0x%lx] exiting\\n\", PR_GetCurrentThread());\n+void PR_CALLBACK Level_1_Thread(void* arg) {\n+  PRUint32 tmp = (PRUint32)arg;\n+  PRThreadScope scope = (PRThreadScope)tmp;\n+  PRThread* thr;\n+\n+  thr = PR_CreateThreadGCAble(PR_USER_THREAD, Level_2_Thread, NULL,\n+                              PR_PRIORITY_HIGH, scope, PR_JOINABLE_THREAD, 0);\n+\n+  if (!thr) {\n+    printf(\"Could not create thread!\\n\");\n+  } else {\n+    printf(\"Level_1_Thread[0x%lx] created %15s thread 0x%lx\\n\",\n+           PR_GetCurrentThread(),\n+           (scope == PR_GLOBAL_THREAD) ? \"PR_GLOBAL_THREAD\" : \"PR_LOCAL_THREAD\",\n+           thr);\n+    PR_JoinThread(thr);\n+  }\n+  PR_EnterMonitor(mon);\n+  alive--;\n+  PR_Notify(mon);\n+  PR_ExitMonitor(mon);\n+  printf(\"Thread[0x%lx] exiting\\n\", PR_GetCurrentThread());\n }\n \n-static PRStatus PR_CALLBACK\n-print_thread(PRThread* thread, int i, void* arg)\n-{\n-    PRInt32 words;\n-    PRWord* registers;\n-\n-    printf(\"\\nprint_thread[0x%lx]: %-20s - i = %ld\\n\", thread,\n-           (PR_GLOBAL_THREAD == PR_GetThreadScope(thread)) ? \"PR_GLOBAL_THREAD\"\n-                                                           : \"PR_LOCAL_THREAD\",\n-           i);\n-    registers = PR_GetGCRegisters(thread, 0, (int*)&words);\n-    if (registers)\n-        printf(\"Registers R0 = 0x%x R1 = 0x%x R2 = 0x%x R3 = 0x%x\\n\", registers[0],\n-               registers[1], registers[2], registers[3]);\n-    printf(\"Stack Pointer = 0x%lx\\n\", PR_GetSP(thread));\n-    return PR_SUCCESS;\n+static PRStatus PR_CALLBACK print_thread(PRThread* thread, int i, void* arg) {\n+  PRInt32 words;\n+  PRWord* registers;\n+\n+  printf(\"\\nprint_thread[0x%lx]: %-20s - i = %ld\\n\", thread,\n+         (PR_GLOBAL_THREAD == PR_GetThreadScope(thread)) ? \"PR_GLOBAL_THREAD\"\n+                                                         : \"PR_LOCAL_THREAD\",\n+         i);\n+  registers = PR_GetGCRegisters(thread, 0, (int*)&words);\n+  if (registers)\n+    printf(\"Registers R0 = 0x%x R1 = 0x%x R2 = 0x%x R3 = 0x%x\\n\", registers[0],\n+           registers[1], registers[2], registers[3]);\n+  printf(\"Stack Pointer = 0x%lx\\n\", PR_GetSP(thread));\n+  return PR_SUCCESS;\n }\n \n-static void\n-Level_0_Thread(PRThreadScope scope1, PRThreadScope scope2)\n-{\n-    PRThread* thr;\n-    PRThread* me = PR_GetCurrentThread();\n-    int n;\n-    PRInt32 words;\n-    PRWord* registers;\n-\n-    alive = 0;\n-    mon = PR_NewMonitor();\n-\n-    alive = count;\n-    for (n = 0; n < count; n++) {\n-        thr = PR_CreateThreadGCAble(PR_USER_THREAD, Level_1_Thread, (void*)scope2,\n-                                    PR_PRIORITY_NORMAL, scope1,\n-                                    PR_UNJOINABLE_THREAD, 0);\n-        if (!thr) {\n-            printf(\"Could not create thread!\\n\");\n-            alive--;\n-        }\n-        printf(\n-            \"Level_0_Thread[0x%lx] created %15s thread 0x%lx\\n\",\n-            PR_GetCurrentThread(),\n-            (scope1 == PR_GLOBAL_THREAD) ? \"PR_GLOBAL_THREAD\" : \"PR_LOCAL_THREAD\",\n-            thr);\n-\n-        PR_Sleep(0);\n-    }\n-    PR_SuspendAll();\n-    PR_EnumerateThreads(print_thread, NULL);\n-    registers = PR_GetGCRegisters(me, 1, (int*)&words);\n-    if (registers)\n-        printf(\"My Registers: R0 = 0x%x R1 = 0x%x R2 = 0x%x R3 = 0x%x\\n\",\n-               registers[0], registers[1], registers[2], registers[3]);\n-    printf(\"My Stack Pointer = 0x%lx\\n\", PR_GetSP(me));\n-    PR_ResumeAll();\n-\n-    /* Wait for all threads to exit */\n-    PR_EnterMonitor(mon);\n-    while (alive) {\n-        PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n+static void Level_0_Thread(PRThreadScope scope1, PRThreadScope scope2) {\n+  PRThread* thr;\n+  PRThread* me = PR_GetCurrentThread();\n+  int n;\n+  PRInt32 words;\n+  PRWord* registers;\n+\n+  alive = 0;\n+  mon = PR_NewMonitor();\n+\n+  alive = count;\n+  for (n = 0; n < count; n++) {\n+    thr = PR_CreateThreadGCAble(PR_USER_THREAD, Level_1_Thread, (void*)scope2,\n+                                PR_PRIORITY_NORMAL, scope1,\n+                                PR_UNJOINABLE_THREAD, 0);\n+    if (!thr) {\n+      printf(\"Could not create thread!\\n\");\n+      alive--;\n     }\n-\n-    PR_ExitMonitor(mon);\n-    PR_DestroyMonitor(mon);\n+    printf(\n+        \"Level_0_Thread[0x%lx] created %15s thread 0x%lx\\n\",\n+        PR_GetCurrentThread(),\n+        (scope1 == PR_GLOBAL_THREAD) ? \"PR_GLOBAL_THREAD\" : \"PR_LOCAL_THREAD\",\n+        thr);\n+\n+    PR_Sleep(0);\n+  }\n+  PR_SuspendAll();\n+  PR_EnumerateThreads(print_thread, NULL);\n+  registers = PR_GetGCRegisters(me, 1, (int*)&words);\n+  if (registers)\n+    printf(\"My Registers: R0 = 0x%x R1 = 0x%x R2 = 0x%x R3 = 0x%x\\n\",\n+           registers[0], registers[1], registers[2], registers[3]);\n+  printf(\"My Stack Pointer = 0x%lx\\n\", PR_GetSP(me));\n+  PR_ResumeAll();\n+\n+  /* Wait for all threads to exit */\n+  PR_EnterMonitor(mon);\n+  while (alive) {\n+    PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+\n+  PR_ExitMonitor(mon);\n+  PR_DestroyMonitor(mon);\n }\n \n-static void\n-CreateThreadsUU(void)\n-{\n-    Level_0_Thread(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n+static void CreateThreadsUU(void) {\n+  Level_0_Thread(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n }\n \n-static void\n-CreateThreadsUK(void)\n-{\n-    Level_0_Thread(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n+static void CreateThreadsUK(void) {\n+  Level_0_Thread(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n }\n \n-static void\n-CreateThreadsKU(void)\n-{\n-    Level_0_Thread(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n+static void CreateThreadsKU(void) {\n+  Level_0_Thread(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n }\n \n-static void\n-CreateThreadsKK(void)\n-{\n-    Level_0_Thread(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n+static void CreateThreadsKK(void) {\n+  Level_0_Thread(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+int main(int argc, char** argv) {\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    if (argc > 1) {\n-        count = atoi(argv[1]);\n-    } else {\n-        count = 5;\n-    }\n+  if (argc > 1) {\n+    count = atoi(argv[1]);\n+  } else {\n+    count = 5;\n+  }\n \n-    printf(\"\\n\\n%20s%30s\\n\\n\", \" \", \"Suspend_Resume Test\");\n-    CreateThreadsUU();\n-    CreateThreadsUK();\n-    CreateThreadsKU();\n-    CreateThreadsKK();\n-    PR_SetConcurrency(2);\n+  printf(\"\\n\\n%20s%30s\\n\\n\", \" \", \"Suspend_Resume Test\");\n+  CreateThreadsUU();\n+  CreateThreadsUK();\n+  CreateThreadsKU();\n+  CreateThreadsKK();\n+  PR_SetConcurrency(2);\n \n-    printf(\"\\n%20s%30s\\n\\n\", \" \", \"Added 2nd CPU\\n\");\n+  printf(\"\\n%20s%30s\\n\\n\", \" \", \"Added 2nd CPU\\n\");\n \n-    CreateThreadsUK();\n-    CreateThreadsKK();\n-    CreateThreadsUU();\n-    CreateThreadsKU();\n-    PR_Cleanup();\n+  CreateThreadsUK();\n+  CreateThreadsKK();\n+  CreateThreadsUU();\n+  CreateThreadsKU();\n+  PR_Cleanup();\n \n-    return 0;\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/switch.c b/nspr/pr/tests/switch.c\nindex b3dd3a0..5896d63 100644\n--- a/nspr/pr/tests/switch.c\n+++ b/nspr/pr/tests/switch.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -31,207 +32,199 @@ static PRFileDesc* debug_out = NULL;\n static PRBool debug_mode = PR_FALSE, verbosity = PR_FALSE, failed = PR_FALSE;\n \n typedef struct Shared {\n-    PRLock* ml;\n-    PRCondVar* cv;\n-    PRBool twiddle;\n-    PRThread* thread;\n-    struct Shared* next;\n+  PRLock* ml;\n+  PRCondVar* cv;\n+  PRBool twiddle;\n+  PRThread* thread;\n+  struct Shared* next;\n } Shared;\n \n-static void\n-Help(void)\n-{\n-    debug_out = PR_STDOUT;\n-\n-    PR_fprintf(debug_out,\n-               \"Usage: >./switch [-c n] [-t n] [-d] [-v] [-G] [-C n]\\n\");\n-    PR_fprintf(debug_out, \"-c n\\tloops at thread level (default: %d)\\n\",\n-               DEFAULT_LOOPS);\n-    PR_fprintf(debug_out, \"-t n\\tnumber of threads (default: %d)\\n\",\n-               DEFAULT_THREADS);\n-    PR_fprintf(debug_out, \"-d\\tturn on debugging output (default: FALSE)\\n\");\n-    PR_fprintf(debug_out, \"-v\\tturn on verbose output (default: FALSE)\\n\");\n-    PR_fprintf(debug_out, \"-G\\tglobal threads only (default: FALSE)\\n\");\n-    PR_fprintf(debug_out, \"-C n\\tconcurrency setting (default: 1)\\n\");\n+static void Help(void) {\n+  debug_out = PR_STDOUT;\n+\n+  PR_fprintf(debug_out,\n+             \"Usage: >./switch [-c n] [-t n] [-d] [-v] [-G] [-C n]\\n\");\n+  PR_fprintf(debug_out, \"-c n\\tloops at thread level (default: %d)\\n\",\n+             DEFAULT_LOOPS);\n+  PR_fprintf(debug_out, \"-t n\\tnumber of threads (default: %d)\\n\",\n+             DEFAULT_THREADS);\n+  PR_fprintf(debug_out, \"-d\\tturn on debugging output (default: FALSE)\\n\");\n+  PR_fprintf(debug_out, \"-v\\tturn on verbose output (default: FALSE)\\n\");\n+  PR_fprintf(debug_out, \"-G\\tglobal threads only (default: FALSE)\\n\");\n+  PR_fprintf(debug_out, \"-C n\\tconcurrency setting (default: 1)\\n\");\n } /* Help */\n \n-static void PR_CALLBACK\n-Notified(void* arg)\n-{\n-    Shared* shared = (Shared*)arg;\n-    PRStatus status = PR_SUCCESS;\n-    while (PR_SUCCESS == status) {\n-        PR_Lock(shared->ml);\n-        while (shared->twiddle && (PR_SUCCESS == status)) {\n-            status = PR_WaitCondVar(shared->cv, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        if (verbosity) {\n-            PR_fprintf(debug_out, \"+\");\n-        }\n-        shared->twiddle = PR_TRUE;\n-        shared->next->twiddle = PR_FALSE;\n-        PR_NotifyCondVar(shared->next->cv);\n-        PR_Unlock(shared->ml);\n+static void PR_CALLBACK Notified(void* arg) {\n+  Shared* shared = (Shared*)arg;\n+  PRStatus status = PR_SUCCESS;\n+  while (PR_SUCCESS == status) {\n+    PR_Lock(shared->ml);\n+    while (shared->twiddle && (PR_SUCCESS == status)) {\n+      status = PR_WaitCondVar(shared->cv, PR_INTERVAL_NO_TIMEOUT);\n     }\n+    if (verbosity) {\n+      PR_fprintf(debug_out, \"+\");\n+    }\n+    shared->twiddle = PR_TRUE;\n+    shared->next->twiddle = PR_FALSE;\n+    PR_NotifyCondVar(shared->next->cv);\n+    PR_Unlock(shared->ml);\n+  }\n } /* Notified */\n \n static Shared home;\n-PRIntn PR_CALLBACK\n-Switch(PRIntn argc, char** argv)\n-{\n-    PLOptStatus os;\n-    PRStatus status;\n-    PRBool help = PR_FALSE;\n-    PRUintn concurrency = 1;\n-    Shared *shared, *link;\n-    PRIntervalTime timein, timeout;\n-    PRThreadScope thread_scope = PR_LOCAL_THREAD;\n-    PRUintn thread_count, inner_count, loop_count, average;\n-    PRUintn thread_limit = DEFAULT_THREADS, loop_limit = DEFAULT_LOOPS;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"hdvc:t:C:G\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'v': /* verbose mode */\n-                verbosity = PR_TRUE;\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            case 'c': /* loop counter */\n-                loop_limit = atoi(opt->value);\n-                break;\n-            case 't': /* thread limit */\n-                thread_limit = atoi(opt->value);\n-                break;\n-            case 'C': /* Concurrency limit */\n-                concurrency = atoi(opt->value);\n-                break;\n-            case 'G': /* global threads only */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'h': /* help message */\n-                Help();\n-                help = PR_TRUE;\n-                break;\n-            default:\n-                break;\n-        }\n+PRIntn PR_CALLBACK Switch(PRIntn argc, char** argv) {\n+  PLOptStatus os;\n+  PRStatus status;\n+  PRBool help = PR_FALSE;\n+  PRUintn concurrency = 1;\n+  Shared *shared, *link;\n+  PRIntervalTime timein, timeout;\n+  PRThreadScope thread_scope = PR_LOCAL_THREAD;\n+  PRUintn thread_count, inner_count, loop_count, average;\n+  PRUintn thread_limit = DEFAULT_THREADS, loop_limit = DEFAULT_LOOPS;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"hdvc:t:C:G\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    if (help) {\n-        return -1;\n-    }\n-\n-    if (PR_TRUE == debug_mode) {\n-        debug_out = PR_STDOUT;\n-        PR_fprintf(debug_out, \"Test parameters\\n\");\n-        PR_fprintf(debug_out, \"\\tThreads involved: %d\\n\", thread_limit);\n-        PR_fprintf(debug_out, \"\\tIteration limit: %d\\n\", loop_limit);\n-        PR_fprintf(debug_out, \"\\tConcurrency: %d\\n\", concurrency);\n-        PR_fprintf(debug_out, \"\\tThread type: %s\\n\",\n-                   (PR_GLOBAL_THREAD == thread_scope) ? \"GLOBAL\" : \"LOCAL\");\n+    switch (opt->option) {\n+      case 'v': /* verbose mode */\n+        verbosity = PR_TRUE;\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      case 'c': /* loop counter */\n+        loop_limit = atoi(opt->value);\n+        break;\n+      case 't': /* thread limit */\n+        thread_limit = atoi(opt->value);\n+        break;\n+      case 'C': /* Concurrency limit */\n+        concurrency = atoi(opt->value);\n+        break;\n+      case 'G': /* global threads only */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'h': /* help message */\n+        Help();\n+        help = PR_TRUE;\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    PR_SetConcurrency(concurrency);\n-\n-    link = &home;\n-    home.ml = PR_NewLock();\n-    home.cv = PR_NewCondVar(home.ml);\n-    home.twiddle = PR_FALSE;\n-    home.next = NULL;\n-\n-    timeout = 0;\n-\n-    for (thread_count = 1; thread_count <= thread_limit; ++thread_count) {\n-        shared = PR_NEWZAP(Shared);\n+  if (help) {\n+    return -1;\n+  }\n \n-        shared->ml = home.ml;\n-        shared->cv = PR_NewCondVar(home.ml);\n-        shared->twiddle = PR_TRUE;\n-        shared->next = link;\n-        link = shared;\n+  if (PR_TRUE == debug_mode) {\n+    debug_out = PR_STDOUT;\n+    PR_fprintf(debug_out, \"Test parameters\\n\");\n+    PR_fprintf(debug_out, \"\\tThreads involved: %d\\n\", thread_limit);\n+    PR_fprintf(debug_out, \"\\tIteration limit: %d\\n\", loop_limit);\n+    PR_fprintf(debug_out, \"\\tConcurrency: %d\\n\", concurrency);\n+    PR_fprintf(debug_out, \"\\tThread type: %s\\n\",\n+               (PR_GLOBAL_THREAD == thread_scope) ? \"GLOBAL\" : \"LOCAL\");\n+  }\n+\n+  PR_SetConcurrency(concurrency);\n+\n+  link = &home;\n+  home.ml = PR_NewLock();\n+  home.cv = PR_NewCondVar(home.ml);\n+  home.twiddle = PR_FALSE;\n+  home.next = NULL;\n+\n+  timeout = 0;\n+\n+  for (thread_count = 1; thread_count <= thread_limit; ++thread_count) {\n+    shared = PR_NEWZAP(Shared);\n+\n+    shared->ml = home.ml;\n+    shared->cv = PR_NewCondVar(home.ml);\n+    shared->twiddle = PR_TRUE;\n+    shared->next = link;\n+    link = shared;\n \n-        shared->thread =\n-            PR_CreateThread(PR_USER_THREAD, Notified, shared, PR_PRIORITY_HIGH,\n-                            thread_scope, PR_JOINABLE_THREAD, 0);\n-        PR_ASSERT(shared->thread != NULL);\n-        if (NULL == shared->thread) {\n-            failed = PR_TRUE;\n-        }\n+    shared->thread =\n+        PR_CreateThread(PR_USER_THREAD, Notified, shared, PR_PRIORITY_HIGH,\n+                        thread_scope, PR_JOINABLE_THREAD, 0);\n+    PR_ASSERT(shared->thread != NULL);\n+    if (NULL == shared->thread) {\n+      failed = PR_TRUE;\n     }\n-\n-    for (loop_count = 1; loop_count <= loop_limit; ++loop_count) {\n-        timein = PR_IntervalNow();\n-        for (inner_count = 0; inner_count < INNER_LOOPS; ++inner_count) {\n-            PR_Lock(home.ml);\n-            home.twiddle = PR_TRUE;\n-            shared->twiddle = PR_FALSE;\n-            PR_NotifyCondVar(shared->cv);\n-            while (home.twiddle) {\n-                status = PR_WaitCondVar(home.cv, PR_INTERVAL_NO_TIMEOUT);\n-                if (PR_FAILURE == status) {\n-                    failed = PR_TRUE;\n-                }\n-            }\n-            PR_Unlock(home.ml);\n+  }\n+\n+  for (loop_count = 1; loop_count <= loop_limit; ++loop_count) {\n+    timein = PR_IntervalNow();\n+    for (inner_count = 0; inner_count < INNER_LOOPS; ++inner_count) {\n+      PR_Lock(home.ml);\n+      home.twiddle = PR_TRUE;\n+      shared->twiddle = PR_FALSE;\n+      PR_NotifyCondVar(shared->cv);\n+      while (home.twiddle) {\n+        status = PR_WaitCondVar(home.cv, PR_INTERVAL_NO_TIMEOUT);\n+        if (PR_FAILURE == status) {\n+          failed = PR_TRUE;\n         }\n-        timeout += (PR_IntervalNow() - timein);\n+      }\n+      PR_Unlock(home.ml);\n     }\n-\n-    if (debug_mode) {\n-        average = PR_IntervalToMicroseconds(timeout) /\n-                  (INNER_LOOPS * loop_limit * thread_count);\n-        PR_fprintf(debug_out, \"Average switch times %d usecs for %d threads\\n\",\n-                   average, thread_limit);\n+    timeout += (PR_IntervalNow() - timein);\n+  }\n+\n+  if (debug_mode) {\n+    average = PR_IntervalToMicroseconds(timeout) /\n+              (INNER_LOOPS * loop_limit * thread_count);\n+    PR_fprintf(debug_out, \"Average switch times %d usecs for %d threads\\n\",\n+               average, thread_limit);\n+  }\n+\n+  link = shared;\n+  for (thread_count = 1; thread_count <= thread_limit; ++thread_count) {\n+    if (&home == link) {\n+      break;\n     }\n-\n-    link = shared;\n-    for (thread_count = 1; thread_count <= thread_limit; ++thread_count) {\n-        if (&home == link) {\n-            break;\n-        }\n-        status = PR_Interrupt(link->thread);\n-        if (PR_SUCCESS != status) {\n-            failed = PR_TRUE;\n-            if (debug_mode) {\n-                PL_FPrintError(debug_out, \"Failed to interrupt\");\n-            }\n-        }\n-        link = link->next;\n+    status = PR_Interrupt(link->thread);\n+    if (PR_SUCCESS != status) {\n+      failed = PR_TRUE;\n+      if (debug_mode) {\n+        PL_FPrintError(debug_out, \"Failed to interrupt\");\n+      }\n     }\n-\n-    for (thread_count = 1; thread_count <= thread_limit; ++thread_count) {\n-        link = shared->next;\n-        status = PR_JoinThread(shared->thread);\n-        if (PR_SUCCESS != status) {\n-            failed = PR_TRUE;\n-            if (debug_mode) {\n-                PL_FPrintError(debug_out, \"Failed to join\");\n-            }\n-        }\n-        PR_DestroyCondVar(shared->cv);\n-        PR_DELETE(shared);\n-        if (&home == link) {\n-            break;\n-        }\n-        shared = link;\n+    link = link->next;\n+  }\n+\n+  for (thread_count = 1; thread_count <= thread_limit; ++thread_count) {\n+    link = shared->next;\n+    status = PR_JoinThread(shared->thread);\n+    if (PR_SUCCESS != status) {\n+      failed = PR_TRUE;\n+      if (debug_mode) {\n+        PL_FPrintError(debug_out, \"Failed to join\");\n+      }\n+    }\n+    PR_DestroyCondVar(shared->cv);\n+    PR_DELETE(shared);\n+    if (&home == link) {\n+      break;\n     }\n-    PR_DestroyCondVar(home.cv);\n-    PR_DestroyLock(home.ml);\n+    shared = link;\n+  }\n+  PR_DestroyCondVar(home.cv);\n+  PR_DestroyLock(home.ml);\n \n-    PR_fprintf(PR_STDOUT, ((failed) ? \"FAILED\\n\" : \"PASSED\\n\"));\n-    return ((failed) ? 1 : 0);\n+  PR_fprintf(PR_STDOUT, ((failed) ? \"FAILED\\n\" : \"PASSED\\n\"));\n+  return ((failed) ? 1 : 0);\n } /* Switch */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn result;\n-    result = PR_Initialize(Switch, argc, argv, 0);\n-    return result;\n+int main(int argc, char** argv) {\n+  PRIntn result;\n+  result = PR_Initialize(Switch, argc, argv, 0);\n+  return result;\n } /* main */\n \n /* switch.c */\ndiff --git a/nspr/pr/tests/system.c b/nspr/pr/tests/system.c\nindex a0736f8..1464f69 100644\n--- a/nspr/pr/tests/system.c\n+++ b/nspr/pr/tests/system.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,44 +10,40 @@\n \n #include \"plerror.h\"\n \n-static char* tag[] = { \"PR_SI_HOSTNAME\", \"PR_SI_SYSNAME\", \"PR_SI_RELEASE\",\n-                       \"PR_SI_ARCHITECTURE\" };\n+static char* tag[] = {\"PR_SI_HOSTNAME\", \"PR_SI_SYSNAME\", \"PR_SI_RELEASE\",\n+                      \"PR_SI_ARCHITECTURE\"};\n \n-static PRSysInfo\n-Incr(PRSysInfo* cmd)\n-{\n-    PRIntn tmp = (PRIntn)*cmd + 1;\n-    *cmd = (PRSysInfo)tmp;\n-    return (PRSysInfo)tmp;\n+static PRSysInfo Incr(PRSysInfo* cmd) {\n+  PRIntn tmp = (PRIntn)*cmd + 1;\n+  *cmd = (PRSysInfo)tmp;\n+  return (PRSysInfo)tmp;\n } /* Incr */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRStatus rv;\n-    PRSysInfo cmd;\n-    PRFileDesc* output = PR_GetSpecialFD(PR_StandardOutput);\n-\n-    char* info = (char*)PR_Calloc(SYS_INFO_BUFFER_LENGTH, 1);\n-    for (cmd = PR_SI_HOSTNAME; cmd <= PR_SI_ARCHITECTURE; Incr(&cmd)) {\n-        rv = PR_GetSystemInfo(cmd, info, SYS_INFO_BUFFER_LENGTH);\n-        if (PR_SUCCESS == rv) {\n-            PR_fprintf(output, \"%s: %s\\n\", tag[cmd], info);\n-        } else {\n-            PL_FPrintError(output, tag[cmd]);\n-        }\n+int main(int argc, char** argv) {\n+  PRStatus rv;\n+  PRSysInfo cmd;\n+  PRFileDesc* output = PR_GetSpecialFD(PR_StandardOutput);\n+\n+  char* info = (char*)PR_Calloc(SYS_INFO_BUFFER_LENGTH, 1);\n+  for (cmd = PR_SI_HOSTNAME; cmd <= PR_SI_ARCHITECTURE; Incr(&cmd)) {\n+    rv = PR_GetSystemInfo(cmd, info, SYS_INFO_BUFFER_LENGTH);\n+    if (PR_SUCCESS == rv) {\n+      PR_fprintf(output, \"%s: %s\\n\", tag[cmd], info);\n+    } else {\n+      PL_FPrintError(output, tag[cmd]);\n     }\n-    PR_DELETE(info);\n-\n-    PR_fprintf(output, \"Host page size is %d\\n\", PR_GetPageSize());\n-    PR_fprintf(output, \"Page shift is %d\\n\", PR_GetPageShift());\n-    PR_fprintf(output, \"Memory map alignment is %ld\\n\", PR_GetMemMapAlignment());\n-    PR_fprintf(output, \"Number of processors is: %d\\n\",\n-               PR_GetNumberOfProcessors());\n-    PR_fprintf(output, \"Physical memory size is: %llu\\n\",\n-               PR_GetPhysicalMemorySize());\n-\n-    return 0;\n+  }\n+  PR_DELETE(info);\n+\n+  PR_fprintf(output, \"Host page size is %d\\n\", PR_GetPageSize());\n+  PR_fprintf(output, \"Page shift is %d\\n\", PR_GetPageShift());\n+  PR_fprintf(output, \"Memory map alignment is %ld\\n\", PR_GetMemMapAlignment());\n+  PR_fprintf(output, \"Number of processors is: %d\\n\",\n+             PR_GetNumberOfProcessors());\n+  PR_fprintf(output, \"Physical memory size is: %llu\\n\",\n+             PR_GetPhysicalMemorySize());\n+\n+  return 0;\n } /* main */\n \n /* system.c */\ndiff --git a/nspr/pr/tests/testbit.c b/nspr/pr/tests/testbit.c\nindex 92e0e54..ed4bb63 100644\n--- a/nspr/pr/tests/testbit.c\n+++ b/nspr/pr/tests/testbit.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,99 +12,97 @@\n #include \"nspr.h\"\n \n #define ErrorReport(x) \\\n-    {                  \\\n-        printf((x));   \\\n-        failed = 1;    \\\n-    }\n+  {                    \\\n+    printf((x));       \\\n+    failed = 1;        \\\n+  }\n \n-prbitmap_t myMap[512 / 32] = { 0 };\n+prbitmap_t myMap[512 / 32] = {0};\n \n PRInt32 rc;\n PRInt32 i;\n PRIntn failed = 0;\n \n-int\n-main(int argc, char** argv)\n-{\n-    /*\n-    ** Test bitmap things.\n-    */\n-    if (PR_TEST_BIT(myMap, 0)) {\n-        ErrorReport(\"Test 0.0: Failed\\n\");\n-    }\n-\n-    if (PR_TEST_BIT(myMap, 31)) {\n-        ErrorReport(\"Test 0.1: Failed\\n\");\n-    }\n-\n-    if (PR_TEST_BIT(myMap, 128)) {\n-        ErrorReport(\"Test 0.2: Failed\\n\");\n-    }\n-\n-    if (PR_TEST_BIT(myMap, 129)) {\n-        ErrorReport(\"Test 0.3: Failed\\n\");\n-    }\n-\n-    PR_SET_BIT(myMap, 0);\n-    if (!PR_TEST_BIT(myMap, 0)) {\n-        ErrorReport(\"Test 1.0: Failed\\n\");\n-    }\n-\n-    PR_CLEAR_BIT(myMap, 0);\n-    if (PR_TEST_BIT(myMap, 0)) {\n-        ErrorReport(\"Test 1.0.1: Failed\\n\");\n-    }\n-\n-    PR_SET_BIT(myMap, 31);\n-    if (!PR_TEST_BIT(myMap, 31)) {\n-        ErrorReport(\"Test 1.1: Failed\\n\");\n-    }\n-\n-    PR_CLEAR_BIT(myMap, 31);\n-    if (PR_TEST_BIT(myMap, 31)) {\n-        ErrorReport(\"Test 1.1.1: Failed\\n\");\n-    }\n-\n-    PR_SET_BIT(myMap, 128);\n-    if (!PR_TEST_BIT(myMap, 128)) {\n-        ErrorReport(\"Test 1.2: Failed\\n\");\n-    }\n-\n-    PR_CLEAR_BIT(myMap, 128);\n-    if (PR_TEST_BIT(myMap, 128)) {\n-        ErrorReport(\"Test 1.2.1: Failed\\n\");\n-    }\n-\n-    PR_SET_BIT(myMap, 129);\n-    if (!PR_TEST_BIT(myMap, 129)) {\n-        ErrorReport(\"Test 1.3: Failed\\n\");\n-    }\n-\n-    PR_CLEAR_BIT(myMap, 129);\n-    if (PR_TEST_BIT(myMap, 129)) {\n-        ErrorReport(\"Test 1.3.1: Failed\\n\");\n-    }\n-\n-    /*\n-    ** Test Ceiling and Floor functions and macros\n-    */\n-    if ((rc = PR_CeilingLog2(32)) != 5) {\n-        ErrorReport(\"Test 10.0: Failed\\n\");\n-    }\n-\n-    if ((rc = PR_FloorLog2(32)) != 5) {\n-        ErrorReport(\"Test 10.1: Failed\\n\");\n-    }\n-\n-    /*\n-    ** Evaluate results and exit\n-    */\n-    if (failed) {\n-        printf(\"FAILED\\n\");\n-        return (1);\n-    } else {\n-        printf(\"PASSED\\n\");\n-        return (0);\n-    }\n+int main(int argc, char** argv) {\n+  /*\n+  ** Test bitmap things.\n+  */\n+  if (PR_TEST_BIT(myMap, 0)) {\n+    ErrorReport(\"Test 0.0: Failed\\n\");\n+  }\n+\n+  if (PR_TEST_BIT(myMap, 31)) {\n+    ErrorReport(\"Test 0.1: Failed\\n\");\n+  }\n+\n+  if (PR_TEST_BIT(myMap, 128)) {\n+    ErrorReport(\"Test 0.2: Failed\\n\");\n+  }\n+\n+  if (PR_TEST_BIT(myMap, 129)) {\n+    ErrorReport(\"Test 0.3: Failed\\n\");\n+  }\n+\n+  PR_SET_BIT(myMap, 0);\n+  if (!PR_TEST_BIT(myMap, 0)) {\n+    ErrorReport(\"Test 1.0: Failed\\n\");\n+  }\n+\n+  PR_CLEAR_BIT(myMap, 0);\n+  if (PR_TEST_BIT(myMap, 0)) {\n+    ErrorReport(\"Test 1.0.1: Failed\\n\");\n+  }\n+\n+  PR_SET_BIT(myMap, 31);\n+  if (!PR_TEST_BIT(myMap, 31)) {\n+    ErrorReport(\"Test 1.1: Failed\\n\");\n+  }\n+\n+  PR_CLEAR_BIT(myMap, 31);\n+  if (PR_TEST_BIT(myMap, 31)) {\n+    ErrorReport(\"Test 1.1.1: Failed\\n\");\n+  }\n+\n+  PR_SET_BIT(myMap, 128);\n+  if (!PR_TEST_BIT(myMap, 128)) {\n+    ErrorReport(\"Test 1.2: Failed\\n\");\n+  }\n+\n+  PR_CLEAR_BIT(myMap, 128);\n+  if (PR_TEST_BIT(myMap, 128)) {\n+    ErrorReport(\"Test 1.2.1: Failed\\n\");\n+  }\n+\n+  PR_SET_BIT(myMap, 129);\n+  if (!PR_TEST_BIT(myMap, 129)) {\n+    ErrorReport(\"Test 1.3: Failed\\n\");\n+  }\n+\n+  PR_CLEAR_BIT(myMap, 129);\n+  if (PR_TEST_BIT(myMap, 129)) {\n+    ErrorReport(\"Test 1.3.1: Failed\\n\");\n+  }\n+\n+  /*\n+  ** Test Ceiling and Floor functions and macros\n+  */\n+  if ((rc = PR_CeilingLog2(32)) != 5) {\n+    ErrorReport(\"Test 10.0: Failed\\n\");\n+  }\n+\n+  if ((rc = PR_FloorLog2(32)) != 5) {\n+    ErrorReport(\"Test 10.1: Failed\\n\");\n+  }\n+\n+  /*\n+  ** Evaluate results and exit\n+  */\n+  if (failed) {\n+    printf(\"FAILED\\n\");\n+    return (1);\n+  } else {\n+    printf(\"PASSED\\n\");\n+    return (0);\n+  }\n } /* end main() */\n /* end testbit.c */\ndiff --git a/nspr/pr/tests/testfile.c b/nspr/pr/tests/testfile.c\nindex 9355a27..f8df0a0 100644\n--- a/nspr/pr/tests/testfile.c\n+++ b/nspr/pr/tests/testfile.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -9,30 +10,29 @@\n #include <stdlib.h>\n #include <string.h>\n #ifdef WIN32\n-#include <windows.h>\n-#include <process.h>\n+#  include <windows.h>\n+#  include <process.h>\n #endif\n #if defined(_PR_PTHREADS)\n-#include <pthread.h>\n+#  include <pthread.h>\n #endif\n \n #if defined(XP_UNIX)\n-#include <unistd.h>\n+#  include <unistd.h>\n #endif\n \n static int _debug_on = 0;\n \n #ifdef WINCE\n-#define setbuf(x, y)\n+#  define setbuf(x, y)\n #endif\n \n #ifdef XP_WIN\n-#define mode_t int\n+#  define mode_t int\n #endif\n \n #define DPRINTF(arg) \\\n-    if (_debug_on)   \\\n-    printf arg\n+  if (_debug_on) printf arg\n \n PRLock* lock;\n PRMonitor* mon;\n@@ -46,14 +46,14 @@ int thread_count;\n #define CHUNK_SIZE 512\n \n typedef struct buffer {\n-    char data[BUF_DATA_SIZE];\n+  char data[BUF_DATA_SIZE];\n } buffer;\n \n typedef struct File_Rdwr_Param {\n-    char* pathname;\n-    char* buf;\n-    int offset;\n-    int len;\n+  char* pathname;\n+  char* buf;\n+  int offset;\n+  int len;\n } File_Rdwr_Param;\n \n #ifdef XP_PC\n@@ -84,796 +84,762 @@ typedef void (*nativeStartType)(void*);\n #endif\n \n #if defined(_PR_PTHREADS)\n-static void* PR_CALLBACK\n-DirTestWrapper(void* argunused)\n-{\n-    (void)DirTest(argunused);\n-    return NULL;\n+static void* PR_CALLBACK DirTestWrapper(void* argunused) {\n+  (void)DirTest(argunused);\n+  return NULL;\n }\n #elif defined(WIN32)\n-static unsigned __stdcall\n-DirTestWrapper(void* argunused)\n-{\n-    (void)DirTest(argunused);\n-    return 0;\n+static unsigned __stdcall DirTestWrapper(void* argunused) {\n+  (void)DirTest(argunused);\n+  return 0;\n }\n #else\n-static void PR_CALLBACK\n-DirTestWrapper(void* argunused)\n-{\n-    (void)DirTest(argunused);\n+static void PR_CALLBACK DirTestWrapper(void* argunused) {\n+  (void)DirTest(argunused);\n }\n #endif\n \n-static void PR_CALLBACK\n-DirTestVoid(void* argunused)\n-{\n-    (void)DirTest(argunused);\n+static void PR_CALLBACK DirTestVoid(void* argunused) {\n+  (void)DirTest(argunused);\n }\n \n-PRThread*\n-create_new_thread(PRThreadType type, nativeStartType nativeStart,\n-                  void (*prStart)(void*), void* arg,\n-                  PRThreadPriority priority, PRThreadScope scope,\n-                  PRThreadState state, PRUint32 stackSize,\n-                  PRInt32 index)\n-{\n-    PRInt32 native_thread = 0;\n+PRThread* create_new_thread(PRThreadType type, nativeStartType nativeStart,\n+                            void (*prStart)(void*), void* arg,\n+                            PRThreadPriority priority, PRThreadScope scope,\n+                            PRThreadState state, PRUint32 stackSize,\n+                            PRInt32 index) {\n+  PRInt32 native_thread = 0;\n \n-    PR_ASSERT(state == PR_UNJOINABLE_THREAD);\n+  PR_ASSERT(state == PR_UNJOINABLE_THREAD);\n \n #if defined(_PR_PTHREADS) || defined(WIN32)\n \n-    switch (index % 4) {\n-        case 0:\n-            scope = (PR_LOCAL_THREAD);\n-            break;\n-        case 1:\n-            scope = (PR_GLOBAL_THREAD);\n-            break;\n-        case 2:\n-            scope = (PR_GLOBAL_BOUND_THREAD);\n-            break;\n-        case 3:\n-            native_thread = 1;\n-            break;\n-        default:\n-            PR_NOT_REACHED(\"Invalid scope\");\n-            break;\n-    }\n-    if (native_thread) {\n-#if defined(_PR_PTHREADS)\n-        pthread_t tid;\n-        if (!pthread_create(&tid, NULL, nativeStart, arg)) {\n-            return ((PRThread*)tid);\n-        } else {\n-            return (NULL);\n-        }\n-#else\n-        HANDLE thandle;\n-        unsigned tid;\n-\n-        thandle = (HANDLE)_beginthreadex(NULL, stackSize, nativeStart, arg,\n-                                         STACK_SIZE_PARAM_IS_A_RESERVATION, &tid);\n-        return ((PRThread*)thandle);\n-#endif\n+  switch (index % 4) {\n+    case 0:\n+      scope = (PR_LOCAL_THREAD);\n+      break;\n+    case 1:\n+      scope = (PR_GLOBAL_THREAD);\n+      break;\n+    case 2:\n+      scope = (PR_GLOBAL_BOUND_THREAD);\n+      break;\n+    case 3:\n+      native_thread = 1;\n+      break;\n+    default:\n+      PR_NOT_REACHED(\"Invalid scope\");\n+      break;\n+  }\n+  if (native_thread) {\n+#  if defined(_PR_PTHREADS)\n+    pthread_t tid;\n+    if (!pthread_create(&tid, NULL, nativeStart, arg)) {\n+      return ((PRThread*)tid);\n     } else {\n-        return (\n-            PR_CreateThread(type, prStart, arg, priority, scope, state, stackSize));\n+      return (NULL);\n     }\n-#else\n+#  else\n+    HANDLE thandle;\n+    unsigned tid;\n+\n+    thandle = (HANDLE)_beginthreadex(NULL, stackSize, nativeStart, arg,\n+                                     STACK_SIZE_PARAM_IS_A_RESERVATION, &tid);\n+    return ((PRThread*)thandle);\n+#  endif\n+  } else {\n     return (\n         PR_CreateThread(type, prStart, arg, priority, scope, state, stackSize));\n+  }\n+#else\n+  return (\n+      PR_CreateThread(type, prStart, arg, priority, scope, state, stackSize));\n #endif\n }\n \n-static void PR_CALLBACK\n-File_Write(void* arg)\n-{\n-    PRFileDesc* fd_file;\n-    File_Rdwr_Param* fp = (File_Rdwr_Param*)arg;\n-    char *name, *buf;\n-    int offset, len;\n-\n-    setbuf(stdout, NULL);\n-    name = fp->pathname;\n-    buf = fp->buf;\n-    offset = fp->offset;\n-    len = fp->len;\n-\n-    fd_file = PR_Open(name, PR_RDWR | PR_CREATE_FILE, 0777);\n-    if (fd_file == NULL) {\n-        printf(\"testfile failed to create/open file %s\\n\", name);\n-        return;\n-    }\n-    if (PR_Seek(fd_file, offset, PR_SEEK_SET) < 0) {\n-        printf(\"testfile failed to seek in file %s\\n\", name);\n-        return;\n-    }\n-    if ((PR_Write(fd_file, buf, len)) < 0) {\n-        printf(\"testfile failed to write to file %s\\n\", name);\n-        return;\n-    }\n-    DPRINTF((\"Write out_buf[0] = 0x%x\\n\", (*((int*)buf))));\n-    PR_Close(fd_file);\n-    PR_DELETE(fp);\n-\n-    PR_EnterMonitor(mon);\n-    --thread_count;\n-    PR_Notify(mon);\n-    PR_ExitMonitor(mon);\n+static void PR_CALLBACK File_Write(void* arg) {\n+  PRFileDesc* fd_file;\n+  File_Rdwr_Param* fp = (File_Rdwr_Param*)arg;\n+  char *name, *buf;\n+  int offset, len;\n+\n+  setbuf(stdout, NULL);\n+  name = fp->pathname;\n+  buf = fp->buf;\n+  offset = fp->offset;\n+  len = fp->len;\n+\n+  fd_file = PR_Open(name, PR_RDWR | PR_CREATE_FILE, 0777);\n+  if (fd_file == NULL) {\n+    printf(\"testfile failed to create/open file %s\\n\", name);\n+    return;\n+  }\n+  if (PR_Seek(fd_file, offset, PR_SEEK_SET) < 0) {\n+    printf(\"testfile failed to seek in file %s\\n\", name);\n+    return;\n+  }\n+  if ((PR_Write(fd_file, buf, len)) < 0) {\n+    printf(\"testfile failed to write to file %s\\n\", name);\n+    return;\n+  }\n+  DPRINTF((\"Write out_buf[0] = 0x%x\\n\", (*((int*)buf))));\n+  PR_Close(fd_file);\n+  PR_DELETE(fp);\n+\n+  PR_EnterMonitor(mon);\n+  --thread_count;\n+  PR_Notify(mon);\n+  PR_ExitMonitor(mon);\n }\n \n #if defined(_PR_PTHREADS)\n-static void* PR_CALLBACK\n-File_Write_Wrapper(void* argunused)\n-{\n-    (void)File_Write(argunused);\n-    return NULL;\n+static void* PR_CALLBACK File_Write_Wrapper(void* argunused) {\n+  (void)File_Write(argunused);\n+  return NULL;\n }\n #elif defined(WIN32)\n-static unsigned __stdcall\n-File_Write_Wrapper(void* argunused)\n-{\n-    (void)File_Write(argunused);\n-    return 0;\n+static unsigned __stdcall File_Write_Wrapper(void* argunused) {\n+  (void)File_Write(argunused);\n+  return 0;\n }\n #else\n-static void PR_CALLBACK\n-File_Write_Wrapper(void* argunused)\n-{\n-    (void)File_Write(argunused);\n+static void PR_CALLBACK File_Write_Wrapper(void* argunused) {\n+  (void)File_Write(argunused);\n }\n #endif\n \n-static void PR_CALLBACK\n-File_Read(void* arg)\n-{\n-    PRFileDesc* fd_file;\n-    File_Rdwr_Param* fp = (File_Rdwr_Param*)arg;\n-    char *name, *buf;\n-    int offset, len;\n-\n-    setbuf(stdout, NULL);\n-    name = fp->pathname;\n-    buf = fp->buf;\n-    offset = fp->offset;\n-    len = fp->len;\n-\n-    fd_file = PR_Open(name, PR_RDONLY, 0);\n-    if (fd_file == NULL) {\n-        printf(\"testfile failed to open file %s\\n\", name);\n-        return;\n-    }\n-    if (PR_Seek(fd_file, offset, PR_SEEK_SET) < 0) {\n-        printf(\"testfile failed to seek in file %s\\n\", name);\n-        return;\n-    }\n-    if ((PR_Read(fd_file, buf, len)) < 0) {\n-        printf(\"testfile failed to read to file %s\\n\", name);\n-        return;\n-    }\n-    DPRINTF((\"Read in_buf[0] = 0x%x\\n\", (*((int*)buf))));\n-    PR_Close(fd_file);\n-    PR_DELETE(fp);\n-\n-    PR_EnterMonitor(mon);\n-    --thread_count;\n-    PR_Notify(mon);\n-    PR_ExitMonitor(mon);\n+static void PR_CALLBACK File_Read(void* arg) {\n+  PRFileDesc* fd_file;\n+  File_Rdwr_Param* fp = (File_Rdwr_Param*)arg;\n+  char *name, *buf;\n+  int offset, len;\n+\n+  setbuf(stdout, NULL);\n+  name = fp->pathname;\n+  buf = fp->buf;\n+  offset = fp->offset;\n+  len = fp->len;\n+\n+  fd_file = PR_Open(name, PR_RDONLY, 0);\n+  if (fd_file == NULL) {\n+    printf(\"testfile failed to open file %s\\n\", name);\n+    return;\n+  }\n+  if (PR_Seek(fd_file, offset, PR_SEEK_SET) < 0) {\n+    printf(\"testfile failed to seek in file %s\\n\", name);\n+    return;\n+  }\n+  if ((PR_Read(fd_file, buf, len)) < 0) {\n+    printf(\"testfile failed to read to file %s\\n\", name);\n+    return;\n+  }\n+  DPRINTF((\"Read in_buf[0] = 0x%x\\n\", (*((int*)buf))));\n+  PR_Close(fd_file);\n+  PR_DELETE(fp);\n+\n+  PR_EnterMonitor(mon);\n+  --thread_count;\n+  PR_Notify(mon);\n+  PR_ExitMonitor(mon);\n }\n \n #if defined(_PR_PTHREADS)\n-static void* PR_CALLBACK\n-File_Read_Wrapper(void* argunused)\n-{\n-    (void)File_Read(argunused);\n-    return NULL;\n+static void* PR_CALLBACK File_Read_Wrapper(void* argunused) {\n+  (void)File_Read(argunused);\n+  return NULL;\n }\n #elif defined(WIN32)\n-static unsigned __stdcall\n-File_Read_Wrapper(void* argunused)\n-{\n-    (void)File_Read(argunused);\n-    return 0;\n+static unsigned __stdcall File_Read_Wrapper(void* argunused) {\n+  (void)File_Read(argunused);\n+  return 0;\n }\n #else\n-static void PR_CALLBACK\n-File_Read_Wrapper(void* argunused)\n-{\n-    (void)File_Read(argunused);\n+static void PR_CALLBACK File_Read_Wrapper(void* argunused) {\n+  (void)File_Read(argunused);\n }\n #endif\n \n-static PRInt32\n-Misc_File_Tests(char* pathname)\n-{\n-    PRFileDesc* fd_file;\n-    int len, rv = 0;\n-    PRFileInfo file_info, file_info1;\n-    char tmpname[1024];\n-\n-    setbuf(stdout, NULL);\n-    /*\n-     * Test PR_Available, PR_Seek, PR_GetFileInfo, PR_Rename, PR_Access\n-     */\n-\n-    fd_file = PR_Open(pathname, PR_RDWR | PR_CREATE_FILE, 0777);\n-\n-    if (fd_file == NULL) {\n-        printf(\"testfile failed to create/open file %s\\n\", pathname);\n-        return -1;\n-    }\n-    if (PR_GetOpenFileInfo(fd_file, &file_info) < 0) {\n-        printf(\"testfile PR_GetFileInfo failed on file %s\\n\", pathname);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-    if (PR_Access(pathname, PR_ACCESS_EXISTS) != 0) {\n-        printf(\"testfile PR_Access failed on file %s\\n\", pathname);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-    if (PR_Access(pathname, PR_ACCESS_WRITE_OK) != 0) {\n-        printf(\"testfile PR_Access failed on file %s\\n\", pathname);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-    if (PR_Access(pathname, PR_ACCESS_READ_OK) != 0) {\n-        printf(\"testfile PR_Access failed on file %s\\n\", pathname);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-\n-    if (PR_GetFileInfo(pathname, &file_info) < 0) {\n-        printf(\"testfile PR_GetFileInfo failed on file %s\\n\", pathname);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-    if (file_info.type != PR_FILE_FILE) {\n-        printf(\n-            \"testfile: Error - PR_GetFileInfo returned incorrect type for file \"\n-            \"%s\\n\",\n-            pathname);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-    if (file_info.size != 0) {\n-        printf(\n-            \"testfile PR_GetFileInfo returned incorrect size (%d should be 0) for \"\n-            \"file %s\\n\",\n-            file_info.size, pathname);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-    file_info1 = file_info;\n-\n-    len = PR_Available(fd_file);\n-    if (len < 0) {\n-        printf(\"testfile PR_Available failed on file %s\\n\", pathname);\n-        rv = -1;\n-        goto cleanup;\n-    } else if (len != 0) {\n-        printf(\"testfile PR_Available failed: expected/returned = %d/%d bytes\\n\", 0,\n-               len);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-    if (PR_GetOpenFileInfo(fd_file, &file_info) < 0) {\n-        printf(\"testfile PR_GetFileInfo failed on file %s\\n\", pathname);\n-        goto cleanup;\n-    }\n-    if (LL_NE(file_info.creationTime, file_info1.creationTime)) {\n-        printf(\n-            \"testfile PR_GetFileInfo returned incorrect status-change time: %s\\n\",\n-            pathname);\n-        printf(\"ft = %lld, ft1 = %lld\\n\", (long long)file_info.creationTime,\n-               (long long)file_info1.creationTime);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-    len = PR_Write(fd_file, out_buf->data, CHUNK_SIZE);\n-    if (len < 0) {\n-        printf(\"testfile failed to write to file %s\\n\", pathname);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-    if (PR_GetOpenFileInfo(fd_file, &file_info) < 0) {\n-        printf(\"testfile PR_GetFileInfo failed on file %s\\n\", pathname);\n-        goto cleanup;\n-    }\n-    if (file_info.size != CHUNK_SIZE) {\n-        printf(\n-            \"testfile PR_GetFileInfo returned incorrect size (%d should be %d) for \"\n-            \"file %s\\n\",\n-            file_info.size, CHUNK_SIZE, pathname);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-    if (LL_CMP(file_info.modifyTime, <, file_info1.modifyTime)) {\n-        printf(\"testfile PR_GetFileInfo returned incorrect modify time: %s\\n\",\n-               pathname);\n-        printf(\"ft = %lld, ft1 = %lld\\n\", (long long)file_info.modifyTime,\n-               (long long)file_info1.modifyTime);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-\n-    len = PR_Available(fd_file);\n-    if (len < 0) {\n-        printf(\"testfile PR_Available failed on file %s\\n\", pathname);\n-        rv = -1;\n-        goto cleanup;\n-    } else if (len != 0) {\n-        printf(\"testfile PR_Available failed: expected/returned = %d/%d bytes\\n\", 0,\n-               len);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-\n-    PR_Seek(fd_file, 0, PR_SEEK_SET);\n-    len = PR_Available(fd_file);\n-    if (len < 0) {\n-        printf(\"testfile PR_Available failed on file %s\\n\", pathname);\n-        rv = -1;\n-        goto cleanup;\n-    } else if (len != CHUNK_SIZE) {\n-        printf(\"testfile PR_Available failed: expected/returned = %d/%d bytes\\n\",\n-               CHUNK_SIZE, len);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-    PR_Close(fd_file);\n-\n-    strcpy(tmpname, pathname);\n-    strcat(tmpname, \".RENAMED\");\n-    if (PR_FAILURE == PR_Rename(pathname, tmpname)) {\n-        printf(\"testfile failed to rename file %s\\n\", pathname);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-\n-    fd_file = PR_Open(pathname, PR_RDWR | PR_CREATE_FILE, 0777);\n-    len = PR_Write(fd_file, out_buf->data, CHUNK_SIZE);\n-    PR_Close(fd_file);\n-    if (PR_SUCCESS == PR_Rename(pathname, tmpname)) {\n-        printf(\"testfile renamed to existing file %s\\n\", pathname);\n-    }\n-\n-    if ((PR_Delete(tmpname)) < 0) {\n-        printf(\"testfile failed to unlink file %s\\n\", tmpname);\n-        rv = -1;\n-    }\n+static PRInt32 Misc_File_Tests(char* pathname) {\n+  PRFileDesc* fd_file;\n+  int len, rv = 0;\n+  PRFileInfo file_info, file_info1;\n+  char tmpname[1024];\n+\n+  setbuf(stdout, NULL);\n+  /*\n+   * Test PR_Available, PR_Seek, PR_GetFileInfo, PR_Rename, PR_Access\n+   */\n+\n+  fd_file = PR_Open(pathname, PR_RDWR | PR_CREATE_FILE, 0777);\n+\n+  if (fd_file == NULL) {\n+    printf(\"testfile failed to create/open file %s\\n\", pathname);\n+    return -1;\n+  }\n+  if (PR_GetOpenFileInfo(fd_file, &file_info) < 0) {\n+    printf(\"testfile PR_GetFileInfo failed on file %s\\n\", pathname);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+  if (PR_Access(pathname, PR_ACCESS_EXISTS) != 0) {\n+    printf(\"testfile PR_Access failed on file %s\\n\", pathname);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+  if (PR_Access(pathname, PR_ACCESS_WRITE_OK) != 0) {\n+    printf(\"testfile PR_Access failed on file %s\\n\", pathname);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+  if (PR_Access(pathname, PR_ACCESS_READ_OK) != 0) {\n+    printf(\"testfile PR_Access failed on file %s\\n\", pathname);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+\n+  if (PR_GetFileInfo(pathname, &file_info) < 0) {\n+    printf(\"testfile PR_GetFileInfo failed on file %s\\n\", pathname);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+  if (file_info.type != PR_FILE_FILE) {\n+    printf(\n+        \"testfile: Error - PR_GetFileInfo returned incorrect type for file \"\n+        \"%s\\n\",\n+        pathname);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+  if (file_info.size != 0) {\n+    printf(\n+        \"testfile PR_GetFileInfo returned incorrect size (%d should be 0) for \"\n+        \"file %s\\n\",\n+        file_info.size, pathname);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+  file_info1 = file_info;\n+\n+  len = PR_Available(fd_file);\n+  if (len < 0) {\n+    printf(\"testfile PR_Available failed on file %s\\n\", pathname);\n+    rv = -1;\n+    goto cleanup;\n+  } else if (len != 0) {\n+    printf(\"testfile PR_Available failed: expected/returned = %d/%d bytes\\n\", 0,\n+           len);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+  if (PR_GetOpenFileInfo(fd_file, &file_info) < 0) {\n+    printf(\"testfile PR_GetFileInfo failed on file %s\\n\", pathname);\n+    goto cleanup;\n+  }\n+  if (LL_NE(file_info.creationTime, file_info1.creationTime)) {\n+    printf(\n+        \"testfile PR_GetFileInfo returned incorrect status-change time: %s\\n\",\n+        pathname);\n+    printf(\"ft = %lld, ft1 = %lld\\n\", (long long)file_info.creationTime,\n+           (long long)file_info1.creationTime);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+  len = PR_Write(fd_file, out_buf->data, CHUNK_SIZE);\n+  if (len < 0) {\n+    printf(\"testfile failed to write to file %s\\n\", pathname);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+  if (PR_GetOpenFileInfo(fd_file, &file_info) < 0) {\n+    printf(\"testfile PR_GetFileInfo failed on file %s\\n\", pathname);\n+    goto cleanup;\n+  }\n+  if (file_info.size != CHUNK_SIZE) {\n+    printf(\n+        \"testfile PR_GetFileInfo returned incorrect size (%d should be %d) for \"\n+        \"file %s\\n\",\n+        file_info.size, CHUNK_SIZE, pathname);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+  if (LL_CMP(file_info.modifyTime, <, file_info1.modifyTime)) {\n+    printf(\"testfile PR_GetFileInfo returned incorrect modify time: %s\\n\",\n+           pathname);\n+    printf(\"ft = %lld, ft1 = %lld\\n\", (long long)file_info.modifyTime,\n+           (long long)file_info1.modifyTime);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+\n+  len = PR_Available(fd_file);\n+  if (len < 0) {\n+    printf(\"testfile PR_Available failed on file %s\\n\", pathname);\n+    rv = -1;\n+    goto cleanup;\n+  } else if (len != 0) {\n+    printf(\"testfile PR_Available failed: expected/returned = %d/%d bytes\\n\", 0,\n+           len);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+\n+  PR_Seek(fd_file, 0, PR_SEEK_SET);\n+  len = PR_Available(fd_file);\n+  if (len < 0) {\n+    printf(\"testfile PR_Available failed on file %s\\n\", pathname);\n+    rv = -1;\n+    goto cleanup;\n+  } else if (len != CHUNK_SIZE) {\n+    printf(\"testfile PR_Available failed: expected/returned = %d/%d bytes\\n\",\n+           CHUNK_SIZE, len);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+  PR_Close(fd_file);\n+\n+  strcpy(tmpname, pathname);\n+  strcat(tmpname, \".RENAMED\");\n+  if (PR_FAILURE == PR_Rename(pathname, tmpname)) {\n+    printf(\"testfile failed to rename file %s\\n\", pathname);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+\n+  fd_file = PR_Open(pathname, PR_RDWR | PR_CREATE_FILE, 0777);\n+  len = PR_Write(fd_file, out_buf->data, CHUNK_SIZE);\n+  PR_Close(fd_file);\n+  if (PR_SUCCESS == PR_Rename(pathname, tmpname)) {\n+    printf(\"testfile renamed to existing file %s\\n\", pathname);\n+  }\n+\n+  if ((PR_Delete(tmpname)) < 0) {\n+    printf(\"testfile failed to unlink file %s\\n\", tmpname);\n+    rv = -1;\n+  }\n \n cleanup:\n-    if ((PR_Delete(pathname)) < 0) {\n-        printf(\"testfile failed to unlink file %s\\n\", pathname);\n-        rv = -1;\n-    }\n-    return rv;\n+  if ((PR_Delete(pathname)) < 0) {\n+    printf(\"testfile failed to unlink file %s\\n\", pathname);\n+    rv = -1;\n+  }\n+  return rv;\n }\n \n-static PRInt32 PR_CALLBACK\n-FileTest(void)\n-{\n-    PRDir* fd_dir;\n-    int i, offset, len, rv = 0;\n-    PRThreadScope scope = PR_GLOBAL_THREAD;\n-    File_Rdwr_Param* fparamp;\n-\n-    /*\n-     * Create Test dir\n-     */\n-    if ((PR_MkDir(TEST_DIR, 0777)) < 0) {\n-        printf(\"testfile failed to create dir %s\\n\", TEST_DIR);\n-        return -1;\n-    }\n-    fd_dir = PR_OpenDir(TEST_DIR);\n-    if (fd_dir == NULL) {\n-        printf(\"testfile failed to open dir %s\\n\", TEST_DIR);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-\n-    PR_CloseDir(fd_dir);\n-\n-    strcat(pathname, TEST_DIR);\n-    strcat(pathname, \"/\");\n-    strcat(pathname, FILE_NAME);\n-\n-    in_buf = PR_NEW(buffer);\n-    if (in_buf == NULL) {\n-        printf(\"testfile failed to alloc buffer struct\\n\");\n-        rv = -1;\n-        goto cleanup;\n-    }\n-    out_buf = PR_NEW(buffer);\n-    if (out_buf == NULL) {\n-        printf(\"testfile failed to alloc buffer struct\\n\");\n-        rv = -1;\n-        goto cleanup;\n-    }\n-\n-    /*\n-     * Start a bunch of writer threads\n-     */\n-    offset = 0;\n-    len = CHUNK_SIZE;\n-    PR_EnterMonitor(mon);\n-    for (i = 0; i < NUM_RDWR_THREADS; i++) {\n-        fparamp = PR_NEW(File_Rdwr_Param);\n-        if (fparamp == NULL) {\n-            printf(\"testfile failed to alloc File_Rdwr_Param struct\\n\");\n-            rv = -1;\n-            goto cleanup;\n-        }\n-        fparamp->pathname = pathname;\n-        fparamp->buf = out_buf->data + offset;\n-        fparamp->offset = offset;\n-        fparamp->len = len;\n-        memset(fparamp->buf, i, len);\n-\n-        (void)create_new_thread(PR_USER_THREAD, File_Write_Wrapper, File_Write,\n-                                (void*)fparamp, PR_PRIORITY_NORMAL, scope,\n-                                PR_UNJOINABLE_THREAD, 0, i);\n-        offset += len;\n-    }\n-    thread_count = i;\n-    /* Wait for writer threads to exit */\n-    while (thread_count) {\n-        PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_ExitMonitor(mon);\n-\n-    /*\n-     * Start a bunch of reader threads\n-     */\n-    offset = 0;\n-    len = CHUNK_SIZE;\n-    PR_EnterMonitor(mon);\n-    for (i = 0; i < NUM_RDWR_THREADS; i++) {\n-        fparamp = PR_NEW(File_Rdwr_Param);\n-        if (fparamp == NULL) {\n-            printf(\"testfile failed to alloc File_Rdwr_Param struct\\n\");\n-            rv = -1;\n-            goto cleanup;\n-        }\n-        fparamp->pathname = pathname;\n-        fparamp->buf = in_buf->data + offset;\n-        fparamp->offset = offset;\n-        fparamp->len = len;\n-\n-        (void)create_new_thread(PR_USER_THREAD, File_Read_Wrapper, File_Read,\n-                                (void*)fparamp, PR_PRIORITY_NORMAL, scope,\n-                                PR_UNJOINABLE_THREAD, 0, i);\n-        offset += len;\n-        if ((offset + len) > BUF_DATA_SIZE) {\n-            break;\n-        }\n-    }\n-    thread_count = i;\n-\n-    /* Wait for reader threads to exit */\n-    while (thread_count) {\n-        PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n-    }\n-    PR_ExitMonitor(mon);\n-\n-    if (memcmp(in_buf->data, out_buf->data, offset) != 0) {\n-        printf(\"File Test failed: file data corrupted\\n\");\n-        rv = -1;\n-        goto cleanup;\n-    }\n-\n-    if ((PR_Delete(pathname)) < 0) {\n-        printf(\"testfile failed to unlink file %s\\n\", pathname);\n-        rv = -1;\n-        goto cleanup;\n-    }\n-\n-    /*\n-     * Test PR_Available, PR_Seek, PR_GetFileInfo, PR_Rename, PR_Access\n-     */\n-    if (Misc_File_Tests(pathname) < 0) {\n-        rv = -1;\n-    }\n+static PRInt32 PR_CALLBACK FileTest(void) {\n+  PRDir* fd_dir;\n+  int i, offset, len, rv = 0;\n+  PRThreadScope scope = PR_GLOBAL_THREAD;\n+  File_Rdwr_Param* fparamp;\n+\n+  /*\n+   * Create Test dir\n+   */\n+  if ((PR_MkDir(TEST_DIR, 0777)) < 0) {\n+    printf(\"testfile failed to create dir %s\\n\", TEST_DIR);\n+    return -1;\n+  }\n+  fd_dir = PR_OpenDir(TEST_DIR);\n+  if (fd_dir == NULL) {\n+    printf(\"testfile failed to open dir %s\\n\", TEST_DIR);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+\n+  PR_CloseDir(fd_dir);\n+\n+  strcat(pathname, TEST_DIR);\n+  strcat(pathname, \"/\");\n+  strcat(pathname, FILE_NAME);\n+\n+  in_buf = PR_NEW(buffer);\n+  if (in_buf == NULL) {\n+    printf(\"testfile failed to alloc buffer struct\\n\");\n+    rv = -1;\n+    goto cleanup;\n+  }\n+  out_buf = PR_NEW(buffer);\n+  if (out_buf == NULL) {\n+    printf(\"testfile failed to alloc buffer struct\\n\");\n+    rv = -1;\n+    goto cleanup;\n+  }\n+\n+  /*\n+   * Start a bunch of writer threads\n+   */\n+  offset = 0;\n+  len = CHUNK_SIZE;\n+  PR_EnterMonitor(mon);\n+  for (i = 0; i < NUM_RDWR_THREADS; i++) {\n+    fparamp = PR_NEW(File_Rdwr_Param);\n+    if (fparamp == NULL) {\n+      printf(\"testfile failed to alloc File_Rdwr_Param struct\\n\");\n+      rv = -1;\n+      goto cleanup;\n+    }\n+    fparamp->pathname = pathname;\n+    fparamp->buf = out_buf->data + offset;\n+    fparamp->offset = offset;\n+    fparamp->len = len;\n+    memset(fparamp->buf, i, len);\n+\n+    (void)create_new_thread(PR_USER_THREAD, File_Write_Wrapper, File_Write,\n+                            (void*)fparamp, PR_PRIORITY_NORMAL, scope,\n+                            PR_UNJOINABLE_THREAD, 0, i);\n+    offset += len;\n+  }\n+  thread_count = i;\n+  /* Wait for writer threads to exit */\n+  while (thread_count) {\n+    PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_ExitMonitor(mon);\n+\n+  /*\n+   * Start a bunch of reader threads\n+   */\n+  offset = 0;\n+  len = CHUNK_SIZE;\n+  PR_EnterMonitor(mon);\n+  for (i = 0; i < NUM_RDWR_THREADS; i++) {\n+    fparamp = PR_NEW(File_Rdwr_Param);\n+    if (fparamp == NULL) {\n+      printf(\"testfile failed to alloc File_Rdwr_Param struct\\n\");\n+      rv = -1;\n+      goto cleanup;\n+    }\n+    fparamp->pathname = pathname;\n+    fparamp->buf = in_buf->data + offset;\n+    fparamp->offset = offset;\n+    fparamp->len = len;\n+\n+    (void)create_new_thread(PR_USER_THREAD, File_Read_Wrapper, File_Read,\n+                            (void*)fparamp, PR_PRIORITY_NORMAL, scope,\n+                            PR_UNJOINABLE_THREAD, 0, i);\n+    offset += len;\n+    if ((offset + len) > BUF_DATA_SIZE) {\n+      break;\n+    }\n+  }\n+  thread_count = i;\n+\n+  /* Wait for reader threads to exit */\n+  while (thread_count) {\n+    PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+  PR_ExitMonitor(mon);\n+\n+  if (memcmp(in_buf->data, out_buf->data, offset) != 0) {\n+    printf(\"File Test failed: file data corrupted\\n\");\n+    rv = -1;\n+    goto cleanup;\n+  }\n+\n+  if ((PR_Delete(pathname)) < 0) {\n+    printf(\"testfile failed to unlink file %s\\n\", pathname);\n+    rv = -1;\n+    goto cleanup;\n+  }\n+\n+  /*\n+   * Test PR_Available, PR_Seek, PR_GetFileInfo, PR_Rename, PR_Access\n+   */\n+  if (Misc_File_Tests(pathname) < 0) {\n+    rv = -1;\n+  }\n \n cleanup:\n-    if ((PR_RmDir(TEST_DIR)) < 0) {\n-        printf(\"testfile failed to rmdir %s\\n\", TEST_DIR);\n-        rv = -1;\n-    }\n-    return rv;\n+  if ((PR_RmDir(TEST_DIR)) < 0) {\n+    printf(\"testfile failed to rmdir %s\\n\", TEST_DIR);\n+    rv = -1;\n+  }\n+  return rv;\n }\n \n struct dirtest_arg {\n-    PRMonitor* mon;\n-    PRInt32 done;\n+  PRMonitor* mon;\n+  PRInt32 done;\n };\n \n-static PRInt32\n-RunDirTest(void)\n-{\n-    int i;\n-    PRThread* t;\n-    PRMonitor* mon;\n-    struct dirtest_arg thrarg;\n-\n-    mon = PR_NewMonitor();\n-    if (!mon) {\n-        printf(\"RunDirTest: Error - failed to create monitor\\n\");\n-        dirtest_failed = 1;\n-        return -1;\n+static PRInt32 RunDirTest(void) {\n+  int i;\n+  PRThread* t;\n+  PRMonitor* mon;\n+  struct dirtest_arg thrarg;\n+\n+  mon = PR_NewMonitor();\n+  if (!mon) {\n+    printf(\"RunDirTest: Error - failed to create monitor\\n\");\n+    dirtest_failed = 1;\n+    return -1;\n+  }\n+  thrarg.mon = mon;\n+\n+  for (i = 0; i < NUM_DIRTEST_THREADS; i++) {\n+    thrarg.done = 0;\n+    t = create_new_thread(PR_USER_THREAD, DirTestWrapper, DirTestVoid, &thrarg,\n+                          PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n+                          PR_UNJOINABLE_THREAD, 0, i);\n+    if (!t) {\n+      printf(\"RunDirTest: Error - failed to create thread\\n\");\n+      dirtest_failed = 1;\n+      return -1;\n     }\n-    thrarg.mon = mon;\n-\n-    for (i = 0; i < NUM_DIRTEST_THREADS; i++) {\n-        thrarg.done = 0;\n-        t = create_new_thread(PR_USER_THREAD, DirTestWrapper, DirTestVoid, &thrarg,\n-                              PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,\n-                              PR_UNJOINABLE_THREAD, 0, i);\n-        if (!t) {\n-            printf(\"RunDirTest: Error - failed to create thread\\n\");\n-            dirtest_failed = 1;\n-            return -1;\n-        }\n-        PR_EnterMonitor(mon);\n-        while (!thrarg.done) {\n-            PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n-        }\n-        PR_ExitMonitor(mon);\n+    PR_EnterMonitor(mon);\n+    while (!thrarg.done) {\n+      PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n     }\n-    PR_DestroyMonitor(mon);\n-    return 0;\n+    PR_ExitMonitor(mon);\n+  }\n+  PR_DestroyMonitor(mon);\n+  return 0;\n }\n \n-static PRInt32 PR_CALLBACK\n-DirTest(void* arg)\n-{\n-    struct dirtest_arg* tinfo = (struct dirtest_arg*)arg;\n-    PRFileDesc* fd_file;\n-    PRDir* fd_dir;\n-    int i;\n-    int path_len;\n-    PRDirEntry* dirEntry;\n-    PRFileInfo info;\n-    PRInt32 num_files = 0;\n+static PRInt32 PR_CALLBACK DirTest(void* arg) {\n+  struct dirtest_arg* tinfo = (struct dirtest_arg*)arg;\n+  PRFileDesc* fd_file;\n+  PRDir* fd_dir;\n+  int i;\n+  int path_len;\n+  PRDirEntry* dirEntry;\n+  PRFileInfo info;\n+  PRInt32 num_files = 0;\n #if defined(XP_PC) && defined(WIN32)\n-    HANDLE hfile;\n+  HANDLE hfile;\n #endif\n \n #define FILES_IN_DIR 20\n \n-    /*\n-     * Create Test dir\n-     */\n-    DPRINTF((\"Creating test dir %s\\n\", TEST_DIR));\n-    if ((PR_MkDir(TEST_DIR, 0777)) < 0) {\n-        printf(\"testfile failed to create dir %s [%d, %d]\\n\", TEST_DIR,\n-               PR_GetError(), PR_GetOSError());\n-        return -1;\n-    }\n-    fd_dir = PR_OpenDir(TEST_DIR);\n-    if (fd_dir == NULL) {\n-        printf(\"testfile failed to open dirctory %s [%d, %d]\\n\", TEST_DIR,\n-               PR_GetError(), PR_GetOSError());\n-        return -1;\n-    }\n-\n-    strcpy(pathname, TEST_DIR);\n-    strcat(pathname, \"/\");\n-    strcat(pathname, FILE_NAME);\n-    path_len = strlen(pathname);\n-\n-    for (i = 0; i < FILES_IN_DIR; i++) {\n-        sprintf(pathname + path_len, \"%d%s\", i, \"\");\n-\n-        DPRINTF((\"Creating test file %s\\n\", pathname));\n+  /*\n+   * Create Test dir\n+   */\n+  DPRINTF((\"Creating test dir %s\\n\", TEST_DIR));\n+  if ((PR_MkDir(TEST_DIR, 0777)) < 0) {\n+    printf(\"testfile failed to create dir %s [%d, %d]\\n\", TEST_DIR,\n+           PR_GetError(), PR_GetOSError());\n+    return -1;\n+  }\n+  fd_dir = PR_OpenDir(TEST_DIR);\n+  if (fd_dir == NULL) {\n+    printf(\"testfile failed to open dirctory %s [%d, %d]\\n\", TEST_DIR,\n+           PR_GetError(), PR_GetOSError());\n+    return -1;\n+  }\n+\n+  strcpy(pathname, TEST_DIR);\n+  strcat(pathname, \"/\");\n+  strcat(pathname, FILE_NAME);\n+  path_len = strlen(pathname);\n+\n+  for (i = 0; i < FILES_IN_DIR; i++) {\n+    sprintf(pathname + path_len, \"%d%s\", i, \"\");\n+\n+    DPRINTF((\"Creating test file %s\\n\", pathname));\n \n-        fd_file = PR_Open(pathname, PR_RDWR | PR_CREATE_FILE, 0777);\n-\n-        if (fd_file == NULL) {\n-            printf(\"testfile failed to create/open file %s [%d, %d]\\n\", pathname,\n-                   PR_GetError(), PR_GetOSError());\n-            return -1;\n-        }\n-        PR_Close(fd_file);\n-    }\n-#if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32))\n-    /*\n-     * Create a hidden file - a platform-dependent operation\n-     */\n-    strcpy(pathname, TEST_DIR);\n-    strcat(pathname, \"/\");\n-    strcat(pathname, HIDDEN_FILE_NAME);\n-#if defined(XP_UNIX)\n-    DPRINTF((\"Creating hidden test file %s\\n\", pathname));\n     fd_file = PR_Open(pathname, PR_RDWR | PR_CREATE_FILE, 0777);\n \n     if (fd_file == NULL) {\n-        printf(\"testfile failed to create/open hidden file %s [%d, %d]\\n\", pathname,\n-               PR_GetError(), PR_GetOSError());\n-        return -1;\n+      printf(\"testfile failed to create/open file %s [%d, %d]\\n\", pathname,\n+             PR_GetError(), PR_GetOSError());\n+      return -1;\n     }\n-\n     PR_Close(fd_file);\n-\n-#elif defined(WINCE)\n-    DPRINTF((\"Creating hidden test file %s\\n\", pathname));\n-    MultiByteToWideChar(CP_ACP, 0, pathname, -1, wPathname, 256);\n-    hfile =\n-        CreateFile(wPathname, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,\n-                   NULL, CREATE_NEW, FILE_ATTRIBUTE_HIDDEN, NULL);\n-    if (hfile == INVALID_HANDLE_VALUE) {\n-        printf(\"testfile failed to create/open hidden file %s [0, %d]\\n\", pathname,\n-               GetLastError());\n-        return -1;\n-    }\n-    CloseHandle(hfile);\n-\n-#elif defined(XP_PC) && defined(WIN32)\n-    DPRINTF((\"Creating hidden test file %s\\n\", pathname));\n-    hfile = CreateFile(pathname, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,\n-                       NULL, CREATE_NEW, FILE_ATTRIBUTE_HIDDEN, NULL);\n-    if (hfile == INVALID_HANDLE_VALUE) {\n-        printf(\"testfile failed to create/open hidden file %s [0, %d]\\n\", pathname,\n-               GetLastError());\n-        return -1;\n-    }\n-    CloseHandle(hfile);\n-\n-#endif /* XP_UNIX */\n+  }\n+#if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32))\n+  /*\n+   * Create a hidden file - a platform-dependent operation\n+   */\n+  strcpy(pathname, TEST_DIR);\n+  strcat(pathname, \"/\");\n+  strcat(pathname, HIDDEN_FILE_NAME);\n+#  if defined(XP_UNIX)\n+  DPRINTF((\"Creating hidden test file %s\\n\", pathname));\n+  fd_file = PR_Open(pathname, PR_RDWR | PR_CREATE_FILE, 0777);\n+\n+  if (fd_file == NULL) {\n+    printf(\"testfile failed to create/open hidden file %s [%d, %d]\\n\", pathname,\n+           PR_GetError(), PR_GetOSError());\n+    return -1;\n+  }\n+\n+  PR_Close(fd_file);\n+\n+#  elif defined(WINCE)\n+  DPRINTF((\"Creating hidden test file %s\\n\", pathname));\n+  MultiByteToWideChar(CP_ACP, 0, pathname, -1, wPathname, 256);\n+  hfile =\n+      CreateFile(wPathname, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,\n+                 NULL, CREATE_NEW, FILE_ATTRIBUTE_HIDDEN, NULL);\n+  if (hfile == INVALID_HANDLE_VALUE) {\n+    printf(\"testfile failed to create/open hidden file %s [0, %d]\\n\", pathname,\n+           GetLastError());\n+    return -1;\n+  }\n+  CloseHandle(hfile);\n+\n+#  elif defined(XP_PC) && defined(WIN32)\n+  DPRINTF((\"Creating hidden test file %s\\n\", pathname));\n+  hfile = CreateFile(pathname, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,\n+                     NULL, CREATE_NEW, FILE_ATTRIBUTE_HIDDEN, NULL);\n+  if (hfile == INVALID_HANDLE_VALUE) {\n+    printf(\"testfile failed to create/open hidden file %s [0, %d]\\n\", pathname,\n+           GetLastError());\n+    return -1;\n+  }\n+  CloseHandle(hfile);\n+\n+#  endif /* XP_UNIX */\n \n #endif /* XP_UNIX || (XP_PC && WIN32) */\n \n-    if (PR_FAILURE == PR_CloseDir(fd_dir)) {\n-        printf(\"testfile failed to close dirctory %s [%d, %d]\\n\", TEST_DIR,\n-               PR_GetError(), PR_GetOSError());\n-        return -1;\n-    }\n-    fd_dir = PR_OpenDir(TEST_DIR);\n-    if (fd_dir == NULL) {\n-        printf(\"testfile failed to reopen dirctory %s [%d, %d]\\n\", TEST_DIR,\n-               PR_GetError(), PR_GetOSError());\n-        return -1;\n-    }\n-\n-    /*\n-     * List all files, including hidden files\n-     */\n-    DPRINTF((\"Listing all files in directory %s\\n\", TEST_DIR));\n+  if (PR_FAILURE == PR_CloseDir(fd_dir)) {\n+    printf(\"testfile failed to close dirctory %s [%d, %d]\\n\", TEST_DIR,\n+           PR_GetError(), PR_GetOSError());\n+    return -1;\n+  }\n+  fd_dir = PR_OpenDir(TEST_DIR);\n+  if (fd_dir == NULL) {\n+    printf(\"testfile failed to reopen dirctory %s [%d, %d]\\n\", TEST_DIR,\n+           PR_GetError(), PR_GetOSError());\n+    return -1;\n+  }\n+\n+  /*\n+   * List all files, including hidden files\n+   */\n+  DPRINTF((\"Listing all files in directory %s\\n\", TEST_DIR));\n #if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32))\n-    num_files = FILES_IN_DIR + 1;\n+  num_files = FILES_IN_DIR + 1;\n #else\n-    num_files = FILES_IN_DIR;\n+  num_files = FILES_IN_DIR;\n #endif\n-    while ((dirEntry = PR_ReadDir(fd_dir, PR_SKIP_BOTH)) != NULL) {\n-        num_files--;\n-        strcpy(pathname, TEST_DIR);\n-        strcat(pathname, \"/\");\n-        strcat(pathname, dirEntry->name);\n-        DPRINTF((\"\\t%s\\n\", dirEntry->name));\n-\n-        if ((PR_GetFileInfo(pathname, &info)) < 0) {\n-            printf(\"testfile failed to GetFileInfo file %s [%d, %d]\\n\", pathname,\n-                   PR_GetError(), PR_GetOSError());\n-            return -1;\n-        }\n-\n-        if (info.type != PR_FILE_FILE) {\n-            printf(\"testfile incorrect fileinfo for file %s [%d, %d]\\n\", pathname,\n-                   PR_GetError(), PR_GetOSError());\n-            return -1;\n-        }\n-    }\n-    if (num_files != 0) {\n-        printf(\"testfile failed to find all files in directory %s [%d, %d]\\n\",\n-               TEST_DIR, PR_GetError(), PR_GetOSError());\n-        return -1;\n-    }\n-\n-    PR_CloseDir(fd_dir);\n-\n-#if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32))\n-\n-    /*\n-     * List all files, except hidden files\n-     */\n-\n-    fd_dir = PR_OpenDir(TEST_DIR);\n-    if (fd_dir == NULL) {\n-        printf(\"testfile failed to reopen dirctory %s [%d, %d]\\n\", TEST_DIR,\n-               PR_GetError(), PR_GetOSError());\n-        return -1;\n-    }\n-\n-    DPRINTF((\"Listing non-hidden files in directory %s\\n\", TEST_DIR));\n-    while ((dirEntry = PR_ReadDir(fd_dir, PR_SKIP_HIDDEN)) != NULL) {\n-        DPRINTF((\"\\t%s\\n\", dirEntry->name));\n-        if (!strcmp(HIDDEN_FILE_NAME, dirEntry->name)) {\n-            printf(\"testfile found hidden file %s\\n\", pathname);\n-            return -1;\n-        }\n-    }\n-    /*\n-     * Delete hidden file\n-     */\n+  while ((dirEntry = PR_ReadDir(fd_dir, PR_SKIP_BOTH)) != NULL) {\n+    num_files--;\n     strcpy(pathname, TEST_DIR);\n     strcat(pathname, \"/\");\n-    strcat(pathname, HIDDEN_FILE_NAME);\n-    if (PR_FAILURE == PR_Delete(pathname)) {\n-        printf(\"testfile failed to delete hidden file %s [%d, %d]\\n\", pathname,\n-               PR_GetError(), PR_GetOSError());\n-        return -1;\n-    }\n-\n-    PR_CloseDir(fd_dir);\n-#endif /* XP_UNIX || (XP_PC && WIN32) */\n+    strcat(pathname, dirEntry->name);\n+    DPRINTF((\"\\t%s\\n\", dirEntry->name));\n \n-    strcpy(renamename, TEST_DIR);\n-    strcat(renamename, \".RENAMED\");\n-    if (PR_FAILURE == PR_Rename(TEST_DIR, renamename)) {\n-        printf(\"testfile failed to rename directory %s [%d, %d]\\n\", TEST_DIR,\n-               PR_GetError(), PR_GetOSError());\n-        return -1;\n+    if ((PR_GetFileInfo(pathname, &info)) < 0) {\n+      printf(\"testfile failed to GetFileInfo file %s [%d, %d]\\n\", pathname,\n+             PR_GetError(), PR_GetOSError());\n+      return -1;\n     }\n \n-    if (PR_FAILURE == PR_MkDir(TEST_DIR, 0777)) {\n-        printf(\"testfile failed to recreate dir %s [%d, %d]\\n\", TEST_DIR,\n-               PR_GetError(), PR_GetOSError());\n-        return -1;\n-    }\n-    if (PR_SUCCESS == PR_Rename(renamename, TEST_DIR)) {\n-        printf(\"testfile renamed directory to existing name %s\\n\", renamename);\n-        return -1;\n+    if (info.type != PR_FILE_FILE) {\n+      printf(\"testfile incorrect fileinfo for file %s [%d, %d]\\n\", pathname,\n+             PR_GetError(), PR_GetOSError());\n+      return -1;\n     }\n+  }\n+  if (num_files != 0) {\n+    printf(\"testfile failed to find all files in directory %s [%d, %d]\\n\",\n+           TEST_DIR, PR_GetError(), PR_GetOSError());\n+    return -1;\n+  }\n \n-    if (PR_FAILURE == PR_RmDir(TEST_DIR)) {\n-        printf(\"testfile failed to rmdir %s [%d, %d]\\n\", TEST_DIR, PR_GetError(),\n-               PR_GetOSError());\n-        return -1;\n-    }\n+  PR_CloseDir(fd_dir);\n \n-    if (PR_FAILURE == PR_Rename(renamename, TEST_DIR)) {\n-        printf(\"testfile failed to rename directory %s [%d, %d]\\n\", renamename,\n-               PR_GetError(), PR_GetOSError());\n-        return -1;\n-    }\n-    fd_dir = PR_OpenDir(TEST_DIR);\n-    if (fd_dir == NULL) {\n-        printf(\"testfile failed to reopen directory %s [%d, %d]\\n\", TEST_DIR,\n-               PR_GetError(), PR_GetOSError());\n-        return -1;\n-    }\n+#if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32))\n \n-    strcpy(pathname, TEST_DIR);\n-    strcat(pathname, \"/\");\n-    strcat(pathname, FILE_NAME);\n-    path_len = strlen(pathname);\n+  /*\n+   * List all files, except hidden files\n+   */\n+\n+  fd_dir = PR_OpenDir(TEST_DIR);\n+  if (fd_dir == NULL) {\n+    printf(\"testfile failed to reopen dirctory %s [%d, %d]\\n\", TEST_DIR,\n+           PR_GetError(), PR_GetOSError());\n+    return -1;\n+  }\n+\n+  DPRINTF((\"Listing non-hidden files in directory %s\\n\", TEST_DIR));\n+  while ((dirEntry = PR_ReadDir(fd_dir, PR_SKIP_HIDDEN)) != NULL) {\n+    DPRINTF((\"\\t%s\\n\", dirEntry->name));\n+    if (!strcmp(HIDDEN_FILE_NAME, dirEntry->name)) {\n+      printf(\"testfile found hidden file %s\\n\", pathname);\n+      return -1;\n+    }\n+  }\n+  /*\n+   * Delete hidden file\n+   */\n+  strcpy(pathname, TEST_DIR);\n+  strcat(pathname, \"/\");\n+  strcat(pathname, HIDDEN_FILE_NAME);\n+  if (PR_FAILURE == PR_Delete(pathname)) {\n+    printf(\"testfile failed to delete hidden file %s [%d, %d]\\n\", pathname,\n+           PR_GetError(), PR_GetOSError());\n+    return -1;\n+  }\n+\n+  PR_CloseDir(fd_dir);\n+#endif /* XP_UNIX || (XP_PC && WIN32) */\n \n-    for (i = 0; i < FILES_IN_DIR; i++) {\n-        sprintf(pathname + path_len, \"%d%s\", i, \"\");\n+  strcpy(renamename, TEST_DIR);\n+  strcat(renamename, \".RENAMED\");\n+  if (PR_FAILURE == PR_Rename(TEST_DIR, renamename)) {\n+    printf(\"testfile failed to rename directory %s [%d, %d]\\n\", TEST_DIR,\n+           PR_GetError(), PR_GetOSError());\n+    return -1;\n+  }\n+\n+  if (PR_FAILURE == PR_MkDir(TEST_DIR, 0777)) {\n+    printf(\"testfile failed to recreate dir %s [%d, %d]\\n\", TEST_DIR,\n+           PR_GetError(), PR_GetOSError());\n+    return -1;\n+  }\n+  if (PR_SUCCESS == PR_Rename(renamename, TEST_DIR)) {\n+    printf(\"testfile renamed directory to existing name %s\\n\", renamename);\n+    return -1;\n+  }\n+\n+  if (PR_FAILURE == PR_RmDir(TEST_DIR)) {\n+    printf(\"testfile failed to rmdir %s [%d, %d]\\n\", TEST_DIR, PR_GetError(),\n+           PR_GetOSError());\n+    return -1;\n+  }\n+\n+  if (PR_FAILURE == PR_Rename(renamename, TEST_DIR)) {\n+    printf(\"testfile failed to rename directory %s [%d, %d]\\n\", renamename,\n+           PR_GetError(), PR_GetOSError());\n+    return -1;\n+  }\n+  fd_dir = PR_OpenDir(TEST_DIR);\n+  if (fd_dir == NULL) {\n+    printf(\"testfile failed to reopen directory %s [%d, %d]\\n\", TEST_DIR,\n+           PR_GetError(), PR_GetOSError());\n+    return -1;\n+  }\n+\n+  strcpy(pathname, TEST_DIR);\n+  strcat(pathname, \"/\");\n+  strcat(pathname, FILE_NAME);\n+  path_len = strlen(pathname);\n+\n+  for (i = 0; i < FILES_IN_DIR; i++) {\n+    sprintf(pathname + path_len, \"%d%s\", i, \"\");\n \n-        if (PR_FAILURE == PR_Delete(pathname)) {\n-            printf(\"testfile failed to delete file %s [%d, %d]\\n\", pathname,\n-                   PR_GetError(), PR_GetOSError());\n-            return -1;\n-        }\n+    if (PR_FAILURE == PR_Delete(pathname)) {\n+      printf(\"testfile failed to delete file %s [%d, %d]\\n\", pathname,\n+             PR_GetError(), PR_GetOSError());\n+      return -1;\n     }\n+  }\n \n-    PR_CloseDir(fd_dir);\n+  PR_CloseDir(fd_dir);\n \n-    if (PR_FAILURE == PR_RmDir(TEST_DIR)) {\n-        printf(\"testfile failed to rmdir %s [%d, %d]\\n\", TEST_DIR, PR_GetError(),\n-               PR_GetOSError());\n-        return -1;\n-    }\n-    PR_EnterMonitor(tinfo->mon);\n-    tinfo->done = 1;\n-    PR_Notify(tinfo->mon);\n-    PR_ExitMonitor(tinfo->mon);\n+  if (PR_FAILURE == PR_RmDir(TEST_DIR)) {\n+    printf(\"testfile failed to rmdir %s [%d, %d]\\n\", TEST_DIR, PR_GetError(),\n+           PR_GetOSError());\n+    return -1;\n+  }\n+  PR_EnterMonitor(tinfo->mon);\n+  tinfo->done = 1;\n+  PR_Notify(tinfo->mon);\n+  PR_ExitMonitor(tinfo->mon);\n \n-    return 0;\n+  return 0;\n }\n /************************************************************************/\n \n@@ -881,74 +847,72 @@ DirTest(void* arg)\n  * Test file and directory NSPR APIs\n  */\n \n-int\n-main(int argc, char** argv)\n-{\n+int main(int argc, char** argv) {\n #ifdef WIN32\n-    PRUint32 len;\n+  PRUint32 len;\n #endif\n #if defined(XP_UNIX)\n-    int opt;\n-    extern char* optarg;\n-    extern int optind;\n+  int opt;\n+  extern char* optarg;\n+  extern int optind;\n #endif\n #if defined(XP_UNIX)\n-    while ((opt = getopt(argc, argv, \"d\")) != EOF) {\n-        switch (opt) {\n-            case 'd':\n-                _debug_on = 1;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n+  while ((opt = getopt(argc, argv, \"d\")) != EOF) {\n+    switch (opt) {\n+      case 'd':\n+        _debug_on = 1;\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n #endif\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    mon = PR_NewMonitor();\n-    if (mon == NULL) {\n-        printf(\"testfile: PR_NewMonitor failed\\n\");\n-        exit(2);\n-    }\n+  mon = PR_NewMonitor();\n+  if (mon == NULL) {\n+    printf(\"testfile: PR_NewMonitor failed\\n\");\n+    exit(2);\n+  }\n #ifdef WIN32\n \n-#ifdef WINCE\n-    {\n-        WCHAR tdir[TMPDIR_LEN];\n-        len = GetTempPath(TMPDIR_LEN, tdir);\n-        if ((len > 0) && (len < (TMPDIR_LEN - 6))) {\n-            /*\n-             * enough space for prdir\n-             */\n-            WideCharToMultiByte(CP_ACP, 0, tdir, -1, testdir, TMPDIR_LEN, 0, 0);\n-        }\n-    }\n-#else\n-    len = GetTempPath(TMPDIR_LEN, testdir);\n-#endif /* WINCE */\n-\n+#  ifdef WINCE\n+  {\n+    WCHAR tdir[TMPDIR_LEN];\n+    len = GetTempPath(TMPDIR_LEN, tdir);\n     if ((len > 0) && (len < (TMPDIR_LEN - 6))) {\n-        /*\n-         * enough space for prdir\n-         */\n-        strcpy((testdir + len), \"prdir\");\n-        TEST_DIR = testdir;\n-        printf(\"TEST_DIR = %s\\n\", TEST_DIR);\n+      /*\n+       * enough space for prdir\n+       */\n+      WideCharToMultiByte(CP_ACP, 0, tdir, -1, testdir, TMPDIR_LEN, 0, 0);\n     }\n-#endif /* WIN32 */\n+  }\n+#  else\n+  len = GetTempPath(TMPDIR_LEN, testdir);\n+#  endif /* WINCE */\n \n-    if (FileTest() < 0) {\n-        printf(\"File Test failed\\n\");\n-        exit(2);\n-    }\n-    printf(\"File Test passed\\n\");\n-    if ((RunDirTest() < 0) || dirtest_failed) {\n-        printf(\"Dir Test failed\\n\");\n-        exit(2);\n-    }\n-    printf(\"Dir Test passed\\n\");\n+  if ((len > 0) && (len < (TMPDIR_LEN - 6))) {\n+    /*\n+     * enough space for prdir\n+     */\n+    strcpy((testdir + len), \"prdir\");\n+    TEST_DIR = testdir;\n+    printf(\"TEST_DIR = %s\\n\", TEST_DIR);\n+  }\n+#endif /* WIN32 */\n \n-    PR_DestroyMonitor(mon);\n-    PR_Cleanup();\n-    return 0;\n+  if (FileTest() < 0) {\n+    printf(\"File Test failed\\n\");\n+    exit(2);\n+  }\n+  printf(\"File Test passed\\n\");\n+  if ((RunDirTest() < 0) || dirtest_failed) {\n+    printf(\"Dir Test failed\\n\");\n+    exit(2);\n+  }\n+  printf(\"Dir Test passed\\n\");\n+\n+  PR_DestroyMonitor(mon);\n+  PR_Cleanup();\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/threads.c b/nspr/pr/tests/threads.c\nindex b19d6d1..60f69ea 100644\n--- a/nspr/pr/tests/threads.c\n+++ b/nspr/pr/tests/threads.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -15,187 +16,167 @@ PRInt32 count, iterations, alive;\n \n PRBool debug_mode = PR_FALSE, passed = PR_TRUE;\n \n-void PR_CALLBACK\n-ReallyDumbThread(void* arg)\n-{\n-    return;\n-}\n+void PR_CALLBACK ReallyDumbThread(void* arg) { return; }\n \n-void PR_CALLBACK\n-DumbThread(void* arg)\n-{\n-    PRInt32 tmp = (PRInt32)arg;\n-    PRThreadScope scope = (PRThreadScope)tmp;\n-    PRThread* thr;\n+void PR_CALLBACK DumbThread(void* arg) {\n+  PRInt32 tmp = (PRInt32)arg;\n+  PRThreadScope scope = (PRThreadScope)tmp;\n+  PRThread* thr;\n \n-    thr = PR_CreateThread(PR_USER_THREAD, ReallyDumbThread, NULL,\n-                          PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n+  thr = PR_CreateThread(PR_USER_THREAD, ReallyDumbThread, NULL,\n+                        PR_PRIORITY_NORMAL, scope, PR_JOINABLE_THREAD, 0);\n \n-    if (!thr) {\n-        if (debug_mode) {\n-            printf(\"Could not create really dumb thread (%d, %d)!\\n\", PR_GetError(),\n-                   PR_GetOSError());\n-        }\n-        passed = PR_FALSE;\n-    } else {\n-        PR_JoinThread(thr);\n+  if (!thr) {\n+    if (debug_mode) {\n+      printf(\"Could not create really dumb thread (%d, %d)!\\n\", PR_GetError(),\n+             PR_GetOSError());\n     }\n-    PR_EnterMonitor(mon);\n-    alive--;\n-    PR_Notify(mon);\n-    PR_ExitMonitor(mon);\n+    passed = PR_FALSE;\n+  } else {\n+    PR_JoinThread(thr);\n+  }\n+  PR_EnterMonitor(mon);\n+  alive--;\n+  PR_Notify(mon);\n+  PR_ExitMonitor(mon);\n }\n \n-static void\n-CreateThreads(PRThreadScope scope1, PRThreadScope scope2)\n-{\n-    PRThread* thr;\n-    int n;\n-\n-    alive = 0;\n-    mon = PR_NewMonitor();\n-\n-    alive = count;\n-    for (n = 0; n < count; n++) {\n-        thr = PR_CreateThread(PR_USER_THREAD, DumbThread, (void*)scope2,\n-                              PR_PRIORITY_NORMAL, scope1, PR_UNJOINABLE_THREAD, 0);\n-        if (!thr) {\n-            if (debug_mode) {\n-                printf(\"Could not create dumb thread (%d, %d)!\\n\", PR_GetError(),\n-                       PR_GetOSError());\n-            }\n-            passed = PR_FALSE;\n-            alive--;\n-        }\n-\n-        PR_Sleep(0);\n-    }\n+static void CreateThreads(PRThreadScope scope1, PRThreadScope scope2) {\n+  PRThread* thr;\n+  int n;\n \n-    /* Wait for all threads to exit */\n-    PR_EnterMonitor(mon);\n-    while (alive) {\n-        PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n+  alive = 0;\n+  mon = PR_NewMonitor();\n+\n+  alive = count;\n+  for (n = 0; n < count; n++) {\n+    thr = PR_CreateThread(PR_USER_THREAD, DumbThread, (void*)scope2,\n+                          PR_PRIORITY_NORMAL, scope1, PR_UNJOINABLE_THREAD, 0);\n+    if (!thr) {\n+      if (debug_mode) {\n+        printf(\"Could not create dumb thread (%d, %d)!\\n\", PR_GetError(),\n+               PR_GetOSError());\n+      }\n+      passed = PR_FALSE;\n+      alive--;\n     }\n \n-    PR_ExitMonitor(mon);\n-    PR_DestroyMonitor(mon);\n+    PR_Sleep(0);\n+  }\n+\n+  /* Wait for all threads to exit */\n+  PR_EnterMonitor(mon);\n+  while (alive) {\n+    PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);\n+  }\n+\n+  PR_ExitMonitor(mon);\n+  PR_DestroyMonitor(mon);\n }\n \n-static void\n-CreateThreadsUU(void)\n-{\n-    CreateThreads(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n+static void CreateThreadsUU(void) {\n+  CreateThreads(PR_LOCAL_THREAD, PR_LOCAL_THREAD);\n }\n \n-static void\n-CreateThreadsUK(void)\n-{\n-    CreateThreads(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n+static void CreateThreadsUK(void) {\n+  CreateThreads(PR_LOCAL_THREAD, PR_GLOBAL_THREAD);\n }\n \n-static void\n-CreateThreadsKU(void)\n-{\n-    CreateThreads(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n+static void CreateThreadsKU(void) {\n+  CreateThreads(PR_GLOBAL_THREAD, PR_LOCAL_THREAD);\n }\n \n-static void\n-CreateThreadsKK(void)\n-{\n-    CreateThreads(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n+static void CreateThreadsKK(void) {\n+  CreateThreads(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);\n }\n \n /************************************************************************/\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow();\n \n-    if (debug_mode) {\n-        d = (double)PR_IntervalToMicroseconds(stop - start);\n-        printf(\"%40s: %6.2f usec\\n\", msg, d / count);\n-    }\n+  if (debug_mode) {\n+    d = (double)PR_IntervalToMicroseconds(stop - start);\n+    printf(\"%40s: %6.2f usec\\n\", msg, d / count);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    int index;\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_HIGH, 0);\n-\n-    {\n-        PLOptStatus os;\n-        PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:i:\");\n-        while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-            if (PL_OPT_BAD == os) {\n-                continue;\n-            }\n-            switch (opt->option) {\n-                case 'd': /* debug mode */\n-                    debug_mode = PR_TRUE;\n-                    break;\n-                case 'c': /* loop counter */\n-                    count = atoi(opt->value);\n-                    break;\n-                case 'i': /* loop counter */\n-                    iterations = atoi(opt->value);\n-                    break;\n-                default:\n-                    break;\n-            }\n-        }\n-        PL_DestroyOptState(opt);\n+int main(int argc, char** argv) {\n+  int index;\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_HIGH, 0);\n+\n+  {\n+    PLOptStatus os;\n+    PLOptState* opt = PL_CreateOptState(argc, argv, \"dc:i:\");\n+    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+      if (PL_OPT_BAD == os) {\n+        continue;\n+      }\n+      switch (opt->option) {\n+        case 'd': /* debug mode */\n+          debug_mode = PR_TRUE;\n+          break;\n+        case 'c': /* loop counter */\n+          count = atoi(opt->value);\n+          break;\n+        case 'i': /* loop counter */\n+          iterations = atoi(opt->value);\n+          break;\n+        default:\n+          break;\n+      }\n     }\n-\n-    if (0 == count) {\n-        count = 50;\n-    }\n-    if (0 == iterations) {\n-        iterations = 10;\n-    }\n-\n-    if (debug_mode) {\n-        printf(\n-            \"\\\n+    PL_DestroyOptState(opt);\n+  }\n+\n+  if (0 == count) {\n+    count = 50;\n+  }\n+  if (0 == iterations) {\n+    iterations = 10;\n+  }\n+\n+  if (debug_mode) {\n+    printf(\n+        \"\\\n ** Tests lots of thread creations.  \\n\\\n ** Create %ld native threads %ld times. \\n\\\n ** Create %ld user threads %ld times \\n\",\n-            iterations, count, iterations, count);\n-    }\n-\n-    for (index = 0; index < iterations; index++) {\n-        Measure(CreateThreadsUU, \"Create user/user threads\");\n-        Measure(CreateThreadsUK, \"Create user/native threads\");\n-        Measure(CreateThreadsKU, \"Create native/user threads\");\n-        Measure(CreateThreadsKK, \"Create native/native threads\");\n-    }\n-\n-    if (debug_mode) {\n-        printf(\"\\nNow switch to recycling threads \\n\\n\");\n-    }\n-    PR_SetThreadRecycleMode(1);\n-\n-    for (index = 0; index < iterations; index++) {\n-        Measure(CreateThreadsUU, \"Create user/user threads\");\n-        Measure(CreateThreadsUK, \"Create user/native threads\");\n-        Measure(CreateThreadsKU, \"Create native/user threads\");\n-        Measure(CreateThreadsKK, \"Create native/native threads\");\n-    }\n-\n-    printf(\"%s\\n\", ((passed) ? \"PASS\" : \"FAIL\"));\n-\n-    PR_Cleanup();\n-\n-    if (passed) {\n-        return 0;\n-    } else {\n-        return 1;\n-    }\n+        iterations, count, iterations, count);\n+  }\n+\n+  for (index = 0; index < iterations; index++) {\n+    Measure(CreateThreadsUU, \"Create user/user threads\");\n+    Measure(CreateThreadsUK, \"Create user/native threads\");\n+    Measure(CreateThreadsKU, \"Create native/user threads\");\n+    Measure(CreateThreadsKK, \"Create native/native threads\");\n+  }\n+\n+  if (debug_mode) {\n+    printf(\"\\nNow switch to recycling threads \\n\\n\");\n+  }\n+  PR_SetThreadRecycleMode(1);\n+\n+  for (index = 0; index < iterations; index++) {\n+    Measure(CreateThreadsUU, \"Create user/user threads\");\n+    Measure(CreateThreadsUK, \"Create user/native threads\");\n+    Measure(CreateThreadsKU, \"Create native/user threads\");\n+    Measure(CreateThreadsKK, \"Create native/native threads\");\n+  }\n+\n+  printf(\"%s\\n\", ((passed) ? \"PASS\" : \"FAIL\"));\n+\n+  PR_Cleanup();\n+\n+  if (passed) {\n+    return 0;\n+  } else {\n+    return 1;\n+  }\n }\ndiff --git a/nspr/pr/tests/thrpool_client.c b/nspr/pr/tests/thrpool_client.c\nindex 822ae3d..ba477b8 100644\n--- a/nspr/pr/tests/thrpool_client.c\n+++ b/nspr/pr/tests/thrpool_client.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -18,14 +19,14 @@\n #include <string.h>\n #include <errno.h>\n #ifdef XP_UNIX\n-#include <sys/mman.h>\n+#  include <sys/mman.h>\n #endif\n #if defined(_PR_PTHREADS)\n-#include <pthread.h>\n+#  include <pthread.h>\n #endif\n \n #ifdef WIN32\n-#include <process.h>\n+#  include <process.h>\n #endif\n \n static int _debug_on = 0;\n@@ -35,12 +36,11 @@ static char* program_name = NULL;\n #include \"obsolete/prsem.h\"\n \n #ifdef XP_PC\n-#define mode_t int\n+#  define mode_t int\n #endif\n \n #define DPRINTF(arg) \\\n-    if (_debug_on)   \\\n-    printf arg\n+  if (_debug_on) printf arg\n \n #define BUF_DATA_SIZE (2 * 1024)\n #define TCP_MESG_SIZE 1024\n@@ -58,65 +58,61 @@ static PRInt32 num_tcp_mesgs_per_connection = NUM_TCP_MESGS_PER_CONNECTION;\n int failed_already = 0;\n \n typedef struct buffer {\n-    char data[BUF_DATA_SIZE];\n+  char data[BUF_DATA_SIZE];\n } buffer;\n \n PRNetAddr tcp_server_addr, udp_server_addr;\n \n typedef struct Client_Param {\n-    PRNetAddr server_addr;\n-    PRMonitor* exit_mon;   /* monitor to signal on exit */\n-    PRInt32* exit_counter; /* counter to decrement, before exit */\n-    PRInt32 datalen;\n+  PRNetAddr server_addr;\n+  PRMonitor* exit_mon;   /* monitor to signal on exit */\n+  PRInt32* exit_counter; /* counter to decrement, before exit */\n+  PRInt32 datalen;\n } Client_Param;\n \n /*\n  * readn\n  *    read data from sockfd into buf\n  */\n-static PRInt32\n-readn(PRFileDesc* sockfd, char* buf, int len)\n-{\n-    int rem;\n-    int bytes;\n-    int offset = 0;\n-    PRIntervalTime timeout = PR_INTERVAL_NO_TIMEOUT;\n-\n-    for (rem = len; rem; offset += bytes, rem -= bytes) {\n-        DPRINTF((\"thread = 0x%lx: calling PR_Recv, bytes = %d\\n\",\n-                 PR_GetCurrentThread(), rem));\n-        bytes = PR_Recv(sockfd, buf + offset, rem, 0, timeout);\n-        DPRINTF((\"thread = 0x%lx: returning from PR_Recv, bytes = %d\\n\",\n-                 PR_GetCurrentThread(), bytes));\n-        if (bytes < 0) {\n-            return -1;\n-        }\n+static PRInt32 readn(PRFileDesc* sockfd, char* buf, int len) {\n+  int rem;\n+  int bytes;\n+  int offset = 0;\n+  PRIntervalTime timeout = PR_INTERVAL_NO_TIMEOUT;\n+\n+  for (rem = len; rem; offset += bytes, rem -= bytes) {\n+    DPRINTF((\"thread = 0x%lx: calling PR_Recv, bytes = %d\\n\",\n+             PR_GetCurrentThread(), rem));\n+    bytes = PR_Recv(sockfd, buf + offset, rem, 0, timeout);\n+    DPRINTF((\"thread = 0x%lx: returning from PR_Recv, bytes = %d\\n\",\n+             PR_GetCurrentThread(), bytes));\n+    if (bytes < 0) {\n+      return -1;\n     }\n-    return len;\n+  }\n+  return len;\n }\n \n /*\n  * writen\n  *    write data from buf to sockfd\n  */\n-static PRInt32\n-writen(PRFileDesc* sockfd, char* buf, int len)\n-{\n-    int rem;\n-    int bytes;\n-    int offset = 0;\n-\n-    for (rem = len; rem; offset += bytes, rem -= bytes) {\n-        DPRINTF((\"thread = 0x%lx: calling PR_Send, bytes = %d\\n\",\n-                 PR_GetCurrentThread(), rem));\n-        bytes = PR_Send(sockfd, buf + offset, rem, 0, PR_INTERVAL_NO_TIMEOUT);\n-        DPRINTF((\"thread = 0x%lx: returning from PR_Send, bytes = %d\\n\",\n-                 PR_GetCurrentThread(), bytes));\n-        if (bytes <= 0) {\n-            return -1;\n-        }\n+static PRInt32 writen(PRFileDesc* sockfd, char* buf, int len) {\n+  int rem;\n+  int bytes;\n+  int offset = 0;\n+\n+  for (rem = len; rem; offset += bytes, rem -= bytes) {\n+    DPRINTF((\"thread = 0x%lx: calling PR_Send, bytes = %d\\n\",\n+             PR_GetCurrentThread(), rem));\n+    bytes = PR_Send(sockfd, buf + offset, rem, 0, PR_INTERVAL_NO_TIMEOUT);\n+    DPRINTF((\"thread = 0x%lx: returning from PR_Send, bytes = %d\\n\",\n+             PR_GetCurrentThread(), bytes));\n+    if (bytes <= 0) {\n+      return -1;\n     }\n-    return len;\n+  }\n+  return len;\n }\n \n /*\n@@ -127,100 +123,98 @@ writen(PRFileDesc* sockfd, char* buf, int len)\n  *    for data corruption.\n  *    Close the socket for server connection\n  */\n-static void PR_CALLBACK\n-TCP_Client(void* arg)\n-{\n-    Client_Param* cp = (Client_Param*)arg;\n-    PRFileDesc* sockfd;\n-    buffer *in_buf, *out_buf;\n-    union PRNetAddr netaddr;\n-    PRInt32 bytes, i, j;\n-\n-    DPRINTF((\"TCP client started\\n\"));\n-    bytes = cp->datalen;\n-    out_buf = PR_NEW(buffer);\n-    if (out_buf == NULL) {\n-        fprintf(stderr, \"%s: failed to alloc buffer struct\\n\", program_name);\n+static void PR_CALLBACK TCP_Client(void* arg) {\n+  Client_Param* cp = (Client_Param*)arg;\n+  PRFileDesc* sockfd;\n+  buffer *in_buf, *out_buf;\n+  union PRNetAddr netaddr;\n+  PRInt32 bytes, i, j;\n+\n+  DPRINTF((\"TCP client started\\n\"));\n+  bytes = cp->datalen;\n+  out_buf = PR_NEW(buffer);\n+  if (out_buf == NULL) {\n+    fprintf(stderr, \"%s: failed to alloc buffer struct\\n\", program_name);\n+    failed_already = 1;\n+    return;\n+  }\n+  in_buf = PR_NEW(buffer);\n+  if (in_buf == NULL) {\n+    fprintf(stderr, \"%s: failed to alloc buffer struct\\n\", program_name);\n+    failed_already = 1;\n+    return;\n+  }\n+  netaddr.inet.family = cp->server_addr.inet.family;\n+  netaddr.inet.port = cp->server_addr.inet.port;\n+  netaddr.inet.ip = cp->server_addr.inet.ip;\n+\n+  for (i = 0; i < num_tcp_connections_per_client; i++) {\n+    if ((sockfd = PR_OpenTCPSocket(PR_AF_INET)) == NULL) {\n+      fprintf(stderr, \"%s: PR_OpenTCPSocket failed\\n\", program_name);\n+      failed_already = 1;\n+      return;\n+    }\n+\n+    DPRINTF((\"TCP client connecting to server:%d\\n\", server_port));\n+    if (PR_Connect(sockfd, &netaddr, PR_INTERVAL_NO_TIMEOUT) < 0) {\n+      fprintf(stderr, \"PR_Connect failed: (%ld, %ld)\\n\", PR_GetError(),\n+              PR_GetOSError());\n+      failed_already = 1;\n+      return;\n+    }\n+    for (j = 0; j < num_tcp_mesgs_per_connection; j++) {\n+      /*\n+       * fill in random data\n+       */\n+      memset(out_buf->data, ((PRInt32)(&netaddr)) + i + j, bytes);\n+      /*\n+       * write to server\n+       */\n+      if (writen(sockfd, out_buf->data, bytes) < bytes) {\n+        fprintf(stderr, \"%s: ERROR - TCP_Client:writen\\n\", program_name);\n         failed_already = 1;\n         return;\n-    }\n-    in_buf = PR_NEW(buffer);\n-    if (in_buf == NULL) {\n-        fprintf(stderr, \"%s: failed to alloc buffer struct\\n\", program_name);\n+      }\n+      /*\n+      DPRINTF((\"TCP Client [0x%lx]: out_buf = 0x%lx out_buf[0] = 0x%lx\\n\",\n+          PR_GetCurrentThread(), out_buf, (*((int *) out_buf->data))));\n+      */\n+      if (readn(sockfd, in_buf->data, bytes) < bytes) {\n+        fprintf(stderr, \"%s: ERROR - TCP_Client:readn\\n\", program_name);\n         failed_already = 1;\n         return;\n+      }\n+      /*\n+       * verify the data read\n+       */\n+      if (memcmp(in_buf->data, out_buf->data, bytes) != 0) {\n+        fprintf(stderr, \"%s: ERROR - data corruption\\n\", program_name);\n+        failed_already = 1;\n+        return;\n+      }\n     }\n-    netaddr.inet.family = cp->server_addr.inet.family;\n-    netaddr.inet.port = cp->server_addr.inet.port;\n-    netaddr.inet.ip = cp->server_addr.inet.ip;\n-\n-    for (i = 0; i < num_tcp_connections_per_client; i++) {\n-        if ((sockfd = PR_OpenTCPSocket(PR_AF_INET)) == NULL) {\n-            fprintf(stderr, \"%s: PR_OpenTCPSocket failed\\n\", program_name);\n-            failed_already = 1;\n-            return;\n-        }\n-\n-        DPRINTF((\"TCP client connecting to server:%d\\n\", server_port));\n-        if (PR_Connect(sockfd, &netaddr, PR_INTERVAL_NO_TIMEOUT) < 0) {\n-            fprintf(stderr, \"PR_Connect failed: (%ld, %ld)\\n\", PR_GetError(),\n-                    PR_GetOSError());\n-            failed_already = 1;\n-            return;\n-        }\n-        for (j = 0; j < num_tcp_mesgs_per_connection; j++) {\n-            /*\n-             * fill in random data\n-             */\n-            memset(out_buf->data, ((PRInt32)(&netaddr)) + i + j, bytes);\n-            /*\n-             * write to server\n-             */\n-            if (writen(sockfd, out_buf->data, bytes) < bytes) {\n-                fprintf(stderr, \"%s: ERROR - TCP_Client:writen\\n\", program_name);\n-                failed_already = 1;\n-                return;\n-            }\n-            /*\n-            DPRINTF((\"TCP Client [0x%lx]: out_buf = 0x%lx out_buf[0] = 0x%lx\\n\",\n-                PR_GetCurrentThread(), out_buf, (*((int *) out_buf->data))));\n-            */\n-            if (readn(sockfd, in_buf->data, bytes) < bytes) {\n-                fprintf(stderr, \"%s: ERROR - TCP_Client:readn\\n\", program_name);\n-                failed_already = 1;\n-                return;\n-            }\n-            /*\n-             * verify the data read\n-             */\n-            if (memcmp(in_buf->data, out_buf->data, bytes) != 0) {\n-                fprintf(stderr, \"%s: ERROR - data corruption\\n\", program_name);\n-                failed_already = 1;\n-                return;\n-            }\n-        }\n-        /*\n-         * shutdown reads and writes\n-         */\n-        if (PR_Shutdown(sockfd, PR_SHUTDOWN_BOTH) < 0) {\n-            fprintf(stderr, \"%s: ERROR - PR_Shutdown\\n\", program_name);\n-            failed_already = 1;\n-        }\n-        PR_Close(sockfd);\n+    /*\n+     * shutdown reads and writes\n+     */\n+    if (PR_Shutdown(sockfd, PR_SHUTDOWN_BOTH) < 0) {\n+      fprintf(stderr, \"%s: ERROR - PR_Shutdown\\n\", program_name);\n+      failed_already = 1;\n     }\n+    PR_Close(sockfd);\n+  }\n \n-    PR_DELETE(out_buf);\n-    PR_DELETE(in_buf);\n+  PR_DELETE(out_buf);\n+  PR_DELETE(in_buf);\n \n-    /*\n-     * Decrement exit_counter and notify parent thread\n-     */\n+  /*\n+   * Decrement exit_counter and notify parent thread\n+   */\n \n-    PR_EnterMonitor(cp->exit_mon);\n-    --(*cp->exit_counter);\n-    PR_Notify(cp->exit_mon);\n-    PR_ExitMonitor(cp->exit_mon);\n-    DPRINTF((\"TCP_Client exiting\\n\"));\n+  PR_EnterMonitor(cp->exit_mon);\n+  --(*cp->exit_counter);\n+  PR_Notify(cp->exit_mon);\n+  PR_ExitMonitor(cp->exit_mon);\n+  DPRINTF((\"TCP_Client exiting\\n\"));\n }\n \n /*\n@@ -234,112 +228,108 @@ TCP_Client(void* arg)\n  *\n  */\n \n-static PRInt32\n-TCP_Socket_Client_Server_Test(void)\n-{\n-    int i;\n-    Client_Param* cparamp;\n-    PRMonitor* mon2;\n-    PRInt32 datalen;\n-    PRInt32 connections = 0;\n-    PRThread* thr;\n-\n-    datalen = tcp_mesg_size;\n-    connections = 0;\n-\n-    mon2 = PR_NewMonitor();\n-    if (mon2 == NULL) {\n-        fprintf(stderr, \"%s: PR_NewMonitor failed\\n\", program_name);\n-        failed_already = 1;\n-        return -1;\n+static PRInt32 TCP_Socket_Client_Server_Test(void) {\n+  int i;\n+  Client_Param* cparamp;\n+  PRMonitor* mon2;\n+  PRInt32 datalen;\n+  PRInt32 connections = 0;\n+  PRThread* thr;\n+\n+  datalen = tcp_mesg_size;\n+  connections = 0;\n+\n+  mon2 = PR_NewMonitor();\n+  if (mon2 == NULL) {\n+    fprintf(stderr, \"%s: PR_NewMonitor failed\\n\", program_name);\n+    failed_already = 1;\n+    return -1;\n+  }\n+\n+  /*\n+   * Start client jobs\n+   */\n+  cparamp = PR_NEW(Client_Param);\n+  if (cparamp == NULL) {\n+    fprintf(stderr, \"%s: PR_NEW failed\\n\", program_name);\n+    failed_already = 1;\n+    return -1;\n+  }\n+  cparamp->server_addr.inet.family = PR_AF_INET;\n+  cparamp->server_addr.inet.port = PR_htons(server_port);\n+  cparamp->server_addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n+  cparamp->exit_mon = mon2;\n+  cparamp->exit_counter = &connections;\n+  cparamp->datalen = datalen;\n+  for (i = 0; i < num_tcp_clients; i++) {\n+    thr = PR_CreateThread(PR_USER_THREAD, TCP_Client, (void*)cparamp,\n+                          PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n+                          PR_UNJOINABLE_THREAD, 0);\n+    if (NULL == thr) {\n+      fprintf(stderr, \"%s: PR_CreateThread failed\\n\", program_name);\n+      failed_already = 1;\n+      return -1;\n     }\n-\n-    /*\n-     * Start client jobs\n-     */\n-    cparamp = PR_NEW(Client_Param);\n-    if (cparamp == NULL) {\n-        fprintf(stderr, \"%s: PR_NEW failed\\n\", program_name);\n-        failed_already = 1;\n-        return -1;\n-    }\n-    cparamp->server_addr.inet.family = PR_AF_INET;\n-    cparamp->server_addr.inet.port = PR_htons(server_port);\n-    cparamp->server_addr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);\n-    cparamp->exit_mon = mon2;\n-    cparamp->exit_counter = &connections;\n-    cparamp->datalen = datalen;\n-    for (i = 0; i < num_tcp_clients; i++) {\n-        thr = PR_CreateThread(PR_USER_THREAD, TCP_Client, (void*)cparamp,\n-                              PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,\n-                              PR_UNJOINABLE_THREAD, 0);\n-        if (NULL == thr) {\n-            fprintf(stderr, \"%s: PR_CreateThread failed\\n\", program_name);\n-            failed_already = 1;\n-            return -1;\n-        }\n-        PR_EnterMonitor(mon2);\n-        connections++;\n-        PR_ExitMonitor(mon2);\n-        DPRINTF((\"Created TCP client = 0x%lx\\n\", thr));\n-    }\n-    /* Wait for client jobs to exit */\n     PR_EnterMonitor(mon2);\n-    while (0 != connections) {\n-        PR_Wait(mon2, PR_INTERVAL_NO_TIMEOUT);\n-        DPRINTF((\"Client job count = %d\\n\", connections));\n-    }\n+    connections++;\n     PR_ExitMonitor(mon2);\n-    printf(\"%30s\", \"TCP_Socket_Client_Server_Test:\");\n-    printf(\"%2ld Server %2ld Clients %2ld connections_per_client\\n\", 1l,\n-           num_tcp_clients, num_tcp_connections_per_client);\n-    printf(\"%30s %2ld messages_per_connection %4ld bytes_per_message\\n\", \":\",\n-           num_tcp_mesgs_per_connection, tcp_mesg_size);\n-\n-    PR_DELETE(cparamp);\n-    return 0;\n+    DPRINTF((\"Created TCP client = 0x%lx\\n\", thr));\n+  }\n+  /* Wait for client jobs to exit */\n+  PR_EnterMonitor(mon2);\n+  while (0 != connections) {\n+    PR_Wait(mon2, PR_INTERVAL_NO_TIMEOUT);\n+    DPRINTF((\"Client job count = %d\\n\", connections));\n+  }\n+  PR_ExitMonitor(mon2);\n+  printf(\"%30s\", \"TCP_Socket_Client_Server_Test:\");\n+  printf(\"%2ld Server %2ld Clients %2ld connections_per_client\\n\", 1l,\n+         num_tcp_clients, num_tcp_connections_per_client);\n+  printf(\"%30s %2ld messages_per_connection %4ld bytes_per_message\\n\", \":\",\n+         num_tcp_mesgs_per_connection, tcp_mesg_size);\n+\n+  PR_DELETE(cparamp);\n+  return 0;\n }\n \n /************************************************************************/\n \n-int\n-main(int argc, char** argv)\n-{\n-    /*\n-     * -d           debug mode\n-     */\n-    PLOptStatus os;\n-    PLOptState* opt;\n-    program_name = argv[0];\n-\n-    opt = PL_CreateOptState(argc, argv, \"dp:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                _debug_on = 1;\n-                break;\n-            case 'p':\n-                server_port = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  /*\n+   * -d           debug mode\n+   */\n+  PLOptStatus os;\n+  PLOptState* opt;\n+  program_name = argv[0];\n+\n+  opt = PL_CreateOptState(argc, argv, \"dp:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        _debug_on = 1;\n+        break;\n+      case 'p':\n+        server_port = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    PR_SetConcurrency(4);\n+  PR_SetConcurrency(4);\n \n-    TCP_Socket_Client_Server_Test();\n+  TCP_Socket_Client_Server_Test();\n \n-    PR_Cleanup();\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  PR_Cleanup();\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/thrpool_server.c b/nspr/pr/tests/thrpool_server.c\nindex 06a12c5..95b8d63 100644\n--- a/nspr/pr/tests/thrpool_server.c\n+++ b/nspr/pr/tests/thrpool_server.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -18,21 +19,21 @@\n #include <string.h>\n #include <errno.h>\n #ifdef XP_UNIX\n-#include <sys/mman.h>\n+#  include <sys/mman.h>\n #endif\n #if defined(_PR_PTHREADS)\n-#include <pthread.h>\n+#  include <pthread.h>\n #endif\n \n /* for getcwd */\n #if defined(XP_UNIX)\n-#include <unistd.h>\n+#  include <unistd.h>\n #elif defined(XP_PC)\n-#include <direct.h>\n+#  include <direct.h>\n #endif\n \n #ifdef WIN32\n-#include <process.h>\n+#  include <process.h>\n #endif\n \n static int _debug_on = 0;\n@@ -42,12 +43,11 @@ static void serve_client_write(void* arg);\n #include \"obsolete/prsem.h\"\n \n #ifdef XP_PC\n-#define mode_t int\n+#  define mode_t int\n #endif\n \n #define DPRINTF(arg) \\\n-    if (_debug_on)   \\\n-    printf arg\n+  if (_debug_on) printf arg\n \n #define BUF_DATA_SIZE (2 * 1024)\n #define TCP_MESG_SIZE 1024\n@@ -59,15 +59,13 @@ static void serve_client_write(void* arg);\n #define SERVER_MAX_BIND_COUNT 100\n \n #ifdef WINCE\n-char*\n-getcwd(char* buf, size_t size)\n-{\n-    wchar_t wpath[MAX_PATH];\n-    _wgetcwd(wpath, MAX_PATH);\n-    WideCharToMultiByte(CP_ACP, 0, wpath, -1, buf, size, 0, 0);\n+char* getcwd(char* buf, size_t size) {\n+  wchar_t wpath[MAX_PATH];\n+  _wgetcwd(wpath, MAX_PATH);\n+  WideCharToMultiByte(CP_ACP, 0, wpath, -1, buf, size, 0, 0);\n }\n \n-#define perror(s)\n+#  define perror(s)\n #endif\n \n static PRInt32 num_tcp_clients = NUM_TCP_CLIENTS;\n@@ -78,125 +76,121 @@ static void TCP_Server_Accept(void* arg);\n \n int failed_already = 0;\n typedef struct buffer {\n-    char data[BUF_DATA_SIZE];\n+  char data[BUF_DATA_SIZE];\n } buffer;\n \n typedef struct Server_Param {\n-    PRJobIoDesc iod; /* socket to read from/write to    */\n-    PRInt32 datalen; /* bytes of data transfered in each read/write */\n-    PRNetAddr netaddr;\n-    PRMonitor* exit_mon;   /* monitor to signal on exit            */\n-    PRInt32* job_counterp; /* counter to decrement, before exit        */\n-    PRInt32 conn_counter;  /* counter to decrement, before exit        */\n-    PRThreadPool* tp;\n+  PRJobIoDesc iod; /* socket to read from/write to    */\n+  PRInt32 datalen; /* bytes of data transfered in each read/write */\n+  PRNetAddr netaddr;\n+  PRMonitor* exit_mon;   /* monitor to signal on exit            */\n+  PRInt32* job_counterp; /* counter to decrement, before exit        */\n+  PRInt32 conn_counter;  /* counter to decrement, before exit        */\n+  PRThreadPool* tp;\n } Server_Param;\n \n typedef struct Serve_Client_Param {\n-    PRJobIoDesc iod;       /* socket to read from/write to    */\n-    PRInt32 datalen;       /* bytes of data transfered in each read/write */\n-    PRMonitor* exit_mon;   /* monitor to signal on exit            */\n-    PRInt32* job_counterp; /* counter to decrement, before exit        */\n-    PRThreadPool* tp;\n+  PRJobIoDesc iod;       /* socket to read from/write to    */\n+  PRInt32 datalen;       /* bytes of data transfered in each read/write */\n+  PRMonitor* exit_mon;   /* monitor to signal on exit            */\n+  PRInt32* job_counterp; /* counter to decrement, before exit        */\n+  PRThreadPool* tp;\n } Serve_Client_Param;\n \n typedef struct Session {\n-    PRJobIoDesc iod; /* socket to read from/write to    */\n-    buffer* in_buf;\n-    PRInt32 bytes;\n-    PRInt32 msg_num;\n-    PRInt32 bytes_read;\n-    PRMonitor* exit_mon;   /* monitor to signal on exit            */\n-    PRInt32* job_counterp; /* counter to decrement, before exit        */\n-    PRThreadPool* tp;\n+  PRJobIoDesc iod; /* socket to read from/write to    */\n+  buffer* in_buf;\n+  PRInt32 bytes;\n+  PRInt32 msg_num;\n+  PRInt32 bytes_read;\n+  PRMonitor* exit_mon;   /* monitor to signal on exit            */\n+  PRInt32* job_counterp; /* counter to decrement, before exit        */\n+  PRThreadPool* tp;\n } Session;\n \n-static void\n-serve_client_read(void* arg)\n-{\n-    Session* sp = (Session*)arg;\n-    int rem;\n-    int bytes;\n-    int offset;\n-    PRFileDesc* sockfd;\n-    char* buf;\n-    PRJob* jobp;\n-\n-    PRIntervalTime timeout = PR_INTERVAL_NO_TIMEOUT;\n-\n-    sockfd = sp->iod.socket;\n-    buf = sp->in_buf->data;\n-\n-    PR_ASSERT(sp->msg_num < num_tcp_mesgs_per_connection);\n-    PR_ASSERT(sp->bytes_read < sp->bytes);\n-\n-    offset = sp->bytes_read;\n-    rem = sp->bytes - offset;\n-    bytes = PR_Recv(sockfd, buf + offset, rem, 0, timeout);\n-    if (bytes < 0) {\n-        return;\n-    }\n-    sp->bytes_read += bytes;\n-    sp->iod.timeout = PR_SecondsToInterval(60);\n-    if (sp->bytes_read < sp->bytes) {\n-        jobp = PR_QueueJob_Read(sp->tp, &sp->iod, serve_client_read, sp, PR_FALSE);\n-        PR_ASSERT(NULL != jobp);\n-        return;\n-    }\n-    PR_ASSERT(sp->bytes_read == sp->bytes);\n-    DPRINTF((\"serve_client: read complete, msg(%d) \\n\", sp->msg_num));\n+static void serve_client_read(void* arg) {\n+  Session* sp = (Session*)arg;\n+  int rem;\n+  int bytes;\n+  int offset;\n+  PRFileDesc* sockfd;\n+  char* buf;\n+  PRJob* jobp;\n \n-    sp->iod.timeout = PR_SecondsToInterval(60);\n-    jobp = PR_QueueJob_Write(sp->tp, &sp->iod, serve_client_write, sp, PR_FALSE);\n-    PR_ASSERT(NULL != jobp);\n+  PRIntervalTime timeout = PR_INTERVAL_NO_TIMEOUT;\n \n+  sockfd = sp->iod.socket;\n+  buf = sp->in_buf->data;\n+\n+  PR_ASSERT(sp->msg_num < num_tcp_mesgs_per_connection);\n+  PR_ASSERT(sp->bytes_read < sp->bytes);\n+\n+  offset = sp->bytes_read;\n+  rem = sp->bytes - offset;\n+  bytes = PR_Recv(sockfd, buf + offset, rem, 0, timeout);\n+  if (bytes < 0) {\n     return;\n+  }\n+  sp->bytes_read += bytes;\n+  sp->iod.timeout = PR_SecondsToInterval(60);\n+  if (sp->bytes_read < sp->bytes) {\n+    jobp = PR_QueueJob_Read(sp->tp, &sp->iod, serve_client_read, sp, PR_FALSE);\n+    PR_ASSERT(NULL != jobp);\n+    return;\n+  }\n+  PR_ASSERT(sp->bytes_read == sp->bytes);\n+  DPRINTF((\"serve_client: read complete, msg(%d) \\n\", sp->msg_num));\n+\n+  sp->iod.timeout = PR_SecondsToInterval(60);\n+  jobp = PR_QueueJob_Write(sp->tp, &sp->iod, serve_client_write, sp, PR_FALSE);\n+  PR_ASSERT(NULL != jobp);\n+\n+  return;\n }\n \n-static void\n-serve_client_write(void* arg)\n-{\n-    Session* sp = (Session*)arg;\n-    int bytes;\n-    PRFileDesc* sockfd;\n-    char* buf;\n-    PRJob* jobp;\n+static void serve_client_write(void* arg) {\n+  Session* sp = (Session*)arg;\n+  int bytes;\n+  PRFileDesc* sockfd;\n+  char* buf;\n+  PRJob* jobp;\n \n-    sockfd = sp->iod.socket;\n-    buf = sp->in_buf->data;\n+  sockfd = sp->iod.socket;\n+  buf = sp->in_buf->data;\n \n-    PR_ASSERT(sp->msg_num < num_tcp_mesgs_per_connection);\n+  PR_ASSERT(sp->msg_num < num_tcp_mesgs_per_connection);\n \n-    bytes = PR_Send(sockfd, buf, sp->bytes, 0, PR_INTERVAL_NO_TIMEOUT);\n-    PR_ASSERT(bytes == sp->bytes);\n+  bytes = PR_Send(sockfd, buf, sp->bytes, 0, PR_INTERVAL_NO_TIMEOUT);\n+  PR_ASSERT(bytes == sp->bytes);\n \n-    if (bytes < 0) {\n-        return;\n-    }\n-    DPRINTF((\"serve_client: write complete, msg(%d) \\n\", sp->msg_num));\n-    sp->msg_num++;\n-    if (sp->msg_num < num_tcp_mesgs_per_connection) {\n-        sp->bytes_read = 0;\n-        sp->iod.timeout = PR_SecondsToInterval(60);\n-        jobp = PR_QueueJob_Read(sp->tp, &sp->iod, serve_client_read, sp, PR_FALSE);\n-        PR_ASSERT(NULL != jobp);\n-        return;\n-    }\n+  if (bytes < 0) {\n+    return;\n+  }\n+  DPRINTF((\"serve_client: write complete, msg(%d) \\n\", sp->msg_num));\n+  sp->msg_num++;\n+  if (sp->msg_num < num_tcp_mesgs_per_connection) {\n+    sp->bytes_read = 0;\n+    sp->iod.timeout = PR_SecondsToInterval(60);\n+    jobp = PR_QueueJob_Read(sp->tp, &sp->iod, serve_client_read, sp, PR_FALSE);\n+    PR_ASSERT(NULL != jobp);\n+    return;\n+  }\n \n-    DPRINTF((\"serve_client: read/write complete, msg(%d) \\n\", sp->msg_num));\n-    if (PR_Shutdown(sockfd, PR_SHUTDOWN_BOTH) < 0) {\n-        fprintf(stderr, \"%s: ERROR - PR_Shutdown\\n\", program_name);\n-    }\n+  DPRINTF((\"serve_client: read/write complete, msg(%d) \\n\", sp->msg_num));\n+  if (PR_Shutdown(sockfd, PR_SHUTDOWN_BOTH) < 0) {\n+    fprintf(stderr, \"%s: ERROR - PR_Shutdown\\n\", program_name);\n+  }\n \n-    PR_Close(sockfd);\n-    PR_EnterMonitor(sp->exit_mon);\n-    --(*sp->job_counterp);\n-    PR_Notify(sp->exit_mon);\n-    PR_ExitMonitor(sp->exit_mon);\n+  PR_Close(sockfd);\n+  PR_EnterMonitor(sp->exit_mon);\n+  --(*sp->job_counterp);\n+  PR_Notify(sp->exit_mon);\n+  PR_ExitMonitor(sp->exit_mon);\n \n-    PR_DELETE(sp->in_buf);\n-    PR_DELETE(sp);\n+  PR_DELETE(sp->in_buf);\n+  PR_DELETE(sp);\n \n-    return;\n+  return;\n }\n \n /*\n@@ -205,56 +199,52 @@ serve_client_write(void* arg)\n  *    Reads data from socket and writes it back, unmodified, and\n  *    closes the socket\n  */\n-static void PR_CALLBACK\n-Serve_Client(void* arg)\n-{\n-    Serve_Client_Param* scp = (Serve_Client_Param*)arg;\n-    buffer* in_buf;\n-    Session* sp;\n-    PRJob* jobp;\n-\n-    sp = PR_NEW(Session);\n-    sp->iod = scp->iod;\n-\n-    in_buf = PR_NEW(buffer);\n-    if (in_buf == NULL) {\n-        fprintf(stderr, \"%s: failed to alloc buffer struct\\n\", program_name);\n-        failed_already = 1;\n-        return;\n-    }\n-\n-    sp->in_buf = in_buf;\n-    sp->bytes = scp->datalen;\n-    sp->msg_num = 0;\n-    sp->bytes_read = 0;\n-    sp->tp = scp->tp;\n-    sp->exit_mon = scp->exit_mon;\n-    sp->job_counterp = scp->job_counterp;\n-\n-    sp->iod.timeout = PR_SecondsToInterval(60);\n-    jobp = PR_QueueJob_Read(sp->tp, &sp->iod, serve_client_read, sp, PR_FALSE);\n-    PR_ASSERT(NULL != jobp);\n-    PR_DELETE(scp);\n+static void PR_CALLBACK Serve_Client(void* arg) {\n+  Serve_Client_Param* scp = (Serve_Client_Param*)arg;\n+  buffer* in_buf;\n+  Session* sp;\n+  PRJob* jobp;\n+\n+  sp = PR_NEW(Session);\n+  sp->iod = scp->iod;\n+\n+  in_buf = PR_NEW(buffer);\n+  if (in_buf == NULL) {\n+    fprintf(stderr, \"%s: failed to alloc buffer struct\\n\", program_name);\n+    failed_already = 1;\n+    return;\n+  }\n+\n+  sp->in_buf = in_buf;\n+  sp->bytes = scp->datalen;\n+  sp->msg_num = 0;\n+  sp->bytes_read = 0;\n+  sp->tp = scp->tp;\n+  sp->exit_mon = scp->exit_mon;\n+  sp->job_counterp = scp->job_counterp;\n+\n+  sp->iod.timeout = PR_SecondsToInterval(60);\n+  jobp = PR_QueueJob_Read(sp->tp, &sp->iod, serve_client_read, sp, PR_FALSE);\n+  PR_ASSERT(NULL != jobp);\n+  PR_DELETE(scp);\n }\n \n-static void\n-print_stats(void* arg)\n-{\n-    Server_Param* sp = (Server_Param*)arg;\n-    PRThreadPool* tp = sp->tp;\n-    PRInt32 counter;\n-    PRJob* jobp;\n+static void print_stats(void* arg) {\n+  Server_Param* sp = (Server_Param*)arg;\n+  PRThreadPool* tp = sp->tp;\n+  PRInt32 counter;\n+  PRJob* jobp;\n \n-    PR_EnterMonitor(sp->exit_mon);\n-    counter = (*sp->job_counterp);\n-    PR_ExitMonitor(sp->exit_mon);\n+  PR_EnterMonitor(sp->exit_mon);\n+  counter = (*sp->job_counterp);\n+  PR_ExitMonitor(sp->exit_mon);\n \n-    printf(\"PRINT_STATS: #client connections = %d\\n\", counter);\n+  printf(\"PRINT_STATS: #client connections = %d\\n\", counter);\n \n-    jobp = PR_QueueJob_Timer(tp, PR_MillisecondsToInterval(500), print_stats, sp,\n-                             PR_FALSE);\n+  jobp = PR_QueueJob_Timer(tp, PR_MillisecondsToInterval(500), print_stats, sp,\n+                           PR_FALSE);\n \n-    PR_ASSERT(NULL != jobp);\n+  PR_ASSERT(NULL != jobp);\n }\n \n static int job_counter = 0;\n@@ -269,230 +259,226 @@ static int job_counter = 0;\n  *    data it sent to the server.\n  *    Finally, the threadpool is shutdown\n  */\n-static void PR_CALLBACK\n-TCP_Server(void* arg)\n-{\n-    PRThreadPool* tp = (PRThreadPool*)arg;\n-    Server_Param* sp;\n-    PRFileDesc* sockfd;\n-    PRNetAddr netaddr;\n-    PRMonitor* sc_mon;\n-    PRJob* jobp;\n-    int i;\n-    PRStatus rval;\n-\n-    /*\n-     * Create a tcp socket\n-     */\n-    if ((sockfd = PR_NewTCPSocket()) == NULL) {\n-        fprintf(stderr, \"%s: PR_NewTCPSocket failed\\n\", program_name);\n-        return;\n-    }\n-    memset(&netaddr, 0, sizeof(netaddr));\n-    netaddr.inet.family = PR_AF_INET;\n-    netaddr.inet.port = PR_htons(TCP_SERVER_PORT);\n-    netaddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    /*\n-     * try a few times to bind server's address, if addresses are in\n-     * use\n-     */\n-    i = 0;\n-    while (PR_Bind(sockfd, &netaddr) < 0) {\n-        if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n-            netaddr.inet.port += 2;\n-            if (i++ < SERVER_MAX_BIND_COUNT) {\n-                continue;\n-            }\n-        }\n-        fprintf(stderr, \"%s: ERROR - PR_Bind failed\\n\", program_name);\n-        perror(\"PR_Bind\");\n-        failed_already = 1;\n-        return;\n-    }\n-\n-    if (PR_Listen(sockfd, 32) < 0) {\n-        fprintf(stderr, \"%s: ERROR - PR_Listen failed\\n\", program_name);\n-        failed_already = 1;\n-        return;\n+static void PR_CALLBACK TCP_Server(void* arg) {\n+  PRThreadPool* tp = (PRThreadPool*)arg;\n+  Server_Param* sp;\n+  PRFileDesc* sockfd;\n+  PRNetAddr netaddr;\n+  PRMonitor* sc_mon;\n+  PRJob* jobp;\n+  int i;\n+  PRStatus rval;\n+\n+  /*\n+   * Create a tcp socket\n+   */\n+  if ((sockfd = PR_NewTCPSocket()) == NULL) {\n+    fprintf(stderr, \"%s: PR_NewTCPSocket failed\\n\", program_name);\n+    return;\n+  }\n+  memset(&netaddr, 0, sizeof(netaddr));\n+  netaddr.inet.family = PR_AF_INET;\n+  netaddr.inet.port = PR_htons(TCP_SERVER_PORT);\n+  netaddr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  /*\n+   * try a few times to bind server's address, if addresses are in\n+   * use\n+   */\n+  i = 0;\n+  while (PR_Bind(sockfd, &netaddr) < 0) {\n+    if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n+      netaddr.inet.port += 2;\n+      if (i++ < SERVER_MAX_BIND_COUNT) {\n+        continue;\n+      }\n     }\n+    fprintf(stderr, \"%s: ERROR - PR_Bind failed\\n\", program_name);\n+    perror(\"PR_Bind\");\n+    failed_already = 1;\n+    return;\n+  }\n \n-    if (PR_GetSockName(sockfd, &netaddr) < 0) {\n-        fprintf(stderr, \"%s: ERROR - PR_GetSockName failed\\n\", program_name);\n-        failed_already = 1;\n-        return;\n-    }\n+  if (PR_Listen(sockfd, 32) < 0) {\n+    fprintf(stderr, \"%s: ERROR - PR_Listen failed\\n\", program_name);\n+    failed_already = 1;\n+    return;\n+  }\n \n-    DPRINTF(\n-        (\"TCP_Server: PR_BIND netaddr.inet.ip = 0x%lx, netaddr.inet.port = %d\\n\",\n-         netaddr.inet.ip, netaddr.inet.port));\n+  if (PR_GetSockName(sockfd, &netaddr) < 0) {\n+    fprintf(stderr, \"%s: ERROR - PR_GetSockName failed\\n\", program_name);\n+    failed_already = 1;\n+    return;\n+  }\n \n-    sp = PR_NEW(Server_Param);\n-    if (sp == NULL) {\n-        fprintf(stderr, \"%s: PR_NEW failed\\n\", program_name);\n-        failed_already = 1;\n-        return;\n-    }\n-    sp->iod.socket = sockfd;\n-    sp->iod.timeout = PR_SecondsToInterval(60);\n-    sp->datalen = tcp_mesg_size;\n-    sp->exit_mon = sc_mon;\n-    sp->job_counterp = &job_counter;\n-    sp->conn_counter = 0;\n-    sp->tp = tp;\n-    sp->netaddr = netaddr;\n-\n-    /* create and cancel an io job */\n-    jobp = PR_QueueJob_Accept(tp, &sp->iod, TCP_Server_Accept, sp, PR_FALSE);\n-    PR_ASSERT(NULL != jobp);\n-    rval = PR_CancelJob(jobp);\n-    PR_ASSERT(PR_SUCCESS == rval);\n+  DPRINTF(\n+      (\"TCP_Server: PR_BIND netaddr.inet.ip = 0x%lx, netaddr.inet.port = %d\\n\",\n+       netaddr.inet.ip, netaddr.inet.port));\n \n-    /*\n-     * create the client process\n-     */\n-    {\n+  sp = PR_NEW(Server_Param);\n+  if (sp == NULL) {\n+    fprintf(stderr, \"%s: PR_NEW failed\\n\", program_name);\n+    failed_already = 1;\n+    return;\n+  }\n+  sp->iod.socket = sockfd;\n+  sp->iod.timeout = PR_SecondsToInterval(60);\n+  sp->datalen = tcp_mesg_size;\n+  sp->exit_mon = sc_mon;\n+  sp->job_counterp = &job_counter;\n+  sp->conn_counter = 0;\n+  sp->tp = tp;\n+  sp->netaddr = netaddr;\n+\n+  /* create and cancel an io job */\n+  jobp = PR_QueueJob_Accept(tp, &sp->iod, TCP_Server_Accept, sp, PR_FALSE);\n+  PR_ASSERT(NULL != jobp);\n+  rval = PR_CancelJob(jobp);\n+  PR_ASSERT(PR_SUCCESS == rval);\n+\n+  /*\n+   * create the client process\n+   */\n+  {\n #define MAX_ARGS 4\n-        char* argv[MAX_ARGS + 1];\n-        int index = 0;\n-        char port[32];\n-        char path[1024 + sizeof(\"/thrpool_client\")];\n+    char* argv[MAX_ARGS + 1];\n+    int index = 0;\n+    char port[32];\n+    char path[1024 + sizeof(\"/thrpool_client\")];\n \n-        getcwd(path, sizeof(path));\n+    getcwd(path, sizeof(path));\n \n-        (void)strcat(path, \"/thrpool_client\");\n+    (void)strcat(path, \"/thrpool_client\");\n #ifdef XP_PC\n-        (void)strcat(path, \".exe\");\n+    (void)strcat(path, \".exe\");\n #endif\n-        argv[index++] = path;\n-        sprintf(port, \"%d\", PR_ntohs(netaddr.inet.port));\n-        if (_debug_on) {\n-            argv[index++] = \"-d\";\n-            argv[index++] = \"-p\";\n-            argv[index++] = port;\n-            argv[index++] = NULL;\n-        } else {\n-            argv[index++] = \"-p\";\n-            argv[index++] = port;\n-            argv[index++] = NULL;\n-        }\n-        PR_ASSERT(MAX_ARGS >= (index - 1));\n-\n-        DPRINTF((\"creating client process %s ...\\n\", path));\n-        if (PR_FAILURE == PR_CreateProcessDetached(path, argv, NULL, NULL)) {\n-            fprintf(stderr,\n-                    \"thrpool_server: ERROR - PR_CreateProcessDetached failed\\n\");\n-            failed_already = 1;\n-            return;\n-        }\n+    argv[index++] = path;\n+    sprintf(port, \"%d\", PR_ntohs(netaddr.inet.port));\n+    if (_debug_on) {\n+      argv[index++] = \"-d\";\n+      argv[index++] = \"-p\";\n+      argv[index++] = port;\n+      argv[index++] = NULL;\n+    } else {\n+      argv[index++] = \"-p\";\n+      argv[index++] = port;\n+      argv[index++] = NULL;\n     }\n-\n-    sc_mon = PR_NewMonitor();\n-    if (sc_mon == NULL) {\n-        fprintf(stderr, \"%s: PR_NewMonitor failed\\n\", program_name);\n-        failed_already = 1;\n-        return;\n+    PR_ASSERT(MAX_ARGS >= (index - 1));\n+\n+    DPRINTF((\"creating client process %s ...\\n\", path));\n+    if (PR_FAILURE == PR_CreateProcessDetached(path, argv, NULL, NULL)) {\n+      fprintf(stderr,\n+              \"thrpool_server: ERROR - PR_CreateProcessDetached failed\\n\");\n+      failed_already = 1;\n+      return;\n     }\n+  }\n \n-    sp->iod.socket = sockfd;\n-    sp->iod.timeout = PR_SecondsToInterval(60);\n-    sp->datalen = tcp_mesg_size;\n-    sp->exit_mon = sc_mon;\n-    sp->job_counterp = &job_counter;\n-    sp->conn_counter = 0;\n-    sp->tp = tp;\n-    sp->netaddr = netaddr;\n-\n-    /* create and cancel a timer job */\n-    jobp = PR_QueueJob_Timer(tp, PR_MillisecondsToInterval(5000), print_stats, sp,\n-                             PR_FALSE);\n-    PR_ASSERT(NULL != jobp);\n-    rval = PR_CancelJob(jobp);\n-    PR_ASSERT(PR_SUCCESS == rval);\n-\n-    DPRINTF((\"TCP_Server: Accepting connections \\n\"));\n-\n-    jobp = PR_QueueJob_Accept(tp, &sp->iod, TCP_Server_Accept, sp, PR_FALSE);\n-    PR_ASSERT(NULL != jobp);\n+  sc_mon = PR_NewMonitor();\n+  if (sc_mon == NULL) {\n+    fprintf(stderr, \"%s: PR_NewMonitor failed\\n\", program_name);\n+    failed_already = 1;\n     return;\n+  }\n+\n+  sp->iod.socket = sockfd;\n+  sp->iod.timeout = PR_SecondsToInterval(60);\n+  sp->datalen = tcp_mesg_size;\n+  sp->exit_mon = sc_mon;\n+  sp->job_counterp = &job_counter;\n+  sp->conn_counter = 0;\n+  sp->tp = tp;\n+  sp->netaddr = netaddr;\n+\n+  /* create and cancel a timer job */\n+  jobp = PR_QueueJob_Timer(tp, PR_MillisecondsToInterval(5000), print_stats, sp,\n+                           PR_FALSE);\n+  PR_ASSERT(NULL != jobp);\n+  rval = PR_CancelJob(jobp);\n+  PR_ASSERT(PR_SUCCESS == rval);\n+\n+  DPRINTF((\"TCP_Server: Accepting connections \\n\"));\n+\n+  jobp = PR_QueueJob_Accept(tp, &sp->iod, TCP_Server_Accept, sp, PR_FALSE);\n+  PR_ASSERT(NULL != jobp);\n+  return;\n }\n \n-static void\n-TCP_Server_Accept(void* arg)\n-{\n-    Server_Param* sp = (Server_Param*)arg;\n-    PRThreadPool* tp = sp->tp;\n-    Serve_Client_Param* scp;\n-    PRFileDesc* newsockfd;\n-    PRJob* jobp;\n-\n-    if ((newsockfd = PR_Accept(sp->iod.socket, &sp->netaddr,\n-                               PR_INTERVAL_NO_TIMEOUT)) == NULL) {\n-        fprintf(stderr, \"%s: ERROR - PR_Accept failed\\n\", program_name);\n-        failed_already = 1;\n-        goto exit;\n-    }\n-    scp = PR_NEW(Serve_Client_Param);\n-    if (scp == NULL) {\n-        fprintf(stderr, \"%s: PR_NEW failed\\n\", program_name);\n-        failed_already = 1;\n-        goto exit;\n-    }\n-\n-    /*\n-     * Start a Serve_Client job for each incoming connection\n-     */\n-    scp->iod.socket = newsockfd;\n-    scp->iod.timeout = PR_SecondsToInterval(60);\n-    scp->datalen = tcp_mesg_size;\n-    scp->exit_mon = sp->exit_mon;\n-    scp->job_counterp = sp->job_counterp;\n-    scp->tp = sp->tp;\n-\n-    PR_EnterMonitor(sp->exit_mon);\n-    (*sp->job_counterp)++;\n-    PR_ExitMonitor(sp->exit_mon);\n-    jobp = PR_QueueJob(tp, Serve_Client, scp, PR_FALSE);\n-\n+static void TCP_Server_Accept(void* arg) {\n+  Server_Param* sp = (Server_Param*)arg;\n+  PRThreadPool* tp = sp->tp;\n+  Serve_Client_Param* scp;\n+  PRFileDesc* newsockfd;\n+  PRJob* jobp;\n+\n+  if ((newsockfd = PR_Accept(sp->iod.socket, &sp->netaddr,\n+                             PR_INTERVAL_NO_TIMEOUT)) == NULL) {\n+    fprintf(stderr, \"%s: ERROR - PR_Accept failed\\n\", program_name);\n+    failed_already = 1;\n+    goto exit;\n+  }\n+  scp = PR_NEW(Serve_Client_Param);\n+  if (scp == NULL) {\n+    fprintf(stderr, \"%s: PR_NEW failed\\n\", program_name);\n+    failed_already = 1;\n+    goto exit;\n+  }\n+\n+  /*\n+   * Start a Serve_Client job for each incoming connection\n+   */\n+  scp->iod.socket = newsockfd;\n+  scp->iod.timeout = PR_SecondsToInterval(60);\n+  scp->datalen = tcp_mesg_size;\n+  scp->exit_mon = sp->exit_mon;\n+  scp->job_counterp = sp->job_counterp;\n+  scp->tp = sp->tp;\n+\n+  PR_EnterMonitor(sp->exit_mon);\n+  (*sp->job_counterp)++;\n+  PR_ExitMonitor(sp->exit_mon);\n+  jobp = PR_QueueJob(tp, Serve_Client, scp, PR_FALSE);\n+\n+  PR_ASSERT(NULL != jobp);\n+  DPRINTF((\"TCP_Server: Created Serve_Client = 0x%lx\\n\", jobp));\n+\n+  /*\n+   * single-threaded update; no lock needed\n+   */\n+  sp->conn_counter++;\n+  if (sp->conn_counter < (num_tcp_clients * num_tcp_connections_per_client)) {\n+    jobp = PR_QueueJob_Accept(tp, &sp->iod, TCP_Server_Accept, sp, PR_FALSE);\n     PR_ASSERT(NULL != jobp);\n-    DPRINTF((\"TCP_Server: Created Serve_Client = 0x%lx\\n\", jobp));\n-\n-    /*\n-     * single-threaded update; no lock needed\n-     */\n-    sp->conn_counter++;\n-    if (sp->conn_counter < (num_tcp_clients * num_tcp_connections_per_client)) {\n-        jobp = PR_QueueJob_Accept(tp, &sp->iod, TCP_Server_Accept, sp, PR_FALSE);\n-        PR_ASSERT(NULL != jobp);\n-        return;\n-    }\n-    jobp = PR_QueueJob_Timer(tp, PR_MillisecondsToInterval(500), print_stats, sp,\n-                             PR_FALSE);\n+    return;\n+  }\n+  jobp = PR_QueueJob_Timer(tp, PR_MillisecondsToInterval(500), print_stats, sp,\n+                           PR_FALSE);\n \n-    PR_ASSERT(NULL != jobp);\n-    DPRINTF((\"TCP_Server: Created print_stats timer job = 0x%lx\\n\", jobp));\n+  PR_ASSERT(NULL != jobp);\n+  DPRINTF((\"TCP_Server: Created print_stats timer job = 0x%lx\\n\", jobp));\n \n exit:\n-    PR_EnterMonitor(sp->exit_mon);\n-    /* Wait for server jobs to finish */\n-    while (0 != *sp->job_counterp) {\n-        PR_Wait(sp->exit_mon, PR_INTERVAL_NO_TIMEOUT);\n-        DPRINTF((\"TCP_Server: conn_counter = %d\\n\", *sp->job_counterp));\n-    }\n-\n-    PR_ExitMonitor(sp->exit_mon);\n-    if (sp->iod.socket) {\n-        PR_Close(sp->iod.socket);\n-    }\n-    PR_DestroyMonitor(sp->exit_mon);\n-    printf(\"%30s\", \"TCP_Socket_Client_Server_Test:\");\n-    printf(\"%2ld Server %2ld Clients %2ld connections_per_client\\n\", 1l,\n-           num_tcp_clients, num_tcp_connections_per_client);\n-    printf(\"%30s %2ld messages_per_connection %4ld bytes_per_message\\n\", \":\",\n-           num_tcp_mesgs_per_connection, tcp_mesg_size);\n-\n-    DPRINTF((\"%s: calling PR_ShutdownThreadPool\\n\", program_name));\n-    PR_ShutdownThreadPool(sp->tp);\n-    PR_DELETE(sp);\n+  PR_EnterMonitor(sp->exit_mon);\n+  /* Wait for server jobs to finish */\n+  while (0 != *sp->job_counterp) {\n+    PR_Wait(sp->exit_mon, PR_INTERVAL_NO_TIMEOUT);\n+    DPRINTF((\"TCP_Server: conn_counter = %d\\n\", *sp->job_counterp));\n+  }\n+\n+  PR_ExitMonitor(sp->exit_mon);\n+  if (sp->iod.socket) {\n+    PR_Close(sp->iod.socket);\n+  }\n+  PR_DestroyMonitor(sp->exit_mon);\n+  printf(\"%30s\", \"TCP_Socket_Client_Server_Test:\");\n+  printf(\"%2ld Server %2ld Clients %2ld connections_per_client\\n\", 1l,\n+         num_tcp_clients, num_tcp_connections_per_client);\n+  printf(\"%30s %2ld messages_per_connection %4ld bytes_per_message\\n\", \":\",\n+         num_tcp_mesgs_per_connection, tcp_mesg_size);\n+\n+  DPRINTF((\"%s: calling PR_ShutdownThreadPool\\n\", program_name));\n+  PR_ShutdownThreadPool(sp->tp);\n+  PR_DELETE(sp);\n }\n \n /************************************************************************/\n@@ -501,62 +487,60 @@ exit:\n #define DEFAULT_MAX_THREADS 100\n #define DEFAULT_STACKSIZE (512 * 1024)\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRInt32 initial_threads = DEFAULT_INITIAL_THREADS;\n-    PRInt32 max_threads = DEFAULT_MAX_THREADS;\n-    PRInt32 stacksize = DEFAULT_STACKSIZE;\n-    PRThreadPool* tp = NULL;\n-    PRStatus rv;\n-    PRJob* jobp;\n-\n-    /*\n-     * -d           debug mode\n-     */\n-    PLOptStatus os;\n-    PLOptState* opt;\n-\n-    program_name = argv[0];\n-    opt = PL_CreateOptState(argc, argv, \"d\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                _debug_on = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  PRInt32 initial_threads = DEFAULT_INITIAL_THREADS;\n+  PRInt32 max_threads = DEFAULT_MAX_THREADS;\n+  PRInt32 stacksize = DEFAULT_STACKSIZE;\n+  PRThreadPool* tp = NULL;\n+  PRStatus rv;\n+  PRJob* jobp;\n+\n+  /*\n+   * -d           debug mode\n+   */\n+  PLOptStatus os;\n+  PLOptState* opt;\n+\n+  program_name = argv[0];\n+  opt = PL_CreateOptState(argc, argv, \"d\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        _debug_on = 1;\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    PR_SetConcurrency(4);\n+  PR_SetConcurrency(4);\n \n-    tp = PR_CreateThreadPool(initial_threads, max_threads, stacksize);\n-    if (NULL == tp) {\n-        printf(\"PR_CreateThreadPool failed\\n\");\n-        failed_already = 1;\n-        goto done;\n-    }\n-    jobp = PR_QueueJob(tp, TCP_Server, tp, PR_TRUE);\n-    rv = PR_JoinJob(jobp);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+  tp = PR_CreateThreadPool(initial_threads, max_threads, stacksize);\n+  if (NULL == tp) {\n+    printf(\"PR_CreateThreadPool failed\\n\");\n+    failed_already = 1;\n+    goto done;\n+  }\n+  jobp = PR_QueueJob(tp, TCP_Server, tp, PR_TRUE);\n+  rv = PR_JoinJob(jobp);\n+  PR_ASSERT(PR_SUCCESS == rv);\n \n-    DPRINTF((\"%s: calling PR_JoinThreadPool\\n\", program_name));\n-    rv = PR_JoinThreadPool(tp);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-    DPRINTF((\"%s: returning from PR_JoinThreadPool\\n\", program_name));\n+  DPRINTF((\"%s: calling PR_JoinThreadPool\\n\", program_name));\n+  rv = PR_JoinThreadPool(tp);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+  DPRINTF((\"%s: returning from PR_JoinThreadPool\\n\", program_name));\n \n done:\n-    PR_Cleanup();\n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  PR_Cleanup();\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/thruput.c b/nspr/pr/tests/thruput.c\nindex 37a482a..8d93fe4 100644\n--- a/nspr/pr/tests/thruput.c\n+++ b/nspr/pr/tests/thruput.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -28,14 +29,14 @@\n #define ADDR_BUFFER 100\n \n #ifdef DEBUG\n-#define PORT_INC_DO +100\n+#  define PORT_INC_DO +100\n #else\n-#define PORT_INC_DO\n+#  define PORT_INC_DO\n #endif\n #ifdef IS_64\n-#define PORT_INC_3264 +200\n+#  define PORT_INC_3264 +200\n #else\n-#define PORT_INC_3264\n+#  define PORT_INC_3264\n #endif\n \n #define PORT_NUMBER 51877 PORT_INC_DO PORT_INC_3264\n@@ -53,328 +54,314 @@ static PRInt32 buffer_size = BUFFER_SIZE;\n static PRThreadScope thread_scope = PR_LOCAL_THREAD;\n \n typedef struct Shared {\n-    PRLock* ml;\n-    PRUint32 sampled;\n-    PRUint32 threads;\n-    PRIntervalTime timein;\n-    PRNetAddr server_address;\n+  PRLock* ml;\n+  PRUint32 sampled;\n+  PRUint32 threads;\n+  PRIntervalTime timein;\n+  PRNetAddr server_address;\n } Shared;\n \n static Shared* shared = NULL;\n \n-static PRStatus\n-PrintAddress(const PRNetAddr* address)\n-{\n-    char buffer[ADDR_BUFFER];\n-    PRStatus rv = PR_NetAddrToString(address, buffer, sizeof(buffer));\n-    if (PR_SUCCESS == rv) {\n-        PR_fprintf(err, \"%s:%u\\n\", buffer, PR_ntohs(address->inet.port));\n-    } else {\n-        PL_FPrintError(err, \"PR_NetAddrToString\");\n-    }\n-    return rv;\n+static PRStatus PrintAddress(const PRNetAddr* address) {\n+  char buffer[ADDR_BUFFER];\n+  PRStatus rv = PR_NetAddrToString(address, buffer, sizeof(buffer));\n+  if (PR_SUCCESS == rv) {\n+    PR_fprintf(err, \"%s:%u\\n\", buffer, PR_ntohs(address->inet.port));\n+  } else {\n+    PL_FPrintError(err, \"PR_NetAddrToString\");\n+  }\n+  return rv;\n } /* PrintAddress */\n \n-static void PR_CALLBACK\n-Clientel(void* arg)\n-{\n-    PRStatus rv;\n-    PRFileDesc* xport;\n-    PRInt32 bytes, sampled;\n-    PRIntervalTime now, interval;\n-    PRBool do_display = PR_FALSE;\n-    Shared* shared = (Shared*)arg;\n-    char* buffer = (char*)PR_Malloc(buffer_size);\n-    PRNetAddr* server_address = &shared->server_address;\n-    PRIntervalTime connect_timeout = PR_SecondsToInterval(5);\n-    PRIntervalTime sampling_interval = PR_SecondsToInterval(SAMPLING_INTERVAL);\n-\n-    PR_fprintf(err, \"Client connecting to \");\n-    (void)PrintAddress(server_address);\n-\n-    do {\n-        xport = PR_Socket(domain, PR_SOCK_STREAM, protocol);\n-        if (NULL == xport) {\n-            PL_FPrintError(err, \"PR_Socket\");\n-            return;\n-        }\n+static void PR_CALLBACK Clientel(void* arg) {\n+  PRStatus rv;\n+  PRFileDesc* xport;\n+  PRInt32 bytes, sampled;\n+  PRIntervalTime now, interval;\n+  PRBool do_display = PR_FALSE;\n+  Shared* shared = (Shared*)arg;\n+  char* buffer = (char*)PR_Malloc(buffer_size);\n+  PRNetAddr* server_address = &shared->server_address;\n+  PRIntervalTime connect_timeout = PR_SecondsToInterval(5);\n+  PRIntervalTime sampling_interval = PR_SecondsToInterval(SAMPLING_INTERVAL);\n+\n+  PR_fprintf(err, \"Client connecting to \");\n+  (void)PrintAddress(server_address);\n+\n+  do {\n+    xport = PR_Socket(domain, PR_SOCK_STREAM, protocol);\n+    if (NULL == xport) {\n+      PL_FPrintError(err, \"PR_Socket\");\n+      return;\n+    }\n \n-        if (xport_buffer != -1) {\n-            PRSocketOptionData data;\n-            data.option = PR_SockOpt_RecvBufferSize;\n-            data.value.recv_buffer_size = (PRSize)xport_buffer;\n-            rv = PR_SetSocketOption(xport, &data);\n-            if (PR_FAILURE == rv) {\n-                PL_FPrintError(err, \"PR_SetSocketOption - ignored\");\n-            }\n-            data.option = PR_SockOpt_SendBufferSize;\n-            data.value.send_buffer_size = (PRSize)xport_buffer;\n-            rv = PR_SetSocketOption(xport, &data);\n-            if (PR_FAILURE == rv) {\n-                PL_FPrintError(err, \"PR_SetSocketOption - ignored\");\n-            }\n-        }\n+    if (xport_buffer != -1) {\n+      PRSocketOptionData data;\n+      data.option = PR_SockOpt_RecvBufferSize;\n+      data.value.recv_buffer_size = (PRSize)xport_buffer;\n+      rv = PR_SetSocketOption(xport, &data);\n+      if (PR_FAILURE == rv) {\n+        PL_FPrintError(err, \"PR_SetSocketOption - ignored\");\n+      }\n+      data.option = PR_SockOpt_SendBufferSize;\n+      data.value.send_buffer_size = (PRSize)xport_buffer;\n+      rv = PR_SetSocketOption(xport, &data);\n+      if (PR_FAILURE == rv) {\n+        PL_FPrintError(err, \"PR_SetSocketOption - ignored\");\n+      }\n+    }\n \n-        rv = PR_Connect(xport, server_address, connect_timeout);\n-        if (PR_FAILURE == rv) {\n-            PL_FPrintError(err, \"PR_Connect\");\n-            if (PR_IO_TIMEOUT_ERROR != PR_GetError()) {\n-                PR_Sleep(connect_timeout);\n-            }\n-            PR_Close(xport); /* delete it and start over */\n-        }\n-    } while (PR_FAILURE == rv);\n-\n-    do {\n-        bytes = PR_Recv(xport, buffer, buffer_size, 0, PR_INTERVAL_NO_TIMEOUT);\n-        PR_Lock(shared->ml);\n-        now = PR_IntervalNow();\n-        shared->sampled += bytes;\n-        interval = now - shared->timein;\n-        if (interval > sampling_interval) {\n-            sampled = shared->sampled;\n-            shared->timein = now;\n-            shared->sampled = 0;\n-            do_display = PR_TRUE;\n-        }\n-        PR_Unlock(shared->ml);\n+    rv = PR_Connect(xport, server_address, connect_timeout);\n+    if (PR_FAILURE == rv) {\n+      PL_FPrintError(err, \"PR_Connect\");\n+      if (PR_IO_TIMEOUT_ERROR != PR_GetError()) {\n+        PR_Sleep(connect_timeout);\n+      }\n+      PR_Close(xport); /* delete it and start over */\n+    }\n+  } while (PR_FAILURE == rv);\n+\n+  do {\n+    bytes = PR_Recv(xport, buffer, buffer_size, 0, PR_INTERVAL_NO_TIMEOUT);\n+    PR_Lock(shared->ml);\n+    now = PR_IntervalNow();\n+    shared->sampled += bytes;\n+    interval = now - shared->timein;\n+    if (interval > sampling_interval) {\n+      sampled = shared->sampled;\n+      shared->timein = now;\n+      shared->sampled = 0;\n+      do_display = PR_TRUE;\n+    }\n+    PR_Unlock(shared->ml);\n \n-        if (do_display) {\n-            PRUint32 rate = sampled / PR_IntervalToMilliseconds(interval);\n-            PR_fprintf(err, \"%u streams @ %u Kbytes/sec\\n\", shared->threads, rate);\n-            do_display = PR_FALSE;\n-        }\n+    if (do_display) {\n+      PRUint32 rate = sampled / PR_IntervalToMilliseconds(interval);\n+      PR_fprintf(err, \"%u streams @ %u Kbytes/sec\\n\", shared->threads, rate);\n+      do_display = PR_FALSE;\n+    }\n \n-    } while (bytes > 0);\n+  } while (bytes > 0);\n } /* Clientel */\n \n-static void\n-Client(const char* server_name)\n-{\n-    PRStatus rv;\n-    PRHostEnt host;\n-    char buffer[PR_NETDB_BUF_SIZE];\n-    PRIntervalTime dally = PR_SecondsToInterval(60);\n-    PR_fprintf(err, \"Translating the name %s\\n\", server_name);\n-    rv = PR_GetHostByName(server_name, buffer, sizeof(buffer), &host);\n-    if (PR_FAILURE == rv) {\n-        PL_FPrintError(err, \"PR_GetHostByName\");\n+static void Client(const char* server_name) {\n+  PRStatus rv;\n+  PRHostEnt host;\n+  char buffer[PR_NETDB_BUF_SIZE];\n+  PRIntervalTime dally = PR_SecondsToInterval(60);\n+  PR_fprintf(err, \"Translating the name %s\\n\", server_name);\n+  rv = PR_GetHostByName(server_name, buffer, sizeof(buffer), &host);\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err, \"PR_GetHostByName\");\n+  } else {\n+    if (PR_EnumerateHostEnt(0, &host, PORT_NUMBER, &shared->server_address) <\n+        0) {\n+      PL_FPrintError(err, \"PR_EnumerateHostEnt\");\n     } else {\n-        if (PR_EnumerateHostEnt(0, &host, PORT_NUMBER, &shared->server_address) <\n-            0) {\n-            PL_FPrintError(err, \"PR_EnumerateHostEnt\");\n-        } else {\n-            do {\n-                shared->threads += 1;\n-                (void)PR_CreateThread(PR_USER_THREAD, Clientel, shared,\n-                                      PR_PRIORITY_NORMAL, thread_scope,\n-                                      PR_UNJOINABLE_THREAD, 8 * 1024);\n-                if (shared->threads == initial_streams) {\n-                    PR_Sleep(dally);\n-                    initial_streams += 1;\n-                }\n-            } while (PR_TRUE);\n+      do {\n+        shared->threads += 1;\n+        (void)PR_CreateThread(PR_USER_THREAD, Clientel, shared,\n+                              PR_PRIORITY_NORMAL, thread_scope,\n+                              PR_UNJOINABLE_THREAD, 8 * 1024);\n+        if (shared->threads == initial_streams) {\n+          PR_Sleep(dally);\n+          initial_streams += 1;\n         }\n+      } while (PR_TRUE);\n     }\n+  }\n }\n \n-static void PR_CALLBACK\n-Servette(void* arg)\n-{\n-    PRInt32 bytes, sampled;\n-    PRIntervalTime now, interval;\n-    PRBool do_display = PR_FALSE;\n-    PRFileDesc* client = (PRFileDesc*)arg;\n-    char* buffer = (char*)PR_Malloc(buffer_size);\n-    PRIntervalTime sampling_interval = PR_SecondsToInterval(SAMPLING_INTERVAL);\n+static void PR_CALLBACK Servette(void* arg) {\n+  PRInt32 bytes, sampled;\n+  PRIntervalTime now, interval;\n+  PRBool do_display = PR_FALSE;\n+  PRFileDesc* client = (PRFileDesc*)arg;\n+  char* buffer = (char*)PR_Malloc(buffer_size);\n+  PRIntervalTime sampling_interval = PR_SecondsToInterval(SAMPLING_INTERVAL);\n \n-    if (xport_buffer != -1) {\n-        PRStatus rv;\n-        PRSocketOptionData data;\n-        data.option = PR_SockOpt_RecvBufferSize;\n-        data.value.recv_buffer_size = (PRSize)xport_buffer;\n-        rv = PR_SetSocketOption(client, &data);\n-        if (PR_FAILURE == rv) {\n-            PL_FPrintError(err, \"PR_SetSocketOption - ignored\");\n-        }\n-        data.option = PR_SockOpt_SendBufferSize;\n-        data.value.send_buffer_size = (PRSize)xport_buffer;\n-        rv = PR_SetSocketOption(client, &data);\n-        if (PR_FAILURE == rv) {\n-            PL_FPrintError(err, \"PR_SetSocketOption - ignored\");\n-        }\n-    }\n-\n-    do {\n-        bytes = PR_Send(client, buffer, buffer_size, 0, PR_INTERVAL_NO_TIMEOUT);\n-\n-        PR_Lock(shared->ml);\n-        now = PR_IntervalNow();\n-        shared->sampled += bytes;\n-        interval = now - shared->timein;\n-        if (interval > sampling_interval) {\n-            sampled = shared->sampled;\n-            shared->timein = now;\n-            shared->sampled = 0;\n-            do_display = PR_TRUE;\n-        }\n-        PR_Unlock(shared->ml);\n-\n-        if (do_display) {\n-            PRUint32 rate = sampled / PR_IntervalToMilliseconds(interval);\n-            PR_fprintf(err, \"%u streams @ %u Kbytes/sec\\n\", shared->threads, rate);\n-            do_display = PR_FALSE;\n-        }\n-    } while (bytes > 0);\n-} /* Servette */\n-\n-static void\n-Server(void)\n-{\n+  if (xport_buffer != -1) {\n     PRStatus rv;\n-    PRNetAddr server_address, client_address;\n-    PRFileDesc* xport = PR_Socket(domain, PR_SOCK_STREAM, protocol);\n+    PRSocketOptionData data;\n+    data.option = PR_SockOpt_RecvBufferSize;\n+    data.value.recv_buffer_size = (PRSize)xport_buffer;\n+    rv = PR_SetSocketOption(client, &data);\n+    if (PR_FAILURE == rv) {\n+      PL_FPrintError(err, \"PR_SetSocketOption - ignored\");\n+    }\n+    data.option = PR_SockOpt_SendBufferSize;\n+    data.value.send_buffer_size = (PRSize)xport_buffer;\n+    rv = PR_SetSocketOption(client, &data);\n+    if (PR_FAILURE == rv) {\n+      PL_FPrintError(err, \"PR_SetSocketOption - ignored\");\n+    }\n+  }\n+\n+  do {\n+    bytes = PR_Send(client, buffer, buffer_size, 0, PR_INTERVAL_NO_TIMEOUT);\n+\n+    PR_Lock(shared->ml);\n+    now = PR_IntervalNow();\n+    shared->sampled += bytes;\n+    interval = now - shared->timein;\n+    if (interval > sampling_interval) {\n+      sampled = shared->sampled;\n+      shared->timein = now;\n+      shared->sampled = 0;\n+      do_display = PR_TRUE;\n+    }\n+    PR_Unlock(shared->ml);\n \n-    if (NULL == xport) {\n-        PL_FPrintError(err, \"PR_Socket\");\n-        return;\n+    if (do_display) {\n+      PRUint32 rate = sampled / PR_IntervalToMilliseconds(interval);\n+      PR_fprintf(err, \"%u streams @ %u Kbytes/sec\\n\", shared->threads, rate);\n+      do_display = PR_FALSE;\n     }\n+  } while (bytes > 0);\n+} /* Servette */\n \n-    rv = PR_InitializeNetAddr(PR_IpAddrAny, PORT_NUMBER, &server_address);\n+static void Server(void) {\n+  PRStatus rv;\n+  PRNetAddr server_address, client_address;\n+  PRFileDesc* xport = PR_Socket(domain, PR_SOCK_STREAM, protocol);\n+\n+  if (NULL == xport) {\n+    PL_FPrintError(err, \"PR_Socket\");\n+    return;\n+  }\n+\n+  rv = PR_InitializeNetAddr(PR_IpAddrAny, PORT_NUMBER, &server_address);\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err, \"PR_InitializeNetAddr\");\n+  } else {\n+    rv = PR_Bind(xport, &server_address);\n     if (PR_FAILURE == rv) {\n-        PL_FPrintError(err, \"PR_InitializeNetAddr\");\n+      PL_FPrintError(err, \"PR_Bind\");\n     } else {\n-        rv = PR_Bind(xport, &server_address);\n-        if (PR_FAILURE == rv) {\n-            PL_FPrintError(err, \"PR_Bind\");\n+      PRFileDesc* client;\n+      rv = PR_Listen(xport, 10);\n+      PR_fprintf(err, \"Server listening on \");\n+      (void)PrintAddress(&server_address);\n+      do {\n+        client = PR_Accept(xport, &client_address, PR_INTERVAL_NO_TIMEOUT);\n+        if (NULL == client) {\n+          PL_FPrintError(err, \"PR_Accept\");\n         } else {\n-            PRFileDesc* client;\n-            rv = PR_Listen(xport, 10);\n-            PR_fprintf(err, \"Server listening on \");\n-            (void)PrintAddress(&server_address);\n-            do {\n-                client = PR_Accept(xport, &client_address, PR_INTERVAL_NO_TIMEOUT);\n-                if (NULL == client) {\n-                    PL_FPrintError(err, \"PR_Accept\");\n-                } else {\n-                    PR_fprintf(err, \"Server accepting from \");\n-                    (void)PrintAddress(&client_address);\n-                    shared->threads += 1;\n-                    (void)PR_CreateThread(PR_USER_THREAD, Servette, client,\n-                                          PR_PRIORITY_NORMAL, thread_scope,\n-                                          PR_UNJOINABLE_THREAD, 8 * 1024);\n-                }\n-            } while (PR_TRUE);\n+          PR_fprintf(err, \"Server accepting from \");\n+          (void)PrintAddress(&client_address);\n+          shared->threads += 1;\n+          (void)PR_CreateThread(PR_USER_THREAD, Servette, client,\n+                                PR_PRIORITY_NORMAL, thread_scope,\n+                                PR_UNJOINABLE_THREAD, 8 * 1024);\n         }\n+      } while (PR_TRUE);\n     }\n+  }\n } /* Server */\n \n-static void\n-Help(void)\n-{\n-    PR_fprintf(err, \"Usage: [-h] [<server>]\\n\");\n-    PR_fprintf(err, \"\\t-s <n>   Initial # of connections        (default: 1)\\n\");\n-    PR_fprintf(err, \"\\t-C <n>   Set 'concurrency'               (default: 1)\\n\");\n-    PR_fprintf(err,\n-               \"\\t-b <nK>  Client buffer size              (default: 32k)\\n\");\n-    PR_fprintf(err,\n-               \"\\t-B <nK>  Transport recv/send buffer size (default: sys)\\n\");\n-    PR_fprintf(err,\n-               \"\\t-G       Use GLOBAL threads              (default: LOCAL)\\n\");\n-    PR_fprintf(err,\n-               \"\\t-X       Use XTP transport               (default: TCP)\\n\");\n-    PR_fprintf(err,\n-               \"\\t-6       Use IPv6                        (default: IPv4)\\n\");\n-    PR_fprintf(err, \"\\t-h       This message and nothing else\\n\");\n-    PR_fprintf(err, \"\\t<server> DNS name of server\\n\");\n-    PR_fprintf(err, \"\\t\\tIf <server> is not specified, this host will be\\n\");\n-    PR_fprintf(err, \"\\t\\tthe server and not act as a client.\\n\");\n+static void Help(void) {\n+  PR_fprintf(err, \"Usage: [-h] [<server>]\\n\");\n+  PR_fprintf(err, \"\\t-s <n>   Initial # of connections        (default: 1)\\n\");\n+  PR_fprintf(err, \"\\t-C <n>   Set 'concurrency'               (default: 1)\\n\");\n+  PR_fprintf(err,\n+             \"\\t-b <nK>  Client buffer size              (default: 32k)\\n\");\n+  PR_fprintf(err,\n+             \"\\t-B <nK>  Transport recv/send buffer size (default: sys)\\n\");\n+  PR_fprintf(err,\n+             \"\\t-G       Use GLOBAL threads              (default: LOCAL)\\n\");\n+  PR_fprintf(err,\n+             \"\\t-X       Use XTP transport               (default: TCP)\\n\");\n+  PR_fprintf(err,\n+             \"\\t-6       Use IPv6                        (default: IPv4)\\n\");\n+  PR_fprintf(err, \"\\t-h       This message and nothing else\\n\");\n+  PR_fprintf(err, \"\\t<server> DNS name of server\\n\");\n+  PR_fprintf(err, \"\\t\\tIf <server> is not specified, this host will be\\n\");\n+  PR_fprintf(err, \"\\t\\tthe server and not act as a client.\\n\");\n } /* Help */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PLOptStatus os;\n-    const char* server_name = NULL;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"hGX6C:b:s:B:\");\n+int main(int argc, char** argv) {\n+  PLOptStatus os;\n+  const char* server_name = NULL;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"hGX6C:b:s:B:\");\n \n-    err = PR_GetSpecialFD(PR_StandardError);\n+  err = PR_GetSpecialFD(PR_StandardError);\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 0: /* Name of server */\n-                server_name = opt->value;\n-                break;\n-            case 'G': /* Globular threads */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'X': /* Use XTP as the transport */\n-                protocol = 36;\n-                break;\n-            case '6': /* Use IPv6 */\n-                domain = PR_AF_INET6;\n-                break;\n-            case 's': /* initial_streams */\n-                initial_streams = atoi(opt->value);\n-                break;\n-            case 'C': /* concurrency */\n-                concurrency = atoi(opt->value);\n-                break;\n-            case 'b': /* buffer size */\n-                buffer_size = 1024 * atoi(opt->value);\n-                break;\n-            case 'B': /* buffer size */\n-                xport_buffer = 1024 * atoi(opt->value);\n-                break;\n-            case 'h': /* user wants some guidance */\n-            default:\n-                Help();   /* so give him an earful */\n-                return 2; /* but not a lot else */\n-        }\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 0: /* Name of server */\n+        server_name = opt->value;\n+        break;\n+      case 'G': /* Globular threads */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'X': /* Use XTP as the transport */\n+        protocol = 36;\n+        break;\n+      case '6': /* Use IPv6 */\n+        domain = PR_AF_INET6;\n+        break;\n+      case 's': /* initial_streams */\n+        initial_streams = atoi(opt->value);\n+        break;\n+      case 'C': /* concurrency */\n+        concurrency = atoi(opt->value);\n+        break;\n+      case 'b': /* buffer size */\n+        buffer_size = 1024 * atoi(opt->value);\n+        break;\n+      case 'B': /* buffer size */\n+        xport_buffer = 1024 * atoi(opt->value);\n+        break;\n+      case 'h': /* user wants some guidance */\n+      default:\n+        Help();   /* so give him an earful */\n+        return 2; /* but not a lot else */\n     }\n-    PL_DestroyOptState(opt);\n+  }\n+  PL_DestroyOptState(opt);\n \n-    shared = PR_NEWZAP(Shared);\n-    shared->ml = PR_NewLock();\n+  shared = PR_NEWZAP(Shared);\n+  shared->ml = PR_NewLock();\n \n-    PR_fprintf(err, \"This machine is %s\\n\",\n-               (NULL == server_name) ? \"the SERVER\" : \"a CLIENT\");\n+  PR_fprintf(err, \"This machine is %s\\n\",\n+             (NULL == server_name) ? \"the SERVER\" : \"a CLIENT\");\n \n-    PR_fprintf(err, \"Transport being used is %s\\n\",\n-               (6 == protocol) ? \"TCP\" : \"XTP\");\n-\n-    if (PR_GLOBAL_THREAD == thread_scope) {\n-        if (1 != concurrency) {\n-            PR_fprintf(err, \"  **Concurrency > 1 and GLOBAL threads!?!?\\n\");\n-            PR_fprintf(err, \"  **Ignoring concurrency\\n\");\n-            concurrency = 1;\n-        }\n-    }\n+  PR_fprintf(err, \"Transport being used is %s\\n\",\n+             (6 == protocol) ? \"TCP\" : \"XTP\");\n \n+  if (PR_GLOBAL_THREAD == thread_scope) {\n     if (1 != concurrency) {\n-        PR_SetConcurrency(concurrency);\n-        PR_fprintf(err, \"Concurrency set to %u\\n\", concurrency);\n+      PR_fprintf(err, \"  **Concurrency > 1 and GLOBAL threads!?!?\\n\");\n+      PR_fprintf(err, \"  **Ignoring concurrency\\n\");\n+      concurrency = 1;\n     }\n+  }\n \n-    PR_fprintf(err, \"All threads will be %s\\n\",\n-               (PR_GLOBAL_THREAD == thread_scope) ? \"GLOBAL\" : \"LOCAL\");\n+  if (1 != concurrency) {\n+    PR_SetConcurrency(concurrency);\n+    PR_fprintf(err, \"Concurrency set to %u\\n\", concurrency);\n+  }\n \n-    PR_fprintf(err, \"Client buffer size will be %u\\n\", buffer_size);\n+  PR_fprintf(err, \"All threads will be %s\\n\",\n+             (PR_GLOBAL_THREAD == thread_scope) ? \"GLOBAL\" : \"LOCAL\");\n \n-    if (-1 != xport_buffer)\n-        PR_fprintf(err, \"Transport send & receive buffer size will be %u\\n\",\n-                   xport_buffer);\n+  PR_fprintf(err, \"Client buffer size will be %u\\n\", buffer_size);\n \n-    if (NULL == server_name) {\n-        Server();\n-    } else {\n-        Client(server_name);\n-    }\n+  if (-1 != xport_buffer)\n+    PR_fprintf(err, \"Transport send & receive buffer size will be %u\\n\",\n+               xport_buffer);\n+\n+  if (NULL == server_name) {\n+    Server();\n+  } else {\n+    Client(server_name);\n+  }\n \n-    return 0;\n+  return 0;\n } /* main */\n \n /* thruput.c */\ndiff --git a/nspr/pr/tests/time.c b/nspr/pr/tests/time.c\nindex 0caf3a9..bdc33ee 100644\n--- a/nspr/pr/tests/time.c\n+++ b/nspr/pr/tests/time.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -33,144 +34,126 @@ PRInt32 count;\n time_t itime;\n hrtime_t ihrtime;\n \n-void\n-ftime_init()\n-{\n-    itime = time(NULL);\n-    ihrtime = gethrtime();\n+void ftime_init() {\n+  itime = time(NULL);\n+  ihrtime = gethrtime();\n }\n \n-time_t\n-ftime()\n-{\n-    hrtime_t now = gethrtime();\n+time_t ftime() {\n+  hrtime_t now = gethrtime();\n \n-    return itime + ((now - ihrtime) / 1000000000ll);\n+  return itime + ((now - ihrtime) / 1000000000ll);\n }\n \n-static void\n-timeTime(void)\n-{\n-    PRInt32 index = count;\n-    time_t rv;\n+static void timeTime(void) {\n+  PRInt32 index = count;\n+  time_t rv;\n \n-    for (; index--;) {\n-        rv = time(NULL);\n-    }\n+  for (; index--;) {\n+    rv = time(NULL);\n+  }\n }\n \n-static void\n-timeGethrtime(void)\n-{\n-    PRInt32 index = count;\n-    time_t rv;\n+static void timeGethrtime(void) {\n+  PRInt32 index = count;\n+  time_t rv;\n \n-    for (; index--;) {\n-        rv = ftime();\n-    }\n+  for (; index--;) {\n+    rv = ftime();\n+  }\n }\n \n-static void\n-timeGettimeofday(void)\n-{\n-    PRInt32 index = count;\n-    time_t rv;\n-    struct timeval tp;\n+static void timeGettimeofday(void) {\n+  PRInt32 index = count;\n+  time_t rv;\n+  struct timeval tp;\n \n-    for (; index--;) {\n-        rv = gettimeofday(&tp, NULL);\n-    }\n+  for (; index--;) {\n+    rv = gettimeofday(&tp, NULL);\n+  }\n }\n \n-static void\n-timePRTime32(void)\n-{\n-    PRInt32 index = count;\n-    PRInt32 rv32;\n-    PRTime q;\n-    PRTime rv;\n+static void timePRTime32(void) {\n+  PRInt32 index = count;\n+  PRInt32 rv32;\n+  PRTime q;\n+  PRTime rv;\n \n-    LL_I2L(q, 1000000);\n+  LL_I2L(q, 1000000);\n \n-    for (; index--;) {\n-        rv = PR_Now();\n-        LL_DIV(rv, rv, q);\n-        LL_L2I(rv32, rv);\n-    }\n+  for (; index--;) {\n+    rv = PR_Now();\n+    LL_DIV(rv, rv, q);\n+    LL_L2I(rv32, rv);\n+  }\n }\n \n-static void\n-timePRTime64(void)\n-{\n-    PRInt32 index = count;\n-    PRTime rv;\n+static void timePRTime64(void) {\n+  PRInt32 index = count;\n+  PRTime rv;\n \n-    for (; index--;) {\n-        rv = PR_Now();\n-    }\n+  for (; index--;) {\n+    rv = PR_Now();\n+  }\n }\n \n /************************************************************************/\n \n-static void\n-Measure(void (*func)(void), const char* msg)\n-{\n-    PRIntervalTime start, stop;\n-    double d;\n-    PRInt32 tot;\n+static void Measure(void (*func)(void), const char* msg) {\n+  PRIntervalTime start, stop;\n+  double d;\n+  PRInt32 tot;\n \n-    start = PR_IntervalNow();\n-    (*func)();\n-    stop = PR_IntervalNow();\n+  start = PR_IntervalNow();\n+  (*func)();\n+  stop = PR_IntervalNow();\n \n-    d = (double)PR_IntervalToMicroseconds(stop - start);\n-    tot = PR_IntervalToMilliseconds(stop - start);\n+  d = (double)PR_IntervalToMicroseconds(stop - start);\n+  tot = PR_IntervalToMilliseconds(stop - start);\n \n-    if (debug_mode) {\n-        printf(\"%40s: %6.2f usec avg, %d msec total\\n\", msg, d / count, tot);\n-    }\n+  if (debug_mode) {\n+    printf(\"%40s: %6.2f usec avg, %d msec total\\n\", msg, d / count, tot);\n+  }\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n \n-    if (argc > 1) {\n-        count = atoi(argv[1]);\n-    } else {\n-        count = DEFAULT_COUNT;\n-    }\n+  if (argc > 1) {\n+    count = atoi(argv[1]);\n+  } else {\n+    count = DEFAULT_COUNT;\n+  }\n \n-    ftime_init();\n+  ftime_init();\n \n-    Measure(timeTime, \"time to get time with time()\");\n-    Measure(timeGethrtime, \"time to get time with gethrtime()\");\n-    Measure(timeGettimeofday, \"time to get time with gettimeofday()\");\n-    Measure(timePRTime32, \"time to get time with PR_Time() (32bit)\");\n-    Measure(timePRTime64, \"time to get time with PR_Time() (64bit)\");\n+  Measure(timeTime, \"time to get time with time()\");\n+  Measure(timeGethrtime, \"time to get time with gethrtime()\");\n+  Measure(timeGettimeofday, \"time to get time with gettimeofday()\");\n+  Measure(timePRTime32, \"time to get time with PR_Time() (32bit)\");\n+  Measure(timePRTime64, \"time to get time with PR_Time() (64bit)\");\n \n-    PR_Cleanup();\n-    return 0;\n+  PR_Cleanup();\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/timemac.c b/nspr/pr/tests/timemac.c\nindex 2cd4307..ac06ebb 100644\n--- a/nspr/pr/tests/timemac.c\n+++ b/nspr/pr/tests/timemac.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,99 +11,95 @@\n #include \"prinit.h\"\n #include \"prtime.h\"\n \n-static char* dayOfWeek[] = { \"Sun\", \"Mon\", \"Tue\", \"Wed\",\n-                             \"Thu\", \"Fri\", \"Sat\", \"???\" };\n-static char* month[] = { \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\",\n-                         \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\", \"???\" };\n-\n-static void\n-printExplodedTime(const PRExplodedTime* et)\n-{\n-    PRInt32 totalOffset;\n-    PRInt32 hourOffset, minOffset;\n-    const char* sign;\n-\n-    /* Print day of the week, month, day, hour, minute, and second */\n-    printf(\"%s %s %ld %02ld:%02ld:%02ld \", dayOfWeek[et->tm_wday],\n-           month[et->tm_month], et->tm_mday, et->tm_hour, et->tm_min, et->tm_sec);\n-\n-    /* Print time zone */\n-    totalOffset = et->tm_params.tp_gmt_offset + et->tm_params.tp_dst_offset;\n-    if (totalOffset == 0) {\n-        printf(\"UTC \");\n-    } else {\n-        sign = \"\";\n-        if (totalOffset < 0) {\n-            totalOffset = -totalOffset;\n-            sign = \"-\";\n-        }\n-        hourOffset = totalOffset / 3600;\n-        minOffset = (totalOffset % 3600) / 60;\n-        printf(\"%s%02ld%02ld \", sign, hourOffset, minOffset);\n+static char* dayOfWeek[] = {\"Sun\", \"Mon\", \"Tue\", \"Wed\",\n+                            \"Thu\", \"Fri\", \"Sat\", \"???\"};\n+static char* month[] = {\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\",\n+                        \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\", \"???\"};\n+\n+static void printExplodedTime(const PRExplodedTime* et) {\n+  PRInt32 totalOffset;\n+  PRInt32 hourOffset, minOffset;\n+  const char* sign;\n+\n+  /* Print day of the week, month, day, hour, minute, and second */\n+  printf(\"%s %s %ld %02ld:%02ld:%02ld \", dayOfWeek[et->tm_wday],\n+         month[et->tm_month], et->tm_mday, et->tm_hour, et->tm_min, et->tm_sec);\n+\n+  /* Print time zone */\n+  totalOffset = et->tm_params.tp_gmt_offset + et->tm_params.tp_dst_offset;\n+  if (totalOffset == 0) {\n+    printf(\"UTC \");\n+  } else {\n+    sign = \"\";\n+    if (totalOffset < 0) {\n+      totalOffset = -totalOffset;\n+      sign = \"-\";\n     }\n+    hourOffset = totalOffset / 3600;\n+    minOffset = (totalOffset % 3600) / 60;\n+    printf(\"%s%02ld%02ld \", sign, hourOffset, minOffset);\n+  }\n \n-    /* Print year */\n-    printf(\"%d\", et->tm_year);\n+  /* Print year */\n+  printf(\"%d\", et->tm_year);\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-\n-    /*\n-     *************************************************************\n-     **\n-     **  Testing PR_Now(), PR_ExplodeTime, and PR_ImplodeTime\n-     **  on the current time\n-     **\n-     *************************************************************\n-     */\n-\n-    {\n-        PRTime t1, t2;\n-        PRExplodedTime et;\n-\n-        printf(\"*********************************************\\n\");\n-        printf(\"**                                         **\\n\");\n-        printf(\"** Testing PR_Now(), PR_ExplodeTime, and   **\\n\");\n-        printf(\"** PR_ImplodeTime on the current time      **\\n\");\n-        printf(\"**                                         **\\n\");\n-        printf(\"*********************************************\\n\\n\");\n-        t1 = PR_Now();\n-\n-        /* First try converting to UTC */\n-\n-        PR_ExplodeTime(t1, PR_GMTParameters, &et);\n-        if (et.tm_params.tp_gmt_offset || et.tm_params.tp_dst_offset) {\n-            printf(\"ERROR: UTC has nonzero gmt or dst offset.\\n\");\n-            return 1;\n-        }\n-        printf(\"Current UTC is \");\n-        printExplodedTime(&et);\n-        printf(\"\\n\");\n-\n-        t2 = PR_ImplodeTime(&et);\n-        if (LL_NE(t1, t2)) {\n-            printf(\"ERROR: Explode and implode are NOT inverse.\\n\");\n-            return 1;\n-        }\n-\n-        /* Next, try converting to local (US Pacific) time */\n-\n-        PR_ExplodeTime(t1, PR_LocalTimeParameters, &et);\n-        printf(\"Current local time is \");\n-        printExplodedTime(&et);\n-        printf(\"\\n\");\n-        printf(\"GMT offset is %ld, DST offset is %ld\\n\", et.tm_params.tp_gmt_offset,\n-               et.tm_params.tp_dst_offset);\n-        t2 = PR_ImplodeTime(&et);\n-        if (LL_NE(t1, t2)) {\n-            printf(\"ERROR: Explode and implode are NOT inverse.\\n\");\n-            return 1;\n-        }\n+int main(int argc, char** argv) {\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  /*\n+   *************************************************************\n+   **\n+   **  Testing PR_Now(), PR_ExplodeTime, and PR_ImplodeTime\n+   **  on the current time\n+   **\n+   *************************************************************\n+   */\n+\n+  {\n+    PRTime t1, t2;\n+    PRExplodedTime et;\n+\n+    printf(\"*********************************************\\n\");\n+    printf(\"**                                         **\\n\");\n+    printf(\"** Testing PR_Now(), PR_ExplodeTime, and   **\\n\");\n+    printf(\"** PR_ImplodeTime on the current time      **\\n\");\n+    printf(\"**                                         **\\n\");\n+    printf(\"*********************************************\\n\\n\");\n+    t1 = PR_Now();\n+\n+    /* First try converting to UTC */\n+\n+    PR_ExplodeTime(t1, PR_GMTParameters, &et);\n+    if (et.tm_params.tp_gmt_offset || et.tm_params.tp_dst_offset) {\n+      printf(\"ERROR: UTC has nonzero gmt or dst offset.\\n\");\n+      return 1;\n     }\n+    printf(\"Current UTC is \");\n+    printExplodedTime(&et);\n+    printf(\"\\n\");\n+\n+    t2 = PR_ImplodeTime(&et);\n+    if (LL_NE(t1, t2)) {\n+      printf(\"ERROR: Explode and implode are NOT inverse.\\n\");\n+      return 1;\n+    }\n+\n+    /* Next, try converting to local (US Pacific) time */\n+\n+    PR_ExplodeTime(t1, PR_LocalTimeParameters, &et);\n+    printf(\"Current local time is \");\n+    printExplodedTime(&et);\n+    printf(\"\\n\");\n+    printf(\"GMT offset is %ld, DST offset is %ld\\n\", et.tm_params.tp_gmt_offset,\n+           et.tm_params.tp_dst_offset);\n+    t2 = PR_ImplodeTime(&et);\n+    if (LL_NE(t1, t2)) {\n+      printf(\"ERROR: Explode and implode are NOT inverse.\\n\");\n+      return 1;\n+    }\n+  }\n \n-    printf(\"Please examine the results\\n\");\n-    return 0;\n+  printf(\"Please examine the results\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/timetest.c b/nspr/pr/tests/timetest.c\nindex 108ca24..8c891ce 100644\n--- a/nspr/pr/tests/timetest.c\n+++ b/nspr/pr/tests/timetest.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -23,793 +24,785 @@\n int failed_already = 0;\n PRBool debug_mode = PR_FALSE;\n \n-static char* dayOfWeek[] = { \"Sun\", \"Mon\", \"Tue\", \"Wed\",\n-                             \"Thu\", \"Fri\", \"Sat\", \"???\" };\n-static char* month[] = { \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\",\n-                         \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\", \"???\" };\n-\n-static void\n-PrintExplodedTime(const PRExplodedTime* et)\n-{\n-    PRInt32 totalOffset;\n-    PRInt32 hourOffset, minOffset;\n-    const char* sign;\n-\n-    /* Print day of the week, month, day, hour, minute, and second */\n-    if (debug_mode)\n-        printf(\"%s %s %ld %02ld:%02ld:%02ld \", dayOfWeek[et->tm_wday],\n-               month[et->tm_month], et->tm_mday, et->tm_hour, et->tm_min,\n-               et->tm_sec);\n-\n-    /* Print time zone */\n-    totalOffset = et->tm_params.tp_gmt_offset + et->tm_params.tp_dst_offset;\n-    if (totalOffset == 0) {\n-        if (debug_mode) {\n-            printf(\"UTC \");\n-        }\n-    } else {\n-        sign = \"+\";\n-        if (totalOffset < 0) {\n-            totalOffset = -totalOffset;\n-            sign = \"-\";\n-        }\n-        hourOffset = totalOffset / 3600;\n-        minOffset = (totalOffset % 3600) / 60;\n-        if (debug_mode) {\n-            printf(\"%s%02ld%02ld \", sign, hourOffset, minOffset);\n-        }\n+static char* dayOfWeek[] = {\"Sun\", \"Mon\", \"Tue\", \"Wed\",\n+                            \"Thu\", \"Fri\", \"Sat\", \"???\"};\n+static char* month[] = {\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\",\n+                        \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\", \"???\"};\n+\n+static void PrintExplodedTime(const PRExplodedTime* et) {\n+  PRInt32 totalOffset;\n+  PRInt32 hourOffset, minOffset;\n+  const char* sign;\n+\n+  /* Print day of the week, month, day, hour, minute, and second */\n+  if (debug_mode)\n+    printf(\"%s %s %ld %02ld:%02ld:%02ld \", dayOfWeek[et->tm_wday],\n+           month[et->tm_month], et->tm_mday, et->tm_hour, et->tm_min,\n+           et->tm_sec);\n+\n+  /* Print time zone */\n+  totalOffset = et->tm_params.tp_gmt_offset + et->tm_params.tp_dst_offset;\n+  if (totalOffset == 0) {\n+    if (debug_mode) {\n+      printf(\"UTC \");\n     }\n-\n-    /* Print year */\n+  } else {\n+    sign = \"+\";\n+    if (totalOffset < 0) {\n+      totalOffset = -totalOffset;\n+      sign = \"-\";\n+    }\n+    hourOffset = totalOffset / 3600;\n+    minOffset = (totalOffset % 3600) / 60;\n     if (debug_mode) {\n-        printf(\"%hd\", et->tm_year);\n+      printf(\"%s%02ld%02ld \", sign, hourOffset, minOffset);\n     }\n+  }\n+\n+  /* Print year */\n+  if (debug_mode) {\n+    printf(\"%hd\", et->tm_year);\n+  }\n }\n \n-static int\n-ExplodedTimeIsEqual(const PRExplodedTime* et1,\n-                    const PRExplodedTime* et2)\n-{\n-    if (et1->tm_usec == et2->tm_usec && et1->tm_sec == et2->tm_sec &&\n-        et1->tm_min == et2->tm_min && et1->tm_hour == et2->tm_hour &&\n-        et1->tm_mday == et2->tm_mday && et1->tm_month == et2->tm_month &&\n-        et1->tm_year == et2->tm_year && et1->tm_wday == et2->tm_wday &&\n-        et1->tm_yday == et2->tm_yday &&\n-        et1->tm_params.tp_gmt_offset == et2->tm_params.tp_gmt_offset &&\n-        et1->tm_params.tp_dst_offset == et2->tm_params.tp_dst_offset) {\n-        return 1;\n-    } else {\n-        return 0;\n+static int ExplodedTimeIsEqual(const PRExplodedTime* et1,\n+                               const PRExplodedTime* et2) {\n+  if (et1->tm_usec == et2->tm_usec && et1->tm_sec == et2->tm_sec &&\n+      et1->tm_min == et2->tm_min && et1->tm_hour == et2->tm_hour &&\n+      et1->tm_mday == et2->tm_mday && et1->tm_month == et2->tm_month &&\n+      et1->tm_year == et2->tm_year && et1->tm_wday == et2->tm_wday &&\n+      et1->tm_yday == et2->tm_yday &&\n+      et1->tm_params.tp_gmt_offset == et2->tm_params.tp_gmt_offset &&\n+      et1->tm_params.tp_dst_offset == et2->tm_params.tp_dst_offset) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n+}\n+\n+static void testParseTimeString(PRTime t) {\n+  PRExplodedTime et;\n+  PRTime t2;\n+  char timeString[128];\n+  char buf[128];\n+  PRInt32 totalOffset;\n+  PRInt32 hourOffset, minOffset;\n+  const char* sign;\n+  PRInt64 usec_per_sec;\n+\n+  /* Truncate the microsecond part of PRTime */\n+  LL_I2L(usec_per_sec, PR_USEC_PER_SEC);\n+  LL_DIV(t, t, usec_per_sec);\n+  LL_MUL(t, t, usec_per_sec);\n+\n+  PR_ExplodeTime(t, PR_LocalTimeParameters, &et);\n+\n+  /* Print day of the week, month, day, hour, minute, and second */\n+  PR_snprintf(timeString, 128, \"%s %s %ld %02ld:%02ld:%02ld \",\n+              dayOfWeek[et.tm_wday], month[et.tm_month], et.tm_mday, et.tm_hour,\n+              et.tm_min, et.tm_sec);\n+  /* Print time zone */\n+  totalOffset = et.tm_params.tp_gmt_offset + et.tm_params.tp_dst_offset;\n+  if (totalOffset == 0) {\n+    strcat(timeString, \"GMT \"); /* I wanted to use \"UTC\" here, but\n+                                 * PR_ParseTimeString doesn't\n+                                 * understand \"UTC\".  */\n+  } else {\n+    sign = \"+\";\n+    if (totalOffset < 0) {\n+      totalOffset = -totalOffset;\n+      sign = \"-\";\n     }\n+    hourOffset = totalOffset / 3600;\n+    minOffset = (totalOffset % 3600) / 60;\n+    PR_snprintf(buf, 128, \"%s%02ld%02ld \", sign, hourOffset, minOffset);\n+    strcat(timeString, buf);\n+  }\n+  /* Print year */\n+  PR_snprintf(buf, 128, \"%hd\", et.tm_year);\n+  strcat(timeString, buf);\n+\n+  if (PR_ParseTimeString(timeString, PR_FALSE, &t2) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_ParseTimeString() failed\\n\");\n+    exit(1);\n+  }\n+  if (LL_NE(t, t2)) {\n+    fprintf(stderr, \"PR_ParseTimeString() incorrect\\n\");\n+    PR_snprintf(buf, 128, \"t is %lld, t2 is %lld, time string is %s\\n\", t, t2,\n+                timeString);\n+    fprintf(stderr, \"%s\\n\", buf);\n+    exit(1);\n+  }\n }\n \n-static void\n-testParseTimeString(PRTime t)\n-{\n+int main(int argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt;\n+\n+  opt = PL_CreateOptState(argc, argv, \"d\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      default:\n+        break;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+\n+  /* Testing zero PRTime (the epoch) */\n+  {\n+    PRTime t;\n     PRExplodedTime et;\n-    PRTime t2;\n-    char timeString[128];\n-    char buf[128];\n-    PRInt32 totalOffset;\n-    PRInt32 hourOffset, minOffset;\n-    const char* sign;\n-    PRInt64 usec_per_sec;\n-\n-    /* Truncate the microsecond part of PRTime */\n-    LL_I2L(usec_per_sec, PR_USEC_PER_SEC);\n-    LL_DIV(t, t, usec_per_sec);\n-    LL_MUL(t, t, usec_per_sec);\n \n+    LL_I2L(t, 0);\n+    if (debug_mode) {\n+      printf(\"The NSPR epoch is:\\n\");\n+    }\n     PR_ExplodeTime(t, PR_LocalTimeParameters, &et);\n+    PrintExplodedTime(&et);\n+    if (debug_mode) {\n+      printf(\"\\n\");\n+    }\n+    PR_ExplodeTime(t, PR_GMTParameters, &et);\n+    PrintExplodedTime(&et);\n+    if (debug_mode) {\n+      printf(\"\\n\\n\");\n+    }\n+    testParseTimeString(t);\n+  }\n+\n+  /*\n+   *************************************************************\n+   **\n+   **  Testing PR_Now(), PR_ExplodeTime, and PR_ImplodeTime\n+   **  on the current time\n+   **\n+   *************************************************************\n+   */\n+\n+  {\n+    PRTime t1, t2;\n+    PRExplodedTime et;\n \n-    /* Print day of the week, month, day, hour, minute, and second */\n-    PR_snprintf(timeString, 128, \"%s %s %ld %02ld:%02ld:%02ld \",\n-                dayOfWeek[et.tm_wday], month[et.tm_month], et.tm_mday, et.tm_hour,\n-                et.tm_min, et.tm_sec);\n-    /* Print time zone */\n-    totalOffset = et.tm_params.tp_gmt_offset + et.tm_params.tp_dst_offset;\n-    if (totalOffset == 0) {\n-        strcat(timeString, \"GMT \"); /* I wanted to use \"UTC\" here, but\n-                                     * PR_ParseTimeString doesn't\n-                                     * understand \"UTC\".  */\n-    } else {\n-        sign = \"+\";\n-        if (totalOffset < 0) {\n-            totalOffset = -totalOffset;\n-            sign = \"-\";\n-        }\n-        hourOffset = totalOffset / 3600;\n-        minOffset = (totalOffset % 3600) / 60;\n-        PR_snprintf(buf, 128, \"%s%02ld%02ld \", sign, hourOffset, minOffset);\n-        strcat(timeString, buf);\n+    if (debug_mode) {\n+      printf(\"*********************************************\\n\");\n+      printf(\"**                                         **\\n\");\n+      printf(\"** Testing PR_Now(), PR_ExplodeTime, and   **\\n\");\n+      printf(\"** PR_ImplodeTime on the current time      **\\n\");\n+      printf(\"**                                         **\\n\");\n+      printf(\"*********************************************\\n\\n\");\n     }\n-    /* Print year */\n-    PR_snprintf(buf, 128, \"%hd\", et.tm_year);\n-    strcat(timeString, buf);\n+    t1 = PR_Now();\n+\n+    /* First try converting to UTC */\n+\n+    PR_ExplodeTime(t1, PR_GMTParameters, &et);\n+    if (et.tm_params.tp_gmt_offset || et.tm_params.tp_dst_offset) {\n+      if (debug_mode) {\n+        printf(\"ERROR: UTC has nonzero gmt or dst offset.\\n\");\n+      } else {\n+        failed_already = 1;\n+      }\n+      return 1;\n+    }\n+    if (debug_mode) {\n+      printf(\"Current UTC is \");\n+    }\n+    PrintExplodedTime(&et);\n+    if (debug_mode) {\n+      printf(\"\\n\");\n+    }\n+\n+    t2 = PR_ImplodeTime(&et);\n+    if (LL_NE(t1, t2)) {\n+      if (debug_mode) {\n+        printf(\"ERROR: Explode and implode are NOT inverse.\\n\");\n+      } else {\n+        printf(\"FAIL\\n\");\n+      }\n+      return 1;\n+    }\n+\n+    /* Next, try converting to local (US Pacific) time */\n \n-    if (PR_ParseTimeString(timeString, PR_FALSE, &t2) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_ParseTimeString() failed\\n\");\n-        exit(1);\n+    PR_ExplodeTime(t1, PR_LocalTimeParameters, &et);\n+    if (debug_mode) {\n+      printf(\"Current local time is \");\n     }\n-    if (LL_NE(t, t2)) {\n-        fprintf(stderr, \"PR_ParseTimeString() incorrect\\n\");\n-        PR_snprintf(buf, 128, \"t is %lld, t2 is %lld, time string is %s\\n\", t, t2,\n-                    timeString);\n-        fprintf(stderr, \"%s\\n\", buf);\n-        exit(1);\n+    PrintExplodedTime(&et);\n+    if (debug_mode) {\n+      printf(\"\\n\");\n+    }\n+    if (debug_mode)\n+      printf(\"GMT offset is %ld, DST offset is %ld\\n\",\n+             et.tm_params.tp_gmt_offset, et.tm_params.tp_dst_offset);\n+    t2 = PR_ImplodeTime(&et);\n+    if (LL_NE(t1, t2)) {\n+      if (debug_mode) {\n+        printf(\"ERROR: Explode and implode are NOT inverse.\\n\");\n+      }\n+      return 1;\n     }\n-}\n \n-int\n-main(int argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt;\n-\n-    opt = PL_CreateOptState(argc, argv, \"d\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            default:\n-                break;\n-        }\n+    if (debug_mode) {\n+      printf(\"Please examine the results\\n\");\n     }\n-    PL_DestroyOptState(opt);\n+    testParseTimeString(t1);\n+  }\n+\n+  /*\n+   *******************************************\n+   **\n+   ** Testing PR_NormalizeTime()\n+   **\n+   *******************************************\n+   */\n+\n+  /* July 4, 2001 is Wednesday */\n+  {\n+    PRExplodedTime et;\n \n-    /* main test */\n+    if (debug_mode) {\n+      printf(\"\\n\");\n+      printf(\"**********************************\\n\");\n+      printf(\"**                              **\\n\");\n+      printf(\"** Testing PR_NormalizeTime()   **\\n\");\n+      printf(\"**                              **\\n\");\n+      printf(\"**********************************\\n\\n\");\n+    }\n+    et.tm_year = 2001;\n+    et.tm_month = 7 - 1;\n+    et.tm_mday = 4;\n+    et.tm_hour = 0;\n+    et.tm_min = 0;\n+    et.tm_sec = 0;\n+    et.tm_usec = 0;\n+    et.tm_params = PR_GMTParameters(&et);\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+    PR_NormalizeTime(&et, PR_GMTParameters);\n \n-    /* Testing zero PRTime (the epoch) */\n-    {\n-        PRTime t;\n-        PRExplodedTime et;\n+    if (debug_mode) {\n+      printf(\"July 4, 2001 is %s.\\n\", dayOfWeek[et.tm_wday]);\n+    }\n+    if (et.tm_wday == 3) {\n+      if (debug_mode) {\n+        printf(\"PASS\\n\");\n+      }\n+    } else {\n+      if (debug_mode) {\n+        printf(\"ERROR: It should be Wednesday\\n\");\n+      } else {\n+        failed_already = 1;\n+      }\n+      return 1;\n+    }\n+    testParseTimeString(PR_ImplodeTime(&et));\n \n-        LL_I2L(t, 0);\n-        if (debug_mode) {\n-            printf(\"The NSPR epoch is:\\n\");\n-        }\n-        PR_ExplodeTime(t, PR_LocalTimeParameters, &et);\n-        PrintExplodedTime(&et);\n-        if (debug_mode) {\n-            printf(\"\\n\");\n-        }\n-        PR_ExplodeTime(t, PR_GMTParameters, &et);\n-        PrintExplodedTime(&et);\n-        if (debug_mode) {\n-            printf(\"\\n\\n\");\n-        }\n-        testParseTimeString(t);\n-    }\n-\n-    /*\n-     *************************************************************\n-     **\n-     **  Testing PR_Now(), PR_ExplodeTime, and PR_ImplodeTime\n-     **  on the current time\n-     **\n-     *************************************************************\n-     */\n-\n-    {\n-        PRTime t1, t2;\n-        PRExplodedTime et;\n-\n-        if (debug_mode) {\n-            printf(\"*********************************************\\n\");\n-            printf(\"**                                         **\\n\");\n-            printf(\"** Testing PR_Now(), PR_ExplodeTime, and   **\\n\");\n-            printf(\"** PR_ImplodeTime on the current time      **\\n\");\n-            printf(\"**                                         **\\n\");\n-            printf(\"*********************************************\\n\\n\");\n-        }\n-        t1 = PR_Now();\n+    /* June 12, 1997 23:00 PST == June 13, 1997 00:00 PDT */\n+    et.tm_year = 1997;\n+    et.tm_month = 6 - 1;\n+    et.tm_mday = 12;\n+    et.tm_hour = 23;\n+    et.tm_min = 0;\n+    et.tm_sec = 0;\n+    et.tm_usec = 0;\n+    et.tm_params.tp_gmt_offset = -8 * 3600;\n+    et.tm_params.tp_dst_offset = 0;\n \n-        /* First try converting to UTC */\n+    PR_NormalizeTime(&et, PR_USPacificTimeParameters);\n \n-        PR_ExplodeTime(t1, PR_GMTParameters, &et);\n-        if (et.tm_params.tp_gmt_offset || et.tm_params.tp_dst_offset) {\n-            if (debug_mode) {\n-                printf(\"ERROR: UTC has nonzero gmt or dst offset.\\n\");\n-            } else {\n-                failed_already = 1;\n-            }\n-            return 1;\n-        }\n-        if (debug_mode) {\n-            printf(\"Current UTC is \");\n-        }\n-        PrintExplodedTime(&et);\n-        if (debug_mode) {\n-            printf(\"\\n\");\n-        }\n+    if (debug_mode) {\n+      printf(\"Thu Jun 12, 1997 23:00:00 PST is \");\n+    }\n+    PrintExplodedTime(&et);\n+    if (debug_mode) {\n+      printf(\".\\n\");\n+    }\n+    if (et.tm_wday == 5) {\n+      if (debug_mode) {\n+        printf(\"PASS\\n\");\n+      }\n+    } else {\n+      if (debug_mode) {\n+        printf(\"ERROR: It should be Friday\\n\");\n+      } else {\n+        failed_already = 1;\n+      }\n+      return 1;\n+    }\n+    testParseTimeString(PR_ImplodeTime(&et));\n \n-        t2 = PR_ImplodeTime(&et);\n-        if (LL_NE(t1, t2)) {\n-            if (debug_mode) {\n-                printf(\"ERROR: Explode and implode are NOT inverse.\\n\");\n-            } else {\n-                printf(\"FAIL\\n\");\n-            }\n-            return 1;\n-        }\n+    /* Feb 14, 1997 00:00:00 PDT == Feb 13, 1997 23:00:00 PST */\n+    et.tm_year = 1997;\n+    et.tm_month = 2 - 1;\n+    et.tm_mday = 14;\n+    et.tm_hour = 0;\n+    et.tm_min = 0;\n+    et.tm_sec = 0;\n+    et.tm_usec = 0;\n+    et.tm_params.tp_gmt_offset = -8 * 3600;\n+    et.tm_params.tp_dst_offset = 3600;\n \n-        /* Next, try converting to local (US Pacific) time */\n+    PR_NormalizeTime(&et, PR_USPacificTimeParameters);\n \n-        PR_ExplodeTime(t1, PR_LocalTimeParameters, &et);\n-        if (debug_mode) {\n-            printf(\"Current local time is \");\n-        }\n-        PrintExplodedTime(&et);\n-        if (debug_mode) {\n-            printf(\"\\n\");\n-        }\n-        if (debug_mode)\n-            printf(\"GMT offset is %ld, DST offset is %ld\\n\",\n-                   et.tm_params.tp_gmt_offset, et.tm_params.tp_dst_offset);\n-        t2 = PR_ImplodeTime(&et);\n-        if (LL_NE(t1, t2)) {\n-            if (debug_mode) {\n-                printf(\"ERROR: Explode and implode are NOT inverse.\\n\");\n-            }\n-            return 1;\n-        }\n+    if (debug_mode) {\n+      printf(\"Fri Feb 14, 1997 00:00:00 PDT is \");\n+    }\n+    PrintExplodedTime(&et);\n+    if (debug_mode) {\n+      printf(\".\\n\");\n+    }\n+    if (et.tm_wday == 4) {\n+      if (debug_mode) {\n+        printf(\"PASS\\n\");\n+      }\n+    } else {\n+      if (debug_mode) {\n+        printf(\"ERROR: It should be Thursday\\n\");\n+      } else {\n+        failed_already = 1;\n+      }\n+      return 1;\n+    }\n+    testParseTimeString(PR_ImplodeTime(&et));\n+\n+    /* What time is Nov. 7, 1996, 18:29:23 PDT? */\n+    et.tm_year = 1996;\n+    et.tm_month = 11 - 1;\n+    et.tm_mday = 7;\n+    et.tm_hour = 18;\n+    et.tm_min = 29;\n+    et.tm_sec = 23;\n+    et.tm_usec = 0;\n+    et.tm_params.tp_gmt_offset = -8 * 3600; /* PDT */\n+    et.tm_params.tp_dst_offset = 3600;\n+\n+    PR_NormalizeTime(&et, PR_LocalTimeParameters);\n+    if (debug_mode) {\n+      printf(\"Nov 7 18:29:23 PDT 1996 is \");\n+    }\n+    PrintExplodedTime(&et);\n+    if (debug_mode) {\n+      printf(\".\\n\");\n+    }\n+    testParseTimeString(PR_ImplodeTime(&et));\n+\n+    /* What time is Oct. 7, 1995, 18:29:23 PST? */\n+    et.tm_year = 1995;\n+    et.tm_month = 10 - 1;\n+    et.tm_mday = 7;\n+    et.tm_hour = 18;\n+    et.tm_min = 29;\n+    et.tm_sec = 23;\n+    et.tm_params.tp_gmt_offset = -8 * 3600; /* PST */\n+    et.tm_params.tp_dst_offset = 0;\n+\n+    PR_NormalizeTime(&et, PR_LocalTimeParameters);\n+    if (debug_mode) {\n+      printf(\"Oct 7 18:29:23 PST 1995 is \");\n+    }\n+    PrintExplodedTime(&et);\n+    if (debug_mode) {\n+      printf(\".\\n\");\n+    }\n+    testParseTimeString(PR_ImplodeTime(&et));\n \n-        if (debug_mode) {\n-            printf(\"Please examine the results\\n\");\n-        }\n-        testParseTimeString(t1);\n+    if (debug_mode) {\n+      printf(\"Please examine the results\\n\");\n     }\n+  }\n \n-    /*\n-     *******************************************\n-     **\n-     ** Testing PR_NormalizeTime()\n-     **\n-     *******************************************\n-     */\n+  /*\n+   **************************************************************\n+   **\n+   ** Testing range of years\n+   **\n+   **************************************************************\n+   */\n \n-    /* July 4, 2001 is Wednesday */\n-    {\n-        PRExplodedTime et;\n+  {\n+    PRExplodedTime et1, et2;\n+    PRTime ttt;\n+    PRTime secs;\n+\n+    if (debug_mode) {\n+      printf(\"\\n\");\n+      printf(\"***************************************\\n\");\n+      printf(\"**                                   **\\n\");\n+      printf(\"**  Testing range of years           **\\n\");\n+      printf(\"**                                   **\\n\");\n+      printf(\"***************************************\\n\\n\");\n+    }\n+    /* April 4, 1917 GMT */\n+    et1.tm_usec = 0;\n+    et1.tm_sec = 0;\n+    et1.tm_min = 0;\n+    et1.tm_hour = 0;\n+    et1.tm_mday = 4;\n+    et1.tm_month = 4 - 1;\n+    et1.tm_year = 1917;\n+    et1.tm_params = PR_GMTParameters(&et1);\n+    PR_NormalizeTime(&et1, PR_LocalTimeParameters);\n+    secs = PR_ImplodeTime(&et1);\n+    if (LL_GE_ZERO(secs)) {\n+      if (debug_mode) {\n+        printf(\"ERROR: April 4, 1917 GMT returns a nonnegative second count\\n\");\n+      }\n+      failed_already = 1;\n+      return 1;\n+    }\n+    PR_ExplodeTime(secs, PR_LocalTimeParameters, &et2);\n+    if (!ExplodedTimeIsEqual(&et1, &et2)) {\n+      if (debug_mode) {\n+        printf(\n+            \"ERROR: PR_ImplodeTime and PR_ExplodeTime are not inverse for \"\n+            \"April 4, 1917 GMT\\n\");\n+      }\n+      failed_already = 1;\n+      return 1;\n+    }\n+    ttt = PR_ImplodeTime(&et1);\n+    testParseTimeString(ttt);\n+\n+    if (debug_mode) {\n+      printf(\"Test passed for April 4, 1917\\n\");\n+    }\n+\n+    /* July 4, 2050 */\n+    et1.tm_usec = 0;\n+    et1.tm_sec = 0;\n+    et1.tm_min = 0;\n+    et1.tm_hour = 0;\n+    et1.tm_mday = 4;\n+    et1.tm_month = 7 - 1;\n+    et1.tm_year = 2050;\n+    et1.tm_params = PR_GMTParameters(&et1);\n+    PR_NormalizeTime(&et1, PR_LocalTimeParameters);\n+    secs = PR_ImplodeTime(&et1);\n+    if (!LL_GE_ZERO(secs)) {\n+      if (debug_mode) {\n+        printf(\"ERROR: July 4, 2050 GMT returns a negative second count\\n\");\n+      }\n+      failed_already = 1;\n+      return 1;\n+    }\n+    PR_ExplodeTime(secs, PR_LocalTimeParameters, &et2);\n+    if (!ExplodedTimeIsEqual(&et1, &et2)) {\n+      if (debug_mode) {\n+        printf(\n+            \"ERROR: PR_ImplodeTime and PR_ExplodeTime are not inverse for July \"\n+            \"4, 2050 GMT\\n\");\n+      }\n+      failed_already = 1;\n+      return 1;\n+    }\n+    testParseTimeString(PR_ImplodeTime(&et1));\n \n-        if (debug_mode) {\n+    if (debug_mode) {\n+      printf(\"Test passed for July 4, 2050\\n\");\n+    }\n+  }\n+\n+  /*\n+   **************************************************************\n+   **\n+   **  Stress test\n+   *\n+   **      Go through four years, starting from\n+   **      00:00:00 PST Jan. 1, 2005, incrementing\n+   **      every 10 minutes.\n+   **\n+   **************************************************************\n+   */\n+\n+  {\n+    PRExplodedTime et, et1, et2;\n+    PRInt64 usecPer10Min;\n+    int day, hour, min;\n+    PRTime usecs;\n+    int dstInEffect = 0;\n+\n+    if (debug_mode) {\n+      printf(\"\\n\");\n+      printf(\"*******************************************************\\n\");\n+      printf(\"**                                                   **\\n\");\n+      printf(\"**        Stress test  Pacific Time                  **\\n\");\n+      printf(\"**  Starting from midnight Jan. 1, 2005 PST,         **\\n\");\n+      printf(\"**  going through four years in 10-minute increment  **\\n\");\n+      printf(\"**                                                   **\\n\");\n+      printf(\"*******************************************************\\n\\n\");\n+    }\n+    LL_I2L(usecPer10Min, 600000000L);\n+\n+    /* 00:00:00 PST Jan. 1, 2005 */\n+    et.tm_usec = 0;\n+    et.tm_sec = 0;\n+    et.tm_min = 0;\n+    et.tm_hour = 0;\n+    et.tm_mday = 1;\n+    et.tm_month = 0;\n+    et.tm_year = 2005;\n+    et.tm_params.tp_gmt_offset = -8 * 3600;\n+    et.tm_params.tp_dst_offset = 0;\n+    usecs = PR_ImplodeTime(&et);\n+\n+    for (day = 0; day < 4 * 365 + 1; day++) {\n+      for (hour = 0; hour < 24; hour++) {\n+        for (min = 0; min < 60; min += 10) {\n+          LL_ADD(usecs, usecs, usecPer10Min);\n+          PR_ExplodeTime(usecs, PR_USPacificTimeParameters, &et1);\n+\n+          et2 = et;\n+          et2.tm_usec += 600000000L;\n+          PR_NormalizeTime(&et2, PR_USPacificTimeParameters);\n+\n+          if (!ExplodedTimeIsEqual(&et1, &et2)) {\n+            printf(\"ERROR: componentwise comparison failed\\n\");\n+            PrintExplodedTime(&et1);\n             printf(\"\\n\");\n-            printf(\"**********************************\\n\");\n-            printf(\"**                              **\\n\");\n-            printf(\"** Testing PR_NormalizeTime()   **\\n\");\n-            printf(\"**                              **\\n\");\n-            printf(\"**********************************\\n\\n\");\n-        }\n-        et.tm_year = 2001;\n-        et.tm_month = 7 - 1;\n-        et.tm_mday = 4;\n-        et.tm_hour = 0;\n-        et.tm_min = 0;\n-        et.tm_sec = 0;\n-        et.tm_usec = 0;\n-        et.tm_params = PR_GMTParameters(&et);\n-\n-        PR_NormalizeTime(&et, PR_GMTParameters);\n-\n-        if (debug_mode) {\n-            printf(\"July 4, 2001 is %s.\\n\", dayOfWeek[et.tm_wday]);\n-        }\n-        if (et.tm_wday == 3) {\n-            if (debug_mode) {\n-                printf(\"PASS\\n\");\n-            }\n-        } else {\n-            if (debug_mode) {\n-                printf(\"ERROR: It should be Wednesday\\n\");\n-            } else {\n-                failed_already = 1;\n-            }\n+            PrintExplodedTime(&et2);\n+            printf(\"\\n\");\n+            failed_already = 1;\n             return 1;\n-        }\n-        testParseTimeString(PR_ImplodeTime(&et));\n-\n-        /* June 12, 1997 23:00 PST == June 13, 1997 00:00 PDT */\n-        et.tm_year = 1997;\n-        et.tm_month = 6 - 1;\n-        et.tm_mday = 12;\n-        et.tm_hour = 23;\n-        et.tm_min = 0;\n-        et.tm_sec = 0;\n-        et.tm_usec = 0;\n-        et.tm_params.tp_gmt_offset = -8 * 3600;\n-        et.tm_params.tp_dst_offset = 0;\n-\n-        PR_NormalizeTime(&et, PR_USPacificTimeParameters);\n-\n-        if (debug_mode) {\n-            printf(\"Thu Jun 12, 1997 23:00:00 PST is \");\n-        }\n-        PrintExplodedTime(&et);\n-        if (debug_mode) {\n-            printf(\".\\n\");\n-        }\n-        if (et.tm_wday == 5) {\n-            if (debug_mode) {\n-                printf(\"PASS\\n\");\n-            }\n-        } else {\n-            if (debug_mode) {\n-                printf(\"ERROR: It should be Friday\\n\");\n-            } else {\n-                failed_already = 1;\n-            }\n+          }\n+\n+          if (LL_NE(usecs, PR_ImplodeTime(&et1))) {\n+            printf(\n+                \"ERROR: PR_ExplodeTime and PR_ImplodeTime are not inverse\\n\");\n+            PrintExplodedTime(&et1);\n+            printf(\"\\n\");\n+            failed_already = 1;\n             return 1;\n-        }\n-        testParseTimeString(PR_ImplodeTime(&et));\n-\n-        /* Feb 14, 1997 00:00:00 PDT == Feb 13, 1997 23:00:00 PST */\n-        et.tm_year = 1997;\n-        et.tm_month = 2 - 1;\n-        et.tm_mday = 14;\n-        et.tm_hour = 0;\n-        et.tm_min = 0;\n-        et.tm_sec = 0;\n-        et.tm_usec = 0;\n-        et.tm_params.tp_gmt_offset = -8 * 3600;\n-        et.tm_params.tp_dst_offset = 3600;\n-\n-        PR_NormalizeTime(&et, PR_USPacificTimeParameters);\n-\n-        if (debug_mode) {\n-            printf(\"Fri Feb 14, 1997 00:00:00 PDT is \");\n-        }\n-        PrintExplodedTime(&et);\n-        if (debug_mode) {\n-            printf(\".\\n\");\n-        }\n-        if (et.tm_wday == 4) {\n+          }\n+          testParseTimeString(usecs);\n+\n+          if (!dstInEffect && et1.tm_params.tp_dst_offset) {\n+            dstInEffect = 1;\n             if (debug_mode) {\n-                printf(\"PASS\\n\");\n+              printf(\"DST changeover from \");\n+              PrintExplodedTime(&et);\n+              printf(\" to \");\n+              PrintExplodedTime(&et1);\n+              printf(\".\\n\");\n             }\n-        } else {\n+          } else if (dstInEffect && !et1.tm_params.tp_dst_offset) {\n+            dstInEffect = 0;\n             if (debug_mode) {\n-                printf(\"ERROR: It should be Thursday\\n\");\n-            } else {\n-                failed_already = 1;\n+              printf(\"DST changeover from \");\n+              PrintExplodedTime(&et);\n+              printf(\" to \");\n+              PrintExplodedTime(&et1);\n+              printf(\".\\n\");\n             }\n-            return 1;\n-        }\n-        testParseTimeString(PR_ImplodeTime(&et));\n-\n-        /* What time is Nov. 7, 1996, 18:29:23 PDT? */\n-        et.tm_year = 1996;\n-        et.tm_month = 11 - 1;\n-        et.tm_mday = 7;\n-        et.tm_hour = 18;\n-        et.tm_min = 29;\n-        et.tm_sec = 23;\n-        et.tm_usec = 0;\n-        et.tm_params.tp_gmt_offset = -8 * 3600; /* PDT */\n-        et.tm_params.tp_dst_offset = 3600;\n-\n-        PR_NormalizeTime(&et, PR_LocalTimeParameters);\n-        if (debug_mode) {\n-            printf(\"Nov 7 18:29:23 PDT 1996 is \");\n-        }\n-        PrintExplodedTime(&et);\n-        if (debug_mode) {\n-            printf(\".\\n\");\n-        }\n-        testParseTimeString(PR_ImplodeTime(&et));\n-\n-        /* What time is Oct. 7, 1995, 18:29:23 PST? */\n-        et.tm_year = 1995;\n-        et.tm_month = 10 - 1;\n-        et.tm_mday = 7;\n-        et.tm_hour = 18;\n-        et.tm_min = 29;\n-        et.tm_sec = 23;\n-        et.tm_params.tp_gmt_offset = -8 * 3600; /* PST */\n-        et.tm_params.tp_dst_offset = 0;\n-\n-        PR_NormalizeTime(&et, PR_LocalTimeParameters);\n-        if (debug_mode) {\n-            printf(\"Oct 7 18:29:23 PST 1995 is \");\n-        }\n-        PrintExplodedTime(&et);\n-        if (debug_mode) {\n-            printf(\".\\n\");\n-        }\n-        testParseTimeString(PR_ImplodeTime(&et));\n+          }\n \n-        if (debug_mode) {\n-            printf(\"Please examine the results\\n\");\n+          et = et1;\n         }\n+      }\n     }\n+    if (debug_mode) {\n+      printf(\"Test passed\\n\");\n+    }\n+  }\n \n-    /*\n-     **************************************************************\n-     **\n-     ** Testing range of years\n-     **\n-     **************************************************************\n-     */\n+  /* Same stress test, but with PR_LocalTimeParameters */\n \n-    {\n-        PRExplodedTime et1, et2;\n-        PRTime ttt;\n-        PRTime secs;\n+  {\n+    PRExplodedTime et, et1, et2;\n+    PRInt64 usecPer10Min;\n+    int day, hour, min;\n+    PRTime usecs;\n+    int dstInEffect = 0;\n \n-        if (debug_mode) {\n+    if (debug_mode) {\n+      printf(\"\\n\");\n+      printf(\"*******************************************************\\n\");\n+      printf(\"**                                                   **\\n\");\n+      printf(\"**         Stress test    Local Time                 **\\n\");\n+      printf(\"**  Starting from midnight Jan. 1, 2005 PST,         **\\n\");\n+      printf(\"**  going through four years in 10-minute increment  **\\n\");\n+      printf(\"**                                                   **\\n\");\n+      printf(\"*******************************************************\\n\\n\");\n+    }\n+\n+    LL_I2L(usecPer10Min, 600000000L);\n+\n+    /* 00:00:00 PST Jan. 1, 2005 */\n+    et.tm_usec = 0;\n+    et.tm_sec = 0;\n+    et.tm_min = 0;\n+    et.tm_hour = 0;\n+    et.tm_mday = 1;\n+    et.tm_month = 0;\n+    et.tm_year = 2005;\n+    et.tm_params.tp_gmt_offset = -8 * 3600;\n+    et.tm_params.tp_dst_offset = 0;\n+    usecs = PR_ImplodeTime(&et);\n+\n+    for (day = 0; day < 4 * 365 + 1; day++) {\n+      for (hour = 0; hour < 24; hour++) {\n+        for (min = 0; min < 60; min += 10) {\n+          LL_ADD(usecs, usecs, usecPer10Min);\n+          PR_ExplodeTime(usecs, PR_LocalTimeParameters, &et1);\n+\n+          et2 = et;\n+          et2.tm_usec += 600000000L;\n+          PR_NormalizeTime(&et2, PR_LocalTimeParameters);\n+\n+          if (!ExplodedTimeIsEqual(&et1, &et2)) {\n+            printf(\"ERROR: componentwise comparison failed\\n\");\n+            PrintExplodedTime(&et1);\n+            printf(\"\\n\");\n+            PrintExplodedTime(&et2);\n             printf(\"\\n\");\n-            printf(\"***************************************\\n\");\n-            printf(\"**                                   **\\n\");\n-            printf(\"**  Testing range of years           **\\n\");\n-            printf(\"**                                   **\\n\");\n-            printf(\"***************************************\\n\\n\");\n-        }\n-        /* April 4, 1917 GMT */\n-        et1.tm_usec = 0;\n-        et1.tm_sec = 0;\n-        et1.tm_min = 0;\n-        et1.tm_hour = 0;\n-        et1.tm_mday = 4;\n-        et1.tm_month = 4 - 1;\n-        et1.tm_year = 1917;\n-        et1.tm_params = PR_GMTParameters(&et1);\n-        PR_NormalizeTime(&et1, PR_LocalTimeParameters);\n-        secs = PR_ImplodeTime(&et1);\n-        if (LL_GE_ZERO(secs)) {\n-            if (debug_mode) {\n-                printf(\"ERROR: April 4, 1917 GMT returns a nonnegative second count\\n\");\n-            }\n-            failed_already = 1;\n             return 1;\n-        }\n-        PR_ExplodeTime(secs, PR_LocalTimeParameters, &et2);\n-        if (!ExplodedTimeIsEqual(&et1, &et2)) {\n-            if (debug_mode) {\n-                printf(\n-                    \"ERROR: PR_ImplodeTime and PR_ExplodeTime are not inverse for \"\n-                    \"April 4, 1917 GMT\\n\");\n-            }\n+          }\n+\n+          if (LL_NE(usecs, PR_ImplodeTime(&et1))) {\n+            printf(\n+                \"ERROR: PR_ExplodeTime and PR_ImplodeTime are not inverse\\n\");\n+            PrintExplodedTime(&et1);\n+            printf(\"\\n\");\n             failed_already = 1;\n             return 1;\n-        }\n-        ttt = PR_ImplodeTime(&et1);\n-        testParseTimeString(ttt);\n-\n-        if (debug_mode) {\n-            printf(\"Test passed for April 4, 1917\\n\");\n-        }\n+          }\n+          testParseTimeString(usecs);\n \n-        /* July 4, 2050 */\n-        et1.tm_usec = 0;\n-        et1.tm_sec = 0;\n-        et1.tm_min = 0;\n-        et1.tm_hour = 0;\n-        et1.tm_mday = 4;\n-        et1.tm_month = 7 - 1;\n-        et1.tm_year = 2050;\n-        et1.tm_params = PR_GMTParameters(&et1);\n-        PR_NormalizeTime(&et1, PR_LocalTimeParameters);\n-        secs = PR_ImplodeTime(&et1);\n-        if (!LL_GE_ZERO(secs)) {\n+          if (!dstInEffect && et1.tm_params.tp_dst_offset) {\n+            dstInEffect = 1;\n             if (debug_mode) {\n-                printf(\"ERROR: July 4, 2050 GMT returns a negative second count\\n\");\n+              printf(\"DST changeover from \");\n+              PrintExplodedTime(&et);\n+              printf(\" to \");\n+              PrintExplodedTime(&et1);\n+              printf(\".\\n\");\n             }\n-            failed_already = 1;\n-            return 1;\n-        }\n-        PR_ExplodeTime(secs, PR_LocalTimeParameters, &et2);\n-        if (!ExplodedTimeIsEqual(&et1, &et2)) {\n+          } else if (dstInEffect && !et1.tm_params.tp_dst_offset) {\n+            dstInEffect = 0;\n             if (debug_mode) {\n-                printf(\n-                    \"ERROR: PR_ImplodeTime and PR_ExplodeTime are not inverse for July \"\n-                    \"4, 2050 GMT\\n\");\n+              printf(\"DST changeover from \");\n+              PrintExplodedTime(&et);\n+              printf(\" to \");\n+              PrintExplodedTime(&et1);\n+              printf(\".\\n\");\n             }\n-            failed_already = 1;\n-            return 1;\n-        }\n-        testParseTimeString(PR_ImplodeTime(&et1));\n+          }\n \n-        if (debug_mode) {\n-            printf(\"Test passed for July 4, 2050\\n\");\n+          et = et1;\n         }\n+      }\n     }\n-\n-    /*\n-     **************************************************************\n-     **\n-     **  Stress test\n-     *\n-     **      Go through four years, starting from\n-     **      00:00:00 PST Jan. 1, 2005, incrementing\n-     **      every 10 minutes.\n-     **\n-     **************************************************************\n-     */\n-\n-    {\n-        PRExplodedTime et, et1, et2;\n-        PRInt64 usecPer10Min;\n-        int day, hour, min;\n-        PRTime usecs;\n-        int dstInEffect = 0;\n-\n-        if (debug_mode) {\n-            printf(\"\\n\");\n-            printf(\"*******************************************************\\n\");\n-            printf(\"**                                                   **\\n\");\n-            printf(\"**        Stress test  Pacific Time                  **\\n\");\n-            printf(\"**  Starting from midnight Jan. 1, 2005 PST,         **\\n\");\n-            printf(\"**  going through four years in 10-minute increment  **\\n\");\n-            printf(\"**                                                   **\\n\");\n-            printf(\"*******************************************************\\n\\n\");\n-        }\n-        LL_I2L(usecPer10Min, 600000000L);\n-\n-        /* 00:00:00 PST Jan. 1, 2005 */\n-        et.tm_usec = 0;\n-        et.tm_sec = 0;\n-        et.tm_min = 0;\n-        et.tm_hour = 0;\n-        et.tm_mday = 1;\n-        et.tm_month = 0;\n-        et.tm_year = 2005;\n-        et.tm_params.tp_gmt_offset = -8 * 3600;\n-        et.tm_params.tp_dst_offset = 0;\n-        usecs = PR_ImplodeTime(&et);\n-\n-        for (day = 0; day < 4 * 365 + 1; day++) {\n-            for (hour = 0; hour < 24; hour++) {\n-                for (min = 0; min < 60; min += 10) {\n-                    LL_ADD(usecs, usecs, usecPer10Min);\n-                    PR_ExplodeTime(usecs, PR_USPacificTimeParameters, &et1);\n-\n-                    et2 = et;\n-                    et2.tm_usec += 600000000L;\n-                    PR_NormalizeTime(&et2, PR_USPacificTimeParameters);\n-\n-                    if (!ExplodedTimeIsEqual(&et1, &et2)) {\n-                        printf(\"ERROR: componentwise comparison failed\\n\");\n-                        PrintExplodedTime(&et1);\n-                        printf(\"\\n\");\n-                        PrintExplodedTime(&et2);\n-                        printf(\"\\n\");\n-                        failed_already = 1;\n-                        return 1;\n-                    }\n-\n-                    if (LL_NE(usecs, PR_ImplodeTime(&et1))) {\n-                        printf(\n-                            \"ERROR: PR_ExplodeTime and PR_ImplodeTime are not inverse\\n\");\n-                        PrintExplodedTime(&et1);\n-                        printf(\"\\n\");\n-                        failed_already = 1;\n-                        return 1;\n-                    }\n-                    testParseTimeString(usecs);\n-\n-                    if (!dstInEffect && et1.tm_params.tp_dst_offset) {\n-                        dstInEffect = 1;\n-                        if (debug_mode) {\n-                            printf(\"DST changeover from \");\n-                            PrintExplodedTime(&et);\n-                            printf(\" to \");\n-                            PrintExplodedTime(&et1);\n-                            printf(\".\\n\");\n-                        }\n-                    } else if (dstInEffect && !et1.tm_params.tp_dst_offset) {\n-                        dstInEffect = 0;\n-                        if (debug_mode) {\n-                            printf(\"DST changeover from \");\n-                            PrintExplodedTime(&et);\n-                            printf(\" to \");\n-                            PrintExplodedTime(&et1);\n-                            printf(\".\\n\");\n-                        }\n-                    }\n-\n-                    et = et1;\n-                }\n-            }\n-        }\n-        if (debug_mode) {\n-            printf(\"Test passed\\n\");\n-        }\n+    if (debug_mode) {\n+      printf(\"Test passed\\n\");\n     }\n+  }\n \n-    /* Same stress test, but with PR_LocalTimeParameters */\n-\n-    {\n-        PRExplodedTime et, et1, et2;\n-        PRInt64 usecPer10Min;\n-        int day, hour, min;\n-        PRTime usecs;\n-        int dstInEffect = 0;\n+  /* Same stress test, but with PR_LocalTimeParameters and going backward */\n \n-        if (debug_mode) {\n-            printf(\"\\n\");\n-            printf(\"*******************************************************\\n\");\n-            printf(\"**                                                   **\\n\");\n-            printf(\"**         Stress test    Local Time                 **\\n\");\n-            printf(\"**  Starting from midnight Jan. 1, 2005 PST,         **\\n\");\n-            printf(\"**  going through four years in 10-minute increment  **\\n\");\n-            printf(\"**                                                   **\\n\");\n-            printf(\"*******************************************************\\n\\n\");\n-        }\n+  {\n+    PRExplodedTime et, et1, et2;\n+    PRInt64 usecPer10Min;\n+    int day, hour, min;\n+    PRTime usecs;\n+    int dstInEffect = 0;\n \n-        LL_I2L(usecPer10Min, 600000000L);\n-\n-        /* 00:00:00 PST Jan. 1, 2005 */\n-        et.tm_usec = 0;\n-        et.tm_sec = 0;\n-        et.tm_min = 0;\n-        et.tm_hour = 0;\n-        et.tm_mday = 1;\n-        et.tm_month = 0;\n-        et.tm_year = 2005;\n-        et.tm_params.tp_gmt_offset = -8 * 3600;\n-        et.tm_params.tp_dst_offset = 0;\n-        usecs = PR_ImplodeTime(&et);\n-\n-        for (day = 0; day < 4 * 365 + 1; day++) {\n-            for (hour = 0; hour < 24; hour++) {\n-                for (min = 0; min < 60; min += 10) {\n-                    LL_ADD(usecs, usecs, usecPer10Min);\n-                    PR_ExplodeTime(usecs, PR_LocalTimeParameters, &et1);\n-\n-                    et2 = et;\n-                    et2.tm_usec += 600000000L;\n-                    PR_NormalizeTime(&et2, PR_LocalTimeParameters);\n-\n-                    if (!ExplodedTimeIsEqual(&et1, &et2)) {\n-                        printf(\"ERROR: componentwise comparison failed\\n\");\n-                        PrintExplodedTime(&et1);\n-                        printf(\"\\n\");\n-                        PrintExplodedTime(&et2);\n-                        printf(\"\\n\");\n-                        return 1;\n-                    }\n-\n-                    if (LL_NE(usecs, PR_ImplodeTime(&et1))) {\n-                        printf(\n-                            \"ERROR: PR_ExplodeTime and PR_ImplodeTime are not inverse\\n\");\n-                        PrintExplodedTime(&et1);\n-                        printf(\"\\n\");\n-                        failed_already = 1;\n-                        return 1;\n-                    }\n-                    testParseTimeString(usecs);\n-\n-                    if (!dstInEffect && et1.tm_params.tp_dst_offset) {\n-                        dstInEffect = 1;\n-                        if (debug_mode) {\n-                            printf(\"DST changeover from \");\n-                            PrintExplodedTime(&et);\n-                            printf(\" to \");\n-                            PrintExplodedTime(&et1);\n-                            printf(\".\\n\");\n-                        }\n-                    } else if (dstInEffect && !et1.tm_params.tp_dst_offset) {\n-                        dstInEffect = 0;\n-                        if (debug_mode) {\n-                            printf(\"DST changeover from \");\n-                            PrintExplodedTime(&et);\n-                            printf(\" to \");\n-                            PrintExplodedTime(&et1);\n-                            printf(\".\\n\");\n-                        }\n-                    }\n-\n-                    et = et1;\n-                }\n-            }\n-        }\n-        if (debug_mode) {\n-            printf(\"Test passed\\n\");\n-        }\n+    if (debug_mode) {\n+      printf(\"\\n\");\n+      printf(\"*******************************************************\\n\");\n+      printf(\"**                                                   **\\n\");\n+      printf(\"**           Stress test    Local Time               **\\n\");\n+      printf(\"**  Starting from midnight Jan. 1, 2009 PST,         **\\n\");\n+      printf(\"**  going back four years in 10-minute increment     **\\n\");\n+      printf(\"**                                                   **\\n\");\n+      printf(\"*******************************************************\\n\\n\");\n     }\n \n-    /* Same stress test, but with PR_LocalTimeParameters and going backward */\n-\n-    {\n-        PRExplodedTime et, et1, et2;\n-        PRInt64 usecPer10Min;\n-        int day, hour, min;\n-        PRTime usecs;\n-        int dstInEffect = 0;\n+    LL_I2L(usecPer10Min, 600000000L);\n+\n+    /* 00:00:00 PST Jan. 1, 2009 */\n+    et.tm_usec = 0;\n+    et.tm_sec = 0;\n+    et.tm_min = 0;\n+    et.tm_hour = 0;\n+    et.tm_mday = 1;\n+    et.tm_month = 0;\n+    et.tm_year = 2009;\n+    et.tm_params.tp_gmt_offset = -8 * 3600;\n+    et.tm_params.tp_dst_offset = 0;\n+    usecs = PR_ImplodeTime(&et);\n+\n+    for (day = 0; day < 4 * 365 + 1; day++) {\n+      for (hour = 0; hour < 24; hour++) {\n+        for (min = 0; min < 60; min += 10) {\n+          LL_SUB(usecs, usecs, usecPer10Min);\n+          PR_ExplodeTime(usecs, PR_LocalTimeParameters, &et1);\n+\n+          et2 = et;\n+          et2.tm_usec -= 600000000L;\n+          PR_NormalizeTime(&et2, PR_LocalTimeParameters);\n+\n+          if (!ExplodedTimeIsEqual(&et1, &et2)) {\n+            printf(\"ERROR: componentwise comparison failed\\n\");\n+            PrintExplodedTime(&et1);\n+            printf(\"\\n\");\n+            PrintExplodedTime(&et2);\n+            printf(\"\\n\");\n+            return 1;\n+          }\n \n-        if (debug_mode) {\n+          if (LL_NE(usecs, PR_ImplodeTime(&et1))) {\n+            printf(\n+                \"ERROR: PR_ExplodeTime and PR_ImplodeTime are not inverse\\n\");\n+            PrintExplodedTime(&et1);\n             printf(\"\\n\");\n-            printf(\"*******************************************************\\n\");\n-            printf(\"**                                                   **\\n\");\n-            printf(\"**           Stress test    Local Time               **\\n\");\n-            printf(\"**  Starting from midnight Jan. 1, 2009 PST,         **\\n\");\n-            printf(\"**  going back four years in 10-minute increment     **\\n\");\n-            printf(\"**                                                   **\\n\");\n-            printf(\"*******************************************************\\n\\n\");\n-        }\n+            failed_already = 1;\n+            return 1;\n+          }\n+          testParseTimeString(usecs);\n \n-        LL_I2L(usecPer10Min, 600000000L);\n-\n-        /* 00:00:00 PST Jan. 1, 2009 */\n-        et.tm_usec = 0;\n-        et.tm_sec = 0;\n-        et.tm_min = 0;\n-        et.tm_hour = 0;\n-        et.tm_mday = 1;\n-        et.tm_month = 0;\n-        et.tm_year = 2009;\n-        et.tm_params.tp_gmt_offset = -8 * 3600;\n-        et.tm_params.tp_dst_offset = 0;\n-        usecs = PR_ImplodeTime(&et);\n-\n-        for (day = 0; day < 4 * 365 + 1; day++) {\n-            for (hour = 0; hour < 24; hour++) {\n-                for (min = 0; min < 60; min += 10) {\n-                    LL_SUB(usecs, usecs, usecPer10Min);\n-                    PR_ExplodeTime(usecs, PR_LocalTimeParameters, &et1);\n-\n-                    et2 = et;\n-                    et2.tm_usec -= 600000000L;\n-                    PR_NormalizeTime(&et2, PR_LocalTimeParameters);\n-\n-                    if (!ExplodedTimeIsEqual(&et1, &et2)) {\n-                        printf(\"ERROR: componentwise comparison failed\\n\");\n-                        PrintExplodedTime(&et1);\n-                        printf(\"\\n\");\n-                        PrintExplodedTime(&et2);\n-                        printf(\"\\n\");\n-                        return 1;\n-                    }\n-\n-                    if (LL_NE(usecs, PR_ImplodeTime(&et1))) {\n-                        printf(\n-                            \"ERROR: PR_ExplodeTime and PR_ImplodeTime are not inverse\\n\");\n-                        PrintExplodedTime(&et1);\n-                        printf(\"\\n\");\n-                        failed_already = 1;\n-                        return 1;\n-                    }\n-                    testParseTimeString(usecs);\n-\n-                    if (!dstInEffect && et1.tm_params.tp_dst_offset) {\n-                        dstInEffect = 1;\n-                        if (debug_mode) {\n-                            printf(\"DST changeover from \");\n-                            PrintExplodedTime(&et);\n-                            printf(\" to \");\n-                            PrintExplodedTime(&et1);\n-                            printf(\".\\n\");\n-                        }\n-                    } else if (dstInEffect && !et1.tm_params.tp_dst_offset) {\n-                        dstInEffect = 0;\n-                        if (debug_mode) {\n-                            printf(\"DST changeover from \");\n-                            PrintExplodedTime(&et);\n-                            printf(\" to \");\n-                            PrintExplodedTime(&et1);\n-                            printf(\".\\n\");\n-                        }\n-                    }\n-\n-                    et = et1;\n-                }\n+          if (!dstInEffect && et1.tm_params.tp_dst_offset) {\n+            dstInEffect = 1;\n+            if (debug_mode) {\n+              printf(\"DST changeover from \");\n+              PrintExplodedTime(&et);\n+              printf(\" to \");\n+              PrintExplodedTime(&et1);\n+              printf(\".\\n\");\n+            }\n+          } else if (dstInEffect && !et1.tm_params.tp_dst_offset) {\n+            dstInEffect = 0;\n+            if (debug_mode) {\n+              printf(\"DST changeover from \");\n+              PrintExplodedTime(&et);\n+              printf(\" to \");\n+              PrintExplodedTime(&et1);\n+              printf(\".\\n\");\n             }\n+          }\n+\n+          et = et1;\n         }\n+      }\n     }\n+  }\n \n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\ndiff --git a/nspr/pr/tests/tmoacc.c b/nspr/pr/tests/tmoacc.c\nindex f03e37e..24a5b3b 100644\n--- a/nspr/pr/tests/tmoacc.c\n+++ b/nspr/pr/tests/tmoacc.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -11,14 +12,14 @@\n #include \"plgetopt.h\"\n \n #ifdef DEBUG\n-#define PORT_INC_DO +100\n+#  define PORT_INC_DO +100\n #else\n-#define PORT_INC_DO\n+#  define PORT_INC_DO\n #endif\n #ifdef IS_64\n-#define PORT_INC_3264 +200\n+#  define PORT_INC_3264 +200\n #else\n-#define PORT_INC_3264\n+#  define PORT_INC_3264\n #endif\n \n #define BASE_PORT 9867 PORT_INC_DO PORT_INC_3264\n@@ -27,279 +28,270 @@\n #define DEFAULT_TIMEOUT 10\n #define RANDOM_RANGE 100 /* should be significantly smaller than RAND_MAX */\n \n-typedef enum { running,\n-               stopped } Status;\n+typedef enum { running, stopped } Status;\n \n typedef struct Shared {\n-    PRLock* ml;\n-    PRCondVar* cv;\n-    PRBool passed;\n-    PRBool random;\n-    PRFileDesc* debug;\n-    PRIntervalTime timeout;\n-    PRFileDesc* listenSock;\n-    Status status;\n+  PRLock* ml;\n+  PRCondVar* cv;\n+  PRBool passed;\n+  PRBool random;\n+  PRFileDesc* debug;\n+  PRIntervalTime timeout;\n+  PRFileDesc* listenSock;\n+  Status status;\n } Shared;\n \n-static PRIntervalTime\n-Timeout(const Shared* shared)\n-{\n-    PRIntervalTime timeout = shared->timeout;\n-    if (shared->random) {\n-        PRIntervalTime half = timeout >> 1; /* one half of the interval */\n-        PRIntervalTime quarter = half >> 1; /* one quarter of the interval */\n-        /* something in [0..timeout / 2) */\n-        PRUint32 random = (rand() % RANDOM_RANGE) * half / RANDOM_RANGE;\n-        timeout = (3 * quarter) + random; /* [75..125)% */\n-    }\n-    return timeout;\n+static PRIntervalTime Timeout(const Shared* shared) {\n+  PRIntervalTime timeout = shared->timeout;\n+  if (shared->random) {\n+    PRIntervalTime half = timeout >> 1; /* one half of the interval */\n+    PRIntervalTime quarter = half >> 1; /* one quarter of the interval */\n+    /* something in [0..timeout / 2) */\n+    PRUint32 random = (rand() % RANDOM_RANGE) * half / RANDOM_RANGE;\n+    timeout = (3 * quarter) + random; /* [75..125)% */\n+  }\n+  return timeout;\n } /* Timeout */\n \n-static void\n-Accept(void* arg)\n-{\n-    PRStatus rv;\n-    char* buffer = NULL;\n-    PRNetAddr clientAddr;\n-    Shared* shared = (Shared*)arg;\n-    PRInt32 recv_length = 0, flags = 0;\n-    PRFileDesc* clientSock;\n-    PRIntn toread, byte, bytes, loop = 0;\n-    struct Descriptor {\n-        PRInt32 length;\n-        PRUint32 checksum;\n-    } descriptor;\n+static void Accept(void* arg) {\n+  PRStatus rv;\n+  char* buffer = NULL;\n+  PRNetAddr clientAddr;\n+  Shared* shared = (Shared*)arg;\n+  PRInt32 recv_length = 0, flags = 0;\n+  PRFileDesc* clientSock;\n+  PRIntn toread, byte, bytes, loop = 0;\n+  struct Descriptor {\n+    PRInt32 length;\n+    PRUint32 checksum;\n+  } descriptor;\n \n-    do {\n-        PRUint32 checksum = 0;\n+  do {\n+    PRUint32 checksum = 0;\n+    if (NULL != shared->debug) {\n+      PR_fprintf(shared->debug, \"[%d]accepting ... \", loop++);\n+    }\n+    clientSock = PR_Accept(shared->listenSock, &clientAddr, Timeout(shared));\n+    if (clientSock != NULL) {\n+      if (NULL != shared->debug) {\n+        PR_fprintf(shared->debug, \"reading length ... \");\n+      }\n+      bytes = PR_Recv(clientSock, &descriptor, sizeof(descriptor), flags,\n+                      Timeout(shared));\n+      if (sizeof(descriptor) == bytes) {\n+        /* and, before doing something stupid ... */\n+        descriptor.length = PR_ntohl(descriptor.length);\n+        descriptor.checksum = PR_ntohl(descriptor.checksum);\n         if (NULL != shared->debug) {\n-            PR_fprintf(shared->debug, \"[%d]accepting ... \", loop++);\n+          PR_fprintf(shared->debug, \"%d bytes ... \", descriptor.length);\n         }\n-        clientSock = PR_Accept(shared->listenSock, &clientAddr, Timeout(shared));\n-        if (clientSock != NULL) {\n-            if (NULL != shared->debug) {\n-                PR_fprintf(shared->debug, \"reading length ... \");\n-            }\n-            bytes = PR_Recv(clientSock, &descriptor, sizeof(descriptor), flags,\n-                            Timeout(shared));\n-            if (sizeof(descriptor) == bytes) {\n-                /* and, before doing something stupid ... */\n-                descriptor.length = PR_ntohl(descriptor.length);\n-                descriptor.checksum = PR_ntohl(descriptor.checksum);\n-                if (NULL != shared->debug) {\n-                    PR_fprintf(shared->debug, \"%d bytes ... \", descriptor.length);\n-                }\n-                toread = descriptor.length;\n-                if (recv_length < descriptor.length) {\n-                    if (NULL != buffer) {\n-                        PR_DELETE(buffer);\n-                    }\n-                    buffer = (char*)PR_MALLOC(descriptor.length);\n-                    recv_length = descriptor.length;\n-                }\n-                for (toread = descriptor.length; toread > 0; toread -= bytes) {\n-                    bytes = PR_Recv(clientSock, &buffer[descriptor.length - toread],\n-                                    toread, flags, Timeout(shared));\n-                    if (-1 == bytes) {\n-                        if (NULL != shared->debug) {\n-                            PR_fprintf(shared->debug, \"read data failed...\");\n-                        }\n-                        bytes = 0;\n-                    }\n-                }\n-            } else if (NULL != shared->debug) {\n-                PR_fprintf(shared->debug, \"read desciptor failed...\");\n-                descriptor.length = -1;\n-            }\n-            if (NULL != shared->debug) {\n-                PR_fprintf(shared->debug, \"closing\");\n-            }\n-            rv = PR_Shutdown(clientSock, PR_SHUTDOWN_BOTH);\n-            if ((PR_FAILURE == rv) && (NULL != shared->debug)) {\n-                PR_fprintf(shared->debug, \" failed\");\n-                shared->passed = PR_FALSE;\n-            }\n-            rv = PR_Close(clientSock);\n-            if (PR_FAILURE == rv)\n-                if (NULL != shared->debug) {\n-                    PR_fprintf(shared->debug, \" failed\");\n-                    shared->passed = PR_FALSE;\n-                }\n-            if (descriptor.length > 0) {\n-                for (byte = 0; byte < descriptor.length; ++byte) {\n-                    PRUint32 overflow = checksum & 0x80000000;\n-                    checksum = (checksum << 1);\n-                    if (0x00000000 != overflow) {\n-                        checksum += 1;\n-                    }\n-                    checksum += buffer[byte];\n-                }\n-                if ((descriptor.checksum != checksum) && (NULL != shared->debug)) {\n-                    PR_fprintf(shared->debug, \" ... data mismatch\");\n-                    shared->passed = PR_FALSE;\n-                }\n-            } else if (0 == descriptor.length) {\n-                PR_Lock(shared->ml);\n-                shared->status = stopped;\n-                PR_NotifyCondVar(shared->cv);\n-                PR_Unlock(shared->ml);\n-            }\n+        toread = descriptor.length;\n+        if (recv_length < descriptor.length) {\n+          if (NULL != buffer) {\n+            PR_DELETE(buffer);\n+          }\n+          buffer = (char*)PR_MALLOC(descriptor.length);\n+          recv_length = descriptor.length;\n+        }\n+        for (toread = descriptor.length; toread > 0; toread -= bytes) {\n+          bytes = PR_Recv(clientSock, &buffer[descriptor.length - toread],\n+                          toread, flags, Timeout(shared));\n+          if (-1 == bytes) {\n             if (NULL != shared->debug) {\n-                PR_fprintf(shared->debug, \"\\n\");\n-            }\n-        } else {\n-            if (PR_PENDING_INTERRUPT_ERROR != PR_GetError()) {\n-                if (NULL != shared->debug) {\n-                    PL_PrintError(\"Accept\");\n-                }\n-                shared->passed = PR_FALSE;\n+              PR_fprintf(shared->debug, \"read data failed...\");\n             }\n+            bytes = 0;\n+          }\n+        }\n+      } else if (NULL != shared->debug) {\n+        PR_fprintf(shared->debug, \"read desciptor failed...\");\n+        descriptor.length = -1;\n+      }\n+      if (NULL != shared->debug) {\n+        PR_fprintf(shared->debug, \"closing\");\n+      }\n+      rv = PR_Shutdown(clientSock, PR_SHUTDOWN_BOTH);\n+      if ((PR_FAILURE == rv) && (NULL != shared->debug)) {\n+        PR_fprintf(shared->debug, \" failed\");\n+        shared->passed = PR_FALSE;\n+      }\n+      rv = PR_Close(clientSock);\n+      if (PR_FAILURE == rv)\n+        if (NULL != shared->debug) {\n+          PR_fprintf(shared->debug, \" failed\");\n+          shared->passed = PR_FALSE;\n         }\n-    } while (running == shared->status);\n-    if (NULL != buffer) {\n-        PR_DELETE(buffer);\n+      if (descriptor.length > 0) {\n+        for (byte = 0; byte < descriptor.length; ++byte) {\n+          PRUint32 overflow = checksum & 0x80000000;\n+          checksum = (checksum << 1);\n+          if (0x00000000 != overflow) {\n+            checksum += 1;\n+          }\n+          checksum += buffer[byte];\n+        }\n+        if ((descriptor.checksum != checksum) && (NULL != shared->debug)) {\n+          PR_fprintf(shared->debug, \" ... data mismatch\");\n+          shared->passed = PR_FALSE;\n+        }\n+      } else if (0 == descriptor.length) {\n+        PR_Lock(shared->ml);\n+        shared->status = stopped;\n+        PR_NotifyCondVar(shared->cv);\n+        PR_Unlock(shared->ml);\n+      }\n+      if (NULL != shared->debug) {\n+        PR_fprintf(shared->debug, \"\\n\");\n+      }\n+    } else {\n+      if (PR_PENDING_INTERRUPT_ERROR != PR_GetError()) {\n+        if (NULL != shared->debug) {\n+          PL_PrintError(\"Accept\");\n+        }\n+        shared->passed = PR_FALSE;\n+      }\n     }\n+  } while (running == shared->status);\n+  if (NULL != buffer) {\n+    PR_DELETE(buffer);\n+  }\n } /* Accept */\n \n-PRIntn\n-Tmoacc(PRIntn argc, char** argv)\n-{\n-    PRStatus rv;\n-    PRIntn exitStatus;\n-    PRIntn index;\n-    Shared* shared;\n-    PLOptStatus os;\n-    PRThread** thread;\n-    PRNetAddr listenAddr;\n-    PRSocketOptionData sockOpt;\n-    PRIntn timeout = DEFAULT_TIMEOUT;\n-    PRIntn threads = DEFAULT_THREADS;\n-    PRIntn backlog = DEFAULT_BACKLOG;\n-    PRThreadScope thread_scope = PR_LOCAL_THREAD;\n+PRIntn Tmoacc(PRIntn argc, char** argv) {\n+  PRStatus rv;\n+  PRIntn exitStatus;\n+  PRIntn index;\n+  Shared* shared;\n+  PLOptStatus os;\n+  PRThread** thread;\n+  PRNetAddr listenAddr;\n+  PRSocketOptionData sockOpt;\n+  PRIntn timeout = DEFAULT_TIMEOUT;\n+  PRIntn threads = DEFAULT_THREADS;\n+  PRIntn backlog = DEFAULT_BACKLOG;\n+  PRThreadScope thread_scope = PR_LOCAL_THREAD;\n \n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dGb:t:T:R\");\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dGb:t:T:R\");\n \n-    shared = PR_NEWZAP(Shared);\n+  shared = PR_NEWZAP(Shared);\n \n-    shared->debug = NULL;\n-    shared->passed = PR_TRUE;\n-    shared->random = PR_TRUE;\n-    shared->status = running;\n-    shared->ml = PR_NewLock();\n-    shared->cv = PR_NewCondVar(shared->ml);\n+  shared->debug = NULL;\n+  shared->passed = PR_TRUE;\n+  shared->random = PR_TRUE;\n+  shared->status = running;\n+  shared->ml = PR_NewLock();\n+  shared->cv = PR_NewCondVar(shared->ml);\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                shared->debug = PR_GetSpecialFD(PR_StandardError);\n-                break;\n-            case 'G': /* use global threads */\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'b': /* size of listen backlog */\n-                backlog = atoi(opt->value);\n-                break;\n-            case 't': /* number of threads doing accept */\n-                threads = atoi(opt->value);\n-                break;\n-            case 'T': /* timeout used for network operations */\n-                timeout = atoi(opt->value);\n-                break;\n-            case 'R': /* randomize the timeout values */\n-                shared->random = PR_TRUE;\n-                break;\n-            default:\n-                break;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n-    if (0 == threads) {\n-        threads = DEFAULT_THREADS;\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    if (0 == backlog) {\n-        backlog = DEFAULT_BACKLOG;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        shared->debug = PR_GetSpecialFD(PR_StandardError);\n+        break;\n+      case 'G': /* use global threads */\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'b': /* size of listen backlog */\n+        backlog = atoi(opt->value);\n+        break;\n+      case 't': /* number of threads doing accept */\n+        threads = atoi(opt->value);\n+        break;\n+      case 'T': /* timeout used for network operations */\n+        timeout = atoi(opt->value);\n+        break;\n+      case 'R': /* randomize the timeout values */\n+        shared->random = PR_TRUE;\n+        break;\n+      default:\n+        break;\n     }\n-    if (0 == timeout) {\n-        timeout = DEFAULT_TIMEOUT;\n-    }\n-\n-    memset(&listenAddr, 0, sizeof(listenAddr));\n-    rv = PR_InitializeNetAddr(PR_IpAddrAny, BASE_PORT, &listenAddr);\n-    PR_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PL_DestroyOptState(opt);\n+  if (0 == threads) {\n+    threads = DEFAULT_THREADS;\n+  }\n+  if (0 == backlog) {\n+    backlog = DEFAULT_BACKLOG;\n+  }\n+  if (0 == timeout) {\n+    timeout = DEFAULT_TIMEOUT;\n+  }\n \n-    shared->timeout = PR_SecondsToInterval(timeout);\n+  memset(&listenAddr, 0, sizeof(listenAddr));\n+  rv = PR_InitializeNetAddr(PR_IpAddrAny, BASE_PORT, &listenAddr);\n+  PR_ASSERT(PR_SUCCESS == rv);\n \n-    /* First bind to the socket */\n-    shared->listenSock = PR_NewTCPSocket();\n-    if (shared->listenSock) {\n-        sockOpt.option = PR_SockOpt_Reuseaddr;\n-        sockOpt.value.reuse_addr = PR_TRUE;\n-        rv = PR_SetSocketOption(shared->listenSock, &sockOpt);\n-        PR_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_Bind(shared->listenSock, &listenAddr);\n-        if (rv != PR_FAILURE) {\n-            rv = PR_Listen(shared->listenSock, threads + backlog);\n-            if (PR_SUCCESS == rv) {\n-                thread = (PRThread**)PR_CALLOC(threads * sizeof(PRThread*));\n-                for (index = 0; index < threads; ++index) {\n-                    thread[index] = PR_CreateThread(PR_USER_THREAD, Accept, shared,\n-                                                    PR_PRIORITY_NORMAL, thread_scope,\n-                                                    PR_JOINABLE_THREAD, 0);\n-                    PR_ASSERT(NULL != thread[index]);\n-                }\n+  shared->timeout = PR_SecondsToInterval(timeout);\n \n-                PR_Lock(shared->ml);\n-                while (shared->status == running) {\n-                    PR_WaitCondVar(shared->cv, PR_INTERVAL_NO_TIMEOUT);\n-                }\n-                PR_Unlock(shared->ml);\n-                for (index = 0; index < threads; ++index) {\n-                    rv = PR_Interrupt(thread[index]);\n-                    PR_ASSERT(PR_SUCCESS == rv);\n-                    rv = PR_JoinThread(thread[index]);\n-                    PR_ASSERT(PR_SUCCESS == rv);\n-                }\n-                PR_DELETE(thread);\n-            } else {\n-                if (shared->debug) {\n-                    PL_PrintError(\"Listen\");\n-                }\n-                shared->passed = PR_FALSE;\n-            }\n-        } else {\n-            if (shared->debug) {\n-                PL_PrintError(\"Bind\");\n-            }\n-            shared->passed = PR_FALSE;\n+  /* First bind to the socket */\n+  shared->listenSock = PR_NewTCPSocket();\n+  if (shared->listenSock) {\n+    sockOpt.option = PR_SockOpt_Reuseaddr;\n+    sockOpt.value.reuse_addr = PR_TRUE;\n+    rv = PR_SetSocketOption(shared->listenSock, &sockOpt);\n+    PR_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_Bind(shared->listenSock, &listenAddr);\n+    if (rv != PR_FAILURE) {\n+      rv = PR_Listen(shared->listenSock, threads + backlog);\n+      if (PR_SUCCESS == rv) {\n+        thread = (PRThread**)PR_CALLOC(threads * sizeof(PRThread*));\n+        for (index = 0; index < threads; ++index) {\n+          thread[index] = PR_CreateThread(PR_USER_THREAD, Accept, shared,\n+                                          PR_PRIORITY_NORMAL, thread_scope,\n+                                          PR_JOINABLE_THREAD, 0);\n+          PR_ASSERT(NULL != thread[index]);\n         }\n \n-        PR_Close(shared->listenSock);\n-    } else {\n+        PR_Lock(shared->ml);\n+        while (shared->status == running) {\n+          PR_WaitCondVar(shared->cv, PR_INTERVAL_NO_TIMEOUT);\n+        }\n+        PR_Unlock(shared->ml);\n+        for (index = 0; index < threads; ++index) {\n+          rv = PR_Interrupt(thread[index]);\n+          PR_ASSERT(PR_SUCCESS == rv);\n+          rv = PR_JoinThread(thread[index]);\n+          PR_ASSERT(PR_SUCCESS == rv);\n+        }\n+        PR_DELETE(thread);\n+      } else {\n         if (shared->debug) {\n-            PL_PrintError(\"Create\");\n+          PL_PrintError(\"Listen\");\n         }\n         shared->passed = PR_FALSE;\n+      }\n+    } else {\n+      if (shared->debug) {\n+        PL_PrintError(\"Bind\");\n+      }\n+      shared->passed = PR_FALSE;\n+    }\n+\n+    PR_Close(shared->listenSock);\n+  } else {\n+    if (shared->debug) {\n+      PL_PrintError(\"Create\");\n     }\n+    shared->passed = PR_FALSE;\n+  }\n \n-    PR_DestroyCondVar(shared->cv);\n-    PR_DestroyLock(shared->ml);\n+  PR_DestroyCondVar(shared->cv);\n+  PR_DestroyLock(shared->ml);\n \n-    PR_fprintf(PR_GetSpecialFD(PR_StandardError), \"%s\\n\",\n-               ((shared->passed) ? \"PASSED\" : \"FAILED\"));\n+  PR_fprintf(PR_GetSpecialFD(PR_StandardError), \"%s\\n\",\n+             ((shared->passed) ? \"PASSED\" : \"FAILED\"));\n \n-    exitStatus = (shared->passed) ? 0 : 1;\n-    PR_DELETE(shared);\n-    return exitStatus;\n+  exitStatus = (shared->passed) ? 0 : 1;\n+  PR_DELETE(shared);\n+  return exitStatus;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    return (PR_VersionCheck(PR_VERSION)) ? PR_Initialize(Tmoacc, argc, argv, 4)\n-                                         : -1;\n+int main(int argc, char** argv) {\n+  return (PR_VersionCheck(PR_VERSION)) ? PR_Initialize(Tmoacc, argc, argv, 4)\n+                                       : -1;\n } /* main */\n \n /* tmoacc */\ndiff --git a/nspr/pr/tests/tmocon.c b/nspr/pr/tests/tmocon.c\nindex 97e72f9..f253761 100644\n--- a/nspr/pr/tests/tmocon.c\n+++ b/nspr/pr/tests/tmocon.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -37,31 +38,29 @@\n \n /* for getcwd */\n #if defined(XP_UNIX)\n-#include <unistd.h>\n+#  include <unistd.h>\n #elif defined(XP_PC)\n-#include <direct.h>\n+#  include <direct.h>\n #endif\n \n #ifdef WINCE\n-#include <windows.h>\n-char*\n-getcwd(char* buf, size_t size)\n-{\n-    wchar_t wpath[MAX_PATH];\n-    _wgetcwd(wpath, MAX_PATH);\n-    WideCharToMultiByte(CP_ACP, 0, wpath, -1, buf, size, 0, 0);\n+#  include <windows.h>\n+char* getcwd(char* buf, size_t size) {\n+  wchar_t wpath[MAX_PATH];\n+  _wgetcwd(wpath, MAX_PATH);\n+  WideCharToMultiByte(CP_ACP, 0, wpath, -1, buf, size, 0, 0);\n }\n #endif\n \n #ifdef DEBUG\n-#define PORT_INC_DO +100\n+#  define PORT_INC_DO +100\n #else\n-#define PORT_INC_DO\n+#  define PORT_INC_DO\n #endif\n #ifdef IS_64\n-#define PORT_INC_3264 +200\n+#  define PORT_INC_3264 +200\n #else\n-#define PORT_INC_3264\n+#  define PORT_INC_3264\n #endif\n \n #define BASE_PORT 9867 PORT_INC_DO PORT_INC_3264\n@@ -75,334 +74,322 @@ getcwd(char* buf, size_t size)\n static PRFileDesc* debug_out = NULL;\n \n typedef struct Shared {\n-    PRBool random;\n-    PRBool failed;\n-    PRBool intermittant;\n-    PRIntn debug;\n-    PRInt32 messages;\n-    PRIntervalTime dally;\n-    PRIntervalTime timeout;\n-    PRInt32 message_length;\n-    PRNetAddr serverAddress;\n+  PRBool random;\n+  PRBool failed;\n+  PRBool intermittant;\n+  PRIntn debug;\n+  PRInt32 messages;\n+  PRIntervalTime dally;\n+  PRIntervalTime timeout;\n+  PRInt32 message_length;\n+  PRNetAddr serverAddress;\n } Shared;\n \n-static PRIntervalTime\n-Timeout(const Shared* shared)\n-{\n-    PRIntervalTime timeout = shared->timeout;\n-    if (shared->random) {\n-        PRIntervalTime quarter = timeout >> 2;               /* one quarter of the interval */\n-        PRUint32 random = rand() % quarter;                  /* something in[0..timeout / 4) */\n-        timeout = (((3 * quarter) + random) >> 2) + quarter; /* [75..125)% */\n-    }\n-    return timeout;\n+static PRIntervalTime Timeout(const Shared* shared) {\n+  PRIntervalTime timeout = shared->timeout;\n+  if (shared->random) {\n+    PRIntervalTime quarter = timeout >> 2; /* one quarter of the interval */\n+    PRUint32 random = rand() % quarter;    /* something in[0..timeout / 4) */\n+    timeout = (((3 * quarter) + random) >> 2) + quarter; /* [75..125)% */\n+  }\n+  return timeout;\n } /* Timeout */\n \n-static void\n-CauseTimeout(const Shared* shared)\n-{\n-    if (shared->intermittant) {\n-        PR_Sleep(Timeout(shared));\n-    }\n+static void CauseTimeout(const Shared* shared) {\n+  if (shared->intermittant) {\n+    PR_Sleep(Timeout(shared));\n+  }\n } /* CauseTimeout */\n \n-static PRStatus\n-MakeReceiver(Shared* shared)\n-{\n-    PRStatus rv = PR_FAILURE;\n-    if (PR_IsNetAddrType(&shared->serverAddress, PR_IpAddrLoopback)) {\n-        char* argv[3];\n-        char path[1024 + sizeof(\"/tmoacc\")];\n+static PRStatus MakeReceiver(Shared* shared) {\n+  PRStatus rv = PR_FAILURE;\n+  if (PR_IsNetAddrType(&shared->serverAddress, PR_IpAddrLoopback)) {\n+    char* argv[3];\n+    char path[1024 + sizeof(\"/tmoacc\")];\n \n-        getcwd(path, sizeof(path));\n+    getcwd(path, sizeof(path));\n \n-        (void)strcat(path, \"/tmoacc\");\n+    (void)strcat(path, \"/tmoacc\");\n #ifdef XP_PC\n-        (void)strcat(path, \".exe\");\n+    (void)strcat(path, \".exe\");\n #endif\n-        argv[0] = path;\n-        if (shared->debug > 0) {\n-            argv[1] = \"-d\";\n-            argv[2] = NULL;\n-        } else {\n-            argv[1] = NULL;\n-        }\n-        if (shared->debug > 1) {\n-            PR_fprintf(debug_out, \" creating accept process %s ...\", path);\n-        }\n-        fflush(stdout);\n-        rv = PR_CreateProcessDetached(path, argv, NULL, NULL);\n-        if (PR_SUCCESS == rv) {\n-            if (shared->debug > 1) {\n-                PR_fprintf(debug_out, \" wait 5 seconds\");\n-            }\n-            if (shared->debug > 1) {\n-                PR_fprintf(debug_out, \" before connecting to accept process ...\");\n-            }\n-            fflush(stdout);\n-            PR_Sleep(PR_SecondsToInterval(5));\n-            return rv;\n-        }\n-        shared->failed = PR_TRUE;\n-        if (shared->debug > 0) {\n-            PL_FPrintError(debug_out, \"PR_CreateProcessDetached failed\");\n-        }\n+    argv[0] = path;\n+    if (shared->debug > 0) {\n+      argv[1] = \"-d\";\n+      argv[2] = NULL;\n+    } else {\n+      argv[1] = NULL;\n     }\n-    return rv;\n+    if (shared->debug > 1) {\n+      PR_fprintf(debug_out, \" creating accept process %s ...\", path);\n+    }\n+    fflush(stdout);\n+    rv = PR_CreateProcessDetached(path, argv, NULL, NULL);\n+    if (PR_SUCCESS == rv) {\n+      if (shared->debug > 1) {\n+        PR_fprintf(debug_out, \" wait 5 seconds\");\n+      }\n+      if (shared->debug > 1) {\n+        PR_fprintf(debug_out, \" before connecting to accept process ...\");\n+      }\n+      fflush(stdout);\n+      PR_Sleep(PR_SecondsToInterval(5));\n+      return rv;\n+    }\n+    shared->failed = PR_TRUE;\n+    if (shared->debug > 0) {\n+      PL_FPrintError(debug_out, \"PR_CreateProcessDetached failed\");\n+    }\n+  }\n+  return rv;\n } /* MakeReceiver */\n \n-static void\n-Connect(void* arg)\n-{\n-    PRStatus rv;\n-    char* buffer = NULL;\n-    PRFileDesc* clientSock;\n-    Shared* shared = (Shared*)arg;\n-    PRInt32 loop, bytes, flags = 0;\n-    struct Descriptor {\n-        PRInt32 length;\n-        PRUint32 checksum;\n-    } descriptor;\n-    debug_out = (0 == shared->debug) ? NULL : PR_GetSpecialFD(PR_StandardError);\n-\n-    buffer = (char*)PR_MALLOC(shared->message_length);\n-\n-    for (bytes = 0; bytes < shared->message_length; ++bytes) {\n-        buffer[bytes] = (char)bytes;\n+static void Connect(void* arg) {\n+  PRStatus rv;\n+  char* buffer = NULL;\n+  PRFileDesc* clientSock;\n+  Shared* shared = (Shared*)arg;\n+  PRInt32 loop, bytes, flags = 0;\n+  struct Descriptor {\n+    PRInt32 length;\n+    PRUint32 checksum;\n+  } descriptor;\n+  debug_out = (0 == shared->debug) ? NULL : PR_GetSpecialFD(PR_StandardError);\n+\n+  buffer = (char*)PR_MALLOC(shared->message_length);\n+\n+  for (bytes = 0; bytes < shared->message_length; ++bytes) {\n+    buffer[bytes] = (char)bytes;\n+  }\n+\n+  descriptor.checksum = 0;\n+  for (bytes = 0; bytes < shared->message_length; ++bytes) {\n+    PRUint32 overflow = descriptor.checksum & 0x80000000;\n+    descriptor.checksum = (descriptor.checksum << 1);\n+    if (0x00000000 != overflow) {\n+      descriptor.checksum += 1;\n     }\n+    descriptor.checksum += buffer[bytes];\n+  }\n+  descriptor.checksum = PR_htonl(descriptor.checksum);\n \n-    descriptor.checksum = 0;\n-    for (bytes = 0; bytes < shared->message_length; ++bytes) {\n-        PRUint32 overflow = descriptor.checksum & 0x80000000;\n-        descriptor.checksum = (descriptor.checksum << 1);\n-        if (0x00000000 != overflow) {\n-            descriptor.checksum += 1;\n-        }\n-        descriptor.checksum += buffer[bytes];\n+  for (loop = 0; loop < shared->messages; ++loop) {\n+    if (shared->debug > 1) {\n+      PR_fprintf(debug_out, \"[%d]socket ... \", loop);\n     }\n-    descriptor.checksum = PR_htonl(descriptor.checksum);\n-\n-    for (loop = 0; loop < shared->messages; ++loop) {\n-        if (shared->debug > 1) {\n-            PR_fprintf(debug_out, \"[%d]socket ... \", loop);\n+    clientSock = PR_NewTCPSocket();\n+    if (clientSock) {\n+      /*\n+       * We need to slow down the rate of generating connect requests,\n+       * otherwise the listen backlog queue on the accept side may\n+       * become full and we will get connection refused or timeout\n+       * error.\n+       */\n+\n+      PR_Sleep(shared->dally);\n+      if (shared->debug > 1) {\n+        char buf[128];\n+        PR_NetAddrToString(&shared->serverAddress, buf, sizeof(buf));\n+        PR_fprintf(debug_out, \"connecting to %s ... \", buf);\n+      }\n+      rv = PR_Connect(clientSock, &shared->serverAddress, Timeout(shared));\n+      if (PR_SUCCESS == rv) {\n+        PRInt32 descriptor_length =\n+            (loop < (shared->messages - 1)) ? shared->message_length : 0;\n+        descriptor.length = PR_htonl(descriptor_length);\n+        if (shared->debug > 1)\n+          PR_fprintf(debug_out, \"sending %d bytes ... \", descriptor_length);\n+        CauseTimeout(shared); /* might cause server to timeout */\n+        bytes = PR_Send(clientSock, &descriptor, sizeof(descriptor), flags,\n+                        Timeout(shared));\n+        if (bytes != sizeof(descriptor)) {\n+          shared->failed = PR_TRUE;\n+          if (shared->debug > 0) {\n+            PL_FPrintError(debug_out, \"PR_Send failed\");\n+          }\n         }\n-        clientSock = PR_NewTCPSocket();\n-        if (clientSock) {\n-            /*\n-             * We need to slow down the rate of generating connect requests,\n-             * otherwise the listen backlog queue on the accept side may\n-             * become full and we will get connection refused or timeout\n-             * error.\n-             */\n-\n-            PR_Sleep(shared->dally);\n-            if (shared->debug > 1) {\n-                char buf[128];\n-                PR_NetAddrToString(&shared->serverAddress, buf, sizeof(buf));\n-                PR_fprintf(debug_out, \"connecting to %s ... \", buf);\n-            }\n-            rv = PR_Connect(clientSock, &shared->serverAddress, Timeout(shared));\n-            if (PR_SUCCESS == rv) {\n-                PRInt32 descriptor_length =\n-                    (loop < (shared->messages - 1)) ? shared->message_length : 0;\n-                descriptor.length = PR_htonl(descriptor_length);\n-                if (shared->debug > 1)\n-                    PR_fprintf(debug_out, \"sending %d bytes ... \", descriptor_length);\n-                CauseTimeout(shared); /* might cause server to timeout */\n-                bytes = PR_Send(clientSock, &descriptor, sizeof(descriptor), flags,\n-                                Timeout(shared));\n-                if (bytes != sizeof(descriptor)) {\n-                    shared->failed = PR_TRUE;\n-                    if (shared->debug > 0) {\n-                        PL_FPrintError(debug_out, \"PR_Send failed\");\n-                    }\n-                }\n-                if (0 != descriptor_length) {\n-                    CauseTimeout(shared);\n-                    bytes = PR_Send(clientSock, buffer, descriptor_length, flags,\n-                                    Timeout(shared));\n-                    if (bytes != descriptor_length) {\n-                        shared->failed = PR_TRUE;\n-                        if (shared->debug > 0) {\n-                            PL_FPrintError(debug_out, \"PR_Send failed\");\n-                        }\n-                    }\n-                }\n-                if (shared->debug > 1) {\n-                    PR_fprintf(debug_out, \"closing ... \");\n-                }\n-                rv = PR_Shutdown(clientSock, PR_SHUTDOWN_BOTH);\n-                rv = PR_Close(clientSock);\n-                if (shared->debug > 1) {\n-                    if (PR_SUCCESS == rv) {\n-                        PR_fprintf(debug_out, \"\\n\");\n-                    } else {\n-                        PL_FPrintError(debug_out, \"shutdown failed\");\n-                    }\n-                }\n-            } else {\n-                if (shared->debug > 1) {\n-                    PL_FPrintError(debug_out, \"connect failed\");\n-                }\n-                PR_Close(clientSock);\n-                if ((loop == 0) && (PR_GetError() == PR_CONNECT_REFUSED_ERROR)) {\n-                    if (MakeReceiver(shared) == PR_FAILURE) {\n-                        break;\n-                    }\n-                } else {\n-                    if (shared->debug > 1) {\n-                        PR_fprintf(debug_out, \" exiting\\n\");\n-                    }\n-                    break;\n-                }\n-            }\n-        } else {\n+        if (0 != descriptor_length) {\n+          CauseTimeout(shared);\n+          bytes = PR_Send(clientSock, buffer, descriptor_length, flags,\n+                          Timeout(shared));\n+          if (bytes != descriptor_length) {\n             shared->failed = PR_TRUE;\n             if (shared->debug > 0) {\n-                PL_FPrintError(debug_out, \"create socket\");\n+              PL_FPrintError(debug_out, \"PR_Send failed\");\n             }\n+          }\n+        }\n+        if (shared->debug > 1) {\n+          PR_fprintf(debug_out, \"closing ... \");\n+        }\n+        rv = PR_Shutdown(clientSock, PR_SHUTDOWN_BOTH);\n+        rv = PR_Close(clientSock);\n+        if (shared->debug > 1) {\n+          if (PR_SUCCESS == rv) {\n+            PR_fprintf(debug_out, \"\\n\");\n+          } else {\n+            PL_FPrintError(debug_out, \"shutdown failed\");\n+          }\n+        }\n+      } else {\n+        if (shared->debug > 1) {\n+          PL_FPrintError(debug_out, \"connect failed\");\n+        }\n+        PR_Close(clientSock);\n+        if ((loop == 0) && (PR_GetError() == PR_CONNECT_REFUSED_ERROR)) {\n+          if (MakeReceiver(shared) == PR_FAILURE) {\n             break;\n+          }\n+        } else {\n+          if (shared->debug > 1) {\n+            PR_fprintf(debug_out, \" exiting\\n\");\n+          }\n+          break;\n         }\n+      }\n+    } else {\n+      shared->failed = PR_TRUE;\n+      if (shared->debug > 0) {\n+        PL_FPrintError(debug_out, \"create socket\");\n+      }\n+      break;\n     }\n+  }\n \n-    PR_DELETE(buffer);\n+  PR_DELETE(buffer);\n } /* Connect */\n \n-int\n-Tmocon(int argc, char** argv)\n-{\n-    /*\n-     * USAGE\n-     * -d       turn on debugging output                (default = off)\n-     * -v       turn on verbose output                  (default = off)\n-     * -h <n>   dns name of host serving the connection (default = self)\n-     * -i       dally intermittantly to cause timeouts  (default = off)\n-     * -m <n>   number of messages to send              (default = 100)\n-     * -s <n>   size of each message                    (default = 100)\n-     * -t <n>   number of threads sending               (default = 1)\n-     * -G       use global threads                      (default = local)\n-     * -T <n>   timeout on I/O operations (seconds)     (default = 10)\n-     * -D <n>   dally between connect requests (seconds)(default = 0)\n-     * -R       randomize the dally types around 'T'    (default = no)\n-     */\n-\n-    PRStatus rv;\n-    int exitStatus;\n-    PLOptStatus os;\n-    Shared* shared = NULL;\n-    PRThread** thread = NULL;\n-    PRIntn index, threads = DEFAULT_THREADS;\n-    PRThreadScope thread_scope = PR_LOCAL_THREAD;\n-    PRInt32 dally = DEFAULT_DALLY, timeout = DEFAULT_TIMEOUT;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"divGRh:m:s:t:T:D:\");\n-\n-    shared = PR_NEWZAP(Shared);\n-\n-    shared->debug = 0;\n-    shared->failed = PR_FALSE;\n-    shared->random = PR_FALSE;\n-    shared->messages = DEFAULT_MESSAGES;\n-    shared->message_length = DEFAULT_MESSAGESIZE;\n-\n-    memset(&shared->serverAddress, 0, sizeof(shared->serverAddress));\n-    rv = PR_InitializeNetAddr(PR_IpAddrLoopback, BASE_PORT,\n-                              &shared->serverAddress);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n+int Tmocon(int argc, char** argv) {\n+  /*\n+   * USAGE\n+   * -d       turn on debugging output                (default = off)\n+   * -v       turn on verbose output                  (default = off)\n+   * -h <n>   dns name of host serving the connection (default = self)\n+   * -i       dally intermittantly to cause timeouts  (default = off)\n+   * -m <n>   number of messages to send              (default = 100)\n+   * -s <n>   size of each message                    (default = 100)\n+   * -t <n>   number of threads sending               (default = 1)\n+   * -G       use global threads                      (default = local)\n+   * -T <n>   timeout on I/O operations (seconds)     (default = 10)\n+   * -D <n>   dally between connect requests (seconds)(default = 0)\n+   * -R       randomize the dally types around 'T'    (default = no)\n+   */\n+\n+  PRStatus rv;\n+  int exitStatus;\n+  PLOptStatus os;\n+  Shared* shared = NULL;\n+  PRThread** thread = NULL;\n+  PRIntn index, threads = DEFAULT_THREADS;\n+  PRThreadScope thread_scope = PR_LOCAL_THREAD;\n+  PRInt32 dally = DEFAULT_DALLY, timeout = DEFAULT_TIMEOUT;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"divGRh:m:s:t:T:D:\");\n+\n+  shared = PR_NEWZAP(Shared);\n+\n+  shared->debug = 0;\n+  shared->failed = PR_FALSE;\n+  shared->random = PR_FALSE;\n+  shared->messages = DEFAULT_MESSAGES;\n+  shared->message_length = DEFAULT_MESSAGESIZE;\n+\n+  memset(&shared->serverAddress, 0, sizeof(shared->serverAddress));\n+  rv = PR_InitializeNetAddr(PR_IpAddrLoopback, BASE_PORT,\n+                            &shared->serverAddress);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd':\n+        if (0 == shared->debug) {\n+          shared->debug = 1;\n         }\n-        switch (opt->option) {\n-            case 'd':\n-                if (0 == shared->debug) {\n-                    shared->debug = 1;\n-                }\n-                break;\n-            case 'v':\n-                if (0 == shared->debug) {\n-                    shared->debug = 2;\n-                }\n-                break;\n-            case 'i':\n-                shared->intermittant = PR_TRUE;\n-                break;\n-            case 'R':\n-                shared->random = PR_TRUE;\n-                break;\n-            case 'G':\n-                thread_scope = PR_GLOBAL_THREAD;\n-                break;\n-            case 'h': /* the value for backlock */\n-            {\n-                PRIntn es = 0;\n-                PRHostEnt host;\n-                char buffer[1024];\n-                (void)PR_GetHostByName(opt->value, buffer, sizeof(buffer), &host);\n-                es = PR_EnumerateHostEnt(es, &host, BASE_PORT, &shared->serverAddress);\n-                PR_ASSERT(es > 0);\n-            } break;\n-            case 'm': /* number of messages to send */\n-                shared->messages = atoi(opt->value);\n-                break;\n-            case 't': /* number of threads sending */\n-                threads = atoi(opt->value);\n-                break;\n-            case 'D': /* dally time between transmissions */\n-                dally = atoi(opt->value);\n-                break;\n-            case 'T': /* timeout on I/O operations */\n-                timeout = atoi(opt->value);\n-                break;\n-            case 's': /* total size of each message */\n-                shared->message_length = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n+        break;\n+      case 'v':\n+        if (0 == shared->debug) {\n+          shared->debug = 2;\n         }\n+        break;\n+      case 'i':\n+        shared->intermittant = PR_TRUE;\n+        break;\n+      case 'R':\n+        shared->random = PR_TRUE;\n+        break;\n+      case 'G':\n+        thread_scope = PR_GLOBAL_THREAD;\n+        break;\n+      case 'h': /* the value for backlock */\n+      {\n+        PRIntn es = 0;\n+        PRHostEnt host;\n+        char buffer[1024];\n+        (void)PR_GetHostByName(opt->value, buffer, sizeof(buffer), &host);\n+        es = PR_EnumerateHostEnt(es, &host, BASE_PORT, &shared->serverAddress);\n+        PR_ASSERT(es > 0);\n+      } break;\n+      case 'm': /* number of messages to send */\n+        shared->messages = atoi(opt->value);\n+        break;\n+      case 't': /* number of threads sending */\n+        threads = atoi(opt->value);\n+        break;\n+      case 'D': /* dally time between transmissions */\n+        dally = atoi(opt->value);\n+        break;\n+      case 'T': /* timeout on I/O operations */\n+        timeout = atoi(opt->value);\n+        break;\n+      case 's': /* total size of each message */\n+        shared->message_length = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    if (0 == timeout) {\n-        timeout = DEFAULT_TIMEOUT;\n-    }\n-    if (0 == threads) {\n-        threads = DEFAULT_THREADS;\n-    }\n-    if (0 == shared->messages) {\n-        shared->messages = DEFAULT_MESSAGES;\n-    }\n-    if (0 == shared->message_length) {\n-        shared->message_length = DEFAULT_MESSAGESIZE;\n-    }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  if (0 == timeout) {\n+    timeout = DEFAULT_TIMEOUT;\n+  }\n+  if (0 == threads) {\n+    threads = DEFAULT_THREADS;\n+  }\n+  if (0 == shared->messages) {\n+    shared->messages = DEFAULT_MESSAGES;\n+  }\n+  if (0 == shared->message_length) {\n+    shared->message_length = DEFAULT_MESSAGESIZE;\n+  }\n \n-    shared->dally = PR_SecondsToInterval(dally);\n-    shared->timeout = PR_SecondsToInterval(timeout);\n+  shared->dally = PR_SecondsToInterval(dally);\n+  shared->timeout = PR_SecondsToInterval(timeout);\n \n-    thread = (PRThread**)PR_CALLOC(threads * sizeof(PRThread*));\n+  thread = (PRThread**)PR_CALLOC(threads * sizeof(PRThread*));\n \n-    for (index = 0; index < threads; ++index)\n-        thread[index] =\n-            PR_CreateThread(PR_USER_THREAD, Connect, shared, PR_PRIORITY_NORMAL,\n-                            thread_scope, PR_JOINABLE_THREAD, 0);\n-    for (index = 0; index < threads; ++index) {\n-        rv = PR_JoinThread(thread[index]);\n-    }\n+  for (index = 0; index < threads; ++index)\n+    thread[index] =\n+        PR_CreateThread(PR_USER_THREAD, Connect, shared, PR_PRIORITY_NORMAL,\n+                        thread_scope, PR_JOINABLE_THREAD, 0);\n+  for (index = 0; index < threads; ++index) {\n+    rv = PR_JoinThread(thread[index]);\n+  }\n \n-    PR_DELETE(thread);\n+  PR_DELETE(thread);\n \n-    PR_fprintf(PR_GetSpecialFD(PR_StandardError), \"%s\\n\",\n-               ((shared->failed) ? \"FAILED\" : \"PASSED\"));\n-    exitStatus = (shared->failed) ? 1 : 0;\n-    PR_DELETE(shared);\n-    return exitStatus;\n+  PR_fprintf(PR_GetSpecialFD(PR_StandardError), \"%s\\n\",\n+             ((shared->failed) ? \"FAILED\" : \"PASSED\"));\n+  exitStatus = (shared->failed) ? 1 : 0;\n+  PR_DELETE(shared);\n+  return exitStatus;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    return (PR_VersionCheck(PR_VERSION)) ? PR_Initialize(Tmocon, argc, argv, 4)\n-                                         : -1;\n+int main(int argc, char** argv) {\n+  return (PR_VersionCheck(PR_VERSION)) ? PR_Initialize(Tmocon, argc, argv, 4)\n+                                       : -1;\n } /* main */\n \n /* tmocon.c */\ndiff --git a/nspr/pr/tests/tpd.c b/nspr/pr/tests/tpd.c\nindex 023e055..4bf6793 100644\n--- a/nspr/pr/tests/tpd.c\n+++ b/nspr/pr/tests/tpd.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -25,253 +26,241 @@ static PRBool should = PR_TRUE;\n static PRBool did = PR_TRUE;\n static PRFileDesc* fout = NULL;\n \n-static void\n-PrintProgress(PRIntn line)\n-{\n-    failed = failed || (should && !did);\n-    failed = failed || (!should && did);\n-    if (debug > 0) {\n-        PR_fprintf(fout,\n-                   \"@ line %d destructor should%s have been called and was%s\\n\",\n-                   line, ((should) ? \"\" : \" NOT\"), ((did) ? \"\" : \" NOT\"));\n-    }\n+static void PrintProgress(PRIntn line) {\n+  failed = failed || (should && !did);\n+  failed = failed || (!should && did);\n+  if (debug > 0) {\n+    PR_fprintf(fout,\n+               \"@ line %d destructor should%s have been called and was%s\\n\",\n+               line, ((should) ? \"\" : \" NOT\"), ((did) ? \"\" : \" NOT\"));\n+  }\n } /* PrintProgress */\n \n-static void\n-MyAssert(const char* expr, const char* file, PRIntn line)\n-{\n-    if (debug > 0) {\n-        (void)PR_fprintf(fout, \"'%s' in file: %s: %d\\n\", expr, file, line);\n-    }\n+static void MyAssert(const char* expr, const char* file, PRIntn line) {\n+  if (debug > 0) {\n+    (void)PR_fprintf(fout, \"'%s' in file: %s: %d\\n\", expr, file, line);\n+  }\n } /* MyAssert */\n \n #define MY_ASSERT(_expr) \\\n-    ((_expr) ? ((void)0) : MyAssert(#_expr, __FILE__, __LINE__))\n-\n-static void PR_CALLBACK\n-Destructor(void* data)\n-{\n-    MY_ASSERT(NULL != data);\n-    if (should) {\n-        did = PR_TRUE;\n-    } else {\n-        failed = PR_TRUE;\n-    }\n-    /*\n-     * We don't actually free the storage since it's actually allocated\n-     * on the stack. Normally, this would not be the case and this is\n-     * the opportunity to free whatever.\n-    PR_Free(data);\n-     */\n+  ((_expr) ? ((void)0) : MyAssert(#_expr, __FILE__, __LINE__))\n+\n+static void PR_CALLBACK Destructor(void* data) {\n+  MY_ASSERT(NULL != data);\n+  if (should) {\n+    did = PR_TRUE;\n+  } else {\n+    failed = PR_TRUE;\n+  }\n+  /*\n+   * We don't actually free the storage since it's actually allocated\n+   * on the stack. Normally, this would not be the case and this is\n+   * the opportunity to free whatever.\n+  PR_Free(data);\n+   */\n } /* Destructor */\n \n-static void PR_CALLBACK\n-Thread(void* null)\n-{\n-    void* pd;\n-    PRStatus rv;\n-    PRUintn keys;\n-    char* key_string[] = { \"Key #0\", \"Key #1\", \"Key #2\", \"Key #3\",\n-                           \"Bogus #5\", \"Bogus #6\", \"Bogus #7\", \"Bogus #8\" };\n-\n-    did = should = PR_FALSE;\n-    for (keys = 0; keys < 8; ++keys) {\n-        pd = PR_GetThreadPrivate(key[keys]);\n-        MY_ASSERT(NULL == pd);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = should = PR_FALSE;\n-    for (keys = 0; keys < 4; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = should = PR_FALSE;\n-    for (keys = 4; keys < 8; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n-        MY_ASSERT(PR_FAILURE == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = PR_FALSE;\n-    should = PR_TRUE;\n-    for (keys = 0; keys < 4; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = PR_FALSE;\n-    should = PR_TRUE;\n-    for (keys = 0; keys < 4; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], NULL);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = should = PR_FALSE;\n-    for (keys = 0; keys < 4; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], NULL);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = should = PR_FALSE;\n-    for (keys = 8; keys < 127; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], \"EXTENSION\");\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = PR_FALSE;\n-    should = PR_TRUE;\n-    for (keys = 8; keys < 127; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], NULL);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = should = PR_FALSE;\n-    for (keys = 8; keys < 127; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], NULL);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-\n-    /* put in keys and leave them there for thread exit */\n-    did = should = PR_FALSE;\n-    for (keys = 0; keys < 4; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-    did = PR_FALSE;\n-    should = PR_TRUE;\n+static void PR_CALLBACK Thread(void* null) {\n+  void* pd;\n+  PRStatus rv;\n+  PRUintn keys;\n+  char* key_string[] = {\"Key #0\",   \"Key #1\",   \"Key #2\",   \"Key #3\",\n+                        \"Bogus #5\", \"Bogus #6\", \"Bogus #7\", \"Bogus #8\"};\n+\n+  did = should = PR_FALSE;\n+  for (keys = 0; keys < 8; ++keys) {\n+    pd = PR_GetThreadPrivate(key[keys]);\n+    MY_ASSERT(NULL == pd);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = should = PR_FALSE;\n+  for (keys = 0; keys < 4; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = should = PR_FALSE;\n+  for (keys = 4; keys < 8; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n+    MY_ASSERT(PR_FAILURE == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = PR_FALSE;\n+  should = PR_TRUE;\n+  for (keys = 0; keys < 4; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = PR_FALSE;\n+  should = PR_TRUE;\n+  for (keys = 0; keys < 4; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], NULL);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = should = PR_FALSE;\n+  for (keys = 0; keys < 4; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], NULL);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = should = PR_FALSE;\n+  for (keys = 8; keys < 127; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], \"EXTENSION\");\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = PR_FALSE;\n+  should = PR_TRUE;\n+  for (keys = 8; keys < 127; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], NULL);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = should = PR_FALSE;\n+  for (keys = 8; keys < 127; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], NULL);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+\n+  /* put in keys and leave them there for thread exit */\n+  did = should = PR_FALSE;\n+  for (keys = 0; keys < 4; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+  did = PR_FALSE;\n+  should = PR_TRUE;\n \n } /* Thread */\n \n-static PRIntn PR_CALLBACK\n-Tpd(PRIntn argc, char** argv)\n-{\n-    void* pd;\n-    PRStatus rv;\n-    PRUintn keys;\n-    PRThread* thread;\n-    char* key_string[] = { \"Key #0\", \"Key #1\", \"Key #2\", \"Key #3\",\n-                           \"Bogus #5\", \"Bogus #6\", \"Bogus #7\", \"Bogus #8\" };\n-\n-    fout = PR_STDOUT;\n-\n-    did = should = PR_FALSE;\n-    for (keys = 0; keys < 4; ++keys) {\n-        rv = PR_NewThreadPrivateIndex(&key[keys], Destructor);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = should = PR_FALSE;\n-    for (keys = 0; keys < 8; ++keys) {\n-        pd = PR_GetThreadPrivate(key[keys]);\n-        MY_ASSERT(NULL == pd);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = should = PR_FALSE;\n-    for (keys = 0; keys < 4; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    for (keys = 4; keys < 8; ++keys) {\n-        key[keys] = 4096; /* set to invalid value */\n-    }\n-    did = should = PR_FALSE;\n-    for (keys = 4; keys < 8; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n-        MY_ASSERT(PR_FAILURE == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = PR_FALSE;\n-    should = PR_TRUE;\n-    for (keys = 0; keys < 4; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = PR_FALSE;\n-    should = PR_TRUE;\n-    for (keys = 0; keys < 4; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], NULL);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = should = PR_FALSE;\n-    for (keys = 0; keys < 4; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], NULL);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = should = PR_FALSE;\n-    for (keys = 8; keys < 127; ++keys) {\n-        rv = PR_NewThreadPrivateIndex(&key[keys], Destructor);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-        rv = PR_SetThreadPrivate(key[keys], \"EXTENSION\");\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = PR_FALSE;\n-    should = PR_TRUE;\n-    for (keys = 8; keys < 127; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], NULL);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-    PrintProgress(__LINE__);\n-\n-    did = should = PR_FALSE;\n-    for (keys = 8; keys < 127; ++keys) {\n-        rv = PR_SetThreadPrivate(key[keys], NULL);\n-        MY_ASSERT(PR_SUCCESS == rv);\n-    }\n-\n-    thread = PR_CreateThread(PR_USER_THREAD, Thread, NULL, PR_PRIORITY_NORMAL,\n-                             PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-\n-    (void)PR_JoinThread(thread);\n-\n-    PrintProgress(__LINE__);\n-\n-    (void)PR_fprintf(fout, \"%s\\n\", ((PR_TRUE == failed) ? \"FAILED\" : \"PASSED\"));\n-\n-    return 0;\n+static PRIntn PR_CALLBACK Tpd(PRIntn argc, char** argv) {\n+  void* pd;\n+  PRStatus rv;\n+  PRUintn keys;\n+  PRThread* thread;\n+  char* key_string[] = {\"Key #0\",   \"Key #1\",   \"Key #2\",   \"Key #3\",\n+                        \"Bogus #5\", \"Bogus #6\", \"Bogus #7\", \"Bogus #8\"};\n+\n+  fout = PR_STDOUT;\n+\n+  did = should = PR_FALSE;\n+  for (keys = 0; keys < 4; ++keys) {\n+    rv = PR_NewThreadPrivateIndex(&key[keys], Destructor);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = should = PR_FALSE;\n+  for (keys = 0; keys < 8; ++keys) {\n+    pd = PR_GetThreadPrivate(key[keys]);\n+    MY_ASSERT(NULL == pd);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = should = PR_FALSE;\n+  for (keys = 0; keys < 4; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  for (keys = 4; keys < 8; ++keys) {\n+    key[keys] = 4096; /* set to invalid value */\n+  }\n+  did = should = PR_FALSE;\n+  for (keys = 4; keys < 8; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n+    MY_ASSERT(PR_FAILURE == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = PR_FALSE;\n+  should = PR_TRUE;\n+  for (keys = 0; keys < 4; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], key_string[keys]);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = PR_FALSE;\n+  should = PR_TRUE;\n+  for (keys = 0; keys < 4; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], NULL);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = should = PR_FALSE;\n+  for (keys = 0; keys < 4; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], NULL);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = should = PR_FALSE;\n+  for (keys = 8; keys < 127; ++keys) {\n+    rv = PR_NewThreadPrivateIndex(&key[keys], Destructor);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+    rv = PR_SetThreadPrivate(key[keys], \"EXTENSION\");\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = PR_FALSE;\n+  should = PR_TRUE;\n+  for (keys = 8; keys < 127; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], NULL);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+  PrintProgress(__LINE__);\n+\n+  did = should = PR_FALSE;\n+  for (keys = 8; keys < 127; ++keys) {\n+    rv = PR_SetThreadPrivate(key[keys], NULL);\n+    MY_ASSERT(PR_SUCCESS == rv);\n+  }\n+\n+  thread = PR_CreateThread(PR_USER_THREAD, Thread, NULL, PR_PRIORITY_NORMAL,\n+                           PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+\n+  (void)PR_JoinThread(thread);\n+\n+  PrintProgress(__LINE__);\n+\n+  (void)PR_fprintf(fout, \"%s\\n\", ((PR_TRUE == failed) ? \"FAILED\" : \"PASSED\"));\n+\n+  return 0;\n \n } /* Tpd */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dl:r:\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug = PR_TRUE;\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dl:r:\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug = PR_TRUE;\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n-    return PR_Initialize(Tpd, argc, argv, 0);\n+  }\n+  PL_DestroyOptState(opt);\n+  return PR_Initialize(Tpd, argc, argv, 0);\n } /* main */\n \n /* tpd.c */\ndiff --git a/nspr/pr/tests/udpsrv.c b/nspr/pr/tests/udpsrv.c\nindex 8623881..db5cba6 100644\n--- a/nspr/pr/tests/udpsrv.c\n+++ b/nspr/pr/tests/udpsrv.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -51,7 +52,7 @@\n #include <errno.h>\n \n #ifdef XP_PC\n-#define mode_t int\n+#  define mode_t int\n #endif\n \n #define UDP_BUF_SIZE 4096\n@@ -76,8 +77,7 @@ static PRFileDesc* output = NULL;\n \n /* --- static function declarations --- */\n #define DPRINTF(arg) \\\n-    if (_debug_on)   \\\n-    PR_fprintf(output, arg)\n+  if (_debug_on) PR_fprintf(output, arg)\n \n /*******************************************************************\n ** ListNetAddr() -- Display the Net Address on stdout\n@@ -92,13 +92,11 @@ static PRFileDesc* output = NULL;\n **\n ********************************************************************\n */\n-void\n-ListNetAddr(char* msg, PRNetAddr* na)\n-{\n-    char mbuf[256];\n+void ListNetAddr(char* msg, PRNetAddr* na) {\n+  char mbuf[256];\n \n-    sprintf(mbuf, \"ListNetAddr: %s family: %d, port: %d, ip: %8.8X\\n\", msg,\n-            na->inet.family, PR_ntohs(na->inet.port), PR_ntohl(na->inet.ip));\n+  sprintf(mbuf, \"ListNetAddr: %s family: %d, port: %d, ip: %8.8X\\n\", msg,\n+          na->inet.family, PR_ntohs(na->inet.port), PR_ntohl(na->inet.ip));\n #if 0\n     DPRINTF( mbuf );\n #endif\n@@ -118,115 +116,113 @@ ListNetAddr(char* msg, PRNetAddr* na)\n **\n ********************************************************************\n */\n-static void PR_CALLBACK\n-UDP_Server(void* arg)\n-{\n-    static char svrBuf[UDP_BUF_SIZE];\n-    PRFileDesc* svrSock;\n-    PRInt32 rv;\n-    PRNetAddr netaddr;\n-    PRBool bound = PR_FALSE;\n-    PRBool endOfInput = PR_FALSE;\n-    PRInt32 numBytes = UDP_DGRAM_SIZE;\n-\n-    DPRINTF(\"udpsrv: UDP_Server(): starting\\n\");\n-\n-    /* --- Create the socket --- */\n-    DPRINTF(\"udpsrv: UDP_Server(): Creating UDP Socket\\n\");\n-    svrSock = PR_NewUDPSocket();\n-    if (svrSock == NULL) {\n+static void PR_CALLBACK UDP_Server(void* arg) {\n+  static char svrBuf[UDP_BUF_SIZE];\n+  PRFileDesc* svrSock;\n+  PRInt32 rv;\n+  PRNetAddr netaddr;\n+  PRBool bound = PR_FALSE;\n+  PRBool endOfInput = PR_FALSE;\n+  PRInt32 numBytes = UDP_DGRAM_SIZE;\n+\n+  DPRINTF(\"udpsrv: UDP_Server(): starting\\n\");\n+\n+  /* --- Create the socket --- */\n+  DPRINTF(\"udpsrv: UDP_Server(): Creating UDP Socket\\n\");\n+  svrSock = PR_NewUDPSocket();\n+  if (svrSock == NULL) {\n+    passed = PR_FALSE;\n+    if (debug_mode)\n+      PR_fprintf(output,\n+                 \"udpsrv: UDP_Server(): PR_NewUDPSocket() returned NULL\\n\");\n+    return;\n+  }\n+\n+  /* --- Initialize the sockaddr_in structure --- */\n+  memset(&netaddr, 0, sizeof(netaddr));\n+  netaddr.inet.family = PR_AF_INET;\n+  netaddr.inet.port = PR_htons(UDP_SERVER_PORT);\n+  netaddr.inet.ip = PR_htonl(MY_INADDR);\n+\n+  /* --- Bind the socket --- */\n+  while (!bound) {\n+    DPRINTF(\"udpsrv: UDP_Server(): Binding socket\\n\");\n+    rv = PR_Bind(svrSock, &netaddr);\n+    if (rv < 0) {\n+      if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n+        if (debug_mode)\n+          PR_fprintf(output,\n+                     \"udpsrv: UDP_Server(): \\\n+\t\t\t\t\t\tPR_Bind(): reports: PR_ADDRESS_IN_USE_ERROR\\n\");\n+        PR_Sleep(PR_MillisecondsToInterval(2000));\n+        continue;\n+      } else {\n         passed = PR_FALSE;\n         if (debug_mode)\n-            PR_fprintf(output,\n-                       \"udpsrv: UDP_Server(): PR_NewUDPSocket() returned NULL\\n\");\n+          PR_fprintf(output,\n+                     \"udpsrv: UDP_Server(): \\\n+\t\t\t\t\t\tPR_Bind(): failed: %ld with error: %ld\\n\",\n+                     rv, PR_GetError());\n+        PR_Close(svrSock);\n         return;\n+      }\n+    } else {\n+      bound = PR_TRUE;\n     }\n-\n-    /* --- Initialize the sockaddr_in structure --- */\n-    memset(&netaddr, 0, sizeof(netaddr));\n-    netaddr.inet.family = PR_AF_INET;\n-    netaddr.inet.port = PR_htons(UDP_SERVER_PORT);\n-    netaddr.inet.ip = PR_htonl(MY_INADDR);\n-\n-    /* --- Bind the socket --- */\n-    while (!bound) {\n-        DPRINTF(\"udpsrv: UDP_Server(): Binding socket\\n\");\n-        rv = PR_Bind(svrSock, &netaddr);\n-        if (rv < 0) {\n-            if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n-                if (debug_mode)\n-                    PR_fprintf(output,\n-                               \"udpsrv: UDP_Server(): \\\n-\t\t\t\t\t\tPR_Bind(): reports: PR_ADDRESS_IN_USE_ERROR\\n\");\n-                PR_Sleep(PR_MillisecondsToInterval(2000));\n-                continue;\n-            } else {\n-                passed = PR_FALSE;\n-                if (debug_mode)\n-                    PR_fprintf(output,\n-                               \"udpsrv: UDP_Server(): \\\n-\t\t\t\t\t\tPR_Bind(): failed: %ld with error: %ld\\n\",\n-                               rv, PR_GetError());\n-                PR_Close(svrSock);\n-                return;\n-            }\n-        } else {\n-            bound = PR_TRUE;\n-        }\n+  }\n+  ListNetAddr(\"UDP_Server: after bind\", &netaddr);\n+\n+  /* --- Recv the socket --- */\n+  while (!endOfInput) {\n+    DPRINTF(\"udpsrv: UDP_Server(): RecvFrom() socket\\n\");\n+    rv = PR_RecvFrom(svrSock, svrBuf, numBytes, 0, &netaddr, UDP_TIMEOUT);\n+    if (rv == -1) {\n+      passed = PR_FALSE;\n+      if (debug_mode)\n+        PR_fprintf(\n+            output,\n+            \"udpsrv: UDP_Server(): PR_RecvFrom(): failed with error: %ld\\n\",\n+            PR_GetError());\n+      PR_Close(svrSock);\n+      return;\n     }\n-    ListNetAddr(\"UDP_Server: after bind\", &netaddr);\n-\n-    /* --- Recv the socket --- */\n-    while (!endOfInput) {\n-        DPRINTF(\"udpsrv: UDP_Server(): RecvFrom() socket\\n\");\n-        rv = PR_RecvFrom(svrSock, svrBuf, numBytes, 0, &netaddr, UDP_TIMEOUT);\n-        if (rv == -1) {\n-            passed = PR_FALSE;\n-            if (debug_mode)\n-                PR_fprintf(\n-                    output,\n-                    \"udpsrv: UDP_Server(): PR_RecvFrom(): failed with error: %ld\\n\",\n-                    PR_GetError());\n-            PR_Close(svrSock);\n-            return;\n-        }\n-        ListNetAddr(\"UDP_Server after RecvFrom\", &netaddr);\n-\n-        srvBytesRead += rv;\n+    ListNetAddr(\"UDP_Server after RecvFrom\", &netaddr);\n \n-        if (svrBuf[0] == 'E') {\n-            DPRINTF(\"udpsrv: UDP_Server(): EOF on input detected\\n\");\n-            endOfInput = PR_TRUE;\n-        }\n+    srvBytesRead += rv;\n \n-        /* --- Send the socket --- */\n-        DPRINTF(\"udpsrv: UDP_Server(): SendTo(): socket\\n\");\n-        rv = PR_SendTo(svrSock, svrBuf, rv, 0, &netaddr, PR_INTERVAL_NO_TIMEOUT);\n-        if (rv == -1) {\n-            passed = PR_FALSE;\n-            if (debug_mode)\n-                PR_fprintf(\n-                    output,\n-                    \"udpsrv: UDP_Server(): PR_SendTo(): failed with error: %ld\\n\",\n-                    PR_GetError());\n-            PR_Close(svrSock);\n-            return;\n-        }\n-        ListNetAddr(\"UDP_Server after SendTo\", &netaddr);\n+    if (svrBuf[0] == 'E') {\n+      DPRINTF(\"udpsrv: UDP_Server(): EOF on input detected\\n\");\n+      endOfInput = PR_TRUE;\n     }\n \n-    /* --- Close the socket --- */\n-    DPRINTF(\"udpsrv: UDP_Server(): Closing socket\\n\");\n-    rv = PR_Close(svrSock);\n-    if (rv != PR_SUCCESS) {\n-        passed = PR_FALSE;\n-        if (debug_mode)\n-            PR_fprintf(output,\n-                       \"udpsrv: UDP_Server(): PR_Close(): failed to close socket\\n\");\n-        return;\n+    /* --- Send the socket --- */\n+    DPRINTF(\"udpsrv: UDP_Server(): SendTo(): socket\\n\");\n+    rv = PR_SendTo(svrSock, svrBuf, rv, 0, &netaddr, PR_INTERVAL_NO_TIMEOUT);\n+    if (rv == -1) {\n+      passed = PR_FALSE;\n+      if (debug_mode)\n+        PR_fprintf(\n+            output,\n+            \"udpsrv: UDP_Server(): PR_SendTo(): failed with error: %ld\\n\",\n+            PR_GetError());\n+      PR_Close(svrSock);\n+      return;\n     }\n+    ListNetAddr(\"UDP_Server after SendTo\", &netaddr);\n+  }\n+\n+  /* --- Close the socket --- */\n+  DPRINTF(\"udpsrv: UDP_Server(): Closing socket\\n\");\n+  rv = PR_Close(svrSock);\n+  if (rv != PR_SUCCESS) {\n+    passed = PR_FALSE;\n+    if (debug_mode)\n+      PR_fprintf(output,\n+                 \"udpsrv: UDP_Server(): PR_Close(): failed to close socket\\n\");\n+    return;\n+  }\n \n-    DPRINTF(\"udpsrv: UDP_Server(): Normal end\\n\");\n+  DPRINTF(\"udpsrv: UDP_Server(): Normal end\\n\");\n } /* --- end UDP_Server() --- */\n \n static char cltBuf[UDP_BUF_SIZE];\n@@ -248,162 +244,160 @@ static char cltBufin[UDP_BUF_SIZE];\n **\n ********************************************************************\n */\n-static void PR_CALLBACK\n-UDP_Client(void* arg)\n-{\n-    PRFileDesc* cltSock;\n-    PRInt32 rv;\n-    PRBool bound = PR_FALSE;\n-    PRNetAddr netaddr;\n-    PRNetAddr netaddrx;\n-    PRBool endOfInput = PR_FALSE;\n-    PRInt32 numBytes = UDP_DGRAM_SIZE;\n-    PRInt32 writeThisMany = UDP_AMOUNT_TO_WRITE;\n-    int i;\n-\n-    DPRINTF(\"udpsrv: UDP_Client(): starting\\n\");\n-\n-    /* --- Create the socket --- */\n-    cltSock = PR_NewUDPSocket();\n-    if (cltSock == NULL) {\n+static void PR_CALLBACK UDP_Client(void* arg) {\n+  PRFileDesc* cltSock;\n+  PRInt32 rv;\n+  PRBool bound = PR_FALSE;\n+  PRNetAddr netaddr;\n+  PRNetAddr netaddrx;\n+  PRBool endOfInput = PR_FALSE;\n+  PRInt32 numBytes = UDP_DGRAM_SIZE;\n+  PRInt32 writeThisMany = UDP_AMOUNT_TO_WRITE;\n+  int i;\n+\n+  DPRINTF(\"udpsrv: UDP_Client(): starting\\n\");\n+\n+  /* --- Create the socket --- */\n+  cltSock = PR_NewUDPSocket();\n+  if (cltSock == NULL) {\n+    passed = PR_FALSE;\n+    if (debug_mode)\n+      PR_fprintf(output,\n+                 \"udpsrv: UDP_Client(): PR_NewUDPSocket() returned NULL\\n\");\n+    return;\n+  }\n+\n+  /* --- Initialize the sockaddr_in structure --- */\n+  memset(&netaddr, 0, sizeof(netaddr));\n+  netaddr.inet.family = PR_AF_INET;\n+  netaddr.inet.ip = PR_htonl(MY_INADDR);\n+  netaddr.inet.port = PR_htons(UDP_CLIENT_PORT);\n+\n+  /* --- Initialize the write buffer --- */\n+  for (i = 0; i < UDP_BUF_SIZE; i++) {\n+    cltBuf[i] = i;\n+  }\n+\n+  /* --- Bind the socket --- */\n+  while (!bound) {\n+    DPRINTF(\"udpsrv: UDP_Client(): Binding socket\\n\");\n+    rv = PR_Bind(cltSock, &netaddr);\n+    if (rv < 0) {\n+      if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n+        if (debug_mode)\n+          PR_fprintf(output,\n+                     \"udpsrv: UDP_Client(): PR_Bind(): reports: \"\n+                     \"PR_ADDRESS_IN_USE_ERROR\\n\");\n+        PR_Sleep(PR_MillisecondsToInterval(2000));\n+        continue;\n+      } else {\n         passed = PR_FALSE;\n         if (debug_mode)\n-            PR_fprintf(output,\n-                       \"udpsrv: UDP_Client(): PR_NewUDPSocket() returned NULL\\n\");\n+          PR_fprintf(\n+              output,\n+              \"udpsrv: UDP_Client(): PR_Bind(): failed: %ld with error: %ld\\n\",\n+              rv, PR_GetError());\n+        PR_Close(cltSock);\n         return;\n+      }\n+    } else {\n+      bound = PR_TRUE;\n     }\n+  }\n+  ListNetAddr(\"UDP_Client after Bind\", &netaddr);\n \n-    /* --- Initialize the sockaddr_in structure --- */\n-    memset(&netaddr, 0, sizeof(netaddr));\n-    netaddr.inet.family = PR_AF_INET;\n-    netaddr.inet.ip = PR_htonl(MY_INADDR);\n-    netaddr.inet.port = PR_htons(UDP_CLIENT_PORT);\n+  /* --- Initialize the sockaddr_in structure --- */\n+  memset(&netaddr, 0, sizeof(netaddr));\n+  netaddr.inet.family = PR_AF_INET;\n+  netaddr.inet.ip = PR_htonl(PEER_INADDR);\n+  netaddr.inet.port = PR_htons(UDP_SERVER_PORT);\n \n-    /* --- Initialize the write buffer --- */\n-    for (i = 0; i < UDP_BUF_SIZE; i++) {\n-        cltBuf[i] = i;\n+  /* --- send and receive packets until no more data left */\n+  while (!endOfInput) {\n+    /*\n+    ** Signal EOF in the data stream on the last packet\n+    */\n+    if (writeThisMany <= UDP_DGRAM_SIZE) {\n+      DPRINTF(\"udpsrv: UDP_Client(): Send EOF packet\\n\");\n+      cltBuf[0] = 'E';\n+      endOfInput = PR_TRUE;\n     }\n \n-    /* --- Bind the socket --- */\n-    while (!bound) {\n-        DPRINTF(\"udpsrv: UDP_Client(): Binding socket\\n\");\n-        rv = PR_Bind(cltSock, &netaddr);\n-        if (rv < 0) {\n-            if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) {\n-                if (debug_mode)\n-                    PR_fprintf(output,\n-                               \"udpsrv: UDP_Client(): PR_Bind(): reports: \"\n-                               \"PR_ADDRESS_IN_USE_ERROR\\n\");\n-                PR_Sleep(PR_MillisecondsToInterval(2000));\n-                continue;\n-            } else {\n-                passed = PR_FALSE;\n-                if (debug_mode)\n-                    PR_fprintf(\n-                        output,\n-                        \"udpsrv: UDP_Client(): PR_Bind(): failed: %ld with error: %ld\\n\",\n-                        rv, PR_GetError());\n-                PR_Close(cltSock);\n-                return;\n-            }\n-        } else {\n-            bound = PR_TRUE;\n-        }\n+    /* --- SendTo the socket --- */\n+    if (writeThisMany > UDP_DGRAM_SIZE) {\n+      numBytes = UDP_DGRAM_SIZE;\n+    } else {\n+      numBytes = writeThisMany;\n     }\n-    ListNetAddr(\"UDP_Client after Bind\", &netaddr);\n-\n-    /* --- Initialize the sockaddr_in structure --- */\n-    memset(&netaddr, 0, sizeof(netaddr));\n-    netaddr.inet.family = PR_AF_INET;\n-    netaddr.inet.ip = PR_htonl(PEER_INADDR);\n-    netaddr.inet.port = PR_htons(UDP_SERVER_PORT);\n-\n-    /* --- send and receive packets until no more data left */\n-    while (!endOfInput) {\n-        /*\n-        ** Signal EOF in the data stream on the last packet\n-        */\n-        if (writeThisMany <= UDP_DGRAM_SIZE) {\n-            DPRINTF(\"udpsrv: UDP_Client(): Send EOF packet\\n\");\n-            cltBuf[0] = 'E';\n-            endOfInput = PR_TRUE;\n-        }\n-\n-        /* --- SendTo the socket --- */\n-        if (writeThisMany > UDP_DGRAM_SIZE) {\n-            numBytes = UDP_DGRAM_SIZE;\n-        } else {\n-            numBytes = writeThisMany;\n-        }\n-        writeThisMany -= numBytes;\n-        {\n-            char mbuf[256];\n-            sprintf(mbuf, \"udpsrv: UDP_Client(): write_this_many: %d, numbytes: %d\\n\",\n-                    writeThisMany, numBytes);\n-            DPRINTF(mbuf);\n-        }\n-\n-        DPRINTF(\"udpsrv: UDP_Client(): SendTo(): socket\\n\");\n-        rv = PR_SendTo(cltSock, cltBuf, numBytes, 0, &netaddr, UDP_TIMEOUT);\n-        if (rv == -1) {\n-            passed = PR_FALSE;\n-            if (debug_mode)\n-                PR_fprintf(\n-                    output,\n-                    \"udpsrv: UDP_Client(): PR_SendTo(): failed with error: %ld\\n\",\n-                    PR_GetError());\n-            PR_Close(cltSock);\n-            return;\n-        }\n-        ListNetAddr(\"UDP_Client after SendTo\", &netaddr);\n-\n-        /* --- RecvFrom the socket --- */\n-        memset(cltBufin, 0, UDP_BUF_SIZE);\n-        DPRINTF(\"udpsrv: UDP_Client(): RecvFrom(): socket\\n\");\n-        rv = PR_RecvFrom(cltSock, cltBufin, numBytes, 0, &netaddrx, UDP_TIMEOUT);\n-        if (rv == -1) {\n-            passed = PR_FALSE;\n-            if (debug_mode)\n-                PR_fprintf(\n-                    output,\n-                    \"udpsrv: UDP_Client(): PR_RecvFrom(): failed with error: %ld\\n\",\n-                    PR_GetError());\n-            PR_Close(cltSock);\n-            return;\n-        }\n-        ListNetAddr(\"UDP_Client after RecvFrom()\", &netaddr);\n-        cltBytesRead += rv;\n-\n-        /* --- verify buffer --- */\n-        for (i = 0; i < rv; i++) {\n-            if (cltBufin[i] != i) {\n-                /* --- special case, end of input --- */\n-                if (endOfInput && i == 0 && cltBufin[0] == 'E') {\n-                    continue;\n-                }\n-                passed = PR_FALSE;\n-                if (debug_mode)\n-                    PR_fprintf(output, \"udpsrv: UDP_Client(): return data mismatch\\n\");\n-                PR_Close(cltSock);\n-                return;\n-            }\n-        }\n-        if (debug_mode) {\n-            PR_fprintf(output, \".\");\n-        }\n+    writeThisMany -= numBytes;\n+    {\n+      char mbuf[256];\n+      sprintf(mbuf, \"udpsrv: UDP_Client(): write_this_many: %d, numbytes: %d\\n\",\n+              writeThisMany, numBytes);\n+      DPRINTF(mbuf);\n     }\n \n-    /* --- Close the socket --- */\n-    DPRINTF(\"udpsrv: UDP_Server(): Closing socket\\n\");\n-    rv = PR_Close(cltSock);\n-    if (rv != PR_SUCCESS) {\n+    DPRINTF(\"udpsrv: UDP_Client(): SendTo(): socket\\n\");\n+    rv = PR_SendTo(cltSock, cltBuf, numBytes, 0, &netaddr, UDP_TIMEOUT);\n+    if (rv == -1) {\n+      passed = PR_FALSE;\n+      if (debug_mode)\n+        PR_fprintf(\n+            output,\n+            \"udpsrv: UDP_Client(): PR_SendTo(): failed with error: %ld\\n\",\n+            PR_GetError());\n+      PR_Close(cltSock);\n+      return;\n+    }\n+    ListNetAddr(\"UDP_Client after SendTo\", &netaddr);\n+\n+    /* --- RecvFrom the socket --- */\n+    memset(cltBufin, 0, UDP_BUF_SIZE);\n+    DPRINTF(\"udpsrv: UDP_Client(): RecvFrom(): socket\\n\");\n+    rv = PR_RecvFrom(cltSock, cltBufin, numBytes, 0, &netaddrx, UDP_TIMEOUT);\n+    if (rv == -1) {\n+      passed = PR_FALSE;\n+      if (debug_mode)\n+        PR_fprintf(\n+            output,\n+            \"udpsrv: UDP_Client(): PR_RecvFrom(): failed with error: %ld\\n\",\n+            PR_GetError());\n+      PR_Close(cltSock);\n+      return;\n+    }\n+    ListNetAddr(\"UDP_Client after RecvFrom()\", &netaddr);\n+    cltBytesRead += rv;\n+\n+    /* --- verify buffer --- */\n+    for (i = 0; i < rv; i++) {\n+      if (cltBufin[i] != i) {\n+        /* --- special case, end of input --- */\n+        if (endOfInput && i == 0 && cltBufin[0] == 'E') {\n+          continue;\n+        }\n         passed = PR_FALSE;\n         if (debug_mode)\n-            PR_fprintf(output,\n-                       \"udpsrv: UDP_Client(): PR_Close(): failed to close socket\\n\");\n+          PR_fprintf(output, \"udpsrv: UDP_Client(): return data mismatch\\n\");\n+        PR_Close(cltSock);\n         return;\n+      }\n+    }\n+    if (debug_mode) {\n+      PR_fprintf(output, \".\");\n     }\n-    DPRINTF(\"udpsrv: UDP_Client(): ending\\n\");\n+  }\n+\n+  /* --- Close the socket --- */\n+  DPRINTF(\"udpsrv: UDP_Server(): Closing socket\\n\");\n+  rv = PR_Close(cltSock);\n+  if (rv != PR_SUCCESS) {\n+    passed = PR_FALSE;\n+    if (debug_mode)\n+      PR_fprintf(output,\n+                 \"udpsrv: UDP_Client(): PR_Close(): failed to close socket\\n\");\n+    return;\n+  }\n+  DPRINTF(\"udpsrv: UDP_Client(): ending\\n\");\n } /* --- end UDP_Client() --- */\n \n /********************************************************************\n@@ -424,93 +418,91 @@ UDP_Client(void* arg)\n ********************************************************************\n */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRThread *srv, *clt;\n-    /* The command line argument: -d is used to determine if the test is being run\n-        in debug mode. The regress tool requires only one line output:PASS or\n-       FAIL. All of the printfs associated with this test has been handled with a\n-       if (debug_mode) test. Usage: test_name -d -v\n-        */\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dv\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = 1;\n-                break;\n-            case 'v': /* verbose mode */\n-                _debug_on = 1;\n-                break;\n-            default:\n-                break;\n-        }\n+int main(int argc, char** argv) {\n+  PRThread *srv, *clt;\n+  /* The command line argument: -d is used to determine if the test is being run\n+      in debug mode. The regress tool requires only one line output:PASS or\n+     FAIL. All of the printfs associated with this test has been handled with a\n+     if (debug_mode) test. Usage: test_name -d -v\n+      */\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dv\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n-\n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-    output = PR_STDERR;\n-\n-    PR_SetConcurrency(4);\n-\n-    /*\n-    ** Create the Server thread\n-    */\n-    DPRINTF(\"udpsrv: Creating Server Thread\\n\");\n-    srv = PR_CreateThread(PR_USER_THREAD, UDP_Server, (void*)0, PR_PRIORITY_LOW,\n-                          PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (srv == NULL) {\n-        if (debug_mode) {\n-            PR_fprintf(output, \"udpsrv: Cannot create server thread\\n\");\n-        }\n-        passed = PR_FALSE;\n-    }\n-\n-    /*\n-    ** Give the Server time to Start\n-    */\n-    DPRINTF(\"udpsrv: Pausing to allow Server to start\\n\");\n-    PR_Sleep(PR_MillisecondsToInterval(200));\n-\n-    /*\n-    ** Create the Client thread\n-    */\n-    DPRINTF(\"udpsrv: Creating Client Thread\\n\");\n-    clt = PR_CreateThread(PR_USER_THREAD, UDP_Client, (void*)0, PR_PRIORITY_LOW,\n-                          PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (clt == NULL) {\n-        if (debug_mode) {\n-            PR_fprintf(output, \"udpsrv: Cannot create server thread\\n\");\n-        }\n-        passed = PR_FALSE;\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = 1;\n+        break;\n+      case 'v': /* verbose mode */\n+        _debug_on = 1;\n+        break;\n+      default:\n+        break;\n     }\n-\n-    /*\n-    **\n-    */\n-    DPRINTF(\"udpsrv: Waiting to join Server & Client Threads\\n\");\n-    PR_JoinThread(srv);\n-    PR_JoinThread(clt);\n-\n-    /*\n-    ** Evaluate test results\n-    */\n-    if (debug_mode)\n-        PR_fprintf(output,\n-                   \"\\n\\nudpsrv: main(): cltBytesRead(%ld), \\\n-\t\tsrvBytesRead(%ld), expected(%ld)\\n\",\n-                   cltBytesRead, srvBytesRead, UDP_AMOUNT_TO_WRITE);\n-    if (cltBytesRead != srvBytesRead || cltBytesRead != UDP_AMOUNT_TO_WRITE) {\n-        passed = PR_FALSE;\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  output = PR_STDERR;\n+\n+  PR_SetConcurrency(4);\n+\n+  /*\n+  ** Create the Server thread\n+  */\n+  DPRINTF(\"udpsrv: Creating Server Thread\\n\");\n+  srv = PR_CreateThread(PR_USER_THREAD, UDP_Server, (void*)0, PR_PRIORITY_LOW,\n+                        PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (srv == NULL) {\n+    if (debug_mode) {\n+      PR_fprintf(output, \"udpsrv: Cannot create server thread\\n\");\n     }\n-    PR_Cleanup();\n-    if (passed) {\n-        return 0;\n-    } else {\n-        return 1;\n+    passed = PR_FALSE;\n+  }\n+\n+  /*\n+  ** Give the Server time to Start\n+  */\n+  DPRINTF(\"udpsrv: Pausing to allow Server to start\\n\");\n+  PR_Sleep(PR_MillisecondsToInterval(200));\n+\n+  /*\n+  ** Create the Client thread\n+  */\n+  DPRINTF(\"udpsrv: Creating Client Thread\\n\");\n+  clt = PR_CreateThread(PR_USER_THREAD, UDP_Client, (void*)0, PR_PRIORITY_LOW,\n+                        PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (clt == NULL) {\n+    if (debug_mode) {\n+      PR_fprintf(output, \"udpsrv: Cannot create server thread\\n\");\n     }\n+    passed = PR_FALSE;\n+  }\n+\n+  /*\n+  **\n+  */\n+  DPRINTF(\"udpsrv: Waiting to join Server & Client Threads\\n\");\n+  PR_JoinThread(srv);\n+  PR_JoinThread(clt);\n+\n+  /*\n+  ** Evaluate test results\n+  */\n+  if (debug_mode)\n+    PR_fprintf(output,\n+               \"\\n\\nudpsrv: main(): cltBytesRead(%ld), \\\n+\t\tsrvBytesRead(%ld), expected(%ld)\\n\",\n+               cltBytesRead, srvBytesRead, UDP_AMOUNT_TO_WRITE);\n+  if (cltBytesRead != srvBytesRead || cltBytesRead != UDP_AMOUNT_TO_WRITE) {\n+    passed = PR_FALSE;\n+  }\n+  PR_Cleanup();\n+  if (passed) {\n+    return 0;\n+  } else {\n+    return 1;\n+  }\n } /* --- end main() --- */\ndiff --git a/nspr/pr/tests/ut_ttools.h b/nspr/pr/tests/ut_ttools.h\nindex 92d329e..e3cac5d 100644\n--- a/nspr/pr/tests/ut_ttools.h\n+++ b/nspr/pr/tests/ut_ttools.h\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -7,4 +8,4 @@\n #define PASS 1\n #define FAIL 0\n \n-PRIntn debug_mode = 0;\n+PRIntn debug_mode=0;\ndiff --git a/nspr/pr/tests/vercheck.c b/nspr/pr/tests/vercheck.c\nindex 21e8e9d..b0e0584 100644\n--- a/nspr/pr/tests/vercheck.c\n+++ b/nspr/pr/tests/vercheck.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -25,20 +26,20 @@\n  * It, of course, is compatible with itself.\n  */\n static char* compatible_version[] = {\n-    \"4.0\", \"4.0.1\", \"4.1\", \"4.1.1\", \"4.1.2\", \"4.1.3\", \"4.2\",\n-    \"4.2.1\", \"4.2.2\", \"4.3\", \"4.4\", \"4.4.1\", \"4.5\", \"4.5.1\",\n-    \"4.6\", \"4.6.1\", \"4.6.2\", \"4.6.3\", \"4.6.4\", \"4.6.5\", \"4.6.6\",\n-    \"4.6.7\", \"4.6.8\", \"4.7\", \"4.7.1\", \"4.7.2\", \"4.7.3\", \"4.7.4\",\n-    \"4.7.5\", \"4.7.6\", \"4.8\", \"4.8.1\", \"4.8.2\", \"4.8.3\", \"4.8.4\",\n-    \"4.8.5\", \"4.8.6\", \"4.8.7\", \"4.8.8\", \"4.8.9\", \"4.9\", \"4.9.1\",\n-    \"4.9.2\", \"4.9.3\", \"4.9.4\", \"4.9.5\", \"4.9.6\", \"4.10\", \"4.10.1\",\n-    \"4.10.2\", \"4.10.3\", \"4.10.4\", \"4.10.5\", \"4.10.6\", \"4.10.7\", \"4.10.8\",\n-    \"4.10.9\", \"4.10.10\", \"4.11\", \"4.12\", \"4.13\", \"4.14\", \"4.15\",\n-    \"4.16\", \"4.17\", \"4.18\", \"4.19\", \"4.20\", \"4.21\", \"4.22\",\n-    \"4.23\", \"4.24\", \"4.25\", \"4.26\", \"4.27\", \"4.28\", \"4.29\",\n-    \"4.30\", \"4.31\", \"4.32\", \"4.33\", \"4.34\", \"4.35\", \"4.36\",\n-    \"4.37\", \"4.38\", \"4.39\", PR_VERSION\n-};\n+    \"4.0\",    \"4.0.1\",   \"4.1\",    \"4.1.1\",  \"4.1.2\",  \"4.1.3\",  \"4.2\",\n+    \"4.2.1\",  \"4.2.2\",   \"4.3\",    \"4.4\",    \"4.4.1\",  \"4.5\",    \"4.5.1\",\n+    \"4.6\",    \"4.6.1\",   \"4.6.2\",  \"4.6.3\",  \"4.6.4\",  \"4.6.5\",  \"4.6.6\",\n+    \"4.6.7\",  \"4.6.8\",   \"4.7\",    \"4.7.1\",  \"4.7.2\",  \"4.7.3\",  \"4.7.4\",\n+    \"4.7.5\",  \"4.7.6\",   \"4.8\",    \"4.8.1\",  \"4.8.2\",  \"4.8.3\",  \"4.8.4\",\n+    \"4.8.5\",  \"4.8.6\",   \"4.8.7\",  \"4.8.8\",  \"4.8.9\",  \"4.9\",    \"4.9.1\",\n+    \"4.9.2\",  \"4.9.3\",   \"4.9.4\",  \"4.9.5\",  \"4.9.6\",  \"4.10\",   \"4.10.1\",\n+    \"4.10.2\", \"4.10.3\",  \"4.10.4\", \"4.10.5\", \"4.10.6\", \"4.10.7\", \"4.10.8\",\n+    \"4.10.9\", \"4.10.10\", \"4.11\",   \"4.12\",   \"4.13\",   \"4.14\",   \"4.15\",\n+    \"4.16\",   \"4.17\",    \"4.18\",   \"4.19\",   \"4.20\",   \"4.21\",   \"4.22\",\n+    \"4.23\",   \"4.24\",    \"4.25\",   \"4,26\",   \"4.27\",   \"4.28\",   \"4.29\",\n+    \"4.30\",   \"4.31\",    \"4.32\",   \"4.33\",   \"4.34\",   \"4.35\",   \"4.36\",\n+    \"4.37\",   \"4.38\",    \"4.38.1\",\n+    PR_VERSION};\n \n /*\n  * This release is not backward compatible with the old\n@@ -48,37 +49,34 @@ static char* compatible_version[] = {\n  * patches.\n  */\n static char* incompatible_version[] = {\n-    \"2.1 19980529\", \"3.0\", \"3.0.1\", \"3.1\", \"3.1.1\",\n-    \"3.1.2\", \"3.1.3\", \"3.5\", \"3.5.1\", \"4.40.1\",\n-    \"4.41\", \"4.41.1\", \"10.0\", \"11.1\", \"12.14.20\"\n-};\n+    \"2.1 19980529\", \"3.0\",    \"3.0.1\", \"3.1\",   \"3.1.1\",\n+    \"3.1.2\",        \"3.1.3\",  \"3.5\",   \"3.5.1\", \"4.38.3\",\n+    \"4.39\",         \"4.39.1\", \"10.0\",  \"11.1\",  \"12.14.20\"};\n \n-int\n-main(int argc, char** argv)\n-{\n-    int idx;\n-    int num_compatible = sizeof(compatible_version) / sizeof(char*);\n-    int num_incompatible = sizeof(incompatible_version) / sizeof(char*);\n+int main(int argc, char** argv) {\n+  int idx;\n+  int num_compatible = sizeof(compatible_version) / sizeof(char*);\n+  int num_incompatible = sizeof(incompatible_version) / sizeof(char*);\n \n-    printf(\"NSPR release %s:\\n\", PR_VERSION);\n-    for (idx = 0; idx < num_compatible; idx++) {\n-        if (PR_VersionCheck(compatible_version[idx]) == PR_FALSE) {\n-            fprintf(stderr, \"Should be compatible with version %s\\n\",\n-                    compatible_version[idx]);\n-            exit(1);\n-        }\n-        printf(\"Compatible with version %s\\n\", compatible_version[idx]);\n+  printf(\"NSPR release %s:\\n\", PR_VERSION);\n+  for (idx = 0; idx < num_compatible; idx++) {\n+    if (PR_VersionCheck(compatible_version[idx]) == PR_FALSE) {\n+      fprintf(stderr, \"Should be compatible with version %s\\n\",\n+              compatible_version[idx]);\n+      exit(1);\n     }\n+    printf(\"Compatible with version %s\\n\", compatible_version[idx]);\n+  }\n \n-    for (idx = 0; idx < num_incompatible; idx++) {\n-        if (PR_VersionCheck(incompatible_version[idx]) == PR_TRUE) {\n-            fprintf(stderr, \"Should be incompatible with version %s\\n\",\n-                    incompatible_version[idx]);\n-            exit(1);\n-        }\n-        printf(\"Incompatible with version %s\\n\", incompatible_version[idx]);\n+  for (idx = 0; idx < num_incompatible; idx++) {\n+    if (PR_VersionCheck(incompatible_version[idx]) == PR_TRUE) {\n+      fprintf(stderr, \"Should be incompatible with version %s\\n\",\n+              incompatible_version[idx]);\n+      exit(1);\n     }\n+    printf(\"Incompatible with version %s\\n\", incompatible_version[idx]);\n+  }\n \n-    printf(\"PASS\\n\");\n-    return 0;\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/version.c b/nspr/pr/tests/version.c\nindex a3cbcc8..71f5bb1 100644\n--- a/nspr/pr/tests/version.c\n+++ b/nspr/pr/tests/version.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,76 +11,73 @@\n #include \"plerror.h\"\n #include \"plgetopt.h\"\n \n-PR_IMPORT(const PRVersionDescription*)\n-libVersionPoint(void);\n+PR_IMPORT(const PRVersionDescription*) libVersionPoint(void);\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv = 1;\n-    PLOptStatus os;\n-    PRIntn verbosity = 0;\n-    PRLibrary* runtime = NULL;\n-    const char* library_name = NULL;\n-    const PRVersionDescription* version_info;\n-    char buffer[100];\n-    PRExplodedTime exploded;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n+int main(int argc, char** argv) {\n+  PRIntn rv = 1;\n+  PLOptStatus os;\n+  PRIntn verbosity = 0;\n+  PRLibrary* runtime = NULL;\n+  const char* library_name = NULL;\n+  const PRVersionDescription* version_info;\n+  char buffer[100];\n+  PRExplodedTime exploded;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"d\");\n \n-    PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n+  PRFileDesc* err = PR_GetSpecialFD(PR_StandardError);\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 0: /* fully qualified library name */\n-                library_name = opt->value;\n-                break;\n-            case 'd': /* verbodity */\n-                verbosity += 1;\n-                break;\n-            default:\n-                PR_fprintf(err, \"Usage: version [-d] {fully qualified library name}\\n\");\n-                return 2; /* but not a lot else */\n-        }\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    PL_DestroyOptState(opt);\n+    switch (opt->option) {\n+      case 0: /* fully qualified library name */\n+        library_name = opt->value;\n+        break;\n+      case 'd': /* verbodity */\n+        verbosity += 1;\n+        break;\n+      default:\n+        PR_fprintf(err, \"Usage: version [-d] {fully qualified library name}\\n\");\n+        return 2; /* but not a lot else */\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    if (NULL != library_name) {\n-        runtime = PR_LoadLibrary(library_name);\n-        if (NULL == runtime) {\n-            PL_FPrintError(err, \"PR_LoadLibrary\");\n-            return 3;\n-        } else {\n-            versionEntryPointType versionPoint =\n-                (versionEntryPointType)PR_FindSymbol(runtime, \"libVersionPoint\");\n-            if (NULL == versionPoint) {\n-                PL_FPrintError(err, \"PR_FindSymbol\");\n-                return 4;\n-            }\n-            version_info = versionPoint();\n-        }\n+  if (NULL != library_name) {\n+    runtime = PR_LoadLibrary(library_name);\n+    if (NULL == runtime) {\n+      PL_FPrintError(err, \"PR_LoadLibrary\");\n+      return 3;\n     } else {\n-        version_info = libVersionPoint(); /* NSPR's version info */\n+      versionEntryPointType versionPoint =\n+          (versionEntryPointType)PR_FindSymbol(runtime, \"libVersionPoint\");\n+      if (NULL == versionPoint) {\n+        PL_FPrintError(err, \"PR_FindSymbol\");\n+        return 4;\n+      }\n+      version_info = versionPoint();\n     }\n+  } else {\n+    version_info = libVersionPoint(); /* NSPR's version info */\n+  }\n \n-    (void)PR_fprintf(err, \"Runtime library version information\\n\");\n-    PR_ExplodeTime(version_info->buildTime, PR_GMTParameters, &exploded);\n-    (void)PR_FormatTime(buffer, sizeof(buffer), \"%d %b %Y %H:%M:%S\", &exploded);\n-    (void)PR_fprintf(err, \"  Build time: %s GMT\\n\", buffer);\n-    (void)PR_fprintf(err, \"  Build time: %s\\n\", version_info->buildTimeString);\n-    (void)PR_fprintf(err, \"  %s V%u.%u.%u (%s%s%s)\\n\", version_info->description,\n-                     version_info->vMajor, version_info->vMinor,\n-                     version_info->vPatch, (version_info->beta ? \" beta \" : \"\"),\n-                     (version_info->debug ? \" debug \" : \"\"),\n-                     (version_info->special ? \" special\" : \"\"));\n-    (void)PR_fprintf(err, \"  filename: %s\\n\", version_info->filename);\n-    (void)PR_fprintf(err, \"  security: %s\\n\", version_info->security);\n-    (void)PR_fprintf(err, \"  copyright: %s\\n\", version_info->copyright);\n-    (void)PR_fprintf(err, \"  comment: %s\\n\", version_info->comment);\n-    rv = 0;\n-    return rv;\n+  (void)PR_fprintf(err, \"Runtime library version information\\n\");\n+  PR_ExplodeTime(version_info->buildTime, PR_GMTParameters, &exploded);\n+  (void)PR_FormatTime(buffer, sizeof(buffer), \"%d %b %Y %H:%M:%S\", &exploded);\n+  (void)PR_fprintf(err, \"  Build time: %s GMT\\n\", buffer);\n+  (void)PR_fprintf(err, \"  Build time: %s\\n\", version_info->buildTimeString);\n+  (void)PR_fprintf(err, \"  %s V%u.%u.%u (%s%s%s)\\n\", version_info->description,\n+                   version_info->vMajor, version_info->vMinor,\n+                   version_info->vPatch, (version_info->beta ? \" beta \" : \"\"),\n+                   (version_info->debug ? \" debug \" : \"\"),\n+                   (version_info->special ? \" special\" : \"\"));\n+  (void)PR_fprintf(err, \"  filename: %s\\n\", version_info->filename);\n+  (void)PR_fprintf(err, \"  security: %s\\n\", version_info->security);\n+  (void)PR_fprintf(err, \"  copyright: %s\\n\", version_info->copyright);\n+  (void)PR_fprintf(err, \"  comment: %s\\n\", version_info->comment);\n+  rv = 0;\n+  return rv;\n }\n \n /* version.c */\ndiff --git a/nspr/pr/tests/writev.c b/nspr/pr/tests/writev.c\nindex 8c38cde..531a29f 100644\n--- a/nspr/pr/tests/writev.c\n+++ b/nspr/pr/tests/writev.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -10,197 +11,193 @@\n #include <string.h>\n \n #ifndef IOV_MAX\n-#define IOV_MAX 16\n+#  define IOV_MAX 16\n #endif\n \n #ifdef DEBUG\n-#define PORT_INC_DO +100\n+#  define PORT_INC_DO +100\n #else\n-#define PORT_INC_DO\n+#  define PORT_INC_DO\n #endif\n #ifdef IS_64\n-#define PORT_INC_3264 +200\n+#  define PORT_INC_3264 +200\n #else\n-#define PORT_INC_3264\n+#  define PORT_INC_3264\n #endif\n \n #define BASE_PORT 9867 PORT_INC_DO PORT_INC_3264\n \n-int PR_CALLBACK\n-Writev(int argc, char** argv)\n-{\n-    PRStatus rv;\n-    PRNetAddr serverAddr;\n-    PRFileDesc *clientSock, *debug = NULL;\n-\n-    char* buffer = NULL;\n-    PRIOVec* iov = NULL;\n-    PRBool passed = PR_TRUE;\n-    PRIntervalTime timein, elapsed, timeout;\n-    PRIntervalTime tmo_min = 0x7fffffff, tmo_max = 0, tmo_elapsed = 0;\n-    PRInt32 tmo_counted = 0, iov_index, loop, bytes, number_fragments;\n-    PRInt32 message_length = 100, fragment_length = 100, messages = 100;\n-    struct Descriptor {\n-        PRInt32 length;\n-        PRUint32 checksum;\n-    } descriptor;\n-\n-    /*\n-     * USAGE\n-     * -h       dns name of host serving the connection (default = self)\n-     * -m       number of messages to send              (default = 100)\n-     * -s       size of each message                    (default = 100)\n-     * -f       size of each message fragment           (default = 100)\n-     */\n-\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dh:m:s:f:\");\n-\n-    rv = PR_InitializeNetAddr(PR_IpAddrLoopback, BASE_PORT, &serverAddr);\n-    PR_ASSERT(PR_SUCCESS == rv);\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'h': /* the remote host */\n-            {\n-                PRIntn es = 0;\n-                PRHostEnt host;\n-                char buffer[1024];\n-                (void)PR_GetHostByName(opt->value, buffer, sizeof(buffer), &host);\n-                es = PR_EnumerateHostEnt(es, &host, BASE_PORT, &serverAddr);\n-                PR_ASSERT(es > 0);\n-            } break;\n-            case 'd': /* debug mode */\n-                debug = PR_GetSpecialFD(PR_StandardError);\n-                break;\n-            case 'm': /* number of messages to send */\n-                messages = atoi(opt->value);\n-                break;\n-            case 's': /* total size of each message */\n-                message_length = atoi(opt->value);\n-                break;\n-            case 'f': /* size of each message fragment */\n-                fragment_length = atoi(opt->value);\n-                break;\n-            default:\n-                break;\n-        }\n+int PR_CALLBACK Writev(int argc, char** argv) {\n+  PRStatus rv;\n+  PRNetAddr serverAddr;\n+  PRFileDesc *clientSock, *debug = NULL;\n+\n+  char* buffer = NULL;\n+  PRIOVec* iov = NULL;\n+  PRBool passed = PR_TRUE;\n+  PRIntervalTime timein, elapsed, timeout;\n+  PRIntervalTime tmo_min = 0x7fffffff, tmo_max = 0, tmo_elapsed = 0;\n+  PRInt32 tmo_counted = 0, iov_index, loop, bytes, number_fragments;\n+  PRInt32 message_length = 100, fragment_length = 100, messages = 100;\n+  struct Descriptor {\n+    PRInt32 length;\n+    PRUint32 checksum;\n+  } descriptor;\n+\n+  /*\n+   * USAGE\n+   * -h       dns name of host serving the connection (default = self)\n+   * -m       number of messages to send              (default = 100)\n+   * -s       size of each message                    (default = 100)\n+   * -f       size of each message fragment           (default = 100)\n+   */\n+\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dh:m:s:f:\");\n+\n+  rv = PR_InitializeNetAddr(PR_IpAddrLoopback, BASE_PORT, &serverAddr);\n+  PR_ASSERT(PR_SUCCESS == rv);\n+\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'h': /* the remote host */\n+      {\n+        PRIntn es = 0;\n+        PRHostEnt host;\n+        char buffer[1024];\n+        (void)PR_GetHostByName(opt->value, buffer, sizeof(buffer), &host);\n+        es = PR_EnumerateHostEnt(es, &host, BASE_PORT, &serverAddr);\n+        PR_ASSERT(es > 0);\n+      } break;\n+      case 'd': /* debug mode */\n+        debug = PR_GetSpecialFD(PR_StandardError);\n+        break;\n+      case 'm': /* number of messages to send */\n+        messages = atoi(opt->value);\n+        break;\n+      case 's': /* total size of each message */\n+        message_length = atoi(opt->value);\n+        break;\n+      case 'f': /* size of each message fragment */\n+        fragment_length = atoi(opt->value);\n+        break;\n+      default:\n+        break;\n     }\n-    PL_DestroyOptState(opt);\n+  }\n+  PL_DestroyOptState(opt);\n \n-    buffer = (char*)malloc(message_length);\n+  buffer = (char*)malloc(message_length);\n \n+  number_fragments =\n+      (message_length + fragment_length - 1) / fragment_length + 1;\n+  while (IOV_MAX < number_fragments) {\n+    fragment_length = message_length / (IOV_MAX - 2);\n     number_fragments =\n         (message_length + fragment_length - 1) / fragment_length + 1;\n-    while (IOV_MAX < number_fragments) {\n-        fragment_length = message_length / (IOV_MAX - 2);\n-        number_fragments =\n-            (message_length + fragment_length - 1) / fragment_length + 1;\n-        if (NULL != debug)\n-            PR_fprintf(debug, \"Too many fragments - reset fragment length to %ld\\n\",\n-                       fragment_length);\n-    }\n-    iov = (PRIOVec*)malloc(number_fragments * sizeof(PRIOVec));\n-\n-    iov[0].iov_base = (char*)&descriptor;\n-    iov[0].iov_len = sizeof(descriptor);\n-    for (iov_index = 1; iov_index < number_fragments; ++iov_index) {\n-        iov[iov_index].iov_base = buffer + (iov_index - 1) * fragment_length;\n-        iov[iov_index].iov_len = fragment_length;\n-    }\n-\n-    for (bytes = 0; bytes < message_length; ++bytes) {\n-        buffer[bytes] = (char)bytes;\n+    if (NULL != debug)\n+      PR_fprintf(debug, \"Too many fragments - reset fragment length to %ld\\n\",\n+                 fragment_length);\n+  }\n+  iov = (PRIOVec*)malloc(number_fragments * sizeof(PRIOVec));\n+\n+  iov[0].iov_base = (char*)&descriptor;\n+  iov[0].iov_len = sizeof(descriptor);\n+  for (iov_index = 1; iov_index < number_fragments; ++iov_index) {\n+    iov[iov_index].iov_base = buffer + (iov_index - 1) * fragment_length;\n+    iov[iov_index].iov_len = fragment_length;\n+  }\n+\n+  for (bytes = 0; bytes < message_length; ++bytes) {\n+    buffer[bytes] = (char)bytes;\n+  }\n+\n+  timeout = PR_SecondsToInterval(1);\n+\n+  for (loop = 0; loop < messages; ++loop) {\n+    if (NULL != debug) {\n+      PR_fprintf(debug, \"[%d]socket ... \", loop);\n     }\n+    clientSock = PR_NewTCPSocket();\n+    if (clientSock) {\n+      timein = PR_IntervalNow();\n+      if (NULL != debug) {\n+        PR_fprintf(debug, \"connecting ... \");\n+      }\n+      rv = PR_Connect(clientSock, &serverAddr, timeout);\n+      if (PR_SUCCESS == rv) {\n+        descriptor.checksum = 0;\n+        descriptor.length = (loop < (messages - 1)) ? message_length : 0;\n+        if (0 == descriptor.length) {\n+          number_fragments = 1;\n+        } else\n+          for (iov_index = 0; iov_index < descriptor.length; ++iov_index) {\n+            PRUint32 overflow = descriptor.checksum & 0x80000000;\n+            descriptor.checksum = (descriptor.checksum << 1);\n+            if (0x00000000 != overflow) {\n+              descriptor.checksum += 1;\n+            }\n+            descriptor.checksum += buffer[iov_index];\n+          }\n+        if (NULL != debug)\n+          PR_fprintf(debug, \"sending %d bytes ... \", descriptor.length);\n \n-    timeout = PR_SecondsToInterval(1);\n+        /* then, at the last moment ... */\n+        descriptor.length = PR_ntohl(descriptor.length);\n+        descriptor.checksum = PR_ntohl(descriptor.checksum);\n \n-    for (loop = 0; loop < messages; ++loop) {\n+        bytes = PR_Writev(clientSock, iov, number_fragments, timeout);\n         if (NULL != debug) {\n-            PR_fprintf(debug, \"[%d]socket ... \", loop);\n+          PR_fprintf(debug, \"closing ... \");\n         }\n-        clientSock = PR_NewTCPSocket();\n-        if (clientSock) {\n-            timein = PR_IntervalNow();\n-            if (NULL != debug) {\n-                PR_fprintf(debug, \"connecting ... \");\n-            }\n-            rv = PR_Connect(clientSock, &serverAddr, timeout);\n-            if (PR_SUCCESS == rv) {\n-                descriptor.checksum = 0;\n-                descriptor.length = (loop < (messages - 1)) ? message_length : 0;\n-                if (0 == descriptor.length) {\n-                    number_fragments = 1;\n-                } else\n-                    for (iov_index = 0; iov_index < descriptor.length; ++iov_index) {\n-                        PRUint32 overflow = descriptor.checksum & 0x80000000;\n-                        descriptor.checksum = (descriptor.checksum << 1);\n-                        if (0x00000000 != overflow) {\n-                            descriptor.checksum += 1;\n-                        }\n-                        descriptor.checksum += buffer[iov_index];\n-                    }\n-                if (NULL != debug)\n-                    PR_fprintf(debug, \"sending %d bytes ... \", descriptor.length);\n-\n-                /* then, at the last moment ... */\n-                descriptor.length = PR_ntohl(descriptor.length);\n-                descriptor.checksum = PR_ntohl(descriptor.checksum);\n-\n-                bytes = PR_Writev(clientSock, iov, number_fragments, timeout);\n-                if (NULL != debug) {\n-                    PR_fprintf(debug, \"closing ... \");\n-                }\n-                rv = PR_Shutdown(clientSock, PR_SHUTDOWN_BOTH);\n-                rv = PR_Close(clientSock);\n-                if (NULL != debug)\n-                    PR_fprintf(debug, \"%s\\n\", ((PR_SUCCESS == rv) ? \"good\" : \"bad\"));\n-                elapsed = PR_IntervalNow() - timein;\n-                if (elapsed < tmo_min) {\n-                    tmo_min = elapsed;\n-                } else if (elapsed > tmo_max) {\n-                    tmo_max = elapsed;\n-                }\n-                tmo_elapsed += elapsed;\n-                tmo_counted += 1;\n-            } else {\n-                if (NULL != debug)\n-                    PR_fprintf(debug, \"failed - retrying (%d, %d)\\n\", PR_GetError(),\n-                               PR_GetOSError());\n-                PR_Close(clientSock);\n-            }\n-        } else if (NULL != debug) {\n-            PR_fprintf(debug, \"unable to create client socket\\n\");\n-            passed = PR_FALSE;\n+        rv = PR_Shutdown(clientSock, PR_SHUTDOWN_BOTH);\n+        rv = PR_Close(clientSock);\n+        if (NULL != debug)\n+          PR_fprintf(debug, \"%s\\n\", ((PR_SUCCESS == rv) ? \"good\" : \"bad\"));\n+        elapsed = PR_IntervalNow() - timein;\n+        if (elapsed < tmo_min) {\n+          tmo_min = elapsed;\n+        } else if (elapsed > tmo_max) {\n+          tmo_max = elapsed;\n         }\n+        tmo_elapsed += elapsed;\n+        tmo_counted += 1;\n+      } else {\n+        if (NULL != debug)\n+          PR_fprintf(debug, \"failed - retrying (%d, %d)\\n\", PR_GetError(),\n+                     PR_GetOSError());\n+        PR_Close(clientSock);\n+      }\n+    } else if (NULL != debug) {\n+      PR_fprintf(debug, \"unable to create client socket\\n\");\n+      passed = PR_FALSE;\n     }\n-    if (NULL != debug) {\n-        if (0 == tmo_counted) {\n-            PR_fprintf(debug, \"No connection made\\n\");\n-        } else {\n-            PR_fprintf(debug, \"\\nTimings: %d [%d] %d (microseconds)\\n\",\n-                       PR_IntervalToMicroseconds(tmo_min),\n-                       PR_IntervalToMicroseconds(tmo_elapsed / tmo_counted),\n-                       PR_IntervalToMicroseconds(tmo_max));\n-        }\n+  }\n+  if (NULL != debug) {\n+    if (0 == tmo_counted) {\n+      PR_fprintf(debug, \"No connection made\\n\");\n+    } else {\n+      PR_fprintf(debug, \"\\nTimings: %d [%d] %d (microseconds)\\n\",\n+                 PR_IntervalToMicroseconds(tmo_min),\n+                 PR_IntervalToMicroseconds(tmo_elapsed / tmo_counted),\n+                 PR_IntervalToMicroseconds(tmo_max));\n     }\n+  }\n \n-    PR_DELETE(buffer);\n-    PR_DELETE(iov);\n+  PR_DELETE(buffer);\n+  PR_DELETE(iov);\n \n-    PR_fprintf(PR_GetSpecialFD(PR_StandardError), \"%s\\n\",\n-               (passed) ? \"PASSED\" : \"FAILED\");\n-    return (passed) ? 0 : 1;\n+  PR_fprintf(PR_GetSpecialFD(PR_StandardError), \"%s\\n\",\n+             (passed) ? \"PASSED\" : \"FAILED\");\n+  return (passed) ? 0 : 1;\n }\n \n-int\n-main(int argc, char** argv)\n-{\n-    return (PR_VersionCheck(PR_VERSION)) ? PR_Initialize(Writev, argc, argv, 4)\n-                                         : -1;\n+int main(int argc, char** argv) {\n+  return (PR_VersionCheck(PR_VERSION)) ? PR_Initialize(Writev, argc, argv, 4)\n+                                       : -1;\n } /* main */\n \n /* writev.c */\ndiff --git a/nspr/pr/tests/xnotify.c b/nspr/pr/tests/xnotify.c\nindex 2097ac4..3a9f2b3 100644\n--- a/nspr/pr/tests/xnotify.c\n+++ b/nspr/pr/tests/xnotify.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -22,274 +23,254 @@ static PRIntervalTime base;\n static PRFileDesc* err = NULL;\n \n typedef struct CMonShared {\n-    PRInt32 o1, o2;\n+  PRInt32 o1, o2;\n } CMonShared;\n \n typedef struct MonShared {\n-    PRMonitor *o1, *o2;\n+  PRMonitor *o1, *o2;\n } MonShared;\n \n typedef struct LockShared {\n-    PRLock *o1, *o2;\n-    PRCondVar *cv1, *cv2;\n+  PRLock *o1, *o2;\n+  PRCondVar *cv1, *cv2;\n } LockShared;\n \n-static void\n-LogNow(const char* msg, PRStatus rv)\n-{\n-    PRIntervalTime now = PR_IntervalNow();\n-    PR_Lock(ml);\n-    PR_fprintf(err, \"%6ld: %s\", (now - base), msg);\n-    if (PR_FAILURE == rv) {\n-        PL_FPrintError(err, \" \");\n-    } else {\n-        PR_fprintf(err, \"\\n\");\n-    }\n-    PR_Unlock(ml);\n+static void LogNow(const char* msg, PRStatus rv) {\n+  PRIntervalTime now = PR_IntervalNow();\n+  PR_Lock(ml);\n+  PR_fprintf(err, \"%6ld: %s\", (now - base), msg);\n+  if (PR_FAILURE == rv) {\n+    PL_FPrintError(err, \" \");\n+  } else {\n+    PR_fprintf(err, \"\\n\");\n+  }\n+  PR_Unlock(ml);\n } /* LogNow */\n \n-static void\n-Help(void)\n-{\n-    PR_fprintf(err, \"Usage: [-[d][l][m][c]] [-h]\\n\");\n-    PR_fprintf(err, \"\\t-d   debug mode                  (default: FALSE)\\n\");\n-    PR_fprintf(err, \"\\t-l   test with locks             (default: FALSE)\\n\");\n-    PR_fprintf(err, \"\\t-m   tests with monitors         (default: FALSE)\\n\");\n-    PR_fprintf(err, \"\\t-c   tests with cmonitors        (default: FALSE)\\n\");\n-    PR_fprintf(err, \"\\t-h   help\\n\");\n+static void Help(void) {\n+  PR_fprintf(err, \"Usage: [-[d][l][m][c]] [-h]\\n\");\n+  PR_fprintf(err, \"\\t-d   debug mode                  (default: FALSE)\\n\");\n+  PR_fprintf(err, \"\\t-l   test with locks             (default: FALSE)\\n\");\n+  PR_fprintf(err, \"\\t-m   tests with monitors         (default: FALSE)\\n\");\n+  PR_fprintf(err, \"\\t-c   tests with cmonitors        (default: FALSE)\\n\");\n+  PR_fprintf(err, \"\\t-h   help\\n\");\n } /* Help */\n \n-static void PR_CALLBACK\n-T2CMon(void* arg)\n-{\n-    PRStatus rv;\n-    CMonShared* shared = (CMonShared*)arg;\n-\n-    PR_CEnterMonitor(&shared->o1);\n-    LogNow(\"T2 waiting 5 seconds on o1\", PR_SUCCESS);\n-    rv = PR_CWait(&shared->o1, PR_SecondsToInterval(5));\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T2 resuming on o1\", rv);\n-    } else {\n-        LogNow(\"T2 wait failed on o1\", rv);\n-    }\n-\n-    rv = PR_CNotify(&shared->o1);\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T2 notified o1\", rv);\n-    } else {\n-        LogNow(\"T2 notify on o1 failed\", rv);\n-    }\n-\n-    PR_CExitMonitor(&shared->o1);\n+static void PR_CALLBACK T2CMon(void* arg) {\n+  PRStatus rv;\n+  CMonShared* shared = (CMonShared*)arg;\n+\n+  PR_CEnterMonitor(&shared->o1);\n+  LogNow(\"T2 waiting 5 seconds on o1\", PR_SUCCESS);\n+  rv = PR_CWait(&shared->o1, PR_SecondsToInterval(5));\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T2 resuming on o1\", rv);\n+  } else {\n+    LogNow(\"T2 wait failed on o1\", rv);\n+  }\n+\n+  rv = PR_CNotify(&shared->o1);\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T2 notified o1\", rv);\n+  } else {\n+    LogNow(\"T2 notify on o1 failed\", rv);\n+  }\n+\n+  PR_CExitMonitor(&shared->o1);\n } /* T2CMon */\n \n-static void PR_CALLBACK\n-T3CMon(void* arg)\n-{\n-    PRStatus rv;\n-    CMonShared* shared = (CMonShared*)arg;\n-\n-    PR_CEnterMonitor(&shared->o2);\n-    LogNow(\"T3 waiting 5 seconds on o2\", PR_SUCCESS);\n-    rv = PR_CWait(&shared->o2, PR_SecondsToInterval(5));\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T3 resuming on o2\", rv);\n-    } else {\n-        LogNow(\"T3 wait failed on o2\", rv);\n-    }\n-    rv = PR_CNotify(&shared->o2);\n-    LogNow(\"T3 notify on o2\", rv);\n-    PR_CExitMonitor(&shared->o2);\n+static void PR_CALLBACK T3CMon(void* arg) {\n+  PRStatus rv;\n+  CMonShared* shared = (CMonShared*)arg;\n+\n+  PR_CEnterMonitor(&shared->o2);\n+  LogNow(\"T3 waiting 5 seconds on o2\", PR_SUCCESS);\n+  rv = PR_CWait(&shared->o2, PR_SecondsToInterval(5));\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T3 resuming on o2\", rv);\n+  } else {\n+    LogNow(\"T3 wait failed on o2\", rv);\n+  }\n+  rv = PR_CNotify(&shared->o2);\n+  LogNow(\"T3 notify on o2\", rv);\n+  PR_CExitMonitor(&shared->o2);\n \n } /* T3CMon */\n \n static CMonShared sharedCM;\n \n-static void\n-T1CMon(void)\n-{\n-    PRStatus rv;\n-    PRThread *t2, *t3;\n-\n-    PR_fprintf(err, \"\\n**********************************\\n\");\n-    PR_fprintf(err, \"         CACHED MONITORS\\n\");\n-    PR_fprintf(err, \"**********************************\\n\");\n-\n-    base = PR_IntervalNow();\n-\n-    PR_CEnterMonitor(&sharedCM.o1);\n-    LogNow(\"T1 waiting 3 seconds on o1\", PR_SUCCESS);\n-    rv = PR_CWait(&sharedCM.o1, PR_SecondsToInterval(3));\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T1 resuming on o1\", rv);\n-    } else {\n-        LogNow(\"T1 wait on o1 failed\", rv);\n-    }\n-    PR_CExitMonitor(&sharedCM.o1);\n-\n-    LogNow(\"T1 creating T2\", PR_SUCCESS);\n-    t2 = PR_CreateThread(PR_USER_THREAD, T2CMon, &sharedCM, PR_PRIORITY_NORMAL,\n-                         PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-\n-    LogNow(\"T1 creating T3\", PR_SUCCESS);\n-    t3 = PR_CreateThread(PR_USER_THREAD, T3CMon, &sharedCM, PR_PRIORITY_NORMAL,\n-                         PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-\n-    PR_CEnterMonitor(&sharedCM.o2);\n-    LogNow(\"T1 waiting forever on o2\", PR_SUCCESS);\n-    rv = PR_CWait(&sharedCM.o2, PR_INTERVAL_NO_TIMEOUT);\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T1 resuming on o2\", rv);\n-    } else {\n-        LogNow(\"T1 wait on o2 failed\", rv);\n-    }\n-    PR_CExitMonitor(&sharedCM.o2);\n-\n-    (void)PR_JoinThread(t2);\n-    (void)PR_JoinThread(t3);\n+static void T1CMon(void) {\n+  PRStatus rv;\n+  PRThread *t2, *t3;\n+\n+  PR_fprintf(err, \"\\n**********************************\\n\");\n+  PR_fprintf(err, \"         CACHED MONITORS\\n\");\n+  PR_fprintf(err, \"**********************************\\n\");\n+\n+  base = PR_IntervalNow();\n+\n+  PR_CEnterMonitor(&sharedCM.o1);\n+  LogNow(\"T1 waiting 3 seconds on o1\", PR_SUCCESS);\n+  rv = PR_CWait(&sharedCM.o1, PR_SecondsToInterval(3));\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T1 resuming on o1\", rv);\n+  } else {\n+    LogNow(\"T1 wait on o1 failed\", rv);\n+  }\n+  PR_CExitMonitor(&sharedCM.o1);\n+\n+  LogNow(\"T1 creating T2\", PR_SUCCESS);\n+  t2 = PR_CreateThread(PR_USER_THREAD, T2CMon, &sharedCM, PR_PRIORITY_NORMAL,\n+                       PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+\n+  LogNow(\"T1 creating T3\", PR_SUCCESS);\n+  t3 = PR_CreateThread(PR_USER_THREAD, T3CMon, &sharedCM, PR_PRIORITY_NORMAL,\n+                       PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+\n+  PR_CEnterMonitor(&sharedCM.o2);\n+  LogNow(\"T1 waiting forever on o2\", PR_SUCCESS);\n+  rv = PR_CWait(&sharedCM.o2, PR_INTERVAL_NO_TIMEOUT);\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T1 resuming on o2\", rv);\n+  } else {\n+    LogNow(\"T1 wait on o2 failed\", rv);\n+  }\n+  PR_CExitMonitor(&sharedCM.o2);\n+\n+  (void)PR_JoinThread(t2);\n+  (void)PR_JoinThread(t3);\n \n } /* T1CMon */\n \n-static void PR_CALLBACK\n-T2Mon(void* arg)\n-{\n-    PRStatus rv;\n-    MonShared* shared = (MonShared*)arg;\n-\n-    PR_EnterMonitor(shared->o1);\n-    LogNow(\"T2 waiting 5 seconds on o1\", PR_SUCCESS);\n-    rv = PR_Wait(shared->o1, PR_SecondsToInterval(5));\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T2 resuming on o1\", rv);\n-    } else {\n-        LogNow(\"T2 wait failed on o1\", rv);\n-    }\n-\n-    rv = PR_Notify(shared->o1);\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T2 notified o1\", rv);\n-    } else {\n-        LogNow(\"T2 notify on o1 failed\", rv);\n-    }\n-\n-    PR_ExitMonitor(shared->o1);\n+static void PR_CALLBACK T2Mon(void* arg) {\n+  PRStatus rv;\n+  MonShared* shared = (MonShared*)arg;\n+\n+  PR_EnterMonitor(shared->o1);\n+  LogNow(\"T2 waiting 5 seconds on o1\", PR_SUCCESS);\n+  rv = PR_Wait(shared->o1, PR_SecondsToInterval(5));\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T2 resuming on o1\", rv);\n+  } else {\n+    LogNow(\"T2 wait failed on o1\", rv);\n+  }\n+\n+  rv = PR_Notify(shared->o1);\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T2 notified o1\", rv);\n+  } else {\n+    LogNow(\"T2 notify on o1 failed\", rv);\n+  }\n+\n+  PR_ExitMonitor(shared->o1);\n } /* T2Mon */\n \n-static void PR_CALLBACK\n-T3Mon(void* arg)\n-{\n-    PRStatus rv;\n-    MonShared* shared = (MonShared*)arg;\n-\n-    PR_EnterMonitor(shared->o2);\n-    LogNow(\"T3 waiting 5 seconds on o2\", PR_SUCCESS);\n-    rv = PR_Wait(shared->o2, PR_SecondsToInterval(5));\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T3 resuming on o2\", rv);\n-    } else {\n-        LogNow(\"T3 wait failed on o2\", rv);\n-    }\n-    rv = PR_Notify(shared->o2);\n-    LogNow(\"T3 notify on o2\", rv);\n-    PR_ExitMonitor(shared->o2);\n+static void PR_CALLBACK T3Mon(void* arg) {\n+  PRStatus rv;\n+  MonShared* shared = (MonShared*)arg;\n+\n+  PR_EnterMonitor(shared->o2);\n+  LogNow(\"T3 waiting 5 seconds on o2\", PR_SUCCESS);\n+  rv = PR_Wait(shared->o2, PR_SecondsToInterval(5));\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T3 resuming on o2\", rv);\n+  } else {\n+    LogNow(\"T3 wait failed on o2\", rv);\n+  }\n+  rv = PR_Notify(shared->o2);\n+  LogNow(\"T3 notify on o2\", rv);\n+  PR_ExitMonitor(shared->o2);\n \n } /* T3Mon */\n \n static MonShared sharedM;\n-static void\n-T1Mon(void)\n-{\n-    PRStatus rv;\n-    PRThread *t2, *t3;\n-\n-    PR_fprintf(err, \"\\n**********************************\\n\");\n-    PR_fprintf(err, \"            MONITORS\\n\");\n-    PR_fprintf(err, \"**********************************\\n\");\n-\n-    sharedM.o1 = PR_NewMonitor();\n-    sharedM.o2 = PR_NewMonitor();\n-\n-    base = PR_IntervalNow();\n-\n-    PR_EnterMonitor(sharedM.o1);\n-    LogNow(\"T1 waiting 3 seconds on o1\", PR_SUCCESS);\n-    rv = PR_Wait(sharedM.o1, PR_SecondsToInterval(3));\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T1 resuming on o1\", rv);\n-    } else {\n-        LogNow(\"T1 wait on o1 failed\", rv);\n-    }\n-    PR_ExitMonitor(sharedM.o1);\n-\n-    LogNow(\"T1 creating T2\", PR_SUCCESS);\n-    t2 = PR_CreateThread(PR_USER_THREAD, T2Mon, &sharedM, PR_PRIORITY_NORMAL,\n-                         PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-\n-    LogNow(\"T1 creating T3\", PR_SUCCESS);\n-    t3 = PR_CreateThread(PR_USER_THREAD, T3Mon, &sharedM, PR_PRIORITY_NORMAL,\n-                         PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-\n-    PR_EnterMonitor(sharedM.o2);\n-    LogNow(\"T1 waiting forever on o2\", PR_SUCCESS);\n-    rv = PR_Wait(sharedM.o2, PR_INTERVAL_NO_TIMEOUT);\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T1 resuming on o2\", rv);\n-    } else {\n-        LogNow(\"T1 wait on o2 failed\", rv);\n-    }\n-    PR_ExitMonitor(sharedM.o2);\n-\n-    (void)PR_JoinThread(t2);\n-    (void)PR_JoinThread(t3);\n-\n-    PR_DestroyMonitor(sharedM.o1);\n-    PR_DestroyMonitor(sharedM.o2);\n+static void T1Mon(void) {\n+  PRStatus rv;\n+  PRThread *t2, *t3;\n+\n+  PR_fprintf(err, \"\\n**********************************\\n\");\n+  PR_fprintf(err, \"            MONITORS\\n\");\n+  PR_fprintf(err, \"**********************************\\n\");\n+\n+  sharedM.o1 = PR_NewMonitor();\n+  sharedM.o2 = PR_NewMonitor();\n+\n+  base = PR_IntervalNow();\n+\n+  PR_EnterMonitor(sharedM.o1);\n+  LogNow(\"T1 waiting 3 seconds on o1\", PR_SUCCESS);\n+  rv = PR_Wait(sharedM.o1, PR_SecondsToInterval(3));\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T1 resuming on o1\", rv);\n+  } else {\n+    LogNow(\"T1 wait on o1 failed\", rv);\n+  }\n+  PR_ExitMonitor(sharedM.o1);\n+\n+  LogNow(\"T1 creating T2\", PR_SUCCESS);\n+  t2 = PR_CreateThread(PR_USER_THREAD, T2Mon, &sharedM, PR_PRIORITY_NORMAL,\n+                       PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+\n+  LogNow(\"T1 creating T3\", PR_SUCCESS);\n+  t3 = PR_CreateThread(PR_USER_THREAD, T3Mon, &sharedM, PR_PRIORITY_NORMAL,\n+                       PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+\n+  PR_EnterMonitor(sharedM.o2);\n+  LogNow(\"T1 waiting forever on o2\", PR_SUCCESS);\n+  rv = PR_Wait(sharedM.o2, PR_INTERVAL_NO_TIMEOUT);\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T1 resuming on o2\", rv);\n+  } else {\n+    LogNow(\"T1 wait on o2 failed\", rv);\n+  }\n+  PR_ExitMonitor(sharedM.o2);\n+\n+  (void)PR_JoinThread(t2);\n+  (void)PR_JoinThread(t3);\n+\n+  PR_DestroyMonitor(sharedM.o1);\n+  PR_DestroyMonitor(sharedM.o2);\n \n } /* T1Mon */\n \n-static void PR_CALLBACK\n-T2Lock(void* arg)\n-{\n-    PRStatus rv;\n-    LockShared* shared = (LockShared*)arg;\n-\n-    PR_Lock(shared->o1);\n-    LogNow(\"T2 waiting 5 seconds on o1\", PR_SUCCESS);\n-    rv = PR_WaitCondVar(shared->cv1, PR_SecondsToInterval(5));\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T2 resuming on o1\", rv);\n-    } else {\n-        LogNow(\"T2 wait failed on o1\", rv);\n-    }\n-\n-    rv = PR_NotifyCondVar(shared->cv1);\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T2 notified o1\", rv);\n-    } else {\n-        LogNow(\"T2 notify on o1 failed\", rv);\n-    }\n-\n-    PR_Unlock(shared->o1);\n+static void PR_CALLBACK T2Lock(void* arg) {\n+  PRStatus rv;\n+  LockShared* shared = (LockShared*)arg;\n+\n+  PR_Lock(shared->o1);\n+  LogNow(\"T2 waiting 5 seconds on o1\", PR_SUCCESS);\n+  rv = PR_WaitCondVar(shared->cv1, PR_SecondsToInterval(5));\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T2 resuming on o1\", rv);\n+  } else {\n+    LogNow(\"T2 wait failed on o1\", rv);\n+  }\n+\n+  rv = PR_NotifyCondVar(shared->cv1);\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T2 notified o1\", rv);\n+  } else {\n+    LogNow(\"T2 notify on o1 failed\", rv);\n+  }\n+\n+  PR_Unlock(shared->o1);\n } /* T2Lock */\n \n-static void PR_CALLBACK\n-T3Lock(void* arg)\n-{\n-    PRStatus rv;\n-    LockShared* shared = (LockShared*)arg;\n-\n-    PR_Lock(shared->o2);\n-    LogNow(\"T3 waiting 5 seconds on o2\", PR_SUCCESS);\n-    rv = PR_WaitCondVar(shared->cv2, PR_SecondsToInterval(5));\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T3 resuming on o2\", rv);\n-    } else {\n-        LogNow(\"T3 wait failed on o2\", rv);\n-    }\n-    rv = PR_NotifyCondVar(shared->cv2);\n-    LogNow(\"T3 notify on o2\", rv);\n-    PR_Unlock(shared->o2);\n+static void PR_CALLBACK T3Lock(void* arg) {\n+  PRStatus rv;\n+  LockShared* shared = (LockShared*)arg;\n+\n+  PR_Lock(shared->o2);\n+  LogNow(\"T3 waiting 5 seconds on o2\", PR_SUCCESS);\n+  rv = PR_WaitCondVar(shared->cv2, PR_SecondsToInterval(5));\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T3 resuming on o2\", rv);\n+  } else {\n+    LogNow(\"T3 wait failed on o2\", rv);\n+  }\n+  rv = PR_NotifyCondVar(shared->cv2);\n+  LogNow(\"T3 notify on o2\", rv);\n+  PR_Unlock(shared->o2);\n \n } /* T3Lock */\n \n@@ -298,115 +279,109 @@ T3Lock(void* arg)\n */\n static LockShared sharedL;\n \n-static void\n-T1Lock(void)\n-{\n-    PRStatus rv;\n-    PRThread *t2, *t3;\n-    sharedL.o1 = PR_NewLock();\n-    sharedL.o2 = PR_NewLock();\n-    sharedL.cv1 = PR_NewCondVar(sharedL.o1);\n-    sharedL.cv2 = PR_NewCondVar(sharedL.o2);\n-\n-    PR_fprintf(err, \"\\n**********************************\\n\");\n-    PR_fprintf(err, \"             LOCKS\\n\");\n-    PR_fprintf(err, \"**********************************\\n\");\n-\n-    base = PR_IntervalNow();\n-\n-    PR_Lock(sharedL.o1);\n-    LogNow(\"T1 waiting 3 seconds on o1\", PR_SUCCESS);\n-    rv = PR_WaitCondVar(sharedL.cv1, PR_SecondsToInterval(3));\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T1 resuming on o1\", rv);\n-    } else {\n-        LogNow(\"T1 wait on o1 failed\", rv);\n-    }\n-    PR_Unlock(sharedL.o1);\n-\n-    LogNow(\"T1 creating T2\", PR_SUCCESS);\n-    t2 = PR_CreateThread(PR_USER_THREAD, T2Lock, &sharedL, PR_PRIORITY_NORMAL,\n-                         PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-\n-    LogNow(\"T1 creating T3\", PR_SUCCESS);\n-    t3 = PR_CreateThread(PR_USER_THREAD, T3Lock, &sharedL, PR_PRIORITY_NORMAL,\n-                         PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n-\n-    PR_Lock(sharedL.o2);\n-    LogNow(\"T1 waiting forever on o2\", PR_SUCCESS);\n-    rv = PR_WaitCondVar(sharedL.cv2, PR_INTERVAL_NO_TIMEOUT);\n-    if (PR_SUCCESS == rv) {\n-        LogNow(\"T1 resuming on o2\", rv);\n-    } else {\n-        LogNow(\"T1 wait on o2 failed\", rv);\n-    }\n-    PR_Unlock(sharedL.o2);\n-\n-    (void)PR_JoinThread(t2);\n-    (void)PR_JoinThread(t3);\n-\n-    PR_DestroyLock(sharedL.o1);\n-    PR_DestroyLock(sharedL.o2);\n-    PR_DestroyCondVar(sharedL.cv1);\n-    PR_DestroyCondVar(sharedL.cv2);\n+static void T1Lock(void) {\n+  PRStatus rv;\n+  PRThread *t2, *t3;\n+  sharedL.o1 = PR_NewLock();\n+  sharedL.o2 = PR_NewLock();\n+  sharedL.cv1 = PR_NewCondVar(sharedL.o1);\n+  sharedL.cv2 = PR_NewCondVar(sharedL.o2);\n+\n+  PR_fprintf(err, \"\\n**********************************\\n\");\n+  PR_fprintf(err, \"             LOCKS\\n\");\n+  PR_fprintf(err, \"**********************************\\n\");\n+\n+  base = PR_IntervalNow();\n+\n+  PR_Lock(sharedL.o1);\n+  LogNow(\"T1 waiting 3 seconds on o1\", PR_SUCCESS);\n+  rv = PR_WaitCondVar(sharedL.cv1, PR_SecondsToInterval(3));\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T1 resuming on o1\", rv);\n+  } else {\n+    LogNow(\"T1 wait on o1 failed\", rv);\n+  }\n+  PR_Unlock(sharedL.o1);\n+\n+  LogNow(\"T1 creating T2\", PR_SUCCESS);\n+  t2 = PR_CreateThread(PR_USER_THREAD, T2Lock, &sharedL, PR_PRIORITY_NORMAL,\n+                       PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+\n+  LogNow(\"T1 creating T3\", PR_SUCCESS);\n+  t3 = PR_CreateThread(PR_USER_THREAD, T3Lock, &sharedL, PR_PRIORITY_NORMAL,\n+                       PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);\n+\n+  PR_Lock(sharedL.o2);\n+  LogNow(\"T1 waiting forever on o2\", PR_SUCCESS);\n+  rv = PR_WaitCondVar(sharedL.cv2, PR_INTERVAL_NO_TIMEOUT);\n+  if (PR_SUCCESS == rv) {\n+    LogNow(\"T1 resuming on o2\", rv);\n+  } else {\n+    LogNow(\"T1 wait on o2 failed\", rv);\n+  }\n+  PR_Unlock(sharedL.o2);\n+\n+  (void)PR_JoinThread(t2);\n+  (void)PR_JoinThread(t3);\n+\n+  PR_DestroyLock(sharedL.o1);\n+  PR_DestroyLock(sharedL.o2);\n+  PR_DestroyCondVar(sharedL.cv1);\n+  PR_DestroyCondVar(sharedL.cv2);\n } /* T1Lock */\n \n-static PRIntn PR_CALLBACK\n-RealMain(PRIntn argc, char** argv)\n-{\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dhlmc\");\n-    PRBool locks = PR_FALSE, monitors = PR_FALSE, cmonitors = PR_FALSE;\n-\n-    err = PR_GetSpecialFD(PR_StandardError);\n-\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode (noop) */\n-                break;\n-            case 'l': /* locks */\n-                locks = PR_TRUE;\n-                break;\n-            case 'm': /* monitors */\n-                monitors = PR_TRUE;\n-                break;\n-            case 'c': /* cached monitors */\n-                cmonitors = PR_TRUE;\n-                break;\n-            case 'h': /* needs guidance */\n-            default:\n-                Help();\n-                return 2;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n+static PRIntn PR_CALLBACK RealMain(PRIntn argc, char** argv) {\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dhlmc\");\n+  PRBool locks = PR_FALSE, monitors = PR_FALSE, cmonitors = PR_FALSE;\n \n-    ml = PR_NewLock();\n-    if (locks) {\n-        T1Lock();\n-    }\n-    if (monitors) {\n-        T1Mon();\n+  err = PR_GetSpecialFD(PR_StandardError);\n+\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n     }\n-    if (cmonitors) {\n-        T1CMon();\n+    switch (opt->option) {\n+      case 'd': /* debug mode (noop) */\n+        break;\n+      case 'l': /* locks */\n+        locks = PR_TRUE;\n+        break;\n+      case 'm': /* monitors */\n+        monitors = PR_TRUE;\n+        break;\n+      case 'c': /* cached monitors */\n+        cmonitors = PR_TRUE;\n+        break;\n+      case 'h': /* needs guidance */\n+      default:\n+        Help();\n+        return 2;\n     }\n-\n-    PR_DestroyLock(ml);\n-\n-    PR_fprintf(err, \"Done!\\n\");\n-    return 0;\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  ml = PR_NewLock();\n+  if (locks) {\n+    T1Lock();\n+  }\n+  if (monitors) {\n+    T1Mon();\n+  }\n+  if (cmonitors) {\n+    T1CMon();\n+  }\n+\n+  PR_DestroyLock(ml);\n+\n+  PR_fprintf(err, \"Done!\\n\");\n+  return 0;\n } /* main */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRIntn rv;\n+int main(int argc, char** argv) {\n+  PRIntn rv;\n \n-    rv = PR_Initialize(RealMain, argc, argv, 0);\n-    return rv;\n+  rv = PR_Initialize(RealMain, argc, argv, 0);\n+  return rv;\n } /* main */\n /* xnotify.c */\ndiff --git a/nspr/pr/tests/y2k.c b/nspr/pr/tests/y2k.c\nindex 41e91a7..cb83f27 100644\n--- a/nspr/pr/tests/y2k.c\n+++ b/nspr/pr/tests/y2k.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -28,64 +29,60 @@\n int failed_already = 0;\n PRBool debug_mode = PR_FALSE;\n \n-static char* dayOfWeek[] = { \"Sun\", \"Mon\", \"Tue\", \"Wed\",\n-                             \"Thu\", \"Fri\", \"Sat\", \"???\" };\n-static char* month[] = { \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\",\n-                         \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\", \"???\" };\n+static char* dayOfWeek[] = {\"Sun\", \"Mon\", \"Tue\", \"Wed\",\n+                            \"Thu\", \"Fri\", \"Sat\", \"???\"};\n+static char* month[] = {\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\",\n+                        \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\", \"???\"};\n \n PRLogModuleInfo* lm;\n \n-static void\n-PrintExplodedTime(const PRExplodedTime* et)\n-{\n-    PRInt32 totalOffset;\n-    PRInt32 hourOffset, minOffset;\n-    const char* sign;\n-\n-    /* Print day of the week, month, day, hour, minute, and second */\n-    printf(\"%s %s %2ld %02ld:%02ld:%02ld \", dayOfWeek[et->tm_wday],\n-           month[et->tm_month], et->tm_mday, et->tm_hour, et->tm_min, et->tm_sec);\n-\n-    /* Print year */\n-    printf(\"%hd \", et->tm_year);\n-\n-    /* Print time zone */\n-    totalOffset = et->tm_params.tp_gmt_offset + et->tm_params.tp_dst_offset;\n-    if (totalOffset == 0) {\n-        printf(\"UTC \");\n-    } else {\n-        sign = \"+\";\n-        if (totalOffset < 0) {\n-            totalOffset = -totalOffset;\n-            sign = \"-\";\n-        }\n-        hourOffset = totalOffset / 3600;\n-        minOffset = (totalOffset % 3600) / 60;\n-        printf(\"%s%02ld%02ld \", sign, hourOffset, minOffset);\n+static void PrintExplodedTime(const PRExplodedTime* et) {\n+  PRInt32 totalOffset;\n+  PRInt32 hourOffset, minOffset;\n+  const char* sign;\n+\n+  /* Print day of the week, month, day, hour, minute, and second */\n+  printf(\"%s %s %2ld %02ld:%02ld:%02ld \", dayOfWeek[et->tm_wday],\n+         month[et->tm_month], et->tm_mday, et->tm_hour, et->tm_min, et->tm_sec);\n+\n+  /* Print year */\n+  printf(\"%hd \", et->tm_year);\n+\n+  /* Print time zone */\n+  totalOffset = et->tm_params.tp_gmt_offset + et->tm_params.tp_dst_offset;\n+  if (totalOffset == 0) {\n+    printf(\"UTC \");\n+  } else {\n+    sign = \"+\";\n+    if (totalOffset < 0) {\n+      totalOffset = -totalOffset;\n+      sign = \"-\";\n     }\n+    hourOffset = totalOffset / 3600;\n+    minOffset = (totalOffset % 3600) / 60;\n+    printf(\"%s%02ld%02ld \", sign, hourOffset, minOffset);\n+  }\n #ifdef PRINT_DETAILS\n-    printf(\"{%d, %d, %d, %d, %d, %d, %d, %d, %d, { %d, %d}}\\n\", et->tm_usec,\n-           et->tm_sec, et->tm_min, et->tm_hour, et->tm_mday, et->tm_month,\n-           et->tm_year, et->tm_wday, et->tm_yday, et->tm_params.tp_gmt_offset,\n-           et->tm_params.tp_dst_offset);\n+  printf(\"{%d, %d, %d, %d, %d, %d, %d, %d, %d, { %d, %d}}\\n\", et->tm_usec,\n+         et->tm_sec, et->tm_min, et->tm_hour, et->tm_mday, et->tm_month,\n+         et->tm_year, et->tm_wday, et->tm_yday, et->tm_params.tp_gmt_offset,\n+         et->tm_params.tp_dst_offset);\n #endif\n }\n \n-static int\n-ExplodedTimeIsEqual(const PRExplodedTime* et1,\n-                    const PRExplodedTime* et2)\n-{\n-    if (et1->tm_usec == et2->tm_usec && et1->tm_sec == et2->tm_sec &&\n-        et1->tm_min == et2->tm_min && et1->tm_hour == et2->tm_hour &&\n-        et1->tm_mday == et2->tm_mday && et1->tm_month == et2->tm_month &&\n-        et1->tm_year == et2->tm_year && et1->tm_wday == et2->tm_wday &&\n-        et1->tm_yday == et2->tm_yday &&\n-        et1->tm_params.tp_gmt_offset == et2->tm_params.tp_gmt_offset &&\n-        et1->tm_params.tp_dst_offset == et2->tm_params.tp_dst_offset) {\n-        return 1;\n-    } else {\n-        return 0;\n-    }\n+static int ExplodedTimeIsEqual(const PRExplodedTime* et1,\n+                               const PRExplodedTime* et2) {\n+  if (et1->tm_usec == et2->tm_usec && et1->tm_sec == et2->tm_sec &&\n+      et1->tm_min == et2->tm_min && et1->tm_hour == et2->tm_hour &&\n+      et1->tm_mday == et2->tm_mday && et1->tm_month == et2->tm_month &&\n+      et1->tm_year == et2->tm_year && et1->tm_wday == et2->tm_wday &&\n+      et1->tm_yday == et2->tm_yday &&\n+      et1->tm_params.tp_gmt_offset == et2->tm_params.tp_gmt_offset &&\n+      et1->tm_params.tp_dst_offset == et2->tm_params.tp_dst_offset) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n }\n \n /*\n@@ -138,37 +135,37 @@ static PRTime prt[] = {\n };\n \n static PRExplodedTime gmt[] = {\n-    { 0, 0, 0, 10, 31, 11, 1999, 5, 364, { 0, 0 } }, /* 1999/12/31 10:00:00 GMT */\n-    { 0, 0, 0, 10, 1, 0, 2000, 6, 0, { 0, 0 } },     /* 2000/01/01 10:00:00 GMT */\n-    { 0, 0, 0, 10, 29, 1, 2000, 2, 59, { 0, 0 } },   /* 2000/02/29 10:00:00 GMT */\n-    { 0, 0, 0, 10, 1, 2, 2001, 4, 59, { 0, 0 } },    /* 2001/3/1 10:00:00 GMT */\n-    { 0, 0, 0, 10, 1, 2, 2005, 2, 59, { 0, 0 } },    /* 2005/3/1 10:00:00 GMT */\n-    { 0, 0, 0, 10, 9, 8, 1999, 4, 251, { 0, 0 } },   /* 1999/9/9 10:00:00 GMT */\n+    {0, 0, 0, 10, 31, 11, 1999, 5, 364, {0, 0}}, /* 1999/12/31 10:00:00 GMT */\n+    {0, 0, 0, 10, 1, 0, 2000, 6, 0, {0, 0}},     /* 2000/01/01 10:00:00 GMT */\n+    {0, 0, 0, 10, 29, 1, 2000, 2, 59, {0, 0}},   /* 2000/02/29 10:00:00 GMT */\n+    {0, 0, 0, 10, 1, 2, 2001, 4, 59, {0, 0}},    /* 2001/3/1 10:00:00 GMT */\n+    {0, 0, 0, 10, 1, 2, 2005, 2, 59, {0, 0}},    /* 2005/3/1 10:00:00 GMT */\n+    {0, 0, 0, 10, 9, 8, 1999, 4, 251, {0, 0}},   /* 1999/9/9 10:00:00 GMT */\n     /* Sun's dates follow */\n-    { 0, 0, 0, 10, 31, 11, 1998, 4, 364, { 0, 0 } }, /* 12/31/1998 10:00:00 GMT */\n-    { 0, 0, 0, 10, 10, 8, 1999, 5, 252, { 0, 0 } },  /* 9/10/1999 10:00:00 GMT */\n-    { 0, 0, 0, 10, 28, 1, 2000, 1, 58, { 0, 0 } },   /* 2/28/2000 10:00:00 GMT */\n-    { 0, 0, 0, 10, 31, 11, 2000, 0, 365, { 0, 0 } }, /* 12/31/2000 10:00:00 GMT */\n-    { 0, 0, 0, 10, 1, 0, 2001, 1, 0, { 0, 0 } }      /* 1/1/2001 10:00:00 GMT */\n+    {0, 0, 0, 10, 31, 11, 1998, 4, 364, {0, 0}}, /* 12/31/1998 10:00:00 GMT */\n+    {0, 0, 0, 10, 10, 8, 1999, 5, 252, {0, 0}},  /* 9/10/1999 10:00:00 GMT */\n+    {0, 0, 0, 10, 28, 1, 2000, 1, 58, {0, 0}},   /* 2/28/2000 10:00:00 GMT */\n+    {0, 0, 0, 10, 31, 11, 2000, 0, 365, {0, 0}}, /* 12/31/2000 10:00:00 GMT */\n+    {0, 0, 0, 10, 1, 0, 2001, 1, 0, {0, 0}}      /* 1/1/2001 10:00:00 GMT */\n };\n \n static PRExplodedTime uspt[] = {\n-    { 0, 0, 0, 2, 31, 11, 1999, 5, 364, { -28800, 0 } },  /* 1999/12/31 2:00:00 PST\n-                                                           */\n-    { 0, 0, 0, 2, 1, 0, 2000, 6, 0, { -28800, 0 } },      /* 2000/01/01 2:00:00 PST */\n-    { 0, 0, 0, 2, 29, 1, 2000, 2, 59, { -28800, 0 } },    /* 2000/02/29 2:00:00 PST */\n-    { 0, 0, 0, 2, 1, 2, 2001, 4, 59, { -28800, 0 } },     /* 2001/3/1 2:00:00 PST */\n-    { 0, 0, 0, 2, 1, 2, 2005, 2, 59, { -28800, 0 } },     /* 2005/3/1 2:00:00 PST */\n-    { 0, 0, 0, 3, 9, 8, 1999, 4, 251, { -28800, 3600 } }, /* 1999/9/9 3:00:00 PDT */\n+    {0, 0, 0, 2, 31, 11, 1999, 5, 364, {-28800, 0}}, /* 1999/12/31 2:00:00 PST\n+                                                      */\n+    {0, 0, 0, 2, 1, 0, 2000, 6, 0, {-28800, 0}},   /* 2000/01/01 2:00:00 PST */\n+    {0, 0, 0, 2, 29, 1, 2000, 2, 59, {-28800, 0}}, /* 2000/02/29 2:00:00 PST */\n+    {0, 0, 0, 2, 1, 2, 2001, 4, 59, {-28800, 0}},  /* 2001/3/1 2:00:00 PST */\n+    {0, 0, 0, 2, 1, 2, 2005, 2, 59, {-28800, 0}},  /* 2005/3/1 2:00:00 PST */\n+    {0, 0, 0, 3, 9, 8, 1999, 4, 251, {-28800, 3600}}, /* 1999/9/9 3:00:00 PDT */\n     /* Sun's dates follow */\n-    { 0, 0, 0, 2, 31, 11, 1998, 4, 364, { -28800, 0 } },   /* 12/31/1998 00:00:00 GMT\n-                                                            */\n-    { 0, 0, 0, 3, 10, 8, 1999, 5, 252, { -28800, 3600 } }, /* 9/10/1999 00:00:00 GMT\n-                                                            */\n-    { 0, 0, 0, 2, 28, 1, 2000, 1, 58, { -28800, 0 } },     /* 2/28/2000 00:00:00 GMT */\n-    { 0, 0, 0, 2, 31, 11, 2000, 0, 365, { -28800, 0 } },   /* 12/31/2000 00:00:00 GMT\n-                                                            */\n-    { 0, 0, 0, 2, 1, 0, 2001, 1, 0, { -28800, 0 } }        /* 1/1/2001 00:00:00 GMT */\n+    {0, 0, 0, 2, 31, 11, 1998, 4, 364, {-28800, 0}}, /* 12/31/1998 00:00:00 GMT\n+                                                      */\n+    {0, 0, 0, 3, 10, 8, 1999, 5, 252, {-28800, 3600}}, /* 9/10/1999 00:00:00 GMT\n+                                                        */\n+    {0, 0, 0, 2, 28, 1, 2000, 1, 58, {-28800, 0}}, /* 2/28/2000 00:00:00 GMT */\n+    {0, 0, 0, 2, 31, 11, 2000, 0, 365, {-28800, 0}}, /* 12/31/2000 00:00:00 GMT\n+                                                      */\n+    {0, 0, 0, 2, 1, 0, 2001, 1, 0, {-28800, 0}}      /* 1/1/2001 00:00:00 GMT */\n };\n \n /*\n@@ -179,149 +176,147 @@ static PRExplodedTime uspt[] = {\n  * Zone is provided as an example.\n  */\n static PRExplodedTime localt[] = {\n-    { 0, 0, 0, 2, 31, 11, 1999, 5, 364, { -28800, 0 } },  /* 1999/12/31 2:00:00 PST\n-                                                           */\n-    { 0, 0, 0, 2, 1, 0, 2000, 6, 0, { -28800, 0 } },      /* 2000/01/01 2:00:00 PST */\n-    { 0, 0, 0, 2, 29, 1, 2000, 2, 59, { -28800, 0 } },    /* 2000/02/29 2:00:00 PST */\n-    { 0, 0, 0, 2, 1, 2, 2001, 4, 59, { -28800, 0 } },     /* 2001/3/1 2:00:00 PST */\n-    { 0, 0, 0, 2, 1, 2, 2005, 2, 59, { -28800, 0 } },     /* 2005/3/1 2:00:00 PST */\n-    { 0, 0, 0, 3, 9, 8, 1999, 4, 251, { -28800, 3600 } }, /* 1999/9/9 3:00:00 PDT */\n+    {0, 0, 0, 2, 31, 11, 1999, 5, 364, {-28800, 0}}, /* 1999/12/31 2:00:00 PST\n+                                                      */\n+    {0, 0, 0, 2, 1, 0, 2000, 6, 0, {-28800, 0}},   /* 2000/01/01 2:00:00 PST */\n+    {0, 0, 0, 2, 29, 1, 2000, 2, 59, {-28800, 0}}, /* 2000/02/29 2:00:00 PST */\n+    {0, 0, 0, 2, 1, 2, 2001, 4, 59, {-28800, 0}},  /* 2001/3/1 2:00:00 PST */\n+    {0, 0, 0, 2, 1, 2, 2005, 2, 59, {-28800, 0}},  /* 2005/3/1 2:00:00 PST */\n+    {0, 0, 0, 3, 9, 8, 1999, 4, 251, {-28800, 3600}}, /* 1999/9/9 3:00:00 PDT */\n     /* Sun's dates follow */\n-    { 0, 0, 0, 2, 31, 11, 1998, 4, 364, { -28800, 0 } },   /* 12/31/1998 00:00:00 GMT\n-                                                            */\n-    { 0, 0, 0, 3, 10, 8, 1999, 5, 252, { -28800, 3600 } }, /* 9/10/1999 00:00:00 GMT\n-                                                            */\n-    { 0, 0, 0, 2, 28, 1, 2000, 1, 58, { -28800, 0 } },     /* 2/28/2000 00:00:00 GMT */\n-    { 0, 0, 0, 2, 31, 11, 2000, 0, 365, { -28800, 0 } },   /* 12/31/2000 00:00:00 GMT\n-                                                            */\n-    { 0, 0, 0, 2, 1, 0, 2001, 1, 0, { -28800, 0 } }        /* 1/1/2001 00:00:00 GMT */\n+    {0, 0, 0, 2, 31, 11, 1998, 4, 364, {-28800, 0}}, /* 12/31/1998 00:00:00 GMT\n+                                                      */\n+    {0, 0, 0, 3, 10, 8, 1999, 5, 252, {-28800, 3600}}, /* 9/10/1999 00:00:00 GMT\n+                                                        */\n+    {0, 0, 0, 2, 28, 1, 2000, 1, 58, {-28800, 0}}, /* 2/28/2000 00:00:00 GMT */\n+    {0, 0, 0, 2, 31, 11, 2000, 0, 365, {-28800, 0}}, /* 12/31/2000 00:00:00 GMT\n+                                                      */\n+    {0, 0, 0, 2, 1, 0, 2001, 1, 0, {-28800, 0}}      /* 1/1/2001 00:00:00 GMT */\n };\n \n #ifdef US_EASTERN_TIME\n static PRExplodedTime localt[] = {\n-    { 0, 0, 0, 5, 31, 11, 1999, 5, 364, { -18000, 0 } },  /* 1999/12/31 2:00:00 EST\n-                                                           */\n-    { 0, 0, 0, 5, 1, 0, 2000, 6, 0, { -18000, 0 } },      /* 2000/01/01 2:00:00 EST */\n-    { 0, 0, 0, 5, 29, 1, 2000, 2, 59, { -18000, 0 } },    /* 2000/02/29 2:00:00 EST */\n-    { 0, 0, 0, 5, 1, 2, 2001, 4, 59, { -18000, 0 } },     /* 2001/3/1 2:00:00 EST */\n-    { 0, 0, 0, 5, 1, 2, 2005, 2, 59, { -18000, 0 } },     /* 2005/3/1 2:00:00 EST */\n-    { 0, 0, 0, 6, 9, 8, 1999, 4, 251, { -18000, 3600 } }, /* 1999/9/9 3:00:00 EDT */\n+    {0, 0, 0, 5, 31, 11, 1999, 5, 364, {-18000, 0}}, /* 1999/12/31 2:00:00 EST\n+                                                      */\n+    {0, 0, 0, 5, 1, 0, 2000, 6, 0, {-18000, 0}},   /* 2000/01/01 2:00:00 EST */\n+    {0, 0, 0, 5, 29, 1, 2000, 2, 59, {-18000, 0}}, /* 2000/02/29 2:00:00 EST */\n+    {0, 0, 0, 5, 1, 2, 2001, 4, 59, {-18000, 0}},  /* 2001/3/1 2:00:00 EST */\n+    {0, 0, 0, 5, 1, 2, 2005, 2, 59, {-18000, 0}},  /* 2005/3/1 2:00:00 EST */\n+    {0, 0, 0, 6, 9, 8, 1999, 4, 251, {-18000, 3600}}, /* 1999/9/9 3:00:00 EDT */\n     /* Sun's dates follow */\n-    { 0, 0, 0, 5, 31, 11, 1998, 4, 364, { -18000 0 } },   /* 12/31/1998 00:00:00 GMT\n-                                                           */\n-    { 0, 0, 0, 6, 10, 8, 1999, 5, 252, { -18000 3600 } }, /* 9/10/1999 00:00:00 GMT\n-                                                           */\n-    { 0, 0, 0, 5, 28, 1, 2000, 1, 58, { -18000 0 } },     /* 2/28/2000 00:00:00 GMT */\n-    { 0, 0, 0, 5, 31, 11, 2000, 0, 365, { -18000 0 } },   /* 12/31/2000 00:00:00 GMT\n-                                                           */\n-    { 0, 0, 0, 5, 1, 0, 2001, 1, 0, { -18000 0 } }        /* 1/1/2001 00:00:00 GMT */\n+    {0, 0, 0, 5, 31, 11, 1998, 4, 364, {-18000 0}},   /* 12/31/1998 00:00:00 GMT\n+                                                       */\n+    {0, 0, 0, 6, 10, 8, 1999, 5, 252, {-18000 3600}}, /* 9/10/1999 00:00:00 GMT\n+                                                       */\n+    {0, 0, 0, 5, 28, 1, 2000, 1, 58, {-18000 0}},   /* 2/28/2000 00:00:00 GMT */\n+    {0, 0, 0, 5, 31, 11, 2000, 0, 365, {-18000 0}}, /* 12/31/2000 00:00:00 GMT\n+                                                     */\n+    {0, 0, 0, 5, 1, 0, 2001, 1, 0, {-18000 0}}      /* 1/1/2001 00:00:00 GMT */\n };\n #endif\n \n-static PRStatus\n-TestExplodeImplodeTime(void)\n-{\n-    PRTime prt_tmp;\n-    PRTime now;\n-    int idx;\n-    int array_size = sizeof(prt) / sizeof(PRTime);\n-    PRExplodedTime et_tmp;\n-    char buf[1024];\n-\n-    for (idx = 0; idx < array_size; idx++) {\n-        PR_snprintf(buf, sizeof(buf), \"%lld\", prt[idx]);\n-        if (debug_mode) {\n-            printf(\"Time stamp %s\\n\", buf);\n-        }\n-        PR_ExplodeTime(prt[idx], PR_GMTParameters, &et_tmp);\n-        if (!ExplodedTimeIsEqual(&et_tmp, &gmt[idx])) {\n-            fprintf(stderr, \"GMT not equal\\n\");\n-            PrintExplodedTime(&et_tmp);\n-            PrintExplodedTime(&gmt[idx]);\n-            exit(1);\n-        }\n-        prt_tmp = PR_ImplodeTime(&et_tmp);\n-        if (LL_NE(prt_tmp, prt[idx])) {\n-            fprintf(stderr, \"PRTime not equal\\n\");\n-            exit(1);\n-        }\n-        if (debug_mode) {\n-            printf(\"GMT: \");\n-            PrintExplodedTime(&et_tmp);\n-            printf(\"\\n\");\n-        }\n+static PRStatus TestExplodeImplodeTime(void) {\n+  PRTime prt_tmp;\n+  PRTime now;\n+  int idx;\n+  int array_size = sizeof(prt) / sizeof(PRTime);\n+  PRExplodedTime et_tmp;\n+  char buf[1024];\n \n-        PR_ExplodeTime(prt[idx], PR_USPacificTimeParameters, &et_tmp);\n-        if (!ExplodedTimeIsEqual(&et_tmp, &uspt[idx])) {\n-            fprintf(stderr, \"US Pacific Time not equal\\n\");\n-            PrintExplodedTime(&et_tmp);\n-            PrintExplodedTime(&uspt[idx]);\n-            exit(1);\n-        }\n-        prt_tmp = PR_ImplodeTime(&et_tmp);\n-        if (LL_NE(prt_tmp, prt[idx])) {\n-            fprintf(stderr, \"PRTime not equal\\n\");\n-            exit(1);\n-        }\n-        if (debug_mode) {\n-            printf(\"US Pacific Time: \");\n-            PrintExplodedTime(&et_tmp);\n-            printf(\"\\n\");\n-        }\n-\n-        PR_ExplodeTime(prt[idx], PR_LocalTimeParameters, &et_tmp);\n-        if (!ExplodedTimeIsEqual(&et_tmp, &localt[idx])) {\n-            fprintf(stderr, \"not equal\\n\");\n-            PrintExplodedTime(&et_tmp);\n-            PrintExplodedTime(&localt[idx]);\n-            exit(1);\n-        }\n-        prt_tmp = PR_ImplodeTime(&et_tmp);\n-        if (LL_NE(prt_tmp, prt[idx])) {\n-            fprintf(stderr, \"not equal\\n\");\n-            exit(1);\n-        }\n-        if (debug_mode) {\n-            printf(\"Local time:\");\n-            PrintExplodedTime(&et_tmp);\n-            printf(\"\\n\\n\");\n-        }\n+  for (idx = 0; idx < array_size; idx++) {\n+    PR_snprintf(buf, sizeof(buf), \"%lld\", prt[idx]);\n+    if (debug_mode) {\n+      printf(\"Time stamp %s\\n\", buf);\n     }\n-\n-    now = PR_Now();\n-    PR_ExplodeTime(now, PR_GMTParameters, &et_tmp);\n-    printf(\"Current GMT is \");\n-    PrintExplodedTime(&et_tmp);\n-    printf(\"\\n\");\n-    prt_tmp = PR_ImplodeTime(&et_tmp);\n-    if (LL_NE(prt_tmp, now)) {\n-        fprintf(stderr, \"not equal\\n\");\n-        exit(1);\n+    PR_ExplodeTime(prt[idx], PR_GMTParameters, &et_tmp);\n+    if (!ExplodedTimeIsEqual(&et_tmp, &gmt[idx])) {\n+      fprintf(stderr, \"GMT not equal\\n\");\n+      PrintExplodedTime(&et_tmp);\n+      PrintExplodedTime(&gmt[idx]);\n+      exit(1);\n     }\n-    PR_ExplodeTime(now, PR_USPacificTimeParameters, &et_tmp);\n-    printf(\"Current US Pacific Time is \");\n-    PrintExplodedTime(&et_tmp);\n-    printf(\"\\n\");\n     prt_tmp = PR_ImplodeTime(&et_tmp);\n-    if (LL_NE(prt_tmp, now)) {\n-        fprintf(stderr, \"not equal\\n\");\n-        exit(1);\n+    if (LL_NE(prt_tmp, prt[idx])) {\n+      fprintf(stderr, \"PRTime not equal\\n\");\n+      exit(1);\n+    }\n+    if (debug_mode) {\n+      printf(\"GMT: \");\n+      PrintExplodedTime(&et_tmp);\n+      printf(\"\\n\");\n+    }\n+\n+    PR_ExplodeTime(prt[idx], PR_USPacificTimeParameters, &et_tmp);\n+    if (!ExplodedTimeIsEqual(&et_tmp, &uspt[idx])) {\n+      fprintf(stderr, \"US Pacific Time not equal\\n\");\n+      PrintExplodedTime(&et_tmp);\n+      PrintExplodedTime(&uspt[idx]);\n+      exit(1);\n     }\n-    PR_ExplodeTime(now, PR_LocalTimeParameters, &et_tmp);\n-    printf(\"Current local time is \");\n-    PrintExplodedTime(&et_tmp);\n-    printf(\"\\n\");\n     prt_tmp = PR_ImplodeTime(&et_tmp);\n-    if (LL_NE(prt_tmp, now)) {\n-        fprintf(stderr, \"not equal\\n\");\n-        exit(1);\n+    if (LL_NE(prt_tmp, prt[idx])) {\n+      fprintf(stderr, \"PRTime not equal\\n\");\n+      exit(1);\n+    }\n+    if (debug_mode) {\n+      printf(\"US Pacific Time: \");\n+      PrintExplodedTime(&et_tmp);\n+      printf(\"\\n\");\n     }\n-    printf(\"Please verify the results\\n\\n\");\n \n+    PR_ExplodeTime(prt[idx], PR_LocalTimeParameters, &et_tmp);\n+    if (!ExplodedTimeIsEqual(&et_tmp, &localt[idx])) {\n+      fprintf(stderr, \"not equal\\n\");\n+      PrintExplodedTime(&et_tmp);\n+      PrintExplodedTime(&localt[idx]);\n+      exit(1);\n+    }\n+    prt_tmp = PR_ImplodeTime(&et_tmp);\n+    if (LL_NE(prt_tmp, prt[idx])) {\n+      fprintf(stderr, \"not equal\\n\");\n+      exit(1);\n+    }\n     if (debug_mode) {\n-        printf(\"Test 1 passed\\n\");\n+      printf(\"Local time:\");\n+      PrintExplodedTime(&et_tmp);\n+      printf(\"\\n\\n\");\n     }\n-    return PR_SUCCESS;\n+  }\n+\n+  now = PR_Now();\n+  PR_ExplodeTime(now, PR_GMTParameters, &et_tmp);\n+  printf(\"Current GMT is \");\n+  PrintExplodedTime(&et_tmp);\n+  printf(\"\\n\");\n+  prt_tmp = PR_ImplodeTime(&et_tmp);\n+  if (LL_NE(prt_tmp, now)) {\n+    fprintf(stderr, \"not equal\\n\");\n+    exit(1);\n+  }\n+  PR_ExplodeTime(now, PR_USPacificTimeParameters, &et_tmp);\n+  printf(\"Current US Pacific Time is \");\n+  PrintExplodedTime(&et_tmp);\n+  printf(\"\\n\");\n+  prt_tmp = PR_ImplodeTime(&et_tmp);\n+  if (LL_NE(prt_tmp, now)) {\n+    fprintf(stderr, \"not equal\\n\");\n+    exit(1);\n+  }\n+  PR_ExplodeTime(now, PR_LocalTimeParameters, &et_tmp);\n+  printf(\"Current local time is \");\n+  PrintExplodedTime(&et_tmp);\n+  printf(\"\\n\");\n+  prt_tmp = PR_ImplodeTime(&et_tmp);\n+  if (LL_NE(prt_tmp, now)) {\n+    fprintf(stderr, \"not equal\\n\");\n+    exit(1);\n+  }\n+  printf(\"Please verify the results\\n\\n\");\n+\n+  if (debug_mode) {\n+    printf(\"Test 1 passed\\n\");\n+  }\n+  return PR_SUCCESS;\n }\n /* End of Test 1: TestExplodeImplodeTime */\n \n@@ -333,10 +328,10 @@ TestExplodeImplodeTime(void)\n  * time increment for addition to PRExplodeTime\n  */\n typedef struct time_increment {\n-    PRInt32 ti_usec;\n-    PRInt32 ti_sec;\n-    PRInt32 ti_min;\n-    PRInt32 ti_hour;\n+  PRInt32 ti_usec;\n+  PRInt32 ti_sec;\n+  PRInt32 ti_min;\n+  PRInt32 ti_hour;\n } time_increment_t;\n \n /*\n@@ -345,10 +340,10 @@ typedef struct time_increment {\n  *      Time zone.\n  */\n typedef struct normalize_test_data {\n-    PRExplodedTime base_time;\n-    time_increment_t increment;\n-    PRExplodedTime expected_gmt_time;\n-    PRExplodedTime expected_uspt_time;\n+  PRExplodedTime base_time;\n+  time_increment_t increment;\n+  PRExplodedTime expected_gmt_time;\n+  PRExplodedTime expected_uspt_time;\n } normalize_test_data_t;\n \n /*\n@@ -361,93 +356,90 @@ normalize_test_data_t normalize_test_array[] = {\n \n     /* Fri 12/31/1999 19:32:48 PST */\n     {\n-        { 0, 48, 32, 19, 31, 11, 1999, 5, 364, { -28800, 0 } },\n-        { 0, 0, 30, 20 },\n-        { 0, 48, 2, 0, 2, 0, 2000, 0, 1, { 0, 0 } },       /*Sun Jan 2 00:02:48 UTC 2000*/\n-        { 0, 48, 2, 16, 1, 0, 2000, 6, 0, { -28800, 0 } }, /* Sat Jan 1 16:02:48\n-                                                            PST 2000*/\n+        {0, 48, 32, 19, 31, 11, 1999, 5, 364, {-28800, 0}},\n+        {0, 0, 30, 20},\n+        {0, 48, 2, 0, 2, 0, 2000, 0, 1, {0, 0}}, /*Sun Jan 2 00:02:48 UTC 2000*/\n+        {0, 48, 2, 16, 1, 0, 2000, 6, 0, {-28800, 0}}, /* Sat Jan 1 16:02:48\n+                                                        PST 2000*/\n     },\n     /* Fri 99-12-31 23:59:02 GMT */\n     {\n-        { 0, 2, 59, 23, 31, 11, 1999, 5, 364, { 0, 0 } },\n-        { 0, 0, 45, 0 },\n-        { 0, 2, 44, 0, 1, 0, 2000, 6, 0, { 0, 0 } },          /* Sat Jan 1 00:44:02 UTC\n-                                                                 2000*/\n-        { 0, 2, 44, 16, 31, 11, 1999, 5, 364, { -28800, 0 } } /*Fri Dec 31 16:44:02\n-                                                            PST 1999*/\n+        {0, 2, 59, 23, 31, 11, 1999, 5, 364, {0, 0}},\n+        {0, 0, 45, 0},\n+        {0, 2, 44, 0, 1, 0, 2000, 6, 0, {0, 0}}, /* Sat Jan 1 00:44:02 UTC\n+                                                    2000*/\n+        {0, 2, 44, 16, 31, 11, 1999, 5, 364, {-28800, 0}} /*Fri Dec 31 16:44:02\n+                                                        PST 1999*/\n     },\n     /* 99-12-25 12:00:00 GMT */\n     {\n-        { 0, 0, 0, 12, 25, 11, 1999, 6, 358, { 0, 0 } },\n-        { 0, 0, 0, 364 * 24 },\n-        { 0, 0, 0, 12, 23, 11, 2000, 6, 357, { 0, 0 } },    /*Sat Dec 23 12:00:00\n-                                                           2000 UTC*/\n-        { 0, 0, 0, 4, 23, 11, 2000, 6, 357, { -28800, 0 } } /*Sat Dec 23 04:00:00\n-                                                            2000 -0800*/\n+        {0, 0, 0, 12, 25, 11, 1999, 6, 358, {0, 0}},\n+        {0, 0, 0, 364 * 24},\n+        {0, 0, 0, 12, 23, 11, 2000, 6, 357, {0, 0}},    /*Sat Dec 23 12:00:00\n+                                                       2000 UTC*/\n+        {0, 0, 0, 4, 23, 11, 2000, 6, 357, {-28800, 0}} /*Sat Dec 23 04:00:00\n+                                                        2000 -0800*/\n     },\n     /* 00-01-1 00:00:00 PST */\n     {\n-        { 0, 0, 0, 0, 1, 0, 2000, 6, 0, { -28800, 0 } },\n-        { 0, 0, 0, 48 },\n-        { 0, 0, 0, 8, 3, 0, 2000, 1, 2, { 0, 0 } },     /*Mon Jan  3 08:00:00 2000 UTC*/\n-        { 0, 0, 0, 0, 3, 0, 2000, 1, 2, { -28800, 0 } } /*Mon Jan  3 00:00:00 2000\n-                                                                    -0800*/\n+        {0, 0, 0, 0, 1, 0, 2000, 6, 0, {-28800, 0}},\n+        {0, 0, 0, 48},\n+        {0, 0, 0, 8, 3, 0, 2000, 1, 2, {0, 0}}, /*Mon Jan  3 08:00:00 2000 UTC*/\n+        {0, 0, 0, 0, 3, 0, 2000, 1, 2, {-28800, 0}} /*Mon Jan  3 00:00:00 2000\n+                                                                -0800*/\n     },\n     /* 00-01-10 12:00:00 PST */\n     {\n-        { 0, 0, 0, 12, 10, 0, 2000, 1, 9, { -28800, 0 } },\n-        { 0, 0, 0, 364 * 5 * 24 },\n-        { 0, 0, 0, 20, 3, 0, 2005, 1, 2, { 0, 0 } },     /*Mon Jan  3 20:00:00 2005 UTC\n-                                                          */\n-        { 0, 0, 0, 12, 3, 0, 2005, 1, 2, { -28800, 0 } } /*Mon Jan  3 12:00:00\n-                                                            2005 -0800*/\n+        {0, 0, 0, 12, 10, 0, 2000, 1, 9, {-28800, 0}},\n+        {0, 0, 0, 364 * 5 * 24},\n+        {0, 0, 0, 20, 3, 0, 2005, 1, 2, {0, 0}}, /*Mon Jan  3 20:00:00 2005 UTC\n+                                                  */\n+        {0, 0, 0, 12, 3, 0, 2005, 1, 2, {-28800, 0}} /*Mon Jan  3 12:00:00\n+                                                        2005 -0800*/\n     },\n     /* 00-02-28 15:39 GMT */\n     {\n-        { 0, 0, 39, 15, 28, 1, 2000, 1, 58, { 0, 0 } },\n-        { 0, 0, 0, 24 },\n-        { 0, 0, 39, 15, 29, 1, 2000, 2, 59, { 0, 0 } },    /*Tue Feb 29 15:39:00 2000\n-                                                              UTC*/\n-        { 0, 0, 39, 7, 29, 1, 2000, 2, 59, { -28800, 0 } } /*Tue Feb 29 07:39:00\n-                                                            2000 -0800*/\n+        {0, 0, 39, 15, 28, 1, 2000, 1, 58, {0, 0}},\n+        {0, 0, 0, 24},\n+        {0, 0, 39, 15, 29, 1, 2000, 2, 59, {0, 0}}, /*Tue Feb 29 15:39:00 2000\n+                                                       UTC*/\n+        {0, 0, 39, 7, 29, 1, 2000, 2, 59, {-28800, 0}} /*Tue Feb 29 07:39:00\n+                                                        2000 -0800*/\n     },\n     /* 01-03-01 12:00 PST */\n     {\n-        { 0, 0, 0, 12, 3, 0, 2001, 3, 2, { -28800, 0 } }, /*Wed Jan 3 12:00:00\n-                                                        -0800 2001*/\n-        { 0, 30, 30, 45 },\n-        { 0, 30, 30, 17, 5, 0, 2001, 5, 4, { 0, 0 } },    /*Fri Jan  5 17:30:30 2001\n-                                                          UTC*/\n-        { 0, 30, 30, 9, 5, 0, 2001, 5, 4, { -28800, 0 } } /*Fri Jan  5 09:30:30\n-                                                           2001 -0800*/\n+        {0, 0, 0, 12, 3, 0, 2001, 3, 2, {-28800, 0}}, /*Wed Jan 3 12:00:00\n+                                                    -0800 2001*/\n+        {0, 30, 30, 45},\n+        {0, 30, 30, 17, 5, 0, 2001, 5, 4, {0, 0}},    /*Fri Jan  5 17:30:30 2001\n+                                                      UTC*/\n+        {0, 30, 30, 9, 5, 0, 2001, 5, 4, {-28800, 0}} /*Fri Jan  5 09:30:30\n+                                                       2001 -0800*/\n     },\n     /* 2004-04-26 12:00 GMT */\n     {\n-        { 0, 0, 0, 20, 3, 0, 2001, 3, 2, { 0, 0 } },\n-        { 0, 0, 30, 0 },\n-        { 0, 0, 30, 20, 3, 0, 2001, 3, 2, { 0, 0 } },     /*Wed Jan  3 20:30:00 2001\n-                                                             UTC*/\n-        { 0, 0, 30, 12, 3, 0, 2001, 3, 2, { -28800, 0 } } /*Wed Jan  3 12:30:00\n-                                                            2001 -0800*/\n+        {0, 0, 0, 20, 3, 0, 2001, 3, 2, {0, 0}},\n+        {0, 0, 30, 0},\n+        {0, 0, 30, 20, 3, 0, 2001, 3, 2, {0, 0}},     /*Wed Jan  3 20:30:00 2001\n+                                                         UTC*/\n+        {0, 0, 30, 12, 3, 0, 2001, 3, 2, {-28800, 0}} /*Wed Jan  3 12:30:00\n+                                                        2001 -0800*/\n     },\n     /* 99-09-09 00:00 GMT */\n     {\n-        { 0, 0, 0, 0, 9, 8, 1999, 4, 251, { 0, 0 } },\n-        { 0, 0, 0, 12 },\n-        { 0, 0, 0, 12, 9, 8, 1999, 4, 251, { 0, 0 } },       /*Thu Sep  9 12:00:00 1999\n-                                                                UTC*/\n-        { 0, 0, 0, 5, 9, 8, 1999, 4, 251, { -28800, 3600 } } /*Thu Sep  9 05:00:00\n-                                                            1999 -0700*/\n-    }\n-};\n-\n-void\n-add_time_increment(PRExplodedTime* et1, time_increment_t* it)\n-{\n-    et1->tm_usec += it->ti_usec;\n-    et1->tm_sec += it->ti_sec;\n-    et1->tm_min += it->ti_min;\n-    et1->tm_hour += it->ti_hour;\n+        {0, 0, 0, 0, 9, 8, 1999, 4, 251, {0, 0}},\n+        {0, 0, 0, 12},\n+        {0, 0, 0, 12, 9, 8, 1999, 4, 251, {0, 0}}, /*Thu Sep  9 12:00:00 1999\n+                                                      UTC*/\n+        {0, 0, 0, 5, 9, 8, 1999, 4, 251, {-28800, 3600}} /*Thu Sep  9 05:00:00\n+                                                        1999 -0700*/\n+    }};\n+\n+void add_time_increment(PRExplodedTime* et1, time_increment_t* it) {\n+  et1->tm_usec += it->ti_usec;\n+  et1->tm_sec += it->ti_sec;\n+  et1->tm_min += it->ti_min;\n+  et1->tm_hour += it->ti_hour;\n }\n \n /*\n@@ -458,53 +450,51 @@ add_time_increment(PRExplodedTime* et1, time_increment_t* it)\n **      should match the expected values in the data item.\n **\n */\n-PRStatus\n-TestNormalizeTime(void)\n-{\n-    int idx, count;\n-    normalize_test_data_t* itemp;\n-    time_increment_t* itp;\n-\n-    count = sizeof(normalize_test_array) / sizeof(normalize_test_array[0]);\n-    for (idx = 0; idx < count; idx++) {\n-        itemp = &normalize_test_array[idx];\n-        if (debug_mode) {\n-            printf(\"%2d. %15s\", idx + 1, \"Base time: \");\n-            PrintExplodedTime(&itemp->base_time);\n-            printf(\"\\n\");\n-        }\n-        itp = &itemp->increment;\n-        if (debug_mode) {\n-            printf(\"%20s %2d hrs %2d min %3d sec\\n\", \"Add\", itp->ti_hour, itp->ti_min,\n-                   itp->ti_sec);\n-        }\n-        add_time_increment(&itemp->base_time, &itemp->increment);\n-        PR_NormalizeTime(&itemp->base_time, PR_LocalTimeParameters);\n-        if (debug_mode) {\n-            printf(\"%19s\", \"PST time: \");\n-            PrintExplodedTime(&itemp->base_time);\n-            printf(\"\\n\");\n-        }\n-        if (!ExplodedTimeIsEqual(&itemp->base_time, &itemp->expected_uspt_time)) {\n-            printf(\"PR_NormalizeTime failed\\n\");\n-            if (debug_mode) {\n-                PrintExplodedTime(&itemp->expected_uspt_time);\n-            }\n-            return PR_FAILURE;\n-        }\n-        PR_NormalizeTime(&itemp->base_time, PR_GMTParameters);\n-        if (debug_mode) {\n-            printf(\"%19s\", \"GMT time: \");\n-            PrintExplodedTime(&itemp->base_time);\n-            printf(\"\\n\");\n-        }\n+PRStatus TestNormalizeTime(void) {\n+  int idx, count;\n+  normalize_test_data_t* itemp;\n+  time_increment_t* itp;\n+\n+  count = sizeof(normalize_test_array) / sizeof(normalize_test_array[0]);\n+  for (idx = 0; idx < count; idx++) {\n+    itemp = &normalize_test_array[idx];\n+    if (debug_mode) {\n+      printf(\"%2d. %15s\", idx + 1, \"Base time: \");\n+      PrintExplodedTime(&itemp->base_time);\n+      printf(\"\\n\");\n+    }\n+    itp = &itemp->increment;\n+    if (debug_mode) {\n+      printf(\"%20s %2d hrs %2d min %3d sec\\n\", \"Add\", itp->ti_hour, itp->ti_min,\n+             itp->ti_sec);\n+    }\n+    add_time_increment(&itemp->base_time, &itemp->increment);\n+    PR_NormalizeTime(&itemp->base_time, PR_LocalTimeParameters);\n+    if (debug_mode) {\n+      printf(\"%19s\", \"PST time: \");\n+      PrintExplodedTime(&itemp->base_time);\n+      printf(\"\\n\");\n+    }\n+    if (!ExplodedTimeIsEqual(&itemp->base_time, &itemp->expected_uspt_time)) {\n+      printf(\"PR_NormalizeTime failed\\n\");\n+      if (debug_mode) {\n+        PrintExplodedTime(&itemp->expected_uspt_time);\n+      }\n+      return PR_FAILURE;\n+    }\n+    PR_NormalizeTime(&itemp->base_time, PR_GMTParameters);\n+    if (debug_mode) {\n+      printf(\"%19s\", \"GMT time: \");\n+      PrintExplodedTime(&itemp->base_time);\n+      printf(\"\\n\");\n+    }\n \n-        if (!ExplodedTimeIsEqual(&itemp->base_time, &itemp->expected_gmt_time)) {\n-            printf(\"PR_NormalizeTime failed\\n\");\n-            return PR_FAILURE;\n-        }\n+    if (!ExplodedTimeIsEqual(&itemp->base_time, &itemp->expected_gmt_time)) {\n+      printf(\"PR_NormalizeTime failed\\n\");\n+      return PR_FAILURE;\n     }\n-    return PR_SUCCESS;\n+  }\n+  return PR_SUCCESS;\n }\n \n /*\n@@ -512,8 +502,8 @@ TestNormalizeTime(void)\n **\n */\n typedef struct ParseTest {\n-    char* sDate;       /* string to be converted using PR_ParseTimeString() */\n-    PRExplodedTime et; /* expected result of the conversion */\n+  char* sDate;       /* string to be converted using PR_ParseTimeString() */\n+  PRExplodedTime et; /* expected result of the conversion */\n } ParseTest;\n \n static ParseTest parseArray[] = {\n@@ -521,278 +511,277 @@ static ParseTest parseArray[] = {\n        ------------------------------------------->| */\n     /* \"string to test\"                   usec     sec min hour   day  mo  year\n        wday julian {gmtoff, dstoff }*/\n-    { \"Thursday 1 Jan 1970 00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"1 Jan 1970 00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"1-Jan-1970 00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"01-Jan-1970 00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"January 1, 1970\", { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"January 1, 1970 00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"January 01, 1970 00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"January 01 1970 00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"January 01 1970 00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"01-01-1970\", { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"01/01/1970\", { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"01/01/70\", { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"01/01/70 00:00:00\", { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"70/01/01 00:00:00\", { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"70/1/1 00:00:\", { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"00:00 Thursday, January 1, 1970\",\n-      { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"1-Jan-70 00:00:00\", { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"70-01-01 00:00:00\", { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n-    { \"70/01/01 00:00:00\", { 000000, 00, 00, 00, 1, 0, 1970, 4, 0, { -28800, 0 } } },\n+    {\"Thursday 1 Jan 1970 00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"1 Jan 1970 00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"1-Jan-1970 00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"01-Jan-1970 00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"January 1, 1970\", {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"January 1, 1970 00:00\",\n+     {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"January 01, 1970 00:00\",\n+     {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"January 01 1970 00:00\",\n+     {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"January 01 1970 00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"01-01-1970\", {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"01/01/1970\", {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"01/01/70\", {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"01/01/70 00:00:00\", {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"70/01/01 00:00:00\", {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"70/1/1 00:00:\", {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"00:00 Thursday, January 1, 1970\",\n+     {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"1-Jan-70 00:00:00\", {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"70-01-01 00:00:00\", {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n+    {\"70/01/01 00:00:00\", {000000, 00, 00, 00, 1, 0, 1970, 4, 0, {-28800, 0}}},\n \n     /* 31-Dec-1969 */\n-    { \"Wed 31 Dec 1969 00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 1969, 3, 364, { -28800, 0 } } },\n-    { \"31 Dec 1969 00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 1969, 3, 364, { -28800, 0 } } },\n-    { \"12/31/69    00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 2069, 2, 364, { -28800, 0 } } },\n-    { \"12/31/1969  00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 1969, 3, 364, { -28800, 0 } } },\n-    { \"12-31-69    00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 2069, 2, 364, { -28800, 0 } } },\n-    { \"12-31-1969  00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 1969, 3, 364, { -28800, 0 } } },\n-    { \"69-12-31    00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 2069, 2, 364, { -28800, 0 } } },\n-    { \"69/12/31    00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 2069, 2, 364, { -28800, 0 } } },\n+    {\"Wed 31 Dec 1969 00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 1969, 3, 364, {-28800, 0}}},\n+    {\"31 Dec 1969 00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 1969, 3, 364, {-28800, 0}}},\n+    {\"12/31/69    00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 2069, 2, 364, {-28800, 0}}},\n+    {\"12/31/1969  00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 1969, 3, 364, {-28800, 0}}},\n+    {\"12-31-69    00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 2069, 2, 364, {-28800, 0}}},\n+    {\"12-31-1969  00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 1969, 3, 364, {-28800, 0}}},\n+    {\"69-12-31    00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 2069, 2, 364, {-28800, 0}}},\n+    {\"69/12/31    00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 2069, 2, 364, {-28800, 0}}},\n \n     /* \"Sun\". 31-Dec-1998 (?) */\n-    { \"Thu 31 Dec 1998 00:00:00\",\n-      { 00000, 00, 00, 00, 31, 11, 1998, 4, 364, { -28800, 0 } } },\n-    { \"12/31/98    00:00:00\",\n-      { 00000, 00, 00, 00, 31, 11, 1998, 4, 364, { -28800, 0 } } },\n-    { \"12/31/1998  00:00:00\",\n-      { 00000, 00, 00, 00, 31, 11, 1998, 4, 364, { -28800, 0 } } },\n-    { \"12-31-98    00:00:00\",\n-      { 00000, 00, 00, 00, 31, 11, 1998, 4, 364, { -28800, 0 } } },\n-    { \"12-31-1998  00:00:00\",\n-      { 00000, 00, 00, 00, 31, 11, 1998, 4, 364, { -28800, 0 } } },\n-    { \"98-12-31    00:00:00\",\n-      { 00000, 00, 00, 00, 31, 11, 1998, 4, 364, { -28800, 0 } } },\n-    { \"98/12/31    00:00:00\",\n-      { 00000, 00, 00, 00, 31, 11, 1998, 4, 364, { -28800, 0 } } },\n+    {\"Thu 31 Dec 1998 00:00:00\",\n+     {00000, 00, 00, 00, 31, 11, 1998, 4, 364, {-28800, 0}}},\n+    {\"12/31/98    00:00:00\",\n+     {00000, 00, 00, 00, 31, 11, 1998, 4, 364, {-28800, 0}}},\n+    {\"12/31/1998  00:00:00\",\n+     {00000, 00, 00, 00, 31, 11, 1998, 4, 364, {-28800, 0}}},\n+    {\"12-31-98    00:00:00\",\n+     {00000, 00, 00, 00, 31, 11, 1998, 4, 364, {-28800, 0}}},\n+    {\"12-31-1998  00:00:00\",\n+     {00000, 00, 00, 00, 31, 11, 1998, 4, 364, {-28800, 0}}},\n+    {\"98-12-31    00:00:00\",\n+     {00000, 00, 00, 00, 31, 11, 1998, 4, 364, {-28800, 0}}},\n+    {\"98/12/31    00:00:00\",\n+     {00000, 00, 00, 00, 31, 11, 1998, 4, 364, {-28800, 0}}},\n \n     /* 09-Sep-1999. Interesting because of its use as an eof marker? */\n-    { \"09 Sep 1999 00:00:00\",\n-      { 000000, 00, 00, 00, 9, 8, 1999, 4, 251, { -28800, 3600 } } },\n-    { \"9/9/99      00:00:00\",\n-      { 000000, 00, 00, 00, 9, 8, 1999, 4, 251, { -28800, 3600 } } },\n-    { \"9/9/1999    00:00:00\",\n-      { 000000, 00, 00, 00, 9, 8, 1999, 4, 251, { -28800, 3600 } } },\n-    { \"9-9-99      00:00:00\",\n-      { 000000, 00, 00, 00, 9, 8, 1999, 4, 251, { -28800, 3600 } } },\n-    { \"9-9-1999    00:00:00\",\n-      { 000000, 00, 00, 00, 9, 8, 1999, 4, 251, { -28800, 3600 } } },\n-    { \"09-09-99    00:00:00\",\n-      { 000000, 00, 00, 00, 9, 8, 1999, 4, 251, { -28800, 3600 } } },\n-    { \"09-09-1999  00:00:00\",\n-      { 000000, 00, 00, 00, 9, 8, 1999, 4, 251, { -28800, 3600 } } },\n-    { \"99-09-09    00:00:00\",\n-      { 000000, 00, 00, 00, 9, 8, 1999, 4, 251, { -28800, 3600 } } },\n+    {\"09 Sep 1999 00:00:00\",\n+     {000000, 00, 00, 00, 9, 8, 1999, 4, 251, {-28800, 3600}}},\n+    {\"9/9/99      00:00:00\",\n+     {000000, 00, 00, 00, 9, 8, 1999, 4, 251, {-28800, 3600}}},\n+    {\"9/9/1999    00:00:00\",\n+     {000000, 00, 00, 00, 9, 8, 1999, 4, 251, {-28800, 3600}}},\n+    {\"9-9-99      00:00:00\",\n+     {000000, 00, 00, 00, 9, 8, 1999, 4, 251, {-28800, 3600}}},\n+    {\"9-9-1999    00:00:00\",\n+     {000000, 00, 00, 00, 9, 8, 1999, 4, 251, {-28800, 3600}}},\n+    {\"09-09-99    00:00:00\",\n+     {000000, 00, 00, 00, 9, 8, 1999, 4, 251, {-28800, 3600}}},\n+    {\"09-09-1999  00:00:00\",\n+     {000000, 00, 00, 00, 9, 8, 1999, 4, 251, {-28800, 3600}}},\n+    {\"99-09-09    00:00:00\",\n+     {000000, 00, 00, 00, 9, 8, 1999, 4, 251, {-28800, 3600}}},\n \n     /* \"Sun\". 10-Sep-1999. Because Sun said so. */\n-    { \"10 Sep 1999 00:00:00\",\n-      { 000000, 00, 00, 00, 10, 8, 1999, 5, 252, { -28800, 3600 } } },\n-    { \"9/10/99     00:00:00\",\n-      { 000000, 00, 00, 00, 10, 8, 1999, 5, 252, { -28800, 3600 } } },\n-    { \"9/10/1999   00:00:00\",\n-      { 000000, 00, 00, 00, 10, 8, 1999, 5, 252, { -28800, 3600 } } },\n-    { \"9-10-99     00:00:00\",\n-      { 000000, 00, 00, 00, 10, 8, 1999, 5, 252, { -28800, 3600 } } },\n-    { \"9-10-1999   00:00:00\",\n-      { 000000, 00, 00, 00, 10, 8, 1999, 5, 252, { -28800, 3600 } } },\n-    { \"09-10-99    00:00:00\",\n-      { 000000, 00, 00, 00, 10, 8, 1999, 5, 252, { -28800, 3600 } } },\n-    { \"09-10-1999  00:00:00\",\n-      { 000000, 00, 00, 00, 10, 8, 1999, 5, 252, { -28800, 3600 } } },\n-    { \"99-09-10    00:00:00\",\n-      { 000000, 00, 00, 00, 10, 8, 1999, 5, 252, { -28800, 3600 } } },\n+    {\"10 Sep 1999 00:00:00\",\n+     {000000, 00, 00, 00, 10, 8, 1999, 5, 252, {-28800, 3600}}},\n+    {\"9/10/99     00:00:00\",\n+     {000000, 00, 00, 00, 10, 8, 1999, 5, 252, {-28800, 3600}}},\n+    {\"9/10/1999   00:00:00\",\n+     {000000, 00, 00, 00, 10, 8, 1999, 5, 252, {-28800, 3600}}},\n+    {\"9-10-99     00:00:00\",\n+     {000000, 00, 00, 00, 10, 8, 1999, 5, 252, {-28800, 3600}}},\n+    {\"9-10-1999   00:00:00\",\n+     {000000, 00, 00, 00, 10, 8, 1999, 5, 252, {-28800, 3600}}},\n+    {\"09-10-99    00:00:00\",\n+     {000000, 00, 00, 00, 10, 8, 1999, 5, 252, {-28800, 3600}}},\n+    {\"09-10-1999  00:00:00\",\n+     {000000, 00, 00, 00, 10, 8, 1999, 5, 252, {-28800, 3600}}},\n+    {\"99-09-10    00:00:00\",\n+     {000000, 00, 00, 00, 10, 8, 1999, 5, 252, {-28800, 3600}}},\n \n     /* 31-Dec-1999 */\n-    { \"31 Dec 1999 00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 1999, 5, 364, { -28800, 0 } } },\n-    { \"12/31/99    00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 1999, 5, 364, { -28800, 0 } } },\n-    { \"12/31/1999  00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 1999, 5, 364, { -28800, 0 } } },\n-    { \"12-31-99    00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 1999, 5, 364, { -28800, 0 } } },\n-    { \"12-31-1999  00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 1999, 5, 364, { -28800, 0 } } },\n-    { \"99-12-31    00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 1999, 5, 364, { -28800, 0 } } },\n-    { \"99/12/31    00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 1999, 5, 364, { -28800, 0 } } },\n+    {\"31 Dec 1999 00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 1999, 5, 364, {-28800, 0}}},\n+    {\"12/31/99    00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 1999, 5, 364, {-28800, 0}}},\n+    {\"12/31/1999  00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 1999, 5, 364, {-28800, 0}}},\n+    {\"12-31-99    00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 1999, 5, 364, {-28800, 0}}},\n+    {\"12-31-1999  00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 1999, 5, 364, {-28800, 0}}},\n+    {\"99-12-31    00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 1999, 5, 364, {-28800, 0}}},\n+    {\"99/12/31    00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 1999, 5, 364, {-28800, 0}}},\n \n     /* 01-Jan-2000 */\n-    { \"01 Jan 2000 00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2000, 6, 0, { -28800, 0 } } },\n-    { \"1/1/00      00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2000, 6, 0, { -28800, 0 } } },\n-    { \"1/1/2000    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2000, 6, 0, { -28800, 0 } } },\n-    { \"1-1-00      00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2000, 6, 0, { -28800, 0 } } },\n-    { \"1-1-2000    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2000, 6, 0, { -28800, 0 } } },\n-    { \"01-01-00    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2000, 6, 0, { -28800, 0 } } },\n-    { \"Saturday 01-01-2000  00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2000, 6, 0, { -28800, 0 } } },\n+    {\"01 Jan 2000 00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2000, 6, 0, {-28800, 0}}},\n+    {\"1/1/00      00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2000, 6, 0, {-28800, 0}}},\n+    {\"1/1/2000    00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2000, 6, 0, {-28800, 0}}},\n+    {\"1-1-00      00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2000, 6, 0, {-28800, 0}}},\n+    {\"1-1-2000    00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2000, 6, 0, {-28800, 0}}},\n+    {\"01-01-00    00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2000, 6, 0, {-28800, 0}}},\n+    {\"Saturday 01-01-2000  00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2000, 6, 0, {-28800, 0}}},\n \n     /* \"Sun\". 28-Feb-2000 */\n-    { \"28 Feb 2000 00:00:00\",\n-      { 000000, 00, 00, 00, 28, 1, 2000, 1, 58, { -28800, 0 } } },\n-    { \"2/28/00     00:00:00\",\n-      { 000000, 00, 00, 00, 28, 1, 2000, 1, 58, { -28800, 0 } } },\n-    { \"2/28/2000   00:00:00\",\n-      { 000000, 00, 00, 00, 28, 1, 2000, 1, 58, { -28800, 0 } } },\n-    { \"2-28-00     00:00:00\",\n-      { 000000, 00, 00, 00, 28, 1, 2000, 1, 58, { -28800, 0 } } },\n-    { \"2-28-2000   00:00:00\",\n-      { 000000, 00, 00, 00, 28, 1, 2000, 1, 58, { -28800, 0 } } },\n-    { \"02-28-00    00:00:00\",\n-      { 000000, 00, 00, 00, 28, 1, 2000, 1, 58, { -28800, 0 } } },\n-    { \"02-28-2000  00:00:00\",\n-      { 000000, 00, 00, 00, 28, 1, 2000, 1, 58, { -28800, 0 } } },\n+    {\"28 Feb 2000 00:00:00\",\n+     {000000, 00, 00, 00, 28, 1, 2000, 1, 58, {-28800, 0}}},\n+    {\"2/28/00     00:00:00\",\n+     {000000, 00, 00, 00, 28, 1, 2000, 1, 58, {-28800, 0}}},\n+    {\"2/28/2000   00:00:00\",\n+     {000000, 00, 00, 00, 28, 1, 2000, 1, 58, {-28800, 0}}},\n+    {\"2-28-00     00:00:00\",\n+     {000000, 00, 00, 00, 28, 1, 2000, 1, 58, {-28800, 0}}},\n+    {\"2-28-2000   00:00:00\",\n+     {000000, 00, 00, 00, 28, 1, 2000, 1, 58, {-28800, 0}}},\n+    {\"02-28-00    00:00:00\",\n+     {000000, 00, 00, 00, 28, 1, 2000, 1, 58, {-28800, 0}}},\n+    {\"02-28-2000  00:00:00\",\n+     {000000, 00, 00, 00, 28, 1, 2000, 1, 58, {-28800, 0}}},\n \n     /* 29-Feb-2000 */\n-    { \"29 Feb 2000 00:00:00\",\n-      { 000000, 00, 00, 00, 29, 1, 2000, 2, 59, { -28800, 0 } } },\n-    { \"2/29/00     00:00:00\",\n-      { 000000, 00, 00, 00, 29, 1, 2000, 2, 59, { -28800, 0 } } },\n-    { \"2/29/2000   00:00:00\",\n-      { 000000, 00, 00, 00, 29, 1, 2000, 2, 59, { -28800, 0 } } },\n-    { \"2-29-00     00:00:00\",\n-      { 000000, 00, 00, 00, 29, 1, 2000, 2, 59, { -28800, 0 } } },\n-    { \"2-29-2000   00:00:00\",\n-      { 000000, 00, 00, 00, 29, 1, 2000, 2, 59, { -28800, 0 } } },\n-    { \"02-29-00    00:00:00\",\n-      { 000000, 00, 00, 00, 29, 1, 2000, 2, 59, { -28800, 0 } } },\n-    { \"02-29-2000  00:00:00\",\n-      { 000000, 00, 00, 00, 29, 1, 2000, 2, 59, { -28800, 0 } } },\n+    {\"29 Feb 2000 00:00:00\",\n+     {000000, 00, 00, 00, 29, 1, 2000, 2, 59, {-28800, 0}}},\n+    {\"2/29/00     00:00:00\",\n+     {000000, 00, 00, 00, 29, 1, 2000, 2, 59, {-28800, 0}}},\n+    {\"2/29/2000   00:00:00\",\n+     {000000, 00, 00, 00, 29, 1, 2000, 2, 59, {-28800, 0}}},\n+    {\"2-29-00     00:00:00\",\n+     {000000, 00, 00, 00, 29, 1, 2000, 2, 59, {-28800, 0}}},\n+    {\"2-29-2000   00:00:00\",\n+     {000000, 00, 00, 00, 29, 1, 2000, 2, 59, {-28800, 0}}},\n+    {\"02-29-00    00:00:00\",\n+     {000000, 00, 00, 00, 29, 1, 2000, 2, 59, {-28800, 0}}},\n+    {\"02-29-2000  00:00:00\",\n+     {000000, 00, 00, 00, 29, 1, 2000, 2, 59, {-28800, 0}}},\n \n     /* 01-Mar-2000 */\n-    { \"01 Mar 2000 00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2000, 3, 60, { -28800, 0 } } },\n-    { \"3/1/00      00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2000, 3, 60, { -28800, 0 } } },\n-    { \"3/1/2000    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2000, 3, 60, { -28800, 0 } } },\n-    { \"3-1-00      00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2000, 3, 60, { -28800, 0 } } },\n-    { \"03-01-00    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2000, 3, 60, { -28800, 0 } } },\n-    { \"03-01-2000  00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2000, 3, 60, { -28800, 0 } } },\n+    {\"01 Mar 2000 00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2000, 3, 60, {-28800, 0}}},\n+    {\"3/1/00      00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2000, 3, 60, {-28800, 0}}},\n+    {\"3/1/2000    00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2000, 3, 60, {-28800, 0}}},\n+    {\"3-1-00      00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2000, 3, 60, {-28800, 0}}},\n+    {\"03-01-00    00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2000, 3, 60, {-28800, 0}}},\n+    {\"03-01-2000  00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2000, 3, 60, {-28800, 0}}},\n \n     /* \"Sun\". 31-Dec-2000 */\n-    { \"31 Dec 2000 00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 2000, 0, 365, { -28800, 0 } } },\n-    { \"12/31/00    00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 2000, 0, 365, { -28800, 0 } } },\n-    { \"12/31/2000  00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 2000, 0, 365, { -28800, 0 } } },\n-    { \"12-31-00    00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 2000, 0, 365, { -28800, 0 } } },\n-    { \"12-31-2000  00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 2000, 0, 365, { -28800, 0 } } },\n-    { \"00-12-31    00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 2000, 0, 365, { -28800, 0 } } },\n-    { \"00/12/31    00:00:00\",\n-      { 000000, 00, 00, 00, 31, 11, 2000, 0, 365, { -28800, 0 } } },\n+    {\"31 Dec 2000 00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 2000, 0, 365, {-28800, 0}}},\n+    {\"12/31/00    00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 2000, 0, 365, {-28800, 0}}},\n+    {\"12/31/2000  00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 2000, 0, 365, {-28800, 0}}},\n+    {\"12-31-00    00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 2000, 0, 365, {-28800, 0}}},\n+    {\"12-31-2000  00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 2000, 0, 365, {-28800, 0}}},\n+    {\"00-12-31    00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 2000, 0, 365, {-28800, 0}}},\n+    {\"00/12/31    00:00:00\",\n+     {000000, 00, 00, 00, 31, 11, 2000, 0, 365, {-28800, 0}}},\n \n     /* \"Sun\". 01-Jan-2001 */\n-    { \"01 Jan 2001 00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2001, 1, 0, { -28800, 0 } } },\n-    { \"1/1/01      00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2001, 1, 0, { -28800, 0 } } },\n-    { \"1/1/2001    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2001, 1, 0, { -28800, 0 } } },\n-    { \"1-1-01      00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2001, 1, 0, { -28800, 0 } } },\n-    { \"1-1-2001    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2001, 1, 0, { -28800, 0 } } },\n-    { \"01-01-01    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2001, 1, 0, { -28800, 0 } } },\n-    { \"Saturday 01-01-2001  00:00:00\",\n-      { 000000, 00, 00, 00, 1, 0, 2001, 1, 0, { -28800, 0 } } },\n+    {\"01 Jan 2001 00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2001, 1, 0, {-28800, 0}}},\n+    {\"1/1/01      00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2001, 1, 0, {-28800, 0}}},\n+    {\"1/1/2001    00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2001, 1, 0, {-28800, 0}}},\n+    {\"1-1-01      00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2001, 1, 0, {-28800, 0}}},\n+    {\"1-1-2001    00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2001, 1, 0, {-28800, 0}}},\n+    {\"01-01-01    00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2001, 1, 0, {-28800, 0}}},\n+    {\"Saturday 01-01-2001  00:00:00\",\n+     {000000, 00, 00, 00, 1, 0, 2001, 1, 0, {-28800, 0}}},\n \n     /* 01-Mar-2001 */\n-    { \"01 Mar 2001 00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2001, 4, 59, { -28800, 0 } } },\n-    { \"3/1/01      00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2001, 4, 59, { -28800, 0 } } },\n-    { \"3/1/2001    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2001, 4, 59, { -28800, 0 } } },\n-    { \"3-1-01      00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2001, 4, 59, { -28800, 0 } } },\n-    { \"3-1-2001    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2001, 4, 59, { -28800, 0 } } },\n-    { \"03-01-01    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2001, 4, 59, { -28800, 0 } } },\n-    { \"03-01-2001  00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2001, 4, 59, { -28800, 0 } } },\n+    {\"01 Mar 2001 00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2001, 4, 59, {-28800, 0}}},\n+    {\"3/1/01      00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2001, 4, 59, {-28800, 0}}},\n+    {\"3/1/2001    00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2001, 4, 59, {-28800, 0}}},\n+    {\"3-1-01      00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2001, 4, 59, {-28800, 0}}},\n+    {\"3-1-2001    00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2001, 4, 59, {-28800, 0}}},\n+    {\"03-01-01    00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2001, 4, 59, {-28800, 0}}},\n+    {\"03-01-2001  00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2001, 4, 59, {-28800, 0}}},\n \n     /* 29-Feb-2004 */\n-    { \"29 Feb 2004 00:00:00\",\n-      { 000000, 00, 00, 00, 29, 1, 2004, 0, 59, { -28800, 0 } } },\n-    { \"2/29/04     00:00:00\",\n-      { 000000, 00, 00, 00, 29, 1, 2004, 0, 59, { -28800, 0 } } },\n-    { \"2/29/2004   00:00:00\",\n-      { 000000, 00, 00, 00, 29, 1, 2004, 0, 59, { -28800, 0 } } },\n-    { \"2-29-04     00:00:00\",\n-      { 000000, 00, 00, 00, 29, 1, 2004, 0, 59, { -28800, 0 } } },\n-    { \"2-29-2004   00:00:00\",\n-      { 000000, 00, 00, 00, 29, 1, 2004, 0, 59, { -28800, 0 } } },\n+    {\"29 Feb 2004 00:00:00\",\n+     {000000, 00, 00, 00, 29, 1, 2004, 0, 59, {-28800, 0}}},\n+    {\"2/29/04     00:00:00\",\n+     {000000, 00, 00, 00, 29, 1, 2004, 0, 59, {-28800, 0}}},\n+    {\"2/29/2004   00:00:00\",\n+     {000000, 00, 00, 00, 29, 1, 2004, 0, 59, {-28800, 0}}},\n+    {\"2-29-04     00:00:00\",\n+     {000000, 00, 00, 00, 29, 1, 2004, 0, 59, {-28800, 0}}},\n+    {\"2-29-2004   00:00:00\",\n+     {000000, 00, 00, 00, 29, 1, 2004, 0, 59, {-28800, 0}}},\n \n     /* 01-Mar-2004 */\n-    { \"01 Mar 2004 00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2004, 1, 60, { -28800, 0 } } },\n-    { \"3/1/04      00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2004, 1, 60, { -28800, 0 } } },\n-    { \"3/1/2004    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2004, 1, 60, { -28800, 0 } } },\n-    { \"3-1-04      00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2004, 1, 60, { -28800, 0 } } },\n-    { \"3-1-2004    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2004, 1, 60, { -28800, 0 } } },\n-    { \"03-01-04    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2004, 1, 60, { -28800, 0 } } },\n-    { \"03-01-2004  00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2004, 1, 60, { -28800, 0 } } },\n+    {\"01 Mar 2004 00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2004, 1, 60, {-28800, 0}}},\n+    {\"3/1/04      00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2004, 1, 60, {-28800, 0}}},\n+    {\"3/1/2004    00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2004, 1, 60, {-28800, 0}}},\n+    {\"3-1-04      00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2004, 1, 60, {-28800, 0}}},\n+    {\"3-1-2004    00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2004, 1, 60, {-28800, 0}}},\n+    {\"03-01-04    00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2004, 1, 60, {-28800, 0}}},\n+    {\"03-01-2004  00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2004, 1, 60, {-28800, 0}}},\n \n     /* 01-Mar-2005 */\n-    { \"01 Mar 2005 00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2005, 2, 59, { -28800, 0 } } },\n-    { \"3/1/05      00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2005, 2, 59, { -28800, 0 } } },\n-    { \"3/1/2005    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2005, 2, 59, { -28800, 0 } } },\n-    { \"3-1-05      00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2005, 2, 59, { -28800, 0 } } },\n-    { \"3-1-2005    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2005, 2, 59, { -28800, 0 } } },\n-    { \"03-01-05    00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2005, 2, 59, { -28800, 0 } } },\n-    { \"03-01-2005  00:00:00\",\n-      { 000000, 00, 00, 00, 1, 2, 2005, 2, 59, { -28800, 0 } } },\n+    {\"01 Mar 2005 00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2005, 2, 59, {-28800, 0}}},\n+    {\"3/1/05      00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2005, 2, 59, {-28800, 0}}},\n+    {\"3/1/2005    00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2005, 2, 59, {-28800, 0}}},\n+    {\"3-1-05      00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2005, 2, 59, {-28800, 0}}},\n+    {\"3-1-2005    00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2005, 2, 59, {-28800, 0}}},\n+    {\"03-01-05    00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2005, 2, 59, {-28800, 0}}},\n+    {\"03-01-2005  00:00:00\",\n+     {000000, 00, 00, 00, 1, 2, 2005, 2, 59, {-28800, 0}}},\n \n     /* last element. string must be null */\n-    { NULL }\n-}; /* end array of ParseTest */\n+    {NULL}}; /* end array of ParseTest */\n \n /*\n ** TestParseTime() -- Test PR_ParseTimeString() for y2k compliance\n@@ -808,100 +797,96 @@ static ParseTest parseArray[] = {\n **\n **\n */\n-static PRStatus\n-TestParseTime(void)\n-{\n-    ParseTest* ptp = parseArray;\n-    PRTime ct;\n-    PRExplodedTime cet;\n-    char* sp = ptp->sDate;\n-    PRStatus rc;\n-    PRStatus rv = PR_SUCCESS;\n-\n-    while (sp != NULL) {\n-        rc = PR_ParseTimeString(sp, PR_FALSE, &ct);\n-        if (PR_FAILURE == rc) {\n-            printf(\"TestParseTime(): PR_ParseTimeString() failed to convert: %s\\n\",\n-                   sp);\n-            rv = PR_FAILURE;\n-            failed_already = 1;\n-        } else {\n-            PR_ExplodeTime(ct, PR_LocalTimeParameters, &cet);\n-\n-            if (!ExplodedTimeIsEqual(&cet, &ptp->et)) {\n-                printf(\"TestParseTime(): Exploded time compare failed: %s\\n\", sp);\n-                if (debug_mode) {\n-                    PrintExplodedTime(&cet);\n-                    printf(\"\\n\");\n-                    PrintExplodedTime(&ptp->et);\n-                    printf(\"\\n\");\n-                }\n-\n-                rv = PR_FAILURE;\n-                failed_already = 1;\n-            }\n-        }\n-\n-        /* point to next element in array, keep going */\n-        ptp++;\n-        sp = ptp->sDate;\n-    } /* end while() */\n-\n-    return (rv);\n-} /* end TestParseTime() */\n+static PRStatus TestParseTime(void) {\n+  ParseTest* ptp = parseArray;\n+  PRTime ct;\n+  PRExplodedTime cet;\n+  char* sp = ptp->sDate;\n+  PRStatus rc;\n+  PRStatus rv = PR_SUCCESS;\n+\n+  while (sp != NULL) {\n+    rc = PR_ParseTimeString(sp, PR_FALSE, &ct);\n+    if (PR_FAILURE == rc) {\n+      printf(\"TestParseTime(): PR_ParseTimeString() failed to convert: %s\\n\",\n+             sp);\n+      rv = PR_FAILURE;\n+      failed_already = 1;\n+    } else {\n+      PR_ExplodeTime(ct, PR_LocalTimeParameters, &cet);\n \n-int\n-main(int argc, char** argv)\n-{\n-    /* The command line argument: -d is used to determine if the test is being run\n-    in debug mode. The regress tool requires only one line output:PASS or FAIL.\n-    All of the printfs associated with this test has been handled with a if\n-    (debug_mode) test. Usage: test_name -d\n-    */\n-    PLOptStatus os;\n-    PLOptState* opt;\n-\n-    opt = PL_CreateOptState(argc, argv, \"d\");\n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            default:\n-                break;\n+      if (!ExplodedTimeIsEqual(&cet, &ptp->et)) {\n+        printf(\"TestParseTime(): Exploded time compare failed: %s\\n\", sp);\n+        if (debug_mode) {\n+          PrintExplodedTime(&cet);\n+          printf(\"\\n\");\n+          PrintExplodedTime(&ptp->et);\n+          printf(\"\\n\");\n         }\n-    }\n-    PL_DestroyOptState(opt);\n-\n-    /* main test */\n \n-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n-    lm = PR_NewLogModule(\"test\");\n-\n-    if (PR_FAILURE == TestExplodeImplodeTime()) {\n-        PR_LOG(lm, PR_LOG_ERROR, (\"TestExplodeImplodeTime() failed\"));\n-    } else {\n-        printf(\"Test 1: Calendar Time Test passed\\n\");\n+        rv = PR_FAILURE;\n+        failed_already = 1;\n+      }\n     }\n \n-    if (PR_FAILURE == TestNormalizeTime()) {\n-        PR_LOG(lm, PR_LOG_ERROR, (\"TestNormalizeTime() failed\"));\n-    } else {\n-        printf(\"Test 2: Normalize Time Test passed\\n\");\n-    }\n+    /* point to next element in array, keep going */\n+    ptp++;\n+    sp = ptp->sDate;\n+  } /* end while() */\n \n-    if (PR_FAILURE == TestParseTime()) {\n-        PR_LOG(lm, PR_LOG_ERROR, (\"TestParseTime() failed\"));\n-    } else {\n-        printf(\"Test 3: Parse Time Test passed\\n\");\n-    }\n+  return (rv);\n+} /* end TestParseTime() */\n \n-    if (failed_already) {\n-        return 1;\n-    } else {\n-        return 0;\n+int main(int argc, char** argv) {\n+  /* The command line argument: -d is used to determine if the test is being run\n+  in debug mode. The regress tool requires only one line output:PASS or FAIL.\n+  All of the printfs associated with this test has been handled with a if\n+  (debug_mode) test. Usage: test_name -d\n+  */\n+  PLOptStatus os;\n+  PLOptState* opt;\n+\n+  opt = PL_CreateOptState(argc, argv, \"d\");\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      default:\n+        break;\n     }\n+  }\n+  PL_DestroyOptState(opt);\n+\n+  /* main test */\n+\n+  PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);\n+  lm = PR_NewLogModule(\"test\");\n+\n+  if (PR_FAILURE == TestExplodeImplodeTime()) {\n+    PR_LOG(lm, PR_LOG_ERROR, (\"TestExplodeImplodeTime() failed\"));\n+  } else {\n+    printf(\"Test 1: Calendar Time Test passed\\n\");\n+  }\n+\n+  if (PR_FAILURE == TestNormalizeTime()) {\n+    PR_LOG(lm, PR_LOG_ERROR, (\"TestNormalizeTime() failed\"));\n+  } else {\n+    printf(\"Test 2: Normalize Time Test passed\\n\");\n+  }\n+\n+  if (PR_FAILURE == TestParseTime()) {\n+    PR_LOG(lm, PR_LOG_ERROR, (\"TestParseTime() failed\"));\n+  } else {\n+    printf(\"Test 3: Parse Time Test passed\\n\");\n+  }\n+\n+  if (failed_already) {\n+    return 1;\n+  } else {\n+    return 0;\n+  }\n } /* end main() y2k.c */\ndiff --git a/nspr/pr/tests/y2ktmo.c b/nspr/pr/tests/y2ktmo.c\nindex 625ed02..c6eb761 100644\n--- a/nspr/pr/tests/y2ktmo.c\n+++ b/nspr/pr/tests/y2ktmo.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -36,15 +37,15 @@\n #include <stdlib.h>\n #include <string.h>\n #if defined(XP_UNIX)\n-#include <sys/time.h> /* for gettimeofday */\n+#  include <sys/time.h> /* for gettimeofday */\n #endif\n #if defined(WIN32)\n-#if defined(WINCE)\n-#include <windows.h>\n-#else\n-#include <sys/types.h>\n-#include <sys/timeb.h> /* for _ftime */\n-#endif\n+#  if defined(WINCE)\n+#    include <windows.h>\n+#  else\n+#    include <sys/types.h>\n+#    include <sys/timeb.h> /* for _ftime */\n+#  endif\n #endif\n \n #define DEFAULT_LEAD_TIME_SECS 5\n@@ -60,499 +61,483 @@ static PRIntervalTime tolerance;\n static struct timeval start_time_tv;\n #endif\n #if defined(WIN32)\n-#if defined(WINCE)\n+#  if defined(WINCE)\n static DWORD start_time_tick;\n-#else\n+#  else\n static struct _timeb start_time_tb;\n-#endif\n+#  endif\n #endif\n \n-static void\n-SleepThread(void* arg)\n-{\n-    PRIntervalTime timeout = (PRIntervalTime)arg;\n-    PRIntervalTime elapsed;\n+static void SleepThread(void* arg) {\n+  PRIntervalTime timeout = (PRIntervalTime)arg;\n+  PRIntervalTime elapsed;\n #if defined(XP_UNIX) || defined(WIN32)\n-    PRInt32 timeout_msecs = PR_IntervalToMilliseconds(timeout);\n-    PRInt32 elapsed_msecs;\n+  PRInt32 timeout_msecs = PR_IntervalToMilliseconds(timeout);\n+  PRInt32 elapsed_msecs;\n #endif\n #if defined(XP_UNIX)\n-    struct timeval end_time_tv;\n+  struct timeval end_time_tv;\n #endif\n #if defined(WIN32) && !defined(WINCE)\n-    struct _timeb end_time_tb;\n+  struct _timeb end_time_tb;\n #endif\n \n-    if (PR_Sleep(timeout) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Sleep failed\\n\");\n-        exit(1);\n-    }\n-    elapsed = (PRIntervalTime)(PR_IntervalNow() - start_time);\n-    if (elapsed + tolerance < timeout || elapsed > timeout + tolerance) {\n-        fprintf(stderr, \"timeout wrong\\n\");\n-        exit(1);\n-    }\n+  if (PR_Sleep(timeout) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Sleep failed\\n\");\n+    exit(1);\n+  }\n+  elapsed = (PRIntervalTime)(PR_IntervalNow() - start_time);\n+  if (elapsed + tolerance < timeout || elapsed > timeout + tolerance) {\n+    fprintf(stderr, \"timeout wrong\\n\");\n+    exit(1);\n+  }\n #if defined(XP_UNIX)\n-    gettimeofday(&end_time_tv, NULL);\n-    elapsed_msecs = 1000 * (end_time_tv.tv_sec - start_time_tv.tv_sec) +\n-                    (end_time_tv.tv_usec - start_time_tv.tv_usec) / 1000;\n+  gettimeofday(&end_time_tv, NULL);\n+  elapsed_msecs = 1000 * (end_time_tv.tv_sec - start_time_tv.tv_sec) +\n+                  (end_time_tv.tv_usec - start_time_tv.tv_usec) / 1000;\n #endif\n #if defined(WIN32)\n-#if defined(WINCE)\n-    elapsed_msecs = GetTickCount() - start_time_tick;\n-#else\n-    _ftime(&end_time_tb);\n-    elapsed_msecs = 1000 * (end_time_tb.time - start_time_tb.time) +\n-                    (end_time_tb.millitm - start_time_tb.millitm);\n-#endif\n+#  if defined(WINCE)\n+  elapsed_msecs = GetTickCount() - start_time_tick;\n+#  else\n+  _ftime(&end_time_tb);\n+  elapsed_msecs = 1000 * (end_time_tb.time - start_time_tb.time) +\n+                  (end_time_tb.millitm - start_time_tb.millitm);\n+#  endif\n #endif\n #if defined(XP_UNIX) || defined(WIN32)\n-    if (elapsed_msecs + tolerance_msecs < timeout_msecs ||\n-        elapsed_msecs > timeout_msecs + tolerance_msecs) {\n-        fprintf(stderr, \"timeout wrong\\n\");\n-        exit(1);\n-    }\n-#endif\n-    if (debug_mode) {\n-        fprintf(stderr, \"Sleep thread (scope %d) done\\n\",\n-                PR_GetThreadScope(PR_GetCurrentThread()));\n-    }\n+  if (elapsed_msecs + tolerance_msecs < timeout_msecs ||\n+      elapsed_msecs > timeout_msecs + tolerance_msecs) {\n+    fprintf(stderr, \"timeout wrong\\n\");\n+    exit(1);\n+  }\n+#endif\n+  if (debug_mode) {\n+    fprintf(stderr, \"Sleep thread (scope %d) done\\n\",\n+            PR_GetThreadScope(PR_GetCurrentThread()));\n+  }\n }\n \n-static void\n-AcceptThread(void* arg)\n-{\n-    PRIntervalTime timeout = (PRIntervalTime)arg;\n-    PRIntervalTime elapsed;\n+static void AcceptThread(void* arg) {\n+  PRIntervalTime timeout = (PRIntervalTime)arg;\n+  PRIntervalTime elapsed;\n #if defined(XP_UNIX) || defined(WIN32)\n-    PRInt32 timeout_msecs = PR_IntervalToMilliseconds(timeout);\n-    PRInt32 elapsed_msecs;\n+  PRInt32 timeout_msecs = PR_IntervalToMilliseconds(timeout);\n+  PRInt32 elapsed_msecs;\n #endif\n #if defined(XP_UNIX)\n-    struct timeval end_time_tv;\n+  struct timeval end_time_tv;\n #endif\n #if defined(WIN32) && !defined(WINCE)\n-    struct _timeb end_time_tb;\n+  struct _timeb end_time_tb;\n #endif\n-    PRFileDesc* sock;\n-    PRNetAddr addr;\n-    PRFileDesc* accepted;\n+  PRFileDesc* sock;\n+  PRNetAddr addr;\n+  PRFileDesc* accepted;\n \n-    sock = PR_NewTCPSocket();\n-    if (sock == NULL) {\n-        fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-        exit(1);\n-    }\n-    memset(&addr, 0, sizeof(addr));\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.port = 0;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    if (PR_Bind(sock, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Bind failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Listen(sock, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Listen failed\\n\");\n-        exit(1);\n-    }\n-    accepted = PR_Accept(sock, NULL, timeout);\n-    if (accepted != NULL || PR_GetError() != PR_IO_TIMEOUT_ERROR) {\n-        fprintf(stderr, \"PR_Accept did not time out\\n\");\n-        exit(1);\n-    }\n-    elapsed = (PRIntervalTime)(PR_IntervalNow() - start_time);\n-    if (elapsed + tolerance < timeout || elapsed > timeout + tolerance) {\n-        fprintf(stderr, \"timeout wrong\\n\");\n-        exit(1);\n-    }\n+  sock = PR_NewTCPSocket();\n+  if (sock == NULL) {\n+    fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+    exit(1);\n+  }\n+  memset(&addr, 0, sizeof(addr));\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.port = 0;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  if (PR_Bind(sock, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Bind failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Listen(sock, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Listen failed\\n\");\n+    exit(1);\n+  }\n+  accepted = PR_Accept(sock, NULL, timeout);\n+  if (accepted != NULL || PR_GetError() != PR_IO_TIMEOUT_ERROR) {\n+    fprintf(stderr, \"PR_Accept did not time out\\n\");\n+    exit(1);\n+  }\n+  elapsed = (PRIntervalTime)(PR_IntervalNow() - start_time);\n+  if (elapsed + tolerance < timeout || elapsed > timeout + tolerance) {\n+    fprintf(stderr, \"timeout wrong\\n\");\n+    exit(1);\n+  }\n #if defined(XP_UNIX)\n-    gettimeofday(&end_time_tv, NULL);\n-    elapsed_msecs = 1000 * (end_time_tv.tv_sec - start_time_tv.tv_sec) +\n-                    (end_time_tv.tv_usec - start_time_tv.tv_usec) / 1000;\n+  gettimeofday(&end_time_tv, NULL);\n+  elapsed_msecs = 1000 * (end_time_tv.tv_sec - start_time_tv.tv_sec) +\n+                  (end_time_tv.tv_usec - start_time_tv.tv_usec) / 1000;\n #endif\n #if defined(WIN32)\n-#if defined(WINCE)\n-    elapsed_msecs = GetTickCount() - start_time_tick;\n-#else\n-    _ftime(&end_time_tb);\n-    elapsed_msecs = 1000 * (end_time_tb.time - start_time_tb.time) +\n-                    (end_time_tb.millitm - start_time_tb.millitm);\n-#endif\n+#  if defined(WINCE)\n+  elapsed_msecs = GetTickCount() - start_time_tick;\n+#  else\n+  _ftime(&end_time_tb);\n+  elapsed_msecs = 1000 * (end_time_tb.time - start_time_tb.time) +\n+                  (end_time_tb.millitm - start_time_tb.millitm);\n+#  endif\n #endif\n #if defined(XP_UNIX) || defined(WIN32)\n-    if (elapsed_msecs + tolerance_msecs < timeout_msecs ||\n-        elapsed_msecs > timeout_msecs + tolerance_msecs) {\n-        fprintf(stderr, \"timeout wrong\\n\");\n-        exit(1);\n-    }\n-#endif\n-    if (PR_Close(sock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    if (debug_mode) {\n-        fprintf(stderr, \"Accept thread (scope %d) done\\n\",\n-                PR_GetThreadScope(PR_GetCurrentThread()));\n-    }\n+  if (elapsed_msecs + tolerance_msecs < timeout_msecs ||\n+      elapsed_msecs > timeout_msecs + tolerance_msecs) {\n+    fprintf(stderr, \"timeout wrong\\n\");\n+    exit(1);\n+  }\n+#endif\n+  if (PR_Close(sock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  if (debug_mode) {\n+    fprintf(stderr, \"Accept thread (scope %d) done\\n\",\n+            PR_GetThreadScope(PR_GetCurrentThread()));\n+  }\n }\n \n-static void\n-PollThread(void* arg)\n-{\n-    PRIntervalTime timeout = (PRIntervalTime)arg;\n-    PRIntervalTime elapsed;\n+static void PollThread(void* arg) {\n+  PRIntervalTime timeout = (PRIntervalTime)arg;\n+  PRIntervalTime elapsed;\n #if defined(XP_UNIX) || defined(WIN32)\n-    PRInt32 timeout_msecs = PR_IntervalToMilliseconds(timeout);\n-    PRInt32 elapsed_msecs;\n+  PRInt32 timeout_msecs = PR_IntervalToMilliseconds(timeout);\n+  PRInt32 elapsed_msecs;\n #endif\n #if defined(XP_UNIX)\n-    struct timeval end_time_tv;\n+  struct timeval end_time_tv;\n #endif\n #if defined(WIN32) && !defined(WINCE)\n-    struct _timeb end_time_tb;\n+  struct _timeb end_time_tb;\n #endif\n-    PRFileDesc* sock;\n-    PRNetAddr addr;\n-    PRPollDesc pd;\n-    PRIntn rv;\n+  PRFileDesc* sock;\n+  PRNetAddr addr;\n+  PRPollDesc pd;\n+  PRIntn rv;\n \n-    sock = PR_NewTCPSocket();\n-    if (sock == NULL) {\n-        fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-        exit(1);\n-    }\n-    memset(&addr, 0, sizeof(addr));\n-    addr.inet.family = PR_AF_INET;\n-    addr.inet.port = 0;\n-    addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n-    if (PR_Bind(sock, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Bind failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Listen(sock, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Listen failed\\n\");\n-        exit(1);\n-    }\n-    pd.fd = sock;\n-    pd.in_flags = PR_POLL_READ;\n-    rv = PR_Poll(&pd, 1, timeout);\n-    if (rv != 0) {\n-        fprintf(stderr, \"PR_Poll did not time out\\n\");\n-        exit(1);\n-    }\n-    elapsed = (PRIntervalTime)(PR_IntervalNow() - start_time);\n-    if (elapsed + tolerance < timeout || elapsed > timeout + tolerance) {\n-        fprintf(stderr, \"timeout wrong\\n\");\n-        exit(1);\n-    }\n+  sock = PR_NewTCPSocket();\n+  if (sock == NULL) {\n+    fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+    exit(1);\n+  }\n+  memset(&addr, 0, sizeof(addr));\n+  addr.inet.family = PR_AF_INET;\n+  addr.inet.port = 0;\n+  addr.inet.ip = PR_htonl(PR_INADDR_ANY);\n+  if (PR_Bind(sock, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Bind failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Listen(sock, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Listen failed\\n\");\n+    exit(1);\n+  }\n+  pd.fd = sock;\n+  pd.in_flags = PR_POLL_READ;\n+  rv = PR_Poll(&pd, 1, timeout);\n+  if (rv != 0) {\n+    fprintf(stderr, \"PR_Poll did not time out\\n\");\n+    exit(1);\n+  }\n+  elapsed = (PRIntervalTime)(PR_IntervalNow() - start_time);\n+  if (elapsed + tolerance < timeout || elapsed > timeout + tolerance) {\n+    fprintf(stderr, \"timeout wrong\\n\");\n+    exit(1);\n+  }\n #if defined(XP_UNIX)\n-    gettimeofday(&end_time_tv, NULL);\n-    elapsed_msecs = 1000 * (end_time_tv.tv_sec - start_time_tv.tv_sec) +\n-                    (end_time_tv.tv_usec - start_time_tv.tv_usec) / 1000;\n+  gettimeofday(&end_time_tv, NULL);\n+  elapsed_msecs = 1000 * (end_time_tv.tv_sec - start_time_tv.tv_sec) +\n+                  (end_time_tv.tv_usec - start_time_tv.tv_usec) / 1000;\n #endif\n #if defined(WIN32)\n-#if defined(WINCE)\n-    elapsed_msecs = GetTickCount() - start_time_tick;\n-#else\n-    _ftime(&end_time_tb);\n-    elapsed_msecs = 1000 * (end_time_tb.time - start_time_tb.time) +\n-                    (end_time_tb.millitm - start_time_tb.millitm);\n-#endif\n+#  if defined(WINCE)\n+  elapsed_msecs = GetTickCount() - start_time_tick;\n+#  else\n+  _ftime(&end_time_tb);\n+  elapsed_msecs = 1000 * (end_time_tb.time - start_time_tb.time) +\n+                  (end_time_tb.millitm - start_time_tb.millitm);\n+#  endif\n #endif\n #if defined(XP_UNIX) || defined(WIN32)\n-    if (elapsed_msecs + tolerance_msecs < timeout_msecs ||\n-        elapsed_msecs > timeout_msecs + tolerance_msecs) {\n-        fprintf(stderr, \"timeout wrong\\n\");\n-        exit(1);\n-    }\n-#endif\n-    if (PR_Close(sock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    if (debug_mode) {\n-        fprintf(stderr, \"Poll thread (scope %d) done\\n\",\n-                PR_GetThreadScope(PR_GetCurrentThread()));\n-    }\n+  if (elapsed_msecs + tolerance_msecs < timeout_msecs ||\n+      elapsed_msecs > timeout_msecs + tolerance_msecs) {\n+    fprintf(stderr, \"timeout wrong\\n\");\n+    exit(1);\n+  }\n+#endif\n+  if (PR_Close(sock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  if (debug_mode) {\n+    fprintf(stderr, \"Poll thread (scope %d) done\\n\",\n+            PR_GetThreadScope(PR_GetCurrentThread()));\n+  }\n }\n \n-static void\n-WaitCondVarThread(void* arg)\n-{\n-    PRIntervalTime timeout = (PRIntervalTime)arg;\n-    PRIntervalTime elapsed;\n+static void WaitCondVarThread(void* arg) {\n+  PRIntervalTime timeout = (PRIntervalTime)arg;\n+  PRIntervalTime elapsed;\n #if defined(XP_UNIX) || defined(WIN32)\n-    PRInt32 timeout_msecs = PR_IntervalToMilliseconds(timeout);\n-    PRInt32 elapsed_msecs;\n+  PRInt32 timeout_msecs = PR_IntervalToMilliseconds(timeout);\n+  PRInt32 elapsed_msecs;\n #endif\n #if defined(XP_UNIX)\n-    struct timeval end_time_tv;\n+  struct timeval end_time_tv;\n #endif\n #if defined(WIN32) && !defined(WINCE)\n-    struct _timeb end_time_tb;\n+  struct _timeb end_time_tb;\n #endif\n-    PRLock* ml;\n-    PRCondVar* cv;\n+  PRLock* ml;\n+  PRCondVar* cv;\n \n-    ml = PR_NewLock();\n-    if (ml == NULL) {\n-        fprintf(stderr, \"PR_NewLock failed\\n\");\n-        exit(1);\n-    }\n-    cv = PR_NewCondVar(ml);\n-    if (cv == NULL) {\n-        fprintf(stderr, \"PR_NewCondVar failed\\n\");\n-        exit(1);\n-    }\n-    PR_Lock(ml);\n-    PR_WaitCondVar(cv, timeout);\n-    PR_Unlock(ml);\n-    elapsed = (PRIntervalTime)(PR_IntervalNow() - start_time);\n-    if (elapsed + tolerance < timeout || elapsed > timeout + tolerance) {\n-        fprintf(stderr, \"timeout wrong\\n\");\n-        exit(1);\n-    }\n+  ml = PR_NewLock();\n+  if (ml == NULL) {\n+    fprintf(stderr, \"PR_NewLock failed\\n\");\n+    exit(1);\n+  }\n+  cv = PR_NewCondVar(ml);\n+  if (cv == NULL) {\n+    fprintf(stderr, \"PR_NewCondVar failed\\n\");\n+    exit(1);\n+  }\n+  PR_Lock(ml);\n+  PR_WaitCondVar(cv, timeout);\n+  PR_Unlock(ml);\n+  elapsed = (PRIntervalTime)(PR_IntervalNow() - start_time);\n+  if (elapsed + tolerance < timeout || elapsed > timeout + tolerance) {\n+    fprintf(stderr, \"timeout wrong\\n\");\n+    exit(1);\n+  }\n #if defined(XP_UNIX)\n-    gettimeofday(&end_time_tv, NULL);\n-    elapsed_msecs = 1000 * (end_time_tv.tv_sec - start_time_tv.tv_sec) +\n-                    (end_time_tv.tv_usec - start_time_tv.tv_usec) / 1000;\n+  gettimeofday(&end_time_tv, NULL);\n+  elapsed_msecs = 1000 * (end_time_tv.tv_sec - start_time_tv.tv_sec) +\n+                  (end_time_tv.tv_usec - start_time_tv.tv_usec) / 1000;\n #endif\n #if defined(WIN32)\n-#if defined(WINCE)\n-    elapsed_msecs = GetTickCount() - start_time_tick;\n-#else\n-    _ftime(&end_time_tb);\n-    elapsed_msecs = 1000 * (end_time_tb.time - start_time_tb.time) +\n-                    (end_time_tb.millitm - start_time_tb.millitm);\n-#endif\n+#  if defined(WINCE)\n+  elapsed_msecs = GetTickCount() - start_time_tick;\n+#  else\n+  _ftime(&end_time_tb);\n+  elapsed_msecs = 1000 * (end_time_tb.time - start_time_tb.time) +\n+                  (end_time_tb.millitm - start_time_tb.millitm);\n+#  endif\n #endif\n #if defined(XP_UNIX) || defined(WIN32)\n-    if (elapsed_msecs + tolerance_msecs < timeout_msecs ||\n-        elapsed_msecs > timeout_msecs + tolerance_msecs) {\n-        fprintf(stderr, \"timeout wrong\\n\");\n-        exit(1);\n-    }\n-#endif\n-    PR_DestroyCondVar(cv);\n-    PR_DestroyLock(ml);\n-    if (debug_mode) {\n-        fprintf(stderr, \"wait cond var thread (scope %d) done\\n\",\n-                PR_GetThreadScope(PR_GetCurrentThread()));\n-    }\n+  if (elapsed_msecs + tolerance_msecs < timeout_msecs ||\n+      elapsed_msecs > timeout_msecs + tolerance_msecs) {\n+    fprintf(stderr, \"timeout wrong\\n\");\n+    exit(1);\n+  }\n+#endif\n+  PR_DestroyCondVar(cv);\n+  PR_DestroyLock(ml);\n+  if (debug_mode) {\n+    fprintf(stderr, \"wait cond var thread (scope %d) done\\n\",\n+            PR_GetThreadScope(PR_GetCurrentThread()));\n+  }\n }\n \n-static void\n-WaitMonitorThread(void* arg)\n-{\n-    PRIntervalTime timeout = (PRIntervalTime)arg;\n-    PRIntervalTime elapsed;\n+static void WaitMonitorThread(void* arg) {\n+  PRIntervalTime timeout = (PRIntervalTime)arg;\n+  PRIntervalTime elapsed;\n #if defined(XP_UNIX) || defined(WIN32)\n-    PRInt32 timeout_msecs = PR_IntervalToMilliseconds(timeout);\n-    PRInt32 elapsed_msecs;\n+  PRInt32 timeout_msecs = PR_IntervalToMilliseconds(timeout);\n+  PRInt32 elapsed_msecs;\n #endif\n #if defined(XP_UNIX)\n-    struct timeval end_time_tv;\n+  struct timeval end_time_tv;\n #endif\n #if defined(WIN32) && !defined(WINCE)\n-    struct _timeb end_time_tb;\n+  struct _timeb end_time_tb;\n #endif\n-    PRMonitor* mon;\n+  PRMonitor* mon;\n \n-    mon = PR_NewMonitor();\n-    if (mon == NULL) {\n-        fprintf(stderr, \"PR_NewMonitor failed\\n\");\n-        exit(1);\n-    }\n-    PR_EnterMonitor(mon);\n-    PR_Wait(mon, timeout);\n-    PR_ExitMonitor(mon);\n-    elapsed = (PRIntervalTime)(PR_IntervalNow() - start_time);\n-    if (elapsed + tolerance < timeout || elapsed > timeout + tolerance) {\n-        fprintf(stderr, \"timeout wrong\\n\");\n-        exit(1);\n-    }\n+  mon = PR_NewMonitor();\n+  if (mon == NULL) {\n+    fprintf(stderr, \"PR_NewMonitor failed\\n\");\n+    exit(1);\n+  }\n+  PR_EnterMonitor(mon);\n+  PR_Wait(mon, timeout);\n+  PR_ExitMonitor(mon);\n+  elapsed = (PRIntervalTime)(PR_IntervalNow() - start_time);\n+  if (elapsed + tolerance < timeout || elapsed > timeout + tolerance) {\n+    fprintf(stderr, \"timeout wrong\\n\");\n+    exit(1);\n+  }\n #if defined(XP_UNIX)\n-    gettimeofday(&end_time_tv, NULL);\n-    elapsed_msecs = 1000 * (end_time_tv.tv_sec - start_time_tv.tv_sec) +\n-                    (end_time_tv.tv_usec - start_time_tv.tv_usec) / 1000;\n+  gettimeofday(&end_time_tv, NULL);\n+  elapsed_msecs = 1000 * (end_time_tv.tv_sec - start_time_tv.tv_sec) +\n+                  (end_time_tv.tv_usec - start_time_tv.tv_usec) / 1000;\n #endif\n #if defined(WIN32)\n-#if defined(WINCE)\n-    elapsed_msecs = GetTickCount() - start_time_tick;\n-#else\n-    _ftime(&end_time_tb);\n-    elapsed_msecs = 1000 * (end_time_tb.time - start_time_tb.time) +\n-                    (end_time_tb.millitm - start_time_tb.millitm);\n-#endif\n+#  if defined(WINCE)\n+  elapsed_msecs = GetTickCount() - start_time_tick;\n+#  else\n+  _ftime(&end_time_tb);\n+  elapsed_msecs = 1000 * (end_time_tb.time - start_time_tb.time) +\n+                  (end_time_tb.millitm - start_time_tb.millitm);\n+#  endif\n #endif\n #if defined(XP_UNIX) || defined(WIN32)\n-    if (elapsed_msecs + tolerance_msecs < timeout_msecs ||\n-        elapsed_msecs > timeout_msecs + tolerance_msecs) {\n-        fprintf(stderr, \"timeout wrong\\n\");\n-        exit(1);\n-    }\n-#endif\n-    PR_DestroyMonitor(mon);\n-    if (debug_mode) {\n-        fprintf(stderr, \"wait monitor thread (scope %d) done\\n\",\n-                PR_GetThreadScope(PR_GetCurrentThread()));\n-    }\n+  if (elapsed_msecs + tolerance_msecs < timeout_msecs ||\n+      elapsed_msecs > timeout_msecs + tolerance_msecs) {\n+    fprintf(stderr, \"timeout wrong\\n\");\n+    exit(1);\n+  }\n+#endif\n+  PR_DestroyMonitor(mon);\n+  if (debug_mode) {\n+    fprintf(stderr, \"wait monitor thread (scope %d) done\\n\",\n+            PR_GetThreadScope(PR_GetCurrentThread()));\n+  }\n }\n \n-static void\n-WaitCMonitorThread(void* arg)\n-{\n-    PRIntervalTime timeout = (PRIntervalTime)arg;\n-    PRIntervalTime elapsed;\n+static void WaitCMonitorThread(void* arg) {\n+  PRIntervalTime timeout = (PRIntervalTime)arg;\n+  PRIntervalTime elapsed;\n #if defined(XP_UNIX) || defined(WIN32)\n-    PRInt32 timeout_msecs = PR_IntervalToMilliseconds(timeout);\n-    PRInt32 elapsed_msecs;\n+  PRInt32 timeout_msecs = PR_IntervalToMilliseconds(timeout);\n+  PRInt32 elapsed_msecs;\n #endif\n #if defined(XP_UNIX)\n-    struct timeval end_time_tv;\n+  struct timeval end_time_tv;\n #endif\n #if defined(WIN32) && !defined(WINCE)\n-    struct _timeb end_time_tb;\n+  struct _timeb end_time_tb;\n #endif\n-    int dummy;\n+  int dummy;\n \n-    PR_CEnterMonitor(&dummy);\n-    PR_CWait(&dummy, timeout);\n-    PR_CExitMonitor(&dummy);\n-    elapsed = (PRIntervalTime)(PR_IntervalNow() - start_time);\n-    if (elapsed + tolerance < timeout || elapsed > timeout + tolerance) {\n-        fprintf(stderr, \"timeout wrong\\n\");\n-        exit(1);\n-    }\n+  PR_CEnterMonitor(&dummy);\n+  PR_CWait(&dummy, timeout);\n+  PR_CExitMonitor(&dummy);\n+  elapsed = (PRIntervalTime)(PR_IntervalNow() - start_time);\n+  if (elapsed + tolerance < timeout || elapsed > timeout + tolerance) {\n+    fprintf(stderr, \"timeout wrong\\n\");\n+    exit(1);\n+  }\n #if defined(XP_UNIX)\n-    gettimeofday(&end_time_tv, NULL);\n-    elapsed_msecs = 1000 * (end_time_tv.tv_sec - start_time_tv.tv_sec) +\n-                    (end_time_tv.tv_usec - start_time_tv.tv_usec) / 1000;\n+  gettimeofday(&end_time_tv, NULL);\n+  elapsed_msecs = 1000 * (end_time_tv.tv_sec - start_time_tv.tv_sec) +\n+                  (end_time_tv.tv_usec - start_time_tv.tv_usec) / 1000;\n #endif\n #if defined(WIN32)\n-#if defined(WINCE)\n-    elapsed_msecs = GetTickCount() - start_time_tick;\n-#else\n-    _ftime(&end_time_tb);\n-    elapsed_msecs = 1000 * (end_time_tb.time - start_time_tb.time) +\n-                    (end_time_tb.millitm - start_time_tb.millitm);\n-#endif\n+#  if defined(WINCE)\n+  elapsed_msecs = GetTickCount() - start_time_tick;\n+#  else\n+  _ftime(&end_time_tb);\n+  elapsed_msecs = 1000 * (end_time_tb.time - start_time_tb.time) +\n+                  (end_time_tb.millitm - start_time_tb.millitm);\n+#  endif\n #endif\n #if defined(XP_UNIX) || defined(WIN32)\n-    if (elapsed_msecs + tolerance_msecs < timeout_msecs ||\n-        elapsed_msecs > timeout_msecs + tolerance_msecs) {\n-        fprintf(stderr, \"timeout wrong\\n\");\n-        exit(1);\n-    }\n-#endif\n-    if (debug_mode) {\n-        fprintf(stderr, \"wait cached monitor thread (scope %d) done\\n\",\n-                PR_GetThreadScope(PR_GetCurrentThread()));\n-    }\n+  if (elapsed_msecs + tolerance_msecs < timeout_msecs ||\n+      elapsed_msecs > timeout_msecs + tolerance_msecs) {\n+    fprintf(stderr, \"timeout wrong\\n\");\n+    exit(1);\n+  }\n+#endif\n+  if (debug_mode) {\n+    fprintf(stderr, \"wait cached monitor thread (scope %d) done\\n\",\n+            PR_GetThreadScope(PR_GetCurrentThread()));\n+  }\n }\n \n typedef void (*NSPRThreadFunc)(void*);\n \n-static NSPRThreadFunc threadFuncs[] = { SleepThread, AcceptThread,\n-                                        PollThread, WaitCondVarThread,\n-                                        WaitMonitorThread, WaitCMonitorThread };\n+static NSPRThreadFunc threadFuncs[] = {SleepThread,       AcceptThread,\n+                                       PollThread,        WaitCondVarThread,\n+                                       WaitMonitorThread, WaitCMonitorThread};\n \n-static PRThreadScope threadScopes[] = { PR_LOCAL_THREAD, PR_GLOBAL_THREAD,\n-                                        PR_GLOBAL_BOUND_THREAD };\n+static PRThreadScope threadScopes[] = {PR_LOCAL_THREAD, PR_GLOBAL_THREAD,\n+                                       PR_GLOBAL_BOUND_THREAD};\n \n-static void\n-Help(void)\n-{\n-    fprintf(stderr, \"y2ktmo test program usage:\\n\");\n-    fprintf(stderr, \"\\t-d           debug mode         (FALSE)\\n\");\n-    fprintf(stderr, \"\\t-l <secs>    lead time          (%d)\\n\",\n-            DEFAULT_LEAD_TIME_SECS);\n-    fprintf(stderr, \"\\t-t <msecs>   tolerance          (%d)\\n\",\n-            DEFAULT_TOLERANCE_MSECS);\n-    fprintf(stderr, \"\\t-h           this message\\n\");\n+static void Help(void) {\n+  fprintf(stderr, \"y2ktmo test program usage:\\n\");\n+  fprintf(stderr, \"\\t-d           debug mode         (FALSE)\\n\");\n+  fprintf(stderr, \"\\t-l <secs>    lead time          (%d)\\n\",\n+          DEFAULT_LEAD_TIME_SECS);\n+  fprintf(stderr, \"\\t-t <msecs>   tolerance          (%d)\\n\",\n+          DEFAULT_TOLERANCE_MSECS);\n+  fprintf(stderr, \"\\t-h           this message\\n\");\n } /* Help */\n \n-int\n-main(int argc, char** argv)\n-{\n-    PRThread** threads;\n-    int num_thread_funcs = sizeof(threadFuncs) / sizeof(NSPRThreadFunc);\n-    int num_thread_scopes = sizeof(threadScopes) / sizeof(PRThreadScope);\n-    int i, j;\n-    int idx;\n-    PRInt32 secs;\n-    PLOptStatus os;\n-    PLOptState* opt = PL_CreateOptState(argc, argv, \"dl:t:h\");\n+int main(int argc, char** argv) {\n+  PRThread** threads;\n+  int num_thread_funcs = sizeof(threadFuncs) / sizeof(NSPRThreadFunc);\n+  int num_thread_scopes = sizeof(threadScopes) / sizeof(PRThreadScope);\n+  int i, j;\n+  int idx;\n+  PRInt32 secs;\n+  PLOptStatus os;\n+  PLOptState* opt = PL_CreateOptState(argc, argv, \"dl:t:h\");\n \n-    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n-        if (PL_OPT_BAD == os) {\n-            continue;\n-        }\n-        switch (opt->option) {\n-            case 'd': /* debug mode */\n-                debug_mode = PR_TRUE;\n-                break;\n-            case 'l': /* lead time */\n-                lead_time_secs = atoi(opt->value);\n-                break;\n-            case 't': /* tolerance */\n-                tolerance_msecs = atoi(opt->value);\n-                break;\n-            case 'h':\n-            default:\n-                Help();\n-                return 2;\n-        }\n-    }\n-    PL_DestroyOptState(opt);\n+  while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {\n+    if (PL_OPT_BAD == os) {\n+      continue;\n+    }\n+    switch (opt->option) {\n+      case 'd': /* debug mode */\n+        debug_mode = PR_TRUE;\n+        break;\n+      case 'l': /* lead time */\n+        lead_time_secs = atoi(opt->value);\n+        break;\n+      case 't': /* tolerance */\n+        tolerance_msecs = atoi(opt->value);\n+        break;\n+      case 'h':\n+      default:\n+        Help();\n+        return 2;\n+    }\n+  }\n+  PL_DestroyOptState(opt);\n \n-    if (debug_mode) {\n-        fprintf(stderr, \"lead time: %d secs\\n\", lead_time_secs);\n-        fprintf(stderr, \"tolerance: %d msecs\\n\", tolerance_msecs);\n-    }\n+  if (debug_mode) {\n+    fprintf(stderr, \"lead time: %d secs\\n\", lead_time_secs);\n+    fprintf(stderr, \"tolerance: %d msecs\\n\", tolerance_msecs);\n+  }\n \n-    start_time = PR_IntervalNow();\n+  start_time = PR_IntervalNow();\n #if defined(XP_UNIX)\n-    gettimeofday(&start_time_tv, NULL);\n+  gettimeofday(&start_time_tv, NULL);\n #endif\n #if defined(WIN32)\n-#ifdef WINCE\n-    start_time_tick = GetTickCount();\n-#else\n-    _ftime(&start_time_tb);\n-#endif\n+#  ifdef WINCE\n+  start_time_tick = GetTickCount();\n+#  else\n+  _ftime(&start_time_tb);\n+#  endif\n #endif\n-    tolerance = PR_MillisecondsToInterval(tolerance_msecs);\n+  tolerance = PR_MillisecondsToInterval(tolerance_msecs);\n \n-    threads = PR_Malloc(num_thread_scopes * num_thread_funcs * sizeof(PRThread*));\n-    if (threads == NULL) {\n-        fprintf(stderr, \"PR_Malloc failed\\n\");\n-        exit(1);\n-    }\n+  threads = PR_Malloc(num_thread_scopes * num_thread_funcs * sizeof(PRThread*));\n+  if (threads == NULL) {\n+    fprintf(stderr, \"PR_Malloc failed\\n\");\n+    exit(1);\n+  }\n \n-    /* start to time out 5 seconds after a rollover date */\n-    secs = lead_time_secs + 5;\n-    idx = 0;\n-    for (i = 0; i < num_thread_scopes; i++) {\n-        for (j = 0; j < num_thread_funcs; j++) {\n-            threads[idx] = PR_CreateThread(\n-                PR_USER_THREAD, threadFuncs[j], (void*)PR_SecondsToInterval(secs),\n-                PR_PRIORITY_NORMAL, threadScopes[i], PR_JOINABLE_THREAD, 0);\n-            if (threads[idx] == NULL) {\n-                fprintf(stderr, \"PR_CreateThread failed\\n\");\n-                exit(1);\n-            }\n-            secs++;\n-            idx++;\n-        }\n-    }\n-    for (idx = 0; idx < num_thread_scopes * num_thread_funcs; idx++) {\n-        if (PR_JoinThread(threads[idx]) == PR_FAILURE) {\n-            fprintf(stderr, \"PR_JoinThread failed\\n\");\n-            exit(1);\n-        }\n-    }\n-    PR_Free(threads);\n-    printf(\"PASS\\n\");\n-    return 0;\n+  /* start to time out 5 seconds after a rollover date */\n+  secs = lead_time_secs + 5;\n+  idx = 0;\n+  for (i = 0; i < num_thread_scopes; i++) {\n+    for (j = 0; j < num_thread_funcs; j++) {\n+      threads[idx] = PR_CreateThread(\n+          PR_USER_THREAD, threadFuncs[j], (void*)PR_SecondsToInterval(secs),\n+          PR_PRIORITY_NORMAL, threadScopes[i], PR_JOINABLE_THREAD, 0);\n+      if (threads[idx] == NULL) {\n+        fprintf(stderr, \"PR_CreateThread failed\\n\");\n+        exit(1);\n+      }\n+      secs++;\n+      idx++;\n+    }\n+  }\n+  for (idx = 0; idx < num_thread_scopes * num_thread_funcs; idx++) {\n+    if (PR_JoinThread(threads[idx]) == PR_FAILURE) {\n+      fprintf(stderr, \"PR_JoinThread failed\\n\");\n+      exit(1);\n+    }\n+  }\n+  PR_Free(threads);\n+  printf(\"PASS\\n\");\n+  return 0;\n }\ndiff --git a/nspr/pr/tests/zerolen.c b/nspr/pr/tests/zerolen.c\nindex 390cb8e..22df5a8 100644\n--- a/nspr/pr/tests/zerolen.c\n+++ b/nspr/pr/tests/zerolen.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n@@ -21,232 +22,226 @@\n \n #ifndef XP_UNIX\n \n-#include <stdio.h>\n+#  include <stdio.h>\n \n-int\n-main(int argc, char** argv)\n-{\n-    printf(\"PASS\\n\");\n-    return 0;\n+int main(int argc, char** argv) {\n+  printf(\"PASS\\n\");\n+  return 0;\n }\n \n #else /* XP_UNIX */\n \n-#include \"nspr.h\"\n-#include \"private/pprio.h\"\n-\n-#include <stdio.h>\n-#include <stdlib.h>\n-#include <string.h>\n-#include <errno.h>\n-#include <unistd.h>\n-\n-static void\n-ClientThread(void* arg)\n-{\n-    PRFileDesc* sock;\n-    PRNetAddr addr;\n-    PRUint16 port = (PRUint16)arg;\n-    char buf[1024];\n-    PRInt32 nbytes;\n-\n-    sock = PR_NewTCPSocket();\n-    if (NULL == sock) {\n-        fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_InitializeNetAddr(PR_IpAddrLoopback, port, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Connect failed\\n\");\n-        exit(1);\n-    }\n-    /*\n-     * Sleep 5 seconds to force the server thread to get EAGAIN.\n-     */\n-    if (PR_Sleep(PR_SecondsToInterval(5)) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Sleep failed\\n\");\n-        exit(1);\n-    }\n-    /*\n-     * Then start reading.\n-     */\n-    while (nbytes = PR_Read(sock, buf, sizeof(buf)) > 0) {\n-        /* empty loop body */\n-    }\n-    if (-1 == nbytes) {\n-        fprintf(stderr, \"PR_Read failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Close(sock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n+#  include \"nspr.h\"\n+#  include \"private/pprio.h\"\n+\n+#  include <stdio.h>\n+#  include <stdlib.h>\n+#  include <string.h>\n+#  include <errno.h>\n+#  include <unistd.h>\n+\n+static void ClientThread(void* arg) {\n+  PRFileDesc* sock;\n+  PRNetAddr addr;\n+  PRUint16 port = (PRUint16)arg;\n+  char buf[1024];\n+  PRInt32 nbytes;\n+\n+  sock = PR_NewTCPSocket();\n+  if (NULL == sock) {\n+    fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_InitializeNetAddr(PR_IpAddrLoopback, port, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Connect(sock, &addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Connect failed\\n\");\n+    exit(1);\n+  }\n+  /*\n+   * Sleep 5 seconds to force the server thread to get EAGAIN.\n+   */\n+  if (PR_Sleep(PR_SecondsToInterval(5)) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Sleep failed\\n\");\n+    exit(1);\n+  }\n+  /*\n+   * Then start reading.\n+   */\n+  while (nbytes = PR_Read(sock, buf, sizeof(buf)) > 0) {\n+    /* empty loop body */\n+  }\n+  if (-1 == nbytes) {\n+    fprintf(stderr, \"PR_Read failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Close(sock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n }\n \n-int\n-main()\n-{\n-    PRFileDesc* listenSock;\n-    PRFileDesc* acceptSock;\n-    int osfd;\n-    PRThread* clientThread;\n-    PRNetAddr addr;\n-    char buf[1024];\n-    PRInt32 nbytes;\n-    PRIOVec iov;\n-\n-    memset(buf, 0, sizeof(buf)); /* Initialize the buffer. */\n-    listenSock = PR_NewTCPSocket();\n-    if (NULL == listenSock) {\n-        fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_InitializeNetAddr(PR_IpAddrAny, 0, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Bind(listenSock, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Bind failed\\n\");\n-        exit(1);\n-    }\n-    /* Find out what port number we are bound to. */\n-    if (PR_GetSockName(listenSock, &addr) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_GetSockName failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_Listen(listenSock, 5) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Listen failed\\n\");\n-        exit(1);\n-    }\n-\n-    /*\n-     * First test PR_Writev.\n-     */\n-    clientThread = PR_CreateThread(\n-        PR_USER_THREAD, ClientThread, (void*)PR_ntohs(PR_NetAddrInetPort(&addr)),\n-        PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (NULL == clientThread) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n-    }\n-    acceptSock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n-    if (NULL == acceptSock) {\n-        fprintf(stderr, \"PR_Accept failed\\n\");\n-        exit(1);\n-    }\n-    osfd = PR_FileDesc2NativeHandle(acceptSock);\n-    while (write(osfd, buf, sizeof(buf)) != -1) {\n-        /* empty loop body */\n-    }\n-    if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) {\n-        fprintf(stderr, \"write failed\\n\");\n-        exit(1);\n-    }\n-    iov.iov_base = buf;\n-    iov.iov_len = 0;\n-    printf(\"calling PR_Writev with a zero-length buffer\\n\");\n-    fflush(stdout);\n-    nbytes = PR_Writev(acceptSock, &iov, 1, PR_INTERVAL_NO_TIMEOUT);\n-    if (nbytes != 0) {\n-        fprintf(stderr, \"PR_Writev should return 0 but returns %d\\n\", nbytes);\n-        exit(1);\n-    }\n-    if (PR_Close(acceptSock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_JoinThread(clientThread) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n-    }\n-\n-    /*\n-     * Then test PR_Write.\n-     */\n-    clientThread = PR_CreateThread(\n-        PR_USER_THREAD, ClientThread, (void*)PR_ntohs(PR_NetAddrInetPort(&addr)),\n-        PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (NULL == clientThread) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n-    }\n-    acceptSock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n-    if (NULL == acceptSock) {\n-        fprintf(stderr, \"PR_Accept failed\\n\");\n-        exit(1);\n-    }\n-    osfd = PR_FileDesc2NativeHandle(acceptSock);\n-    while (write(osfd, buf, sizeof(buf)) != -1) {\n-        /* empty loop body */\n-    }\n-    if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) {\n-        fprintf(stderr, \"write failed\\n\");\n-        exit(1);\n-    }\n-    printf(\"calling PR_Write with a zero-length buffer\\n\");\n-    fflush(stdout);\n-    nbytes = PR_Write(acceptSock, buf, 0);\n-    if (nbytes != 0) {\n-        fprintf(stderr, \"PR_Write should return 0 but returns %d\\n\", nbytes);\n-        exit(1);\n-    }\n-    if (PR_Close(acceptSock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_JoinThread(clientThread) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n-    }\n-\n-    /*\n-     * Finally test PR_Send.\n-     */\n-    clientThread = PR_CreateThread(\n-        PR_USER_THREAD, ClientThread, (void*)PR_ntohs(PR_NetAddrInetPort(&addr)),\n-        PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n-    if (NULL == clientThread) {\n-        fprintf(stderr, \"PR_CreateThread failed\\n\");\n-        exit(1);\n-    }\n-    acceptSock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n-    if (NULL == acceptSock) {\n-        fprintf(stderr, \"PR_Accept failed\\n\");\n-        exit(1);\n-    }\n-    osfd = PR_FileDesc2NativeHandle(acceptSock);\n-    while (write(osfd, buf, sizeof(buf)) != -1) {\n-        /* empty loop body */\n-    }\n-    if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) {\n-        fprintf(stderr, \"write failed\\n\");\n-        exit(1);\n-    }\n-    printf(\"calling PR_Send with a zero-length buffer\\n\");\n-    fflush(stdout);\n-    nbytes = PR_Send(acceptSock, buf, 0, 0, PR_INTERVAL_NO_TIMEOUT);\n-    if (nbytes != 0) {\n-        fprintf(stderr, \"PR_Send should return 0 but returns %d\\n\", nbytes);\n-        exit(1);\n-    }\n-    if (PR_Close(acceptSock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    if (PR_JoinThread(clientThread) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_JoinThread failed\\n\");\n-        exit(1);\n-    }\n-\n-    if (PR_Close(listenSock) == PR_FAILURE) {\n-        fprintf(stderr, \"PR_Close failed\\n\");\n-        exit(1);\n-    }\n-    printf(\"PASS\\n\");\n-    return 0;\n+int main() {\n+  PRFileDesc* listenSock;\n+  PRFileDesc* acceptSock;\n+  int osfd;\n+  PRThread* clientThread;\n+  PRNetAddr addr;\n+  char buf[1024];\n+  PRInt32 nbytes;\n+  PRIOVec iov;\n+\n+  memset(buf, 0, sizeof(buf)); /* Initialize the buffer. */\n+  listenSock = PR_NewTCPSocket();\n+  if (NULL == listenSock) {\n+    fprintf(stderr, \"PR_NewTCPSocket failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_InitializeNetAddr(PR_IpAddrAny, 0, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_InitializeNetAddr failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Bind(listenSock, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Bind failed\\n\");\n+    exit(1);\n+  }\n+  /* Find out what port number we are bound to. */\n+  if (PR_GetSockName(listenSock, &addr) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_GetSockName failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_Listen(listenSock, 5) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Listen failed\\n\");\n+    exit(1);\n+  }\n+\n+  /*\n+   * First test PR_Writev.\n+   */\n+  clientThread = PR_CreateThread(\n+      PR_USER_THREAD, ClientThread, (void*)PR_ntohs(PR_NetAddrInetPort(&addr)),\n+      PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (NULL == clientThread) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n+  acceptSock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n+  if (NULL == acceptSock) {\n+    fprintf(stderr, \"PR_Accept failed\\n\");\n+    exit(1);\n+  }\n+  osfd = PR_FileDesc2NativeHandle(acceptSock);\n+  while (write(osfd, buf, sizeof(buf)) != -1) {\n+    /* empty loop body */\n+  }\n+  if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) {\n+    fprintf(stderr, \"write failed\\n\");\n+    exit(1);\n+  }\n+  iov.iov_base = buf;\n+  iov.iov_len = 0;\n+  printf(\"calling PR_Writev with a zero-length buffer\\n\");\n+  fflush(stdout);\n+  nbytes = PR_Writev(acceptSock, &iov, 1, PR_INTERVAL_NO_TIMEOUT);\n+  if (nbytes != 0) {\n+    fprintf(stderr, \"PR_Writev should return 0 but returns %d\\n\", nbytes);\n+    exit(1);\n+  }\n+  if (PR_Close(acceptSock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_JoinThread(clientThread) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+\n+  /*\n+   * Then test PR_Write.\n+   */\n+  clientThread = PR_CreateThread(\n+      PR_USER_THREAD, ClientThread, (void*)PR_ntohs(PR_NetAddrInetPort(&addr)),\n+      PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (NULL == clientThread) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n+  acceptSock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n+  if (NULL == acceptSock) {\n+    fprintf(stderr, \"PR_Accept failed\\n\");\n+    exit(1);\n+  }\n+  osfd = PR_FileDesc2NativeHandle(acceptSock);\n+  while (write(osfd, buf, sizeof(buf)) != -1) {\n+    /* empty loop body */\n+  }\n+  if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) {\n+    fprintf(stderr, \"write failed\\n\");\n+    exit(1);\n+  }\n+  printf(\"calling PR_Write with a zero-length buffer\\n\");\n+  fflush(stdout);\n+  nbytes = PR_Write(acceptSock, buf, 0);\n+  if (nbytes != 0) {\n+    fprintf(stderr, \"PR_Write should return 0 but returns %d\\n\", nbytes);\n+    exit(1);\n+  }\n+  if (PR_Close(acceptSock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_JoinThread(clientThread) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+\n+  /*\n+   * Finally test PR_Send.\n+   */\n+  clientThread = PR_CreateThread(\n+      PR_USER_THREAD, ClientThread, (void*)PR_ntohs(PR_NetAddrInetPort(&addr)),\n+      PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);\n+  if (NULL == clientThread) {\n+    fprintf(stderr, \"PR_CreateThread failed\\n\");\n+    exit(1);\n+  }\n+  acceptSock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);\n+  if (NULL == acceptSock) {\n+    fprintf(stderr, \"PR_Accept failed\\n\");\n+    exit(1);\n+  }\n+  osfd = PR_FileDesc2NativeHandle(acceptSock);\n+  while (write(osfd, buf, sizeof(buf)) != -1) {\n+    /* empty loop body */\n+  }\n+  if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) {\n+    fprintf(stderr, \"write failed\\n\");\n+    exit(1);\n+  }\n+  printf(\"calling PR_Send with a zero-length buffer\\n\");\n+  fflush(stdout);\n+  nbytes = PR_Send(acceptSock, buf, 0, 0, PR_INTERVAL_NO_TIMEOUT);\n+  if (nbytes != 0) {\n+    fprintf(stderr, \"PR_Send should return 0 but returns %d\\n\", nbytes);\n+    exit(1);\n+  }\n+  if (PR_Close(acceptSock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  if (PR_JoinThread(clientThread) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_JoinThread failed\\n\");\n+    exit(1);\n+  }\n+\n+  if (PR_Close(listenSock) == PR_FAILURE) {\n+    fprintf(stderr, \"PR_Close failed\\n\");\n+    exit(1);\n+  }\n+  printf(\"PASS\\n\");\n+  return 0;\n }\n \n #endif /* XP_UNIX */\ndiff --git a/nspr/tools/.cvsignore b/nspr/tools/.cvsignore\nnew file mode 100644\nindex 0000000..f3c7a7c\n--- /dev/null\n+++ b/nspr/tools/.cvsignore\n@@ -0,0 +1 @@\n+Makefile\ndiff --git a/nspr/tools/httpget.c b/nspr/tools/httpget.c\nindex 17fd4c8..638f1db 100644\n--- a/nspr/tools/httpget.c\n+++ b/nspr/tools/httpget.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndiff --git a/nspr/tools/tail.c b/nspr/tools/tail.c\nindex abde847..98378da 100644\n--- a/nspr/tools/tail.c\n+++ b/nspr/tools/tail.c\n@@ -1,3 +1,4 @@\n+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n /* This Source Code Form is subject to the terms of the Mozilla Public\n  * License, v. 2.0. If a copy of the MPL was not distributed with this\n  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n","remote_name":"master","revision":"git-v1:0ea5e81e77a9f849b4652916d89170cd6dffd82f","role":"main"}],"result_code":"success","result_tags":[],"revision":"git-v1:0ea5e81e77a9f849b4652916d89170cd6dffd82f","start_time":"2026-11-08T14:09:06.466428Z","subpath":"","suite":"control","target_branch_url":null,"vcs_type":"git","worker":"tyr"},"run_id":"a54043ef-fdfa-4c26-a02a-915e77d04fd1","success_probability":1.0,"suite":"control","total_previous_runs":1,"utcnow":"2026-11-09T03:36:04.427928234+00:00","vcs_type":"git","vcs_url":"git+ssh://git@salsa.debian.org/mozilla-team/nspr.git","version":"0.0.0","worker_log_name":"worker.log","worker_name":"tyr"}